Grid block: Plate-native column container for the editor

Open
#278 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
8/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
css, typescript
Domain
frontend

Research direction

This is a multi-PR design plan, not a single fix. Start with PR 1 and read SidebarPlugin.tsx (getPloneBlockFromSelection, which uses path[0]) and Blocks.d.ts (PlateBlockConfigBase). Done for that PR means a nested Plone block shows its settings and the breadcrumb navigates to its parent, covered by Playwright tests. Coordinate scope with maintainers before starting.

Written by the indexing model from the issue text.

Description

04 type: enhancement

Summary

Add a Grid block to the Aurora editor. It is a Plate-native container: grid → columns → any allowed Plate content. Editors can add, remove, reorder and resize columns. It replaces the current "3 columns" block (column_group), which is too limited for real use. Volto's Grid is the reference for the UX, but not for the data shape.

Design and UX proposal, with a clickable prototype:

Aurora Grid Block.html

This issue is the implementation plan. It is split into PRs below.

Screenshots of the prototype

The prototype shows interactions, not final visuals.

Column selected. The column handle sits in the column's reserved top strip, and hovering a gap between columns shows the + to insert a column. The sidebar shows the column, with the breadcrumb above it.

Grid with column 1 selected: column handle in the top strip, + in the gap between columns 2 and 3, sidebar breadcrumb Document › Grid › Column 1

Inner block selected. Selecting the image inside column 2 shows the image's own settings in the sidebar, with alignment and size hidden in this context. The breadcrumb shows the full path, and each level is clickable.

Image inside column 2 selected: sidebar shows image settings, breadcrumb Document › Grid › Column 2 › Image

Grid selected. Column count, layout presets, background, headline, gap, stacking and the delete action all live in the sidebar. There is no floating grid toolbar. The grid uses the example "Sand" theme here.

Grid selected: sidebar shows the columns stepper, layout presets, headline, gap, narrow-width stacking and Delete grid

Permalinks point to main at 6fe13459b.

