Transform selection into a stand-alone new editor state #4757
Unanswered
mariusplanable
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hola amigos,
Trying to achieve the following:
Having a selection in the editor (which may stretch across different types of nodes) to extract somehow the selected nodes and instantiate a new editor from them. Imagine you want to select a part of editor content and suggest a change to it, so after selection a new floating editor would pop up with the selection as the initial state.
What I'm currently doing (which is working OKish for plain text, but not really for rich text) is trying to create a serialized editor state (something
editor.getEditorState().toJSON()would return) by traversingselection.getNodes()and trimming the anchor/focus nodes to the selection offsets. Then, this serialized editor state would be provided to the new editor. There a multiple use-cases to handle with such an approach, like for example selecting part of aListNodeonly, or having the selection starting into aMarkNode.I am wondering if there is an easier way to create a standalone editor state from a selection.
Thanks in advance for any input which will be much appreciated.
Beta Was this translation helpful? Give feedback.
All reactions