Skip to content

fix(editor): apply node inline styles in read-only composed canvas content#54

Merged
DavidBabinec merged 2 commits into
mainfrom
fix/template-preview-inline-styles
Jun 13, 2026
Merged

fix(editor): apply node inline styles in read-only composed canvas content#54
DavidBabinec merged 2 commits into
mainfrom
fix/template-preview-inline-styles

Conversation

@DavidBabinec

Copy link
Copy Markdown
Contributor

What changed

ReadOnlyNodeTree — the shared renderer for all composed, non-editable canvas content (wrapping template chrome, a template's outlet preview, inlined Visual Component bodies) — rendered nodes without their inlineStyles, while both the editable canvas (NodeRenderer) and the publisher (injectNodeInlineStyles) apply them.

Symptom (reported on the demo site): the homepage hero h1 carries style="font-size: clamp(46px, 10.5vw, 138px)". Editing the page directly shows it at ~138px; previewing the same page while editing the Main template collapsed it to the base heading size — and degraded the rest of the hero too, since the demo content uses inline styles pervasively (margin-bottom, max-width, font-size, …).

Fix:

  • New bagToReactStyle in @core/publisher (classCss.ts), next to bagToCSS / bagToInlineStyle, behind the same isEmittableProperty / sanitiseCssValue gate — one sanitisation source for every emission surface.
  • ReadOnlyNodeTree now applies each node's inlineStyles via that helper. A forwarded root wrapper bag's style (the VC-ref case) is appended after the node's own declarations, matching the publisher's append order in renderVisualComponentRef (owning node wins per property).
  • Deleted the admin-only duplicate getCanvasNodeInlineStyle; NodeRenderer uses the core helper.
  • Documented the fidelity contract in docs/features/templates.md and the ReadOnlyNodeTree header.

Why

Template-edit mode is advertised as a pixel-identical preview of how the page publishes. Dropping the per-node inline-style layer made composed content visibly drift from both the editable canvas and the published output.

Impact

Template chrome, outlet previews, and inlined VC bodies on the canvas now render the same style="…" the published page ships. No publisher/output changes.

Verification

  • bun test — 5393 pass (includes new src/__tests__/editor/readOnlyNodeTree.test.tsx: DOM wiring, sanitisation gate, root-bag merge order, clamp() passthrough)
  • bun run build — clean
  • bun run lint — clean

🤖 Generated with Claude Code

…ntent

ReadOnlyNodeTree (template chrome, outlet previews, inlined VC bodies)
rendered nodes without their inlineStyles, so a page previewed inside a
template's outlet lost every style="…" the publisher emits — the demo
hero h1 (font-size: clamp(46px, 10.5vw, 138px)) collapsed to the base
heading size when editing the Main template, while editing the page
directly showed it correctly.

The inline-style React conversion now lives in @core/publisher as
bagToReactStyle, next to bagToCSS/bagToInlineStyle and behind the same
isEmittableProperty/sanitiseCssValue gate, replacing the admin-only
getCanvasNodeInlineStyle duplicate. ReadOnlyNodeTree applies each
node's own styles and appends a forwarded root bag's style after them,
matching renderVisualComponentRef's append order (owning node wins).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@DavidBabinec DavidBabinec marked this pull request as ready for review June 13, 2026 07:25
@DavidBabinec DavidBabinec merged commit 01c9fe7 into main Jun 13, 2026
@DavidBabinec DavidBabinec deleted the fix/template-preview-inline-styles branch June 13, 2026 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant