-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Insert in whitespaces #59
Comments
@artemisIrelia : white spaces in middle of text is considered as white space only and not converted to |
@artemisIrelia if you display the parsed state into something other than a
|
I know this is an old issue (yet it is still marked as open), so a solution that I used for such a problem (where it trimmed the multiple whitespaces from the start or end of the blocks), was to use a simple regex to convert all whitespaces into a // If there is text get its value and send it to the consumer
const value: string = draftToHTML(convertToRaw(editor.getCurrentContent()));
// Convert every whitespace in the text into a ` ` HTML code
// that adds the option to have multiple whitespaces one after another
const addedWhitespaceCharacters = value.replace(/\s(?=[\w\s\d])/g, " ");
onEditorChange(addedWhitespaceCharacters); This will convert all the whitespaces that are followed by: another whitespace, a word or a digit. |
Currently when I insert spaces in draftjs editor, draftToHtml(convertToRaw(editorState.getCurrentContent()))
does not convert whitespaces to nbsp when not at the end/start of a block.
How do I put nbsp; in the middle of paragraph tags as well?
The text was updated successfully, but these errors were encountered: