Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump Mermaid Version 9.3.0 -> 10.9.0 #6869

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
"markdown-it": "^13.0.1",
"markdown-it-container": "^3.0.0",
"markdown-it-emoji": "^2.0.0",
"mermaid": "9.3.0",
"mermaid": "10.9.0",
"mime-types": "^2.1.35",
"mobx": "^4.15.4",
"mobx-react": "^6.3.1",
Expand Down Expand Up @@ -275,7 +275,6 @@
"@types/markdown-it": "^12.2.3",
"@types/markdown-it-container": "^2.0.9",
"@types/markdown-it-emoji": "^2.0.4",
"@types/mermaid": "^9.2.0",
"@types/mime-types": "^2.1.4",
"@types/natural-sort": "^0.0.24",
"@types/node": "20.10.0",
Expand Down Expand Up @@ -360,4 +359,4 @@
"rollup": "^4.5.1"
},
"version": "0.76.1"
}
}
2 changes: 1 addition & 1 deletion server/models/helpers/ProsemirrorHelper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ export default class ProsemirrorHelper {
// Inject Mermaid script
if (mermaidElements.length) {
element.innerHTML = `
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@9/dist/mermaid.esm.min.mjs';
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs';
mermaid.initialize({
startOnLoad: true,
fontFamily: "inherit",
Expand Down
23 changes: 10 additions & 13 deletions shared/editor/extensions/Mermaid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class MermaidRenderer {
const cacheKey = `${isDark ? "dark" : "light"}-${text}`;
const cache = Cache.get(cacheKey);
if (cache) {
element.classList.remove("parse-error", "empty");
elemƒent.classList.remove("parse-error", "empty");
Copy link

@twliqiang twliqiang May 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change the variable name by mistake ?

element.innerHTML = cache;
return;
}
Expand All @@ -76,20 +76,17 @@ class MermaidRenderer {
mermaid.mermaidAPI.setConfig({
theme: isDark ? "dark" : "default",
});
mermaid.render(
const { svg, bindFunctions } = await mermaid.render(
`mermaid-diagram-${this.diagramId}`,
text,
(svgCode, bindFunctions) => {
this.currentTextContent = text;
if (text) {
Cache.set(cacheKey, svgCode);
}
element.classList.remove("parse-error", "empty");
element.innerHTML = svgCode;
bindFunctions?.(element);
},
element
text
);
this.currentTextContent = text;
if (text) {
Cache.set(cacheKey, svg);
}
element.classList.remove("parse-error", "empty");
element.innerHTML = svg;
bindFunctions?.(element);
} catch (error) {
const isEmpty = block.node.textContent.trim().length === 0;

Expand Down