md-editor-v3 5.4.0-1 → 5.4.0-2
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/chunks/config.cjs +2 -1
- package/lib/cjs/chunks/dom.cjs +131 -76
- package/lib/cjs/chunks/index.cjs +36 -35
- package/lib/cjs/index.cjs +2 -1
- package/lib/es/chunks/config.mjs +2 -1
- package/lib/es/chunks/dom.mjs +131 -76
- package/lib/es/chunks/index.mjs +37 -36
- package/lib/es/index.mjs +2 -1
- package/lib/preview.css +1 -1
- package/lib/style.css +1 -1
- package/lib/types/MdEditor/Editor.d.ts +2 -8
- package/lib/types/MdEditor/components/Icon/Str.d.ts +2 -3
- package/lib/types/MdEditor/layouts/Content/composition/useMermaid.d.ts +0 -1
- package/lib/types/MdEditor/type.d.ts +13 -4
- package/lib/types/MdEditor/utils/dom.d.ts +4 -1
- package/lib/types/MdPreview/MdPreview.d.ts +2 -8
- package/lib/umd/index.js +101 -101
- package/package.json +2 -2
package/lib/cjs/chunks/dom.cjs
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
const config = require("./config.cjs");
|
|
3
|
+
const iconMaps = {
|
|
4
|
+
copy: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-copy ${config.prefix}-icon"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>`,
|
|
5
|
+
"collapse-tips": `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-circle-chevron-left ${config.prefix}-icon"><circle cx="12" cy="12" r="10"/><path d="m14 16-4-4 4-4"/></svg>`,
|
|
6
|
+
pin: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-pin"><path d="M12 17v5"/><path d="M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z"/></svg>`,
|
|
7
|
+
"pin-off": `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-pin-off"><path d="M12 17v5"/><path d="M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89"/><path d="m2 2 20 20"/><path d="M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11"/></svg>`
|
|
8
|
+
};
|
|
9
|
+
const StrIcon = (name, customIcon) => {
|
|
10
|
+
if (typeof customIcon[name] === "string") {
|
|
11
|
+
return customIcon[name];
|
|
12
|
+
}
|
|
13
|
+
return iconMaps[name];
|
|
14
|
+
};
|
|
15
|
+
const StrIcon$1 = StrIcon;
|
|
2
16
|
const keyMove = (trigger, moveHandler) => {
|
|
3
17
|
const triggerMouseDown = (mdown) => {
|
|
4
18
|
const parent = trigger.parentElement || document.body;
|
|
@@ -69,7 +83,8 @@ const createHTMLElement = (tagName, attributes) => {
|
|
|
69
83
|
const zoomMermaid = /* @__PURE__ */ (() => {
|
|
70
84
|
const addEvent = (container) => {
|
|
71
85
|
if (!container) {
|
|
72
|
-
return
|
|
86
|
+
return () => {
|
|
87
|
+
};
|
|
73
88
|
}
|
|
74
89
|
const content = container.firstChild;
|
|
75
90
|
let scale = 1;
|
|
@@ -82,100 +97,140 @@ const zoomMermaid = /* @__PURE__ */ (() => {
|
|
|
82
97
|
const updateTransform = () => {
|
|
83
98
|
content.style.transform = `translate(${posX}px, ${posY}px) scale(${scale})`;
|
|
84
99
|
};
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
(event)
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
} else if (event.touches.length === 2) {
|
|
111
|
-
const newDistance = Math.hypot(
|
|
112
|
-
event.touches[0].clientX - event.touches[1].clientX,
|
|
113
|
-
event.touches[0].clientY - event.touches[1].clientY
|
|
114
|
-
);
|
|
115
|
-
const scaleChange = newDistance / initialDistance;
|
|
116
|
-
const previousScale = scale;
|
|
117
|
-
scale = initialScale * (1 + (scaleChange - 1));
|
|
118
|
-
const centerX = (event.touches[0].clientX + event.touches[1].clientX) / 2;
|
|
119
|
-
const centerY = (event.touches[0].clientY + event.touches[1].clientY) / 2;
|
|
120
|
-
const rect = content.getBoundingClientRect();
|
|
121
|
-
const relativeX = (centerX - rect.left) / previousScale;
|
|
122
|
-
const relativeY = (centerY - rect.top) / previousScale;
|
|
123
|
-
posX -= relativeX * (scale - previousScale);
|
|
124
|
-
posY -= relativeY * (scale - previousScale);
|
|
125
|
-
updateTransform();
|
|
126
|
-
}
|
|
127
|
-
},
|
|
128
|
-
{ passive: false }
|
|
129
|
-
);
|
|
130
|
-
container.addEventListener("touchend", () => {
|
|
131
|
-
isDragging = false;
|
|
132
|
-
});
|
|
133
|
-
container.addEventListener(
|
|
134
|
-
"wheel",
|
|
135
|
-
(event) => {
|
|
136
|
-
event.preventDefault();
|
|
137
|
-
const scaleAmount = 0.02;
|
|
100
|
+
const onTouchStart = (event) => {
|
|
101
|
+
if (event.touches.length === 1) {
|
|
102
|
+
isDragging = true;
|
|
103
|
+
startX = event.touches[0].clientX - posX;
|
|
104
|
+
startY = event.touches[0].clientY - posY;
|
|
105
|
+
} else if (event.touches.length === 2) {
|
|
106
|
+
initialDistance = Math.hypot(
|
|
107
|
+
event.touches[0].clientX - event.touches[1].clientX,
|
|
108
|
+
event.touches[0].clientY - event.touches[1].clientY
|
|
109
|
+
);
|
|
110
|
+
initialScale = scale;
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
const onTouchMove = (event) => {
|
|
114
|
+
event.preventDefault();
|
|
115
|
+
if (isDragging && event.touches.length === 1) {
|
|
116
|
+
posX = event.touches[0].clientX - startX;
|
|
117
|
+
posY = event.touches[0].clientY - startY;
|
|
118
|
+
updateTransform();
|
|
119
|
+
} else if (event.touches.length === 2) {
|
|
120
|
+
const newDistance = Math.hypot(
|
|
121
|
+
event.touches[0].clientX - event.touches[1].clientX,
|
|
122
|
+
event.touches[0].clientY - event.touches[1].clientY
|
|
123
|
+
);
|
|
124
|
+
const scaleChange = newDistance / initialDistance;
|
|
138
125
|
const previousScale = scale;
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
scale = Math.max(0.1, scale - scaleAmount);
|
|
143
|
-
}
|
|
126
|
+
scale = initialScale * (1 + (scaleChange - 1));
|
|
127
|
+
const centerX = (event.touches[0].clientX + event.touches[1].clientX) / 2;
|
|
128
|
+
const centerY = (event.touches[0].clientY + event.touches[1].clientY) / 2;
|
|
144
129
|
const rect = content.getBoundingClientRect();
|
|
145
|
-
const
|
|
146
|
-
const
|
|
147
|
-
posX -=
|
|
148
|
-
posY -=
|
|
130
|
+
const relativeX = (centerX - rect.left) / previousScale;
|
|
131
|
+
const relativeY = (centerY - rect.top) / previousScale;
|
|
132
|
+
posX -= relativeX * (scale - previousScale);
|
|
133
|
+
posY -= relativeY * (scale - previousScale);
|
|
149
134
|
updateTransform();
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
)
|
|
153
|
-
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
const onTouchEnd = () => {
|
|
138
|
+
isDragging = false;
|
|
139
|
+
};
|
|
140
|
+
const onWheel = (event) => {
|
|
141
|
+
event.preventDefault();
|
|
142
|
+
const scaleAmount = 0.02;
|
|
143
|
+
const previousScale = scale;
|
|
144
|
+
if (event.deltaY < 0) {
|
|
145
|
+
scale += scaleAmount;
|
|
146
|
+
} else {
|
|
147
|
+
scale = Math.max(0.1, scale - scaleAmount);
|
|
148
|
+
}
|
|
149
|
+
const rect = content.getBoundingClientRect();
|
|
150
|
+
const mouseX = event.clientX - rect.left;
|
|
151
|
+
const mouseY = event.clientY - rect.top;
|
|
152
|
+
posX -= mouseX / previousScale * (scale - previousScale);
|
|
153
|
+
posY -= mouseY / previousScale * (scale - previousScale);
|
|
154
|
+
updateTransform();
|
|
155
|
+
};
|
|
156
|
+
const onMouseDown = (event) => {
|
|
154
157
|
isDragging = true;
|
|
155
158
|
startX = event.clientX - posX;
|
|
156
159
|
startY = event.clientY - posY;
|
|
157
|
-
}
|
|
158
|
-
|
|
160
|
+
};
|
|
161
|
+
const onMouseMove = (event) => {
|
|
159
162
|
if (isDragging) {
|
|
160
163
|
posX = event.clientX - startX;
|
|
161
164
|
posY = event.clientY - startY;
|
|
162
165
|
updateTransform();
|
|
163
166
|
}
|
|
164
|
-
}
|
|
165
|
-
|
|
167
|
+
};
|
|
168
|
+
const onMouseUp = () => {
|
|
166
169
|
isDragging = false;
|
|
167
|
-
}
|
|
168
|
-
|
|
170
|
+
};
|
|
171
|
+
const onMouseLeave = () => {
|
|
169
172
|
isDragging = false;
|
|
170
|
-
}
|
|
173
|
+
};
|
|
174
|
+
container.addEventListener("touchstart", onTouchStart, { passive: false });
|
|
175
|
+
container.addEventListener("touchmove", onTouchMove, { passive: false });
|
|
176
|
+
container.addEventListener("touchend", onTouchEnd);
|
|
177
|
+
container.addEventListener("wheel", onWheel, { passive: false });
|
|
178
|
+
container.addEventListener("mousedown", onMouseDown);
|
|
179
|
+
container.addEventListener("mousemove", onMouseMove);
|
|
180
|
+
container.addEventListener("mouseup", onMouseUp);
|
|
181
|
+
container.addEventListener("mouseleave", onMouseLeave);
|
|
182
|
+
return () => {
|
|
183
|
+
container.removeEventListener("touchstart", onTouchStart);
|
|
184
|
+
container.removeEventListener("touchmove", onTouchMove);
|
|
185
|
+
container.removeEventListener("touchend", onTouchEnd);
|
|
186
|
+
container.removeEventListener("wheel", onWheel);
|
|
187
|
+
container.removeEventListener("mousedown", onMouseDown);
|
|
188
|
+
container.removeEventListener("mousemove", onMouseMove);
|
|
189
|
+
container.removeEventListener("mouseup", onMouseUp);
|
|
190
|
+
container.removeEventListener("mouseleave", onMouseLeave);
|
|
191
|
+
};
|
|
171
192
|
};
|
|
172
|
-
const handler = (containers) => {
|
|
193
|
+
const handler = (containers, options) => {
|
|
194
|
+
const removeEventsMap = /* @__PURE__ */ new Map();
|
|
173
195
|
containers == null ? void 0 : containers.forEach((mm) => {
|
|
174
|
-
|
|
196
|
+
let actionDiv = mm.querySelector(`.${config.prefix}-mermaid-action`);
|
|
197
|
+
if (!actionDiv) {
|
|
198
|
+
mm.insertAdjacentHTML(
|
|
199
|
+
"beforeend",
|
|
200
|
+
`<div class="${config.prefix}-mermaid-action">${StrIcon$1("pin-off", options.customIcon)}</div>`
|
|
201
|
+
);
|
|
202
|
+
actionDiv = mm.querySelector(`.${config.prefix}-mermaid-action`);
|
|
203
|
+
}
|
|
204
|
+
const onClick = () => {
|
|
205
|
+
const current = removeEventsMap.get(mm);
|
|
206
|
+
if (current == null ? void 0 : current.removeEvent) {
|
|
207
|
+
current.removeEvent();
|
|
208
|
+
mm.removeAttribute("data-grab");
|
|
209
|
+
removeEventsMap.set(mm, { removeClick: current.removeClick });
|
|
210
|
+
actionDiv.innerHTML = StrIcon$1("pin-off", options.customIcon);
|
|
211
|
+
} else {
|
|
212
|
+
const removeEvent = addEvent(mm);
|
|
213
|
+
mm.setAttribute("data-grab", "");
|
|
214
|
+
removeEventsMap.set(mm, { removeEvent, removeClick: current == null ? void 0 : current.removeClick });
|
|
215
|
+
actionDiv.innerHTML = StrIcon$1("pin", options.customIcon);
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
actionDiv.addEventListener("click", onClick);
|
|
219
|
+
removeEventsMap.set(mm, {
|
|
220
|
+
removeClick: () => actionDiv.removeEventListener("click", onClick)
|
|
221
|
+
});
|
|
175
222
|
});
|
|
223
|
+
return () => {
|
|
224
|
+
removeEventsMap.forEach(({ removeEvent, removeClick }) => {
|
|
225
|
+
if (removeEvent) removeEvent();
|
|
226
|
+
if (removeClick) removeClick();
|
|
227
|
+
});
|
|
228
|
+
removeEventsMap.clear();
|
|
229
|
+
};
|
|
176
230
|
};
|
|
177
231
|
return handler;
|
|
178
232
|
})();
|
|
233
|
+
exports.StrIcon = StrIcon$1;
|
|
179
234
|
exports.appendHandler = appendHandler;
|
|
180
235
|
exports.keyMove = keyMove;
|
|
181
236
|
exports.updateHandler = updateHandler;
|
package/lib/cjs/chunks/index.cjs
CHANGED
|
@@ -148,10 +148,9 @@ const useMermaid = (props) => {
|
|
|
148
148
|
const theme = vue.inject("theme");
|
|
149
149
|
const rootRef = vue.inject("rootRef");
|
|
150
150
|
const { editorExtensions, editorExtensionsAttrs, mermaidConfig } = config.configOption;
|
|
151
|
-
|
|
151
|
+
let mermaid = editorExtensions.mermaid.instance;
|
|
152
152
|
const reRenderRef = vue.shallowRef(-1);
|
|
153
153
|
const configMermaid = () => {
|
|
154
|
-
const mermaid = mermaidRef.value;
|
|
155
154
|
if (!props.noMermaid && mermaid) {
|
|
156
155
|
mermaid.initialize(
|
|
157
156
|
mermaidConfig({
|
|
@@ -171,7 +170,7 @@ const useMermaid = (props) => {
|
|
|
171
170
|
);
|
|
172
171
|
vue.onMounted(() => {
|
|
173
172
|
var _a, _b;
|
|
174
|
-
if (props.noMermaid ||
|
|
173
|
+
if (props.noMermaid || mermaid) {
|
|
175
174
|
return;
|
|
176
175
|
}
|
|
177
176
|
const jsSrc = editorExtensions.mermaid.js;
|
|
@@ -187,7 +186,7 @@ const useMermaid = (props) => {
|
|
|
187
186
|
/* webpackIgnore: true */
|
|
188
187
|
jsSrc
|
|
189
188
|
).then((module2) => {
|
|
190
|
-
|
|
189
|
+
mermaid = module2.default;
|
|
191
190
|
configMermaid();
|
|
192
191
|
});
|
|
193
192
|
} else {
|
|
@@ -198,7 +197,7 @@ const useMermaid = (props) => {
|
|
|
198
197
|
src: jsSrc,
|
|
199
198
|
id: CDN_IDS.mermaid,
|
|
200
199
|
onload() {
|
|
201
|
-
|
|
200
|
+
mermaid = window.mermaid;
|
|
202
201
|
configMermaid();
|
|
203
202
|
}
|
|
204
203
|
},
|
|
@@ -207,7 +206,7 @@ const useMermaid = (props) => {
|
|
|
207
206
|
}
|
|
208
207
|
});
|
|
209
208
|
const replaceMermaid = async () => {
|
|
210
|
-
if (!props.noMermaid &&
|
|
209
|
+
if (!props.noMermaid && mermaid) {
|
|
211
210
|
const mermaidSourceEles = rootRef.value.querySelectorAll(
|
|
212
211
|
`div.${config.prefix}-mermaid`
|
|
213
212
|
);
|
|
@@ -227,23 +226,20 @@ const useMermaid = (props) => {
|
|
|
227
226
|
Array.from(mermaidSourceEles).map((ele) => {
|
|
228
227
|
const handler = async (item) => {
|
|
229
228
|
var _a;
|
|
230
|
-
|
|
229
|
+
const code = item.dataset.code;
|
|
230
|
+
let mermaidHtml = mermaidCache.get(code);
|
|
231
231
|
if (!mermaidHtml) {
|
|
232
232
|
const idRand = util.randomId();
|
|
233
233
|
let result = { svg: "" };
|
|
234
234
|
try {
|
|
235
|
-
result = await
|
|
236
|
-
idRand,
|
|
237
|
-
item.innerText,
|
|
238
|
-
svgContainingElement
|
|
239
|
-
);
|
|
235
|
+
result = await mermaid.render(idRand, code, svgContainingElement);
|
|
240
236
|
mermaidHtml = await props.sanitizeMermaid(result.svg);
|
|
241
237
|
const p = document.createElement("p");
|
|
242
238
|
p.className = `${config.prefix}-mermaid`;
|
|
243
239
|
p.setAttribute("data-processed", "");
|
|
244
240
|
p.innerHTML = mermaidHtml;
|
|
245
241
|
(_a = p.children[0]) == null ? void 0 : _a.removeAttribute("height");
|
|
246
|
-
mermaidCache.set(
|
|
242
|
+
mermaidCache.set(code, p.innerHTML);
|
|
247
243
|
if (item.dataset.line !== void 0) {
|
|
248
244
|
p.dataset.line = item.dataset.line;
|
|
249
245
|
}
|
|
@@ -260,7 +256,7 @@ const useMermaid = (props) => {
|
|
|
260
256
|
);
|
|
261
257
|
}
|
|
262
258
|
};
|
|
263
|
-
return {
|
|
259
|
+
return { reRenderRef, replaceMermaid };
|
|
264
260
|
};
|
|
265
261
|
const useKatex = (props) => {
|
|
266
262
|
const katex = vue.shallowRef(config.configOption.editorExtensions.katex.instance);
|
|
@@ -303,7 +299,7 @@ const MermaidPlugin = (md, options) => {
|
|
|
303
299
|
if (mermaidHtml) {
|
|
304
300
|
return `<p class="${config.prefix}-mermaid" ${line !== void 0 ? "data-line=" + line : ""} data-processed>${mermaidHtml}</p>`;
|
|
305
301
|
}
|
|
306
|
-
return `<div class="${config.prefix}-mermaid" ${line !== void 0 ? "data-line=" + line : ""} data-mermaid-theme=${options.themeRef.value}>${code}</div>`;
|
|
302
|
+
return `<div class="${config.prefix}-mermaid" ${line !== void 0 ? "data-line=" + line : ""} data-mermaid-theme=${options.themeRef.value} data-code="${code}">${code}</div>`;
|
|
307
303
|
}
|
|
308
304
|
return temp(tokens, idx, ops, env, slf);
|
|
309
305
|
};
|
|
@@ -602,17 +598,6 @@ const HeadingPlugin = (md, options) => {
|
|
|
602
598
|
return self.renderToken(tokens, idx, opts);
|
|
603
599
|
};
|
|
604
600
|
};
|
|
605
|
-
const iconMaps = {
|
|
606
|
-
copy: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-copy ${config.prefix}-icon"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>`,
|
|
607
|
-
"collapse-tips": `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-circle-chevron-left ${config.prefix}-icon"><circle cx="12" cy="12" r="10"/><path d="m14 16-4-4 4-4"/></svg>`
|
|
608
|
-
};
|
|
609
|
-
const StrIcon = (name, customIcon) => {
|
|
610
|
-
if (typeof customIcon[name] === "string") {
|
|
611
|
-
return customIcon[name];
|
|
612
|
-
}
|
|
613
|
-
return iconMaps[name];
|
|
614
|
-
};
|
|
615
|
-
const StrIcon$1 = StrIcon;
|
|
616
601
|
const codetabs = (md, _opts) => {
|
|
617
602
|
const defaultRender = md.renderer.rules.fence, unescapeAll = md.utils.unescapeAll, re = /\[(\w*)(?::([\w ]*))?\]/, mandatoryRe = /::(open|close)/;
|
|
618
603
|
const getInfo = (token) => {
|
|
@@ -640,7 +625,7 @@ const codetabs = (md, _opts) => {
|
|
|
640
625
|
const codeCodeText = (_a = _opts.usedLanguageTextRef.value) == null ? void 0 : _a.copyCode.text;
|
|
641
626
|
const copyBtnHtml = _opts.customIconRef.value.copy || codeCodeText;
|
|
642
627
|
const isIcon = !!_opts.customIconRef.value.copy;
|
|
643
|
-
const collapseTips = `<span class="${config.prefix}-collapse-tips">${StrIcon
|
|
628
|
+
const collapseTips = `<span class="${config.prefix}-collapse-tips">${dom.StrIcon("collapse-tips", _opts.customIconRef.value)}</span>`;
|
|
644
629
|
const [GROUP] = getGroupAndTab(tokens[idx]);
|
|
645
630
|
if (GROUP === null) {
|
|
646
631
|
const { open: open2, tagContainer: tagContainer2, tagHeader: tagHeader2 } = getTagType(tokens[idx]);
|
|
@@ -845,7 +830,7 @@ const initLineNumber = (md) => {
|
|
|
845
830
|
});
|
|
846
831
|
};
|
|
847
832
|
const useMarkdownIt = (props, previewOnly) => {
|
|
848
|
-
const { editorConfig, markdownItConfig, markdownItPlugins } = config.configOption;
|
|
833
|
+
const { editorConfig, markdownItConfig, markdownItPlugins, editorExtensions } = config.configOption;
|
|
849
834
|
const editorId = vue.inject("editorId");
|
|
850
835
|
const languageRef = vue.inject("language");
|
|
851
836
|
const usedLanguageTextRef = vue.inject(
|
|
@@ -856,6 +841,8 @@ const useMarkdownIt = (props, previewOnly) => {
|
|
|
856
841
|
const customIconRef = vue.inject("customIcon");
|
|
857
842
|
const rootRef = vue.inject("rootRef");
|
|
858
843
|
const headsRef = vue.ref([]);
|
|
844
|
+
let clearMermaidEvents = () => {
|
|
845
|
+
};
|
|
859
846
|
const hljsRef = useHighlight(props);
|
|
860
847
|
const katexRef = useKatex(props);
|
|
861
848
|
const { reRenderRef, replaceMermaid } = useMermaid(props);
|
|
@@ -970,8 +957,16 @@ const useMarkdownIt = (props, previewOnly) => {
|
|
|
970
957
|
eventName.bus.emit(editorId, eventName.CATALOG_CHANGED, headsRef.value);
|
|
971
958
|
vue.nextTick(() => {
|
|
972
959
|
replaceMermaid().then(() => {
|
|
973
|
-
var _a;
|
|
974
|
-
|
|
960
|
+
var _a, _b;
|
|
961
|
+
if ((_a = editorExtensions.mermaid) == null ? void 0 : _a.enableZoom) {
|
|
962
|
+
clearMermaidEvents();
|
|
963
|
+
clearMermaidEvents = dom.zoomMermaid(
|
|
964
|
+
(_b = rootRef.value) == null ? void 0 : _b.querySelectorAll(`#${editorId} p.${config.prefix}-mermaid`),
|
|
965
|
+
{
|
|
966
|
+
customIcon: customIconRef.value
|
|
967
|
+
}
|
|
968
|
+
);
|
|
969
|
+
}
|
|
975
970
|
});
|
|
976
971
|
});
|
|
977
972
|
};
|
|
@@ -998,10 +993,16 @@ const useMarkdownIt = (props, previewOnly) => {
|
|
|
998
993
|
if (props.setting.preview) {
|
|
999
994
|
vue.nextTick(() => {
|
|
1000
995
|
replaceMermaid().then(() => {
|
|
1001
|
-
var _a;
|
|
1002
|
-
|
|
1003
|
-
(
|
|
1004
|
-
|
|
996
|
+
var _a, _b;
|
|
997
|
+
if ((_a = editorExtensions.mermaid) == null ? void 0 : _a.enableZoom) {
|
|
998
|
+
clearMermaidEvents();
|
|
999
|
+
clearMermaidEvents = dom.zoomMermaid(
|
|
1000
|
+
(_b = rootRef.value) == null ? void 0 : _b.querySelectorAll(`#${editorId} p.${config.prefix}-mermaid`),
|
|
1001
|
+
{
|
|
1002
|
+
customIcon: customIconRef.value
|
|
1003
|
+
}
|
|
1004
|
+
);
|
|
1005
|
+
}
|
|
1005
1006
|
});
|
|
1006
1007
|
eventName.bus.emit(editorId, eventName.CATALOG_CHANGED, headsRef.value);
|
|
1007
1008
|
});
|
|
@@ -1025,6 +1026,7 @@ const useMarkdownIt = (props, previewOnly) => {
|
|
|
1025
1026
|
});
|
|
1026
1027
|
});
|
|
1027
1028
|
vue.onBeforeUnmount(() => {
|
|
1029
|
+
clearMermaidEvents();
|
|
1028
1030
|
clearTimeout(timer);
|
|
1029
1031
|
});
|
|
1030
1032
|
return { html, key };
|
|
@@ -2322,7 +2324,6 @@ MdPreview.install = (app) => {
|
|
|
2322
2324
|
exports.CDN_IDS = CDN_IDS;
|
|
2323
2325
|
exports.ContentPreview = ContentPreview;
|
|
2324
2326
|
exports.MdPreview = MdPreview;
|
|
2325
|
-
exports.StrIcon = StrIcon$1;
|
|
2326
2327
|
exports.contentProps = contentProps;
|
|
2327
2328
|
exports.editorEmits = editorEmits;
|
|
2328
2329
|
exports.editorProps = editorProps;
|
package/lib/cjs/index.cjs
CHANGED
|
@@ -7,6 +7,7 @@ const DropdownToolbar = require("./chunks/index2.cjs");
|
|
|
7
7
|
const ModalToolbar = require("./ModalToolbar.cjs");
|
|
8
8
|
const MdCatalog = require("./chunks/index3.cjs");
|
|
9
9
|
const MdModal = require("./chunks/index4.cjs");
|
|
10
|
+
const dom = require("./chunks/dom.cjs");
|
|
10
11
|
const vue = require("vue");
|
|
11
12
|
const vueTsx = require("./chunks/vue-tsx.cjs");
|
|
12
13
|
const config$1 = require("./chunks/config.cjs");
|
|
@@ -1379,12 +1380,12 @@ const clearSideEffects = () => {
|
|
|
1379
1380
|
};
|
|
1380
1381
|
exports.MdEditor = MdEditor;
|
|
1381
1382
|
exports.MdPreview = MdPreview.MdPreview;
|
|
1382
|
-
exports.StrIcon = MdPreview.StrIcon;
|
|
1383
1383
|
exports.NormalToolbar = NormalToolbar;
|
|
1384
1384
|
exports.DropdownToolbar = DropdownToolbar.DropdownToolbar;
|
|
1385
1385
|
exports.ModalToolbar = ModalToolbar;
|
|
1386
1386
|
exports.MdCatalog = MdCatalog.MdCatalog;
|
|
1387
1387
|
exports.MdModal = MdModal.MdModal;
|
|
1388
|
+
exports.StrIcon = dom.StrIcon;
|
|
1388
1389
|
exports.allFooter = config$1.allFooter;
|
|
1389
1390
|
exports.allToolbar = config$1.allToolbar;
|
|
1390
1391
|
exports.config = config$1.config;
|