autumnnote 3.0.1 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/autumnnote.cjs +34 -32
- package/dist/autumnnote.core.es.js +1497 -789
- package/dist/autumnnote.core.es.js.map +1 -1
- package/dist/autumnnote.es.js +2042 -1298
- package/dist/autumnnote.es.js.map +1 -1
- package/dist/autumnnote.min.js +34 -32
- package/dist/autumnnote.umd.js +34 -32
- package/dist/autumnnote.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -65,8 +65,8 @@ function d(e) {
|
|
|
65
65
|
}
|
|
66
66
|
//#endregion
|
|
67
67
|
//#region src/js/core/dom.js
|
|
68
|
-
var f = 1,
|
|
69
|
-
function
|
|
68
|
+
var f = 1, ee = 3, p = (e) => e?.nodeType === 1, m = (e) => e?.nodeType === 3, te = (e) => p(e) && /^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/i.test(e.nodeName), ne = (e) => p(e) && /^(p|div|li|h[1-6]|blockquote|td|th|pre)$/i.test(e.nodeName), re = (e) => p(e) && /^(li)$/i.test(e.nodeName), h = (e) => p(e) && /^(ul|ol)$/i.test(e.nodeName), ie = (e) => p(e) && e.nodeName.toUpperCase() === "TABLE", ae = (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), oe = (e) => p(e) && e.isContentEditable, se = (e) => p(e) && e.nodeName.toUpperCase() === "A", ce = (e) => p(e) && e.nodeName.toUpperCase() === "IMG";
|
|
69
|
+
function g(e, t, n) {
|
|
70
70
|
let r = e;
|
|
71
71
|
for (; r && r !== n;) {
|
|
72
72
|
if (t(r)) return r;
|
|
@@ -74,65 +74,65 @@ function v(e, t, n) {
|
|
|
74
74
|
}
|
|
75
75
|
return null;
|
|
76
76
|
}
|
|
77
|
-
function
|
|
78
|
-
return
|
|
77
|
+
function le(e, t) {
|
|
78
|
+
return g(e, ne, t);
|
|
79
79
|
}
|
|
80
|
-
function
|
|
80
|
+
function ue(e, t) {
|
|
81
81
|
let n = [], r = e.parentNode;
|
|
82
82
|
for (; r && r !== t;) n.push(r), r = r.parentNode;
|
|
83
83
|
return n;
|
|
84
84
|
}
|
|
85
|
-
function
|
|
85
|
+
function de(e) {
|
|
86
86
|
return Array.from(e.childNodes);
|
|
87
87
|
}
|
|
88
|
-
function
|
|
88
|
+
function _(e) {
|
|
89
89
|
let t = e.previousSibling;
|
|
90
|
-
for (; t && !
|
|
90
|
+
for (; t && !p(t);) t = t.previousSibling;
|
|
91
91
|
return t;
|
|
92
92
|
}
|
|
93
|
-
function
|
|
93
|
+
function fe(e) {
|
|
94
94
|
let t = e.nextSibling;
|
|
95
|
-
for (; t && !
|
|
95
|
+
for (; t && !p(t);) t = t.nextSibling;
|
|
96
96
|
return t;
|
|
97
97
|
}
|
|
98
|
-
function
|
|
98
|
+
function v(e, t = {}, n = []) {
|
|
99
99
|
let r = document.createElement(e);
|
|
100
100
|
for (let [e, n] of Object.entries(t)) r.setAttribute(e, n);
|
|
101
101
|
for (let e of n) typeof e == "string" ? r.appendChild(document.createTextNode(e)) : r.appendChild(e);
|
|
102
102
|
return r;
|
|
103
103
|
}
|
|
104
|
-
function
|
|
104
|
+
function pe(e) {
|
|
105
105
|
e?.parentNode && e.remove();
|
|
106
106
|
}
|
|
107
|
-
function
|
|
107
|
+
function me(e) {
|
|
108
108
|
let t = e.parentNode;
|
|
109
109
|
if (t) {
|
|
110
110
|
for (; e.firstChild;) t.insertBefore(e.firstChild, e);
|
|
111
111
|
e.remove();
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
|
-
function
|
|
114
|
+
function he(e, t) {
|
|
115
115
|
return e.parentNode.insertBefore(t, e), t.appendChild(e), t;
|
|
116
116
|
}
|
|
117
|
-
function
|
|
117
|
+
function ge(e, t) {
|
|
118
118
|
t.nextSibling ? t.parentNode.insertBefore(e, t.nextSibling) : t.parentNode.appendChild(e);
|
|
119
119
|
}
|
|
120
|
-
function
|
|
121
|
-
return
|
|
120
|
+
function _e(e) {
|
|
121
|
+
return m(e) ? e.nodeValue : e.textContent || "";
|
|
122
122
|
}
|
|
123
|
-
function
|
|
124
|
-
return
|
|
123
|
+
function ve(e) {
|
|
124
|
+
return m(e) ? !e.nodeValue : te(e) ? !1 : e.childNodes.length === 1 && e.firstChild?.nodeName === "BR" || !e.textContent.trim() && !e.querySelector("img, video, hr, table");
|
|
125
125
|
}
|
|
126
|
-
function
|
|
126
|
+
function ye(e) {
|
|
127
127
|
return e.outerHTML;
|
|
128
128
|
}
|
|
129
|
-
function
|
|
129
|
+
function be(e) {
|
|
130
130
|
let t = document.createRange();
|
|
131
131
|
t.selectNodeContents(e), t.collapse(!1);
|
|
132
132
|
let n = globalThis.getSelection();
|
|
133
133
|
n && (n.removeAllRanges(), n.addRange(t));
|
|
134
134
|
}
|
|
135
|
-
function
|
|
135
|
+
function xe(e) {
|
|
136
136
|
if (e?.querySelectorAll) for (let t of e.querySelectorAll("ul > ul, ul > ol, ol > ul, ol > ol")) {
|
|
137
137
|
let e = t.previousElementSibling;
|
|
138
138
|
if (e && e.nodeName === "LI") e.appendChild(t);
|
|
@@ -142,13 +142,13 @@ function ye(e) {
|
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
|
-
function
|
|
146
|
-
return !!
|
|
145
|
+
function Se(e) {
|
|
146
|
+
return !!g(e, oe);
|
|
147
147
|
}
|
|
148
|
-
function
|
|
148
|
+
function y(e, t, n, r) {
|
|
149
149
|
return e.addEventListener(t, n, r), () => e.removeEventListener(t, n, r);
|
|
150
150
|
}
|
|
151
|
-
function
|
|
151
|
+
function Ce(e, t) {
|
|
152
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) => {
|
|
153
153
|
if (e.key === "Escape") {
|
|
154
154
|
e.stopPropagation(), t?.();
|
|
@@ -162,7 +162,7 @@ function xe(e, t) {
|
|
|
162
162
|
};
|
|
163
163
|
return document.addEventListener("keydown", r), () => document.removeEventListener("keydown", r);
|
|
164
164
|
}
|
|
165
|
-
function
|
|
165
|
+
function we(e, t) {
|
|
166
166
|
e.style.cursor = "grab";
|
|
167
167
|
let n = (n) => {
|
|
168
168
|
if (n.button !== 0 || n.target.closest("button, input, select, textarea, a")) return;
|
|
@@ -182,12 +182,12 @@ function Se(e, t) {
|
|
|
182
182
|
};
|
|
183
183
|
return e.addEventListener("mousedown", n), () => e.removeEventListener("mousedown", n);
|
|
184
184
|
}
|
|
185
|
-
function
|
|
185
|
+
function Te(e) {
|
|
186
186
|
return e?.layoutInfo?.portal || document.body;
|
|
187
187
|
}
|
|
188
188
|
//#endregion
|
|
189
189
|
//#region src/js/core/range.js
|
|
190
|
-
var
|
|
190
|
+
var Ee = class {
|
|
191
191
|
constructor(e, t, n, r) {
|
|
192
192
|
this.sc = e, this.so = t, this.ec = n, this.eo = r;
|
|
193
193
|
}
|
|
@@ -207,10 +207,10 @@ var S = class {
|
|
|
207
207
|
}
|
|
208
208
|
commonAncestor() {
|
|
209
209
|
let e = this.toNativeRange().commonAncestorContainer;
|
|
210
|
-
return
|
|
210
|
+
return p(e) ? e : e.parentElement;
|
|
211
211
|
}
|
|
212
212
|
blockNode(e) {
|
|
213
|
-
return
|
|
213
|
+
return g(this.sc, (t) => p(t) && t !== e, e);
|
|
214
214
|
}
|
|
215
215
|
toString() {
|
|
216
216
|
return this.toNativeRange().toString();
|
|
@@ -223,40 +223,40 @@ var S = class {
|
|
|
223
223
|
this.toNativeRange().insertNode(e);
|
|
224
224
|
}
|
|
225
225
|
};
|
|
226
|
-
function
|
|
227
|
-
return new
|
|
226
|
+
function De(e) {
|
|
227
|
+
return new Ee(e.startContainer, e.startOffset, e.endContainer, e.endOffset);
|
|
228
228
|
}
|
|
229
|
-
function
|
|
229
|
+
function Oe(e) {
|
|
230
230
|
let t = globalThis.getSelection();
|
|
231
231
|
if (!t || t.rangeCount === 0) return null;
|
|
232
232
|
let n = t.getRangeAt(0);
|
|
233
|
-
return e && !e.contains(n.commonAncestorContainer) ? null :
|
|
233
|
+
return e && !e.contains(n.commonAncestorContainer) ? null : De(n);
|
|
234
234
|
}
|
|
235
|
-
function
|
|
236
|
-
return new
|
|
235
|
+
function ke(e) {
|
|
236
|
+
return new Ee(e, 0, e, e.childNodes.length);
|
|
237
237
|
}
|
|
238
|
-
function
|
|
239
|
-
return new
|
|
238
|
+
function Ae(e, t = 0) {
|
|
239
|
+
return new Ee(e, t, e, t);
|
|
240
240
|
}
|
|
241
|
-
function
|
|
241
|
+
function je(e) {
|
|
242
242
|
let t = globalThis.getSelection();
|
|
243
243
|
return !t || t.rangeCount === 0 ? !1 : e.contains(t.getRangeAt(0).commonAncestorContainer);
|
|
244
244
|
}
|
|
245
|
-
function
|
|
245
|
+
function Me(e) {
|
|
246
246
|
let t = globalThis.getSelection();
|
|
247
247
|
if (!t || t.rangeCount === 0) {
|
|
248
248
|
e(null);
|
|
249
249
|
return;
|
|
250
250
|
}
|
|
251
251
|
let n = t.getRangeAt(0).cloneRange();
|
|
252
|
-
e(
|
|
252
|
+
e(De(n)), t.removeAllRanges(), t.addRange(n);
|
|
253
253
|
}
|
|
254
|
-
function
|
|
254
|
+
function Ne(e, t) {
|
|
255
255
|
return [e, e.splitText(t)];
|
|
256
256
|
}
|
|
257
257
|
//#endregion
|
|
258
258
|
//#region src/js/editing/insert.js
|
|
259
|
-
function
|
|
259
|
+
function Pe(e) {
|
|
260
260
|
let t = e && e.nodeType === 1 ? e : e?.parentElement;
|
|
261
261
|
for (; t;) {
|
|
262
262
|
let e = t.getAttribute?.("contenteditable") ?? t.contentEditable;
|
|
@@ -266,41 +266,41 @@ function je(e) {
|
|
|
266
266
|
}
|
|
267
267
|
return null;
|
|
268
268
|
}
|
|
269
|
-
function
|
|
269
|
+
function b(e) {
|
|
270
270
|
let t = globalThis.getSelection?.();
|
|
271
271
|
if (!t || t.rangeCount === 0) return null;
|
|
272
272
|
let n = t.getRangeAt(0);
|
|
273
|
-
return e && e !== document ? e.contains(n.commonAncestorContainer) ? n : null :
|
|
273
|
+
return e && e !== document ? e.contains(n.commonAncestorContainer) ? n : null : Pe(n.commonAncestorContainer) ? n : null;
|
|
274
274
|
}
|
|
275
|
-
function
|
|
275
|
+
function Fe(e) {
|
|
276
276
|
let t = globalThis.getSelection?.();
|
|
277
277
|
if (!t) return;
|
|
278
278
|
let n = document.createRange();
|
|
279
279
|
n.setStartAfter(e), n.collapse(!0), t.removeAllRanges(), t.addRange(n);
|
|
280
280
|
}
|
|
281
|
-
function
|
|
282
|
-
let n =
|
|
281
|
+
function Ie(e, t) {
|
|
282
|
+
let n = b(t);
|
|
283
283
|
if (!n) return !1;
|
|
284
284
|
let r = document.createElement("template");
|
|
285
285
|
r.innerHTML = e;
|
|
286
286
|
let i = r.content, a = i.lastChild;
|
|
287
|
-
return n.deleteContents(), n.insertNode(i), a &&
|
|
287
|
+
return n.deleteContents(), n.insertNode(i), a && Fe(a), !0;
|
|
288
288
|
}
|
|
289
|
-
function
|
|
290
|
-
let n =
|
|
289
|
+
function Le(e, t) {
|
|
290
|
+
let n = b(t);
|
|
291
291
|
if (!n) return !1;
|
|
292
292
|
n.deleteContents();
|
|
293
293
|
let r = String(e), i = document.createDocumentFragment();
|
|
294
|
-
!r.includes("\n") ||
|
|
294
|
+
!r.includes("\n") || ze(n.startContainer, t) ? i.appendChild(document.createTextNode(r)) : r.split("\n").forEach((e, t) => {
|
|
295
295
|
t > 0 && i.appendChild(document.createElement("br")), e && i.appendChild(document.createTextNode(e));
|
|
296
296
|
});
|
|
297
297
|
let a = i.lastChild;
|
|
298
|
-
return n.insertNode(i), a &&
|
|
298
|
+
return n.insertNode(i), a && Fe(a), !0;
|
|
299
299
|
}
|
|
300
|
-
function
|
|
301
|
-
return
|
|
300
|
+
function Re(e) {
|
|
301
|
+
return Le("\n", e);
|
|
302
302
|
}
|
|
303
|
-
function
|
|
303
|
+
function ze(e, t) {
|
|
304
304
|
let n = e.nodeType === 1 ? e : e.parentElement;
|
|
305
305
|
for (; n && n !== t;) {
|
|
306
306
|
if (n.tagName === "PRE" || n.tagName === "TEXTAREA") return !0;
|
|
@@ -310,12 +310,12 @@ function Le(e, t) {
|
|
|
310
310
|
}
|
|
311
311
|
return !1;
|
|
312
312
|
}
|
|
313
|
-
function
|
|
314
|
-
let t =
|
|
313
|
+
function Be(e) {
|
|
314
|
+
let t = b(e);
|
|
315
315
|
if (!t) return !1;
|
|
316
316
|
let n = document.createElement("hr");
|
|
317
317
|
t.deleteContents();
|
|
318
|
-
let r =
|
|
318
|
+
let r = He(t.startContainer, e);
|
|
319
319
|
r && r.parentNode ? r.parentNode.insertBefore(n, r.nextSibling) : t.insertNode(n);
|
|
320
320
|
let i = n.nextElementSibling;
|
|
321
321
|
if (!i || i.tagName === "HR") {
|
|
@@ -329,7 +329,7 @@ function Re(e) {
|
|
|
329
329
|
}
|
|
330
330
|
return !0;
|
|
331
331
|
}
|
|
332
|
-
var
|
|
332
|
+
var Ve = /* @__PURE__ */ new Set([
|
|
333
333
|
"P",
|
|
334
334
|
"DIV",
|
|
335
335
|
"H1",
|
|
@@ -342,81 +342,813 @@ var ze = /* @__PURE__ */ new Set([
|
|
|
342
342
|
"PRE",
|
|
343
343
|
"LI"
|
|
344
344
|
]);
|
|
345
|
-
function
|
|
345
|
+
function He(e, t) {
|
|
346
346
|
let n = e.nodeType === 1 ? e : e.parentElement;
|
|
347
347
|
for (; n && n !== t;) {
|
|
348
|
-
if (
|
|
348
|
+
if (Ve.has(n.tagName)) return n;
|
|
349
349
|
n = n.parentElement;
|
|
350
350
|
}
|
|
351
351
|
return null;
|
|
352
352
|
}
|
|
353
353
|
//#endregion
|
|
354
|
-
//#region src/js/editing/
|
|
355
|
-
|
|
356
|
-
|
|
354
|
+
//#region src/js/editing/format.js
|
|
355
|
+
var Ue = /* @__PURE__ */ new Set(/* @__PURE__ */ "ADDRESS.ARTICLE.ASIDE.BLOCKQUOTE.CAPTION.DD.DETAILS.DIV.DL.DT.FIELDSET.FIGCAPTION.FIGURE.FOOTER.FORM.H1.H2.H3.H4.H5.H6.HEADER.HR.LI.MAIN.NAV.OL.P.PRE.SECTION.SUMMARY.TABLE.TBODY.TD.TFOOT.TH.THEAD.TR.UL".split(".")), We = /* @__PURE__ */ new Set([
|
|
356
|
+
"A",
|
|
357
|
+
"B",
|
|
358
|
+
"BIG",
|
|
359
|
+
"CITE",
|
|
360
|
+
"CODE",
|
|
361
|
+
"DFN",
|
|
362
|
+
"EM",
|
|
363
|
+
"FONT",
|
|
364
|
+
"I",
|
|
365
|
+
"INS",
|
|
366
|
+
"KBD",
|
|
367
|
+
"MARK",
|
|
368
|
+
"Q",
|
|
369
|
+
"S",
|
|
370
|
+
"SAMP",
|
|
371
|
+
"SMALL",
|
|
372
|
+
"SPAN",
|
|
373
|
+
"STRIKE",
|
|
374
|
+
"STRONG",
|
|
375
|
+
"SUB",
|
|
376
|
+
"SUP",
|
|
377
|
+
"TT",
|
|
378
|
+
"U",
|
|
379
|
+
"VAR",
|
|
380
|
+
"DEL"
|
|
381
|
+
]), Ge = /* @__PURE__ */ new Set([
|
|
382
|
+
"B",
|
|
383
|
+
"BIG",
|
|
384
|
+
"CITE",
|
|
385
|
+
"CODE",
|
|
386
|
+
"DEL",
|
|
387
|
+
"DFN",
|
|
388
|
+
"EM",
|
|
389
|
+
"FONT",
|
|
390
|
+
"I",
|
|
391
|
+
"INS",
|
|
392
|
+
"KBD",
|
|
393
|
+
"MARK",
|
|
394
|
+
"Q",
|
|
395
|
+
"S",
|
|
396
|
+
"SAMP",
|
|
397
|
+
"SMALL",
|
|
398
|
+
"SPAN",
|
|
399
|
+
"STRIKE",
|
|
400
|
+
"STRONG",
|
|
401
|
+
"SUB",
|
|
402
|
+
"SUP",
|
|
403
|
+
"TT",
|
|
404
|
+
"U",
|
|
405
|
+
"VAR"
|
|
406
|
+
]), Ke = /* @__PURE__ */ new Set([
|
|
407
|
+
"IMG",
|
|
408
|
+
"BR",
|
|
409
|
+
"INPUT",
|
|
410
|
+
"IFRAME",
|
|
411
|
+
"VIDEO",
|
|
412
|
+
"AUDIO",
|
|
413
|
+
"CANVAS",
|
|
414
|
+
"SVG",
|
|
415
|
+
"svg"
|
|
416
|
+
]), x = "", S = (e) => !!e && e.nodeType === 1, C = (e) => S(e) && Ue.has(e.nodeName), qe = (e) => !e.hasChildNodes() || e.getAttribute("contenteditable") === "false";
|
|
417
|
+
function w(e) {
|
|
418
|
+
let t = 0;
|
|
419
|
+
for (let n = e.previousSibling; n; n = n.previousSibling) t++;
|
|
420
|
+
return t;
|
|
357
421
|
}
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
t.nodeType === 3 && (t = t.parentElement);
|
|
364
|
-
let n = t?.closest("u"), r = document.queryCommandState("underline");
|
|
365
|
-
if (n && !r) {
|
|
366
|
-
let e = n.parentNode;
|
|
367
|
-
for (; n.firstChild;) e.insertBefore(n.firstChild, n);
|
|
368
|
-
n.remove();
|
|
369
|
-
return;
|
|
422
|
+
function Je(e, t) {
|
|
423
|
+
let n = S(e) ? e : e.parentElement;
|
|
424
|
+
for (; n && n !== t;) {
|
|
425
|
+
if (Ue.has(n.nodeName)) return n;
|
|
426
|
+
n = n.parentElement;
|
|
370
427
|
}
|
|
371
|
-
|
|
428
|
+
return t;
|
|
372
429
|
}
|
|
373
|
-
function
|
|
374
|
-
let e =
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
let
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
return;
|
|
430
|
+
function Ye(e, t) {
|
|
431
|
+
for (let n = S(e) ? e : e.parentElement; n && n !== t; n = n.parentElement) if (n.getAttribute("contenteditable") === "false") return !0;
|
|
432
|
+
return !1;
|
|
433
|
+
}
|
|
434
|
+
function Xe(e, t, n) {
|
|
435
|
+
let r = document.createRange();
|
|
436
|
+
r.selectNodeContents(e);
|
|
437
|
+
try {
|
|
438
|
+
r.setEnd(t, n);
|
|
439
|
+
} catch {
|
|
440
|
+
return 0;
|
|
384
441
|
}
|
|
385
|
-
|
|
442
|
+
return r.toString().length;
|
|
386
443
|
}
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
444
|
+
function Ze(e, t, n) {
|
|
445
|
+
let r = document.createTreeWalker(e, NodeFilter.SHOW_TEXT), i = 0, a = null, o;
|
|
446
|
+
for (; o = r.nextNode();) {
|
|
447
|
+
let e = o.length;
|
|
448
|
+
if (n ? t < i + e : t <= i + e) return [o, t - i];
|
|
449
|
+
i += e, a = o;
|
|
450
|
+
}
|
|
451
|
+
return a ? [a, a.length] : null;
|
|
452
|
+
}
|
|
453
|
+
function T(e, t) {
|
|
454
|
+
return {
|
|
455
|
+
start: Xe(e, t.startContainer, t.startOffset),
|
|
456
|
+
end: Xe(e, t.endContainer, t.endOffset)
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
function E(e, t) {
|
|
460
|
+
let n = t.start === t.end, r = Ze(e, t.start, !n), i = n ? r : Ze(e, t.end, !1);
|
|
461
|
+
if (!r || !i) return;
|
|
462
|
+
let a = document.createRange();
|
|
463
|
+
try {
|
|
464
|
+
a.setStart(r[0], r[1]), a.setEnd(i[0], i[1]);
|
|
465
|
+
} catch {
|
|
399
466
|
return;
|
|
400
467
|
}
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
468
|
+
Qe(a);
|
|
469
|
+
}
|
|
470
|
+
function Qe(e) {
|
|
471
|
+
let t = globalThis.getSelection?.();
|
|
472
|
+
t && (t.removeAllRanges(), t.addRange(e));
|
|
473
|
+
}
|
|
474
|
+
function $e(e, t) {
|
|
475
|
+
let n = document.createRange();
|
|
476
|
+
n.setStart(e, t), n.collapse(!0), Qe(n);
|
|
477
|
+
}
|
|
478
|
+
function et(e, t) {
|
|
479
|
+
if (!t.length || t === e.startContainer && e.startOffset >= t.length || t === e.endContainer && e.endOffset === 0) return !1;
|
|
480
|
+
try {
|
|
481
|
+
return e.intersectsNode(t);
|
|
482
|
+
} catch {
|
|
483
|
+
return !1;
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
function tt(e, t) {
|
|
487
|
+
let n = t.parentNode;
|
|
488
|
+
if (!n) return !1;
|
|
489
|
+
let r = w(t);
|
|
490
|
+
try {
|
|
491
|
+
return e.comparePoint(n, r) >= 0 && e.comparePoint(n, r + 1) <= 0;
|
|
492
|
+
} catch {
|
|
493
|
+
return !1;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
function nt(e, t) {
|
|
497
|
+
let n = e.commonAncestorContainer;
|
|
498
|
+
if (n.nodeType === 3) return et(e, n) && !Ye(n, t) ? [n] : [];
|
|
499
|
+
let r = [], i = document.createTreeWalker(n, NodeFilter.SHOW_TEXT | NodeFilter.SHOW_ELEMENT), a;
|
|
500
|
+
for (; a = i.nextNode();) a.nodeType === 3 ? et(e, a) && !Ye(a, t) && r.push(a) : Ke.has(a.nodeName) && tt(e, a) && !Ye(a, t) && r.push(a);
|
|
501
|
+
return r;
|
|
502
|
+
}
|
|
503
|
+
function rt(e, t) {
|
|
504
|
+
let n = nt(e, t), r = [], i = null;
|
|
505
|
+
for (let e of n) {
|
|
506
|
+
let n = Je(e, t);
|
|
507
|
+
!i || i.block !== n ? (i = {
|
|
508
|
+
block: n,
|
|
509
|
+
first: e,
|
|
510
|
+
last: e
|
|
511
|
+
}, r.push(i)) : i.last = e;
|
|
512
|
+
}
|
|
513
|
+
let { startContainer: a, startOffset: o, endContainer: s, endOffset: c } = e;
|
|
514
|
+
return r.map(({ block: e, first: t, last: n }) => ({
|
|
515
|
+
block: e,
|
|
516
|
+
start: () => t === a && t.nodeType === 3 ? [t, o] : [t.parentNode, w(t)],
|
|
517
|
+
end: () => n === s && n.nodeType === 3 ? [n, c] : [n.parentNode, w(n) + 1]
|
|
518
|
+
}));
|
|
519
|
+
}
|
|
520
|
+
function it(e, t, n) {
|
|
521
|
+
let r, i;
|
|
522
|
+
if (e.nodeType === 3) {
|
|
523
|
+
let n = e;
|
|
524
|
+
r = n.parentNode, i = t <= 0 ? w(n) : t >= n.length ? w(n) + 1 : w(n.splitText(t));
|
|
525
|
+
} else r = e, i = t;
|
|
526
|
+
for (; r && r !== n;) {
|
|
527
|
+
let e = r.parentNode, t = w(r);
|
|
528
|
+
if (i <= 0) i = t;
|
|
529
|
+
else if (i >= r.childNodes.length) i = t + 1;
|
|
530
|
+
else {
|
|
531
|
+
let n = r.cloneNode(!1);
|
|
532
|
+
for (n.removeAttribute("id"); r.childNodes.length > i;) n.appendChild(r.childNodes[i]);
|
|
533
|
+
e.insertBefore(n, r.nextSibling), i = t + 1;
|
|
534
|
+
}
|
|
535
|
+
r = e;
|
|
536
|
+
}
|
|
537
|
+
return i;
|
|
538
|
+
}
|
|
539
|
+
function at(e, t, n) {
|
|
540
|
+
let r = it(n[0], n[1], e), i = e.childNodes[r] || null, a = it(t[0], t[1], e), o = [];
|
|
541
|
+
for (let t = e.childNodes[a]; t && t !== i; t = t.nextSibling) o.push(t);
|
|
542
|
+
return o;
|
|
543
|
+
}
|
|
544
|
+
function ot(e, t) {
|
|
545
|
+
if (e.nodeName !== t.nodeName || e.attributes.length !== t.attributes.length) return !1;
|
|
546
|
+
for (let n of e.attributes) if (t.getAttribute(n.name) !== n.value) return !1;
|
|
547
|
+
return !0;
|
|
548
|
+
}
|
|
549
|
+
function st(e) {
|
|
550
|
+
let t = e.firstChild;
|
|
551
|
+
for (; t;) {
|
|
552
|
+
let e = t.nextSibling;
|
|
553
|
+
if (S(t) && We.has(t.nodeName) && !t.hasChildNodes() && t.attributes.length === 0) {
|
|
554
|
+
t.remove(), t = e;
|
|
555
|
+
continue;
|
|
556
|
+
}
|
|
557
|
+
if (S(t) && S(e) && We.has(t.nodeName) && ot(t, e) && !qe(t) && !qe(e)) {
|
|
558
|
+
for (; e.firstChild;) t.appendChild(e.firstChild);
|
|
559
|
+
e.remove();
|
|
560
|
+
continue;
|
|
561
|
+
}
|
|
562
|
+
S(t) && !C(t) && st(t), t = e;
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
function D(e) {
|
|
566
|
+
let t = e.parentNode;
|
|
567
|
+
if (t) {
|
|
568
|
+
for (; e.firstChild;) t.insertBefore(e.firstChild, e);
|
|
569
|
+
e.remove();
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
function ct(e, t) {
|
|
573
|
+
let n = [], r = null;
|
|
574
|
+
for (let i of e) {
|
|
575
|
+
if (C(i)) {
|
|
576
|
+
r = null;
|
|
577
|
+
continue;
|
|
578
|
+
}
|
|
579
|
+
r || (r = t(), i.parentNode.insertBefore(r, i), n.push(r)), r.appendChild(i);
|
|
580
|
+
}
|
|
581
|
+
return n;
|
|
582
|
+
}
|
|
583
|
+
function lt(e, t, n) {
|
|
584
|
+
let r = T(e, t), i = rt(t, e), a = /* @__PURE__ */ new Set();
|
|
585
|
+
for (let e of i) {
|
|
586
|
+
let t = at(e.block, e.start(), e.end());
|
|
587
|
+
for (let e of ct(t, () => document.createElement("span"))) n(e), D(e);
|
|
588
|
+
a.add(e.block);
|
|
589
|
+
}
|
|
590
|
+
return a.forEach((e) => {
|
|
591
|
+
st(e), e.normalize();
|
|
592
|
+
}), E(e, r), i.length > 0;
|
|
593
|
+
}
|
|
594
|
+
function ut(e, t) {
|
|
595
|
+
let n = (e.style.textDecorationLine || e.style.textDecoration || "").split(/\s+/).filter((e) => e && e !== t && e !== "none");
|
|
596
|
+
e.style.removeProperty("text-decoration"), e.style.removeProperty("text-decoration-line"), n.length && (e.style.textDecorationLine = n.join(" "));
|
|
597
|
+
}
|
|
598
|
+
var dt = (e, t) => (e.textDecorationLine || e.textDecoration || "").split(/\s+/).includes(t), ft = {
|
|
599
|
+
bold: {
|
|
600
|
+
tag: "b",
|
|
601
|
+
tags: /* @__PURE__ */ new Set(["B", "STRONG"]),
|
|
602
|
+
styled: (e) => /^(bold|bolder|[6-9]00)$/.test(e.fontWeight),
|
|
603
|
+
unstyle: (e) => e.style.removeProperty("font-weight")
|
|
604
|
+
},
|
|
605
|
+
italic: {
|
|
606
|
+
tag: "i",
|
|
607
|
+
tags: /* @__PURE__ */ new Set(["I", "EM"]),
|
|
608
|
+
styled: (e) => e.fontStyle === "italic" || e.fontStyle === "oblique",
|
|
609
|
+
unstyle: (e) => e.style.removeProperty("font-style")
|
|
610
|
+
},
|
|
611
|
+
underline: {
|
|
612
|
+
tag: "u",
|
|
613
|
+
tags: /* @__PURE__ */ new Set(["U", "INS"]),
|
|
614
|
+
styled: (e) => dt(e, "underline"),
|
|
615
|
+
unstyle: (e) => ut(e, "underline")
|
|
616
|
+
},
|
|
617
|
+
strikethrough: {
|
|
618
|
+
tag: "s",
|
|
619
|
+
tags: /* @__PURE__ */ new Set([
|
|
620
|
+
"S",
|
|
621
|
+
"STRIKE",
|
|
622
|
+
"DEL"
|
|
623
|
+
]),
|
|
624
|
+
styled: (e) => dt(e, "line-through"),
|
|
625
|
+
unstyle: (e) => ut(e, "line-through")
|
|
626
|
+
},
|
|
627
|
+
superscript: {
|
|
628
|
+
tag: "sup",
|
|
629
|
+
tags: /* @__PURE__ */ new Set(["SUP"]),
|
|
630
|
+
styled: (e) => e.verticalAlign === "super",
|
|
631
|
+
unstyle: (e) => e.style.removeProperty("vertical-align"),
|
|
632
|
+
excludes: "subscript"
|
|
633
|
+
},
|
|
634
|
+
subscript: {
|
|
635
|
+
tag: "sub",
|
|
636
|
+
tags: /* @__PURE__ */ new Set(["SUB"]),
|
|
637
|
+
styled: (e) => e.verticalAlign === "sub",
|
|
638
|
+
unstyle: (e) => e.style.removeProperty("vertical-align"),
|
|
639
|
+
excludes: "superscript"
|
|
640
|
+
}
|
|
641
|
+
};
|
|
642
|
+
function pt(e, t) {
|
|
643
|
+
if (!S(e)) return !1;
|
|
644
|
+
if (t.tags.has(e.nodeName)) return !0;
|
|
645
|
+
let n = e.style;
|
|
646
|
+
return !!n && t.styled(n);
|
|
647
|
+
}
|
|
648
|
+
function mt(e, t, n) {
|
|
649
|
+
for (let r = S(e) ? e : e.parentElement; r && r !== n; r = r.parentElement) if (pt(r, t)) return !0;
|
|
650
|
+
return !1;
|
|
651
|
+
}
|
|
652
|
+
function ht(e, t) {
|
|
653
|
+
let n = [...e.querySelectorAll("*")].filter((e) => pt(e, t)).reverse();
|
|
654
|
+
for (let e of n) gt(e, t);
|
|
655
|
+
}
|
|
656
|
+
function gt(e, t) {
|
|
657
|
+
if (!qe(e)) {
|
|
658
|
+
if (t.tags.has(e.nodeName)) {
|
|
659
|
+
if (e.getAttribute("style")) {
|
|
660
|
+
let n = document.createElement("span");
|
|
661
|
+
for (n.setAttribute("style", e.getAttribute("style")), e.parentNode.insertBefore(n, e); e.firstChild;) n.appendChild(e.firstChild);
|
|
662
|
+
e.remove(), t.styled(n.style) && t.unstyle(n);
|
|
663
|
+
return;
|
|
664
|
+
}
|
|
665
|
+
D(e);
|
|
666
|
+
return;
|
|
667
|
+
}
|
|
668
|
+
t.unstyle(e), e.getAttribute("style") || e.removeAttribute("style"), (e.nodeName === "SPAN" || e.nodeName === "FONT") && e.attributes.length === 0 && D(e);
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
function _t(e, t) {
|
|
672
|
+
let n = ft[e], r = b(t);
|
|
673
|
+
if (!n || !r) return !1;
|
|
674
|
+
let i = O(r, t);
|
|
675
|
+
if (!i) return !1;
|
|
676
|
+
if (r.collapsed) return mt(r.startContainer, n, i);
|
|
677
|
+
let a = nt(r, i).filter((e) => e.nodeType === 3 && /[^\s\u200B]/.test(e.data));
|
|
678
|
+
return a.length ? a.every((e) => mt(e, n, i)) : mt(r.startContainer, n, i);
|
|
679
|
+
}
|
|
680
|
+
function O(e, t) {
|
|
681
|
+
return t && t !== document ? t : Pe(e.commonAncestorContainer);
|
|
682
|
+
}
|
|
683
|
+
function k(e, t, n) {
|
|
684
|
+
let r = ft[e], i = b(n);
|
|
685
|
+
if (!r || !i) return !1;
|
|
686
|
+
let a = O(i, n);
|
|
687
|
+
if (!a) return !1;
|
|
688
|
+
let o = t ?? !_t(e, n);
|
|
689
|
+
if (i.collapsed) {
|
|
690
|
+
if (o) {
|
|
691
|
+
if (mt(i.startContainer, r, a)) return !0;
|
|
692
|
+
vt(i, () => document.createElement(r.tag), r.excludes ? ft[r.excludes] : null, a);
|
|
693
|
+
} else St(i, r, a);
|
|
694
|
+
return !0;
|
|
695
|
+
}
|
|
696
|
+
let s = r.excludes ? ft[r.excludes] : null;
|
|
697
|
+
return lt(a, i, (e) => {
|
|
698
|
+
if (ht(e, r), s && o && ht(e, s), !o) return;
|
|
699
|
+
let t = document.createElement(r.tag);
|
|
700
|
+
for (; e.firstChild;) t.appendChild(e.firstChild);
|
|
701
|
+
e.appendChild(t);
|
|
702
|
+
});
|
|
703
|
+
}
|
|
704
|
+
function vt(e, t, n, r) {
|
|
705
|
+
let i = t(), a = e.startContainer;
|
|
706
|
+
if (a.nodeType === 3 && a.data === x ? (a.parentNode.insertBefore(i, a), i.appendChild(a)) : (i.appendChild(document.createTextNode(x)), e.insertNode(i)), n) {
|
|
707
|
+
let e = bt(i, n, r);
|
|
708
|
+
e && xt(i.firstChild, e, n);
|
|
709
|
+
}
|
|
710
|
+
let o = i.ownerDocument.contains(i) ? yt(i) : null;
|
|
711
|
+
o && $e(o, o.length);
|
|
712
|
+
}
|
|
713
|
+
function yt(e) {
|
|
714
|
+
let t = document.createTreeWalker(e, NodeFilter.SHOW_TEXT), n, r = null;
|
|
715
|
+
for (; n = t.nextNode();) r = n;
|
|
716
|
+
return r;
|
|
717
|
+
}
|
|
718
|
+
function bt(e, t, n) {
|
|
719
|
+
let r = null;
|
|
720
|
+
for (let i = S(e) ? e : e.parentElement; i && i !== n && !C(i); i = i.parentElement) pt(i, t) && (r = i);
|
|
721
|
+
return r;
|
|
722
|
+
}
|
|
723
|
+
function xt(e, t, n) {
|
|
724
|
+
let r = t.parentNode, i = at(r, [e.parentNode, w(e)], [e.parentNode, w(e) + 1]);
|
|
725
|
+
for (let e of i) S(e) && (ht(e, n), pt(e, n) && gt(e, n));
|
|
726
|
+
st(r);
|
|
727
|
+
}
|
|
728
|
+
function St(e, t, n) {
|
|
729
|
+
let r = e.startContainer;
|
|
730
|
+
(r.nodeType !== 3 || r.data !== x) && (r = document.createTextNode(x), e.insertNode(r));
|
|
731
|
+
let i = bt(r, t, n);
|
|
732
|
+
i && xt(r, i, t), r.parentNode && $e(r, 1);
|
|
733
|
+
}
|
|
734
|
+
function Ct(e) {
|
|
735
|
+
let t = b(e);
|
|
736
|
+
if (!t || !t.collapsed || t.startContainer.nodeType !== 3) return;
|
|
737
|
+
let n = t.startContainer, r = n.data.indexOf(x);
|
|
738
|
+
if (r === -1 || n.data.length < 2) return;
|
|
739
|
+
let i = t.startOffset;
|
|
740
|
+
n.deleteData(r, 1), $e(n, i > r ? i - 1 : i);
|
|
741
|
+
}
|
|
742
|
+
var wt = {
|
|
743
|
+
color: "color",
|
|
744
|
+
"font-family": "face",
|
|
745
|
+
"font-size": "size"
|
|
746
|
+
};
|
|
747
|
+
function A(e, t, n) {
|
|
748
|
+
let r = b(n);
|
|
749
|
+
if (!r) return !1;
|
|
750
|
+
let i = O(r, n);
|
|
751
|
+
if (!i) return !1;
|
|
752
|
+
let a = () => {
|
|
404
753
|
let n = document.createElement("span");
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
let
|
|
754
|
+
return n.style.setProperty(e, t), n;
|
|
755
|
+
};
|
|
756
|
+
return r.collapsed ? (vt(r, a, null, i), !0) : lt(i, r, (n) => {
|
|
757
|
+
for (let t of [...n.querySelectorAll("*")].reverse()) {
|
|
758
|
+
let n = t;
|
|
759
|
+
n.style?.getPropertyValue(e) && n.style.removeProperty(e), n.nodeName === "FONT" && wt[e] && n.removeAttribute(wt[e]), n.getAttribute("style") || n.removeAttribute("style"), (n.nodeName === "SPAN" || n.nodeName === "FONT") && n.attributes.length === 0 && D(n);
|
|
760
|
+
}
|
|
761
|
+
let r = n.childNodes.length === 1 ? n.firstChild : null;
|
|
762
|
+
if (r && S(r) && r.nodeName === "SPAN") {
|
|
763
|
+
r.style.setProperty(e, t);
|
|
764
|
+
return;
|
|
765
|
+
}
|
|
766
|
+
let i = a();
|
|
767
|
+
for (; n.firstChild;) i.appendChild(n.firstChild);
|
|
768
|
+
n.appendChild(i);
|
|
769
|
+
});
|
|
770
|
+
}
|
|
771
|
+
function Tt(e) {
|
|
772
|
+
let t = b(e);
|
|
773
|
+
if (!t || t.collapsed) return !1;
|
|
774
|
+
let n = O(t, e);
|
|
775
|
+
return n ? lt(n, t, (e) => {
|
|
776
|
+
for (let t of [...e.querySelectorAll("*")].reverse()) qe(t) || (Ge.has(t.nodeName) ? D(t) : C(t) || t.removeAttribute("style"));
|
|
777
|
+
}) : !1;
|
|
778
|
+
}
|
|
779
|
+
function Et(e, t) {
|
|
780
|
+
let n = b(t);
|
|
781
|
+
if (!n || n.collapsed) return [];
|
|
782
|
+
let r = O(n, t);
|
|
783
|
+
if (!r) return [];
|
|
784
|
+
let i = [];
|
|
785
|
+
return lt(r, n, (t) => {
|
|
786
|
+
t.querySelectorAll("a").forEach((e) => D(e));
|
|
787
|
+
let n = document.createElement("a");
|
|
788
|
+
for (n.setAttribute("href", e); t.firstChild;) n.appendChild(t.firstChild);
|
|
789
|
+
t.appendChild(n), i.push(n);
|
|
790
|
+
}), i.filter((e) => e.isConnected);
|
|
791
|
+
}
|
|
792
|
+
function Dt(e) {
|
|
793
|
+
let t = b(e);
|
|
794
|
+
if (!t) return !1;
|
|
795
|
+
let n = O(t, e);
|
|
796
|
+
if (!n) return !1;
|
|
797
|
+
let r = T(n, t), i = /* @__PURE__ */ new Set(), a = (S(t.startContainer) ? t.startContainer : t.startContainer.parentElement)?.closest("a");
|
|
798
|
+
return a && n.contains(a) && i.add(a), t.collapsed || n.querySelectorAll("a").forEach((e) => {
|
|
409
799
|
try {
|
|
410
|
-
|
|
411
|
-
r.setStart(i, 0), r.setEnd(a, a.nodeType === Node.TEXT_NODE ? a.textContent.length : a.childNodes.length), n.removeAllRanges(), n.addRange(r);
|
|
800
|
+
t.intersectsNode(e) && i.add(e);
|
|
412
801
|
} catch {}
|
|
802
|
+
}), i.size ? (i.forEach((e) => {
|
|
803
|
+
let t = e.parentElement;
|
|
804
|
+
D(e), t?.normalize();
|
|
805
|
+
}), E(n, r), !0) : !1;
|
|
806
|
+
}
|
|
807
|
+
function Ot(e, t) {
|
|
808
|
+
let n = e;
|
|
809
|
+
for (; n.previousSibling && !C(n.previousSibling);) n = n.previousSibling;
|
|
810
|
+
let r = e;
|
|
811
|
+
for (; r.nextSibling && !C(r.nextSibling);) r = r.nextSibling;
|
|
812
|
+
let i = document.createElement("p");
|
|
813
|
+
t.insertBefore(i, n);
|
|
814
|
+
let a = n;
|
|
815
|
+
for (; a;) {
|
|
816
|
+
let e = a === r ? null : a.nextSibling;
|
|
817
|
+
i.appendChild(a), a = e;
|
|
818
|
+
}
|
|
819
|
+
return i;
|
|
820
|
+
}
|
|
821
|
+
function j(e, t) {
|
|
822
|
+
let n = [], r = /* @__PURE__ */ new Set(), i = nt(e, t);
|
|
823
|
+
i.length || (i = [e.startContainer]);
|
|
824
|
+
for (let e of i) {
|
|
825
|
+
if (e === t || !t.contains(e)) continue;
|
|
826
|
+
let i = Je(e, t);
|
|
827
|
+
if (i === t) {
|
|
828
|
+
let n = e;
|
|
829
|
+
for (; n.parentNode !== t;) n = n.parentNode;
|
|
830
|
+
i = C(n) ? n : Ot(n, t);
|
|
831
|
+
}
|
|
832
|
+
r.has(i) || (r.add(i), n.push(i));
|
|
833
|
+
}
|
|
834
|
+
if (!n.length && e.startContainer === t) {
|
|
835
|
+
let r = t.childNodes[Math.min(e.startOffset, t.childNodes.length - 1)];
|
|
836
|
+
r && !C(r) ? n.push(Ot(r, t)) : r && !kt.has(r.nodeName) && n.push(r);
|
|
837
|
+
}
|
|
838
|
+
return n;
|
|
839
|
+
}
|
|
840
|
+
var kt = /* @__PURE__ */ new Set([
|
|
841
|
+
"UL",
|
|
842
|
+
"OL",
|
|
843
|
+
"DL",
|
|
844
|
+
"TABLE",
|
|
845
|
+
"TBODY",
|
|
846
|
+
"THEAD",
|
|
847
|
+
"TFOOT",
|
|
848
|
+
"TR"
|
|
849
|
+
]);
|
|
850
|
+
function At(e) {
|
|
851
|
+
if (!(e.textContent || e.querySelector("br, img, input, iframe, video, hr, table"))) {
|
|
852
|
+
for (; e.firstChild;) e.firstChild.remove();
|
|
853
|
+
e.appendChild(document.createElement("br"));
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
var jt = [
|
|
857
|
+
"style",
|
|
858
|
+
"dir",
|
|
859
|
+
"lang",
|
|
860
|
+
"data-an-block-id"
|
|
861
|
+
];
|
|
862
|
+
function Mt(e, t) {
|
|
863
|
+
let n = document.createElement(t);
|
|
864
|
+
for (let t of jt) {
|
|
865
|
+
let r = e.getAttribute(t);
|
|
866
|
+
r != null && n.setAttribute(t, r);
|
|
867
|
+
}
|
|
868
|
+
for (; e.firstChild;) n.appendChild(e.firstChild);
|
|
869
|
+
return e.parentNode.replaceChild(n, e), n;
|
|
870
|
+
}
|
|
871
|
+
var Nt = /* @__PURE__ */ new Set([
|
|
872
|
+
"LI",
|
|
873
|
+
"TD",
|
|
874
|
+
"TH",
|
|
875
|
+
"DD",
|
|
876
|
+
"DT",
|
|
877
|
+
"CAPTION",
|
|
878
|
+
"FIGCAPTION",
|
|
879
|
+
"SUMMARY"
|
|
880
|
+
]);
|
|
881
|
+
function Pt(e, t) {
|
|
882
|
+
let n = b(t);
|
|
883
|
+
if (!n) return !1;
|
|
884
|
+
let r = O(n, t);
|
|
885
|
+
if (!r) return !1;
|
|
886
|
+
let i = String(e).replace(/[<>]/g, "").toLowerCase();
|
|
887
|
+
if (!i) return !1;
|
|
888
|
+
let a = T(r, n), o = [];
|
|
889
|
+
for (let e of j(n, r)) {
|
|
890
|
+
if (e.nodeName.toLowerCase() === i) continue;
|
|
891
|
+
if (Nt.has(e.nodeName)) {
|
|
892
|
+
if (i === "p") continue;
|
|
893
|
+
let t = document.createElement(i);
|
|
894
|
+
for (; e.firstChild && !C(e.firstChild);) t.appendChild(e.firstChild);
|
|
895
|
+
e.insertBefore(t, e.firstChild), o.push(t);
|
|
896
|
+
continue;
|
|
897
|
+
}
|
|
898
|
+
if (i === "p" && Nt.has(e.parentElement?.nodeName ?? "")) {
|
|
899
|
+
D(e);
|
|
900
|
+
continue;
|
|
901
|
+
}
|
|
902
|
+
e.nodeName === "PRE" && Ft(e);
|
|
903
|
+
let t = Mt(e, i);
|
|
904
|
+
At(t), o.push(t);
|
|
905
|
+
}
|
|
906
|
+
return i === "pre" && It(o), E(r, a), !0;
|
|
907
|
+
}
|
|
908
|
+
function Ft(e) {
|
|
909
|
+
let t = document.createTreeWalker(e, NodeFilter.SHOW_TEXT), n = [], r;
|
|
910
|
+
for (; r = t.nextNode();) n.push(r);
|
|
911
|
+
for (let e of n) {
|
|
912
|
+
let t = e.data.split("\n");
|
|
913
|
+
if (t.length === 1) continue;
|
|
914
|
+
let n = document.createDocumentFragment();
|
|
915
|
+
t.forEach((e, t) => {
|
|
916
|
+
t && n.appendChild(document.createElement("br")), e && n.appendChild(document.createTextNode(e));
|
|
917
|
+
}), e.parentNode.replaceChild(n, e);
|
|
918
|
+
}
|
|
919
|
+
let i = e.querySelector(":scope > code");
|
|
920
|
+
i && e.childNodes.length === 1 && D(i);
|
|
921
|
+
}
|
|
922
|
+
function It(e) {
|
|
923
|
+
for (let t = e.length - 1; t > 0; t--) {
|
|
924
|
+
let n = e[t], r = e[t - 1];
|
|
925
|
+
if (n.previousElementSibling === r && n.previousSibling === r) {
|
|
926
|
+
for (Lt(r), Lt(n), r.appendChild(document.createTextNode("\n")); n.firstChild;) r.appendChild(n.firstChild);
|
|
927
|
+
n.remove();
|
|
928
|
+
}
|
|
413
929
|
}
|
|
930
|
+
e.forEach((e) => {
|
|
931
|
+
e.isConnected && (Lt(e), e.normalize());
|
|
932
|
+
});
|
|
414
933
|
}
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
C("indent"), ye(rt());
|
|
934
|
+
function Lt(e) {
|
|
935
|
+
e.querySelectorAll("br").forEach((e) => e.replaceWith(document.createTextNode("\n")));
|
|
418
936
|
}
|
|
419
|
-
function
|
|
937
|
+
function M(e, t) {
|
|
938
|
+
let n = b(t);
|
|
939
|
+
if (!n) return !1;
|
|
940
|
+
let r = O(n, t);
|
|
941
|
+
if (!r) return !1;
|
|
942
|
+
let i = T(r, n);
|
|
943
|
+
for (let t of j(n, r)) {
|
|
944
|
+
let n = t, r = getComputedStyle(n).direction === "rtl";
|
|
945
|
+
e === "left" && !r || e === "right" && r ? n.style.removeProperty("text-align") : n.style.textAlign = e, n.getAttribute("style") || n.removeAttribute("style");
|
|
946
|
+
}
|
|
947
|
+
return E(r, i), !0;
|
|
948
|
+
}
|
|
949
|
+
function Rt(e, t) {
|
|
950
|
+
let n = /* @__PURE__ */ new Map();
|
|
951
|
+
for (let r of j(e, t)) {
|
|
952
|
+
let e = r.nodeName === "LI" ? r : r.closest("li");
|
|
953
|
+
if (!e || !t.contains(e)) continue;
|
|
954
|
+
let i = e.parentElement;
|
|
955
|
+
n.has(i) || n.set(i, []);
|
|
956
|
+
let a = n.get(i);
|
|
957
|
+
a.includes(e) || a.push(e);
|
|
958
|
+
}
|
|
959
|
+
return n;
|
|
960
|
+
}
|
|
961
|
+
function N(e, t) {
|
|
962
|
+
let n = b(t);
|
|
963
|
+
if (!n) return !1;
|
|
964
|
+
let r = O(n, t);
|
|
965
|
+
if (!r) return !1;
|
|
966
|
+
let i = e.toUpperCase(), a = T(r, n), o = Rt(n, r), s = [...o.keys()];
|
|
967
|
+
if (s.length && s.every((e) => e.nodeName === i)) for (let [e, t] of o) Bt(e, t);
|
|
968
|
+
else {
|
|
969
|
+
let e = j(n, r).filter((e) => e.nodeName !== "LI" && !e.closest("li"));
|
|
970
|
+
for (let e of s) e.nodeName !== i && zt(e, i.toLowerCase());
|
|
971
|
+
Vt(e, i.toLowerCase());
|
|
972
|
+
}
|
|
973
|
+
return E(r, a), !0;
|
|
974
|
+
}
|
|
975
|
+
function zt(e, t) {
|
|
976
|
+
let n = document.createElement(t);
|
|
977
|
+
for (let t of e.attributes) n.setAttribute(t.name, t.value);
|
|
978
|
+
for (; e.firstChild;) n.appendChild(e.firstChild);
|
|
979
|
+
e.replaceWith(n);
|
|
980
|
+
}
|
|
981
|
+
function Bt(e, t) {
|
|
982
|
+
let n = [...e.children], r = n.indexOf(t[0]), i = n.indexOf(t.at(-1));
|
|
983
|
+
if (r === -1 || i === -1) return;
|
|
984
|
+
let a = n.slice(i + 1), o = e;
|
|
985
|
+
for (let e of n.slice(r, i + 1)) {
|
|
986
|
+
let t = document.createElement("p"), n = [];
|
|
987
|
+
for (let r of [...e.childNodes]) S(r) && (r.nodeName === "UL" || r.nodeName === "OL") ? n.push(r) : S(r) && r.nodeName === "INPUT" || t.appendChild(r);
|
|
988
|
+
t.hasChildNodes() || t.appendChild(document.createElement("br"));
|
|
989
|
+
let r = e.style.textAlign;
|
|
990
|
+
r && (t.style.textAlign = r), o.after(t), o = t;
|
|
991
|
+
for (let e of n) o.after(e), o = e;
|
|
992
|
+
e.remove();
|
|
993
|
+
}
|
|
994
|
+
if (a.length) {
|
|
995
|
+
let t = e.cloneNode(!1);
|
|
996
|
+
t.removeAttribute("id"), a.forEach((e) => t.appendChild(e)), o.after(t);
|
|
997
|
+
}
|
|
998
|
+
e.children.length || e.remove();
|
|
999
|
+
}
|
|
1000
|
+
function Vt(e, t) {
|
|
1001
|
+
let n = [], r = null;
|
|
1002
|
+
for (let i of e) {
|
|
1003
|
+
if (Nt.has(i.nodeName)) {
|
|
1004
|
+
let e = document.createElement(t), n = document.createElement("li");
|
|
1005
|
+
for (; i.firstChild;) n.appendChild(i.firstChild);
|
|
1006
|
+
n.hasChildNodes() || n.appendChild(document.createElement("br")), e.appendChild(n), i.appendChild(e), r = null;
|
|
1007
|
+
continue;
|
|
1008
|
+
}
|
|
1009
|
+
(!r || r.nextElementSibling !== i || !Ht(r, i)) && (r = document.createElement(t), i.parentNode.insertBefore(r, i), n.push(r));
|
|
1010
|
+
let e = document.createElement("li"), a = i.style?.textAlign;
|
|
1011
|
+
if (a && (e.style.textAlign = a), i.nodeName === "PRE" || i.nodeName === "BLOCKQUOTE") e.appendChild(i);
|
|
1012
|
+
else {
|
|
1013
|
+
for (; i.firstChild;) e.appendChild(i.firstChild);
|
|
1014
|
+
i.remove();
|
|
1015
|
+
}
|
|
1016
|
+
At(e), r.appendChild(e);
|
|
1017
|
+
}
|
|
1018
|
+
n.forEach(Ut);
|
|
1019
|
+
}
|
|
1020
|
+
function Ht(e, t) {
|
|
1021
|
+
for (let n = e.nextSibling; n && n !== t; n = n.nextSibling) if (n.nodeType !== 3 || /\S/.test(n.data)) return !1;
|
|
1022
|
+
return !0;
|
|
1023
|
+
}
|
|
1024
|
+
function Ut(e) {
|
|
1025
|
+
if (!e.isConnected) return;
|
|
1026
|
+
let t = e.previousElementSibling;
|
|
1027
|
+
if (t && t.nodeName === e.nodeName && !t.className && !e.className && Ht(t, e)) {
|
|
1028
|
+
for (; e.firstChild;) t.appendChild(e.firstChild);
|
|
1029
|
+
e.remove(), e = t;
|
|
1030
|
+
}
|
|
1031
|
+
let n = e.nextElementSibling;
|
|
1032
|
+
if (n && n.nodeName === e.nodeName && !n.className && !e.className && Ht(e, n)) {
|
|
1033
|
+
for (; n.firstChild;) e.appendChild(n.firstChild);
|
|
1034
|
+
n.remove();
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
var Wt = 40, Gt = (e) => getComputedStyle(e).direction === "rtl" ? "margin-right" : "margin-left";
|
|
1038
|
+
function Kt(e) {
|
|
1039
|
+
let t = b(e);
|
|
1040
|
+
if (!t) return !1;
|
|
1041
|
+
let n = O(t, e);
|
|
1042
|
+
if (!n) return !1;
|
|
1043
|
+
let r = T(n, t), i = Rt(t, n);
|
|
1044
|
+
if (i.size) for (let [e, t] of i) {
|
|
1045
|
+
let n = t[0].previousElementSibling;
|
|
1046
|
+
if (!n || n.nodeName !== "LI") continue;
|
|
1047
|
+
let r = n.lastElementChild;
|
|
1048
|
+
(!r || r.nodeName !== e.nodeName) && (r = e.cloneNode(!1), r.removeAttribute("id"), r.removeAttribute("data-an-block-id"), n.appendChild(r));
|
|
1049
|
+
for (let e of t) r.appendChild(e);
|
|
1050
|
+
}
|
|
1051
|
+
else for (let e of j(t, n)) {
|
|
1052
|
+
let t = e, n = Gt(t), r = parseFloat(t.style.getPropertyValue(n)) || 0;
|
|
1053
|
+
t.style.setProperty(n, `${r + Wt}px`);
|
|
1054
|
+
}
|
|
1055
|
+
return E(n, r), !0;
|
|
1056
|
+
}
|
|
1057
|
+
function qt(e) {
|
|
1058
|
+
let t = b(e);
|
|
1059
|
+
if (!t) return !1;
|
|
1060
|
+
let n = O(t, e);
|
|
1061
|
+
if (!n) return !1;
|
|
1062
|
+
let r = T(n, t), i = Rt(t, n);
|
|
1063
|
+
if (i.size) for (let [e, t] of i) {
|
|
1064
|
+
let n = e.parentElement;
|
|
1065
|
+
n?.nodeName === "LI" ? Jt(e, t, n) : Bt(e, t);
|
|
1066
|
+
}
|
|
1067
|
+
else for (let e of j(t, n)) {
|
|
1068
|
+
let t = e, n = Gt(t), r = parseFloat(t.style.getPropertyValue(n)) || 0;
|
|
1069
|
+
r > Wt ? t.style.setProperty(n, `${r - Wt}px`) : t.style.removeProperty(n), t.getAttribute("style") || t.removeAttribute("style");
|
|
1070
|
+
let i = t.parentElement;
|
|
1071
|
+
r === 0 && i?.nodeName === "BLOCKQUOTE" && /border:\s*none/.test(i.getAttribute("style") || "") && D(i);
|
|
1072
|
+
}
|
|
1073
|
+
return E(n, r), !0;
|
|
1074
|
+
}
|
|
1075
|
+
function Jt(e, t, n) {
|
|
1076
|
+
let r = t.at(-1), i = [];
|
|
1077
|
+
for (let e = r.nextElementSibling; e; e = e.nextElementSibling) i.push(e);
|
|
1078
|
+
if (i.length) {
|
|
1079
|
+
let t = e.cloneNode(!1);
|
|
1080
|
+
t.removeAttribute("id"), i.forEach((e) => t.appendChild(e)), r.appendChild(t);
|
|
1081
|
+
}
|
|
1082
|
+
let a = n;
|
|
1083
|
+
for (let e of t) a.after(e), a = e;
|
|
1084
|
+
e.children.length || e.remove();
|
|
1085
|
+
}
|
|
1086
|
+
function Yt(e) {
|
|
1087
|
+
let t = b(e);
|
|
1088
|
+
if (!t) return "";
|
|
1089
|
+
let n = O(t, e);
|
|
1090
|
+
if (!n) return "";
|
|
1091
|
+
let r = Je(t.startContainer, n);
|
|
1092
|
+
return r === n || Nt.has(r.nodeName) ? "p" : r.nodeName.toLowerCase();
|
|
1093
|
+
}
|
|
1094
|
+
function Xt(e) {
|
|
1095
|
+
let t = b(e);
|
|
1096
|
+
if (!t) return "";
|
|
1097
|
+
let n = t.startContainer, r = S(n) ? n : n.parentElement;
|
|
1098
|
+
return r ? (getComputedStyle(r).fontFamily || "").split(",")[0].replace(/["']/g, "").trim() : "";
|
|
1099
|
+
}
|
|
1100
|
+
//#endregion
|
|
1101
|
+
//#region src/js/editing/Style.js
|
|
1102
|
+
var Zt = [
|
|
1103
|
+
"10px",
|
|
1104
|
+
"13px",
|
|
1105
|
+
"16px",
|
|
1106
|
+
"18px",
|
|
1107
|
+
"24px",
|
|
1108
|
+
"32px",
|
|
1109
|
+
"48px"
|
|
1110
|
+
], Qt = {
|
|
1111
|
+
bold: () => k("bold"),
|
|
1112
|
+
italic: () => k("italic"),
|
|
1113
|
+
underline: () => k("underline"),
|
|
1114
|
+
strikeThrough: () => k("strikethrough"),
|
|
1115
|
+
superscript: () => k("superscript"),
|
|
1116
|
+
subscript: () => k("subscript"),
|
|
1117
|
+
foreColor: (e) => A("color", String(e)),
|
|
1118
|
+
hiliteColor: (e) => A("background-color", String(e)),
|
|
1119
|
+
backColor: (e) => A("background-color", String(e)),
|
|
1120
|
+
fontName: (e) => A("font-family", String(e)),
|
|
1121
|
+
fontSize: (e) => A("font-size", /^[1-7]$/.test(String(e)) ? Zt[Number(e) - 1] : String(e)),
|
|
1122
|
+
formatBlock: (e) => Pt(String(e)),
|
|
1123
|
+
justifyLeft: () => M("left"),
|
|
1124
|
+
justifyCenter: () => M("center"),
|
|
1125
|
+
justifyRight: () => M("right"),
|
|
1126
|
+
justifyFull: () => M("justify"),
|
|
1127
|
+
indent: () => hn(),
|
|
1128
|
+
outdent: () => _n(),
|
|
1129
|
+
insertUnorderedList: () => xn(),
|
|
1130
|
+
insertOrderedList: () => Sn(),
|
|
1131
|
+
createLink: (e) => Et(String(e)).length > 0,
|
|
1132
|
+
unlink: () => Dt(),
|
|
1133
|
+
removeFormat: () => Tt(),
|
|
1134
|
+
insertHTML: (e) => Ie(String(e ?? "")),
|
|
1135
|
+
insertText: (e) => Le(String(e ?? "")),
|
|
1136
|
+
insertLineBreak: () => Re(),
|
|
1137
|
+
insertHorizontalRule: () => Be()
|
|
1138
|
+
};
|
|
1139
|
+
function P(e, t = null) {
|
|
1140
|
+
let n = Qt[e];
|
|
1141
|
+
return n ? n(t) !== !1 : (console.warn(`[AutumnNote] execCommand: unsupported command "${e}".`), !1);
|
|
1142
|
+
}
|
|
1143
|
+
var $t = () => k("bold"), en = () => k("italic"), tn = () => k("underline"), nn = () => k("strikethrough"), rn = () => k("superscript"), an = () => k("subscript"), on = (e) => A("color", e), sn = (e) => A("background-color", e), cn = (e) => A("font-family", e);
|
|
1144
|
+
function ln(e, t = document) {
|
|
1145
|
+
A("font-size", e, t instanceof HTMLElement ? t : void 0);
|
|
1146
|
+
}
|
|
1147
|
+
var un = (e) => Pt(e), dn = () => M("left"), fn = () => M("center"), pn = () => M("right"), mn = () => M("justify");
|
|
1148
|
+
function hn() {
|
|
1149
|
+
Kt(), xe(gn());
|
|
1150
|
+
}
|
|
1151
|
+
function gn() {
|
|
420
1152
|
let e = globalThis.getSelection();
|
|
421
1153
|
if (!e?.rangeCount) return null;
|
|
422
1154
|
let t = e.getRangeAt(0).commonAncestorContainer;
|
|
@@ -425,39 +1157,20 @@ function rt() {
|
|
|
425
1157
|
for (let e = t; e; e = e.parentElement) (e.nodeName === "UL" || e.nodeName === "OL") && (n = e);
|
|
426
1158
|
return n;
|
|
427
1159
|
}
|
|
428
|
-
function
|
|
1160
|
+
function _n() {
|
|
429
1161
|
let e = globalThis.getSelection();
|
|
430
1162
|
if (e?.rangeCount) {
|
|
431
1163
|
let t = e.getRangeAt(0).commonAncestorContainer;
|
|
432
1164
|
t.nodeType === 3 && (t = t.parentElement);
|
|
433
1165
|
let n = t?.closest(".an-checklist li");
|
|
434
|
-
if (n) {
|
|
435
|
-
|
|
1166
|
+
if (n && !n.parentElement?.closest("li")) {
|
|
1167
|
+
vn(n);
|
|
436
1168
|
return;
|
|
437
1169
|
}
|
|
438
1170
|
}
|
|
439
|
-
|
|
1171
|
+
qt();
|
|
440
1172
|
}
|
|
441
|
-
function
|
|
442
|
-
let e = globalThis.getSelection();
|
|
443
|
-
if (!e?.rangeCount) return !1;
|
|
444
|
-
let t = e.getRangeAt(0).startContainer;
|
|
445
|
-
t.nodeType === 3 && (t = t.parentElement);
|
|
446
|
-
let n = t?.closest?.("li");
|
|
447
|
-
if (!n) return !1;
|
|
448
|
-
let r = n.parentElement;
|
|
449
|
-
if (!r || r.nodeName !== "UL" && r.nodeName !== "OL") return !1;
|
|
450
|
-
let i = r.parentElement;
|
|
451
|
-
if (!i || i.nodeName !== "LI" || !i.parentNode) return !1;
|
|
452
|
-
let a = [];
|
|
453
|
-
for (let e = n.nextElementSibling; e; e = e.nextElementSibling) a.push(e);
|
|
454
|
-
if (a.length) {
|
|
455
|
-
let e = n.ownerDocument.createElement(r.nodeName.toLowerCase());
|
|
456
|
-
a.forEach((t) => e.appendChild(t)), n.appendChild(e);
|
|
457
|
-
}
|
|
458
|
-
return i.parentNode.insertBefore(n, i.nextSibling), r.children.length || r.remove(), !0;
|
|
459
|
-
}
|
|
460
|
-
function ot(e) {
|
|
1173
|
+
function vn(e) {
|
|
461
1174
|
let t = e.closest(".an-checklist");
|
|
462
1175
|
if (!t) return;
|
|
463
1176
|
let n = Array.from(t.children), r = n.indexOf(e), i = n.slice(r + 1), a = document.createElement("p");
|
|
@@ -474,24 +1187,24 @@ function ot(e) {
|
|
|
474
1187
|
n && (n.removeAllRanges(), n.addRange(e));
|
|
475
1188
|
} catch {}
|
|
476
1189
|
}
|
|
477
|
-
function
|
|
1190
|
+
function yn() {
|
|
478
1191
|
let e = globalThis.getSelection();
|
|
479
1192
|
if (!e?.rangeCount) return null;
|
|
480
1193
|
let t = e.getRangeAt(0).commonAncestorContainer;
|
|
481
1194
|
return t.nodeType === 3 && (t = t.parentElement), t?.closest("ul, ol") || null;
|
|
482
1195
|
}
|
|
483
|
-
function
|
|
1196
|
+
function bn(e) {
|
|
484
1197
|
e.classList.remove("an-checklist"), e.querySelectorAll("input[type=\"checkbox\"]").forEach((e) => e.remove());
|
|
485
1198
|
}
|
|
486
|
-
function
|
|
487
|
-
let e =
|
|
488
|
-
e ? e.classList.contains("an-checklist") ? (
|
|
1199
|
+
function xn() {
|
|
1200
|
+
let e = yn();
|
|
1201
|
+
e ? e.classList.contains("an-checklist") ? (bn(e), e.tagName === "OL" && N("ul")) : (e.tagName, N("ul")) : N("ul");
|
|
489
1202
|
}
|
|
490
|
-
function
|
|
491
|
-
let e =
|
|
492
|
-
e ? e.classList.contains("an-checklist") ? (
|
|
1203
|
+
function Sn() {
|
|
1204
|
+
let e = yn();
|
|
1205
|
+
e ? e.classList.contains("an-checklist") ? (bn(e), e.tagName === "UL" && N("ol")) : (e.tagName, N("ol")) : N("ol");
|
|
493
1206
|
}
|
|
494
|
-
function
|
|
1207
|
+
function Cn(e) {
|
|
495
1208
|
let t = globalThis.getSelection();
|
|
496
1209
|
if (!t || t.rangeCount === 0) return;
|
|
497
1210
|
let n = t.getRangeAt(0), r = /* @__PURE__ */ new Set([
|
|
@@ -534,7 +1247,7 @@ function dt(e) {
|
|
|
534
1247
|
t.style.lineHeight = e;
|
|
535
1248
|
});
|
|
536
1249
|
}
|
|
537
|
-
function
|
|
1250
|
+
function wn(e) {
|
|
538
1251
|
let t = globalThis.getSelection();
|
|
539
1252
|
if (!t?.rangeCount) return;
|
|
540
1253
|
let n = t.getRangeAt(0), r = n.commonAncestorContainer;
|
|
@@ -566,7 +1279,7 @@ function ft(e) {
|
|
|
566
1279
|
}
|
|
567
1280
|
}
|
|
568
1281
|
}
|
|
569
|
-
function
|
|
1282
|
+
function Tn() {
|
|
570
1283
|
let e = globalThis.getSelection();
|
|
571
1284
|
if (!e?.rangeCount) return !1;
|
|
572
1285
|
let t = e.getRangeAt(0).startContainer;
|
|
@@ -574,13 +1287,13 @@ function pt() {
|
|
|
574
1287
|
let n = t?.closest("code");
|
|
575
1288
|
return !!(n && !n.closest("pre"));
|
|
576
1289
|
}
|
|
577
|
-
function
|
|
1290
|
+
function En(e, t) {
|
|
578
1291
|
let n = document.createElement(t);
|
|
579
1292
|
for (let t of e.attributes) n.setAttribute(t.name, t.value);
|
|
580
1293
|
for (; e.firstChild;) n.appendChild(e.firstChild);
|
|
581
1294
|
return e.parentNode.replaceChild(n, e), n;
|
|
582
1295
|
}
|
|
583
|
-
function
|
|
1296
|
+
function Dn(e) {
|
|
584
1297
|
e.querySelectorAll("li").forEach((e) => {
|
|
585
1298
|
if (!e.querySelector("input[type=\"checkbox\"]")) {
|
|
586
1299
|
let t = document.createElement("input");
|
|
@@ -588,7 +1301,7 @@ function mt(e) {
|
|
|
588
1301
|
}
|
|
589
1302
|
});
|
|
590
1303
|
}
|
|
591
|
-
function
|
|
1304
|
+
function On() {
|
|
592
1305
|
let e = globalThis.getSelection();
|
|
593
1306
|
if (!e?.rangeCount) return;
|
|
594
1307
|
let t = e.getRangeAt(0), n = t.commonAncestorContainer;
|
|
@@ -608,8 +1321,8 @@ function ht() {
|
|
|
608
1321
|
}
|
|
609
1322
|
}
|
|
610
1323
|
} else {
|
|
611
|
-
let t =
|
|
612
|
-
t.classList.add("an-checklist"),
|
|
1324
|
+
let t = En(r, "ul");
|
|
1325
|
+
t.classList.add("an-checklist"), Dn(t);
|
|
613
1326
|
let n = t.querySelector("li");
|
|
614
1327
|
if (n) {
|
|
615
1328
|
let t = document.createRange();
|
|
@@ -682,7 +1395,7 @@ function ht() {
|
|
|
682
1395
|
}
|
|
683
1396
|
}
|
|
684
1397
|
}
|
|
685
|
-
function
|
|
1398
|
+
function kn() {
|
|
686
1399
|
let e = globalThis.getSelection();
|
|
687
1400
|
if (!e?.rangeCount) return !1;
|
|
688
1401
|
let t = e.getRangeAt(0).commonAncestorContainer;
|
|
@@ -690,7 +1403,7 @@ function gt() {
|
|
|
690
1403
|
}
|
|
691
1404
|
//#endregion
|
|
692
1405
|
//#region src/js/module/Buttons.js
|
|
693
|
-
function
|
|
1406
|
+
function F(e, t, n, r, i, a) {
|
|
694
1407
|
return {
|
|
695
1408
|
name: e,
|
|
696
1409
|
icon: t,
|
|
@@ -700,22 +1413,22 @@ function T(e, t, n, r, i, a) {
|
|
|
700
1413
|
isDisabled: a
|
|
701
1414
|
};
|
|
702
1415
|
}
|
|
703
|
-
var
|
|
704
|
-
function
|
|
1416
|
+
var An = /* @__PURE__ */ new Map();
|
|
1417
|
+
function jn(e) {
|
|
705
1418
|
if (!e || typeof e.name != "string") {
|
|
706
1419
|
console.warn("[AutumnNote] registerButton: btnDef must have a string `name` property.");
|
|
707
1420
|
return;
|
|
708
1421
|
}
|
|
709
|
-
|
|
1422
|
+
An.has(e.name) && console.warn(`[AutumnNote] registerButton: overwriting existing button "${e.name}".`), An.set(e.name, e);
|
|
710
1423
|
}
|
|
711
|
-
function
|
|
712
|
-
return
|
|
1424
|
+
function Mn(e) {
|
|
1425
|
+
return An.get(e) ?? Pn().get(e);
|
|
713
1426
|
}
|
|
714
|
-
var
|
|
715
|
-
function
|
|
716
|
-
return
|
|
1427
|
+
var Nn = null;
|
|
1428
|
+
function Pn() {
|
|
1429
|
+
return Nn ??= new Map(Object.values(kr).filter((e) => e && !Array.isArray(e) && typeof e.name == "string").map((e) => [e.name, e])), Nn;
|
|
717
1430
|
}
|
|
718
|
-
function
|
|
1431
|
+
function Fn(e, t) {
|
|
719
1432
|
let n = t?.buttons;
|
|
720
1433
|
if (Array.isArray(n)) {
|
|
721
1434
|
let t = n.find((t) => t?.name === e);
|
|
@@ -724,30 +1437,30 @@ function bt(e, t) {
|
|
|
724
1437
|
name: e,
|
|
725
1438
|
...n[e]
|
|
726
1439
|
};
|
|
727
|
-
return
|
|
1440
|
+
return Mn(e);
|
|
728
1441
|
}
|
|
729
|
-
var
|
|
730
|
-
function
|
|
1442
|
+
var In = /* @__PURE__ */ new Map();
|
|
1443
|
+
function Ln(e, t) {
|
|
731
1444
|
if (typeof e != "string" || typeof t != "string") {
|
|
732
1445
|
console.warn("[AutumnNote] registerIcon: name and icon must be strings.");
|
|
733
1446
|
return;
|
|
734
1447
|
}
|
|
735
|
-
|
|
1448
|
+
In.set(e, t);
|
|
736
1449
|
}
|
|
737
|
-
function
|
|
1450
|
+
function Rn(e) {
|
|
738
1451
|
let t = e.trim();
|
|
739
1452
|
return t.startsWith("<") ? t : `<i class="${t.replace(/["<>&]/g, "")}" aria-hidden="true"></i>`;
|
|
740
1453
|
}
|
|
741
|
-
function
|
|
1454
|
+
function zn(e, t) {
|
|
742
1455
|
let n = e?.icons;
|
|
743
1456
|
for (let e of t) {
|
|
744
1457
|
if (!e) continue;
|
|
745
|
-
let t = n && typeof n[e] == "string" ? n[e] :
|
|
746
|
-
if (typeof t == "string" && t.trim()) return
|
|
1458
|
+
let t = n && typeof n[e] == "string" ? n[e] : In.get(e);
|
|
1459
|
+
if (typeof t == "string" && t.trim()) return Rn(t);
|
|
747
1460
|
}
|
|
748
1461
|
return null;
|
|
749
1462
|
}
|
|
750
|
-
var
|
|
1463
|
+
var Bn = [
|
|
751
1464
|
"8px",
|
|
752
1465
|
"10px",
|
|
753
1466
|
"11px",
|
|
@@ -763,7 +1476,7 @@ var wt = [
|
|
|
763
1476
|
"36px",
|
|
764
1477
|
"48px",
|
|
765
1478
|
"72px"
|
|
766
|
-
],
|
|
1479
|
+
], Vn = [
|
|
767
1480
|
"1.0",
|
|
768
1481
|
"1.15",
|
|
769
1482
|
"1.5",
|
|
@@ -771,7 +1484,7 @@ var wt = [
|
|
|
771
1484
|
"2.0",
|
|
772
1485
|
"2.5",
|
|
773
1486
|
"3.0"
|
|
774
|
-
],
|
|
1487
|
+
], Hn = [
|
|
775
1488
|
{
|
|
776
1489
|
value: "p",
|
|
777
1490
|
label: "Normal"
|
|
@@ -808,13 +1521,7 @@ var wt = [
|
|
|
808
1521
|
value: "pre",
|
|
809
1522
|
label: "Code"
|
|
810
1523
|
}
|
|
811
|
-
],
|
|
812
|
-
if (document.queryCommandState("underline")) return !0;
|
|
813
|
-
let e = globalThis.getSelection();
|
|
814
|
-
if (!e?.rangeCount) return !1;
|
|
815
|
-
let t = e.getRangeAt(0).startContainer;
|
|
816
|
-
return t.nodeType === 3 && (t = t.parentElement), !!t?.closest("u");
|
|
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 = {
|
|
1524
|
+
], I = (e) => (t) => _t(e, t?.layoutInfo?.editable), Un = F("bold", "bold", "Bold (Ctrl+B)", () => $t(), I("bold")), Wn = F("italic", "italic", "Italic (Ctrl+I)", () => en(), I("italic")), Gn = F("underline", "underline", "Underline (Ctrl+U)", () => tn(), I("underline")), Kn = F("strikethrough", "strikethrough", "Strikethrough", () => nn(), I("strikethrough")), qn = F("superscript", "superscript", "Superscript", () => rn(), I("superscript")), Jn = F("subscript", "subscript", "Subscript", () => an(), I("subscript")), Yn = F("alignLeft", "align-left", "Align Left", () => dn()), Xn = F("alignCenter", "align-center", "Align Center", () => fn()), Zn = F("alignRight", "align-right", "Align Right", () => pn()), Qn = F("alignJustify", "align-justify", "Justify", () => mn()), $n = F("ul", "list-ul", "Unordered List", () => xn()), er = F("ol", "list-ol", "Ordered List", () => Sn()), tr = F("indent", "indent", "Indent", () => hn()), nr = F("outdent", "outdent", "Outdent", () => _n()), rr = F("undo", "undo", "Undo (Ctrl+Z)", (e) => e.invoke("editor.undo"), void 0, (e) => !e.invoke("editor.canUndo")), ir = F("redo", "redo", "Redo (Ctrl+Y)", (e) => e.invoke("editor.redo"), void 0, (e) => !e.invoke("editor.canRedo")), ar = F("hr", "minus", "Horizontal Rule", () => P("insertHorizontalRule")), or = F("link", "link", "Insert Link", (e) => e.invoke("linkDialog.show")), sr = F("image", "image", "Insert Image", (e) => e.invoke("imageDialog.show")), cr = F("video", "video", "Insert Video", (e) => e.invoke("videoDialog.show")), lr = F("emoji", "emoji", "Insert Emoji", (e) => e.invoke("emojiDialog.show")), ur = F("icon", "icon", "Insert FA Icon", (e) => e.invoke("iconDialog.show")), dr = {
|
|
818
1525
|
name: "table",
|
|
819
1526
|
type: "grid",
|
|
820
1527
|
icon: "table",
|
|
@@ -822,14 +1529,14 @@ var wt = [
|
|
|
822
1529
|
action: (e, t, n) => {
|
|
823
1530
|
e.invoke("editor.insertTable", n, t), e.invoke("editor.afterCommand");
|
|
824
1531
|
}
|
|
825
|
-
},
|
|
1532
|
+
}, fr = {
|
|
826
1533
|
name: "fontSize",
|
|
827
1534
|
type: "select",
|
|
828
1535
|
tooltip: "Font Size",
|
|
829
1536
|
placeholder: "Size",
|
|
830
1537
|
selectClass: "an-select-narrow",
|
|
831
|
-
items:
|
|
832
|
-
action: (e, t) =>
|
|
1538
|
+
items: Bn,
|
|
1539
|
+
action: (e, t) => ln(t, e.layoutInfo.editable),
|
|
833
1540
|
getValue: (e) => {
|
|
834
1541
|
try {
|
|
835
1542
|
let t = globalThis.getSelection();
|
|
@@ -845,45 +1552,35 @@ var wt = [
|
|
|
845
1552
|
return "";
|
|
846
1553
|
}
|
|
847
1554
|
}
|
|
848
|
-
},
|
|
1555
|
+
}, pr = F("removeFormat", "remove-format", "Remove Format", () => P("removeFormat")), mr = F("direction", "direction", "Toggle Text Direction (LTR / RTL)", (e) => {
|
|
849
1556
|
let t = e.layoutInfo.editable, n = (t.getAttribute("dir") || "ltr") === "ltr" ? "rtl" : "ltr";
|
|
850
1557
|
t.setAttribute("dir", n), t.style.textAlign = n === "rtl" ? "right" : "left", e.invoke("editor.afterCommand");
|
|
851
|
-
}),
|
|
1558
|
+
}), hr = {
|
|
852
1559
|
name: "fontFamily",
|
|
853
1560
|
type: "select",
|
|
854
1561
|
tooltip: "Font Family",
|
|
855
|
-
action: (e, t) =>
|
|
856
|
-
getValue: () =>
|
|
857
|
-
|
|
858
|
-
return document.queryCommandValue("fontName") || "";
|
|
859
|
-
} catch {
|
|
860
|
-
return "";
|
|
861
|
-
}
|
|
862
|
-
}
|
|
863
|
-
}, en = {
|
|
1562
|
+
action: (e, t) => cn(t),
|
|
1563
|
+
getValue: (e) => Xt(e?.layoutInfo?.editable)
|
|
1564
|
+
}, gr = {
|
|
864
1565
|
name: "paragraphStyle",
|
|
865
1566
|
type: "select",
|
|
866
1567
|
tooltip: "Paragraph Style",
|
|
867
1568
|
placeholder: "Style",
|
|
868
1569
|
selectClass: "an-select-style",
|
|
869
|
-
items:
|
|
870
|
-
action: (e, t) =>
|
|
871
|
-
getValue: () => {
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
return e === "div" ? "p" : e || "p";
|
|
875
|
-
} catch {
|
|
876
|
-
return "";
|
|
877
|
-
}
|
|
1570
|
+
items: Hn,
|
|
1571
|
+
action: (e, t) => un(t),
|
|
1572
|
+
getValue: (e) => {
|
|
1573
|
+
let t = Yt(e?.layoutInfo?.editable);
|
|
1574
|
+
return t === "div" ? "p" : t;
|
|
878
1575
|
}
|
|
879
|
-
},
|
|
1576
|
+
}, _r = {
|
|
880
1577
|
name: "lineHeight",
|
|
881
1578
|
type: "select",
|
|
882
1579
|
tooltip: "Line Height",
|
|
883
1580
|
placeholder: "↕ Line",
|
|
884
1581
|
selectClass: "an-select-narrow",
|
|
885
|
-
items:
|
|
886
|
-
action: (e, t) =>
|
|
1582
|
+
items: Vn,
|
|
1583
|
+
action: (e, t) => Cn(t),
|
|
887
1584
|
getValue: () => {
|
|
888
1585
|
try {
|
|
889
1586
|
let e = globalThis.getSelection();
|
|
@@ -909,109 +1606,109 @@ var wt = [
|
|
|
909
1606
|
return "";
|
|
910
1607
|
}
|
|
911
1608
|
}
|
|
912
|
-
},
|
|
1609
|
+
}, vr = F("codeview", "code", "HTML Code View", (e) => e.invoke("codeview.toggle"), (e) => e.invoke("codeview.isActive")), yr = F("fullscreen", "expand", "Fullscreen", (e) => e.invoke("fullscreen.toggle"), (e) => e.invoke("fullscreen.isActive")), br = F("shortcuts", "keyboard", "Keyboard Shortcuts (Ctrl+Shift+/)", (e) => e.invoke("shortcutsDialog.show")), xr = F("find", "search", "Find (Ctrl+F)", (e) => e.invoke("findReplace.show", "find")), Sr = F("findReplace", "find-replace", "Find & Replace (Ctrl+H)", (e) => e.invoke("findReplace.show", "replace")), Cr = F("inlineCode", "inline-code", "Inline Code (Ctrl+`)", (e) => e.invoke("editor.inlineCode"), () => Tn()), wr = F("checklist", "checklist", "Checklist", (e) => e.invoke("editor.toggleChecklist"), () => kn()), Tr = F("print", "print", "Print", (e) => e.invoke("editor.print")), Er = {
|
|
913
1610
|
name: "foreColor",
|
|
914
1611
|
type: "colorpicker",
|
|
915
1612
|
icon: "foreColor",
|
|
916
1613
|
tooltip: "Text Color",
|
|
917
1614
|
defaultColor: "#e11d48",
|
|
918
|
-
action: (e, t) =>
|
|
919
|
-
},
|
|
1615
|
+
action: (e, t) => on(t)
|
|
1616
|
+
}, Dr = {
|
|
920
1617
|
name: "backColor",
|
|
921
1618
|
type: "colorpicker",
|
|
922
1619
|
icon: "backColor",
|
|
923
1620
|
tooltip: "Highlight Color",
|
|
924
1621
|
defaultColor: "#fbbf24",
|
|
925
|
-
action: (e, t) =>
|
|
926
|
-
},
|
|
1622
|
+
action: (e, t) => sn(t)
|
|
1623
|
+
}, Or = [
|
|
927
1624
|
[
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
1625
|
+
gr,
|
|
1626
|
+
hr,
|
|
1627
|
+
fr,
|
|
1628
|
+
_r
|
|
932
1629
|
],
|
|
933
|
-
[
|
|
1630
|
+
[rr, ir],
|
|
934
1631
|
[
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
1632
|
+
Un,
|
|
1633
|
+
Wn,
|
|
1634
|
+
Gn,
|
|
1635
|
+
Kn,
|
|
1636
|
+
Cr
|
|
940
1637
|
],
|
|
941
|
-
[
|
|
942
|
-
[
|
|
1638
|
+
[qn, Jn],
|
|
1639
|
+
[Er, Dr],
|
|
943
1640
|
[
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
1641
|
+
Yn,
|
|
1642
|
+
Xn,
|
|
1643
|
+
Zn,
|
|
1644
|
+
Qn
|
|
948
1645
|
],
|
|
949
1646
|
[
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
1647
|
+
$n,
|
|
1648
|
+
er,
|
|
1649
|
+
wr,
|
|
1650
|
+
tr,
|
|
1651
|
+
nr
|
|
955
1652
|
],
|
|
956
1653
|
[
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
1654
|
+
ar,
|
|
1655
|
+
or,
|
|
1656
|
+
sr,
|
|
1657
|
+
cr,
|
|
1658
|
+
dr,
|
|
1659
|
+
lr,
|
|
1660
|
+
ur
|
|
964
1661
|
],
|
|
965
1662
|
[
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
1663
|
+
pr,
|
|
1664
|
+
vr,
|
|
1665
|
+
yr,
|
|
1666
|
+
xr,
|
|
1667
|
+
Tr,
|
|
1668
|
+
br
|
|
972
1669
|
]
|
|
973
|
-
],
|
|
974
|
-
boldBtn:
|
|
975
|
-
italicBtn:
|
|
976
|
-
underlineBtn:
|
|
977
|
-
strikeBtn:
|
|
978
|
-
superscriptBtn:
|
|
979
|
-
subscriptBtn:
|
|
980
|
-
alignLeftBtn:
|
|
981
|
-
alignCenterBtn:
|
|
982
|
-
alignRightBtn:
|
|
983
|
-
alignJustifyBtn:
|
|
984
|
-
ulBtn:
|
|
985
|
-
olBtn:
|
|
986
|
-
indentBtn:
|
|
987
|
-
outdentBtn:
|
|
988
|
-
undoBtn:
|
|
989
|
-
redoBtn:
|
|
990
|
-
hrBtn:
|
|
991
|
-
linkBtn:
|
|
992
|
-
imageBtn:
|
|
993
|
-
videoBtn:
|
|
994
|
-
emojiBtn:
|
|
995
|
-
iconBtn:
|
|
996
|
-
tableBtn:
|
|
997
|
-
fontSizeBtn:
|
|
998
|
-
removeFormatBtn:
|
|
999
|
-
directionBtn:
|
|
1000
|
-
fontFamilyBtn:
|
|
1001
|
-
paragraphStyleBtn:
|
|
1002
|
-
lineHeightBtn:
|
|
1003
|
-
codeviewBtn:
|
|
1004
|
-
fullscreenBtn:
|
|
1005
|
-
shortcutsBtn:
|
|
1006
|
-
findBtn:
|
|
1007
|
-
findReplaceBtn:
|
|
1008
|
-
inlineCodeBtn:
|
|
1009
|
-
checklistBtn:
|
|
1010
|
-
printBtn:
|
|
1011
|
-
foreColorBtn:
|
|
1012
|
-
backColorBtn:
|
|
1013
|
-
defaultToolbar:
|
|
1014
|
-
},
|
|
1670
|
+
], kr = {
|
|
1671
|
+
boldBtn: Un,
|
|
1672
|
+
italicBtn: Wn,
|
|
1673
|
+
underlineBtn: Gn,
|
|
1674
|
+
strikeBtn: Kn,
|
|
1675
|
+
superscriptBtn: qn,
|
|
1676
|
+
subscriptBtn: Jn,
|
|
1677
|
+
alignLeftBtn: Yn,
|
|
1678
|
+
alignCenterBtn: Xn,
|
|
1679
|
+
alignRightBtn: Zn,
|
|
1680
|
+
alignJustifyBtn: Qn,
|
|
1681
|
+
ulBtn: $n,
|
|
1682
|
+
olBtn: er,
|
|
1683
|
+
indentBtn: tr,
|
|
1684
|
+
outdentBtn: nr,
|
|
1685
|
+
undoBtn: rr,
|
|
1686
|
+
redoBtn: ir,
|
|
1687
|
+
hrBtn: ar,
|
|
1688
|
+
linkBtn: or,
|
|
1689
|
+
imageBtn: sr,
|
|
1690
|
+
videoBtn: cr,
|
|
1691
|
+
emojiBtn: lr,
|
|
1692
|
+
iconBtn: ur,
|
|
1693
|
+
tableBtn: dr,
|
|
1694
|
+
fontSizeBtn: fr,
|
|
1695
|
+
removeFormatBtn: pr,
|
|
1696
|
+
directionBtn: mr,
|
|
1697
|
+
fontFamilyBtn: hr,
|
|
1698
|
+
paragraphStyleBtn: gr,
|
|
1699
|
+
lineHeightBtn: _r,
|
|
1700
|
+
codeviewBtn: vr,
|
|
1701
|
+
fullscreenBtn: yr,
|
|
1702
|
+
shortcutsBtn: br,
|
|
1703
|
+
findBtn: xr,
|
|
1704
|
+
findReplaceBtn: Sr,
|
|
1705
|
+
inlineCodeBtn: Cr,
|
|
1706
|
+
checklistBtn: wr,
|
|
1707
|
+
printBtn: Tr,
|
|
1708
|
+
foreColorBtn: Er,
|
|
1709
|
+
backColorBtn: Dr,
|
|
1710
|
+
defaultToolbar: Or
|
|
1711
|
+
}, L = {
|
|
1015
1712
|
placeholder: "",
|
|
1016
1713
|
height: 200,
|
|
1017
1714
|
minHeight: 100,
|
|
@@ -1019,7 +1716,7 @@ var wt = [
|
|
|
1019
1716
|
focus: !1,
|
|
1020
1717
|
resizable: !0,
|
|
1021
1718
|
statusbar: !0,
|
|
1022
|
-
toolbar:
|
|
1719
|
+
toolbar: Or,
|
|
1023
1720
|
useBootstrap: !1,
|
|
1024
1721
|
toolbarButtonClass: "btn btn-sm btn-light",
|
|
1025
1722
|
useFontAwesome: !0,
|
|
@@ -1054,9 +1751,9 @@ var wt = [
|
|
|
1054
1751
|
historyMaxBytes: 10485760,
|
|
1055
1752
|
defaultFontFamily: "Arial",
|
|
1056
1753
|
defaultFontSize: "14px",
|
|
1057
|
-
fontSizes: [...
|
|
1058
|
-
lineHeights: [...
|
|
1059
|
-
paragraphStyles:
|
|
1754
|
+
fontSizes: [...Bn],
|
|
1755
|
+
lineHeights: [...Vn],
|
|
1756
|
+
paragraphStyles: Hn.map((e) => ({ ...e })),
|
|
1060
1757
|
colorPalette: null,
|
|
1061
1758
|
icons: null,
|
|
1062
1759
|
buttons: null,
|
|
@@ -1125,7 +1822,7 @@ var wt = [
|
|
|
1125
1822
|
],
|
|
1126
1823
|
contextMenu: null,
|
|
1127
1824
|
mention: null
|
|
1128
|
-
},
|
|
1825
|
+
}, R = {
|
|
1129
1826
|
toolbar: {
|
|
1130
1827
|
bold: "Bold (Ctrl+B)",
|
|
1131
1828
|
italic: "Italic (Ctrl+I)",
|
|
@@ -1501,23 +2198,23 @@ var wt = [
|
|
|
1501
2198
|
table: "Table",
|
|
1502
2199
|
image: "Image"
|
|
1503
2200
|
}
|
|
1504
|
-
},
|
|
1505
|
-
function
|
|
2201
|
+
}, Ar = { en: R };
|
|
2202
|
+
function jr(e, t) {
|
|
1506
2203
|
if (typeof e != "string" || !e) throw TypeError("[AutumnNote] registerLocale: code must be a non-empty string.");
|
|
1507
2204
|
if (!t || typeof t != "object") throw TypeError(`[AutumnNote] registerLocale: locale for "${e}" must be an object.`);
|
|
1508
|
-
|
|
2205
|
+
Ar[e] = t;
|
|
1509
2206
|
}
|
|
1510
|
-
function
|
|
1511
|
-
if (!e || e === "en") return
|
|
2207
|
+
function Mr(e) {
|
|
2208
|
+
if (!e || e === "en") return R;
|
|
1512
2209
|
if (typeof e == "string") {
|
|
1513
|
-
let t =
|
|
1514
|
-
return t ? c(c({},
|
|
2210
|
+
let t = Ar[e];
|
|
2211
|
+
return t ? c(c({}, R), 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});`), R);
|
|
1515
2212
|
}
|
|
1516
|
-
return typeof e == "object" ? c(c({},
|
|
2213
|
+
return typeof e == "object" ? c(c({}, R), e) : R;
|
|
1517
2214
|
}
|
|
1518
2215
|
//#endregion
|
|
1519
2216
|
//#region src/js/core/sanitise.js
|
|
1520
|
-
var
|
|
2217
|
+
var Nr = [
|
|
1521
2218
|
"script",
|
|
1522
2219
|
"style",
|
|
1523
2220
|
"iframe",
|
|
@@ -1540,7 +2237,7 @@ var vn = [
|
|
|
1540
2237
|
"mglyph",
|
|
1541
2238
|
"malignmark",
|
|
1542
2239
|
"annotation-xml"
|
|
1543
|
-
],
|
|
2240
|
+
], Pr = /* @__PURE__ */ new Set(["button"]), Fr = [
|
|
1544
2241
|
"href",
|
|
1545
2242
|
"src",
|
|
1546
2243
|
"action",
|
|
@@ -1549,17 +2246,20 @@ var vn = [
|
|
|
1549
2246
|
"poster",
|
|
1550
2247
|
"background",
|
|
1551
2248
|
"srcset"
|
|
1552
|
-
],
|
|
2249
|
+
], Ir = /* @__PURE__ */ new Set([
|
|
1553
2250
|
"poster",
|
|
1554
2251
|
"background",
|
|
1555
2252
|
"srcset"
|
|
1556
|
-
]),
|
|
2253
|
+
]), Lr = /* @__PURE__ */ new Set(["ping"]), Rr = /* @__PURE__ */ new Set([
|
|
1557
2254
|
"color",
|
|
1558
2255
|
"background-color",
|
|
1559
2256
|
"font-size",
|
|
1560
2257
|
"line-height",
|
|
1561
2258
|
"text-align",
|
|
1562
2259
|
"vertical-align",
|
|
2260
|
+
"font-family",
|
|
2261
|
+
"margin-left",
|
|
2262
|
+
"margin-right",
|
|
1563
2263
|
"width",
|
|
1564
2264
|
"min-width",
|
|
1565
2265
|
"height",
|
|
@@ -1569,31 +2269,34 @@ var vn = [
|
|
|
1569
2269
|
"border-color",
|
|
1570
2270
|
"padding",
|
|
1571
2271
|
"white-space"
|
|
1572
|
-
]),
|
|
2272
|
+
]), zr = {
|
|
2273
|
+
"margin-left": /^(0|\d+(\.\d+)?(px|em|rem|%))$/,
|
|
2274
|
+
"margin-right": /^(0|\d+(\.\d+)?(px|em|rem|%))$/
|
|
2275
|
+
}, Br = /url\s*\(|image-set\s*\(|src\s*\(|expression\s*\(|@import|javascript:|vbscript:|behavior\s*:|-moz-binding/i, Vr = /* @__PURE__ */ new Set([
|
|
1573
2276
|
"www.youtube.com",
|
|
1574
2277
|
"youtube.com",
|
|
1575
2278
|
"m.youtube.com",
|
|
1576
2279
|
"www.youtube-nocookie.com",
|
|
1577
2280
|
"youtube-nocookie.com",
|
|
1578
2281
|
"player.vimeo.com"
|
|
1579
|
-
]),
|
|
2282
|
+
]), Hr = /* @__PURE__ */ new Set([
|
|
1580
2283
|
"http:",
|
|
1581
2284
|
"https:",
|
|
1582
2285
|
"mailto:",
|
|
1583
2286
|
"tel:"
|
|
1584
|
-
]),
|
|
2287
|
+
]), Ur = /* @__PURE__ */ new Set([
|
|
1585
2288
|
"http:",
|
|
1586
2289
|
"https:",
|
|
1587
2290
|
"blob:"
|
|
1588
|
-
]),
|
|
1589
|
-
function
|
|
1590
|
-
return
|
|
2291
|
+
]), Wr = /^data:image\/(?:png|jpe?g|gif|webp|avif|bmp);base64,[a-z0-9+/=\s]+$/i, Gr = "https://autumnnote.invalid/";
|
|
2292
|
+
function z(e, t) {
|
|
2293
|
+
return Kr(e, t).innerHTML;
|
|
1591
2294
|
}
|
|
1592
|
-
function
|
|
1593
|
-
let r = new DOMParser().parseFromString(`<body>${e || ""}</body>`, "text/html"), i =
|
|
2295
|
+
function Kr(e, { allowIframes: t = !1, iframeHosts: n = null } = {}) {
|
|
2296
|
+
let r = new DOMParser().parseFromString(`<body>${e || ""}</body>`, "text/html"), i = Yr(n), a = Array.from(r.querySelectorAll("*")), o = new Set(t ? Nr.filter((e) => e !== "iframe") : Nr);
|
|
1594
2297
|
for (let e of a) {
|
|
1595
2298
|
let t = e.tagName.toLowerCase();
|
|
1596
|
-
if (
|
|
2299
|
+
if (Pr.has(t)) {
|
|
1597
2300
|
e.replaceWith(...e.childNodes);
|
|
1598
2301
|
continue;
|
|
1599
2302
|
}
|
|
@@ -1603,7 +2306,7 @@ function An(e, { allowIframes: t = !1, iframeHosts: n = null } = {}) {
|
|
|
1603
2306
|
}
|
|
1604
2307
|
if (t === "iframe") {
|
|
1605
2308
|
let t = e.getAttribute("src");
|
|
1606
|
-
if (!t || !
|
|
2309
|
+
if (!t || !Xr(t, i)) {
|
|
1607
2310
|
e.remove();
|
|
1608
2311
|
continue;
|
|
1609
2312
|
}
|
|
@@ -1614,22 +2317,22 @@ function An(e, { allowIframes: t = !1, iframeHosts: n = null } = {}) {
|
|
|
1614
2317
|
continue;
|
|
1615
2318
|
}
|
|
1616
2319
|
if (t.name === "style") {
|
|
1617
|
-
let n =
|
|
2320
|
+
let n = qr(t.value);
|
|
1618
2321
|
n ? e.setAttribute("style", n) : e.removeAttribute("style");
|
|
1619
2322
|
continue;
|
|
1620
2323
|
}
|
|
1621
|
-
if (
|
|
2324
|
+
if (Lr.has(t.name)) {
|
|
1622
2325
|
e.removeAttribute(t.name);
|
|
1623
2326
|
continue;
|
|
1624
2327
|
}
|
|
1625
|
-
if (
|
|
1626
|
-
let n = t.value.trim(), r =
|
|
2328
|
+
if (Fr.includes(t.name)) {
|
|
2329
|
+
let n = t.value.trim(), r = Ir.has(t.name) || t.name === "src" && [
|
|
1627
2330
|
"IMG",
|
|
1628
2331
|
"VIDEO",
|
|
1629
2332
|
"AUDIO",
|
|
1630
2333
|
"SOURCE"
|
|
1631
2334
|
].includes(e.tagName), i = e.tagName === "IMG";
|
|
1632
|
-
if (!(t.name === "srcset" ?
|
|
2335
|
+
if (!(t.name === "srcset" ? Jr(n, { allowData: i }) : $r(n, {
|
|
1633
2336
|
media: r,
|
|
1634
2337
|
allowData: i
|
|
1635
2338
|
}))) {
|
|
@@ -1642,7 +2345,7 @@ function An(e, { allowIframes: t = !1, iframeHosts: n = null } = {}) {
|
|
|
1642
2345
|
e.removeAttribute(t.name);
|
|
1643
2346
|
continue;
|
|
1644
2347
|
}
|
|
1645
|
-
t.name === "src" && !
|
|
2348
|
+
t.name === "src" && !Xr(t.value, i) && e.removeAttribute(t.name);
|
|
1646
2349
|
}
|
|
1647
2350
|
}
|
|
1648
2351
|
if (t === "a" && e.getAttribute("target") === "_blank" && e.setAttribute("rel", "noopener noreferrer"), t === "input") {
|
|
@@ -1656,29 +2359,29 @@ function An(e, { allowIframes: t = !1, iframeHosts: n = null } = {}) {
|
|
|
1656
2359
|
}
|
|
1657
2360
|
return r.body;
|
|
1658
2361
|
}
|
|
1659
|
-
function
|
|
2362
|
+
function qr(e) {
|
|
1660
2363
|
let t = [];
|
|
1661
2364
|
for (let n of (e || "").split(";")) {
|
|
1662
2365
|
let e = n.indexOf(":");
|
|
1663
2366
|
if (e === -1) continue;
|
|
1664
2367
|
let r = n.slice(0, e).trim().toLowerCase(), i = n.slice(e + 1).trim();
|
|
1665
|
-
!r || !i ||
|
|
2368
|
+
!r || !i || Rr.has(r) && (Br.test(i) || i.includes("\\") || zr[r] && !zr[r].test(i) || t.push(`${r}: ${i}`));
|
|
1666
2369
|
}
|
|
1667
2370
|
return t.join("; ");
|
|
1668
2371
|
}
|
|
1669
|
-
function
|
|
2372
|
+
function Jr(e, { allowData: t = !1 } = {}) {
|
|
1670
2373
|
let n = (e || "").trim().split(/\s+/).filter(Boolean);
|
|
1671
2374
|
for (let e of n) {
|
|
1672
2375
|
if (/^[\d.]+[xw],?$/i.test(e)) continue;
|
|
1673
2376
|
let n = e.replace(/,+$/, "");
|
|
1674
|
-
if (n &&
|
|
2377
|
+
if (n && !$r(n, {
|
|
1675
2378
|
media: !0,
|
|
1676
2379
|
allowData: t
|
|
1677
2380
|
})) return !1;
|
|
1678
2381
|
}
|
|
1679
2382
|
return !0;
|
|
1680
2383
|
}
|
|
1681
|
-
function
|
|
2384
|
+
function Yr(e) {
|
|
1682
2385
|
let t = /* @__PURE__ */ new Set();
|
|
1683
2386
|
if (!e || typeof e[Symbol.iterator] != "function" || typeof e == "string") return t;
|
|
1684
2387
|
for (let n of e) {
|
|
@@ -1687,42 +2390,42 @@ function Nn(e) {
|
|
|
1687
2390
|
}
|
|
1688
2391
|
return t;
|
|
1689
2392
|
}
|
|
1690
|
-
function
|
|
2393
|
+
function Xr(e, t) {
|
|
1691
2394
|
let n = (e || "").trim();
|
|
1692
2395
|
if (!n || n.startsWith("//") || n.startsWith("/")) return !1;
|
|
1693
2396
|
try {
|
|
1694
2397
|
let e = new URL(n);
|
|
1695
2398
|
if (e.protocol !== "https:") return !1;
|
|
1696
2399
|
let r = e.hostname.toLowerCase();
|
|
1697
|
-
return
|
|
2400
|
+
return Vr.has(r) || !!t?.has(r);
|
|
1698
2401
|
} catch {
|
|
1699
2402
|
return !1;
|
|
1700
2403
|
}
|
|
1701
2404
|
}
|
|
1702
|
-
function
|
|
1703
|
-
return
|
|
2405
|
+
function Zr(e, t) {
|
|
2406
|
+
return Xr(e, Yr(t));
|
|
1704
2407
|
}
|
|
1705
|
-
function
|
|
2408
|
+
function Qr(e, { allowData: t = !1, media: n = t } = {}) {
|
|
1706
2409
|
let r = (e || "").trim();
|
|
1707
|
-
return !r && e == null ? null :
|
|
2410
|
+
return !r && e == null ? null : $r(r, {
|
|
1708
2411
|
media: n,
|
|
1709
2412
|
allowData: t
|
|
1710
2413
|
}) ? e : null;
|
|
1711
2414
|
}
|
|
1712
|
-
function
|
|
2415
|
+
function $r(e, { media: t = !1, allowData: n = !1 } = {}) {
|
|
1713
2416
|
let r = (e || "").trim();
|
|
1714
|
-
if (!r || n &&
|
|
2417
|
+
if (!r || n && Wr.test(r)) return !0;
|
|
1715
2418
|
try {
|
|
1716
|
-
let e = new URL(r,
|
|
1717
|
-
return (t ?
|
|
2419
|
+
let e = new URL(r, Gr);
|
|
2420
|
+
return (t ? Ur : Hr).has(e.protocol);
|
|
1718
2421
|
} catch {
|
|
1719
2422
|
return !1;
|
|
1720
2423
|
}
|
|
1721
2424
|
}
|
|
1722
2425
|
//#endregion
|
|
1723
2426
|
//#region src/js/renderer.js
|
|
1724
|
-
function
|
|
1725
|
-
let n =
|
|
2427
|
+
function ei(e, t) {
|
|
2428
|
+
let n = v("div", { class: "an-container" }), r = v("div", {
|
|
1726
2429
|
class: "an-editable",
|
|
1727
2430
|
contenteditable: t.readOnly ? "false" : "true",
|
|
1728
2431
|
spellcheck: String(t.spellcheck !== !1),
|
|
@@ -1733,30 +2436,30 @@ function Ln(e, t) {
|
|
|
1733
2436
|
if (t.autoSave && t.autoSaveKey) try {
|
|
1734
2437
|
i = localStorage.getItem(t.autoSaveKey) || "";
|
|
1735
2438
|
} catch {}
|
|
1736
|
-
i ||= e.tagName === "TEXTAREA" ? (e.value || "").trim() : (e.innerHTML || "").trim(), r.innerHTML =
|
|
2439
|
+
i ||= e.tagName === "TEXTAREA" ? (e.value || "").trim() : (e.innerHTML || "").trim(), r.innerHTML = z(i, {
|
|
1737
2440
|
allowIframes: !0,
|
|
1738
2441
|
iframeHosts: t.iframeHosts
|
|
1739
2442
|
});
|
|
1740
2443
|
let a = t.defaultFontFamily || t.fontFamilies?.[0];
|
|
1741
2444
|
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) => {
|
|
1742
2445
|
e.setAttribute("disabled", "");
|
|
1743
|
-
})), t.direction === "rtl" && (r.setAttribute("dir", "rtl"), n.classList.add("an-dir-rtl")),
|
|
2446
|
+
})), t.direction === "rtl" && (r.setAttribute("dir", "rtl"), n.classList.add("an-dir-rtl")), ai(n, null, t), e.style.display = "none", e.after(n), {
|
|
1744
2447
|
container: n,
|
|
1745
2448
|
editable: r
|
|
1746
2449
|
};
|
|
1747
2450
|
}
|
|
1748
|
-
var
|
|
1749
|
-
function
|
|
2451
|
+
var ti = ["an-theme-dark", "an-theme-auto"];
|
|
2452
|
+
function ni(e) {
|
|
1750
2453
|
return e.startsWith("--") ? e : `--an-${e}`;
|
|
1751
2454
|
}
|
|
1752
|
-
function
|
|
1753
|
-
let t =
|
|
2455
|
+
function ri(e) {
|
|
2456
|
+
let t = v("div", {
|
|
1754
2457
|
class: "an-portal",
|
|
1755
2458
|
"data-an-portal": ""
|
|
1756
2459
|
});
|
|
1757
|
-
return
|
|
2460
|
+
return ii(e.popupContainer).appendChild(t), t;
|
|
1758
2461
|
}
|
|
1759
|
-
function
|
|
2462
|
+
function ii(e) {
|
|
1760
2463
|
if (typeof e == "string" && e) {
|
|
1761
2464
|
let t = document.querySelector(e);
|
|
1762
2465
|
if (t) return t;
|
|
@@ -1764,13 +2467,13 @@ function Vn(e) {
|
|
|
1764
2467
|
} else if (e && typeof e.appendChild == "function") return e;
|
|
1765
2468
|
return document.body;
|
|
1766
2469
|
}
|
|
1767
|
-
function
|
|
2470
|
+
function ai(e, t, n) {
|
|
1768
2471
|
let r = t ? [e, t] : [e], i = n.theme === "dark" ? "an-theme-dark" : n.theme === "auto" ? "an-theme-auto" : null;
|
|
1769
2472
|
for (let e of r) {
|
|
1770
|
-
e.classList.remove(...
|
|
2473
|
+
e.classList.remove(...ti), i && e.classList.add(i);
|
|
1771
2474
|
for (let t of Array.from(e.style)) t.startsWith("--an-") && e.style.removeProperty(t);
|
|
1772
2475
|
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(
|
|
2476
|
+
if (t && typeof t == "object") for (let [n, r] of Object.entries(t)) (typeof r == "string" || typeof r == "number") && e.style.setProperty(ni(n), String(r));
|
|
1774
2477
|
n.focusColor && e.style.setProperty("--an-focus-color", n.focusColor);
|
|
1775
2478
|
let r = Number(n.zIndexOffset) || 0;
|
|
1776
2479
|
r && e.style.setProperty("--an-z-offset", String(Math.trunc(r)));
|
|
@@ -1779,11 +2482,11 @@ function Hn(e, t, n) {
|
|
|
1779
2482
|
}
|
|
1780
2483
|
//#endregion
|
|
1781
2484
|
//#region src/js/Context.js
|
|
1782
|
-
var
|
|
1783
|
-
function
|
|
1784
|
-
|
|
2485
|
+
var oi = /* @__PURE__ */ new Map(), si = [];
|
|
2486
|
+
function ci(e) {
|
|
2487
|
+
si = Array.isArray(e) ? e : [];
|
|
1785
2488
|
}
|
|
1786
|
-
var
|
|
2489
|
+
var li = [
|
|
1787
2490
|
"theme",
|
|
1788
2491
|
"themeVars",
|
|
1789
2492
|
"focusColor",
|
|
@@ -1791,7 +2494,7 @@ var Kn = [
|
|
|
1791
2494
|
"toolbarOverflow",
|
|
1792
2495
|
"stickyToolbar",
|
|
1793
2496
|
"stickyToolbarOffset"
|
|
1794
|
-
],
|
|
2497
|
+
], ui = [
|
|
1795
2498
|
"toolbar",
|
|
1796
2499
|
"useFontAwesome",
|
|
1797
2500
|
"fontAwesomeClass",
|
|
@@ -1805,15 +2508,15 @@ var Kn = [
|
|
|
1805
2508
|
"paragraphStyles",
|
|
1806
2509
|
"colorPalette",
|
|
1807
2510
|
"colorSwatches"
|
|
1808
|
-
],
|
|
2511
|
+
], di = ["lang"], B = /* @__PURE__ */ new Map(), fi = class {
|
|
1809
2512
|
constructor(e, t = {}) {
|
|
1810
|
-
this.targetEl = e, this.options = c(
|
|
2513
|
+
this.targetEl = e, this.options = c(L, t), this.locale = Mr(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;
|
|
1811
2514
|
}
|
|
1812
2515
|
initialize() {
|
|
1813
|
-
let { container: e, editable: t } =
|
|
2516
|
+
let { container: e, editable: t } = ei(this.targetEl, this.options);
|
|
1814
2517
|
this.layoutInfo.container = e, this.layoutInfo.editable = t, t.setAttribute("aria-label", this.locale.a11y?.editor || "Rich text editor");
|
|
1815
|
-
let n =
|
|
1816
|
-
this.layoutInfo.portal = n,
|
|
2518
|
+
let n = ri(this.options);
|
|
2519
|
+
this.layoutInfo.portal = n, ai(e, n, this.options), this._registerModules();
|
|
1817
2520
|
let r = this._modules.get("toolbar");
|
|
1818
2521
|
r?.el && (e.insertBefore(r.el, t), this.layoutInfo.toolbar = r.el);
|
|
1819
2522
|
let i = this._modules.get("statusbar");
|
|
@@ -1824,11 +2527,11 @@ var Kn = [
|
|
|
1824
2527
|
let n = new t(this);
|
|
1825
2528
|
this._modules.set(e, n), n.initialize();
|
|
1826
2529
|
};
|
|
1827
|
-
for (let { name: t, Class: n, enabled: r } of
|
|
1828
|
-
if (
|
|
2530
|
+
for (let { name: t, Class: n, enabled: r } of si) typeof r == "function" && !r(this.options) || e(t, n);
|
|
2531
|
+
if (oi.size > 0) for (let [t, n] of oi) e(t, n);
|
|
1829
2532
|
}
|
|
1830
2533
|
_syncOptionalModules() {
|
|
1831
|
-
for (let { name: e, Class: t, enabled: n } of
|
|
2534
|
+
for (let { name: e, Class: t, enabled: n } of si) {
|
|
1832
2535
|
if (typeof n != "function") continue;
|
|
1833
2536
|
let r = n(this.options);
|
|
1834
2537
|
if (r !== this._modules.has(e)) {
|
|
@@ -1853,7 +2556,7 @@ var Kn = [
|
|
|
1853
2556
|
return n >= 0 ? t[n] = e : t.push(e), this.invoke("slashMenu.refresh"), this;
|
|
1854
2557
|
}
|
|
1855
2558
|
use(e, t = {}) {
|
|
1856
|
-
return Array.isArray(e.buttons) && e.buttons.forEach((e) =>
|
|
2559
|
+
return Array.isArray(e.buttons) && e.buttons.forEach((e) => jn(e)), this._installPlugin(e, t), this;
|
|
1857
2560
|
}
|
|
1858
2561
|
getPlugin(e) {
|
|
1859
2562
|
return this._plugins.get(e)?.publicApi ?? null;
|
|
@@ -1875,12 +2578,12 @@ var Kn = [
|
|
|
1875
2578
|
});
|
|
1876
2579
|
}
|
|
1877
2580
|
_applyGlobalPlugins() {
|
|
1878
|
-
if (
|
|
2581
|
+
if (B.size !== 0) for (let { plugin: e, options: t } of B.values()) this._installPlugin(e, t);
|
|
1879
2582
|
}
|
|
1880
2583
|
_bindEditorEvents(e) {
|
|
1881
|
-
let t =
|
|
2584
|
+
let t = y(e, "input", () => this._syncToTarget()), n = y(e, "focus", () => {
|
|
1882
2585
|
this.layoutInfo.container.classList.add("an-focused"), this.triggerEvent("focus", this);
|
|
1883
|
-
}), r =
|
|
2586
|
+
}), r = y(e, "blur", () => {
|
|
1884
2587
|
this.layoutInfo.container.classList.remove("an-focused"), this._syncToTarget(), this.triggerEvent("blur", this);
|
|
1885
2588
|
}), i = this.on("change", (e) => this._syncToTarget(e)), a = this.on("change", (e) => {
|
|
1886
2589
|
if (this.options.blockIds && (this.ensureBlockIds(), e = this.getHTML()), e === this._suppressedRemoteHTML) {
|
|
@@ -1979,8 +2682,8 @@ var Kn = [
|
|
|
1979
2682
|
let e = this.options.height || this.options.minHeight || 0;
|
|
1980
2683
|
a.style.minHeight = e ? `${e}px` : "";
|
|
1981
2684
|
}
|
|
1982
|
-
Object.hasOwn(e, "maxHeight") && (a.style.maxHeight = this.options.maxHeight ? `${this.options.maxHeight}px` : ""),
|
|
1983
|
-
let o =
|
|
2685
|
+
Object.hasOwn(e, "maxHeight") && (a.style.maxHeight = this.options.maxHeight ? `${this.options.maxHeight}px` : ""), ui.some(r) && this.invoke("toolbar.rebuild"), li.some(r) && ai(i, this.layoutInfo.portal ?? null, this.options), r("popupContainer") && this.layoutInfo.portal && ii(this.options.popupContainer).appendChild(this.layoutInfo.portal), r("resizable") && this.invoke("statusbar.applyResizable");
|
|
2686
|
+
let o = di.filter(r);
|
|
1984
2687
|
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;
|
|
1985
2688
|
}
|
|
1986
2689
|
getHTML() {
|
|
@@ -2141,12 +2844,12 @@ var Kn = [
|
|
|
2141
2844
|
};
|
|
2142
2845
|
//#endregion
|
|
2143
2846
|
//#region src/js/editing/History.js
|
|
2144
|
-
function
|
|
2847
|
+
function pi(e, t) {
|
|
2145
2848
|
let n = Math.min(e.length, t.length), r = 0;
|
|
2146
2849
|
for (; r < n && e.charCodeAt(r) === t.charCodeAt(r);) r++;
|
|
2147
2850
|
return r;
|
|
2148
2851
|
}
|
|
2149
|
-
var
|
|
2852
|
+
var mi = class {
|
|
2150
2853
|
constructor(e, t = 100, n = 10485760) {
|
|
2151
2854
|
this.editable = e, this._limit = t, this._maxBytes = n, this._bytes = 0, this.stack = [], this.stackOffset = -1, this._savePoint();
|
|
2152
2855
|
}
|
|
@@ -2225,7 +2928,7 @@ var Zn = class {
|
|
|
2225
2928
|
this.editable.innerHTML = this._detokenizeImages(e);
|
|
2226
2929
|
let n = e.sel;
|
|
2227
2930
|
if (!n) {
|
|
2228
|
-
let e =
|
|
2931
|
+
let e = pi(t, this.editable.textContent || "");
|
|
2229
2932
|
n = {
|
|
2230
2933
|
start: e,
|
|
2231
2934
|
end: e
|
|
@@ -2278,31 +2981,31 @@ var Zn = class {
|
|
|
2278
2981
|
};
|
|
2279
2982
|
//#endregion
|
|
2280
2983
|
//#region src/js/editing/Table.js
|
|
2281
|
-
function
|
|
2282
|
-
let { headerRow: r = !1 } = n, i =
|
|
2984
|
+
function hi(e, t, n = {}) {
|
|
2985
|
+
let { headerRow: r = !1 } = n, i = v("table", { class: "an-table" });
|
|
2283
2986
|
if (r && t > 0) {
|
|
2284
|
-
let t =
|
|
2987
|
+
let t = v("thead"), n = v("tr");
|
|
2285
2988
|
for (let t = 0; t < e; t++) {
|
|
2286
|
-
let e =
|
|
2989
|
+
let e = v("th", {}, [document.createElement("br")]);
|
|
2287
2990
|
n.appendChild(e);
|
|
2288
2991
|
}
|
|
2289
2992
|
t.appendChild(n), i.appendChild(t);
|
|
2290
2993
|
}
|
|
2291
|
-
let a = r ? Math.max(t - 1, 1) : t, o =
|
|
2994
|
+
let a = r ? Math.max(t - 1, 1) : t, o = v("tbody");
|
|
2292
2995
|
i.appendChild(o);
|
|
2293
2996
|
for (let t = 0; t < a; t++) {
|
|
2294
|
-
let t =
|
|
2997
|
+
let t = v("tr");
|
|
2295
2998
|
for (let n = 0; n < e; n++) {
|
|
2296
|
-
let e =
|
|
2999
|
+
let e = v("td", {}, [document.createElement("br")]);
|
|
2297
3000
|
t.appendChild(e);
|
|
2298
3001
|
}
|
|
2299
3002
|
o.appendChild(t);
|
|
2300
3003
|
}
|
|
2301
3004
|
return i;
|
|
2302
3005
|
}
|
|
2303
|
-
function
|
|
3006
|
+
function gi(e, t, n = {}) {
|
|
2304
3007
|
if (e <= 0 || t <= 0) return;
|
|
2305
|
-
let r =
|
|
3008
|
+
let r = hi(e, t, n), i = globalThis.getSelection();
|
|
2306
3009
|
if (!i || i.rangeCount === 0) return;
|
|
2307
3010
|
let a = i.getRangeAt(0);
|
|
2308
3011
|
try {
|
|
@@ -2343,7 +3046,7 @@ function $n(e, t, n = {}) {
|
|
|
2343
3046
|
}
|
|
2344
3047
|
//#endregion
|
|
2345
3048
|
//#region src/js/core/keymap.js
|
|
2346
|
-
var
|
|
3049
|
+
var _i = Object.freeze({
|
|
2347
3050
|
"Mod+Z": "undo",
|
|
2348
3051
|
"Mod+Shift+Z": "redo",
|
|
2349
3052
|
"Mod+Y": "redo",
|
|
@@ -2356,7 +3059,7 @@ var er = Object.freeze({
|
|
|
2356
3059
|
"Mod+H": "findReplace",
|
|
2357
3060
|
"Mod+`": "inlineCode",
|
|
2358
3061
|
"Ctrl+Shift+/": "shortcuts"
|
|
2359
|
-
}),
|
|
3062
|
+
}), vi = {
|
|
2360
3063
|
Slash: "/",
|
|
2361
3064
|
Backslash: "\\",
|
|
2362
3065
|
Backquote: "`",
|
|
@@ -2370,7 +3073,7 @@ var er = Object.freeze({
|
|
|
2370
3073
|
Period: ".",
|
|
2371
3074
|
Space: " "
|
|
2372
3075
|
};
|
|
2373
|
-
function
|
|
3076
|
+
function yi(e) {
|
|
2374
3077
|
if (typeof e != "string") return null;
|
|
2375
3078
|
let t = e.trim().split(/\+(?!$)/).map((e) => e.trim()).filter(Boolean);
|
|
2376
3079
|
if (!t.length) return null;
|
|
@@ -2394,23 +3097,23 @@ function nr(e) {
|
|
|
2394
3097
|
}
|
|
2395
3098
|
return n.key ? n : null;
|
|
2396
3099
|
}
|
|
2397
|
-
function
|
|
3100
|
+
function bi(e, t) {
|
|
2398
3101
|
if (t.mod) {
|
|
2399
3102
|
if (!e.ctrlKey && !e.metaKey) return !1;
|
|
2400
3103
|
} else if (e.ctrlKey !== t.ctrl || e.metaKey !== t.meta) return !1;
|
|
2401
3104
|
if (e.altKey !== t.alt || e.shiftKey !== t.shift) return !1;
|
|
2402
3105
|
if ((e.key || "").toLowerCase() === t.key) return !0;
|
|
2403
|
-
let n = e.code || "", r =
|
|
3106
|
+
let n = e.code || "", r = vi[n];
|
|
2404
3107
|
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
3108
|
}
|
|
2406
|
-
function
|
|
3109
|
+
function xi(e) {
|
|
2407
3110
|
let t = /* @__PURE__ */ new Map(), n = (e, n) => {
|
|
2408
|
-
let r =
|
|
3111
|
+
let r = yi(e);
|
|
2409
3112
|
if (!r) {
|
|
2410
3113
|
console.warn(`[AutumnNote] keyMap: cannot parse shortcut "${e}".`);
|
|
2411
3114
|
return;
|
|
2412
3115
|
}
|
|
2413
|
-
let i =
|
|
3116
|
+
let i = Si(r);
|
|
2414
3117
|
if (n === !1 || n === null) {
|
|
2415
3118
|
t.set(i, null);
|
|
2416
3119
|
return;
|
|
@@ -2427,11 +3130,11 @@ function ir(e) {
|
|
|
2427
3130
|
description: o
|
|
2428
3131
|
});
|
|
2429
3132
|
};
|
|
2430
|
-
for (let [e, t] of Object.entries(
|
|
3133
|
+
for (let [e, t] of Object.entries(_i)) n(e, t);
|
|
2431
3134
|
if (e && typeof e == "object") for (let [t, r] of Object.entries(e)) n(t, r);
|
|
2432
3135
|
return [...t.values()].filter(Boolean);
|
|
2433
3136
|
}
|
|
2434
|
-
function
|
|
3137
|
+
function Si(e) {
|
|
2435
3138
|
return [
|
|
2436
3139
|
e.mod && "mod",
|
|
2437
3140
|
e.ctrl && "ctrl",
|
|
@@ -2443,7 +3146,7 @@ function ar(e) {
|
|
|
2443
3146
|
}
|
|
2444
3147
|
//#endregion
|
|
2445
3148
|
//#region src/js/core/key.js
|
|
2446
|
-
var
|
|
3149
|
+
var V = {
|
|
2447
3150
|
BACKSPACE: "Backspace",
|
|
2448
3151
|
TAB: "Tab",
|
|
2449
3152
|
ENTER: "Enter",
|
|
@@ -2482,27 +3185,27 @@ var P = {
|
|
|
2482
3185
|
SLASH: "/",
|
|
2483
3186
|
PERIOD: "."
|
|
2484
3187
|
};
|
|
2485
|
-
function
|
|
3188
|
+
function H(e, t) {
|
|
2486
3189
|
return e.key === t || e.key === t.toUpperCase();
|
|
2487
3190
|
}
|
|
2488
|
-
function
|
|
2489
|
-
return (e.ctrlKey || e.metaKey) &&
|
|
3191
|
+
function Ci(e, t) {
|
|
3192
|
+
return (e.ctrlKey || e.metaKey) && H(e, t);
|
|
2490
3193
|
}
|
|
2491
3194
|
//#endregion
|
|
2492
3195
|
//#region src/js/editing/Typing.js
|
|
2493
|
-
var
|
|
2494
|
-
function
|
|
3196
|
+
var wi = /\bfa-/, U = (e) => !!(e?.nodeName === "I" && wi.test(e.className || "")), Ti = (e) => !(e?.nodeType !== Node.TEXT_NODE || e.textContent !== "" && e.textContent !== "");
|
|
3197
|
+
function Ei(e, t, n) {
|
|
2495
3198
|
let r = (e?.nodeType === Node.ELEMENT_NODE ? e : e?.parentElement ?? null)?.closest("td, th") ?? null;
|
|
2496
3199
|
if (!r || !t.contains(r)) return !1;
|
|
2497
3200
|
let i = r.closest("table");
|
|
2498
3201
|
if (!i || !t.contains(i)) return !1;
|
|
2499
3202
|
let a = Array.from(i.querySelectorAll("td, th")), o = a[a.indexOf(r) + (n ? -1 : 1)];
|
|
2500
|
-
if (o) return
|
|
3203
|
+
if (o) return be(o), !0;
|
|
2501
3204
|
if (n) return !0;
|
|
2502
|
-
let s =
|
|
2503
|
-
return s &&
|
|
3205
|
+
let s = Di(r.closest("tr"))?.firstElementChild ?? null;
|
|
3206
|
+
return s && be(s), !0;
|
|
2504
3207
|
}
|
|
2505
|
-
function
|
|
3208
|
+
function Di(e) {
|
|
2506
3209
|
if (!e?.parentNode) return null;
|
|
2507
3210
|
let t = document.createElement("tr");
|
|
2508
3211
|
for (let n of e.cells) {
|
|
@@ -2511,7 +3214,7 @@ function lr(e) {
|
|
|
2511
3214
|
}
|
|
2512
3215
|
return e.parentNode.insertBefore(t, e.nextSibling), t;
|
|
2513
3216
|
}
|
|
2514
|
-
function
|
|
3217
|
+
function Oi(e, t) {
|
|
2515
3218
|
try {
|
|
2516
3219
|
let n = document.createRange();
|
|
2517
3220
|
return n.setStart(e.startContainer, e.startOffset), n.setEnd(t, t.childNodes.length), n.extractContents();
|
|
@@ -2519,21 +3222,21 @@ function ur(e, t) {
|
|
|
2519
3222
|
return document.createDocumentFragment();
|
|
2520
3223
|
}
|
|
2521
3224
|
}
|
|
2522
|
-
function
|
|
3225
|
+
function ki(e, t, n = {}) {
|
|
2523
3226
|
let r = (e) => {
|
|
2524
3227
|
let t = globalThis.getSelection();
|
|
2525
3228
|
if (!t) return !1;
|
|
2526
3229
|
let n = document.createRange();
|
|
2527
3230
|
return e(n), n.collapse(!0), t.removeAllRanges(), t.addRange(n), !0;
|
|
2528
3231
|
};
|
|
2529
|
-
if (
|
|
3232
|
+
if (H(e, V.BACKSPACE)) {
|
|
2530
3233
|
let t = globalThis.getSelection();
|
|
2531
3234
|
if (t?.rangeCount > 0) {
|
|
2532
3235
|
let n = t.getRangeAt(0);
|
|
2533
3236
|
if (n.collapsed && n.startContainer.nodeType === Node.TEXT_NODE) {
|
|
2534
3237
|
let r = n.startContainer;
|
|
2535
|
-
if (n.startOffset === 0 &&
|
|
2536
|
-
if (n.startOffset === 1 && r.textContent === "" &&
|
|
3238
|
+
if (n.startOffset === 0 && U(r.previousSibling)) return e.preventDefault(), r.previousSibling.remove(), !0;
|
|
3239
|
+
if (n.startOffset === 1 && r.textContent === "" && U(r.previousSibling)) {
|
|
2537
3240
|
e.preventDefault();
|
|
2538
3241
|
let n = r.parentNode, i = r.previousSibling, a = i.previousSibling;
|
|
2539
3242
|
i.remove(), r.remove();
|
|
@@ -2544,17 +3247,17 @@ function dr(e, t, n = {}) {
|
|
|
2544
3247
|
}
|
|
2545
3248
|
return !1;
|
|
2546
3249
|
}
|
|
2547
|
-
if (
|
|
3250
|
+
if (H(e, V.LEFT) || H(e, V.RIGHT)) {
|
|
2548
3251
|
let t = globalThis.getSelection();
|
|
2549
3252
|
if (!t || t.rangeCount === 0) return !1;
|
|
2550
3253
|
let n = t.getRangeAt(0);
|
|
2551
3254
|
if (!n.collapsed) return !1;
|
|
2552
|
-
let i = n.startContainer, a =
|
|
3255
|
+
let i = n.startContainer, a = H(e, V.LEFT);
|
|
2553
3256
|
if (i.nodeType === Node.TEXT_NODE) {
|
|
2554
3257
|
let t = i;
|
|
2555
|
-
if (a && n.startOffset === 1 && t.textContent === "" &&
|
|
2556
|
-
if (a && n.startOffset === 0 &&
|
|
2557
|
-
if (!a && n.startOffset === t.textContent.length &&
|
|
3258
|
+
if (a && n.startOffset === 1 && t.textContent === "" && U(t.previousSibling) || a && n.startOffset === 0 && U(t.previousSibling)) return e.preventDefault(), r((e) => e.setStartBefore(t.previousSibling));
|
|
3259
|
+
if (a && n.startOffset === 0 && Ti(t.previousSibling) && U(t.previousSibling.previousSibling)) return e.preventDefault(), r((e) => e.setStartBefore(t.previousSibling.previousSibling));
|
|
3260
|
+
if (!a && n.startOffset === t.textContent.length && U(t.nextSibling)) {
|
|
2558
3261
|
let n = t.nextSibling, i = n.nextSibling;
|
|
2559
3262
|
if (e.preventDefault(), i?.nodeType === Node.TEXT_NODE) {
|
|
2560
3263
|
let e = +!!(i.textContent || "").startsWith("");
|
|
@@ -2562,7 +3265,7 @@ function dr(e, t, n = {}) {
|
|
|
2562
3265
|
}
|
|
2563
3266
|
return r((e) => e.setStartAfter(n));
|
|
2564
3267
|
}
|
|
2565
|
-
if (!a && n.startOffset === t.textContent.length &&
|
|
3268
|
+
if (!a && n.startOffset === t.textContent.length && Ti(t.nextSibling) && U(t.nextSibling.nextSibling)) {
|
|
2566
3269
|
let n = t.nextSibling.nextSibling, i = n.nextSibling;
|
|
2567
3270
|
if (e.preventDefault(), i?.nodeType === Node.TEXT_NODE) {
|
|
2568
3271
|
let e = +!!(i.textContent || "").startsWith("");
|
|
@@ -2575,12 +3278,12 @@ function dr(e, t, n = {}) {
|
|
|
2575
3278
|
let t = i;
|
|
2576
3279
|
if (a && n.startOffset > 0) {
|
|
2577
3280
|
let i = t.childNodes[n.startOffset - 1];
|
|
2578
|
-
if (
|
|
2579
|
-
if (
|
|
3281
|
+
if (U(i)) return e.preventDefault(), r((e) => e.setStartBefore(i));
|
|
3282
|
+
if (Ti(i) && U(i.previousSibling)) return e.preventDefault(), r((e) => e.setStartBefore(i.previousSibling));
|
|
2580
3283
|
}
|
|
2581
3284
|
if (!a && n.startOffset < t.childNodes.length) {
|
|
2582
3285
|
let i = t.childNodes[n.startOffset];
|
|
2583
|
-
if (
|
|
3286
|
+
if (U(i)) {
|
|
2584
3287
|
let t = i.nextSibling;
|
|
2585
3288
|
if (e.preventDefault(), t?.nodeType === Node.TEXT_NODE) {
|
|
2586
3289
|
let e = +!!(t.textContent || "").startsWith("");
|
|
@@ -2588,7 +3291,7 @@ function dr(e, t, n = {}) {
|
|
|
2588
3291
|
}
|
|
2589
3292
|
return r((e) => e.setStartAfter(i));
|
|
2590
3293
|
}
|
|
2591
|
-
if (
|
|
3294
|
+
if (Ti(i) && U(i.nextSibling)) {
|
|
2592
3295
|
let t = i.nextSibling, n = t.nextSibling;
|
|
2593
3296
|
if (e.preventDefault(), n?.nodeType === Node.TEXT_NODE) {
|
|
2594
3297
|
let e = +!!(n.textContent || "").startsWith("");
|
|
@@ -2599,18 +3302,18 @@ function dr(e, t, n = {}) {
|
|
|
2599
3302
|
}
|
|
2600
3303
|
}
|
|
2601
3304
|
}
|
|
2602
|
-
if (
|
|
2603
|
-
let r =
|
|
3305
|
+
if (H(e, V.TAB)) {
|
|
3306
|
+
let r = Oe(t);
|
|
2604
3307
|
if (!r) return !1;
|
|
2605
|
-
if (
|
|
2606
|
-
let i =
|
|
2607
|
-
if (i &&
|
|
2608
|
-
if (i?.nodeName.toUpperCase() === "PRE") return !e.shiftKey && (e.preventDefault(),
|
|
2609
|
-
if (n.tabSize) return !e.shiftKey && (e.preventDefault(),
|
|
2610
|
-
}
|
|
2611
|
-
if (
|
|
2612
|
-
if (
|
|
2613
|
-
let n =
|
|
3308
|
+
if (Ei(r.sc, t, e.shiftKey)) return e.preventDefault(), !0;
|
|
3309
|
+
let i = le(r.sc, t);
|
|
3310
|
+
if (i && re(i)) return e.preventDefault(), e.shiftKey ? _n() : hn(), !0;
|
|
3311
|
+
if (i?.nodeName.toUpperCase() === "PRE") return !e.shiftKey && (e.preventDefault(), P("insertText", " ".repeat(n.tabSize || 4)), !0);
|
|
3312
|
+
if (n.tabSize) return !e.shiftKey && (e.preventDefault(), P("insertText", " ".repeat(n.tabSize)), !0);
|
|
3313
|
+
}
|
|
3314
|
+
if (H(e, V.ENTER) && e.shiftKey) return e.preventDefault(), P("insertLineBreak"), !0;
|
|
3315
|
+
if (H(e, V.ENTER) && !e.shiftKey) {
|
|
3316
|
+
let n = Oe(t);
|
|
2614
3317
|
if (!n) return !1;
|
|
2615
3318
|
let r = n.sc, i = r.nodeType === 3 ? r.parentElement : r;
|
|
2616
3319
|
if (i?.nodeName === "I" && /\bfa-/.test(i.className || "")) {
|
|
@@ -2643,46 +3346,46 @@ function dr(e, t, n = {}) {
|
|
|
2643
3346
|
if (r.deleteContents(), n.rangeCount === 0 || !o.isConnected) return !0;
|
|
2644
3347
|
r = n.getRangeAt(0);
|
|
2645
3348
|
}
|
|
2646
|
-
let i =
|
|
3349
|
+
let i = Oi(r, o), a = document.createElement("li"), s = document.createElement("input");
|
|
2647
3350
|
s.type = "checkbox", s.setAttribute("contenteditable", "false"), a.appendChild(s), i.textContent.replace(/[\u00a0\u200B]/g, "").length > 0 && a.appendChild(i);
|
|
2648
3351
|
let c = a.childNodes[1];
|
|
2649
3352
|
c?.nodeType !== Node.TEXT_NODE && (c = document.createTextNode(""), a.appendChild(c)), o.after(a);
|
|
2650
3353
|
let l = document.createRange();
|
|
2651
3354
|
return l.setStart(c, 0), l.collapse(!0), n.removeAllRanges(), n.addRange(l), !0;
|
|
2652
3355
|
}
|
|
2653
|
-
let s =
|
|
2654
|
-
if (s?.nodeName.toUpperCase() === "PRE") return e.preventDefault(),
|
|
3356
|
+
let s = le(n.sc, t);
|
|
3357
|
+
if (s?.nodeName.toUpperCase() === "PRE") return e.preventDefault(), P("insertText", "\n"), !0;
|
|
2655
3358
|
if (s?.nodeName.toUpperCase() === "BLOCKQUOTE") {
|
|
2656
3359
|
let t = n.toNativeRange();
|
|
2657
|
-
if (t.setEnd(s, s.childNodes.length), t.toString() === "" && n.isCollapsed()) return e.preventDefault(),
|
|
3360
|
+
if (t.setEnd(s, s.childNodes.length), t.toString() === "" && n.isCollapsed()) return e.preventDefault(), P("formatBlock", "<p>"), !0;
|
|
2658
3361
|
}
|
|
2659
3362
|
}
|
|
2660
3363
|
return !1;
|
|
2661
3364
|
}
|
|
2662
3365
|
//#endregion
|
|
2663
3366
|
//#region src/js/core/count.js
|
|
2664
|
-
var
|
|
2665
|
-
function
|
|
3367
|
+
var Ai = typeof Intl < "u" && typeof Intl.Segmenter == "function" ? new Intl.Segmenter(void 0, { granularity: "word" }) : null;
|
|
3368
|
+
function ji(e) {
|
|
2666
3369
|
let t = e.trim();
|
|
2667
3370
|
if (!t) return 0;
|
|
2668
|
-
if (
|
|
3371
|
+
if (Ai) {
|
|
2669
3372
|
let e = 0;
|
|
2670
|
-
for (let n of
|
|
3373
|
+
for (let n of Ai.segment(t)) n.isWordLike && e++;
|
|
2671
3374
|
return e;
|
|
2672
3375
|
}
|
|
2673
3376
|
return t.split(/\s+/).length;
|
|
2674
3377
|
}
|
|
2675
|
-
var
|
|
2676
|
-
function
|
|
3378
|
+
var Mi = /* @__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("."));
|
|
3379
|
+
function Ni(e, t, n) {
|
|
2677
3380
|
for (let r = e.firstChild; r; r = r.nextSibling) if (r.nodeType === 3) {
|
|
2678
3381
|
let e = r.data;
|
|
2679
3382
|
t.push(e), n.push(e);
|
|
2680
3383
|
} else if (r.nodeType === 1) {
|
|
2681
|
-
let e =
|
|
2682
|
-
e && t.push("\n"),
|
|
3384
|
+
let e = Mi.has(r.tagName);
|
|
3385
|
+
e && t.push("\n"), Ni(r, t, n), e && t.push("\n");
|
|
2683
3386
|
}
|
|
2684
3387
|
}
|
|
2685
|
-
function
|
|
3388
|
+
function Pi(e) {
|
|
2686
3389
|
if (e.nodeType === 3) {
|
|
2687
3390
|
let t = e.data;
|
|
2688
3391
|
return {
|
|
@@ -2691,12 +3394,12 @@ function hr(e) {
|
|
|
2691
3394
|
};
|
|
2692
3395
|
}
|
|
2693
3396
|
let t = [], n = [];
|
|
2694
|
-
return
|
|
3397
|
+
return Ni(e, t, n), {
|
|
2695
3398
|
lines: t.join(""),
|
|
2696
3399
|
flat: n.join("")
|
|
2697
3400
|
};
|
|
2698
3401
|
}
|
|
2699
|
-
var
|
|
3402
|
+
var Fi = class {
|
|
2700
3403
|
constructor() {
|
|
2701
3404
|
this._cache = /* @__PURE__ */ new WeakMap();
|
|
2702
3405
|
}
|
|
@@ -2708,7 +3411,7 @@ var gr = class {
|
|
|
2708
3411
|
t += e.words, n += e.chars;
|
|
2709
3412
|
continue;
|
|
2710
3413
|
}
|
|
2711
|
-
let { lines: s, flat: c } =
|
|
3414
|
+
let { lines: s, flat: c } = Pi(o);
|
|
2712
3415
|
r.push({
|
|
2713
3416
|
node: o,
|
|
2714
3417
|
key: c,
|
|
@@ -2717,12 +3420,12 @@ var gr = class {
|
|
|
2717
3420
|
}), i.push(s), a += s.length + 1;
|
|
2718
3421
|
}
|
|
2719
3422
|
if (r.length) {
|
|
2720
|
-
let e =
|
|
3423
|
+
let e = Ii(r, i.join("\n"));
|
|
2721
3424
|
r.forEach((r, i) => {
|
|
2722
3425
|
let a = {
|
|
2723
3426
|
key: r.key,
|
|
2724
3427
|
words: e[i],
|
|
2725
|
-
chars: r.key.
|
|
3428
|
+
chars: r.key.replace(/[\n\u200B]/g, "").length
|
|
2726
3429
|
};
|
|
2727
3430
|
this._cache.set(r.node, a), t += a.words, n += a.chars;
|
|
2728
3431
|
});
|
|
@@ -2733,10 +3436,10 @@ var gr = class {
|
|
|
2733
3436
|
};
|
|
2734
3437
|
}
|
|
2735
3438
|
};
|
|
2736
|
-
function
|
|
2737
|
-
if (!
|
|
3439
|
+
function Ii(e, t) {
|
|
3440
|
+
if (!Ai) return e.map((e) => ji(e.text));
|
|
2738
3441
|
let n = Array(e.length).fill(0), r = 0;
|
|
2739
|
-
for (let i of
|
|
3442
|
+
for (let i of Ai.segment(t)) if (i.isWordLike) {
|
|
2740
3443
|
for (; r < e.length - 1 && i.index >= e[r + 1].start;) r++;
|
|
2741
3444
|
n[r]++;
|
|
2742
3445
|
}
|
|
@@ -2744,14 +3447,14 @@ function _r(e, t) {
|
|
|
2744
3447
|
}
|
|
2745
3448
|
//#endregion
|
|
2746
3449
|
//#region src/js/core/markdown.js
|
|
2747
|
-
function
|
|
3450
|
+
function Li(e) {
|
|
2748
3451
|
let t = new DOMParser().parseFromString(`<body>${e || ""}</body>`, "text/html");
|
|
2749
|
-
return
|
|
3452
|
+
return xe(t.body), Gi(t.body).replace(/\n{3,}/g, "\n\n").trim();
|
|
2750
3453
|
}
|
|
2751
|
-
function
|
|
3454
|
+
function Ri(e, t) {
|
|
2752
3455
|
return Array.from(e.children).filter((e) => e.tagName === t.toUpperCase());
|
|
2753
3456
|
}
|
|
2754
|
-
function
|
|
3457
|
+
function zi(e) {
|
|
2755
3458
|
let t = "";
|
|
2756
3459
|
for (let n of e.childNodes) {
|
|
2757
3460
|
if (n.nodeType === 3) {
|
|
@@ -2765,40 +3468,43 @@ function yr(e) {
|
|
|
2765
3468
|
continue;
|
|
2766
3469
|
}
|
|
2767
3470
|
if (e === "div" || e === "p") {
|
|
2768
|
-
t && !t.endsWith("\n") && (t += "\n"), t +=
|
|
3471
|
+
t && !t.endsWith("\n") && (t += "\n"), t += zi(n), t += "\n";
|
|
2769
3472
|
continue;
|
|
2770
3473
|
}
|
|
2771
|
-
t +=
|
|
3474
|
+
t += zi(n);
|
|
2772
3475
|
}
|
|
2773
3476
|
return t;
|
|
2774
3477
|
}
|
|
2775
|
-
function
|
|
3478
|
+
function Bi(e) {
|
|
2776
3479
|
return e.replaceAll("\\", "\\\\").replace(/&(?=#\d+;|#[xX][0-9a-fA-F]+;|[a-zA-Z][a-zA-Z0-9]*;)/g, "&").replace(/!(?=\[)/g, String.raw`\!`).replace(/([`*[\]])/g, String.raw`\$1`).replace(/(?<!\w)_|_(?!\w)/g, String.raw`\_`).replace(/~(?=~)|(?<=~)~/g, String.raw`\~`);
|
|
2777
3480
|
}
|
|
2778
|
-
function
|
|
3481
|
+
function Vi(e) {
|
|
2779
3482
|
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}`);
|
|
2780
3483
|
}
|
|
2781
|
-
function
|
|
2782
|
-
return e.split("\n").map(
|
|
3484
|
+
function Hi(e) {
|
|
3485
|
+
return e.split("\n").map(Vi).join("\n");
|
|
2783
3486
|
}
|
|
2784
|
-
function
|
|
3487
|
+
function Ui(e, t) {
|
|
2785
3488
|
let n = " ".repeat(t + 1);
|
|
2786
|
-
return
|
|
3489
|
+
return Gi(e, t + 1).trim().split("\n").map((e, t) => t === 0 || e.trim() === "" || e.startsWith(n) ? e : n + e).join("\n");
|
|
2787
3490
|
}
|
|
2788
|
-
function
|
|
3491
|
+
function Wi(e, t) {
|
|
2789
3492
|
let n = e.getAttribute(t) || "", r = /[\s()]/.test(n) ? `<${n}>` : n, i = e.getAttribute("title");
|
|
2790
3493
|
return i ? `${r} "${i.replaceAll("\"", String.raw`\"`)}"` : r;
|
|
2791
3494
|
}
|
|
2792
|
-
function
|
|
3495
|
+
function Gi(e, t = 0) {
|
|
2793
3496
|
if (e.nodeType === 3) {
|
|
2794
3497
|
let t = e.textContent.replace(/\s+/g, " ");
|
|
2795
|
-
return e.parentElement?.closest("pre, code") ? t :
|
|
3498
|
+
return e.parentElement?.closest("pre, code") ? t : Bi(t);
|
|
2796
3499
|
}
|
|
2797
3500
|
if (e.nodeType !== 1) return "";
|
|
2798
|
-
let n = e, r = n.nodeName.toLowerCase(), i = () => Array.from(n.childNodes).map((e) =>
|
|
3501
|
+
let n = e, r = n.nodeName.toLowerCase(), i = () => Array.from(n.childNodes).map((e) => Gi(e, t)).join(""), a = (e, t = e) => {
|
|
3502
|
+
let n = i();
|
|
3503
|
+
return n.trim() ? `${e}${n}${t}` : n;
|
|
3504
|
+
};
|
|
2799
3505
|
switch (r) {
|
|
2800
3506
|
case "p":
|
|
2801
|
-
case "div": return `\n\n${
|
|
3507
|
+
case "div": return `\n\n${Hi(i())}\n\n`;
|
|
2802
3508
|
case "br": return " \n";
|
|
2803
3509
|
case "h1": return `\n\n# ${i()}\n\n`;
|
|
2804
3510
|
case "h2": return `\n\n## ${i()}\n\n`;
|
|
@@ -2807,18 +3513,18 @@ function Tr(e, t = 0) {
|
|
|
2807
3513
|
case "h5": return `\n\n##### ${i()}\n\n`;
|
|
2808
3514
|
case "h6": return `\n\n###### ${i()}\n\n`;
|
|
2809
3515
|
case "strong":
|
|
2810
|
-
case "b": return
|
|
3516
|
+
case "b": return a("**");
|
|
2811
3517
|
case "em":
|
|
2812
|
-
case "i": return
|
|
3518
|
+
case "i": return a("*");
|
|
2813
3519
|
case "del":
|
|
2814
3520
|
case "s":
|
|
2815
|
-
case "strike": return
|
|
2816
|
-
case "sup": return
|
|
2817
|
-
case "sub": return
|
|
2818
|
-
case "u": return
|
|
3521
|
+
case "strike": return a("~~");
|
|
3522
|
+
case "sup": return a("^");
|
|
3523
|
+
case "sub": return a("~");
|
|
3524
|
+
case "u": return a("<u>", "</u>");
|
|
2819
3525
|
case "span": {
|
|
2820
3526
|
let e = n.getAttribute("style") || "";
|
|
2821
|
-
return /\b(color|background-color|font-size)\s*:/.test(e) ? `<span style="${q(e)}">${i()}</span>` : i();
|
|
3527
|
+
return /\b(color|background-color|font-size|font-family)\s*:/.test(e) ? `<span style="${q(e)}">${i()}</span>` : i();
|
|
2822
3528
|
}
|
|
2823
3529
|
case "code": {
|
|
2824
3530
|
if (n.closest("pre")) return i();
|
|
@@ -2827,27 +3533,27 @@ function Tr(e, t = 0) {
|
|
|
2827
3533
|
}
|
|
2828
3534
|
case "pre": {
|
|
2829
3535
|
let e = n.querySelector("code"), t = /language-(\S+)/.exec(e?.className || "");
|
|
2830
|
-
return `\n\n\`\`\`${t ? t[1] : ""}\n${
|
|
3536
|
+
return `\n\n\`\`\`${t ? t[1] : ""}\n${zi(e || n).replace(/\n$/, "")}\n\`\`\`\n\n`;
|
|
2831
3537
|
}
|
|
2832
3538
|
case "blockquote": {
|
|
2833
3539
|
let e = i().trim().split("\n");
|
|
2834
3540
|
return `\n\n${e.filter((t, n) => t.trim() !== "" || (e[n - 1] ?? "").trim() !== "").map((e) => e.trim() === "" ? ">" : `> ${e}`).join("\n")}\n\n`;
|
|
2835
3541
|
}
|
|
2836
|
-
case "a": return `[${i()}](${
|
|
2837
|
-
case "img": return `})`;
|
|
3543
|
+
case "img": return `})`;
|
|
2838
3544
|
case "ul": {
|
|
2839
|
-
let e =
|
|
3545
|
+
let e = Ri(n, "li");
|
|
2840
3546
|
if (!e.length) return i();
|
|
2841
3547
|
let r = " ".repeat(t), a = n.classList.contains("an-checklist"), o = e.map((e) => {
|
|
2842
|
-
let n =
|
|
2843
|
-
return (a || n) && (i = n && n.checked ? "- [x] " : "- [ ] "), `${r}${i}${
|
|
3548
|
+
let n = Ri(e, "input").find((e) => e.getAttribute("type") === "checkbox"), i = "- ";
|
|
3549
|
+
return (a || n) && (i = n && n.checked ? "- [x] " : "- [ ] "), `${r}${i}${Ui(e, t)}`;
|
|
2844
3550
|
}).join("\n");
|
|
2845
3551
|
return t === 0 ? `\n\n${o}\n\n` : `\n${o}`;
|
|
2846
3552
|
}
|
|
2847
3553
|
case "ol": {
|
|
2848
|
-
let e =
|
|
3554
|
+
let e = Ri(n, "li");
|
|
2849
3555
|
if (!e.length) return i();
|
|
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}. ${
|
|
3556
|
+
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}. ${Ui(e, t)}`).join("\n");
|
|
2851
3557
|
return t === 0 ? `\n\n${s}\n\n` : `\n${s}`;
|
|
2852
3558
|
}
|
|
2853
3559
|
case "li": return i();
|
|
@@ -2855,7 +3561,7 @@ function Tr(e, t = 0) {
|
|
|
2855
3561
|
case "table": {
|
|
2856
3562
|
let e = Array.from(n.querySelectorAll("tr"));
|
|
2857
3563
|
if (!e.length) return i();
|
|
2858
|
-
let t = !!
|
|
3564
|
+
let t = !!Ri(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) => Bi(e.textContent.trim()).replaceAll("|", String.raw`\|`))), a = Math.max(...r.map((e) => e.length)), o = (e) => {
|
|
2859
3565
|
let t = [...e];
|
|
2860
3566
|
for (; t.length < a;) t.push("");
|
|
2861
3567
|
return t;
|
|
@@ -2870,16 +3576,16 @@ function Tr(e, t = 0) {
|
|
|
2870
3576
|
default: return i();
|
|
2871
3577
|
}
|
|
2872
3578
|
}
|
|
2873
|
-
function
|
|
3579
|
+
function Ki(e) {
|
|
2874
3580
|
return String(e ?? "").replace(/^\ufeff/, "");
|
|
2875
3581
|
}
|
|
2876
|
-
function
|
|
2877
|
-
let t =
|
|
3582
|
+
function qi(e) {
|
|
3583
|
+
let t = Ki(e);
|
|
2878
3584
|
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);
|
|
2879
3585
|
}
|
|
2880
|
-
var
|
|
2881
|
-
function
|
|
2882
|
-
let t =
|
|
3586
|
+
var Ji = /^ {0,3}>( ?)(.*)$/, Yi = /^(?: {4}|\t)\s*\S/, Xi = /^( {0,3})(`{3,}|~{3,})[ \t]*([^\s`~][^\n]*)?$/;
|
|
3587
|
+
function Zi(e) {
|
|
3588
|
+
let t = Xi.exec(e);
|
|
2883
3589
|
if (!t) return null;
|
|
2884
3590
|
let [, n, r, i = ""] = t;
|
|
2885
3591
|
return r[0] === "`" && i.includes("`") ? null : {
|
|
@@ -2889,7 +3595,7 @@ function V(e) {
|
|
|
2889
3595
|
lang: i.trim().split(/\s+/)[0] || ""
|
|
2890
3596
|
};
|
|
2891
3597
|
}
|
|
2892
|
-
function
|
|
3598
|
+
function Qi(e, t) {
|
|
2893
3599
|
let n = 0, r = 0;
|
|
2894
3600
|
for (; r < e.length && n < t;) {
|
|
2895
3601
|
if (e[r] === " ") {
|
|
@@ -2906,40 +3612,40 @@ function Ar(e, t) {
|
|
|
2906
3612
|
}
|
|
2907
3613
|
return e.slice(r);
|
|
2908
3614
|
}
|
|
2909
|
-
var
|
|
2910
|
-
function
|
|
2911
|
-
let t =
|
|
2912
|
-
t =
|
|
2913
|
-
let n =
|
|
2914
|
-
return t = n.clean,
|
|
3615
|
+
var $i = /^ {0,3}([-*_])( *\1){2,}\s*$/, ea = "";
|
|
3616
|
+
function ta(e) {
|
|
3617
|
+
let t = Ki(e).replaceAll("\r\n", "\n").replaceAll("\r", "\n").split("\n");
|
|
3618
|
+
t = aa(t);
|
|
3619
|
+
let n = oa(t);
|
|
3620
|
+
return t = n.clean, ra = n.linkDefs, ia = n.footnoteIds, na(t);
|
|
2915
3621
|
}
|
|
2916
|
-
function
|
|
3622
|
+
function na(e) {
|
|
2917
3623
|
let t = [], n = 0;
|
|
2918
3624
|
for (; n < e.length;) {
|
|
2919
|
-
let r = e[n], i =
|
|
3625
|
+
let r = e[n], i = Zi(r);
|
|
2920
3626
|
if (i) {
|
|
2921
3627
|
let r = RegExp(`^ {0,3}\\${i.marker}{${i.length},}[ \t]*$`), a = [];
|
|
2922
|
-
for (n++; n < e.length && !r.test(e[n]);) a.push(
|
|
3628
|
+
for (n++; n < e.length && !r.test(e[n]);) a.push(Oa(Qi(e[n], i.indent))), n++;
|
|
2923
3629
|
let o = i.lang ? ` class="language-${q(i.lang)}"` : "";
|
|
2924
3630
|
t.push(`<pre><code${o}>${a.join("\n")}</code></pre>`), n++;
|
|
2925
3631
|
continue;
|
|
2926
3632
|
}
|
|
2927
|
-
if (
|
|
3633
|
+
if (Yi.test(r)) {
|
|
2928
3634
|
let r = [];
|
|
2929
|
-
for (; n < e.length && (
|
|
3635
|
+
for (; n < e.length && (Yi.test(e[n]) || e[n].trim() === "");) {
|
|
2930
3636
|
if (e[n].trim() === "") {
|
|
2931
3637
|
let t = n;
|
|
2932
3638
|
for (; t < e.length && e[t].trim() === "";) t++;
|
|
2933
|
-
if (t >= e.length || !
|
|
3639
|
+
if (t >= e.length || !Yi.test(e[t])) break;
|
|
2934
3640
|
for (; n < t; n++) r.push("");
|
|
2935
3641
|
continue;
|
|
2936
3642
|
}
|
|
2937
|
-
r.push(
|
|
3643
|
+
r.push(Oa(Qi(e[n], 4))), n++;
|
|
2938
3644
|
}
|
|
2939
3645
|
t.push(`<pre><code>${r.join("\n")}</code></pre>`);
|
|
2940
3646
|
continue;
|
|
2941
3647
|
}
|
|
2942
|
-
if (r.trim() &&
|
|
3648
|
+
if (r.trim() && !$i.test(r) && !/^#{1,6} /.test(r) && n + 1 < e.length) {
|
|
2943
3649
|
if (/^=+\s*$/.test(e[n + 1])) {
|
|
2944
3650
|
t.push(`<h1>${K(r.trim())}</h1>`), n += 2;
|
|
2945
3651
|
continue;
|
|
@@ -2949,7 +3655,7 @@ function Nr(e) {
|
|
|
2949
3655
|
continue;
|
|
2950
3656
|
}
|
|
2951
3657
|
}
|
|
2952
|
-
if (
|
|
3658
|
+
if ($i.test(r)) {
|
|
2953
3659
|
t.push("<hr>"), n++;
|
|
2954
3660
|
continue;
|
|
2955
3661
|
}
|
|
@@ -2959,19 +3665,19 @@ function Nr(e) {
|
|
|
2959
3665
|
t.push(`<h${e}>${K(r)}</h${e}>`), n++;
|
|
2960
3666
|
continue;
|
|
2961
3667
|
}
|
|
2962
|
-
if (
|
|
3668
|
+
if (Ji.test(r)) {
|
|
2963
3669
|
let r = [];
|
|
2964
|
-
for (; n < e.length &&
|
|
2965
|
-
t.push(`<blockquote>${
|
|
3670
|
+
for (; n < e.length && Ji.test(e[n]);) r.push(Ji.exec(e[n])[2]), n++;
|
|
3671
|
+
t.push(`<blockquote>${na(r)}</blockquote>`);
|
|
2966
3672
|
continue;
|
|
2967
3673
|
}
|
|
2968
3674
|
if (/^[-*+] /.test(r)) {
|
|
2969
|
-
let { html: r, endIdx: i } =
|
|
3675
|
+
let { html: r, endIdx: i } = da(e, n);
|
|
2970
3676
|
t.push(r), n = i;
|
|
2971
3677
|
continue;
|
|
2972
3678
|
}
|
|
2973
3679
|
if (/^\d+[.)] /.test(r)) {
|
|
2974
|
-
let { html: r, endIdx: i } =
|
|
3680
|
+
let { html: r, endIdx: i } = da(e, n);
|
|
2975
3681
|
t.push(r), n = i;
|
|
2976
3682
|
continue;
|
|
2977
3683
|
}
|
|
@@ -2979,23 +3685,23 @@ function Nr(e) {
|
|
|
2979
3685
|
n++;
|
|
2980
3686
|
continue;
|
|
2981
3687
|
}
|
|
2982
|
-
if (
|
|
2983
|
-
let i =
|
|
3688
|
+
if (ua(e, n)) {
|
|
3689
|
+
let i = W(r), a = W(e[n + 1]).map((e) => e.startsWith(":") && e.endsWith(":") ? "center" : e.endsWith(":") ? "right" : e.startsWith(":") ? "left" : null);
|
|
2984
3690
|
n += 2;
|
|
2985
3691
|
let o = [];
|
|
2986
|
-
for (; n < e.length && e[n].trim() !== "" &&
|
|
3692
|
+
for (; n < e.length && e[n].trim() !== "" && la(e[n]);) o.push(W(e[n])), n++;
|
|
2987
3693
|
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>` : "";
|
|
2988
3694
|
t.push(`<table>${c}${l}</table>`);
|
|
2989
3695
|
continue;
|
|
2990
3696
|
}
|
|
2991
3697
|
let o = [];
|
|
2992
|
-
for (; n < e.length && e[n].trim() !== "" && !/^(#{1,6} |[-*+] |\d+[.)] )/.test(e[n]) && !
|
|
2993
|
-
o.length ? t.push(`<p>${K(
|
|
3698
|
+
for (; n < e.length && e[n].trim() !== "" && !/^(#{1,6} |[-*+] |\d+[.)] )/.test(e[n]) && !Zi(e[n]) && !Ji.test(e[n]) && !$i.test(e[n]) && !ua(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++;
|
|
3699
|
+
o.length ? t.push(`<p>${K(sa(o)).replaceAll(ea, "<br>")}</p>`) : (t.push(`<p>${K(r)}</p>`), n++);
|
|
2994
3700
|
}
|
|
2995
3701
|
return t.join("");
|
|
2996
3702
|
}
|
|
2997
|
-
var
|
|
2998
|
-
function
|
|
3703
|
+
var ra = /* @__PURE__ */ new Map(), ia = /* @__PURE__ */ new Set();
|
|
3704
|
+
function aa(e) {
|
|
2999
3705
|
if ((e[0] || "").trim() !== "---") return e;
|
|
3000
3706
|
let t = -1;
|
|
3001
3707
|
for (let n = 1; n < e.length; n++) {
|
|
@@ -3009,14 +3715,14 @@ function Ir(e) {
|
|
|
3009
3715
|
let n = t + 1;
|
|
3010
3716
|
return e[n] !== void 0 && e[n].trim() === "" && n++, e.slice(n);
|
|
3011
3717
|
}
|
|
3012
|
-
function
|
|
3718
|
+
function oa(e) {
|
|
3013
3719
|
let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set(), r = [], i = !1, a = /^\[([^\]]+)\]:\s*(\S+)(?:\s+"([^"]*)")?\s*$/, o = /^\[\^([^\]]+)\]:[ \t]*(\S.*)$/;
|
|
3014
3720
|
for (let s of e) {
|
|
3015
3721
|
if (i) {
|
|
3016
3722
|
/^ {0,3}(?:`{3,}|~{3,})[ \t]*$/.test(s) && (i = !1), r.push(s);
|
|
3017
3723
|
continue;
|
|
3018
3724
|
}
|
|
3019
|
-
if (
|
|
3725
|
+
if (Zi(s)) {
|
|
3020
3726
|
i = !0, r.push(s);
|
|
3021
3727
|
continue;
|
|
3022
3728
|
}
|
|
@@ -3043,36 +3749,36 @@ function Lr(e) {
|
|
|
3043
3749
|
footnoteIds: n
|
|
3044
3750
|
};
|
|
3045
3751
|
}
|
|
3046
|
-
function
|
|
3752
|
+
function sa(e) {
|
|
3047
3753
|
let t = "";
|
|
3048
3754
|
for (let n = 0; n < e.length; n++) {
|
|
3049
3755
|
let r = n === e.length - 1, i = e[n].replace(/^[ \t]+/, "");
|
|
3050
3756
|
if (!r && /\\$/.test(i)) {
|
|
3051
|
-
t += i.replace(/\\$/, "") +
|
|
3757
|
+
t += i.replace(/\\$/, "") + ea;
|
|
3052
3758
|
continue;
|
|
3053
3759
|
}
|
|
3054
3760
|
if (!r && / {2,}$/.test(i)) {
|
|
3055
|
-
t += i.replace(/ {2,}$/, "") +
|
|
3761
|
+
t += i.replace(/ {2,}$/, "") + ea;
|
|
3056
3762
|
continue;
|
|
3057
3763
|
}
|
|
3058
3764
|
t += i + (r ? "" : " ");
|
|
3059
3765
|
}
|
|
3060
3766
|
return t;
|
|
3061
3767
|
}
|
|
3062
|
-
function
|
|
3063
|
-
return
|
|
3768
|
+
function ca(e) {
|
|
3769
|
+
return W(e).length;
|
|
3064
3770
|
}
|
|
3065
|
-
function
|
|
3066
|
-
return e.includes("|") ? /^\s*\|/.test(e) ||
|
|
3771
|
+
function la(e) {
|
|
3772
|
+
return e.includes("|") ? /^\s*\|/.test(e) || ca(e) > 1 : !1;
|
|
3067
3773
|
}
|
|
3068
|
-
function
|
|
3774
|
+
function ua(e, t) {
|
|
3069
3775
|
let n = e[t], r = e[t + 1];
|
|
3070
3776
|
if (r === void 0 || !n.includes("|")) return !1;
|
|
3071
3777
|
if (/^\|.+\|/.test(n)) return /^\|[\s|:-]+\|/.test(r);
|
|
3072
|
-
let i =
|
|
3073
|
-
return i.length < 2 || !i.every((e) => /^:?-+:?$/.test(e)) ? !1 :
|
|
3778
|
+
let i = W(r);
|
|
3779
|
+
return i.length < 2 || !i.every((e) => /^:?-+:?$/.test(e)) ? !1 : ca(n) === i.length;
|
|
3074
3780
|
}
|
|
3075
|
-
function
|
|
3781
|
+
function W(e) {
|
|
3076
3782
|
let t = e.replace(/^\|/, "").replace(/\|$/, ""), n = [], r = "";
|
|
3077
3783
|
for (let e = 0; e < t.length; e++) {
|
|
3078
3784
|
if (t[e] === "\\" && t[e + 1] === "|") {
|
|
@@ -3087,7 +3793,7 @@ function U(e) {
|
|
|
3087
3793
|
}
|
|
3088
3794
|
return n.push(r), n.map((e) => e.trim());
|
|
3089
3795
|
}
|
|
3090
|
-
function
|
|
3796
|
+
function da(e, t) {
|
|
3091
3797
|
let n = e[t].match(/^(\s*)/)[1].length, r = /^\s*\d+[.)] /.test(e[t]), i = [], a = null, o = !1, s = !1, c = t;
|
|
3092
3798
|
for (; c < e.length;) {
|
|
3093
3799
|
let t = e[c];
|
|
@@ -3115,15 +3821,15 @@ function Hr(e, t) {
|
|
|
3115
3821
|
c++;
|
|
3116
3822
|
continue;
|
|
3117
3823
|
}
|
|
3118
|
-
let n = (e) =>
|
|
3824
|
+
let n = (e) => Qi(e, l), r = Zi(n(t));
|
|
3119
3825
|
if (r) {
|
|
3120
3826
|
let t = RegExp(`^ {0,3}\\${r.marker}{${r.length},}[ \t]*$`), a = [n(e[c])];
|
|
3121
3827
|
for (c++; c < e.length && !t.test(n(e[c]));) a.push(n(e[c])), c++;
|
|
3122
|
-
c < e.length && (a.push(n(e[c])), c++), i[i.length - 1].sub +=
|
|
3828
|
+
c < e.length && (a.push(n(e[c])), c++), i[i.length - 1].sub += na(a), s = !1;
|
|
3123
3829
|
continue;
|
|
3124
3830
|
}
|
|
3125
3831
|
if (/^\s*(?:[-*+]|\d+[.)]) /.test(t)) {
|
|
3126
|
-
let t =
|
|
3832
|
+
let t = da(e, c);
|
|
3127
3833
|
i[i.length - 1].sub += t.html, c = t.endIdx, s = !1;
|
|
3128
3834
|
} else if (s) i[i.length - 1].paras.push(t.trim()), s = !1, c++;
|
|
3129
3835
|
else {
|
|
@@ -3132,41 +3838,41 @@ function Hr(e, t) {
|
|
|
3132
3838
|
}
|
|
3133
3839
|
}
|
|
3134
3840
|
}
|
|
3135
|
-
let l = !r && a === !0, u = r ? /^\s*(\d+)[.)] /.exec(e[t]) : null, d = u ? Number.parseInt(u[1], 10) : 1, f = r ? d === 1 ? "<ol>" : `<ol start="${d}">` : l ? "<ul class=\"an-checklist\">" : "<ul>",
|
|
3841
|
+
let l = !r && a === !0, u = r ? /^\s*(\d+)[.)] /.exec(e[t]) : null, d = u ? Number.parseInt(u[1], 10) : 1, f = r ? d === 1 ? "<ol>" : `<ol start="${d}">` : l ? "<ul class=\"an-checklist\">" : "<ul>", ee = r ? "</ol>" : "</ul>";
|
|
3136
3842
|
return {
|
|
3137
3843
|
html: `${f}${i.map(({ paras: e, isCB: t, checked: n, sub: r }) => {
|
|
3138
3844
|
let i = t ? `<input type="checkbox" contenteditable="false"${n ? " checked" : ""}>` : "";
|
|
3139
3845
|
return `<li>${o ? e.map((e, t) => `<p>${t === 0 ? i : ""}${K(e)}</p>`).join("") : `${i}${K(e[0])}`}${r}</li>`;
|
|
3140
|
-
}).join("")}${
|
|
3846
|
+
}).join("")}${ee}`,
|
|
3141
3847
|
endIdx: c
|
|
3142
3848
|
};
|
|
3143
3849
|
}
|
|
3144
|
-
var
|
|
3145
|
-
function
|
|
3850
|
+
var fa = /\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g, G = "\0", pa = "", ma = /(`+)([^]*?)\1/g;
|
|
3851
|
+
function ha(e) {
|
|
3146
3852
|
let t = [];
|
|
3147
3853
|
return {
|
|
3148
|
-
text: e.replace(
|
|
3854
|
+
text: e.replace(ma, (e, n, r) => r === "" ? e : (t.push(r), `${pa}${t.length - 1}${pa}`)),
|
|
3149
3855
|
codes: t
|
|
3150
3856
|
};
|
|
3151
3857
|
}
|
|
3152
|
-
function
|
|
3153
|
-
return e.replace(RegExp(`${
|
|
3858
|
+
function ga(e, t, n) {
|
|
3859
|
+
return e.replace(RegExp(`${pa}(\\d+)${pa}`, "g"), (e, r) => {
|
|
3154
3860
|
let i = t[Number(r)];
|
|
3155
|
-
return i = i.replace(RegExp(`${
|
|
3861
|
+
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>${Oa(i)}</code>`;
|
|
3156
3862
|
});
|
|
3157
3863
|
}
|
|
3158
|
-
function
|
|
3864
|
+
function _a(e) {
|
|
3159
3865
|
let t = [];
|
|
3160
3866
|
return {
|
|
3161
|
-
text: e.replace(
|
|
3867
|
+
text: e.replace(fa, (e, n) => (t.push(n), `${G}${t.length - 1}${G}`)),
|
|
3162
3868
|
literals: t
|
|
3163
3869
|
};
|
|
3164
3870
|
}
|
|
3165
|
-
function
|
|
3166
|
-
return e.replace(RegExp(`${
|
|
3871
|
+
function va(e, t) {
|
|
3872
|
+
return e.replace(RegExp(`${G}(\\d+)${G}`, "g"), (e, n) => Da(t[Number(n)]));
|
|
3167
3873
|
}
|
|
3168
|
-
var
|
|
3169
|
-
function
|
|
3874
|
+
var ya = String.raw`(<.*?>(?:\s+(?:"[^"]*"|'[^']*'))?|[^)]*)`, ba = new RegExp(String.raw`!\[([^\]]*)\]\(${ya}\)`, "g"), xa = new RegExp(String.raw`\[([^\]]+)\]\(${ya}\)`, "g");
|
|
3875
|
+
function Sa(e) {
|
|
3170
3876
|
let t = e.trim(), n = /^<([\s\S]*?)>(?:[ \t]*(?:"([^"]*)"|'([^']*)'))?[ \t]*$/.exec(t);
|
|
3171
3877
|
if (n) return {
|
|
3172
3878
|
href: n[1],
|
|
@@ -3181,26 +3887,26 @@ function Qr(e) {
|
|
|
3181
3887
|
title: ""
|
|
3182
3888
|
};
|
|
3183
3889
|
}
|
|
3184
|
-
function
|
|
3185
|
-
return e = e.replace(
|
|
3186
|
-
let { href: r, title: i } =
|
|
3890
|
+
function Ca(e) {
|
|
3891
|
+
return e = e.replace(ba, (e, t, n) => {
|
|
3892
|
+
let { href: r, title: i } = Sa(n), a = i ? ` title="${J(i)}"` : "";
|
|
3187
3893
|
return `<img src="${J(r)}" alt="${J(t)}"${a} class="an-image">`;
|
|
3188
|
-
}), e = e.replace(
|
|
3189
|
-
let { href: r, title: i } =
|
|
3894
|
+
}), e = e.replace(xa, (e, t, n) => {
|
|
3895
|
+
let { href: r, title: i } = Sa(n), a = i ? ` title="${J(i)}"` : "";
|
|
3190
3896
|
return `<a href="${J(r)}"${a}>${t}</a>`;
|
|
3191
3897
|
}), e = e.replace(/\[([^\]]+)\]\[([^\]]*)\]/g, (e, t, n) => {
|
|
3192
|
-
let r =
|
|
3898
|
+
let r = ra.get(ka(n || t).trim().toLowerCase());
|
|
3193
3899
|
if (!r) return e;
|
|
3194
3900
|
let i = r.title ? ` title="${q(r.title)}"` : "";
|
|
3195
3901
|
return `<a href="${q(r.href)}"${i}>${t}</a>`;
|
|
3196
3902
|
}), e = e.replace(/\[([^\]]+)\]/g, (e, t) => {
|
|
3197
|
-
let n =
|
|
3903
|
+
let n = ra.get(ka(t).trim().toLowerCase());
|
|
3198
3904
|
if (!n) return e;
|
|
3199
3905
|
let r = n.title ? ` title="${q(n.title)}"` : "";
|
|
3200
3906
|
return `<a href="${q(n.href)}"${r}>${t}</a>`;
|
|
3201
|
-
}), e = e.replace(/\[\^([^\]]+)\]/g, (e, t) =>
|
|
3907
|
+
}), e = e.replace(/\[\^([^\]]+)\]/g, (e, t) => ia.has(ka(t)) ? `<sup>[${t}]</sup>` : e), e;
|
|
3202
3908
|
}
|
|
3203
|
-
function
|
|
3909
|
+
function wa(e) {
|
|
3204
3910
|
return e = e.replace(/<(https?:\/\/[^\s&]+?)>/g, (e, t) => `<a href="${J(t)}">${t}</a>`), e = e.replace(/<([\w.!#$%&'*+/=?^`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+)>/g, (e, t) => `<a href="mailto:${J(t)}">${t}</a>`), e = e.replace(/(^|[\s(])(https?:\/\/[^\s()]+)/g, (e, t, n) => {
|
|
3205
3911
|
let r = /[.,;:!?)]+$/.exec(n), i = r ? n.slice(0, -r[0].length) : n;
|
|
3206
3912
|
if (!i) return e;
|
|
@@ -3208,18 +3914,18 @@ function ei(e) {
|
|
|
3208
3914
|
return `${t}<a href="${J(i)}">${i}</a>${a}`;
|
|
3209
3915
|
}), e;
|
|
3210
3916
|
}
|
|
3211
|
-
function
|
|
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;
|
|
3917
|
+
function Ta(e) {
|
|
3918
|
+
return e = e.replace(/\*{3}([^*\n]+?)\*{3}/g, (e, t) => `<strong><em>${t}</em></strong>`), e = e.replace(/(?<!\w)_{3}([^_\n]+?)_{3}(?!\w)/g, (e, t) => `<strong><em>${t}</em></strong>`), e = e.replace(/\*{2}([^*\n]+?)\*{2}/g, (e, t) => `<strong>${t}</strong>`), e = e.replace(/(?<!\w)_{2}([^_\n]+?)_{2}(?!\w)/g, (e, t) => `<strong>${t}</strong>`), e = e.replace(/\*([^*\n]+?)\*/g, (e, t) => `<em>${t}</em>`), e = e.replace(/(?<!\w)_([^_\n]+?)_(?!\w)/g, (e, t) => `<em>${t}</em>`), e = e.replace(/~~([^~\n]+?)~~/g, (e, t) => `<del>${t}</del>`), e = e.replace(/\^([^\s^]+)\^/g, (e, t) => `<sup>${t}</sup>`), e = e.replace(/(?<!~)~([^\s~]+)~(?!~)/g, (e, t) => `<sub>${t}</sub>`), e = e.replace(/<u>(.+?)<\/u>/g, (e, t) => `<u>${t}</u>`), e = e.replace(/<span style=(?:"|")([^"<>&]*(?:&[^"<>&]*)*)(?:"|")>(.*?)<\/span>/g, (e, t, n) => `<span style="${t}">${n}</span>`), e;
|
|
3213
3919
|
}
|
|
3214
3920
|
function K(e) {
|
|
3215
|
-
let { text: t, literals: n } =
|
|
3216
|
-
return a =
|
|
3921
|
+
let { text: t, literals: n } = _a(e), { text: r, codes: i } = ha(t), a = Da(r);
|
|
3922
|
+
return a = Ca(a), a = wa(a), a = Ta(a), ga(va(a, n), i, n);
|
|
3217
3923
|
}
|
|
3218
|
-
var
|
|
3219
|
-
function
|
|
3220
|
-
return String(e).replace(
|
|
3924
|
+
var Ea = /&(?!#\d+;|#[xX][0-9a-fA-F]+;|[a-zA-Z][a-zA-Z0-9]*;)/g;
|
|
3925
|
+
function Da(e) {
|
|
3926
|
+
return String(e).replace(Ea, "&").replaceAll("<", "<").replaceAll(">", ">");
|
|
3221
3927
|
}
|
|
3222
|
-
function
|
|
3928
|
+
function Oa(e) {
|
|
3223
3929
|
return String(e).replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">");
|
|
3224
3930
|
}
|
|
3225
3931
|
function q(e) {
|
|
@@ -3228,16 +3934,16 @@ function q(e) {
|
|
|
3228
3934
|
function J(e) {
|
|
3229
3935
|
return String(e).replaceAll("\"", """).replaceAll("'", "'");
|
|
3230
3936
|
}
|
|
3231
|
-
function
|
|
3937
|
+
function ka(e) {
|
|
3232
3938
|
return String(e).replaceAll("<", "<").replaceAll(">", ">").replaceAll("&", "&");
|
|
3233
3939
|
}
|
|
3234
3940
|
//#endregion
|
|
3235
3941
|
//#region src/js/core/detectLang.js
|
|
3236
|
-
var
|
|
3942
|
+
var Aa = 5, ja = 2, Ma = [
|
|
3237
3943
|
["typescript", "javascript"],
|
|
3238
3944
|
["scss", "css"],
|
|
3239
3945
|
["cpp", "c"]
|
|
3240
|
-
],
|
|
3946
|
+
], Na = [
|
|
3241
3947
|
"javascript",
|
|
3242
3948
|
"typescript",
|
|
3243
3949
|
"python",
|
|
@@ -3260,7 +3966,7 @@ var oi = 5, si = 2, ci = [
|
|
|
3260
3966
|
"scss",
|
|
3261
3967
|
"css",
|
|
3262
3968
|
"bash"
|
|
3263
|
-
],
|
|
3969
|
+
], Pa = [
|
|
3264
3970
|
{
|
|
3265
3971
|
lang: "php",
|
|
3266
3972
|
w: 10,
|
|
@@ -3826,27 +4532,35 @@ var oi = 5, si = 2, ci = [
|
|
|
3826
4532
|
w: 3,
|
|
3827
4533
|
re: /\s\|[ \t]*\w|\s&&\s|\s2>&1|\s-[\w-]+\s/
|
|
3828
4534
|
}
|
|
3829
|
-
],
|
|
3830
|
-
function
|
|
3831
|
-
if (e.length <=
|
|
3832
|
-
let t = e.slice(0,
|
|
4535
|
+
], Fa = 4e3;
|
|
4536
|
+
function Ia(e) {
|
|
4537
|
+
if (e.length <= Fa) return e;
|
|
4538
|
+
let t = e.slice(0, Fa), n = t.lastIndexOf("\n");
|
|
3833
4539
|
return n > 0 ? t.slice(0, n) : t;
|
|
3834
4540
|
}
|
|
3835
|
-
function
|
|
4541
|
+
function La(e) {
|
|
3836
4542
|
if (!e?.trim()) return null;
|
|
3837
|
-
let t =
|
|
3838
|
-
for (let { lang: e, re: r, w: i } of
|
|
4543
|
+
let t = Ia(e.trim()), n = /* @__PURE__ */ new Map();
|
|
4544
|
+
for (let { lang: e, re: r, w: i } of Pa) r.test(t) && n.set(e, (n.get(e) || 0) + i);
|
|
3839
4545
|
if (n.size === 0) return null;
|
|
3840
|
-
for (let [e, t] of
|
|
4546
|
+
for (let [e, t] of Ma) {
|
|
3841
4547
|
let r = n.get(e);
|
|
3842
4548
|
r && n.set(e, r + (n.get(t) || 0));
|
|
3843
4549
|
}
|
|
3844
4550
|
let r = [...n.entries()].sort((e, t) => t[1] - e[1]), [i, a] = r[0], o = r[1]?.[1] ?? 0;
|
|
3845
|
-
return a <
|
|
4551
|
+
return a < Aa || a - o < ja ? null : i;
|
|
3846
4552
|
}
|
|
3847
4553
|
//#endregion
|
|
3848
4554
|
//#region src/js/module/Editor.js
|
|
3849
|
-
var
|
|
4555
|
+
var Ra = /<(b|i|u|s|sup|sub|strong|em|strike)><\/\1>|<span(?: style="[^"]*")?><\/span>/g;
|
|
4556
|
+
function za(e) {
|
|
4557
|
+
let t;
|
|
4558
|
+
do
|
|
4559
|
+
t = e, e = e.replace(Ra, "");
|
|
4560
|
+
while (e !== t);
|
|
4561
|
+
return e;
|
|
4562
|
+
}
|
|
4563
|
+
var Ba = /* @__PURE__ */ new Set([
|
|
3850
4564
|
"PRE",
|
|
3851
4565
|
"BLOCKQUOTE",
|
|
3852
4566
|
"TABLE",
|
|
@@ -3854,7 +4568,7 @@ var mi = /* @__PURE__ */ new Set([
|
|
|
3854
4568
|
"UL",
|
|
3855
4569
|
"OL",
|
|
3856
4570
|
"HR"
|
|
3857
|
-
]),
|
|
4571
|
+
]), Va = {
|
|
3858
4572
|
undo: { run: (e) => e.undo() },
|
|
3859
4573
|
redo: { run: (e) => e.redo() },
|
|
3860
4574
|
bold: { run: (e) => e.bold() },
|
|
@@ -3869,19 +4583,21 @@ var mi = /* @__PURE__ */ new Set([
|
|
|
3869
4583
|
run: (e) => e.context.invoke("clipboard.setForcePlain", !0),
|
|
3870
4584
|
preventDefault: !1
|
|
3871
4585
|
}
|
|
3872
|
-
},
|
|
4586
|
+
}, Ha = class {
|
|
3873
4587
|
constructor(e) {
|
|
3874
4588
|
this.context = e, this.options = e.options, this._history = null, this._disposers = [], this._snapshotTimer = null, this._limitCounter = null;
|
|
3875
4589
|
}
|
|
3876
4590
|
initialize() {
|
|
3877
4591
|
let e = this.context.layoutInfo.editable;
|
|
3878
|
-
return this._history = new
|
|
4592
|
+
return this._history = new mi(e, this.options.historyLimit || 100, this.options.historyMaxBytes || 10485760), this._bindEvents(e), this;
|
|
3879
4593
|
}
|
|
3880
4594
|
destroy() {
|
|
3881
4595
|
this._disposers.forEach((e) => e()), this._disposers = [], this._history = null, clearTimeout(this._snapshotTimer), this._snapshotTimer = null;
|
|
3882
4596
|
}
|
|
3883
4597
|
_bindEvents(e) {
|
|
3884
|
-
let t = (e) => this._onKeydown(e), n = () =>
|
|
4598
|
+
let t = (e) => this._onKeydown(e), n = (t) => {
|
|
4599
|
+
t?.isComposing || Ct(e), this.afterCommand();
|
|
4600
|
+
}, r = (e) => this._enforceLimit(e), i = () => {
|
|
3885
4601
|
if (!this.context._alive) return;
|
|
3886
4602
|
let t = globalThis.getSelection();
|
|
3887
4603
|
t?.rangeCount > 0 && e.contains(t.anchorNode) && (this.context.invoke("toolbar.refresh"), this.context.triggerEvent("selectionChange", this.context));
|
|
@@ -3917,18 +4633,18 @@ var mi = /* @__PURE__ */ new Set([
|
|
|
3917
4633
|
}
|
|
3918
4634
|
l ? c.setStart(l, 0) : c.setStartAfter(s), c.collapse(!0), n.removeAllRanges(), n.addRange(c);
|
|
3919
4635
|
}, s = () => this.context.layoutInfo.container.classList.contains("an-disabled");
|
|
3920
|
-
this._disposers.push(
|
|
4636
|
+
this._disposers.push(y(e, "keydown", t), y(e, "beforeinput", r), y(e, "input", n), y(document, "selectionchange", i), y(e, "click", a), y(e, "mouseup", o), y(e, "keyup", o), y(e, "dragstart", (e) => {
|
|
3921
4637
|
if (s()) {
|
|
3922
4638
|
e.preventDefault();
|
|
3923
4639
|
return;
|
|
3924
4640
|
}
|
|
3925
4641
|
let t = e.target;
|
|
3926
4642
|
t && (t.nodeName === "IFRAME" || t.closest(".an-video-wrapper")) && e.preventDefault();
|
|
3927
|
-
}),
|
|
4643
|
+
}), y(e, "drop", (e) => {
|
|
3928
4644
|
s() && e.preventDefault();
|
|
3929
4645
|
}));
|
|
3930
4646
|
let c = null;
|
|
3931
|
-
this._disposers.push(
|
|
4647
|
+
this._disposers.push(y(e, "compositionstart", () => {
|
|
3932
4648
|
let e = globalThis.getSelection();
|
|
3933
4649
|
if (!e?.rangeCount) {
|
|
3934
4650
|
c = null;
|
|
@@ -3939,25 +4655,31 @@ var mi = /* @__PURE__ */ new Set([
|
|
|
3939
4655
|
let e = t;
|
|
3940
4656
|
c = e.closest("sup") ? "superscript" : e.closest("sub") ? "subscript" : null;
|
|
3941
4657
|
}
|
|
3942
|
-
}),
|
|
3943
|
-
let
|
|
3944
|
-
if (c = null, !
|
|
3945
|
-
let
|
|
3946
|
-
if (!
|
|
3947
|
-
let
|
|
3948
|
-
|
|
3949
|
-
let
|
|
3950
|
-
(
|
|
4658
|
+
}), y(e, "compositionend", (t) => {
|
|
4659
|
+
let n = c;
|
|
4660
|
+
if (c = null, !n) return;
|
|
4661
|
+
let r = globalThis.getSelection();
|
|
4662
|
+
if (!r?.rangeCount) return;
|
|
4663
|
+
let i = r.getRangeAt(0).startContainer;
|
|
4664
|
+
i.nodeType === Node.TEXT_NODE && (i = i.parentElement);
|
|
4665
|
+
let a = i;
|
|
4666
|
+
if (!(n === "superscript" ? a?.closest("sup") : a?.closest("sub"))) {
|
|
4667
|
+
let i = r.getRangeAt(0), a = (t?.data || "").length, o = i.startContainer;
|
|
4668
|
+
if (a && o.nodeType === Node.TEXT_NODE && i.startOffset >= a) {
|
|
4669
|
+
let t = document.createRange();
|
|
4670
|
+
t.setStart(o, i.startOffset - a), t.setEnd(o, i.startOffset), r.removeAllRanges(), r.addRange(t), k(n, !0, e), globalThis.getSelection()?.collapseToEnd();
|
|
4671
|
+
}
|
|
4672
|
+
}
|
|
3951
4673
|
}));
|
|
3952
4674
|
}
|
|
3953
4675
|
_onKeydown(e) {
|
|
3954
4676
|
let t = this.context.layoutInfo.editable;
|
|
3955
|
-
|
|
4677
|
+
ki(e, t, this.options) || this._runShortcut(e);
|
|
3956
4678
|
}
|
|
3957
4679
|
_runShortcut(e) {
|
|
3958
4680
|
if (!e.ctrlKey && !e.metaKey && !e.altKey) return !1;
|
|
3959
4681
|
for (let t of this.getKeyBindings()) {
|
|
3960
|
-
if (!
|
|
4682
|
+
if (!bi(e, t.parsed)) continue;
|
|
3961
4683
|
let { command: n } = t, r = typeof n == "string" ? n : t.combo;
|
|
3962
4684
|
if (this.context.triggerEvent("beforeCommand", {
|
|
3963
4685
|
name: r,
|
|
@@ -3965,20 +4687,20 @@ var mi = /* @__PURE__ */ new Set([
|
|
|
3965
4687
|
event: e
|
|
3966
4688
|
}) === !1) return e.preventDefault(), !0;
|
|
3967
4689
|
if (typeof n == "function") return n(this.context, e) !== !1 && e.preventDefault(), !0;
|
|
3968
|
-
let i =
|
|
4690
|
+
let i = Va[n];
|
|
3969
4691
|
if (i) return i.preventDefault !== !1 && e.preventDefault(), i.run(this), !0;
|
|
3970
|
-
let a =
|
|
4692
|
+
let a = Fn(n, this.options);
|
|
3971
4693
|
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);
|
|
3972
4694
|
}
|
|
3973
4695
|
return !1;
|
|
3974
4696
|
}
|
|
3975
4697
|
getKeyBindings() {
|
|
3976
|
-
return (!this._keyBindings || this._keyMapSource !== this.options.keyMap) && (this._keyMapSource = this.options.keyMap, this._keyBindings =
|
|
4698
|
+
return (!this._keyBindings || this._keyMapSource !== this.options.keyMap) && (this._keyMapSource = this.options.keyMap, this._keyBindings = xi(this.options.keyMap)), this._keyBindings;
|
|
3977
4699
|
}
|
|
3978
4700
|
_enforceLimit(e) {
|
|
3979
4701
|
let t = this.options.maxChars || 0, n = this.options.maxWords || 0;
|
|
3980
4702
|
if (!t && !n) return;
|
|
3981
|
-
this._limitCounter ??= new
|
|
4703
|
+
this._limitCounter ??= new Fi();
|
|
3982
4704
|
let r = e.inputType || "";
|
|
3983
4705
|
if (r.startsWith("delete") || r === "historyUndo" || r === "historyRedo" || r === "insertFromPaste" || r === "insertFromDrop" || !r.startsWith("insert")) return;
|
|
3984
4706
|
let { words: i, chars: a } = this._limitCounter.counts(this.context.layoutInfo.editable);
|
|
@@ -4005,7 +4727,7 @@ var mi = /* @__PURE__ */ new Set([
|
|
|
4005
4727
|
let e = this.context.layoutInfo.editable;
|
|
4006
4728
|
if (!e) return;
|
|
4007
4729
|
let t = e.lastElementChild;
|
|
4008
|
-
if (t &&
|
|
4730
|
+
if (t && Ba.has(t.nodeName)) {
|
|
4009
4731
|
let t = document.createElement("p");
|
|
4010
4732
|
t.innerHTML = "<br>", e.appendChild(t);
|
|
4011
4733
|
}
|
|
@@ -4014,11 +4736,11 @@ var mi = /* @__PURE__ */ new Set([
|
|
|
4014
4736
|
this.context.layoutInfo.editable.focus();
|
|
4015
4737
|
}
|
|
4016
4738
|
getHTML() {
|
|
4017
|
-
let e = this.context.layoutInfo.editable.innerHTML.replaceAll("", "");
|
|
4739
|
+
let e = za(this.context.layoutInfo.editable.innerHTML.replaceAll("", ""));
|
|
4018
4740
|
return this.context.invoke("clipboard.resolveImages", e) ?? e;
|
|
4019
4741
|
}
|
|
4020
4742
|
setHTML(e) {
|
|
4021
|
-
let t =
|
|
4743
|
+
let t = Kr(e, {
|
|
4022
4744
|
allowIframes: !0,
|
|
4023
4745
|
iframeHosts: this.options.iframeHosts
|
|
4024
4746
|
});
|
|
@@ -4041,16 +4763,16 @@ var mi = /* @__PURE__ */ new Set([
|
|
|
4041
4763
|
return !e && !t;
|
|
4042
4764
|
}
|
|
4043
4765
|
insertHTML(e) {
|
|
4044
|
-
e && (
|
|
4766
|
+
e && (P("insertHTML", z(e)), this.afterCommand());
|
|
4045
4767
|
}
|
|
4046
4768
|
insertText(e) {
|
|
4047
|
-
e && (
|
|
4769
|
+
e && (P("insertText", e), this.afterCommand());
|
|
4048
4770
|
}
|
|
4049
4771
|
setMarkdown(e) {
|
|
4050
|
-
this.setHTML(
|
|
4772
|
+
this.setHTML(ta(e || ""));
|
|
4051
4773
|
}
|
|
4052
4774
|
getMarkdown() {
|
|
4053
|
-
return
|
|
4775
|
+
return Li(this.getHTML());
|
|
4054
4776
|
}
|
|
4055
4777
|
undo() {
|
|
4056
4778
|
this._history && (this._flushPendingSnapshot(), this._history.undo(), this.context.invoke("toolbar.refresh"), this.context.invoke("statusbar.update"), this.context.triggerEvent("change", this.getHTML()));
|
|
@@ -4080,63 +4802,63 @@ var mi = /* @__PURE__ */ new Set([
|
|
|
4080
4802
|
return !e || !this._history ? !1 : (this._history._restoreSelection(e), !0);
|
|
4081
4803
|
}
|
|
4082
4804
|
bold() {
|
|
4083
|
-
|
|
4805
|
+
$t(), this.afterCommand();
|
|
4084
4806
|
}
|
|
4085
4807
|
italic() {
|
|
4086
|
-
|
|
4808
|
+
en(), this.afterCommand();
|
|
4087
4809
|
}
|
|
4088
4810
|
underline() {
|
|
4089
|
-
|
|
4811
|
+
tn(), this.afterCommand();
|
|
4090
4812
|
}
|
|
4091
4813
|
strikethrough() {
|
|
4092
|
-
|
|
4814
|
+
nn(), this.afterCommand();
|
|
4093
4815
|
}
|
|
4094
4816
|
superscript() {
|
|
4095
|
-
|
|
4817
|
+
rn(), this.afterCommand();
|
|
4096
4818
|
}
|
|
4097
4819
|
subscript() {
|
|
4098
|
-
|
|
4820
|
+
an(), this.afterCommand();
|
|
4099
4821
|
}
|
|
4100
4822
|
justifyLeft() {
|
|
4101
|
-
|
|
4823
|
+
dn(), this.afterCommand();
|
|
4102
4824
|
}
|
|
4103
4825
|
justifyCenter() {
|
|
4104
|
-
|
|
4826
|
+
fn(), this.afterCommand();
|
|
4105
4827
|
}
|
|
4106
4828
|
justifyRight() {
|
|
4107
|
-
|
|
4829
|
+
pn(), this.afterCommand();
|
|
4108
4830
|
}
|
|
4109
4831
|
justifyFull() {
|
|
4110
|
-
|
|
4832
|
+
mn(), this.afterCommand();
|
|
4111
4833
|
}
|
|
4112
4834
|
indent() {
|
|
4113
|
-
|
|
4835
|
+
hn(), this.afterCommand();
|
|
4114
4836
|
}
|
|
4115
4837
|
outdent() {
|
|
4116
|
-
|
|
4838
|
+
_n(), this.afterCommand();
|
|
4117
4839
|
}
|
|
4118
4840
|
insertUL() {
|
|
4119
|
-
|
|
4841
|
+
xn(), this.afterCommand();
|
|
4120
4842
|
}
|
|
4121
4843
|
insertOL() {
|
|
4122
|
-
|
|
4844
|
+
Sn(), this.afterCommand();
|
|
4123
4845
|
}
|
|
4124
4846
|
inlineCode() {
|
|
4125
|
-
|
|
4847
|
+
wn(this.context.layoutInfo.editable), this.afterCommand();
|
|
4126
4848
|
}
|
|
4127
4849
|
toggleChecklist() {
|
|
4128
|
-
|
|
4850
|
+
On(), this.afterCommand();
|
|
4129
4851
|
}
|
|
4130
4852
|
print() {
|
|
4131
4853
|
this.context.print();
|
|
4132
4854
|
}
|
|
4133
4855
|
formatBlock(e) {
|
|
4134
|
-
if (
|
|
4856
|
+
if (un(e), e === "pre") {
|
|
4135
4857
|
let e = globalThis.getSelection();
|
|
4136
4858
|
if (e?.rangeCount > 0) {
|
|
4137
4859
|
let t = e.getRangeAt(0).commonAncestorContainer, n = t.nodeType === 1 ? t.closest("pre") : t.parentElement?.closest("pre");
|
|
4138
4860
|
if (n && !n.dataset.language) {
|
|
4139
|
-
let e =
|
|
4861
|
+
let e = La(n.textContent || "");
|
|
4140
4862
|
if (e) {
|
|
4141
4863
|
this.context.invoke("codeTooltip.applyLanguage", n, e);
|
|
4142
4864
|
return;
|
|
@@ -4147,34 +4869,30 @@ var mi = /* @__PURE__ */ new Set([
|
|
|
4147
4869
|
this.afterCommand();
|
|
4148
4870
|
}
|
|
4149
4871
|
foreColor(e) {
|
|
4150
|
-
|
|
4872
|
+
on(e), this.afterCommand();
|
|
4151
4873
|
}
|
|
4152
4874
|
backColor(e) {
|
|
4153
|
-
|
|
4875
|
+
sn(e), this.afterCommand();
|
|
4154
4876
|
}
|
|
4155
4877
|
fontName(e) {
|
|
4156
|
-
|
|
4878
|
+
cn(e), this.afterCommand();
|
|
4157
4879
|
}
|
|
4158
4880
|
fontSize(e) {
|
|
4159
|
-
|
|
4881
|
+
ln(e, this.context.layoutInfo.editable), this.afterCommand();
|
|
4160
4882
|
}
|
|
4161
4883
|
insertHr() {
|
|
4162
|
-
|
|
4884
|
+
P("insertHorizontalRule"), this.afterCommand();
|
|
4163
4885
|
}
|
|
4164
4886
|
insertLink(e, t, n = !1) {
|
|
4165
4887
|
let r = globalThis.getSelection();
|
|
4166
4888
|
if (!r || r.rangeCount === 0) return;
|
|
4167
|
-
let i =
|
|
4889
|
+
let i = Qr(e);
|
|
4168
4890
|
if (!i) return;
|
|
4169
4891
|
let a = this._newTabRel();
|
|
4170
|
-
if (r.toString().trim().length > 0)
|
|
4171
|
-
|
|
4172
|
-
let e = this._getClosestAnchor();
|
|
4173
|
-
e && (e.setAttribute("target", "_blank"), e.setAttribute("rel", a));
|
|
4174
|
-
}
|
|
4175
|
-
} else {
|
|
4892
|
+
if (r.toString().trim().length > 0) for (let e of Et(i, this.context.layoutInfo.editable)) n && (e.setAttribute("target", "_blank"), e.setAttribute("rel", a));
|
|
4893
|
+
else {
|
|
4176
4894
|
let e = this._escapeAttr(t || i), r = n ? ` target="_blank" rel="${this._escapeAttr(a)}"` : "";
|
|
4177
|
-
|
|
4895
|
+
P("insertHTML", `<a href="${this._escapeAttr(i)}"${r}>${e}</a>`);
|
|
4178
4896
|
}
|
|
4179
4897
|
this.afterCommand();
|
|
4180
4898
|
}
|
|
@@ -4183,41 +4901,31 @@ var mi = /* @__PURE__ */ new Set([
|
|
|
4183
4901
|
return t.add("noopener"), [...t].join(" ");
|
|
4184
4902
|
}
|
|
4185
4903
|
unlink() {
|
|
4186
|
-
|
|
4904
|
+
Dt(this.context.layoutInfo.editable), this.afterCommand();
|
|
4187
4905
|
}
|
|
4188
4906
|
insertImage(e, t = "", n = "") {
|
|
4189
|
-
let r =
|
|
4907
|
+
let r = Qr(e, { allowData: !0 });
|
|
4190
4908
|
if (!r) return;
|
|
4191
4909
|
let i = {
|
|
4192
4910
|
left: "float:left;margin:0 1em 1em 0",
|
|
4193
4911
|
center: "display:block;margin:0 auto",
|
|
4194
4912
|
right: "float:right;margin:0 0 1em 1em"
|
|
4195
4913
|
}[n] || "", a = i ? ` style="${i}"` : "";
|
|
4196
|
-
|
|
4914
|
+
P("insertHTML", `<img src="${this._escapeAttr(r)}" alt="${this._escapeAttr(t)}" class="an-image"${a}>`), this.afterCommand();
|
|
4197
4915
|
}
|
|
4198
4916
|
insertVideo(e) {
|
|
4199
|
-
e && (
|
|
4917
|
+
e && (P("insertHTML", z(e, {
|
|
4200
4918
|
allowIframes: !0,
|
|
4201
4919
|
iframeHosts: this.options.iframeHosts
|
|
4202
4920
|
})), this.afterCommand());
|
|
4203
4921
|
}
|
|
4204
4922
|
insertTable(e, t) {
|
|
4205
|
-
|
|
4206
|
-
}
|
|
4207
|
-
_getClosestAnchor() {
|
|
4208
|
-
let e = globalThis.getSelection();
|
|
4209
|
-
if (!e || e.rangeCount === 0) return null;
|
|
4210
|
-
let t = e.getRangeAt(0).startContainer;
|
|
4211
|
-
for (; t;) {
|
|
4212
|
-
if (t.nodeName === "A") return t;
|
|
4213
|
-
t = t.parentNode;
|
|
4214
|
-
}
|
|
4215
|
-
return null;
|
|
4923
|
+
gi(e, t, { headerRow: this.context.options.tableHeaderRow }), this.afterCommand();
|
|
4216
4924
|
}
|
|
4217
4925
|
_escapeAttr(e) {
|
|
4218
4926
|
return String(e ?? "").replaceAll("&", "&").replaceAll("\"", """).replaceAll("<", "<").replaceAll(">", ">");
|
|
4219
4927
|
}
|
|
4220
|
-
},
|
|
4928
|
+
}, Ua = Object.freeze([
|
|
4221
4929
|
"#000000",
|
|
4222
4930
|
"#434343",
|
|
4223
4931
|
"#666666",
|
|
@@ -4243,13 +4951,13 @@ var mi = /* @__PURE__ */ new Set([
|
|
|
4243
4951
|
"#d9d2e9",
|
|
4244
4952
|
"#ead1dc"
|
|
4245
4953
|
]);
|
|
4246
|
-
function
|
|
4247
|
-
let t = Array.isArray(e?.colorPalette) && e.colorPalette.length ? e.colorPalette :
|
|
4954
|
+
function Wa(e) {
|
|
4955
|
+
let t = Array.isArray(e?.colorPalette) && e.colorPalette.length ? e.colorPalette : Ua, n = Array.isArray(e?.colorSwatches) ? e.colorSwatches : [];
|
|
4248
4956
|
return [...new Set([...n, ...t].filter((e) => typeof e == "string" && e))];
|
|
4249
4957
|
}
|
|
4250
4958
|
//#endregion
|
|
4251
4959
|
//#region src/js/module/Toolbar.js
|
|
4252
|
-
var Y = null,
|
|
4960
|
+
var Y = null, Ga = "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" ${Ga} style="display:block">${e}</svg>`, Z = /* @__PURE__ */ new Map([
|
|
4253
4961
|
["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\"/>")],
|
|
4254
4962
|
["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\"/>")],
|
|
4255
4963
|
["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\"/>")],
|
|
@@ -4286,7 +4994,7 @@ var Y = null, yi = "stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"
|
|
|
4286
4994
|
["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\"/>")],
|
|
4287
4995
|
["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\"/>")],
|
|
4288
4996
|
["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\"/>")]
|
|
4289
|
-
]),
|
|
4997
|
+
]), Ka = /* @__PURE__ */ new Map([
|
|
4290
4998
|
["bold", "fa-bold"],
|
|
4291
4999
|
["italic", "fa-italic"],
|
|
4292
5000
|
["underline", "fa-underline"],
|
|
@@ -4320,17 +5028,17 @@ var Y = null, yi = "stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"
|
|
|
4320
5028
|
["inline-code", "fa-code"],
|
|
4321
5029
|
["checklist", "fa-list-check"],
|
|
4322
5030
|
["print", "fa-print"]
|
|
4323
|
-
]),
|
|
5031
|
+
]), qa = {
|
|
4324
5032
|
fontFamily: "fontFamilies",
|
|
4325
5033
|
fontSize: "fontSizes",
|
|
4326
5034
|
lineHeight: "lineHeights",
|
|
4327
5035
|
paragraphStyle: "paragraphStyles"
|
|
4328
|
-
},
|
|
5036
|
+
}, Ja = class {
|
|
4329
5037
|
constructor(e) {
|
|
4330
5038
|
this.context = e, this.options = e.options, this.el = null, this._disposers = [], this._colorPickerClosers = [], this._refreshRaf = null;
|
|
4331
5039
|
}
|
|
4332
5040
|
initialize() {
|
|
4333
|
-
return this.el =
|
|
5041
|
+
return this.el = v("div", {
|
|
4334
5042
|
class: "an-toolbar",
|
|
4335
5043
|
role: "toolbar",
|
|
4336
5044
|
"aria-orientation": "horizontal",
|
|
@@ -4341,7 +5049,7 @@ var Y = null, yi = "stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"
|
|
|
4341
5049
|
this._refreshRaf && cancelAnimationFrame(this._refreshRaf), this._refreshRaf = null, this._disposers.forEach((e) => e()), this._disposers = [], this.el?.parentNode && this.el.remove(), this.el = null;
|
|
4342
5050
|
}
|
|
4343
5051
|
_resolveBtn(e) {
|
|
4344
|
-
return typeof e == "string" ?
|
|
5052
|
+
return typeof e == "string" ? Fn(e, this.options) : e;
|
|
4345
5053
|
}
|
|
4346
5054
|
_allow(e, t) {
|
|
4347
5055
|
return this.context.triggerEvent?.("beforeCommand", {
|
|
@@ -4353,7 +5061,7 @@ var Y = null, yi = "stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"
|
|
|
4353
5061
|
_buildButtons() {
|
|
4354
5062
|
let e = this.options.toolbar || [], t = document.createDocumentFragment();
|
|
4355
5063
|
e.forEach((e) => {
|
|
4356
|
-
let n =
|
|
5064
|
+
let n = v("div", { class: "an-btn-group" });
|
|
4357
5065
|
e.forEach((e) => {
|
|
4358
5066
|
let t = this._resolveBtn(e);
|
|
4359
5067
|
if (!t) {
|
|
@@ -4366,7 +5074,7 @@ var Y = null, yi = "stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"
|
|
|
4366
5074
|
}), this.el.appendChild(t);
|
|
4367
5075
|
}
|
|
4368
5076
|
_createGridPicker(e) {
|
|
4369
|
-
let t =
|
|
5077
|
+
let t = v("div", { class: "an-table-picker-wrap" }), n = v("button", {
|
|
4370
5078
|
type: "button",
|
|
4371
5079
|
class: this.options.useBootstrap ? this.options.toolbarButtonClass || "btn btn-sm btn-light" : "an-btn",
|
|
4372
5080
|
title: this.context.locale.toolbar[e.name] || e.tooltip || "",
|
|
@@ -4375,16 +5083,16 @@ var Y = null, yi = "stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"
|
|
|
4375
5083
|
"aria-haspopup": "true",
|
|
4376
5084
|
"aria-expanded": "false"
|
|
4377
5085
|
});
|
|
4378
|
-
n.innerHTML =
|
|
4379
|
-
let r =
|
|
5086
|
+
n.innerHTML = zn(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>");
|
|
5087
|
+
let r = v("div", {
|
|
4380
5088
|
class: "an-table-picker-popup",
|
|
4381
5089
|
role: "dialog",
|
|
4382
5090
|
"aria-label": this.context.locale.a11y?.tableSize || "Select table size"
|
|
4383
|
-
}), i =
|
|
5091
|
+
}), i = v("div", { class: "an-table-grid" }), a = v("div", { class: "an-table-label" });
|
|
4384
5092
|
a.textContent = this.context.locale.toolbar.insertTableLabel || "Insert Table";
|
|
4385
5093
|
let o = [];
|
|
4386
5094
|
for (let e = 1; e <= 10; e++) for (let t = 1; t <= 10; t++) {
|
|
4387
|
-
let n =
|
|
5095
|
+
let n = v("div", {
|
|
4388
5096
|
class: "an-table-cell",
|
|
4389
5097
|
"data-row": String(e),
|
|
4390
5098
|
"data-col": String(t)
|
|
@@ -4405,12 +5113,12 @@ var Y = null, yi = "stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"
|
|
|
4405
5113
|
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");
|
|
4406
5114
|
}, u = () => {
|
|
4407
5115
|
s = !1, r.style.display = "none", n.setAttribute("aria-expanded", "false"), c(0, 0);
|
|
4408
|
-
}, d =
|
|
5116
|
+
}, d = y(n, "click", (e) => {
|
|
4409
5117
|
e.stopPropagation(), s ? u() : l();
|
|
4410
|
-
}), f =
|
|
5118
|
+
}), f = y(i, "mouseover", (e) => {
|
|
4411
5119
|
let t = e.target?.closest(".an-table-cell");
|
|
4412
5120
|
t && c(+t.dataset.row, +t.dataset.col);
|
|
4413
|
-
}),
|
|
5121
|
+
}), ee = y(i, "mouseleave", () => c(0, 0)), p = y(i, "click", (t) => {
|
|
4414
5122
|
let n = t.target?.closest(".an-table-cell");
|
|
4415
5123
|
if (!n) return;
|
|
4416
5124
|
let r = +n.dataset.row, i = +n.dataset.col;
|
|
@@ -4418,25 +5126,25 @@ var Y = null, yi = "stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"
|
|
|
4418
5126
|
rows: r,
|
|
4419
5127
|
cols: i
|
|
4420
5128
|
}) && (this.context.invoke("editor.focus"), e.action(this.context, r, i));
|
|
4421
|
-
}),
|
|
5129
|
+
}), m = y(document, "click", () => {
|
|
4422
5130
|
s && u();
|
|
4423
5131
|
});
|
|
4424
|
-
return this._disposers.push(d, f, p, m,
|
|
5132
|
+
return this._disposers.push(d, f, ee, p, m, () => {
|
|
4425
5133
|
r.parentNode && r.remove();
|
|
4426
|
-
}), t.appendChild(n),
|
|
5134
|
+
}), t.appendChild(n), Te(this.context).appendChild(r), t;
|
|
4427
5135
|
}
|
|
4428
5136
|
_createColorPicker(e) {
|
|
4429
|
-
let t = e.defaultColor || "#000000", n =
|
|
5137
|
+
let t = e.defaultColor || "#000000", n = v("div", { class: "an-color-picker-wrap" }), r = this.options.useBootstrap ? this.options.toolbarButtonClass || "btn btn-sm btn-light" : "an-btn", i = v("button", {
|
|
4430
5138
|
type: "button",
|
|
4431
5139
|
class: `${r} an-color-btn`,
|
|
4432
5140
|
title: this.context.locale.toolbar[e.name] || e.tooltip || "",
|
|
4433
5141
|
"data-btn": e.name,
|
|
4434
5142
|
"aria-label": this.context.locale.toolbar[e.name] || e.tooltip || e.name
|
|
4435
5143
|
}), 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 =
|
|
4437
|
-
let s =
|
|
5144
|
+
i.innerHTML = zn(this.options, [e.name, e.icon]) ?? o;
|
|
5145
|
+
let s = v("span", { class: "an-color-strip" });
|
|
4438
5146
|
s.style.background = t, i.appendChild(s);
|
|
4439
|
-
let c =
|
|
5147
|
+
let c = v("button", {
|
|
4440
5148
|
type: "button",
|
|
4441
5149
|
class: `${r} an-color-arrow`,
|
|
4442
5150
|
title: e.name === "foreColor" ? this.context.locale.toolbar.chooseTextColor || "Choose text color" : this.context.locale.toolbar.chooseHighlightColor || "Choose highlight color",
|
|
@@ -4444,81 +5152,81 @@ var Y = null, yi = "stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"
|
|
|
4444
5152
|
"aria-expanded": "false"
|
|
4445
5153
|
});
|
|
4446
5154
|
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>";
|
|
4447
|
-
let l =
|
|
5155
|
+
let l = v("div", { class: "an-color-popup" });
|
|
4448
5156
|
l.style.display = "none";
|
|
4449
|
-
let u =
|
|
4450
|
-
|
|
4451
|
-
let t =
|
|
5157
|
+
let u = v("div", { class: "an-color-swatches" });
|
|
5158
|
+
Wa(this.options).forEach((e) => {
|
|
5159
|
+
let t = v("div", {
|
|
4452
5160
|
class: "an-color-swatch",
|
|
4453
5161
|
title: e,
|
|
4454
5162
|
"data-color": e
|
|
4455
5163
|
});
|
|
4456
5164
|
t.style.background = e, u.appendChild(t);
|
|
4457
5165
|
});
|
|
4458
|
-
let d =
|
|
5166
|
+
let d = v("div", { class: "an-color-custom" }), f = v("input", {
|
|
4459
5167
|
type: "color",
|
|
4460
5168
|
value: t,
|
|
4461
5169
|
title: this.context.locale.toolbar.customColor || "Custom color"
|
|
4462
|
-
}),
|
|
4463
|
-
d.appendChild(f), d.appendChild(
|
|
4464
|
-
let
|
|
5170
|
+
}), ee = v("span", {}, [this.context.locale.toolbar.customColor || "Custom color"]);
|
|
5171
|
+
d.appendChild(f), d.appendChild(ee), l.appendChild(u), l.appendChild(d);
|
|
5172
|
+
let p = !1, m = null, te = () => {
|
|
4465
5173
|
let e = globalThis.getSelection();
|
|
4466
|
-
|
|
4467
|
-
},
|
|
4468
|
-
if (
|
|
5174
|
+
m = e?.rangeCount ? e.getRangeAt(0).cloneRange() : null;
|
|
5175
|
+
}, ne = () => {
|
|
5176
|
+
if (m) try {
|
|
4469
5177
|
let e = globalThis.getSelection();
|
|
4470
5178
|
if (!e) return;
|
|
4471
|
-
e.removeAllRanges(), e.addRange(
|
|
5179
|
+
e.removeAllRanges(), e.addRange(m);
|
|
4472
5180
|
} catch {}
|
|
4473
|
-
},
|
|
5181
|
+
}, re = () => {
|
|
4474
5182
|
this._colorPickerClosers.forEach((e) => {
|
|
4475
|
-
e !==
|
|
4476
|
-
}),
|
|
5183
|
+
e !== h && e();
|
|
5184
|
+
}), te(), p = !0;
|
|
4477
5185
|
let e = c.getBoundingClientRect(), t = e.left;
|
|
4478
5186
|
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");
|
|
4479
|
-
},
|
|
4480
|
-
|
|
4481
|
-
},
|
|
5187
|
+
}, h = () => {
|
|
5188
|
+
p = !1, l.style.display = "none", l.style.top = "", l.style.left = "", c.setAttribute("aria-expanded", "false");
|
|
5189
|
+
}, ie = (n) => {
|
|
4482
5190
|
if (t = n, s.style.background = n, f.value = n, !this._allow(e.name, n)) {
|
|
4483
|
-
|
|
5191
|
+
h();
|
|
4484
5192
|
return;
|
|
4485
5193
|
}
|
|
4486
|
-
|
|
4487
|
-
},
|
|
4488
|
-
n.preventDefault(), this._allow(e.name, t) && (
|
|
4489
|
-
}),
|
|
5194
|
+
ne(), e.action(this.context, n), this.context.invoke("editor.afterCommand"), h();
|
|
5195
|
+
}, ae = y(i, "click", (n) => {
|
|
5196
|
+
n.preventDefault(), this._allow(e.name, t) && (ne(), e.action(this.context, t), this.context.invoke("editor.afterCommand"));
|
|
5197
|
+
}), oe = y(c, "mousedown", (e) => {
|
|
4490
5198
|
e.preventDefault();
|
|
4491
|
-
}),
|
|
4492
|
-
e.stopPropagation(),
|
|
4493
|
-
}),
|
|
5199
|
+
}), se = y(c, "click", (e) => {
|
|
5200
|
+
e.stopPropagation(), p ? h() : re();
|
|
5201
|
+
}), ce = y(u, "mousedown", (e) => {
|
|
4494
5202
|
e.preventDefault();
|
|
4495
|
-
}),
|
|
5203
|
+
}), g = y(u, "click", (e) => {
|
|
4496
5204
|
let t = e.target?.closest(".an-color-swatch");
|
|
4497
|
-
t &&
|
|
4498
|
-
}),
|
|
4499
|
-
|
|
4500
|
-
}),
|
|
4501
|
-
|
|
4502
|
-
}),
|
|
4503
|
-
|
|
5205
|
+
t && ie(t.dataset.color);
|
|
5206
|
+
}), le = y(f, "change", (e) => {
|
|
5207
|
+
ie(e.target.value);
|
|
5208
|
+
}), ue = y(document, "click", (e) => {
|
|
5209
|
+
p && !n.contains(e.target) && !l.contains(e.target) && h();
|
|
5210
|
+
}), de = y(l, "click", (e) => e.stopPropagation()), _ = () => {
|
|
5211
|
+
p && h();
|
|
4504
5212
|
};
|
|
4505
|
-
return document.addEventListener("scroll",
|
|
5213
|
+
return document.addEventListener("scroll", _, {
|
|
4506
5214
|
passive: !0,
|
|
4507
5215
|
capture: !0
|
|
4508
|
-
}), globalThis.addEventListener("resize",
|
|
5216
|
+
}), globalThis.addEventListener("resize", _, { passive: !0 }), this._disposers.push(ae, oe, se, ce, g, le, ue, de, () => document.removeEventListener("scroll", _, { capture: !0 }), () => globalThis.removeEventListener("resize", _), () => {
|
|
4509
5217
|
l.parentNode && l.remove();
|
|
4510
|
-
}), this._colorPickerClosers.push(
|
|
4511
|
-
let e = this._colorPickerClosers.indexOf(
|
|
5218
|
+
}), this._colorPickerClosers.push(h), this._disposers.push(() => {
|
|
5219
|
+
let e = this._colorPickerClosers.indexOf(h);
|
|
4512
5220
|
e !== -1 && this._colorPickerClosers.splice(e, 1);
|
|
4513
|
-
}), n.appendChild(i), n.appendChild(c),
|
|
5221
|
+
}), n.appendChild(i), n.appendChild(c), Te(this.context).appendChild(l), n;
|
|
4514
5222
|
}
|
|
4515
5223
|
_createSelect(e) {
|
|
4516
|
-
let t =
|
|
5224
|
+
let t = qa[e.name], n = t ? this.options[t] : null, r = Array.isArray(n) && (n.length || e.name === "fontFamily") ? n : e.items || [], i = v("select", {
|
|
4517
5225
|
class: e.selectClass ? `an-select ${e.selectClass}` : "an-select",
|
|
4518
5226
|
title: this.context.locale.toolbar[e.name] || e.tooltip || "",
|
|
4519
5227
|
"data-btn": e.name,
|
|
4520
5228
|
"aria-label": this.context.locale.toolbar[e.name] || e.tooltip || e.name
|
|
4521
|
-
}), a =
|
|
5229
|
+
}), a = v("option", {
|
|
4522
5230
|
value: "",
|
|
4523
5231
|
disabled: "",
|
|
4524
5232
|
hidden: ""
|
|
@@ -4528,13 +5236,13 @@ var Y = null, yi = "stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"
|
|
|
4528
5236
|
r = typeof t == "object" ? e.name === "paragraphStyle" && this.context.locale.toolbar.paragraphItems?.[t.value] || t.label : t;
|
|
4529
5237
|
let a = typeof t == "object" && !!t.disabled, o = { value: n };
|
|
4530
5238
|
a && (o.disabled = "");
|
|
4531
|
-
let s =
|
|
5239
|
+
let s = v("option", o, [r]);
|
|
4532
5240
|
e.name === "fontFamily" && !a && (s.style.fontFamily = n), i.appendChild(s);
|
|
4533
5241
|
});
|
|
4534
|
-
let o = null, s =
|
|
5242
|
+
let o = null, s = y(i, "mousedown", () => {
|
|
4535
5243
|
let e = globalThis.getSelection();
|
|
4536
5244
|
o = e?.rangeCount ? e.getRangeAt(0).cloneRange() : null;
|
|
4537
|
-
}), c =
|
|
5245
|
+
}), c = y(i, "change", (t) => {
|
|
4538
5246
|
let n = t.target.value, r = t.target.options[t.target.selectedIndex];
|
|
4539
5247
|
if (!(!n || r.disabled)) {
|
|
4540
5248
|
if (this.context.invoke("editor.focus"), o) try {
|
|
@@ -4547,20 +5255,20 @@ var Y = null, yi = "stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"
|
|
|
4547
5255
|
return this._disposers.push(s, c), i;
|
|
4548
5256
|
}
|
|
4549
5257
|
_createButton(e) {
|
|
4550
|
-
let t =
|
|
5258
|
+
let t = v("button", {
|
|
4551
5259
|
type: "button",
|
|
4552
5260
|
class: `${this.options.useBootstrap ? this.options.toolbarButtonClass || "btn btn-sm btn-light" : "an-btn"}${e.className ? ` ${e.className}` : ""}`,
|
|
4553
5261
|
title: this.context.locale.toolbar[e.name] || e.tooltip || "",
|
|
4554
5262
|
"data-btn": e.name,
|
|
4555
5263
|
"aria-label": this.context.locale.toolbar[e.name] || e.tooltip || e.name,
|
|
4556
5264
|
...typeof e.isActive == "function" ? { "aria-pressed": "false" } : {}
|
|
4557
|
-
}), n = this.options.fontAwesomeClass || "fas", r = this._faReady, i =
|
|
5265
|
+
}), n = this.options.fontAwesomeClass || "fas", r = this._faReady, i = zn(this.options, [e.name, e.icon]);
|
|
4558
5266
|
if (i) t.innerHTML = i;
|
|
4559
5267
|
else if (r) {
|
|
4560
|
-
let r =
|
|
5268
|
+
let r = Ka.get(e.icon) || Ka.get(e.name) || null;
|
|
4561
5269
|
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;
|
|
4562
5270
|
} 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;
|
|
4563
|
-
let a =
|
|
5271
|
+
let a = y(t, "click", (t) => {
|
|
4564
5272
|
t.preventDefault(), this._allow(e.name) && (this.context.invoke("editor.focus"), e.action(this.context), this.context.invoke("editor.afterCommand"), this.refresh());
|
|
4565
5273
|
});
|
|
4566
5274
|
return this._disposers.push(a), t;
|
|
@@ -4578,7 +5286,7 @@ var Y = null, yi = "stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"
|
|
|
4578
5286
|
t.forEach((e) => e.setAttribute("tabindex", e === r ? "0" : "-1"));
|
|
4579
5287
|
}
|
|
4580
5288
|
_initRovingFocus() {
|
|
4581
|
-
this.el && (this._syncRovingTabindex(), this._disposers.push(
|
|
5289
|
+
this.el && (this._syncRovingTabindex(), this._disposers.push(y(this.el, "keydown", (e) => this._onToolbarKeydown(e)), y(this.el, "focusin", (e) => {
|
|
4582
5290
|
let t = e.target?.closest?.("button, select");
|
|
4583
5291
|
t && this._syncRovingTabindex(t);
|
|
4584
5292
|
})));
|
|
@@ -4644,29 +5352,29 @@ var Y = null, yi = "stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"
|
|
|
4644
5352
|
};
|
|
4645
5353
|
//#endregion
|
|
4646
5354
|
//#region src/js/module/Statusbar.js
|
|
4647
|
-
function
|
|
5355
|
+
function Ya(e, t, n) {
|
|
4648
5356
|
if (!n) {
|
|
4649
5357
|
e.classList.remove("an-count-warn", "an-count-exceeded");
|
|
4650
5358
|
return;
|
|
4651
5359
|
}
|
|
4652
5360
|
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");
|
|
4653
5361
|
}
|
|
4654
|
-
var
|
|
5362
|
+
var Xa = class {
|
|
4655
5363
|
constructor(e) {
|
|
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
|
|
5364
|
+
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 Fi();
|
|
4657
5365
|
}
|
|
4658
5366
|
initialize() {
|
|
4659
|
-
this.el =
|
|
5367
|
+
this.el = v("div", { class: "an-statusbar" }), this._wordCountEl = v("span", {
|
|
4660
5368
|
class: "an-word-count",
|
|
4661
5369
|
role: "status",
|
|
4662
5370
|
"aria-live": "polite",
|
|
4663
5371
|
"aria-atomic": "true"
|
|
4664
|
-
}), this._charCountEl =
|
|
5372
|
+
}), this._charCountEl = v("span", {
|
|
4665
5373
|
class: "an-char-count",
|
|
4666
5374
|
"aria-live": "polite",
|
|
4667
5375
|
"aria-atomic": "true"
|
|
4668
5376
|
});
|
|
4669
|
-
let e =
|
|
5377
|
+
let e = v("div", {
|
|
4670
5378
|
class: "an-status-info",
|
|
4671
5379
|
"aria-label": this.context.locale.a11y?.statistics || "Editor statistics"
|
|
4672
5380
|
});
|
|
@@ -4676,7 +5384,7 @@ var wi = class {
|
|
|
4676
5384
|
if (!this.el) return;
|
|
4677
5385
|
let e = this.options.resizable !== !1;
|
|
4678
5386
|
if (e && !this._handle) {
|
|
4679
|
-
let e =
|
|
5387
|
+
let e = v("div", {
|
|
4680
5388
|
class: "an-resize-handle",
|
|
4681
5389
|
title: this.context.locale.statusbar.resizeHandle,
|
|
4682
5390
|
"aria-hidden": "true"
|
|
@@ -4706,7 +5414,7 @@ var wi = class {
|
|
|
4706
5414
|
}, l = () => {
|
|
4707
5415
|
document.removeEventListener("touchmove", c), document.removeEventListener("touchend", l), this._dragDisposers = null;
|
|
4708
5416
|
};
|
|
4709
|
-
return [
|
|
5417
|
+
return [y(e, "mousedown", s), y(e, "touchstart", (e) => {
|
|
4710
5418
|
let i = e.touches[0];
|
|
4711
5419
|
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)]);
|
|
4712
5420
|
})];
|
|
@@ -4717,7 +5425,7 @@ var wi = class {
|
|
|
4717
5425
|
update() {
|
|
4718
5426
|
if (!this._wordCountEl || !this._charCountEl || this.el?.hidden) return;
|
|
4719
5427
|
let { words: e, chars: t } = this._counts(), n = this.options.maxWords || 0, r = this.options.maxChars || 0, i = this.context.locale.statusbar;
|
|
4720
|
-
this._wordCountEl.textContent = n ? i.wordsLimit(e, n) : i.words(e), this._charCountEl.textContent = r ? i.charsLimit(t, r) : i.chars(t),
|
|
5428
|
+
this._wordCountEl.textContent = n ? i.wordsLimit(e, n) : i.words(e), this._charCountEl.textContent = r ? i.charsLimit(t, r) : i.chars(t), Ya(this._wordCountEl, e, n), Ya(this._charCountEl, t, r);
|
|
4721
5429
|
}
|
|
4722
5430
|
getWordCount() {
|
|
4723
5431
|
return this._counts().words;
|
|
@@ -4725,14 +5433,14 @@ var wi = class {
|
|
|
4725
5433
|
getCharCount() {
|
|
4726
5434
|
return this._counts().chars;
|
|
4727
5435
|
}
|
|
4728
|
-
},
|
|
5436
|
+
}, Za = class {
|
|
4729
5437
|
constructor(e) {
|
|
4730
5438
|
this.context = e, this.options = e.options, this._disposers = [];
|
|
4731
5439
|
}
|
|
4732
5440
|
initialize() {
|
|
4733
5441
|
this._blobRegistry = /* @__PURE__ */ new Map(), this._forcePlain = !1;
|
|
4734
5442
|
let e = this.context.layoutInfo.editable;
|
|
4735
|
-
return this._disposers.push(
|
|
5443
|
+
return this._disposers.push(y(e, "paste", (e) => this._onPaste(e)), y(e, "dragover", (e) => this._onDragover(e)), y(e, "drop", (e) => this._onDrop(e))), this._mutationObserver = new MutationObserver((e) => {
|
|
4736
5444
|
for (let t of e) for (let e of t.removedNodes) this._revokeRemovedBlobs(e);
|
|
4737
5445
|
}), this._mutationObserver.observe(e, {
|
|
4738
5446
|
childList: !0,
|
|
@@ -4846,24 +5554,24 @@ var wi = class {
|
|
|
4846
5554
|
return;
|
|
4847
5555
|
}
|
|
4848
5556
|
if (typeof i == "string") {
|
|
4849
|
-
e.preventDefault(),
|
|
5557
|
+
e.preventDefault(), P("insertHTML", z(i)), this.context.invoke("editor.afterCommand");
|
|
4850
5558
|
return;
|
|
4851
5559
|
}
|
|
4852
5560
|
if (n || this.options.pasteAsPlainText) {
|
|
4853
|
-
e.preventDefault(),
|
|
5561
|
+
e.preventDefault(), P("insertHTML", t.getData("text/plain").split(/\r?\n/).map((e) => `<p>${this._escapeHTML(e) || "<br>"}</p>`).join("")), this.context.invoke("editor.afterCommand");
|
|
4854
5562
|
return;
|
|
4855
5563
|
}
|
|
4856
5564
|
if (this.options.markdownPaste !== !1) {
|
|
4857
5565
|
let n = t.types.includes("text/html"), r = n ? t.getData("text/html") : "", i = !n || this._isTriviallyPlainHtml(r), a = t.getData("text/plain");
|
|
4858
|
-
if (a && i &&
|
|
4859
|
-
e.preventDefault(),
|
|
5566
|
+
if (a && i && qi(a)) {
|
|
5567
|
+
e.preventDefault(), P("insertHTML", z(ta(a))), this.context.invoke("editor.afterCommand");
|
|
4860
5568
|
return;
|
|
4861
5569
|
}
|
|
4862
5570
|
}
|
|
4863
5571
|
if (this.options.pasteCleanHTML !== !1 && t.types.includes("text/html")) {
|
|
4864
5572
|
e.preventDefault();
|
|
4865
5573
|
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;
|
|
4866
|
-
r ? a = this._cleanWordHtml(a) : i && (a = this._cleanSocialHtml(a)), a = this._normalizeExternalTaskLists(a), a =
|
|
5574
|
+
r ? a = this._cleanWordHtml(a) : i && (a = this._cleanSocialHtml(a)), a = this._normalizeExternalTaskLists(a), a = z(a), this.options.pasteStripAttributes && (a = this._stripAttributes(a)), P("insertHTML", a), this.context.invoke("editor.afterCommand");
|
|
4867
5575
|
}
|
|
4868
5576
|
}
|
|
4869
5577
|
_onDragover(e) {
|
|
@@ -4895,7 +5603,7 @@ var wi = class {
|
|
|
4895
5603
|
}
|
|
4896
5604
|
let n = new FileReader();
|
|
4897
5605
|
n.onload = (e) => {
|
|
4898
|
-
|
|
5606
|
+
P("insertHTML", z(ta(e.target.result || ""))), this.context.invoke("editor.afterCommand");
|
|
4899
5607
|
}, n.onerror = () => {
|
|
4900
5608
|
let t = `Failed to read dropped markdown file "${e.name}".`;
|
|
4901
5609
|
console.warn(`[AutumnNote] ${t}`), this.context.triggerEvent("pasteError", { message: t });
|
|
@@ -4980,7 +5688,7 @@ var wi = class {
|
|
|
4980
5688
|
file: e
|
|
4981
5689
|
});
|
|
4982
5690
|
let r = this._escapeAttr(e.name.replace(/\.[^.]+$/, ""));
|
|
4983
|
-
return
|
|
5691
|
+
return P("insertHTML", `<img src="${this._escapeAttr(n)}" alt="${r}" class="an-image an-image-uploading" data-an-upload="${t}">`), this.context.invoke("editor.afterCommand"), t;
|
|
4984
5692
|
}
|
|
4985
5693
|
_findPlaceholder(e) {
|
|
4986
5694
|
return this.context.layoutInfo.editable?.querySelector(`img[data-an-upload="${e}"]`) ?? null;
|
|
@@ -4988,7 +5696,7 @@ var wi = class {
|
|
|
4988
5696
|
_resolveUpload(e, t) {
|
|
4989
5697
|
let n = this._findPlaceholder(e), r = this._uploadPreviews?.get(e);
|
|
4990
5698
|
if (n) {
|
|
4991
|
-
let i =
|
|
5699
|
+
let i = Qr(t, { allowData: !0 });
|
|
4992
5700
|
if (i) n.setAttribute("src", i), n.classList.remove("an-image-uploading"), n.removeAttribute("data-an-upload"), n.style.removeProperty("--an-upload-progress");
|
|
4993
5701
|
else {
|
|
4994
5702
|
this._failUpload(e, r?.file, /* @__PURE__ */ Error(`Rejected image URL: ${t}`));
|
|
@@ -5080,30 +5788,30 @@ var wi = class {
|
|
|
5080
5788
|
_escapeHTML(e) {
|
|
5081
5789
|
return e.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll("\"", """).replaceAll("'", "'");
|
|
5082
5790
|
}
|
|
5083
|
-
},
|
|
5084
|
-
function
|
|
5791
|
+
}, Qa = /[^\s\u200B]/;
|
|
5792
|
+
function $a(e) {
|
|
5085
5793
|
let t = document.createTreeWalker(e, NodeFilter.SHOW_TEXT);
|
|
5086
|
-
for (let e = t.nextNode(); e; e = t.nextNode()) if (
|
|
5794
|
+
for (let e = t.nextNode(); e; e = t.nextNode()) if (Qa.test(e.data)) return !0;
|
|
5087
5795
|
return !1;
|
|
5088
5796
|
}
|
|
5089
5797
|
//#endregion
|
|
5090
5798
|
//#region src/js/presets/core.js
|
|
5091
|
-
var
|
|
5799
|
+
var eo = [
|
|
5092
5800
|
{
|
|
5093
5801
|
name: "editor",
|
|
5094
|
-
Class:
|
|
5802
|
+
Class: Ha
|
|
5095
5803
|
},
|
|
5096
5804
|
{
|
|
5097
5805
|
name: "toolbar",
|
|
5098
|
-
Class:
|
|
5806
|
+
Class: Ja
|
|
5099
5807
|
},
|
|
5100
5808
|
{
|
|
5101
5809
|
name: "statusbar",
|
|
5102
|
-
Class:
|
|
5810
|
+
Class: Xa
|
|
5103
5811
|
},
|
|
5104
5812
|
{
|
|
5105
5813
|
name: "clipboard",
|
|
5106
|
-
Class:
|
|
5814
|
+
Class: Za
|
|
5107
5815
|
},
|
|
5108
5816
|
{
|
|
5109
5817
|
name: "placeholder",
|
|
@@ -5114,54 +5822,54 @@ var Oi = [
|
|
|
5114
5822
|
initialize() {
|
|
5115
5823
|
let e = this.context.layoutInfo.editable, t = this.options.placeholder || "";
|
|
5116
5824
|
t && (e.dataset.placeholder = t);
|
|
5117
|
-
let n = () => this._update(), r =
|
|
5825
|
+
let n = () => this._update(), r = y(e, "input", n), i = y(e, "focus", n), a = y(e, "blur", n);
|
|
5118
5826
|
return this._disposers.push(r, i, a), this._update(), this;
|
|
5119
5827
|
}
|
|
5120
5828
|
destroy() {
|
|
5121
5829
|
this._disposers.forEach((e) => e()), this._disposers = [];
|
|
5122
5830
|
}
|
|
5123
5831
|
_update() {
|
|
5124
|
-
let e = this.context.layoutInfo.editable, t = document.activeElement === e, n =
|
|
5832
|
+
let e = this.context.layoutInfo.editable, t = document.activeElement === e, n = !$a(e) && !e.querySelector("img, table, hr, .an-video-wrapper");
|
|
5125
5833
|
e.classList.toggle("an-placeholder", n && !t);
|
|
5126
5834
|
}
|
|
5127
5835
|
}
|
|
5128
5836
|
}
|
|
5129
|
-
],
|
|
5837
|
+
], to = "3.1.0";
|
|
5130
5838
|
//#endregion
|
|
5131
5839
|
//#region src/js/core/lists.js
|
|
5132
|
-
function
|
|
5840
|
+
function no(e) {
|
|
5133
5841
|
return e[e.length - 1];
|
|
5134
5842
|
}
|
|
5135
|
-
function
|
|
5843
|
+
function ro(e) {
|
|
5136
5844
|
return e[0];
|
|
5137
5845
|
}
|
|
5138
|
-
function
|
|
5846
|
+
function io(e, t = 1) {
|
|
5139
5847
|
return e.slice(0, e.length - t);
|
|
5140
5848
|
}
|
|
5141
|
-
function
|
|
5849
|
+
function ao(e, t = 1) {
|
|
5142
5850
|
return e.slice(t);
|
|
5143
5851
|
}
|
|
5144
|
-
function
|
|
5852
|
+
function oo(e) {
|
|
5145
5853
|
return e.flat();
|
|
5146
5854
|
}
|
|
5147
|
-
function
|
|
5855
|
+
function so(e) {
|
|
5148
5856
|
return [...new Set(e)];
|
|
5149
5857
|
}
|
|
5150
|
-
function
|
|
5858
|
+
function co(e, t) {
|
|
5151
5859
|
let n = [];
|
|
5152
5860
|
for (let r = 0; r < e.length; r += t) n.push(e.slice(r, r + t));
|
|
5153
5861
|
return n;
|
|
5154
5862
|
}
|
|
5155
|
-
function
|
|
5863
|
+
function lo(e, t) {
|
|
5156
5864
|
return e.reduce((e, n) => {
|
|
5157
5865
|
let r = t(n);
|
|
5158
5866
|
return e[r] || (e[r] = []), e[r].push(n), e;
|
|
5159
5867
|
}, {});
|
|
5160
5868
|
}
|
|
5161
|
-
function
|
|
5869
|
+
function uo(e, t) {
|
|
5162
5870
|
return e.every(t);
|
|
5163
5871
|
}
|
|
5164
|
-
function
|
|
5872
|
+
function fo(e, t) {
|
|
5165
5873
|
return e.some(t);
|
|
5166
5874
|
}
|
|
5167
5875
|
//#endregion
|
|
@@ -5169,7 +5877,7 @@ function zi(e, t) {
|
|
|
5169
5877
|
function Q() {
|
|
5170
5878
|
return globalThis.navigator?.userAgent ?? "";
|
|
5171
5879
|
}
|
|
5172
|
-
var
|
|
5880
|
+
var po = {
|
|
5173
5881
|
get isChrome() {
|
|
5174
5882
|
return /Chrome\//.test(Q()) && !/Edg\//.test(Q());
|
|
5175
5883
|
},
|
|
@@ -5194,11 +5902,11 @@ var Bi = {
|
|
|
5194
5902
|
get modifierKey() {
|
|
5195
5903
|
return /Macintosh/.test(Q()) ? "metaKey" : "ctrlKey";
|
|
5196
5904
|
}
|
|
5197
|
-
},
|
|
5905
|
+
}, mo = { ...L }, $ = /* @__PURE__ */ new WeakMap(), ho = {
|
|
5198
5906
|
create(e, t = {}) {
|
|
5199
|
-
let n =
|
|
5907
|
+
let n = go(e).map((e) => {
|
|
5200
5908
|
if ($.has(e)) return $.get(e);
|
|
5201
|
-
let n = new
|
|
5909
|
+
let n = new fi(e, t);
|
|
5202
5910
|
return n._releaseInstance = () => {
|
|
5203
5911
|
$.get(e) === n && $.delete(e);
|
|
5204
5912
|
}, n.initialize(), $.set(e, n), n;
|
|
@@ -5206,7 +5914,7 @@ var Bi = {
|
|
|
5206
5914
|
return n.length === 1 ? n[0] : n;
|
|
5207
5915
|
},
|
|
5208
5916
|
destroy(e) {
|
|
5209
|
-
|
|
5917
|
+
go(e).forEach((e) => {
|
|
5210
5918
|
let t = $.get(e);
|
|
5211
5919
|
t && (t.destroy(), $.delete(e));
|
|
5212
5920
|
});
|
|
@@ -5216,51 +5924,51 @@ var Bi = {
|
|
|
5216
5924
|
return t && $.get(t) || null;
|
|
5217
5925
|
},
|
|
5218
5926
|
get defaults() {
|
|
5219
|
-
return { ...
|
|
5927
|
+
return { ...L };
|
|
5220
5928
|
},
|
|
5221
5929
|
setDefaults(e) {
|
|
5222
|
-
Object.assign(
|
|
5930
|
+
Object.assign(L, e);
|
|
5223
5931
|
},
|
|
5224
5932
|
resetDefaults() {
|
|
5225
|
-
Object.keys(
|
|
5933
|
+
Object.keys(L).forEach((e) => delete L[e]), Object.assign(L, mo);
|
|
5226
5934
|
},
|
|
5227
5935
|
registerModule(e, t) {
|
|
5228
|
-
|
|
5936
|
+
oi.set(e, t);
|
|
5229
5937
|
},
|
|
5230
5938
|
use(e, t = {}) {
|
|
5231
5939
|
if (!e || typeof e.name != "string") throw TypeError("[AutumnNote] AutumnNote.use: plugin must have a string `name` property.");
|
|
5232
|
-
return
|
|
5940
|
+
return B.has(e.name) ? (console.warn(`[AutumnNote] Plugin "${e.name}" already registered globally. Skipping.`), this) : (Array.isArray(e.buttons) && e.buttons.forEach((e) => jn(e)), B.set(e.name, {
|
|
5233
5941
|
plugin: e,
|
|
5234
5942
|
options: t
|
|
5235
5943
|
}), this);
|
|
5236
5944
|
},
|
|
5237
5945
|
hasPlugin(e) {
|
|
5238
|
-
return
|
|
5946
|
+
return B.has(e);
|
|
5239
5947
|
},
|
|
5240
5948
|
registerButton(e) {
|
|
5241
|
-
return
|
|
5949
|
+
return jn(e), this;
|
|
5242
5950
|
},
|
|
5243
5951
|
registerIcon(e, t) {
|
|
5244
|
-
return
|
|
5952
|
+
return Ln(e, t), this;
|
|
5245
5953
|
},
|
|
5246
5954
|
registerLocale(e, t) {
|
|
5247
|
-
return
|
|
5955
|
+
return jr(e, t), this;
|
|
5248
5956
|
},
|
|
5249
5957
|
registerSlashCommand(e) {
|
|
5250
5958
|
if (!e?.id || typeof e.run != "function") throw TypeError("[AutumnNote] Slash command requires an id and run(context) function.");
|
|
5251
|
-
let t =
|
|
5959
|
+
let t = L.slashCommands, n = t.findIndex((t) => t.id === e.id);
|
|
5252
5960
|
return n >= 0 ? t[n] = e : t.push(e), this;
|
|
5253
5961
|
},
|
|
5254
|
-
buttons:
|
|
5255
|
-
version:
|
|
5962
|
+
buttons: kr,
|
|
5963
|
+
version: to
|
|
5256
5964
|
};
|
|
5257
|
-
function
|
|
5965
|
+
function go(e) {
|
|
5258
5966
|
return typeof e == "string" ? Array.from(document.querySelectorAll(e)) : e instanceof Element ? [e] : e instanceof NodeList || Array.isArray(e) ? Array.from(e) : [];
|
|
5259
5967
|
}
|
|
5260
5968
|
//#endregion
|
|
5261
5969
|
//#region src/js/core.js
|
|
5262
|
-
|
|
5970
|
+
ci(eo);
|
|
5263
5971
|
//#endregion
|
|
5264
|
-
export {
|
|
5972
|
+
export { fi as Context, Bn as DEFAULT_FONT_SIZES, Vn as DEFAULT_LINE_HEIGHTS, Hn as DEFAULT_PARAGRAPH_STYLES, f as ELEMENT_NODE, Na as SUPPORTED_LANGS, ee as TEXT_NODE, Ee as WrappedRange, An as _buttonRegistry, In as _iconRegistry, Xn as alignCenterBtn, Qn as alignJustifyBtn, Yn as alignLeftBtn, Zn as alignRightBtn, uo as all, ue as ancestors, fo as any, Dr as backColorBtn, Un as boldBtn, kr as buttons, wr as checklistBtn, de as children, co as chunk, e as clamp, g as closest, le as closestPara, vr as codeviewBtn, Ae as collapsedRange, r as compose, v as createElement, Oe as currentRange, t as debounce, l as deepEqual, ho as default, L as defaultOptions, Or as defaultToolbar, La as detectLang, mr as directionBtn, lr as emojiBtn, po as env, xr as findBtn, Sr as findReplaceBtn, ro as first, oo as flatten, hr as fontFamilyBtn, fr as fontSizeBtn, Er as foreColorBtn, De as fromNativeRange, yr as fullscreenBtn, Mn as getButton, lo as groupBy, ar as hrBtn, Li as htmlToMarkdown, ur as iconBtn, i as identity, sr as imageBtn, tr as indentBtn, io as initial, Cr as inlineCodeBtn, ge as insertAfter, Zr as isAllowedIframeSrc, se as isAnchor, oe as isEditable, p as isElement, ve as isEmpty, s as isFunction, ce as isImage, ae as isInline, Se as isInsideEditable, H as isKey, re as isLi, h as isList, qi as isMarkdown, Ci as isModifier, a as isNil, ne as isPara, u as isPlainObject, je as isSelectionInside, o as isString, ie as isTable, m as isText, te as isVoid, Wn as italicBtn, V as key, no as last, _r as lineHeightBtn, or as linkBtn, Ar as locales, we as makeDraggable, ta as markdownToHTML, c as mergeDeep, fe as nextElement, _e as nodeValue, er as olBtn, y as on, nr as outdentBtn, ye as outerHtml, gr as paragraphStyleBtn, be as placeCaret, Te as portalOf, _ as prevElement, Tr as printBtn, ke as rangeFromElement, d as rect2bnd, ir as redoBtn, jn as registerButton, Ln as registerIcon, jr as registerLocale, pe as remove, pr as removeFormatBtn, xe as repairListNesting, Fn as resolveButton, zn as resolveIcon, Mr as resolveLocale, z as sanitiseHTML, Kr as sanitiseToBody, Qr as sanitiseUrl, br as shortcutsBtn, Ne as splitText, Kn as strikeBtn, Jn as subscriptBtn, qn as superscriptBtn, dr as tableBtn, ao as tail, n as throttle, Ce as trapFocus, $n as ulBtn, Gn as underlineBtn, rr as undoBtn, so as unique, me as unwrap, cr as videoBtn, Me as withSavedRange, he as wrap };
|
|
5265
5973
|
|
|
5266
5974
|
//# sourceMappingURL=autumnnote.core.es.js.map
|