Skip to content

Commit f260f6d

Browse files
authored
feat(editor-md): 添加公式渲染、plantuml渲染DEMO示例 (DevCloudFE#1737)
1 parent 0f29d8b commit f260f6d

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed

packages/devui-vue/docs/components/editor-md/index.md

+84
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,90 @@ export default defineComponent({
232232
editor-md/checkbox
233233
:::
234234

235+
### 数学公式 渲染
236+
237+
:::demo 通过配置md-plugins katex插件,进行数学公式渲染。
238+
239+
```vue
240+
<template>
241+
<d-editor-md
242+
v-model="content"
243+
>
244+
</d-editor-md>
245+
<!-- <d-editor-md
246+
v-model="content"
247+
:md-plugins="plugins"
248+
>
249+
</d-editor-md> -->
250+
</template>
251+
252+
<script>
253+
import { defineComponent, reactive, ref } from 'vue';
254+
// import mk from '@ittakahiro/markdown-it-katex'; // 请首先安装 @ittakahiro/markdown-it-katex 依赖
255+
256+
export default defineComponent({
257+
setup() {
258+
const content = ref(`$E = mc^2$
259+
$\\sqrt{3x-1}+(1+x)^2$ // DEMO无法进行import,使用时请放开代码中注释
260+
`);
261+
262+
mdPlugins = [{
263+
// plugin: mk
264+
}];
265+
266+
return { content, mdPlugins };
267+
},
268+
});
269+
</script>
270+
```
271+
272+
:::
273+
274+
### PlantUML 渲染
275+
276+
:::demo 通过配置md-plugins plantuml插件,进行plantuml图渲染。
277+
278+
```vue
279+
<template>
280+
<d-editor-md
281+
v-model="content"
282+
>
283+
</d-editor-md>
284+
<!-- <d-editor-md
285+
v-model="content"
286+
:md-plugins="plugins"
287+
>
288+
</d-editor-md> -->
289+
</template>
290+
291+
<script>
292+
import { defineComponent, reactive, ref } from 'vue';
293+
// import PlantUml from 'markdown-it-plantuml'; // 请首先安装 markdown-it-plantuml 依赖
294+
295+
export default defineComponent({
296+
setup() {
297+
const content = ref(`// DEMO无法进行import,使用时请放开代码中注释
298+
@startuml
299+
Alice -> "Bob()" : Hello
300+
"Bob()" -> "This is very long" as Long
301+
' You can also declare:
302+
' "Bob()" -> Long as "This is very long"
303+
Long --> "Bob()" : ok
304+
@enduml`);
305+
306+
mdPlugins = [{
307+
// plugin: PlantUml,
308+
// opts: {server: 'https://www/plantuml.com/plantuml'} // 自定义server可参考plantuml官方文档进行搭建
309+
}];
310+
311+
return { content, mdPlugins };
312+
},
313+
});
314+
</script>
315+
```
316+
317+
:::
318+
235319
### 配置快速提示
236320

237321
:::demo 设置 hintConfig 后,可用于支持@选择用户等场景。

packages/devui-vue/package.json

+2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"@babel/helper-hoist-variables": "^7.22.5",
4949
"@devui-design/icons": "^1.3.0",
5050
"@floating-ui/dom": "^0.4.4",
51+
"@iktakahiro/markdown-it-katex": "^4.0.1",
5152
"@types/codemirror": "0.0.97",
5253
"@types/lodash-es": "^4.17.4",
5354
"@vue/shared": "^3.2.33",
@@ -65,6 +66,7 @@
6566
"lodash": "^4.17.21",
6667
"lodash-es": "^4.17.20",
6768
"markdown-it": "12.2.0",
69+
"markdown-it-plantuml": "^1.4.1",
6870
"mermaid": "9.1.1",
6971
"mitt": "^3.0.0",
7072
"monaco-editor": "0.34.0",

0 commit comments

Comments
 (0)