md-editor-v3 4.15.2 → 4.15.3

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
@@ -48,6 +48,10 @@ For more ways to use or contribute, please refer to: [md-editor-extension](https
48
48
 
49
49
  ## 💡 Usage
50
50
 
51
+ When using server-side rendering, make sure to set `editorId` to a constant value.
52
+
53
+ Starting from `4.0.0`, internal components can be imported on-demand.
54
+
51
55
  ### ✍🏻 Display Editor
52
56
 
53
57
  ```vue
@@ -64,10 +68,6 @@ const text = ref('# Hello Editor');
64
68
  </script>
65
69
  ```
66
70
 
67
- > `^4.0.0`, internal components can be imported on-demand.
68
-
69
- > If there are multiple editors on the page, please set different `editorId` for each editor!
70
-
71
71
  ### 📖 Preview Only
72
72
 
73
73
  ```vue
@@ -87,6 +87,8 @@ const scrollElement = document.documentElement;
87
87
  </script>
88
88
  ```
89
89
 
90
+ When using server-side rendering, `scrollElement` should be of string type, eg: `body`, `#id`, `.class`.
91
+
90
92
  ## 🗺 Preview
91
93
 
92
94
  | Default theme | Dark theme | Preview only |
@@ -106,11 +108,11 @@ Inputing prompt and mark, emoji extensions
106
108
  | modelValue | `string` | '' | Markdown content, use `v-model` in vue template |
107
109
  | theme | `'light' \| 'dark'` | 'light' | Editor theme |
108
110
  | class | `string` | '' | |
111
+ | style | `string \| CSSProperties` | {} | Inline style |
109
112
  | language | `string` | 'zh-CN' | Build-in language('zh-CN','en-US') |
110
- | editorId | `string` | 'md-editor-v3' | Editor's id, it is used when there are more than two editors in the same page |
111
- | showCodeRowNumber | `boolean` | false | Show row number for code block or not |
113
+ | editorId | `string` | 'md-editor-v3\_[\d]' | Editor's id, default incrementing by number. When using server-side rendering, make sure to set this attribute to a constant value |
114
+ | showCodeRowNumber | `boolean` | true | Show row number for code block or not |
112
115
  | previewTheme | `'default' \| 'github' \| 'vuepress' \| 'mk-cute' \| 'smart-blue' \| 'cyanosis'` | 'default' | Theme of preview, can be customized |
113
- | style | `string \| CSSProperties` | {} | Inline style |
114
116
  | noMermaid | `boolean` | false | Use mermaid or not |
115
117
  | noKatex | `boolean` | false | Use katex or not |
116
118
  | codeTheme | `'atom' \| 'a11y' \| 'github' \| 'gradient' \| 'kimbie' \| 'paraiso' \| 'qtcreator' \| 'stackoverflow'` | 'atom' | Highlight code style, can be customized also |
@@ -450,9 +450,6 @@ const AdmonitionPlugin = (md, options) => {
450
450
  if (array.length > 1) {
451
451
  title = params.substring(type.length + 2);
452
452
  }
453
- if (title === "" || !title) {
454
- title = type;
455
- }
456
453
  };
457
454
  md.block.ruler.before(
458
455
  "code",
@@ -520,15 +517,17 @@ const AdmonitionPlugin = (md, options) => {
520
517
  token.block = true;
521
518
  token.info = type;
522
519
  token.map = [startLine, nextLine];
523
- token = state.push("admonition_title_open", "p", 1);
524
- token.markup = markup + " " + type;
525
- token.map = [startLine, nextLine];
526
- token = state.push("inline", "", 0);
527
- token.content = title;
528
- token.map = [startLine, state.line - 1];
529
- token.children = [];
530
- token = state.push("admonition_title_close", "p", -1);
531
- token.markup = markup + " " + type;
520
+ if (title) {
521
+ token = state.push("admonition_title_open", "p", 1);
522
+ token.markup = markup + " " + type;
523
+ token.map = [startLine, nextLine];
524
+ token = state.push("inline", "", 0);
525
+ token.content = title;
526
+ token.map = [startLine, state.line - 1];
527
+ token.children = [];
528
+ token = state.push("admonition_title_close", "p", -1);
529
+ token.markup = markup + " " + type;
530
+ }
532
531
  state.md.block.tokenize(state, startLine + 1, nextLine);
533
532
  token = state.push("admonition_close", "div", -1);
534
533
  token.markup = state.src.slice(start, pos);
@@ -574,7 +573,7 @@ const HeadingPlugin = (md, options) => {
574
573
  };
575
574
  const HeadingPlugin$1 = HeadingPlugin;
576
575
  const codetabs = (md, _opts) => {
577
- const defaultRender = md.renderer.rules.fence, unescapeAll = md.utils.unescapeAll, re = /\[(\w*)(?::([\w ]*))?\]/;
576
+ const defaultRender = md.renderer.rules.fence, unescapeAll = md.utils.unescapeAll, re = /\[(\w*)(?::([\w ]*))?\]/, mandatoryRe = /::close/;
578
577
  const getInfo = (token) => {
579
578
  return token.info ? unescapeAll(token.info).trim() : "";
580
579
  };
@@ -587,8 +586,9 @@ const codetabs = (md, _opts) => {
587
586
  return info ? info.split(/(\s+)/g)[0] : "";
588
587
  };
589
588
  const getTagType = (token) => {
590
- const open = token.content.trim().split("\n").length < _opts.autoFoldThreshold;
591
- const tagContainer = _opts.codeFoldable ? "details" : "div", tagHeader = _opts.codeFoldable ? "summary" : "div";
589
+ const mandatory = mandatoryRe.test(token.info);
590
+ const open = !mandatory && token.content.trim().split("\n").length < _opts.autoFoldThreshold;
591
+ const tagContainer = mandatory || _opts.codeFoldable ? "details" : "div", tagHeader = mandatory || _opts.codeFoldable ? "summary" : "div";
592
592
  return { open, tagContainer, tagHeader };
593
593
  };
594
594
  const fenceGroup = (tokens, idx, options, env, slf) => {
@@ -604,6 +604,7 @@ const codetabs = (md, _opts) => {
604
604
  const tmpToken2 = {
605
605
  attrs: mergeAttrs(tokens[idx], addAttrs2)
606
606
  };
607
+ tokens[idx].info = tokens[idx].info.replace(mandatoryRe, "");
607
608
  const codeRendered = defaultRender(tokens, idx, options, env, slf);
608
609
  return `<${tagContainer2} ${slf.renderAttrs(tmpToken2)}>
609
610
  <${tagHeader2} class="${config.prefix}-code-head">
@@ -631,7 +632,7 @@ const codetabs = (md, _opts) => {
631
632
  if (group !== GROUP) {
632
633
  break;
633
634
  }
634
- token.info = token.info.replace(re, "");
635
+ token.info = token.info.replace(re, "").replace(mandatoryRe, "");
635
636
  token.hidden = true;
636
637
  const className = `${config.prefix}-codetab-${_opts.editorId}-${idx}-${i - idx}`;
637
638
  checked = i - idx > 0 ? "" : "checked";
@@ -1491,11 +1492,11 @@ const mdPreviewProps = {
1491
1492
  /**
1492
1493
  * 预览中代码是否显示行号
1493
1494
  *
1494
- * @default false
1495
+ * @default true
1495
1496
  */
1496
1497
  showCodeRowNumber: {
1497
1498
  type: Boolean,
1498
- default: false
1499
+ default: true
1499
1500
  },
1500
1501
  /**
1501
1502
  * 预览内容样式
@@ -449,9 +449,6 @@ const AdmonitionPlugin = (md, options) => {
449
449
  if (array.length > 1) {
450
450
  title = params.substring(type.length + 2);
451
451
  }
452
- if (title === "" || !title) {
453
- title = type;
454
- }
455
452
  };
456
453
  md.block.ruler.before(
457
454
  "code",
@@ -519,15 +516,17 @@ const AdmonitionPlugin = (md, options) => {
519
516
  token.block = true;
520
517
  token.info = type;
521
518
  token.map = [startLine, nextLine];
522
- token = state.push("admonition_title_open", "p", 1);
523
- token.markup = markup + " " + type;
524
- token.map = [startLine, nextLine];
525
- token = state.push("inline", "", 0);
526
- token.content = title;
527
- token.map = [startLine, state.line - 1];
528
- token.children = [];
529
- token = state.push("admonition_title_close", "p", -1);
530
- token.markup = markup + " " + type;
519
+ if (title) {
520
+ token = state.push("admonition_title_open", "p", 1);
521
+ token.markup = markup + " " + type;
522
+ token.map = [startLine, nextLine];
523
+ token = state.push("inline", "", 0);
524
+ token.content = title;
525
+ token.map = [startLine, state.line - 1];
526
+ token.children = [];
527
+ token = state.push("admonition_title_close", "p", -1);
528
+ token.markup = markup + " " + type;
529
+ }
531
530
  state.md.block.tokenize(state, startLine + 1, nextLine);
532
531
  token = state.push("admonition_close", "div", -1);
533
532
  token.markup = state.src.slice(start, pos);
@@ -573,7 +572,7 @@ const HeadingPlugin = (md, options) => {
573
572
  };
574
573
  const HeadingPlugin$1 = HeadingPlugin;
575
574
  const codetabs = (md, _opts) => {
576
- const defaultRender = md.renderer.rules.fence, unescapeAll = md.utils.unescapeAll, re = /\[(\w*)(?::([\w ]*))?\]/;
575
+ const defaultRender = md.renderer.rules.fence, unescapeAll = md.utils.unescapeAll, re = /\[(\w*)(?::([\w ]*))?\]/, mandatoryRe = /::close/;
577
576
  const getInfo = (token) => {
578
577
  return token.info ? unescapeAll(token.info).trim() : "";
579
578
  };
@@ -586,8 +585,9 @@ const codetabs = (md, _opts) => {
586
585
  return info ? info.split(/(\s+)/g)[0] : "";
587
586
  };
588
587
  const getTagType = (token) => {
589
- const open = token.content.trim().split("\n").length < _opts.autoFoldThreshold;
590
- const tagContainer = _opts.codeFoldable ? "details" : "div", tagHeader = _opts.codeFoldable ? "summary" : "div";
588
+ const mandatory = mandatoryRe.test(token.info);
589
+ const open = !mandatory && token.content.trim().split("\n").length < _opts.autoFoldThreshold;
590
+ const tagContainer = mandatory || _opts.codeFoldable ? "details" : "div", tagHeader = mandatory || _opts.codeFoldable ? "summary" : "div";
591
591
  return { open, tagContainer, tagHeader };
592
592
  };
593
593
  const fenceGroup = (tokens, idx, options, env, slf) => {
@@ -603,6 +603,7 @@ const codetabs = (md, _opts) => {
603
603
  const tmpToken2 = {
604
604
  attrs: mergeAttrs(tokens[idx], addAttrs2)
605
605
  };
606
+ tokens[idx].info = tokens[idx].info.replace(mandatoryRe, "");
606
607
  const codeRendered = defaultRender(tokens, idx, options, env, slf);
607
608
  return `<${tagContainer2} ${slf.renderAttrs(tmpToken2)}>
608
609
  <${tagHeader2} class="${prefix}-code-head">
@@ -630,7 +631,7 @@ const codetabs = (md, _opts) => {
630
631
  if (group !== GROUP) {
631
632
  break;
632
633
  }
633
- token.info = token.info.replace(re, "");
634
+ token.info = token.info.replace(re, "").replace(mandatoryRe, "");
634
635
  token.hidden = true;
635
636
  const className = `${prefix}-codetab-${_opts.editorId}-${idx}-${i - idx}`;
636
637
  checked = i - idx > 0 ? "" : "checked";
@@ -1490,11 +1491,11 @@ const mdPreviewProps = {
1490
1491
  /**
1491
1492
  * 预览中代码是否显示行号
1492
1493
  *
1493
- * @default false
1494
+ * @default true
1494
1495
  */
1495
1496
  showCodeRowNumber: {
1496
1497
  type: Boolean,
1497
- default: false
1498
+ default: true
1498
1499
  },
1499
1500
  /**
1500
1501
  * 预览内容样式
@@ -64,7 +64,7 @@ export declare const mdPreviewProps: {
64
64
  /**
65
65
  * 预览中代码是否显示行号
66
66
  *
67
- * @default false
67
+ * @default true
68
68
  */
69
69
  showCodeRowNumber: {
70
70
  type: PropType<boolean>;
@@ -533,7 +533,7 @@ export declare const editorProps: {
533
533
  /**
534
534
  * 预览中代码是否显示行号
535
535
  *
536
- * @default false
536
+ * @default true
537
537
  */
538
538
  showCodeRowNumber: {
539
539
  type: PropType<boolean>;