Estaba tratando de implementar la funcionalidad de arrastrar y soltar dentro del editor. Puedo arrastrar y soltar el valor dentro del editor, pero el problema es que cuando trato de soltar otro valor, la cadena no se concatena.
Codesandbox: lo que probé
const EditorComponent = ({ editorState, setEditorState }) => { const onChange = async (value) => { setEditorState(value); }; const insertText = (text, editorValue) => { const currentContent = editorValue.getCurrentContent(); const currentSelection = editorValue.getSelection(); const newContent = Modifier.replaceText( currentContent, currentSelection, text ); const newEditorState = EditorState.push( editorValue, newContent, "insert-characters" ); return EditorState.forceSelection( newEditorState, newContent.getSelectionAfter() ); }; const sendTextToEditor = (text) => { setEditorState(insertText(text, editorState)); }; const [{ isOver }, drop] = useDrop(() => ({ accept: "button", drop: (item) => sendTextToEditor(item.id), collect: (monitor) => ({ isOver: !!monitor.isOver() }) })); return ( <div ref={drop}> <Editor editorState={editorState} ... onEditorStateChange={(value) => { onChange(value); }} /> </div> ); }; export default EditorComponent;