md-editor-v3 2.1.2 → 2.2.0-beta.2
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 +28 -17
- package/lib/MdEditor/Editor.d.ts +7 -1
- package/lib/MdEditor/config.d.ts +26 -0
- package/lib/MdEditor/extensions/MdCatalog/CatalogLink.d.ts +9 -0
- package/lib/MdEditor/extensions/MdCatalog/index.d.ts +4 -2
- package/lib/MdEditor/index.d.ts +18 -6
- package/lib/MdEditor/type.d.ts +8 -2
- package/lib/md-editor-v3.es.js +88 -62
- package/lib/md-editor-v3.umd.js +64 -64
- package/lib/style.css +1 -1
- package/package.json +10 -13
- package/lib/MdEditor/utils/config.d.ts +0 -3
package/README.md
CHANGED
|
@@ -25,6 +25,28 @@ Markdown editor for vue3, developed in `jsx` and `typescript`.
|
|
|
25
25
|
- `mermaid`(>=1.8.0), `katex` mathematical formula(>=1.9.0).
|
|
26
26
|
- Customize the toolbar as you like.
|
|
27
27
|
|
|
28
|
+
## Install
|
|
29
|
+
|
|
30
|
+
```shell
|
|
31
|
+
yarn add md-editor-v3
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Usage
|
|
35
|
+
|
|
36
|
+
```vue
|
|
37
|
+
<template>
|
|
38
|
+
<md-editor v-model="text" preview-only />
|
|
39
|
+
</template>
|
|
40
|
+
|
|
41
|
+
<script setup>
|
|
42
|
+
import { ref } from 'vue';
|
|
43
|
+
import MdEditor from 'md-editor-v3';
|
|
44
|
+
import 'md-editor-v3/lib/style.css';
|
|
45
|
+
|
|
46
|
+
const text = ref('# Hello Editor');
|
|
47
|
+
</script>
|
|
48
|
+
```
|
|
49
|
+
|
|
28
50
|
## Preview
|
|
29
51
|
|
|
30
52
|
| Default theme | Dark theme | Preview only |
|
|
@@ -67,6 +89,7 @@ mark and emoji extensions
|
|
|
67
89
|
| sanitize | (html: string) => string | (html) => html | Sanitize the html, prevent XSS |
|
|
68
90
|
| footers | Array<'markdownTotal' \| '=' \| 'scrollSwitch' \| number> | ['markdownTotal', '=', 'scrollSwitch'] | Show contents of footer, they are divided by `'='`. Set it to `[]` to hidden footer |
|
|
69
91
|
| scrollAuto | boolean | true | Scroll default setting |
|
|
92
|
+
| noIconfont | boolean | false | Not append iconfont script, [download](https://at.alicdn.com/t/font_2605852_pqekijay2ij.js) and import it by yourself |
|
|
70
93
|
|
|
71
94
|
<details>
|
|
72
95
|
<summary>[toolbars]</summary>
|
|
@@ -317,7 +340,7 @@ Use `MdEditor.config(option: ConfigOption)` to reconfigure `renderer`.
|
|
|
317
340
|
flow: `flow tempalte`,
|
|
318
341
|
...more
|
|
319
342
|
},
|
|
320
|
-
//
|
|
343
|
+
// Default 500ms. It is set to 0ms when preview only and not set.
|
|
321
344
|
renderDelay: 500
|
|
322
345
|
}
|
|
323
346
|
});
|
|
@@ -482,6 +505,10 @@ They are used as attributes of the editor component, eg: `Editor.DropdownToolbar
|
|
|
482
505
|
- `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`.
|
|
483
506
|
- `theme`: `'light' | 'dark'`, not necessary, provide it when you want to change theme online, it is the same as Editor `theme`.
|
|
484
507
|
|
|
508
|
+
- **events**
|
|
509
|
+
|
|
510
|
+
- `onClick`: `(e: MouseEvent, t: TocItem) => void`, not necessary.
|
|
511
|
+
|
|
485
512
|
## Examples
|
|
486
513
|
|
|
487
514
|
### Jsx Template
|
|
@@ -503,22 +530,6 @@ export default defineComponent({
|
|
|
503
530
|
});
|
|
504
531
|
```
|
|
505
532
|
|
|
506
|
-
### Setup Template
|
|
507
|
-
|
|
508
|
-
```vue
|
|
509
|
-
<template>
|
|
510
|
-
<md-editor v-model="text" preview-only />
|
|
511
|
-
</template>
|
|
512
|
-
|
|
513
|
-
<script setup>
|
|
514
|
-
import { ref } from 'vue';
|
|
515
|
-
import MdEditor from 'md-editor-v3';
|
|
516
|
-
import 'md-editor-v3/lib/style.css';
|
|
517
|
-
|
|
518
|
-
const text = ref('# Hello Editor');
|
|
519
|
-
</script>
|
|
520
|
-
```
|
|
521
|
-
|
|
522
533
|
### Upload Picture
|
|
523
534
|
|
|
524
535
|
> Tips: When you paste and upload GIF, it will upload a static picture. So you should upload it by file system!
|
package/lib/MdEditor/Editor.d.ts
CHANGED
|
@@ -130,6 +130,9 @@ declare const Editor: import("vue").DefineComponent<{
|
|
|
130
130
|
defFooters: {
|
|
131
131
|
type: PropType<string | JSX.Element>;
|
|
132
132
|
};
|
|
133
|
+
noIconfont: {
|
|
134
|
+
type: PropType<boolean>;
|
|
135
|
+
};
|
|
133
136
|
}, () => 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<{
|
|
134
137
|
modelValue: {
|
|
135
138
|
type: PropType<string>;
|
|
@@ -259,6 +262,9 @@ declare const Editor: import("vue").DefineComponent<{
|
|
|
259
262
|
defFooters: {
|
|
260
263
|
type: PropType<string | JSX.Element>;
|
|
261
264
|
};
|
|
265
|
+
noIconfont: {
|
|
266
|
+
type: PropType<boolean>;
|
|
267
|
+
};
|
|
262
268
|
}>>, {
|
|
263
269
|
pageFullScreen: boolean;
|
|
264
270
|
preview: boolean;
|
|
@@ -274,6 +280,7 @@ declare const Editor: import("vue").DefineComponent<{
|
|
|
274
280
|
style: string | CSSProperties;
|
|
275
281
|
class: string;
|
|
276
282
|
scrollAuto: boolean;
|
|
283
|
+
sanitize: (html: string) => string;
|
|
277
284
|
modelValue: string;
|
|
278
285
|
language: string;
|
|
279
286
|
toolbars: ToolbarNames[];
|
|
@@ -281,7 +288,6 @@ declare const Editor: import("vue").DefineComponent<{
|
|
|
281
288
|
markedHeadingId: MarkedHeadingId;
|
|
282
289
|
tableShape: number[];
|
|
283
290
|
noMermaid: boolean;
|
|
284
|
-
sanitize: (html: string) => string;
|
|
285
291
|
placeholder: string;
|
|
286
292
|
noKatex: boolean;
|
|
287
293
|
codeTheme: string;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { CodeCss, Config, ConfigOption, Footers, StaticTextDefault } from './type';
|
|
2
|
+
export declare const prefix = "md";
|
|
3
|
+
export declare const iconScriptId = "md-editor-v3";
|
|
4
|
+
export declare const iconfontUrl = "https://at.alicdn.com/t/font_2605852_pqekijay2ij.js";
|
|
5
|
+
export declare const cdnBase = "https://cdnjs.cloudflare.com/ajax/libs";
|
|
6
|
+
export declare const highlightUrl: string;
|
|
7
|
+
export declare const prettierUrl: {
|
|
8
|
+
main: string;
|
|
9
|
+
markdown: string;
|
|
10
|
+
};
|
|
11
|
+
export declare const cropperUrl: {
|
|
12
|
+
css: string;
|
|
13
|
+
js: string;
|
|
14
|
+
};
|
|
15
|
+
export declare const screenfullUrl: string;
|
|
16
|
+
export declare const allToolbar: string[];
|
|
17
|
+
export declare const allFooter: Array<Footers>;
|
|
18
|
+
export declare const staticTextDefault: StaticTextDefault;
|
|
19
|
+
export declare const mermaidUrl: string;
|
|
20
|
+
export declare const katexUrl: {
|
|
21
|
+
js: string;
|
|
22
|
+
css: string;
|
|
23
|
+
};
|
|
24
|
+
export declare const codeCss: CodeCss;
|
|
25
|
+
export declare const configOption: ConfigOption;
|
|
26
|
+
export declare const config: Config;
|
|
@@ -18,6 +18,10 @@ declare const CatalogLink: import("vue").DefineComponent<{
|
|
|
18
18
|
type: PropType<string | Element>;
|
|
19
19
|
default: string;
|
|
20
20
|
};
|
|
21
|
+
onClick: {
|
|
22
|
+
type: PropType<(e: MouseEvent, t: TocItem) => void>;
|
|
23
|
+
default: () => void;
|
|
24
|
+
};
|
|
21
25
|
}, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
22
26
|
tocItem: {
|
|
23
27
|
type: PropType<TocItem>;
|
|
@@ -31,8 +35,13 @@ declare const CatalogLink: import("vue").DefineComponent<{
|
|
|
31
35
|
type: PropType<string | Element>;
|
|
32
36
|
default: string;
|
|
33
37
|
};
|
|
38
|
+
onClick: {
|
|
39
|
+
type: PropType<(e: MouseEvent, t: TocItem) => void>;
|
|
40
|
+
default: () => void;
|
|
41
|
+
};
|
|
34
42
|
}>>, {
|
|
35
43
|
markedHeadingId: MarkedHeadingId;
|
|
44
|
+
onClick: (e: MouseEvent, t: TocItem) => void;
|
|
36
45
|
scrollElement: string | Element;
|
|
37
46
|
tocItem: TocItem;
|
|
38
47
|
}>;
|
|
@@ -25,7 +25,7 @@ declare const MdCatalog: import("vue").DefineComponent<{
|
|
|
25
25
|
type: PropType<Themes>;
|
|
26
26
|
default: string;
|
|
27
27
|
};
|
|
28
|
-
}, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin,
|
|
28
|
+
}, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "onClick"[], "onClick", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
29
29
|
editorId: {
|
|
30
30
|
type: PropType<string>;
|
|
31
31
|
};
|
|
@@ -44,7 +44,9 @@ declare const MdCatalog: import("vue").DefineComponent<{
|
|
|
44
44
|
type: PropType<Themes>;
|
|
45
45
|
default: string;
|
|
46
46
|
};
|
|
47
|
-
}
|
|
47
|
+
}>> & {
|
|
48
|
+
onOnClick?: ((...args: any[]) => any) | undefined;
|
|
49
|
+
}, {
|
|
48
50
|
theme: Themes;
|
|
49
51
|
class: string;
|
|
50
52
|
markedHeadingId: MarkedHeadingId;
|
package/lib/MdEditor/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import NormalToolbar from './extensions/NormalToolbar';
|
|
|
3
3
|
import DropdownToolbar from './extensions/DropdownToolbar';
|
|
4
4
|
import MdCatalog from './extensions/MdCatalog';
|
|
5
5
|
import ModalToolbar from './extensions/ModalToolbar';
|
|
6
|
-
import
|
|
6
|
+
import { config } from './config';
|
|
7
7
|
declare const _default: {
|
|
8
8
|
new (...args: any[]): {
|
|
9
9
|
$: import("vue").ComponentInternalInstance;
|
|
@@ -23,6 +23,7 @@ declare const _default: {
|
|
|
23
23
|
style: string | import("vue").CSSProperties;
|
|
24
24
|
class: string;
|
|
25
25
|
scrollAuto: boolean;
|
|
26
|
+
sanitize: (html: string) => string;
|
|
26
27
|
modelValue: string;
|
|
27
28
|
language: string;
|
|
28
29
|
toolbars: import("./type").ToolbarNames[];
|
|
@@ -30,7 +31,6 @@ declare const _default: {
|
|
|
30
31
|
markedHeadingId: import("./type").MarkedHeadingId;
|
|
31
32
|
tableShape: number[];
|
|
32
33
|
noMermaid: boolean;
|
|
33
|
-
sanitize: (html: string) => string;
|
|
34
34
|
placeholder: string;
|
|
35
35
|
noKatex: boolean;
|
|
36
36
|
codeTheme: string;
|
|
@@ -164,7 +164,10 @@ declare const _default: {
|
|
|
164
164
|
defFooters: {
|
|
165
165
|
type: import("vue").PropType<string | JSX.Element>;
|
|
166
166
|
};
|
|
167
|
-
|
|
167
|
+
noIconfont: {
|
|
168
|
+
type: import("vue").PropType<boolean>;
|
|
169
|
+
};
|
|
170
|
+
}>> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, "pageFullScreen" | "preview" | "htmlPreview" | "editorId" | "noPrettier" | "tabWidth" | "theme" | "historyLength" | "previewOnly" | "showCodeRowNumber" | "previewTheme" | "style" | "class" | "scrollAuto" | "sanitize" | "modelValue" | "language" | "toolbars" | "toolbarsExclude" | "markedHeadingId" | "tableShape" | "noMermaid" | "placeholder" | "noKatex" | "codeTheme" | "footers">;
|
|
168
171
|
$attrs: {
|
|
169
172
|
[x: string]: unknown;
|
|
170
173
|
};
|
|
@@ -307,6 +310,9 @@ declare const _default: {
|
|
|
307
310
|
defFooters: {
|
|
308
311
|
type: import("vue").PropType<string | JSX.Element>;
|
|
309
312
|
};
|
|
313
|
+
noIconfont: {
|
|
314
|
+
type: import("vue").PropType<boolean>;
|
|
315
|
+
};
|
|
310
316
|
}>>, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, {
|
|
311
317
|
pageFullScreen: boolean;
|
|
312
318
|
preview: boolean;
|
|
@@ -322,6 +328,7 @@ declare const _default: {
|
|
|
322
328
|
style: string | import("vue").CSSProperties;
|
|
323
329
|
class: string;
|
|
324
330
|
scrollAuto: boolean;
|
|
331
|
+
sanitize: (html: string) => string;
|
|
325
332
|
modelValue: string;
|
|
326
333
|
language: string;
|
|
327
334
|
toolbars: import("./type").ToolbarNames[];
|
|
@@ -329,7 +336,6 @@ declare const _default: {
|
|
|
329
336
|
markedHeadingId: import("./type").MarkedHeadingId;
|
|
330
337
|
tableShape: number[];
|
|
331
338
|
noMermaid: boolean;
|
|
332
|
-
sanitize: (html: string) => string;
|
|
333
339
|
placeholder: string;
|
|
334
340
|
noKatex: boolean;
|
|
335
341
|
codeTheme: string;
|
|
@@ -483,6 +489,9 @@ declare const _default: {
|
|
|
483
489
|
defFooters: {
|
|
484
490
|
type: import("vue").PropType<string | JSX.Element>;
|
|
485
491
|
};
|
|
492
|
+
noIconfont: {
|
|
493
|
+
type: import("vue").PropType<boolean>;
|
|
494
|
+
};
|
|
486
495
|
}>> & import("vue").ShallowUnwrapRef<() => JSX.Element> & {} & {} & import("vue").ComponentCustomProperties;
|
|
487
496
|
__isFragment?: undefined;
|
|
488
497
|
__isTeleport?: undefined;
|
|
@@ -616,6 +625,9 @@ declare const _default: {
|
|
|
616
625
|
defFooters: {
|
|
617
626
|
type: import("vue").PropType<string | JSX.Element>;
|
|
618
627
|
};
|
|
628
|
+
noIconfont: {
|
|
629
|
+
type: import("vue").PropType<boolean>;
|
|
630
|
+
};
|
|
619
631
|
}>>, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, "onSave" | "onError" | "onUploadImg" | "onChange" | "onHtmlChanged" | "onGetCatalog" | "update:modelValue", {
|
|
620
632
|
pageFullScreen: boolean;
|
|
621
633
|
preview: boolean;
|
|
@@ -631,6 +643,7 @@ declare const _default: {
|
|
|
631
643
|
style: string | import("vue").CSSProperties;
|
|
632
644
|
class: string;
|
|
633
645
|
scrollAuto: boolean;
|
|
646
|
+
sanitize: (html: string) => string;
|
|
634
647
|
modelValue: string;
|
|
635
648
|
language: string;
|
|
636
649
|
toolbars: import("./type").ToolbarNames[];
|
|
@@ -638,7 +651,6 @@ declare const _default: {
|
|
|
638
651
|
markedHeadingId: import("./type").MarkedHeadingId;
|
|
639
652
|
tableShape: number[];
|
|
640
653
|
noMermaid: boolean;
|
|
641
|
-
sanitize: (html: string) => string;
|
|
642
654
|
placeholder: string;
|
|
643
655
|
noKatex: boolean;
|
|
644
656
|
codeTheme: string;
|
|
@@ -648,7 +660,7 @@ declare const _default: {
|
|
|
648
660
|
readonly DropdownToolbar: typeof DropdownToolbar;
|
|
649
661
|
readonly MdCatalog: typeof MdCatalog;
|
|
650
662
|
readonly ModalToolbar: typeof ModalToolbar;
|
|
651
|
-
readonly config: typeof
|
|
663
|
+
readonly config: typeof config;
|
|
652
664
|
install: (app: App) => App;
|
|
653
665
|
};
|
|
654
666
|
export default _default;
|
package/lib/MdEditor/type.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { marked, Renderer, Slugger } from 'marked';
|
|
2
2
|
declare global {
|
|
3
3
|
interface Window {
|
|
4
4
|
hljs: any;
|
|
@@ -146,12 +146,16 @@ export interface MermaidTemplate {
|
|
|
146
146
|
*/
|
|
147
147
|
journey?: string;
|
|
148
148
|
}
|
|
149
|
+
export declare type RewriteHeading = (text: string, level: 1 | 2 | 3 | 4 | 5 | 6, raw: string, slugger: Slugger, index: number) => string;
|
|
150
|
+
export interface RewriteRenderer extends Omit<Renderer, 'heading'> {
|
|
151
|
+
heading: RewriteHeading;
|
|
152
|
+
}
|
|
149
153
|
export interface ConfigOption {
|
|
150
154
|
/**
|
|
151
155
|
* 覆盖编辑器默认的renderer属性
|
|
152
156
|
* @see https://marked.js.org/using_pro#renderer
|
|
153
157
|
*/
|
|
154
|
-
markedRenderer?: (renderer:
|
|
158
|
+
markedRenderer?: (renderer: RewriteRenderer) => RewriteRenderer;
|
|
155
159
|
/**
|
|
156
160
|
* 自定义 marked 扩展
|
|
157
161
|
* @see https://marked.js.org/using_pro#extensions
|
|
@@ -172,6 +176,8 @@ export interface ConfigOption {
|
|
|
172
176
|
css?: CodeCss;
|
|
173
177
|
};
|
|
174
178
|
prettier?: {
|
|
179
|
+
prettierInstance?: any;
|
|
180
|
+
parserMarkdownInstance?: any;
|
|
175
181
|
standaloneJs?: string;
|
|
176
182
|
parserMarkdownJs?: string;
|
|
177
183
|
};
|