Skip to content

feat: add undo and redo to rich text fields - #141

Merged
rimzzlabs merged 1 commit into
mainfrom
feat/rich-text-undo-redo
Aug 3, 2026
Merged

feat: add undo and redo to rich text fields#141
rimzzlabs merged 1 commit into
mainfrom
feat/rich-text-undo-redo

Conversation

@rimzzlabs

Copy link
Copy Markdown
Owner

Part of #137.

The rich-text fields had no history at all. buildRichTextExtensions registered Document, Paragraph, Text and the opt-in marks, and never a history plugin, so ProseMirror had nothing to undo against and Cmd+Z was a dead key in every description field. This registers TipTap's UndoRedo extension and adds undo and redo buttons at the head of the field toolbar, disabled when there is nothing to undo or redo.

UndoRedo is a plugin over the transaction stream rather than a node or mark, so it adds nothing to the restricted schema and leaves export structure untouched. It ships in @tiptap/extensions, pinned to 3.27.1 to match the rest of the TipTap packages. History is per field and per mount: each editor instance keeps its own stack, and closing a section unmounts its editors and drops theirs.

This does not give the document a global undo. Reordering sections, toggling visibility, and edits made in the plain inputs are outside a rich-text field's history, so #137 stays open.

Testing

Typed into a summary field and pressed Cmd+Z: the text returned to exactly its previous content, and Cmd+Shift+Z put it back. The toolbar buttons do the same thing, start out disabled on a freshly opened field, and the undo button enables as soon as there is an edit to take back. An undo also flows through to the live preview, so the reverted text disappears from the rendered page and from what would be exported.

Signed-off-by: Rizki Citra <rimzzlabs@proton.me>
@rimzzlabs
rimzzlabs merged commit 94e95f4 into main Aug 3, 2026
4 checks passed
@rimzzlabs
rimzzlabs deleted the feat/rich-text-undo-redo branch August 3, 2026 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant