autumnnote 2.5.0 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/autumnnote.cjs +20 -18
- package/dist/autumnnote.core.es.js +736 -662
- package/dist/autumnnote.core.es.js.map +1 -1
- package/dist/autumnnote.css +1 -1
- package/dist/autumnnote.es.js +413 -339
- package/dist/autumnnote.es.js.map +1 -1
- package/dist/autumnnote.min.js +20 -18
- package/dist/autumnnote.umd.js +20 -18
- package/dist/autumnnote.umd.js.map +1 -1
- package/package.json +1 -1
- package/types/core/sanitise.d.ts +7 -0
package/dist/autumnnote.es.js
CHANGED
|
@@ -1459,7 +1459,10 @@ var tn = [
|
|
|
1459
1459
|
"https:",
|
|
1460
1460
|
"blob:"
|
|
1461
1461
|
]), fn = /^data:image\/(?:png|jpe?g|gif|webp|avif|bmp);base64,[a-z0-9+/=\s]+$/i, pn = "https://autumnnote.invalid/";
|
|
1462
|
-
function j(e,
|
|
1462
|
+
function j(e, t) {
|
|
1463
|
+
return mn(e, t).innerHTML;
|
|
1464
|
+
}
|
|
1465
|
+
function mn(e, { allowIframes: t = !1 } = {}) {
|
|
1463
1466
|
let n = new DOMParser().parseFromString(`<body>${e || ""}</body>`, "text/html"), r = Array.from(n.querySelectorAll("*")), i = new Set(t ? tn.filter((e) => e !== "iframe") : tn);
|
|
1464
1467
|
for (let e of r) {
|
|
1465
1468
|
let t = e.tagName.toLowerCase();
|
|
@@ -1473,7 +1476,7 @@ function j(e, { allowIframes: t = !1 } = {}) {
|
|
|
1473
1476
|
}
|
|
1474
1477
|
if (t === "iframe") {
|
|
1475
1478
|
let t = e.getAttribute("src");
|
|
1476
|
-
if (!t || !
|
|
1479
|
+
if (!t || !_n(t)) {
|
|
1477
1480
|
e.remove();
|
|
1478
1481
|
continue;
|
|
1479
1482
|
}
|
|
@@ -1484,7 +1487,7 @@ function j(e, { allowIframes: t = !1 } = {}) {
|
|
|
1484
1487
|
continue;
|
|
1485
1488
|
}
|
|
1486
1489
|
if (t.name === "style") {
|
|
1487
|
-
let n =
|
|
1490
|
+
let n = hn(t.value);
|
|
1488
1491
|
n ? e.setAttribute("style", n) : e.removeAttribute("style");
|
|
1489
1492
|
continue;
|
|
1490
1493
|
}
|
|
@@ -1499,7 +1502,7 @@ function j(e, { allowIframes: t = !1 } = {}) {
|
|
|
1499
1502
|
"AUDIO",
|
|
1500
1503
|
"SOURCE"
|
|
1501
1504
|
].includes(e.tagName), i = e.tagName === "IMG";
|
|
1502
|
-
if (!(t.name === "srcset" ?
|
|
1505
|
+
if (!(t.name === "srcset" ? gn(n, { allowData: i }) : vn(n, {
|
|
1503
1506
|
media: r,
|
|
1504
1507
|
allowData: i
|
|
1505
1508
|
}))) {
|
|
@@ -1512,7 +1515,7 @@ function j(e, { allowIframes: t = !1 } = {}) {
|
|
|
1512
1515
|
e.removeAttribute(t.name);
|
|
1513
1516
|
continue;
|
|
1514
1517
|
}
|
|
1515
|
-
t.name === "src" && !
|
|
1518
|
+
t.name === "src" && !_n(t.value) && e.removeAttribute(t.name);
|
|
1516
1519
|
}
|
|
1517
1520
|
}
|
|
1518
1521
|
if (t === "a" && e.getAttribute("target") === "_blank" && e.setAttribute("rel", "noopener noreferrer"), t === "input") if (!(e.closest("ul.an-checklist") !== null && e.closest("li") !== null) || e.getAttribute("type") !== "checkbox") e.remove();
|
|
@@ -1522,9 +1525,9 @@ function j(e, { allowIframes: t = !1 } = {}) {
|
|
|
1522
1525
|
"contenteditable"
|
|
1523
1526
|
].includes(t.name) || e.removeAttribute(t.name);
|
|
1524
1527
|
}
|
|
1525
|
-
return n.body
|
|
1528
|
+
return n.body;
|
|
1526
1529
|
}
|
|
1527
|
-
function
|
|
1530
|
+
function hn(e) {
|
|
1528
1531
|
let t = [];
|
|
1529
1532
|
for (let n of (e || "").split(";")) {
|
|
1530
1533
|
let e = n.indexOf(":");
|
|
@@ -1534,19 +1537,19 @@ function mn(e) {
|
|
|
1534
1537
|
}
|
|
1535
1538
|
return t.join("; ");
|
|
1536
1539
|
}
|
|
1537
|
-
function
|
|
1540
|
+
function gn(e, { allowData: t = !1 } = {}) {
|
|
1538
1541
|
let n = (e || "").trim().split(/\s+/).filter(Boolean);
|
|
1539
1542
|
for (let e of n) {
|
|
1540
1543
|
if (/^[\d.]+[xw],?$/i.test(e)) continue;
|
|
1541
1544
|
let n = e.replace(/,+$/, "");
|
|
1542
|
-
if (n && !
|
|
1545
|
+
if (n && !vn(n, {
|
|
1543
1546
|
media: !0,
|
|
1544
1547
|
allowData: t
|
|
1545
1548
|
})) return !1;
|
|
1546
1549
|
}
|
|
1547
1550
|
return !0;
|
|
1548
1551
|
}
|
|
1549
|
-
function
|
|
1552
|
+
function _n(e) {
|
|
1550
1553
|
let t = (e || "").trim();
|
|
1551
1554
|
if (!t || t.startsWith("//") || t.startsWith("/")) return !1;
|
|
1552
1555
|
try {
|
|
@@ -1558,12 +1561,12 @@ function gn(e) {
|
|
|
1558
1561
|
}
|
|
1559
1562
|
function M(e, { allowData: t = !1, media: n = t } = {}) {
|
|
1560
1563
|
let r = (e || "").trim();
|
|
1561
|
-
return !r && e == null ? null :
|
|
1564
|
+
return !r && e == null ? null : vn(r, {
|
|
1562
1565
|
media: n,
|
|
1563
1566
|
allowData: t
|
|
1564
1567
|
}) ? e : null;
|
|
1565
1568
|
}
|
|
1566
|
-
function
|
|
1569
|
+
function vn(e, { media: t = !1, allowData: n = !1 } = {}) {
|
|
1567
1570
|
let r = (e || "").trim();
|
|
1568
1571
|
if (!r || n && fn.test(r)) return !0;
|
|
1569
1572
|
try {
|
|
@@ -1575,7 +1578,7 @@ function _n(e, { media: t = !1, allowData: n = !1 } = {}) {
|
|
|
1575
1578
|
}
|
|
1576
1579
|
//#endregion
|
|
1577
1580
|
//#region src/js/renderer.js
|
|
1578
|
-
function
|
|
1581
|
+
function yn(e, t) {
|
|
1579
1582
|
let n = w("div", { class: "an-container" }), r = w("div", {
|
|
1580
1583
|
class: "an-editable",
|
|
1581
1584
|
contenteditable: t.readOnly ? "false" : "true",
|
|
@@ -1598,16 +1601,16 @@ function vn(e, t) {
|
|
|
1598
1601
|
}
|
|
1599
1602
|
//#endregion
|
|
1600
1603
|
//#region src/js/Context.js
|
|
1601
|
-
var
|
|
1602
|
-
function
|
|
1603
|
-
|
|
1604
|
+
var bn = /* @__PURE__ */ new Map(), xn = [];
|
|
1605
|
+
function Sn(e) {
|
|
1606
|
+
xn = Array.isArray(e) ? e : [];
|
|
1604
1607
|
}
|
|
1605
|
-
var
|
|
1608
|
+
var Cn = /* @__PURE__ */ new Map(), wn = class {
|
|
1606
1609
|
constructor(e, t = {}) {
|
|
1607
1610
|
this.targetEl = e, this.options = c(k, t), this.locale = en(this.options.lang), this.layoutInfo = {}, this._listeners = /* @__PURE__ */ new Map(), this._modules = /* @__PURE__ */ new Map(), this._plugins = /* @__PURE__ */ new Map(), this._disposers = [], this._alive = !1, this._autoSaveTimer = null, this._pendingAutoSave = null, this._suppressedRemoteHTML = null, this._destroyPromise = null;
|
|
1608
1611
|
}
|
|
1609
1612
|
initialize() {
|
|
1610
|
-
let { container: e, editable: t } =
|
|
1613
|
+
let { container: e, editable: t } = yn(this.targetEl, this.options);
|
|
1611
1614
|
this.layoutInfo.container = e, this.layoutInfo.editable = t, this._registerModules();
|
|
1612
1615
|
let n = this._modules.get("toolbar");
|
|
1613
1616
|
n?.el && (e.insertBefore(n.el, t), this.layoutInfo.toolbar = n.el);
|
|
@@ -1619,11 +1622,11 @@ var Sn = /* @__PURE__ */ new Map(), Cn = class {
|
|
|
1619
1622
|
let n = new t(this);
|
|
1620
1623
|
this._modules.set(e, n), n.initialize();
|
|
1621
1624
|
};
|
|
1622
|
-
for (let { name: t, Class: n, enabled: r } of
|
|
1623
|
-
if (
|
|
1625
|
+
for (let { name: t, Class: n, enabled: r } of xn) typeof r == "function" && !r(this.options) || e(t, n);
|
|
1626
|
+
if (bn.size > 0) for (let [t, n] of bn) e(t, n);
|
|
1624
1627
|
}
|
|
1625
1628
|
_syncOptionalModules() {
|
|
1626
|
-
for (let { name: e, Class: t, enabled: n } of
|
|
1629
|
+
for (let { name: e, Class: t, enabled: n } of xn) {
|
|
1627
1630
|
if (typeof n != "function") continue;
|
|
1628
1631
|
let r = n(this.options);
|
|
1629
1632
|
if (r !== this._modules.has(e)) if (r) {
|
|
@@ -1668,7 +1671,7 @@ var Sn = /* @__PURE__ */ new Map(), Cn = class {
|
|
|
1668
1671
|
});
|
|
1669
1672
|
}
|
|
1670
1673
|
_applyGlobalPlugins() {
|
|
1671
|
-
if (
|
|
1674
|
+
if (Cn.size !== 0) for (let { plugin: e, options: t } of Cn.values()) this._installPlugin(e, t);
|
|
1672
1675
|
}
|
|
1673
1676
|
_bindEditorEvents(e) {
|
|
1674
1677
|
let t = E(e, "input", () => this._syncToTarget()), n = E(e, "focus", () => {
|
|
@@ -1921,7 +1924,7 @@ var Sn = /* @__PURE__ */ new Map(), Cn = class {
|
|
|
1921
1924
|
_syncToTarget(e) {
|
|
1922
1925
|
(this.targetEl.tagName === "TEXTAREA" || this.targetEl.tagName === "INPUT") && (this.targetEl.value = typeof e == "string" ? e : this.getHTML());
|
|
1923
1926
|
}
|
|
1924
|
-
},
|
|
1927
|
+
}, Tn = class {
|
|
1925
1928
|
constructor(e, t = 100, n = 10 * 1024 * 1024) {
|
|
1926
1929
|
this.editable = e, this._limit = t, this._maxBytes = n, this._bytes = 0, this.stack = [], this.stackOffset = -1, this._savePoint();
|
|
1927
1930
|
}
|
|
@@ -2042,7 +2045,7 @@ var Sn = /* @__PURE__ */ new Map(), Cn = class {
|
|
|
2042
2045
|
};
|
|
2043
2046
|
//#endregion
|
|
2044
2047
|
//#region src/js/editing/Table.js
|
|
2045
|
-
function
|
|
2048
|
+
function En(e, t, n = {}) {
|
|
2046
2049
|
let { headerRow: r = !1 } = n, i = w("table", { class: "an-table" });
|
|
2047
2050
|
if (r && t > 0) {
|
|
2048
2051
|
let t = w("thead"), n = w("tr");
|
|
@@ -2064,9 +2067,9 @@ function Tn(e, t, n = {}) {
|
|
|
2064
2067
|
}
|
|
2065
2068
|
return i;
|
|
2066
2069
|
}
|
|
2067
|
-
function
|
|
2070
|
+
function Dn(e, t, n = {}) {
|
|
2068
2071
|
if (e <= 0 || t <= 0) return;
|
|
2069
|
-
let r =
|
|
2072
|
+
let r = En(e, t, n), i = globalThis.getSelection();
|
|
2070
2073
|
if (!i || i.rangeCount === 0) return;
|
|
2071
2074
|
let a = i.getRangeAt(0);
|
|
2072
2075
|
try {
|
|
@@ -2154,8 +2157,8 @@ function F(e, t) {
|
|
|
2154
2157
|
}
|
|
2155
2158
|
//#endregion
|
|
2156
2159
|
//#region src/js/editing/Typing.js
|
|
2157
|
-
var
|
|
2158
|
-
function
|
|
2160
|
+
var On = /\bfa-/, I = (e) => !!(e?.nodeName === "I" && On.test(e.className || "")), kn = (e) => e?.nodeType === Node.TEXT_NODE && (e.textContent === "" || e.textContent === "");
|
|
2161
|
+
function An(e, t) {
|
|
2159
2162
|
try {
|
|
2160
2163
|
let n = document.createRange();
|
|
2161
2164
|
return n.setStart(e.startContainer, e.startOffset), n.setEnd(t, t.childNodes.length), n.extractContents();
|
|
@@ -2163,7 +2166,7 @@ function kn(e, t) {
|
|
|
2163
2166
|
return document.createDocumentFragment();
|
|
2164
2167
|
}
|
|
2165
2168
|
}
|
|
2166
|
-
function
|
|
2169
|
+
function jn(e, t, n = {}) {
|
|
2167
2170
|
let r = (e) => {
|
|
2168
2171
|
let t = globalThis.getSelection();
|
|
2169
2172
|
if (!t) return !1;
|
|
@@ -2197,7 +2200,7 @@ function An(e, t, n = {}) {
|
|
|
2197
2200
|
if (i.nodeType === Node.TEXT_NODE) {
|
|
2198
2201
|
let t = i;
|
|
2199
2202
|
if (a && n.startOffset === 1 && t.textContent === "" && I(t.previousSibling) || a && n.startOffset === 0 && I(t.previousSibling)) return e.preventDefault(), r((e) => e.setStartBefore(t.previousSibling));
|
|
2200
|
-
if (a && n.startOffset === 0 &&
|
|
2203
|
+
if (a && n.startOffset === 0 && kn(t.previousSibling) && I(t.previousSibling.previousSibling)) return e.preventDefault(), r((e) => e.setStartBefore(t.previousSibling.previousSibling));
|
|
2201
2204
|
if (!a && n.startOffset === t.textContent.length && I(t.nextSibling)) {
|
|
2202
2205
|
let n = t.nextSibling, i = n.nextSibling;
|
|
2203
2206
|
if (e.preventDefault(), i?.nodeType === Node.TEXT_NODE) {
|
|
@@ -2206,7 +2209,7 @@ function An(e, t, n = {}) {
|
|
|
2206
2209
|
}
|
|
2207
2210
|
return r((e) => e.setStartAfter(n));
|
|
2208
2211
|
}
|
|
2209
|
-
if (!a && n.startOffset === t.textContent.length &&
|
|
2212
|
+
if (!a && n.startOffset === t.textContent.length && kn(t.nextSibling) && I(t.nextSibling.nextSibling)) {
|
|
2210
2213
|
let n = t.nextSibling.nextSibling, i = n.nextSibling;
|
|
2211
2214
|
if (e.preventDefault(), i?.nodeType === Node.TEXT_NODE) {
|
|
2212
2215
|
let e = +!!(i.textContent || "").startsWith("");
|
|
@@ -2220,7 +2223,7 @@ function An(e, t, n = {}) {
|
|
|
2220
2223
|
if (a && n.startOffset > 0) {
|
|
2221
2224
|
let i = t.childNodes[n.startOffset - 1];
|
|
2222
2225
|
if (I(i)) return e.preventDefault(), r((e) => e.setStartBefore(i));
|
|
2223
|
-
if (
|
|
2226
|
+
if (kn(i) && I(i.previousSibling)) return e.preventDefault(), r((e) => e.setStartBefore(i.previousSibling));
|
|
2224
2227
|
}
|
|
2225
2228
|
if (!a && n.startOffset < t.childNodes.length) {
|
|
2226
2229
|
let i = t.childNodes[n.startOffset];
|
|
@@ -2232,7 +2235,7 @@ function An(e, t, n = {}) {
|
|
|
2232
2235
|
}
|
|
2233
2236
|
return r((e) => e.setStartAfter(i));
|
|
2234
2237
|
}
|
|
2235
|
-
if (
|
|
2238
|
+
if (kn(i) && I(i.nextSibling)) {
|
|
2236
2239
|
let t = i.nextSibling, n = t.nextSibling;
|
|
2237
2240
|
if (e.preventDefault(), n?.nodeType === Node.TEXT_NODE) {
|
|
2238
2241
|
let e = +!!(n.textContent || "").startsWith("");
|
|
@@ -2286,7 +2289,7 @@ function An(e, t, n = {}) {
|
|
|
2286
2289
|
if (r.deleteContents(), n.rangeCount === 0 || !o.isConnected) return !0;
|
|
2287
2290
|
r = n.getRangeAt(0);
|
|
2288
2291
|
}
|
|
2289
|
-
let i =
|
|
2292
|
+
let i = An(r, o), a = document.createElement("li"), s = document.createElement("input");
|
|
2290
2293
|
s.type = "checkbox", s.setAttribute("contenteditable", "false"), a.appendChild(s), i.textContent.replace(/[\u00a0\u200B]/g, "").length > 0 && a.appendChild(i);
|
|
2291
2294
|
let c = a.childNodes[1];
|
|
2292
2295
|
c?.nodeType !== Node.TEXT_NODE && (c = document.createTextNode(""), a.appendChild(c)), o.after(a);
|
|
@@ -2304,13 +2307,13 @@ function An(e, t, n = {}) {
|
|
|
2304
2307
|
}
|
|
2305
2308
|
//#endregion
|
|
2306
2309
|
//#region src/js/core/markdown.js
|
|
2307
|
-
function
|
|
2308
|
-
return
|
|
2310
|
+
function Mn(e) {
|
|
2311
|
+
return Bn(new DOMParser().parseFromString(`<body>${e || ""}</body>`, "text/html").body).replace(/\n{3,}/g, "\n\n").trim();
|
|
2309
2312
|
}
|
|
2310
|
-
function
|
|
2313
|
+
function Nn(e, t) {
|
|
2311
2314
|
return Array.from(e.children).filter((e) => e.tagName === t.toUpperCase());
|
|
2312
2315
|
}
|
|
2313
|
-
function
|
|
2316
|
+
function Pn(e) {
|
|
2314
2317
|
let t = "";
|
|
2315
2318
|
for (let n of e.childNodes) {
|
|
2316
2319
|
if (n.nodeType === 3) {
|
|
@@ -2324,40 +2327,40 @@ function Nn(e) {
|
|
|
2324
2327
|
continue;
|
|
2325
2328
|
}
|
|
2326
2329
|
if (e === "div" || e === "p") {
|
|
2327
|
-
t && !t.endsWith("\n") && (t += "\n"), t +=
|
|
2330
|
+
t && !t.endsWith("\n") && (t += "\n"), t += Pn(n), t += "\n";
|
|
2328
2331
|
continue;
|
|
2329
2332
|
}
|
|
2330
|
-
t +=
|
|
2333
|
+
t += Pn(n);
|
|
2331
2334
|
}
|
|
2332
2335
|
return t;
|
|
2333
2336
|
}
|
|
2334
|
-
function
|
|
2337
|
+
function Fn(e) {
|
|
2335
2338
|
return e.replaceAll("\\", "\\\\").replace(/&(?=#\d+;|#[xX][0-9a-fA-F]+;|[a-zA-Z][a-zA-Z0-9]*;)/g, "&").replace(/!(?=\[)/g, String.raw`\!`).replace(/([`*[\]])/g, String.raw`\$1`).replace(/(?<!\w)_|_(?!\w)/g, String.raw`\_`).replace(/~(?=~)|(?<=~)~/g, String.raw`\~`);
|
|
2336
2339
|
}
|
|
2337
|
-
function
|
|
2340
|
+
function In(e) {
|
|
2338
2341
|
return /^\s*(?:-{2,}|={2,}|\*{3,}|_{3,}|(?:[-*_] +){2,}[-*_])\s*$/.test(e) ? e.replace(/[-=*_]/, (e) => `\\${e}`) : e.replace(/^(\s*)(#{1,6})(?=\s|$)/, (e, t, n) => `${t}\\${n}`).replace(/^(\s*)>/, (e, t) => `${t}\\>`).replace(/^(\s*)([-*+])(?=\s)/, (e, t, n) => `${t}\\${n}`).replace(/^(\s*)(\d+)([.)])(?=\s)/, (e, t, n, r) => `${t}${n}\\${r}`);
|
|
2339
2342
|
}
|
|
2340
|
-
function
|
|
2341
|
-
return e.split("\n").map(
|
|
2343
|
+
function Ln(e) {
|
|
2344
|
+
return e.split("\n").map(In).join("\n");
|
|
2342
2345
|
}
|
|
2343
|
-
function
|
|
2346
|
+
function Rn(e, t) {
|
|
2344
2347
|
let n = " ".repeat(t + 1);
|
|
2345
|
-
return
|
|
2348
|
+
return Bn(e, t + 1).trim().split("\n").map((e, t) => t === 0 || e.trim() === "" || e.startsWith(n) ? e : n + e).join("\n");
|
|
2346
2349
|
}
|
|
2347
|
-
function
|
|
2350
|
+
function zn(e, t) {
|
|
2348
2351
|
let n = e.getAttribute(t) || "", r = /[\s()]/.test(n) ? `<${n}>` : n, i = e.getAttribute("title");
|
|
2349
2352
|
return i ? `${r} "${i.replaceAll("\"", String.raw`\"`)}"` : r;
|
|
2350
2353
|
}
|
|
2351
|
-
function
|
|
2354
|
+
function Bn(e, t = 0) {
|
|
2352
2355
|
if (e.nodeType === 3) {
|
|
2353
2356
|
let t = e.textContent.replace(/\s+/g, " ");
|
|
2354
|
-
return e.parentElement?.closest("pre, code") ? t :
|
|
2357
|
+
return e.parentElement?.closest("pre, code") ? t : Fn(t);
|
|
2355
2358
|
}
|
|
2356
2359
|
if (e.nodeType !== 1) return "";
|
|
2357
|
-
let n = e, r = n.nodeName.toLowerCase(), i = () => Array.from(n.childNodes).map((e) =>
|
|
2360
|
+
let n = e, r = n.nodeName.toLowerCase(), i = () => Array.from(n.childNodes).map((e) => Bn(e, t)).join("");
|
|
2358
2361
|
switch (r) {
|
|
2359
2362
|
case "p":
|
|
2360
|
-
case "div": return `\n\n${
|
|
2363
|
+
case "div": return `\n\n${Ln(i())}\n\n`;
|
|
2361
2364
|
case "br": return " \n";
|
|
2362
2365
|
case "h1": return `\n\n# ${i()}\n\n`;
|
|
2363
2366
|
case "h2": return `\n\n## ${i()}\n\n`;
|
|
@@ -2386,27 +2389,27 @@ function zn(e, t = 0) {
|
|
|
2386
2389
|
}
|
|
2387
2390
|
case "pre": {
|
|
2388
2391
|
let e = n.querySelector("code"), t = /language-(\S+)/.exec(e?.className || "");
|
|
2389
|
-
return `\n\n\`\`\`${t ? t[1] : ""}\n${
|
|
2392
|
+
return `\n\n\`\`\`${t ? t[1] : ""}\n${Pn(e || n).replace(/\n$/, "")}\n\`\`\`\n\n`;
|
|
2390
2393
|
}
|
|
2391
2394
|
case "blockquote": {
|
|
2392
2395
|
let e = i().trim().split("\n");
|
|
2393
2396
|
return `\n\n${e.filter((t, n) => t.trim() !== "" || (e[n - 1] ?? "").trim() !== "").map((e) => e.trim() === "" ? ">" : `> ${e}`).join("\n")}\n\n`;
|
|
2394
2397
|
}
|
|
2395
|
-
case "a": return `[${i()}](${
|
|
2396
|
-
case "img": return `})`;
|
|
2399
|
+
case "img": return `})`;
|
|
2397
2400
|
case "ul": {
|
|
2398
|
-
let e =
|
|
2401
|
+
let e = Nn(n, "li");
|
|
2399
2402
|
if (!e.length) return i();
|
|
2400
2403
|
let r = " ".repeat(t), a = n.classList.contains("an-checklist"), o = e.map((e) => {
|
|
2401
|
-
let n =
|
|
2402
|
-
return (a || n) && (i = n && n.checked ? "- [x] " : "- [ ] "), `${r}${i}${
|
|
2404
|
+
let n = Nn(e, "input").find((e) => e.getAttribute("type") === "checkbox"), i = "- ";
|
|
2405
|
+
return (a || n) && (i = n && n.checked ? "- [x] " : "- [ ] "), `${r}${i}${Rn(e, t)}`;
|
|
2403
2406
|
}).join("\n");
|
|
2404
2407
|
return t === 0 ? `\n\n${o}\n\n` : `\n${o}`;
|
|
2405
2408
|
}
|
|
2406
2409
|
case "ol": {
|
|
2407
|
-
let e =
|
|
2410
|
+
let e = Nn(n, "li");
|
|
2408
2411
|
if (!e.length) return i();
|
|
2409
|
-
let r = " ".repeat(t), a = Number.parseInt(n.getAttribute("start") || "1", 10), o = Number.isFinite(a) ? a : 1, s = e.map((e, n) => `${r}${o + n}. ${
|
|
2412
|
+
let r = " ".repeat(t), a = Number.parseInt(n.getAttribute("start") || "1", 10), o = Number.isFinite(a) ? a : 1, s = e.map((e, n) => `${r}${o + n}. ${Rn(e, t)}`).join("\n");
|
|
2410
2413
|
return t === 0 ? `\n\n${s}\n\n` : `\n${s}`;
|
|
2411
2414
|
}
|
|
2412
2415
|
case "li": return i();
|
|
@@ -2414,7 +2417,7 @@ function zn(e, t = 0) {
|
|
|
2414
2417
|
case "table": {
|
|
2415
2418
|
let e = Array.from(n.querySelectorAll("tr"));
|
|
2416
2419
|
if (!e.length) return i();
|
|
2417
|
-
let t = !!
|
|
2420
|
+
let t = !!Nn(n, "thead")[0] || e[0].children.length > 0 && Array.from(e[0].children).every((e) => e.tagName === "TH"), r = e.map((e) => Array.from(e.querySelectorAll("th, td")).map((e) => Fn(e.textContent.trim()).replaceAll("|", String.raw`\|`))), a = Math.max(...r.map((e) => e.length)), o = (e) => {
|
|
2418
2421
|
let t = [...e];
|
|
2419
2422
|
for (; t.length < a;) t.push("");
|
|
2420
2423
|
return t;
|
|
@@ -2429,16 +2432,16 @@ function zn(e, t = 0) {
|
|
|
2429
2432
|
default: return i();
|
|
2430
2433
|
}
|
|
2431
2434
|
}
|
|
2432
|
-
function
|
|
2435
|
+
function Vn(e) {
|
|
2433
2436
|
return String(e ?? "").replace(/^\ufeff/, "");
|
|
2434
2437
|
}
|
|
2435
|
-
function
|
|
2436
|
-
let t =
|
|
2438
|
+
function Hn(e) {
|
|
2439
|
+
let t = Vn(e);
|
|
2437
2440
|
return /^#{1,6} [^\s]|^[ \t]*[-*+] [^\s]|^[ \t]*\d+[.)] [^\s]|^> ?[^\s]|^ {0,3}(?:`{3,}|~{3,})|^\*{2}[^*\n]+\*{2}/m.test(t) || /^.+\n=+\s*$/m.test(t) || /^.+\n-{2,}\s*$/m.test(t) || /^---[ \t]*\n(?:[\s\S]*?\n)?(?:---|\.\.\.)[ \t]*(?:\n|$)/.test(t) || /^\|.+\|[ \t]*\n\|[ \t:|-]+\|/m.test(t) || /^[^\n|]*\|[^\n]*\n[ \t]*:?-+:?[ \t]*(?:\|[ \t]*:?-+:?[ \t]*)+$/m.test(t) || /!?\[[^\]\n]*\]\([^)\n]*\)/.test(t) && /`[^`\n]+`|\*\*[^*\n]+\*\*|^#{1,6} |^[-*+] /m.test(t);
|
|
2438
2441
|
}
|
|
2439
|
-
var
|
|
2440
|
-
function
|
|
2441
|
-
let t =
|
|
2442
|
+
var Un = /^ {0,3}>( ?)(.*)$/, Wn = /^(?: {4}|\t)\s*\S/, Gn = /^( {0,3})(`{3,}|~{3,})[ \t]*([^\s`~][^\n]*)?$/;
|
|
2443
|
+
function Kn(e) {
|
|
2444
|
+
let t = Gn.exec(e);
|
|
2442
2445
|
if (!t) return null;
|
|
2443
2446
|
let [, n, r, i = ""] = t;
|
|
2444
2447
|
return r[0] === "`" && i.includes("`") ? null : {
|
|
@@ -2448,7 +2451,7 @@ function Gn(e) {
|
|
|
2448
2451
|
lang: i.trim().split(/\s+/)[0] || ""
|
|
2449
2452
|
};
|
|
2450
2453
|
}
|
|
2451
|
-
function
|
|
2454
|
+
function qn(e, t) {
|
|
2452
2455
|
let n = 0, r = 0;
|
|
2453
2456
|
for (; r < e.length && n < t;) {
|
|
2454
2457
|
if (e[r] === " ") {
|
|
@@ -2465,40 +2468,40 @@ function Kn(e, t) {
|
|
|
2465
2468
|
}
|
|
2466
2469
|
return e.slice(r);
|
|
2467
2470
|
}
|
|
2468
|
-
var
|
|
2469
|
-
function Yn(e) {
|
|
2470
|
-
let t = Bn(e).replaceAll("\r\n", "\n").replaceAll("\r", "\n").split("\n");
|
|
2471
|
-
t = $n(t);
|
|
2472
|
-
let n = er(t);
|
|
2473
|
-
return t = n.clean, Zn = n.linkDefs, Qn = n.footnoteIds, Xn(t);
|
|
2474
|
-
}
|
|
2471
|
+
var Jn = /^ {0,3}([-*_])( *\1){2,}\s*$/, Yn = "";
|
|
2475
2472
|
function Xn(e) {
|
|
2473
|
+
let t = Vn(e).replaceAll("\r\n", "\n").replaceAll("\r", "\n").split("\n");
|
|
2474
|
+
t = er(t);
|
|
2475
|
+
let n = tr(t);
|
|
2476
|
+
return t = n.clean, Qn = n.linkDefs, $n = n.footnoteIds, Zn(t);
|
|
2477
|
+
}
|
|
2478
|
+
function Zn(e) {
|
|
2476
2479
|
let t = [], n = 0;
|
|
2477
2480
|
for (; n < e.length;) {
|
|
2478
|
-
let r = e[n], i =
|
|
2481
|
+
let r = e[n], i = Kn(r);
|
|
2479
2482
|
if (i) {
|
|
2480
2483
|
let r = RegExp(`^ {0,3}\\${i.marker}{${i.length},}[ \t]*$`), a = [];
|
|
2481
|
-
for (n++; n < e.length && !r.test(e[n]);) a.push(
|
|
2484
|
+
for (n++; n < e.length && !r.test(e[n]);) a.push(Cr(qn(e[n], i.indent))), n++;
|
|
2482
2485
|
let o = i.lang ? ` class="language-${z(i.lang)}"` : "";
|
|
2483
2486
|
t.push(`<pre><code${o}>${a.join("\n")}</code></pre>`), n++;
|
|
2484
2487
|
continue;
|
|
2485
2488
|
}
|
|
2486
|
-
if (
|
|
2489
|
+
if (Wn.test(r)) {
|
|
2487
2490
|
let r = [];
|
|
2488
|
-
for (; n < e.length && (
|
|
2491
|
+
for (; n < e.length && (Wn.test(e[n]) || e[n].trim() === "");) {
|
|
2489
2492
|
if (e[n].trim() === "") {
|
|
2490
2493
|
let t = n;
|
|
2491
2494
|
for (; t < e.length && e[t].trim() === "";) t++;
|
|
2492
|
-
if (t >= e.length || !
|
|
2495
|
+
if (t >= e.length || !Wn.test(e[t])) break;
|
|
2493
2496
|
for (; n < t; n++) r.push("");
|
|
2494
2497
|
continue;
|
|
2495
2498
|
}
|
|
2496
|
-
r.push(
|
|
2499
|
+
r.push(Cr(qn(e[n], 4))), n++;
|
|
2497
2500
|
}
|
|
2498
2501
|
t.push(`<pre><code>${r.join("\n")}</code></pre>`);
|
|
2499
2502
|
continue;
|
|
2500
2503
|
}
|
|
2501
|
-
if (r.trim() && !
|
|
2504
|
+
if (r.trim() && !Jn.test(r) && !/^#{1,6} /.test(r) && n + 1 < e.length) {
|
|
2502
2505
|
if (/^=+\s*$/.test(e[n + 1])) {
|
|
2503
2506
|
t.push(`<h1>${R(r.trim())}</h1>`), n += 2;
|
|
2504
2507
|
continue;
|
|
@@ -2508,7 +2511,7 @@ function Xn(e) {
|
|
|
2508
2511
|
continue;
|
|
2509
2512
|
}
|
|
2510
2513
|
}
|
|
2511
|
-
if (
|
|
2514
|
+
if (Jn.test(r)) {
|
|
2512
2515
|
t.push("<hr>"), n++;
|
|
2513
2516
|
continue;
|
|
2514
2517
|
}
|
|
@@ -2518,19 +2521,19 @@ function Xn(e) {
|
|
|
2518
2521
|
t.push(`<h${e}>${R(r)}</h${e}>`), n++;
|
|
2519
2522
|
continue;
|
|
2520
2523
|
}
|
|
2521
|
-
if (
|
|
2524
|
+
if (Un.test(r)) {
|
|
2522
2525
|
let r = [];
|
|
2523
|
-
for (; n < e.length &&
|
|
2524
|
-
t.push(`<blockquote>${
|
|
2526
|
+
for (; n < e.length && Un.test(e[n]);) r.push(Un.exec(e[n])[2]), n++;
|
|
2527
|
+
t.push(`<blockquote>${Zn(r)}</blockquote>`);
|
|
2525
2528
|
continue;
|
|
2526
2529
|
}
|
|
2527
2530
|
if (/^[-*+] /.test(r)) {
|
|
2528
|
-
let { html: r, endIdx: i } =
|
|
2531
|
+
let { html: r, endIdx: i } = or(e, n);
|
|
2529
2532
|
t.push(r), n = i;
|
|
2530
2533
|
continue;
|
|
2531
2534
|
}
|
|
2532
2535
|
if (/^\d+[.)] /.test(r)) {
|
|
2533
|
-
let { html: r, endIdx: i } =
|
|
2536
|
+
let { html: r, endIdx: i } = or(e, n);
|
|
2534
2537
|
t.push(r), n = i;
|
|
2535
2538
|
continue;
|
|
2536
2539
|
}
|
|
@@ -2538,23 +2541,23 @@ function Xn(e) {
|
|
|
2538
2541
|
n++;
|
|
2539
2542
|
continue;
|
|
2540
2543
|
}
|
|
2541
|
-
if (
|
|
2542
|
-
let i =
|
|
2544
|
+
if (ir(e, n)) {
|
|
2545
|
+
let i = ar(r), a = ar(e[n + 1]).map((e) => e.startsWith(":") && e.endsWith(":") ? "center" : e.endsWith(":") ? "right" : e.startsWith(":") ? "left" : null);
|
|
2543
2546
|
n += 2;
|
|
2544
2547
|
let o = [];
|
|
2545
|
-
for (; n < e.length && e[n].trim() !== "" &&
|
|
2548
|
+
for (; n < e.length && e[n].trim() !== "" && rr(e[n]) > 1;) o.push(ar(e[n])), n++;
|
|
2546
2549
|
let s = (e, t, n) => `<${e}${n ? ` style="text-align:${n}"` : ""}>${R(t)}</${e}>`, c = `<thead><tr>${i.map((e, t) => s("th", e, a[t])).join("")}</tr></thead>`, l = o.length ? `<tbody>${o.map((e) => `<tr>${e.map((e, t) => s("td", e, a[t])).join("")}</tr>`).join("")}</tbody>` : "";
|
|
2547
2550
|
t.push(`<table>${c}${l}</table>`);
|
|
2548
2551
|
continue;
|
|
2549
2552
|
}
|
|
2550
2553
|
let o = [];
|
|
2551
|
-
for (; n < e.length && e[n].trim() !== "" && !/^(#{1,6} |[-*+] |\d+[.)] )/.test(e[n]) && !
|
|
2552
|
-
o.length ? t.push(`<p>${R(
|
|
2554
|
+
for (; n < e.length && e[n].trim() !== "" && !/^(#{1,6} |[-*+] |\d+[.)] )/.test(e[n]) && !Kn(e[n]) && !Un.test(e[n]) && !Jn.test(e[n]) && !ir(e, n) && !(n + 1 < e.length && /^=+\s*$/.test(e[n + 1])) && !(n + 1 < e.length && /^-{2,}\s*$/.test(e[n + 1]));) o.push(e[n]), n++;
|
|
2555
|
+
o.length ? t.push(`<p>${R(nr(o)).replaceAll(Yn, "<br>")}</p>`) : (t.push(`<p>${R(r)}</p>`), n++);
|
|
2553
2556
|
}
|
|
2554
2557
|
return t.join("");
|
|
2555
2558
|
}
|
|
2556
|
-
var
|
|
2557
|
-
function
|
|
2559
|
+
var Qn = /* @__PURE__ */ new Map(), $n = /* @__PURE__ */ new Set();
|
|
2560
|
+
function er(e) {
|
|
2558
2561
|
if ((e[0] || "").trim() !== "---") return e;
|
|
2559
2562
|
let t = -1;
|
|
2560
2563
|
for (let n = 1; n < e.length; n++) {
|
|
@@ -2568,14 +2571,14 @@ function $n(e) {
|
|
|
2568
2571
|
let n = t + 1;
|
|
2569
2572
|
return e[n] !== void 0 && e[n].trim() === "" && n++, e.slice(n);
|
|
2570
2573
|
}
|
|
2571
|
-
function
|
|
2574
|
+
function tr(e) {
|
|
2572
2575
|
let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set(), r = [], i = !1, a = /^\[([^\]]+)\]:\s*(\S+)(?:\s+"([^"]*)")?\s*$/, o = /^\[\^([^\]]+)\]:[ \t]*(\S.*)$/;
|
|
2573
2576
|
for (let s of e) {
|
|
2574
2577
|
if (i) {
|
|
2575
2578
|
/^ {0,3}(?:`{3,}|~{3,})[ \t]*$/.test(s) && (i = !1), r.push(s);
|
|
2576
2579
|
continue;
|
|
2577
2580
|
}
|
|
2578
|
-
if (
|
|
2581
|
+
if (Kn(s)) {
|
|
2579
2582
|
i = !0, r.push(s);
|
|
2580
2583
|
continue;
|
|
2581
2584
|
}
|
|
@@ -2602,33 +2605,33 @@ function er(e) {
|
|
|
2602
2605
|
footnoteIds: n
|
|
2603
2606
|
};
|
|
2604
2607
|
}
|
|
2605
|
-
function
|
|
2608
|
+
function nr(e) {
|
|
2606
2609
|
let t = "";
|
|
2607
2610
|
for (let n = 0; n < e.length; n++) {
|
|
2608
2611
|
let r = n === e.length - 1, i = e[n].replace(/^[ \t]+/, "");
|
|
2609
2612
|
if (!r && /\\$/.test(i)) {
|
|
2610
|
-
t += i.replace(/\\$/, "") +
|
|
2613
|
+
t += i.replace(/\\$/, "") + Yn;
|
|
2611
2614
|
continue;
|
|
2612
2615
|
}
|
|
2613
2616
|
if (!r && / {2,}$/.test(i)) {
|
|
2614
|
-
t += i.replace(/ {2,}$/, "") +
|
|
2617
|
+
t += i.replace(/ {2,}$/, "") + Yn;
|
|
2615
2618
|
continue;
|
|
2616
2619
|
}
|
|
2617
2620
|
t += i + (r ? "" : " ");
|
|
2618
2621
|
}
|
|
2619
2622
|
return t;
|
|
2620
2623
|
}
|
|
2621
|
-
function
|
|
2622
|
-
return
|
|
2624
|
+
function rr(e) {
|
|
2625
|
+
return ar(e).length;
|
|
2623
2626
|
}
|
|
2624
|
-
function
|
|
2627
|
+
function ir(e, t) {
|
|
2625
2628
|
let n = e[t], r = e[t + 1];
|
|
2626
2629
|
if (r === void 0 || !n.includes("|")) return !1;
|
|
2627
2630
|
if (/^\|.+\|/.test(n)) return /^\|[\s|:-]+\|/.test(r);
|
|
2628
|
-
let i =
|
|
2629
|
-
return i.length < 2 || !i.every((e) => /^:?-+:?$/.test(e)) ? !1 :
|
|
2631
|
+
let i = ar(r);
|
|
2632
|
+
return i.length < 2 || !i.every((e) => /^:?-+:?$/.test(e)) ? !1 : rr(n) === i.length;
|
|
2630
2633
|
}
|
|
2631
|
-
function
|
|
2634
|
+
function ar(e) {
|
|
2632
2635
|
let t = e.replace(/^\|/, "").replace(/\|$/, ""), n = [], r = "";
|
|
2633
2636
|
for (let e = 0; e < t.length; e++) {
|
|
2634
2637
|
if (t[e] === "\\" && t[e + 1] === "|") {
|
|
@@ -2643,7 +2646,7 @@ function ir(e) {
|
|
|
2643
2646
|
}
|
|
2644
2647
|
return n.push(r), n.map((e) => e.trim());
|
|
2645
2648
|
}
|
|
2646
|
-
function
|
|
2649
|
+
function or(e, t) {
|
|
2647
2650
|
let n = e[t].match(/^(\s*)/)[1].length, r = /^\s*\d+[.)] /.test(e[t]), i = [], a = null, o = !1, s = !1, c = t;
|
|
2648
2651
|
for (; c < e.length;) {
|
|
2649
2652
|
let t = e[c];
|
|
@@ -2671,15 +2674,15 @@ function ar(e, t) {
|
|
|
2671
2674
|
c++;
|
|
2672
2675
|
continue;
|
|
2673
2676
|
}
|
|
2674
|
-
let n = (e) =>
|
|
2677
|
+
let n = (e) => qn(e, l), r = Kn(n(t));
|
|
2675
2678
|
if (r) {
|
|
2676
2679
|
let t = RegExp(`^ {0,3}\\${r.marker}{${r.length},}[ \t]*$`), a = [n(e[c])];
|
|
2677
2680
|
for (c++; c < e.length && !t.test(n(e[c]));) a.push(n(e[c])), c++;
|
|
2678
|
-
c < e.length && (a.push(n(e[c])), c++), i[i.length - 1].sub +=
|
|
2681
|
+
c < e.length && (a.push(n(e[c])), c++), i[i.length - 1].sub += Zn(a), s = !1;
|
|
2679
2682
|
continue;
|
|
2680
2683
|
}
|
|
2681
2684
|
if (/^\s*(?:[-*+]|\d+[.)]) /.test(t)) {
|
|
2682
|
-
let t =
|
|
2685
|
+
let t = or(e, c);
|
|
2683
2686
|
i[i.length - 1].sub += t.html, c = t.endIdx, s = !1;
|
|
2684
2687
|
} else if (s) i[i.length - 1].paras.push(t.trim()), s = !1, c++;
|
|
2685
2688
|
else {
|
|
@@ -2697,32 +2700,32 @@ function ar(e, t) {
|
|
|
2697
2700
|
endIdx: c
|
|
2698
2701
|
};
|
|
2699
2702
|
}
|
|
2700
|
-
var
|
|
2701
|
-
function
|
|
2703
|
+
var sr = /\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g, L = "\0", cr = "", lr = /(`+)([^]*?)\1/g;
|
|
2704
|
+
function ur(e) {
|
|
2702
2705
|
let t = [];
|
|
2703
2706
|
return {
|
|
2704
|
-
text: e.replace(
|
|
2707
|
+
text: e.replace(lr, (e, n, r) => r === "" ? e : (t.push(r), `${cr}${t.length - 1}${cr}`)),
|
|
2705
2708
|
codes: t
|
|
2706
2709
|
};
|
|
2707
2710
|
}
|
|
2708
|
-
function
|
|
2709
|
-
return e.replace(RegExp(`${
|
|
2711
|
+
function dr(e, t, n) {
|
|
2712
|
+
return e.replace(RegExp(`${cr}(\\d+)${cr}`, "g"), (e, r) => {
|
|
2710
2713
|
let i = t[Number(r)];
|
|
2711
|
-
return i = i.replace(RegExp(`${L}(\\d+)${L}`, "g"), (e, t) => `\\${n[Number(t)]}`), i.length > 2 && i.startsWith(" ") && i.endsWith(" ") && i.trim() !== "" && (i = i.slice(1, -1)), `<code>${
|
|
2714
|
+
return i = i.replace(RegExp(`${L}(\\d+)${L}`, "g"), (e, t) => `\\${n[Number(t)]}`), i.length > 2 && i.startsWith(" ") && i.endsWith(" ") && i.trim() !== "" && (i = i.slice(1, -1)), `<code>${Cr(i)}</code>`;
|
|
2712
2715
|
});
|
|
2713
2716
|
}
|
|
2714
|
-
function
|
|
2717
|
+
function fr(e) {
|
|
2715
2718
|
let t = [];
|
|
2716
2719
|
return {
|
|
2717
|
-
text: e.replace(
|
|
2720
|
+
text: e.replace(sr, (e, n) => (t.push(n), `${L}${t.length - 1}${L}`)),
|
|
2718
2721
|
literals: t
|
|
2719
2722
|
};
|
|
2720
2723
|
}
|
|
2721
|
-
function
|
|
2722
|
-
return e.replace(RegExp(`${L}(\\d+)${L}`, "g"), (e, n) =>
|
|
2724
|
+
function pr(e, t) {
|
|
2725
|
+
return e.replace(RegExp(`${L}(\\d+)${L}`, "g"), (e, n) => Sr(t[Number(n)]));
|
|
2723
2726
|
}
|
|
2724
|
-
var
|
|
2725
|
-
function
|
|
2727
|
+
var mr = String.raw`(<.*?>(?:\s+(?:"[^"]*"|'[^']*'))?|[^)]*)`, hr = new RegExp(String.raw`!\[([^\]]*)\]\(${mr}\)`, "g"), gr = new RegExp(String.raw`\[([^\]]+)\]\(${mr}\)`, "g");
|
|
2728
|
+
function _r(e) {
|
|
2726
2729
|
let t = e.trim(), n = /^<([\s\S]*?)>(?:[ \t]*(?:"([^"]*)"|'([^']*)'))?[ \t]*$/.exec(t);
|
|
2727
2730
|
if (n) return {
|
|
2728
2731
|
href: n[1],
|
|
@@ -2737,26 +2740,26 @@ function gr(e) {
|
|
|
2737
2740
|
title: ""
|
|
2738
2741
|
};
|
|
2739
2742
|
}
|
|
2740
|
-
function
|
|
2741
|
-
return e = e.replace(
|
|
2742
|
-
let { href: r, title: i } =
|
|
2743
|
+
function vr(e) {
|
|
2744
|
+
return e = e.replace(hr, (e, t, n) => {
|
|
2745
|
+
let { href: r, title: i } = _r(n), a = i ? ` title="${B(i)}"` : "";
|
|
2743
2746
|
return `<img src="${B(r)}" alt="${B(t)}"${a} class="an-image">`;
|
|
2744
|
-
}), e = e.replace(
|
|
2745
|
-
let { href: r, title: i } =
|
|
2747
|
+
}), e = e.replace(gr, (e, t, n) => {
|
|
2748
|
+
let { href: r, title: i } = _r(n), a = i ? ` title="${B(i)}"` : "";
|
|
2746
2749
|
return `<a href="${B(r)}"${a}>${t}</a>`;
|
|
2747
2750
|
}), e = e.replace(/\[([^\]]+)\]\[([^\]]*)\]/g, (e, t, n) => {
|
|
2748
|
-
let r =
|
|
2751
|
+
let r = Qn.get(wr(n || t).trim().toLowerCase());
|
|
2749
2752
|
if (!r) return e;
|
|
2750
2753
|
let i = r.title ? ` title="${z(r.title)}"` : "";
|
|
2751
2754
|
return `<a href="${z(r.href)}"${i}>${t}</a>`;
|
|
2752
2755
|
}), e = e.replace(/\[([^\]]+)\]/g, (e, t) => {
|
|
2753
|
-
let n =
|
|
2756
|
+
let n = Qn.get(wr(t).trim().toLowerCase());
|
|
2754
2757
|
if (!n) return e;
|
|
2755
2758
|
let r = n.title ? ` title="${z(n.title)}"` : "";
|
|
2756
2759
|
return `<a href="${z(n.href)}"${r}>${t}</a>`;
|
|
2757
|
-
}), e = e.replace(/\[\^([^\]]+)\]/g, (e, t) =>
|
|
2760
|
+
}), e = e.replace(/\[\^([^\]]+)\]/g, (e, t) => $n.has(wr(t)) ? `<sup>[${t}]</sup>` : e), e;
|
|
2758
2761
|
}
|
|
2759
|
-
function
|
|
2762
|
+
function yr(e) {
|
|
2760
2763
|
return e = e.replace(/<(https?:\/\/[^\s&]+?)>/g, (e, t) => `<a href="${B(t)}">${t}</a>`), e = e.replace(/<([\w.!#$%&'*+/=?^`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+)>/g, (e, t) => `<a href="mailto:${B(t)}">${t}</a>`), e = e.replace(/(^|[\s(])(https?:\/\/[^\s()]+)/g, (e, t, n) => {
|
|
2761
2764
|
let r = /[.,;:!?)]+$/.exec(n), i = r ? n.slice(0, -r[0].length) : n;
|
|
2762
2765
|
if (!i) return e;
|
|
@@ -2764,18 +2767,18 @@ function vr(e) {
|
|
|
2764
2767
|
return `${t}<a href="${B(i)}">${i}</a>${a}`;
|
|
2765
2768
|
}), e;
|
|
2766
2769
|
}
|
|
2767
|
-
function
|
|
2770
|
+
function br(e) {
|
|
2768
2771
|
return e = e.replace(/\*{3}([^*\n]+?)\*{3}/g, (e, t) => `<strong><em>${t}</em></strong>`), e = e.replace(/(?<!\w)_{3}([^_\n]+?)_{3}(?!\w)/g, (e, t) => `<strong><em>${t}</em></strong>`), e = e.replace(/\*{2}([^*\n]+?)\*{2}/g, (e, t) => `<strong>${t}</strong>`), e = e.replace(/(?<!\w)_{2}([^_\n]+?)_{2}(?!\w)/g, (e, t) => `<strong>${t}</strong>`), e = e.replace(/\*([^*\n]+?)\*/g, (e, t) => `<em>${t}</em>`), e = e.replace(/(?<!\w)_([^_\n]+?)_(?!\w)/g, (e, t) => `<em>${t}</em>`), e = e.replace(/~~([^~\n]+?)~~/g, (e, t) => `<del>${t}</del>`), e;
|
|
2769
2772
|
}
|
|
2770
2773
|
function R(e) {
|
|
2771
|
-
let { text: t, literals: n } =
|
|
2772
|
-
return a =
|
|
2773
|
-
}
|
|
2774
|
-
var br = /&(?!#\d+;|#[xX][0-9a-fA-F]+;|[a-zA-Z][a-zA-Z0-9]*;)/g;
|
|
2775
|
-
function xr(e) {
|
|
2776
|
-
return String(e).replace(br, "&").replaceAll("<", "<").replaceAll(">", ">");
|
|
2774
|
+
let { text: t, literals: n } = fr(e), { text: r, codes: i } = ur(t), a = Sr(r);
|
|
2775
|
+
return a = vr(a), a = yr(a), a = br(a), dr(pr(a, n), i, n);
|
|
2777
2776
|
}
|
|
2777
|
+
var xr = /&(?!#\d+;|#[xX][0-9a-fA-F]+;|[a-zA-Z][a-zA-Z0-9]*;)/g;
|
|
2778
2778
|
function Sr(e) {
|
|
2779
|
+
return String(e).replace(xr, "&").replaceAll("<", "<").replaceAll(">", ">");
|
|
2780
|
+
}
|
|
2781
|
+
function Cr(e) {
|
|
2779
2782
|
return String(e).replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">");
|
|
2780
2783
|
}
|
|
2781
2784
|
function z(e) {
|
|
@@ -2784,16 +2787,16 @@ function z(e) {
|
|
|
2784
2787
|
function B(e) {
|
|
2785
2788
|
return String(e).replaceAll("\"", """).replaceAll("'", "'");
|
|
2786
2789
|
}
|
|
2787
|
-
function
|
|
2790
|
+
function wr(e) {
|
|
2788
2791
|
return String(e).replaceAll("<", "<").replaceAll(">", ">").replaceAll("&", "&");
|
|
2789
2792
|
}
|
|
2790
2793
|
//#endregion
|
|
2791
2794
|
//#region src/js/core/detectLang.js
|
|
2792
|
-
var
|
|
2795
|
+
var Tr = 5, Er = 2, Dr = [
|
|
2793
2796
|
["typescript", "javascript"],
|
|
2794
2797
|
["scss", "css"],
|
|
2795
2798
|
["cpp", "c"]
|
|
2796
|
-
],
|
|
2799
|
+
], Or = [
|
|
2797
2800
|
"javascript",
|
|
2798
2801
|
"typescript",
|
|
2799
2802
|
"python",
|
|
@@ -2816,7 +2819,7 @@ var wr = 5, Tr = 2, Er = [
|
|
|
2816
2819
|
"scss",
|
|
2817
2820
|
"css",
|
|
2818
2821
|
"bash"
|
|
2819
|
-
],
|
|
2822
|
+
], kr = [
|
|
2820
2823
|
{
|
|
2821
2824
|
lang: "php",
|
|
2822
2825
|
w: 10,
|
|
@@ -3382,33 +3385,41 @@ var wr = 5, Tr = 2, Er = [
|
|
|
3382
3385
|
w: 3,
|
|
3383
3386
|
re: /\s\|[ \t]*\w|\s&&\s|\s2>&1|\s-[\w-]+\s/
|
|
3384
3387
|
}
|
|
3385
|
-
],
|
|
3386
|
-
function
|
|
3387
|
-
if (e.length <=
|
|
3388
|
-
let t = e.slice(0,
|
|
3388
|
+
], Ar = 4e3;
|
|
3389
|
+
function jr(e) {
|
|
3390
|
+
if (e.length <= Ar) return e;
|
|
3391
|
+
let t = e.slice(0, Ar), n = t.lastIndexOf("\n");
|
|
3389
3392
|
return n > 0 ? t.slice(0, n) : t;
|
|
3390
3393
|
}
|
|
3391
|
-
function
|
|
3394
|
+
function Mr(e) {
|
|
3392
3395
|
if (!e?.trim()) return null;
|
|
3393
|
-
let t =
|
|
3394
|
-
for (let { lang: e, re: r, w: i } of
|
|
3396
|
+
let t = jr(e.trim()), n = /* @__PURE__ */ new Map();
|
|
3397
|
+
for (let { lang: e, re: r, w: i } of kr) r.test(t) && n.set(e, (n.get(e) || 0) + i);
|
|
3395
3398
|
if (n.size === 0) return null;
|
|
3396
|
-
for (let [e, t] of
|
|
3399
|
+
for (let [e, t] of Dr) {
|
|
3397
3400
|
let r = n.get(e);
|
|
3398
3401
|
r && n.set(e, r + (n.get(t) || 0));
|
|
3399
3402
|
}
|
|
3400
3403
|
let r = [...n.entries()].sort((e, t) => t[1] - e[1]), [i, a] = r[0], o = r[1]?.[1] ?? 0;
|
|
3401
|
-
return a <
|
|
3404
|
+
return a < Tr || a - o < Er ? null : i;
|
|
3402
3405
|
}
|
|
3403
3406
|
//#endregion
|
|
3404
3407
|
//#region src/js/module/Editor.js
|
|
3405
|
-
var
|
|
3408
|
+
var Nr = /* @__PURE__ */ new Set([
|
|
3409
|
+
"PRE",
|
|
3410
|
+
"BLOCKQUOTE",
|
|
3411
|
+
"TABLE",
|
|
3412
|
+
"FIGURE",
|
|
3413
|
+
"UL",
|
|
3414
|
+
"OL",
|
|
3415
|
+
"HR"
|
|
3416
|
+
]), Pr = class {
|
|
3406
3417
|
constructor(e) {
|
|
3407
3418
|
this.context = e, this.options = e.options, this._history = null, this._disposers = [], this._snapshotTimer = null;
|
|
3408
3419
|
}
|
|
3409
3420
|
initialize() {
|
|
3410
3421
|
let e = this.context.layoutInfo.editable;
|
|
3411
|
-
return this._history = new
|
|
3422
|
+
return this._history = new Tn(e, this.options.historyLimit || 100, this.options.historyMaxBytes || 10 * 1024 * 1024), this._bindEvents(e), this;
|
|
3412
3423
|
}
|
|
3413
3424
|
destroy() {
|
|
3414
3425
|
this._disposers.forEach((e) => e()), this._disposers = [], this._history = null, clearTimeout(this._snapshotTimer), this._snapshotTimer = null;
|
|
@@ -3485,7 +3496,7 @@ var Mr = class {
|
|
|
3485
3496
|
}
|
|
3486
3497
|
_onKeydown(e) {
|
|
3487
3498
|
let t = this.context.layoutInfo.editable;
|
|
3488
|
-
if (!
|
|
3499
|
+
if (!jn(e, t, this.options)) {
|
|
3489
3500
|
if (F(e, "z") && !e.shiftKey) {
|
|
3490
3501
|
e.preventDefault(), this.undo();
|
|
3491
3502
|
return;
|
|
@@ -3554,15 +3565,7 @@ var Mr = class {
|
|
|
3554
3565
|
let e = this.context.layoutInfo.editable;
|
|
3555
3566
|
if (!e) return;
|
|
3556
3567
|
let t = e.lastElementChild;
|
|
3557
|
-
if (t && (
|
|
3558
|
-
"PRE",
|
|
3559
|
-
"BLOCKQUOTE",
|
|
3560
|
-
"TABLE",
|
|
3561
|
-
"FIGURE",
|
|
3562
|
-
"UL",
|
|
3563
|
-
"OL",
|
|
3564
|
-
"HR"
|
|
3565
|
-
])).has(t.nodeName)) {
|
|
3568
|
+
if (t && Nr.has(t.nodeName)) {
|
|
3566
3569
|
let t = document.createElement("p");
|
|
3567
3570
|
t.innerHTML = "<br>", e.appendChild(t);
|
|
3568
3571
|
}
|
|
@@ -3575,7 +3578,8 @@ var Mr = class {
|
|
|
3575
3578
|
return this.context.invoke("clipboard.resolveImages", e) ?? e;
|
|
3576
3579
|
}
|
|
3577
3580
|
setHTML(e) {
|
|
3578
|
-
|
|
3581
|
+
let t = mn(e, { allowIframes: !0 });
|
|
3582
|
+
this.context.layoutInfo.editable.replaceChildren(...t.childNodes), this._history && this._history.reset(), this.afterCommand();
|
|
3579
3583
|
}
|
|
3580
3584
|
getText() {
|
|
3581
3585
|
return this.context.layoutInfo.editable.innerText || "";
|
|
@@ -3600,10 +3604,10 @@ var Mr = class {
|
|
|
3600
3604
|
e && (D("insertText", e), this.afterCommand());
|
|
3601
3605
|
}
|
|
3602
3606
|
setMarkdown(e) {
|
|
3603
|
-
this.setHTML(
|
|
3607
|
+
this.setHTML(Xn(e || ""));
|
|
3604
3608
|
}
|
|
3605
3609
|
getMarkdown() {
|
|
3606
|
-
return
|
|
3610
|
+
return Mn(this.getHTML());
|
|
3607
3611
|
}
|
|
3608
3612
|
undo() {
|
|
3609
3613
|
this._history && (this._flushPendingSnapshot(), this._history.undo(), this.context.invoke("toolbar.refresh"), this.context.invoke("statusbar.update"), this.context.triggerEvent("change", this.getHTML()));
|
|
@@ -3689,7 +3693,7 @@ var Mr = class {
|
|
|
3689
3693
|
if (e?.rangeCount > 0) {
|
|
3690
3694
|
let t = e.getRangeAt(0).commonAncestorContainer, n = t.nodeType === 1 ? t.closest("pre") : t.parentElement?.closest("pre");
|
|
3691
3695
|
if (n && !n.dataset.language) {
|
|
3692
|
-
let e =
|
|
3696
|
+
let e = Mr(n.textContent || "");
|
|
3693
3697
|
if (e) {
|
|
3694
3698
|
this.context.invoke("codeTooltip.applyLanguage", n, e);
|
|
3695
3699
|
return;
|
|
@@ -3748,7 +3752,7 @@ var Mr = class {
|
|
|
3748
3752
|
e && (D("insertHTML", e), this.afterCommand());
|
|
3749
3753
|
}
|
|
3750
3754
|
insertTable(e, t) {
|
|
3751
|
-
|
|
3755
|
+
Dn(e, t, { headerRow: this.context.options.tableHeaderRow }), this.afterCommand();
|
|
3752
3756
|
}
|
|
3753
3757
|
_getClosestAnchor() {
|
|
3754
3758
|
let e = globalThis.getSelection();
|
|
@@ -3763,7 +3767,7 @@ var Mr = class {
|
|
|
3763
3767
|
_escapeAttr(e) {
|
|
3764
3768
|
return String(e ?? "").replaceAll("&", "&").replaceAll("\"", """).replaceAll("<", "<").replaceAll(">", ">");
|
|
3765
3769
|
}
|
|
3766
|
-
},
|
|
3770
|
+
}, Fr = (e) => typeof e == "string" ? ut(e) : e, Ir = null, Lr = "stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"", V = (e) => `<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24" fill="none" ${Lr} style="display:block">${e}</svg>`, H = /* @__PURE__ */ new Map([
|
|
3767
3771
|
["bold", V("<path d=\"M6 4h8a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z\"/><path d=\"M6 12h9a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z\"/>")],
|
|
3768
3772
|
["italic", V("<line x1=\"19\" y1=\"4\" x2=\"10\" y2=\"4\"/><line x1=\"14\" y1=\"20\" x2=\"5\" y2=\"20\"/><line x1=\"15\" y1=\"4\" x2=\"9\" y2=\"20\"/>")],
|
|
3769
3773
|
["underline", V("<path d=\"M6 3v7a6 6 0 0 0 6 6 6 6 0 0 0 6-6V3\"/><line x1=\"4\" y1=\"21\" x2=\"20\" y2=\"21\"/>")],
|
|
@@ -3800,7 +3804,7 @@ var Mr = class {
|
|
|
3800
3804
|
["inline-code", V("<path d=\"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1\"/><path d=\"M16 3h1a2 2 0 0 1 2 2v5c0 1.1.9 2 2 2a2 2 0 0 1-2 2v5a2 2 0 0 1-2 2h-1\"/>")],
|
|
3801
3805
|
["checklist", V("<rect x=\"3\" y=\"4\" width=\"5\" height=\"5\" rx=\"1\"/><path d=\"m4 6.5 1 1 2-2\"/><rect x=\"3\" y=\"13\" width=\"5\" height=\"5\" rx=\"1\"/><line x1=\"10\" y1=\"6.5\" x2=\"21\" y2=\"6.5\"/><line x1=\"10\" y1=\"15.5\" x2=\"21\" y2=\"15.5\"/>")],
|
|
3802
3806
|
["print", V("<path d=\"M6 9V2h12v7\"/><path d=\"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2\"/><rect x=\"6\" y=\"14\" width=\"12\" height=\"8\"/>")]
|
|
3803
|
-
]),
|
|
3807
|
+
]), Rr = /* @__PURE__ */ new Map([
|
|
3804
3808
|
["bold", "fa-bold"],
|
|
3805
3809
|
["italic", "fa-italic"],
|
|
3806
3810
|
["underline", "fa-underline"],
|
|
@@ -3834,7 +3838,7 @@ var Mr = class {
|
|
|
3834
3838
|
["inline-code", "fa-code"],
|
|
3835
3839
|
["checklist", "fa-list-check"],
|
|
3836
3840
|
["print", "fa-print"]
|
|
3837
|
-
]),
|
|
3841
|
+
]), zr = class {
|
|
3838
3842
|
constructor(e) {
|
|
3839
3843
|
this.context = e, this.options = e.options, this.el = null, this._disposers = [], this._colorPickerClosers = [], this._refreshRaf = null;
|
|
3840
3844
|
}
|
|
@@ -3844,7 +3848,7 @@ var Mr = class {
|
|
|
3844
3848
|
role: "toolbar",
|
|
3845
3849
|
"aria-orientation": "horizontal",
|
|
3846
3850
|
"aria-label": "Editor toolbar"
|
|
3847
|
-
}), this._faReady = this._detectFontAwesome(), this._buildButtons(), this._initRovingFocus(), this._btnMap = new Map((this.options.toolbar || []).flat().map(
|
|
3851
|
+
}), this._faReady = this._detectFontAwesome(), this._buildButtons(), this._initRovingFocus(), this._btnMap = new Map((this.options.toolbar || []).flat().map(Fr).filter(Boolean).map((e) => [e.name, e])), this;
|
|
3848
3852
|
}
|
|
3849
3853
|
destroy() {
|
|
3850
3854
|
this._refreshRaf && cancelAnimationFrame(this._refreshRaf), this._refreshRaf = null, this._disposers.forEach((e) => e()), this._disposers = [], this.el?.parentNode && this.el.remove(), this.el = null;
|
|
@@ -3854,7 +3858,7 @@ var Mr = class {
|
|
|
3854
3858
|
e.forEach((e) => {
|
|
3855
3859
|
let n = w("div", { class: "an-btn-group" });
|
|
3856
3860
|
e.forEach((e) => {
|
|
3857
|
-
let t =
|
|
3861
|
+
let t = Fr(e);
|
|
3858
3862
|
if (!t) {
|
|
3859
3863
|
console.warn(`[AutumnNote] Toolbar: button "${e}" not found in registry. Skipped.`);
|
|
3860
3864
|
return;
|
|
@@ -4073,7 +4077,7 @@ var Mr = class {
|
|
|
4073
4077
|
...typeof e.isActive == "function" ? { "aria-pressed": "false" } : {}
|
|
4074
4078
|
}), n = this.options.fontAwesomeClass || "fas";
|
|
4075
4079
|
if (this._faReady) {
|
|
4076
|
-
let r =
|
|
4080
|
+
let r = Rr.get(e.icon) || Rr.get(e.name) || null;
|
|
4077
4081
|
r ? t.innerHTML = `<i class="${n} ${r}" aria-hidden="true"></i>` : H.has(e.icon) ? t.innerHTML = H.get(e.icon) : t.textContent = e.icon || e.name;
|
|
4078
4082
|
} else H.has(e.icon) ? t.innerHTML = H.get(e.icon) : H.has(e.name) ? t.innerHTML = H.get(e.name) : t.textContent = e.icon || e.name;
|
|
4079
4083
|
let r = E(t, "click", (t) => {
|
|
@@ -4119,10 +4123,10 @@ var Mr = class {
|
|
|
4119
4123
|
}
|
|
4120
4124
|
_detectFontAwesome() {
|
|
4121
4125
|
if (!this.options.useFontAwesome) return !1;
|
|
4122
|
-
if (
|
|
4123
|
-
if (document.querySelector(".fa, .fas, .far, .fal, .fab, .fa-solid")) return
|
|
4126
|
+
if (Ir !== null) return Ir;
|
|
4127
|
+
if (document.querySelector(".fa, .fas, .far, .fal, .fab, .fa-solid")) return Ir = !0, !0;
|
|
4124
4128
|
let e = Array.from(document.querySelectorAll("link[rel=\"stylesheet\"]")).filter((e) => e.id !== "an-fontawesome-css").map((e) => e.href || "").join(" ");
|
|
4125
|
-
return
|
|
4129
|
+
return Ir = /fontawesome|font-awesome|use\.fontawesome|all\.css/.test(e), Ir;
|
|
4126
4130
|
}
|
|
4127
4131
|
refresh() {
|
|
4128
4132
|
this._refreshRaf && cancelAnimationFrame(this._refreshRaf), this._refreshRaf = requestAnimationFrame(() => {
|
|
@@ -4155,29 +4159,53 @@ var Mr = class {
|
|
|
4155
4159
|
this.el && (this.el.style.display = "none");
|
|
4156
4160
|
}
|
|
4157
4161
|
rebuild() {
|
|
4158
|
-
this._refreshRaf &&= (cancelAnimationFrame(this._refreshRaf), null), this._disposers.forEach((e) => e()), this._disposers = [], this.el && (this.el.innerHTML = ""), this._faReady = this._detectFontAwesome(), this._buildButtons(), this._initRovingFocus(), this._btnMap = new Map((this.options.toolbar || []).flat().map(
|
|
4162
|
+
this._refreshRaf &&= (cancelAnimationFrame(this._refreshRaf), null), this._disposers.forEach((e) => e()), this._disposers = [], this.el && (this.el.innerHTML = ""), this._faReady = this._detectFontAwesome(), this._buildButtons(), this._initRovingFocus(), this._btnMap = new Map((this.options.toolbar || []).flat().map(Fr).filter(Boolean).map((e) => [e.name, e])), this.refresh();
|
|
4159
4163
|
}
|
|
4160
|
-
},
|
|
4161
|
-
function
|
|
4164
|
+
}, Br = typeof Intl < "u" && typeof Intl.Segmenter == "function" ? new Intl.Segmenter(void 0, { granularity: "word" }) : null;
|
|
4165
|
+
function Vr(e) {
|
|
4162
4166
|
let t = e.trim();
|
|
4163
4167
|
if (!t) return 0;
|
|
4164
|
-
if (
|
|
4168
|
+
if (Br) {
|
|
4165
4169
|
let e = 0;
|
|
4166
|
-
for (let n of
|
|
4170
|
+
for (let n of Br.segment(t)) n.isWordLike && e++;
|
|
4167
4171
|
return e;
|
|
4168
4172
|
}
|
|
4169
4173
|
return t.split(/\s+/).length;
|
|
4170
4174
|
}
|
|
4171
|
-
|
|
4175
|
+
var Hr = /* @__PURE__ */ new Set(/* @__PURE__ */ "ADDRESS.ARTICLE.ASIDE.BLOCKQUOTE.BR.DD.DIV.DL.DT.FIELDSET.FIGCAPTION.FIGURE.FOOTER.FORM.H1.H2.H3.H4.H5.H6.HEADER.HR.LI.MAIN.NAV.OL.P.PRE.SECTION.TABLE.TBODY.TD.TFOOT.TH.THEAD.TR.UL".split("."));
|
|
4176
|
+
function Ur(e, t, n) {
|
|
4177
|
+
for (let r = e.firstChild; r; r = r.nextSibling) if (r.nodeType === 3) {
|
|
4178
|
+
let e = r.data;
|
|
4179
|
+
t.push(e), n.push(e);
|
|
4180
|
+
} else if (r.nodeType === 1) {
|
|
4181
|
+
let e = Hr.has(r.tagName);
|
|
4182
|
+
e && t.push("\n"), Ur(r, t, n), e && t.push("\n");
|
|
4183
|
+
}
|
|
4184
|
+
}
|
|
4185
|
+
function Wr(e) {
|
|
4186
|
+
if (e.nodeType === 3) {
|
|
4187
|
+
let t = e.data;
|
|
4188
|
+
return {
|
|
4189
|
+
lines: t,
|
|
4190
|
+
flat: t
|
|
4191
|
+
};
|
|
4192
|
+
}
|
|
4193
|
+
let t = [], n = [];
|
|
4194
|
+
return Ur(e, t, n), {
|
|
4195
|
+
lines: t.join(""),
|
|
4196
|
+
flat: n.join("")
|
|
4197
|
+
};
|
|
4198
|
+
}
|
|
4199
|
+
function Gr(e, t, n) {
|
|
4172
4200
|
if (!n) {
|
|
4173
4201
|
e.classList.remove("an-count-warn", "an-count-exceeded");
|
|
4174
4202
|
return;
|
|
4175
4203
|
}
|
|
4176
4204
|
t > n ? (e.classList.add("an-count-exceeded"), e.classList.remove("an-count-warn")) : t >= n * .9 ? (e.classList.add("an-count-warn"), e.classList.remove("an-count-exceeded")) : e.classList.remove("an-count-warn", "an-count-exceeded");
|
|
4177
4205
|
}
|
|
4178
|
-
var
|
|
4206
|
+
var Kr = class {
|
|
4179
4207
|
constructor(e) {
|
|
4180
|
-
this.context = e, this.options = e.options, this.el = null, this._disposers = [], this._wordCountEl = null, this._charCountEl = null;
|
|
4208
|
+
this.context = e, this.options = e.options, this.el = null, this._disposers = [], this._wordCountEl = null, this._charCountEl = null, this._countCache = /* @__PURE__ */ new WeakMap();
|
|
4181
4209
|
}
|
|
4182
4210
|
initialize() {
|
|
4183
4211
|
if (this.el = w("div", { class: "an-statusbar" }), this.options.resizable !== !1) {
|
|
@@ -4226,19 +4254,59 @@ var Vr = class {
|
|
|
4226
4254
|
}, d = E(e, "mousedown", s), f = E(e, "touchstart", u);
|
|
4227
4255
|
this._disposers.push(d, f);
|
|
4228
4256
|
}
|
|
4257
|
+
_counts() {
|
|
4258
|
+
let e = this.context.layoutInfo.editable, t = 0, n = 0, r = [], i = [], a = 0;
|
|
4259
|
+
for (let o = e.firstChild; o; o = o.nextSibling) {
|
|
4260
|
+
let e = this._countCache.get(o);
|
|
4261
|
+
if (e && e.key === (o.textContent || "")) {
|
|
4262
|
+
t += e.words, n += e.chars;
|
|
4263
|
+
continue;
|
|
4264
|
+
}
|
|
4265
|
+
let { lines: s, flat: c } = Wr(o);
|
|
4266
|
+
r.push({
|
|
4267
|
+
node: o,
|
|
4268
|
+
key: c,
|
|
4269
|
+
text: s,
|
|
4270
|
+
start: a
|
|
4271
|
+
}), i.push(s), a += s.length + 1;
|
|
4272
|
+
}
|
|
4273
|
+
if (r.length) {
|
|
4274
|
+
let e = this._countBatch(r, i.join("\n"));
|
|
4275
|
+
r.forEach((r, i) => {
|
|
4276
|
+
let a = {
|
|
4277
|
+
key: r.key,
|
|
4278
|
+
words: e[i],
|
|
4279
|
+
chars: r.key.replaceAll("\n", "").length
|
|
4280
|
+
};
|
|
4281
|
+
this._countCache.set(r.node, a), t += a.words, n += a.chars;
|
|
4282
|
+
});
|
|
4283
|
+
}
|
|
4284
|
+
return {
|
|
4285
|
+
words: t,
|
|
4286
|
+
chars: n
|
|
4287
|
+
};
|
|
4288
|
+
}
|
|
4289
|
+
_countBatch(e, t) {
|
|
4290
|
+
if (!Br) return e.map((e) => Vr(e.text));
|
|
4291
|
+
let n = Array(e.length).fill(0), r = 0;
|
|
4292
|
+
for (let i of Br.segment(t)) if (i.isWordLike) {
|
|
4293
|
+
for (; r < e.length - 1 && i.index >= e[r + 1].start;) r++;
|
|
4294
|
+
n[r]++;
|
|
4295
|
+
}
|
|
4296
|
+
return n;
|
|
4297
|
+
}
|
|
4229
4298
|
update() {
|
|
4230
4299
|
if (!this._wordCountEl || !this._charCountEl) return;
|
|
4231
|
-
let
|
|
4232
|
-
this._wordCountEl.textContent =
|
|
4300
|
+
let { words: e, chars: t } = this._counts(), n = this.options.maxWords || 0, r = this.options.maxChars || 0, i = this.context.locale.statusbar;
|
|
4301
|
+
this._wordCountEl.textContent = n ? i.wordsLimit(e, n) : i.words(e), this._charCountEl.textContent = r ? i.charsLimit(t, r) : i.chars(t), Gr(this._wordCountEl, e, n), Gr(this._charCountEl, t, r);
|
|
4233
4302
|
}
|
|
4234
4303
|
getWordCount() {
|
|
4235
|
-
|
|
4236
|
-
return zr(e.innerText || "");
|
|
4304
|
+
return this._counts().words;
|
|
4237
4305
|
}
|
|
4238
4306
|
getCharCount() {
|
|
4239
|
-
return
|
|
4307
|
+
return this._counts().chars;
|
|
4240
4308
|
}
|
|
4241
|
-
},
|
|
4309
|
+
}, qr = class {
|
|
4242
4310
|
constructor(e) {
|
|
4243
4311
|
this.context = e, this.options = e.options, this._disposers = [];
|
|
4244
4312
|
}
|
|
@@ -4355,8 +4423,8 @@ var Vr = class {
|
|
|
4355
4423
|
}
|
|
4356
4424
|
if (this.options.markdownPaste !== !1) {
|
|
4357
4425
|
let n = t.types.includes("text/html"), r = n ? t.getData("text/html") : "", i = !n || this._isTriviallyPlainHtml(r), a = t.getData("text/plain");
|
|
4358
|
-
if (a && i &&
|
|
4359
|
-
e.preventDefault(), D("insertHTML", j(
|
|
4426
|
+
if (a && i && Hn(a)) {
|
|
4427
|
+
e.preventDefault(), D("insertHTML", j(Xn(a))), this.context.invoke("editor.afterCommand");
|
|
4360
4428
|
return;
|
|
4361
4429
|
}
|
|
4362
4430
|
}
|
|
@@ -4395,7 +4463,7 @@ var Vr = class {
|
|
|
4395
4463
|
}
|
|
4396
4464
|
let n = new FileReader();
|
|
4397
4465
|
n.onload = (e) => {
|
|
4398
|
-
D("insertHTML", j(
|
|
4466
|
+
D("insertHTML", j(Xn(e.target.result || ""))), this.context.invoke("editor.afterCommand");
|
|
4399
4467
|
}, n.onerror = () => {
|
|
4400
4468
|
let t = `Failed to read dropped markdown file "${e.name}".`;
|
|
4401
4469
|
console.warn(`[AutumnNote] ${t}`), this.context.triggerEvent("pasteError", { message: t });
|
|
@@ -4607,7 +4675,7 @@ var Vr = class {
|
|
|
4607
4675
|
highlightColor: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M3 21v-4l9-9 4 4-9 9z\"/><path d=\"M12 8l4 4\"/><line x1=\"3\" y1=\"21\" x2=\"21\" y2=\"21\"/></svg>",
|
|
4608
4676
|
noColor: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"11\" height=\"11\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\"><line x1=\"4\" y1=\"4\" x2=\"20\" y2=\"20\"/><line x1=\"20\" y1=\"4\" x2=\"4\" y2=\"20\"/></svg>",
|
|
4609
4677
|
back: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"15 18 9 12 15 6\"/></svg>"
|
|
4610
|
-
},
|
|
4678
|
+
}, Jr = [
|
|
4611
4679
|
"#000000",
|
|
4612
4680
|
"#434343",
|
|
4613
4681
|
"#666666",
|
|
@@ -4633,19 +4701,19 @@ var Vr = class {
|
|
|
4633
4701
|
"#d9d2e9",
|
|
4634
4702
|
"#ead1dc"
|
|
4635
4703
|
];
|
|
4636
|
-
function
|
|
4704
|
+
function Yr(e) {
|
|
4637
4705
|
let t = e === "foreColor" ? "Text Color" : "Highlight Color", n = e === "foreColor" ? "textColor" : "highlightColor";
|
|
4638
4706
|
return () => [{
|
|
4639
4707
|
back: !0,
|
|
4640
4708
|
label: t,
|
|
4641
4709
|
localeKey: n,
|
|
4642
|
-
navigate: () =>
|
|
4710
|
+
navigate: () => Xr
|
|
4643
4711
|
}, {
|
|
4644
4712
|
colorPalette: !0,
|
|
4645
4713
|
colorType: e
|
|
4646
4714
|
}];
|
|
4647
4715
|
}
|
|
4648
|
-
var
|
|
4716
|
+
var Xr = [
|
|
4649
4717
|
{
|
|
4650
4718
|
name: "cut",
|
|
4651
4719
|
label: "Cut",
|
|
@@ -4709,14 +4777,14 @@ var Gr = [
|
|
|
4709
4777
|
label: "Text Color",
|
|
4710
4778
|
icon: U.textColor,
|
|
4711
4779
|
colorStrip: "foreColor",
|
|
4712
|
-
navigate:
|
|
4780
|
+
navigate: Yr("foreColor")
|
|
4713
4781
|
},
|
|
4714
4782
|
{
|
|
4715
4783
|
name: "highlightColor",
|
|
4716
4784
|
label: "Highlight Color",
|
|
4717
4785
|
icon: U.highlightColor,
|
|
4718
4786
|
colorStrip: "hiliteColor",
|
|
4719
|
-
navigate:
|
|
4787
|
+
navigate: Yr("hiliteColor")
|
|
4720
4788
|
},
|
|
4721
4789
|
{ separator: !0 },
|
|
4722
4790
|
{
|
|
@@ -4763,9 +4831,9 @@ var Gr = [
|
|
|
4763
4831
|
icon: U.table,
|
|
4764
4832
|
tableGrid: !0
|
|
4765
4833
|
}
|
|
4766
|
-
],
|
|
4834
|
+
], Zr = class {
|
|
4767
4835
|
constructor(e) {
|
|
4768
|
-
this.context = e, this.options = e.options || {}, this._items = this.options.contextMenu?.items ||
|
|
4836
|
+
this.context = e, this.options = e.options || {}, this._items = this.options.contextMenu?.items || Xr, this.el = null, this._disposers = [], this._menuDisposers = [], this._lastX = 0, this._lastY = 0, this._copiedFormat = null, this._savedRange = null;
|
|
4769
4837
|
}
|
|
4770
4838
|
initialize() {
|
|
4771
4839
|
this.el = w("div", {
|
|
@@ -4851,7 +4919,7 @@ var Gr = [
|
|
|
4851
4919
|
}
|
|
4852
4920
|
if (e.colorPalette) {
|
|
4853
4921
|
let t = w("div", { class: "an-context-color-palette" });
|
|
4854
|
-
if (
|
|
4922
|
+
if (Jr.forEach((n) => {
|
|
4855
4923
|
let r = w("div", {
|
|
4856
4924
|
class: "an-context-color-swatch",
|
|
4857
4925
|
title: n,
|
|
@@ -5081,7 +5149,13 @@ var Gr = [
|
|
|
5081
5149
|
} catch {}
|
|
5082
5150
|
this.context.invoke("editor.afterCommand");
|
|
5083
5151
|
}
|
|
5084
|
-
},
|
|
5152
|
+
}, Qr = /[^\s\u200B]/;
|
|
5153
|
+
function $r(e) {
|
|
5154
|
+
let t = document.createTreeWalker(e, NodeFilter.SHOW_TEXT);
|
|
5155
|
+
for (let e = t.nextNode(); e; e = t.nextNode()) if (Qr.test(e.data)) return !0;
|
|
5156
|
+
return !1;
|
|
5157
|
+
}
|
|
5158
|
+
var ei = class {
|
|
5085
5159
|
constructor(e) {
|
|
5086
5160
|
this.context = e, this.options = e.options, this._disposers = [];
|
|
5087
5161
|
}
|
|
@@ -5095,10 +5169,10 @@ var Gr = [
|
|
|
5095
5169
|
this._disposers.forEach((e) => e()), this._disposers = [];
|
|
5096
5170
|
}
|
|
5097
5171
|
_update() {
|
|
5098
|
-
let e = this.context.layoutInfo.editable, t = document.activeElement === e, n =
|
|
5172
|
+
let e = this.context.layoutInfo.editable, t = document.activeElement === e, n = !$r(e) && !e.querySelector("img, table, hr, .an-video-wrapper");
|
|
5099
5173
|
e.classList.toggle("an-placeholder", n && !t);
|
|
5100
5174
|
}
|
|
5101
|
-
},
|
|
5175
|
+
}, ti = class {
|
|
5102
5176
|
constructor(e) {
|
|
5103
5177
|
this.context = e, this.options = e.options, this._active = !1, this._textarea = null, this._disposers = [];
|
|
5104
5178
|
}
|
|
@@ -5143,7 +5217,7 @@ var Gr = [
|
|
|
5143
5217
|
return /^<[^/!][^>]*[^/]>/.test(r) && !t.test(r) && !/^<(br|hr|img|input|link|meta)/.test(r) && n++, i;
|
|
5144
5218
|
}).filter(Boolean).join("\n");
|
|
5145
5219
|
}
|
|
5146
|
-
},
|
|
5220
|
+
}, ni = class {
|
|
5147
5221
|
constructor(e) {
|
|
5148
5222
|
this.context = e, this._active = !1, this._disposers = [], this._prevHeight = "";
|
|
5149
5223
|
}
|
|
@@ -5228,12 +5302,12 @@ var Gr = [
|
|
|
5228
5302
|
let o = E(i, "click", n), s = E(a, "click", () => this._close());
|
|
5229
5303
|
return this._disposers.push(o, s), r;
|
|
5230
5304
|
}
|
|
5231
|
-
},
|
|
5305
|
+
}, ri = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71\"/><path d=\"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71\"/></svg>", ii = class extends W {
|
|
5232
5306
|
show() {
|
|
5233
5307
|
this._saveRange(), this._prefill(), this._open();
|
|
5234
5308
|
}
|
|
5235
5309
|
_buildDialog() {
|
|
5236
|
-
let e = this.context.locale.linkDialog, { overlay: t, box: n } = this._buildDialogShell(e.ariaLabel,
|
|
5310
|
+
let e = this.context.locale.linkDialog, { overlay: t, box: n } = this._buildDialogShell(e.ariaLabel, ri, e.title), r = w("label", { class: "an-label" });
|
|
5237
5311
|
r.textContent = e.url;
|
|
5238
5312
|
let i = w("input", {
|
|
5239
5313
|
type: "url",
|
|
@@ -5303,12 +5377,12 @@ var Gr = [
|
|
|
5303
5377
|
}
|
|
5304
5378
|
this._savedRange && this._savedRange.select(), this.context.invoke("editor.insertLink", e, t, n), this._close();
|
|
5305
5379
|
}
|
|
5306
|
-
},
|
|
5380
|
+
}, ai = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect x=\"3\" y=\"3\" width=\"18\" height=\"18\" rx=\"2\"/><circle cx=\"8.5\" cy=\"8.5\" r=\"1.5\"/><polyline points=\"21 15 16 10 5 21\"/></svg>", oi = class extends W {
|
|
5307
5381
|
show({ beforeInsert: e } = {}) {
|
|
5308
5382
|
this._beforeInsert = typeof e == "function" ? e : null, this._saveRange(), this._urlInput.value = "", this._altInput.value = "", this._fileInput && (this._fileInput.value = ""), this._open();
|
|
5309
5383
|
}
|
|
5310
5384
|
_buildDialog() {
|
|
5311
|
-
let e = this.context.locale.imageDialog, { overlay: t, box: n } = this._buildDialogShell(e.ariaLabel,
|
|
5385
|
+
let e = this.context.locale.imageDialog, { overlay: t, box: n } = this._buildDialogShell(e.ariaLabel, ai, e.title), r = w("label", { class: "an-label" });
|
|
5312
5386
|
r.textContent = e.imageUrl;
|
|
5313
5387
|
let i = w("input", {
|
|
5314
5388
|
type: "url",
|
|
@@ -5435,12 +5509,12 @@ var Gr = [
|
|
|
5435
5509
|
_close() {
|
|
5436
5510
|
this._beforeInsert = null, super._close();
|
|
5437
5511
|
}
|
|
5438
|
-
},
|
|
5512
|
+
}, si = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polygon points=\"23 7 16 12 23 17 23 7\"/><rect x=\"1\" y=\"5\" width=\"15\" height=\"14\" rx=\"2\"/></svg>", ci = class extends W {
|
|
5439
5513
|
show() {
|
|
5440
5514
|
this._saveRange(), this._urlInput.value = "", this._widthInput.value = "560", this._hintEl.textContent = "", this._open();
|
|
5441
5515
|
}
|
|
5442
5516
|
_buildDialog() {
|
|
5443
|
-
let e = this.context.locale.videoDialog, { overlay: t, box: n } = this._buildDialogShell(e.ariaLabel,
|
|
5517
|
+
let e = this.context.locale.videoDialog, { overlay: t, box: n } = this._buildDialogShell(e.ariaLabel, si, e.title), r = w("label", { class: "an-label" });
|
|
5444
5518
|
r.textContent = e.videoUrl;
|
|
5445
5519
|
let i = w("input", {
|
|
5446
5520
|
type: "url",
|
|
@@ -5521,7 +5595,7 @@ var Gr = [
|
|
|
5521
5595
|
let i = M(e, { media: !0 });
|
|
5522
5596
|
return i ? `<div class="an-video-wrapper" style="position:relative;display:block;width:${t}px;max-width:100%"><video src="${i.replaceAll("\"", "%22")}" width="${t}" height="${r}" controls style="display:block;max-width:100%"></video><div class="an-video-shield"></div></div>` : null;
|
|
5523
5597
|
}
|
|
5524
|
-
},
|
|
5598
|
+
}, li = [
|
|
5525
5599
|
{
|
|
5526
5600
|
pos: "nw",
|
|
5527
5601
|
cursor: "nw-resize"
|
|
@@ -5554,7 +5628,7 @@ var Gr = [
|
|
|
5554
5628
|
pos: "w",
|
|
5555
5629
|
cursor: "w-resize"
|
|
5556
5630
|
}
|
|
5557
|
-
],
|
|
5631
|
+
], ui = class {
|
|
5558
5632
|
constructor(e) {
|
|
5559
5633
|
this.context = e, this._active = null, this._overlay = null, this._disposers = [], this._positionRaf = null, this._lastOverlayPos = null;
|
|
5560
5634
|
}
|
|
@@ -5607,7 +5681,7 @@ var Gr = [
|
|
|
5607
5681
|
}
|
|
5608
5682
|
_buildOverlay() {
|
|
5609
5683
|
let e = document.createElement("div");
|
|
5610
|
-
return e.className = this._overlayClass, e.style.display = "none",
|
|
5684
|
+
return e.className = this._overlayClass, e.style.display = "none", li.forEach(({ pos: t }) => {
|
|
5611
5685
|
let n = document.createElement("div");
|
|
5612
5686
|
n.className = `an-resize-handle an-resize-${t}`, n.dataset.handle = t, this._disposers.push(E(n, "pointerdown", (e) => {
|
|
5613
5687
|
e.preventDefault(), e.stopPropagation(), this._startResize(e, t);
|
|
@@ -5664,7 +5738,7 @@ var Gr = [
|
|
|
5664
5738
|
};
|
|
5665
5739
|
document.addEventListener("pointermove", p), document.addEventListener("pointerup", h), document.addEventListener("pointercancel", h), this._dragDisposers = [m];
|
|
5666
5740
|
}
|
|
5667
|
-
},
|
|
5741
|
+
}, di = class extends ui {
|
|
5668
5742
|
get _overlayClass() {
|
|
5669
5743
|
return "an-image-resizer";
|
|
5670
5744
|
}
|
|
@@ -5693,7 +5767,7 @@ var Gr = [
|
|
|
5693
5767
|
getActiveImage() {
|
|
5694
5768
|
return this._active;
|
|
5695
5769
|
}
|
|
5696
|
-
},
|
|
5770
|
+
}, fi = class extends ui {
|
|
5697
5771
|
get _overlayClass() {
|
|
5698
5772
|
return "an-video-resizer";
|
|
5699
5773
|
}
|
|
@@ -5729,12 +5803,12 @@ var Gr = [
|
|
|
5729
5803
|
getActiveWrapper() {
|
|
5730
5804
|
return this._active;
|
|
5731
5805
|
}
|
|
5732
|
-
},
|
|
5806
|
+
}, pi = {
|
|
5733
5807
|
open: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6\"/><polyline points=\"15 3 21 3 21 9\"/><line x1=\"10\" y1=\"14\" x2=\"21\" y2=\"3\"/></svg>",
|
|
5734
5808
|
edit: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7\"/><path d=\"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z\"/></svg>",
|
|
5735
5809
|
unlink: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M18.84 12.25l1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71\"/><path d=\"M5.17 11.75l-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71\"/><line x1=\"8\" y1=\"2\" x2=\"8\" y2=\"5\"/><line x1=\"2\" y1=\"8\" x2=\"5\" y2=\"8\"/><line x1=\"16\" y1=\"19\" x2=\"16\" y2=\"22\"/><line x1=\"19\" y1=\"16\" x2=\"22\" y2=\"16\"/></svg>",
|
|
5736
5810
|
copy: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect x=\"9\" y=\"9\" width=\"13\" height=\"13\" rx=\"2\"/><path d=\"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1\"/></svg>"
|
|
5737
|
-
},
|
|
5811
|
+
}, mi = 120, hi = 200, gi = class {
|
|
5738
5812
|
constructor(e) {
|
|
5739
5813
|
this.context = e, this._el = null, this._activeAnchor = null, this._showTimer = null, this._hideTimer = null, this._disposers = [];
|
|
5740
5814
|
}
|
|
@@ -5758,7 +5832,7 @@ var Gr = [
|
|
|
5758
5832
|
role: "toolbar",
|
|
5759
5833
|
"aria-label": e.ariaLabel
|
|
5760
5834
|
});
|
|
5761
|
-
return t.style.display = "none", this._urlLabel = w("span", { class: "an-link-tooltip-url" }), t.appendChild(this._urlLabel), t.appendChild(w("div", { class: "an-link-tooltip-sep" })), this._openBtn = this._makeBtn(
|
|
5835
|
+
return t.style.display = "none", this._urlLabel = w("span", { class: "an-link-tooltip-url" }), t.appendChild(this._urlLabel), t.appendChild(w("div", { class: "an-link-tooltip-sep" })), this._openBtn = this._makeBtn(pi.open, e.openLink, () => this._openLink()), this._copyBtn = this._makeBtn(pi.copy, e.copyUrl, () => this._copyLink()), this._editBtn = this._makeBtn(pi.edit, e.editLink, () => this._editLink()), this._unlinkBtn = this._makeBtn(pi.unlink, e.removeLink, () => this._unlink()), t.appendChild(this._openBtn), t.appendChild(this._copyBtn), t.appendChild(this._editBtn), t.appendChild(this._unlinkBtn), this._disposers.push(E(t, "mouseenter", () => this._clearTimers()), E(t, "mouseleave", () => this._scheduleHide())), t;
|
|
5762
5836
|
}
|
|
5763
5837
|
_makeBtn(e, t, n) {
|
|
5764
5838
|
let r = w("button", {
|
|
@@ -5773,12 +5847,12 @@ var Gr = [
|
|
|
5773
5847
|
_scheduleShow(e) {
|
|
5774
5848
|
this._activeAnchor === e && this._el.style.display !== "none" || (clearTimeout(this._hideTimer), this._hideTimer = null, clearTimeout(this._showTimer), this._showTimer = setTimeout(() => {
|
|
5775
5849
|
this._activeAnchor = e, this._show(e);
|
|
5776
|
-
},
|
|
5850
|
+
}, mi));
|
|
5777
5851
|
}
|
|
5778
5852
|
_scheduleHide() {
|
|
5779
5853
|
clearTimeout(this._showTimer), this._showTimer = null, !this._hideTimer && (this._hideTimer = setTimeout(() => {
|
|
5780
5854
|
this._hide();
|
|
5781
|
-
},
|
|
5855
|
+
}, hi));
|
|
5782
5856
|
}
|
|
5783
5857
|
_show(e) {
|
|
5784
5858
|
let t = this.context.layoutInfo.container.classList.contains("an-disabled"), n = e.getAttribute("href") || "";
|
|
@@ -5827,7 +5901,7 @@ var Gr = [
|
|
|
5827
5901
|
let t = globalThis.getSelection(), n = document.createRange();
|
|
5828
5902
|
n.selectNode(e), t.removeAllRanges(), t.addRange(n), document.execCommand("unlink"), this.context.invoke("editor.afterCommand");
|
|
5829
5903
|
}
|
|
5830
|
-
},
|
|
5904
|
+
}, _i = class {
|
|
5831
5905
|
constructor(e) {
|
|
5832
5906
|
this.context = e, this.options = e.options, this._el = null, this._active = null, this._showTimer = null, this._hideTimer = null, this._disposers = [];
|
|
5833
5907
|
}
|
|
@@ -5879,7 +5953,7 @@ var Gr = [
|
|
|
5879
5953
|
rotateLeft: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8\"/><polyline points=\"3 3 3 8 8 8\"/></svg>",
|
|
5880
5954
|
rotateRight: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M21 12a9 9 0 1 1-9-9 9.75 9.75 0 0 1 6.74 2.74L21 8\"/><polyline points=\"21 3 21 8 16 8\"/></svg>",
|
|
5881
5955
|
crop: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"6 2 6 18 22 18\"/><polyline points=\"2 6 18 6 18 22\"/></svg>"
|
|
5882
|
-
},
|
|
5956
|
+
}, vi = class extends _i {
|
|
5883
5957
|
initialize() {
|
|
5884
5958
|
this._el = this._buildTooltip(), document.body.appendChild(this._el);
|
|
5885
5959
|
let e = this.context.layoutInfo.editable;
|
|
@@ -5979,7 +6053,7 @@ var Gr = [
|
|
|
5979
6053
|
originalSize: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"15 3 21 3 21 9\"/><polyline points=\"9 21 3 21 3 15\"/><line x1=\"21\" y1=\"3\" x2=\"14\" y2=\"10\"/><line x1=\"3\" y1=\"21\" x2=\"10\" y2=\"14\"/></svg>",
|
|
5980
6054
|
deleteVideo: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"3 6 5 6 21 6\"/><path d=\"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2\"/></svg>",
|
|
5981
6055
|
preview: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polygon points=\"5 3 19 12 5 21 5 3\"/></svg>"
|
|
5982
|
-
},
|
|
6056
|
+
}, yi = class extends _i {
|
|
5983
6057
|
initialize() {
|
|
5984
6058
|
this._el = this._buildTooltip(), document.body.appendChild(this._el);
|
|
5985
6059
|
let e = this.context.layoutInfo.editable;
|
|
@@ -6085,7 +6159,7 @@ var Gr = [
|
|
|
6085
6159
|
};
|
|
6086
6160
|
//#endregion
|
|
6087
6161
|
//#region src/js/module/table-grid.js
|
|
6088
|
-
function
|
|
6162
|
+
function bi(e) {
|
|
6089
6163
|
let t = e.closest("tr");
|
|
6090
6164
|
if (!t) return -1;
|
|
6091
6165
|
let n = 0;
|
|
@@ -6104,7 +6178,7 @@ function J(e, t) {
|
|
|
6104
6178
|
}
|
|
6105
6179
|
return null;
|
|
6106
6180
|
}
|
|
6107
|
-
function
|
|
6181
|
+
function xi(e, t) {
|
|
6108
6182
|
let n = 0;
|
|
6109
6183
|
for (let r of e.cells) if (n += r.colSpan || 1, n > t) {
|
|
6110
6184
|
let e = r.nextElementSibling;
|
|
@@ -6112,7 +6186,7 @@ function mi(e, t) {
|
|
|
6112
6186
|
}
|
|
6113
6187
|
return null;
|
|
6114
6188
|
}
|
|
6115
|
-
function
|
|
6189
|
+
function Si(e) {
|
|
6116
6190
|
let t = Array.from(e.rows), n = {}, r = /* @__PURE__ */ new WeakMap();
|
|
6117
6191
|
return t.forEach((e, t) => {
|
|
6118
6192
|
n[t] || (n[t] = {});
|
|
@@ -6139,7 +6213,7 @@ function hi(e) {
|
|
|
6139
6213
|
}
|
|
6140
6214
|
//#endregion
|
|
6141
6215
|
//#region src/js/module/TableTooltip.js
|
|
6142
|
-
var
|
|
6216
|
+
var Ci = 120, wi = 200, Ti = [
|
|
6143
6217
|
"#000000",
|
|
6144
6218
|
"#434343",
|
|
6145
6219
|
"#666666",
|
|
@@ -6164,7 +6238,7 @@ var gi = 120, _i = 200, vi = [
|
|
|
6164
6238
|
"#c9daf8",
|
|
6165
6239
|
"#d9d2e9",
|
|
6166
6240
|
"#ead1dc"
|
|
6167
|
-
],
|
|
6241
|
+
], Ei = class {
|
|
6168
6242
|
constructor(e) {
|
|
6169
6243
|
this.context = e, this._el = null, this._activeTable = null, this._activeCell = null, this._showTimer = null, this._hideTimer = null, this._disposers = [], this._sizePopover = null, this._sizeApply = null, this._sizeTitleEl = null, this._sizeInputEl = null, this._shadePopover = null, this._shadeTitleEl = null, this._shadeColorStrip = null, this._borderColorPopover = null, this._borderColorTitleEl = null, this._borderColorStrip = null, this._borderColorNoBtn = null, this._selectMode = !1, this._selectedCells = [], this._selectStart = null, this._selectDragging = !1, this._selectBtn = null, this._editable = null;
|
|
6170
6244
|
}
|
|
@@ -6222,7 +6296,7 @@ var gi = 120, _i = 200, vi = [
|
|
|
6222
6296
|
});
|
|
6223
6297
|
}), E(e, "mousedown", (e) => {
|
|
6224
6298
|
if (!this.context.layoutInfo.container.classList.contains("an-disabled") && !(!t || !n)) {
|
|
6225
|
-
if (r = !0, i = n, a = e.clientX, o = e.clientY, f = t.closest("table"), i === "col") l =
|
|
6299
|
+
if (r = !0, i = n, a = e.clientX, o = e.clientY, f = t.closest("table"), i === "col") l = bi(t) + (t.colSpan || 1) - 1, u = l >= 0 ? Array.from(f.querySelectorAll("tr")).map((e) => J(e, l)).filter(Boolean).filter((e) => (e.colSpan || 1) === 1) : [], s = u.length > 0 ? u[0].offsetWidth : Math.max(30, Math.round(t.offsetWidth / (t.colSpan || 1))), document.body.style.cursor = "col-resize";
|
|
6226
6300
|
else {
|
|
6227
6301
|
let e = t.closest("tr"), n = (e ? Array.from(f.rows).indexOf(e) : 0) + (t.rowSpan || 1) - 1;
|
|
6228
6302
|
d = f.rows[n] || e, c = d ? d.offsetHeight : 40, document.body.style.cursor = "row-resize";
|
|
@@ -6294,10 +6368,10 @@ var gi = 120, _i = 200, vi = [
|
|
|
6294
6368
|
_scheduleShow(e) {
|
|
6295
6369
|
this._activeTable === e && this._el.style.display !== "none" || (clearTimeout(this._hideTimer), this._hideTimer = null, clearTimeout(this._showTimer), this._showTimer = setTimeout(() => {
|
|
6296
6370
|
this._activeTable = e, this._show();
|
|
6297
|
-
},
|
|
6371
|
+
}, Ci));
|
|
6298
6372
|
}
|
|
6299
6373
|
_scheduleHide() {
|
|
6300
|
-
clearTimeout(this._showTimer), this._showTimer = null, !this._hideTimer && (this._hideTimer = setTimeout(() => this._hide(),
|
|
6374
|
+
clearTimeout(this._showTimer), this._showTimer = null, !this._hideTimer && (this._hideTimer = setTimeout(() => this._hide(), wi));
|
|
6301
6375
|
}
|
|
6302
6376
|
_show() {
|
|
6303
6377
|
this._activeTable && (this._el.style.display = "flex", this._syncShadeStrip(), this._syncBorderColorStrip(), requestAnimationFrame(() => {
|
|
@@ -6346,7 +6420,7 @@ var gi = 120, _i = 200, vi = [
|
|
|
6346
6420
|
if (!t || e === t) return [e];
|
|
6347
6421
|
let n = e.closest("table");
|
|
6348
6422
|
if (!n?.contains(t)) return [e];
|
|
6349
|
-
let { gridMap: r, cellPos: i } =
|
|
6423
|
+
let { gridMap: r, cellPos: i } = Si(n), a = i.get(e), o = i.get(t);
|
|
6350
6424
|
if (!a || !o) return [e];
|
|
6351
6425
|
let s = Math.min(a.r, o.r), c = Math.max(a.r + a.rs - 1, o.r + o.rs - 1), l = Math.min(a.c, o.c), u = Math.max(a.c + a.cs - 1, o.c + o.cs - 1), d = !0;
|
|
6352
6426
|
for (; d;) {
|
|
@@ -6394,7 +6468,7 @@ var gi = 120, _i = 200, vi = [
|
|
|
6394
6468
|
if (!t.length) return;
|
|
6395
6469
|
let n = t[0].closest("table");
|
|
6396
6470
|
if (!n) return;
|
|
6397
|
-
let r = t.map((e) =>
|
|
6471
|
+
let r = t.map((e) => bi(e)), i = e === "left" ? Math.min(...r) : Math.max(...r), a = Array.from(n.querySelectorAll("tr")), o = a.map((t) => e === "left" ? J(t, i) : xi(t, i)), s = a.map((e) => e.closest("thead") !== null);
|
|
6398
6472
|
a.forEach((e, t) => {
|
|
6399
6473
|
e.insertBefore(w(s[t] ? "th" : "td", {}, ["\xA0"]), o[t]);
|
|
6400
6474
|
}), requestAnimationFrame(() => this._positionNear(this._activeTable)), this.context.invoke("editor.afterCommand");
|
|
@@ -6414,7 +6488,7 @@ var gi = 120, _i = 200, vi = [
|
|
|
6414
6488
|
if (!t) return;
|
|
6415
6489
|
let n = Array.from(t.querySelectorAll("tr"));
|
|
6416
6490
|
if (n[0] && n[0].cells.length <= 1) return;
|
|
6417
|
-
let r = [...new Set(e.map((e) =>
|
|
6491
|
+
let r = [...new Set(e.map((e) => bi(e)))];
|
|
6418
6492
|
if (r.length >= (n[0]?.cells.length ?? 1)) return;
|
|
6419
6493
|
let i = [];
|
|
6420
6494
|
r.forEach((e) => {
|
|
@@ -6442,7 +6516,7 @@ var gi = 120, _i = 200, vi = [
|
|
|
6442
6516
|
}
|
|
6443
6517
|
}), n.length < 2) return;
|
|
6444
6518
|
}
|
|
6445
|
-
let { gridMap: r, cellPos: i } =
|
|
6519
|
+
let { gridMap: r, cellPos: i } = Si(t), a = Infinity, o = -Infinity, s = Infinity, c = -Infinity;
|
|
6446
6520
|
if (n.forEach((e) => {
|
|
6447
6521
|
let t = i.get(e);
|
|
6448
6522
|
t && (t.r < a && (a = t.r), t.r + t.rs - 1 > o && (o = t.r + t.rs - 1), t.c < s && (s = t.c), t.c + t.cs - 1 > c && (c = t.c + t.cs - 1));
|
|
@@ -6481,7 +6555,7 @@ var gi = 120, _i = 200, vi = [
|
|
|
6481
6555
|
_unmergeOne(e, t) {
|
|
6482
6556
|
let n = e.colSpan || 1, r = e.rowSpan || 1;
|
|
6483
6557
|
if (n === 1 && r === 1) return;
|
|
6484
|
-
let { cellPos: i } =
|
|
6558
|
+
let { cellPos: i } = Si(t), a = i.get(e);
|
|
6485
6559
|
if (!a) return;
|
|
6486
6560
|
let { r: o, c: s } = a, c = Array.from(t.rows), l = e.tagName.toLowerCase();
|
|
6487
6561
|
if (e.rowSpan = 1, e.colSpan = 1, e.style.verticalAlign = "", n > 1) {
|
|
@@ -6568,7 +6642,7 @@ var gi = 120, _i = 200, vi = [
|
|
|
6568
6642
|
let i = t.closest("table");
|
|
6569
6643
|
if (i) {
|
|
6570
6644
|
if (n) {
|
|
6571
|
-
let t = [...new Set(r.map((e) =>
|
|
6645
|
+
let t = [...new Set(r.map((e) => bi(e)))], n = Array.from(i.querySelectorAll("tr"));
|
|
6572
6646
|
t.forEach((t) => {
|
|
6573
6647
|
n.forEach((n) => {
|
|
6574
6648
|
let r = J(n, t);
|
|
@@ -6598,7 +6672,7 @@ var gi = 120, _i = 200, vi = [
|
|
|
6598
6672
|
let a = w("div", { class: "an-size-popover-title" });
|
|
6599
6673
|
i.appendChild(a);
|
|
6600
6674
|
let o = w("div", { class: "an-context-color-palette" });
|
|
6601
|
-
|
|
6675
|
+
Ti.forEach((e) => {
|
|
6602
6676
|
let n = w("div", {
|
|
6603
6677
|
class: "an-context-color-swatch",
|
|
6604
6678
|
title: e
|
|
@@ -6718,7 +6792,7 @@ var gi = 120, _i = 200, vi = [
|
|
|
6718
6792
|
if (!t) return;
|
|
6719
6793
|
let n = this._getCell();
|
|
6720
6794
|
if (!n) return;
|
|
6721
|
-
let r =
|
|
6795
|
+
let r = bi(n);
|
|
6722
6796
|
if (r === -1) return;
|
|
6723
6797
|
let i = t.querySelector("tbody") || t, a = Array.from(i.querySelectorAll(":scope > tr"));
|
|
6724
6798
|
a.length < 2 || (a.sort((t, n) => {
|
|
@@ -6743,13 +6817,13 @@ var gi = 120, _i = 200, vi = [
|
|
|
6743
6817
|
let t = Array.from(e.querySelectorAll("tr")).map((e) => Array.from(e.querySelectorAll("td, th")).map((e) => `"${(e.textContent || "").trim().replace(/"/g, "\"\"")}"`).join(",")).join("\n"), n = new Blob(["" + t], { type: "text/csv;charset=utf-8;" }), r = URL.createObjectURL(n), i = document.createElement("a");
|
|
6744
6818
|
i.href = r, i.download = "table.csv", i.style.display = "none", document.body.appendChild(i), i.click(), i.remove(), URL.revokeObjectURL(r);
|
|
6745
6819
|
}
|
|
6746
|
-
},
|
|
6820
|
+
}, Di = 100, Oi = 180, ki = /language-(\S+)/, Ai = {
|
|
6747
6821
|
copy: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect x=\"9\" y=\"9\" width=\"13\" height=\"13\" rx=\"2\"/><path d=\"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1\"/></svg>",
|
|
6748
6822
|
wrapOn: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><line x1=\"3\" y1=\"6\" x2=\"21\" y2=\"6\"/><path d=\"M3 12h15a3 3 0 0 1 0 6H3\"/><polyline points=\"6 15 3 18 6 21\"/></svg>",
|
|
6749
6823
|
toParagraph: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M13 4v16\"/><path d=\"M17 4v16\"/><path d=\"M9 4h8a4 4 0 0 1 0 8H9V4z\"/></svg>",
|
|
6750
6824
|
deleteCode: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"3 6 5 6 21 6\"/><path d=\"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2\"/></svg>",
|
|
6751
6825
|
lineNumbers: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><line x1=\"10\" y1=\"6\" x2=\"21\" y2=\"6\"/><line x1=\"10\" y1=\"12\" x2=\"21\" y2=\"12\"/><line x1=\"10\" y1=\"18\" x2=\"21\" y2=\"18\"/><path d=\"M4 6h1v4\"/><path d=\"M4 10h2\"/><path d=\"M6 18H4c0-1 2-2 2-3s-1-2-2-2\"/></svg>"
|
|
6752
|
-
},
|
|
6826
|
+
}, ji = [
|
|
6753
6827
|
["", "Plain text"],
|
|
6754
6828
|
["javascript", "JavaScript"],
|
|
6755
6829
|
["typescript", "TypeScript"],
|
|
@@ -6774,12 +6848,12 @@ var gi = 120, _i = 200, vi = [
|
|
|
6774
6848
|
["kotlin", "Kotlin"],
|
|
6775
6849
|
["swift", "Swift"]
|
|
6776
6850
|
];
|
|
6777
|
-
function
|
|
6851
|
+
function Mi(e, t) {
|
|
6778
6852
|
[...e.classList].forEach((t) => {
|
|
6779
6853
|
t.startsWith("language-") && e.classList.remove(t);
|
|
6780
6854
|
}), t && e.classList.add(`language-${t}`);
|
|
6781
6855
|
}
|
|
6782
|
-
var
|
|
6856
|
+
var Ni = class {
|
|
6783
6857
|
constructor(e) {
|
|
6784
6858
|
this.context = e, this._el = null, this._activePre = null, this._showTimer = null, this._hideTimer = null, this._disposers = [], this._copyBtn = null, this._wrapBtn = null, this._lineNumbersBtn = null, this._langSelect = null, this._prismScript = null;
|
|
6785
6859
|
}
|
|
@@ -6811,10 +6885,10 @@ var Ei = class {
|
|
|
6811
6885
|
class: "an-code-lang-select",
|
|
6812
6886
|
title: e.syntaxLanguage,
|
|
6813
6887
|
"aria-label": e.syntaxAriaLabel
|
|
6814
|
-
}),
|
|
6888
|
+
}), ji.forEach(([e, t]) => {
|
|
6815
6889
|
let n = w("option", { value: e });
|
|
6816
6890
|
n.textContent = t, this._langSelect.appendChild(n);
|
|
6817
|
-
}), this._disposers.push(E(this._langSelect, "change", () => this._onLangChange())), t.appendChild(this._langSelect), t.appendChild(this._sep()), this._copyBtn = this._makeBtn(
|
|
6891
|
+
}), this._disposers.push(E(this._langSelect, "change", () => this._onLangChange())), t.appendChild(this._langSelect), t.appendChild(this._sep()), this._copyBtn = this._makeBtn(Ai.copy, e.copyCode, () => this._copyCode()), t.appendChild(this._copyBtn), t.appendChild(this._sep()), this._wrapBtn = this._makeBtn(Ai.wrapOn, e.toggleWordWrap, () => this._toggleWrap()), t.appendChild(this._wrapBtn), this._lineNumbersBtn = this._makeBtn(Ai.lineNumbers, e.lineNumbers, () => this._toggleLineNumbers()), t.appendChild(this._lineNumbersBtn), t.appendChild(this._sep()), t.appendChild(this._makeBtn(Ai.toParagraph, e.convertToParagraph, () => this._toParagraph())), t.appendChild(this._sep()), t.appendChild(this._makeBtn(Ai.deleteCode, e.deleteCodeBlock, () => this._delete(), !0)), this._disposers.push(E(t, "mouseenter", () => this._clearTimers()), E(t, "mouseleave", () => this._scheduleHide())), t;
|
|
6818
6892
|
}
|
|
6819
6893
|
_sep() {
|
|
6820
6894
|
return w("div", { class: "an-link-tooltip-sep" });
|
|
@@ -6832,10 +6906,10 @@ var Ei = class {
|
|
|
6832
6906
|
_scheduleShow(e) {
|
|
6833
6907
|
this._activePre === e && this._el.style.display !== "none" || (clearTimeout(this._hideTimer), this._hideTimer = null, clearTimeout(this._showTimer), this._showTimer = setTimeout(() => {
|
|
6834
6908
|
this._activePre = e, this._syncWrapBtn(), this._syncLineNumbersBtn(), this._syncLangSelect(), this._show(e);
|
|
6835
|
-
},
|
|
6909
|
+
}, Di));
|
|
6836
6910
|
}
|
|
6837
6911
|
_scheduleHide() {
|
|
6838
|
-
clearTimeout(this._showTimer), this._showTimer = null, clearTimeout(this._hideTimer), this._hideTimer = setTimeout(() => this._hide(),
|
|
6912
|
+
clearTimeout(this._showTimer), this._showTimer = null, clearTimeout(this._hideTimer), this._hideTimer = setTimeout(() => this._hide(), Oi);
|
|
6839
6913
|
}
|
|
6840
6914
|
_show(e) {
|
|
6841
6915
|
this._el.style.display = "flex", this._positionNear(e);
|
|
@@ -6862,7 +6936,7 @@ var Ei = class {
|
|
|
6862
6936
|
}
|
|
6863
6937
|
_syncLangSelect() {
|
|
6864
6938
|
if (!this._activePre || !this._langSelect) return;
|
|
6865
|
-
let e = this._activePre.querySelector("code"), t = this._activePre.dataset.language || "", n = e && (
|
|
6939
|
+
let e = this._activePre.querySelector("code"), t = this._activePre.dataset.language || "", n = e && (ki.exec(e.className) || [])[1] || "";
|
|
6866
6940
|
this._langSelect.value = t || n || "";
|
|
6867
6941
|
}
|
|
6868
6942
|
_copyCode() {
|
|
@@ -6905,7 +6979,7 @@ var Ei = class {
|
|
|
6905
6979
|
let e = this._activePre;
|
|
6906
6980
|
if (!e) return;
|
|
6907
6981
|
let t = this._langSelect.value, n = globalThis, r = e.querySelector("code");
|
|
6908
|
-
r || (r = document.createElement("code"), r.innerHTML = e.innerHTML, e.innerHTML = "", e.appendChild(r)),
|
|
6982
|
+
r || (r = document.createElement("code"), r.innerHTML = e.innerHTML, e.innerHTML = "", e.appendChild(r)), Mi(r, t), Mi(e, t), t ? e.dataset.language = t : delete e.dataset.language;
|
|
6909
6983
|
let i = () => {
|
|
6910
6984
|
r.querySelectorAll("br").forEach((e) => e.replaceWith("\n")), n.Prism.highlightElement(r), this.context.invoke("editor.afterCommand");
|
|
6911
6985
|
};
|
|
@@ -6968,21 +7042,21 @@ var Ei = class {
|
|
|
6968
7042
|
let e = this._activePre;
|
|
6969
7043
|
e && (this._hide(), e.remove(), this.context.invoke("editor.afterCommand"));
|
|
6970
7044
|
}
|
|
6971
|
-
},
|
|
6972
|
-
function
|
|
6973
|
-
return
|
|
7045
|
+
}, Pi = null, Fi = null;
|
|
7046
|
+
function Ii() {
|
|
7047
|
+
return Pi ? Promise.resolve(Pi) : (Fi ??= import("./emoji-data-BDQX5kh-.js").then((e) => (Pi = {
|
|
6974
7048
|
EMOJI_CATS: e.EMOJI_CATS,
|
|
6975
7049
|
EMOJI_LIST: e.EMOJI_LIST
|
|
6976
|
-
},
|
|
7050
|
+
}, Pi)), Fi);
|
|
6977
7051
|
}
|
|
6978
|
-
var
|
|
7052
|
+
var Li = class extends W {
|
|
6979
7053
|
_activeCat = "all";
|
|
6980
7054
|
initialize() {
|
|
6981
7055
|
return this;
|
|
6982
7056
|
}
|
|
6983
7057
|
async show() {
|
|
6984
7058
|
if (this._saveRange(), !this._dialog) {
|
|
6985
|
-
let { EMOJI_CATS: e, EMOJI_LIST: t } = await
|
|
7059
|
+
let { EMOJI_CATS: e, EMOJI_LIST: t } = await Ii();
|
|
6986
7060
|
this._dialog || (this._cats = e, this._list = t, this._dialog = this._buildDialog(), document.body.appendChild(this._dialog));
|
|
6987
7061
|
}
|
|
6988
7062
|
this._activeCat = "all", this._searchInput.value = "", this._updateCatTabs(), this._filterEmojis("", "all"), this._open();
|
|
@@ -7075,14 +7149,14 @@ var Ai = class extends W {
|
|
|
7075
7149
|
let s = document.createTextNode(e);
|
|
7076
7150
|
i.insertNode(s), i.setStartAfter(s), i.collapse(!0), r && (r.removeAllRanges(), r.addRange(i)), this._close(), n.focus(), this.context.invoke("editor.afterCommand");
|
|
7077
7151
|
}
|
|
7078
|
-
},
|
|
7079
|
-
function
|
|
7080
|
-
return
|
|
7152
|
+
}, Ri = "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css", zi = null, Bi = null;
|
|
7153
|
+
function Vi() {
|
|
7154
|
+
return zi ? Promise.resolve(zi) : (Bi ??= import("./icon-data-V0Xqv-wX.js").then((e) => (zi = {
|
|
7081
7155
|
ICON_CATEGORIES: e.ICON_CATEGORIES,
|
|
7082
7156
|
ICON_LIST: e.ICON_LIST
|
|
7083
|
-
},
|
|
7157
|
+
}, zi)), Bi);
|
|
7084
7158
|
}
|
|
7085
|
-
var
|
|
7159
|
+
var Hi = class extends W {
|
|
7086
7160
|
_selectedIcon = null;
|
|
7087
7161
|
_activeCat = "all";
|
|
7088
7162
|
initialize() {
|
|
@@ -7090,7 +7164,7 @@ var Fi = class extends W {
|
|
|
7090
7164
|
}
|
|
7091
7165
|
_ensureFontAwesome() {
|
|
7092
7166
|
if (this.context.options.fontAwesomeAutoInject === !1) return;
|
|
7093
|
-
let e = this.context.options.fontAwesomeCDN ||
|
|
7167
|
+
let e = this.context.options.fontAwesomeCDN || Ri;
|
|
7094
7168
|
if (!e || document.getElementById("an-fontawesome-css")) return;
|
|
7095
7169
|
let t = Array.from(document.querySelectorAll("link[rel=\"stylesheet\"]")).map((e) => e.href || "").join(" ");
|
|
7096
7170
|
if (/fontawesome|font-awesome/.test(t) || document.querySelector(".fa-solid, .fas, .far, .fab")) return;
|
|
@@ -7099,7 +7173,7 @@ var Fi = class extends W {
|
|
|
7099
7173
|
}
|
|
7100
7174
|
async show() {
|
|
7101
7175
|
if (this._saveRange(), this._ensureFontAwesome(), !this._dialog) {
|
|
7102
|
-
let { ICON_CATEGORIES: e, ICON_LIST: t } = await
|
|
7176
|
+
let { ICON_CATEGORIES: e, ICON_LIST: t } = await Vi();
|
|
7103
7177
|
this._dialog || (this._cats = e, this._list = t, this._dialog = this._buildDialog(), document.body.appendChild(this._dialog));
|
|
7104
7178
|
}
|
|
7105
7179
|
this._selectedIcon = null, this._activeCat = "all", this._searchInput.value = "", this._grid.querySelectorAll(".an-icon-cell.active").forEach((e) => e.classList.remove("active")), this._insertBtn.setAttribute("disabled", ""), this._updateCatTabs(), this._filterIcons("", "all"), this._updatePreview(null), this._open();
|
|
@@ -7263,7 +7337,7 @@ var Fi = class extends W {
|
|
|
7263
7337
|
_close() {
|
|
7264
7338
|
this._selectedIcon = null, super._close();
|
|
7265
7339
|
}
|
|
7266
|
-
},
|
|
7340
|
+
}, Ui = [
|
|
7267
7341
|
{
|
|
7268
7342
|
category: "Text Formatting",
|
|
7269
7343
|
items: [
|
|
@@ -7336,12 +7410,12 @@ var Fi = class extends W {
|
|
|
7336
7410
|
action: "Show this keyboard shortcuts dialog"
|
|
7337
7411
|
}]
|
|
7338
7412
|
}
|
|
7339
|
-
],
|
|
7413
|
+
], Wi = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect x=\"2\" y=\"7\" width=\"20\" height=\"14\" rx=\"2\"/><path d=\"M6 11h.01M10 11h.01M14 11h.01M18 11h.01M6 15h.01M18 15h.01M10 15h4\"/><path d=\"M7 3l5 4 5-4\"/></svg>", Gi = class extends W {
|
|
7340
7414
|
show() {
|
|
7341
7415
|
this._open();
|
|
7342
7416
|
}
|
|
7343
7417
|
_buildDialog() {
|
|
7344
|
-
let e = this.context.locale.shortcutsDialog, { overlay: t, box: n } = this._buildDialogShell(e.ariaLabel,
|
|
7418
|
+
let e = this.context.locale.shortcutsDialog, { overlay: t, box: n } = this._buildDialogShell(e.ariaLabel, Wi, e.title);
|
|
7345
7419
|
n.classList.add("an-shortcuts-box");
|
|
7346
7420
|
let r = w("button", {
|
|
7347
7421
|
type: "button",
|
|
@@ -7349,7 +7423,7 @@ var Fi = class extends W {
|
|
|
7349
7423
|
"aria-label": e.close,
|
|
7350
7424
|
style: "margin-left:auto"
|
|
7351
7425
|
});
|
|
7352
|
-
r.textContent = "×", this._closeBtn = r, this._firstInput = r, n.querySelector(".an-dialog-header").appendChild(r), (this.context.locale.shortcutsDialog.shortcuts ||
|
|
7426
|
+
r.textContent = "×", this._closeBtn = r, this._firstInput = r, n.querySelector(".an-dialog-header").appendChild(r), (this.context.locale.shortcutsDialog.shortcuts || Ui).forEach(({ category: e, items: t }) => {
|
|
7353
7427
|
let r = w("div", { class: "an-shortcuts-cat" });
|
|
7354
7428
|
r.textContent = e, n.appendChild(r);
|
|
7355
7429
|
let i = w("div", { class: "an-shortcuts-table" });
|
|
@@ -7363,7 +7437,7 @@ var Fi = class extends W {
|
|
|
7363
7437
|
let i = E(r, "click", () => this._close());
|
|
7364
7438
|
return this._disposers.push(i), t;
|
|
7365
7439
|
}
|
|
7366
|
-
},
|
|
7440
|
+
}, Ki = class extends W {
|
|
7367
7441
|
constructor(e) {
|
|
7368
7442
|
super(e), this._findInput = null, this._replaceInput = null, this._caseCheckbox = null, this._counterEl = null, this._closeBtn = null, this._matches = [], this._currentIndex = -1, this._caseSensitive = !1, this._useRegex = !1, this._wholeWord = !1, this._mode = "find", this._queryRegex = null, this._lastQuery = null, this._lastCaseSensitive = null, this._lastUseRegex = null, this._lastWholeWord = null, this._focusTimer = null;
|
|
7369
7443
|
}
|
|
@@ -7606,8 +7680,8 @@ var Fi = class extends W {
|
|
|
7606
7680
|
this._counterEl.textContent = e ? this.context.locale.findReplace.noResults : "";
|
|
7607
7681
|
} else this._counterEl.textContent = `${this._currentIndex + 1} / ${e}`;
|
|
7608
7682
|
}
|
|
7609
|
-
}, Y = 20,
|
|
7610
|
-
function
|
|
7683
|
+
}, Y = 20, qi = "#3b82f6", X = (e, t, n) => Math.min(Math.max(e, t), n);
|
|
7684
|
+
function Ji(e, t, n, r) {
|
|
7611
7685
|
return new Promise((i) => {
|
|
7612
7686
|
let a = (e) => {
|
|
7613
7687
|
let a = document.createElement("canvas");
|
|
@@ -7631,7 +7705,7 @@ function Vi(e, t, n, r) {
|
|
|
7631
7705
|
o.crossOrigin = "anonymous", o.onload = () => a(o), o.onerror = () => i(null), o.src = e.src + (e.src.includes("?") ? "&" : "?") + "_an=" + Date.now();
|
|
7632
7706
|
});
|
|
7633
7707
|
}
|
|
7634
|
-
var
|
|
7708
|
+
var Yi = class {
|
|
7635
7709
|
constructor(e) {
|
|
7636
7710
|
this.context = e, this._img = null, this._box = null, this._imgRect = null, this._scrim = null, this._cropBox = null, this._handles = {}, this._toolbar = null, this._infoEl = null, this._dragDisposers = null, this._disposers = [];
|
|
7637
7711
|
}
|
|
@@ -7662,7 +7736,7 @@ var Hi = class {
|
|
|
7662
7736
|
t.className = "an-crop-box", t.style.cssText = `
|
|
7663
7737
|
position:fixed; z-index:10101;
|
|
7664
7738
|
box-sizing:border-box;
|
|
7665
|
-
border:2px solid ${
|
|
7739
|
+
border:2px solid ${qi};
|
|
7666
7740
|
cursor:move;
|
|
7667
7741
|
outline: none;
|
|
7668
7742
|
`;
|
|
@@ -7727,7 +7801,7 @@ var Hi = class {
|
|
|
7727
7801
|
"position:absolute",
|
|
7728
7802
|
"width:10px",
|
|
7729
7803
|
"height:10px",
|
|
7730
|
-
`background:${
|
|
7804
|
+
`background:${qi}`,
|
|
7731
7805
|
"border:2px solid #fff",
|
|
7732
7806
|
"border-radius:2px",
|
|
7733
7807
|
"box-sizing:border-box",
|
|
@@ -7761,7 +7835,7 @@ var Hi = class {
|
|
|
7761
7835
|
let a = this._makeToolbarBtn("✓ Crop", "#22c55e", () => this._confirm()), o = this._makeToolbarBtn("✕ Cancel", "#94a3b8", () => this._close(!1)), s = document.createElement("label");
|
|
7762
7836
|
s.style.cssText = "color:#94a3b8;font-size:11px;cursor:pointer;display:flex;align-items:center;gap:4px;";
|
|
7763
7837
|
let c = document.createElement("input");
|
|
7764
|
-
c.type = "checkbox", c.style.accentColor =
|
|
7838
|
+
c.type = "checkbox", c.style.accentColor = qi, s.appendChild(c), s.appendChild(document.createTextNode("Lock ratio")), this._arCheck = c, i.appendChild(a), i.appendChild(o), i.appendChild(s), this._toolbar = i, this._disposers.push(E(i, "mousedown", (e) => e.stopPropagation())), document.body.appendChild(e), document.body.appendChild(t), document.body.appendChild(i), this._scrim = e, this._cropBox = t;
|
|
7765
7839
|
}
|
|
7766
7840
|
_makeToolbarBtn(e, t, n) {
|
|
7767
7841
|
let r = document.createElement("button");
|
|
@@ -7846,7 +7920,7 @@ var Hi = class {
|
|
|
7846
7920
|
this._close(!1);
|
|
7847
7921
|
return;
|
|
7848
7922
|
}
|
|
7849
|
-
let f = await
|
|
7923
|
+
let f = await Ji(e, {
|
|
7850
7924
|
x: c,
|
|
7851
7925
|
y: l,
|
|
7852
7926
|
width: u,
|
|
@@ -7890,7 +7964,7 @@ var Hi = class {
|
|
|
7890
7964
|
e?.remove();
|
|
7891
7965
|
}), this._scrim = null, this._cropBox = null, this._toolbar = null, this._infoEl = null, this._handles = {}, this._img = null, this._box = null, this._imgRect = null, this._arCheck = null;
|
|
7892
7966
|
}
|
|
7893
|
-
},
|
|
7967
|
+
}, Xi = class {
|
|
7894
7968
|
constructor(e) {
|
|
7895
7969
|
this.context = e, this.options = e.options, this._banner = null;
|
|
7896
7970
|
}
|
|
@@ -7943,7 +8017,7 @@ var Hi = class {
|
|
|
7943
8017
|
_removeBanner() {
|
|
7944
8018
|
this._banner?.remove(), this._banner = null;
|
|
7945
8019
|
}
|
|
7946
|
-
},
|
|
8020
|
+
}, Zi = class {
|
|
7947
8021
|
constructor(e) {
|
|
7948
8022
|
this.context = e, this.options = e.options, this._disposers = [];
|
|
7949
8023
|
}
|
|
@@ -8089,7 +8163,7 @@ var Hi = class {
|
|
|
8089
8163
|
break;
|
|
8090
8164
|
}
|
|
8091
8165
|
}
|
|
8092
|
-
},
|
|
8166
|
+
}, Qi = [
|
|
8093
8167
|
"#000000",
|
|
8094
8168
|
"#434343",
|
|
8095
8169
|
"#666666",
|
|
@@ -8114,7 +8188,7 @@ var Hi = class {
|
|
|
8114
8188
|
"#c9daf8",
|
|
8115
8189
|
"#d9d2e9",
|
|
8116
8190
|
"#ead1dc"
|
|
8117
|
-
],
|
|
8191
|
+
], $i = "stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"", Z = (e) => `<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" ${$i} style="display:block">${e}</svg>`, ea = {
|
|
8118
8192
|
bold: Z("<path d=\"M6 4h8a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z\"/><path d=\"M6 12h9a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z\"/>"),
|
|
8119
8193
|
italic: Z("<line x1=\"19\" y1=\"4\" x2=\"10\" y2=\"4\"/><line x1=\"14\" y1=\"20\" x2=\"5\" y2=\"20\"/><line x1=\"15\" y1=\"4\" x2=\"9\" y2=\"20\"/>"),
|
|
8120
8194
|
underline: Z("<path d=\"M6 3v7a6 6 0 0 0 6 6 6 6 0 0 0 6-6V3\"/><line x1=\"4\" y1=\"21\" x2=\"20\" y2=\"21\"/>"),
|
|
@@ -8124,7 +8198,7 @@ var Hi = class {
|
|
|
8124
8198
|
hiliteColor: Z("<path d=\"M3 21v-4l9-9 4 4-9 9z\"/><path d=\"M12 8l4 4\"/><line x1=\"3\" y1=\"21\" x2=\"21\" y2=\"21\"/>"),
|
|
8125
8199
|
removeFormat: Z("<path d=\"m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21\"/><path d=\"M22 21H7\"/><path d=\"m5 11 9 9\"/>"),
|
|
8126
8200
|
inlineCode: Z("<path d=\"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1\"/><path d=\"M16 3h1a2 2 0 0 1 2 2v5c0 1.1.9 2 2 2a2 2 0 0 1-2 2v5a2 2 0 0 1-2 2h-1\"/>")
|
|
8127
|
-
},
|
|
8201
|
+
}, ta = {
|
|
8128
8202
|
bold: (e) => e.invoke("editor.bold"),
|
|
8129
8203
|
italic: (e) => e.invoke("editor.italic"),
|
|
8130
8204
|
underline: (e) => e.invoke("editor.underline"),
|
|
@@ -8145,115 +8219,115 @@ var Hi = class {
|
|
|
8145
8219
|
e.invoke("editor.afterCommand");
|
|
8146
8220
|
},
|
|
8147
8221
|
inlineCode: (e) => e.invoke("editor.inlineCode")
|
|
8148
|
-
},
|
|
8222
|
+
}, na = {
|
|
8149
8223
|
bold: () => document.queryCommandState("bold"),
|
|
8150
8224
|
italic: () => document.queryCommandState("italic"),
|
|
8151
8225
|
underline: () => document.queryCommandState("underline"),
|
|
8152
8226
|
strikethrough: () => document.queryCommandState("strikeThrough")
|
|
8153
|
-
},
|
|
8227
|
+
}, ra = {
|
|
8154
8228
|
foreColor: !0,
|
|
8155
8229
|
hiliteColor: !0
|
|
8156
|
-
},
|
|
8230
|
+
}, ia = [
|
|
8157
8231
|
{
|
|
8158
8232
|
name: "editor",
|
|
8159
|
-
Class:
|
|
8233
|
+
Class: Pr
|
|
8160
8234
|
},
|
|
8161
8235
|
{
|
|
8162
8236
|
name: "toolbar",
|
|
8163
|
-
Class:
|
|
8237
|
+
Class: zr
|
|
8164
8238
|
},
|
|
8165
8239
|
{
|
|
8166
8240
|
name: "statusbar",
|
|
8167
|
-
Class:
|
|
8241
|
+
Class: Kr
|
|
8168
8242
|
},
|
|
8169
8243
|
{
|
|
8170
8244
|
name: "clipboard",
|
|
8171
|
-
Class:
|
|
8245
|
+
Class: qr
|
|
8172
8246
|
},
|
|
8173
8247
|
{
|
|
8174
8248
|
name: "placeholder",
|
|
8175
|
-
Class:
|
|
8249
|
+
Class: ei
|
|
8176
8250
|
},
|
|
8177
8251
|
{
|
|
8178
8252
|
name: "contextMenu",
|
|
8179
|
-
Class:
|
|
8253
|
+
Class: Zr
|
|
8180
8254
|
},
|
|
8181
8255
|
{
|
|
8182
8256
|
name: "codeview",
|
|
8183
|
-
Class:
|
|
8257
|
+
Class: ti
|
|
8184
8258
|
},
|
|
8185
8259
|
{
|
|
8186
8260
|
name: "fullscreen",
|
|
8187
|
-
Class:
|
|
8261
|
+
Class: ni
|
|
8188
8262
|
},
|
|
8189
8263
|
{
|
|
8190
8264
|
name: "linkDialog",
|
|
8191
|
-
Class:
|
|
8265
|
+
Class: ii
|
|
8192
8266
|
},
|
|
8193
8267
|
{
|
|
8194
8268
|
name: "imageDialog",
|
|
8195
|
-
Class:
|
|
8269
|
+
Class: oi
|
|
8196
8270
|
},
|
|
8197
8271
|
{
|
|
8198
8272
|
name: "videoDialog",
|
|
8199
|
-
Class:
|
|
8273
|
+
Class: ci
|
|
8200
8274
|
},
|
|
8201
8275
|
{
|
|
8202
8276
|
name: "imageResizer",
|
|
8203
|
-
Class:
|
|
8277
|
+
Class: di
|
|
8204
8278
|
},
|
|
8205
8279
|
{
|
|
8206
8280
|
name: "videoResizer",
|
|
8207
|
-
Class:
|
|
8281
|
+
Class: fi
|
|
8208
8282
|
},
|
|
8209
8283
|
{
|
|
8210
8284
|
name: "linkTooltip",
|
|
8211
|
-
Class:
|
|
8285
|
+
Class: gi
|
|
8212
8286
|
},
|
|
8213
8287
|
{
|
|
8214
8288
|
name: "imageTooltip",
|
|
8215
|
-
Class:
|
|
8289
|
+
Class: vi
|
|
8216
8290
|
},
|
|
8217
8291
|
{
|
|
8218
8292
|
name: "videoTooltip",
|
|
8219
|
-
Class:
|
|
8293
|
+
Class: yi
|
|
8220
8294
|
},
|
|
8221
8295
|
{
|
|
8222
8296
|
name: "tableTooltip",
|
|
8223
|
-
Class:
|
|
8297
|
+
Class: Ei
|
|
8224
8298
|
},
|
|
8225
8299
|
{
|
|
8226
8300
|
name: "codeTooltip",
|
|
8227
|
-
Class:
|
|
8301
|
+
Class: Ni
|
|
8228
8302
|
},
|
|
8229
8303
|
{
|
|
8230
8304
|
name: "emojiDialog",
|
|
8231
|
-
Class:
|
|
8305
|
+
Class: Li
|
|
8232
8306
|
},
|
|
8233
8307
|
{
|
|
8234
8308
|
name: "iconDialog",
|
|
8235
|
-
Class:
|
|
8309
|
+
Class: Hi
|
|
8236
8310
|
},
|
|
8237
8311
|
{
|
|
8238
8312
|
name: "shortcutsDialog",
|
|
8239
|
-
Class:
|
|
8313
|
+
Class: Gi
|
|
8240
8314
|
},
|
|
8241
8315
|
{
|
|
8242
8316
|
name: "findReplace",
|
|
8243
|
-
Class:
|
|
8317
|
+
Class: Ki
|
|
8244
8318
|
},
|
|
8245
8319
|
{
|
|
8246
8320
|
name: "imageCropOverlay",
|
|
8247
|
-
Class:
|
|
8321
|
+
Class: Yi
|
|
8248
8322
|
},
|
|
8249
8323
|
{
|
|
8250
8324
|
name: "autoSaveRestore",
|
|
8251
|
-
Class:
|
|
8325
|
+
Class: Xi,
|
|
8252
8326
|
enabled: (e) => !!e.autoSaveRestore
|
|
8253
8327
|
},
|
|
8254
8328
|
{
|
|
8255
8329
|
name: "markdownShortcuts",
|
|
8256
|
-
Class:
|
|
8330
|
+
Class: Zi,
|
|
8257
8331
|
enabled: (e) => e.markdownShortcuts !== !1
|
|
8258
8332
|
},
|
|
8259
8333
|
{
|
|
@@ -8288,23 +8362,23 @@ var Hi = class {
|
|
|
8288
8362
|
"removeFormat"
|
|
8289
8363
|
];
|
|
8290
8364
|
for (let n of t) {
|
|
8291
|
-
if (!
|
|
8365
|
+
if (!ea[n]) continue;
|
|
8292
8366
|
let t = document.createElement("button");
|
|
8293
|
-
if (t.type = "button", t.dataset.name = n, t.setAttribute("aria-label", n),
|
|
8367
|
+
if (t.type = "button", t.dataset.name = n, t.setAttribute("aria-label", n), ra[n]) {
|
|
8294
8368
|
t.className = "an-bubble-btn an-bubble-btn--color";
|
|
8295
8369
|
let e = document.createElement("span");
|
|
8296
|
-
e.className = "an-bubble-btn-svg", e.innerHTML =
|
|
8370
|
+
e.className = "an-bubble-btn-svg", e.innerHTML = ea[n];
|
|
8297
8371
|
let r = document.createElement("span");
|
|
8298
8372
|
r.className = "an-bubble-color-strip", r.style.background = n === "foreColor" ? "#000000" : "transparent", t.appendChild(e), t.appendChild(r);
|
|
8299
|
-
} else t.className = "an-bubble-btn", t.innerHTML =
|
|
8373
|
+
} else t.className = "an-bubble-btn", t.innerHTML = ea[n];
|
|
8300
8374
|
t.addEventListener("mousedown", (e) => {
|
|
8301
8375
|
e.preventDefault();
|
|
8302
8376
|
}), t.addEventListener("click", (e) => {
|
|
8303
|
-
if (e.preventDefault(), e.stopPropagation(),
|
|
8377
|
+
if (e.preventDefault(), e.stopPropagation(), ra[n]) {
|
|
8304
8378
|
this._openColorPicker(n, t);
|
|
8305
8379
|
return;
|
|
8306
8380
|
}
|
|
8307
|
-
this.context.invoke("editor.focus"),
|
|
8381
|
+
this.context.invoke("editor.focus"), ta[n] && ta[n](this.context), this._syncActive();
|
|
8308
8382
|
}), e.appendChild(t);
|
|
8309
8383
|
}
|
|
8310
8384
|
document.body.appendChild(e), this._el = e, this._btnCache = Array.from(e.querySelectorAll(".an-bubble-btn"));
|
|
@@ -8313,7 +8387,7 @@ var Hi = class {
|
|
|
8313
8387
|
let e = document.createElement("div");
|
|
8314
8388
|
e.className = "an-bubble-color-picker", e.style.display = "none", e.addEventListener("mousedown", (e) => e.preventDefault());
|
|
8315
8389
|
let t = document.createElement("div");
|
|
8316
|
-
t.className = "an-context-color-palette",
|
|
8390
|
+
t.className = "an-context-color-palette", Qi.forEach((e) => {
|
|
8317
8391
|
let n = document.createElement("div");
|
|
8318
8392
|
n.className = "an-context-color-swatch", n.title = e, n.style.background = e, n.setAttribute("role", "button"), n.setAttribute("aria-label", e), n.addEventListener("click", (t) => {
|
|
8319
8393
|
t.stopPropagation(), this._applyColor(this._pickerType, e);
|
|
@@ -8381,7 +8455,7 @@ var Hi = class {
|
|
|
8381
8455
|
}
|
|
8382
8456
|
_syncActive() {
|
|
8383
8457
|
this._btnCache && this._btnCache.forEach((e) => {
|
|
8384
|
-
let t =
|
|
8458
|
+
let t = na[e.dataset.name];
|
|
8385
8459
|
e.classList.toggle("an-active", !!t?.());
|
|
8386
8460
|
});
|
|
8387
8461
|
}
|
|
@@ -8820,39 +8894,39 @@ var Hi = class {
|
|
|
8820
8894
|
];
|
|
8821
8895
|
//#endregion
|
|
8822
8896
|
//#region src/js/core/lists.js
|
|
8823
|
-
function
|
|
8897
|
+
function aa(e) {
|
|
8824
8898
|
return e[e.length - 1];
|
|
8825
8899
|
}
|
|
8826
|
-
function
|
|
8900
|
+
function oa(e) {
|
|
8827
8901
|
return e[0];
|
|
8828
8902
|
}
|
|
8829
|
-
function
|
|
8903
|
+
function sa(e, t = 1) {
|
|
8830
8904
|
return e.slice(0, e.length - t);
|
|
8831
8905
|
}
|
|
8832
|
-
function
|
|
8906
|
+
function ca(e, t = 1) {
|
|
8833
8907
|
return e.slice(t);
|
|
8834
8908
|
}
|
|
8835
|
-
function
|
|
8909
|
+
function la(e) {
|
|
8836
8910
|
return e.flat();
|
|
8837
8911
|
}
|
|
8838
|
-
function
|
|
8912
|
+
function ua(e) {
|
|
8839
8913
|
return [...new Set(e)];
|
|
8840
8914
|
}
|
|
8841
|
-
function
|
|
8915
|
+
function da(e, t) {
|
|
8842
8916
|
let n = [];
|
|
8843
8917
|
for (let r = 0; r < e.length; r += t) n.push(e.slice(r, r + t));
|
|
8844
8918
|
return n;
|
|
8845
8919
|
}
|
|
8846
|
-
function
|
|
8920
|
+
function fa(e, t) {
|
|
8847
8921
|
return e.reduce((e, n) => {
|
|
8848
8922
|
let r = t(n);
|
|
8849
8923
|
return e[r] || (e[r] = []), e[r].push(n), e;
|
|
8850
8924
|
}, {});
|
|
8851
8925
|
}
|
|
8852
|
-
function
|
|
8926
|
+
function pa(e, t) {
|
|
8853
8927
|
return e.every(t);
|
|
8854
8928
|
}
|
|
8855
|
-
function
|
|
8929
|
+
function ma(e, t) {
|
|
8856
8930
|
return e.some(t);
|
|
8857
8931
|
}
|
|
8858
8932
|
//#endregion
|
|
@@ -8860,7 +8934,7 @@ function sa(e, t) {
|
|
|
8860
8934
|
function Q() {
|
|
8861
8935
|
return globalThis.navigator?.userAgent ?? "";
|
|
8862
8936
|
}
|
|
8863
|
-
var
|
|
8937
|
+
var ha = {
|
|
8864
8938
|
get isChrome() {
|
|
8865
8939
|
return /Chrome\//.test(Q()) && !/Edg\//.test(Q());
|
|
8866
8940
|
},
|
|
@@ -8885,17 +8959,17 @@ var ca = {
|
|
|
8885
8959
|
get modifierKey() {
|
|
8886
8960
|
return /Macintosh/.test(Q()) ? "metaKey" : "ctrlKey";
|
|
8887
8961
|
}
|
|
8888
|
-
},
|
|
8962
|
+
}, ga = { ...k }, $ = /* @__PURE__ */ new WeakMap(), _a = {
|
|
8889
8963
|
create(e, t = {}) {
|
|
8890
|
-
let n =
|
|
8964
|
+
let n = va(e).map((e) => {
|
|
8891
8965
|
if ($.has(e)) return $.get(e);
|
|
8892
|
-
let n = new
|
|
8966
|
+
let n = new wn(e, t);
|
|
8893
8967
|
return n.initialize(), $.set(e, n), n;
|
|
8894
8968
|
});
|
|
8895
8969
|
return n.length === 1 ? n[0] : n;
|
|
8896
8970
|
},
|
|
8897
8971
|
destroy(e) {
|
|
8898
|
-
|
|
8972
|
+
va(e).forEach((e) => {
|
|
8899
8973
|
let t = $.get(e);
|
|
8900
8974
|
t && (t.destroy(), $.delete(e));
|
|
8901
8975
|
});
|
|
@@ -8911,20 +8985,20 @@ var ca = {
|
|
|
8911
8985
|
Object.assign(k, e);
|
|
8912
8986
|
},
|
|
8913
8987
|
resetDefaults() {
|
|
8914
|
-
Object.keys(k).forEach((e) => delete k[e]), Object.assign(k,
|
|
8988
|
+
Object.keys(k).forEach((e) => delete k[e]), Object.assign(k, ga);
|
|
8915
8989
|
},
|
|
8916
8990
|
registerModule(e, t) {
|
|
8917
|
-
|
|
8991
|
+
bn.set(e, t);
|
|
8918
8992
|
},
|
|
8919
8993
|
use(e, t = {}) {
|
|
8920
8994
|
if (!e || typeof e.name != "string") throw TypeError("[AutumnNote] AutumnNote.use: plugin must have a string `name` property.");
|
|
8921
|
-
return
|
|
8995
|
+
return Cn.has(e.name) ? (console.warn(`[AutumnNote] Plugin "${e.name}" already registered globally. Skipping.`), this) : (Array.isArray(e.buttons) && e.buttons.forEach((e) => lt(e)), Cn.set(e.name, {
|
|
8922
8996
|
plugin: e,
|
|
8923
8997
|
options: t
|
|
8924
8998
|
}), this);
|
|
8925
8999
|
},
|
|
8926
9000
|
hasPlugin(e) {
|
|
8927
|
-
return
|
|
9001
|
+
return Cn.has(e);
|
|
8928
9002
|
},
|
|
8929
9003
|
registerButton(e) {
|
|
8930
9004
|
return lt(e), this;
|
|
@@ -8940,13 +9014,13 @@ var ca = {
|
|
|
8940
9014
|
buttons: Zt,
|
|
8941
9015
|
version: "2.5.0"
|
|
8942
9016
|
};
|
|
8943
|
-
function
|
|
9017
|
+
function va(e) {
|
|
8944
9018
|
return typeof e == "string" ? Array.from(document.querySelectorAll(e)) : e instanceof Element ? [e] : e instanceof NodeList || Array.isArray(e) ? Array.from(e) : [];
|
|
8945
9019
|
}
|
|
8946
9020
|
//#endregion
|
|
8947
9021
|
//#region src/js/index.js
|
|
8948
|
-
|
|
9022
|
+
Sn(ia);
|
|
8949
9023
|
//#endregion
|
|
8950
|
-
export {
|
|
9024
|
+
export { wn as Context, d as ELEMENT_NODE, Or as SUPPORTED_LANGS, f as TEXT_NODE, ge as WrappedRange, ct as _buttonRegistry, vt as alignCenterBtn, bt as alignJustifyBtn, _t as alignLeftBtn, yt as alignRightBtn, pa as all, ne as ancestors, ma as any, Yt as backColorBtn, dt as boldBtn, Zt as buttons, Kt as checklistBtn, re as children, da as chunk, e as clamp, S as closest, C as closestPara, Bt as codeviewBtn, be as collapsedRange, r as compose, w as createElement, ve as currentRange, t as debounce, _a as default, k as defaultOptions, Xt as defaultToolbar, Mr as detectLang, It as directionBtn, jt as emojiBtn, ha as env, Ut as findBtn, Wt as findReplaceBtn, oa as first, la as flatten, Lt as fontFamilyBtn, Pt as fontSizeBtn, Jt as foreColorBtn, _e as fromNativeRange, Vt as fullscreenBtn, ut as getButton, fa as groupBy, Dt as hrBtn, Mn as htmlToMarkdown, Mt as iconBtn, i as identity, kt as imageBtn, Ct as indentBtn, sa as initial, Gt as inlineCodeBtn, ce as insertAfter, ee as isAnchor, x as isEditable, p as isElement, ue as isEmpty, s as isFunction, te as isImage, b as isInline, pe as isInsideEditable, P as isKey, _ as isLi, v as isList, Hn as isMarkdown, F as isModifier, a as isNil, g as isPara, l as isPlainObject, xe as isSelectionInside, o as isString, y as isTable, m as isText, h as isVoid, ft as italicBtn, N as key, aa as last, zt as lineHeightBtn, Ot as linkBtn, Qt as locales, he as makeDraggable, Xn as markdownToHTML, c as mergeDeep, ae as nextElement, le as nodeValue, St as olBtn, E as on, wt as outdentBtn, de as outerHtml, Rt as paragraphStyleBtn, fe as placeCaret, ie as prevElement, qt as printBtn, ye as rangeFromElement, u as rect2bnd, Et as redoBtn, lt as registerButton, $t as registerLocale, T as remove, Ft as removeFormatBtn, en as resolveLocale, j as sanitiseHTML, mn as sanitiseToBody, M as sanitiseUrl, Ht as shortcutsBtn, Ce as splitText, mt as strikeBtn, gt as subscriptBtn, ht as superscriptBtn, Nt as tableBtn, ca as tail, n as throttle, me as trapFocus, xt as ulBtn, pt as underlineBtn, Tt as undoBtn, ua as unique, oe as unwrap, At as videoBtn, Se as withSavedRange, se as wrap };
|
|
8951
9025
|
|
|
8952
9026
|
//# sourceMappingURL=autumnnote.es.js.map
|