md-editor-v3 5.4.0-0 → 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 +38 -58
- 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 +39 -59
- 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 +16 -3
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
|
@@ -5,6 +5,7 @@ const eventName = require("./event-name.cjs");
|
|
|
5
5
|
const util = require("@vavt/util");
|
|
6
6
|
const dom = require("./dom.cjs");
|
|
7
7
|
const mediumZoom = require("medium-zoom");
|
|
8
|
+
const copy2clipboard = require("@vavt/copy2clipboard");
|
|
8
9
|
const mdit = require("markdown-it");
|
|
9
10
|
const ImageFiguresPlugin = require("markdown-it-image-figures");
|
|
10
11
|
const SubPlugin = require("markdown-it-sub");
|
|
@@ -49,28 +50,6 @@ const userZoom = (props, html) => {
|
|
|
49
50
|
}
|
|
50
51
|
});
|
|
51
52
|
};
|
|
52
|
-
const copy2Clipboard = async (text) => {
|
|
53
|
-
if (typeof text !== "string") return;
|
|
54
|
-
if (window.isSecureContext && navigator.clipboard) {
|
|
55
|
-
return await navigator.clipboard.writeText(text);
|
|
56
|
-
} else {
|
|
57
|
-
const textarea = document.createElement("textarea");
|
|
58
|
-
let successed = false;
|
|
59
|
-
textarea.value = text;
|
|
60
|
-
textarea.style.position = "fixed";
|
|
61
|
-
textarea.style.opacity = 0;
|
|
62
|
-
textarea.style.zIndex = "-10000";
|
|
63
|
-
textarea.style.top = "-10000";
|
|
64
|
-
document.body.appendChild(textarea);
|
|
65
|
-
textarea.select();
|
|
66
|
-
successed = document.execCommand("copy");
|
|
67
|
-
document.body.removeChild(textarea);
|
|
68
|
-
if (successed) {
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
throw new Error('Failed to copy content via "execCommand"!');
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
53
|
const useCopyCode = (props, html, key) => {
|
|
75
54
|
const editorId = vue.inject("editorId");
|
|
76
55
|
const rootRef = vue.inject("rootRef");
|
|
@@ -89,7 +68,7 @@ const useCopyCode = (props, html, key) => {
|
|
|
89
68
|
const codeText = activeCode.textContent;
|
|
90
69
|
const { text, successTips, failTips } = ult.value.copyCode;
|
|
91
70
|
let msg = successTips;
|
|
92
|
-
|
|
71
|
+
copy2clipboard(props.formatCopiedText(codeText)).catch(() => {
|
|
93
72
|
msg = failTips;
|
|
94
73
|
}).finally(() => {
|
|
95
74
|
if (copyButton.dataset.isIcon) {
|
|
@@ -169,10 +148,9 @@ const useMermaid = (props) => {
|
|
|
169
148
|
const theme = vue.inject("theme");
|
|
170
149
|
const rootRef = vue.inject("rootRef");
|
|
171
150
|
const { editorExtensions, editorExtensionsAttrs, mermaidConfig } = config.configOption;
|
|
172
|
-
|
|
151
|
+
let mermaid = editorExtensions.mermaid.instance;
|
|
173
152
|
const reRenderRef = vue.shallowRef(-1);
|
|
174
153
|
const configMermaid = () => {
|
|
175
|
-
const mermaid = mermaidRef.value;
|
|
176
154
|
if (!props.noMermaid && mermaid) {
|
|
177
155
|
mermaid.initialize(
|
|
178
156
|
mermaidConfig({
|
|
@@ -192,7 +170,7 @@ const useMermaid = (props) => {
|
|
|
192
170
|
);
|
|
193
171
|
vue.onMounted(() => {
|
|
194
172
|
var _a, _b;
|
|
195
|
-
if (props.noMermaid ||
|
|
173
|
+
if (props.noMermaid || mermaid) {
|
|
196
174
|
return;
|
|
197
175
|
}
|
|
198
176
|
const jsSrc = editorExtensions.mermaid.js;
|
|
@@ -208,7 +186,7 @@ const useMermaid = (props) => {
|
|
|
208
186
|
/* webpackIgnore: true */
|
|
209
187
|
jsSrc
|
|
210
188
|
).then((module2) => {
|
|
211
|
-
|
|
189
|
+
mermaid = module2.default;
|
|
212
190
|
configMermaid();
|
|
213
191
|
});
|
|
214
192
|
} else {
|
|
@@ -219,7 +197,7 @@ const useMermaid = (props) => {
|
|
|
219
197
|
src: jsSrc,
|
|
220
198
|
id: CDN_IDS.mermaid,
|
|
221
199
|
onload() {
|
|
222
|
-
|
|
200
|
+
mermaid = window.mermaid;
|
|
223
201
|
configMermaid();
|
|
224
202
|
}
|
|
225
203
|
},
|
|
@@ -228,7 +206,7 @@ const useMermaid = (props) => {
|
|
|
228
206
|
}
|
|
229
207
|
});
|
|
230
208
|
const replaceMermaid = async () => {
|
|
231
|
-
if (!props.noMermaid &&
|
|
209
|
+
if (!props.noMermaid && mermaid) {
|
|
232
210
|
const mermaidSourceEles = rootRef.value.querySelectorAll(
|
|
233
211
|
`div.${config.prefix}-mermaid`
|
|
234
212
|
);
|
|
@@ -248,23 +226,20 @@ const useMermaid = (props) => {
|
|
|
248
226
|
Array.from(mermaidSourceEles).map((ele) => {
|
|
249
227
|
const handler = async (item) => {
|
|
250
228
|
var _a;
|
|
251
|
-
|
|
229
|
+
const code = item.dataset.code;
|
|
230
|
+
let mermaidHtml = mermaidCache.get(code);
|
|
252
231
|
if (!mermaidHtml) {
|
|
253
232
|
const idRand = util.randomId();
|
|
254
233
|
let result = { svg: "" };
|
|
255
234
|
try {
|
|
256
|
-
result = await
|
|
257
|
-
idRand,
|
|
258
|
-
item.innerText,
|
|
259
|
-
svgContainingElement
|
|
260
|
-
);
|
|
235
|
+
result = await mermaid.render(idRand, code, svgContainingElement);
|
|
261
236
|
mermaidHtml = await props.sanitizeMermaid(result.svg);
|
|
262
237
|
const p = document.createElement("p");
|
|
263
238
|
p.className = `${config.prefix}-mermaid`;
|
|
264
239
|
p.setAttribute("data-processed", "");
|
|
265
240
|
p.innerHTML = mermaidHtml;
|
|
266
241
|
(_a = p.children[0]) == null ? void 0 : _a.removeAttribute("height");
|
|
267
|
-
mermaidCache.set(
|
|
242
|
+
mermaidCache.set(code, p.innerHTML);
|
|
268
243
|
if (item.dataset.line !== void 0) {
|
|
269
244
|
p.dataset.line = item.dataset.line;
|
|
270
245
|
}
|
|
@@ -281,7 +256,7 @@ const useMermaid = (props) => {
|
|
|
281
256
|
);
|
|
282
257
|
}
|
|
283
258
|
};
|
|
284
|
-
return {
|
|
259
|
+
return { reRenderRef, replaceMermaid };
|
|
285
260
|
};
|
|
286
261
|
const useKatex = (props) => {
|
|
287
262
|
const katex = vue.shallowRef(config.configOption.editorExtensions.katex.instance);
|
|
@@ -324,7 +299,7 @@ const MermaidPlugin = (md, options) => {
|
|
|
324
299
|
if (mermaidHtml) {
|
|
325
300
|
return `<p class="${config.prefix}-mermaid" ${line !== void 0 ? "data-line=" + line : ""} data-processed>${mermaidHtml}</p>`;
|
|
326
301
|
}
|
|
327
|
-
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>`;
|
|
328
303
|
}
|
|
329
304
|
return temp(tokens, idx, ops, env, slf);
|
|
330
305
|
};
|
|
@@ -623,17 +598,6 @@ const HeadingPlugin = (md, options) => {
|
|
|
623
598
|
return self.renderToken(tokens, idx, opts);
|
|
624
599
|
};
|
|
625
600
|
};
|
|
626
|
-
const iconMaps = {
|
|
627
|
-
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>`,
|
|
628
|
-
"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>`
|
|
629
|
-
};
|
|
630
|
-
const StrIcon = (name, customIcon) => {
|
|
631
|
-
if (typeof customIcon[name] === "string") {
|
|
632
|
-
return customIcon[name];
|
|
633
|
-
}
|
|
634
|
-
return iconMaps[name];
|
|
635
|
-
};
|
|
636
|
-
const StrIcon$1 = StrIcon;
|
|
637
601
|
const codetabs = (md, _opts) => {
|
|
638
602
|
const defaultRender = md.renderer.rules.fence, unescapeAll = md.utils.unescapeAll, re = /\[(\w*)(?::([\w ]*))?\]/, mandatoryRe = /::(open|close)/;
|
|
639
603
|
const getInfo = (token) => {
|
|
@@ -661,7 +625,7 @@ const codetabs = (md, _opts) => {
|
|
|
661
625
|
const codeCodeText = (_a = _opts.usedLanguageTextRef.value) == null ? void 0 : _a.copyCode.text;
|
|
662
626
|
const copyBtnHtml = _opts.customIconRef.value.copy || codeCodeText;
|
|
663
627
|
const isIcon = !!_opts.customIconRef.value.copy;
|
|
664
|
-
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>`;
|
|
665
629
|
const [GROUP] = getGroupAndTab(tokens[idx]);
|
|
666
630
|
if (GROUP === null) {
|
|
667
631
|
const { open: open2, tagContainer: tagContainer2, tagHeader: tagHeader2 } = getTagType(tokens[idx]);
|
|
@@ -866,7 +830,7 @@ const initLineNumber = (md) => {
|
|
|
866
830
|
});
|
|
867
831
|
};
|
|
868
832
|
const useMarkdownIt = (props, previewOnly) => {
|
|
869
|
-
const { editorConfig, markdownItConfig, markdownItPlugins } = config.configOption;
|
|
833
|
+
const { editorConfig, markdownItConfig, markdownItPlugins, editorExtensions } = config.configOption;
|
|
870
834
|
const editorId = vue.inject("editorId");
|
|
871
835
|
const languageRef = vue.inject("language");
|
|
872
836
|
const usedLanguageTextRef = vue.inject(
|
|
@@ -877,6 +841,8 @@ const useMarkdownIt = (props, previewOnly) => {
|
|
|
877
841
|
const customIconRef = vue.inject("customIcon");
|
|
878
842
|
const rootRef = vue.inject("rootRef");
|
|
879
843
|
const headsRef = vue.ref([]);
|
|
844
|
+
let clearMermaidEvents = () => {
|
|
845
|
+
};
|
|
880
846
|
const hljsRef = useHighlight(props);
|
|
881
847
|
const katexRef = useKatex(props);
|
|
882
848
|
const { reRenderRef, replaceMermaid } = useMermaid(props);
|
|
@@ -991,8 +957,16 @@ const useMarkdownIt = (props, previewOnly) => {
|
|
|
991
957
|
eventName.bus.emit(editorId, eventName.CATALOG_CHANGED, headsRef.value);
|
|
992
958
|
vue.nextTick(() => {
|
|
993
959
|
replaceMermaid().then(() => {
|
|
994
|
-
var _a;
|
|
995
|
-
|
|
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
|
+
}
|
|
996
970
|
});
|
|
997
971
|
});
|
|
998
972
|
};
|
|
@@ -1019,10 +993,16 @@ const useMarkdownIt = (props, previewOnly) => {
|
|
|
1019
993
|
if (props.setting.preview) {
|
|
1020
994
|
vue.nextTick(() => {
|
|
1021
995
|
replaceMermaid().then(() => {
|
|
1022
|
-
var _a;
|
|
1023
|
-
|
|
1024
|
-
(
|
|
1025
|
-
|
|
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
|
+
}
|
|
1026
1006
|
});
|
|
1027
1007
|
eventName.bus.emit(editorId, eventName.CATALOG_CHANGED, headsRef.value);
|
|
1028
1008
|
});
|
|
@@ -1046,6 +1026,7 @@ const useMarkdownIt = (props, previewOnly) => {
|
|
|
1046
1026
|
});
|
|
1047
1027
|
});
|
|
1048
1028
|
vue.onBeforeUnmount(() => {
|
|
1029
|
+
clearMermaidEvents();
|
|
1049
1030
|
clearTimeout(timer);
|
|
1050
1031
|
});
|
|
1051
1032
|
return { html, key };
|
|
@@ -2343,7 +2324,6 @@ MdPreview.install = (app) => {
|
|
|
2343
2324
|
exports.CDN_IDS = CDN_IDS;
|
|
2344
2325
|
exports.ContentPreview = ContentPreview;
|
|
2345
2326
|
exports.MdPreview = MdPreview;
|
|
2346
|
-
exports.StrIcon = StrIcon$1;
|
|
2347
2327
|
exports.contentProps = contentProps;
|
|
2348
2328
|
exports.editorEmits = editorEmits;
|
|
2349
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;
|