Repository navigation
Conversation
…ocks The Image and Maps block sidebars and the ToC block edit form now read their schema from config.blocks.blocksConfig[type].blockSchema, so the editor and the block configuration share one source and add-ons can override it through config. The toc block now uses the generic BlockSettingsSchema as its schema, like the other blocks.
Form.onSubmit validates blocks with a blockSchema and passes the content type to applySchemaEnhancer, but the content type layout editor has no content. Now that the image block has a blockSchema, saving a layout with an image block threw.
2 tasks
davisagli
reviewed
Oct 21, 2026
davisagli
left a comment
Member
There was a problem hiding this comment.
@sneridagh I agree with the goal here, but I didn't have time to review it yet.
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.
Some core blocks kept their data schema inside their sidebar or edit component instead of in the block configuration, so
config.blocks.blocksConfig[type].blockSchemawas missing for them. Consumers of the blocks configuration (for example the/@blocks-schemaendpoint proposed in #8023) gotschema: nullfor image, maps, toc, html, title, description and leadimage.This PR is independent of #8023.
Blocks that now have a
blockSchemablockSchemaimageImageSchema(Image/schema.jsx, unchanged fields)ImageSidebarmapsMapsSchema(Maps/schema.js, unchanged)MapsSidebartocToC/Schema.jsx(exported asToCSettingsSchema, unchanged fields, variation-aware)ToC/EdithtmlHTMLBlockSchema(HTML/schema.js), onehtmlfieldleadimageLeadImageBlockSchema(LeadImage/schema.js):align,href,openLinkInNewTabThe sidebars and the ToC edit form resolve the schema the same way
DefaultEditdoes:blocksConfig[data['@type']].blockSchema, called with the block props andintl, falling back to the module's schema if an add-on replaced the block config without one. They use theblocksConfigprop, so blocks inside a container (for example the grid, with itsgridImageDisableSizeAndPositionHandlersSchemaenhancer) keep working as before. Editor behaviour and appearance are unchanged; no snapshots changed.The schema functions now accept the block data as either
data(theblockSchemaconvention used byDefaultEdit,Teaser, and the endpoint) orformData(whatImageSidebarpassed before), soImageSchema({ formData, intl })callers in add-ons still work, and calling them without block data no longer throws.Table of Contents
ToC/Schema.jsxis the block data schema (title, hide title, entries, ordered/sticky depending on the variation), not a block settings schema. It was registered asschema, the keyBlock/Editpasses to the generic "block settings" sidebar in layout (manage) mode, which expects an object likeBlockSettingsSchema, not a schema function. It is now theblockSchema, andtocusesBlockSettingsSchemaas itsschemalike the other blocks. TheToCSettingsSchemaexport in@plone/volto/componentskeeps its name for backwards compatibility.HTML
The HTML block stores a single
htmlfield that is edited with the code editor in the block itself, so there is no sidebar to wire. The new schema only describes the block data for consumers of the configuration. Nothing in the editor renders it, since the block has its owneditandview.Lead image
Contrary to what we assumed, the lead image block does store block data:
align,hrefandopenLinkInNewTab. The image and its alt text come from the content item'simageandimage_captionfields.LeadImageSidebaris a hand-built form with legacy widgets (notBlockDataForm), so porting it to render the schema would change the editor's look. This PR only adds the schema and leaves the sidebar alone. A comment in the schema notes both must stay in sync. Moving the sidebar toBlockDataFormcan be a follow-up.Blocks that still have no
blockSchema, on purposetitleanddescriptionrender the content item'stitleanddescriptionfields. They store no block data besides@type, so there is nothing to describe. They keep the genericBlockSettingsSchemaasschema.Notes
alt,align,sizeand the link fieldset only once an image is set (url), as before. Called without block data, its fieldsets are empty but all properties are listed.#:source references frompnpm i18nfor existing message IDs; no new strings to translate.Tests
src/config/Blocks.test.jschecks thatimage,leadimage,maps,tocandhtmlhave ablockSchemathat resolves with endpoint-style arguments and no block data, thattitle/descriptionhave none, that the ToC schema follows the variation, and thattocuses the generic settings schema.pnpm --filter @plone/volto test --runon the Image, Maps, HTML, LeadImage, ToC, Block and config tests passes, with no snapshot changes.Fix: saving a content type layout
When the form is saved,
Form.onSubmitvalidates every block that has ablockSchema, and passesthis.props.content['@type']toapplySchemaEnhancer. The content type layout editor (/controlpanel/dexterity-types/<type>/layout) has no content, so once the image block had ablockSchema, saving a layout with an image block threwCannot read properties of null (reading '@type'). The Cypress test "ControlPanel: Dexterity Content-Types Layout" caught it. The same would have happened before with any other block that has ablockSchema, like a teaser, in a type layout. It now uses optional chaining (this.props.content?.['@type']).