Live mermaid preview while editing + handle alignment fix#26
Merged
Conversation
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Mermaid blocks share the 'code' slice type with regular code fences but render as <div.mermaid-container> rather than <pre><code>. The 13px handle offset tuned for <pre>'s 16px top padding plus 85% font lines was pushing the handle down into the diagram. Override to 0px for mermaid via :has(.mermaid-container) so the handle sits at the slice's top edge — aligned with the diagram's bounding box. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Move preview imports to the top of the file, nest describe('getPreviewablePlugins')
inside the main describe('PluginManager'), and add a negative-case test that confirms
registered-but-not-enabled previewable plugins are excluded from the result.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…urce - Add test: raw with no fences round-trips unchanged - Add test: raw with opening fence but no closing fence strips only the opener - Change trim() → trimEnd() on the closing-fence check to match the trimStart() used on the opening-fence check (symmetry fix) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ring Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ling Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Wire previewable plugin detection into EditModeController.startEdit so mermaid (and any future PreviewablePlugin) slices open with live preview above source. Factor the post-update re-render logic from commitRawEdit into a shared applyRawCommit helper used by both paths. Non-previewable code slices now also fall back to raw editing instead of WYSIWYG. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two things in this branch:
Live mermaid preview while editing — clicking a ```mermaid``` block in edit mode now opens a preview-above-source surface. The rendered diagram stays visible at the top; a textarea sits below; the diagram re-renders ~250ms after each keystroke. Invalid mermaid syntax keeps the last good preview visible and surfaces the error in an inline chip between preview and textarea. `Esc` commits, click-away commits, race conditions are handled by per-call scratch containers and monotonic request IDs.
Slice handle alignment for mermaid blocks — `slice-code:has(.mermaid-container)` override sets `--slice-handle-top: 0px` since mermaid blocks render as `<div.mermaid-container>` rather than `
Architecture (generalised)
The live preview is built on a new optional plugin capability — `PreviewablePlugin` — so any plugin that owns a fenced code block and can render to visual content can opt into the same editing surface. Mermaid is the first implementer; future plugins (math, graphviz, embedded HTML, etc.) get live preview for free by implementing four methods.
Stats
Spec and plan
Test plan
🤖 Generated with Claude Code