md-editor-v3 2.0.0-beta.8 → 2.0.1-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/LICENSE +1 -1
- package/README.md +92 -34
- package/lib/MdEditor/Editor.d.ts +4 -4
- package/lib/MdEditor/index.d.ts +11 -11
- package/lib/MdEditor/type.d.ts +6 -1
- package/lib/md-editor-v3.es.js +171 -162
- package/lib/md-editor-v3.umd.js +59 -59
- package/lib/style.css +1 -1
- package/package.json +3 -3
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -6,11 +6,11 @@ English \| [中文](https://github.com/imzbf/md-editor-v3/blob/dev/README-CN.md)
|
|
|
6
6
|
|
|
7
7
|
Markdown editor for vue3, developed in `jsx` and `typescript`.
|
|
8
8
|
|
|
9
|
-
- Documentation and example
|
|
9
|
+
- Documentation and example: [Go](https://imzbf.github.io/md-editor-v3)
|
|
10
10
|
|
|
11
|
-
- Use it online
|
|
11
|
+
- Use it online: [Go](https://codesandbox.io/s/epic-bird-2znqo)
|
|
12
12
|
|
|
13
|
-
- The same series editor for react
|
|
13
|
+
- The same series editor for react: [md-editor-rt](https://github.com/imzbf/md-editor-rt)
|
|
14
14
|
|
|
15
15
|
## Features
|
|
16
16
|
|
|
@@ -21,7 +21,7 @@ Markdown editor for vue3, developed in `jsx` and `typescript`.
|
|
|
21
21
|
- Multi-language, build-in Chinese and English(default: Chinese).
|
|
22
22
|
- Upload picture, paste or clip the picture and upload it.
|
|
23
23
|
- Render article directly(no editor, no event listener, only preview content).
|
|
24
|
-
- Preview themes, `defalut`, `vuepress`, `github`, `cyanosis`, `mk-cute`, `smart-blue` styles(not identical). It can be customized also(
|
|
24
|
+
- Preview themes, `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
27
|
|
|
@@ -113,7 +113,7 @@ mark and emoji extensions
|
|
|
113
113
|
<details>
|
|
114
114
|
<summary>[StaticTextDefaultValue]</summary>
|
|
115
115
|
|
|
116
|
-
Expand language, you need to replace all the content here
|
|
116
|
+
Expand language, you need to replace all the content here:
|
|
117
117
|
|
|
118
118
|
```ts
|
|
119
119
|
export interface ToolbarTips {
|
|
@@ -183,7 +183,8 @@ export interface StaticTextDefaultValue {
|
|
|
183
183
|
// Copy code tips, v1.1.4
|
|
184
184
|
copyCode?: {
|
|
185
185
|
text?: string;
|
|
186
|
-
|
|
186
|
+
successTips?: string;
|
|
187
|
+
failTips?: string;
|
|
187
188
|
};
|
|
188
189
|
// 1.8.0
|
|
189
190
|
mermaid?: {
|
|
@@ -212,15 +213,15 @@ export interface StaticTextDefaultValue {
|
|
|
212
213
|
|
|
213
214
|
| name | type | default | description |
|
|
214
215
|
| --- | --- | --- | --- |
|
|
215
|
-
| defToolbars | Array<DropdownToolbar \| NormalToolbar \| ModalToolbar> | null |
|
|
216
|
+
| defToolbars | Array<DropdownToolbar \| NormalToolbar \| ModalToolbar> | null | Custom toolbar in `DropdownToolbar`, `NormalToolbar` or `ModalToolbar` |
|
|
216
217
|
|
|
217
|
-
`NormalToolbar`
|
|
218
|
+
`NormalToolbar` example:
|
|
218
219
|
|
|
219
|
-
```
|
|
220
|
+
```vue
|
|
220
221
|
<template>
|
|
221
222
|
<md-editor>
|
|
222
223
|
<template #defToolbars>
|
|
223
|
-
<normal-toolbar title="mark" @
|
|
224
|
+
<normal-toolbar title="mark" @onClick="handler">
|
|
224
225
|
<template #trigger>
|
|
225
226
|
<svg class="md-icon" aria-hidden="true">
|
|
226
227
|
<use xlink:href="#icon-mark"></use>
|
|
@@ -230,12 +231,15 @@ export interface StaticTextDefaultValue {
|
|
|
230
231
|
</template>
|
|
231
232
|
</md-editor>
|
|
232
233
|
</template>
|
|
234
|
+
|
|
233
235
|
<script setup>
|
|
234
236
|
import MdEditor from 'md-editor-v3';
|
|
235
237
|
|
|
236
238
|
const NormalToolbar = MdEditor.NormalToolbar;
|
|
237
239
|
|
|
238
|
-
const handler = () => {
|
|
240
|
+
const handler = () => {
|
|
241
|
+
console.log('NormalToolbar clicked!');
|
|
242
|
+
};
|
|
239
243
|
</script>
|
|
240
244
|
```
|
|
241
245
|
|
|
@@ -254,7 +258,9 @@ const handler = () => { console.log('NormalToolbar clicked!') }
|
|
|
254
258
|
|
|
255
259
|
Use `MdEditor.config(option: ConfigOption)` to reconfigure `renderer`.
|
|
256
260
|
|
|
257
|
-
- markedRenderer: `(renderer: Renderer) => Renderer
|
|
261
|
+
- markedRenderer: `(renderer: Renderer) => Renderer`
|
|
262
|
+
|
|
263
|
+
Open target page in a new browser window:
|
|
258
264
|
|
|
259
265
|
```js
|
|
260
266
|
MdEditor.config({
|
|
@@ -282,7 +288,9 @@ Use `MdEditor.config(option: ConfigOption)` to reconfigure `renderer`.
|
|
|
282
288
|
|
|
283
289
|
> Reference: https://marked.js.org/using_pro#extensions
|
|
284
290
|
|
|
285
|
-
- markedOptions: `marked.MarkedOptions
|
|
291
|
+
- markedOptions: `marked.MarkedOptions`
|
|
292
|
+
|
|
293
|
+
Do not render `<br>` on a single line break:
|
|
286
294
|
|
|
287
295
|
```js
|
|
288
296
|
import MdEditor from 'md-editor-v3';
|
|
@@ -294,18 +302,20 @@ Use `MdEditor.config(option: ConfigOption)` to reconfigure `renderer`.
|
|
|
294
302
|
|
|
295
303
|
> Reference: https://marked.js.org/using_advanced#options
|
|
296
304
|
|
|
297
|
-
- editorConfig: Add more languages
|
|
305
|
+
- editorConfig: Add more languages, reset `mermaid` template or delay rendering time:
|
|
298
306
|
|
|
299
307
|
```js
|
|
300
308
|
import MdEditor from 'md-editor-v3';
|
|
301
309
|
|
|
302
310
|
MdEditor.config({
|
|
303
|
-
|
|
304
|
-
languageUserDefined: {
|
|
311
|
+
editorConfig: {
|
|
312
|
+
languageUserDefined: { lang: StaticTextDefaultValue },
|
|
305
313
|
mermaidTemplate: {
|
|
306
|
-
flow: `flow tempalte
|
|
314
|
+
flow: `flow tempalte`,
|
|
307
315
|
...more
|
|
308
|
-
}
|
|
316
|
+
},
|
|
317
|
+
// ms
|
|
318
|
+
renderDelay: 500
|
|
309
319
|
}
|
|
310
320
|
});
|
|
311
321
|
```
|
|
@@ -365,7 +375,7 @@ Use `MdEditor.config(option: ConfigOption)` to reconfigure `renderer`.
|
|
|
365
375
|
|
|
366
376
|
</details>
|
|
367
377
|
|
|
368
|
-
## Shortcut
|
|
378
|
+
## Shortcut Key
|
|
369
379
|
|
|
370
380
|
| key | function | description |
|
|
371
381
|
| --- | --- | --- |
|
|
@@ -388,7 +398,7 @@ Use `MdEditor.config(option: ConfigOption)` to reconfigure `renderer`.
|
|
|
388
398
|
| CTRL + SHIFT + S | line-through | `~line-through~` |
|
|
389
399
|
| CTRL + SHIFT + U | unordered list | `- unordered list` |
|
|
390
400
|
| CTRL + SHIFT + C | code block | |
|
|
391
|
-
| CTRL + SHIFT + I | picture | `` |
|
|
392
402
|
| CTRL + SHIFT + Z | forward | Forward history in editor, not the function of system |
|
|
393
403
|
| CTRL + SHIFT + F | Beautify | |
|
|
394
404
|
| CTRL + ALT + C | code row | |
|
|
@@ -442,22 +452,22 @@ They are used as attributes of the editor component, eg: `Editor.DropdownToolbar
|
|
|
442
452
|
- `modalTitle`: `string`, not necessary, title of the Modal.
|
|
443
453
|
- `visible`: `boolean`, necessary, visibility of Modal.
|
|
444
454
|
- `width`: `string`, not necessary, width of Modal, default `auto`.
|
|
445
|
-
- `height
|
|
455
|
+
- `height`: `string`, same as `width`.
|
|
446
456
|
- `showAdjust`: `boolean`, not necessary, visibility of fullscreen button.
|
|
447
457
|
- `isFullscreen`: `boolean`, necessary when `showAdjust = true`, status of fullscreen.
|
|
448
458
|
|
|
449
459
|
- **events**
|
|
450
460
|
|
|
451
461
|
- `onClick`: `() => void`, necessary.
|
|
452
|
-
- `onClose
|
|
453
|
-
- `onAdjust
|
|
462
|
+
- `onClose`: `() => void`, necessary, close event.
|
|
463
|
+
- `onAdjust`: `(val: boolean) => void`, fullscreen button click event.
|
|
454
464
|
|
|
455
465
|
- **slots**
|
|
456
466
|
|
|
457
467
|
- `trigger`: `string | JSX.Element`, necessary, it is usually an icon, which is displayed on the toolbar.
|
|
458
468
|
- `overlay`: `string | JSX.Element`, necessary, content of Modal.
|
|
459
469
|
|
|
460
|
-
###
|
|
470
|
+
### MdCatalog
|
|
461
471
|
|
|
462
472
|
`Editor.MdCatalog`
|
|
463
473
|
|
|
@@ -471,7 +481,7 @@ They are used as attributes of the editor component, eg: `Editor.DropdownToolbar
|
|
|
471
481
|
|
|
472
482
|
## Examples
|
|
473
483
|
|
|
474
|
-
### Jsx
|
|
484
|
+
### Jsx Template
|
|
475
485
|
|
|
476
486
|
```js
|
|
477
487
|
import { defineComponent, reactive } from 'vue';
|
|
@@ -490,11 +500,11 @@ export default defineComponent({
|
|
|
490
500
|
});
|
|
491
501
|
```
|
|
492
502
|
|
|
493
|
-
###
|
|
503
|
+
### Setup Template
|
|
494
504
|
|
|
495
|
-
```
|
|
505
|
+
```vue
|
|
496
506
|
<template>
|
|
497
|
-
<md-editor v-model="text"
|
|
507
|
+
<md-editor v-model="text" preview-only />
|
|
498
508
|
</template>
|
|
499
509
|
|
|
500
510
|
<script setup>
|
|
@@ -502,16 +512,27 @@ import { ref } from 'vue';
|
|
|
502
512
|
import MdEditor from 'md-editor-v3';
|
|
503
513
|
import 'md-editor-v3/lib/style.css';
|
|
504
514
|
|
|
505
|
-
const text = ref('# Hello Editor')
|
|
515
|
+
const text = ref('# Hello Editor');
|
|
506
516
|
</script>
|
|
507
517
|
```
|
|
508
518
|
|
|
509
|
-
### Upload
|
|
519
|
+
### Upload Picture
|
|
510
520
|
|
|
511
|
-
> Tips
|
|
521
|
+
> Tips: When you paste and upload GIF, it will upload a static picture. So you should upload it by file system!
|
|
512
522
|
|
|
513
|
-
```
|
|
514
|
-
|
|
523
|
+
```vue
|
|
524
|
+
<template>
|
|
525
|
+
<md-editor v-model="text" @onUploadImg="onUploadImg" />
|
|
526
|
+
</template>
|
|
527
|
+
|
|
528
|
+
<script setup>
|
|
529
|
+
import { ref } from 'vue';
|
|
530
|
+
import MdEditor from 'md-editor-v3';
|
|
531
|
+
import 'md-editor-v3/lib/style.css';
|
|
532
|
+
|
|
533
|
+
const text = ref('# Hello Editor');
|
|
534
|
+
|
|
535
|
+
const onUploadImg = async (files, callback) => {
|
|
515
536
|
const res = await Promise.all(
|
|
516
537
|
files.map((file) => {
|
|
517
538
|
return new Promise((rev, rej) => {
|
|
@@ -530,6 +551,43 @@ async onUploadImg(files: Array<File>, callback: (urls: string[]) => void) {
|
|
|
530
551
|
})
|
|
531
552
|
);
|
|
532
553
|
|
|
533
|
-
callback(res.map((item
|
|
554
|
+
callback(res.map((item) => item.data.url));
|
|
555
|
+
};
|
|
556
|
+
</script>
|
|
557
|
+
```
|
|
558
|
+
|
|
559
|
+
### Change Styles
|
|
560
|
+
|
|
561
|
+
```less
|
|
562
|
+
.css-vars(@isDark) {
|
|
563
|
+
--md-color: if(@isDark, #999, #222);
|
|
564
|
+
--md-hover-color: if(@isDark, #bbb, #000);
|
|
565
|
+
--md-bk-color: if(@isDark, #000, #fff);
|
|
566
|
+
--md-bk-color-outstand: if(@isDark, #111, #f6f6f6);
|
|
567
|
+
--md-bk-hover-color: if(@isDark, #1b1a1a, #f5f7fa);
|
|
568
|
+
--md-border-color: if(@isDark, #2d2d2d, #e6e6e6);
|
|
569
|
+
--md-border-hover-color: if(@isDark, #636262, #b9b9b9);
|
|
570
|
+
--md-border-active-color: if(@isDark, #777, #999);
|
|
571
|
+
--md-modal-mask: #00000073;
|
|
572
|
+
--md-scrollbar-bg-color: if(@isDark, #0f0f0f, #e2e2e2);
|
|
573
|
+
--md-scrollbar-thumb-color: if(@isDark, #2d2d2d, #0000004d);
|
|
574
|
+
--md-scrollbar-thumb-hover-color: if(@isDark, #3a3a3a, #00000059);
|
|
575
|
+
--md-scrollbar-thumb-avtive-color: if(@isDark, #3a3a3a, #00000061);
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
.md {
|
|
579
|
+
.css-vars(false);
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
.md-dark {
|
|
583
|
+
.css-vars(true);
|
|
584
|
+
}
|
|
585
|
+
```
|
|
586
|
+
|
|
587
|
+
Change background color in dark mode:
|
|
588
|
+
|
|
589
|
+
```css
|
|
590
|
+
.md-dark {
|
|
591
|
+
--md-bk-color: #333 !important;
|
|
534
592
|
}
|
|
535
593
|
```
|
package/lib/MdEditor/Editor.d.ts
CHANGED
|
@@ -119,7 +119,7 @@ declare const Editor: import("vue").DefineComponent<{
|
|
|
119
119
|
type: PropType<string>;
|
|
120
120
|
default: string;
|
|
121
121
|
};
|
|
122
|
-
}, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, "onSave" | "
|
|
122
|
+
}, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, "onSave" | "onError" | "onUploadImg" | "onChange" | "onHtmlChanged" | "onGetCatalog" | "update:modelValue", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
123
123
|
modelValue: {
|
|
124
124
|
type: PropType<string>;
|
|
125
125
|
default: string;
|
|
@@ -238,20 +238,20 @@ declare const Editor: import("vue").DefineComponent<{
|
|
|
238
238
|
default: string;
|
|
239
239
|
};
|
|
240
240
|
}>>, {
|
|
241
|
-
|
|
241
|
+
pageFullScreen: boolean;
|
|
242
242
|
preview: boolean;
|
|
243
243
|
htmlPreview: boolean;
|
|
244
|
+
editorId: string;
|
|
245
|
+
noPrettier: boolean;
|
|
244
246
|
tabWidth: number;
|
|
245
247
|
theme: Themes;
|
|
246
248
|
historyLength: number;
|
|
247
249
|
previewOnly: boolean;
|
|
248
250
|
showCodeRowNumber: boolean;
|
|
249
251
|
previewTheme: string;
|
|
250
|
-
noPrettier: boolean;
|
|
251
252
|
style: string | CSSProperties;
|
|
252
253
|
class: string;
|
|
253
254
|
modelValue: string;
|
|
254
|
-
pageFullScreen: boolean;
|
|
255
255
|
language: string;
|
|
256
256
|
toolbars: ToolbarNames[];
|
|
257
257
|
toolbarsExclude: ToolbarNames[];
|
package/lib/MdEditor/index.d.ts
CHANGED
|
@@ -9,20 +9,20 @@ declare const _default: {
|
|
|
9
9
|
$: import("vue").ComponentInternalInstance;
|
|
10
10
|
$data: {};
|
|
11
11
|
$props: Partial<{
|
|
12
|
-
|
|
12
|
+
pageFullScreen: boolean;
|
|
13
13
|
preview: boolean;
|
|
14
14
|
htmlPreview: boolean;
|
|
15
|
+
editorId: string;
|
|
16
|
+
noPrettier: boolean;
|
|
15
17
|
tabWidth: number;
|
|
16
18
|
theme: import("./type").Themes;
|
|
17
19
|
historyLength: number;
|
|
18
20
|
previewOnly: boolean;
|
|
19
21
|
showCodeRowNumber: boolean;
|
|
20
22
|
previewTheme: string;
|
|
21
|
-
noPrettier: boolean;
|
|
22
23
|
style: string | import("vue").CSSProperties;
|
|
23
24
|
class: string;
|
|
24
25
|
modelValue: string;
|
|
25
|
-
pageFullScreen: boolean;
|
|
26
26
|
language: string;
|
|
27
27
|
toolbars: import("./type").ToolbarNames[];
|
|
28
28
|
toolbarsExclude: import("./type").ToolbarNames[];
|
|
@@ -151,7 +151,7 @@ declare const _default: {
|
|
|
151
151
|
type: import("vue").PropType<string>;
|
|
152
152
|
default: string;
|
|
153
153
|
};
|
|
154
|
-
}>> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, "
|
|
154
|
+
}>> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, "pageFullScreen" | "preview" | "htmlPreview" | "editorId" | "noPrettier" | "tabWidth" | "theme" | "historyLength" | "previewOnly" | "showCodeRowNumber" | "previewTheme" | "style" | "class" | "modelValue" | "language" | "toolbars" | "toolbarsExclude" | "markedHeadingId" | "tableShape" | "noMermaid" | "sanitize" | "placeholder" | "noKatex" | "codeTheme">;
|
|
155
155
|
$attrs: {
|
|
156
156
|
[x: string]: unknown;
|
|
157
157
|
};
|
|
@@ -284,20 +284,20 @@ declare const _default: {
|
|
|
284
284
|
default: string;
|
|
285
285
|
};
|
|
286
286
|
}>>, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, {
|
|
287
|
-
|
|
287
|
+
pageFullScreen: boolean;
|
|
288
288
|
preview: boolean;
|
|
289
289
|
htmlPreview: boolean;
|
|
290
|
+
editorId: string;
|
|
291
|
+
noPrettier: boolean;
|
|
290
292
|
tabWidth: number;
|
|
291
293
|
theme: import("./type").Themes;
|
|
292
294
|
historyLength: number;
|
|
293
295
|
previewOnly: boolean;
|
|
294
296
|
showCodeRowNumber: boolean;
|
|
295
297
|
previewTheme: string;
|
|
296
|
-
noPrettier: boolean;
|
|
297
298
|
style: string | import("vue").CSSProperties;
|
|
298
299
|
class: string;
|
|
299
300
|
modelValue: string;
|
|
300
|
-
pageFullScreen: boolean;
|
|
301
301
|
language: string;
|
|
302
302
|
toolbars: import("./type").ToolbarNames[];
|
|
303
303
|
toolbarsExclude: import("./type").ToolbarNames[];
|
|
@@ -568,21 +568,21 @@ declare const _default: {
|
|
|
568
568
|
type: import("vue").PropType<string>;
|
|
569
569
|
default: string;
|
|
570
570
|
};
|
|
571
|
-
}>>, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, "onSave" | "
|
|
572
|
-
|
|
571
|
+
}>>, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, "onSave" | "onError" | "onUploadImg" | "onChange" | "onHtmlChanged" | "onGetCatalog" | "update:modelValue", {
|
|
572
|
+
pageFullScreen: boolean;
|
|
573
573
|
preview: boolean;
|
|
574
574
|
htmlPreview: boolean;
|
|
575
|
+
editorId: string;
|
|
576
|
+
noPrettier: boolean;
|
|
575
577
|
tabWidth: number;
|
|
576
578
|
theme: import("./type").Themes;
|
|
577
579
|
historyLength: number;
|
|
578
580
|
previewOnly: boolean;
|
|
579
581
|
showCodeRowNumber: boolean;
|
|
580
582
|
previewTheme: string;
|
|
581
|
-
noPrettier: boolean;
|
|
582
583
|
style: string | import("vue").CSSProperties;
|
|
583
584
|
class: string;
|
|
584
585
|
modelValue: string;
|
|
585
|
-
pageFullScreen: boolean;
|
|
586
586
|
language: string;
|
|
587
587
|
toolbars: import("./type").ToolbarNames[];
|
|
588
588
|
toolbarsExclude: import("./type").ToolbarNames[];
|
package/lib/MdEditor/type.d.ts
CHANGED
|
@@ -70,7 +70,8 @@ export interface StaticTextDefaultValue {
|
|
|
70
70
|
};
|
|
71
71
|
copyCode?: {
|
|
72
72
|
text?: string;
|
|
73
|
-
|
|
73
|
+
successTips?: string;
|
|
74
|
+
failTips?: string;
|
|
74
75
|
};
|
|
75
76
|
mermaid?: {
|
|
76
77
|
flow?: string;
|
|
@@ -200,6 +201,10 @@ export interface ConfigOption {
|
|
|
200
201
|
* 自定义内部mermaid模块
|
|
201
202
|
*/
|
|
202
203
|
mermaidTemplate?: MermaidTemplate;
|
|
204
|
+
/**
|
|
205
|
+
* 输入渲染延迟(ms)
|
|
206
|
+
*/
|
|
207
|
+
renderDelay?: number;
|
|
203
208
|
};
|
|
204
209
|
}
|
|
205
210
|
/**
|