autumnnote 2.7.1 → 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)) n[r] = l(t[r]) ? c(l(e[r]) ? e[r] : {}, t[r]) : Array.isArray(t[r]) ? [...t[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,7 +457,7 @@ 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");
@@ -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,7 +588,7 @@ 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;
@@ -594,8 +608,8 @@ function dt() {
594
608
  }
595
609
  }
596
610
  } else {
597
- let t = E(r, "ul");
598
- t.classList.add("an-checklist"), ut(t);
611
+ let t = w(r, "ul");
612
+ t.classList.add("an-checklist"), mt(t);
599
613
  let n = t.querySelector("li");
600
614
  if (n) {
601
615
  let t = document.createRange();
@@ -668,7 +682,7 @@ function dt() {
668
682
  }
669
683
  }
670
684
  }
671
- function ft() {
685
+ function gt() {
672
686
  let e = globalThis.getSelection();
673
687
  if (!e?.rangeCount) return !1;
674
688
  let t = e.getRangeAt(0).commonAncestorContainer;
@@ -676,7 +690,7 @@ function ft() {
676
690
  }
677
691
  //#endregion
678
692
  //#region src/js/module/Buttons.js
679
- function D(e, t, n, r, i, a) {
693
+ function T(e, t, n, r, i, a) {
680
694
  return {
681
695
  name: e,
682
696
  icon: t,
@@ -686,24 +700,121 @@ function D(e, t, n, r, i, a) {
686
700
  isDisabled: a
687
701
  };
688
702
  }
689
- var O = /* @__PURE__ */ new Map();
690
- function k(e) {
703
+ var E = /* @__PURE__ */ new Map();
704
+ function D(e) {
691
705
  if (!e || typeof e.name != "string") {
692
706
  console.warn("[AutumnNote] registerButton: btnDef must have a string `name` property.");
693
707
  return;
694
708
  }
695
- 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);
710
+ }
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;
696
717
  }
697
- function pt(e) {
698
- return O.get(e);
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);
728
+ }
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>`;
699
740
  }
700
- 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(), () => {
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(), () => {
701
812
  if (document.queryCommandState("underline")) return !0;
702
813
  let e = globalThis.getSelection();
703
814
  if (!e?.rangeCount) return !1;
704
815
  let t = e.getRangeAt(0).startContainer;
705
816
  return t.nodeType === 3 && (t = t.parentElement), !!t?.closest("u");
706
- }), _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 = {
707
818
  name: "table",
708
819
  type: "grid",
709
820
  icon: "table",
@@ -711,30 +822,14 @@ var mt = D("bold", "bold", "Bold (Ctrl+B)", () => Le(), () => document.queryComm
711
822
  action: (e, t, n) => {
712
823
  e.invoke("editor.insertTable", n, t), e.invoke("editor.afterCommand");
713
824
  }
714
- }, Lt = {
825
+ }, Xt = {
715
826
  name: "fontSize",
716
827
  type: "select",
717
828
  tooltip: "Font Size",
718
829
  placeholder: "Size",
719
830
  selectClass: "an-select-narrow",
720
- items: [
721
- "8px",
722
- "10px",
723
- "11px",
724
- "12px",
725
- "13px",
726
- "14px",
727
- "16px",
728
- "18px",
729
- "20px",
730
- "24px",
731
- "28px",
732
- "32px",
733
- "36px",
734
- "48px",
735
- "72px"
736
- ],
737
- action: (e, t) => Ke(t, e.layoutInfo.editable),
831
+ items: wt,
832
+ action: (e, t) => Xe(t, e.layoutInfo.editable),
738
833
  getValue: (e) => {
739
834
  try {
740
835
  let t = globalThis.getSelection();
@@ -750,14 +845,14 @@ var mt = D("bold", "bold", "Bold (Ctrl+B)", () => Le(), () => document.queryComm
750
845
  return "";
751
846
  }
752
847
  }
753
- }, 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) => {
754
849
  let t = e.layoutInfo.editable, n = (t.getAttribute("dir") || "ltr") === "ltr" ? "rtl" : "ltr";
755
850
  t.setAttribute("dir", n), t.style.textAlign = n === "rtl" ? "right" : "left", e.invoke("editor.afterCommand");
756
- }), Bt = {
851
+ }), $t = {
757
852
  name: "fontFamily",
758
853
  type: "select",
759
854
  tooltip: "Font Family",
760
- action: (e, t) => Ge(t),
855
+ action: (e, t) => Ye(t),
761
856
  getValue: () => {
762
857
  try {
763
858
  return document.queryCommandValue("fontName") || "";
@@ -765,51 +860,14 @@ var mt = D("bold", "bold", "Bold (Ctrl+B)", () => Le(), () => document.queryComm
765
860
  return "";
766
861
  }
767
862
  }
768
- }, Vt = {
863
+ }, en = {
769
864
  name: "paragraphStyle",
770
865
  type: "select",
771
866
  tooltip: "Paragraph Style",
772
867
  placeholder: "Style",
773
868
  selectClass: "an-select-style",
774
- items: [
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
- ],
812
- action: (e, t) => qe(t),
869
+ items: Et,
870
+ action: (e, t) => Ze(t),
813
871
  getValue: () => {
814
872
  try {
815
873
  let e = document.queryCommandValue("formatBlock").toLowerCase().replace(/[<>]/g, "");
@@ -818,22 +876,14 @@ var mt = D("bold", "bold", "Bold (Ctrl+B)", () => Le(), () => document.queryComm
818
876
  return "";
819
877
  }
820
878
  }
821
- }, Ht = {
879
+ }, tn = {
822
880
  name: "lineHeight",
823
881
  type: "select",
824
882
  tooltip: "Line Height",
825
883
  placeholder: "↕ Line",
826
884
  selectClass: "an-select-narrow",
827
- items: [
828
- "1.0",
829
- "1.15",
830
- "1.5",
831
- "1.75",
832
- "2.0",
833
- "2.5",
834
- "3.0"
835
- ],
836
- action: (e, t) => st(t),
885
+ items: Tt,
886
+ action: (e, t) => dt(t),
837
887
  getValue: () => {
838
888
  try {
839
889
  let e = globalThis.getSelection();
@@ -859,116 +909,117 @@ var mt = D("bold", "bold", "Bold (Ctrl+B)", () => Le(), () => document.queryComm
859
909
  return "";
860
910
  }
861
911
  }
862
- }, 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 = {
863
913
  name: "foreColor",
864
914
  type: "colorpicker",
865
915
  icon: "foreColor",
866
916
  tooltip: "Text Color",
867
917
  defaultColor: "#e11d48",
868
- action: (e, t) => Ue(t)
869
- }, Qt = {
918
+ action: (e, t) => qe(t)
919
+ }, fn = {
870
920
  name: "backColor",
871
921
  type: "colorpicker",
872
922
  icon: "backColor",
873
923
  tooltip: "Highlight Color",
874
924
  defaultColor: "#fbbf24",
875
- action: (e, t) => We(t)
876
- }, $t = [
925
+ action: (e, t) => Je(t)
926
+ }, pn = [
877
927
  [
878
- Vt,
879
- Bt,
880
- Lt,
881
- Ht
882
- ],
883
- [Ot, kt],
884
- [
885
- mt,
886
- ht,
887
- gt,
888
- _t,
889
- Jt
890
- ],
891
- [vt, yt],
892
- [Zt, Qt],
893
- [
894
- bt,
895
- xt,
896
- St,
897
- Ct
928
+ en,
929
+ $t,
930
+ Xt,
931
+ tn
898
932
  ],
933
+ [Vt, Ht],
899
934
  [
900
- wt,
901
- Tt,
902
- Yt,
903
- Et,
904
- Dt
935
+ Dt,
936
+ Ot,
937
+ kt,
938
+ At,
939
+ cn
905
940
  ],
941
+ [jt, Mt],
942
+ [dn, fn],
906
943
  [
907
- At,
908
- jt,
909
- Mt,
910
944
  Nt,
911
- It,
912
945
  Pt,
913
- Ft
946
+ Ft,
947
+ It
914
948
  ],
915
949
  [
950
+ Lt,
916
951
  Rt,
952
+ ln,
953
+ zt,
954
+ Bt
955
+ ],
956
+ [
917
957
  Ut,
918
958
  Wt,
959
+ Gt,
919
960
  Kt,
920
- Xt,
921
- Gt
961
+ Yt,
962
+ qt,
963
+ Jt
964
+ ],
965
+ [
966
+ Zt,
967
+ nn,
968
+ rn,
969
+ on,
970
+ un,
971
+ an
922
972
  ]
923
- ], en = {
924
- boldBtn: mt,
925
- italicBtn: ht,
926
- underlineBtn: gt,
927
- strikeBtn: _t,
928
- superscriptBtn: vt,
929
- subscriptBtn: yt,
930
- alignLeftBtn: bt,
931
- alignCenterBtn: xt,
932
- alignRightBtn: St,
933
- alignJustifyBtn: Ct,
934
- ulBtn: wt,
935
- olBtn: Tt,
936
- indentBtn: Et,
937
- outdentBtn: Dt,
938
- undoBtn: Ot,
939
- redoBtn: kt,
940
- hrBtn: At,
941
- linkBtn: jt,
942
- imageBtn: Mt,
943
- videoBtn: Nt,
944
- emojiBtn: Pt,
945
- iconBtn: Ft,
946
- tableBtn: It,
947
- fontSizeBtn: Lt,
948
- removeFormatBtn: Rt,
949
- directionBtn: zt,
950
- fontFamilyBtn: Bt,
951
- paragraphStyleBtn: Vt,
952
- lineHeightBtn: Ht,
953
- codeviewBtn: Ut,
954
- fullscreenBtn: Wt,
955
- shortcutsBtn: Gt,
956
- findBtn: Kt,
957
- findReplaceBtn: qt,
958
- inlineCodeBtn: Jt,
959
- checklistBtn: Yt,
960
- printBtn: Xt,
961
- foreColorBtn: Zt,
962
- backColorBtn: Qt,
963
- defaultToolbar: $t
964
- }, 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 = {
965
1015
  placeholder: "",
966
1016
  height: 200,
967
1017
  minHeight: 100,
968
1018
  maxHeight: 0,
969
1019
  focus: !1,
970
1020
  resizable: !0,
971
- toolbar: $t,
1021
+ statusbar: !0,
1022
+ toolbar: pn,
972
1023
  useBootstrap: !1,
973
1024
  toolbarButtonClass: "btn btn-sm btn-light",
974
1025
  useFontAwesome: !0,
@@ -990,6 +1041,9 @@ var mt = D("bold", "bold", "Bold (Ctrl+B)", () => Le(), () => document.queryComm
990
1041
  stickyToolbar: !1,
991
1042
  stickyToolbarOffset: 0,
992
1043
  theme: "light",
1044
+ themeVars: null,
1045
+ zIndexOffset: 0,
1046
+ popupContainer: null,
993
1047
  codeHighlight: !0,
994
1048
  codeHighlightCDN: "https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0",
995
1049
  cspNonce: "",
@@ -1000,6 +1054,20 @@ var mt = D("bold", "bold", "Bold (Ctrl+B)", () => Le(), () => document.queryComm
1000
1054
  historyMaxBytes: 10485760,
1001
1055
  defaultFontFamily: "Arial",
1002
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,
1003
1071
  fontFamilies: [
1004
1072
  "Arial",
1005
1073
  "Arial Black",
@@ -1028,6 +1096,7 @@ var mt = D("bold", "bold", "Bold (Ctrl+B)", () => Le(), () => document.queryComm
1028
1096
  onPaste: null,
1029
1097
  onPasteError: null,
1030
1098
  onDestroy: null,
1099
+ onBeforeCommand: null,
1031
1100
  onCharLimitReached: null,
1032
1101
  onWordLimitReached: null,
1033
1102
  focusColor: null,
@@ -1054,8 +1123,9 @@ var mt = D("bold", "bold", "Bold (Ctrl+B)", () => Le(), () => document.queryComm
1054
1123
  "hiliteColor",
1055
1124
  "removeFormat"
1056
1125
  ],
1126
+ contextMenu: null,
1057
1127
  mention: null
1058
- }, j = {
1128
+ }, A = {
1059
1129
  toolbar: {
1060
1130
  bold: "Bold (Ctrl+B)",
1061
1131
  italic: "Italic (Ctrl+I)",
@@ -1205,6 +1275,8 @@ var mt = D("bold", "bold", "Bold (Ctrl+B)", () => Le(), () => document.queryComm
1205
1275
  replaceAllBtn: "Replace All",
1206
1276
  noResults: "No results",
1207
1277
  useRegex: "Use Regular Expression",
1278
+ prevMatch: "Previous (Shift+Enter)",
1279
+ nextMatch: "Next (Enter)",
1208
1280
  close: "×"
1209
1281
  },
1210
1282
  autoSaveRestore: {
@@ -1217,6 +1289,7 @@ var mt = D("bold", "bold", "Bold (Ctrl+B)", () => Le(), () => document.queryComm
1217
1289
  title: "Keyboard Shortcuts",
1218
1290
  ariaLabel: "Keyboard Shortcuts",
1219
1291
  close: "Close",
1292
+ customCategory: "Custom",
1220
1293
  shortcuts: [
1221
1294
  {
1222
1295
  category: "Text Formatting",
@@ -1320,6 +1393,12 @@ var mt = D("bold", "bold", "Bold (Ctrl+B)", () => Le(), () => document.queryComm
1320
1393
  chars: (e) => `Chars: ${e}`,
1321
1394
  charsLimit: (e, t) => `Chars: ${e}/${t}`
1322
1395
  },
1396
+ a11y: {
1397
+ editor: "Rich text editor",
1398
+ toolbar: "Editor toolbar",
1399
+ statistics: "Editor statistics",
1400
+ tableSize: "Select table size"
1401
+ },
1323
1402
  tooltips: {
1324
1403
  link: {
1325
1404
  ariaLabel: "Link actions",
@@ -1422,23 +1501,23 @@ var mt = D("bold", "bold", "Bold (Ctrl+B)", () => Le(), () => document.queryComm
1422
1501
  table: "Table",
1423
1502
  image: "Image"
1424
1503
  }
1425
- }, tn = { en: j };
1426
- function nn(e, t) {
1504
+ }, hn = { en: A };
1505
+ function gn(e, t) {
1427
1506
  if (typeof e != "string" || !e) throw TypeError("[AutumnNote] registerLocale: code must be a non-empty string.");
1428
1507
  if (!t || typeof t != "object") throw TypeError(`[AutumnNote] registerLocale: locale for "${e}" must be an object.`);
1429
- tn[e] = t;
1508
+ hn[e] = t;
1430
1509
  }
1431
- function rn(e) {
1432
- if (!e || e === "en") return j;
1510
+ function _n(e) {
1511
+ if (!e || e === "en") return A;
1433
1512
  if (typeof e == "string") {
1434
- let t = tn[e];
1435
- 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);
1436
1515
  }
1437
- return typeof e == "object" ? c(c({}, j), e) : j;
1516
+ return typeof e == "object" ? c(c({}, A), e) : A;
1438
1517
  }
1439
1518
  //#endregion
1440
1519
  //#region src/js/core/sanitise.js
1441
- var an = [
1520
+ var vn = [
1442
1521
  "script",
1443
1522
  "style",
1444
1523
  "iframe",
@@ -1461,7 +1540,7 @@ var an = [
1461
1540
  "mglyph",
1462
1541
  "malignmark",
1463
1542
  "annotation-xml"
1464
- ], on = /* @__PURE__ */ new Set(["button"]), sn = [
1543
+ ], yn = /* @__PURE__ */ new Set(["button"]), bn = [
1465
1544
  "href",
1466
1545
  "src",
1467
1546
  "action",
@@ -1470,11 +1549,11 @@ var an = [
1470
1549
  "poster",
1471
1550
  "background",
1472
1551
  "srcset"
1473
- ], cn = /* @__PURE__ */ new Set([
1552
+ ], xn = /* @__PURE__ */ new Set([
1474
1553
  "poster",
1475
1554
  "background",
1476
1555
  "srcset"
1477
- ]), ln = /* @__PURE__ */ new Set(["ping"]), un = /* @__PURE__ */ new Set([
1556
+ ]), Sn = /* @__PURE__ */ new Set(["ping"]), Cn = /* @__PURE__ */ new Set([
1478
1557
  "color",
1479
1558
  "background-color",
1480
1559
  "font-size",
@@ -1490,41 +1569,41 @@ var an = [
1490
1569
  "border-color",
1491
1570
  "padding",
1492
1571
  "white-space"
1493
- ]), 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([
1494
1573
  "www.youtube.com",
1495
1574
  "youtube.com",
1496
1575
  "m.youtube.com",
1497
1576
  "www.youtube-nocookie.com",
1498
1577
  "youtube-nocookie.com",
1499
1578
  "player.vimeo.com"
1500
- ]), pn = /* @__PURE__ */ new Set([
1579
+ ]), En = /* @__PURE__ */ new Set([
1501
1580
  "http:",
1502
1581
  "https:",
1503
1582
  "mailto:",
1504
1583
  "tel:"
1505
- ]), mn = /* @__PURE__ */ new Set([
1584
+ ]), Dn = /* @__PURE__ */ new Set([
1506
1585
  "http:",
1507
1586
  "https:",
1508
1587
  "blob:"
1509
- ]), hn = /^data:image\/(?:png|jpe?g|gif|webp|avif|bmp);base64,[a-z0-9+/=\s]+$/i, gn = "https://autumnnote.invalid/";
1510
- function M(e, t) {
1511
- 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;
1512
1591
  }
1513
- function _n(e, { allowIframes: t = !1 } = {}) {
1514
- 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);
1515
- 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) {
1516
1595
  let t = e.tagName.toLowerCase();
1517
- if (on.has(t)) {
1596
+ if (yn.has(t)) {
1518
1597
  e.replaceWith(...e.childNodes);
1519
1598
  continue;
1520
1599
  }
1521
- if (i.has(t)) {
1600
+ if (o.has(t)) {
1522
1601
  e.remove();
1523
1602
  continue;
1524
1603
  }
1525
1604
  if (t === "iframe") {
1526
1605
  let t = e.getAttribute("src");
1527
- if (!t || !bn(t)) {
1606
+ if (!t || !Pn(t, i)) {
1528
1607
  e.remove();
1529
1608
  continue;
1530
1609
  }
@@ -1535,22 +1614,22 @@ function _n(e, { allowIframes: t = !1 } = {}) {
1535
1614
  continue;
1536
1615
  }
1537
1616
  if (t.name === "style") {
1538
- let n = vn(t.value);
1617
+ let n = jn(t.value);
1539
1618
  n ? e.setAttribute("style", n) : e.removeAttribute("style");
1540
1619
  continue;
1541
1620
  }
1542
- if (ln.has(t.name)) {
1621
+ if (Sn.has(t.name)) {
1543
1622
  e.removeAttribute(t.name);
1544
1623
  continue;
1545
1624
  }
1546
- if (sn.includes(t.name)) {
1547
- 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" && [
1548
1627
  "IMG",
1549
1628
  "VIDEO",
1550
1629
  "AUDIO",
1551
1630
  "SOURCE"
1552
1631
  ].includes(e.tagName), i = e.tagName === "IMG";
1553
- if (!(t.name === "srcset" ? yn(n, { allowData: i }) : xn(n, {
1632
+ if (!(t.name === "srcset" ? Mn(n, { allowData: i }) : In(n, {
1554
1633
  media: r,
1555
1634
  allowData: i
1556
1635
  }))) {
@@ -1563,7 +1642,7 @@ function _n(e, { allowIframes: t = !1 } = {}) {
1563
1642
  e.removeAttribute(t.name);
1564
1643
  continue;
1565
1644
  }
1566
- t.name === "src" && !bn(t.value) && e.removeAttribute(t.name);
1645
+ t.name === "src" && !Pn(t.value, i) && e.removeAttribute(t.name);
1567
1646
  }
1568
1647
  }
1569
1648
  if (t === "a" && e.getAttribute("target") === "_blank" && e.setAttribute("rel", "noopener noreferrer"), t === "input") {
@@ -1575,61 +1654,75 @@ function _n(e, { allowIframes: t = !1 } = {}) {
1575
1654
  ].includes(t.name) || e.removeAttribute(t.name);
1576
1655
  }
1577
1656
  }
1578
- return n.body;
1657
+ return r.body;
1579
1658
  }
1580
- function vn(e) {
1659
+ function jn(e) {
1581
1660
  let t = [];
1582
1661
  for (let n of (e || "").split(";")) {
1583
1662
  let e = n.indexOf(":");
1584
1663
  if (e === -1) continue;
1585
1664
  let r = n.slice(0, e).trim().toLowerCase(), i = n.slice(e + 1).trim();
1586
- !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}`));
1587
1666
  }
