Skip to content

Commit 855b05b

Browse files
authored
feat: options (#90)
1 parent f5f78dd commit 855b05b

File tree

4 files changed

+43
-0
lines changed

4 files changed

+43
-0
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,16 @@ export default {
180180
</script>
181181
```
182182

183+
## Mermaid options
184+
185+
It is possible to customize the diagram by passing options to the component. The options are internally passed to `mermaid.initialize`. See the [default config](https://github.com/mermaid-js/mermaid/blob/5b269348024c031e6d76c5582242ea89a86ebf47/src/defaultConfig.js) for a list of available options.
186+
187+
```html
188+
<template>
189+
<vue-mermaid-string :value="diagram" :options="{ maxTextSize: 10000 }" />
190+
</template>
191+
```
192+
183193
## Click events
184194

185195
You can register click events by declaring them in the diagram string. See [the Mermaid docs](https://mermaid-js.github.io/mermaid/#/flowchart?id=interaction) for details. When registering a callback, you do not need to specify the callback name, the component will magically inject it into the diagram by itself. Implement the `node-click` event handler to react to click events:
Lines changed: 3 additions & 0 deletions
Loading

src/index.spec.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,34 @@ export default tester(
148148
}
149149
</script>
150150
151+
`,
152+
async test() {
153+
await this.page.goto('http://localhost:3000')
154+
await this.page.waitForSelector('.foo')
155+
expect(
156+
await this.page.screenshot({ fullPage: true })
157+
).toMatchImageSnapshot(this)
158+
},
159+
},
160+
options: {
161+
page: endent`
162+
<template>
163+
<self class="foo" :value="diagram" :options="{ maxTextSize: 3 }" />
164+
</template>
165+
166+
<script>
167+
import { endent } from '@dword-design/functions'
168+
169+
export default {
170+
computed: {
171+
diagram: () => endent\`
172+
graph TD
173+
A --> B
174+
\`,
175+
},
176+
}
177+
</script>
178+
151179
`,
152180
async test() {
153181
await this.page.goto('http://localhost:3000')

src/index.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,15 @@ export default {
4040
securityLevel: 'loose',
4141
startOnLoad: false,
4242
theme: 'default',
43+
...this.options,
4344
})
4445
}
4546
4647
return this.update()
4748
},
4849
name: 'VueMermaidString',
4950
props: {
51+
options: { default: () => ({}), type: Object },
5052
value: { required: true, type: String },
5153
},
5254
watch: {

0 commit comments

Comments
 (0)