feat(web): add mermaid-editor app for standalone .mmd diagrams - #12676
feat(web): add mermaid-editor app for standalone .mmd diagrams#12676dj4oC wants to merge 4 commits into
Conversation
md-editor-v3's mermaid support only fires inside a Markdown fenced code block, so there was no way to edit a Mermaid diagram on its own. This adds a dedicated split-pane editor/preview app (mirroring web-app-html-editor's shape) for the mmd/mermaid extensions, feeding raw diagram source straight into mermaid.render() - no Markdown wrapping involved. Invalid syntax surfaces an inline error instead of crashing the preview pane, and the rendered SVG is sanitized with DOMPurify the same way the embedded markdown-mermaid renderer already does. 🤖 Generated with Claude Code Signed-off-by: David Walter <[email protected]>
Wires the new 'mmdFile' resource type into the create/edit e2e resource helpers (mirroring txtFile/mdFile) and adds a spec covering diagram rendering, invalid-syntax error surfacing, and the view-mode toggle. The new mermaidEditor.ts page-object asserts the existing WCAG 2.1 a11y baseline every other e2e spec uses, plus an additional WCAG 2.2 tag scan (target-size, focus-appearance, etc.) scoped to this file only - the shared a11y helper used by every other spec stays on its current WCAG 2.1 tag set, since widening it repo-wide is a separate decision with its own pre-existing-violation triage cost. 🤖 Generated with Claude Code Signed-off-by: David Walter <[email protected]>
|
Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would create a changelog item based on your changes. |
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
CI's e2e run for the new mermaid-editor app timed out waiting for the "New > Mermaid diagram" menu entry: config.json.dist (a reference/dev file) had "mermaid-editor" added, but the actual runtime default config a packaged oCIS binary serves comes from services/web's Go defaults, which didn't. Also runs Prettier over the 3 files check:format flagged. 🤖 Generated with Claude Code Signed-off-by: David Walter <[email protected]>
There was a problem hiding this comment.
web/packages/web-app-mermaid-editor/package.json — vue3-gettext is pinned to "2.4.0" (exact, no ^), while every other web app package (web-app-html-editor, web-app-text-editor) and the root web/package.json use "^4.0.1". This pulls a separate v2 dependency tree into the lockfile with its own deprecated transitive deps ([email protected], [email protected], etc. — both flagged deprecated in the lockfile itself). Looks like a typo rather than intentional — should be ^4.0.1.
services/web/pkg/config/defaults/defaultconfig.go:101 — mermaid-editor was added to DefaultConfig().Web.Config.Apps, but html-editor (the app this PR mirrors) was never added there — it's only in config.json.dist/config.json.sample-ocis. This Go list is a separate registry that seeds the default runtime config. Was touching this file intentional, or should this app follow the same pattern as html-editor and skip it?
No changelog entry — other recent feature additions (e.g. #12648) include one under changelog/unreleased/. Add one.
vue3-gettext was pinned to an exact "2.4.0" in web-app-mermaid-editor's package.json (a copy-paste slip) instead of "^4.0.1" like every other web app package, pulling in a stray v2 dependency tree with its own deprecated transitives ([email protected], [email protected]). Also adds the changelog/unreleased entry this PR was missing. 🤖 Generated with Claude Code Signed-off-by: David Walter <[email protected]>
|
Thanks for the review, addressed in 8992703:
I noticed the same gap you did (html-editor isn't in this list either) while I chose to add it here rather than mirror html-editor's opt-in stance because Happy to revert to match html-editor's pattern instead if you'd rather keep |
Problem
md-editor-v3's Mermaid support only fires for```mermaidfenced code blocksinside a Markdown document being previewed — there was no way to open a
standalone
.mmd/.mermaiddiagram file and get a live-rendered previewwithout wrapping it in Markdown first.
What this adds
A new
web-app-mermaid-editorpackage (packages/web-app-mermaid-editor),structurally mirroring
web-app-html-editor's split-pane editor/preview shape:mmd/mermaidfile extensions and a "New > Mermaid diagram"menu entry.
language exists, so this stays a plain-text pane — line numbers/history/
bracket-matching only).
mermaid.parse(..., { suppressErrors: true })thenmermaid.render()directly on the raw file content — no Markdownfence involved. Invalid syntax shows an inline error instead of crashing
the pane, and a token counter discards stale in-flight renders so a slow
keystroke can never clobber a newer one.
ADD_TAGS: ['foreignObject']config the existing embedded-in-MarkdownMermaid renderer already uses (
TextEditor.vue), since some diagram typesembed real HTML via
<foreignObject>.config/config.json.distandconfig.json.sample-ocis(the same files
html-editorwas added to).Testing
helpers, covering valid rendering, invalid-syntax handling, theme
reactivity, the large-file preview pause, and a stale-render race guard.
eslintclean, full-workspacevue-tsc --noEmitclean.specs/file-action/mermaidEditor.spec.ts)wires the
mmdFileresource type into the existing create/edit e2ehelpers (mirroring
txtFile/mdFile) and covers diagram rendering,invalid-syntax error surfacing, and the view-mode toggle.
existing WCAG 2.1 baseline every other spec in this repo uses, plus an
additional WCAG 2.2 tag scan (
wcag22aa— covers things like target sizeand focus appearance) scoped to this app only. The shared a11y helper used
by every other spec in the repo is untouched and stays on WCAG 2.1 — widening
it repo-wide is a separate decision with its own pre-existing-violation
triage cost, out of scope here.
ocis_fulldeployment that
WEB_ASSET_CORE_PATH+WEB_UI_CONFIG_FILEcorrectlyserve the new bundle and register the app in the live
config.json.Full live Playwright e2e execution was blocked by local Docker/network
environment flakiness unrelated to this change (see note below), not
completed as part of this PR.
Note: found a pre-existing bug while verifying (not fixed here)
While hand-verifying via
WEB_UI_CONFIG_FILE, a config missing the optionaloptions.editor/accountEditLink/feedbackLink/upload/embedkeys (whichis exactly what a real generated
config.jsonlooks like, since they're allomitempty) crashesservices/web/pkg/config/defaults.Sanitizewith a nilpointer dereference — it dereferences those
Optionssub-struct pointerswithout a nil-check when deciding whether to null them back out. Flagging
separately since it's out of scope for this PR; happy to file an issue if
useful.
Risk
Low. New, self-contained package; no existing app's code path is touched
except the two
appsarray config files and the e2e test helper additions(both purely additive).
🤖 Generated with Claude Code