1588
1667
  return t.join("; ");
1589
1668
  }
1590
- function yn(e, { allowData: t = !1 } = {}) {
1669
+ function Mn(e, { allowData: t = !1 } = {}) {
1591
1670
  let n = (e || "").trim().split(/\s+/).filter(Boolean);
1592
1671
  for (let e of n) {
1593
1672
  if (/^[\d.]+[xw],?$/i.test(e)) continue;
1594
1673
  let n = e.replace(/,+$/, "");
1595
- if (n && !xn(n, {
1674
+ if (n && !In(n, {
1596
1675
  media: !0,
1597
1676
  allowData: t
1598
1677
  })) return !1;
1599
1678
  }
1600
1679
  return !0;
1601
1680
  }
1602
- function bn(e) {
1603
- let t = (e || "").trim();
1604
- 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;
1605
1693
  try {
1606
- let e = new URL(t);
1607
- 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);
1608
1698
  } catch {
1609
1699
  return !1;
1610
1700
  }
1611
1701
  }
1612
- 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 } = {}) {
1613
1706
  let r = (e || "").trim();
1614
- return !r && e == null ? null : xn(r, {
1707
+ return !r && e == null ? null : In(r, {
1615
1708
  media: n,
1616
1709
  allowData: t
1617
1710
  }) ? e : null;
1618
1711
  }
1619
- function xn(e, { media: t = !1, allowData: n = !1 } = {}) {
1712
+ function In(e, { media: t = !1, allowData: n = !1 } = {}) {
1620
1713
  let r = (e || "").trim();
1621
- if (!r || n && hn.test(r)) return !0;
1714
+ if (!r || n && On.test(r)) return !0;
1622
1715
  try {
1623
- let e = new URL(r, gn);
1624
- return (t ? mn : pn).has(e.protocol);
1716
+ let e = new URL(r, kn);
1717
+ return (t ? Dn : En).has(e.protocol);
1625
1718
  } catch {
1626
1719
  return !1;
1627
1720
  }
1628
1721
  }
1629
1722
  //#endregion
1630
1723
  //#region src/js/renderer.js
1631
- function Sn(e, t) {
1632
- 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", {
1633
1726
  class: "an-editable",
1634
1727
  contenteditable: t.readOnly ? "false" : "true",
1635
1728
  spellcheck: String(t.spellcheck !== !1),
@@ -1640,43 +1733,102 @@ function Sn(e, t) {
1640
1733
  if (t.autoSave && t.autoSaveKey) try {
1641
1734
  i = localStorage.getItem(t.autoSaveKey) || "";
1642
1735
  } catch {}
1643
- 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
+ });
1644
1740
  let a = t.defaultFontFamily || t.fontFamilies?.[0];
1645
- 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) => {
1646
1742
  e.setAttribute("disabled", "");
1647
- })), 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), {
1648
1744
  container: n,
1649
1745
  editable: r
1650
1746
  };
1651
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
+ }
1652
1780
  //#endregion
1653
1781
  //#region src/js/Context.js
1654
- var Cn = /* @__PURE__ */ new Map(), wn = [];
1655
- function Tn(e) {
1656
- wn = Array.isArray(e) ? e : [];
1657
- }
1658
- 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 {
1659
1809
  constructor(e, t = {}) {
1660
- 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;
1661
1811
  }
1662
1812
  initialize() {
1663
- let { container: e, editable: t } = Sn(this.targetEl, this.options);
1664
- this.layoutInfo.container = e, this.layoutInfo.editable = t, this._registerModules();
1665
- let n = this._modules.get("toolbar");
1666
- n?.el && (e.insertBefore(n.el, t), this.layoutInfo.toolbar = n.el);
1667
- let r = this._modules.get("statusbar");
1668
- 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;
1669
1821
  }
1670
1822
  _registerModules() {
1671
1823
  let e = (e, t) => {
1672
1824
  let n = new t(this);
1673
1825
  this._modules.set(e, n), n.initialize();
1674
1826
  };
1675
- for (let { name: t, Class: n, enabled: r } of wn) typeof r == "function" && !r(this.options) || e(t, n);
1676
- 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);
1677
1829
  }
