ianstormtaylor / slate

A completely customizable framework for building rich text editors. (Currently in beta.)
http://slatejs.org
MIT License
30.03k stars 3.26k forks source link

Missing of value={value} and I am out of ideas PLS HELP!! #5488

Open Alllexklar opened 1 year ago

Alllexklar commented 1 year ago

Problem How can I change the content of my editor programmatically without causing an onChange. I am trying to update the content of my editor with socket io and I am out of ideas. Apparently in the version of Slate + Editable there is no such thing as value={value} and then onChange(setValue()) soooo...

<Slate editor={editor} initialValue={value} onChange={handleChange}>
  <div className="Editor-block">
    <Editable
      className="text-field"
      // for basic functionality
      renderElement={renderElement}
      renderLeaf={renderLeaf}
      // if editor is focused it passes down the element for formating
      onFocus={() => {
        handleEditorFocus(editor);
      }}
      // adding shortcuts for formating
      onKeyDown={onTextFieldKeyDown}
      value={editorValue}
      ref
      //contentEditable
    />
  </div>
</Slate>

Context "dependencies": { "react": "^18.2.0", "react-dom": "^18.2.0", "slate": "^0.94.1", "slate-history": "^0.93.0", "slate-react": "^0.97.2", "socket.io-client": "^4.7.1", "uuid": "^9.0.0"

surjit commented 1 year ago

I'm facing same problem to reset editor value after submitting to API @Alllexklar any update?