autumnnote 2.6.0 → 2.7.1
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 +34 -1
- package/dist/autumnnote.cjs +33 -33
- package/dist/autumnnote.core.es.js +680 -568
- package/dist/autumnnote.core.es.js.map +1 -1
- package/dist/autumnnote.es.js +856 -712
- 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 +9 -9
- package/src/js/core/func.js +10 -4
- package/types/index.d.ts +50 -1
package/dist/autumnnote.es.js
CHANGED
|
@@ -36,7 +36,7 @@ function s(e) {
|
|
|
36
36
|
function c(e, t) {
|
|
37
37
|
let n = {};
|
|
38
38
|
for (let t of Object.keys(e)) n[t] = Array.isArray(e[t]) ? [...e[t]] : e[t];
|
|
39
|
-
if (l(e) && l(t)) for (let r of Object.keys(t)) l(t[r]) ?
|
|
39
|
+
if (l(e) && l(t)) for (let r of Object.keys(t)) n[r] = l(t[r]) ? c(l(e[r]) ? e[r] : {}, t[r]) : Array.isArray(t[r]) ? [...t[r]] : t[r];
|
|
40
40
|
return n;
|
|
41
41
|
}
|
|
42
42
|
function l(e) {
|
|
@@ -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,25 +398,56 @@ 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");
|
|
406
|
-
for (let t of e.childNodes) t.nodeType
|
|
450
|
+
for (let t of e.childNodes) (t.nodeType !== 1 || t.tagName !== "INPUT") && a.appendChild(t.cloneNode(!0));
|
|
407
451
|
if (a.innerHTML = a.innerHTML.replaceAll("", ""), (!a.hasChildNodes() || !a.textContent.trim()) && (a.innerHTML = "", a.appendChild(document.createTextNode("\xA0"))), i.length > 0) {
|
|
408
452
|
let e = document.createElement("ul");
|
|
409
453
|
e.className = "an-checklist", i.forEach((t) => e.appendChild(t)), t.parentNode.insertBefore(e, t.nextSibling);
|
|
@@ -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,34 +574,35 @@ 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;
|
|
537
581
|
n.nodeType === 3 && (n = n.parentElement);
|
|
538
582
|
let r = n?.closest("ul, ol");
|
|
539
|
-
if (r)
|
|
540
|
-
if (r.
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
583
|
+
if (r) {
|
|
584
|
+
if (r.classList.contains("an-checklist")) {
|
|
585
|
+
if (r.parentNode) {
|
|
586
|
+
let t = Array.from(r.children), n = null;
|
|
587
|
+
if (t.forEach((e) => {
|
|
588
|
+
let t = document.createElement("p");
|
|
589
|
+
for (let n of e.childNodes) (n.nodeType !== 1 || n.tagName !== "INPUT") && t.appendChild(n.cloneNode(!0));
|
|
590
|
+
t.innerHTML = t.innerHTML.replaceAll("", "").replaceAll("", ""), (!t.hasChildNodes() || !t.textContent.trim()) && (t.innerHTML = "", t.appendChild(document.createTextNode("\xA0"))), r.before(t), n ||= t;
|
|
591
|
+
}), r.remove(), n) {
|
|
592
|
+
let t = document.createRange();
|
|
593
|
+
t.setStart(n.firstChild || n, 0), t.collapse(!0), e.removeAllRanges(), e.addRange(t);
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
} else {
|
|
597
|
+
let t = ct(r, "ul");
|
|
598
|
+
t.classList.add("an-checklist"), lt(t);
|
|
599
|
+
let n = t.querySelector("li");
|
|
600
|
+
if (n) {
|
|
547
601
|
let t = document.createRange();
|
|
548
|
-
t.
|
|
602
|
+
t.selectNodeContents(n), t.collapse(!1), e.removeAllRanges(), e.addRange(t);
|
|
549
603
|
}
|
|
550
604
|
}
|
|
551
605
|
} else {
|
|
552
|
-
let t = it(r, "ul");
|
|
553
|
-
t.classList.add("an-checklist"), at(t);
|
|
554
|
-
let n = t.querySelector("li");
|
|
555
|
-
if (n) {
|
|
556
|
-
let t = document.createRange();
|
|
557
|
-
t.selectNodeContents(n), t.collapse(!1), e.removeAllRanges(), e.addRange(t);
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
else {
|
|
561
606
|
let r = n?.closest("[contenteditable=\"true\"]");
|
|
562
607
|
if (t.collapsed) {
|
|
563
608
|
let t = /* @__PURE__ */ new Set([
|
|
@@ -623,7 +668,7 @@ function ot() {
|
|
|
623
668
|
}
|
|
624
669
|
}
|
|
625
670
|
}
|
|
626
|
-
function
|
|
671
|
+
function dt() {
|
|
627
672
|
let e = globalThis.getSelection();
|
|
628
673
|
if (!e?.rangeCount) return !1;
|
|
629
674
|
let t = e.getRangeAt(0).commonAncestorContainer;
|
|
@@ -641,24 +686,24 @@ function O(e, t, n, r, i, a) {
|
|
|
641
686
|
isDisabled: a
|
|
642
687
|
};
|
|
643
688
|
}
|
|
644
|
-
var
|
|
645
|
-
function
|
|
689
|
+
var ft = /* @__PURE__ */ new Map();
|
|
690
|
+
function pt(e) {
|
|
646
691
|
if (!e || typeof e.name != "string") {
|
|
647
692
|
console.warn("[AutumnNote] registerButton: btnDef must have a string `name` property.");
|
|
648
693
|
return;
|
|
649
694
|
}
|
|
650
|
-
|
|
695
|
+
ft.has(e.name) && console.warn(`[AutumnNote] registerButton: overwriting existing button "${e.name}".`), ft.set(e.name, e);
|
|
651
696
|
}
|
|
652
|
-
function
|
|
653
|
-
return
|
|
697
|
+
function mt(e) {
|
|
698
|
+
return ft.get(e);
|
|
654
699
|
}
|
|
655
|
-
var
|
|
700
|
+
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
701
|
if (document.queryCommandState("underline")) return !0;
|
|
657
702
|
let e = globalThis.getSelection();
|
|
658
703
|
if (!e?.rangeCount) return !1;
|
|
659
704
|
let t = e.getRangeAt(0).startContainer;
|
|
660
705
|
return t.nodeType === 3 && (t = t.parentElement), !!t?.closest("u");
|
|
661
|
-
}),
|
|
706
|
+
}), 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
707
|
name: "table",
|
|
663
708
|
type: "grid",
|
|
664
709
|
icon: "table",
|
|
@@ -666,7 +711,7 @@ var dt = O("bold", "bold", "Bold (Ctrl+B)", () => Ne(), () => document.queryComm
|
|
|
666
711
|
action: (e, t, n) => {
|
|
667
712
|
e.invoke("editor.insertTable", n, t), e.invoke("editor.afterCommand");
|
|
668
713
|
}
|
|
669
|
-
},
|
|
714
|
+
}, Rt = {
|
|
670
715
|
name: "fontSize",
|
|
671
716
|
type: "select",
|
|
672
717
|
tooltip: "Font Size",
|
|
@@ -689,7 +734,7 @@ var dt = O("bold", "bold", "Bold (Ctrl+B)", () => Ne(), () => document.queryComm
|
|
|
689
734
|
"48px",
|
|
690
735
|
"72px"
|
|
691
736
|
],
|
|
692
|
-
action: (e, t) =>
|
|
737
|
+
action: (e, t) => We(t, e.layoutInfo.editable),
|
|
693
738
|
getValue: (e) => {
|
|
694
739
|
try {
|
|
695
740
|
let t = globalThis.getSelection();
|
|
@@ -705,14 +750,14 @@ var dt = O("bold", "bold", "Bold (Ctrl+B)", () => Ne(), () => document.queryComm
|
|
|
705
750
|
return "";
|
|
706
751
|
}
|
|
707
752
|
}
|
|
708
|
-
},
|
|
753
|
+
}, zt = O("removeFormat", "remove-format", "Remove Format", () => D("removeFormat")), Bt = O("direction", "direction", "Toggle Text Direction (LTR / RTL)", (e) => {
|
|
709
754
|
let t = e.layoutInfo.editable, n = (t.getAttribute("dir") || "ltr") === "ltr" ? "rtl" : "ltr";
|
|
710
755
|
t.setAttribute("dir", n), t.style.textAlign = n === "rtl" ? "right" : "left", e.invoke("editor.afterCommand");
|
|
711
|
-
}),
|
|
756
|
+
}), Vt = {
|
|
712
757
|
name: "fontFamily",
|
|
713
758
|
type: "select",
|
|
714
759
|
tooltip: "Font Family",
|
|
715
|
-
action: (e, t) =>
|
|
760
|
+
action: (e, t) => Ue(t),
|
|
716
761
|
getValue: () => {
|
|
717
762
|
try {
|
|
718
763
|
return document.queryCommandValue("fontName") || "";
|
|
@@ -720,7 +765,7 @@ var dt = O("bold", "bold", "Bold (Ctrl+B)", () => Ne(), () => document.queryComm
|
|
|
720
765
|
return "";
|
|
721
766
|
}
|
|
722
767
|
}
|
|
723
|
-
},
|
|
768
|
+
}, Ht = {
|
|
724
769
|
name: "paragraphStyle",
|
|
725
770
|
type: "select",
|
|
726
771
|
tooltip: "Paragraph Style",
|
|
@@ -764,7 +809,7 @@ var dt = O("bold", "bold", "Bold (Ctrl+B)", () => Ne(), () => document.queryComm
|
|
|
764
809
|
label: "Code"
|
|
765
810
|
}
|
|
766
811
|
],
|
|
767
|
-
action: (e, t) =>
|
|
812
|
+
action: (e, t) => Ge(t),
|
|
768
813
|
getValue: () => {
|
|
769
814
|
try {
|
|
770
815
|
let e = document.queryCommandValue("formatBlock").toLowerCase().replace(/[<>]/g, "");
|
|
@@ -773,7 +818,7 @@ var dt = O("bold", "bold", "Bold (Ctrl+B)", () => Ne(), () => document.queryComm
|
|
|
773
818
|
return "";
|
|
774
819
|
}
|
|
775
820
|
}
|
|
776
|
-
},
|
|
821
|
+
}, Ut = {
|
|
777
822
|
name: "lineHeight",
|
|
778
823
|
type: "select",
|
|
779
824
|
tooltip: "Line Height",
|
|
@@ -788,7 +833,7 @@ var dt = O("bold", "bold", "Bold (Ctrl+B)", () => Ne(), () => document.queryComm
|
|
|
788
833
|
"2.5",
|
|
789
834
|
"3.0"
|
|
790
835
|
],
|
|
791
|
-
action: (e, t) =>
|
|
836
|
+
action: (e, t) => at(t),
|
|
792
837
|
getValue: () => {
|
|
793
838
|
try {
|
|
794
839
|
let e = globalThis.getSelection();
|
|
@@ -814,108 +859,108 @@ var dt = O("bold", "bold", "Bold (Ctrl+B)", () => Ne(), () => document.queryComm
|
|
|
814
859
|
return "";
|
|
815
860
|
}
|
|
816
861
|
}
|
|
817
|
-
},
|
|
862
|
+
}, 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
863
|
name: "foreColor",
|
|
819
864
|
type: "colorpicker",
|
|
820
865
|
icon: "foreColor",
|
|
821
866
|
tooltip: "Text Color",
|
|
822
867
|
defaultColor: "#e11d48",
|
|
823
|
-
action: (e, t) =>
|
|
824
|
-
},
|
|
868
|
+
action: (e, t) => Ve(t)
|
|
869
|
+
}, $t = {
|
|
825
870
|
name: "backColor",
|
|
826
871
|
type: "colorpicker",
|
|
827
872
|
icon: "backColor",
|
|
828
873
|
tooltip: "Highlight Color",
|
|
829
874
|
defaultColor: "#fbbf24",
|
|
830
|
-
action: (e, t) =>
|
|
831
|
-
},
|
|
875
|
+
action: (e, t) => He(t)
|
|
876
|
+
}, en = [
|
|
832
877
|
[
|
|
878
|
+
Ht,
|
|
879
|
+
Vt,
|
|
833
880
|
Rt,
|
|
834
|
-
|
|
835
|
-
Pt,
|
|
836
|
-
zt
|
|
837
|
-
],
|
|
838
|
-
[Tt, Et],
|
|
839
|
-
[
|
|
840
|
-
dt,
|
|
841
|
-
ft,
|
|
842
|
-
pt,
|
|
843
|
-
mt,
|
|
844
|
-
Gt
|
|
881
|
+
Ut
|
|
845
882
|
],
|
|
846
|
-
[
|
|
847
|
-
[Jt, Yt],
|
|
883
|
+
[kt, At],
|
|
848
884
|
[
|
|
885
|
+
ht,
|
|
886
|
+
gt,
|
|
849
887
|
_t,
|
|
850
888
|
vt,
|
|
851
|
-
|
|
852
|
-
bt
|
|
889
|
+
Yt
|
|
853
890
|
],
|
|
891
|
+
[yt, bt],
|
|
892
|
+
[Qt, $t],
|
|
854
893
|
[
|
|
855
894
|
xt,
|
|
856
895
|
St,
|
|
857
|
-
Kt,
|
|
858
896
|
Ct,
|
|
859
897
|
wt
|
|
860
898
|
],
|
|
861
899
|
[
|
|
900
|
+
Tt,
|
|
901
|
+
Et,
|
|
902
|
+
Xt,
|
|
862
903
|
Dt,
|
|
863
|
-
Ot
|
|
864
|
-
kt,
|
|
865
|
-
At,
|
|
866
|
-
Nt,
|
|
867
|
-
jt,
|
|
868
|
-
Mt
|
|
904
|
+
Ot
|
|
869
905
|
],
|
|
870
906
|
[
|
|
907
|
+
jt,
|
|
908
|
+
Mt,
|
|
909
|
+
Nt,
|
|
910
|
+
Pt,
|
|
911
|
+
Lt,
|
|
871
912
|
Ft,
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
913
|
+
It
|
|
914
|
+
],
|
|
915
|
+
[
|
|
916
|
+
zt,
|
|
917
|
+
Wt,
|
|
918
|
+
Gt,
|
|
875
919
|
qt,
|
|
876
|
-
|
|
920
|
+
Zt,
|
|
921
|
+
Kt
|
|
877
922
|
]
|
|
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:
|
|
923
|
+
], tn = {
|
|
924
|
+
boldBtn: ht,
|
|
925
|
+
italicBtn: gt,
|
|
926
|
+
underlineBtn: _t,
|
|
927
|
+
strikeBtn: vt,
|
|
928
|
+
superscriptBtn: yt,
|
|
929
|
+
subscriptBtn: bt,
|
|
930
|
+
alignLeftBtn: xt,
|
|
931
|
+
alignCenterBtn: St,
|
|
932
|
+
alignRightBtn: Ct,
|
|
933
|
+
alignJustifyBtn: wt,
|
|
934
|
+
ulBtn: Tt,
|
|
935
|
+
olBtn: Et,
|
|
936
|
+
indentBtn: Dt,
|
|
937
|
+
outdentBtn: Ot,
|
|
938
|
+
undoBtn: kt,
|
|
939
|
+
redoBtn: At,
|
|
940
|
+
hrBtn: jt,
|
|
941
|
+
linkBtn: Mt,
|
|
942
|
+
imageBtn: Nt,
|
|
943
|
+
videoBtn: Pt,
|
|
944
|
+
emojiBtn: Ft,
|
|
945
|
+
iconBtn: It,
|
|
946
|
+
tableBtn: Lt,
|
|
947
|
+
fontSizeBtn: Rt,
|
|
948
|
+
removeFormatBtn: zt,
|
|
949
|
+
directionBtn: Bt,
|
|
950
|
+
fontFamilyBtn: Vt,
|
|
951
|
+
paragraphStyleBtn: Ht,
|
|
952
|
+
lineHeightBtn: Ut,
|
|
953
|
+
codeviewBtn: Wt,
|
|
954
|
+
fullscreenBtn: Gt,
|
|
955
|
+
shortcutsBtn: Kt,
|
|
956
|
+
findBtn: qt,
|
|
957
|
+
findReplaceBtn: Jt,
|
|
958
|
+
inlineCodeBtn: Yt,
|
|
959
|
+
checklistBtn: Xt,
|
|
960
|
+
printBtn: Zt,
|
|
961
|
+
foreColorBtn: Qt,
|
|
962
|
+
backColorBtn: $t,
|
|
963
|
+
defaultToolbar: en
|
|
919
964
|
}, k = {
|
|
920
965
|
placeholder: "",
|
|
921
966
|
height: 200,
|
|
@@ -923,7 +968,7 @@ var dt = O("bold", "bold", "Bold (Ctrl+B)", () => Ne(), () => document.queryComm
|
|
|
923
968
|
maxHeight: 0,
|
|
924
969
|
focus: !1,
|
|
925
970
|
resizable: !0,
|
|
926
|
-
toolbar:
|
|
971
|
+
toolbar: en,
|
|
927
972
|
useBootstrap: !1,
|
|
928
973
|
toolbarButtonClass: "btn btn-sm btn-light",
|
|
929
974
|
useFontAwesome: !0,
|
|
@@ -947,9 +992,12 @@ var dt = O("bold", "bold", "Bold (Ctrl+B)", () => Ne(), () => document.queryComm
|
|
|
947
992
|
theme: "light",
|
|
948
993
|
codeHighlight: !0,
|
|
949
994
|
codeHighlightCDN: "https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0",
|
|
995
|
+
cspNonce: "",
|
|
996
|
+
externalAssetCrossOrigin: "anonymous",
|
|
997
|
+
externalAssetReferrerPolicy: "no-referrer",
|
|
950
998
|
markdownPaste: !0,
|
|
951
999
|
historyLimit: 100,
|
|
952
|
-
historyMaxBytes:
|
|
1000
|
+
historyMaxBytes: 10485760,
|
|
953
1001
|
defaultFontFamily: "Arial",
|
|
954
1002
|
defaultFontSize: "14px",
|
|
955
1003
|
fontFamilies: [
|
|
@@ -994,7 +1042,7 @@ var dt = O("bold", "bold", "Bold (Ctrl+B)", () => Ne(), () => document.queryComm
|
|
|
994
1042
|
collaborationAdapter: null,
|
|
995
1043
|
imageProcessor: null,
|
|
996
1044
|
blockIds: !1,
|
|
997
|
-
maxPasteSize:
|
|
1045
|
+
maxPasteSize: 5242880,
|
|
998
1046
|
minImageSize: 20,
|
|
999
1047
|
bubbleToolbar: !1,
|
|
1000
1048
|
bubbleToolbarItems: [
|
|
@@ -1374,23 +1422,23 @@ var dt = O("bold", "bold", "Bold (Ctrl+B)", () => Ne(), () => document.queryComm
|
|
|
1374
1422
|
table: "Table",
|
|
1375
1423
|
image: "Image"
|
|
1376
1424
|
}
|
|
1377
|
-
},
|
|
1378
|
-
function
|
|
1425
|
+
}, nn = { en: A };
|
|
1426
|
+
function rn(e, t) {
|
|
1379
1427
|
if (typeof e != "string" || !e) throw TypeError("[AutumnNote] registerLocale: code must be a non-empty string.");
|
|
1380
1428
|
if (!t || typeof t != "object") throw TypeError(`[AutumnNote] registerLocale: locale for "${e}" must be an object.`);
|
|
1381
|
-
|
|
1429
|
+
nn[e] = t;
|
|
1382
1430
|
}
|
|
1383
|
-
function
|
|
1431
|
+
function an(e) {
|
|
1384
1432
|
if (!e || e === "en") return A;
|
|
1385
1433
|
if (typeof e == "string") {
|
|
1386
|
-
let t =
|
|
1434
|
+
let t = nn[e];
|
|
1387
1435
|
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
1436
|
}
|
|
1389
1437
|
return typeof e == "object" ? c(c({}, A), e) : A;
|
|
1390
1438
|
}
|
|
1391
1439
|
//#endregion
|
|
1392
1440
|
//#region src/js/core/sanitise.js
|
|
1393
|
-
var
|
|
1441
|
+
var on = [
|
|
1394
1442
|
"script",
|
|
1395
1443
|
"style",
|
|
1396
1444
|
"iframe",
|
|
@@ -1413,7 +1461,7 @@ var tn = [
|
|
|
1413
1461
|
"mglyph",
|
|
1414
1462
|
"malignmark",
|
|
1415
1463
|
"annotation-xml"
|
|
1416
|
-
],
|
|
1464
|
+
], sn = /* @__PURE__ */ new Set(["button"]), cn = [
|
|
1417
1465
|
"href",
|
|
1418
1466
|
"src",
|
|
1419
1467
|
"action",
|
|
@@ -1422,11 +1470,11 @@ var tn = [
|
|
|
1422
1470
|
"poster",
|
|
1423
1471
|
"background",
|
|
1424
1472
|
"srcset"
|
|
1425
|
-
],
|
|
1473
|
+
], ln = /* @__PURE__ */ new Set([
|
|
1426
1474
|
"poster",
|
|
1427
1475
|
"background",
|
|
1428
1476
|
"srcset"
|
|
1429
|
-
]),
|
|
1477
|
+
]), un = /* @__PURE__ */ new Set(["ping"]), dn = /* @__PURE__ */ new Set([
|
|
1430
1478
|
"color",
|
|
1431
1479
|
"background-color",
|
|
1432
1480
|
"font-size",
|
|
@@ -1442,31 +1490,31 @@ var tn = [
|
|
|
1442
1490
|
"border-color",
|
|
1443
1491
|
"padding",
|
|
1444
1492
|
"white-space"
|
|
1445
|
-
]),
|
|
1493
|
+
]), fn = /url\s*\(|image-set\s*\(|src\s*\(|expression\s*\(|@import|javascript:|vbscript:|behavior\s*:|-moz-binding/i, pn = /* @__PURE__ */ new Set([
|
|
1446
1494
|
"www.youtube.com",
|
|
1447
1495
|
"youtube.com",
|
|
1448
1496
|
"m.youtube.com",
|
|
1449
1497
|
"www.youtube-nocookie.com",
|
|
1450
1498
|
"youtube-nocookie.com",
|
|
1451
1499
|
"player.vimeo.com"
|
|
1452
|
-
]),
|
|
1500
|
+
]), mn = /* @__PURE__ */ new Set([
|
|
1453
1501
|
"http:",
|
|
1454
1502
|
"https:",
|
|
1455
1503
|
"mailto:",
|
|
1456
1504
|
"tel:"
|
|
1457
|
-
]),
|
|
1505
|
+
]), hn = /* @__PURE__ */ new Set([
|
|
1458
1506
|
"http:",
|
|
1459
1507
|
"https:",
|
|
1460
1508
|
"blob:"
|
|
1461
|
-
]),
|
|
1509
|
+
]), gn = /^data:image\/(?:png|jpe?g|gif|webp|avif|bmp);base64,[a-z0-9+/=\s]+$/i, _n = "https://autumnnote.invalid/";
|
|
1462
1510
|
function j(e, t) {
|
|
1463
|
-
return
|
|
1511
|
+
return vn(e, t).innerHTML;
|
|
1464
1512
|
}
|
|
1465
|
-
function
|
|
1466
|
-
let n = new DOMParser().parseFromString(`<body>${e || ""}</body>`, "text/html"), r = Array.from(n.querySelectorAll("*")), i = new Set(t ?
|
|
1513
|
+
function vn(e, { allowIframes: t = !1 } = {}) {
|
|
1514
|
+
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
1515
|
for (let e of r) {
|
|
1468
1516
|
let t = e.tagName.toLowerCase();
|
|
1469
|
-
if (
|
|
1517
|
+
if (sn.has(t)) {
|
|
1470
1518
|
e.replaceWith(...e.childNodes);
|
|
1471
1519
|
continue;
|
|
1472
1520
|
}
|
|
@@ -1476,7 +1524,7 @@ function mn(e, { allowIframes: t = !1 } = {}) {
|
|
|
1476
1524
|
}
|
|
1477
1525
|
if (t === "iframe") {
|
|
1478
1526
|
let t = e.getAttribute("src");
|
|
1479
|
-
if (!t || !
|
|
1527
|
+
if (!t || !xn(t)) {
|
|
1480
1528
|
e.remove();
|
|
1481
1529
|
continue;
|
|
1482
1530
|
}
|
|
@@ -1487,22 +1535,22 @@ function mn(e, { allowIframes: t = !1 } = {}) {
|
|
|
1487
1535
|
continue;
|
|
1488
1536
|
}
|
|
1489
1537
|
if (t.name === "style") {
|
|
1490
|
-
let n =
|
|
1538
|
+
let n = yn(t.value);
|
|
1491
1539
|
n ? e.setAttribute("style", n) : e.removeAttribute("style");
|
|
1492
1540
|
continue;
|
|
1493
1541
|
}
|
|
1494
|
-
if (
|
|
1542
|
+
if (un.has(t.name)) {
|
|
1495
1543
|
e.removeAttribute(t.name);
|
|
1496
1544
|
continue;
|
|
1497
1545
|
}
|
|
1498
|
-
if (
|
|
1499
|
-
let n = t.value.trim(), r =
|
|
1546
|
+
if (cn.includes(t.name)) {
|
|
1547
|
+
let n = t.value.trim(), r = ln.has(t.name) || t.name === "src" && [
|
|
1500
1548
|
"IMG",
|
|
1501
1549
|
"VIDEO",
|
|
1502
1550
|
"AUDIO",
|
|
1503
1551
|
"SOURCE"
|
|
1504
1552
|
].includes(e.tagName), i = e.tagName === "IMG";
|
|
1505
|
-
if (!(t.name === "srcset" ?
|
|
1553
|
+
if (!(t.name === "srcset" ? bn(n, { allowData: i }) : Sn(n, {
|
|
1506
1554
|
media: r,
|
|
1507
1555
|
allowData: i
|
|
1508
1556
|
}))) {
|
|
@@ -1515,70 +1563,72 @@ function mn(e, { allowIframes: t = !1 } = {}) {
|
|
|
1515
1563
|
e.removeAttribute(t.name);
|
|
1516
1564
|
continue;
|
|
1517
1565
|
}
|
|
1518
|
-
t.name === "src" && !
|
|
1566
|
+
t.name === "src" && !xn(t.value) && e.removeAttribute(t.name);
|
|
1519
1567
|
}
|
|
1520
1568
|
}
|
|
1521
|
-
if (t === "a" && e.getAttribute("target") === "_blank" && e.setAttribute("rel", "noopener noreferrer"), t === "input")
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1569
|
+
if (t === "a" && e.getAttribute("target") === "_blank" && e.setAttribute("rel", "noopener noreferrer"), t === "input") {
|
|
1570
|
+
if (e.closest("ul.an-checklist") === null || e.closest("li") === null || e.getAttribute("type") !== "checkbox") e.remove();
|
|
1571
|
+
else for (let t of Array.from(e.attributes)) [
|
|
1572
|
+
"type",
|
|
1573
|
+
"checked",
|
|
1574
|
+
"contenteditable"
|
|
1575
|
+
].includes(t.name) || e.removeAttribute(t.name);
|
|
1576
|
+
}
|
|
1527
1577
|
}
|
|
1528
1578
|
return n.body;
|
|
1529
1579
|
}
|
|
1530
|
-
function
|
|
1580
|
+
function yn(e) {
|
|
1531
1581
|
let t = [];
|
|
1532
1582
|
for (let n of (e || "").split(";")) {
|
|
1533
1583
|
let e = n.indexOf(":");
|
|
1534
1584
|
if (e === -1) continue;
|
|
1535
1585
|
let r = n.slice(0, e).trim().toLowerCase(), i = n.slice(e + 1).trim();
|
|
1536
|
-
!r || !i ||
|
|
1586
|
+
!r || !i || dn.has(r) && (fn.test(i) || t.push(`${r}: ${i}`));
|
|
1537
1587
|
}
|
|
1538
1588
|
return t.join("; ");
|
|
1539
1589
|
}
|
|
1540
|
-
function
|
|
1590
|
+
function bn(e, { allowData: t = !1 } = {}) {
|
|
1541
1591
|
let n = (e || "").trim().split(/\s+/).filter(Boolean);
|
|
1542
1592
|
for (let e of n) {
|
|
1543
1593
|
if (/^[\d.]+[xw],?$/i.test(e)) continue;
|
|
1544
1594
|
let n = e.replace(/,+$/, "");
|
|
1545
|
-
if (n && !
|
|
1595
|
+
if (n && !Sn(n, {
|
|
1546
1596
|
media: !0,
|
|
1547
1597
|
allowData: t
|
|
1548
1598
|
})) return !1;
|
|
1549
1599
|
}
|
|
1550
1600
|
return !0;
|
|
1551
1601
|
}
|
|
1552
|
-
function
|
|
1602
|
+
function xn(e) {
|
|
1553
1603
|
let t = (e || "").trim();
|
|
1554
1604
|
if (!t || t.startsWith("//") || t.startsWith("/")) return !1;
|
|
1555
1605
|
try {
|
|
1556
1606
|
let e = new URL(t);
|
|
1557
|
-
return e.protocol === "https:" &&
|
|
1607
|
+
return e.protocol === "https:" && pn.has(e.hostname.toLowerCase());
|
|
1558
1608
|
} catch {
|
|
1559
1609
|
return !1;
|
|
1560
1610
|
}
|
|
1561
1611
|
}
|
|
1562
1612
|
function M(e, { allowData: t = !1, media: n = t } = {}) {
|
|
1563
1613
|
let r = (e || "").trim();
|
|
1564
|
-
return !r && e == null ? null :
|
|
1614
|
+
return !r && e == null ? null : Sn(r, {
|
|
1565
1615
|
media: n,
|
|
1566
1616
|
allowData: t
|
|
1567
1617
|
}) ? e : null;
|
|
1568
1618
|
}
|
|
1569
|
-
function
|
|
1619
|
+
function Sn(e, { media: t = !1, allowData: n = !1 } = {}) {
|
|
1570
1620
|
let r = (e || "").trim();
|
|
1571
|
-
if (!r || n &&
|
|
1621
|
+
if (!r || n && gn.test(r)) return !0;
|
|
1572
1622
|
try {
|
|
1573
|
-
let e = new URL(r,
|
|
1574
|
-
return (t ?
|
|
1623
|
+
let e = new URL(r, _n);
|
|
1624
|
+
return (t ? hn : mn).has(e.protocol);
|
|
1575
1625
|
} catch {
|
|
1576
1626
|
return !1;
|
|
1577
1627
|
}
|
|
1578
1628
|
}
|
|
1579
1629
|
//#endregion
|
|
1580
1630
|
//#region src/js/renderer.js
|
|
1581
|
-
function
|
|
1631
|
+
function Cn(e, t) {
|
|
1582
1632
|
let n = w("div", { class: "an-container" }), r = w("div", {
|
|
1583
1633
|
class: "an-editable",
|
|
1584
1634
|
contenteditable: t.readOnly ? "false" : "true",
|
|
@@ -1601,16 +1651,16 @@ function yn(e, t) {
|
|
|
1601
1651
|
}
|
|
1602
1652
|
//#endregion
|
|
1603
1653
|
//#region src/js/Context.js
|
|
1604
|
-
var
|
|
1605
|
-
function
|
|
1606
|
-
|
|
1654
|
+
var wn = /* @__PURE__ */ new Map(), Tn = [];
|
|
1655
|
+
function En(e) {
|
|
1656
|
+
Tn = Array.isArray(e) ? e : [];
|
|
1607
1657
|
}
|
|
1608
|
-
var
|
|
1658
|
+
var Dn = /* @__PURE__ */ new Map(), On = class {
|
|
1609
1659
|
constructor(e, t = {}) {
|
|
1610
|
-
this.targetEl = e, this.options = c(k, t), this.locale =
|
|
1660
|
+
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
1661
|
}
|
|
1612
1662
|
initialize() {
|
|
1613
|
-
let { container: e, editable: t } =
|
|
1663
|
+
let { container: e, editable: t } = Cn(this.targetEl, this.options);
|
|
1614
1664
|
this.layoutInfo.container = e, this.layoutInfo.editable = t, this._registerModules();
|
|
1615
1665
|
let n = this._modules.get("toolbar");
|
|
1616
1666
|
n?.el && (e.insertBefore(n.el, t), this.layoutInfo.toolbar = n.el);
|
|
@@ -1622,19 +1672,21 @@ var Cn = /* @__PURE__ */ new Map(), wn = class {
|
|
|
1622
1672
|
let n = new t(this);
|
|
1623
1673
|
this._modules.set(e, n), n.initialize();
|
|
1624
1674
|
};
|
|
1625
|
-
for (let { name: t, Class: n, enabled: r } of
|
|
1626
|
-
if (
|
|
1675
|
+
for (let { name: t, Class: n, enabled: r } of Tn) typeof r == "function" && !r(this.options) || e(t, n);
|
|
1676
|
+
if (wn.size > 0) for (let [t, n] of wn) e(t, n);
|
|
1627
1677
|
}
|
|
1628
1678
|
_syncOptionalModules() {
|
|
1629
|
-
for (let { name: e, Class: t, enabled: n } of
|
|
1679
|
+
for (let { name: e, Class: t, enabled: n } of Tn) {
|
|
1630
1680
|
if (typeof n != "function") continue;
|
|
1631
1681
|
let r = n(this.options);
|
|
1632
|
-
if (r !== this._modules.has(e))
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1682
|
+
if (r !== this._modules.has(e)) {
|
|
1683
|
+
if (r) {
|
|
1684
|
+
let n = new t(this);
|
|
1685
|
+
this._modules.set(e, n), n.initialize();
|
|
1686
|
+
} else {
|
|
1687
|
+
let t = this._modules.get(e);
|
|
1688
|
+
typeof t?.destroy == "function" && t.destroy(), this._modules.delete(e);
|
|
1689
|
+
}
|
|
1638
1690
|
}
|
|
1639
1691
|
}
|
|
1640
1692
|
}
|
|
@@ -1649,7 +1701,7 @@ var Cn = /* @__PURE__ */ new Map(), wn = class {
|
|
|
1649
1701
|
return n >= 0 ? t[n] = e : t.push(e), this.invoke("slashMenu.refresh"), this;
|
|
1650
1702
|
}
|
|
1651
1703
|
use(e, t = {}) {
|
|
1652
|
-
return Array.isArray(e.buttons) && e.buttons.forEach((e) =>
|
|
1704
|
+
return Array.isArray(e.buttons) && e.buttons.forEach((e) => pt(e)), this._installPlugin(e, t), this;
|
|
1653
1705
|
}
|
|
1654
1706
|
getPlugin(e) {
|
|
1655
1707
|
return this._plugins.get(e)?.publicApi ?? null;
|
|
@@ -1671,7 +1723,7 @@ var Cn = /* @__PURE__ */ new Map(), wn = class {
|
|
|
1671
1723
|
});
|
|
1672
1724
|
}
|
|
1673
1725
|
_applyGlobalPlugins() {
|
|
1674
|
-
if (
|
|
1726
|
+
if (Dn.size !== 0) for (let { plugin: e, options: t } of Dn.values()) this._installPlugin(e, t);
|
|
1675
1727
|
}
|
|
1676
1728
|
_bindEditorEvents(e) {
|
|
1677
1729
|
let t = E(e, "input", () => this._syncToTarget()), n = E(e, "focus", () => {
|
|
@@ -1917,15 +1969,23 @@ var Cn = /* @__PURE__ */ new Map(), wn = class {
|
|
|
1917
1969
|
} catch {}
|
|
1918
1970
|
this._plugins.clear(), this._disposers.forEach((e) => e()), this._disposers = [];
|
|
1919
1971
|
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(() => {
|
|
1972
|
+
return t?.parentNode && (this.targetEl.style.display = "", t.remove()), n && !document.querySelector(".an-container.an-theme-dark") && document.body.classList.remove("an-theme-dark"), r && !document.querySelector(".an-container.an-theme-auto") && document.body.classList.remove("an-theme-auto"), typeof this.options.onDestroy == "function" && this.options.onDestroy(this), this._alive = !1, this._releaseInstance?.(), this._releaseInstance = null, this._destroyPromise = Promise.resolve(e).then(() => {
|
|
1921
1973
|
this._listeners.clear();
|
|
1922
1974
|
}), this._destroyPromise;
|
|
1923
1975
|
}
|
|
1924
1976
|
_syncToTarget(e) {
|
|
1925
1977
|
(this.targetEl.tagName === "TEXTAREA" || this.targetEl.tagName === "INPUT") && (this.targetEl.value = typeof e == "string" ? e : this.getHTML());
|
|
1926
1978
|
}
|
|
1927
|
-
}
|
|
1928
|
-
|
|
1979
|
+
};
|
|
1980
|
+
//#endregion
|
|
1981
|
+
//#region src/js/editing/History.js
|
|
1982
|
+
function kn(e, t) {
|
|
1983
|
+
let n = Math.min(e.length, t.length), r = 0;
|
|
1984
|
+
for (; r < n && e.charCodeAt(r) === t.charCodeAt(r);) r++;
|
|
1985
|
+
return r;
|
|
1986
|
+
}
|
|
1987
|
+
var An = class {
|
|
1988
|
+
constructor(e, t = 100, n = 10485760) {
|
|
1929
1989
|
this.editable = e, this._limit = t, this._maxBytes = n, this._bytes = 0, this.stack = [], this.stackOffset = -1, this._savePoint();
|
|
1930
1990
|
}
|
|
1931
1991
|
_entrySize(e) {
|
|
@@ -1946,12 +2006,12 @@ var Cn = /* @__PURE__ */ new Map(), wn = class {
|
|
|
1946
2006
|
} : null;
|
|
1947
2007
|
}
|
|
1948
2008
|
_charOffset(e, t) {
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
2009
|
+
try {
|
|
2010
|
+
let n = document.createRange();
|
|
2011
|
+
return n.selectNodeContents(this.editable), n.setEnd(e, t), n.toString().length;
|
|
2012
|
+
} catch {
|
|
2013
|
+
return 0;
|
|
1953
2014
|
}
|
|
1954
|
-
return 0;
|
|
1955
2015
|
}
|
|
1956
2016
|
_restoreSelection(e) {
|
|
1957
2017
|
if (!e) return;
|
|
@@ -1998,7 +2058,18 @@ var Cn = /* @__PURE__ */ new Map(), wn = class {
|
|
|
1998
2058
|
this.stackOffset = this.stack.length - 1;
|
|
1999
2059
|
}
|
|
2000
2060
|
_restore(e) {
|
|
2001
|
-
|
|
2061
|
+
if (!e) return;
|
|
2062
|
+
let t = this.editable.textContent || "";
|
|
2063
|
+
this.editable.innerHTML = this._detokenizeImages(e);
|
|
2064
|
+
let n = e.sel;
|
|
2065
|
+
if (!n) {
|
|
2066
|
+
let e = kn(t, this.editable.textContent || "");
|
|
2067
|
+
n = {
|
|
2068
|
+
start: e,
|
|
2069
|
+
end: e
|
|
2070
|
+
};
|
|
2071
|
+
}
|
|
2072
|
+
this._restoreSelection(n);
|
|
2002
2073
|
}
|
|
2003
2074
|
_tokenizeImages(e) {
|
|
2004
2075
|
if (!e.includes("data:")) return {
|
|
@@ -2045,7 +2116,7 @@ var Cn = /* @__PURE__ */ new Map(), wn = class {
|
|
|
2045
2116
|
};
|
|
2046
2117
|
//#endregion
|
|
2047
2118
|
//#region src/js/editing/Table.js
|
|
2048
|
-
function
|
|
2119
|
+
function jn(e, t, n = {}) {
|
|
2049
2120
|
let { headerRow: r = !1 } = n, i = w("table", { class: "an-table" });
|
|
2050
2121
|
if (r && t > 0) {
|
|
2051
2122
|
let t = w("thead"), n = w("tr");
|
|
@@ -2067,9 +2138,9 @@ function En(e, t, n = {}) {
|
|
|
2067
2138
|
}
|
|
2068
2139
|
return i;
|
|
2069
2140
|
}
|
|
2070
|
-
function
|
|
2141
|
+
function Mn(e, t, n = {}) {
|
|
2071
2142
|
if (e <= 0 || t <= 0) return;
|
|
2072
|
-
let r =
|
|
2143
|
+
let r = jn(e, t, n), i = globalThis.getSelection();
|
|
2073
2144
|
if (!i || i.rangeCount === 0) return;
|
|
2074
2145
|
let a = i.getRangeAt(0);
|
|
2075
2146
|
try {
|
|
@@ -2157,8 +2228,28 @@ function F(e, t) {
|
|
|
2157
2228
|
}
|
|
2158
2229
|
//#endregion
|
|
2159
2230
|
//#region src/js/editing/Typing.js
|
|
2160
|
-
var
|
|
2161
|
-
function
|
|
2231
|
+
var Nn = /\bfa-/, I = (e) => !!(e?.nodeName === "I" && Nn.test(e.className || "")), Pn = (e) => !(e?.nodeType !== Node.TEXT_NODE || e.textContent !== "" && e.textContent !== "");
|
|
2232
|
+
function Fn(e, t, n) {
|
|
2233
|
+
let r = (e?.nodeType === Node.ELEMENT_NODE ? e : e?.parentElement ?? null)?.closest("td, th") ?? null;
|
|
2234
|
+
if (!r || !t.contains(r)) return !1;
|
|
2235
|
+
let i = r.closest("table");
|
|
2236
|
+
if (!i || !t.contains(i)) return !1;
|
|
2237
|
+
let a = Array.from(i.querySelectorAll("td, th")), o = a[a.indexOf(r) + (n ? -1 : 1)];
|
|
2238
|
+
if (o) return fe(o), !0;
|
|
2239
|
+
if (n) return !0;
|
|
2240
|
+
let s = In(r.closest("tr"))?.firstElementChild ?? null;
|
|
2241
|
+
return s && fe(s), !0;
|
|
2242
|
+
}
|
|
2243
|
+
function In(e) {
|
|
2244
|
+
if (!e?.parentNode) return null;
|
|
2245
|
+
let t = document.createElement("tr");
|
|
2246
|
+
for (let n of e.cells) {
|
|
2247
|
+
let e = document.createElement("td");
|
|
2248
|
+
e.appendChild(document.createElement("br")), n.hasAttribute("style") && e.setAttribute("style", n.getAttribute("style")), t.appendChild(e);
|
|
2249
|
+
}
|
|
2250
|
+
return e.parentNode.insertBefore(t, e.nextSibling), t;
|
|
2251
|
+
}
|
|
2252
|
+
function Ln(e, t) {
|
|
2162
2253
|
try {
|
|
2163
2254
|
let n = document.createRange();
|
|
2164
2255
|
return n.setStart(e.startContainer, e.startOffset), n.setEnd(t, t.childNodes.length), n.extractContents();
|
|
@@ -2166,7 +2257,7 @@ function An(e, t) {
|
|
|
2166
2257
|
return document.createDocumentFragment();
|
|
2167
2258
|
}
|
|
2168
2259
|
}
|
|
2169
|
-
function
|
|
2260
|
+
function Rn(e, t, n = {}) {
|
|
2170
2261
|
let r = (e) => {
|
|
2171
2262
|
let t = globalThis.getSelection();
|
|
2172
2263
|
if (!t) return !1;
|
|
@@ -2200,7 +2291,7 @@ function jn(e, t, n = {}) {
|
|
|
2200
2291
|
if (i.nodeType === Node.TEXT_NODE) {
|
|
2201
2292
|
let t = i;
|
|
2202
2293
|
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 &&
|
|
2294
|
+
if (a && n.startOffset === 0 && Pn(t.previousSibling) && I(t.previousSibling.previousSibling)) return e.preventDefault(), r((e) => e.setStartBefore(t.previousSibling.previousSibling));
|
|
2204
2295
|
if (!a && n.startOffset === t.textContent.length && I(t.nextSibling)) {
|
|
2205
2296
|
let n = t.nextSibling, i = n.nextSibling;
|
|
2206
2297
|
if (e.preventDefault(), i?.nodeType === Node.TEXT_NODE) {
|
|
@@ -2209,7 +2300,7 @@ function jn(e, t, n = {}) {
|
|
|
2209
2300
|
}
|
|
2210
2301
|
return r((e) => e.setStartAfter(n));
|
|
2211
2302
|
}
|
|
2212
|
-
if (!a && n.startOffset === t.textContent.length &&
|
|
2303
|
+
if (!a && n.startOffset === t.textContent.length && Pn(t.nextSibling) && I(t.nextSibling.nextSibling)) {
|
|
2213
2304
|
let n = t.nextSibling.nextSibling, i = n.nextSibling;
|
|
2214
2305
|
if (e.preventDefault(), i?.nodeType === Node.TEXT_NODE) {
|
|
2215
2306
|
let e = +!!(i.textContent || "").startsWith("");
|
|
@@ -2223,7 +2314,7 @@ function jn(e, t, n = {}) {
|
|
|
2223
2314
|
if (a && n.startOffset > 0) {
|
|
2224
2315
|
let i = t.childNodes[n.startOffset - 1];
|
|
2225
2316
|
if (I(i)) return e.preventDefault(), r((e) => e.setStartBefore(i));
|
|
2226
|
-
if (
|
|
2317
|
+
if (Pn(i) && I(i.previousSibling)) return e.preventDefault(), r((e) => e.setStartBefore(i.previousSibling));
|
|
2227
2318
|
}
|
|
2228
2319
|
if (!a && n.startOffset < t.childNodes.length) {
|
|
2229
2320
|
let i = t.childNodes[n.startOffset];
|
|
@@ -2235,7 +2326,7 @@ function jn(e, t, n = {}) {
|
|
|
2235
2326
|
}
|
|
2236
2327
|
return r((e) => e.setStartAfter(i));
|
|
2237
2328
|
}
|
|
2238
|
-
if (
|
|
2329
|
+
if (Pn(i) && I(i.nextSibling)) {
|
|
2239
2330
|
let t = i.nextSibling, n = t.nextSibling;
|
|
2240
2331
|
if (e.preventDefault(), n?.nodeType === Node.TEXT_NODE) {
|
|
2241
2332
|
let e = +!!(n.textContent || "").startsWith("");
|
|
@@ -2247,16 +2338,17 @@ function jn(e, t, n = {}) {
|
|
|
2247
2338
|
}
|
|
2248
2339
|
}
|
|
2249
2340
|
if (P(e, N.TAB)) {
|
|
2250
|
-
let r =
|
|
2341
|
+
let r = ye(t);
|
|
2251
2342
|
if (!r) return !1;
|
|
2343
|
+
if (Fn(r.sc, t, e.shiftKey)) return e.preventDefault(), !0;
|
|
2252
2344
|
let i = C(r.sc, t);
|
|
2253
|
-
if (i && _(i)) return e.preventDefault(), e.shiftKey ?
|
|
2254
|
-
if (i?.nodeName.toUpperCase() === "PRE") return e.shiftKey
|
|
2255
|
-
if (n.tabSize) return e.shiftKey
|
|
2345
|
+
if (i && _(i)) return e.preventDefault(), e.shiftKey ? Qe() : Xe(), !0;
|
|
2346
|
+
if (i?.nodeName.toUpperCase() === "PRE") return !e.shiftKey && (e.preventDefault(), D("insertText", " ".repeat(n.tabSize || 4)), !0);
|
|
2347
|
+
if (n.tabSize) return !e.shiftKey && (e.preventDefault(), D("insertText", " ".repeat(n.tabSize)), !0);
|
|
2256
2348
|
}
|
|
2257
2349
|
if (P(e, N.ENTER) && e.shiftKey) return e.preventDefault(), D("insertLineBreak"), !0;
|
|
2258
2350
|
if (P(e, N.ENTER) && !e.shiftKey) {
|
|
2259
|
-
let n =
|
|
2351
|
+
let n = ye(t);
|
|
2260
2352
|
if (!n) return !1;
|
|
2261
2353
|
let r = n.sc, i = r.nodeType === 3 ? r.parentElement : r;
|
|
2262
2354
|
if (i?.nodeName === "I" && /\bfa-/.test(i.className || "")) {
|
|
@@ -2279,7 +2371,7 @@ function jn(e, t, n = {}) {
|
|
|
2279
2371
|
if (o) {
|
|
2280
2372
|
e.preventDefault();
|
|
2281
2373
|
let t = o.closest(".an-checklist"), n = globalThis.getSelection(), r = n.getRangeAt(0);
|
|
2282
|
-
if (!((e) => Array.from(e.childNodes).filter((e) =>
|
|
2374
|
+
if (!((e) => Array.from(e.childNodes).filter((e) => e.nodeType !== 1 || e.tagName !== "INPUT").map((e) => e.textContent).join("").replace(/[\u00a0\u200B]/g, " ").trim())(o)) {
|
|
2283
2375
|
let e = document.createElement("p");
|
|
2284
2376
|
e.innerHTML = "\xA0", t.parentNode.insertBefore(e, t.nextSibling), o.remove(), t.children.length === 0 && t.remove();
|
|
2285
2377
|
let r = document.createRange();
|
|
@@ -2289,7 +2381,7 @@ function jn(e, t, n = {}) {
|
|
|
2289
2381
|
if (r.deleteContents(), n.rangeCount === 0 || !o.isConnected) return !0;
|
|
2290
2382
|
r = n.getRangeAt(0);
|
|
2291
2383
|
}
|
|
2292
|
-
let i =
|
|
2384
|
+
let i = Ln(r, o), a = document.createElement("li"), s = document.createElement("input");
|
|
2293
2385
|
s.type = "checkbox", s.setAttribute("contenteditable", "false"), a.appendChild(s), i.textContent.replace(/[\u00a0\u200B]/g, "").length > 0 && a.appendChild(i);
|
|
2294
2386
|
let c = a.childNodes[1];
|
|
2295
2387
|
c?.nodeType !== Node.TEXT_NODE && (c = document.createTextNode(""), a.appendChild(c)), o.after(a);
|
|
@@ -2306,14 +2398,98 @@ function jn(e, t, n = {}) {
|
|
|
2306
2398
|
return !1;
|
|
2307
2399
|
}
|
|
2308
2400
|
//#endregion
|
|
2401
|
+
//#region src/js/core/count.js
|
|
2402
|
+
var zn = typeof Intl < "u" && typeof Intl.Segmenter == "function" ? new Intl.Segmenter(void 0, { granularity: "word" }) : null;
|
|
2403
|
+
function Bn(e) {
|
|
2404
|
+
let t = e.trim();
|
|
2405
|
+
if (!t) return 0;
|
|
2406
|
+
if (zn) {
|
|
2407
|
+
let e = 0;
|
|
2408
|
+
for (let n of zn.segment(t)) n.isWordLike && e++;
|
|
2409
|
+
return e;
|
|
2410
|
+
}
|
|
2411
|
+
return t.split(/\s+/).length;
|
|
2412
|
+
}
|
|
2413
|
+
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("."));
|
|
2414
|
+
function Hn(e, t, n) {
|
|
2415
|
+
for (let r = e.firstChild; r; r = r.nextSibling) if (r.nodeType === 3) {
|
|
2416
|
+
let e = r.data;
|
|
2417
|
+
t.push(e), n.push(e);
|
|
2418
|
+
} else if (r.nodeType === 1) {
|
|
2419
|
+
let e = Vn.has(r.tagName);
|
|
2420
|
+
e && t.push("\n"), Hn(r, t, n), e && t.push("\n");
|
|
2421
|
+
}
|
|
2422
|
+
}
|
|
2423
|
+
function Un(e) {
|
|
2424
|
+
if (e.nodeType === 3) {
|
|
2425
|
+
let t = e.data;
|
|
2426
|
+
return {
|
|
2427
|
+
lines: t,
|
|
2428
|
+
flat: t
|
|
2429
|
+
};
|
|
2430
|
+
}
|
|
2431
|
+
let t = [], n = [];
|
|
2432
|
+
return Hn(e, t, n), {
|
|
2433
|
+
lines: t.join(""),
|
|
2434
|
+
flat: n.join("")
|
|
2435
|
+
};
|
|
2436
|
+
}
|
|
2437
|
+
var Wn = class {
|
|
2438
|
+
constructor() {
|
|
2439
|
+
this._cache = /* @__PURE__ */ new WeakMap();
|
|
2440
|
+
}
|
|
2441
|
+
counts(e) {
|
|
2442
|
+
let t = 0, n = 0, r = [], i = [], a = 0;
|
|
2443
|
+
for (let o = e.firstChild; o; o = o.nextSibling) {
|
|
2444
|
+
let e = this._cache.get(o);
|
|
2445
|
+
if (e && e.key === (o.textContent || "")) {
|
|
2446
|
+
t += e.words, n += e.chars;
|
|
2447
|
+
continue;
|
|
2448
|
+
}
|
|
2449
|
+
let { lines: s, flat: c } = Un(o);
|
|
2450
|
+
r.push({
|
|
2451
|
+
node: o,
|
|
2452
|
+
key: c,
|
|
2453
|
+
text: s,
|
|
2454
|
+
start: a
|
|
2455
|
+
}), i.push(s), a += s.length + 1;
|
|
2456
|
+
}
|
|
2457
|
+
if (r.length) {
|
|
2458
|
+
let e = Gn(r, i.join("\n"));
|
|
2459
|
+
r.forEach((r, i) => {
|
|
2460
|
+
let a = {
|
|
2461
|
+
key: r.key,
|
|
2462
|
+
words: e[i],
|
|
2463
|
+
chars: r.key.replaceAll("\n", "").length
|
|
2464
|
+
};
|
|
2465
|
+
this._cache.set(r.node, a), t += a.words, n += a.chars;
|
|
2466
|
+
});
|
|
2467
|
+
}
|
|
2468
|
+
return {
|
|
2469
|
+
words: t,
|
|
2470
|
+
chars: n
|
|
2471
|
+
};
|
|
2472
|
+
}
|
|
2473
|
+
};
|
|
2474
|
+
function Gn(e, t) {
|
|
2475
|
+
if (!zn) return e.map((e) => Bn(e.text));
|
|
2476
|
+
let n = Array(e.length).fill(0), r = 0;
|
|
2477
|
+
for (let i of zn.segment(t)) if (i.isWordLike) {
|
|
2478
|
+
for (; r < e.length - 1 && i.index >= e[r + 1].start;) r++;
|
|
2479
|
+
n[r]++;
|
|
2480
|
+
}
|
|
2481
|
+
return n;
|
|
2482
|
+
}
|
|
2483
|
+
//#endregion
|
|
2309
2484
|
//#region src/js/core/markdown.js
|
|
2310
|
-
function
|
|
2311
|
-
|
|
2485
|
+
function Kn(e) {
|
|
2486
|
+
let t = new DOMParser().parseFromString(`<body>${e || ""}</body>`, "text/html");
|
|
2487
|
+
return pe(t.body), er(t.body).replace(/\n{3,}/g, "\n\n").trim();
|
|
2312
2488
|
}
|
|
2313
|
-
function
|
|
2489
|
+
function qn(e, t) {
|
|
2314
2490
|
return Array.from(e.children).filter((e) => e.tagName === t.toUpperCase());
|
|
2315
2491
|
}
|
|
2316
|
-
function
|
|
2492
|
+
function Jn(e) {
|
|
2317
2493
|
let t = "";
|
|
2318
2494
|
for (let n of e.childNodes) {
|
|
2319
2495
|
if (n.nodeType === 3) {
|
|
@@ -2327,40 +2503,40 @@ function Pn(e) {
|
|
|
2327
2503
|
continue;
|
|
2328
2504
|
}
|
|
2329
2505
|
if (e === "div" || e === "p") {
|
|
2330
|
-
t && !t.endsWith("\n") && (t += "\n"), t +=
|
|
2506
|
+
t && !t.endsWith("\n") && (t += "\n"), t += Jn(n), t += "\n";
|
|
2331
2507
|
continue;
|
|
2332
2508
|
}
|
|
2333
|
-
t +=
|
|
2509
|
+
t += Jn(n);
|
|
2334
2510
|
}
|
|
2335
2511
|
return t;
|
|
2336
2512
|
}
|
|
2337
|
-
function
|
|
2513
|
+
function Yn(e) {
|
|
2338
2514
|
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
2515
|
}
|
|
2340
|
-
function
|
|
2516
|
+
function Xn(e) {
|
|
2341
2517
|
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
2518
|
}
|
|
2343
|
-
function
|
|
2344
|
-
return e.split("\n").map(
|
|
2519
|
+
function Zn(e) {
|
|
2520
|
+
return e.split("\n").map(Xn).join("\n");
|
|
2345
2521
|
}
|
|
2346
|
-
function
|
|
2522
|
+
function Qn(e, t) {
|
|
2347
2523
|
let n = " ".repeat(t + 1);
|
|
2348
|
-
return
|
|
2524
|
+
return er(e, t + 1).trim().split("\n").map((e, t) => t === 0 || e.trim() === "" || e.startsWith(n) ? e : n + e).join("\n");
|
|
2349
2525
|
}
|
|
2350
|
-
function
|
|
2526
|
+
function $n(e, t) {
|
|
2351
2527
|
let n = e.getAttribute(t) || "", r = /[\s()]/.test(n) ? `<${n}>` : n, i = e.getAttribute("title");
|
|
2352
2528
|
return i ? `${r} "${i.replaceAll("\"", String.raw`\"`)}"` : r;
|
|
2353
2529
|
}
|
|
2354
|
-
function
|
|
2530
|
+
function er(e, t = 0) {
|
|
2355
2531
|
if (e.nodeType === 3) {
|
|
2356
2532
|
let t = e.textContent.replace(/\s+/g, " ");
|
|
2357
|
-
return e.parentElement?.closest("pre, code") ? t :
|
|
2533
|
+
return e.parentElement?.closest("pre, code") ? t : Yn(t);
|
|
2358
2534
|
}
|
|
2359
2535
|
if (e.nodeType !== 1) return "";
|
|
2360
|
-
let n = e, r = n.nodeName.toLowerCase(), i = () => Array.from(n.childNodes).map((e) =>
|
|
2536
|
+
let n = e, r = n.nodeName.toLowerCase(), i = () => Array.from(n.childNodes).map((e) => er(e, t)).join("");
|
|
2361
2537
|
switch (r) {
|
|
2362
2538
|
case "p":
|
|
2363
|
-
case "div": return `\n\n${
|
|
2539
|
+
case "div": return `\n\n${Zn(i())}\n\n`;
|
|
2364
2540
|
case "br": return " \n";
|
|
2365
2541
|
case "h1": return `\n\n# ${i()}\n\n`;
|
|
2366
2542
|
case "h2": return `\n\n## ${i()}\n\n`;
|
|
@@ -2389,27 +2565,27 @@ function Bn(e, t = 0) {
|
|
|
2389
2565
|
}
|
|
2390
2566
|
case "pre": {
|
|
2391
2567
|
let e = n.querySelector("code"), t = /language-(\S+)/.exec(e?.className || "");
|
|
2392
|
-
return `\n\n\`\`\`${t ? t[1] : ""}\n${
|
|
2568
|
+
return `\n\n\`\`\`${t ? t[1] : ""}\n${Jn(e || n).replace(/\n$/, "")}\n\`\`\`\n\n`;
|
|
2393
2569
|
}
|
|
2394
2570
|
case "blockquote": {
|
|
2395
2571
|
let e = i().trim().split("\n");
|
|
2396
2572
|
return `\n\n${e.filter((t, n) => t.trim() !== "" || (e[n - 1] ?? "").trim() !== "").map((e) => e.trim() === "" ? ">" : `> ${e}`).join("\n")}\n\n`;
|
|
2397
2573
|
}
|
|
2398
|
-
case "a": return `[${i()}](${
|
|
2399
|
-
case "img": return `})`;
|
|
2575
|
+
case "img": return `})`;
|
|
2400
2576
|
case "ul": {
|
|
2401
|
-
let e =
|
|
2577
|
+
let e = qn(n, "li");
|
|
2402
2578
|
if (!e.length) return i();
|
|
2403
2579
|
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}${
|
|
2580
|
+
let n = qn(e, "input").find((e) => e.getAttribute("type") === "checkbox"), i = "- ";
|
|
2581
|
+
return (a || n) && (i = n && n.checked ? "- [x] " : "- [ ] "), `${r}${i}${Qn(e, t)}`;
|
|
2406
2582
|
}).join("\n");
|
|
2407
2583
|
return t === 0 ? `\n\n${o}\n\n` : `\n${o}`;
|
|
2408
2584
|
}
|
|
2409
2585
|
case "ol": {
|
|
2410
|
-
let e =
|
|
2586
|
+
let e = qn(n, "li");
|
|
2411
2587
|
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}. ${
|
|
2588
|
+
let r = " ".repeat(t), a = Number.parseInt(n.getAttribute("start") || "1", 10), o = Number.isFinite(a) ? a : 1, s = e.map((e, n) => `${r}${o + n}. ${Qn(e, t)}`).join("\n");
|
|
2413
2589
|
return t === 0 ? `\n\n${s}\n\n` : `\n${s}`;
|
|
2414
2590
|
}
|
|
2415
2591
|
case "li": return i();
|
|
@@ -2417,7 +2593,7 @@ function Bn(e, t = 0) {
|
|
|
2417
2593
|
case "table": {
|
|
2418
2594
|
let e = Array.from(n.querySelectorAll("tr"));
|
|
2419
2595
|
if (!e.length) return i();
|
|
2420
|
-
let t = !!
|
|
2596
|
+
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
2597
|
let t = [...e];
|
|
2422
2598
|
for (; t.length < a;) t.push("");
|
|
2423
2599
|
return t;
|
|
@@ -2432,16 +2608,16 @@ function Bn(e, t = 0) {
|
|
|
2432
2608
|
default: return i();
|
|
2433
2609
|
}
|
|
2434
2610
|
}
|
|
2435
|
-
function
|
|
2611
|
+
function tr(e) {
|
|
2436
2612
|
return String(e ?? "").replace(/^\ufeff/, "");
|
|
2437
2613
|
}
|
|
2438
|
-
function
|
|
2439
|
-
let t =
|
|
2614
|
+
function nr(e) {
|
|
2615
|
+
let t = tr(e);
|
|
2440
2616
|
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
2617
|
}
|
|
2442
|
-
var
|
|
2443
|
-
function
|
|
2444
|
-
let t =
|
|
2618
|
+
var rr = /^ {0,3}>( ?)(.*)$/, ir = /^(?: {4}|\t)\s*\S/, ar = /^( {0,3})(`{3,}|~{3,})[ \t]*([^\s`~][^\n]*)?$/;
|
|
2619
|
+
function or(e) {
|
|
2620
|
+
let t = ar.exec(e);
|
|
2445
2621
|
if (!t) return null;
|
|
2446
2622
|
let [, n, r, i = ""] = t;
|
|
2447
2623
|
return r[0] === "`" && i.includes("`") ? null : {
|
|
@@ -2451,7 +2627,7 @@ function Kn(e) {
|
|
|
2451
2627
|
lang: i.trim().split(/\s+/)[0] || ""
|
|
2452
2628
|
};
|
|
2453
2629
|
}
|
|
2454
|
-
function
|
|
2630
|
+
function sr(e, t) {
|
|
2455
2631
|
let n = 0, r = 0;
|
|
2456
2632
|
for (; r < e.length && n < t;) {
|
|
2457
2633
|
if (e[r] === " ") {
|
|
@@ -2468,40 +2644,40 @@ function qn(e, t) {
|
|
|
2468
2644
|
}
|
|
2469
2645
|
return e.slice(r);
|
|
2470
2646
|
}
|
|
2471
|
-
var
|
|
2472
|
-
function
|
|
2473
|
-
let t =
|
|
2474
|
-
t =
|
|
2475
|
-
let n =
|
|
2476
|
-
return t = n.clean,
|
|
2647
|
+
var cr = /^ {0,3}([-*_])( *\1){2,}\s*$/, lr = "";
|
|
2648
|
+
function ur(e) {
|
|
2649
|
+
let t = tr(e).replaceAll("\r\n", "\n").replaceAll("\r", "\n").split("\n");
|
|
2650
|
+
t = mr(t);
|
|
2651
|
+
let n = hr(t);
|
|
2652
|
+
return t = n.clean, fr = n.linkDefs, pr = n.footnoteIds, dr(t);
|
|
2477
2653
|
}
|
|
2478
|
-
function
|
|
2654
|
+
function dr(e) {
|
|
2479
2655
|
let t = [], n = 0;
|
|
2480
2656
|
for (; n < e.length;) {
|
|
2481
|
-
let r = e[n], i =
|
|
2657
|
+
let r = e[n], i = or(r);
|
|
2482
2658
|
if (i) {
|
|
2483
2659
|
let r = RegExp(`^ {0,3}\\${i.marker}{${i.length},}[ \t]*$`), a = [];
|
|
2484
|
-
for (n++; n < e.length && !r.test(e[n]);) a.push(
|
|
2660
|
+
for (n++; n < e.length && !r.test(e[n]);) a.push(Rr(sr(e[n], i.indent))), n++;
|
|
2485
2661
|
let o = i.lang ? ` class="language-${z(i.lang)}"` : "";
|
|
2486
2662
|
t.push(`<pre><code${o}>${a.join("\n")}</code></pre>`), n++;
|
|
2487
2663
|
continue;
|
|
2488
2664
|
}
|
|
2489
|
-
if (
|
|
2665
|
+
if (ir.test(r)) {
|
|
2490
2666
|
let r = [];
|
|
2491
|
-
for (; n < e.length && (
|
|
2667
|
+
for (; n < e.length && (ir.test(e[n]) || e[n].trim() === "");) {
|
|
2492
2668
|
if (e[n].trim() === "") {
|
|
2493
2669
|
let t = n;
|
|
2494
2670
|
for (; t < e.length && e[t].trim() === "";) t++;
|
|
2495
|
-
if (t >= e.length || !
|
|
2671
|
+
if (t >= e.length || !ir.test(e[t])) break;
|
|
2496
2672
|
for (; n < t; n++) r.push("");
|
|
2497
2673
|
continue;
|
|
2498
2674
|
}
|
|
2499
|
-
r.push(
|
|
2675
|
+
r.push(Rr(sr(e[n], 4))), n++;
|
|
2500
2676
|
}
|
|
2501
2677
|
t.push(`<pre><code>${r.join("\n")}</code></pre>`);
|
|
2502
2678
|
continue;
|
|
2503
2679
|
}
|
|
2504
|
-
if (r.trim() && !
|
|
2680
|
+
if (r.trim() && !cr.test(r) && !/^#{1,6} /.test(r) && n + 1 < e.length) {
|
|
2505
2681
|
if (/^=+\s*$/.test(e[n + 1])) {
|
|
2506
2682
|
t.push(`<h1>${R(r.trim())}</h1>`), n += 2;
|
|
2507
2683
|
continue;
|
|
@@ -2511,7 +2687,7 @@ function Zn(e) {
|
|
|
2511
2687
|
continue;
|
|
2512
2688
|
}
|
|
2513
2689
|
}
|
|
2514
|
-
if (
|
|
2690
|
+
if (cr.test(r)) {
|
|
2515
2691
|
t.push("<hr>"), n++;
|
|
2516
2692
|
continue;
|
|
2517
2693
|
}
|
|
@@ -2521,19 +2697,19 @@ function Zn(e) {
|
|
|
2521
2697
|
t.push(`<h${e}>${R(r)}</h${e}>`), n++;
|
|
2522
2698
|
continue;
|
|
2523
2699
|
}
|
|
2524
|
-
if (
|
|
2700
|
+
if (rr.test(r)) {
|
|
2525
2701
|
let r = [];
|
|
2526
|
-
for (; n < e.length &&
|
|
2527
|
-
t.push(`<blockquote>${
|
|
2702
|
+
for (; n < e.length && rr.test(e[n]);) r.push(rr.exec(e[n])[2]), n++;
|
|
2703
|
+
t.push(`<blockquote>${dr(r)}</blockquote>`);
|
|
2528
2704
|
continue;
|
|
2529
2705
|
}
|
|
2530
2706
|
if (/^[-*+] /.test(r)) {
|
|
2531
|
-
let { html: r, endIdx: i } =
|
|
2707
|
+
let { html: r, endIdx: i } = xr(e, n);
|
|
2532
2708
|
t.push(r), n = i;
|
|
2533
2709
|
continue;
|
|
2534
2710
|
}
|
|
2535
2711
|
if (/^\d+[.)] /.test(r)) {
|
|
2536
|
-
let { html: r, endIdx: i } =
|
|
2712
|
+
let { html: r, endIdx: i } = xr(e, n);
|
|
2537
2713
|
t.push(r), n = i;
|
|
2538
2714
|
continue;
|
|
2539
2715
|
}
|
|
@@ -2541,23 +2717,23 @@ function Zn(e) {
|
|
|
2541
2717
|
n++;
|
|
2542
2718
|
continue;
|
|
2543
2719
|
}
|
|
2544
|
-
if (
|
|
2545
|
-
let i =
|
|
2720
|
+
if (yr(e, n)) {
|
|
2721
|
+
let i = br(r), a = br(e[n + 1]).map((e) => e.startsWith(":") && e.endsWith(":") ? "center" : e.endsWith(":") ? "right" : e.startsWith(":") ? "left" : null);
|
|
2546
2722
|
n += 2;
|
|
2547
2723
|
let o = [];
|
|
2548
|
-
for (; n < e.length && e[n].trim() !== "" &&
|
|
2724
|
+
for (; n < e.length && e[n].trim() !== "" && vr(e[n]);) o.push(br(e[n])), n++;
|
|
2549
2725
|
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
2726
|
t.push(`<table>${c}${l}</table>`);
|
|
2551
2727
|
continue;
|
|
2552
2728
|
}
|
|
2553
2729
|
let o = [];
|
|
2554
|
-
for (; n < e.length && e[n].trim() !== "" && !/^(#{1,6} |[-*+] |\d+[.)] )/.test(e[n]) && !
|
|
2555
|
-
o.length ? t.push(`<p>${R(
|
|
2730
|
+
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++;
|
|
2731
|
+
o.length ? t.push(`<p>${R(gr(o)).replaceAll(lr, "<br>")}</p>`) : (t.push(`<p>${R(r)}</p>`), n++);
|
|
2556
2732
|
}
|
|
2557
2733
|
return t.join("");
|
|
2558
2734
|
}
|
|
2559
|
-
var
|
|
2560
|
-
function
|
|
2735
|
+
var fr = /* @__PURE__ */ new Map(), pr = /* @__PURE__ */ new Set();
|
|
2736
|
+
function mr(e) {
|
|
2561
2737
|
if ((e[0] || "").trim() !== "---") return e;
|
|
2562
2738
|
let t = -1;
|
|
2563
2739
|
for (let n = 1; n < e.length; n++) {
|
|
@@ -2571,14 +2747,14 @@ function er(e) {
|
|
|
2571
2747
|
let n = t + 1;
|
|
2572
2748
|
return e[n] !== void 0 && e[n].trim() === "" && n++, e.slice(n);
|
|
2573
2749
|
}
|
|
2574
|
-
function
|
|
2750
|
+
function hr(e) {
|
|
2575
2751
|
let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set(), r = [], i = !1, a = /^\[([^\]]+)\]:\s*(\S+)(?:\s+"([^"]*)")?\s*$/, o = /^\[\^([^\]]+)\]:[ \t]*(\S.*)$/;
|
|
2576
2752
|
for (let s of e) {
|
|
2577
2753
|
if (i) {
|
|
2578
2754
|
/^ {0,3}(?:`{3,}|~{3,})[ \t]*$/.test(s) && (i = !1), r.push(s);
|
|
2579
2755
|
continue;
|
|
2580
2756
|
}
|
|
2581
|
-
if (
|
|
2757
|
+
if (or(s)) {
|
|
2582
2758
|
i = !0, r.push(s);
|
|
2583
2759
|
continue;
|
|
2584
2760
|
}
|
|
@@ -2605,33 +2781,36 @@ function tr(e) {
|
|
|
2605
2781
|
footnoteIds: n
|
|
2606
2782
|
};
|
|
2607
2783
|
}
|
|
2608
|
-
function
|
|
2784
|
+
function gr(e) {
|
|
2609
2785
|
let t = "";
|
|
2610
2786
|
for (let n = 0; n < e.length; n++) {
|
|
2611
2787
|
let r = n === e.length - 1, i = e[n].replace(/^[ \t]+/, "");
|
|
2612
2788
|
if (!r && /\\$/.test(i)) {
|
|
2613
|
-
t += i.replace(/\\$/, "") +
|
|
2789
|
+
t += i.replace(/\\$/, "") + lr;
|
|
2614
2790
|
continue;
|
|
2615
2791
|
}
|
|
2616
2792
|
if (!r && / {2,}$/.test(i)) {
|
|
2617
|
-
t += i.replace(/ {2,}$/, "") +
|
|
2793
|
+
t += i.replace(/ {2,}$/, "") + lr;
|
|
2618
2794
|
continue;
|
|
2619
2795
|
}
|
|
2620
2796
|
t += i + (r ? "" : " ");
|
|
2621
2797
|
}
|
|
2622
2798
|
return t;
|
|
2623
2799
|
}
|
|
2624
|
-
function
|
|
2625
|
-
return
|
|
2800
|
+
function _r(e) {
|
|
2801
|
+
return br(e).length;
|
|
2802
|
+
}
|
|
2803
|
+
function vr(e) {
|
|
2804
|
+
return e.includes("|") ? /^\s*\|/.test(e) || _r(e) > 1 : !1;
|
|
2626
2805
|
}
|
|
2627
|
-
function
|
|
2806
|
+
function yr(e, t) {
|
|
2628
2807
|
let n = e[t], r = e[t + 1];
|
|
2629
2808
|
if (r === void 0 || !n.includes("|")) return !1;
|
|
2630
2809
|
if (/^\|.+\|/.test(n)) return /^\|[\s|:-]+\|/.test(r);
|
|
2631
|
-
let i =
|
|
2632
|
-
return i.length < 2 || !i.every((e) => /^:?-+:?$/.test(e)) ? !1 :
|
|
2810
|
+
let i = br(r);
|
|
2811
|
+
return i.length < 2 || !i.every((e) => /^:?-+:?$/.test(e)) ? !1 : _r(n) === i.length;
|
|
2633
2812
|
}
|
|
2634
|
-
function
|
|
2813
|
+
function br(e) {
|
|
2635
2814
|
let t = e.replace(/^\|/, "").replace(/\|$/, ""), n = [], r = "";
|
|
2636
2815
|
for (let e = 0; e < t.length; e++) {
|
|
2637
2816
|
if (t[e] === "\\" && t[e + 1] === "|") {
|
|
@@ -2646,7 +2825,7 @@ function ar(e) {
|
|
|
2646
2825
|
}
|
|
2647
2826
|
return n.push(r), n.map((e) => e.trim());
|
|
2648
2827
|
}
|
|
2649
|
-
function
|
|
2828
|
+
function xr(e, t) {
|
|
2650
2829
|
let n = e[t].match(/^(\s*)/)[1].length, r = /^\s*\d+[.)] /.test(e[t]), i = [], a = null, o = !1, s = !1, c = t;
|
|
2651
2830
|
for (; c < e.length;) {
|
|
2652
2831
|
let t = e[c];
|
|
@@ -2674,15 +2853,15 @@ function or(e, t) {
|
|
|
2674
2853
|
c++;
|
|
2675
2854
|
continue;
|
|
2676
2855
|
}
|
|
2677
|
-
let n = (e) =>
|
|
2856
|
+
let n = (e) => sr(e, l), r = or(n(t));
|
|
2678
2857
|
if (r) {
|
|
2679
2858
|
let t = RegExp(`^ {0,3}\\${r.marker}{${r.length},}[ \t]*$`), a = [n(e[c])];
|
|
2680
2859
|
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 +=
|
|
2860
|
+
c < e.length && (a.push(n(e[c])), c++), i[i.length - 1].sub += dr(a), s = !1;
|
|
2682
2861
|
continue;
|
|
2683
2862
|
}
|
|
2684
2863
|
if (/^\s*(?:[-*+]|\d+[.)]) /.test(t)) {
|
|
2685
|
-
let t =
|
|
2864
|
+
let t = xr(e, c);
|
|
2686
2865
|
i[i.length - 1].sub += t.html, c = t.endIdx, s = !1;
|
|
2687
2866
|
} else if (s) i[i.length - 1].paras.push(t.trim()), s = !1, c++;
|
|
2688
2867
|
else {
|
|
@@ -2700,32 +2879,32 @@ function or(e, t) {
|
|
|
2700
2879
|
endIdx: c
|
|
2701
2880
|
};
|
|
2702
2881
|
}
|
|
2703
|
-
var
|
|
2704
|
-
function
|
|
2882
|
+
var Sr = /\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g, L = "\0", Cr = "", wr = /(`+)([^]*?)\1/g;
|
|
2883
|
+
function Tr(e) {
|
|
2705
2884
|
let t = [];
|
|
2706
2885
|
return {
|
|
2707
|
-
text: e.replace(
|
|
2886
|
+
text: e.replace(wr, (e, n, r) => r === "" ? e : (t.push(r), `${Cr}${t.length - 1}${Cr}`)),
|
|
2708
2887
|
codes: t
|
|
2709
2888
|
};
|
|
2710
2889
|
}
|
|
2711
|
-
function
|
|
2712
|
-
return e.replace(RegExp(`${
|
|
2890
|
+
function Er(e, t, n) {
|
|
2891
|
+
return e.replace(RegExp(`${Cr}(\\d+)${Cr}`, "g"), (e, r) => {
|
|
2713
2892
|
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>${
|
|
2893
|
+
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
2894
|
});
|
|
2716
2895
|
}
|
|
2717
|
-
function
|
|
2896
|
+
function Dr(e) {
|
|
2718
2897
|
let t = [];
|
|
2719
2898
|
return {
|
|
2720
|
-
text: e.replace(
|
|
2899
|
+
text: e.replace(Sr, (e, n) => (t.push(n), `${L}${t.length - 1}${L}`)),
|
|
2721
2900
|
literals: t
|
|
2722
2901
|
};
|
|
2723
2902
|
}
|
|
2724
|
-
function
|
|
2725
|
-
return e.replace(RegExp(`${L}(\\d+)${L}`, "g"), (e, n) =>
|
|
2903
|
+
function Or(e, t) {
|
|
2904
|
+
return e.replace(RegExp(`${L}(\\d+)${L}`, "g"), (e, n) => Lr(t[Number(n)]));
|
|
2726
2905
|
}
|
|
2727
|
-
var
|
|
2728
|
-
function
|
|
2906
|
+
var kr = String.raw`(<.*?>(?:\s+(?:"[^"]*"|'[^']*'))?|[^)]*)`, Ar = new RegExp(String.raw`!\[([^\]]*)\]\(${kr}\)`, "g"), jr = new RegExp(String.raw`\[([^\]]+)\]\(${kr}\)`, "g");
|
|
2907
|
+
function Mr(e) {
|
|
2729
2908
|
let t = e.trim(), n = /^<([\s\S]*?)>(?:[ \t]*(?:"([^"]*)"|'([^']*)'))?[ \t]*$/.exec(t);
|
|
2730
2909
|
if (n) return {
|
|
2731
2910
|
href: n[1],
|
|
@@ -2740,26 +2919,26 @@ function _r(e) {
|
|
|
2740
2919
|
title: ""
|
|
2741
2920
|
};
|
|
2742
2921
|
}
|
|
2743
|
-
function
|
|
2744
|
-
return e = e.replace(
|
|
2745
|
-
let { href: r, title: i } =
|
|
2922
|
+
function Nr(e) {
|
|
2923
|
+
return e = e.replace(Ar, (e, t, n) => {
|
|
2924
|
+
let { href: r, title: i } = Mr(n), a = i ? ` title="${B(i)}"` : "";
|
|
2746
2925
|
return `<img src="${B(r)}" alt="${B(t)}"${a} class="an-image">`;
|
|
2747
|
-
}), e = e.replace(
|
|
2748
|
-
let { href: r, title: i } =
|
|
2926
|
+
}), e = e.replace(jr, (e, t, n) => {
|
|
2927
|
+
let { href: r, title: i } = Mr(n), a = i ? ` title="${B(i)}"` : "";
|
|
2749
2928
|
return `<a href="${B(r)}"${a}>${t}</a>`;
|
|
2750
2929
|
}), e = e.replace(/\[([^\]]+)\]\[([^\]]*)\]/g, (e, t, n) => {
|
|
2751
|
-
let r =
|
|
2930
|
+
let r = fr.get(zr(n || t).trim().toLowerCase());
|
|
2752
2931
|
if (!r) return e;
|
|
2753
2932
|
let i = r.title ? ` title="${z(r.title)}"` : "";
|
|
2754
2933
|
return `<a href="${z(r.href)}"${i}>${t}</a>`;
|
|
2755
2934
|
}), e = e.replace(/\[([^\]]+)\]/g, (e, t) => {
|
|
2756
|
-
let n =
|
|
2935
|
+
let n = fr.get(zr(t).trim().toLowerCase());
|
|
2757
2936
|
if (!n) return e;
|
|
2758
2937
|
let r = n.title ? ` title="${z(n.title)}"` : "";
|
|
2759
2938
|
return `<a href="${z(n.href)}"${r}>${t}</a>`;
|
|
2760
|
-
}), e = e.replace(/\[\^([^\]]+)\]/g, (e, t) =>
|
|
2939
|
+
}), e = e.replace(/\[\^([^\]]+)\]/g, (e, t) => pr.has(zr(t)) ? `<sup>[${t}]</sup>` : e), e;
|
|
2761
2940
|
}
|
|
2762
|
-
function
|
|
2941
|
+
function Pr(e) {
|
|
2763
2942
|
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
2943
|
let r = /[.,;:!?)]+$/.exec(n), i = r ? n.slice(0, -r[0].length) : n;
|
|
2765
2944
|
if (!i) return e;
|
|
@@ -2767,18 +2946,18 @@ function yr(e) {
|
|
|
2767
2946
|
return `${t}<a href="${B(i)}">${i}</a>${a}`;
|
|
2768
2947
|
}), e;
|
|
2769
2948
|
}
|
|
2770
|
-
function
|
|
2949
|
+
function Fr(e) {
|
|
2771
2950
|
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
2951
|
}
|
|
2773
2952
|
function R(e) {
|
|
2774
|
-
let { text: t, literals: n } =
|
|
2775
|
-
return a =
|
|
2953
|
+
let { text: t, literals: n } = Dr(e), { text: r, codes: i } = Tr(t), a = Lr(r);
|
|
2954
|
+
return a = Nr(a), a = Pr(a), a = Fr(a), Er(Or(a, n), i, n);
|
|
2776
2955
|
}
|
|
2777
|
-
var
|
|
2778
|
-
function
|
|
2779
|
-
return String(e).replace(
|
|
2956
|
+
var Ir = /&(?!#\d+;|#[xX][0-9a-fA-F]+;|[a-zA-Z][a-zA-Z0-9]*;)/g;
|
|
2957
|
+
function Lr(e) {
|
|
2958
|
+
return String(e).replace(Ir, "&").replaceAll("<", "<").replaceAll(">", ">");
|
|
2780
2959
|
}
|
|
2781
|
-
function
|
|
2960
|
+
function Rr(e) {
|
|
2782
2961
|
return String(e).replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">");
|
|
2783
2962
|
}
|
|
2784
2963
|
function z(e) {
|
|
@@ -2787,16 +2966,16 @@ function z(e) {
|
|
|
2787
2966
|
function B(e) {
|
|
2788
2967
|
return String(e).replaceAll("\"", """).replaceAll("'", "'");
|
|
2789
2968
|
}
|
|
2790
|
-
function
|
|
2969
|
+
function zr(e) {
|
|
2791
2970
|
return String(e).replaceAll("<", "<").replaceAll(">", ">").replaceAll("&", "&");
|
|
2792
2971
|
}
|
|
2793
2972
|
//#endregion
|
|
2794
2973
|
//#region src/js/core/detectLang.js
|
|
2795
|
-
var
|
|
2974
|
+
var Br = 5, Vr = 2, Hr = [
|
|
2796
2975
|
["typescript", "javascript"],
|
|
2797
2976
|
["scss", "css"],
|
|
2798
2977
|
["cpp", "c"]
|
|
2799
|
-
],
|
|
2978
|
+
], Ur = [
|
|
2800
2979
|
"javascript",
|
|
2801
2980
|
"typescript",
|
|
2802
2981
|
"python",
|
|
@@ -2819,7 +2998,7 @@ var Tr = 5, Er = 2, Dr = [
|
|
|
2819
2998
|
"scss",
|
|
2820
2999
|
"css",
|
|
2821
3000
|
"bash"
|
|
2822
|
-
],
|
|
3001
|
+
], Wr = [
|
|
2823
3002
|
{
|
|
2824
3003
|
lang: "php",
|
|
2825
3004
|
w: 10,
|
|
@@ -3385,27 +3564,27 @@ var Tr = 5, Er = 2, Dr = [
|
|
|
3385
3564
|
w: 3,
|
|
3386
3565
|
re: /\s\|[ \t]*\w|\s&&\s|\s2>&1|\s-[\w-]+\s/
|
|
3387
3566
|
}
|
|
3388
|
-
],
|
|
3389
|
-
function
|
|
3390
|
-
if (e.length <=
|
|
3391
|
-
let t = e.slice(0,
|
|
3567
|
+
], Gr = 4e3;
|
|
3568
|
+
function Kr(e) {
|
|
3569
|
+
if (e.length <= Gr) return e;
|
|
3570
|
+
let t = e.slice(0, Gr), n = t.lastIndexOf("\n");
|
|
3392
3571
|
return n > 0 ? t.slice(0, n) : t;
|
|
3393
3572
|
}
|
|
3394
|
-
function
|
|
3573
|
+
function qr(e) {
|
|
3395
3574
|
if (!e?.trim()) return null;
|
|
3396
|
-
let t =
|
|
3397
|
-
for (let { lang: e, re: r, w: i } of
|
|
3575
|
+
let t = Kr(e.trim()), n = /* @__PURE__ */ new Map();
|
|
3576
|
+
for (let { lang: e, re: r, w: i } of Wr) r.test(t) && n.set(e, (n.get(e) || 0) + i);
|
|
3398
3577
|
if (n.size === 0) return null;
|
|
3399
|
-
for (let [e, t] of
|
|
3578
|
+
for (let [e, t] of Hr) {
|
|
3400
3579
|
let r = n.get(e);
|
|
3401
3580
|
r && n.set(e, r + (n.get(t) || 0));
|
|
3402
3581
|
}
|
|
3403
3582
|
let r = [...n.entries()].sort((e, t) => t[1] - e[1]), [i, a] = r[0], o = r[1]?.[1] ?? 0;
|
|
3404
|
-
return a <
|
|
3583
|
+
return a < Br || a - o < Vr ? null : i;
|
|
3405
3584
|
}
|
|
3406
3585
|
//#endregion
|
|
3407
3586
|
//#region src/js/module/Editor.js
|
|
3408
|
-
var
|
|
3587
|
+
var Jr = /* @__PURE__ */ new Set([
|
|
3409
3588
|
"PRE",
|
|
3410
3589
|
"BLOCKQUOTE",
|
|
3411
3590
|
"TABLE",
|
|
@@ -3413,13 +3592,13 @@ var Nr = /* @__PURE__ */ new Set([
|
|
|
3413
3592
|
"UL",
|
|
3414
3593
|
"OL",
|
|
3415
3594
|
"HR"
|
|
3416
|
-
]),
|
|
3595
|
+
]), Yr = class {
|
|
3417
3596
|
constructor(e) {
|
|
3418
|
-
this.context = e, this.options = e.options, this._history = null, this._disposers = [], this._snapshotTimer = null;
|
|
3597
|
+
this.context = e, this.options = e.options, this._history = null, this._disposers = [], this._snapshotTimer = null, this._limitCounter = null;
|
|
3419
3598
|
}
|
|
3420
3599
|
initialize() {
|
|
3421
3600
|
let e = this.context.layoutInfo.editable;
|
|
3422
|
-
return this._history = new
|
|
3601
|
+
return this._history = new An(e, this.options.historyLimit || 100, this.options.historyMaxBytes || 10485760), this._bindEvents(e), this;
|
|
3423
3602
|
}
|
|
3424
3603
|
destroy() {
|
|
3425
3604
|
this._disposers.forEach((e) => e()), this._disposers = [], this._history = null, clearTimeout(this._snapshotTimer), this._snapshotTimer = null;
|
|
@@ -3496,7 +3675,7 @@ var Nr = /* @__PURE__ */ new Set([
|
|
|
3496
3675
|
}
|
|
3497
3676
|
_onKeydown(e) {
|
|
3498
3677
|
let t = this.context.layoutInfo.editable;
|
|
3499
|
-
if (!
|
|
3678
|
+
if (!Rn(e, t, this.options)) {
|
|
3500
3679
|
if (F(e, "z") && !e.shiftKey) {
|
|
3501
3680
|
e.preventDefault(), this.undo();
|
|
3502
3681
|
return;
|
|
@@ -3539,14 +3718,15 @@ var Nr = /* @__PURE__ */ new Set([
|
|
|
3539
3718
|
_enforceLimit(e) {
|
|
3540
3719
|
let t = this.options.maxChars || 0, n = this.options.maxWords || 0;
|
|
3541
3720
|
if (!t && !n) return;
|
|
3721
|
+
this._limitCounter ??= new Wn();
|
|
3542
3722
|
let r = e.inputType || "";
|
|
3543
3723
|
if (r.startsWith("delete") || r === "historyUndo" || r === "historyRedo" || r === "insertFromPaste" || r === "insertFromDrop" || !r.startsWith("insert")) return;
|
|
3544
|
-
let i = this.context.layoutInfo.editable
|
|
3724
|
+
let { words: i, chars: a } = this._limitCounter.counts(this.context.layoutInfo.editable);
|
|
3545
3725
|
if (t && a >= t) {
|
|
3546
3726
|
e.preventDefault(), typeof this.options.onCharLimitReached == "function" && this.options.onCharLimitReached(this.context);
|
|
3547
3727
|
return;
|
|
3548
3728
|
}
|
|
3549
|
-
n && (e.data === " " || r === "insertParagraph" || r === "insertLineBreak") &&
|
|
3729
|
+
n && (e.data === " " || r === "insertParagraph" || r === "insertLineBreak") && i >= n && (e.preventDefault(), typeof this.options.onWordLimitReached == "function" && this.options.onWordLimitReached(this.context));
|
|
3550
3730
|
}
|
|
3551
3731
|
afterCommand() {
|
|
3552
3732
|
this._cleanOrphanedFigures(), this._ensureTrailingParagraph(), this.context.invoke("toolbar.refresh"), this.context.invoke("statusbar.update"), this._scheduleSnapshot();
|
|
@@ -3565,7 +3745,7 @@ var Nr = /* @__PURE__ */ new Set([
|
|
|
3565
3745
|
let e = this.context.layoutInfo.editable;
|
|
3566
3746
|
if (!e) return;
|
|
3567
3747
|
let t = e.lastElementChild;
|
|
3568
|
-
if (t &&
|
|
3748
|
+
if (t && Jr.has(t.nodeName)) {
|
|
3569
3749
|
let t = document.createElement("p");
|
|
3570
3750
|
t.innerHTML = "<br>", e.appendChild(t);
|
|
3571
3751
|
}
|
|
@@ -3578,7 +3758,7 @@ var Nr = /* @__PURE__ */ new Set([
|
|
|
3578
3758
|
return this.context.invoke("clipboard.resolveImages", e) ?? e;
|
|
3579
3759
|
}
|
|
3580
3760
|
setHTML(e) {
|
|
3581
|
-
let t =
|
|
3761
|
+
let t = vn(e, { allowIframes: !0 });
|
|
3582
3762
|
this.context.layoutInfo.editable.replaceChildren(...t.childNodes), this._history && this._history.reset(), this.afterCommand();
|
|
3583
3763
|
}
|
|
3584
3764
|
getText() {
|
|
@@ -3604,10 +3784,10 @@ var Nr = /* @__PURE__ */ new Set([
|
|
|
3604
3784
|
e && (D("insertText", e), this.afterCommand());
|
|
3605
3785
|
}
|
|
3606
3786
|
setMarkdown(e) {
|
|
3607
|
-
this.setHTML(
|
|
3787
|
+
this.setHTML(ur(e || ""));
|
|
3608
3788
|
}
|
|
3609
3789
|
getMarkdown() {
|
|
3610
|
-
return
|
|
3790
|
+
return Kn(this.getHTML());
|
|
3611
3791
|
}
|
|
3612
3792
|
undo() {
|
|
3613
3793
|
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 +3817,63 @@ var Nr = /* @__PURE__ */ new Set([
|
|
|
3637
3817
|
return !e || !this._history ? !1 : (this._history._restoreSelection(e), !0);
|
|
3638
3818
|
}
|
|
3639
3819
|
bold() {
|
|
3640
|
-
|
|
3820
|
+
Fe(), this.afterCommand();
|
|
3641
3821
|
}
|
|
3642
3822
|
italic() {
|
|
3643
|
-
|
|
3823
|
+
Ie(), this.afterCommand();
|
|
3644
3824
|
}
|
|
3645
3825
|
underline() {
|
|
3646
|
-
|
|
3826
|
+
Le(), this.afterCommand();
|
|
3647
3827
|
}
|
|
3648
3828
|
strikethrough() {
|
|
3649
|
-
|
|
3829
|
+
Re(), this.afterCommand();
|
|
3650
3830
|
}
|
|
3651
3831
|
superscript() {
|
|
3652
|
-
|
|
3832
|
+
ze(), this.afterCommand();
|
|
3653
3833
|
}
|
|
3654
3834
|
subscript() {
|
|
3655
|
-
|
|
3835
|
+
Be(), this.afterCommand();
|
|
3656
3836
|
}
|
|
3657
3837
|
justifyLeft() {
|
|
3658
|
-
|
|
3838
|
+
Ke(), this.afterCommand();
|
|
3659
3839
|
}
|
|
3660
3840
|
justifyCenter() {
|
|
3661
|
-
|
|
3841
|
+
qe(), this.afterCommand();
|
|
3662
3842
|
}
|
|
3663
3843
|
justifyRight() {
|
|
3664
|
-
|
|
3844
|
+
Je(), this.afterCommand();
|
|
3665
3845
|
}
|
|
3666
3846
|
justifyFull() {
|
|
3667
|
-
|
|
3847
|
+
Ye(), this.afterCommand();
|
|
3668
3848
|
}
|
|
3669
3849
|
indent() {
|
|
3670
|
-
|
|
3850
|
+
Xe(), this.afterCommand();
|
|
3671
3851
|
}
|
|
3672
3852
|
outdent() {
|
|
3673
|
-
|
|
3853
|
+
Qe(), this.afterCommand();
|
|
3674
3854
|
}
|
|
3675
3855
|
insertUL() {
|
|
3676
|
-
|
|
3856
|
+
rt(), this.afterCommand();
|
|
3677
3857
|
}
|
|
3678
3858
|
insertOL() {
|
|
3679
|
-
|
|
3859
|
+
it(), this.afterCommand();
|
|
3680
3860
|
}
|
|
3681
3861
|
inlineCode() {
|
|
3682
|
-
|
|
3862
|
+
ot(this.context.layoutInfo.editable), this.afterCommand();
|
|
3683
3863
|
}
|
|
3684
3864
|
toggleChecklist() {
|
|
3685
|
-
|
|
3865
|
+
ut(), this.afterCommand();
|
|
3686
3866
|
}
|
|
3687
3867
|
print() {
|
|
3688
3868
|
this.context.print();
|
|
3689
3869
|
}
|
|
3690
3870
|
formatBlock(e) {
|
|
3691
|
-
if (
|
|
3871
|
+
if (Ge(e), e === "pre") {
|
|
3692
3872
|
let e = globalThis.getSelection();
|
|
3693
3873
|
if (e?.rangeCount > 0) {
|
|
3694
3874
|
let t = e.getRangeAt(0).commonAncestorContainer, n = t.nodeType === 1 ? t.closest("pre") : t.parentElement?.closest("pre");
|
|
3695
3875
|
if (n && !n.dataset.language) {
|
|
3696
|
-
let e =
|
|
3876
|
+
let e = qr(n.textContent || "");
|
|
3697
3877
|
if (e) {
|
|
3698
3878
|
this.context.invoke("codeTooltip.applyLanguage", n, e);
|
|
3699
3879
|
return;
|
|
@@ -3704,16 +3884,16 @@ var Nr = /* @__PURE__ */ new Set([
|
|
|
3704
3884
|
this.afterCommand();
|
|
3705
3885
|
}
|
|
3706
3886
|
foreColor(e) {
|
|
3707
|
-
|
|
3887
|
+
Ve(e), this.afterCommand();
|
|
3708
3888
|
}
|
|
3709
3889
|
backColor(e) {
|
|
3710
|
-
|
|
3890
|
+
He(e), this.afterCommand();
|
|
3711
3891
|
}
|
|
3712
3892
|
fontName(e) {
|
|
3713
|
-
|
|
3893
|
+
Ue(e), this.afterCommand();
|
|
3714
3894
|
}
|
|
3715
3895
|
fontSize(e) {
|
|
3716
|
-
|
|
3896
|
+
We(e, this.context.layoutInfo.editable), this.afterCommand();
|
|
3717
3897
|
}
|
|
3718
3898
|
insertHr() {
|
|
3719
3899
|
D("insertHorizontalRule"), this.afterCommand();
|
|
@@ -3752,7 +3932,7 @@ var Nr = /* @__PURE__ */ new Set([
|
|
|
3752
3932
|
e && (D("insertHTML", e), this.afterCommand());
|
|
3753
3933
|
}
|
|
3754
3934
|
insertTable(e, t) {
|
|
3755
|
-
|
|
3935
|
+
Mn(e, t, { headerRow: this.context.options.tableHeaderRow }), this.afterCommand();
|
|
3756
3936
|
}
|
|
3757
3937
|
_getClosestAnchor() {
|
|
3758
3938
|
let e = globalThis.getSelection();
|
|
@@ -3767,7 +3947,7 @@ var Nr = /* @__PURE__ */ new Set([
|
|
|
3767
3947
|
_escapeAttr(e) {
|
|
3768
3948
|
return String(e ?? "").replaceAll("&", "&").replaceAll("\"", """).replaceAll("<", "<").replaceAll(">", ">");
|
|
3769
3949
|
}
|
|
3770
|
-
},
|
|
3950
|
+
}, 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
3951
|
["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
3952
|
["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
3953
|
["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 +3984,7 @@ var Nr = /* @__PURE__ */ new Set([
|
|
|
3804
3984
|
["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
3985
|
["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
3986
|
["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
|
-
]),
|
|
3987
|
+
]), $r = /* @__PURE__ */ new Map([
|
|
3808
3988
|
["bold", "fa-bold"],
|
|
3809
3989
|
["italic", "fa-italic"],
|
|
3810
3990
|
["underline", "fa-underline"],
|
|
@@ -3838,7 +4018,7 @@ var Nr = /* @__PURE__ */ new Set([
|
|
|
3838
4018
|
["inline-code", "fa-code"],
|
|
3839
4019
|
["checklist", "fa-list-check"],
|
|
3840
4020
|
["print", "fa-print"]
|
|
3841
|
-
]),
|
|
4021
|
+
]), ei = class {
|
|
3842
4022
|
constructor(e) {
|
|
3843
4023
|
this.context = e, this.options = e.options, this.el = null, this._disposers = [], this._colorPickerClosers = [], this._refreshRaf = null;
|
|
3844
4024
|
}
|
|
@@ -3848,7 +4028,7 @@ var Nr = /* @__PURE__ */ new Set([
|
|
|
3848
4028
|
role: "toolbar",
|
|
3849
4029
|
"aria-orientation": "horizontal",
|
|
3850
4030
|
"aria-label": "Editor toolbar"
|
|
3851
|
-
}), this._faReady = this._detectFontAwesome(), this._buildButtons(), this._initRovingFocus(), this._btnMap = new Map((this.options.toolbar || []).flat().map(
|
|
4031
|
+
}), 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
4032
|
}
|
|
3853
4033
|
destroy() {
|
|
3854
4034
|
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 +4038,7 @@ var Nr = /* @__PURE__ */ new Set([
|
|
|
3858
4038
|
e.forEach((e) => {
|
|
3859
4039
|
let n = w("div", { class: "an-btn-group" });
|
|
3860
4040
|
e.forEach((e) => {
|
|
3861
|
-
let t =
|
|
4041
|
+
let t = Xr(e);
|
|
3862
4042
|
if (!t) {
|
|
3863
4043
|
console.warn(`[AutumnNote] Toolbar: button "${e}" not found in registry. Skipped.`);
|
|
3864
4044
|
return;
|
|
@@ -3878,7 +4058,7 @@ var Nr = /* @__PURE__ */ new Set([
|
|
|
3878
4058
|
"aria-haspopup": "true",
|
|
3879
4059
|
"aria-expanded": "false"
|
|
3880
4060
|
});
|
|
3881
|
-
this._faReady ?
|
|
4061
|
+
n.innerHTML = this._faReady ? `<i class="${this.options.fontAwesomeClass || "fas"} fa-table" aria-hidden="true"></i>` : "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"15\" height=\"15\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" style=\"display:block\"><rect x=\"3\" y=\"3\" width=\"18\" height=\"18\" rx=\"1\"/><line x1=\"3\" y1=\"9\" x2=\"21\" y2=\"9\"/><line x1=\"3\" y1=\"15\" x2=\"21\" y2=\"15\"/><line x1=\"9\" y1=\"3\" x2=\"9\" y2=\"21\"/><line x1=\"15\" y1=\"3\" x2=\"15\" y2=\"21\"/></svg>";
|
|
3882
4062
|
let r = w("div", {
|
|
3883
4063
|
class: "an-table-picker-popup",
|
|
3884
4064
|
role: "dialog",
|
|
@@ -4077,7 +4257,7 @@ var Nr = /* @__PURE__ */ new Set([
|
|
|
4077
4257
|
...typeof e.isActive == "function" ? { "aria-pressed": "false" } : {}
|
|
4078
4258
|
}), n = this.options.fontAwesomeClass || "fas";
|
|
4079
4259
|
if (this._faReady) {
|
|
4080
|
-
let r =
|
|
4260
|
+
let r = $r.get(e.icon) || $r.get(e.name) || null;
|
|
4081
4261
|
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
4262
|
} 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
4263
|
let r = E(t, "click", (t) => {
|
|
@@ -4123,10 +4303,10 @@ var Nr = /* @__PURE__ */ new Set([
|
|
|
4123
4303
|
}
|
|
4124
4304
|
_detectFontAwesome() {
|
|
4125
4305
|
if (!this.options.useFontAwesome) return !1;
|
|
4126
|
-
if (
|
|
4127
|
-
if (document.querySelector(".fa, .fas, .far, .fal, .fab, .fa-solid")) return
|
|
4306
|
+
if (Zr !== null) return Zr;
|
|
4307
|
+
if (document.querySelector(".fa, .fas, .far, .fal, .fab, .fa-solid")) return Zr = !0, !0;
|
|
4128
4308
|
let e = Array.from(document.querySelectorAll("link[rel=\"stylesheet\"]")).filter((e) => e.id !== "an-fontawesome-css").map((e) => e.href || "").join(" ");
|
|
4129
|
-
return
|
|
4309
|
+
return Zr = /fontawesome|font-awesome|use\.fontawesome|all\.css/.test(e), Zr;
|
|
4130
4310
|
}
|
|
4131
4311
|
refresh() {
|
|
4132
4312
|
this._refreshRaf && cancelAnimationFrame(this._refreshRaf), this._refreshRaf = requestAnimationFrame(() => {
|
|
@@ -4159,53 +4339,21 @@ var Nr = /* @__PURE__ */ new Set([
|
|
|
4159
4339
|
this.el && (this.el.style.display = "none");
|
|
4160
4340
|
}
|
|
4161
4341
|
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(
|
|
4163
|
-
}
|
|
4164
|
-
}, Br = typeof Intl < "u" && typeof Intl.Segmenter == "function" ? new Intl.Segmenter(void 0, { granularity: "word" }) : null;
|
|
4165
|
-
function Vr(e) {
|
|
4166
|
-
let t = e.trim();
|
|
4167
|
-
if (!t) return 0;
|
|
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
|
-
};
|
|
4342
|
+
this._refreshRaf &&= (cancelAnimationFrame(this._refreshRaf), null), this._disposers.forEach((e) => e()), this._disposers = [], this.el && (this.el.innerHTML = ""), this._faReady = this._detectFontAwesome(), this._buildButtons(), this._initRovingFocus(), this._btnMap = new Map((this.options.toolbar || []).flat().map(Xr).filter(Boolean).map((e) => [e.name, e])), this.refresh();
|
|
4192
4343
|
}
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
};
|
|
4198
|
-
}
|
|
4199
|
-
function Gr(e, t, n) {
|
|
4344
|
+
};
|
|
4345
|
+
//#endregion
|
|
4346
|
+
//#region src/js/module/Statusbar.js
|
|
4347
|
+
function ti(e, t, n) {
|
|
4200
4348
|
if (!n) {
|
|
4201
4349
|
e.classList.remove("an-count-warn", "an-count-exceeded");
|
|
4202
4350
|
return;
|
|
4203
4351
|
}
|
|
4204
4352
|
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
4353
|
}
|
|
4206
|
-
var
|
|
4354
|
+
var ni = class {
|
|
4207
4355
|
constructor(e) {
|
|
4208
|
-
this.context = e, this.options = e.options, this.el = null, this._disposers = [], this._wordCountEl = null, this._charCountEl = null, this.
|
|
4356
|
+
this.context = e, this.options = e.options, this.el = null, this._disposers = [], this._wordCountEl = null, this._charCountEl = null, this._counter = new Wn();
|
|
4209
4357
|
}
|
|
4210
4358
|
initialize() {
|
|
4211
4359
|
if (this.el = w("div", { class: "an-statusbar" }), this.options.resizable !== !1) {
|
|
@@ -4255,50 +4403,12 @@ var Kr = class {
|
|
|
4255
4403
|
this._disposers.push(d, f);
|
|
4256
4404
|
}
|
|
4257
4405
|
_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;
|
|
4406
|
+
return this._counter.counts(this.context.layoutInfo.editable);
|
|
4297
4407
|
}
|
|
4298
4408
|
update() {
|
|
4299
4409
|
if (!this._wordCountEl || !this._charCountEl) return;
|
|
4300
4410
|
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),
|
|
4411
|
+
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
4412
|
}
|
|
4303
4413
|
getWordCount() {
|
|
4304
4414
|
return this._counts().words;
|
|
@@ -4306,7 +4416,7 @@ var Kr = class {
|
|
|
4306
4416
|
getCharCount() {
|
|
4307
4417
|
return this._counts().chars;
|
|
4308
4418
|
}
|
|
4309
|
-
},
|
|
4419
|
+
}, ri = class {
|
|
4310
4420
|
constructor(e) {
|
|
4311
4421
|
this.context = e, this.options = e.options, this._disposers = [];
|
|
4312
4422
|
}
|
|
@@ -4423,8 +4533,8 @@ var Kr = class {
|
|
|
4423
4533
|
}
|
|
4424
4534
|
if (this.options.markdownPaste !== !1) {
|
|
4425
4535
|
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(
|
|
4536
|
+
if (a && i && nr(a)) {
|
|
4537
|
+
e.preventDefault(), D("insertHTML", j(ur(a))), this.context.invoke("editor.afterCommand");
|
|
4428
4538
|
return;
|
|
4429
4539
|
}
|
|
4430
4540
|
}
|
|
@@ -4463,7 +4573,7 @@ var Kr = class {
|
|
|
4463
4573
|
}
|
|
4464
4574
|
let n = new FileReader();
|
|
4465
4575
|
n.onload = (e) => {
|
|
4466
|
-
D("insertHTML", j(
|
|
4576
|
+
D("insertHTML", j(ur(e.target.result || ""))), this.context.invoke("editor.afterCommand");
|
|
4467
4577
|
}, n.onerror = () => {
|
|
4468
4578
|
let t = `Failed to read dropped markdown file "${e.name}".`;
|
|
4469
4579
|
console.warn(`[AutumnNote] ${t}`), this.context.triggerEvent("pasteError", { message: t });
|
|
@@ -4675,7 +4785,7 @@ var Kr = class {
|
|
|
4675
4785
|
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
4786
|
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
4787
|
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
|
-
},
|
|
4788
|
+
}, ii = [
|
|
4679
4789
|
"#000000",
|
|
4680
4790
|
"#434343",
|
|
4681
4791
|
"#666666",
|
|
@@ -4701,19 +4811,19 @@ var Kr = class {
|
|
|
4701
4811
|
"#d9d2e9",
|
|
4702
4812
|
"#ead1dc"
|
|
4703
4813
|
];
|
|
4704
|
-
function
|
|
4814
|
+
function ai(e) {
|
|
4705
4815
|
let t = e === "foreColor" ? "Text Color" : "Highlight Color", n = e === "foreColor" ? "textColor" : "highlightColor";
|
|
4706
4816
|
return () => [{
|
|
4707
4817
|
back: !0,
|
|
4708
4818
|
label: t,
|
|
4709
4819
|
localeKey: n,
|
|
4710
|
-
navigate: () =>
|
|
4820
|
+
navigate: () => oi
|
|
4711
4821
|
}, {
|
|
4712
4822
|
colorPalette: !0,
|
|
4713
4823
|
colorType: e
|
|
4714
4824
|
}];
|
|
4715
4825
|
}
|
|
4716
|
-
var
|
|
4826
|
+
var oi = [
|
|
4717
4827
|
{
|
|
4718
4828
|
name: "cut",
|
|
4719
4829
|
label: "Cut",
|
|
@@ -4777,14 +4887,14 @@ var Xr = [
|
|
|
4777
4887
|
label: "Text Color",
|
|
4778
4888
|
icon: U.textColor,
|
|
4779
4889
|
colorStrip: "foreColor",
|
|
4780
|
-
navigate:
|
|
4890
|
+
navigate: ai("foreColor")
|
|
4781
4891
|
},
|
|
4782
4892
|
{
|
|
4783
4893
|
name: "highlightColor",
|
|
4784
4894
|
label: "Highlight Color",
|
|
4785
4895
|
icon: U.highlightColor,
|
|
4786
4896
|
colorStrip: "hiliteColor",
|
|
4787
|
-
navigate:
|
|
4897
|
+
navigate: ai("hiliteColor")
|
|
4788
4898
|
},
|
|
4789
4899
|
{ separator: !0 },
|
|
4790
4900
|
{
|
|
@@ -4831,9 +4941,9 @@ var Xr = [
|
|
|
4831
4941
|
icon: U.table,
|
|
4832
4942
|
tableGrid: !0
|
|
4833
4943
|
}
|
|
4834
|
-
],
|
|
4944
|
+
], si = class {
|
|
4835
4945
|
constructor(e) {
|
|
4836
|
-
this.context = e, this.options = e.options
|
|
4946
|
+
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
4947
|
}
|
|
4838
4948
|
initialize() {
|
|
4839
4949
|
this.el = w("div", {
|
|
@@ -4888,20 +4998,22 @@ var Xr = [
|
|
|
4888
4998
|
class: "an-context-item an-context-submenu",
|
|
4889
4999
|
"data-name": e.name || ""
|
|
4890
5000
|
});
|
|
4891
|
-
if (e.icon)
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
5001
|
+
if (e.icon) {
|
|
5002
|
+
if (e.colorStrip) {
|
|
5003
|
+
let n = w("span", {
|
|
5004
|
+
class: "an-context-icon an-context-icon--color",
|
|
5005
|
+
"aria-hidden": "true"
|
|
5006
|
+
}), r = w("span", { class: "an-context-icon-svg" });
|
|
5007
|
+
r.innerHTML = e.icon;
|
|
5008
|
+
let i = w("span", { class: "an-context-color-strip" });
|
|
5009
|
+
i.style.background = this._getSelectionColor(e.colorStrip), n.appendChild(r), n.appendChild(i), t.appendChild(n);
|
|
5010
|
+
} else {
|
|
5011
|
+
let n = w("span", {
|
|
5012
|
+
class: "an-context-icon",
|
|
5013
|
+
"aria-hidden": "true"
|
|
5014
|
+
});
|
|
5015
|
+
n.innerHTML = e.icon, t.appendChild(n);
|
|
5016
|
+
}
|
|
4905
5017
|
}
|
|
4906
5018
|
t.appendChild(w("span", { class: "an-context-label" }, [this.context.locale.contextMenu[e.name] || e.label || e.name]));
|
|
4907
5019
|
let n = w("span", {
|
|
@@ -4919,7 +5031,7 @@ var Xr = [
|
|
|
4919
5031
|
}
|
|
4920
5032
|
if (e.colorPalette) {
|
|
4921
5033
|
let t = w("div", { class: "an-context-color-palette" });
|
|
4922
|
-
if (
|
|
5034
|
+
if (ii.forEach((n) => {
|
|
4923
5035
|
let r = w("div", {
|
|
4924
5036
|
class: "an-context-color-swatch",
|
|
4925
5037
|
title: n,
|
|
@@ -5149,13 +5261,13 @@ var Xr = [
|
|
|
5149
5261
|
} catch {}
|
|
5150
5262
|
this.context.invoke("editor.afterCommand");
|
|
5151
5263
|
}
|
|
5152
|
-
},
|
|
5153
|
-
function
|
|
5264
|
+
}, ci = /[^\s\u200B]/;
|
|
5265
|
+
function li(e) {
|
|
5154
5266
|
let t = document.createTreeWalker(e, NodeFilter.SHOW_TEXT);
|
|
5155
|
-
for (let e = t.nextNode(); e; e = t.nextNode()) if (
|
|
5267
|
+
for (let e = t.nextNode(); e; e = t.nextNode()) if (ci.test(e.data)) return !0;
|
|
5156
5268
|
return !1;
|
|
5157
5269
|
}
|
|
5158
|
-
var
|
|
5270
|
+
var ui = class {
|
|
5159
5271
|
constructor(e) {
|
|
5160
5272
|
this.context = e, this.options = e.options, this._disposers = [];
|
|
5161
5273
|
}
|
|
@@ -5169,10 +5281,10 @@ var ei = class {
|
|
|
5169
5281
|
this._disposers.forEach((e) => e()), this._disposers = [];
|
|
5170
5282
|
}
|
|
5171
5283
|
_update() {
|
|
5172
|
-
let e = this.context.layoutInfo.editable, t = document.activeElement === e, n =
|
|
5284
|
+
let e = this.context.layoutInfo.editable, t = document.activeElement === e, n = !li(e) && !e.querySelector("img, table, hr, .an-video-wrapper");
|
|
5173
5285
|
e.classList.toggle("an-placeholder", n && !t);
|
|
5174
5286
|
}
|
|
5175
|
-
},
|
|
5287
|
+
}, di = class {
|
|
5176
5288
|
constructor(e) {
|
|
5177
5289
|
this.context = e, this.options = e.options, this._active = !1, this._textarea = null, this._disposers = [];
|
|
5178
5290
|
}
|
|
@@ -5217,7 +5329,7 @@ var ei = class {
|
|
|
5217
5329
|
return /^<[^/!][^>]*[^/]>/.test(r) && !t.test(r) && !/^<(br|hr|img|input|link|meta)/.test(r) && n++, i;
|
|
5218
5330
|
}).filter(Boolean).join("\n");
|
|
5219
5331
|
}
|
|
5220
|
-
},
|
|
5332
|
+
}, fi = class {
|
|
5221
5333
|
constructor(e) {
|
|
5222
5334
|
this.context = e, this._active = !1, this._disposers = [], this._prevHeight = "";
|
|
5223
5335
|
}
|
|
@@ -5260,12 +5372,12 @@ var ei = class {
|
|
|
5260
5372
|
this._disposers.forEach((e) => e()), this._disposers = [], this._dialog?.parentNode && this._dialog.remove(), this._dialog = null;
|
|
5261
5373
|
}
|
|
5262
5374
|
_saveRange() {
|
|
5263
|
-
|
|
5375
|
+
Ce((e) => {
|
|
5264
5376
|
this._savedRange = e;
|
|
5265
5377
|
});
|
|
5266
5378
|
}
|
|
5267
5379
|
_open() {
|
|
5268
|
-
this._dialog && (this._dialog.style.display = "flex", this._removeTrap =
|
|
5380
|
+
this._dialog && (this._dialog.style.display = "flex", this._removeTrap = he(this._dialog, () => this._close()), setTimeout(() => this._firstInput?.focus(), 50));
|
|
5269
5381
|
}
|
|
5270
5382
|
_close() {
|
|
5271
5383
|
this._dialog && (this._dialog.style.display = "none"), this._removeTrap &&= (this._removeTrap(), null), this._savedRange = null;
|
|
@@ -5279,7 +5391,7 @@ var ei = class {
|
|
|
5279
5391
|
}), i = w("div", { class: "an-dialog-box" }), a = w("div", { class: "an-dialog-header" }), o = w("span", { class: "an-dialog-icon" });
|
|
5280
5392
|
o.innerHTML = t;
|
|
5281
5393
|
let s = w("h3", { class: "an-dialog-title" });
|
|
5282
|
-
s.textContent = n, a.appendChild(o), a.appendChild(s), i.appendChild(a), r.appendChild(i),
|
|
5394
|
+
s.textContent = n, a.appendChild(o), a.appendChild(s), i.appendChild(a), r.appendChild(i), ge(a, i);
|
|
5283
5395
|
let c = E(r, "click", (e) => {
|
|
5284
5396
|
e.target === r && this._close();
|
|
5285
5397
|
});
|
|
@@ -5302,12 +5414,12 @@ var ei = class {
|
|
|
5302
5414
|
let o = E(i, "click", n), s = E(a, "click", () => this._close());
|
|
5303
5415
|
return this._disposers.push(o, s), r;
|
|
5304
5416
|
}
|
|
5305
|
-
},
|
|
5417
|
+
}, 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
5418
|
show() {
|
|
5307
5419
|
this._saveRange(), this._prefill(), this._open();
|
|
5308
5420
|
}
|
|
5309
5421
|
_buildDialog() {
|
|
5310
|
-
let e = this.context.locale.linkDialog, { overlay: t, box: n } = this._buildDialogShell(e.ariaLabel,
|
|
5422
|
+
let e = this.context.locale.linkDialog, { overlay: t, box: n } = this._buildDialogShell(e.ariaLabel, pi, e.title), r = w("label", { class: "an-label" });
|
|
5311
5423
|
r.textContent = e.url;
|
|
5312
5424
|
let i = w("input", {
|
|
5313
5425
|
type: "url",
|
|
@@ -5377,12 +5489,12 @@ var ei = class {
|
|
|
5377
5489
|
}
|
|
5378
5490
|
this._savedRange && this._savedRange.select(), this.context.invoke("editor.insertLink", e, t, n), this._close();
|
|
5379
5491
|
}
|
|
5380
|
-
},
|
|
5492
|
+
}, 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
5493
|
show({ beforeInsert: e } = {}) {
|
|
5382
5494
|
this._beforeInsert = typeof e == "function" ? e : null, this._saveRange(), this._urlInput.value = "", this._altInput.value = "", this._fileInput && (this._fileInput.value = ""), this._open();
|
|
5383
5495
|
}
|
|
5384
5496
|
_buildDialog() {
|
|
5385
|
-
let e = this.context.locale.imageDialog, { overlay: t, box: n } = this._buildDialogShell(e.ariaLabel,
|
|
5497
|
+
let e = this.context.locale.imageDialog, { overlay: t, box: n } = this._buildDialogShell(e.ariaLabel, hi, e.title), r = w("label", { class: "an-label" });
|
|
5386
5498
|
r.textContent = e.imageUrl;
|
|
5387
5499
|
let i = w("input", {
|
|
5388
5500
|
type: "url",
|
|
@@ -5509,12 +5621,12 @@ var ei = class {
|
|
|
5509
5621
|
_close() {
|
|
5510
5622
|
this._beforeInsert = null, super._close();
|
|
5511
5623
|
}
|
|
5512
|
-
},
|
|
5624
|
+
}, _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
5625
|
show() {
|
|
5514
5626
|
this._saveRange(), this._urlInput.value = "", this._widthInput.value = "560", this._hintEl.textContent = "", this._open();
|
|
5515
5627
|
}
|
|
5516
5628
|
_buildDialog() {
|
|
5517
|
-
let e = this.context.locale.videoDialog, { overlay: t, box: n } = this._buildDialogShell(e.ariaLabel,
|
|
5629
|
+
let e = this.context.locale.videoDialog, { overlay: t, box: n } = this._buildDialogShell(e.ariaLabel, _i, e.title), r = w("label", { class: "an-label" });
|
|
5518
5630
|
r.textContent = e.videoUrl;
|
|
5519
5631
|
let i = w("input", {
|
|
5520
5632
|
type: "url",
|
|
@@ -5595,7 +5707,7 @@ var ei = class {
|
|
|
5595
5707
|
let i = M(e, { media: !0 });
|
|
5596
5708
|
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
5709
|
}
|
|
5598
|
-
},
|
|
5710
|
+
}, yi = [
|
|
5599
5711
|
{
|
|
5600
5712
|
pos: "nw",
|
|
5601
5713
|
cursor: "nw-resize"
|
|
@@ -5628,7 +5740,7 @@ var ei = class {
|
|
|
5628
5740
|
pos: "w",
|
|
5629
5741
|
cursor: "w-resize"
|
|
5630
5742
|
}
|
|
5631
|
-
],
|
|
5743
|
+
], bi = class {
|
|
5632
5744
|
constructor(e) {
|
|
5633
5745
|
this.context = e, this._active = null, this._overlay = null, this._disposers = [], this._positionRaf = null, this._lastOverlayPos = null;
|
|
5634
5746
|
}
|
|
@@ -5681,7 +5793,7 @@ var ei = class {
|
|
|
5681
5793
|
}
|
|
5682
5794
|
_buildOverlay() {
|
|
5683
5795
|
let e = document.createElement("div");
|
|
5684
|
-
return e.className = this._overlayClass, e.style.display = "none",
|
|
5796
|
+
return e.className = this._overlayClass, e.style.display = "none", yi.forEach(({ pos: t }) => {
|
|
5685
5797
|
let n = document.createElement("div");
|
|
5686
5798
|
n.className = `an-resize-handle an-resize-${t}`, n.dataset.handle = t, this._disposers.push(E(n, "pointerdown", (e) => {
|
|
5687
5799
|
e.preventDefault(), e.stopPropagation(), this._startResize(e, t);
|
|
@@ -5738,7 +5850,7 @@ var ei = class {
|
|
|
5738
5850
|
};
|
|
5739
5851
|
document.addEventListener("pointermove", p), document.addEventListener("pointerup", h), document.addEventListener("pointercancel", h), this._dragDisposers = [m];
|
|
5740
5852
|
}
|
|
5741
|
-
},
|
|
5853
|
+
}, xi = class extends bi {
|
|
5742
5854
|
get _overlayClass() {
|
|
5743
5855
|
return "an-image-resizer";
|
|
5744
5856
|
}
|
|
@@ -5767,7 +5879,7 @@ var ei = class {
|
|
|
5767
5879
|
getActiveImage() {
|
|
5768
5880
|
return this._active;
|
|
5769
5881
|
}
|
|
5770
|
-
},
|
|
5882
|
+
}, Si = class extends bi {
|
|
5771
5883
|
get _overlayClass() {
|
|
5772
5884
|
return "an-video-resizer";
|
|
5773
5885
|
}
|
|
@@ -5803,12 +5915,12 @@ var ei = class {
|
|
|
5803
5915
|
getActiveWrapper() {
|
|
5804
5916
|
return this._active;
|
|
5805
5917
|
}
|
|
5806
|
-
},
|
|
5918
|
+
}, Ci = {
|
|
5807
5919
|
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
5920
|
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
5921
|
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
5922
|
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
|
-
},
|
|
5923
|
+
}, wi = 120, Ti = 200, Ei = class {
|
|
5812
5924
|
constructor(e) {
|
|
5813
5925
|
this.context = e, this._el = null, this._activeAnchor = null, this._showTimer = null, this._hideTimer = null, this._disposers = [];
|
|
5814
5926
|
}
|
|
@@ -5832,7 +5944,7 @@ var ei = class {
|
|
|
5832
5944
|
role: "toolbar",
|
|
5833
5945
|
"aria-label": e.ariaLabel
|
|
5834
5946
|
});
|
|
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(
|
|
5947
|
+
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
5948
|
}
|
|
5837
5949
|
_makeBtn(e, t, n) {
|
|
5838
5950
|
let r = w("button", {
|
|
@@ -5845,14 +5957,14 @@ var ei = class {
|
|
|
5845
5957
|
})), r;
|
|
5846
5958
|
}
|
|
5847
5959
|
_scheduleShow(e) {
|
|
5848
|
-
this._activeAnchor
|
|
5960
|
+
(this._activeAnchor !== e || this._el.style.display === "none") && (clearTimeout(this._hideTimer), this._hideTimer = null, clearTimeout(this._showTimer), this._showTimer = setTimeout(() => {
|
|
5849
5961
|
this._activeAnchor = e, this._show(e);
|
|
5850
|
-
},
|
|
5962
|
+
}, wi));
|
|
5851
5963
|
}
|
|
5852
5964
|
_scheduleHide() {
|
|
5853
5965
|
clearTimeout(this._showTimer), this._showTimer = null, !this._hideTimer && (this._hideTimer = setTimeout(() => {
|
|
5854
5966
|
this._hide();
|
|
5855
|
-
},
|
|
5967
|
+
}, Ti));
|
|
5856
5968
|
}
|
|
5857
5969
|
_show(e) {
|
|
5858
5970
|
let t = this.context.layoutInfo.container.classList.contains("an-disabled"), n = e.getAttribute("href") || "";
|
|
@@ -5901,7 +6013,7 @@ var ei = class {
|
|
|
5901
6013
|
let t = globalThis.getSelection(), n = document.createRange();
|
|
5902
6014
|
n.selectNode(e), t.removeAllRanges(), t.addRange(n), document.execCommand("unlink"), this.context.invoke("editor.afterCommand");
|
|
5903
6015
|
}
|
|
5904
|
-
},
|
|
6016
|
+
}, Di = class {
|
|
5905
6017
|
constructor(e) {
|
|
5906
6018
|
this.context = e, this.options = e.options, this._el = null, this._active = null, this._showTimer = null, this._hideTimer = null, this._disposers = [];
|
|
5907
6019
|
}
|
|
@@ -5920,7 +6032,7 @@ var ei = class {
|
|
|
5920
6032
|
})), i;
|
|
5921
6033
|
}
|
|
5922
6034
|
_scheduleShow(e) {
|
|
5923
|
-
this._active
|
|
6035
|
+
(this._active !== e || this._el.style.display === "none") && (clearTimeout(this._hideTimer), this._hideTimer = null, clearTimeout(this._showTimer), this._showTimer = setTimeout(() => {
|
|
5924
6036
|
this._active = e, this._show(e);
|
|
5925
6037
|
}, 100));
|
|
5926
6038
|
}
|
|
@@ -5953,7 +6065,7 @@ var ei = class {
|
|
|
5953
6065
|
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
6066
|
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
6067
|
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
|
-
},
|
|
6068
|
+
}, Oi = class extends Di {
|
|
5957
6069
|
initialize() {
|
|
5958
6070
|
this._el = this._buildTooltip(), document.body.appendChild(this._el);
|
|
5959
6071
|
let e = this.context.layoutInfo.editable;
|
|
@@ -6053,7 +6165,7 @@ var ei = class {
|
|
|
6053
6165
|
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
6166
|
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
6167
|
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
|
-
},
|
|
6168
|
+
}, ki = class extends Di {
|
|
6057
6169
|
initialize() {
|
|
6058
6170
|
this._el = this._buildTooltip(), document.body.appendChild(this._el);
|
|
6059
6171
|
let e = this.context.layoutInfo.editable;
|
|
@@ -6159,7 +6271,7 @@ var ei = class {
|
|
|
6159
6271
|
};
|
|
6160
6272
|
//#endregion
|
|
6161
6273
|
//#region src/js/module/table-grid.js
|
|
6162
|
-
function
|
|
6274
|
+
function Ai(e) {
|
|
6163
6275
|
let t = e.closest("tr");
|
|
6164
6276
|
if (!t) return -1;
|
|
6165
6277
|
let n = 0;
|
|
@@ -6178,7 +6290,7 @@ function J(e, t) {
|
|
|
6178
6290
|
}
|
|
6179
6291
|
return null;
|
|
6180
6292
|
}
|
|
6181
|
-
function
|
|
6293
|
+
function ji(e, t) {
|
|
6182
6294
|
let n = 0;
|
|
6183
6295
|
for (let r of e.cells) if (n += r.colSpan || 1, n > t) {
|
|
6184
6296
|
let e = r.nextElementSibling;
|
|
@@ -6186,7 +6298,7 @@ function xi(e, t) {
|
|
|
6186
6298
|
}
|
|
6187
6299
|
return null;
|
|
6188
6300
|
}
|
|
6189
|
-
function
|
|
6301
|
+
function Mi(e) {
|
|
6190
6302
|
let t = Array.from(e.rows), n = {}, r = /* @__PURE__ */ new WeakMap();
|
|
6191
6303
|
return t.forEach((e, t) => {
|
|
6192
6304
|
n[t] || (n[t] = {});
|
|
@@ -6213,7 +6325,7 @@ function Si(e) {
|
|
|
6213
6325
|
}
|
|
6214
6326
|
//#endregion
|
|
6215
6327
|
//#region src/js/module/TableTooltip.js
|
|
6216
|
-
var
|
|
6328
|
+
var Ni = 120, Pi = 200, Fi = [
|
|
6217
6329
|
"#000000",
|
|
6218
6330
|
"#434343",
|
|
6219
6331
|
"#666666",
|
|
@@ -6238,7 +6350,7 @@ var Ci = 120, wi = 200, Ti = [
|
|
|
6238
6350
|
"#c9daf8",
|
|
6239
6351
|
"#d9d2e9",
|
|
6240
6352
|
"#ead1dc"
|
|
6241
|
-
],
|
|
6353
|
+
], Ii = class {
|
|
6242
6354
|
constructor(e) {
|
|
6243
6355
|
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
6356
|
}
|
|
@@ -6248,7 +6360,7 @@ var Ci = 120, wi = 200, Ti = [
|
|
|
6248
6360
|
return this._editable = e, this._disposers.push(E(e, "mousedown", (t) => {
|
|
6249
6361
|
if (!this._selectMode) return;
|
|
6250
6362
|
let n = t.target.closest("td, th");
|
|
6251
|
-
!n || !e.contains(n) || n.style.cursor
|
|
6363
|
+
!n || !e.contains(n) || n.style.cursor !== "col-resize" && n.style.cursor !== "row-resize" && (t.preventDefault(), this._activeTable = n.closest("table"), this._selectStart = n, this._selectDragging = !0, this._setSelection([n]));
|
|
6252
6364
|
}), E(e, "mousemove", (t) => {
|
|
6253
6365
|
if (!this._selectMode || !this._selectDragging || !this._selectStart) return;
|
|
6254
6366
|
let n = t.target.closest("td, th");
|
|
@@ -6296,7 +6408,7 @@ var Ci = 120, wi = 200, Ti = [
|
|
|
6296
6408
|
});
|
|
6297
6409
|
}), E(e, "mousedown", (e) => {
|
|
6298
6410
|
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 =
|
|
6411
|
+
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
6412
|
else {
|
|
6301
6413
|
let e = t.closest("tr"), n = (e ? Array.from(f.rows).indexOf(e) : 0) + (t.rowSpan || 1) - 1;
|
|
6302
6414
|
d = f.rows[n] || e, c = d ? d.offsetHeight : 40, document.body.style.cursor = "row-resize";
|
|
@@ -6366,12 +6478,12 @@ var Ci = 120, wi = 200, Ti = [
|
|
|
6366
6478
|
})), i;
|
|
6367
6479
|
}
|
|
6368
6480
|
_scheduleShow(e) {
|
|
6369
|
-
this._activeTable
|
|
6481
|
+
(this._activeTable !== e || this._el.style.display === "none") && (clearTimeout(this._hideTimer), this._hideTimer = null, clearTimeout(this._showTimer), this._showTimer = setTimeout(() => {
|
|
6370
6482
|
this._activeTable = e, this._show();
|
|
6371
|
-
},
|
|
6483
|
+
}, Ni));
|
|
6372
6484
|
}
|
|
6373
6485
|
_scheduleHide() {
|
|
6374
|
-
clearTimeout(this._showTimer), this._showTimer = null, !this._hideTimer && (this._hideTimer = setTimeout(() => this._hide(),
|
|
6486
|
+
clearTimeout(this._showTimer), this._showTimer = null, !this._hideTimer && (this._hideTimer = setTimeout(() => this._hide(), Pi));
|
|
6375
6487
|
}
|
|
6376
6488
|
_show() {
|
|
6377
6489
|
this._activeTable && (this._el.style.display = "flex", this._syncShadeStrip(), this._syncBorderColorStrip(), requestAnimationFrame(() => {
|
|
@@ -6420,7 +6532,7 @@ var Ci = 120, wi = 200, Ti = [
|
|
|
6420
6532
|
if (!t || e === t) return [e];
|
|
6421
6533
|
let n = e.closest("table");
|
|
6422
6534
|
if (!n?.contains(t)) return [e];
|
|
6423
|
-
let { gridMap: r, cellPos: i } =
|
|
6535
|
+
let { gridMap: r, cellPos: i } = Mi(n), a = i.get(e), o = i.get(t);
|
|
6424
6536
|
if (!a || !o) return [e];
|
|
6425
6537
|
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
6538
|
for (; d;) {
|
|
@@ -6468,7 +6580,7 @@ var Ci = 120, wi = 200, Ti = [
|
|
|
6468
6580
|
if (!t.length) return;
|
|
6469
6581
|
let n = t[0].closest("table");
|
|
6470
6582
|
if (!n) return;
|
|
6471
|
-
let r = t.map((e) =>
|
|
6583
|
+
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
6584
|
a.forEach((e, t) => {
|
|
6473
6585
|
e.insertBefore(w(s[t] ? "th" : "td", {}, ["\xA0"]), o[t]);
|
|
6474
6586
|
}), requestAnimationFrame(() => this._positionNear(this._activeTable)), this.context.invoke("editor.afterCommand");
|
|
@@ -6488,7 +6600,7 @@ var Ci = 120, wi = 200, Ti = [
|
|
|
6488
6600
|
if (!t) return;
|
|
6489
6601
|
let n = Array.from(t.querySelectorAll("tr"));
|
|
6490
6602
|
if (n[0] && n[0].cells.length <= 1) return;
|
|
6491
|
-
let r = [...new Set(e.map((e) =>
|
|
6603
|
+
let r = [...new Set(e.map((e) => Ai(e)))];
|
|
6492
6604
|
if (r.length >= (n[0]?.cells.length ?? 1)) return;
|
|
6493
6605
|
let i = [];
|
|
6494
6606
|
r.forEach((e) => {
|
|
@@ -6516,7 +6628,7 @@ var Ci = 120, wi = 200, Ti = [
|
|
|
6516
6628
|
}
|
|
6517
6629
|
}), n.length < 2) return;
|
|
6518
6630
|
}
|
|
6519
|
-
let { gridMap: r, cellPos: i } =
|
|
6631
|
+
let { gridMap: r, cellPos: i } = Mi(t), a = Infinity, o = -Infinity, s = Infinity, c = -Infinity;
|
|
6520
6632
|
if (n.forEach((e) => {
|
|
6521
6633
|
let t = i.get(e);
|
|
6522
6634
|
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 +6667,7 @@ var Ci = 120, wi = 200, Ti = [
|
|
|
6555
6667
|
_unmergeOne(e, t) {
|
|
6556
6668
|
let n = e.colSpan || 1, r = e.rowSpan || 1;
|
|
6557
6669
|
if (n === 1 && r === 1) return;
|
|
6558
|
-
let { cellPos: i } =
|
|
6670
|
+
let { cellPos: i } = Mi(t), a = i.get(e);
|
|
6559
6671
|
if (!a) return;
|
|
6560
6672
|
let { r: o, c: s } = a, c = Array.from(t.rows), l = e.tagName.toLowerCase();
|
|
6561
6673
|
if (e.rowSpan = 1, e.colSpan = 1, e.style.verticalAlign = "", n > 1) {
|
|
@@ -6642,7 +6754,7 @@ var Ci = 120, wi = 200, Ti = [
|
|
|
6642
6754
|
let i = t.closest("table");
|
|
6643
6755
|
if (i) {
|
|
6644
6756
|
if (n) {
|
|
6645
|
-
let t = [...new Set(r.map((e) =>
|
|
6757
|
+
let t = [...new Set(r.map((e) => Ai(e)))], n = Array.from(i.querySelectorAll("tr"));
|
|
6646
6758
|
t.forEach((t) => {
|
|
6647
6759
|
n.forEach((n) => {
|
|
6648
6760
|
let r = J(n, t);
|
|
@@ -6672,7 +6784,7 @@ var Ci = 120, wi = 200, Ti = [
|
|
|
6672
6784
|
let a = w("div", { class: "an-size-popover-title" });
|
|
6673
6785
|
i.appendChild(a);
|
|
6674
6786
|
let o = w("div", { class: "an-context-color-palette" });
|
|
6675
|
-
|
|
6787
|
+
Fi.forEach((e) => {
|
|
6676
6788
|
let n = w("div", {
|
|
6677
6789
|
class: "an-context-color-swatch",
|
|
6678
6790
|
title: e
|
|
@@ -6792,7 +6904,7 @@ var Ci = 120, wi = 200, Ti = [
|
|
|
6792
6904
|
if (!t) return;
|
|
6793
6905
|
let n = this._getCell();
|
|
6794
6906
|
if (!n) return;
|
|
6795
|
-
let r =
|
|
6907
|
+
let r = Ai(n);
|
|
6796
6908
|
if (r === -1) return;
|
|
6797
6909
|
let i = t.querySelector("tbody") || t, a = Array.from(i.querySelectorAll(":scope > tr"));
|
|
6798
6910
|
a.length < 2 || (a.sort((t, n) => {
|
|
@@ -6817,13 +6929,23 @@ var Ci = 120, wi = 200, Ti = [
|
|
|
6817
6929
|
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
6930
|
i.href = r, i.download = "table.csv", i.style.display = "none", document.body.appendChild(i), i.click(), i.remove(), URL.revokeObjectURL(r);
|
|
6819
6931
|
}
|
|
6820
|
-
}
|
|
6932
|
+
};
|
|
6933
|
+
//#endregion
|
|
6934
|
+
//#region src/js/core/externalAsset.js
|
|
6935
|
+
function Li(e, t = {}) {
|
|
6936
|
+
t.cspNonce && (e.nonce = t.cspNonce);
|
|
6937
|
+
let n = t.externalAssetCrossOrigin ?? "anonymous", r = t.externalAssetReferrerPolicy ?? "no-referrer";
|
|
6938
|
+
return n && (e.crossOrigin = n), r && (e.referrerPolicy = r), e;
|
|
6939
|
+
}
|
|
6940
|
+
//#endregion
|
|
6941
|
+
//#region src/js/module/CodeTooltip.js
|
|
6942
|
+
var Ri = 100, zi = 180, Bi = /language-(\S+)/, Vi = {
|
|
6821
6943
|
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
6944
|
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
6945
|
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
6946
|
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
6947
|
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
|
-
},
|
|
6948
|
+
}, Hi = [
|
|
6827
6949
|
["", "Plain text"],
|
|
6828
6950
|
["javascript", "JavaScript"],
|
|
6829
6951
|
["typescript", "TypeScript"],
|
|
@@ -6848,14 +6970,14 @@ var Ci = 120, wi = 200, Ti = [
|
|
|
6848
6970
|
["kotlin", "Kotlin"],
|
|
6849
6971
|
["swift", "Swift"]
|
|
6850
6972
|
];
|
|
6851
|
-
function
|
|
6973
|
+
function Ui(e, t) {
|
|
6852
6974
|
[...e.classList].forEach((t) => {
|
|
6853
6975
|
t.startsWith("language-") && e.classList.remove(t);
|
|
6854
6976
|
}), t && e.classList.add(`language-${t}`);
|
|
6855
6977
|
}
|
|
6856
|
-
var
|
|
6978
|
+
var Wi = class {
|
|
6857
6979
|
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;
|
|
6980
|
+
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
6981
|
}
|
|
6860
6982
|
initialize() {
|
|
6861
6983
|
this._el = this._buildTooltip(), document.body.appendChild(this._el), this._ensurePrism();
|
|
@@ -6873,7 +6995,7 @@ var Ni = class {
|
|
|
6873
6995
|
})), this;
|
|
6874
6996
|
}
|
|
6875
6997
|
destroy() {
|
|
6876
|
-
this._clearTimers(), this._disposers.forEach((e) => e()), this._disposers = [], this._el?.remove(), this._el = null;
|
|
6998
|
+
this._clearTimers(), this._asyncDisposers.forEach((e) => e()), this._asyncDisposers = [], this._disposers.forEach((e) => e()), this._disposers = [], this._el?.remove(), this._el = null;
|
|
6877
6999
|
}
|
|
6878
7000
|
_buildTooltip() {
|
|
6879
7001
|
let e = this.context.locale.tooltips.code, t = w("div", {
|
|
@@ -6885,10 +7007,10 @@ var Ni = class {
|
|
|
6885
7007
|
class: "an-code-lang-select",
|
|
6886
7008
|
title: e.syntaxLanguage,
|
|
6887
7009
|
"aria-label": e.syntaxAriaLabel
|
|
6888
|
-
}),
|
|
7010
|
+
}), Hi.forEach(([e, t]) => {
|
|
6889
7011
|
let n = w("option", { value: e });
|
|
6890
7012
|
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(
|
|
7013
|
+
}), 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
7014
|
}
|
|
6893
7015
|
_sep() {
|
|
6894
7016
|
return w("div", { class: "an-link-tooltip-sep" });
|
|
@@ -6904,12 +7026,12 @@ var Ni = class {
|
|
|
6904
7026
|
})), i;
|
|
6905
7027
|
}
|
|
6906
7028
|
_scheduleShow(e) {
|
|
6907
|
-
this._activePre
|
|
7029
|
+
(this._activePre !== e || this._el.style.display === "none") && (clearTimeout(this._hideTimer), this._hideTimer = null, clearTimeout(this._showTimer), this._showTimer = setTimeout(() => {
|
|
6908
7030
|
this._activePre = e, this._syncWrapBtn(), this._syncLineNumbersBtn(), this._syncLangSelect(), this._show(e);
|
|
6909
|
-
},
|
|
7031
|
+
}, Ri));
|
|
6910
7032
|
}
|
|
6911
7033
|
_scheduleHide() {
|
|
6912
|
-
clearTimeout(this._showTimer), this._showTimer = null, clearTimeout(this._hideTimer), this._hideTimer = setTimeout(() => this._hide(),
|
|
7034
|
+
clearTimeout(this._showTimer), this._showTimer = null, clearTimeout(this._hideTimer), this._hideTimer = setTimeout(() => this._hide(), zi);
|
|
6913
7035
|
}
|
|
6914
7036
|
_show(e) {
|
|
6915
7037
|
this._el.style.display = "flex", this._positionNear(e);
|
|
@@ -6936,7 +7058,7 @@ var Ni = class {
|
|
|
6936
7058
|
}
|
|
6937
7059
|
_syncLangSelect() {
|
|
6938
7060
|
if (!this._activePre || !this._langSelect) return;
|
|
6939
|
-
let e = this._activePre.querySelector("code"), t = this._activePre.dataset.language || "", n = e && (
|
|
7061
|
+
let e = this._activePre.querySelector("code"), t = this._activePre.dataset.language || "", n = e && (Bi.exec(e.className) || [])[1] || "";
|
|
6940
7062
|
this._langSelect.value = t || n || "";
|
|
6941
7063
|
}
|
|
6942
7064
|
_copyCode() {
|
|
@@ -6979,9 +7101,9 @@ var Ni = class {
|
|
|
6979
7101
|
let e = this._activePre;
|
|
6980
7102
|
if (!e) return;
|
|
6981
7103
|
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)),
|
|
7104
|
+
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
7105
|
let i = () => {
|
|
6984
|
-
r.querySelectorAll("br").forEach((e) => e.replaceWith("\n")), n.Prism.highlightElement(r), this.context.invoke("editor.afterCommand");
|
|
7106
|
+
!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
7107
|
};
|
|
6986
7108
|
if (t) {
|
|
6987
7109
|
if (n.Prism !== void 0) {
|
|
@@ -6991,22 +7113,26 @@ var Ni = class {
|
|
|
6991
7113
|
}
|
|
6992
7114
|
this._loadPrismComponent(t, i);
|
|
6993
7115
|
return;
|
|
6994
|
-
}
|
|
6995
|
-
|
|
7116
|
+
}
|
|
7117
|
+
if (this._prismScript) {
|
|
7118
|
+
this._onScriptLoad(this._prismScript, () => {
|
|
6996
7119
|
n.Prism.languages[t] ? i() : this._loadPrismComponent(t, i);
|
|
6997
|
-
}
|
|
7120
|
+
});
|
|
6998
7121
|
return;
|
|
6999
7122
|
}
|
|
7000
7123
|
}
|
|
7001
7124
|
this.context.invoke("editor.afterCommand");
|
|
7002
7125
|
}
|
|
7126
|
+
_cdnBase() {
|
|
7127
|
+
return String(this.context.options.codeHighlightCDN ?? "").replace(/\/+$/, "");
|
|
7128
|
+
}
|
|
7003
7129
|
_ensurePrism() {
|
|
7004
7130
|
let e = globalThis;
|
|
7005
7131
|
if (!this.context.options.codeHighlight || e.Prism) return;
|
|
7006
|
-
let t = this.
|
|
7132
|
+
let t = this._cdnBase(), n = `${t}/themes/prism-tomorrow.min.css`, r = `${t}/prism.min.js`;
|
|
7007
7133
|
if (!document.querySelector(`link[href="${n}"]`)) {
|
|
7008
7134
|
let e = document.createElement("link");
|
|
7009
|
-
e.rel = "stylesheet", e.href = n, document.head.appendChild(e);
|
|
7135
|
+
e.rel = "stylesheet", e.href = n, Li(e, this.context.options), document.head.appendChild(e);
|
|
7010
7136
|
}
|
|
7011
7137
|
let i = document.querySelector(`script[src="${r}"]`);
|
|
7012
7138
|
if (i) {
|
|
@@ -7014,21 +7140,33 @@ var Ni = class {
|
|
|
7014
7140
|
return;
|
|
7015
7141
|
}
|
|
7016
7142
|
let a = document.createElement("script");
|
|
7017
|
-
a.dataset.manual = "", a.src = r, this._prismScript = a,
|
|
7143
|
+
a.dataset.manual = "", a.src = r, Li(a, this.context.options), this._prismScript = a, this._onScriptLoad(a, () => {
|
|
7018
7144
|
this._prismScript = null;
|
|
7019
|
-
}
|
|
7145
|
+
}), document.head.appendChild(a);
|
|
7146
|
+
}
|
|
7147
|
+
_onScriptLoad(e, t) {
|
|
7148
|
+
let n = () => {
|
|
7149
|
+
this.context._alive && t();
|
|
7150
|
+
};
|
|
7151
|
+
e.addEventListener("load", n, { once: !0 }), this._asyncDisposers.push(() => e.removeEventListener("load", n));
|
|
7020
7152
|
}
|
|
7021
7153
|
_loadPrismComponent(e, t) {
|
|
7022
|
-
let n = globalThis, r = `${this.
|
|
7154
|
+
let n = globalThis, r = `${this._cdnBase()}/components/prism-${e}.min.js`;
|
|
7023
7155
|
if (document.querySelector(`script[src="${r}"]`)) {
|
|
7024
7156
|
let r = setInterval(() => {
|
|
7157
|
+
if (!this.context._alive) {
|
|
7158
|
+
clearInterval(r);
|
|
7159
|
+
return;
|
|
7160
|
+
}
|
|
7025
7161
|
n.Prism?.languages[e] && (clearInterval(r), t());
|
|
7026
|
-
}, 50);
|
|
7027
|
-
|
|
7162
|
+
}, 50), i = setTimeout(() => clearInterval(r), 3e3);
|
|
7163
|
+
this._asyncDisposers.push(() => {
|
|
7164
|
+
clearInterval(r), clearTimeout(i);
|
|
7165
|
+
});
|
|
7028
7166
|
return;
|
|
7029
7167
|
}
|
|
7030
7168
|
let i = document.createElement("script");
|
|
7031
|
-
i.src = r, i.
|
|
7169
|
+
i.src = r, Li(i, this.context.options), this._onScriptLoad(i, t), document.head.appendChild(i);
|
|
7032
7170
|
}
|
|
7033
7171
|
_toParagraph() {
|
|
7034
7172
|
let e = this._activePre;
|
|
@@ -7042,21 +7180,21 @@ var Ni = class {
|
|
|
7042
7180
|
let e = this._activePre;
|
|
7043
7181
|
e && (this._hide(), e.remove(), this.context.invoke("editor.afterCommand"));
|
|
7044
7182
|
}
|
|
7045
|
-
},
|
|
7046
|
-
function
|
|
7047
|
-
return
|
|
7183
|
+
}, Gi = null, Ki = null;
|
|
7184
|
+
function qi() {
|
|
7185
|
+
return Gi ? Promise.resolve(Gi) : (Ki ??= import("./emoji-data-BDQX5kh-.js").then((e) => (Gi = {
|
|
7048
7186
|
EMOJI_CATS: e.EMOJI_CATS,
|
|
7049
7187
|
EMOJI_LIST: e.EMOJI_LIST
|
|
7050
|
-
},
|
|
7188
|
+
}, Gi)), Ki);
|
|
7051
7189
|
}
|
|
7052
|
-
var
|
|
7190
|
+
var Ji = class extends W {
|
|
7053
7191
|
_activeCat = "all";
|
|
7054
7192
|
initialize() {
|
|
7055
7193
|
return this;
|
|
7056
7194
|
}
|
|
7057
7195
|
async show() {
|
|
7058
7196
|
if (this._saveRange(), !this._dialog) {
|
|
7059
|
-
let { EMOJI_CATS: e, EMOJI_LIST: t } = await
|
|
7197
|
+
let { EMOJI_CATS: e, EMOJI_LIST: t } = await qi();
|
|
7060
7198
|
this._dialog || (this._cats = e, this._list = t, this._dialog = this._buildDialog(), document.body.appendChild(this._dialog));
|
|
7061
7199
|
}
|
|
7062
7200
|
this._activeCat = "all", this._searchInput.value = "", this._updateCatTabs(), this._filterEmojis("", "all"), this._open();
|
|
@@ -7113,7 +7251,7 @@ var Li = class extends W {
|
|
|
7113
7251
|
type: "button",
|
|
7114
7252
|
class: "an-btn"
|
|
7115
7253
|
});
|
|
7116
|
-
p.textContent = e.cancelBtn, f.appendChild(p), n.append(r, c, l, d, f), t.appendChild(n),
|
|
7254
|
+
p.textContent = e.cancelBtn, f.appendChild(p), n.append(r, c, l, d, f), t.appendChild(n), ge(r, n);
|
|
7117
7255
|
let m = E(s, "click", () => this._close()), h = E(p, "click", () => this._close()), g = E(t, "click", (e) => {
|
|
7118
7256
|
e.target === t && this._close();
|
|
7119
7257
|
}), _ = E(c, "input", () => this._filterEmojis(c.value, this._activeCat)), v = E(l, "click", (e) => {
|
|
@@ -7149,14 +7287,14 @@ var Li = class extends W {
|
|
|
7149
7287
|
let s = document.createTextNode(e);
|
|
7150
7288
|
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
7289
|
}
|
|
7152
|
-
},
|
|
7153
|
-
function
|
|
7154
|
-
return
|
|
7290
|
+
}, Yi = "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css", Xi = null, Zi = null;
|
|
7291
|
+
function Qi() {
|
|
7292
|
+
return Xi ? Promise.resolve(Xi) : (Zi ??= import("./icon-data-V0Xqv-wX.js").then((e) => (Xi = {
|
|
7155
7293
|
ICON_CATEGORIES: e.ICON_CATEGORIES,
|
|
7156
7294
|
ICON_LIST: e.ICON_LIST
|
|
7157
|
-
},
|
|
7295
|
+
}, Xi)), Zi);
|
|
7158
7296
|
}
|
|
7159
|
-
var
|
|
7297
|
+
var $i = class extends W {
|
|
7160
7298
|
_selectedIcon = null;
|
|
7161
7299
|
_activeCat = "all";
|
|
7162
7300
|
initialize() {
|
|
@@ -7164,16 +7302,16 @@ var Hi = class extends W {
|
|
|
7164
7302
|
}
|
|
7165
7303
|
_ensureFontAwesome() {
|
|
7166
7304
|
if (this.context.options.fontAwesomeAutoInject === !1) return;
|
|
7167
|
-
let e = this.context.options.fontAwesomeCDN ||
|
|
7305
|
+
let e = this.context.options.fontAwesomeCDN || Yi;
|
|
7168
7306
|
if (!e || document.getElementById("an-fontawesome-css")) return;
|
|
7169
7307
|
let t = Array.from(document.querySelectorAll("link[rel=\"stylesheet\"]")).map((e) => e.href || "").join(" ");
|
|
7170
7308
|
if (/fontawesome|font-awesome/.test(t) || document.querySelector(".fa-solid, .fas, .far, .fab")) return;
|
|
7171
7309
|
let n = document.createElement("link");
|
|
7172
|
-
n.id = "an-fontawesome-css", n.rel = "stylesheet", n.href = e, n
|
|
7310
|
+
n.id = "an-fontawesome-css", n.rel = "stylesheet", n.href = e, Li(n, this.context.options), document.head.appendChild(n);
|
|
7173
7311
|
}
|
|
7174
7312
|
async show() {
|
|
7175
7313
|
if (this._saveRange(), this._ensureFontAwesome(), !this._dialog) {
|
|
7176
|
-
let { ICON_CATEGORIES: e, ICON_LIST: t } = await
|
|
7314
|
+
let { ICON_CATEGORIES: e, ICON_LIST: t } = await Qi();
|
|
7177
7315
|
this._dialog || (this._cats = e, this._list = t, this._dialog = this._buildDialog(), document.body.appendChild(this._dialog));
|
|
7178
7316
|
}
|
|
7179
7317
|
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 +7417,7 @@ var Hi = class extends W {
|
|
|
7279
7417
|
type: "button",
|
|
7280
7418
|
class: "an-btn"
|
|
7281
7419
|
});
|
|
7282
|
-
C.textContent = e.cancelBtn, te.append(S, C), this._insertBtn = S, n.append(r, c, l, d, f, x, te), t.appendChild(n),
|
|
7420
|
+
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
7421
|
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
7422
|
e.target === t && this._close();
|
|
7285
7423
|
}), T = E(c, "input", () => this._filterIcons(c.value, this._activeCat)), oe = E(l, "click", (e) => {
|
|
@@ -7330,14 +7468,14 @@ var Hi = class extends W {
|
|
|
7330
7468
|
let l = c.startContainer, u = (l.nodeType === 1 ? l : l.parentElement)?.closest("td, th");
|
|
7331
7469
|
c.deleteContents(), u?.isConnected && !u.contains(c.startContainer) && (c.setStart(u, 0), c.collapse(!0)), c.insertNode(i);
|
|
7332
7470
|
let d = i.nextSibling;
|
|
7333
|
-
d?.nodeType === Node.TEXT_NODE ? d.textContent
|
|
7471
|
+
d?.nodeType === Node.TEXT_NODE ? d.textContent || (d.textContent = "") : (d = document.createTextNode(""), i.parentNode.insertBefore(d, i.nextSibling));
|
|
7334
7472
|
let f = +!!(d.textContent || "").startsWith(""), p = document.createRange();
|
|
7335
7473
|
p.setStart(d, Math.min(f, d.textContent.length)), p.collapse(!0), s && (s.removeAllRanges(), s.addRange(p)), this._close(), o.focus(), s && (s.removeAllRanges(), s.addRange(p)), this.context.invoke("editor.afterCommand");
|
|
7336
7474
|
}
|
|
7337
7475
|
_close() {
|
|
7338
7476
|
this._selectedIcon = null, super._close();
|
|
7339
7477
|
}
|
|
7340
|
-
},
|
|
7478
|
+
}, ea = [
|
|
7341
7479
|
{
|
|
7342
7480
|
category: "Text Formatting",
|
|
7343
7481
|
items: [
|
|
@@ -7410,12 +7548,12 @@ var Hi = class extends W {
|
|
|
7410
7548
|
action: "Show this keyboard shortcuts dialog"
|
|
7411
7549
|
}]
|
|
7412
7550
|
}
|
|
7413
|
-
],
|
|
7551
|
+
], 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
7552
|
show() {
|
|
7415
7553
|
this._open();
|
|
7416
7554
|
}
|
|
7417
7555
|
_buildDialog() {
|
|
7418
|
-
let e = this.context.locale.shortcutsDialog, { overlay: t, box: n } = this._buildDialogShell(e.ariaLabel,
|
|
7556
|
+
let e = this.context.locale.shortcutsDialog, { overlay: t, box: n } = this._buildDialogShell(e.ariaLabel, ta, e.title);
|
|
7419
7557
|
n.classList.add("an-shortcuts-box");
|
|
7420
7558
|
let r = w("button", {
|
|
7421
7559
|
type: "button",
|
|
@@ -7423,7 +7561,7 @@ var Hi = class extends W {
|
|
|
7423
7561
|
"aria-label": e.close,
|
|
7424
7562
|
style: "margin-left:auto"
|
|
7425
7563
|
});
|
|
7426
|
-
r.textContent = "×", this._closeBtn = r, this._firstInput = r, n.querySelector(".an-dialog-header").appendChild(r), (this.context.locale.shortcutsDialog.shortcuts ||
|
|
7564
|
+
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
7565
|
let r = w("div", { class: "an-shortcuts-cat" });
|
|
7428
7566
|
r.textContent = e, n.appendChild(r);
|
|
7429
7567
|
let i = w("div", { class: "an-shortcuts-table" });
|
|
@@ -7437,7 +7575,7 @@ var Hi = class extends W {
|
|
|
7437
7575
|
let i = E(r, "click", () => this._close());
|
|
7438
7576
|
return this._disposers.push(i), t;
|
|
7439
7577
|
}
|
|
7440
|
-
},
|
|
7578
|
+
}, ra = class extends W {
|
|
7441
7579
|
constructor(e) {
|
|
7442
7580
|
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
7581
|
}
|
|
@@ -7455,7 +7593,7 @@ var Hi = class extends W {
|
|
|
7455
7593
|
this._findInput && this._findInput.focus();
|
|
7456
7594
|
return;
|
|
7457
7595
|
}
|
|
7458
|
-
this._dialog.style.display = "flex", this._removeTrap &&= (this._removeTrap(), null), this._removeTrap =
|
|
7596
|
+
this._dialog.style.display = "flex", this._removeTrap &&= (this._removeTrap(), null), this._removeTrap = he(this._dialog, () => this._close());
|
|
7459
7597
|
}
|
|
7460
7598
|
}
|
|
7461
7599
|
_close() {
|
|
@@ -7553,7 +7691,7 @@ var Hi = class extends W {
|
|
|
7553
7691
|
});
|
|
7554
7692
|
b.textContent = e.replaceAllBtn, _.append(v, y, b), n.appendChild(_);
|
|
7555
7693
|
let x = w("div", { class: "an-fr-replace-actions" });
|
|
7556
|
-
x.style.display = "none", n.appendChild(x), t.appendChild(n),
|
|
7694
|
+
x.style.display = "none", n.appendChild(x), t.appendChild(n), ge(r, n);
|
|
7557
7695
|
let ee = E(s, "click", () => this._close()), te = E(t, "click", (e) => {
|
|
7558
7696
|
e.target === t && this._close();
|
|
7559
7697
|
}), S = E(l, "input", () => this._onSearch()), C = E(d, "click", () => {
|
|
@@ -7680,8 +7818,8 @@ var Hi = class extends W {
|
|
|
7680
7818
|
this._counterEl.textContent = e ? this.context.locale.findReplace.noResults : "";
|
|
7681
7819
|
} else this._counterEl.textContent = `${this._currentIndex + 1} / ${e}`;
|
|
7682
7820
|
}
|
|
7683
|
-
}, Y = 20,
|
|
7684
|
-
function
|
|
7821
|
+
}, Y = 20, ia = "#3b82f6", X = (e, t, n) => Math.min(Math.max(e, t), n);
|
|
7822
|
+
function aa(e, t, n, r) {
|
|
7685
7823
|
return new Promise((i) => {
|
|
7686
7824
|
let a = (e) => {
|
|
7687
7825
|
let a = document.createElement("canvas");
|
|
@@ -7705,7 +7843,7 @@ function Ji(e, t, n, r) {
|
|
|
7705
7843
|
o.crossOrigin = "anonymous", o.onload = () => a(o), o.onerror = () => i(null), o.src = e.src + (e.src.includes("?") ? "&" : "?") + "_an=" + Date.now();
|
|
7706
7844
|
});
|
|
7707
7845
|
}
|
|
7708
|
-
var
|
|
7846
|
+
var oa = class {
|
|
7709
7847
|
constructor(e) {
|
|
7710
7848
|
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
7849
|
}
|
|
@@ -7736,7 +7874,7 @@ var Yi = class {
|
|
|
7736
7874
|
t.className = "an-crop-box", t.style.cssText = `
|
|
7737
7875
|
position:fixed; z-index:10101;
|
|
7738
7876
|
box-sizing:border-box;
|
|
7739
|
-
border:2px solid ${
|
|
7877
|
+
border:2px solid ${ia};
|
|
7740
7878
|
cursor:move;
|
|
7741
7879
|
outline: none;
|
|
7742
7880
|
`;
|
|
@@ -7801,7 +7939,7 @@ var Yi = class {
|
|
|
7801
7939
|
"position:absolute",
|
|
7802
7940
|
"width:10px",
|
|
7803
7941
|
"height:10px",
|
|
7804
|
-
`background:${
|
|
7942
|
+
`background:${ia}`,
|
|
7805
7943
|
"border:2px solid #fff",
|
|
7806
7944
|
"border-radius:2px",
|
|
7807
7945
|
"box-sizing:border-box",
|
|
@@ -7818,7 +7956,7 @@ var Yi = class {
|
|
|
7818
7956
|
}, e);
|
|
7819
7957
|
}, { passive: !1 })), this._handles[e] = i, t.appendChild(i);
|
|
7820
7958
|
}), this._disposers.push(E(t, "mousedown", (e) => {
|
|
7821
|
-
e.target.classList.contains("an-crop-handle") || e.target
|
|
7959
|
+
e.target.classList.contains("an-crop-handle") || (e.target === t || e.target === n) && (e.preventDefault(), e.stopPropagation(), this._startBoxMove(e));
|
|
7822
7960
|
}), E(t, "touchstart", (e) => {
|
|
7823
7961
|
if (e.target.classList.contains("an-crop-handle") || e.target !== t && e.target !== n) return;
|
|
7824
7962
|
e.preventDefault(), e.stopPropagation();
|
|
@@ -7835,7 +7973,7 @@ var Yi = class {
|
|
|
7835
7973
|
let a = this._makeToolbarBtn("✓ Crop", "#22c55e", () => this._confirm()), o = this._makeToolbarBtn("✕ Cancel", "#94a3b8", () => this._close(!1)), s = document.createElement("label");
|
|
7836
7974
|
s.style.cssText = "color:#94a3b8;font-size:11px;cursor:pointer;display:flex;align-items:center;gap:4px;";
|
|
7837
7975
|
let c = document.createElement("input");
|
|
7838
|
-
c.type = "checkbox", c.style.accentColor =
|
|
7976
|
+
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
7977
|
}
|
|
7840
7978
|
_makeToolbarBtn(e, t, n) {
|
|
7841
7979
|
let r = document.createElement("button");
|
|
@@ -7920,7 +8058,7 @@ var Yi = class {
|
|
|
7920
8058
|
this._close(!1);
|
|
7921
8059
|
return;
|
|
7922
8060
|
}
|
|
7923
|
-
let f = await
|
|
8061
|
+
let f = await aa(e, {
|
|
7924
8062
|
x: c,
|
|
7925
8063
|
y: l,
|
|
7926
8064
|
width: u,
|
|
@@ -7964,7 +8102,7 @@ var Yi = class {
|
|
|
7964
8102
|
e?.remove();
|
|
7965
8103
|
}), 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
8104
|
}
|
|
7967
|
-
},
|
|
8105
|
+
}, sa = class {
|
|
7968
8106
|
constructor(e) {
|
|
7969
8107
|
this.context = e, this.options = e.options, this._banner = null;
|
|
7970
8108
|
}
|
|
@@ -8017,7 +8155,7 @@ var Yi = class {
|
|
|
8017
8155
|
_removeBanner() {
|
|
8018
8156
|
this._banner?.remove(), this._banner = null;
|
|
8019
8157
|
}
|
|
8020
|
-
},
|
|
8158
|
+
}, ca = class {
|
|
8021
8159
|
constructor(e) {
|
|
8022
8160
|
this.context = e, this.options = e.options, this._disposers = [];
|
|
8023
8161
|
}
|
|
@@ -8163,7 +8301,7 @@ var Yi = class {
|
|
|
8163
8301
|
break;
|
|
8164
8302
|
}
|
|
8165
8303
|
}
|
|
8166
|
-
},
|
|
8304
|
+
}, la = [
|
|
8167
8305
|
"#000000",
|
|
8168
8306
|
"#434343",
|
|
8169
8307
|
"#666666",
|
|
@@ -8188,7 +8326,7 @@ var Yi = class {
|
|
|
8188
8326
|
"#c9daf8",
|
|
8189
8327
|
"#d9d2e9",
|
|
8190
8328
|
"#ead1dc"
|
|
8191
|
-
],
|
|
8329
|
+
], 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
8330
|
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
8331
|
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
8332
|
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 +8336,7 @@ var Yi = class {
|
|
|
8198
8336
|
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
8337
|
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
8338
|
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
|
-
},
|
|
8339
|
+
}, fa = {
|
|
8202
8340
|
bold: (e) => e.invoke("editor.bold"),
|
|
8203
8341
|
italic: (e) => e.invoke("editor.italic"),
|
|
8204
8342
|
underline: (e) => e.invoke("editor.underline"),
|
|
@@ -8219,115 +8357,115 @@ var Yi = class {
|
|
|
8219
8357
|
e.invoke("editor.afterCommand");
|
|
8220
8358
|
},
|
|
8221
8359
|
inlineCode: (e) => e.invoke("editor.inlineCode")
|
|
8222
|
-
},
|
|
8360
|
+
}, pa = {
|
|
8223
8361
|
bold: () => document.queryCommandState("bold"),
|
|
8224
8362
|
italic: () => document.queryCommandState("italic"),
|
|
8225
8363
|
underline: () => document.queryCommandState("underline"),
|
|
8226
8364
|
strikethrough: () => document.queryCommandState("strikeThrough")
|
|
8227
|
-
},
|
|
8365
|
+
}, ma = {
|
|
8228
8366
|
foreColor: !0,
|
|
8229
8367
|
hiliteColor: !0
|
|
8230
|
-
},
|
|
8368
|
+
}, ha = [
|
|
8231
8369
|
{
|
|
8232
8370
|
name: "editor",
|
|
8233
|
-
Class:
|
|
8371
|
+
Class: Yr
|
|
8234
8372
|
},
|
|
8235
8373
|
{
|
|
8236
8374
|
name: "toolbar",
|
|
8237
|
-
Class:
|
|
8375
|
+
Class: ei
|
|
8238
8376
|
},
|
|
8239
8377
|
{
|
|
8240
8378
|
name: "statusbar",
|
|
8241
|
-
Class:
|
|
8379
|
+
Class: ni
|
|
8242
8380
|
},
|
|
8243
8381
|
{
|
|
8244
8382
|
name: "clipboard",
|
|
8245
|
-
Class:
|
|
8383
|
+
Class: ri
|
|
8246
8384
|
},
|
|
8247
8385
|
{
|
|
8248
8386
|
name: "placeholder",
|
|
8249
|
-
Class:
|
|
8387
|
+
Class: ui
|
|
8250
8388
|
},
|
|
8251
8389
|
{
|
|
8252
8390
|
name: "contextMenu",
|
|
8253
|
-
Class:
|
|
8391
|
+
Class: si
|
|
8254
8392
|
},
|
|
8255
8393
|
{
|
|
8256
8394
|
name: "codeview",
|
|
8257
|
-
Class:
|
|
8395
|
+
Class: di
|
|
8258
8396
|
},
|
|
8259
8397
|
{
|
|
8260
8398
|
name: "fullscreen",
|
|
8261
|
-
Class:
|
|
8399
|
+
Class: fi
|
|
8262
8400
|
},
|
|
8263
8401
|
{
|
|
8264
8402
|
name: "linkDialog",
|
|
8265
|
-
Class:
|
|
8403
|
+
Class: mi
|
|
8266
8404
|
},
|
|
8267
8405
|
{
|
|
8268
8406
|
name: "imageDialog",
|
|
8269
|
-
Class:
|
|
8407
|
+
Class: gi
|
|
8270
8408
|
},
|
|
8271
8409
|
{
|
|
8272
8410
|
name: "videoDialog",
|
|
8273
|
-
Class:
|
|
8411
|
+
Class: vi
|
|
8274
8412
|
},
|
|
8275
8413
|
{
|
|
8276
8414
|
name: "imageResizer",
|
|
8277
|
-
Class:
|
|
8415
|
+
Class: xi
|
|
8278
8416
|
},
|
|
8279
8417
|
{
|
|
8280
8418
|
name: "videoResizer",
|
|
8281
|
-
Class:
|
|
8419
|
+
Class: Si
|
|
8282
8420
|
},
|
|
8283
8421
|
{
|
|
8284
8422
|
name: "linkTooltip",
|
|
8285
|
-
Class:
|
|
8423
|
+
Class: Ei
|
|
8286
8424
|
},
|
|
8287
8425
|
{
|
|
8288
8426
|
name: "imageTooltip",
|
|
8289
|
-
Class:
|
|
8427
|
+
Class: Oi
|
|
8290
8428
|
},
|
|
8291
8429
|
{
|
|
8292
8430
|
name: "videoTooltip",
|
|
8293
|
-
Class:
|
|
8431
|
+
Class: ki
|
|
8294
8432
|
},
|
|
8295
8433
|
{
|
|
8296
8434
|
name: "tableTooltip",
|
|
8297
|
-
Class:
|
|
8435
|
+
Class: Ii
|
|
8298
8436
|
},
|
|
8299
8437
|
{
|
|
8300
8438
|
name: "codeTooltip",
|
|
8301
|
-
Class:
|
|
8439
|
+
Class: Wi
|
|
8302
8440
|
},
|
|
8303
8441
|
{
|
|
8304
8442
|
name: "emojiDialog",
|
|
8305
|
-
Class:
|
|
8443
|
+
Class: Ji
|
|
8306
8444
|
},
|
|
8307
8445
|
{
|
|
8308
8446
|
name: "iconDialog",
|
|
8309
|
-
Class:
|
|
8447
|
+
Class: $i
|
|
8310
8448
|
},
|
|
8311
8449
|
{
|
|
8312
8450
|
name: "shortcutsDialog",
|
|
8313
|
-
Class:
|
|
8451
|
+
Class: na
|
|
8314
8452
|
},
|
|
8315
8453
|
{
|
|
8316
8454
|
name: "findReplace",
|
|
8317
|
-
Class:
|
|
8455
|
+
Class: ra
|
|
8318
8456
|
},
|
|
8319
8457
|
{
|
|
8320
8458
|
name: "imageCropOverlay",
|
|
8321
|
-
Class:
|
|
8459
|
+
Class: oa
|
|
8322
8460
|
},
|
|
8323
8461
|
{
|
|
8324
8462
|
name: "autoSaveRestore",
|
|
8325
|
-
Class:
|
|
8463
|
+
Class: sa,
|
|
8326
8464
|
enabled: (e) => !!e.autoSaveRestore
|
|
8327
8465
|
},
|
|
8328
8466
|
{
|
|
8329
8467
|
name: "markdownShortcuts",
|
|
8330
|
-
Class:
|
|
8468
|
+
Class: ca,
|
|
8331
8469
|
enabled: (e) => e.markdownShortcuts !== !1
|
|
8332
8470
|
},
|
|
8333
8471
|
{
|
|
@@ -8362,23 +8500,23 @@ var Yi = class {
|
|
|
8362
8500
|
"removeFormat"
|
|
8363
8501
|
];
|
|
8364
8502
|
for (let n of t) {
|
|
8365
|
-
if (!
|
|
8503
|
+
if (!da[n]) continue;
|
|
8366
8504
|
let t = document.createElement("button");
|
|
8367
|
-
if (t.type = "button", t.dataset.name = n, t.setAttribute("aria-label", n),
|
|
8505
|
+
if (t.type = "button", t.dataset.name = n, t.setAttribute("aria-label", n), ma[n]) {
|
|
8368
8506
|
t.className = "an-bubble-btn an-bubble-btn--color";
|
|
8369
8507
|
let e = document.createElement("span");
|
|
8370
|
-
e.className = "an-bubble-btn-svg", e.innerHTML =
|
|
8508
|
+
e.className = "an-bubble-btn-svg", e.innerHTML = da[n];
|
|
8371
8509
|
let r = document.createElement("span");
|
|
8372
8510
|
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 =
|
|
8511
|
+
} else t.className = "an-bubble-btn", t.innerHTML = da[n];
|
|
8374
8512
|
t.addEventListener("mousedown", (e) => {
|
|
8375
8513
|
e.preventDefault();
|
|
8376
8514
|
}), t.addEventListener("click", (e) => {
|
|
8377
|
-
if (e.preventDefault(), e.stopPropagation(),
|
|
8515
|
+
if (e.preventDefault(), e.stopPropagation(), ma[n]) {
|
|
8378
8516
|
this._openColorPicker(n, t);
|
|
8379
8517
|
return;
|
|
8380
8518
|
}
|
|
8381
|
-
this.context.invoke("editor.focus"),
|
|
8519
|
+
this.context.invoke("editor.focus"), fa[n] && fa[n](this.context), this._syncActive();
|
|
8382
8520
|
}), e.appendChild(t);
|
|
8383
8521
|
}
|
|
8384
8522
|
document.body.appendChild(e), this._el = e, this._btnCache = Array.from(e.querySelectorAll(".an-bubble-btn"));
|
|
@@ -8387,7 +8525,7 @@ var Yi = class {
|
|
|
8387
8525
|
let e = document.createElement("div");
|
|
8388
8526
|
e.className = "an-bubble-color-picker", e.style.display = "none", e.addEventListener("mousedown", (e) => e.preventDefault());
|
|
8389
8527
|
let t = document.createElement("div");
|
|
8390
|
-
t.className = "an-context-color-palette",
|
|
8528
|
+
t.className = "an-context-color-palette", la.forEach((e) => {
|
|
8391
8529
|
let n = document.createElement("div");
|
|
8392
8530
|
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
8531
|
t.stopPropagation(), this._applyColor(this._pickerType, e);
|
|
@@ -8455,7 +8593,7 @@ var Yi = class {
|
|
|
8455
8593
|
}
|
|
8456
8594
|
_syncActive() {
|
|
8457
8595
|
this._btnCache && this._btnCache.forEach((e) => {
|
|
8458
|
-
let t =
|
|
8596
|
+
let t = pa[e.dataset.name];
|
|
8459
8597
|
e.classList.toggle("an-active", !!t?.());
|
|
8460
8598
|
});
|
|
8461
8599
|
}
|
|
@@ -8631,15 +8769,17 @@ var Yi = class {
|
|
|
8631
8769
|
}, this._cfg.debounce);
|
|
8632
8770
|
}
|
|
8633
8771
|
_onKeydown(e) {
|
|
8634
|
-
if (!(!this._cfg || !this._open))
|
|
8635
|
-
e.
|
|
8636
|
-
|
|
8637
|
-
|
|
8638
|
-
|
|
8639
|
-
e.
|
|
8640
|
-
|
|
8641
|
-
|
|
8642
|
-
|
|
8772
|
+
if (!(!this._cfg || !this._open)) {
|
|
8773
|
+
if (e.key === "ArrowDown") {
|
|
8774
|
+
e.preventDefault();
|
|
8775
|
+
let t = (this._activeIndex + 1) % this._items.length;
|
|
8776
|
+
this._highlightItem(t);
|
|
8777
|
+
} else if (e.key === "ArrowUp") {
|
|
8778
|
+
e.preventDefault();
|
|
8779
|
+
let t = (this._activeIndex - 1 + this._items.length) % this._items.length;
|
|
8780
|
+
this._highlightItem(t);
|
|
8781
|
+
} else e.key === "Enter" || e.key === "Tab" ? this._activeIndex >= 0 && (e.preventDefault(), this._select(this._activeIndex)) : e.key === "Escape" && this._hideDropdown();
|
|
8782
|
+
}
|
|
8643
8783
|
}
|
|
8644
8784
|
_onDocClick(e) {
|
|
8645
8785
|
this._open && (this._dropdown?.contains(e.target) || this._hideDropdown());
|
|
@@ -8845,13 +8985,15 @@ var Yi = class {
|
|
|
8845
8985
|
this._textNode = e.textNode, this._triggerOffset = e.triggerOffset, this._query = e.query, this._caretRect = this._captureCaretRect(e.textNode, e.triggerOffset), this._open ? (this._filterAndRender(), this._position()) : this._open_();
|
|
8846
8986
|
}
|
|
8847
8987
|
_onKeydown(e) {
|
|
8848
|
-
if (this._open)
|
|
8849
|
-
if (e.
|
|
8850
|
-
|
|
8851
|
-
|
|
8852
|
-
if (e.
|
|
8853
|
-
|
|
8854
|
-
|
|
8988
|
+
if (this._open) {
|
|
8989
|
+
if (e.key === "ArrowDown") {
|
|
8990
|
+
if (e.preventDefault(), this._filtered.length === 0) return;
|
|
8991
|
+
this._highlight((this._activeIndex + 1) % this._filtered.length);
|
|
8992
|
+
} else if (e.key === "ArrowUp") {
|
|
8993
|
+
if (e.preventDefault(), this._filtered.length === 0) return;
|
|
8994
|
+
this._highlight((this._activeIndex - 1 + this._filtered.length) % this._filtered.length);
|
|
8995
|
+
} else e.key === "Enter" || e.key === "Tab" ? this._activeIndex >= 0 && (e.preventDefault(), this._select(this._activeIndex)) : e.key === "Escape" && (e.preventDefault(), this._close());
|
|
8996
|
+
}
|
|
8855
8997
|
}
|
|
8856
8998
|
_onDocClick(e) {
|
|
8857
8999
|
this._open && (this._menu?.contains(e.target) || this._close());
|
|
@@ -8891,42 +9033,42 @@ var Yi = class {
|
|
|
8891
9033
|
},
|
|
8892
9034
|
enabled: (e) => e.slashMenu !== !1
|
|
8893
9035
|
}
|
|
8894
|
-
];
|
|
9036
|
+
], ga = "2.7.1";
|
|
8895
9037
|
//#endregion
|
|
8896
9038
|
//#region src/js/core/lists.js
|
|
8897
|
-
function
|
|
9039
|
+
function _a(e) {
|
|
8898
9040
|
return e[e.length - 1];
|
|
8899
9041
|
}
|
|
8900
|
-
function
|
|
9042
|
+
function va(e) {
|
|
8901
9043
|
return e[0];
|
|
8902
9044
|
}
|
|
8903
|
-
function
|
|
9045
|
+
function ya(e, t = 1) {
|
|
8904
9046
|
return e.slice(0, e.length - t);
|
|
8905
9047
|
}
|
|
8906
|
-
function
|
|
9048
|
+
function ba(e, t = 1) {
|
|
8907
9049
|
return e.slice(t);
|
|
8908
9050
|
}
|
|
8909
|
-
function
|
|
9051
|
+
function xa(e) {
|
|
8910
9052
|
return e.flat();
|
|
8911
9053
|
}
|
|
8912
|
-
function
|
|
9054
|
+
function Sa(e) {
|
|
8913
9055
|
return [...new Set(e)];
|
|
8914
9056
|
}
|
|
8915
|
-
function
|
|
9057
|
+
function Ca(e, t) {
|
|
8916
9058
|
let n = [];
|
|
8917
9059
|
for (let r = 0; r < e.length; r += t) n.push(e.slice(r, r + t));
|
|
8918
9060
|
return n;
|
|
8919
9061
|
}
|
|
8920
|
-
function
|
|
9062
|
+
function wa(e, t) {
|
|
8921
9063
|
return e.reduce((e, n) => {
|
|
8922
9064
|
let r = t(n);
|
|
8923
9065
|
return e[r] || (e[r] = []), e[r].push(n), e;
|
|
8924
9066
|
}, {});
|
|
8925
9067
|
}
|
|
8926
|
-
function
|
|
9068
|
+
function Ta(e, t) {
|
|
8927
9069
|
return e.every(t);
|
|
8928
9070
|
}
|
|
8929
|
-
function
|
|
9071
|
+
function Ea(e, t) {
|
|
8930
9072
|
return e.some(t);
|
|
8931
9073
|
}
|
|
8932
9074
|
//#endregion
|
|
@@ -8934,7 +9076,7 @@ function ma(e, t) {
|
|
|
8934
9076
|
function Q() {
|
|
8935
9077
|
return globalThis.navigator?.userAgent ?? "";
|
|
8936
9078
|
}
|
|
8937
|
-
var
|
|
9079
|
+
var Da = {
|
|
8938
9080
|
get isChrome() {
|
|
8939
9081
|
return /Chrome\//.test(Q()) && !/Edg\//.test(Q());
|
|
8940
9082
|
},
|
|
@@ -8959,17 +9101,19 @@ var ha = {
|
|
|
8959
9101
|
get modifierKey() {
|
|
8960
9102
|
return /Macintosh/.test(Q()) ? "metaKey" : "ctrlKey";
|
|
8961
9103
|
}
|
|
8962
|
-
},
|
|
9104
|
+
}, Oa = { ...k }, $ = /* @__PURE__ */ new WeakMap(), ka = {
|
|
8963
9105
|
create(e, t = {}) {
|
|
8964
|
-
let n =
|
|
9106
|
+
let n = Aa(e).map((e) => {
|
|
8965
9107
|
if ($.has(e)) return $.get(e);
|
|
8966
|
-
let n = new
|
|
8967
|
-
return n.
|
|
9108
|
+
let n = new On(e, t);
|
|
9109
|
+
return n._releaseInstance = () => {
|
|
9110
|
+
$.get(e) === n && $.delete(e);
|
|
9111
|
+
}, n.initialize(), $.set(e, n), n;
|
|
8968
9112
|
});
|
|
8969
9113
|
return n.length === 1 ? n[0] : n;
|
|
8970
9114
|
},
|
|
8971
9115
|
destroy(e) {
|
|
8972
|
-
|
|
9116
|
+
Aa(e).forEach((e) => {
|
|
8973
9117
|
let t = $.get(e);
|
|
8974
9118
|
t && (t.destroy(), $.delete(e));
|
|
8975
9119
|
});
|
|
@@ -8985,42 +9129,42 @@ var ha = {
|
|
|
8985
9129
|
Object.assign(k, e);
|
|
8986
9130
|
},
|
|
8987
9131
|
resetDefaults() {
|
|
8988
|
-
Object.keys(k).forEach((e) => delete k[e]), Object.assign(k,
|
|
9132
|
+
Object.keys(k).forEach((e) => delete k[e]), Object.assign(k, Oa);
|
|
8989
9133
|
},
|
|
8990
9134
|
registerModule(e, t) {
|
|
8991
|
-
|
|
9135
|
+
wn.set(e, t);
|
|
8992
9136
|
},
|
|
8993
9137
|
use(e, t = {}) {
|
|
8994
9138
|
if (!e || typeof e.name != "string") throw TypeError("[AutumnNote] AutumnNote.use: plugin must have a string `name` property.");
|
|
8995
|
-
return
|
|
9139
|
+
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
9140
|
plugin: e,
|
|
8997
9141
|
options: t
|
|
8998
9142
|
}), this);
|
|
8999
9143
|
},
|
|
9000
9144
|
hasPlugin(e) {
|
|
9001
|
-
return
|
|
9145
|
+
return Dn.has(e);
|
|
9002
9146
|
},
|
|
9003
9147
|
registerButton(e) {
|
|
9004
|
-
return
|
|
9148
|
+
return pt(e), this;
|
|
9005
9149
|
},
|
|
9006
9150
|
registerLocale(e, t) {
|
|
9007
|
-
return
|
|
9151
|
+
return rn(e, t), this;
|
|
9008
9152
|
},
|
|
9009
9153
|
registerSlashCommand(e) {
|
|
9010
9154
|
if (!e?.id || typeof e.run != "function") throw TypeError("[AutumnNote] Slash command requires an id and run(context) function.");
|
|
9011
9155
|
let t = k.slashCommands, n = t.findIndex((t) => t.id === e.id);
|
|
9012
9156
|
return n >= 0 ? t[n] = e : t.push(e), this;
|
|
9013
9157
|
},
|
|
9014
|
-
buttons:
|
|
9015
|
-
version:
|
|
9158
|
+
buttons: tn,
|
|
9159
|
+
version: ga
|
|
9016
9160
|
};
|
|
9017
|
-
function
|
|
9161
|
+
function Aa(e) {
|
|
9018
9162
|
return typeof e == "string" ? Array.from(document.querySelectorAll(e)) : e instanceof Element ? [e] : e instanceof NodeList || Array.isArray(e) ? Array.from(e) : [];
|
|
9019
9163
|
}
|
|
9020
9164
|
//#endregion
|
|
9021
9165
|
//#region src/js/index.js
|
|
9022
|
-
|
|
9166
|
+
En(ha);
|
|
9023
9167
|
//#endregion
|
|
9024
|
-
export {
|
|
9168
|
+
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
9169
|
|
|
9026
9170
|
//# sourceMappingURL=autumnnote.es.js.map
|