Skip to content
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

nbsp not working when adding the HTML back into Wysiwyg #1418

Open
TrofinSorin opened this issue Jan 24, 2024 · 0 comments
Open

nbsp not working when adding the HTML back into Wysiwyg #1418

TrofinSorin opened this issue Jan 24, 2024 · 0 comments

Comments

@TrofinSorin
Copy link

TrofinSorin commented Jan 24, 2024

I'm saving the HTML to my database and when entering the modal that contains this WYSIWYG.

I need to add back to the WYSIWYG this HTML:
<h1>1</h1>\n<h1>&nbsp;&nbsp;2</h1>\n<h1>3</h1>\n

Which will look something like this:

 1
   2
 3 

This is what I'm using to set the editor state to populate the WYSIWYG.

const [editorState, setEditorState] = useState(EditorState.createEmpty());
const blocksFromHTML = convertFromHTML(messageFromBackend);
      const contentState = ContentState.createFromBlockArray(
        blocksFromHTML.contentBlocks,
        blocksFromHTML.entityMap
      );

// Update the editorState with the new content
setEditorState(EditorState.createWithContent(contentState));

This is the HTML:

<Editor
        editorState={editorState}
        wrapperClassName="demo-wrapper"
        editorClassName="demo-editor"
        onEditorStateChange={onEditorStateChange}
      />

I need the nbsp to show inside wysiwyg when setting the state with what i've saved from WYSIWYG initiality

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant