autumnnote 2.6.0 → 2.7.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 +27 -1
- package/dist/autumnnote.cjs +33 -33
- package/dist/autumnnote.core.es.js +640 -533
- package/dist/autumnnote.core.es.js.map +1 -1
- package/dist/autumnnote.es.js +769 -637
- package/dist/autumnnote.es.js.map +1 -1
- package/dist/autumnnote.min.js +33 -33
- package/dist/autumnnote.umd.js +33 -33
- package/dist/autumnnote.umd.js.map +1 -1
- package/package.json +1 -1
- package/types/index.d.ts +8 -1
package/dist/autumnnote.es.js
CHANGED
|
@@ -122,12 +122,22 @@ function fe(e) {
|
|
|
122
122
|
n && (n.removeAllRanges(), n.addRange(t));
|
|
123
123
|
}
|
|
124
124
|
function pe(e) {
|
|
125
|
+
if (e?.querySelectorAll) for (let t of e.querySelectorAll("ul > ul, ul > ol, ol > ul, ol > ol")) {
|
|
126
|
+
let e = t.previousElementSibling;
|
|
127
|
+
if (e && e.nodeName === "LI") e.appendChild(t);
|
|
128
|
+
else if (t.parentNode) {
|
|
129
|
+
let e = t.ownerDocument.createElement("li");
|
|
130
|
+
t.parentNode.insertBefore(e, t), e.appendChild(t);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function me(e) {
|
|
125
135
|
return !!S(e, x);
|
|
126
136
|
}
|
|
127
137
|
function E(e, t, n, r) {
|
|
128
138
|
return e.addEventListener(t, n, r), () => e.removeEventListener(t, n, r);
|
|
129
139
|
}
|
|
130
|
-
function
|
|
140
|
+
function he(e, t) {
|
|
131
141
|
let n = () => Array.from(e.querySelectorAll("a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])")).filter((e) => !e.closest("[style*=\"display: none\"]") && !e.closest("[style*=\"display:none\"]")), r = (e) => {
|
|
132
142
|
if (e.key === "Escape") {
|
|
133
143
|
e.stopPropagation(), t?.();
|
|
@@ -141,7 +151,7 @@ function me(e, t) {
|
|
|
141
151
|
};
|
|
142
152
|
return document.addEventListener("keydown", r), () => document.removeEventListener("keydown", r);
|
|
143
153
|
}
|
|
144
|
-
function
|
|
154
|
+
function ge(e, t) {
|
|
145
155
|
e.style.cursor = "grab";
|
|
146
156
|
let n = (n) => {
|
|
147
157
|
if (n.button !== 0 || n.target.closest("button, input, select, textarea, a")) return;
|
|
@@ -163,7 +173,7 @@ function he(e, t) {
|
|
|
163
173
|
}
|
|
164
174
|
//#endregion
|
|
165
175
|
//#region src/js/core/range.js
|
|
166
|
-
var
|
|
176
|
+
var _e = class {
|
|
167
177
|
constructor(e, t, n, r) {
|
|
168
178
|
this.sc = e, this.so = t, this.ec = n, this.eo = r;
|
|
169
179
|
}
|
|
@@ -199,40 +209,40 @@ var ge = class {
|
|
|
199
209
|
this.toNativeRange().insertNode(e);
|
|
200
210
|
}
|
|
201
211
|
};
|
|
202
|
-
function _e(e) {
|
|
203
|
-
return new ge(e.startContainer, e.startOffset, e.endContainer, e.endOffset);
|
|
204
|
-
}
|
|
205
212
|
function ve(e) {
|
|
213
|
+
return new _e(e.startContainer, e.startOffset, e.endContainer, e.endOffset);
|
|
214
|
+
}
|
|
215
|
+
function ye(e) {
|
|
206
216
|
let t = globalThis.getSelection();
|
|
207
217
|
if (!t || t.rangeCount === 0) return null;
|
|
208
218
|
let n = t.getRangeAt(0);
|
|
209
|
-
return e && !e.contains(n.commonAncestorContainer) ? null :
|
|
219
|
+
return e && !e.contains(n.commonAncestorContainer) ? null : ve(n);
|
|
210
220
|
}
|
|
211
|
-
function
|
|
212
|
-
return new
|
|
221
|
+
function be(e) {
|
|
222
|
+
return new _e(e, 0, e, e.childNodes.length);
|
|
213
223
|
}
|
|
214
|
-
function
|
|
215
|
-
return new
|
|
224
|
+
function xe(e, t = 0) {
|
|
225
|
+
return new _e(e, t, e, t);
|
|
216
226
|
}
|
|
217
|
-
function
|
|
227
|
+
function Se(e) {
|
|
218
228
|
let t = globalThis.getSelection();
|
|
219
229
|
return !t || t.rangeCount === 0 ? !1 : e.contains(t.getRangeAt(0).commonAncestorContainer);
|
|
220
230
|
}
|
|
221
|
-
function
|
|
231
|
+
function Ce(e) {
|
|
222
232
|
let t = globalThis.getSelection();
|
|
223
233
|
if (!t || t.rangeCount === 0) {
|
|
224
234
|
e(null);
|
|
225
235
|
return;
|
|
226
236
|
}
|
|
227
237
|
let n = t.getRangeAt(0).cloneRange();
|
|
228
|
-
e(
|
|
238
|
+
e(ve(n)), t.removeAllRanges(), t.addRange(n);
|
|
229
239
|
}
|
|
230
|
-
function
|
|
240
|
+
function we(e, t) {
|
|
231
241
|
return [e, e.splitText(t)];
|
|
232
242
|
}
|
|
233
243
|
//#endregion
|
|
234
244
|
//#region src/js/editing/insert.js
|
|
235
|
-
function
|
|
245
|
+
function Te(e) {
|
|
236
246
|
let t = e && e.nodeType === 1 ? e : e?.parentElement;
|
|
237
247
|
for (; t;) {
|
|
238
248
|
let e = t.getAttribute?.("contenteditable") ?? t.contentEditable;
|
|
@@ -242,38 +252,41 @@ function we(e) {
|
|
|
242
252
|
}
|
|
243
253
|
return null;
|
|
244
254
|
}
|
|
245
|
-
function
|
|
255
|
+
function Ee(e) {
|
|
246
256
|
let t = globalThis.getSelection?.();
|
|
247
257
|
if (!t || t.rangeCount === 0) return null;
|
|
248
258
|
let n = t.getRangeAt(0);
|
|
249
|
-
return e && e !== document ? e.contains(n.commonAncestorContainer) ? n : null :
|
|
259
|
+
return e && e !== document ? e.contains(n.commonAncestorContainer) ? n : null : Te(n.commonAncestorContainer) ? n : null;
|
|
250
260
|
}
|
|
251
|
-
function
|
|
261
|
+
function De(e) {
|
|
252
262
|
let t = globalThis.getSelection?.();
|
|
253
263
|
if (!t) return;
|
|
254
264
|
let n = document.createRange();
|
|
255
265
|
n.setStartAfter(e), n.collapse(!0), t.removeAllRanges(), t.addRange(n);
|
|
256
266
|
}
|
|
257
|
-
function
|
|
258
|
-
let n =
|
|
267
|
+
function Oe(e, t) {
|
|
268
|
+
let n = Ee(t);
|
|
259
269
|
if (!n) return !1;
|
|
260
270
|
let r = document.createElement("template");
|
|
261
271
|
r.innerHTML = e;
|
|
262
272
|
let i = r.content, a = i.lastChild;
|
|
263
|
-
return n.deleteContents(), n.insertNode(i), a &&
|
|
273
|
+
return n.deleteContents(), n.insertNode(i), a && De(a), !0;
|
|
264
274
|
}
|
|
265
|
-
function
|
|
266
|
-
let n =
|
|
275
|
+
function ke(e, t) {
|
|
276
|
+
let n = Ee(t);
|
|
267
277
|
if (!n) return !1;
|
|
268
278
|
n.deleteContents();
|
|
269
279
|
let r = String(e), i = document.createDocumentFragment();
|
|
270
|
-
!r.includes("\n") ||
|
|
280
|
+
!r.includes("\n") || je(n.startContainer, t) ? i.appendChild(document.createTextNode(r)) : r.split("\n").forEach((e, t) => {
|
|
271
281
|
t > 0 && i.appendChild(document.createElement("br")), e && i.appendChild(document.createTextNode(e));
|
|
272
282
|
});
|
|
273
283
|
let a = i.lastChild;
|
|
274
|
-
return n.insertNode(i), a &&
|
|
284
|
+
return n.insertNode(i), a && De(a), !0;
|
|
275
285
|
}
|
|
276
|
-
function
|
|
286
|
+
function Ae(e) {
|
|
287
|
+
return ke("\n", e);
|
|
288
|
+
}
|
|
289
|
+
function je(e, t) {
|
|
277
290
|
let n = e.nodeType === 1 ? e : e.parentElement;
|
|
278
291
|
for (; n && n !== t;) {
|
|
279
292
|
if (n.tagName === "PRE" || n.tagName === "TEXTAREA") return !0;
|
|
@@ -283,12 +296,12 @@ function ke(e, t) {
|
|
|
283
296
|
}
|
|
284
297
|
return !1;
|
|
285
298
|
}
|
|
286
|
-
function
|
|
287
|
-
let t =
|
|
299
|
+
function Me(e) {
|
|
300
|
+
let t = Ee(e);
|
|
288
301
|
if (!t) return !1;
|
|
289
302
|
let n = document.createElement("hr");
|
|
290
303
|
t.deleteContents();
|
|
291
|
-
let r =
|
|
304
|
+
let r = Pe(t.startContainer, e);
|
|
292
305
|
r && r.parentNode ? r.parentNode.insertBefore(n, r.nextSibling) : t.insertNode(n);
|
|
293
306
|
let i = n.nextElementSibling;
|
|
294
307
|
if (!i || i.tagName === "HR") {
|
|
@@ -302,7 +315,7 @@ function Ae(e) {
|
|
|
302
315
|
}
|
|
303
316
|
return !0;
|
|
304
317
|
}
|
|
305
|
-
var
|
|
318
|
+
var Ne = /* @__PURE__ */ new Set([
|
|
306
319
|
"P",
|
|
307
320
|
"DIV",
|
|
308
321
|
"H1",
|
|
@@ -315,10 +328,10 @@ var je = /* @__PURE__ */ new Set([
|
|
|
315
328
|
"PRE",
|
|
316
329
|
"LI"
|
|
317
330
|
]);
|
|
318
|
-
function
|
|
331
|
+
function Pe(e, t) {
|
|
319
332
|
let n = e.nodeType === 1 ? e : e.parentElement;
|
|
320
333
|
for (; n && n !== t;) {
|
|
321
|
-
if (
|
|
334
|
+
if (Ne.has(n.tagName)) return n;
|
|
322
335
|
n = n.parentElement;
|
|
323
336
|
}
|
|
324
337
|
return null;
|
|
@@ -326,10 +339,10 @@ function Me(e, t) {
|
|
|
326
339
|
//#endregion
|
|
327
340
|
//#region src/js/editing/Style.js
|
|
328
341
|
function D(e, t = null) {
|
|
329
|
-
return e === "insertHTML" &&
|
|
342
|
+
return e === "insertHTML" && Oe(String(t ?? "")) || e === "insertText" && ke(String(t ?? "")) || e === "insertLineBreak" && Ae() || e === "insertHorizontalRule" && Me() ? !0 : document.execCommand(e, !1, t);
|
|
330
343
|
}
|
|
331
|
-
var
|
|
332
|
-
function
|
|
344
|
+
var Fe = () => D("bold"), Ie = () => D("italic");
|
|
345
|
+
function Le() {
|
|
333
346
|
let e = globalThis.getSelection();
|
|
334
347
|
if (!e?.rangeCount) return;
|
|
335
348
|
let t = e.getRangeAt(0).commonAncestorContainer;
|
|
@@ -343,7 +356,7 @@ function Fe() {
|
|
|
343
356
|
}
|
|
344
357
|
D("underline");
|
|
345
358
|
}
|
|
346
|
-
function
|
|
359
|
+
function Re() {
|
|
347
360
|
let e = globalThis.getSelection();
|
|
348
361
|
if (!e?.rangeCount) return;
|
|
349
362
|
let t = e.getRangeAt(0).startContainer;
|
|
@@ -357,8 +370,8 @@ function Ie() {
|
|
|
357
370
|
}
|
|
358
371
|
D("strikeThrough");
|
|
359
372
|
}
|
|
360
|
-
var
|
|
361
|
-
function
|
|
373
|
+
var ze = () => D("superscript"), Be = () => D("subscript"), Ve = (e) => D("foreColor", e), He = (e) => D("hiliteColor", e), Ue = (e) => D("fontName", e);
|
|
374
|
+
function We(e, t = document) {
|
|
362
375
|
let n = globalThis.getSelection(), r = !n?.rangeCount || n.getRangeAt(0).collapsed;
|
|
363
376
|
if (r && n?.rangeCount > 0) {
|
|
364
377
|
try {
|
|
@@ -385,21 +398,52 @@ function He(e, t = document) {
|
|
|
385
398
|
} catch {}
|
|
386
399
|
}
|
|
387
400
|
}
|
|
388
|
-
var
|
|
389
|
-
function
|
|
401
|
+
var Ge = (e) => D("formatBlock", `<${e}>`), Ke = () => D("justifyLeft"), qe = () => D("justifyCenter"), Je = () => D("justifyRight"), Ye = () => D("justifyFull");
|
|
402
|
+
function Xe() {
|
|
403
|
+
D("indent"), pe(Ze());
|
|
404
|
+
}
|
|
405
|
+
function Ze() {
|
|
406
|
+
let e = globalThis.getSelection();
|
|
407
|
+
if (!e?.rangeCount) return null;
|
|
408
|
+
let t = e.getRangeAt(0).commonAncestorContainer;
|
|
409
|
+
t.nodeType === 3 && (t = t.parentElement);
|
|
410
|
+
let n = null;
|
|
411
|
+
for (let e = t; e; e = e.parentElement) (e.nodeName === "UL" || e.nodeName === "OL") && (n = e);
|
|
412
|
+
return n;
|
|
413
|
+
}
|
|
414
|
+
function Qe() {
|
|
390
415
|
let e = globalThis.getSelection();
|
|
391
416
|
if (e?.rangeCount) {
|
|
392
417
|
let t = e.getRangeAt(0).commonAncestorContainer;
|
|
393
418
|
t.nodeType === 3 && (t = t.parentElement);
|
|
394
419
|
let n = t?.closest(".an-checklist li");
|
|
395
420
|
if (n) {
|
|
396
|
-
|
|
421
|
+
et(n);
|
|
397
422
|
return;
|
|
398
423
|
}
|
|
399
424
|
}
|
|
400
|
-
D("outdent");
|
|
425
|
+
$e() || D("outdent");
|
|
401
426
|
}
|
|
402
|
-
function
|
|
427
|
+
function $e() {
|
|
428
|
+
let e = globalThis.getSelection();
|
|
429
|
+
if (!e?.rangeCount) return !1;
|
|
430
|
+
let t = e.getRangeAt(0).startContainer;
|
|
431
|
+
t.nodeType === 3 && (t = t.parentElement);
|
|
432
|
+
let n = t?.closest?.("li");
|
|
433
|
+
if (!n) return !1;
|
|
434
|
+
let r = n.parentElement;
|
|
435
|
+
if (!r || r.nodeName !== "UL" && r.nodeName !== "OL") return !1;
|
|
436
|
+
let i = r.parentElement;
|
|
437
|
+
if (!i || i.nodeName !== "LI" || !i.parentNode) return !1;
|
|
438
|
+
let a = [];
|
|
439
|
+
for (let e = n.nextElementSibling; e; e = e.nextElementSibling) a.push(e);
|
|
440
|
+
if (a.length) {
|
|
441
|
+
let e = n.ownerDocument.createElement(r.nodeName.toLowerCase());
|
|
442
|
+
a.forEach((t) => e.appendChild(t)), n.appendChild(e);
|
|
443
|
+
}
|
|
444
|
+
return i.parentNode.insertBefore(n, i.nextSibling), r.children.length || r.remove(), !0;
|
|
445
|
+
}
|
|
446
|
+
function et(e) {
|
|
403
447
|
let t = e.closest(".an-checklist");
|
|
404
448
|
if (!t) return;
|
|
405
449
|
let n = Array.from(t.children), r = n.indexOf(e), i = n.slice(r + 1), a = document.createElement("p");
|
|
@@ -416,24 +460,24 @@ function Xe(e) {
|
|
|
416
460
|
n && (n.removeAllRanges(), n.addRange(e));
|
|
417
461
|
} catch {}
|
|
418
462
|
}
|
|
419
|
-
function
|
|
463
|
+
function tt() {
|
|
420
464
|
let e = globalThis.getSelection();
|
|
421
465
|
if (!e?.rangeCount) return null;
|
|
422
466
|
let t = e.getRangeAt(0).commonAncestorContainer;
|
|
423
467
|
return t.nodeType === 3 && (t = t.parentElement), t?.closest("ul, ol") || null;
|
|
424
468
|
}
|
|
425
|
-
function
|
|
469
|
+
function nt(e) {
|
|
426
470
|
e.classList.remove("an-checklist"), e.querySelectorAll("input[type=\"checkbox\"]").forEach((e) => e.remove());
|
|
427
471
|
}
|
|
428
|
-
function
|
|
429
|
-
let e =
|
|
430
|
-
e ? e.classList.contains("an-checklist") ? (
|
|
472
|
+
function rt() {
|
|
473
|
+
let e = tt();
|
|
474
|
+
e ? e.classList.contains("an-checklist") ? (nt(e), e.tagName === "OL" && ct(e, "ul")) : e.tagName === "OL" ? ct(e, "ul") : D("insertUnorderedList") : D("insertUnorderedList");
|
|
431
475
|
}
|
|
432
|
-
function
|
|
433
|
-
let e =
|
|
434
|
-
e ? e.classList.contains("an-checklist") ? (
|
|
476
|
+
function it() {
|
|
477
|
+
let e = tt();
|
|
478
|
+
e ? e.classList.contains("an-checklist") ? (nt(e), ct(e, "ol")) : e.tagName === "UL" ? ct(e, "ol") : D("insertOrderedList") : D("insertOrderedList");
|
|
435
479
|
}
|
|
436
|
-
function
|
|
480
|
+
function at(e) {
|
|
437
481
|
let t = globalThis.getSelection();
|
|
438
482
|
if (!t || t.rangeCount === 0) return;
|
|
439
483
|
let n = t.getRangeAt(0), r = /* @__PURE__ */ new Set([
|
|
@@ -476,7 +520,7 @@ function tt(e) {
|
|
|
476
520
|
t.style.lineHeight = e;
|
|
477
521
|
});
|
|
478
522
|
}
|
|
479
|
-
function
|
|
523
|
+
function ot(e) {
|
|
480
524
|
let t = globalThis.getSelection();
|
|
481
525
|
if (!t?.rangeCount) return;
|
|
482
526
|
let n = t.getRangeAt(0), r = n.commonAncestorContainer;
|
|
@@ -508,7 +552,7 @@ function nt(e) {
|
|
|
508
552
|
}
|
|
509
553
|
}
|
|
510
554
|
}
|
|
511
|
-
function
|
|
555
|
+
function st() {
|
|
512
556
|
let e = globalThis.getSelection();
|
|
513
557
|
if (!e?.rangeCount) return !1;
|
|
514
558
|
let t = e.getRangeAt(0).startContainer;
|
|
@@ -516,13 +560,13 @@ function rt() {
|
|
|
516
560
|
let n = t?.closest("code");
|
|
517
561
|
return !!(n && !n.closest("pre"));
|
|
518
562
|
}
|
|
519
|
-
function
|
|
563
|
+
function ct(e, t) {
|
|
520
564
|
let n = document.createElement(t);
|
|
521
565
|
for (let t of e.attributes) n.setAttribute(t.name, t.value);
|
|
522
566
|
for (; e.firstChild;) n.appendChild(e.firstChild);
|
|
523
567
|
return e.parentNode.replaceChild(n, e), n;
|
|
524
568
|
}
|
|
525
|
-
function
|
|
569
|
+
function lt(e) {
|
|
526
570
|
e.querySelectorAll("li").forEach((e) => {
|
|
527
571
|
if (!e.querySelector("input[type=\"checkbox\"]")) {
|
|
528
572
|
let t = document.createElement("input");
|
|
@@ -530,7 +574,7 @@ function at(e) {
|
|
|
530
574
|
}
|
|
531
575
|
});
|
|
532
576
|
}
|
|
533
|
-
function
|
|
577
|
+
function ut() {
|
|
534
578
|
let e = globalThis.getSelection();
|
|
535
579
|
if (!e?.rangeCount) return;
|
|
536
580
|
let t = e.getRangeAt(0), n = t.commonAncestorContainer;
|
|
@@ -549,8 +593,8 @@ function ot() {
|
|
|
549
593
|
}
|
|
550
594
|
}
|
|
551
595
|
} else {
|
|
552
|
-
let t =
|
|
553
|
-
t.classList.add("an-checklist"),
|
|
596
|
+
let t = ct(r, "ul");
|
|
597
|
+
t.classList.add("an-checklist"), lt(t);
|
|
554
598
|
let n = t.querySelector("li");
|
|
555
599
|
if (n) {
|
|
556
600
|
let t = document.createRange();
|
|
@@ -623,7 +667,7 @@ function ot() {
|
|
|
623
667
|
}
|
|
624
668
|
}
|
|
625
669
|
}
|
|
626
|
-
function
|
|
670
|
+
function dt() {
|
|
627
671
|
let e = globalThis.getSelection();
|
|
628
672
|
if (!e?.rangeCount) return !1;
|
|
629
673
|
let t = e.getRangeAt(0).commonAncestorContainer;
|
|
@@ -641,24 +685,24 @@ function O(e, t, n, r, i, a) {
|
|
|
641
685
|
isDisabled: a
|
|
642
686
|
};
|
|
643
687
|
}
|
|
644
|
-
var
|
|
645
|
-
function
|
|
688
|
+
var ft = /* @__PURE__ */ new Map();
|
|
689
|
+
function pt(e) {
|
|
646
690
|
if (!e || typeof e.name != "string") {
|
|
647
691
|
console.warn("[AutumnNote] registerButton: btnDef must have a string `name` property.");
|
|
648
692
|
return;
|
|
649
693
|
}
|
|
650
|
-
|
|
694
|
+
ft.has(e.name) && console.warn(`[AutumnNote] registerButton: overwriting existing button "${e.name}".`), ft.set(e.name, e);
|
|
651
695
|
}
|
|
652
|
-
function
|
|
653
|
-
return
|
|
696
|
+
function mt(e) {
|
|
697
|
+
return ft.get(e);
|
|
654
698
|
}
|
|
655
|
-
var
|
|
699
|
+
var ht = O("bold", "bold", "Bold (Ctrl+B)", () => Fe(), () => document.queryCommandState("bold")), gt = O("italic", "italic", "Italic (Ctrl+I)", () => Ie(), () => document.queryCommandState("italic")), _t = O("underline", "underline", "Underline (Ctrl+U)", () => Le(), () => {
|
|
656
700
|
if (document.queryCommandState("underline")) return !0;
|
|
657
701
|
let e = globalThis.getSelection();
|
|
658
702
|
if (!e?.rangeCount) return !1;
|
|
659
703
|
let t = e.getRangeAt(0).startContainer;
|
|
660
704
|
return t.nodeType === 3 && (t = t.parentElement), !!t?.closest("u");
|
|
661
|
-
}),
|
|
705
|
+
}), vt = O("strikethrough", "strikethrough", "Strikethrough", () => Re(), () => document.queryCommandState("strikeThrough")), yt = O("superscript", "superscript", "Superscript", () => ze(), () => document.queryCommandState("superscript")), bt = O("subscript", "subscript", "Subscript", () => Be(), () => document.queryCommandState("subscript")), xt = O("alignLeft", "align-left", "Align Left", () => Ke()), St = O("alignCenter", "align-center", "Align Center", () => qe()), Ct = O("alignRight", "align-right", "Align Right", () => Je()), wt = O("alignJustify", "align-justify", "Justify", () => Ye()), Tt = O("ul", "list-ul", "Unordered List", () => rt()), Et = O("ol", "list-ol", "Ordered List", () => it()), Dt = O("indent", "indent", "Indent", () => Xe()), Ot = O("outdent", "outdent", "Outdent", () => Qe()), kt = O("undo", "undo", "Undo (Ctrl+Z)", (e) => e.invoke("editor.undo"), void 0, (e) => !e.invoke("editor.canUndo")), At = O("redo", "redo", "Redo (Ctrl+Y)", (e) => e.invoke("editor.redo"), void 0, (e) => !e.invoke("editor.canRedo")), jt = O("hr", "minus", "Horizontal Rule", () => D("insertHorizontalRule")), Mt = O("link", "link", "Insert Link", (e) => e.invoke("linkDialog.show")), Nt = O("image", "image", "Insert Image", (e) => e.invoke("imageDialog.show")), Pt = O("video", "video", "Insert Video", (e) => e.invoke("videoDialog.show")), Ft = O("emoji", "emoji", "Insert Emoji", (e) => e.invoke("emojiDialog.show")), It = O("icon", "icon", "Insert FA Icon", (e) => e.invoke("iconDialog.show")), Lt = {
|
|
662
706
|
name: "table",
|
|
663
707
|
type: "grid",
|
|
664
708
|
icon: "table",
|
|
@@ -666,7 +710,7 @@ var dt = O("bold", "bold", "Bold (Ctrl+B)", () => Ne(), () => document.queryComm
|
|
|
666
710
|
action: (e, t, n) => {
|
|
667
711
|
e.invoke("editor.insertTable", n, t), e.invoke("editor.afterCommand");
|
|
668
712
|
}
|
|
669
|
-
},
|
|
713
|
+
}, Rt = {
|
|
670
714
|
name: "fontSize",
|
|
671
715
|
type: "select",
|
|
672
716
|
tooltip: "Font Size",
|
|
@@ -689,7 +733,7 @@ var dt = O("bold", "bold", "Bold (Ctrl+B)", () => Ne(), () => document.queryComm
|
|
|
689
733
|
"48px",
|
|
690
734
|
"72px"
|
|
691
735
|
],
|
|
692
|
-
action: (e, t) =>
|
|
736
|
+
action: (e, t) => We(t, e.layoutInfo.editable),
|
|
693
737
|
getValue: (e) => {
|
|
694
738
|
try {
|
|
695
739
|
let t = globalThis.getSelection();
|
|
@@ -705,14 +749,14 @@ var dt = O("bold", "bold", "Bold (Ctrl+B)", () => Ne(), () => document.queryComm
|
|
|
705
749
|
return "";
|
|
706
750
|
}
|
|
707
751
|
}
|
|
708
|
-
},
|
|
752
|
+
}, zt = O("removeFormat", "remove-format", "Remove Format", () => D("removeFormat")), Bt = O("direction", "direction", "Toggle Text Direction (LTR / RTL)", (e) => {
|
|
709
753
|
let t = e.layoutInfo.editable, n = (t.getAttribute("dir") || "ltr") === "ltr" ? "rtl" : "ltr";
|
|
710
754
|
t.setAttribute("dir", n), t.style.textAlign = n === "rtl" ? "right" : "left", e.invoke("editor.afterCommand");
|
|
711
|
-
}),
|
|
755
|
+
}), Vt = {
|
|
712
756
|
name: "fontFamily",
|
|
713
757
|
type: "select",
|
|
714
758
|
tooltip: "Font Family",
|
|
715
|
-
action: (e, t) =>
|
|
759
|
+
action: (e, t) => Ue(t),
|
|
716
760
|
getValue: () => {
|
|
717
761
|
try {
|
|
718
762
|
return document.queryCommandValue("fontName") || "";
|
|
@@ -720,7 +764,7 @@ var dt = O("bold", "bold", "Bold (Ctrl+B)", () => Ne(), () => document.queryComm
|
|
|
720
764
|
return "";
|
|
721
765
|
}
|
|
722
766
|
}
|
|
723
|
-
},
|
|
767
|
+
}, Ht = {
|
|
724
768
|
name: "paragraphStyle",
|
|
725
769
|
type: "select",
|
|
726
770
|
tooltip: "Paragraph Style",
|
|
@@ -764,7 +808,7 @@ var dt = O("bold", "bold", "Bold (Ctrl+B)", () => Ne(), () => document.queryComm
|
|
|
764
808
|
label: "Code"
|
|
765
809
|
}
|
|
766
810
|
],
|
|
767
|
-
action: (e, t) =>
|
|
811
|
+
action: (e, t) => Ge(t),
|
|
768
812
|
getValue: () => {
|
|
769
813
|
try {
|
|
770
814
|
let e = document.queryCommandValue("formatBlock").toLowerCase().replace(/[<>]/g, "");
|
|
@@ -773,7 +817,7 @@ var dt = O("bold", "bold", "Bold (Ctrl+B)", () => Ne(), () => document.queryComm
|
|
|
773
817
|
return "";
|
|
774
818
|
}
|
|
775
819
|
}
|
|
776
|
-
},
|
|
820
|
+
}, Ut = {
|
|
777
821
|
name: "lineHeight",
|
|
778
822
|
type: "select",
|
|
779
823
|
tooltip: "Line Height",
|
|
@@ -788,7 +832,7 @@ var dt = O("bold", "bold", "Bold (Ctrl+B)", () => Ne(), () => document.queryComm
|
|
|
788
832
|
"2.5",
|
|
789
833
|
"3.0"
|
|
790
834
|
],
|
|
791
|
-
action: (e, t) =>
|
|
835
|
+
action: (e, t) => at(t),
|
|
792
836
|
getValue: () => {
|
|
793
837
|
try {
|
|
794
838
|
let e = globalThis.getSelection();
|
|
@@ -814,108 +858,108 @@ var dt = O("bold", "bold", "Bold (Ctrl+B)", () => Ne(), () => document.queryComm
|
|
|
814
858
|
return "";
|
|
815
859
|
}
|
|
816
860
|
}
|
|
817
|
-
},
|
|
861
|
+
}, Wt = O("codeview", "code", "HTML Code View", (e) => e.invoke("codeview.toggle"), (e) => e.invoke("codeview.isActive")), Gt = O("fullscreen", "expand", "Fullscreen", (e) => e.invoke("fullscreen.toggle"), (e) => e.invoke("fullscreen.isActive")), Kt = O("shortcuts", "keyboard", "Keyboard Shortcuts (Ctrl+Shift+/)", (e) => e.invoke("shortcutsDialog.show")), qt = O("find", "search", "Find (Ctrl+F)", (e) => e.invoke("findReplace.show", "find")), Jt = O("findReplace", "find-replace", "Find & Replace (Ctrl+H)", (e) => e.invoke("findReplace.show", "replace")), Yt = O("inlineCode", "inline-code", "Inline Code (Ctrl+`)", (e) => e.invoke("editor.inlineCode"), () => st()), Xt = O("checklist", "checklist", "Checklist", (e) => e.invoke("editor.toggleChecklist"), () => dt()), Zt = O("print", "print", "Print", (e) => e.invoke("editor.print")), Qt = {
|
|
818
862
|
name: "foreColor",
|
|
819
863
|
type: "colorpicker",
|
|
820
864
|
icon: "foreColor",
|
|
821
865
|
tooltip: "Text Color",
|
|
822
866
|
defaultColor: "#e11d48",
|
|
823
|
-
action: (e, t) =>
|
|
824
|
-
},
|
|
867
|
+
action: (e, t) => Ve(t)
|
|
868
|
+
}, $t = {
|
|
825
869
|
name: "backColor",
|
|
826
870
|
type: "colorpicker",
|
|
827
871
|
icon: "backColor",
|
|
828
872
|
tooltip: "Highlight Color",
|
|
829
873
|
defaultColor: "#fbbf24",
|
|
830
|
-
action: (e, t) =>
|
|
831
|
-
},
|
|
874
|
+
action: (e, t) => He(t)
|
|
875
|
+
}, en = [
|
|
832
876
|
[
|
|
877
|
+
Ht,
|
|
878
|
+
Vt,
|
|
833
879
|
Rt,
|
|
834
|
-
|
|
835
|
-
Pt,
|
|
836
|
-
zt
|
|
880
|
+
Ut
|
|
837
881
|
],
|
|
838
|
-
[
|
|
839
|
-
[
|
|
840
|
-
dt,
|
|
841
|
-
ft,
|
|
842
|
-
pt,
|
|
843
|
-
mt,
|
|
844
|
-
Gt
|
|
845
|
-
],
|
|
846
|
-
[ht, gt],
|
|
847
|
-
[Jt, Yt],
|
|
882
|
+
[kt, At],
|
|
848
883
|
[
|
|
884
|
+
ht,
|
|
885
|
+
gt,
|
|
849
886
|
_t,
|
|
850
887
|
vt,
|
|
851
|
-
|
|
852
|
-
bt
|
|
888
|
+
Yt
|
|
853
889
|
],
|
|
890
|
+
[yt, bt],
|
|
891
|
+
[Qt, $t],
|
|
854
892
|
[
|
|
855
893
|
xt,
|
|
856
894
|
St,
|
|
857
|
-
Kt,
|
|
858
895
|
Ct,
|
|
859
896
|
wt
|
|
860
897
|
],
|
|
861
898
|
[
|
|
899
|
+
Tt,
|
|
900
|
+
Et,
|
|
901
|
+
Xt,
|
|
862
902
|
Dt,
|
|
863
|
-
Ot
|
|
864
|
-
kt,
|
|
865
|
-
At,
|
|
866
|
-
Nt,
|
|
867
|
-
jt,
|
|
868
|
-
Mt
|
|
903
|
+
Ot
|
|
869
904
|
],
|
|
870
905
|
[
|
|
906
|
+
jt,
|
|
907
|
+
Mt,
|
|
908
|
+
Nt,
|
|
909
|
+
Pt,
|
|
910
|
+
Lt,
|
|
871
911
|
Ft,
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
912
|
+
It
|
|
913
|
+
],
|
|
914
|
+
[
|
|
915
|
+
zt,
|
|
916
|
+
Wt,
|
|
917
|
+
Gt,
|
|
875
918
|
qt,
|
|
876
|
-
|
|
919
|
+
Zt,
|
|
920
|
+
Kt
|
|
877
921
|
]
|
|
878
|
-
],
|
|
879
|
-
boldBtn:
|
|
880
|
-
italicBtn:
|
|
881
|
-
underlineBtn:
|
|
882
|
-
strikeBtn:
|
|
883
|
-
superscriptBtn:
|
|
884
|
-
subscriptBtn:
|
|
885
|
-
alignLeftBtn:
|
|
886
|
-
alignCenterBtn:
|
|
887
|
-
alignRightBtn:
|
|
888
|
-
alignJustifyBtn:
|
|
889
|
-
ulBtn:
|
|
890
|
-
olBtn:
|
|
891
|
-
indentBtn:
|
|
892
|
-
outdentBtn:
|
|
893
|
-
undoBtn:
|
|
894
|
-
redoBtn:
|
|
895
|
-
hrBtn:
|
|
896
|
-
linkBtn:
|
|
897
|
-
imageBtn:
|
|
898
|
-
videoBtn:
|
|
899
|
-
emojiBtn:
|
|
900
|
-
iconBtn:
|
|
901
|
-
tableBtn:
|
|
902
|
-
fontSizeBtn:
|
|
903
|
-
removeFormatBtn:
|
|
904
|
-
directionBtn:
|
|
905
|
-
fontFamilyBtn:
|
|
906
|
-
paragraphStyleBtn:
|
|
907
|
-
lineHeightBtn:
|
|
908
|
-
codeviewBtn:
|
|
909
|
-
fullscreenBtn:
|
|
910
|
-
shortcutsBtn:
|
|
911
|
-
findBtn:
|
|
912
|
-
findReplaceBtn:
|
|
913
|
-
inlineCodeBtn:
|
|
914
|
-
checklistBtn:
|
|
915
|
-
printBtn:
|
|
916
|
-
foreColorBtn:
|
|
917
|
-
backColorBtn:
|
|
918
|
-
defaultToolbar:
|
|
922
|
+
], tn = {
|
|
923
|
+
boldBtn: ht,
|
|
924
|
+
italicBtn: gt,
|
|
925
|
+
underlineBtn: _t,
|
|
926
|
+
strikeBtn: vt,
|
|
927
|
+
superscriptBtn: yt,
|
|
928
|
+
subscriptBtn: bt,
|
|
929
|
+
alignLeftBtn: xt,
|
|
930
|
+
alignCenterBtn: St,
|
|
931
|
+
alignRightBtn: Ct,
|
|
932
|
+
alignJustifyBtn: wt,
|
|
933
|
+
ulBtn: Tt,
|
|
934
|
+
olBtn: Et,
|
|
935
|
+
indentBtn: Dt,
|
|
936
|
+
outdentBtn: Ot,
|
|
937
|
+
undoBtn: kt,
|
|
938
|
+
redoBtn: At,
|
|
939
|
+
hrBtn: jt,
|
|
940
|
+
linkBtn: Mt,
|
|
941
|
+
imageBtn: Nt,
|
|
942
|
+
videoBtn: Pt,
|
|
943
|
+
emojiBtn: Ft,
|
|
944
|
+
iconBtn: It,
|
|
945
|
+
tableBtn: Lt,
|
|
946
|
+
fontSizeBtn: Rt,
|
|
947
|
+
removeFormatBtn: zt,
|
|
948
|
+
directionBtn: Bt,
|
|
949
|
+
fontFamilyBtn: Vt,
|
|
950
|
+
paragraphStyleBtn: Ht,
|
|
951
|
+
lineHeightBtn: Ut,
|
|
952
|
+
codeviewBtn: Wt,
|
|
953
|
+
fullscreenBtn: Gt,
|
|
954
|
+
shortcutsBtn: Kt,
|
|
955
|
+
findBtn: qt,
|
|
956
|
+
findReplaceBtn: Jt,
|
|
957
|
+
inlineCodeBtn: Yt,
|
|
958
|
+
checklistBtn: Xt,
|
|
959
|
+
printBtn: Zt,
|
|
960
|
+
foreColorBtn: Qt,
|
|
961
|
+
backColorBtn: $t,
|
|
962
|
+
defaultToolbar: en
|
|
919
963
|
}, k = {
|
|
920
964
|
placeholder: "",
|
|
921
965
|
height: 200,
|
|
@@ -923,7 +967,7 @@ var dt = O("bold", "bold", "Bold (Ctrl+B)", () => Ne(), () => document.queryComm
|
|
|
923
967
|
maxHeight: 0,
|
|
924
968
|
focus: !1,
|
|
925
969
|
resizable: !0,
|
|
926
|
-
toolbar:
|
|
970
|
+
toolbar: en,
|
|
927
971
|
useBootstrap: !1,
|
|
928
972
|
toolbarButtonClass: "btn btn-sm btn-light",
|
|
929
973
|
useFontAwesome: !0,
|
|
@@ -947,6 +991,9 @@ var dt = O("bold", "bold", "Bold (Ctrl+B)", () => Ne(), () => document.queryComm
|
|
|
947
991
|
theme: "light",
|
|
948
992
|
codeHighlight: !0,
|
|
949
993
|
codeHighlightCDN: "https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0",
|
|
994
|
+
cspNonce: "",
|
|
995
|
+
externalAssetCrossOrigin: "anonymous",
|
|
996
|
+
externalAssetReferrerPolicy: "no-referrer",
|
|
950
997
|
markdownPaste: !0,
|
|
951
998
|
historyLimit: 100,
|
|
952
999
|
historyMaxBytes: 10 * 1024 * 1024,
|
|
@@ -1374,23 +1421,23 @@ var dt = O("bold", "bold", "Bold (Ctrl+B)", () => Ne(), () => document.queryComm
|
|
|
1374
1421
|
table: "Table",
|
|
1375
1422
|
image: "Image"
|
|
1376
1423
|
}
|
|
1377
|
-
},
|
|
1378
|
-
function
|
|
1424
|
+
}, nn = { en: A };
|
|
1425
|
+
function rn(e, t) {
|
|
1379
1426
|
if (typeof e != "string" || !e) throw TypeError("[AutumnNote] registerLocale: code must be a non-empty string.");
|
|
1380
1427
|
if (!t || typeof t != "object") throw TypeError(`[AutumnNote] registerLocale: locale for "${e}" must be an object.`);
|
|
1381
|
-
|
|
1428
|
+
nn[e] = t;
|
|
1382
1429
|
}
|
|
1383
|
-
function
|
|
1430
|
+
function an(e) {
|
|
1384
1431
|
if (!e || e === "en") return A;
|
|
1385
1432
|
if (typeof e == "string") {
|
|
1386
|
-
let t =
|
|
1433
|
+
let t = nn[e];
|
|
1387
1434
|
return t ? c(c({}, A), t) : (console.warn(`[AutumnNote] Locale "${e}" is not registered, falling back to English. Import it first: import { ${e} } from 'autumnnote/i18n/${e}'; AutumnNote.registerLocale('${e}', ${e});`), A);
|
|
1388
1435
|
}
|
|
1389
1436
|
return typeof e == "object" ? c(c({}, A), e) : A;
|
|
1390
1437
|
}
|
|
1391
1438
|
//#endregion
|
|
1392
1439
|
//#region src/js/core/sanitise.js
|
|
1393
|
-
var
|
|
1440
|
+
var on = [
|
|
1394
1441
|
"script",
|
|
1395
1442
|
"style",
|
|
1396
1443
|
"iframe",
|
|
@@ -1413,7 +1460,7 @@ var tn = [
|
|
|
1413
1460
|
"mglyph",
|
|
1414
1461
|
"malignmark",
|
|
1415
1462
|
"annotation-xml"
|
|
1416
|
-
],
|
|
1463
|
+
], sn = /* @__PURE__ */ new Set(["button"]), cn = [
|
|
1417
1464
|
"href",
|
|
1418
1465
|
"src",
|
|
1419
1466
|
"action",
|
|
@@ -1422,11 +1469,11 @@ var tn = [
|
|
|
1422
1469
|
"poster",
|
|
1423
1470
|
"background",
|
|
1424
1471
|
"srcset"
|
|
1425
|
-
],
|
|
1472
|
+
], ln = /* @__PURE__ */ new Set([
|
|
1426
1473
|
"poster",
|
|
1427
1474
|
"background",
|
|
1428
1475
|
"srcset"
|
|
1429
|
-
]),
|
|
1476
|
+
]), un = /* @__PURE__ */ new Set(["ping"]), dn = /* @__PURE__ */ new Set([
|
|
1430
1477
|
"color",
|
|
1431
1478
|
"background-color",
|
|
1432
1479
|
"font-size",
|
|
@@ -1442,31 +1489,31 @@ var tn = [
|
|
|
1442
1489
|
"border-color",
|
|
1443
1490
|
"padding",
|
|
1444
1491
|
"white-space"
|
|
1445
|
-
]),
|
|
1492
|
+
]), fn = /url\s*\(|image-set\s*\(|src\s*\(|expression\s*\(|@import|javascript:|vbscript:|behavior\s*:|-moz-binding/i, pn = /* @__PURE__ */ new Set([
|
|
1446
1493
|
"www.youtube.com",
|
|
1447
1494
|
"youtube.com",
|
|
1448
1495
|
"m.youtube.com",
|
|
1449
1496
|
"www.youtube-nocookie.com",
|
|
1450
1497
|
"youtube-nocookie.com",
|
|
1451
1498
|
"player.vimeo.com"
|
|
1452
|
-
]),
|
|
1499
|
+
]), mn = /* @__PURE__ */ new Set([
|
|
1453
1500
|
"http:",
|
|
1454
1501
|
"https:",
|
|
1455
1502
|
"mailto:",
|
|
1456
1503
|
"tel:"
|
|
1457
|
-
]),
|
|
1504
|
+
]), hn = /* @__PURE__ */ new Set([
|
|
1458
1505
|
"http:",
|
|
1459
1506
|
"https:",
|
|
1460
1507
|
"blob:"
|
|
1461
|
-
]),
|
|
1508
|
+
]), gn = /^data:image\/(?:png|jpe?g|gif|webp|avif|bmp);base64,[a-z0-9+/=\s]+$/i, _n = "https://autumnnote.invalid/";
|
|
1462
1509
|
function j(e, t) {
|
|
1463
|
-
return
|
|
1510
|
+
return vn(e, t).innerHTML;
|
|
1464
1511
|
}
|
|
1465
|
-
function
|
|
1466
|
-
let n = new DOMParser().parseFromString(`<body>${e || ""}</body>`, "text/html"), r = Array.from(n.querySelectorAll("*")), i = new Set(t ?
|
|
1512
|
+
function vn(e, { allowIframes: t = !1 } = {}) {
|
|
1513
|
+
let n = new DOMParser().parseFromString(`<body>${e || ""}</body>`, "text/html"), r = Array.from(n.querySelectorAll("*")), i = new Set(t ? on.filter((e) => e !== "iframe") : on);
|
|
1467
1514
|
for (let e of r) {
|
|
1468
1515
|
let t = e.tagName.toLowerCase();
|
|
1469
|
-
if (
|
|
1516
|
+
if (sn.has(t)) {
|
|
1470
1517
|
e.replaceWith(...e.childNodes);
|
|
1471
1518
|
continue;
|
|
1472
1519
|
}
|
|
@@ -1476,7 +1523,7 @@ function mn(e, { allowIframes: t = !1 } = {}) {
|
|
|
1476
1523
|
}
|
|
1477
1524
|
if (t === "iframe") {
|
|
1478
1525
|
let t = e.getAttribute("src");
|
|
1479
|
-
if (!t || !
|
|
1526
|
+
if (!t || !xn(t)) {
|
|
1480
1527
|
e.remove();
|
|
1481
1528
|
continue;
|
|
1482
1529
|
}
|
|
@@ -1487,22 +1534,22 @@ function mn(e, { allowIframes: t = !1 } = {}) {
|
|
|
1487
1534
|
continue;
|
|
1488
1535
|
}
|
|
1489
1536
|
if (t.name === "style") {
|
|
1490
|
-
let n =
|
|
1537
|
+
let n = yn(t.value);
|
|
1491
1538
|
n ? e.setAttribute("style", n) : e.removeAttribute("style");
|
|
1492
1539
|
continue;
|
|
1493
1540
|
}
|
|
1494
|
-
if (
|
|
1541
|
+
if (un.has(t.name)) {
|
|
1495
1542
|
e.removeAttribute(t.name);
|
|
1496
1543
|
continue;
|
|
1497
1544
|
}
|
|
1498
|
-
if (
|
|
1499
|
-
let n = t.value.trim(), r =
|
|
1545
|
+
if (cn.includes(t.name)) {
|
|
1546
|
+
let n = t.value.trim(), r = ln.has(t.name) || t.name === "src" && [
|
|
1500
1547
|
"IMG",
|
|
1501
1548
|
"VIDEO",
|
|
1502
1549
|
"AUDIO",
|
|
1503
1550
|
"SOURCE"
|
|
1504
1551
|
].includes(e.tagName), i = e.tagName === "IMG";
|
|
1505
|
-
if (!(t.name === "srcset" ?
|
|
1552
|
+
if (!(t.name === "srcset" ? bn(n, { allowData: i }) : Sn(n, {
|
|
1506
1553
|
media: r,
|
|
1507
1554
|
allowData: i
|
|
1508
1555
|
}))) {
|
|
@@ -1515,7 +1562,7 @@ function mn(e, { allowIframes: t = !1 } = {}) {
|
|
|
1515
1562
|
e.removeAttribute(t.name);
|
|
1516
1563
|
continue;
|
|
1517
1564
|
}
|
|
1518
|
-
t.name === "src" && !
|
|
1565
|
+
t.name === "src" && !xn(t.value) && e.removeAttribute(t.name);
|
|
1519
1566
|
}
|
|
1520
1567
|
}
|
|
1521
1568
|
if (t === "a" && e.getAttribute("target") === "_blank" && e.setAttribute("rel", "noopener noreferrer"), t === "input") if (!(e.closest("ul.an-checklist") !== null && e.closest("li") !== null) || e.getAttribute("type") !== "checkbox") e.remove();
|
|
@@ -1527,58 +1574,58 @@ function mn(e, { allowIframes: t = !1 } = {}) {
|
|
|
1527
1574
|
}
|
|
1528
1575
|
return n.body;
|
|
1529
1576
|
}
|
|
1530
|
-
function
|
|
1577
|
+
function yn(e) {
|
|
1531
1578
|
let t = [];
|
|
1532
1579
|
for (let n of (e || "").split(";")) {
|
|
1533
1580
|
let e = n.indexOf(":");
|
|
1534
1581
|
if (e === -1) continue;
|
|
1535
1582
|
let r = n.slice(0, e).trim().toLowerCase(), i = n.slice(e + 1).trim();
|
|
1536
|
-
!r || !i ||
|
|
1583
|
+
!r || !i || dn.has(r) && (fn.test(i) || t.push(`${r}: ${i}`));
|
|
1537
1584
|
}
|
|
1538
1585
|
return t.join("; ");
|
|
1539
1586
|
}
|
|
1540
|
-
function
|
|
1587
|
+
function bn(e, { allowData: t = !1 } = {}) {
|
|
1541
1588
|
let n = (e || "").trim().split(/\s+/).filter(Boolean);
|
|
1542
1589
|
for (let e of n) {
|
|
1543
1590
|
if (/^[\d.]+[xw],?$/i.test(e)) continue;
|
|
1544
1591
|
let n = e.replace(/,+$/, "");
|
|
1545
|
-
if (n && !
|
|
1592
|
+
if (n && !Sn(n, {
|
|
1546
1593
|
media: !0,
|
|
1547
1594
|
allowData: t
|
|
1548
1595
|
})) return !1;
|
|
1549
1596
|
}
|
|
1550
1597
|
return !0;
|
|
1551
1598
|
}
|
|
1552
|
-
function
|
|
1599
|
+
function xn(e) {
|
|
1553
1600
|
let t = (e || "").trim();
|
|
1554
1601
|
if (!t || t.startsWith("//") || t.startsWith("/")) return !1;
|
|
1555
1602
|
try {
|
|
1556
1603
|
let e = new URL(t);
|
|
1557
|
-
return e.protocol === "https:" &&
|
|
1604
|
+
return e.protocol === "https:" && pn.has(e.hostname.toLowerCase());
|
|
1558
1605
|
} catch {
|
|
1559
1606
|
return !1;
|
|
1560
1607
|
}
|
|
1561
1608
|
}
|
|
1562
1609
|
function M(e, { allowData: t = !1, media: n = t } = {}) {
|
|
1563
1610
|
let r = (e || "").trim();
|
|
1564
|
-
return !r && e == null ? null :
|
|
1611
|
+
return !r && e == null ? null : Sn(r, {
|
|
1565
1612
|
media: n,
|
|
1566
1613
|
allowData: t
|
|
1567
1614
|
}) ? e : null;
|
|
1568
1615
|
}
|
|
1569
|
-
function
|
|
1616
|
+
function Sn(e, { media: t = !1, allowData: n = !1 } = {}) {
|
|
1570
1617
|
let r = (e || "").trim();
|
|
1571
|
-
if (!r || n &&
|
|
1618
|
+
if (!r || n && gn.test(r)) return !0;
|
|
1572
1619
|
try {
|
|
1573
|
-
let e = new URL(r,
|
|
1574
|
-
return (t ?
|
|
1620
|
+
let e = new URL(r, _n);
|
|
1621
|
+
return (t ? hn : mn).has(e.protocol);
|
|
1575
1622
|
} catch {
|
|
1576
1623
|
return !1;
|
|
1577
1624
|
}
|
|
1578
1625
|
}
|
|
1579
1626
|
//#endregion
|
|
1580
1627
|
//#region src/js/renderer.js
|
|
1581
|
-
function
|
|
1628
|
+
function Cn(e, t) {
|
|
1582
1629
|
let n = w("div", { class: "an-container" }), r = w("div", {
|
|
1583
1630
|
class: "an-editable",
|
|
1584
1631
|
contenteditable: t.readOnly ? "false" : "true",
|
|
@@ -1601,16 +1648,16 @@ function yn(e, t) {
|
|
|
1601
1648
|
}
|
|
1602
1649
|
//#endregion
|
|
1603
1650
|
//#region src/js/Context.js
|
|
1604
|
-
var
|
|
1605
|
-
function
|
|
1606
|
-
|
|
1651
|
+
var wn = /* @__PURE__ */ new Map(), Tn = [];
|
|
1652
|
+
function En(e) {
|
|
1653
|
+
Tn = Array.isArray(e) ? e : [];
|
|
1607
1654
|
}
|
|
1608
|
-
var
|
|
1655
|
+
var Dn = /* @__PURE__ */ new Map(), On = class {
|
|
1609
1656
|
constructor(e, t = {}) {
|
|
1610
|
-
this.targetEl = e, this.options = c(k, t), this.locale =
|
|
1657
|
+
this.targetEl = e, this.options = c(k, t), this.locale = an(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;
|
|
1611
1658
|
}
|
|
1612
1659
|
initialize() {
|
|
1613
|
-
let { container: e, editable: t } =
|
|
1660
|
+
let { container: e, editable: t } = Cn(this.targetEl, this.options);
|
|
1614
1661
|
this.layoutInfo.container = e, this.layoutInfo.editable = t, this._registerModules();
|
|
1615
1662
|
let n = this._modules.get("toolbar");
|
|
1616
1663
|
n?.el && (e.insertBefore(n.el, t), this.layoutInfo.toolbar = n.el);
|
|
@@ -1622,11 +1669,11 @@ var Cn = /* @__PURE__ */ new Map(), wn = class {
|
|
|
1622
1669
|
let n = new t(this);
|
|
1623
1670
|
this._modules.set(e, n), n.initialize();
|
|
1624
1671
|
};
|
|
1625
|
-
for (let { name: t, Class: n, enabled: r } of
|
|
1626
|
-
if (
|
|
1672
|
+
for (let { name: t, Class: n, enabled: r } of Tn) typeof r == "function" && !r(this.options) || e(t, n);
|
|
1673
|
+
if (wn.size > 0) for (let [t, n] of wn) e(t, n);
|
|
1627
1674
|
}
|
|
1628
1675
|
_syncOptionalModules() {
|
|
1629
|
-
for (let { name: e, Class: t, enabled: n } of
|
|
1676
|
+
for (let { name: e, Class: t, enabled: n } of Tn) {
|
|
1630
1677
|
if (typeof n != "function") continue;
|
|
1631
1678
|
let r = n(this.options);
|
|
1632
1679
|
if (r !== this._modules.has(e)) if (r) {
|
|
@@ -1649,7 +1696,7 @@ var Cn = /* @__PURE__ */ new Map(), wn = class {
|
|
|
1649
1696
|
return n >= 0 ? t[n] = e : t.push(e), this.invoke("slashMenu.refresh"), this;
|
|
1650
1697
|
}
|
|
1651
1698
|
use(e, t = {}) {
|
|
1652
|
-
return Array.isArray(e.buttons) && e.buttons.forEach((e) =>
|
|
1699
|
+
return Array.isArray(e.buttons) && e.buttons.forEach((e) => pt(e)), this._installPlugin(e, t), this;
|
|
1653
1700
|
}
|
|
1654
1701
|
getPlugin(e) {
|
|
1655
1702
|
return this._plugins.get(e)?.publicApi ?? null;
|
|
@@ -1671,7 +1718,7 @@ var Cn = /* @__PURE__ */ new Map(), wn = class {
|
|
|
1671
1718
|
});
|
|
1672
1719
|
}
|
|
1673
1720
|
_applyGlobalPlugins() {
|
|
1674
|
-
if (
|
|
1721
|
+
if (Dn.size !== 0) for (let { plugin: e, options: t } of Dn.values()) this._installPlugin(e, t);
|
|
1675
1722
|
}
|
|
1676
1723
|
_bindEditorEvents(e) {
|
|
1677
1724
|
let t = E(e, "input", () => this._syncToTarget()), n = E(e, "focus", () => {
|
|
@@ -1917,14 +1964,22 @@ var Cn = /* @__PURE__ */ new Map(), wn = class {
|
|
|
1917
1964
|
} catch {}
|
|
1918
1965
|
this._plugins.clear(), this._disposers.forEach((e) => e()), this._disposers = [];
|
|
1919
1966
|
let t = this.layoutInfo.container, n = t?.classList.contains("an-theme-dark"), r = t?.classList.contains("an-theme-auto");
|
|
1920
|
-
return t?.parentNode && (this.targetEl.style.display = "", t.remove()), n && !document.querySelector(".an-container.an-theme-dark") && document.body.classList.remove("an-theme-dark"), r && !document.querySelector(".an-container.an-theme-auto") && document.body.classList.remove("an-theme-auto"), typeof this.options.onDestroy == "function" && this.options.onDestroy(this), this._alive = !1, this._destroyPromise = Promise.resolve(e).then(() => {
|
|
1967
|
+
return t?.parentNode && (this.targetEl.style.display = "", t.remove()), n && !document.querySelector(".an-container.an-theme-dark") && document.body.classList.remove("an-theme-dark"), r && !document.querySelector(".an-container.an-theme-auto") && document.body.classList.remove("an-theme-auto"), typeof this.options.onDestroy == "function" && this.options.onDestroy(this), this._alive = !1, this._releaseInstance?.(), this._releaseInstance = null, this._destroyPromise = Promise.resolve(e).then(() => {
|
|
1921
1968
|
this._listeners.clear();
|
|
1922
1969
|
}), this._destroyPromise;
|
|
1923
1970
|
}
|
|
1924
1971
|
_syncToTarget(e) {
|
|
1925
1972
|
(this.targetEl.tagName === "TEXTAREA" || this.targetEl.tagName === "INPUT") && (this.targetEl.value = typeof e == "string" ? e : this.getHTML());
|
|
1926
1973
|
}
|
|
1927
|
-
}
|
|
1974
|
+
};
|
|
1975
|
+
//#endregion
|
|
1976
|
+
//#region src/js/editing/History.js
|
|
1977
|
+
function kn(e, t) {
|
|
1978
|
+
let n = Math.min(e.length, t.length), r = 0;
|
|
1979
|
+
for (; r < n && e.charCodeAt(r) === t.charCodeAt(r);) r++;
|
|
1980
|
+
return r;
|
|
1981
|
+
}
|
|
1982
|
+
var An = class {
|
|
1928
1983
|
constructor(e, t = 100, n = 10 * 1024 * 1024) {
|
|
1929
1984
|
this.editable = e, this._limit = t, this._maxBytes = n, this._bytes = 0, this.stack = [], this.stackOffset = -1, this._savePoint();
|
|
1930
1985
|
}
|
|
@@ -1946,12 +2001,12 @@ var Cn = /* @__PURE__ */ new Map(), wn = class {
|
|
|
1946
2001
|
} : null;
|
|
1947
2002
|
}
|
|
1948
2003
|
_charOffset(e, t) {
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
2004
|
+
try {
|
|
2005
|
+
let n = document.createRange();
|
|
2006
|
+
return n.selectNodeContents(this.editable), n.setEnd(e, t), n.toString().length;
|
|
2007
|
+
} catch {
|
|
2008
|
+
return 0;
|
|
1953
2009
|
}
|
|
1954
|
-
return 0;
|
|
1955
2010
|
}
|
|
1956
2011
|
_restoreSelection(e) {
|
|
1957
2012
|
if (!e) return;
|
|
@@ -1998,7 +2053,18 @@ var Cn = /* @__PURE__ */ new Map(), wn = class {
|
|
|
1998
2053
|
this.stackOffset = this.stack.length - 1;
|
|
1999
2054
|
}
|
|
2000
2055
|
_restore(e) {
|
|
2001
|
-
|
|
2056
|
+
if (!e) return;
|
|
2057
|
+
let t = this.editable.textContent || "";
|
|
2058
|
+
this.editable.innerHTML = this._detokenizeImages(e);
|
|
2059
|
+
let n = e.sel;
|
|
2060
|
+
if (!n) {
|
|
2061
|
+
let e = kn(t, this.editable.textContent || "");
|
|
2062
|
+
n = {
|
|
2063
|
+
start: e,
|
|
2064
|
+
end: e
|
|
2065
|
+
};
|
|
2066
|
+
}
|
|
2067
|
+
this._restoreSelection(n);
|
|
2002
2068
|
}
|
|
2003
2069
|
_tokenizeImages(e) {
|
|
2004
2070
|
if (!e.includes("data:")) return {
|
|
@@ -2045,7 +2111,7 @@ var Cn = /* @__PURE__ */ new Map(), wn = class {
|
|
|
2045
2111
|
};
|
|
2046
2112
|
//#endregion
|
|
2047
2113
|
//#region src/js/editing/Table.js
|
|
2048
|
-
function
|
|
2114
|
+
function jn(e, t, n = {}) {
|
|
2049
2115
|
let { headerRow: r = !1 } = n, i = w("table", { class: "an-table" });
|
|
2050
2116
|
if (r && t > 0) {
|
|
2051
2117
|
let t = w("thead"), n = w("tr");
|
|
@@ -2067,9 +2133,9 @@ function En(e, t, n = {}) {
|
|
|
2067
2133
|
}
|
|
2068
2134
|
return i;
|
|
2069
2135
|
}
|
|
2070
|
-
function
|
|
2136
|
+
function Mn(e, t, n = {}) {
|
|
2071
2137
|
if (e <= 0 || t <= 0) return;
|
|
2072
|
-
let r =
|
|
2138
|
+
let r = jn(e, t, n), i = globalThis.getSelection();
|
|
2073
2139
|
if (!i || i.rangeCount === 0) return;
|
|
2074
2140
|
let a = i.getRangeAt(0);
|
|
2075
2141
|
try {
|
|
@@ -2157,8 +2223,28 @@ function F(e, t) {
|
|
|
2157
2223
|
}
|
|
2158
2224
|
//#endregion
|
|
2159
2225
|
//#region src/js/editing/Typing.js
|
|
2160
|
-
var
|
|
2161
|
-
function
|
|
2226
|
+
var Nn = /\bfa-/, I = (e) => !!(e?.nodeName === "I" && Nn.test(e.className || "")), Pn = (e) => e?.nodeType === Node.TEXT_NODE && (e.textContent === "" || e.textContent === "");
|
|
2227
|
+
function Fn(e, t, n) {
|
|
2228
|
+
let r = (e?.nodeType === Node.ELEMENT_NODE ? e : e?.parentElement ?? null)?.closest("td, th") ?? null;
|
|
2229
|
+
if (!r || !t.contains(r)) return !1;
|
|
2230
|
+
let i = r.closest("table");
|
|
2231
|
+
if (!i || !t.contains(i)) return !1;
|
|
2232
|
+
let a = Array.from(i.querySelectorAll("td, th")), o = a[a.indexOf(r) + (n ? -1 : 1)];
|
|
2233
|
+
if (o) return fe(o), !0;
|
|
2234
|
+
if (n) return !0;
|
|
2235
|
+
let s = In(r.closest("tr"))?.firstElementChild ?? null;
|
|
2236
|
+
return s && fe(s), !0;
|
|
2237
|
+
}
|
|
2238
|
+
function In(e) {
|
|
2239
|
+
if (!e?.parentNode) return null;
|
|
2240
|
+
let t = document.createElement("tr");
|
|
2241
|
+
for (let n of e.cells) {
|
|
2242
|
+
let e = document.createElement("td");
|
|
2243
|
+
e.appendChild(document.createElement("br")), n.hasAttribute("style") && e.setAttribute("style", n.getAttribute("style")), t.appendChild(e);
|
|
2244
|
+
}
|
|
2245
|
+
return e.parentNode.insertBefore(t, e.nextSibling), t;
|
|
2246
|
+
}
|
|
2247
|
+
function Ln(e, t) {
|
|
2162
2248
|
try {
|
|
2163
2249
|
let n = document.createRange();
|
|
2164
2250
|
return n.setStart(e.startContainer, e.startOffset), n.setEnd(t, t.childNodes.length), n.extractContents();
|
|
@@ -2166,7 +2252,7 @@ function An(e, t) {
|
|
|
2166
2252
|
return document.createDocumentFragment();
|
|
2167
2253
|
}
|
|
2168
2254
|
}
|
|
2169
|
-
function
|
|
2255
|
+
function Rn(e, t, n = {}) {
|
|
2170
2256
|
let r = (e) => {
|
|
2171
2257
|
let t = globalThis.getSelection();
|
|
2172
2258
|
if (!t) return !1;
|
|
@@ -2200,7 +2286,7 @@ function jn(e, t, n = {}) {
|
|
|
2200
2286
|
if (i.nodeType === Node.TEXT_NODE) {
|
|
2201
2287
|
let t = i;
|
|
2202
2288
|
if (a && n.startOffset === 1 && t.textContent === "" && I(t.previousSibling) || a && n.startOffset === 0 && I(t.previousSibling)) return e.preventDefault(), r((e) => e.setStartBefore(t.previousSibling));
|
|
2203
|
-
if (a && n.startOffset === 0 &&
|
|
2289
|
+
if (a && n.startOffset === 0 && Pn(t.previousSibling) && I(t.previousSibling.previousSibling)) return e.preventDefault(), r((e) => e.setStartBefore(t.previousSibling.previousSibling));
|
|
2204
2290
|
if (!a && n.startOffset === t.textContent.length && I(t.nextSibling)) {
|
|
2205
2291
|
let n = t.nextSibling, i = n.nextSibling;
|
|
2206
2292
|
if (e.preventDefault(), i?.nodeType === Node.TEXT_NODE) {
|
|
@@ -2209,7 +2295,7 @@ function jn(e, t, n = {}) {
|
|
|
2209
2295
|
}
|
|
2210
2296
|
return r((e) => e.setStartAfter(n));
|
|
2211
2297
|
}
|
|
2212
|
-
if (!a && n.startOffset === t.textContent.length &&
|
|
2298
|
+
if (!a && n.startOffset === t.textContent.length && Pn(t.nextSibling) && I(t.nextSibling.nextSibling)) {
|
|
2213
2299
|
let n = t.nextSibling.nextSibling, i = n.nextSibling;
|
|
2214
2300
|
if (e.preventDefault(), i?.nodeType === Node.TEXT_NODE) {
|
|
2215
2301
|
let e = +!!(i.textContent || "").startsWith("");
|
|
@@ -2223,7 +2309,7 @@ function jn(e, t, n = {}) {
|
|
|
2223
2309
|
if (a && n.startOffset > 0) {
|
|
2224
2310
|
let i = t.childNodes[n.startOffset - 1];
|
|
2225
2311
|
if (I(i)) return e.preventDefault(), r((e) => e.setStartBefore(i));
|
|
2226
|
-
if (
|
|
2312
|
+
if (Pn(i) && I(i.previousSibling)) return e.preventDefault(), r((e) => e.setStartBefore(i.previousSibling));
|
|
2227
2313
|
}
|
|
2228
2314
|
if (!a && n.startOffset < t.childNodes.length) {
|
|
2229
2315
|
let i = t.childNodes[n.startOffset];
|
|
@@ -2235,7 +2321,7 @@ function jn(e, t, n = {}) {
|
|
|
2235
2321
|
}
|
|
2236
2322
|
return r((e) => e.setStartAfter(i));
|
|
2237
2323
|
}
|
|
2238
|
-
if (
|
|
2324
|
+
if (Pn(i) && I(i.nextSibling)) {
|
|
2239
2325
|
let t = i.nextSibling, n = t.nextSibling;
|
|
2240
2326
|
if (e.preventDefault(), n?.nodeType === Node.TEXT_NODE) {
|
|
2241
2327
|
let e = +!!(n.textContent || "").startsWith("");
|
|
@@ -2247,16 +2333,17 @@ function jn(e, t, n = {}) {
|
|
|
2247
2333
|
}
|
|
2248
2334
|
}
|
|
2249
2335
|
if (P(e, N.TAB)) {
|
|
2250
|
-
let r =
|
|
2336
|
+
let r = ye(t);
|
|
2251
2337
|
if (!r) return !1;
|
|
2338
|
+
if (Fn(r.sc, t, e.shiftKey)) return e.preventDefault(), !0;
|
|
2252
2339
|
let i = C(r.sc, t);
|
|
2253
|
-
if (i && _(i)) return e.preventDefault(), e.shiftKey ?
|
|
2340
|
+
if (i && _(i)) return e.preventDefault(), e.shiftKey ? Qe() : Xe(), !0;
|
|
2254
2341
|
if (i?.nodeName.toUpperCase() === "PRE") return e.shiftKey ? !1 : (e.preventDefault(), D("insertText", " ".repeat(n.tabSize || 4)), !0);
|
|
2255
2342
|
if (n.tabSize) return e.shiftKey ? !1 : (e.preventDefault(), D("insertText", " ".repeat(n.tabSize)), !0);
|
|
2256
2343
|
}
|
|
2257
2344
|
if (P(e, N.ENTER) && e.shiftKey) return e.preventDefault(), D("insertLineBreak"), !0;
|
|
2258
2345
|
if (P(e, N.ENTER) && !e.shiftKey) {
|
|
2259
|
-
let n =
|
|
2346
|
+
let n = ye(t);
|
|
2260
2347
|
if (!n) return !1;
|
|
2261
2348
|
let r = n.sc, i = r.nodeType === 3 ? r.parentElement : r;
|
|
2262
2349
|
if (i?.nodeName === "I" && /\bfa-/.test(i.className || "")) {
|
|
@@ -2289,7 +2376,7 @@ function jn(e, t, n = {}) {
|
|
|
2289
2376
|
if (r.deleteContents(), n.rangeCount === 0 || !o.isConnected) return !0;
|
|
2290
2377
|
r = n.getRangeAt(0);
|
|
2291
2378
|
}
|
|
2292
|
-
let i =
|
|
2379
|
+
let i = Ln(r, o), a = document.createElement("li"), s = document.createElement("input");
|
|
2293
2380
|
s.type = "checkbox", s.setAttribute("contenteditable", "false"), a.appendChild(s), i.textContent.replace(/[\u00a0\u200B]/g, "").length > 0 && a.appendChild(i);
|
|
2294
2381
|
let c = a.childNodes[1];
|
|
2295
2382
|
c?.nodeType !== Node.TEXT_NODE && (c = document.createTextNode(""), a.appendChild(c)), o.after(a);
|
|
@@ -2306,14 +2393,98 @@ function jn(e, t, n = {}) {
|
|
|
2306
2393
|
return !1;
|
|
2307
2394
|
}
|
|
2308
2395
|
//#endregion
|
|
2396
|
+
//#region src/js/core/count.js
|
|
2397
|
+
var zn = typeof Intl < "u" && typeof Intl.Segmenter == "function" ? new Intl.Segmenter(void 0, { granularity: "word" }) : null;
|
|
2398
|
+
function Bn(e) {
|
|
2399
|
+
let t = e.trim();
|
|
2400
|
+
if (!t) return 0;
|
|
2401
|
+
if (zn) {
|
|
2402
|
+
let e = 0;
|
|
2403
|
+
for (let n of zn.segment(t)) n.isWordLike && e++;
|
|
2404
|
+
return e;
|
|
2405
|
+
}
|
|
2406
|
+
return t.split(/\s+/).length;
|
|
2407
|
+
}
|
|
2408
|
+
var Vn = /* @__PURE__ */ new Set(/* @__PURE__ */ "ADDRESS.ARTICLE.ASIDE.BLOCKQUOTE.BR.DD.DIV.DL.DT.FIELDSET.FIGCAPTION.FIGURE.FOOTER.FORM.H1.H2.H3.H4.H5.H6.HEADER.HR.LI.MAIN.NAV.OL.P.PRE.SECTION.TABLE.TBODY.TD.TFOOT.TH.THEAD.TR.UL".split("."));
|
|
2409
|
+
function Hn(e, t, n) {
|
|
2410
|
+
for (let r = e.firstChild; r; r = r.nextSibling) if (r.nodeType === 3) {
|
|
2411
|
+
let e = r.data;
|
|
2412
|
+
t.push(e), n.push(e);
|
|
2413
|
+
} else if (r.nodeType === 1) {
|
|
2414
|
+
let e = Vn.has(r.tagName);
|
|
2415
|
+
e && t.push("\n"), Hn(r, t, n), e && t.push("\n");
|
|
2416
|
+
}
|
|
2417
|
+
}
|
|
2418
|
+
function Un(e) {
|
|
2419
|
+
if (e.nodeType === 3) {
|
|
2420
|
+
let t = e.data;
|
|
2421
|
+
return {
|
|
2422
|
+
lines: t,
|
|
2423
|
+
flat: t
|
|
2424
|
+
};
|
|
2425
|
+
}
|
|
2426
|
+
let t = [], n = [];
|
|
2427
|
+
return Hn(e, t, n), {
|
|
2428
|
+
lines: t.join(""),
|
|
2429
|
+
flat: n.join("")
|
|
2430
|
+
};
|
|
2431
|
+
}
|
|
2432
|
+
var Wn = class {
|
|
2433
|
+
constructor() {
|
|
2434
|
+
this._cache = /* @__PURE__ */ new WeakMap();
|
|
2435
|
+
}
|
|
2436
|
+
counts(e) {
|
|
2437
|
+
let t = 0, n = 0, r = [], i = [], a = 0;
|
|
2438
|
+
for (let o = e.firstChild; o; o = o.nextSibling) {
|
|
2439
|
+
let e = this._cache.get(o);
|
|
2440
|
+
if (e && e.key === (o.textContent || "")) {
|
|
2441
|
+
t += e.words, n += e.chars;
|
|
2442
|
+
continue;
|
|
2443
|
+
}
|
|
2444
|
+
let { lines: s, flat: c } = Un(o);
|
|
2445
|
+
r.push({
|
|
2446
|
+
node: o,
|
|
2447
|
+
key: c,
|
|
2448
|
+
text: s,
|
|
2449
|
+
start: a
|
|
2450
|
+
}), i.push(s), a += s.length + 1;
|
|
2451
|
+
}
|
|
2452
|
+
if (r.length) {
|
|
2453
|
+
let e = Gn(r, i.join("\n"));
|
|
2454
|
+
r.forEach((r, i) => {
|
|
2455
|
+
let a = {
|
|
2456
|
+
key: r.key,
|
|
2457
|
+
words: e[i],
|
|
2458
|
+
chars: r.key.replaceAll("\n", "").length
|
|
2459
|
+
};
|
|
2460
|
+
this._cache.set(r.node, a), t += a.words, n += a.chars;
|
|
2461
|
+
});
|
|
2462
|
+
}
|
|
2463
|
+
return {
|
|
2464
|
+
words: t,
|
|
2465
|
+
chars: n
|
|
2466
|
+
};
|
|
2467
|
+
}
|
|
2468
|
+
};
|
|
2469
|
+
function Gn(e, t) {
|
|
2470
|
+
if (!zn) return e.map((e) => Bn(e.text));
|
|
2471
|
+
let n = Array(e.length).fill(0), r = 0;
|
|
2472
|
+
for (let i of zn.segment(t)) if (i.isWordLike) {
|
|
2473
|
+
for (; r < e.length - 1 && i.index >= e[r + 1].start;) r++;
|
|
2474
|
+
n[r]++;
|
|
2475
|
+
}
|
|
2476
|
+
return n;
|
|
2477
|
+
}
|
|
2478
|
+
//#endregion
|
|
2309
2479
|
//#region src/js/core/markdown.js
|
|
2310
|
-
function
|
|
2311
|
-
|
|
2480
|
+
function Kn(e) {
|
|
2481
|
+
let t = new DOMParser().parseFromString(`<body>${e || ""}</body>`, "text/html");
|
|
2482
|
+
return pe(t.body), er(t.body).replace(/\n{3,}/g, "\n\n").trim();
|
|
2312
2483
|
}
|
|
2313
|
-
function
|
|
2484
|
+
function qn(e, t) {
|
|
2314
2485
|
return Array.from(e.children).filter((e) => e.tagName === t.toUpperCase());
|
|
2315
2486
|
}
|
|
2316
|
-
function
|
|
2487
|
+
function Jn(e) {
|
|
2317
2488
|
let t = "";
|
|
2318
2489
|
for (let n of e.childNodes) {
|
|
2319
2490
|
if (n.nodeType === 3) {
|
|
@@ -2327,40 +2498,40 @@ function Pn(e) {
|
|
|
2327
2498
|
continue;
|
|
2328
2499
|
}
|
|
2329
2500
|
if (e === "div" || e === "p") {
|
|
2330
|
-
t && !t.endsWith("\n") && (t += "\n"), t +=
|
|
2501
|
+
t && !t.endsWith("\n") && (t += "\n"), t += Jn(n), t += "\n";
|
|
2331
2502
|
continue;
|
|
2332
2503
|
}
|
|
2333
|
-
t +=
|
|
2504
|
+
t += Jn(n);
|
|
2334
2505
|
}
|
|
2335
2506
|
return t;
|
|
2336
2507
|
}
|
|
2337
|
-
function
|
|
2508
|
+
function Yn(e) {
|
|
2338
2509
|
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`\~`);
|
|
2339
2510
|
}
|
|
2340
|
-
function
|
|
2511
|
+
function Xn(e) {
|
|
2341
2512
|
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}`);
|
|
2342
2513
|
}
|
|
2343
|
-
function
|
|
2344
|
-
return e.split("\n").map(
|
|
2514
|
+
function Zn(e) {
|
|
2515
|
+
return e.split("\n").map(Xn).join("\n");
|
|
2345
2516
|
}
|
|
2346
|
-
function
|
|
2517
|
+
function Qn(e, t) {
|
|
2347
2518
|
let n = " ".repeat(t + 1);
|
|
2348
|
-
return
|
|
2519
|
+
return er(e, t + 1).trim().split("\n").map((e, t) => t === 0 || e.trim() === "" || e.startsWith(n) ? e : n + e).join("\n");
|
|
2349
2520
|
}
|
|
2350
|
-
function
|
|
2521
|
+
function $n(e, t) {
|
|
2351
2522
|
let n = e.getAttribute(t) || "", r = /[\s()]/.test(n) ? `<${n}>` : n, i = e.getAttribute("title");
|
|
2352
2523
|
return i ? `${r} "${i.replaceAll("\"", String.raw`\"`)}"` : r;
|
|
2353
2524
|
}
|
|
2354
|
-
function
|
|
2525
|
+
function er(e, t = 0) {
|
|
2355
2526
|
if (e.nodeType === 3) {
|
|
2356
2527
|
let t = e.textContent.replace(/\s+/g, " ");
|
|
2357
|
-
return e.parentElement?.closest("pre, code") ? t :
|
|
2528
|
+
return e.parentElement?.closest("pre, code") ? t : Yn(t);
|
|
2358
2529
|
}
|
|
2359
2530
|
if (e.nodeType !== 1) return "";
|
|
2360
|
-
let n = e, r = n.nodeName.toLowerCase(), i = () => Array.from(n.childNodes).map((e) =>
|
|
2531
|
+
let n = e, r = n.nodeName.toLowerCase(), i = () => Array.from(n.childNodes).map((e) => er(e, t)).join("");
|
|
2361
2532
|
switch (r) {
|
|
2362
2533
|
case "p":
|
|
2363
|
-
case "div": return `\n\n${
|
|
2534
|
+
case "div": return `\n\n${Zn(i())}\n\n`;
|
|
2364
2535
|
case "br": return " \n";
|
|
2365
2536
|
case "h1": return `\n\n# ${i()}\n\n`;
|
|
2366
2537
|
case "h2": return `\n\n## ${i()}\n\n`;
|
|
@@ -2389,27 +2560,27 @@ function Bn(e, t = 0) {
|
|
|
2389
2560
|
}
|
|
2390
2561
|
case "pre": {
|
|
2391
2562
|
let e = n.querySelector("code"), t = /language-(\S+)/.exec(e?.className || "");
|
|
2392
|
-
return `\n\n\`\`\`${t ? t[1] : ""}\n${
|
|
2563
|
+
return `\n\n\`\`\`${t ? t[1] : ""}\n${Jn(e || n).replace(/\n$/, "")}\n\`\`\`\n\n`;
|
|
2393
2564
|
}
|
|
2394
2565
|
case "blockquote": {
|
|
2395
2566
|
let e = i().trim().split("\n");
|
|
2396
2567
|
return `\n\n${e.filter((t, n) => t.trim() !== "" || (e[n - 1] ?? "").trim() !== "").map((e) => e.trim() === "" ? ">" : `> ${e}`).join("\n")}\n\n`;
|
|
2397
2568
|
}
|
|
2398
|
-
case "a": return `[${i()}](${
|
|
2399
|
-
case "img": return `})`;
|
|
2570
|
+
case "img": return `})`;
|
|
2400
2571
|
case "ul": {
|
|
2401
|
-
let e =
|
|
2572
|
+
let e = qn(n, "li");
|
|
2402
2573
|
if (!e.length) return i();
|
|
2403
2574
|
let r = " ".repeat(t), a = n.classList.contains("an-checklist"), o = e.map((e) => {
|
|
2404
|
-
let n =
|
|
2405
|
-
return (a || n) && (i = n && n.checked ? "- [x] " : "- [ ] "), `${r}${i}${
|
|
2575
|
+
let n = qn(e, "input").find((e) => e.getAttribute("type") === "checkbox"), i = "- ";
|
|
2576
|
+
return (a || n) && (i = n && n.checked ? "- [x] " : "- [ ] "), `${r}${i}${Qn(e, t)}`;
|
|
2406
2577
|
}).join("\n");
|
|
2407
2578
|
return t === 0 ? `\n\n${o}\n\n` : `\n${o}`;
|
|
2408
2579
|
}
|
|
2409
2580
|
case "ol": {
|
|
2410
|
-
let e =
|
|
2581
|
+
let e = qn(n, "li");
|
|
2411
2582
|
if (!e.length) return i();
|
|
2412
|
-
let r = " ".repeat(t), a = Number.parseInt(n.getAttribute("start") || "1", 10), o = Number.isFinite(a) ? a : 1, s = e.map((e, n) => `${r}${o + n}. ${
|
|
2583
|
+
let r = " ".repeat(t), a = Number.parseInt(n.getAttribute("start") || "1", 10), o = Number.isFinite(a) ? a : 1, s = e.map((e, n) => `${r}${o + n}. ${Qn(e, t)}`).join("\n");
|
|
2413
2584
|
return t === 0 ? `\n\n${s}\n\n` : `\n${s}`;
|
|
2414
2585
|
}
|
|
2415
2586
|
case "li": return i();
|
|
@@ -2417,7 +2588,7 @@ function Bn(e, t = 0) {
|
|
|
2417
2588
|
case "table": {
|
|
2418
2589
|
let e = Array.from(n.querySelectorAll("tr"));
|
|
2419
2590
|
if (!e.length) return i();
|
|
2420
|
-
let t = !!
|
|
2591
|
+
let t = !!qn(n, "thead")[0] || e[0].children.length > 0 && Array.from(e[0].children).every((e) => e.tagName === "TH"), r = e.map((e) => Array.from(e.querySelectorAll("th, td")).map((e) => Yn(e.textContent.trim()).replaceAll("|", String.raw`\|`))), a = Math.max(...r.map((e) => e.length)), o = (e) => {
|
|
2421
2592
|
let t = [...e];
|
|
2422
2593
|
for (; t.length < a;) t.push("");
|
|
2423
2594
|
return t;
|
|
@@ -2432,16 +2603,16 @@ function Bn(e, t = 0) {
|
|
|
2432
2603
|
default: return i();
|
|
2433
2604
|
}
|
|
2434
2605
|
}
|
|
2435
|
-
function
|
|
2606
|
+
function tr(e) {
|
|
2436
2607
|
return String(e ?? "").replace(/^\ufeff/, "");
|
|
2437
2608
|
}
|
|
2438
|
-
function
|
|
2439
|
-
let t =
|
|
2609
|
+
function nr(e) {
|
|
2610
|
+
let t = tr(e);
|
|
2440
2611
|
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);
|
|
2441
2612
|
}
|
|
2442
|
-
var
|
|
2443
|
-
function
|
|
2444
|
-
let t =
|
|
2613
|
+
var rr = /^ {0,3}>( ?)(.*)$/, ir = /^(?: {4}|\t)\s*\S/, ar = /^( {0,3})(`{3,}|~{3,})[ \t]*([^\s`~][^\n]*)?$/;
|
|
2614
|
+
function or(e) {
|
|
2615
|
+
let t = ar.exec(e);
|
|
2445
2616
|
if (!t) return null;
|
|
2446
2617
|
let [, n, r, i = ""] = t;
|
|
2447
2618
|
return r[0] === "`" && i.includes("`") ? null : {
|
|
@@ -2451,7 +2622,7 @@ function Kn(e) {
|
|
|
2451
2622
|
lang: i.trim().split(/\s+/)[0] || ""
|
|
2452
2623
|
};
|
|
2453
2624
|
}
|
|
2454
|
-
function
|
|
2625
|
+
function sr(e, t) {
|
|
2455
2626
|
let n = 0, r = 0;
|
|
2456
2627
|
for (; r < e.length && n < t;) {
|
|
2457
2628
|
if (e[r] === " ") {
|
|
@@ -2468,40 +2639,40 @@ function qn(e, t) {
|
|
|
2468
2639
|
}
|
|
2469
2640
|
return e.slice(r);
|
|
2470
2641
|
}
|
|
2471
|
-
var
|
|
2472
|
-
function
|
|
2473
|
-
let t =
|
|
2474
|
-
t =
|
|
2475
|
-
let n =
|
|
2476
|
-
return t = n.clean,
|
|
2642
|
+
var cr = /^ {0,3}([-*_])( *\1){2,}\s*$/, lr = "";
|
|
2643
|
+
function ur(e) {
|
|
2644
|
+
let t = tr(e).replaceAll("\r\n", "\n").replaceAll("\r", "\n").split("\n");
|
|
2645
|
+
t = mr(t);
|
|
2646
|
+
let n = hr(t);
|
|
2647
|
+
return t = n.clean, fr = n.linkDefs, pr = n.footnoteIds, dr(t);
|
|
2477
2648
|
}
|
|
2478
|
-
function
|
|
2649
|
+
function dr(e) {
|
|
2479
2650
|
let t = [], n = 0;
|
|
2480
2651
|
for (; n < e.length;) {
|
|
2481
|
-
let r = e[n], i =
|
|
2652
|
+
let r = e[n], i = or(r);
|
|
2482
2653
|
if (i) {
|
|
2483
2654
|
let r = RegExp(`^ {0,3}\\${i.marker}{${i.length},}[ \t]*$`), a = [];
|
|
2484
|
-
for (n++; n < e.length && !r.test(e[n]);) a.push(
|
|
2655
|
+
for (n++; n < e.length && !r.test(e[n]);) a.push(Rr(sr(e[n], i.indent))), n++;
|
|
2485
2656
|
let o = i.lang ? ` class="language-${z(i.lang)}"` : "";
|
|
2486
2657
|
t.push(`<pre><code${o}>${a.join("\n")}</code></pre>`), n++;
|
|
2487
2658
|
continue;
|
|
2488
2659
|
}
|
|
2489
|
-
if (
|
|
2660
|
+
if (ir.test(r)) {
|
|
2490
2661
|
let r = [];
|
|
2491
|
-
for (; n < e.length && (
|
|
2662
|
+
for (; n < e.length && (ir.test(e[n]) || e[n].trim() === "");) {
|
|
2492
2663
|
if (e[n].trim() === "") {
|
|
2493
2664
|
let t = n;
|
|
2494
2665
|
for (; t < e.length && e[t].trim() === "";) t++;
|
|
2495
|
-
if (t >= e.length || !
|
|
2666
|
+
if (t >= e.length || !ir.test(e[t])) break;
|
|
2496
2667
|
for (; n < t; n++) r.push("");
|
|
2497
2668
|
continue;
|
|
2498
2669
|
}
|
|
2499
|
-
r.push(
|
|
2670
|
+
r.push(Rr(sr(e[n], 4))), n++;
|
|
2500
2671
|
}
|
|
2501
2672
|
t.push(`<pre><code>${r.join("\n")}</code></pre>`);
|
|
2502
2673
|
continue;
|
|
2503
2674
|
}
|
|
2504
|
-
if (r.trim() && !
|
|
2675
|
+
if (r.trim() && !cr.test(r) && !/^#{1,6} /.test(r) && n + 1 < e.length) {
|
|
2505
2676
|
if (/^=+\s*$/.test(e[n + 1])) {
|
|
2506
2677
|
t.push(`<h1>${R(r.trim())}</h1>`), n += 2;
|
|
2507
2678
|
continue;
|
|
@@ -2511,7 +2682,7 @@ function Zn(e) {
|
|
|
2511
2682
|
continue;
|
|
2512
2683
|
}
|
|
2513
2684
|
}
|
|
2514
|
-
if (
|
|
2685
|
+
if (cr.test(r)) {
|
|
2515
2686
|
t.push("<hr>"), n++;
|
|
2516
2687
|
continue;
|
|
2517
2688
|
}
|
|
@@ -2521,19 +2692,19 @@ function Zn(e) {
|
|
|
2521
2692
|
t.push(`<h${e}>${R(r)}</h${e}>`), n++;
|
|
2522
2693
|
continue;
|
|
2523
2694
|
}
|
|
2524
|
-
if (
|
|
2695
|
+
if (rr.test(r)) {
|
|
2525
2696
|
let r = [];
|
|
2526
|
-
for (; n < e.length &&
|
|
2527
|
-
t.push(`<blockquote>${
|
|
2697
|
+
for (; n < e.length && rr.test(e[n]);) r.push(rr.exec(e[n])[2]), n++;
|
|
2698
|
+
t.push(`<blockquote>${dr(r)}</blockquote>`);
|
|
2528
2699
|
continue;
|
|
2529
2700
|
}
|
|
2530
2701
|
if (/^[-*+] /.test(r)) {
|
|
2531
|
-
let { html: r, endIdx: i } =
|
|
2702
|
+
let { html: r, endIdx: i } = xr(e, n);
|
|
2532
2703
|
t.push(r), n = i;
|
|
2533
2704
|
continue;
|
|
2534
2705
|
}
|
|
2535
2706
|
if (/^\d+[.)] /.test(r)) {
|
|
2536
|
-
let { html: r, endIdx: i } =
|
|
2707
|
+
let { html: r, endIdx: i } = xr(e, n);
|
|
2537
2708
|
t.push(r), n = i;
|
|
2538
2709
|
continue;
|
|
2539
2710
|
}
|
|
@@ -2541,23 +2712,23 @@ function Zn(e) {
|
|
|
2541
2712
|
n++;
|
|
2542
2713
|
continue;
|
|
2543
2714
|
}
|
|
2544
|
-
if (
|
|
2545
|
-
let i =
|
|
2715
|
+
if (yr(e, n)) {
|
|
2716
|
+
let i = br(r), a = br(e[n + 1]).map((e) => e.startsWith(":") && e.endsWith(":") ? "center" : e.endsWith(":") ? "right" : e.startsWith(":") ? "left" : null);
|
|
2546
2717
|
n += 2;
|
|
2547
2718
|
let o = [];
|
|
2548
|
-
for (; n < e.length && e[n].trim() !== "" &&
|
|
2719
|
+
for (; n < e.length && e[n].trim() !== "" && vr(e[n]);) o.push(br(e[n])), n++;
|
|
2549
2720
|
let s = (e, t, n) => `<${e}${n ? ` style="text-align:${n}"` : ""}>${R(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>` : "";
|
|
2550
2721
|
t.push(`<table>${c}${l}</table>`);
|
|
2551
2722
|
continue;
|
|
2552
2723
|
}
|
|
2553
2724
|
let o = [];
|
|
2554
|
-
for (; n < e.length && e[n].trim() !== "" && !/^(#{1,6} |[-*+] |\d+[.)] )/.test(e[n]) && !
|
|
2555
|
-
o.length ? t.push(`<p>${R(
|
|
2725
|
+
for (; n < e.length && e[n].trim() !== "" && !/^(#{1,6} |[-*+] |\d+[.)] )/.test(e[n]) && !or(e[n]) && !rr.test(e[n]) && !cr.test(e[n]) && !yr(e, n) && !(n + 1 < e.length && /^=+\s*$/.test(e[n + 1])) && !(n + 1 < e.length && /^-{2,}\s*$/.test(e[n + 1]));) o.push(e[n]), n++;
|
|
2726
|
+
o.length ? t.push(`<p>${R(gr(o)).replaceAll(lr, "<br>")}</p>`) : (t.push(`<p>${R(r)}</p>`), n++);
|
|
2556
2727
|
}
|
|
2557
2728
|
return t.join("");
|
|
2558
2729
|
}
|
|
2559
|
-
var
|
|
2560
|
-
function
|
|
2730
|
+
var fr = /* @__PURE__ */ new Map(), pr = /* @__PURE__ */ new Set();
|
|
2731
|
+
function mr(e) {
|
|
2561
2732
|
if ((e[0] || "").trim() !== "---") return e;
|
|
2562
2733
|
let t = -1;
|
|
2563
2734
|
for (let n = 1; n < e.length; n++) {
|
|
@@ -2571,14 +2742,14 @@ function er(e) {
|
|
|
2571
2742
|
let n = t + 1;
|
|
2572
2743
|
return e[n] !== void 0 && e[n].trim() === "" && n++, e.slice(n);
|
|
2573
2744
|
}
|
|
2574
|
-
function
|
|
2745
|
+
function hr(e) {
|
|
2575
2746
|
let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set(), r = [], i = !1, a = /^\[([^\]]+)\]:\s*(\S+)(?:\s+"([^"]*)")?\s*$/, o = /^\[\^([^\]]+)\]:[ \t]*(\S.*)$/;
|
|
2576
2747
|
for (let s of e) {
|
|
2577
2748
|
if (i) {
|
|
2578
2749
|
/^ {0,3}(?:`{3,}|~{3,})[ \t]*$/.test(s) && (i = !1), r.push(s);
|
|
2579
2750
|
continue;
|
|
2580
2751
|
}
|
|
2581
|
-
if (
|
|
2752
|
+
if (or(s)) {
|
|
2582
2753
|
i = !0, r.push(s);
|
|
2583
2754
|
continue;
|
|
2584
2755
|
}
|
|
@@ -2605,33 +2776,36 @@ function tr(e) {
|
|
|
2605
2776
|
footnoteIds: n
|
|
2606
2777
|
};
|
|
2607
2778
|
}
|
|
2608
|
-
function
|
|
2779
|
+
function gr(e) {
|
|
2609
2780
|
let t = "";
|
|
2610
2781
|
for (let n = 0; n < e.length; n++) {
|
|
2611
2782
|
let r = n === e.length - 1, i = e[n].replace(/^[ \t]+/, "");
|
|
2612
2783
|
if (!r && /\\$/.test(i)) {
|
|
2613
|
-
t += i.replace(/\\$/, "") +
|
|
2784
|
+
t += i.replace(/\\$/, "") + lr;
|
|
2614
2785
|
continue;
|
|
2615
2786
|
}
|
|
2616
2787
|
if (!r && / {2,}$/.test(i)) {
|
|
2617
|
-
t += i.replace(/ {2,}$/, "") +
|
|
2788
|
+
t += i.replace(/ {2,}$/, "") + lr;
|
|
2618
2789
|
continue;
|
|
2619
2790
|
}
|
|
2620
2791
|
t += i + (r ? "" : " ");
|
|
2621
2792
|
}
|
|
2622
2793
|
return t;
|
|
2623
2794
|
}
|
|
2624
|
-
function
|
|
2625
|
-
return
|
|
2795
|
+
function _r(e) {
|
|
2796
|
+
return br(e).length;
|
|
2626
2797
|
}
|
|
2627
|
-
function
|
|
2798
|
+
function vr(e) {
|
|
2799
|
+
return e.includes("|") ? /^\s*\|/.test(e) || _r(e) > 1 : !1;
|
|
2800
|
+
}
|
|
2801
|
+
function yr(e, t) {
|
|
2628
2802
|
let n = e[t], r = e[t + 1];
|
|
2629
2803
|
if (r === void 0 || !n.includes("|")) return !1;
|
|
2630
2804
|
if (/^\|.+\|/.test(n)) return /^\|[\s|:-]+\|/.test(r);
|
|
2631
|
-
let i =
|
|
2632
|
-
return i.length < 2 || !i.every((e) => /^:?-+:?$/.test(e)) ? !1 :
|
|
2805
|
+
let i = br(r);
|
|
2806
|
+
return i.length < 2 || !i.every((e) => /^:?-+:?$/.test(e)) ? !1 : _r(n) === i.length;
|
|
2633
2807
|
}
|
|
2634
|
-
function
|
|
2808
|
+
function br(e) {
|
|
2635
2809
|
let t = e.replace(/^\|/, "").replace(/\|$/, ""), n = [], r = "";
|
|
2636
2810
|
for (let e = 0; e < t.length; e++) {
|
|
2637
2811
|
if (t[e] === "\\" && t[e + 1] === "|") {
|
|
@@ -2646,7 +2820,7 @@ function ar(e) {
|
|
|
2646
2820
|
}
|
|
2647
2821
|
return n.push(r), n.map((e) => e.trim());
|
|
2648
2822
|
}
|
|
2649
|
-
function
|
|
2823
|
+
function xr(e, t) {
|
|
2650
2824
|
let n = e[t].match(/^(\s*)/)[1].length, r = /^\s*\d+[.)] /.test(e[t]), i = [], a = null, o = !1, s = !1, c = t;
|
|
2651
2825
|
for (; c < e.length;) {
|
|
2652
2826
|
let t = e[c];
|
|
@@ -2674,15 +2848,15 @@ function or(e, t) {
|
|
|
2674
2848
|
c++;
|
|
2675
2849
|
continue;
|
|
2676
2850
|
}
|
|
2677
|
-
let n = (e) =>
|
|
2851
|
+
let n = (e) => sr(e, l), r = or(n(t));
|
|
2678
2852
|
if (r) {
|
|
2679
2853
|
let t = RegExp(`^ {0,3}\\${r.marker}{${r.length},}[ \t]*$`), a = [n(e[c])];
|
|
2680
2854
|
for (c++; c < e.length && !t.test(n(e[c]));) a.push(n(e[c])), c++;
|
|
2681
|
-
c < e.length && (a.push(n(e[c])), c++), i[i.length - 1].sub +=
|
|
2855
|
+
c < e.length && (a.push(n(e[c])), c++), i[i.length - 1].sub += dr(a), s = !1;
|
|
2682
2856
|
continue;
|
|
2683
2857
|
}
|
|
2684
2858
|
if (/^\s*(?:[-*+]|\d+[.)]) /.test(t)) {
|
|
2685
|
-
let t =
|
|
2859
|
+
let t = xr(e, c);
|
|
2686
2860
|
i[i.length - 1].sub += t.html, c = t.endIdx, s = !1;
|
|
2687
2861
|
} else if (s) i[i.length - 1].paras.push(t.trim()), s = !1, c++;
|
|
2688
2862
|
else {
|
|
@@ -2700,32 +2874,32 @@ function or(e, t) {
|
|
|
2700
2874
|
endIdx: c
|
|
2701
2875
|
};
|
|
2702
2876
|
}
|
|
2703
|
-
var
|
|
2704
|
-
function
|
|
2877
|
+
var Sr = /\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g, L = "\0", Cr = "", wr = /(`+)([^]*?)\1/g;
|
|
2878
|
+
function Tr(e) {
|
|
2705
2879
|
let t = [];
|
|
2706
2880
|
return {
|
|
2707
|
-
text: e.replace(
|
|
2881
|
+
text: e.replace(wr, (e, n, r) => r === "" ? e : (t.push(r), `${Cr}${t.length - 1}${Cr}`)),
|
|
2708
2882
|
codes: t
|
|
2709
2883
|
};
|
|
2710
2884
|
}
|
|
2711
|
-
function
|
|
2712
|
-
return e.replace(RegExp(`${
|
|
2885
|
+
function Er(e, t, n) {
|
|
2886
|
+
return e.replace(RegExp(`${Cr}(\\d+)${Cr}`, "g"), (e, r) => {
|
|
2713
2887
|
let i = t[Number(r)];
|
|
2714
|
-
return i = i.replace(RegExp(`${L}(\\d+)${L}`, "g"), (e, t) => `\\${n[Number(t)]}`), i.length > 2 && i.startsWith(" ") && i.endsWith(" ") && i.trim() !== "" && (i = i.slice(1, -1)), `<code>${
|
|
2888
|
+
return i = i.replace(RegExp(`${L}(\\d+)${L}`, "g"), (e, t) => `\\${n[Number(t)]}`), i.length > 2 && i.startsWith(" ") && i.endsWith(" ") && i.trim() !== "" && (i = i.slice(1, -1)), `<code>${Rr(i)}</code>`;
|
|
2715
2889
|
});
|
|
2716
2890
|
}
|
|
2717
|
-
function
|
|
2891
|
+
function Dr(e) {
|
|
2718
2892
|
let t = [];
|
|
2719
2893
|
return {
|
|
2720
|
-
text: e.replace(
|
|
2894
|
+
text: e.replace(Sr, (e, n) => (t.push(n), `${L}${t.length - 1}${L}`)),
|
|
2721
2895
|
literals: t
|
|
2722
2896
|
};
|
|
2723
2897
|
}
|
|
2724
|
-
function
|
|
2725
|
-
return e.replace(RegExp(`${L}(\\d+)${L}`, "g"), (e, n) =>
|
|
2898
|
+
function Or(e, t) {
|
|
2899
|
+
return e.replace(RegExp(`${L}(\\d+)${L}`, "g"), (e, n) => Lr(t[Number(n)]));
|
|
2726
2900
|
}
|
|
2727
|
-
var
|
|
2728
|
-
function
|
|
2901
|
+
var kr = String.raw`(<.*?>(?:\s+(?:"[^"]*"|'[^']*'))?|[^)]*)`, Ar = new RegExp(String.raw`!\[([^\]]*)\]\(${kr}\)`, "g"), jr = new RegExp(String.raw`\[([^\]]+)\]\(${kr}\)`, "g");
|
|
2902
|
+
function Mr(e) {
|
|
2729
2903
|
let t = e.trim(), n = /^<([\s\S]*?)>(?:[ \t]*(?:"([^"]*)"|'([^']*)'))?[ \t]*$/.exec(t);
|
|
2730
2904
|
if (n) return {
|
|
2731
2905
|
href: n[1],
|
|
@@ -2740,26 +2914,26 @@ function _r(e) {
|
|
|
2740
2914
|
title: ""
|
|
2741
2915
|
};
|
|
2742
2916
|
}
|
|
2743
|
-
function
|
|
2744
|
-
return e = e.replace(
|
|
2745
|
-
let { href: r, title: i } =
|
|
2917
|
+
function Nr(e) {
|
|
2918
|
+
return e = e.replace(Ar, (e, t, n) => {
|
|
2919
|
+
let { href: r, title: i } = Mr(n), a = i ? ` title="${B(i)}"` : "";
|
|
2746
2920
|
return `<img src="${B(r)}" alt="${B(t)}"${a} class="an-image">`;
|
|
2747
|
-
}), e = e.replace(
|
|
2748
|
-
let { href: r, title: i } =
|
|
2921
|
+
}), e = e.replace(jr, (e, t, n) => {
|
|
2922
|
+
let { href: r, title: i } = Mr(n), a = i ? ` title="${B(i)}"` : "";
|
|
2749
2923
|
return `<a href="${B(r)}"${a}>${t}</a>`;
|
|
2750
2924
|
}), e = e.replace(/\[([^\]]+)\]\[([^\]]*)\]/g, (e, t, n) => {
|
|
2751
|
-
let r =
|
|
2925
|
+
let r = fr.get(zr(n || t).trim().toLowerCase());
|
|
2752
2926
|
if (!r) return e;
|
|
2753
2927
|
let i = r.title ? ` title="${z(r.title)}"` : "";
|
|
2754
2928
|
return `<a href="${z(r.href)}"${i}>${t}</a>`;
|
|
2755
2929
|
}), e = e.replace(/\[([^\]]+)\]/g, (e, t) => {
|
|
2756
|
-
let n =
|
|
2930
|
+
let n = fr.get(zr(t).trim().toLowerCase());
|
|
2757
2931
|
if (!n) return e;
|
|
2758
2932
|
let r = n.title ? ` title="${z(n.title)}"` : "";
|
|
2759
2933
|
return `<a href="${z(n.href)}"${r}>${t}</a>`;
|
|
2760
|
-
}), e = e.replace(/\[\^([^\]]+)\]/g, (e, t) =>
|
|
2934
|
+
}), e = e.replace(/\[\^([^\]]+)\]/g, (e, t) => pr.has(zr(t)) ? `<sup>[${t}]</sup>` : e), e;
|
|
2761
2935
|
}
|
|
2762
|
-
function
|
|
2936
|
+
function Pr(e) {
|
|
2763
2937
|
return e = e.replace(/<(https?:\/\/[^\s&]+?)>/g, (e, t) => `<a href="${B(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:${B(t)}">${t}</a>`), e = e.replace(/(^|[\s(])(https?:\/\/[^\s()]+)/g, (e, t, n) => {
|
|
2764
2938
|
let r = /[.,;:!?)]+$/.exec(n), i = r ? n.slice(0, -r[0].length) : n;
|
|
2765
2939
|
if (!i) return e;
|
|
@@ -2767,18 +2941,18 @@ function yr(e) {
|
|
|
2767
2941
|
return `${t}<a href="${B(i)}">${i}</a>${a}`;
|
|
2768
2942
|
}), e;
|
|
2769
2943
|
}
|
|
2770
|
-
function
|
|
2944
|
+
function Fr(e) {
|
|
2771
2945
|
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;
|
|
2772
2946
|
}
|
|
2773
2947
|
function R(e) {
|
|
2774
|
-
let { text: t, literals: n } =
|
|
2775
|
-
return a =
|
|
2948
|
+
let { text: t, literals: n } = Dr(e), { text: r, codes: i } = Tr(t), a = Lr(r);
|
|
2949
|
+
return a = Nr(a), a = Pr(a), a = Fr(a), Er(Or(a, n), i, n);
|
|
2776
2950
|
}
|
|
2777
|
-
var
|
|
2778
|
-
function
|
|
2779
|
-
return String(e).replace(
|
|
2951
|
+
var Ir = /&(?!#\d+;|#[xX][0-9a-fA-F]+;|[a-zA-Z][a-zA-Z0-9]*;)/g;
|
|
2952
|
+
function Lr(e) {
|
|
2953
|
+
return String(e).replace(Ir, "&").replaceAll("<", "<").replaceAll(">", ">");
|
|
2780
2954
|
}
|
|
2781
|
-
function
|
|
2955
|
+
function Rr(e) {
|
|
2782
2956
|
return String(e).replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">");
|
|
2783
2957
|
}
|
|
2784
2958
|
function z(e) {
|
|
@@ -2787,16 +2961,16 @@ function z(e) {
|
|
|
2787
2961
|
function B(e) {
|
|
2788
2962
|
return String(e).replaceAll("\"", """).replaceAll("'", "'");
|
|
2789
2963
|
}
|
|
2790
|
-
function
|
|
2964
|
+
function zr(e) {
|
|
2791
2965
|
return String(e).replaceAll("<", "<").replaceAll(">", ">").replaceAll("&", "&");
|
|
2792
2966
|
}
|
|
2793
2967
|
//#endregion
|
|
2794
2968
|
//#region src/js/core/detectLang.js
|
|
2795
|
-
var
|
|
2969
|
+
var Br = 5, Vr = 2, Hr = [
|
|
2796
2970
|
["typescript", "javascript"],
|
|
2797
2971
|
["scss", "css"],
|
|
2798
2972
|
["cpp", "c"]
|
|
2799
|
-
],
|
|
2973
|
+
], Ur = [
|
|
2800
2974
|
"javascript",
|
|
2801
2975
|
"typescript",
|
|
2802
2976
|
"python",
|
|
@@ -2819,7 +2993,7 @@ var Tr = 5, Er = 2, Dr = [
|
|
|
2819
2993
|
"scss",
|
|
2820
2994
|
"css",
|
|
2821
2995
|
"bash"
|
|
2822
|
-
],
|
|
2996
|
+
], Wr = [
|
|
2823
2997
|
{
|
|
2824
2998
|
lang: "php",
|
|
2825
2999
|
w: 10,
|
|
@@ -3385,27 +3559,27 @@ var Tr = 5, Er = 2, Dr = [
|
|
|
3385
3559
|
w: 3,
|
|
3386
3560
|
re: /\s\|[ \t]*\w|\s&&\s|\s2>&1|\s-[\w-]+\s/
|
|
3387
3561
|
}
|
|
3388
|
-
],
|
|
3389
|
-
function
|
|
3390
|
-
if (e.length <=
|
|
3391
|
-
let t = e.slice(0,
|
|
3562
|
+
], Gr = 4e3;
|
|
3563
|
+
function Kr(e) {
|
|
3564
|
+
if (e.length <= Gr) return e;
|
|
3565
|
+
let t = e.slice(0, Gr), n = t.lastIndexOf("\n");
|
|
3392
3566
|
return n > 0 ? t.slice(0, n) : t;
|
|
3393
3567
|
}
|
|
3394
|
-
function
|
|
3568
|
+
function qr(e) {
|
|
3395
3569
|
if (!e?.trim()) return null;
|
|
3396
|
-
let t =
|
|
3397
|
-
for (let { lang: e, re: r, w: i } of
|
|
3570
|
+
let t = Kr(e.trim()), n = /* @__PURE__ */ new Map();
|
|
3571
|
+
for (let { lang: e, re: r, w: i } of Wr) r.test(t) && n.set(e, (n.get(e) || 0) + i);
|
|
3398
3572
|
if (n.size === 0) return null;
|
|
3399
|
-
for (let [e, t] of
|
|
3573
|
+
for (let [e, t] of Hr) {
|
|
3400
3574
|
let r = n.get(e);
|
|
3401
3575
|
r && n.set(e, r + (n.get(t) || 0));
|
|
3402
3576
|
}
|
|
3403
3577
|
let r = [...n.entries()].sort((e, t) => t[1] - e[1]), [i, a] = r[0], o = r[1]?.[1] ?? 0;
|
|
3404
|
-
return a <
|
|
3578
|
+
return a < Br || a - o < Vr ? null : i;
|
|
3405
3579
|
}
|
|
3406
3580
|
//#endregion
|
|
3407
3581
|
//#region src/js/module/Editor.js
|
|
3408
|
-
var
|
|
3582
|
+
var Jr = /* @__PURE__ */ new Set([
|
|
3409
3583
|
"PRE",
|
|
3410
3584
|
"BLOCKQUOTE",
|
|
3411
3585
|
"TABLE",
|
|
@@ -3413,13 +3587,13 @@ var Nr = /* @__PURE__ */ new Set([
|
|
|
3413
3587
|
"UL",
|
|
3414
3588
|
"OL",
|
|
3415
3589
|
"HR"
|
|
3416
|
-
]),
|
|
3590
|
+
]), Yr = class {
|
|
3417
3591
|
constructor(e) {
|
|
3418
|
-
this.context = e, this.options = e.options, this._history = null, this._disposers = [], this._snapshotTimer = null;
|
|
3592
|
+
this.context = e, this.options = e.options, this._history = null, this._disposers = [], this._snapshotTimer = null, this._limitCounter = null;
|
|
3419
3593
|
}
|
|
3420
3594
|
initialize() {
|
|
3421
3595
|
let e = this.context.layoutInfo.editable;
|
|
3422
|
-
return this._history = new
|
|
3596
|
+
return this._history = new An(e, this.options.historyLimit || 100, this.options.historyMaxBytes || 10 * 1024 * 1024), this._bindEvents(e), this;
|
|
3423
3597
|
}
|
|
3424
3598
|
destroy() {
|
|
3425
3599
|
this._disposers.forEach((e) => e()), this._disposers = [], this._history = null, clearTimeout(this._snapshotTimer), this._snapshotTimer = null;
|
|
@@ -3496,7 +3670,7 @@ var Nr = /* @__PURE__ */ new Set([
|
|
|
3496
3670
|
}
|
|
3497
3671
|
_onKeydown(e) {
|
|
3498
3672
|
let t = this.context.layoutInfo.editable;
|
|
3499
|
-
if (!
|
|
3673
|
+
if (!Rn(e, t, this.options)) {
|
|
3500
3674
|
if (F(e, "z") && !e.shiftKey) {
|
|
3501
3675
|
e.preventDefault(), this.undo();
|
|
3502
3676
|
return;
|
|
@@ -3539,14 +3713,15 @@ var Nr = /* @__PURE__ */ new Set([
|
|
|
3539
3713
|
_enforceLimit(e) {
|
|
3540
3714
|
let t = this.options.maxChars || 0, n = this.options.maxWords || 0;
|
|
3541
3715
|
if (!t && !n) return;
|
|
3716
|
+
this._limitCounter ??= new Wn();
|
|
3542
3717
|
let r = e.inputType || "";
|
|
3543
3718
|
if (r.startsWith("delete") || r === "historyUndo" || r === "historyRedo" || r === "insertFromPaste" || r === "insertFromDrop" || !r.startsWith("insert")) return;
|
|
3544
|
-
let i = this.context.layoutInfo.editable
|
|
3719
|
+
let { words: i, chars: a } = this._limitCounter.counts(this.context.layoutInfo.editable);
|
|
3545
3720
|
if (t && a >= t) {
|
|
3546
3721
|
e.preventDefault(), typeof this.options.onCharLimitReached == "function" && this.options.onCharLimitReached(this.context);
|
|
3547
3722
|
return;
|
|
3548
3723
|
}
|
|
3549
|
-
n && (e.data === " " || r === "insertParagraph" || r === "insertLineBreak") &&
|
|
3724
|
+
n && (e.data === " " || r === "insertParagraph" || r === "insertLineBreak") && i >= n && (e.preventDefault(), typeof this.options.onWordLimitReached == "function" && this.options.onWordLimitReached(this.context));
|
|
3550
3725
|
}
|
|
3551
3726
|
afterCommand() {
|
|
3552
3727
|
this._cleanOrphanedFigures(), this._ensureTrailingParagraph(), this.context.invoke("toolbar.refresh"), this.context.invoke("statusbar.update"), this._scheduleSnapshot();
|
|
@@ -3565,7 +3740,7 @@ var Nr = /* @__PURE__ */ new Set([
|
|
|
3565
3740
|
let e = this.context.layoutInfo.editable;
|
|
3566
3741
|
if (!e) return;
|
|
3567
3742
|
let t = e.lastElementChild;
|
|
3568
|
-
if (t &&
|
|
3743
|
+
if (t && Jr.has(t.nodeName)) {
|
|
3569
3744
|
let t = document.createElement("p");
|
|
3570
3745
|
t.innerHTML = "<br>", e.appendChild(t);
|
|
3571
3746
|
}
|
|
@@ -3578,7 +3753,7 @@ var Nr = /* @__PURE__ */ new Set([
|
|
|
3578
3753
|
return this.context.invoke("clipboard.resolveImages", e) ?? e;
|
|
3579
3754
|
}
|
|
3580
3755
|
setHTML(e) {
|
|
3581
|
-
let t =
|
|
3756
|
+
let t = vn(e, { allowIframes: !0 });
|
|
3582
3757
|
this.context.layoutInfo.editable.replaceChildren(...t.childNodes), this._history && this._history.reset(), this.afterCommand();
|
|
3583
3758
|
}
|
|
3584
3759
|
getText() {
|
|
@@ -3604,10 +3779,10 @@ var Nr = /* @__PURE__ */ new Set([
|
|
|
3604
3779
|
e && (D("insertText", e), this.afterCommand());
|
|
3605
3780
|
}
|
|
3606
3781
|
setMarkdown(e) {
|
|
3607
|
-
this.setHTML(
|
|
3782
|
+
this.setHTML(ur(e || ""));
|
|
3608
3783
|
}
|
|
3609
3784
|
getMarkdown() {
|
|
3610
|
-
return
|
|
3785
|
+
return Kn(this.getHTML());
|
|
3611
3786
|
}
|
|
3612
3787
|
undo() {
|
|
3613
3788
|
this._history && (this._flushPendingSnapshot(), this._history.undo(), this.context.invoke("toolbar.refresh"), this.context.invoke("statusbar.update"), this.context.triggerEvent("change", this.getHTML()));
|
|
@@ -3637,63 +3812,63 @@ var Nr = /* @__PURE__ */ new Set([
|
|
|
3637
3812
|
return !e || !this._history ? !1 : (this._history._restoreSelection(e), !0);
|
|
3638
3813
|
}
|
|
3639
3814
|
bold() {
|
|
3640
|
-
|
|
3815
|
+
Fe(), this.afterCommand();
|
|
3641
3816
|
}
|
|
3642
3817
|
italic() {
|
|
3643
|
-
|
|
3818
|
+
Ie(), this.afterCommand();
|
|
3644
3819
|
}
|
|
3645
3820
|
underline() {
|
|
3646
|
-
|
|
3821
|
+
Le(), this.afterCommand();
|
|
3647
3822
|
}
|
|
3648
3823
|
strikethrough() {
|
|
3649
|
-
|
|
3824
|
+
Re(), this.afterCommand();
|
|
3650
3825
|
}
|
|
3651
3826
|
superscript() {
|
|
3652
|
-
|
|
3827
|
+
ze(), this.afterCommand();
|
|
3653
3828
|
}
|
|
3654
3829
|
subscript() {
|
|
3655
|
-
|
|
3830
|
+
Be(), this.afterCommand();
|
|
3656
3831
|
}
|
|
3657
3832
|
justifyLeft() {
|
|
3658
|
-
|
|
3833
|
+
Ke(), this.afterCommand();
|
|
3659
3834
|
}
|
|
3660
3835
|
justifyCenter() {
|
|
3661
|
-
|
|
3836
|
+
qe(), this.afterCommand();
|
|
3662
3837
|
}
|
|
3663
3838
|
justifyRight() {
|
|
3664
|
-
|
|
3839
|
+
Je(), this.afterCommand();
|
|
3665
3840
|
}
|
|
3666
3841
|
justifyFull() {
|
|
3667
|
-
|
|
3842
|
+
Ye(), this.afterCommand();
|
|
3668
3843
|
}
|
|
3669
3844
|
indent() {
|
|
3670
|
-
|
|
3845
|
+
Xe(), this.afterCommand();
|
|
3671
3846
|
}
|
|
3672
3847
|
outdent() {
|
|
3673
|
-
|
|
3848
|
+
Qe(), this.afterCommand();
|
|
3674
3849
|
}
|
|
3675
3850
|
insertUL() {
|
|
3676
|
-
|
|
3851
|
+
rt(), this.afterCommand();
|
|
3677
3852
|
}
|
|
3678
3853
|
insertOL() {
|
|
3679
|
-
|
|
3854
|
+
it(), this.afterCommand();
|
|
3680
3855
|
}
|
|
3681
3856
|
inlineCode() {
|
|
3682
|
-
|
|
3857
|
+
ot(this.context.layoutInfo.editable), this.afterCommand();
|
|
3683
3858
|
}
|
|
3684
3859
|
toggleChecklist() {
|
|
3685
|
-
|
|
3860
|
+
ut(), this.afterCommand();
|
|
3686
3861
|
}
|
|
3687
3862
|
print() {
|
|
3688
3863
|
this.context.print();
|
|
3689
3864
|
}
|
|
3690
3865
|
formatBlock(e) {
|
|
3691
|
-
if (
|
|
3866
|
+
if (Ge(e), e === "pre") {
|
|
3692
3867
|
let e = globalThis.getSelection();
|
|
3693
3868
|
if (e?.rangeCount > 0) {
|
|
3694
3869
|
let t = e.getRangeAt(0).commonAncestorContainer, n = t.nodeType === 1 ? t.closest("pre") : t.parentElement?.closest("pre");
|
|
3695
3870
|
if (n && !n.dataset.language) {
|
|
3696
|
-
let e =
|
|
3871
|
+
let e = qr(n.textContent || "");
|
|
3697
3872
|
if (e) {
|
|
3698
3873
|
this.context.invoke("codeTooltip.applyLanguage", n, e);
|
|
3699
3874
|
return;
|
|
@@ -3704,16 +3879,16 @@ var Nr = /* @__PURE__ */ new Set([
|
|
|
3704
3879
|
this.afterCommand();
|
|
3705
3880
|
}
|
|
3706
3881
|
foreColor(e) {
|
|
3707
|
-
|
|
3882
|
+
Ve(e), this.afterCommand();
|
|
3708
3883
|
}
|
|
3709
3884
|
backColor(e) {
|
|
3710
|
-
|
|
3885
|
+
He(e), this.afterCommand();
|
|
3711
3886
|
}
|
|
3712
3887
|
fontName(e) {
|
|
3713
|
-
|
|
3888
|
+
Ue(e), this.afterCommand();
|
|
3714
3889
|
}
|
|
3715
3890
|
fontSize(e) {
|
|
3716
|
-
|
|
3891
|
+
We(e, this.context.layoutInfo.editable), this.afterCommand();
|
|
3717
3892
|
}
|
|
3718
3893
|
insertHr() {
|
|
3719
3894
|
D("insertHorizontalRule"), this.afterCommand();
|
|
@@ -3752,7 +3927,7 @@ var Nr = /* @__PURE__ */ new Set([
|
|
|
3752
3927
|
e && (D("insertHTML", e), this.afterCommand());
|
|
3753
3928
|
}
|
|
3754
3929
|
insertTable(e, t) {
|
|
3755
|
-
|
|
3930
|
+
Mn(e, t, { headerRow: this.context.options.tableHeaderRow }), this.afterCommand();
|
|
3756
3931
|
}
|
|
3757
3932
|
_getClosestAnchor() {
|
|
3758
3933
|
let e = globalThis.getSelection();
|
|
@@ -3767,7 +3942,7 @@ var Nr = /* @__PURE__ */ new Set([
|
|
|
3767
3942
|
_escapeAttr(e) {
|
|
3768
3943
|
return String(e ?? "").replaceAll("&", "&").replaceAll("\"", """).replaceAll("<", "<").replaceAll(">", ">");
|
|
3769
3944
|
}
|
|
3770
|
-
},
|
|
3945
|
+
}, Xr = (e) => typeof e == "string" ? mt(e) : e, Zr = null, Qr = "stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"", V = (e) => `<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24" fill="none" ${Qr} style="display:block">${e}</svg>`, H = /* @__PURE__ */ new Map([
|
|
3771
3946
|
["bold", V("<path d=\"M6 4h8a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z\"/><path d=\"M6 12h9a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z\"/>")],
|
|
3772
3947
|
["italic", V("<line x1=\"19\" y1=\"4\" x2=\"10\" y2=\"4\"/><line x1=\"14\" y1=\"20\" x2=\"5\" y2=\"20\"/><line x1=\"15\" y1=\"4\" x2=\"9\" y2=\"20\"/>")],
|
|
3773
3948
|
["underline", V("<path d=\"M6 3v7a6 6 0 0 0 6 6 6 6 0 0 0 6-6V3\"/><line x1=\"4\" y1=\"21\" x2=\"20\" y2=\"21\"/>")],
|
|
@@ -3804,7 +3979,7 @@ var Nr = /* @__PURE__ */ new Set([
|
|
|
3804
3979
|
["inline-code", V("<path d=\"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1\"/><path d=\"M16 3h1a2 2 0 0 1 2 2v5c0 1.1.9 2 2 2a2 2 0 0 1-2 2v5a2 2 0 0 1-2 2h-1\"/>")],
|
|
3805
3980
|
["checklist", V("<rect x=\"3\" y=\"4\" width=\"5\" height=\"5\" rx=\"1\"/><path d=\"m4 6.5 1 1 2-2\"/><rect x=\"3\" y=\"13\" width=\"5\" height=\"5\" rx=\"1\"/><line x1=\"10\" y1=\"6.5\" x2=\"21\" y2=\"6.5\"/><line x1=\"10\" y1=\"15.5\" x2=\"21\" y2=\"15.5\"/>")],
|
|
3806
3981
|
["print", V("<path d=\"M6 9V2h12v7\"/><path d=\"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2\"/><rect x=\"6\" y=\"14\" width=\"12\" height=\"8\"/>")]
|
|
3807
|
-
]),
|
|
3982
|
+
]), $r = /* @__PURE__ */ new Map([
|
|
3808
3983
|
["bold", "fa-bold"],
|
|
3809
3984
|
["italic", "fa-italic"],
|
|
3810
3985
|
["underline", "fa-underline"],
|
|
@@ -3838,7 +4013,7 @@ var Nr = /* @__PURE__ */ new Set([
|
|
|
3838
4013
|
["inline-code", "fa-code"],
|
|
3839
4014
|
["checklist", "fa-list-check"],
|
|
3840
4015
|
["print", "fa-print"]
|
|
3841
|
-
]),
|
|
4016
|
+
]), ei = class {
|
|
3842
4017
|
constructor(e) {
|
|
3843
4018
|
this.context = e, this.options = e.options, this.el = null, this._disposers = [], this._colorPickerClosers = [], this._refreshRaf = null;
|
|
3844
4019
|
}
|
|
@@ -3848,7 +4023,7 @@ var Nr = /* @__PURE__ */ new Set([
|
|
|
3848
4023
|
role: "toolbar",
|
|
3849
4024
|
"aria-orientation": "horizontal",
|
|
3850
4025
|
"aria-label": "Editor toolbar"
|
|
3851
|
-
}), this._faReady = this._detectFontAwesome(), this._buildButtons(), this._initRovingFocus(), this._btnMap = new Map((this.options.toolbar || []).flat().map(
|
|
4026
|
+
}), this._faReady = this._detectFontAwesome(), this._buildButtons(), this._initRovingFocus(), this._btnMap = new Map((this.options.toolbar || []).flat().map(Xr).filter(Boolean).map((e) => [e.name, e])), this;
|
|
3852
4027
|
}
|
|
3853
4028
|
destroy() {
|
|
3854
4029
|
this._refreshRaf && cancelAnimationFrame(this._refreshRaf), this._refreshRaf = null, this._disposers.forEach((e) => e()), this._disposers = [], this.el?.parentNode && this.el.remove(), this.el = null;
|
|
@@ -3858,7 +4033,7 @@ var Nr = /* @__PURE__ */ new Set([
|
|
|
3858
4033
|
e.forEach((e) => {
|
|
3859
4034
|
let n = w("div", { class: "an-btn-group" });
|
|
3860
4035
|
e.forEach((e) => {
|
|
3861
|
-
let t =
|
|
4036
|
+
let t = Xr(e);
|
|
3862
4037
|
if (!t) {
|
|
3863
4038
|
console.warn(`[AutumnNote] Toolbar: button "${e}" not found in registry. Skipped.`);
|
|
3864
4039
|
return;
|
|
@@ -4077,7 +4252,7 @@ var Nr = /* @__PURE__ */ new Set([
|
|
|
4077
4252
|
...typeof e.isActive == "function" ? { "aria-pressed": "false" } : {}
|
|
4078
4253
|
}), n = this.options.fontAwesomeClass || "fas";
|
|
4079
4254
|
if (this._faReady) {
|
|
4080
|
-
let r =
|
|
4255
|
+
let r = $r.get(e.icon) || $r.get(e.name) || null;
|
|
4081
4256
|
r ? t.innerHTML = `<i class="${n} ${r}" aria-hidden="true"></i>` : H.has(e.icon) ? t.innerHTML = H.get(e.icon) : t.textContent = e.icon || e.name;
|
|
4082
4257
|
} else H.has(e.icon) ? t.innerHTML = H.get(e.icon) : H.has(e.name) ? t.innerHTML = H.get(e.name) : t.textContent = e.icon || e.name;
|
|
4083
4258
|
let r = E(t, "click", (t) => {
|
|
@@ -4123,10 +4298,10 @@ var Nr = /* @__PURE__ */ new Set([
|
|
|
4123
4298
|
}
|
|
4124
4299
|
_detectFontAwesome() {
|
|
4125
4300
|
if (!this.options.useFontAwesome) return !1;
|
|
4126
|
-
if (
|
|
4127
|
-
if (document.querySelector(".fa, .fas, .far, .fal, .fab, .fa-solid")) return
|
|
4301
|
+
if (Zr !== null) return Zr;
|
|
4302
|
+
if (document.querySelector(".fa, .fas, .far, .fal, .fab, .fa-solid")) return Zr = !0, !0;
|
|
4128
4303
|
let e = Array.from(document.querySelectorAll("link[rel=\"stylesheet\"]")).filter((e) => e.id !== "an-fontawesome-css").map((e) => e.href || "").join(" ");
|
|
4129
|
-
return
|
|
4304
|
+
return Zr = /fontawesome|font-awesome|use\.fontawesome|all\.css/.test(e), Zr;
|
|
4130
4305
|
}
|
|
4131
4306
|
refresh() {
|
|
4132
4307
|
this._refreshRaf && cancelAnimationFrame(this._refreshRaf), this._refreshRaf = requestAnimationFrame(() => {
|
|
@@ -4159,53 +4334,21 @@ var Nr = /* @__PURE__ */ new Set([
|
|
|
4159
4334
|
this.el && (this.el.style.display = "none");
|
|
4160
4335
|
}
|
|
4161
4336
|
rebuild() {
|
|
4162
|
-
this._refreshRaf &&= (cancelAnimationFrame(this._refreshRaf), null), this._disposers.forEach((e) => e()), this._disposers = [], this.el && (this.el.innerHTML = ""), this._faReady = this._detectFontAwesome(), this._buildButtons(), this._initRovingFocus(), this._btnMap = new Map((this.options.toolbar || []).flat().map(
|
|
4337
|
+
this._refreshRaf &&= (cancelAnimationFrame(this._refreshRaf), null), this._disposers.forEach((e) => e()), this._disposers = [], this.el && (this.el.innerHTML = ""), this._faReady = this._detectFontAwesome(), this._buildButtons(), this._initRovingFocus(), this._btnMap = new Map((this.options.toolbar || []).flat().map(Xr).filter(Boolean).map((e) => [e.name, e])), this.refresh();
|
|
4163
4338
|
}
|
|
4164
|
-
}
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
if (Br) {
|
|
4169
|
-
let e = 0;
|
|
4170
|
-
for (let n of Br.segment(t)) n.isWordLike && e++;
|
|
4171
|
-
return e;
|
|
4172
|
-
}
|
|
4173
|
-
return t.split(/\s+/).length;
|
|
4174
|
-
}
|
|
4175
|
-
var Hr = /* @__PURE__ */ new Set(/* @__PURE__ */ "ADDRESS.ARTICLE.ASIDE.BLOCKQUOTE.BR.DD.DIV.DL.DT.FIELDSET.FIGCAPTION.FIGURE.FOOTER.FORM.H1.H2.H3.H4.H5.H6.HEADER.HR.LI.MAIN.NAV.OL.P.PRE.SECTION.TABLE.TBODY.TD.TFOOT.TH.THEAD.TR.UL".split("."));
|
|
4176
|
-
function Ur(e, t, n) {
|
|
4177
|
-
for (let r = e.firstChild; r; r = r.nextSibling) if (r.nodeType === 3) {
|
|
4178
|
-
let e = r.data;
|
|
4179
|
-
t.push(e), n.push(e);
|
|
4180
|
-
} else if (r.nodeType === 1) {
|
|
4181
|
-
let e = Hr.has(r.tagName);
|
|
4182
|
-
e && t.push("\n"), Ur(r, t, n), e && t.push("\n");
|
|
4183
|
-
}
|
|
4184
|
-
}
|
|
4185
|
-
function Wr(e) {
|
|
4186
|
-
if (e.nodeType === 3) {
|
|
4187
|
-
let t = e.data;
|
|
4188
|
-
return {
|
|
4189
|
-
lines: t,
|
|
4190
|
-
flat: t
|
|
4191
|
-
};
|
|
4192
|
-
}
|
|
4193
|
-
let t = [], n = [];
|
|
4194
|
-
return Ur(e, t, n), {
|
|
4195
|
-
lines: t.join(""),
|
|
4196
|
-
flat: n.join("")
|
|
4197
|
-
};
|
|
4198
|
-
}
|
|
4199
|
-
function Gr(e, t, n) {
|
|
4339
|
+
};
|
|
4340
|
+
//#endregion
|
|
4341
|
+
//#region src/js/module/Statusbar.js
|
|
4342
|
+
function ti(e, t, n) {
|
|
4200
4343
|
if (!n) {
|
|
4201
4344
|
e.classList.remove("an-count-warn", "an-count-exceeded");
|
|
4202
4345
|
return;
|
|
4203
4346
|
}
|
|
4204
4347
|
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");
|
|
4205
4348
|
}
|
|
4206
|
-
var
|
|
4349
|
+
var ni = class {
|
|
4207
4350
|
constructor(e) {
|
|
4208
|
-
this.context = e, this.options = e.options, this.el = null, this._disposers = [], this._wordCountEl = null, this._charCountEl = null, this.
|
|
4351
|
+
this.context = e, this.options = e.options, this.el = null, this._disposers = [], this._wordCountEl = null, this._charCountEl = null, this._counter = new Wn();
|
|
4209
4352
|
}
|
|
4210
4353
|
initialize() {
|
|
4211
4354
|
if (this.el = w("div", { class: "an-statusbar" }), this.options.resizable !== !1) {
|
|
@@ -4255,50 +4398,12 @@ var Kr = class {
|
|
|
4255
4398
|
this._disposers.push(d, f);
|
|
4256
4399
|
}
|
|
4257
4400
|
_counts() {
|
|
4258
|
-
|
|
4259
|
-
for (let o = e.firstChild; o; o = o.nextSibling) {
|
|
4260
|
-
let e = this._countCache.get(o);
|
|
4261
|
-
if (e && e.key === (o.textContent || "")) {
|
|
4262
|
-
t += e.words, n += e.chars;
|
|
4263
|
-
continue;
|
|
4264
|
-
}
|
|
4265
|
-
let { lines: s, flat: c } = Wr(o);
|
|
4266
|
-
r.push({
|
|
4267
|
-
node: o,
|
|
4268
|
-
key: c,
|
|
4269
|
-
text: s,
|
|
4270
|
-
start: a
|
|
4271
|
-
}), i.push(s), a += s.length + 1;
|
|
4272
|
-
}
|
|
4273
|
-
if (r.length) {
|
|
4274
|
-
let e = this._countBatch(r, i.join("\n"));
|
|
4275
|
-
r.forEach((r, i) => {
|
|
4276
|
-
let a = {
|
|
4277
|
-
key: r.key,
|
|
4278
|
-
words: e[i],
|
|
4279
|
-
chars: r.key.replaceAll("\n", "").length
|
|
4280
|
-
};
|
|
4281
|
-
this._countCache.set(r.node, a), t += a.words, n += a.chars;
|
|
4282
|
-
});
|
|
4283
|
-
}
|
|
4284
|
-
return {
|
|
4285
|
-
words: t,
|
|
4286
|
-
chars: n
|
|
4287
|
-
};
|
|
4288
|
-
}
|
|
4289
|
-
_countBatch(e, t) {
|
|
4290
|
-
if (!Br) return e.map((e) => Vr(e.text));
|
|
4291
|
-
let n = Array(e.length).fill(0), r = 0;
|
|
4292
|
-
for (let i of Br.segment(t)) if (i.isWordLike) {
|
|
4293
|
-
for (; r < e.length - 1 && i.index >= e[r + 1].start;) r++;
|
|
4294
|
-
n[r]++;
|
|
4295
|
-
}
|
|
4296
|
-
return n;
|
|
4401
|
+
return this._counter.counts(this.context.layoutInfo.editable);
|
|
4297
4402
|
}
|
|
4298
4403
|
update() {
|
|
4299
4404
|
if (!this._wordCountEl || !this._charCountEl) return;
|
|
4300
4405
|
let { words: e, chars: t } = this._counts(), n = this.options.maxWords || 0, r = this.options.maxChars || 0, i = this.context.locale.statusbar;
|
|
4301
|
-
this._wordCountEl.textContent = n ? i.wordsLimit(e, n) : i.words(e), this._charCountEl.textContent = r ? i.charsLimit(t, r) : i.chars(t),
|
|
4406
|
+
this._wordCountEl.textContent = n ? i.wordsLimit(e, n) : i.words(e), this._charCountEl.textContent = r ? i.charsLimit(t, r) : i.chars(t), ti(this._wordCountEl, e, n), ti(this._charCountEl, t, r);
|
|
4302
4407
|
}
|
|
4303
4408
|
getWordCount() {
|
|
4304
4409
|
return this._counts().words;
|
|
@@ -4306,7 +4411,7 @@ var Kr = class {
|
|
|
4306
4411
|
getCharCount() {
|
|
4307
4412
|
return this._counts().chars;
|
|
4308
4413
|
}
|
|
4309
|
-
},
|
|
4414
|
+
}, ri = class {
|
|
4310
4415
|
constructor(e) {
|
|
4311
4416
|
this.context = e, this.options = e.options, this._disposers = [];
|
|
4312
4417
|
}
|
|
@@ -4423,8 +4528,8 @@ var Kr = class {
|
|
|
4423
4528
|
}
|
|
4424
4529
|
if (this.options.markdownPaste !== !1) {
|
|
4425
4530
|
let n = t.types.includes("text/html"), r = n ? t.getData("text/html") : "", i = !n || this._isTriviallyPlainHtml(r), a = t.getData("text/plain");
|
|
4426
|
-
if (a && i &&
|
|
4427
|
-
e.preventDefault(), D("insertHTML", j(
|
|
4531
|
+
if (a && i && nr(a)) {
|
|
4532
|
+
e.preventDefault(), D("insertHTML", j(ur(a))), this.context.invoke("editor.afterCommand");
|
|
4428
4533
|
return;
|
|
4429
4534
|
}
|
|
4430
4535
|
}
|
|
@@ -4463,7 +4568,7 @@ var Kr = class {
|
|
|
4463
4568
|
}
|
|
4464
4569
|
let n = new FileReader();
|
|
4465
4570
|
n.onload = (e) => {
|
|
4466
|
-
D("insertHTML", j(
|
|
4571
|
+
D("insertHTML", j(ur(e.target.result || ""))), this.context.invoke("editor.afterCommand");
|
|
4467
4572
|
}, n.onerror = () => {
|
|
4468
4573
|
let t = `Failed to read dropped markdown file "${e.name}".`;
|
|
4469
4574
|
console.warn(`[AutumnNote] ${t}`), this.context.triggerEvent("pasteError", { message: t });
|
|
@@ -4675,7 +4780,7 @@ var Kr = class {
|
|
|
4675
4780
|
highlightColor: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M3 21v-4l9-9 4 4-9 9z\"/><path d=\"M12 8l4 4\"/><line x1=\"3\" y1=\"21\" x2=\"21\" y2=\"21\"/></svg>",
|
|
4676
4781
|
noColor: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"11\" height=\"11\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\"><line x1=\"4\" y1=\"4\" x2=\"20\" y2=\"20\"/><line x1=\"20\" y1=\"4\" x2=\"4\" y2=\"20\"/></svg>",
|
|
4677
4782
|
back: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"15 18 9 12 15 6\"/></svg>"
|
|
4678
|
-
},
|
|
4783
|
+
}, ii = [
|
|
4679
4784
|
"#000000",
|
|
4680
4785
|
"#434343",
|
|
4681
4786
|
"#666666",
|
|
@@ -4701,19 +4806,19 @@ var Kr = class {
|
|
|
4701
4806
|
"#d9d2e9",
|
|
4702
4807
|
"#ead1dc"
|
|
4703
4808
|
];
|
|
4704
|
-
function
|
|
4809
|
+
function ai(e) {
|
|
4705
4810
|
let t = e === "foreColor" ? "Text Color" : "Highlight Color", n = e === "foreColor" ? "textColor" : "highlightColor";
|
|
4706
4811
|
return () => [{
|
|
4707
4812
|
back: !0,
|
|
4708
4813
|
label: t,
|
|
4709
4814
|
localeKey: n,
|
|
4710
|
-
navigate: () =>
|
|
4815
|
+
navigate: () => oi
|
|
4711
4816
|
}, {
|
|
4712
4817
|
colorPalette: !0,
|
|
4713
4818
|
colorType: e
|
|
4714
4819
|
}];
|
|
4715
4820
|
}
|
|
4716
|
-
var
|
|
4821
|
+
var oi = [
|
|
4717
4822
|
{
|
|
4718
4823
|
name: "cut",
|
|
4719
4824
|
label: "Cut",
|
|
@@ -4777,14 +4882,14 @@ var Xr = [
|
|
|
4777
4882
|
label: "Text Color",
|
|
4778
4883
|
icon: U.textColor,
|
|
4779
4884
|
colorStrip: "foreColor",
|
|
4780
|
-
navigate:
|
|
4885
|
+
navigate: ai("foreColor")
|
|
4781
4886
|
},
|
|
4782
4887
|
{
|
|
4783
4888
|
name: "highlightColor",
|
|
4784
4889
|
label: "Highlight Color",
|
|
4785
4890
|
icon: U.highlightColor,
|
|
4786
4891
|
colorStrip: "hiliteColor",
|
|
4787
|
-
navigate:
|
|
4892
|
+
navigate: ai("hiliteColor")
|
|
4788
4893
|
},
|
|
4789
4894
|
{ separator: !0 },
|
|
4790
4895
|
{
|
|
@@ -4831,9 +4936,9 @@ var Xr = [
|
|
|
4831
4936
|
icon: U.table,
|
|
4832
4937
|
tableGrid: !0
|
|
4833
4938
|
}
|
|
4834
|
-
],
|
|
4939
|
+
], si = class {
|
|
4835
4940
|
constructor(e) {
|
|
4836
|
-
this.context = e, this.options = e.options || {}, this._items = this.options.contextMenu?.items ||
|
|
4941
|
+
this.context = e, this.options = e.options || {}, this._items = this.options.contextMenu?.items || oi, this.el = null, this._disposers = [], this._menuDisposers = [], this._lastX = 0, this._lastY = 0, this._copiedFormat = null, this._savedRange = null;
|
|
4837
4942
|
}
|
|
4838
4943
|
initialize() {
|
|
4839
4944
|
this.el = w("div", {
|
|
@@ -4919,7 +5024,7 @@ var Xr = [
|
|
|
4919
5024
|
}
|
|
4920
5025
|
if (e.colorPalette) {
|
|
4921
5026
|
let t = w("div", { class: "an-context-color-palette" });
|
|
4922
|
-
if (
|
|
5027
|
+
if (ii.forEach((n) => {
|
|
4923
5028
|
let r = w("div", {
|
|
4924
5029
|
class: "an-context-color-swatch",
|
|
4925
5030
|
title: n,
|
|
@@ -5149,13 +5254,13 @@ var Xr = [
|
|
|
5149
5254
|
} catch {}
|
|
5150
5255
|
this.context.invoke("editor.afterCommand");
|
|
5151
5256
|
}
|
|
5152
|
-
},
|
|
5153
|
-
function
|
|
5257
|
+
}, ci = /[^\s\u200B]/;
|
|
5258
|
+
function li(e) {
|
|
5154
5259
|
let t = document.createTreeWalker(e, NodeFilter.SHOW_TEXT);
|
|
5155
|
-
for (let e = t.nextNode(); e; e = t.nextNode()) if (
|
|
5260
|
+
for (let e = t.nextNode(); e; e = t.nextNode()) if (ci.test(e.data)) return !0;
|
|
5156
5261
|
return !1;
|
|
5157
5262
|
}
|
|
5158
|
-
var
|
|
5263
|
+
var ui = class {
|
|
5159
5264
|
constructor(e) {
|
|
5160
5265
|
this.context = e, this.options = e.options, this._disposers = [];
|
|
5161
5266
|
}
|
|
@@ -5169,10 +5274,10 @@ var ei = class {
|
|
|
5169
5274
|
this._disposers.forEach((e) => e()), this._disposers = [];
|
|
5170
5275
|
}
|
|
5171
5276
|
_update() {
|
|
5172
|
-
let e = this.context.layoutInfo.editable, t = document.activeElement === e, n =
|
|
5277
|
+
let e = this.context.layoutInfo.editable, t = document.activeElement === e, n = !li(e) && !e.querySelector("img, table, hr, .an-video-wrapper");
|
|
5173
5278
|
e.classList.toggle("an-placeholder", n && !t);
|
|
5174
5279
|
}
|
|
5175
|
-
},
|
|
5280
|
+
}, di = class {
|
|
5176
5281
|
constructor(e) {
|
|
5177
5282
|
this.context = e, this.options = e.options, this._active = !1, this._textarea = null, this._disposers = [];
|
|
5178
5283
|
}
|
|
@@ -5217,7 +5322,7 @@ var ei = class {
|
|
|
5217
5322
|
return /^<[^/!][^>]*[^/]>/.test(r) && !t.test(r) && !/^<(br|hr|img|input|link|meta)/.test(r) && n++, i;
|
|
5218
5323
|
}).filter(Boolean).join("\n");
|
|
5219
5324
|
}
|
|
5220
|
-
},
|
|
5325
|
+
}, fi = class {
|
|
5221
5326
|
constructor(e) {
|
|
5222
5327
|
this.context = e, this._active = !1, this._disposers = [], this._prevHeight = "";
|
|
5223
5328
|
}
|
|
@@ -5260,12 +5365,12 @@ var ei = class {
|
|
|
5260
5365
|
this._disposers.forEach((e) => e()), this._disposers = [], this._dialog?.parentNode && this._dialog.remove(), this._dialog = null;
|
|
5261
5366
|
}
|
|
5262
5367
|
_saveRange() {
|
|
5263
|
-
|
|
5368
|
+
Ce((e) => {
|
|
5264
5369
|
this._savedRange = e;
|
|
5265
5370
|
});
|
|
5266
5371
|
}
|
|
5267
5372
|
_open() {
|
|
5268
|
-
this._dialog && (this._dialog.style.display = "flex", this._removeTrap =
|
|
5373
|
+
this._dialog && (this._dialog.style.display = "flex", this._removeTrap = he(this._dialog, () => this._close()), setTimeout(() => this._firstInput?.focus(), 50));
|
|
5269
5374
|
}
|
|
5270
5375
|
_close() {
|
|
5271
5376
|
this._dialog && (this._dialog.style.display = "none"), this._removeTrap &&= (this._removeTrap(), null), this._savedRange = null;
|
|
@@ -5279,7 +5384,7 @@ var ei = class {
|
|
|
5279
5384
|
}), i = w("div", { class: "an-dialog-box" }), a = w("div", { class: "an-dialog-header" }), o = w("span", { class: "an-dialog-icon" });
|
|
5280
5385
|
o.innerHTML = t;
|
|
5281
5386
|
let s = w("h3", { class: "an-dialog-title" });
|
|
5282
|
-
s.textContent = n, a.appendChild(o), a.appendChild(s), i.appendChild(a), r.appendChild(i),
|
|
5387
|
+
s.textContent = n, a.appendChild(o), a.appendChild(s), i.appendChild(a), r.appendChild(i), ge(a, i);
|
|
5283
5388
|
let c = E(r, "click", (e) => {
|
|
5284
5389
|
e.target === r && this._close();
|
|
5285
5390
|
});
|
|
@@ -5302,12 +5407,12 @@ var ei = class {
|
|
|
5302
5407
|
let o = E(i, "click", n), s = E(a, "click", () => this._close());
|
|
5303
5408
|
return this._disposers.push(o, s), r;
|
|
5304
5409
|
}
|
|
5305
|
-
},
|
|
5410
|
+
}, pi = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71\"/><path d=\"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71\"/></svg>", mi = class extends W {
|
|
5306
5411
|
show() {
|
|
5307
5412
|
this._saveRange(), this._prefill(), this._open();
|
|
5308
5413
|
}
|
|
5309
5414
|
_buildDialog() {
|
|
5310
|
-
let e = this.context.locale.linkDialog, { overlay: t, box: n } = this._buildDialogShell(e.ariaLabel,
|
|
5415
|
+
let e = this.context.locale.linkDialog, { overlay: t, box: n } = this._buildDialogShell(e.ariaLabel, pi, e.title), r = w("label", { class: "an-label" });
|
|
5311
5416
|
r.textContent = e.url;
|
|
5312
5417
|
let i = w("input", {
|
|
5313
5418
|
type: "url",
|
|
@@ -5377,12 +5482,12 @@ var ei = class {
|
|
|
5377
5482
|
}
|
|
5378
5483
|
this._savedRange && this._savedRange.select(), this.context.invoke("editor.insertLink", e, t, n), this._close();
|
|
5379
5484
|
}
|
|
5380
|
-
},
|
|
5485
|
+
}, hi = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect x=\"3\" y=\"3\" width=\"18\" height=\"18\" rx=\"2\"/><circle cx=\"8.5\" cy=\"8.5\" r=\"1.5\"/><polyline points=\"21 15 16 10 5 21\"/></svg>", gi = class extends W {
|
|
5381
5486
|
show({ beforeInsert: e } = {}) {
|
|
5382
5487
|
this._beforeInsert = typeof e == "function" ? e : null, this._saveRange(), this._urlInput.value = "", this._altInput.value = "", this._fileInput && (this._fileInput.value = ""), this._open();
|
|
5383
5488
|
}
|
|
5384
5489
|
_buildDialog() {
|
|
5385
|
-
let e = this.context.locale.imageDialog, { overlay: t, box: n } = this._buildDialogShell(e.ariaLabel,
|
|
5490
|
+
let e = this.context.locale.imageDialog, { overlay: t, box: n } = this._buildDialogShell(e.ariaLabel, hi, e.title), r = w("label", { class: "an-label" });
|
|
5386
5491
|
r.textContent = e.imageUrl;
|
|
5387
5492
|
let i = w("input", {
|
|
5388
5493
|
type: "url",
|
|
@@ -5509,12 +5614,12 @@ var ei = class {
|
|
|
5509
5614
|
_close() {
|
|
5510
5615
|
this._beforeInsert = null, super._close();
|
|
5511
5616
|
}
|
|
5512
|
-
},
|
|
5617
|
+
}, _i = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polygon points=\"23 7 16 12 23 17 23 7\"/><rect x=\"1\" y=\"5\" width=\"15\" height=\"14\" rx=\"2\"/></svg>", vi = class extends W {
|
|
5513
5618
|
show() {
|
|
5514
5619
|
this._saveRange(), this._urlInput.value = "", this._widthInput.value = "560", this._hintEl.textContent = "", this._open();
|
|
5515
5620
|
}
|
|
5516
5621
|
_buildDialog() {
|
|
5517
|
-
let e = this.context.locale.videoDialog, { overlay: t, box: n } = this._buildDialogShell(e.ariaLabel,
|
|
5622
|
+
let e = this.context.locale.videoDialog, { overlay: t, box: n } = this._buildDialogShell(e.ariaLabel, _i, e.title), r = w("label", { class: "an-label" });
|
|
5518
5623
|
r.textContent = e.videoUrl;
|
|
5519
5624
|
let i = w("input", {
|
|
5520
5625
|
type: "url",
|
|
@@ -5595,7 +5700,7 @@ var ei = class {
|
|
|
5595
5700
|
let i = M(e, { media: !0 });
|
|
5596
5701
|
return i ? `<div class="an-video-wrapper" style="position:relative;display:block;width:${t}px;max-width:100%"><video src="${i.replaceAll("\"", "%22")}" width="${t}" height="${r}" controls style="display:block;max-width:100%"></video><div class="an-video-shield"></div></div>` : null;
|
|
5597
5702
|
}
|
|
5598
|
-
},
|
|
5703
|
+
}, yi = [
|
|
5599
5704
|
{
|
|
5600
5705
|
pos: "nw",
|
|
5601
5706
|
cursor: "nw-resize"
|
|
@@ -5628,7 +5733,7 @@ var ei = class {
|
|
|
5628
5733
|
pos: "w",
|
|
5629
5734
|
cursor: "w-resize"
|
|
5630
5735
|
}
|
|
5631
|
-
],
|
|
5736
|
+
], bi = class {
|
|
5632
5737
|
constructor(e) {
|
|
5633
5738
|
this.context = e, this._active = null, this._overlay = null, this._disposers = [], this._positionRaf = null, this._lastOverlayPos = null;
|
|
5634
5739
|
}
|
|
@@ -5681,7 +5786,7 @@ var ei = class {
|
|
|
5681
5786
|
}
|
|
5682
5787
|
_buildOverlay() {
|
|
5683
5788
|
let e = document.createElement("div");
|
|
5684
|
-
return e.className = this._overlayClass, e.style.display = "none",
|
|
5789
|
+
return e.className = this._overlayClass, e.style.display = "none", yi.forEach(({ pos: t }) => {
|
|
5685
5790
|
let n = document.createElement("div");
|
|
5686
5791
|
n.className = `an-resize-handle an-resize-${t}`, n.dataset.handle = t, this._disposers.push(E(n, "pointerdown", (e) => {
|
|
5687
5792
|
e.preventDefault(), e.stopPropagation(), this._startResize(e, t);
|
|
@@ -5738,7 +5843,7 @@ var ei = class {
|
|
|
5738
5843
|
};
|
|
5739
5844
|
document.addEventListener("pointermove", p), document.addEventListener("pointerup", h), document.addEventListener("pointercancel", h), this._dragDisposers = [m];
|
|
5740
5845
|
}
|
|
5741
|
-
},
|
|
5846
|
+
}, xi = class extends bi {
|
|
5742
5847
|
get _overlayClass() {
|
|
5743
5848
|
return "an-image-resizer";
|
|
5744
5849
|
}
|
|
@@ -5767,7 +5872,7 @@ var ei = class {
|
|
|
5767
5872
|
getActiveImage() {
|
|
5768
5873
|
return this._active;
|
|
5769
5874
|
}
|
|
5770
|
-
},
|
|
5875
|
+
}, Si = class extends bi {
|
|
5771
5876
|
get _overlayClass() {
|
|
5772
5877
|
return "an-video-resizer";
|
|
5773
5878
|
}
|
|
@@ -5803,12 +5908,12 @@ var ei = class {
|
|
|
5803
5908
|
getActiveWrapper() {
|
|
5804
5909
|
return this._active;
|
|
5805
5910
|
}
|
|
5806
|
-
},
|
|
5911
|
+
}, Ci = {
|
|
5807
5912
|
open: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6\"/><polyline points=\"15 3 21 3 21 9\"/><line x1=\"10\" y1=\"14\" x2=\"21\" y2=\"3\"/></svg>",
|
|
5808
5913
|
edit: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7\"/><path d=\"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z\"/></svg>",
|
|
5809
5914
|
unlink: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M18.84 12.25l1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71\"/><path d=\"M5.17 11.75l-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71\"/><line x1=\"8\" y1=\"2\" x2=\"8\" y2=\"5\"/><line x1=\"2\" y1=\"8\" x2=\"5\" y2=\"8\"/><line x1=\"16\" y1=\"19\" x2=\"16\" y2=\"22\"/><line x1=\"19\" y1=\"16\" x2=\"22\" y2=\"16\"/></svg>",
|
|
5810
5915
|
copy: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect x=\"9\" y=\"9\" width=\"13\" height=\"13\" rx=\"2\"/><path d=\"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1\"/></svg>"
|
|
5811
|
-
},
|
|
5916
|
+
}, wi = 120, Ti = 200, Ei = class {
|
|
5812
5917
|
constructor(e) {
|
|
5813
5918
|
this.context = e, this._el = null, this._activeAnchor = null, this._showTimer = null, this._hideTimer = null, this._disposers = [];
|
|
5814
5919
|
}
|
|
@@ -5832,7 +5937,7 @@ var ei = class {
|
|
|
5832
5937
|
role: "toolbar",
|
|
5833
5938
|
"aria-label": e.ariaLabel
|
|
5834
5939
|
});
|
|
5835
|
-
return t.style.display = "none", this._urlLabel = w("span", { class: "an-link-tooltip-url" }), t.appendChild(this._urlLabel), t.appendChild(w("div", { class: "an-link-tooltip-sep" })), this._openBtn = this._makeBtn(
|
|
5940
|
+
return t.style.display = "none", this._urlLabel = w("span", { class: "an-link-tooltip-url" }), t.appendChild(this._urlLabel), t.appendChild(w("div", { class: "an-link-tooltip-sep" })), this._openBtn = this._makeBtn(Ci.open, e.openLink, () => this._openLink()), this._copyBtn = this._makeBtn(Ci.copy, e.copyUrl, () => this._copyLink()), this._editBtn = this._makeBtn(Ci.edit, e.editLink, () => this._editLink()), this._unlinkBtn = this._makeBtn(Ci.unlink, e.removeLink, () => this._unlink()), t.appendChild(this._openBtn), t.appendChild(this._copyBtn), t.appendChild(this._editBtn), t.appendChild(this._unlinkBtn), this._disposers.push(E(t, "mouseenter", () => this._clearTimers()), E(t, "mouseleave", () => this._scheduleHide())), t;
|
|
5836
5941
|
}
|
|
5837
5942
|
_makeBtn(e, t, n) {
|
|
5838
5943
|
let r = w("button", {
|
|
@@ -5847,12 +5952,12 @@ var ei = class {
|
|
|
5847
5952
|
_scheduleShow(e) {
|
|
5848
5953
|
this._activeAnchor === e && this._el.style.display !== "none" || (clearTimeout(this._hideTimer), this._hideTimer = null, clearTimeout(this._showTimer), this._showTimer = setTimeout(() => {
|
|
5849
5954
|
this._activeAnchor = e, this._show(e);
|
|
5850
|
-
},
|
|
5955
|
+
}, wi));
|
|
5851
5956
|
}
|
|
5852
5957
|
_scheduleHide() {
|
|
5853
5958
|
clearTimeout(this._showTimer), this._showTimer = null, !this._hideTimer && (this._hideTimer = setTimeout(() => {
|
|
5854
5959
|
this._hide();
|
|
5855
|
-
},
|
|
5960
|
+
}, Ti));
|
|
5856
5961
|
}
|
|
5857
5962
|
_show(e) {
|
|
5858
5963
|
let t = this.context.layoutInfo.container.classList.contains("an-disabled"), n = e.getAttribute("href") || "";
|
|
@@ -5901,7 +6006,7 @@ var ei = class {
|
|
|
5901
6006
|
let t = globalThis.getSelection(), n = document.createRange();
|
|
5902
6007
|
n.selectNode(e), t.removeAllRanges(), t.addRange(n), document.execCommand("unlink"), this.context.invoke("editor.afterCommand");
|
|
5903
6008
|
}
|
|
5904
|
-
},
|
|
6009
|
+
}, Di = class {
|
|
5905
6010
|
constructor(e) {
|
|
5906
6011
|
this.context = e, this.options = e.options, this._el = null, this._active = null, this._showTimer = null, this._hideTimer = null, this._disposers = [];
|
|
5907
6012
|
}
|
|
@@ -5953,7 +6058,7 @@ var ei = class {
|
|
|
5953
6058
|
rotateLeft: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8\"/><polyline points=\"3 3 3 8 8 8\"/></svg>",
|
|
5954
6059
|
rotateRight: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M21 12a9 9 0 1 1-9-9 9.75 9.75 0 0 1 6.74 2.74L21 8\"/><polyline points=\"21 3 21 8 16 8\"/></svg>",
|
|
5955
6060
|
crop: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"6 2 6 18 22 18\"/><polyline points=\"2 6 18 6 18 22\"/></svg>"
|
|
5956
|
-
},
|
|
6061
|
+
}, Oi = class extends Di {
|
|
5957
6062
|
initialize() {
|
|
5958
6063
|
this._el = this._buildTooltip(), document.body.appendChild(this._el);
|
|
5959
6064
|
let e = this.context.layoutInfo.editable;
|
|
@@ -6053,7 +6158,7 @@ var ei = class {
|
|
|
6053
6158
|
originalSize: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"15 3 21 3 21 9\"/><polyline points=\"9 21 3 21 3 15\"/><line x1=\"21\" y1=\"3\" x2=\"14\" y2=\"10\"/><line x1=\"3\" y1=\"21\" x2=\"10\" y2=\"14\"/></svg>",
|
|
6054
6159
|
deleteVideo: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"3 6 5 6 21 6\"/><path d=\"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2\"/></svg>",
|
|
6055
6160
|
preview: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polygon points=\"5 3 19 12 5 21 5 3\"/></svg>"
|
|
6056
|
-
},
|
|
6161
|
+
}, ki = class extends Di {
|
|
6057
6162
|
initialize() {
|
|
6058
6163
|
this._el = this._buildTooltip(), document.body.appendChild(this._el);
|
|
6059
6164
|
let e = this.context.layoutInfo.editable;
|
|
@@ -6159,7 +6264,7 @@ var ei = class {
|
|
|
6159
6264
|
};
|
|
6160
6265
|
//#endregion
|
|
6161
6266
|
//#region src/js/module/table-grid.js
|
|
6162
|
-
function
|
|
6267
|
+
function Ai(e) {
|
|
6163
6268
|
let t = e.closest("tr");
|
|
6164
6269
|
if (!t) return -1;
|
|
6165
6270
|
let n = 0;
|
|
@@ -6178,7 +6283,7 @@ function J(e, t) {
|
|
|
6178
6283
|
}
|
|
6179
6284
|
return null;
|
|
6180
6285
|
}
|
|
6181
|
-
function
|
|
6286
|
+
function ji(e, t) {
|
|
6182
6287
|
let n = 0;
|
|
6183
6288
|
for (let r of e.cells) if (n += r.colSpan || 1, n > t) {
|
|
6184
6289
|
let e = r.nextElementSibling;
|
|
@@ -6186,7 +6291,7 @@ function xi(e, t) {
|
|
|
6186
6291
|
}
|
|
6187
6292
|
return null;
|
|
6188
6293
|
}
|
|
6189
|
-
function
|
|
6294
|
+
function Mi(e) {
|
|
6190
6295
|
let t = Array.from(e.rows), n = {}, r = /* @__PURE__ */ new WeakMap();
|
|
6191
6296
|
return t.forEach((e, t) => {
|
|
6192
6297
|
n[t] || (n[t] = {});
|
|
@@ -6213,7 +6318,7 @@ function Si(e) {
|
|
|
6213
6318
|
}
|
|
6214
6319
|
//#endregion
|
|
6215
6320
|
//#region src/js/module/TableTooltip.js
|
|
6216
|
-
var
|
|
6321
|
+
var Ni = 120, Pi = 200, Fi = [
|
|
6217
6322
|
"#000000",
|
|
6218
6323
|
"#434343",
|
|
6219
6324
|
"#666666",
|
|
@@ -6238,7 +6343,7 @@ var Ci = 120, wi = 200, Ti = [
|
|
|
6238
6343
|
"#c9daf8",
|
|
6239
6344
|
"#d9d2e9",
|
|
6240
6345
|
"#ead1dc"
|
|
6241
|
-
],
|
|
6346
|
+
], Ii = class {
|
|
6242
6347
|
constructor(e) {
|
|
6243
6348
|
this.context = e, this._el = null, this._activeTable = null, this._activeCell = null, this._showTimer = null, this._hideTimer = null, this._disposers = [], this._sizePopover = null, this._sizeApply = null, this._sizeTitleEl = null, this._sizeInputEl = null, this._shadePopover = null, this._shadeTitleEl = null, this._shadeColorStrip = null, this._borderColorPopover = null, this._borderColorTitleEl = null, this._borderColorStrip = null, this._borderColorNoBtn = null, this._selectMode = !1, this._selectedCells = [], this._selectStart = null, this._selectDragging = !1, this._selectBtn = null, this._editable = null;
|
|
6244
6349
|
}
|
|
@@ -6296,7 +6401,7 @@ var Ci = 120, wi = 200, Ti = [
|
|
|
6296
6401
|
});
|
|
6297
6402
|
}), E(e, "mousedown", (e) => {
|
|
6298
6403
|
if (!this.context.layoutInfo.container.classList.contains("an-disabled") && !(!t || !n)) {
|
|
6299
|
-
if (r = !0, i = n, a = e.clientX, o = e.clientY, f = t.closest("table"), i === "col") l =
|
|
6404
|
+
if (r = !0, i = n, a = e.clientX, o = e.clientY, f = t.closest("table"), i === "col") l = Ai(t) + (t.colSpan || 1) - 1, u = l >= 0 ? Array.from(f.querySelectorAll("tr")).map((e) => J(e, l)).filter(Boolean).filter((e) => (e.colSpan || 1) === 1) : [], s = u.length > 0 ? u[0].offsetWidth : Math.max(30, Math.round(t.offsetWidth / (t.colSpan || 1))), document.body.style.cursor = "col-resize";
|
|
6300
6405
|
else {
|
|
6301
6406
|
let e = t.closest("tr"), n = (e ? Array.from(f.rows).indexOf(e) : 0) + (t.rowSpan || 1) - 1;
|
|
6302
6407
|
d = f.rows[n] || e, c = d ? d.offsetHeight : 40, document.body.style.cursor = "row-resize";
|
|
@@ -6368,10 +6473,10 @@ var Ci = 120, wi = 200, Ti = [
|
|
|
6368
6473
|
_scheduleShow(e) {
|
|
6369
6474
|
this._activeTable === e && this._el.style.display !== "none" || (clearTimeout(this._hideTimer), this._hideTimer = null, clearTimeout(this._showTimer), this._showTimer = setTimeout(() => {
|
|
6370
6475
|
this._activeTable = e, this._show();
|
|
6371
|
-
},
|
|
6476
|
+
}, Ni));
|
|
6372
6477
|
}
|
|
6373
6478
|
_scheduleHide() {
|
|
6374
|
-
clearTimeout(this._showTimer), this._showTimer = null, !this._hideTimer && (this._hideTimer = setTimeout(() => this._hide(),
|
|
6479
|
+
clearTimeout(this._showTimer), this._showTimer = null, !this._hideTimer && (this._hideTimer = setTimeout(() => this._hide(), Pi));
|
|
6375
6480
|
}
|
|
6376
6481
|
_show() {
|
|
6377
6482
|
this._activeTable && (this._el.style.display = "flex", this._syncShadeStrip(), this._syncBorderColorStrip(), requestAnimationFrame(() => {
|
|
@@ -6420,7 +6525,7 @@ var Ci = 120, wi = 200, Ti = [
|
|
|
6420
6525
|
if (!t || e === t) return [e];
|
|
6421
6526
|
let n = e.closest("table");
|
|
6422
6527
|
if (!n?.contains(t)) return [e];
|
|
6423
|
-
let { gridMap: r, cellPos: i } =
|
|
6528
|
+
let { gridMap: r, cellPos: i } = Mi(n), a = i.get(e), o = i.get(t);
|
|
6424
6529
|
if (!a || !o) return [e];
|
|
6425
6530
|
let s = Math.min(a.r, o.r), c = Math.max(a.r + a.rs - 1, o.r + o.rs - 1), l = Math.min(a.c, o.c), u = Math.max(a.c + a.cs - 1, o.c + o.cs - 1), d = !0;
|
|
6426
6531
|
for (; d;) {
|
|
@@ -6468,7 +6573,7 @@ var Ci = 120, wi = 200, Ti = [
|
|
|
6468
6573
|
if (!t.length) return;
|
|
6469
6574
|
let n = t[0].closest("table");
|
|
6470
6575
|
if (!n) return;
|
|
6471
|
-
let r = t.map((e) =>
|
|
6576
|
+
let r = t.map((e) => Ai(e)), i = e === "left" ? Math.min(...r) : Math.max(...r), a = Array.from(n.querySelectorAll("tr")), o = a.map((t) => e === "left" ? J(t, i) : ji(t, i)), s = a.map((e) => e.closest("thead") !== null);
|
|
6472
6577
|
a.forEach((e, t) => {
|
|
6473
6578
|
e.insertBefore(w(s[t] ? "th" : "td", {}, ["\xA0"]), o[t]);
|
|
6474
6579
|
}), requestAnimationFrame(() => this._positionNear(this._activeTable)), this.context.invoke("editor.afterCommand");
|
|
@@ -6488,7 +6593,7 @@ var Ci = 120, wi = 200, Ti = [
|
|
|
6488
6593
|
if (!t) return;
|
|
6489
6594
|
let n = Array.from(t.querySelectorAll("tr"));
|
|
6490
6595
|
if (n[0] && n[0].cells.length <= 1) return;
|
|
6491
|
-
let r = [...new Set(e.map((e) =>
|
|
6596
|
+
let r = [...new Set(e.map((e) => Ai(e)))];
|
|
6492
6597
|
if (r.length >= (n[0]?.cells.length ?? 1)) return;
|
|
6493
6598
|
let i = [];
|
|
6494
6599
|
r.forEach((e) => {
|
|
@@ -6516,7 +6621,7 @@ var Ci = 120, wi = 200, Ti = [
|
|
|
6516
6621
|
}
|
|
6517
6622
|
}), n.length < 2) return;
|
|
6518
6623
|
}
|
|
6519
|
-
let { gridMap: r, cellPos: i } =
|
|
6624
|
+
let { gridMap: r, cellPos: i } = Mi(t), a = Infinity, o = -Infinity, s = Infinity, c = -Infinity;
|
|
6520
6625
|
if (n.forEach((e) => {
|
|
6521
6626
|
let t = i.get(e);
|
|
6522
6627
|
t && (t.r < a && (a = t.r), t.r + t.rs - 1 > o && (o = t.r + t.rs - 1), t.c < s && (s = t.c), t.c + t.cs - 1 > c && (c = t.c + t.cs - 1));
|
|
@@ -6555,7 +6660,7 @@ var Ci = 120, wi = 200, Ti = [
|
|
|
6555
6660
|
_unmergeOne(e, t) {
|
|
6556
6661
|
let n = e.colSpan || 1, r = e.rowSpan || 1;
|
|
6557
6662
|
if (n === 1 && r === 1) return;
|
|
6558
|
-
let { cellPos: i } =
|
|
6663
|
+
let { cellPos: i } = Mi(t), a = i.get(e);
|
|
6559
6664
|
if (!a) return;
|
|
6560
6665
|
let { r: o, c: s } = a, c = Array.from(t.rows), l = e.tagName.toLowerCase();
|
|
6561
6666
|
if (e.rowSpan = 1, e.colSpan = 1, e.style.verticalAlign = "", n > 1) {
|
|
@@ -6642,7 +6747,7 @@ var Ci = 120, wi = 200, Ti = [
|
|
|
6642
6747
|
let i = t.closest("table");
|
|
6643
6748
|
if (i) {
|
|
6644
6749
|
if (n) {
|
|
6645
|
-
let t = [...new Set(r.map((e) =>
|
|
6750
|
+
let t = [...new Set(r.map((e) => Ai(e)))], n = Array.from(i.querySelectorAll("tr"));
|
|
6646
6751
|
t.forEach((t) => {
|
|
6647
6752
|
n.forEach((n) => {
|
|
6648
6753
|
let r = J(n, t);
|
|
@@ -6672,7 +6777,7 @@ var Ci = 120, wi = 200, Ti = [
|
|
|
6672
6777
|
let a = w("div", { class: "an-size-popover-title" });
|
|
6673
6778
|
i.appendChild(a);
|
|
6674
6779
|
let o = w("div", { class: "an-context-color-palette" });
|
|
6675
|
-
|
|
6780
|
+
Fi.forEach((e) => {
|
|
6676
6781
|
let n = w("div", {
|
|
6677
6782
|
class: "an-context-color-swatch",
|
|
6678
6783
|
title: e
|
|
@@ -6792,7 +6897,7 @@ var Ci = 120, wi = 200, Ti = [
|
|
|
6792
6897
|
if (!t) return;
|
|
6793
6898
|
let n = this._getCell();
|
|
6794
6899
|
if (!n) return;
|
|
6795
|
-
let r =
|
|
6900
|
+
let r = Ai(n);
|
|
6796
6901
|
if (r === -1) return;
|
|
6797
6902
|
let i = t.querySelector("tbody") || t, a = Array.from(i.querySelectorAll(":scope > tr"));
|
|
6798
6903
|
a.length < 2 || (a.sort((t, n) => {
|
|
@@ -6817,13 +6922,23 @@ var Ci = 120, wi = 200, Ti = [
|
|
|
6817
6922
|
let t = Array.from(e.querySelectorAll("tr")).map((e) => Array.from(e.querySelectorAll("td, th")).map((e) => `"${(e.textContent || "").trim().replace(/"/g, "\"\"")}"`).join(",")).join("\n"), n = new Blob(["" + t], { type: "text/csv;charset=utf-8;" }), r = URL.createObjectURL(n), i = document.createElement("a");
|
|
6818
6923
|
i.href = r, i.download = "table.csv", i.style.display = "none", document.body.appendChild(i), i.click(), i.remove(), URL.revokeObjectURL(r);
|
|
6819
6924
|
}
|
|
6820
|
-
}
|
|
6925
|
+
};
|
|
6926
|
+
//#endregion
|
|
6927
|
+
//#region src/js/core/externalAsset.js
|
|
6928
|
+
function Li(e, t = {}) {
|
|
6929
|
+
t.cspNonce && (e.nonce = t.cspNonce);
|
|
6930
|
+
let n = t.externalAssetCrossOrigin ?? "anonymous", r = t.externalAssetReferrerPolicy ?? "no-referrer";
|
|
6931
|
+
return n && (e.crossOrigin = n), r && (e.referrerPolicy = r), e;
|
|
6932
|
+
}
|
|
6933
|
+
//#endregion
|
|
6934
|
+
//#region src/js/module/CodeTooltip.js
|
|
6935
|
+
var Ri = 100, zi = 180, Bi = /language-(\S+)/, Vi = {
|
|
6821
6936
|
copy: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect x=\"9\" y=\"9\" width=\"13\" height=\"13\" rx=\"2\"/><path d=\"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1\"/></svg>",
|
|
6822
6937
|
wrapOn: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><line x1=\"3\" y1=\"6\" x2=\"21\" y2=\"6\"/><path d=\"M3 12h15a3 3 0 0 1 0 6H3\"/><polyline points=\"6 15 3 18 6 21\"/></svg>",
|
|
6823
6938
|
toParagraph: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M13 4v16\"/><path d=\"M17 4v16\"/><path d=\"M9 4h8a4 4 0 0 1 0 8H9V4z\"/></svg>",
|
|
6824
6939
|
deleteCode: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"3 6 5 6 21 6\"/><path d=\"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2\"/></svg>",
|
|
6825
6940
|
lineNumbers: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><line x1=\"10\" y1=\"6\" x2=\"21\" y2=\"6\"/><line x1=\"10\" y1=\"12\" x2=\"21\" y2=\"12\"/><line x1=\"10\" y1=\"18\" x2=\"21\" y2=\"18\"/><path d=\"M4 6h1v4\"/><path d=\"M4 10h2\"/><path d=\"M6 18H4c0-1 2-2 2-3s-1-2-2-2\"/></svg>"
|
|
6826
|
-
},
|
|
6941
|
+
}, Hi = [
|
|
6827
6942
|
["", "Plain text"],
|
|
6828
6943
|
["javascript", "JavaScript"],
|
|
6829
6944
|
["typescript", "TypeScript"],
|
|
@@ -6848,14 +6963,14 @@ var Ci = 120, wi = 200, Ti = [
|
|
|
6848
6963
|
["kotlin", "Kotlin"],
|
|
6849
6964
|
["swift", "Swift"]
|
|
6850
6965
|
];
|
|
6851
|
-
function
|
|
6966
|
+
function Ui(e, t) {
|
|
6852
6967
|
[...e.classList].forEach((t) => {
|
|
6853
6968
|
t.startsWith("language-") && e.classList.remove(t);
|
|
6854
6969
|
}), t && e.classList.add(`language-${t}`);
|
|
6855
6970
|
}
|
|
6856
|
-
var
|
|
6971
|
+
var Wi = class {
|
|
6857
6972
|
constructor(e) {
|
|
6858
|
-
this.context = e, this._el = null, this._activePre = null, this._showTimer = null, this._hideTimer = null, this._disposers = [], this._copyBtn = null, this._wrapBtn = null, this._lineNumbersBtn = null, this._langSelect = null, this._prismScript = null;
|
|
6973
|
+
this.context = e, this._el = null, this._activePre = null, this._showTimer = null, this._hideTimer = null, this._disposers = [], this._copyBtn = null, this._wrapBtn = null, this._lineNumbersBtn = null, this._langSelect = null, this._prismScript = null, this._asyncDisposers = [];
|
|
6859
6974
|
}
|
|
6860
6975
|
initialize() {
|
|
6861
6976
|
this._el = this._buildTooltip(), document.body.appendChild(this._el), this._ensurePrism();
|
|
@@ -6873,7 +6988,7 @@ var Ni = class {
|
|
|
6873
6988
|
})), this;
|
|
6874
6989
|
}
|
|
6875
6990
|
destroy() {
|
|
6876
|
-
this._clearTimers(), this._disposers.forEach((e) => e()), this._disposers = [], this._el?.remove(), this._el = null;
|
|
6991
|
+
this._clearTimers(), this._asyncDisposers.forEach((e) => e()), this._asyncDisposers = [], this._disposers.forEach((e) => e()), this._disposers = [], this._el?.remove(), this._el = null;
|
|
6877
6992
|
}
|
|
6878
6993
|
_buildTooltip() {
|
|
6879
6994
|
let e = this.context.locale.tooltips.code, t = w("div", {
|
|
@@ -6885,10 +7000,10 @@ var Ni = class {
|
|
|
6885
7000
|
class: "an-code-lang-select",
|
|
6886
7001
|
title: e.syntaxLanguage,
|
|
6887
7002
|
"aria-label": e.syntaxAriaLabel
|
|
6888
|
-
}),
|
|
7003
|
+
}), Hi.forEach(([e, t]) => {
|
|
6889
7004
|
let n = w("option", { value: e });
|
|
6890
7005
|
n.textContent = t, this._langSelect.appendChild(n);
|
|
6891
|
-
}), this._disposers.push(E(this._langSelect, "change", () => this._onLangChange())), t.appendChild(this._langSelect), t.appendChild(this._sep()), this._copyBtn = this._makeBtn(
|
|
7006
|
+
}), this._disposers.push(E(this._langSelect, "change", () => this._onLangChange())), t.appendChild(this._langSelect), t.appendChild(this._sep()), this._copyBtn = this._makeBtn(Vi.copy, e.copyCode, () => this._copyCode()), t.appendChild(this._copyBtn), t.appendChild(this._sep()), this._wrapBtn = this._makeBtn(Vi.wrapOn, e.toggleWordWrap, () => this._toggleWrap()), t.appendChild(this._wrapBtn), this._lineNumbersBtn = this._makeBtn(Vi.lineNumbers, e.lineNumbers, () => this._toggleLineNumbers()), t.appendChild(this._lineNumbersBtn), t.appendChild(this._sep()), t.appendChild(this._makeBtn(Vi.toParagraph, e.convertToParagraph, () => this._toParagraph())), t.appendChild(this._sep()), t.appendChild(this._makeBtn(Vi.deleteCode, e.deleteCodeBlock, () => this._delete(), !0)), this._disposers.push(E(t, "mouseenter", () => this._clearTimers()), E(t, "mouseleave", () => this._scheduleHide())), t;
|
|
6892
7007
|
}
|
|
6893
7008
|
_sep() {
|
|
6894
7009
|
return w("div", { class: "an-link-tooltip-sep" });
|
|
@@ -6906,10 +7021,10 @@ var Ni = class {
|
|
|
6906
7021
|
_scheduleShow(e) {
|
|
6907
7022
|
this._activePre === e && this._el.style.display !== "none" || (clearTimeout(this._hideTimer), this._hideTimer = null, clearTimeout(this._showTimer), this._showTimer = setTimeout(() => {
|
|
6908
7023
|
this._activePre = e, this._syncWrapBtn(), this._syncLineNumbersBtn(), this._syncLangSelect(), this._show(e);
|
|
6909
|
-
},
|
|
7024
|
+
}, Ri));
|
|
6910
7025
|
}
|
|
6911
7026
|
_scheduleHide() {
|
|
6912
|
-
clearTimeout(this._showTimer), this._showTimer = null, clearTimeout(this._hideTimer), this._hideTimer = setTimeout(() => this._hide(),
|
|
7027
|
+
clearTimeout(this._showTimer), this._showTimer = null, clearTimeout(this._hideTimer), this._hideTimer = setTimeout(() => this._hide(), zi);
|
|
6913
7028
|
}
|
|
6914
7029
|
_show(e) {
|
|
6915
7030
|
this._el.style.display = "flex", this._positionNear(e);
|
|
@@ -6936,7 +7051,7 @@ var Ni = class {
|
|
|
6936
7051
|
}
|
|
6937
7052
|
_syncLangSelect() {
|
|
6938
7053
|
if (!this._activePre || !this._langSelect) return;
|
|
6939
|
-
let e = this._activePre.querySelector("code"), t = this._activePre.dataset.language || "", n = e && (
|
|
7054
|
+
let e = this._activePre.querySelector("code"), t = this._activePre.dataset.language || "", n = e && (Bi.exec(e.className) || [])[1] || "";
|
|
6940
7055
|
this._langSelect.value = t || n || "";
|
|
6941
7056
|
}
|
|
6942
7057
|
_copyCode() {
|
|
@@ -6979,9 +7094,9 @@ var Ni = class {
|
|
|
6979
7094
|
let e = this._activePre;
|
|
6980
7095
|
if (!e) return;
|
|
6981
7096
|
let t = this._langSelect.value, n = globalThis, r = e.querySelector("code");
|
|
6982
|
-
r || (r = document.createElement("code"), r.innerHTML = e.innerHTML, e.innerHTML = "", e.appendChild(r)),
|
|
7097
|
+
r || (r = document.createElement("code"), r.innerHTML = e.innerHTML, e.innerHTML = "", e.appendChild(r)), Ui(r, t), Ui(e, t), t ? e.dataset.language = t : delete e.dataset.language;
|
|
6983
7098
|
let i = () => {
|
|
6984
|
-
r.querySelectorAll("br").forEach((e) => e.replaceWith("\n")), n.Prism.highlightElement(r), this.context.invoke("editor.afterCommand");
|
|
7099
|
+
!this.context._alive || !r.isConnected || !n.Prism || (r.querySelectorAll("br").forEach((e) => e.replaceWith("\n")), n.Prism.highlightElement(r), this.context.invoke("editor.afterCommand"));
|
|
6985
7100
|
};
|
|
6986
7101
|
if (t) {
|
|
6987
7102
|
if (n.Prism !== void 0) {
|
|
@@ -6992,21 +7107,24 @@ var Ni = class {
|
|
|
6992
7107
|
this._loadPrismComponent(t, i);
|
|
6993
7108
|
return;
|
|
6994
7109
|
} else if (this._prismScript) {
|
|
6995
|
-
this._prismScript
|
|
7110
|
+
this._onScriptLoad(this._prismScript, () => {
|
|
6996
7111
|
n.Prism.languages[t] ? i() : this._loadPrismComponent(t, i);
|
|
6997
|
-
}
|
|
7112
|
+
});
|
|
6998
7113
|
return;
|
|
6999
7114
|
}
|
|
7000
7115
|
}
|
|
7001
7116
|
this.context.invoke("editor.afterCommand");
|
|
7002
7117
|
}
|
|
7118
|
+
_cdnBase() {
|
|
7119
|
+
return String(this.context.options.codeHighlightCDN ?? "").replace(/\/+$/, "");
|
|
7120
|
+
}
|
|
7003
7121
|
_ensurePrism() {
|
|
7004
7122
|
let e = globalThis;
|
|
7005
7123
|
if (!this.context.options.codeHighlight || e.Prism) return;
|
|
7006
|
-
let t = this.
|
|
7124
|
+
let t = this._cdnBase(), n = `${t}/themes/prism-tomorrow.min.css`, r = `${t}/prism.min.js`;
|
|
7007
7125
|
if (!document.querySelector(`link[href="${n}"]`)) {
|
|
7008
7126
|
let e = document.createElement("link");
|
|
7009
|
-
e.rel = "stylesheet", e.href = n, document.head.appendChild(e);
|
|
7127
|
+
e.rel = "stylesheet", e.href = n, Li(e, this.context.options), document.head.appendChild(e);
|
|
7010
7128
|
}
|
|
7011
7129
|
let i = document.querySelector(`script[src="${r}"]`);
|
|
7012
7130
|
if (i) {
|
|
@@ -7014,21 +7132,33 @@ var Ni = class {
|
|
|
7014
7132
|
return;
|
|
7015
7133
|
}
|
|
7016
7134
|
let a = document.createElement("script");
|
|
7017
|
-
a.dataset.manual = "", a.src = r, this._prismScript = a,
|
|
7135
|
+
a.dataset.manual = "", a.src = r, Li(a, this.context.options), this._prismScript = a, this._onScriptLoad(a, () => {
|
|
7018
7136
|
this._prismScript = null;
|
|
7019
|
-
}
|
|
7137
|
+
}), document.head.appendChild(a);
|
|
7138
|
+
}
|
|
7139
|
+
_onScriptLoad(e, t) {
|
|
7140
|
+
let n = () => {
|
|
7141
|
+
this.context._alive && t();
|
|
7142
|
+
};
|
|
7143
|
+
e.addEventListener("load", n, { once: !0 }), this._asyncDisposers.push(() => e.removeEventListener("load", n));
|
|
7020
7144
|
}
|
|
7021
7145
|
_loadPrismComponent(e, t) {
|
|
7022
|
-
let n = globalThis, r = `${this.
|
|
7146
|
+
let n = globalThis, r = `${this._cdnBase()}/components/prism-${e}.min.js`;
|
|
7023
7147
|
if (document.querySelector(`script[src="${r}"]`)) {
|
|
7024
7148
|
let r = setInterval(() => {
|
|
7149
|
+
if (!this.context._alive) {
|
|
7150
|
+
clearInterval(r);
|
|
7151
|
+
return;
|
|
7152
|
+
}
|
|
7025
7153
|
n.Prism?.languages[e] && (clearInterval(r), t());
|
|
7026
|
-
}, 50);
|
|
7027
|
-
|
|
7154
|
+
}, 50), i = setTimeout(() => clearInterval(r), 3e3);
|
|
7155
|
+
this._asyncDisposers.push(() => {
|
|
7156
|
+
clearInterval(r), clearTimeout(i);
|
|
7157
|
+
});
|
|
7028
7158
|
return;
|
|
7029
7159
|
}
|
|
7030
7160
|
let i = document.createElement("script");
|
|
7031
|
-
i.src = r, i.
|
|
7161
|
+
i.src = r, Li(i, this.context.options), this._onScriptLoad(i, t), document.head.appendChild(i);
|
|
7032
7162
|
}
|
|
7033
7163
|
_toParagraph() {
|
|
7034
7164
|
let e = this._activePre;
|
|
@@ -7042,21 +7172,21 @@ var Ni = class {
|
|
|
7042
7172
|
let e = this._activePre;
|
|
7043
7173
|
e && (this._hide(), e.remove(), this.context.invoke("editor.afterCommand"));
|
|
7044
7174
|
}
|
|
7045
|
-
},
|
|
7046
|
-
function
|
|
7047
|
-
return
|
|
7175
|
+
}, Gi = null, Ki = null;
|
|
7176
|
+
function qi() {
|
|
7177
|
+
return Gi ? Promise.resolve(Gi) : (Ki ??= import("./emoji-data-BDQX5kh-.js").then((e) => (Gi = {
|
|
7048
7178
|
EMOJI_CATS: e.EMOJI_CATS,
|
|
7049
7179
|
EMOJI_LIST: e.EMOJI_LIST
|
|
7050
|
-
},
|
|
7180
|
+
}, Gi)), Ki);
|
|
7051
7181
|
}
|
|
7052
|
-
var
|
|
7182
|
+
var Ji = class extends W {
|
|
7053
7183
|
_activeCat = "all";
|
|
7054
7184
|
initialize() {
|
|
7055
7185
|
return this;
|
|
7056
7186
|
}
|
|
7057
7187
|
async show() {
|
|
7058
7188
|
if (this._saveRange(), !this._dialog) {
|
|
7059
|
-
let { EMOJI_CATS: e, EMOJI_LIST: t } = await
|
|
7189
|
+
let { EMOJI_CATS: e, EMOJI_LIST: t } = await qi();
|
|
7060
7190
|
this._dialog || (this._cats = e, this._list = t, this._dialog = this._buildDialog(), document.body.appendChild(this._dialog));
|
|
7061
7191
|
}
|
|
7062
7192
|
this._activeCat = "all", this._searchInput.value = "", this._updateCatTabs(), this._filterEmojis("", "all"), this._open();
|
|
@@ -7113,7 +7243,7 @@ var Li = class extends W {
|
|
|
7113
7243
|
type: "button",
|
|
7114
7244
|
class: "an-btn"
|
|
7115
7245
|
});
|
|
7116
|
-
p.textContent = e.cancelBtn, f.appendChild(p), n.append(r, c, l, d, f), t.appendChild(n),
|
|
7246
|
+
p.textContent = e.cancelBtn, f.appendChild(p), n.append(r, c, l, d, f), t.appendChild(n), ge(r, n);
|
|
7117
7247
|
let m = E(s, "click", () => this._close()), h = E(p, "click", () => this._close()), g = E(t, "click", (e) => {
|
|
7118
7248
|
e.target === t && this._close();
|
|
7119
7249
|
}), _ = E(c, "input", () => this._filterEmojis(c.value, this._activeCat)), v = E(l, "click", (e) => {
|
|
@@ -7149,14 +7279,14 @@ var Li = class extends W {
|
|
|
7149
7279
|
let s = document.createTextNode(e);
|
|
7150
7280
|
i.insertNode(s), i.setStartAfter(s), i.collapse(!0), r && (r.removeAllRanges(), r.addRange(i)), this._close(), n.focus(), this.context.invoke("editor.afterCommand");
|
|
7151
7281
|
}
|
|
7152
|
-
},
|
|
7153
|
-
function
|
|
7154
|
-
return
|
|
7282
|
+
}, Yi = "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css", Xi = null, Zi = null;
|
|
7283
|
+
function Qi() {
|
|
7284
|
+
return Xi ? Promise.resolve(Xi) : (Zi ??= import("./icon-data-V0Xqv-wX.js").then((e) => (Xi = {
|
|
7155
7285
|
ICON_CATEGORIES: e.ICON_CATEGORIES,
|
|
7156
7286
|
ICON_LIST: e.ICON_LIST
|
|
7157
|
-
},
|
|
7287
|
+
}, Xi)), Zi);
|
|
7158
7288
|
}
|
|
7159
|
-
var
|
|
7289
|
+
var $i = class extends W {
|
|
7160
7290
|
_selectedIcon = null;
|
|
7161
7291
|
_activeCat = "all";
|
|
7162
7292
|
initialize() {
|
|
@@ -7164,16 +7294,16 @@ var Hi = class extends W {
|
|
|
7164
7294
|
}
|
|
7165
7295
|
_ensureFontAwesome() {
|
|
7166
7296
|
if (this.context.options.fontAwesomeAutoInject === !1) return;
|
|
7167
|
-
let e = this.context.options.fontAwesomeCDN ||
|
|
7297
|
+
let e = this.context.options.fontAwesomeCDN || Yi;
|
|
7168
7298
|
if (!e || document.getElementById("an-fontawesome-css")) return;
|
|
7169
7299
|
let t = Array.from(document.querySelectorAll("link[rel=\"stylesheet\"]")).map((e) => e.href || "").join(" ");
|
|
7170
7300
|
if (/fontawesome|font-awesome/.test(t) || document.querySelector(".fa-solid, .fas, .far, .fab")) return;
|
|
7171
7301
|
let n = document.createElement("link");
|
|
7172
|
-
n.id = "an-fontawesome-css", n.rel = "stylesheet", n.href = e, n
|
|
7302
|
+
n.id = "an-fontawesome-css", n.rel = "stylesheet", n.href = e, Li(n, this.context.options), document.head.appendChild(n);
|
|
7173
7303
|
}
|
|
7174
7304
|
async show() {
|
|
7175
7305
|
if (this._saveRange(), this._ensureFontAwesome(), !this._dialog) {
|
|
7176
|
-
let { ICON_CATEGORIES: e, ICON_LIST: t } = await
|
|
7306
|
+
let { ICON_CATEGORIES: e, ICON_LIST: t } = await Qi();
|
|
7177
7307
|
this._dialog || (this._cats = e, this._list = t, this._dialog = this._buildDialog(), document.body.appendChild(this._dialog));
|
|
7178
7308
|
}
|
|
7179
7309
|
this._selectedIcon = null, this._activeCat = "all", this._searchInput.value = "", this._grid.querySelectorAll(".an-icon-cell.active").forEach((e) => e.classList.remove("active")), this._insertBtn.setAttribute("disabled", ""), this._updateCatTabs(), this._filterIcons("", "all"), this._updatePreview(null), this._open();
|
|
@@ -7279,7 +7409,7 @@ var Hi = class extends W {
|
|
|
7279
7409
|
type: "button",
|
|
7280
7410
|
class: "an-btn"
|
|
7281
7411
|
});
|
|
7282
|
-
C.textContent = e.cancelBtn, te.append(S, C), this._insertBtn = S, n.append(r, c, l, d, f, x, te), t.appendChild(n),
|
|
7412
|
+
C.textContent = e.cancelBtn, te.append(S, C), this._insertBtn = S, n.append(r, c, l, d, f, x, te), t.appendChild(n), ge(r, n);
|
|
7283
7413
|
let ne = E(s, "click", () => this._close()), re = E(C, "click", () => this._close()), ie = E(S, "click", () => this._onInsert()), ae = E(t, "click", (e) => {
|
|
7284
7414
|
e.target === t && this._close();
|
|
7285
7415
|
}), T = E(c, "input", () => this._filterIcons(c.value, this._activeCat)), oe = E(l, "click", (e) => {
|
|
@@ -7337,7 +7467,7 @@ var Hi = class extends W {
|
|
|
7337
7467
|
_close() {
|
|
7338
7468
|
this._selectedIcon = null, super._close();
|
|
7339
7469
|
}
|
|
7340
|
-
},
|
|
7470
|
+
}, ea = [
|
|
7341
7471
|
{
|
|
7342
7472
|
category: "Text Formatting",
|
|
7343
7473
|
items: [
|
|
@@ -7410,12 +7540,12 @@ var Hi = class extends W {
|
|
|
7410
7540
|
action: "Show this keyboard shortcuts dialog"
|
|
7411
7541
|
}]
|
|
7412
7542
|
}
|
|
7413
|
-
],
|
|
7543
|
+
], ta = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect x=\"2\" y=\"7\" width=\"20\" height=\"14\" rx=\"2\"/><path d=\"M6 11h.01M10 11h.01M14 11h.01M18 11h.01M6 15h.01M18 15h.01M10 15h4\"/><path d=\"M7 3l5 4 5-4\"/></svg>", na = class extends W {
|
|
7414
7544
|
show() {
|
|
7415
7545
|
this._open();
|
|
7416
7546
|
}
|
|
7417
7547
|
_buildDialog() {
|
|
7418
|
-
let e = this.context.locale.shortcutsDialog, { overlay: t, box: n } = this._buildDialogShell(e.ariaLabel,
|
|
7548
|
+
let e = this.context.locale.shortcutsDialog, { overlay: t, box: n } = this._buildDialogShell(e.ariaLabel, ta, e.title);
|
|
7419
7549
|
n.classList.add("an-shortcuts-box");
|
|
7420
7550
|
let r = w("button", {
|
|
7421
7551
|
type: "button",
|
|
@@ -7423,7 +7553,7 @@ var Hi = class extends W {
|
|
|
7423
7553
|
"aria-label": e.close,
|
|
7424
7554
|
style: "margin-left:auto"
|
|
7425
7555
|
});
|
|
7426
|
-
r.textContent = "×", this._closeBtn = r, this._firstInput = r, n.querySelector(".an-dialog-header").appendChild(r), (this.context.locale.shortcutsDialog.shortcuts ||
|
|
7556
|
+
r.textContent = "×", this._closeBtn = r, this._firstInput = r, n.querySelector(".an-dialog-header").appendChild(r), (this.context.locale.shortcutsDialog.shortcuts || ea).forEach(({ category: e, items: t }) => {
|
|
7427
7557
|
let r = w("div", { class: "an-shortcuts-cat" });
|
|
7428
7558
|
r.textContent = e, n.appendChild(r);
|
|
7429
7559
|
let i = w("div", { class: "an-shortcuts-table" });
|
|
@@ -7437,7 +7567,7 @@ var Hi = class extends W {
|
|
|
7437
7567
|
let i = E(r, "click", () => this._close());
|
|
7438
7568
|
return this._disposers.push(i), t;
|
|
7439
7569
|
}
|
|
7440
|
-
},
|
|
7570
|
+
}, ra = class extends W {
|
|
7441
7571
|
constructor(e) {
|
|
7442
7572
|
super(e), this._findInput = null, this._replaceInput = null, this._caseCheckbox = null, this._counterEl = null, this._closeBtn = null, this._matches = [], this._currentIndex = -1, this._caseSensitive = !1, this._useRegex = !1, this._wholeWord = !1, this._mode = "find", this._queryRegex = null, this._lastQuery = null, this._lastCaseSensitive = null, this._lastUseRegex = null, this._lastWholeWord = null, this._focusTimer = null;
|
|
7443
7573
|
}
|
|
@@ -7455,7 +7585,7 @@ var Hi = class extends W {
|
|
|
7455
7585
|
this._findInput && this._findInput.focus();
|
|
7456
7586
|
return;
|
|
7457
7587
|
}
|
|
7458
|
-
this._dialog.style.display = "flex", this._removeTrap &&= (this._removeTrap(), null), this._removeTrap =
|
|
7588
|
+
this._dialog.style.display = "flex", this._removeTrap &&= (this._removeTrap(), null), this._removeTrap = he(this._dialog, () => this._close());
|
|
7459
7589
|
}
|
|
7460
7590
|
}
|
|
7461
7591
|
_close() {
|
|
@@ -7553,7 +7683,7 @@ var Hi = class extends W {
|
|
|
7553
7683
|
});
|
|
7554
7684
|
b.textContent = e.replaceAllBtn, _.append(v, y, b), n.appendChild(_);
|
|
7555
7685
|
let x = w("div", { class: "an-fr-replace-actions" });
|
|
7556
|
-
x.style.display = "none", n.appendChild(x), t.appendChild(n),
|
|
7686
|
+
x.style.display = "none", n.appendChild(x), t.appendChild(n), ge(r, n);
|
|
7557
7687
|
let ee = E(s, "click", () => this._close()), te = E(t, "click", (e) => {
|
|
7558
7688
|
e.target === t && this._close();
|
|
7559
7689
|
}), S = E(l, "input", () => this._onSearch()), C = E(d, "click", () => {
|
|
@@ -7680,8 +7810,8 @@ var Hi = class extends W {
|
|
|
7680
7810
|
this._counterEl.textContent = e ? this.context.locale.findReplace.noResults : "";
|
|
7681
7811
|
} else this._counterEl.textContent = `${this._currentIndex + 1} / ${e}`;
|
|
7682
7812
|
}
|
|
7683
|
-
}, Y = 20,
|
|
7684
|
-
function
|
|
7813
|
+
}, Y = 20, ia = "#3b82f6", X = (e, t, n) => Math.min(Math.max(e, t), n);
|
|
7814
|
+
function aa(e, t, n, r) {
|
|
7685
7815
|
return new Promise((i) => {
|
|
7686
7816
|
let a = (e) => {
|
|
7687
7817
|
let a = document.createElement("canvas");
|
|
@@ -7705,7 +7835,7 @@ function Ji(e, t, n, r) {
|
|
|
7705
7835
|
o.crossOrigin = "anonymous", o.onload = () => a(o), o.onerror = () => i(null), o.src = e.src + (e.src.includes("?") ? "&" : "?") + "_an=" + Date.now();
|
|
7706
7836
|
});
|
|
7707
7837
|
}
|
|
7708
|
-
var
|
|
7838
|
+
var oa = class {
|
|
7709
7839
|
constructor(e) {
|
|
7710
7840
|
this.context = e, this._img = null, this._box = null, this._imgRect = null, this._scrim = null, this._cropBox = null, this._handles = {}, this._toolbar = null, this._infoEl = null, this._dragDisposers = null, this._disposers = [];
|
|
7711
7841
|
}
|
|
@@ -7736,7 +7866,7 @@ var Yi = class {
|
|
|
7736
7866
|
t.className = "an-crop-box", t.style.cssText = `
|
|
7737
7867
|
position:fixed; z-index:10101;
|
|
7738
7868
|
box-sizing:border-box;
|
|
7739
|
-
border:2px solid ${
|
|
7869
|
+
border:2px solid ${ia};
|
|
7740
7870
|
cursor:move;
|
|
7741
7871
|
outline: none;
|
|
7742
7872
|
`;
|
|
@@ -7801,7 +7931,7 @@ var Yi = class {
|
|
|
7801
7931
|
"position:absolute",
|
|
7802
7932
|
"width:10px",
|
|
7803
7933
|
"height:10px",
|
|
7804
|
-
`background:${
|
|
7934
|
+
`background:${ia}`,
|
|
7805
7935
|
"border:2px solid #fff",
|
|
7806
7936
|
"border-radius:2px",
|
|
7807
7937
|
"box-sizing:border-box",
|
|
@@ -7835,7 +7965,7 @@ var Yi = class {
|
|
|
7835
7965
|
let a = this._makeToolbarBtn("✓ Crop", "#22c55e", () => this._confirm()), o = this._makeToolbarBtn("✕ Cancel", "#94a3b8", () => this._close(!1)), s = document.createElement("label");
|
|
7836
7966
|
s.style.cssText = "color:#94a3b8;font-size:11px;cursor:pointer;display:flex;align-items:center;gap:4px;";
|
|
7837
7967
|
let c = document.createElement("input");
|
|
7838
|
-
c.type = "checkbox", c.style.accentColor =
|
|
7968
|
+
c.type = "checkbox", c.style.accentColor = ia, s.appendChild(c), s.appendChild(document.createTextNode("Lock ratio")), this._arCheck = c, i.appendChild(a), i.appendChild(o), i.appendChild(s), this._toolbar = i, this._disposers.push(E(i, "mousedown", (e) => e.stopPropagation())), document.body.appendChild(e), document.body.appendChild(t), document.body.appendChild(i), this._scrim = e, this._cropBox = t;
|
|
7839
7969
|
}
|
|
7840
7970
|
_makeToolbarBtn(e, t, n) {
|
|
7841
7971
|
let r = document.createElement("button");
|
|
@@ -7920,7 +8050,7 @@ var Yi = class {
|
|
|
7920
8050
|
this._close(!1);
|
|
7921
8051
|
return;
|
|
7922
8052
|
}
|
|
7923
|
-
let f = await
|
|
8053
|
+
let f = await aa(e, {
|
|
7924
8054
|
x: c,
|
|
7925
8055
|
y: l,
|
|
7926
8056
|
width: u,
|
|
@@ -7964,7 +8094,7 @@ var Yi = class {
|
|
|
7964
8094
|
e?.remove();
|
|
7965
8095
|
}), this._scrim = null, this._cropBox = null, this._toolbar = null, this._infoEl = null, this._handles = {}, this._img = null, this._box = null, this._imgRect = null, this._arCheck = null;
|
|
7966
8096
|
}
|
|
7967
|
-
},
|
|
8097
|
+
}, sa = class {
|
|
7968
8098
|
constructor(e) {
|
|
7969
8099
|
this.context = e, this.options = e.options, this._banner = null;
|
|
7970
8100
|
}
|
|
@@ -8017,7 +8147,7 @@ var Yi = class {
|
|
|
8017
8147
|
_removeBanner() {
|
|
8018
8148
|
this._banner?.remove(), this._banner = null;
|
|
8019
8149
|
}
|
|
8020
|
-
},
|
|
8150
|
+
}, ca = class {
|
|
8021
8151
|
constructor(e) {
|
|
8022
8152
|
this.context = e, this.options = e.options, this._disposers = [];
|
|
8023
8153
|
}
|
|
@@ -8163,7 +8293,7 @@ var Yi = class {
|
|
|
8163
8293
|
break;
|
|
8164
8294
|
}
|
|
8165
8295
|
}
|
|
8166
|
-
},
|
|
8296
|
+
}, la = [
|
|
8167
8297
|
"#000000",
|
|
8168
8298
|
"#434343",
|
|
8169
8299
|
"#666666",
|
|
@@ -8188,7 +8318,7 @@ var Yi = class {
|
|
|
8188
8318
|
"#c9daf8",
|
|
8189
8319
|
"#d9d2e9",
|
|
8190
8320
|
"#ead1dc"
|
|
8191
|
-
],
|
|
8321
|
+
], ua = "stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"", Z = (e) => `<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" ${ua} style="display:block">${e}</svg>`, da = {
|
|
8192
8322
|
bold: Z("<path d=\"M6 4h8a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z\"/><path d=\"M6 12h9a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z\"/>"),
|
|
8193
8323
|
italic: Z("<line x1=\"19\" y1=\"4\" x2=\"10\" y2=\"4\"/><line x1=\"14\" y1=\"20\" x2=\"5\" y2=\"20\"/><line x1=\"15\" y1=\"4\" x2=\"9\" y2=\"20\"/>"),
|
|
8194
8324
|
underline: Z("<path d=\"M6 3v7a6 6 0 0 0 6 6 6 6 0 0 0 6-6V3\"/><line x1=\"4\" y1=\"21\" x2=\"20\" y2=\"21\"/>"),
|
|
@@ -8198,7 +8328,7 @@ var Yi = class {
|
|
|
8198
8328
|
hiliteColor: Z("<path d=\"M3 21v-4l9-9 4 4-9 9z\"/><path d=\"M12 8l4 4\"/><line x1=\"3\" y1=\"21\" x2=\"21\" y2=\"21\"/>"),
|
|
8199
8329
|
removeFormat: Z("<path d=\"m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21\"/><path d=\"M22 21H7\"/><path d=\"m5 11 9 9\"/>"),
|
|
8200
8330
|
inlineCode: Z("<path d=\"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1\"/><path d=\"M16 3h1a2 2 0 0 1 2 2v5c0 1.1.9 2 2 2a2 2 0 0 1-2 2v5a2 2 0 0 1-2 2h-1\"/>")
|
|
8201
|
-
},
|
|
8331
|
+
}, fa = {
|
|
8202
8332
|
bold: (e) => e.invoke("editor.bold"),
|
|
8203
8333
|
italic: (e) => e.invoke("editor.italic"),
|
|
8204
8334
|
underline: (e) => e.invoke("editor.underline"),
|
|
@@ -8219,115 +8349,115 @@ var Yi = class {
|
|
|
8219
8349
|
e.invoke("editor.afterCommand");
|
|
8220
8350
|
},
|
|
8221
8351
|
inlineCode: (e) => e.invoke("editor.inlineCode")
|
|
8222
|
-
},
|
|
8352
|
+
}, pa = {
|
|
8223
8353
|
bold: () => document.queryCommandState("bold"),
|
|
8224
8354
|
italic: () => document.queryCommandState("italic"),
|
|
8225
8355
|
underline: () => document.queryCommandState("underline"),
|
|
8226
8356
|
strikethrough: () => document.queryCommandState("strikeThrough")
|
|
8227
|
-
},
|
|
8357
|
+
}, ma = {
|
|
8228
8358
|
foreColor: !0,
|
|
8229
8359
|
hiliteColor: !0
|
|
8230
|
-
},
|
|
8360
|
+
}, ha = [
|
|
8231
8361
|
{
|
|
8232
8362
|
name: "editor",
|
|
8233
|
-
Class:
|
|
8363
|
+
Class: Yr
|
|
8234
8364
|
},
|
|
8235
8365
|
{
|
|
8236
8366
|
name: "toolbar",
|
|
8237
|
-
Class:
|
|
8367
|
+
Class: ei
|
|
8238
8368
|
},
|
|
8239
8369
|
{
|
|
8240
8370
|
name: "statusbar",
|
|
8241
|
-
Class:
|
|
8371
|
+
Class: ni
|
|
8242
8372
|
},
|
|
8243
8373
|
{
|
|
8244
8374
|
name: "clipboard",
|
|
8245
|
-
Class:
|
|
8375
|
+
Class: ri
|
|
8246
8376
|
},
|
|
8247
8377
|
{
|
|
8248
8378
|
name: "placeholder",
|
|
8249
|
-
Class:
|
|
8379
|
+
Class: ui
|
|
8250
8380
|
},
|
|
8251
8381
|
{
|
|
8252
8382
|
name: "contextMenu",
|
|
8253
|
-
Class:
|
|
8383
|
+
Class: si
|
|
8254
8384
|
},
|
|
8255
8385
|
{
|
|
8256
8386
|
name: "codeview",
|
|
8257
|
-
Class:
|
|
8387
|
+
Class: di
|
|
8258
8388
|
},
|
|
8259
8389
|
{
|
|
8260
8390
|
name: "fullscreen",
|
|
8261
|
-
Class:
|
|
8391
|
+
Class: fi
|
|
8262
8392
|
},
|
|
8263
8393
|
{
|
|
8264
8394
|
name: "linkDialog",
|
|
8265
|
-
Class:
|
|
8395
|
+
Class: mi
|
|
8266
8396
|
},
|
|
8267
8397
|
{
|
|
8268
8398
|
name: "imageDialog",
|
|
8269
|
-
Class:
|
|
8399
|
+
Class: gi
|
|
8270
8400
|
},
|
|
8271
8401
|
{
|
|
8272
8402
|
name: "videoDialog",
|
|
8273
|
-
Class:
|
|
8403
|
+
Class: vi
|
|
8274
8404
|
},
|
|
8275
8405
|
{
|
|
8276
8406
|
name: "imageResizer",
|
|
8277
|
-
Class:
|
|
8407
|
+
Class: xi
|
|
8278
8408
|
},
|
|
8279
8409
|
{
|
|
8280
8410
|
name: "videoResizer",
|
|
8281
|
-
Class:
|
|
8411
|
+
Class: Si
|
|
8282
8412
|
},
|
|
8283
8413
|
{
|
|
8284
8414
|
name: "linkTooltip",
|
|
8285
|
-
Class:
|
|
8415
|
+
Class: Ei
|
|
8286
8416
|
},
|
|
8287
8417
|
{
|
|
8288
8418
|
name: "imageTooltip",
|
|
8289
|
-
Class:
|
|
8419
|
+
Class: Oi
|
|
8290
8420
|
},
|
|
8291
8421
|
{
|
|
8292
8422
|
name: "videoTooltip",
|
|
8293
|
-
Class:
|
|
8423
|
+
Class: ki
|
|
8294
8424
|
},
|
|
8295
8425
|
{
|
|
8296
8426
|
name: "tableTooltip",
|
|
8297
|
-
Class:
|
|
8427
|
+
Class: Ii
|
|
8298
8428
|
},
|
|
8299
8429
|
{
|
|
8300
8430
|
name: "codeTooltip",
|
|
8301
|
-
Class:
|
|
8431
|
+
Class: Wi
|
|
8302
8432
|
},
|
|
8303
8433
|
{
|
|
8304
8434
|
name: "emojiDialog",
|
|
8305
|
-
Class:
|
|
8435
|
+
Class: Ji
|
|
8306
8436
|
},
|
|
8307
8437
|
{
|
|
8308
8438
|
name: "iconDialog",
|
|
8309
|
-
Class:
|
|
8439
|
+
Class: $i
|
|
8310
8440
|
},
|
|
8311
8441
|
{
|
|
8312
8442
|
name: "shortcutsDialog",
|
|
8313
|
-
Class:
|
|
8443
|
+
Class: na
|
|
8314
8444
|
},
|
|
8315
8445
|
{
|
|
8316
8446
|
name: "findReplace",
|
|
8317
|
-
Class:
|
|
8447
|
+
Class: ra
|
|
8318
8448
|
},
|
|
8319
8449
|
{
|
|
8320
8450
|
name: "imageCropOverlay",
|
|
8321
|
-
Class:
|
|
8451
|
+
Class: oa
|
|
8322
8452
|
},
|
|
8323
8453
|
{
|
|
8324
8454
|
name: "autoSaveRestore",
|
|
8325
|
-
Class:
|
|
8455
|
+
Class: sa,
|
|
8326
8456
|
enabled: (e) => !!e.autoSaveRestore
|
|
8327
8457
|
},
|
|
8328
8458
|
{
|
|
8329
8459
|
name: "markdownShortcuts",
|
|
8330
|
-
Class:
|
|
8460
|
+
Class: ca,
|
|
8331
8461
|
enabled: (e) => e.markdownShortcuts !== !1
|
|
8332
8462
|
},
|
|
8333
8463
|
{
|
|
@@ -8362,23 +8492,23 @@ var Yi = class {
|
|
|
8362
8492
|
"removeFormat"
|
|
8363
8493
|
];
|
|
8364
8494
|
for (let n of t) {
|
|
8365
|
-
if (!
|
|
8495
|
+
if (!da[n]) continue;
|
|
8366
8496
|
let t = document.createElement("button");
|
|
8367
|
-
if (t.type = "button", t.dataset.name = n, t.setAttribute("aria-label", n),
|
|
8497
|
+
if (t.type = "button", t.dataset.name = n, t.setAttribute("aria-label", n), ma[n]) {
|
|
8368
8498
|
t.className = "an-bubble-btn an-bubble-btn--color";
|
|
8369
8499
|
let e = document.createElement("span");
|
|
8370
|
-
e.className = "an-bubble-btn-svg", e.innerHTML =
|
|
8500
|
+
e.className = "an-bubble-btn-svg", e.innerHTML = da[n];
|
|
8371
8501
|
let r = document.createElement("span");
|
|
8372
8502
|
r.className = "an-bubble-color-strip", r.style.background = n === "foreColor" ? "#000000" : "transparent", t.appendChild(e), t.appendChild(r);
|
|
8373
|
-
} else t.className = "an-bubble-btn", t.innerHTML =
|
|
8503
|
+
} else t.className = "an-bubble-btn", t.innerHTML = da[n];
|
|
8374
8504
|
t.addEventListener("mousedown", (e) => {
|
|
8375
8505
|
e.preventDefault();
|
|
8376
8506
|
}), t.addEventListener("click", (e) => {
|
|
8377
|
-
if (e.preventDefault(), e.stopPropagation(),
|
|
8507
|
+
if (e.preventDefault(), e.stopPropagation(), ma[n]) {
|
|
8378
8508
|
this._openColorPicker(n, t);
|
|
8379
8509
|
return;
|
|
8380
8510
|
}
|
|
8381
|
-
this.context.invoke("editor.focus"),
|
|
8511
|
+
this.context.invoke("editor.focus"), fa[n] && fa[n](this.context), this._syncActive();
|
|
8382
8512
|
}), e.appendChild(t);
|
|
8383
8513
|
}
|
|
8384
8514
|
document.body.appendChild(e), this._el = e, this._btnCache = Array.from(e.querySelectorAll(".an-bubble-btn"));
|
|
@@ -8387,7 +8517,7 @@ var Yi = class {
|
|
|
8387
8517
|
let e = document.createElement("div");
|
|
8388
8518
|
e.className = "an-bubble-color-picker", e.style.display = "none", e.addEventListener("mousedown", (e) => e.preventDefault());
|
|
8389
8519
|
let t = document.createElement("div");
|
|
8390
|
-
t.className = "an-context-color-palette",
|
|
8520
|
+
t.className = "an-context-color-palette", la.forEach((e) => {
|
|
8391
8521
|
let n = document.createElement("div");
|
|
8392
8522
|
n.className = "an-context-color-swatch", n.title = e, n.style.background = e, n.setAttribute("role", "button"), n.setAttribute("aria-label", e), n.addEventListener("click", (t) => {
|
|
8393
8523
|
t.stopPropagation(), this._applyColor(this._pickerType, e);
|
|
@@ -8455,7 +8585,7 @@ var Yi = class {
|
|
|
8455
8585
|
}
|
|
8456
8586
|
_syncActive() {
|
|
8457
8587
|
this._btnCache && this._btnCache.forEach((e) => {
|
|
8458
|
-
let t =
|
|
8588
|
+
let t = pa[e.dataset.name];
|
|
8459
8589
|
e.classList.toggle("an-active", !!t?.());
|
|
8460
8590
|
});
|
|
8461
8591
|
}
|
|
@@ -8891,42 +9021,42 @@ var Yi = class {
|
|
|
8891
9021
|
},
|
|
8892
9022
|
enabled: (e) => e.slashMenu !== !1
|
|
8893
9023
|
}
|
|
8894
|
-
];
|
|
9024
|
+
], ga = "2.7.0";
|
|
8895
9025
|
//#endregion
|
|
8896
9026
|
//#region src/js/core/lists.js
|
|
8897
|
-
function
|
|
9027
|
+
function _a(e) {
|
|
8898
9028
|
return e[e.length - 1];
|
|
8899
9029
|
}
|
|
8900
|
-
function
|
|
9030
|
+
function va(e) {
|
|
8901
9031
|
return e[0];
|
|
8902
9032
|
}
|
|
8903
|
-
function
|
|
9033
|
+
function ya(e, t = 1) {
|
|
8904
9034
|
return e.slice(0, e.length - t);
|
|
8905
9035
|
}
|
|
8906
|
-
function
|
|
9036
|
+
function ba(e, t = 1) {
|
|
8907
9037
|
return e.slice(t);
|
|
8908
9038
|
}
|
|
8909
|
-
function
|
|
9039
|
+
function xa(e) {
|
|
8910
9040
|
return e.flat();
|
|
8911
9041
|
}
|
|
8912
|
-
function
|
|
9042
|
+
function Sa(e) {
|
|
8913
9043
|
return [...new Set(e)];
|
|
8914
9044
|
}
|
|
8915
|
-
function
|
|
9045
|
+
function Ca(e, t) {
|
|
8916
9046
|
let n = [];
|
|
8917
9047
|
for (let r = 0; r < e.length; r += t) n.push(e.slice(r, r + t));
|
|
8918
9048
|
return n;
|
|
8919
9049
|
}
|
|
8920
|
-
function
|
|
9050
|
+
function wa(e, t) {
|
|
8921
9051
|
return e.reduce((e, n) => {
|
|
8922
9052
|
let r = t(n);
|
|
8923
9053
|
return e[r] || (e[r] = []), e[r].push(n), e;
|
|
8924
9054
|
}, {});
|
|
8925
9055
|
}
|
|
8926
|
-
function
|
|
9056
|
+
function Ta(e, t) {
|
|
8927
9057
|
return e.every(t);
|
|
8928
9058
|
}
|
|
8929
|
-
function
|
|
9059
|
+
function Ea(e, t) {
|
|
8930
9060
|
return e.some(t);
|
|
8931
9061
|
}
|
|
8932
9062
|
//#endregion
|
|
@@ -8934,7 +9064,7 @@ function ma(e, t) {
|
|
|
8934
9064
|
function Q() {
|
|
8935
9065
|
return globalThis.navigator?.userAgent ?? "";
|
|
8936
9066
|
}
|
|
8937
|
-
var
|
|
9067
|
+
var Da = {
|
|
8938
9068
|
get isChrome() {
|
|
8939
9069
|
return /Chrome\//.test(Q()) && !/Edg\//.test(Q());
|
|
8940
9070
|
},
|
|
@@ -8959,17 +9089,19 @@ var ha = {
|
|
|
8959
9089
|
get modifierKey() {
|
|
8960
9090
|
return /Macintosh/.test(Q()) ? "metaKey" : "ctrlKey";
|
|
8961
9091
|
}
|
|
8962
|
-
},
|
|
9092
|
+
}, Oa = { ...k }, $ = /* @__PURE__ */ new WeakMap(), ka = {
|
|
8963
9093
|
create(e, t = {}) {
|
|
8964
|
-
let n =
|
|
9094
|
+
let n = Aa(e).map((e) => {
|
|
8965
9095
|
if ($.has(e)) return $.get(e);
|
|
8966
|
-
let n = new
|
|
8967
|
-
return n.
|
|
9096
|
+
let n = new On(e, t);
|
|
9097
|
+
return n._releaseInstance = () => {
|
|
9098
|
+
$.get(e) === n && $.delete(e);
|
|
9099
|
+
}, n.initialize(), $.set(e, n), n;
|
|
8968
9100
|
});
|
|
8969
9101
|
return n.length === 1 ? n[0] : n;
|
|
8970
9102
|
},
|
|
8971
9103
|
destroy(e) {
|
|
8972
|
-
|
|
9104
|
+
Aa(e).forEach((e) => {
|
|
8973
9105
|
let t = $.get(e);
|
|
8974
9106
|
t && (t.destroy(), $.delete(e));
|
|
8975
9107
|
});
|
|
@@ -8985,42 +9117,42 @@ var ha = {
|
|
|
8985
9117
|
Object.assign(k, e);
|
|
8986
9118
|
},
|
|
8987
9119
|
resetDefaults() {
|
|
8988
|
-
Object.keys(k).forEach((e) => delete k[e]), Object.assign(k,
|
|
9120
|
+
Object.keys(k).forEach((e) => delete k[e]), Object.assign(k, Oa);
|
|
8989
9121
|
},
|
|
8990
9122
|
registerModule(e, t) {
|
|
8991
|
-
|
|
9123
|
+
wn.set(e, t);
|
|
8992
9124
|
},
|
|
8993
9125
|
use(e, t = {}) {
|
|
8994
9126
|
if (!e || typeof e.name != "string") throw TypeError("[AutumnNote] AutumnNote.use: plugin must have a string `name` property.");
|
|
8995
|
-
return
|
|
9127
|
+
return Dn.has(e.name) ? (console.warn(`[AutumnNote] Plugin "${e.name}" already registered globally. Skipping.`), this) : (Array.isArray(e.buttons) && e.buttons.forEach((e) => pt(e)), Dn.set(e.name, {
|
|
8996
9128
|
plugin: e,
|
|
8997
9129
|
options: t
|
|
8998
9130
|
}), this);
|
|
8999
9131
|
},
|
|
9000
9132
|
hasPlugin(e) {
|
|
9001
|
-
return
|
|
9133
|
+
return Dn.has(e);
|
|
9002
9134
|
},
|
|
9003
9135
|
registerButton(e) {
|
|
9004
|
-
return
|
|
9136
|
+
return pt(e), this;
|
|
9005
9137
|
},
|
|
9006
9138
|
registerLocale(e, t) {
|
|
9007
|
-
return
|
|
9139
|
+
return rn(e, t), this;
|
|
9008
9140
|
},
|
|
9009
9141
|
registerSlashCommand(e) {
|
|
9010
9142
|
if (!e?.id || typeof e.run != "function") throw TypeError("[AutumnNote] Slash command requires an id and run(context) function.");
|
|
9011
9143
|
let t = k.slashCommands, n = t.findIndex((t) => t.id === e.id);
|
|
9012
9144
|
return n >= 0 ? t[n] = e : t.push(e), this;
|
|
9013
9145
|
},
|
|
9014
|
-
buttons:
|
|
9015
|
-
version:
|
|
9146
|
+
buttons: tn,
|
|
9147
|
+
version: ga
|
|
9016
9148
|
};
|
|
9017
|
-
function
|
|
9149
|
+
function Aa(e) {
|
|
9018
9150
|
return typeof e == "string" ? Array.from(document.querySelectorAll(e)) : e instanceof Element ? [e] : e instanceof NodeList || Array.isArray(e) ? Array.from(e) : [];
|
|
9019
9151
|
}
|
|
9020
9152
|
//#endregion
|
|
9021
9153
|
//#region src/js/index.js
|
|
9022
|
-
|
|
9154
|
+
En(ha);
|
|
9023
9155
|
//#endregion
|
|
9024
|
-
export {
|
|
9156
|
+
export { On as Context, d as ELEMENT_NODE, Ur as SUPPORTED_LANGS, f as TEXT_NODE, _e as WrappedRange, ft as _buttonRegistry, St as alignCenterBtn, wt as alignJustifyBtn, xt as alignLeftBtn, Ct as alignRightBtn, Ta as all, ne as ancestors, Ea as any, $t as backColorBtn, ht as boldBtn, tn as buttons, Xt as checklistBtn, re as children, Ca as chunk, e as clamp, S as closest, C as closestPara, Wt as codeviewBtn, xe as collapsedRange, r as compose, w as createElement, ye as currentRange, t as debounce, ka as default, k as defaultOptions, en as defaultToolbar, qr as detectLang, Bt as directionBtn, Ft as emojiBtn, Da as env, qt as findBtn, Jt as findReplaceBtn, va as first, xa as flatten, Vt as fontFamilyBtn, Rt as fontSizeBtn, Qt as foreColorBtn, ve as fromNativeRange, Gt as fullscreenBtn, mt as getButton, wa as groupBy, jt as hrBtn, Kn as htmlToMarkdown, It as iconBtn, i as identity, Nt as imageBtn, Dt as indentBtn, ya as initial, Yt as inlineCodeBtn, ce as insertAfter, ee as isAnchor, x as isEditable, p as isElement, ue as isEmpty, s as isFunction, te as isImage, b as isInline, me as isInsideEditable, P as isKey, _ as isLi, v as isList, nr as isMarkdown, F as isModifier, a as isNil, g as isPara, l as isPlainObject, Se as isSelectionInside, o as isString, y as isTable, m as isText, h as isVoid, gt as italicBtn, N as key, _a as last, Ut as lineHeightBtn, Mt as linkBtn, nn as locales, ge as makeDraggable, ur as markdownToHTML, c as mergeDeep, ae as nextElement, le as nodeValue, Et as olBtn, E as on, Ot as outdentBtn, de as outerHtml, Ht as paragraphStyleBtn, fe as placeCaret, ie as prevElement, Zt as printBtn, be as rangeFromElement, u as rect2bnd, At as redoBtn, pt as registerButton, rn as registerLocale, T as remove, zt as removeFormatBtn, pe as repairListNesting, an as resolveLocale, j as sanitiseHTML, vn as sanitiseToBody, M as sanitiseUrl, Kt as shortcutsBtn, we as splitText, vt as strikeBtn, bt as subscriptBtn, yt as superscriptBtn, Lt as tableBtn, ba as tail, n as throttle, he as trapFocus, Tt as ulBtn, _t as underlineBtn, kt as undoBtn, Sa as unique, oe as unwrap, Pt as videoBtn, Ce as withSavedRange, se as wrap };
|
|
9025
9157
|
|
|
9026
9158
|
//# sourceMappingURL=autumnnote.es.js.map
|