Skip to content
Merged
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@

### Feature

- Support the Plate regions of the `@plone/plate` document model used by Plone Aurora and `@kitconcept/volto-plate`: entries of `blocks` whose `@type` is `plate` and whose `value` is a Plate document, keyed by the name of the region, `main` for the page body and the slot name for slots, like `aboveContent`. Their text is indexed in `SearchableText`, the `main` region is converted to Markdown, `@replace` changes their text, the blocks wrapped in them are processed by their type (html blocks are sanitized) and their types are in `block_types`. Once a page has a `main` region, its `blocks_layout` and other blocks are not used for the Markdown and the searchable text. The legacy `__somersault__` region of content saved before regions existed is read as the `main` region, and is deprecated @sneridagh
- Blocks can define `searchableText` to add their text to `SearchableText`; the slate block uses its `plaintext` like before @sneridagh
- Add a Microsoft 365 (OAuth) mail transport: set the application (client) ID, tenant ID and client secret in the mail control panel to send mail through the Microsoft Graph API with the client credentials flow instead of SMTP. Run `pnpm seed:upgrade` (upgrade 1019) @robgietema

### Bugfix

- Don't fail with a 500 on content whose `blocks_layout` lists ids missing in `blocks`, or which has no `blocks`, for example `@plone/plate` documents sent with the default layout: the missing blocks are skipped, like Plone does @sneridagh

### Internal

- Make `pnpm i18n` deterministic: sort the source files, so the context of a message that is in more than one file no longer depends on the order of glob, and keep the existing translation of a message when its context changes @robgietema
Expand Down
36 changes: 33 additions & 3 deletions docs/developer-guide/blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,19 @@ Blocks are content components used in Volto's block-based pages. Each block type

```ts
type Block = {
toMarkdown: (self: any, document: any) => string;
toMarkdown?: (self: any, document: any) => string;
searchableText?: (self: any) => string;
replace?: (self: any, pattern: RegExp, replacement: string) => any;
process?: (self: any) => Promise<any>;
};
```

The `toMarkdown` method receives the block's JSON data (`self`) and the parent document (`document`), and returns a Markdown string.
All methods are optional, a missing method falls back to the default block, which does nothing.

- `toMarkdown` receives the block's JSON data (`self`) and the parent document (`document`), and returns a Markdown string.
- `searchableText` returns the text of the block for the `SearchableText` index. The slate block returns its `plaintext`.
- `replace` returns the new `value` of the block with the text replaced, or `false` if nothing changed. It is used by `@replace`.
- `process` returns the block data to store, it is called when content is added or changed. The html block uses it to sanitize its html.

## Creating a block

