feat(pages): on-page visual editor for landing pages #64

Merged
ngqile merged 17 commits from add-page-visual-editor into main 2026-12-03 08:19:05 +00:00
Owner

Implements the OpenSpec change add-page-visual-editor, change 3 of the page builder.

What changes

On windows 1024 px and wider, the page editor now edits the page in place on a canvas, with a side panel next to it.

  • Canvas. The page renders on a canvas: Desktop at 1280 px, scaled down to fit, or Phone at 390 px.
    • Headings, text, button labels, cards and FAQ entries are edited on the page as plain text, with the server's length limits.
    • Rich text is edited in place, with a floating toolbar. A refused link says why.
    • Clicking an image spot opens the file picker.
  • Side panel. It shows the selected section's settings, or the page settings when nothing is selected.
  • Section tools. Drag, Move up, Move down, Duplicate and Remove. "Add section" sits between sections and offers every block type. A section that is added, copied or moved is scrolled into view.
  • Undo and redo. Up to 50 steps, with buttons and Ctrl+Z / Ctrl+Shift+Z. Typing in one field counts as one step.
  • Refusals. A refused block is selected, outlined and scrolled into view, and the message shows at its field.
  • Custom HTML. The block shows "Save to update" while its HTML is unsaved, and reloads after a save.
  • Leave guard. An in-app link asks before it drops unsaved edits.
  • Narrow windows. They keep the form editor. The shared usePageDraft hook keeps unsaved edits when the window is resized.

Security

The canvas iframe (CanvasFrame) is the portal's only unsandboxed frame. It holds a constant blank document, and React portals into it. This is recorded in design Decision 1 and in the proposal's Impact section. The markup sweep allow-lists exactly that file and its shape. Custom HTML still renders in sandboxed frames.

Verification

  • vitest: 1979 passed, exit code 0.
  • tsc: clean.
  • lint: 0 errors and the 4 old warnings.
  • openspec validate --strict: valid.
  • Live Playwright check (task 4.2), on disposable pages at 1280 px and 900 px with Desktop and Phone views. The test pages were deleted afterwards. Checked:
    • template, in-place edits, Look, add/duplicate/move/drag/delete;
    • undo and redo, one step per Ctrl+Z from three places;
    • a save refused for a missing event, then save and Publish changes;
    • safe and unsafe rich-text links;
    • the Custom HTML stale mark;
    • the leave guard.
  • Fixes from the live check:
    • Ctrl+Z was ignored once focus fell out of the editor.
    • Empty rich text had no room and no cue.
    • Added sections stayed out of view.

Notes

  • The VisualEditor UI tests were written after the component. The usePageDraft tests were written red first.
  • CI is expected to fail until solvway is in place.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs

Implements the OpenSpec change `add-page-visual-editor`, change 3 of the page builder. ## What changes On windows 1024 px and wider, the page editor now edits the page in place on a canvas, with a side panel next to it. - **Canvas.** The page renders on a canvas: Desktop at 1280 px, scaled down to fit, or Phone at 390 px. - Headings, text, button labels, cards and FAQ entries are edited on the page as plain text, with the server's length limits. - Rich text is edited in place, with a floating toolbar. A refused link says why. - Clicking an image spot opens the file picker. - **Side panel.** It shows the selected section's settings, or the page settings when nothing is selected. - **Section tools.** Drag, Move up, Move down, Duplicate and Remove. "Add section" sits between sections and offers every block type. A section that is added, copied or moved is scrolled into view. - **Undo and redo.** Up to 50 steps, with buttons and Ctrl+Z / Ctrl+Shift+Z. Typing in one field counts as one step. - **Refusals.** A refused block is selected, outlined and scrolled into view, and the message shows at its field. - **Custom HTML.** The block shows "Save to update" while its HTML is unsaved, and reloads after a save. - **Leave guard.** An in-app link asks before it drops unsaved edits. - **Narrow windows.** They keep the form editor. The shared `usePageDraft` hook keeps unsaved edits when the window is resized. ## Security The canvas iframe (`CanvasFrame`) is the portal's only unsandboxed frame. It holds a constant blank document, and React portals into it. This is recorded in design Decision 1 and in the proposal's Impact section. The markup sweep allow-lists exactly that file and its shape. Custom HTML still renders in sandboxed frames. ## Verification - `vitest`: 1979 passed, exit code 0. - `tsc`: clean. - `lint`: 0 errors and the 4 old warnings. - `openspec validate --strict`: valid. - **Live Playwright check (task 4.2)**, on disposable pages at 1280 px and 900 px with Desktop and Phone views. The test pages were deleted afterwards. Checked: - template, in-place edits, Look, add/duplicate/move/drag/delete; - undo and redo, one step per Ctrl+Z from three places; - a save refused for a missing event, then save and Publish changes; - safe and unsafe rich-text links; - the Custom HTML stale mark; - the leave guard. - **Fixes from the live check:** - Ctrl+Z was ignored once focus fell out of the editor. - Empty rich text had no room and no cue. - Added sections stayed out of view. ## Notes - The VisualEditor UI tests were written after the component. The `usePageDraft` tests were written red first. - CI is expected to fail until solvway is in place. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
ngqile added 17 commits 2026-12-03 08:19:00 +00:00
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
A toolbar button removed with its section drops focus on the canvas body, and
a button that just went disabled drops it on the page body; neither reached the
editor's key handler. Listen on both documents as a fallback.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
A new Text section was a thin line under its Add section button, with nothing
to click or read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
ngqile merged commit 7cd2972a70 into main 2026-12-03 08:19:05 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ngqile/co-lite#64