1678
1830
  _syncOptionalModules() {
1679
- for (let { name: e, Class: t, enabled: n } of wn) {
1831
+ for (let { name: e, Class: t, enabled: n } of Wn) {
1680
1832
  if (typeof n != "function") continue;
1681
1833
  let r = n(this.options);
1682
1834
  if (r !== this._modules.has(e)) {
@@ -1701,7 +1853,7 @@ var P = /* @__PURE__ */ new Map(), En = class {
1701
1853
  return n >= 0 ? t[n] = e : t.push(e), this.invoke("slashMenu.refresh"), this;
1702
1854
  }
1703
1855
  use(e, t = {}) {
1704
- 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;
1705
1857
  }
1706
1858
  getPlugin(e) {
1707
1859
  return this._plugins.get(e)?.publicApi ?? null;
@@ -1723,13 +1875,13 @@ var P = /* @__PURE__ */ new Map(), En = class {
1723
1875
  });
1724
1876
  }
1725
1877
  _applyGlobalPlugins() {
1726
- 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);
1727
1879
  }
1728
1880
  _bindEditorEvents(e) {
1729
- let t = C(e, "input", () => this._syncToTarget()), n = C(e, "focus", () => {
1730
- this.layoutInfo.container.classList.add("an-focused"), typeof this.options.onFocus == "function" && this.options.onFocus(this);
1731
- }), r = C(e, "blur", () => {
1732
- 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);
1733
1885
  }), i = this.on("change", (e) => this._syncToTarget(e)), a = this.on("change", (e) => {
1734
1886
  if (this.options.blockIds && (this.ensureBlockIds(), e = this.getHTML()), e === this._suppressedRemoteHTML) {
1735
1887
  this._suppressedRemoteHTML = null;
@@ -1803,23 +1955,33 @@ var P = /* @__PURE__ */ new Map(), En = class {
1803
1955
  r !== -1 && n.splice(r, 1);
1804
1956
  }
1805
1957
  triggerEvent(e, ...t) {
1806
- (this._listeners.get(e) || []).forEach((e) => e(...t));
1807
- let n = "on" + e.charAt(0).toUpperCase() + e.slice(1);
1808
- 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;
1809
1969
  }
1810
1970
  updateOptions(e = {}) {
1811
- let t = c(this.options, e);
1812
- Object.keys(this.options).forEach((e) => delete this.options[e]), Object.assign(this.options, t);
1813
- let { container: n, editable: r } = this.layoutInfo;
1814
- 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")) {
1815
1975
  let e = this.options.direction === "rtl";
1816
- 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);
1817
1977
  }
1818
1978
  if (Object.hasOwn(e, "height") || Object.hasOwn(e, "minHeight")) {
1819
1979
  let e = this.options.height || this.options.minHeight || 0;
1820
- r.style.minHeight = e ? `${e}px` : "";
1980
+ a.style.minHeight = e ? `${e}px` : "";
1821
1981
  }
1822
- 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;
1823
1985
  }
1824
1986
  getHTML() {
1825
1987
  let e = this.invoke("editor.getHTML");
@@ -1968,8 +2130,8 @@ var P = /* @__PURE__ */ new Map(), En = class {
1968
2130
  e.uninstall(this);
1969
2131
  } catch {}
1970
2132
  this._plugins.clear(), this._disposers.forEach((e) => e()), this._disposers = [];
1971
- let t = this.layoutInfo.container, n = t?.classList.contains("an-theme-dark"), r = t?.classList.contains("an-theme-auto");
1972
- 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(() => {
1973
2135
  this._listeners.clear();
1974
2136
  }), this._destroyPromise;
1975
2137
  }
@@ -1979,12 +2141,12 @@ var P = /* @__PURE__ */ new Map(), En = class {
1979
2141
  };
1980
2142
  //#endregion
1981
2143
  //#region src/js/editing/History.js
1982
- function Dn(e, t) {
2144
+ function Xn(e, t) {
1983
2145
  let n = Math.min(e.length, t.length), r = 0;
1984
2146
  for (; r < n && e.charCodeAt(r) === t.charCodeAt(r);) r++;
1985
2147
  return r;
1986
2148
  }
1987
- var On = class {
2149
+ var Zn = class {
1988
2150
  constructor(e, t = 100, n = 10485760) {
1989
2151
  this.editable = e, this._limit = t, this._maxBytes = n, this._bytes = 0, this.stack = [], this.stackOffset = -1, this._savePoint();
1990
2152
  }
@@ -2063,7 +2225,7 @@ var On = class {
2063
2225
  this.editable.innerHTML = this._detokenizeImages(e);
2064
2226
  let n = e.sel;
2065
2227
  if (!n) {
2066
- let e = Dn(t, this.editable.textContent || "");
2228
+ let e = Xn(t, this.editable.textContent || "");
2067
2229
  n = {
2068
2230
  start: e,
2069
2231
  end: e
@@ -2116,31 +2278,31 @@ var On = class {
2116
2278
  };
2117
2279
  //#endregion
2118
2280
  //#region src/js/editing/Table.js
2119
- function kn(e, t, n = {}) {
2120
- 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" });
2121
2283
  if (r && t > 0) {
2122
- let t = x("thead"), n = x("tr");
2284
+ let t = b("thead"), n = b("tr");
2123
2285
  for (let t = 0; t < e; t++) {
2124
- let e = x("th", {}, [document.createElement("br")]);
2286
+ let e = b("th", {}, [document.createElement("br")]);
2125
2287
  n.appendChild(e);
2126
2288
  }
2127
2289
  t.appendChild(n), i.appendChild(t);
2128
2290
  }
2129
- 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");
2130
2292
  i.appendChild(o);
2131
2293
  for (let t = 0; t < a; t++) {
2132
- let t = x("tr");
2294
+ let t = b("tr");
2133
2295
  for (let n = 0; n < e; n++) {
2134
- let e = x("td", {}, [document.createElement("br")]);
2296
+ let e = b("td", {}, [document.createElement("br")]);
2135
2297
  t.appendChild(e);
2136
2298
  }
2137
2299
  o.appendChild(t);
2138
2300
  }
2139
2301
  return i;
2140
2302
  }
2141
- function An(e, t, n = {}) {
2303
+ function $n(e, t, n = {}) {
2142
2304
  if (e <= 0 || t <= 0) return;
2143
- let r = kn(e, t, n), i = globalThis.getSelection();
2305
+ let r = Qn(e, t, n), i = globalThis.getSelection();
2144
2306
  if (!i || i.rangeCount === 0) return;
2145
2307
  let a = i.getRangeAt(0);
2146
2308
  try {
@@ -2180,8 +2342,108 @@ function An(e, t, n = {}) {
2180
2342
  }
2181
2343
  }
2182
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
2183
2445
  //#region src/js/core/key.js
2184
- var F = {
2446
+ var P = {
2185
2447
  BACKSPACE: "Backspace",
2186
2448
  TAB: "Tab",
2187
2449
  ENTER: "Enter",
@@ -2220,27 +2482,27 @@ var F = {
2220
2482
  SLASH: "/",
2221
2483
  PERIOD: "."
2222
2484
  };
2223
- function I(e, t) {
2485
+ function F(e, t) {
2224
2486
  return e.key === t || e.key === t.toUpperCase();
2225
2487
  }
2226
- function L(e, t) {
2227
- return (e.ctrlKey || e.metaKey) && I(e, t);
2488
+ function or(e, t) {
2489
+ return (e.ctrlKey || e.metaKey) && F(e, t);
2228
2490
  }
2229
2491
  //#endregion
2230
2492
  //#region src/js/editing/Typing.js
2231
- var jn = /\bfa-/, R = (e) => !!(e?.nodeName === "I" && jn.test(e.className || "")), z = (e) => !(e?.nodeType !== Node.TEXT_NODE || e.textContent !== "​" && e.textContent !== "");
2232
- 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) {
2233
2495
  let r = (e?.nodeType === Node.ELEMENT_NODE ? e : e?.parentElement ?? null)?.closest("td, th") ?? null;
2234
2496
  if (!r || !t.contains(r)) return !1;
2235
2497
  let i = r.closest("table");
2236
2498
  if (!i || !t.contains(i)) return !1;
2237
2499
  let a = Array.from(i.querySelectorAll("td, th")), o = a[a.indexOf(r) + (n ? -1 : 1)];
2238
- if (o) return he(o), !0;
2500
+ if (o) return ve(o), !0;
2239
2501
  if (n) return !0;
2240
- let s = Nn(r.closest("tr"))?.firstElementChild ?? null;
2241
- return s && he(s), !0;
2502
+ let s = lr(r.closest("tr"))?.firstElementChild ?? null;
2503
+ return s && ve(s), !0;
2242
2504
  }
2243
- function Nn(e) {
2505
+ function lr(e) {
2244
2506
  if (!e?.parentNode) return null;
2245
2507
  let t = document.createElement("tr");
2246
2508
  for (let n of e.cells) {
@@ -2249,7 +2511,7 @@ function Nn(e) {
2249
2511
  }
2250
2512
  return e.parentNode.insertBefore(t, e.nextSibling), t;
2251
2513
  }
2252
- function Pn(e, t) {
2514
+ function ur(e, t) {
2253
2515
  try {
2254
2516
  let n = document.createRange();
2255
2517
  return n.setStart(e.startContainer, e.startOffset), n.setEnd(t, t.childNodes.length), n.extractContents();
@@ -2257,21 +2519,21 @@ function Pn(e, t) {
2257
2519
  return document.createDocumentFragment();
2258
2520
  }
2259
2521
  }
2260
- function Fn(e, t, n = {}) {
2522
+ function dr(e, t, n = {}) {
2261
2523
  let r = (e) => {
2262
2524
  let t = globalThis.getSelection();
2263
2525
  if (!t) return !1;
2264
2526
  let n = document.createRange();
2265
2527
  return e(n), n.collapse(!0), t.removeAllRanges(), t.addRange(n), !0;
2266
2528
  };
2267
- if (I(e, F.BACKSPACE)) {
2529
+ if (F(e, P.BACKSPACE)) {
2268
2530
  let t = globalThis.getSelection();
2269
2531
  if (t?.rangeCount > 0) {
2270
2532
  let n = t.getRangeAt(0);
2271
2533
  if (n.collapsed && n.startContainer.nodeType === Node.TEXT_NODE) {
2272
2534
  let r = n.startContainer;
2273
- if (n.startOffset === 0 && R(r.previousSibling)) return e.preventDefault(), r.previousSibling.remove(), !0;
2274
- 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)) {
2275
2537
  e.preventDefault();
2276
2538
  let n = r.parentNode, i = r.previousSibling, a = i.previousSibling;
2277
2539
  i.remove(), r.remove();
@@ -2282,17 +2544,17 @@ function Fn(e, t, n = {}) {
2282
2544
  }
2283
2545
  return !1;
2284
2546
  }
2285
- if (I(e, F.LEFT) || I(e, F.RIGHT)) {
2547
+ if (F(e, P.LEFT) || F(e, P.RIGHT)) {
2286
2548
  let t = globalThis.getSelection();
2287
2549
  if (!t || t.rangeCount === 0) return !1;
2288
2550
  let n = t.getRangeAt(0);
2289
2551
  if (!n.collapsed) return !1;
2290
- let i = n.startContainer, a = I(e, F.LEFT);
2552
+ let i = n.startContainer, a = F(e, P.LEFT);
2291
2553
  if (i.nodeType === Node.TEXT_NODE) {
2292
2554
  let t = i;
2293
- 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));
2294
- if (a && n.startOffset === 0 && z(t.previousSibling) && R(t.previousSibling.previousSibling)) return e.preventDefault(), r((e) => e.setStartBefore(t.previousSibling.previousSibling));
2295
- 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)) {
2296
2558
  let n = t.nextSibling, i = n.nextSibling;
2297
2559
  if (e.preventDefault(), i?.nodeType === Node.TEXT_NODE) {
2298
2560
  let e = +!!(i.textContent || "").startsWith("​");
@@ -2300,7 +2562,7 @@ function Fn(e, t, n = {}) {
2300
2562
  }
2301
2563
  return r((e) => e.setStartAfter(n));
2302
2564
  }
2303
- 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)) {
2304
2566
  let n = t.nextSibling.nextSibling, i = n.nextSibling;
2305
2567
  if (e.preventDefault(), i?.nodeType === Node.TEXT_NODE) {
2306
2568
  let e = +!!(i.textContent || "").startsWith("​");
@@ -2313,12 +2575,12 @@ function Fn(e, t, n = {}) {
2313
2575
  let t = i;
2314
2576
  if (a && n.startOffset > 0) {
2315
2577
  let i = t.childNodes[n.startOffset - 1];
2316
- if (R(i)) return e.preventDefault(), r((e) => e.setStartBefore(i));
2317
- 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));
2318
2580
  }
2319
2581
  if (!a && n.startOffset < t.childNodes.length) {
2320
2582
  let i = t.childNodes[n.startOffset];
2321
- if (R(i)) {
2583
+ if (I(i)) {
2322
2584
  let t = i.nextSibling;
2323
2585
  if (e.preventDefault(), t?.nodeType === Node.TEXT_NODE) {
2324
2586
  let e = +!!(t.textContent || "").startsWith("​");
@@ -2326,7 +2588,7 @@ function Fn(e, t, n = {}) {
2326
2588
  }
2327
2589
  return r((e) => e.setStartAfter(i));
2328
2590
  }
2329
- if (z(i) && R(i.nextSibling)) {
2591
+ if (L(i) && I(i.nextSibling)) {
2330
2592
  let t = i.nextSibling, n = t.nextSibling;
2331
2593
  if (e.preventDefault(), n?.nodeType === Node.TEXT_NODE) {
2332
2594
  let e = +!!(n.textContent || "").startsWith("​");
@@ -2337,18 +2599,18 @@ function Fn(e, t, n = {}) {
2337
2599
  }
2338
2600
  }
2339
2601
  }
2340
- if (I(e, F.TAB)) {
2341
- let r = xe(t);
2602
+ if (F(e, P.TAB)) {
2603
+ let r = Te(t);
2342
2604
  if (!r) return !1;
2343
- if (Mn(r.sc, t, e.shiftKey)) return e.preventDefault(), !0;
2344
- let i = b(r.sc, t);
2345
- if (i && ee(i)) return e.preventDefault(), e.shiftKey ? et() : Qe(), !0;
2346
- if (i?.nodeName.toUpperCase() === "PRE") return !e.shiftKey && (e.preventDefault(), T("insertText", " ".repeat(n.tabSize || 4)), !0);
2347
- if (n.tabSize) return !e.shiftKey && (e.preventDefault(), T("insertText", " ".repeat(n.tabSize)), !0);
2348
- }
2349
- if (I(e, F.ENTER) && e.shiftKey) return e.preventDefault(), T("insertLineBreak"), !0;
2350
- if (I(e, F.ENTER) && !e.shiftKey) {
2351
- 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);
2352
2614
  if (!n) return !1;
2353
2615
  let r = n.sc, i = r.nodeType === 3 ? r.parentElement : r;
2354
2616
  if (i?.nodeName === "I" && /\bfa-/.test(i.className || "")) {
@@ -2381,46 +2643,46 @@ function Fn(e, t, n = {}) {
2381
2643
  if (r.deleteContents(), n.rangeCount === 0 || !o.isConnected) return !0;
2382
2644
  r = n.getRangeAt(0);
2383
2645
  }
2384
- 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");
2385
2647
  s.type = "checkbox", s.setAttribute("contenteditable", "false"), a.appendChild(s), i.textContent.replace(/[\u00a0\u200B]/g, "").length > 0 && a.appendChild(i);
2386
2648
  let c = a.childNodes[1];
2387
2649
  c?.nodeType !== Node.TEXT_NODE && (c = document.createTextNode("​"), a.appendChild(c)), o.after(a);
2388
2650
  let l = document.createRange();
2389
2651
  return l.setStart(c, 0), l.collapse(!0), n.removeAllRanges(), n.addRange(l), !0;
2390
2652
  }
2391
- let s = b(n.sc, t);
2392
- 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;
2393
2655
  if (s?.nodeName.toUpperCase() === "BLOCKQUOTE") {
2394
2656
  let t = n.toNativeRange();
2395
- 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;
2396
2658
  }
2397
2659
  }
2398
2660
  return !1;
2399
2661
  }
2400
2662
  //#endregion
2401
2663
  //#region src/js/core/count.js
2402
- var B = typeof Intl < "u" && typeof Intl.Segmenter == "function" ? new Intl.Segmenter(void 0, { granularity: "word" }) : null;
2403
- 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) {
2404
2666
  let t = e.trim();
2405
2667
  if (!t) return 0;
2406
- if (B) {
2668
+ if (R) {
2407
2669
  let e = 0;
2408
- for (let n of B.segment(t)) n.isWordLike && e++;
2670
+ for (let n of R.segment(t)) n.isWordLike && e++;
2409
2671
  return e;
2410
2672
  }
2411
2673
  return t.split(/\s+/).length;
2412
2674
  }
2413
- 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("."));
2414
- 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) {
2415
2677
  for (let r = e.firstChild; r; r = r.nextSibling) if (r.nodeType === 3) {
2416
2678
  let e = r.data;
2417
2679
  t.push(e), n.push(e);
2418
2680
  } else if (r.nodeType === 1) {
2419
- let e = Ln.has(r.tagName);
2420
- 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");
2421
2683
  }
2422
2684
  }
2423
- function zn(e) {
2685
+ function hr(e) {
2424
2686
  if (e.nodeType === 3) {
2425
2687
  let t = e.data;
2426
2688
  return {
@@ -2429,12 +2691,12 @@ function zn(e) {
2429
2691
  };
2430
2692
  }
2431
2693
  let t = [], n = [];
2432
- return Rn(e, t, n), {
2694
+ return mr(e, t, n), {
2433
2695
  lines: t.join(""),
2434
2696
  flat: n.join("")
2435
2697
  };
2436
2698
  }
2437
- var Bn = class {
2699
+ var gr = class {
2438
2700
  constructor() {
2439
2701
  this._cache = /* @__PURE__ */ new WeakMap();
2440
2702
  }
@@ -2446,7 +2708,7 @@ var Bn = class {
2446
2708
  t += e.words, n += e.chars;
2447
2709
  continue;
2448
2710
  }
2449
- let { lines: s, flat: c } = zn(o);
2711
+ let { lines: s, flat: c } = hr(o);
2450
2712
  r.push({
2451
2713
  node: o,
2452
2714
  key: c,
@@ -2455,7 +2717,7 @@ var Bn = class {
2455
2717
  }), i.push(s), a += s.length + 1;
2456
2718
  }
2457
2719
  if (r.length) {
2458
- let e = Vn(r, i.join("\n"));
2720
+ let e = _r(r, i.join("\n"));
2459
2721
  r.forEach((r, i) => {
2460
2722
  let a = {
2461
2723
  key: r.key,
@@ -2471,10 +2733,10 @@ var Bn = class {
2471
2733
  };
2472
2734
  }
2473
2735
  };
2474
- function Vn(e, t) {
2475
- if (!B) return e.map((e) => In(e.text));
2736
+ function _r(e, t) {
2737
+ if (!R) return e.map((e) => fr(e.text));
2476
2738
  let n = Array(e.length).fill(0), r = 0;
2477
- for (let i of B.segment(t)) if (i.isWordLike) {
2739
+ for (let i of R.segment(t)) if (i.isWordLike) {
2478
2740
  for (; r < e.length - 1 && i.index >= e[r + 1].start;) r++;
2479
2741
  n[r]++;
2480
2742
  }
@@ -2482,14 +2744,14 @@ function Vn(e, t) {
2482
2744
  }
2483
2745
  //#endregion
2484
2746
  //#region src/js/core/markdown.js
2485
- function Hn(e) {
2747
+ function vr(e) {
2486
2748
  let t = new DOMParser().parseFromString(`<body>${e || ""}</body>`, "text/html");
2487
- 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();
2488
2750
  }
2489
- function V(e, t) {
2751
+ function z(e, t) {
2490
2752
  return Array.from(e.children).filter((e) => e.tagName === t.toUpperCase());
2491
2753
  }
2492
- function Un(e) {
2754
+ function yr(e) {
2493
2755
  let t = "";
2494
2756
  for (let n of e.childNodes) {
2495
2757
  if (n.nodeType === 3) {
@@ -2503,40 +2765,40 @@ function Un(e) {
2503
2765
  continue;
2504
2766
  }
2505
2767
  if (e === "div" || e === "p") {
2506
- t && !t.endsWith("\n") && (t += "\n"), t += Un(n), t += "\n";
2768
+ t && !t.endsWith("\n") && (t += "\n"), t += yr(n), t += "\n";
2507
2769
  continue;
2508
2770
  }
2509
- t += Un(n);
2771
+ t += yr(n);
2510
2772
  }
2511
2773
  return t;
2512
2774
  }
2513
- function Wn(e) {
2775
+ function br(e) {
2514
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`\~`);
2515
2777
  }
2516
- function Gn(e) {
2778
+ function xr(e) {
2517
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}`);
2518
2780
  }
2519
- function Kn(e) {
2520
- return e.split("\n").map(Gn).join("\n");
2781
+ function Sr(e) {
2782
+ return e.split("\n").map(xr).join("\n");
2521
2783
  }
2522
- function qn(e, t) {
2784
+ function Cr(e, t) {
2523
2785
  let n = " ".repeat(t + 1);
2524
- 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");
2525
2787
  }
2526
- function Jn(e, t) {
2788
+ function wr(e, t) {
2527
2789
  let n = e.getAttribute(t) || "", r = /[\s()]/.test(n) ? `<${n}>` : n, i = e.getAttribute("title");
2528
2790
  return i ? `${r} "${i.replaceAll("\"", String.raw`\"`)}"` : r;
2529
2791
  }
2530
- function Yn(e, t = 0) {
2792
+ function Tr(e, t = 0) {
2531
2793
  if (e.nodeType === 3) {
2532
2794
  let t = e.textContent.replace(/\s+/g, " ");
2533
- return e.parentElement?.closest("pre, code") ? t : Wn(t);
2795
+ return e.parentElement?.closest("pre, code") ? t : br(t);
2534
2796
  }
2535
2797
  if (e.nodeType !== 1) return "";
2536
- 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("");
2537
2799
  switch (r) {
2538
2800
  case "p":
2539
- case "div": return `\n\n${Kn(i())}\n\n`;
2801
+ case "div": return `\n\n${Sr(i())}\n\n`;
2540
2802
  case "br": return " \n";
2541
2803
  case "h1": return `\n\n# ${i()}\n\n`;
2542
2804
  case "h2": return `\n\n## ${i()}\n\n`;
@@ -2565,27 +2827,27 @@ function Yn(e, t = 0) {
2565
2827
  }
2566
2828
  case "pre": {
2567
2829
  let e = n.querySelector("code"), t = /language-(\S+)/.exec(e?.className || "");
2568
- 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`;
2569
2831
  }
2570
2832
  case "blockquote": {
2571
2833
  let e = i().trim().split("\n");
2572
2834
  return `\n\n${e.filter((t, n) => t.trim() !== "" || (e[n - 1] ?? "").trim() !== "").map((e) => e.trim() === "" ? ">" : `> ${e}`).join("\n")}\n\n`;
2573
2835
  }
2574
- case "a": return `[${i()}](${Jn(n, "href")})`;
2575
- 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")})`;
2576
2838
  case "ul": {
2577
- let e = V(n, "li");
2839
+ let e = z(n, "li");
2578
2840
  if (!e.length) return i();
2579
2841
  let r = " ".repeat(t), a = n.classList.contains("an-checklist"), o = e.map((e) => {
2580
- let n = V(e, "input").find((e) => e.getAttribute("type") === "checkbox"), i = "- ";
2581
- 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)}`;
2582
2844
  }).join("\n");
2583
2845
  return t === 0 ? `\n\n${o}\n\n` : `\n${o}`;
2584
2846
  }
2585
2847
  case "ol": {
2586
- let e = V(n, "li");
2848
+ let e = z(n, "li");
2587
2849
  if (!e.length) return i();
2588
- 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");
2589
2851
  return t === 0 ? `\n\n${s}\n\n` : `\n${s}`;
2590
2852
  }
2591
2853
  case "li": return i();
@@ -2593,7 +2855,7 @@ function Yn(e, t = 0) {
2593
2855
  case "table": {
2594
2856
  let e = Array.from(n.querySelectorAll("tr"));
2595
2857
  if (!e.length) return i();
2596
- 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) => {
2597
2859
  let t = [...e];
2598
2860
  for (; t.length < a;) t.push("");
2599
2861
  return t;
@@ -2608,16 +2870,16 @@ function Yn(e, t = 0) {
2608
2870
  default: return i();
2609
2871
  }
2610
2872
  }
2611
- function Xn(e) {
2873
+ function Er(e) {
2612
2874
  return String(e ?? "").replace(/^\ufeff/, "");
2613
2875
  }
2614
- function Zn(e) {
2615
- let t = Xn(e);
2876
+ function Dr(e) {
2877
+ let t = Er(e);
2616
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);
2617
2879
  }
2618
- var H = /^ {0,3}>( ?)(.*)$/, Qn = /^(?: {4}|\t)\s*\S/, $n = /^( {0,3})(`{3,}|~{3,})[ \t]*([^\s`~][^\n]*)?$/;
2619
- function U(e) {
2620
- 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);
2621
2883
  if (!t) return null;
2622
2884
  let [, n, r, i = ""] = t;
2623
2885
  return r[0] === "`" && i.includes("`") ? null : {
@@ -2627,7 +2889,7 @@ function U(e) {
2627
2889
  lang: i.trim().split(/\s+/)[0] || ""
2628
2890
  };
2629
2891
  }
2630
- function er(e, t) {
2892
+ function Ar(e, t) {
2631
2893
  let n = 0, r = 0;
2632
2894
  for (; r < e.length && n < t;) {
2633
2895
  if (e[r] === " ") {
@@ -2644,40 +2906,40 @@ function er(e, t) {
2644
2906
  }
2645
2907
  return e.slice(r);
2646
2908
  }
2647
- var tr = /^ {0,3}([-*_])( *\1){2,}\s*$/, nr = "";
2648
- function rr(e) {
2649
- let t = Xn(e).replaceAll("\r\n", "\n").replaceAll("\r", "\n").split("\n");
2650
- t = sr(t);
2651
- let n = cr(t);
2652
- 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);
2653
2915
  }
2654
- function ir(e) {
2916
+ function Nr(e) {
2655
2917
  let t = [], n = 0;
2656
2918
  for (; n < e.length;) {
2657
- let r = e[n], i = U(r);
2919
+ let r = e[n], i = V(r);
2658
2920
  if (i) {
2659
2921
  let r = RegExp(`^ {0,3}\\${i.marker}{${i.length},}[ \t]*$`), a = [];
2660
- 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++;
2661
2923
  let o = i.lang ? ` class="language-${q(i.lang)}"` : "";
2662
2924
  t.push(`<pre><code${o}>${a.join("\n")}</code></pre>`), n++;
2663
2925
  continue;
2664
2926
  }
2665
- if (Qn.test(r)) {
2927
+ if (Or.test(r)) {
2666
2928
  let r = [];
2667
- for (; n < e.length && (Qn.test(e[n]) || e[n].trim() === "");) {
2929
+ for (; n < e.length && (Or.test(e[n]) || e[n].trim() === "");) {
2668
2930
  if (e[n].trim() === "") {
2669
2931
  let t = n;
2670
2932
  for (; t < e.length && e[t].trim() === "";) t++;
2671
- if (t >= e.length || !Qn.test(e[t])) break;
2933
+ if (t >= e.length || !Or.test(e[t])) break;
2672
2934
  for (; n < t; n++) r.push("");
2673
2935
  continue;
2674
2936
  }
2675
- r.push(Ar(er(e[n], 4))), n++;
2937
+ r.push(ii(Ar(e[n], 4))), n++;
2676
2938
  }
2677
2939
  t.push(`<pre><code>${r.join("\n")}</code></pre>`);
2678
2940
  continue;
2679
2941
  }
2680
- 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) {
2681
2943
  if (/^=+\s*$/.test(e[n + 1])) {
2682
2944
  t.push(`<h1>${K(r.trim())}</h1>`), n += 2;
2683
2945
  continue;
@@ -2687,7 +2949,7 @@ function ir(e) {
2687
2949
  continue;
2688
2950
  }
2689
2951
  }
2690
- if (tr.test(r)) {
2952
+ if (jr.test(r)) {
2691
2953
  t.push("<hr>"), n++;
2692
2954
  continue;
2693
2955
  }
@@ -2697,19 +2959,19 @@ function ir(e) {
2697
2959
  t.push(`<h${e}>${K(r)}</h${e}>`), n++;
2698
2960
  continue;
2699
2961
  }
2700
- if (H.test(r)) {
2962
+ if (B.test(r)) {
2701
2963
  let r = [];
2702
- for (; n < e.length && H.test(e[n]);) r.push(H.exec(e[n])[2]), n++;
2703
- 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>`);
2704
2966
  continue;
2705
2967
  }
2706
2968
  if (/^[-*+] /.test(r)) {
2707
- let { html: r, endIdx: i } = pr(e, n);
2969
+ let { html: r, endIdx: i } = Hr(e, n);
2708
2970
  t.push(r), n = i;
2709
2971
  continue;
2710
2972
  }
2711
2973
  if (/^\d+[.)] /.test(r)) {
2712
- let { html: r, endIdx: i } = pr(e, n);
2974
+ let { html: r, endIdx: i } = Hr(e, n);
2713
2975
  t.push(r), n = i;
2714
2976
  continue;
2715
2977
  }
@@ -2717,23 +2979,23 @@ function ir(e) {
2717
2979
  n++;
2718
2980
  continue;
2719
2981
  }
2720
- if (fr(e, n)) {
2721
- 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);
2722
2984
  n += 2;
2723
2985
  let o = [];
2724
- 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++;
2725
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>` : "";
2726
2988
  t.push(`<table>${c}${l}</table>`);
2727
2989
  continue;
2728
2990
  }
2729
2991
  let o = [];
2730
- 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++;
2731
- 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++);
2732
2994
  }
2733
2995
  return t.join("");
2734
2996
  }
2735
- var ar = /* @__PURE__ */ new Map(), or = /* @__PURE__ */ new Set();
2736
- function sr(e) {
2997
+ var Pr = /* @__PURE__ */ new Map(), Fr = /* @__PURE__ */ new Set();
2998
+ function Ir(e) {
2737
2999
  if ((e[0] || "").trim() !== "---") return e;
2738
3000
  let t = -1;
2739
3001
  for (let n = 1; n < e.length; n++) {
@@ -2747,14 +3009,14 @@ function sr(e) {
2747
3009
  let n = t + 1;
2748
3010
  return e[n] !== void 0 && e[n].trim() === "" && n++, e.slice(n);
2749
3011
  }
2750
- function cr(e) {
3012
+ function Lr(e) {
2751
3013
  let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set(), r = [], i = !1, a = /^\[([^\]]+)\]:\s*(\S+)(?:\s+"([^"]*)")?\s*$/, o = /^\[\^([^\]]+)\]:[ \t]*(\S.*)$/;
2752
3014
  for (let s of e) {
2753
3015
  if (i) {
2754
3016
  /^ {0,3}(?:`{3,}|~{3,})[ \t]*$/.test(s) && (i = !1), r.push(s);
2755
3017
  continue;
2756
3018
  }
2757
- if (U(s)) {
3019
+ if (V(s)) {
2758
3020
  i = !0, r.push(s);
2759
3021
  continue;
2760
3022
  }
@@ -2781,36 +3043,36 @@ function cr(e) {
2781
3043
  footnoteIds: n
2782
3044
  };
2783
3045
  }
2784
- function lr(e) {
3046
+ function Rr(e) {
2785
3047
  let t = "";
2786
3048
  for (let n = 0; n < e.length; n++) {
2787
3049
  let r = n === e.length - 1, i = e[n].replace(/^[ \t]+/, "");
2788
3050
  if (!r && /\\$/.test(i)) {
2789
- t += i.replace(/\\$/, "") + nr;
3051
+ t += i.replace(/\\$/, "") + Mr;
2790
3052
  continue;
2791
3053
  }
2792
3054
  if (!r && / {2,}$/.test(i)) {
2793
- t += i.replace(/ {2,}$/, "") + nr;
3055
+ t += i.replace(/ {2,}$/, "") + Mr;
2794
3056
  continue;
2795
3057
  }
2796
3058
  t += i + (r ? "" : " ");
2797
3059
  }
2798
3060
  return t;
2799
3061
  }
2800
- function ur(e) {
2801
- return W(e).length;
3062
+ function zr(e) {
3063
+ return U(e).length;
2802
3064
  }
2803
- function dr(e) {
2804
- 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;
2805
3067
  }
2806
- function fr(e, t) {
3068
+ function Vr(e, t) {
2807
3069
  let n = e[t], r = e[t + 1];
2808
3070
  if (r === void 0 || !n.includes("|")) return !1;
2809
3071
  if (/^\|.+\|/.test(n)) return /^\|[\s|:-]+\|/.test(r);
2810
- let i = W(r);
2811
- 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;
2812
3074
  }
2813
- function W(e) {
3075
+ function U(e) {
2814
3076
  let t = e.replace(/^\|/, "").replace(/\|$/, ""), n = [], r = "";
2815
3077
  for (let e = 0; e < t.length; e++) {
2816
3078
  if (t[e] === "\\" && t[e + 1] === "|") {
@@ -2825,7 +3087,7 @@ function W(e) {
2825
3087
  }
2826
3088
  return n.push(r), n.map((e) => e.trim());
2827
3089
  }
2828
- function pr(e, t) {
3090
+ function Hr(e, t) {
2829
3091
  let n = e[t].match(/^(\s*)/)[1].length, r = /^\s*\d+[.)] /.test(e[t]), i = [], a = null, o = !1, s = !1, c = t;
2830
3092
  for (; c < e.length;) {
2831
3093
  let t = e[c];
@@ -2853,15 +3115,15 @@ function pr(e, t) {
2853
3115
  c++;
2854
3116
  continue;
2855
3117
  }
2856
- let n = (e) => er(e, l), r = U(n(t));
3118
+ let n = (e) => Ar(e, l), r = V(n(t));
2857
3119
  if (r) {
2858
3120
  let t = RegExp(`^ {0,3}\\${r.marker}{${r.length},}[ \t]*$`), a = [n(e[c])];
2859
3121
  for (c++; c < e.length && !t.test(n(e[c]));) a.push(n(e[c])), c++;
2860
- 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;
2861
3123
  continue;
2862
3124
  }
2863
3125
  if (/^\s*(?:[-*+]|\d+[.)]) /.test(t)) {
2864
- let t = pr(e, c);
3126
+ let t = Hr(e, c);
2865
3127
  i[i.length - 1].sub += t.html, c = t.endIdx, s = !1;
2866
3128
  } else if (s) i[i.length - 1].paras.push(t.trim()), s = !1, c++;
2867
3129
  else {
@@ -2879,32 +3141,32 @@ function pr(e, t) {
2879
3141
  endIdx: c
2880
3142
  };
2881
3143
  }
2882
- var mr = /\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g, G = "\0", hr = "", gr = /(`+)([^]*?)\1/g;
2883
- function _r(e) {
3144
+ var Ur = /\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g, W = "\0", G = "", Wr = /(`+)([^]*?)\1/g;
3145
+ function Gr(e) {
2884
3146
  let t = [];
2885
3147
  return {
2886
- 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}`)),
2887
3149
  codes: t
2888
3150
  };
2889
3151
  }
2890
- function vr(e, t, n) {
2891
- 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) => {
2892
3154
  let i = t[Number(r)];
2893
- 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>`;
2894
3156
  });
2895
3157
  }
2896
- function yr(e) {
3158
+ function qr(e) {
2897
3159
  let t = [];
2898
3160
  return {
2899
- 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}`)),
2900
3162
  literals: t
2901
3163
  };
2902
3164
  }
2903
- function br(e, t) {
2904
- 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)]));
2905
3167
  }
2906
- var xr = String.raw`(&lt;.*?&gt;(?:\s+(?:"[^"]*"|'[^']*'))?|[^)]*)`, Sr = new RegExp(String.raw`!\[([^\]]*)\]\(${xr}\)`, "g"), Cr = new RegExp(String.raw`\[([^\]]+)\]\(${xr}\)`, "g");
2907
- 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) {
2908
3170
  let t = e.trim(), n = /^&lt;([\s\S]*?)&gt;(?:[ \t]*(?:"([^"]*)"|'([^']*)'))?[ \t]*$/.exec(t);
2909
3171
  if (n) return {
2910
3172
  href: n[1],
@@ -2919,26 +3181,26 @@ function wr(e) {
2919
3181
  title: ""
2920
3182
  };
2921
3183
  }
2922
- function Tr(e) {
2923
- return e = e.replace(Sr, (e, t, n) => {
2924
- 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)}"` : "";
2925
3187
  return `<img src="${J(r)}" alt="${J(t)}"${a} class="an-image">`;
2926
- }), e = e.replace(Cr, (e, t, n) => {
2927
- 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)}"` : "";
2928
3190
  return `<a href="${J(r)}"${a}>${t}</a>`;
2929
3191
  }), e = e.replace(/\[([^\]]+)\]\[([^\]]*)\]/g, (e, t, n) => {
2930
- let r = ar.get(jr(n || t).trim().toLowerCase());
3192
+ let r = Pr.get(ai(n || t).trim().toLowerCase());
2931
3193
  if (!r) return e;
2932
3194
  let i = r.title ? ` title="${q(r.title)}"` : "";
2933
3195
  return `<a href="${q(r.href)}"${i}>${t}</a>`;
2934
3196
  }), e = e.replace(/\[([^\]]+)\]/g, (e, t) => {
2935
- let n = ar.get(jr(t).trim().toLowerCase());
3197
+ let n = Pr.get(ai(t).trim().toLowerCase());
2936
3198
  if (!n) return e;
2937
3199
  let r = n.title ? ` title="${q(n.title)}"` : "";
2938
3200
  return `<a href="${q(n.href)}"${r}>${t}</a>`;
2939
- }), 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;
2940
3202
  }
2941
- function Er(e) {
3203
+ function ei(e) {
2942
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) => {
2943
3205
  let r = /[.,;:!?)]+$/.exec(n), i = r ? n.slice(0, -r[0].length) : n;
2944
3206
  if (!i) return e;
@@ -2946,18 +3208,18 @@ function Er(e) {
2946
3208
  return `${t}<a href="${J(i)}">${i}</a>${a}`;
2947
3209
  }), e;
2948
3210
  }
2949
- function Dr(e) {
3211
+ function ti(e) {
2950
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;
2951
3213
  }
2952
3214
  function K(e) {
2953
- let { text: t, literals: n } = yr(e), { text: r, codes: i } = _r(t), a = kr(r);
2954
- 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);
2955
3217
  }
2956
- var Or = /&(?!#\d+;|#[xX][0-9a-fA-F]+;|[a-zA-Z][a-zA-Z0-9]*;)/g;
2957
- function kr(e) {
2958
- 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;");
2959
3221
  }
2960
- function Ar(e) {
3222
+ function ii(e) {
2961
3223
  return String(e).replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
2962
3224
  }
2963
3225
  function q(e) {
@@ -2966,16 +3228,16 @@ function q(e) {
2966
3228
  function J(e) {
2967
3229
  return String(e).replaceAll("\"", "&quot;").replaceAll("'", "&#39;");
2968
3230
  }
2969
- function jr(e) {
3231
+ function ai(e) {
2970
3232
  return String(e).replaceAll("&lt;", "<").replaceAll("&gt;", ">").replaceAll("&amp;", "&");
2971
3233
  }
2972
3234
  //#endregion
2973
3235
  //#region src/js/core/detectLang.js
2974
- var Mr = 5, Nr = 2, Pr = [
3236
+ var oi = 5, si = 2, ci = [
2975
3237
  ["typescript", "javascript"],
2976
3238
  ["scss", "css"],
2977
3239
  ["cpp", "c"]
2978
- ], Fr = [
3240
+ ], li = [
2979
3241
  "javascript",
2980
3242
  "typescript",
2981
3243
  "python",
@@ -2998,7 +3260,7 @@ var Mr = 5, Nr = 2, Pr = [
2998
3260
  "scss",
2999
3261
  "css",
3000
3262
  "bash"
3001
- ], Ir = [
3263
+ ], ui = [
3002
3264
  {
3003
3265
  lang: "php",
3004
3266
  w: 10,
@@ -3564,27 +3826,27 @@ var Mr = 5, Nr = 2, Pr = [
3564
3826
  w: 3,
3565
3827
  re: /\s\|[ \t]*\w|\s&&\s|\s2>&1|\s-[\w-]+\s/
3566
3828
  }
3567
- ], Lr = 4e3;
3568
- function Rr(e) {
3569
- if (e.length <= Lr) return e;
3570
- 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");
3571
3833
  return n > 0 ? t.slice(0, n) : t;
3572
3834
  }
3573
- function zr(e) {
3835
+ function pi(e) {
3574
3836
  if (!e?.trim()) return null;
3575
- let t = Rr(e.trim()), n = /* @__PURE__ */ new Map();
3576
- 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);
3577
3839
  if (n.size === 0) return null;
3578
- for (let [e, t] of Pr) {
3840
+ for (let [e, t] of ci) {
3579
3841
  let r = n.get(e);
3580
3842
  r && n.set(e, r + (n.get(t) || 0));
3581
3843
  }
3582
3844
  let r = [...n.entries()].sort((e, t) => t[1] - e[1]), [i, a] = r[0], o = r[1]?.[1] ?? 0;
3583
- return a < Mr || a - o < Nr ? null : i;
3845
+ return a < oi || a - o < si ? null : i;
3584
3846
  }
3585
3847
  //#endregion
3586
3848
  //#region src/js/module/Editor.js
3587
- var Br = /* @__PURE__ */ new Set([
3849
+ var mi = /* @__PURE__ */ new Set([
3588
3850
  "PRE",
3589
3851
  "BLOCKQUOTE",
3590
3852
  "TABLE",
@@ -3592,13 +3854,28 @@ var Br = /* @__PURE__ */ new Set([
3592
3854
  "UL",
3593
3855
  "OL",
3594
3856
  "HR"
3595
- ]), 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 {
3596
3873
  constructor(e) {
3597
3874
  this.context = e, this.options = e.options, this._history = null, this._disposers = [], this._snapshotTimer = null, this._limitCounter = null;
3598
3875
  }
3599
3876
  initialize() {
3600
3877
  let e = this.context.layoutInfo.editable;
3601
- return this._history = new On(e, this.options.historyLimit || 100, this.options.historyMaxBytes || 10485760), this._bindEvents(e), this;
3878
+ return this._history = new Zn(e, this.options.historyLimit || 100, this.options.historyMaxBytes || 10485760), this._bindEvents(e), this;
3602
3879
  }
3603
3880
  destroy() {
3604
3881
  this._disposers.forEach((e) => e()), this._disposers = [], this._history = null, clearTimeout(this._snapshotTimer), this._snapshotTimer = null;
@@ -3607,7 +3884,7 @@ var Br = /* @__PURE__ */ new Set([
3607
3884
  let t = (e) => this._onKeydown(e), n = () => this.afterCommand(), r = (e) => this._enforceLimit(e), i = () => {
3608
3885
  if (!this.context._alive) return;
3609
3886
  let t = globalThis.getSelection();
3610
- 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));
3611
3888
  }, a = (e) => {
3612
3889
  e.target.type === "checkbox" && e.target.closest(".an-checklist") && this.afterCommand();
3613
3890
  }, o = (t) => {
@@ -3640,18 +3917,18 @@ var Br = /* @__PURE__ */ new Set([
3640
3917
  }
3641
3918
  l ? c.setStart(l, 0) : c.setStartAfter(s), c.collapse(!0), n.removeAllRanges(), n.addRange(c);
3642
3919
  }, s = () => this.context.layoutInfo.container.classList.contains("an-disabled");
3643
- 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) => {
3644
3921
  if (s()) {
3645
3922
  e.preventDefault();
3646
3923
  return;
3647
3924
  }
3648
3925
  let t = e.target;
3649
3926
  t && (t.nodeName === "IFRAME" || t.closest(".an-video-wrapper")) && e.preventDefault();
3650
- }), C(e, "drop", (e) => {
3927
+ }), x(e, "drop", (e) => {
3651
3928
  s() && e.preventDefault();
3652
3929
  }));
3653
3930
  let c = null;
3654
- this._disposers.push(C(e, "compositionstart", () => {
3931
+ this._disposers.push(x(e, "compositionstart", () => {
3655
3932
  let e = globalThis.getSelection();
3656
3933
  if (!e?.rangeCount) {
3657
3934
  c = null;
@@ -3662,7 +3939,7 @@ var Br = /* @__PURE__ */ new Set([
3662
3939
  let e = t;
3663
3940
  c = e.closest("sup") ? "superscript" : e.closest("sub") ? "subscript" : null;
3664
3941
  }
3665
- }), C(e, "compositionend", () => {
3942
+ }), x(e, "compositionend", () => {
3666
3943
  let e = c;
3667
3944
  if (c = null, !e) return;
3668
3945
  let t = globalThis.getSelection();
@@ -3675,58 +3952,41 @@ var Br = /* @__PURE__ */ new Set([
3675
3952
  }
3676
3953
  _onKeydown(e) {
3677
3954
  let t = this.context.layoutInfo.editable;
3678
- if (!Fn(e, t, this.options)) {
3679
- if (L(e, "z") && !e.shiftKey) {
3680
- e.preventDefault(), this.undo();
3681
- return;
3682
- }
3683
- if (L(e, "z") && e.shiftKey || L(e, "y")) {
3684
- e.preventDefault(), this.redo();
3685
- return;
3686
- }
3687
- if (L(e, "b")) {
3688
- e.preventDefault(), this.bold();
3689
- return;
3690
- }
3691
- if (L(e, "i")) {
3692
- e.preventDefault(), this.italic();
3693
- return;
3694
- }
3695
- if (L(e, "u")) {
3696
- e.preventDefault(), this.underline();
3697
- return;
3698
- }
3699
- if (L(e, "k")) {
3700
- e.preventDefault(), this.context.invoke("linkDialog.show");
3701
- return;
3702
- }
3703
- if (L(e, "v") && e.shiftKey) {
3704
- this.context.invoke("clipboard.setForcePlain", !0);
3705
- return;
3706
- }
3707
- if (e.key === "/" && e.shiftKey && e.ctrlKey && !e.metaKey) {
3708
- e.preventDefault(), this.context.invoke("shortcutsDialog.show");
3709
- return;
3710
- }
3711
- if (L(e, "f")) {
3712
- e.preventDefault(), this.context.invoke("findReplace.show", "find");
3713
- return;
3714
- }
3715
- 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);
3716
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;
3717
3977
  }
3718
3978
  _enforceLimit(e) {
3719
3979
  let t = this.options.maxChars || 0, n = this.options.maxWords || 0;
3720
3980
  if (!t && !n) return;
3721
- this._limitCounter ??= new Bn();
3981
+ this._limitCounter ??= new gr();
3722
3982
  let r = e.inputType || "";
3723
3983
  if (r.startsWith("delete") || r === "historyUndo" || r === "historyRedo" || r === "insertFromPaste" || r === "insertFromDrop" || !r.startsWith("insert")) return;
3724
3984
  let { words: i, chars: a } = this._limitCounter.counts(this.context.layoutInfo.editable);
3725
3985
  if (t && a >= t) {
3726
- e.preventDefault(), typeof this.options.onCharLimitReached == "function" && this.options.onCharLimitReached(this.context);
3986
+ e.preventDefault(), this.context.triggerEvent("charLimitReached", this.context);
3727
3987
  return;
3728
3988
  }
3729
- 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));
3730
3990
  }
3731
3991
  afterCommand() {
3732
3992
  this._cleanOrphanedFigures(), this._ensureTrailingParagraph(), this.context.invoke("toolbar.refresh"), this.context.invoke("statusbar.update"), this._scheduleSnapshot();
@@ -3745,7 +4005,7 @@ var Br = /* @__PURE__ */ new Set([
3745
4005
  let e = this.context.layoutInfo.editable;
3746
4006
  if (!e) return;
3747
4007
  let t = e.lastElementChild;
3748
- if (t && Br.has(t.nodeName)) {
4008
+ if (t && mi.has(t.nodeName)) {
3749
4009
  let t = document.createElement("p");
3750
4010
  t.innerHTML = "<br>", e.appendChild(t);
3751
4011
  }
@@ -3758,7 +4018,10 @@ var Br = /* @__PURE__ */ new Set([
3758
4018
  return this.context.invoke("clipboard.resolveImages", e) ?? e;
3759
4019
  }
3760
4020
  setHTML(e) {
3761
- let t = _n(e, { allowIframes: !0 });
4021
+ let t = An(e, {
4022
+ allowIframes: !0,
4023
+ iframeHosts: this.options.iframeHosts
4024
+ });
3762
4025
  this.context.layoutInfo.editable.replaceChildren(...t.childNodes), this._history && this._history.reset(), this.afterCommand();
3763
4026
  }
3764
4027
  getText() {
@@ -3778,16 +4041,16 @@ var Br = /* @__PURE__ */ new Set([
3778
4041
  return !e && !t;
3779
4042
  }
3780
4043
  insertHTML(e) {
3781
- e && (T("insertHTML", M(e)), this.afterCommand());
4044
+ e && (C("insertHTML", j(e)), this.afterCommand());
3782
4045
  }
3783
4046
  insertText(e) {
3784
- e && (T("insertText", e), this.afterCommand());
4047
+ e && (C("insertText", e), this.afterCommand());
3785
4048
  }
3786
4049
  setMarkdown(e) {
3787
- this.setHTML(rr(e || ""));
4050
+ this.setHTML(H(e || ""));
3788
4051
  }
3789
4052
  getMarkdown() {
3790
- return Hn(this.getHTML());
4053
+ return vr(this.getHTML());
3791
4054
  }
3792
4055
  undo() {
3793
4056
  this._history && (this._flushPendingSnapshot(), this._history.undo(), this.context.invoke("toolbar.refresh"), this.context.invoke("statusbar.update"), this.context.triggerEvent("change", this.getHTML()));
@@ -3817,63 +4080,63 @@ var Br = /* @__PURE__ */ new Set([
3817
4080
  return !e || !this._history ? !1 : (this._history._restoreSelection(e), !0);
3818
4081
  }
3819
4082
  bold() {
3820
- Le(), this.afterCommand();
4083
+ Ve(), this.afterCommand();
3821
4084
  }
3822
4085
  italic() {
3823
- Re(), this.afterCommand();
4086
+ He(), this.afterCommand();
3824
4087
  }
3825
4088
  underline() {
3826
- ze(), this.afterCommand();
4089
+ Ue(), this.afterCommand();
3827
4090
  }
3828
4091
  strikethrough() {
3829
- Be(), this.afterCommand();
4092
+ We(), this.afterCommand();
3830
4093
  }
3831
4094
  superscript() {
3832
- Ve(), this.afterCommand();
4095
+ Ge(), this.afterCommand();
3833
4096
  }
3834
4097
  subscript() {
3835
- He(), this.afterCommand();
4098
+ Ke(), this.afterCommand();
3836
4099
  }
3837
4100
  justifyLeft() {
3838
- Je(), this.afterCommand();
4101
+ Qe(), this.afterCommand();
3839
4102
  }
3840
4103
  justifyCenter() {
3841
- Ye(), this.afterCommand();
4104
+ $e(), this.afterCommand();
3842
4105
  }
3843
4106
  justifyRight() {
3844
- Xe(), this.afterCommand();
4107
+ et(), this.afterCommand();
3845
4108
  }
3846
4109
  justifyFull() {
3847
- Ze(), this.afterCommand();
4110
+ tt(), this.afterCommand();
3848
4111
  }
3849
4112
  indent() {
3850
- Qe(), this.afterCommand();
4113
+ nt(), this.afterCommand();
3851
4114
  }
3852
4115
  outdent() {
3853
- et(), this.afterCommand();
4116
+ it(), this.afterCommand();
3854
4117
  }
3855
4118
  insertUL() {
3856
- at(), this.afterCommand();
4119
+ lt(), this.afterCommand();
3857
4120
  }
3858
4121
  insertOL() {
3859
- ot(), this.afterCommand();
4122
+ ut(), this.afterCommand();
3860
4123
  }
3861
4124
  inlineCode() {
3862
- ct(this.context.layoutInfo.editable), this.afterCommand();
4125
+ ft(this.context.layoutInfo.editable), this.afterCommand();
3863
4126
  }
3864
4127
  toggleChecklist() {
3865
- dt(), this.afterCommand();
4128
+ ht(), this.afterCommand();
3866
4129
  }
3867
4130
  print() {
3868
4131
  this.context.print();
3869
4132
  }
3870
4133
  formatBlock(e) {
3871
- if (qe(e), e === "pre") {
4134
+ if (Ze(e), e === "pre") {
3872
4135
  let e = globalThis.getSelection();
3873
4136
  if (e?.rangeCount > 0) {
3874
4137
  let t = e.getRangeAt(0).commonAncestorContainer, n = t.nodeType === 1 ? t.closest("pre") : t.parentElement?.closest("pre");
3875
4138
  if (n && !n.dataset.language) {
3876
- let e = zr(n.textContent || "");
4139
+ let e = pi(n.textContent || "");
3877
4140
  if (e) {
3878
4141
  this.context.invoke("codeTooltip.applyLanguage", n, e);
3879
4142
  return;
@@ -3884,55 +4147,62 @@ var Br = /* @__PURE__ */ new Set([
3884
4147
  this.afterCommand();
3885
4148
  }
3886
4149
  foreColor(e) {
3887
- Ue(e), this.afterCommand();
4150
+ qe(e), this.afterCommand();
3888
4151
  }
3889
4152
  backColor(e) {
3890
- We(e), this.afterCommand();
4153
+ Je(e), this.afterCommand();
3891
4154
  }
3892
4155
  fontName(e) {
3893
- Ge(e), this.afterCommand();
4156
+ Ye(e), this.afterCommand();
3894
4157
  }
3895
4158
  fontSize(e) {
3896
- Ke(e, this.context.layoutInfo.editable), this.afterCommand();
4159
+ Xe(e, this.context.layoutInfo.editable), this.afterCommand();
3897
4160
  }
3898
4161
  insertHr() {
3899
- T("insertHorizontalRule"), this.afterCommand();
4162
+ C("insertHorizontalRule"), this.afterCommand();
3900
4163
  }
3901
4164
  insertLink(e, t, n = !1) {
3902
4165
  let r = globalThis.getSelection();
3903
4166
  if (!r || r.rangeCount === 0) return;
3904
- let i = N(e);
3905
- if (i) {
3906
- if (r.toString().trim().length > 0) {
3907
- if (T("createLink", i), n) {
3908
- let e = this._getClosestAnchor();
3909
- e && (e.setAttribute("target", "_blank"), e.setAttribute("rel", "noopener noreferrer"));
3910
- }
3911
- } else {
3912
- let e = this._escapeAttr(t || i);
3913
- 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));
3914
4174
  }
3915
- 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>`);
3916
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(" ");
3917
4184
  }
3918
4185
  unlink() {
3919
- T("unlink"), this.afterCommand();
4186
+ C("unlink"), this.afterCommand();
3920
4187
  }
3921
4188
  insertImage(e, t = "", n = "") {
3922
- let r = N(e, { allowData: !0 });
4189
+ let r = M(e, { allowData: !0 });
3923
4190
  if (!r) return;
3924
4191
  let i = {
3925
4192
  left: "float:left;margin:0 1em 1em 0",
3926
4193
  center: "display:block;margin:0 auto",
3927
4194
  right: "float:right;margin:0 0 1em 1em"
3928
4195
  }[n] || "", a = i ? ` style="${i}"` : "";
3929
- 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();
3930
4197
  }
3931
4198
  insertVideo(e) {
3932
- e && (T("insertHTML", e), this.afterCommand());
4199
+ e && (C("insertHTML", j(e, {
4200
+ allowIframes: !0,
4201
+ iframeHosts: this.options.iframeHosts
4202
+ })), this.afterCommand());
3933
4203
  }
3934
4204
  insertTable(e, t) {
3935
- An(e, t, { headerRow: this.context.options.tableHeaderRow }), this.afterCommand();
4205
+ $n(e, t, { headerRow: this.context.options.tableHeaderRow }), this.afterCommand();
3936
4206
  }
3937
4207
  _getClosestAnchor() {
3938
4208
  let e = globalThis.getSelection();
@@ -3947,7 +4217,39 @@ var Br = /* @__PURE__ */ new Set([
3947
4217
  _escapeAttr(e) {
3948
4218
  return String(e ?? "").replaceAll("&", "&amp;").replaceAll("\"", "&quot;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
3949
4219
  }
3950
- }, 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([
3951
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\"/>")],
3952
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\"/>")],
3953
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\"/>")],
@@ -3984,7 +4286,7 @@ var Br = /* @__PURE__ */ new Set([
3984
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\"/>")],
3985
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\"/>")],
3986
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\"/>")]
3987
- ]), Wr = /* @__PURE__ */ new Map([
4289
+ ]), bi = /* @__PURE__ */ new Map([
3988
4290
  ["bold", "fa-bold"],
3989
4291
  ["italic", "fa-italic"],
3990
4292
  ["underline", "fa-underline"],
@@ -4018,27 +4320,42 @@ var Br = /* @__PURE__ */ new Set([
4018
4320
  ["inline-code", "fa-code"],
4019
4321
  ["checklist", "fa-list-check"],
4020
4322
  ["print", "fa-print"]
4021
- ]), Gr = class {
4323
+ ]), xi = {
4324
+ fontFamily: "fontFamilies",
4325
+ fontSize: "fontSizes",
4326
+ lineHeight: "lineHeights",
4327
+ paragraphStyle: "paragraphStyles"
4328
+ }, Si = class {
4022
4329
  constructor(e) {
4023
4330
  this.context = e, this.options = e.options, this.el = null, this._disposers = [], this._colorPickerClosers = [], this._refreshRaf = null;
4024
4331
  }
4025
4332
  initialize() {
4026
- return this.el = x("div", {
4333
+ return this.el = b("div", {
4027
4334
  class: "an-toolbar",
4028
4335
  role: "toolbar",
4029
4336
  "aria-orientation": "horizontal",
4030
- "aria-label": "Editor toolbar"
4031
- }), 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;
4032
4339
  }
4033
4340
  destroy() {
4034
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;
4035
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
+ }
4036
4353
  _buildButtons() {
4037
4354
  let e = this.options.toolbar || [], t = document.createDocumentFragment();
4038
4355
  e.forEach((e) => {
4039
- let n = x("div", { class: "an-btn-group" });
4356
+ let n = b("div", { class: "an-btn-group" });
4040
4357
  e.forEach((e) => {
4041
- let t = Hr(e);
4358
+ let t = this._resolveBtn(e);
4042
4359
  if (!t) {
4043
4360
  console.warn(`[AutumnNote] Toolbar: button "${e}" not found in registry. Skipped.`);
4044
4361
  return;
@@ -4049,7 +4366,7 @@ var Br = /* @__PURE__ */ new Set([
4049
4366
  }), this.el.appendChild(t);
4050
4367
  }
4051
4368
  _createGridPicker(e) {
4052
- 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", {
4053
4370
  type: "button",
4054
4371
  class: this.options.useBootstrap ? this.options.toolbarButtonClass || "btn btn-sm btn-light" : "an-btn",
4055
4372
  title: this.context.locale.toolbar[e.name] || e.tooltip || "",
@@ -4058,16 +4375,16 @@ var Br = /* @__PURE__ */ new Set([
4058
4375
  "aria-haspopup": "true",
4059
4376
  "aria-expanded": "false"
4060
4377
  });
4061
- n.innerHTML = 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>";
4062
- 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", {
4063
4380
  class: "an-table-picker-popup",
4064
4381
  role: "dialog",
4065
- "aria-label": "Select table size"
4066
- }), 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" });
4067
4384
  a.textContent = this.context.locale.toolbar.insertTableLabel || "Insert Table";
4068
4385
  let o = [];
4069
4386
  for (let e = 1; e <= 10; e++) for (let t = 1; t <= 10; t++) {
4070
- let n = x("div", {
4387
+ let n = b("div", {
4071
4388
  class: "an-table-cell",
4072
4389
  "data-row": String(e),
4073
4390
  "data-col": String(t)
@@ -4088,182 +4405,165 @@ var Br = /* @__PURE__ */ new Set([
4088
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");
4089
4406
  }, u = () => {
4090
4407
  s = !1, r.style.display = "none", n.setAttribute("aria-expanded", "false"), c(0, 0);
4091
- }, d = C(n, "click", (e) => {
4408
+ }, d = x(n, "click", (e) => {
4092
4409
  e.stopPropagation(), s ? u() : l();
4093
- }), f = C(i, "mouseover", (e) => {
4410
+ }), f = x(i, "mouseover", (e) => {
4094
4411
  let t = e.target?.closest(".an-table-cell");
4095
4412
  t && c(+t.dataset.row, +t.dataset.col);
4096
- }), 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) => {
4097
4414
  let n = t.target?.closest(".an-table-cell");
4098
4415
  if (!n) return;
4099
4416
  let r = +n.dataset.row, i = +n.dataset.col;
4100
- u(), this.context.invoke("editor.focus"), e.action(this.context, r, i);
4101
- }), 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", () => {
4102
4422
  s && u();
4103
4423
  });
4104
4424
  return this._disposers.push(d, f, p, m, h, () => {
4105
4425
  r.parentNode && r.remove();
4106
- }), t.appendChild(n), document.body.appendChild(r), t;
4426
+ }), t.appendChild(n), Ce(this.context).appendChild(r), t;
4107
4427
  }
4108
4428
  _createColorPicker(e) {
4109
- let t = [
4110
- "#000000",
4111
- "#434343",
4112
- "#666666",
4113
- "#999999",
4114
- "#b7b7b7",
4115
- "#cccccc",
4116
- "#efefef",
4117
- "#ffffff",
4118
- "#ff0000",
4119
- "#ff9900",
4120
- "#ffff00",
4121
- "#00ff00",
4122
- "#00ffff",
4123
- "#4a86e8",
4124
- "#9900ff",
4125
- "#ff00ff",
4126
- "#f4cccc",
4127
- "#fce5cd",
4128
- "#fff2cc",
4129
- "#d9ead3",
4130
- "#d0e0e3",
4131
- "#c9daf8",
4132
- "#d9d2e9",
4133
- "#ead1dc"
4134
- ], 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", {
4135
4430
  type: "button",
4136
- class: `${i} an-color-btn`,
4431
+ class: `${r} an-color-btn`,
4137
4432
  title: this.context.locale.toolbar[e.name] || e.tooltip || "",
4138
4433
  "data-btn": e.name,
4139
4434
  "aria-label": this.context.locale.toolbar[e.name] || e.tooltip || e.name
4140
- }), o = "stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"";
4141
- 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>`;
4142
- let s = x("span", { class: "an-color-strip" });
4143
- s.style.background = n, a.appendChild(s);
4144
- 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", {
4145
4440
  type: "button",
4146
- class: `${i} an-color-arrow`,
4441
+ class: `${r} an-color-arrow`,
4147
4442
  title: e.name === "foreColor" ? this.context.locale.toolbar.chooseTextColor || "Choose text color" : this.context.locale.toolbar.chooseHighlightColor || "Choose highlight color",
4148
4443
  "aria-haspopup": "true",
4149
4444
  "aria-expanded": "false"
4150
4445
  });
4151
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>";
4152
- let l = x("div", { class: "an-color-popup" });
4447
+ let l = b("div", { class: "an-color-popup" });
4153
4448
  l.style.display = "none";
4154
- let u = x("div", { class: "an-color-swatches" }), d = Array.isArray(this.options.colorSwatches) ? this.options.colorSwatches : [];
4155
- [.../* @__PURE__ */ new Set([...d, ...t])].forEach((e) => {
4156
- let t = x("div", {
4449
+ let u = b("div", { class: "an-color-swatches" });
4450
+ vi(this.options).forEach((e) => {
4451
+ let t = b("div", {
4157
4452
  class: "an-color-swatch",
4158
4453
  title: e,
4159
4454
  "data-color": e
4160
4455
  });
4161
4456
  t.style.background = e, u.appendChild(t);
4162
4457
  });
4163
- let f = x("div", { class: "an-color-custom" }), p = x("input", {
4458
+ let d = b("div", { class: "an-color-custom" }), f = b("input", {
4164
4459
  type: "color",
4165
- value: n,
4460
+ value: t,
4166
4461
  title: this.context.locale.toolbar.customColor || "Custom color"
4167
- }), m = x("span", {}, [this.context.locale.toolbar.customColor || "Custom color"]);
4168
- f.appendChild(p), f.appendChild(m), l.appendChild(u), l.appendChild(f);
4169
- 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 = () => {
4170
4465
  let e = globalThis.getSelection();
4171
- g = e?.rangeCount ? e.getRangeAt(0).cloneRange() : null;
4172
- }, te = () => {
4173
- if (g) try {
4466
+ h = e?.rangeCount ? e.getRangeAt(0).cloneRange() : null;
4467
+ }, g = () => {
4468
+ if (h) try {
4174
4469
  let e = globalThis.getSelection();
4175
4470
  if (!e) return;
4176
- e.removeAllRanges(), e.addRange(g);
4471
+ e.removeAllRanges(), e.addRange(h);
4177
4472
  } catch {}
4178
- }, ne = () => {
4473
+ }, te = () => {
4179
4474
  this._colorPickerClosers.forEach((e) => {
4180
4475
  e !== _ && e();
4181
- }), ee(), h = !0;
4476
+ }), ee(), m = !0;
4182
4477
  let e = c.getBoundingClientRect(), t = e.left;
4183
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");
4184
4479
  }, _ = () => {
4185
- h = !1, l.style.display = "none", l.style.top = "", l.style.left = "", c.setAttribute("aria-expanded", "false");
4186
- }, v = (t) => {
4187
- n = t, s.style.background = t, p.value = t, te(), e.action(this.context, t), this.context.invoke("editor.afterCommand"), _();
4188
- }, re = C(a, "click", (t) => {
4189
- t.preventDefault(), te(), e.action(this.context, n), this.context.invoke("editor.afterCommand");
4190
- }), 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) => {
4191
4490
  e.preventDefault();
4192
- }), y = C(c, "click", (e) => {
4193
- e.stopPropagation(), h ? _() : ne();
4194
- }), b = C(u, "mousedown", (e) => {
4491
+ }), ae = x(c, "click", (e) => {
4492
+ e.stopPropagation(), m ? _() : te();
4493
+ }), oe = x(u, "mousedown", (e) => {
4195
4494
  e.preventDefault();
4196
- }), ae = C(u, "click", (e) => {
4495
+ }), v = x(u, "click", (e) => {
4197
4496
  let t = e.target?.closest(".an-color-swatch");
4198
- t && v(t.dataset.color);
4199
- }), oe = C(p, "change", (e) => {
4200
- v(e.target.value);
4201
- }), se = C(document, "click", (e) => {
4202
- h && !r.contains(e.target) && !l.contains(e.target) && _();
4203
- }), ce = C(l, "click", (e) => e.stopPropagation()), S = () => {
4204
- 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 && _();
4205
4504
  };
4206
- return document.addEventListener("scroll", S, {
4505
+ return document.addEventListener("scroll", y, {
4207
4506
  passive: !0,
4208
4507
  capture: !0
4209
- }), 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), () => {
4210
4509
  l.parentNode && l.remove();
4211
4510
  }), this._colorPickerClosers.push(_), this._disposers.push(() => {
4212
4511
  let e = this._colorPickerClosers.indexOf(_);
4213
4512
  e !== -1 && this._colorPickerClosers.splice(e, 1);
4214
- }), r.appendChild(a), r.appendChild(c), document.body.appendChild(l), r;
4513
+ }), n.appendChild(i), n.appendChild(c), Ce(this.context).appendChild(l), n;
4215
4514
  }
4216
4515
  _createSelect(e) {
4217
- 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", {
4218
4517
  class: e.selectClass ? `an-select ${e.selectClass}` : "an-select",
4219
4518
  title: this.context.locale.toolbar[e.name] || e.tooltip || "",
4220
4519
  "data-btn": e.name,
4221
4520
  "aria-label": this.context.locale.toolbar[e.name] || e.tooltip || e.name
4222
- }), r = x("option", {
4521
+ }), a = b("option", {
4223
4522
  value: "",
4224
4523
  disabled: "",
4225
4524
  hidden: ""
4226
4525
  }, [this.context.locale.toolbar[e.name + "Placeholder"] || e.placeholder || "Font"]);
4227
- n.appendChild(r), t.forEach((t) => {
4228
- let r = typeof t == "object" ? t.value : t, i;
4229
- i = typeof t == "object" ? e.name === "paragraphStyle" && this.context.locale.toolbar.paragraphItems?.[t.value] || t.label : t;
4230
- 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 };
4231
4530
  a && (o.disabled = "");
4232
- let s = x("option", o, [i]);
4233
- 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);
4234
4533
  });
4235
- let i = null, a = C(n, "mousedown", () => {
4534
+ let o = null, s = x(i, "mousedown", () => {
4236
4535
  let e = globalThis.getSelection();
4237
- i = e?.rangeCount ? e.getRangeAt(0).cloneRange() : null;
4238
- }), o = C(n, "change", (t) => {
4536
+ o = e?.rangeCount ? e.getRangeAt(0).cloneRange() : null;
4537
+ }), c = x(i, "change", (t) => {
4239
4538
  let n = t.target.value, r = t.target.options[t.target.selectedIndex];
4240
4539
  if (!(!n || r.disabled)) {
4241
- if (this.context.invoke("editor.focus"), i) try {
4540
+ if (this.context.invoke("editor.focus"), o) try {
4242
4541
  let e = globalThis.getSelection();
4243
- e && (e.removeAllRanges(), e.addRange(i));
4542
+ e && (e.removeAllRanges(), e.addRange(o));
4244
4543
  } catch {}
4245
- 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"));
4246
4545
  }
4247
4546
  });
4248
- return this._disposers.push(a, o), n;
4547
+ return this._disposers.push(s, c), i;
4249
4548
  }
4250
4549
  _createButton(e) {
4251
- let t = x("button", {
4550
+ let t = b("button", {
4252
4551
  type: "button",
4253
4552
  class: `${this.options.useBootstrap ? this.options.toolbarButtonClass || "btn btn-sm btn-light" : "an-btn"}${e.className ? ` ${e.className}` : ""}`,
4254
4553
  title: this.context.locale.toolbar[e.name] || e.tooltip || "",
4255
4554
  "data-btn": e.name,
4256
4555
  "aria-label": this.context.locale.toolbar[e.name] || e.tooltip || e.name,
4257
4556
  ...typeof e.isActive == "function" ? { "aria-pressed": "false" } : {}
4258
- }), n = this.options.fontAwesomeClass || "fas";
4259
- if (this._faReady) {
4260
- 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;
4261
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;
4262
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;
4263
- let r = C(t, "click", (t) => {
4264
- 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());
4265
4565
  });
4266
- return this._disposers.push(r), t;
4566
+ return this._disposers.push(a), t;
4267
4567
  }
4268
4568
  _controls() {
4269
4569
  return this.el ? Array.from(this.el.querySelectorAll("button, select")) : [];
@@ -4278,7 +4578,7 @@ var Br = /* @__PURE__ */ new Set([
4278
4578
  t.forEach((e) => e.setAttribute("tabindex", e === r ? "0" : "-1"));
4279
4579
  }
4280
4580
  _initRovingFocus() {
4281
- 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) => {
4282
4582
  let t = e.target?.closest?.("button, select");
4283
4583
  t && this._syncRovingTabindex(t);
4284
4584
  })));
@@ -4339,49 +4639,58 @@ var Br = /* @__PURE__ */ new Set([
4339
4639
  this.el && (this.el.style.display = "none");
4340
4640
  }
4341
4641
  rebuild() {
4342
- 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();
4343
4643
  }
4344
4644
  };
4345
4645
  //#endregion
4346
4646
  //#region src/js/module/Statusbar.js
4347
- function Kr(e, t, n) {
4647
+ function Ci(e, t, n) {
4348
4648
  if (!n) {
4349
4649
  e.classList.remove("an-count-warn", "an-count-exceeded");
4350
4650
  return;
4351
4651
  }
4352
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");
4353
4653
  }
4354
- var qr = class {
4654
+ var wi = class {
4355
4655
  constructor(e) {
4356
- 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();
4357
4657
  }
4358
4658
  initialize() {
4359
- if (this.el = x("div", { class: "an-statusbar" }), this.options.resizable !== !1) {
4360
- let e = x("div", {
4361
- class: "an-resize-handle",
4362
- title: this.context.locale.statusbar.resizeHandle,
4363
- "aria-hidden": "true"
4364
- });
4365
- this._bindResize(e), this.el.appendChild(e);
4366
- }
4367
- this._wordCountEl = x("span", {
4659
+ this.el = b("div", { class: "an-statusbar" }), this._wordCountEl = b("span", {
4368
4660
  class: "an-word-count",
4369
4661
  role: "status",
4370
4662
  "aria-live": "polite",
4371
4663
  "aria-atomic": "true"
4372
- }), this._charCountEl = x("span", {
4664
+ }), this._charCountEl = b("span", {
4373
4665
  class: "an-char-count",
4374
4666
  "aria-live": "polite",
4375
4667
  "aria-atomic": "true"
4376
4668
  });
4377
- let e = x("div", {
4669
+ let e = b("div", {
4378
4670
  class: "an-status-info",
4379
- "aria-label": "Editor statistics"
4671
+ "aria-label": this.context.locale.a11y?.statistics || "Editor statistics"
4380
4672
  });
4381
- 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);
4382
4691
  }
4383
4692
  destroy() {
4384
- 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;
4385
4694
  }
4386
4695
  _bindResize(e) {
4387
4696
  let t = 0, n = 0, r = this.context.layoutInfo.container, i = (e) => {
@@ -4396,19 +4705,19 @@ var qr = class {
4396
4705
  t && (e.preventDefault(), i(t.clientY));
4397
4706
  }, l = () => {
4398
4707
  document.removeEventListener("touchmove", c), document.removeEventListener("touchend", l), this._dragDisposers = null;
4399
- }, u = (e) => {
4708
+ };
4709
+ return [x(e, "mousedown", s), x(e, "touchstart", (e) => {
4400
4710
  let i = e.touches[0];
4401
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)]);
4402
- }, d = C(e, "mousedown", s), f = C(e, "touchstart", u);
4403
- this._disposers.push(d, f);
4712
+ })];
4404
4713
  }
4405
4714
  _counts() {
4406
4715
  return this._counter.counts(this.context.layoutInfo.editable);
4407
4716
  }
4408
4717
  update() {
4409
- if (!this._wordCountEl || !this._charCountEl) return;
4718
+ if (!this._wordCountEl || !this._charCountEl || this.el?.hidden) return;
4410
4719
  let { words: e, chars: t } = this._counts(), n = this.options.maxWords || 0, r = this.options.maxChars || 0, i = this.context.locale.statusbar;
4411
- 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);
4412
4721
  }
4413
4722
  getWordCount() {
4414
4723
  return this._counts().words;
@@ -4416,14 +4725,14 @@ var qr = class {
4416
4725
  getCharCount() {
4417
4726
  return this._counts().chars;
4418
4727
  }
4419
- }, Jr = class {
4728
+ }, Ti = class {
4420
4729
  constructor(e) {
4421
4730
  this.context = e, this.options = e.options, this._disposers = [];
4422
4731
  }
4423
4732
  initialize() {
4424
4733
  this._blobRegistry = /* @__PURE__ */ new Map(), this._forcePlain = !1;
4425
4734
  let e = this.context.layoutInfo.editable;
4426
- 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) => {
4427
4736
  for (let t of e) for (let e of t.removedNodes) this._revokeRemovedBlobs(e);
4428
4737
  }), this._mutationObserver.observe(e, {
4429
4738
  childList: !0,
@@ -4496,17 +4805,21 @@ var qr = class {
4496
4805
  setForcePlain(e) {
4497
4806
  this._forcePlain = !!e;
4498
4807
  }
4808
+ _maxPasteBytes() {
4809
+ let e = this.options.maxPasteSize;
4810
+ return typeof e == "number" && e >= 0 ? e : 5242880;
4811
+ }
4499
4812
  _onPaste(e) {
4500
4813
  let t = e.clipboardData || globalThis.clipboardData;
4501
4814
  if (!t) return;
4502
4815
  let n = this._forcePlain;
4503
4816
  this._forcePlain = !1;
4504
- let r = (this.options.maxPasteSize ?? 5) * 1024 * 1024;
4817
+ let r = this._maxPasteBytes();
4505
4818
  if (r > 0) {
4506
4819
  let n = t.getData("text/plain") || "", i = t.getData("text/html") || "", a = Math.max(n.length, i.length);
4507
4820
  if (a > r) {
4508
4821
  e.preventDefault();
4509
- 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.`;
4510
4823
  this.context.triggerEvent("pasteError", {
4511
4824
  size: a,
4512
4825
  maxBytes: r,
@@ -4524,24 +4837,33 @@ var qr = class {
4524
4837
  return;
4525
4838
  }
4526
4839
  }
4527
- if (typeof this.options.onPaste == "function" && this.options.onPaste({
4840
+ let i = this.context.triggerEvent("paste", {
4528
4841
  text: t.getData("text/plain") || "",
4529
4842
  html: t.types.includes("text/html") ? t.getData("text/html") : null
4530
- }), n || this.options.pasteAsPlainText) {
4531
- 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");
4532
4854
  return;
4533
4855
  }
4534
4856
  if (this.options.markdownPaste !== !1) {
4535
4857
  let n = t.types.includes("text/html"), r = n ? t.getData("text/html") : "", i = !n || this._isTriviallyPlainHtml(r), a = t.getData("text/plain");
4536
- if (a && i && Zn(a)) {
4537
- 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");
4538
4860
  return;
4539
4861
  }
4540
4862
  }
4541
4863
  if (this.options.pasteCleanHTML !== !1 && t.types.includes("text/html")) {
4542
4864
  e.preventDefault();
4543
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;
4544
- 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");
4545
4867
  }
4546
4868
  }
4547
4869
  _onDragover(e) {
@@ -4561,9 +4883,9 @@ var qr = class {
4561
4883
  }
4562
4884
  }
4563
4885
  _insertMarkdownFile(e) {
4564
- let t = (this.options.maxPasteSize ?? 5) * 1024 * 1024;
4886
+ let t = this._maxPasteBytes();
4565
4887
  if (t > 0 && e.size > t) {
4566
- 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.`;
4567
4889
  this.context.triggerEvent("pasteError", {
4568
4890
  size: e.size,
4569
4891
  maxBytes: t,
@@ -4573,7 +4895,7 @@ var qr = class {
4573
4895
  }
4574
4896
  let n = new FileReader();
4575
4897
  n.onload = (e) => {
4576
- 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");
4577
4899
  }, n.onerror = () => {
4578
4900
  let t = `Failed to read dropped markdown file "${e.name}".`;
4579
4901
  console.warn(`[AutumnNote] ${t}`), this.context.triggerEvent("pasteError", { message: t });
@@ -4658,7 +4980,7 @@ var qr = class {
4658
4980
  file: e
4659
4981
  });
4660
4982
  let r = this._escapeAttr(e.name.replace(/\.[^.]+$/, ""));
4661
- 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;
4662
4984
  }
4663
4985
  _findPlaceholder(e) {
4664
4986
  return this.context.layoutInfo.editable?.querySelector(`img[data-an-upload="${e}"]`) ?? null;
@@ -4666,7 +4988,7 @@ var qr = class {
4666
4988
  _resolveUpload(e, t) {
4667
4989
  let n = this._findPlaceholder(e), r = this._uploadPreviews?.get(e);
4668
4990
  if (n) {
4669
- let i = N(t, { allowData: !0 });
4991
+ let i = M(t, { allowData: !0 });
4670
4992
  if (i) n.setAttribute("src", i), n.classList.remove("an-image-uploading"), n.removeAttribute("data-an-upload"), n.style.removeProperty("--an-upload-progress");
4671
4993
  else {
4672
4994
  this._failUpload(e, r?.file, /* @__PURE__ */ Error(`Rejected image URL: ${t}`));
@@ -4758,30 +5080,30 @@ var qr = class {
4758
5080
  _escapeHTML(e) {
4759
5081
  return e.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll("\"", "&quot;").replaceAll("'", "&#039;");
4760
5082
  }
4761
- }, Yr = /[^\s\u200B]/;
4762
- function Xr(e) {
5083
+ }, Ei = /[^\s\u200B]/;
5084
+ function Di(e) {
4763
5085
  let t = document.createTreeWalker(e, NodeFilter.SHOW_TEXT);
4764
- 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;
4765
5087
  return !1;
4766
5088
  }
4767
5089
  //#endregion
4768
5090
  //#region src/js/presets/core.js
4769
- var Zr = [
5091
+ var Oi = [
4770
5092
  {
4771
5093
  name: "editor",
4772
- Class: Vr
5094
+ Class: gi
4773
5095
  },
4774
5096
  {
4775
5097
  name: "toolbar",
4776
- Class: Gr
5098
+ Class: Si
4777
5099
  },
4778
5100
  {
4779
5101
  name: "statusbar",
4780
- Class: qr
5102
+ Class: wi
4781
5103
  },
4782
5104
  {
4783
5105
  name: "clipboard",
4784
- Class: Jr
5106
+ Class: Ti
4785
5107
  },
4786
5108
  {
4787
5109
  name: "placeholder",
@@ -4792,54 +5114,54 @@ var Zr = [
4792
5114
  initialize() {
4793
5115
  let e = this.context.layoutInfo.editable, t = this.options.placeholder || "";
4794
5116
  t && (e.dataset.placeholder = t);
4795
- 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);
4796
5118
  return this._disposers.push(r, i, a), this._update(), this;
4797
5119
  }
4798
5120
  destroy() {
4799
5121
  this._disposers.forEach((e) => e()), this._disposers = [];
4800
5122
  }
4801
5123
  _update() {
4802
- 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");
4803
5125
  e.classList.toggle("an-placeholder", n && !t);
4804
5126
  }
4805
5127
  }
4806
5128
  }
4807
- ], Qr = "2.7.1";
5129
+ ], ki = "3.0.0";
4808
5130
  //#endregion
4809
5131
  //#region src/js/core/lists.js
4810
- function $r(e) {
5132
+ function Ai(e) {
4811
5133
  return e[e.length - 1];
4812
5134
  }
4813
- function ei(e) {
5135
+ function ji(e) {
4814
5136
  return e[0];
4815
5137
  }
4816
- function ti(e, t = 1) {
5138
+ function Mi(e, t = 1) {
4817
5139
  return e.slice(0, e.length - t);
4818
5140
  }
4819
- function ni(e, t = 1) {
5141
+ function Ni(e, t = 1) {
4820
5142
  return e.slice(t);
4821
5143
  }
4822
- function ri(e) {
5144
+ function Pi(e) {
4823
5145
  return e.flat();
4824
5146
  }
4825
- function ii(e) {
5147
+ function Fi(e) {
4826
5148
  return [...new Set(e)];
4827
5149
  }
4828
- function ai(e, t) {
5150
+ function Ii(e, t) {
4829
5151
  let n = [];
4830
5152
  for (let r = 0; r < e.length; r += t) n.push(e.slice(r, r + t));
4831
5153
  return n;
4832
5154
  }
4833
- function oi(e, t) {
5155
+ function Li(e, t) {
4834
5156
  return e.reduce((e, n) => {
4835
5157
  let r = t(n);
4836
5158
  return e[r] || (e[r] = []), e[r].push(n), e;
4837
5159
  }, {});
4838
5160
  }
4839
- function si(e, t) {
5161
+ function Ri(e, t) {
4840
5162
  return e.every(t);
4841
5163
  }
4842
- function ci(e, t) {
5164
+ function zi(e, t) {
4843
5165
  return e.some(t);
4844
5166
  }
4845
5167
  //#endregion
@@ -4847,7 +5169,7 @@ function ci(e, t) {
4847
5169
  function Q() {
4848
5170
  return globalThis.navigator?.userAgent ?? "";
4849
5171
  }
4850
- var li = {
5172
+ var Bi = {
4851
5173
  get isChrome() {
4852
5174
  return /Chrome\//.test(Q()) && !/Edg\//.test(Q());
4853
5175
  },
@@ -4872,11 +5194,11 @@ var li = {
4872
5194
  get modifierKey() {
4873
5195
  return /Macintosh/.test(Q()) ? "metaKey" : "ctrlKey";
4874
5196
  }
4875
- }, ui = { ...A }, $ = /* @__PURE__ */ new WeakMap(), di = {
5197
+ }, Vi = { ...k }, $ = /* @__PURE__ */ new WeakMap(), Hi = {
4876
5198
  create(e, t = {}) {
4877
- let n = fi(e).map((e) => {
5199
+ let n = Ui(e).map((e) => {
4878
5200
  if ($.has(e)) return $.get(e);
4879
- let n = new En(e, t);
5201
+ let n = new Yn(e, t);
4880
5202
  return n._releaseInstance = () => {
4881
5203
  $.get(e) === n && $.delete(e);
4882
5204
  }, n.initialize(), $.set(e, n), n;
@@ -4884,7 +5206,7 @@ var li = {
4884
5206
  return n.length === 1 ? n[0] : n;
4885
5207
  },
4886
5208
  destroy(e) {
4887
- fi(e).forEach((e) => {
5209
+ Ui(e).forEach((e) => {
4888
5210
  let t = $.get(e);
4889
5211
  t && (t.destroy(), $.delete(e));
4890
5212
  });
@@ -4894,48 +5216,51 @@ var li = {
4894
5216
  return t && $.get(t) || null;
4895
5217
  },
4896
5218
  get defaults() {
4897
- return { ...A };
5219
+ return { ...k };
4898
5220
  },
4899
5221
  setDefaults(e) {
4900
- Object.assign(A, e);
5222
+ Object.assign(k, e);
4901
5223
  },
4902
5224
  resetDefaults() {
4903
- 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);
4904
5226
  },
4905
5227
  registerModule(e, t) {
4906
- Cn.set(e, t);
5228
+ Un.set(e, t);
4907
5229
  },
4908
5230
  use(e, t = {}) {
4909
5231
  if (!e || typeof e.name != "string") throw TypeError("[AutumnNote] AutumnNote.use: plugin must have a string `name` property.");
4910
- 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, {
4911
5233
  plugin: e,
4912
5234
  options: t
4913
5235
  }), this);
4914
5236
  },
4915
5237
  hasPlugin(e) {
4916
- return P.has(e);
5238
+ return N.has(e);
4917
5239
  },
4918
5240
  registerButton(e) {
4919
- return k(e), this;
5241
+ return D(e), this;
5242
+ },
5243
+ registerIcon(e, t) {
5244
+ return St(e, t), this;
4920
5245
  },
4921
5246
  registerLocale(e, t) {
4922
- return nn(e, t), this;
5247
+ return gn(e, t), this;
4923
5248
  },
4924
5249
  registerSlashCommand(e) {
4925
5250
  if (!e?.id || typeof e.run != "function") throw TypeError("[AutumnNote] Slash command requires an id and run(context) function.");
4926
- 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);
4927
5252
  return n >= 0 ? t[n] = e : t.push(e), this;
4928
5253
  },
4929
- buttons: en,
4930
- version: Qr
5254
+ buttons: mn,
5255
+ version: ki
4931
5256
  };
4932
- function fi(e) {
5257
+ function Ui(e) {
4933
5258
  return typeof e == "string" ? Array.from(document.querySelectorAll(e)) : e instanceof Element ? [e] : e instanceof NodeList || Array.isArray(e) ? Array.from(e) : [];
4934
5259
  }
4935
5260
  //#endregion
4936
5261
  //#region src/js/core.js
4937
- Tn(Zr);
5262
+ Gn(Oi);
4938
5263
  //#endregion
4939
- 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 };
4940
5265
 
4941
5266
  //# sourceMappingURL=autumnnote.core.es.js.map