Note: a callout inside an article
A Block that holds other Blocks, with a “/” item and Block actions in the “⋮” menu.
A note is a passage set apart in an article, with the tone “note” or “warning”. Inside it are ordinary Blocks —
paragraphs, lists, code — each with its own Block handle “⋮”. The
Recipe shows two UI contributions that don't require you to build a menu:
an Insert item (insertItems) and Block actions
(blockActions).
Try it
Type “/” and find “Note” (or Ctrl+Alt+N, on Apple ⌘+⌥+N). Open “⋮” next to a new note: you'll find “Make it a warning” and “Unwrap”. On a warning, the first one is “Make it a note” instead.
How it works
Container is a Block trait
container: true in the Schema rules is a Block trait: it gives the
Blocks inside the container their own handle, like the kit's Wrapper. The
Extensions (engine) contain content: "block+", isolating: true and
the acme_tone attribute; the kit sets the group and the HTML output.
The tone is a list attribute
acme_tone: { kind: "list", values: ["info", "warning"] }: a value that is not on the list is dropped: in
value, on paste and on the server.
Insert item
The item shows up in “/”, in “+” on the Toolbar and in “Add ›” of the handle. With
section: "insert" the kit prepares an empty paragraph at the caret itself, and run only inserts
the Block — one edit, one undo.
Block actions
Block actions sit in a section before “Delete”. pos is the position of the Block whose handle opened
the menu: it may be the note itself or a paragraph right inside it, so notePos finds the note.
isVisible hides an action that would change nothing.
The basic Preset has no Slash menu. Without "insertMenu" in tools the item has nowhere to
appear and won't be in “/”.
Look
The Block's look is plain CSS that selects on data-block and uses kit tokens. The same CSS works in
the Editor, in RichTextView and on the Paper (surface="paper"): the
theme switches the tokens.
[data-block="acme_note"][data-acme_tone="warning"] {
border-color: var(--warning);
background: var(--warning-soft);
}