autumnnote 2.2.0 → 2.3.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 +2 -1
- package/dist/autumnnote.cjs +27 -22
- package/dist/autumnnote.es.js +489 -372
- package/dist/autumnnote.es.js.map +1 -1
- package/dist/autumnnote.min.js +27 -22
- package/dist/autumnnote.umd.js +27 -22
- package/dist/autumnnote.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/autumnnote.es.js
CHANGED
|
@@ -1405,7 +1405,7 @@ function M(e, { allowIframes: t = !1 } = {}) {
|
|
|
1405
1405
|
"AUDIO",
|
|
1406
1406
|
"SOURCE"
|
|
1407
1407
|
].includes(e.tagName), i = e.tagName === "IMG";
|
|
1408
|
-
if (!(t.name === "srcset" ? an(n, { allowData: i }) :
|
|
1408
|
+
if (!(t.name === "srcset" ? an(n, { allowData: i }) : cn(n, {
|
|
1409
1409
|
media: r,
|
|
1410
1410
|
allowData: i
|
|
1411
1411
|
}))) {
|
|
@@ -1445,7 +1445,7 @@ function an(e, { allowData: t = !1 } = {}) {
|
|
|
1445
1445
|
for (let e of n) {
|
|
1446
1446
|
if (/^[\d.]+[xw],?$/i.test(e)) continue;
|
|
1447
1447
|
let n = e.replace(/,+$/, "");
|
|
1448
|
-
if (n && !
|
|
1448
|
+
if (n && !cn(n, {
|
|
1449
1449
|
media: !0,
|
|
1450
1450
|
allowData: t
|
|
1451
1451
|
})) return !1;
|
|
@@ -1462,14 +1462,14 @@ function on(e) {
|
|
|
1462
1462
|
return !1;
|
|
1463
1463
|
}
|
|
1464
1464
|
}
|
|
1465
|
-
function
|
|
1465
|
+
function sn(e, { allowData: t = !1, media: n = t } = {}) {
|
|
1466
1466
|
let r = (e || "").trim();
|
|
1467
|
-
return !r && e == null ? null :
|
|
1467
|
+
return !r && e == null ? null : cn(r, {
|
|
1468
1468
|
media: n,
|
|
1469
1469
|
allowData: t
|
|
1470
1470
|
}) ? e : null;
|
|
1471
1471
|
}
|
|
1472
|
-
function
|
|
1472
|
+
function cn(e, { media: t = !1, allowData: n = !1 } = {}) {
|
|
1473
1473
|
let r = (e || "").trim();
|
|
1474
1474
|
if (!r || n && tn.test(r)) return !0;
|
|
1475
1475
|
try {
|
|
@@ -1481,7 +1481,7 @@ function sn(e, { media: t = !1, allowData: n = !1 } = {}) {
|
|
|
1481
1481
|
}
|
|
1482
1482
|
//#endregion
|
|
1483
1483
|
//#region src/js/renderer.js
|
|
1484
|
-
function
|
|
1484
|
+
function ln(e, t) {
|
|
1485
1485
|
let n = w("div", { class: "an-container" }), r = w("div", {
|
|
1486
1486
|
class: "an-editable",
|
|
1487
1487
|
contenteditable: t.readOnly ? "false" : "true",
|
|
@@ -1504,7 +1504,7 @@ function cn(e, t) {
|
|
|
1504
1504
|
}
|
|
1505
1505
|
//#endregion
|
|
1506
1506
|
//#region src/js/editing/History.js
|
|
1507
|
-
var
|
|
1507
|
+
var un = class {
|
|
1508
1508
|
constructor(e, t = 100, n = 10 * 1024 * 1024) {
|
|
1509
1509
|
this.editable = e, this._limit = t, this._maxBytes = n, this._bytes = 0, this.stack = [], this.stackOffset = -1, this._savePoint();
|
|
1510
1510
|
}
|
|
@@ -1625,7 +1625,7 @@ var ln = class {
|
|
|
1625
1625
|
};
|
|
1626
1626
|
//#endregion
|
|
1627
1627
|
//#region src/js/editing/Table.js
|
|
1628
|
-
function
|
|
1628
|
+
function dn(e, t, n = {}) {
|
|
1629
1629
|
let { headerRow: r = !1 } = n, i = w("table", { class: "an-table" });
|
|
1630
1630
|
if (r && t > 0) {
|
|
1631
1631
|
let t = w("thead"), n = w("tr");
|
|
@@ -1647,9 +1647,9 @@ function un(e, t, n = {}) {
|
|
|
1647
1647
|
}
|
|
1648
1648
|
return i;
|
|
1649
1649
|
}
|
|
1650
|
-
function
|
|
1650
|
+
function fn(e, t, n = {}) {
|
|
1651
1651
|
if (e <= 0 || t <= 0) return;
|
|
1652
|
-
let r =
|
|
1652
|
+
let r = dn(e, t, n), i = globalThis.getSelection();
|
|
1653
1653
|
if (!i || i.rangeCount === 0) return;
|
|
1654
1654
|
let a = i.getRangeAt(0);
|
|
1655
1655
|
try {
|
|
@@ -1690,7 +1690,7 @@ function dn(e, t, n = {}) {
|
|
|
1690
1690
|
}
|
|
1691
1691
|
//#endregion
|
|
1692
1692
|
//#region src/js/core/key.js
|
|
1693
|
-
var
|
|
1693
|
+
var N = {
|
|
1694
1694
|
BACKSPACE: "Backspace",
|
|
1695
1695
|
TAB: "Tab",
|
|
1696
1696
|
ENTER: "Enter",
|
|
@@ -1729,16 +1729,16 @@ var P = {
|
|
|
1729
1729
|
SLASH: "/",
|
|
1730
1730
|
PERIOD: "."
|
|
1731
1731
|
};
|
|
1732
|
-
function
|
|
1732
|
+
function P(e, t) {
|
|
1733
1733
|
return e.key === t || e.key === t.toUpperCase();
|
|
1734
1734
|
}
|
|
1735
|
-
function
|
|
1736
|
-
return (e.ctrlKey || e.metaKey) &&
|
|
1735
|
+
function F(e, t) {
|
|
1736
|
+
return (e.ctrlKey || e.metaKey) && P(e, t);
|
|
1737
1737
|
}
|
|
1738
1738
|
//#endregion
|
|
1739
1739
|
//#region src/js/editing/Typing.js
|
|
1740
|
-
var
|
|
1741
|
-
function
|
|
1740
|
+
var pn = /\bfa-/, I = (e) => !!(e?.nodeName === "I" && pn.test(e.className || "")), mn = (e) => e?.nodeType === Node.TEXT_NODE && (e.textContent === "" || e.textContent === "");
|
|
1741
|
+
function hn(e, t) {
|
|
1742
1742
|
try {
|
|
1743
1743
|
let n = document.createRange();
|
|
1744
1744
|
return n.setStart(e.startContainer, e.startOffset), n.setEnd(t, t.childNodes.length), n.extractContents();
|
|
@@ -1746,21 +1746,21 @@ function mn(e, t) {
|
|
|
1746
1746
|
return document.createDocumentFragment();
|
|
1747
1747
|
}
|
|
1748
1748
|
}
|
|
1749
|
-
function
|
|
1749
|
+
function gn(e, t, n = {}) {
|
|
1750
1750
|
let r = (e) => {
|
|
1751
1751
|
let t = globalThis.getSelection();
|
|
1752
1752
|
if (!t) return !1;
|
|
1753
1753
|
let n = document.createRange();
|
|
1754
1754
|
return e(n), n.collapse(!0), t.removeAllRanges(), t.addRange(n), !0;
|
|
1755
1755
|
};
|
|
1756
|
-
if (
|
|
1756
|
+
if (P(e, N.BACKSPACE)) {
|
|
1757
1757
|
let t = globalThis.getSelection();
|
|
1758
1758
|
if (t?.rangeCount > 0) {
|
|
1759
1759
|
let n = t.getRangeAt(0);
|
|
1760
1760
|
if (n.collapsed && n.startContainer.nodeType === Node.TEXT_NODE) {
|
|
1761
1761
|
let r = n.startContainer;
|
|
1762
|
-
if (n.startOffset === 0 &&
|
|
1763
|
-
if (n.startOffset === 1 && r.textContent === "" &&
|
|
1762
|
+
if (n.startOffset === 0 && I(r.previousSibling)) return e.preventDefault(), r.previousSibling.remove(), !0;
|
|
1763
|
+
if (n.startOffset === 1 && r.textContent === "" && I(r.previousSibling)) {
|
|
1764
1764
|
e.preventDefault();
|
|
1765
1765
|
let n = r.parentNode, i = r.previousSibling, a = i.previousSibling;
|
|
1766
1766
|
i.remove(), r.remove();
|
|
@@ -1771,17 +1771,17 @@ function hn(e, t, n = {}) {
|
|
|
1771
1771
|
}
|
|
1772
1772
|
return !1;
|
|
1773
1773
|
}
|
|
1774
|
-
if (
|
|
1774
|
+
if (P(e, N.LEFT) || P(e, N.RIGHT)) {
|
|
1775
1775
|
let t = globalThis.getSelection();
|
|
1776
1776
|
if (!t || t.rangeCount === 0) return !1;
|
|
1777
1777
|
let n = t.getRangeAt(0);
|
|
1778
1778
|
if (!n.collapsed) return !1;
|
|
1779
|
-
let i = n.startContainer, a =
|
|
1779
|
+
let i = n.startContainer, a = P(e, N.LEFT);
|
|
1780
1780
|
if (i.nodeType === Node.TEXT_NODE) {
|
|
1781
1781
|
let t = i;
|
|
1782
|
-
if (a && n.startOffset === 1 && t.textContent === "" &&
|
|
1783
|
-
if (a && n.startOffset === 0 &&
|
|
1784
|
-
if (!a && n.startOffset === t.textContent.length &&
|
|
1782
|
+
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));
|
|
1783
|
+
if (a && n.startOffset === 0 && mn(t.previousSibling) && I(t.previousSibling.previousSibling)) return e.preventDefault(), r((e) => e.setStartBefore(t.previousSibling.previousSibling));
|
|
1784
|
+
if (!a && n.startOffset === t.textContent.length && I(t.nextSibling)) {
|
|
1785
1785
|
let n = t.nextSibling, i = n.nextSibling;
|
|
1786
1786
|
if (e.preventDefault(), i?.nodeType === Node.TEXT_NODE) {
|
|
1787
1787
|
let e = +!!(i.textContent || "").startsWith("");
|
|
@@ -1789,7 +1789,7 @@ function hn(e, t, n = {}) {
|
|
|
1789
1789
|
}
|
|
1790
1790
|
return r((e) => e.setStartAfter(n));
|
|
1791
1791
|
}
|
|
1792
|
-
if (!a && n.startOffset === t.textContent.length &&
|
|
1792
|
+
if (!a && n.startOffset === t.textContent.length && mn(t.nextSibling) && I(t.nextSibling.nextSibling)) {
|
|
1793
1793
|
let n = t.nextSibling.nextSibling, i = n.nextSibling;
|
|
1794
1794
|
if (e.preventDefault(), i?.nodeType === Node.TEXT_NODE) {
|
|
1795
1795
|
let e = +!!(i.textContent || "").startsWith("");
|
|
@@ -1802,12 +1802,12 @@ function hn(e, t, n = {}) {
|
|
|
1802
1802
|
let t = i;
|
|
1803
1803
|
if (a && n.startOffset > 0) {
|
|
1804
1804
|
let i = t.childNodes[n.startOffset - 1];
|
|
1805
|
-
if (
|
|
1806
|
-
if (
|
|
1805
|
+
if (I(i)) return e.preventDefault(), r((e) => e.setStartBefore(i));
|
|
1806
|
+
if (mn(i) && I(i.previousSibling)) return e.preventDefault(), r((e) => e.setStartBefore(i.previousSibling));
|
|
1807
1807
|
}
|
|
1808
1808
|
if (!a && n.startOffset < t.childNodes.length) {
|
|
1809
1809
|
let i = t.childNodes[n.startOffset];
|
|
1810
|
-
if (
|
|
1810
|
+
if (I(i)) {
|
|
1811
1811
|
let t = i.nextSibling;
|
|
1812
1812
|
if (e.preventDefault(), t?.nodeType === Node.TEXT_NODE) {
|
|
1813
1813
|
let e = +!!(t.textContent || "").startsWith("");
|
|
@@ -1815,7 +1815,7 @@ function hn(e, t, n = {}) {
|
|
|
1815
1815
|
}
|
|
1816
1816
|
return r((e) => e.setStartAfter(i));
|
|
1817
1817
|
}
|
|
1818
|
-
if (
|
|
1818
|
+
if (mn(i) && I(i.nextSibling)) {
|
|
1819
1819
|
let t = i.nextSibling, n = t.nextSibling;
|
|
1820
1820
|
if (e.preventDefault(), n?.nodeType === Node.TEXT_NODE) {
|
|
1821
1821
|
let e = +!!(n.textContent || "").startsWith("");
|
|
@@ -1826,7 +1826,7 @@ function hn(e, t, n = {}) {
|
|
|
1826
1826
|
}
|
|
1827
1827
|
}
|
|
1828
1828
|
}
|
|
1829
|
-
if (
|
|
1829
|
+
if (P(e, N.TAB)) {
|
|
1830
1830
|
let r = ve(t);
|
|
1831
1831
|
if (!r) return !1;
|
|
1832
1832
|
let i = C(r.sc, t);
|
|
@@ -1834,8 +1834,8 @@ function hn(e, t, n = {}) {
|
|
|
1834
1834
|
if (i?.nodeName.toUpperCase() === "PRE") return e.shiftKey ? !1 : (e.preventDefault(), D("insertText", " ".repeat(n.tabSize || 4)), !0);
|
|
1835
1835
|
if (n.tabSize) return e.shiftKey ? !1 : (e.preventDefault(), D("insertText", " ".repeat(n.tabSize)), !0);
|
|
1836
1836
|
}
|
|
1837
|
-
if (
|
|
1838
|
-
if (
|
|
1837
|
+
if (P(e, N.ENTER) && e.shiftKey) return e.preventDefault(), D("insertLineBreak"), !0;
|
|
1838
|
+
if (P(e, N.ENTER) && !e.shiftKey) {
|
|
1839
1839
|
let n = ve(t);
|
|
1840
1840
|
if (!n) return !1;
|
|
1841
1841
|
let r = n.sc, i = r.nodeType === 3 ? r.parentElement : r;
|
|
@@ -1869,7 +1869,7 @@ function hn(e, t, n = {}) {
|
|
|
1869
1869
|
if (r.deleteContents(), n.rangeCount === 0 || !o.isConnected) return !0;
|
|
1870
1870
|
r = n.getRangeAt(0);
|
|
1871
1871
|
}
|
|
1872
|
-
let i =
|
|
1872
|
+
let i = hn(r, o), a = document.createElement("li"), s = document.createElement("input");
|
|
1873
1873
|
s.type = "checkbox", s.setAttribute("contenteditable", "false"), a.appendChild(s), i.textContent.replace(/[\u00a0\u200B]/g, "").length > 0 && a.appendChild(i);
|
|
1874
1874
|
let c = a.childNodes[1];
|
|
1875
1875
|
c?.nodeType !== Node.TEXT_NODE && (c = document.createTextNode(""), a.appendChild(c)), o.after(a);
|
|
@@ -1887,19 +1887,39 @@ function hn(e, t, n = {}) {
|
|
|
1887
1887
|
}
|
|
1888
1888
|
//#endregion
|
|
1889
1889
|
//#region src/js/core/markdown.js
|
|
1890
|
-
function
|
|
1891
|
-
return
|
|
1890
|
+
function _n(e) {
|
|
1891
|
+
return wn(new DOMParser().parseFromString(`<body>${e || ""}</body>`, "text/html").body).replace(/\n{3,}/g, "\n\n").trim();
|
|
1892
1892
|
}
|
|
1893
|
-
function
|
|
1893
|
+
function vn(e, t) {
|
|
1894
1894
|
return Array.from(e.children).filter((e) => e.tagName === t.toUpperCase());
|
|
1895
1895
|
}
|
|
1896
|
-
function
|
|
1897
|
-
|
|
1896
|
+
function yn(e) {
|
|
1897
|
+
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`\~`);
|
|
1898
|
+
}
|
|
1899
|
+
function bn(e) {
|
|
1900
|
+
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}`);
|
|
1901
|
+
}
|
|
1902
|
+
function xn(e) {
|
|
1903
|
+
return e.split("\n").map(bn).join("\n");
|
|
1904
|
+
}
|
|
1905
|
+
function Sn(e, t) {
|
|
1906
|
+
let n = " ".repeat(t + 1);
|
|
1907
|
+
return wn(e, t + 1).trim().split("\n").map((e, t) => t === 0 || e.trim() === "" || e.startsWith(n) ? e : n + e).join("\n");
|
|
1908
|
+
}
|
|
1909
|
+
function Cn(e, t) {
|
|
1910
|
+
let n = e.getAttribute(t) || "", r = /[\s()]/.test(n) ? `<${n}>` : n, i = e.getAttribute("title");
|
|
1911
|
+
return i ? `${r} "${i.replaceAll("\"", String.raw`\"`)}"` : r;
|
|
1912
|
+
}
|
|
1913
|
+
function wn(e, t = 0) {
|
|
1914
|
+
if (e.nodeType === 3) {
|
|
1915
|
+
let t = e.textContent.replace(/\s+/g, " ");
|
|
1916
|
+
return e.parentElement?.closest("pre, code") ? t : yn(t);
|
|
1917
|
+
}
|
|
1898
1918
|
if (e.nodeType !== 1) return "";
|
|
1899
|
-
let n = e, r = n.nodeName.toLowerCase(), i = () => Array.from(n.childNodes).map((e) =>
|
|
1919
|
+
let n = e, r = n.nodeName.toLowerCase(), i = () => Array.from(n.childNodes).map((e) => wn(e, t)).join("");
|
|
1900
1920
|
switch (r) {
|
|
1901
1921
|
case "p":
|
|
1902
|
-
case "div": return `\n\n${i()}\n\n`;
|
|
1922
|
+
case "div": return `\n\n${xn(i())}\n\n`;
|
|
1903
1923
|
case "br": return " \n";
|
|
1904
1924
|
case "h1": return `\n\n# ${i()}\n\n`;
|
|
1905
1925
|
case "h2": return `\n\n## ${i()}\n\n`;
|
|
@@ -1919,9 +1939,13 @@ function vn(e, t = 0) {
|
|
|
1919
1939
|
case "u": return `<u>${i()}</u>`;
|
|
1920
1940
|
case "span": {
|
|
1921
1941
|
let e = n.getAttribute("style") || "";
|
|
1922
|
-
return /\b(color|background-color|font-size)\s*:/.test(e) ? `<span style="${
|
|
1942
|
+
return /\b(color|background-color|font-size)\s*:/.test(e) ? `<span style="${R(e)}">${i()}</span>` : i();
|
|
1943
|
+
}
|
|
1944
|
+
case "code": {
|
|
1945
|
+
if (n.closest("pre")) return i();
|
|
1946
|
+
let e = i(), t = Math.max(0, ...Array.from(e.matchAll(/`+/g), (e) => e[0].length)), r = "`".repeat(t + 1), a = /^`|`$/.test(e) ? " " : "";
|
|
1947
|
+
return `${r}${a}${e}${a}${r}`;
|
|
1923
1948
|
}
|
|
1924
|
-
case "code": return n.closest("pre") ? i() : `\`${i()}\``;
|
|
1925
1949
|
case "pre": {
|
|
1926
1950
|
let e = n.querySelector("code"), t = /language-(\S+)/.exec(e?.className || "");
|
|
1927
1951
|
return `\n\n\`\`\`${t ? t[1] : ""}\n${(e || n).textContent || ""}\n\`\`\`\n\n`;
|
|
@@ -1930,100 +1954,145 @@ function vn(e, t = 0) {
|
|
|
1930
1954
|
let e = i().trim().split("\n");
|
|
1931
1955
|
return `\n\n${e.filter((t, n) => t.trim() !== "" || (e[n - 1] ?? "").trim() !== "").map((e) => e.trim() === "" ? ">" : `> ${e}`).join("\n")}\n\n`;
|
|
1932
1956
|
}
|
|
1933
|
-
case "a": {
|
|
1934
|
-
|
|
1935
|
-
return `[${i()}](${e})`;
|
|
1936
|
-
}
|
|
1937
|
-
case "img": {
|
|
1938
|
-
let e = n.getAttribute("src") || "";
|
|
1939
|
-
return ``;
|
|
1940
|
-
}
|
|
1957
|
+
case "a": return `[${i()}](${Cn(n, "href")})`;
|
|
1958
|
+
case "img": return `})`;
|
|
1941
1959
|
case "ul": {
|
|
1942
|
-
let e =
|
|
1960
|
+
let e = vn(n, "li");
|
|
1943
1961
|
if (!e.length) return i();
|
|
1944
1962
|
let r = " ".repeat(t), a = n.classList.contains("an-checklist"), o = e.map((e) => {
|
|
1945
|
-
let n =
|
|
1946
|
-
return (a || n) && (i = n && n.checked ? "- [x] " : "- [ ] "), `${r}${i}${
|
|
1963
|
+
let n = vn(e, "input").find((e) => e.getAttribute("type") === "checkbox"), i = "- ";
|
|
1964
|
+
return (a || n) && (i = n && n.checked ? "- [x] " : "- [ ] "), `${r}${i}${Sn(e, t)}`;
|
|
1947
1965
|
}).join("\n");
|
|
1948
1966
|
return t === 0 ? `\n\n${o}\n\n` : `\n${o}`;
|
|
1949
1967
|
}
|
|
1950
1968
|
case "ol": {
|
|
1951
|
-
let e =
|
|
1969
|
+
let e = vn(n, "li");
|
|
1952
1970
|
if (!e.length) return i();
|
|
1953
|
-
let r = " ".repeat(t), a = e.map((e, n) => `${r}${
|
|
1954
|
-
return t === 0 ? `\n\n${
|
|
1971
|
+
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}. ${Sn(e, t)}`).join("\n");
|
|
1972
|
+
return t === 0 ? `\n\n${s}\n\n` : `\n${s}`;
|
|
1955
1973
|
}
|
|
1956
1974
|
case "li": return i();
|
|
1957
1975
|
case "hr": return "\n\n---\n\n";
|
|
1958
1976
|
case "table": {
|
|
1959
1977
|
let e = Array.from(n.querySelectorAll("tr"));
|
|
1960
1978
|
if (!e.length) return i();
|
|
1961
|
-
let t = !!
|
|
1979
|
+
let t = !!vn(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) => yn(e.textContent.trim()).replaceAll("|", String.raw`\|`))), a = Math.max(...r.map((e) => e.length)), o = (e) => {
|
|
1962
1980
|
let t = [...e];
|
|
1963
1981
|
for (; t.length < a;) t.push("");
|
|
1964
1982
|
return t;
|
|
1965
|
-
}, s = +!!t, c = t ? o(r[0]) : Array(a).fill(""), l =
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1983
|
+
}, s = +!!t, c = t ? o(r[0]) : Array(a).fill(""), l = Array.from({ length: a }, (t, n) => {
|
|
1984
|
+
let r = e[0]?.children[n], i = /text-align:\s*(left|center|right)/.exec(r?.getAttribute("style") || "")?.[1];
|
|
1985
|
+
return i === "center" ? ":---:" : i === "right" ? "---:" : i === "left" ? ":---" : "---";
|
|
1986
|
+
}), u = "\n\n";
|
|
1987
|
+
u += `| ${c.join(" | ")} |\n`, u += `| ${l.join(" | ")} |\n`;
|
|
1988
|
+
for (let e = s; e < r.length; e++) u += `| ${o(r[e]).join(" | ")} |\n`;
|
|
1989
|
+
return u + "\n";
|
|
1969
1990
|
}
|
|
1970
1991
|
default: return i();
|
|
1971
1992
|
}
|
|
1972
1993
|
}
|
|
1973
|
-
function
|
|
1974
|
-
return
|
|
1994
|
+
function Tn(e) {
|
|
1995
|
+
return String(e ?? "").replace(/^/, "");
|
|
1996
|
+
}
|
|
1997
|
+
function En(e) {
|
|
1998
|
+
let t = Tn(e);
|
|
1999
|
+
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) || /^---\s*\n(?:[\s\S]*?\n)?(?:---|\.\.\.)\s*(?:\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);
|
|
2000
|
+
}
|
|
2001
|
+
var Dn = /^ {0,3}>( ?)(.*)$/, On = /^(?: {4}|\t)\s*\S/, kn = /^( {0,3})(`{3,}|~{3,})[ \t]*(.*)$/;
|
|
2002
|
+
function An(e) {
|
|
2003
|
+
let t = kn.exec(e);
|
|
2004
|
+
if (!t) return null;
|
|
2005
|
+
let [, n, r, i] = t;
|
|
2006
|
+
return r[0] === "`" && i.includes("`") ? null : {
|
|
2007
|
+
marker: r[0],
|
|
2008
|
+
length: r.length,
|
|
2009
|
+
indent: n.length,
|
|
2010
|
+
lang: i.trim().split(/\s+/)[0] || ""
|
|
2011
|
+
};
|
|
1975
2012
|
}
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
2013
|
+
function jn(e, t) {
|
|
2014
|
+
let n = 0, r = 0;
|
|
2015
|
+
for (; r < e.length && n < t;) {
|
|
2016
|
+
if (e[r] === " ") {
|
|
2017
|
+
n += 1, r += 1;
|
|
2018
|
+
continue;
|
|
2019
|
+
}
|
|
2020
|
+
if (e[r] === " ") {
|
|
2021
|
+
let e = 4 - n % 4;
|
|
2022
|
+
if (n + e > t) break;
|
|
2023
|
+
n += e, r += 1;
|
|
2024
|
+
continue;
|
|
2025
|
+
}
|
|
2026
|
+
break;
|
|
2027
|
+
}
|
|
2028
|
+
return e.slice(r);
|
|
1982
2029
|
}
|
|
1983
|
-
|
|
2030
|
+
var Mn = /^ {0,3}([-*_])( *\1){2,}\s*$/, Nn = "";
|
|
2031
|
+
function Pn(e) {
|
|
2032
|
+
let t = Tn(e).replaceAll("\r\n", "\n").replaceAll("\r", "\n").split("\n");
|
|
2033
|
+
t = Rn(t);
|
|
2034
|
+
let n = zn(t);
|
|
2035
|
+
return t = n.clean, In = n.linkDefs, Ln = n.footnoteIds, Fn(t);
|
|
2036
|
+
}
|
|
2037
|
+
function Fn(e) {
|
|
1984
2038
|
let t = [], n = 0;
|
|
1985
2039
|
for (; n < e.length;) {
|
|
1986
|
-
let r = e[n], i =
|
|
2040
|
+
let r = e[n], i = An(r);
|
|
1987
2041
|
if (i) {
|
|
1988
|
-
let r = i[
|
|
1989
|
-
for (n++; n < e.length && !e[n]
|
|
1990
|
-
let o =
|
|
2042
|
+
let r = RegExp(`^ {0,3}\\${i.marker}{${i.length},}[ \t]*$`), a = [];
|
|
2043
|
+
for (n++; n < e.length && !r.test(e[n]);) a.push(rr(jn(e[n], i.indent))), n++;
|
|
2044
|
+
let o = i.lang ? ` class="language-${R(i.lang)}"` : "";
|
|
1991
2045
|
t.push(`<pre><code${o}>${a.join("\n")}</code></pre>`), n++;
|
|
1992
2046
|
continue;
|
|
1993
2047
|
}
|
|
1994
|
-
if (
|
|
2048
|
+
if (On.test(r)) {
|
|
2049
|
+
let r = [];
|
|
2050
|
+
for (; n < e.length && (On.test(e[n]) || e[n].trim() === "");) {
|
|
2051
|
+
if (e[n].trim() === "") {
|
|
2052
|
+
let t = n;
|
|
2053
|
+
for (; t < e.length && e[t].trim() === "";) t++;
|
|
2054
|
+
if (t >= e.length || !On.test(e[t])) break;
|
|
2055
|
+
for (; n < t; n++) r.push("");
|
|
2056
|
+
continue;
|
|
2057
|
+
}
|
|
2058
|
+
r.push(rr(jn(e[n], 4))), n++;
|
|
2059
|
+
}
|
|
2060
|
+
t.push(`<pre><code>${r.join("\n")}</code></pre>`);
|
|
2061
|
+
continue;
|
|
2062
|
+
}
|
|
2063
|
+
if (r.trim() && !Mn.test(r) && !/^#{1,6} /.test(r) && n + 1 < e.length) {
|
|
1995
2064
|
if (/^=+\s*$/.test(e[n + 1])) {
|
|
1996
|
-
t.push(`<h1>${
|
|
2065
|
+
t.push(`<h1>${L(r.trim())}</h1>`), n += 2;
|
|
1997
2066
|
continue;
|
|
1998
2067
|
}
|
|
1999
2068
|
if (/^-{2,}\s*$/.test(e[n + 1])) {
|
|
2000
|
-
t.push(`<h2>${
|
|
2069
|
+
t.push(`<h2>${L(r.trim())}</h2>`), n += 2;
|
|
2001
2070
|
continue;
|
|
2002
2071
|
}
|
|
2003
2072
|
}
|
|
2004
|
-
if (
|
|
2073
|
+
if (Mn.test(r)) {
|
|
2005
2074
|
t.push("<hr>"), n++;
|
|
2006
2075
|
continue;
|
|
2007
2076
|
}
|
|
2008
2077
|
let a = /^(#{1,6})\s+(.+)$/.exec(r);
|
|
2009
2078
|
if (a) {
|
|
2010
2079
|
let e = a[1].length, r = a[2].replace(/(?:^|\s)#+\s*$/, "");
|
|
2011
|
-
t.push(`<h${e}>${
|
|
2080
|
+
t.push(`<h${e}>${L(r)}</h${e}>`), n++;
|
|
2012
2081
|
continue;
|
|
2013
2082
|
}
|
|
2014
|
-
if (
|
|
2083
|
+
if (Dn.test(r)) {
|
|
2015
2084
|
let r = [];
|
|
2016
|
-
for (; n < e.length &&
|
|
2017
|
-
t.push(`<blockquote>${
|
|
2085
|
+
for (; n < e.length && Dn.test(e[n]);) r.push(Dn.exec(e[n])[2]), n++;
|
|
2086
|
+
t.push(`<blockquote>${Fn(r)}</blockquote>`);
|
|
2018
2087
|
continue;
|
|
2019
2088
|
}
|
|
2020
2089
|
if (/^[-*+] /.test(r)) {
|
|
2021
|
-
let { html: r, endIdx: i } =
|
|
2090
|
+
let { html: r, endIdx: i } = Wn(e, n);
|
|
2022
2091
|
t.push(r), n = i;
|
|
2023
2092
|
continue;
|
|
2024
2093
|
}
|
|
2025
|
-
if (/^\d
|
|
2026
|
-
let { html: r, endIdx: i } =
|
|
2094
|
+
if (/^\d+[.)] /.test(r)) {
|
|
2095
|
+
let { html: r, endIdx: i } = Wn(e, n);
|
|
2027
2096
|
t.push(r), n = i;
|
|
2028
2097
|
continue;
|
|
2029
2098
|
}
|
|
@@ -2031,23 +2100,23 @@ function wn(e) {
|
|
|
2031
2100
|
n++;
|
|
2032
2101
|
continue;
|
|
2033
2102
|
}
|
|
2034
|
-
if (
|
|
2035
|
-
let i =
|
|
2103
|
+
if (Hn(e, n)) {
|
|
2104
|
+
let i = Un(r), a = Un(e[n + 1]).map((e) => e.startsWith(":") && e.endsWith(":") ? "center" : e.endsWith(":") ? "right" : e.startsWith(":") ? "left" : null);
|
|
2036
2105
|
n += 2;
|
|
2037
2106
|
let o = [];
|
|
2038
|
-
for (; n < e.length &&
|
|
2039
|
-
let s = (e, t, n) => `<${e}${n ? ` style="text-align:${n}"` : ""}>${
|
|
2107
|
+
for (; n < e.length && e[n].trim() !== "" && Vn(e[n]) > 1;) o.push(Un(e[n])), n++;
|
|
2108
|
+
let s = (e, t, n) => `<${e}${n ? ` style="text-align:${n}"` : ""}>${L(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>` : "";
|
|
2040
2109
|
t.push(`<table>${c}${l}</table>`);
|
|
2041
2110
|
continue;
|
|
2042
2111
|
}
|
|
2043
2112
|
let o = [];
|
|
2044
|
-
for (; n < e.length && e[n].trim() !== "" && !/^(#{1,6} |[-*+] |\d
|
|
2045
|
-
o.length && t.push(`<p>${
|
|
2113
|
+
for (; n < e.length && e[n].trim() !== "" && !/^(#{1,6} |[-*+] |\d+[.)] )/.test(e[n]) && !An(e[n]) && !Dn.test(e[n]) && !Mn.test(e[n]) && !Hn(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++;
|
|
2114
|
+
o.length && t.push(`<p>${L(Bn(o)).replaceAll(Nn, "<br>")}</p>`);
|
|
2046
2115
|
}
|
|
2047
2116
|
return t.join("");
|
|
2048
2117
|
}
|
|
2049
|
-
var
|
|
2050
|
-
function
|
|
2118
|
+
var In = /* @__PURE__ */ new Map(), Ln = /* @__PURE__ */ new Set();
|
|
2119
|
+
function Rn(e) {
|
|
2051
2120
|
if ((e[0] || "").trim() !== "---") return e;
|
|
2052
2121
|
let t = -1;
|
|
2053
2122
|
for (let n = 1; n < e.length; n++) {
|
|
@@ -2061,14 +2130,18 @@ function Dn(e) {
|
|
|
2061
2130
|
let n = t + 1;
|
|
2062
2131
|
return e[n] !== void 0 && e[n].trim() === "" && n++, e.slice(n);
|
|
2063
2132
|
}
|
|
2064
|
-
function
|
|
2133
|
+
function zn(e) {
|
|
2065
2134
|
let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set(), r = [], i = !1, a = /^\[([^\]]+)\]:\s*(\S+)(?:\s+"([^"]*)")?\s*$/, o = /^\[\^([^\]]+)\]:\s*(.+)$/;
|
|
2066
2135
|
for (let s of e) {
|
|
2067
|
-
if (
|
|
2068
|
-
i = !
|
|
2136
|
+
if (i) {
|
|
2137
|
+
/^ {0,3}(?:`{3,}|~{3,})[ \t]*$/.test(s) && (i = !1), r.push(s);
|
|
2069
2138
|
continue;
|
|
2070
2139
|
}
|
|
2071
|
-
if (
|
|
2140
|
+
if (An(s)) {
|
|
2141
|
+
i = !0, r.push(s);
|
|
2142
|
+
continue;
|
|
2143
|
+
}
|
|
2144
|
+
{
|
|
2072
2145
|
let e = o.exec(s);
|
|
2073
2146
|
if (e) {
|
|
2074
2147
|
n.add(e[1]);
|
|
@@ -2091,23 +2164,33 @@ function On(e) {
|
|
|
2091
2164
|
footnoteIds: n
|
|
2092
2165
|
};
|
|
2093
2166
|
}
|
|
2094
|
-
function
|
|
2167
|
+
function Bn(e) {
|
|
2095
2168
|
let t = "";
|
|
2096
2169
|
for (let n = 0; n < e.length; n++) {
|
|
2097
|
-
let r = n === e.length - 1, i = e[n];
|
|
2170
|
+
let r = n === e.length - 1, i = e[n].replace(/^[ \t]+/, "");
|
|
2098
2171
|
if (!r && /\\$/.test(i)) {
|
|
2099
|
-
t += i.replace(/\\$/, "") +
|
|
2172
|
+
t += i.replace(/\\$/, "") + Nn;
|
|
2100
2173
|
continue;
|
|
2101
2174
|
}
|
|
2102
2175
|
if (!r && / {2,}$/.test(i)) {
|
|
2103
|
-
t += i.replace(/ {2,}$/, "") +
|
|
2176
|
+
t += i.replace(/ {2,}$/, "") + Nn;
|
|
2104
2177
|
continue;
|
|
2105
2178
|
}
|
|
2106
2179
|
t += i + (r ? "" : " ");
|
|
2107
2180
|
}
|
|
2108
2181
|
return t;
|
|
2109
2182
|
}
|
|
2110
|
-
function
|
|
2183
|
+
function Vn(e) {
|
|
2184
|
+
return Un(e).length;
|
|
2185
|
+
}
|
|
2186
|
+
function Hn(e, t) {
|
|
2187
|
+
let n = e[t], r = e[t + 1];
|
|
2188
|
+
if (r === void 0 || !n.includes("|")) return !1;
|
|
2189
|
+
if (/^\|.+\|/.test(n)) return /^\|[\s|:-]+\|/.test(r);
|
|
2190
|
+
let i = Un(r);
|
|
2191
|
+
return i.length < 2 || !i.every((e) => /^:?-+:?$/.test(e)) ? !1 : Vn(n) === i.length;
|
|
2192
|
+
}
|
|
2193
|
+
function Un(e) {
|
|
2111
2194
|
let t = e.replace(/^\|/, "").replace(/\|$/, ""), n = [], r = "";
|
|
2112
2195
|
for (let e = 0; e < t.length; e++) {
|
|
2113
2196
|
if (t[e] === "\\" && t[e + 1] === "|") {
|
|
@@ -2122,12 +2205,12 @@ function An(e) {
|
|
|
2122
2205
|
}
|
|
2123
2206
|
return n.push(r), n.map((e) => e.trim());
|
|
2124
2207
|
}
|
|
2125
|
-
function
|
|
2126
|
-
let n = e[t].match(/^(\s*)/)[1].length, r = /^\s*\d
|
|
2208
|
+
function Wn(e, t) {
|
|
2209
|
+
let n = e[t].match(/^(\s*)/)[1].length, r = /^\s*\d+[.)] /.test(e[t]), i = [], a = null, o = !1, s = !1, c = t;
|
|
2127
2210
|
for (; c < e.length;) {
|
|
2128
2211
|
let t = e[c];
|
|
2129
2212
|
if (t.trim() === "") {
|
|
2130
|
-
let t = e[c + 1], a = t === void 0 ? -1 : t.match(/^(\s*)/)[1].length, l = t !== void 0 && /^\s*(?:[-*+]|\d
|
|
2213
|
+
let t = e[c + 1], a = t === void 0 ? -1 : t.match(/^(\s*)/)[1].length, l = t !== void 0 && /^\s*(?:[-*+]|\d+[.)]) /.test(t) && /^\s*\d+[.)] /.test(t) === r && a === n, u = t !== void 0 && t.trim() !== "" && a > n;
|
|
2131
2214
|
if (!i.length || !l && !u) break;
|
|
2132
2215
|
o = !0, s = !0, c++;
|
|
2133
2216
|
continue;
|
|
@@ -2135,8 +2218,8 @@ function jn(e, t) {
|
|
|
2135
2218
|
let l = t.match(/^(\s*)/)[1].length;
|
|
2136
2219
|
if (l < n) break;
|
|
2137
2220
|
if (l === n) {
|
|
2138
|
-
if (!/^\s*(?:[-*+]|\d
|
|
2139
|
-
let e = r ? t.replace(/^\s*\d
|
|
2221
|
+
if (!/^\s*(?:[-*+]|\d+[.)]) /.test(t) || /^\s*\d+[.)] /.test(t) !== r) break;
|
|
2222
|
+
let e = r ? t.replace(/^\s*\d+[.)] /, "") : t.replace(/^\s*[-*+] /, ""), n = !r && /^\[[ xX]\]\s+/.test(e);
|
|
2140
2223
|
if (a === null && (a = n), n !== a) break;
|
|
2141
2224
|
let o = n && e[1].toLowerCase() === "x", l = n ? e.replace(/^\[[ xX]\]\s+/, "") : e;
|
|
2142
2225
|
i.push({
|
|
@@ -2150,8 +2233,8 @@ function jn(e, t) {
|
|
|
2150
2233
|
c++;
|
|
2151
2234
|
continue;
|
|
2152
2235
|
}
|
|
2153
|
-
if (/^\s*(?:[-*+]|\d
|
|
2154
|
-
let t =
|
|
2236
|
+
if (/^\s*(?:[-*+]|\d+[.)]) /.test(t)) {
|
|
2237
|
+
let t = Wn(e, c);
|
|
2155
2238
|
i[i.length - 1].sub += t.html, c = t.endIdx, s = !1;
|
|
2156
2239
|
} else if (s) i[i.length - 1].paras.push(t.trim()), s = !1, c++;
|
|
2157
2240
|
else {
|
|
@@ -2160,82 +2243,105 @@ function jn(e, t) {
|
|
|
2160
2243
|
}
|
|
2161
2244
|
}
|
|
2162
2245
|
}
|
|
2163
|
-
let l = !r && a === !0, u = r ? /^\s*(\d+)
|
|
2246
|
+
let l = !r && a === !0, u = r ? /^\s*(\d+)[.)] /.exec(e[t]) : null, d = u ? Number.parseInt(u[1], 10) : 1, f = r ? d === 1 ? "<ol>" : `<ol start="${d}">` : l ? "<ul class=\"an-checklist\">" : "<ul>", p = r ? "</ol>" : "</ul>";
|
|
2164
2247
|
return {
|
|
2165
2248
|
html: `${f}${i.map(({ paras: e, isCB: t, checked: n, sub: r }) => {
|
|
2166
2249
|
let i = t ? `<input type="checkbox" contenteditable="false"${n ? " checked" : ""}>` : "";
|
|
2167
|
-
return `<li>${o ? e.map((e, t) => `<p>${t === 0 ? i : ""}${
|
|
2250
|
+
return `<li>${o ? e.map((e, t) => `<p>${t === 0 ? i : ""}${L(e)}</p>`).join("") : `${i}${L(e[0])}`}${r}</li>`;
|
|
2168
2251
|
}).join("")}${p}`,
|
|
2169
2252
|
endIdx: c
|
|
2170
2253
|
};
|
|
2171
2254
|
}
|
|
2172
|
-
var
|
|
2173
|
-
function
|
|
2255
|
+
var Gn = /\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g, Kn = "\0";
|
|
2256
|
+
function qn(e) {
|
|
2174
2257
|
let t = [];
|
|
2175
2258
|
return {
|
|
2176
|
-
text: e.replace(
|
|
2259
|
+
text: e.replace(Gn, (e, n) => (t.push(n), `${Kn}${t.length - 1}${Kn}`)),
|
|
2177
2260
|
literals: t
|
|
2178
2261
|
};
|
|
2179
2262
|
}
|
|
2180
|
-
function
|
|
2181
|
-
return e.replace(RegExp(`${
|
|
2263
|
+
function Jn(e, t) {
|
|
2264
|
+
return e.replace(RegExp(`${Kn}(\\d+)${Kn}`, "g"), (e, n) => rr(t[Number(n)]));
|
|
2182
2265
|
}
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2266
|
+
var Yn = String.raw`(<.*?>(?:\s+(?:"[^"]*"|'[^']*'))?|[^)]*)`, Xn = new RegExp(String.raw`!\[([^\]]*)\]\(${Yn}\)`, "g"), Zn = new RegExp(String.raw`\[([^\]]+)\]\(${Yn}\)`, "g");
|
|
2267
|
+
function Qn(e) {
|
|
2268
|
+
let t = e.trim(), n = /^<([^]*?)>\s*(?:"([^"]*)"|'([^']*)')?\s*$/.exec(t);
|
|
2269
|
+
if (n) return {
|
|
2270
|
+
href: n[1],
|
|
2271
|
+
title: n[2] ?? n[3] ?? ""
|
|
2272
|
+
};
|
|
2273
|
+
let r = /^(\S+)\s+(?:"([^"]*)"|'([^']*)')\s*$/.exec(t);
|
|
2274
|
+
return r ? {
|
|
2275
|
+
href: r[1],
|
|
2276
|
+
title: r[2] ?? r[3] ?? ""
|
|
2277
|
+
} : {
|
|
2278
|
+
href: t,
|
|
2279
|
+
title: ""
|
|
2280
|
+
};
|
|
2281
|
+
}
|
|
2282
|
+
function $n(e) {
|
|
2283
|
+
return e = e.replace(Xn, (e, t, n) => {
|
|
2284
|
+
let { href: r, title: i } = Qn(n), a = i ? ` title="${z(i)}"` : "";
|
|
2285
|
+
return `<img src="${z(r)}" alt="${z(t)}"${a} class="an-image">`;
|
|
2286
|
+
}), e = e.replace(Zn, (e, t, n) => {
|
|
2287
|
+
let { href: r, title: i } = Qn(n), a = i ? ` title="${z(i)}"` : "";
|
|
2288
|
+
return `<a href="${z(r)}"${a}>${t}</a>`;
|
|
2289
|
+
}), e = e.replace(/\[([^\]]+)\]\[([^\]]*)\]/g, (e, t, n) => {
|
|
2290
|
+
let r = In.get(ir(n || t).trim().toLowerCase());
|
|
2186
2291
|
if (!r) return e;
|
|
2187
|
-
let i = r.title ? ` title="${
|
|
2188
|
-
return `<a href="${
|
|
2292
|
+
let i = r.title ? ` title="${R(r.title)}"` : "";
|
|
2293
|
+
return `<a href="${R(r.href)}"${i}>${t}</a>`;
|
|
2189
2294
|
}), e = e.replace(/\[([^\]]+)\]/g, (e, t) => {
|
|
2190
|
-
let n =
|
|
2295
|
+
let n = In.get(ir(t).trim().toLowerCase());
|
|
2191
2296
|
if (!n) return e;
|
|
2192
|
-
let r = n.title ? ` title="${
|
|
2193
|
-
return `<a href="${
|
|
2194
|
-
}), e = e.replace(/\[\^([^\]]+)\]/g, (e, t) =>
|
|
2297
|
+
let r = n.title ? ` title="${R(n.title)}"` : "";
|
|
2298
|
+
return `<a href="${R(n.href)}"${r}>${t}</a>`;
|
|
2299
|
+
}), e = e.replace(/\[\^([^\]]+)\]/g, (e, t) => Ln.has(ir(t)) ? `<sup>[${t}]</sup>` : e), e;
|
|
2195
2300
|
}
|
|
2196
|
-
function
|
|
2197
|
-
return e = e.replace(/<(https?:\/\/[^\s&]+?)>/g, (e, t) => `<a href="${
|
|
2301
|
+
function er(e) {
|
|
2302
|
+
return e = e.replace(/<(https?:\/\/[^\s&]+?)>/g, (e, t) => `<a href="${z(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:${z(t)}">${t}</a>`), e = e.replace(/(^|[\s(])(https?:\/\/[^\s()]+)/g, (e, t, n) => {
|
|
2198
2303
|
let r = /[.,;:!?)]+$/.exec(n), i = r ? n.slice(0, -r[0].length) : n;
|
|
2199
2304
|
if (!i) return e;
|
|
2200
2305
|
let a = r ? r[0] : "";
|
|
2201
|
-
return `${t}<a href="${
|
|
2306
|
+
return `${t}<a href="${z(i)}">${i}</a>${a}`;
|
|
2202
2307
|
}), e;
|
|
2203
2308
|
}
|
|
2204
|
-
function
|
|
2309
|
+
function tr(e) {
|
|
2205
2310
|
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 = e.replace(/``([\s\S]*?)``/g, (e, t) => `<code>${t}</code>`), e = e.replace(/`([^`]+)`/g, (e, t) => `<code>${t}</code>`), e;
|
|
2206
2311
|
}
|
|
2207
|
-
function
|
|
2208
|
-
let { text: t, literals: n } =
|
|
2209
|
-
return r =
|
|
2312
|
+
function L(e) {
|
|
2313
|
+
let { text: t, literals: n } = qn(e), r = rr(t);
|
|
2314
|
+
return r = $n(r), r = er(r), r = tr(r), Jn(r, n);
|
|
2210
2315
|
}
|
|
2211
|
-
|
|
2212
|
-
|
|
2316
|
+
var nr = /&(?!#\d+;|#[xX][0-9a-fA-F]+;|[a-zA-Z][a-zA-Z0-9]*;)/g;
|
|
2317
|
+
function rr(e) {
|
|
2318
|
+
return String(e).replace(nr, "&").replaceAll("<", "<").replaceAll(">", ">");
|
|
2213
2319
|
}
|
|
2214
|
-
function
|
|
2320
|
+
function R(e) {
|
|
2215
2321
|
return String(e).replaceAll("&", "&").replaceAll("\"", """).replaceAll("'", "'").replaceAll("<", "<").replaceAll(">", ">");
|
|
2216
2322
|
}
|
|
2217
|
-
function
|
|
2323
|
+
function z(e) {
|
|
2218
2324
|
return String(e).replaceAll("\"", """).replaceAll("'", "'");
|
|
2219
2325
|
}
|
|
2220
|
-
function
|
|
2326
|
+
function ir(e) {
|
|
2221
2327
|
return String(e).replaceAll("<", "<").replaceAll(">", ">").replaceAll("&", "&");
|
|
2222
2328
|
}
|
|
2223
2329
|
//#endregion
|
|
2224
2330
|
//#region src/js/core/detectLang.js
|
|
2225
|
-
function
|
|
2331
|
+
function ar(e) {
|
|
2226
2332
|
if (!e?.trim()) return null;
|
|
2227
2333
|
let t = e.trim();
|
|
2228
2334
|
return /(:\s*(string|number|boolean|void|never|any|unknown)\b|interface\s+\w+\s*\{|type\s+\w+\s*[=<(]|<\w+>\s*[;,)]|readonly\s+\w|enum\s+\w+\s*\{|\?\s*:\s*\w|as\s+\w+\s*[;,)\]])/.test(t) ? "typescript" : /\bprintln!\s*\(|\bprint!\s*\(|\bfn\s+\w+\s*(<[^>]*>)?\s*\(|\blet\s+mut\s|\bpub\s+fn\s|\buse\s+std::|\bimpl\s+\w+|\bOption<|\bResult<\w+/.test(t) ? "rust" : /(<\?php\b|<\?=|\becho\s+.*\$\w|\$this->|\$\w+\s*=\s*\w|\bforeach\s*\(\s*\$|Illuminate\\)/.test(t) ? "php" : /\bpublic\s+(class|static|void|int|String)\s+\w|System\.out\.(print|println)\s*\(|@(Override|Autowired|Component|Service|Controller)\b|import\s+java\.(util|io|lang|net)\.|throws\s+\w+Exception/.test(t) ? "java" : /\bfun\s+\w+\s*\(|\bdata\s+class\s+\w+|\bcompanion\s+object\b|\bval\s+\w+\s*:\s*\w|\bprintln\s*\(/.test(t) ? "kotlin" : /\bguard\s+(let|var)\b|\bprotocol\s+\w+\s*\{|\bextension\s+\w+|\bfunc\s+\w+[^(]*\([^)]*\)\s*->\s*\w|\blet\s+\w+\s*:\s*[A-Z]\w*|\bSwiftUI\b/.test(t) ? "swift" : /\bpackage\s+\w+\b|\bfmt\.(Print|Println|Sprintf|Errorf|Fprintf)\s*\(|:=\s*\w|\bgoroutine\b|\bchan\s+\w|\bgo\s+func\b/.test(t) ? "go" : /\b(const\s+\w|let\s+\w+\s*=|var\s+\w+\s*=|function\s+\w|\=>\s*[{(]|import\s+.*\bfrom\b\s*['"]|require\s*\(|console\.(log|error|warn|info)|document\.\w|window\.\w|async\s+function|\bPromise\b|React\.|useState\s*\(|\.then\s*\()/.test(t) ? "javascript" : /^<!DOCTYPE html/i.test(t) || /<(html|head|body|div|section|article|nav|p|a|img|ul|ol|li|table|form|input|button|script|style)\b[^>]*>/i.test(t) ? "html" : /(^|\n)\s*(\/\/\s+\S|&[:.[\w]|\$\w+\s*:|@(mixin|include|extend|each|if|for|use|forward)\b|#\{)/.test(t) && /[\w#.*&[\]:(),>+~ -]+\s*\{/.test(t) ? "scss" : /(^|\n)\s*[\w#.*:[\]&, +-]+\s*\{[^}]*[\w-]+\s*:[^{}:;]+[;}\n]/m.test(t) && !/<\w|function\s|def\s|:\s*(string|number)/.test(t) ? "css" : /^\s*[{[]/.test(t) && /"\w[\w\s-]*"\s*:/.test(t) && !/\bfunction\b|\bdef\b/.test(t) ? "json" : /(^|\n)\s*(SELECT\s|INSERT\s+INTO|UPDATE\s+\w|DELETE\s+FROM|CREATE\s+(TABLE|DATABASE|INDEX|VIEW)|DROP\s+(TABLE|DATABASE)|ALTER\s+TABLE|WITH\s+\w+\s+AS\s*\()/im.test(t) ? "sql" : /\bdef\s+\w+\s*\([^)]*\)\s*:|(^|\n)\s*class\s+\w+.*:\s*$|(^|\n)\s*import\s+\w|(^|\n)\s*from\s+\w+\s+import\s+|\bprint\s*\(|if\s+__name__\s*==\s*['"]__main__['"]/m.test(t) ? "python" : /\bputs\s+\S|\battr_(accessor|reader|writer)\s|\.each\s+do\s*\|\w+\s*\||\bdo\s*\|\w+\s*\|.*\bend\b|\bdef\s+\w+[^:]*\n[\s\S]*?\bend\b/.test(t) ? "ruby" : /^#!.*\/(ba|z|da|fi|k)?sh\b/m.test(t) || /\b(echo\s+["']|grep\s+|awk\s+|sed\s+['"\\/-]|chmod\s+|sudo\s+|apt(-get)?\s+install|brew\s+install|npm\s+(install|run|start|build)|pip\s+(install|3\s)|docker\s+(run|build|compose)|kubectl\s+|git\s+(clone|add|commit|push|pull|checkout))\b/.test(t) ? "bash" : /\bcout\s*<<|\bcin\s*>>|using\s+namespace\s+std\b|std::\w|\btemplate\s*<\w|\b#include\s*<(iostream|vector|map|set|algorithm|string|memory)>/.test(t) ? "cpp" : /\busing\s+System\b|Console\.(Write|WriteLine)\s*\(|\bget;\s*set;|\basync\s+Task[<\s]|IEnumerable<|\bLINQ\b|\.Select\s*\(|\.Where\s*\(/.test(t) ? "csharp" : /\b#include\s*<(stdio|stdlib|string|math|time|ctype)\.h>|\bprintf\s*\(|\bscanf\s*\(|int\s+main\s*\(\s*(void|int\s+argc)|\bmalloc\s*\(|\bfree\s*\(/.test(t) && !/namespace|cout|cin|std::/.test(t) ? "c" : /^<\?xml\s/i.test(t) || /xmlns:|<\/[\w:]+>/.test(t) ? "xml" : null;
|
|
2229
2335
|
}
|
|
2230
2336
|
//#endregion
|
|
2231
2337
|
//#region src/js/module/Editor.js
|
|
2232
|
-
var
|
|
2338
|
+
var or = class {
|
|
2233
2339
|
constructor(e) {
|
|
2234
2340
|
this.context = e, this.options = e.options, this._history = null, this._disposers = [], this._snapshotTimer = null;
|
|
2235
2341
|
}
|
|
2236
2342
|
initialize() {
|
|
2237
2343
|
let e = this.context.layoutInfo.editable;
|
|
2238
|
-
return this._history = new
|
|
2344
|
+
return this._history = new un(e, this.options.historyLimit || 100, this.options.historyMaxBytes || 10 * 1024 * 1024), this._bindEvents(e), this;
|
|
2239
2345
|
}
|
|
2240
2346
|
destroy() {
|
|
2241
2347
|
this._disposers.forEach((e) => e()), this._disposers = [], this._history = null, clearTimeout(this._snapshotTimer), this._snapshotTimer = null;
|
|
@@ -2312,32 +2418,32 @@ var Un = class {
|
|
|
2312
2418
|
}
|
|
2313
2419
|
_onKeydown(e) {
|
|
2314
2420
|
let t = this.context.layoutInfo.editable;
|
|
2315
|
-
if (!
|
|
2316
|
-
if (
|
|
2421
|
+
if (!gn(e, t, this.options)) {
|
|
2422
|
+
if (F(e, "z") && !e.shiftKey) {
|
|
2317
2423
|
e.preventDefault(), this.undo();
|
|
2318
2424
|
return;
|
|
2319
2425
|
}
|
|
2320
|
-
if (
|
|
2426
|
+
if (F(e, "z") && e.shiftKey || F(e, "y")) {
|
|
2321
2427
|
e.preventDefault(), this.redo();
|
|
2322
2428
|
return;
|
|
2323
2429
|
}
|
|
2324
|
-
if (
|
|
2430
|
+
if (F(e, "b")) {
|
|
2325
2431
|
e.preventDefault(), this.bold();
|
|
2326
2432
|
return;
|
|
2327
2433
|
}
|
|
2328
|
-
if (
|
|
2434
|
+
if (F(e, "i")) {
|
|
2329
2435
|
e.preventDefault(), this.italic();
|
|
2330
2436
|
return;
|
|
2331
2437
|
}
|
|
2332
|
-
if (
|
|
2438
|
+
if (F(e, "u")) {
|
|
2333
2439
|
e.preventDefault(), this.underline();
|
|
2334
2440
|
return;
|
|
2335
2441
|
}
|
|
2336
|
-
if (
|
|
2442
|
+
if (F(e, "k")) {
|
|
2337
2443
|
e.preventDefault(), this.context.invoke("linkDialog.show");
|
|
2338
2444
|
return;
|
|
2339
2445
|
}
|
|
2340
|
-
if (
|
|
2446
|
+
if (F(e, "v") && e.shiftKey) {
|
|
2341
2447
|
this.context.invoke("clipboard.setForcePlain", !0);
|
|
2342
2448
|
return;
|
|
2343
2449
|
}
|
|
@@ -2345,11 +2451,11 @@ var Un = class {
|
|
|
2345
2451
|
e.preventDefault(), this.context.invoke("shortcutsDialog.show");
|
|
2346
2452
|
return;
|
|
2347
2453
|
}
|
|
2348
|
-
if (
|
|
2454
|
+
if (F(e, "f")) {
|
|
2349
2455
|
e.preventDefault(), this.context.invoke("findReplace.show", "find");
|
|
2350
2456
|
return;
|
|
2351
2457
|
}
|
|
2352
|
-
|
|
2458
|
+
F(e, "h") && (e.preventDefault(), this.context.invoke("findReplace.show", "replace")), F(e, "`") && (e.preventDefault(), this.inlineCode());
|
|
2353
2459
|
}
|
|
2354
2460
|
}
|
|
2355
2461
|
_enforceLimit(e) {
|
|
@@ -2427,10 +2533,10 @@ var Un = class {
|
|
|
2427
2533
|
e && (D("insertText", e), this.afterCommand());
|
|
2428
2534
|
}
|
|
2429
2535
|
setMarkdown(e) {
|
|
2430
|
-
this.setHTML(
|
|
2536
|
+
this.setHTML(Pn(e || ""));
|
|
2431
2537
|
}
|
|
2432
2538
|
getMarkdown() {
|
|
2433
|
-
return
|
|
2539
|
+
return _n(this.getHTML());
|
|
2434
2540
|
}
|
|
2435
2541
|
undo() {
|
|
2436
2542
|
this._history && (this._flushPendingSnapshot(), this._history.undo(), this.context.invoke("toolbar.refresh"), this.context.invoke("statusbar.update"), this.context.triggerEvent("change", this.getHTML()));
|
|
@@ -2516,7 +2622,7 @@ var Un = class {
|
|
|
2516
2622
|
if (e?.rangeCount > 0) {
|
|
2517
2623
|
let t = e.getRangeAt(0).commonAncestorContainer, n = t.nodeType === 1 ? t.closest("pre") : t.parentElement?.closest("pre");
|
|
2518
2624
|
if (n && !n.dataset.language) {
|
|
2519
|
-
let e =
|
|
2625
|
+
let e = ar(n.textContent || "");
|
|
2520
2626
|
if (e) {
|
|
2521
2627
|
this.context.invoke("codeTooltip.applyLanguage", n, e);
|
|
2522
2628
|
return;
|
|
@@ -2544,7 +2650,7 @@ var Un = class {
|
|
|
2544
2650
|
insertLink(e, t, n = !1) {
|
|
2545
2651
|
let r = globalThis.getSelection();
|
|
2546
2652
|
if (!r || r.rangeCount === 0) return;
|
|
2547
|
-
let i =
|
|
2653
|
+
let i = sn(e);
|
|
2548
2654
|
if (i) {
|
|
2549
2655
|
if (r.toString().trim().length > 0) {
|
|
2550
2656
|
if (D("createLink", i), n) {
|
|
@@ -2562,7 +2668,7 @@ var Un = class {
|
|
|
2562
2668
|
D("unlink"), this.afterCommand();
|
|
2563
2669
|
}
|
|
2564
2670
|
insertImage(e, t = "", n = "") {
|
|
2565
|
-
let r =
|
|
2671
|
+
let r = sn(e, { allowData: !0 });
|
|
2566
2672
|
if (!r) return;
|
|
2567
2673
|
let i = {
|
|
2568
2674
|
left: "float:left;margin:0 1em 1em 0",
|
|
@@ -2575,7 +2681,7 @@ var Un = class {
|
|
|
2575
2681
|
e && (D("insertHTML", e), this.afterCommand());
|
|
2576
2682
|
}
|
|
2577
2683
|
insertTable(e, t) {
|
|
2578
|
-
|
|
2684
|
+
fn(e, t, { headerRow: this.context.options.tableHeaderRow }), this.afterCommand();
|
|
2579
2685
|
}
|
|
2580
2686
|
_getClosestAnchor() {
|
|
2581
2687
|
let e = globalThis.getSelection();
|
|
@@ -2590,44 +2696,44 @@ var Un = class {
|
|
|
2590
2696
|
_escapeAttr(e) {
|
|
2591
2697
|
return String(e ?? "").replaceAll("&", "&").replaceAll("\"", """).replaceAll("<", "<").replaceAll(">", ">");
|
|
2592
2698
|
}
|
|
2593
|
-
},
|
|
2594
|
-
["bold",
|
|
2595
|
-
["italic",
|
|
2596
|
-
["underline",
|
|
2597
|
-
["strikethrough",
|
|
2598
|
-
["superscript",
|
|
2599
|
-
["subscript",
|
|
2600
|
-
["align-left",
|
|
2601
|
-
["align-center",
|
|
2602
|
-
["align-right",
|
|
2603
|
-
["align-justify",
|
|
2604
|
-
["list-ul",
|
|
2605
|
-
["list-ol",
|
|
2606
|
-
["indent",
|
|
2607
|
-
["outdent",
|
|
2608
|
-
["undo",
|
|
2609
|
-
["redo",
|
|
2610
|
-
["minus",
|
|
2611
|
-
["link",
|
|
2612
|
-
["image",
|
|
2613
|
-
["video",
|
|
2614
|
-
["table",
|
|
2615
|
-
["emoji",
|
|
2616
|
-
["icon",
|
|
2617
|
-
["code",
|
|
2618
|
-
["expand",
|
|
2619
|
-
["foreColor",
|
|
2620
|
-
["backColor",
|
|
2621
|
-
["keyboard",
|
|
2622
|
-
["caption",
|
|
2623
|
-
["remove-format",
|
|
2624
|
-
["direction",
|
|
2625
|
-
["search",
|
|
2626
|
-
["find-replace",
|
|
2627
|
-
["inline-code",
|
|
2628
|
-
["checklist",
|
|
2629
|
-
["print",
|
|
2630
|
-
]),
|
|
2699
|
+
}, sr = (e) => typeof e == "string" ? et(e) : e, B = null, cr = "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" ${cr} style="display:block">${e}</svg>`, H = /* @__PURE__ */ new Map([
|
|
2700
|
+
["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\"/>")],
|
|
2701
|
+
["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\"/>")],
|
|
2702
|
+
["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\"/>")],
|
|
2703
|
+
["strikethrough", V("<path d=\"M17.3 12H6.7\"/><path d=\"M10 6.5C10 5.1 11.1 4 12.5 4c1.4 0 2.5 1.1 2.5 2.5 0 .8-.4 1.5-1 2\"/><path d=\"M14 17.5C14 19 12.9 20 11.5 20 10.1 20 9 18.9 9 17.5c0-.8.4-1.5 1-2\"/>")],
|
|
2704
|
+
["superscript", V("<path d=\"m4 19 8-8\"/><path d=\"m12 19-8-8\"/><path d=\"M20 12h-4c0-1.5.44-2 1.5-2.5S20 8.33 20 7.25C20 6 19 5 17.5 5S15 6 15 7\"/>")],
|
|
2705
|
+
["subscript", V("<path d=\"m4 5 8 8\"/><path d=\"m12 5-8 8\"/><path d=\"M20 21h-4c0-1.5.44-2 1.5-2.5S20 17.33 20 16.25C20 15 19 14 17.5 14S15 15 15 16\"/>")],
|
|
2706
|
+
["align-left", V("<line x1=\"21\" y1=\"6\" x2=\"3\" y2=\"6\"/><line x1=\"15\" y1=\"12\" x2=\"3\" y2=\"12\"/><line x1=\"17\" y1=\"18\" x2=\"3\" y2=\"18\"/>")],
|
|
2707
|
+
["align-center", V("<line x1=\"21\" y1=\"6\" x2=\"3\" y2=\"6\"/><line x1=\"18\" y1=\"12\" x2=\"6\" y2=\"12\"/><line x1=\"21\" y1=\"18\" x2=\"3\" y2=\"18\"/>")],
|
|
2708
|
+
["align-right", V("<line x1=\"21\" y1=\"6\" x2=\"3\" y2=\"6\"/><line x1=\"21\" y1=\"12\" x2=\"9\" y2=\"12\"/><line x1=\"21\" y1=\"18\" x2=\"7\" y2=\"18\"/>")],
|
|
2709
|
+
["align-justify", V("<line x1=\"21\" y1=\"6\" x2=\"3\" y2=\"6\"/><line x1=\"21\" y1=\"12\" x2=\"3\" y2=\"12\"/><line x1=\"21\" y1=\"18\" x2=\"3\" y2=\"18\"/>")],
|
|
2710
|
+
["list-ul", V("<line x1=\"9\" y1=\"6\" x2=\"20\" y2=\"6\"/><line x1=\"9\" y1=\"12\" x2=\"20\" y2=\"12\"/><line x1=\"9\" y1=\"18\" x2=\"20\" y2=\"18\"/><circle cx=\"4\" cy=\"6\" r=\"1\" fill=\"currentColor\" stroke=\"none\"/><circle cx=\"4\" cy=\"12\" r=\"1\" fill=\"currentColor\" stroke=\"none\"/><circle cx=\"4\" cy=\"18\" r=\"1\" fill=\"currentColor\" stroke=\"none\"/>")],
|
|
2711
|
+
["list-ol", V("<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 6h1V3\"/><path d=\"M4 10h2l-2 2h2\"/><path d=\"M4 16.5A1.5 1.5 0 0 1 5.5 15a1.5 1.5 0 0 1 0 3H4\"/>")],
|
|
2712
|
+
["indent", V("<polyline points=\"3 8 7 12 3 16\"/><line x1=\"21\" y1=\"12\" x2=\"11\" y2=\"12\"/><line x1=\"21\" y1=\"6\" x2=\"11\" y2=\"6\"/><line x1=\"21\" y1=\"18\" x2=\"11\" y2=\"18\"/>")],
|
|
2713
|
+
["outdent", V("<polyline points=\"7 8 3 12 7 16\"/><line x1=\"21\" y1=\"12\" x2=\"11\" y2=\"12\"/><line x1=\"21\" y1=\"6\" x2=\"11\" y2=\"6\"/><line x1=\"21\" y1=\"18\" x2=\"11\" y2=\"18\"/>")],
|
|
2714
|
+
["undo", V("<path d=\"M3 7v6h6\"/><path d=\"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13\"/>")],
|
|
2715
|
+
["redo", V("<path d=\"M21 7v6h-6\"/><path d=\"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3L21 13\"/>")],
|
|
2716
|
+
["minus", V("<line x1=\"5\" y1=\"12\" x2=\"19\" y2=\"12\"/>")],
|
|
2717
|
+
["link", V("<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\"/>")],
|
|
2718
|
+
["image", V("<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\"/>")],
|
|
2719
|
+
["video", V("<polygon points=\"23 7 16 12 23 17 23 7\"/><rect x=\"1\" y=\"5\" width=\"15\" height=\"14\" rx=\"2\"/>")],
|
|
2720
|
+
["table", V("<rect x=\"3\" y=\"3\" width=\"18\" height=\"18\" rx=\"1\"/><line x1=\"3\" y1=\"9\" x2=\"21\" y2=\"9\"/><line x1=\"3\" y1=\"15\" x2=\"21\" y2=\"15\"/><line x1=\"9\" y1=\"3\" x2=\"9\" y2=\"21\"/><line x1=\"15\" y1=\"3\" x2=\"15\" y2=\"21\"/>")],
|
|
2721
|
+
["emoji", V("<circle cx=\"12\" cy=\"12\" r=\"10\"/><path d=\"M8.5 14.5s1.5 2.5 3.5 2.5 3.5-2.5 3.5-2.5\"/><circle cx=\"9\" cy=\"9\" r=\"1.5\" fill=\"currentColor\" stroke=\"none\"/><circle cx=\"15\" cy=\"9\" r=\"1.5\" fill=\"currentColor\" stroke=\"none\"/>")],
|
|
2722
|
+
["icon", V("<circle cx=\"8\" cy=\"8\" r=\"3\"/><circle cx=\"16\" cy=\"8\" r=\"3\"/><rect x=\"5\" y=\"13\" width=\"6\" height=\"6\" rx=\"1\"/><rect x=\"13\" y=\"13\" width=\"6\" height=\"6\" rx=\"1\"/>")],
|
|
2723
|
+
["code", V("<polyline points=\"16 18 22 12 16 6\"/><polyline points=\"8 6 2 12 8 18\"/>")],
|
|
2724
|
+
["expand", V("<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\"/>")],
|
|
2725
|
+
["foreColor", V("<path d=\"M4 20L12 4L20 20\"/><line x1=\"7.5\" y1=\"14\" x2=\"16.5\" y2=\"14\"/>")],
|
|
2726
|
+
["backColor", V("<path d=\"M3 21v-4l9-9 4 4-9 9z\"/><path d=\"M12 8l4 4\"/>")],
|
|
2727
|
+
["keyboard", V("<rect x=\"2\" y=\"6\" width=\"20\" height=\"12\" rx=\"2\"/><line x1=\"6\" y1=\"10\" x2=\"6\" y2=\"10\" stroke-width=\"2.5\"/><line x1=\"10\" y1=\"10\" x2=\"10\" y2=\"10\" stroke-width=\"2.5\"/><line x1=\"14\" y1=\"10\" x2=\"14\" y2=\"10\" stroke-width=\"2.5\"/><line x1=\"18\" y1=\"10\" x2=\"18\" y2=\"10\" stroke-width=\"2.5\"/><line x1=\"8\" y1=\"14\" x2=\"16\" y2=\"14\" stroke-width=\"2\"/>")],
|
|
2728
|
+
["caption", V("<rect x=\"3\" y=\"3\" width=\"18\" height=\"11\" rx=\"2\"/><line x1=\"6\" y1=\"18\" x2=\"18\" y2=\"18\"/><line x1=\"9\" y1=\"21\" x2=\"15\" y2=\"21\"/>")],
|
|
2729
|
+
["remove-format", V("<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\"/>")],
|
|
2730
|
+
["direction", V("<path d=\"M12 20V4\"/><path d=\"m9 7-3 3 3 3\"/><path d=\"M4 10h8\"/><path d=\"m15 7 3 3-3 3\"/><path d=\"M20 10h-8\"/>")],
|
|
2731
|
+
["search", V("<circle cx=\"11\" cy=\"11\" r=\"7\"/><line x1=\"21\" y1=\"21\" x2=\"16.65\" y2=\"16.65\"/>")],
|
|
2732
|
+
["find-replace", V("<circle cx=\"10\" cy=\"10\" r=\"6\"/><line x1=\"18\" y1=\"18\" x2=\"14.35\" y2=\"14.35\"/><path d=\"M16 19h6\"/><path d=\"M19 16v6\"/>")],
|
|
2733
|
+
["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\"/>")],
|
|
2734
|
+
["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\"/>")],
|
|
2735
|
+
["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\"/>")]
|
|
2736
|
+
]), lr = /* @__PURE__ */ new Map([
|
|
2631
2737
|
["bold", "fa-bold"],
|
|
2632
2738
|
["italic", "fa-italic"],
|
|
2633
2739
|
["underline", "fa-underline"],
|
|
@@ -2661,7 +2767,7 @@ var Un = class {
|
|
|
2661
2767
|
["inline-code", "fa-code"],
|
|
2662
2768
|
["checklist", "fa-list-check"],
|
|
2663
2769
|
["print", "fa-print"]
|
|
2664
|
-
]),
|
|
2770
|
+
]), ur = class {
|
|
2665
2771
|
constructor(e) {
|
|
2666
2772
|
this.context = e, this.options = e.options, this.el = null, this._disposers = [], this._colorPickerClosers = [], this._refreshRaf = null;
|
|
2667
2773
|
}
|
|
@@ -2671,7 +2777,7 @@ var Un = class {
|
|
|
2671
2777
|
role: "toolbar",
|
|
2672
2778
|
"aria-orientation": "horizontal",
|
|
2673
2779
|
"aria-label": "Editor toolbar"
|
|
2674
|
-
}), this._faReady = this._detectFontAwesome(), this._buildButtons(), this._initRovingFocus(), this._btnMap = new Map((this.options.toolbar || []).flat().map(
|
|
2780
|
+
}), this._faReady = this._detectFontAwesome(), this._buildButtons(), this._initRovingFocus(), this._btnMap = new Map((this.options.toolbar || []).flat().map(sr).filter(Boolean).map((e) => [e.name, e])), this;
|
|
2675
2781
|
}
|
|
2676
2782
|
destroy() {
|
|
2677
2783
|
this._refreshRaf && cancelAnimationFrame(this._refreshRaf), this._refreshRaf = null, this._disposers.forEach((e) => e()), this._disposers = [], this.el?.parentNode && this.el.remove(), this.el = null;
|
|
@@ -2681,7 +2787,7 @@ var Un = class {
|
|
|
2681
2787
|
e.forEach((e) => {
|
|
2682
2788
|
let n = w("div", { class: "an-btn-group" });
|
|
2683
2789
|
e.forEach((e) => {
|
|
2684
|
-
let t =
|
|
2790
|
+
let t = sr(e);
|
|
2685
2791
|
if (!t) {
|
|
2686
2792
|
console.warn(`[AutumnNote] Toolbar: button "${e}" not found in registry. Skipped.`);
|
|
2687
2793
|
return;
|
|
@@ -2900,9 +3006,9 @@ var Un = class {
|
|
|
2900
3006
|
...typeof e.isActive == "function" ? { "aria-pressed": "false" } : {}
|
|
2901
3007
|
}), n = this.options.fontAwesomeClass || "fas";
|
|
2902
3008
|
if (this._faReady) {
|
|
2903
|
-
let r =
|
|
2904
|
-
r ? t.innerHTML = `<i class="${n} ${r}" aria-hidden="true"></i>` :
|
|
2905
|
-
} else
|
|
3009
|
+
let r = lr.get(e.icon) || lr.get(e.name) || null;
|
|
3010
|
+
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;
|
|
3011
|
+
} 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;
|
|
2906
3012
|
let r = E(t, "click", (t) => {
|
|
2907
3013
|
t.preventDefault(), this.context.invoke("editor.focus"), e.action(this.context), this.context.invoke("editor.afterCommand"), this.refresh();
|
|
2908
3014
|
});
|
|
@@ -2946,10 +3052,10 @@ var Un = class {
|
|
|
2946
3052
|
}
|
|
2947
3053
|
_detectFontAwesome() {
|
|
2948
3054
|
if (!this.options.useFontAwesome) return !1;
|
|
2949
|
-
if (
|
|
2950
|
-
if (document.querySelector(".fa, .fas, .far, .fal, .fab, .fa-solid")) return
|
|
3055
|
+
if (B !== null) return B;
|
|
3056
|
+
if (document.querySelector(".fa, .fas, .far, .fal, .fab, .fa-solid")) return B = !0, !0;
|
|
2951
3057
|
let e = Array.from(document.querySelectorAll("link[rel=\"stylesheet\"]")).filter((e) => e.id !== "an-fontawesome-css").map((e) => e.href || "").join(" ");
|
|
2952
|
-
return
|
|
3058
|
+
return B = /fontawesome|font-awesome|use\.fontawesome|all\.css/.test(e), B;
|
|
2953
3059
|
}
|
|
2954
3060
|
refresh() {
|
|
2955
3061
|
this._refreshRaf && cancelAnimationFrame(this._refreshRaf), this._refreshRaf = requestAnimationFrame(() => {
|
|
@@ -2982,27 +3088,27 @@ var Un = class {
|
|
|
2982
3088
|
this.el && (this.el.style.display = "none");
|
|
2983
3089
|
}
|
|
2984
3090
|
rebuild() {
|
|
2985
|
-
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(
|
|
3091
|
+
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(sr).filter(Boolean).map((e) => [e.name, e])), this.refresh();
|
|
2986
3092
|
}
|
|
2987
|
-
},
|
|
2988
|
-
function
|
|
3093
|
+
}, dr = typeof Intl < "u" && typeof Intl.Segmenter == "function" ? new Intl.Segmenter(void 0, { granularity: "word" }) : null;
|
|
3094
|
+
function fr(e) {
|
|
2989
3095
|
let t = e.trim();
|
|
2990
3096
|
if (!t) return 0;
|
|
2991
|
-
if (
|
|
3097
|
+
if (dr) {
|
|
2992
3098
|
let e = 0;
|
|
2993
|
-
for (let n of
|
|
3099
|
+
for (let n of dr.segment(t)) n.isWordLike && e++;
|
|
2994
3100
|
return e;
|
|
2995
3101
|
}
|
|
2996
3102
|
return t.split(/\s+/).length;
|
|
2997
3103
|
}
|
|
2998
|
-
function
|
|
3104
|
+
function pr(e, t, n) {
|
|
2999
3105
|
if (!n) {
|
|
3000
3106
|
e.classList.remove("an-count-warn", "an-count-exceeded");
|
|
3001
3107
|
return;
|
|
3002
3108
|
}
|
|
3003
3109
|
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");
|
|
3004
3110
|
}
|
|
3005
|
-
var
|
|
3111
|
+
var mr = class {
|
|
3006
3112
|
constructor(e) {
|
|
3007
3113
|
this.context = e, this.options = e.options, this.el = null, this._disposers = [], this._wordCountEl = null, this._charCountEl = null;
|
|
3008
3114
|
}
|
|
@@ -3055,17 +3161,17 @@ var Qn = class {
|
|
|
3055
3161
|
}
|
|
3056
3162
|
update() {
|
|
3057
3163
|
if (!this._wordCountEl || !this._charCountEl) return;
|
|
3058
|
-
let e = this.context.layoutInfo.editable.textContent || "", t =
|
|
3059
|
-
this._wordCountEl.textContent = r ? a.wordsLimit(t, r) : a.words(t), this._charCountEl.textContent = i ? a.charsLimit(n, i) : a.chars(n),
|
|
3164
|
+
let e = this.context.layoutInfo.editable.textContent || "", t = fr(e), n = e.replaceAll("\n", "").length, r = this.options.maxWords || 0, i = this.options.maxChars || 0, a = this.context.locale.statusbar;
|
|
3165
|
+
this._wordCountEl.textContent = r ? a.wordsLimit(t, r) : a.words(t), this._charCountEl.textContent = i ? a.charsLimit(n, i) : a.chars(n), pr(this._wordCountEl, t, r), pr(this._charCountEl, n, i);
|
|
3060
3166
|
}
|
|
3061
3167
|
getWordCount() {
|
|
3062
3168
|
let e = this.context.layoutInfo.editable;
|
|
3063
|
-
return
|
|
3169
|
+
return fr(e.innerText || "");
|
|
3064
3170
|
}
|
|
3065
3171
|
getCharCount() {
|
|
3066
3172
|
return (this.context.layoutInfo.editable.innerText || "").replaceAll("\n", "").length;
|
|
3067
3173
|
}
|
|
3068
|
-
},
|
|
3174
|
+
}, hr = class {
|
|
3069
3175
|
constructor(e) {
|
|
3070
3176
|
this.context = e, this.options = e.options, this._disposers = [];
|
|
3071
3177
|
}
|
|
@@ -3182,8 +3288,8 @@ var Qn = class {
|
|
|
3182
3288
|
}
|
|
3183
3289
|
if (this.options.markdownPaste !== !1) {
|
|
3184
3290
|
let n = t.types.includes("text/html"), r = n ? t.getData("text/html") : "", i = !n || this._isTriviallyPlainHtml(r), a = t.getData("text/plain");
|
|
3185
|
-
if (a && i &&
|
|
3186
|
-
e.preventDefault(), D("insertHTML", M(
|
|
3291
|
+
if (a && i && En(a)) {
|
|
3292
|
+
e.preventDefault(), D("insertHTML", M(Pn(a))), this.context.invoke("editor.afterCommand");
|
|
3187
3293
|
return;
|
|
3188
3294
|
}
|
|
3189
3295
|
}
|
|
@@ -3222,7 +3328,7 @@ var Qn = class {
|
|
|
3222
3328
|
}
|
|
3223
3329
|
let n = new FileReader();
|
|
3224
3330
|
n.onload = (e) => {
|
|
3225
|
-
D("insertHTML", M(
|
|
3331
|
+
D("insertHTML", M(Pn(e.target.result || ""))), this.context.invoke("editor.afterCommand");
|
|
3226
3332
|
}, n.onerror = () => {
|
|
3227
3333
|
let t = `Failed to read dropped markdown file "${e.name}".`;
|
|
3228
3334
|
console.warn(`[AutumnNote] ${t}`), this.context.triggerEvent("pasteError", { message: t });
|
|
@@ -3324,7 +3430,7 @@ var Qn = class {
|
|
|
3324
3430
|
_escapeHTML(e) {
|
|
3325
3431
|
return e.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll("\"", """).replaceAll("'", "'");
|
|
3326
3432
|
}
|
|
3327
|
-
},
|
|
3433
|
+
}, gr = class {
|
|
3328
3434
|
constructor(e) {
|
|
3329
3435
|
this.context = e, this.options = e.options, this._disposers = [];
|
|
3330
3436
|
}
|
|
@@ -3341,7 +3447,7 @@ var Qn = class {
|
|
|
3341
3447
|
let e = this.context.layoutInfo.editable, t = document.activeElement === e, n = !(e.textContent.replaceAll("", "").trim().length > 0) && !e.querySelector("img, table, hr, .an-video-wrapper");
|
|
3342
3448
|
e.classList.toggle("an-placeholder", n && !t);
|
|
3343
3449
|
}
|
|
3344
|
-
},
|
|
3450
|
+
}, _r = class {
|
|
3345
3451
|
constructor(e) {
|
|
3346
3452
|
this.context = e, this.options = e.options, this._active = !1, this._textarea = null, this._disposers = [];
|
|
3347
3453
|
}
|
|
@@ -3386,13 +3492,13 @@ var Qn = class {
|
|
|
3386
3492
|
return /^<[^/!][^>]*[^/]>/.test(r) && !t.test(r) && !/^<(br|hr|img|input|link|meta)/.test(r) && n++, i;
|
|
3387
3493
|
}).filter(Boolean).join("\n");
|
|
3388
3494
|
}
|
|
3389
|
-
},
|
|
3495
|
+
}, vr = class {
|
|
3390
3496
|
constructor(e) {
|
|
3391
3497
|
this.context = e, this._active = !1, this._disposers = [], this._prevHeight = "";
|
|
3392
3498
|
}
|
|
3393
3499
|
initialize() {
|
|
3394
3500
|
let e = E(document, "keydown", (e) => {
|
|
3395
|
-
this._active &&
|
|
3501
|
+
this._active && P(e, N.ESCAPE) && this.deactivate();
|
|
3396
3502
|
});
|
|
3397
3503
|
return this._disposers.push(e), this;
|
|
3398
3504
|
}
|
|
@@ -3415,7 +3521,7 @@ var Qn = class {
|
|
|
3415
3521
|
let e = this.context.layoutInfo.container;
|
|
3416
3522
|
e.classList.remove("an-fullscreen"), e.style.height = this._prevHeight, document.body.style.overflow = "", this._active = !1, this.context.invoke("toolbar.refresh");
|
|
3417
3523
|
}
|
|
3418
|
-
},
|
|
3524
|
+
}, U = class {
|
|
3419
3525
|
constructor(e) {
|
|
3420
3526
|
this.context = e, this.options = e.options, this._dialog = null, this._disposers = [], this._savedRange = null, this._firstInput = null, this._removeTrap = null;
|
|
3421
3527
|
}
|
|
@@ -3471,12 +3577,12 @@ var Qn = class {
|
|
|
3471
3577
|
let o = E(i, "click", n), s = E(a, "click", () => this._close());
|
|
3472
3578
|
return this._disposers.push(o, s), r;
|
|
3473
3579
|
}
|
|
3474
|
-
},
|
|
3580
|
+
}, yr = "<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>", br = class extends U {
|
|
3475
3581
|
show() {
|
|
3476
3582
|
this._saveRange(), this._prefill(), this._open();
|
|
3477
3583
|
}
|
|
3478
3584
|
_buildDialog() {
|
|
3479
|
-
let e = this.context.locale.linkDialog, { overlay: t, box: n } = this._buildDialogShell(e.ariaLabel,
|
|
3585
|
+
let e = this.context.locale.linkDialog, { overlay: t, box: n } = this._buildDialogShell(e.ariaLabel, yr, e.title), r = w("label", { class: "an-label" });
|
|
3480
3586
|
r.textContent = e.url;
|
|
3481
3587
|
let i = w("input", {
|
|
3482
3588
|
type: "url",
|
|
@@ -3546,12 +3652,12 @@ var Qn = class {
|
|
|
3546
3652
|
}
|
|
3547
3653
|
this._savedRange && this._savedRange.select(), this.context.invoke("editor.insertLink", e, t, n), this._close();
|
|
3548
3654
|
}
|
|
3549
|
-
},
|
|
3655
|
+
}, xr = "<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>", Sr = class extends U {
|
|
3550
3656
|
show({ beforeInsert: e } = {}) {
|
|
3551
3657
|
this._beforeInsert = typeof e == "function" ? e : null, this._saveRange(), this._urlInput.value = "", this._altInput.value = "", this._fileInput && (this._fileInput.value = ""), this._open();
|
|
3552
3658
|
}
|
|
3553
3659
|
_buildDialog() {
|
|
3554
|
-
let e = this.context.locale.imageDialog, { overlay: t, box: n } = this._buildDialogShell(e.ariaLabel,
|
|
3660
|
+
let e = this.context.locale.imageDialog, { overlay: t, box: n } = this._buildDialogShell(e.ariaLabel, xr, e.title), r = w("label", { class: "an-label" });
|
|
3555
3661
|
r.textContent = e.imageUrl;
|
|
3556
3662
|
let i = w("input", {
|
|
3557
3663
|
type: "url",
|
|
@@ -3678,12 +3784,12 @@ var Qn = class {
|
|
|
3678
3784
|
_close() {
|
|
3679
3785
|
this._beforeInsert = null, super._close();
|
|
3680
3786
|
}
|
|
3681
|
-
},
|
|
3787
|
+
}, Cr = "<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>", wr = class extends U {
|
|
3682
3788
|
show() {
|
|
3683
3789
|
this._saveRange(), this._urlInput.value = "", this._widthInput.value = "560", this._hintEl.textContent = "", this._open();
|
|
3684
3790
|
}
|
|
3685
3791
|
_buildDialog() {
|
|
3686
|
-
let e = this.context.locale.videoDialog, { overlay: t, box: n } = this._buildDialogShell(e.ariaLabel,
|
|
3792
|
+
let e = this.context.locale.videoDialog, { overlay: t, box: n } = this._buildDialogShell(e.ariaLabel, Cr, e.title), r = w("label", { class: "an-label" });
|
|
3687
3793
|
r.textContent = e.videoUrl;
|
|
3688
3794
|
let i = w("input", {
|
|
3689
3795
|
type: "url",
|
|
@@ -3729,7 +3835,7 @@ var Qn = class {
|
|
|
3729
3835
|
this._savedRange && this._savedRange.select(), this.context.invoke("editor.insertVideo", n), this._close();
|
|
3730
3836
|
}
|
|
3731
3837
|
_parseVideoUrl(e) {
|
|
3732
|
-
if (!e || !
|
|
3838
|
+
if (!e || !sn(e, { media: !0 })) return null;
|
|
3733
3839
|
let t = /(?:youtube\.com\/watch\?(?:.*&)?v=|youtube\.com\/embed\/)([a-zA-Z0-9_-]{11})/.exec(e);
|
|
3734
3840
|
if (t) return {
|
|
3735
3841
|
type: "YouTube",
|
|
@@ -3761,10 +3867,10 @@ var Qn = class {
|
|
|
3761
3867
|
return `<div class="an-video-wrapper" style="position:relative;display:block;width:${t}px;max-width:100%"><iframe src="${n.embedUrl}" width="${t}" height="${r}" title="${e}" frameborder="0" allowfullscreen allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" style="display:block;max-width:100%"></iframe><div class="an-video-shield"></div></div>`;
|
|
3762
3868
|
}
|
|
3763
3869
|
if (n?.type === "Direct video") return `<div class="an-video-wrapper" style="position:relative;display:block;width:${t}px;max-width:100%"><video src="${n.embedUrl.replaceAll("\"", "%22")}" width="${t}" height="${r}" controls style="display:block;max-width:100%"></video><div class="an-video-shield"></div></div>`;
|
|
3764
|
-
let i =
|
|
3870
|
+
let i = sn(e, { media: !0 });
|
|
3765
3871
|
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;
|
|
3766
3872
|
}
|
|
3767
|
-
},
|
|
3873
|
+
}, Tr = [
|
|
3768
3874
|
{
|
|
3769
3875
|
pos: "nw",
|
|
3770
3876
|
cursor: "nw-resize"
|
|
@@ -3797,7 +3903,7 @@ var Qn = class {
|
|
|
3797
3903
|
pos: "w",
|
|
3798
3904
|
cursor: "w-resize"
|
|
3799
3905
|
}
|
|
3800
|
-
],
|
|
3906
|
+
], Er = class {
|
|
3801
3907
|
constructor(e) {
|
|
3802
3908
|
this.context = e, this._active = null, this._overlay = null, this._disposers = [], this._positionRaf = null, this._lastOverlayPos = null;
|
|
3803
3909
|
}
|
|
@@ -3850,7 +3956,7 @@ var Qn = class {
|
|
|
3850
3956
|
}
|
|
3851
3957
|
_buildOverlay() {
|
|
3852
3958
|
let e = document.createElement("div");
|
|
3853
|
-
return e.className = this._overlayClass, e.style.display = "none",
|
|
3959
|
+
return e.className = this._overlayClass, e.style.display = "none", Tr.forEach(({ pos: t }) => {
|
|
3854
3960
|
let n = document.createElement("div");
|
|
3855
3961
|
n.className = `an-resize-handle an-resize-${t}`, n.dataset.handle = t, this._disposers.push(E(n, "pointerdown", (e) => {
|
|
3856
3962
|
e.preventDefault(), e.stopPropagation(), this._startResize(e, t);
|
|
@@ -3907,7 +4013,7 @@ var Qn = class {
|
|
|
3907
4013
|
};
|
|
3908
4014
|
document.addEventListener("pointermove", p), document.addEventListener("pointerup", h), document.addEventListener("pointercancel", h), this._dragDisposers = [m];
|
|
3909
4015
|
}
|
|
3910
|
-
},
|
|
4016
|
+
}, Dr = class extends Er {
|
|
3911
4017
|
get _overlayClass() {
|
|
3912
4018
|
return "an-image-resizer";
|
|
3913
4019
|
}
|
|
@@ -3936,7 +4042,7 @@ var Qn = class {
|
|
|
3936
4042
|
getActiveImage() {
|
|
3937
4043
|
return this._active;
|
|
3938
4044
|
}
|
|
3939
|
-
},
|
|
4045
|
+
}, Or = class extends Er {
|
|
3940
4046
|
get _overlayClass() {
|
|
3941
4047
|
return "an-video-resizer";
|
|
3942
4048
|
}
|
|
@@ -3972,12 +4078,12 @@ var Qn = class {
|
|
|
3972
4078
|
getActiveWrapper() {
|
|
3973
4079
|
return this._active;
|
|
3974
4080
|
}
|
|
3975
|
-
},
|
|
4081
|
+
}, kr = {
|
|
3976
4082
|
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>",
|
|
3977
4083
|
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>",
|
|
3978
4084
|
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>",
|
|
3979
4085
|
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>"
|
|
3980
|
-
},
|
|
4086
|
+
}, Ar = 120, jr = 200, Mr = class {
|
|
3981
4087
|
constructor(e) {
|
|
3982
4088
|
this.context = e, this._el = null, this._activeAnchor = null, this._showTimer = null, this._hideTimer = null, this._disposers = [];
|
|
3983
4089
|
}
|
|
@@ -4001,7 +4107,7 @@ var Qn = class {
|
|
|
4001
4107
|
role: "toolbar",
|
|
4002
4108
|
"aria-label": e.ariaLabel
|
|
4003
4109
|
});
|
|
4004
|
-
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(
|
|
4110
|
+
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(kr.open, e.openLink, () => this._openLink()), this._copyBtn = this._makeBtn(kr.copy, e.copyUrl, () => this._copyLink()), this._editBtn = this._makeBtn(kr.edit, e.editLink, () => this._editLink()), this._unlinkBtn = this._makeBtn(kr.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;
|
|
4005
4111
|
}
|
|
4006
4112
|
_makeBtn(e, t, n) {
|
|
4007
4113
|
let r = w("button", {
|
|
@@ -4016,12 +4122,12 @@ var Qn = class {
|
|
|
4016
4122
|
_scheduleShow(e) {
|
|
4017
4123
|
this._activeAnchor === e && this._el.style.display !== "none" || (clearTimeout(this._hideTimer), this._hideTimer = null, clearTimeout(this._showTimer), this._showTimer = setTimeout(() => {
|
|
4018
4124
|
this._activeAnchor = e, this._show(e);
|
|
4019
|
-
},
|
|
4125
|
+
}, Ar));
|
|
4020
4126
|
}
|
|
4021
4127
|
_scheduleHide() {
|
|
4022
4128
|
clearTimeout(this._showTimer), this._showTimer = null, !this._hideTimer && (this._hideTimer = setTimeout(() => {
|
|
4023
4129
|
this._hide();
|
|
4024
|
-
},
|
|
4130
|
+
}, jr));
|
|
4025
4131
|
}
|
|
4026
4132
|
_show(e) {
|
|
4027
4133
|
let t = this.context.layoutInfo.container.classList.contains("an-disabled"), n = e.getAttribute("href") || "";
|
|
@@ -4070,7 +4176,7 @@ var Qn = class {
|
|
|
4070
4176
|
let t = globalThis.getSelection(), n = document.createRange();
|
|
4071
4177
|
n.selectNode(e), t.removeAllRanges(), t.addRange(n), document.execCommand("unlink"), this.context.invoke("editor.afterCommand");
|
|
4072
4178
|
}
|
|
4073
|
-
},
|
|
4179
|
+
}, Nr = class {
|
|
4074
4180
|
constructor(e) {
|
|
4075
4181
|
this.context = e, this.options = e.options, this._el = null, this._active = null, this._showTimer = null, this._hideTimer = null, this._disposers = [];
|
|
4076
4182
|
}
|
|
@@ -4111,7 +4217,7 @@ var Qn = class {
|
|
|
4111
4217
|
let t = e.getBoundingClientRect(), n = this._el.offsetWidth || 220, r = this._el.offsetHeight || 32, i = t.bottom + 6, a = t.left + (t.width - n) / 2;
|
|
4112
4218
|
i + r > globalThis.innerHeight - 6 && (i = t.top - r - 6), a + n > globalThis.innerWidth - 6 && (a = globalThis.innerWidth - n - 6), a < 6 && (a = 6), this._el.style.top = `${i}px`, this._el.style.left = `${a}px`;
|
|
4113
4219
|
}
|
|
4114
|
-
},
|
|
4220
|
+
}, W = {
|
|
4115
4221
|
floatLeft: "<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=\"2\" y=\"4\" width=\"8\" height=\"8\" rx=\"1\"/><line x1=\"12\" y1=\"6\" x2=\"22\" y2=\"6\"/><line x1=\"12\" y1=\"9\" x2=\"22\" y2=\"9\"/><line x1=\"12\" y1=\"12\" x2=\"22\" y2=\"12\"/><line x1=\"2\" y1=\"16\" x2=\"22\" y2=\"16\"/><line x1=\"2\" y1=\"20\" x2=\"18\" y2=\"20\"/></svg>",
|
|
4116
4222
|
floatRight: "<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=\"14\" y=\"4\" width=\"8\" height=\"8\" rx=\"1\"/><line x1=\"2\" y1=\"6\" x2=\"12\" y2=\"6\"/><line x1=\"2\" y1=\"9\" x2=\"12\" y2=\"9\"/><line x1=\"2\" y1=\"12\" x2=\"12\" y2=\"12\"/><line x1=\"2\" y1=\"16\" x2=\"22\" y2=\"16\"/><line x1=\"2\" y1=\"20\" x2=\"18\" y2=\"20\"/></svg>",
|
|
4117
4223
|
floatNone: "<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=\"3\" y=\"3\" width=\"8\" height=\"8\" rx=\"1\"/><line x1=\"3\" y1=\"15\" x2=\"21\" y2=\"15\"/><line x1=\"3\" y1=\"19\" x2=\"17\" y2=\"19\"/></svg>",
|
|
@@ -4122,7 +4228,7 @@ var Qn = class {
|
|
|
4122
4228
|
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>",
|
|
4123
4229
|
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>",
|
|
4124
4230
|
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>"
|
|
4125
|
-
},
|
|
4231
|
+
}, Pr = class extends Nr {
|
|
4126
4232
|
initialize() {
|
|
4127
4233
|
this._el = this._buildTooltip(), document.body.appendChild(this._el);
|
|
4128
4234
|
let e = this.context.layoutInfo.editable;
|
|
@@ -4147,7 +4253,7 @@ var Qn = class {
|
|
|
4147
4253
|
role: "toolbar",
|
|
4148
4254
|
"aria-label": e.ariaLabel
|
|
4149
4255
|
});
|
|
4150
|
-
return t.style.display = "none", this._label = w("span", { class: "an-link-tooltip-url" }), this._label.textContent = e.label, t.appendChild(this._label), t.appendChild(w("div", { class: "an-link-tooltip-sep" })), this._floatLeftBtn = this._makeBtn(
|
|
4256
|
+
return t.style.display = "none", this._label = w("span", { class: "an-link-tooltip-url" }), this._label.textContent = e.label, t.appendChild(this._label), t.appendChild(w("div", { class: "an-link-tooltip-sep" })), this._floatLeftBtn = this._makeBtn(W.floatLeft, e.floatLeft, () => this._setFloat("left")), this._floatNoneBtn = this._makeBtn(W.floatNone, e.noFloat, () => this._setFloat("")), this._alignCenterBtn = this._makeBtn(W.alignCenter, e.alignCenter, () => this._setCenter()), this._floatRightBtn = this._makeBtn(W.floatRight, e.floatRight, () => this._setFloat("right")), t.appendChild(this._floatLeftBtn), t.appendChild(this._floatNoneBtn), t.appendChild(this._alignCenterBtn), t.appendChild(this._floatRightBtn), t.appendChild(w("div", { class: "an-link-tooltip-sep" })), this._originalBtn = this._makeBtn(W.originalSize, e.originalSize, () => this._resetSize()), t.appendChild(this._originalBtn), t.appendChild(w("div", { class: "an-link-tooltip-sep" })), t.appendChild(this._makeBtn(W.rotateLeft, e.rotateLeft, () => this._rotate(-90))), t.appendChild(this._makeBtn(W.rotateRight, e.rotateRight, () => this._rotate(90))), t.appendChild(w("div", { class: "an-link-tooltip-sep" })), this._cropBtn = this._makeBtn(W.crop, e.cropImage, () => this._crop()), t.appendChild(this._cropBtn), t.appendChild(w("div", { class: "an-link-tooltip-sep" })), this._captionBtn = this._makeBtn(W.caption, e.addCaption, () => this._toggleCaption()), t.appendChild(this._captionBtn), t.appendChild(w("div", { class: "an-link-tooltip-sep" })), this._deleteBtn = this._makeBtn(W.deleteImg, e.deleteImage, () => this._delete(), !0), t.appendChild(this._deleteBtn), this._disposers.push(E(t, "mouseenter", () => this._clearTimers()), E(t, "mouseleave", () => this._scheduleHide())), t;
|
|
4151
4257
|
}
|
|
4152
4258
|
_setFloat(e) {
|
|
4153
4259
|
let t = this._active;
|
|
@@ -4214,7 +4320,7 @@ var Qn = class {
|
|
|
4214
4320
|
let a = globalThis.getSelection();
|
|
4215
4321
|
a && (a.removeAllRanges(), a.addRange(i)), this.context.invoke("editor.afterCommand"), this.context.invoke("imageResizer.updateOverlay"), this._hide();
|
|
4216
4322
|
}
|
|
4217
|
-
},
|
|
4323
|
+
}, G = {
|
|
4218
4324
|
floatLeft: "<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=\"2\" y=\"4\" width=\"8\" height=\"8\" rx=\"1\"/><line x1=\"12\" y1=\"6\" x2=\"22\" y2=\"6\"/><line x1=\"12\" y1=\"9\" x2=\"22\" y2=\"9\"/><line x1=\"12\" y1=\"12\" x2=\"22\" y2=\"12\"/><line x1=\"2\" y1=\"16\" x2=\"22\" y2=\"16\"/><line x1=\"2\" y1=\"20\" x2=\"18\" y2=\"20\"/></svg>",
|
|
4219
4325
|
floatRight: "<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=\"14\" y=\"4\" width=\"8\" height=\"8\" rx=\"1\"/><line x1=\"2\" y1=\"6\" x2=\"12\" y2=\"6\"/><line x1=\"2\" y1=\"9\" x2=\"12\" y2=\"9\"/><line x1=\"2\" y1=\"12\" x2=\"12\" y2=\"12\"/><line x1=\"2\" y1=\"16\" x2=\"22\" y2=\"16\"/><line x1=\"2\" y1=\"20\" x2=\"18\" y2=\"20\"/></svg>",
|
|
4220
4326
|
floatNone: "<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=\"3\" y=\"3\" width=\"8\" height=\"8\" rx=\"1\"/><line x1=\"3\" y1=\"15\" x2=\"21\" y2=\"15\"/><line x1=\"3\" y1=\"19\" x2=\"17\" y2=\"19\"/></svg>",
|
|
@@ -4222,7 +4328,7 @@ var Qn = class {
|
|
|
4222
4328
|
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>",
|
|
4223
4329
|
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>",
|
|
4224
4330
|
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>"
|
|
4225
|
-
},
|
|
4331
|
+
}, Fr = class extends Nr {
|
|
4226
4332
|
initialize() {
|
|
4227
4333
|
this._el = this._buildTooltip(), document.body.appendChild(this._el);
|
|
4228
4334
|
let e = this.context.layoutInfo.editable;
|
|
@@ -4253,7 +4359,7 @@ var Qn = class {
|
|
|
4253
4359
|
role: "toolbar",
|
|
4254
4360
|
"aria-label": e.ariaLabel
|
|
4255
4361
|
});
|
|
4256
|
-
return t.style.display = "none", this._label = w("span", { class: "an-link-tooltip-url" }), this._label.textContent = e.label, t.appendChild(this._label), t.appendChild(w("div", { class: "an-link-tooltip-sep" })), this._floatLeftBtn = this._makeBtn(
|
|
4362
|
+
return t.style.display = "none", this._label = w("span", { class: "an-link-tooltip-url" }), this._label.textContent = e.label, t.appendChild(this._label), t.appendChild(w("div", { class: "an-link-tooltip-sep" })), this._floatLeftBtn = this._makeBtn(G.floatLeft, e.floatLeft, () => this._setFloat("left")), this._floatNoneBtn = this._makeBtn(G.floatNone, e.noFloat, () => this._setFloat("")), this._alignCenterBtn = this._makeBtn(G.alignCenter, e.alignCenter, () => this._setCenter()), this._floatRightBtn = this._makeBtn(G.floatRight, e.floatRight, () => this._setFloat("right")), t.appendChild(this._floatLeftBtn), t.appendChild(this._floatNoneBtn), t.appendChild(this._alignCenterBtn), t.appendChild(this._floatRightBtn), t.appendChild(w("div", { class: "an-link-tooltip-sep" })), this._originalBtn = this._makeBtn(G.originalSize, e.originalSize, () => this._resetSize()), t.appendChild(this._originalBtn), t.appendChild(w("div", { class: "an-link-tooltip-sep" })), this._previewBtn = this._makeBtn(G.preview, e.previewVideo, () => this._togglePreview()), t.appendChild(this._previewBtn), t.appendChild(w("div", { class: "an-link-tooltip-sep" })), this._deleteBtn = this._makeBtn(G.deleteVideo, e.deleteVideo, () => this._delete(), !0), t.appendChild(this._deleteBtn), this._disposers.push(E(t, "mouseenter", () => this._clearTimers()), E(t, "mouseleave", () => this._scheduleHide())), t;
|
|
4257
4363
|
}
|
|
4258
4364
|
_setFloat(e) {
|
|
4259
4365
|
let t = this._active;
|
|
@@ -4300,7 +4406,7 @@ var Qn = class {
|
|
|
4300
4406
|
}
|
|
4301
4407
|
this._previewBtn.classList.remove("an-link-tooltip-btn--copied"), this._previewBtn.title = this.context.locale.tooltips.video.previewVideo, this._previewClickOff &&= (document.removeEventListener("mousedown", this._previewClickOff, !0), null);
|
|
4302
4408
|
}
|
|
4303
|
-
},
|
|
4409
|
+
}, K = {
|
|
4304
4410
|
rowAbove: "<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=\"3\" y=\"3\" width=\"18\" height=\"18\" rx=\"1\"/><line x1=\"3\" y1=\"12\" x2=\"21\" y2=\"12\"/><path d=\"M12 3v7\"/><path d=\"M9 7l3-4 3 4\"/></svg>",
|
|
4305
4411
|
rowBelow: "<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=\"3\" y=\"3\" width=\"18\" height=\"18\" rx=\"1\"/><line x1=\"3\" y1=\"12\" x2=\"21\" y2=\"12\"/><path d=\"M12 12v7\"/><path d=\"M9 17l3 4 3-4\"/></svg>",
|
|
4306
4412
|
deleteRow: "<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=\"3\" y=\"3\" width=\"18\" height=\"18\" rx=\"1\"/><line x1=\"3\" y1=\"12\" x2=\"21\" y2=\"12\"/><line x1=\"15\" y1=\"15\" x2=\"21\" y2=\"21\"/><line x1=\"21\" y1=\"15\" x2=\"15\" y2=\"21\"/></svg>",
|
|
@@ -4328,7 +4434,7 @@ var Qn = class {
|
|
|
4328
4434
|
};
|
|
4329
4435
|
//#endregion
|
|
4330
4436
|
//#region src/js/module/table-grid.js
|
|
4331
|
-
function
|
|
4437
|
+
function Ir(e) {
|
|
4332
4438
|
let t = e.closest("tr");
|
|
4333
4439
|
if (!t) return -1;
|
|
4334
4440
|
let n = 0;
|
|
@@ -4347,7 +4453,7 @@ function q(e, t) {
|
|
|
4347
4453
|
}
|
|
4348
4454
|
return null;
|
|
4349
4455
|
}
|
|
4350
|
-
function
|
|
4456
|
+
function Lr(e, t) {
|
|
4351
4457
|
let n = 0;
|
|
4352
4458
|
for (let r of e.cells) if (n += r.colSpan || 1, n > t) {
|
|
4353
4459
|
let e = r.nextElementSibling;
|
|
@@ -4355,7 +4461,7 @@ function br(e, t) {
|
|
|
4355
4461
|
}
|
|
4356
4462
|
return null;
|
|
4357
4463
|
}
|
|
4358
|
-
function
|
|
4464
|
+
function Rr(e) {
|
|
4359
4465
|
let t = Array.from(e.rows), n = {}, r = /* @__PURE__ */ new WeakMap();
|
|
4360
4466
|
return t.forEach((e, t) => {
|
|
4361
4467
|
n[t] || (n[t] = {});
|
|
@@ -4382,7 +4488,7 @@ function xr(e) {
|
|
|
4382
4488
|
}
|
|
4383
4489
|
//#endregion
|
|
4384
4490
|
//#region src/js/module/TableTooltip.js
|
|
4385
|
-
var
|
|
4491
|
+
var zr = 120, Br = 200, Vr = [
|
|
4386
4492
|
"#000000",
|
|
4387
4493
|
"#434343",
|
|
4388
4494
|
"#666666",
|
|
@@ -4407,7 +4513,7 @@ var Sr = 120, Cr = 200, wr = [
|
|
|
4407
4513
|
"#c9daf8",
|
|
4408
4514
|
"#d9d2e9",
|
|
4409
4515
|
"#ead1dc"
|
|
4410
|
-
],
|
|
4516
|
+
], Hr = class {
|
|
4411
4517
|
constructor(e) {
|
|
4412
4518
|
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;
|
|
4413
4519
|
}
|
|
@@ -4465,7 +4571,7 @@ var Sr = 120, Cr = 200, wr = [
|
|
|
4465
4571
|
});
|
|
4466
4572
|
}), E(e, "mousedown", (e) => {
|
|
4467
4573
|
if (!this.context.layoutInfo.container.classList.contains("an-disabled") && !(!t || !n)) {
|
|
4468
|
-
if (r = !0, i = n, a = e.clientX, o = e.clientY, f = t.closest("table"), i === "col") l =
|
|
4574
|
+
if (r = !0, i = n, a = e.clientX, o = e.clientY, f = t.closest("table"), i === "col") l = Ir(t) + (t.colSpan || 1) - 1, u = l >= 0 ? Array.from(f.querySelectorAll("tr")).map((e) => q(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";
|
|
4469
4575
|
else {
|
|
4470
4576
|
let e = t.closest("tr"), n = (e ? Array.from(f.rows).indexOf(e) : 0) + (t.rowSpan || 1) - 1;
|
|
4471
4577
|
d = f.rows[n] || e, c = d ? d.offsetHeight : 40, document.body.style.cursor = "row-resize";
|
|
@@ -4497,27 +4603,27 @@ var Sr = 120, Cr = 200, wr = [
|
|
|
4497
4603
|
role: "toolbar",
|
|
4498
4604
|
"aria-label": e.ariaLabel
|
|
4499
4605
|
});
|
|
4500
|
-
t.style.display = "none", this._label = w("span", { class: "an-link-tooltip-url" }), this._label.textContent = e.label, t.appendChild(this._label), t.appendChild(this._sep()), this._selectBtn = this._makeBtn(
|
|
4606
|
+
t.style.display = "none", this._label = w("span", { class: "an-link-tooltip-url" }), this._label.textContent = e.label, t.appendChild(this._label), t.appendChild(this._sep()), this._selectBtn = this._makeBtn(K.selectCells, e.selectCells, () => this._toggleSelectMode()), t.appendChild(this._selectBtn), t.appendChild(this._sep()), t.appendChild(this._makeBtn(K.rowAbove, e.addRowAbove, () => this._addRow("above"))), t.appendChild(this._makeBtn(K.rowBelow, e.addRowBelow, () => this._addRow("below"))), t.appendChild(this._makeBtn(K.deleteRow, e.deleteRow, () => this._deleteRow())), t.appendChild(this._sep()), t.appendChild(this._makeBtn(K.colLeft, e.addColumnLeft, () => this._addColumn("left"))), t.appendChild(this._makeBtn(K.colRight, e.addColumnRight, () => this._addColumn("right"))), t.appendChild(this._makeBtn(K.deleteCol, e.deleteColumn, () => this._deleteColumn())), t.appendChild(this._makeBtn(K.sortAsc, e.sortAsc, () => this._sortColumn("asc"))), t.appendChild(this._makeBtn(K.sortDesc, e.sortDesc, () => this._sortColumn("desc"))), t.appendChild(this._sep()), t.appendChild(this._makeBtn(K.mergeCells, e.mergeCells, () => this._mergeCells())), t.appendChild(this._makeBtn(K.unmergeCells, e.unmergeCells, () => this._unmergeCells())), t.appendChild(this._sep()), t.appendChild(this._makeBtn(K.alignLeft, e.cellAlignLeft, () => this._applyCellAlign("left"))), t.appendChild(this._makeBtn(K.alignCenter, e.cellAlignCenter, () => this._applyCellAlign("center"))), t.appendChild(this._makeBtn(K.alignRight, e.cellAlignRight, () => this._applyCellAlign("right"))), t.appendChild(this._makeBtn(K.alignJustify, e.cellAlignJustify, () => this._applyCellAlign("justify"))), t.appendChild(this._makeBtn(K.headerRow, e.toggleHeaderRow, () => this._toggleHeaderRow())), t.appendChild(this._sep());
|
|
4501
4607
|
let n = w("button", {
|
|
4502
4608
|
type: "button",
|
|
4503
4609
|
class: "an-link-tooltip-btn an-link-tooltip-btn--shade",
|
|
4504
4610
|
title: e.cellBackground
|
|
4505
4611
|
}), r = w("span", { class: "an-bubble-btn-svg" });
|
|
4506
|
-
r.innerHTML =
|
|
4612
|
+
r.innerHTML = K.cellShade;
|
|
4507
4613
|
let i = w("span", { class: "an-link-tooltip-color-strip" });
|
|
4508
4614
|
n.appendChild(r), n.appendChild(i), this._shadeColorStrip = i, this._disposers.push(E(n, "click", (e) => {
|
|
4509
4615
|
e.preventDefault(), e.stopPropagation(), this._openCellShadePopover();
|
|
4510
|
-
})), t.appendChild(n), t.appendChild(this._sep()), t.appendChild(this._makeBtn(
|
|
4616
|
+
})), t.appendChild(n), t.appendChild(this._sep()), t.appendChild(this._makeBtn(K.colWidth, e.columnWidth, () => this._openSizePopover("col"))), t.appendChild(this._makeBtn(K.rowHeight, e.rowHeight, () => this._openSizePopover("row"))), t.appendChild(this._makeBtn(K.tableBorder, e.tableBorderWidth, () => this._openSizePopover("border"))), t.appendChild(this._makeBtn(K.cellPadding, e.cellPadding, () => this._openSizePopover("cellPadding")));
|
|
4511
4617
|
let a = w("button", {
|
|
4512
4618
|
type: "button",
|
|
4513
4619
|
class: "an-link-tooltip-btn an-link-tooltip-btn--shade",
|
|
4514
4620
|
title: e.tableBorderColor
|
|
4515
4621
|
}), o = w("span", { class: "an-bubble-btn-svg" });
|
|
4516
|
-
o.innerHTML =
|
|
4622
|
+
o.innerHTML = K.borderColor;
|
|
4517
4623
|
let s = w("span", { class: "an-link-tooltip-color-strip" });
|
|
4518
4624
|
return a.appendChild(o), a.appendChild(s), this._borderColorStrip = s, this._disposers.push(E(a, "click", (e) => {
|
|
4519
4625
|
e.preventDefault(), e.stopPropagation(), this._openBorderColorPopover();
|
|
4520
|
-
})), t.appendChild(a), t.appendChild(this._sep()), t.appendChild(this._makeBtn(
|
|
4626
|
+
})), t.appendChild(a), t.appendChild(this._sep()), t.appendChild(this._makeBtn(K.deleteTable, e.deleteTable, () => this._deleteTable(), !0)), t.appendChild(this._sep()), t.appendChild(this._makeBtn(K.exportCSV, e.exportCSV, () => this._exportTableCSV())), this._disposers.push(E(t, "mouseenter", () => this._clearTimers()), E(t, "mouseleave", () => {
|
|
4521
4627
|
this._selectMode || this._sizePopover && this._sizePopover.style.display !== "none" || this._shadePopover && this._shadePopover.style.display !== "none" || this._borderColorPopover && this._borderColorPopover.style.display !== "none" || this._scheduleHide();
|
|
4522
4628
|
})), t;
|
|
4523
4629
|
}
|
|
@@ -4537,10 +4643,10 @@ var Sr = 120, Cr = 200, wr = [
|
|
|
4537
4643
|
_scheduleShow(e) {
|
|
4538
4644
|
this._activeTable === e && this._el.style.display !== "none" || (clearTimeout(this._hideTimer), this._hideTimer = null, clearTimeout(this._showTimer), this._showTimer = setTimeout(() => {
|
|
4539
4645
|
this._activeTable = e, this._show();
|
|
4540
|
-
},
|
|
4646
|
+
}, zr));
|
|
4541
4647
|
}
|
|
4542
4648
|
_scheduleHide() {
|
|
4543
|
-
clearTimeout(this._showTimer), this._showTimer = null, !this._hideTimer && (this._hideTimer = setTimeout(() => this._hide(),
|
|
4649
|
+
clearTimeout(this._showTimer), this._showTimer = null, !this._hideTimer && (this._hideTimer = setTimeout(() => this._hide(), Br));
|
|
4544
4650
|
}
|
|
4545
4651
|
_show() {
|
|
4546
4652
|
this._activeTable && (this._el.style.display = "flex", this._syncShadeStrip(), this._syncBorderColorStrip(), requestAnimationFrame(() => {
|
|
@@ -4589,7 +4695,7 @@ var Sr = 120, Cr = 200, wr = [
|
|
|
4589
4695
|
if (!t || e === t) return [e];
|
|
4590
4696
|
let n = e.closest("table");
|
|
4591
4697
|
if (!n?.contains(t)) return [e];
|
|
4592
|
-
let { gridMap: r, cellPos: i } =
|
|
4698
|
+
let { gridMap: r, cellPos: i } = Rr(n), a = i.get(e), o = i.get(t);
|
|
4593
4699
|
if (!a || !o) return [e];
|
|
4594
4700
|
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;
|
|
4595
4701
|
for (; d;) {
|
|
@@ -4637,7 +4743,7 @@ var Sr = 120, Cr = 200, wr = [
|
|
|
4637
4743
|
if (!t.length) return;
|
|
4638
4744
|
let n = t[0].closest("table");
|
|
4639
4745
|
if (!n) return;
|
|
4640
|
-
let r = t.map((e) =>
|
|
4746
|
+
let r = t.map((e) => Ir(e)), i = e === "left" ? Math.min(...r) : Math.max(...r), a = Array.from(n.querySelectorAll("tr")), o = a.map((t) => e === "left" ? q(t, i) : Lr(t, i)), s = a.map((e) => e.closest("thead") !== null);
|
|
4641
4747
|
a.forEach((e, t) => {
|
|
4642
4748
|
e.insertBefore(w(s[t] ? "th" : "td", {}, ["\xA0"]), o[t]);
|
|
4643
4749
|
}), requestAnimationFrame(() => this._positionNear(this._activeTable)), this.context.invoke("editor.afterCommand");
|
|
@@ -4657,7 +4763,7 @@ var Sr = 120, Cr = 200, wr = [
|
|
|
4657
4763
|
if (!t) return;
|
|
4658
4764
|
let n = Array.from(t.querySelectorAll("tr"));
|
|
4659
4765
|
if (n[0] && n[0].cells.length <= 1) return;
|
|
4660
|
-
let r = [...new Set(e.map((e) =>
|
|
4766
|
+
let r = [...new Set(e.map((e) => Ir(e)))];
|
|
4661
4767
|
if (r.length >= (n[0]?.cells.length ?? 1)) return;
|
|
4662
4768
|
let i = [];
|
|
4663
4769
|
r.forEach((e) => {
|
|
@@ -4685,7 +4791,7 @@ var Sr = 120, Cr = 200, wr = [
|
|
|
4685
4791
|
}
|
|
4686
4792
|
}), n.length < 2) return;
|
|
4687
4793
|
}
|
|
4688
|
-
let { gridMap: r, cellPos: i } =
|
|
4794
|
+
let { gridMap: r, cellPos: i } = Rr(t), a = Infinity, o = -Infinity, s = Infinity, c = -Infinity;
|
|
4689
4795
|
if (n.forEach((e) => {
|
|
4690
4796
|
let t = i.get(e);
|
|
4691
4797
|
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));
|
|
@@ -4724,7 +4830,7 @@ var Sr = 120, Cr = 200, wr = [
|
|
|
4724
4830
|
_unmergeOne(e, t) {
|
|
4725
4831
|
let n = e.colSpan || 1, r = e.rowSpan || 1;
|
|
4726
4832
|
if (n === 1 && r === 1) return;
|
|
4727
|
-
let { cellPos: i } =
|
|
4833
|
+
let { cellPos: i } = Rr(t), a = i.get(e);
|
|
4728
4834
|
if (!a) return;
|
|
4729
4835
|
let { r: o, c: s } = a, c = Array.from(t.rows), l = e.tagName.toLowerCase();
|
|
4730
4836
|
if (e.rowSpan = 1, e.colSpan = 1, e.style.verticalAlign = "", n > 1) {
|
|
@@ -4811,7 +4917,7 @@ var Sr = 120, Cr = 200, wr = [
|
|
|
4811
4917
|
let i = t.closest("table");
|
|
4812
4918
|
if (i) {
|
|
4813
4919
|
if (n) {
|
|
4814
|
-
let t = [...new Set(r.map((e) =>
|
|
4920
|
+
let t = [...new Set(r.map((e) => Ir(e)))], n = Array.from(i.querySelectorAll("tr"));
|
|
4815
4921
|
t.forEach((t) => {
|
|
4816
4922
|
n.forEach((n) => {
|
|
4817
4923
|
let r = q(n, t);
|
|
@@ -4841,7 +4947,7 @@ var Sr = 120, Cr = 200, wr = [
|
|
|
4841
4947
|
let a = w("div", { class: "an-size-popover-title" });
|
|
4842
4948
|
i.appendChild(a);
|
|
4843
4949
|
let o = w("div", { class: "an-context-color-palette" });
|
|
4844
|
-
|
|
4950
|
+
Vr.forEach((e) => {
|
|
4845
4951
|
let n = w("div", {
|
|
4846
4952
|
class: "an-context-color-swatch",
|
|
4847
4953
|
title: e
|
|
@@ -4961,7 +5067,7 @@ var Sr = 120, Cr = 200, wr = [
|
|
|
4961
5067
|
if (!t) return;
|
|
4962
5068
|
let n = this._getCell();
|
|
4963
5069
|
if (!n) return;
|
|
4964
|
-
let r =
|
|
5070
|
+
let r = Ir(n);
|
|
4965
5071
|
if (r === -1) return;
|
|
4966
5072
|
let i = t.querySelector("tbody") || t, a = Array.from(i.querySelectorAll(":scope > tr"));
|
|
4967
5073
|
a.length < 2 || (a.sort((t, n) => {
|
|
@@ -4986,13 +5092,13 @@ var Sr = 120, Cr = 200, wr = [
|
|
|
4986
5092
|
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");
|
|
4987
5093
|
i.href = r, i.download = "table.csv", i.style.display = "none", document.body.appendChild(i), i.click(), i.remove(), URL.revokeObjectURL(r);
|
|
4988
5094
|
}
|
|
4989
|
-
},
|
|
5095
|
+
}, Ur = 100, Wr = 180, Gr = /language-(\S+)/, Kr = {
|
|
4990
5096
|
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>",
|
|
4991
5097
|
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>",
|
|
4992
5098
|
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>",
|
|
4993
5099
|
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>",
|
|
4994
5100
|
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>"
|
|
4995
|
-
},
|
|
5101
|
+
}, qr = class {
|
|
4996
5102
|
constructor(e) {
|
|
4997
5103
|
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;
|
|
4998
5104
|
}
|
|
@@ -5049,7 +5155,7 @@ var Sr = 120, Cr = 200, wr = [
|
|
|
5049
5155
|
].forEach(([e, t]) => {
|
|
5050
5156
|
let n = w("option", { value: e });
|
|
5051
5157
|
n.textContent = t, this._langSelect.appendChild(n);
|
|
5052
|
-
}), this._disposers.push(E(this._langSelect, "change", () => this._onLangChange())), t.appendChild(this._langSelect), t.appendChild(this._sep()), this._copyBtn = this._makeBtn(
|
|
5158
|
+
}), this._disposers.push(E(this._langSelect, "change", () => this._onLangChange())), t.appendChild(this._langSelect), t.appendChild(this._sep()), this._copyBtn = this._makeBtn(Kr.copy, e.copyCode, () => this._copyCode()), t.appendChild(this._copyBtn), t.appendChild(this._sep()), this._wrapBtn = this._makeBtn(Kr.wrapOn, e.toggleWordWrap, () => this._toggleWrap()), t.appendChild(this._wrapBtn), this._lineNumbersBtn = this._makeBtn(Kr.lineNumbers, e.lineNumbers, () => this._toggleLineNumbers()), t.appendChild(this._lineNumbersBtn), t.appendChild(this._sep()), t.appendChild(this._makeBtn(Kr.toParagraph, e.convertToParagraph, () => this._toParagraph())), t.appendChild(this._sep()), t.appendChild(this._makeBtn(Kr.deleteCode, e.deleteCodeBlock, () => this._delete(), !0)), this._disposers.push(E(t, "mouseenter", () => this._clearTimers()), E(t, "mouseleave", () => this._scheduleHide())), t;
|
|
5053
5159
|
}
|
|
5054
5160
|
_sep() {
|
|
5055
5161
|
return w("div", { class: "an-link-tooltip-sep" });
|
|
@@ -5067,10 +5173,10 @@ var Sr = 120, Cr = 200, wr = [
|
|
|
5067
5173
|
_scheduleShow(e) {
|
|
5068
5174
|
this._activePre === e && this._el.style.display !== "none" || (clearTimeout(this._hideTimer), this._hideTimer = null, clearTimeout(this._showTimer), this._showTimer = setTimeout(() => {
|
|
5069
5175
|
this._activePre = e, this._syncWrapBtn(), this._syncLineNumbersBtn(), this._syncLangSelect(), this._show(e);
|
|
5070
|
-
},
|
|
5176
|
+
}, Ur));
|
|
5071
5177
|
}
|
|
5072
5178
|
_scheduleHide() {
|
|
5073
|
-
clearTimeout(this._showTimer), this._showTimer = null, clearTimeout(this._hideTimer), this._hideTimer = setTimeout(() => this._hide(),
|
|
5179
|
+
clearTimeout(this._showTimer), this._showTimer = null, clearTimeout(this._hideTimer), this._hideTimer = setTimeout(() => this._hide(), Wr);
|
|
5074
5180
|
}
|
|
5075
5181
|
_show(e) {
|
|
5076
5182
|
this._el.style.display = "flex", this._positionNear(e);
|
|
@@ -5097,7 +5203,7 @@ var Sr = 120, Cr = 200, wr = [
|
|
|
5097
5203
|
}
|
|
5098
5204
|
_syncLangSelect() {
|
|
5099
5205
|
if (!this._activePre || !this._langSelect) return;
|
|
5100
|
-
let e = this._activePre.querySelector("code"), t = this._activePre.dataset.language || "", n = e && (
|
|
5206
|
+
let e = this._activePre.querySelector("code"), t = this._activePre.dataset.language || "", n = e && (Gr.exec(e.className) || [])[1] || "";
|
|
5101
5207
|
this._langSelect.value = t || n || "";
|
|
5102
5208
|
}
|
|
5103
5209
|
_copyCode() {
|
|
@@ -5203,21 +5309,21 @@ var Sr = 120, Cr = 200, wr = [
|
|
|
5203
5309
|
let e = this._activePre;
|
|
5204
5310
|
e && (this._hide(), e.remove(), this.context.invoke("editor.afterCommand"));
|
|
5205
5311
|
}
|
|
5206
|
-
},
|
|
5207
|
-
function
|
|
5208
|
-
return
|
|
5312
|
+
}, Jr = null, Yr = null;
|
|
5313
|
+
function Xr() {
|
|
5314
|
+
return Jr ? Promise.resolve(Jr) : (Yr ??= import("./emoji-data-BDQX5kh-.js").then((e) => (Jr = {
|
|
5209
5315
|
EMOJI_CATS: e.EMOJI_CATS,
|
|
5210
5316
|
EMOJI_LIST: e.EMOJI_LIST
|
|
5211
|
-
},
|
|
5317
|
+
}, Jr)), Yr);
|
|
5212
5318
|
}
|
|
5213
|
-
var
|
|
5319
|
+
var Zr = class extends U {
|
|
5214
5320
|
_activeCat = "all";
|
|
5215
5321
|
initialize() {
|
|
5216
5322
|
return this;
|
|
5217
5323
|
}
|
|
5218
5324
|
async show() {
|
|
5219
5325
|
if (this._saveRange(), !this._dialog) {
|
|
5220
|
-
let { EMOJI_CATS: e, EMOJI_LIST: t } = await
|
|
5326
|
+
let { EMOJI_CATS: e, EMOJI_LIST: t } = await Xr();
|
|
5221
5327
|
this._dialog || (this._cats = e, this._list = t, this._dialog = this._buildDialog(), document.body.appendChild(this._dialog));
|
|
5222
5328
|
}
|
|
5223
5329
|
this._activeCat = "all", this._searchInput.value = "", this._updateCatTabs(), this._filterEmojis("", "all"), this._open();
|
|
@@ -5310,14 +5416,14 @@ var Pr = class extends H {
|
|
|
5310
5416
|
let s = document.createTextNode(e);
|
|
5311
5417
|
i.insertNode(s), i.setStartAfter(s), i.collapse(!0), r && (r.removeAllRanges(), r.addRange(i)), this._close(), n.focus(), this.context.invoke("editor.afterCommand");
|
|
5312
5418
|
}
|
|
5313
|
-
},
|
|
5314
|
-
function
|
|
5315
|
-
return
|
|
5419
|
+
}, Qr = "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css", $r = null, ei = null;
|
|
5420
|
+
function ti() {
|
|
5421
|
+
return $r ? Promise.resolve($r) : (ei ??= import("./icon-data-V0Xqv-wX.js").then((e) => ($r = {
|
|
5316
5422
|
ICON_CATEGORIES: e.ICON_CATEGORIES,
|
|
5317
5423
|
ICON_LIST: e.ICON_LIST
|
|
5318
|
-
},
|
|
5424
|
+
}, $r)), ei);
|
|
5319
5425
|
}
|
|
5320
|
-
var
|
|
5426
|
+
var ni = class extends U {
|
|
5321
5427
|
_selectedIcon = null;
|
|
5322
5428
|
_activeCat = "all";
|
|
5323
5429
|
initialize() {
|
|
@@ -5325,7 +5431,7 @@ var zr = class extends H {
|
|
|
5325
5431
|
}
|
|
5326
5432
|
_ensureFontAwesome() {
|
|
5327
5433
|
if (this.context.options.fontAwesomeAutoInject === !1) return;
|
|
5328
|
-
let e = this.context.options.fontAwesomeCDN ||
|
|
5434
|
+
let e = this.context.options.fontAwesomeCDN || Qr;
|
|
5329
5435
|
if (!e || document.getElementById("an-fontawesome-css")) return;
|
|
5330
5436
|
let t = Array.from(document.querySelectorAll("link[rel=\"stylesheet\"]")).map((e) => e.href || "").join(" ");
|
|
5331
5437
|
if (/fontawesome|font-awesome/.test(t) || document.querySelector(".fa-solid, .fas, .far, .fab")) return;
|
|
@@ -5334,7 +5440,7 @@ var zr = class extends H {
|
|
|
5334
5440
|
}
|
|
5335
5441
|
async show() {
|
|
5336
5442
|
if (this._saveRange(), this._ensureFontAwesome(), !this._dialog) {
|
|
5337
|
-
let { ICON_CATEGORIES: e, ICON_LIST: t } = await
|
|
5443
|
+
let { ICON_CATEGORIES: e, ICON_LIST: t } = await ti();
|
|
5338
5444
|
this._dialog || (this._cats = e, this._list = t, this._dialog = this._buildDialog(), document.body.appendChild(this._dialog));
|
|
5339
5445
|
}
|
|
5340
5446
|
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();
|
|
@@ -5525,7 +5631,7 @@ var zr = class extends H {
|
|
|
5525
5631
|
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>",
|
|
5526
5632
|
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>",
|
|
5527
5633
|
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>"
|
|
5528
|
-
},
|
|
5634
|
+
}, ri = [
|
|
5529
5635
|
"#000000",
|
|
5530
5636
|
"#434343",
|
|
5531
5637
|
"#666666",
|
|
@@ -5551,19 +5657,19 @@ var zr = class extends H {
|
|
|
5551
5657
|
"#d9d2e9",
|
|
5552
5658
|
"#ead1dc"
|
|
5553
5659
|
];
|
|
5554
|
-
function
|
|
5660
|
+
function ii(e) {
|
|
5555
5661
|
let t = e === "foreColor" ? "Text Color" : "Highlight Color", n = e === "foreColor" ? "textColor" : "highlightColor";
|
|
5556
5662
|
return () => [{
|
|
5557
5663
|
back: !0,
|
|
5558
5664
|
label: t,
|
|
5559
5665
|
localeKey: n,
|
|
5560
|
-
navigate: () =>
|
|
5666
|
+
navigate: () => ai
|
|
5561
5667
|
}, {
|
|
5562
5668
|
colorPalette: !0,
|
|
5563
5669
|
colorType: e
|
|
5564
5670
|
}];
|
|
5565
5671
|
}
|
|
5566
|
-
var
|
|
5672
|
+
var ai = [
|
|
5567
5673
|
{
|
|
5568
5674
|
name: "cut",
|
|
5569
5675
|
label: "Cut",
|
|
@@ -5627,14 +5733,14 @@ var Hr = [
|
|
|
5627
5733
|
label: "Text Color",
|
|
5628
5734
|
icon: J.textColor,
|
|
5629
5735
|
colorStrip: "foreColor",
|
|
5630
|
-
navigate:
|
|
5736
|
+
navigate: ii("foreColor")
|
|
5631
5737
|
},
|
|
5632
5738
|
{
|
|
5633
5739
|
name: "highlightColor",
|
|
5634
5740
|
label: "Highlight Color",
|
|
5635
5741
|
icon: J.highlightColor,
|
|
5636
5742
|
colorStrip: "hiliteColor",
|
|
5637
|
-
navigate:
|
|
5743
|
+
navigate: ii("hiliteColor")
|
|
5638
5744
|
},
|
|
5639
5745
|
{ separator: !0 },
|
|
5640
5746
|
{
|
|
@@ -5681,9 +5787,9 @@ var Hr = [
|
|
|
5681
5787
|
icon: J.table,
|
|
5682
5788
|
tableGrid: !0
|
|
5683
5789
|
}
|
|
5684
|
-
],
|
|
5790
|
+
], oi = class {
|
|
5685
5791
|
constructor(e) {
|
|
5686
|
-
this.context = e, this.options = e.options || {}, this._items = this.options.contextMenu?.items ||
|
|
5792
|
+
this.context = e, this.options = e.options || {}, this._items = this.options.contextMenu?.items || ai, this.el = null, this._disposers = [], this._menuDisposers = [], this._lastX = 0, this._lastY = 0, this._copiedFormat = null, this._savedRange = null;
|
|
5687
5793
|
}
|
|
5688
5794
|
initialize() {
|
|
5689
5795
|
this.el = w("div", {
|
|
@@ -5769,7 +5875,7 @@ var Hr = [
|
|
|
5769
5875
|
}
|
|
5770
5876
|
if (e.colorPalette) {
|
|
5771
5877
|
let t = w("div", { class: "an-context-color-palette" });
|
|
5772
|
-
if (
|
|
5878
|
+
if (ri.forEach((n) => {
|
|
5773
5879
|
let r = w("div", {
|
|
5774
5880
|
class: "an-context-color-swatch",
|
|
5775
5881
|
title: n,
|
|
@@ -5999,7 +6105,7 @@ var Hr = [
|
|
|
5999
6105
|
} catch {}
|
|
6000
6106
|
this.context.invoke("editor.afterCommand");
|
|
6001
6107
|
}
|
|
6002
|
-
},
|
|
6108
|
+
}, si = [
|
|
6003
6109
|
{
|
|
6004
6110
|
category: "Text Formatting",
|
|
6005
6111
|
items: [
|
|
@@ -6072,12 +6178,12 @@ var Hr = [
|
|
|
6072
6178
|
action: "Show this keyboard shortcuts dialog"
|
|
6073
6179
|
}]
|
|
6074
6180
|
}
|
|
6075
|
-
],
|
|
6181
|
+
], ci = "<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>", li = class extends U {
|
|
6076
6182
|
show() {
|
|
6077
6183
|
this._open();
|
|
6078
6184
|
}
|
|
6079
6185
|
_buildDialog() {
|
|
6080
|
-
let e = this.context.locale.shortcutsDialog, { overlay: t, box: n } = this._buildDialogShell(e.ariaLabel,
|
|
6186
|
+
let e = this.context.locale.shortcutsDialog, { overlay: t, box: n } = this._buildDialogShell(e.ariaLabel, ci, e.title);
|
|
6081
6187
|
n.classList.add("an-shortcuts-box");
|
|
6082
6188
|
let r = w("button", {
|
|
6083
6189
|
type: "button",
|
|
@@ -6085,7 +6191,7 @@ var Hr = [
|
|
|
6085
6191
|
"aria-label": e.close,
|
|
6086
6192
|
style: "margin-left:auto"
|
|
6087
6193
|
});
|
|
6088
|
-
r.textContent = "×", this._closeBtn = r, this._firstInput = r, n.querySelector(".an-dialog-header").appendChild(r), (this.context.locale.shortcutsDialog.shortcuts ||
|
|
6194
|
+
r.textContent = "×", this._closeBtn = r, this._firstInput = r, n.querySelector(".an-dialog-header").appendChild(r), (this.context.locale.shortcutsDialog.shortcuts || si).forEach(({ category: e, items: t }) => {
|
|
6089
6195
|
let r = w("div", { class: "an-shortcuts-cat" });
|
|
6090
6196
|
r.textContent = e, n.appendChild(r);
|
|
6091
6197
|
let i = w("div", { class: "an-shortcuts-table" });
|
|
@@ -6099,7 +6205,7 @@ var Hr = [
|
|
|
6099
6205
|
let i = E(r, "click", () => this._close());
|
|
6100
6206
|
return this._disposers.push(i), t;
|
|
6101
6207
|
}
|
|
6102
|
-
},
|
|
6208
|
+
}, ui = class extends U {
|
|
6103
6209
|
constructor(e) {
|
|
6104
6210
|
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;
|
|
6105
6211
|
}
|
|
@@ -6342,8 +6448,8 @@ var Hr = [
|
|
|
6342
6448
|
this._counterEl.textContent = e ? this.context.locale.findReplace.noResults : "";
|
|
6343
6449
|
} else this._counterEl.textContent = `${this._currentIndex + 1} / ${e}`;
|
|
6344
6450
|
}
|
|
6345
|
-
}, Y = 20,
|
|
6346
|
-
function
|
|
6451
|
+
}, Y = 20, di = "#3b82f6", X = (e, t, n) => Math.min(Math.max(e, t), n);
|
|
6452
|
+
function fi(e, t, n, r) {
|
|
6347
6453
|
return new Promise((i) => {
|
|
6348
6454
|
let a = (e) => {
|
|
6349
6455
|
let a = document.createElement("canvas");
|
|
@@ -6367,7 +6473,7 @@ function Yr(e, t, n, r) {
|
|
|
6367
6473
|
o.crossOrigin = "anonymous", o.onload = () => a(o), o.onerror = () => i(null), o.src = e.src + (e.src.includes("?") ? "&" : "?") + "_an=" + Date.now();
|
|
6368
6474
|
});
|
|
6369
6475
|
}
|
|
6370
|
-
var
|
|
6476
|
+
var pi = class {
|
|
6371
6477
|
constructor(e) {
|
|
6372
6478
|
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 = [];
|
|
6373
6479
|
}
|
|
@@ -6398,7 +6504,7 @@ var Xr = class {
|
|
|
6398
6504
|
t.className = "an-crop-box", t.style.cssText = `
|
|
6399
6505
|
position:fixed; z-index:10101;
|
|
6400
6506
|
box-sizing:border-box;
|
|
6401
|
-
border:2px solid ${
|
|
6507
|
+
border:2px solid ${di};
|
|
6402
6508
|
cursor:move;
|
|
6403
6509
|
outline: none;
|
|
6404
6510
|
`;
|
|
@@ -6463,7 +6569,7 @@ var Xr = class {
|
|
|
6463
6569
|
"position:absolute",
|
|
6464
6570
|
"width:10px",
|
|
6465
6571
|
"height:10px",
|
|
6466
|
-
`background:${
|
|
6572
|
+
`background:${di}`,
|
|
6467
6573
|
"border:2px solid #fff",
|
|
6468
6574
|
"border-radius:2px",
|
|
6469
6575
|
"box-sizing:border-box",
|
|
@@ -6497,7 +6603,7 @@ var Xr = class {
|
|
|
6497
6603
|
let a = this._makeToolbarBtn("✓ Crop", "#22c55e", () => this._confirm()), o = this._makeToolbarBtn("✕ Cancel", "#94a3b8", () => this._close(!1)), s = document.createElement("label");
|
|
6498
6604
|
s.style.cssText = "color:#94a3b8;font-size:11px;cursor:pointer;display:flex;align-items:center;gap:4px;";
|
|
6499
6605
|
let c = document.createElement("input");
|
|
6500
|
-
c.type = "checkbox", c.style.accentColor =
|
|
6606
|
+
c.type = "checkbox", c.style.accentColor = di, 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;
|
|
6501
6607
|
}
|
|
6502
6608
|
_makeToolbarBtn(e, t, n) {
|
|
6503
6609
|
let r = document.createElement("button");
|
|
@@ -6582,7 +6688,7 @@ var Xr = class {
|
|
|
6582
6688
|
this._close(!1);
|
|
6583
6689
|
return;
|
|
6584
6690
|
}
|
|
6585
|
-
let f = await
|
|
6691
|
+
let f = await fi(e, {
|
|
6586
6692
|
x: c,
|
|
6587
6693
|
y: l,
|
|
6588
6694
|
width: u,
|
|
@@ -6626,7 +6732,7 @@ var Xr = class {
|
|
|
6626
6732
|
e?.remove();
|
|
6627
6733
|
}), 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;
|
|
6628
6734
|
}
|
|
6629
|
-
},
|
|
6735
|
+
}, mi = class {
|
|
6630
6736
|
constructor(e) {
|
|
6631
6737
|
this.context = e, this.options = e.options, this._banner = null;
|
|
6632
6738
|
}
|
|
@@ -6679,7 +6785,7 @@ var Xr = class {
|
|
|
6679
6785
|
_removeBanner() {
|
|
6680
6786
|
this._banner?.remove(), this._banner = null;
|
|
6681
6787
|
}
|
|
6682
|
-
},
|
|
6788
|
+
}, hi = class {
|
|
6683
6789
|
constructor(e) {
|
|
6684
6790
|
this.context = e, this.options = e.options, this._disposers = [];
|
|
6685
6791
|
}
|
|
@@ -6692,7 +6798,13 @@ var Xr = class {
|
|
|
6692
6798
|
this._disposers.forEach((e) => e()), this._disposers = [];
|
|
6693
6799
|
}
|
|
6694
6800
|
_onKeydown(e) {
|
|
6695
|
-
e.key === " " ? this._applyBlockRule() && e.preventDefault() : e.key === "Enter" && this._applyEnterRule() && e.preventDefault();
|
|
6801
|
+
this._inCodeContext() || (e.key === " " ? this._applyBlockRule() && e.preventDefault() : e.key === "Enter" && this._applyEnterRule() && e.preventDefault());
|
|
6802
|
+
}
|
|
6803
|
+
_inCodeContext() {
|
|
6804
|
+
let e = globalThis.getSelection();
|
|
6805
|
+
if (!e?.rangeCount) return !1;
|
|
6806
|
+
let t = e.getRangeAt(0).startContainer;
|
|
6807
|
+
return !!(t.nodeType === Node.ELEMENT_NODE ? t : t.parentElement)?.closest("pre, code");
|
|
6696
6808
|
}
|
|
6697
6809
|
_getLineContext() {
|
|
6698
6810
|
let e = globalThis.getSelection();
|
|
@@ -6721,7 +6833,7 @@ var Xr = class {
|
|
|
6721
6833
|
if (!e) return !1;
|
|
6722
6834
|
let { text: t } = e, n = [
|
|
6723
6835
|
{
|
|
6724
|
-
re: /^(#{1,
|
|
6836
|
+
re: /^(#{1,6})$/,
|
|
6725
6837
|
handler: (e) => this._convertToHeading(e[1].length)
|
|
6726
6838
|
},
|
|
6727
6839
|
{
|
|
@@ -6729,16 +6841,16 @@ var Xr = class {
|
|
|
6729
6841
|
handler: () => this._convertToBlockquote()
|
|
6730
6842
|
},
|
|
6731
6843
|
{
|
|
6732
|
-
re: /^[
|
|
6844
|
+
re: /^[-*+]$/,
|
|
6733
6845
|
handler: () => this._convertToList("ul")
|
|
6734
6846
|
},
|
|
6735
6847
|
{
|
|
6736
|
-
re: /^1
|
|
6848
|
+
re: /^1[.)]$/,
|
|
6737
6849
|
handler: () => this._convertToList("ol")
|
|
6738
6850
|
},
|
|
6739
6851
|
{
|
|
6740
|
-
re: /^\[ \]$/,
|
|
6741
|
-
handler: () => this._convertToChecklist()
|
|
6852
|
+
re: /^\[([ xX])\]$/,
|
|
6853
|
+
handler: (e) => this._convertToChecklist(e[1].toLowerCase() === "x")
|
|
6742
6854
|
}
|
|
6743
6855
|
];
|
|
6744
6856
|
for (let { re: e, handler: r } of n) {
|
|
@@ -6751,7 +6863,7 @@ var Xr = class {
|
|
|
6751
6863
|
let e = this._getLineContext();
|
|
6752
6864
|
if (!e) return !1;
|
|
6753
6865
|
let { text: t } = e;
|
|
6754
|
-
return
|
|
6866
|
+
return /^(?:-{3,}|\*{3,}|_{3,})$/.test(t) ? (this._convertToHr(), !0) : /^(?:`{3}|~{3})/.test(t) ? (this._convertToCodeBlock(), !0) : !1;
|
|
6755
6867
|
}
|
|
6756
6868
|
_selectLineAndDelete() {
|
|
6757
6869
|
let e = globalThis.getSelection();
|
|
@@ -6768,8 +6880,12 @@ var Xr = class {
|
|
|
6768
6880
|
_convertToList(e) {
|
|
6769
6881
|
this._selectLineAndDelete(), document.execCommand(e === "ul" ? "insertUnorderedList" : "insertOrderedList"), this.context.triggerEvent("change", this.context.getHTML());
|
|
6770
6882
|
}
|
|
6771
|
-
_convertToChecklist() {
|
|
6772
|
-
this._selectLineAndDelete(), this.context.invoke("editor.toggleChecklist"),
|
|
6883
|
+
_convertToChecklist(e = !1) {
|
|
6884
|
+
if (this._selectLineAndDelete(), this.context.invoke("editor.toggleChecklist"), e) {
|
|
6885
|
+
let e = globalThis.getSelection(), t = e?.rangeCount ? e.getRangeAt(0).startContainer : null, n = (t?.nodeType === Node.ELEMENT_NODE ? t : t?.parentElement ?? null)?.closest("li")?.querySelector("input[type=\"checkbox\"]") ?? null;
|
|
6886
|
+
n && (n.checked = !0);
|
|
6887
|
+
}
|
|
6888
|
+
this.context.triggerEvent("change", this.context.getHTML());
|
|
6773
6889
|
}
|
|
6774
6890
|
_convertToHr() {
|
|
6775
6891
|
this._selectLineAndDelete(), this.context.invoke("editor.insertHr"), this.context.triggerEvent("change", this.context.getHTML());
|
|
@@ -6778,6 +6894,7 @@ var Xr = class {
|
|
|
6778
6894
|
this._selectLineAndDelete(), document.execCommand("formatBlock", !1, "pre"), this.context.triggerEvent("change", this.context.getHTML());
|
|
6779
6895
|
}
|
|
6780
6896
|
_onInput() {
|
|
6897
|
+
if (this._inCodeContext()) return;
|
|
6781
6898
|
let e = globalThis.getSelection();
|
|
6782
6899
|
if (!e?.rangeCount) return;
|
|
6783
6900
|
let t = e.getRangeAt(0);
|
|
@@ -6814,7 +6931,7 @@ var Xr = class {
|
|
|
6814
6931
|
break;
|
|
6815
6932
|
}
|
|
6816
6933
|
}
|
|
6817
|
-
},
|
|
6934
|
+
}, gi = [
|
|
6818
6935
|
"#000000",
|
|
6819
6936
|
"#434343",
|
|
6820
6937
|
"#666666",
|
|
@@ -6839,7 +6956,7 @@ var Xr = class {
|
|
|
6839
6956
|
"#c9daf8",
|
|
6840
6957
|
"#d9d2e9",
|
|
6841
6958
|
"#ead1dc"
|
|
6842
|
-
],
|
|
6959
|
+
], _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>`, vi = {
|
|
6843
6960
|
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\"/>"),
|
|
6844
6961
|
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\"/>"),
|
|
6845
6962
|
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\"/>"),
|
|
@@ -6849,7 +6966,7 @@ var Xr = class {
|
|
|
6849
6966
|
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\"/>"),
|
|
6850
6967
|
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\"/>"),
|
|
6851
6968
|
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\"/>")
|
|
6852
|
-
},
|
|
6969
|
+
}, yi = {
|
|
6853
6970
|
bold: (e) => e.invoke("editor.bold"),
|
|
6854
6971
|
italic: (e) => e.invoke("editor.italic"),
|
|
6855
6972
|
underline: (e) => e.invoke("editor.underline"),
|
|
@@ -6870,15 +6987,15 @@ var Xr = class {
|
|
|
6870
6987
|
e.invoke("editor.afterCommand");
|
|
6871
6988
|
},
|
|
6872
6989
|
inlineCode: (e) => e.invoke("editor.inlineCode")
|
|
6873
|
-
},
|
|
6990
|
+
}, bi = {
|
|
6874
6991
|
bold: () => document.queryCommandState("bold"),
|
|
6875
6992
|
italic: () => document.queryCommandState("italic"),
|
|
6876
6993
|
underline: () => document.queryCommandState("underline"),
|
|
6877
6994
|
strikethrough: () => document.queryCommandState("strikeThrough")
|
|
6878
|
-
},
|
|
6995
|
+
}, xi = {
|
|
6879
6996
|
foreColor: !0,
|
|
6880
6997
|
hiliteColor: !0
|
|
6881
|
-
},
|
|
6998
|
+
}, Si = class {
|
|
6882
6999
|
constructor(e) {
|
|
6883
7000
|
this.context = e, this.options = e.options, this._el = null, this._picker = null, this._pickerType = null, this._savedRange = null, this._visible = !1, this._rafId = null, this._contextMenuOpen = !1, this._disposers = [], this._onSelectionChange = this._onSelectionChange.bind(this), this._onMousedown = this._onMousedown.bind(this), this._onKeydown = this._onKeydown.bind(this), this._onContextMenu = this._onContextMenu.bind(this);
|
|
6884
7001
|
}
|
|
@@ -6908,23 +7025,23 @@ var Xr = class {
|
|
|
6908
7025
|
"removeFormat"
|
|
6909
7026
|
];
|
|
6910
7027
|
for (let n of t) {
|
|
6911
|
-
if (!
|
|
7028
|
+
if (!vi[n]) continue;
|
|
6912
7029
|
let t = document.createElement("button");
|
|
6913
|
-
if (t.type = "button", t.dataset.name = n, t.setAttribute("aria-label", n),
|
|
7030
|
+
if (t.type = "button", t.dataset.name = n, t.setAttribute("aria-label", n), xi[n]) {
|
|
6914
7031
|
t.className = "an-bubble-btn an-bubble-btn--color";
|
|
6915
7032
|
let e = document.createElement("span");
|
|
6916
|
-
e.className = "an-bubble-btn-svg", e.innerHTML =
|
|
7033
|
+
e.className = "an-bubble-btn-svg", e.innerHTML = vi[n];
|
|
6917
7034
|
let r = document.createElement("span");
|
|
6918
7035
|
r.className = "an-bubble-color-strip", r.style.background = n === "foreColor" ? "#000000" : "transparent", t.appendChild(e), t.appendChild(r);
|
|
6919
|
-
} else t.className = "an-bubble-btn", t.innerHTML =
|
|
7036
|
+
} else t.className = "an-bubble-btn", t.innerHTML = vi[n];
|
|
6920
7037
|
t.addEventListener("mousedown", (e) => {
|
|
6921
7038
|
e.preventDefault();
|
|
6922
7039
|
}), t.addEventListener("click", (e) => {
|
|
6923
|
-
if (e.preventDefault(), e.stopPropagation(),
|
|
7040
|
+
if (e.preventDefault(), e.stopPropagation(), xi[n]) {
|
|
6924
7041
|
this._openColorPicker(n, t);
|
|
6925
7042
|
return;
|
|
6926
7043
|
}
|
|
6927
|
-
this.context.invoke("editor.focus"),
|
|
7044
|
+
this.context.invoke("editor.focus"), yi[n] && yi[n](this.context), this._syncActive();
|
|
6928
7045
|
}), e.appendChild(t);
|
|
6929
7046
|
}
|
|
6930
7047
|
document.body.appendChild(e), this._el = e, this._btnCache = Array.from(e.querySelectorAll(".an-bubble-btn"));
|
|
@@ -6933,7 +7050,7 @@ var Xr = class {
|
|
|
6933
7050
|
let e = document.createElement("div");
|
|
6934
7051
|
e.className = "an-bubble-color-picker", e.style.display = "none", e.addEventListener("mousedown", (e) => e.preventDefault());
|
|
6935
7052
|
let t = document.createElement("div");
|
|
6936
|
-
t.className = "an-context-color-palette",
|
|
7053
|
+
t.className = "an-context-color-palette", gi.forEach((e) => {
|
|
6937
7054
|
let n = document.createElement("div");
|
|
6938
7055
|
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) => {
|
|
6939
7056
|
t.stopPropagation(), this._applyColor(this._pickerType, e);
|
|
@@ -7001,7 +7118,7 @@ var Xr = class {
|
|
|
7001
7118
|
}
|
|
7002
7119
|
_syncActive() {
|
|
7003
7120
|
this._btnCache && this._btnCache.forEach((e) => {
|
|
7004
|
-
let t =
|
|
7121
|
+
let t = bi[e.dataset.name];
|
|
7005
7122
|
e.classList.toggle("an-active", !!t?.());
|
|
7006
7123
|
});
|
|
7007
7124
|
}
|
|
@@ -7052,7 +7169,7 @@ var Xr = class {
|
|
|
7052
7169
|
_onContextMenu() {
|
|
7053
7170
|
this._hide();
|
|
7054
7171
|
}
|
|
7055
|
-
},
|
|
7172
|
+
}, Ci = class {
|
|
7056
7173
|
constructor(e) {
|
|
7057
7174
|
this.context = e, this._dropdown = null, this._query = "", this._debounceTimer = null, this._activeIndex = -1, this._items = [], this._open = !1, this._triggerNode = null, this._triggerOffset = 0, this._caretRect = null, this._disposers = [];
|
|
7058
7175
|
}
|
|
@@ -7197,7 +7314,7 @@ var Xr = class {
|
|
|
7197
7314
|
let n;
|
|
7198
7315
|
typeof this._cfg.onInsert == "function" && (n = this._cfg.onInsert(t)), n ||= `<span class="${this._cfg.mentionClass}" data-mention-id="${t.id}" contenteditable="false">@${t.label}</span>`, this.context.invoke("editor.insertHTML", n + "​"), this._hideDropdown(), this.context.triggerEvent("change", this.context.getHTML());
|
|
7199
7316
|
}
|
|
7200
|
-
},
|
|
7317
|
+
}, wi = class {
|
|
7201
7318
|
constructor(e) {
|
|
7202
7319
|
this.context = e, this.options = e.options, this._disposers = [], this._menu = null, this._filtered = [], this._activeIndex = -1, this._open = !1, this._query = "", this._textNode = null, this._triggerOffset = 0, this._caretRect = null;
|
|
7203
7320
|
}
|
|
@@ -7424,38 +7541,38 @@ var Xr = class {
|
|
|
7424
7541
|
this._deleteTriggerText(), this._close(), t.run();
|
|
7425
7542
|
}
|
|
7426
7543
|
}
|
|
7427
|
-
},
|
|
7544
|
+
}, Ti = /* @__PURE__ */ new Map(), Ei = [
|
|
7428
7545
|
{
|
|
7429
7546
|
name: "autoSaveRestore",
|
|
7430
|
-
Class:
|
|
7547
|
+
Class: mi,
|
|
7431
7548
|
enabled: (e) => !!e.autoSaveRestore
|
|
7432
7549
|
},
|
|
7433
7550
|
{
|
|
7434
7551
|
name: "markdownShortcuts",
|
|
7435
|
-
Class:
|
|
7552
|
+
Class: hi,
|
|
7436
7553
|
enabled: (e) => e.markdownShortcuts !== !1
|
|
7437
7554
|
},
|
|
7438
7555
|
{
|
|
7439
7556
|
name: "bubbleToolbar",
|
|
7440
|
-
Class:
|
|
7557
|
+
Class: Si,
|
|
7441
7558
|
enabled: (e) => !!e.bubbleToolbar
|
|
7442
7559
|
},
|
|
7443
7560
|
{
|
|
7444
7561
|
name: "mention",
|
|
7445
|
-
Class:
|
|
7562
|
+
Class: Ci,
|
|
7446
7563
|
enabled: (e) => !!e.mention
|
|
7447
7564
|
},
|
|
7448
7565
|
{
|
|
7449
7566
|
name: "slashMenu",
|
|
7450
|
-
Class:
|
|
7567
|
+
Class: wi,
|
|
7451
7568
|
enabled: (e) => e.slashMenu !== !1
|
|
7452
7569
|
}
|
|
7453
|
-
],
|
|
7570
|
+
], Di = /* @__PURE__ */ new Map(), Oi = class {
|
|
7454
7571
|
constructor(e, t = {}) {
|
|
7455
7572
|
this.targetEl = e, this.options = c(A, t), this.locale = Wt(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;
|
|
7456
7573
|
}
|
|
7457
7574
|
initialize() {
|
|
7458
|
-
let { container: e, editable: t } =
|
|
7575
|
+
let { container: e, editable: t } = ln(this.targetEl, this.options);
|
|
7459
7576
|
this.layoutInfo.container = e, this.layoutInfo.editable = t, this._registerModules();
|
|
7460
7577
|
let n = this._modules.get("toolbar");
|
|
7461
7578
|
n?.el && (e.insertBefore(n.el, t), this.layoutInfo.toolbar = n.el);
|
|
@@ -7467,12 +7584,12 @@ var Xr = class {
|
|
|
7467
7584
|
let n = new t(this);
|
|
7468
7585
|
this._modules.set(e, n), n.initialize();
|
|
7469
7586
|
};
|
|
7470
|
-
e("editor",
|
|
7471
|
-
for (let { name: t, Class: n, enabled: r } of
|
|
7472
|
-
if (
|
|
7587
|
+
e("editor", or), e("toolbar", ur), e("statusbar", mr), e("clipboard", hr), e("contextMenu", oi), e("placeholder", gr), e("codeview", _r), e("fullscreen", vr), e("linkDialog", br), e("imageDialog", Sr), e("videoDialog", wr), e("imageResizer", Dr), e("videoResizer", Or), e("linkTooltip", Mr), e("imageTooltip", Pr), e("videoTooltip", Fr), e("tableTooltip", Hr), e("codeTooltip", qr), e("emojiDialog", Zr), e("iconDialog", ni), e("shortcutsDialog", li), e("findReplace", ui), e("imageCropOverlay", pi);
|
|
7588
|
+
for (let { name: t, Class: n, enabled: r } of Ei) r(this.options) && e(t, n);
|
|
7589
|
+
if (Ti.size > 0) for (let [t, n] of Ti) e(t, n);
|
|
7473
7590
|
}
|
|
7474
7591
|
_syncOptionalModules() {
|
|
7475
|
-
for (let { name: e, Class: t, enabled: n } of
|
|
7592
|
+
for (let { name: e, Class: t, enabled: n } of Ei) {
|
|
7476
7593
|
let r = n(this.options);
|
|
7477
7594
|
if (r !== this._modules.has(e)) if (r) {
|
|
7478
7595
|
let n = new t(this);
|
|
@@ -7516,7 +7633,7 @@ var Xr = class {
|
|
|
7516
7633
|
});
|
|
7517
7634
|
}
|
|
7518
7635
|
_applyGlobalPlugins() {
|
|
7519
|
-
if (
|
|
7636
|
+
if (Di.size !== 0) for (let { plugin: e, options: t } of Di.values()) this._installPlugin(e, t);
|
|
7520
7637
|
}
|
|
7521
7638
|
_bindEditorEvents(e) {
|
|
7522
7639
|
let t = E(e, "input", () => this._syncToTarget()), n = E(e, "focus", () => {
|
|
@@ -7772,39 +7889,39 @@ var Xr = class {
|
|
|
7772
7889
|
};
|
|
7773
7890
|
//#endregion
|
|
7774
7891
|
//#region src/js/core/lists.js
|
|
7775
|
-
function
|
|
7892
|
+
function ki(e) {
|
|
7776
7893
|
return e[e.length - 1];
|
|
7777
7894
|
}
|
|
7778
|
-
function
|
|
7895
|
+
function Ai(e) {
|
|
7779
7896
|
return e[0];
|
|
7780
7897
|
}
|
|
7781
|
-
function
|
|
7898
|
+
function ji(e, t = 1) {
|
|
7782
7899
|
return e.slice(0, e.length - t);
|
|
7783
7900
|
}
|
|
7784
|
-
function
|
|
7901
|
+
function Mi(e, t = 1) {
|
|
7785
7902
|
return e.slice(t);
|
|
7786
7903
|
}
|
|
7787
|
-
function
|
|
7904
|
+
function Ni(e) {
|
|
7788
7905
|
return e.flat();
|
|
7789
7906
|
}
|
|
7790
|
-
function
|
|
7907
|
+
function Pi(e) {
|
|
7791
7908
|
return [...new Set(e)];
|
|
7792
7909
|
}
|
|
7793
|
-
function
|
|
7910
|
+
function Fi(e, t) {
|
|
7794
7911
|
let n = [];
|
|
7795
7912
|
for (let r = 0; r < e.length; r += t) n.push(e.slice(r, r + t));
|
|
7796
7913
|
return n;
|
|
7797
7914
|
}
|
|
7798
|
-
function
|
|
7915
|
+
function Ii(e, t) {
|
|
7799
7916
|
return e.reduce((e, n) => {
|
|
7800
7917
|
let r = t(n);
|
|
7801
7918
|
return e[r] || (e[r] = []), e[r].push(n), e;
|
|
7802
7919
|
}, {});
|
|
7803
7920
|
}
|
|
7804
|
-
function
|
|
7921
|
+
function Li(e, t) {
|
|
7805
7922
|
return e.every(t);
|
|
7806
7923
|
}
|
|
7807
|
-
function
|
|
7924
|
+
function Ri(e, t) {
|
|
7808
7925
|
return e.some(t);
|
|
7809
7926
|
}
|
|
7810
7927
|
//#endregion
|
|
@@ -7812,7 +7929,7 @@ function xi(e, t) {
|
|
|
7812
7929
|
function Q() {
|
|
7813
7930
|
return globalThis.navigator?.userAgent ?? "";
|
|
7814
7931
|
}
|
|
7815
|
-
var
|
|
7932
|
+
var zi = {
|
|
7816
7933
|
get isChrome() {
|
|
7817
7934
|
return /Chrome\//.test(Q()) && !/Edg\//.test(Q());
|
|
7818
7935
|
},
|
|
@@ -7837,17 +7954,17 @@ var Si = {
|
|
|
7837
7954
|
get modifierKey() {
|
|
7838
7955
|
return /Macintosh/.test(Q()) ? "metaKey" : "ctrlKey";
|
|
7839
7956
|
}
|
|
7840
|
-
},
|
|
7957
|
+
}, Bi = { ...A }, $ = /* @__PURE__ */ new WeakMap(), Vi = {
|
|
7841
7958
|
create(e, t = {}) {
|
|
7842
|
-
let n =
|
|
7959
|
+
let n = Hi(e).map((e) => {
|
|
7843
7960
|
if ($.has(e)) return $.get(e);
|
|
7844
|
-
let n = new
|
|
7961
|
+
let n = new Oi(e, t);
|
|
7845
7962
|
return n.initialize(), $.set(e, n), n;
|
|
7846
7963
|
});
|
|
7847
7964
|
return n.length === 1 ? n[0] : n;
|
|
7848
7965
|
},
|
|
7849
7966
|
destroy(e) {
|
|
7850
|
-
|
|
7967
|
+
Hi(e).forEach((e) => {
|
|
7851
7968
|
let t = $.get(e);
|
|
7852
7969
|
t && (t.destroy(), $.delete(e));
|
|
7853
7970
|
});
|
|
@@ -7863,20 +7980,20 @@ var Si = {
|
|
|
7863
7980
|
Object.assign(A, e);
|
|
7864
7981
|
},
|
|
7865
7982
|
resetDefaults() {
|
|
7866
|
-
Object.keys(A).forEach((e) => delete A[e]), Object.assign(A,
|
|
7983
|
+
Object.keys(A).forEach((e) => delete A[e]), Object.assign(A, Bi);
|
|
7867
7984
|
},
|
|
7868
7985
|
registerModule(e, t) {
|
|
7869
|
-
|
|
7986
|
+
Ti.set(e, t);
|
|
7870
7987
|
},
|
|
7871
7988
|
use(e, t = {}) {
|
|
7872
7989
|
if (!e || typeof e.name != "string") throw TypeError("[AutumnNote] AutumnNote.use: plugin must have a string `name` property.");
|
|
7873
|
-
return
|
|
7990
|
+
return Di.has(e.name) ? (console.warn(`[AutumnNote] Plugin "${e.name}" already registered globally. Skipping.`), this) : (Array.isArray(e.buttons) && e.buttons.forEach((e) => $e(e)), Di.set(e.name, {
|
|
7874
7991
|
plugin: e,
|
|
7875
7992
|
options: t
|
|
7876
7993
|
}), this);
|
|
7877
7994
|
},
|
|
7878
7995
|
hasPlugin(e) {
|
|
7879
|
-
return
|
|
7996
|
+
return Di.has(e);
|
|
7880
7997
|
},
|
|
7881
7998
|
registerButton(e) {
|
|
7882
7999
|
return $e(e), this;
|
|
@@ -7890,12 +8007,12 @@ var Si = {
|
|
|
7890
8007
|
return n >= 0 ? t[n] = e : t.push(e), this;
|
|
7891
8008
|
},
|
|
7892
8009
|
buttons: Vt,
|
|
7893
|
-
version: "2.
|
|
8010
|
+
version: "2.3.0"
|
|
7894
8011
|
};
|
|
7895
|
-
function
|
|
8012
|
+
function Hi(e) {
|
|
7896
8013
|
return typeof e == "string" ? Array.from(document.querySelectorAll(e)) : e instanceof Element ? [e] : e instanceof NodeList || Array.isArray(e) ? Array.from(e) : [];
|
|
7897
8014
|
}
|
|
7898
8015
|
//#endregion
|
|
7899
|
-
export {
|
|
8016
|
+
export { Oi as Context, d as ELEMENT_NODE, f as TEXT_NODE, ge as WrappedRange, Qe as _buttonRegistry, ct as alignCenterBtn, ut as alignJustifyBtn, st as alignLeftBtn, lt as alignRightBtn, Li as all, ne as ancestors, Ri as any, zt as backColorBtn, tt as boldBtn, Vt as buttons, It as checklistBtn, re as children, Fi as chunk, e as clamp, S as closest, C as closestPara, At as codeviewBtn, be as collapsedRange, r as compose, w as createElement, ve as currentRange, t as debounce, Vi as default, A as defaultOptions, Bt as defaultToolbar, Et as directionBtn, xt as emojiBtn, zi as env, Nt as findBtn, Pt as findReplaceBtn, Ai as first, Ni as flatten, Dt as fontFamilyBtn, wt as fontSizeBtn, Rt as foreColorBtn, _e as fromNativeRange, jt as fullscreenBtn, et as getButton, Ii as groupBy, _t as hrBtn, St as iconBtn, i as identity, yt as imageBtn, pt as indentBtn, ji as initial, Ft 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, 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, nt as italicBtn, N as key, ki as last, kt as lineHeightBtn, vt as linkBtn, Ht as locales, he as makeDraggable, c as mergeDeep, ae as nextElement, le as nodeValue, ft as olBtn, E as on, mt as outdentBtn, de as outerHtml, Ot as paragraphStyleBtn, fe as placeCaret, ie as prevElement, Lt as printBtn, ye as rangeFromElement, u as rect2bnd, gt as redoBtn, $e as registerButton, Ut as registerLocale, T as remove, Tt as removeFormatBtn, Wt as resolveLocale, M as sanitiseHTML, sn as sanitiseUrl, Mt as shortcutsBtn, Ce as splitText, it as strikeBtn, ot as subscriptBtn, at as superscriptBtn, Ct as tableBtn, Mi as tail, n as throttle, me as trapFocus, dt as ulBtn, rt as underlineBtn, ht as undoBtn, Pi as unique, oe as unwrap, bt as videoBtn, Se as withSavedRange, se as wrap };
|
|
7900
8017
|
|
|
7901
8018
|
//# sourceMappingURL=autumnnote.es.js.map
|