md-editor-v3 3.0.1 → 4.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +131 -95
- package/lib/cjs/DropdownToolbar.cjs +1 -0
- package/lib/cjs/MdCatalog.cjs +1 -0
- package/lib/cjs/MdEditor.cjs +60 -0
- package/lib/cjs/MdPreview.cjs +1 -0
- package/lib/cjs/ModalToolbar.cjs +1 -0
- package/lib/cjs/NormalToolbar.cjs +1 -0
- package/lib/cjs/chunks/config.cjs +1 -0
- package/lib/cjs/chunks/dom.cjs +1 -0
- package/lib/cjs/chunks/event-bus.cjs +1 -0
- package/lib/cjs/chunks/index.cjs +8 -0
- package/lib/cjs/chunks/index2.cjs +1 -0
- package/lib/cjs/chunks/index3.cjs +1 -0
- package/lib/cjs/chunks/index4.cjs +2 -0
- package/lib/cjs/chunks/vue-tsx.cjs +1 -0
- package/lib/cjs/config.cjs +1 -0
- package/lib/cjs/index.cjs +1 -0
- package/lib/es/DropdownToolbar.mjs +7 -0
- package/lib/es/MdCatalog.mjs +215 -0
- package/lib/es/MdEditor.mjs +2286 -0
- package/lib/es/MdPreview.mjs +15 -0
- package/lib/es/ModalToolbar.mjs +9 -0
- package/lib/es/NormalToolbar.mjs +39 -0
- package/lib/es/chunks/config.mjs +271 -0
- package/lib/es/chunks/dom.mjs +32 -0
- package/lib/es/chunks/event-bus.mjs +38 -0
- package/lib/es/chunks/index.mjs +1061 -0
- package/lib/es/chunks/index2.mjs +135 -0
- package/lib/es/chunks/index3.mjs +229 -0
- package/lib/es/chunks/index4.mjs +57 -0
- package/lib/es/chunks/vue-tsx.mjs +11 -0
- package/lib/es/config.mjs +4 -0
- package/lib/es/index.mjs +35 -0
- package/lib/preview.css +1 -0
- package/lib/style.css +1 -1
- package/lib/types/DropdownToolbar/index.d.ts +129 -0
- package/lib/{MdEditor/extensions → types}/MdCatalog/CatalogLink.d.ts +4 -4
- package/lib/{MdEditor/extensions/MdCatalog/index.d.ts → types/MdCatalog/MdCatalog.d.ts} +3 -3
- package/lib/types/MdCatalog/index.d.ts +193 -0
- package/lib/{MdEditor → types/MdEditor}/Editor.d.ts +153 -162
- package/lib/types/MdEditor/components/Checkbox/index.d.ts +24 -0
- package/lib/types/MdEditor/components/Divider/index.d.ts +2 -0
- package/lib/types/MdEditor/components/Dropdown/index.d.ts +53 -0
- package/lib/types/MdEditor/components/Modal/index.d.ts +84 -0
- package/lib/types/MdEditor/composition.d.ts +66 -0
- package/lib/{MdEditor → types/MdEditor}/index.d.ts +343 -388
- package/lib/types/MdEditor/layouts/Content/ContentPreview.d.ts +154 -0
- package/lib/types/MdEditor/layouts/Content/codemirror/commands.d.ts +4 -0
- package/lib/types/MdEditor/layouts/Content/codemirror/index.d.ts +56 -0
- package/lib/types/MdEditor/layouts/Content/codemirror/themeLight.d.ts +23 -0
- package/lib/types/MdEditor/layouts/Content/codemirror/themeOneDark.d.ts +26 -0
- package/lib/types/MdEditor/layouts/Content/composition/index.d.ts +6 -0
- package/lib/types/MdEditor/layouts/Content/composition/useAttach.d.ts +7 -0
- package/lib/types/MdEditor/layouts/Content/composition/useAutoScroll.d.ts +5 -0
- package/lib/types/MdEditor/layouts/Content/composition/useCodeMirror.d.ts +13 -0
- package/lib/types/MdEditor/layouts/Content/composition/useCopyCode.d.ts +4 -0
- package/lib/types/MdEditor/layouts/Content/composition/useHighlight.d.ts +8 -0
- package/lib/types/MdEditor/layouts/Content/composition/useKatex.d.ts +8 -0
- package/lib/types/MdEditor/layouts/Content/composition/useMarkdownIt.d.ts +5 -0
- package/lib/types/MdEditor/layouts/Content/composition/useMermaid.d.ts +11 -0
- package/lib/types/MdEditor/layouts/Content/composition/usePasteUpload.d.ts +6 -0
- package/lib/types/MdEditor/layouts/Content/composition/userZoom.d.ts +10 -0
- package/lib/types/MdEditor/layouts/Content/index.d.ts +173 -0
- package/lib/types/MdEditor/layouts/Content/markdownIt/admonition/index.d.ts +5 -0
- package/lib/types/MdEditor/layouts/Content/markdownIt/codetabs/index.d.ts +14 -0
- package/lib/types/MdEditor/layouts/Content/markdownIt/heading/index.d.ts +9 -0
- package/lib/types/MdEditor/layouts/Content/markdownIt/katex/index.d.ts +10 -0
- package/lib/types/MdEditor/layouts/Content/markdownIt/mermaid/index.d.ts +6 -0
- package/lib/types/MdEditor/layouts/Content/props.d.ts +89 -0
- package/lib/types/MdEditor/layouts/Footer/MarkdownTotal.d.ts +15 -0
- package/lib/types/MdEditor/layouts/Footer/ScrollAuto.d.ts +21 -0
- package/lib/types/MdEditor/layouts/Footer/index.d.ts +50 -0
- package/lib/types/MdEditor/layouts/Modals/Clip.d.ts +33 -0
- package/lib/types/MdEditor/layouts/Modals/Link.d.ts +42 -0
- package/lib/types/MdEditor/layouts/Modals/index.d.ts +51 -0
- package/lib/types/MdEditor/layouts/Toolbar/TableShape.d.ts +28 -0
- package/lib/types/MdEditor/layouts/Toolbar/composition.d.ts +4 -0
- package/lib/types/MdEditor/layouts/Toolbar/index.d.ts +91 -0
- package/lib/types/MdEditor/layouts/Toolbar/props.d.ts +45 -0
- package/lib/types/MdEditor/props.d.ts +546 -0
- package/lib/types/MdEditor/static/event-name.d.ts +9 -0
- package/lib/{MdEditor → types/MdEditor}/type.d.ts +2 -1
- package/lib/types/MdEditor/utils/content-help.d.ts +19 -0
- package/lib/types/MdEditor/utils/dom.d.ts +22 -0
- package/lib/types/MdEditor/utils/event-bus.d.ts +17 -0
- package/lib/types/MdEditor/utils/index.d.ts +66 -0
- package/lib/types/MdEditor/utils/scroll-auto.d.ts +18 -0
- package/lib/types/MdEditor/utils/smooth-scroll.d.ts +8 -0
- package/lib/types/MdEditor/utils/vue-tsx.d.ts +23 -0
- package/lib/types/MdPreview/MdPreview.d.ts +186 -0
- package/lib/types/MdPreview/index.d.ts +453 -0
- package/lib/types/ModalToolbar/index.d.ts +244 -0
- package/lib/types/NormalToolbar/index.d.ts +105 -0
- package/lib/types/config.d.ts +1 -0
- package/lib/types/index.d.ts +8 -0
- package/lib/{md-editor-v3.umd.js → umd/index.js} +38 -38
- package/package.json +16 -20
- package/lib/md-editor-v3.cjs +0 -63
- package/lib/md-editor-v3.mjs +0 -4143
- /package/lib/{MdEditor/extensions → types/DropdownToolbar}/DropdownToolbar.d.ts +0 -0
- /package/lib/{MdEditor → types/MdEditor}/config.d.ts +0 -0
- /package/lib/{MdEditor/extensions → types/ModalToolbar}/ModalToolbar.d.ts +0 -0
- /package/lib/{MdEditor/extensions → types/NormalToolbar}/NormalToolbar.d.ts +0 -0
package/README.md
CHANGED
|
@@ -24,6 +24,7 @@ Markdown editor for vue3, developed in `jsx` and `typescript`.
|
|
|
24
24
|
- Theme of preview, `defalut`, `vuepress`, `github`, `cyanosis`, `mk-cute`, `smart-blue` styles(not identical). It can be customized also(Refer to example page).
|
|
25
25
|
- `mermaid`(>=1.8.0), `katex` mathematical formula(>=1.9.0).
|
|
26
26
|
- Customize the toolbar as you like.
|
|
27
|
+
- On-demand Import(>=4.0.0).
|
|
27
28
|
|
|
28
29
|
## 📦 Install
|
|
29
30
|
|
|
@@ -41,20 +42,45 @@ For more ways to use or contribute, please refer to: [md-editor-extension](https
|
|
|
41
42
|
|
|
42
43
|
## 💡 Usage
|
|
43
44
|
|
|
45
|
+
### ✍🏻 Display Editor
|
|
46
|
+
|
|
44
47
|
```vue
|
|
45
48
|
<template>
|
|
46
|
-
<MdEditor v-model="text"
|
|
49
|
+
<MdEditor v-model="text" />
|
|
47
50
|
</template>
|
|
48
51
|
|
|
49
52
|
<script setup>
|
|
50
53
|
import { ref } from 'vue';
|
|
51
|
-
import MdEditor from 'md-editor-v3';
|
|
54
|
+
import { MdEditor } from 'md-editor-v3';
|
|
52
55
|
import 'md-editor-v3/lib/style.css';
|
|
53
56
|
|
|
54
57
|
const text = ref('# Hello Editor');
|
|
55
58
|
</script>
|
|
56
59
|
```
|
|
57
60
|
|
|
61
|
+
> `^4.0.0`, internal components can be imported on-demand.
|
|
62
|
+
|
|
63
|
+
> If there are multiple editors on the page, please set different `editorId` for each editor!
|
|
64
|
+
|
|
65
|
+
### 📖 Preview Only
|
|
66
|
+
|
|
67
|
+
```vue
|
|
68
|
+
<template>
|
|
69
|
+
<MdPreview :editorId="id" :modelValue="text" />
|
|
70
|
+
<MdCatalog :editorId="id" :scrollElement="scrollElement" />
|
|
71
|
+
</template>
|
|
72
|
+
|
|
73
|
+
<script setup>
|
|
74
|
+
import { ref } from 'vue';
|
|
75
|
+
import { MdPreview, MdCatalog } from 'md-editor-v3';
|
|
76
|
+
import 'md-editor-v3/lib/preview.css';
|
|
77
|
+
|
|
78
|
+
const id = 'preview-only';
|
|
79
|
+
const text = ref('# Hello Editor');
|
|
80
|
+
const scrollElement = document.documentElement;
|
|
81
|
+
</script>
|
|
82
|
+
```
|
|
83
|
+
|
|
58
84
|
## 🗺 Preview
|
|
59
85
|
|
|
60
86
|
| Default theme | Dark theme | Preview only |
|
|
@@ -67,48 +93,52 @@ mark and emoji extensions
|
|
|
67
93
|
|
|
68
94
|
## 🎁 Apis
|
|
69
95
|
|
|
70
|
-
###
|
|
96
|
+
### 🔖 MdPreivew Props
|
|
71
97
|
|
|
72
98
|
| name | type | default | description |
|
|
73
99
|
| --- | --- | --- | --- |
|
|
74
100
|
| modelValue | `string` | '' | Markdown content, use `v-model` in vue template |
|
|
75
101
|
| theme | `'light' \| 'dark'` | 'light' | Editor theme |
|
|
76
102
|
| class | `string` | '' | |
|
|
77
|
-
| historyLength<sup>`deleted^3.0.0`</sup> | `number` | 10 | The max length of history. `^3.0.0` uses the `history` extension of `@codemirror/commands` instead of it. |
|
|
78
|
-
| pageFullscreen | `boolean` | false | Screenfull in web page |
|
|
79
|
-
| preview | `boolean` | true | Preview content in editor |
|
|
80
|
-
| htmlPreview | `boolean` | false | Preview html in editor(If true, preview must be false) |
|
|
81
|
-
| previewOnly | `boolean` | false | Only render preview of content, no toolbar, no editing area |
|
|
82
103
|
| language | `string` | 'zh-CN' | Build-in language('zh-CN','en-US') |
|
|
83
|
-
| toolbars | `Array<ToolbarNames \| number>` | [toolbars] | Show contents of toolbar, all keys<sup>see `toolbars` below</sup> |
|
|
84
|
-
| toolbarsExclude | `Array<ToolbarNames \| number>` | [] | Don't show contents of toolbar, all keys`toolbars` |
|
|
85
|
-
| noPrettier | `boolean` | false | Use prettier to beautify content or not |
|
|
86
104
|
| editorId | `string` | 'md-editor-v3' | Editor's id, it is used when there are more than two editors in the same page |
|
|
87
|
-
| tabWidth | `number` | 2 | One tab eq some spaces |
|
|
88
105
|
| showCodeRowNumber | `boolean` | false | Show row number for code block or not |
|
|
89
106
|
| previewTheme | `'default' \| 'github' \| 'vuepress' \| 'mk-cute' \| 'smart-blue' \| 'cyanosis'` | 'default' | Theme of preview, can be customized |
|
|
90
107
|
| style | `string \| CSSProperties` | {} | Inline style |
|
|
91
|
-
| tableShape | `[number, number]` | [6, 4] | Preset the size of the table, [columns, rows] |
|
|
92
108
|
| noMermaid | `boolean` | false | Use mermaid or not |
|
|
93
|
-
| placeholder | `string` | '' | |
|
|
94
109
|
| noKatex | `boolean` | false | Use katex or not |
|
|
95
110
|
| codeTheme | `'atom' \| 'a11y' \| 'github' \| 'gradient' \| 'kimbie' \| 'paraiso' \| 'qtcreator' \| 'stackoverflow'` | 'atom' | Highlight code style, can be customized also |
|
|
96
|
-
| markedHeadingId<sup>`deleted^3.0.0`</sup> | `(text: string, level: number, index: number) => string` | (text) => text | Use `mdHeadingId` instead of it |
|
|
97
111
|
| mdHeadingId | `(text: string, level: number, index: number) => string` | (text) => text | H1-H6 `ID` generator |
|
|
98
112
|
| sanitize | `(html: string) => string` | (html) => html | Sanitize the html, prevent XSS |
|
|
99
|
-
| footers | `Array<'markdownTotal' \| '=' \| 'scrollSwitch' \| number>` | ['markdownTotal', '=', 'scrollSwitch'] | Show contents of footer, they are divided by `'='`. Set it to `[]` to hidden footer |
|
|
100
|
-
| scrollAuto | `boolean` | true | Scroll default setting |
|
|
101
113
|
| noIconfont | `boolean` | false | Not append iconfont script, [download](https://at.alicdn.com/t/c/font_2605852_u82y61ve02.js) and import it by yourself |
|
|
102
114
|
| formatCopiedText | `(text: string) => string` | (text: string) => text | Format copied code |
|
|
103
|
-
| noUploadImg | `boolean` | false | Not show the entrance to upload pictures |
|
|
104
115
|
| codeStyleReverse | `boolean` | true | Code style will be reversed to dark while code block of the theme has a dark background |
|
|
105
116
|
| codeStyleReverseList | `Array<string>` | ['default', 'mk-cute'] | Themes to be reversed |
|
|
117
|
+
| noHighlight | `boolean` | false | never highlight code |
|
|
118
|
+
|
|
119
|
+
### 🔩 MdEditor Props
|
|
120
|
+
|
|
121
|
+
Except for the same as `MdPreview`:
|
|
122
|
+
|
|
123
|
+
| name | type | default | description |
|
|
124
|
+
| --- | --- | --- | --- |
|
|
125
|
+
| pageFullscreen | `boolean` | false | Screenfull in web page |
|
|
126
|
+
| preview | `boolean` | true | Preview content in editor |
|
|
127
|
+
| htmlPreview | `boolean` | false | Preview html in editor(If true, preview must be false) |
|
|
128
|
+
| toolbars | `Array<ToolbarNames \| number>` | [toolbars] | Show contents of toolbar, all keys<sup>see `toolbars` below</sup> |
|
|
129
|
+
| toolbarsExclude | `Array<ToolbarNames \| number>` | [] | Don't show contents of toolbar, all keys`toolbars` |
|
|
130
|
+
| noPrettier | `boolean` | false | Use prettier to beautify content or not |
|
|
131
|
+
| tabWidth | `number` | 2 | One tab eq some spaces |
|
|
132
|
+
| tableShape | `[number, number]` | [6, 4] | Preset the size of the table, [columns, rows] |
|
|
133
|
+
| placeholder | `string` | '' | |
|
|
134
|
+
| footers | `Array<'markdownTotal' \| '=' \| 'scrollSwitch' \| number>` | ['markdownTotal', '=', 'scrollSwitch'] | Show contents of footer, they are divided by `'='`. Set it to `[]` to hidden footer |
|
|
135
|
+
| scrollAuto | `boolean` | true | Scroll default setting |
|
|
136
|
+
| noUploadImg | `boolean` | false | Not show the entrance to upload pictures |
|
|
106
137
|
| autoFocus | `boolean` | false | same as `autofocus` in native textarea |
|
|
107
138
|
| disabled | `boolean` | false | same as `disabled` in native textarea |
|
|
108
139
|
| readOnly | `boolean` | false | same as `readonly` in native textarea |
|
|
109
140
|
| maxLength | `number` | | same as `maxlength` in native textarea |
|
|
110
141
|
| autoDetectCode | `boolean` | false | auto detect the type of pasted code, only support that copied from `vscode` |
|
|
111
|
-
| noHighlight | `boolean` | false | never highlight code |
|
|
112
142
|
|
|
113
143
|
<details>
|
|
114
144
|
<summary>『toolbars』</summary>
|
|
@@ -151,9 +181,9 @@ mark and emoji extensions
|
|
|
151
181
|
|
|
152
182
|
</details>
|
|
153
183
|
|
|
154
|
-
>
|
|
184
|
+
> You can sort the toolbar as you like, split tools by `'-'`, the left and right toolbars are divided by `'='`!
|
|
155
185
|
|
|
156
|
-
>
|
|
186
|
+
> You can customize the toolbar. To display them, put index of `defToolbars` into `toolbars`(this is not standard), for more usage, please refer to [docs](https://imzbf.github.io/md-editor-v3/docs).
|
|
157
187
|
|
|
158
188
|
<details>
|
|
159
189
|
<summary>『StaticTextDefaultValue』</summary>
|
|
@@ -256,6 +286,60 @@ export interface StaticTextDefaultValue {
|
|
|
256
286
|
|
|
257
287
|
</details>
|
|
258
288
|
|
|
289
|
+
### 🧵 MdPreview Events
|
|
290
|
+
|
|
291
|
+
| name | param | description |
|
|
292
|
+
| --- | --- | --- |
|
|
293
|
+
| onHtmlChanged | `html: string` | Compile markdown successful event, you can use it to get the html code |
|
|
294
|
+
| onGetCatalog | `list: Array<HeadList>` | Get catalog of article |
|
|
295
|
+
|
|
296
|
+
### 🪢 MdEditor Events
|
|
297
|
+
|
|
298
|
+
Except for the same as `MdPreview`:
|
|
299
|
+
|
|
300
|
+
| name | param | description |
|
|
301
|
+
| --- | --- | --- |
|
|
302
|
+
| onChange | `value: string` | Content changed event(bind to `oninput` of `textarea`) |
|
|
303
|
+
| onSave | `value: string, html: Promise<string>` | Save content event, `ctrl+s`and click button will be triggered also |
|
|
304
|
+
| onUploadImg | `files: Array<File>, callback: (urls: Array<string>) => void` | Upload picture event, when picture is uploading the modal will not close, please provide right urls to the callback function |
|
|
305
|
+
| onError | `err: { name: string; message: string }` | Catch run-time error, `Cropper`, `fullscreen` and `prettier` are used when they are not loaded |
|
|
306
|
+
| onBlur | `event: FocusEvent` | Blur the `textarea` element |
|
|
307
|
+
| onFocus | `event: FocusEvent` | Focus the `textarea` element |
|
|
308
|
+
|
|
309
|
+
### 🎍 Slots
|
|
310
|
+
|
|
311
|
+
| name | type | default | description |
|
|
312
|
+
| --- | --- | --- | --- |
|
|
313
|
+
| defToolbars | `Array<DropdownToolbar \| NormalToolbar \| ModalToolbar>` | null | Custom toolbar in `DropdownToolbar`, `NormalToolbar` or `ModalToolbar` |
|
|
314
|
+
| defFooters | `Array<string \| VNode \| JSX.Element>` | null | Custom footer |
|
|
315
|
+
|
|
316
|
+
`NormalToolbar` example:
|
|
317
|
+
|
|
318
|
+
```vue
|
|
319
|
+
<template>
|
|
320
|
+
<MdEditor>
|
|
321
|
+
<template #defToolbars>
|
|
322
|
+
<NormalToolbar title="mark" @onClick="handler">
|
|
323
|
+
<template #trigger>
|
|
324
|
+
<svg class="md-editor-icon" aria-hidden="true">
|
|
325
|
+
<use xlink:href="#md-editor-icon-mark"></use>
|
|
326
|
+
</svg>
|
|
327
|
+
</template>
|
|
328
|
+
</NormalToolbar>
|
|
329
|
+
</template>
|
|
330
|
+
</MdEditor>
|
|
331
|
+
</template>
|
|
332
|
+
|
|
333
|
+
<script setup lang="ts">
|
|
334
|
+
import { MdEditor, NormalToolbar } from 'md-editor-v3';
|
|
335
|
+
import 'md-editor-v3/lib/style.css';
|
|
336
|
+
|
|
337
|
+
const handler = () => {
|
|
338
|
+
console.log('NormalToolbar clicked!');
|
|
339
|
+
};
|
|
340
|
+
</script>
|
|
341
|
+
```
|
|
342
|
+
|
|
259
343
|
## 🤱🏼 Expose
|
|
260
344
|
|
|
261
345
|
After 2.5.0, Editor exposes several methods on the instance, used to get or change the internal status of the editor.
|
|
@@ -267,16 +351,14 @@ After 2.5.0, Editor exposes several methods on the instance, used to get or chan
|
|
|
267
351
|
|
|
268
352
|
<script setup lang="ts">
|
|
269
353
|
import { ref, onMounted } from 'vue';
|
|
270
|
-
import MdEditor from 'md-editor-v3';
|
|
354
|
+
import { MdEditor } from 'md-editor-v3';
|
|
271
355
|
import type { ExposeParam } from 'md-editor-v3';
|
|
272
|
-
|
|
273
356
|
import 'md-editor-v3/lib/style.css';
|
|
274
357
|
|
|
275
358
|
const editorRef = ref<ExposeParam>();
|
|
276
359
|
|
|
277
360
|
onMounted(() => {
|
|
278
361
|
editorRef.value?.on('catalog', console.log);
|
|
279
|
-
|
|
280
362
|
editorRef.value?.toggleCatalog(true);
|
|
281
363
|
});
|
|
282
364
|
</script>
|
|
@@ -398,67 +480,19 @@ focus the textarea.
|
|
|
398
480
|
editorRef.value?.focus();
|
|
399
481
|
```
|
|
400
482
|
|
|
401
|
-
### 🎍 Slots
|
|
402
|
-
|
|
403
|
-
| name | type | default | description |
|
|
404
|
-
| --- | --- | --- | --- |
|
|
405
|
-
| defToolbars | `Array<DropdownToolbar \| NormalToolbar \| ModalToolbar>` | null | Custom toolbar in `DropdownToolbar`, `NormalToolbar` or `ModalToolbar` |
|
|
406
|
-
| defFooters | `Array<string \| VNode \| JSX.Element>` | null | Custom footer |
|
|
407
|
-
|
|
408
|
-
`NormalToolbar` example:
|
|
409
|
-
|
|
410
|
-
```vue
|
|
411
|
-
<template>
|
|
412
|
-
<MdEditor>
|
|
413
|
-
<template #defToolbars>
|
|
414
|
-
<NormalToolbar title="mark" @onClick="handler">
|
|
415
|
-
<template #trigger>
|
|
416
|
-
<svg class="md-editor-icon" aria-hidden="true">
|
|
417
|
-
<use xlink:href="#md-editor-icon-mark"></use>
|
|
418
|
-
</svg>
|
|
419
|
-
</template>
|
|
420
|
-
</NormalToolbar>
|
|
421
|
-
</template>
|
|
422
|
-
</MdEditor>
|
|
423
|
-
</template>
|
|
424
|
-
|
|
425
|
-
<script setup>
|
|
426
|
-
import MdEditor from 'md-editor-v3';
|
|
427
|
-
|
|
428
|
-
const NormalToolbar = MdEditor.NormalToolbar;
|
|
429
|
-
|
|
430
|
-
const handler = () => {
|
|
431
|
-
console.log('NormalToolbar clicked!');
|
|
432
|
-
};
|
|
433
|
-
</script>
|
|
434
|
-
```
|
|
435
|
-
|
|
436
|
-
### 🪢 Events
|
|
437
|
-
|
|
438
|
-
| name | param | description |
|
|
439
|
-
| --- | --- | --- |
|
|
440
|
-
| onChange | `value: string` | Content changed event(bind to `oninput` of `textarea`) |
|
|
441
|
-
| onSave | `value: string, html: Promise<string>` | Save content event, `ctrl+s`and click button will be triggered also |
|
|
442
|
-
| onUploadImg | `files: Array<File>, callback: (urls: Array<string>) => void` | Upload picture event, when picture is uploading the modal will not close, please provide right urls to the callback function |
|
|
443
|
-
| onHtmlChanged | `html: string` | Compile markdown successful event, you can use it to get the html code |
|
|
444
|
-
| onGetCatalog | `list: Array<HeadList>` | Get catalog of article |
|
|
445
|
-
| onError | `err: { name: string; message: string }` | Catch run-time error, `Cropper`, `fullscreen` and `prettier` are used when they are not loaded |
|
|
446
|
-
| onBlur | `event: FocusEvent` | Blur the `textarea` element |
|
|
447
|
-
| onFocus | `event: FocusEvent` | Focus the `textarea` element |
|
|
448
|
-
|
|
449
483
|
## 💴 Config Editor
|
|
450
484
|
|
|
451
|
-
Use `
|
|
485
|
+
Use `config(option: ConfigOption)` to reconfigure `markdown-it` and so on.
|
|
452
486
|
|
|
453
487
|
- codeMirrorExtensions: Customize new extensions based on theme and default extensions f codeMirror.
|
|
454
488
|
|
|
455
489
|
Example: Editor does not render the line number of textarea by default, this extension needs to be manually added
|
|
456
490
|
|
|
457
491
|
```js
|
|
458
|
-
import
|
|
492
|
+
import { config } from 'md-editor-v3';
|
|
459
493
|
import { lineNumbers } from '@codemirror/view';
|
|
460
494
|
|
|
461
|
-
|
|
495
|
+
config({
|
|
462
496
|
codeMirrorExtensions(_theme, extensions) {
|
|
463
497
|
return [...extensions, lineNumbers()];
|
|
464
498
|
}
|
|
@@ -470,10 +504,10 @@ Use `MdEditor.config(option: ConfigOption)` to reconfigure `markdown-it` and so
|
|
|
470
504
|
Example: Use `markdown-it-anchor` to render a hyperlink symbol to the right of the title
|
|
471
505
|
|
|
472
506
|
```js
|
|
473
|
-
import
|
|
507
|
+
import { config } from 'md-editor-v3';
|
|
474
508
|
import ancher from 'markdown-it-anchor';
|
|
475
509
|
|
|
476
|
-
|
|
510
|
+
config({
|
|
477
511
|
markdownItConfig(mdit) {
|
|
478
512
|
mdit.use(ancher, {
|
|
479
513
|
permalink: true
|
|
@@ -485,9 +519,9 @@ Use `MdEditor.config(option: ConfigOption)` to reconfigure `markdown-it` and so
|
|
|
485
519
|
- editorConfig: Add more languages, reset `mermaid` template or delay rendering time:
|
|
486
520
|
|
|
487
521
|
```js
|
|
488
|
-
import
|
|
522
|
+
import { config } from 'md-editor-v3';
|
|
489
523
|
|
|
490
|
-
|
|
524
|
+
config({
|
|
491
525
|
editorConfig: {
|
|
492
526
|
languageUserDefined: { lang: StaticTextDefaultValue },
|
|
493
527
|
mermaidTemplate: {
|
|
@@ -503,9 +537,9 @@ Use `MdEditor.config(option: ConfigOption)` to reconfigure `markdown-it` and so
|
|
|
503
537
|
- editorExtensions: Config some dependency libraries, like highlight..
|
|
504
538
|
|
|
505
539
|
```typescript
|
|
506
|
-
import
|
|
540
|
+
import { config } from 'md-editor-v3';
|
|
507
541
|
|
|
508
|
-
|
|
542
|
+
config({
|
|
509
543
|
editorExtensions: { iconfont: 'https://xxx.cc' }
|
|
510
544
|
});
|
|
511
545
|
```
|
|
@@ -514,9 +548,7 @@ Use `MdEditor.config(option: ConfigOption)` to reconfigure `markdown-it` and so
|
|
|
514
548
|
<summary>『EditorExtensions』</summary>
|
|
515
549
|
|
|
516
550
|
```ts
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
interface EditorExtensions {
|
|
551
|
+
export interface EditorExtensions {
|
|
520
552
|
highlight?: {
|
|
521
553
|
instance?: any;
|
|
522
554
|
js?: string;
|
|
@@ -573,26 +605,31 @@ _Pay attention: shortcut keys are only available when the textarea is focused!_
|
|
|
573
605
|
| CTRL + 1-6 | h1-h6 | `# title` |
|
|
574
606
|
| CTRL + ↑ | superscript | `<sup>superscript</sup>` |
|
|
575
607
|
| CTRL + ↓ | subscript | `<sub>subscript</sub>` |
|
|
576
|
-
| CTRL + Q<sup>`deleted^3.0.0`</sup> | quote | `> quote` |
|
|
577
608
|
| CTRL + O | ordered list | `1. ordered list` |
|
|
578
609
|
| CTRL + L | link | `[link](https://github.com/imzbf/md-editor-v3)` |
|
|
579
610
|
| CTRL + Z | withdraw | Withdraw history in editor, not the function of system |
|
|
580
611
|
| CTRL + SHIFT + S | line-through | `~line-through~` |
|
|
581
612
|
| CTRL + SHIFT + U | unordered list | `- unordered list` |
|
|
582
613
|
| CTRL + SHIFT + C | code block | |
|
|
583
|
-
| CTRL + SHIFT + I | picture | `` |
|
|
584
615
|
| CTRL + SHIFT + Z | forward | Forward history in editor, not the function of system |
|
|
585
616
|
| CTRL + SHIFT + F | Beautify | |
|
|
586
617
|
| CTRL + ALT + C | code row | |
|
|
587
618
|
| CTRL + SHIFT + ALT + T | table | `\|table\|` |
|
|
588
619
|
|
|
589
|
-
## 🪤 Components
|
|
620
|
+
## 🪤 Internal Components
|
|
621
|
+
|
|
622
|
+
```vue
|
|
623
|
+
<script lang="ts" setup>
|
|
624
|
+
import { NormalToolbar } from 'md-editor-v3';
|
|
625
|
+
</script>
|
|
626
|
+
```
|
|
590
627
|
|
|
591
|
-
|
|
628
|
+
On-demand import. For more examples, refer to [document](https://imzbf.github.io/md-editor-v3).
|
|
592
629
|
|
|
593
630
|
### 🐣 NormalToolbar
|
|
594
631
|
|
|
595
|
-
`
|
|
632
|
+
`NormalToolbar`
|
|
596
633
|
|
|
597
634
|
- **props**
|
|
598
635
|
|
|
@@ -608,7 +645,7 @@ They are used as attributes of the editor component, eg: `MdEditor.DropdownToolb
|
|
|
608
645
|
|
|
609
646
|
### 🐼 DropdownToolbar
|
|
610
647
|
|
|
611
|
-
`
|
|
648
|
+
`DropdownToolbar`
|
|
612
649
|
|
|
613
650
|
- **props**
|
|
614
651
|
|
|
@@ -626,7 +663,7 @@ They are used as attributes of the editor component, eg: `MdEditor.DropdownToolb
|
|
|
626
663
|
|
|
627
664
|
### 🦉 ModalToolbar
|
|
628
665
|
|
|
629
|
-
`
|
|
666
|
+
`ModalToolbar`
|
|
630
667
|
|
|
631
668
|
- **props**
|
|
632
669
|
|
|
@@ -651,13 +688,12 @@ They are used as attributes of the editor component, eg: `MdEditor.DropdownToolb
|
|
|
651
688
|
|
|
652
689
|
### 🐻 MdCatalog
|
|
653
690
|
|
|
654
|
-
`
|
|
691
|
+
`MdCatalog`
|
|
655
692
|
|
|
656
693
|
- **props**
|
|
657
694
|
|
|
658
695
|
- `editorId`: `string`, necessary, same as editor's `editorId`, used to register listening events.
|
|
659
696
|
- `class`: `string`, not necessary.
|
|
660
|
-
- `markedHeadingId`<sup>`deleted^3.0.0`</sup>: use `mdHeadingId` instead of it.
|
|
661
697
|
- `mdHeadingId`: `MdHeadingId`, not necessary, same as editor.
|
|
662
698
|
- `scrollElement`: `string | HTMLElement`, not necessary, it is an element selector when its type is string. When `previewOnly` eq `true`, it is usually set to `document.documentElement`.
|
|
663
699
|
- `theme`: `'light' | 'dark'`, not necessary, provide it when you want to change theme online, it is the same as Editor `theme`.
|
|
@@ -674,7 +710,7 @@ They are used as attributes of the editor component, eg: `MdEditor.DropdownToolb
|
|
|
674
710
|
|
|
675
711
|
```jsx
|
|
676
712
|
import { defineComponent, reactive } from 'vue';
|
|
677
|
-
import MdEditor from 'md-editor-v3';
|
|
713
|
+
import { MdEditor } from 'md-editor-v3';
|
|
678
714
|
import 'md-editor-v3/lib/style.css';
|
|
679
715
|
|
|
680
716
|
export default defineComponent({
|
|
@@ -701,7 +737,7 @@ export default defineComponent({
|
|
|
701
737
|
<script setup>
|
|
702
738
|
import { ref } from 'vue';
|
|
703
739
|
import axios from 'axios';
|
|
704
|
-
import MdEditor from 'md-editor-v3';
|
|
740
|
+
import { MdEditor } from 'md-editor-v3';
|
|
705
741
|
import 'md-editor-v3/lib/style.css';
|
|
706
742
|
|
|
707
743
|
const text = ref('# Hello Editor');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const r=require("./chunks/index2.cjs");require("vue");require("./chunks/config.cjs");require("./chunks/vue-tsx.cjs");module.exports=r.DropdownToolbar;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const n=require("vue"),h=require("./chunks/config.cjs"),T=require("./chunks/index4.cjs"),y=require("./chunks/event-bus.cjs"),x={tocItem:{type:Object,default:()=>({})},mdHeadingId:{type:Function,default:()=>{}},scrollElement:{type:[String,Object],default:""},onClick:{type:Function,default:()=>{}},scrollElementOffsetTop:{type:Number,default:0}},C=n.defineComponent({props:x,setup(l){return()=>{const{tocItem:o,mdHeadingId:d,scrollElement:c,onClick:u,scrollElementOffsetTop:p}=l;return n.createVNode("div",{class:[`${h.prefix}-catalog-link`,o.active&&`${h.prefix}-catalog-active`],onClick:r=>{u(r,o),r.stopPropagation();const E=d(o.text,o.level,o.index),m=document.getElementById(E),e=c instanceof Element?c:document.querySelector(c);if(m&&e){let t=m.offsetParent,s=m.offsetTop;if(e.contains(t))for(;t&&e!=t;)s+=t==null?void 0:t.offsetTop,t=t==null?void 0:t.offsetParent;e==null||e.scrollTo({top:s-p,behavior:"smooth"})}}},[n.createVNode("span",{title:o.text},[o.text]),n.createVNode("div",{class:`${h.prefix}-catalog-wrapper`},[o.children&&o.children.map(r=>n.createVNode(C,{mdHeadingId:d,key:`${o.text}-link-${r.level}-${r.text}`,tocItem:r,scrollElement:c,onClick:u,scrollElementOffsetTop:p},null))])])}}}),H=C,$={editorId:{type:String},class:{type:String,default:""},mdHeadingId:{type:Function,default:l=>l},scrollElement:{type:[String,Object]},theme:{type:String,default:"light"},offsetTop:{type:Number,default:20},scrollElementOffsetTop:{type:Number,default:0},onClick:{type:Function}},b=n.defineComponent({name:"MdCatalog",props:$,emits:["onClick"],setup(l,o){const d=l.editorId,c=n.reactive({list:[],show:!1,scrollElement:l.scrollElement||`#${d}-preview-wrapper`}),u=n.shallowRef(),p=n.computed(()=>{const e=[];return c.list.forEach((t,s)=>{const{text:g,level:I}=t,a={level:I,text:g,index:s+1,active:u.value===t};if(e.length===0)e.push(a);else{let i=e[e.length-1];if(a.level>i.level)for(let f=i.level+1;f<=6;f++){const{children:v}=i;if(!v){i.children=[a];break}if(i=v[v.length-1],a.level<=i.level){v.push(a);break}}else e.push(a)}}),e}),r=()=>c.scrollElement instanceof HTMLElement?c.scrollElement:document.querySelector(c.scrollElement),E=T.throttle(e=>{if(e.length===0)return!1;const{activeHead:t}=e.reduce((s,g,I)=>{const a=document.getElementById(l.mdHeadingId(g.text,g.level,I+1));if(a instanceof HTMLElement){const i=r(),f=T.getRelativeTop(a,i);if(f<l.offsetTop&&f>s.minTop)return{activeHead:g,minTop:f}}return s},{activeHead:e[0],minTop:Number.MIN_SAFE_INTEGER});u.value=t,c.list=e}),m=()=>{E(c.list)};return n.onMounted(()=>{var t;const e=r();(t=e===document.documentElement?window:e)==null||t.addEventListener("scroll",m),y.bus.on(d,{name:"catalogChanged",callback:s=>{E(s)}}),y.bus.emit(d,"pushCatalog")}),n.onBeforeUnmount(()=>{var t;const e=r();(t=e===document.documentElement?window:e)==null||t.removeEventListener("scroll",m)}),()=>n.createVNode("div",{class:`${h.prefix}-catalog${l.theme==="dark"?"-dark":""} ${l.class}`},[p.value.map(e=>n.createVNode(H,{mdHeadingId:l.mdHeadingId,tocItem:e,key:`link-${e.level}-${e.text}`,scrollElement:c.scrollElement,onClick:(t,s)=>{l.onClick?l.onClick(t,s):o.emit("onClick",t,s)},scrollElementOffsetTop:l.scrollElementOffsetTop},null))])}}),k=b;k.install=l=>(l.component(k.name,k),l);module.exports=k;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";var qe=Object.defineProperty;var Re=(t,a,r)=>a in t?qe(t,a,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[a]=r;var q=(t,a,r)=>(Re(t,typeof a!="symbol"?a+"":a,r),r);const e=require("vue"),l=require("./chunks/config.cjs"),K=require("./chunks/index2.cjs"),h=require("./chunks/event-bus.cjs"),ie=require("./chunks/index4.cjs"),w=require("./chunks/index.cjs"),Pe=require("./chunks/dom.cjs"),ne=require("./chunks/index3.cjs"),Y=require("codemirror"),X=require("@codemirror/view"),je=require("@codemirror/language-data"),Ge=require("@codemirror/lang-markdown"),oe=require("@codemirror/commands"),Q=require("@codemirror/language"),n=require("@lezer/highlight"),R=require("@codemirror/state"),Ne=require("./chunks/vue-tsx.cjs"),Oe=require("./MdCatalog.cjs"),Ue=require("./NormalToolbar.cjs");require("medium-zoom");require("copy-to-clipboard");require("markdown-it");require("markdown-it-image-figures");require("markdown-it-task-lists");require("lru-cache");const Ke=e.defineComponent({setup(){return()=>e.createVNode("div",{class:`${l.prefix}-divider`},null)}}),_e={noPrettier:{type:Boolean},toolbars:{type:Array,default:()=>[]},toolbarsExclude:{type:Array,default:()=>[]},setting:{type:Object,default:()=>({})},screenfull:{type:Object,default:null},screenfullJs:{type:String,default:""},updateSetting:{type:Function,default:()=>{}},tableShape:{type:Array,default:()=>[6,4]},defToolbars:{type:Object},noUploadImg:{type:Boolean}},We=t=>{var g,d,u,v;const a=e.inject("editorId");let r=(d=(g=l.configOption.editorExtensions)==null?void 0:g.screenfull)==null?void 0:d.instance;const o=(v=(u=l.configOption.editorExtensions)==null?void 0:u.screenfull)==null?void 0:v.js,c=e.ref(!1),i=k=>{if(!r){h.bus.emit(a,"errorCatcher",{name:"fullscreen",message:"fullscreen is undefined"});return}r.isEnabled?(c.value=!0,(k===void 0?!r.isFullscreen:k)?r.request():r.exit()):console.error("browser does not support screenfull!")},s=()=>{r&&r.isEnabled&&r.on("change",()=>{(c.value||t.setting.fullscreen)&&(c.value=!1,t.updateSetting("fullscreen"))})},m=()=>{r=window.screenfull,s()};return e.onMounted(()=>{if(s(),!r){const k=document.createElement("script");k.src=o||l.screenfullUrl,k.onload=m,k.id=`${l.prefix}-screenfull`,Pe.appendHandler(k,"screenfull")}}),e.onMounted(()=>{h.bus.on(a,{name:w.CHANGE_FULL_SCREEN,callback:i})}),{fullscreenHandler:i}},ze={tableShape:{type:Array,default:()=>[6,4]},onSelected:{type:Function,default:()=>{}}},Ye=e.defineComponent({name:"TableShape",props:ze,setup(t){const a=e.reactive({x:-1,y:-1});return()=>e.createVNode("div",{class:`${l.prefix}-table-shape`,onMouseleave:()=>{a.x=-1,a.y=-1}},[new Array(t.tableShape[1]).fill("").map((r,o)=>e.createVNode("div",{class:`${l.prefix}-table-shape-row`,key:`table-shape-row-${o}`},[new Array(t.tableShape[0]).fill("").map((c,i)=>e.createVNode("div",{class:`${l.prefix}-table-shape-col`,key:`table-shape-col-${i}`,onMouseenter:()=>{a.x=o,a.y=i},onClick:()=>{t.onSelected(a)}},[e.createVNode("div",{class:[`${l.prefix}-table-shape-col-default`,o<=a.x&&i<=a.y&&`${l.prefix}-table-shape-col-include`]},null)]))]))])}}),Ze=Ye,Je={type:{type:String,default:"link"},visible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},Xe=e.defineComponent({props:Je,setup(t){const a=e.inject("usedLanguageText"),r=e.inject("editorId"),o=e.computed(()=>{var i,s;switch(t.type){case"link":return(i=a.value.linkModalTips)==null?void 0:i.linkTitle;case"image":return(s=a.value.linkModalTips)==null?void 0:s.imageTitle;default:return""}}),c=e.reactive({desc:"",url:""});return e.watch(()=>t.visible,i=>{i||setTimeout(()=>{c.desc="",c.url=""},200)}),()=>e.createVNode(ne.Modal,{title:o.value,visible:t.visible,onClose:t.onCancel},{default:()=>{var i,s,m,g,d;return[e.createVNode("div",{class:`${l.prefix}-form-item`},[e.createVNode("label",{class:`${l.prefix}-label`,for:`link-desc-${r}`},[(i=a.value.linkModalTips)==null?void 0:i.descLabel]),e.createVNode("input",{placeholder:(s=a.value.linkModalTips)==null?void 0:s.descLabelPlaceHolder,class:`${l.prefix}-input`,id:`link-desc-${r}`,type:"text",value:c.desc,onChange:u=>{c.desc=u.target.value},autocomplete:"off"},null)]),e.createVNode("div",{class:`${l.prefix}-form-item`},[e.createVNode("label",{class:`${l.prefix}-label`,for:`link-url-${r}`},[(m=a.value.linkModalTips)==null?void 0:m.urlLabel]),e.createVNode("input",{placeholder:(g=a.value.linkModalTips)==null?void 0:g.urlLabelPlaceHolder,class:`${l.prefix}-input`,id:`link-url-${r}`,type:"text",value:c.url,onChange:u=>{c.url=u.target.value},autocomplete:"off"},null)]),e.createVNode("div",{class:`${l.prefix}-form-item`},[e.createVNode("button",{class:[`${l.prefix}-btn`,`${l.prefix}-btn-row`],type:"button",onClick:()=>{t.onOk(c),c.desc="",c.url=""}},[(d=a.value.linkModalTips)==null?void 0:d.buttonOK])])]}})}}),Qe={visible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},et=e.defineComponent({props:Qe,setup(t){var u,v,k;const a=e.inject("usedLanguageText"),r=e.inject("editorId");let o=(k=(v=(u=l.configOption)==null?void 0:u.editorExtensions)==null?void 0:v.cropper)==null?void 0:k.instance;const c=e.ref(),i=e.ref(),s=e.ref(),m=e.reactive({cropperInited:!1,imgSelected:!1,imgSrc:"",isFullscreen:!1});let g=null;e.watch(()=>t.visible,()=>{t.visible&&!m.cropperInited&&(o=o||window.Cropper,c.value.onchange=()=>{if(!o){h.bus.emit(r,"errorCatcher",{name:"Cropper",message:"Cropper is undefined"});return}const b=c.value.files||[];if(m.imgSelected=!0,(b==null?void 0:b.length)>0){const p=new FileReader;p.onload=f=>{m.imgSrc=f.target.result,e.nextTick(()=>{g=new o(i.value,{viewMode:2,preview:`.${l.prefix}-clip-preview-target`})})},p.readAsDataURL(b[0])}})}),e.watch(()=>[m.imgSelected],()=>{s.value.style=""}),e.watch(()=>m.isFullscreen,()=>{e.nextTick(()=>{g==null||g.destroy(),s.value.style="",i.value&&(g=new o(i.value,{viewMode:2,preview:`.${l.prefix}-clip-preview-target`}))})});const d=()=>{g.clear(),g.destroy(),g=null,c.value.value="",m.imgSelected=!1};return()=>{var b;return e.createVNode(ne.Modal,{class:`${l.prefix}-modal-clip`,title:(b=a.value.clipModalTips)==null?void 0:b.title,visible:t.visible,onClose:t.onCancel,showAdjust:!0,isFullscreen:m.isFullscreen,onAdjust:p=>{m.isFullscreen=p},width:"668px",height:"421px"},{default:()=>{var p,f;return[e.createVNode("div",{class:`${l.prefix}-form-item ${l.prefix}-clip`},[e.createVNode("div",{class:`${l.prefix}-clip-main`},[m.imgSelected?e.createVNode("div",{class:`${l.prefix}-clip-cropper`},[e.createVNode("img",{src:m.imgSrc,ref:i,style:{display:"none"},alt:""},null),e.createVNode("div",{class:`${l.prefix}-clip-delete`,onClick:d},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-delete"},null)])])]):e.createVNode("div",{class:`${l.prefix}-clip-upload`,onClick:()=>{c.value.click()}},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-upload"},null)])])]),e.createVNode("div",{class:`${l.prefix}-clip-preview`},[e.createVNode("div",{class:`${l.prefix}-clip-preview-target`,ref:s},null)])]),e.createVNode("div",{class:`${l.prefix}-form-item`},[e.createVNode("button",{class:`${l.prefix}-btn`,type:"button",onClick:()=>{if(g){const x=g.getCroppedCanvas();h.bus.emit(r,"uploadImage",[ie.base642File(x.toDataURL("image/png"))],t.onOk),d()}}},[((p=a.value.clipModalTips)==null?void 0:p.buttonUpload)||((f=a.value.linkModalTips)==null?void 0:f.buttonOK)])]),e.createVNode("input",{ref:c,accept:"image/*",type:"file",multiple:!1,style:{display:"none"}},null)]}})}}}),tt={type:{type:String,default:"link"},linkVisible:{type:Boolean,default:!1},clipVisible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},ot=e.defineComponent({props:tt,setup(t){return()=>e.createVNode(e.Fragment,null,[e.createVNode(Xe,{type:t.type,visible:t.linkVisible,onOk:t.onOk,onCancel:t.onCancel},null),e.createVNode(et,{visible:t.clipVisible,onOk:t.onOk,onCancel:t.onCancel},null)])}}),lt=e.defineComponent({name:"MDEditorToolbar",props:_e,setup(t){const a=e.inject("editorId"),r=e.inject("usedLanguageText"),{fullscreenHandler:o}=We(t),c=`${a}-toolbar-wrapper`,i=e.reactive({title:!1,catalog:!1,image:!1,table:!1,mermaid:!1,katex:!1}),s=(b,p)=>{h.bus.emit(a,"replace",b,p)},m=e.reactive({type:"link",linkVisible:!1,clipVisible:!1}),g=e.ref();e.onMounted(()=>{h.bus.on(a,{name:"openModals",callback(b){m.type=b,m.linkVisible=!0}})});const d=e.computed(()=>{const b=t.toolbars.filter($=>!t.toolbarsExclude.includes($)),p=b.indexOf("="),f=p===-1?b:b.slice(0,p+1),x=p===-1?[]:b.slice(p,Number.MAX_SAFE_INTEGER);return[f,x]}),u=e.ref(),v=()=>{h.bus.emit(a,"uploadImage",Array.from(u.value.files||[])),u.value.value=""};e.onMounted(()=>{u.value.addEventListener("change",v)});const k=b=>{var p,f,x,$,y,N,T,C,S,B,M,A,L,H,E,P,I,ee,_,j,O,W,G,D,F,z,te,ce,se,de,ue,fe,ge,me,he,be,pe,ve,ke,xe,Ce,Ve,$e;if(l.allToolbar.includes(b))switch(b){case"-":return e.createVNode(Ke,null,null);case"bold":return e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(p=r.value.toolbarTips)==null?void 0:p.bold,onClick:()=>{s("bold")}},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-bold"},null)])]);case"underline":return e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(f=r.value.toolbarTips)==null?void 0:f.underline,onClick:()=>{s("underline")}},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-underline"},null)])]);case"italic":return e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(x=r.value.toolbarTips)==null?void 0:x.italic,onClick:()=>{s("italic")}},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-italic"},null)])]);case"strikeThrough":return e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:($=r.value.toolbarTips)==null?void 0:$.strikeThrough,onClick:()=>{s("strikeThrough")}},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-strike-through"},null)])]);case"title":return e.createVNode(K.Dropdown,{relative:`#${c}`,visible:i.title,onChange:V=>{i.title=V},overlay:e.createVNode("ul",{class:`${l.prefix}-menu`,onClick:()=>{i.title=!1}},[e.createVNode("li",{class:`${l.prefix}-menu-item`,onClick:()=>{s("h1")}},[(y=r.value.titleItem)==null?void 0:y.h1]),e.createVNode("li",{class:`${l.prefix}-menu-item`,onClick:()=>{s("h2")}},[(N=r.value.titleItem)==null?void 0:N.h2]),e.createVNode("li",{class:`${l.prefix}-menu-item`,onClick:()=>{s("h3")}},[(T=r.value.titleItem)==null?void 0:T.h3]),e.createVNode("li",{class:`${l.prefix}-menu-item`,onClick:()=>{s("h4")}},[(C=r.value.titleItem)==null?void 0:C.h4]),e.createVNode("li",{class:`${l.prefix}-menu-item`,onClick:()=>{s("h5")}},[(S=r.value.titleItem)==null?void 0:S.h5]),e.createVNode("li",{class:`${l.prefix}-menu-item`,onClick:()=>{s("h6")}},[(B=r.value.titleItem)==null?void 0:B.h6])])},{default:()=>{var V;return[e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(V=r.value.toolbarTips)==null?void 0:V.title},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-title"},null)])])]}});case"sub":return e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(M=r.value.toolbarTips)==null?void 0:M.sub,onClick:()=>{s("sub")}},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-sub"},null)])]);case"sup":return e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(A=r.value.toolbarTips)==null?void 0:A.sup,onClick:()=>{s("sup")}},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-sup"},null)])]);case"quote":return e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(L=r.value.toolbarTips)==null?void 0:L.quote,onClick:()=>{s("quote")}},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-quote"},null)])]);case"unorderedList":return e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(H=r.value.toolbarTips)==null?void 0:H.unorderedList,onClick:()=>{s("unorderedList")}},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-unordered-list"},null)])]);case"orderedList":return e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(E=r.value.toolbarTips)==null?void 0:E.orderedList,onClick:()=>{s("orderedList")}},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-ordered-list"},null)])]);case"task":return e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(P=r.value.toolbarTips)==null?void 0:P.task,onClick:()=>{s("task")}},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-task"},null)])]);case"codeRow":return e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(I=r.value.toolbarTips)==null?void 0:I.codeRow,onClick:()=>{s("codeRow")}},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-code-row"},null)])]);case"code":return e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(ee=r.value.toolbarTips)==null?void 0:ee.code,onClick:()=>{s("code")}},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-code"},null)])]);case"link":return e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(_=r.value.toolbarTips)==null?void 0:_.link,onClick:()=>{m.type="link",m.linkVisible=!0}},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-link"},null)])]);case"image":return t.noUploadImg?e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(j=r.value.toolbarTips)==null?void 0:j.image,onClick:()=>{m.type="image",m.linkVisible=!0}},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-image"},null)])]):e.createVNode(K.Dropdown,{relative:`#${c}`,visible:i.image,onChange:V=>{i.image=V},overlay:e.createVNode("ul",{class:`${l.prefix}-menu`,onClick:()=>{i.title=!1}},[e.createVNode("li",{class:`${l.prefix}-menu-item`,onClick:()=>{m.type="image",m.linkVisible=!0}},[(O=r.value.imgTitleItem)==null?void 0:O.link]),e.createVNode("li",{class:`${l.prefix}-menu-item`,onClick:()=>{u.value.click()}},[(W=r.value.imgTitleItem)==null?void 0:W.upload]),e.createVNode("li",{class:`${l.prefix}-menu-item`,onClick:()=>{m.clipVisible=!0}},[(G=r.value.imgTitleItem)==null?void 0:G.clip2upload])])},{default:()=>{var V;return[e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(V=r.value.toolbarTips)==null?void 0:V.image},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-image"},null)])])]}});case"table":return e.createVNode(K.Dropdown,{relative:`#${c}`,visible:i.table,onChange:V=>{i.table=V},key:"bar-table",overlay:e.createVNode(Ze,{tableShape:t.tableShape,onSelected:V=>{s("table",{selectedShape:V})}},null)},{default:()=>{var V;return[e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(V=r.value.toolbarTips)==null?void 0:V.table},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-table"},null)])])]}});case"revoke":return e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(D=r.value.toolbarTips)==null?void 0:D.revoke,onClick:()=>{h.bus.emit(a,"ctrlZ")}},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-revoke"},null)])]);case"next":return e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(F=r.value.toolbarTips)==null?void 0:F.next,onClick:()=>{h.bus.emit(a,"ctrlShiftZ")}},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-next"},null)])]);case"save":return e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(z=r.value.toolbarTips)==null?void 0:z.save,onClick:()=>{h.bus.emit(a,w.ON_SAVE)}},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-baocun"},null)])]);case"prettier":return t.noPrettier?"":e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(te=r.value.toolbarTips)==null?void 0:te.prettier,onClick:()=>{s("prettier")}},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-prettier"},null)])]);case"pageFullscreen":return!t.setting.fullscreen&&e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(ce=r.value.toolbarTips)==null?void 0:ce.pageFullscreen,onClick:()=>{t.updateSetting("pageFullscreen")}},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":`#md-editor-icon-${t.setting.pageFullscreen?"suoxiao":"fangda"}`},null)])]);case"fullscreen":return e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(se=r.value.toolbarTips)==null?void 0:se.fullscreen,onClick:()=>{o()}},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":`#md-editor-icon-${t.setting.fullscreen?"fullscreen-exit":"fullscreen"}`},null)])]);case"preview":return e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(de=r.value.toolbarTips)==null?void 0:de.preview,onClick:()=>{t.updateSetting("preview")}},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-preview"},null)])]);case"htmlPreview":return e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(ue=r.value.toolbarTips)==null?void 0:ue.htmlPreview,onClick:()=>{t.updateSetting("htmlPreview")}},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-coding"},null)])]);case"catalog":return e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(fe=r.value.toolbarTips)==null?void 0:fe.catalog,onClick:()=>{h.bus.emit(a,w.CHANGE_CATALOG_VISIBLE)},key:"bar-catalog"},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-catalog"},null)])]);case"github":return e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(ge=r.value.toolbarTips)==null?void 0:ge.github,onClick:()=>ie.goto("https://github.com/imzbf/md-editor-v3")},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-github"},null)])]);case"mermaid":return e.createVNode(K.Dropdown,{relative:`#${c}`,visible:i.mermaid,onChange:V=>{i.mermaid=V},overlay:e.createVNode("ul",{class:`${l.prefix}-menu`,onClick:()=>{i.mermaid=!1}},[e.createVNode("li",{class:`${l.prefix}-menu-item`,onClick:()=>{s("flow")}},[(me=r.value.mermaid)==null?void 0:me.flow]),e.createVNode("li",{class:`${l.prefix}-menu-item`,onClick:()=>{s("sequence")}},[(he=r.value.mermaid)==null?void 0:he.sequence]),e.createVNode("li",{class:`${l.prefix}-menu-item`,onClick:()=>{s("gantt")}},[(be=r.value.mermaid)==null?void 0:be.gantt]),e.createVNode("li",{class:`${l.prefix}-menu-item`,onClick:()=>{s("class")}},[(pe=r.value.mermaid)==null?void 0:pe.class]),e.createVNode("li",{class:`${l.prefix}-menu-item`,onClick:()=>{s("state")}},[(ve=r.value.mermaid)==null?void 0:ve.state]),e.createVNode("li",{class:`${l.prefix}-menu-item`,onClick:()=>{s("pie")}},[(ke=r.value.mermaid)==null?void 0:ke.pie]),e.createVNode("li",{class:`${l.prefix}-menu-item`,onClick:()=>{s("relationship")}},[(xe=r.value.mermaid)==null?void 0:xe.relationship]),e.createVNode("li",{class:`${l.prefix}-menu-item`,onClick:()=>{s("journey")}},[(Ce=r.value.mermaid)==null?void 0:Ce.journey])]),key:"bar-mermaid"},{default:()=>{var V;return[e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(V=r.value.toolbarTips)==null?void 0:V.mermaid},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-mermaid"},null)])])]}});case"katex":return e.createVNode(K.Dropdown,{relative:`#${c}`,visible:i.katex,onChange:V=>{i.katex=V},overlay:e.createVNode("ul",{class:`${l.prefix}-menu`,onClick:()=>{i.katex=!1}},[e.createVNode("li",{class:`${l.prefix}-menu-item`,onClick:()=>{s("katexInline")}},[(Ve=r.value.katex)==null?void 0:Ve.inline]),e.createVNode("li",{class:`${l.prefix}-menu-item`,onClick:()=>{s("katexBlock")}},[($e=r.value.katex)==null?void 0:$e.block])]),key:"bar-katex"},{default:()=>{var V;return[e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(V=r.value.toolbarTips)==null?void 0:V.katex},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-formula"},null)])])]}})}else return t.defToolbars instanceof Array?t.defToolbars[b]||"":t.defToolbars&&t.defToolbars.children instanceof Array&&t.defToolbars.children[b]||""};return()=>{const b=d.value[0].map(f=>k(f)),p=d.value[1].map(f=>k(f));return e.createVNode(e.Fragment,null,[t.toolbars.length>0&&e.createVNode("div",{class:`${l.prefix}-toolbar-wrapper`,id:c},[e.createVNode("div",{class:`${l.prefix}-toolbar`},[e.createVNode("div",{class:`${l.prefix}-toolbar-left`,ref:g},[b]),e.createVNode("div",{class:`${l.prefix}-toolbar-right`},[p])])]),e.createVNode("input",{ref:u,accept:"image/*",type:"file",multiple:!0,style:{display:"none"}},null),e.createVNode(ot,{linkVisible:m.linkVisible,clipVisible:m.clipVisible,type:m.type,onCancel:()=>{m.linkVisible=!1,m.clipVisible=!1},onOk:f=>{f&&s(m.type,{desc:f.desc,url:f.url}),m.linkVisible=!1,m.clipVisible=!1}},null)])}}}),at=(t,a,r)=>{let o=t.scrollTop;const c=()=>{const i=a-o;o=o+i/5,Math.abs(i)<1?(t.scrollTo(0,a),r&&setTimeout(r,100)):(t.scrollTo(0,o),requestAnimationFrame(c))};c()},ye=at,rt=(t,a)=>{const r=ie.debounce(()=>{t.removeEventListener("scroll",o),t.addEventListener("scroll",o),a.removeEventListener("scroll",o),a.addEventListener("scroll",o)},50),o=c=>{const i=t.clientHeight,s=a.clientHeight,m=t.scrollHeight,g=a.scrollHeight,d=(m-i)/(g-s);c.target===t?(a.removeEventListener("scroll",o),a.scrollTo({top:t.scrollTop/d}),r()):(t.removeEventListener("scroll",o),t.scrollTo({top:a.scrollTop*d}),r())};return[()=>{r().finally(()=>{t.dispatchEvent(new Event("scroll"))})},()=>{t.removeEventListener("scroll",o),a.removeEventListener("scroll",o)}]},it=(t,a,r)=>{const{view:o}=r,c=v=>o.lineBlockAt(o.state.doc.line(v).from).top,i=v=>o.lineBlockAt(o.state.doc.line(v).from).height;let s=[];const m=()=>{s=[];const v=Array.from(a.querySelectorAll("[data-line]")).map(f=>Number(f.dataset.line)+1),{lines:k}=o.state.doc;let b=1,p=v.shift()??k;for(let f=1;f<=k;f++)f===p&&(b=f,p=v.shift()||k+1),s.push({start:b,end:p-1})};let g=0,d=0;const u=v=>{var p,f,x,$,y,N,T;if(!((p=a.firstElementChild)!=null&&p.firstElementChild))return;const k=o.lineBlockAtHeight(o.scrollDOM.scrollTop),{number:b}=o.state.doc.lineAt(k.from);if(!(b>s.length)&&!(o.state.doc.lines<s[s.length-1].end))if(v.target===t){if(d!==0)return;g++;const C=s[b-1],S=c(C.end)+i(C.end);let B=0;const M=c(C.start),A=a.querySelector(`[data-line="${C.start-1}"]`)||((f=a.firstElementChild)==null?void 0:f.firstElementChild),L=a.querySelector(`[data-line="${C.end}"]`)||((x=a.lastElementChild)==null?void 0:x.lastElementChild);let H=0,E=0;M===0?(B=(o.scrollDOM.scrollTop-M)/(S-M),H=L.offsetTop):S>o.scrollDOM.scrollHeight-o.scrollDOM.clientHeight?(B=(o.scrollDOM.scrollTop-M)/(o.scrollDOM.scrollHeight-o.scrollDOM.clientHeight-M),E=A.offsetTop,H=a.scrollHeight-a.clientHeight-E+10):(B=(o.scrollDOM.scrollTop-M)/(S-M),E=A.offsetTop,H=L.offsetTop-E);const P=E-10+H*B;ye(a,P,()=>{g--})}else{if(g!==0)return;d++;const C=Array.from(a.querySelectorAll("[data-line]")),S=a.scrollTop,B=a.scrollHeight;let M=C.length===0?1:Math.ceil(Number(C[C.length-1].dataset.line)*(S/B)),A=($=a.firstElementChild)==null?void 0:$.firstElementChild;for(let D=M;D>=0;D--){const F=a.querySelector(`[data-line="${D}"]`);if(F){A=F,M=D;break}}let L=(y=a.firstElementChild)==null?void 0:y.firstElementChild,H=(N=a.firstElementChild)==null?void 0:N.lastElementChild;for(;C.length>0;){const D=C.indexOf(A);if(D+1>=C.length)break;const F=C[D+1],z=A.offsetTop;if(z>S){if(D===0){L=A,H=F;break}A=C[D-1];continue}const te=F.offsetTop;if(z<=S&&te>S){L=A,H=F;break}A=F}const E=L.offsetTop,P=H.offsetTop;let I=0;const{start:ee,end:_}=s[Number(L.dataset.line||0)],j=c(ee);let O=c(_);const W=i(_);let G=0;L===((T=a.firstElementChild)==null?void 0:T.firstElementChild)?(I=Math.max(S/P,0),G=O+W-j):O>o.scrollDOM.scrollHeight-o.scrollDOM.clientHeight?(I=Math.max((S-E)/(a.scrollHeight-E-a.clientHeight),0),O=c(o.state.doc.lines)+i(o.state.doc.lines),G=8+O-j-t.clientHeight):(I=Math.max((S-E)/(P-E),0),G=O+W-j),ye(t,j+G*I,()=>{d--})}};return[()=>{m(),t.addEventListener("scroll",u),a.addEventListener("scroll",u),t.dispatchEvent(new Event("scroll"))},()=>{s=[],t.removeEventListener("scroll",u),a.removeEventListener("scroll",u)}]},nt=(t,a,r)=>{const o=e.inject("editorId");let c=()=>{},i=()=>{};const s=()=>{c();const m=document.querySelector(".cm-scroller"),g=document.querySelector(`[id="${o}-preview-wrapper"][data-show="true"]`),d=document.querySelector(`[id="${o}-html-wrapper"][data-show="true"]`);(g||d)&&([i,c]=(g?it:rt)(m,g||d,r.value)),t.scrollAuto&&i()};e.watch([a,e.toRef(t.setting,"preview"),e.toRef(t.setting,"htmlPreview"),e.toRef(t.setting,"fullscreen"),e.toRef(t.setting,"pageFullscreen")],()=>{e.nextTick(s)}),e.watch(()=>t.scrollAuto,m=>{m?i():c()}),e.onMounted(s)},ct=nt,st=(t,a,r)=>{var u,v,k,b,p,f;let o="",c=0,i=0,s=!0,m=!1;const g=a.getSelectedText(),d=(u=l.configOption.editorConfig)==null?void 0:u.mermaidTemplate;if(/^h[1-6]{1}$/.test(t)){const x=t.replace(/^h(\d)/,($,y)=>new Array(Number(y)).fill("#",0,y).join(""));o=`${x} ${g}`,c=x.length+1}else if(t==="prettier"){const x=window.prettier||((k=(v=l.configOption.editorExtensions)==null?void 0:v.prettier)==null?void 0:k.prettierInstance),$=[((b=window.prettierPlugins)==null?void 0:b.markdown)||((f=(p=l.configOption.editorExtensions)==null?void 0:p.prettier)==null?void 0:f.parserMarkdownInstance)];!x||$[0]===void 0?(h.bus.emit(r.editorId,"errorCatcher",{name:"prettier",message:"prettier is undefined"}),o=a.getValue()):o=x.format(a.getValue(),{parser:"markdown",plugins:$}),s=!1,m=!0}else switch(t){case"bold":{o=`**${g}**`,c=2,i=-2;break}case"underline":{o=`<u>${g}</u>`,c=3,i=-4;break}case"italic":{o=`*${g}*`,c=1,i=-1;break}case"strikeThrough":{o=`~~${g}~~`,c=2,i=-2;break}case"sub":{o=`<sub>${g}</sub>`,c=5,i=-6;break}case"sup":{o=`<sup>${g}</sup>`,c=5,i=-6;break}case"codeRow":{o="`"+g+"`",c=1,i=-1;break}case"quote":{o=`> ${g}`,c=2;break}case"orderedList":{o=`1. ${g}`,c=3;break}case"unorderedList":{o=`- ${g}`,c=2;break}case"task":{o=`- [ ] ${g}`,c=6;break}case"code":{const x=r.text||g||"",$=r.mode||"language";o=`\`\`\`${$}
|
|
2
|
+
${x}
|
|
3
|
+
\`\`\`
|
|
4
|
+
`,c=3,i=3+$.length-o.length;break}case"table":{o="|";const{selectedShape:x={x:1,y:1}}=r,{x:$,y}=x;for(let N=0;N<=y;N++)o+=" col |";o+=`
|
|
5
|
+
|`;for(let N=0;N<=y;N++)o+=" - |";for(let N=0;N<=$;N++){o+=`
|
|
6
|
+
|`;for(let T=0;T<=y;T++)o+=" content |"}c=2,i=5-o.length;break}case"link":{const{desc:x,url:$}=r;o=`[${x}](${$})`,s=!1;break}case"image":{const{desc:x,url:$,urls:y}=r;y instanceof Array?o=y.reduce((N,T)=>N+`
|
|
7
|
+
`,""):o=`
|
|
8
|
+
`,s=!1;break}case"flow":{o=`\`\`\`mermaid
|
|
9
|
+
${(d==null?void 0:d.flow)||`flowchart TD
|
|
10
|
+
Start --> Stop`}
|
|
11
|
+
\`\`\`
|
|
12
|
+
`,c=3,i=10-o.length;break}case"sequence":{o=`\`\`\`mermaid
|
|
13
|
+
${(d==null?void 0:d.sequence)||`sequenceDiagram
|
|
14
|
+
A->>B: hello!
|
|
15
|
+
B-->>A: hi!
|
|
16
|
+
A-)B: bye!`}
|
|
17
|
+
\`\`\`
|
|
18
|
+
`,c=3,i=10-o.length;break}case"gantt":{o=`\`\`\`mermaid
|
|
19
|
+
${(d==null?void 0:d.gantt)||`gantt
|
|
20
|
+
title A Gantt Diagram
|
|
21
|
+
dateFormat YYYY-MM-DD
|
|
22
|
+
section Section
|
|
23
|
+
A task :a1, 2014-01-01, 30d
|
|
24
|
+
Another task :after a1, 20d`}
|
|
25
|
+
\`\`\`
|
|
26
|
+
`,c=3,i=10-o.length;break}case"class":{o=`\`\`\`mermaid
|
|
27
|
+
${(d==null?void 0:d.class)||`classDiagram
|
|
28
|
+
class Animal
|
|
29
|
+
Vehicle <|-- Car`}
|
|
30
|
+
\`\`\`
|
|
31
|
+
`,c=3,i=10-o.length;break}case"state":{o=`\`\`\`mermaid
|
|
32
|
+
${(d==null?void 0:d.state)||`stateDiagram-v2
|
|
33
|
+
s1 --> s2`}
|
|
34
|
+
\`\`\`
|
|
35
|
+
`,c=3,i=10-o.length;break}case"pie":{o=`\`\`\`mermaid
|
|
36
|
+
${(d==null?void 0:d.pie)||`pie title Pets adopted by volunteers
|
|
37
|
+
"Dogs" : 386
|
|
38
|
+
"Cats" : 85
|
|
39
|
+
"Rats" : 15`}
|
|
40
|
+
\`\`\`
|
|
41
|
+
`,c=3,i=10-o.length;break}case"relationship":{o=`\`\`\`mermaid
|
|
42
|
+
${(d==null?void 0:d.relationship)||`erDiagram
|
|
43
|
+
CAR ||--o{ NAMED-DRIVER : allows
|
|
44
|
+
PERSON ||--o{ NAMED-DRIVER : is`}
|
|
45
|
+
\`\`\`
|
|
46
|
+
`,c=3,i=10-o.length;break}case"journey":{o=`\`\`\`mermaid
|
|
47
|
+
${(d==null?void 0:d.journey)||`journey
|
|
48
|
+
title My working day
|
|
49
|
+
section Go to work
|
|
50
|
+
Make tea: 5: Me
|
|
51
|
+
Go upstairs: 3: Me
|
|
52
|
+
Do work: 1: Me, Cat
|
|
53
|
+
section Go home
|
|
54
|
+
Go downstairs: 5: Me
|
|
55
|
+
Sit down: 5: Me`}
|
|
56
|
+
\`\`\`
|
|
57
|
+
`,c=3,i=10-o.length;break}case"katexInline":{o="$$",c=1,i=-1;break}case"katexBlock":{o=`$$
|
|
58
|
+
|
|
59
|
+
$$
|
|
60
|
+
`,c=3,i=-4;break}case"universal":{const{generate:x}=r,$=x(g);o=$.targetValue,s=$.select,c=$.deviationStart,i=$.deviationEnd}}return{text:o,options:{select:s,deviationStart:c,deviationEnd:i,replaceAll:m}}},dt="#e5c07b",we="var(--md-color)",ut="#56b6c2",ft="#ffffff",Z="var(--md-color)",Te="#e5c07b",gt="#e5c07b",mt="var(--md-color)",Se="#d19a66",ht="#c678dd",bt="#21252b",Me="#2c313a",Ae="#000",ae="#353a42",pt="#ceedfa33",Ee="#528bff",vt=X.EditorView.theme({"&":{color:Z,backgroundColor:Ae},".cm-content":{caretColor:Ee},".cm-cursor, .cm-dropCursor":{borderLeftColor:Ee},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:pt},".cm-panels":{backgroundColor:bt,color:Z},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#ceedfa33"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:Ae,color:Z,borderRight:"1px solid",borderColor:"var(--md-border-color)"},".cm-activeLineGutter":{backgroundColor:Me},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:ae},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:ae,borderBottomColor:ae},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:Me,color:Z}}},{dark:!0}),kt=Q.HighlightStyle.define([{tag:n.tags.keyword,color:ht},{tag:[n.tags.name,n.tags.deleted,n.tags.character,n.tags.propertyName,n.tags.macroName],color:we},{tag:[n.tags.function(n.tags.variableName),n.tags.labelName],color:gt},{tag:[n.tags.color,n.tags.constant(n.tags.name),n.tags.standard(n.tags.name)],color:Se},{tag:[n.tags.definition(n.tags.name),n.tags.separator],color:Z},{tag:[n.tags.typeName,n.tags.className,n.tags.number,n.tags.changed,n.tags.annotation,n.tags.modifier,n.tags.self,n.tags.namespace],color:dt},{tag:[n.tags.operator,n.tags.operatorKeyword,n.tags.url,n.tags.escape,n.tags.regexp,n.tags.link,n.tags.special(n.tags.string)],color:ut},{tag:[n.tags.meta,n.tags.comment],color:Te},{tag:n.tags.strong,fontWeight:"bold"},{tag:n.tags.emphasis,fontStyle:"italic"},{tag:n.tags.strikethrough,textDecoration:"line-through"},{tag:n.tags.link,color:Te,textDecoration:"underline"},{tag:n.tags.heading,fontWeight:"bold",color:we},{tag:[n.tags.atom,n.tags.bool,n.tags.special(n.tags.variableName)],color:Se},{tag:[n.tags.processingInstruction,n.tags.string,n.tags.inserted],color:mt},{tag:n.tags.invalid,color:ft}]),xt=[vt,Q.syntaxHighlighting(kt)],Ct="#e5c07b",De="#3f4a54",Vt="#56b6c2",$t="#fff",J="#3f4a54",Le="#2d8cf0",Nt="#2d8cf0",yt="#3f4a54",He="#d19a66",wt="#c678dd",Tt="#21252b",Fe="#ceedfa33",Be="#fff",re="#353a42",St="#bad5fa",Ie="#3f4a54",Mt=X.EditorView.theme({"&":{color:J,backgroundColor:Be},".cm-content":{caretColor:Ie},".cm-cursor, .cm-dropCursor":{borderLeftColor:Ie},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:St},".cm-panels":{backgroundColor:Tt,color:J},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#ceedfa33"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:Be,color:J,borderRight:"1px solid",borderColor:"var(--md-border-color)"},".cm-activeLineGutter":{backgroundColor:Fe},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:re},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:re,borderBottomColor:re},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:Fe,color:J}}},{dark:!0}),At=Q.HighlightStyle.define([{tag:n.tags.keyword,color:wt},{tag:[n.tags.name,n.tags.deleted,n.tags.character,n.tags.propertyName,n.tags.macroName],color:De},{tag:[n.tags.function(n.tags.variableName),n.tags.labelName],color:Nt},{tag:[n.tags.color,n.tags.constant(n.tags.name),n.tags.standard(n.tags.name)],color:He},{tag:[n.tags.definition(n.tags.name),n.tags.separator],color:J},{tag:[n.tags.typeName,n.tags.className,n.tags.number,n.tags.changed,n.tags.annotation,n.tags.modifier,n.tags.self,n.tags.namespace],color:Ct},{tag:[n.tags.operator,n.tags.operatorKeyword,n.tags.url,n.tags.escape,n.tags.regexp,n.tags.link,n.tags.special(n.tags.string)],color:Vt},{tag:[n.tags.meta,n.tags.comment],color:Le},{tag:n.tags.strong,fontWeight:"bold"},{tag:n.tags.emphasis,fontStyle:"italic"},{tag:n.tags.strikethrough,textDecoration:"line-through"},{tag:n.tags.link,color:Le,textDecoration:"underline"},{tag:n.tags.heading,fontWeight:"bold",color:De},{tag:[n.tags.atom,n.tags.bool,n.tags.special(n.tags.variableName)],color:He},{tag:[n.tags.processingInstruction,n.tags.string,n.tags.inserted],color:yt},{tag:n.tags.invalid,color:$t}]),Et=[Mt,Q.syntaxHighlighting(At)],U=t=>{const a=new R.Compartment;return o=>(a.get(t.state)?t.dispatch({effects:a.reconfigure(o)}):t.dispatch({effects:R.StateEffect.appendConfig.of(a.of(o))}),!0)};class Dt{constructor(a){q(this,"view");q(this,"toggleTabSize");q(this,"togglePlaceholder");q(this,"setExtensions");q(this,"toggleDisabled");q(this,"toggleReadOnly");q(this,"toggleMaxlength");this.view=a,this.toggleTabSize=U(this.view),this.togglePlaceholder=U(this.view),this.setExtensions=U(this.view),this.toggleDisabled=U(this.view),this.toggleReadOnly=U(this.view),this.toggleMaxlength=U(this.view)}getValue(){return this.view.state.doc.toString()}setValue(a,r=0,o=this.view.state.doc.length){this.view.dispatch({changes:{from:r,to:o,insert:a}})}getSelectedText(){const{from:a,to:r}=this.view.state.selection.main;return this.view.state.sliceDoc(a,r)}replaceSelectedText(a,r={select:!0,deviationStart:0,deviationEnd:0,replaceAll:!1}){if(r.replaceAll){this.setValue(a);return}const{from:o}=this.view.state.selection.main;if(this.view.dispatch(this.view.state.replaceSelection(a)),r.select){const c=o+a.length+r.deviationEnd;this.view.dispatch({selection:R.EditorSelection.create([R.EditorSelection.range(o+r.deviationStart,c),R.EditorSelection.cursor(c)],1)}),this.view.focus()}}setTabSize(a){this.toggleTabSize([R.EditorState.tabSize.of(a),Q.indentUnit.of(" ".repeat(a))])}setPlaceholder(a){this.togglePlaceholder(X.placeholder(a))}focus(){this.view.focus()}setDisabled(a){this.toggleDisabled([X.EditorView.editable.of(!a)])}setReadOnly(a){this.toggleReadOnly([R.EditorState.readOnly.of(a)])}setMaxLength(a){this.toggleMaxlength([R.EditorState.changeFilter.of(r=>r.newDoc.length<=a)])}}const Lt=t=>{const a=e.inject("editorId");return o=>{if(o.clipboardData){if(o.clipboardData.files.length>0){const{files:c}=o.clipboardData;h.bus.emit(a,"uploadImage",Array.from(c).filter(i=>/image\/.*/.test(i.type))),o.preventDefault()}if(t.autoDetectCode&&o.clipboardData.types.includes("vscode-editor-data")){const c=JSON.parse(o.clipboardData.getData("vscode-editor-data"));h.bus.emit(a,"replace","code",{mode:c.mode,text:o.clipboardData.getData("text/plain")}),o.preventDefault()}}}},Ht=Lt,Ft=t=>{const a=e.inject("editorId");e.onMounted(()=>{h.bus.on(a,{name:w.TEXTAREA_FOCUS,callback(){var r;(r=t.value)==null||r.focus()}})})},Bt=Ft,It=(t,a)=>{const r={key:"Ctrl-b",mac:"Cmd-b",run:()=>(h.bus.emit(t,"replace","bold"),!0)},o={key:"Ctrl-s",mac:"Cmd-s",run:T=>(h.bus.emit(t,w.ON_SAVE,T.state.doc.toString()),!0),shift:()=>(h.bus.emit(t,"replace","strikeThrough"),!0)},c={key:"Ctrl-u",mac:"Cmd-u",run:()=>(h.bus.emit(t,"replace","underline"),!0),shift:()=>(h.bus.emit(t,"replace","unorderedList"),!0)},i={key:"Ctrl-i",mac:"Cmd-i",run:()=>(h.bus.emit(t,"replace","italic"),!0),shift:()=>(h.bus.emit(t,"openModals","image"),!0)},s={key:"Ctrl-1",mac:"Cmd-1",run:()=>(h.bus.emit(t,"replace","h1"),!0)},m={key:"Ctrl-2",mac:"Cmd-2",run:()=>(h.bus.emit(t,"replace","h2"),!0)},g={key:"Ctrl-3",mac:"Cmd-3",run:()=>(h.bus.emit(t,"replace","h3"),!0)},d={key:"Ctrl-4",mac:"Cmd-4",run:()=>(h.bus.emit(t,"replace","h4"),!0)},u={key:"Ctrl-5",mac:"Cmd-5",run:()=>(h.bus.emit(t,"replace","h5"),!0)},v={key:"Ctrl-6",mac:"Cmd-6",run:()=>(h.bus.emit(t,"replace","h6"),!0)},k={key:"Ctrl-ArrowUp",mac:"Cmd-ArrowUp",run:()=>(h.bus.emit(t,"replace","sup"),!0)},b={key:"Ctrl-ArrowDown",mac:"Cmd-ArrowDown",run:()=>(h.bus.emit(t,"replace","sub"),!0)},p={key:"Ctrl-o",mac:"Cmd-o",run:()=>(h.bus.emit(t,"replace","orderedList"),!0)},f={key:"Ctrl-c",mac:"Cmd-c",shift:()=>(h.bus.emit(t,"replace","code"),!0),any(T,C){return(C.ctrlKey||C.metaKey)&&C.altKey&&C.code==="KeyC"?(h.bus.emit(t,"replace","codeRow"),!0):!1}},x={key:"Ctrl-l",mac:"Cmd-l",run:()=>(h.bus.emit(t,"openModals","link"),!0)},$={key:"Ctrl-f",mac:"Cmd-f",shift:()=>a.noPrettier?!1:(h.bus.emit(t,"replace","prettier"),!0)},y={any:(T,C)=>(C.ctrlKey||C.metaKey)&&C.altKey&&C.shiftKey&&C.code==="KeyT"?(h.bus.emit(t,"replace","table"),!0):!1},N={key:"Ctrl-d",mac:"Cmd-d",run:oe.deleteLine,preventDefault:!0};return[r,N,o,c,i,s,m,g,d,u,v,k,b,p,f,x,$,y]},Ot=It,qt=t=>{const a=e.inject("tabWidth"),r=e.inject("editorId"),o=e.inject("theme"),c=e.ref(),i=e.shallowRef(),s=Ot(r,t),m=Ht(t),g=[X.keymap.of([...s,oe.indentWithTab]),Y.minimalSetup,Ge.markdown({codeLanguages:je.languages}),Y.EditorView.lineWrapping,Y.EditorView.updateListener.of(u=>{u.docChanged&&t.onChange(u.state.doc.toString())}),Y.EditorView.domEventHandlers({paste:m,blur:t.onBlur,focus:t.onFocus})],d=()=>o.value==="light"?l.configOption.codeMirrorExtensions(o.value,[...g,Et],[...s]):l.configOption.codeMirrorExtensions(o.value,[...g,xt],[...s]);return e.onMounted(()=>{const u=new Y.EditorView({doc:t.value,parent:c.value});i.value=new Dt(u),i.value.setTabSize(a),i.value.setExtensions(d()),i.value.setDisabled(t.disabled),i.value.setReadOnly(t.readonly),t.placeholder&&i.value.setPlaceholder(t.placeholder),t.autofocus&&u.focus(),t.maxlength&&i.value.setMaxLength(t.maxlength),h.bus.on(r,{name:"ctrlZ",callback(){oe.undo(u)}}),h.bus.on(r,{name:"ctrlShiftZ",callback(){oe.redo(u)}}),h.bus.on(r,{name:"replace",callback(v,k={}){var f;const{text:b,options:p}=st(v,i.value,k);(f=i.value)==null||f.replaceSelectedText(b,p)}})}),e.watch(()=>o.value,()=>{var u,v;o.value==="dark"?(u=i.value)==null||u.setExtensions(d()):(v=i.value)==null||v.setExtensions(d())}),e.watch(()=>t.value,()=>{var u,v;((u=i.value)==null?void 0:u.getValue())!==t.value&&((v=i.value)==null||v.setValue(t.value))}),e.watch(()=>t.placeholder,()=>{var u;(u=i.value)==null||u.setPlaceholder(t.placeholder)}),e.watch(()=>t.disabled,()=>{var u;(u=i.value)==null||u.setDisabled(t.disabled)}),e.watch(()=>t.readonly,()=>{var u;(u=i.value)==null||u.setDisabled(t.readonly)}),e.watch(()=>t.maxlength,()=>{var u;t.maxlength&&((u=i.value)==null||u.setMaxLength(t.maxlength))}),Bt(i),{inputWrapperRef:c,codeMirrorUt:i}},Rt=qt,Pt={value:{type:String,default:""},onChange:{type:Function,default:()=>{}},setting:{type:Object,default:()=>({})},onHtmlChanged:{type:Function,default:()=>{}},onGetCatalog:{type:Function,default:()=>{}},mdHeadingId:{type:Function,default:()=>""},noMermaid:{type:Boolean,default:!1},sanitize:{type:Function,default:t=>t},placeholder:{type:String,default:""},noKatex:{type:Boolean,default:!1},scrollAuto:{type:Boolean},formatCopiedText:{type:Function,default:t=>t},autofocus:{type:Boolean},disabled:{type:Boolean},readonly:{type:Boolean},maxlength:{type:Number},autoDetectCode:{type:Boolean},onBlur:{type:Function,default:()=>{}},onFocus:{type:Function,default:()=>{}},noPrettier:{type:Boolean},noHighlight:{type:Boolean,default:!1}},jt=e.defineComponent({name:"MDEditorContent",props:Pt,setup(t){const a=e.ref(""),{inputWrapperRef:r,codeMirrorUt:o}=Rt(t);return ct(t,a,o),()=>e.createVNode("div",{class:`${l.prefix}-content`},[e.createVNode("div",{class:`${l.prefix}-input-wrapper`,ref:r},null),e.createVNode(w.ContentPreview,{modelValue:t.value,setting:t.setting,onHtmlChanged:c=>{a.value=c,t.onHtmlChanged(c)},onGetCatalog:t.onGetCatalog,mdHeadingId:t.mdHeadingId,noMermaid:t.noMermaid,sanitize:t.sanitize,noKatex:t.noKatex,formatCopiedText:t.formatCopiedText,noHighlight:t.noHighlight},null)])}}),Gt=e.defineComponent({props:{modelValue:{type:String,default:""}},setup(t){const a=e.inject("usedLanguageText");return()=>{var r,o;return e.createVNode("div",{class:`${l.prefix}-footer-item`},[e.createVNode("label",{class:`${l.prefix}-footer-label`},[`${(r=a.value.footer)==null?void 0:r.markdownTotal}:`]),e.createVNode("span",null,[((o=t.modelValue)==null?void 0:o.length)||0])])}}}),Ut={checked:{type:Boolean,default:!1},onChange:{type:Function,default:()=>{}}},Kt=e.defineComponent({props:Ut,setup(t){return()=>e.createVNode("div",{class:[`${l.prefix}-checkbox`,t.checked&&`${l.prefix}-checkbox-checked`],onClick:()=>{t.onChange(!t.checked)}},null)}}),_t={scrollAuto:{type:Boolean},onScrollAutoChange:{type:Function,default:()=>{}}},Wt=e.defineComponent({props:_t,setup(t){const a=e.inject("usedLanguageText");return()=>{var r;return e.createVNode("div",{class:`${l.prefix}-footer-item`},[e.createVNode("label",{class:`${l.prefix}-footer-label`,onClick:()=>{t.onScrollAutoChange(!t.scrollAuto)}},[(r=a.value.footer)==null?void 0:r.scrollAuto]),e.createVNode(Kt,{checked:t.scrollAuto,onChange:t.onScrollAutoChange},null)])}}}),zt={modelValue:{type:String,default:""},footers:{type:Array,default:[]},scrollAuto:{type:Boolean},onScrollAutoChange:{type:Function,default:()=>{}},defFooters:{type:Object}},Yt=e.defineComponent({name:"MDEditorFooter",props:zt,setup(t){const a=e.computed(()=>{const o=t.footers.indexOf("="),c=o===-1?t.footers:t.footers.slice(0,o),i=o===-1?[]:t.footers.slice(o,Number.MAX_SAFE_INTEGER);return[c,i]}),r=o=>{if(l.allFooter.includes(o))switch(o){case"markdownTotal":return e.createVNode(Gt,{modelValue:t.modelValue},null);case"scrollSwitch":return e.createVNode(Wt,{scrollAuto:t.scrollAuto,onScrollAutoChange:t.onScrollAutoChange},null)}else return t.defFooters instanceof Array?t.defFooters[o]||"":t.defFooters&&t.defFooters.children instanceof Array&&t.defFooters.children[o]||""};return()=>{const o=a.value[0].map(i=>r(i)),c=a.value[1].map(i=>r(i));return e.createVNode("div",{class:`${l.prefix}-footer`},[e.createVNode("div",{class:`${l.prefix}-footer-left`},[o]),e.createVNode("div",{class:`${l.prefix}-footer-right`},[c])])}}}),Zt=e.defineComponent({name:"MdEditorV3",props:w.editorProps,emits:w.editorEmits,setup(t,a){const{editorId:r,noKatex:o,noMermaid:c,noPrettier:i,noUploadImg:s,noHighlight:m}=t,g=e.reactive({scrollAuto:t.scrollAuto});w.useOnSave(t,a),w.useProvide(t),w.useExpansion(t);const[d,u]=w.useConfig(t,a),v=w.useCatalog(t);return e.onBeforeUnmount(()=>{h.bus.clear(r)}),w.useExpose(t,a,v,d,u),()=>{var p;const k=Ne.getSlot({props:t,ctx:a},"defToolbars"),b=Ne.getSlot({props:t,ctx:a},"defFooters");return e.createVNode("div",{id:r,class:[l.prefix,t.class,t.theme==="dark"&&`${l.prefix}-dark`,d.fullscreen||d.pageFullscreen?`${l.prefix}-fullscreen`:""],style:t.style},[e.createVNode(lt,{noPrettier:i,toolbars:t.toolbars,toolbarsExclude:t.toolbarsExclude,setting:d,updateSetting:u,tableShape:t.tableShape,defToolbars:k,noUploadImg:s},null),e.createVNode(jt,{value:t.modelValue,setting:d,mdHeadingId:t.mdHeadingId,noMermaid:c,noPrettier:i,sanitize:t.sanitize,placeholder:t.placeholder,noKatex:o,scrollAuto:g.scrollAuto,formatCopiedText:t.formatCopiedText,autofocus:t.autoFocus,disabled:t.disabled,readonly:t.readOnly,maxlength:t.maxLength,autoDetectCode:t.autoDetectCode,noHighlight:m,onChange:f=>{t.onChange?t.onChange(f):(a.emit("update:modelValue",f),a.emit("onChange",f))},onHtmlChanged:f=>{t.onHtmlChanged?t.onHtmlChanged(f):a.emit("onHtmlChanged",f)},onGetCatalog:f=>{t.onGetCatalog?t.onGetCatalog(f):a.emit("onGetCatalog",f)},onBlur:f=>{t.onBlur?t.onBlur(f):a.emit("onBlur",f)},onFocus:f=>{t.onFocus?t.onFocus(f):a.emit("onFocus",f)}},null),((p=t.footers)==null?void 0:p.length)>0&&e.createVNode(Yt,{modelValue:t.modelValue,footers:t.footers,defFooters:b,scrollAuto:g.scrollAuto,onScrollAutoChange:f=>g.scrollAuto=f},null),v.value&&e.createVNode(Oe,{theme:t.theme,class:`${l.prefix}-catalog-editor`,editorId:r,mdHeadingId:t.mdHeadingId,key:"internal-catalog"},null)])}}}),le=Zt;le.install=t=>(t.component(le.name,le),t.use(Ue).use(K.DropdownToolbar).use(ne.ModalToolbar).use(Oe).use(w.MdPreview),t);module.exports=le;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("./chunks/index.cjs");require("vue");require("./chunks/config.cjs");require("./chunks/event-bus.cjs");require("./chunks/dom.cjs");require("./chunks/index4.cjs");require("medium-zoom");require("copy-to-clipboard");require("markdown-it");require("markdown-it-image-figures");require("markdown-it-task-lists");require("lru-cache");module.exports=e.MdPreview;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const r=require("./chunks/index3.cjs");require("vue");require("./chunks/config.cjs");require("./chunks/vue-tsx.cjs");require("./chunks/dom.cjs");require("./chunks/index4.cjs");module.exports=r.ModalToolbar;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const o=require("vue"),c=require("./chunks/config.cjs"),l=require("./chunks/vue-tsx.cjs"),s={title:{type:String,default:""},trigger:{type:[String,Object]},onClick:{type:Function}},t=o.defineComponent({name:"NormalToolbar",props:s,emits:["onClick"],setup(e,n){return()=>{const r=l.getSlot({props:e,ctx:n},"trigger");return o.createVNode("div",{class:`${c.prefix}-toolbar-item`,title:e.title,onClick:i=>{e.onClick instanceof Function?e.onClick(i):n.emit("onClick",i)}},[r])}}});t.install=e=>(e.component(t.name,t),e);module.exports=t;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const r="md-editor",o="md-editor-v3",a="https://at.alicdn.com/t/c/font_2605852_u82y61ve02.js",e="https://cdnjs.cloudflare.com/ajax/libs",n=`${e}/highlight.js/11.7.0/highlight.min.js`,c={main:`${e}/prettier/2.8.0/standalone.js`,markdown:`${e}/prettier/2.8.0/parser-markdown.js`},d={css:`${e}/cropperjs/1.5.13/cropper.min.css`,js:`${e}/cropperjs/1.5.13/cropper.min.js`},h=`${e}/screenfull.js/5.2.0/screenfull.min.js`,g=["bold","underline","italic","strikeThrough","-","title","sub","sup","quote","unorderedList","orderedList","task","-","codeRow","code","link","image","table","mermaid","katex","-","revoke","next","save","=","prettier","pageFullscreen","fullscreen","preview","htmlPreview","catalog","github"],m=["markdownTotal","=","scrollSwitch"],p={"zh-CN":{toolbarTips:{bold:"加粗",underline:"下划线",italic:"斜体",strikeThrough:"删除线",title:"标题",sub:"下标",sup:"上标",quote:"引用",unorderedList:"无序列表",orderedList:"有序列表",task:"任务列表",codeRow:"行内代码",code:"块级代码",link:"链接",image:"图片",table:"表格",mermaid:"mermaid图",katex:"katex公式",revoke:"后退",next:"前进",save:"保存",prettier:"美化",pageFullscreen:"浏览器全屏",fullscreen:"屏幕全屏",preview:"预览",htmlPreview:"html代码预览",catalog:"目录",github:"源码地址"},titleItem:{h1:"一级标题",h2:"二级标题",h3:"三级标题",h4:"四级标题",h5:"五级标题",h6:"六级标题"},imgTitleItem:{link:"添加链接",upload:"上传图片",clip2upload:"裁剪上传"},linkModalTips:{linkTitle:"添加链接",imageTitle:"添加图片",descLabel:"链接描述:",descLabelPlaceHolder:"请输入描述...",urlLabel:"链接地址:",urlLabelPlaceHolder:"请输入链接...",buttonOK:"确定"},clipModalTips:{title:"裁剪图片上传",buttonUpload:"上传"},copyCode:{text:"复制代码",successTips:"已复制!",failTips:"复制失败!"},mermaid:{flow:"流程图",sequence:"时序图",gantt:"甘特图",class:"类图",state:"状态图",pie:"饼图",relationship:"关系图",journey:"旅程图"},katex:{inline:"行内公式",block:"块级公式"},footer:{markdownTotal:"字数",scrollAuto:"同步滚动"}},"en-US":{toolbarTips:{bold:"bold",underline:"underline",italic:"italic",strikeThrough:"strikeThrough",title:"title",sub:"subscript",sup:"superscript",quote:"quote",unorderedList:"unordered list",orderedList:"ordered list",task:"task list",codeRow:"inline code",code:"block-level code",link:"link",image:"image",table:"table",mermaid:"mermaid",katex:"formula",revoke:"revoke",next:"undo revoke",save:"save",prettier:"prettier",pageFullscreen:"fullscreen in page",fullscreen:"fullscreen",preview:"preview",htmlPreview:"html preview",catalog:"catalog",github:"source code"},titleItem:{h1:"Lv1 Heading",h2:"Lv2 Heading",h3:"Lv3 Heading",h4:"Lv4 Heading",h5:"Lv5 Heading",h6:"Lv6 Heading"},imgTitleItem:{link:"Add Img Link",upload:"Upload Img",clip2upload:"Clip Upload"},linkModalTips:{linkTitle:"Add Link",imageTitle:"Add Image",descLabel:"Desc:",descLabelPlaceHolder:"Enter a description...",urlLabel:"Link:",urlLabelPlaceHolder:"Enter a link...",buttonOK:"OK"},clipModalTips:{title:"Crop Image",buttonUpload:"Upload"},copyCode:{text:"Copy",successTips:"Copied!",failTips:"Copy failed!"},mermaid:{flow:"flow",sequence:"sequence",gantt:"gantt",class:"class",state:"state",pie:"pie",relationship:"relationship",journey:"journey"},katex:{inline:"inline",block:"block"},footer:{markdownTotal:"Word Count",scrollAuto:"Scroll Auto"}}},u=`${e}/mermaid/9.4.0/mermaid.min.js`,k={js:`${e}/KaTeX/0.16.3/katex.min.js`,css:`${e}/KaTeX/0.16.3/katex.min.css`},b={a11y:{light:`${e}/highlight.js/11.7.0/styles/a11y-light.min.css`,dark:`${e}/highlight.js/11.7.0/styles/a11y-dark.min.css`},atom:{light:`${e}/highlight.js/11.7.0/styles/atom-one-light.min.css`,dark:`${e}/highlight.js/11.7.0/styles/atom-one-dark.min.css`},github:{light:`${e}/highlight.js/11.7.0/styles/github.min.css`,dark:`${e}/highlight.js/11.7.0/styles/github-dark.min.css`},gradient:{light:`${e}/highlight.js/11.7.0/styles/gradient-light.min.css`,dark:`${e}/highlight.js/11.7.0/styles/gradient-dark.min.css`},kimbie:{light:`${e}/highlight.js/11.7.0/styles/kimbie-light.min.css`,dark:`${e}/highlight.js/11.7.0/styles/kimbie-dark.min.css`},paraiso:{light:`${e}/highlight.js/11.7.0/styles/paraiso-light.min.css`,dark:`${e}/highlight.js/11.7.0/styles/paraiso-dark.min.css`},qtcreator:{light:`${e}/highlight.js/11.7.0/styles/qtcreator-light.min.css`,dark:`${e}/highlight.js/11.7.0/styles/qtcreator-dark.min.css`},stackoverflow:{light:`${e}/highlight.js/11.7.0/styles/stackoverflow-light.min.css`,dark:`${e}/highlight.js/11.7.0/styles/stackoverflow-dark.min.css`}},s={editorExtensions:{},editorConfig:{},codeMirrorExtensions:(t,i)=>i,markdownItConfig:()=>{}},f=t=>{if(t)for(const i in t){const l=t[i];l&&(s[i]=l)}};exports.allFooter=m;exports.allToolbar=g;exports.codeCss=b;exports.config=f;exports.configOption=s;exports.cropperUrl=d;exports.defaultEditorId=o;exports.highlightUrl=n;exports.iconfontUrl=a;exports.katexUrl=k;exports.mermaidUrl=u;exports.prefix=r;exports.prettierUrl=c;exports.screenfullUrl=h;exports.staticTextDefault=p;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const E=require("./index4.cjs"),y=(e,d)=>{const t=n=>{const o=e.parentElement||document.body,i=o.offsetWidth,u=o.offsetHeight,{clientWidth:l}=document.documentElement,{clientHeight:m}=document.documentElement,p=n.offsetX,v=n.offsetY,a=f=>{let s=f.x+document.body.scrollLeft-document.body.clientLeft-p,c=f.y+document.body.scrollTop-document.body.clientTop-v;s=s<1?1:s<l-i-1?s:l-i-1,c=c<1?1:c<m-u-1?c:m-u-1,d?d(s,c):(o.style.left=`${s}px`,o.style.top=`${c}px`)};document.addEventListener("mousemove",a);const r=()=>{document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",r)};document.addEventListener("mouseup",r)};return e.addEventListener("mousedown",t),()=>{e.removeEventListener("mousedown",t)}},L=(e,d="")=>{const t=document.getElementById(e.id),n=e.onload;e.onload=null;const o=function(i){typeof n=="function"&&n.bind(this)(i),e.removeEventListener("load",o)};t?d!==""&&(t.addEventListener("load",o),Reflect.get(window,d)&&t.dispatchEvent(new Event("load"))):(e.addEventListener("load",o),document.head.appendChild(e))},h=E.debounce((e,d,t)=>{const n=document.getElementById(e);n&&n.setAttribute(d,t)},10);exports.appendHandler=L;exports.keyMove=y;exports.updateHandler=h;
|