Files
co-lite/openspec/changes/add-page-visual-editor/tasks.md
T

4.5 KiB

Tasks: add-page-visual-editor

Design: design.md. Every task is TDD. Work is serial in the main session, with a self-review per task.

  • Verify (portal): cd solvway-admin-portal && npx vitest run; echo VITEST=$? && npx tsc --noEmit && npm run lint

1. Foundations

  • 1.1 Spike, kept only if it passes: render LandingPage into a blank frame by portal, with copied styles and theme. It passes when all of these work, in next dev and in one next build + next start:

    • Tailwind breakpoints follow the frame width (390 vs 1280).
    • Fonts and dark mode look right.
    • A Tiptap editor inside the frame types, selects and applies bold.
    • A contentEditable field keeps its caret while typing.
    • Native drag events fire.
    • A Custom HTML frame inside it reports its height.

    On failure, stop and switch to the canvas-route fallback (design Decision 1), noting why. Passed 2026-12-03 in next dev and next build + next start: 390 px stacks the cards and 1280 px shows three columns; Inter and dark mode follow the editor live; Tiptap typed and applied bold; a plain field kept its caret; dragstart and drop fired inside the scaled frame; a Custom HTML frame grew to 4419 px after 1.2. The frame scrolls inside rather than growing (design Decision 2).

  • 1.2 HtmlFrame listens on its own document's window (test: a frame inside another document still resizes).

  • 1.3 Move PageEditor state and actions into usePageDraft, with no behaviour change. All existing PageEditor*.test.tsx stay green and unchanged.

  • 1.4 Leave guard for in-app links in the form editor (test: an in-app link click with unsaved edits asks; Cancel stays, Leave navigates).

2. Canvas

  • 2.1 PageCanvas: the frame, the Desktop view (1280 px scaled) and the Phone view (390 px), live updates from the draft, and links and buttons inert.
  • 2.2 Edit-mode hooks in CmsBlocks: EditContext, EditableText for every plain text field with its server limit, image spots, Section outline and data-index. Public rendering stays unchanged: the existing CmsBlocks*.test.tsx stay green.
  • 2.3 Rich text in place: RichTextEditor bare mode with a floating toolbar (test: an unsafe link is refused with a message).
  • 2.4 Custom HTML on the canvas: the saved-draft frame, the "Save to update" mark, and a reload after save.

3. Editor

  • 3.1 VisualEditor layout:
    • The top bar: title, status, Desktop and Phone, undo and redo, Duplicate, Preview, View page, Delete, Save.
    • The change 2 banner with Publish changes and Discard changes.
    • The side panel: BlockFields for the selected block, or the page settings.
    • The editor is chosen by width, 1024 px and up.
  • 3.2 Selection and section actions: select, toolbar (up, down, duplicate, delete), "Add section" between sections and at the end, native drag reorder (reorder function unit-tested), and the keyboard path.
  • 3.3 Undo and redo: history of 50, one step per field edit and per action, Ctrl+Z and Ctrl+Shift+Z, kept across saves.
  • 3.4 Refusals on the canvas: select, outline, scroll into view, message at the panel field; page-field refusals in the page settings.
  • 3.5 Templates (?template=) and Duplicate (?from=) open in the visual editor.
  • 3.6 Labels in defaultMessages.ts and zh_CN.seed.json, npm run i18n:sql, sql/01-visual-editor-labels.sql, sql/99-rollback.sql.

4. Release

  • 4.1 docs/deployment.md §12: the on-page editor for staff, the narrow-window form, and Custom HTML showing after Save.
  • 4.2 Live check with Playwright (snapshot, find and screenshots only; no eval), on disposable pages, at 1280 px and at 900 px for the form, with Desktop and Phone views:
    • Create from a template, edit headings and a card in place, change a look in the panel, and add, duplicate, move and delete sections.
    • Undo and redo.
    • Save without an event: the form is outlined with the message at Event.
    • Choose the event and save. Publish changes.
    • Rich text with a safe link and a refused unsafe one.
    • A Custom HTML block: the "Save to update" mark, then the new HTML after save.
    • Leaving by a menu link with unsaved changes.
    • Done 2026-12-03. The panel change was a card icon, not the Look select. Found and fixed on the way:
      • Ctrl+Z did nothing right after a toolbar delete: focus fell to the canvas body.
      • Ctrl+Z also did nothing once Redo went disabled: focus fell to the page body.
      • A new empty Text section was a thin line under its Add section button.
      • A section added from the panel stayed out of view.