Skip to content

Tiptap RTE: Add delete action support for RTE blocks (closes #21345)#21615

Merged
iOvergaard merged 1 commit intomainfrom
v17/feature/block-rte-delete
Feb 4, 2026
Merged

Tiptap RTE: Add delete action support for RTE blocks (closes #21345)#21615
iOvergaard merged 1 commit intomainfrom
v17/feature/block-rte-delete

Conversation

@leekelleher
Copy link
Copy Markdown
Member

@leekelleher leekelleher commented Feb 3, 2026

Prerequisites

  • I have added steps to test this contribution in the description below

Description

Adds a delete button to RTE block entries that removes blocks from both the editor HTML and the block manager data. Implements an HTML-first deletion approach that enables Ctrl+Z undo support by leveraging the existing _filterUnusedBlocks mechanism.

This is a partial fix towards #21345.

Changes

  • block-rte-entry.element.ts: Add delete button to action bar
  • block-rte-manager.context.ts: Add pendingDeletions state and methods for HTML-first deletion flow
  • block-rte-entries.context.ts: Override delete() to use pending deletion mechanism
  • block.tiptap-api.ts: Add observer to process pending deletions and remove blocks from editor via ProseMirror transactions

How it works

  1. User clicks delete button → confirmation modal appears
  2. After confirmation, contentKey is added to pendingDeletions on the manager
  3. Tiptap API observes pendingDeletions → removes HTML from editor (creating undo history)
  4. Tiptap's onUpdate fires → _filterUnusedBlocks runs
  5. _filterUnusedBlocks stores block data in lookup maps (enabling undo) and removes from manager
  6. User can press Ctrl+Z → Tiptap restores HTML → _restoreUnusedBlocks restores data

How to test

  1. Create a document type with an RTE property that has blocks enabled
  2. Add a block to the RTE
  3. Hover over the block to see the action bar
  4. Click the delete button (trash icon)
  5. Confirm the deletion in the modal
  6. Verify: Block should disappear from the editor
  7. Press Ctrl+Z (undo)
  8. Verify: Block should reappear with its data restored
  9. Save and reload to verify persistence

🤖 Generated with Claude Code

Adds a delete button to RTE block entries that removes blocks from
both the editor HTML and the block manager data. Implements an
HTML-first deletion approach that enables Ctrl+Z undo support by
leveraging the existing _filterUnusedBlocks mechanism.

- Add delete button to block-rte-entry action bar
- Add pendingDeletions state to manager for HTML-first deletion flow
- Modify entries context to use pending deletion mechanism
- Add Tiptap API observer to process pending deletions
- Remove blocks from editor via ProseMirror transactions

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@leekelleher leekelleher changed the base branch from contrib to main February 3, 2026 15:35
@leekelleher leekelleher changed the title Block RTE: Add delete action with undo support Tiptap RTE: Add delete action support for RTE blocks Feb 3, 2026
@iOvergaard iOvergaard merged commit bd3d2e1 into main Feb 4, 2026
20 checks passed
@iOvergaard iOvergaard deleted the v17/feature/block-rte-delete branch February 4, 2026 08:00
@AndyButland AndyButland changed the title Tiptap RTE: Add delete action support for RTE blocks Tiptap RTE: Add delete action support for RTE blocks (closes #21345) Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants