When trying to import lengthy html to draft state most browsers (Chrome, Firefox, Safari) crash with call stack exceeded error.
Steps to reproduce:
- (In a react app with react-draft-wysiwyg) in constructer convert html
- convert large html string (in my case 75,000+ characters) to draftjs using
stateFromHTML()
- Import will not complete, giving:
RangeError: Maximum callstack size exceeded
To solve this I ended up using
import DraftPasteProcessor from 'draft-js/lib/DraftPasteProcessor'
const processedHTML = DraftPasteProcessor.processHTML(value);
const contentState = ContentState.createFromBlockArray(processedHTML);
editorState = EditorState.createWithContent(contentState);
From draftjs own utils.
When trying to import lengthy html to draft state most browsers (Chrome, Firefox, Safari) crash with call stack exceeded error.
Steps to reproduce:
stateFromHTML()RangeError: Maximum callstack size exceededTo solve this I ended up using
From draftjs own utils.