md-editor-v3 4.14.0-0 → 4.14.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.
@@ -128,13 +128,16 @@ const useSreenfull = (props2) => {
128
128
  var _a;
129
129
  onScreenfullEvent();
130
130
  if (!screenfull) {
131
- const screenScript = dom.createHTMLElement("script", {
132
- ...(_a = editorExtensionsAttrs.screenfull) == null ? void 0 : _a.js,
133
- src: editorExtensions.screenfull.js,
134
- id: `${config.prefix}-screenfull`,
135
- onload: screenfullLoad
136
- });
137
- dom.appendHandler(screenScript, "screenfull");
131
+ dom.appendHandler(
132
+ "script",
133
+ {
134
+ ...(_a = editorExtensionsAttrs.screenfull) == null ? void 0 : _a.js,
135
+ src: editorExtensions.screenfull.js,
136
+ id: `${config.prefix}-screenfull`,
137
+ onload: screenfullLoad
138
+ },
139
+ "screenfull"
140
+ );
138
141
  }
139
142
  });
140
143
  vue.onMounted(() => {
@@ -2853,11 +2856,17 @@ const useResize = (props2, contentRef, resizeRef) => {
2853
2856
  const resizeMouseup = () => {
2854
2857
  document.removeEventListener("mousemove", resizeMousemove);
2855
2858
  };
2856
- vue.onMounted(() => {
2857
- var _a;
2858
- (_a = resizeRef.value) == null ? void 0 : _a.addEventListener("mousedown", resizeMousedown);
2859
- document.addEventListener("mouseup", resizeMouseup);
2860
- });
2859
+ vue.watch(
2860
+ [resizeRef],
2861
+ () => {
2862
+ var _a, _b;
2863
+ (_a = resizeRef.value) == null ? void 0 : _a.addEventListener("mousedown", resizeMousedown);
2864
+ (_b = resizeRef.value) == null ? void 0 : _b.addEventListener("mouseup", resizeMouseup);
2865
+ },
2866
+ {
2867
+ immediate: true
2868
+ }
2869
+ );
2861
2870
  vue.onBeforeUnmount(() => {
2862
2871
  var _a, _b;
2863
2872
  (_a = resizeRef.value) == null ? void 0 : _a.removeEventListener("mousedown", resizeMousedown);
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
- const util = require("@vavt/util");
3
2
  const keyMove = (trigger, moveHandler) => {
4
3
  const triggerMouseDown = (mdown) => {
5
4
  const parent = trigger.parentElement || document.body;
@@ -33,31 +32,28 @@ const keyMove = (trigger, moveHandler) => {
33
32
  trigger.removeEventListener("mousedown", triggerMouseDown);
34
33
  };
35
34
  };
36
- const appendHandler = (ele, checkKey = "") => {
37
- const insertedEle = document.getElementById(ele.id);
38
- const onload_ = ele.onload;
39
- ele.onload = null;
40
- const onload = function(e) {
41
- if (typeof onload_ === "function") {
42
- onload_.bind(this)(e);
43
- }
44
- ele.removeEventListener("load", onload);
45
- };
35
+ const appendHandler = (tagName, attributes, checkKey = "") => {
36
+ var _a;
37
+ const insertedEle = document.getElementById(attributes.id);
46
38
  if (!insertedEle) {
47
- ele.addEventListener("load", onload);
39
+ const attrsCopy = { ...attributes };
40
+ attrsCopy.onload = null;
41
+ const ele = createHTMLElement(tagName, attrsCopy);
42
+ onload && ele.addEventListener("load", onload);
48
43
  document.head.appendChild(ele);
49
44
  } else if (checkKey !== "") {
50
- insertedEle.addEventListener("load", onload);
51
45
  if (Reflect.get(window, checkKey)) {
52
- insertedEle.dispatchEvent(new Event("load"));
46
+ (_a = attributes.onload) == null ? void 0 : _a.call(insertedEle, new Event("load"));
47
+ } else {
48
+ attributes.onload && insertedEle.addEventListener("load", attributes.onload);
53
49
  }
54
50
  }
55
51
  };
56
- const updateHandler = util.debounce((ele) => {
57
- const insertedEle = document.getElementById(ele.id);
52
+ const updateHandler = (tagName, attributes) => {
53
+ const insertedEle = document.getElementById(attributes.id);
58
54
  insertedEle == null ? void 0 : insertedEle.remove();
59
- appendHandler(ele);
60
- }, 10);
55
+ appendHandler(tagName, attributes);
56
+ };
61
57
  const createHTMLElement = (tagName, attributes) => {
62
58
  const element = document.createElement(tagName);
63
59
  Object.keys(attributes).forEach((key) => {
@@ -68,6 +64,5 @@ const createHTMLElement = (tagName, attributes) => {
68
64
  return element;
69
65
  };
70
66
  exports.appendHandler = appendHandler;
71
- exports.createHTMLElement = createHTMLElement;
72
67
  exports.keyMove = keyMove;
73
68
  exports.updateHandler = updateHandler;
@@ -103,31 +103,31 @@ const useHighlight = (props) => {
103
103
  if (props.noHighlight || hljsRef.value) {
104
104
  return;
105
105
  }
106
- const highlightScript = dom.createHTMLElement("script", {
107
- ...highlight.value.js,
108
- id: `${config.prefix}-hljs`,
109
- onload() {
110
- hljsRef.value = window.hljs;
111
- }
112
- });
113
- const highlightLink = dom.createHTMLElement("link", {
106
+ dom.appendHandler("link", {
114
107
  ...highlight.value.css,
115
108
  rel: "stylesheet",
116
109
  id: `${config.prefix}-hlCss`
117
110
  });
118
- dom.appendHandler(highlightLink);
119
- dom.appendHandler(highlightScript, "hljs");
111
+ dom.appendHandler(
112
+ "script",
113
+ {
114
+ ...highlight.value.js,
115
+ id: `${config.prefix}-hljs`,
116
+ onload() {
117
+ hljsRef.value = window.hljs;
118
+ }
119
+ },
120
+ "hljs"
121
+ );
120
122
  });
121
123
  vue.watch(
122
124
  () => highlight.value.css,
123
125
  () => {
124
- dom.updateHandler(
125
- dom.createHTMLElement("link", {
126
- ...highlight.value.css,
127
- rel: "stylesheet",
128
- id: `${config.prefix}-hlCss`
129
- })
130
- );
126
+ dom.updateHandler("link", {
127
+ ...highlight.value.css,
128
+ rel: "stylesheet",
129
+ id: `${config.prefix}-hlCss`
130
+ });
131
131
  }
132
132
  );
133
133
  return hljsRef;
@@ -168,13 +168,12 @@ const useMermaid = (props) => {
168
168
  }
169
169
  const jsSrc = editorExtensions.mermaid.js;
170
170
  if (/\.mjs/.test(jsSrc)) {
171
- const modulePreload = dom.createHTMLElement("link", {
171
+ dom.appendHandler("link", {
172
172
  ...(_b = editorExtensionsAttrs.mermaid) == null ? void 0 : _b.js,
173
173
  rel: "modulepreload",
174
174
  href: jsSrc,
175
175
  id: `${config.prefix}-mermaid-m`
176
176
  });
177
- dom.appendHandler(modulePreload);
178
177
  import(
179
178
  /* @vite-ignore */
180
179
  /* webpackIgnore: true */
@@ -184,16 +183,19 @@ const useMermaid = (props) => {
184
183
  configMermaid();
185
184
  });
186
185
  } else {
187
- const mermaidScript = dom.createHTMLElement("script", {
188
- ...(_c = editorExtensionsAttrs.mermaid) == null ? void 0 : _c.js,
189
- src: jsSrc,
190
- id: `${config.prefix}-mermaid`,
191
- onload() {
192
- mermaidRef.value = window.mermaid;
193
- configMermaid();
194
- }
195
- });
196
- dom.appendHandler(mermaidScript, "mermaid");
186
+ dom.appendHandler(
187
+ "script",
188
+ {
189
+ ...(_c = editorExtensionsAttrs.mermaid) == null ? void 0 : _c.js,
190
+ src: jsSrc,
191
+ id: `${config.prefix}-mermaid`,
192
+ onload() {
193
+ mermaidRef.value = window.mermaid;
194
+ configMermaid();
195
+ }
196
+ },
197
+ "mermaid"
198
+ );
197
199
  }
198
200
  });
199
201
  const replaceMermaid = () => {
@@ -251,20 +253,22 @@ const useKatex = (props) => {
251
253
  return;
252
254
  }
253
255
  const { editorExtensions } = config.configOption;
254
- const katexScript = dom.createHTMLElement("script", {
255
- src: editorExtensions.katex.js,
256
- id: `${config.prefix}-katex`,
257
- onload() {
258
- katex.value = window.katex;
259
- }
260
- });
261
- const katexLink = dom.createHTMLElement("link", {
256
+ dom.appendHandler(
257
+ "script",
258
+ {
259
+ src: editorExtensions.katex.js,
260
+ id: `${config.prefix}-katex`,
261
+ onload() {
262
+ katex.value = window.katex;
263
+ }
264
+ },
265
+ "katex"
266
+ );
267
+ dom.appendHandler("link", {
262
268
  rel: "stylesheet",
263
269
  href: editorExtensions.katex.css,
264
270
  id: `${config.prefix}-katexCss`
265
271
  });
266
- dom.appendHandler(katexScript, "katex");
267
- dom.appendHandler(katexLink);
268
272
  });
269
273
  return katex;
270
274
  };
@@ -671,11 +675,6 @@ const useMarkdownIt = (props, previewOnly) => {
671
675
  editorId
672
676
  });
673
677
  const plugins = [
674
- {
675
- type: "katex",
676
- plugin: KatexPlugin$1,
677
- options: { katexRef }
678
- },
679
678
  {
680
679
  type: "image",
681
680
  plugin: ImageFiguresPlugin,
@@ -730,6 +729,13 @@ const useMarkdownIt = (props, previewOnly) => {
730
729
  }
731
730
  }
732
731
  ];
732
+ if (!props.noKatex) {
733
+ plugins.push({
734
+ type: "katex",
735
+ plugin: KatexPlugin$1,
736
+ options: { katexRef }
737
+ });
738
+ }
733
739
  if (!props.noMermaid) {
734
740
  plugins.push({
735
741
  type: "mermaid",
@@ -1107,20 +1113,18 @@ const useExpansionPreview = (props) => {
1107
1113
  return;
1108
1114
  }
1109
1115
  if (iconfontType === "svg") {
1110
- const iconfontScript = dom.createHTMLElement("script", {
1116
+ dom.appendHandler("script", {
1111
1117
  ...editorExtensionsAttrs.iconfont,
1112
1118
  src: editorExtensions.iconfont,
1113
1119
  id: `${config.prefix}-icon`
1114
1120
  });
1115
- dom.appendHandler(iconfontScript);
1116
1121
  } else {
1117
- const iconfontLink = dom.createHTMLElement("link", {
1122
+ dom.appendHandler("link", {
1118
1123
  ...editorExtensionsAttrs.iconfontClass,
1119
1124
  rel: "stylesheet",
1120
1125
  href: editorExtensions.iconfontClass,
1121
1126
  id: `${config.prefix}-icon-class`
1122
1127
  });
1123
- dom.appendHandler(iconfontLink);
1124
1128
  }
1125
1129
  });
1126
1130
  };
@@ -1133,37 +1137,33 @@ const useExpansion = (props) => {
1133
1137
  vue.onMounted(() => {
1134
1138
  if (!noCropperScript) {
1135
1139
  const { js = {}, css = {} } = editorExtensionsAttrs.cropper || {};
1136
- const cropperLink = dom.createHTMLElement("link", {
1140
+ dom.appendHandler("link", {
1137
1141
  ...css,
1138
1142
  rel: "stylesheet",
1139
1143
  href: editorExtensions.cropper.css,
1140
1144
  id: `${config.prefix}-cropperCss`
1141
1145
  });
1142
- const cropperScript = dom.createHTMLElement("script", {
1146
+ dom.appendHandler("script", {
1143
1147
  ...js,
1144
1148
  src: editorExtensions.cropper.js,
1145
1149
  id: `${config.prefix}-cropper`
1146
1150
  });
1147
- dom.appendHandler(cropperLink);
1148
- dom.appendHandler(cropperScript);
1149
1151
  }
1150
1152
  if (!noPrettierScript) {
1151
1153
  const { standaloneJs = {} } = editorExtensionsAttrs.prettier || {};
1152
- const prettierScript = dom.createHTMLElement("script", {
1154
+ dom.appendHandler("script", {
1153
1155
  ...standaloneJs,
1154
1156
  src: editorExtensions.prettier.standaloneJs,
1155
1157
  id: `${config.prefix}-prettier`
1156
1158
  });
1157
- dom.appendHandler(prettierScript);
1158
1159
  }
1159
1160
  if (!noParserMarkdownScript) {
1160
1161
  const { parserMarkdownJs = {} } = editorExtensionsAttrs.prettier || {};
1161
- const prettierMDScript = dom.createHTMLElement("script", {
1162
+ dom.appendHandler("script", {
1162
1163
  ...parserMarkdownJs,
1163
1164
  src: editorExtensions.prettier.parserMarkdownJs,
1164
1165
  id: `${config.prefix}-prettierMD`
1165
1166
  });
1166
- dom.appendHandler(prettierMDScript);
1167
1167
  }
1168
1168
  });
1169
1169
  useExpansionPreview(props);
@@ -9,7 +9,7 @@ import { p as prefix, f as configOption, b as allToolbar, M as MinInputBoxWidth,
9
9
  import { draggingScroll, linkTo, debounce, createSmoothScroll, throttle } from "@vavt/util";
10
10
  import { a as Dropdown, D as DropdownToolbar } from "./chunks/index2.mjs";
11
11
  import { b as bus, h as CHANGE_FULL_SCREEN, E as ERROR_CATCHER, U as UPLOAD_IMAGE, j as OPEN_MODALS, g as REPLACE, a as CHANGE_CATALOG_VISIBLE, O as ON_SAVE, k as CTRL_SHIFT_Z, l as CTRL_Z, i as EVENT_LISTENER } from "./chunks/event-name.mjs";
12
- import { c as createHTMLElement, a as appendHandler } from "./chunks/dom.mjs";
12
+ import { a as appendHandler } from "./chunks/dom.mjs";
13
13
  import { M as MdModal, I as Icon } from "./chunks/index3.mjs";
14
14
  import { d as base642File } from "./chunks/index4.mjs";
15
15
  import { EditorView as EditorView$1 } from "codemirror";
@@ -127,13 +127,16 @@ const useSreenfull = (props2) => {
127
127
  var _a;
128
128
  onScreenfullEvent();
129
129
  if (!screenfull) {
130
- const screenScript = createHTMLElement("script", {
131
- ...(_a = editorExtensionsAttrs.screenfull) == null ? void 0 : _a.js,
132
- src: editorExtensions.screenfull.js,
133
- id: `${prefix}-screenfull`,
134
- onload: screenfullLoad
135
- });
136
- appendHandler(screenScript, "screenfull");
130
+ appendHandler(
131
+ "script",
132
+ {
133
+ ...(_a = editorExtensionsAttrs.screenfull) == null ? void 0 : _a.js,
134
+ src: editorExtensions.screenfull.js,
135
+ id: `${prefix}-screenfull`,
136
+ onload: screenfullLoad
137
+ },
138
+ "screenfull"
139
+ );
137
140
  }
138
141
  });
139
142
  onMounted(() => {
@@ -2852,11 +2855,17 @@ const useResize = (props2, contentRef, resizeRef) => {
2852
2855
  const resizeMouseup = () => {
2853
2856
  document.removeEventListener("mousemove", resizeMousemove);
2854
2857
  };
2855
- onMounted(() => {
2856
- var _a;
2857
- (_a = resizeRef.value) == null ? void 0 : _a.addEventListener("mousedown", resizeMousedown);
2858
- document.addEventListener("mouseup", resizeMouseup);
2859
- });
2858
+ watch(
2859
+ [resizeRef],
2860
+ () => {
2861
+ var _a, _b;
2862
+ (_a = resizeRef.value) == null ? void 0 : _a.addEventListener("mousedown", resizeMousedown);
2863
+ (_b = resizeRef.value) == null ? void 0 : _b.addEventListener("mouseup", resizeMouseup);
2864
+ },
2865
+ {
2866
+ immediate: true
2867
+ }
2868
+ );
2860
2869
  onBeforeUnmount(() => {
2861
2870
  var _a, _b;
2862
2871
  (_a = resizeRef.value) == null ? void 0 : _a.removeEventListener("mousedown", resizeMousedown);
@@ -1,4 +1,3 @@
1
- import { debounce } from "@vavt/util";
2
1
  const keyMove = (trigger, moveHandler) => {
3
2
  const triggerMouseDown = (mdown) => {
4
3
  const parent = trigger.parentElement || document.body;
@@ -32,31 +31,28 @@ const keyMove = (trigger, moveHandler) => {
32
31
  trigger.removeEventListener("mousedown", triggerMouseDown);
33
32
  };
34
33
  };
35
- const appendHandler = (ele, checkKey = "") => {
36
- const insertedEle = document.getElementById(ele.id);
37
- const onload_ = ele.onload;
38
- ele.onload = null;
39
- const onload = function(e) {
40
- if (typeof onload_ === "function") {
41
- onload_.bind(this)(e);
42
- }
43
- ele.removeEventListener("load", onload);
44
- };
34
+ const appendHandler = (tagName, attributes, checkKey = "") => {
35
+ var _a;
36
+ const insertedEle = document.getElementById(attributes.id);
45
37
  if (!insertedEle) {
46
- ele.addEventListener("load", onload);
38
+ const attrsCopy = { ...attributes };
39
+ attrsCopy.onload = null;
40
+ const ele = createHTMLElement(tagName, attrsCopy);
41
+ onload && ele.addEventListener("load", onload);
47
42
  document.head.appendChild(ele);
48
43
  } else if (checkKey !== "") {
49
- insertedEle.addEventListener("load", onload);
50
44
  if (Reflect.get(window, checkKey)) {
51
- insertedEle.dispatchEvent(new Event("load"));
45
+ (_a = attributes.onload) == null ? void 0 : _a.call(insertedEle, new Event("load"));
46
+ } else {
47
+ attributes.onload && insertedEle.addEventListener("load", attributes.onload);
52
48
  }
53
49
  }
54
50
  };
55
- const updateHandler = debounce((ele) => {
56
- const insertedEle = document.getElementById(ele.id);
51
+ const updateHandler = (tagName, attributes) => {
52
+ const insertedEle = document.getElementById(attributes.id);
57
53
  insertedEle == null ? void 0 : insertedEle.remove();
58
- appendHandler(ele);
59
- }, 10);
54
+ appendHandler(tagName, attributes);
55
+ };
60
56
  const createHTMLElement = (tagName, attributes) => {
61
57
  const element = document.createElement(tagName);
62
58
  Object.keys(attributes).forEach((key) => {
@@ -68,7 +64,6 @@ const createHTMLElement = (tagName, attributes) => {
68
64
  };
69
65
  export {
70
66
  appendHandler as a,
71
- createHTMLElement as c,
72
67
  keyMove as k,
73
68
  updateHandler as u
74
69
  };
@@ -1,7 +1,7 @@
1
1
  import { inject, watch, toRef, onMounted, nextTick, shallowRef, ref, computed, defineComponent, createVNode, Fragment, reactive, provide, onBeforeUnmount } from "vue";
2
2
  import { f as configOption, p as prefix, g as codeCss, s as staticTextDefault, b as allToolbar, d as allFooter } from "./config.mjs";
3
3
  import { b as bus, C as CATALOG_CHANGED, P as PUSH_CATALOG, R as RERENDER, B as BUILD_FINISHED, O as ON_SAVE, E as ERROR_CATCHER, U as UPLOAD_IMAGE, a as CHANGE_CATALOG_VISIBLE, c as PAGE_FULL_SCREEN_CHANGED, F as FULL_SCREEN_CHANGED, d as PREVIEW_CHANGED, e as PREVIEW_ONLY_CHANGED, H as HTML_PREVIEW_CHANGED, f as CATALOG_VISIBLE_CHANGED, g as REPLACE, h as CHANGE_FULL_SCREEN, i as EVENT_LISTENER } from "./event-name.mjs";
4
- import { c as createHTMLElement, a as appendHandler, u as updateHandler } from "./dom.mjs";
4
+ import { a as appendHandler, u as updateHandler } from "./dom.mjs";
5
5
  import { debounce, uuid, deepMerge, deepClone } from "@vavt/util";
6
6
  import mediumZoom from "medium-zoom";
7
7
  import copy from "copy-to-clipboard";
@@ -102,31 +102,31 @@ const useHighlight = (props) => {
102
102
  if (props.noHighlight || hljsRef.value) {
103
103
  return;
104
104
  }
105
- const highlightScript = createHTMLElement("script", {
106
- ...highlight.value.js,
107
- id: `${prefix}-hljs`,
108
- onload() {
109
- hljsRef.value = window.hljs;
110
- }
111
- });
112
- const highlightLink = createHTMLElement("link", {
105
+ appendHandler("link", {
113
106
  ...highlight.value.css,
114
107
  rel: "stylesheet",
115
108
  id: `${prefix}-hlCss`
116
109
  });
117
- appendHandler(highlightLink);
118
- appendHandler(highlightScript, "hljs");
110
+ appendHandler(
111
+ "script",
112
+ {
113
+ ...highlight.value.js,
114
+ id: `${prefix}-hljs`,
115
+ onload() {
116
+ hljsRef.value = window.hljs;
117
+ }
118
+ },
119
+ "hljs"
120
+ );
119
121
  });
120
122
  watch(
121
123
  () => highlight.value.css,
122
124
  () => {
123
- updateHandler(
124
- createHTMLElement("link", {
125
- ...highlight.value.css,
126
- rel: "stylesheet",
127
- id: `${prefix}-hlCss`
128
- })
129
- );
125
+ updateHandler("link", {
126
+ ...highlight.value.css,
127
+ rel: "stylesheet",
128
+ id: `${prefix}-hlCss`
129
+ });
130
130
  }
131
131
  );
132
132
  return hljsRef;
@@ -167,13 +167,12 @@ const useMermaid = (props) => {
167
167
  }
168
168
  const jsSrc = editorExtensions.mermaid.js;
169
169
  if (/\.mjs/.test(jsSrc)) {
170
- const modulePreload = createHTMLElement("link", {
170
+ appendHandler("link", {
171
171
  ...(_b = editorExtensionsAttrs.mermaid) == null ? void 0 : _b.js,
172
172
  rel: "modulepreload",
173
173
  href: jsSrc,
174
174
  id: `${prefix}-mermaid-m`
175
175
  });
176
- appendHandler(modulePreload);
177
176
  import(
178
177
  /* @vite-ignore */
179
178
  /* webpackIgnore: true */
@@ -183,16 +182,19 @@ const useMermaid = (props) => {
183
182
  configMermaid();
184
183
  });
185
184
  } else {
186
- const mermaidScript = createHTMLElement("script", {
187
- ...(_c = editorExtensionsAttrs.mermaid) == null ? void 0 : _c.js,
188
- src: jsSrc,
189
- id: `${prefix}-mermaid`,
190
- onload() {
191
- mermaidRef.value = window.mermaid;
192
- configMermaid();
193
- }
194
- });
195
- appendHandler(mermaidScript, "mermaid");
185
+ appendHandler(
186
+ "script",
187
+ {
188
+ ...(_c = editorExtensionsAttrs.mermaid) == null ? void 0 : _c.js,
189
+ src: jsSrc,
190
+ id: `${prefix}-mermaid`,
191
+ onload() {
192
+ mermaidRef.value = window.mermaid;
193
+ configMermaid();
194
+ }
195
+ },
196
+ "mermaid"
197
+ );
196
198
  }
197
199
  });
198
200
  const replaceMermaid = () => {
@@ -250,20 +252,22 @@ const useKatex = (props) => {
250
252
  return;
251
253
  }
252
254
  const { editorExtensions } = configOption;
253
- const katexScript = createHTMLElement("script", {
254
- src: editorExtensions.katex.js,
255
- id: `${prefix}-katex`,
256
- onload() {
257
- katex.value = window.katex;
258
- }
259
- });
260
- const katexLink = createHTMLElement("link", {
255
+ appendHandler(
256
+ "script",
257
+ {
258
+ src: editorExtensions.katex.js,
259
+ id: `${prefix}-katex`,
260
+ onload() {
261
+ katex.value = window.katex;
262
+ }
263
+ },
264
+ "katex"
265
+ );
266
+ appendHandler("link", {
261
267
  rel: "stylesheet",
262
268
  href: editorExtensions.katex.css,
263
269
  id: `${prefix}-katexCss`
264
270
  });
265
- appendHandler(katexScript, "katex");
266
- appendHandler(katexLink);
267
271
  });
268
272
  return katex;
269
273
  };
@@ -670,11 +674,6 @@ const useMarkdownIt = (props, previewOnly) => {
670
674
  editorId
671
675
  });
672
676
  const plugins = [
673
- {
674
- type: "katex",
675
- plugin: KatexPlugin$1,
676
- options: { katexRef }
677
- },
678
677
  {
679
678
  type: "image",
680
679
  plugin: ImageFiguresPlugin,
@@ -729,6 +728,13 @@ const useMarkdownIt = (props, previewOnly) => {
729
728
  }
730
729
  }
731
730
  ];
731
+ if (!props.noKatex) {
732
+ plugins.push({
733
+ type: "katex",
734
+ plugin: KatexPlugin$1,
735
+ options: { katexRef }
736
+ });
737
+ }
732
738
  if (!props.noMermaid) {
733
739
  plugins.push({
734
740
  type: "mermaid",
@@ -1106,20 +1112,18 @@ const useExpansionPreview = (props) => {
1106
1112
  return;
1107
1113
  }
1108
1114
  if (iconfontType === "svg") {
1109
- const iconfontScript = createHTMLElement("script", {
1115
+ appendHandler("script", {
1110
1116
  ...editorExtensionsAttrs.iconfont,
1111
1117
  src: editorExtensions.iconfont,
1112
1118
  id: `${prefix}-icon`
1113
1119
  });
1114
- appendHandler(iconfontScript);
1115
1120
  } else {
1116
- const iconfontLink = createHTMLElement("link", {
1121
+ appendHandler("link", {
1117
1122
  ...editorExtensionsAttrs.iconfontClass,
1118
1123
  rel: "stylesheet",
1119
1124
  href: editorExtensions.iconfontClass,
1120
1125
  id: `${prefix}-icon-class`
1121
1126
  });
1122
- appendHandler(iconfontLink);
1123
1127
  }
1124
1128
  });
1125
1129
  };
@@ -1132,37 +1136,33 @@ const useExpansion = (props) => {
1132
1136
  onMounted(() => {
1133
1137
  if (!noCropperScript) {
1134
1138
  const { js = {}, css = {} } = editorExtensionsAttrs.cropper || {};
1135
- const cropperLink = createHTMLElement("link", {
1139
+ appendHandler("link", {
1136
1140
  ...css,
1137
1141
  rel: "stylesheet",
1138
1142
  href: editorExtensions.cropper.css,
1139
1143
  id: `${prefix}-cropperCss`
1140
1144
  });
1141
- const cropperScript = createHTMLElement("script", {
1145
+ appendHandler("script", {
1142
1146
  ...js,
1143
1147
  src: editorExtensions.cropper.js,
1144
1148
  id: `${prefix}-cropper`
1145
1149
  });
1146
- appendHandler(cropperLink);
1147
- appendHandler(cropperScript);
1148
1150
  }
1149
1151
  if (!noPrettierScript) {
1150
1152
  const { standaloneJs = {} } = editorExtensionsAttrs.prettier || {};
1151
- const prettierScript = createHTMLElement("script", {
1153
+ appendHandler("script", {
1152
1154
  ...standaloneJs,
1153
1155
  src: editorExtensions.prettier.standaloneJs,
1154
1156
  id: `${prefix}-prettier`
1155
1157
  });
1156
- appendHandler(prettierScript);
1157
1158
  }
1158
1159
  if (!noParserMarkdownScript) {
1159
1160
  const { parserMarkdownJs = {} } = editorExtensionsAttrs.prettier || {};
1160
- const prettierMDScript = createHTMLElement("script", {
1161
+ appendHandler("script", {
1161
1162
  ...parserMarkdownJs,
1162
1163
  src: editorExtensions.prettier.parserMarkdownJs,
1163
1164
  id: `${prefix}-prettierMD`
1164
1165
  });
1165
- appendHandler(prettierMDScript);
1166
1166
  }
1167
1167
  });
1168
1168
  useExpansionPreview(props);
@@ -11,7 +11,7 @@ export declare const keyMove: (trigger: HTMLElement, moveHandler?: (left: number
11
11
  * @param ele
12
12
  * @param checkKey 全局名称
13
13
  */
14
- export declare const appendHandler: (ele: HTMLElement, checkKey?: string) => void;
14
+ export declare const appendHandler: <K extends keyof HTMLElementTagNameMap>(tagName: K, attributes: Partial<HTMLElementTagNameMap[K]>, checkKey?: string) => void;
15
15
  /**
16
16
  * 更新插入的元素属性
17
17
  *
@@ -19,7 +19,7 @@ export declare const appendHandler: (ele: HTMLElement, checkKey?: string) => voi
19
19
  * @param attr 属性名
20
20
  * @param value 属性值
21
21
  */
22
- export declare const updateHandler: (...params: HTMLElement[]) => Promise<unknown>;
22
+ export declare const updateHandler: <K extends keyof HTMLElementTagNameMap>(tagName: K, attributes: Partial<HTMLElementTagNameMap[K]>) => void;
23
23
  /**
24
24
  * 创建带属性的原始标签
25
25
  *