Skip to content

control content by trigger function #299

Answered by lin-mt
lin-mt asked this question in Q&A
Discussion options

You must be logged in to vote
const [editor, setEditor] = useState<any>();

const focusAndAddText = () => {
  if (editor) {
    var result ="new value";
    var position = editor.getSelection();
    editor.executeEdits("", [{range: position, text: result}]);
    editor.focus();
  }
}

const handleEditorOnMount = (editor: any) => {
  setEditor(editor);
}

<Editor
  onMount={handleEditorOnMount}
/>

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by lin-mt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant