autumnnote 2.5.0 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -63,71 +63,71 @@ function y(e, t, n) {
63
63
  }
64
64
  return null;
65
65
  }
66
- function ae(e, t) {
66
+ function b(e, t) {
67
67
  return y(e, g, t);
68
68
  }
69
- function oe(e, t) {
69
+ function ae(e, t) {
70
70
  let n = [], r = e.parentNode;
71
71
  for (; r && r !== t;) n.push(r), r = r.parentNode;
72
72
  return n;
73
73
  }
74
- function se(e) {
74
+ function oe(e) {
75
75
  return Array.from(e.childNodes);
76
76
  }
77
- function ce(e) {
77
+ function se(e) {
78
78
  let t = e.previousSibling;
79
79
  for (; t && !p(t);) t = t.previousSibling;
80
80
  return t;
81
81
  }
82
- function le(e) {
82
+ function ce(e) {
83
83
  let t = e.nextSibling;
84
84
  for (; t && !p(t);) t = t.nextSibling;
85
85
  return t;
86
86
  }
87
- function b(e, t = {}, n = []) {
87
+ function x(e, t = {}, n = []) {
88
88
  let r = document.createElement(e);
89
89
  for (let [e, n] of Object.entries(t)) r.setAttribute(e, n);
90
90
  for (let e of n) typeof e == "string" ? r.appendChild(document.createTextNode(e)) : r.appendChild(e);
91
91
  return r;
92
92
  }
93
- function x(e) {
93
+ function S(e) {
94
94
  e?.parentNode && e.remove();
95
95
  }
96
- function ue(e) {
96
+ function le(e) {
97
97
  let t = e.parentNode;
98
98
  if (t) {
99
99
  for (; e.firstChild;) t.insertBefore(e.firstChild, e);
100
100
  e.remove();
101
101
  }
102
102
  }
103
- function de(e, t) {
103
+ function ue(e, t) {
104
104
  return e.parentNode.insertBefore(t, e), t.appendChild(e), t;
105
105
  }
106
- function fe(e, t) {
106
+ function de(e, t) {
107
107
  t.nextSibling ? t.parentNode.insertBefore(e, t.nextSibling) : t.parentNode.appendChild(e);
108
108
  }
109
- function pe(e) {
109
+ function fe(e) {
110
110
  return m(e) ? e.nodeValue : e.textContent || "";
111
111
  }
112
- function me(e) {
112
+ function pe(e) {
113
113
  return m(e) ? !e.nodeValue : h(e) ? !1 : e.childNodes.length === 1 && e.firstChild?.nodeName === "BR" || !e.textContent.trim() && !e.querySelector("img, video, hr, table");
114
114
  }
115
- function he(e) {
115
+ function me(e) {
116
116
  return e.outerHTML;
117
117
  }
118
- function ge(e) {
118
+ function he(e) {
119
119
  let t = document.createRange();
120
120
  t.selectNodeContents(e), t.collapse(!1);
121
121
  let n = globalThis.getSelection();
122
122
  n && (n.removeAllRanges(), n.addRange(t));
123
123
  }
124
- function _e(e) {
124
+ function ge(e) {
125
125
  return !!y(e, v);
126
126
  }
127
- function S(e, t, n, r) {
127
+ function C(e, t, n, r) {
128
128
  return e.addEventListener(t, n, r), () => e.removeEventListener(t, n, r);
129
129
  }
130
- function ve(e, t) {
130
+ function _e(e, t) {
131
131
  let n = () => Array.from(e.querySelectorAll("a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])")).filter((e) => !e.closest("[style*=\"display: none\"]") && !e.closest("[style*=\"display:none\"]")), r = (e) => {
132
132
  if (e.key === "Escape") {
133
133
  e.stopPropagation(), t?.();
@@ -141,7 +141,7 @@ function ve(e, t) {
141
141
  };
142
142
  return document.addEventListener("keydown", r), () => document.removeEventListener("keydown", r);
143
143
  }
144
- function ye(e, t) {
144
+ function ve(e, t) {
145
145
  e.style.cursor = "grab";
146
146
  let n = (n) => {
147
147
  if (n.button !== 0 || n.target.closest("button, input, select, textarea, a")) return;
@@ -163,7 +163,7 @@ function ye(e, t) {
163
163
  }
164
164
  //#endregion
165
165
  //#region src/js/core/range.js
166
- var C = class {
166
+ var ye = class {
167
167
  constructor(e, t, n, r) {
168
168
  this.sc = e, this.so = t, this.ec = n, this.eo = r;
169
169
  }
@@ -200,7 +200,7 @@ var C = class {
200
200
  }
201
201
  };
202
202
  function be(e) {
203
- return new C(e.startContainer, e.startOffset, e.endContainer, e.endOffset);
203
+ return new ye(e.startContainer, e.startOffset, e.endContainer, e.endOffset);
204
204
  }
205
205
  function xe(e) {
206
206
  let t = globalThis.getSelection();
@@ -209,10 +209,10 @@ function xe(e) {
209
209
  return e && !e.contains(n.commonAncestorContainer) ? null : be(n);
210
210
  }
211
211
  function Se(e) {
212
- return new C(e, 0, e, e.childNodes.length);
212
+ return new ye(e, 0, e, e.childNodes.length);
213
213
  }
214
214
  function Ce(e, t = 0) {
215
- return new C(e, t, e, t);
215
+ return new ye(e, t, e, t);
216
216
  }
217
217
  function we(e) {
218
218
  let t = globalThis.getSelection();
@@ -1459,7 +1459,10 @@ var tn = [
1459
1459
  "https:",
1460
1460
  "blob:"
1461
1461
  ]), fn = /^data:image\/(?:png|jpe?g|gif|webp|avif|bmp);base64,[a-z0-9+/=\s]+$/i, pn = "https://autumnnote.invalid/";
1462
- function j(e, { allowIframes: t = !1 } = {}) {
1462
+ function j(e, t) {
1463
+ return mn(e, t).innerHTML;
1464
+ }
1465
+ function mn(e, { allowIframes: t = !1 } = {}) {
1463
1466
  let n = new DOMParser().parseFromString(`<body>${e || ""}</body>`, "text/html"), r = Array.from(n.querySelectorAll("*")), i = new Set(t ? tn.filter((e) => e !== "iframe") : tn);
1464
1467
  for (let e of r) {
1465
1468
  let t = e.tagName.toLowerCase();
@@ -1473,7 +1476,7 @@ function j(e, { allowIframes: t = !1 } = {}) {
1473
1476
  }
1474
1477
  if (t === "iframe") {
1475
1478
  let t = e.getAttribute("src");
1476
- if (!t || !gn(t)) {
1479
+ if (!t || !_n(t)) {
1477
1480
  e.remove();
1478
1481
  continue;
1479
1482
  }
@@ -1484,7 +1487,7 @@ function j(e, { allowIframes: t = !1 } = {}) {
1484
1487
  continue;
1485
1488
  }
1486
1489
  if (t.name === "style") {
1487
- let n = mn(t.value);
1490
+ let n = hn(t.value);
1488
1491
  n ? e.setAttribute("style", n) : e.removeAttribute("style");
1489
1492
  continue;
1490
1493
  }
@@ -1499,7 +1502,7 @@ function j(e, { allowIframes: t = !1 } = {}) {
1499
1502
  "AUDIO",
1500
1503
  "SOURCE"
1501
1504
  ].includes(e.tagName), i = e.tagName === "IMG";
1502
- if (!(t.name === "srcset" ? hn(n, { allowData: i }) : _n(n, {
1505
+ if (!(t.name === "srcset" ? gn(n, { allowData: i }) : vn(n, {
1503
1506
  media: r,
1504
1507
  allowData: i
1505
1508
  }))) {
@@ -1512,7 +1515,7 @@ function j(e, { allowIframes: t = !1 } = {}) {
1512
1515
  e.removeAttribute(t.name);
1513
1516
  continue;
1514
1517
  }
1515
- t.name === "src" && !gn(t.value) && e.removeAttribute(t.name);
1518
+ t.name === "src" && !_n(t.value) && e.removeAttribute(t.name);
1516
1519
  }
1517
1520
  }
1518
1521
  if (t === "a" && e.getAttribute("target") === "_blank" && e.setAttribute("rel", "noopener noreferrer"), t === "input") if (!(e.closest("ul.an-checklist") !== null && e.closest("li") !== null) || e.getAttribute("type") !== "checkbox") e.remove();
@@ -1522,9 +1525,9 @@ function j(e, { allowIframes: t = !1 } = {}) {
1522
1525
  "contenteditable"
1523
1526
  ].includes(t.name) || e.removeAttribute(t.name);
1524
1527
  }
1525
- return n.body.innerHTML;
1528
+ return n.body;
1526
1529
  }
1527
- function mn(e) {
1530
+ function hn(e) {
1528
1531
  let t = [];
1529
1532
  for (let n of (e || "").split(";")) {
1530
1533
  let e = n.indexOf(":");
@@ -1534,19 +1537,19 @@ function mn(e) {
1534
1537
  }
1535
1538
  return t.join("; ");
1536
1539
  }
1537
- function hn(e, { allowData: t = !1 } = {}) {
1540
+ function gn(e, { allowData: t = !1 } = {}) {
1538
1541
  let n = (e || "").trim().split(/\s+/).filter(Boolean);
1539
1542
  for (let e of n) {
1540
1543
  if (/^[\d.]+[xw],?$/i.test(e)) continue;
1541
1544
  let n = e.replace(/,+$/, "");
1542
- if (n && !_n(n, {
1545
+ if (n && !vn(n, {
1543
1546
  media: !0,
1544
1547
  allowData: t
1545
1548
  })) return !1;
1546
1549
  }
1547
1550
  return !0;
1548
1551
  }
1549
- function gn(e) {
1552
+ function _n(e) {
1550
1553
  let t = (e || "").trim();
1551
1554
  if (!t || t.startsWith("//") || t.startsWith("/")) return !1;
1552
1555
  try {
@@ -1558,12 +1561,12 @@ function gn(e) {
1558
1561
  }
1559
1562
  function M(e, { allowData: t = !1, media: n = t } = {}) {
1560
1563
  let r = (e || "").trim();
1561
- return !r && e == null ? null : _n(r, {
1564
+ return !r && e == null ? null : vn(r, {
1562
1565
  media: n,
1563
1566
  allowData: t
1564
1567
  }) ? e : null;
1565
1568
  }
1566
- function _n(e, { media: t = !1, allowData: n = !1 } = {}) {
1569
+ function vn(e, { media: t = !1, allowData: n = !1 } = {}) {
1567
1570
  let r = (e || "").trim();
1568
1571
  if (!r || n && fn.test(r)) return !0;
1569
1572
  try {
@@ -1575,8 +1578,8 @@ function _n(e, { media: t = !1, allowData: n = !1 } = {}) {
1575
1578
  }
1576
1579
  //#endregion
1577
1580
  //#region src/js/renderer.js
1578
- function vn(e, t) {
1579
- let n = b("div", { class: "an-container" }), r = b("div", {
1581
+ function yn(e, t) {
1582
+ let n = x("div", { class: "an-container" }), r = x("div", {
1580
1583
  class: "an-editable",
1581
1584
  contenteditable: t.readOnly ? "false" : "true",
1582
1585
  spellcheck: String(t.spellcheck !== !1),
@@ -1598,16 +1601,16 @@ function vn(e, t) {
1598
1601
  }
1599
1602
  //#endregion
1600
1603
  //#region src/js/Context.js
1601
- var yn = /* @__PURE__ */ new Map(), bn = [];
1602
- function xn(e) {
1603
- bn = Array.isArray(e) ? e : [];
1604
+ var bn = /* @__PURE__ */ new Map(), xn = [];
1605
+ function Sn(e) {
1606
+ xn = Array.isArray(e) ? e : [];
1604
1607
  }
1605
- var N = /* @__PURE__ */ new Map(), Sn = class {
1608
+ var N = /* @__PURE__ */ new Map(), Cn = class {
1606
1609
  constructor(e, t = {}) {
1607
1610
  this.targetEl = e, this.options = c(k, t), this.locale = en(this.options.lang), this.layoutInfo = {}, this._listeners = /* @__PURE__ */ new Map(), this._modules = /* @__PURE__ */ new Map(), this._plugins = /* @__PURE__ */ new Map(), this._disposers = [], this._alive = !1, this._autoSaveTimer = null, this._pendingAutoSave = null, this._suppressedRemoteHTML = null, this._destroyPromise = null;
1608
1611
  }
1609
1612
  initialize() {
1610
- let { container: e, editable: t } = vn(this.targetEl, this.options);
1613
+ let { container: e, editable: t } = yn(this.targetEl, this.options);
1611
1614
  this.layoutInfo.container = e, this.layoutInfo.editable = t, this._registerModules();
1612
1615
  let n = this._modules.get("toolbar");
1613
1616
  n?.el && (e.insertBefore(n.el, t), this.layoutInfo.toolbar = n.el);
@@ -1619,11 +1622,11 @@ var N = /* @__PURE__ */ new Map(), Sn = class {
1619
1622
  let n = new t(this);
1620
1623
  this._modules.set(e, n), n.initialize();
1621
1624
  };
1622
- for (let { name: t, Class: n, enabled: r } of bn) typeof r == "function" && !r(this.options) || e(t, n);
1623
- if (yn.size > 0) for (let [t, n] of yn) e(t, n);
1625
+ for (let { name: t, Class: n, enabled: r } of xn) typeof r == "function" && !r(this.options) || e(t, n);
1626
+ if (bn.size > 0) for (let [t, n] of bn) e(t, n);
1624
1627
  }
1625
1628
  _syncOptionalModules() {
1626
- for (let { name: e, Class: t, enabled: n } of bn) {
1629
+ for (let { name: e, Class: t, enabled: n } of xn) {
1627
1630
  if (typeof n != "function") continue;
1628
1631
  let r = n(this.options);
1629
1632
  if (r !== this._modules.has(e)) if (r) {
@@ -1671,9 +1674,9 @@ var N = /* @__PURE__ */ new Map(), Sn = class {
1671
1674
  if (N.size !== 0) for (let { plugin: e, options: t } of N.values()) this._installPlugin(e, t);
1672
1675
  }
1673
1676
  _bindEditorEvents(e) {
1674
- let t = S(e, "input", () => this._syncToTarget()), n = S(e, "focus", () => {
1677
+ let t = C(e, "input", () => this._syncToTarget()), n = C(e, "focus", () => {
1675
1678
  this.layoutInfo.container.classList.add("an-focused"), typeof this.options.onFocus == "function" && this.options.onFocus(this);
1676
- }), r = S(e, "blur", () => {
1679
+ }), r = C(e, "blur", () => {
1677
1680
  this.layoutInfo.container.classList.remove("an-focused"), this._syncToTarget(), typeof this.options.onBlur == "function" && this.options.onBlur(this);
1678
1681
  }), i = this.on("change", (e) => this._syncToTarget(e)), a = this.on("change", (e) => {
1679
1682
  if (this.options.blockIds && (this.ensureBlockIds(), e = this.getHTML()), e === this._suppressedRemoteHTML) {
@@ -1921,7 +1924,7 @@ var N = /* @__PURE__ */ new Map(), Sn = class {
1921
1924
  _syncToTarget(e) {
1922
1925
  (this.targetEl.tagName === "TEXTAREA" || this.targetEl.tagName === "INPUT") && (this.targetEl.value = typeof e == "string" ? e : this.getHTML());
1923
1926
  }
1924
- }, Cn = class {
1927
+ }, wn = class {
1925
1928
  constructor(e, t = 100, n = 10 * 1024 * 1024) {
1926
1929
  this.editable = e, this._limit = t, this._maxBytes = n, this._bytes = 0, this.stack = [], this.stackOffset = -1, this._savePoint();
1927
1930
  }
@@ -2042,31 +2045,31 @@ var N = /* @__PURE__ */ new Map(), Sn = class {
2042
2045
  };
2043
2046
  //#endregion
2044
2047
  //#region src/js/editing/Table.js
2045
- function wn(e, t, n = {}) {
2046
- let { headerRow: r = !1 } = n, i = b("table", { class: "an-table" });
2048
+ function Tn(e, t, n = {}) {
2049
+ let { headerRow: r = !1 } = n, i = x("table", { class: "an-table" });
2047
2050
  if (r && t > 0) {
2048
- let t = b("thead"), n = b("tr");
2051
+ let t = x("thead"), n = x("tr");
2049
2052
  for (let t = 0; t < e; t++) {
2050
- let e = b("th", {}, [document.createElement("br")]);
2053
+ let e = x("th", {}, [document.createElement("br")]);
2051
2054
  n.appendChild(e);
2052
2055
  }
2053
2056
  t.appendChild(n), i.appendChild(t);
2054
2057
  }
2055
- let a = r ? Math.max(t - 1, 1) : t, o = b("tbody");
2058
+ let a = r ? Math.max(t - 1, 1) : t, o = x("tbody");
2056
2059
  i.appendChild(o);
2057
2060
  for (let t = 0; t < a; t++) {
2058
- let t = b("tr");
2061
+ let t = x("tr");
2059
2062
  for (let n = 0; n < e; n++) {
2060
- let e = b("td", {}, [document.createElement("br")]);
2063
+ let e = x("td", {}, [document.createElement("br")]);
2061
2064
  t.appendChild(e);
2062
2065
  }
2063
2066
  o.appendChild(t);
2064
2067
  }
2065
2068
  return i;
2066
2069
  }
2067
- function Tn(e, t, n = {}) {
2070
+ function En(e, t, n = {}) {
2068
2071
  if (e <= 0 || t <= 0) return;
2069
- let r = wn(e, t, n), i = globalThis.getSelection();
2072
+ let r = Tn(e, t, n), i = globalThis.getSelection();
2070
2073
  if (!i || i.rangeCount === 0) return;
2071
2074
  let a = i.getRangeAt(0);
2072
2075
  try {
@@ -2154,8 +2157,8 @@ function I(e, t) {
2154
2157
  }
2155
2158
  //#endregion
2156
2159
  //#region src/js/editing/Typing.js
2157
- var En = /\bfa-/, L = (e) => !!(e?.nodeName === "I" && En.test(e.className || "")), R = (e) => e?.nodeType === Node.TEXT_NODE && (e.textContent === "​" || e.textContent === "");
2158
- function Dn(e, t) {
2160
+ var Dn = /\bfa-/, L = (e) => !!(e?.nodeName === "I" && Dn.test(e.className || "")), R = (e) => e?.nodeType === Node.TEXT_NODE && (e.textContent === "​" || e.textContent === "");
2161
+ function On(e, t) {
2159
2162
  try {
2160
2163
  let n = document.createRange();
2161
2164
  return n.setStart(e.startContainer, e.startOffset), n.setEnd(t, t.childNodes.length), n.extractContents();
@@ -2163,7 +2166,7 @@ function Dn(e, t) {
2163
2166
  return document.createDocumentFragment();
2164
2167
  }
2165
2168
  }
2166
- function On(e, t, n = {}) {
2169
+ function kn(e, t, n = {}) {
2167
2170
  let r = (e) => {
2168
2171
  let t = globalThis.getSelection();
2169
2172
  if (!t) return !1;
@@ -2246,7 +2249,7 @@ function On(e, t, n = {}) {
2246
2249
  if (F(e, P.TAB)) {
2247
2250
  let r = xe(t);
2248
2251
  if (!r) return !1;
2249
- let i = ae(r.sc, t);
2252
+ let i = b(r.sc, t);
2250
2253
  if (i && ee(i)) return e.preventDefault(), e.shiftKey ? Qe() : w("indent"), !0;
2251
2254
  if (i?.nodeName.toUpperCase() === "PRE") return e.shiftKey ? !1 : (e.preventDefault(), w("insertText", " ".repeat(n.tabSize || 4)), !0);
2252
2255
  if (n.tabSize) return e.shiftKey ? !1 : (e.preventDefault(), w("insertText", " ".repeat(n.tabSize)), !0);
@@ -2286,14 +2289,14 @@ function On(e, t, n = {}) {
2286
2289
  if (r.deleteContents(), n.rangeCount === 0 || !o.isConnected) return !0;
2287
2290
  r = n.getRangeAt(0);
2288
2291
  }
2289
- let i = Dn(r, o), a = document.createElement("li"), s = document.createElement("input");
2292
+ let i = On(r, o), a = document.createElement("li"), s = document.createElement("input");
2290
2293
  s.type = "checkbox", s.setAttribute("contenteditable", "false"), a.appendChild(s), i.textContent.replace(/[\u00a0\u200B]/g, "").length > 0 && a.appendChild(i);
2291
2294
  let c = a.childNodes[1];
2292
2295
  c?.nodeType !== Node.TEXT_NODE && (c = document.createTextNode("​"), a.appendChild(c)), o.after(a);
2293
2296
  let l = document.createRange();
2294
2297
  return l.setStart(c, 0), l.collapse(!0), n.removeAllRanges(), n.addRange(l), !0;
2295
2298
  }
2296
- let s = ae(n.sc, t);
2299
+ let s = b(n.sc, t);
2297
2300
  if (s?.nodeName.toUpperCase() === "PRE") return e.preventDefault(), w("insertText", "\n"), !0;
2298
2301
  if (s?.nodeName.toUpperCase() === "BLOCKQUOTE") {
2299
2302
  let t = n.toNativeRange();
@@ -2304,13 +2307,13 @@ function On(e, t, n = {}) {
2304
2307
  }
2305
2308
  //#endregion
2306
2309
  //#region src/js/core/markdown.js
2307
- function kn(e) {
2308
- return In(new DOMParser().parseFromString(`<body>${e || ""}</body>`, "text/html").body).replace(/\n{3,}/g, "\n\n").trim();
2310
+ function An(e) {
2311
+ return Ln(new DOMParser().parseFromString(`<body>${e || ""}</body>`, "text/html").body).replace(/\n{3,}/g, "\n\n").trim();
2309
2312
  }
2310
2313
  function z(e, t) {
2311
2314
  return Array.from(e.children).filter((e) => e.tagName === t.toUpperCase());
2312
2315
  }
2313
- function An(e) {
2316
+ function jn(e) {
2314
2317
  let t = "";
2315
2318
  for (let n of e.childNodes) {
2316
2319
  if (n.nodeType === 3) {
@@ -2324,40 +2327,40 @@ function An(e) {
2324
2327
  continue;
2325
2328
  }
2326
2329
  if (e === "div" || e === "p") {
2327
- t && !t.endsWith("\n") && (t += "\n"), t += An(n), t += "\n";
2330
+ t && !t.endsWith("\n") && (t += "\n"), t += jn(n), t += "\n";
2328
2331
  continue;
2329
2332
  }
2330
- t += An(n);
2333
+ t += jn(n);
2331
2334
  }
2332
2335
  return t;
2333
2336
  }
2334
- function jn(e) {
2337
+ function Mn(e) {
2335
2338
  return e.replaceAll("\\", "\\\\").replace(/&(?=#\d+;|#[xX][0-9a-fA-F]+;|[a-zA-Z][a-zA-Z0-9]*;)/g, "&amp;").replace(/!(?=\[)/g, String.raw`\!`).replace(/([`*[\]])/g, String.raw`\$1`).replace(/(?<!\w)_|_(?!\w)/g, String.raw`\_`).replace(/~(?=~)|(?<=~)~/g, String.raw`\~`);
2336
2339
  }
2337
- function Mn(e) {
2340
+ function Nn(e) {
2338
2341
  return /^\s*(?:-{2,}|={2,}|\*{3,}|_{3,}|(?:[-*_] +){2,}[-*_])\s*$/.test(e) ? e.replace(/[-=*_]/, (e) => `\\${e}`) : e.replace(/^(\s*)(#{1,6})(?=\s|$)/, (e, t, n) => `${t}\\${n}`).replace(/^(\s*)>/, (e, t) => `${t}\\>`).replace(/^(\s*)([-*+])(?=\s)/, (e, t, n) => `${t}\\${n}`).replace(/^(\s*)(\d+)([.)])(?=\s)/, (e, t, n, r) => `${t}${n}\\${r}`);
2339
2342
  }
2340
- function Nn(e) {
2341
- return e.split("\n").map(Mn).join("\n");
2343
+ function Pn(e) {
2344
+ return e.split("\n").map(Nn).join("\n");
2342
2345
  }
2343
- function Pn(e, t) {
2346
+ function Fn(e, t) {
2344
2347
  let n = " ".repeat(t + 1);
2345
- return In(e, t + 1).trim().split("\n").map((e, t) => t === 0 || e.trim() === "" || e.startsWith(n) ? e : n + e).join("\n");
2348
+ return Ln(e, t + 1).trim().split("\n").map((e, t) => t === 0 || e.trim() === "" || e.startsWith(n) ? e : n + e).join("\n");
2346
2349
  }
2347
- function Fn(e, t) {
2350
+ function In(e, t) {
2348
2351
  let n = e.getAttribute(t) || "", r = /[\s()]/.test(n) ? `<${n}>` : n, i = e.getAttribute("title");
2349
2352
  return i ? `${r} "${i.replaceAll("\"", String.raw`\"`)}"` : r;
2350
2353
  }
2351
- function In(e, t = 0) {
2354
+ function Ln(e, t = 0) {
2352
2355
  if (e.nodeType === 3) {
2353
2356
  let t = e.textContent.replace(/\s+/g, " ");
2354
- return e.parentElement?.closest("pre, code") ? t : jn(t);
2357
+ return e.parentElement?.closest("pre, code") ? t : Mn(t);
2355
2358
  }
2356
2359
  if (e.nodeType !== 1) return "";
2357
- let n = e, r = n.nodeName.toLowerCase(), i = () => Array.from(n.childNodes).map((e) => In(e, t)).join("");
2360
+ let n = e, r = n.nodeName.toLowerCase(), i = () => Array.from(n.childNodes).map((e) => Ln(e, t)).join("");
2358
2361
  switch (r) {
2359
2362
  case "p":
2360
- case "div": return `\n\n${Nn(i())}\n\n`;
2363
+ case "div": return `\n\n${Pn(i())}\n\n`;
2361
2364
  case "br": return " \n";
2362
2365
  case "h1": return `\n\n# ${i()}\n\n`;
2363
2366
  case "h2": return `\n\n## ${i()}\n\n`;
@@ -2386,27 +2389,27 @@ function In(e, t = 0) {
2386
2389
  }
2387
2390
  case "pre": {
2388
2391
  let e = n.querySelector("code"), t = /language-(\S+)/.exec(e?.className || "");
2389
- return `\n\n\`\`\`${t ? t[1] : ""}\n${An(e || n).replace(/\n$/, "")}\n\`\`\`\n\n`;
2392
+ return `\n\n\`\`\`${t ? t[1] : ""}\n${jn(e || n).replace(/\n$/, "")}\n\`\`\`\n\n`;
2390
2393
  }
2391
2394
  case "blockquote": {
2392
2395
  let e = i().trim().split("\n");
2393
2396
  return `\n\n${e.filter((t, n) => t.trim() !== "" || (e[n - 1] ?? "").trim() !== "").map((e) => e.trim() === "" ? ">" : `> ${e}`).join("\n")}\n\n`;
2394
2397
  }
2395
- case "a": return `[${i()}](${Fn(n, "href")})`;
2396
- case "img": return `![${jn(n.getAttribute("alt") || "")}](${Fn(n, "src")})`;
2398
+ case "a": return `[${i()}](${In(n, "href")})`;
2399
+ case "img": return `![${Mn(n.getAttribute("alt") || "")}](${In(n, "src")})`;
2397
2400
  case "ul": {
2398
2401
  let e = z(n, "li");
2399
2402
  if (!e.length) return i();
2400
2403
  let r = " ".repeat(t), a = n.classList.contains("an-checklist"), o = e.map((e) => {
2401
2404
  let n = z(e, "input").find((e) => e.getAttribute("type") === "checkbox"), i = "- ";
2402
- return (a || n) && (i = n && n.checked ? "- [x] " : "- [ ] "), `${r}${i}${Pn(e, t)}`;
2405
+ return (a || n) && (i = n && n.checked ? "- [x] " : "- [ ] "), `${r}${i}${Fn(e, t)}`;
2403
2406
  }).join("\n");
2404
2407
  return t === 0 ? `\n\n${o}\n\n` : `\n${o}`;
2405
2408
  }
2406
2409
  case "ol": {
2407
2410
  let e = z(n, "li");
2408
2411
  if (!e.length) return i();
2409
- let r = " ".repeat(t), a = Number.parseInt(n.getAttribute("start") || "1", 10), o = Number.isFinite(a) ? a : 1, s = e.map((e, n) => `${r}${o + n}. ${Pn(e, t)}`).join("\n");
2412
+ let r = " ".repeat(t), a = Number.parseInt(n.getAttribute("start") || "1", 10), o = Number.isFinite(a) ? a : 1, s = e.map((e, n) => `${r}${o + n}. ${Fn(e, t)}`).join("\n");
2410
2413
  return t === 0 ? `\n\n${s}\n\n` : `\n${s}`;
2411
2414
  }
2412
2415
  case "li": return i();
@@ -2414,7 +2417,7 @@ function In(e, t = 0) {
2414
2417
  case "table": {
2415
2418
  let e = Array.from(n.querySelectorAll("tr"));
2416
2419
  if (!e.length) return i();
2417
- let t = !!z(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) => jn(e.textContent.trim()).replaceAll("|", String.raw`\|`))), a = Math.max(...r.map((e) => e.length)), o = (e) => {
2420
+ let t = !!z(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) => Mn(e.textContent.trim()).replaceAll("|", String.raw`\|`))), a = Math.max(...r.map((e) => e.length)), o = (e) => {
2418
2421
  let t = [...e];
2419
2422
  for (; t.length < a;) t.push("");
2420
2423
  return t;
@@ -2429,16 +2432,16 @@ function In(e, t = 0) {
2429
2432
  default: return i();
2430
2433
  }
2431
2434
  }
2432
- function Ln(e) {
2435
+ function Rn(e) {
2433
2436
  return String(e ?? "").replace(/^\ufeff/, "");
2434
2437
  }
2435
- function Rn(e) {
2436
- let t = Ln(e);
2438
+ function zn(e) {
2439
+ let t = Rn(e);
2437
2440
  return /^#{1,6} [^\s]|^[ \t]*[-*+] [^\s]|^[ \t]*\d+[.)] [^\s]|^> ?[^\s]|^ {0,3}(?:`{3,}|~{3,})|^\*{2}[^*\n]+\*{2}/m.test(t) || /^.+\n=+\s*$/m.test(t) || /^.+\n-{2,}\s*$/m.test(t) || /^---[ \t]*\n(?:[\s\S]*?\n)?(?:---|\.\.\.)[ \t]*(?:\n|$)/.test(t) || /^\|.+\|[ \t]*\n\|[ \t:|-]+\|/m.test(t) || /^[^\n|]*\|[^\n]*\n[ \t]*:?-+:?[ \t]*(?:\|[ \t]*:?-+:?[ \t]*)+$/m.test(t) || /!?\[[^\]\n]*\]\([^)\n]*\)/.test(t) && /`[^`\n]+`|\*\*[^*\n]+\*\*|^#{1,6} |^[-*+] /m.test(t);
2438
2441
  }
2439
- var B = /^ {0,3}>( ?)(.*)$/, zn = /^(?: {4}|\t)\s*\S/, Bn = /^( {0,3})(`{3,}|~{3,})[ \t]*([^\s`~][^\n]*)?$/;
2442
+ var B = /^ {0,3}>( ?)(.*)$/, Bn = /^(?: {4}|\t)\s*\S/, Vn = /^( {0,3})(`{3,}|~{3,})[ \t]*([^\s`~][^\n]*)?$/;
2440
2443
  function V(e) {
2441
- let t = Bn.exec(e);
2444
+ let t = Vn.exec(e);
2442
2445
  if (!t) return null;
2443
2446
  let [, n, r, i = ""] = t;
2444
2447
  return r[0] === "`" && i.includes("`") ? null : {
@@ -2448,7 +2451,7 @@ function V(e) {
2448
2451
  lang: i.trim().split(/\s+/)[0] || ""
2449
2452
  };
2450
2453
  }
2451
- function Vn(e, t) {
2454
+ function Hn(e, t) {
2452
2455
  let n = 0, r = 0;
2453
2456
  for (; r < e.length && n < t;) {
2454
2457
  if (e[r] === " ") {
@@ -2465,40 +2468,40 @@ function Vn(e, t) {
2465
2468
  }
2466
2469
  return e.slice(r);
2467
2470
  }
2468
- var Hn = /^ {0,3}([-*_])( *\1){2,}\s*$/, Un = "";
2471
+ var Un = /^ {0,3}([-*_])( *\1){2,}\s*$/, Wn = "";
2469
2472
  function H(e) {
2470
- let t = Ln(e).replaceAll("\r\n", "\n").replaceAll("\r", "\n").split("\n");
2471
- t = qn(t);
2472
- let n = Jn(t);
2473
- return t = n.clean, Gn = n.linkDefs, Kn = n.footnoteIds, Wn(t);
2473
+ let t = Rn(e).replaceAll("\r\n", "\n").replaceAll("\r", "\n").split("\n");
2474
+ t = Jn(t);
2475
+ let n = Yn(t);
2476
+ return t = n.clean, Kn = n.linkDefs, qn = n.footnoteIds, Gn(t);
2474
2477
  }
2475
- function Wn(e) {
2478
+ function Gn(e) {
2476
2479
  let t = [], n = 0;
2477
2480
  for (; n < e.length;) {
2478
2481
  let r = e[n], i = V(r);
2479
2482
  if (i) {
2480
2483
  let r = RegExp(`^ {0,3}\\${i.marker}{${i.length},}[ \t]*$`), a = [];
2481
- for (n++; n < e.length && !r.test(e[n]);) a.push(mr(Vn(e[n], i.indent))), n++;
2484
+ for (n++; n < e.length && !r.test(e[n]);) a.push(hr(Hn(e[n], i.indent))), n++;
2482
2485
  let o = i.lang ? ` class="language-${q(i.lang)}"` : "";
2483
2486
  t.push(`<pre><code${o}>${a.join("\n")}</code></pre>`), n++;
2484
2487
  continue;
2485
2488
  }
2486
- if (zn.test(r)) {
2489
+ if (Bn.test(r)) {
2487
2490
  let r = [];
2488
- for (; n < e.length && (zn.test(e[n]) || e[n].trim() === "");) {
2491
+ for (; n < e.length && (Bn.test(e[n]) || e[n].trim() === "");) {
2489
2492
  if (e[n].trim() === "") {
2490
2493
  let t = n;
2491
2494
  for (; t < e.length && e[t].trim() === "";) t++;
2492
- if (t >= e.length || !zn.test(e[t])) break;
2495
+ if (t >= e.length || !Bn.test(e[t])) break;
2493
2496
  for (; n < t; n++) r.push("");
2494
2497
  continue;
2495
2498
  }
2496
- r.push(mr(Vn(e[n], 4))), n++;
2499
+ r.push(hr(Hn(e[n], 4))), n++;
2497
2500
  }
2498
2501
  t.push(`<pre><code>${r.join("\n")}</code></pre>`);
2499
2502
  continue;
2500
2503
  }
2501
- if (r.trim() && !Hn.test(r) && !/^#{1,6} /.test(r) && n + 1 < e.length) {
2504
+ if (r.trim() && !Un.test(r) && !/^#{1,6} /.test(r) && n + 1 < e.length) {
2502
2505
  if (/^=+\s*$/.test(e[n + 1])) {
2503
2506
  t.push(`<h1>${K(r.trim())}</h1>`), n += 2;
2504
2507
  continue;
@@ -2508,7 +2511,7 @@ function Wn(e) {
2508
2511
  continue;
2509
2512
  }
2510
2513
  }
2511
- if (Hn.test(r)) {
2514
+ if (Un.test(r)) {
2512
2515
  t.push("<hr>"), n++;
2513
2516
  continue;
2514
2517
  }
@@ -2521,16 +2524,16 @@ function Wn(e) {
2521
2524
  if (B.test(r)) {
2522
2525
  let r = [];
2523
2526
  for (; n < e.length && B.test(e[n]);) r.push(B.exec(e[n])[2]), n++;
2524
- t.push(`<blockquote>${Wn(r)}</blockquote>`);
2527
+ t.push(`<blockquote>${Gn(r)}</blockquote>`);
2525
2528
  continue;
2526
2529
  }
2527
2530
  if (/^[-*+] /.test(r)) {
2528
- let { html: r, endIdx: i } = Qn(e, n);
2531
+ let { html: r, endIdx: i } = $n(e, n);
2529
2532
  t.push(r), n = i;
2530
2533
  continue;
2531
2534
  }
2532
2535
  if (/^\d+[.)] /.test(r)) {
2533
- let { html: r, endIdx: i } = Qn(e, n);
2536
+ let { html: r, endIdx: i } = $n(e, n);
2534
2537
  t.push(r), n = i;
2535
2538
  continue;
2536
2539
  }
@@ -2538,23 +2541,23 @@ function Wn(e) {
2538
2541
  n++;
2539
2542
  continue;
2540
2543
  }
2541
- if (Zn(e, n)) {
2544
+ if (Qn(e, n)) {
2542
2545
  let i = U(r), a = U(e[n + 1]).map((e) => e.startsWith(":") && e.endsWith(":") ? "center" : e.endsWith(":") ? "right" : e.startsWith(":") ? "left" : null);
2543
2546
  n += 2;
2544
2547
  let o = [];
2545
- for (; n < e.length && e[n].trim() !== "" && Xn(e[n]) > 1;) o.push(U(e[n])), n++;
2548
+ for (; n < e.length && e[n].trim() !== "" && Zn(e[n]) > 1;) o.push(U(e[n])), n++;
2546
2549
  let s = (e, t, n) => `<${e}${n ? ` style="text-align:${n}"` : ""}>${K(t)}</${e}>`, c = `<thead><tr>${i.map((e, t) => s("th", e, a[t])).join("")}</tr></thead>`, l = o.length ? `<tbody>${o.map((e) => `<tr>${e.map((e, t) => s("td", e, a[t])).join("")}</tr>`).join("")}</tbody>` : "";
2547
2550
  t.push(`<table>${c}${l}</table>`);
2548
2551
  continue;
2549
2552
  }
2550
2553
  let o = [];
2551
- for (; n < e.length && e[n].trim() !== "" && !/^(#{1,6} |[-*+] |\d+[.)] )/.test(e[n]) && !V(e[n]) && !B.test(e[n]) && !Hn.test(e[n]) && !Zn(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++;
2552
- o.length ? t.push(`<p>${K(Yn(o)).replaceAll(Un, "<br>")}</p>`) : (t.push(`<p>${K(r)}</p>`), n++);
2554
+ for (; n < e.length && e[n].trim() !== "" && !/^(#{1,6} |[-*+] |\d+[.)] )/.test(e[n]) && !V(e[n]) && !B.test(e[n]) && !Un.test(e[n]) && !Qn(e, n) && !(n + 1 < e.length && /^=+\s*$/.test(e[n + 1])) && !(n + 1 < e.length && /^-{2,}\s*$/.test(e[n + 1]));) o.push(e[n]), n++;
2555
+ o.length ? t.push(`<p>${K(Xn(o)).replaceAll(Wn, "<br>")}</p>`) : (t.push(`<p>${K(r)}</p>`), n++);
2553
2556
  }
2554
2557
  return t.join("");
2555
2558
  }
2556
- var Gn = /* @__PURE__ */ new Map(), Kn = /* @__PURE__ */ new Set();
2557
- function qn(e) {
2559
+ var Kn = /* @__PURE__ */ new Map(), qn = /* @__PURE__ */ new Set();
2560
+ function Jn(e) {
2558
2561
  if ((e[0] || "").trim() !== "---") return e;
2559
2562
  let t = -1;
2560
2563
  for (let n = 1; n < e.length; n++) {
@@ -2568,7 +2571,7 @@ function qn(e) {
2568
2571
  let n = t + 1;
2569
2572
  return e[n] !== void 0 && e[n].trim() === "" && n++, e.slice(n);
2570
2573
  }
2571
- function Jn(e) {
2574
+ function Yn(e) {
2572
2575
  let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set(), r = [], i = !1, a = /^\[([^\]]+)\]:\s*(\S+)(?:\s+"([^"]*)")?\s*$/, o = /^\[\^([^\]]+)\]:[ \t]*(\S.*)$/;
2573
2576
  for (let s of e) {
2574
2577
  if (i) {
@@ -2602,31 +2605,31 @@ function Jn(e) {
2602
2605
  footnoteIds: n
2603
2606
  };
2604
2607
  }
2605
- function Yn(e) {
2608
+ function Xn(e) {
2606
2609
  let t = "";
2607
2610
  for (let n = 0; n < e.length; n++) {
2608
2611
  let r = n === e.length - 1, i = e[n].replace(/^[ \t]+/, "");
2609
2612
  if (!r && /\\$/.test(i)) {
2610
- t += i.replace(/\\$/, "") + Un;
2613
+ t += i.replace(/\\$/, "") + Wn;
2611
2614
  continue;
2612
2615
  }
2613
2616
  if (!r && / {2,}$/.test(i)) {
2614
- t += i.replace(/ {2,}$/, "") + Un;
2617
+ t += i.replace(/ {2,}$/, "") + Wn;
2615
2618
  continue;
2616
2619
  }
2617
2620
  t += i + (r ? "" : " ");
2618
2621
  }
2619
2622
  return t;
2620
2623
  }
2621
- function Xn(e) {
2624
+ function Zn(e) {
2622
2625
  return U(e).length;
2623
2626
  }
2624
- function Zn(e, t) {
2627
+ function Qn(e, t) {
2625
2628
  let n = e[t], r = e[t + 1];
2626
2629
  if (r === void 0 || !n.includes("|")) return !1;
2627
2630
  if (/^\|.+\|/.test(n)) return /^\|[\s|:-]+\|/.test(r);
2628
2631
  let i = U(r);
2629
- return i.length < 2 || !i.every((e) => /^:?-+:?$/.test(e)) ? !1 : Xn(n) === i.length;
2632
+ return i.length < 2 || !i.every((e) => /^:?-+:?$/.test(e)) ? !1 : Zn(n) === i.length;
2630
2633
  }
2631
2634
  function U(e) {
2632
2635
  let t = e.replace(/^\|/, "").replace(/\|$/, ""), n = [], r = "";
@@ -2643,7 +2646,7 @@ function U(e) {
2643
2646
  }
2644
2647
  return n.push(r), n.map((e) => e.trim());
2645
2648
  }
2646
- function Qn(e, t) {
2649
+ function $n(e, t) {
2647
2650
  let n = e[t].match(/^(\s*)/)[1].length, r = /^\s*\d+[.)] /.test(e[t]), i = [], a = null, o = !1, s = !1, c = t;
2648
2651
  for (; c < e.length;) {
2649
2652
  let t = e[c];
@@ -2671,15 +2674,15 @@ function Qn(e, t) {
2671
2674
  c++;
2672
2675
  continue;
2673
2676
  }
2674
- let n = (e) => Vn(e, l), r = V(n(t));
2677
+ let n = (e) => Hn(e, l), r = V(n(t));
2675
2678
  if (r) {
2676
2679
  let t = RegExp(`^ {0,3}\\${r.marker}{${r.length},}[ \t]*$`), a = [n(e[c])];
2677
2680
  for (c++; c < e.length && !t.test(n(e[c]));) a.push(n(e[c])), c++;
2678
- c < e.length && (a.push(n(e[c])), c++), i[i.length - 1].sub += Wn(a), s = !1;
2681
+ c < e.length && (a.push(n(e[c])), c++), i[i.length - 1].sub += Gn(a), s = !1;
2679
2682
  continue;
2680
2683
  }
2681
2684
  if (/^\s*(?:[-*+]|\d+[.)]) /.test(t)) {
2682
- let t = Qn(e, c);
2685
+ let t = $n(e, c);
2683
2686
  i[i.length - 1].sub += t.html, c = t.endIdx, s = !1;
2684
2687
  } else if (s) i[i.length - 1].paras.push(t.trim()), s = !1, c++;
2685
2688
  else {
@@ -2697,32 +2700,32 @@ function Qn(e, t) {
2697
2700
  endIdx: c
2698
2701
  };
2699
2702
  }
2700
- var $n = /\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g, W = "\0", G = "", er = /(`+)([^]*?)\1/g;
2701
- function tr(e) {
2703
+ var er = /\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g, W = "\0", G = "", tr = /(`+)([^]*?)\1/g;
2704
+ function nr(e) {
2702
2705
  let t = [];
2703
2706
  return {
2704
- text: e.replace(er, (e, n, r) => r === "" ? e : (t.push(r), `${G}${t.length - 1}${G}`)),
2707
+ text: e.replace(tr, (e, n, r) => r === "" ? e : (t.push(r), `${G}${t.length - 1}${G}`)),
2705
2708
  codes: t
2706
2709
  };
2707
2710
  }
2708
- function nr(e, t, n) {
2711
+ function rr(e, t, n) {
2709
2712
  return e.replace(RegExp(`${G}(\\d+)${G}`, "g"), (e, r) => {
2710
2713
  let i = t[Number(r)];
2711
- return i = i.replace(RegExp(`${W}(\\d+)${W}`, "g"), (e, t) => `\\${n[Number(t)]}`), i.length > 2 && i.startsWith(" ") && i.endsWith(" ") && i.trim() !== "" && (i = i.slice(1, -1)), `<code>${mr(i)}</code>`;
2714
+ return i = i.replace(RegExp(`${W}(\\d+)${W}`, "g"), (e, t) => `\\${n[Number(t)]}`), i.length > 2 && i.startsWith(" ") && i.endsWith(" ") && i.trim() !== "" && (i = i.slice(1, -1)), `<code>${hr(i)}</code>`;
2712
2715
  });
2713
2716
  }
2714
- function rr(e) {
2717
+ function ir(e) {
2715
2718
  let t = [];
2716
2719
  return {
2717
- text: e.replace($n, (e, n) => (t.push(n), `${W}${t.length - 1}${W}`)),
2720
+ text: e.replace(er, (e, n) => (t.push(n), `${W}${t.length - 1}${W}`)),
2718
2721
  literals: t
2719
2722
  };
2720
2723
  }
2721
- function ir(e, t) {
2722
- return e.replace(RegExp(`${W}(\\d+)${W}`, "g"), (e, n) => pr(t[Number(n)]));
2724
+ function ar(e, t) {
2725
+ return e.replace(RegExp(`${W}(\\d+)${W}`, "g"), (e, n) => mr(t[Number(n)]));
2723
2726
  }
2724
- var ar = String.raw`(&lt;.*?&gt;(?:\s+(?:"[^"]*"|'[^']*'))?|[^)]*)`, or = new RegExp(String.raw`!\[([^\]]*)\]\(${ar}\)`, "g"), sr = new RegExp(String.raw`\[([^\]]+)\]\(${ar}\)`, "g");
2725
- function cr(e) {
2727
+ var or = String.raw`(&lt;.*?&gt;(?:\s+(?:"[^"]*"|'[^']*'))?|[^)]*)`, sr = new RegExp(String.raw`!\[([^\]]*)\]\(${or}\)`, "g"), cr = new RegExp(String.raw`\[([^\]]+)\]\(${or}\)`, "g");
2728
+ function lr(e) {
2726
2729
  let t = e.trim(), n = /^&lt;([\s\S]*?)&gt;(?:[ \t]*(?:"([^"]*)"|'([^']*)'))?[ \t]*$/.exec(t);
2727
2730
  if (n) return {
2728
2731
  href: n[1],
@@ -2737,26 +2740,26 @@ function cr(e) {
2737
2740
  title: ""
2738
2741
  };
2739
2742
  }
2740
- function lr(e) {
2741
- return e = e.replace(or, (e, t, n) => {
2742
- let { href: r, title: i } = cr(n), a = i ? ` title="${J(i)}"` : "";
2743
+ function ur(e) {
2744
+ return e = e.replace(sr, (e, t, n) => {
2745
+ let { href: r, title: i } = lr(n), a = i ? ` title="${J(i)}"` : "";
2743
2746
  return `<img src="${J(r)}" alt="${J(t)}"${a} class="an-image">`;
2744
- }), e = e.replace(sr, (e, t, n) => {
2745
- let { href: r, title: i } = cr(n), a = i ? ` title="${J(i)}"` : "";
2747
+ }), e = e.replace(cr, (e, t, n) => {
2748
+ let { href: r, title: i } = lr(n), a = i ? ` title="${J(i)}"` : "";
2746
2749
  return `<a href="${J(r)}"${a}>${t}</a>`;
2747
2750
  }), e = e.replace(/\[([^\]]+)\]\[([^\]]*)\]/g, (e, t, n) => {
2748
- let r = Gn.get(hr(n || t).trim().toLowerCase());
2751
+ let r = Kn.get(gr(n || t).trim().toLowerCase());
2749
2752
  if (!r) return e;
2750
2753
  let i = r.title ? ` title="${q(r.title)}"` : "";
2751
2754
  return `<a href="${q(r.href)}"${i}>${t}</a>`;
2752
2755
  }), e = e.replace(/\[([^\]]+)\]/g, (e, t) => {
2753
- let n = Gn.get(hr(t).trim().toLowerCase());
2756
+ let n = Kn.get(gr(t).trim().toLowerCase());
2754
2757
  if (!n) return e;
2755
2758
  let r = n.title ? ` title="${q(n.title)}"` : "";
2756
2759
  return `<a href="${q(n.href)}"${r}>${t}</a>`;
2757
- }), e = e.replace(/\[\^([^\]]+)\]/g, (e, t) => Kn.has(hr(t)) ? `<sup>[${t}]</sup>` : e), e;
2760
+ }), e = e.replace(/\[\^([^\]]+)\]/g, (e, t) => qn.has(gr(t)) ? `<sup>[${t}]</sup>` : e), e;
2758
2761
  }
2759
- function ur(e) {
2762
+ function dr(e) {
2760
2763
  return e = e.replace(/&lt;(https?:\/\/[^\s&]+?)&gt;/g, (e, t) => `<a href="${J(t)}">${t}</a>`), e = e.replace(/&lt;([\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])?)+)&gt;/g, (e, t) => `<a href="mailto:${J(t)}">${t}</a>`), e = e.replace(/(^|[\s(])(https?:\/\/[^\s()]+)/g, (e, t, n) => {
2761
2764
  let r = /[.,;:!?)]+$/.exec(n), i = r ? n.slice(0, -r[0].length) : n;
2762
2765
  if (!i) return e;
@@ -2764,18 +2767,18 @@ function ur(e) {
2764
2767
  return `${t}<a href="${J(i)}">${i}</a>${a}`;
2765
2768
  }), e;
2766
2769
  }
2767
- function dr(e) {
2770
+ function fr(e) {
2768
2771
  return e = e.replace(/\*{3}([^*\n]+?)\*{3}/g, (e, t) => `<strong><em>${t}</em></strong>`), e = e.replace(/(?<!\w)_{3}([^_\n]+?)_{3}(?!\w)/g, (e, t) => `<strong><em>${t}</em></strong>`), e = e.replace(/\*{2}([^*\n]+?)\*{2}/g, (e, t) => `<strong>${t}</strong>`), e = e.replace(/(?<!\w)_{2}([^_\n]+?)_{2}(?!\w)/g, (e, t) => `<strong>${t}</strong>`), e = e.replace(/\*([^*\n]+?)\*/g, (e, t) => `<em>${t}</em>`), e = e.replace(/(?<!\w)_([^_\n]+?)_(?!\w)/g, (e, t) => `<em>${t}</em>`), e = e.replace(/~~([^~\n]+?)~~/g, (e, t) => `<del>${t}</del>`), e;
2769
2772
  }
2770
2773
  function K(e) {
2771
- let { text: t, literals: n } = rr(e), { text: r, codes: i } = tr(t), a = pr(r);
2772
- return a = lr(a), a = ur(a), a = dr(a), nr(ir(a, n), i, n);
2773
- }
2774
- var fr = /&(?!#\d+;|#[xX][0-9a-fA-F]+;|[a-zA-Z][a-zA-Z0-9]*;)/g;
2775
- function pr(e) {
2776
- return String(e).replace(fr, "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
2774
+ let { text: t, literals: n } = ir(e), { text: r, codes: i } = nr(t), a = mr(r);
2775
+ return a = ur(a), a = dr(a), a = fr(a), rr(ar(a, n), i, n);
2777
2776
  }
2777
+ var pr = /&(?!#\d+;|#[xX][0-9a-fA-F]+;|[a-zA-Z][a-zA-Z0-9]*;)/g;
2778
2778
  function mr(e) {
2779
+ return String(e).replace(pr, "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
2780
+ }
2781
+ function hr(e) {
2779
2782
  return String(e).replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
2780
2783
  }
2781
2784
  function q(e) {
@@ -2784,16 +2787,16 @@ function q(e) {
2784
2787
  function J(e) {
2785
2788
  return String(e).replaceAll("\"", "&quot;").replaceAll("'", "&#39;");
2786
2789
  }
2787
- function hr(e) {
2790
+ function gr(e) {
2788
2791
  return String(e).replaceAll("&lt;", "<").replaceAll("&gt;", ">").replaceAll("&amp;", "&");
2789
2792
  }
2790
2793
  //#endregion
2791
2794
  //#region src/js/core/detectLang.js
2792
- var gr = 5, _r = 2, vr = [
2795
+ var _r = 5, vr = 2, yr = [
2793
2796
  ["typescript", "javascript"],
2794
2797
  ["scss", "css"],
2795
2798
  ["cpp", "c"]
2796
- ], yr = [
2799
+ ], br = [
2797
2800
  "javascript",
2798
2801
  "typescript",
2799
2802
  "python",
@@ -2816,7 +2819,7 @@ var gr = 5, _r = 2, vr = [
2816
2819
  "scss",
2817
2820
  "css",
2818
2821
  "bash"
2819
- ], br = [
2822
+ ], xr = [
2820
2823
  {
2821
2824
  lang: "php",
2822
2825
  w: 10,
@@ -3382,33 +3385,41 @@ var gr = 5, _r = 2, vr = [
3382
3385
  w: 3,
3383
3386
  re: /\s\|[ \t]*\w|\s&&\s|\s2>&1|\s-[\w-]+\s/
3384
3387
  }
3385
- ], xr = 4e3;
3386
- function Sr(e) {
3387
- if (e.length <= xr) return e;
3388
- let t = e.slice(0, xr), n = t.lastIndexOf("\n");
3388
+ ], Sr = 4e3;
3389
+ function Cr(e) {
3390
+ if (e.length <= Sr) return e;
3391
+ let t = e.slice(0, Sr), n = t.lastIndexOf("\n");
3389
3392
  return n > 0 ? t.slice(0, n) : t;
3390
3393
  }
3391
- function Cr(e) {
3394
+ function wr(e) {
3392
3395
  if (!e?.trim()) return null;
3393
- let t = Sr(e.trim()), n = /* @__PURE__ */ new Map();
3394
- for (let { lang: e, re: r, w: i } of br) r.test(t) && n.set(e, (n.get(e) || 0) + i);
3396
+ let t = Cr(e.trim()), n = /* @__PURE__ */ new Map();
3397
+ for (let { lang: e, re: r, w: i } of xr) r.test(t) && n.set(e, (n.get(e) || 0) + i);
3395
3398
  if (n.size === 0) return null;
3396
- for (let [e, t] of vr) {
3399
+ for (let [e, t] of yr) {
3397
3400
  let r = n.get(e);
3398
3401
  r && n.set(e, r + (n.get(t) || 0));
3399
3402
  }
3400
3403
  let r = [...n.entries()].sort((e, t) => t[1] - e[1]), [i, a] = r[0], o = r[1]?.[1] ?? 0;
3401
- return a < gr || a - o < _r ? null : i;
3404
+ return a < _r || a - o < vr ? null : i;
3402
3405
  }
3403
3406
  //#endregion
3404
3407
  //#region src/js/module/Editor.js
3405
- var wr = class {
3408
+ var Tr = /* @__PURE__ */ new Set([
3409
+ "PRE",
3410
+ "BLOCKQUOTE",
3411
+ "TABLE",
3412
+ "FIGURE",
3413
+ "UL",
3414
+ "OL",
3415
+ "HR"
3416
+ ]), Er = class {
3406
3417
  constructor(e) {
3407
3418
  this.context = e, this.options = e.options, this._history = null, this._disposers = [], this._snapshotTimer = null;
3408
3419
  }
3409
3420
  initialize() {
3410
3421
  let e = this.context.layoutInfo.editable;
3411
- return this._history = new Cn(e, this.options.historyLimit || 100, this.options.historyMaxBytes || 10 * 1024 * 1024), this._bindEvents(e), this;
3422
+ return this._history = new wn(e, this.options.historyLimit || 100, this.options.historyMaxBytes || 10 * 1024 * 1024), this._bindEvents(e), this;
3412
3423
  }
3413
3424
  destroy() {
3414
3425
  this._disposers.forEach((e) => e()), this._disposers = [], this._history = null, clearTimeout(this._snapshotTimer), this._snapshotTimer = null;
@@ -3450,18 +3461,18 @@ var wr = class {
3450
3461
  }
3451
3462
  l ? c.setStart(l, 0) : c.setStartAfter(s), c.collapse(!0), n.removeAllRanges(), n.addRange(c);
3452
3463
  }, s = () => this.context.layoutInfo.container.classList.contains("an-disabled");
3453
- this._disposers.push(S(e, "keydown", t), S(e, "beforeinput", r), S(e, "input", n), S(document, "selectionchange", i), S(e, "click", a), S(e, "mouseup", o), S(e, "keyup", o), S(e, "dragstart", (e) => {
3464
+ this._disposers.push(C(e, "keydown", t), C(e, "beforeinput", r), C(e, "input", n), C(document, "selectionchange", i), C(e, "click", a), C(e, "mouseup", o), C(e, "keyup", o), C(e, "dragstart", (e) => {
3454
3465
  if (s()) {
3455
3466
  e.preventDefault();
3456
3467
  return;
3457
3468
  }
3458
3469
  let t = e.target;
3459
3470
  t && (t.nodeName === "IFRAME" || t.closest(".an-video-wrapper")) && e.preventDefault();
3460
- }), S(e, "drop", (e) => {
3471
+ }), C(e, "drop", (e) => {
3461
3472
  s() && e.preventDefault();
3462
3473
  }));
3463
3474
  let c = null;
3464
- this._disposers.push(S(e, "compositionstart", () => {
3475
+ this._disposers.push(C(e, "compositionstart", () => {
3465
3476
  let e = globalThis.getSelection();
3466
3477
  if (!e?.rangeCount) {
3467
3478
  c = null;
@@ -3472,7 +3483,7 @@ var wr = class {
3472
3483
  let e = t;
3473
3484
  c = e.closest("sup") ? "superscript" : e.closest("sub") ? "subscript" : null;
3474
3485
  }
3475
- }), S(e, "compositionend", () => {
3486
+ }), C(e, "compositionend", () => {
3476
3487
  let e = c;
3477
3488
  if (c = null, !e) return;
3478
3489
  let t = globalThis.getSelection();
@@ -3485,7 +3496,7 @@ var wr = class {
3485
3496
  }
3486
3497
  _onKeydown(e) {
3487
3498
  let t = this.context.layoutInfo.editable;
3488
- if (!On(e, t, this.options)) {
3499
+ if (!kn(e, t, this.options)) {
3489
3500
  if (I(e, "z") && !e.shiftKey) {
3490
3501
  e.preventDefault(), this.undo();
3491
3502
  return;
@@ -3554,15 +3565,7 @@ var wr = class {
3554
3565
  let e = this.context.layoutInfo.editable;
3555
3566
  if (!e) return;
3556
3567
  let t = e.lastElementChild;
3557
- if (t && (/* @__PURE__ */ new Set([
3558
- "PRE",
3559
- "BLOCKQUOTE",
3560
- "TABLE",
3561
- "FIGURE",
3562
- "UL",
3563
- "OL",
3564
- "HR"
3565
- ])).has(t.nodeName)) {
3568
+ if (t && Tr.has(t.nodeName)) {
3566
3569
  let t = document.createElement("p");
3567
3570
  t.innerHTML = "<br>", e.appendChild(t);
3568
3571
  }
@@ -3575,7 +3578,8 @@ var wr = class {
3575
3578
  return this.context.invoke("clipboard.resolveImages", e) ?? e;
3576
3579
  }
3577
3580
  setHTML(e) {
3578
- this.context.layoutInfo.editable.innerHTML = j(e, { allowIframes: !0 }), this._history && this._history.reset(), this.afterCommand();
3581
+ let t = mn(e, { allowIframes: !0 });
3582
+ this.context.layoutInfo.editable.replaceChildren(...t.childNodes), this._history && this._history.reset(), this.afterCommand();
3579
3583
  }
3580
3584
  getText() {
3581
3585
  return this.context.layoutInfo.editable.innerText || "";
@@ -3603,7 +3607,7 @@ var wr = class {
3603
3607
  this.setHTML(H(e || ""));
3604
3608
  }
3605
3609
  getMarkdown() {
3606
- return kn(this.getHTML());
3610
+ return An(this.getHTML());
3607
3611
  }
3608
3612
  undo() {
3609
3613
  this._history && (this._flushPendingSnapshot(), this._history.undo(), this.context.invoke("toolbar.refresh"), this.context.invoke("statusbar.update"), this.context.triggerEvent("change", this.getHTML()));
@@ -3689,7 +3693,7 @@ var wr = class {
3689
3693
  if (e?.rangeCount > 0) {
3690
3694
  let t = e.getRangeAt(0).commonAncestorContainer, n = t.nodeType === 1 ? t.closest("pre") : t.parentElement?.closest("pre");
3691
3695
  if (n && !n.dataset.language) {
3692
- let e = Cr(n.textContent || "");
3696
+ let e = wr(n.textContent || "");
3693
3697
  if (e) {
3694
3698
  this.context.invoke("codeTooltip.applyLanguage", n, e);
3695
3699
  return;
@@ -3748,7 +3752,7 @@ var wr = class {
3748
3752
  e && (w("insertHTML", e), this.afterCommand());
3749
3753
  }
3750
3754
  insertTable(e, t) {
3751
- Tn(e, t, { headerRow: this.context.options.tableHeaderRow }), this.afterCommand();
3755
+ En(e, t, { headerRow: this.context.options.tableHeaderRow }), this.afterCommand();
3752
3756
  }
3753
3757
  _getClosestAnchor() {
3754
3758
  let e = globalThis.getSelection();
@@ -3763,7 +3767,7 @@ var wr = class {
3763
3767
  _escapeAttr(e) {
3764
3768
  return String(e ?? "").replaceAll("&", "&amp;").replaceAll("\"", "&quot;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
3765
3769
  }
3766
- }, Tr = (e) => typeof e == "string" ? ut(e) : e, Y = null, Er = "stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"", X = (e) => `<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24" fill="none" ${Er} style="display:block">${e}</svg>`, Z = /* @__PURE__ */ new Map([
3770
+ }, Dr = (e) => typeof e == "string" ? ut(e) : e, Y = null, Or = "stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"", X = (e) => `<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24" fill="none" ${Or} style="display:block">${e}</svg>`, Z = /* @__PURE__ */ new Map([
3767
3771
  ["bold", X("<path d=\"M6 4h8a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z\"/><path d=\"M6 12h9a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z\"/>")],
3768
3772
  ["italic", X("<line x1=\"19\" y1=\"4\" x2=\"10\" y2=\"4\"/><line x1=\"14\" y1=\"20\" x2=\"5\" y2=\"20\"/><line x1=\"15\" y1=\"4\" x2=\"9\" y2=\"20\"/>")],
3769
3773
  ["underline", X("<path d=\"M6 3v7a6 6 0 0 0 6 6 6 6 0 0 0 6-6V3\"/><line x1=\"4\" y1=\"21\" x2=\"20\" y2=\"21\"/>")],
@@ -3800,7 +3804,7 @@ var wr = class {
3800
3804
  ["inline-code", X("<path d=\"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1\"/><path d=\"M16 3h1a2 2 0 0 1 2 2v5c0 1.1.9 2 2 2a2 2 0 0 1-2 2v5a2 2 0 0 1-2 2h-1\"/>")],
3801
3805
  ["checklist", X("<rect x=\"3\" y=\"4\" width=\"5\" height=\"5\" rx=\"1\"/><path d=\"m4 6.5 1 1 2-2\"/><rect x=\"3\" y=\"13\" width=\"5\" height=\"5\" rx=\"1\"/><line x1=\"10\" y1=\"6.5\" x2=\"21\" y2=\"6.5\"/><line x1=\"10\" y1=\"15.5\" x2=\"21\" y2=\"15.5\"/>")],
3802
3806
  ["print", X("<path d=\"M6 9V2h12v7\"/><path d=\"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2\"/><rect x=\"6\" y=\"14\" width=\"12\" height=\"8\"/>")]
3803
- ]), Dr = /* @__PURE__ */ new Map([
3807
+ ]), kr = /* @__PURE__ */ new Map([
3804
3808
  ["bold", "fa-bold"],
3805
3809
  ["italic", "fa-italic"],
3806
3810
  ["underline", "fa-underline"],
@@ -3834,17 +3838,17 @@ var wr = class {
3834
3838
  ["inline-code", "fa-code"],
3835
3839
  ["checklist", "fa-list-check"],
3836
3840
  ["print", "fa-print"]
3837
- ]), Or = class {
3841
+ ]), Ar = class {
3838
3842
  constructor(e) {
3839
3843
  this.context = e, this.options = e.options, this.el = null, this._disposers = [], this._colorPickerClosers = [], this._refreshRaf = null;
3840
3844
  }
3841
3845
  initialize() {
3842
- return this.el = b("div", {
3846
+ return this.el = x("div", {
3843
3847
  class: "an-toolbar",
3844
3848
  role: "toolbar",
3845
3849
  "aria-orientation": "horizontal",
3846
3850
  "aria-label": "Editor toolbar"
3847
- }), this._faReady = this._detectFontAwesome(), this._buildButtons(), this._initRovingFocus(), this._btnMap = new Map((this.options.toolbar || []).flat().map(Tr).filter(Boolean).map((e) => [e.name, e])), this;
3851
+ }), this._faReady = this._detectFontAwesome(), this._buildButtons(), this._initRovingFocus(), this._btnMap = new Map((this.options.toolbar || []).flat().map(Dr).filter(Boolean).map((e) => [e.name, e])), this;
3848
3852
  }
3849
3853
  destroy() {
3850
3854
  this._refreshRaf && cancelAnimationFrame(this._refreshRaf), this._refreshRaf = null, this._disposers.forEach((e) => e()), this._disposers = [], this.el?.parentNode && this.el.remove(), this.el = null;
@@ -3852,9 +3856,9 @@ var wr = class {
3852
3856
  _buildButtons() {
3853
3857
  let e = this.options.toolbar || [], t = document.createDocumentFragment();
3854
3858
  e.forEach((e) => {
3855
- let n = b("div", { class: "an-btn-group" });
3859
+ let n = x("div", { class: "an-btn-group" });
3856
3860
  e.forEach((e) => {
3857
- let t = Tr(e);
3861
+ let t = Dr(e);
3858
3862
  if (!t) {
3859
3863
  console.warn(`[AutumnNote] Toolbar: button "${e}" not found in registry. Skipped.`);
3860
3864
  return;
@@ -3865,7 +3869,7 @@ var wr = class {
3865
3869
  }), this.el.appendChild(t);
3866
3870
  }
3867
3871
  _createGridPicker(e) {
3868
- let t = b("div", { class: "an-table-picker-wrap" }), n = b("button", {
3872
+ let t = x("div", { class: "an-table-picker-wrap" }), n = x("button", {
3869
3873
  type: "button",
3870
3874
  class: this.options.useBootstrap ? this.options.toolbarButtonClass || "btn btn-sm btn-light" : "an-btn",
3871
3875
  title: this.context.locale.toolbar[e.name] || e.tooltip || "",
@@ -3875,15 +3879,15 @@ var wr = class {
3875
3879
  "aria-expanded": "false"
3876
3880
  });
3877
3881
  this._faReady ? n.innerHTML = `<i class="${this.options.fontAwesomeClass || "fas"} fa-table" aria-hidden="true"></i>` : n.innerHTML = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"15\" height=\"15\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" style=\"display:block\"><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\"/></svg>";
3878
- let r = b("div", {
3882
+ let r = x("div", {
3879
3883
  class: "an-table-picker-popup",
3880
3884
  role: "dialog",
3881
3885
  "aria-label": "Select table size"
3882
- }), i = b("div", { class: "an-table-grid" }), a = b("div", { class: "an-table-label" });
3886
+ }), i = x("div", { class: "an-table-grid" }), a = x("div", { class: "an-table-label" });
3883
3887
  a.textContent = this.context.locale.toolbar.insertTableLabel || "Insert Table";
3884
3888
  let o = [];
3885
3889
  for (let e = 1; e <= 10; e++) for (let t = 1; t <= 10; t++) {
3886
- let n = b("div", {
3890
+ let n = x("div", {
3887
3891
  class: "an-table-cell",
3888
3892
  "data-row": String(e),
3889
3893
  "data-col": String(t)
@@ -3904,17 +3908,17 @@ var wr = class {
3904
3908
  a + t > globalThis.innerWidth - 8 && (a = Math.max(8, globalThis.innerWidth - t - 8)), o + i > globalThis.innerHeight - 8 && (o = e.top - i - 4), r.style.left = `${a}px`, r.style.top = `${o}px`, r.style.visibility = "", n.setAttribute("aria-expanded", "true");
3905
3909
  }, u = () => {
3906
3910
  s = !1, r.style.display = "none", n.setAttribute("aria-expanded", "false"), c(0, 0);
3907
- }, d = S(n, "click", (e) => {
3911
+ }, d = C(n, "click", (e) => {
3908
3912
  e.stopPropagation(), s ? u() : l();
3909
- }), f = S(i, "mouseover", (e) => {
3913
+ }), f = C(i, "mouseover", (e) => {
3910
3914
  let t = e.target?.closest(".an-table-cell");
3911
3915
  t && c(+t.dataset.row, +t.dataset.col);
3912
- }), p = S(i, "mouseleave", () => c(0, 0)), m = S(i, "click", (t) => {
3916
+ }), p = C(i, "mouseleave", () => c(0, 0)), m = C(i, "click", (t) => {
3913
3917
  let n = t.target?.closest(".an-table-cell");
3914
3918
  if (!n) return;
3915
3919
  let r = +n.dataset.row, i = +n.dataset.col;
3916
3920
  u(), this.context.invoke("editor.focus"), e.action(this.context, r, i);
3917
- }), h = S(document, "click", () => {
3921
+ }), h = C(document, "click", () => {
3918
3922
  s && u();
3919
3923
  });
3920
3924
  return this._disposers.push(d, f, p, m, h, () => {
@@ -3947,7 +3951,7 @@ var wr = class {
3947
3951
  "#c9daf8",
3948
3952
  "#d9d2e9",
3949
3953
  "#ead1dc"
3950
- ], n = e.defaultColor || "#000000", r = b("div", { class: "an-color-picker-wrap" }), i = this.options.useBootstrap ? this.options.toolbarButtonClass || "btn btn-sm btn-light" : "an-btn", a = b("button", {
3954
+ ], n = e.defaultColor || "#000000", r = x("div", { class: "an-color-picker-wrap" }), i = this.options.useBootstrap ? this.options.toolbarButtonClass || "btn btn-sm btn-light" : "an-btn", a = x("button", {
3951
3955
  type: "button",
3952
3956
  class: `${i} an-color-btn`,
3953
3957
  title: this.context.locale.toolbar[e.name] || e.tooltip || "",
@@ -3955,9 +3959,9 @@ var wr = class {
3955
3959
  "aria-label": this.context.locale.toolbar[e.name] || e.tooltip || e.name
3956
3960
  }), o = "stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"";
3957
3961
  a.innerHTML = e.name === "foreColor" ? `<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24" fill="none" ${o} style="display:block"><path d="M4 20L12 4L20 20"/><line x1="7.5" y1="14" x2="16.5" y2="14"/></svg>` : `<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24" fill="none" ${o} style="display:block"><path d="M3 21v-4l9-9 4 4-9 9z"/><path d="M12 8l4 4"/></svg>`;
3958
- let s = b("span", { class: "an-color-strip" });
3962
+ let s = x("span", { class: "an-color-strip" });
3959
3963
  s.style.background = n, a.appendChild(s);
3960
- let c = b("button", {
3964
+ let c = x("button", {
3961
3965
  type: "button",
3962
3966
  class: `${i} an-color-arrow`,
3963
3967
  title: e.name === "foreColor" ? this.context.locale.toolbar.chooseTextColor || "Choose text color" : this.context.locale.toolbar.chooseHighlightColor || "Choose highlight color",
@@ -3965,22 +3969,22 @@ var wr = class {
3965
3969
  "aria-expanded": "false"
3966
3970
  });
3967
3971
  c.innerHTML = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"8\" height=\"8\" viewBox=\"0 0 24 24\" fill=\"currentColor\" stroke=\"none\" style=\"display:block\"><path d=\"M7 10l5 5 5-5H7z\"/></svg>";
3968
- let l = b("div", { class: "an-color-popup" });
3972
+ let l = x("div", { class: "an-color-popup" });
3969
3973
  l.style.display = "none";
3970
- let u = b("div", { class: "an-color-swatches" }), d = Array.isArray(this.options.colorSwatches) ? this.options.colorSwatches : [];
3974
+ let u = x("div", { class: "an-color-swatches" }), d = Array.isArray(this.options.colorSwatches) ? this.options.colorSwatches : [];
3971
3975
  [.../* @__PURE__ */ new Set([...d, ...t])].forEach((e) => {
3972
- let t = b("div", {
3976
+ let t = x("div", {
3973
3977
  class: "an-color-swatch",
3974
3978
  title: e,
3975
3979
  "data-color": e
3976
3980
  });
3977
3981
  t.style.background = e, u.appendChild(t);
3978
3982
  });
3979
- let f = b("div", { class: "an-color-custom" }), p = b("input", {
3983
+ let f = x("div", { class: "an-color-custom" }), p = x("input", {
3980
3984
  type: "color",
3981
3985
  value: n,
3982
3986
  title: this.context.locale.toolbar.customColor || "Custom color"
3983
- }), m = b("span", {}, [this.context.locale.toolbar.customColor || "Custom color"]);
3987
+ }), m = x("span", {}, [this.context.locale.toolbar.customColor || "Custom color"]);
3984
3988
  f.appendChild(p), f.appendChild(m), l.appendChild(u), l.appendChild(f);
3985
3989
  let h = !1, g = null, ee = () => {
3986
3990
  let e = globalThis.getSelection();
@@ -4001,28 +4005,28 @@ var wr = class {
4001
4005
  h = !1, l.style.display = "none", l.style.top = "", l.style.left = "", c.setAttribute("aria-expanded", "false");
4002
4006
  }, v = (t) => {
4003
4007
  n = t, s.style.background = t, p.value = t, te(), e.action(this.context, t), this.context.invoke("editor.afterCommand"), _();
4004
- }, re = S(a, "click", (t) => {
4008
+ }, re = C(a, "click", (t) => {
4005
4009
  t.preventDefault(), te(), e.action(this.context, n), this.context.invoke("editor.afterCommand");
4006
- }), ie = S(c, "mousedown", (e) => {
4010
+ }), ie = C(c, "mousedown", (e) => {
4007
4011
  e.preventDefault();
4008
- }), y = S(c, "click", (e) => {
4012
+ }), y = C(c, "click", (e) => {
4009
4013
  e.stopPropagation(), h ? _() : ne();
4010
- }), ae = S(u, "mousedown", (e) => {
4014
+ }), b = C(u, "mousedown", (e) => {
4011
4015
  e.preventDefault();
4012
- }), oe = S(u, "click", (e) => {
4016
+ }), ae = C(u, "click", (e) => {
4013
4017
  let t = e.target?.closest(".an-color-swatch");
4014
4018
  t && v(t.dataset.color);
4015
- }), se = S(p, "change", (e) => {
4019
+ }), oe = C(p, "change", (e) => {
4016
4020
  v(e.target.value);
4017
- }), ce = S(document, "click", (e) => {
4021
+ }), se = C(document, "click", (e) => {
4018
4022
  h && !r.contains(e.target) && !l.contains(e.target) && _();
4019
- }), le = S(l, "click", (e) => e.stopPropagation()), x = () => {
4023
+ }), ce = C(l, "click", (e) => e.stopPropagation()), S = () => {
4020
4024
  h && _();
4021
4025
  };
4022
- return document.addEventListener("scroll", x, {
4026
+ return document.addEventListener("scroll", S, {
4023
4027
  passive: !0,
4024
4028
  capture: !0
4025
- }), globalThis.addEventListener("resize", x, { passive: !0 }), this._disposers.push(re, ie, y, ae, oe, se, ce, le, () => document.removeEventListener("scroll", x, { capture: !0 }), () => globalThis.removeEventListener("resize", x), () => {
4029
+ }), globalThis.addEventListener("resize", S, { passive: !0 }), this._disposers.push(re, ie, y, b, ae, oe, se, ce, () => document.removeEventListener("scroll", S, { capture: !0 }), () => globalThis.removeEventListener("resize", S), () => {
4026
4030
  l.parentNode && l.remove();
4027
4031
  }), this._colorPickerClosers.push(_), this._disposers.push(() => {
4028
4032
  let e = this._colorPickerClosers.indexOf(_);
@@ -4030,12 +4034,12 @@ var wr = class {
4030
4034
  }), r.appendChild(a), r.appendChild(c), document.body.appendChild(l), r;
4031
4035
  }
4032
4036
  _createSelect(e) {
4033
- let t = e.name === "fontFamily" ? this.options.fontFamilies || [] : e.items || [], n = b("select", {
4037
+ let t = e.name === "fontFamily" ? this.options.fontFamilies || [] : e.items || [], n = x("select", {
4034
4038
  class: e.selectClass ? `an-select ${e.selectClass}` : "an-select",
4035
4039
  title: this.context.locale.toolbar[e.name] || e.tooltip || "",
4036
4040
  "data-btn": e.name,
4037
4041
  "aria-label": this.context.locale.toolbar[e.name] || e.tooltip || e.name
4038
- }), r = b("option", {
4042
+ }), r = x("option", {
4039
4043
  value: "",
4040
4044
  disabled: "",
4041
4045
  hidden: ""
@@ -4045,13 +4049,13 @@ var wr = class {
4045
4049
  i = typeof t == "object" ? e.name === "paragraphStyle" && this.context.locale.toolbar.paragraphItems?.[t.value] || t.label : t;
4046
4050
  let a = typeof t == "object" && !!t.disabled, o = { value: r };
4047
4051
  a && (o.disabled = "");
4048
- let s = b("option", o, [i]);
4052
+ let s = x("option", o, [i]);
4049
4053
  e.name === "fontFamily" && !a && (s.style.fontFamily = r), n.appendChild(s);
4050
4054
  });
4051
- let i = null, a = S(n, "mousedown", () => {
4055
+ let i = null, a = C(n, "mousedown", () => {
4052
4056
  let e = globalThis.getSelection();
4053
4057
  i = e?.rangeCount ? e.getRangeAt(0).cloneRange() : null;
4054
- }), o = S(n, "change", (t) => {
4058
+ }), o = C(n, "change", (t) => {
4055
4059
  let n = t.target.value, r = t.target.options[t.target.selectedIndex];
4056
4060
  if (!(!n || r.disabled)) {
4057
4061
  if (this.context.invoke("editor.focus"), i) try {
@@ -4064,7 +4068,7 @@ var wr = class {
4064
4068
  return this._disposers.push(a, o), n;
4065
4069
  }
4066
4070
  _createButton(e) {
4067
- let t = b("button", {
4071
+ let t = x("button", {
4068
4072
  type: "button",
4069
4073
  class: `${this.options.useBootstrap ? this.options.toolbarButtonClass || "btn btn-sm btn-light" : "an-btn"}${e.className ? ` ${e.className}` : ""}`,
4070
4074
  title: this.context.locale.toolbar[e.name] || e.tooltip || "",
@@ -4073,10 +4077,10 @@ var wr = class {
4073
4077
  ...typeof e.isActive == "function" ? { "aria-pressed": "false" } : {}
4074
4078
  }), n = this.options.fontAwesomeClass || "fas";
4075
4079
  if (this._faReady) {
4076
- let r = Dr.get(e.icon) || Dr.get(e.name) || null;
4080
+ let r = kr.get(e.icon) || kr.get(e.name) || null;
4077
4081
  r ? t.innerHTML = `<i class="${n} ${r}" aria-hidden="true"></i>` : Z.has(e.icon) ? t.innerHTML = Z.get(e.icon) : t.textContent = e.icon || e.name;
4078
4082
  } else Z.has(e.icon) ? t.innerHTML = Z.get(e.icon) : Z.has(e.name) ? t.innerHTML = Z.get(e.name) : t.textContent = e.icon || e.name;
4079
- let r = S(t, "click", (t) => {
4083
+ let r = C(t, "click", (t) => {
4080
4084
  t.preventDefault(), this.context.invoke("editor.focus"), e.action(this.context), this.context.invoke("editor.afterCommand"), this.refresh();
4081
4085
  });
4082
4086
  return this._disposers.push(r), t;
@@ -4094,7 +4098,7 @@ var wr = class {
4094
4098
  t.forEach((e) => e.setAttribute("tabindex", e === r ? "0" : "-1"));
4095
4099
  }
4096
4100
  _initRovingFocus() {
4097
- this.el && (this._syncRovingTabindex(), this._disposers.push(S(this.el, "keydown", (e) => this._onToolbarKeydown(e)), S(this.el, "focusin", (e) => {
4101
+ this.el && (this._syncRovingTabindex(), this._disposers.push(C(this.el, "keydown", (e) => this._onToolbarKeydown(e)), C(this.el, "focusin", (e) => {
4098
4102
  let t = e.target?.closest?.("button, select");
4099
4103
  t && this._syncRovingTabindex(t);
4100
4104
  })));
@@ -4155,449 +4159,519 @@ var wr = class {
4155
4159
  this.el && (this.el.style.display = "none");
4156
4160
  }
4157
4161
  rebuild() {
4158
- this._refreshRaf &&= (cancelAnimationFrame(this._refreshRaf), null), this._disposers.forEach((e) => e()), this._disposers = [], this.el && (this.el.innerHTML = ""), this._faReady = this._detectFontAwesome(), this._buildButtons(), this._initRovingFocus(), this._btnMap = new Map((this.options.toolbar || []).flat().map(Tr).filter(Boolean).map((e) => [e.name, e])), this.refresh();
4162
+ this._refreshRaf &&= (cancelAnimationFrame(this._refreshRaf), null), this._disposers.forEach((e) => e()), this._disposers = [], this.el && (this.el.innerHTML = ""), this._faReady = this._detectFontAwesome(), this._buildButtons(), this._initRovingFocus(), this._btnMap = new Map((this.options.toolbar || []).flat().map(Dr).filter(Boolean).map((e) => [e.name, e])), this.refresh();
4159
4163
  }
4160
- }, kr = typeof Intl < "u" && typeof Intl.Segmenter == "function" ? new Intl.Segmenter(void 0, { granularity: "word" }) : null;
4161
- function Ar(e) {
4164
+ }, jr = typeof Intl < "u" && typeof Intl.Segmenter == "function" ? new Intl.Segmenter(void 0, { granularity: "word" }) : null;
4165
+ function Mr(e) {
4162
4166
  let t = e.trim();
4163
4167
  if (!t) return 0;
4164
- if (kr) {
4168
+ if (jr) {
4165
4169
  let e = 0;
4166
- for (let n of kr.segment(t)) n.isWordLike && e++;
4170
+ for (let n of jr.segment(t)) n.isWordLike && e++;
4167
4171
  return e;
4168
4172
  }
4169
4173
  return t.split(/\s+/).length;
4170
4174
  }
4171
- function jr(e, t, n) {
4175
+ var Nr = /* @__PURE__ */ new Set(/* @__PURE__ */ "ADDRESS.ARTICLE.ASIDE.BLOCKQUOTE.BR.DD.DIV.DL.DT.FIELDSET.FIGCAPTION.FIGURE.FOOTER.FORM.H1.H2.H3.H4.H5.H6.HEADER.HR.LI.MAIN.NAV.OL.P.PRE.SECTION.TABLE.TBODY.TD.TFOOT.TH.THEAD.TR.UL".split("."));
4176
+ function Pr(e, t, n) {
4177
+ for (let r = e.firstChild; r; r = r.nextSibling) if (r.nodeType === 3) {
4178
+ let e = r.data;
4179
+ t.push(e), n.push(e);
4180
+ } else if (r.nodeType === 1) {
4181
+ let e = Nr.has(r.tagName);
4182
+ e && t.push("\n"), Pr(r, t, n), e && t.push("\n");
4183
+ }
4184
+ }
4185
+ function Fr(e) {
4186
+ if (e.nodeType === 3) {
4187
+ let t = e.data;
4188
+ return {
4189
+ lines: t,
4190
+ flat: t
4191
+ };
4192
+ }
4193
+ let t = [], n = [];
4194
+ return Pr(e, t, n), {
4195
+ lines: t.join(""),
4196
+ flat: n.join("")
4197
+ };
4198
+ }
4199
+ function Ir(e, t, n) {
4172
4200
  if (!n) {
4173
4201
  e.classList.remove("an-count-warn", "an-count-exceeded");
4174
4202
  return;
4175
4203
  }
4176
4204
  t > n ? (e.classList.add("an-count-exceeded"), e.classList.remove("an-count-warn")) : t >= n * .9 ? (e.classList.add("an-count-warn"), e.classList.remove("an-count-exceeded")) : e.classList.remove("an-count-warn", "an-count-exceeded");
4177
4205
  }
4178
- //#endregion
4179
- //#region src/js/presets/core.js
4180
- var Mr = [
4181
- {
4182
- name: "editor",
4183
- Class: wr
4184
- },
4185
- {
4186
- name: "toolbar",
4187
- Class: Or
4188
- },
4189
- {
4190
- name: "statusbar",
4191
- Class: class {
4192
- constructor(e) {
4193
- this.context = e, this.options = e.options, this.el = null, this._disposers = [], this._wordCountEl = null, this._charCountEl = null;
4194
- }
4195
- initialize() {
4196
- if (this.el = b("div", { class: "an-statusbar" }), this.options.resizable !== !1) {
4197
- let e = b("div", {
4198
- class: "an-resize-handle",
4199
- title: this.context.locale.statusbar.resizeHandle,
4200
- "aria-hidden": "true"
4201
- });
4202
- this._bindResize(e), this.el.appendChild(e);
4203
- }
4204
- this._wordCountEl = b("span", {
4205
- class: "an-word-count",
4206
- role: "status",
4207
- "aria-live": "polite",
4208
- "aria-atomic": "true"
4209
- }), this._charCountEl = b("span", {
4210
- class: "an-char-count",
4211
- "aria-live": "polite",
4212
- "aria-atomic": "true"
4213
- });
4214
- let e = b("div", {
4215
- class: "an-status-info",
4216
- "aria-label": "Editor statistics"
4217
- });
4218
- return e.appendChild(this._wordCountEl), e.appendChild(this._charCountEl), this.el.appendChild(e), this.update(), this;
4219
- }
4220
- destroy() {
4221
- this._disposers.forEach((e) => e()), this._disposers = [], this._dragDisposers &&= (this._dragDisposers.forEach((e) => e()), null), this.el?.remove(), this.el = null;
4222
- }
4223
- _bindResize(e) {
4224
- let t = 0, n = 0, r = this.context.layoutInfo.container, i = (e) => {
4225
- let i = e - t, a = Array.from(r.children).filter((e) => !e.classList.contains("an-editable")).reduce((e, t) => e + t.offsetHeight, 0), o = Math.max(this.options.minHeight || 100, a + 40);
4226
- r.style.height = `${Math.max(o, n + i)}px`;
4227
- }, a = (e) => i(e.clientY), o = () => {
4228
- document.removeEventListener("mousemove", a), document.removeEventListener("mouseup", o), this._dragDisposers = null;
4229
- }, s = (e) => {
4230
- t = e.clientY, n = r.offsetHeight, this.context.layoutInfo.editable.style.minHeight = "", document.addEventListener("mousemove", a), document.addEventListener("mouseup", o), this._dragDisposers = [() => document.removeEventListener("mousemove", a), () => document.removeEventListener("mouseup", o)], e.preventDefault();
4231
- }, c = (e) => {
4232
- let t = e.touches[0];
4233
- t && (e.preventDefault(), i(t.clientY));
4234
- }, l = () => {
4235
- document.removeEventListener("touchmove", c), document.removeEventListener("touchend", l), this._dragDisposers = null;
4236
- }, u = (e) => {
4237
- let i = e.touches[0];
4238
- i && (t = i.clientY, n = r.offsetHeight, this.context.layoutInfo.editable.style.minHeight = "", document.addEventListener("touchmove", c, { passive: !1 }), document.addEventListener("touchend", l), this._dragDisposers = [() => document.removeEventListener("touchmove", c), () => document.removeEventListener("touchend", l)]);
4239
- }, d = S(e, "mousedown", s), f = S(e, "touchstart", u);
4240
- this._disposers.push(d, f);
4241
- }
4242
- update() {
4243
- if (!this._wordCountEl || !this._charCountEl) return;
4244
- let e = this.context.layoutInfo.editable.textContent || "", t = Ar(e), n = e.replaceAll("\n", "").length, r = this.options.maxWords || 0, i = this.options.maxChars || 0, a = this.context.locale.statusbar;
4245
- this._wordCountEl.textContent = r ? a.wordsLimit(t, r) : a.words(t), this._charCountEl.textContent = i ? a.charsLimit(n, i) : a.chars(n), jr(this._wordCountEl, t, r), jr(this._charCountEl, n, i);
4246
- }
4247
- getWordCount() {
4248
- let e = this.context.layoutInfo.editable;
4249
- return Ar(e.innerText || "");
4250
- }
4251
- getCharCount() {
4252
- return (this.context.layoutInfo.editable.innerText || "").replaceAll("\n", "").length;
4253
- }
4206
+ var Lr = class {
4207
+ constructor(e) {
4208
+ this.context = e, this.options = e.options, this.el = null, this._disposers = [], this._wordCountEl = null, this._charCountEl = null, this._countCache = /* @__PURE__ */ new WeakMap();
4209
+ }
4210
+ initialize() {
4211
+ if (this.el = x("div", { class: "an-statusbar" }), this.options.resizable !== !1) {
4212
+ let e = x("div", {
4213
+ class: "an-resize-handle",
4214
+ title: this.context.locale.statusbar.resizeHandle,
4215
+ "aria-hidden": "true"
4216
+ });
4217
+ this._bindResize(e), this.el.appendChild(e);
4254
4218
  }
4255
- },
4256
- {
4257
- name: "clipboard",
4258
- Class: class {
4259
- constructor(e) {
4260
- this.context = e, this.options = e.options, this._disposers = [];
4261
- }
4262
- initialize() {
4263
- this._blobRegistry = /* @__PURE__ */ new Map(), this._forcePlain = !1;
4264
- let e = this.context.layoutInfo.editable;
4265
- return this._disposers.push(S(e, "paste", (e) => this._onPaste(e)), S(e, "dragover", (e) => this._onDragover(e)), S(e, "drop", (e) => this._onDrop(e))), this._mutationObserver = new MutationObserver((e) => {
4266
- for (let t of e) for (let e of t.removedNodes) this._revokeRemovedBlobs(e);
4267
- }), this._mutationObserver.observe(e, {
4268
- childList: !0,
4269
- subtree: !0
4270
- }), this;
4271
- }
4272
- destroy() {
4273
- this._disposers.forEach((e) => e()), this._disposers = [], this._mutationObserver &&= (this._mutationObserver.disconnect(), null), this._blobRegistry && (this._blobRegistry.forEach((e, t) => URL.revokeObjectURL(t)), this._blobRegistry.clear()), this._uploadPreviews && (this._uploadPreviews.forEach(({ previewUrl: e }) => URL.revokeObjectURL(e)), this._uploadPreviews.clear());
4274
- }
4275
- _revokeRemovedBlobs(e) {
4276
- if (!this._blobRegistry?.size) return;
4277
- let t = [];
4278
- e.nodeName === "IMG" ? t.push(e) : e.querySelectorAll && t.push(...e.querySelectorAll("img")), t.forEach((e) => {
4279
- let t = e.getAttribute("src") || "";
4280
- t.startsWith("blob:") && this._blobRegistry.has(t) && (URL.revokeObjectURL(t), this._blobRegistry.delete(t));
4281
- });
4282
- }
4283
- _cleanWordHtml(e) {
4284
- return e.replace(/<!--\[if[\s\S]*?\[endif\]-->/gi, "").replace(/<xml[\s\S]*?<\/xml>/gi, "").replace(/<\?xml[\s\S]*?\?>/gi, "").replace(/<\/?(o|w|m|v|st1):[a-z][^>]*>/gi, "").replace(/\s+class="Mso[^"]*"/gi, "").replace(/\s+style="([^"]*)"/gi, (e, t) => {
4285
- let n = t.split(";").map((e) => e.trim()).filter((e) => e && !/^mso-/i.test(e) && !/^(tab-stops|margin-[a-z]+-alt)/i.test(e)).join("; ");
4286
- return n ? ` style="${n}"` : "";
4287
- }).replace(/<p[^>]*>\s*(&nbsp;)?\s*<\/p>/gi, "");
4288
- }
4289
- _cleanSocialHtml(e) {
4290
- let t = new DOMParser().parseFromString(`<body>${e}</body>`, "text/html"), n = Array.from(t.querySelectorAll("span, div"));
4291
- for (let e = n.length - 1; e >= 0; e--) {
4292
- let t = n[e];
4293
- if (!t.parentNode || t.querySelector("a, strong, em, b, i, ul, ol, li, table, img, blockquote, pre, code, h1, h2, h3, h4, h5, h6")) continue;
4294
- let r = t.parentNode;
4295
- for (; t.firstChild;) r.insertBefore(t.firstChild, t);
4296
- t.remove();
4297
- }
4298
- return t.querySelectorAll("*").forEach((e) => {
4299
- e.removeAttribute("class"), e.removeAttribute("id"), Array.from(e.attributes).filter((e) => e.name.startsWith("data-") || e.name.startsWith("aria-")).forEach((t) => e.removeAttribute(t.name));
4300
- }), t.body.innerHTML;
4301
- }
4302
- _stripAttributes(e) {
4303
- let t = new DOMParser().parseFromString(`<body>${e}</body>`, "text/html"), n = /* @__PURE__ */ new Set([
4304
- "href",
4305
- "src",
4306
- "alt",
4307
- "target",
4308
- "rel",
4309
- "colspan",
4310
- "rowspan",
4311
- "type"
4312
- ]);
4313
- return t.querySelectorAll("*").forEach((e) => {
4314
- Array.from(e.attributes).filter((e) => !n.has(e.name)).forEach((t) => e.removeAttribute(t.name));
4315
- }), t.body.innerHTML;
4316
- }
4317
- _normalizeExternalTaskLists(e) {
4318
- let t = new DOMParser().parseFromString(`<body>${e}</body>`, "text/html");
4319
- for (let e of t.querySelectorAll("input[type=\"checkbox\"]")) {
4320
- let t = e.closest("li"), n = t?.closest("ul");
4321
- if (!(!t || !n || n.classList.contains("an-checklist"))) {
4322
- n.classList.add("an-checklist"), e.removeAttribute("disabled"), e.setAttribute("contenteditable", "false");
4323
- for (let t of Array.from(e.attributes)) [
4324
- "type",
4325
- "checked",
4326
- "contenteditable"
4327
- ].includes(t.name) || e.removeAttribute(t.name);
4328
- }
4329
- }
4330
- return t.body.innerHTML;
4331
- }
4332
- _isTriviallyPlainHtml(e) {
4333
- return !new DOMParser().parseFromString(`<body>${e}</body>`, "text/html").body.querySelector("a,img,table,ul,ol,li,blockquote,pre,code,h1,h2,h3,h4,h5,h6,strong,b,em,i,u,s,del,strike,hr,br");
4334
- }
4335
- setForcePlain(e) {
4336
- this._forcePlain = !!e;
4337
- }
4338
- _onPaste(e) {
4339
- let t = e.clipboardData || globalThis.clipboardData;
4340
- if (!t) return;
4341
- let n = this._forcePlain;
4342
- this._forcePlain = !1;
4343
- let r = (this.options.maxPasteSize ?? 5) * 1024 * 1024;
4344
- if (r > 0) {
4345
- let n = t.getData("text/plain") || "", i = t.getData("text/html") || "", a = Math.max(n.length, i.length);
4346
- if (a > r) {
4347
- e.preventDefault();
4348
- let t = `Pasted content (${a} bytes) exceeds the ${this.options.maxPasteSize ?? 5} MB paste size limit.`;
4349
- this.context.triggerEvent("pasteError", {
4350
- size: a,
4351
- maxBytes: r,
4352
- message: t
4353
- }), console.warn(`[AutumnNote] ${t}`);
4354
- return;
4355
- }
4356
- }
4357
- if (t.items) {
4358
- let n = Array.from(t.items).filter((e) => e.kind === "file" && e.type.startsWith("image/"));
4359
- if (n.length > 0) {
4360
- e.preventDefault();
4361
- let t = n.map((e) => e.getAsFile()).filter(Boolean);
4362
- this._insertImageFiles(t);
4363
- return;
4364
- }
4365
- }
4366
- if (typeof this.options.onPaste == "function" && this.options.onPaste({
4367
- text: t.getData("text/plain") || "",
4368
- html: t.types.includes("text/html") ? t.getData("text/html") : null
4369
- }), n || this.options.pasteAsPlainText) {
4370
- e.preventDefault(), w("insertHTML", t.getData("text/plain").split(/\r?\n/).map((e) => `<p>${this._escapeHTML(e) || "<br>"}</p>`).join("")), this.context.invoke("editor.afterCommand");
4371
- return;
4372
- }
4373
- if (this.options.markdownPaste !== !1) {
4374
- let n = t.types.includes("text/html"), r = n ? t.getData("text/html") : "", i = !n || this._isTriviallyPlainHtml(r), a = t.getData("text/plain");
4375
- if (a && i && Rn(a)) {
4376
- e.preventDefault(), w("insertHTML", j(H(a))), this.context.invoke("editor.afterCommand");
4377
- return;
4378
- }
4379
- }
4380
- if (this.options.pasteCleanHTML !== !1 && t.types.includes("text/html")) {
4381
- e.preventDefault();
4382
- let n = t.getData("text/html"), r = /<[a-z]+:[a-z]/i.test(n) || /class="Mso/i.test(n) || /\bmso-/i.test(n), i = /class="[^"]*\b(?:x[a-z0-9]{6,}|r-[a-z0-9]{3,})\b/.test(n), a = n;
4383
- r ? a = this._cleanWordHtml(a) : i && (a = this._cleanSocialHtml(a)), a = this._normalizeExternalTaskLists(a), a = j(a), this.options.pasteStripAttributes && (a = this._stripAttributes(a)), w("insertHTML", a), this.context.invoke("editor.afterCommand");
4384
- }
4385
- }
4386
- _onDragover(e) {
4387
- e.dataTransfer && Array.from(e.dataTransfer.types || []).includes("Files") && (e.preventDefault(), e.dataTransfer.dropEffect = "copy");
4388
- }
4389
- _onDrop(e) {
4390
- let t = e.dataTransfer;
4391
- if (!t?.files?.length) return;
4392
- let n = Array.from(t.files).filter((e) => e.type.startsWith("image/"));
4393
- if (n.length > 0) {
4394
- e.preventDefault(), e.stopPropagation(), this._placeCaretAtPoint(e.clientX, e.clientY), this._insertImageFiles(n);
4395
- return;
4396
- }
4397
- if (this.options.markdownPaste !== !1) {
4398
- let n = Array.from(t.files).find((e) => /\.md$/i.test(e.name) || e.type === "text/markdown");
4399
- n && (e.preventDefault(), e.stopPropagation(), this._placeCaretAtPoint(e.clientX, e.clientY), this._insertMarkdownFile(n));
4400
- }
4401
- }
4402
- _insertMarkdownFile(e) {
4403
- let t = (this.options.maxPasteSize ?? 5) * 1024 * 1024;
4404
- if (t > 0 && e.size > t) {
4405
- let n = `Dropped file "${e.name}" (${e.size} bytes) exceeds the ${this.options.maxPasteSize ?? 5} MB paste size limit.`;
4406
- this.context.triggerEvent("pasteError", {
4407
- size: e.size,
4408
- maxBytes: t,
4409
- message: n
4410
- }), console.warn(`[AutumnNote] ${n}`);
4411
- return;
4412
- }
4413
- let n = new FileReader();
4414
- n.onload = (e) => {
4415
- w("insertHTML", j(H(e.target.result || ""))), this.context.invoke("editor.afterCommand");
4416
- }, n.onerror = () => {
4417
- let t = `Failed to read dropped markdown file "${e.name}".`;
4418
- console.warn(`[AutumnNote] ${t}`), this.context.triggerEvent("pasteError", { message: t });
4419
- }, n.readAsText(e);
4420
- }
4421
- _insertImageFiles(e) {
4422
- if (!e || e.length === 0) return;
4423
- if (typeof this.options.onImageUpload == "function") {
4424
- this._runUploadHandler(e);
4425
- return;
4426
- }
4427
- let t = /* @__PURE__ */ new Set([
4428
- "image/tiff",
4429
- "image/x-tiff",
4430
- "image/bmp",
4431
- "image/x-bmp",
4432
- "image/x-ms-bmp"
4433
- ]), n = (this.options.maxImageSize || 5) * 1024 * 1024;
4434
- e.forEach((e) => {
4435
- if (!e?.type?.startsWith("image/")) return;
4436
- if (t.has(e.type)) {
4437
- let t = `Image format "${e.type}" is not supported for display in web browsers. Please convert to PNG, JPEG, or WebP first.`;
4438
- this.context.triggerEvent("imageError", {
4439
- file: e,
4440
- message: t
4441
- }), console.warn("[AutumnNote]", t);
4442
- return;
4443
- }
4444
- if (e.size > n) {
4445
- let t = `Image "${e.name}" exceeds the ${this.options.maxImageSize || 5} MB size limit.`;
4446
- this.context.triggerEvent("imageError", {
4447
- file: e,
4448
- message: t
4449
- }), console.warn(`[AutumnNote] ${t}`);
4450
- return;
4451
- }
4452
- let r = e.name.replace(/\.[^.]+$/, "");
4453
- this.compressAndRegister(e).then((e) => {
4454
- this.context.invoke("editor.insertImage", e, r);
4455
- }).catch((t) => {
4456
- let n = `Image "${e.name}" could not be processed.`;
4457
- this.context.triggerEvent("imageError", {
4458
- file: e,
4459
- message: n,
4460
- error: t
4461
- }), console.warn("[AutumnNote]", n, t);
4462
- });
4463
- });
4219
+ this._wordCountEl = x("span", {
4220
+ class: "an-word-count",
4221
+ role: "status",
4222
+ "aria-live": "polite",
4223
+ "aria-atomic": "true"
4224
+ }), this._charCountEl = x("span", {
4225
+ class: "an-char-count",
4226
+ "aria-live": "polite",
4227
+ "aria-atomic": "true"
4228
+ });
4229
+ let e = x("div", {
4230
+ class: "an-status-info",
4231
+ "aria-label": "Editor statistics"
4232
+ });
4233
+ return e.appendChild(this._wordCountEl), e.appendChild(this._charCountEl), this.el.appendChild(e), this.update(), this;
4234
+ }
4235
+ destroy() {
4236
+ this._disposers.forEach((e) => e()), this._disposers = [], this._dragDisposers &&= (this._dragDisposers.forEach((e) => e()), null), this.el?.remove(), this.el = null;
4237
+ }
4238
+ _bindResize(e) {
4239
+ let t = 0, n = 0, r = this.context.layoutInfo.container, i = (e) => {
4240
+ let i = e - t, a = Array.from(r.children).filter((e) => !e.classList.contains("an-editable")).reduce((e, t) => e + t.offsetHeight, 0), o = Math.max(this.options.minHeight || 100, a + 40);
4241
+ r.style.height = `${Math.max(o, n + i)}px`;
4242
+ }, a = (e) => i(e.clientY), o = () => {
4243
+ document.removeEventListener("mousemove", a), document.removeEventListener("mouseup", o), this._dragDisposers = null;
4244
+ }, s = (e) => {
4245
+ t = e.clientY, n = r.offsetHeight, this.context.layoutInfo.editable.style.minHeight = "", document.addEventListener("mousemove", a), document.addEventListener("mouseup", o), this._dragDisposers = [() => document.removeEventListener("mousemove", a), () => document.removeEventListener("mouseup", o)], e.preventDefault();
4246
+ }, c = (e) => {
4247
+ let t = e.touches[0];
4248
+ t && (e.preventDefault(), i(t.clientY));
4249
+ }, l = () => {
4250
+ document.removeEventListener("touchmove", c), document.removeEventListener("touchend", l), this._dragDisposers = null;
4251
+ }, u = (e) => {
4252
+ let i = e.touches[0];
4253
+ i && (t = i.clientY, n = r.offsetHeight, this.context.layoutInfo.editable.style.minHeight = "", document.addEventListener("touchmove", c, { passive: !1 }), document.addEventListener("touchend", l), this._dragDisposers = [() => document.removeEventListener("touchmove", c), () => document.removeEventListener("touchend", l)]);
4254
+ }, d = C(e, "mousedown", s), f = C(e, "touchstart", u);
4255
+ this._disposers.push(d, f);
4256
+ }
4257
+ _counts() {
4258
+ let e = this.context.layoutInfo.editable, t = 0, n = 0, r = [], i = [], a = 0;
4259
+ for (let o = e.firstChild; o; o = o.nextSibling) {
4260
+ let e = this._countCache.get(o);
4261
+ if (e && e.key === (o.textContent || "")) {
4262
+ t += e.words, n += e.chars;
4263
+ continue;
4464
4264
  }
4465
- _escapeAttr(e) {
4466
- return String(e).replaceAll("&", "&amp;").replaceAll("\"", "&quot;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
4265
+ let { lines: s, flat: c } = Fr(o);
4266
+ r.push({
4267
+ node: o,
4268
+ key: c,
4269
+ text: s,
4270
+ start: a
4271
+ }), i.push(s), a += s.length + 1;
4272
+ }
4273
+ if (r.length) {
4274
+ let e = this._countBatch(r, i.join("\n"));
4275
+ r.forEach((r, i) => {
4276
+ let a = {
4277
+ key: r.key,
4278
+ words: e[i],
4279
+ chars: r.key.replaceAll("\n", "").length
4280
+ };
4281
+ this._countCache.set(r.node, a), t += a.words, n += a.chars;
4282
+ });
4283
+ }
4284
+ return {
4285
+ words: t,
4286
+ chars: n
4287
+ };
4288
+ }
4289
+ _countBatch(e, t) {
4290
+ if (!jr) return e.map((e) => Mr(e.text));
4291
+ let n = Array(e.length).fill(0), r = 0;
4292
+ for (let i of jr.segment(t)) if (i.isWordLike) {
4293
+ for (; r < e.length - 1 && i.index >= e[r + 1].start;) r++;
4294
+ n[r]++;
4295
+ }
4296
+ return n;
4297
+ }
4298
+ update() {
4299
+ if (!this._wordCountEl || !this._charCountEl) return;
4300
+ let { words: e, chars: t } = this._counts(), n = this.options.maxWords || 0, r = this.options.maxChars || 0, i = this.context.locale.statusbar;
4301
+ this._wordCountEl.textContent = n ? i.wordsLimit(e, n) : i.words(e), this._charCountEl.textContent = r ? i.charsLimit(t, r) : i.chars(t), Ir(this._wordCountEl, e, n), Ir(this._charCountEl, t, r);
4302
+ }
4303
+ getWordCount() {
4304
+ return this._counts().words;
4305
+ }
4306
+ getCharCount() {
4307
+ return this._counts().chars;
4308
+ }
4309
+ }, Rr = class {
4310
+ constructor(e) {
4311
+ this.context = e, this.options = e.options, this._disposers = [];
4312
+ }
4313
+ initialize() {
4314
+ this._blobRegistry = /* @__PURE__ */ new Map(), this._forcePlain = !1;
4315
+ let e = this.context.layoutInfo.editable;
4316
+ return this._disposers.push(C(e, "paste", (e) => this._onPaste(e)), C(e, "dragover", (e) => this._onDragover(e)), C(e, "drop", (e) => this._onDrop(e))), this._mutationObserver = new MutationObserver((e) => {
4317
+ for (let t of e) for (let e of t.removedNodes) this._revokeRemovedBlobs(e);
4318
+ }), this._mutationObserver.observe(e, {
4319
+ childList: !0,
4320
+ subtree: !0
4321
+ }), this;
4322
+ }
4323
+ destroy() {
4324
+ this._disposers.forEach((e) => e()), this._disposers = [], this._mutationObserver &&= (this._mutationObserver.disconnect(), null), this._blobRegistry && (this._blobRegistry.forEach((e, t) => URL.revokeObjectURL(t)), this._blobRegistry.clear()), this._uploadPreviews && (this._uploadPreviews.forEach(({ previewUrl: e }) => URL.revokeObjectURL(e)), this._uploadPreviews.clear());
4325
+ }
4326
+ _revokeRemovedBlobs(e) {
4327
+ if (!this._blobRegistry?.size) return;
4328
+ let t = [];
4329
+ e.nodeName === "IMG" ? t.push(e) : e.querySelectorAll && t.push(...e.querySelectorAll("img")), t.forEach((e) => {
4330
+ let t = e.getAttribute("src") || "";
4331
+ t.startsWith("blob:") && this._blobRegistry.has(t) && (URL.revokeObjectURL(t), this._blobRegistry.delete(t));
4332
+ });
4333
+ }
4334
+ _cleanWordHtml(e) {
4335
+ return e.replace(/<!--\[if[\s\S]*?\[endif\]-->/gi, "").replace(/<xml[\s\S]*?<\/xml>/gi, "").replace(/<\?xml[\s\S]*?\?>/gi, "").replace(/<\/?(o|w|m|v|st1):[a-z][^>]*>/gi, "").replace(/\s+class="Mso[^"]*"/gi, "").replace(/\s+style="([^"]*)"/gi, (e, t) => {
4336
+ let n = t.split(";").map((e) => e.trim()).filter((e) => e && !/^mso-/i.test(e) && !/^(tab-stops|margin-[a-z]+-alt)/i.test(e)).join("; ");
4337
+ return n ? ` style="${n}"` : "";
4338
+ }).replace(/<p[^>]*>\s*(&nbsp;)?\s*<\/p>/gi, "");
4339
+ }
4340
+ _cleanSocialHtml(e) {
4341
+ let t = new DOMParser().parseFromString(`<body>${e}</body>`, "text/html"), n = Array.from(t.querySelectorAll("span, div"));
4342
+ for (let e = n.length - 1; e >= 0; e--) {
4343
+ let t = n[e];
4344
+ if (!t.parentNode || t.querySelector("a, strong, em, b, i, ul, ol, li, table, img, blockquote, pre, code, h1, h2, h3, h4, h5, h6")) continue;
4345
+ let r = t.parentNode;
4346
+ for (; t.firstChild;) r.insertBefore(t.firstChild, t);
4347
+ t.remove();
4348
+ }
4349
+ return t.querySelectorAll("*").forEach((e) => {
4350
+ e.removeAttribute("class"), e.removeAttribute("id"), Array.from(e.attributes).filter((e) => e.name.startsWith("data-") || e.name.startsWith("aria-")).forEach((t) => e.removeAttribute(t.name));
4351
+ }), t.body.innerHTML;
4352
+ }
4353
+ _stripAttributes(e) {
4354
+ let t = new DOMParser().parseFromString(`<body>${e}</body>`, "text/html"), n = /* @__PURE__ */ new Set([
4355
+ "href",
4356
+ "src",
4357
+ "alt",
4358
+ "target",
4359
+ "rel",
4360
+ "colspan",
4361
+ "rowspan",
4362
+ "type"
4363
+ ]);
4364
+ return t.querySelectorAll("*").forEach((e) => {
4365
+ Array.from(e.attributes).filter((e) => !n.has(e.name)).forEach((t) => e.removeAttribute(t.name));
4366
+ }), t.body.innerHTML;
4367
+ }
4368
+ _normalizeExternalTaskLists(e) {
4369
+ let t = new DOMParser().parseFromString(`<body>${e}</body>`, "text/html");
4370
+ for (let e of t.querySelectorAll("input[type=\"checkbox\"]")) {
4371
+ let t = e.closest("li"), n = t?.closest("ul");
4372
+ if (!(!t || !n || n.classList.contains("an-checklist"))) {
4373
+ n.classList.add("an-checklist"), e.removeAttribute("disabled"), e.setAttribute("contenteditable", "false");
4374
+ for (let t of Array.from(e.attributes)) [
4375
+ "type",
4376
+ "checked",
4377
+ "contenteditable"
4378
+ ].includes(t.name) || e.removeAttribute(t.name);
4467
4379
  }
4468
- async _runUploadHandler(e) {
4469
- let t = {
4470
- context: this.context,
4471
- setProgress: (e, t) => this._setUploadProgress(e, t)
4472
- }, n;
4473
- try {
4474
- n = this.options.onImageUpload(e, t);
4475
- } catch (t) {
4476
- this._reportUploadError(e, t);
4477
- return;
4478
- }
4479
- if (n === void 0) return;
4480
- let r = e.map((e) => this._insertUploadPlaceholder(e)), i;
4481
- try {
4482
- i = await n;
4483
- } catch (t) {
4484
- r.forEach((n, r) => this._failUpload(n, e[r], t));
4485
- return;
4486
- }
4487
- let a = Array.isArray(i) ? i : [i];
4488
- r.forEach((t, n) => {
4489
- let r = a[n];
4490
- typeof r == "string" && r ? this._resolveUpload(t, r) : this._failUpload(t, e[n], /* @__PURE__ */ Error("No URL returned for this file."));
4491
- });
4380
+ }
4381
+ return t.body.innerHTML;
4382
+ }
4383
+ _isTriviallyPlainHtml(e) {
4384
+ return !new DOMParser().parseFromString(`<body>${e}</body>`, "text/html").body.querySelector("a,img,table,ul,ol,li,blockquote,pre,code,h1,h2,h3,h4,h5,h6,strong,b,em,i,u,s,del,strike,hr,br");
4385
+ }
4386
+ setForcePlain(e) {
4387
+ this._forcePlain = !!e;
4388
+ }
4389
+ _onPaste(e) {
4390
+ let t = e.clipboardData || globalThis.clipboardData;
4391
+ if (!t) return;
4392
+ let n = this._forcePlain;
4393
+ this._forcePlain = !1;
4394
+ let r = (this.options.maxPasteSize ?? 5) * 1024 * 1024;
4395
+ if (r > 0) {
4396
+ let n = t.getData("text/plain") || "", i = t.getData("text/html") || "", a = Math.max(n.length, i.length);
4397
+ if (a > r) {
4398
+ e.preventDefault();
4399
+ let t = `Pasted content (${a} bytes) exceeds the ${this.options.maxPasteSize ?? 5} MB paste size limit.`;
4400
+ this.context.triggerEvent("pasteError", {
4401
+ size: a,
4402
+ maxBytes: r,
4403
+ message: t
4404
+ }), console.warn(`[AutumnNote] ${t}`);
4405
+ return;
4492
4406
  }
4493
- _insertUploadPlaceholder(e) {
4494
- let t = `an-up-${Date.now().toString(36)}-${this._uploadSeq = (this._uploadSeq || 0) + 1}`, n = URL.createObjectURL(e);
4495
- this._uploadPreviews = this._uploadPreviews || /* @__PURE__ */ new Map(), this._uploadPreviews.set(t, {
4496
- previewUrl: n,
4497
- file: e
4498
- });
4499
- let r = this._escapeAttr(e.name.replace(/\.[^.]+$/, ""));
4500
- return w("insertHTML", `<img src="${this._escapeAttr(n)}" alt="${r}" class="an-image an-image-uploading" data-an-upload="${t}">`), this.context.invoke("editor.afterCommand"), t;
4407
+ }
4408
+ if (t.items) {
4409
+ let n = Array.from(t.items).filter((e) => e.kind === "file" && e.type.startsWith("image/"));
4410
+ if (n.length > 0) {
4411
+ e.preventDefault();
4412
+ let t = n.map((e) => e.getAsFile()).filter(Boolean);
4413
+ this._insertImageFiles(t);
4414
+ return;
4501
4415
  }
4502
- _findPlaceholder(e) {
4503
- return this.context.layoutInfo.editable?.querySelector(`img[data-an-upload="${e}"]`) ?? null;
4416
+ }
4417
+ if (typeof this.options.onPaste == "function" && this.options.onPaste({
4418
+ text: t.getData("text/plain") || "",
4419
+ html: t.types.includes("text/html") ? t.getData("text/html") : null
4420
+ }), n || this.options.pasteAsPlainText) {
4421
+ e.preventDefault(), w("insertHTML", t.getData("text/plain").split(/\r?\n/).map((e) => `<p>${this._escapeHTML(e) || "<br>"}</p>`).join("")), this.context.invoke("editor.afterCommand");
4422
+ return;
4423
+ }
4424
+ if (this.options.markdownPaste !== !1) {
4425
+ let n = t.types.includes("text/html"), r = n ? t.getData("text/html") : "", i = !n || this._isTriviallyPlainHtml(r), a = t.getData("text/plain");
4426
+ if (a && i && zn(a)) {
4427
+ e.preventDefault(), w("insertHTML", j(H(a))), this.context.invoke("editor.afterCommand");
4428
+ return;
4504
4429
  }
4505
- _resolveUpload(e, t) {
4506
- let n = this._findPlaceholder(e), r = this._uploadPreviews?.get(e);
4507
- if (n) {
4508
- let i = M(t, { allowData: !0 });
4509
- if (i) n.setAttribute("src", i), n.classList.remove("an-image-uploading"), n.removeAttribute("data-an-upload"), n.style.removeProperty("--an-upload-progress");
4510
- else {
4511
- this._failUpload(e, r?.file, /* @__PURE__ */ Error(`Rejected image URL: ${t}`));
4512
- return;
4513
- }
4514
- }
4515
- r && (URL.revokeObjectURL(r.previewUrl), this._uploadPreviews.delete(e)), this.context.invoke("editor.afterCommand");
4430
+ }
4431
+ if (this.options.pasteCleanHTML !== !1 && t.types.includes("text/html")) {
4432
+ e.preventDefault();
4433
+ let n = t.getData("text/html"), r = /<[a-z]+:[a-z]/i.test(n) || /class="Mso/i.test(n) || /\bmso-/i.test(n), i = /class="[^"]*\b(?:x[a-z0-9]{6,}|r-[a-z0-9]{3,})\b/.test(n), a = n;
4434
+ r ? a = this._cleanWordHtml(a) : i && (a = this._cleanSocialHtml(a)), a = this._normalizeExternalTaskLists(a), a = j(a), this.options.pasteStripAttributes && (a = this._stripAttributes(a)), w("insertHTML", a), this.context.invoke("editor.afterCommand");
4435
+ }
4436
+ }
4437
+ _onDragover(e) {
4438
+ e.dataTransfer && Array.from(e.dataTransfer.types || []).includes("Files") && (e.preventDefault(), e.dataTransfer.dropEffect = "copy");
4439
+ }
4440
+ _onDrop(e) {
4441
+ let t = e.dataTransfer;
4442
+ if (!t?.files?.length) return;
4443
+ let n = Array.from(t.files).filter((e) => e.type.startsWith("image/"));
4444
+ if (n.length > 0) {
4445
+ e.preventDefault(), e.stopPropagation(), this._placeCaretAtPoint(e.clientX, e.clientY), this._insertImageFiles(n);
4446
+ return;
4447
+ }
4448
+ if (this.options.markdownPaste !== !1) {
4449
+ let n = Array.from(t.files).find((e) => /\.md$/i.test(e.name) || e.type === "text/markdown");
4450
+ n && (e.preventDefault(), e.stopPropagation(), this._placeCaretAtPoint(e.clientX, e.clientY), this._insertMarkdownFile(n));
4451
+ }
4452
+ }
4453
+ _insertMarkdownFile(e) {
4454
+ let t = (this.options.maxPasteSize ?? 5) * 1024 * 1024;
4455
+ if (t > 0 && e.size > t) {
4456
+ let n = `Dropped file "${e.name}" (${e.size} bytes) exceeds the ${this.options.maxPasteSize ?? 5} MB paste size limit.`;
4457
+ this.context.triggerEvent("pasteError", {
4458
+ size: e.size,
4459
+ maxBytes: t,
4460
+ message: n
4461
+ }), console.warn(`[AutumnNote] ${n}`);
4462
+ return;
4463
+ }
4464
+ let n = new FileReader();
4465
+ n.onload = (e) => {
4466
+ w("insertHTML", j(H(e.target.result || ""))), this.context.invoke("editor.afterCommand");
4467
+ }, n.onerror = () => {
4468
+ let t = `Failed to read dropped markdown file "${e.name}".`;
4469
+ console.warn(`[AutumnNote] ${t}`), this.context.triggerEvent("pasteError", { message: t });
4470
+ }, n.readAsText(e);
4471
+ }
4472
+ _insertImageFiles(e) {
4473
+ if (!e || e.length === 0) return;
4474
+ if (typeof this.options.onImageUpload == "function") {
4475
+ this._runUploadHandler(e);
4476
+ return;
4477
+ }
4478
+ let t = /* @__PURE__ */ new Set([
4479
+ "image/tiff",
4480
+ "image/x-tiff",
4481
+ "image/bmp",
4482
+ "image/x-bmp",
4483
+ "image/x-ms-bmp"
4484
+ ]), n = (this.options.maxImageSize || 5) * 1024 * 1024;
4485
+ e.forEach((e) => {
4486
+ if (!e?.type?.startsWith("image/")) return;
4487
+ if (t.has(e.type)) {
4488
+ let t = `Image format "${e.type}" is not supported for display in web browsers. Please convert to PNG, JPEG, or WebP first.`;
4489
+ this.context.triggerEvent("imageError", {
4490
+ file: e,
4491
+ message: t
4492
+ }), console.warn("[AutumnNote]", t);
4493
+ return;
4516
4494
  }
4517
- _failUpload(e, t, n) {
4518
- let r = this._findPlaceholder(e);
4519
- r && (r.classList.remove("an-image-uploading"), r.classList.add("an-image-failed"), r.style.removeProperty("--an-upload-progress"));
4520
- let i = `Image "${t?.name ?? "unknown"}" could not be uploaded.`;
4521
- console.warn("[AutumnNote]", i, n), this.context.triggerEvent("imageError", {
4522
- file: t,
4523
- message: i,
4524
- error: n,
4525
- retry: () => {
4526
- r?.remove(), this._uploadPreviews?.delete(e), t && this._runUploadHandler([t]);
4527
- }
4528
- });
4495
+ if (e.size > n) {
4496
+ let t = `Image "${e.name}" exceeds the ${this.options.maxImageSize || 5} MB size limit.`;
4497
+ this.context.triggerEvent("imageError", {
4498
+ file: e,
4499
+ message: t
4500
+ }), console.warn(`[AutumnNote] ${t}`);
4501
+ return;
4529
4502
  }
4530
- _reportUploadError(e, t) {
4531
- let n = "The image upload handler threw before any file was sent.";
4532
- console.warn("[AutumnNote]", n, t), this.context.triggerEvent("imageError", {
4533
- file: e[0],
4503
+ let r = e.name.replace(/\.[^.]+$/, "");
4504
+ this.compressAndRegister(e).then((e) => {
4505
+ this.context.invoke("editor.insertImage", e, r);
4506
+ }).catch((t) => {
4507
+ let n = `Image "${e.name}" could not be processed.`;
4508
+ this.context.triggerEvent("imageError", {
4509
+ file: e,
4534
4510
  message: n,
4535
4511
  error: t
4536
- });
4537
- }
4538
- _setUploadProgress(e, t) {
4539
- if (!this._uploadPreviews) return;
4540
- let n = Math.max(0, Math.min(1, Number(t) || 0));
4541
- for (let [t, r] of this._uploadPreviews) {
4542
- if (r.file !== e) continue;
4543
- let i = this._findPlaceholder(t);
4544
- i && i.style.setProperty("--an-upload-progress", String(n));
4545
- return;
4546
- }
4547
- }
4548
- async compressAndRegister(e) {
4549
- let t = this.options.imageProcessor, n = typeof t == "function" ? await t(e, { context: this.context }) : await this._compressImage(e), r = this._dataUrlToBlob(n), i = URL.createObjectURL(r);
4550
- return this._blobRegistry.set(i, n), i;
4551
- }
4552
- resolveImages(e) {
4553
- return this._blobRegistry?.size ? e.replace(/blob:[^"'> \t\n\r]*/g, (e) => this._blobRegistry.get(e) || e) : e;
4554
- }
4555
- _dataUrlToBlob(e) {
4556
- let [t, n] = e.split(","), r = /:(.*?);/.exec(t)?.[1] ?? "image/png", i = atob(n), a = new Uint8Array(i.length);
4557
- for (let e = 0; e < i.length; e++) a[e] = i.charCodeAt(e);
4558
- return new Blob([a], { type: r });
4512
+ }), console.warn("[AutumnNote]", n, t);
4513
+ });
4514
+ });
4515
+ }
4516
+ _escapeAttr(e) {
4517
+ return String(e).replaceAll("&", "&amp;").replaceAll("\"", "&quot;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
4518
+ }
4519
+ async _runUploadHandler(e) {
4520
+ let t = {
4521
+ context: this.context,
4522
+ setProgress: (e, t) => this._setUploadProgress(e, t)
4523
+ }, n;
4524
+ try {
4525
+ n = this.options.onImageUpload(e, t);
4526
+ } catch (t) {
4527
+ this._reportUploadError(e, t);
4528
+ return;
4529
+ }
4530
+ if (n === void 0) return;
4531
+ let r = e.map((e) => this._insertUploadPlaceholder(e)), i;
4532
+ try {
4533
+ i = await n;
4534
+ } catch (t) {
4535
+ r.forEach((n, r) => this._failUpload(n, e[r], t));
4536
+ return;
4537
+ }
4538
+ let a = Array.isArray(i) ? i : [i];
4539
+ r.forEach((t, n) => {
4540
+ let r = a[n];
4541
+ typeof r == "string" && r ? this._resolveUpload(t, r) : this._failUpload(t, e[n], /* @__PURE__ */ Error("No URL returned for this file."));
4542
+ });
4543
+ }
4544
+ _insertUploadPlaceholder(e) {
4545
+ let t = `an-up-${Date.now().toString(36)}-${this._uploadSeq = (this._uploadSeq || 0) + 1}`, n = URL.createObjectURL(e);
4546
+ this._uploadPreviews = this._uploadPreviews || /* @__PURE__ */ new Map(), this._uploadPreviews.set(t, {
4547
+ previewUrl: n,
4548
+ file: e
4549
+ });
4550
+ let r = this._escapeAttr(e.name.replace(/\.[^.]+$/, ""));
4551
+ return w("insertHTML", `<img src="${this._escapeAttr(n)}" alt="${r}" class="an-image an-image-uploading" data-an-upload="${t}">`), this.context.invoke("editor.afterCommand"), t;
4552
+ }
4553
+ _findPlaceholder(e) {
4554
+ return this.context.layoutInfo.editable?.querySelector(`img[data-an-upload="${e}"]`) ?? null;
4555
+ }
4556
+ _resolveUpload(e, t) {
4557
+ let n = this._findPlaceholder(e), r = this._uploadPreviews?.get(e);
4558
+ if (n) {
4559
+ let i = M(t, { allowData: !0 });
4560
+ if (i) n.setAttribute("src", i), n.classList.remove("an-image-uploading"), n.removeAttribute("data-an-upload"), n.style.removeProperty("--an-upload-progress");
4561
+ else {
4562
+ this._failUpload(e, r?.file, /* @__PURE__ */ Error(`Rejected image URL: ${t}`));
4563
+ return;
4559
4564
  }
4560
- _compressImage(e) {
4561
- let t = 1920, n = .85;
4562
- return new Promise((r, i) => {
4563
- let a = URL.createObjectURL(e), o = new Image();
4564
- o.onload = () => {
4565
- URL.revokeObjectURL(a);
4566
- let { width: s, height: c } = o;
4567
- (s > t || c > t) && (s >= c ? (c = Math.round(c * t / s), s = t) : (s = Math.round(s * t / c), c = t));
4568
- let l = document.createElement("canvas");
4569
- l.width = s, l.height = c;
4570
- let u = l.getContext("2d");
4571
- if (!u) {
4572
- let t = new FileReader();
4573
- t.onload = (e) => r(e.target.result), t.onerror = () => i(/* @__PURE__ */ Error("FileReader failed")), t.readAsDataURL(e);
4574
- return;
4575
- }
4576
- u.drawImage(o, 0, 0, s, c);
4577
- let d = l.toDataURL("image/webp", n);
4578
- r(d.startsWith("data:image/webp") ? d : l.toDataURL("image/jpeg", n));
4579
- }, o.onerror = () => {
4580
- URL.revokeObjectURL(a);
4581
- let t = new FileReader();
4582
- t.onload = (e) => r(e.target.result), t.onerror = () => i(/* @__PURE__ */ Error("FileReader failed")), t.readAsDataURL(e);
4583
- }, o.src = a;
4584
- });
4565
+ }
4566
+ r && (URL.revokeObjectURL(r.previewUrl), this._uploadPreviews.delete(e)), this.context.invoke("editor.afterCommand");
4567
+ }
4568
+ _failUpload(e, t, n) {
4569
+ let r = this._findPlaceholder(e);
4570
+ r && (r.classList.remove("an-image-uploading"), r.classList.add("an-image-failed"), r.style.removeProperty("--an-upload-progress"));
4571
+ let i = `Image "${t?.name ?? "unknown"}" could not be uploaded.`;
4572
+ console.warn("[AutumnNote]", i, n), this.context.triggerEvent("imageError", {
4573
+ file: t,
4574
+ message: i,
4575
+ error: n,
4576
+ retry: () => {
4577
+ r?.remove(), this._uploadPreviews?.delete(e), t && this._runUploadHandler([t]);
4585
4578
  }
4586
- _placeCaretAtPoint(e, t) {
4587
- let n;
4588
- if (document.caretRangeFromPoint) n = document.caretRangeFromPoint(e, t);
4589
- else if (document.caretPositionFromPoint) {
4590
- let r = document.caretPositionFromPoint(e, t);
4591
- r && (n = document.createRange(), n.setStart(r.offsetNode, r.offset), n.collapse(!0));
4579
+ });
4580
+ }
4581
+ _reportUploadError(e, t) {
4582
+ let n = "The image upload handler threw before any file was sent.";
4583
+ console.warn("[AutumnNote]", n, t), this.context.triggerEvent("imageError", {
4584
+ file: e[0],
4585
+ message: n,
4586
+ error: t
4587
+ });
4588
+ }
4589
+ _setUploadProgress(e, t) {
4590
+ if (!this._uploadPreviews) return;
4591
+ let n = Math.max(0, Math.min(1, Number(t) || 0));
4592
+ for (let [t, r] of this._uploadPreviews) {
4593
+ if (r.file !== e) continue;
4594
+ let i = this._findPlaceholder(t);
4595
+ i && i.style.setProperty("--an-upload-progress", String(n));
4596
+ return;
4597
+ }
4598
+ }
4599
+ async compressAndRegister(e) {
4600
+ let t = this.options.imageProcessor, n = typeof t == "function" ? await t(e, { context: this.context }) : await this._compressImage(e), r = this._dataUrlToBlob(n), i = URL.createObjectURL(r);
4601
+ return this._blobRegistry.set(i, n), i;
4602
+ }
4603
+ resolveImages(e) {
4604
+ return this._blobRegistry?.size ? e.replace(/blob:[^"'> \t\n\r]*/g, (e) => this._blobRegistry.get(e) || e) : e;
4605
+ }
4606
+ _dataUrlToBlob(e) {
4607
+ let [t, n] = e.split(","), r = /:(.*?);/.exec(t)?.[1] ?? "image/png", i = atob(n), a = new Uint8Array(i.length);
4608
+ for (let e = 0; e < i.length; e++) a[e] = i.charCodeAt(e);
4609
+ return new Blob([a], { type: r });
4610
+ }
4611
+ _compressImage(e) {
4612
+ let t = 1920, n = .85;
4613
+ return new Promise((r, i) => {
4614
+ let a = URL.createObjectURL(e), o = new Image();
4615
+ o.onload = () => {
4616
+ URL.revokeObjectURL(a);
4617
+ let { width: s, height: c } = o;
4618
+ (s > t || c > t) && (s >= c ? (c = Math.round(c * t / s), s = t) : (s = Math.round(s * t / c), c = t));
4619
+ let l = document.createElement("canvas");
4620
+ l.width = s, l.height = c;
4621
+ let u = l.getContext("2d");
4622
+ if (!u) {
4623
+ let t = new FileReader();
4624
+ t.onload = (e) => r(e.target.result), t.onerror = () => i(/* @__PURE__ */ Error("FileReader failed")), t.readAsDataURL(e);
4625
+ return;
4592
4626
  }
4593
- if (!n) return;
4594
- let r = globalThis.getSelection();
4595
- r && (r.removeAllRanges(), r.addRange(n));
4596
- }
4597
- _escapeHTML(e) {
4598
- return e.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll("\"", "&quot;").replaceAll("'", "&#039;");
4599
- }
4627
+ u.drawImage(o, 0, 0, s, c);
4628
+ let d = l.toDataURL("image/webp", n);
4629
+ r(d.startsWith("data:image/webp") ? d : l.toDataURL("image/jpeg", n));
4630
+ }, o.onerror = () => {
4631
+ URL.revokeObjectURL(a);
4632
+ let t = new FileReader();
4633
+ t.onload = (e) => r(e.target.result), t.onerror = () => i(/* @__PURE__ */ Error("FileReader failed")), t.readAsDataURL(e);
4634
+ }, o.src = a;
4635
+ });
4636
+ }
4637
+ _placeCaretAtPoint(e, t) {
4638
+ let n;
4639
+ if (document.caretRangeFromPoint) n = document.caretRangeFromPoint(e, t);
4640
+ else if (document.caretPositionFromPoint) {
4641
+ let r = document.caretPositionFromPoint(e, t);
4642
+ r && (n = document.createRange(), n.setStart(r.offsetNode, r.offset), n.collapse(!0));
4600
4643
  }
4644
+ if (!n) return;
4645
+ let r = globalThis.getSelection();
4646
+ r && (r.removeAllRanges(), r.addRange(n));
4647
+ }
4648
+ _escapeHTML(e) {
4649
+ return e.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll("\"", "&quot;").replaceAll("'", "&#039;");
4650
+ }
4651
+ }, zr = /[^\s\u200B]/;
4652
+ function Br(e) {
4653
+ let t = document.createTreeWalker(e, NodeFilter.SHOW_TEXT);
4654
+ for (let e = t.nextNode(); e; e = t.nextNode()) if (zr.test(e.data)) return !0;
4655
+ return !1;
4656
+ }
4657
+ //#endregion
4658
+ //#region src/js/presets/core.js
4659
+ var Vr = [
4660
+ {
4661
+ name: "editor",
4662
+ Class: Er
4663
+ },
4664
+ {
4665
+ name: "toolbar",
4666
+ Class: Ar
4667
+ },
4668
+ {
4669
+ name: "statusbar",
4670
+ Class: Lr
4671
+ },
4672
+ {
4673
+ name: "clipboard",
4674
+ Class: Rr
4601
4675
  },
4602
4676
  {
4603
4677
  name: "placeholder",
@@ -4608,14 +4682,14 @@ var Mr = [
4608
4682
  initialize() {
4609
4683
  let e = this.context.layoutInfo.editable, t = this.options.placeholder || "";
4610
4684
  t && (e.dataset.placeholder = t);
4611
- let n = () => this._update(), r = S(e, "input", n), i = S(e, "focus", n), a = S(e, "blur", n);
4685
+ let n = () => this._update(), r = C(e, "input", n), i = C(e, "focus", n), a = C(e, "blur", n);
4612
4686
  return this._disposers.push(r, i, a), this._update(), this;
4613
4687
  }
4614
4688
  destroy() {
4615
4689
  this._disposers.forEach((e) => e()), this._disposers = [];
4616
4690
  }
4617
4691
  _update() {
4618
- 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");
4692
+ let e = this.context.layoutInfo.editable, t = document.activeElement === e, n = !Br(e) && !e.querySelector("img, table, hr, .an-video-wrapper");
4619
4693
  e.classList.toggle("an-placeholder", n && !t);
4620
4694
  }
4621
4695
  }
@@ -4623,39 +4697,39 @@ var Mr = [
4623
4697
  ];
4624
4698
  //#endregion
4625
4699
  //#region src/js/core/lists.js
4626
- function Nr(e) {
4700
+ function Hr(e) {
4627
4701
  return e[e.length - 1];
4628
4702
  }
4629
- function Pr(e) {
4703
+ function Ur(e) {
4630
4704
  return e[0];
4631
4705
  }
4632
- function Fr(e, t = 1) {
4706
+ function Wr(e, t = 1) {
4633
4707
  return e.slice(0, e.length - t);
4634
4708
  }
4635
- function Ir(e, t = 1) {
4709
+ function Gr(e, t = 1) {
4636
4710
  return e.slice(t);
4637
4711
  }
4638
- function Lr(e) {
4712
+ function Kr(e) {
4639
4713
  return e.flat();
4640
4714
  }
4641
- function Rr(e) {
4715
+ function qr(e) {
4642
4716
  return [...new Set(e)];
4643
4717
  }
4644
- function zr(e, t) {
4718
+ function Jr(e, t) {
4645
4719
  let n = [];
4646
4720
  for (let r = 0; r < e.length; r += t) n.push(e.slice(r, r + t));
4647
4721
  return n;
4648
4722
  }
4649
- function Br(e, t) {
4723
+ function Yr(e, t) {
4650
4724
  return e.reduce((e, n) => {
4651
4725
  let r = t(n);
4652
4726
  return e[r] || (e[r] = []), e[r].push(n), e;
4653
4727
  }, {});
4654
4728
  }
4655
- function Vr(e, t) {
4729
+ function Xr(e, t) {
4656
4730
  return e.every(t);
4657
4731
  }
4658
- function Hr(e, t) {
4732
+ function Zr(e, t) {
4659
4733
  return e.some(t);
4660
4734
  }
4661
4735
  //#endregion
@@ -4663,7 +4737,7 @@ function Hr(e, t) {
4663
4737
  function Q() {
4664
4738
  return globalThis.navigator?.userAgent ?? "";
4665
4739
  }
4666
- var Ur = {
4740
+ var Qr = {
4667
4741
  get isChrome() {
4668
4742
  return /Chrome\//.test(Q()) && !/Edg\//.test(Q());
4669
4743
  },
@@ -4688,17 +4762,17 @@ var Ur = {
4688
4762
  get modifierKey() {
4689
4763
  return /Macintosh/.test(Q()) ? "metaKey" : "ctrlKey";
4690
4764
  }
4691
- }, Wr = { ...k }, $ = /* @__PURE__ */ new WeakMap(), Gr = {
4765
+ }, $r = { ...k }, $ = /* @__PURE__ */ new WeakMap(), ei = {
4692
4766
  create(e, t = {}) {
4693
- let n = Kr(e).map((e) => {
4767
+ let n = ti(e).map((e) => {
4694
4768
  if ($.has(e)) return $.get(e);
4695
- let n = new Sn(e, t);
4769
+ let n = new Cn(e, t);
4696
4770
  return n.initialize(), $.set(e, n), n;
4697
4771
  });
4698
4772
  return n.length === 1 ? n[0] : n;
4699
4773
  },
4700
4774
  destroy(e) {
4701
- Kr(e).forEach((e) => {
4775
+ ti(e).forEach((e) => {
4702
4776
  let t = $.get(e);
4703
4777
  t && (t.destroy(), $.delete(e));
4704
4778
  });
@@ -4714,10 +4788,10 @@ var Ur = {
4714
4788
  Object.assign(k, e);
4715
4789
  },
4716
4790
  resetDefaults() {
4717
- Object.keys(k).forEach((e) => delete k[e]), Object.assign(k, Wr);
4791
+ Object.keys(k).forEach((e) => delete k[e]), Object.assign(k, $r);
4718
4792
  },
4719
4793
  registerModule(e, t) {
4720
- yn.set(e, t);
4794
+ bn.set(e, t);
4721
4795
  },
4722
4796
  use(e, t = {}) {
4723
4797
  if (!e || typeof e.name != "string") throw TypeError("[AutumnNote] AutumnNote.use: plugin must have a string `name` property.");
@@ -4743,13 +4817,13 @@ var Ur = {
4743
4817
  buttons: Zt,
4744
4818
  version: "2.5.0"
4745
4819
  };
4746
- function Kr(e) {
4820
+ function ti(e) {
4747
4821
  return typeof e == "string" ? Array.from(document.querySelectorAll(e)) : e instanceof Element ? [e] : e instanceof NodeList || Array.isArray(e) ? Array.from(e) : [];
4748
4822
  }
4749
4823
  //#endregion
4750
4824
  //#region src/js/core.js
4751
- xn(Mr);
4825
+ Sn(Vr);
4752
4826
  //#endregion
4753
- export { Sn as Context, d as ELEMENT_NODE, yr as SUPPORTED_LANGS, f as TEXT_NODE, C as WrappedRange, D as _buttonRegistry, vt as alignCenterBtn, bt as alignJustifyBtn, _t as alignLeftBtn, yt as alignRightBtn, Vr as all, oe as ancestors, Hr as any, Yt as backColorBtn, dt as boldBtn, Zt as buttons, Kt as checklistBtn, se as children, zr as chunk, e as clamp, y as closest, ae as closestPara, Bt as codeviewBtn, Ce as collapsedRange, r as compose, b as createElement, xe as currentRange, t as debounce, Gr as default, k as defaultOptions, Xt as defaultToolbar, Cr as detectLang, It as directionBtn, jt as emojiBtn, Ur as env, Ut as findBtn, Wt as findReplaceBtn, Pr as first, Lr as flatten, Lt as fontFamilyBtn, Pt as fontSizeBtn, Jt as foreColorBtn, be as fromNativeRange, Vt as fullscreenBtn, ut as getButton, Br as groupBy, Dt as hrBtn, kn as htmlToMarkdown, Mt as iconBtn, i as identity, kt as imageBtn, Ct as indentBtn, Fr as initial, Gt as inlineCodeBtn, fe as insertAfter, re as isAnchor, v as isEditable, p as isElement, me as isEmpty, s as isFunction, ie as isImage, _ as isInline, _e as isInsideEditable, F as isKey, ee as isLi, te as isList, Rn as isMarkdown, I as isModifier, a as isNil, g as isPara, l as isPlainObject, we as isSelectionInside, o as isString, ne as isTable, m as isText, h as isVoid, ft as italicBtn, P as key, Nr as last, zt as lineHeightBtn, Ot as linkBtn, Qt as locales, ye as makeDraggable, H as markdownToHTML, c as mergeDeep, le as nextElement, pe as nodeValue, St as olBtn, S as on, wt as outdentBtn, he as outerHtml, Rt as paragraphStyleBtn, ge as placeCaret, ce as prevElement, qt as printBtn, Se as rangeFromElement, u as rect2bnd, Et as redoBtn, O as registerButton, $t as registerLocale, x as remove, Ft as removeFormatBtn, en as resolveLocale, j as sanitiseHTML, M as sanitiseUrl, Ht as shortcutsBtn, Ee as splitText, mt as strikeBtn, gt as subscriptBtn, ht as superscriptBtn, Nt as tableBtn, Ir as tail, n as throttle, ve as trapFocus, xt as ulBtn, pt as underlineBtn, Tt as undoBtn, Rr as unique, ue as unwrap, At as videoBtn, Te as withSavedRange, de as wrap };
4827
+ export { Cn as Context, d as ELEMENT_NODE, br as SUPPORTED_LANGS, f as TEXT_NODE, ye as WrappedRange, D as _buttonRegistry, vt as alignCenterBtn, bt as alignJustifyBtn, _t as alignLeftBtn, yt as alignRightBtn, Xr as all, ae as ancestors, Zr as any, Yt as backColorBtn, dt as boldBtn, Zt as buttons, Kt as checklistBtn, oe as children, Jr as chunk, e as clamp, y as closest, b as closestPara, Bt as codeviewBtn, Ce as collapsedRange, r as compose, x as createElement, xe as currentRange, t as debounce, ei as default, k as defaultOptions, Xt as defaultToolbar, wr as detectLang, It as directionBtn, jt as emojiBtn, Qr as env, Ut as findBtn, Wt as findReplaceBtn, Ur as first, Kr as flatten, Lt as fontFamilyBtn, Pt as fontSizeBtn, Jt as foreColorBtn, be as fromNativeRange, Vt as fullscreenBtn, ut as getButton, Yr as groupBy, Dt as hrBtn, An as htmlToMarkdown, Mt as iconBtn, i as identity, kt as imageBtn, Ct as indentBtn, Wr as initial, Gt as inlineCodeBtn, de as insertAfter, re as isAnchor, v as isEditable, p as isElement, pe as isEmpty, s as isFunction, ie as isImage, _ as isInline, ge as isInsideEditable, F as isKey, ee as isLi, te as isList, zn as isMarkdown, I as isModifier, a as isNil, g as isPara, l as isPlainObject, we as isSelectionInside, o as isString, ne as isTable, m as isText, h as isVoid, ft as italicBtn, P as key, Hr as last, zt as lineHeightBtn, Ot as linkBtn, Qt as locales, ve as makeDraggable, H as markdownToHTML, c as mergeDeep, ce as nextElement, fe as nodeValue, St as olBtn, C as on, wt as outdentBtn, me as outerHtml, Rt as paragraphStyleBtn, he as placeCaret, se as prevElement, qt as printBtn, Se as rangeFromElement, u as rect2bnd, Et as redoBtn, O as registerButton, $t as registerLocale, S as remove, Ft as removeFormatBtn, en as resolveLocale, j as sanitiseHTML, mn as sanitiseToBody, M as sanitiseUrl, Ht as shortcutsBtn, Ee as splitText, mt as strikeBtn, gt as subscriptBtn, ht as superscriptBtn, Nt as tableBtn, Gr as tail, n as throttle, _e as trapFocus, xt as ulBtn, pt as underlineBtn, Tt as undoBtn, qr as unique, le as unwrap, At as videoBtn, Te as withSavedRange, ue as wrap };
4754
4828
 
4755
4829
  //# sourceMappingURL=autumnnote.core.es.js.map