vditor 3.8.14 → 3.8.17

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.
@@ -31,6 +31,7 @@ import {
31
31
  } from "../util/selection";
32
32
  import {afterRenderEvent} from "./afterRenderEvent";
33
33
  import {removeBlockElement} from "./processKeydown";
34
+ import {renderToc} from "../util/toc";
34
35
 
35
36
  export const highlightToolbarWYSIWYG = (vditor: IVditor) => {
36
37
  clearTimeout(vditor.wysiwyg.hlToolbarTimeoutId);
@@ -931,6 +932,9 @@ const genClose = (element: HTMLElement, vditor: IVditor) => {
931
932
  element.remove();
932
933
  afterRenderEvent(vditor);
933
934
  highlightToolbarWYSIWYG(vditor);
935
+ if (["H1", "H2", "H3", "H4", "H5" ,"H6"].includes(element.tagName)) {
936
+ renderToc(vditor);
937
+ }
934
938
  };
935
939
  vditor.wysiwyg.popover.insertAdjacentElement("beforeend", close);
936
940
  };
@@ -28,6 +28,7 @@ import {genImagePopover, genLinkRefPopover, highlightToolbarWYSIWYG} from "./hig
28
28
  import {getRenderElementNextNode, modifyPre} from "./inlineTag";
29
29
  import {input} from "./input";
30
30
  import {showCode} from "./showCode";
31
+ import {getMarkdown} from "../markdown/getMarkdown";
31
32
 
32
33
  class WYSIWYG {
33
34
  public range: Range;
@@ -389,6 +390,9 @@ class WYSIWYG {
389
390
  if ((startSpace && blockElement.getAttribute("data-type") !== "code-block")
390
391
  || endSpace || isHeadingMD(blockElement.innerHTML) ||
391
392
  (isHrMD(blockElement.innerHTML) && blockElement.previousElementSibling)) {
393
+ if (typeof vditor.options.input === "function") {
394
+ vditor.options.input(getMarkdown(vditor));
395
+ }
392
396
  return;
393
397
  }
394
398
 
@@ -108,21 +108,23 @@ export const input = (vditor: IVditor, range: Range, event?: InputEvent) => {
108
108
  html = html.replace("<div><wbr><br></div>", "<li><p><wbr><br></p></li>");
109
109
  }
110
110
 
111
- // 添加链接引用
112
- vditor.wysiwyg.element.querySelectorAll("[data-type='link-ref-defs-block']").forEach((item) => {
113
- if (item && !(blockElement as HTMLElement).isEqualNode(item)) {
114
- html += item.outerHTML;
115
- item.remove();
116
- }
117
- });
111
+ if (!blockElement.innerText.startsWith("```")) {
112
+ // 添加链接引用
113
+ vditor.wysiwyg.element.querySelectorAll("[data-type='link-ref-defs-block']").forEach((item) => {
114
+ if (item && !(blockElement as HTMLElement).isEqualNode(item)) {
115
+ html += item.outerHTML;
116
+ item.remove();
117
+ }
118
+ });
118
119
 
119
- // 添加脚注
120
- vditor.wysiwyg.element.querySelectorAll("[data-type='footnotes-block']").forEach((item) => {
121
- if (item && !(blockElement as HTMLElement).isEqualNode(item)) {
122
- html += item.outerHTML;
123
- item.remove();
124
- }
125
- });
120
+ // 添加脚注
121
+ vditor.wysiwyg.element.querySelectorAll("[data-type='footnotes-block']").forEach((item) => {
122
+ if (item && !(blockElement as HTMLElement).isEqualNode(item)) {
123
+ html += item.outerHTML;
124
+ item.remove();
125
+ }
126
+ });
127
+ }
126
128
  } else {
127
129
  html = blockElement.innerHTML;
128
130
  }