I have this code that uses draft-js and markdown-draft-js libraries. I want you to…
Jump to turn (7)
- 1I have this code that uses draft-js and markdown-draft-js libraries. I want you
- 2Currently, if within the function markdownToDraft the current input value would
- 3I get the error 'Property 'getSelection' does not exist on type 'ContentState' a
- 4You didn't change anything
- 5markdownToDraft(input.slice(0, remainingLength), { remarkableOptions: { disable:
- 6if my draft.js raw js object is an ordered list but it looses its numbers as a p
- 7How do I convert a string using draft.js into ContentState?
- User
I have this code that uses draft-js and markdown-draft-js libraries. I want you to analyze it and tell me what it does. const addPastedContent = (input: any, state: EditorState): void => { const inputLength = state.getCurrentContent().getPlainText().length; const remainingLength = MAX_MESSAGE_LENGTH - inputLength; const converted = convertFromRaw( markdownToDraft(input.slice(0, remainingLength), { remarkableOptions: { disable: { inline: ['links', 'emphasis'], block: ['heading'], }, }, }), );
codeconst newState = Modifier.replaceWithFragment( state.getCurrentContent(), state.getSelection(), converted.getBlockMap(), ); const newEditorState = EditorState.push( editorState, newState, 'insert-characters', ); handleChange(EditorState.forceSelection(newEditorState, newEditorState.getSelection())); }; - Assistant