Skip to content

Commit e85f02a

Browse files
committed
upgrade deps
1 parent 89e02f6 commit e85f02a

File tree

3 files changed

+303
-269
lines changed

3 files changed

+303
-269
lines changed

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "vue-mermaid-render",
33
"type": "module",
4-
"version": "0.1.2",
5-
"packageManager": "pnpm@8.13.1",
4+
"version": "0.1.3",
5+
"packageManager": "pnpm@8.14.1",
66
"license": "MIT",
77
"repository": "hojas/vue-mermaid-render",
88
"bugs": "https://github.com/hojas/vue-mermaid-render/issues",
@@ -33,17 +33,17 @@
3333
"push": "pnpm build && npm publish"
3434
},
3535
"dependencies": {
36-
"mermaid": "^10.6.1"
36+
"mermaid": "^10.7.0"
3737
},
3838
"devDependencies": {
39-
"@antfu/eslint-config": "^2.6.1",
40-
"@types/node": "^20.10.6",
41-
"@vitejs/plugin-vue": "^5.0.2",
39+
"@antfu/eslint-config": "^2.6.3",
40+
"@types/node": "^20.11.5",
41+
"@vitejs/plugin-vue": "^5.0.3",
4242
"eslint": "^8.56.0",
4343
"shelljs": "^0.8.5",
4444
"typescript": "^5.3.3",
45-
"vite": "^5.0.10",
46-
"vue": "^3.4.3",
45+
"vite": "^5.0.12",
46+
"vue": "^3.4.15",
4747
"vue-tsc": "^1.8.27"
4848
}
4949
}

packages/vue-mermaid-render/src/components/VueMermaidRender.vue

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,40 @@ import { ref, watchEffect } from 'vue'
33
import mermaid from 'mermaid'
44
import type { MermaidConfig } from 'mermaid'
55
6+
/**
7+
* props
8+
*
9+
* @param {string} content - mermaid graph definition
10+
* @param {MermaidConfig} config - mermaid config
11+
*/
612
const props = defineProps<{ content: string, config?: MermaidConfig }>()
713
814
const el = ref()
915
const mermaidString = ref('')
1016
17+
/**
18+
* generate svg id
19+
*/
1120
function genSvgId() {
12-
const min = Math.ceil(1)
13-
const max = Math.floor(100000)
14-
return `mermaid-svg-${Math.floor(Math.random() * (max - min + 1))}${min}`
21+
const max = 1000000
22+
return `mermaid-svg-${genId(max)}${genId(max)}`
23+
24+
function genId(max: number) {
25+
return ~~(Math.random() * max)
26+
}
1527
}
1628
29+
/**
30+
* update graph
31+
* @param graphDefinition - mermaid graph definition
32+
*/
1733
async function updateGraph(graphDefinition: string) {
1834
const id = genSvgId()
1935
const res = await mermaid.render(id, graphDefinition, el.value)
2036
mermaidString.value = res.svg
2137
}
2238
39+
// init mermaid
2340
watchEffect(() => {
2441
if (!el.value)
2542
return
@@ -30,6 +47,7 @@ watchEffect(() => {
3047
mermaid.initialize({ startOnLoad: false })
3148
})
3249
50+
// update graph
3351
watchEffect(() => {
3452
if (!el.value)
3553
return

0 commit comments

Comments
 (0)