Turn the warning block into callouts with four kinds (#62) #63

Merged
miko merged 4 commits from feature/62-callouts into development 2026-11-04 09:30:41 +01:00
Owner

Closes #62

Summary

The Editor.js warning block becomes a Callout: an optional title and a message, in one of four kinds. The kind is chosen in the block's settings. Editor and reader show the kind's icon, border and tint.

kind colour token icon
warning --warning TriangleAlert
error --danger CircleX
note (default) --info (new) Info
success --success (new) CircleCheck
 src/richText/
+├── callouts.ts        # icon + translatable name per kind, shared by renderer and editor
+├── calloutTool.ts     # own Editor.js block tool, replaces @editorjs/warning
 ├── document.ts        # parse/write: callout {kind}; legacy warning → warning callout
 ├── RichText.tsx       # <aside class="rich-text-callout" data-kind=…> + icon
 └── RichTextEditor.tsx # registers the tool and its texts
parseRichText(stored)
  "warning" block  → callout(kind: warning)   # existing content, no migration
  "callout" block  → callout(kind: variant ?? note)
toEditorJson(doc)
  callout → {type: "callout", data: {variant, title, message}}

GLOSSARY (Callout), ADR-0005, CHANGELOG (Unreleased) and the German catalogue are updated.

Evidence

  • Before: the warning icon in the editor was a black SVG, barely visible in dark mode; read view had a border only, no icon.
    After: the new e2e test a callout's kind shows while editing, also in dark mode, and when read switches a callout to error in dark mode, asserts the icon reaches ≥ 3:1 contrast on the tint, saves, and finds the error callout with its icon in the read view (8/8 repeated runs green).
  • Unit: every kind survives parse → write; a stored warning reads as a warning callout; a missing/unknown kind reads as note.
  • typecheck, lint, 293 unit tests, 17 e2e tests: green.

Merge Danger

Door: one-way, for content

Once a description or step with a warning is saved after deploy, it is stored as a callout block. Rolling back to a build without this change would drop those blocks from rendering and from the editor (unknown blocks are discarded by the parser), and the next save would delete them.

Blast Radius: rich-text

All rich text (guide/category descriptions, step content) renders through the changed parser; the search text is unchanged. Not verified by eye: the other three kinds in light/dark mode (colours only checked via tokens).

🤖 Generated with Claude Code

Closes #62 ## Summary The Editor.js warning block becomes a **Callout**: an optional title and a message, in one of four kinds. The kind is chosen in the block's settings. Editor and reader show the kind's icon, border and tint. | kind | colour token | icon | |---|---|---| | warning | `--warning` | TriangleAlert | | error | `--danger` | CircleX | | note (default) | `--info` *(new)* | Info | | success | `--success` *(new)* | CircleCheck | ```diff src/richText/ +├── callouts.ts # icon + translatable name per kind, shared by renderer and editor +├── calloutTool.ts # own Editor.js block tool, replaces @editorjs/warning ├── document.ts # parse/write: callout {kind}; legacy warning → warning callout ├── RichText.tsx # <aside class="rich-text-callout" data-kind=…> + icon └── RichTextEditor.tsx # registers the tool and its texts ``` ```text parseRichText(stored) "warning" block → callout(kind: warning) # existing content, no migration "callout" block → callout(kind: variant ?? note) toEditorJson(doc) callout → {type: "callout", data: {variant, title, message}} ``` GLOSSARY (Callout), ADR-0005, CHANGELOG (Unreleased) and the German catalogue are updated. ## Evidence - **Before:** the warning icon in the editor was a black SVG, barely visible in dark mode; read view had a border only, no icon. **After:** the new e2e test `a callout's kind shows while editing, also in dark mode, and when read` switches a callout to *error* in dark mode, asserts the icon reaches ≥ 3:1 contrast on the tint, saves, and finds the error callout with its icon in the read view (8/8 repeated runs green). - Unit: every kind survives parse → write; a stored `warning` reads as a warning callout; a missing/unknown kind reads as note. - typecheck, lint, 293 unit tests, 17 e2e tests: green. ## Merge Danger **Door:** one-way, for content Once a description or step with a warning is saved after deploy, it is stored as a `callout` block. Rolling back to a build without this change would drop those blocks from rendering and from the editor (unknown blocks are discarded by the parser), and the next save would delete them. **Blast Radius:** rich-text All rich text (guide/category descriptions, step content) renders through the changed parser; the search text is unchanged. Not verified by eye: the other three kinds in light/dark mode (colours only checked via tokens). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Our own Editor.js tool replaces @editorjs/warning: a callout has an
optional title, a message and a kind (warning, error, note, success),
chosen in the block's settings. Editor and renderer show the kind's icon,
border and tint, so the icon is readable in dark mode. Stored warning
blocks are read as warning callouts; no data migration.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From the review: the editor tool reuses the parser's fallback to "note"
instead of its own copy, the list of kinds is CALLOUT_VARIANTS like the
repo's other constant lists, and all four kinds go through parse and back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Code, DOM attribute and CSS use "kind" (CalloutKind, CALLOUT_KINDS,
data-kind), like step line kinds. Only the stored Editor.js JSON keeps
the field name "variant", as agreed in #62.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The e2e test only checked the data attribute and the icon's contrast, so
a stylesheet selector that no longer matches would have gone unnoticed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
miko merged commit b2ecbf5cdd into development 2026-11-04 09:30:41 +01:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MassiveDynamic/kataba!63
No description provided.