fix: live-reload theme CSS vars on editor save and frontmatter changes

Wire notifyThemeSaved through the frontmatter update chain so CSS
variables update immediately when:
- The user edits a theme note in raw mode and presses Cmd+S
- A frontmatter property is changed via the inspector panel

Also expose CodeMirror EditorView on the DOM for Playwright test access,
add unit tests for onNotePersisted, and a new Playwright smoke test
that verifies the full raw-editor → save → CSS-vars-update flow.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
lucaronin
2026-03-19 00:57:34 +01:00
parent 7db3c2f00a
commit 8f6da24ef5
6 changed files with 178 additions and 8 deletions

View File

@@ -126,6 +126,9 @@ export function useCodeMirror(
const view = new EditorView({ state, parent })
viewRef.current = view
// Expose EditorView on the parent DOM for Playwright test access
// eslint-disable-next-line @typescript-eslint/no-explicit-any
;(parent as any).__cmView = view
// When CSS zoom changes on the document, CodeMirror's cached measurements
// (scaleX/scaleY, line heights, character widths) become stale because
@@ -136,6 +139,8 @@ export function useCodeMirror(
return () => {
window.removeEventListener('laputa-zoom-change', handleZoomChange)
// eslint-disable-next-line @typescript-eslint/no-explicit-any
delete (parent as any).__cmView
view.destroy()
viewRef.current = null
}