Created
November 8, 2017 14:18
-
-
Save ddelrio1986/30428183bb6b449033d7d23393beab34 to your computer and use it in GitHub Desktop.
DraftJS ContentState Logger
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const contentStateLogger = editorState => { | |
const result = JSON.stringify(convertToRaw(editorState.getCurrentContent()), null, 4); | |
const newResult = JSON.parse(result); | |
const contentState = JSON.stringify(newResult, null, 4); | |
// unquotes object keys | |
const keyQuotes = /"(.+)"(?=:)/g; | |
const newContentState = contentState.replace(keyQuotes, '$1'); | |
console.log(newContentState); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment