Skip to content

Add undo/redo support to editable CodeBlock#3288

Merged
Alex-Tideman merged 3 commits intomainfrom
undo-redo
Apr 13, 2026
Merged

Add undo/redo support to editable CodeBlock#3288
Alex-Tideman merged 3 commits intomainfrom
undo-redo

Conversation

@Alex-Tideman
Copy link
Copy Markdown
Collaborator

@Alex-Tideman Alex-Tideman commented Apr 9, 2026

Enable CodeMirror's history() extension so existing historyKeymap keybindings (Cmd+Z / Cmd+Shift+Z) actually work. Annotate programmatic content replacements with addToHistory: false to keep prop syncs and blur reformats out of the undo stack.

Description & motivation 💭

Summary

  • Enable CodeMirror's history() extension so the existing historyKeymap keybindings (Cmd+Z / Cmd+Shift+Z) actually perform undo/redo in editable code blocks
  • Annotate programmatic content replacements (replaceContent) with addToHistory: false to prevent prop syncs and blur reformats from polluting the undo stack

Context

The CodeBlock component already imported historyKeymap from @codemirror/commands and wired it into the keymap, but never registered the history() extension that provides the actual undo/redo state tracking. The keybindings were present but silently no-op'd because there was no history state to operate on.

Test plan

  • Open an editable CodeBlock (e.g. Workflow input/payload editor)
  • Type some changes
  • Press Cmd+Z (Mac) / Ctrl+Z (Windows/Linux) — changes should undo
  • Press Cmd+Shift+Z (Mac) / Ctrl+Y (Windows/Linux) — changes should redo
  • Edit content, blur the editor (click outside), then undo — the blur reformat should not appear in the undo stack
  • Verify read-only CodeBlocks are unaffected

Screenshots (if applicable) 📸

Undo.Redo.CodeBlock.mov

Design Considerations 🎨

Testing 🧪

How was this tested 👻

  • Manual testing
  • E2E tests added
  • Unit tests added

Steps for others to test: 🚶🏽‍♂️🚶🏽‍♀️

Checklists

Draft Checklist

Merge Checklist

Issue(s) closed

Docs

Any docs updates needed?

Enable CodeMirror's history() extension so existing historyKeymap
keybindings (Cmd+Z / Cmd+Shift+Z) actually work. Annotate
programmatic content replacements with addToHistory: false to keep
prop syncs and blur reformats out of the undo stack.
@Alex-Tideman Alex-Tideman requested a review from a team as a code owner April 9, 2026 18:30
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 9, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
holocene Ready Ready Preview, Comment Apr 10, 2026 8:27pm

Request Review

@temporal-cicd
Copy link
Copy Markdown
Contributor

temporal-cicd bot commented Apr 9, 2026

Warnings
⚠️

📊 Strict Mode: 6 errors in 1 file (0.6% of 1085 total)

src/lib/holocene/code-block.svelte (6)
  • L146:32: 'editorView.contentHeight' is possibly 'undefined'.
  • L166:24: Type 'number | boolean' is not assignable to type 'boolean'.
  • L174:23: Type 'number | undefined' is not assignable to type 'number'.
  • L174:34: Type 'number | undefined' is not assignable to type 'number'.
  • L186:8: 'editorView' is possibly 'undefined'.
  • L285:30: Type 'boolean | 0' is not assignable to type 'boolean | undefined'.

Generated by 🚫 dangerJS against 906b0b1

let dynamicExtensions: Extension[] = $derived(
[
...(editable ? [history()] : []),
getEditorTheme($useDarkMode, hasHeader),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • ⚠️ Type 'number | boolean' is not assignable to type 'boolean'.

@Alex-Tideman Alex-Tideman merged commit 59c95f8 into main Apr 13, 2026
19 checks passed
@Alex-Tideman Alex-Tideman deleted the undo-redo branch April 13, 2026 14:35
temporal-cicd bot pushed a commit that referenced this pull request Apr 14, 2026
Auto-generated version bump from 2.48.2 to 2.48.3

Specific version: 2.48.3

Changes included:
- [`59c95f8b`](59c95f8) Add undo/redo support to editable CodeBlock (#3288)
- [`89269c62`](89269c6) chore: bump go.temporal.io/api to v1.62.8 and update go.sum (#3298)
- [`8e795d8a`](8e795d8) Worker insights (#3087)
- [`c58019ae`](c58019a) Use CountSchedules API (#3258)
- [`a0d20fcc`](a0d20fc) Add optional initial name to search attribute defintion (#3303)
- [`cbaf7549`](cbaf754) DT-3655 - add external payload count and size to workflow details (#3276)
- [`0fe2b33c`](0fe2b33) Remove by-type option for activity commands (#3284)
laurakwhit added a commit that referenced this pull request Apr 14, 2026
Auto-generated version bump from 2.48.2 to 2.48.3

Specific version: 2.48.3

Changes included:
- [`59c95f8b`](59c95f8) Add undo/redo support to editable CodeBlock (#3288)
- [`89269c62`](89269c6) chore: bump go.temporal.io/api to v1.62.8 and update go.sum (#3298)
- [`8e795d8a`](8e795d8) Worker insights (#3087)
- [`c58019ae`](c58019a) Use CountSchedules API (#3258)
- [`a0d20fcc`](a0d20fc) Add optional initial name to search attribute defintion (#3303)
- [`cbaf7549`](cbaf754) DT-3655 - add external payload count and size to workflow details (#3276)
- [`0fe2b33c`](0fe2b33) Remove by-type option for activity commands (#3284)

Co-authored-by: laurakwhit <15069288+laurakwhit@users.noreply.github.com>
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.

3 participants