Repository navigation
Store the default block width of every top-level block - #190
Merged
Merged
Conversation
A document loaded into the editor gets the default width on every top-level block, but blocks created while editing did not always store it, so saving and loading the same page changed it. History diffs showed those widths as changes nobody made. - The block width and style field plugins overrode `editor.tf.insertNodes`, `setNodes` and `wrapNodes` by assignment in `extendEditor`, which Plate 53 ignores. Removed those dead overrides. - The editor now normalizes the width of every top-level native block, not only of the types in `plateBlocksConfig`, with the same rules as loading a document. Top-level Plone blocks get their style field defaults the same way. - `PlateEditor` reports the value it normalized on load through `onChange`, so saving a page without editing it stores what the editor shows.
…-width * origin/main: (67 commits) Releasing @plone/aurora 1.0.0-alpha.19 Release @plone/cmsui 1.0.0-alpha.12 Release @plone/agave 1.0.0-alpha.9 Release @plone/theming 1.0.0-alpha.9 Release @plone/layout 1.0.0-alpha.14 Release @plone/blocks 1.0.0-alpha.18 Release @plone/plate 1.0.0-alpha.25 Release @plone/registry 4.0.0-alpha.5 Release @plone/quanta 1.0.0-alpha.2 Content CSS Phase 11: theming guide for blocks and cleanup (#219) Rename the Plone blocks' classnames to the content contract (#218) Share the block spacing between the Public UI and the editor (#217) Content CSS Phase 8: structural blocks and content root to styles/content.css (#216) Remove the Plate media nodes from Aurora's presets (#215) Move the table styles to styles/content.css (#214) Move the code block styles to styles/content.css (#213) Move the list styles to styles/content.css (#211) Move the inline mark styles to styles/content.css (#210) Move the text block styles to styles/content.css (#209) Add h1 and hr to the Plate block anatomy (#208) ... # Conflicts: # packages/plate/components/editor/index.tsx
sneridagh
added a commit
that referenced
this pull request
Oct 8, 2026
* origin/main: (190 commits) Make control panels saveable (#220) Public UI: render a single .content-area root (#230) (#234) Remove tsconfig test/spec/story excludes that never matched any file (#222) Add PloneClient.extend() and clientEndpoints utility for custom endpoints (#221) Store the default block width of every top-level block (#190) Releasing @plone/aurora 1.0.0-alpha.19 Release @plone/cmsui 1.0.0-alpha.12 Release @plone/agave 1.0.0-alpha.9 Release @plone/theming 1.0.0-alpha.9 Release @plone/layout 1.0.0-alpha.14 Release @plone/blocks 1.0.0-alpha.18 Release @plone/plate 1.0.0-alpha.25 Release @plone/registry 4.0.0-alpha.5 Release @plone/quanta 1.0.0-alpha.2 Content CSS Phase 11: theming guide for blocks and cleanup (#219) Rename the Plone blocks' classnames to the content contract (#218) Share the block spacing between the Public UI and the editor (#217) Content CSS Phase 8: structural blocks and content root to styles/content.css (#216) Remove the Plate media nodes from Aurora's presets (#215) Move the table styles to styles/content.css (#214) ... # Conflicts: # packages/cmsui/components/BooleanWidget/BooleanWidget.stories.tsx # packages/cmsui/components/BooleanWidget/BooleanWidget.test.tsx # packages/cmsui/components/BooleanWidget/BooleanWidget.tsx # packages/cmsui/news/+boolean-widget-adapter.bugfix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When a document is loaded, the editor gives every top-level block a width (
normalizeInitialValue). Blocks created while editing didn't always store theirs, so saving a page and loading it again changed it. A history diff then showed "Width: not set → Default" on blocks nobody touched. This was found in a volto-plate wiki (kitconcept/volto-plate#83) on a code block.Causes:
BaseBlockWidthPluginandBaseStyleFieldsPluginoverrideeditor.tf.insertNodes,setNodesandwrapNodesby assignment insideextendEditor. Plate 53 ignores that: verified withcreateSlateEditor, where only theapi.create.blockandnormalizeNodeoverrides run. Their unit tests passed because they calledextendEditoron mock editors.plateBlocksConfig; on load it's filled in for every top-level block. Aurora registers nearly every type, which hides this, buthrisn't registered. volto-plate registered onlytitleandp, so pasted, wrapped and inserted blocks (code blocks, callouts, tables…) were saved without a width.<Plate>mounts, soonChangedoesn't fire. Saving a page without editing it stored the raw value, and the next real edit showed every width as a change.Fix
block-width-plugin.tstfoverrides.normalizeNodenow fills in the width of every top-level native block, registered or not.normalizeInitialValueuses the same resolution (getEffectiveBlockWidth), so a saved value loads unchanged.style-fields-plugin.ts: removed the deadinsertNodesoverride. Top-level Plone blocks now get their style-field defaults innormalizeNode.components/editor/index.tsx: if loading changed the value,PlateEditorcallsonChangeonce on mount. The form then saves what the editor shows. This is a behaviour change: opening a page stored without widths now updates the form data immediately.Shipped behaviour is otherwise unchanged. The removed overrides never ran; turning them on instead would have added widths to nested nodes such as table rows and code lines.
Tests
block-width-plugin.test.ts): new real-editor tests cover insert, paste (insertFragment), wrap, unwrap, type changes, non-default widths, reset, invalid widths and Plone blocks (inserted and created), each checked through save → reload. The old mock tests for the dead overrides are gone.pnpm --filter @plone/plate test --runpasses (68 tests), andcheck:tsand lint are clean.acceptance/tests/block-width-persistence.test.ts, 14 tests): each saves through the UI, reads the stored value from the REST API, and checks the page reopens unchanged.hr), a page stored without widths saved untouched, and a non-default TOC width that is stored, kept and rendered.hr) and untouched-save tests fail. The Plone-block case can't be reproduced through Aurora's UI, so the unit tests cover it.title-block-sync› "Reloading edit view with no stored title block does not trigger hydration mismatch", which fails the same way onmain.