md-editor-v3 2.11.0 → 3.0.0-beta.1

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 CHANGED
@@ -31,12 +31,6 @@ Markdown editor for vue3, developed in `jsx` and `typescript`.
31
31
  yarn add md-editor-v3
32
32
  ```
33
33
 
34
- Please install `@types/marked` in your typescript project if you want to configure `renderer`:
35
-
36
- ```shell
37
- yarn add @types/marked -D
38
- ```
39
-
40
34
  Install existing extension of language and theme of preview:
41
35
 
42
36
  ```shell
@@ -80,10 +74,10 @@ mark and emoji extensions
80
74
  | modelValue | `string` | '' | Markdown content, use `v-model` in vue template |
81
75
  | theme | `'light' \| 'dark'` | 'light' | Editor theme |
82
76
  | class | `string` | '' | |
83
- | historyLength | `number` | 10 | The max length of history(if it is too big, editor will use more `RAM`) |
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. |
84
78
  | pageFullscreen | `boolean` | false | Screenfull in web page |
85
79
  | preview | `boolean` | true | Preview content in editor |
86
- | htmlPreview | `boolean` | false | Preview html in editor |
80
+ | htmlPreview | `boolean` | false | Preview html in editor(If true, preview must be false) |
87
81
  | previewOnly | `boolean` | false | Only render preview of content, no toolbar, no editing area |
88
82
  | language | `string` | 'zh-CN' | Build-in language('zh-CN','en-US') |
89
83
  | toolbars | `Array<ToolbarNames \| number>` | [toolbars] | Show contents of toolbar, all keys<sup>see `toolbars` below</sup> |
@@ -99,7 +93,8 @@ mark and emoji extensions
99
93
  | placeholder | `string` | '' | |
100
94
  | noKatex | `boolean` | false | Use katex or not |
101
95
  | codeTheme | `'atom' \| 'a11y' \| 'github' \| 'gradient' \| 'kimbie' \| 'paraiso' \| 'qtcreator' \| 'stackoverflow'` | 'atom' | Highlight code style, can be customized also |
102
- | markedHeadingId | `(text: string, level: number, index: number) => string` | (text) => text | H1-H6 `ID` generator |
96
+ | markedHeadingId<sup>`deleted^3.0.0`</sup> | `(text: string, level: number, index: number) => string` | (text) => text | Use `mdHeadingId` instead of it |
97
+ | mdHeadingId | `(text: string, level: number, index: number) => string` | (text) => text | H1-H6 `ID` generator |
103
98
  | sanitize | `(html: string) => string` | (html) => html | Sanitize the html, prevent XSS |
104
99
  | footers | `Array<'markdownTotal' \| '=' \| 'scrollSwitch' \| number>` | ['markdownTotal', '=', 'scrollSwitch'] | Show contents of footer, they are divided by `'='`. Set it to `[]` to hidden footer |
105
100
  | scrollAuto | `boolean` | true | Scroll default setting |
@@ -113,6 +108,7 @@ mark and emoji extensions
113
108
  | readOnly | `boolean` | false | same as `readonly` in native textarea |
114
109
  | maxLength | `number` | | same as `maxlength` in native textarea |
115
110
  | autoDetectCode | `boolean` | false | auto detect the type of pasted code, only support that copied from `vscode` |
111
+ | noHighlight | `boolean` | false | never highlight code |
116
112
 
117
113
  <details>
118
114
  <summary>『toolbars』</summary>
