You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I call $generateHtmlFromNodes with both an editor and a selection, it only returns the HTML for nodes/text in both the editorState's selection (what the user selected) and the selection object I pass to the call. For example, if I pass a node selection with nodes A,B,C, and the user has only selected B, then it only exports the HTML for B.
Lexical version:
Steps To Reproduce
Register an update listener
Get all nodes of a certain type
For each node
Create a node selection and add that node's key
Run $generateHtmlFromNodes using that selection
Create a few lines/nodes, and change the selection
When you have multiple nodes, it will always output the currently selected node (or wherever the cursor currently is)
To replicate, replace MyCustomAutoFocusPlugin.js in the example codesandbox, with this:
Thank you for your response. I was not aware that node selection were exclusivly for decorator nodes. The documentation says that NodeSelections are "selection[s] of multiple arbitrary nodes", so I assumed I could use them for any nodes. In my code, I'm using them to select a custom ElementNode subclass (and its children), but for my example code it was easier to work with text nodes.
I still have the issue if I use a range selection instead of a node selection. When I modify MyCustomAutoFocusPlugin.js to the following, $generateHtmlFromNodes returns the html for the user-selected string, not the RangeSelection I pass to it.
Activity
thegreatercurve commentedon Jan 31, 2023
Node selections are exclusively for decorator nodes. Do you have this same issue if you apply a range selection to the stated array of nodes?
SeanBrodyWP commentedon Feb 2, 2023
Thank you for your response. I was not aware that node selection were exclusivly for decorator nodes. The documentation says that NodeSelections are "selection[s] of multiple arbitrary nodes", so I assumed I could use them for any nodes. In my code, I'm using them to select a custom ElementNode subclass (and its children), but for my example code it was easier to work with text nodes.
I still have the issue if I use a range selection instead of a node selection. When I modify MyCustomAutoFocusPlugin.js to the following, $generateHtmlFromNodes returns the html for the user-selected string, not the RangeSelection I pass to it.