Agreed design

  • Node types: grid and grid_column. We don't reuse column_group. The upstream @platejs/layout normalizers unwrap groups with fewer than 2 columns and silently rebalance widths.

  • Columns hold any allowed blocks, not one block per column as in Volto. The default allow list is text, headings, lists, quote, image, teaser, video and listing. No nested grids.

  • 1 to 4 columns, set by maxColumns in the config. A one-column grid is valid.

  • Widths come from layout presets. Each column stores an integer size weight, so a column keeps its width when it moves.

    • 2 columns: 1:1, 2:1, 1:2
    • 3 columns: 1:1:1, 2:1:1, 1:2:1, 1:1:2
    • 4 columns: equal
    • The presets are registry data, so projects can add their own.
  • No floating grid toolbar. The canvas shows at most two pieces of chrome:

    • a column handle, inside a strip each column reserves at its top in edit mode;
    • the existing text formatting toolbar.

    The column handle hides while text is selected. Column count, layout and settings live in the sidebar.

  • Adding columns: hovering a gap between columns, or an outer edge, shows a + that inserts a column there.

  • The column handle has a drag grip, move left, move right, duplicate and delete. Delete takes one click and shows an "Undo" toast. It is disabled on the last column.

  • Reordering:

    • drag the column grip (drag and drop scoped to that grip only, see PR 5);
    • the move buttons;
    • Alt+Shift+←/→, announced through a live region.
  • No general block drag and drop. Blocks are still edited word-processor style: they move between columns by cut and paste.

  • Native blocks get their own sidebar, as CMSUI state, driven by a schema in plateBlocksConfig.

    • The sidebar shows the deepest selected node that has a schema. An image inside a column shows the image's settings; the caret in a paragraph shows the column.
    • A breadcrumb shows the full path, for example Document › Grid › Column 2 › Image. Every level is clickable.
    • Esc goes up one level. Clicking a gap between columns selects the grid.
  • Grid settings: column count, layout, background (theme), optional headline (as in Volto), gap (S/M/L), stacking on narrow widths, delete grid.

  • Columns are always equal height (stretch), and they have no settings of their own.

  • Background follows the block model. In the block model, the outer container handles theme styling. So the grid's background is a theme style field, not grid-specific CSS:

    • The grid schema has a theme field marked styleField: true. The grid stores a semantic ID such as sand, never a raw color.
    • The existing theme styleFieldDefinition utility resolves the ID against config.blocks.themes, the same palette other blocks use. A grid-specific list in plateBlocksConfig.grid.themes can replace it.
    • The resolved custom properties (for example --theme-color) and data-style-theme go on the grid's outer container. The background covers the whole grid, headline included.
    • With a non-default theme, the grid gets inner padding so the content doesn't touch the colored edge. Columns have no background of their own in v1.
  • Nested blocks know they are inside a grid, and can act on it. Nothing is stored on the inner block: the context comes from where the block sits in the tree, so a block moved out of the grid gets its normal behaviour back. There are three explicit mechanisms:

    1. Config overrides per container. plateBlocksConfig.grid.blocksConfig maps a block type to overrides of its normal config. A single resolver, getBlockConfig(type, { container }), merges them over the global config. The sidebar, the renderers, the style fields and the slash menu all use only this lookup. The grid uses it to remove controls that make no sense in a column:
      • image: a schemaEnhancer removes alignment and size, because the column sets the width (as Volto's gridImageDisableSizeAndPositionHandlersSchema);
      • teaser: a schemaEnhancer removes the theme field, because the grid's background applies (as Volto's gridTeaserDisableStylingSchema). Projects can switch this back on;
      • all blocks: blockWidth is not offered, because the column sets the width.
    2. Runtime context. A useBlockContainer() hook works in the editor and in the public view. It returns the container type and data, plus the column's position, its size and the grid's total parts. Blocks use it to adapt, for example to compute image sizes from the column's share of the width, as Volto's teaser does with GridContext. Schema enhancers and styleFieldDefinition utilities receive the same container data.
    3. Stored values are kept. A field hidden by an override keeps its stored value; it is ignored while the block is in the grid. An image moved out of the grid gets its alignment back.
  • Public view: only contract classes, styled in plate/styles/content.css.

    • .block-grid with has--gap--* and is--stacking, plus h2.block-grid__headline.
    • .block-grid__column with has--size--N.
    • Sizes map to flex-grow with a zero basis.
    • Columns stack based on the grid's own width (container-type: inline-size), not the viewport.
  • "3 columns" is removed. There is no migration for existing column_group content.

Data model
{
  "type": "grid",
  "headline": "Opening hours",
  "theme": "sand",
  "gap": "m",
  "stack": true,
  "children": [
    { "type": "grid_column", "size": 2, "children": [{ "type": "p", "children": [{ "text": "…" }] }] },
    { "type": "grid_column", "size": 1, "children": [{ "type": "ploneBlock", "@type": "image", "children": [{ "text": "" }] }] }
  ]
}
Normalization rules
  • A grid holds 1 to maxColumns grid_column children.
  • A grid_column always contains at least one block. An empty paragraph is inserted if needed.
  • size is a positive integer, defaulting to 1.
  • Content that is not a column, pasted directly into a grid, is wrapped in a column.
  • A grid pasted inside a column is unwrapped into its content.
  • Widths are never rebalanced, and grids are never unwrapped automatically.
  • Lowering the column count merges the content of removed columns into the last remaining one.