@@ -452,63 +448,40 @@ const handler = () => {
452
448
 
453
449
  ## 💴 Config Editor
454
450
 
455
- Use `MdEditor.config(option: ConfigOption)` to reconfigure `renderer`.
456
-
457
- - markedRenderer: `(renderer: RewriteRenderer) => RewriteRenderer`
458
-
459
- Open target page in a new browser window:
460
-
461
- ```js
462
- MdEditor.config({
463
- markedRenderer(renderer) {
464
- renderer.link = (href, title, text) => {
465
- return `<a href="${href}" title="${title}" target="_blank">${text}</a>`;
466
- };
451
+ Use `MdEditor.config(option: ConfigOption)` to reconfigure `markdown-it` and so on.
467
452
 
468
- return renderer;
469
- }
470
- });
471
- ```
453
+ - codeMirrorExtensions: Customize new extensions based on theme and default extensions f codeMirror.
472
454
 
473
- > Reference: https://marked.js.org/using_pro#renderer, RewriteRenderer extends Renderer and rewrites heading, now provides `index` as the fifth parameter and `headingId` as the sixth parameter.
474
- >
475
- > ```ts
476
- > type RewriteHeading = (
477
- > text: string,
478
- > level: 1 | 2 | 3 | 4 | 5 | 6,
479
- > raw: string,
480
- > slugger: Slugger,
481
- > index: number,
482
- > headingId: string
483
- > ) => string;
484
- > ```
485
-
486
- - markedExtensions: `Array<marked.TokenizerExtension & marked.RendererExtension>`
455
+ Example: Editor does not render the line number of textarea by default, this extension needs to be manually added
487
456
 
488
457
  ```js
489
458
  import MdEditor from 'md-editor-v3';
459
+ import { lineNumbers } from '@codemirror/view';
490
460
 
491
461
  MdEditor.config({
492
- markedExtensions: [your extension]
462
+ codeMirrorExtensions(_theme, extensions) {
463
+ return [...extensions, lineNumbers()];
464
+ }
493
465
  });
494
466
  ```
495
467
 
496
- > Reference: https://marked.js.org/using_pro#extensions
468
+ - markdownItConfig: Customize extensions, attributes of `markdown-it`, etc.
497
469
 
498
- - markedOptions: `marked.MarkedOptions`
499
-
500
- Do not render `<br>` on a single line break:
470
+ Example: Use `markdown-it-anchor` to render a hyperlink symbol to the right of the title
501
471
 
502
472
  ```js
503
473
  import MdEditor from 'md-editor-v3';
474
+ import ancher from 'markdown-it-anchor';
504
475
 
505
476
  MdEditor.config({
506
- markedOptions: { breaks: false }
477
+ markdownItConfig(mdit) {
478
+ mdit.use(ancher, {
479
+ permalink: true
480
+ });
481
+ }
507
482
  });
508
483
  ```
509
484
 
510
- > Reference: https://marked.js.org/using_advanced#options
511
-
512
485
  - editorConfig: Add more languages, reset `mermaid` template or delay rendering time:
513
486
 
514
487
  ```js
@@ -600,7 +573,7 @@ _Pay attention: shortcut keys are only available when the textarea is focused!_
600
573
  | CTRL + 1-6 | h1-h6 | `# title` |
601
574
  | CTRL + ↑ | superscript | `<sup>superscript</sup>` |
602
575
  | CTRL + ↓ | subscript | `<sub>subscript</sub>` |
603
- | CTRL + Q | quote | `> quote` |
576
+ | CTRL + Q<sup>`deleted^3.0.0`</sup> | quote | `> quote` |
604
577
  | CTRL + O | ordered list | `1. ordered list` |
605
578
  | CTRL + L | link | `[link](https://github.com/imzbf/md-editor-v3)` |
606
579
  | CTRL + Z | withdraw | Withdraw history in editor, not the function of system |
@@ -684,7 +657,8 @@ They are used as attributes of the editor component, eg: `MdEditor.DropdownToolb
684
657
 
685
658
  - `editorId`: `string`, necessary, same as editor's `editorId`, used to register listening events.
686
659
  - `class`: `string`, not necessary.
687
- - `markedHeadingId`: `MarkedHeadingId`, not necessary, same as editor.
660
+ - `markedHeadingId`<sup>`deleted^3.0.0`</sup>: use `mdHeadingId` instead of it.
661
+ - `mdHeadingId`: `MdHeadingId`, not necessary, same as editor.
688
662
  - `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`.
689
663
  - `theme`: `'light' | 'dark'`, not necessary, provide it when you want to change theme online, it is the same as Editor `theme`.
690
664
  - `offsetTop`: `number`, not necessary, highlight current item of catalogs when title is `offsetTop` pixels from the top, defalut 20.
@@ -4,25 +4,21 @@ declare const Editor: import("vue").DefineComponent<{
4
4
  default: string;
5
5
  };
6
6
  theme: {
7
- type: import("vue").PropType<import("./type").Themes>;
7
+ type: import("vue").PropType<import('./type').Themes>;
8
8
  default: string;
9
9
  };
10
10
  class: {
11
11
  type: StringConstructor;
12
12
  default: string;
13
13
  };
14
- historyLength: {
15
- type: import("vue").PropType<number>;
16
- default: number;
17
- };
18
14
  onChange: {
19
- type: import("vue").PropType<import("./type").ChangeEvent>;
15
+ type: import("vue").PropType<import('./type').ChangeEvent>;
20
16
  };
21
17
  onSave: {
22
- type: import("vue").PropType<import("./type").SaveEvent>;
18
+ type: import("vue").PropType<import('./type').SaveEvent>;
23
19
  };
24
20
  onUploadImg: {
25
- type: import("vue").PropType<import("./type").UploadImgEvent>;
21
+ type: import("vue").PropType<import('./type').UploadImgEvent>;
26
22
  };
27
23
  pageFullscreen: {
28
24
  type: import("vue").PropType<boolean>;
@@ -45,11 +41,11 @@ declare const Editor: import("vue").DefineComponent<{
45
41
  default: string;
46
42
  };
47
43
  toolbars: {
48
- type: import("vue").PropType<import("./type").ToolbarNames[]>;
44
+ type: import("vue").PropType<import('./type').ToolbarNames[]>;
49
45
  default: string[];
50
46
  };
51
47
  toolbarsExclude: {
52
- type: import("vue").PropType<import("./type").ToolbarNames[]>;
48
+ type: import("vue").PropType<import('./type').ToolbarNames[]>;
53
49
  default: never[];
54
50
  };
55
51
  noPrettier: {
@@ -57,10 +53,10 @@ declare const Editor: import("vue").DefineComponent<{
57
53
  default: boolean;
58
54
  };
59
55
  onHtmlChanged: {
60
- type: import("vue").PropType<import("./type").HtmlChangedEvent>;
56
+ type: import("vue").PropType<import('./type').HtmlChangedEvent>;
61
57
  };
62
58
  onGetCatalog: {
63
- type: import("vue").PropType<import("./type").GetCatalogEvent>;
59
+ type: import("vue").PropType<import('./type').GetCatalogEvent>;
64
60
  };
65
61
  editorId: {
66
62
  type: import("vue").PropType<string>;
@@ -82,9 +78,9 @@ declare const Editor: import("vue").DefineComponent<{
82
78
  type: import("vue").PropType<string | import("vue").CSSProperties>;
83
79
  default: () => {};
84
80
  };
85
- markedHeadingId: {
86
- type: import("vue").PropType<import("./type").MarkedHeadingId>;
87
- default: import("./type").MarkedHeadingId;
81
+ mdHeadingId: {
82
+ type: import("vue").PropType<import('./type').MdHeadingId>;
83
+ default: import('./type').MdHeadingId;
88
84
  };
89
85
  tableShape: {
90
86
  type: import("vue").PropType<number[]>;
@@ -110,15 +106,15 @@ declare const Editor: import("vue").DefineComponent<{
110
106
  type: import("vue").PropType<string | JSX.Element>;
111
107
  };
112
108
  onError: {
113
- type: import("vue").PropType<import("./type").ErrorEvent>;
109
+ type: import("vue").PropType<import('./type').ErrorEvent>;
114
110
  };
115
111
  codeTheme: {
116
112
  type: import("vue").PropType<string>;
117
113
  default: string;
118
114
  };
119
115
  footers: {
120
- type: import("vue").PropType<import("./type").Footers[]>;
121
- default: import("./type").Footers[];
116
+ type: import("vue").PropType<import('./type').Footers[]>;
117
+ default: import('./type').Footers[];
122
118
  };
123
119
  scrollAuto: {
124
120
  type: import("vue").PropType<boolean>;
@@ -166,31 +162,31 @@ declare const Editor: import("vue").DefineComponent<{
166
162
  onFocus: {
167
163
  type: import("vue").PropType<(event: FocusEvent) => void>;
168
164
  };
169
- }, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("./type").EditorEmits, "onChange" | "onSave" | "onUploadImg" | "onHtmlChanged" | "onGetCatalog" | "onError" | "onBlur" | "onFocus" | "update:modelValue", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
165
+ noHighlight: {
166
+ type: import("vue").PropType<boolean>;
167
+ default: boolean;
168
+ };
169
+ }, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import('./type').EditorEmits, "onChange" | "onSave" | "onUploadImg" | "onHtmlChanged" | "onGetCatalog" | "onError" | "onBlur" | "onFocus" | "update:modelValue", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
170
170
  modelValue: {
171
171
  type: import("vue").PropType<string>;
172
172
  default: string;
173
173
  };
174
174
  theme: {
175
- type: import("vue").PropType<import("./type").Themes>;
175
+ type: import("vue").PropType<import('./type').Themes>;
176
176
  default: string;
177
177
  };
178
178
  class: {
179
179
  type: StringConstructor;
180
180
  default: string;
181
181
  };
182
- historyLength: {
183
- type: import("vue").PropType<number>;
184
- default: number;
185
- };
186
182
  onChange: {
187
- type: import("vue").PropType<import("./type").ChangeEvent>;
183
+ type: import("vue").PropType<import('./type').ChangeEvent>;
188
184
  };
189
185
  onSave: {
190
- type: import("vue").PropType<import("./type").SaveEvent>;
186
+ type: import("vue").PropType<import('./type').SaveEvent>;
191
187
  };
192
188
  onUploadImg: {
193
- type: import("vue").PropType<import("./type").UploadImgEvent>;
189
+ type: import("vue").PropType<import('./type').UploadImgEvent>;
194
190
  };
195
191
  pageFullscreen: {
196
192
  type: import("vue").PropType<boolean>;
@@ -213,11 +209,11 @@ declare const Editor: import("vue").DefineComponent<{
213
209
  default: string;
214
210
  };
215
211
  toolbars: {
216
- type: import("vue").PropType<import("./type").ToolbarNames[]>;
212
+ type: import("vue").PropType<import('./type').ToolbarNames[]>;
217
213
  default: string[];
218
214
  };
219
215
  toolbarsExclude: {
220
- type: import("vue").PropType<import("./type").ToolbarNames[]>;
216
+ type: import("vue").PropType<import('./type').ToolbarNames[]>;
221
217
  default: never[];
222
218
  };
223
219
  noPrettier: {
@@ -225,10 +221,10 @@ declare const Editor: import("vue").DefineComponent<{
225
221
  default: boolean;
226
222
  };
227
223
  onHtmlChanged: {
228
- type: import("vue").PropType<import("./type").HtmlChangedEvent>;
224
+ type: import("vue").PropType<import('./type').HtmlChangedEvent>;
229
225
  };
230
226
  onGetCatalog: {
231
- type: import("vue").PropType<import("./type").GetCatalogEvent>;
227
+ type: import("vue").PropType<import('./type').GetCatalogEvent>;
232
228
  };
233
229
  editorId: {
234
230
  type: import("vue").PropType<string>;
@@ -250,9 +246,9 @@ declare const Editor: import("vue").DefineComponent<{
250
246
  type: import("vue").PropType<string | import("vue").CSSProperties>;
251
247
  default: () => {};
252
248
  };
253
- markedHeadingId: {
254
- type: import("vue").PropType<import("./type").MarkedHeadingId>;
255
- default: import("./type").MarkedHeadingId;
249
+ mdHeadingId: {
250
+ type: import("vue").PropType<import('./type').MdHeadingId>;
251
+ default: import('./type').MdHeadingId;
256
252
  };
257
253
  tableShape: {
258
254
  type: import("vue").PropType<number[]>;
@@ -278,15 +274,15 @@ declare const Editor: import("vue").DefineComponent<{
278
274
  type: import("vue").PropType<string | JSX.Element>;
279
275
  };
280
276
  onError: {
281
- type: import("vue").PropType<import("./type").ErrorEvent>;
277
+ type: import("vue").PropType<import('./type').ErrorEvent>;
282
278
  };
283
279
  codeTheme: {
284
280
  type: import("vue").PropType<string>;
285
281
  default: string;
286
282
  };
287
283
  footers: {
288
- type: import("vue").PropType<import("./type").Footers[]>;
289
- default: import("./type").Footers[];
284
+ type: import("vue").PropType<import('./type').Footers[]>;
285
+ default: import('./type').Footers[];
290
286
  };
291
287
  scrollAuto: {
292
288
  type: import("vue").PropType<boolean>;
@@ -334,6 +330,10 @@ declare const Editor: import("vue").DefineComponent<{
334
330
  onFocus: {
335
331
  type: import("vue").PropType<(event: FocusEvent) => void>;
336
332
  };
333
+ noHighlight: {
334
+ type: import("vue").PropType<boolean>;
335
+ default: boolean;
336
+ };
337
337
  }>> & {
338
338
  onOnChange?: ((...args: any[]) => any) | undefined;
339
339
  onOnSave?: ((...args: any[]) => any) | undefined;
@@ -349,30 +349,30 @@ declare const Editor: import("vue").DefineComponent<{
349
349
  preview: boolean;
350
350
  htmlPreview: boolean;
351
351
  modelValue: string;
352
- theme: import("./type").Themes;
352
+ theme: import('./type').Themes;
353
353
  class: string;
354
- historyLength: number;
355
354
  previewOnly: boolean;
356
355
  language: string;
357
- toolbars: import("./type").ToolbarNames[];
358
- toolbarsExclude: import("./type").ToolbarNames[];
356
+ toolbars: import('./type').ToolbarNames[];
357
+ toolbarsExclude: import('./type').ToolbarNames[];
359
358
  noPrettier: boolean;
360
359
  editorId: string;
361
360
  tabWidth: number;
362
361
  showCodeRowNumber: boolean;
363
362
  previewTheme: string;
364
363
  style: string | import("vue").CSSProperties;
365
- markedHeadingId: import("./type").MarkedHeadingId;
364
+ mdHeadingId: import('./type').MdHeadingId;
366
365
  tableShape: number[];
367
366
  noMermaid: boolean;
368
367
  sanitize: (html: string) => string;
369
368
  placeholder: string;
370
369
  noKatex: boolean;
371
370
  codeTheme: string;
372
- footers: import("./type").Footers[];
371
+ footers: import('./type').Footers[];
373
372
  scrollAuto: boolean;
374
373
  formatCopiedText: (text: string) => string;
375
374
  codeStyleReverse: boolean;
376
375
  codeStyleReverseList: string[];
376
+ noHighlight: boolean;
377
377
  }>;
378
378
  export default Editor;
@@ -1,14 +1,14 @@
1
1
  import { PropType, ExtractPropTypes } from 'vue';
2
2
  import { LooseRequired } from '@vue/shared';
3
- import { TocItem } from './index';
4
- import { MarkedHeadingId } from '../../type';
5
- declare const catalogLinkProps: () => {
3
+ import { MdHeadingId } from '../../type';
4
+ import { TocItem } from '.';
5
+ declare const props: {
6
6
  tocItem: {
7
7
  type: PropType<TocItem>;
8
8
  default: () => {};
9
9
  };
10
- markedHeadingId: {
11
- type: PropType<MarkedHeadingId>;
10
+ mdHeadingId: {
11
+ type: PropType<MdHeadingId>;
12
12
  default: () => void;
13
13
  };
14
14
  scrollElement: {
@@ -24,14 +24,14 @@ declare const catalogLinkProps: () => {
24
24
  default: number;
25
25
  };
26
26
  };
27
- export type CatalogLinkProps = Readonly<LooseRequired<Readonly<ExtractPropTypes<ReturnType<typeof catalogLinkProps>>>>>;
27
+ export type CatalogLinkProps = Readonly<LooseRequired<Readonly<ExtractPropTypes<typeof props>>>>;
28
28
  declare const CatalogLink: import("vue").DefineComponent<{
29
29
  tocItem: {
30
30
  type: PropType<TocItem>;
31
31
  default: () => {};
32
32
  };
33
- markedHeadingId: {
34
- type: PropType<MarkedHeadingId>;
33
+ mdHeadingId: {
34
+ type: PropType<MdHeadingId>;
35
35
  default: () => void;
36
36
  };
37
37
  scrollElement: {
@@ -51,8 +51,8 @@ declare const CatalogLink: import("vue").DefineComponent<{
51
51
  type: PropType<TocItem>;
52
52
  default: () => {};
53
53
  };
54
- markedHeadingId: {
55
- type: PropType<MarkedHeadingId>;
54
+ mdHeadingId: {
55
+ type: PropType<MdHeadingId>;
56
56
  default: () => void;
57
57
  };
58
58
  scrollElement: {
@@ -68,7 +68,7 @@ declare const CatalogLink: import("vue").DefineComponent<{
68
68
  default: number;
69
69
  };
70
70
  }>>, {
71
- markedHeadingId: MarkedHeadingId;
71
+ mdHeadingId: MdHeadingId;
72
72
  onClick: (e: MouseEvent, t: TocItem) => void;
73
73
  scrollElement: string | Element;
74
74
  scrollElementOffsetTop: number;
@@ -1,5 +1,5 @@
1
1
  import { PropType, ExtractPropTypes } from 'vue';
2
- import { MarkedHeadingId, Themes } from '../../type';
2
+ import { MdHeadingId, Themes } from '../../type';
3
3
  export interface TocItem {
4
4
  text: string;
5
5
  level: number;
@@ -18,8 +18,8 @@ declare const MdCatalog: import("vue").DefineComponent<{
18
18
  type: StringConstructor;
19
19
  default: string;
20
20
  };
21
- markedHeadingId: {
22
- type: PropType<MarkedHeadingId>;
21
+ mdHeadingId: {
22
+ type: PropType<MdHeadingId>;
23
23
  default: (text: string) => string;
24
24
  };
25
25
  /**
@@ -67,8 +67,8 @@ declare const MdCatalog: import("vue").DefineComponent<{
67
67
  type: StringConstructor;
68
68
  default: string;
69
69
  };
70
- markedHeadingId: {
71
- type: PropType<MarkedHeadingId>;
70
+ mdHeadingId: {
71
+ type: PropType<MdHeadingId>;
72
72
  default: (text: string) => string;
73
73
  };
74
74
  /**
@@ -110,7 +110,7 @@ declare const MdCatalog: import("vue").DefineComponent<{
110
110
  }, {
111
111
  theme: Themes;
112
112
  class: string;
113
- markedHeadingId: MarkedHeadingId;
113
+ mdHeadingId: MdHeadingId;
114
114
  offsetTop: number;
115
115
  scrollElementOffsetTop: number;
116
116
  }>;