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/es/chunks/dom.mjs
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
import { p as prefix } from "./config.mjs";
|
|
2
|
+
const iconMaps = {
|
|
3
|
+
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 ${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>`,
|
|
4
|
+
"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 ${prefix}-icon"><circle cx="12" cy="12" r="10"/><path d="m14 16-4-4 4-4"/></svg>`,
|
|
5
|
+
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>`,
|
|
6
|
+
"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>`
|
|
7
|
+
};
|
|
8
|
+
const StrIcon = (name, customIcon) => {
|
|
9
|
+
if (typeof customIcon[name] === "string") {
|
|
10
|
+
return customIcon[name];
|
|
11
|
+
}
|
|
12
|
+
return iconMaps[name];
|
|
13
|
+
};
|
|
14
|
+
const StrIcon$1 = StrIcon;
|
|
1
15
|
const keyMove = (trigger, moveHandler) => {
|
|
2
16
|
const triggerMouseDown = (mdown) => {
|
|
3
17
|
const parent = trigger.parentElement || document.body;
|
|
@@ -68,7 +82,8 @@ const createHTMLElement = (tagName, attributes) => {
|
|
|
68
82
|
const zoomMermaid = /* @__PURE__ */ (() => {
|
|
69
83
|
const addEvent = (container) => {
|
|
70
84
|
if (!container) {
|
|
71
|
-
return
|
|
85
|
+
return () => {
|
|
86
|
+
};
|
|
72
87
|
}
|
|
73
88
|
const content = container.firstChild;
|
|
74
89
|
let scale = 1;
|
|
@@ -81,101 +96,141 @@ const zoomMermaid = /* @__PURE__ */ (() => {
|
|
|
81
96
|
const updateTransform = () => {
|
|
82
97
|
content.style.transform = `translate(${posX}px, ${posY}px) scale(${scale})`;
|
|
83
98
|
};
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
(event)
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
} else if (event.touches.length === 2) {
|
|
110
|
-
const newDistance = Math.hypot(
|
|
111
|
-
event.touches[0].clientX - event.touches[1].clientX,
|
|
112
|
-
event.touches[0].clientY - event.touches[1].clientY
|
|
113
|
-
);
|
|
114
|
-
const scaleChange = newDistance / initialDistance;
|
|
115
|
-
const previousScale = scale;
|
|
116
|
-
scale = initialScale * (1 + (scaleChange - 1));
|
|
117
|
-
const centerX = (event.touches[0].clientX + event.touches[1].clientX) / 2;
|
|
118
|
-
const centerY = (event.touches[0].clientY + event.touches[1].clientY) / 2;
|
|
119
|
-
const rect = content.getBoundingClientRect();
|
|
120
|
-
const relativeX = (centerX - rect.left) / previousScale;
|
|
121
|
-
const relativeY = (centerY - rect.top) / previousScale;
|
|
122
|
-
posX -= relativeX * (scale - previousScale);
|
|
123
|
-
posY -= relativeY * (scale - previousScale);
|
|
124
|
-
updateTransform();
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
{ passive: false }
|
|
128
|
-
);
|
|
129
|
-
container.addEventListener("touchend", () => {
|
|
130
|
-
isDragging = false;
|
|
131
|
-
});
|
|
132
|
-
container.addEventListener(
|
|
133
|
-
"wheel",
|
|
134
|
-
(event) => {
|
|
135
|
-
event.preventDefault();
|
|
136
|
-
const scaleAmount = 0.02;
|
|
99
|
+
const onTouchStart = (event) => {
|
|
100
|
+
if (event.touches.length === 1) {
|
|
101
|
+
isDragging = true;
|
|
102
|
+
startX = event.touches[0].clientX - posX;
|
|
103
|
+
startY = event.touches[0].clientY - posY;
|
|
104
|
+
} else if (event.touches.length === 2) {
|
|
105
|
+
initialDistance = Math.hypot(
|
|
106
|
+
event.touches[0].clientX - event.touches[1].clientX,
|
|
107
|
+
event.touches[0].clientY - event.touches[1].clientY
|
|
108
|
+
);
|
|
109
|
+
initialScale = scale;
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
const onTouchMove = (event) => {
|
|
113
|
+
event.preventDefault();
|
|
114
|
+
if (isDragging && event.touches.length === 1) {
|
|
115
|
+
posX = event.touches[0].clientX - startX;
|
|
116
|
+
posY = event.touches[0].clientY - startY;
|
|
117
|
+
updateTransform();
|
|
118
|
+
} else if (event.touches.length === 2) {
|
|
119
|
+
const newDistance = Math.hypot(
|
|
120
|
+
event.touches[0].clientX - event.touches[1].clientX,
|
|
121
|
+
event.touches[0].clientY - event.touches[1].clientY
|
|
122
|
+
);
|
|
123
|
+
const scaleChange = newDistance / initialDistance;
|
|
137
124
|
const previousScale = scale;
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
scale = Math.max(0.1, scale - scaleAmount);
|
|
142
|
-
}
|
|
125
|
+
scale = initialScale * (1 + (scaleChange - 1));
|
|
126
|
+
const centerX = (event.touches[0].clientX + event.touches[1].clientX) / 2;
|
|
127
|
+
const centerY = (event.touches[0].clientY + event.touches[1].clientY) / 2;
|
|
143
128
|
const rect = content.getBoundingClientRect();
|
|
144
|
-
const
|
|
145
|
-
const
|
|
146
|
-
posX -=
|
|
147
|
-
posY -=
|
|
129
|
+
const relativeX = (centerX - rect.left) / previousScale;
|
|
130
|
+
const relativeY = (centerY - rect.top) / previousScale;
|
|
131
|
+
posX -= relativeX * (scale - previousScale);
|
|
132
|
+
posY -= relativeY * (scale - previousScale);
|
|
148
133
|
updateTransform();
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
)
|
|
152
|
-
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
const onTouchEnd = () => {
|
|
137
|
+
isDragging = false;
|
|
138
|
+
};
|
|
139
|
+
const onWheel = (event) => {
|
|
140
|
+
event.preventDefault();
|
|
141
|
+
const scaleAmount = 0.02;
|
|
142
|
+
const previousScale = scale;
|
|
143
|
+
if (event.deltaY < 0) {
|
|
144
|
+
scale += scaleAmount;
|
|
145
|
+
} else {
|
|
146
|
+
scale = Math.max(0.1, scale - scaleAmount);
|
|
147
|
+
}
|
|
148
|
+
const rect = content.getBoundingClientRect();
|
|
149
|
+
const mouseX = event.clientX - rect.left;
|
|
150
|
+
const mouseY = event.clientY - rect.top;
|
|
151
|
+
posX -= mouseX / previousScale * (scale - previousScale);
|
|
152
|
+
posY -= mouseY / previousScale * (scale - previousScale);
|
|
153
|
+
updateTransform();
|
|
154
|
+
};
|
|
155
|
+
const onMouseDown = (event) => {
|
|
153
156
|
isDragging = true;
|
|
154
157
|
startX = event.clientX - posX;
|
|
155
158
|
startY = event.clientY - posY;
|
|
156
|
-
}
|
|
157
|
-
|
|
159
|
+
};
|
|
160
|
+
const onMouseMove = (event) => {
|
|
158
161
|
if (isDragging) {
|
|
159
162
|
posX = event.clientX - startX;
|
|
160
163
|
posY = event.clientY - startY;
|
|
161
164
|
updateTransform();
|
|
162
165
|
}
|
|
163
|
-
}
|
|
164
|
-
|
|
166
|
+
};
|
|
167
|
+
const onMouseUp = () => {
|
|
165
168
|
isDragging = false;
|
|
166
|
-
}
|
|
167
|
-
|
|
169
|
+
};
|
|
170
|
+
const onMouseLeave = () => {
|
|
168
171
|
isDragging = false;
|
|
169
|
-
}
|
|
172
|
+
};
|
|
173
|
+
container.addEventListener("touchstart", onTouchStart, { passive: false });
|
|
174
|
+
container.addEventListener("touchmove", onTouchMove, { passive: false });
|
|
175
|
+
container.addEventListener("touchend", onTouchEnd);
|
|
176
|
+
container.addEventListener("wheel", onWheel, { passive: false });
|
|
177
|
+
container.addEventListener("mousedown", onMouseDown);
|
|
178
|
+
container.addEventListener("mousemove", onMouseMove);
|
|
179
|
+
container.addEventListener("mouseup", onMouseUp);
|
|
180
|
+
container.addEventListener("mouseleave", onMouseLeave);
|
|
181
|
+
return () => {
|
|
182
|
+
container.removeEventListener("touchstart", onTouchStart);
|
|
183
|
+
container.removeEventListener("touchmove", onTouchMove);
|
|
184
|
+
container.removeEventListener("touchend", onTouchEnd);
|
|
185
|
+
container.removeEventListener("wheel", onWheel);
|
|
186
|
+
container.removeEventListener("mousedown", onMouseDown);
|
|
187
|
+
container.removeEventListener("mousemove", onMouseMove);
|
|
188
|
+
container.removeEventListener("mouseup", onMouseUp);
|
|
189
|
+
container.removeEventListener("mouseleave", onMouseLeave);
|
|
190
|
+
};
|
|
170
191
|
};
|
|
171
|
-
const handler = (containers) => {
|
|
192
|
+
const handler = (containers, options) => {
|
|
193
|
+
const removeEventsMap = /* @__PURE__ */ new Map();
|
|
172
194
|
containers == null ? void 0 : containers.forEach((mm) => {
|
|
173
|
-
|
|
195
|
+
let actionDiv = mm.querySelector(`.${prefix}-mermaid-action`);
|
|
196
|
+
if (!actionDiv) {
|
|
197
|
+
mm.insertAdjacentHTML(
|
|
198
|
+
"beforeend",
|
|
199
|
+
`<div class="${prefix}-mermaid-action">${StrIcon$1("pin-off", options.customIcon)}</div>`
|
|
200
|
+
);
|
|
201
|
+
actionDiv = mm.querySelector(`.${prefix}-mermaid-action`);
|
|
202
|
+
}
|
|
203
|
+
const onClick = () => {
|
|
204
|
+
const current = removeEventsMap.get(mm);
|
|
205
|
+
if (current == null ? void 0 : current.removeEvent) {
|
|
206
|
+
current.removeEvent();
|
|
207
|
+
mm.removeAttribute("data-grab");
|
|
208
|
+
removeEventsMap.set(mm, { removeClick: current.removeClick });
|
|
209
|
+
actionDiv.innerHTML = StrIcon$1("pin-off", options.customIcon);
|
|
210
|
+
} else {
|
|
211
|
+
const removeEvent = addEvent(mm);
|
|
212
|
+
mm.setAttribute("data-grab", "");
|
|
213
|
+
removeEventsMap.set(mm, { removeEvent, removeClick: current == null ? void 0 : current.removeClick });
|
|
214
|
+
actionDiv.innerHTML = StrIcon$1("pin", options.customIcon);
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
actionDiv.addEventListener("click", onClick);
|
|
218
|
+
removeEventsMap.set(mm, {
|
|
219
|
+
removeClick: () => actionDiv.removeEventListener("click", onClick)
|
|
220
|
+
});
|
|
174
221
|
});
|
|
222
|
+
return () => {
|
|
223
|
+
removeEventsMap.forEach(({ removeEvent, removeClick }) => {
|
|
224
|
+
if (removeEvent) removeEvent();
|
|
225
|
+
if (removeClick) removeClick();
|
|
226
|
+
});
|
|
227
|
+
removeEventsMap.clear();
|
|
228
|
+
};
|
|
175
229
|
};
|
|
176
230
|
return handler;
|
|
177
231
|
})();
|
|
178
232
|
export {
|
|
233
|
+
StrIcon$1 as S,
|
|
179
234
|
appendHandler as a,
|
|
180
235
|
keyMove as k,
|
|
181
236
|
updateHandler as u,
|
package/lib/es/chunks/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { inject, onMounted, watch, toRef, nextTick, shallowRef, ref, computed, o
|
|
|
2
2
|
import { p as prefix, d as configOption, f as codeCss, s as staticTextDefault, a as allToolbar, b as allFooter } from "./config.mjs";
|
|
3
3
|
import { b as bus, g as CATALOG_CHANGED, P as PUSH_CATALOG, h as RERENDER, B as BUILD_FINISHED, T as TASK_STATE_CHANGED, c as ON_SAVE, E as ERROR_CATCHER, U as UPLOAD_IMAGE, a as CHANGE_CATALOG_VISIBLE, i as PAGE_FULL_SCREEN_CHANGED, F as FULL_SCREEN_CHANGED, j as PREVIEW_CHANGED, k as PREVIEW_ONLY_CHANGED, H as HTML_PREVIEW_CHANGED, l as CATALOG_VISIBLE_CHANGED, R as REPLACE, C as CHANGE_FULL_SCREEN, f as EVENT_LISTENER } from "./event-name.mjs";
|
|
4
4
|
import { debounce, randomId, deepMerge, deepClone } from "@vavt/util";
|
|
5
|
-
import { a as appendHandler, u as updateHandler, z as zoomMermaid } from "./dom.mjs";
|
|
5
|
+
import { a as appendHandler, u as updateHandler, S as StrIcon, z as zoomMermaid } from "./dom.mjs";
|
|
6
6
|
import mediumZoom from "medium-zoom";
|
|
7
7
|
import copy2clipboard from "@vavt/copy2clipboard";
|
|
8
8
|
import mdit from "markdown-it";
|
|
@@ -147,10 +147,9 @@ const useMermaid = (props) => {
|
|
|
147
147
|
const theme = inject("theme");
|
|
148
148
|
const rootRef = inject("rootRef");
|
|
149
149
|
const { editorExtensions, editorExtensionsAttrs, mermaidConfig } = configOption;
|
|
150
|
-
|
|
150
|
+
let mermaid = editorExtensions.mermaid.instance;
|
|
151
151
|
const reRenderRef = shallowRef(-1);
|
|
152
152
|
const configMermaid = () => {
|
|
153
|
-
const mermaid = mermaidRef.value;
|
|
154
153
|
if (!props.noMermaid && mermaid) {
|
|
155
154
|
mermaid.initialize(
|
|
156
155
|
mermaidConfig({
|
|
@@ -170,7 +169,7 @@ const useMermaid = (props) => {
|
|
|
170
169
|
);
|
|
171
170
|
onMounted(() => {
|
|
172
171
|
var _a, _b;
|
|
173
|
-
if (props.noMermaid ||
|
|
172
|
+
if (props.noMermaid || mermaid) {
|
|
174
173
|
return;
|
|
175
174
|
}
|
|
176
175
|
const jsSrc = editorExtensions.mermaid.js;
|
|
@@ -186,7 +185,7 @@ const useMermaid = (props) => {
|
|
|
186
185
|
/* webpackIgnore: true */
|
|
187
186
|
jsSrc
|
|
188
187
|
).then((module) => {
|
|
189
|
-
|
|
188
|
+
mermaid = module.default;
|
|
190
189
|
configMermaid();
|
|
191
190
|
});
|
|
192
191
|
} else {
|
|
@@ -197,7 +196,7 @@ const useMermaid = (props) => {
|
|
|
197
196
|
src: jsSrc,
|
|
198
197
|
id: CDN_IDS.mermaid,
|
|
199
198
|
onload() {
|
|
200
|
-
|
|
199
|
+
mermaid = window.mermaid;
|
|
201
200
|
configMermaid();
|
|
202
201
|
}
|
|
203
202
|
},
|
|
@@ -206,7 +205,7 @@ const useMermaid = (props) => {
|
|
|
206
205
|
}
|
|
207
206
|
});
|
|
208
207
|
const replaceMermaid = async () => {
|
|
209
|
-
if (!props.noMermaid &&
|
|
208
|
+
if (!props.noMermaid && mermaid) {
|
|
210
209
|
const mermaidSourceEles = rootRef.value.querySelectorAll(
|
|
211
210
|
`div.${prefix}-mermaid`
|
|
212
211
|
);
|
|
@@ -226,23 +225,20 @@ const useMermaid = (props) => {
|
|
|
226
225
|
Array.from(mermaidSourceEles).map((ele) => {
|
|
227
226
|
const handler = async (item) => {
|
|
228
227
|
var _a;
|
|
229
|
-
|
|
228
|
+
const code = item.dataset.code;
|
|
229
|
+
let mermaidHtml = mermaidCache.get(code);
|
|
230
230
|
if (!mermaidHtml) {
|
|
231
231
|
const idRand = randomId();
|
|
232
232
|
let result = { svg: "" };
|
|
233
233
|
try {
|
|
234
|
-
result = await
|
|
235
|
-
idRand,
|
|
236
|
-
item.innerText,
|
|
237
|
-
svgContainingElement
|
|
238
|
-
);
|
|
234
|
+
result = await mermaid.render(idRand, code, svgContainingElement);
|
|
239
235
|
mermaidHtml = await props.sanitizeMermaid(result.svg);
|
|
240
236
|
const p = document.createElement("p");
|
|
241
237
|
p.className = `${prefix}-mermaid`;
|
|
242
238
|
p.setAttribute("data-processed", "");
|
|
243
239
|
p.innerHTML = mermaidHtml;
|
|
244
240
|
(_a = p.children[0]) == null ? void 0 : _a.removeAttribute("height");
|
|
245
|
-
mermaidCache.set(
|
|
241
|
+
mermaidCache.set(code, p.innerHTML);
|
|
246
242
|
if (item.dataset.line !== void 0) {
|
|
247
243
|
p.dataset.line = item.dataset.line;
|
|
248
244
|
}
|
|
@@ -259,7 +255,7 @@ const useMermaid = (props) => {
|
|
|
259
255
|
);
|
|
260
256
|
}
|
|
261
257
|
};
|
|
262
|
-
return {
|
|
258
|
+
return { reRenderRef, replaceMermaid };
|
|
263
259
|
};
|
|
264
260
|
const useKatex = (props) => {
|
|
265
261
|
const katex = shallowRef(configOption.editorExtensions.katex.instance);
|
|
@@ -302,7 +298,7 @@ const MermaidPlugin = (md, options) => {
|
|
|
302
298
|
if (mermaidHtml) {
|
|
303
299
|
return `<p class="${prefix}-mermaid" ${line !== void 0 ? "data-line=" + line : ""} data-processed>${mermaidHtml}</p>`;
|
|
304
300
|
}
|
|
305
|
-
return `<div class="${prefix}-mermaid" ${line !== void 0 ? "data-line=" + line : ""} data-mermaid-theme=${options.themeRef.value}>${code}</div>`;
|
|
301
|
+
return `<div class="${prefix}-mermaid" ${line !== void 0 ? "data-line=" + line : ""} data-mermaid-theme=${options.themeRef.value} data-code="${code}">${code}</div>`;
|
|
306
302
|
}
|
|
307
303
|
return temp(tokens, idx, ops, env, slf);
|
|
308
304
|
};
|
|
@@ -601,17 +597,6 @@ const HeadingPlugin = (md, options) => {
|
|
|
601
597
|
return self.renderToken(tokens, idx, opts);
|
|
602
598
|
};
|
|
603
599
|
};
|
|
604
|
-
const iconMaps = {
|
|
605
|
-
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 ${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>`,
|
|
606
|
-
"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 ${prefix}-icon"><circle cx="12" cy="12" r="10"/><path d="m14 16-4-4 4-4"/></svg>`
|
|
607
|
-
};
|
|
608
|
-
const StrIcon = (name, customIcon) => {
|
|
609
|
-
if (typeof customIcon[name] === "string") {
|
|
610
|
-
return customIcon[name];
|
|
611
|
-
}
|
|
612
|
-
return iconMaps[name];
|
|
613
|
-
};
|
|
614
|
-
const StrIcon$1 = StrIcon;
|
|
615
600
|
const codetabs = (md, _opts) => {
|
|
616
601
|
const defaultRender = md.renderer.rules.fence, unescapeAll = md.utils.unescapeAll, re = /\[(\w*)(?::([\w ]*))?\]/, mandatoryRe = /::(open|close)/;
|
|
617
602
|
const getInfo = (token) => {
|
|
@@ -639,7 +624,7 @@ const codetabs = (md, _opts) => {
|
|
|
639
624
|
const codeCodeText = (_a = _opts.usedLanguageTextRef.value) == null ? void 0 : _a.copyCode.text;
|
|
640
625
|
const copyBtnHtml = _opts.customIconRef.value.copy || codeCodeText;
|
|
641
626
|
const isIcon = !!_opts.customIconRef.value.copy;
|
|
642
|
-
const collapseTips = `<span class="${prefix}-collapse-tips">${StrIcon
|
|
627
|
+
const collapseTips = `<span class="${prefix}-collapse-tips">${StrIcon("collapse-tips", _opts.customIconRef.value)}</span>`;
|
|
643
628
|
const [GROUP] = getGroupAndTab(tokens[idx]);
|
|
644
629
|
if (GROUP === null) {
|
|
645
630
|
const { open: open2, tagContainer: tagContainer2, tagHeader: tagHeader2 } = getTagType(tokens[idx]);
|
|
@@ -844,7 +829,7 @@ const initLineNumber = (md) => {
|
|
|
844
829
|
});
|
|
845
830
|
};
|
|
846
831
|
const useMarkdownIt = (props, previewOnly) => {
|
|
847
|
-
const { editorConfig, markdownItConfig, markdownItPlugins } = configOption;
|
|
832
|
+
const { editorConfig, markdownItConfig, markdownItPlugins, editorExtensions } = configOption;
|
|
848
833
|
const editorId = inject("editorId");
|
|
849
834
|
const languageRef = inject("language");
|
|
850
835
|
const usedLanguageTextRef = inject(
|
|
@@ -855,6 +840,8 @@ const useMarkdownIt = (props, previewOnly) => {
|
|
|
855
840
|
const customIconRef = inject("customIcon");
|
|
856
841
|
const rootRef = inject("rootRef");
|
|
857
842
|
const headsRef = ref([]);
|
|
843
|
+
let clearMermaidEvents = () => {
|
|
844
|
+
};
|
|
858
845
|
const hljsRef = useHighlight(props);
|
|
859
846
|
const katexRef = useKatex(props);
|
|
860
847
|
const { reRenderRef, replaceMermaid } = useMermaid(props);
|
|
@@ -969,8 +956,16 @@ const useMarkdownIt = (props, previewOnly) => {
|
|
|
969
956
|
bus.emit(editorId, CATALOG_CHANGED, headsRef.value);
|
|
970
957
|
nextTick(() => {
|
|
971
958
|
replaceMermaid().then(() => {
|
|
972
|
-
var _a;
|
|
973
|
-
|
|
959
|
+
var _a, _b;
|
|
960
|
+
if ((_a = editorExtensions.mermaid) == null ? void 0 : _a.enableZoom) {
|
|
961
|
+
clearMermaidEvents();
|
|
962
|
+
clearMermaidEvents = zoomMermaid(
|
|
963
|
+
(_b = rootRef.value) == null ? void 0 : _b.querySelectorAll(`#${editorId} p.${prefix}-mermaid`),
|
|
964
|
+
{
|
|
965
|
+
customIcon: customIconRef.value
|
|
966
|
+
}
|
|
967
|
+
);
|
|
968
|
+
}
|
|
974
969
|
});
|
|
975
970
|
});
|
|
976
971
|
};
|
|
@@ -997,10 +992,16 @@ const useMarkdownIt = (props, previewOnly) => {
|
|
|
997
992
|
if (props.setting.preview) {
|
|
998
993
|
nextTick(() => {
|
|
999
994
|
replaceMermaid().then(() => {
|
|
1000
|
-
var _a;
|
|
1001
|
-
|
|
1002
|
-
(
|
|
1003
|
-
|
|
995
|
+
var _a, _b;
|
|
996
|
+
if ((_a = editorExtensions.mermaid) == null ? void 0 : _a.enableZoom) {
|
|
997
|
+
clearMermaidEvents();
|
|
998
|
+
clearMermaidEvents = zoomMermaid(
|
|
999
|
+
(_b = rootRef.value) == null ? void 0 : _b.querySelectorAll(`#${editorId} p.${prefix}-mermaid`),
|
|
1000
|
+
{
|
|
1001
|
+
customIcon: customIconRef.value
|
|
1002
|
+
}
|
|
1003
|
+
);
|
|
1004
|
+
}
|
|
1004
1005
|
});
|
|
1005
1006
|
bus.emit(editorId, CATALOG_CHANGED, headsRef.value);
|
|
1006
1007
|
});
|
|
@@ -1024,6 +1025,7 @@ const useMarkdownIt = (props, previewOnly) => {
|
|
|
1024
1025
|
});
|
|
1025
1026
|
});
|
|
1026
1027
|
onBeforeUnmount(() => {
|
|
1028
|
+
clearMermaidEvents();
|
|
1027
1029
|
clearTimeout(timer);
|
|
1028
1030
|
});
|
|
1029
1031
|
return { html, key };
|
|
@@ -2321,7 +2323,6 @@ MdPreview.install = (app) => {
|
|
|
2321
2323
|
export {
|
|
2322
2324
|
CDN_IDS as C,
|
|
2323
2325
|
MdPreview as M,
|
|
2324
|
-
StrIcon$1 as S,
|
|
2325
2326
|
ContentPreview as a,
|
|
2326
2327
|
editorEmits as b,
|
|
2327
2328
|
contentProps as c,
|
package/lib/es/index.mjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { default as default2 } from "./MdEditor.mjs";
|
|
2
2
|
import { C as CDN_IDS } from "./chunks/index.mjs";
|
|
3
|
-
import { M
|
|
3
|
+
import { M } from "./chunks/index.mjs";
|
|
4
4
|
import { default as default3 } from "./NormalToolbar.mjs";
|
|
5
5
|
import { D } from "./chunks/index2.mjs";
|
|
6
6
|
import { default as default4 } from "./ModalToolbar.mjs";
|
|
7
7
|
import { M as M2 } from "./chunks/index3.mjs";
|
|
8
8
|
import { M as M3 } from "./chunks/index4.mjs";
|
|
9
|
+
import { S } from "./chunks/dom.mjs";
|
|
9
10
|
import { defineComponent, createVNode } from "vue";
|
|
10
11
|
import { g as getSlot } from "./chunks/vue-tsx.mjs";
|
|
11
12
|
import { p as prefix } from "./chunks/config.mjs";
|