md-editor-v3 4.19.1 → 4.19.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/MdEditor.cjs +15 -11
- package/lib/cjs/chunks/dom.cjs +99 -0
- package/lib/cjs/chunks/event-name.cjs +1 -4
- package/lib/cjs/chunks/index.cjs +143 -172
- package/lib/cjs/chunks/index3.cjs +1 -2
- package/lib/es/MdEditor.mjs +16 -12
- package/lib/es/chunks/dom.mjs +100 -1
- package/lib/es/chunks/event-name.mjs +1 -4
- package/lib/es/chunks/index.mjs +144 -173
- package/lib/es/chunks/index3.mjs +1 -2
- package/lib/preview.css +1 -1
- package/lib/style.css +1 -1
- package/lib/types/MdEditor/layouts/Content/composition/useMermaid.d.ts +1 -1
- package/lib/types/MdEditor/utils/dom.d.ts +4 -0
- package/lib/umd/index.js +55 -54
- package/package.json +2 -2
package/lib/cjs/chunks/index.cjs
CHANGED
|
@@ -208,52 +208,57 @@ const useMermaid = (props) => {
|
|
|
208
208
|
);
|
|
209
209
|
}
|
|
210
210
|
});
|
|
211
|
-
const replaceMermaid = () => {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
mermaidSourceEles.forEach(async (item) => {
|
|
228
|
-
let mermaidHtml = mermaidCache.get(item.innerText);
|
|
229
|
-
if (!mermaidHtml) {
|
|
230
|
-
const idRand = util$2.randomId();
|
|
231
|
-
const render = mermaidRef.value.renderAsync || mermaidRef.value.render;
|
|
232
|
-
let svg = "";
|
|
233
|
-
try {
|
|
234
|
-
svg = await render(idRand, item.innerText, svgContainingElement);
|
|
235
|
-
} catch (error) {
|
|
236
|
-
}
|
|
237
|
-
mermaidHtml = await props.sanitizeMermaid(
|
|
238
|
-
typeof svg === "string" ? svg : svg.svg
|
|
239
|
-
);
|
|
240
|
-
}
|
|
241
|
-
const p = document.createElement("p");
|
|
242
|
-
p.className = `${config.prefix}-mermaid`;
|
|
243
|
-
p.setAttribute("data-processed", "");
|
|
244
|
-
p.innerHTML = mermaidHtml;
|
|
245
|
-
p.children[0].removeAttribute("height");
|
|
246
|
-
mermaidCache.set(item.innerText, p.innerHTML);
|
|
247
|
-
if (item.dataset.line !== void 0) {
|
|
248
|
-
p.dataset.line = item.dataset.line;
|
|
249
|
-
}
|
|
250
|
-
item.replaceWith(p);
|
|
251
|
-
if (--count === 0) {
|
|
252
|
-
svgContainingElement.remove();
|
|
253
|
-
}
|
|
254
|
-
});
|
|
211
|
+
const replaceMermaid = async () => {
|
|
212
|
+
if (!props.noMermaid && mermaidRef.value) {
|
|
213
|
+
const mermaidSourceEles = rootRef.value.querySelectorAll(
|
|
214
|
+
`div.${config.prefix}-mermaid`
|
|
215
|
+
);
|
|
216
|
+
const svgContainingElement = document.createElement("div");
|
|
217
|
+
const sceWidth = document.body.offsetWidth > 1366 ? document.body.offsetWidth : 1366;
|
|
218
|
+
const sceHeight = document.body.offsetHeight > 768 ? document.body.offsetHeight : 768;
|
|
219
|
+
svgContainingElement.style.width = sceWidth + "px";
|
|
220
|
+
svgContainingElement.style.height = sceHeight + "px";
|
|
221
|
+
svgContainingElement.style.position = "fixed";
|
|
222
|
+
svgContainingElement.style.zIndex = "-10000";
|
|
223
|
+
svgContainingElement.style.top = "-10000";
|
|
224
|
+
let count = mermaidSourceEles.length;
|
|
225
|
+
if (count > 0) {
|
|
226
|
+
document.body.appendChild(svgContainingElement);
|
|
255
227
|
}
|
|
256
|
-
|
|
228
|
+
await Promise.allSettled(
|
|
229
|
+
Array.from(mermaidSourceEles).map((ele) => {
|
|
230
|
+
const handler = async (item) => {
|
|
231
|
+
let mermaidHtml = mermaidCache.get(item.innerText);
|
|
232
|
+
if (!mermaidHtml) {
|
|
233
|
+
const idRand = util$2.randomId();
|
|
234
|
+
const render = mermaidRef.value.renderAsync || mermaidRef.value.render;
|
|
235
|
+
let svg = "";
|
|
236
|
+
try {
|
|
237
|
+
svg = await render(idRand, item.innerText, svgContainingElement);
|
|
238
|
+
} catch (error) {
|
|
239
|
+
}
|
|
240
|
+
mermaidHtml = await props.sanitizeMermaid(
|
|
241
|
+
typeof svg === "string" ? svg : svg.svg
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
const p = document.createElement("p");
|
|
245
|
+
p.className = `${config.prefix}-mermaid`;
|
|
246
|
+
p.setAttribute("data-processed", "");
|
|
247
|
+
p.innerHTML = mermaidHtml;
|
|
248
|
+
p.children[0].removeAttribute("height");
|
|
249
|
+
mermaidCache.set(item.innerText, p.innerHTML);
|
|
250
|
+
if (item.dataset.line !== void 0) {
|
|
251
|
+
p.dataset.line = item.dataset.line;
|
|
252
|
+
}
|
|
253
|
+
item.replaceWith(p);
|
|
254
|
+
if (--count === 0) {
|
|
255
|
+
svgContainingElement.remove();
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
return handler(ele);
|
|
259
|
+
})
|
|
260
|
+
);
|
|
261
|
+
}
|
|
257
262
|
};
|
|
258
263
|
return { mermaidRef, reRenderRef, replaceMermaid };
|
|
259
264
|
};
|
|
@@ -303,7 +308,6 @@ const MermaidPlugin = (md, options) => {
|
|
|
303
308
|
return temp(tokens, idx, ops, env, slf);
|
|
304
309
|
};
|
|
305
310
|
};
|
|
306
|
-
const MermaidPlugin$1 = MermaidPlugin;
|
|
307
311
|
const mergeAttrs = (token, addAttrs) => {
|
|
308
312
|
const tmpAttrs = token.attrs ? token.attrs.slice() : [];
|
|
309
313
|
addAttrs.forEach((addAttr) => {
|
|
@@ -455,7 +459,6 @@ const KatexPlugin = (md, { katexRef }) => {
|
|
|
455
459
|
md.renderer.rules.math_inline = katexInline;
|
|
456
460
|
md.renderer.rules.math_block = katexBlock;
|
|
457
461
|
};
|
|
458
|
-
const KatexPlugin$1 = KatexPlugin;
|
|
459
462
|
const AdmonitionPlugin = (md, options) => {
|
|
460
463
|
options = options || {};
|
|
461
464
|
const markers = 3, markerStr = options.marker || "!", markerChar = markerStr.charCodeAt(0), markerLen = markerStr.length;
|
|
@@ -575,7 +578,6 @@ const AdmonitionPlugin = (md, options) => {
|
|
|
575
578
|
md.renderer.rules["admonition_title_close"] = render;
|
|
576
579
|
md.renderer.rules["admonition_close"] = render;
|
|
577
580
|
};
|
|
578
|
-
const AdmonitionPlugin$1 = AdmonitionPlugin;
|
|
579
581
|
const HeadingPlugin = (md, options) => {
|
|
580
582
|
md.renderer.rules.heading_open = (tokens, idx) => {
|
|
581
583
|
var _a;
|
|
@@ -600,7 +602,6 @@ const HeadingPlugin = (md, options) => {
|
|
|
600
602
|
return self2.renderToken(tokens, idx, opts);
|
|
601
603
|
};
|
|
602
604
|
};
|
|
603
|
-
const HeadingPlugin$1 = HeadingPlugin;
|
|
604
605
|
const StrIcon = (name, customIcon) => {
|
|
605
606
|
if (typeof customIcon[name] === "string") {
|
|
606
607
|
return customIcon[name];
|
|
@@ -705,7 +706,6 @@ const codetabs = (md, _opts) => {
|
|
|
705
706
|
md.renderer.rules.fence = fenceGroup;
|
|
706
707
|
md.renderer.rules.code_block = fenceGroup;
|
|
707
708
|
};
|
|
708
|
-
const CodePlugin = codetabs;
|
|
709
709
|
function getDefaultExportFromCjs(x) {
|
|
710
710
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
711
711
|
}
|
|
@@ -1058,8 +1058,7 @@ function onIgnoreAttr(name, value, options) {
|
|
|
1058
1058
|
}
|
|
1059
1059
|
var REGEXP_URL_JAVASCRIPT = /javascript\s*\:/img;
|
|
1060
1060
|
function safeAttrValue$1(name, value) {
|
|
1061
|
-
if (REGEXP_URL_JAVASCRIPT.test(value))
|
|
1062
|
-
return "";
|
|
1061
|
+
if (REGEXP_URL_JAVASCRIPT.test(value)) return "";
|
|
1063
1062
|
return value;
|
|
1064
1063
|
}
|
|
1065
1064
|
_default.whiteList = getDefaultWhiteList$1();
|
|
@@ -1105,8 +1104,7 @@ var util$1 = {
|
|
|
1105
1104
|
var _$3 = util$1;
|
|
1106
1105
|
function parseStyle$1(css2, onAttr2) {
|
|
1107
1106
|
css2 = _$3.trimRight(css2);
|
|
1108
|
-
if (css2[css2.length - 1] !== ";")
|
|
1109
|
-
css2 += ";";
|
|
1107
|
+
if (css2[css2.length - 1] !== ";") css2 += ";";
|
|
1110
1108
|
var cssLength = css2.length;
|
|
1111
1109
|
var isParenthesisOpen = false;
|
|
1112
1110
|
var lastPos = 0;
|
|
@@ -1121,8 +1119,7 @@ function parseStyle$1(css2, onAttr2) {
|
|
|
1121
1119
|
var value = _$3.trim(source.slice(j2 + 1));
|
|
1122
1120
|
if (name) {
|
|
1123
1121
|
var ret = onAttr2(lastPos, retCSS.length, name, value, source);
|
|
1124
|
-
if (ret)
|
|
1125
|
-
retCSS += ret + "; ";
|
|
1122
|
+
if (ret) retCSS += ret + "; ";
|
|
1126
1123
|
}
|
|
1127
1124
|
}
|
|
1128
1125
|
}
|
|
@@ -1132,8 +1129,7 @@ function parseStyle$1(css2, onAttr2) {
|
|
|
1132
1129
|
var c = css2[i];
|
|
1133
1130
|
if (c === "/" && css2[i + 1] === "*") {
|
|
1134
1131
|
var j = css2.indexOf("*/", i + 2);
|
|
1135
|
-
if (j === -1)
|
|
1136
|
-
break;
|
|
1132
|
+
if (j === -1) break;
|
|
1137
1133
|
i = j + 1;
|
|
1138
1134
|
lastPos = i + 1;
|
|
1139
1135
|
isParenthesisOpen = false;
|
|
@@ -1142,8 +1138,7 @@ function parseStyle$1(css2, onAttr2) {
|
|
|
1142
1138
|
} else if (c === ")") {
|
|
1143
1139
|
isParenthesisOpen = false;
|
|
1144
1140
|
} else if (c === ";") {
|
|
1145
|
-
if (isParenthesisOpen)
|
|
1146
|
-
;
|
|
1141
|
+
if (isParenthesisOpen) ;
|
|
1147
1142
|
else {
|
|
1148
1143
|
addNewAttr();
|
|
1149
1144
|
}
|
|
@@ -1177,8 +1172,7 @@ function FilterCSS$2(options) {
|
|
|
1177
1172
|
FilterCSS$2.prototype.process = function(css2) {
|
|
1178
1173
|
css2 = css2 || "";
|
|
1179
1174
|
css2 = css2.toString();
|
|
1180
|
-
if (!css2)
|
|
1181
|
-
return "";
|
|
1175
|
+
if (!css2) return "";
|
|
1182
1176
|
var me = this;
|
|
1183
1177
|
var options = me.options;
|
|
1184
1178
|
var whiteList = options.whiteList;
|
|
@@ -1188,17 +1182,12 @@ FilterCSS$2.prototype.process = function(css2) {
|
|
|
1188
1182
|
var retCSS = parseStyle(css2, function(sourcePosition, position, name, value, source) {
|
|
1189
1183
|
var check = whiteList[name];
|
|
1190
1184
|
var isWhite = false;
|
|
1191
|
-
if (check === true)
|
|
1192
|
-
|
|
1193
|
-
else if (
|
|
1194
|
-
|
|
1195
|
-
else if (check instanceof RegExp)
|
|
1196
|
-
isWhite = check.test(value);
|
|
1197
|
-
if (isWhite !== true)
|
|
1198
|
-
isWhite = false;
|
|
1185
|
+
if (check === true) isWhite = check;
|
|
1186
|
+
else if (typeof check === "function") isWhite = check(value);
|
|
1187
|
+
else if (check instanceof RegExp) isWhite = check.test(value);
|
|
1188
|
+
if (isWhite !== true) isWhite = false;
|
|
1199
1189
|
value = safeAttrValue2(name, value);
|
|
1200
|
-
if (!value)
|
|
1201
|
-
return;
|
|
1190
|
+
if (!value) return;
|
|
1202
1191
|
var opts = {
|
|
1203
1192
|
position,
|
|
1204
1193
|
sourcePosition,
|
|
@@ -1231,8 +1220,7 @@ var css = FilterCSS$2;
|
|
|
1231
1220
|
}
|
|
1232
1221
|
exports2 = module2.exports = filterCSS;
|
|
1233
1222
|
exports2.FilterCSS = FilterCSS2;
|
|
1234
|
-
for (var i in DEFAULT2)
|
|
1235
|
-
exports2[i] = DEFAULT2[i];
|
|
1223
|
+
for (var i in DEFAULT2) exports2[i] = DEFAULT2[i];
|
|
1236
1224
|
if (typeof window !== "undefined") {
|
|
1237
1225
|
window.filterCSS = module2.exports;
|
|
1238
1226
|
}
|
|
@@ -1383,8 +1371,7 @@ function safeAttrValue(tag, name, value, cssFilter) {
|
|
|
1383
1371
|
value = friendlyAttrValue(value);
|
|
1384
1372
|
if (name === "href" || name === "src") {
|
|
1385
1373
|
value = _$2.trim(value);
|
|
1386
|
-
if (value === "#")
|
|
1387
|
-
return "#";
|
|
1374
|
+
if (value === "#") return "#";
|
|
1388
1375
|
if (!(value.substr(0, 7) === "http://" || value.substr(0, 8) === "https://" || value.substr(0, 7) === "mailto:" || value.substr(0, 4) === "tel:" || value.substr(0, 11) === "data:image/" || value.substr(0, 6) === "ftp://" || value.substr(0, 2) === "./" || value.substr(0, 3) === "../" || value[0] === "#" || value[0] === "/")) {
|
|
1389
1376
|
return "";
|
|
1390
1377
|
}
|
|
@@ -1466,8 +1453,7 @@ function StripTagBody(tags, next) {
|
|
|
1466
1453
|
}
|
|
1467
1454
|
var isRemoveAllTag = !Array.isArray(tags);
|
|
1468
1455
|
function isRemoveTag(tag) {
|
|
1469
|
-
if (isRemoveAllTag)
|
|
1470
|
-
return true;
|
|
1456
|
+
if (isRemoveAllTag) return true;
|
|
1471
1457
|
return _$2.indexOf(tags, tag) !== -1;
|
|
1472
1458
|
}
|
|
1473
1459
|
var removeList = [];
|
|
@@ -1528,11 +1514,9 @@ function stripBlankChar(html) {
|
|
|
1528
1514
|
var chars = html.split("");
|
|
1529
1515
|
chars = chars.filter(function(char) {
|
|
1530
1516
|
var c = char.charCodeAt(0);
|
|
1531
|
-
if (c === 127)
|
|
1532
|
-
return false;
|
|
1517
|
+
if (c === 127) return false;
|
|
1533
1518
|
if (c <= 31) {
|
|
1534
|
-
if (c === 10 || c === 13)
|
|
1535
|
-
return true;
|
|
1519
|
+
if (c === 10 || c === 13) return true;
|
|
1536
1520
|
return false;
|
|
1537
1521
|
}
|
|
1538
1522
|
return true;
|
|
@@ -1572,10 +1556,8 @@ function getTagName(html) {
|
|
|
1572
1556
|
tagName = html.slice(1, i + 1);
|
|
1573
1557
|
}
|
|
1574
1558
|
tagName = _$1.trim(tagName).toLowerCase();
|
|
1575
|
-
if (tagName.slice(0, 1) === "/")
|
|
1576
|
-
|
|
1577
|
-
if (tagName.slice(-1) === "/")
|
|
1578
|
-
tagName = tagName.slice(0, -1);
|
|
1559
|
+
if (tagName.slice(0, 1) === "/") tagName = tagName.slice(1);
|
|
1560
|
+
if (tagName.slice(-1) === "/") tagName = tagName.slice(0, -1);
|
|
1579
1561
|
return tagName;
|
|
1580
1562
|
}
|
|
1581
1563
|
function isClosing(html) {
|
|
@@ -1590,56 +1572,55 @@ function parseTag$1(html, onTag2, escapeHtml2) {
|
|
|
1590
1572
|
var len = html.length;
|
|
1591
1573
|
var currentTagName = "";
|
|
1592
1574
|
var currentHtml = "";
|
|
1593
|
-
chariterator:
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
if (
|
|
1575
|
+
chariterator: for (currentPos = 0; currentPos < len; currentPos++) {
|
|
1576
|
+
var c = html.charAt(currentPos);
|
|
1577
|
+
if (tagStart === false) {
|
|
1578
|
+
if (c === "<") {
|
|
1579
|
+
tagStart = currentPos;
|
|
1580
|
+
continue;
|
|
1581
|
+
}
|
|
1582
|
+
} else {
|
|
1583
|
+
if (quoteStart === false) {
|
|
1597
1584
|
if (c === "<") {
|
|
1585
|
+
rethtml += escapeHtml2(html.slice(lastPos, currentPos));
|
|
1598
1586
|
tagStart = currentPos;
|
|
1587
|
+
lastPos = currentPos;
|
|
1599
1588
|
continue;
|
|
1600
1589
|
}
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
}
|
|
1624
|
-
if (c === '"' || c === "'") {
|
|
1625
|
-
var i = 1;
|
|
1626
|
-
var ic = html.charAt(currentPos - i);
|
|
1627
|
-
while (ic.trim() === "" || ic === "=") {
|
|
1628
|
-
if (ic === "=") {
|
|
1629
|
-
quoteStart = c;
|
|
1630
|
-
continue chariterator;
|
|
1631
|
-
}
|
|
1632
|
-
ic = html.charAt(currentPos - ++i);
|
|
1590
|
+
if (c === ">" || currentPos === len - 1) {
|
|
1591
|
+
rethtml += escapeHtml2(html.slice(lastPos, tagStart));
|
|
1592
|
+
currentHtml = html.slice(tagStart, currentPos + 1);
|
|
1593
|
+
currentTagName = getTagName(currentHtml);
|
|
1594
|
+
rethtml += onTag2(
|
|
1595
|
+
tagStart,
|
|
1596
|
+
rethtml.length,
|
|
1597
|
+
currentTagName,
|
|
1598
|
+
currentHtml,
|
|
1599
|
+
isClosing(currentHtml)
|
|
1600
|
+
);
|
|
1601
|
+
lastPos = currentPos + 1;
|
|
1602
|
+
tagStart = false;
|
|
1603
|
+
continue;
|
|
1604
|
+
}
|
|
1605
|
+
if (c === '"' || c === "'") {
|
|
1606
|
+
var i = 1;
|
|
1607
|
+
var ic = html.charAt(currentPos - i);
|
|
1608
|
+
while (ic.trim() === "" || ic === "=") {
|
|
1609
|
+
if (ic === "=") {
|
|
1610
|
+
quoteStart = c;
|
|
1611
|
+
continue chariterator;
|
|
1633
1612
|
}
|
|
1634
|
-
|
|
1635
|
-
} else {
|
|
1636
|
-
if (c === quoteStart) {
|
|
1637
|
-
quoteStart = false;
|
|
1638
|
-
continue;
|
|
1613
|
+
ic = html.charAt(currentPos - ++i);
|
|
1639
1614
|
}
|
|
1640
1615
|
}
|
|
1616
|
+
} else {
|
|
1617
|
+
if (c === quoteStart) {
|
|
1618
|
+
quoteStart = false;
|
|
1619
|
+
continue;
|
|
1620
|
+
}
|
|
1641
1621
|
}
|
|
1642
1622
|
}
|
|
1623
|
+
}
|
|
1643
1624
|
if (lastPos < len) {
|
|
1644
1625
|
rethtml += escapeHtml2(html.substr(lastPos));
|
|
1645
1626
|
}
|
|
@@ -1655,11 +1636,9 @@ function parseAttr$1(html, onAttr2) {
|
|
|
1655
1636
|
function addAttr(name, value) {
|
|
1656
1637
|
name = _$1.trim(name);
|
|
1657
1638
|
name = name.replace(REGEXP_ILLEGAL_ATTR_NAME, "").toLowerCase();
|
|
1658
|
-
if (name.length < 1)
|
|
1659
|
-
return;
|
|
1639
|
+
if (name.length < 1) return;
|
|
1660
1640
|
var ret = onAttr2(name, value || "");
|
|
1661
|
-
if (ret)
|
|
1662
|
-
retAttrs.push(ret);
|
|
1641
|
+
if (ret) retAttrs.push(ret);
|
|
1663
1642
|
}
|
|
1664
1643
|
for (var i = 0; i < len; i++) {
|
|
1665
1644
|
var c = html.charAt(i);
|
|
@@ -1726,30 +1705,24 @@ function parseAttr$1(html, onAttr2) {
|
|
|
1726
1705
|
function findNextEqual(str, i) {
|
|
1727
1706
|
for (; i < str.length; i++) {
|
|
1728
1707
|
var c = str[i];
|
|
1729
|
-
if (c === " ")
|
|
1730
|
-
|
|
1731
|
-
if (c === "=")
|
|
1732
|
-
return i;
|
|
1708
|
+
if (c === " ") continue;
|
|
1709
|
+
if (c === "=") return i;
|
|
1733
1710
|
return -1;
|
|
1734
1711
|
}
|
|
1735
1712
|
}
|
|
1736
1713
|
function findNextQuotationMark(str, i) {
|
|
1737
1714
|
for (; i < str.length; i++) {
|
|
1738
1715
|
var c = str[i];
|
|
1739
|
-
if (c === " ")
|
|
1740
|
-
|
|
1741
|
-
if (c === "'" || c === '"')
|
|
1742
|
-
return i;
|
|
1716
|
+
if (c === " ") continue;
|
|
1717
|
+
if (c === "'" || c === '"') return i;
|
|
1743
1718
|
return -1;
|
|
1744
1719
|
}
|
|
1745
1720
|
}
|
|
1746
1721
|
function findBeforeEqual(str, i) {
|
|
1747
1722
|
for (; i > 0; i--) {
|
|
1748
1723
|
var c = str[i];
|
|
1749
|
-
if (c === " ")
|
|
1750
|
-
|
|
1751
|
-
if (c === "=")
|
|
1752
|
-
return i;
|
|
1724
|
+
if (c === " ") continue;
|
|
1725
|
+
if (c === "=") return i;
|
|
1753
1726
|
return -1;
|
|
1754
1727
|
}
|
|
1755
1728
|
}
|
|
@@ -1788,8 +1761,7 @@ function getAttrs(html) {
|
|
|
1788
1761
|
}
|
|
1789
1762
|
html = _.trim(html.slice(i + 1, -1));
|
|
1790
1763
|
var isClosing2 = html[html.length - 1] === "/";
|
|
1791
|
-
if (isClosing2)
|
|
1792
|
-
html = _.trim(html.slice(0, -1));
|
|
1764
|
+
if (isClosing2) html = _.trim(html.slice(0, -1));
|
|
1793
1765
|
return {
|
|
1794
1766
|
html,
|
|
1795
1767
|
closing: isClosing2
|
|
@@ -1848,8 +1820,7 @@ function FilterXSS(options) {
|
|
|
1848
1820
|
FilterXSS.prototype.process = function(html) {
|
|
1849
1821
|
html = html || "";
|
|
1850
1822
|
html = html.toString();
|
|
1851
|
-
if (!html)
|
|
1852
|
-
return "";
|
|
1823
|
+
if (!html) return "";
|
|
1853
1824
|
var me = this;
|
|
1854
1825
|
var options = me.options;
|
|
1855
1826
|
var whiteList = options.whiteList;
|
|
@@ -1885,8 +1856,7 @@ FilterXSS.prototype.process = function(html) {
|
|
|
1885
1856
|
isWhite: Object.prototype.hasOwnProperty.call(whiteList, tag)
|
|
1886
1857
|
};
|
|
1887
1858
|
var ret = onTag2(tag, html2, info);
|
|
1888
|
-
if (!isNull(ret))
|
|
1889
|
-
return ret;
|
|
1859
|
+
if (!isNull(ret)) return ret;
|
|
1890
1860
|
if (info.isWhite) {
|
|
1891
1861
|
if (info.isClosing) {
|
|
1892
1862
|
return "</" + tag + ">";
|
|
@@ -1896,8 +1866,7 @@ FilterXSS.prototype.process = function(html) {
|
|
|
1896
1866
|
var attrsHtml = parseAttr(attrs.html, function(name, value) {
|
|
1897
1867
|
var isWhiteAttr = _.indexOf(whiteAttrList, name) !== -1;
|
|
1898
1868
|
var ret2 = onTagAttr2(tag, name, value, isWhiteAttr);
|
|
1899
|
-
if (!isNull(ret2))
|
|
1900
|
-
return ret2;
|
|
1869
|
+
if (!isNull(ret2)) return ret2;
|
|
1901
1870
|
if (isWhiteAttr) {
|
|
1902
1871
|
value = safeAttrValue2(tag, name, value, cssFilter);
|
|
1903
1872
|
if (value) {
|
|
@@ -1907,22 +1876,18 @@ FilterXSS.prototype.process = function(html) {
|
|
|
1907
1876
|
}
|
|
1908
1877
|
} else {
|
|
1909
1878
|
ret2 = onIgnoreTagAttr2(tag, name, value, isWhiteAttr);
|
|
1910
|
-
if (!isNull(ret2))
|
|
1911
|
-
return ret2;
|
|
1879
|
+
if (!isNull(ret2)) return ret2;
|
|
1912
1880
|
return;
|
|
1913
1881
|
}
|
|
1914
1882
|
});
|
|
1915
1883
|
html2 = "<" + tag;
|
|
1916
|
-
if (attrsHtml)
|
|
1917
|
-
|
|
1918
|
-
if (attrs.closing)
|
|
1919
|
-
html2 += " /";
|
|
1884
|
+
if (attrsHtml) html2 += " " + attrsHtml;
|
|
1885
|
+
if (attrs.closing) html2 += " /";
|
|
1920
1886
|
html2 += ">";
|
|
1921
1887
|
return html2;
|
|
1922
1888
|
} else {
|
|
1923
1889
|
ret = onIgnoreTag2(tag, html2, info);
|
|
1924
|
-
if (!isNull(ret))
|
|
1925
|
-
return ret;
|
|
1890
|
+
if (!isNull(ret)) return ret;
|
|
1926
1891
|
return escapeHtml2(html2);
|
|
1927
1892
|
}
|
|
1928
1893
|
},
|
|
@@ -2030,7 +1995,6 @@ const XSSPlugin = (md, options) => {
|
|
|
2030
1995
|
}
|
|
2031
1996
|
});
|
|
2032
1997
|
};
|
|
2033
|
-
const XSSPlugin$1 = XSSPlugin;
|
|
2034
1998
|
const attrSet = (token, name, value) => {
|
|
2035
1999
|
const index2 = token.attrIndex(name);
|
|
2036
2000
|
const attr = [name, value];
|
|
@@ -2124,7 +2088,6 @@ const githubTaskLists = (md, options = {}) => {
|
|
|
2124
2088
|
}
|
|
2125
2089
|
});
|
|
2126
2090
|
};
|
|
2127
|
-
const TaskListPlugin = githubTaskLists;
|
|
2128
2091
|
const initLineNumber = (md) => {
|
|
2129
2092
|
md.core.ruler.push("init-line-number", (state) => {
|
|
2130
2093
|
state.tokens.forEach((token) => {
|
|
@@ -2148,6 +2111,7 @@ const useMarkdownIt = (props, previewOnly) => {
|
|
|
2148
2111
|
const showCodeRowNumber = vue.inject("showCodeRowNumber");
|
|
2149
2112
|
const themeRef = vue.inject("theme");
|
|
2150
2113
|
const customIconRef = vue.inject("customIcon");
|
|
2114
|
+
const rootRef = vue.inject("rootRef");
|
|
2151
2115
|
const headsRef = vue.ref([]);
|
|
2152
2116
|
const hljsRef = useHighlight(props);
|
|
2153
2117
|
const katexRef = useKatex(props);
|
|
@@ -2168,22 +2132,22 @@ const useMarkdownIt = (props, previewOnly) => {
|
|
|
2168
2132
|
},
|
|
2169
2133
|
{
|
|
2170
2134
|
type: "admonition",
|
|
2171
|
-
plugin: AdmonitionPlugin
|
|
2135
|
+
plugin: AdmonitionPlugin,
|
|
2172
2136
|
options: {}
|
|
2173
2137
|
},
|
|
2174
2138
|
{
|
|
2175
2139
|
type: "taskList",
|
|
2176
|
-
plugin:
|
|
2140
|
+
plugin: githubTaskLists,
|
|
2177
2141
|
options: {}
|
|
2178
2142
|
},
|
|
2179
2143
|
{
|
|
2180
2144
|
type: "heading",
|
|
2181
|
-
plugin: HeadingPlugin
|
|
2145
|
+
plugin: HeadingPlugin,
|
|
2182
2146
|
options: { mdHeadingId: props.mdHeadingId, headsRef }
|
|
2183
2147
|
},
|
|
2184
2148
|
{
|
|
2185
2149
|
type: "code",
|
|
2186
|
-
plugin:
|
|
2150
|
+
plugin: codetabs,
|
|
2187
2151
|
options: {
|
|
2188
2152
|
editorId,
|
|
2189
2153
|
usedLanguageTextRef,
|
|
@@ -2195,21 +2159,21 @@ const useMarkdownIt = (props, previewOnly) => {
|
|
|
2195
2159
|
},
|
|
2196
2160
|
{
|
|
2197
2161
|
type: "xss",
|
|
2198
|
-
plugin: XSSPlugin
|
|
2162
|
+
plugin: XSSPlugin,
|
|
2199
2163
|
options: {}
|
|
2200
2164
|
}
|
|
2201
2165
|
];
|
|
2202
2166
|
if (!props.noKatex) {
|
|
2203
2167
|
plugins.push({
|
|
2204
2168
|
type: "katex",
|
|
2205
|
-
plugin: KatexPlugin
|
|
2169
|
+
plugin: KatexPlugin,
|
|
2206
2170
|
options: { katexRef }
|
|
2207
2171
|
});
|
|
2208
2172
|
}
|
|
2209
2173
|
if (!props.noMermaid) {
|
|
2210
2174
|
plugins.push({
|
|
2211
2175
|
type: "mermaid",
|
|
2212
|
-
plugin: MermaidPlugin
|
|
2176
|
+
plugin: MermaidPlugin,
|
|
2213
2177
|
options: { themeRef }
|
|
2214
2178
|
});
|
|
2215
2179
|
}
|
|
@@ -2256,7 +2220,11 @@ const useMarkdownIt = (props, previewOnly) => {
|
|
|
2256
2220
|
props.onHtmlChanged(html.value);
|
|
2257
2221
|
props.onGetCatalog(headsRef.value);
|
|
2258
2222
|
eventName.bus.emit(editorId, eventName.CATALOG_CHANGED, headsRef.value);
|
|
2259
|
-
|
|
2223
|
+
vue.nextTick(() => {
|
|
2224
|
+
replaceMermaid().then(() => {
|
|
2225
|
+
dom.zoomMermaid(rootRef.value.querySelectorAll(`#${editorId} .${config.prefix}-mermaid`));
|
|
2226
|
+
});
|
|
2227
|
+
});
|
|
2260
2228
|
};
|
|
2261
2229
|
vue.onMounted(updatedTodo);
|
|
2262
2230
|
const markHtml = () => {
|
|
@@ -2276,7 +2244,11 @@ const useMarkdownIt = (props, previewOnly) => {
|
|
|
2276
2244
|
() => {
|
|
2277
2245
|
if (props.setting.preview) {
|
|
2278
2246
|
vue.nextTick(() => {
|
|
2279
|
-
replaceMermaid()
|
|
2247
|
+
replaceMermaid().then(() => {
|
|
2248
|
+
dom.zoomMermaid(
|
|
2249
|
+
rootRef.value.querySelectorAll(`#${editorId} .${config.prefix}-mermaid`)
|
|
2250
|
+
);
|
|
2251
|
+
});
|
|
2280
2252
|
eventName.bus.emit(editorId, eventName.CATALOG_CHANGED, headsRef.value);
|
|
2281
2253
|
});
|
|
2282
2254
|
}
|
|
@@ -2299,7 +2271,6 @@ const useMarkdownIt = (props, previewOnly) => {
|
|
|
2299
2271
|
});
|
|
2300
2272
|
return { html, key };
|
|
2301
2273
|
};
|
|
2302
|
-
const useMarkdownIt$1 = useMarkdownIt;
|
|
2303
2274
|
const template = {
|
|
2304
2275
|
checked: {
|
|
2305
2276
|
regexp: /- \[x\]/,
|
|
@@ -2517,7 +2488,7 @@ const ContentPreview = /* @__PURE__ */ vue.defineComponent({
|
|
|
2517
2488
|
const {
|
|
2518
2489
|
html,
|
|
2519
2490
|
key
|
|
2520
|
-
} = useMarkdownIt
|
|
2491
|
+
} = useMarkdownIt(props, props.previewOnly);
|
|
2521
2492
|
useCopyCode(props, html, key);
|
|
2522
2493
|
userZoom(props, html);
|
|
2523
2494
|
useTaskState(props, html);
|
|
@@ -349,7 +349,6 @@ const CatalogLink = /* @__PURE__ */ vue.defineComponent({
|
|
|
349
349
|
};
|
|
350
350
|
}
|
|
351
351
|
});
|
|
352
|
-
const CatalogLink$1 = CatalogLink;
|
|
353
352
|
const props = {
|
|
354
353
|
/**
|
|
355
354
|
* 编辑器的Id,务必与需要绑定的编辑器Id相同
|
|
@@ -547,7 +546,7 @@ const MdCatalog = /* @__PURE__ */ vue.defineComponent({
|
|
|
547
546
|
"class": [`${config.prefix}-catalog${props2.theme === "dark" ? "-dark" : ""}`, `${props2.class}`],
|
|
548
547
|
"ref": catalogRef
|
|
549
548
|
}, [catalogs.value.map((item) => {
|
|
550
|
-
return vue.createVNode(CatalogLink
|
|
549
|
+
return vue.createVNode(CatalogLink, {
|
|
551
550
|
"mdHeadingId": props2.mdHeadingId,
|
|
552
551
|
"tocItem": item,
|
|
553
552
|
"key": `link-${item.level}-${item.text}`,
|