Repository navigation
Support the @plone/plate document model (plate regions), and don't fail on blocks missing in blocks_layout - #99
Conversation
Content whose blocks_layout lists ids that are not in blocks, or which has no blocks, failed with a 500 when it was indexed (toMarkdown), and invalid blocks broke the bodytext, the block types, the processing of blocks, the block references and @replace. Missing and invalid blocks are skipped now, like Plone does. Assisted-by: Claude Opus 5.5
Plone Aurora stores the whole page in one __somersault__ block whose value is a Plate document. Register a block for it which converts the document to Markdown, gives its text to SearchableText, replaces text for @replace and processes the blocks wrapped in ploneBlock nodes by their type, so html blocks inside it are sanitized. Its wrapped block types are added to block_types. When a page has this block, its blocks_layout and other blocks are not used for the Markdown and the searchable text, as documented by Plone Aurora. Blocks get a searchableText method for this; the slate block returns its plaintext, so the searchable text of Volto pages doesn't change. Assisted-by: Claude Opus 5.5
Plone Aurora's default editor is one consumer of the @plone/plate document model; @kitconcept/volto-plate is another. Link the Plone Aurora docs on the unified block editor. Assisted-by: Claude Opus 5.5
Add types that mirror TText, TElement and Value of platejs and the nodes documented in @plone/plate: marks, links, indent list items, code blocks, ploneBlock elements and the __somersault__ block. The helpers still read stored values through a loose PlateNode, since clients send them unvalidated, and wrapped blocks without an @type are now skipped. Assisted-by: Claude Opus 5.5
Assisted-by: Claude Opus 5.5
…k into somersault-blocks * 'somersault-blocks' of github.com:plone/nick: * 'main' of github.com:plone/nick: Make the i18n script deterministic and keep translations. # Conflicts: # CHANGELOG.md # locales/nick.pot
* 'main' of github.com:plone/nick: Update the mail control panel example for the Microsoft 365 settings. Add the strings of the Microsoft 365 mail settings to the locales. Add a Microsoft 365 (OAuth) mail transport. # Conflicts: # CHANGELOG.md # locales/nick.pot
davisagli
left a comment
There was a problem hiding this comment.
Reminder: needs to be updated to match the new format with main region of type plate plone/plone.restapi#2092
The page body is the main region, and slots use their slot name. Regions are found by their @type, plate. The legacy __somersault__ region is read as the main region, and is deprecated. Assisted-by: Claude Opus 5.5
|
@davisagli I updated it to the latest shape in the other PRs. |
|
@robgietema everything is ready on the Aurora side for this PR. plone/aurora#412 (the page body in the The releases have to happen in sync, because of the current Mack deployments, in this order:
Aurora with plone/aurora#412 saves every page it edits as the The full merge plan is in plone/aurora#379. Assisted-by: Claude Opus 5.5 |
|
🎉 |
Aurora's shared acceptance suite against Nick (plone/aurora#370) fails 111 of 253 tests with a 500 on creating a page. Aurora's default editor is built on
@plone/plate, whose document model stores the page in Plate regions (the@kitconcept/volto-plateadd-on for Volto uses the same model). Aurora's fixtures send the page with the defaultblocks_layout, which still lists the ids of a title and a slate block that aren't inblocks. Plone accepts that. Nick crashes while indexing:The first two commits are the fix. The third names the block after the
@plone/platedocument model and links the Plone Aurora docs on it fromdocs/developer-guide/blocks.md, and the fourth types the document model instead of usingany. The last one moves to the storage shape agreed in plone/aurora#379.Note
Updated to the agreed storage shape (plone/aurora#379). A region is an entry of
blockskeyed by its name, whose@typeisplate:mainfor the page body, and the slot name for slots, likeaboveContent. This is what plone.restapi 10.3.0 supports (plone/plone.restapi#2092), what Aurora writes after plone/aurora#412, and what volto-plate writes after kitconcept/volto-plate#122. Content saved before, with one__somersault__region, is still read, as themainregion.{ "blocks": { "main": { "@type": "plate", "value": [ ... ] }, "aboveContent": { "@type": "plate", "value": [ ... ] } } }1. Skip blocks missing in
blocks_layoutinstead of failing (bugfix)toMarkdownreadblocks[id]['@type']for every id inblocks_layout.items, so a dangling id, or a layout withoutblocks, threw. The newDocument.getLayoutBlocks()skips ids without a block and treats missingblocksorblocks_layoutas empty.getBodytext,getBlockTypes,handleBlocks,handleBlockReferencesand@replacealso skipnullor invalid blocks, which crashed them in the same way.blockseither.2. Support the
@plone/platedocument model: Plate regions (feature)Without the crash, the block would fall back to
_default: no Markdown and no searchable text for any@plone/platedocument.src/helpers/plate/plate.tsconverts a Plate value to Markdown and plain text: marks, links, Plate's indent lists, title and headings, blockquote, hr, code blocks, tables, and nested columns, callouts and toggles.src/blocks/plate/plate.tsregisters theplateblock withtoMarkdown,searchableText,replaceandprocess, and the same block for the deprecated__somersault__type.isPlateRegionfinds regions by@type, never by key,getMainRegionreturnsmainor the legacy__somersault__region, andgetPlateRegionsreturns the main region first, then the slots. Volto blocks wrapped inploneBlocknodes go to their own registered block, so html blocks inside a@plone/platedocument are now sanitized, and their types are inblock_types.searchableText. The default returns''and slate returns itsplaintext, so search results for Volto pages don't change.mainregion, it is the page: itsblocks_layoutand other blocks are not used for the Markdown and the searchable text. The Markdown is themainregion only. The searchable text is the text of themainregion followed by the text of the slot regions, as plone.restapi indexes everyplateregion. This follows the model as documented in The unified block editor, and stops pages migrated from Volto, which keep their legacy blocks next to it, from being indexed twice.src/helpers/plate/plate.ts:PlateText,PlateElementandPlateValuemirrorTText,TElementandValueofplatejswithout depending on it, plus the documented nodes (links, indent list items, code blocks,ploneBlock) andPlateRegion, withSomersaultBlockas a deprecated alias. The helpers read stored values through a loosePlateNode, since clients send them unvalidated, and aploneBlockwithout an@typeis skipped.replacesignature of the default block now takesselffirst, which is how it is called.Why a block and not a behavior
A behavior was the other option. Nick has no
blocks_layoutcheck to get past: theblocksbehavior requires nothing, and the 500 came from indexing. A behavior would only fix the types that list it, so Folder, Event, News Item and custom types would keep crashing until each one was changed and upgraded. A Plate region is a block inblocks, so the block registry is where it belongs.Validation
document.test.ts,src/helpers/plate/plate.test.ts,src/blocks/plate/plate.test.tsandcontent.test.ts. Thecontent.test.tsone POSTs amainregion with a stale layout, like Aurora's fixtures, and checks the 201, the Markdown, html sanitizing and@search?SearchableText=. The others also cover slot regions indexed aftermain, the legacy__somersault__region read asmain, and regions found by@type.main, the new regression tests fail with the TypeError above. On this branch they pass.query.test.tsand should collect more statistics incatalog.test.ts, fail the same way onmain, most likely because of PostgreSQL 14 versus CI's 18.tsc --noEmit, ESLint and Prettier are clean.Not verified yet, so draft
packages/platedocs.Left out
hrefs inside a Plate region don't get image scales inhandleBlockReferencesyet.@replacewrites its result tovaluefor every block, so for html blocks it setsvalueinstead ofhtml.See plone/aurora#379 for how to review and merge this PR together with the related ones.
Assisted-by: Claude Opus 5.5