fable-editor 1.0.0 → 1.0.2
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/LICENSE +1 -1
- package/README.md +1 -1
- package/dist/angular/LICENSE +1 -1
- package/dist/angular/README.md +1 -1
- package/dist/angular/core/editor.d.ts +16 -0
- package/dist/angular/core/i18n.d.ts +6 -0
- package/dist/angular/esm2022/core/config.mjs +2 -2
- package/dist/angular/esm2022/core/editor.mjs +194 -6
- package/dist/angular/esm2022/core/i18n.mjs +15 -3
- package/dist/angular/esm2022/core/icons.mjs +6 -1
- package/dist/angular/fesm2022/fable-editor.mjs +213 -8
- package/dist/angular/fesm2022/fable-editor.mjs.map +1 -1
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/editor.css +142 -0
- package/dist/core/editor.d.ts +16 -0
- package/dist/core/editor.d.ts.map +1 -1
- package/dist/core/i18n.d.ts +6 -0
- package/dist/core/i18n.d.ts.map +1 -1
- package/dist/core/icons.d.ts.map +1 -1
- package/dist/core/index.cjs +3 -3
- package/dist/core/index.mjs +282 -174
- package/dist/react/index.cjs +12 -12
- package/dist/react/index.mjs +411 -306
- package/package.json +10 -2
- package/style.css +142 -0
package/dist/core/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const j = {
|
|
2
2
|
en: {
|
|
3
3
|
dir: "ltr",
|
|
4
4
|
file: "File",
|
|
@@ -133,7 +133,13 @@ const W = {
|
|
|
133
133
|
insertimg: "Insert",
|
|
134
134
|
dropimage: "Drop image here",
|
|
135
135
|
uploading: "Uploading…",
|
|
136
|
-
uploadfailed: "Upload failed — click to retry"
|
|
136
|
+
uploadfailed: "Upload failed — click to retry",
|
|
137
|
+
template: "Templates",
|
|
138
|
+
tplimgleft: "Image left, text right",
|
|
139
|
+
tplimgright: "Image right, text left",
|
|
140
|
+
tplimgtop: "Image top, text below",
|
|
141
|
+
tplimgcenter: "Text top, image center",
|
|
142
|
+
deltemplate: "Delete template"
|
|
137
143
|
},
|
|
138
144
|
ar: {
|
|
139
145
|
dir: "rtl",
|
|
@@ -269,13 +275,19 @@ const W = {
|
|
|
269
275
|
insertimg: "إدراج",
|
|
270
276
|
dropimage: "أسقط الصورة هنا",
|
|
271
277
|
uploading: "جارٍ الرفع…",
|
|
272
|
-
uploadfailed: "فشل الرفع — انقر لإعادة المحاولة"
|
|
278
|
+
uploadfailed: "فشل الرفع — انقر لإعادة المحاولة",
|
|
279
|
+
template: "قوالب",
|
|
280
|
+
tplimgleft: "صورة يسار، نص يمين",
|
|
281
|
+
tplimgright: "صورة يمين، نص يسار",
|
|
282
|
+
tplimgtop: "صورة أعلى، نص أسفل",
|
|
283
|
+
tplimgcenter: "نص أعلى، صورة وسط",
|
|
284
|
+
deltemplate: "حذف القالب"
|
|
273
285
|
}
|
|
274
286
|
};
|
|
275
287
|
function B(p) {
|
|
276
|
-
return
|
|
288
|
+
return j[p];
|
|
277
289
|
}
|
|
278
|
-
const
|
|
290
|
+
const X = "undo redo | preview print | importword revhistory | fontfamily fontsize | fontsizeincrease fontsizedecrease | bold italic underline strikethrough | forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist | outdent indent | link blockquote changecase lineheight wordspacing | removeformat | blocks | ltr rtl | quickimage quicktable template charmap | fullscreen sourcecode", _ = "file edit view insert format tools table help", Q = [
|
|
279
291
|
["Andale Mono", "andale mono,times"],
|
|
280
292
|
["Arial", "arial,helvetica,sans-serif"],
|
|
281
293
|
["Arial Black", "arial black,avant garde"],
|
|
@@ -295,7 +307,7 @@ const U = "undo redo | preview print | importword revhistory | fontfamily fontsi
|
|
|
295
307
|
["Verdana", "verdana,geneva"],
|
|
296
308
|
["Webdings", "webdings"],
|
|
297
309
|
["Wingdings", "wingdings,zapf dingbats"]
|
|
298
|
-
],
|
|
310
|
+
], Y = ["8px", "9px", "10px", "11px", "12px", "14px", "16px", "18px", "20px", "24px", "28px", "32px", "36px", "48px", "72px", "96px"], G = 1, K = 100, V = ["1", "1.15", "1.4", "1.5", "1.75", "2", "2.5", "3"], J = ["1px", "2px", "4px", "6px", "8px", "12px"], P = [
|
|
299
311
|
["p", "para"],
|
|
300
312
|
["h1", "heading1"],
|
|
301
313
|
["h2", "heading2"],
|
|
@@ -304,7 +316,7 @@ const U = "undo redo | preview print | importword revhistory | fontfamily fontsi
|
|
|
304
316
|
["h5", "heading5"],
|
|
305
317
|
["h6", "heading6"],
|
|
306
318
|
["pre", "pre"]
|
|
307
|
-
],
|
|
319
|
+
], tt = ["#F76707", "#4263EB", "#CC5DE8"], et = [
|
|
308
320
|
"#BFEDD2",
|
|
309
321
|
"#FBEEB8",
|
|
310
322
|
"#F8CAC6",
|
|
@@ -327,7 +339,7 @@ const U = "undo redo | preview print | importword revhistory | fontfamily fontsi
|
|
|
327
339
|
"#34495E",
|
|
328
340
|
"#000000",
|
|
329
341
|
"#FFFFFF"
|
|
330
|
-
],
|
|
342
|
+
], it = [
|
|
331
343
|
"©",
|
|
332
344
|
"®",
|
|
333
345
|
"™",
|
|
@@ -376,7 +388,7 @@ const U = "undo redo | preview print | importword revhistory | fontfamily fontsi
|
|
|
376
388
|
"ـ",
|
|
377
389
|
"٠",
|
|
378
390
|
"١"
|
|
379
|
-
],
|
|
391
|
+
], b = (p, t) => `<svg viewBox="${t || "0 0 24 24"}">${p}</svg>`, u = (p) => b(`<path class="f" d="${p}"/>`, "0 -960 960 960"), L = (p, t = 7.5) => b(
|
|
380
392
|
'<path d="M10 6h10M10 12h10M10 18h10"/>' + p.map(
|
|
381
393
|
(e, i) => `<text x="2.5" y="${8.4 + i * 6}" font-size="${t}" stroke="none" fill="#222f3e" font-family="Arial">${e}</text>`
|
|
382
394
|
).join("")
|
|
@@ -423,7 +435,7 @@ const U = "undo redo | preview print | importword revhistory | fontfamily fontsi
|
|
|
423
435
|
bullist: u(
|
|
424
436
|
"M360-200v-80h480v80H360Zm0-240v-80h480v80H360Zm0-240v-80h480v80H360ZM200-160q-33 0-56.5-23.5T120-240q0-33 23.5-56.5T200-320q33 0 56.5 23.5T280-240q0 33-23.5 56.5T200-160Zm0-240q-33 0-56.5-23.5T120-480q0-33 23.5-56.5T200-560q33 0 56.5 23.5T280-480q0 33-23.5 56.5T200-400Zm-56.5-263.5Q120-687 120-720t23.5-56.5Q167-800 200-800t56.5 23.5Q280-753 280-720t-23.5 56.5Q233-640 200-640t-56.5-23.5Z"
|
|
425
437
|
),
|
|
426
|
-
chev:
|
|
438
|
+
chev: b('<path d="M2 3.5 6 7.5 10 3.5"/>', "0 0 12 11"),
|
|
427
439
|
backcolor: u(
|
|
428
440
|
"M440-80q-33 0-56.5-23.5T360-160v-160H240q-33 0-56.5-23.5T160-400v-280q0-66 47-113t113-47h480v440q0 33-23.5 56.5T720-320H600v160q0 33-23.5 56.5T520-80h-80ZM240-560h480v-200h-40v160h-80v-160h-40v80h-80v-80H320q-33 0-56.5 23.5T240-680v120Zm0 160h480v-80H240v80Zm0 0v-80 80Z"
|
|
429
441
|
),
|
|
@@ -433,7 +445,7 @@ const U = "undo redo | preview print | importword revhistory | fontfamily fontsi
|
|
|
433
445
|
indent: u(
|
|
434
446
|
"M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm0 440v-320l160 160-160 160Z"
|
|
435
447
|
),
|
|
436
|
-
more:
|
|
448
|
+
more: b(
|
|
437
449
|
'<circle class="f" cx="5" cy="12" r="1.7"/><circle class="f" cx="12" cy="12" r="1.7"/><circle class="f" cx="19" cy="12" r="1.7"/>'
|
|
438
450
|
),
|
|
439
451
|
image: u(
|
|
@@ -445,17 +457,17 @@ const U = "undo redo | preview print | importword revhistory | fontfamily fontsi
|
|
|
445
457
|
tableic: u(
|
|
446
458
|
"M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm240-240H200v160h240v-160Zm80 0v160h240v-160H520Zm-80-80v-160H200v160h240Zm80 0h240v-160H520v160ZM200-680h560v-80H200v80Z"
|
|
447
459
|
),
|
|
448
|
-
hric:
|
|
460
|
+
hric: b('<path d="M4 12h16"/>'),
|
|
449
461
|
charic: u(
|
|
450
462
|
"M120-120v-120h200q-84-45-132-125t-48-175q0-142 99-241t241-99q142 0 241 99t99 241q0 95-48 175T640-240h200v120H520v-204q78-14 129-75t51-141q0-92-64-156t-156-64q-92 0-156 64t-64 156q0 80 51 141t129 75v204H120Z"
|
|
451
463
|
),
|
|
452
|
-
dateic:
|
|
464
|
+
dateic: b(
|
|
453
465
|
'<rect x="4" y="6" width="16" height="14" rx="1.5"/><path d="M4 10h16M8 4v4M16 4v4"/>'
|
|
454
466
|
),
|
|
455
467
|
pbic: u(
|
|
456
468
|
"M240-80q-33 0-56.5-23.5T160-160v-120h80v120h480v-120h80v120q0 33-23.5 56.5T720-80H240Zm-80-440v-280q0-33 23.5-56.5T240-880h320l240 240v120h-80v-80H520v-200H240v280h-80Zm200 160v-80h240v80H360Zm320 0v-80h240v80H680Zm-640 0v-80h240v80H40Zm440-160Zm0 240Z"
|
|
457
469
|
),
|
|
458
|
-
nbspic:
|
|
470
|
+
nbspic: b('<path d="M6 12v4h12v-4"/>'),
|
|
459
471
|
srcic: u(
|
|
460
472
|
"M240-280 40-480l200-200 56 56-143 144 143 144-56 56Zm178 132-76-24 200-640 76 24-200 640Zm302-132-56-56 143-144-143-144 56-56 200 200-200 200Z"
|
|
461
473
|
),
|
|
@@ -483,11 +495,11 @@ const U = "undo redo | preview print | importword revhistory | fontfamily fontsi
|
|
|
483
495
|
subscriptic: u(
|
|
484
496
|
"M760-160v-80q0-17 11.5-28.5T800-280h80v-40H760v-40h120q17 0 28.5 11.5T920-320v40q0 17-11.5 28.5T880-240h-80v40h120v40H760Zm-525-80 185-291-172-269h106l124 200h4l123-200h107L539-531l186 291H618L482-457h-4L342-240H235Z"
|
|
485
497
|
),
|
|
486
|
-
newic:
|
|
487
|
-
helpic:
|
|
498
|
+
newic: b('<path d="M6 3h8l5 5v13H6z"/><path d="M14 3v5h5"/>'),
|
|
499
|
+
helpic: b(
|
|
488
500
|
'<circle cx="12" cy="12" r="8.5"/><path d="M9.6 9.6a2.5 2.5 0 1 1 3.4 2.6c-.8.3-1 .9-1 1.8"/><circle class="f" cx="12" cy="16.6" r="1.1"/>'
|
|
489
501
|
),
|
|
490
|
-
wcic:
|
|
502
|
+
wcic: b('<path d="M4 6h16M4 10h16M4 14h9"/><path d="M15 17.5l2 2 3.6-4"/>'),
|
|
491
503
|
rowbefore: u(
|
|
492
504
|
"M200-160h560v-240H200v240Zm640 80H120v-720h160v80h-80v240h560v-240h-80v-80h160v720ZM480-480Zm0 80v-80 80Zm0 0Zm-40-240v-80h-80v-80h80v-80h80v80h80v80h-80v80h-80Z"
|
|
493
505
|
),
|
|
@@ -506,7 +518,7 @@ const U = "undo redo | preview print | importword revhistory | fontfamily fontsi
|
|
|
506
518
|
coldelete: u(
|
|
507
519
|
"M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200ZM200-200h560v-560H200ZM400-200v-560h160v560H400ZM330-580l250 250 50-50-250-250ZM330-380l250-250 50 50-250 250Z"
|
|
508
520
|
),
|
|
509
|
-
tabledelete:
|
|
521
|
+
tabledelete: b(
|
|
510
522
|
'<rect x="4" y="5" width="16" height="14" rx="1.5"/><path d="M4 10h16M4 14.5h16M9.5 5v14M14.5 5v14"/><path d="M6.5 6.5l11 11M17.5 6.5l-11 11" stroke-width="2.1"/>'
|
|
511
523
|
),
|
|
512
524
|
quote: u(
|
|
@@ -515,7 +527,7 @@ const U = "undo redo | preview print | importword revhistory | fontfamily fontsi
|
|
|
515
527
|
link: u(
|
|
516
528
|
"M440-280H280q-83 0-141.5-58.5T80-480q0-83 58.5-141.5T280-680h160v80H280q-50 0-85 35t-35 85q0 50 35 85t85 35h160v80ZM320-440v-80h320v80H320Zm200 160v-80h160q50 0 85-35t35-85q0-50-35-85t-85-35H520v-80h160q83 0 141.5 58.5T880-480q0 83-58.5 141.5T680-280H520Z"
|
|
517
529
|
),
|
|
518
|
-
unlink:
|
|
530
|
+
unlink: b(
|
|
519
531
|
'<path d="M13.5 6.5l1.7-1.7a4 4 0 0 1 5.6 5.6L19 12.2"/><path d="M10.5 17.5l-1.7 1.7a4 4 0 0 1-5.6-5.6L5 11.8"/><path d="M4 4l16 16"/>'
|
|
520
532
|
),
|
|
521
533
|
lineheight: u(
|
|
@@ -536,8 +548,8 @@ const U = "undo redo | preview print | importword revhistory | fontfamily fontsi
|
|
|
536
548
|
capitalizeic: u(
|
|
537
549
|
"M344-250v-366H224v-64h308v64H412v366h-68Zm344 10q-44 0-69-25.5T594-336v-162h-54v-58h54v-87h66v87h74v58h-74v148q0 23 10.5 36t28.5 13q9 0 18.5-3.5T736-314v65q-10 5-22 7t-26 2Z"
|
|
538
550
|
),
|
|
539
|
-
plus:
|
|
540
|
-
minus:
|
|
551
|
+
plus: b('<path d="M12 5.5v13M5.5 12h13"/>'),
|
|
552
|
+
minus: b('<path d="M5.5 12h13"/>'),
|
|
541
553
|
fontsizeup: u(
|
|
542
554
|
"m40-200 210-560h100l210 560h-96l-51-143H187l-51 143H40Zm176-224h168l-82-232h-4l-82 232Zm504 104v-120H600v-80h120v-120h80v120h120v80H800v120h-80Z"
|
|
543
555
|
),
|
|
@@ -547,29 +559,44 @@ const U = "undo redo | preview print | importword revhistory | fontfamily fontsi
|
|
|
547
559
|
historyic: u(
|
|
548
560
|
"M480-120q-138 0-240.5-91.5T122-440h82q14 104 92.5 172T480-200q117 0 198.5-81.5T760-480q0-117-81.5-198.5T480-760q-69 0-129 32t-101 88h110v80H120v-240h80v94q51-64 124.5-99T480-840q75 0 140.5 28.5t114 77q48.5 48.5 77 114T840-480q0 75-28.5 140.5t-77 114q-48.5 48.5-114 77T480-120Zm112-192L440-464v-216h80v184l128 128-56 56Z"
|
|
549
561
|
),
|
|
550
|
-
wordic:
|
|
562
|
+
wordic: b(
|
|
551
563
|
'<path d="M6 3h8l5 5v13H6z"/><path d="M14 3v5h5"/><text x="8" y="17" font-size="8.5" stroke="none" fill="#222f3e" font-family="Arial" font-weight="bold">W</text>'
|
|
552
564
|
),
|
|
553
565
|
draftic: u(
|
|
554
566
|
"M480-160q-134 0-227-93t-93-227q0-134 93-227t227-93q69 0 132 28.5T720-690v-110h80v280H520v-80h168q-32-56-87.5-88T480-720q-100 0-170 70t-70 170q0 100 70 170t170 70q77 0 139-44t87-116h84q-28 106-114 173t-196 67Z"
|
|
555
567
|
),
|
|
556
|
-
trash:
|
|
568
|
+
trash: b(
|
|
557
569
|
'<path d="M5 7h14M10 7V5h4v2M7.5 7l1 13h7l1-13"/>'
|
|
558
570
|
),
|
|
559
|
-
|
|
571
|
+
templateic: b(
|
|
572
|
+
'<rect x="4" y="4" width="16" height="16" rx="1.5"/><rect x="6.5" y="6.5" width="5" height="5" rx=".5"/><path d="M14 7.5h3.5M14 10h3.5M6.5 14h11M6.5 17h11"/>'
|
|
573
|
+
),
|
|
574
|
+
tplleft: b(
|
|
575
|
+
'<rect x="3" y="5" width="8" height="8" rx=".8"/><path d="M13.5 6.5H21M13.5 9.5H21M13.5 12.5H21M3 15.5h18M3 18.5h18"/>'
|
|
576
|
+
),
|
|
577
|
+
tplright: b(
|
|
578
|
+
'<rect x="13" y="5" width="8" height="8" rx=".8"/><path d="M3 6.5h7.5M3 9.5h7.5M3 12.5h7.5M3 15.5h18M3 18.5h18"/>'
|
|
579
|
+
),
|
|
580
|
+
tpltop: b(
|
|
581
|
+
'<rect x="5" y="3" width="14" height="9" rx=".8"/><path d="M3 15h18M3 18h18M3 21h12"/>'
|
|
582
|
+
),
|
|
583
|
+
tplcenter: b(
|
|
584
|
+
'<path d="M3 4h18M3 7h18M3 10h12"/><rect x="5" y="12.5" width="14" height="9" rx=".8"/>'
|
|
585
|
+
),
|
|
586
|
+
rotateleft: b(
|
|
560
587
|
'<polyline points="1 4 1 10 7 10"/><path d="M3.51 15a9 9 0 1 0 2.13-9.36L1 10"/>'
|
|
561
588
|
),
|
|
562
|
-
rotateright:
|
|
589
|
+
rotateright: b(
|
|
563
590
|
'<polyline points="23 4 23 10 17 10"/><path d="M20.49 15a9 9 0 1 1-2.12-9.36L23 10"/>'
|
|
564
591
|
),
|
|
565
|
-
fliphorizontal:
|
|
592
|
+
fliphorizontal: b(
|
|
566
593
|
'<path d="M12 3v18"/><path d="M7 8l-4 4 4 4"/><path d="M17 8l4 4-4 4"/>'
|
|
567
594
|
),
|
|
568
|
-
flipvertical:
|
|
595
|
+
flipvertical: b(
|
|
569
596
|
'<path d="M3 12h18"/><path d="M8 7l4-4 4 4"/><path d="M8 17l4 4 4-4"/>'
|
|
570
597
|
),
|
|
571
|
-
check:
|
|
572
|
-
palette:
|
|
598
|
+
check: b('<path d="M5 12.5 9.5 17 19 7"/>'),
|
|
599
|
+
palette: b(
|
|
573
600
|
'<path d="M12 3a9 9 0 1 0 0 18h1.2a2 2 0 0 0 2-2 2 2 0 0 1 2-2H18a3 3 0 0 0 3-3c0-6.1-4.5-11-9-11z"/><circle class="f" cx="7.8" cy="10.2" r="1.3"/><circle class="f" cx="11.6" cy="7.3" r="1.3"/><circle class="f" cx="15.8" cy="9.6" r="1.3"/><circle class="f" cx="9" cy="14.8" r="1.3"/>'
|
|
574
601
|
),
|
|
575
602
|
ul_circle: u(
|
|
@@ -578,11 +605,11 @@ const U = "undo redo | preview print | importword revhistory | fontfamily fontsi
|
|
|
578
605
|
ul_square: u(
|
|
579
606
|
"M80-160v-160h160v160H80Zm240 0v-160h560v160H320ZM80-400v-160h160v160H80Zm240 0v-160h560v160H320ZM80-640v-160h160v160H80Zm240 0v-160h560v160H320Z"
|
|
580
607
|
),
|
|
581
|
-
ol_alpha:
|
|
582
|
-
ol_roman:
|
|
583
|
-
ol_alphau:
|
|
584
|
-
ol_romanu:
|
|
585
|
-
},
|
|
608
|
+
ol_alpha: L(["a", "b", "c"]),
|
|
609
|
+
ol_roman: L(["i", "ii", "iii"], 6.5),
|
|
610
|
+
ol_alphau: L(["A", "B", "C"]),
|
|
611
|
+
ol_romanu: L(["I", "II", "III"], 6.5)
|
|
612
|
+
}, Ct = (p) => `<span class="txt">${p}</span>`, st = /* @__PURE__ */ new Set([
|
|
586
613
|
"p",
|
|
587
614
|
"div",
|
|
588
615
|
"span",
|
|
@@ -624,7 +651,7 @@ const U = "undo redo | preview print | importword revhistory | fontfamily fontsi
|
|
|
624
651
|
"figure",
|
|
625
652
|
"figcaption",
|
|
626
653
|
"mark"
|
|
627
|
-
]),
|
|
654
|
+
]), lt = /* @__PURE__ */ new Set([
|
|
628
655
|
"text-align",
|
|
629
656
|
"direction",
|
|
630
657
|
"unicode-bidi",
|
|
@@ -680,7 +707,7 @@ const U = "undo redo | preview print | importword revhistory | fontfamily fontsi
|
|
|
680
707
|
"box-sizing",
|
|
681
708
|
"list-style-type",
|
|
682
709
|
"white-space"
|
|
683
|
-
]),
|
|
710
|
+
]), O = {
|
|
684
711
|
"*": ["dir", "lang", "colspan", "rowspan"],
|
|
685
712
|
a: ["href", "target", "rel", "title"],
|
|
686
713
|
img: ["src", "alt", "width", "height", "title"],
|
|
@@ -696,13 +723,13 @@ function Z(p) {
|
|
|
696
723
|
s < 1 || (t[i.slice(0, s).trim().toLowerCase()] = i.slice(s + 1).trim());
|
|
697
724
|
}), t;
|
|
698
725
|
}
|
|
699
|
-
function
|
|
726
|
+
function nt(p) {
|
|
700
727
|
return p.replace(/<!--\[if !supportLists\]-->([\s\S]*?)<!--\[endif\]-->/gi, "$1").replace(/<!--\[if !supportLists\]>([\s\S]*?)<!\[endif\]-->/gi, "$1").replace(/<!\[if !supportLists\]>([\s\S]*?)<!\[endif\]>/gi, "$1").replace(/<!--\[if [\s\S]*?<!\[endif\]-->/gi, "").replace(/<!--[\s\S]*?-->/g, "").replace(/<(script|style|xml|title)[\s\S]*?<\/\1>/gi, "").replace(/<\/?(meta|link)[^>]*>/gi, "").replace(/<\?xml[\s\S]*?\?>/gi, "").replace(/<\/?(o|v|w|m|st1):[^>]*>/gi, "");
|
|
701
728
|
}
|
|
702
|
-
function
|
|
729
|
+
function ot(p) {
|
|
703
730
|
return /^[0-9]+[\.\)،]/.test(p) ? { ordered: !0 } : /^[٠-٩۰-۹]+/.test(p) ? { ordered: !0, style: "arabic-indic" } : /^[ivxlc]{2,}[\.\)]/.test(p) ? { ordered: !0, style: "lower-roman" } : /^[IVXLC]{2,}[\.\)]/.test(p) ? { ordered: !0, style: "upper-roman" } : /^[a-z][\.\)]/.test(p) ? { ordered: !0, style: "lower-alpha" } : /^[A-Z][\.\)]/.test(p) ? { ordered: !0, style: "upper-alpha" } : /^[ء-ي][\.\)،-]/.test(p) ? { ordered: !0, style: "arabic-indic" } : { ordered: !1 };
|
|
704
731
|
}
|
|
705
|
-
function
|
|
732
|
+
function rt(p) {
|
|
706
733
|
const t = (s) => {
|
|
707
734
|
const l = (s.getAttribute("style") || "") + " " + (s.className || "");
|
|
708
735
|
return /mso-list\s*:(?!\s*ignore)/i.test(l) || /MsoListParagraph/i.test(l);
|
|
@@ -718,10 +745,10 @@ function nt(p) {
|
|
|
718
745
|
}), e.forEach((s) => {
|
|
719
746
|
const l = [], n = s[0];
|
|
720
747
|
s.forEach((o) => {
|
|
721
|
-
var T,
|
|
748
|
+
var T, S, M;
|
|
722
749
|
const c = +(((T = (o.getAttribute("style") || "").match(/level(\d+)/i)) == null ? void 0 : T[1]) || 1), h = Array.from(o.querySelectorAll("span")).find(
|
|
723
750
|
(x) => /mso-list\s*:\s*ignore/i.test(x.getAttribute("style") || "")
|
|
724
|
-
), d = h ? ((
|
|
751
|
+
), d = h ? ((S = h.textContent) == null ? void 0 : S.trim()) || "" : (((M = o.textContent) == null ? void 0 : M.trim().match(/^\S{1,4}/)) || [""])[0], { ordered: m, style: g } = ot(d);
|
|
725
752
|
for (h && h.remove(); l.length && l[l.length - 1].level > c; ) l.pop();
|
|
726
753
|
if (!l.length || l[l.length - 1].level < c) {
|
|
727
754
|
const x = p.createElement(m ? "ol" : "ul");
|
|
@@ -732,19 +759,19 @@ function nt(p) {
|
|
|
732
759
|
n.parentNode.insertBefore(x, n);
|
|
733
760
|
l.push({ list: x, level: c });
|
|
734
761
|
}
|
|
735
|
-
const f = p.createElement("li"),
|
|
736
|
-
for (
|
|
762
|
+
const f = p.createElement("li"), v = Z(o), y = ["text-align", "direction", "unicode-bidi", "color", "font-size", "font-family", "background-color"].filter((x) => v[x]).map((x) => x + ":" + v[x]).join(";");
|
|
763
|
+
for (y && f.setAttribute("style", y), o.getAttribute("dir") && f.setAttribute("dir", o.getAttribute("dir")); o.firstChild; ) f.appendChild(o.firstChild);
|
|
737
764
|
l[l.length - 1].list.appendChild(f), o.remove();
|
|
738
765
|
});
|
|
739
766
|
});
|
|
740
767
|
}
|
|
741
|
-
function
|
|
768
|
+
function at(p) {
|
|
742
769
|
p.querySelectorAll('b[id^="docs-internal-guid"]').forEach((t) => {
|
|
743
770
|
for (; t.firstChild; ) t.parentNode.insertBefore(t.firstChild, t);
|
|
744
771
|
t.remove();
|
|
745
772
|
});
|
|
746
773
|
}
|
|
747
|
-
function
|
|
774
|
+
function ct(p) {
|
|
748
775
|
p.querySelectorAll("table").forEach((t) => {
|
|
749
776
|
const e = t;
|
|
750
777
|
Z(e)["border-collapse"] || (e.style.borderCollapse = "collapse");
|
|
@@ -763,7 +790,7 @@ function rt(p) {
|
|
|
763
790
|
e.style.backgroundColor = e.style.backgroundColor || e.getAttribute("bgcolor"), e.removeAttribute("bgcolor");
|
|
764
791
|
});
|
|
765
792
|
}
|
|
766
|
-
function
|
|
793
|
+
function q(p, t) {
|
|
767
794
|
Array.from(p.childNodes).forEach((e) => {
|
|
768
795
|
if (e.nodeType === Node.COMMENT_NODE) {
|
|
769
796
|
e.remove();
|
|
@@ -771,7 +798,7 @@ function L(p, t) {
|
|
|
771
798
|
}
|
|
772
799
|
if (e.nodeType !== Node.ELEMENT_NODE) return;
|
|
773
800
|
const i = e, s = i.tagName.toLowerCase();
|
|
774
|
-
if (!
|
|
801
|
+
if (!st.has(s)) {
|
|
775
802
|
if (s === "font") {
|
|
776
803
|
const r = t.createElement("span");
|
|
777
804
|
i.getAttribute("style") && r.setAttribute("style", i.getAttribute("style")), i.getAttribute("color") && (r.style.color = i.getAttribute("color")), i.getAttribute("face") && (r.style.fontFamily = i.getAttribute("face"));
|
|
@@ -789,14 +816,14 @@ function L(p, t) {
|
|
|
789
816
|
h[c] && (r.style.fontSize = h[c]);
|
|
790
817
|
}
|
|
791
818
|
for (; i.firstChild; ) r.appendChild(i.firstChild);
|
|
792
|
-
i.replaceWith(r),
|
|
819
|
+
i.replaceWith(r), q(r, t);
|
|
793
820
|
return;
|
|
794
821
|
}
|
|
795
|
-
for (
|
|
822
|
+
for (q(i, t); i.firstChild; ) i.parentNode.insertBefore(i.firstChild, i);
|
|
796
823
|
i.remove();
|
|
797
824
|
return;
|
|
798
825
|
}
|
|
799
|
-
const l = /* @__PURE__ */ new Set([...
|
|
826
|
+
const l = /* @__PURE__ */ new Set([...O["*"] || [], ...O[s] || []]);
|
|
800
827
|
if (Array.from(i.attributes).forEach((r) => {
|
|
801
828
|
const c = r.name.toLowerCase();
|
|
802
829
|
c !== "style" && !l.has(c) && i.removeAttribute(r.name);
|
|
@@ -814,14 +841,14 @@ function L(p, t) {
|
|
|
814
841
|
}
|
|
815
842
|
const n = Z(i), o = [];
|
|
816
843
|
for (const [r, c] of Object.entries(n))
|
|
817
|
-
|
|
818
|
-
if (o.length ? i.setAttribute("style", o.join(";")) : i.removeAttribute("style"), i.removeAttribute("class"),
|
|
844
|
+
lt.has(r) && (/expression|javascript|url\s*\(\s*['"]?\s*file:/i.test(c) || r === "font-weight" && /^(400|normal)$/i.test(c) || r === "font-style" && /^normal$/i.test(c) || r === "text-decoration" && /^none$/i.test(c) || o.push(r + ":" + c));
|
|
845
|
+
if (o.length ? i.setAttribute("style", o.join(";")) : i.removeAttribute("style"), i.removeAttribute("class"), q(i, t), s === "span" && !i.attributes.length) {
|
|
819
846
|
for (; i.firstChild; ) i.parentNode.insertBefore(i.firstChild, i);
|
|
820
847
|
i.remove();
|
|
821
848
|
}
|
|
822
849
|
});
|
|
823
850
|
}
|
|
824
|
-
function
|
|
851
|
+
function ht(p) {
|
|
825
852
|
const t = [], e = /<style[^>]*>([\s\S]*?)<\/style>/gi;
|
|
826
853
|
let i;
|
|
827
854
|
for (; i = e.exec(p); ) {
|
|
@@ -839,7 +866,7 @@ function at(p) {
|
|
|
839
866
|
}
|
|
840
867
|
return t;
|
|
841
868
|
}
|
|
842
|
-
function
|
|
869
|
+
function dt(p, t) {
|
|
843
870
|
if (!t.length) return;
|
|
844
871
|
const e = /* @__PURE__ */ new Map();
|
|
845
872
|
t.forEach(({ sel: i, decls: s }) => {
|
|
@@ -862,18 +889,18 @@ function ct(p, t) {
|
|
|
862
889
|
s.setAttribute("style", h ? c + ";" + h : c);
|
|
863
890
|
});
|
|
864
891
|
}
|
|
865
|
-
function
|
|
892
|
+
function U(p) {
|
|
866
893
|
return p.replace(/[ﭐ-﷿ﹰ-ﻼ]+/g, (t) => t.normalize("NFKC"));
|
|
867
894
|
}
|
|
868
|
-
function
|
|
895
|
+
function pt(p) {
|
|
869
896
|
const t = p.createTreeWalker(p.body, NodeFilter.SHOW_TEXT, null);
|
|
870
897
|
let e;
|
|
871
898
|
for (; e = t.nextNode(); )
|
|
872
|
-
/[ﭐ-﷿ﹰ-ﻼ]/.test(e.nodeValue || "") && (e.nodeValue =
|
|
899
|
+
/[ﭐ-﷿ﹰ-ﻼ]/.test(e.nodeValue || "") && (e.nodeValue = U(e.nodeValue || ""));
|
|
873
900
|
}
|
|
874
|
-
function
|
|
875
|
-
const e =
|
|
876
|
-
|
|
901
|
+
function mt(p, t = "ltr") {
|
|
902
|
+
const e = ht(p), i = new DOMParser().parseFromString(nt(p), "text/html");
|
|
903
|
+
dt(i, e), /class="?Mso|mso-|urn:schemas-microsoft-com/i.test(i.body.innerHTML) && rt(i), at(i), ct(i), q(i.body, i), pt(i);
|
|
877
904
|
const s = (l) => {
|
|
878
905
|
var n;
|
|
879
906
|
return l && l.tagName === "P" && !((n = l.textContent) != null && n.trim()) && !l.querySelector("img,table");
|
|
@@ -882,11 +909,11 @@ function dt(p, t = "ltr") {
|
|
|
882
909
|
for (; s(i.body.lastElementChild); ) i.body.lastElementChild.remove();
|
|
883
910
|
return i.body.innerHTML.trim();
|
|
884
911
|
}
|
|
885
|
-
function
|
|
886
|
-
const t =
|
|
912
|
+
function ut(p) {
|
|
913
|
+
const t = U(p).replace(/\r/g, ""), e = (i) => i.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
887
914
|
return /\n/.test(t) ? t.split(/\n{2,}/).map((i) => `<p dir="auto">${e(i).replace(/\n/g, "<br>") || "<br>"}</p>`).join("") : e(t);
|
|
888
915
|
}
|
|
889
|
-
function
|
|
916
|
+
function gt(p) {
|
|
890
917
|
const t = new DataView(p), e = /* @__PURE__ */ new Map();
|
|
891
918
|
let i = -1;
|
|
892
919
|
for (let o = p.byteLength - 22; o >= Math.max(0, p.byteLength - 22 - 65535); o--)
|
|
@@ -904,7 +931,7 @@ function mt(p) {
|
|
|
904
931
|
}
|
|
905
932
|
return e;
|
|
906
933
|
}
|
|
907
|
-
async function
|
|
934
|
+
async function $(p, t) {
|
|
908
935
|
const e = new DataView(p, t.localOffset);
|
|
909
936
|
if (e.getUint32(0, !0) !== 67324752) throw new Error("Bad local header");
|
|
910
937
|
const i = e.getUint16(26, !0), s = e.getUint16(28, !0), l = t.localOffset + 30 + i + s, n = new Uint8Array(p.slice(l, l + t.compSize));
|
|
@@ -913,24 +940,24 @@ async function P(p, t) {
|
|
|
913
940
|
const o = new Blob([n]).stream().pipeThrough(new DecompressionStream("deflate-raw"));
|
|
914
941
|
return new Uint8Array(await new Response(o).arrayBuffer());
|
|
915
942
|
}
|
|
916
|
-
const
|
|
943
|
+
const F = (p) => p.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """), I = (p, t) => Array.from(p.children).filter((e) => e.localName === t), C = (p, ...t) => {
|
|
917
944
|
let e = p;
|
|
918
945
|
for (const i of t) {
|
|
919
946
|
if (!e) return null;
|
|
920
947
|
e = Array.from(e.children).find((s) => s.localName === i) || null;
|
|
921
948
|
}
|
|
922
949
|
return e;
|
|
923
|
-
},
|
|
950
|
+
}, w = (p, t = "val") => {
|
|
924
951
|
if (!p) return "";
|
|
925
952
|
for (const e of Array.from(p.attributes))
|
|
926
953
|
if (e.localName === t) return e.value;
|
|
927
954
|
return "";
|
|
928
|
-
},
|
|
955
|
+
}, k = (p, t) => {
|
|
929
956
|
const e = p ? C(p, t) : null;
|
|
930
957
|
if (!e) return !1;
|
|
931
|
-
const i =
|
|
958
|
+
const i = w(e);
|
|
932
959
|
return i !== "false" && i !== "0";
|
|
933
|
-
},
|
|
960
|
+
}, z = {
|
|
934
961
|
yellow: "#FFFF00",
|
|
935
962
|
green: "#00FF00",
|
|
936
963
|
cyan: "#00FFFF",
|
|
@@ -947,7 +974,7 @@ const O = (p) => p.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, "&
|
|
|
947
974
|
lightGray: "#D3D3D3",
|
|
948
975
|
black: "#000000",
|
|
949
976
|
white: "#FFFFFF"
|
|
950
|
-
},
|
|
977
|
+
}, ft = {
|
|
951
978
|
png: "image/png",
|
|
952
979
|
jpg: "image/jpeg",
|
|
953
980
|
jpeg: "image/jpeg",
|
|
@@ -955,13 +982,13 @@ const O = (p) => p.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, "&
|
|
|
955
982
|
bmp: "image/bmp",
|
|
956
983
|
webp: "image/webp"
|
|
957
984
|
};
|
|
958
|
-
function
|
|
985
|
+
function vt(p) {
|
|
959
986
|
let t = "";
|
|
960
987
|
for (let e = 0; e < p.length; e += 32768)
|
|
961
988
|
t += String.fromCharCode(...p.subarray(e, e + 32768));
|
|
962
989
|
return btoa(t);
|
|
963
990
|
}
|
|
964
|
-
class
|
|
991
|
+
class bt {
|
|
965
992
|
constructor(t, e, i) {
|
|
966
993
|
this.rels = t, this.images = e, this.numFmt = i;
|
|
967
994
|
}
|
|
@@ -988,17 +1015,17 @@ class ft {
|
|
|
988
1015
|
paraList(t) {
|
|
989
1016
|
const e = C(t, "pPr", "numPr");
|
|
990
1017
|
if (!e) return null;
|
|
991
|
-
const i =
|
|
1018
|
+
const i = w(C(e, "numId"));
|
|
992
1019
|
if (!i || i === "0") return null;
|
|
993
|
-
const s = parseInt(
|
|
1020
|
+
const s = parseInt(w(C(e, "ilvl")) || "0", 10) || 0;
|
|
994
1021
|
return { type: this.numFmt.get(i) || "ul", ilvl: Math.min(s, 8) };
|
|
995
1022
|
}
|
|
996
1023
|
convertPara(t) {
|
|
997
|
-
const e = C(t, "pPr"), i =
|
|
1024
|
+
const e = C(t, "pPr"), i = w(C(t, "pPr", "pStyle"));
|
|
998
1025
|
let s = "p";
|
|
999
1026
|
const l = /^Heading([1-6])$/i.exec(i);
|
|
1000
1027
|
l ? s = "h" + l[1] : /^Title$/i.test(i) && (s = "h1");
|
|
1001
|
-
const n = [], o =
|
|
1028
|
+
const n = [], o = w(C(t, "pPr", "jc"));
|
|
1002
1029
|
o === "center" ? n.push("text-align:center") : o === "right" || o === "end" ? n.push("text-align:right") : (o === "both" || o === "distribute") && n.push("text-align:justify"), e && C(e, "bidi") && n.push("direction:rtl");
|
|
1003
1030
|
const r = this.runsOf(t), c = n.length ? ` style="${n.join(";")}"` : "";
|
|
1004
1031
|
return `<${s}${c}>${r || "<br>"}</${s}>`;
|
|
@@ -1008,11 +1035,11 @@ class ft {
|
|
|
1008
1035
|
for (const i of Array.from(t.children))
|
|
1009
1036
|
if (i.localName === "r") e += this.convertRun(i);
|
|
1010
1037
|
else if (i.localName === "hyperlink") {
|
|
1011
|
-
let s = this.rels.get(
|
|
1012
|
-
const l =
|
|
1038
|
+
let s = this.rels.get(w(i, "id")) || "";
|
|
1039
|
+
const l = w(i, "anchor");
|
|
1013
1040
|
!s && l && (s = "#" + l);
|
|
1014
1041
|
const n = this.runsOf(i);
|
|
1015
|
-
e += s ? `<a href="${
|
|
1042
|
+
e += s ? `<a href="${F(s)}">${n}</a>` : n;
|
|
1016
1043
|
} else (i.localName === "smartTag" || i.localName === "ins") && (e += this.runsOf(i));
|
|
1017
1044
|
return e;
|
|
1018
1045
|
}
|
|
@@ -1020,23 +1047,23 @@ class ft {
|
|
|
1020
1047
|
const e = C(t, "rPr");
|
|
1021
1048
|
let i = "";
|
|
1022
1049
|
for (const d of Array.from(t.children))
|
|
1023
|
-
d.localName === "t" ? i +=
|
|
1050
|
+
d.localName === "t" ? i += F(d.textContent || "") : d.localName === "br" || d.localName === "cr" ? i += "<br>" : d.localName === "tab" ? i += " " : (d.localName === "drawing" || d.localName === "pict" || d.localName === "object") && (i += this.convertImage(d));
|
|
1024
1051
|
if (!i) return "";
|
|
1025
|
-
const s = [], l =
|
|
1052
|
+
const s = [], l = w(e ? C(e, "color") : null);
|
|
1026
1053
|
l && l !== "auto" && s.push("color:#" + l);
|
|
1027
|
-
const n =
|
|
1028
|
-
n &&
|
|
1029
|
-
const o = parseFloat(
|
|
1054
|
+
const n = w(e ? C(e, "highlight") : null);
|
|
1055
|
+
n && z[n] && s.push("background-color:" + z[n]);
|
|
1056
|
+
const o = parseFloat(w(e ? C(e, "sz") : null));
|
|
1030
1057
|
o && s.push("font-size:" + Math.round(o / 2 * (4 / 3)) + "px");
|
|
1031
|
-
const r = e ? C(e, "rFonts") : null, c =
|
|
1032
|
-
c && s.push(`font-family:'${c}'`), s.length && (i = `<span style="${s.join(";")}">${i}</span>`),
|
|
1033
|
-
const h =
|
|
1058
|
+
const r = e ? C(e, "rFonts") : null, c = w(r, "ascii") || w(r, "cs");
|
|
1059
|
+
c && s.push(`font-family:'${c}'`), s.length && (i = `<span style="${s.join(";")}">${i}</span>`), k(e, "b") && (i = `<strong>${i}</strong>`), k(e, "i") && (i = `<em>${i}</em>`), k(e, "u") && w(C(e, "u")) !== "none" && (i = `<u>${i}</u>`), k(e, "strike") && (i = `<s>${i}</s>`);
|
|
1060
|
+
const h = w(e ? C(e, "vertAlign") : null);
|
|
1034
1061
|
return h === "superscript" ? i = `<sup>${i}</sup>` : h === "subscript" && (i = `<sub>${i}</sub>`), i;
|
|
1035
1062
|
}
|
|
1036
1063
|
convertImage(t) {
|
|
1037
1064
|
let e = "", i = 0;
|
|
1038
1065
|
const s = (o) => {
|
|
1039
|
-
if (o.localName === "blip" && (e = e ||
|
|
1066
|
+
if (o.localName === "blip" && (e = e || w(o, "embed") || w(o, "link")), o.localName === "imagedata" && (e = e || w(o, "id")), o.localName === "extent") {
|
|
1040
1067
|
const r = parseFloat(o.getAttribute("cx") || "0");
|
|
1041
1068
|
r && (i = Math.round(r / 9525));
|
|
1042
1069
|
}
|
|
@@ -1053,7 +1080,7 @@ class ft {
|
|
|
1053
1080
|
for (const i of I(t, "tr")) {
|
|
1054
1081
|
e += "<tr>";
|
|
1055
1082
|
for (const s of I(i, "tc")) {
|
|
1056
|
-
const l = parseInt(
|
|
1083
|
+
const l = parseInt(w(C(s, "tcPr", "gridSpan")) || "1", 10) || 1, n = l > 1 ? ` colspan="${l}"` : "";
|
|
1057
1084
|
let o = "";
|
|
1058
1085
|
for (const r of Array.from(s.children))
|
|
1059
1086
|
r.localName === "p" ? o += this.convertPara(r) : r.localName === "tbl" && (o += this.convertTable(r));
|
|
@@ -1064,10 +1091,10 @@ class ft {
|
|
|
1064
1091
|
return e + "</tbody></table>";
|
|
1065
1092
|
}
|
|
1066
1093
|
}
|
|
1067
|
-
async function
|
|
1068
|
-
const t = p instanceof ArrayBuffer ? p : await p.arrayBuffer(), e =
|
|
1069
|
-
const
|
|
1070
|
-
return
|
|
1094
|
+
async function yt(p) {
|
|
1095
|
+
const t = p instanceof ArrayBuffer ? p : await p.arrayBuffer(), e = gt(t), i = new TextDecoder(), s = async (f) => {
|
|
1096
|
+
const v = e.get(f);
|
|
1097
|
+
return v ? new DOMParser().parseFromString(i.decode(await $(t, v)), "application/xml") : null;
|
|
1071
1098
|
}, l = await s("word/document.xml"), n = l == null ? void 0 : l.getElementsByTagName("*");
|
|
1072
1099
|
let o = null;
|
|
1073
1100
|
if (n) {
|
|
@@ -1082,39 +1109,49 @@ async function bt(p) {
|
|
|
1082
1109
|
if (h)
|
|
1083
1110
|
for (const f of Array.from(h.getElementsByTagName("*"))) {
|
|
1084
1111
|
if (f.localName !== "Relationship") continue;
|
|
1085
|
-
const
|
|
1086
|
-
/hyperlink/i.test(T) ? r.set(
|
|
1112
|
+
const v = f.getAttribute("Id") || "", y = f.getAttribute("Target") || "", T = f.getAttribute("Type") || "";
|
|
1113
|
+
/hyperlink/i.test(T) ? r.set(v, y) : /image/i.test(T) && c.set(v, y);
|
|
1087
1114
|
}
|
|
1088
1115
|
const d = /* @__PURE__ */ new Map();
|
|
1089
|
-
for (const [f,
|
|
1090
|
-
const
|
|
1116
|
+
for (const [f, v] of c) {
|
|
1117
|
+
const y = v.startsWith("/") ? v.slice(1) : "word/" + v.replace(/^\.\//, ""), T = e.get(y);
|
|
1091
1118
|
if (!T) continue;
|
|
1092
|
-
const
|
|
1093
|
-
if (
|
|
1119
|
+
const S = (y.split(".").pop() || "").toLowerCase(), M = ft[S];
|
|
1120
|
+
if (M)
|
|
1094
1121
|
try {
|
|
1095
|
-
d.set(f, `data:${
|
|
1122
|
+
d.set(f, `data:${M};base64,${vt(await $(t, T))}`);
|
|
1096
1123
|
} catch {
|
|
1097
1124
|
}
|
|
1098
1125
|
}
|
|
1099
1126
|
const m = /* @__PURE__ */ new Map(), g = await s("word/numbering.xml");
|
|
1100
1127
|
if (g) {
|
|
1101
|
-
const f = /* @__PURE__ */ new Map(),
|
|
1102
|
-
for (const
|
|
1103
|
-
if (
|
|
1104
|
-
const T = y
|
|
1105
|
-
f.set(T,
|
|
1128
|
+
const f = /* @__PURE__ */ new Map(), v = Array.from(g.getElementsByTagName("*"));
|
|
1129
|
+
for (const y of v) {
|
|
1130
|
+
if (y.localName !== "abstractNum") continue;
|
|
1131
|
+
const T = w(y, "abstractNumId"), S = I(y, "lvl").find((x) => w(x, "ilvl") === "0") || I(y, "lvl")[0], M = S ? w(C(S, "numFmt")) : "";
|
|
1132
|
+
f.set(T, M === "bullet" ? "ul" : "ol");
|
|
1106
1133
|
}
|
|
1107
|
-
for (const
|
|
1108
|
-
if (
|
|
1109
|
-
const T = y
|
|
1110
|
-
m.set(T, f.get(
|
|
1134
|
+
for (const y of v) {
|
|
1135
|
+
if (y.localName !== "num") continue;
|
|
1136
|
+
const T = w(y, "numId"), S = w(C(y, "abstractNumId"));
|
|
1137
|
+
m.set(T, f.get(S) || "ul");
|
|
1111
1138
|
}
|
|
1112
1139
|
}
|
|
1113
|
-
return new
|
|
1140
|
+
return new bt(r, d, m).convertBody(o);
|
|
1114
1141
|
}
|
|
1115
|
-
const
|
|
1142
|
+
const wt = ["nw", "ne", "sw", "se"], D = ["img-left", "img-right", "img-top", "img-center"], R = {
|
|
1143
|
+
"img-left": "tplimgleft",
|
|
1144
|
+
"img-right": "tplimgright",
|
|
1145
|
+
"img-top": "tplimgtop",
|
|
1146
|
+
"img-center": "tplimgcenter"
|
|
1147
|
+
}, xt = {
|
|
1148
|
+
"img-left": a.tplleft,
|
|
1149
|
+
"img-right": a.tplright,
|
|
1150
|
+
"img-top": a.tpltop,
|
|
1151
|
+
"img-center": a.tplcenter
|
|
1152
|
+
}, A = class A {
|
|
1116
1153
|
constructor(t) {
|
|
1117
|
-
this.lang = "en", this.contentClass = "fable-content-" + A.instanceCounter++, this.contentStyleEl = null, this.savedRange = null, this.foreColor = "#000000", this.backColor = "#FACC15", this.openPop = null, this.openSubEl = null, this.popAnchor = null, this.dlgOvl = null, this.tblActive = null, this.tblCorner = null, this.tblColBars = [], this.tblCtx = null, this.tblCellMark = null, this.tblOpMark = null, this.tblOpMarkKind = null, this.imgActive = null, this.imgHandles = [], this.imgCtx = null, this.imgHideTimer = null, this.phActive = null, this.phCtx = null, this.phUploadTarget = null, this.selCtx = null, this.revisions = [], this.revTimer = null, this.draftTimer = null, this.draftStorageKey = "", this.listeners = [], this.isDestroyed = !1, this.options = {
|
|
1154
|
+
this.lang = "en", this.contentClass = "fable-content-" + A.instanceCounter++, this.contentStyleEl = null, this.savedRange = null, this.foreColor = "#000000", this.backColor = "#FACC15", this.openPop = null, this.openSubEl = null, this.popAnchor = null, this.dlgOvl = null, this.tblActive = null, this.tblCorner = null, this.tblColBars = [], this.tblCtx = null, this.tblCellMark = null, this.tblOpMark = null, this.tblOpMarkKind = null, this.imgActive = null, this.imgHandles = [], this.imgCtx = null, this.imgHideTimer = null, this.phActive = null, this.phCtx = null, this.phUploadTarget = null, this.selCtx = null, this.tplActive = null, this.tplCtx = null, this.revisions = [], this.revTimer = null, this.draftTimer = null, this.draftStorageKey = "", this.listeners = [], this.isDestroyed = !1, this.options = {
|
|
1118
1155
|
target: t.target,
|
|
1119
1156
|
language: t.language || "en",
|
|
1120
1157
|
height: t.height ?? 302,
|
|
@@ -1128,7 +1165,7 @@ const vt = ["nw", "ne", "sw", "se"], A = class A {
|
|
|
1128
1165
|
statusbar: t.statusbar ?? !0,
|
|
1129
1166
|
readonly: t.readonly ?? !1,
|
|
1130
1167
|
draftKey: t.draftKey ?? (typeof location < "u" ? location.pathname : "default"),
|
|
1131
|
-
fontFamilyFormats: t.fontFamilyFormats ??
|
|
1168
|
+
fontFamilyFormats: t.fontFamilyFormats ?? Q,
|
|
1132
1169
|
imageFileTypes: t.imageFileTypes ?? ["image/jpeg", "image/jpg", "image/png", "image/gif", "image/bmp", "image/webp"]
|
|
1133
1170
|
}, this.imageUploadHandler = t.imageUploadHandler, this.onImageUploadError = t.onImageUploadError, this.contentStyle = t.contentStyle, this.lang = this.options.language, this.draftStorageKey = "tmclone-draft:" + this.options.draftKey, this.initDOM(), this.bindEvents(), this.initUI(), this.recordRevision(), this.options.onReady(this);
|
|
1134
1171
|
}
|
|
@@ -1185,9 +1222,9 @@ const vt = ["nw", "ne", "sw", "se"], A = class A {
|
|
|
1185
1222
|
const t = window.getSelection();
|
|
1186
1223
|
t && this.ed.contains(t.anchorNode) ? (this.saveSel(), this.refreshState(), this.updateSelToolbar(t), this.positionCellMarker()) : this.clearSelToolbar();
|
|
1187
1224
|
}), this.on(this.ed, "input", () => {
|
|
1188
|
-
this.refreshState(), this.onChange(), this.positionTableHandles(), this.positionImageHandles(), this.positionImgPhCtx();
|
|
1225
|
+
this.refreshState(), this.onChange(), this.positionTableHandles(), this.positionImageHandles(), this.positionImgPhCtx(), this.positionTplCtx();
|
|
1189
1226
|
}), this.on(this.ed, "keydown", (t) => {
|
|
1190
|
-
t.altKey && t.key === "0" && (t.preventDefault(), this.helpDlg());
|
|
1227
|
+
t.altKey && t.key === "0" && (t.preventDefault(), this.helpDlg()), (t.key === "Delete" || t.key === "Backspace") && this.phActive && (t.preventDefault(), this.removeImgPlaceholder());
|
|
1191
1228
|
}), this.on(this.ed, "paste", (t) => this.handlePaste(t)), this.on(this.ed, "drop", (t) => {
|
|
1192
1229
|
var s, l, n;
|
|
1193
1230
|
t.preventDefault();
|
|
@@ -1196,13 +1233,15 @@ const vt = ["nw", "ne", "sw", "se"], A = class A {
|
|
|
1196
1233
|
const i = Array.from(((n = t.dataTransfer) == null ? void 0 : n.files) || []).find((o) => o.type.startsWith("image/"));
|
|
1197
1234
|
i && this.readImageFileInto(i, e);
|
|
1198
1235
|
}), this.on(this.ed, "dragover", (t) => t.preventDefault()), this.on(this.ed, "mousedown", (t) => {
|
|
1199
|
-
var
|
|
1200
|
-
const e = t.target, i = (
|
|
1236
|
+
var o, r, c, h;
|
|
1237
|
+
const e = t.target, i = (o = e.closest) == null ? void 0 : o.call(e, "table");
|
|
1201
1238
|
i && this.ed.contains(i) ? this.selectTableForResize(i) : this.clearTableHandles();
|
|
1202
|
-
const s = (
|
|
1203
|
-
s && this.ed.contains(s) && !this.options.readonly ? (t.preventDefault(), this.selectImgPlaceholder(s)) : this.clearImgPlaceholderSel();
|
|
1204
|
-
const l = (
|
|
1205
|
-
l && this.ed.contains(l) && !this.options.readonly ?
|
|
1239
|
+
const s = (r = e.closest) == null ? void 0 : r.call(e, ".img-ph");
|
|
1240
|
+
s && this.ed.contains(s) && !this.options.readonly ? (t.preventDefault(), this.ed.focus(), this.selectImgPlaceholder(s)) : this.clearImgPlaceholderSel();
|
|
1241
|
+
const l = (c = e.closest) == null ? void 0 : c.call(e, ".tpl");
|
|
1242
|
+
l && this.ed.contains(l) && !this.options.readonly ? this.selectTemplate(l) : this.clearTplSel();
|
|
1243
|
+
const n = (h = e.closest) == null ? void 0 : h.call(e, "img");
|
|
1244
|
+
n && this.ed.contains(n) && !this.options.readonly ? (t.preventDefault(), this.selectImage(n)) : this.clearImageHandles();
|
|
1206
1245
|
}), this.on(this.ed, "mouseover", (t) => {
|
|
1207
1246
|
var i, s;
|
|
1208
1247
|
if (this.options.readonly) return;
|
|
@@ -1215,15 +1254,15 @@ const vt = ["nw", "ne", "sw", "se"], A = class A {
|
|
|
1215
1254
|
const i = t.relatedTarget;
|
|
1216
1255
|
i && ((n = this.imgCtx) != null && n.contains(i) || this.imgHandles.some((r) => r.contains(i)) || ((o = i.closest) == null ? void 0 : o.call(i, "img")) === e) || this.scheduleImgHide();
|
|
1217
1256
|
}), this.on(this.ed, "scroll", () => {
|
|
1218
|
-
this.positionTableHandles(), this.positionImageHandles(), this.positionImgPhCtx();
|
|
1257
|
+
this.positionTableHandles(), this.positionImageHandles(), this.positionImgPhCtx(), this.positionTplCtx();
|
|
1219
1258
|
}), this.onWin(
|
|
1220
1259
|
"scroll",
|
|
1221
1260
|
() => {
|
|
1222
|
-
this.positionTableHandles(), this.positionImageHandles(), this.positionImgPhCtx(), this.repositionSelToolbar();
|
|
1261
|
+
this.positionTableHandles(), this.positionImageHandles(), this.positionImgPhCtx(), this.positionTplCtx(), this.repositionSelToolbar();
|
|
1223
1262
|
},
|
|
1224
1263
|
!0
|
|
1225
1264
|
), this.onWin("resize", () => {
|
|
1226
|
-
this.positionTableHandles(), this.positionImageHandles(), this.positionImgPhCtx(), this.repositionSelToolbar();
|
|
1265
|
+
this.positionTableHandles(), this.positionImageHandles(), this.positionImgPhCtx(), this.positionTplCtx(), this.repositionSelToolbar();
|
|
1227
1266
|
}), this.on(this.imgInput, "change", () => {
|
|
1228
1267
|
var s;
|
|
1229
1268
|
const t = (s = this.imgInput.files) == null ? void 0 : s[0];
|
|
@@ -1246,7 +1285,7 @@ const vt = ["nw", "ne", "sw", "se"], A = class A {
|
|
|
1246
1285
|
const t = (e = this.docInput.files) == null ? void 0 : e[0];
|
|
1247
1286
|
t && this.importWordFile(t).catch(() => alert(this.t("importfail")));
|
|
1248
1287
|
}), this.onDoc("mousedown", (t) => {
|
|
1249
|
-
this.ed.contains(t.target) || t.target === this.tblCorner || this.tblColBars.includes(t.target) || this.tblCtx && this.tblCtx.contains(t.target) || this.imgHandles.includes(t.target) || this.imgCtx && this.imgCtx.contains(t.target) || this.phCtx && this.phCtx.contains(t.target) || this.selCtx && this.selCtx.contains(t.target) || this.openPop && this.openPop.contains(t.target) || this.openSubEl && this.openSubEl.contains(t.target) || (this.clearTableHandles(), this.clearImageHandles(), this.clearImgPlaceholderSel(), this.clearSelToolbar());
|
|
1288
|
+
this.ed.contains(t.target) || t.target === this.tblCorner || this.tblColBars.includes(t.target) || this.tblCtx && this.tblCtx.contains(t.target) || this.imgHandles.includes(t.target) || this.imgCtx && this.imgCtx.contains(t.target) || this.phCtx && this.phCtx.contains(t.target) || this.tplCtx && this.tplCtx.contains(t.target) || this.selCtx && this.selCtx.contains(t.target) || this.openPop && this.openPop.contains(t.target) || this.openSubEl && this.openSubEl.contains(t.target) || (this.clearTableHandles(), this.clearImageHandles(), this.clearImgPlaceholderSel(), this.clearTplSel(), this.clearSelToolbar());
|
|
1250
1289
|
});
|
|
1251
1290
|
}
|
|
1252
1291
|
on(t, e, i) {
|
|
@@ -1263,7 +1302,7 @@ const vt = ["nw", "ne", "sw", "se"], A = class A {
|
|
|
1263
1302
|
return this.ed.innerHTML;
|
|
1264
1303
|
}
|
|
1265
1304
|
setContent(t) {
|
|
1266
|
-
this.ed.innerHTML = t || "<p><br></p>", this.refreshState(), this.clearTableHandles(), this.clearImageHandles(), this.clearImgPlaceholderSel(), this.clearSelToolbar(), this.onChange();
|
|
1305
|
+
this.ed.innerHTML = t || "<p><br></p>", this.refreshState(), this.clearTableHandles(), this.clearImageHandles(), this.clearImgPlaceholderSel(), this.clearTplSel(), this.clearSelToolbar(), this.onChange();
|
|
1267
1306
|
}
|
|
1268
1307
|
insertContent(t) {
|
|
1269
1308
|
this.restoreSel(), document.execCommand("insertHTML", !1, t), this.saveSel(), this.refreshState(), this.onChange();
|
|
@@ -1275,7 +1314,7 @@ const vt = ["nw", "ne", "sw", "se"], A = class A {
|
|
|
1275
1314
|
this.ed.focus();
|
|
1276
1315
|
}
|
|
1277
1316
|
async importWordFile(t) {
|
|
1278
|
-
const e = await
|
|
1317
|
+
const e = await yt(t);
|
|
1279
1318
|
this.recordRevision(), this.setContent(e), this.recordRevision();
|
|
1280
1319
|
}
|
|
1281
1320
|
restoreDraft() {
|
|
@@ -1296,7 +1335,7 @@ const vt = ["nw", "ne", "sw", "se"], A = class A {
|
|
|
1296
1335
|
return this.revisions.slice();
|
|
1297
1336
|
}
|
|
1298
1337
|
destroy() {
|
|
1299
|
-
this.isDestroyed || (this.isDestroyed = !0, this.revTimer != null && window.clearTimeout(this.revTimer), this.draftTimer != null && window.clearTimeout(this.draftTimer), this.closePop(), this.closeDlg(), this.clearTableHandles(), this.clearImageHandles(), this.clearImgPlaceholderSel(), this.clearSelToolbar(), this.listeners.forEach((t) => t()), this.listeners = [], this.shell && this.shell.parentNode && this.shell.parentNode.removeChild(this.shell), this.imgInput && this.imgInput.parentNode && this.imgInput.parentNode.removeChild(this.imgInput), this.docInput && this.docInput.parentNode && this.docInput.parentNode.removeChild(this.docInput), this.contentStyleEl = null);
|
|
1338
|
+
this.isDestroyed || (this.isDestroyed = !0, this.revTimer != null && window.clearTimeout(this.revTimer), this.draftTimer != null && window.clearTimeout(this.draftTimer), this.closePop(), this.closeDlg(), this.clearTableHandles(), this.clearImageHandles(), this.clearImgPlaceholderSel(), this.clearTplSel(), this.clearSelToolbar(), this.listeners.forEach((t) => t()), this.listeners = [], this.shell && this.shell.parentNode && this.shell.parentNode.removeChild(this.shell), this.imgInput && this.imgInput.parentNode && this.imgInput.parentNode.removeChild(this.imgInput), this.docInput && this.docInput.parentNode && this.docInput.parentNode.removeChild(this.docInput), this.contentStyleEl = null);
|
|
1300
1339
|
}
|
|
1301
1340
|
/* ---------------------------------------------------------- selection */
|
|
1302
1341
|
saveSel() {
|
|
@@ -1388,8 +1427,8 @@ const vt = ["nw", "ne", "sw", "se"], A = class A {
|
|
|
1388
1427
|
for (let h = this.revisions.length - 1; h >= 0; h--) {
|
|
1389
1428
|
const d = this.revisions[h], m = document.createElement("button");
|
|
1390
1429
|
m.type = "button";
|
|
1391
|
-
const g = (new DOMParser().parseFromString(d.html, "text/html").body.textContent || "").trim(), f = g ? g.split(/\s+/).length : 0,
|
|
1392
|
-
m.innerHTML = `<span>${
|
|
1430
|
+
const g = (new DOMParser().parseFromString(d.html, "text/html").body.textContent || "").trim(), f = g ? g.split(/\s+/).length : 0, v = h === this.revisions.length - 1;
|
|
1431
|
+
m.innerHTML = `<span>${v ? this.t("currentver") : o.format(new Date(d.time))}</span><span class="wc">${f} ${this.t("words")}</span>`, m.addEventListener("click", () => c(h)), r[h] = m, i.appendChild(m);
|
|
1393
1432
|
}
|
|
1394
1433
|
i.append(l), l.addEventListener("click", () => {
|
|
1395
1434
|
const h = this.revisions[n];
|
|
@@ -1473,7 +1512,7 @@ const vt = ["nw", "ne", "sw", "se"], A = class A {
|
|
|
1473
1512
|
return l.type = "button", l.className = "cchip", l.title = s, l.addEventListener("mousedown", (n) => {
|
|
1474
1513
|
n.preventDefault(), this.saveSel();
|
|
1475
1514
|
}), l;
|
|
1476
|
-
}, e =
|
|
1515
|
+
}, e = tt.map((s) => {
|
|
1477
1516
|
const l = t(this.t("forecolor"));
|
|
1478
1517
|
return l.style.background = s, l.addEventListener("click", () => this.applyColor("fore", s)), l;
|
|
1479
1518
|
}), i = t(this.t("forecolor"));
|
|
@@ -1521,17 +1560,17 @@ const vt = ["nw", "ne", "sw", "se"], A = class A {
|
|
|
1521
1560
|
]), h.insertAdjacentHTML("beforeend", '<div class="sep"></div>');
|
|
1522
1561
|
const d = document.createElement("div");
|
|
1523
1562
|
d.className = "mi-grid", s.forEach(([m, g], f) => {
|
|
1524
|
-
const
|
|
1525
|
-
|
|
1563
|
+
const v = document.createElement("button");
|
|
1564
|
+
v.className = "mi" + (r === m ? " on" : ""), v.innerHTML = `<span class="ic">${g}</span><span class="prev">${l[f]}</span>`, v.addEventListener("click", () => {
|
|
1526
1565
|
this.closePop(), this.setListStyle(e, m);
|
|
1527
|
-
}), d.appendChild(
|
|
1566
|
+
}), d.appendChild(v);
|
|
1528
1567
|
}), h.appendChild(d);
|
|
1529
1568
|
});
|
|
1530
1569
|
}
|
|
1531
1570
|
colorMenu(t, e) {
|
|
1532
1571
|
this.popup(t, (i) => {
|
|
1533
1572
|
const s = document.createElement("div");
|
|
1534
|
-
s.className = "cpal",
|
|
1573
|
+
s.className = "cpal", et.forEach((d) => {
|
|
1535
1574
|
const m = document.createElement("button");
|
|
1536
1575
|
m.style.background = d, m.title = d, m.addEventListener("click", () => {
|
|
1537
1576
|
this.closePop(), this.applyColor(e, d);
|
|
@@ -1578,7 +1617,7 @@ const vt = ["nw", "ne", "sw", "se"], A = class A {
|
|
|
1578
1617
|
this.popup(t, (e) => {
|
|
1579
1618
|
this.menuItems(
|
|
1580
1619
|
e,
|
|
1581
|
-
|
|
1620
|
+
Y.map((i) => ({
|
|
1582
1621
|
label: i,
|
|
1583
1622
|
on: this.currentSize() === i,
|
|
1584
1623
|
action: () => this.applyFontSize(i)
|
|
@@ -1630,7 +1669,7 @@ const vt = ["nw", "ne", "sw", "se"], A = class A {
|
|
|
1630
1669
|
this.saveSel(), this.refreshState(), this.onChange();
|
|
1631
1670
|
}
|
|
1632
1671
|
stepFontSize(t) {
|
|
1633
|
-
const e = parseInt(this.currentSize(), 10) || 14, i = Math.min(
|
|
1672
|
+
const e = parseInt(this.currentSize(), 10) || 14, i = Math.min(K, Math.max(G, e + t));
|
|
1634
1673
|
i !== e && this.applyFontSize(i + "px");
|
|
1635
1674
|
}
|
|
1636
1675
|
/* ------------------------------------------------ case / spacing / link */
|
|
@@ -1672,7 +1711,7 @@ const vt = ["nw", "ne", "sw", "se"], A = class A {
|
|
|
1672
1711
|
this.popup(t, (i) => {
|
|
1673
1712
|
this.menuItems(i, [
|
|
1674
1713
|
{ label: this.t("normal"), on: !e, action: () => this.applyBlockStyle("lineHeight", "") },
|
|
1675
|
-
...
|
|
1714
|
+
...V.map((s) => ({
|
|
1676
1715
|
label: s,
|
|
1677
1716
|
on: e === s,
|
|
1678
1717
|
action: () => this.applyBlockStyle("lineHeight", s)
|
|
@@ -1685,7 +1724,7 @@ const vt = ["nw", "ne", "sw", "se"], A = class A {
|
|
|
1685
1724
|
this.popup(t, (i) => {
|
|
1686
1725
|
this.menuItems(i, [
|
|
1687
1726
|
{ label: this.t("normal"), on: !e, action: () => this.applyBlockStyle("wordSpacing", "") },
|
|
1688
|
-
...
|
|
1727
|
+
...J.map((s) => ({
|
|
1689
1728
|
label: s,
|
|
1690
1729
|
on: e === s,
|
|
1691
1730
|
action: () => this.applyBlockStyle("wordSpacing", s)
|
|
@@ -1747,7 +1786,7 @@ const vt = ["nw", "ne", "sw", "se"], A = class A {
|
|
|
1747
1786
|
this.popup(t, (e) => {
|
|
1748
1787
|
this.menuItems(
|
|
1749
1788
|
e,
|
|
1750
|
-
|
|
1789
|
+
P.map(([i, s]) => ({
|
|
1751
1790
|
label: this.blockLabel(i),
|
|
1752
1791
|
previewStyle: i.startsWith("h") ? `font-weight:700;font-size:${22 - 2 * +i[1]}px` : i === "pre" ? "font-family:monospace" : "",
|
|
1753
1792
|
on: this.currentBlock() === i,
|
|
@@ -1850,6 +1889,7 @@ const vt = ["nw", "ne", "sw", "se"], A = class A {
|
|
|
1850
1889
|
rtl: () => this.tbtn(a.rtl, this.t("rtl"), () => this.setDir("rtl"), "rtl"),
|
|
1851
1890
|
quickimage: () => this.tbtn(a.image, this.t("quickimage"), () => this.insertImagePlaceholder()),
|
|
1852
1891
|
quicktable: () => t,
|
|
1892
|
+
template: () => this.menuTbtn(a.templateic, this.t("template"), (e) => this.templateMenu(e)),
|
|
1853
1893
|
charmap: () => this.tbtn(a.charic, this.t("charmap"), () => this.charMap()),
|
|
1854
1894
|
fullscreen: () => this.tbtn(a.fullscreen, this.t("fullscreen"), () => this.toggleFullscreen(), "fullscreen"),
|
|
1855
1895
|
sourcecode: () => this.tbtn(a.srcic, this.t("sourcecode"), () => this.sourceDlg())
|
|
@@ -1857,7 +1897,7 @@ const vt = ["nw", "ne", "sw", "se"], A = class A {
|
|
|
1857
1897
|
}
|
|
1858
1898
|
buildToolbar() {
|
|
1859
1899
|
this.toolbar.innerHTML = "";
|
|
1860
|
-
const t = this.options.toolbar === !0 ?
|
|
1900
|
+
const t = this.options.toolbar === !0 ? X : this.options.toolbar, e = this.buildToolbarRegistry();
|
|
1861
1901
|
this.parseToolbarString(t).forEach((i) => {
|
|
1862
1902
|
const s = [];
|
|
1863
1903
|
i.forEach((l) => {
|
|
@@ -1911,6 +1951,7 @@ const vt = ["nw", "ne", "sw", "se"], A = class A {
|
|
|
1911
1951
|
this.mItem("link", a.link, () => this.linkDlg()),
|
|
1912
1952
|
this.mItem("image", a.image, () => this.insertImagePlaceholder()),
|
|
1913
1953
|
{ label: this.t("inserttable"), icon: a.tableic, action: () => this.tableGrid(this.menubar.querySelector('[data-menu-key="table"]') || this.menubar) },
|
|
1954
|
+
{ label: this.t("template"), icon: a.templateic, subBuild: (s) => this.buildTemplatePickInto(s) },
|
|
1914
1955
|
this.mItem("hr", a.hric, () => this.exec("insertHorizontalRule")),
|
|
1915
1956
|
"|",
|
|
1916
1957
|
this.mItem("charmap", a.charic, () => this.charMap()),
|
|
@@ -1984,10 +2025,10 @@ const vt = ["nw", "ne", "sw", "se"], A = class A {
|
|
|
1984
2025
|
this.tblActive = s.closest("table"), this.tablePropsDlg();
|
|
1985
2026
|
}
|
|
1986
2027
|
},
|
|
1987
|
-
{ label: this.t("deltable"), icon: a.
|
|
2028
|
+
{ label: this.t("deltable"), icon: a.trash, action: () => this.tableOp("deltable") }
|
|
1988
2029
|
],
|
|
1989
2030
|
help: [this.mItem("helpttl", a.helpic, () => this.helpDlg(), "Alt+0")]
|
|
1990
|
-
}, e = this.options.menubar === !0 ?
|
|
2031
|
+
}, e = this.options.menubar === !0 ? _ : this.options.menubar, i = /* @__PURE__ */ new Set();
|
|
1991
2032
|
e.split(/\s+/).filter(Boolean).forEach((s) => {
|
|
1992
2033
|
if (i.has(s)) return;
|
|
1993
2034
|
if (i.add(s), !t[s]) {
|
|
@@ -2036,17 +2077,17 @@ const vt = ["nw", "ne", "sw", "se"], A = class A {
|
|
|
2036
2077
|
const t = this.tblActive;
|
|
2037
2078
|
if (!t) return;
|
|
2038
2079
|
let e, i, s, l, n;
|
|
2039
|
-
const o = "display:flex;align-items:center;gap:10px;margin:10px 0", r = "width:120px;color:#556;flex:none", c = "flex:1;border:1px solid #cfd6df;border-radius:6px;padding:7px 9px;font:14px inherit", h = t.querySelector("td,th"), d = t.style.width || "", m = h && h.style.padding ? parseFloat(h.style.padding) : "", g = t.style.borderSpacing ? parseFloat(t.style.borderSpacing) : "", f = t.style.borderWidth ? parseFloat(t.style.borderWidth) : "",
|
|
2080
|
+
const o = "display:flex;align-items:center;gap:10px;margin:10px 0", r = "width:120px;color:#556;flex:none", c = "flex:1;border:1px solid #cfd6df;border-radius:6px;padding:7px 9px;font:14px inherit", h = t.querySelector("td,th"), d = t.style.width || "", m = h && h.style.padding ? parseFloat(h.style.padding) : "", g = t.style.borderSpacing ? parseFloat(t.style.borderSpacing) : "", f = t.style.borderWidth ? parseFloat(t.style.borderWidth) : "", v = t.style.marginLeft, y = t.style.marginRight, T = v === "auto" && y === "auto" ? "center" : v === "auto" ? "right" : y === "auto" && v === "0" ? "left" : "";
|
|
2040
2081
|
this.dialog(
|
|
2041
2082
|
this.t("tablepropsttl"),
|
|
2042
|
-
(
|
|
2043
|
-
const
|
|
2083
|
+
(S) => {
|
|
2084
|
+
const M = (x, E) => {
|
|
2044
2085
|
const H = document.createElement("div");
|
|
2045
2086
|
H.style.cssText = o;
|
|
2046
2087
|
const N = document.createElement("span");
|
|
2047
|
-
N.style.cssText = r, N.textContent = this.t(x), H.append(N, E),
|
|
2088
|
+
N.style.cssText = r, N.textContent = this.t(x), H.append(N, E), S.appendChild(H);
|
|
2048
2089
|
};
|
|
2049
|
-
e = document.createElement("input"), e.type = "text", e.style.cssText = c, e.placeholder = "e.g. 600px or 100%", e.value = d,
|
|
2090
|
+
e = document.createElement("input"), e.type = "text", e.style.cssText = c, e.placeholder = "e.g. 600px or 100%", e.value = d, M("tblwidth", e), i = document.createElement("input"), i.type = "number", i.min = "0", i.style.cssText = c, i.value = String(m), M("tblcellpadding", i), s = document.createElement("input"), s.type = "number", s.min = "0", s.style.cssText = c, s.value = String(g), M("tblcellspacing", s), l = document.createElement("input"), l.type = "number", l.min = "0", l.style.cssText = c, l.value = String(f), M("tblborder", l), n = document.createElement("select"), n.style.cssText = c, [
|
|
2050
2091
|
["", "alignnone"],
|
|
2051
2092
|
["left", "alignleft"],
|
|
2052
2093
|
["center", "aligncenter"],
|
|
@@ -2054,7 +2095,7 @@ const vt = ["nw", "ne", "sw", "se"], A = class A {
|
|
|
2054
2095
|
].forEach(([x, E]) => {
|
|
2055
2096
|
const H = document.createElement("option");
|
|
2056
2097
|
H.value = x, H.textContent = this.t(E), x === T && (H.selected = !0), n.appendChild(H);
|
|
2057
|
-
}),
|
|
2098
|
+
}), M("tblalign", n);
|
|
2058
2099
|
},
|
|
2059
2100
|
[
|
|
2060
2101
|
{ label: this.t("cancel"), action: () => this.closeDlg() },
|
|
@@ -2284,7 +2325,7 @@ const vt = ["nw", "ne", "sw", "se"], A = class A {
|
|
|
2284
2325
|
this.t("charmap").replace("…", ""),
|
|
2285
2326
|
(t) => {
|
|
2286
2327
|
const e = document.createElement("div");
|
|
2287
|
-
e.className = "chgrid",
|
|
2328
|
+
e.className = "chgrid", it.forEach((i) => {
|
|
2288
2329
|
const s = document.createElement("button");
|
|
2289
2330
|
s.textContent = i, s.onclick = () => {
|
|
2290
2331
|
this.closeDlg(), this.exec("insertText", i);
|
|
@@ -2303,14 +2344,13 @@ const vt = ["nw", "ne", "sw", "se"], A = class A {
|
|
|
2303
2344
|
this.imgInput.value = "", this.imgInput.click();
|
|
2304
2345
|
}
|
|
2305
2346
|
/* ---------------------------------------------- image upload placeholder */
|
|
2347
|
+
imgPhHTML(t) {
|
|
2348
|
+
return `<div class="img-ph"${t ? ` id="${t}"` : ""} contenteditable="false">${a.image}<span>${this.t("dropimage")}</span></div>`;
|
|
2349
|
+
}
|
|
2306
2350
|
insertImagePlaceholder() {
|
|
2307
2351
|
this.restoreSel();
|
|
2308
2352
|
const t = "img-ph-" + Date.now().toString(36) + Math.random().toString(36).slice(2, 6);
|
|
2309
|
-
document.execCommand(
|
|
2310
|
-
"insertHTML",
|
|
2311
|
-
!1,
|
|
2312
|
-
`<div class="img-ph" id="${t}" contenteditable="false">${a.image}<span>${this.t("dropimage")}</span></div>`
|
|
2313
|
-
);
|
|
2353
|
+
document.execCommand("insertHTML", !1, this.imgPhHTML(t));
|
|
2314
2354
|
const e = this.ed.querySelector("#" + t);
|
|
2315
2355
|
e && (e.removeAttribute("id"), this.selectImgPlaceholder(e)), this.onChange();
|
|
2316
2356
|
}
|
|
@@ -2318,6 +2358,10 @@ const vt = ["nw", "ne", "sw", "se"], A = class A {
|
|
|
2318
2358
|
var t, e;
|
|
2319
2359
|
(t = this.phCtx) == null || t.remove(), this.phCtx = null, (e = this.phActive) == null || e.classList.remove("active"), this.phActive = null;
|
|
2320
2360
|
}
|
|
2361
|
+
removeImgPlaceholder() {
|
|
2362
|
+
const t = this.phActive;
|
|
2363
|
+
t && (this.clearImgPlaceholderSel(), (t.closest(".tpl-media") || t).remove(), this.refreshState(), this.onChange());
|
|
2364
|
+
}
|
|
2321
2365
|
selectImgPlaceholder(t) {
|
|
2322
2366
|
this.phActive !== t && (this.clearImgPlaceholderSel(), this.phActive = t, t.classList.add("active"), this.phCtx = document.createElement("div"), this.phCtx.className = "imgctx img-ph-ctx", this.phCtx.dir = this.dir(), document.body.appendChild(this.phCtx), this.renderPhCtxButtons());
|
|
2323
2367
|
}
|
|
@@ -2327,7 +2371,9 @@ const vt = ["nw", "ne", "sw", "se"], A = class A {
|
|
|
2327
2371
|
this.ctxBtn(a.uploadic, this.t("uploadimg"), () => {
|
|
2328
2372
|
this.phUploadTarget = this.phActive, this.pickImage();
|
|
2329
2373
|
}),
|
|
2330
|
-
this.ctxBtn(a.link, this.t("imagelink"), () => this.renderPhCtxUrlInput())
|
|
2374
|
+
this.ctxBtn(a.link, this.t("imagelink"), () => this.renderPhCtxUrlInput()),
|
|
2375
|
+
this.ctxSep(),
|
|
2376
|
+
this.ctxBtn(a.trash, this.t("deleteimg"), () => this.removeImgPlaceholder())
|
|
2331
2377
|
), this.positionImgPhCtx());
|
|
2332
2378
|
}
|
|
2333
2379
|
renderPhCtxUrlInput() {
|
|
@@ -2395,6 +2441,67 @@ const vt = ["nw", "ne", "sw", "se"], A = class A {
|
|
|
2395
2441
|
let l = t.bottom + scrollY + 8;
|
|
2396
2442
|
t.bottom + 8 + i > innerHeight - 4 && (l = Math.max(this.ctxMinTop(), t.top + scrollY - i - 8)), this.phCtx.style.left = s + "px", this.phCtx.style.top = l + "px";
|
|
2397
2443
|
}
|
|
2444
|
+
/* ---------------------------------------------------------- templates */
|
|
2445
|
+
templateMenu(t) {
|
|
2446
|
+
this.popup(t, (e) => this.buildTemplatePickInto(e));
|
|
2447
|
+
}
|
|
2448
|
+
/** Miniature div-based mockup of a layout, mirroring what the block looks
|
|
2449
|
+
like in the editor: grey box = image slot, bars = heading/paragraph. */
|
|
2450
|
+
tplPreviewHTML(t) {
|
|
2451
|
+
const e = '<span class="pv-img"></span>', i = '<span class="pv-h"></span>', s = (r) => `<span class="pv-l" style="width:${r}%"></span>`, l = (r) => `<span class="pv-col">${r}</span>`, n = (r) => `<span class="pv-row">${r}</span>`, o = l(i + s(100) + s(88));
|
|
2452
|
+
return t === "img-left" ? `<span class="pv">${n(e + o)}${s(100)}${s(72)}</span>` : t === "img-right" ? `<span class="pv">${n(o + e)}${s(100)}${s(72)}</span>` : t === "img-top" ? `<span class="pv pv-c">${e}${i}${s(100)}${s(72)}</span>` : `<span class="pv pv-c">${i}${s(100)}${s(72)}${e}</span>`;
|
|
2453
|
+
}
|
|
2454
|
+
buildTemplatePickInto(t, e) {
|
|
2455
|
+
const i = document.createElement("div");
|
|
2456
|
+
i.className = "tplpick", D.forEach((s) => {
|
|
2457
|
+
const l = document.createElement("button");
|
|
2458
|
+
l.type = "button", l.className = "tpltile", l.title = this.t(R[s]), l.innerHTML = this.tplPreviewHTML(s) + `<span class="tpllbl">${this.t(R[s])}</span>`, l.addEventListener("click", () => {
|
|
2459
|
+
this.closePop(), this.insertTemplate(s), e == null || e();
|
|
2460
|
+
}), i.appendChild(l);
|
|
2461
|
+
}), t.appendChild(i);
|
|
2462
|
+
}
|
|
2463
|
+
insertTemplate(t) {
|
|
2464
|
+
this.restoreSel();
|
|
2465
|
+
const e = `<div class="tpl-media" contenteditable="false">${this.imgPhHTML()}</div>`, i = `<div class="tpl-text"><h2>${this.t("heading")}</h2><p>${this.t("para")}</p></div>`, s = t === "img-center" ? i + e : e + i;
|
|
2466
|
+
document.execCommand("insertHTML", !1, `<div class="tpl tpl-${t}">${s}</div><p><br></p>`), this.saveSel(), this.onChange();
|
|
2467
|
+
}
|
|
2468
|
+
clearTplSel() {
|
|
2469
|
+
var t, e;
|
|
2470
|
+
(t = this.tplCtx) == null || t.remove(), this.tplCtx = null, (e = this.tplActive) == null || e.classList.remove("tpl-selected"), this.tplActive = null;
|
|
2471
|
+
}
|
|
2472
|
+
selectTemplate(t) {
|
|
2473
|
+
this.tplActive !== t && (this.clearTplSel(), this.tplActive = t, t.classList.add("tpl-selected"), this.tplCtx = document.createElement("div"), this.tplCtx.className = "imgctx tplctx", this.tplCtx.dir = this.dir(), document.body.appendChild(this.tplCtx), this.renderTplCtxButtons());
|
|
2474
|
+
}
|
|
2475
|
+
renderTplCtxButtons() {
|
|
2476
|
+
const t = this.tplCtx, e = this.tplActive;
|
|
2477
|
+
!t || !e || (t.innerHTML = "", D.forEach((i) => {
|
|
2478
|
+
const s = this.ctxBtn(xt[i], this.t(R[i]), () => this.setTplLayout(i));
|
|
2479
|
+
s.classList.toggle("on", e.classList.contains("tpl-" + i)), t.appendChild(s);
|
|
2480
|
+
}), t.append(this.ctxSep(), this.ctxBtn(a.trash, this.t("deltemplate"), () => this.removeTemplate())), this.positionTplCtx());
|
|
2481
|
+
}
|
|
2482
|
+
setTplLayout(t) {
|
|
2483
|
+
const e = this.tplActive;
|
|
2484
|
+
if (!e) return;
|
|
2485
|
+
D.forEach((l) => e.classList.remove("tpl-" + l)), e.classList.add("tpl-" + t);
|
|
2486
|
+
const i = e.querySelector(":scope > .tpl-media"), s = e.querySelector(":scope > .tpl-text");
|
|
2487
|
+
i && s && (t === "img-center" ? e.appendChild(i) : e.insertBefore(i, s)), this.renderTplCtxButtons(), this.positionImgPhCtx(), this.positionImageHandles(), this.onChange();
|
|
2488
|
+
}
|
|
2489
|
+
removeTemplate() {
|
|
2490
|
+
const t = this.tplActive;
|
|
2491
|
+
t && (this.clearTplSel(), this.phActive && t.contains(this.phActive) && this.clearImgPlaceholderSel(), this.imgActive && t.contains(this.imgActive) && this.clearImageHandles(), t.remove(), this.refreshState(), this.onChange());
|
|
2492
|
+
}
|
|
2493
|
+
positionTplCtx() {
|
|
2494
|
+
if (this.tplActive && !document.body.contains(this.tplActive)) {
|
|
2495
|
+
this.clearTplSel();
|
|
2496
|
+
return;
|
|
2497
|
+
}
|
|
2498
|
+
if (!this.tplActive || !this.tplCtx) return;
|
|
2499
|
+
const t = this.tplActive.getBoundingClientRect(), e = this.tplCtx.offsetWidth, i = this.tplCtx.offsetHeight;
|
|
2500
|
+
let s = t.left + scrollX + (t.width - e) / 2;
|
|
2501
|
+
s = Math.max(8 + scrollX, Math.min(s, scrollX + innerWidth - e - 8));
|
|
2502
|
+
let l = t.top + scrollY - i - 8;
|
|
2503
|
+
l < this.ctxMinTop() && (l = t.bottom + scrollY + 8), this.tplCtx.style.left = s + "px", this.tplCtx.style.top = l + "px";
|
|
2504
|
+
}
|
|
2398
2505
|
pickWordDoc() {
|
|
2399
2506
|
this.docInput.value = "", this.docInput.click();
|
|
2400
2507
|
}
|
|
@@ -2463,7 +2570,7 @@ const vt = ["nw", "ne", "sw", "se"], A = class A {
|
|
|
2463
2570
|
e(this.ctxBtn(a.colafter, this.t("colafter"), () => this.tableOp("colafter")), "col"),
|
|
2464
2571
|
e(this.ctxBtn(a.coldelete, this.t("delcol"), () => this.tableOp("delcol")), "col"),
|
|
2465
2572
|
this.ctxSep(),
|
|
2466
|
-
this.ctxBtn(a.
|
|
2573
|
+
this.ctxBtn(a.trash, this.t("deltable"), () => this.tableOp("deltable")),
|
|
2467
2574
|
this.ctxBtn(a.tableic, this.t("tablepropsttl"), () => this.tablePropsDlg())
|
|
2468
2575
|
), document.body.appendChild(t), t;
|
|
2469
2576
|
}
|
|
@@ -2522,8 +2629,8 @@ const vt = ["nw", "ne", "sw", "se"], A = class A {
|
|
|
2522
2629
|
const r = t.clientX, c = n[0].getBoundingClientRect().width, h = o[0].getBoundingClientRect().width;
|
|
2523
2630
|
i.style.tableLayout = "fixed", this.withNoTextSelect((d) => {
|
|
2524
2631
|
const m = (f) => {
|
|
2525
|
-
const
|
|
2526
|
-
n.forEach((
|
|
2632
|
+
const v = (s ? -1 : 1) * (f.clientX - r);
|
|
2633
|
+
n.forEach((y) => y.style.width = Math.max(24, Math.round(c + v)) + "px"), o.forEach((y) => y.style.width = Math.max(24, Math.round(h - v)) + "px"), this.positionTableHandles();
|
|
2527
2634
|
}, g = () => {
|
|
2528
2635
|
window.removeEventListener("mousemove", m), window.removeEventListener("mouseup", g), d(), this.onChange();
|
|
2529
2636
|
};
|
|
@@ -2542,7 +2649,7 @@ const vt = ["nw", "ne", "sw", "se"], A = class A {
|
|
|
2542
2649
|
this.cancelImgHide(), this.imgHandles.forEach((i) => i.remove()), this.imgHandles = [], (t = this.imgCtx) == null || t.remove(), this.imgCtx = null, (e = this.imgActive) == null || e.classList.remove("img-selected"), this.imgActive = null;
|
|
2543
2650
|
}
|
|
2544
2651
|
selectImage(t) {
|
|
2545
|
-
this.imgActive !== t && (this.clearImageHandles(), this.imgActive = t, t.classList.add("img-selected"), this.imgHandles =
|
|
2652
|
+
this.imgActive !== t && (this.clearImageHandles(), this.imgActive = t, t.classList.add("img-selected"), this.imgHandles = wt.map((e) => {
|
|
2546
2653
|
const i = document.createElement("div");
|
|
2547
2654
|
return i.className = "img-handle img-handle-" + e, i.dataset.corner = e, i.addEventListener("mousedown", (s) => this.startImageResizeDrag(s, e)), i.addEventListener("mouseenter", () => this.cancelImgHide()), i.addEventListener("mouseleave", () => this.scheduleImgHide()), document.body.appendChild(i), i;
|
|
2548
2655
|
}), this.imgCtx = this.buildImageCtxToolbar(t), this.positionImageHandles());
|
|
@@ -2580,7 +2687,8 @@ const vt = ["nw", "ne", "sw", "se"], A = class A {
|
|
|
2580
2687
|
}),
|
|
2581
2688
|
this.ctxSep(),
|
|
2582
2689
|
r(a.trash, this.t("deleteimg"), !1, () => {
|
|
2583
|
-
t.
|
|
2690
|
+
const c = t.closest(".tpl-media");
|
|
2691
|
+
c && this.ed.contains(c) ? t.outerHTML = this.imgPhHTML() : t.remove(), this.clearImageHandles(), this.onChange();
|
|
2584
2692
|
})
|
|
2585
2693
|
), e.addEventListener("mousedown", (c) => c.preventDefault()), e.addEventListener("mouseenter", () => this.cancelImgHide()), e.addEventListener("mouseleave", () => this.scheduleImgHide()), document.body.appendChild(e), e;
|
|
2586
2694
|
}
|
|
@@ -2745,7 +2853,7 @@ const vt = ["nw", "ne", "sw", "se"], A = class A {
|
|
|
2745
2853
|
const f = this.toolbar.querySelector(`[data-id=${d}] .lbl`);
|
|
2746
2854
|
f && (f.textContent = m || g || "", f.classList.toggle("empty", !m));
|
|
2747
2855
|
};
|
|
2748
|
-
o("fontsel", this.currentFont()), o("sizesel", this.currentSize().replace("px", "")), e && o("blocksel",
|
|
2856
|
+
o("fontsel", this.currentFont()), o("sizesel", this.currentSize().replace("px", "")), e && o("blocksel", P.some((d) => d[0] === i) ? this.blockLabel(i) : this.t("para")), this.sbWords.textContent = this.countWords() + " " + this.t("words");
|
|
2749
2857
|
}
|
|
2750
2858
|
countWords() {
|
|
2751
2859
|
const t = (this.ed.textContent || "").trim();
|
|
@@ -2764,7 +2872,7 @@ const vt = ["nw", "ne", "sw", "se"], A = class A {
|
|
|
2764
2872
|
}, l.readAsDataURL(s.getAsFile());
|
|
2765
2873
|
return;
|
|
2766
2874
|
}
|
|
2767
|
-
i ? document.execCommand("insertHTML", !1,
|
|
2875
|
+
i ? document.execCommand("insertHTML", !1, mt(i, this.dir())) : document.execCommand("insertHTML", !1, ut(e.getData("text/plain"))), this.onChange();
|
|
2768
2876
|
}
|
|
2769
2877
|
/* ---------------------------------------------------------- init */
|
|
2770
2878
|
initUI() {
|
|
@@ -2772,18 +2880,18 @@ const vt = ["nw", "ne", "sw", "se"], A = class A {
|
|
|
2772
2880
|
}
|
|
2773
2881
|
};
|
|
2774
2882
|
A.instanceCounter = 0;
|
|
2775
|
-
let
|
|
2883
|
+
let W = A;
|
|
2776
2884
|
export {
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2885
|
+
P as BLOCKS,
|
|
2886
|
+
it as CHARS,
|
|
2887
|
+
et as COLORS,
|
|
2888
|
+
Q as FONTS,
|
|
2889
|
+
W as FableEditor,
|
|
2890
|
+
j as I18N,
|
|
2783
2891
|
a as IC,
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2892
|
+
Y as SIZES,
|
|
2893
|
+
Ct as TXT,
|
|
2894
|
+
mt as cleanPastedHTML,
|
|
2787
2895
|
B as getStrings,
|
|
2788
|
-
|
|
2896
|
+
ut as normalizeTextPaste
|
|
2789
2897
|
};
|