Skip to content

Commit

Permalink
feat: upgrade mermaid version (#289)
Browse files Browse the repository at this point in the history
support mindmap and timeline
  • Loading branch information
linzhefeng authored Mar 30, 2023
1 parent 5341fc6 commit fb903a9
Show file tree
Hide file tree
Showing 5 changed files with 163 additions and 33 deletions.
4 changes: 3 additions & 1 deletion packages/plugin-mermaid/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@
"pie": "Pie chart",
"sequence": "Sequence diagram",
"state": "State diagram",
"uj": "User journey diagram"
"uj": "User journey diagram",
"mindmap": "Mindmaps",
"timeline": "Timeline"
}
4 changes: 3 additions & 1 deletion packages/plugin-mermaid/locales/zh_Hans.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@
"pie": "饼状图",
"sequence": "时序图",
"state": "状态图",
"uj": "旅程图"
"uj": "旅程图",
"mindmap": "思维导图",
"timeline": "时间轴"
}
2 changes: 1 addition & 1 deletion packages/plugin-mermaid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"locales"
],
"dependencies": {
"mermaid": "^9.3.0"
"mermaid": "^10.0.2"
},
"devDependencies": {
"bytemd": "workspace:*"
Expand Down
46 changes: 34 additions & 12 deletions packages/plugin-mermaid/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ type Locale = {
uj: string
gantt: string
pie: string
mindmap: string
timeline: string
}

export interface BytemdPluginMermaidOptions extends MermaidConfig {
Expand Down Expand Up @@ -112,6 +114,26 @@ another task : 24d`,
"Cats" : 85
"Rats" : 15`,
},
{
title: locale.mindmap,
code: `mindmap
Root
A
B
C
`,
},
{
title: locale.timeline,
code: `timeline
title History of Social Media Platform
2002 : LinkedIn
2004 : Facebook
: Google
2005 : Youtube
2006 : Twitter
`,
},
]

return {
Expand All @@ -138,19 +160,19 @@ another task : 24d`,
container.style.lineHeight = 'initial' // reset line-height
pre.replaceWith(container)

try {
m.render(
`bytemd-mermaid-${Date.now()}-${i}`,
source,
(svgCode) => {
container.innerHTML = svgCode
},
m.render(
`bytemd-mermaid-${Date.now()}-${i}`,
source,
// @ts-ignore
container
)
.then((svgCode) => {
// @ts-ignore
container
)
} catch (err) {
// console.error(err);
}
container.innerHTML = svgCode.svg
})
.catch((err) => {
// console.error(err);
})
})
})()
},
Expand Down
140 changes: 122 additions & 18 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fb903a9

Please sign in to comment.