What on main needs to change

  • The sidebar only handles Plone blocks at the top level. getPloneBlockFromSelection uses path[0]: SidebarPlugin.tsx#L61-L71. Native nodes get no sidebar at all.
  • The Plone block keyboard handling assumes top-level blocks: getTopLevelBlockPath in plone-block-adapter.tsx#L64 and #L238.
  • Block width already only normalizes top-level nodes (block-width-plugin.ts#L278). That is correct for nested blocks. The width toolbar button must also be hidden for them.
  • Drag and drop is off in Aurora (block-editor-kit.tsx#L17, #L72).
    • The per-block handles come only from aboveNodes: BlockDraggable (dnd-kit.tsx#L20).
    • A scoped kit that only renders the DndProvider (aboveSlate) enables the column grip and nothing else.
  • PlateBlockConfigBase only has category and blockWidth (Blocks.d.ts#L154). It needs:
    • title and schema for native blocks;
    • for the grid: allowedBlocks, maxColumns, layouts, themes and blocksConfig (the overrides for inner blocks).
  • Style fields only work on Plone blocks. getElementStyleFieldConfigs returns {} for native nodes (style-fields-plugin.ts#L52-L82), so a native grid can't have a theme yet. The resolver already takes a container argument (styleFields.ts#L38-L43), but every caller passes undefined.

Plan

Each PR is self-contained and validated with the package-scoped commands from the package AGENTS.md files. User-facing flows get Playwright acceptance tests, through the somersault-editor / somersault-renderer presets. Transforms and normalizers get Vitest unit tests.

PR 1: Path-aware sidebar for native and nested blocks (@plone/cmsui, @plone/types, @plone/plate)
  • Extend PlateBlockConfigBase with title and schema, which can be a function, like blockSchema.
  • Generalize SidebarPlugin so it resolves the deepest selected node with a schema at any depth: a ploneBlock (by @type) or a native node (by plateBlocksConfig[type].schema). Native node settings are written with setNodes at the node's path.
  • Sidebar breadcrumb: the ancestors of the selected node that have a schema or a title. A click selects that node.
  • Esc moves the selection one level up.
  • Style fields for native nodes: getElementStyleFieldConfigs also reads styleField markers from plateBlocksConfig[type].schema, so native blocks can have a theme.
  • Acceptance tests:
    • Selecting a Plone block nested in a container shows its settings. This can be tested with the existing column_group before it is removed, and fixes the current nested case.
    • The breadcrumb navigates to the parent.
PR 2: Container context for nested blocks (@plone/helpers, @plone/plate, @plone/cmsui, @plone/blocks, @plone/types)
  • getBlockConfig(type, { container }): merges plateBlocksConfig[containerType].blocksConfig[type] over the global block config. It replaces direct blocksConfig[type] lookups in:
    • the sidebar
    • the Plone block adapter (edit and view)
    • the style fields plugin
    • the slash menu
  • useBlockContainer() hook, available in the editor and the static renderer. It returns the container type and data, the column's position, its size, and the total parts.
  • Pass the container data to schema enhancers, and as the container argument of the style field resolver.
  • Hidden fields keep their stored values. Rendering ignores them while the block is inside the container.
  • Make the Plone block keyboard plugin path-aware: Enter and arrow keys inside a column must stay in that column.
  • Hide the block width toolbar button for nested nodes.
  • Acceptance tests:
    • keyboard behaviour around a nested image;
    • an override hides a field inside a container and the field comes back outside it. This can be tested with the existing column_group until the grid lands.
PR 3: Grid node, transforms and rendering (@plone/plate, @plone/blocks)
  • grid / grid_column base plugins with the normalization rules above.
  • Transforms:
    • insertGrid
    • insertGridColumn(at)
    • removeGridColumn
    • duplicateGridColumn
    • moveGridColumn(from, to)
    • setGridColumnCount(n), which merges content of removed columns
    • applyGridLayout(preset)
  • Registry config in plateBlocksConfig.grid:
    • title, category: 'layout'
    • maxColumns: 4
    • layouts
    • allowedBlocks
    • schema: theme (style field), headline, gap, stacking
    • blocksConfig defaults: image without alignment and size, teaser without theme, no blockWidth for any block
  • Static and edit elements with the contract classes. CSS goes in content.css:
    • gap and has--size--N
    • container-query stacking
    • the headline
    • the themed background on the outer container (var(--theme-color)), with inner padding when a non-default theme is set
  • useBlockContainer() data for the grid. Use it in the teaser and image blocks to compute image sizes from the column's share of the width.
  • Update the content class contract test and structural-content-css.test.ts.
  • Slash menu Grid entry under "Advanced blocks", and a Turn into → Grid entry that wraps the selection into column 1 of 2.
  • Filter the slash menu inside a column by allowedBlocks. Grid is hidden there, so grids can't be nested.
  • Paste handling: unwrap a grid pasted into a column.
  • Unit tests for the normalizers and transforms. Acceptance tests for insertion and public rendering, including stacking.
PR 4: Grid editing UX (@plone/plate, @plone/cmsui)
  • Reserved top strip per column in edit mode, with the column handle: move left, move right, duplicate, delete. The handle hides while text is selected.
  • + in the gaps and at the outer edges to insert a column. It is hidden when the grid is at maxColumns.
  • Clicking a gap selects the grid.
  • Alt+Shift+←/→ moves the current column, announced through a live region.
  • Grid sidebar:
    • a column count stepper and a layout preset picker, as widgets for virtual fields that are mapped to the PR 3 transforms;
    • headline, gap and stacking;
    • a delete grid action.
  • Column sidebar: position and width in parts. No settings.
  • Undo toast for column deletion.
  • A new grid opens the sidebar on its settings, with the caret in column 1.
  • Acceptance tests:
    • add, remove, duplicate and move columns, by buttons and by keyboard;
    • change the count and the layout;
    • selection levels and the breadcrumb.
PR 5: Column reordering by drag (@plone/plate)
  • Scoped DnD kit: DndPlugin with only the aboveSlate DndProvider, without BlockDraggable, so other blocks don't get drag handles.
  • Column grip with useDraggable({ orientation: 'horizontal' }). Drops are accepted only within the same grid, with a vertical drop line in the gap.
  • Acceptance test for drag reorder.
PR 6: Remove "3 columns" (@plone/plate, @plone/blocks, docs)

Each PR gets a towncrier news fragment in the affected packages.

To review for v2

  • Free column resizing. Drag the gap between columns to resize, snapping to a 12-part scale. In v1, widths come only from the layout presets.
  • Vertical alignment. Where a shorter column's content sits when another column is taller (top, center or stretch).
    • In v1, columns are always equal height (stretch).
    • Top and stretch look the same unless columns have a background or border, so only center changes the look, for example an image next to a longer text.
    • If editors ask for it, add it at grid level only (align-items). A per-column override (align-self) needs a stronger case.

Review and merge guide

The work is a stack of 11 PRs, #415 → #425. Each PR is based on the branch of the one before it, so each PR's diff shows only its own changes. Review and merge them bottom-up, in the order of the table.

The stack sits on the accordion stack (#389 → #397, for #378). #415 is based on accordion-editing-polish (#397), not on main. The grid needs what the accordion added: a settings host, selection levels with Esc, and rules for the blocks a container holds. #415 and #416 make those generic, and the accordion moves onto them. So the accordion stack merges first. Until it does, the 11 PRs are drafts, and when #397 is merged, #415's base becomes main.

The grid is a Plate.js block of @plone/plate, so it works in any editor that uses the Plate presets, Aurora's and Volto's. The ESLint rule that keeps the accordion from importing Aurora's application packages covers the grid too.

The stack
# PR What Size Breaking Backend
1 #415 Plate blocks can hold other blocks through a shared container model: allowed blocks, getBlockConfig with per-container overrides, the slash menu filter. The accordion uses it 25 files No Any
2 #416 Selection levels, the breadcrumb and the settings host, shared by container blocks. Aurora's sidebar uses them 30 files No Any
3 #417 Style fields, such as theme, for native Plate blocks 5 files No Any
4 #418 The grid's data model, normalization and published view 28 files No, new block Any
5 #419 Inserting a grid (slash menu, Insert, Turn into) and editing the blocks in its columns 18 files No Any
6 #420 Adding, moving, duplicating and deleting columns, with Alt+Shift+arrows and Undo 10 files No Any
7 #421 The grid and column settings, the outline of the selected column, and Tab from a column handle into its settings 12 files No Any
8 #422 Blocks inside a grid adapt to their column: useBlockContainer(), image sizes, and the image and teaser overrides 20 files No Any
9 #423 Reordering columns by dragging their grip 12 files No Any
10 #424 The how-to guide, the theme docs, and visual regression tests 7 files No Any
11 #425 "3 columns" (column_group) and @platejs/layout are removed, and the grid takes their place in the menus 38 files Yes: existing column_group content isn't migrated. The upgrade guide explains how to rebuild it as a grid Any

"Backend" means what the PR's features need. No PR changes the backend: the grid is saved in the page's Plate value, like the other Plate blocks, so every PR works on the released plone.restapi, which is what CI runs.

Only #425 changes pnpm-lock.yaml and a package.json: @plone/plate no longer depends on @platejs/layout.

#418 adds a grid to the native blocks page, which changes the three Native blocks screenshots, and #425 removes the columns from that page, which changes them again. #424 adds four Grid screenshots. The PRs don't add baselines. See step 5 of "How to merge".

Each PR's description has the details: what changed, and the tests that ran.

How the PRs map to the plan above
Plan above PRs
PR 1: path-aware sidebar #416 (levels, breadcrumb, Esc, the native block sidebar) and #417 (style fields for native blocks)
PR 2: container context #415 (getBlockConfig, the slash menu filter, no width button inside a container) and #422 (useBlockContainer(), hidden fields, image sizes)
PR 3: grid node, transforms and rendering #418 (model, normalization, published view) and #419 (insert, Turn into, paste, the slash menu in a column)
PR 4: grid editing UX #420 (the column handle, the + in the gaps, keyboard moves, Undo) and #421 (the sidebar)
PR 5: drag #423
PR 6: remove "3 columns" #424 (docs) and #425 (removal)

Each PR of the plan became one or two smaller ones, so that each has one concern and can be reviewed in one sitting.

Where the implementation differs from the plan

The plan was written before the accordion (#378) existed. The accordion solved several of the same problems for itself, so the grid builds on those solutions instead of adding a second set:

Plan above Implementation Why
Grid options in plateBlocksConfig.grid (maxColumns, layouts, allowedBlocks, schema, themes, blocksConfig) Plugin options with defaults, GridPlugin.configure({ options }), as the accordion does. plateBlocksConfig.grid keeps only category: 'layout' @plone/plate must work in Volto, where Aurora's registry doesn't exist
Native block settings as CMSUI state, rendered by cmsui's form engine @plone/plate renders them into the host's settingsContainer, which is Aurora's sidebar, or into a popover when there is none. cmsui still renders the settings of Plone blocks, now at any depth Same reason. This is how the accordion's settings work
New sidebar, breadcrumb, Esc and container mechanisms The accordion's versions become shared (#415, #416), and the accordion moves onto them without behavior changes Avoids two implementations of the same thing
useBlockContainer() in the editor and the static renderer It lives in @plone/helpers, and the grid's elements provide it @plone/blocks (Image, Teaser) can't import @plone/plate
has--gap--*, is--stacking, has--size--N classes data-gap, data-stack and data-size attributes, plus --block-grid-column-size inline Fits the existing content class contract, like the accordion's data-open
The existing theme utility resolves config.blocks.themes The grid has its own themes option, Default and Grey by default, in the StyleDefinition shape that config.blocks.themes uses. A registered theme style field definition is the fallback The utility doesn't exist yet, and a site-wide theme system is outside this issue. The same shape and the same theme field keep saved grids compatible with one

Beyond the plan, a keyboard path into the settings: Tab reaches a column's handle, which shows that column in the sidebar, and goes on from the handle into its settings (#421).

How to review
  • The shared container layer (#415, #416, #417): packages/plate/components/editor/plugins/containers/ (the container option, getBlockConfig, what happens to a block a container can't hold), plugins/block-settings/ (the settings option, the Esc levels, the settings target) and components/ui/block-settings.tsx. The accordion uses them, and its unit and acceptance tests still pass. Aurora's side is in packages/cmsui/components/BlockEditor/plugins/SidebarPlugin.tsx.

  • The block (#418): the nodes in plugins/grid/types.ts, the normalizer that keeps them valid (normalize.ts and its tests), the options in options.ts, the published view in components/ui/grid-node-static.tsx, and the classes, attributes and container query in styles/content.css. Everything later builds on these, and Volto will use them too.

  • Editing (#419, #420, #421, #423): compare it with the prototype attached above, in Storybook and in Aurora. The unit tests cover the transforms and the keyboard, and the acceptance tests the flows, so skim them.

  • Blocks inside a grid (#422): packages/helpers/src/blockContainer.tsx, the default overrides in plugins/grid/inner-block-schema.ts, and the image sizes in packages/blocks/Image/utils.ts.

  • Accessibility: use the keyboard only:

    • Tab reaches a column's handle, and the sidebar shows that column. Tab from the handle's last control goes into the settings, and from the last setting on to the next column's handle. Shift+Tab goes back.
    • Esc selects the level above: block › column › grid › page.
    • Alt+Shift+←/→ moves the column that holds the caret.
    • The + in the gaps is for the pointer only. The column settings (Add column before or after) and the grid's column count do the same from the keyboard.

    Changes are announced in a polite live region ([data-plate-announcer]).

  • The removal (#425): the breaking change note and docs/upgrade-guide/plone-aurora.md.

  • The docs (#424): docs/how-to-guides/configure-grid-blocks.md, the grid's rows in docs/how-to-guides/style-blocks-in-a-theme.md, and docs/development/editor-slash-menu.md.

Manual check after #425:

  1. Storybook: run pnpm --filter @plone/plate storybook and open Blocks/Grid/Editor and Blocks/Grid/Published view.

  2. Aurora: run make acceptance-backend-start, then pnpm start. Edit a page:

    • type / and choose Grid, then write in the columns and add an Image and a Teaser;
    • add columns with the + in a gap, then move, duplicate and delete them, undo, and drag a column by its grip;
    • in the sidebar, change the number of columns, the layout, the background, the headline, the gap and "Keep in a row";
    • select an image in a column: it has no alignment or size, and the breadcrumb reads Page › Grid › Column 2 › Image;
    • try the keyboard as above.

    Save, then on the published page check the widths, the headline, the background, and the columns stacking in a narrow window.

  3. Volto (not tested yet): in a Volto project with this @plone/plate, the block-editor and block-renderer presets have the grid, and its settings open in popovers.

How to merge

The repository only allows squash merges, and deletes a branch once its PR is merged. First merge the accordion stack (#389 → #397). Then, for each PR, in order:

  1. Check it's ready: CI is green, its base is main, and it's marked ready for review.
  2. Squash and merge with the stack. Keep the PR title as the commit subject.
  3. Restack the rest. GitHub changes the next PR's base to main, but its branch still has the merged PR's original commit, which main now has as a squash commit. Press the stack's Rebase button, or ask Claude to "rebase the stack on main". Afterwards, each PR's diff must be unchanged, with only its own commits. This also applies after #397: #415 then has the accordion's commits to drop.
  4. Wait for CI on the next PR before merging it.
  5. After #425, run the Update VRT Screenshots workflow on main with the pattern Native blocks|Grid, so the nightly visual check has the new baselines.

Never merge main into a branch of the stack: the stack stops being linear, and GitHub asks for a rebase. To bring the stack up to date with main, rebase it.

Restack by hand

After squash-merging PR N (#397 for the first grid PR), from a clean checkout:

git fetch origin
old=$(gh pr view N --repo plone/aurora --json headRefOid -q .headRefOid)
new=origin/main
for b in <the remaining branches, bottom-up>; do
  head=$(git rev-parse origin/$b)
  git rebase --onto "$new" "$old" "$head"
  git push --force-with-lease=$b:$head origin HEAD:refs/heads/$b
  new=$(git rev-parse HEAD); old=$head
done

Only #425 changes pnpm-lock.yaml. If a rebase stops on it, take either side, run pnpm install --fix-lockfile with pnpm 12 (the version in packageManager), and continue. Check each branch with pnpm install --frozen-lockfile, which is what CI runs.

The branches, bottom-up: block-containers, block-settings-levels, native-style-fields, grid-model-view, grid-editor, grid-column-actions, grid-settings, grid-inner-blocks, grid-column-drag, grid-docs, remove-column-group.

Assisted-by: Claude Opus 5.5

Dominant language
JavaScript
Stars
10
Forks
9
Avg merge
4d 7h
Merged PRs (30d)
54

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from plone/aurora

All issues in plone/aurora

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.