md-editor-v3 4.12.0-beta.2 → 4.12.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 +12 -0
- package/lib/cjs/DropdownToolbar.cjs +3 -1
- package/lib/cjs/MdCatalog.cjs +270 -1
- package/lib/cjs/MdEditor.cjs +3101 -58
- package/lib/cjs/MdModal.cjs +3 -1
- package/lib/cjs/MdPreview.cjs +3 -1
- package/lib/cjs/ModalToolbar.cjs +124 -1
- package/lib/cjs/NormalToolbar.cjs +61 -1
- package/lib/cjs/chunks/config.cjs +290 -1
- package/lib/cjs/chunks/dom.cjs +64 -1
- package/lib/cjs/chunks/index.cjs +1863 -8
- package/lib/cjs/chunks/index2.cjs +198 -1
- package/lib/cjs/chunks/index3.cjs +270 -1
- package/lib/cjs/chunks/index4.cjs +141 -2
- package/lib/cjs/chunks/vue-tsx.cjs +10 -1
- package/lib/cjs/config.cjs +12 -1
- package/lib/cjs/index.cjs +25 -1
- package/lib/es/DropdownToolbar.mjs +2 -2
- package/lib/es/MdCatalog.mjs +164 -114
- package/lib/es/MdEditor.mjs +2297 -1654
- package/lib/es/MdModal.mjs +2 -2
- package/lib/es/MdPreview.mjs +2 -2
- package/lib/es/ModalToolbar.mjs +55 -38
- package/lib/es/NormalToolbar.mjs +26 -18
- package/lib/es/chunks/config.mjs +73 -54
- package/lib/es/chunks/dom.mjs +57 -24
- package/lib/es/chunks/index.mjs +1099 -609
- package/lib/es/chunks/index2.mjs +126 -78
- package/lib/es/chunks/index3.mjs +185 -111
- package/lib/es/chunks/index4.mjs +124 -72
- package/lib/es/chunks/vue-tsx.mjs +8 -8
- package/lib/es/config.mjs +11 -10
- package/lib/es/index.mjs +23 -23
- package/lib/preview.css +200 -1
- package/lib/style.css +592 -1
- package/lib/types/MdEditor/components/Modal/Modal.d.ts +1 -1
- package/lib/types/MdEditor/components/Modal/index.d.ts +3 -3
- package/lib/types/MdEditor/layouts/Content/index.d.ts +9 -0
- package/lib/types/MdEditor/layouts/Content/props.d.ts +4 -0
- package/lib/types/MdEditor/static/event-name.d.ts +1 -0
- package/lib/types/MdEditor/type.d.ts +10 -1
- package/lib/umd/index.js +75625 -114
- package/package.json +1 -1
package/lib/es/chunks/index.mjs
CHANGED
|
@@ -1,314 +1,614 @@
|
|
|
1
|
-
import { inject
|
|
2
|
-
import { e as
|
|
3
|
-
import { a as
|
|
4
|
-
import { a as
|
|
5
|
-
import
|
|
6
|
-
import { debounce
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import { LRUCache
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
I(
|
|
21
|
-
[a, te(e.setting, "preview")],
|
|
1
|
+
import { inject, watch, toRef, onMounted, nextTick, shallowRef, ref, computed, defineComponent, createVNode, Fragment, reactive, provide, onBeforeUnmount } from "vue";
|
|
2
|
+
import { e as configOption, p as prefix, m as mermaidUrl, k as katexUrl, f as codeCss, h as highlightUrl, s as staticTextDefault, a as iconfontSvgUrl, i as iconfontClassUrl, g as prettierUrl, j as cropperUrl, b as allToolbar, d as allFooter } from "./config.mjs";
|
|
3
|
+
import { a as generateCodeRowNumber, b as bus, P as PUSH_CATALOG, C as CATALOG_CHANGED, R as RERENDER, B as BUILD_FINISHED, O as ON_SAVE, E as ERROR_CATCHER, U as UPLOAD_IMAGE, c as CHANGE_CATALOG_VISIBLE, d as PAGE_FULL_SCREEN_CHANGED, F as FULL_SCREEN_CHANGED, e as PREVIEW_CHANGED, H as HTML_PREVIEW_CHANGED, f as CATALOG_VISIBLE_CHANGED, h as REPLACE, i as CHANGE_FULL_SCREEN, j as EVENT_LISTENER, k as getNextId } from "./index4.mjs";
|
|
4
|
+
import { a as appendHandler, u as updateHandler } from "./dom.mjs";
|
|
5
|
+
import mediumZoom from "medium-zoom";
|
|
6
|
+
import { debounce, uuid } from "@vavt/util";
|
|
7
|
+
import copy from "copy-to-clipboard";
|
|
8
|
+
import mdit from "markdown-it";
|
|
9
|
+
import ImageFiguresPlugin from "markdown-it-image-figures";
|
|
10
|
+
import TaskListPlugin from "markdown-it-task-lists";
|
|
11
|
+
import XSSPlugin from "markdown-it-xss";
|
|
12
|
+
import { LRUCache } from "lru-cache";
|
|
13
|
+
const userZoom = (props, html) => {
|
|
14
|
+
const editorId = inject("editorId");
|
|
15
|
+
const { noImgZoomIn } = props;
|
|
16
|
+
let zoomHander = () => {
|
|
17
|
+
};
|
|
18
|
+
watch(
|
|
19
|
+
[html, toRef(props.setting, "preview")],
|
|
22
20
|
() => {
|
|
23
|
-
!
|
|
21
|
+
if (!noImgZoomIn && props.setting.preview) {
|
|
22
|
+
zoomHander();
|
|
23
|
+
}
|
|
24
24
|
},
|
|
25
25
|
{
|
|
26
|
-
immediate:
|
|
26
|
+
immediate: true
|
|
27
27
|
}
|
|
28
28
|
);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
29
|
+
onMounted(() => {
|
|
30
|
+
zoomHander = debounce(() => {
|
|
31
|
+
const imgs = document.querySelectorAll(`#${editorId}-preview img`);
|
|
32
|
+
if (imgs.length === 0) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
mediumZoom(imgs, {
|
|
36
|
+
background: "#00000073"
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
const StrIcon = (name, customIcon) => {
|
|
42
|
+
if (typeof customIcon[name] === "string") {
|
|
43
|
+
return customIcon[name];
|
|
44
|
+
}
|
|
45
|
+
const defaultStr = `<i class="${prefix}-iconfont ${prefix}-icon-${name}"></i>`;
|
|
46
|
+
switch (configOption.iconfontType) {
|
|
47
|
+
case "svg": {
|
|
48
|
+
return `<svg class="${prefix}-icon" aria-hidden="true"><use xlink:href="#${prefix}-icon-${name}"></use></svg>`;
|
|
49
|
+
}
|
|
50
|
+
default: {
|
|
51
|
+
return defaultStr;
|
|
52
|
+
}
|
|
38
53
|
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
54
|
+
};
|
|
55
|
+
const useCopyCode = (props, html, key) => {
|
|
56
|
+
const editorId = inject("editorId");
|
|
57
|
+
const ult = inject("usedLanguageText");
|
|
58
|
+
const customIcon = inject("customIcon");
|
|
59
|
+
const initCopyEntry = () => {
|
|
60
|
+
document.querySelectorAll(`#${editorId}-preview pre`).forEach((pre) => {
|
|
61
|
+
var _a, _b;
|
|
62
|
+
let clearTimer = -1;
|
|
63
|
+
(_a = pre.querySelector(".copy-button")) == null ? void 0 : _a.remove();
|
|
64
|
+
const copyBtnText = ((_b = ult.value.copyCode) == null ? void 0 : _b.text) || "复制代码";
|
|
65
|
+
const copyButton = document.createElement("span");
|
|
66
|
+
copyButton.setAttribute("class", "copy-button");
|
|
67
|
+
copyButton.dataset.tips = copyBtnText;
|
|
68
|
+
copyButton.innerHTML = StrIcon("copy", customIcon.value);
|
|
69
|
+
copyButton.addEventListener("click", () => {
|
|
70
|
+
var _a2, _b2;
|
|
71
|
+
clearTimeout(clearTimer);
|
|
72
|
+
const codeText = pre.querySelector("code").innerText;
|
|
73
|
+
const success = copy(props.formatCopiedText(codeText));
|
|
74
|
+
const succssTip = ((_a2 = ult.value.copyCode) == null ? void 0 : _a2.successTips) || "已复制!";
|
|
75
|
+
const failTip = ((_b2 = ult.value.copyCode) == null ? void 0 : _b2.failTips) || "已复制!";
|
|
76
|
+
copyButton.dataset.tips = success ? succssTip : failTip;
|
|
77
|
+
clearTimer = window.setTimeout(() => {
|
|
78
|
+
copyButton.dataset.tips = copyBtnText;
|
|
52
79
|
}, 1500);
|
|
53
|
-
})
|
|
80
|
+
});
|
|
81
|
+
pre.appendChild(copyButton);
|
|
54
82
|
});
|
|
55
|
-
}, u = () => {
|
|
56
|
-
j(r);
|
|
57
|
-
}, c = (s) => {
|
|
58
|
-
s && j(r);
|
|
59
83
|
};
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const r = document.createElement("script");
|
|
67
|
-
r.src = t.value.js, r.onload = () => {
|
|
68
|
-
n.value = window.hljs;
|
|
69
|
-
}, r.id = `${h}-hljs`, T(r, "hljs");
|
|
70
|
-
const u = document.createElement("link");
|
|
71
|
-
u.rel = "stylesheet", u.href = t.value.css, u.id = `${h}-hlCss`, T(u);
|
|
84
|
+
const htmlChanged = () => {
|
|
85
|
+
nextTick(initCopyEntry);
|
|
86
|
+
};
|
|
87
|
+
const settingPreviewChanged = (nVal) => {
|
|
88
|
+
if (nVal) {
|
|
89
|
+
nextTick(initCopyEntry);
|
|
72
90
|
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
91
|
+
};
|
|
92
|
+
watch([html, key], htmlChanged);
|
|
93
|
+
watch(() => props.setting.preview, settingPreviewChanged);
|
|
94
|
+
watch(() => props.setting.htmlPreview, settingPreviewChanged);
|
|
95
|
+
watch(() => ult.value, initCopyEntry);
|
|
96
|
+
onMounted(initCopyEntry);
|
|
97
|
+
};
|
|
98
|
+
const useHighlight = (props) => {
|
|
99
|
+
var _a;
|
|
100
|
+
const hljsConf = (_a = configOption.editorExtensions) == null ? void 0 : _a.highlight;
|
|
101
|
+
const hljs = hljsConf == null ? void 0 : hljsConf.instance;
|
|
102
|
+
const highlightUrl2 = inject("highlight");
|
|
103
|
+
const hljsRef = shallowRef(hljs);
|
|
104
|
+
onMounted(() => {
|
|
105
|
+
if (props.noHighlight) {
|
|
106
|
+
return;
|
|
77
107
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
108
|
+
if (!hljsRef.value) {
|
|
109
|
+
const highlightScript = document.createElement("script");
|
|
110
|
+
highlightScript.src = highlightUrl2.value.js;
|
|
111
|
+
highlightScript.onload = () => {
|
|
112
|
+
hljsRef.value = window.hljs;
|
|
113
|
+
};
|
|
114
|
+
highlightScript.id = `${prefix}-hljs`;
|
|
115
|
+
appendHandler(highlightScript, "hljs");
|
|
116
|
+
const highlightLink = document.createElement("link");
|
|
117
|
+
highlightLink.rel = "stylesheet";
|
|
118
|
+
highlightLink.href = highlightUrl2.value.css;
|
|
119
|
+
highlightLink.id = `${prefix}-hlCss`;
|
|
120
|
+
appendHandler(highlightLink);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
watch(
|
|
124
|
+
() => highlightUrl2.value.css,
|
|
125
|
+
(url) => {
|
|
126
|
+
updateHandler(`${prefix}-hlCss`, "href", url);
|
|
127
|
+
}
|
|
128
|
+
);
|
|
129
|
+
return hljsRef;
|
|
130
|
+
};
|
|
131
|
+
const useMermaid = (props) => {
|
|
132
|
+
const theme = inject("theme");
|
|
133
|
+
const { editorExtensions, mermaidConfig } = configOption;
|
|
134
|
+
const mermaidConf = editorExtensions == null ? void 0 : editorExtensions.mermaid;
|
|
135
|
+
const mermaidRef = shallowRef(mermaidConf == null ? void 0 : mermaidConf.instance);
|
|
136
|
+
const reRenderRef = shallowRef(-1);
|
|
137
|
+
const mermaidCache = new LRUCache({
|
|
81
138
|
max: 1e3,
|
|
82
139
|
// 缓存10分钟
|
|
83
140
|
ttl: 6e5
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
141
|
+
});
|
|
142
|
+
const configMermaid = () => {
|
|
143
|
+
const mermaid = mermaidRef.value;
|
|
144
|
+
if (!props.noMermaid && mermaid) {
|
|
145
|
+
mermaid.initialize(
|
|
146
|
+
mermaidConfig({
|
|
147
|
+
startOnLoad: false,
|
|
148
|
+
theme: theme.value === "dark" ? "dark" : "default"
|
|
149
|
+
})
|
|
150
|
+
);
|
|
151
|
+
reRenderRef.value = reRenderRef.value + 1;
|
|
152
|
+
}
|
|
92
153
|
};
|
|
93
|
-
|
|
94
|
-
() =>
|
|
154
|
+
watch(
|
|
155
|
+
() => theme.value,
|
|
95
156
|
() => {
|
|
96
|
-
|
|
157
|
+
mermaidCache.clear();
|
|
158
|
+
configMermaid();
|
|
159
|
+
}
|
|
160
|
+
);
|
|
161
|
+
onMounted(() => {
|
|
162
|
+
if (props.noMermaid) {
|
|
163
|
+
return;
|
|
97
164
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
if (/\.mjs/.test(o))
|
|
165
|
+
if (!(mermaidConf == null ? void 0 : mermaidConf.instance)) {
|
|
166
|
+
const jsSrc = (mermaidConf == null ? void 0 : mermaidConf.js) || mermaidUrl;
|
|
167
|
+
if (/\.mjs/.test(jsSrc)) {
|
|
102
168
|
import(
|
|
103
169
|
/* @vite-ignore */
|
|
104
170
|
/* webpackIgnore: true */
|
|
105
|
-
|
|
106
|
-
).then((
|
|
107
|
-
|
|
171
|
+
jsSrc
|
|
172
|
+
).then((module) => {
|
|
173
|
+
mermaidRef.value = module.default;
|
|
174
|
+
configMermaid();
|
|
108
175
|
});
|
|
109
|
-
else {
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
176
|
+
} else {
|
|
177
|
+
const mermaidScript = document.createElement("script");
|
|
178
|
+
mermaidScript.id = `${prefix}-mermaid`;
|
|
179
|
+
mermaidScript.src = jsSrc;
|
|
180
|
+
mermaidScript.onload = () => {
|
|
181
|
+
mermaidRef.value = window.mermaid;
|
|
182
|
+
configMermaid();
|
|
183
|
+
};
|
|
184
|
+
appendHandler(mermaidScript, "mermaid");
|
|
114
185
|
}
|
|
115
186
|
}
|
|
116
|
-
})
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
187
|
+
});
|
|
188
|
+
const replaceMermaid = () => {
|
|
189
|
+
nextTick(() => {
|
|
190
|
+
if (!props.noMermaid && mermaidRef.value) {
|
|
191
|
+
const mermaidSourceEles = document.querySelectorAll(
|
|
192
|
+
`div.${prefix}-mermaid`
|
|
193
|
+
);
|
|
194
|
+
const svgContainingElement = document.createElement("div");
|
|
195
|
+
svgContainingElement.style.width = document.body.offsetWidth + "px";
|
|
196
|
+
svgContainingElement.style.height = document.body.offsetHeight + "px";
|
|
197
|
+
svgContainingElement.style.position = "fixed";
|
|
198
|
+
svgContainingElement.style.zIndex = "-10000";
|
|
199
|
+
svgContainingElement.style.top = "-10000";
|
|
200
|
+
let count = mermaidSourceEles.length;
|
|
201
|
+
if (count > 0) {
|
|
202
|
+
document.body.appendChild(svgContainingElement);
|
|
203
|
+
}
|
|
204
|
+
mermaidSourceEles.forEach(async (item) => {
|
|
205
|
+
let mermaidHtml = mermaidCache.get(item.innerText);
|
|
206
|
+
if (!mermaidHtml) {
|
|
207
|
+
const idRand = uuid();
|
|
208
|
+
const render = mermaidRef.value.renderAsync || mermaidRef.value.render;
|
|
209
|
+
let svg = "";
|
|
129
210
|
try {
|
|
130
|
-
|
|
131
|
-
} catch {
|
|
211
|
+
svg = await render(idRand, item.innerText, svgContainingElement);
|
|
212
|
+
} catch (error) {
|
|
132
213
|
}
|
|
133
|
-
|
|
134
|
-
typeof
|
|
135
|
-
)
|
|
214
|
+
mermaidHtml = await props.sanitizeMermaid(
|
|
215
|
+
typeof svg === "string" ? svg : svg.svg
|
|
216
|
+
);
|
|
217
|
+
mermaidCache.set(item.innerText, mermaidHtml);
|
|
136
218
|
}
|
|
137
219
|
const p = document.createElement("p");
|
|
138
|
-
p.className = `${
|
|
220
|
+
p.className = `${prefix}-mermaid`;
|
|
221
|
+
p.setAttribute("data-processed", "");
|
|
222
|
+
p.innerHTML = mermaidHtml;
|
|
223
|
+
if (item.dataset.line !== void 0) {
|
|
224
|
+
p.dataset.line = item.dataset.line;
|
|
225
|
+
}
|
|
226
|
+
item.replaceWith(p);
|
|
227
|
+
if (--count === 0) {
|
|
228
|
+
svgContainingElement.remove();
|
|
229
|
+
}
|
|
139
230
|
});
|
|
140
231
|
}
|
|
141
232
|
});
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
const
|
|
153
|
-
|
|
233
|
+
};
|
|
234
|
+
return { mermaidRef, reRenderRef, replaceMermaid };
|
|
235
|
+
};
|
|
236
|
+
const useKatex = (props) => {
|
|
237
|
+
var _a;
|
|
238
|
+
const katexConf = (_a = configOption.editorExtensions) == null ? void 0 : _a.katex;
|
|
239
|
+
const katexIns = katexConf == null ? void 0 : katexConf.instance;
|
|
240
|
+
const katex = shallowRef(katexIns);
|
|
241
|
+
onMounted(() => {
|
|
242
|
+
if (!props.noKatex && !katex.value) {
|
|
243
|
+
const katexScript = document.createElement("script");
|
|
244
|
+
katexScript.src = (katexConf == null ? void 0 : katexConf.js) || katexUrl.js;
|
|
245
|
+
katexScript.onload = () => {
|
|
246
|
+
katex.value = window.katex;
|
|
247
|
+
};
|
|
248
|
+
katexScript.id = `${prefix}-katex`;
|
|
249
|
+
const katexLink = document.createElement("link");
|
|
250
|
+
katexLink.rel = "stylesheet";
|
|
251
|
+
katexLink.href = (katexConf == null ? void 0 : katexConf.css) || katexUrl.css;
|
|
252
|
+
katexLink.id = `${prefix}-katexCss`;
|
|
253
|
+
appendHandler(katexScript, "katex");
|
|
254
|
+
appendHandler(katexLink);
|
|
154
255
|
}
|
|
155
|
-
})
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
256
|
+
});
|
|
257
|
+
return katex;
|
|
258
|
+
};
|
|
259
|
+
const MermaidPlugin = (md, options) => {
|
|
260
|
+
const temp = md.renderer.rules.fence.bind(md.renderer.rules);
|
|
261
|
+
md.renderer.rules.fence = (tokens, idx, ops, env, slf) => {
|
|
262
|
+
const token = tokens[idx];
|
|
263
|
+
const code = token.content.trim();
|
|
264
|
+
if (token.info === "mermaid") {
|
|
265
|
+
let line;
|
|
266
|
+
if (tokens[idx].map && tokens[idx].level === 0) {
|
|
267
|
+
line = tokens[idx].map[0];
|
|
268
|
+
tokens[idx].attrSet("data-line", String(line));
|
|
269
|
+
}
|
|
270
|
+
return `<div class="${prefix}-mermaid" ${line !== void 0 ? "data-line=" + line : ""} data-mermaid-theme=${options.themeRef.value}>${code}</div>`;
|
|
163
271
|
}
|
|
164
|
-
return
|
|
272
|
+
return temp(tokens, idx, ops, env, slf);
|
|
165
273
|
};
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
274
|
+
};
|
|
275
|
+
const MermaidPlugin$1 = MermaidPlugin;
|
|
276
|
+
const isValidDelim = (state, pos) => {
|
|
277
|
+
let can_open = true, can_close = true;
|
|
278
|
+
const max = state.posMax;
|
|
279
|
+
const prevChar = pos > 0 ? state.src.charCodeAt(pos - 1) : -1;
|
|
280
|
+
const nextChar = pos + 1 <= max ? state.src.charCodeAt(pos + 1) : -1;
|
|
281
|
+
if (prevChar === 32 || prevChar === 9 || nextChar >= 48 && nextChar <= 57) {
|
|
282
|
+
can_close = false;
|
|
283
|
+
}
|
|
284
|
+
if (nextChar === 32 || nextChar === 9) {
|
|
285
|
+
can_open = false;
|
|
286
|
+
}
|
|
287
|
+
return {
|
|
288
|
+
can_open,
|
|
289
|
+
can_close
|
|
172
290
|
};
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
291
|
+
};
|
|
292
|
+
const math_inline = (state, silent) => {
|
|
293
|
+
let match, token, res, pos;
|
|
294
|
+
if (state.src[state.pos] !== "$") {
|
|
295
|
+
return false;
|
|
296
|
+
}
|
|
297
|
+
res = isValidDelim(state, state.pos);
|
|
298
|
+
if (!res.can_open) {
|
|
299
|
+
if (!silent) {
|
|
300
|
+
state.pending += "$";
|
|
301
|
+
}
|
|
302
|
+
state.pos += 1;
|
|
303
|
+
return true;
|
|
304
|
+
}
|
|
305
|
+
const start = state.pos + 1;
|
|
306
|
+
match = start;
|
|
307
|
+
while ((match = state.src.indexOf("$", match)) !== -1) {
|
|
308
|
+
pos = match - 1;
|
|
309
|
+
while (state.src[pos] === "\\") {
|
|
310
|
+
pos -= 1;
|
|
311
|
+
}
|
|
312
|
+
if ((match - pos) % 2 == 1) {
|
|
184
313
|
break;
|
|
185
|
-
|
|
314
|
+
}
|
|
315
|
+
match += 1;
|
|
316
|
+
}
|
|
317
|
+
if (match === -1) {
|
|
318
|
+
if (!silent) {
|
|
319
|
+
state.pending += "$";
|
|
320
|
+
}
|
|
321
|
+
state.pos = start;
|
|
322
|
+
return true;
|
|
323
|
+
}
|
|
324
|
+
if (match - start === 0) {
|
|
325
|
+
if (!silent) {
|
|
326
|
+
state.pending += "$$";
|
|
327
|
+
}
|
|
328
|
+
state.pos = start + 1;
|
|
329
|
+
return true;
|
|
330
|
+
}
|
|
331
|
+
res = isValidDelim(state, match);
|
|
332
|
+
if (!res.can_close) {
|
|
333
|
+
if (!silent) {
|
|
334
|
+
state.pending += "$";
|
|
335
|
+
}
|
|
336
|
+
state.pos = start;
|
|
337
|
+
return true;
|
|
338
|
+
}
|
|
339
|
+
if (!silent) {
|
|
340
|
+
token = state.push("math_inline", "math", 0);
|
|
341
|
+
token.markup = "$";
|
|
342
|
+
token.content = state.src.slice(start, match);
|
|
343
|
+
}
|
|
344
|
+
state.pos = match + 1;
|
|
345
|
+
return true;
|
|
346
|
+
};
|
|
347
|
+
const math_block = (state, start, end, silent) => {
|
|
348
|
+
let firstLine, lastLine, next, lastPos, found = false, pos = state.bMarks[start] + state.tShift[start], max = state.eMarks[start];
|
|
349
|
+
if (pos + 2 > max) {
|
|
350
|
+
return false;
|
|
351
|
+
}
|
|
352
|
+
if (state.src.slice(pos, pos + 2) !== "$$") {
|
|
353
|
+
return false;
|
|
186
354
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
if (
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
355
|
+
pos += 2;
|
|
356
|
+
firstLine = state.src.slice(pos, max);
|
|
357
|
+
if (silent) {
|
|
358
|
+
return true;
|
|
359
|
+
}
|
|
360
|
+
if (firstLine.trim().slice(-2) === "$$") {
|
|
361
|
+
firstLine = firstLine.trim().slice(0, -2);
|
|
362
|
+
found = true;
|
|
363
|
+
}
|
|
364
|
+
for (next = start; !found; ) {
|
|
365
|
+
next++;
|
|
366
|
+
if (next >= end) {
|
|
367
|
+
break;
|
|
368
|
+
}
|
|
369
|
+
pos = state.bMarks[next] + state.tShift[next];
|
|
370
|
+
max = state.eMarks[next];
|
|
371
|
+
if (pos < max && state.tShift[next] < state.blkIndent) {
|
|
372
|
+
break;
|
|
373
|
+
}
|
|
374
|
+
if (state.src.slice(pos, max).trim().slice(-2) === "$$") {
|
|
375
|
+
lastPos = state.src.slice(0, max).lastIndexOf("$$");
|
|
376
|
+
lastLine = state.src.slice(pos, lastPos);
|
|
377
|
+
found = true;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
state.line = next + 1;
|
|
381
|
+
const token = state.push("math_block", "math", 0);
|
|
382
|
+
token.block = true;
|
|
383
|
+
token.content = (firstLine && firstLine.trim() ? firstLine + "\n" : "") + state.getLines(start + 1, next, state.tShift[start], true) + (lastLine && lastLine.trim() ? lastLine : "");
|
|
384
|
+
token.map = [start, state.line];
|
|
385
|
+
token.markup = "$$";
|
|
386
|
+
return true;
|
|
387
|
+
};
|
|
388
|
+
const KatexPlugin = (md, options) => {
|
|
389
|
+
const katexInline = (str) => {
|
|
390
|
+
if (options.katexRef.value) {
|
|
391
|
+
const html = options.katexRef.value.renderToString(str, {
|
|
392
|
+
throwOnError: false
|
|
205
393
|
});
|
|
206
|
-
return `<span class="${
|
|
207
|
-
} else
|
|
208
|
-
return `<span class="${
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
394
|
+
return `<span class="${prefix}-katex-inline" data-processed>${html}</span>`;
|
|
395
|
+
} else {
|
|
396
|
+
return `<span class="${prefix}-katex-inline">${str}</span>`;
|
|
397
|
+
}
|
|
398
|
+
};
|
|
399
|
+
const katexBlock = (str, lineNum) => {
|
|
400
|
+
if (options.katexRef.value) {
|
|
401
|
+
const html = options.katexRef.value.renderToString(str, {
|
|
402
|
+
throwOnError: false,
|
|
403
|
+
displayMode: true
|
|
214
404
|
});
|
|
215
|
-
return `<p class="${
|
|
216
|
-
} else
|
|
217
|
-
return `<p class="${
|
|
405
|
+
return `<p class="${prefix}-katex-block" data-line=${lineNum} data-processed>${html}</p>`;
|
|
406
|
+
} else {
|
|
407
|
+
return `<p class="${prefix}-katex-block" data-line=${lineNum}>${str}</p>`;
|
|
408
|
+
}
|
|
218
409
|
};
|
|
219
|
-
|
|
410
|
+
md.inline.ruler.after("escape", "math_inline", math_inline);
|
|
411
|
+
md.block.ruler.after("blockquote", "math_block", math_block, {
|
|
220
412
|
alt: ["paragraph", "reference", "blockquote", "list"]
|
|
221
|
-
})
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
413
|
+
});
|
|
414
|
+
md.renderer.rules.math_inline = (tokens, idx) => {
|
|
415
|
+
return katexInline(tokens[idx].content);
|
|
416
|
+
};
|
|
417
|
+
md.renderer.rules.math_block = (tokens, idx) => {
|
|
418
|
+
return katexBlock(tokens[idx].content, tokens[idx].map[0]) + "\n";
|
|
419
|
+
};
|
|
420
|
+
};
|
|
421
|
+
const KatexPlugin$1 = KatexPlugin;
|
|
422
|
+
const AdmonitionPlugin = (md, options) => {
|
|
423
|
+
options = options || {};
|
|
424
|
+
const markers = 3, markerStr = options.marker || "!", markerChar = markerStr.charCodeAt(0), markerLen = markerStr.length;
|
|
425
|
+
let type = "", title = "";
|
|
426
|
+
const render = (tokens, idx, _options, _env, self) => {
|
|
427
|
+
const token = tokens[idx];
|
|
428
|
+
if (token.type === "admonition_open") {
|
|
429
|
+
tokens[idx].attrPush([
|
|
430
|
+
"class",
|
|
431
|
+
`${prefix}-admonition ${prefix}-admonition-${token.info}`
|
|
432
|
+
]);
|
|
433
|
+
tokens[idx].attrSet("data-line", String(tokens[idx].map[0]));
|
|
434
|
+
} else if (token.type === "admonition_title_open") {
|
|
435
|
+
tokens[idx].attrPush(["class", `${prefix}-admonition-title`]);
|
|
436
|
+
}
|
|
437
|
+
return self.renderToken(tokens, idx, _options);
|
|
438
|
+
};
|
|
439
|
+
const validate = (params) => {
|
|
440
|
+
const array = params.trim().split(" ", 2);
|
|
441
|
+
title = "";
|
|
442
|
+
type = array[0];
|
|
443
|
+
if (array.length > 1) {
|
|
444
|
+
title = params.substring(type.length + 2);
|
|
445
|
+
}
|
|
446
|
+
if (title === "" || !title) {
|
|
447
|
+
title = type;
|
|
448
|
+
}
|
|
236
449
|
};
|
|
237
|
-
|
|
450
|
+
md.block.ruler.before(
|
|
238
451
|
"code",
|
|
239
452
|
"admonition",
|
|
240
|
-
(
|
|
241
|
-
let
|
|
242
|
-
if (
|
|
243
|
-
return
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
const
|
|
251
|
-
if (
|
|
252
|
-
return
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
453
|
+
(state, startLine, endLine, silent) => {
|
|
454
|
+
let pos, nextLine, token, autoClosed = false, start = state.bMarks[startLine] + state.tShift[startLine], max = state.eMarks[startLine];
|
|
455
|
+
if (markerChar !== state.src.charCodeAt(start)) {
|
|
456
|
+
return false;
|
|
457
|
+
}
|
|
458
|
+
for (pos = start + 1; pos <= max; pos++) {
|
|
459
|
+
if (markerStr[(pos - start) % markerLen] !== state.src[pos]) {
|
|
460
|
+
break;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
const markerCount = Math.floor((pos - start) / markerLen);
|
|
464
|
+
if (markerCount !== markers) {
|
|
465
|
+
return false;
|
|
466
|
+
}
|
|
467
|
+
pos -= (pos - start) % markerLen;
|
|
468
|
+
const markup = state.src.slice(start, pos);
|
|
469
|
+
const params = state.src.slice(pos, max);
|
|
470
|
+
validate(params);
|
|
471
|
+
if (silent) {
|
|
472
|
+
return true;
|
|
473
|
+
}
|
|
474
|
+
nextLine = startLine;
|
|
475
|
+
for (; ; ) {
|
|
476
|
+
nextLine++;
|
|
477
|
+
if (nextLine >= endLine) {
|
|
478
|
+
break;
|
|
479
|
+
}
|
|
480
|
+
start = state.bMarks[nextLine] + state.tShift[nextLine];
|
|
481
|
+
max = state.eMarks[nextLine];
|
|
482
|
+
if (start < max && state.sCount[nextLine] < state.blkIndent) {
|
|
483
|
+
break;
|
|
484
|
+
}
|
|
485
|
+
if (markerChar !== state.src.charCodeAt(start)) {
|
|
486
|
+
continue;
|
|
487
|
+
}
|
|
488
|
+
if (state.sCount[nextLine] - state.blkIndent >= 4) {
|
|
489
|
+
continue;
|
|
490
|
+
}
|
|
491
|
+
for (pos = start + 1; pos <= max; pos++) {
|
|
492
|
+
if (markerStr[(pos - start) % markerLen] !== state.src[pos]) {
|
|
259
493
|
break;
|
|
260
494
|
}
|
|
261
495
|
}
|
|
262
|
-
|
|
263
|
-
|
|
496
|
+
if (Math.floor((pos - start) / markerLen) < markerCount) {
|
|
497
|
+
continue;
|
|
498
|
+
}
|
|
499
|
+
pos -= (pos - start) % markerLen;
|
|
500
|
+
pos = state.skipSpaces(pos);
|
|
501
|
+
if (pos < max) {
|
|
502
|
+
continue;
|
|
503
|
+
}
|
|
504
|
+
autoClosed = true;
|
|
505
|
+
break;
|
|
506
|
+
}
|
|
507
|
+
const oldParent = state.parentType;
|
|
508
|
+
const oldLineMax = state.lineMax;
|
|
509
|
+
state.parentType = "root";
|
|
510
|
+
state.lineMax = nextLine;
|
|
511
|
+
token = state.push("admonition_open", "div", 1);
|
|
512
|
+
token.markup = markup;
|
|
513
|
+
token.block = true;
|
|
514
|
+
token.info = type;
|
|
515
|
+
token.map = [startLine, nextLine];
|
|
516
|
+
token = state.push("admonition_title_open", "p", 1);
|
|
517
|
+
token.markup = markup + " " + type;
|
|
518
|
+
token.map = [startLine, nextLine];
|
|
519
|
+
token = state.push("inline", "", 0);
|
|
520
|
+
token.content = title;
|
|
521
|
+
token.map = [startLine, state.line - 1];
|
|
522
|
+
token.children = [];
|
|
523
|
+
token = state.push("admonition_title_close", "p", -1);
|
|
524
|
+
token.markup = markup + " " + type;
|
|
525
|
+
state.md.block.tokenize(state, startLine + 1, nextLine);
|
|
526
|
+
token = state.push("admonition_close", "div", -1);
|
|
527
|
+
token.markup = state.src.slice(start, pos);
|
|
528
|
+
token.block = true;
|
|
529
|
+
state.parentType = oldParent;
|
|
530
|
+
state.lineMax = oldLineMax;
|
|
531
|
+
state.line = nextLine + (autoClosed ? 1 : 0);
|
|
532
|
+
return true;
|
|
264
533
|
},
|
|
265
534
|
{
|
|
266
535
|
alt: ["paragraph", "reference", "blockquote", "list"]
|
|
267
536
|
}
|
|
268
|
-
)
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
)
|
|
280
|
-
|
|
281
|
-
},
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
537
|
+
);
|
|
538
|
+
md.renderer.rules["admonition_open"] = render;
|
|
539
|
+
md.renderer.rules["admonition_title_open"] = render;
|
|
540
|
+
md.renderer.rules["admonition_title_close"] = render;
|
|
541
|
+
md.renderer.rules["admonition_close"] = render;
|
|
542
|
+
};
|
|
543
|
+
const AdmonitionPlugin$1 = AdmonitionPlugin;
|
|
544
|
+
const HeadingPlugin = (md, options) => {
|
|
545
|
+
md.renderer.rules.heading_open = (tokens, idx) => {
|
|
546
|
+
var _a;
|
|
547
|
+
const token = tokens[idx];
|
|
548
|
+
const text = ((_a = tokens[idx + 1].children) == null ? void 0 : _a.reduce((p, c) => {
|
|
549
|
+
return p + (c.content || "");
|
|
550
|
+
}, "")) || "";
|
|
551
|
+
const level = token.markup.length;
|
|
552
|
+
options.headsRef.value.push({
|
|
553
|
+
text,
|
|
554
|
+
level
|
|
555
|
+
});
|
|
556
|
+
if (token.map && token.level === 0) {
|
|
557
|
+
token.attrSet("data-line", String(token.map[0]));
|
|
558
|
+
token.attrSet(
|
|
559
|
+
"id",
|
|
560
|
+
options.mdHeadingId(text, level, options.headsRef.value.length)
|
|
561
|
+
);
|
|
562
|
+
}
|
|
563
|
+
return md.renderer.renderToken(tokens, idx, options);
|
|
564
|
+
};
|
|
565
|
+
md.renderer.rules.heading_close = (tokens, idx, opts, _env, self) => {
|
|
566
|
+
return self.renderToken(tokens, idx, opts);
|
|
567
|
+
};
|
|
568
|
+
};
|
|
569
|
+
const HeadingPlugin$1 = HeadingPlugin;
|
|
570
|
+
const codetabs = (md, _opts) => {
|
|
571
|
+
const defaultRender = md.renderer.rules.fence, unescapeAll = md.utils.unescapeAll, re = /\[(\w*)(?::([\w ]*))?\]/;
|
|
572
|
+
function getInfo(token) {
|
|
573
|
+
return token.info ? unescapeAll(token.info).trim() : "";
|
|
285
574
|
}
|
|
286
|
-
function
|
|
287
|
-
const
|
|
288
|
-
return [
|
|
575
|
+
function getGroupAndTab(token) {
|
|
576
|
+
const info = getInfo(token), [group = null, tab = ""] = (re.exec(info) || []).slice(1);
|
|
577
|
+
return [group, tab];
|
|
289
578
|
}
|
|
290
|
-
function
|
|
291
|
-
const
|
|
292
|
-
return
|
|
579
|
+
function getLangName(token) {
|
|
580
|
+
const info = getInfo(token);
|
|
581
|
+
return info ? info.split(/(\s+)/g)[0] : "";
|
|
293
582
|
}
|
|
294
|
-
const
|
|
295
|
-
if (
|
|
583
|
+
const fenceGroup = (tokens, idx, options, env, slf) => {
|
|
584
|
+
if (tokens[idx].hidden) {
|
|
296
585
|
return "";
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
586
|
+
}
|
|
587
|
+
const [GROUP, _] = getGroupAndTab(tokens[idx]);
|
|
588
|
+
if (GROUP === null) {
|
|
589
|
+
return defaultRender(tokens, idx, options, env, slf);
|
|
590
|
+
}
|
|
591
|
+
let token, group, tab, checked, labels = "", pres = "";
|
|
592
|
+
for (let i = idx; i < tokens.length; i++) {
|
|
593
|
+
token = tokens[i];
|
|
594
|
+
[group, tab] = getGroupAndTab(token);
|
|
595
|
+
if (group !== GROUP) {
|
|
596
|
+
break;
|
|
597
|
+
}
|
|
598
|
+
token.info = token.info.replace(re, "");
|
|
599
|
+
token.hidden = true;
|
|
600
|
+
checked = i - idx > 0 ? "" : " checked";
|
|
601
|
+
labels += `<li><input type="radio" name="label-group-${_opts.editorId}-${idx}"${checked}><label for="group-${_opts.editorId}-${idx}-tab-${i - idx}" onclick="this.previousElementSibling.click()">${tab || getLangName(token)}</label></li>
|
|
602
|
+
`;
|
|
603
|
+
pres += `<input type="radio" id="group-${_opts.editorId}-${idx}-tab-${i - idx}" name="group-${_opts.editorId}-${idx}"${checked}>
|
|
604
|
+
` + defaultRender(tokens, i, options, env, slf);
|
|
605
|
+
}
|
|
606
|
+
return '<div class="code-tabs">\n<ul>\n' + labels + "</ul>\n" + pres + "</div>";
|
|
309
607
|
};
|
|
310
|
-
|
|
311
|
-
}
|
|
608
|
+
md.renderer.rules.fence = fenceGroup;
|
|
609
|
+
};
|
|
610
|
+
const CodeTabsPlugin = codetabs;
|
|
611
|
+
const initLineNumber = (md) => {
|
|
312
612
|
[
|
|
313
613
|
"paragraph_open",
|
|
314
614
|
"table_open",
|
|
@@ -318,64 +618,85 @@ const Be = (e, a) => {
|
|
|
318
618
|
"hr",
|
|
319
619
|
"html_block",
|
|
320
620
|
"fence"
|
|
321
|
-
].forEach((
|
|
322
|
-
const
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
621
|
+
].forEach((rule) => {
|
|
622
|
+
const backup = md.renderer.rules[rule];
|
|
623
|
+
if (!backup) {
|
|
624
|
+
md.renderer.rules[rule] = (tokens, idx, options, _env, self) => {
|
|
625
|
+
let line;
|
|
626
|
+
if (tokens[idx].map && tokens[idx].level === 0) {
|
|
627
|
+
line = tokens[idx].map[0];
|
|
628
|
+
tokens[idx].attrSet("data-line", String(line));
|
|
629
|
+
}
|
|
630
|
+
return self.renderToken(tokens, idx, options);
|
|
631
|
+
};
|
|
632
|
+
} else {
|
|
633
|
+
md.renderer.rules[rule] = (tokens, idx, options, env, self) => {
|
|
634
|
+
let line;
|
|
635
|
+
const _htmlCode = backup(tokens, idx, options, env, self);
|
|
636
|
+
if (tokens[idx].map && tokens[idx].level === 0 && !/^<!--/.test(_htmlCode)) {
|
|
637
|
+
line = tokens[idx].map[0];
|
|
638
|
+
return _htmlCode.replace(/^(<[^>]*)/, `$1 data-line="${line}"`);
|
|
639
|
+
}
|
|
640
|
+
return _htmlCode;
|
|
641
|
+
};
|
|
642
|
+
}
|
|
331
643
|
});
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
644
|
+
};
|
|
645
|
+
const useMarkdownIt = (props, previewOnly) => {
|
|
646
|
+
const { editorConfig, markdownItConfig, markdownItPlugins } = configOption;
|
|
647
|
+
const editorId = inject("editorId");
|
|
648
|
+
const showCodeRowNumber = inject("showCodeRowNumber");
|
|
649
|
+
const themeRef = inject("theme");
|
|
650
|
+
const headsRef = ref([]);
|
|
651
|
+
const hljsRef = useHighlight(props);
|
|
652
|
+
const katexRef = useKatex(props);
|
|
653
|
+
const { reRenderRef, replaceMermaid } = useMermaid(props);
|
|
654
|
+
const md = mdit({
|
|
655
|
+
html: true,
|
|
656
|
+
breaks: true
|
|
336
657
|
});
|
|
337
|
-
|
|
338
|
-
editorId
|
|
658
|
+
markdownItConfig(md, {
|
|
659
|
+
editorId
|
|
339
660
|
});
|
|
340
|
-
const
|
|
661
|
+
const plugins = [
|
|
341
662
|
{
|
|
342
663
|
type: "katex",
|
|
343
|
-
plugin:
|
|
344
|
-
options: { katexRef
|
|
664
|
+
plugin: KatexPlugin$1,
|
|
665
|
+
options: { katexRef }
|
|
345
666
|
},
|
|
346
667
|
{
|
|
347
668
|
type: "image",
|
|
348
|
-
plugin:
|
|
349
|
-
options: { figcaption:
|
|
669
|
+
plugin: ImageFiguresPlugin,
|
|
670
|
+
options: { figcaption: true, classes: "md-zoom" }
|
|
350
671
|
},
|
|
351
672
|
{
|
|
352
673
|
type: "admonition",
|
|
353
|
-
plugin:
|
|
674
|
+
plugin: AdmonitionPlugin$1,
|
|
354
675
|
options: {}
|
|
355
676
|
},
|
|
356
677
|
{
|
|
357
678
|
type: "taskList",
|
|
358
|
-
plugin:
|
|
679
|
+
plugin: TaskListPlugin,
|
|
359
680
|
options: {}
|
|
360
681
|
},
|
|
361
682
|
{
|
|
362
683
|
type: "heading",
|
|
363
|
-
plugin:
|
|
364
|
-
options: { mdHeadingId:
|
|
684
|
+
plugin: HeadingPlugin$1,
|
|
685
|
+
options: { mdHeadingId: props.mdHeadingId, headsRef }
|
|
365
686
|
},
|
|
366
687
|
{
|
|
367
688
|
type: "codeTabs",
|
|
368
|
-
plugin:
|
|
369
|
-
options: { editorId
|
|
689
|
+
plugin: CodeTabsPlugin,
|
|
690
|
+
options: { editorId }
|
|
370
691
|
},
|
|
371
692
|
{
|
|
372
693
|
type: "xss",
|
|
373
|
-
plugin:
|
|
694
|
+
plugin: XSSPlugin,
|
|
374
695
|
options: {
|
|
375
696
|
// https://github.com/leizongmin/js-xss/blob/master/README.zh.md
|
|
376
|
-
xss(
|
|
697
|
+
xss(xss) {
|
|
377
698
|
return {
|
|
378
|
-
whiteList: Object.assign({},
|
|
699
|
+
whiteList: Object.assign({}, xss.getDefaultWhiteList(), {
|
|
379
700
|
// 支持任务列表
|
|
380
701
|
input: ["class", "disabled", "type", "checked"],
|
|
381
702
|
// 主要支持youtobe、腾讯视频、哔哩哔哩等内嵌视频代码
|
|
@@ -397,66 +718,97 @@ const Be = (e, a) => {
|
|
|
397
718
|
}
|
|
398
719
|
}
|
|
399
720
|
];
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
}
|
|
407
|
-
|
|
721
|
+
if (!props.noMermaid) {
|
|
722
|
+
plugins.push({
|
|
723
|
+
type: "mermaid",
|
|
724
|
+
plugin: MermaidPlugin$1,
|
|
725
|
+
options: { themeRef }
|
|
726
|
+
});
|
|
727
|
+
}
|
|
728
|
+
markdownItPlugins(plugins, {
|
|
729
|
+
editorId
|
|
730
|
+
}).forEach((item) => {
|
|
731
|
+
md.use(item.plugin, item.options);
|
|
408
732
|
});
|
|
409
|
-
const
|
|
410
|
-
|
|
411
|
-
highlight: (
|
|
412
|
-
if (
|
|
413
|
-
const
|
|
414
|
-
if (
|
|
415
|
-
return
|
|
733
|
+
const userDefHighlight = md.options.highlight;
|
|
734
|
+
md.set({
|
|
735
|
+
highlight: (str, language, attrs) => {
|
|
736
|
+
if (userDefHighlight) {
|
|
737
|
+
const result = userDefHighlight(str, language, attrs);
|
|
738
|
+
if (result) {
|
|
739
|
+
return result;
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
let codeHtml;
|
|
743
|
+
if (!props.noHighlight && hljsRef.value) {
|
|
744
|
+
const hljsLang = hljsRef.value.getLanguage(language);
|
|
745
|
+
if (hljsLang) {
|
|
746
|
+
codeHtml = hljsRef.value.highlight(str, {
|
|
747
|
+
language,
|
|
748
|
+
ignoreIllegals: true
|
|
749
|
+
}).value;
|
|
750
|
+
} else {
|
|
751
|
+
codeHtml = hljsRef.value.highlightAuto(str).value;
|
|
752
|
+
}
|
|
753
|
+
} else {
|
|
754
|
+
codeHtml = md.utils.escapeHtml(str);
|
|
416
755
|
}
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
language: C,
|
|
420
|
-
ignoreIllegals: !0
|
|
421
|
-
}).value : H = s.value.highlightAuto($).value : H = v.utils.escapeHtml($);
|
|
422
|
-
const fe = r ? $e(H.replace(/^\n+|\n+$/g, "")) : `<span class="code-block">${H.replace(/^\n+|\n+$/g, "")}</span>`;
|
|
423
|
-
return `<pre><code class="language-${C}" language=${C}>${fe}</code></pre>`;
|
|
756
|
+
const codeSpan = showCodeRowNumber ? generateCodeRowNumber(codeHtml.replace(/^\n+|\n+$/g, "")) : `<span class="code-block">${codeHtml.replace(/^\n+|\n+$/g, "")}</span>`;
|
|
757
|
+
return `<pre><code class="language-${language}" language=${language}>${codeSpan}</code></pre>`;
|
|
424
758
|
}
|
|
425
|
-
})
|
|
426
|
-
|
|
427
|
-
|
|
759
|
+
});
|
|
760
|
+
initLineNumber(md);
|
|
761
|
+
const key = ref(`_article-key_${uuid()}`);
|
|
762
|
+
const html = ref(props.sanitize(md.render(props.modelValue)));
|
|
763
|
+
const updatedTodo = () => {
|
|
764
|
+
bus.emit(editorId, BUILD_FINISHED, html.value);
|
|
765
|
+
props.onHtmlChanged(html.value);
|
|
766
|
+
props.onGetCatalog(headsRef.value);
|
|
767
|
+
bus.emit(editorId, CATALOG_CHANGED, headsRef.value);
|
|
768
|
+
replaceMermaid();
|
|
428
769
|
};
|
|
429
|
-
|
|
430
|
-
const
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
770
|
+
onMounted(updatedTodo);
|
|
771
|
+
const markHtml = () => {
|
|
772
|
+
headsRef.value = [];
|
|
773
|
+
html.value = props.sanitize(md.render(props.modelValue));
|
|
774
|
+
updatedTodo();
|
|
775
|
+
};
|
|
776
|
+
const needReRender = computed(() => {
|
|
777
|
+
return (props.noKatex || katexRef.value) && (props.noHighlight || hljsRef.value);
|
|
778
|
+
});
|
|
779
|
+
watch(
|
|
780
|
+
[toRef(props, "modelValue"), needReRender, reRenderRef],
|
|
781
|
+
debounce(
|
|
782
|
+
markHtml,
|
|
783
|
+
(editorConfig == null ? void 0 : editorConfig.renderDelay) !== void 0 ? editorConfig == null ? void 0 : editorConfig.renderDelay : previewOnly ? 0 : 500
|
|
438
784
|
)
|
|
439
|
-
)
|
|
440
|
-
|
|
441
|
-
|
|
785
|
+
);
|
|
786
|
+
onMounted(() => {
|
|
787
|
+
bus.on(editorId, {
|
|
788
|
+
name: PUSH_CATALOG,
|
|
442
789
|
callback() {
|
|
443
|
-
|
|
790
|
+
bus.emit(editorId, CATALOG_CHANGED, headsRef.value);
|
|
444
791
|
}
|
|
445
|
-
})
|
|
446
|
-
|
|
792
|
+
});
|
|
793
|
+
bus.on(editorId, {
|
|
794
|
+
name: RERENDER,
|
|
447
795
|
callback: () => {
|
|
448
|
-
|
|
796
|
+
markHtml();
|
|
797
|
+
key.value = `_article-key_${uuid()}`;
|
|
449
798
|
}
|
|
450
799
|
});
|
|
451
|
-
})
|
|
452
|
-
|
|
800
|
+
});
|
|
801
|
+
return { html, key };
|
|
802
|
+
};
|
|
803
|
+
const useMarkdownIt$1 = useMarkdownIt;
|
|
804
|
+
const contentPreviewProps = {
|
|
453
805
|
modelValue: {
|
|
454
806
|
type: String,
|
|
455
807
|
default: ""
|
|
456
808
|
},
|
|
457
809
|
setting: {
|
|
458
810
|
type: Object,
|
|
459
|
-
default: () => ({ preview:
|
|
811
|
+
default: () => ({ preview: true })
|
|
460
812
|
},
|
|
461
813
|
onHtmlChanged: {
|
|
462
814
|
type: Function,
|
|
@@ -474,28 +826,28 @@ const Be = (e, a) => {
|
|
|
474
826
|
},
|
|
475
827
|
noMermaid: {
|
|
476
828
|
type: Boolean,
|
|
477
|
-
default:
|
|
829
|
+
default: false
|
|
478
830
|
},
|
|
479
831
|
sanitize: {
|
|
480
832
|
type: Function,
|
|
481
|
-
default: (
|
|
833
|
+
default: (html) => html
|
|
482
834
|
},
|
|
483
835
|
// 不使用该函数功能
|
|
484
836
|
noKatex: {
|
|
485
837
|
type: Boolean,
|
|
486
|
-
default:
|
|
838
|
+
default: false
|
|
487
839
|
},
|
|
488
840
|
formatCopiedText: {
|
|
489
841
|
type: Function,
|
|
490
|
-
default: (
|
|
842
|
+
default: (text) => text
|
|
491
843
|
},
|
|
492
844
|
noHighlight: {
|
|
493
845
|
type: Boolean,
|
|
494
|
-
default:
|
|
846
|
+
default: false
|
|
495
847
|
},
|
|
496
848
|
previewOnly: {
|
|
497
849
|
type: Boolean,
|
|
498
|
-
default:
|
|
850
|
+
default: false
|
|
499
851
|
},
|
|
500
852
|
noImgZoomIn: {
|
|
501
853
|
type: Boolean
|
|
@@ -503,8 +855,14 @@ const Be = (e, a) => {
|
|
|
503
855
|
sanitizeMermaid: {
|
|
504
856
|
type: Function
|
|
505
857
|
}
|
|
506
|
-
}
|
|
507
|
-
|
|
858
|
+
};
|
|
859
|
+
const contentProps = {
|
|
860
|
+
...contentPreviewProps,
|
|
861
|
+
updateModelValue: {
|
|
862
|
+
type: Function,
|
|
863
|
+
default: () => {
|
|
864
|
+
}
|
|
865
|
+
},
|
|
508
866
|
onChange: {
|
|
509
867
|
type: Function,
|
|
510
868
|
default: () => {
|
|
@@ -575,293 +933,402 @@ const Be = (e, a) => {
|
|
|
575
933
|
onInputBoxWitdhChange: {
|
|
576
934
|
type: Function
|
|
577
935
|
}
|
|
578
|
-
}
|
|
936
|
+
};
|
|
937
|
+
const ContentPreview = /* @__PURE__ */ defineComponent({
|
|
579
938
|
name: "ContentPreview",
|
|
580
|
-
props:
|
|
581
|
-
setup(
|
|
582
|
-
const
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
939
|
+
props: contentPreviewProps,
|
|
940
|
+
setup(props) {
|
|
941
|
+
const editorId = inject("editorId");
|
|
942
|
+
const previewTheme = inject("previewTheme");
|
|
943
|
+
const showCodeRowNumber = inject("showCodeRowNumber");
|
|
944
|
+
const {
|
|
945
|
+
html,
|
|
946
|
+
key
|
|
947
|
+
} = useMarkdownIt$1(props, props.previewOnly);
|
|
948
|
+
useCopyCode(props, html, key);
|
|
949
|
+
userZoom(props, html);
|
|
950
|
+
return () => {
|
|
951
|
+
return createVNode(Fragment, null, [props.setting.preview && createVNode("div", {
|
|
952
|
+
"id": `${editorId}-preview-wrapper`,
|
|
953
|
+
"class": `${prefix}-preview-wrapper`,
|
|
954
|
+
"key": "content-preview-wrapper"
|
|
955
|
+
}, [createVNode("div", {
|
|
956
|
+
"key": key.value,
|
|
957
|
+
"id": `${editorId}-preview`,
|
|
958
|
+
"class": [`${prefix}-preview`, `${previewTheme == null ? void 0 : previewTheme.value}-theme`, showCodeRowNumber && `${prefix}-scrn`],
|
|
959
|
+
"innerHTML": html.value
|
|
960
|
+
}, null)]), !props.previewOnly && props.setting.htmlPreview && createVNode("div", {
|
|
961
|
+
"id": `${editorId}-html-wrapper`,
|
|
962
|
+
"class": `${prefix}-preview-wrapper`,
|
|
963
|
+
"key": "html-preview-wrapper"
|
|
964
|
+
}, [createVNode("div", {
|
|
965
|
+
"class": `${prefix}-html`
|
|
966
|
+
}, [html.value])])]);
|
|
967
|
+
};
|
|
602
968
|
}
|
|
603
|
-
})
|
|
604
|
-
|
|
969
|
+
});
|
|
970
|
+
const useOnSave = (props, context) => {
|
|
971
|
+
const { editorId } = props;
|
|
972
|
+
const state = reactive({
|
|
605
973
|
// 是否已编译成html
|
|
606
|
-
buildFinished:
|
|
974
|
+
buildFinished: false,
|
|
607
975
|
// 存储当前最新的html
|
|
608
976
|
html: ""
|
|
609
977
|
});
|
|
610
|
-
|
|
611
|
-
() =>
|
|
978
|
+
watch(
|
|
979
|
+
() => props.modelValue,
|
|
612
980
|
() => {
|
|
613
|
-
|
|
981
|
+
state.buildFinished = false;
|
|
614
982
|
}
|
|
615
|
-
)
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
983
|
+
);
|
|
984
|
+
onMounted(() => {
|
|
985
|
+
bus.on(editorId, {
|
|
986
|
+
name: BUILD_FINISHED,
|
|
987
|
+
callback(html) {
|
|
988
|
+
state.buildFinished = true;
|
|
989
|
+
state.html = html;
|
|
620
990
|
}
|
|
621
|
-
})
|
|
622
|
-
|
|
991
|
+
});
|
|
992
|
+
bus.on(editorId, {
|
|
993
|
+
name: ON_SAVE,
|
|
623
994
|
callback() {
|
|
624
|
-
const
|
|
625
|
-
if (
|
|
626
|
-
|
|
627
|
-
else {
|
|
628
|
-
const
|
|
629
|
-
|
|
995
|
+
const htmlPromise = new Promise((rev) => {
|
|
996
|
+
if (state.buildFinished) {
|
|
997
|
+
rev(state.html);
|
|
998
|
+
} else {
|
|
999
|
+
const buildFinishedCallback = (html) => {
|
|
1000
|
+
rev(html);
|
|
1001
|
+
bus.remove(editorId, BUILD_FINISHED, buildFinishedCallback);
|
|
630
1002
|
};
|
|
631
|
-
|
|
632
|
-
name:
|
|
633
|
-
callback:
|
|
1003
|
+
bus.on(editorId, {
|
|
1004
|
+
name: BUILD_FINISHED,
|
|
1005
|
+
callback: buildFinishedCallback
|
|
634
1006
|
});
|
|
635
1007
|
}
|
|
636
1008
|
});
|
|
637
|
-
|
|
1009
|
+
if (props.onSave) {
|
|
1010
|
+
props.onSave(props.modelValue, htmlPromise);
|
|
1011
|
+
} else {
|
|
1012
|
+
context.emit("onSave", props.modelValue, htmlPromise);
|
|
1013
|
+
}
|
|
638
1014
|
}
|
|
639
1015
|
});
|
|
640
1016
|
});
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
1017
|
+
};
|
|
1018
|
+
const useProvidePreview = (props) => {
|
|
1019
|
+
var _a, _b;
|
|
1020
|
+
const { editorId } = props;
|
|
1021
|
+
const highlightConfig = (_b = (_a = configOption) == null ? void 0 : _a.editorExtensions) == null ? void 0 : _b.highlight;
|
|
1022
|
+
provide("editorId", editorId);
|
|
1023
|
+
provide(
|
|
645
1024
|
"theme",
|
|
646
|
-
|
|
647
|
-
)
|
|
1025
|
+
computed(() => props.theme)
|
|
1026
|
+
);
|
|
1027
|
+
provide(
|
|
648
1028
|
"language",
|
|
649
|
-
|
|
650
|
-
)
|
|
1029
|
+
computed(() => props.language)
|
|
1030
|
+
);
|
|
1031
|
+
provide(
|
|
651
1032
|
"highlight",
|
|
652
|
-
|
|
653
|
-
const
|
|
654
|
-
...
|
|
655
|
-
...
|
|
656
|
-
}
|
|
1033
|
+
computed(() => {
|
|
1034
|
+
const cssList = {
|
|
1035
|
+
...codeCss,
|
|
1036
|
+
...highlightConfig == null ? void 0 : highlightConfig.css
|
|
1037
|
+
};
|
|
1038
|
+
const theme = props.codeStyleReverse && props.codeStyleReverseList.includes(props.previewTheme) ? "dark" : props.theme;
|
|
657
1039
|
return {
|
|
658
|
-
js: (
|
|
659
|
-
css:
|
|
1040
|
+
js: (highlightConfig == null ? void 0 : highlightConfig.js) || highlightUrl,
|
|
1041
|
+
css: cssList[props.codeTheme] ? cssList[props.codeTheme][theme] : codeCss.atom[theme]
|
|
660
1042
|
};
|
|
661
1043
|
})
|
|
662
|
-
)
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
...
|
|
1044
|
+
);
|
|
1045
|
+
provide("showCodeRowNumber", props.showCodeRowNumber);
|
|
1046
|
+
const usedLanguageText = computed(() => {
|
|
1047
|
+
var _a2, _b2;
|
|
1048
|
+
const allText = {
|
|
1049
|
+
...staticTextDefault,
|
|
1050
|
+
...(_b2 = (_a2 = configOption) == null ? void 0 : _a2.editorConfig) == null ? void 0 : _b2.languageUserDefined
|
|
668
1051
|
};
|
|
669
|
-
|
|
1052
|
+
if (allText[props.language]) {
|
|
1053
|
+
return allText[props.language];
|
|
1054
|
+
} else {
|
|
1055
|
+
return staticTextDefault["zh-CN"];
|
|
1056
|
+
}
|
|
670
1057
|
});
|
|
671
|
-
|
|
1058
|
+
provide("usedLanguageText", usedLanguageText);
|
|
1059
|
+
provide(
|
|
672
1060
|
"previewTheme",
|
|
673
|
-
|
|
674
|
-
)
|
|
1061
|
+
computed(() => props.previewTheme)
|
|
1062
|
+
);
|
|
1063
|
+
provide(
|
|
675
1064
|
"customIcon",
|
|
676
|
-
|
|
1065
|
+
computed(() => props.customIcon)
|
|
677
1066
|
);
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
1067
|
+
};
|
|
1068
|
+
const useProvide = (props) => {
|
|
1069
|
+
useProvidePreview(props);
|
|
1070
|
+
provide("tabWidth", props.tabWidth);
|
|
1071
|
+
};
|
|
1072
|
+
const useExpansionPreview = (props) => {
|
|
1073
|
+
onMounted(() => {
|
|
1074
|
+
var _a, _b;
|
|
1075
|
+
if (!props.noIconfont) {
|
|
1076
|
+
if (configOption.iconfontType === "svg") {
|
|
1077
|
+
const iconfontScript = document.createElement("script");
|
|
1078
|
+
iconfontScript.src = ((_a = configOption.editorExtensions) == null ? void 0 : _a.iconfont) || iconfontSvgUrl;
|
|
1079
|
+
iconfontScript.id = `${prefix}-icon`;
|
|
1080
|
+
appendHandler(iconfontScript);
|
|
687
1081
|
} else {
|
|
688
|
-
const
|
|
689
|
-
|
|
1082
|
+
const iconfontLink = document.createElement("link");
|
|
1083
|
+
iconfontLink.rel = "stylesheet";
|
|
1084
|
+
iconfontLink.href = ((_b = configOption.editorExtensions) == null ? void 0 : _b.iconfontClass) || iconfontClassUrl;
|
|
1085
|
+
iconfontLink.id = `${prefix}-icon-class`;
|
|
1086
|
+
appendHandler(iconfontLink);
|
|
690
1087
|
}
|
|
1088
|
+
}
|
|
691
1089
|
});
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
1090
|
+
};
|
|
1091
|
+
const useExpansion = (props) => {
|
|
1092
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1093
|
+
const { noPrettier, noUploadImg } = props;
|
|
1094
|
+
const { editorExtensions } = configOption;
|
|
1095
|
+
const noPrettierScript = noPrettier || !!((_b = (_a = configOption.editorExtensions) == null ? void 0 : _a.prettier) == null ? void 0 : _b.prettierInstance);
|
|
1096
|
+
const noParserMarkdownScript = noPrettier || !!((_d = (_c = configOption.editorExtensions) == null ? void 0 : _c.prettier) == null ? void 0 : _d.parserMarkdownInstance);
|
|
1097
|
+
const noCropperScript = noUploadImg || !!((_f = (_e = configOption.editorExtensions) == null ? void 0 : _e.cropper) == null ? void 0 : _f.instance);
|
|
1098
|
+
onMounted(() => {
|
|
1099
|
+
var _a2, _b2, _c2, _d2;
|
|
1100
|
+
const prettierScript = document.createElement("script");
|
|
1101
|
+
const prettierMDScript = document.createElement("script");
|
|
1102
|
+
prettierScript.src = ((_a2 = editorExtensions == null ? void 0 : editorExtensions.prettier) == null ? void 0 : _a2.standaloneJs) || prettierUrl.main;
|
|
1103
|
+
prettierScript.id = `${prefix}-prettier`;
|
|
1104
|
+
prettierMDScript.src = ((_b2 = editorExtensions == null ? void 0 : editorExtensions.prettier) == null ? void 0 : _b2.parserMarkdownJs) || prettierUrl.markdown;
|
|
1105
|
+
prettierMDScript.id = `${prefix}-prettierMD`;
|
|
1106
|
+
const cropperLink = document.createElement("link");
|
|
1107
|
+
cropperLink.rel = "stylesheet";
|
|
1108
|
+
cropperLink.href = ((_c2 = editorExtensions == null ? void 0 : editorExtensions.cropper) == null ? void 0 : _c2.css) || cropperUrl.css;
|
|
1109
|
+
cropperLink.id = `${prefix}-cropperCss`;
|
|
1110
|
+
const cropperScript = document.createElement("script");
|
|
1111
|
+
cropperScript.src = ((_d2 = editorExtensions == null ? void 0 : editorExtensions.cropper) == null ? void 0 : _d2.js) || cropperUrl.js;
|
|
1112
|
+
cropperScript.id = `${prefix}-cropper`;
|
|
1113
|
+
if (!noCropperScript) {
|
|
1114
|
+
appendHandler(cropperLink);
|
|
1115
|
+
appendHandler(cropperScript);
|
|
1116
|
+
}
|
|
1117
|
+
if (!noPrettierScript) {
|
|
1118
|
+
appendHandler(prettierScript);
|
|
1119
|
+
}
|
|
1120
|
+
if (!noParserMarkdownScript) {
|
|
1121
|
+
appendHandler(prettierMDScript);
|
|
1122
|
+
}
|
|
1123
|
+
});
|
|
1124
|
+
useExpansionPreview(props);
|
|
1125
|
+
};
|
|
1126
|
+
const useErrorCatcher = (props, context) => {
|
|
1127
|
+
const { editorId } = props;
|
|
1128
|
+
onMounted(() => {
|
|
1129
|
+
bus.on(editorId, {
|
|
1130
|
+
name: ERROR_CATCHER,
|
|
1131
|
+
callback: (err) => {
|
|
1132
|
+
if (props.onError instanceof Function) {
|
|
1133
|
+
props.onError(err);
|
|
1134
|
+
} else {
|
|
1135
|
+
context.emit("onError", err);
|
|
1136
|
+
}
|
|
711
1137
|
}
|
|
712
1138
|
});
|
|
713
1139
|
});
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
1140
|
+
};
|
|
1141
|
+
const useConfig = (props, context) => {
|
|
1142
|
+
const { editorId } = props;
|
|
1143
|
+
const setting = reactive({
|
|
1144
|
+
pageFullscreen: props.pageFullscreen,
|
|
1145
|
+
fullscreen: false,
|
|
1146
|
+
preview: props.preview,
|
|
1147
|
+
htmlPreview: props.preview ? false : props.htmlPreview
|
|
1148
|
+
});
|
|
1149
|
+
const updateSetting = (k, v) => {
|
|
1150
|
+
setting[k] = v === void 0 ? !setting[k] : v;
|
|
1151
|
+
if (k === "preview" && setting.preview) {
|
|
1152
|
+
setting.htmlPreview = false;
|
|
1153
|
+
} else if (k === "htmlPreview" && setting.htmlPreview) {
|
|
1154
|
+
setting.preview = false;
|
|
1155
|
+
}
|
|
722
1156
|
};
|
|
723
|
-
let
|
|
724
|
-
const
|
|
725
|
-
|
|
1157
|
+
let bodyOverflowHistory = "";
|
|
1158
|
+
const adjustBody = () => {
|
|
1159
|
+
if (setting.pageFullscreen || setting.fullscreen) {
|
|
1160
|
+
document.body.style.overflow = "hidden";
|
|
1161
|
+
} else {
|
|
1162
|
+
document.body.style.overflow = bodyOverflowHistory;
|
|
1163
|
+
}
|
|
726
1164
|
};
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
1165
|
+
watch(() => [setting.pageFullscreen, setting.fullscreen], adjustBody);
|
|
1166
|
+
onMounted(() => {
|
|
1167
|
+
bus.on(editorId, {
|
|
1168
|
+
name: UPLOAD_IMAGE,
|
|
1169
|
+
callback(files, cb) {
|
|
1170
|
+
const insertHanlder = (urls) => {
|
|
1171
|
+
bus.emit(editorId, REPLACE, "image", {
|
|
733
1172
|
desc: "",
|
|
734
|
-
urls
|
|
735
|
-
})
|
|
1173
|
+
urls
|
|
1174
|
+
});
|
|
1175
|
+
cb && cb();
|
|
736
1176
|
};
|
|
737
|
-
|
|
1177
|
+
if (props.onUploadImg) {
|
|
1178
|
+
props.onUploadImg(files, insertHanlder);
|
|
1179
|
+
} else {
|
|
1180
|
+
context.emit("onUploadImg", files, insertHanlder);
|
|
1181
|
+
}
|
|
738
1182
|
}
|
|
739
|
-
})
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
return
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
1183
|
+
});
|
|
1184
|
+
bodyOverflowHistory = document.body.style.overflow;
|
|
1185
|
+
adjustBody();
|
|
1186
|
+
});
|
|
1187
|
+
return [setting, updateSetting];
|
|
1188
|
+
};
|
|
1189
|
+
const useCatalog = (props) => {
|
|
1190
|
+
const { editorId } = props;
|
|
1191
|
+
const catalogShow = ref(false);
|
|
1192
|
+
onMounted(() => {
|
|
1193
|
+
bus.on(editorId, {
|
|
1194
|
+
name: CHANGE_CATALOG_VISIBLE,
|
|
1195
|
+
callback: (v) => {
|
|
1196
|
+
if (v === void 0) {
|
|
1197
|
+
catalogShow.value = !catalogShow.value;
|
|
1198
|
+
} else {
|
|
1199
|
+
catalogShow.value = v;
|
|
1200
|
+
}
|
|
748
1201
|
}
|
|
749
1202
|
});
|
|
750
|
-
})
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
1203
|
+
});
|
|
1204
|
+
const catalogVisible = computed(() => {
|
|
1205
|
+
return !props.toolbarsExclude.includes("catalog") && props.toolbars.includes("catalog") && catalogShow.value;
|
|
1206
|
+
});
|
|
1207
|
+
return catalogVisible;
|
|
1208
|
+
};
|
|
1209
|
+
const useExpose$1 = (props, ctx, catalogVisible, setting, updateSetting, codeRef) => {
|
|
1210
|
+
const { editorId } = props;
|
|
1211
|
+
watch(
|
|
1212
|
+
() => setting.pageFullscreen,
|
|
1213
|
+
(newVal) => {
|
|
1214
|
+
bus.emit(editorId, PAGE_FULL_SCREEN_CHANGED, newVal);
|
|
757
1215
|
}
|
|
758
|
-
)
|
|
759
|
-
|
|
760
|
-
(
|
|
761
|
-
|
|
1216
|
+
);
|
|
1217
|
+
watch(
|
|
1218
|
+
() => setting.fullscreen,
|
|
1219
|
+
(newVal) => {
|
|
1220
|
+
bus.emit(editorId, FULL_SCREEN_CHANGED, newVal);
|
|
762
1221
|
}
|
|
763
|
-
)
|
|
764
|
-
|
|
765
|
-
(
|
|
766
|
-
|
|
1222
|
+
);
|
|
1223
|
+
watch(
|
|
1224
|
+
() => setting.preview,
|
|
1225
|
+
(newVal) => {
|
|
1226
|
+
bus.emit(editorId, PREVIEW_CHANGED, newVal);
|
|
767
1227
|
}
|
|
768
|
-
)
|
|
769
|
-
|
|
770
|
-
(
|
|
771
|
-
|
|
1228
|
+
);
|
|
1229
|
+
watch(
|
|
1230
|
+
() => setting.htmlPreview,
|
|
1231
|
+
(newVal) => {
|
|
1232
|
+
bus.emit(editorId, HTML_PREVIEW_CHANGED, newVal);
|
|
772
1233
|
}
|
|
773
|
-
)
|
|
774
|
-
|
|
1234
|
+
);
|
|
1235
|
+
watch(catalogVisible, (newVal) => {
|
|
1236
|
+
bus.emit(editorId, CATALOG_VISIBLE_CHANGED, newVal);
|
|
775
1237
|
});
|
|
776
|
-
const
|
|
777
|
-
on(
|
|
778
|
-
switch (
|
|
1238
|
+
const exposeParam = {
|
|
1239
|
+
on(eventName, callBack) {
|
|
1240
|
+
switch (eventName) {
|
|
779
1241
|
case "pageFullscreen": {
|
|
780
|
-
|
|
781
|
-
name:
|
|
782
|
-
callback(
|
|
783
|
-
|
|
1242
|
+
bus.on(editorId, {
|
|
1243
|
+
name: PAGE_FULL_SCREEN_CHANGED,
|
|
1244
|
+
callback(status) {
|
|
1245
|
+
callBack(status);
|
|
784
1246
|
}
|
|
785
1247
|
});
|
|
786
1248
|
break;
|
|
787
1249
|
}
|
|
788
1250
|
case "fullscreen": {
|
|
789
|
-
|
|
790
|
-
name:
|
|
791
|
-
callback(
|
|
792
|
-
|
|
1251
|
+
bus.on(editorId, {
|
|
1252
|
+
name: FULL_SCREEN_CHANGED,
|
|
1253
|
+
callback(status) {
|
|
1254
|
+
callBack(status);
|
|
793
1255
|
}
|
|
794
1256
|
});
|
|
795
1257
|
break;
|
|
796
1258
|
}
|
|
797
1259
|
case "preview": {
|
|
798
|
-
|
|
799
|
-
name:
|
|
800
|
-
callback(
|
|
801
|
-
|
|
1260
|
+
bus.on(editorId, {
|
|
1261
|
+
name: PREVIEW_CHANGED,
|
|
1262
|
+
callback(status) {
|
|
1263
|
+
callBack(status);
|
|
802
1264
|
}
|
|
803
1265
|
});
|
|
804
1266
|
break;
|
|
805
1267
|
}
|
|
806
1268
|
case "htmlPreview": {
|
|
807
|
-
|
|
808
|
-
name:
|
|
809
|
-
callback(
|
|
810
|
-
|
|
1269
|
+
bus.on(editorId, {
|
|
1270
|
+
name: HTML_PREVIEW_CHANGED,
|
|
1271
|
+
callback(status) {
|
|
1272
|
+
callBack(status);
|
|
811
1273
|
}
|
|
812
1274
|
});
|
|
813
1275
|
break;
|
|
814
1276
|
}
|
|
815
1277
|
case "catalog": {
|
|
816
|
-
|
|
817
|
-
name:
|
|
818
|
-
callback(
|
|
819
|
-
|
|
1278
|
+
bus.on(editorId, {
|
|
1279
|
+
name: CATALOG_VISIBLE_CHANGED,
|
|
1280
|
+
callback(status) {
|
|
1281
|
+
callBack(status);
|
|
820
1282
|
}
|
|
821
1283
|
});
|
|
822
1284
|
break;
|
|
823
1285
|
}
|
|
824
1286
|
}
|
|
825
1287
|
},
|
|
826
|
-
togglePageFullscreen(
|
|
827
|
-
|
|
1288
|
+
togglePageFullscreen(status) {
|
|
1289
|
+
updateSetting("pageFullscreen", status);
|
|
828
1290
|
},
|
|
829
|
-
toggleFullscreen(
|
|
830
|
-
|
|
1291
|
+
toggleFullscreen(status) {
|
|
1292
|
+
bus.emit(editorId, CHANGE_FULL_SCREEN, status);
|
|
831
1293
|
},
|
|
832
|
-
togglePreview(
|
|
833
|
-
|
|
1294
|
+
togglePreview(status) {
|
|
1295
|
+
updateSetting("preview", status);
|
|
834
1296
|
},
|
|
835
|
-
toggleHtmlPreview(
|
|
836
|
-
|
|
1297
|
+
toggleHtmlPreview(status) {
|
|
1298
|
+
updateSetting("htmlPreview", status);
|
|
837
1299
|
},
|
|
838
|
-
toggleCatalog(
|
|
839
|
-
|
|
1300
|
+
toggleCatalog(status) {
|
|
1301
|
+
bus.emit(editorId, CHANGE_CATALOG_VISIBLE, status);
|
|
840
1302
|
},
|
|
841
1303
|
triggerSave() {
|
|
842
|
-
|
|
1304
|
+
bus.emit(editorId, ON_SAVE);
|
|
843
1305
|
},
|
|
844
|
-
insert(
|
|
845
|
-
|
|
1306
|
+
insert(generate) {
|
|
1307
|
+
bus.emit(editorId, REPLACE, "universal", { generate });
|
|
846
1308
|
},
|
|
847
|
-
focus(
|
|
848
|
-
var
|
|
849
|
-
(
|
|
1309
|
+
focus(options) {
|
|
1310
|
+
var _a;
|
|
1311
|
+
(_a = codeRef.value) == null ? void 0 : _a.focus(options);
|
|
850
1312
|
},
|
|
851
1313
|
rerender() {
|
|
852
|
-
|
|
1314
|
+
bus.emit(editorId, RERENDER);
|
|
853
1315
|
},
|
|
854
1316
|
getSelectedText() {
|
|
855
|
-
var
|
|
856
|
-
return (
|
|
1317
|
+
var _a;
|
|
1318
|
+
return (_a = codeRef.value) == null ? void 0 : _a.getSelectedText();
|
|
857
1319
|
},
|
|
858
1320
|
resetHistory() {
|
|
859
|
-
var
|
|
860
|
-
(
|
|
1321
|
+
var _a;
|
|
1322
|
+
(_a = codeRef.value) == null ? void 0 : _a.resetHistory();
|
|
1323
|
+
},
|
|
1324
|
+
domEventHandlers(handlers) {
|
|
1325
|
+
bus.emit(editorId, EVENT_LISTENER, handlers);
|
|
861
1326
|
}
|
|
862
1327
|
};
|
|
863
|
-
|
|
864
|
-
}
|
|
1328
|
+
ctx.expose(exposeParam);
|
|
1329
|
+
};
|
|
1330
|
+
const mdHeadingId = (text) => text;
|
|
1331
|
+
const mdPreviewProps = {
|
|
865
1332
|
/**
|
|
866
1333
|
* markdown content.
|
|
867
1334
|
*
|
|
@@ -917,7 +1384,7 @@ const Be = (e, a) => {
|
|
|
917
1384
|
*/
|
|
918
1385
|
editorId: {
|
|
919
1386
|
type: String,
|
|
920
|
-
default: () =>
|
|
1387
|
+
default: () => getNextId("md-editor-v3_")
|
|
921
1388
|
},
|
|
922
1389
|
/**
|
|
923
1390
|
* 预览中代码是否显示行号
|
|
@@ -926,7 +1393,7 @@ const Be = (e, a) => {
|
|
|
926
1393
|
*/
|
|
927
1394
|
showCodeRowNumber: {
|
|
928
1395
|
type: Boolean,
|
|
929
|
-
default:
|
|
1396
|
+
default: false
|
|
930
1397
|
},
|
|
931
1398
|
/**
|
|
932
1399
|
* 预览内容样式
|
|
@@ -951,7 +1418,7 @@ const Be = (e, a) => {
|
|
|
951
1418
|
*/
|
|
952
1419
|
mdHeadingId: {
|
|
953
1420
|
type: Function,
|
|
954
|
-
default:
|
|
1421
|
+
default: mdHeadingId
|
|
955
1422
|
},
|
|
956
1423
|
/**
|
|
957
1424
|
*
|
|
@@ -962,7 +1429,7 @@ const Be = (e, a) => {
|
|
|
962
1429
|
*/
|
|
963
1430
|
sanitize: {
|
|
964
1431
|
type: Function,
|
|
965
|
-
default: (
|
|
1432
|
+
default: (html) => html
|
|
966
1433
|
},
|
|
967
1434
|
/**
|
|
968
1435
|
* 不使用该mermaid
|
|
@@ -971,7 +1438,7 @@ const Be = (e, a) => {
|
|
|
971
1438
|
*/
|
|
972
1439
|
noMermaid: {
|
|
973
1440
|
type: Boolean,
|
|
974
|
-
default:
|
|
1441
|
+
default: false
|
|
975
1442
|
},
|
|
976
1443
|
/**
|
|
977
1444
|
* 不使用katex
|
|
@@ -980,7 +1447,7 @@ const Be = (e, a) => {
|
|
|
980
1447
|
*/
|
|
981
1448
|
noKatex: {
|
|
982
1449
|
type: Boolean,
|
|
983
|
-
default:
|
|
1450
|
+
default: false
|
|
984
1451
|
},
|
|
985
1452
|
/**
|
|
986
1453
|
* 代码主题
|
|
@@ -1006,7 +1473,7 @@ const Be = (e, a) => {
|
|
|
1006
1473
|
*/
|
|
1007
1474
|
formatCopiedText: {
|
|
1008
1475
|
type: Function,
|
|
1009
|
-
default: (
|
|
1476
|
+
default: (text) => text
|
|
1010
1477
|
},
|
|
1011
1478
|
/**
|
|
1012
1479
|
* 某些预览主题的代码模块背景是暗色系
|
|
@@ -1016,7 +1483,7 @@ const Be = (e, a) => {
|
|
|
1016
1483
|
*/
|
|
1017
1484
|
codeStyleReverse: {
|
|
1018
1485
|
type: Boolean,
|
|
1019
|
-
default:
|
|
1486
|
+
default: true
|
|
1020
1487
|
},
|
|
1021
1488
|
/**
|
|
1022
1489
|
* 需要自动调整的预览主题
|
|
@@ -1029,14 +1496,14 @@ const Be = (e, a) => {
|
|
|
1029
1496
|
},
|
|
1030
1497
|
noHighlight: {
|
|
1031
1498
|
type: Boolean,
|
|
1032
|
-
default:
|
|
1499
|
+
default: false
|
|
1033
1500
|
},
|
|
1034
1501
|
/**
|
|
1035
1502
|
* 是否关闭编辑器默认的放大缩小功能
|
|
1036
1503
|
*/
|
|
1037
1504
|
noImgZoomIn: {
|
|
1038
1505
|
type: Boolean,
|
|
1039
|
-
default:
|
|
1506
|
+
default: false
|
|
1040
1507
|
},
|
|
1041
1508
|
/**
|
|
1042
1509
|
* 自定义的图标
|
|
@@ -1047,10 +1514,11 @@ const Be = (e, a) => {
|
|
|
1047
1514
|
},
|
|
1048
1515
|
sanitizeMermaid: {
|
|
1049
1516
|
type: Function,
|
|
1050
|
-
default: (
|
|
1517
|
+
default: (h) => Promise.resolve(h)
|
|
1051
1518
|
}
|
|
1052
|
-
}
|
|
1053
|
-
|
|
1519
|
+
};
|
|
1520
|
+
const editorProps = {
|
|
1521
|
+
...mdPreviewProps,
|
|
1054
1522
|
/**
|
|
1055
1523
|
* input回调事件
|
|
1056
1524
|
*/
|
|
@@ -1076,7 +1544,7 @@ const Be = (e, a) => {
|
|
|
1076
1544
|
*/
|
|
1077
1545
|
pageFullscreen: {
|
|
1078
1546
|
type: Boolean,
|
|
1079
|
-
default:
|
|
1547
|
+
default: false
|
|
1080
1548
|
},
|
|
1081
1549
|
/**
|
|
1082
1550
|
* 是否展开预览
|
|
@@ -1085,7 +1553,7 @@ const Be = (e, a) => {
|
|
|
1085
1553
|
*/
|
|
1086
1554
|
preview: {
|
|
1087
1555
|
type: Boolean,
|
|
1088
|
-
default:
|
|
1556
|
+
default: true
|
|
1089
1557
|
},
|
|
1090
1558
|
/**
|
|
1091
1559
|
* 是否展开html预览
|
|
@@ -1094,7 +1562,7 @@ const Be = (e, a) => {
|
|
|
1094
1562
|
*/
|
|
1095
1563
|
htmlPreview: {
|
|
1096
1564
|
type: Boolean,
|
|
1097
|
-
default:
|
|
1565
|
+
default: false
|
|
1098
1566
|
},
|
|
1099
1567
|
/**
|
|
1100
1568
|
* 仅预览模式,不显示toolbar和编辑框
|
|
@@ -1114,7 +1582,7 @@ const Be = (e, a) => {
|
|
|
1114
1582
|
*/
|
|
1115
1583
|
toolbars: {
|
|
1116
1584
|
type: Array,
|
|
1117
|
-
default:
|
|
1585
|
+
default: allToolbar
|
|
1118
1586
|
},
|
|
1119
1587
|
/**
|
|
1120
1588
|
* 工具栏选择不显示
|
|
@@ -1132,7 +1600,7 @@ const Be = (e, a) => {
|
|
|
1132
1600
|
*/
|
|
1133
1601
|
noPrettier: {
|
|
1134
1602
|
type: Boolean,
|
|
1135
|
-
default:
|
|
1603
|
+
default: false
|
|
1136
1604
|
},
|
|
1137
1605
|
/**
|
|
1138
1606
|
* 一个tab等于空格数
|
|
@@ -1178,7 +1646,7 @@ const Be = (e, a) => {
|
|
|
1178
1646
|
*/
|
|
1179
1647
|
footers: {
|
|
1180
1648
|
type: Array,
|
|
1181
|
-
default:
|
|
1649
|
+
default: allFooter
|
|
1182
1650
|
},
|
|
1183
1651
|
/**
|
|
1184
1652
|
* 是否默认激活输入框和预览框同步滚动
|
|
@@ -1187,7 +1655,7 @@ const Be = (e, a) => {
|
|
|
1187
1655
|
*/
|
|
1188
1656
|
scrollAuto: {
|
|
1189
1657
|
type: Boolean,
|
|
1190
|
-
default:
|
|
1658
|
+
default: true
|
|
1191
1659
|
},
|
|
1192
1660
|
/**
|
|
1193
1661
|
* 自定义的也叫工具组件列表
|
|
@@ -1274,7 +1742,7 @@ const Be = (e, a) => {
|
|
|
1274
1742
|
*/
|
|
1275
1743
|
showToolbarName: {
|
|
1276
1744
|
type: Boolean,
|
|
1277
|
-
default:
|
|
1745
|
+
default: false
|
|
1278
1746
|
},
|
|
1279
1747
|
/**
|
|
1280
1748
|
* 字符输入事件
|
|
@@ -1301,8 +1769,10 @@ const Be = (e, a) => {
|
|
|
1301
1769
|
onInputBoxWitdhChange: {
|
|
1302
1770
|
type: Function
|
|
1303
1771
|
}
|
|
1304
|
-
}
|
|
1305
|
-
|
|
1772
|
+
};
|
|
1773
|
+
const mdPreviewEmits = ["onHtmlChanged", "onGetCatalog"];
|
|
1774
|
+
const editorEmits = [
|
|
1775
|
+
...mdPreviewEmits,
|
|
1306
1776
|
"onChange",
|
|
1307
1777
|
"onSave",
|
|
1308
1778
|
"onUploadImg",
|
|
@@ -1313,62 +1783,82 @@ const Be = (e, a) => {
|
|
|
1313
1783
|
"onInput",
|
|
1314
1784
|
"onDrop",
|
|
1315
1785
|
"onInputBoxWitdhChange"
|
|
1316
|
-
]
|
|
1317
|
-
|
|
1786
|
+
];
|
|
1787
|
+
const useExpose = (props, ctx) => {
|
|
1788
|
+
const { editorId } = props;
|
|
1789
|
+
const exposeParam = {
|
|
1318
1790
|
rerender() {
|
|
1319
|
-
|
|
1791
|
+
bus.emit(editorId, RERENDER);
|
|
1320
1792
|
}
|
|
1321
1793
|
};
|
|
1322
|
-
|
|
1323
|
-
}
|
|
1794
|
+
ctx.expose(exposeParam);
|
|
1795
|
+
};
|
|
1796
|
+
const MdPreview = /* @__PURE__ */ defineComponent({
|
|
1324
1797
|
name: "MdPreview",
|
|
1325
|
-
props:
|
|
1326
|
-
emits:
|
|
1327
|
-
setup(
|
|
1798
|
+
props: mdPreviewProps,
|
|
1799
|
+
emits: mdPreviewEmits,
|
|
1800
|
+
setup(props, ctx) {
|
|
1328
1801
|
const {
|
|
1329
|
-
editorId
|
|
1330
|
-
noKatex
|
|
1331
|
-
noMermaid
|
|
1332
|
-
noHighlight
|
|
1333
|
-
} =
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1802
|
+
editorId,
|
|
1803
|
+
noKatex,
|
|
1804
|
+
noMermaid,
|
|
1805
|
+
noHighlight
|
|
1806
|
+
} = props;
|
|
1807
|
+
useProvidePreview(props);
|
|
1808
|
+
useExpansionPreview(props);
|
|
1809
|
+
useExpose(props, ctx);
|
|
1810
|
+
onBeforeUnmount(() => {
|
|
1811
|
+
bus.clear(editorId);
|
|
1812
|
+
});
|
|
1813
|
+
return () => {
|
|
1814
|
+
return createVNode("div", {
|
|
1815
|
+
"id": editorId,
|
|
1816
|
+
"class": [prefix, props.class, props.theme === "dark" && `${prefix}-dark`, `${prefix}-previewOnly`],
|
|
1817
|
+
"style": props.style
|
|
1818
|
+
}, [createVNode(ContentPreview, {
|
|
1819
|
+
"modelValue": props.modelValue,
|
|
1820
|
+
"onHtmlChanged": (html) => {
|
|
1821
|
+
if (props.onHtmlChanged) {
|
|
1822
|
+
props.onHtmlChanged(html);
|
|
1823
|
+
} else {
|
|
1824
|
+
ctx.emit("onHtmlChanged", html);
|
|
1825
|
+
}
|
|
1826
|
+
},
|
|
1827
|
+
"onGetCatalog": (list) => {
|
|
1828
|
+
if (props.onGetCatalog) {
|
|
1829
|
+
props.onGetCatalog(list);
|
|
1830
|
+
} else {
|
|
1831
|
+
ctx.emit("onGetCatalog", list);
|
|
1832
|
+
}
|
|
1833
|
+
},
|
|
1834
|
+
"mdHeadingId": props.mdHeadingId,
|
|
1835
|
+
"noMermaid": noMermaid,
|
|
1836
|
+
"sanitize": props.sanitize,
|
|
1837
|
+
"noKatex": noKatex,
|
|
1838
|
+
"formatCopiedText": props.formatCopiedText,
|
|
1839
|
+
"noHighlight": noHighlight,
|
|
1840
|
+
"noImgZoomIn": props.noImgZoomIn,
|
|
1841
|
+
"previewOnly": true,
|
|
1842
|
+
"sanitizeMermaid": props.sanitizeMermaid
|
|
1843
|
+
}, null)]);
|
|
1844
|
+
};
|
|
1358
1845
|
}
|
|
1359
1846
|
});
|
|
1360
|
-
|
|
1847
|
+
MdPreview.install = (app) => {
|
|
1848
|
+
app.component(MdPreview.name, MdPreview);
|
|
1849
|
+
return app;
|
|
1850
|
+
};
|
|
1361
1851
|
export {
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1852
|
+
ContentPreview as C,
|
|
1853
|
+
MdPreview as M,
|
|
1854
|
+
editorEmits as a,
|
|
1855
|
+
useProvide as b,
|
|
1856
|
+
contentProps as c,
|
|
1857
|
+
useExpansion as d,
|
|
1858
|
+
editorProps as e,
|
|
1859
|
+
useErrorCatcher as f,
|
|
1860
|
+
useConfig as g,
|
|
1861
|
+
useCatalog as h,
|
|
1862
|
+
useExpose$1 as i,
|
|
1863
|
+
useOnSave as u
|
|
1374
1864
|
};
|