autumnnote 2.7.0 → 3.0.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.
@@ -36,13 +36,24 @@ function s(e) {
36
36
  function c(e, t) {
37
37
  let n = {};
38
38
  for (let t of Object.keys(e)) n[t] = Array.isArray(e[t]) ? [...e[t]] : e[t];
39
- if (l(e) && l(t)) for (let r of Object.keys(t)) l(t[r]) ? n[r] = c(l(e[r]) ? e[r] : {}, t[r]) : Array.isArray(t[r]) ? n[r] = [...t[r]] : n[r] = t[r];
39
+ if (u(e) && u(t)) for (let r of Object.keys(t)) n[r] = u(t[r]) ? c(u(e[r]) ? e[r] : {}, t[r]) : Array.isArray(t[r]) ? [...t[r]] : t[r];
40
40
  return n;
41
41
  }
42
- function l(e) {
43
- return typeof e == "object" && !!e && !Array.isArray(e);
42
+ function l(e, t) {
43
+ if (Object.is(e, t)) return !0;
44
+ if (Array.isArray(e) && Array.isArray(t)) return e.length === t.length && e.every((e, n) => l(e, t[n]));
45
+ if (u(e) && u(t)) {
46
+ let n = Object.keys(e);
47
+ return n.length === Object.keys(t).length && n.every((n) => Object.hasOwn(t, n) && l(e[n], t[n]));
48
+ }
49
+ return !1;
44
50
  }
45
51
  function u(e) {
52
+ if (typeof e != "object" || !e) return !1;
53
+ let t = Object.getPrototypeOf(e);
54
+ return t === Object.prototype || t === null;
55
+ }
56
+ function d(e) {
46
57
  return e ? {
47
58
  top: e.top,
48
59
  left: e.left,
@@ -54,8 +65,8 @@ function u(e) {
54
65
  }
55
66
  //#endregion
56
67
  //#region src/js/core/dom.js
57
- var d = 1, f = 3, p = (e) => e?.nodeType === 1, m = (e) => e?.nodeType === 3, h = (e) => p(e) && /^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/i.test(e.nodeName), g = (e) => p(e) && /^(p|div|li|h[1-6]|blockquote|td|th|pre)$/i.test(e.nodeName), ee = (e) => p(e) && /^(li)$/i.test(e.nodeName), te = (e) => p(e) && /^(ul|ol)$/i.test(e.nodeName), ne = (e) => p(e) && e.nodeName.toUpperCase() === "TABLE", _ = (e) => p(e) && /^(a|abbr|acronym|b|bdo|big|br|button|cite|code|dfn|em|i|img|input|kbd|label|map|object|output|q|s|samp|select|small|span|strong|sub|sup|textarea|time|tt|u|var)$/i.test(e.nodeName), v = (e) => p(e) && e.isContentEditable, re = (e) => p(e) && e.nodeName.toUpperCase() === "A", ie = (e) => p(e) && e.nodeName.toUpperCase() === "IMG";
58
- function y(e, t, n) {
68
+ var f = 1, p = 3, m = (e) => e?.nodeType === 1, h = (e) => e?.nodeType === 3, ee = (e) => m(e) && /^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/i.test(e.nodeName), g = (e) => m(e) && /^(p|div|li|h[1-6]|blockquote|td|th|pre)$/i.test(e.nodeName), te = (e) => m(e) && /^(li)$/i.test(e.nodeName), _ = (e) => m(e) && /^(ul|ol)$/i.test(e.nodeName), ne = (e) => m(e) && e.nodeName.toUpperCase() === "TABLE", re = (e) => m(e) && /^(a|abbr|acronym|b|bdo|big|br|button|cite|code|dfn|em|i|img|input|kbd|label|map|object|output|q|s|samp|select|small|span|strong|sub|sup|textarea|time|tt|u|var)$/i.test(e.nodeName), ie = (e) => m(e) && e.isContentEditable, ae = (e) => m(e) && e.nodeName.toUpperCase() === "A", oe = (e) => m(e) && e.nodeName.toUpperCase() === "IMG";
69
+ function v(e, t, n) {
59
70
  let r = e;
60
71
  for (; r && r !== n;) {
61
72
  if (t(r)) return r;
@@ -63,65 +74,65 @@ function y(e, t, n) {
63
74
  }
64
75
  return null;
65
76
  }
66
- function b(e, t) {
67
- return y(e, g, t);
77
+ function se(e, t) {
78
+ return v(e, g, t);
68
79
  }
69
- function ae(e, t) {
80
+ function ce(e, t) {
70
81
  let n = [], r = e.parentNode;
71
82
  for (; r && r !== t;) n.push(r), r = r.parentNode;
72
83
  return n;
73
84
  }
74
- function oe(e) {
85
+ function le(e) {
75
86
  return Array.from(e.childNodes);
76
87
  }
77
- function se(e) {
88
+ function y(e) {
78
89
  let t = e.previousSibling;
79
- for (; t && !p(t);) t = t.previousSibling;
90
+ for (; t && !m(t);) t = t.previousSibling;
80
91
  return t;
81
92
  }
82
- function ce(e) {
93
+ function ue(e) {
83
94
  let t = e.nextSibling;
84
- for (; t && !p(t);) t = t.nextSibling;
95
+ for (; t && !m(t);) t = t.nextSibling;
85
96
  return t;
86
97
  }
87
- function x(e, t = {}, n = []) {
98
+ function b(e, t = {}, n = []) {
88
99
  let r = document.createElement(e);
89
100
  for (let [e, n] of Object.entries(t)) r.setAttribute(e, n);
90
101
  for (let e of n) typeof e == "string" ? r.appendChild(document.createTextNode(e)) : r.appendChild(e);
91
102
  return r;
92
103
  }
93
- function S(e) {
104
+ function de(e) {
94
105
  e?.parentNode && e.remove();
95
106
  }
96
- function le(e) {
107
+ function fe(e) {
97
108
  let t = e.parentNode;
98
109
  if (t) {
99
110
  for (; e.firstChild;) t.insertBefore(e.firstChild, e);
100
111
  e.remove();
101
112
  }
102
113
  }
103
- function ue(e, t) {
114
+ function pe(e, t) {
104
115
  return e.parentNode.insertBefore(t, e), t.appendChild(e), t;
105
116
  }
106
- function de(e, t) {
117
+ function me(e, t) {
107
118
  t.nextSibling ? t.parentNode.insertBefore(e, t.nextSibling) : t.parentNode.appendChild(e);
108
119
  }
109
- function fe(e) {
110
- return m(e) ? e.nodeValue : e.textContent || "";
120
+ function he(e) {
121
+ return h(e) ? e.nodeValue : e.textContent || "";
111
122
  }
112
- function pe(e) {
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");
123
+ function ge(e) {
124
+ return h(e) ? !e.nodeValue : ee(e) ? !1 : e.childNodes.length === 1 && e.firstChild?.nodeName === "BR" || !e.textContent.trim() && !e.querySelector("img, video, hr, table");
114
125
  }
115
- function me(e) {
126
+ function _e(e) {
116
127
  return e.outerHTML;
117
128
  }
118
- function he(e) {
129
+ function ve(e) {
119
130
  let t = document.createRange();
120
131
  t.selectNodeContents(e), t.collapse(!1);
121
132
  let n = globalThis.getSelection();
122
133
  n && (n.removeAllRanges(), n.addRange(t));
123
134
  }
124
- function ge(e) {
135
+ function ye(e) {
125
136
  if (e?.querySelectorAll) for (let t of e.querySelectorAll("ul > ul, ul > ol, ol > ul, ol > ol")) {
126
137
  let e = t.previousElementSibling;
127
138
  if (e && e.nodeName === "LI") e.appendChild(t);
@@ -131,13 +142,13 @@ function ge(e) {
131
142
  }
132
143
  }
133
144
  }
134
- function _e(e) {
135
- return !!y(e, v);
145
+ function be(e) {
146
+ return !!v(e, ie);
136
147
  }
137
- function C(e, t, n, r) {
148
+ function x(e, t, n, r) {
138
149
  return e.addEventListener(t, n, r), () => e.removeEventListener(t, n, r);
139
150
  }
140
- function ve(e, t) {
151
+ function xe(e, t) {
141
152
  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) => {
142
153
  if (e.key === "Escape") {
143
154
  e.stopPropagation(), t?.();
@@ -151,7 +162,7 @@ function ve(e, t) {
151
162
  };
152
163
  return document.addEventListener("keydown", r), () => document.removeEventListener("keydown", r);
153
164
  }
154
- function ye(e, t) {
165
+ function Se(e, t) {
155
166
  e.style.cursor = "grab";
156
167
  let n = (n) => {
157
168
  if (n.button !== 0 || n.target.closest("button, input, select, textarea, a")) return;
@@ -171,9 +182,12 @@ function ye(e, t) {
171
182
  };
172
183
  return e.addEventListener("mousedown", n), () => e.removeEventListener("mousedown", n);
173
184
  }
185
+ function Ce(e) {
186
+ return e?.layoutInfo?.portal || document.body;
187
+ }
174
188
  //#endregion
175
189
  //#region src/js/core/range.js
176
- var w = class {
190
+ var S = class {
177
191
  constructor(e, t, n, r) {
178
192
  this.sc = e, this.so = t, this.ec = n, this.eo = r;
179
193
  }
@@ -193,10 +207,10 @@ var w = class {
193
207
  }
194
208
  commonAncestor() {
195
209
  let e = this.toNativeRange().commonAncestorContainer;
196
- return p(e) ? e : e.parentElement;
210
+ return m(e) ? e : e.parentElement;
197
211
  }
198
212
  blockNode(e) {
199
- return y(this.sc, (t) => p(t) && t !== e, e);
213
+ return v(this.sc, (t) => m(t) && t !== e, e);
200
214
  }
201
215
  toString() {
202
216
  return this.toNativeRange().toString();
@@ -209,40 +223,40 @@ var w = class {
209
223
  this.toNativeRange().insertNode(e);
210
224
  }
211
225
  };
212
- function be(e) {
213
- return new w(e.startContainer, e.startOffset, e.endContainer, e.endOffset);
226
+ function we(e) {
227
+ return new S(e.startContainer, e.startOffset, e.endContainer, e.endOffset);
214
228
  }
215
- function xe(e) {
229
+ function Te(e) {
216
230
  let t = globalThis.getSelection();
217
231
  if (!t || t.rangeCount === 0) return null;
218
232
  let n = t.getRangeAt(0);
219
- return e && !e.contains(n.commonAncestorContainer) ? null : be(n);
233
+ return e && !e.contains(n.commonAncestorContainer) ? null : we(n);
220
234
  }
221
- function Se(e) {
222
- return new w(e, 0, e, e.childNodes.length);
235
+ function Ee(e) {
236
+ return new S(e, 0, e, e.childNodes.length);
223
237
  }
224
- function Ce(e, t = 0) {
225
- return new w(e, t, e, t);
238
+ function De(e, t = 0) {
239
+ return new S(e, t, e, t);
226
240
  }
227
- function we(e) {
241
+ function Oe(e) {
228
242
  let t = globalThis.getSelection();
229
243
  return !t || t.rangeCount === 0 ? !1 : e.contains(t.getRangeAt(0).commonAncestorContainer);
230
244
  }
231
- function Te(e) {
245
+ function ke(e) {
232
246
  let t = globalThis.getSelection();
233
247
  if (!t || t.rangeCount === 0) {
234
248
  e(null);
235
249
  return;
236
250
  }
237
251
  let n = t.getRangeAt(0).cloneRange();
238
- e(be(n)), t.removeAllRanges(), t.addRange(n);
252
+ e(we(n)), t.removeAllRanges(), t.addRange(n);
239
253
  }
240
- function Ee(e, t) {
254
+ function Ae(e, t) {
241
255
  return [e, e.splitText(t)];
242
256
  }
243
257
  //#endregion
244
258
  //#region src/js/editing/insert.js
245
- function De(e) {
259
+ function je(e) {
246
260
  let t = e && e.nodeType === 1 ? e : e?.parentElement;
247
261
  for (; t;) {
248
262
  let e = t.getAttribute?.("contenteditable") ?? t.contentEditable;
@@ -252,41 +266,41 @@ function De(e) {
252
266
  }
253
267
  return null;
254
268
  }
255
- function Oe(e) {
269
+ function Me(e) {
256
270
  let t = globalThis.getSelection?.();
257
271
  if (!t || t.rangeCount === 0) return null;
258
272
  let n = t.getRangeAt(0);
259
- return e && e !== document ? e.contains(n.commonAncestorContainer) ? n : null : De(n.commonAncestorContainer) ? n : null;
273
+ return e && e !== document ? e.contains(n.commonAncestorContainer) ? n : null : je(n.commonAncestorContainer) ? n : null;
260
274
  }
261
- function ke(e) {
275
+ function Ne(e) {
262
276
  let t = globalThis.getSelection?.();
263
277
  if (!t) return;
264
278
  let n = document.createRange();
265
279
  n.setStartAfter(e), n.collapse(!0), t.removeAllRanges(), t.addRange(n);
266
280
  }
267
- function Ae(e, t) {
268
- let n = Oe(t);
281
+ function Pe(e, t) {
282
+ let n = Me(t);
269
283
  if (!n) return !1;
270
284
  let r = document.createElement("template");
271
285
  r.innerHTML = e;
272
286
  let i = r.content, a = i.lastChild;
273
- return n.deleteContents(), n.insertNode(i), a && ke(a), !0;
287
+ return n.deleteContents(), n.insertNode(i), a && Ne(a), !0;
274
288
  }
275
- function je(e, t) {
276
- let n = Oe(t);
289
+ function Fe(e, t) {
290
+ let n = Me(t);
277
291
  if (!n) return !1;
278
292
  n.deleteContents();
279
293
  let r = String(e), i = document.createDocumentFragment();
280
- !r.includes("\n") || Ne(n.startContainer, t) ? i.appendChild(document.createTextNode(r)) : r.split("\n").forEach((e, t) => {
294
+ !r.includes("\n") || Le(n.startContainer, t) ? i.appendChild(document.createTextNode(r)) : r.split("\n").forEach((e, t) => {
281
295
  t > 0 && i.appendChild(document.createElement("br")), e && i.appendChild(document.createTextNode(e));
282
296
  });
283
297
  let a = i.lastChild;
284
- return n.insertNode(i), a && ke(a), !0;
298
+ return n.insertNode(i), a && Ne(a), !0;
285
299
  }
286
- function Me(e) {
287
- return je("\n", e);
300
+ function Ie(e) {
301
+ return Fe("\n", e);
288
302
  }
289
- function Ne(e, t) {
303
+ function Le(e, t) {
290
304
  let n = e.nodeType === 1 ? e : e.parentElement;
291
305
  for (; n && n !== t;) {
292
306
  if (n.tagName === "PRE" || n.tagName === "TEXTAREA") return !0;
@@ -296,12 +310,12 @@ function Ne(e, t) {
296
310
  }
297
311
  return !1;
298
312
  }
299
- function Pe(e) {
300
- let t = Oe(e);
313
+ function Re(e) {
314
+ let t = Me(e);
301
315
  if (!t) return !1;
302
316
  let n = document.createElement("hr");
303
317
  t.deleteContents();
304
- let r = Ie(t.startContainer, e);
318
+ let r = Be(t.startContainer, e);
305
319
  r && r.parentNode ? r.parentNode.insertBefore(n, r.nextSibling) : t.insertNode(n);
306
320
  let i = n.nextElementSibling;
307
321
  if (!i || i.tagName === "HR") {
@@ -315,7 +329,7 @@ function Pe(e) {
315
329
  }
316
330
  return !0;
317
331
  }
318
- var Fe = /* @__PURE__ */ new Set([
332
+ var ze = /* @__PURE__ */ new Set([
319
333
  "P",
320
334
  "DIV",
321
335
  "H1",
@@ -328,21 +342,21 @@ var Fe = /* @__PURE__ */ new Set([
328
342
  "PRE",
329
343
  "LI"
330
344
  ]);
331
- function Ie(e, t) {
345
+ function Be(e, t) {
332
346
  let n = e.nodeType === 1 ? e : e.parentElement;
333
347
  for (; n && n !== t;) {
334
- if (Fe.has(n.tagName)) return n;
348
+ if (ze.has(n.tagName)) return n;
335
349
  n = n.parentElement;
336
350
  }
337
351
  return null;
338
352
  }
339
353
  //#endregion
340
354
  //#region src/js/editing/Style.js
341
- function T(e, t = null) {
342
- return e === "insertHTML" && Ae(String(t ?? "")) || e === "insertText" && je(String(t ?? "")) || e === "insertLineBreak" && Me() || e === "insertHorizontalRule" && Pe() ? !0 : document.execCommand(e, !1, t);
355
+ function C(e, t = null) {
356
+ return e === "insertHTML" && Pe(String(t ?? "")) || e === "insertText" && Fe(String(t ?? "")) || e === "insertLineBreak" && Ie() || e === "insertHorizontalRule" && Re() ? !0 : document.execCommand(e, !1, t);
343
357
  }
344
- var Le = () => T("bold"), Re = () => T("italic");
345
- function ze() {
358
+ var Ve = () => C("bold"), He = () => C("italic");
359
+ function Ue() {
346
360
  let e = globalThis.getSelection();
347
361
  if (!e?.rangeCount) return;
348
362
  let t = e.getRangeAt(0).commonAncestorContainer;
@@ -354,9 +368,9 @@ function ze() {
354
368
  n.remove();
355
369
  return;
356
370
  }
357
- T("underline");
371
+ C("underline");
358
372
  }
359
- function Be() {
373
+ function We() {
360
374
  let e = globalThis.getSelection();
361
375
  if (!e?.rangeCount) return;
362
376
  let t = e.getRangeAt(0).startContainer;
@@ -368,10 +382,10 @@ function Be() {
368
382
  n.remove();
369
383
  return;
370
384
  }
371
- T("strikeThrough");
385
+ C("strikeThrough");
372
386
  }
373
- var Ve = () => T("superscript"), He = () => T("subscript"), Ue = (e) => T("foreColor", e), We = (e) => T("hiliteColor", e), Ge = (e) => T("fontName", e);
374
- function Ke(e, t = document) {
387
+ var Ge = () => C("superscript"), Ke = () => C("subscript"), qe = (e) => C("foreColor", e), Je = (e) => C("hiliteColor", e), Ye = (e) => C("fontName", e);
388
+ function Xe(e, t = document) {
375
389
  let n = globalThis.getSelection(), r = !n?.rangeCount || n.getRangeAt(0).collapsed;
376
390
  if (r && n?.rangeCount > 0) {
377
391
  try {
@@ -384,7 +398,7 @@ function Ke(e, t = document) {
384
398
  } catch {}
385
399
  return;
386
400
  }
387
- T("fontSize", "7");
401
+ C("fontSize", "7");
388
402
  let i = t instanceof HTMLElement ? t : document, a = [];
389
403
  if (i.querySelectorAll("font[size=\"7\"]").forEach((t) => {
390
404
  let n = document.createElement("span");
@@ -398,11 +412,11 @@ function Ke(e, t = document) {
398
412
  } catch {}
399
413
  }
400
414
  }
401
- var qe = (e) => T("formatBlock", `<${e}>`), Je = () => T("justifyLeft"), Ye = () => T("justifyCenter"), Xe = () => T("justifyRight"), Ze = () => T("justifyFull");
402
- function Qe() {
403
- T("indent"), ge($e());
415
+ var Ze = (e) => C("formatBlock", `<${e}>`), Qe = () => C("justifyLeft"), $e = () => C("justifyCenter"), et = () => C("justifyRight"), tt = () => C("justifyFull");
416
+ function nt() {
417
+ C("indent"), ye(rt());
404
418
  }
405
- function $e() {
419
+ function rt() {
406
420
  let e = globalThis.getSelection();
407
421
  if (!e?.rangeCount) return null;
408
422
  let t = e.getRangeAt(0).commonAncestorContainer;
@@ -411,20 +425,20 @@ function $e() {
411
425
  for (let e = t; e; e = e.parentElement) (e.nodeName === "UL" || e.nodeName === "OL") && (n = e);
412
426
  return n;
413
427
  }
414
- function et() {
428
+ function it() {
415
429
  let e = globalThis.getSelection();
416
430
  if (e?.rangeCount) {
417
431
  let t = e.getRangeAt(0).commonAncestorContainer;
418
432
  t.nodeType === 3 && (t = t.parentElement);
419
433
  let n = t?.closest(".an-checklist li");
420
434
  if (n) {
421
- nt(n);
435
+ ot(n);
422
436
  return;
423
437
  }
424
438
  }
425
- tt() || T("outdent");
439
+ at() || C("outdent");
426
440
  }
427
- function tt() {
441
+ function at() {
428
442
  let e = globalThis.getSelection();
429
443
  if (!e?.rangeCount) return !1;
430
444
  let t = e.getRangeAt(0).startContainer;
@@ -443,11 +457,11 @@ function tt() {
443
457
  }
444
458
  return i.parentNode.insertBefore(n, i.nextSibling), r.children.length || r.remove(), !0;
445
459
  }
446
- function nt(e) {
460
+ function ot(e) {
447
461
  let t = e.closest(".an-checklist");
448
462
  if (!t) return;
449
463
  let n = Array.from(t.children), r = n.indexOf(e), i = n.slice(r + 1), a = document.createElement("p");
450
- for (let t of e.childNodes) t.nodeType === 1 && t.tagName === "INPUT" || a.appendChild(t.cloneNode(!0));
464
+ for (let t of e.childNodes) (t.nodeType !== 1 || t.tagName !== "INPUT") && a.appendChild(t.cloneNode(!0));
451
465
  if (a.innerHTML = a.innerHTML.replaceAll("​", ""), (!a.hasChildNodes() || !a.textContent.trim()) && (a.innerHTML = "", a.appendChild(document.createTextNode("\xA0"))), i.length > 0) {
452
466
  let e = document.createElement("ul");
453
467
  e.className = "an-checklist", i.forEach((t) => e.appendChild(t)), t.parentNode.insertBefore(e, t.nextSibling);
@@ -460,24 +474,24 @@ function nt(e) {
460
474
  n && (n.removeAllRanges(), n.addRange(e));
461
475
  } catch {}
462
476
  }
463
- function rt() {
477
+ function st() {
464
478
  let e = globalThis.getSelection();
465
479
  if (!e?.rangeCount) return null;
466
480
  let t = e.getRangeAt(0).commonAncestorContainer;
467
481
  return t.nodeType === 3 && (t = t.parentElement), t?.closest("ul, ol") || null;
468
482
  }
469
- function it(e) {
483
+ function ct(e) {
470
484
  e.classList.remove("an-checklist"), e.querySelectorAll("input[type=\"checkbox\"]").forEach((e) => e.remove());
471
485
  }
472
- function at() {
473
- let e = rt();
474
- e ? e.classList.contains("an-checklist") ? (it(e), e.tagName === "OL" && E(e, "ul")) : e.tagName === "OL" ? E(e, "ul") : T("insertUnorderedList") : T("insertUnorderedList");
486
+ function lt() {
487
+ let e = st();
488
+ e ? e.classList.contains("an-checklist") ? (ct(e), e.tagName === "OL" && w(e, "ul")) : e.tagName === "OL" ? w(e, "ul") : C("insertUnorderedList") : C("insertUnorderedList");
475
489
  }
476
- function ot() {
477
- let e = rt();
478
- e ? e.classList.contains("an-checklist") ? (it(e), E(e, "ol")) : e.tagName === "UL" ? E(e, "ol") : T("insertOrderedList") : T("insertOrderedList");
490
+ function ut() {
491
+ let e = st();
492
+ e ? e.classList.contains("an-checklist") ? (ct(e), w(e, "ol")) : e.tagName === "UL" ? w(e, "ol") : C("insertOrderedList") : C("insertOrderedList");
479
493
  }
480
- function st(e) {
494
+ function dt(e) {
481
495
  let t = globalThis.getSelection();
482
496
  if (!t || t.rangeCount === 0) return;
483
497
  let n = t.getRangeAt(0), r = /* @__PURE__ */ new Set([
@@ -520,7 +534,7 @@ function st(e) {
520
534
  t.style.lineHeight = e;
521
535
  });
522
536
  }
523
- function ct(e) {
537
+ function ft(e) {
524
538
  let t = globalThis.getSelection();
525
539
  if (!t?.rangeCount) return;
526
540
  let n = t.getRangeAt(0), r = n.commonAncestorContainer;
@@ -552,7 +566,7 @@ function ct(e) {
552
566
  }
553
567
  }
554
568
  }
555
- function lt() {
569
+ function pt() {
556
570
  let e = globalThis.getSelection();
557
571
  if (!e?.rangeCount) return !1;
558
572
  let t = e.getRangeAt(0).startContainer;
@@ -560,13 +574,13 @@ function lt() {
560
574
  let n = t?.closest("code");
561
575
  return !!(n && !n.closest("pre"));
562
576
  }
563
- function E(e, t) {
577
+ function w(e, t) {
564
578
  let n = document.createElement(t);
565
579
  for (let t of e.attributes) n.setAttribute(t.name, t.value);
566
580
  for (; e.firstChild;) n.appendChild(e.firstChild);
567
581
  return e.parentNode.replaceChild(n, e), n;
568
582
  }
569
- function ut(e) {
583
+ function mt(e) {
570
584
  e.querySelectorAll("li").forEach((e) => {
571
585
  if (!e.querySelector("input[type=\"checkbox\"]")) {
572
586
  let t = document.createElement("input");
@@ -574,34 +588,35 @@ function ut(e) {
574
588
  }
575
589
  });
576
590
  }
577
- function dt() {
591
+ function ht() {
578
592
  let e = globalThis.getSelection();
579
593
  if (!e?.rangeCount) return;
580
594
  let t = e.getRangeAt(0), n = t.commonAncestorContainer;
581
595
  n.nodeType === 3 && (n = n.parentElement);
582
596
  let r = n?.closest("ul, ol");
583
- if (r) if (r.classList.contains("an-checklist")) {
584
- if (r.parentNode) {
585
- let t = Array.from(r.children), n = null;
586
- if (t.forEach((e) => {
587
- let t = document.createElement("p");
588
- for (let n of e.childNodes) n.nodeType === 1 && n.tagName === "INPUT" || t.appendChild(n.cloneNode(!0));
589
- t.innerHTML = t.innerHTML.replaceAll("​", "").replaceAll("​", ""), (!t.hasChildNodes() || !t.textContent.trim()) && (t.innerHTML = "", t.appendChild(document.createTextNode("\xA0"))), r.before(t), n ||= t;
590
- }), r.remove(), n) {
597
+ if (r) {
598
+ if (r.classList.contains("an-checklist")) {
599
+ if (r.parentNode) {
600
+ let t = Array.from(r.children), n = null;
601
+ if (t.forEach((e) => {
602
+ let t = document.createElement("p");
603
+ for (let n of e.childNodes) (n.nodeType !== 1 || n.tagName !== "INPUT") && t.appendChild(n.cloneNode(!0));
604
+ t.innerHTML = t.innerHTML.replaceAll("​", "").replaceAll("​", ""), (!t.hasChildNodes() || !t.textContent.trim()) && (t.innerHTML = "", t.appendChild(document.createTextNode("\xA0"))), r.before(t), n ||= t;
605
+ }), r.remove(), n) {
606
+ let t = document.createRange();
607
+ t.setStart(n.firstChild || n, 0), t.collapse(!0), e.removeAllRanges(), e.addRange(t);
608
+ }
609
+ }
610
+ } else {
611
+ let t = w(r, "ul");
612
+ t.classList.add("an-checklist"), mt(t);
613
+ let n = t.querySelector("li");
614
+ if (n) {
591
615
  let t = document.createRange();
592
- t.setStart(n.firstChild || n, 0), t.collapse(!0), e.removeAllRanges(), e.addRange(t);
616
+ t.selectNodeContents(n), t.collapse(!1), e.removeAllRanges(), e.addRange(t);
593
617
  }
594
618
  }
595
619
  } else {
596
- let t = E(r, "ul");
597
- t.classList.add("an-checklist"), ut(t);
598
- let n = t.querySelector("li");
599
- if (n) {
600
- let t = document.createRange();
601
- t.selectNodeContents(n), t.collapse(!1), e.removeAllRanges(), e.addRange(t);
602
- }
603
- }
604
- else {
605
620
  let r = n?.closest("[contenteditable=\"true\"]");
606
621
  if (t.collapsed) {
607
622
  let t = /* @__PURE__ */ new Set([
@@ -667,7 +682,7 @@ function dt() {
667
682
  }
668
683
  }
669
684
  }
670
- function ft() {
685
+ function gt() {
671
686
  let e = globalThis.getSelection();
672
687
  if (!e?.rangeCount) return !1;
673
688
  let t = e.getRangeAt(0).commonAncestorContainer;
@@ -675,7 +690,7 @@ function ft() {
675
690
  }
676
691
  //#endregion
677
692
  //#region src/js/module/Buttons.js
678
- function D(e, t, n, r, i, a) {
693
+ function T(e, t, n, r, i, a) {
679
694
  return {
680
695
  name: e,
681
696
  icon: t,
@@ -685,24 +700,121 @@ function D(e, t, n, r, i, a) {
685
700
  isDisabled: a
686
701
  };
687
702
  }
688
- var O = /* @__PURE__ */ new Map();
689
- function k(e) {
703
+ var E = /* @__PURE__ */ new Map();
704
+ function D(e) {
690
705
  if (!e || typeof e.name != "string") {
691
706
  console.warn("[AutumnNote] registerButton: btnDef must have a string `name` property.");
692
707
  return;
693
708
  }
694
- O.has(e.name) && console.warn(`[AutumnNote] registerButton: overwriting existing button "${e.name}".`), O.set(e.name, e);
709
+ E.has(e.name) && console.warn(`[AutumnNote] registerButton: overwriting existing button "${e.name}".`), E.set(e.name, e);
695
710
  }
696
- function pt(e) {
697
- return O.get(e);
711
+ function _t(e) {
712
+ return E.get(e) ?? yt().get(e);
713
+ }
714
+ var vt = null;
715
+ function yt() {
716
+ return vt ??= new Map(Object.values(mn).filter((e) => e && !Array.isArray(e) && typeof e.name == "string").map((e) => [e.name, e])), vt;
717
+ }
718
+ function bt(e, t) {
719
+ let n = t?.buttons;
720
+ if (Array.isArray(n)) {
721
+ let t = n.find((t) => t?.name === e);
722
+ if (t) return t;
723
+ } else if (n && typeof n == "object" && n[e]) return {
724
+ name: e,
725
+ ...n[e]
726
+ };
727
+ return _t(e);
698
728
  }
699
- var mt = D("bold", "bold", "Bold (Ctrl+B)", () => Le(), () => document.queryCommandState("bold")), ht = D("italic", "italic", "Italic (Ctrl+I)", () => Re(), () => document.queryCommandState("italic")), gt = D("underline", "underline", "Underline (Ctrl+U)", () => ze(), () => {
729
+ var xt = /* @__PURE__ */ new Map();
730
+ function St(e, t) {
731
+ if (typeof e != "string" || typeof t != "string") {
732
+ console.warn("[AutumnNote] registerIcon: name and icon must be strings.");
733
+ return;
734
+ }
735
+ xt.set(e, t);
736
+ }
737
+ function Ct(e) {
738
+ let t = e.trim();
739
+ return t.startsWith("<") ? t : `<i class="${t.replace(/["<>&]/g, "")}" aria-hidden="true"></i>`;
740
+ }
741
+ function O(e, t) {
742
+ let n = e?.icons;
743
+ for (let e of t) {
744
+ if (!e) continue;
745
+ let t = n && typeof n[e] == "string" ? n[e] : xt.get(e);
746
+ if (typeof t == "string" && t.trim()) return Ct(t);
747
+ }
748
+ return null;
749
+ }
750
+ var wt = [
751
+ "8px",
752
+ "10px",
753
+ "11px",
754
+ "12px",
755
+ "13px",
756
+ "14px",
757
+ "16px",
758
+ "18px",
759
+ "20px",
760
+ "24px",
761
+ "28px",
762
+ "32px",
763
+ "36px",
764
+ "48px",
765
+ "72px"
766
+ ], Tt = [
767
+ "1.0",
768
+ "1.15",
769
+ "1.5",
770
+ "1.75",
771
+ "2.0",
772
+ "2.5",
773
+ "3.0"
774
+ ], Et = [
775
+ {
776
+ value: "p",
777
+ label: "Normal"
778
+ },
779
+ {
780
+ value: "h1",
781
+ label: "H1"
782
+ },
783
+ {
784
+ value: "h2",
785
+ label: "H2"
786
+ },
787
+ {
788
+ value: "h3",
789
+ label: "H3"
790
+ },
791
+ {
792
+ value: "h4",
793
+ label: "H4"
794
+ },
795
+ {
796
+ value: "h5",
797
+ label: "H5"
798
+ },
799
+ {
800
+ value: "h6",
801
+ label: "H6"
802
+ },
803
+ {
804
+ value: "blockquote",
805
+ label: "Quote"
806
+ },
807
+ {
808
+ value: "pre",
809
+ label: "Code"
810
+ }
811
+ ], Dt = T("bold", "bold", "Bold (Ctrl+B)", () => Ve(), () => document.queryCommandState("bold")), Ot = T("italic", "italic", "Italic (Ctrl+I)", () => He(), () => document.queryCommandState("italic")), kt = T("underline", "underline", "Underline (Ctrl+U)", () => Ue(), () => {
700
812
  if (document.queryCommandState("underline")) return !0;
701
813
  let e = globalThis.getSelection();
702
814
  if (!e?.rangeCount) return !1;
703
815
  let t = e.getRangeAt(0).startContainer;
704
816
  return t.nodeType === 3 && (t = t.parentElement), !!t?.closest("u");
705
- }), _t = D("strikethrough", "strikethrough", "Strikethrough", () => Be(), () => document.queryCommandState("strikeThrough")), vt = D("superscript", "superscript", "Superscript", () => Ve(), () => document.queryCommandState("superscript")), yt = D("subscript", "subscript", "Subscript", () => He(), () => document.queryCommandState("subscript")), bt = D("alignLeft", "align-left", "Align Left", () => Je()), xt = D("alignCenter", "align-center", "Align Center", () => Ye()), St = D("alignRight", "align-right", "Align Right", () => Xe()), Ct = D("alignJustify", "align-justify", "Justify", () => Ze()), wt = D("ul", "list-ul", "Unordered List", () => at()), Tt = D("ol", "list-ol", "Ordered List", () => ot()), Et = D("indent", "indent", "Indent", () => Qe()), Dt = D("outdent", "outdent", "Outdent", () => et()), Ot = D("undo", "undo", "Undo (Ctrl+Z)", (e) => e.invoke("editor.undo"), void 0, (e) => !e.invoke("editor.canUndo")), kt = D("redo", "redo", "Redo (Ctrl+Y)", (e) => e.invoke("editor.redo"), void 0, (e) => !e.invoke("editor.canRedo")), At = D("hr", "minus", "Horizontal Rule", () => T("insertHorizontalRule")), jt = D("link", "link", "Insert Link", (e) => e.invoke("linkDialog.show")), Mt = D("image", "image", "Insert Image", (e) => e.invoke("imageDialog.show")), Nt = D("video", "video", "Insert Video", (e) => e.invoke("videoDialog.show")), Pt = D("emoji", "emoji", "Insert Emoji", (e) => e.invoke("emojiDialog.show")), Ft = D("icon", "icon", "Insert FA Icon", (e) => e.invoke("iconDialog.show")), It = {
817
+ }), At = T("strikethrough", "strikethrough", "Strikethrough", () => We(), () => document.queryCommandState("strikeThrough")), jt = T("superscript", "superscript", "Superscript", () => Ge(), () => document.queryCommandState("superscript")), Mt = T("subscript", "subscript", "Subscript", () => Ke(), () => document.queryCommandState("subscript")), Nt = T("alignLeft", "align-left", "Align Left", () => Qe()), Pt = T("alignCenter", "align-center", "Align Center", () => $e()), Ft = T("alignRight", "align-right", "Align Right", () => et()), It = T("alignJustify", "align-justify", "Justify", () => tt()), Lt = T("ul", "list-ul", "Unordered List", () => lt()), Rt = T("ol", "list-ol", "Ordered List", () => ut()), zt = T("indent", "indent", "Indent", () => nt()), Bt = T("outdent", "outdent", "Outdent", () => it()), Vt = T("undo", "undo", "Undo (Ctrl+Z)", (e) => e.invoke("editor.undo"), void 0, (e) => !e.invoke("editor.canUndo")), Ht = T("redo", "redo", "Redo (Ctrl+Y)", (e) => e.invoke("editor.redo"), void 0, (e) => !e.invoke("editor.canRedo")), Ut = T("hr", "minus", "Horizontal Rule", () => C("insertHorizontalRule")), Wt = T("link", "link", "Insert Link", (e) => e.invoke("linkDialog.show")), Gt = T("image", "image", "Insert Image", (e) => e.invoke("imageDialog.show")), Kt = T("video", "video", "Insert Video", (e) => e.invoke("videoDialog.show")), qt = T("emoji", "emoji", "Insert Emoji", (e) => e.invoke("emojiDialog.show")), Jt = T("icon", "icon", "Insert FA Icon", (e) => e.invoke("iconDialog.show")), Yt = {
706
818
  name: "table",
707
819
  type: "grid",
708
820
  icon: "table",
@@ -710,30 +822,14 @@ var mt = D("bold", "bold", "Bold (Ctrl+B)", () => Le(), () => document.queryComm
710
822
  action: (e, t, n) => {
711
823
  e.invoke("editor.insertTable", n, t), e.invoke("editor.afterCommand");
712
824
  }
713
- }, Lt = {
825
+ }, Xt = {
714
826
  name: "fontSize",
715
827
  type: "select",
716
828
  tooltip: "Font Size",
717
829
  placeholder: "Size",
718
830
  selectClass: "an-select-narrow",
719
- items: [
720
- "8px",
721
- "10px",
722
- "11px",
723
- "12px",
724
- "13px",
725
- "14px",
726
- "16px",
727
- "18px",
728
- "20px",
729
- "24px",
730
- "28px",
731
- "32px",
732
- "36px",
733
- "48px",
734
- "72px"
735
- ],
736
- action: (e, t) => Ke(t, e.layoutInfo.editable),
831
+ items: wt,
832
+ action: (e, t) => Xe(t, e.layoutInfo.editable),
737
833
  getValue: (e) => {
738
834
  try {
739
835
  let t = globalThis.getSelection();
@@ -749,14 +845,14 @@ var mt = D("bold", "bold", "Bold (Ctrl+B)", () => Le(), () => document.queryComm
749
845
  return "";
750
846
  }
751
847
  }
752
- }, Rt = D("removeFormat", "remove-format", "Remove Format", () => T("removeFormat")), zt = D("direction", "direction", "Toggle Text Direction (LTR / RTL)", (e) => {
848
+ }, Zt = T("removeFormat", "remove-format", "Remove Format", () => C("removeFormat")), Qt = T("direction", "direction", "Toggle Text Direction (LTR / RTL)", (e) => {
753
849
  let t = e.layoutInfo.editable, n = (t.getAttribute("dir") || "ltr") === "ltr" ? "rtl" : "ltr";
754
850
  t.setAttribute("dir", n), t.style.textAlign = n === "rtl" ? "right" : "left", e.invoke("editor.afterCommand");
755
- }), Bt = {
851
+ }), $t = {
756
852
  name: "fontFamily",
757
853
  type: "select",
758
854
  tooltip: "Font Family",
759
- action: (e, t) => Ge(t),
855
+ action: (e, t) => Ye(t),
760
856
  getValue: () => {
761
857
  try {
762
858
  return document.queryCommandValue("fontName") || "";
@@ -764,51 +860,14 @@ var mt = D("bold", "bold", "Bold (Ctrl+B)", () => Le(), () => document.queryComm
764
860
  return "";
765
861
  }
766
862
  }
767
- }, Vt = {
863
+ }, en = {
768
864
  name: "paragraphStyle",
769
865
  type: "select",
770
866
  tooltip: "Paragraph Style",
771
867
  placeholder: "Style",
772
868
  selectClass: "an-select-style",
773
- items: [
774
- {
775
- value: "p",
776
- label: "Normal"
777
- },
778
- {
779
- value: "h1",
780
- label: "H1"
781
- },
782
- {
783
- value: "h2",
784
- label: "H2"
785
- },
786
- {
787
- value: "h3",
788
- label: "H3"
789
- },
790
- {
791
- value: "h4",
792
- label: "H4"
793
- },
794
- {
795
- value: "h5",
796
- label: "H5"
797
- },
798
- {
799
- value: "h6",
800
- label: "H6"
801
- },
802
- {
803
- value: "blockquote",
804
- label: "Quote"
805
- },
806
- {
807
- value: "pre",
808
- label: "Code"
809
- }
810
- ],
811
- action: (e, t) => qe(t),
869
+ items: Et,
870
+ action: (e, t) => Ze(t),
812
871
  getValue: () => {
813
872
  try {
814
873
  let e = document.queryCommandValue("formatBlock").toLowerCase().replace(/[<>]/g, "");
@@ -817,22 +876,14 @@ var mt = D("bold", "bold", "Bold (Ctrl+B)", () => Le(), () => document.queryComm
817
876
  return "";
818
877
  }
819
878
  }
820
- }, Ht = {
879
+ }, tn = {
821
880
  name: "lineHeight",
822
881
  type: "select",
823
882
  tooltip: "Line Height",
824
883
  placeholder: "↕ Line",
825
884
  selectClass: "an-select-narrow",
826
- items: [
827
- "1.0",
828
- "1.15",
829
- "1.5",
830
- "1.75",
831
- "2.0",
832
- "2.5",
833
- "3.0"
834
- ],
835
- action: (e, t) => st(t),
885
+ items: Tt,
886
+ action: (e, t) => dt(t),
836
887
  getValue: () => {
837
888
  try {
838
889
  let e = globalThis.getSelection();
@@ -858,116 +909,117 @@ var mt = D("bold", "bold", "Bold (Ctrl+B)", () => Le(), () => document.queryComm
858
909
  return "";
859
910
  }
860
911
  }
861
- }, Ut = D("codeview", "code", "HTML Code View", (e) => e.invoke("codeview.toggle"), (e) => e.invoke("codeview.isActive")), Wt = D("fullscreen", "expand", "Fullscreen", (e) => e.invoke("fullscreen.toggle"), (e) => e.invoke("fullscreen.isActive")), Gt = D("shortcuts", "keyboard", "Keyboard Shortcuts (Ctrl+Shift+/)", (e) => e.invoke("shortcutsDialog.show")), Kt = D("find", "search", "Find (Ctrl+F)", (e) => e.invoke("findReplace.show", "find")), qt = D("findReplace", "find-replace", "Find & Replace (Ctrl+H)", (e) => e.invoke("findReplace.show", "replace")), Jt = D("inlineCode", "inline-code", "Inline Code (Ctrl+`)", (e) => e.invoke("editor.inlineCode"), () => lt()), Yt = D("checklist", "checklist", "Checklist", (e) => e.invoke("editor.toggleChecklist"), () => ft()), Xt = D("print", "print", "Print", (e) => e.invoke("editor.print")), Zt = {
912
+ }, nn = T("codeview", "code", "HTML Code View", (e) => e.invoke("codeview.toggle"), (e) => e.invoke("codeview.isActive")), rn = T("fullscreen", "expand", "Fullscreen", (e) => e.invoke("fullscreen.toggle"), (e) => e.invoke("fullscreen.isActive")), an = T("shortcuts", "keyboard", "Keyboard Shortcuts (Ctrl+Shift+/)", (e) => e.invoke("shortcutsDialog.show")), on = T("find", "search", "Find (Ctrl+F)", (e) => e.invoke("findReplace.show", "find")), sn = T("findReplace", "find-replace", "Find & Replace (Ctrl+H)", (e) => e.invoke("findReplace.show", "replace")), cn = T("inlineCode", "inline-code", "Inline Code (Ctrl+`)", (e) => e.invoke("editor.inlineCode"), () => pt()), ln = T("checklist", "checklist", "Checklist", (e) => e.invoke("editor.toggleChecklist"), () => gt()), un = T("print", "print", "Print", (e) => e.invoke("editor.print")), dn = {
862
913
  name: "foreColor",
863
914
  type: "colorpicker",
864
915
  icon: "foreColor",
865
916
  tooltip: "Text Color",
866
917
  defaultColor: "#e11d48",
867
- action: (e, t) => Ue(t)
868
- }, Qt = {
918
+ action: (e, t) => qe(t)
919
+ }, fn = {
869
920
  name: "backColor",
870
921
  type: "colorpicker",
871
922
  icon: "backColor",
872
923
  tooltip: "Highlight Color",
873
924
  defaultColor: "#fbbf24",
874
- action: (e, t) => We(t)
875
- }, $t = [
876
- [
877
- Vt,
878
- Bt,
879
- Lt,
880
- Ht
881
- ],
882
- [Ot, kt],
925
+ action: (e, t) => Je(t)
926
+ }, pn = [
883
927
  [
884
- mt,
885
- ht,
886
- gt,
887
- _t,
888
- Jt
889
- ],
890
- [vt, yt],
891
- [Zt, Qt],
892
- [
893
- bt,
894
- xt,
895
- St,
896
- Ct
928
+ en,
929
+ $t,
930
+ Xt,
931
+ tn
897
932
  ],
933
+ [Vt, Ht],
898
934
  [
899
- wt,
900
- Tt,
901
- Yt,
902
- Et,
903
- Dt
935
+ Dt,
936
+ Ot,
937
+ kt,
938
+ At,
939
+ cn
904
940
  ],
941
+ [jt, Mt],
942
+ [dn, fn],
905
943
  [
906
- At,
907
- jt,
908
- Mt,
909
944
  Nt,
910
- It,
911
945
  Pt,
912
- Ft
946
+ Ft,
947
+ It
913
948
  ],
914
949
  [
950
+ Lt,
915
951
  Rt,
952
+ ln,
953
+ zt,
954
+ Bt
955
+ ],
956
+ [
916
957
  Ut,
917
958
  Wt,
959
+ Gt,
918
960
  Kt,
919
- Xt,
920
- Gt
961
+ Yt,
962
+ qt,
963
+ Jt
964
+ ],
965
+ [
966
+ Zt,
967
+ nn,
968
+ rn,
969
+ on,
970
+ un,
971
+ an
921
972
  ]
922
- ], en = {
923
- boldBtn: mt,
924
- italicBtn: ht,
925
- underlineBtn: gt,
926
- strikeBtn: _t,
927
- superscriptBtn: vt,
928
- subscriptBtn: yt,
929
- alignLeftBtn: bt,
930
- alignCenterBtn: xt,
931
- alignRightBtn: St,
932
- alignJustifyBtn: Ct,
933
- ulBtn: wt,
934
- olBtn: Tt,
935
- indentBtn: Et,
936
- outdentBtn: Dt,
937
- undoBtn: Ot,
938
- redoBtn: kt,
939
- hrBtn: At,
940
- linkBtn: jt,
941
- imageBtn: Mt,
942
- videoBtn: Nt,
943
- emojiBtn: Pt,
944
- iconBtn: Ft,
945
- tableBtn: It,
946
- fontSizeBtn: Lt,
947
- removeFormatBtn: Rt,
948
- directionBtn: zt,
949
- fontFamilyBtn: Bt,
950
- paragraphStyleBtn: Vt,
951
- lineHeightBtn: Ht,
952
- codeviewBtn: Ut,
953
- fullscreenBtn: Wt,
954
- shortcutsBtn: Gt,
955
- findBtn: Kt,
956
- findReplaceBtn: qt,
957
- inlineCodeBtn: Jt,
958
- checklistBtn: Yt,
959
- printBtn: Xt,
960
- foreColorBtn: Zt,
961
- backColorBtn: Qt,
962
- defaultToolbar: $t
963
- }, A = {
973
+ ], mn = {
974
+ boldBtn: Dt,
975
+ italicBtn: Ot,
976
+ underlineBtn: kt,
977
+ strikeBtn: At,
978
+ superscriptBtn: jt,
979
+ subscriptBtn: Mt,
980
+ alignLeftBtn: Nt,
981
+ alignCenterBtn: Pt,
982
+ alignRightBtn: Ft,
983
+ alignJustifyBtn: It,
984
+ ulBtn: Lt,
985
+ olBtn: Rt,
986
+ indentBtn: zt,
987
+ outdentBtn: Bt,
988
+ undoBtn: Vt,
989
+ redoBtn: Ht,
990
+ hrBtn: Ut,
991
+ linkBtn: Wt,
992
+ imageBtn: Gt,
993
+ videoBtn: Kt,
994
+ emojiBtn: qt,
995
+ iconBtn: Jt,
996
+ tableBtn: Yt,
997
+ fontSizeBtn: Xt,
998
+ removeFormatBtn: Zt,
999
+ directionBtn: Qt,
1000
+ fontFamilyBtn: $t,
1001
+ paragraphStyleBtn: en,
1002
+ lineHeightBtn: tn,
1003
+ codeviewBtn: nn,
1004
+ fullscreenBtn: rn,
1005
+ shortcutsBtn: an,
1006
+ findBtn: on,
1007
+ findReplaceBtn: sn,
1008
+ inlineCodeBtn: cn,
1009
+ checklistBtn: ln,
1010
+ printBtn: un,
1011
+ foreColorBtn: dn,
1012
+ backColorBtn: fn,
1013
+ defaultToolbar: pn
1014
+ }, k = {
964
1015
  placeholder: "",
965
1016
  height: 200,
966
1017
  minHeight: 100,
967
1018
  maxHeight: 0,
968
1019
  focus: !1,
969
1020
  resizable: !0,
970
- toolbar: $t,
1021
+ statusbar: !0,
1022
+ toolbar: pn,
971
1023
  useBootstrap: !1,
972
1024
  toolbarButtonClass: "btn btn-sm btn-light",
973
1025
  useFontAwesome: !0,
@@ -989,6 +1041,9 @@ var mt = D("bold", "bold", "Bold (Ctrl+B)", () => Le(), () => document.queryComm
989
1041
  stickyToolbar: !1,
990
1042
  stickyToolbarOffset: 0,
991
1043
  theme: "light",
1044
+ themeVars: null,
1045
+ zIndexOffset: 0,
1046
+ popupContainer: null,
992
1047
  codeHighlight: !0,
993
1048
  codeHighlightCDN: "https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0",
994
1049
  cspNonce: "",
@@ -996,9 +1051,23 @@ var mt = D("bold", "bold", "Bold (Ctrl+B)", () => Le(), () => document.queryComm
996
1051
  externalAssetReferrerPolicy: "no-referrer",
997
1052
  markdownPaste: !0,
998
1053
  historyLimit: 100,
999
- historyMaxBytes: 10 * 1024 * 1024,
1054
+ historyMaxBytes: 10485760,
1000
1055
  defaultFontFamily: "Arial",
1001
1056
  defaultFontSize: "14px",
1057
+ fontSizes: [...wt],
1058
+ lineHeights: [...Tt],
1059
+ paragraphStyles: Et.map((e) => ({ ...e })),
1060
+ colorPalette: null,
1061
+ icons: null,
1062
+ buttons: null,
1063
+ keyMap: null,
1064
+ linkDefaults: {
1065
+ openInNewTab: !1,
1066
+ rel: "noopener noreferrer",
1067
+ defaultProtocol: "https://"
1068
+ },
1069
+ videoProviders: null,
1070
+ iframeHosts: null,
1002
1071
  fontFamilies: [
1003
1072
  "Arial",
1004
1073
  "Arial Black",
@@ -1027,6 +1096,7 @@ var mt = D("bold", "bold", "Bold (Ctrl+B)", () => Le(), () => document.queryComm
1027
1096
  onPaste: null,
1028
1097
  onPasteError: null,
1029
1098
  onDestroy: null,
1099
+ onBeforeCommand: null,
1030
1100
  onCharLimitReached: null,
1031
1101
  onWordLimitReached: null,
1032
1102
  focusColor: null,
@@ -1041,7 +1111,7 @@ var mt = D("bold", "bold", "Bold (Ctrl+B)", () => Le(), () => document.queryComm
1041
1111
  collaborationAdapter: null,
1042
1112
  imageProcessor: null,
1043
1113
  blockIds: !1,
1044
- maxPasteSize: 5 * 1024 * 1024,
1114
+ maxPasteSize: 5242880,
1045
1115
  minImageSize: 20,
1046
1116
  bubbleToolbar: !1,
1047
1117
  bubbleToolbarItems: [
@@ -1053,8 +1123,9 @@ var mt = D("bold", "bold", "Bold (Ctrl+B)", () => Le(), () => document.queryComm
1053
1123
  "hiliteColor",
1054
1124
  "removeFormat"
1055
1125
  ],
1126
+ contextMenu: null,
1056
1127
  mention: null
1057
- }, j = {
1128
+ }, A = {
1058
1129
  toolbar: {
1059
1130
  bold: "Bold (Ctrl+B)",
1060
1131
  italic: "Italic (Ctrl+I)",
@@ -1204,6 +1275,8 @@ var mt = D("bold", "bold", "Bold (Ctrl+B)", () => Le(), () => document.queryComm
1204
1275
  replaceAllBtn: "Replace All",
1205
1276
  noResults: "No results",
1206
1277
  useRegex: "Use Regular Expression",
1278
+ prevMatch: "Previous (Shift+Enter)",
1279
+ nextMatch: "Next (Enter)",
1207
1280
  close: "×"
1208
1281
  },
1209
1282
  autoSaveRestore: {
@@ -1216,6 +1289,7 @@ var mt = D("bold", "bold", "Bold (Ctrl+B)", () => Le(), () => document.queryComm
1216
1289
  title: "Keyboard Shortcuts",
1217
1290
  ariaLabel: "Keyboard Shortcuts",
1218
1291
  close: "Close",
1292
+ customCategory: "Custom",
1219
1293
  shortcuts: [
1220
1294
  {
1221
1295
  category: "Text Formatting",
@@ -1319,6 +1393,12 @@ var mt = D("bold", "bold", "Bold (Ctrl+B)", () => Le(), () => document.queryComm
1319
1393
  chars: (e) => `Chars: ${e}`,
1320
1394
  charsLimit: (e, t) => `Chars: ${e}/${t}`
1321
1395
  },
1396
+ a11y: {
1397
+ editor: "Rich text editor",
1398
+ toolbar: "Editor toolbar",
1399
+ statistics: "Editor statistics",
1400
+ tableSize: "Select table size"
1401
+ },
1322
1402
  tooltips: {
1323
1403
  link: {
1324
1404
  ariaLabel: "Link actions",
@@ -1421,23 +1501,23 @@ var mt = D("bold", "bold", "Bold (Ctrl+B)", () => Le(), () => document.queryComm
1421
1501
  table: "Table",
1422
1502
  image: "Image"
1423
1503
  }
1424
- }, tn = { en: j };
1425
- function nn(e, t) {
1504
+ }, hn = { en: A };
1505
+ function gn(e, t) {
1426
1506
  if (typeof e != "string" || !e) throw TypeError("[AutumnNote] registerLocale: code must be a non-empty string.");
1427
1507
  if (!t || typeof t != "object") throw TypeError(`[AutumnNote] registerLocale: locale for "${e}" must be an object.`);
1428
- tn[e] = t;
1508
+ hn[e] = t;
1429
1509
  }
1430
- function rn(e) {
1431
- if (!e || e === "en") return j;
1510
+ function _n(e) {
1511
+ if (!e || e === "en") return A;
1432
1512
  if (typeof e == "string") {
1433
- let t = tn[e];
1434
- return t ? c(c({}, j), t) : (console.warn(`[AutumnNote] Locale "${e}" is not registered, falling back to English. Import it first: import { ${e} } from 'autumnnote/i18n/${e}'; AutumnNote.registerLocale('${e}', ${e});`), j);
1513
+ let t = hn[e];
1514
+ return t ? c(c({}, A), t) : (console.warn(`[AutumnNote] Locale "${e}" is not registered, falling back to English. Import it first: import { ${e} } from 'autumnnote/i18n/${e}'; AutumnNote.registerLocale('${e}', ${e});`), A);
1435
1515
  }
1436
- return typeof e == "object" ? c(c({}, j), e) : j;
1516
+ return typeof e == "object" ? c(c({}, A), e) : A;
1437
1517
  }
1438
1518
  //#endregion
1439
1519
  //#region src/js/core/sanitise.js
1440
- var an = [
1520
+ var vn = [
1441
1521
  "script",
1442
1522
  "style",
1443
1523
  "iframe",
@@ -1460,7 +1540,7 @@ var an = [
1460
1540
  "mglyph",
1461
1541
  "malignmark",
1462
1542
  "annotation-xml"
1463
- ], on = /* @__PURE__ */ new Set(["button"]), sn = [
1543
+ ], yn = /* @__PURE__ */ new Set(["button"]), bn = [
1464
1544
  "href",
1465
1545
  "src",
1466
1546
  "action",
@@ -1469,11 +1549,11 @@ var an = [
1469
1549
  "poster",
1470
1550
  "background",
1471
1551
  "srcset"
1472
- ], cn = /* @__PURE__ */ new Set([
1552
+ ], xn = /* @__PURE__ */ new Set([
1473
1553
  "poster",
1474
1554
  "background",
1475
1555
  "srcset"
1476
- ]), ln = /* @__PURE__ */ new Set(["ping"]), un = /* @__PURE__ */ new Set([
1556
+ ]), Sn = /* @__PURE__ */ new Set(["ping"]), Cn = /* @__PURE__ */ new Set([
1477
1557
  "color",
1478
1558
  "background-color",
1479
1559
  "font-size",
@@ -1489,41 +1569,41 @@ var an = [
1489
1569
  "border-color",
1490
1570
  "padding",
1491
1571
  "white-space"
1492
- ]), dn = /url\s*\(|image-set\s*\(|src\s*\(|expression\s*\(|@import|javascript:|vbscript:|behavior\s*:|-moz-binding/i, fn = /* @__PURE__ */ new Set([
1572
+ ]), wn = /url\s*\(|image-set\s*\(|src\s*\(|expression\s*\(|@import|javascript:|vbscript:|behavior\s*:|-moz-binding/i, Tn = /* @__PURE__ */ new Set([
1493
1573
  "www.youtube.com",
1494
1574
  "youtube.com",
1495
1575
  "m.youtube.com",
1496
1576
  "www.youtube-nocookie.com",
1497
1577
  "youtube-nocookie.com",
1498
1578
  "player.vimeo.com"
1499
- ]), pn = /* @__PURE__ */ new Set([
1579
+ ]), En = /* @__PURE__ */ new Set([
1500
1580
  "http:",
1501
1581
  "https:",
1502
1582
  "mailto:",
1503
1583
  "tel:"
1504
- ]), mn = /* @__PURE__ */ new Set([
1584
+ ]), Dn = /* @__PURE__ */ new Set([
1505
1585
  "http:",
1506
1586
  "https:",
1507
1587
  "blob:"
1508
- ]), hn = /^data:image\/(?:png|jpe?g|gif|webp|avif|bmp);base64,[a-z0-9+/=\s]+$/i, gn = "https://autumnnote.invalid/";
1509
- function M(e, t) {
1510
- return _n(e, t).innerHTML;
1588
+ ]), On = /^data:image\/(?:png|jpe?g|gif|webp|avif|bmp);base64,[a-z0-9+/=\s]+$/i, kn = "https://autumnnote.invalid/";
1589
+ function j(e, t) {
1590
+ return An(e, t).innerHTML;
1511
1591
  }
1512
- function _n(e, { allowIframes: t = !1 } = {}) {
1513
- let n = new DOMParser().parseFromString(`<body>${e || ""}</body>`, "text/html"), r = Array.from(n.querySelectorAll("*")), i = new Set(t ? an.filter((e) => e !== "iframe") : an);
1514
- for (let e of r) {
1592
+ function An(e, { allowIframes: t = !1, iframeHosts: n = null } = {}) {
1593
+ let r = new DOMParser().parseFromString(`<body>${e || ""}</body>`, "text/html"), i = Nn(n), a = Array.from(r.querySelectorAll("*")), o = new Set(t ? vn.filter((e) => e !== "iframe") : vn);
1594
+ for (let e of a) {
1515
1595
  let t = e.tagName.toLowerCase();
1516
- if (on.has(t)) {
1596
+ if (yn.has(t)) {
1517
1597
  e.replaceWith(...e.childNodes);
1518
1598
  continue;
1519
1599
  }
1520
- if (i.has(t)) {
1600
+ if (o.has(t)) {
1521
1601
  e.remove();
1522
1602
  continue;
1523
1603
  }
1524
1604
  if (t === "iframe") {
1525
1605
  let t = e.getAttribute("src");
1526
- if (!t || !bn(t)) {
1606
+ if (!t || !Pn(t, i)) {
1527
1607
  e.remove();
1528
1608
  continue;
1529
1609
  }
@@ -1534,22 +1614,22 @@ function _n(e, { allowIframes: t = !1 } = {}) {
1534
1614
  continue;
1535
1615
  }
1536
1616
  if (t.name === "style") {
1537
- let n = vn(t.value);
1617
+ let n = jn(t.value);
1538
1618
  n ? e.setAttribute("style", n) : e.removeAttribute("style");
1539
1619
  continue;
1540
1620
  }
1541
- if (ln.has(t.name)) {
1621
+ if (Sn.has(t.name)) {
1542
1622
  e.removeAttribute(t.name);
1543
1623
  continue;
1544
1624
  }
1545
- if (sn.includes(t.name)) {
1546
- let n = t.value.trim(), r = cn.has(t.name) || t.name === "src" && [
1625
+ if (bn.includes(t.name)) {
1626
+ let n = t.value.trim(), r = xn.has(t.name) || t.name === "src" && [
1547
1627
  "IMG",
1548
1628
  "VIDEO",
1549
1629
  "AUDIO",
1550
1630
  "SOURCE"
1551
1631
  ].includes(e.tagName), i = e.tagName === "IMG";
1552
- if (!(t.name === "srcset" ? yn(n, { allowData: i }) : xn(n, {
1632
+ if (!(t.name === "srcset" ? Mn(n, { allowData: i }) : In(n, {
1553
1633
  media: r,
1554
1634
  allowData: i
1555
1635
  }))) {
@@ -1562,71 +1642,87 @@ function _n(e, { allowIframes: t = !1 } = {}) {
1562
1642
  e.removeAttribute(t.name);
1563
1643
  continue;
1564
1644
  }
1565
- t.name === "src" && !bn(t.value) && e.removeAttribute(t.name);
1645
+ t.name === "src" && !Pn(t.value, i) && e.removeAttribute(t.name);
1566
1646
  }
1567
1647
  }
1568
- 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();
1569
- else for (let t of Array.from(e.attributes)) [
1570
- "type",
1571
- "checked",
1572
- "contenteditable"
1573
- ].includes(t.name) || e.removeAttribute(t.name);
1648
+ if (t === "a" && e.getAttribute("target") === "_blank" && e.setAttribute("rel", "noopener noreferrer"), t === "input") {
1649
+ if (e.closest("ul.an-checklist") === null || e.closest("li") === null || e.getAttribute("type") !== "checkbox") e.remove();
1650
+ else for (let t of Array.from(e.attributes)) [
1651
+ "type",
1652
+ "checked",
1653
+ "contenteditable"
1654
+ ].includes(t.name) || e.removeAttribute(t.name);
1655
+ }
1574
1656
  }
1575
- return n.body;
1657
+ return r.body;
1576
1658
  }
1577
- function vn(e) {
1659
+ function jn(e) {
1578
1660
  let t = [];
1579
1661
  for (let n of (e || "").split(";")) {
1580
1662
  let e = n.indexOf(":");
1581
1663
  if (e === -1) continue;
1582
1664
  let r = n.slice(0, e).trim().toLowerCase(), i = n.slice(e + 1).trim();
1583
- !r || !i || un.has(r) && (dn.test(i) || t.push(`${r}: ${i}`));
1665
+ !r || !i || Cn.has(r) && (wn.test(i) || t.push(`${r}: ${i}`));
1584
1666
  }
1585
1667
  return t.join("; ");
1586
1668
  }
1587
- function yn(e, { allowData: t = !1 } = {}) {
1669
+ function Mn(e, { allowData: t = !1 } = {}) {
1588
1670
  let n = (e || "").trim().split(/\s+/).filter(Boolean);
1589
1671
  for (let e of n) {
1590
1672
  if (/^[\d.]+[xw],?$/i.test(e)) continue;
1591
1673
  let n = e.replace(/,+$/, "");
1592
- if (n && !xn(n, {
1674
+ if (n && !In(n, {
1593
1675
  media: !0,
1594
1676
  allowData: t
1595
1677
  })) return !1;
1596
1678
  }
1597
1679
  return !0;
1598
1680
  }
1599
- function bn(e) {
1600
- let t = (e || "").trim();
1601
- if (!t || t.startsWith("//") || t.startsWith("/")) return !1;
1681
+ function Nn(e) {
1682
+ let t = /* @__PURE__ */ new Set();
1683
+ if (!e || typeof e[Symbol.iterator] != "function" || typeof e == "string") return t;
1684
+ for (let n of e) {
1685
+ let e = typeof n == "string" ? n.trim().toLowerCase() : "";
1686
+ /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)+$/.test(e) ? t.add(e) : console.warn(`[AutumnNote] iframeHosts: ignoring "${n}" — use a bare hostname such as "player.example.com".`);
1687
+ }
1688
+ return t;
1689
+ }
1690
+ function Pn(e, t) {
1691
+ let n = (e || "").trim();
1692
+ if (!n || n.startsWith("//") || n.startsWith("/")) return !1;
1602
1693
  try {
1603
- let e = new URL(t);
1604
- return e.protocol === "https:" && fn.has(e.hostname.toLowerCase());
1694
+ let e = new URL(n);
1695
+ if (e.protocol !== "https:") return !1;
1696
+ let r = e.hostname.toLowerCase();
1697
+ return Tn.has(r) || !!t?.has(r);
1605
1698
  } catch {
1606
1699
  return !1;
1607
1700
  }
1608
1701
  }
1609
- function N(e, { allowData: t = !1, media: n = t } = {}) {
1702
+ function Fn(e, t) {
1703
+ return Pn(e, Nn(t));
1704
+ }
1705
+ function M(e, { allowData: t = !1, media: n = t } = {}) {
1610
1706
  let r = (e || "").trim();
1611
- return !r && e == null ? null : xn(r, {
1707
+ return !r && e == null ? null : In(r, {
1612
1708
  media: n,
1613
1709
  allowData: t
1614
1710
  }) ? e : null;
1615
1711
  }
1616
- function xn(e, { media: t = !1, allowData: n = !1 } = {}) {
1712
+ function In(e, { media: t = !1, allowData: n = !1 } = {}) {
1617
1713
  let r = (e || "").trim();
1618
- if (!r || n && hn.test(r)) return !0;
1714
+ if (!r || n && On.test(r)) return !0;
1619
1715
  try {
1620
- let e = new URL(r, gn);
1621
- return (t ? mn : pn).has(e.protocol);
1716
+ let e = new URL(r, kn);
1717
+ return (t ? Dn : En).has(e.protocol);
1622
1718
  } catch {
1623
1719
  return !1;
1624
1720
  }
1625
1721
  }
1626
1722
  //#endregion
1627
1723
  //#region src/js/renderer.js
1628
- function Sn(e, t) {
1629
- let n = x("div", { class: "an-container" }), r = x("div", {
1724
+ function Ln(e, t) {
1725
+ let n = b("div", { class: "an-container" }), r = b("div", {
1630
1726
  class: "an-editable",
1631
1727
  contenteditable: t.readOnly ? "false" : "true",
1632
1728
  spellcheck: String(t.spellcheck !== !1),
@@ -1637,51 +1733,112 @@ function Sn(e, t) {
1637
1733
  if (t.autoSave && t.autoSaveKey) try {
1638
1734
  i = localStorage.getItem(t.autoSaveKey) || "";
1639
1735
  } catch {}
1640
- i ||= e.tagName === "TEXTAREA" ? (e.value || "").trim() : (e.innerHTML || "").trim(), r.innerHTML = M(i, { allowIframes: !0 });
1736
+ i ||= e.tagName === "TEXTAREA" ? (e.value || "").trim() : (e.innerHTML || "").trim(), r.innerHTML = j(i, {
1737
+ allowIframes: !0,
1738
+ iframeHosts: t.iframeHosts
1739
+ });
1641
1740
  let a = t.defaultFontFamily || t.fontFamilies?.[0];
1642
- return a && (r.style.fontFamily = a), t.defaultFontSize && (r.style.fontSize = t.defaultFontSize), t.height ? r.style.minHeight = `${t.height}px` : t.minHeight && (r.style.minHeight = `${t.minHeight}px`), t.maxHeight && (r.style.maxHeight = `${t.maxHeight}px`), n.appendChild(r), t.theme === "dark" ? (n.classList.add("an-theme-dark"), document.body.classList.add("an-theme-dark")) : t.theme === "auto" && (n.classList.add("an-theme-auto"), document.body.classList.add("an-theme-auto")), t.readOnly && (n.classList.add("an-disabled"), r.querySelectorAll("ul.an-checklist input[type=\"checkbox\"]").forEach((e) => {
1741
+ return a && (r.style.fontFamily = a), t.defaultFontSize && (r.style.fontSize = t.defaultFontSize), t.height ? r.style.minHeight = `${t.height}px` : t.minHeight && (r.style.minHeight = `${t.minHeight}px`), t.maxHeight && (r.style.maxHeight = `${t.maxHeight}px`), n.appendChild(r), t.readOnly && (n.classList.add("an-disabled"), r.querySelectorAll("ul.an-checklist input[type=\"checkbox\"]").forEach((e) => {
1643
1742
  e.setAttribute("disabled", "");
1644
- })), t.direction === "rtl" && (r.setAttribute("dir", "rtl"), n.classList.add("an-dir-rtl")), t.toolbarOverflow === "scroll" && n.classList.add("an-toolbar-overflow-scroll"), t.stickyToolbar && (n.classList.add("an-sticky-toolbar"), t.stickyToolbarOffset && n.style.setProperty("--an-sticky-top", `${t.stickyToolbarOffset}px`)), t.focusColor && n.style.setProperty("--an-focus-color", t.focusColor), e.style.display = "none", e.after(n), {
1743
+ })), t.direction === "rtl" && (r.setAttribute("dir", "rtl"), n.classList.add("an-dir-rtl")), Hn(n, null, t), e.style.display = "none", e.after(n), {
1645
1744
  container: n,
1646
1745
  editable: r
1647
1746
  };
1648
1747
  }
1748
+ var Rn = ["an-theme-dark", "an-theme-auto"];
1749
+ function zn(e) {
1750
+ return e.startsWith("--") ? e : `--an-${e}`;
1751
+ }
1752
+ function Bn(e) {
1753
+ let t = b("div", {
1754
+ class: "an-portal",
1755
+ "data-an-portal": ""
1756
+ });
1757
+ return Vn(e.popupContainer).appendChild(t), t;
1758
+ }
1759
+ function Vn(e) {
1760
+ if (typeof e == "string" && e) {
1761
+ let t = document.querySelector(e);
1762
+ if (t) return t;
1763
+ console.warn(`[AutumnNote] popupContainer "${e}" matched nothing; using document.body.`);
1764
+ } else if (e && typeof e.appendChild == "function") return e;
1765
+ return document.body;
1766
+ }
1767
+ function Hn(e, t, n) {
1768
+ let r = t ? [e, t] : [e], i = n.theme === "dark" ? "an-theme-dark" : n.theme === "auto" ? "an-theme-auto" : null;
1769
+ for (let e of r) {
1770
+ e.classList.remove(...Rn), i && e.classList.add(i);
1771
+ for (let t of Array.from(e.style)) t.startsWith("--an-") && e.style.removeProperty(t);
1772
+ let t = n.themeVars;
1773
+ if (t && typeof t == "object") for (let [n, r] of Object.entries(t)) (typeof r == "string" || typeof r == "number") && e.style.setProperty(zn(n), String(r));
1774
+ n.focusColor && e.style.setProperty("--an-focus-color", n.focusColor);
1775
+ let r = Number(n.zIndexOffset) || 0;
1776
+ r && e.style.setProperty("--an-z-offset", String(Math.trunc(r)));
1777
+ }
1778
+ e.classList.toggle("an-toolbar-overflow-scroll", n.toolbarOverflow === "scroll"), e.classList.toggle("an-sticky-toolbar", !!n.stickyToolbar), n.stickyToolbar && n.stickyToolbarOffset && e.style.setProperty("--an-sticky-top", `${n.stickyToolbarOffset}px`);
1779
+ }
1649
1780
  //#endregion
1650
1781
  //#region src/js/Context.js
1651
- var Cn = /* @__PURE__ */ new Map(), wn = [];
1652
- function Tn(e) {
1653
- wn = Array.isArray(e) ? e : [];
1654
- }
1655
- var P = /* @__PURE__ */ new Map(), En = class {
1782
+ var Un = /* @__PURE__ */ new Map(), Wn = [];
1783
+ function Gn(e) {
1784
+ Wn = Array.isArray(e) ? e : [];
1785
+ }
1786
+ var Kn = [
1787
+ "theme",
1788
+ "themeVars",
1789
+ "focusColor",
1790
+ "zIndexOffset",
1791
+ "toolbarOverflow",
1792
+ "stickyToolbar",
1793
+ "stickyToolbarOffset"
1794
+ ], qn = [
1795
+ "toolbar",
1796
+ "useFontAwesome",
1797
+ "fontAwesomeClass",
1798
+ "useBootstrap",
1799
+ "toolbarButtonClass",
1800
+ "icons",
1801
+ "buttons",
1802
+ "fontFamilies",
1803
+ "fontSizes",
1804
+ "lineHeights",
1805
+ "paragraphStyles",
1806
+ "colorPalette",
1807
+ "colorSwatches"
1808
+ ], Jn = ["lang"], N = /* @__PURE__ */ new Map(), Yn = class {
1656
1809
  constructor(e, t = {}) {
1657
- this.targetEl = e, this.options = c(A, t), this.locale = rn(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, this._releaseInstance = null;
1810
+ this.targetEl = e, this.options = c(k, t), this.locale = _n(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, this._releaseInstance = null;
1658
1811
  }
1659
1812
  initialize() {
1660
- let { container: e, editable: t } = Sn(this.targetEl, this.options);
1661
- this.layoutInfo.container = e, this.layoutInfo.editable = t, this._registerModules();
1662
- let n = this._modules.get("toolbar");
1663
- n?.el && (e.insertBefore(n.el, t), this.layoutInfo.toolbar = n.el);
1664
- let r = this._modules.get("statusbar");
1665
- return r?.el && (e.appendChild(r.el), this.layoutInfo.statusbar = r.el), this._bindEditorEvents(t), this.options.focus && t.focus(), this._alive = !0, this.invoke("toolbar.refresh"), this._applyGlobalPlugins(), typeof this.options.onInit == "function" && this.options.onInit(this), this;
1813
+ let { container: e, editable: t } = Ln(this.targetEl, this.options);
1814
+ this.layoutInfo.container = e, this.layoutInfo.editable = t, t.setAttribute("aria-label", this.locale.a11y?.editor || "Rich text editor");
1815
+ let n = Bn(this.options);
1816
+ this.layoutInfo.portal = n, Hn(e, n, this.options), this._registerModules();
1817
+ let r = this._modules.get("toolbar");
1818
+ r?.el && (e.insertBefore(r.el, t), this.layoutInfo.toolbar = r.el);
1819
+ let i = this._modules.get("statusbar");
1820
+ return i?.el && (e.appendChild(i.el), this.layoutInfo.statusbar = i.el), this._bindEditorEvents(t), this.options.focus && t.focus(), this._alive = !0, this.invoke("toolbar.refresh"), this._applyGlobalPlugins(), this.triggerEvent("init", this), this;
1666
1821
  }
1667
1822
  _registerModules() {
1668
1823
  let e = (e, t) => {
1669
1824
  let n = new t(this);
1670
1825
  this._modules.set(e, n), n.initialize();
1671
1826
  };
1672
- for (let { name: t, Class: n, enabled: r } of wn) typeof r == "function" && !r(this.options) || e(t, n);
1673
- if (Cn.size > 0) for (let [t, n] of Cn) e(t, n);
1827
+ for (let { name: t, Class: n, enabled: r } of Wn) typeof r == "function" && !r(this.options) || e(t, n);
1828
+ if (Un.size > 0) for (let [t, n] of Un) e(t, n);
1674
1829
  }
1675
1830
  _syncOptionalModules() {
1676
- for (let { name: e, Class: t, enabled: n } of wn) {
1831
+ for (let { name: e, Class: t, enabled: n } of Wn) {
1677
1832
  if (typeof n != "function") continue;
1678
1833
  let r = n(this.options);
1679
- if (r !== this._modules.has(e)) if (r) {
1680
- let n = new t(this);
1681
- this._modules.set(e, n), n.initialize();
1682
- } else {
1683
- let t = this._modules.get(e);
1684
- typeof t?.destroy == "function" && t.destroy(), this._modules.delete(e);
1834
+ if (r !== this._modules.has(e)) {
1835
+ if (r) {
1836
+ let n = new t(this);
1837
+ this._modules.set(e, n), n.initialize();
1838
+ } else {
1839
+ let t = this._modules.get(e);
1840
+ typeof t?.destroy == "function" && t.destroy(), this._modules.delete(e);
1841
+ }
1685
1842
  }
1686
1843
  }
1687
1844
  }
@@ -1696,7 +1853,7 @@ var P = /* @__PURE__ */ new Map(), En = class {
1696
1853
  return n >= 0 ? t[n] = e : t.push(e), this.invoke("slashMenu.refresh"), this;
1697
1854
  }
1698
1855
  use(e, t = {}) {
1699
- return Array.isArray(e.buttons) && e.buttons.forEach((e) => k(e)), this._installPlugin(e, t), this;
1856
+ return Array.isArray(e.buttons) && e.buttons.forEach((e) => D(e)), this._installPlugin(e, t), this;
1700
1857
  }
1701
1858
  getPlugin(e) {
1702
1859
  return this._plugins.get(e)?.publicApi ?? null;
@@ -1718,13 +1875,13 @@ var P = /* @__PURE__ */ new Map(), En = class {
1718
1875
  });
1719
1876
  }
1720
1877
  _applyGlobalPlugins() {
1721
- if (P.size !== 0) for (let { plugin: e, options: t } of P.values()) this._installPlugin(e, t);
1878
+ if (N.size !== 0) for (let { plugin: e, options: t } of N.values()) this._installPlugin(e, t);
1722
1879
  }
1723
1880
  _bindEditorEvents(e) {
1724
- let t = C(e, "input", () => this._syncToTarget()), n = C(e, "focus", () => {
1725
- this.layoutInfo.container.classList.add("an-focused"), typeof this.options.onFocus == "function" && this.options.onFocus(this);
1726
- }), r = C(e, "blur", () => {
1727
- this.layoutInfo.container.classList.remove("an-focused"), this._syncToTarget(), typeof this.options.onBlur == "function" && this.options.onBlur(this);
1881
+ let t = x(e, "input", () => this._syncToTarget()), n = x(e, "focus", () => {
1882
+ this.layoutInfo.container.classList.add("an-focused"), this.triggerEvent("focus", this);
1883
+ }), r = x(e, "blur", () => {
1884
+ this.layoutInfo.container.classList.remove("an-focused"), this._syncToTarget(), this.triggerEvent("blur", this);
1728
1885
  }), i = this.on("change", (e) => this._syncToTarget(e)), a = this.on("change", (e) => {
1729
1886
  if (this.options.blockIds && (this.ensureBlockIds(), e = this.getHTML()), e === this._suppressedRemoteHTML) {
1730
1887
  this._suppressedRemoteHTML = null;
@@ -1798,23 +1955,33 @@ var P = /* @__PURE__ */ new Map(), En = class {
1798
1955
  r !== -1 && n.splice(r, 1);
1799
1956
  }
1800
1957
  triggerEvent(e, ...t) {
1801
- (this._listeners.get(e) || []).forEach((e) => e(...t));
1802
- let n = "on" + e.charAt(0).toUpperCase() + e.slice(1);
1803
- typeof this.options[n] == "function" && this.options[n](...t);
1958
+ let n, r = [...this._listeners.get(e) || []];
1959
+ for (let e of r) {
1960
+ let r = e(...t);
1961
+ r !== void 0 && (n = r);
1962
+ }
1963
+ let i = "on" + e.charAt(0).toUpperCase() + e.slice(1);
1964
+ if (typeof this.options[i] == "function") {
1965
+ let e = this.options[i](...t);
1966
+ e !== void 0 && (n = e);
1967
+ }
1968
+ return n;
1804
1969
  }
1805
1970
  updateOptions(e = {}) {
1806
- let t = c(this.options, e);
1807
- Object.keys(this.options).forEach((e) => delete this.options[e]), Object.assign(this.options, t);
1808
- let { container: n, editable: r } = this.layoutInfo;
1809
- if (Object.hasOwn(e, "readOnly") && this.setDisabled(!!this.options.readOnly), Object.hasOwn(e, "spellcheck") && (r.spellcheck = this.options.spellcheck !== !1), Object.hasOwn(e, "placeholder") && (r.dataset.placeholder = this.options.placeholder || ""), Object.hasOwn(e, "direction")) {
1971
+ let t = { ...this.options }, n = c(this.options, e);
1972
+ Object.keys(this.options).forEach((e) => delete this.options[e]), Object.assign(this.options, n);
1973
+ let r = (n) => Object.hasOwn(e, n) && !l(t[n], this.options[n]), { container: i, editable: a } = this.layoutInfo;
1974
+ if (Object.hasOwn(e, "readOnly") && this.setDisabled(!!this.options.readOnly), Object.hasOwn(e, "spellcheck") && (a.spellcheck = this.options.spellcheck !== !1), Object.hasOwn(e, "placeholder") && (a.dataset.placeholder = this.options.placeholder || ""), Object.hasOwn(e, "direction")) {
1810
1975
  let e = this.options.direction === "rtl";
1811
- r.setAttribute("dir", e ? "rtl" : "ltr"), n.classList.toggle("an-dir-rtl", e);
1976
+ a.setAttribute("dir", e ? "rtl" : "ltr"), i.classList.toggle("an-dir-rtl", e);
1812
1977
  }
1813
1978
  if (Object.hasOwn(e, "height") || Object.hasOwn(e, "minHeight")) {
1814
1979
  let e = this.options.height || this.options.minHeight || 0;
1815
- r.style.minHeight = e ? `${e}px` : "";
1980
+ a.style.minHeight = e ? `${e}px` : "";
1816
1981
  }
1817
- return Object.hasOwn(e, "maxHeight") && (r.style.maxHeight = this.options.maxHeight ? `${this.options.maxHeight}px` : ""), Object.hasOwn(e, "toolbar") && this.invoke("toolbar.rebuild"), this._syncOptionalModules(), this.invoke("statusbar.update"), this.triggerEvent("optionsChange", { ...e }), this;
1982
+ Object.hasOwn(e, "maxHeight") && (a.style.maxHeight = this.options.maxHeight ? `${this.options.maxHeight}px` : ""), qn.some(r) && this.invoke("toolbar.rebuild"), Kn.some(r) && Hn(i, this.layoutInfo.portal ?? null, this.options), r("popupContainer") && this.layoutInfo.portal && Vn(this.options.popupContainer).appendChild(this.layoutInfo.portal), r("resizable") && this.invoke("statusbar.applyResizable");
1983
+ let o = Jn.filter(r);
1984
+ return o.length && console.warn(`[AutumnNote] updateOptions: ${o.join(", ")} only take effect when the editor is created; destroy and re-create it to apply.`), this._syncOptionalModules(), r("statusbar") && this.invoke("statusbar.applyVisibility"), this.invoke("statusbar.update"), this.triggerEvent("optionsChange", { ...e }), this;
1818
1985
  }
1819
1986
  getHTML() {
1820
1987
  let e = this.invoke("editor.getHTML");
@@ -1963,8 +2130,8 @@ var P = /* @__PURE__ */ new Map(), En = class {
1963
2130
  e.uninstall(this);
1964
2131
  } catch {}
1965
2132
  this._plugins.clear(), this._disposers.forEach((e) => e()), this._disposers = [];
1966
- let t = this.layoutInfo.container, n = t?.classList.contains("an-theme-dark"), r = t?.classList.contains("an-theme-auto");
1967
- return t?.parentNode && (this.targetEl.style.display = "", t.remove()), n && !document.querySelector(".an-container.an-theme-dark") && document.body.classList.remove("an-theme-dark"), r && !document.querySelector(".an-container.an-theme-auto") && document.body.classList.remove("an-theme-auto"), typeof this.options.onDestroy == "function" && this.options.onDestroy(this), this._alive = !1, this._releaseInstance?.(), this._releaseInstance = null, this._destroyPromise = Promise.resolve(e).then(() => {
2133
+ let t = this.layoutInfo.container;
2134
+ return t?.parentNode && (this.targetEl.style.display = "", t.remove()), this.layoutInfo.portal?.remove(), this.triggerEvent("destroy", this), this._alive = !1, this._releaseInstance?.(), this._releaseInstance = null, this._destroyPromise = Promise.resolve(e).then(() => {
1968
2135
  this._listeners.clear();
1969
2136
  }), this._destroyPromise;
1970
2137
  }
@@ -1974,13 +2141,13 @@ var P = /* @__PURE__ */ new Map(), En = class {
1974
2141
  };
1975
2142
  //#endregion
1976
2143
  //#region src/js/editing/History.js
1977
- function Dn(e, t) {
2144
+ function Xn(e, t) {
1978
2145
  let n = Math.min(e.length, t.length), r = 0;
1979
2146
  for (; r < n && e.charCodeAt(r) === t.charCodeAt(r);) r++;
1980
2147
  return r;
1981
2148
  }
1982
- var On = class {
1983
- constructor(e, t = 100, n = 10 * 1024 * 1024) {
2149
+ var Zn = class {
2150
+ constructor(e, t = 100, n = 10485760) {
1984
2151
  this.editable = e, this._limit = t, this._maxBytes = n, this._bytes = 0, this.stack = [], this.stackOffset = -1, this._savePoint();
1985
2152
  }
1986
2153
  _entrySize(e) {
@@ -2058,7 +2225,7 @@ var On = class {
2058
2225
  this.editable.innerHTML = this._detokenizeImages(e);
2059
2226
  let n = e.sel;
2060
2227
  if (!n) {
2061
- let e = Dn(t, this.editable.textContent || "");
2228
+ let e = Xn(t, this.editable.textContent || "");
2062
2229
  n = {
2063
2230
  start: e,
2064
2231
  end: e
@@ -2111,31 +2278,31 @@ var On = class {
2111
2278
  };
2112
2279
  //#endregion
2113
2280
  //#region src/js/editing/Table.js
2114
- function kn(e, t, n = {}) {
2115
- let { headerRow: r = !1 } = n, i = x("table", { class: "an-table" });
2281
+ function Qn(e, t, n = {}) {
2282
+ let { headerRow: r = !1 } = n, i = b("table", { class: "an-table" });
2116
2283
  if (r && t > 0) {
2117
- let t = x("thead"), n = x("tr");
2284
+ let t = b("thead"), n = b("tr");
2118
2285
  for (let t = 0; t < e; t++) {
2119
- let e = x("th", {}, [document.createElement("br")]);
2286
+ let e = b("th", {}, [document.createElement("br")]);
2120
2287
  n.appendChild(e);
2121
2288
  }
2122
2289
  t.appendChild(n), i.appendChild(t);
2123
2290
  }
2124
- let a = r ? Math.max(t - 1, 1) : t, o = x("tbody");
2291
+ let a = r ? Math.max(t - 1, 1) : t, o = b("tbody");
2125
2292
  i.appendChild(o);
2126
2293
  for (let t = 0; t < a; t++) {
2127
- let t = x("tr");
2294
+ let t = b("tr");
2128
2295
  for (let n = 0; n < e; n++) {
2129
- let e = x("td", {}, [document.createElement("br")]);
2296
+ let e = b("td", {}, [document.createElement("br")]);
2130
2297
  t.appendChild(e);
2131
2298
  }
2132
2299
  o.appendChild(t);
2133
2300
  }
2134
2301
  return i;
2135
2302
  }
2136
- function An(e, t, n = {}) {
2303
+ function $n(e, t, n = {}) {
2137
2304
  if (e <= 0 || t <= 0) return;
2138
- let r = kn(e, t, n), i = globalThis.getSelection();
2305
+ let r = Qn(e, t, n), i = globalThis.getSelection();
2139
2306
  if (!i || i.rangeCount === 0) return;
2140
2307
  let a = i.getRangeAt(0);
2141
2308
  try {
@@ -2175,8 +2342,108 @@ function An(e, t, n = {}) {
2175
2342
  }
2176
2343
  }
2177
2344
  //#endregion
2345
+ //#region src/js/core/keymap.js
2346
+ var er = Object.freeze({
2347
+ "Mod+Z": "undo",
2348
+ "Mod+Shift+Z": "redo",
2349
+ "Mod+Y": "redo",
2350
+ "Mod+B": "bold",
2351
+ "Mod+I": "italic",
2352
+ "Mod+U": "underline",
2353
+ "Mod+K": "link",
2354
+ "Mod+Shift+V": "pastePlainText",
2355
+ "Mod+F": "find",
2356
+ "Mod+H": "findReplace",
2357
+ "Mod+`": "inlineCode",
2358
+ "Ctrl+Shift+/": "shortcuts"
2359
+ }), tr = {
2360
+ Slash: "/",
2361
+ Backslash: "\\",
2362
+ Backquote: "`",
2363
+ Minus: "-",
2364
+ Equal: "=",
2365
+ BracketLeft: "[",
2366
+ BracketRight: "]",
2367
+ Semicolon: ";",
2368
+ Quote: "'",
2369
+ Comma: ",",
2370
+ Period: ".",
2371
+ Space: " "
2372
+ };
2373
+ function nr(e) {
2374
+ if (typeof e != "string") return null;
2375
+ let t = e.trim().split(/\+(?!$)/).map((e) => e.trim()).filter(Boolean);
2376
+ if (!t.length) return null;
2377
+ let n = {
2378
+ mod: !1,
2379
+ ctrl: !1,
2380
+ meta: !1,
2381
+ alt: !1,
2382
+ shift: !1,
2383
+ key: ""
2384
+ };
2385
+ for (let [e, r] of t.entries()) {
2386
+ let i = r.toLowerCase(), a = e === t.length - 1;
2387
+ if (!a && (i === "mod" || i === "cmdorctrl")) n.mod = !0;
2388
+ else if (!a && (i === "ctrl" || i === "control")) n.ctrl = !0;
2389
+ else if (!a && (i === "meta" || i === "cmd" || i === "command")) n.meta = !0;
2390
+ else if (!a && (i === "alt" || i === "option")) n.alt = !0;
2391
+ else if (!a && i === "shift") n.shift = !0;
2392
+ else if (a) n.key = i;
2393
+ else return null;
2394
+ }
2395
+ return n.key ? n : null;
2396
+ }
2397
+ function rr(e, t) {
2398
+ if (t.mod) {
2399
+ if (!e.ctrlKey && !e.metaKey) return !1;
2400
+ } else if (e.ctrlKey !== t.ctrl || e.metaKey !== t.meta) return !1;
2401
+ if (e.altKey !== t.alt || e.shiftKey !== t.shift) return !1;
2402
+ if ((e.key || "").toLowerCase() === t.key) return !0;
2403
+ let n = e.code || "", r = tr[n];
2404
+ return !r && /^Key[A-Z]$/.test(n) ? r = n.slice(3).toLowerCase() : !r && /^Digit\d$/.test(n) && (r = n.slice(5)), r === t.key;
2405
+ }
2406
+ function ir(e) {
2407
+ let t = /* @__PURE__ */ new Map(), n = (e, n) => {
2408
+ let r = nr(e);
2409
+ if (!r) {
2410
+ console.warn(`[AutumnNote] keyMap: cannot parse shortcut "${e}".`);
2411
+ return;
2412
+ }
2413
+ let i = ar(r);
2414
+ if (n === !1 || n === null) {
2415
+ t.set(i, null);
2416
+ return;
2417
+ }
2418
+ let a = n, o;
2419
+ if (n && typeof n == "object" && typeof n.run == "function" && (a = n.run, o = typeof n.description == "string" ? n.description : void 0), typeof a != "string" && typeof a != "function") {
2420
+ console.warn(`[AutumnNote] keyMap: "${e}" must map to a command name, a function or false.`);
2421
+ return;
2422
+ }
2423
+ t.set(i, {
2424
+ combo: e,
2425
+ parsed: r,
2426
+ command: a,
2427
+ description: o
2428
+ });
2429
+ };
2430
+ for (let [e, t] of Object.entries(er)) n(e, t);
2431
+ if (e && typeof e == "object") for (let [t, r] of Object.entries(e)) n(t, r);
2432
+ return [...t.values()].filter(Boolean);
2433
+ }
2434
+ function ar(e) {
2435
+ return [
2436
+ e.mod && "mod",
2437
+ e.ctrl && "ctrl",
2438
+ e.meta && "meta",
2439
+ e.alt && "alt",
2440
+ e.shift && "shift",
2441
+ e.key
2442
+ ].filter(Boolean).join("+");
2443
+ }
2444
+ //#endregion
2178
2445
  //#region src/js/core/key.js
2179
- var F = {
2446
+ var P = {
2180
2447
  BACKSPACE: "Backspace",
2181
2448
  TAB: "Tab",
2182
2449
  ENTER: "Enter",
@@ -2215,27 +2482,27 @@ var F = {
2215
2482
  SLASH: "/",
2216
2483
  PERIOD: "."
2217
2484
  };
2218
- function I(e, t) {
2485
+ function F(e, t) {
2219
2486
  return e.key === t || e.key === t.toUpperCase();
2220
2487
  }
2221
- function L(e, t) {
2222
- return (e.ctrlKey || e.metaKey) && I(e, t);
2488
+ function or(e, t) {
2489
+ return (e.ctrlKey || e.metaKey) && F(e, t);
2223
2490
  }
2224
2491
  //#endregion
2225
2492
  //#region src/js/editing/Typing.js
2226
- var jn = /\bfa-/, R = (e) => !!(e?.nodeName === "I" && jn.test(e.className || "")), z = (e) => e?.nodeType === Node.TEXT_NODE && (e.textContent === "​" || e.textContent === "");
2227
- function Mn(e, t, n) {
2493
+ var sr = /\bfa-/, I = (e) => !!(e?.nodeName === "I" && sr.test(e.className || "")), L = (e) => !(e?.nodeType !== Node.TEXT_NODE || e.textContent !== "​" && e.textContent !== "");
2494
+ function cr(e, t, n) {
2228
2495
  let r = (e?.nodeType === Node.ELEMENT_NODE ? e : e?.parentElement ?? null)?.closest("td, th") ?? null;
2229
2496
  if (!r || !t.contains(r)) return !1;
2230
2497
  let i = r.closest("table");
2231
2498
  if (!i || !t.contains(i)) return !1;
2232
2499
  let a = Array.from(i.querySelectorAll("td, th")), o = a[a.indexOf(r) + (n ? -1 : 1)];
2233
- if (o) return he(o), !0;
2500
+ if (o) return ve(o), !0;
2234
2501
  if (n) return !0;
2235
- let s = Nn(r.closest("tr"))?.firstElementChild ?? null;
2236
- return s && he(s), !0;
2502
+ let s = lr(r.closest("tr"))?.firstElementChild ?? null;
2503
+ return s && ve(s), !0;
2237
2504
  }
2238
- function Nn(e) {
2505
+ function lr(e) {
2239
2506
  if (!e?.parentNode) return null;
2240
2507
  let t = document.createElement("tr");
2241
2508
  for (let n of e.cells) {
@@ -2244,7 +2511,7 @@ function Nn(e) {
2244
2511
  }
2245
2512
  return e.parentNode.insertBefore(t, e.nextSibling), t;
2246
2513
  }
2247
- function Pn(e, t) {
2514
+ function ur(e, t) {
2248
2515
  try {
2249
2516
  let n = document.createRange();
2250
2517
  return n.setStart(e.startContainer, e.startOffset), n.setEnd(t, t.childNodes.length), n.extractContents();
@@ -2252,21 +2519,21 @@ function Pn(e, t) {
2252
2519
  return document.createDocumentFragment();
2253
2520
  }
2254
2521
  }
2255
- function Fn(e, t, n = {}) {
2522
+ function dr(e, t, n = {}) {
2256
2523
  let r = (e) => {
2257
2524
  let t = globalThis.getSelection();
2258
2525
  if (!t) return !1;
2259
2526
  let n = document.createRange();
2260
2527
  return e(n), n.collapse(!0), t.removeAllRanges(), t.addRange(n), !0;
2261
2528
  };
2262
- if (I(e, F.BACKSPACE)) {
2529
+ if (F(e, P.BACKSPACE)) {
2263
2530
  let t = globalThis.getSelection();
2264
2531
  if (t?.rangeCount > 0) {
2265
2532
  let n = t.getRangeAt(0);
2266
2533
  if (n.collapsed && n.startContainer.nodeType === Node.TEXT_NODE) {
2267
2534
  let r = n.startContainer;
2268
- if (n.startOffset === 0 && R(r.previousSibling)) return e.preventDefault(), r.previousSibling.remove(), !0;
2269
- if (n.startOffset === 1 && r.textContent === "​" && R(r.previousSibling)) {
2535
+ if (n.startOffset === 0 && I(r.previousSibling)) return e.preventDefault(), r.previousSibling.remove(), !0;
2536
+ if (n.startOffset === 1 && r.textContent === "​" && I(r.previousSibling)) {
2270
2537
  e.preventDefault();
2271
2538
  let n = r.parentNode, i = r.previousSibling, a = i.previousSibling;
2272
2539
  i.remove(), r.remove();
@@ -2277,17 +2544,17 @@ function Fn(e, t, n = {}) {
2277
2544
  }
2278
2545
  return !1;
2279
2546
  }
2280
- if (I(e, F.LEFT) || I(e, F.RIGHT)) {
2547
+ if (F(e, P.LEFT) || F(e, P.RIGHT)) {
2281
2548
  let t = globalThis.getSelection();
2282
2549
  if (!t || t.rangeCount === 0) return !1;
2283
2550
  let n = t.getRangeAt(0);
2284
2551
  if (!n.collapsed) return !1;
2285
- let i = n.startContainer, a = I(e, F.LEFT);
2552
+ let i = n.startContainer, a = F(e, P.LEFT);
2286
2553
  if (i.nodeType === Node.TEXT_NODE) {
2287
2554
  let t = i;
2288
- if (a && n.startOffset === 1 && t.textContent === "​" && R(t.previousSibling) || a && n.startOffset === 0 && R(t.previousSibling)) return e.preventDefault(), r((e) => e.setStartBefore(t.previousSibling));
2289
- if (a && n.startOffset === 0 && z(t.previousSibling) && R(t.previousSibling.previousSibling)) return e.preventDefault(), r((e) => e.setStartBefore(t.previousSibling.previousSibling));
2290
- if (!a && n.startOffset === t.textContent.length && R(t.nextSibling)) {
2555
+ if (a && n.startOffset === 1 && t.textContent === "​" && I(t.previousSibling) || a && n.startOffset === 0 && I(t.previousSibling)) return e.preventDefault(), r((e) => e.setStartBefore(t.previousSibling));
2556
+ if (a && n.startOffset === 0 && L(t.previousSibling) && I(t.previousSibling.previousSibling)) return e.preventDefault(), r((e) => e.setStartBefore(t.previousSibling.previousSibling));
2557
+ if (!a && n.startOffset === t.textContent.length && I(t.nextSibling)) {
2291
2558
  let n = t.nextSibling, i = n.nextSibling;
2292
2559
  if (e.preventDefault(), i?.nodeType === Node.TEXT_NODE) {
2293
2560
  let e = +!!(i.textContent || "").startsWith("​");
@@ -2295,7 +2562,7 @@ function Fn(e, t, n = {}) {
2295
2562
  }
2296
2563
  return r((e) => e.setStartAfter(n));
2297
2564
  }
2298
- if (!a && n.startOffset === t.textContent.length && z(t.nextSibling) && R(t.nextSibling.nextSibling)) {
2565
+ if (!a && n.startOffset === t.textContent.length && L(t.nextSibling) && I(t.nextSibling.nextSibling)) {
2299
2566
  let n = t.nextSibling.nextSibling, i = n.nextSibling;
2300
2567
  if (e.preventDefault(), i?.nodeType === Node.TEXT_NODE) {
2301
2568
  let e = +!!(i.textContent || "").startsWith("​");
@@ -2308,12 +2575,12 @@ function Fn(e, t, n = {}) {
2308
2575
  let t = i;
2309
2576
  if (a && n.startOffset > 0) {
2310
2577
  let i = t.childNodes[n.startOffset - 1];
2311
- if (R(i)) return e.preventDefault(), r((e) => e.setStartBefore(i));
2312
- if (z(i) && R(i.previousSibling)) return e.preventDefault(), r((e) => e.setStartBefore(i.previousSibling));
2578
+ if (I(i)) return e.preventDefault(), r((e) => e.setStartBefore(i));
2579
+ if (L(i) && I(i.previousSibling)) return e.preventDefault(), r((e) => e.setStartBefore(i.previousSibling));
2313
2580
  }
2314
2581
  if (!a && n.startOffset < t.childNodes.length) {
2315
2582
  let i = t.childNodes[n.startOffset];
2316
- if (R(i)) {
2583
+ if (I(i)) {
2317
2584
  let t = i.nextSibling;
2318
2585
  if (e.preventDefault(), t?.nodeType === Node.TEXT_NODE) {
2319
2586
  let e = +!!(t.textContent || "").startsWith("​");
@@ -2321,7 +2588,7 @@ function Fn(e, t, n = {}) {
2321
2588
  }
2322
2589
  return r((e) => e.setStartAfter(i));
2323
2590
  }
2324
- if (z(i) && R(i.nextSibling)) {
2591
+ if (L(i) && I(i.nextSibling)) {
2325
2592
  let t = i.nextSibling, n = t.nextSibling;
2326
2593
  if (e.preventDefault(), n?.nodeType === Node.TEXT_NODE) {
2327
2594
  let e = +!!(n.textContent || "").startsWith("​");
@@ -2332,18 +2599,18 @@ function Fn(e, t, n = {}) {
2332
2599
  }
2333
2600
  }
2334
2601
  }
2335
- if (I(e, F.TAB)) {
2336
- let r = xe(t);
2602
+ if (F(e, P.TAB)) {
2603
+ let r = Te(t);
2337
2604
  if (!r) return !1;
2338
- if (Mn(r.sc, t, e.shiftKey)) return e.preventDefault(), !0;
2339
- let i = b(r.sc, t);
2340
- if (i && ee(i)) return e.preventDefault(), e.shiftKey ? et() : Qe(), !0;
2341
- if (i?.nodeName.toUpperCase() === "PRE") return e.shiftKey ? !1 : (e.preventDefault(), T("insertText", " ".repeat(n.tabSize || 4)), !0);
2342
- if (n.tabSize) return e.shiftKey ? !1 : (e.preventDefault(), T("insertText", " ".repeat(n.tabSize)), !0);
2343
- }
2344
- if (I(e, F.ENTER) && e.shiftKey) return e.preventDefault(), T("insertLineBreak"), !0;
2345
- if (I(e, F.ENTER) && !e.shiftKey) {
2346
- let n = xe(t);
2605
+ if (cr(r.sc, t, e.shiftKey)) return e.preventDefault(), !0;
2606
+ let i = se(r.sc, t);
2607
+ if (i && te(i)) return e.preventDefault(), e.shiftKey ? it() : nt(), !0;
2608
+ if (i?.nodeName.toUpperCase() === "PRE") return !e.shiftKey && (e.preventDefault(), C("insertText", " ".repeat(n.tabSize || 4)), !0);
2609
+ if (n.tabSize) return !e.shiftKey && (e.preventDefault(), C("insertText", " ".repeat(n.tabSize)), !0);
2610
+ }
2611
+ if (F(e, P.ENTER) && e.shiftKey) return e.preventDefault(), C("insertLineBreak"), !0;
2612
+ if (F(e, P.ENTER) && !e.shiftKey) {
2613
+ let n = Te(t);
2347
2614
  if (!n) return !1;
2348
2615
  let r = n.sc, i = r.nodeType === 3 ? r.parentElement : r;
2349
2616
  if (i?.nodeName === "I" && /\bfa-/.test(i.className || "")) {
@@ -2366,7 +2633,7 @@ function Fn(e, t, n = {}) {
2366
2633
  if (o) {
2367
2634
  e.preventDefault();
2368
2635
  let t = o.closest(".an-checklist"), n = globalThis.getSelection(), r = n.getRangeAt(0);
2369
- if (!((e) => Array.from(e.childNodes).filter((e) => !(e.nodeType === 1 && e.tagName === "INPUT")).map((e) => e.textContent).join("").replace(/[\u00a0\u200B]/g, " ").trim())(o)) {
2636
+ if (!((e) => Array.from(e.childNodes).filter((e) => e.nodeType !== 1 || e.tagName !== "INPUT").map((e) => e.textContent).join("").replace(/[\u00a0\u200B]/g, " ").trim())(o)) {
2370
2637
  let e = document.createElement("p");
2371
2638
  e.innerHTML = "\xA0", t.parentNode.insertBefore(e, t.nextSibling), o.remove(), t.children.length === 0 && t.remove();
2372
2639
  let r = document.createRange();
@@ -2376,46 +2643,46 @@ function Fn(e, t, n = {}) {
2376
2643
  if (r.deleteContents(), n.rangeCount === 0 || !o.isConnected) return !0;
2377
2644
  r = n.getRangeAt(0);
2378
2645
  }
2379
- let i = Pn(r, o), a = document.createElement("li"), s = document.createElement("input");
2646
+ let i = ur(r, o), a = document.createElement("li"), s = document.createElement("input");
2380
2647
  s.type = "checkbox", s.setAttribute("contenteditable", "false"), a.appendChild(s), i.textContent.replace(/[\u00a0\u200B]/g, "").length > 0 && a.appendChild(i);
2381
2648
  let c = a.childNodes[1];
2382
2649
  c?.nodeType !== Node.TEXT_NODE && (c = document.createTextNode("​"), a.appendChild(c)), o.after(a);
2383
2650
  let l = document.createRange();
2384
2651
  return l.setStart(c, 0), l.collapse(!0), n.removeAllRanges(), n.addRange(l), !0;
2385
2652
  }
2386
- let s = b(n.sc, t);
2387
- if (s?.nodeName.toUpperCase() === "PRE") return e.preventDefault(), T("insertText", "\n"), !0;
2653
+ let s = se(n.sc, t);
2654
+ if (s?.nodeName.toUpperCase() === "PRE") return e.preventDefault(), C("insertText", "\n"), !0;
2388
2655
  if (s?.nodeName.toUpperCase() === "BLOCKQUOTE") {
2389
2656
  let t = n.toNativeRange();
2390
- if (t.setEnd(s, s.childNodes.length), t.toString() === "" && n.isCollapsed()) return e.preventDefault(), T("formatBlock", "<p>"), !0;
2657
+ if (t.setEnd(s, s.childNodes.length), t.toString() === "" && n.isCollapsed()) return e.preventDefault(), C("formatBlock", "<p>"), !0;
2391
2658
  }
2392
2659
  }
2393
2660
  return !1;
2394
2661
  }
2395
2662
  //#endregion
2396
2663
  //#region src/js/core/count.js
2397
- var B = typeof Intl < "u" && typeof Intl.Segmenter == "function" ? new Intl.Segmenter(void 0, { granularity: "word" }) : null;
2398
- function In(e) {
2664
+ var R = typeof Intl < "u" && typeof Intl.Segmenter == "function" ? new Intl.Segmenter(void 0, { granularity: "word" }) : null;
2665
+ function fr(e) {
2399
2666
  let t = e.trim();
2400
2667
  if (!t) return 0;
2401
- if (B) {
2668
+ if (R) {
2402
2669
  let e = 0;
2403
- for (let n of B.segment(t)) n.isWordLike && e++;
2670
+ for (let n of R.segment(t)) n.isWordLike && e++;
2404
2671
  return e;
2405
2672
  }
2406
2673
  return t.split(/\s+/).length;
2407
2674
  }
2408
- var Ln = /* @__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("."));
2409
- function Rn(e, t, n) {
2675
+ var pr = /* @__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("."));
2676
+ function mr(e, t, n) {
2410
2677
  for (let r = e.firstChild; r; r = r.nextSibling) if (r.nodeType === 3) {
2411
2678
  let e = r.data;
2412
2679
  t.push(e), n.push(e);
2413
2680
  } else if (r.nodeType === 1) {
2414
- let e = Ln.has(r.tagName);
2415
- e && t.push("\n"), Rn(r, t, n), e && t.push("\n");
2681
+ let e = pr.has(r.tagName);
2682
+ e && t.push("\n"), mr(r, t, n), e && t.push("\n");
2416
2683
  }
2417
2684
  }
2418
- function zn(e) {
2685
+ function hr(e) {
2419
2686
  if (e.nodeType === 3) {
2420
2687
  let t = e.data;
2421
2688
  return {
@@ -2424,12 +2691,12 @@ function zn(e) {
2424
2691
  };
2425
2692
  }
2426
2693
  let t = [], n = [];
2427
- return Rn(e, t, n), {
2694
+ return mr(e, t, n), {
2428
2695
  lines: t.join(""),
2429
2696
  flat: n.join("")
2430
2697
  };
2431
2698
  }
2432
- var Bn = class {
2699
+ var gr = class {
2433
2700
  constructor() {
2434
2701
  this._cache = /* @__PURE__ */ new WeakMap();
2435
2702
  }
@@ -2441,7 +2708,7 @@ var Bn = class {
2441
2708
  t += e.words, n += e.chars;
2442
2709
  continue;
2443
2710
  }
2444
- let { lines: s, flat: c } = zn(o);
2711
+ let { lines: s, flat: c } = hr(o);
2445
2712
  r.push({
2446
2713
  node: o,
2447
2714
  key: c,
@@ -2450,7 +2717,7 @@ var Bn = class {
2450
2717
  }), i.push(s), a += s.length + 1;
2451
2718
  }
2452
2719
  if (r.length) {
2453
- let e = Vn(r, i.join("\n"));
2720
+ let e = _r(r, i.join("\n"));
2454
2721
  r.forEach((r, i) => {
2455
2722
  let a = {
2456
2723
  key: r.key,
@@ -2466,10 +2733,10 @@ var Bn = class {
2466
2733
  };
2467
2734
  }
2468
2735
  };
2469
- function Vn(e, t) {
2470
- if (!B) return e.map((e) => In(e.text));
2736
+ function _r(e, t) {
2737
+ if (!R) return e.map((e) => fr(e.text));
2471
2738
  let n = Array(e.length).fill(0), r = 0;
2472
- for (let i of B.segment(t)) if (i.isWordLike) {
2739
+ for (let i of R.segment(t)) if (i.isWordLike) {
2473
2740
  for (; r < e.length - 1 && i.index >= e[r + 1].start;) r++;
2474
2741
  n[r]++;
2475
2742
  }
@@ -2477,14 +2744,14 @@ function Vn(e, t) {
2477
2744
  }
2478
2745
  //#endregion
2479
2746
  //#region src/js/core/markdown.js
2480
- function Hn(e) {
2747
+ function vr(e) {
2481
2748
  let t = new DOMParser().parseFromString(`<body>${e || ""}</body>`, "text/html");
2482
- return ge(t.body), Yn(t.body).replace(/\n{3,}/g, "\n\n").trim();
2749
+ return ye(t.body), Tr(t.body).replace(/\n{3,}/g, "\n\n").trim();
2483
2750
  }
2484
- function V(e, t) {
2751
+ function z(e, t) {
2485
2752
  return Array.from(e.children).filter((e) => e.tagName === t.toUpperCase());
2486
2753
  }
2487
- function Un(e) {
2754
+ function yr(e) {
2488
2755
  let t = "";
2489
2756
  for (let n of e.childNodes) {
2490
2757
  if (n.nodeType === 3) {
@@ -2498,40 +2765,40 @@ function Un(e) {
2498
2765
  continue;
2499
2766
  }
2500
2767
  if (e === "div" || e === "p") {
2501
- t && !t.endsWith("\n") && (t += "\n"), t += Un(n), t += "\n";
2768
+ t && !t.endsWith("\n") && (t += "\n"), t += yr(n), t += "\n";
2502
2769
  continue;
2503
2770
  }
2504
- t += Un(n);
2771
+ t += yr(n);
2505
2772
  }
2506
2773
  return t;
2507
2774
  }
2508
- function Wn(e) {
2775
+ function br(e) {
2509
2776
  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`\~`);
2510
2777
  }
2511
- function Gn(e) {
2778
+ function xr(e) {
2512
2779
  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}`);
2513
2780
  }
2514
- function Kn(e) {
2515
- return e.split("\n").map(Gn).join("\n");
2781
+ function Sr(e) {
2782
+ return e.split("\n").map(xr).join("\n");
2516
2783
  }
2517
- function qn(e, t) {
2784
+ function Cr(e, t) {
2518
2785
  let n = " ".repeat(t + 1);
2519
- return Yn(e, t + 1).trim().split("\n").map((e, t) => t === 0 || e.trim() === "" || e.startsWith(n) ? e : n + e).join("\n");
2786
+ return Tr(e, t + 1).trim().split("\n").map((e, t) => t === 0 || e.trim() === "" || e.startsWith(n) ? e : n + e).join("\n");
2520
2787
  }
2521
- function Jn(e, t) {
2788
+ function wr(e, t) {
2522
2789
  let n = e.getAttribute(t) || "", r = /[\s()]/.test(n) ? `<${n}>` : n, i = e.getAttribute("title");
2523
2790
  return i ? `${r} "${i.replaceAll("\"", String.raw`\"`)}"` : r;
2524
2791
  }
2525
- function Yn(e, t = 0) {
2792
+ function Tr(e, t = 0) {
2526
2793
  if (e.nodeType === 3) {
2527
2794
  let t = e.textContent.replace(/\s+/g, " ");
2528
- return e.parentElement?.closest("pre, code") ? t : Wn(t);
2795
+ return e.parentElement?.closest("pre, code") ? t : br(t);
2529
2796
  }
2530
2797
  if (e.nodeType !== 1) return "";
2531
- let n = e, r = n.nodeName.toLowerCase(), i = () => Array.from(n.childNodes).map((e) => Yn(e, t)).join("");
2798
+ let n = e, r = n.nodeName.toLowerCase(), i = () => Array.from(n.childNodes).map((e) => Tr(e, t)).join("");
2532
2799
  switch (r) {
2533
2800
  case "p":
2534
- case "div": return `\n\n${Kn(i())}\n\n`;
2801
+ case "div": return `\n\n${Sr(i())}\n\n`;
2535
2802
  case "br": return " \n";
2536
2803
  case "h1": return `\n\n# ${i()}\n\n`;
2537
2804
  case "h2": return `\n\n## ${i()}\n\n`;
@@ -2560,27 +2827,27 @@ function Yn(e, t = 0) {
2560
2827
  }
2561
2828
  case "pre": {
2562
2829
  let e = n.querySelector("code"), t = /language-(\S+)/.exec(e?.className || "");
2563
- return `\n\n\`\`\`${t ? t[1] : ""}\n${Un(e || n).replace(/\n$/, "")}\n\`\`\`\n\n`;
2830
+ return `\n\n\`\`\`${t ? t[1] : ""}\n${yr(e || n).replace(/\n$/, "")}\n\`\`\`\n\n`;
2564
2831
  }
2565
2832
  case "blockquote": {
2566
2833
  let e = i().trim().split("\n");
2567
2834
  return `\n\n${e.filter((t, n) => t.trim() !== "" || (e[n - 1] ?? "").trim() !== "").map((e) => e.trim() === "" ? ">" : `> ${e}`).join("\n")}\n\n`;
2568
2835
  }
2569
- case "a": return `[${i()}](${Jn(n, "href")})`;
2570
- case "img": return `![${Wn(n.getAttribute("alt") || "")}](${Jn(n, "src")})`;
2836
+ case "a": return `[${i()}](${wr(n, "href")})`;
2837
+ case "img": return `![${br(n.getAttribute("alt") || "")}](${wr(n, "src")})`;
2571
2838
  case "ul": {
2572
- let e = V(n, "li");
2839
+ let e = z(n, "li");
2573
2840
  if (!e.length) return i();
2574
2841
  let r = " ".repeat(t), a = n.classList.contains("an-checklist"), o = e.map((e) => {
2575
- let n = V(e, "input").find((e) => e.getAttribute("type") === "checkbox"), i = "- ";
2576
- return (a || n) && (i = n && n.checked ? "- [x] " : "- [ ] "), `${r}${i}${qn(e, t)}`;
2842
+ let n = z(e, "input").find((e) => e.getAttribute("type") === "checkbox"), i = "- ";
2843
+ return (a || n) && (i = n && n.checked ? "- [x] " : "- [ ] "), `${r}${i}${Cr(e, t)}`;
2577
2844
  }).join("\n");
2578
2845
  return t === 0 ? `\n\n${o}\n\n` : `\n${o}`;
2579
2846
  }
2580
2847
  case "ol": {
2581
- let e = V(n, "li");
2848
+ let e = z(n, "li");
2582
2849
  if (!e.length) return i();
2583
- 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}. ${qn(e, t)}`).join("\n");
2850
+ 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}. ${Cr(e, t)}`).join("\n");
2584
2851
  return t === 0 ? `\n\n${s}\n\n` : `\n${s}`;
2585
2852
  }
2586
2853
  case "li": return i();
@@ -2588,7 +2855,7 @@ function Yn(e, t = 0) {
2588
2855
  case "table": {
2589
2856
  let e = Array.from(n.querySelectorAll("tr"));
2590
2857
  if (!e.length) return i();
2591
- let t = !!V(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) => Wn(e.textContent.trim()).replaceAll("|", String.raw`\|`))), a = Math.max(...r.map((e) => e.length)), o = (e) => {
2858
+ 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) => br(e.textContent.trim()).replaceAll("|", String.raw`\|`))), a = Math.max(...r.map((e) => e.length)), o = (e) => {
2592
2859
  let t = [...e];
2593
2860
  for (; t.length < a;) t.push("");
2594
2861
  return t;
@@ -2603,16 +2870,16 @@ function Yn(e, t = 0) {
2603
2870
  default: return i();
2604
2871
  }
2605
2872
  }
2606
- function Xn(e) {
2873
+ function Er(e) {
2607
2874
  return String(e ?? "").replace(/^\ufeff/, "");
2608
2875
  }
2609
- function Zn(e) {
2610
- let t = Xn(e);
2876
+ function Dr(e) {
2877
+ let t = Er(e);
2611
2878
  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);
2612
2879
  }
2613
- var H = /^ {0,3}>( ?)(.*)$/, Qn = /^(?: {4}|\t)\s*\S/, $n = /^( {0,3})(`{3,}|~{3,})[ \t]*([^\s`~][^\n]*)?$/;
2614
- function U(e) {
2615
- let t = $n.exec(e);
2880
+ var B = /^ {0,3}>( ?)(.*)$/, Or = /^(?: {4}|\t)\s*\S/, kr = /^( {0,3})(`{3,}|~{3,})[ \t]*([^\s`~][^\n]*)?$/;
2881
+ function V(e) {
2882
+ let t = kr.exec(e);
2616
2883
  if (!t) return null;
2617
2884
  let [, n, r, i = ""] = t;
2618
2885
  return r[0] === "`" && i.includes("`") ? null : {
@@ -2622,7 +2889,7 @@ function U(e) {
2622
2889
  lang: i.trim().split(/\s+/)[0] || ""
2623
2890
  };
2624
2891
  }
2625
- function er(e, t) {
2892
+ function Ar(e, t) {
2626
2893
  let n = 0, r = 0;
2627
2894
  for (; r < e.length && n < t;) {
2628
2895
  if (e[r] === " ") {
@@ -2639,40 +2906,40 @@ function er(e, t) {
2639
2906
  }
2640
2907
  return e.slice(r);
2641
2908
  }
2642
- var tr = /^ {0,3}([-*_])( *\1){2,}\s*$/, nr = "";
2643
- function rr(e) {
2644
- let t = Xn(e).replaceAll("\r\n", "\n").replaceAll("\r", "\n").split("\n");
2645
- t = sr(t);
2646
- let n = cr(t);
2647
- return t = n.clean, ar = n.linkDefs, or = n.footnoteIds, ir(t);
2909
+ var jr = /^ {0,3}([-*_])( *\1){2,}\s*$/, Mr = "";
2910
+ function H(e) {
2911
+ let t = Er(e).replaceAll("\r\n", "\n").replaceAll("\r", "\n").split("\n");
2912
+ t = Ir(t);
2913
+ let n = Lr(t);
2914
+ return t = n.clean, Pr = n.linkDefs, Fr = n.footnoteIds, Nr(t);
2648
2915
  }
2649
- function ir(e) {
2916
+ function Nr(e) {
2650
2917
  let t = [], n = 0;
2651
2918
  for (; n < e.length;) {
2652
- let r = e[n], i = U(r);
2919
+ let r = e[n], i = V(r);
2653
2920
  if (i) {
2654
2921
  let r = RegExp(`^ {0,3}\\${i.marker}{${i.length},}[ \t]*$`), a = [];
2655
- for (n++; n < e.length && !r.test(e[n]);) a.push(Ar(er(e[n], i.indent))), n++;
2922
+ for (n++; n < e.length && !r.test(e[n]);) a.push(ii(Ar(e[n], i.indent))), n++;
2656
2923
  let o = i.lang ? ` class="language-${q(i.lang)}"` : "";
2657
2924
  t.push(`<pre><code${o}>${a.join("\n")}</code></pre>`), n++;
2658
2925
  continue;
2659
2926
  }
2660
- if (Qn.test(r)) {
2927
+ if (Or.test(r)) {
2661
2928
  let r = [];
2662
- for (; n < e.length && (Qn.test(e[n]) || e[n].trim() === "");) {
2929
+ for (; n < e.length && (Or.test(e[n]) || e[n].trim() === "");) {
2663
2930
  if (e[n].trim() === "") {
2664
2931
  let t = n;
2665
2932
  for (; t < e.length && e[t].trim() === "";) t++;
2666
- if (t >= e.length || !Qn.test(e[t])) break;
2933
+ if (t >= e.length || !Or.test(e[t])) break;
2667
2934
  for (; n < t; n++) r.push("");
2668
2935
  continue;
2669
2936
  }
2670
- r.push(Ar(er(e[n], 4))), n++;
2937
+ r.push(ii(Ar(e[n], 4))), n++;
2671
2938
  }
2672
2939
  t.push(`<pre><code>${r.join("\n")}</code></pre>`);
2673
2940
  continue;
2674
2941
  }
2675
- if (r.trim() && !tr.test(r) && !/^#{1,6} /.test(r) && n + 1 < e.length) {
2942
+ if (r.trim() && !jr.test(r) && !/^#{1,6} /.test(r) && n + 1 < e.length) {
2676
2943
  if (/^=+\s*$/.test(e[n + 1])) {
2677
2944
  t.push(`<h1>${K(r.trim())}</h1>`), n += 2;
2678
2945
  continue;
@@ -2682,7 +2949,7 @@ function ir(e) {
2682
2949
  continue;
2683
2950
  }
2684
2951
  }
2685
- if (tr.test(r)) {
2952
+ if (jr.test(r)) {
2686
2953
  t.push("<hr>"), n++;
2687
2954
  continue;
2688
2955
  }
@@ -2692,19 +2959,19 @@ function ir(e) {
2692
2959
  t.push(`<h${e}>${K(r)}</h${e}>`), n++;
2693
2960
  continue;
2694
2961
  }
2695
- if (H.test(r)) {
2962
+ if (B.test(r)) {
2696
2963
  let r = [];
2697
- for (; n < e.length && H.test(e[n]);) r.push(H.exec(e[n])[2]), n++;
2698
- t.push(`<blockquote>${ir(r)}</blockquote>`);
2964
+ for (; n < e.length && B.test(e[n]);) r.push(B.exec(e[n])[2]), n++;
2965
+ t.push(`<blockquote>${Nr(r)}</blockquote>`);
2699
2966
  continue;
2700
2967
  }
2701
2968
  if (/^[-*+] /.test(r)) {
2702
- let { html: r, endIdx: i } = pr(e, n);
2969
+ let { html: r, endIdx: i } = Hr(e, n);
2703
2970
  t.push(r), n = i;
2704
2971
  continue;
2705
2972
  }
2706
2973
  if (/^\d+[.)] /.test(r)) {
2707
- let { html: r, endIdx: i } = pr(e, n);
2974
+ let { html: r, endIdx: i } = Hr(e, n);
2708
2975
  t.push(r), n = i;
2709
2976
  continue;
2710
2977
  }
@@ -2712,23 +2979,23 @@ function ir(e) {
2712
2979
  n++;
2713
2980
  continue;
2714
2981
  }
2715
- if (fr(e, n)) {
2716
- let i = W(r), a = W(e[n + 1]).map((e) => e.startsWith(":") && e.endsWith(":") ? "center" : e.endsWith(":") ? "right" : e.startsWith(":") ? "left" : null);
2982
+ if (Vr(e, n)) {
2983
+ let i = U(r), a = U(e[n + 1]).map((e) => e.startsWith(":") && e.endsWith(":") ? "center" : e.endsWith(":") ? "right" : e.startsWith(":") ? "left" : null);
2717
2984
  n += 2;
2718
2985
  let o = [];
2719
- for (; n < e.length && e[n].trim() !== "" && dr(e[n]);) o.push(W(e[n])), n++;
2986
+ for (; n < e.length && e[n].trim() !== "" && Br(e[n]);) o.push(U(e[n])), n++;
2720
2987
  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>` : "";
2721
2988
  t.push(`<table>${c}${l}</table>`);
2722
2989
  continue;
2723
2990
  }
2724
2991
  let o = [];
2725
- for (; n < e.length && e[n].trim() !== "" && !/^(#{1,6} |[-*+] |\d+[.)] )/.test(e[n]) && !U(e[n]) && !H.test(e[n]) && !tr.test(e[n]) && !fr(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++;
2726
- o.length ? t.push(`<p>${K(lr(o)).replaceAll(nr, "<br>")}</p>`) : (t.push(`<p>${K(r)}</p>`), n++);
2992
+ for (; n < e.length && e[n].trim() !== "" && !/^(#{1,6} |[-*+] |\d+[.)] )/.test(e[n]) && !V(e[n]) && !B.test(e[n]) && !jr.test(e[n]) && !Vr(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++;
2993
+ o.length ? t.push(`<p>${K(Rr(o)).replaceAll(Mr, "<br>")}</p>`) : (t.push(`<p>${K(r)}</p>`), n++);
2727
2994
  }
2728
2995
  return t.join("");
2729
2996
  }
2730
- var ar = /* @__PURE__ */ new Map(), or = /* @__PURE__ */ new Set();
2731
- function sr(e) {
2997
+ var Pr = /* @__PURE__ */ new Map(), Fr = /* @__PURE__ */ new Set();
2998
+ function Ir(e) {
2732
2999
  if ((e[0] || "").trim() !== "---") return e;
2733
3000
  let t = -1;
2734
3001
  for (let n = 1; n < e.length; n++) {
@@ -2742,14 +3009,14 @@ function sr(e) {
2742
3009
  let n = t + 1;
2743
3010
  return e[n] !== void 0 && e[n].trim() === "" && n++, e.slice(n);
2744
3011
  }
2745
- function cr(e) {
3012
+ function Lr(e) {
2746
3013
  let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set(), r = [], i = !1, a = /^\[([^\]]+)\]:\s*(\S+)(?:\s+"([^"]*)")?\s*$/, o = /^\[\^([^\]]+)\]:[ \t]*(\S.*)$/;
2747
3014
  for (let s of e) {
2748
3015
  if (i) {
2749
3016
  /^ {0,3}(?:`{3,}|~{3,})[ \t]*$/.test(s) && (i = !1), r.push(s);
2750
3017
  continue;
2751
3018
  }
2752
- if (U(s)) {
3019
+ if (V(s)) {
2753
3020
  i = !0, r.push(s);
2754
3021
  continue;
2755
3022
  }
@@ -2776,36 +3043,36 @@ function cr(e) {
2776
3043
  footnoteIds: n
2777
3044
  };
2778
3045
  }
2779
- function lr(e) {
3046
+ function Rr(e) {
2780
3047
  let t = "";
2781
3048
  for (let n = 0; n < e.length; n++) {
2782
3049
  let r = n === e.length - 1, i = e[n].replace(/^[ \t]+/, "");
2783
3050
  if (!r && /\\$/.test(i)) {
2784
- t += i.replace(/\\$/, "") + nr;
3051
+ t += i.replace(/\\$/, "") + Mr;
2785
3052
  continue;
2786
3053
  }
2787
3054
  if (!r && / {2,}$/.test(i)) {
2788
- t += i.replace(/ {2,}$/, "") + nr;
3055
+ t += i.replace(/ {2,}$/, "") + Mr;
2789
3056
  continue;
2790
3057
  }
2791
3058
  t += i + (r ? "" : " ");
2792
3059
  }
2793
3060
  return t;
2794
3061
  }
2795
- function ur(e) {
2796
- return W(e).length;
3062
+ function zr(e) {
3063
+ return U(e).length;
2797
3064
  }
2798
- function dr(e) {
2799
- return e.includes("|") ? /^\s*\|/.test(e) || ur(e) > 1 : !1;
3065
+ function Br(e) {
3066
+ return e.includes("|") ? /^\s*\|/.test(e) || zr(e) > 1 : !1;
2800
3067
  }
2801
- function fr(e, t) {
3068
+ function Vr(e, t) {
2802
3069
  let n = e[t], r = e[t + 1];
2803
3070
  if (r === void 0 || !n.includes("|")) return !1;
2804
3071
  if (/^\|.+\|/.test(n)) return /^\|[\s|:-]+\|/.test(r);
2805
- let i = W(r);
2806
- return i.length < 2 || !i.every((e) => /^:?-+:?$/.test(e)) ? !1 : ur(n) === i.length;
3072
+ let i = U(r);
3073
+ return i.length < 2 || !i.every((e) => /^:?-+:?$/.test(e)) ? !1 : zr(n) === i.length;
2807
3074
  }
2808
- function W(e) {
3075
+ function U(e) {
2809
3076
  let t = e.replace(/^\|/, "").replace(/\|$/, ""), n = [], r = "";
2810
3077
  for (let e = 0; e < t.length; e++) {
2811
3078
  if (t[e] === "\\" && t[e + 1] === "|") {
@@ -2820,7 +3087,7 @@ function W(e) {
2820
3087
  }
2821
3088
  return n.push(r), n.map((e) => e.trim());
2822
3089
  }
2823
- function pr(e, t) {
3090
+ function Hr(e, t) {
2824
3091
  let n = e[t].match(/^(\s*)/)[1].length, r = /^\s*\d+[.)] /.test(e[t]), i = [], a = null, o = !1, s = !1, c = t;
2825
3092
  for (; c < e.length;) {
2826
3093
  let t = e[c];
@@ -2848,15 +3115,15 @@ function pr(e, t) {
2848
3115
  c++;
2849
3116
  continue;
2850
3117
  }
2851
- let n = (e) => er(e, l), r = U(n(t));
3118
+ let n = (e) => Ar(e, l), r = V(n(t));
2852
3119
  if (r) {
2853
3120
  let t = RegExp(`^ {0,3}\\${r.marker}{${r.length},}[ \t]*$`), a = [n(e[c])];
2854
3121
  for (c++; c < e.length && !t.test(n(e[c]));) a.push(n(e[c])), c++;
2855
- c < e.length && (a.push(n(e[c])), c++), i[i.length - 1].sub += ir(a), s = !1;
3122
+ c < e.length && (a.push(n(e[c])), c++), i[i.length - 1].sub += Nr(a), s = !1;
2856
3123
  continue;
2857
3124
  }
2858
3125
  if (/^\s*(?:[-*+]|\d+[.)]) /.test(t)) {
2859
- let t = pr(e, c);
3126
+ let t = Hr(e, c);
2860
3127
  i[i.length - 1].sub += t.html, c = t.endIdx, s = !1;
2861
3128
  } else if (s) i[i.length - 1].paras.push(t.trim()), s = !1, c++;
2862
3129
  else {
@@ -2874,32 +3141,32 @@ function pr(e, t) {
2874
3141
  endIdx: c
2875
3142
  };
2876
3143
  }
2877
- var mr = /\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g, G = "\0", hr = "", gr = /(`+)([^]*?)\1/g;
2878
- function _r(e) {
3144
+ var Ur = /\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g, W = "\0", G = "", Wr = /(`+)([^]*?)\1/g;
3145
+ function Gr(e) {
2879
3146
  let t = [];
2880
3147
  return {
2881
- text: e.replace(gr, (e, n, r) => r === "" ? e : (t.push(r), `${hr}${t.length - 1}${hr}`)),
3148
+ text: e.replace(Wr, (e, n, r) => r === "" ? e : (t.push(r), `${G}${t.length - 1}${G}`)),
2882
3149
  codes: t
2883
3150
  };
2884
3151
  }
2885
- function vr(e, t, n) {
2886
- return e.replace(RegExp(`${hr}(\\d+)${hr}`, "g"), (e, r) => {
3152
+ function Kr(e, t, n) {
3153
+ return e.replace(RegExp(`${G}(\\d+)${G}`, "g"), (e, r) => {
2887
3154
  let i = t[Number(r)];
2888
- return i = i.replace(RegExp(`${G}(\\d+)${G}`, "g"), (e, t) => `\\${n[Number(t)]}`), i.length > 2 && i.startsWith(" ") && i.endsWith(" ") && i.trim() !== "" && (i = i.slice(1, -1)), `<code>${Ar(i)}</code>`;
3155
+ 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>${ii(i)}</code>`;
2889
3156
  });
2890
3157
  }
2891
- function yr(e) {
3158
+ function qr(e) {
2892
3159
  let t = [];
2893
3160
  return {
2894
- text: e.replace(mr, (e, n) => (t.push(n), `${G}${t.length - 1}${G}`)),
3161
+ text: e.replace(Ur, (e, n) => (t.push(n), `${W}${t.length - 1}${W}`)),
2895
3162
  literals: t
2896
3163
  };
2897
3164
  }
2898
- function br(e, t) {
2899
- return e.replace(RegExp(`${G}(\\d+)${G}`, "g"), (e, n) => kr(t[Number(n)]));
3165
+ function Jr(e, t) {
3166
+ return e.replace(RegExp(`${W}(\\d+)${W}`, "g"), (e, n) => ri(t[Number(n)]));
2900
3167
  }
2901
- var xr = String.raw`(&lt;.*?&gt;(?:\s+(?:"[^"]*"|'[^']*'))?|[^)]*)`, Sr = new RegExp(String.raw`!\[([^\]]*)\]\(${xr}\)`, "g"), Cr = new RegExp(String.raw`\[([^\]]+)\]\(${xr}\)`, "g");
2902
- function wr(e) {
3168
+ var Yr = String.raw`(&lt;.*?&gt;(?:\s+(?:"[^"]*"|'[^']*'))?|[^)]*)`, Xr = new RegExp(String.raw`!\[([^\]]*)\]\(${Yr}\)`, "g"), Zr = new RegExp(String.raw`\[([^\]]+)\]\(${Yr}\)`, "g");
3169
+ function Qr(e) {
2903
3170
  let t = e.trim(), n = /^&lt;([\s\S]*?)&gt;(?:[ \t]*(?:"([^"]*)"|'([^']*)'))?[ \t]*$/.exec(t);
2904
3171
  if (n) return {
2905
3172
  href: n[1],
@@ -2914,26 +3181,26 @@ function wr(e) {
2914
3181
  title: ""
2915
3182
  };
2916
3183
  }
2917
- function Tr(e) {
2918
- return e = e.replace(Sr, (e, t, n) => {
2919
- let { href: r, title: i } = wr(n), a = i ? ` title="${J(i)}"` : "";
3184
+ function $r(e) {
3185
+ return e = e.replace(Xr, (e, t, n) => {
3186
+ let { href: r, title: i } = Qr(n), a = i ? ` title="${J(i)}"` : "";
2920
3187
  return `<img src="${J(r)}" alt="${J(t)}"${a} class="an-image">`;
2921
- }), e = e.replace(Cr, (e, t, n) => {
2922
- let { href: r, title: i } = wr(n), a = i ? ` title="${J(i)}"` : "";
3188
+ }), e = e.replace(Zr, (e, t, n) => {
3189
+ let { href: r, title: i } = Qr(n), a = i ? ` title="${J(i)}"` : "";
2923
3190
  return `<a href="${J(r)}"${a}>${t}</a>`;
2924
3191
  }), e = e.replace(/\[([^\]]+)\]\[([^\]]*)\]/g, (e, t, n) => {
2925
- let r = ar.get(jr(n || t).trim().toLowerCase());
3192
+ let r = Pr.get(ai(n || t).trim().toLowerCase());
2926
3193
  if (!r) return e;
2927
3194
  let i = r.title ? ` title="${q(r.title)}"` : "";
2928
3195
  return `<a href="${q(r.href)}"${i}>${t}</a>`;
2929
3196
  }), e = e.replace(/\[([^\]]+)\]/g, (e, t) => {
2930
- let n = ar.get(jr(t).trim().toLowerCase());
3197
+ let n = Pr.get(ai(t).trim().toLowerCase());
2931
3198
  if (!n) return e;
2932
3199
  let r = n.title ? ` title="${q(n.title)}"` : "";
2933
3200
  return `<a href="${q(n.href)}"${r}>${t}</a>`;
2934
- }), e = e.replace(/\[\^([^\]]+)\]/g, (e, t) => or.has(jr(t)) ? `<sup>[${t}]</sup>` : e), e;
3201
+ }), e = e.replace(/\[\^([^\]]+)\]/g, (e, t) => Fr.has(ai(t)) ? `<sup>[${t}]</sup>` : e), e;
2935
3202
  }
2936
- function Er(e) {
3203
+ function ei(e) {
2937
3204
  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) => {
2938
3205
  let r = /[.,;:!?)]+$/.exec(n), i = r ? n.slice(0, -r[0].length) : n;
2939
3206
  if (!i) return e;
@@ -2941,18 +3208,18 @@ function Er(e) {
2941
3208
  return `${t}<a href="${J(i)}">${i}</a>${a}`;
2942
3209
  }), e;
2943
3210
  }
2944
- function Dr(e) {
3211
+ function ti(e) {
2945
3212
  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;
2946
3213
  }
2947
3214
  function K(e) {
2948
- let { text: t, literals: n } = yr(e), { text: r, codes: i } = _r(t), a = kr(r);
2949
- return a = Tr(a), a = Er(a), a = Dr(a), vr(br(a, n), i, n);
3215
+ let { text: t, literals: n } = qr(e), { text: r, codes: i } = Gr(t), a = ri(r);
3216
+ return a = $r(a), a = ei(a), a = ti(a), Kr(Jr(a, n), i, n);
2950
3217
  }
2951
- var Or = /&(?!#\d+;|#[xX][0-9a-fA-F]+;|[a-zA-Z][a-zA-Z0-9]*;)/g;
2952
- function kr(e) {
2953
- return String(e).replace(Or, "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
3218
+ var ni = /&(?!#\d+;|#[xX][0-9a-fA-F]+;|[a-zA-Z][a-zA-Z0-9]*;)/g;
3219
+ function ri(e) {
3220
+ return String(e).replace(ni, "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
2954
3221
  }
2955
- function Ar(e) {
3222
+ function ii(e) {
2956
3223
  return String(e).replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
2957
3224
  }
2958
3225
  function q(e) {
@@ -2961,16 +3228,16 @@ function q(e) {
2961
3228
  function J(e) {
2962
3229
  return String(e).replaceAll("\"", "&quot;").replaceAll("'", "&#39;");
2963
3230
  }
2964
- function jr(e) {
3231
+ function ai(e) {
2965
3232
  return String(e).replaceAll("&lt;", "<").replaceAll("&gt;", ">").replaceAll("&amp;", "&");
2966
3233
  }
2967
3234
  //#endregion
2968
3235
  //#region src/js/core/detectLang.js
2969
- var Mr = 5, Nr = 2, Pr = [
3236
+ var oi = 5, si = 2, ci = [
2970
3237
  ["typescript", "javascript"],
2971
3238
  ["scss", "css"],
2972
3239
  ["cpp", "c"]
2973
- ], Fr = [
3240
+ ], li = [
2974
3241
  "javascript",
2975
3242
  "typescript",
2976
3243
  "python",
@@ -2993,7 +3260,7 @@ var Mr = 5, Nr = 2, Pr = [
2993
3260
  "scss",
2994
3261
  "css",
2995
3262
  "bash"
2996
- ], Ir = [
3263
+ ], ui = [
2997
3264
  {
2998
3265
  lang: "php",
2999
3266
  w: 10,
@@ -3559,27 +3826,27 @@ var Mr = 5, Nr = 2, Pr = [
3559
3826
  w: 3,
3560
3827
  re: /\s\|[ \t]*\w|\s&&\s|\s2>&1|\s-[\w-]+\s/
3561
3828
  }
3562
- ], Lr = 4e3;
3563
- function Rr(e) {
3564
- if (e.length <= Lr) return e;
3565
- let t = e.slice(0, Lr), n = t.lastIndexOf("\n");
3829
+ ], di = 4e3;
3830
+ function fi(e) {
3831
+ if (e.length <= di) return e;
3832
+ let t = e.slice(0, di), n = t.lastIndexOf("\n");
3566
3833
  return n > 0 ? t.slice(0, n) : t;
3567
3834
  }
3568
- function zr(e) {
3835
+ function pi(e) {
3569
3836
  if (!e?.trim()) return null;
3570
- let t = Rr(e.trim()), n = /* @__PURE__ */ new Map();
3571
- for (let { lang: e, re: r, w: i } of Ir) r.test(t) && n.set(e, (n.get(e) || 0) + i);
3837
+ let t = fi(e.trim()), n = /* @__PURE__ */ new Map();
3838
+ for (let { lang: e, re: r, w: i } of ui) r.test(t) && n.set(e, (n.get(e) || 0) + i);
3572
3839
  if (n.size === 0) return null;
3573
- for (let [e, t] of Pr) {
3840
+ for (let [e, t] of ci) {
3574
3841
  let r = n.get(e);
3575
3842
  r && n.set(e, r + (n.get(t) || 0));
3576
3843
  }
3577
3844
  let r = [...n.entries()].sort((e, t) => t[1] - e[1]), [i, a] = r[0], o = r[1]?.[1] ?? 0;
3578
- return a < Mr || a - o < Nr ? null : i;
3845
+ return a < oi || a - o < si ? null : i;
3579
3846
  }
3580
3847
  //#endregion
3581
3848
  //#region src/js/module/Editor.js
3582
- var Br = /* @__PURE__ */ new Set([
3849
+ var mi = /* @__PURE__ */ new Set([
3583
3850
  "PRE",
3584
3851
  "BLOCKQUOTE",
3585
3852
  "TABLE",
@@ -3587,13 +3854,28 @@ var Br = /* @__PURE__ */ new Set([
3587
3854
  "UL",
3588
3855
  "OL",
3589
3856
  "HR"
3590
- ]), Vr = class {
3857
+ ]), hi = {
3858
+ undo: { run: (e) => e.undo() },
3859
+ redo: { run: (e) => e.redo() },
3860
+ bold: { run: (e) => e.bold() },
3861
+ italic: { run: (e) => e.italic() },
3862
+ underline: { run: (e) => e.underline() },
3863
+ inlineCode: { run: (e) => e.inlineCode() },
3864
+ link: { run: (e) => e.context.invoke("linkDialog.show") },
3865
+ find: { run: (e) => e.context.invoke("findReplace.show", "find") },
3866
+ findReplace: { run: (e) => e.context.invoke("findReplace.show", "replace") },
3867
+ shortcuts: { run: (e) => e.context.invoke("shortcutsDialog.show") },
3868
+ pastePlainText: {
3869
+ run: (e) => e.context.invoke("clipboard.setForcePlain", !0),
3870
+ preventDefault: !1
3871
+ }
3872
+ }, gi = class {
3591
3873
  constructor(e) {
3592
3874
  this.context = e, this.options = e.options, this._history = null, this._disposers = [], this._snapshotTimer = null, this._limitCounter = null;
3593
3875
  }
3594
3876
  initialize() {
3595
3877
  let e = this.context.layoutInfo.editable;
3596
- return this._history = new On(e, this.options.historyLimit || 100, this.options.historyMaxBytes || 10 * 1024 * 1024), this._bindEvents(e), this;
3878
+ return this._history = new Zn(e, this.options.historyLimit || 100, this.options.historyMaxBytes || 10485760), this._bindEvents(e), this;
3597
3879
  }
3598
3880
  destroy() {
3599
3881
  this._disposers.forEach((e) => e()), this._disposers = [], this._history = null, clearTimeout(this._snapshotTimer), this._snapshotTimer = null;
@@ -3602,7 +3884,7 @@ var Br = /* @__PURE__ */ new Set([
3602
3884
  let t = (e) => this._onKeydown(e), n = () => this.afterCommand(), r = (e) => this._enforceLimit(e), i = () => {
3603
3885
  if (!this.context._alive) return;
3604
3886
  let t = globalThis.getSelection();
3605
- t?.rangeCount > 0 && e.contains(t.anchorNode) && (this.context.invoke("toolbar.refresh"), typeof this.options.onSelectionChange == "function" && this.options.onSelectionChange(this.context));
3887
+ t?.rangeCount > 0 && e.contains(t.anchorNode) && (this.context.invoke("toolbar.refresh"), this.context.triggerEvent("selectionChange", this.context));
3606
3888
  }, a = (e) => {
3607
3889
  e.target.type === "checkbox" && e.target.closest(".an-checklist") && this.afterCommand();
3608
3890
  }, o = (t) => {
@@ -3635,18 +3917,18 @@ var Br = /* @__PURE__ */ new Set([
3635
3917
  }
3636
3918
  l ? c.setStart(l, 0) : c.setStartAfter(s), c.collapse(!0), n.removeAllRanges(), n.addRange(c);
3637
3919
  }, s = () => this.context.layoutInfo.container.classList.contains("an-disabled");
3638
- 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) => {
3920
+ this._disposers.push(x(e, "keydown", t), x(e, "beforeinput", r), x(e, "input", n), x(document, "selectionchange", i), x(e, "click", a), x(e, "mouseup", o), x(e, "keyup", o), x(e, "dragstart", (e) => {
3639
3921
  if (s()) {
3640
3922
  e.preventDefault();
3641
3923
  return;
3642
3924
  }
3643
3925
  let t = e.target;
3644
3926
  t && (t.nodeName === "IFRAME" || t.closest(".an-video-wrapper")) && e.preventDefault();
3645
- }), C(e, "drop", (e) => {
3927
+ }), x(e, "drop", (e) => {
3646
3928
  s() && e.preventDefault();
3647
3929
  }));
3648
3930
  let c = null;
3649
- this._disposers.push(C(e, "compositionstart", () => {
3931
+ this._disposers.push(x(e, "compositionstart", () => {
3650
3932
  let e = globalThis.getSelection();
3651
3933
  if (!e?.rangeCount) {
3652
3934
  c = null;
@@ -3657,7 +3939,7 @@ var Br = /* @__PURE__ */ new Set([
3657
3939
  let e = t;
3658
3940
  c = e.closest("sup") ? "superscript" : e.closest("sub") ? "subscript" : null;
3659
3941
  }
3660
- }), C(e, "compositionend", () => {
3942
+ }), x(e, "compositionend", () => {
3661
3943
  let e = c;
3662
3944
  if (c = null, !e) return;
3663
3945
  let t = globalThis.getSelection();
@@ -3670,58 +3952,41 @@ var Br = /* @__PURE__ */ new Set([
3670
3952
  }
3671
3953
  _onKeydown(e) {
3672
3954
  let t = this.context.layoutInfo.editable;
3673
- if (!Fn(e, t, this.options)) {
3674
- if (L(e, "z") && !e.shiftKey) {
3675
- e.preventDefault(), this.undo();
3676
- return;
3677
- }
3678
- if (L(e, "z") && e.shiftKey || L(e, "y")) {
3679
- e.preventDefault(), this.redo();
3680
- return;
3681
- }
3682
- if (L(e, "b")) {
3683
- e.preventDefault(), this.bold();
3684
- return;
3685
- }
3686
- if (L(e, "i")) {
3687
- e.preventDefault(), this.italic();
3688
- return;
3689
- }
3690
- if (L(e, "u")) {
3691
- e.preventDefault(), this.underline();
3692
- return;
3693
- }
3694
- if (L(e, "k")) {
3695
- e.preventDefault(), this.context.invoke("linkDialog.show");
3696
- return;
3697
- }
3698
- if (L(e, "v") && e.shiftKey) {
3699
- this.context.invoke("clipboard.setForcePlain", !0);
3700
- return;
3701
- }
3702
- if (e.key === "/" && e.shiftKey && e.ctrlKey && !e.metaKey) {
3703
- e.preventDefault(), this.context.invoke("shortcutsDialog.show");
3704
- return;
3705
- }
3706
- if (L(e, "f")) {
3707
- e.preventDefault(), this.context.invoke("findReplace.show", "find");
3708
- return;
3709
- }
3710
- L(e, "h") && (e.preventDefault(), this.context.invoke("findReplace.show", "replace")), L(e, "`") && (e.preventDefault(), this.inlineCode());
3955
+ dr(e, t, this.options) || this._runShortcut(e);
3956
+ }
3957
+ _runShortcut(e) {
3958
+ if (!e.ctrlKey && !e.metaKey && !e.altKey) return !1;
3959
+ for (let t of this.getKeyBindings()) {
3960
+ if (!rr(e, t.parsed)) continue;
3961
+ let { command: n } = t, r = typeof n == "string" ? n : t.combo;
3962
+ if (this.context.triggerEvent("beforeCommand", {
3963
+ name: r,
3964
+ source: "shortcut",
3965
+ event: e
3966
+ }) === !1) return e.preventDefault(), !0;
3967
+ if (typeof n == "function") return n(this.context, e) !== !1 && e.preventDefault(), !0;
3968
+ let i = hi[n];
3969
+ if (i) return i.preventDefault !== !1 && e.preventDefault(), i.run(this), !0;
3970
+ let a = bt(n, this.options);
3971
+ return a && typeof a.action == "function" && !a.type ? (e.preventDefault(), a.action(this.context), this.afterCommand(), !0) : (console.warn(`[AutumnNote] keyMap: unknown command "${n}".`), !1);
3711
3972
  }
3973
+ return !1;
3974
+ }
3975
+ getKeyBindings() {
3976
+ return (!this._keyBindings || this._keyMapSource !== this.options.keyMap) && (this._keyMapSource = this.options.keyMap, this._keyBindings = ir(this.options.keyMap)), this._keyBindings;
3712
3977
  }
3713
3978
  _enforceLimit(e) {
3714
3979
  let t = this.options.maxChars || 0, n = this.options.maxWords || 0;
3715
3980
  if (!t && !n) return;
3716
- this._limitCounter ??= new Bn();
3981
+ this._limitCounter ??= new gr();
3717
3982
  let r = e.inputType || "";
3718
3983
  if (r.startsWith("delete") || r === "historyUndo" || r === "historyRedo" || r === "insertFromPaste" || r === "insertFromDrop" || !r.startsWith("insert")) return;
3719
3984
  let { words: i, chars: a } = this._limitCounter.counts(this.context.layoutInfo.editable);
3720
3985
  if (t && a >= t) {
3721
- e.preventDefault(), typeof this.options.onCharLimitReached == "function" && this.options.onCharLimitReached(this.context);
3986
+ e.preventDefault(), this.context.triggerEvent("charLimitReached", this.context);
3722
3987
  return;
3723
3988
  }
3724
- n && (e.data === " " || r === "insertParagraph" || r === "insertLineBreak") && i >= n && (e.preventDefault(), typeof this.options.onWordLimitReached == "function" && this.options.onWordLimitReached(this.context));
3989
+ n && (e.data === " " || r === "insertParagraph" || r === "insertLineBreak") && i >= n && (e.preventDefault(), this.context.triggerEvent("wordLimitReached", this.context));
3725
3990
  }
3726
3991
  afterCommand() {
3727
3992
  this._cleanOrphanedFigures(), this._ensureTrailingParagraph(), this.context.invoke("toolbar.refresh"), this.context.invoke("statusbar.update"), this._scheduleSnapshot();
@@ -3740,7 +4005,7 @@ var Br = /* @__PURE__ */ new Set([
3740
4005
  let e = this.context.layoutInfo.editable;
3741
4006
  if (!e) return;
3742
4007
  let t = e.lastElementChild;
3743
- if (t && Br.has(t.nodeName)) {
4008
+ if (t && mi.has(t.nodeName)) {
3744
4009
  let t = document.createElement("p");
3745
4010
  t.innerHTML = "<br>", e.appendChild(t);
3746
4011
  }
@@ -3753,7 +4018,10 @@ var Br = /* @__PURE__ */ new Set([
3753
4018
  return this.context.invoke("clipboard.resolveImages", e) ?? e;
3754
4019
  }
3755
4020
  setHTML(e) {
3756
- let t = _n(e, { allowIframes: !0 });
4021
+ let t = An(e, {
4022
+ allowIframes: !0,
4023
+ iframeHosts: this.options.iframeHosts
4024
+ });
3757
4025
  this.context.layoutInfo.editable.replaceChildren(...t.childNodes), this._history && this._history.reset(), this.afterCommand();
3758
4026
  }
3759
4027
  getText() {
@@ -3773,16 +4041,16 @@ var Br = /* @__PURE__ */ new Set([
3773
4041
  return !e && !t;
3774
4042
  }
3775
4043
  insertHTML(e) {
3776
- e && (T("insertHTML", M(e)), this.afterCommand());
4044
+ e && (C("insertHTML", j(e)), this.afterCommand());
3777
4045
  }
3778
4046
  insertText(e) {
3779
- e && (T("insertText", e), this.afterCommand());
4047
+ e && (C("insertText", e), this.afterCommand());
3780
4048
  }
3781
4049
  setMarkdown(e) {
3782
- this.setHTML(rr(e || ""));
4050
+ this.setHTML(H(e || ""));
3783
4051
  }
3784
4052
  getMarkdown() {
3785
- return Hn(this.getHTML());
4053
+ return vr(this.getHTML());
3786
4054
  }
3787
4055
  undo() {
3788
4056
  this._history && (this._flushPendingSnapshot(), this._history.undo(), this.context.invoke("toolbar.refresh"), this.context.invoke("statusbar.update"), this.context.triggerEvent("change", this.getHTML()));
@@ -3812,63 +4080,63 @@ var Br = /* @__PURE__ */ new Set([
3812
4080
  return !e || !this._history ? !1 : (this._history._restoreSelection(e), !0);
3813
4081
  }
3814
4082
  bold() {
3815
- Le(), this.afterCommand();
4083
+ Ve(), this.afterCommand();
3816
4084
  }
3817
4085
  italic() {
3818
- Re(), this.afterCommand();
4086
+ He(), this.afterCommand();
3819
4087
  }
3820
4088
  underline() {
3821
- ze(), this.afterCommand();
4089
+ Ue(), this.afterCommand();
3822
4090
  }
3823
4091
  strikethrough() {
3824
- Be(), this.afterCommand();
4092
+ We(), this.afterCommand();
3825
4093
  }
3826
4094
  superscript() {
3827
- Ve(), this.afterCommand();
4095
+ Ge(), this.afterCommand();
3828
4096
  }
3829
4097
  subscript() {
3830
- He(), this.afterCommand();
4098
+ Ke(), this.afterCommand();
3831
4099
  }
3832
4100
  justifyLeft() {
3833
- Je(), this.afterCommand();
4101
+ Qe(), this.afterCommand();
3834
4102
  }
3835
4103
  justifyCenter() {
3836
- Ye(), this.afterCommand();
4104
+ $e(), this.afterCommand();
3837
4105
  }
3838
4106
  justifyRight() {
3839
- Xe(), this.afterCommand();
4107
+ et(), this.afterCommand();
3840
4108
  }
3841
4109
  justifyFull() {
3842
- Ze(), this.afterCommand();
4110
+ tt(), this.afterCommand();
3843
4111
  }
3844
4112
  indent() {
3845
- Qe(), this.afterCommand();
4113
+ nt(), this.afterCommand();
3846
4114
  }
3847
4115
  outdent() {
3848
- et(), this.afterCommand();
4116
+ it(), this.afterCommand();
3849
4117
  }
3850
4118
  insertUL() {
3851
- at(), this.afterCommand();
4119
+ lt(), this.afterCommand();
3852
4120
  }
3853
4121
  insertOL() {
3854
- ot(), this.afterCommand();
4122
+ ut(), this.afterCommand();
3855
4123
  }
3856
4124
  inlineCode() {
3857
- ct(this.context.layoutInfo.editable), this.afterCommand();
4125
+ ft(this.context.layoutInfo.editable), this.afterCommand();
3858
4126
  }
3859
4127
  toggleChecklist() {
3860
- dt(), this.afterCommand();
4128
+ ht(), this.afterCommand();
3861
4129
  }
3862
4130
  print() {
3863
4131
  this.context.print();
3864
4132
  }
3865
4133
  formatBlock(e) {
3866
- if (qe(e), e === "pre") {
4134
+ if (Ze(e), e === "pre") {
3867
4135
  let e = globalThis.getSelection();
3868
4136
  if (e?.rangeCount > 0) {
3869
4137
  let t = e.getRangeAt(0).commonAncestorContainer, n = t.nodeType === 1 ? t.closest("pre") : t.parentElement?.closest("pre");
3870
4138
  if (n && !n.dataset.language) {
3871
- let e = zr(n.textContent || "");
4139
+ let e = pi(n.textContent || "");
3872
4140
  if (e) {
3873
4141
  this.context.invoke("codeTooltip.applyLanguage", n, e);
3874
4142
  return;
@@ -3879,55 +4147,62 @@ var Br = /* @__PURE__ */ new Set([
3879
4147
  this.afterCommand();
3880
4148
  }
3881
4149
  foreColor(e) {
3882
- Ue(e), this.afterCommand();
4150
+ qe(e), this.afterCommand();
3883
4151
  }
3884
4152
  backColor(e) {
3885
- We(e), this.afterCommand();
4153
+ Je(e), this.afterCommand();
3886
4154
  }
3887
4155
  fontName(e) {
3888
- Ge(e), this.afterCommand();
4156
+ Ye(e), this.afterCommand();
3889
4157
  }
3890
4158
  fontSize(e) {
3891
- Ke(e, this.context.layoutInfo.editable), this.afterCommand();
4159
+ Xe(e, this.context.layoutInfo.editable), this.afterCommand();
3892
4160
  }
3893
4161
  insertHr() {
3894
- T("insertHorizontalRule"), this.afterCommand();
4162
+ C("insertHorizontalRule"), this.afterCommand();
3895
4163
  }
3896
4164
  insertLink(e, t, n = !1) {
3897
4165
  let r = globalThis.getSelection();
3898
4166
  if (!r || r.rangeCount === 0) return;
3899
- let i = N(e);
3900
- if (i) {
3901
- if (r.toString().trim().length > 0) {
3902
- if (T("createLink", i), n) {
3903
- let e = this._getClosestAnchor();
3904
- e && (e.setAttribute("target", "_blank"), e.setAttribute("rel", "noopener noreferrer"));
3905
- }
3906
- } else {
3907
- let e = this._escapeAttr(t || i);
3908
- T("insertHTML", `<a href="${this._escapeAttr(i)}"${n ? " target=\"_blank\" rel=\"noopener noreferrer\"" : ""}>${e}</a>`);
4167
+ let i = M(e);
4168
+ if (!i) return;
4169
+ let a = this._newTabRel();
4170
+ if (r.toString().trim().length > 0) {
4171
+ if (C("createLink", i), n) {
4172
+ let e = this._getClosestAnchor();
4173
+ e && (e.setAttribute("target", "_blank"), e.setAttribute("rel", a));
3909
4174
  }
3910
- this.afterCommand();
4175
+ } else {
4176
+ let e = this._escapeAttr(t || i), r = n ? ` target="_blank" rel="${this._escapeAttr(a)}"` : "";
4177
+ C("insertHTML", `<a href="${this._escapeAttr(i)}"${r}>${e}</a>`);
3911
4178
  }
4179
+ this.afterCommand();
4180
+ }
4181
+ _newTabRel() {
4182
+ let e = this.options.linkDefaults?.rel, t = new Set((typeof e == "string" ? e : "noopener noreferrer").split(/\s+/).filter(Boolean));
4183
+ return t.add("noopener"), [...t].join(" ");
3912
4184
  }
3913
4185
  unlink() {
3914
- T("unlink"), this.afterCommand();
4186
+ C("unlink"), this.afterCommand();
3915
4187
  }
3916
4188
  insertImage(e, t = "", n = "") {
3917
- let r = N(e, { allowData: !0 });
4189
+ let r = M(e, { allowData: !0 });
3918
4190
  if (!r) return;
3919
4191
  let i = {
3920
4192
  left: "float:left;margin:0 1em 1em 0",
3921
4193
  center: "display:block;margin:0 auto",
3922
4194
  right: "float:right;margin:0 0 1em 1em"
3923
4195
  }[n] || "", a = i ? ` style="${i}"` : "";
3924
- T("insertHTML", `<img src="${this._escapeAttr(r)}" alt="${this._escapeAttr(t)}" class="an-image"${a}>`), this.afterCommand();
4196
+ C("insertHTML", `<img src="${this._escapeAttr(r)}" alt="${this._escapeAttr(t)}" class="an-image"${a}>`), this.afterCommand();
3925
4197
  }
3926
4198
  insertVideo(e) {
3927
- e && (T("insertHTML", e), this.afterCommand());
4199
+ e && (C("insertHTML", j(e, {
4200
+ allowIframes: !0,
4201
+ iframeHosts: this.options.iframeHosts
4202
+ })), this.afterCommand());
3928
4203
  }
3929
4204
  insertTable(e, t) {
3930
- An(e, t, { headerRow: this.context.options.tableHeaderRow }), this.afterCommand();
4205
+ $n(e, t, { headerRow: this.context.options.tableHeaderRow }), this.afterCommand();
3931
4206
  }
3932
4207
  _getClosestAnchor() {
3933
4208
  let e = globalThis.getSelection();
@@ -3942,7 +4217,39 @@ var Br = /* @__PURE__ */ new Set([
3942
4217
  _escapeAttr(e) {
3943
4218
  return String(e ?? "").replaceAll("&", "&amp;").replaceAll("\"", "&quot;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
3944
4219
  }
3945
- }, Hr = (e) => typeof e == "string" ? pt(e) : e, Y = null, Ur = "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" ${Ur} style="display:block">${e}</svg>`, Z = /* @__PURE__ */ new Map([
4220
+ }, _i = Object.freeze([
4221
+ "#000000",
4222
+ "#434343",
4223
+ "#666666",
4224
+ "#999999",
4225
+ "#b7b7b7",
4226
+ "#cccccc",
4227
+ "#efefef",
4228
+ "#ffffff",
4229
+ "#ff0000",
4230
+ "#ff9900",
4231
+ "#ffff00",
4232
+ "#00ff00",
4233
+ "#00ffff",
4234
+ "#4a86e8",
4235
+ "#9900ff",
4236
+ "#ff00ff",
4237
+ "#f4cccc",
4238
+ "#fce5cd",
4239
+ "#fff2cc",
4240
+ "#d9ead3",
4241
+ "#d0e0e3",
4242
+ "#c9daf8",
4243
+ "#d9d2e9",
4244
+ "#ead1dc"
4245
+ ]);
4246
+ function vi(e) {
4247
+ let t = Array.isArray(e?.colorPalette) && e.colorPalette.length ? e.colorPalette : _i, n = Array.isArray(e?.colorSwatches) ? e.colorSwatches : [];
4248
+ return [...new Set([...n, ...t].filter((e) => typeof e == "string" && e))];
4249
+ }
4250
+ //#endregion
4251
+ //#region src/js/module/Toolbar.js
4252
+ var Y = null, yi = "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" ${yi} style="display:block">${e}</svg>`, Z = /* @__PURE__ */ new Map([
3946
4253
  ["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\"/>")],
3947
4254
  ["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\"/>")],
3948
4255
  ["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\"/>")],
@@ -3979,7 +4286,7 @@ var Br = /* @__PURE__ */ new Set([
3979
4286
  ["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\"/>")],
3980
4287
  ["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\"/>")],
3981
4288
  ["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\"/>")]
3982
- ]), Wr = /* @__PURE__ */ new Map([
4289
+ ]), bi = /* @__PURE__ */ new Map([
3983
4290
  ["bold", "fa-bold"],
3984
4291
  ["italic", "fa-italic"],
3985
4292
  ["underline", "fa-underline"],
@@ -4013,27 +4320,42 @@ var Br = /* @__PURE__ */ new Set([
4013
4320
  ["inline-code", "fa-code"],
4014
4321
  ["checklist", "fa-list-check"],
4015
4322
  ["print", "fa-print"]
4016
- ]), Gr = class {
4323
+ ]), xi = {
4324
+ fontFamily: "fontFamilies",
4325
+ fontSize: "fontSizes",
4326
+ lineHeight: "lineHeights",
4327
+ paragraphStyle: "paragraphStyles"
4328
+ }, Si = class {
4017
4329
  constructor(e) {
4018
4330
  this.context = e, this.options = e.options, this.el = null, this._disposers = [], this._colorPickerClosers = [], this._refreshRaf = null;
4019
4331
  }
4020
4332
  initialize() {
4021
- return this.el = x("div", {
4333
+ return this.el = b("div", {
4022
4334
  class: "an-toolbar",
4023
4335
  role: "toolbar",
4024
4336
  "aria-orientation": "horizontal",
4025
- "aria-label": "Editor toolbar"
4026
- }), this._faReady = this._detectFontAwesome(), this._buildButtons(), this._initRovingFocus(), this._btnMap = new Map((this.options.toolbar || []).flat().map(Hr).filter(Boolean).map((e) => [e.name, e])), this;
4337
+ "aria-label": this.context.locale.a11y?.toolbar || "Editor toolbar"
4338
+ }), this._faReady = this._detectFontAwesome(), this._buildButtons(), this._initRovingFocus(), this._btnMap = new Map((this.options.toolbar || []).flat().map((e) => this._resolveBtn(e)).filter(Boolean).map((e) => [e.name, e])), this;
4027
4339
  }
4028
4340
  destroy() {
4029
4341
  this._refreshRaf && cancelAnimationFrame(this._refreshRaf), this._refreshRaf = null, this._disposers.forEach((e) => e()), this._disposers = [], this.el?.parentNode && this.el.remove(), this.el = null;
4030
4342
  }
4343
+ _resolveBtn(e) {
4344
+ return typeof e == "string" ? bt(e, this.options) : e;
4345
+ }
4346
+ _allow(e, t) {
4347
+ return this.context.triggerEvent?.("beforeCommand", {
4348
+ name: e,
4349
+ value: t,
4350
+ source: "toolbar"
4351
+ }) !== !1;
4352
+ }
4031
4353
  _buildButtons() {
4032
4354
  let e = this.options.toolbar || [], t = document.createDocumentFragment();
4033
4355
  e.forEach((e) => {
4034
- let n = x("div", { class: "an-btn-group" });
4356
+ let n = b("div", { class: "an-btn-group" });
4035
4357
  e.forEach((e) => {
4036
- let t = Hr(e);
4358
+ let t = this._resolveBtn(e);
4037
4359
  if (!t) {
4038
4360
  console.warn(`[AutumnNote] Toolbar: button "${e}" not found in registry. Skipped.`);
4039
4361
  return;
@@ -4044,7 +4366,7 @@ var Br = /* @__PURE__ */ new Set([
4044
4366
  }), this.el.appendChild(t);
4045
4367
  }
4046
4368
  _createGridPicker(e) {
4047
- let t = x("div", { class: "an-table-picker-wrap" }), n = x("button", {
4369
+ let t = b("div", { class: "an-table-picker-wrap" }), n = b("button", {
4048
4370
  type: "button",
4049
4371
  class: this.options.useBootstrap ? this.options.toolbarButtonClass || "btn btn-sm btn-light" : "an-btn",
4050
4372
  title: this.context.locale.toolbar[e.name] || e.tooltip || "",
@@ -4053,16 +4375,16 @@ var Br = /* @__PURE__ */ new Set([
4053
4375
  "aria-haspopup": "true",
4054
4376
  "aria-expanded": "false"
4055
4377
  });
4056
- 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>";
4057
- let r = x("div", {
4378
+ n.innerHTML = O(this.options, [e.name, e.icon]) || (this._faReady ? `<i class="${this.options.fontAwesomeClass || "fas"} fa-table" aria-hidden="true"></i>` : "<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>");
4379
+ let r = b("div", {
4058
4380
  class: "an-table-picker-popup",
4059
4381
  role: "dialog",
4060
- "aria-label": "Select table size"
4061
- }), i = x("div", { class: "an-table-grid" }), a = x("div", { class: "an-table-label" });
4382
+ "aria-label": this.context.locale.a11y?.tableSize || "Select table size"
4383
+ }), i = b("div", { class: "an-table-grid" }), a = b("div", { class: "an-table-label" });
4062
4384
  a.textContent = this.context.locale.toolbar.insertTableLabel || "Insert Table";
4063
4385
  let o = [];
4064
4386
  for (let e = 1; e <= 10; e++) for (let t = 1; t <= 10; t++) {
4065
- let n = x("div", {
4387
+ let n = b("div", {
4066
4388
  class: "an-table-cell",
4067
4389
  "data-row": String(e),
4068
4390
  "data-col": String(t)
@@ -4083,182 +4405,165 @@ var Br = /* @__PURE__ */ new Set([
4083
4405
  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");
4084
4406
  }, u = () => {
4085
4407
  s = !1, r.style.display = "none", n.setAttribute("aria-expanded", "false"), c(0, 0);
4086
- }, d = C(n, "click", (e) => {
4408
+ }, d = x(n, "click", (e) => {
4087
4409
  e.stopPropagation(), s ? u() : l();
4088
- }), f = C(i, "mouseover", (e) => {
4410
+ }), f = x(i, "mouseover", (e) => {
4089
4411
  let t = e.target?.closest(".an-table-cell");
4090
4412
  t && c(+t.dataset.row, +t.dataset.col);
4091
- }), p = C(i, "mouseleave", () => c(0, 0)), m = C(i, "click", (t) => {
4413
+ }), p = x(i, "mouseleave", () => c(0, 0)), m = x(i, "click", (t) => {
4092
4414
  let n = t.target?.closest(".an-table-cell");
4093
4415
  if (!n) return;
4094
4416
  let r = +n.dataset.row, i = +n.dataset.col;
4095
- u(), this.context.invoke("editor.focus"), e.action(this.context, r, i);
4096
- }), h = C(document, "click", () => {
4417
+ u(), this._allow(e.name, {
4418
+ rows: r,
4419
+ cols: i
4420
+ }) && (this.context.invoke("editor.focus"), e.action(this.context, r, i));
4421
+ }), h = x(document, "click", () => {
4097
4422
  s && u();
4098
4423
  });
4099
4424
  return this._disposers.push(d, f, p, m, h, () => {
4100
4425
  r.parentNode && r.remove();
4101
- }), t.appendChild(n), document.body.appendChild(r), t;
4426
+ }), t.appendChild(n), Ce(this.context).appendChild(r), t;
4102
4427
  }
4103
4428
  _createColorPicker(e) {
4104
- let t = [
4105
- "#000000",
4106
- "#434343",
4107
- "#666666",
4108
- "#999999",
4109
- "#b7b7b7",
4110
- "#cccccc",
4111
- "#efefef",
4112
- "#ffffff",
4113
- "#ff0000",
4114
- "#ff9900",
4115
- "#ffff00",
4116
- "#00ff00",
4117
- "#00ffff",
4118
- "#4a86e8",
4119
- "#9900ff",
4120
- "#ff00ff",
4121
- "#f4cccc",
4122
- "#fce5cd",
4123
- "#fff2cc",
4124
- "#d9ead3",
4125
- "#d0e0e3",
4126
- "#c9daf8",
4127
- "#d9d2e9",
4128
- "#ead1dc"
4129
- ], 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", {
4429
+ let t = e.defaultColor || "#000000", n = b("div", { class: "an-color-picker-wrap" }), r = this.options.useBootstrap ? this.options.toolbarButtonClass || "btn btn-sm btn-light" : "an-btn", i = b("button", {
4130
4430
  type: "button",
4131
- class: `${i} an-color-btn`,
4431
+ class: `${r} an-color-btn`,
4132
4432
  title: this.context.locale.toolbar[e.name] || e.tooltip || "",
4133
4433
  "data-btn": e.name,
4134
4434
  "aria-label": this.context.locale.toolbar[e.name] || e.tooltip || e.name
4135
- }), o = "stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"";
4136
- 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>`;
4137
- let s = x("span", { class: "an-color-strip" });
4138
- s.style.background = n, a.appendChild(s);
4139
- let c = x("button", {
4435
+ }), a = "stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"", o = e.name === "foreColor" ? `<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24" fill="none" ${a} 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" ${a} style="display:block"><path d="M3 21v-4l9-9 4 4-9 9z"/><path d="M12 8l4 4"/></svg>`;
4436
+ i.innerHTML = O(this.options, [e.name, e.icon]) ?? o;
4437
+ let s = b("span", { class: "an-color-strip" });
4438
+ s.style.background = t, i.appendChild(s);
4439
+ let c = b("button", {
4140
4440
  type: "button",
4141
- class: `${i} an-color-arrow`,
4441
+ class: `${r} an-color-arrow`,
4142
4442
  title: e.name === "foreColor" ? this.context.locale.toolbar.chooseTextColor || "Choose text color" : this.context.locale.toolbar.chooseHighlightColor || "Choose highlight color",
4143
4443
  "aria-haspopup": "true",
4144
4444
  "aria-expanded": "false"
4145
4445
  });
4146
4446
  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>";
4147
- let l = x("div", { class: "an-color-popup" });
4447
+ let l = b("div", { class: "an-color-popup" });
4148
4448
  l.style.display = "none";
4149
- let u = x("div", { class: "an-color-swatches" }), d = Array.isArray(this.options.colorSwatches) ? this.options.colorSwatches : [];
4150
- [.../* @__PURE__ */ new Set([...d, ...t])].forEach((e) => {
4151
- let t = x("div", {
4449
+ let u = b("div", { class: "an-color-swatches" });
4450
+ vi(this.options).forEach((e) => {
4451
+ let t = b("div", {
4152
4452
  class: "an-color-swatch",
4153
4453
  title: e,
4154
4454
  "data-color": e
4155
4455
  });
4156
4456
  t.style.background = e, u.appendChild(t);
4157
4457
  });
4158
- let f = x("div", { class: "an-color-custom" }), p = x("input", {
4458
+ let d = b("div", { class: "an-color-custom" }), f = b("input", {
4159
4459
  type: "color",
4160
- value: n,
4460
+ value: t,
4161
4461
  title: this.context.locale.toolbar.customColor || "Custom color"
4162
- }), m = x("span", {}, [this.context.locale.toolbar.customColor || "Custom color"]);
4163
- f.appendChild(p), f.appendChild(m), l.appendChild(u), l.appendChild(f);
4164
- let h = !1, g = null, ee = () => {
4462
+ }), p = b("span", {}, [this.context.locale.toolbar.customColor || "Custom color"]);
4463
+ d.appendChild(f), d.appendChild(p), l.appendChild(u), l.appendChild(d);
4464
+ let m = !1, h = null, ee = () => {
4165
4465
  let e = globalThis.getSelection();
4166
- g = e?.rangeCount ? e.getRangeAt(0).cloneRange() : null;
4167
- }, te = () => {
4168
- if (g) try {
4466
+ h = e?.rangeCount ? e.getRangeAt(0).cloneRange() : null;
4467
+ }, g = () => {
4468
+ if (h) try {
4169
4469
  let e = globalThis.getSelection();
4170
4470
  if (!e) return;
4171
- e.removeAllRanges(), e.addRange(g);
4471
+ e.removeAllRanges(), e.addRange(h);
4172
4472
  } catch {}
4173
- }, ne = () => {
4473
+ }, te = () => {
4174
4474
  this._colorPickerClosers.forEach((e) => {
4175
4475
  e !== _ && e();
4176
- }), ee(), h = !0;
4476
+ }), ee(), m = !0;
4177
4477
  let e = c.getBoundingClientRect(), t = e.left;
4178
4478
  t + 184 > globalThis.innerWidth && (t = e.right - 184), l.style.top = `${e.bottom + 4}px`, l.style.left = `${Math.max(4, t)}px`, l.style.display = "block", c.setAttribute("aria-expanded", "true");
4179
4479
  }, _ = () => {
4180
- h = !1, l.style.display = "none", l.style.top = "", l.style.left = "", c.setAttribute("aria-expanded", "false");
4181
- }, v = (t) => {
4182
- n = t, s.style.background = t, p.value = t, te(), e.action(this.context, t), this.context.invoke("editor.afterCommand"), _();
4183
- }, re = C(a, "click", (t) => {
4184
- t.preventDefault(), te(), e.action(this.context, n), this.context.invoke("editor.afterCommand");
4185
- }), ie = C(c, "mousedown", (e) => {
4480
+ m = !1, l.style.display = "none", l.style.top = "", l.style.left = "", c.setAttribute("aria-expanded", "false");
4481
+ }, ne = (n) => {
4482
+ if (t = n, s.style.background = n, f.value = n, !this._allow(e.name, n)) {
4483
+ _();
4484
+ return;
4485
+ }
4486
+ g(), e.action(this.context, n), this.context.invoke("editor.afterCommand"), _();
4487
+ }, re = x(i, "click", (n) => {
4488
+ n.preventDefault(), this._allow(e.name, t) && (g(), e.action(this.context, t), this.context.invoke("editor.afterCommand"));
4489
+ }), ie = x(c, "mousedown", (e) => {
4186
4490
  e.preventDefault();
4187
- }), y = C(c, "click", (e) => {
4188
- e.stopPropagation(), h ? _() : ne();
4189
- }), b = C(u, "mousedown", (e) => {
4491
+ }), ae = x(c, "click", (e) => {
4492
+ e.stopPropagation(), m ? _() : te();
4493
+ }), oe = x(u, "mousedown", (e) => {
4190
4494
  e.preventDefault();
4191
- }), ae = C(u, "click", (e) => {
4495
+ }), v = x(u, "click", (e) => {
4192
4496
  let t = e.target?.closest(".an-color-swatch");
4193
- t && v(t.dataset.color);
4194
- }), oe = C(p, "change", (e) => {
4195
- v(e.target.value);
4196
- }), se = C(document, "click", (e) => {
4197
- h && !r.contains(e.target) && !l.contains(e.target) && _();
4198
- }), ce = C(l, "click", (e) => e.stopPropagation()), S = () => {
4199
- h && _();
4497
+ t && ne(t.dataset.color);
4498
+ }), se = x(f, "change", (e) => {
4499
+ ne(e.target.value);
4500
+ }), ce = x(document, "click", (e) => {
4501
+ m && !n.contains(e.target) && !l.contains(e.target) && _();
4502
+ }), le = x(l, "click", (e) => e.stopPropagation()), y = () => {
4503
+ m && _();
4200
4504
  };
4201
- return document.addEventListener("scroll", S, {
4505
+ return document.addEventListener("scroll", y, {
4202
4506
  passive: !0,
4203
4507
  capture: !0
4204
- }), 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), () => {
4508
+ }), globalThis.addEventListener("resize", y, { passive: !0 }), this._disposers.push(re, ie, ae, oe, v, se, ce, le, () => document.removeEventListener("scroll", y, { capture: !0 }), () => globalThis.removeEventListener("resize", y), () => {
4205
4509
  l.parentNode && l.remove();
4206
4510
  }), this._colorPickerClosers.push(_), this._disposers.push(() => {
4207
4511
  let e = this._colorPickerClosers.indexOf(_);
4208
4512
  e !== -1 && this._colorPickerClosers.splice(e, 1);
4209
- }), r.appendChild(a), r.appendChild(c), document.body.appendChild(l), r;
4513
+ }), n.appendChild(i), n.appendChild(c), Ce(this.context).appendChild(l), n;
4210
4514
  }
4211
4515
  _createSelect(e) {
4212
- let t = e.name === "fontFamily" ? this.options.fontFamilies || [] : e.items || [], n = x("select", {
4516
+ let t = xi[e.name], n = t ? this.options[t] : null, r = Array.isArray(n) && (n.length || e.name === "fontFamily") ? n : e.items || [], i = b("select", {
4213
4517
  class: e.selectClass ? `an-select ${e.selectClass}` : "an-select",
4214
4518
  title: this.context.locale.toolbar[e.name] || e.tooltip || "",
4215
4519
  "data-btn": e.name,
4216
4520
  "aria-label": this.context.locale.toolbar[e.name] || e.tooltip || e.name
4217
- }), r = x("option", {
4521
+ }), a = b("option", {
4218
4522
  value: "",
4219
4523
  disabled: "",
4220
4524
  hidden: ""
4221
4525
  }, [this.context.locale.toolbar[e.name + "Placeholder"] || e.placeholder || "Font"]);
4222
- n.appendChild(r), t.forEach((t) => {
4223
- let r = typeof t == "object" ? t.value : t, i;
4224
- i = typeof t == "object" ? e.name === "paragraphStyle" && this.context.locale.toolbar.paragraphItems?.[t.value] || t.label : t;
4225
- let a = typeof t == "object" && !!t.disabled, o = { value: r };
4526
+ i.appendChild(a), r.forEach((t) => {
4527
+ let n = typeof t == "object" ? t.value : t, r;
4528
+ r = typeof t == "object" ? e.name === "paragraphStyle" && this.context.locale.toolbar.paragraphItems?.[t.value] || t.label : t;
4529
+ let a = typeof t == "object" && !!t.disabled, o = { value: n };
4226
4530
  a && (o.disabled = "");
4227
- let s = x("option", o, [i]);
4228
- e.name === "fontFamily" && !a && (s.style.fontFamily = r), n.appendChild(s);
4531
+ let s = b("option", o, [r]);
4532
+ e.name === "fontFamily" && !a && (s.style.fontFamily = n), i.appendChild(s);
4229
4533
  });
4230
- let i = null, a = C(n, "mousedown", () => {
4534
+ let o = null, s = x(i, "mousedown", () => {
4231
4535
  let e = globalThis.getSelection();
4232
- i = e?.rangeCount ? e.getRangeAt(0).cloneRange() : null;
4233
- }), o = C(n, "change", (t) => {
4536
+ o = e?.rangeCount ? e.getRangeAt(0).cloneRange() : null;
4537
+ }), c = x(i, "change", (t) => {
4234
4538
  let n = t.target.value, r = t.target.options[t.target.selectedIndex];
4235
4539
  if (!(!n || r.disabled)) {
4236
- if (this.context.invoke("editor.focus"), i) try {
4540
+ if (this.context.invoke("editor.focus"), o) try {
4237
4541
  let e = globalThis.getSelection();
4238
- e && (e.removeAllRanges(), e.addRange(i));
4542
+ e && (e.removeAllRanges(), e.addRange(o));
4239
4543
  } catch {}
4240
- e.action(this.context, n), this.context.invoke("editor.afterCommand");
4544
+ this._allow(e.name, n) && (e.action(this.context, n), this.context.invoke("editor.afterCommand"));
4241
4545
  }
4242
4546
  });
4243
- return this._disposers.push(a, o), n;
4547
+ return this._disposers.push(s, c), i;
4244
4548
  }
4245
4549
  _createButton(e) {
4246
- let t = x("button", {
4550
+ let t = b("button", {
4247
4551
  type: "button",
4248
4552
  class: `${this.options.useBootstrap ? this.options.toolbarButtonClass || "btn btn-sm btn-light" : "an-btn"}${e.className ? ` ${e.className}` : ""}`,
4249
4553
  title: this.context.locale.toolbar[e.name] || e.tooltip || "",
4250
4554
  "data-btn": e.name,
4251
4555
  "aria-label": this.context.locale.toolbar[e.name] || e.tooltip || e.name,
4252
4556
  ...typeof e.isActive == "function" ? { "aria-pressed": "false" } : {}
4253
- }), n = this.options.fontAwesomeClass || "fas";
4254
- if (this._faReady) {
4255
- let r = Wr.get(e.icon) || Wr.get(e.name) || null;
4557
+ }), n = this.options.fontAwesomeClass || "fas", r = this._faReady, i = O(this.options, [e.name, e.icon]);
4558
+ if (i) t.innerHTML = i;
4559
+ else if (r) {
4560
+ let r = bi.get(e.icon) || bi.get(e.name) || null;
4256
4561
  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;
4257
4562
  } 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;
4258
- let r = C(t, "click", (t) => {
4259
- t.preventDefault(), this.context.invoke("editor.focus"), e.action(this.context), this.context.invoke("editor.afterCommand"), this.refresh();
4563
+ let a = x(t, "click", (t) => {
4564
+ t.preventDefault(), this._allow(e.name) && (this.context.invoke("editor.focus"), e.action(this.context), this.context.invoke("editor.afterCommand"), this.refresh());
4260
4565
  });
4261
- return this._disposers.push(r), t;
4566
+ return this._disposers.push(a), t;
4262
4567
  }
4263
4568
  _controls() {
4264
4569
  return this.el ? Array.from(this.el.querySelectorAll("button, select")) : [];
@@ -4273,7 +4578,7 @@ var Br = /* @__PURE__ */ new Set([
4273
4578
  t.forEach((e) => e.setAttribute("tabindex", e === r ? "0" : "-1"));
4274
4579
  }
4275
4580
  _initRovingFocus() {
4276
- this.el && (this._syncRovingTabindex(), this._disposers.push(C(this.el, "keydown", (e) => this._onToolbarKeydown(e)), C(this.el, "focusin", (e) => {
4581
+ this.el && (this._syncRovingTabindex(), this._disposers.push(x(this.el, "keydown", (e) => this._onToolbarKeydown(e)), x(this.el, "focusin", (e) => {
4277
4582
  let t = e.target?.closest?.("button, select");
4278
4583
  t && this._syncRovingTabindex(t);
4279
4584
  })));
@@ -4334,49 +4639,58 @@ var Br = /* @__PURE__ */ new Set([
4334
4639
  this.el && (this.el.style.display = "none");
4335
4640
  }
4336
4641
  rebuild() {
4337
- 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(Hr).filter(Boolean).map((e) => [e.name, e])), this.refresh();
4642
+ 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((e) => this._resolveBtn(e)).filter(Boolean).map((e) => [e.name, e])), this.refresh();
4338
4643
  }
4339
4644
  };
4340
4645
  //#endregion
4341
4646
  //#region src/js/module/Statusbar.js
4342
- function Kr(e, t, n) {
4647
+ function Ci(e, t, n) {
4343
4648
  if (!n) {
4344
4649
  e.classList.remove("an-count-warn", "an-count-exceeded");
4345
4650
  return;
4346
4651
  }
4347
4652
  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");
4348
4653
  }
4349
- var qr = class {
4654
+ var wi = class {
4350
4655
  constructor(e) {
4351
- this.context = e, this.options = e.options, this.el = null, this._disposers = [], this._wordCountEl = null, this._charCountEl = null, this._counter = new Bn();
4656
+ this.context = e, this.options = e.options, this.el = null, this._disposers = [], this._handle = null, this._handleDisposers = [], this._wordCountEl = null, this._charCountEl = null, this._counter = new gr();
4352
4657
  }
4353
4658
  initialize() {
4354
- if (this.el = x("div", { class: "an-statusbar" }), this.options.resizable !== !1) {
4355
- let e = x("div", {
4356
- class: "an-resize-handle",
4357
- title: this.context.locale.statusbar.resizeHandle,
4358
- "aria-hidden": "true"
4359
- });
4360
- this._bindResize(e), this.el.appendChild(e);
4361
- }
4362
- this._wordCountEl = x("span", {
4659
+ this.el = b("div", { class: "an-statusbar" }), this._wordCountEl = b("span", {
4363
4660
  class: "an-word-count",
4364
4661
  role: "status",
4365
4662
  "aria-live": "polite",
4366
4663
  "aria-atomic": "true"
4367
- }), this._charCountEl = x("span", {
4664
+ }), this._charCountEl = b("span", {
4368
4665
  class: "an-char-count",
4369
4666
  "aria-live": "polite",
4370
4667
  "aria-atomic": "true"
4371
4668
  });
4372
- let e = x("div", {
4669
+ let e = b("div", {
4373
4670
  class: "an-status-info",
4374
- "aria-label": "Editor statistics"
4671
+ "aria-label": this.context.locale.a11y?.statistics || "Editor statistics"
4375
4672
  });
4376
- return e.appendChild(this._wordCountEl), e.appendChild(this._charCountEl), this.el.appendChild(e), this.update(), this;
4673
+ return e.appendChild(this._wordCountEl), e.appendChild(this._charCountEl), this.el.appendChild(e), this.applyResizable(), this.applyVisibility(), this.update(), this;
4674
+ }
4675
+ applyResizable() {
4676
+ if (!this.el) return;
4677
+ let e = this.options.resizable !== !1;
4678
+ if (e && !this._handle) {
4679
+ let e = b("div", {
4680
+ class: "an-resize-handle",
4681
+ title: this.context.locale.statusbar.resizeHandle,
4682
+ "aria-hidden": "true"
4683
+ });
4684
+ this._handleDisposers = this._bindResize(e), this.el.prepend(e), this._handle = e;
4685
+ } else !e && this._handle && (this._handleDisposers.forEach((e) => e()), this._handleDisposers = [], this._handle.remove(), this._handle = null);
4686
+ }
4687
+ applyVisibility() {
4688
+ if (!this.el) return;
4689
+ let e = this.options.statusbar !== !1;
4690
+ this.el.hidden = !e, this.context.layoutInfo.container?.classList.toggle("an-no-statusbar", !e);
4377
4691
  }
4378
4692
  destroy() {
4379
- this._disposers.forEach((e) => e()), this._disposers = [], this._dragDisposers &&= (this._dragDisposers.forEach((e) => e()), null), this.el?.remove(), this.el = null;
4693
+ this.context.layoutInfo.container?.classList.remove("an-no-statusbar"), this._disposers.forEach((e) => e()), this._disposers = [], this._handleDisposers.forEach((e) => e()), this._handleDisposers = [], this._handle = null, this._dragDisposers &&= (this._dragDisposers.forEach((e) => e()), null), this.el?.remove(), this.el = null;
4380
4694
  }
4381
4695
  _bindResize(e) {
4382
4696
  let t = 0, n = 0, r = this.context.layoutInfo.container, i = (e) => {
@@ -4391,19 +4705,19 @@ var qr = class {
4391
4705
  t && (e.preventDefault(), i(t.clientY));
4392
4706
  }, l = () => {
4393
4707
  document.removeEventListener("touchmove", c), document.removeEventListener("touchend", l), this._dragDisposers = null;
4394
- }, u = (e) => {
4708
+ };
4709
+ return [x(e, "mousedown", s), x(e, "touchstart", (e) => {
4395
4710
  let i = e.touches[0];
4396
4711
  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)]);
4397
- }, d = C(e, "mousedown", s), f = C(e, "touchstart", u);
4398
- this._disposers.push(d, f);
4712
+ })];
4399
4713
  }
4400
4714
  _counts() {
4401
4715
  return this._counter.counts(this.context.layoutInfo.editable);
4402
4716
  }
4403
4717
  update() {
4404
- if (!this._wordCountEl || !this._charCountEl) return;
4718
+ if (!this._wordCountEl || !this._charCountEl || this.el?.hidden) return;
4405
4719
  let { words: e, chars: t } = this._counts(), n = this.options.maxWords || 0, r = this.options.maxChars || 0, i = this.context.locale.statusbar;
4406
- this._wordCountEl.textContent = n ? i.wordsLimit(e, n) : i.words(e), this._charCountEl.textContent = r ? i.charsLimit(t, r) : i.chars(t), Kr(this._wordCountEl, e, n), Kr(this._charCountEl, t, r);
4720
+ this._wordCountEl.textContent = n ? i.wordsLimit(e, n) : i.words(e), this._charCountEl.textContent = r ? i.charsLimit(t, r) : i.chars(t), Ci(this._wordCountEl, e, n), Ci(this._charCountEl, t, r);
4407
4721
  }
4408
4722
  getWordCount() {
4409
4723
  return this._counts().words;
@@ -4411,14 +4725,14 @@ var qr = class {
4411
4725
  getCharCount() {
4412
4726
  return this._counts().chars;
4413
4727
  }
4414
- }, Jr = class {
4728
+ }, Ti = class {
4415
4729
  constructor(e) {
4416
4730
  this.context = e, this.options = e.options, this._disposers = [];
4417
4731
  }
4418
4732
  initialize() {
4419
4733
  this._blobRegistry = /* @__PURE__ */ new Map(), this._forcePlain = !1;
4420
4734
  let e = this.context.layoutInfo.editable;
4421
- 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) => {
4735
+ return this._disposers.push(x(e, "paste", (e) => this._onPaste(e)), x(e, "dragover", (e) => this._onDragover(e)), x(e, "drop", (e) => this._onDrop(e))), this._mutationObserver = new MutationObserver((e) => {
4422
4736
  for (let t of e) for (let e of t.removedNodes) this._revokeRemovedBlobs(e);
4423
4737
  }), this._mutationObserver.observe(e, {
4424
4738
  childList: !0,
@@ -4491,17 +4805,21 @@ var qr = class {
4491
4805
  setForcePlain(e) {
4492
4806
  this._forcePlain = !!e;
4493
4807
  }
4808
+ _maxPasteBytes() {
4809
+ let e = this.options.maxPasteSize;
4810
+ return typeof e == "number" && e >= 0 ? e : 5242880;
4811
+ }
4494
4812
  _onPaste(e) {
4495
4813
  let t = e.clipboardData || globalThis.clipboardData;
4496
4814
  if (!t) return;
4497
4815
  let n = this._forcePlain;
4498
4816
  this._forcePlain = !1;
4499
- let r = (this.options.maxPasteSize ?? 5) * 1024 * 1024;
4817
+ let r = this._maxPasteBytes();
4500
4818
  if (r > 0) {
4501
4819
  let n = t.getData("text/plain") || "", i = t.getData("text/html") || "", a = Math.max(n.length, i.length);
4502
4820
  if (a > r) {
4503
4821
  e.preventDefault();
4504
- let t = `Pasted content (${a} bytes) exceeds the ${this.options.maxPasteSize ?? 5} MB paste size limit.`;
4822
+ let t = `Pasted content (${a} bytes) exceeds the ${r}-byte paste size limit.`;
4505
4823
  this.context.triggerEvent("pasteError", {
4506
4824
  size: a,
4507
4825
  maxBytes: r,
@@ -4519,24 +4837,33 @@ var qr = class {
4519
4837
  return;
4520
4838
  }
4521
4839
  }
4522
- if (typeof this.options.onPaste == "function" && this.options.onPaste({
4840
+ let i = this.context.triggerEvent("paste", {
4523
4841
  text: t.getData("text/plain") || "",
4524
4842
  html: t.types.includes("text/html") ? t.getData("text/html") : null
4525
- }), n || this.options.pasteAsPlainText) {
4526
- e.preventDefault(), T("insertHTML", t.getData("text/plain").split(/\r?\n/).map((e) => `<p>${this._escapeHTML(e) || "<br>"}</p>`).join("")), this.context.invoke("editor.afterCommand");
4843
+ });
4844
+ if (i === !1) {
4845
+ e.preventDefault();
4846
+ return;
4847
+ }
4848
+ if (typeof i == "string") {
4849
+ e.preventDefault(), C("insertHTML", j(i)), this.context.invoke("editor.afterCommand");
4850
+ return;
4851
+ }
4852
+ if (n || this.options.pasteAsPlainText) {
4853
+ e.preventDefault(), C("insertHTML", t.getData("text/plain").split(/\r?\n/).map((e) => `<p>${this._escapeHTML(e) || "<br>"}</p>`).join("")), this.context.invoke("editor.afterCommand");
4527
4854
  return;
4528
4855
  }
4529
4856
  if (this.options.markdownPaste !== !1) {
4530
4857
  let n = t.types.includes("text/html"), r = n ? t.getData("text/html") : "", i = !n || this._isTriviallyPlainHtml(r), a = t.getData("text/plain");
4531
- if (a && i && Zn(a)) {
4532
- e.preventDefault(), T("insertHTML", M(rr(a))), this.context.invoke("editor.afterCommand");
4858
+ if (a && i && Dr(a)) {
4859
+ e.preventDefault(), C("insertHTML", j(H(a))), this.context.invoke("editor.afterCommand");
4533
4860
  return;
4534
4861
  }
4535
4862
  }
4536
4863
  if (this.options.pasteCleanHTML !== !1 && t.types.includes("text/html")) {
4537
4864
  e.preventDefault();
4538
4865
  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;
4539
- r ? a = this._cleanWordHtml(a) : i && (a = this._cleanSocialHtml(a)), a = this._normalizeExternalTaskLists(a), a = M(a), this.options.pasteStripAttributes && (a = this._stripAttributes(a)), T("insertHTML", a), this.context.invoke("editor.afterCommand");
4866
+ r ? a = this._cleanWordHtml(a) : i && (a = this._cleanSocialHtml(a)), a = this._normalizeExternalTaskLists(a), a = j(a), this.options.pasteStripAttributes && (a = this._stripAttributes(a)), C("insertHTML", a), this.context.invoke("editor.afterCommand");
4540
4867
  }
4541
4868
  }
4542
4869
  _onDragover(e) {
@@ -4556,9 +4883,9 @@ var qr = class {
4556
4883
  }
4557
4884
  }
4558
4885
  _insertMarkdownFile(e) {
4559
- let t = (this.options.maxPasteSize ?? 5) * 1024 * 1024;
4886
+ let t = this._maxPasteBytes();
4560
4887
  if (t > 0 && e.size > t) {
4561
- let n = `Dropped file "${e.name}" (${e.size} bytes) exceeds the ${this.options.maxPasteSize ?? 5} MB paste size limit.`;
4888
+ let n = `Dropped file "${e.name}" (${e.size} bytes) exceeds the ${t}-byte paste size limit.`;
4562
4889
  this.context.triggerEvent("pasteError", {
4563
4890
  size: e.size,
4564
4891
  maxBytes: t,
@@ -4568,7 +4895,7 @@ var qr = class {
4568
4895
  }
4569
4896
  let n = new FileReader();
4570
4897
  n.onload = (e) => {
4571
- T("insertHTML", M(rr(e.target.result || ""))), this.context.invoke("editor.afterCommand");
4898
+ C("insertHTML", j(H(e.target.result || ""))), this.context.invoke("editor.afterCommand");
4572
4899
  }, n.onerror = () => {
4573
4900
  let t = `Failed to read dropped markdown file "${e.name}".`;
4574
4901
  console.warn(`[AutumnNote] ${t}`), this.context.triggerEvent("pasteError", { message: t });
@@ -4653,7 +4980,7 @@ var qr = class {
4653
4980
  file: e
4654
4981
  });
4655
4982
  let r = this._escapeAttr(e.name.replace(/\.[^.]+$/, ""));
4656
- return T("insertHTML", `<img src="${this._escapeAttr(n)}" alt="${r}" class="an-image an-image-uploading" data-an-upload="${t}">`), this.context.invoke("editor.afterCommand"), t;
4983
+ return C("insertHTML", `<img src="${this._escapeAttr(n)}" alt="${r}" class="an-image an-image-uploading" data-an-upload="${t}">`), this.context.invoke("editor.afterCommand"), t;
4657
4984
  }
4658
4985
  _findPlaceholder(e) {
4659
4986
  return this.context.layoutInfo.editable?.querySelector(`img[data-an-upload="${e}"]`) ?? null;
@@ -4661,7 +4988,7 @@ var qr = class {
4661
4988
  _resolveUpload(e, t) {
4662
4989
  let n = this._findPlaceholder(e), r = this._uploadPreviews?.get(e);
4663
4990
  if (n) {
4664
- let i = N(t, { allowData: !0 });
4991
+ let i = M(t, { allowData: !0 });
4665
4992
  if (i) n.setAttribute("src", i), n.classList.remove("an-image-uploading"), n.removeAttribute("data-an-upload"), n.style.removeProperty("--an-upload-progress");
4666
4993
  else {
4667
4994
  this._failUpload(e, r?.file, /* @__PURE__ */ Error(`Rejected image URL: ${t}`));
@@ -4753,30 +5080,30 @@ var qr = class {
4753
5080
  _escapeHTML(e) {
4754
5081
  return e.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll("\"", "&quot;").replaceAll("'", "&#039;");
4755
5082
  }
4756
- }, Yr = /[^\s\u200B]/;
4757
- function Xr(e) {
5083
+ }, Ei = /[^\s\u200B]/;
5084
+ function Di(e) {
4758
5085
  let t = document.createTreeWalker(e, NodeFilter.SHOW_TEXT);
4759
- for (let e = t.nextNode(); e; e = t.nextNode()) if (Yr.test(e.data)) return !0;
5086
+ for (let e = t.nextNode(); e; e = t.nextNode()) if (Ei.test(e.data)) return !0;
4760
5087
  return !1;
4761
5088
  }
4762
5089
  //#endregion
4763
5090
  //#region src/js/presets/core.js
4764
- var Zr = [
5091
+ var Oi = [
4765
5092
  {
4766
5093
  name: "editor",
4767
- Class: Vr
5094
+ Class: gi
4768
5095
  },
4769
5096
  {
4770
5097
  name: "toolbar",
4771
- Class: Gr
5098
+ Class: Si
4772
5099
  },
4773
5100
  {
4774
5101
  name: "statusbar",
4775
- Class: qr
5102
+ Class: wi
4776
5103
  },
4777
5104
  {
4778
5105
  name: "clipboard",
4779
- Class: Jr
5106
+ Class: Ti
4780
5107
  },
4781
5108
  {
4782
5109
  name: "placeholder",
@@ -4787,54 +5114,54 @@ var Zr = [
4787
5114
  initialize() {
4788
5115
  let e = this.context.layoutInfo.editable, t = this.options.placeholder || "";
4789
5116
  t && (e.dataset.placeholder = t);
4790
- let n = () => this._update(), r = C(e, "input", n), i = C(e, "focus", n), a = C(e, "blur", n);
5117
+ let n = () => this._update(), r = x(e, "input", n), i = x(e, "focus", n), a = x(e, "blur", n);
4791
5118
  return this._disposers.push(r, i, a), this._update(), this;
4792
5119
  }
4793
5120
  destroy() {
4794
5121
  this._disposers.forEach((e) => e()), this._disposers = [];
4795
5122
  }
4796
5123
  _update() {
4797
- let e = this.context.layoutInfo.editable, t = document.activeElement === e, n = !Xr(e) && !e.querySelector("img, table, hr, .an-video-wrapper");
5124
+ let e = this.context.layoutInfo.editable, t = document.activeElement === e, n = !Di(e) && !e.querySelector("img, table, hr, .an-video-wrapper");
4798
5125
  e.classList.toggle("an-placeholder", n && !t);
4799
5126
  }
4800
5127
  }
4801
5128
  }
4802
- ], Qr = "2.7.0";
5129
+ ], ki = "3.0.0";
4803
5130
  //#endregion
4804
5131
  //#region src/js/core/lists.js
4805
- function $r(e) {
5132
+ function Ai(e) {
4806
5133
  return e[e.length - 1];
4807
5134
  }
4808
- function ei(e) {
5135
+ function ji(e) {
4809
5136
  return e[0];
4810
5137
  }
4811
- function ti(e, t = 1) {
5138
+ function Mi(e, t = 1) {
4812
5139
  return e.slice(0, e.length - t);
4813
5140
  }
4814
- function ni(e, t = 1) {
5141
+ function Ni(e, t = 1) {
4815
5142
  return e.slice(t);
4816
5143
  }
4817
- function ri(e) {
5144
+ function Pi(e) {
4818
5145
  return e.flat();
4819
5146
  }
4820
- function ii(e) {
5147
+ function Fi(e) {
4821
5148
  return [...new Set(e)];
4822
5149
  }
4823
- function ai(e, t) {
5150
+ function Ii(e, t) {
4824
5151
  let n = [];
4825
5152
  for (let r = 0; r < e.length; r += t) n.push(e.slice(r, r + t));
4826
5153
  return n;
4827
5154
  }
4828
- function oi(e, t) {
5155
+ function Li(e, t) {
4829
5156
  return e.reduce((e, n) => {
4830
5157
  let r = t(n);
4831
5158
  return e[r] || (e[r] = []), e[r].push(n), e;
4832
5159
  }, {});
4833
5160
  }
4834
- function si(e, t) {
5161
+ function Ri(e, t) {
4835
5162
  return e.every(t);
4836
5163
  }
4837
- function ci(e, t) {
5164
+ function zi(e, t) {
4838
5165
  return e.some(t);
4839
5166
  }
4840
5167
  //#endregion
@@ -4842,7 +5169,7 @@ function ci(e, t) {
4842
5169
  function Q() {
4843
5170
  return globalThis.navigator?.userAgent ?? "";
4844
5171
  }
4845
- var li = {
5172
+ var Bi = {
4846
5173
  get isChrome() {
4847
5174
  return /Chrome\//.test(Q()) && !/Edg\//.test(Q());
4848
5175
  },
@@ -4867,11 +5194,11 @@ var li = {
4867
5194
  get modifierKey() {
4868
5195
  return /Macintosh/.test(Q()) ? "metaKey" : "ctrlKey";
4869
5196
  }
4870
- }, ui = { ...A }, $ = /* @__PURE__ */ new WeakMap(), di = {
5197
+ }, Vi = { ...k }, $ = /* @__PURE__ */ new WeakMap(), Hi = {
4871
5198
  create(e, t = {}) {
4872
- let n = fi(e).map((e) => {
5199
+ let n = Ui(e).map((e) => {
4873
5200
  if ($.has(e)) return $.get(e);
4874
- let n = new En(e, t);
5201
+ let n = new Yn(e, t);
4875
5202
  return n._releaseInstance = () => {
4876
5203
  $.get(e) === n && $.delete(e);
4877
5204
  }, n.initialize(), $.set(e, n), n;
@@ -4879,7 +5206,7 @@ var li = {
4879
5206
  return n.length === 1 ? n[0] : n;
4880
5207
  },
4881
5208
  destroy(e) {
4882
- fi(e).forEach((e) => {
5209
+ Ui(e).forEach((e) => {
4883
5210
  let t = $.get(e);
4884
5211
  t && (t.destroy(), $.delete(e));
4885
5212
  });
@@ -4889,48 +5216,51 @@ var li = {
4889
5216
  return t && $.get(t) || null;
4890
5217
  },
4891
5218
  get defaults() {
4892
- return { ...A };
5219
+ return { ...k };
4893
5220
  },
4894
5221
  setDefaults(e) {
4895
- Object.assign(A, e);
5222
+ Object.assign(k, e);
4896
5223
  },
4897
5224
  resetDefaults() {
4898
- Object.keys(A).forEach((e) => delete A[e]), Object.assign(A, ui);
5225
+ Object.keys(k).forEach((e) => delete k[e]), Object.assign(k, Vi);
4899
5226
  },
4900
5227
  registerModule(e, t) {
4901
- Cn.set(e, t);
5228
+ Un.set(e, t);
4902
5229
  },
4903
5230
  use(e, t = {}) {
4904
5231
  if (!e || typeof e.name != "string") throw TypeError("[AutumnNote] AutumnNote.use: plugin must have a string `name` property.");
4905
- return P.has(e.name) ? (console.warn(`[AutumnNote] Plugin "${e.name}" already registered globally. Skipping.`), this) : (Array.isArray(e.buttons) && e.buttons.forEach((e) => k(e)), P.set(e.name, {
5232
+ return N.has(e.name) ? (console.warn(`[AutumnNote] Plugin "${e.name}" already registered globally. Skipping.`), this) : (Array.isArray(e.buttons) && e.buttons.forEach((e) => D(e)), N.set(e.name, {
4906
5233
  plugin: e,
4907
5234
  options: t
4908
5235
  }), this);
4909
5236
  },
4910
5237
  hasPlugin(e) {
4911
- return P.has(e);
5238
+ return N.has(e);
4912
5239
  },
4913
5240
  registerButton(e) {
4914
- return k(e), this;
5241
+ return D(e), this;
5242
+ },
5243
+ registerIcon(e, t) {
5244
+ return St(e, t), this;
4915
5245
  },
4916
5246
  registerLocale(e, t) {
4917
- return nn(e, t), this;
5247
+ return gn(e, t), this;
4918
5248
  },
4919
5249
  registerSlashCommand(e) {
4920
5250
  if (!e?.id || typeof e.run != "function") throw TypeError("[AutumnNote] Slash command requires an id and run(context) function.");
4921
- let t = A.slashCommands, n = t.findIndex((t) => t.id === e.id);
5251
+ let t = k.slashCommands, n = t.findIndex((t) => t.id === e.id);
4922
5252
  return n >= 0 ? t[n] = e : t.push(e), this;
4923
5253
  },
4924
- buttons: en,
4925
- version: Qr
5254
+ buttons: mn,
5255
+ version: ki
4926
5256
  };
4927
- function fi(e) {
5257
+ function Ui(e) {
4928
5258
  return typeof e == "string" ? Array.from(document.querySelectorAll(e)) : e instanceof Element ? [e] : e instanceof NodeList || Array.isArray(e) ? Array.from(e) : [];
4929
5259
  }
4930
5260
  //#endregion
4931
5261
  //#region src/js/core.js
4932
- Tn(Zr);
5262
+ Gn(Oi);
4933
5263
  //#endregion
4934
- export { En as Context, d as ELEMENT_NODE, Fr as SUPPORTED_LANGS, f as TEXT_NODE, w as WrappedRange, O as _buttonRegistry, xt as alignCenterBtn, Ct as alignJustifyBtn, bt as alignLeftBtn, St as alignRightBtn, si as all, ae as ancestors, ci as any, Qt as backColorBtn, mt as boldBtn, en as buttons, Yt as checklistBtn, oe as children, ai as chunk, e as clamp, y as closest, b as closestPara, Ut as codeviewBtn, Ce as collapsedRange, r as compose, x as createElement, xe as currentRange, t as debounce, di as default, A as defaultOptions, $t as defaultToolbar, zr as detectLang, zt as directionBtn, Pt as emojiBtn, li as env, Kt as findBtn, qt as findReplaceBtn, ei as first, ri as flatten, Bt as fontFamilyBtn, Lt as fontSizeBtn, Zt as foreColorBtn, be as fromNativeRange, Wt as fullscreenBtn, pt as getButton, oi as groupBy, At as hrBtn, Hn as htmlToMarkdown, Ft as iconBtn, i as identity, Mt as imageBtn, Et as indentBtn, ti as initial, Jt 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, _e as isInsideEditable, I as isKey, ee as isLi, te as isList, Zn as isMarkdown, L 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, ht as italicBtn, F as key, $r as last, Ht as lineHeightBtn, jt as linkBtn, tn as locales, ye as makeDraggable, rr as markdownToHTML, c as mergeDeep, ce as nextElement, fe as nodeValue, Tt as olBtn, C as on, Dt as outdentBtn, me as outerHtml, Vt as paragraphStyleBtn, he as placeCaret, se as prevElement, Xt as printBtn, Se as rangeFromElement, u as rect2bnd, kt as redoBtn, k as registerButton, nn as registerLocale, S as remove, Rt as removeFormatBtn, ge as repairListNesting, rn as resolveLocale, M as sanitiseHTML, _n as sanitiseToBody, N as sanitiseUrl, Gt as shortcutsBtn, Ee as splitText, _t as strikeBtn, yt as subscriptBtn, vt as superscriptBtn, It as tableBtn, ni as tail, n as throttle, ve as trapFocus, wt as ulBtn, gt as underlineBtn, Ot as undoBtn, ii as unique, le as unwrap, Nt as videoBtn, Te as withSavedRange, ue as wrap };
5264
+ export { Yn as Context, wt as DEFAULT_FONT_SIZES, Tt as DEFAULT_LINE_HEIGHTS, Et as DEFAULT_PARAGRAPH_STYLES, f as ELEMENT_NODE, li as SUPPORTED_LANGS, p as TEXT_NODE, S as WrappedRange, E as _buttonRegistry, xt as _iconRegistry, Pt as alignCenterBtn, It as alignJustifyBtn, Nt as alignLeftBtn, Ft as alignRightBtn, Ri as all, ce as ancestors, zi as any, fn as backColorBtn, Dt as boldBtn, mn as buttons, ln as checklistBtn, le as children, Ii as chunk, e as clamp, v as closest, se as closestPara, nn as codeviewBtn, De as collapsedRange, r as compose, b as createElement, Te as currentRange, t as debounce, l as deepEqual, Hi as default, k as defaultOptions, pn as defaultToolbar, pi as detectLang, Qt as directionBtn, qt as emojiBtn, Bi as env, on as findBtn, sn as findReplaceBtn, ji as first, Pi as flatten, $t as fontFamilyBtn, Xt as fontSizeBtn, dn as foreColorBtn, we as fromNativeRange, rn as fullscreenBtn, _t as getButton, Li as groupBy, Ut as hrBtn, vr as htmlToMarkdown, Jt as iconBtn, i as identity, Gt as imageBtn, zt as indentBtn, Mi as initial, cn as inlineCodeBtn, me as insertAfter, Fn as isAllowedIframeSrc, ae as isAnchor, ie as isEditable, m as isElement, ge as isEmpty, s as isFunction, oe as isImage, re as isInline, be as isInsideEditable, F as isKey, te as isLi, _ as isList, Dr as isMarkdown, or as isModifier, a as isNil, g as isPara, u as isPlainObject, Oe as isSelectionInside, o as isString, ne as isTable, h as isText, ee as isVoid, Ot as italicBtn, P as key, Ai as last, tn as lineHeightBtn, Wt as linkBtn, hn as locales, Se as makeDraggable, H as markdownToHTML, c as mergeDeep, ue as nextElement, he as nodeValue, Rt as olBtn, x as on, Bt as outdentBtn, _e as outerHtml, en as paragraphStyleBtn, ve as placeCaret, Ce as portalOf, y as prevElement, un as printBtn, Ee as rangeFromElement, d as rect2bnd, Ht as redoBtn, D as registerButton, St as registerIcon, gn as registerLocale, de as remove, Zt as removeFormatBtn, ye as repairListNesting, bt as resolveButton, O as resolveIcon, _n as resolveLocale, j as sanitiseHTML, An as sanitiseToBody, M as sanitiseUrl, an as shortcutsBtn, Ae as splitText, At as strikeBtn, Mt as subscriptBtn, jt as superscriptBtn, Yt as tableBtn, Ni as tail, n as throttle, xe as trapFocus, Lt as ulBtn, kt as underlineBtn, Vt as undoBtn, Fi as unique, fe as unwrap, Kt as videoBtn, ke as withSavedRange, pe as wrap };
4935
5265
 
4936
5266
  //# sourceMappingURL=autumnnote.core.es.js.map