feat(code-block): offer /code on the PDF editor and every registered language #827

Merged
raisondetredev merged 1 commit from refs/pull/827/head into main 2026-08-08 15:45:48 +02:00
raisondetredev commented 2026-08-08 15:45:38 +02:00 (Migrated from codeberg.org)

Two ways a code block was out of reach of the author who wanted one.

The PDF flashcard editor had no /code. AppFlowy's slash menu takes a
single slashMenuItems list rather than a base plus an overlay, so a host
injecting its own entries replaces the list instead of extending it. The PDF
editor injects /screenshot, and the replacement branch it fell into named
only standardSelectionMenuItems — so code, table, callout, spoiler, audio,
youtube and the study button all silently vanished from the one surface where
you are transcribing a page of a programming book. Math had already been
hand-restored there for the same reason, which is the shape of the bug: every
new block has to remember this branch exists.

Code joins math. The others stay out on purpose — that menu lives in a narrow
sidebar and is long already, and a formula or a snippet is what a PDF-sourced
card actually needs. The branch moves out of the widget's build into
curatedSlashMenuItems, so what a curated surface offers is a value a test
can read rather than an expression buried in a private State.

Six languages had grammars but no way to pick them. go, rust,
kotlin, c, cpp and r were registered in code_highlighting.dart
imported, bundled, and already colouring imported decks — while
kCodeBlockLanguages, the block's language menu, omitted them. An author
writing Go by hand got no highlighting and no way to ask for it, even though
the grammar was sitting in the binary. They are listed now, and the two lists
are pinned to each other in both directions by tests: no menu entry without a
grammar (which would read as a broken choice), and no grammar the menu hides
(which would be bundle weight nobody can reach). console and text remain
the two deliberate exceptions, present to mean "verbatim".

Signed-off-by: Tizian 「ティツィアーン」 raisondetredev@pm.me

Two ways a code block was out of reach of the author who wanted one. **The PDF flashcard editor had no `/code`.** AppFlowy's slash menu takes a single `slashMenuItems` list rather than a base plus an overlay, so a host injecting its own entries replaces the list instead of extending it. The PDF editor injects `/screenshot`, and the replacement branch it fell into named only `standardSelectionMenuItems` — so code, table, callout, spoiler, audio, youtube and the study button all silently vanished from the one surface where you are transcribing a page of a programming book. Math had already been hand-restored there for the same reason, which is the shape of the bug: every new block has to remember this branch exists. Code joins math. The others stay out on purpose — that menu lives in a narrow sidebar and is long already, and a formula or a snippet is what a PDF-sourced card actually needs. The branch moves out of the widget's build into `curatedSlashMenuItems`, so what a curated surface offers is a value a test can read rather than an expression buried in a private State. **Six languages had grammars but no way to pick them.** `go`, `rust`, `kotlin`, `c`, `cpp` and `r` were registered in `code_highlighting.dart` — imported, bundled, and already colouring imported decks — while `kCodeBlockLanguages`, the block's language menu, omitted them. An author writing Go by hand got no highlighting and no way to ask for it, even though the grammar was sitting in the binary. They are listed now, and the two lists are pinned to each other in both directions by tests: no menu entry without a grammar (which would read as a broken choice), and no grammar the menu hides (which would be bundle weight nobody can reach). `console` and `text` remain the two deliberate exceptions, present to mean "verbatim". Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
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
project-halkyon/halkyon-learn!827
No description provided.