Add columns to the page editor (#68) #74

Merged
miko merged 2 commits from feature/68-columns into development 2026-11-04 12:47:31 +01:00
Owner

Closes #68

Summary

A Columns block in the page editor: 2 or 3 columns of equal width, side by side from md on and stacked below. Our own Editor.js tool with one nested editor per column (ADR 0016).

createEditor (src/richText/createEditor.ts)     # shared factory, own tools object per editor
  page editor: tools + columns
    ColumnsTool (src/richText/columnsTool.ts)
      column editor × 2|3: same tools and texts, no columns

The format nests one level; the parser, search text, page image references and renderer recurse:

 {type: "columns", data: {cols: [{blocks: [...]}, {blocks: [...]}]}}
 parseRichText   → each column against the allow-list, without columns
 plainText       → text in columns is found
 imageIds        → page images in columns survive saving
 RichText        → .rich-text-columns grid

Behaviour in the editor:

keydown/keyup/paste/copy/cut/drop  → stop at the column's border (Enter, Tab stay in the column)
arrows at a column's start/end      → previous/next column, or the page's block before/after
arrows into the columns from around → handled by the tool through the column editors' API
3 → 2 columns                       → third column's blocks appended to the second; save waits

Also: a page's content and its editor now span the page's full width (max-w-6xl), and the page editor is taller, so editing looks like the page when read.

Evidence

  • Before: no columns block; page content at most 48rem wide.
    After: unit tests for round trip, dropping nested columns and unknown blocks, search text, image ids, renderer; e2e:
✓ tables, images and columns are not offered outside pages
✓ an admin lays out a page in columns across its full width, side by side from md on and stacked below; search finds their text
✓ keys and paste in a column stay in the column
✓ an image in a column survives saving, and is deleted once removed from it
vitest 363 passed · playwright 38 passed

Mutation check: with keydown not stopped at a column's border, the Enter and Tab assertions fail. The paste assertion cannot fail: Editor.js 2.31 already ignores paste targets in nested editors; it stays as a guard.

Merge Danger

Door: two-way

No migration. Stored columns blocks would be dropped by an older parser on the next save of that page, so rolling back after pages use columns loses that layout's content on re-save.

Blast Radius: pages

Page editor and page rendering only; guides, steps and categories keep their editors and 48rem width. Known limit: undo works per editor (a column or the page), not across both.

🤖 Generated with Claude Code

Closes #68 ## Summary A **Columns** block in the page editor: 2 or 3 columns of equal width, side by side from md on and stacked below. Our own Editor.js tool with one nested editor per column (ADR 0016). ```text createEditor (src/richText/createEditor.ts) # shared factory, own tools object per editor page editor: tools + columns ColumnsTool (src/richText/columnsTool.ts) column editor × 2|3: same tools and texts, no columns ``` The format nests one level; the parser, search text, page image references and renderer recurse: ```diff {type: "columns", data: {cols: [{blocks: [...]}, {blocks: [...]}]}} parseRichText → each column against the allow-list, without columns plainText → text in columns is found imageIds → page images in columns survive saving RichText → .rich-text-columns grid ``` Behaviour in the editor: ```text keydown/keyup/paste/copy/cut/drop → stop at the column's border (Enter, Tab stay in the column) arrows at a column's start/end → previous/next column, or the page's block before/after arrows into the columns from around → handled by the tool through the column editors' API 3 → 2 columns → third column's blocks appended to the second; save waits ``` Also: a page's content and its editor now span the page's full width (max-w-6xl), and the page editor is taller, so editing looks like the page when read. ## Evidence - **Before:** no columns block; page content at most 48rem wide. **After:** unit tests for round trip, dropping nested columns and unknown blocks, search text, image ids, renderer; e2e: ```text ✓ tables, images and columns are not offered outside pages ✓ an admin lays out a page in columns across its full width, side by side from md on and stacked below; search finds their text ✓ keys and paste in a column stay in the column ✓ an image in a column survives saving, and is deleted once removed from it vitest 363 passed · playwright 38 passed ``` Mutation check: with keydown not stopped at a column's border, the Enter and Tab assertions fail. The paste assertion cannot fail: Editor.js 2.31 already ignores paste targets in nested editors; it stays as a guard. ## Merge Danger **Door:** two-way No migration. Stored columns blocks would be dropped by an older parser on the next save of that page, so rolling back after pages use columns loses that layout's content on re-save. **Blast Radius:** pages Page editor and page rendering only; guides, steps and categories keep their editors and 48rem width. Known limit: undo works per editor (a column or the page), not across both. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Admins lay out a page's content in 2 or 3 columns of equal width, side
by side from md on and stacked below, in the editor as on the page.
A column holds any page block but further columns. The block's settings
switch between 2 and 3 columns; going from 3 to 2 appends the third
column's blocks to the second, and saving waits for that.

Columns are an Editor.js tool of our own with one nested editor per
column (ADR 0016), built by a shared factory that gives every editor
its own tools. The format nests one level: the parser checks each
column against the same allow-list without columns, and search text,
page image references and the renderer walk into the columns, so text
in columns is found and images in columns survive saving.

Keys, paste, copy, cut and drop end at a column's border, so Enter and
Tab act in the column only. The arrow keys move into and out of the
columns through the column editors, which Editor.js does not know.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A page's content now spans the page container instead of 48rem, and so
does the content editor, which is also taller, so editing a page, its
columns in particular, looks more like the page when read. The other
fields of the form stay narrow. Page images ask for variants to match
the wider content.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
miko merged commit bb05b0aa5e into development 2026-11-04 12:47:31 +01:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MassiveDynamic/kataba!74
No description provided.