Repository navigation
[COMMS-1059] Enable diagrams support in BlockNote on documents - #26157
Conversation
|
Warning Flaky specs
🤖 Ask Copilot to investigateCopy the prompt below into a new comment on this PR to delegate the investigation to GitHub Copilot. It will look into the flakiness and open a separate pull request with you as reviewer. |
ihordubas99
marked this pull request as ready for review
October 20, 2026 09:59
|
Caution The provided work package version does not match the core version Details:
Please make sure that:
|
|
Caution The Enterprise plan field is not set on the work package Details:
Please make sure that:
|
ihordubas99
added this pull request to stack #26127
October 20, 2026 10:00
1 of 3 tasks
ihordubas99
force-pushed
the
feature/comms-1059-enable-diagrams-support-in-blocknote-on-documents
branch
from
October 22, 2026 13:12
cee793e to
0b14986
Compare
Collaborator
Author
|
Following the review of #26049, I added the same drift guard here. |
ihordubas99
force-pushed
the
feature/comms-1059-enable-diagrams-support-in-blocknote-on-documents
branch
from
October 26, 2026 11:47
0b14986 to
3f40623
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ticket
https://community.openproject.org/wp/COMMS-1059
Stacked on #26126 (COMMS-1058), which is stacked on #26049 (COMMS-1057). Please review those first.
What are you trying to accomplish?
Documents can contain Mermaid diagrams. A diagram is inserted from the slash menu (
/diagram,/mermaid,/flowchart), its Mermaid source is edited in a popup with a live preview, and invalid source shows an error placeholder instead of breaking the editor. The stored markdown keeps the source as a```mermaidcode block. The menu texts follow the user's locale.Screenshots
What approach did you choose and why?
Editor. The diagram block from
@blocknote/diagram-block(0.54.2, matching our BlockNote version) is added to the schema inOpBlockNoteEditor, and its slash menu item joins the math items in the "Advanced" group. The diagram dictionary of the user's locale is merged into the editor dictionary next to the math one. The source popup is highlighted by thesyntaxHighlighterextension from COMMS-1058, since the block declaresmermaidas its language.Markdown in hocuspocus. Hocuspocus builds the stored markdown from its own schema, and without the diagram block every diagram would be dropped from it. The package renders through Mermaid and React, which cannot run in Node, so
diagramSpec.tsdefines a static twin with the same type, content andcodemeta, as already done for math. It renders a<pre><code class="language-mermaid">, which BlockNote's markdown exporter turns into a fenced code block. The markdown test helper is now shared by the math and diagram tests.Dark mode. The block initializes Mermaid without a theme, so in OpenProject's dark mode the edges were dark grey on a dark background and practically invisible. Every
mermaid.initializecall resets Mermaid's whole configuration, sodiagram-theme.tslets the block initialize first and then initializes again with the block's own options plus the theme matching the OpenProject color mode. The block's later initialization calls are no-ops. It runs in a layout effect, before the previews render in their effects.Dependencies. Mermaid depends on
katex ^0.16, which is affected by GHSA-238p-pmpm-9mq7. It gets the same override as math-block, so the whole tree uses KaTeX 0.18.11. The lockfile only adds Mermaid and its dependencies, nothing existing changes. Mermaid stays out of the main bundle, because the editor controller is loaded lazily and every diagram type is its own chunk. Mermaid runs with its defaultstrictsecurity level, which strips HTML and click handlers from labels in these shared documents.Known limitations
Tests
Merge checklist