vditor 3.8.18 → 3.9.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.
@@ -8,6 +8,7 @@ import {highlightRender} from "../markdown/highlightRender";
8
8
  import {mathRender} from "../markdown/mathRender";
9
9
  import {mediaRender} from "../markdown/mediaRender";
10
10
  import {mermaidRender} from "../markdown/mermaidRender";
11
+ import {markmapRender} from "../markdown/markmapRender";
11
12
  import {mindmapRender} from "../markdown/mindmapRender";
12
13
  import {plantumlRender} from "../markdown/plantumlRender";
13
14
  import {getEventName} from "../util/compatibility";
@@ -51,8 +52,21 @@ export class Preview {
51
52
  }
52
53
  return;
53
54
  }
55
+ if (event.target.tagName === "A") {
56
+ if (vditor.options.link.click) {
57
+ vditor.options.link.click(event.target);
58
+ } else if (vditor.options.link.isOpen) {
59
+ window.open(event.target.getAttribute("href"));
60
+ }
61
+ event.preventDefault();
62
+ return;
63
+ }
54
64
  if (event.target.tagName === "IMG") {
55
- previewImage(event.target as HTMLImageElement, vditor.options.lang, vditor.options.theme);
65
+ if (vditor.options.image.preview) {
66
+ vditor.options.image.preview(event.target)
67
+ } else if (vditor.options.image.isPreview) {
68
+ previewImage(event.target as HTMLImageElement, vditor.options.lang, vditor.options.theme);
69
+ }
56
70
  }
57
71
  });
58
72
 
@@ -211,6 +225,7 @@ export class Preview {
211
225
  highlightRender(vditor.options.preview.hljs, vditor.preview.element.lastElementChild as HTMLElement,
212
226
  vditor.options.cdn);
213
227
  mermaidRender(vditor.preview.element.lastElementChild as HTMLElement, vditor.options.cdn, vditor.options.theme);
228
+ markmapRender(vditor.preview.element.lastElementChild as HTMLElement, vditor.options.cdn, vditor.options.theme);
214
229
  flowchartRender(vditor.preview.element.lastElementChild as HTMLElement, vditor.options.cdn);
215
230
  graphvizRender(vditor.preview.element.lastElementChild as HTMLElement, vditor.options.cdn);
216
231
  chartRender(vditor.preview.element.lastElementChild as HTMLElement, vditor.options.cdn, vditor.options.theme);
@@ -145,7 +145,7 @@ export const setEditMode = (vditor: IVditor, type: string, event: Event | string
145
145
  vditor.toolbar.elements["edit-mode"].querySelector(`button[data-mode="${vditor.currentMode}"]`).classList.add("vditor-menu--current");
146
146
  }
147
147
 
148
- vditor.outline.toggle(vditor, vditor.currentMode !== "sv" && vditor.options.outline.enable);
148
+ vditor.outline.toggle(vditor, vditor.currentMode !== "sv" && vditor.options.outline.enable, typeof event !== "string");
149
149
  };
150
150
 
151
151
  export class EditMode extends MenuItem {
@@ -81,7 +81,7 @@ export const initUI = (vditor: IVditor) => {
81
81
  if (vditor.toolbar.elements.export) {
82
82
  // for export pdf
83
83
  vditor.element.insertAdjacentHTML("beforeend",
84
- '<iframe style="width: 100%;height: 0;border: 0"></iframe>');
84
+ '<iframe id="vditorExportIframe" style="width: 100%;height: 0;border: 0"></iframe>');
85
85
  }
86
86
 
87
87
  setEditMode(vditor, vditor.options.mode, afterRender(vditor));
@@ -1,5 +1,5 @@
1
- import { Constants } from "../constants";
2
- import { merge } from "./merge";
1
+ import {Constants} from "../constants";
2
+ import {merge} from "./merge";
3
3
 
4
4
  export class Options {
5
5
  public options: IOptions;
@@ -59,6 +59,12 @@ export class Options {
59
59
  mode: "both",
60
60
  theme: Constants.THEME_OPTIONS,
61
61
  },
62
+ link: {
63
+ isOpen: true,
64
+ },
65
+ image: {
66
+ isPreview: true,
67
+ },
62
68
  resize: {
63
69
  enable: false,
64
70
  position: "bottom",
@@ -29,7 +29,11 @@ export const focusEvent = (vditor: IVditor, editorElement: HTMLElement) => {
29
29
  export const dblclickEvent = (vditor: IVditor, editorElement: HTMLElement) => {
30
30
  editorElement.addEventListener("dblclick", (event: MouseEvent & { target: HTMLElement }) => {
31
31
  if (event.target.tagName === "IMG") {
32
- previewImage(event.target as HTMLImageElement, vditor.options.lang, vditor.options.theme);
32
+ if (vditor.options.image.preview) {
33
+ vditor.options.image.preview(event.target);
34
+ } else if (vditor.options.image.isPreview) {
35
+ previewImage(event.target as HTMLImageElement, vditor.options.lang, vditor.options.theme);
36
+ }
33
37
  }
34
38
  });
35
39
  };
@@ -6,6 +6,7 @@ import {graphvizRender} from "../markdown/graphvizRender";
6
6
  import {highlightRender} from "../markdown/highlightRender";
7
7
  import {mathRender} from "../markdown/mathRender";
8
8
  import {mermaidRender} from "../markdown/mermaidRender";
9
+ import {markmapRender} from "../markdown/markmapRender";
9
10
  import {mindmapRender} from "../markdown/mindmapRender";
10
11
  import {plantumlRender} from "../markdown/plantumlRender";
11
12
 
@@ -69,6 +70,8 @@ export const processCodeRender = (previewPanel: HTMLElement, vditor: IVditor) =>
69
70
  abcRender(previewPanel, vditor.options.cdn);
70
71
  } else if (language === "mermaid") {
71
72
  mermaidRender(previewPanel, vditor.options.cdn, vditor.options.theme);
73
+ } else if (language === "markmap") {
74
+ markmapRender(previewPanel, vditor.options.cdn, vditor.options.theme);
72
75
  } else if (language === "flowchart") {
73
76
  flowchartRender(previewPanel, vditor.options.cdn);
74
77
  } else if (language === "echarts") {
@@ -425,7 +425,13 @@ class WYSIWYG {
425
425
 
426
426
  // 打开链接
427
427
  if (event.target.tagName === "A") {
428
- window.open(event.target.getAttribute("href"));
428
+ if (vditor.options.link.click) {
429
+ vditor.options.link.click(event.target);
430
+ } else if (vditor.options.link.isOpen) {
431
+ window.open(event.target.getAttribute("href"));
432
+ }
433
+ event.preventDefault();
434
+ return;
429
435
  }
430
436
 
431
437
  const range = getEditorRange(vditor);