Expand Down Expand Up @@ -45,4 +53,26 @@ import { myBlock } from '../../blocks/my-block/my-block';
blocks.register('myBlock', myBlock);
```

The block name (first argument) must match the `@type` value in the Volto block's JSON data. When a document is converted to Markdown, `Document.toMarkdown()` iterates the document's `blocks_layout.items`, looks up each block's `@type` in the registry, and calls its `toMarkdown` method.
The block name (first argument) must match the `@type` value in the Volto block's JSON data. When a document is converted to Markdown, `Document.toMarkdown()` iterates the document's `blocks_layout.items`, skipping ids missing in `blocks`, looks up each block's `@type` in the registry, and calls its `toMarkdown` method.

## `@plone/plate` documents

`@plone/plate` has its own document model.
Editors built on it, like the default editor of Plone Aurora and the [`@kitconcept/volto-plate`](https://github.com/kitconcept/volto-plate) add-on for Volto, store content in regions: entries of `blocks` keyed by the name of the region, whose `@type` is `plate` and whose `value` is a Plate document. A Plate document is a list of nodes such as `title`, `p` and `h2`, and other blocks wrapped in nodes of type `ploneBlock` which carry the block data next to its `@type`.

```json
{
"blocks": {
"main": { "@type": "plate", "value": [ ... ] },
"aboveContent": { "@type": "plate", "value": [ ... ] }
}
}
```

The page body is the `main` region, and slots use their slot name, like `aboveContent`. Regions are found by their `@type`, never by their key. When a page has a `main` region, `blocks_layout` and the other blocks are not used: the Markdown is the `main` region, and the searchable text is the text of the `main` region followed by the text of the other regions.

Content saved before regions existed has one region with the key and the `@type` `__somersault__`. It is read as the `main` region. This type is deprecated.

See [The unified block editor](https://plone-aurora.readthedocs.io/conceptual-guides/unified-editor.html) in the Plone Aurora documentation for the document model and how it relates to Volto blocks.

The core profile registers the `plate` block, and the same block for the legacy `__somersault__` type. It converts the Plate document itself, and calls the methods of the registered blocks for the wrapped blocks, so a block registered for Volto also works inside a `@plone/plate` document.
2 changes: 1 addition & 1 deletion locales/af/LC_MESSAGES/nick.po
Original file line number Diff line number Diff line change
Expand Up @@ -2261,7 +2261,7 @@ msgid "Rename"
msgstr "Hernoem"

#. Default: "Replaced text from {pattern} to {replacement}."
#: src/routes/replace/replace.ts:174
#: src/routes/replace/replace.ts:181
msgctxt "Routes|Replace"
msgid "Replaced text from {pattern} to {replacement}."
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion locales/ar/LC_MESSAGES/nick.po
Original file line number Diff line number Diff line change
Expand Up @@ -2261,7 +2261,7 @@ msgid "Rename"
msgstr "تغيير الاسم"

#. Default: "Replaced text from {pattern} to {replacement}."
#: src/routes/replace/replace.ts:174
#: src/routes/replace/replace.ts:181
msgctxt "Routes|Replace"
msgid "Replaced text from {pattern} to {replacement}."
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion locales/bg/LC_MESSAGES/nick.po
Original file line number Diff line number Diff line change
Expand Up @@ -2261,7 +2261,7 @@ msgid "Rename"
msgstr "Преименуване"

#. Default: "Replaced text from {pattern} to {replacement}."
#: src/routes/replace/replace.ts:174
#: src/routes/replace/replace.ts:181
msgctxt "Routes|Replace"
msgid "Replaced text from {pattern} to {replacement}."
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion locales/bn/LC_MESSAGES/nick.po
Original file line number Diff line number Diff line change
Expand Up @@ -2261,7 +2261,7 @@ msgid "Rename"
msgstr "পুনঃনামকরণ"

#. Default: "Replaced text from {pattern} to {replacement}."
#: src/routes/replace/replace.ts:174
#: src/routes/replace/replace.ts:181
msgctxt "Routes|Replace"
msgid "Replaced text from {pattern} to {replacement}."
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion locales/ca/LC_MESSAGES/nick.po
Original file line number Diff line number Diff line change
Expand Up @@ -2261,7 +2261,7 @@ msgid "Rename"
msgstr "Canvia el nom"

#. Default: "Replaced text from {pattern} to {replacement}."
#: src/routes/replace/replace.ts:174
#: src/routes/replace/replace.ts:181
msgctxt "Routes|Replace"
msgid "Replaced text from {pattern} to {replacement}."
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion locales/cs/LC_MESSAGES/nick.po
Original file line number Diff line number Diff line change
Expand Up @@ -2261,7 +2261,7 @@ msgid "Rename"
msgstr "Přejmenovat"

#. Default: "Replaced text from {pattern} to {replacement}."
#: src/routes/replace/replace.ts:174
#: src/routes/replace/replace.ts:181
msgctxt "Routes|Replace"
msgid "Replaced text from {pattern} to {replacement}."
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion locales/cy/LC_MESSAGES/nick.po
Original file line number Diff line number Diff line change
Expand Up @@ -2261,7 +2261,7 @@ msgid "Rename"
msgstr "Ailenwi"

#. Default: "Replaced text from {pattern} to {replacement}."
#: src/routes/replace/replace.ts:174
#: src/routes/replace/replace.ts:181
msgctxt "Routes|Replace"
msgid "Replaced text from {pattern} to {replacement}."
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion locales/da/LC_MESSAGES/nick.po
Original file line number Diff line number Diff line change
Expand Up @@ -2261,7 +2261,7 @@ msgid "Rename"
msgstr "Omdøb"

#. Default: "Replaced text from {pattern} to {replacement}."
#: src/routes/replace/replace.ts:174
#: src/routes/replace/replace.ts:181
msgctxt "Routes|Replace"
msgid "Replaced text from {pattern} to {replacement}."
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion locales/de/LC_MESSAGES/nick.po
Original file line number Diff line number Diff line change
Expand Up @@ -2261,7 +2261,7 @@ msgid "Rename"
msgstr "Umbenennen"

#. Default: "Replaced text from {pattern} to {replacement}."
#: src/routes/replace/replace.ts:174
#: src/routes/replace/replace.ts:181
msgctxt "Routes|Replace"
msgid "Replaced text from {pattern} to {replacement}."
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion locales/el/LC_MESSAGES/nick.po
Original file line number Diff line number Diff line change
Expand Up @@ -2261,7 +2261,7 @@ msgid "Rename"
msgstr "Μετονομασία"

#. Default: "Replaced text from {pattern} to {replacement}."
#: src/routes/replace/replace.ts:174
#: src/routes/replace/replace.ts:181
msgctxt "Routes|Replace"
msgid "Replaced text from {pattern} to {replacement}."
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion locales/en/LC_MESSAGES/nick.po
Original file line number Diff line number Diff line change
Expand Up @@ -2261,7 +2261,7 @@ msgid "Rename"
msgstr ""

#. Default: "Replaced text from {pattern} to {replacement}."
#: src/routes/replace/replace.ts:174
#: src/routes/replace/replace.ts:181
msgctxt "Routes|Replace"
msgid "Replaced text from {pattern} to {replacement}."
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion locales/en_AU/LC_MESSAGES/nick.po
Original file line number Diff line number Diff line change
Expand Up @@ -2261,7 +2261,7 @@ msgid "Rename"
msgstr "Rename"

#. Default: "Replaced text from {pattern} to {replacement}."
#: src/routes/replace/replace.ts:174
#: src/routes/replace/replace.ts:181
msgctxt "Routes|Replace"
msgid "Replaced text from {pattern} to {replacement}."
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion locales/en_GB/LC_MESSAGES/nick.po
Original file line number Diff line number Diff line change
Expand Up @@ -2261,7 +2261,7 @@ msgid "Rename"
msgstr "Rename"

#. Default: "Replaced text from {pattern} to {replacement}."
#: src/routes/replace/replace.ts:174
#: src/routes/replace/replace.ts:181
msgctxt "Routes|Replace"
msgid "Replaced text from {pattern} to {replacement}."
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion locales/eo/LC_MESSAGES/nick.po
Original file line number Diff line number Diff line change
Expand Up @@ -2261,7 +2261,7 @@ msgid "Rename"
msgstr "Renomi"

#. Default: "Replaced text from {pattern} to {replacement}."
#: src/routes/replace/replace.ts:174
#: src/routes/replace/replace.ts:181
msgctxt "Routes|Replace"
msgid "Replaced text from {pattern} to {replacement}."
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion locales/es/LC_MESSAGES/nick.po
Original file line number Diff line number Diff line change
Expand Up @@ -2261,7 +2261,7 @@ msgid "Rename"
msgstr "Renombrar"

#. Default: "Replaced text from {pattern} to {replacement}."
#: src/routes/replace/replace.ts:174
#: src/routes/replace/replace.ts:181
msgctxt "Routes|Replace"
msgid "Replaced text from {pattern} to {replacement}."
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion locales/et/LC_MESSAGES/nick.po
Original file line number Diff line number Diff line change
Expand Up @@ -2261,7 +2261,7 @@ msgid "Rename"
msgstr "Nimeta ümber"

#. Default: "Replaced text from {pattern} to {replacement}."
#: src/routes/replace/replace.ts:174
#: src/routes/replace/replace.ts:181
msgctxt "Routes|Replace"
msgid "Replaced text from {pattern} to {replacement}."
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion locales/eu/LC_MESSAGES/nick.po
Original file line number Diff line number Diff line change
Expand Up @@ -2261,7 +2261,7 @@ msgid "Rename"
msgstr "Izena aldatu"

#. Default: "Replaced text from {pattern} to {replacement}."
#: src/routes/replace/replace.ts:174
#: src/routes/replace/replace.ts:181
msgctxt "Routes|Replace"
msgid "Replaced text from {pattern} to {replacement}."
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion locales/fa/LC_MESSAGES/nick.po
Original file line number Diff line number Diff line change
Expand Up @@ -2261,7 +2261,7 @@ msgid "Rename"
msgstr "تغییر نام"

#. Default: "Replaced text from {pattern} to {replacement}."
#: src/routes/replace/replace.ts:174
#: src/routes/replace/replace.ts:181
msgctxt "Routes|Replace"
msgid "Replaced text from {pattern} to {replacement}."
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion locales/fi/LC_MESSAGES/nick.po
Original file line number Diff line number Diff line change
Expand Up @@ -2261,7 +2261,7 @@ msgid "Rename"
msgstr "Uudelleennimeä"

#. Default: "Replaced text from {pattern} to {replacement}."
#: src/routes/replace/replace.ts:174
#: src/routes/replace/replace.ts:181
msgctxt "Routes|Replace"
msgid "Replaced text from {pattern} to {replacement}."
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion locales/fr/LC_MESSAGES/nick.po
Original file line number Diff line number Diff line change
Expand Up @@ -2261,7 +2261,7 @@ msgid "Rename"
msgstr "Renommer"

#. Default: "Replaced text from {pattern} to {replacement}."
#: src/routes/replace/replace.ts:174
#: src/routes/replace/replace.ts:181
msgctxt "Routes|Replace"
msgid "Replaced text from {pattern} to {replacement}."
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion locales/fu/LC_MESSAGES/nick.po
Original file line number Diff line number Diff line change
Expand Up @@ -2261,7 +2261,7 @@ msgid "Rename"
msgstr "Torne a nomenâ"

#. Default: "Replaced text from {pattern} to {replacement}."
#: src/routes/replace/replace.ts:174
#: src/routes/replace/replace.ts:181
msgctxt "Routes|Replace"
msgid "Replaced text from {pattern} to {replacement}."
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion locales/ga/LC_MESSAGES/nick.po
Original file line number Diff line number Diff line change
Expand Up @@ -2261,7 +2261,7 @@ msgid "Rename"
msgstr "Athainmnigh"

#. Default: "Replaced text from {pattern} to {replacement}."
#: src/routes/replace/replace.ts:174
#: src/routes/replace/replace.ts:181
msgctxt "Routes|Replace"
msgid "Replaced text from {pattern} to {replacement}."
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion locales/gl/LC_MESSAGES/nick.po
Original file line number Diff line number Diff line change
Expand Up @@ -2261,7 +2261,7 @@ msgid "Rename"
msgstr "Renomear"

#. Default: "Replaced text from {pattern} to {replacement}."
#: src/routes/replace/replace.ts:174
#: src/routes/replace/replace.ts:181
msgctxt "Routes|Replace"
msgid "Replaced text from {pattern} to {replacement}."
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion locales/he/LC_MESSAGES/nick.po
Original file line number Diff line number Diff line change
Expand Up @@ -2261,7 +2261,7 @@ msgid "Rename"
msgstr "שנה שם"

#. Default: "Replaced text from {pattern} to {replacement}."
#: src/routes/replace/replace.ts:174
#: src/routes/replace/replace.ts:181
msgctxt "Routes|Replace"
msgid "Replaced text from {pattern} to {replacement}."
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion locales/hi/LC_MESSAGES/nick.po
Original file line number Diff line number Diff line change
Expand Up @@ -2261,7 +2261,7 @@ msgid "Rename"
msgstr "नाम बदलें"

#. Default: "Replaced text from {pattern} to {replacement}."
#: src/routes/replace/replace.ts:174
#: src/routes/replace/replace.ts:181
msgctxt "Routes|Replace"
msgid "Replaced text from {pattern} to {replacement}."
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion locales/hr/LC_MESSAGES/nick.po
Original file line number Diff line number Diff line change
Expand Up @@ -2261,7 +2261,7 @@ msgid "Rename"
msgstr "Preimenuj"

#. Default: "Replaced text from {pattern} to {replacement}."
#: src/routes/replace/replace.ts:174
#: src/routes/replace/replace.ts:181
msgctxt "Routes|Replace"
msgid "Replaced text from {pattern} to {replacement}."
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion locales/hu/LC_MESSAGES/nick.po
Original file line number Diff line number Diff line change
Expand Up @@ -2261,7 +2261,7 @@ msgid "Rename"
msgstr "Átnevezés"

#. Default: "Replaced text from {pattern} to {replacement}."
#: src/routes/replace/replace.ts:174
#: src/routes/replace/replace.ts:181
msgctxt "Routes|Replace"
msgid "Replaced text from {pattern} to {replacement}."
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion locales/hy/LC_MESSAGES/nick.po
Original file line number Diff line number Diff line change
Expand Up @@ -2261,7 +2261,7 @@ msgid "Rename"
msgstr "Վերանվանել"

#. Default: "Replaced text from {pattern} to {replacement}."
#: src/routes/replace/replace.ts:174
#: src/routes/replace/replace.ts:181
msgctxt "Routes|Replace"
msgid "Replaced text from {pattern} to {replacement}."
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion locales/id/LC_MESSAGES/nick.po
Original file line number Diff line number Diff line change
Expand Up @@ -2261,7 +2261,7 @@ msgid "Rename"
msgstr "Ganti nama"

#. Default: "Replaced text from {pattern} to {replacement}."
#: src/routes/replace/replace.ts:174
#: src/routes/replace/replace.ts:181
msgctxt "Routes|Replace"
msgid "Replaced text from {pattern} to {replacement}."
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion locales/it/LC_MESSAGES/nick.po
Original file line number Diff line number Diff line change
Expand Up @@ -2261,7 +2261,7 @@ msgid "Rename"
msgstr "Rinomina"

#. Default: "Replaced text from {pattern} to {replacement}."
#: src/routes/replace/replace.ts:174
#: src/routes/replace/replace.ts:181
msgctxt "Routes|Replace"
msgid "Replaced text from {pattern} to {replacement}."
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion locales/ja/LC_MESSAGES/nick.po
Original file line number Diff line number Diff line change
Expand Up @@ -2261,7 +2261,7 @@ msgid "Rename"
msgstr "名前の変更"

#. Default: "Replaced text from {pattern} to {replacement}."
#: src/routes/replace/replace.ts:174
#: src/routes/replace/replace.ts:181
msgctxt "Routes|Replace"
msgid "Replaced text from {pattern} to {replacement}."
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion locales/ka/LC_MESSAGES/nick.po
Original file line number Diff line number Diff line change
Expand Up @@ -2261,7 +2261,7 @@ msgid "Rename"
msgstr "გადარქმევა"

#. Default: "Replaced text from {pattern} to {replacement}."
#: src/routes/replace/replace.ts:174
#: src/routes/replace/replace.ts:181
msgctxt "Routes|Replace"
msgid "Replaced text from {pattern} to {replacement}."
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion locales/kn/LC_MESSAGES/nick.po
Original file line number Diff line number Diff line change
Expand Up @@ -2261,7 +2261,7 @@ msgid "Rename"
msgstr "ಪುನ ಹೆಸರಿಸು"

#. Default: "Replaced text from {pattern} to {replacement}."
#: src/routes/replace/replace.ts:174
#: src/routes/replace/replace.ts:181
msgctxt "Routes|Replace"
msgid "Replaced text from {pattern} to {replacement}."
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion locales/ko/LC_MESSAGES/nick.po
Original file line number Diff line number Diff line change
Expand Up @@ -2261,7 +2261,7 @@ msgid "Rename"
msgstr "이름 바꾸기"

#. Default: "Replaced text from {pattern} to {replacement}."
#: src/routes/replace/replace.ts:174
#: src/routes/replace/replace.ts:181
msgctxt "Routes|Replace"
msgid "Replaced text from {pattern} to {replacement}."
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion locales/lt/LC_MESSAGES/nick.po
Original file line number Diff line number Diff line change
Expand Up @@ -2261,7 +2261,7 @@ msgid "Rename"
msgstr "Pervadinti"

#. Default: "Replaced text from {pattern} to {replacement}."
#: src/routes/replace/replace.ts:174
#: src/routes/replace/replace.ts:181
msgctxt "Routes|Replace"
msgid "Replaced text from {pattern} to {replacement}."
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion locales/lv/LC_MESSAGES/nick.po
Original file line number Diff line number Diff line change
Expand Up @@ -2261,7 +2261,7 @@ msgid "Rename"
msgstr "Pārdēvēt"

#. Default: "Replaced text from {pattern} to {replacement}."
#: src/routes/replace/replace.ts:174
#: src/routes/replace/replace.ts:181
msgctxt "Routes|Replace"
msgid "Replaced text from {pattern} to {replacement}."
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion locales/mi/LC_MESSAGES/nick.po
Original file line number Diff line number Diff line change
Expand Up @@ -2261,7 +2261,7 @@ msgid "Rename"
msgstr "Whakaingoa anō"

#. Default: "Replaced text from {pattern} to {replacement}."
#: src/routes/replace/replace.ts:174
#: src/routes/replace/replace.ts:181
msgctxt "Routes|Replace"
msgid "Replaced text from {pattern} to {replacement}."
msgstr ""
Expand Down
Loading
Loading