md-editor-v3 5.7.1 → 5.8.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.
- package/lib/cjs/DropdownToolbar.cjs +1 -1
- package/lib/cjs/MdCatalog.cjs +1 -1
- package/lib/cjs/MdEditor.cjs +7 -6
- package/lib/cjs/MdModal.cjs +1 -1
- package/lib/cjs/MdPreview.cjs +1 -1
- package/lib/cjs/ModalToolbar.cjs +1 -1
- package/lib/cjs/chunks/index.cjs +186 -2398
- package/lib/cjs/chunks/index2.cjs +285 -198
- package/lib/cjs/chunks/index3.cjs +2333 -525
- package/lib/cjs/chunks/index4.cjs +598 -281
- package/lib/cjs/index.cjs +6 -6
- package/lib/es/DropdownToolbar.mjs +1 -1
- package/lib/es/MdCatalog.mjs +1 -1
- package/lib/es/MdEditor.mjs +7 -6
- package/lib/es/MdModal.mjs +1 -1
- package/lib/es/MdPreview.mjs +1 -1
- package/lib/es/ModalToolbar.mjs +1 -1
- package/lib/es/chunks/index.mjs +188 -2400
- package/lib/es/chunks/index2.mjs +287 -200
- package/lib/es/chunks/index3.mjs +2337 -529
- package/lib/es/chunks/index4.mjs +601 -284
- package/lib/es/index.mjs +8 -8
- package/lib/types/config.d.ts +2 -2
- package/lib/types/index.d.ts +1 -6
- package/lib/types/preview.d.ts +6 -0
- package/lib/umd/index.js +2 -2
- package/lib/umd/preview.js +83 -0
- package/package.json +1 -1
|
@@ -1,448 +1,2333 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const vue = require("vue");
|
|
3
3
|
const config = require("./config.cjs");
|
|
4
|
-
const index = require("./index5.cjs");
|
|
5
4
|
const eventName = require("./event-name.cjs");
|
|
6
5
|
const util = require("@vavt/util");
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
6
|
+
const dom = require("./dom.cjs");
|
|
7
|
+
const mediumZoom = require("medium-zoom");
|
|
8
|
+
const copy2clipboard = require("@vavt/copy2clipboard");
|
|
9
|
+
const mdit = require("markdown-it");
|
|
10
|
+
const ImageFiguresPlugin = require("markdown-it-image-figures");
|
|
11
|
+
const SubPlugin = require("markdown-it-sub");
|
|
12
|
+
const SupPlugin = require("markdown-it-sup");
|
|
13
|
+
const index = require("./index5.cjs");
|
|
14
|
+
const lruCache = require("lru-cache");
|
|
15
|
+
const CDN_IDS = {
|
|
16
|
+
hljs: `${config.prefix}-hljs`,
|
|
17
|
+
hlcss: `${config.prefix}-hlCss`,
|
|
18
|
+
prettier: `${config.prefix}-prettier`,
|
|
19
|
+
prettierMD: `${config.prefix}-prettierMD`,
|
|
20
|
+
cropperjs: `${config.prefix}-cropper`,
|
|
21
|
+
croppercss: `${config.prefix}-cropperCss`,
|
|
22
|
+
screenfull: `${config.prefix}-screenfull`,
|
|
23
|
+
mermaidM: `${config.prefix}-mermaid-m`,
|
|
24
|
+
mermaid: `${config.prefix}-mermaid`,
|
|
25
|
+
katexjs: `${config.prefix}-katex`,
|
|
26
|
+
katexcss: `${config.prefix}-katexCss`
|
|
27
|
+
};
|
|
28
|
+
const userZoom = (props, html) => {
|
|
29
|
+
const editorId = vue.inject("editorId");
|
|
30
|
+
const { noImgZoomIn } = props;
|
|
31
|
+
const zoomHander = util.debounce(() => {
|
|
32
|
+
const imgs = document.querySelectorAll(
|
|
33
|
+
`#${editorId}-preview img:not(.not-zoom):not(.medium-zoom-image)`
|
|
34
|
+
);
|
|
35
|
+
if (imgs.length === 0) {
|
|
36
|
+
return;
|
|
38
37
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
() => {
|
|
47
|
-
pEle.removeEventListener("scroll", scrollHandler);
|
|
48
|
-
cEle.removeEventListener("scroll", scrollHandler);
|
|
38
|
+
mediumZoom(imgs, {
|
|
39
|
+
background: "#00000073"
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
vue.onMounted(() => {
|
|
43
|
+
if (!noImgZoomIn && props.setting.preview) {
|
|
44
|
+
zoomHander();
|
|
49
45
|
}
|
|
50
|
-
|
|
46
|
+
});
|
|
47
|
+
vue.watch([html, vue.toRef(props.setting, "preview")], () => {
|
|
48
|
+
if (!noImgZoomIn && props.setting.preview) {
|
|
49
|
+
zoomHander();
|
|
50
|
+
}
|
|
51
|
+
});
|
|
51
52
|
};
|
|
52
|
-
const
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
const
|
|
56
|
-
|
|
53
|
+
const useCopyCode = (props, html, key) => {
|
|
54
|
+
const editorId = vue.inject("editorId");
|
|
55
|
+
const rootRef = vue.inject("rootRef");
|
|
56
|
+
const ult = vue.inject("usedLanguageText");
|
|
57
|
+
const initCopyEntry = () => {
|
|
58
|
+
rootRef.value.querySelectorAll(`#${editorId} .${config.prefix}-preview .${config.prefix}-code`).forEach((codeBlock) => {
|
|
59
|
+
let clearTimer = -1;
|
|
60
|
+
const copyButton = codeBlock.querySelector(
|
|
61
|
+
`.${config.prefix}-copy-button`
|
|
62
|
+
);
|
|
63
|
+
if (copyButton)
|
|
64
|
+
copyButton.onclick = (e) => {
|
|
65
|
+
e.preventDefault();
|
|
66
|
+
clearTimeout(clearTimer);
|
|
67
|
+
const activeCode = codeBlock.querySelector("input:checked + pre code") || codeBlock.querySelector("pre code");
|
|
68
|
+
const codeText = activeCode.textContent;
|
|
69
|
+
const { text, successTips, failTips } = ult.value.copyCode;
|
|
70
|
+
let msg = successTips;
|
|
71
|
+
copy2clipboard(props.formatCopiedText(codeText)).catch(() => {
|
|
72
|
+
msg = failTips;
|
|
73
|
+
}).finally(() => {
|
|
74
|
+
if (copyButton.dataset.isIcon) {
|
|
75
|
+
copyButton.dataset.tips = msg;
|
|
76
|
+
} else {
|
|
77
|
+
copyButton.innerHTML = msg;
|
|
78
|
+
}
|
|
79
|
+
clearTimer = window.setTimeout(() => {
|
|
80
|
+
if (copyButton.dataset.isIcon) {
|
|
81
|
+
copyButton.dataset.tips = text;
|
|
82
|
+
} else {
|
|
83
|
+
copyButton.innerHTML = text;
|
|
84
|
+
}
|
|
85
|
+
}, 1500);
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
});
|
|
57
89
|
};
|
|
58
|
-
const
|
|
59
|
-
|
|
90
|
+
const htmlChanged = () => {
|
|
91
|
+
vue.nextTick(initCopyEntry);
|
|
60
92
|
};
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const buildMap = () => {
|
|
65
|
-
blockMap = [];
|
|
66
|
-
elesHasLineNumber = Array.from(
|
|
67
|
-
cEle.querySelectorAll(DATA_LINE_SELECTOR)
|
|
68
|
-
);
|
|
69
|
-
startLines = elesHasLineNumber.map((item) => Number(item.dataset.line));
|
|
70
|
-
const tempStartLines = [...startLines];
|
|
71
|
-
const { lines } = view.state.doc;
|
|
72
|
-
let start = tempStartLines.shift() || 0;
|
|
73
|
-
let end = tempStartLines.shift() || lines;
|
|
74
|
-
for (let i = 0; i < lines; i++) {
|
|
75
|
-
if (i === end) {
|
|
76
|
-
start = i;
|
|
77
|
-
end = tempStartLines.shift() || lines;
|
|
78
|
-
}
|
|
79
|
-
blockMap.push({
|
|
80
|
-
start,
|
|
81
|
-
end: end - 1
|
|
82
|
-
});
|
|
93
|
+
const settingPreviewChanged = (nVal) => {
|
|
94
|
+
if (nVal) {
|
|
95
|
+
vue.nextTick(initCopyEntry);
|
|
83
96
|
}
|
|
84
97
|
};
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
98
|
+
vue.watch([html, key], htmlChanged);
|
|
99
|
+
vue.watch(() => props.setting.preview, settingPreviewChanged);
|
|
100
|
+
vue.watch(() => props.setting.htmlPreview, settingPreviewChanged);
|
|
101
|
+
vue.onMounted(initCopyEntry);
|
|
102
|
+
};
|
|
103
|
+
const useHighlight = (props) => {
|
|
104
|
+
const highlight = vue.inject("highlight");
|
|
105
|
+
const hljsRef = vue.shallowRef(config.globalConfig.editorExtensions.highlight.instance);
|
|
106
|
+
vue.onMounted(() => {
|
|
107
|
+
if (props.noHighlight || hljsRef.value) {
|
|
108
|
+
return;
|
|
94
109
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
110
|
+
dom.appendHandler("link", {
|
|
111
|
+
...highlight.value.css,
|
|
112
|
+
rel: "stylesheet",
|
|
113
|
+
id: CDN_IDS.hlcss
|
|
114
|
+
});
|
|
115
|
+
dom.appendHandler(
|
|
116
|
+
"script",
|
|
117
|
+
{
|
|
118
|
+
...highlight.value.js,
|
|
119
|
+
id: CDN_IDS.hljs,
|
|
120
|
+
onload() {
|
|
121
|
+
hljsRef.value = window.hljs;
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
"hljs"
|
|
125
|
+
);
|
|
126
|
+
});
|
|
127
|
+
vue.watch(
|
|
128
|
+
() => highlight.value.css,
|
|
129
|
+
() => {
|
|
130
|
+
if (props.noHighlight || config.globalConfig.editorExtensions.highlight.instance) {
|
|
131
|
+
return;
|
|
101
132
|
}
|
|
133
|
+
dom.updateHandler("link", {
|
|
134
|
+
...highlight.value.css,
|
|
135
|
+
rel: "stylesheet",
|
|
136
|
+
id: CDN_IDS.hlcss
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
);
|
|
140
|
+
return hljsRef;
|
|
141
|
+
};
|
|
142
|
+
const mermaidCache = new lruCache.LRUCache({
|
|
143
|
+
max: 1e3,
|
|
144
|
+
// 缓存10分钟
|
|
145
|
+
ttl: 6e5
|
|
146
|
+
});
|
|
147
|
+
const useMermaid = (props) => {
|
|
148
|
+
const editorId = vue.inject("editorId");
|
|
149
|
+
const theme = vue.inject("theme");
|
|
150
|
+
const rootRef = vue.inject("rootRef");
|
|
151
|
+
const { editorExtensions, editorExtensionsAttrs, mermaidConfig } = config.globalConfig;
|
|
152
|
+
let mermaid = editorExtensions.mermaid.instance;
|
|
153
|
+
const reRenderRef = vue.shallowRef(-1);
|
|
154
|
+
const configMermaid = () => {
|
|
155
|
+
if (!props.noMermaid && mermaid) {
|
|
156
|
+
mermaid.initialize(
|
|
157
|
+
mermaidConfig({
|
|
158
|
+
startOnLoad: false,
|
|
159
|
+
theme: theme.value === "dark" ? "dark" : "default"
|
|
160
|
+
})
|
|
161
|
+
);
|
|
162
|
+
reRenderRef.value = reRenderRef.value + 1;
|
|
102
163
|
}
|
|
103
|
-
return lineNumer;
|
|
104
164
|
};
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
return false;
|
|
165
|
+
vue.watch(
|
|
166
|
+
() => theme.value,
|
|
167
|
+
() => {
|
|
168
|
+
mermaidCache.clear();
|
|
169
|
+
configMermaid();
|
|
111
170
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
const blockData = blockMap[currLine - 1];
|
|
118
|
-
if (!blockData) {
|
|
119
|
-
return false;
|
|
171
|
+
);
|
|
172
|
+
vue.onMounted(() => {
|
|
173
|
+
var _a, _b;
|
|
174
|
+
if (props.noMermaid || mermaid) {
|
|
175
|
+
return;
|
|
120
176
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
|
|
177
|
+
const jsSrc = editorExtensions.mermaid.js;
|
|
178
|
+
if (/\.mjs/.test(jsSrc)) {
|
|
179
|
+
dom.appendHandler("link", {
|
|
180
|
+
...(_a = editorExtensionsAttrs.mermaid) == null ? void 0 : _a.js,
|
|
181
|
+
rel: "modulepreload",
|
|
182
|
+
href: jsSrc,
|
|
183
|
+
id: CDN_IDS.mermaidM
|
|
184
|
+
});
|
|
185
|
+
import(
|
|
186
|
+
/* @vite-ignore */
|
|
187
|
+
/* webpackIgnore: true */
|
|
188
|
+
jsSrc
|
|
189
|
+
).then((module2) => {
|
|
190
|
+
mermaid = module2.default;
|
|
191
|
+
configMermaid();
|
|
192
|
+
});
|
|
193
|
+
} else {
|
|
194
|
+
dom.appendHandler(
|
|
195
|
+
"script",
|
|
196
|
+
{
|
|
197
|
+
...(_b = editorExtensionsAttrs.mermaid) == null ? void 0 : _b.js,
|
|
198
|
+
src: jsSrc,
|
|
199
|
+
id: CDN_IDS.mermaid,
|
|
200
|
+
onload() {
|
|
201
|
+
mermaid = window.mermaid;
|
|
202
|
+
configMermaid();
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
"mermaid"
|
|
206
|
+
);
|
|
139
207
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
if (
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
|
|
208
|
+
});
|
|
209
|
+
const replaceMermaid = async () => {
|
|
210
|
+
if (!props.noMermaid && mermaid) {
|
|
211
|
+
const mermaidSourceEles = rootRef.value.querySelectorAll(
|
|
212
|
+
`div.${config.prefix}-mermaid`
|
|
213
|
+
);
|
|
214
|
+
const svgContainingElement = document.createElement("div");
|
|
215
|
+
const sceWidth = document.body.offsetWidth > 1366 ? document.body.offsetWidth : 1366;
|
|
216
|
+
const sceHeight = document.body.offsetHeight > 768 ? document.body.offsetHeight : 768;
|
|
217
|
+
svgContainingElement.style.width = sceWidth + "px";
|
|
218
|
+
svgContainingElement.style.height = sceHeight + "px";
|
|
219
|
+
svgContainingElement.style.position = "fixed";
|
|
220
|
+
svgContainingElement.style.zIndex = "-10000";
|
|
221
|
+
svgContainingElement.style.top = "-10000";
|
|
222
|
+
let count = mermaidSourceEles.length;
|
|
223
|
+
if (count > 0) {
|
|
224
|
+
document.body.appendChild(svgContainingElement);
|
|
149
225
|
}
|
|
150
|
-
|
|
226
|
+
await Promise.allSettled(
|
|
227
|
+
Array.from(mermaidSourceEles).map((ele) => {
|
|
228
|
+
const handler = async (item) => {
|
|
229
|
+
var _a;
|
|
230
|
+
const code = item.innerText;
|
|
231
|
+
let mermaidHtml = mermaidCache.get(code);
|
|
232
|
+
if (!mermaidHtml) {
|
|
233
|
+
const idRand = util.randomId();
|
|
234
|
+
let result = { svg: "" };
|
|
235
|
+
try {
|
|
236
|
+
result = await mermaid.render(idRand, code, svgContainingElement);
|
|
237
|
+
mermaidHtml = await props.sanitizeMermaid(result.svg);
|
|
238
|
+
const p = document.createElement("p");
|
|
239
|
+
p.className = `${config.prefix}-mermaid`;
|
|
240
|
+
p.setAttribute("data-processed", "");
|
|
241
|
+
p.innerHTML = mermaidHtml;
|
|
242
|
+
(_a = p.children[0]) == null ? void 0 : _a.removeAttribute("height");
|
|
243
|
+
mermaidCache.set(code, p.innerHTML);
|
|
244
|
+
if (item.dataset.line !== void 0) {
|
|
245
|
+
p.dataset.line = item.dataset.line;
|
|
246
|
+
}
|
|
247
|
+
item.replaceWith(p);
|
|
248
|
+
} catch (error) {
|
|
249
|
+
eventName.bus.emit(editorId, eventName.ERROR_CATCHER, {
|
|
250
|
+
name: "mermaid",
|
|
251
|
+
message: error.message,
|
|
252
|
+
error
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
if (--count === 0) {
|
|
256
|
+
svgContainingElement.remove();
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
return handler(ele);
|
|
261
|
+
})
|
|
262
|
+
);
|
|
151
263
|
}
|
|
152
|
-
const scrollToTop = startEleOffetTop - cElePaddingTop + blockHeight * scale;
|
|
153
|
-
smoothScroll(cEle, scrollToTop, () => {
|
|
154
|
-
pLock--;
|
|
155
|
-
});
|
|
156
264
|
};
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
265
|
+
return { reRenderRef, replaceMermaid };
|
|
266
|
+
};
|
|
267
|
+
const useKatex = (props) => {
|
|
268
|
+
const katex = vue.shallowRef(config.globalConfig.editorExtensions.katex.instance);
|
|
269
|
+
vue.onMounted(() => {
|
|
270
|
+
if (props.noKatex || katex.value) {
|
|
160
271
|
return;
|
|
161
272
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
273
|
+
const { editorExtensions } = config.globalConfig;
|
|
274
|
+
dom.appendHandler(
|
|
275
|
+
"script",
|
|
276
|
+
{
|
|
277
|
+
src: editorExtensions.katex.js,
|
|
278
|
+
id: CDN_IDS.katexjs,
|
|
279
|
+
onload() {
|
|
280
|
+
katex.value = window.katex;
|
|
281
|
+
}
|
|
282
|
+
},
|
|
283
|
+
"katex"
|
|
284
|
+
);
|
|
285
|
+
dom.appendHandler("link", {
|
|
286
|
+
rel: "stylesheet",
|
|
287
|
+
href: editorExtensions.katex.css,
|
|
288
|
+
id: CDN_IDS.katexcss
|
|
289
|
+
});
|
|
290
|
+
});
|
|
291
|
+
return katex;
|
|
292
|
+
};
|
|
293
|
+
const MermaidPlugin = (md, options) => {
|
|
294
|
+
const temp = md.renderer.rules.fence.bind(md.renderer.rules);
|
|
295
|
+
md.renderer.rules.fence = (tokens, idx, ops, env, slf) => {
|
|
296
|
+
const token = tokens[idx];
|
|
297
|
+
const code = token.content.trim();
|
|
298
|
+
if (token.info === "mermaid") {
|
|
299
|
+
let line;
|
|
300
|
+
if (tokens[idx].map && tokens[idx].level === 0) {
|
|
301
|
+
line = tokens[idx].map[0];
|
|
302
|
+
tokens[idx].attrSet("data-line", String(line));
|
|
303
|
+
}
|
|
304
|
+
const mermaidHtml = mermaidCache.get(code);
|
|
305
|
+
if (mermaidHtml) {
|
|
306
|
+
return `<p class="${config.prefix}-mermaid" ${line !== void 0 ? "data-line=" + line : ""} data-processed>${mermaidHtml}</p>`;
|
|
307
|
+
}
|
|
308
|
+
return `<div class="${config.prefix}-mermaid" ${line !== void 0 ? "data-line=" + line : ""} data-mermaid-theme=${options.themeRef.value}">${md.utils.escapeHtml(code)}</div>`;
|
|
309
|
+
}
|
|
310
|
+
return temp(tokens, idx, ops, env, slf);
|
|
311
|
+
};
|
|
312
|
+
};
|
|
313
|
+
const mergeAttrs = (token, addAttrs) => {
|
|
314
|
+
const tmpAttrs = token.attrs ? token.attrs.slice() : [];
|
|
315
|
+
addAttrs.forEach((addAttr) => {
|
|
316
|
+
const i = token.attrIndex(addAttr[0]);
|
|
317
|
+
if (i < 0) {
|
|
318
|
+
tmpAttrs.push(addAttr);
|
|
319
|
+
} else {
|
|
320
|
+
tmpAttrs[i] = tmpAttrs[i].slice();
|
|
321
|
+
tmpAttrs[i][1] += ` ${addAttr[1]}`;
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
return tmpAttrs;
|
|
325
|
+
};
|
|
326
|
+
const delimiters = {
|
|
327
|
+
block: [
|
|
328
|
+
{ open: "$$", close: "$$" },
|
|
329
|
+
{ open: "\\[", close: "\\]" }
|
|
330
|
+
],
|
|
331
|
+
inline: [
|
|
332
|
+
{ open: "$$", close: "$$" },
|
|
333
|
+
{ open: "$", close: "$" },
|
|
334
|
+
{ open: "\\[", close: "\\]" },
|
|
335
|
+
{ open: "\\(", close: "\\)" }
|
|
336
|
+
]
|
|
337
|
+
};
|
|
338
|
+
const create_math_inline = (options) => (state, silent) => {
|
|
339
|
+
const delimiters2 = options.delimiters;
|
|
340
|
+
let match, token, pos;
|
|
341
|
+
for (const delim of delimiters2) {
|
|
342
|
+
if (state.src.startsWith(delim.open, state.pos)) {
|
|
343
|
+
const start = state.pos + delim.open.length;
|
|
344
|
+
match = start;
|
|
345
|
+
while ((match = state.src.indexOf(delim.close, match)) !== -1) {
|
|
346
|
+
pos = match - 1;
|
|
347
|
+
while (state.src[pos] === "\\") {
|
|
348
|
+
pos -= 1;
|
|
349
|
+
}
|
|
350
|
+
if ((match - pos) % 2 === 1) {
|
|
194
351
|
break;
|
|
195
352
|
}
|
|
353
|
+
match += delim.close.length;
|
|
354
|
+
}
|
|
355
|
+
if (match === -1) {
|
|
356
|
+
if (!silent) {
|
|
357
|
+
state.pending += delim.open;
|
|
358
|
+
}
|
|
359
|
+
state.pos = start;
|
|
360
|
+
return true;
|
|
361
|
+
}
|
|
362
|
+
if (match - start === 0) {
|
|
363
|
+
if (!silent) {
|
|
364
|
+
state.pending += delim.open + delim.close;
|
|
365
|
+
}
|
|
366
|
+
state.pos = start + delim.close.length;
|
|
367
|
+
return true;
|
|
196
368
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
369
|
+
if (!silent) {
|
|
370
|
+
const inlineContent = state.src.slice(start, match);
|
|
371
|
+
token = state.push("math_inline", "math", 0);
|
|
372
|
+
token.markup = delim.open;
|
|
373
|
+
token.content = inlineContent;
|
|
374
|
+
}
|
|
375
|
+
state.pos = match + delim.close.length;
|
|
376
|
+
return true;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
return false;
|
|
380
|
+
};
|
|
381
|
+
const create_math_block = (options) => (state, start, end, silent) => {
|
|
382
|
+
const delimiters2 = options.delimiters;
|
|
383
|
+
let firstLine, lastLine, next, lastPos, found = false;
|
|
384
|
+
let pos = state.bMarks[start] + state.tShift[start];
|
|
385
|
+
let max = state.eMarks[start];
|
|
386
|
+
for (const delim of delimiters2) {
|
|
387
|
+
if (state.src.slice(pos, pos + delim.open.length) === delim.open && state.src.slice(max - delim.close.length, max) === delim.close) {
|
|
388
|
+
pos += delim.open.length;
|
|
389
|
+
firstLine = state.src.slice(pos, max);
|
|
390
|
+
if (silent) {
|
|
391
|
+
return true;
|
|
392
|
+
}
|
|
393
|
+
if (firstLine.trim().slice(-delim.close.length) === delim.close) {
|
|
394
|
+
firstLine = firstLine.trim().slice(0, -delim.close.length);
|
|
395
|
+
found = true;
|
|
396
|
+
}
|
|
397
|
+
for (next = start; !found; ) {
|
|
398
|
+
next++;
|
|
399
|
+
if (next >= end) {
|
|
201
400
|
break;
|
|
202
401
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
402
|
+
pos = state.bMarks[next] + state.tShift[next];
|
|
403
|
+
max = state.eMarks[next];
|
|
404
|
+
if (pos < max && state.tShift[next] < state.blkIndent) {
|
|
206
405
|
break;
|
|
207
406
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
407
|
+
if (state.src.slice(pos, max).trim().slice(-delim.close.length) === delim.close) {
|
|
408
|
+
lastPos = state.src.slice(0, max).lastIndexOf(delim.close);
|
|
409
|
+
lastLine = state.src.slice(pos, lastPos);
|
|
410
|
+
found = true;
|
|
211
411
|
}
|
|
212
412
|
}
|
|
413
|
+
state.line = next + 1;
|
|
414
|
+
const token = state.push("math_block", "math", 0);
|
|
415
|
+
token.block = true;
|
|
416
|
+
token.content = (firstLine && firstLine.trim() ? firstLine + "\n" : "") + state.getLines(start + 1, next, state.tShift[start], true) + (lastLine && lastLine.trim() ? lastLine : "");
|
|
417
|
+
token.map = [start, state.line];
|
|
418
|
+
token.markup = delim.open;
|
|
419
|
+
return true;
|
|
213
420
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
const
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
if (
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
if (realEleStart === realEleEnd) {
|
|
232
|
-
eleEndOffsetTop = realEleEnd.offsetTop + realEleEnd.offsetHeight + +getComputedStyle(realEleEnd).marginBottom.replace("px", "");
|
|
233
|
-
blockHeight = endLineScrollTop;
|
|
234
|
-
} else {
|
|
235
|
-
blockHeight = endLineScrollTop;
|
|
236
|
-
}
|
|
237
|
-
scale = Math.max(cScrollTop / eleEndOffsetTop, 0);
|
|
421
|
+
}
|
|
422
|
+
return false;
|
|
423
|
+
};
|
|
424
|
+
const KatexPlugin = (md, { katexRef, inlineDelimiters, blockDelimiters }) => {
|
|
425
|
+
const katexInline = (tokens, idx, options, env, slf) => {
|
|
426
|
+
const token = tokens[idx];
|
|
427
|
+
const tmpToken = {
|
|
428
|
+
attrs: mergeAttrs(token, [["class", `${config.prefix}-katex-inline`]])
|
|
429
|
+
};
|
|
430
|
+
if (katexRef.value) {
|
|
431
|
+
const html = katexRef.value.renderToString(
|
|
432
|
+
token.content,
|
|
433
|
+
config.globalConfig.katexConfig({
|
|
434
|
+
throwOnError: false
|
|
435
|
+
})
|
|
436
|
+
);
|
|
437
|
+
return `<span ${slf.renderAttrs(tmpToken)} data-processed>${html}</span>`;
|
|
238
438
|
} else {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
439
|
+
return `<span ${slf.renderAttrs(tmpToken)}>${token.content}</span>`;
|
|
440
|
+
}
|
|
441
|
+
};
|
|
442
|
+
const katexBlock = (tokens, idx, options, env, slf) => {
|
|
443
|
+
const token = tokens[idx];
|
|
444
|
+
const tmpToken = {
|
|
445
|
+
attrs: mergeAttrs(token, [["class", `${config.prefix}-katex-block`]])
|
|
446
|
+
};
|
|
447
|
+
if (katexRef.value) {
|
|
448
|
+
const html = katexRef.value.renderToString(
|
|
449
|
+
token.content,
|
|
450
|
+
config.globalConfig.katexConfig({
|
|
451
|
+
throwOnError: false,
|
|
452
|
+
displayMode: true
|
|
453
|
+
})
|
|
242
454
|
);
|
|
243
|
-
|
|
455
|
+
return `<p ${slf.renderAttrs(tmpToken)} data-processed>${html}</p>`;
|
|
456
|
+
} else {
|
|
457
|
+
return `<p ${slf.renderAttrs(tmpToken)}>${token.content}</p>`;
|
|
458
|
+
}
|
|
459
|
+
};
|
|
460
|
+
md.inline.ruler.before(
|
|
461
|
+
"escape",
|
|
462
|
+
"math_inline",
|
|
463
|
+
create_math_inline({
|
|
464
|
+
delimiters: inlineDelimiters || delimiters.inline
|
|
465
|
+
})
|
|
466
|
+
);
|
|
467
|
+
md.block.ruler.after(
|
|
468
|
+
"blockquote",
|
|
469
|
+
"math_block",
|
|
470
|
+
create_math_block({
|
|
471
|
+
delimiters: blockDelimiters || delimiters.block
|
|
472
|
+
}),
|
|
473
|
+
{
|
|
474
|
+
alt: ["paragraph", "reference", "blockquote", "list"]
|
|
475
|
+
}
|
|
476
|
+
);
|
|
477
|
+
md.renderer.rules.math_inline = katexInline;
|
|
478
|
+
md.renderer.rules.math_block = katexBlock;
|
|
479
|
+
};
|
|
480
|
+
const AdmonitionPlugin = (md, options) => {
|
|
481
|
+
options = options || {};
|
|
482
|
+
const markers = 3, markerStr = options.marker || "!", markerChar = markerStr.charCodeAt(0), markerLen = markerStr.length;
|
|
483
|
+
let type = "", title = "";
|
|
484
|
+
const render = (tokens, idx, _options, _env, self) => {
|
|
485
|
+
const token = tokens[idx];
|
|
486
|
+
if (token.type === "admonition_open") {
|
|
487
|
+
tokens[idx].attrPush([
|
|
488
|
+
"class",
|
|
489
|
+
`${config.prefix}-admonition ${config.prefix}-admonition-${token.info}`
|
|
490
|
+
]);
|
|
491
|
+
} else if (token.type === "admonition_title_open") {
|
|
492
|
+
tokens[idx].attrPush(["class", `${config.prefix}-admonition-title`]);
|
|
493
|
+
}
|
|
494
|
+
return self.renderToken(tokens, idx, _options);
|
|
495
|
+
};
|
|
496
|
+
const validate = (params) => {
|
|
497
|
+
const array = params.trim().split(" ", 2);
|
|
498
|
+
title = "";
|
|
499
|
+
type = array[0];
|
|
500
|
+
if (array.length > 1) {
|
|
501
|
+
title = params.substring(type.length + 2);
|
|
502
|
+
}
|
|
503
|
+
};
|
|
504
|
+
md.block.ruler.before(
|
|
505
|
+
"code",
|
|
506
|
+
"admonition",
|
|
507
|
+
(state, startLine, endLine, silent) => {
|
|
508
|
+
let pos, nextLine, token, autoClosed = false, start = state.bMarks[startLine] + state.tShift[startLine], max = state.eMarks[startLine];
|
|
509
|
+
if (markerChar !== state.src.charCodeAt(start)) {
|
|
510
|
+
return false;
|
|
511
|
+
}
|
|
512
|
+
for (pos = start + 1; pos <= max; pos++) {
|
|
513
|
+
if (markerStr[(pos - start) % markerLen] !== state.src[pos]) {
|
|
514
|
+
break;
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
const markerCount = Math.floor((pos - start) / markerLen);
|
|
518
|
+
if (markerCount !== markers) {
|
|
519
|
+
return false;
|
|
520
|
+
}
|
|
521
|
+
pos -= (pos - start) % markerLen;
|
|
522
|
+
const markup = state.src.slice(start, pos);
|
|
523
|
+
const params = state.src.slice(pos, max);
|
|
524
|
+
validate(params);
|
|
525
|
+
if (silent) {
|
|
526
|
+
return true;
|
|
527
|
+
}
|
|
528
|
+
nextLine = startLine;
|
|
529
|
+
for (; ; ) {
|
|
530
|
+
nextLine++;
|
|
531
|
+
if (nextLine >= endLine) {
|
|
532
|
+
break;
|
|
533
|
+
}
|
|
534
|
+
start = state.bMarks[nextLine] + state.tShift[nextLine];
|
|
535
|
+
max = state.eMarks[nextLine];
|
|
536
|
+
if (start < max && state.sCount[nextLine] < state.blkIndent) {
|
|
537
|
+
break;
|
|
538
|
+
}
|
|
539
|
+
if (markerChar !== state.src.charCodeAt(start)) {
|
|
540
|
+
continue;
|
|
541
|
+
}
|
|
542
|
+
if (state.sCount[nextLine] - state.blkIndent >= 4) {
|
|
543
|
+
continue;
|
|
544
|
+
}
|
|
545
|
+
for (pos = start + 1; pos <= max; pos++) {
|
|
546
|
+
if (markerStr[(pos - start) % markerLen] !== state.src[pos]) {
|
|
547
|
+
break;
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
if (Math.floor((pos - start) / markerLen) < markerCount) {
|
|
551
|
+
continue;
|
|
552
|
+
}
|
|
553
|
+
pos -= (pos - start) % markerLen;
|
|
554
|
+
pos = state.skipSpaces(pos);
|
|
555
|
+
if (pos < max) {
|
|
556
|
+
continue;
|
|
557
|
+
}
|
|
558
|
+
autoClosed = true;
|
|
559
|
+
break;
|
|
560
|
+
}
|
|
561
|
+
const oldParent = state.parentType;
|
|
562
|
+
const oldLineMax = state.lineMax;
|
|
563
|
+
state.parentType = "root";
|
|
564
|
+
state.lineMax = nextLine;
|
|
565
|
+
token = state.push("admonition_open", "div", 1);
|
|
566
|
+
token.markup = markup;
|
|
567
|
+
token.block = true;
|
|
568
|
+
token.info = type;
|
|
569
|
+
token.map = [startLine, nextLine];
|
|
570
|
+
if (title) {
|
|
571
|
+
token = state.push("admonition_title_open", "p", 1);
|
|
572
|
+
token.markup = markup + " " + type;
|
|
573
|
+
token.map = [startLine, nextLine];
|
|
574
|
+
token = state.push("inline", "", 0);
|
|
575
|
+
token.content = title;
|
|
576
|
+
token.map = [startLine, state.line - 1];
|
|
577
|
+
token.children = [];
|
|
578
|
+
token = state.push("admonition_title_close", "p", -1);
|
|
579
|
+
token.markup = markup + " " + type;
|
|
580
|
+
}
|
|
581
|
+
state.md.block.tokenize(state, startLine + 1, nextLine);
|
|
582
|
+
token = state.push("admonition_close", "div", -1);
|
|
583
|
+
token.markup = state.src.slice(start, pos);
|
|
584
|
+
token.block = true;
|
|
585
|
+
state.parentType = oldParent;
|
|
586
|
+
state.lineMax = oldLineMax;
|
|
587
|
+
state.line = nextLine + (autoClosed ? 1 : 0);
|
|
588
|
+
return true;
|
|
589
|
+
},
|
|
590
|
+
{
|
|
591
|
+
alt: ["paragraph", "reference", "blockquote", "list"]
|
|
244
592
|
}
|
|
245
|
-
|
|
246
|
-
|
|
593
|
+
);
|
|
594
|
+
md.renderer.rules["admonition_open"] = render;
|
|
595
|
+
md.renderer.rules["admonition_title_open"] = render;
|
|
596
|
+
md.renderer.rules["admonition_title_close"] = render;
|
|
597
|
+
md.renderer.rules["admonition_close"] = render;
|
|
598
|
+
};
|
|
599
|
+
const HeadingPlugin = (md, options) => {
|
|
600
|
+
md.renderer.rules.heading_open = (tokens, idx) => {
|
|
601
|
+
var _a;
|
|
602
|
+
const token = tokens[idx];
|
|
603
|
+
const text = ((_a = tokens[idx + 1].children) == null ? void 0 : _a.reduce((p, c) => {
|
|
604
|
+
return p + (["text", "code_inline", "math_inline"].includes(c.type) ? c.content || "" : "");
|
|
605
|
+
}, "")) || "";
|
|
606
|
+
const level = token.markup.length;
|
|
607
|
+
options.headsRef.value.push({
|
|
608
|
+
text,
|
|
609
|
+
level,
|
|
610
|
+
line: token.map[0]
|
|
247
611
|
});
|
|
612
|
+
if (token.map && token.level === 0) {
|
|
613
|
+
token.attrSet(
|
|
614
|
+
"id",
|
|
615
|
+
options.mdHeadingId(text, level, options.headsRef.value.length)
|
|
616
|
+
);
|
|
617
|
+
}
|
|
618
|
+
return md.renderer.renderToken(tokens, idx, options);
|
|
619
|
+
};
|
|
620
|
+
md.renderer.rules.heading_close = (tokens, idx, opts, _env, self) => {
|
|
621
|
+
return self.renderToken(tokens, idx, opts);
|
|
622
|
+
};
|
|
623
|
+
};
|
|
624
|
+
const codetabs = (md, _opts) => {
|
|
625
|
+
const defaultRender = md.renderer.rules.fence, unescapeAll = md.utils.unescapeAll, re = /\[(\w*)(?::([\w ]*))?\]/, mandatoryRe = /::(open|close)/;
|
|
626
|
+
const getInfo = (token) => {
|
|
627
|
+
return token.info ? unescapeAll(token.info).trim() : "";
|
|
628
|
+
};
|
|
629
|
+
const getGroupAndTab = (token) => {
|
|
630
|
+
const info = getInfo(token), [group = null, tab = ""] = (re.exec(info) || []).slice(1);
|
|
631
|
+
return [group, tab];
|
|
632
|
+
};
|
|
633
|
+
const getLangName = (token) => {
|
|
634
|
+
const info = getInfo(token);
|
|
635
|
+
return info ? info.split(/(\s+)/g)[0] : "";
|
|
248
636
|
};
|
|
249
|
-
const
|
|
637
|
+
const getTagType = (token) => {
|
|
638
|
+
const mandatory = token.info.match(mandatoryRe) || [];
|
|
639
|
+
const open = mandatory[1] === "open" || mandatory[1] !== "close" && _opts.codeFoldable && token.content.trim().split("\n").length < _opts.autoFoldThreshold;
|
|
640
|
+
const tagContainer = mandatory[1] || _opts.codeFoldable ? "details" : "div", tagHeader = mandatory[1] || _opts.codeFoldable ? "summary" : "div";
|
|
641
|
+
return { open, tagContainer, tagHeader };
|
|
642
|
+
};
|
|
643
|
+
const fenceGroup = (tokens, idx, options, env, slf) => {
|
|
250
644
|
var _a;
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
if (contentHeight <= scrollDomHeight || cEle.firstElementChild.clientHeight <= cEle.clientHeight) {
|
|
254
|
-
return false;
|
|
645
|
+
if (tokens[idx].hidden) {
|
|
646
|
+
return "";
|
|
255
647
|
}
|
|
256
|
-
|
|
257
|
-
|
|
648
|
+
const codeCodeText = (_a = _opts.usedLanguageTextRef.value) == null ? void 0 : _a.copyCode.text;
|
|
649
|
+
const copyBtnHtml = _opts.customIconRef.value.copy || codeCodeText;
|
|
650
|
+
const isIcon = !!_opts.customIconRef.value.copy;
|
|
651
|
+
const collapseTips = `<span class="${config.prefix}-collapse-tips">${dom.StrIcon("collapse-tips", _opts.customIconRef.value)}</span>`;
|
|
652
|
+
const [GROUP] = getGroupAndTab(tokens[idx]);
|
|
653
|
+
if (GROUP === null) {
|
|
654
|
+
const { open: open2, tagContainer: tagContainer2, tagHeader: tagHeader2 } = getTagType(tokens[idx]);
|
|
655
|
+
const addAttrs2 = [["class", `${config.prefix}-code`]];
|
|
656
|
+
if (open2) addAttrs2.push(["open", ""]);
|
|
657
|
+
const tmpToken2 = {
|
|
658
|
+
attrs: mergeAttrs(tokens[idx], addAttrs2)
|
|
659
|
+
};
|
|
660
|
+
tokens[idx].info = tokens[idx].info.replace(mandatoryRe, "");
|
|
661
|
+
const codeRendered = defaultRender(tokens, idx, options, env, slf);
|
|
662
|
+
return `
|
|
663
|
+
<${tagContainer2} ${slf.renderAttrs(tmpToken2)}>
|
|
664
|
+
<${tagHeader2} class="${config.prefix}-code-head">
|
|
665
|
+
<div class="${config.prefix}-code-flag"><span></span><span></span><span></span></div>
|
|
666
|
+
<div class="${config.prefix}-code-action">
|
|
667
|
+
<span class="${config.prefix}-code-lang">${tokens[idx].info.trim()}</span>
|
|
668
|
+
<span class="${config.prefix}-copy-button" data-tips="${codeCodeText}"${isIcon ? " data-is-icon=true" : ""}>${copyBtnHtml}</span>
|
|
669
|
+
${_opts.extraTools instanceof Function ? _opts.extraTools({ lang: tokens[idx].info.trim() }) : _opts.extraTools || ""}
|
|
670
|
+
${tagContainer2 === "details" ? collapseTips : ""}
|
|
671
|
+
</div>
|
|
672
|
+
</${tagHeader2}>
|
|
673
|
+
${codeRendered}
|
|
674
|
+
</${tagContainer2}>
|
|
675
|
+
`;
|
|
676
|
+
}
|
|
677
|
+
let token, group, tab, checked, labels = "", pres = "", langs = "";
|
|
678
|
+
const { open, tagContainer, tagHeader } = getTagType(tokens[idx]);
|
|
679
|
+
const addAttrs = [["class", `${config.prefix}-code`]];
|
|
680
|
+
if (open) addAttrs.push(["open", ""]);
|
|
681
|
+
const tmpToken = {
|
|
682
|
+
attrs: mergeAttrs(tokens[idx], addAttrs)
|
|
683
|
+
};
|
|
684
|
+
for (let i = idx; i < tokens.length; i++) {
|
|
685
|
+
token = tokens[i];
|
|
686
|
+
[group, tab] = getGroupAndTab(token);
|
|
687
|
+
if (group !== GROUP) {
|
|
688
|
+
break;
|
|
689
|
+
}
|
|
690
|
+
token.info = token.info.replace(re, "").replace(mandatoryRe, "");
|
|
691
|
+
token.hidden = true;
|
|
692
|
+
const className = `${config.prefix}-codetab-${_opts.editorId}-${idx}-${i - idx}`;
|
|
693
|
+
checked = i - idx > 0 ? "" : "checked";
|
|
694
|
+
labels += `
|
|
695
|
+
<li>
|
|
696
|
+
<input
|
|
697
|
+
type="radio"
|
|
698
|
+
id="label-${config.prefix}-codetab-label-1-${_opts.editorId}-${idx}-${i - idx}"
|
|
699
|
+
name="${config.prefix}-codetab-label-${_opts.editorId}-${idx}"
|
|
700
|
+
class="${className}"
|
|
701
|
+
${checked}
|
|
702
|
+
>
|
|
703
|
+
<label
|
|
704
|
+
for="label-${config.prefix}-codetab-label-1-${_opts.editorId}-${idx}-${i - idx}"
|
|
705
|
+
onclick="this.getRootNode().querySelectorAll('.${className}').forEach(e => e.click())"
|
|
706
|
+
>
|
|
707
|
+
${tab || getLangName(token)}
|
|
708
|
+
</label>
|
|
709
|
+
</li>`;
|
|
710
|
+
pres += `
|
|
711
|
+
<div role="tabpanel">
|
|
712
|
+
<input
|
|
713
|
+
type="radio"
|
|
714
|
+
name="${config.prefix}-codetab-pre-${_opts.editorId}-${idx}"
|
|
715
|
+
class="${className}"
|
|
716
|
+
${checked}
|
|
717
|
+
role="presentation">
|
|
718
|
+
${defaultRender(tokens, i, options, env, slf)}
|
|
719
|
+
</div>`;
|
|
720
|
+
langs += `
|
|
721
|
+
<input
|
|
722
|
+
type="radio"
|
|
723
|
+
name="${config.prefix}-codetab-lang-${_opts.editorId}-${idx}"
|
|
724
|
+
class="${className}"
|
|
725
|
+
${checked}
|
|
726
|
+
role="presentation">
|
|
727
|
+
<span class=${config.prefix}-code-lang role="note">${getLangName(token)}</span>`;
|
|
728
|
+
}
|
|
729
|
+
return `
|
|
730
|
+
<${tagContainer} ${slf.renderAttrs(tmpToken)}>
|
|
731
|
+
<${tagHeader} class="${config.prefix}-code-head">
|
|
732
|
+
<div class="${config.prefix}-code-flag">
|
|
733
|
+
<ul class="${config.prefix}-codetab-label" role="tablist">${labels}</ul>
|
|
734
|
+
</div>
|
|
735
|
+
<div class="${config.prefix}-code-action">
|
|
736
|
+
<span class="${config.prefix}-codetab-lang">${langs}</span>
|
|
737
|
+
<span class="${config.prefix}-copy-button" data-tips="${codeCodeText}"${isIcon ? " data-is-icon=true" : ""}>${copyBtnHtml}</span>
|
|
738
|
+
${_opts.extraTools instanceof Function ? _opts.extraTools({ lang: tokens[idx].info.trim() }) : _opts.extraTools || ""}
|
|
739
|
+
${tagContainer === "details" ? collapseTips : ""}
|
|
740
|
+
</div>
|
|
741
|
+
</${tagHeader}>
|
|
742
|
+
${pres}
|
|
743
|
+
</${tagContainer}>
|
|
744
|
+
`;
|
|
745
|
+
};
|
|
746
|
+
md.renderer.rules.fence = fenceGroup;
|
|
747
|
+
md.renderer.rules.code_block = fenceGroup;
|
|
748
|
+
};
|
|
749
|
+
const attrSet = (token, name, value) => {
|
|
750
|
+
const index2 = token.attrIndex(name);
|
|
751
|
+
const attr = [name, value];
|
|
752
|
+
if (index2 < 0) {
|
|
753
|
+
token.attrPush(attr);
|
|
754
|
+
} else {
|
|
755
|
+
token.attrs = token.attrs || [];
|
|
756
|
+
token.attrs[index2] = attr;
|
|
757
|
+
}
|
|
758
|
+
};
|
|
759
|
+
const isInline = (token) => {
|
|
760
|
+
return token.type === "inline";
|
|
761
|
+
};
|
|
762
|
+
const isParagraph = (token) => {
|
|
763
|
+
return token.type === "paragraph_open";
|
|
764
|
+
};
|
|
765
|
+
const isListItem = (token) => {
|
|
766
|
+
return token.type === "list_item_open";
|
|
767
|
+
};
|
|
768
|
+
const startsWithTodoMarkdown = (token) => {
|
|
769
|
+
return token.content.indexOf("[ ] ") === 0 || token.content.indexOf("[x] ") === 0 || token.content.indexOf("[X] ") === 0;
|
|
770
|
+
};
|
|
771
|
+
const isTodoItem = (tokens, index2) => {
|
|
772
|
+
return isInline(tokens[index2]) && isParagraph(tokens[index2 - 1]) && isListItem(tokens[index2 - 2]) && startsWithTodoMarkdown(tokens[index2]);
|
|
773
|
+
};
|
|
774
|
+
const parentToken = (tokens, index2) => {
|
|
775
|
+
const targetLevel = tokens[index2].level - 1;
|
|
776
|
+
for (let i = index2 - 1; i >= 0; i--) {
|
|
777
|
+
if (tokens[i].level === targetLevel) {
|
|
778
|
+
return i;
|
|
258
779
|
}
|
|
259
|
-
|
|
260
|
-
|
|
780
|
+
}
|
|
781
|
+
return -1;
|
|
782
|
+
};
|
|
783
|
+
const beginLabel = (TokenConstructor) => {
|
|
784
|
+
const token = new TokenConstructor("html_inline", "", 0);
|
|
785
|
+
token.content = "<label>";
|
|
786
|
+
return token;
|
|
787
|
+
};
|
|
788
|
+
const endLabel = (TokenConstructor) => {
|
|
789
|
+
const token = new TokenConstructor("html_inline", "", 0);
|
|
790
|
+
token.content = "</label>";
|
|
791
|
+
return token;
|
|
792
|
+
};
|
|
793
|
+
const afterLabel = (content, id, TokenConstructor) => {
|
|
794
|
+
const token = new TokenConstructor("html_inline", "", 0);
|
|
795
|
+
token.content = '<label class="task-list-item-label" for="' + id + '">' + content + "</label>";
|
|
796
|
+
token.attrs = [{ for: id }];
|
|
797
|
+
return token;
|
|
798
|
+
};
|
|
799
|
+
const makeCheckbox = (token, TokenConstructor, options) => {
|
|
800
|
+
const checkbox = new TokenConstructor("html_inline", "", 0);
|
|
801
|
+
const disabledAttr = !options.enabled ? ' disabled="" ' : " ";
|
|
802
|
+
if (token.content.indexOf("[ ] ") === 0) {
|
|
803
|
+
checkbox.content = '<input class="task-list-item-checkbox"' + disabledAttr + 'type="checkbox">';
|
|
804
|
+
} else if (token.content.indexOf("[x] ") === 0 || token.content.indexOf("[X] ") === 0) {
|
|
805
|
+
checkbox.content = '<input class="task-list-item-checkbox" checked=""' + disabledAttr + 'type="checkbox">';
|
|
806
|
+
}
|
|
807
|
+
return checkbox;
|
|
808
|
+
};
|
|
809
|
+
const todoify = (token, TokenConstructor, options) => {
|
|
810
|
+
token.children = token.children || [];
|
|
811
|
+
token.children.unshift(makeCheckbox(token, TokenConstructor, options));
|
|
812
|
+
token.children[1].content = token.children[1].content.slice(3);
|
|
813
|
+
token.content = token.content.slice(3);
|
|
814
|
+
if (options.label) {
|
|
815
|
+
if (options.labelAfter) {
|
|
816
|
+
token.children.pop();
|
|
817
|
+
const id = "task-item-" + Math.ceil(Math.random() * (1e4 * 1e3) - 1e3);
|
|
818
|
+
token.children[0].content = token.children[0].content.slice(0, -1) + ' id="' + id + '">';
|
|
819
|
+
token.children.push(afterLabel(token.content, id, TokenConstructor));
|
|
261
820
|
} else {
|
|
262
|
-
|
|
821
|
+
token.children.unshift(beginLabel(TokenConstructor));
|
|
822
|
+
token.children.push(endLabel(TokenConstructor));
|
|
263
823
|
}
|
|
824
|
+
}
|
|
825
|
+
};
|
|
826
|
+
const githubTaskLists = (md, options = {}) => {
|
|
827
|
+
md.core.ruler.after("inline", "github-task-lists", (state) => {
|
|
828
|
+
const tokens = state.tokens;
|
|
829
|
+
for (let i = 2; i < tokens.length; i++) {
|
|
830
|
+
if (isTodoItem(tokens, i)) {
|
|
831
|
+
todoify(tokens[i], state.Token, options);
|
|
832
|
+
attrSet(
|
|
833
|
+
tokens[i - 2],
|
|
834
|
+
"class",
|
|
835
|
+
"task-list-item" + (options.enabled ? " enabled" : " ")
|
|
836
|
+
);
|
|
837
|
+
attrSet(tokens[parentToken(tokens, i - 2)], "class", "contains-task-list");
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
});
|
|
841
|
+
};
|
|
842
|
+
const initLineNumber = (md) => {
|
|
843
|
+
md.core.ruler.push("init-line-number", (state) => {
|
|
844
|
+
state.tokens.forEach((token) => {
|
|
845
|
+
if (token.map) {
|
|
846
|
+
if (!token.attrs) {
|
|
847
|
+
token.attrs = [];
|
|
848
|
+
}
|
|
849
|
+
token.attrs.push(["data-line", token.map[0].toString()]);
|
|
850
|
+
}
|
|
851
|
+
});
|
|
852
|
+
return true;
|
|
853
|
+
});
|
|
854
|
+
};
|
|
855
|
+
const useMarkdownIt = (props, previewOnly) => {
|
|
856
|
+
const { editorConfig, markdownItConfig, markdownItPlugins, editorExtensions } = config.globalConfig;
|
|
857
|
+
const editorId = vue.inject("editorId");
|
|
858
|
+
const languageRef = vue.inject("language");
|
|
859
|
+
const usedLanguageTextRef = vue.inject(
|
|
860
|
+
"usedLanguageText"
|
|
861
|
+
);
|
|
862
|
+
const showCodeRowNumber = vue.inject("showCodeRowNumber");
|
|
863
|
+
const themeRef = vue.inject("theme");
|
|
864
|
+
const customIconRef = vue.inject("customIcon");
|
|
865
|
+
const rootRef = vue.inject("rootRef");
|
|
866
|
+
const headsRef = vue.ref([]);
|
|
867
|
+
let clearMermaidEvents = () => {
|
|
264
868
|
};
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
869
|
+
const hljsRef = useHighlight(props);
|
|
870
|
+
const katexRef = useKatex(props);
|
|
871
|
+
const { reRenderRef, replaceMermaid } = useMermaid(props);
|
|
872
|
+
const md = mdit({
|
|
873
|
+
html: true,
|
|
874
|
+
breaks: true,
|
|
875
|
+
linkify: true
|
|
876
|
+
});
|
|
877
|
+
markdownItConfig(md, {
|
|
878
|
+
editorId
|
|
879
|
+
});
|
|
880
|
+
const plugins = [
|
|
881
|
+
{
|
|
882
|
+
type: "image",
|
|
883
|
+
plugin: ImageFiguresPlugin,
|
|
884
|
+
options: { figcaption: true, classes: "md-zoom" }
|
|
271
885
|
},
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
886
|
+
{
|
|
887
|
+
type: "admonition",
|
|
888
|
+
plugin: AdmonitionPlugin,
|
|
889
|
+
options: {}
|
|
890
|
+
},
|
|
891
|
+
{
|
|
892
|
+
type: "taskList",
|
|
893
|
+
plugin: githubTaskLists,
|
|
894
|
+
options: {}
|
|
895
|
+
},
|
|
896
|
+
{
|
|
897
|
+
type: "heading",
|
|
898
|
+
plugin: HeadingPlugin,
|
|
899
|
+
options: { mdHeadingId: props.mdHeadingId, headsRef }
|
|
900
|
+
},
|
|
901
|
+
{
|
|
902
|
+
type: "code",
|
|
903
|
+
plugin: codetabs,
|
|
904
|
+
options: {
|
|
905
|
+
editorId,
|
|
906
|
+
usedLanguageTextRef,
|
|
907
|
+
// showCodeRowNumber,
|
|
908
|
+
codeFoldable: props.codeFoldable,
|
|
909
|
+
autoFoldThreshold: props.autoFoldThreshold,
|
|
910
|
+
customIconRef
|
|
911
|
+
}
|
|
912
|
+
},
|
|
913
|
+
{
|
|
914
|
+
type: "sub",
|
|
915
|
+
plugin: SubPlugin,
|
|
916
|
+
options: {}
|
|
917
|
+
},
|
|
918
|
+
{
|
|
919
|
+
type: "sup",
|
|
920
|
+
plugin: SupPlugin,
|
|
921
|
+
options: {}
|
|
275
922
|
}
|
|
276
923
|
];
|
|
924
|
+
if (!props.noKatex) {
|
|
925
|
+
plugins.push({
|
|
926
|
+
type: "katex",
|
|
927
|
+
plugin: KatexPlugin,
|
|
928
|
+
options: { katexRef }
|
|
929
|
+
});
|
|
930
|
+
}
|
|
931
|
+
if (!props.noMermaid) {
|
|
932
|
+
plugins.push({
|
|
933
|
+
type: "mermaid",
|
|
934
|
+
plugin: MermaidPlugin,
|
|
935
|
+
options: { themeRef }
|
|
936
|
+
});
|
|
937
|
+
}
|
|
938
|
+
markdownItPlugins(plugins, {
|
|
939
|
+
editorId
|
|
940
|
+
}).forEach((item) => {
|
|
941
|
+
md.use(item.plugin, item.options);
|
|
942
|
+
});
|
|
943
|
+
const userDefHighlight = md.options.highlight;
|
|
944
|
+
md.set({
|
|
945
|
+
highlight: (str, language, attrs) => {
|
|
946
|
+
if (userDefHighlight) {
|
|
947
|
+
const result = userDefHighlight(str, language, attrs);
|
|
948
|
+
if (result) {
|
|
949
|
+
return result;
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
let codeHtml;
|
|
953
|
+
if (!props.noHighlight && hljsRef.value) {
|
|
954
|
+
const hljsLang = hljsRef.value.getLanguage(language);
|
|
955
|
+
if (hljsLang) {
|
|
956
|
+
codeHtml = hljsRef.value.highlight(str, {
|
|
957
|
+
language,
|
|
958
|
+
ignoreIllegals: true
|
|
959
|
+
}).value;
|
|
960
|
+
} else {
|
|
961
|
+
codeHtml = hljsRef.value.highlightAuto(str).value;
|
|
962
|
+
}
|
|
963
|
+
} else {
|
|
964
|
+
codeHtml = md.utils.escapeHtml(str);
|
|
965
|
+
}
|
|
966
|
+
const codeSpan = showCodeRowNumber ? index.generateCodeRowNumber(
|
|
967
|
+
codeHtml.replace(/^\n+|\n+$/g, ""),
|
|
968
|
+
str.replace(/^\n+|\n+$/g, "")
|
|
969
|
+
) : `<span class="${config.prefix}-code-block">${codeHtml.replace(/^\n+|\n+$/g, "")}</span>`;
|
|
970
|
+
return `<pre><code class="language-${language}" language=${language}>${codeSpan}</code></pre>`;
|
|
971
|
+
}
|
|
972
|
+
});
|
|
973
|
+
initLineNumber(md);
|
|
974
|
+
const key = vue.ref(`_article-key_${util.randomId()}`);
|
|
975
|
+
const html = vue.ref(props.sanitize(md.render(props.modelValue)));
|
|
976
|
+
const updatedTodo = () => {
|
|
977
|
+
eventName.bus.emit(editorId, eventName.BUILD_FINISHED, html.value);
|
|
978
|
+
props.onHtmlChanged(html.value);
|
|
979
|
+
props.onGetCatalog(headsRef.value);
|
|
980
|
+
eventName.bus.emit(editorId, eventName.CATALOG_CHANGED, headsRef.value);
|
|
981
|
+
vue.nextTick(() => {
|
|
982
|
+
replaceMermaid().then(() => {
|
|
983
|
+
var _a, _b;
|
|
984
|
+
if ((_a = editorExtensions.mermaid) == null ? void 0 : _a.enableZoom) {
|
|
985
|
+
clearMermaidEvents();
|
|
986
|
+
clearMermaidEvents = dom.zoomMermaid(
|
|
987
|
+
(_b = rootRef.value) == null ? void 0 : _b.querySelectorAll(`#${editorId} p.${config.prefix}-mermaid`),
|
|
988
|
+
{
|
|
989
|
+
customIcon: customIconRef.value
|
|
990
|
+
}
|
|
991
|
+
);
|
|
992
|
+
}
|
|
993
|
+
});
|
|
994
|
+
});
|
|
995
|
+
};
|
|
996
|
+
const markHtml = () => {
|
|
997
|
+
headsRef.value = [];
|
|
998
|
+
html.value = props.sanitize(md.render(props.modelValue));
|
|
999
|
+
updatedTodo();
|
|
1000
|
+
};
|
|
1001
|
+
const needReRender = vue.computed(() => {
|
|
1002
|
+
return (props.noKatex || katexRef.value) && (props.noHighlight || hljsRef.value);
|
|
1003
|
+
});
|
|
1004
|
+
let timer = -1;
|
|
1005
|
+
vue.watch([vue.toRef(props, "modelValue"), needReRender, reRenderRef, languageRef], () => {
|
|
1006
|
+
timer = window.setTimeout(
|
|
1007
|
+
() => {
|
|
1008
|
+
markHtml();
|
|
1009
|
+
},
|
|
1010
|
+
previewOnly ? 0 : editorConfig.renderDelay
|
|
1011
|
+
);
|
|
1012
|
+
});
|
|
1013
|
+
vue.watch(
|
|
1014
|
+
() => props.setting.preview,
|
|
1015
|
+
() => {
|
|
1016
|
+
if (props.setting.preview) {
|
|
1017
|
+
vue.nextTick(() => {
|
|
1018
|
+
replaceMermaid().then(() => {
|
|
1019
|
+
var _a, _b;
|
|
1020
|
+
if ((_a = editorExtensions.mermaid) == null ? void 0 : _a.enableZoom) {
|
|
1021
|
+
clearMermaidEvents();
|
|
1022
|
+
clearMermaidEvents = dom.zoomMermaid(
|
|
1023
|
+
(_b = rootRef.value) == null ? void 0 : _b.querySelectorAll(`#${editorId} p.${config.prefix}-mermaid`),
|
|
1024
|
+
{
|
|
1025
|
+
customIcon: customIconRef.value
|
|
1026
|
+
}
|
|
1027
|
+
);
|
|
1028
|
+
}
|
|
1029
|
+
});
|
|
1030
|
+
eventName.bus.emit(editorId, eventName.CATALOG_CHANGED, headsRef.value);
|
|
1031
|
+
});
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
);
|
|
1035
|
+
vue.onMounted(updatedTodo);
|
|
1036
|
+
vue.onMounted(() => {
|
|
1037
|
+
eventName.bus.on(editorId, {
|
|
1038
|
+
name: eventName.PUSH_CATALOG,
|
|
1039
|
+
callback() {
|
|
1040
|
+
eventName.bus.emit(editorId, eventName.CATALOG_CHANGED, headsRef.value);
|
|
1041
|
+
}
|
|
1042
|
+
});
|
|
1043
|
+
eventName.bus.on(editorId, {
|
|
1044
|
+
name: eventName.RERENDER,
|
|
1045
|
+
callback: () => {
|
|
1046
|
+
key.value = `_article-key_${util.randomId()}`;
|
|
1047
|
+
markHtml();
|
|
1048
|
+
}
|
|
1049
|
+
});
|
|
1050
|
+
});
|
|
1051
|
+
vue.onBeforeUnmount(() => {
|
|
1052
|
+
clearMermaidEvents();
|
|
1053
|
+
clearTimeout(timer);
|
|
1054
|
+
});
|
|
1055
|
+
return { html, key };
|
|
1056
|
+
};
|
|
1057
|
+
const template = {
|
|
1058
|
+
checked: {
|
|
1059
|
+
regexp: /- \[x\]/,
|
|
1060
|
+
value: "- [ ]"
|
|
1061
|
+
},
|
|
1062
|
+
unChecked: {
|
|
1063
|
+
regexp: /- \[\s\]/,
|
|
1064
|
+
value: "- [x]"
|
|
1065
|
+
}
|
|
1066
|
+
};
|
|
1067
|
+
const useTaskState = (props, html) => {
|
|
1068
|
+
const editorId = vue.inject("editorId");
|
|
1069
|
+
const rootRef = vue.inject("rootRef");
|
|
1070
|
+
let removeListener = () => {
|
|
1071
|
+
};
|
|
1072
|
+
const addListener = () => {
|
|
1073
|
+
if (!rootRef.value) {
|
|
1074
|
+
return false;
|
|
1075
|
+
}
|
|
1076
|
+
const tasks = rootRef.value.querySelectorAll(".task-list-item.enabled");
|
|
1077
|
+
const listener = (e) => {
|
|
1078
|
+
var _a;
|
|
1079
|
+
e.preventDefault();
|
|
1080
|
+
const nextValue = e.target.checked ? "unChecked" : "checked";
|
|
1081
|
+
const line = (_a = e.target.parentElement) == null ? void 0 : _a.dataset.line;
|
|
1082
|
+
if (!line) {
|
|
1083
|
+
return;
|
|
1084
|
+
}
|
|
1085
|
+
const lineNumber = Number(line);
|
|
1086
|
+
const lines = props.modelValue.split("\n");
|
|
1087
|
+
const targetValue = lines[Number(lineNumber)].replace(
|
|
1088
|
+
template[nextValue].regexp,
|
|
1089
|
+
template[nextValue].value
|
|
1090
|
+
);
|
|
1091
|
+
if (props.previewOnly) {
|
|
1092
|
+
lines[Number(lineNumber)] = targetValue;
|
|
1093
|
+
props.onChange(lines.join("\n"));
|
|
1094
|
+
} else {
|
|
1095
|
+
eventName.bus.emit(editorId, eventName.TASK_STATE_CHANGED, lineNumber + 1, targetValue);
|
|
1096
|
+
}
|
|
1097
|
+
};
|
|
1098
|
+
tasks.forEach((item) => {
|
|
1099
|
+
item.addEventListener("click", listener);
|
|
1100
|
+
});
|
|
1101
|
+
removeListener = () => {
|
|
1102
|
+
tasks.forEach((item) => {
|
|
1103
|
+
item.removeEventListener("click", listener);
|
|
1104
|
+
});
|
|
1105
|
+
};
|
|
1106
|
+
};
|
|
1107
|
+
vue.onBeforeUnmount(() => {
|
|
1108
|
+
removeListener();
|
|
1109
|
+
});
|
|
1110
|
+
vue.watch(
|
|
1111
|
+
[html],
|
|
1112
|
+
() => {
|
|
1113
|
+
removeListener();
|
|
1114
|
+
vue.nextTick(addListener);
|
|
1115
|
+
},
|
|
1116
|
+
{
|
|
1117
|
+
immediate: true
|
|
1118
|
+
}
|
|
1119
|
+
);
|
|
1120
|
+
};
|
|
1121
|
+
const useRemount = (props, html, key) => {
|
|
1122
|
+
const handler = () => {
|
|
1123
|
+
vue.nextTick(() => {
|
|
1124
|
+
var _a;
|
|
1125
|
+
(_a = props.onRemount) == null ? void 0 : _a.call(props);
|
|
1126
|
+
});
|
|
1127
|
+
};
|
|
1128
|
+
const settingPreviewChanged = (nVal) => {
|
|
1129
|
+
if (nVal) {
|
|
1130
|
+
handler();
|
|
1131
|
+
}
|
|
1132
|
+
};
|
|
1133
|
+
vue.watch([html, key], handler);
|
|
1134
|
+
vue.watch(() => props.setting.preview, settingPreviewChanged);
|
|
1135
|
+
vue.watch(() => props.setting.htmlPreview, settingPreviewChanged);
|
|
1136
|
+
vue.onMounted(handler);
|
|
277
1137
|
};
|
|
278
|
-
const
|
|
279
|
-
|
|
1138
|
+
const contentPreviewProps = {
|
|
1139
|
+
modelValue: {
|
|
1140
|
+
type: String,
|
|
1141
|
+
default: ""
|
|
1142
|
+
},
|
|
1143
|
+
onChange: {
|
|
1144
|
+
type: Function,
|
|
1145
|
+
default: () => {
|
|
1146
|
+
}
|
|
1147
|
+
},
|
|
1148
|
+
setting: {
|
|
280
1149
|
type: Object,
|
|
281
|
-
default: () => ({})
|
|
1150
|
+
default: () => ({ preview: true })
|
|
282
1151
|
},
|
|
283
|
-
|
|
1152
|
+
onHtmlChanged: {
|
|
1153
|
+
type: Function,
|
|
1154
|
+
default: () => {
|
|
1155
|
+
}
|
|
1156
|
+
},
|
|
1157
|
+
onGetCatalog: {
|
|
284
1158
|
type: Function,
|
|
285
1159
|
default: () => {
|
|
286
1160
|
}
|
|
287
1161
|
},
|
|
288
|
-
|
|
1162
|
+
mdHeadingId: {
|
|
1163
|
+
type: Function,
|
|
1164
|
+
default: () => ""
|
|
1165
|
+
},
|
|
1166
|
+
noMermaid: {
|
|
1167
|
+
type: Boolean,
|
|
1168
|
+
default: false
|
|
1169
|
+
},
|
|
1170
|
+
sanitize: {
|
|
1171
|
+
type: Function,
|
|
1172
|
+
default: (html) => html
|
|
1173
|
+
},
|
|
1174
|
+
// 不使用该函数功能
|
|
1175
|
+
noKatex: {
|
|
1176
|
+
type: Boolean,
|
|
1177
|
+
default: false
|
|
1178
|
+
},
|
|
1179
|
+
formatCopiedText: {
|
|
1180
|
+
type: Function,
|
|
1181
|
+
default: (text) => text
|
|
1182
|
+
},
|
|
1183
|
+
noHighlight: {
|
|
1184
|
+
type: Boolean,
|
|
1185
|
+
default: false
|
|
1186
|
+
},
|
|
1187
|
+
previewOnly: {
|
|
1188
|
+
type: Boolean,
|
|
1189
|
+
default: false
|
|
1190
|
+
},
|
|
1191
|
+
noImgZoomIn: {
|
|
1192
|
+
type: Boolean
|
|
1193
|
+
},
|
|
1194
|
+
sanitizeMermaid: {
|
|
1195
|
+
type: Function
|
|
1196
|
+
},
|
|
1197
|
+
codeFoldable: {
|
|
1198
|
+
type: Boolean
|
|
1199
|
+
},
|
|
1200
|
+
autoFoldThreshold: {
|
|
1201
|
+
type: Number
|
|
1202
|
+
},
|
|
1203
|
+
onRemount: {
|
|
1204
|
+
type: Function
|
|
1205
|
+
}
|
|
1206
|
+
};
|
|
1207
|
+
const contentProps = {
|
|
1208
|
+
...contentPreviewProps,
|
|
1209
|
+
updateModelValue: {
|
|
1210
|
+
type: Function,
|
|
1211
|
+
default: () => {
|
|
1212
|
+
}
|
|
1213
|
+
},
|
|
1214
|
+
placeholder: {
|
|
1215
|
+
type: String,
|
|
1216
|
+
default: ""
|
|
1217
|
+
},
|
|
1218
|
+
scrollAuto: {
|
|
1219
|
+
type: Boolean
|
|
1220
|
+
},
|
|
1221
|
+
autofocus: {
|
|
1222
|
+
type: Boolean
|
|
1223
|
+
},
|
|
1224
|
+
disabled: {
|
|
1225
|
+
type: Boolean
|
|
1226
|
+
},
|
|
1227
|
+
readonly: {
|
|
1228
|
+
type: Boolean
|
|
1229
|
+
},
|
|
1230
|
+
maxlength: {
|
|
1231
|
+
type: Number
|
|
1232
|
+
},
|
|
1233
|
+
autoDetectCode: {
|
|
1234
|
+
type: Boolean
|
|
1235
|
+
},
|
|
1236
|
+
/**
|
|
1237
|
+
* 输入框失去焦点时触发事件
|
|
1238
|
+
*/
|
|
1239
|
+
onBlur: {
|
|
1240
|
+
type: Function,
|
|
1241
|
+
default: () => {
|
|
1242
|
+
}
|
|
1243
|
+
},
|
|
1244
|
+
/**
|
|
1245
|
+
* 输入框获得焦点时触发事件
|
|
1246
|
+
*/
|
|
1247
|
+
onFocus: {
|
|
1248
|
+
type: Function,
|
|
1249
|
+
default: () => {
|
|
1250
|
+
}
|
|
1251
|
+
},
|
|
1252
|
+
noPrettier: {
|
|
1253
|
+
type: Boolean
|
|
1254
|
+
},
|
|
1255
|
+
completions: {
|
|
1256
|
+
type: Array
|
|
1257
|
+
},
|
|
1258
|
+
catalogVisible: {
|
|
1259
|
+
type: Boolean
|
|
1260
|
+
},
|
|
1261
|
+
theme: {
|
|
1262
|
+
type: String,
|
|
1263
|
+
default: "light"
|
|
1264
|
+
},
|
|
1265
|
+
onInput: {
|
|
1266
|
+
type: Function
|
|
1267
|
+
},
|
|
1268
|
+
onDrop: {
|
|
1269
|
+
type: Function,
|
|
1270
|
+
default: () => {
|
|
1271
|
+
}
|
|
1272
|
+
},
|
|
1273
|
+
inputBoxWidth: {
|
|
1274
|
+
type: String
|
|
1275
|
+
},
|
|
1276
|
+
oninputBoxWidthChange: {
|
|
1277
|
+
type: Function
|
|
1278
|
+
},
|
|
1279
|
+
transformImgUrl: {
|
|
1280
|
+
type: Function,
|
|
1281
|
+
default: (t) => t
|
|
1282
|
+
},
|
|
1283
|
+
catalogLayout: {
|
|
1284
|
+
type: String
|
|
1285
|
+
},
|
|
1286
|
+
catalogMaxDepth: {
|
|
1287
|
+
type: Number
|
|
1288
|
+
}
|
|
1289
|
+
};
|
|
1290
|
+
const splitNodes = (html) => {
|
|
1291
|
+
const parser = new DOMParser();
|
|
1292
|
+
const doc = parser.parseFromString(html, "text/html");
|
|
1293
|
+
return Array.from(doc.body.childNodes);
|
|
1294
|
+
};
|
|
1295
|
+
const compareHtml = (newNodes, currentNodes) => {
|
|
1296
|
+
const updates = [];
|
|
1297
|
+
const deletes = [];
|
|
1298
|
+
newNodes.forEach((newNode, index2) => {
|
|
1299
|
+
const currentNode = currentNodes[index2];
|
|
1300
|
+
if (!currentNode) {
|
|
1301
|
+
updates.push({
|
|
1302
|
+
index: index2,
|
|
1303
|
+
newNode
|
|
1304
|
+
});
|
|
1305
|
+
return;
|
|
1306
|
+
}
|
|
1307
|
+
if (newNode.nodeType !== currentNode.nodeType || newNode.textContent !== currentNode.textContent || newNode.nodeType === 1 && newNode.outerHTML !== currentNode.outerHTML) {
|
|
1308
|
+
updates.push({
|
|
1309
|
+
index: index2,
|
|
1310
|
+
newNode
|
|
1311
|
+
});
|
|
1312
|
+
}
|
|
1313
|
+
});
|
|
1314
|
+
if (currentNodes.length > newNodes.length) {
|
|
1315
|
+
for (let i = newNodes.length; i < currentNodes.length; i++) {
|
|
1316
|
+
deletes.push(currentNodes[i]);
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1319
|
+
return {
|
|
1320
|
+
updates,
|
|
1321
|
+
deletes
|
|
1322
|
+
};
|
|
1323
|
+
};
|
|
1324
|
+
const UpdateOnDemand = /* @__PURE__ */ vue.defineComponent({
|
|
1325
|
+
name: "UpdateOnDemand",
|
|
1326
|
+
props: {
|
|
1327
|
+
html: {
|
|
1328
|
+
type: String,
|
|
1329
|
+
required: true
|
|
1330
|
+
}
|
|
1331
|
+
},
|
|
1332
|
+
setup(props) {
|
|
1333
|
+
const editorId = vue.inject("editorId");
|
|
1334
|
+
const previewTheme = vue.inject("previewTheme");
|
|
1335
|
+
const showCodeRowNumber = vue.inject("showCodeRowNumber");
|
|
1336
|
+
const htmlContainer = vue.ref();
|
|
1337
|
+
const firstHtml = props.html;
|
|
1338
|
+
const updateHtmlContent = (updates, deletes) => {
|
|
1339
|
+
if (!htmlContainer.value) return;
|
|
1340
|
+
deletes.forEach((node) => {
|
|
1341
|
+
node.remove();
|
|
1342
|
+
});
|
|
1343
|
+
updates.forEach(({
|
|
1344
|
+
index: index2,
|
|
1345
|
+
newNode
|
|
1346
|
+
}) => {
|
|
1347
|
+
var _a, _b, _c;
|
|
1348
|
+
const targetNode = (_a = htmlContainer.value) == null ? void 0 : _a.childNodes[index2];
|
|
1349
|
+
if (!targetNode) {
|
|
1350
|
+
(_b = htmlContainer.value) == null ? void 0 : _b.appendChild(newNode.cloneNode(true));
|
|
1351
|
+
} else {
|
|
1352
|
+
(_c = htmlContainer.value) == null ? void 0 : _c.replaceChild(newNode.cloneNode(true), targetNode);
|
|
1353
|
+
}
|
|
1354
|
+
});
|
|
1355
|
+
};
|
|
1356
|
+
vue.watch(() => props.html, (newHtml) => {
|
|
1357
|
+
var _a;
|
|
1358
|
+
const newNodes = splitNodes(newHtml);
|
|
1359
|
+
const currentNodes = Array.from(((_a = htmlContainer.value) == null ? void 0 : _a.childNodes) || []);
|
|
1360
|
+
const {
|
|
1361
|
+
updates,
|
|
1362
|
+
deletes
|
|
1363
|
+
} = compareHtml(newNodes, currentNodes);
|
|
1364
|
+
updateHtmlContent(updates, deletes);
|
|
1365
|
+
});
|
|
1366
|
+
return () => vue.createVNode("div", {
|
|
1367
|
+
"id": `${editorId}-preview`,
|
|
1368
|
+
"class": [`${config.prefix}-preview`, `${previewTheme == null ? void 0 : previewTheme.value}-theme`, showCodeRowNumber && `${config.prefix}-scrn`],
|
|
1369
|
+
"innerHTML": firstHtml,
|
|
1370
|
+
"ref": htmlContainer
|
|
1371
|
+
}, null);
|
|
1372
|
+
}
|
|
1373
|
+
});
|
|
1374
|
+
const ContentPreview = /* @__PURE__ */ vue.defineComponent({
|
|
1375
|
+
name: "ContentPreview",
|
|
1376
|
+
props: contentPreviewProps,
|
|
1377
|
+
setup(props) {
|
|
1378
|
+
const editorId = vue.inject("editorId");
|
|
1379
|
+
const {
|
|
1380
|
+
html,
|
|
1381
|
+
key
|
|
1382
|
+
} = useMarkdownIt(props, props.previewOnly);
|
|
1383
|
+
useCopyCode(props, html, key);
|
|
1384
|
+
userZoom(props, html);
|
|
1385
|
+
useTaskState(props, html);
|
|
1386
|
+
useRemount(props, html, key);
|
|
1387
|
+
return () => {
|
|
1388
|
+
return vue.createVNode(vue.Fragment, null, [props.setting.preview && vue.createVNode("div", {
|
|
1389
|
+
"id": `${editorId}-preview-wrapper`,
|
|
1390
|
+
"class": `${config.prefix}-preview-wrapper`,
|
|
1391
|
+
"key": "content-preview-wrapper"
|
|
1392
|
+
}, [vue.createVNode(UpdateOnDemand, {
|
|
1393
|
+
"key": key.value,
|
|
1394
|
+
"html": html.value
|
|
1395
|
+
}, null)]), !props.previewOnly && props.setting.htmlPreview && vue.createVNode("div", {
|
|
1396
|
+
"id": `${editorId}-html-wrapper`,
|
|
1397
|
+
"class": `${config.prefix}-preview-wrapper`,
|
|
1398
|
+
"key": "html-preview-wrapper"
|
|
1399
|
+
}, [vue.createVNode("div", {
|
|
1400
|
+
"class": `${config.prefix}-html`
|
|
1401
|
+
}, [html.value])])]);
|
|
1402
|
+
};
|
|
1403
|
+
}
|
|
1404
|
+
});
|
|
1405
|
+
const useOnSave = (props, context, options) => {
|
|
1406
|
+
const { editorId } = options;
|
|
1407
|
+
const state = vue.reactive({
|
|
1408
|
+
// 是否已编译成html
|
|
1409
|
+
buildFinished: false,
|
|
1410
|
+
// 存储当前最新的html
|
|
1411
|
+
html: ""
|
|
1412
|
+
});
|
|
1413
|
+
vue.watch(
|
|
1414
|
+
() => props.modelValue,
|
|
1415
|
+
() => {
|
|
1416
|
+
state.buildFinished = false;
|
|
1417
|
+
}
|
|
1418
|
+
);
|
|
1419
|
+
vue.onMounted(() => {
|
|
1420
|
+
eventName.bus.on(editorId, {
|
|
1421
|
+
name: eventName.BUILD_FINISHED,
|
|
1422
|
+
callback(html) {
|
|
1423
|
+
state.buildFinished = true;
|
|
1424
|
+
state.html = html;
|
|
1425
|
+
}
|
|
1426
|
+
});
|
|
1427
|
+
eventName.bus.on(editorId, {
|
|
1428
|
+
name: eventName.ON_SAVE,
|
|
1429
|
+
callback() {
|
|
1430
|
+
const htmlPromise = new Promise((rev) => {
|
|
1431
|
+
if (state.buildFinished) {
|
|
1432
|
+
rev(state.html);
|
|
1433
|
+
} else {
|
|
1434
|
+
const buildFinishedCallback = (html) => {
|
|
1435
|
+
rev(html);
|
|
1436
|
+
eventName.bus.remove(editorId, eventName.BUILD_FINISHED, buildFinishedCallback);
|
|
1437
|
+
};
|
|
1438
|
+
eventName.bus.on(editorId, {
|
|
1439
|
+
name: eventName.BUILD_FINISHED,
|
|
1440
|
+
callback: buildFinishedCallback
|
|
1441
|
+
});
|
|
1442
|
+
}
|
|
1443
|
+
});
|
|
1444
|
+
if (props.onSave) {
|
|
1445
|
+
props.onSave(props.modelValue, htmlPromise);
|
|
1446
|
+
} else {
|
|
1447
|
+
context.emit("onSave", props.modelValue, htmlPromise);
|
|
1448
|
+
}
|
|
1449
|
+
}
|
|
1450
|
+
});
|
|
1451
|
+
});
|
|
1452
|
+
};
|
|
1453
|
+
const useProvidePreview = (props, rootRef) => {
|
|
1454
|
+
const hljsUrls = config.globalConfig.editorExtensions.highlight;
|
|
1455
|
+
const hljsAttrs = config.globalConfig.editorExtensionsAttrs.highlight;
|
|
1456
|
+
const editorId = useEditorId(props);
|
|
1457
|
+
vue.provide("editorId", editorId);
|
|
1458
|
+
vue.provide("rootRef", rootRef);
|
|
1459
|
+
vue.provide(
|
|
1460
|
+
"theme",
|
|
1461
|
+
vue.computed(() => props.theme)
|
|
1462
|
+
);
|
|
1463
|
+
vue.provide(
|
|
1464
|
+
"language",
|
|
1465
|
+
vue.computed(() => props.language)
|
|
1466
|
+
);
|
|
1467
|
+
vue.provide(
|
|
1468
|
+
"highlight",
|
|
1469
|
+
vue.computed(() => {
|
|
1470
|
+
const { js: jsUrl } = hljsUrls;
|
|
1471
|
+
const cssList = {
|
|
1472
|
+
...config.codeCss,
|
|
1473
|
+
...hljsUrls.css
|
|
1474
|
+
};
|
|
1475
|
+
const { js: jsAttrs, css: cssAttrs = {} } = hljsAttrs || {};
|
|
1476
|
+
const _theme = props.codeStyleReverse && props.codeStyleReverseList.includes(props.previewTheme) ? "dark" : props.theme;
|
|
1477
|
+
const codeCssHref = cssList[props.codeTheme] ? cssList[props.codeTheme][_theme] : config.codeCss.atom[_theme];
|
|
1478
|
+
const codeCssAttrs = cssList[props.codeTheme] && cssAttrs[props.codeTheme] ? cssAttrs[props.codeTheme][_theme] : cssAttrs["atom"] ? cssAttrs["atom"][_theme] : {};
|
|
1479
|
+
return {
|
|
1480
|
+
js: {
|
|
1481
|
+
src: jsUrl,
|
|
1482
|
+
...jsAttrs
|
|
1483
|
+
},
|
|
1484
|
+
css: {
|
|
1485
|
+
href: codeCssHref,
|
|
1486
|
+
...codeCssAttrs
|
|
1487
|
+
}
|
|
1488
|
+
};
|
|
1489
|
+
})
|
|
1490
|
+
);
|
|
1491
|
+
vue.provide("showCodeRowNumber", props.showCodeRowNumber);
|
|
1492
|
+
const usedLanguageText = vue.computed(() => {
|
|
1493
|
+
const allText = {
|
|
1494
|
+
...config.staticTextDefault,
|
|
1495
|
+
...config.globalConfig.editorConfig.languageUserDefined
|
|
1496
|
+
};
|
|
1497
|
+
return util.deepMerge(
|
|
1498
|
+
util.deepClone(config.staticTextDefault["en-US"]),
|
|
1499
|
+
allText[props.language] || {}
|
|
1500
|
+
);
|
|
1501
|
+
});
|
|
1502
|
+
vue.provide("usedLanguageText", usedLanguageText);
|
|
1503
|
+
vue.provide(
|
|
1504
|
+
"previewTheme",
|
|
1505
|
+
vue.computed(() => props.previewTheme)
|
|
1506
|
+
);
|
|
1507
|
+
vue.provide(
|
|
1508
|
+
"customIcon",
|
|
1509
|
+
vue.computed(() => props.customIcon)
|
|
1510
|
+
);
|
|
1511
|
+
return { editorId };
|
|
1512
|
+
};
|
|
1513
|
+
const useProvide = (props, rootRef) => {
|
|
1514
|
+
vue.provide("tabWidth", props.tabWidth);
|
|
1515
|
+
vue.provide(
|
|
1516
|
+
"disabled",
|
|
1517
|
+
vue.computed(() => props.disabled)
|
|
1518
|
+
);
|
|
1519
|
+
return useProvidePreview(props, rootRef);
|
|
1520
|
+
};
|
|
1521
|
+
const useExpansion = (props) => {
|
|
1522
|
+
const { noPrettier, noUploadImg } = props;
|
|
1523
|
+
const { editorExtensions, editorExtensionsAttrs } = config.globalConfig;
|
|
1524
|
+
const noPrettierScript = noPrettier || editorExtensions.prettier.prettierInstance;
|
|
1525
|
+
const noParserMarkdownScript = noPrettier || editorExtensions.prettier.parserMarkdownInstance;
|
|
1526
|
+
const noCropperScript = noUploadImg || editorExtensions.cropper.instance;
|
|
1527
|
+
vue.onMounted(() => {
|
|
1528
|
+
if (!noCropperScript) {
|
|
1529
|
+
const { js = {}, css = {} } = editorExtensionsAttrs.cropper || {};
|
|
1530
|
+
dom.appendHandler("link", {
|
|
1531
|
+
...css,
|
|
1532
|
+
rel: "stylesheet",
|
|
1533
|
+
href: editorExtensions.cropper.css,
|
|
1534
|
+
id: CDN_IDS.croppercss
|
|
1535
|
+
});
|
|
1536
|
+
dom.appendHandler("script", {
|
|
1537
|
+
...js,
|
|
1538
|
+
src: editorExtensions.cropper.js,
|
|
1539
|
+
id: CDN_IDS.cropperjs
|
|
1540
|
+
});
|
|
1541
|
+
}
|
|
1542
|
+
if (!noPrettierScript) {
|
|
1543
|
+
const { standaloneJs = {} } = editorExtensionsAttrs.prettier || {};
|
|
1544
|
+
dom.appendHandler("script", {
|
|
1545
|
+
...standaloneJs,
|
|
1546
|
+
src: editorExtensions.prettier.standaloneJs,
|
|
1547
|
+
id: CDN_IDS.prettier
|
|
1548
|
+
});
|
|
1549
|
+
}
|
|
1550
|
+
if (!noParserMarkdownScript) {
|
|
1551
|
+
const { parserMarkdownJs = {} } = editorExtensionsAttrs.prettier || {};
|
|
1552
|
+
dom.appendHandler("script", {
|
|
1553
|
+
...parserMarkdownJs,
|
|
1554
|
+
src: editorExtensions.prettier.parserMarkdownJs,
|
|
1555
|
+
id: CDN_IDS.prettierMD
|
|
1556
|
+
});
|
|
1557
|
+
}
|
|
1558
|
+
});
|
|
1559
|
+
};
|
|
1560
|
+
const useErrorCatcher = (props, context, options) => {
|
|
1561
|
+
const { editorId } = options;
|
|
1562
|
+
vue.onMounted(() => {
|
|
1563
|
+
eventName.bus.on(editorId, {
|
|
1564
|
+
name: eventName.ERROR_CATCHER,
|
|
1565
|
+
callback: (err) => {
|
|
1566
|
+
var _a;
|
|
1567
|
+
(_a = props.onError) == null ? void 0 : _a.call(props, err);
|
|
1568
|
+
context.emit("onError", err);
|
|
1569
|
+
}
|
|
1570
|
+
});
|
|
1571
|
+
});
|
|
1572
|
+
};
|
|
1573
|
+
const useConfig = (props, context, options) => {
|
|
1574
|
+
const { editorId } = options;
|
|
1575
|
+
const setting = vue.reactive({
|
|
1576
|
+
pageFullscreen: props.pageFullscreen,
|
|
1577
|
+
fullscreen: false,
|
|
1578
|
+
preview: props.preview,
|
|
1579
|
+
htmlPreview: props.preview ? false : props.htmlPreview,
|
|
1580
|
+
previewOnly: false
|
|
1581
|
+
});
|
|
1582
|
+
const cacheSetting = vue.reactive({ ...setting });
|
|
1583
|
+
const updateSetting = (k, v) => {
|
|
1584
|
+
const realValue = v === void 0 ? !setting[k] : v;
|
|
1585
|
+
switch (k) {
|
|
1586
|
+
case "preview": {
|
|
1587
|
+
setting.htmlPreview = false;
|
|
1588
|
+
setting.previewOnly = false;
|
|
1589
|
+
break;
|
|
1590
|
+
}
|
|
1591
|
+
case "htmlPreview": {
|
|
1592
|
+
setting.preview = false;
|
|
1593
|
+
setting.previewOnly = false;
|
|
1594
|
+
break;
|
|
1595
|
+
}
|
|
1596
|
+
case "previewOnly": {
|
|
1597
|
+
if (realValue) {
|
|
1598
|
+
if (!setting.preview && !setting.htmlPreview) {
|
|
1599
|
+
setting.preview = true;
|
|
1600
|
+
}
|
|
1601
|
+
} else {
|
|
1602
|
+
if (!cacheSetting.preview) {
|
|
1603
|
+
setting.preview = false;
|
|
1604
|
+
}
|
|
1605
|
+
if (!cacheSetting.htmlPreview) {
|
|
1606
|
+
setting.htmlPreview = false;
|
|
1607
|
+
}
|
|
1608
|
+
}
|
|
1609
|
+
break;
|
|
1610
|
+
}
|
|
1611
|
+
}
|
|
1612
|
+
cacheSetting[k] = realValue;
|
|
1613
|
+
setting[k] = realValue;
|
|
1614
|
+
};
|
|
1615
|
+
let bodyOverflowHistory = "";
|
|
1616
|
+
const adjustBody = () => {
|
|
1617
|
+
if (setting.pageFullscreen || setting.fullscreen) {
|
|
1618
|
+
document.body.style.overflow = "hidden";
|
|
1619
|
+
} else {
|
|
1620
|
+
document.body.style.overflow = bodyOverflowHistory;
|
|
1621
|
+
}
|
|
1622
|
+
};
|
|
1623
|
+
vue.watch(() => [setting.pageFullscreen, setting.fullscreen], adjustBody);
|
|
1624
|
+
vue.onMounted(() => {
|
|
1625
|
+
eventName.bus.on(editorId, {
|
|
1626
|
+
name: eventName.UPLOAD_IMAGE,
|
|
1627
|
+
callback(files, cb) {
|
|
1628
|
+
const insertHanlder = (urls) => {
|
|
1629
|
+
eventName.bus.emit(editorId, eventName.REPLACE, "image", {
|
|
1630
|
+
desc: "",
|
|
1631
|
+
urls
|
|
1632
|
+
});
|
|
1633
|
+
cb == null ? void 0 : cb();
|
|
1634
|
+
};
|
|
1635
|
+
if (props.onUploadImg) {
|
|
1636
|
+
props.onUploadImg(files, insertHanlder);
|
|
1637
|
+
} else {
|
|
1638
|
+
context.emit("onUploadImg", files, insertHanlder);
|
|
1639
|
+
}
|
|
1640
|
+
}
|
|
1641
|
+
});
|
|
1642
|
+
bodyOverflowHistory = document.body.style.overflow;
|
|
1643
|
+
adjustBody();
|
|
1644
|
+
});
|
|
1645
|
+
return [setting, updateSetting];
|
|
1646
|
+
};
|
|
1647
|
+
const useCatalog = (_props, options) => {
|
|
1648
|
+
const { editorId } = options;
|
|
1649
|
+
const catalogShow = vue.ref(false);
|
|
1650
|
+
vue.onMounted(() => {
|
|
1651
|
+
eventName.bus.on(editorId, {
|
|
1652
|
+
name: eventName.CHANGE_CATALOG_VISIBLE,
|
|
1653
|
+
callback: (v) => {
|
|
1654
|
+
if (v === void 0) {
|
|
1655
|
+
catalogShow.value = !catalogShow.value;
|
|
1656
|
+
} else {
|
|
1657
|
+
catalogShow.value = v;
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1660
|
+
});
|
|
1661
|
+
});
|
|
1662
|
+
return catalogShow;
|
|
1663
|
+
};
|
|
1664
|
+
const useExpose$1 = (props, ctx, options) => {
|
|
1665
|
+
const { editorId, catalogVisible, setting, updateSetting, codeRef } = options;
|
|
1666
|
+
vue.watch(
|
|
1667
|
+
() => setting.pageFullscreen,
|
|
1668
|
+
(newVal) => {
|
|
1669
|
+
eventName.bus.emit(editorId, eventName.PAGE_FULL_SCREEN_CHANGED, newVal);
|
|
1670
|
+
}
|
|
1671
|
+
);
|
|
1672
|
+
vue.watch(
|
|
1673
|
+
() => setting.fullscreen,
|
|
1674
|
+
(newVal) => {
|
|
1675
|
+
eventName.bus.emit(editorId, eventName.FULL_SCREEN_CHANGED, newVal);
|
|
1676
|
+
}
|
|
1677
|
+
);
|
|
1678
|
+
vue.watch(
|
|
1679
|
+
() => setting.preview,
|
|
1680
|
+
(newVal) => {
|
|
1681
|
+
eventName.bus.emit(editorId, eventName.PREVIEW_CHANGED, newVal);
|
|
1682
|
+
}
|
|
1683
|
+
);
|
|
1684
|
+
vue.watch(
|
|
1685
|
+
() => setting.previewOnly,
|
|
1686
|
+
(newVal) => {
|
|
1687
|
+
eventName.bus.emit(editorId, eventName.PREVIEW_ONLY_CHANGED, newVal);
|
|
1688
|
+
}
|
|
1689
|
+
);
|
|
1690
|
+
vue.watch(
|
|
1691
|
+
() => setting.htmlPreview,
|
|
1692
|
+
(newVal) => {
|
|
1693
|
+
eventName.bus.emit(editorId, eventName.HTML_PREVIEW_CHANGED, newVal);
|
|
1694
|
+
}
|
|
1695
|
+
);
|
|
1696
|
+
vue.watch(catalogVisible, (newVal) => {
|
|
1697
|
+
eventName.bus.emit(editorId, eventName.CATALOG_VISIBLE_CHANGED, newVal);
|
|
1698
|
+
});
|
|
1699
|
+
const exposeParam = {
|
|
1700
|
+
on(eventName$1, callBack) {
|
|
1701
|
+
switch (eventName$1) {
|
|
1702
|
+
case "pageFullscreen": {
|
|
1703
|
+
eventName.bus.on(editorId, {
|
|
1704
|
+
name: eventName.PAGE_FULL_SCREEN_CHANGED,
|
|
1705
|
+
callback(status) {
|
|
1706
|
+
callBack(status);
|
|
1707
|
+
}
|
|
1708
|
+
});
|
|
1709
|
+
break;
|
|
1710
|
+
}
|
|
1711
|
+
case "fullscreen": {
|
|
1712
|
+
eventName.bus.on(editorId, {
|
|
1713
|
+
name: eventName.FULL_SCREEN_CHANGED,
|
|
1714
|
+
callback(status) {
|
|
1715
|
+
callBack(status);
|
|
1716
|
+
}
|
|
1717
|
+
});
|
|
1718
|
+
break;
|
|
1719
|
+
}
|
|
1720
|
+
case "preview": {
|
|
1721
|
+
eventName.bus.on(editorId, {
|
|
1722
|
+
name: eventName.PREVIEW_CHANGED,
|
|
1723
|
+
callback(status) {
|
|
1724
|
+
callBack(status);
|
|
1725
|
+
}
|
|
1726
|
+
});
|
|
1727
|
+
break;
|
|
1728
|
+
}
|
|
1729
|
+
case "previewOnly": {
|
|
1730
|
+
eventName.bus.on(editorId, {
|
|
1731
|
+
name: eventName.PREVIEW_ONLY_CHANGED,
|
|
1732
|
+
callback(status) {
|
|
1733
|
+
callBack(status);
|
|
1734
|
+
}
|
|
1735
|
+
});
|
|
1736
|
+
break;
|
|
1737
|
+
}
|
|
1738
|
+
case "htmlPreview": {
|
|
1739
|
+
eventName.bus.on(editorId, {
|
|
1740
|
+
name: eventName.HTML_PREVIEW_CHANGED,
|
|
1741
|
+
callback(status) {
|
|
1742
|
+
callBack(status);
|
|
1743
|
+
}
|
|
1744
|
+
});
|
|
1745
|
+
break;
|
|
1746
|
+
}
|
|
1747
|
+
case "catalog": {
|
|
1748
|
+
eventName.bus.on(editorId, {
|
|
1749
|
+
name: eventName.CATALOG_VISIBLE_CHANGED,
|
|
1750
|
+
callback(status) {
|
|
1751
|
+
callBack(status);
|
|
1752
|
+
}
|
|
1753
|
+
});
|
|
1754
|
+
break;
|
|
1755
|
+
}
|
|
1756
|
+
}
|
|
1757
|
+
},
|
|
1758
|
+
togglePageFullscreen(status) {
|
|
1759
|
+
updateSetting("pageFullscreen", status);
|
|
1760
|
+
},
|
|
1761
|
+
toggleFullscreen(status) {
|
|
1762
|
+
eventName.bus.emit(editorId, eventName.CHANGE_FULL_SCREEN, status);
|
|
1763
|
+
},
|
|
1764
|
+
togglePreview(status) {
|
|
1765
|
+
updateSetting("preview", status);
|
|
1766
|
+
},
|
|
1767
|
+
togglePreviewOnly(status) {
|
|
1768
|
+
updateSetting("previewOnly", status);
|
|
1769
|
+
},
|
|
1770
|
+
toggleHtmlPreview(status) {
|
|
1771
|
+
updateSetting("htmlPreview", status);
|
|
1772
|
+
},
|
|
1773
|
+
toggleCatalog(status) {
|
|
1774
|
+
eventName.bus.emit(editorId, eventName.CHANGE_CATALOG_VISIBLE, status);
|
|
1775
|
+
},
|
|
1776
|
+
triggerSave() {
|
|
1777
|
+
eventName.bus.emit(editorId, eventName.ON_SAVE);
|
|
1778
|
+
},
|
|
1779
|
+
insert(generate) {
|
|
1780
|
+
eventName.bus.emit(editorId, eventName.REPLACE, "universal", { generate });
|
|
1781
|
+
},
|
|
1782
|
+
focus(options2) {
|
|
1783
|
+
var _a;
|
|
1784
|
+
(_a = codeRef.value) == null ? void 0 : _a.focus(options2);
|
|
1785
|
+
},
|
|
1786
|
+
rerender() {
|
|
1787
|
+
eventName.bus.emit(editorId, eventName.RERENDER);
|
|
1788
|
+
},
|
|
1789
|
+
getSelectedText() {
|
|
1790
|
+
var _a;
|
|
1791
|
+
return (_a = codeRef.value) == null ? void 0 : _a.getSelectedText();
|
|
1792
|
+
},
|
|
1793
|
+
resetHistory() {
|
|
1794
|
+
var _a;
|
|
1795
|
+
(_a = codeRef.value) == null ? void 0 : _a.resetHistory();
|
|
1796
|
+
},
|
|
1797
|
+
domEventHandlers(handlers) {
|
|
1798
|
+
eventName.bus.emit(editorId, eventName.EVENT_LISTENER, handlers);
|
|
1799
|
+
},
|
|
1800
|
+
execCommand(direct) {
|
|
1801
|
+
eventName.bus.emit(editorId, eventName.REPLACE, direct);
|
|
1802
|
+
},
|
|
1803
|
+
getEditorView() {
|
|
1804
|
+
var _a;
|
|
1805
|
+
return (_a = codeRef.value) == null ? void 0 : _a.getEditorView();
|
|
1806
|
+
}
|
|
1807
|
+
};
|
|
1808
|
+
ctx.expose(exposeParam);
|
|
1809
|
+
};
|
|
1810
|
+
const useEditorId = (props) => {
|
|
1811
|
+
const defaultId = vue.useId();
|
|
1812
|
+
return props.id || props.editorId || `${config.prefix}-${defaultId}`;
|
|
1813
|
+
};
|
|
1814
|
+
const mdHeadingId = (text) => text;
|
|
1815
|
+
const mdPreviewProps = {
|
|
1816
|
+
/**
|
|
1817
|
+
* markdown content.
|
|
1818
|
+
*
|
|
1819
|
+
* @default ''
|
|
1820
|
+
*/
|
|
1821
|
+
modelValue: {
|
|
1822
|
+
type: String,
|
|
1823
|
+
default: ""
|
|
1824
|
+
},
|
|
1825
|
+
/**
|
|
1826
|
+
* input回调事件
|
|
1827
|
+
*/
|
|
1828
|
+
onChange: {
|
|
1829
|
+
type: Function,
|
|
1830
|
+
default: void 0
|
|
1831
|
+
},
|
|
1832
|
+
/**
|
|
1833
|
+
* 主题,支持light和dark
|
|
1834
|
+
*
|
|
1835
|
+
* @default 'light'
|
|
1836
|
+
*/
|
|
1837
|
+
theme: {
|
|
1838
|
+
type: String,
|
|
1839
|
+
default: "light"
|
|
1840
|
+
},
|
|
1841
|
+
/**
|
|
1842
|
+
* 外层类名
|
|
1843
|
+
*
|
|
1844
|
+
* @default ''
|
|
1845
|
+
*/
|
|
1846
|
+
class: {
|
|
1847
|
+
type: String,
|
|
1848
|
+
default: ""
|
|
1849
|
+
},
|
|
1850
|
+
/**
|
|
1851
|
+
* 预设语言名称
|
|
1852
|
+
*
|
|
1853
|
+
* @default 'zh-CN'
|
|
1854
|
+
*/
|
|
1855
|
+
language: {
|
|
1856
|
+
type: String,
|
|
1857
|
+
default: "zh-CN"
|
|
1858
|
+
},
|
|
1859
|
+
/**
|
|
1860
|
+
* html变化事件
|
|
1861
|
+
*/
|
|
1862
|
+
onHtmlChanged: {
|
|
1863
|
+
type: Function,
|
|
1864
|
+
default: void 0
|
|
1865
|
+
},
|
|
1866
|
+
/**
|
|
1867
|
+
* 获取目录结构
|
|
1868
|
+
*/
|
|
1869
|
+
onGetCatalog: {
|
|
1870
|
+
type: Function,
|
|
1871
|
+
default: void 0
|
|
1872
|
+
},
|
|
1873
|
+
/**
|
|
1874
|
+
* 编辑器唯一标识
|
|
1875
|
+
*
|
|
1876
|
+
* @default 'md-editor-v3'
|
|
1877
|
+
* @deprecated 5.x版本开始使用 id 替换
|
|
1878
|
+
*/
|
|
1879
|
+
editorId: {
|
|
1880
|
+
type: String,
|
|
1881
|
+
default: void 0
|
|
1882
|
+
},
|
|
1883
|
+
/**
|
|
1884
|
+
* 5.x版本开始 editorId 的替换
|
|
1885
|
+
*
|
|
1886
|
+
* @default 'md-editor-v3'
|
|
1887
|
+
*/
|
|
1888
|
+
id: {
|
|
1889
|
+
type: String,
|
|
1890
|
+
default: void 0
|
|
1891
|
+
},
|
|
1892
|
+
/**
|
|
1893
|
+
* 预览中代码是否显示行号
|
|
1894
|
+
*
|
|
1895
|
+
* @default true
|
|
1896
|
+
*/
|
|
1897
|
+
showCodeRowNumber: {
|
|
1898
|
+
type: Boolean,
|
|
1899
|
+
default: true
|
|
1900
|
+
},
|
|
1901
|
+
/**
|
|
1902
|
+
* 预览内容样式
|
|
1903
|
+
*
|
|
1904
|
+
* @default 'default'
|
|
1905
|
+
*/
|
|
1906
|
+
previewTheme: {
|
|
1907
|
+
type: String,
|
|
1908
|
+
default: "default"
|
|
1909
|
+
},
|
|
1910
|
+
/**
|
|
1911
|
+
* 编辑器样式
|
|
1912
|
+
*/
|
|
1913
|
+
style: {
|
|
1914
|
+
type: Object,
|
|
1915
|
+
default: () => ({})
|
|
1916
|
+
},
|
|
1917
|
+
/**
|
|
1918
|
+
* 标题的id生成方式
|
|
1919
|
+
*
|
|
1920
|
+
* @default (text: string) => text
|
|
1921
|
+
*/
|
|
1922
|
+
mdHeadingId: {
|
|
1923
|
+
type: Function,
|
|
1924
|
+
default: mdHeadingId
|
|
1925
|
+
},
|
|
1926
|
+
/**
|
|
1927
|
+
*
|
|
1928
|
+
* 不能保证文本正确的情况,在marked编译md文本后通过该方法处理
|
|
1929
|
+
* 推荐DOMPurify、sanitize-html
|
|
1930
|
+
*
|
|
1931
|
+
* @default (text: string) => text
|
|
1932
|
+
*/
|
|
1933
|
+
sanitize: {
|
|
1934
|
+
type: Function,
|
|
1935
|
+
default: (html) => html
|
|
1936
|
+
},
|
|
1937
|
+
/**
|
|
1938
|
+
* 不使用该mermaid
|
|
1939
|
+
*
|
|
1940
|
+
* @default false
|
|
1941
|
+
*/
|
|
1942
|
+
noMermaid: {
|
|
1943
|
+
type: Boolean,
|
|
1944
|
+
default: false
|
|
1945
|
+
},
|
|
1946
|
+
/**
|
|
1947
|
+
* 不使用katex
|
|
1948
|
+
*
|
|
1949
|
+
* @default false
|
|
1950
|
+
*/
|
|
1951
|
+
noKatex: {
|
|
1952
|
+
type: Boolean,
|
|
1953
|
+
default: false
|
|
1954
|
+
},
|
|
1955
|
+
/**
|
|
1956
|
+
* 代码主题
|
|
1957
|
+
*
|
|
1958
|
+
* @default 'atom'
|
|
1959
|
+
*/
|
|
1960
|
+
codeTheme: {
|
|
1961
|
+
type: String,
|
|
1962
|
+
default: "atom"
|
|
1963
|
+
},
|
|
1964
|
+
/**
|
|
1965
|
+
* 复制代码格式化方法
|
|
1966
|
+
*
|
|
1967
|
+
* @default (text) => text
|
|
1968
|
+
*/
|
|
1969
|
+
formatCopiedText: {
|
|
289
1970
|
type: Function,
|
|
290
|
-
default: () =>
|
|
291
|
-
|
|
1971
|
+
default: (text) => text
|
|
1972
|
+
},
|
|
1973
|
+
/**
|
|
1974
|
+
* 某些预览主题的代码模块背景是暗色系
|
|
1975
|
+
* 将这个属性设置为true,会自动在该主题下的light模式下使用暗色系的代码风格
|
|
1976
|
+
*
|
|
1977
|
+
* @default true
|
|
1978
|
+
*/
|
|
1979
|
+
codeStyleReverse: {
|
|
1980
|
+
type: Boolean,
|
|
1981
|
+
default: true
|
|
1982
|
+
},
|
|
1983
|
+
/**
|
|
1984
|
+
* 需要自动调整的预览主题
|
|
1985
|
+
*
|
|
1986
|
+
* @default ['default', 'mk-cute']
|
|
1987
|
+
*/
|
|
1988
|
+
codeStyleReverseList: {
|
|
1989
|
+
type: Array,
|
|
1990
|
+
default: ["default", "mk-cute"]
|
|
1991
|
+
},
|
|
1992
|
+
noHighlight: {
|
|
1993
|
+
type: Boolean,
|
|
1994
|
+
default: false
|
|
1995
|
+
},
|
|
1996
|
+
/**
|
|
1997
|
+
* 是否关闭编辑器默认的放大缩小功能
|
|
1998
|
+
*/
|
|
1999
|
+
noImgZoomIn: {
|
|
2000
|
+
type: Boolean,
|
|
2001
|
+
default: false
|
|
2002
|
+
},
|
|
2003
|
+
/**
|
|
2004
|
+
* 自定义的图标
|
|
2005
|
+
*/
|
|
2006
|
+
customIcon: {
|
|
2007
|
+
type: Object,
|
|
2008
|
+
default: {}
|
|
292
2009
|
},
|
|
293
|
-
|
|
2010
|
+
sanitizeMermaid: {
|
|
294
2011
|
type: Function,
|
|
295
|
-
default: () =>
|
|
296
|
-
|
|
2012
|
+
default: (h) => Promise.resolve(h)
|
|
2013
|
+
},
|
|
2014
|
+
/**
|
|
2015
|
+
* 是否开启折叠代码功能
|
|
2016
|
+
* 不开启会使用div标签替代details标签
|
|
2017
|
+
*
|
|
2018
|
+
* @default true
|
|
2019
|
+
*/
|
|
2020
|
+
codeFoldable: {
|
|
2021
|
+
type: Boolean,
|
|
2022
|
+
default: true
|
|
297
2023
|
},
|
|
298
|
-
|
|
2024
|
+
/**
|
|
2025
|
+
* 触发自动折叠代码的行数阈值
|
|
2026
|
+
*
|
|
2027
|
+
* @default 30
|
|
2028
|
+
*/
|
|
2029
|
+
autoFoldThreshold: {
|
|
299
2030
|
type: Number,
|
|
300
|
-
default:
|
|
2031
|
+
default: 30
|
|
2032
|
+
},
|
|
2033
|
+
/**
|
|
2034
|
+
* 内容重新挂载事件
|
|
2035
|
+
*
|
|
2036
|
+
* 相比起onHtmlChanged,onRemount会在重新挂载后触发
|
|
2037
|
+
*/
|
|
2038
|
+
onRemount: {
|
|
2039
|
+
type: Function,
|
|
2040
|
+
default: void 0
|
|
301
2041
|
}
|
|
302
2042
|
};
|
|
303
|
-
const
|
|
304
|
-
|
|
305
|
-
setup(props2) {
|
|
306
|
-
const scrollElementRef = vue.inject("scrollElementRef");
|
|
307
|
-
const rootNodeRef = vue.inject("roorNodeRef");
|
|
308
|
-
const currRef = vue.ref();
|
|
309
|
-
vue.watch(() => props2.tocItem.active, (active) => {
|
|
310
|
-
if (active) {
|
|
311
|
-
props2.onActive(props2.tocItem, currRef.value);
|
|
312
|
-
}
|
|
313
|
-
});
|
|
314
|
-
vue.onMounted(() => {
|
|
315
|
-
if (props2.tocItem.active) {
|
|
316
|
-
props2.onActive(props2.tocItem, currRef.value);
|
|
317
|
-
}
|
|
318
|
-
});
|
|
319
|
-
return () => {
|
|
320
|
-
const {
|
|
321
|
-
tocItem,
|
|
322
|
-
mdHeadingId,
|
|
323
|
-
onClick,
|
|
324
|
-
scrollElementOffsetTop
|
|
325
|
-
} = props2;
|
|
326
|
-
return vue.createVNode("div", {
|
|
327
|
-
"ref": currRef,
|
|
328
|
-
"class": [`${config.prefix}-catalog-link`, tocItem.active && `${config.prefix}-catalog-active`],
|
|
329
|
-
"onClick": (e) => {
|
|
330
|
-
e.stopPropagation();
|
|
331
|
-
onClick(e, tocItem);
|
|
332
|
-
if (e.defaultPrevented) {
|
|
333
|
-
return;
|
|
334
|
-
}
|
|
335
|
-
const id = mdHeadingId(tocItem.text, tocItem.level, tocItem.index);
|
|
336
|
-
const targetHeadEle = rootNodeRef.value.getElementById(id);
|
|
337
|
-
const scrollContainer = scrollElementRef.value;
|
|
338
|
-
if (targetHeadEle && scrollContainer) {
|
|
339
|
-
let par = targetHeadEle.offsetParent;
|
|
340
|
-
let offsetTop = targetHeadEle.offsetTop;
|
|
341
|
-
if (scrollContainer.contains(par)) {
|
|
342
|
-
while (par && scrollContainer != par) {
|
|
343
|
-
offsetTop += par == null ? void 0 : par.offsetTop;
|
|
344
|
-
par = par == null ? void 0 : par.offsetParent;
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
const pel = targetHeadEle.previousElementSibling;
|
|
348
|
-
let currMarginTop = 0;
|
|
349
|
-
if (!pel) {
|
|
350
|
-
currMarginTop = getComputedStyleNum(targetHeadEle, "margin-top");
|
|
351
|
-
}
|
|
352
|
-
scrollContainer == null ? void 0 : scrollContainer.scrollTo({
|
|
353
|
-
top: offsetTop - scrollElementOffsetTop - currMarginTop,
|
|
354
|
-
behavior: "smooth"
|
|
355
|
-
});
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
}, [vue.createVNode("span", {
|
|
359
|
-
"title": tocItem.text
|
|
360
|
-
}, [tocItem.text]), tocItem.children && tocItem.children.length > 0 && vue.createVNode("div", {
|
|
361
|
-
"class": `${config.prefix}-catalog-wrapper`
|
|
362
|
-
}, [tocItem.children.map((item) => vue.createVNode(CatalogLink, {
|
|
363
|
-
"mdHeadingId": mdHeadingId,
|
|
364
|
-
"key": `${tocItem.text}-link-${item.level}-${item.text}`,
|
|
365
|
-
"tocItem": item,
|
|
366
|
-
"onActive": props2.onActive,
|
|
367
|
-
"onClick": onClick,
|
|
368
|
-
"scrollElementOffsetTop": scrollElementOffsetTop
|
|
369
|
-
}, null))])]);
|
|
370
|
-
};
|
|
371
|
-
}
|
|
372
|
-
});
|
|
373
|
-
const props = {
|
|
2043
|
+
const editorProps = {
|
|
2044
|
+
...mdPreviewProps,
|
|
374
2045
|
/**
|
|
375
|
-
*
|
|
2046
|
+
* input回调事件
|
|
376
2047
|
*/
|
|
377
|
-
|
|
378
|
-
type:
|
|
2048
|
+
onSave: {
|
|
2049
|
+
type: Function,
|
|
379
2050
|
default: void 0
|
|
380
2051
|
},
|
|
381
|
-
|
|
2052
|
+
/**
|
|
2053
|
+
* 上传图片事件
|
|
2054
|
+
*/
|
|
2055
|
+
onUploadImg: {
|
|
2056
|
+
type: Function,
|
|
2057
|
+
default: void 0
|
|
2058
|
+
},
|
|
2059
|
+
/**
|
|
2060
|
+
* 是否页面内全屏
|
|
2061
|
+
*
|
|
2062
|
+
* @default false
|
|
2063
|
+
*/
|
|
2064
|
+
pageFullscreen: {
|
|
2065
|
+
type: Boolean,
|
|
2066
|
+
default: false
|
|
2067
|
+
},
|
|
2068
|
+
/**
|
|
2069
|
+
* 是否展开预览
|
|
2070
|
+
*
|
|
2071
|
+
* @default true
|
|
2072
|
+
*/
|
|
2073
|
+
preview: {
|
|
2074
|
+
type: Boolean,
|
|
2075
|
+
default: true
|
|
2076
|
+
},
|
|
2077
|
+
/**
|
|
2078
|
+
* 是否展开html预览
|
|
2079
|
+
*
|
|
2080
|
+
* @default false
|
|
2081
|
+
*/
|
|
2082
|
+
htmlPreview: {
|
|
2083
|
+
type: Boolean,
|
|
2084
|
+
default: false
|
|
2085
|
+
},
|
|
2086
|
+
/**
|
|
2087
|
+
* 仅预览模式,不显示toolbar和编辑框
|
|
2088
|
+
*
|
|
2089
|
+
* @4.0.0开始移除该设置,使用组件MdPreview替换
|
|
2090
|
+
*
|
|
2091
|
+
* @default false
|
|
2092
|
+
*/
|
|
2093
|
+
// previewOnly: {
|
|
2094
|
+
// type: Boolean as PropType<boolean>,
|
|
2095
|
+
// default: false
|
|
2096
|
+
// },
|
|
2097
|
+
/**
|
|
2098
|
+
* 工具栏选择显示
|
|
2099
|
+
*
|
|
2100
|
+
* @default allToolbar
|
|
2101
|
+
*/
|
|
2102
|
+
toolbars: {
|
|
2103
|
+
type: Array,
|
|
2104
|
+
default: config.allToolbar
|
|
2105
|
+
},
|
|
2106
|
+
/**
|
|
2107
|
+
* 工具栏选择不显示
|
|
2108
|
+
*
|
|
2109
|
+
* @default []
|
|
2110
|
+
*/
|
|
2111
|
+
toolbarsExclude: {
|
|
2112
|
+
type: Array,
|
|
2113
|
+
default: []
|
|
2114
|
+
},
|
|
2115
|
+
/**
|
|
2116
|
+
* 格式化md
|
|
2117
|
+
*
|
|
2118
|
+
* @default true
|
|
2119
|
+
*/
|
|
2120
|
+
noPrettier: {
|
|
2121
|
+
type: Boolean,
|
|
2122
|
+
default: false
|
|
2123
|
+
},
|
|
2124
|
+
/**
|
|
2125
|
+
* 一个tab等于空格数
|
|
2126
|
+
*
|
|
2127
|
+
* @default 2
|
|
2128
|
+
*/
|
|
2129
|
+
tabWidth: {
|
|
2130
|
+
type: Number,
|
|
2131
|
+
default: 2
|
|
2132
|
+
},
|
|
2133
|
+
/**
|
|
2134
|
+
* 表格预设格子数
|
|
2135
|
+
*
|
|
2136
|
+
* 也可以是[6, 4, 10, 8]
|
|
2137
|
+
*
|
|
2138
|
+
* @default [6, 4]
|
|
2139
|
+
*/
|
|
2140
|
+
tableShape: {
|
|
2141
|
+
type: Array,
|
|
2142
|
+
default: [6, 4]
|
|
2143
|
+
},
|
|
2144
|
+
/**
|
|
2145
|
+
* 空提示
|
|
2146
|
+
*
|
|
2147
|
+
* @default ''
|
|
2148
|
+
*/
|
|
2149
|
+
placeholder: {
|
|
382
2150
|
type: String,
|
|
383
2151
|
default: ""
|
|
384
2152
|
},
|
|
385
|
-
|
|
2153
|
+
/**
|
|
2154
|
+
* 自定义的工具栏列表
|
|
2155
|
+
*/
|
|
2156
|
+
defToolbars: {
|
|
2157
|
+
type: [String, Object],
|
|
2158
|
+
default: void 0
|
|
2159
|
+
},
|
|
2160
|
+
/**
|
|
2161
|
+
* 内部错误捕获
|
|
2162
|
+
*/
|
|
2163
|
+
onError: {
|
|
386
2164
|
type: Function,
|
|
387
|
-
default:
|
|
2165
|
+
default: void 0
|
|
2166
|
+
},
|
|
2167
|
+
/**
|
|
2168
|
+
* 页脚列表显示顺序
|
|
2169
|
+
*/
|
|
2170
|
+
footers: {
|
|
2171
|
+
type: Array,
|
|
2172
|
+
default: config.allFooter
|
|
388
2173
|
},
|
|
389
2174
|
/**
|
|
390
|
-
*
|
|
391
|
-
* 元素必须定位!!!!!!
|
|
2175
|
+
* 是否默认激活输入框和预览框同步滚动
|
|
392
2176
|
*
|
|
393
|
-
*
|
|
2177
|
+
* @default true
|
|
2178
|
+
*/
|
|
2179
|
+
scrollAuto: {
|
|
2180
|
+
type: Boolean,
|
|
2181
|
+
default: true
|
|
2182
|
+
},
|
|
2183
|
+
/**
|
|
2184
|
+
* 自定义的也叫工具组件列表
|
|
394
2185
|
*/
|
|
395
|
-
|
|
2186
|
+
defFooters: {
|
|
396
2187
|
type: [String, Object],
|
|
397
2188
|
default: void 0
|
|
398
2189
|
},
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
2190
|
+
/**
|
|
2191
|
+
* 是否禁用上传图片
|
|
2192
|
+
*
|
|
2193
|
+
* @default false
|
|
2194
|
+
*/
|
|
2195
|
+
noUploadImg: {
|
|
2196
|
+
type: Boolean,
|
|
2197
|
+
default: false
|
|
402
2198
|
},
|
|
403
2199
|
/**
|
|
404
|
-
*
|
|
2200
|
+
* 文本区域自动获得焦点
|
|
405
2201
|
*
|
|
406
|
-
*
|
|
2202
|
+
* @default false
|
|
407
2203
|
*/
|
|
408
|
-
|
|
409
|
-
type:
|
|
410
|
-
default:
|
|
2204
|
+
autoFocus: {
|
|
2205
|
+
type: Boolean,
|
|
2206
|
+
default: false
|
|
2207
|
+
},
|
|
2208
|
+
/**
|
|
2209
|
+
* 禁用文本区域
|
|
2210
|
+
*
|
|
2211
|
+
* @default false
|
|
2212
|
+
*/
|
|
2213
|
+
disabled: {
|
|
2214
|
+
type: Boolean,
|
|
2215
|
+
default: false
|
|
411
2216
|
},
|
|
412
2217
|
/**
|
|
413
|
-
*
|
|
2218
|
+
* 文本区域为只读
|
|
414
2219
|
*
|
|
415
|
-
*
|
|
2220
|
+
* @default false
|
|
2221
|
+
*/
|
|
2222
|
+
readOnly: {
|
|
2223
|
+
type: Boolean,
|
|
2224
|
+
default: false
|
|
2225
|
+
},
|
|
2226
|
+
/**
|
|
2227
|
+
* 文本区域允许的最大字符数
|
|
416
2228
|
*/
|
|
417
|
-
|
|
2229
|
+
maxLength: {
|
|
418
2230
|
type: Number,
|
|
419
|
-
default: 0
|
|
2231
|
+
default: void 0
|
|
2232
|
+
},
|
|
2233
|
+
/**
|
|
2234
|
+
* 是否启用自动识别粘贴代码类别
|
|
2235
|
+
* 目前支持 vscode 复制的代码识别
|
|
2236
|
+
*
|
|
2237
|
+
* @default false
|
|
2238
|
+
*/
|
|
2239
|
+
autoDetectCode: {
|
|
2240
|
+
type: Boolean,
|
|
2241
|
+
default: false
|
|
420
2242
|
},
|
|
421
|
-
|
|
2243
|
+
/**
|
|
2244
|
+
* 输入框失去焦点时触发事件
|
|
2245
|
+
*/
|
|
2246
|
+
onBlur: {
|
|
422
2247
|
type: Function,
|
|
423
2248
|
default: void 0
|
|
424
2249
|
},
|
|
425
|
-
|
|
2250
|
+
/**
|
|
2251
|
+
* 输入框获得焦点时触发事件
|
|
2252
|
+
*/
|
|
2253
|
+
onFocus: {
|
|
426
2254
|
type: Function,
|
|
427
2255
|
default: void 0
|
|
428
2256
|
},
|
|
429
2257
|
/**
|
|
430
|
-
*
|
|
2258
|
+
* @codemirror/autocomplete匹配关键词的方法列表
|
|
2259
|
+
*
|
|
2260
|
+
* 它会被像下面这样嵌入编辑器
|
|
2261
|
+
*
|
|
2262
|
+
* import { autocompletion } from '@codemirror/autocomplete';
|
|
2263
|
+
* autocompletion({
|
|
2264
|
+
* override: [...completions]
|
|
2265
|
+
* })
|
|
2266
|
+
*/
|
|
2267
|
+
completions: {
|
|
2268
|
+
type: Array,
|
|
2269
|
+
default: void 0
|
|
2270
|
+
},
|
|
2271
|
+
/**
|
|
2272
|
+
* 是否在工具栏下面显示对应的文字名称
|
|
431
2273
|
*
|
|
432
|
-
*
|
|
2274
|
+
* @default false
|
|
433
2275
|
*/
|
|
434
|
-
|
|
2276
|
+
showToolbarName: {
|
|
435
2277
|
type: Boolean,
|
|
436
2278
|
default: false
|
|
437
2279
|
},
|
|
438
2280
|
/**
|
|
439
|
-
*
|
|
2281
|
+
* 字符输入事件
|
|
2282
|
+
*/
|
|
2283
|
+
onInput: {
|
|
2284
|
+
type: Function,
|
|
2285
|
+
default: void 0
|
|
2286
|
+
},
|
|
2287
|
+
onDrop: {
|
|
2288
|
+
type: Function,
|
|
2289
|
+
default: void 0
|
|
2290
|
+
},
|
|
2291
|
+
/**
|
|
2292
|
+
* 输入框的默认宽度
|
|
2293
|
+
*
|
|
2294
|
+
* @example '100px'/'50%'
|
|
2295
|
+
* @default '50%
|
|
2296
|
+
*/
|
|
2297
|
+
inputBoxWidth: {
|
|
2298
|
+
type: String,
|
|
2299
|
+
default: "50%"
|
|
2300
|
+
},
|
|
2301
|
+
/**
|
|
2302
|
+
* 输入框宽度变化事件
|
|
2303
|
+
*/
|
|
2304
|
+
oninputBoxWidthChange: {
|
|
2305
|
+
type: Function,
|
|
2306
|
+
default: void 0
|
|
2307
|
+
},
|
|
2308
|
+
/**
|
|
2309
|
+
* 替换粘贴的图片链接
|
|
2310
|
+
*
|
|
2311
|
+
* @param t 图片链接
|
|
2312
|
+
* @returns
|
|
2313
|
+
*/
|
|
2314
|
+
transformImgUrl: {
|
|
2315
|
+
type: Function,
|
|
2316
|
+
default: (t) => t
|
|
2317
|
+
},
|
|
2318
|
+
/**
|
|
2319
|
+
* 内置的目录显示的状态
|
|
2320
|
+
*
|
|
2321
|
+
* 'fixed': 悬浮在内容上方
|
|
2322
|
+
* 'flat': 展示在右侧
|
|
2323
|
+
*
|
|
2324
|
+
* \>=5.3.0
|
|
440
2325
|
*
|
|
441
|
-
*
|
|
2326
|
+
* @default 'fixed'
|
|
442
2327
|
*/
|
|
443
|
-
|
|
2328
|
+
catalogLayout: {
|
|
444
2329
|
type: String,
|
|
445
|
-
default: "
|
|
2330
|
+
default: "fixed"
|
|
446
2331
|
},
|
|
447
2332
|
/**
|
|
448
2333
|
* 控制最大显示的目录层级
|
|
@@ -450,197 +2335,120 @@ const props = {
|
|
|
450
2335
|
catalogMaxDepth: {
|
|
451
2336
|
type: Number,
|
|
452
2337
|
default: void 0
|
|
2338
|
+
},
|
|
2339
|
+
/**
|
|
2340
|
+
* 工具栏直接插入内容到输入框
|
|
2341
|
+
*/
|
|
2342
|
+
insertLinkDirect: {
|
|
2343
|
+
type: Boolean,
|
|
2344
|
+
default: false
|
|
453
2345
|
}
|
|
454
2346
|
};
|
|
455
|
-
const
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
if (item.level > lastItem.level) {
|
|
499
|
-
for (let i = lastItem.level + 1; i <= 6; i++) {
|
|
500
|
-
const {
|
|
501
|
-
children
|
|
502
|
-
} = lastItem;
|
|
503
|
-
if (!children) {
|
|
504
|
-
lastItem.children = [item];
|
|
505
|
-
break;
|
|
506
|
-
}
|
|
507
|
-
lastItem = children[children.length - 1];
|
|
508
|
-
if (item.level <= lastItem.level) {
|
|
509
|
-
children.push(item);
|
|
510
|
-
break;
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
} else {
|
|
514
|
-
tocItems.push(item);
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
});
|
|
518
|
-
return tocItems;
|
|
519
|
-
});
|
|
520
|
-
const getScrollElement = () => {
|
|
521
|
-
var _a;
|
|
522
|
-
if (state.scrollElement instanceof HTMLElement) {
|
|
523
|
-
return state.scrollElement;
|
|
524
|
-
}
|
|
525
|
-
let scrollRoot = document;
|
|
526
|
-
if (state.scrollElement === defaultScrollElement || props2.isScrollElementInShadow) {
|
|
527
|
-
scrollRoot = (_a = catalogRef.value) == null ? void 0 : _a.getRootNode();
|
|
528
|
-
}
|
|
529
|
-
return scrollRoot.querySelector(state.scrollElement);
|
|
530
|
-
};
|
|
531
|
-
const findActiveHeading = (list) => {
|
|
532
|
-
if (list.length === 0) {
|
|
533
|
-
activeItem.value = void 0;
|
|
534
|
-
state.list = [];
|
|
535
|
-
return false;
|
|
536
|
-
}
|
|
537
|
-
const {
|
|
538
|
-
activeHead
|
|
539
|
-
} = list.reduce((activeData, link, index$1) => {
|
|
540
|
-
var _a;
|
|
541
|
-
let relativeTop = 0;
|
|
542
|
-
if (props2.syncWith === "preview") {
|
|
543
|
-
const linkEle = (_a = rootNodeRef.value) == null ? void 0 : _a.getElementById(props2.mdHeadingId(link.text, link.level, index$1 + 1));
|
|
544
|
-
if (linkEle instanceof HTMLElement) {
|
|
545
|
-
relativeTop = index.getRelativeTop(linkEle, scrollElementRef.value);
|
|
546
|
-
}
|
|
547
|
-
} else {
|
|
548
|
-
const view = editorViewRef.value;
|
|
549
|
-
if (view) {
|
|
550
|
-
const top = view.lineBlockAt(view.state.doc.line(link.line + 1).from).top;
|
|
551
|
-
const scrollTop = view.scrollDOM.scrollTop;
|
|
552
|
-
relativeTop = top - scrollTop;
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
if (relativeTop < props2.offsetTop && relativeTop > activeData.minTop) {
|
|
556
|
-
return {
|
|
557
|
-
activeHead: link,
|
|
558
|
-
minTop: relativeTop
|
|
559
|
-
};
|
|
560
|
-
}
|
|
561
|
-
return activeData;
|
|
562
|
-
}, {
|
|
563
|
-
activeHead: list[0],
|
|
564
|
-
minTop: Number.MIN_SAFE_INTEGER
|
|
565
|
-
});
|
|
566
|
-
activeItem.value = activeHead;
|
|
567
|
-
state.list = list;
|
|
568
|
-
};
|
|
569
|
-
const onActive = (tocItem, ele) => {
|
|
570
|
-
var _a;
|
|
571
|
-
indicatorStyles.value.top = ele.offsetTop + getComputedStyleNum(ele, "padding-top") + "px";
|
|
572
|
-
(_a = props2.onActive) == null ? void 0 : _a.call(props2, tocItem, ele);
|
|
573
|
-
ctx.emit("onActive", tocItem, ele);
|
|
574
|
-
};
|
|
575
|
-
const scrollHandler = () => {
|
|
576
|
-
findActiveHeading(state.list);
|
|
577
|
-
};
|
|
578
|
-
const catalogChangedHandler = (_list) => {
|
|
579
|
-
var _a, _b, _c;
|
|
580
|
-
(_a = scrollContainerRef.value) == null ? void 0 : _a.removeEventListener("scroll", scrollHandler);
|
|
581
|
-
if (props2.syncWith === "editor") {
|
|
582
|
-
scrollContainerRef.value = (_b = editorViewRef.value) == null ? void 0 : _b.scrollDOM;
|
|
583
|
-
} else {
|
|
584
|
-
const scrollElement = getScrollElement();
|
|
585
|
-
scrollElementRef.value = scrollElement;
|
|
586
|
-
scrollContainerRef.value = scrollElement === document.documentElement ? document : scrollElement;
|
|
587
|
-
}
|
|
588
|
-
findActiveHeading(_list);
|
|
589
|
-
(_c = scrollContainerRef.value) == null ? void 0 : _c.addEventListener("scroll", scrollHandler);
|
|
590
|
-
};
|
|
591
|
-
const getEditorView = (view) => {
|
|
592
|
-
editorViewRef.value = view;
|
|
593
|
-
};
|
|
594
|
-
vue.watch([() => props2.syncWith, editorViewRef, () => props2.catalogMaxDepth], () => {
|
|
595
|
-
catalogChangedHandler(state.list);
|
|
596
|
-
});
|
|
597
|
-
vue.onMounted(() => {
|
|
598
|
-
rootNodeRef.value = catalogRef.value.getRootNode();
|
|
599
|
-
eventName.bus.on(editorId, {
|
|
600
|
-
name: eventName.CATALOG_CHANGED,
|
|
601
|
-
callback: catalogChangedHandler
|
|
602
|
-
});
|
|
603
|
-
eventName.bus.on(editorId, {
|
|
604
|
-
name: eventName.GET_EDITOR_VIEW,
|
|
605
|
-
callback: getEditorView
|
|
606
|
-
});
|
|
607
|
-
eventName.bus.emit(editorId, eventName.PUSH_CATALOG);
|
|
608
|
-
eventName.bus.emit(editorId, eventName.SEND_EDITOR_VIEW);
|
|
2347
|
+
const mdPreviewEmits = [
|
|
2348
|
+
"onHtmlChanged",
|
|
2349
|
+
"onGetCatalog",
|
|
2350
|
+
"onChange",
|
|
2351
|
+
"onRemount",
|
|
2352
|
+
"update:modelValue"
|
|
2353
|
+
];
|
|
2354
|
+
const editorEmits = [
|
|
2355
|
+
...mdPreviewEmits,
|
|
2356
|
+
"onSave",
|
|
2357
|
+
"onUploadImg",
|
|
2358
|
+
"onError",
|
|
2359
|
+
"onBlur",
|
|
2360
|
+
"onFocus",
|
|
2361
|
+
"onInput",
|
|
2362
|
+
"onDrop",
|
|
2363
|
+
"oninputBoxWidthChange"
|
|
2364
|
+
];
|
|
2365
|
+
const useExpose = (props, ctx, options) => {
|
|
2366
|
+
const { editorId } = options;
|
|
2367
|
+
const exposeParam = {
|
|
2368
|
+
rerender() {
|
|
2369
|
+
eventName.bus.emit(editorId, eventName.RERENDER);
|
|
2370
|
+
}
|
|
2371
|
+
};
|
|
2372
|
+
ctx.expose(exposeParam);
|
|
2373
|
+
};
|
|
2374
|
+
const MdPreview = /* @__PURE__ */ vue.defineComponent({
|
|
2375
|
+
name: "MdPreview",
|
|
2376
|
+
props: mdPreviewProps,
|
|
2377
|
+
emits: mdPreviewEmits,
|
|
2378
|
+
setup(props, ctx) {
|
|
2379
|
+
const {
|
|
2380
|
+
noKatex,
|
|
2381
|
+
noMermaid,
|
|
2382
|
+
noHighlight
|
|
2383
|
+
} = props;
|
|
2384
|
+
const rootRef = vue.ref();
|
|
2385
|
+
const {
|
|
2386
|
+
editorId
|
|
2387
|
+
} = useProvidePreview(props, rootRef);
|
|
2388
|
+
useExpose(props, ctx, {
|
|
2389
|
+
editorId
|
|
609
2390
|
});
|
|
610
2391
|
vue.onBeforeUnmount(() => {
|
|
611
|
-
|
|
612
|
-
eventName.bus.remove(editorId, eventName.CATALOG_CHANGED, catalogChangedHandler);
|
|
613
|
-
eventName.bus.remove(editorId, eventName.GET_EDITOR_VIEW, getEditorView);
|
|
614
|
-
(_a = scrollContainerRef.value) == null ? void 0 : _a.removeEventListener("scroll", scrollHandler);
|
|
2392
|
+
eventName.bus.clear(editorId);
|
|
615
2393
|
});
|
|
616
|
-
return () =>
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
"
|
|
2394
|
+
return () => {
|
|
2395
|
+
return vue.createVNode("div", {
|
|
2396
|
+
"id": editorId,
|
|
2397
|
+
"class": [config.prefix, props.class, props.theme === "dark" && `${config.prefix}-dark`, `${config.prefix}-previewOnly`],
|
|
2398
|
+
"style": props.style,
|
|
2399
|
+
"ref": rootRef
|
|
2400
|
+
}, [vue.createVNode(ContentPreview, {
|
|
2401
|
+
"modelValue": props.modelValue,
|
|
2402
|
+
"onChange": (value) => {
|
|
2403
|
+
var _a;
|
|
2404
|
+
(_a = props.onChange) == null ? void 0 : _a.call(props, value);
|
|
2405
|
+
ctx.emit("onChange", value);
|
|
2406
|
+
ctx.emit("update:modelValue", value);
|
|
2407
|
+
},
|
|
2408
|
+
"onHtmlChanged": (html) => {
|
|
2409
|
+
var _a;
|
|
2410
|
+
(_a = props.onHtmlChanged) == null ? void 0 : _a.call(props, html);
|
|
2411
|
+
ctx.emit("onHtmlChanged", html);
|
|
2412
|
+
},
|
|
2413
|
+
"onGetCatalog": (list) => {
|
|
631
2414
|
var _a;
|
|
632
|
-
(_a =
|
|
633
|
-
ctx.emit("
|
|
2415
|
+
(_a = props.onGetCatalog) == null ? void 0 : _a.call(props, list);
|
|
2416
|
+
ctx.emit("onGetCatalog", list);
|
|
634
2417
|
},
|
|
635
|
-
"
|
|
636
|
-
|
|
637
|
-
|
|
2418
|
+
"mdHeadingId": props.mdHeadingId,
|
|
2419
|
+
"noMermaid": noMermaid,
|
|
2420
|
+
"sanitize": props.sanitize,
|
|
2421
|
+
"noKatex": noKatex,
|
|
2422
|
+
"formatCopiedText": props.formatCopiedText,
|
|
2423
|
+
"noHighlight": noHighlight,
|
|
2424
|
+
"noImgZoomIn": props.noImgZoomIn,
|
|
2425
|
+
"previewOnly": true,
|
|
2426
|
+
"sanitizeMermaid": props.sanitizeMermaid,
|
|
2427
|
+
"codeFoldable": props.codeFoldable,
|
|
2428
|
+
"autoFoldThreshold": props.autoFoldThreshold,
|
|
2429
|
+
"onRemount": () => {
|
|
2430
|
+
var _a;
|
|
2431
|
+
(_a = props.onRemount) == null ? void 0 : _a.call(props);
|
|
2432
|
+
ctx.emit("onRemount");
|
|
2433
|
+
}
|
|
2434
|
+
}, null)]);
|
|
2435
|
+
};
|
|
638
2436
|
}
|
|
639
2437
|
});
|
|
640
|
-
|
|
641
|
-
app.component(
|
|
2438
|
+
MdPreview.install = (app) => {
|
|
2439
|
+
app.component(MdPreview.name, MdPreview);
|
|
642
2440
|
return app;
|
|
643
2441
|
};
|
|
644
|
-
exports.
|
|
645
|
-
exports.
|
|
646
|
-
exports.
|
|
2442
|
+
exports.CDN_IDS = CDN_IDS;
|
|
2443
|
+
exports.ContentPreview = ContentPreview;
|
|
2444
|
+
exports.MdPreview = MdPreview;
|
|
2445
|
+
exports.contentProps = contentProps;
|
|
2446
|
+
exports.editorEmits = editorEmits;
|
|
2447
|
+
exports.editorProps = editorProps;
|
|
2448
|
+
exports.useCatalog = useCatalog;
|
|
2449
|
+
exports.useConfig = useConfig;
|
|
2450
|
+
exports.useErrorCatcher = useErrorCatcher;
|
|
2451
|
+
exports.useExpansion = useExpansion;
|
|
2452
|
+
exports.useExpose = useExpose$1;
|
|
2453
|
+
exports.useOnSave = useOnSave;
|
|
2454
|
+
exports.useProvide = useProvide;
|