Open totorofly opened 1 year ago
Can you please share if any update on this?
We are also facing similar issue with Undo/History.
If the Heading Tag involved in the selection along with more than 4-6 paragraphs, the Undo takes more clicks to get the content back. This creates the illusion that content is lost. Also noted that if there are More heading tag it take those many undo clicks (But the selection involves as i mentioned above only)
Which packages did you experience the bug in?
@tiptap/core
What Tiptap version are you using?
2.0.4
What’s the bug you are facing?
I am using Tiptap's NodeView capability to extend the heading NodeView. After adding the following:
I encounter an issue where the content of the line being modified gets deleted each time editor.commands.setHeading({ level: level }) is invoked when switching between different heading levels (e.g., H1 to H2, H2 to H1). However, if I switch from a heading to a normal paragraph or vice versa using (editor.commands as any).setParagraph(), there's no problem.
This deletion operation seems to be recorded in the history because executing an undo operation via Tiptap's history extension requires two clicks to restore the content.
However, some additional peculiar behavior I noticed is:
When switching from a normal paragraph to H1, the content does not get lost. When switching from H1 to H2, the content gets lost. But then, when switching from H2 back to a normal paragraph, the content is automatically restored.
I suspect this issue might be related to how NodeView handles the saving and restoring of node content during type conversion, and might require a better way to handle node content in NodeView during update, destroy, or create methods. Any help or insights would be appreciated.
Here's the NodeViewSideToolBar component code:
Please let me know if there's anything I'm doing wrong or if there's a workaround or solution for this issue.
What browser are you using?
Edge
Code example
No response
What did you expect to happen?
I expected the content of the headings to persist when changing the heading level, whether from H1 to H2, H2 to H1, or from a heading to a normal paragraph and vice versa. No content should be lost during these transitions. Also, the history of operations should accurately reflect the actions performed by the user without any extraneous steps.
In summary, the expected behavior is for the editor.commands.setHeading({ level: level }) command to simply change the heading level while preserving the existing content within the heading.
Anything to add? (optional)
No response
Did you update your dependencies?
Are you sponsoring us?