-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Tiptap RTE: Undo deleted blocks #19851
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Maintains a state of unused (deleted) blocks, that could be restored later, e.g. with Tiptap RTE's undo action. Fixes #19637
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements undo functionality for deleted blocks in the Tiptap RTE by maintaining a cache of unused block data that can be restored when the RTE's undo action brings back previously deleted blocks.
- Adds lookup maps to cache deleted block layout, content, and settings data
- Implements restoration logic to re-add cached block data when content keys are referenced again
- Adds proper cleanup in the destroy method to prevent memory leaks
src/Umbraco.Web.UI.Client/src/packages/rte/components/rte-base.element.ts
Outdated
Show resolved
Hide resolved
src/Umbraco.Web.UI.Client/src/packages/rte/components/rte-base.element.ts
Outdated
Show resolved
Hide resolved
src/Umbraco.Web.UI.Client/src/packages/rte/components/rte-base.element.ts
Show resolved
Hide resolved
Will this fix also solve a similar problem that occurs when you try to cut and paste a block? |
@nikolaj-kaplan Yes, this patch will support cut-and-paste of block elements. 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just testing this out - looks to work but there's a couple of glitches I found.
- With an entered block looking like this:

Once I remove it and undo to restore it, it comes back like this (note greyed out, and with a + icon instead of an edit one - though clicking the + does allow to edit):

- You can copy/paste a block within an editor, which works fine. But then if you edit the copied block, it'll update the settings on the original one too.
@AndyButland, This seems to happen on variant pages. I'll look into a fix.
I suspect the same happens outside of this PR. Definitely something for us to look into further. 🕵️ |
@AndyButland I've patched up the issue on variant documents, ready to re-review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Working as expected now for point 1, as I understand for point 2 it's not caused in this PR so will be tackled separately.
Description
Fixes #19637.
Enables RTE Blocks to be "un-deleted", with the RTE's undo action.
In the RTE property-editor base class, a state of unused (deleted) blocks is maintained, so that if an RTE's undo action restores a block in the markup, the unused block data can be re-added.
How to test?
In a Tiptap RTE, try adding a block element (with data, content and/or settings), now delete the block to remove it from the RTE, then perform an undo action (either by the undo toolbar button or keyboard shortcut CTRL+Z). The block should be restored and content/settings property data is still present.