fable-editor 1.2.8 → 1.3.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/dist/angular/core/editor.d.ts +34 -0
- package/dist/angular/core/word-image-paste.d.ts +27 -0
- package/dist/angular/esm2022/core/editor.mjs +360 -5
- package/dist/angular/esm2022/core/word-image-paste.mjs +189 -0
- package/dist/angular/fesm2022/fable-editor.mjs +547 -4
- package/dist/angular/fesm2022/fable-editor.mjs.map +1 -1
- package/dist/core/editor.css +14 -0
- package/dist/core/editor.d.ts +34 -0
- package/dist/core/editor.d.ts.map +1 -1
- package/dist/core/index.cjs +4 -4
- package/dist/core/index.mjs +1225 -927
- package/dist/core/word-image-paste.d.ts +28 -0
- package/dist/core/word-image-paste.d.ts.map +1 -0
- package/dist/react/index.cjs +12 -12
- package/dist/react/index.mjs +1193 -895
- package/package.json +1 -1
- package/style.css +14 -0
package/dist/core/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const ct = {
|
|
2
2
|
en: {
|
|
3
3
|
dir: "ltr",
|
|
4
4
|
file: "File",
|
|
@@ -384,10 +384,10 @@ const it = {
|
|
|
384
384
|
emcat_flags: "أعلام"
|
|
385
385
|
}
|
|
386
386
|
};
|
|
387
|
-
function
|
|
388
|
-
return
|
|
387
|
+
function O(h) {
|
|
388
|
+
return ct[h];
|
|
389
389
|
}
|
|
390
|
-
const
|
|
390
|
+
const ht = "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 code changecase lineheight wordspacing letterspacing | removeformat | blocks | ltr rtl | quickimage quickvideo quicktable codesample template charmap emoji | fullscreen sourcecode", dt = "file edit view insert format tools table help", pt = [
|
|
391
391
|
["Andale Mono", "andale mono,times"],
|
|
392
392
|
["Arial", "arial,helvetica,sans-serif"],
|
|
393
393
|
["Arial Black", "arial black,avant garde"],
|
|
@@ -407,7 +407,7 @@ const st = "undo redo | preview print | importword revhistory | fontfamily fonts
|
|
|
407
407
|
["Verdana", "verdana,geneva"],
|
|
408
408
|
["Webdings", "webdings"],
|
|
409
409
|
["Wingdings", "wingdings,zapf dingbats"]
|
|
410
|
-
],
|
|
410
|
+
], ut = ["8px", "9px", "10px", "11px", "12px", "14px", "16px", "18px", "20px", "24px", "28px", "32px", "36px", "48px", "72px", "96px"], mt = 1, gt = 100, W = ["1", "1.15", "1.4", "1.5", "1.75", "2", "2.5", "3"], V = ["1px", "2px", "4px", "6px", "8px", "12px"], j = ["0.5px", "1px", "1.5px", "2px", "3px", "4px"], X = [
|
|
411
411
|
["plain", "Plain text"],
|
|
412
412
|
["html", "HTML/XML"],
|
|
413
413
|
["css", "CSS"],
|
|
@@ -424,7 +424,7 @@ const st = "undo redo | preview print | importword revhistory | fontfamily fonts
|
|
|
424
424
|
["rust", "Rust"],
|
|
425
425
|
["sql", "SQL"],
|
|
426
426
|
["bash", "Bash/Shell"]
|
|
427
|
-
],
|
|
427
|
+
], Q = [
|
|
428
428
|
["p", "para"],
|
|
429
429
|
["h1", "heading1"],
|
|
430
430
|
["h2", "heading2"],
|
|
@@ -433,7 +433,7 @@ const st = "undo redo | preview print | importword revhistory | fontfamily fonts
|
|
|
433
433
|
["h5", "heading5"],
|
|
434
434
|
["h6", "heading6"],
|
|
435
435
|
["pre", "pre"]
|
|
436
|
-
],
|
|
436
|
+
], ft = ["#F76707", "#4263EB", "#CC5DE8"], vt = [
|
|
437
437
|
"#FFFFFF",
|
|
438
438
|
"#F4F4F4",
|
|
439
439
|
"#E8EAED",
|
|
@@ -459,7 +459,7 @@ const st = "undo redo | preview print | importword revhistory | fontfamily fonts
|
|
|
459
459
|
"#8E24AA",
|
|
460
460
|
"#C2185B",
|
|
461
461
|
"#6D4C41"
|
|
462
|
-
],
|
|
462
|
+
], bt = [
|
|
463
463
|
{
|
|
464
464
|
key: "chcat_currency",
|
|
465
465
|
chars: [
|
|
@@ -799,7 +799,7 @@ const st = "undo redo | preview print | importword revhistory | fontfamily fonts
|
|
|
799
799
|
"ة"
|
|
800
800
|
]
|
|
801
801
|
}
|
|
802
|
-
],
|
|
802
|
+
], yt = [
|
|
803
803
|
{
|
|
804
804
|
key: "emcat_smileys",
|
|
805
805
|
chars: [
|
|
@@ -1524,7 +1524,7 @@ const st = "undo redo | preview print | importword revhistory | fontfamily fonts
|
|
|
1524
1524
|
"🇲🇦"
|
|
1525
1525
|
]
|
|
1526
1526
|
}
|
|
1527
|
-
],
|
|
1527
|
+
], pe = [
|
|
1528
1528
|
"©",
|
|
1529
1529
|
"®",
|
|
1530
1530
|
"™",
|
|
@@ -1573,244 +1573,244 @@ const st = "undo redo | preview print | importword revhistory | fontfamily fonts
|
|
|
1573
1573
|
"ـ",
|
|
1574
1574
|
"٠",
|
|
1575
1575
|
"١"
|
|
1576
|
-
],
|
|
1577
|
-
'<path d="M10 6h10M10 12h10M10 18h10"/>' +
|
|
1576
|
+
], x = (h, t) => `<svg viewBox="${t || "0 0 24 24"}">${h}</svg>`, v = (h) => x(`<path class="f" d="${h}"/>`, "0 -960 960 960"), q = (h, t = 7.5) => x(
|
|
1577
|
+
'<path d="M10 6h10M10 12h10M10 18h10"/>' + h.map(
|
|
1578
1578
|
(e, i) => `<text x="2.5" y="${8.4 + i * 6}" font-size="${t}" stroke="none" fill="#222f3e" font-family="Arial">${e}</text>`
|
|
1579
1579
|
).join("")
|
|
1580
|
-
),
|
|
1581
|
-
bold:
|
|
1580
|
+
), c = {
|
|
1581
|
+
bold: v(
|
|
1582
1582
|
"M272-200v-560h221q65 0 120 40t55 111q0 51-23 78.5T602-491q25 11 55.5 41t30.5 90q0 89-65 124.5T501-200H272Zm121-112h104q48 0 58.5-24.5T566-372q0-11-10.5-35.5T494-432H393v120Zm0-228h93q33 0 48-17t15-38q0-24-17-39t-44-15h-95v109Z"
|
|
1583
1583
|
),
|
|
1584
|
-
italic:
|
|
1585
|
-
underline:
|
|
1584
|
+
italic: v("M200-200v-100h160l120-360H320v-100h400v100H580L460-300h140v100H200Z"),
|
|
1585
|
+
underline: v(
|
|
1586
1586
|
"M200-120v-80h560v80H200Zm123-223q-56-63-56-167v-330h103v336q0 56 28 91t82 35q54 0 82-35t28-91v-336h103v330q0 104-56 167t-157 63q-101 0-157-63Z"
|
|
1587
1587
|
),
|
|
1588
|
-
strikethrough:
|
|
1588
|
+
strikethrough: v(
|
|
1589
1589
|
"M486-160q-76 0-135-45t-85-123l88-38q14 48 48.5 79t85.5 31q42 0 76-20t34-64q0-18-7-33t-19-27h112q5 14 7.5 28.5T694-340q0 86-61.5 133T486-160ZM80-480v-80h800v80H80Zm402-326q66 0 115.5 32.5T674-674l-88 39q-9-29-33.5-52T484-710q-41 0-68 18.5T386-640h-96q2-69 54.5-117.5T482-806Z"
|
|
1590
1590
|
),
|
|
1591
|
-
undo:
|
|
1592
|
-
redo:
|
|
1593
|
-
ltr:
|
|
1591
|
+
undo: v("M280-200v-80h284q63 0 109.5-40T720-420q0-60-46.5-100T564-560H312l104 104-56 56-200-200 200-200 56 56-104 104h252q97 0 166.5 63T800-420q0 94-69.5 157T564-200H280Z"),
|
|
1592
|
+
redo: v("M396-200q-97 0-166.5-63T160-420q0-94 69.5-157T396-640h252L544-744l56-56 200 200-200 200-56-56 104-104H396q-63 0-109.5 40T240-420q0 60 46.5 100T396-280h284v80H396Z"),
|
|
1593
|
+
ltr: v(
|
|
1594
1594
|
"M360-360v-200q-66 0-113-47t-47-113q0-66 47-113t113-47h320v80h-80v440h-80v-440h-80v440h-80Zm0-280v-160q-33 0-56.5 23.5T280-720q0 33 23.5 56.5T360-640Zm0-80ZM680-80l-56-56 64-64H120v-80h568l-64-64 56-56 160 160L680-80Z"
|
|
1595
1595
|
),
|
|
1596
|
-
rtl:
|
|
1596
|
+
rtl: v(
|
|
1597
1597
|
"M360-360v-200q-66 0-113-47t-47-113q0-66 47-113t113-47h320v80h-80v440h-80v-440h-80v440h-80Zm-88 160 64 64-56 56-160-160 160-160 56 56-64 64h568v80H272Zm88-440v-160q-33 0-56.5 23.5T280-720q0 33 23.5 56.5T360-640Zm0-80Z"
|
|
1598
1598
|
),
|
|
1599
|
-
alignleft:
|
|
1599
|
+
alignleft: v(
|
|
1600
1600
|
"M120-120v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Z"
|
|
1601
1601
|
),
|
|
1602
|
-
aligncenter:
|
|
1602
|
+
aligncenter: v(
|
|
1603
1603
|
"M120-120v-80h720v80H120Zm160-160v-80h400v80H280ZM120-440v-80h720v80H120Zm160-160v-80h400v80H280ZM120-760v-80h720v80H120Z"
|
|
1604
1604
|
),
|
|
1605
|
-
alignright:
|
|
1605
|
+
alignright: v(
|
|
1606
1606
|
"M120-760v-80h720v80H120Zm240 160v-80h480v80H360ZM120-440v-80h720v80H120Zm240 160v-80h480v80H360ZM120-120v-80h720v80H120Z"
|
|
1607
1607
|
),
|
|
1608
|
-
alignjustify:
|
|
1608
|
+
alignjustify: v(
|
|
1609
1609
|
"M120-120v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Z"
|
|
1610
1610
|
),
|
|
1611
|
-
fullscreen:
|
|
1611
|
+
fullscreen: v(
|
|
1612
1612
|
"M120-120v-200h80v120h120v80H120Zm520 0v-80h120v-120h80v200H640ZM120-640v-200h200v80H200v120h-80Zm640 0v-120H640v-80h200v200h-80Z"
|
|
1613
1613
|
),
|
|
1614
|
-
clearformatic:
|
|
1614
|
+
clearformatic: v(
|
|
1615
1615
|
"m528-546-93-93-121-121h486v120H568l-40 94ZM792-56 460-388l-80 188H249l119-280L56-792l56-56 736 736-56 56Z"
|
|
1616
1616
|
),
|
|
1617
|
-
numlist:
|
|
1617
|
+
numlist: v(
|
|
1618
1618
|
"M120-80v-60h100v-30h-60v-60h60v-30H120v-60h120q17 0 28.5 11.5T280-280v40q0 17-11.5 28.5T240-200q17 0 28.5 11.5T280-160v40q0 17-11.5 28.5T240-80H120Zm0-280v-110q0-17 11.5-28.5T160-510h60v-30H120v-60h120q17 0 28.5 11.5T280-560v70q0 17-11.5 28.5T240-450h-60v30h100v60H120Zm60-280v-180h-60v-60h120v240h-60Zm180 440v-80h480v80H360Zm0-240v-80h480v80H360Zm0-240v-80h480v80H360Z"
|
|
1619
1619
|
),
|
|
1620
|
-
bullist:
|
|
1620
|
+
bullist: v(
|
|
1621
1621
|
"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"
|
|
1622
1622
|
),
|
|
1623
|
-
chev:
|
|
1624
|
-
backcolor:
|
|
1623
|
+
chev: x('<path d="M2 3.5 6 7.5 10 3.5"/>', "0 0 12 11"),
|
|
1624
|
+
backcolor: v(
|
|
1625
1625
|
"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"
|
|
1626
1626
|
),
|
|
1627
|
-
outdent:
|
|
1627
|
+
outdent: v(
|
|
1628
1628
|
"M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm160 440L120-480l160-160v320Z"
|
|
1629
1629
|
),
|
|
1630
|
-
indent:
|
|
1630
|
+
indent: v(
|
|
1631
1631
|
"M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm0 440v-320l160 160-160 160Z"
|
|
1632
1632
|
),
|
|
1633
|
-
more:
|
|
1633
|
+
more: x(
|
|
1634
1634
|
'<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"/>'
|
|
1635
1635
|
),
|
|
1636
|
-
image:
|
|
1636
|
+
image: v(
|
|
1637
1637
|
"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-120H200Zm0-80h560v-560H200v560Zm40-80h480L570-480 450-320l-90-120-120 160Zm-40 80v-560 560Z"
|
|
1638
1638
|
),
|
|
1639
|
-
uploadic:
|
|
1639
|
+
uploadic: v(
|
|
1640
1640
|
"M440-200v-326L336-422l-56-58 200-200 200 200-56 58-104-104v326h-80ZM240-80q-33 0-56.5-23.5T160-160v-120h80v120h480v-120h80v120q0 33-23.5 56.5T720-80H240Z"
|
|
1641
1641
|
),
|
|
1642
|
-
tableic:
|
|
1642
|
+
tableic: v(
|
|
1643
1643
|
"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"
|
|
1644
1644
|
),
|
|
1645
|
-
hric:
|
|
1646
|
-
charic:
|
|
1645
|
+
hric: x('<path d="M4 12h16"/>'),
|
|
1646
|
+
charic: v(
|
|
1647
1647
|
"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"
|
|
1648
1648
|
),
|
|
1649
|
-
dateic:
|
|
1649
|
+
dateic: x(
|
|
1650
1650
|
'<rect x="4" y="6" width="16" height="14" rx="1.5"/><path d="M4 10h16M8 4v4M16 4v4"/>'
|
|
1651
1651
|
),
|
|
1652
|
-
pbic:
|
|
1652
|
+
pbic: v(
|
|
1653
1653
|
"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"
|
|
1654
1654
|
),
|
|
1655
|
-
nbspic:
|
|
1656
|
-
srcic:
|
|
1655
|
+
nbspic: x('<path d="M6 12v4h12v-4"/>'),
|
|
1656
|
+
srcic: v(
|
|
1657
1657
|
"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"
|
|
1658
1658
|
),
|
|
1659
|
-
prevw:
|
|
1659
|
+
prevw: v(
|
|
1660
1660
|
"M607.5-372.5Q660-425 660-500t-52.5-127.5Q555-680 480-680t-127.5 52.5Q300-575 300-500t52.5 127.5Q405-320 480-320t127.5-52.5Zm-204-51Q372-455 372-500t31.5-76.5Q435-608 480-608t76.5 31.5Q588-545 588-500t-31.5 76.5Q525-392 480-392t-76.5-31.5ZM214-281.5Q94-363 40-500q54-137 174-218.5T480-800q146 0 266 81.5T920-500q-54 137-174 218.5T480-200q-146 0-266-81.5ZM480-500Zm207.5 160.5Q782-399 832-500q-50-101-144.5-160.5T480-720q-113 0-207.5 59.5T128-500q50 101 144.5 160.5T480-280q113 0 207.5-59.5Z"
|
|
1661
1661
|
),
|
|
1662
|
-
printic:
|
|
1662
|
+
printic: v(
|
|
1663
1663
|
"M640-640v-120H320v120h-80v-200h480v200h-80Zm-480 80h640-640Zm560 100q17 0 28.5-11.5T760-500q0-17-11.5-28.5T720-540q-17 0-28.5 11.5T680-500q0 17 11.5 28.5T720-460Zm-80 260v-160H320v160h320Zm80 80H240v-160H80v-240q0-51 35-85.5t85-34.5h560q51 0 85.5 34.5T880-520v240H720v160Zm80-240v-160q0-17-11.5-28.5T760-560H200q-17 0-28.5 11.5T160-520v160h80v-80h480v80h80Z"
|
|
1664
1664
|
),
|
|
1665
|
-
cutic:
|
|
1665
|
+
cutic: v(
|
|
1666
1666
|
"M760-120 480-400l-94 94q8 15 11 32t3 34q0 66-47 113T240-80q-66 0-113-47T80-240q0-66 47-113t113-47q17 0 34 3t32 11l94-94-94-94q-15 8-32 11t-34 3q-66 0-113-47T80-720q0-66 47-113t113-47q66 0 113 47t47 113q0 17-3 34t-11 32l494 494v40H760ZM600-520l-80-80 240-240h120v40L600-520ZM296.5-663.5Q320-687 320-720t-23.5-56.5Q273-800 240-800t-56.5 23.5Q160-753 160-720t23.5 56.5Q207-640 240-640t56.5-23.5ZM494-466q6-6 6-14t-6-14q-6-6-14-6t-14 6q-6 6-6 14t6 14q6 6 14 6t14-6ZM296.5-183.5Q320-207 320-240t-23.5-56.5Q273-320 240-320t-56.5 23.5Q160-273 160-240t23.5 56.5Q207-160 240-160t56.5-23.5Z"
|
|
1667
1667
|
),
|
|
1668
|
-
copyic:
|
|
1668
|
+
copyic: v(
|
|
1669
1669
|
"M360-240q-33 0-56.5-23.5T280-320v-480q0-33 23.5-56.5T360-880h360q33 0 56.5 23.5T800-800v480q0 33-23.5 56.5T720-240H360Zm0-80h360v-480H360v480ZM200-80q-33 0-56.5-23.5T120-160v-560h80v560h440v80H200Zm160-240v-480 480Z"
|
|
1670
1670
|
),
|
|
1671
|
-
pasteic:
|
|
1671
|
+
pasteic: v(
|
|
1672
1672
|
"M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h167q11-35 43-57.5t70-22.5q40 0 71.5 22.5T594-840h166q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560h-80v120H280v-120h-80v560Zm308.5-571.5Q520-783 520-800t-11.5-28.5Q497-840 480-840t-28.5 11.5Q440-817 440-800t11.5 28.5Q463-760 480-760t28.5-11.5Z"
|
|
1673
1673
|
),
|
|
1674
|
-
selall:
|
|
1674
|
+
selall: v(
|
|
1675
1675
|
"M280-280v-400h400v400H280Zm80-80h240v-240H360v240ZM200-200v80q-33 0-56.5-23.5T120-200h80Zm-80-80v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm80-160h-80q0-33 23.5-56.5T200-840v80Zm80 640v-80h80v80h-80Zm0-640v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-640v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-640v-80h80v80h-80Zm160 640v-80h80q0 33-23.5 56.5T760-120Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80q33 0 56.5 23.5T840-760h-80Z"
|
|
1676
1676
|
),
|
|
1677
|
-
superscriptic:
|
|
1677
|
+
superscriptic: v(
|
|
1678
1678
|
"M760-600v-80q0-17 11.5-28.5T800-720h80v-40H760v-40h120q17 0 28.5 11.5T920-760v40q0 17-11.5 28.5T880-680h-80v40h120v40H760ZM235-160l185-291-172-269h106l124 200h4l123-200h107L539-451l186 291H618L482-377h-4L342-160H235Z"
|
|
1679
1679
|
),
|
|
1680
|
-
subscriptic:
|
|
1680
|
+
subscriptic: v(
|
|
1681
1681
|
"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"
|
|
1682
1682
|
),
|
|
1683
|
-
newic:
|
|
1684
|
-
helpic:
|
|
1683
|
+
newic: x('<path d="M6 3h8l5 5v13H6z"/><path d="M14 3v5h5"/>'),
|
|
1684
|
+
helpic: x(
|
|
1685
1685
|
'<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"/>'
|
|
1686
1686
|
),
|
|
1687
|
-
wcic:
|
|
1688
|
-
rowbefore:
|
|
1687
|
+
wcic: x('<path d="M4 6h16M4 10h16M4 14h9"/><path d="M15 17.5l2 2 3.6-4"/>'),
|
|
1688
|
+
rowbefore: v(
|
|
1689
1689
|
"M200-160h560v-240H200v240Zm640 80H120v-720h160v80h-80v240h560v-240h-80v-80h160v720ZM480-480Zm0 80v-80 80Zm0 0Zm-40-240v-80h-80v-80h80v-80h80v80h80v80h-80v80h-80Z"
|
|
1690
1690
|
),
|
|
1691
|
-
rowafter:
|
|
1691
|
+
rowafter: v(
|
|
1692
1692
|
"M200-560h560v-240H200v240Zm-80 400v-720h720v720H680v-80h80v-240H200v240h80v80H120Zm360-320Zm0-80v80-80Zm0 0ZM440-80v-80h-80v-80h80v-80h80v80h80v80h-80v80h-80Z"
|
|
1693
1693
|
),
|
|
1694
|
-
rowdelete:
|
|
1694
|
+
rowdelete: v(
|
|
1695
1695
|
"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-560H200ZM200-400v-160h560v160H200ZM330-580l250 250 50-50-250-250ZM330-380l250-250 50 50-250 250Z"
|
|
1696
1696
|
),
|
|
1697
|
-
colbefore:
|
|
1697
|
+
colbefore: v(
|
|
1698
1698
|
"M800-200v-560H560v560h240Zm-640 80v-160h80v80h240v-560H240v80h-80v-160h720v720H160Zm320-360Zm80 0h-80 80Zm0 0ZM160-360v-80H80v-80h80v-80h80v80h80v80h-80v80h-80Z"
|
|
1699
1699
|
),
|
|
1700
|
-
colafter:
|
|
1700
|
+
colafter: v(
|
|
1701
1701
|
"M160-760v560h240v-560H160ZM80-120v-720h720v160h-80v-80H480v560h240v-80h80v160H80Zm400-360Zm-80 0h80-80Zm0 0Zm320 120v-80h-80v-80h80v-80h80v80h80v80h-80v80h-80Z"
|
|
1702
1702
|
),
|
|
1703
|
-
coldelete:
|
|
1703
|
+
coldelete: v(
|
|
1704
1704
|
"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"
|
|
1705
1705
|
),
|
|
1706
|
-
tabledelete:
|
|
1706
|
+
tabledelete: x(
|
|
1707
1707
|
'<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"/>'
|
|
1708
1708
|
),
|
|
1709
|
-
quote:
|
|
1709
|
+
quote: v(
|
|
1710
1710
|
"m228-240 92-160q-66 0-113-47t-47-113q0-66 47-113t113-47q66 0 113 47t47 113q0 23-5.5 42.5T458-480L320-240h-92Zm360 0 92-160q-66 0-113-47t-47-113q0-66 47-113t113-47q66 0 113 47t47 113q0 23-5.5 42.5T818-480L680-240h-92ZM362.5-517.5Q380-535 380-560t-17.5-42.5Q345-620 320-620t-42.5 17.5Q260-585 260-560t17.5 42.5Q295-500 320-500t42.5-17.5Zm360 0Q740-535 740-560t-17.5-42.5Q705-620 680-620t-42.5 17.5Q620-585 620-560t17.5 42.5Q655-500 680-500t42.5-17.5ZM680-560Zm-360 0Z"
|
|
1711
1711
|
),
|
|
1712
|
-
link:
|
|
1712
|
+
link: v(
|
|
1713
1713
|
"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"
|
|
1714
1714
|
),
|
|
1715
|
-
unlink:
|
|
1715
|
+
unlink: x(
|
|
1716
1716
|
'<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"/>'
|
|
1717
1717
|
),
|
|
1718
|
-
lineheight:
|
|
1718
|
+
lineheight: v(
|
|
1719
1719
|
"M240-160 80-320l56-56 64 62v-332l-64 62-56-56 160-160 160 160-56 56-64-62v332l64-62 56 56-160 160Zm240-40v-80h400v80H480Zm0-240v-80h400v80H480Zm0-240v-80h400v80H480Z"
|
|
1720
1720
|
),
|
|
1721
|
-
wordspacing:
|
|
1721
|
+
wordspacing: v(
|
|
1722
1722
|
"M320-80 160-240l160-160 57 56-64 64h334l-63-64 56-56 160 160L640-80l-57-56 64-64H313l63 64-56 56ZM200-480v-400h80v400h-80Zm240 0v-400h80v400h-80Zm240 0v-400h80v400h-80Z"
|
|
1723
1723
|
),
|
|
1724
|
-
caseic:
|
|
1724
|
+
caseic: v(
|
|
1725
1725
|
"m131-252 165-440h79l165 440h-76l-39-112H247l-40 112h-76Zm139-176h131l-64-182h-4l-63 182Zm395 186q-51 0-81-27.5T554-342q0-44 34.5-72.5T677-443q23 0 45 4t38 11v-12q0-29-20.5-47T685-505q-23 0-42 9.5T610-468l-47-35q24-29 54.5-43t68.5-14q69 0 103 32.5t34 97.5v178h-63v-37h-4q-14 23-38 35t-53 12Zm12-54q35 0 59.5-24t24.5-56q-14-8-33.5-12.5T689-393q-32 0-50 14t-18 37q0 20 16 33t40 13Z"
|
|
1726
1726
|
),
|
|
1727
|
-
uppercaseic:
|
|
1727
|
+
uppercaseic: v(
|
|
1728
1728
|
"M660-240v-248l-64 64-56-56 160-160 160 160-56 56-64-64v248h-80Zm-540 0 165-440h79l165 440h-76l-39-113H236l-40 113h-76Zm139-177h131l-65-182h-4l-62 182Z"
|
|
1729
1729
|
),
|
|
1730
|
-
lowercaseic:
|
|
1730
|
+
lowercaseic: v(
|
|
1731
1731
|
"M300-240q-51 0-81-27.5T189-340q0-44 34.5-72.5T312-441q23 0 45 4t38 11v-12q0-29-20.5-47T320-503q-23 0-42 9.5T245-466l-47-35q24-29 54.5-43t68.5-14q69 0 103 32.5t34 97.5v178h-63v-37h-4q-14 23-38 35t-53 12Zm12-54q35 0 59.5-24t24.5-56q-14-8-33.5-12.5T324-391q-32 0-50 14t-18 37q0 20 16 33t40 13Zm388 54L540-400l56-56 64 64v-248h80v248l64-64 56 56-160 160Z"
|
|
1732
1732
|
),
|
|
1733
|
-
capitalizeic:
|
|
1733
|
+
capitalizeic: v(
|
|
1734
1734
|
"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"
|
|
1735
1735
|
),
|
|
1736
|
-
plus:
|
|
1737
|
-
minus:
|
|
1738
|
-
fontsizeup:
|
|
1736
|
+
plus: x('<path d="M12 5.5v13M5.5 12h13"/>'),
|
|
1737
|
+
minus: x('<path d="M5.5 12h13"/>'),
|
|
1738
|
+
fontsizeup: v(
|
|
1739
1739
|
"m40-200 210-560h100l210 560h-96l-51-143H187l-51 143H40Zm176-224h168l-82-232h-4l-82 232Zm504 104v-120H600v-80h120v-120h80v120h120v80H800v120h-80Z"
|
|
1740
1740
|
),
|
|
1741
|
-
fontsizedown:
|
|
1741
|
+
fontsizedown: v(
|
|
1742
1742
|
"m40-200 210-560h100l210 560h-96l-51-143H187l-51 143H40Zm176-224h168l-82-232h-4l-82 232Zm384-16v-80h320v80H600Z"
|
|
1743
1743
|
),
|
|
1744
|
-
historyic:
|
|
1744
|
+
historyic: v(
|
|
1745
1745
|
"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"
|
|
1746
1746
|
),
|
|
1747
|
-
wordic:
|
|
1747
|
+
wordic: x(
|
|
1748
1748
|
'<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>'
|
|
1749
1749
|
),
|
|
1750
|
-
draftic:
|
|
1750
|
+
draftic: v(
|
|
1751
1751
|
"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"
|
|
1752
1752
|
),
|
|
1753
|
-
trash:
|
|
1753
|
+
trash: x(
|
|
1754
1754
|
'<path d="M5 7h14M10 7V5h4v2M7.5 7l1 13h7l1-13"/>'
|
|
1755
1755
|
),
|
|
1756
|
-
templateic:
|
|
1756
|
+
templateic: x(
|
|
1757
1757
|
'<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"/>'
|
|
1758
1758
|
),
|
|
1759
|
-
tplleft:
|
|
1759
|
+
tplleft: x(
|
|
1760
1760
|
'<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"/>'
|
|
1761
1761
|
),
|
|
1762
|
-
tplright:
|
|
1762
|
+
tplright: x(
|
|
1763
1763
|
'<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"/>'
|
|
1764
1764
|
),
|
|
1765
|
-
tpltop:
|
|
1765
|
+
tpltop: x(
|
|
1766
1766
|
'<rect x="5" y="3" width="14" height="9" rx=".8"/><path d="M3 15h18M3 18h18M3 21h12"/>'
|
|
1767
1767
|
),
|
|
1768
|
-
tplcenter:
|
|
1768
|
+
tplcenter: x(
|
|
1769
1769
|
'<path d="M3 4h18M3 7h18M3 10h12"/><rect x="5" y="12.5" width="14" height="9" rx=".8"/>'
|
|
1770
1770
|
),
|
|
1771
|
-
rotateleft:
|
|
1771
|
+
rotateleft: x(
|
|
1772
1772
|
'<polyline points="1 4 1 10 7 10"/><path d="M3.51 15a9 9 0 1 0 2.13-9.36L1 10"/>'
|
|
1773
1773
|
),
|
|
1774
|
-
rotateright:
|
|
1774
|
+
rotateright: x(
|
|
1775
1775
|
'<polyline points="23 4 23 10 17 10"/><path d="M20.49 15a9 9 0 1 1-2.12-9.36L23 10"/>'
|
|
1776
1776
|
),
|
|
1777
|
-
fliphorizontal:
|
|
1777
|
+
fliphorizontal: x(
|
|
1778
1778
|
'<path d="M12 3v18"/><path d="M7 8l-4 4 4 4"/><path d="M17 8l4 4-4 4"/>'
|
|
1779
1779
|
),
|
|
1780
|
-
flipvertical:
|
|
1780
|
+
flipvertical: x(
|
|
1781
1781
|
'<path d="M3 12h18"/><path d="M8 7l4-4 4 4"/><path d="M8 17l4 4 4-4"/>'
|
|
1782
1782
|
),
|
|
1783
|
-
check:
|
|
1784
|
-
palette:
|
|
1783
|
+
check: x('<path d="M5 12.5 9.5 17 19 7"/>'),
|
|
1784
|
+
palette: x(
|
|
1785
1785
|
'<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"/>'
|
|
1786
1786
|
),
|
|
1787
|
-
ul_circle:
|
|
1787
|
+
ul_circle: v(
|
|
1788
1788
|
"M280-600v-80h560v80H280Zm0 160v-80h560v80H280Zm0 160v-80h560v80H280ZM160-600q-17 0-28.5-11.5T120-640q0-17 11.5-28.5T160-680q17 0 28.5 11.5T200-640q0 17-11.5 28.5T160-600Zm0 160q-17 0-28.5-11.5T120-480q0-17 11.5-28.5T160-520q17 0 28.5 11.5T200-480q0 17-11.5 28.5T160-440Zm0 160q-17 0-28.5-11.5T120-320q0-17 11.5-28.5T160-360q17 0 28.5 11.5T200-320q0 17-11.5 28.5T160-280Z"
|
|
1789
1789
|
),
|
|
1790
|
-
ul_square:
|
|
1790
|
+
ul_square: v(
|
|
1791
1791
|
"M80-160v-160h160v160H80Zm240 0v-160h560v160H320ZM80-400v-160h160v160H80Zm240 0v-160h560v160H320ZM80-640v-160h160v160H80Zm240 0v-160h560v160H320Z"
|
|
1792
1792
|
),
|
|
1793
1793
|
ol_alpha: q(["a", "b", "c"]),
|
|
1794
1794
|
ol_roman: q(["i", "ii", "iii"], 6.5),
|
|
1795
1795
|
ol_alphau: q(["A", "B", "C"]),
|
|
1796
1796
|
ol_romanu: q(["I", "II", "III"], 6.5),
|
|
1797
|
-
video:
|
|
1798
|
-
editic:
|
|
1799
|
-
letterspacing:
|
|
1797
|
+
video: x('<rect x="3" y="6" width="13" height="12" rx="1.5"/><path d="M16 10l5-3v10l-5-3z"/>'),
|
|
1798
|
+
editic: x('<path d="M4 20l1-4.5L15.5 5 19 8.5 8.5 19 4 20z"/><path d="M13.5 6.5l4 4"/>'),
|
|
1799
|
+
letterspacing: x(
|
|
1800
1800
|
'<text x="2.5" y="13" font-size="12" stroke="none" fill="#222f3e" font-family="Arial" font-weight="bold">A</text><text x="13" y="13" font-size="12" stroke="none" fill="#222f3e" font-family="Arial" font-weight="bold">B</text><path d="M7 18.5h10"/><path class="f" d="M7.5 18.5 4.5 16.6v3.8z"/><path class="f" d="M16.5 18.5l3-1.9v3.8z"/>'
|
|
1801
1801
|
),
|
|
1802
|
-
emojiic:
|
|
1802
|
+
emojiic: x(
|
|
1803
1803
|
'<circle cx="12" cy="12" r="8.5"/><path d="M8.6 14.3a4.6 4.6 0 0 0 6.8 0"/><path d="M9.2 9.6v.7M14.8 9.6v.7"/>'
|
|
1804
1804
|
),
|
|
1805
|
-
inlinecodeic:
|
|
1806
|
-
moverowup:
|
|
1807
|
-
moverowdown:
|
|
1808
|
-
movecolleft:
|
|
1809
|
-
movecolright:
|
|
1810
|
-
codesampleic:
|
|
1805
|
+
inlinecodeic: x('<path d="M8.5 8 4.5 12l4 4M15.5 8l4 4-4 4"/><path d="M13 6l-2 12"/>'),
|
|
1806
|
+
moverowup: x('<rect x="4" y="15.5" width="16" height="5" rx="1"/><path d="M12 12.5V4M8.5 7.5 12 4l3.5 3.5"/>'),
|
|
1807
|
+
moverowdown: x('<rect x="4" y="3.5" width="16" height="5" rx="1"/><path d="M12 11.5V20M8.5 16.5 12 20l3.5-3.5"/>'),
|
|
1808
|
+
movecolleft: x('<rect x="15.5" y="4" width="5" height="16" rx="1"/><path d="M12.5 12H4M7.5 8.5 4 12l3.5 3.5"/>'),
|
|
1809
|
+
movecolright: x('<rect x="3.5" y="4" width="5" height="16" rx="1"/><path d="M11.5 12H20M16.5 8.5 20 12l-3.5 3.5"/>'),
|
|
1810
|
+
codesampleic: x(
|
|
1811
1811
|
'<rect x="3.5" y="4" width="17" height="16" rx="2"/><path d="M3.5 8.5h17"/><path d="M9.5 12 7 14.25l2.5 2.25M14.5 12l2.5 2.25-2.5 2.25"/>'
|
|
1812
1812
|
)
|
|
1813
|
-
},
|
|
1813
|
+
}, ue = (h) => `<span class="txt">${h}</span>`, xt = /* @__PURE__ */ new Set([
|
|
1814
1814
|
"p",
|
|
1815
1815
|
"div",
|
|
1816
1816
|
"span",
|
|
@@ -1852,7 +1852,7 @@ const st = "undo redo | preview print | importword revhistory | fontfamily fonts
|
|
|
1852
1852
|
"figure",
|
|
1853
1853
|
"figcaption",
|
|
1854
1854
|
"mark"
|
|
1855
|
-
]),
|
|
1855
|
+
]), Ct = /* @__PURE__ */ new Set([
|
|
1856
1856
|
"text-align",
|
|
1857
1857
|
"direction",
|
|
1858
1858
|
"unicode-bidi",
|
|
@@ -1908,7 +1908,7 @@ const st = "undo redo | preview print | importword revhistory | fontfamily fonts
|
|
|
1908
1908
|
"box-sizing",
|
|
1909
1909
|
"list-style-type",
|
|
1910
1910
|
"white-space"
|
|
1911
|
-
]),
|
|
1911
|
+
]), G = {
|
|
1912
1912
|
"*": ["dir", "lang", "colspan", "rowspan"],
|
|
1913
1913
|
a: ["href", "target", "rel", "title"],
|
|
1914
1914
|
img: ["src", "alt", "width", "height", "title"],
|
|
@@ -1917,26 +1917,26 @@ const st = "undo redo | preview print | importword revhistory | fontfamily fonts
|
|
|
1917
1917
|
th: ["width", "valign"],
|
|
1918
1918
|
table: ["width", "cellpadding", "cellspacing"]
|
|
1919
1919
|
};
|
|
1920
|
-
function
|
|
1921
|
-
const t = {}, e =
|
|
1920
|
+
function P(h) {
|
|
1921
|
+
const t = {}, e = h.getAttribute && h.getAttribute("style");
|
|
1922
1922
|
return e && e.split(";").forEach((i) => {
|
|
1923
1923
|
const s = i.indexOf(":");
|
|
1924
1924
|
s < 1 || (t[i.slice(0, s).trim().toLowerCase()] = i.slice(s + 1).trim());
|
|
1925
1925
|
}), t;
|
|
1926
1926
|
}
|
|
1927
|
-
function
|
|
1928
|
-
return
|
|
1927
|
+
function wt(h) {
|
|
1928
|
+
return h.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, "");
|
|
1929
1929
|
}
|
|
1930
|
-
function
|
|
1931
|
-
return /^[0-9]+[\.\)،]/.test(
|
|
1930
|
+
function Tt(h) {
|
|
1931
|
+
return /^[0-9]+[\.\)،]/.test(h) ? { ordered: !0 } : /^[٠-٩۰-۹]+/.test(h) ? { ordered: !0, style: "arabic-indic" } : /^[ivxlc]{2,}[\.\)]/.test(h) ? { ordered: !0, style: "lower-roman" } : /^[IVXLC]{2,}[\.\)]/.test(h) ? { ordered: !0, style: "upper-roman" } : /^[a-z][\.\)]/.test(h) ? { ordered: !0, style: "lower-alpha" } : /^[A-Z][\.\)]/.test(h) ? { ordered: !0, style: "upper-alpha" } : /^[ء-ي][\.\)،-]/.test(h) ? { ordered: !0, style: "arabic-indic" } : { ordered: !1 };
|
|
1932
1932
|
}
|
|
1933
|
-
function
|
|
1933
|
+
function St(h) {
|
|
1934
1934
|
const t = (s) => {
|
|
1935
1935
|
const l = (s.getAttribute("style") || "") + " " + (s.className || "");
|
|
1936
1936
|
return /mso-list\s*:(?!\s*ignore)/i.test(l) || /MsoListParagraph/i.test(l);
|
|
1937
1937
|
}, e = [];
|
|
1938
1938
|
let i = null;
|
|
1939
|
-
Array.from(
|
|
1939
|
+
Array.from(h.body.querySelectorAll("p")).forEach((s) => {
|
|
1940
1940
|
if (!t(s)) {
|
|
1941
1941
|
i = null;
|
|
1942
1942
|
return;
|
|
@@ -1944,68 +1944,68 @@ function vt(p) {
|
|
|
1944
1944
|
const l = s.previousElementSibling;
|
|
1945
1945
|
i && l && i[i.length - 1] === l ? i.push(s) : (i = [s], e.push(i));
|
|
1946
1946
|
}), e.forEach((s) => {
|
|
1947
|
-
const l = [],
|
|
1948
|
-
s.forEach((
|
|
1949
|
-
var
|
|
1950
|
-
const
|
|
1947
|
+
const l = [], n = s[0];
|
|
1948
|
+
s.forEach((o) => {
|
|
1949
|
+
var y, C, S;
|
|
1950
|
+
const a = +(((y = (o.getAttribute("style") || "").match(/level(\d+)/i)) == null ? void 0 : y[1]) || 1), d = Array.from(o.querySelectorAll("span")).find(
|
|
1951
1951
|
(w) => /mso-list\s*:\s*ignore/i.test(w.getAttribute("style") || "")
|
|
1952
|
-
),
|
|
1953
|
-
for (
|
|
1954
|
-
if (!l.length || l[l.length - 1].level <
|
|
1955
|
-
const w =
|
|
1956
|
-
if (
|
|
1957
|
-
const
|
|
1958
|
-
(
|
|
1952
|
+
), p = d ? ((C = d.textContent) == null ? void 0 : C.trim()) || "" : (((S = o.textContent) == null ? void 0 : S.trim().match(/^\S{1,4}/)) || [""])[0], { ordered: u, style: g } = Tt(p);
|
|
1953
|
+
for (d && d.remove(); l.length && l[l.length - 1].level > a; ) l.pop();
|
|
1954
|
+
if (!l.length || l[l.length - 1].level < a) {
|
|
1955
|
+
const w = h.createElement(u ? "ol" : "ul");
|
|
1956
|
+
if (u && g && (w.style.listStyleType = g), l.length) {
|
|
1957
|
+
const k = l[l.length - 1].list;
|
|
1958
|
+
(k.lastElementChild || k).appendChild(w);
|
|
1959
1959
|
} else
|
|
1960
|
-
|
|
1961
|
-
l.push({ list: w, level:
|
|
1960
|
+
n.parentNode.insertBefore(w, n);
|
|
1961
|
+
l.push({ list: w, level: a });
|
|
1962
1962
|
}
|
|
1963
|
-
const
|
|
1964
|
-
for (b &&
|
|
1965
|
-
l[l.length - 1].list.appendChild(
|
|
1963
|
+
const m = h.createElement("li"), f = P(o), b = ["text-align", "direction", "unicode-bidi", "color", "font-size", "font-family", "background-color"].filter((w) => f[w]).map((w) => w + ":" + f[w]).join(";");
|
|
1964
|
+
for (b && m.setAttribute("style", b), o.getAttribute("dir") && m.setAttribute("dir", o.getAttribute("dir")); o.firstChild; ) m.appendChild(o.firstChild);
|
|
1965
|
+
l[l.length - 1].list.appendChild(m), o.remove();
|
|
1966
1966
|
});
|
|
1967
1967
|
});
|
|
1968
1968
|
}
|
|
1969
|
-
function
|
|
1970
|
-
|
|
1969
|
+
function Et(h) {
|
|
1970
|
+
h.querySelectorAll('b[id^="docs-internal-guid"]').forEach((t) => {
|
|
1971
1971
|
for (; t.firstChild; ) t.parentNode.insertBefore(t.firstChild, t);
|
|
1972
1972
|
t.remove();
|
|
1973
1973
|
});
|
|
1974
1974
|
}
|
|
1975
|
-
function
|
|
1976
|
-
|
|
1975
|
+
function Mt(h) {
|
|
1976
|
+
h.querySelectorAll("table").forEach((t) => {
|
|
1977
1977
|
const e = t;
|
|
1978
|
-
|
|
1979
|
-
}),
|
|
1978
|
+
P(e)["border-collapse"] || (e.style.borderCollapse = "collapse");
|
|
1979
|
+
}), h.querySelectorAll("[align]").forEach((t) => {
|
|
1980
1980
|
const e = t, i = e.getAttribute("align").toLowerCase();
|
|
1981
1981
|
e.tagName.toLowerCase() === "table" ? i === "center" ? (e.style.marginLeft = e.style.marginLeft || "auto", e.style.marginRight = e.style.marginRight || "auto") : i === "right" ? e.style.marginLeft = e.style.marginLeft || "auto" : i === "left" && (e.style.marginRight = e.style.marginRight || "auto") : ["left", "right", "center", "justify"].includes(i) && (e.style.textAlign = e.style.textAlign || i, Array.from(e.children).forEach((s) => {
|
|
1982
1982
|
if (s.tagName.toLowerCase() !== "table") return;
|
|
1983
1983
|
const l = s;
|
|
1984
1984
|
i === "center" ? (l.style.marginLeft = l.style.marginLeft || "auto", l.style.marginRight = l.style.marginRight || "auto") : i === "right" ? l.style.marginLeft = l.style.marginLeft || "auto" : i === "left" && (l.style.marginRight = l.style.marginRight || "auto");
|
|
1985
1985
|
})), e.removeAttribute("align");
|
|
1986
|
-
}),
|
|
1986
|
+
}), h.querySelectorAll("center table").forEach((t) => {
|
|
1987
1987
|
const e = t;
|
|
1988
1988
|
e.style.marginLeft = e.style.marginLeft || "auto", e.style.marginRight = e.style.marginRight || "auto";
|
|
1989
|
-
}),
|
|
1989
|
+
}), h.querySelectorAll("[bgcolor]").forEach((t) => {
|
|
1990
1990
|
const e = t;
|
|
1991
1991
|
e.style.backgroundColor = e.style.backgroundColor || e.getAttribute("bgcolor"), e.removeAttribute("bgcolor");
|
|
1992
1992
|
});
|
|
1993
1993
|
}
|
|
1994
|
-
function Z(
|
|
1995
|
-
Array.from(
|
|
1994
|
+
function Z(h, t) {
|
|
1995
|
+
Array.from(h.childNodes).forEach((e) => {
|
|
1996
1996
|
if (e.nodeType === Node.COMMENT_NODE) {
|
|
1997
1997
|
e.remove();
|
|
1998
1998
|
return;
|
|
1999
1999
|
}
|
|
2000
2000
|
if (e.nodeType !== Node.ELEMENT_NODE) return;
|
|
2001
2001
|
const i = e, s = i.tagName.toLowerCase();
|
|
2002
|
-
if (!
|
|
2002
|
+
if (!xt.has(s)) {
|
|
2003
2003
|
if (s === "font") {
|
|
2004
2004
|
const r = t.createElement("span");
|
|
2005
2005
|
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"));
|
|
2006
|
-
const
|
|
2007
|
-
if (
|
|
2008
|
-
const
|
|
2006
|
+
const a = i.getAttribute("size");
|
|
2007
|
+
if (a && !r.style.fontSize) {
|
|
2008
|
+
const d = {
|
|
2009
2009
|
1: "8pt",
|
|
2010
2010
|
2: "10pt",
|
|
2011
2011
|
3: "12pt",
|
|
@@ -2014,7 +2014,7 @@ function Z(p, t) {
|
|
|
2014
2014
|
6: "24pt",
|
|
2015
2015
|
7: "36pt"
|
|
2016
2016
|
};
|
|
2017
|
-
|
|
2017
|
+
d[a] && (r.style.fontSize = d[a]);
|
|
2018
2018
|
}
|
|
2019
2019
|
for (; i.firstChild; ) r.appendChild(i.firstChild);
|
|
2020
2020
|
i.replaceWith(r), Z(r, t);
|
|
@@ -2024,10 +2024,10 @@ function Z(p, t) {
|
|
|
2024
2024
|
i.remove();
|
|
2025
2025
|
return;
|
|
2026
2026
|
}
|
|
2027
|
-
const l = /* @__PURE__ */ new Set([...
|
|
2027
|
+
const l = /* @__PURE__ */ new Set([...G["*"] || [], ...G[s] || []]);
|
|
2028
2028
|
if (Array.from(i.attributes).forEach((r) => {
|
|
2029
|
-
const
|
|
2030
|
-
|
|
2029
|
+
const a = r.name.toLowerCase();
|
|
2030
|
+
a !== "style" && !l.has(a) && i.removeAttribute(r.name);
|
|
2031
2031
|
}), s === "a") {
|
|
2032
2032
|
const r = i.getAttribute("href") || "";
|
|
2033
2033
|
/^(https?:|mailto:|tel:|#)/i.test(r) || i.removeAttribute("href");
|
|
@@ -2035,130 +2035,233 @@ function Z(p, t) {
|
|
|
2035
2035
|
if (s === "img") {
|
|
2036
2036
|
const r = i.getAttribute("src") || "";
|
|
2037
2037
|
if (!/^(https?:|data:image\/|blob:)/i.test(r)) {
|
|
2038
|
-
const
|
|
2039
|
-
|
|
2038
|
+
const a = t.createElement("span");
|
|
2039
|
+
a.textContent = "[local image — paste it separately]", a.setAttribute("style", "color:#a33;font-style:italic;font-size:12px"), i.replaceWith(a);
|
|
2040
2040
|
return;
|
|
2041
2041
|
}
|
|
2042
2042
|
}
|
|
2043
|
-
const
|
|
2044
|
-
for (const [r,
|
|
2045
|
-
|
|
2046
|
-
if (
|
|
2043
|
+
const n = P(i), o = [];
|
|
2044
|
+
for (const [r, a] of Object.entries(n))
|
|
2045
|
+
Ct.has(r) && (/expression|javascript|url\s*\(\s*['"]?\s*file:/i.test(a) || r === "font-weight" && /^(400|normal)$/i.test(a) || r === "font-style" && /^normal$/i.test(a) || r === "text-decoration" && /^none$/i.test(a) || o.push(r + ":" + a));
|
|
2046
|
+
if (o.length ? i.setAttribute("style", o.join(";")) : i.removeAttribute("style"), i.removeAttribute("class"), Z(i, t), s === "span" && !i.attributes.length) {
|
|
2047
2047
|
for (; i.firstChild; ) i.parentNode.insertBefore(i.firstChild, i);
|
|
2048
2048
|
i.remove();
|
|
2049
2049
|
}
|
|
2050
2050
|
});
|
|
2051
2051
|
}
|
|
2052
|
-
function
|
|
2052
|
+
function Lt(h) {
|
|
2053
2053
|
const t = [], e = /<style[^>]*>([\s\S]*?)<\/style>/gi;
|
|
2054
2054
|
let i;
|
|
2055
|
-
for (; i = e.exec(
|
|
2055
|
+
for (; i = e.exec(h); ) {
|
|
2056
2056
|
let s = i[1].replace(/<!--|-->/g, "").replace(/\/\*[\s\S]*?\*\//g, "");
|
|
2057
2057
|
s = s.replace(/@media[^{]*\{(?:[^{}]*\{[^{}]*\})*[^{}]*\}/gi, ""), s = s.replace(/@[\w-]+[^{]*\{[^{}]*\}/g, "");
|
|
2058
2058
|
let l;
|
|
2059
|
-
const
|
|
2060
|
-
for (; l =
|
|
2061
|
-
const
|
|
2062
|
-
const
|
|
2063
|
-
return
|
|
2059
|
+
const n = /([^{}]+)\{([^}]*)\}/g;
|
|
2060
|
+
for (; l = n.exec(s); ) {
|
|
2061
|
+
const o = l[2].split(";").map((r) => {
|
|
2062
|
+
const a = r.indexOf(":");
|
|
2063
|
+
return a < 1 ? null : [r.slice(0, a).trim().toLowerCase(), r.slice(a + 1).trim()];
|
|
2064
2064
|
}).filter((r) => !!r && !!r[1]);
|
|
2065
|
-
|
|
2065
|
+
o.length && l[1].split(",").map((r) => r.trim()).filter((r) => r && !r.startsWith("@")).forEach((r) => t.push({ sel: r, decls: o }));
|
|
2066
2066
|
}
|
|
2067
2067
|
}
|
|
2068
2068
|
return t;
|
|
2069
2069
|
}
|
|
2070
|
-
function
|
|
2070
|
+
function Ht(h, t) {
|
|
2071
2071
|
if (!t.length) return;
|
|
2072
2072
|
const e = /* @__PURE__ */ new Map();
|
|
2073
2073
|
t.forEach(({ sel: i, decls: s }) => {
|
|
2074
2074
|
let l;
|
|
2075
2075
|
try {
|
|
2076
|
-
l =
|
|
2076
|
+
l = h.querySelectorAll(i);
|
|
2077
2077
|
} catch {
|
|
2078
2078
|
return;
|
|
2079
2079
|
}
|
|
2080
|
-
l.forEach((
|
|
2081
|
-
let
|
|
2082
|
-
|
|
2083
|
-
|
|
2080
|
+
l.forEach((n) => {
|
|
2081
|
+
let o = e.get(n);
|
|
2082
|
+
o || (o = {}, e.set(n, o)), s.forEach(([r, a]) => {
|
|
2083
|
+
o[r] = a;
|
|
2084
2084
|
});
|
|
2085
2085
|
});
|
|
2086
2086
|
}), e.forEach((i, s) => {
|
|
2087
|
-
const l =
|
|
2087
|
+
const l = P(s), n = s.hasAttribute("dir"), o = s.hasAttribute("align"), r = Object.entries(i).filter(([p]) => !(p in l || (p === "direction" || p === "unicode-bidi") && n || p === "text-align" && (o || n) || (p === "background" || p === "background-color") && s.hasAttribute("bgcolor")));
|
|
2088
2088
|
if (!r.length) return;
|
|
2089
|
-
const
|
|
2090
|
-
s.setAttribute("style",
|
|
2089
|
+
const a = r.map(([p, u]) => p + ":" + u).join(";"), d = s.getAttribute("style");
|
|
2090
|
+
s.setAttribute("style", d ? a + ";" + d : a);
|
|
2091
2091
|
});
|
|
2092
2092
|
}
|
|
2093
|
-
function
|
|
2094
|
-
return
|
|
2093
|
+
function lt(h) {
|
|
2094
|
+
return h.replace(/[ﭐ-﷿ﹰ-ﻼ]+/g, (t) => t.normalize("NFKC"));
|
|
2095
2095
|
}
|
|
2096
|
-
function
|
|
2097
|
-
const t =
|
|
2096
|
+
function kt(h) {
|
|
2097
|
+
const t = h.createTreeWalker(h.body, NodeFilter.SHOW_TEXT, null);
|
|
2098
2098
|
let e;
|
|
2099
2099
|
for (; e = t.nextNode(); )
|
|
2100
|
-
/[ﭐ-﷿ﹰ-ﻼ]/.test(e.nodeValue || "") && (e.nodeValue =
|
|
2100
|
+
/[ﭐ-﷿ﹰ-ﻼ]/.test(e.nodeValue || "") && (e.nodeValue = lt(e.nodeValue || ""));
|
|
2101
2101
|
}
|
|
2102
|
-
function
|
|
2103
|
-
const e =
|
|
2104
|
-
|
|
2102
|
+
function At(h, t = "ltr") {
|
|
2103
|
+
const e = Lt(h), i = new DOMParser().parseFromString(wt(h), "text/html");
|
|
2104
|
+
Ht(i, e), /class="?Mso|mso-|urn:schemas-microsoft-com/i.test(i.body.innerHTML) && St(i), Et(i), Mt(i), Z(i.body, i), kt(i);
|
|
2105
2105
|
const s = (l) => {
|
|
2106
|
-
var
|
|
2107
|
-
return l && l.tagName === "P" && !((
|
|
2106
|
+
var n;
|
|
2107
|
+
return l && l.tagName === "P" && !((n = l.textContent) != null && n.trim()) && !l.querySelector("img,table");
|
|
2108
2108
|
};
|
|
2109
2109
|
for (; s(i.body.firstElementChild); ) i.body.firstElementChild.remove();
|
|
2110
2110
|
for (; s(i.body.lastElementChild); ) i.body.lastElementChild.remove();
|
|
2111
2111
|
return i.body.innerHTML.trim();
|
|
2112
2112
|
}
|
|
2113
|
-
function
|
|
2114
|
-
const t =
|
|
2113
|
+
function It(h) {
|
|
2114
|
+
const t = lt(h).replace(/\r/g, ""), e = (i) => i.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
2115
2115
|
return /\n/.test(t) ? t.split(/\n{2,}/).map((i) => `<p dir="auto">${e(i).replace(/\n/g, "<br>") || "<br>"}</p>`).join("") : e(t);
|
|
2116
2116
|
}
|
|
2117
|
-
|
|
2118
|
-
|
|
2117
|
+
const qt = 10 * 1024 * 1024, ot = /^(https?:|data:image\/|blob:)/i;
|
|
2118
|
+
function Y(h, t) {
|
|
2119
|
+
const e = [], i = "{\\" + t;
|
|
2120
|
+
let s = 0;
|
|
2121
|
+
for (; (s = h.indexOf(i, s)) !== -1; ) {
|
|
2122
|
+
const l = h[s + i.length];
|
|
2123
|
+
if (l && /[a-z0-9]/i.test(l)) {
|
|
2124
|
+
s += i.length;
|
|
2125
|
+
continue;
|
|
2126
|
+
}
|
|
2127
|
+
let n = 0, o = s;
|
|
2128
|
+
for (; o < h.length; o++) {
|
|
2129
|
+
const r = h[o];
|
|
2130
|
+
if (r === "\\") {
|
|
2131
|
+
o++;
|
|
2132
|
+
continue;
|
|
2133
|
+
}
|
|
2134
|
+
if (r === "{") n++;
|
|
2135
|
+
else if (r === "}" && (n--, !n))
|
|
2136
|
+
break;
|
|
2137
|
+
}
|
|
2138
|
+
e.push({ start: s, end: o + 1, body: h.slice(s + i.length, o) }), s = o + 1;
|
|
2139
|
+
}
|
|
2140
|
+
return e;
|
|
2141
|
+
}
|
|
2142
|
+
function Bt(h) {
|
|
2143
|
+
const t = new Uint8Array(h.length / 2);
|
|
2144
|
+
for (let e = 0; e < t.length; e++) t[e] = parseInt(h.substr(e * 2, 2), 16);
|
|
2145
|
+
return t;
|
|
2146
|
+
}
|
|
2147
|
+
function F(h) {
|
|
2148
|
+
let t = "";
|
|
2149
|
+
for (let e = 0; e < h.length; e++) t += String.fromCharCode(h[e]);
|
|
2150
|
+
return btoa(t);
|
|
2151
|
+
}
|
|
2152
|
+
function K(h, t) {
|
|
2153
|
+
t: for (let e = 0; e + t.length <= h.length; e++) {
|
|
2154
|
+
for (let i = 0; i < t.length; i++) if (h[e + i] !== t[i]) continue t;
|
|
2155
|
+
return e;
|
|
2156
|
+
}
|
|
2157
|
+
return -1;
|
|
2158
|
+
}
|
|
2159
|
+
const Nt = [137, 80, 78, 71], Rt = [255, 216, 255];
|
|
2160
|
+
function Zt(h) {
|
|
2161
|
+
let t = null;
|
|
2162
|
+
if (/\\pngblip/.test(h) ? t = "image/png" : /\\jpegblip/.test(h) ? t = "image/jpeg" : (/\\wmetafile\d*/.test(h) || /\\emfblip/.test(h)) && (t = "metafile"), !t) return null;
|
|
2163
|
+
let e = h.replace(/\{[^{}]*\}/g, "").replace(/\\[a-z]+-?\d*\s?/gi, "").replace(/[^0-9a-fA-F]/g, "");
|
|
2164
|
+
if (e.length % 2 && (e = e.slice(0, -1)), !e) return null;
|
|
2165
|
+
const i = Bt(e);
|
|
2166
|
+
if (t === "metafile") {
|
|
2167
|
+
const s = K(i, Nt);
|
|
2168
|
+
if (s >= 0) return "data:image/png;base64," + F(i.slice(s));
|
|
2169
|
+
const l = K(i, Rt);
|
|
2170
|
+
return l >= 0 ? "data:image/jpeg;base64," + F(i.slice(l)) : null;
|
|
2171
|
+
}
|
|
2172
|
+
return "data:" + t + ";base64," + F(i);
|
|
2173
|
+
}
|
|
2174
|
+
function Dt(h) {
|
|
2175
|
+
if (!h || h.indexOf("\\pict") === -1) return [];
|
|
2176
|
+
let t = h;
|
|
2177
|
+
Y(h, "nonshppict").reverse().forEach((i) => {
|
|
2178
|
+
t = t.slice(0, i.start) + t.slice(i.end);
|
|
2179
|
+
});
|
|
2180
|
+
let e = qt;
|
|
2181
|
+
return Y(t, "pict").map((i) => {
|
|
2182
|
+
if (e <= 0) return null;
|
|
2183
|
+
const s = Zt(i.body);
|
|
2184
|
+
return s && (e -= s.length * 0.75), s;
|
|
2185
|
+
});
|
|
2186
|
+
}
|
|
2187
|
+
function nt(h, t) {
|
|
2188
|
+
if (!h || !t.length) return { html: h, injected: [] };
|
|
2189
|
+
const e = [];
|
|
2190
|
+
let i = 0;
|
|
2191
|
+
return { html: h.replace(/<img\b[^>]*>/gi, (l) => {
|
|
2192
|
+
const n = (l.match(/\ssrc\s*=\s*["']?([^"'\s>]+)/i) || [])[1] || "";
|
|
2193
|
+
if (ot.test(n)) return l;
|
|
2194
|
+
const o = t[i++];
|
|
2195
|
+
return o ? (e.push(o), /\ssrc\s*=\s*["']/i.test(l) ? l.replace(/(\ssrc\s*=\s*)(["'])[^"']*\2/i, '$1"' + o + '"') : l.replace(/(\ssrc\s*=\s*)[^\s>]+/i, '$1"' + o + '"')) : l;
|
|
2196
|
+
}), injected: e };
|
|
2197
|
+
}
|
|
2198
|
+
function Pt(h, t) {
|
|
2199
|
+
return !h || !t ? { html: h, injected: [] } : nt(h, Dt(t));
|
|
2200
|
+
}
|
|
2201
|
+
function Ot(h) {
|
|
2202
|
+
const t = h.match(/<img\b[^>]*>/gi);
|
|
2203
|
+
return t ? t.filter((e) => {
|
|
2204
|
+
const i = (e.match(/\ssrc\s*=\s*["']?([^"'\s>]+)/i) || [])[1] || "";
|
|
2205
|
+
return !ot.test(i);
|
|
2206
|
+
}).length : 0;
|
|
2207
|
+
}
|
|
2208
|
+
function Ft(h, t) {
|
|
2209
|
+
const e = h.match(/^data:([^;,]+);base64,(.*)$/);
|
|
2210
|
+
if (!e) return null;
|
|
2211
|
+
const i = (e[1].split("/")[1] || "png").replace(/[^a-z0-9]/gi, "") || "png";
|
|
2212
|
+
try {
|
|
2213
|
+
const s = atob(e[2]), l = new Uint8Array(s.length);
|
|
2214
|
+
for (let n = 0; n < s.length; n++) l[n] = s.charCodeAt(n);
|
|
2215
|
+
return new File([l], t + "." + (i === "jpeg" ? "jpg" : i), { type: e[1] });
|
|
2216
|
+
} catch {
|
|
2217
|
+
return null;
|
|
2218
|
+
}
|
|
2219
|
+
}
|
|
2220
|
+
function $t(h) {
|
|
2221
|
+
const t = new DataView(h), e = /* @__PURE__ */ new Map();
|
|
2119
2222
|
let i = -1;
|
|
2120
|
-
for (let
|
|
2121
|
-
if (t.getUint32(
|
|
2122
|
-
i =
|
|
2223
|
+
for (let o = h.byteLength - 22; o >= Math.max(0, h.byteLength - 22 - 65535); o--)
|
|
2224
|
+
if (t.getUint32(o, !0) === 101010256) {
|
|
2225
|
+
i = o;
|
|
2123
2226
|
break;
|
|
2124
2227
|
}
|
|
2125
2228
|
if (i < 0) throw new Error("EOCD not found");
|
|
2126
2229
|
const s = t.getUint16(i + 10, !0);
|
|
2127
2230
|
let l = t.getUint32(i + 16, !0);
|
|
2128
|
-
const
|
|
2129
|
-
for (let
|
|
2130
|
-
const r = t.getUint16(l + 10, !0),
|
|
2131
|
-
e.set(
|
|
2231
|
+
const n = new TextDecoder();
|
|
2232
|
+
for (let o = 0; o < s && t.getUint32(l, !0) === 33639248; o++) {
|
|
2233
|
+
const r = t.getUint16(l + 10, !0), a = t.getUint32(l + 20, !0), d = t.getUint16(l + 28, !0), p = t.getUint16(l + 30, !0), u = t.getUint16(l + 32, !0), g = t.getUint32(l + 42, !0), m = n.decode(new Uint8Array(h, l + 46, d));
|
|
2234
|
+
e.set(m, { name: m, method: r, compSize: a, localOffset: g }), l += 46 + d + p + u;
|
|
2132
2235
|
}
|
|
2133
2236
|
return e;
|
|
2134
2237
|
}
|
|
2135
|
-
async function
|
|
2136
|
-
const e = new DataView(
|
|
2238
|
+
async function J(h, t) {
|
|
2239
|
+
const e = new DataView(h, t.localOffset);
|
|
2137
2240
|
if (e.getUint32(0, !0) !== 67324752) throw new Error("Bad local header");
|
|
2138
|
-
const i = e.getUint16(26, !0), s = e.getUint16(28, !0), l = t.localOffset + 30 + i + s,
|
|
2139
|
-
if (t.method === 0) return
|
|
2241
|
+
const i = e.getUint16(26, !0), s = e.getUint16(28, !0), l = t.localOffset + 30 + i + s, n = new Uint8Array(h.slice(l, l + t.compSize));
|
|
2242
|
+
if (t.method === 0) return n;
|
|
2140
2243
|
if (t.method !== 8) throw new Error("Unsupported compression method " + t.method);
|
|
2141
|
-
const
|
|
2142
|
-
return new Uint8Array(await new Response(
|
|
2244
|
+
const o = new Blob([n]).stream().pipeThrough(new DecompressionStream("deflate-raw"));
|
|
2245
|
+
return new Uint8Array(await new Response(o).arrayBuffer());
|
|
2143
2246
|
}
|
|
2144
|
-
const
|
|
2145
|
-
let e =
|
|
2247
|
+
const tt = (h) => h.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """), D = (h, t) => Array.from(h.children).filter((e) => e.localName === t), E = (h, ...t) => {
|
|
2248
|
+
let e = h;
|
|
2146
2249
|
for (const i of t) {
|
|
2147
2250
|
if (!e) return null;
|
|
2148
2251
|
e = Array.from(e.children).find((s) => s.localName === i) || null;
|
|
2149
2252
|
}
|
|
2150
2253
|
return e;
|
|
2151
|
-
}, T = (
|
|
2152
|
-
if (!
|
|
2153
|
-
for (const e of Array.from(
|
|
2254
|
+
}, T = (h, t = "val") => {
|
|
2255
|
+
if (!h) return "";
|
|
2256
|
+
for (const e of Array.from(h.attributes))
|
|
2154
2257
|
if (e.localName === t) return e.value;
|
|
2155
2258
|
return "";
|
|
2156
|
-
}, B = (
|
|
2157
|
-
const e =
|
|
2259
|
+
}, B = (h, t) => {
|
|
2260
|
+
const e = h ? E(h, t) : null;
|
|
2158
2261
|
if (!e) return !1;
|
|
2159
2262
|
const i = T(e);
|
|
2160
2263
|
return i !== "false" && i !== "0";
|
|
2161
|
-
},
|
|
2264
|
+
}, et = {
|
|
2162
2265
|
yellow: "#FFFF00",
|
|
2163
2266
|
green: "#00FF00",
|
|
2164
2267
|
cyan: "#00FFFF",
|
|
@@ -2175,7 +2278,7 @@ const Y = (p) => p.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, "&
|
|
|
2175
2278
|
lightGray: "#D3D3D3",
|
|
2176
2279
|
black: "#000000",
|
|
2177
2280
|
white: "#FFFFFF"
|
|
2178
|
-
},
|
|
2281
|
+
}, _t = {
|
|
2179
2282
|
png: "image/png",
|
|
2180
2283
|
jpg: "image/jpeg",
|
|
2181
2284
|
jpeg: "image/jpeg",
|
|
@@ -2183,13 +2286,13 @@ const Y = (p) => p.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, "&
|
|
|
2183
2286
|
bmp: "image/bmp",
|
|
2184
2287
|
webp: "image/webp"
|
|
2185
2288
|
};
|
|
2186
|
-
function
|
|
2289
|
+
function zt(h) {
|
|
2187
2290
|
let t = "";
|
|
2188
|
-
for (let e = 0; e <
|
|
2189
|
-
t += String.fromCharCode(...
|
|
2291
|
+
for (let e = 0; e < h.length; e += 32768)
|
|
2292
|
+
t += String.fromCharCode(...h.subarray(e, e + 32768));
|
|
2190
2293
|
return btoa(t);
|
|
2191
2294
|
}
|
|
2192
|
-
class
|
|
2295
|
+
class Ut {
|
|
2193
2296
|
constructor(t, e, i) {
|
|
2194
2297
|
this.rels = t, this.images = e, this.numFmt = i;
|
|
2195
2298
|
}
|
|
@@ -2200,12 +2303,12 @@ class kt {
|
|
|
2200
2303
|
};
|
|
2201
2304
|
for (const l of Array.from(t.children))
|
|
2202
2305
|
if (l.localName === "p") {
|
|
2203
|
-
const
|
|
2204
|
-
if (
|
|
2205
|
-
const
|
|
2206
|
-
for (; i.length >
|
|
2207
|
-
for (i.length ===
|
|
2208
|
-
e += `<${
|
|
2306
|
+
const n = this.paraList(l);
|
|
2307
|
+
if (n) {
|
|
2308
|
+
const o = n.ilvl + 1;
|
|
2309
|
+
for (; i.length > o; ) e += `</${i.pop()}>`;
|
|
2310
|
+
for (i.length === o && i[o - 1] !== n.type && (e += `</${i.pop()}>`); i.length < o; )
|
|
2311
|
+
e += `<${n.type}>`, i.push(n.type);
|
|
2209
2312
|
e += `<li>${this.runsOf(l) || "<br>"}</li>`;
|
|
2210
2313
|
continue;
|
|
2211
2314
|
}
|
|
@@ -2214,22 +2317,22 @@ class kt {
|
|
|
2214
2317
|
return s(0), e || "<p><br></p>";
|
|
2215
2318
|
}
|
|
2216
2319
|
paraList(t) {
|
|
2217
|
-
const e =
|
|
2320
|
+
const e = E(t, "pPr", "numPr");
|
|
2218
2321
|
if (!e) return null;
|
|
2219
|
-
const i = T(
|
|
2322
|
+
const i = T(E(e, "numId"));
|
|
2220
2323
|
if (!i || i === "0") return null;
|
|
2221
|
-
const s = parseInt(T(
|
|
2324
|
+
const s = parseInt(T(E(e, "ilvl")) || "0", 10) || 0;
|
|
2222
2325
|
return { type: this.numFmt.get(i) || "ul", ilvl: Math.min(s, 8) };
|
|
2223
2326
|
}
|
|
2224
2327
|
convertPara(t) {
|
|
2225
|
-
const e =
|
|
2328
|
+
const e = E(t, "pPr"), i = T(E(t, "pPr", "pStyle"));
|
|
2226
2329
|
let s = "p";
|
|
2227
2330
|
const l = /^Heading([1-6])$/i.exec(i);
|
|
2228
2331
|
l ? s = "h" + l[1] : /^Title$/i.test(i) && (s = "h1");
|
|
2229
|
-
const
|
|
2230
|
-
|
|
2231
|
-
const r = this.runsOf(t),
|
|
2232
|
-
return `<${s}${
|
|
2332
|
+
const n = [], o = T(E(t, "pPr", "jc"));
|
|
2333
|
+
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 && E(e, "bidi") && n.push("direction:rtl");
|
|
2334
|
+
const r = this.runsOf(t), a = n.length ? ` style="${n.join(";")}"` : "";
|
|
2335
|
+
return `<${s}${a}>${r || "<br>"}</${s}>`;
|
|
2233
2336
|
}
|
|
2234
2337
|
runsOf(t) {
|
|
2235
2338
|
let e = "";
|
|
@@ -2239,167 +2342,241 @@ class kt {
|
|
|
2239
2342
|
let s = this.rels.get(T(i, "id")) || "";
|
|
2240
2343
|
const l = T(i, "anchor");
|
|
2241
2344
|
!s && l && (s = "#" + l);
|
|
2242
|
-
const
|
|
2243
|
-
e += s ? `<a href="${
|
|
2345
|
+
const n = this.runsOf(i);
|
|
2346
|
+
e += s ? `<a href="${tt(s)}">${n}</a>` : n;
|
|
2244
2347
|
} else (i.localName === "smartTag" || i.localName === "ins") && (e += this.runsOf(i));
|
|
2245
2348
|
return e;
|
|
2246
2349
|
}
|
|
2247
2350
|
convertRun(t) {
|
|
2248
|
-
const e =
|
|
2351
|
+
const e = E(t, "rPr");
|
|
2249
2352
|
let i = "";
|
|
2250
|
-
for (const
|
|
2251
|
-
|
|
2353
|
+
for (const p of Array.from(t.children))
|
|
2354
|
+
p.localName === "t" ? i += tt(p.textContent || "") : p.localName === "br" || p.localName === "cr" ? i += "<br>" : p.localName === "tab" ? i += " " : (p.localName === "drawing" || p.localName === "pict" || p.localName === "object") && (i += this.convertImage(p));
|
|
2252
2355
|
if (!i) return "";
|
|
2253
|
-
const s = [], l = T(e ?
|
|
2356
|
+
const s = [], l = T(e ? E(e, "color") : null);
|
|
2254
2357
|
l && l !== "auto" && s.push("color:#" + l);
|
|
2255
|
-
const
|
|
2256
|
-
|
|
2257
|
-
const
|
|
2258
|
-
|
|
2259
|
-
const r = e ?
|
|
2260
|
-
|
|
2261
|
-
const
|
|
2262
|
-
return
|
|
2358
|
+
const n = T(e ? E(e, "highlight") : null);
|
|
2359
|
+
n && et[n] && s.push("background-color:" + et[n]);
|
|
2360
|
+
const o = parseFloat(T(e ? E(e, "sz") : null));
|
|
2361
|
+
o && s.push("font-size:" + Math.round(o / 2 * (4 / 3)) + "px");
|
|
2362
|
+
const r = e ? E(e, "rFonts") : null, a = T(r, "ascii") || T(r, "cs");
|
|
2363
|
+
a && s.push(`font-family:'${a}'`), s.length && (i = `<span style="${s.join(";")}">${i}</span>`), B(e, "b") && (i = `<strong>${i}</strong>`), B(e, "i") && (i = `<em>${i}</em>`), B(e, "u") && T(E(e, "u")) !== "none" && (i = `<u>${i}</u>`), B(e, "strike") && (i = `<s>${i}</s>`);
|
|
2364
|
+
const d = T(e ? E(e, "vertAlign") : null);
|
|
2365
|
+
return d === "superscript" ? i = `<sup>${i}</sup>` : d === "subscript" && (i = `<sub>${i}</sub>`), i;
|
|
2263
2366
|
}
|
|
2264
2367
|
convertImage(t) {
|
|
2265
2368
|
let e = "", i = 0;
|
|
2266
|
-
const s = (
|
|
2267
|
-
if (
|
|
2268
|
-
const r = parseFloat(
|
|
2369
|
+
const s = (o) => {
|
|
2370
|
+
if (o.localName === "blip" && (e = e || T(o, "embed") || T(o, "link")), o.localName === "imagedata" && (e = e || T(o, "id")), o.localName === "extent") {
|
|
2371
|
+
const r = parseFloat(o.getAttribute("cx") || "0");
|
|
2269
2372
|
r && (i = Math.round(r / 9525));
|
|
2270
2373
|
}
|
|
2271
|
-
for (const r of Array.from(
|
|
2374
|
+
for (const r of Array.from(o.children)) s(r);
|
|
2272
2375
|
};
|
|
2273
2376
|
if (s(t), !e) return "";
|
|
2274
2377
|
const l = this.images.get(e);
|
|
2275
2378
|
if (!l) return "";
|
|
2276
|
-
const
|
|
2277
|
-
return `<img src="${l}" alt=""${
|
|
2379
|
+
const n = i ? ` width="${i}"` : "";
|
|
2380
|
+
return `<img src="${l}" alt=""${n}>`;
|
|
2278
2381
|
}
|
|
2279
2382
|
convertTable(t) {
|
|
2280
2383
|
let e = '<table style="border-collapse:collapse;width:100%"><tbody>';
|
|
2281
|
-
for (const i of
|
|
2384
|
+
for (const i of D(t, "tr")) {
|
|
2282
2385
|
e += "<tr>";
|
|
2283
|
-
for (const s of
|
|
2284
|
-
const l = parseInt(T(
|
|
2285
|
-
let
|
|
2386
|
+
for (const s of D(i, "tc")) {
|
|
2387
|
+
const l = parseInt(T(E(s, "tcPr", "gridSpan")) || "1", 10) || 1, n = l > 1 ? ` colspan="${l}"` : "";
|
|
2388
|
+
let o = "";
|
|
2286
2389
|
for (const r of Array.from(s.children))
|
|
2287
|
-
r.localName === "p" ?
|
|
2288
|
-
e += `<td style="border:1px solid #b9c2cc"${
|
|
2390
|
+
r.localName === "p" ? o += this.convertPara(r) : r.localName === "tbl" && (o += this.convertTable(r));
|
|
2391
|
+
e += `<td style="border:1px solid #b9c2cc"${n}>${o || "<br>"}</td>`;
|
|
2289
2392
|
}
|
|
2290
2393
|
e += "</tr>";
|
|
2291
2394
|
}
|
|
2292
2395
|
return e + "</tbody></table>";
|
|
2293
2396
|
}
|
|
2294
2397
|
}
|
|
2295
|
-
async function
|
|
2296
|
-
const t =
|
|
2297
|
-
const
|
|
2298
|
-
return
|
|
2299
|
-
}, l = await s("word/document.xml"),
|
|
2300
|
-
let
|
|
2301
|
-
if (
|
|
2302
|
-
for (const
|
|
2303
|
-
if (
|
|
2304
|
-
|
|
2398
|
+
async function Wt(h) {
|
|
2399
|
+
const t = h instanceof ArrayBuffer ? h : await h.arrayBuffer(), e = $t(t), i = new TextDecoder(), s = async (m) => {
|
|
2400
|
+
const f = e.get(m);
|
|
2401
|
+
return f ? new DOMParser().parseFromString(i.decode(await J(t, f)), "application/xml") : null;
|
|
2402
|
+
}, l = await s("word/document.xml"), n = l == null ? void 0 : l.getElementsByTagName("*");
|
|
2403
|
+
let o = null;
|
|
2404
|
+
if (n) {
|
|
2405
|
+
for (const m of Array.from(n))
|
|
2406
|
+
if (m.localName === "body") {
|
|
2407
|
+
o = m;
|
|
2305
2408
|
break;
|
|
2306
2409
|
}
|
|
2307
2410
|
}
|
|
2308
|
-
if (!
|
|
2309
|
-
const r = /* @__PURE__ */ new Map(),
|
|
2310
|
-
if (
|
|
2311
|
-
for (const
|
|
2312
|
-
if (
|
|
2313
|
-
const
|
|
2314
|
-
/hyperlink/i.test(
|
|
2411
|
+
if (!o) throw new Error("word/document.xml missing or invalid");
|
|
2412
|
+
const r = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), d = await s("word/_rels/document.xml.rels");
|
|
2413
|
+
if (d)
|
|
2414
|
+
for (const m of Array.from(d.getElementsByTagName("*"))) {
|
|
2415
|
+
if (m.localName !== "Relationship") continue;
|
|
2416
|
+
const f = m.getAttribute("Id") || "", b = m.getAttribute("Target") || "", y = m.getAttribute("Type") || "";
|
|
2417
|
+
/hyperlink/i.test(y) ? r.set(f, b) : /image/i.test(y) && a.set(f, b);
|
|
2315
2418
|
}
|
|
2316
|
-
const
|
|
2317
|
-
for (const [
|
|
2318
|
-
const b =
|
|
2319
|
-
if (!
|
|
2320
|
-
const C = (b.split(".").pop() || "").toLowerCase(),
|
|
2321
|
-
if (
|
|
2419
|
+
const p = /* @__PURE__ */ new Map();
|
|
2420
|
+
for (const [m, f] of a) {
|
|
2421
|
+
const b = f.startsWith("/") ? f.slice(1) : "word/" + f.replace(/^\.\//, ""), y = e.get(b);
|
|
2422
|
+
if (!y) continue;
|
|
2423
|
+
const C = (b.split(".").pop() || "").toLowerCase(), S = _t[C];
|
|
2424
|
+
if (S)
|
|
2322
2425
|
try {
|
|
2323
|
-
|
|
2426
|
+
p.set(m, `data:${S};base64,${zt(await J(t, y))}`);
|
|
2324
2427
|
} catch {
|
|
2325
2428
|
}
|
|
2326
2429
|
}
|
|
2327
|
-
const
|
|
2430
|
+
const u = /* @__PURE__ */ new Map(), g = await s("word/numbering.xml");
|
|
2328
2431
|
if (g) {
|
|
2329
|
-
const
|
|
2330
|
-
for (const b of
|
|
2432
|
+
const m = /* @__PURE__ */ new Map(), f = Array.from(g.getElementsByTagName("*"));
|
|
2433
|
+
for (const b of f) {
|
|
2331
2434
|
if (b.localName !== "abstractNum") continue;
|
|
2332
|
-
const
|
|
2333
|
-
|
|
2435
|
+
const y = T(b, "abstractNumId"), C = D(b, "lvl").find((w) => T(w, "ilvl") === "0") || D(b, "lvl")[0], S = C ? T(E(C, "numFmt")) : "";
|
|
2436
|
+
m.set(y, S === "bullet" ? "ul" : "ol");
|
|
2334
2437
|
}
|
|
2335
|
-
for (const b of
|
|
2438
|
+
for (const b of f) {
|
|
2336
2439
|
if (b.localName !== "num") continue;
|
|
2337
|
-
const
|
|
2338
|
-
|
|
2440
|
+
const y = T(b, "numId"), C = T(E(b, "abstractNumId"));
|
|
2441
|
+
u.set(y, m.get(C) || "ul");
|
|
2339
2442
|
}
|
|
2340
2443
|
}
|
|
2341
|
-
return new
|
|
2444
|
+
return new Ut(r, p, u).convertBody(o);
|
|
2342
2445
|
}
|
|
2343
|
-
const
|
|
2446
|
+
const Vt = ["nw", "ne", "sw", "se"], $ = ["img-left", "img-right", "img-top", "img-center"], _ = {
|
|
2344
2447
|
"img-left": "tplimgleft",
|
|
2345
2448
|
"img-right": "tplimgright",
|
|
2346
2449
|
"img-top": "tplimgtop",
|
|
2347
2450
|
"img-center": "tplimgcenter"
|
|
2348
|
-
},
|
|
2349
|
-
"img-left":
|
|
2350
|
-
"img-right":
|
|
2351
|
-
"img-top":
|
|
2352
|
-
"img-center":
|
|
2353
|
-
},
|
|
2354
|
-
let
|
|
2451
|
+
}, jt = {
|
|
2452
|
+
"img-left": c.tplleft,
|
|
2453
|
+
"img-right": c.tplright,
|
|
2454
|
+
"img-top": c.tpltop,
|
|
2455
|
+
"img-center": c.tplcenter
|
|
2456
|
+
}, Xt = ".tox,.pop,.tblctx,.imgctx,.selctx,.dlg";
|
|
2457
|
+
let M = null, A = null, z = 0, it = !1;
|
|
2355
2458
|
function N() {
|
|
2356
|
-
clearTimeout(
|
|
2459
|
+
clearTimeout(z), A = null, M && M.classList.remove("show");
|
|
2357
2460
|
}
|
|
2358
|
-
function
|
|
2359
|
-
const t =
|
|
2461
|
+
function Qt(h) {
|
|
2462
|
+
const t = h.dataset.tip;
|
|
2360
2463
|
if (!t) return;
|
|
2361
|
-
A =
|
|
2362
|
-
const e =
|
|
2363
|
-
|
|
2364
|
-
if (A !==
|
|
2365
|
-
|
|
2366
|
-
const i =
|
|
2367
|
-
let
|
|
2368
|
-
|
|
2369
|
-
let
|
|
2370
|
-
|
|
2464
|
+
A = h, clearTimeout(z);
|
|
2465
|
+
const e = M && M.classList.contains("show") ? 60 : 350;
|
|
2466
|
+
z = window.setTimeout(() => {
|
|
2467
|
+
if (A !== h || !document.contains(h)) return;
|
|
2468
|
+
M || (M = document.createElement("div"), M.className = "etip", document.body.appendChild(M)), M.textContent = t, M.classList.add("show");
|
|
2469
|
+
const i = h.getBoundingClientRect(), s = M.offsetWidth, l = M.offsetHeight;
|
|
2470
|
+
let n = i.left + i.width / 2 - s / 2;
|
|
2471
|
+
n = Math.max(6, Math.min(n, innerWidth - s - 6));
|
|
2472
|
+
let o = i.bottom + 7;
|
|
2473
|
+
o + l > innerHeight - 6 && (o = i.top - l - 7), M.style.left = n + "px", M.style.top = o + "px";
|
|
2371
2474
|
}, e);
|
|
2372
2475
|
}
|
|
2373
|
-
function
|
|
2374
|
-
|
|
2375
|
-
const t =
|
|
2376
|
-
if (!e || !e.closest(
|
|
2476
|
+
function Gt() {
|
|
2477
|
+
it || (it = !0, document.addEventListener("mouseover", (h) => {
|
|
2478
|
+
const t = h.target, e = t.closest ? t.closest("[title],[data-tip]") : null;
|
|
2479
|
+
if (!e || !e.closest(Xt) || e.closest(".earea")) {
|
|
2377
2480
|
e !== A && N();
|
|
2378
2481
|
return;
|
|
2379
2482
|
}
|
|
2380
2483
|
const i = e.getAttribute("title");
|
|
2381
|
-
i && (e.dataset.tip = i, e.removeAttribute("title"), e.getAttribute("aria-label") || e.setAttribute("aria-label", i)), e !== A &&
|
|
2382
|
-
}), document.addEventListener("mouseout", (
|
|
2383
|
-
A && !A.contains(
|
|
2484
|
+
i && (e.dataset.tip = i, e.removeAttribute("title"), e.getAttribute("aria-label") || e.setAttribute("aria-label", i)), e !== A && Qt(e);
|
|
2485
|
+
}), document.addEventListener("mouseout", (h) => {
|
|
2486
|
+
A && !A.contains(h.relatedTarget) && N();
|
|
2384
2487
|
}), document.addEventListener("mousedown", N, !0), addEventListener("scroll", N, !0));
|
|
2385
2488
|
}
|
|
2386
|
-
const
|
|
2387
|
-
function
|
|
2388
|
-
for (const t of
|
|
2389
|
-
if (
|
|
2390
|
-
if (
|
|
2489
|
+
const Yt = /[\u0590-\u05FF\u0600-\u06FF\u0750-\u077F\u0780-\u07BF\u08A0-\u08FF\uFB1D-\uFB4F\uFB50-\uFDFF\uFE70-\uFEFF]/, Kt = new RegExp("\\p{L}", "u"), Jt = "p,div,li,td,th,blockquote,h1,h2,h3,h4,h5,h6,pre,figcaption";
|
|
2490
|
+
function te(h) {
|
|
2491
|
+
for (const t of h) {
|
|
2492
|
+
if (Yt.test(t)) return "rtl";
|
|
2493
|
+
if (Kt.test(t)) return "ltr";
|
|
2391
2494
|
}
|
|
2392
2495
|
return null;
|
|
2393
2496
|
}
|
|
2394
|
-
|
|
2497
|
+
const R = ["top", "right", "bottom", "left"], ee = /^(none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset)$/i, ie = /^(thin|medium|thick|[+-]?(\d+\.?\d*|\.\d+)(px|pt|em|rem|ex|ch|cm|mm|in|pc|q)?)$/i, se = /^[+-]?0*(\.0*)?(px|pt|em|rem|ex|ch|cm|mm|in|pc|q)?$/i, le = /^border-(collapse|spacing|radius|image|block|inline|start|end)/i, oe = /^border(?:-(top|right|bottom|left))?(?:-(width|style|color))?$/, ne = /^(inherit|initial|unset|revert|revert-layer)$/i;
|
|
2498
|
+
function rt(h) {
|
|
2499
|
+
const t = [];
|
|
2500
|
+
let e = 0, i = "";
|
|
2501
|
+
for (const s of h)
|
|
2502
|
+
s === "(" ? e++ : s === ")" && e--, e === 0 && /\s/.test(s) ? (i && t.push(i), i = "") : i += s;
|
|
2503
|
+
return i && t.push(i), t;
|
|
2504
|
+
}
|
|
2505
|
+
function re(h) {
|
|
2506
|
+
const [t, e = t, i = t, s = e] = h;
|
|
2507
|
+
return [t, e, i, s];
|
|
2508
|
+
}
|
|
2509
|
+
function ae(h) {
|
|
2510
|
+
const t = { width: "medium", style: "none", color: "" };
|
|
2511
|
+
return rt(h).forEach((e) => {
|
|
2512
|
+
ee.test(e) ? t.style = e.toLowerCase() : ie.test(e) ? t.width = e : t.color = e;
|
|
2513
|
+
}), t;
|
|
2514
|
+
}
|
|
2515
|
+
function ce(h) {
|
|
2516
|
+
return !h || /^currentcolor$/i.test(h) ? "" : /^windowtext$/i.test(h) ? "#000000" : h;
|
|
2517
|
+
}
|
|
2518
|
+
function he(h) {
|
|
2519
|
+
if (h.width === null && h.style === null && h.color === null) return "";
|
|
2520
|
+
const t = h.style ?? "solid";
|
|
2521
|
+
return t === "none" || t === "hidden" || h.width && se.test(h.width) ? "none" : [h.width && h.width !== "medium" ? h.width : "", t, ce(h.color || "")].filter(Boolean).join(" ");
|
|
2522
|
+
}
|
|
2523
|
+
function de(h) {
|
|
2524
|
+
h.querySelectorAll("table,td,th").forEach((t) => {
|
|
2525
|
+
const e = t.getAttribute("style") || "";
|
|
2526
|
+
if (!/border/i.test(e)) return;
|
|
2527
|
+
const i = {
|
|
2528
|
+
top: { width: null, style: null, color: null },
|
|
2529
|
+
right: { width: null, style: null, color: null },
|
|
2530
|
+
bottom: { width: null, style: null, color: null },
|
|
2531
|
+
left: { width: null, style: null, color: null }
|
|
2532
|
+
}, s = [];
|
|
2533
|
+
let l = !1, n = !1;
|
|
2534
|
+
if (e.split(";").forEach((a) => {
|
|
2535
|
+
const d = a.indexOf(":");
|
|
2536
|
+
if (d < 1) {
|
|
2537
|
+
a.trim() && s.push(a.trim());
|
|
2538
|
+
return;
|
|
2539
|
+
}
|
|
2540
|
+
const p = a.slice(0, d).trim().toLowerCase(), u = a.slice(d + 1).trim(), g = oe.exec(p);
|
|
2541
|
+
if (!g || le.test(p)) {
|
|
2542
|
+
s.push(p + ":" + u);
|
|
2543
|
+
return;
|
|
2544
|
+
}
|
|
2545
|
+
if (ne.test(u)) {
|
|
2546
|
+
n = !0;
|
|
2547
|
+
return;
|
|
2548
|
+
}
|
|
2549
|
+
l = !0;
|
|
2550
|
+
const m = g[1], f = g[2];
|
|
2551
|
+
if (f)
|
|
2552
|
+
if (m)
|
|
2553
|
+
i[m][f] = u;
|
|
2554
|
+
else {
|
|
2555
|
+
const b = re(rt(u));
|
|
2556
|
+
R.forEach((y, C) => {
|
|
2557
|
+
i[y][f] = b[C];
|
|
2558
|
+
});
|
|
2559
|
+
}
|
|
2560
|
+
else {
|
|
2561
|
+
const b = ae(u);
|
|
2562
|
+
(m ? [m] : R.slice()).forEach((y) => {
|
|
2563
|
+
i[y] = { ...b };
|
|
2564
|
+
});
|
|
2565
|
+
}
|
|
2566
|
+
}), n || !l) return;
|
|
2567
|
+
const o = R.map((a) => he(i[a])), r = s.slice();
|
|
2568
|
+
o.every((a) => a && a === o[0]) ? r.push("border:" + o[0]) : R.forEach((a, d) => o[d] && r.push(`border-${a}:` + o[d])), t.setAttribute("style", r.join(";"));
|
|
2569
|
+
});
|
|
2570
|
+
}
|
|
2571
|
+
function at(h) {
|
|
2395
2572
|
let t = "";
|
|
2396
|
-
return
|
|
2573
|
+
return h.childNodes.forEach((e) => {
|
|
2397
2574
|
if (e.nodeType === Node.TEXT_NODE)
|
|
2398
2575
|
t += e.nodeValue || "";
|
|
2399
2576
|
else if (e.nodeType === Node.ELEMENT_NODE) {
|
|
2400
2577
|
const i = e, s = (i.getAttribute("dir") || "").toLowerCase();
|
|
2401
2578
|
if (s === "rtl" || s === "ltr") return;
|
|
2402
|
-
t +=
|
|
2579
|
+
t += at(i);
|
|
2403
2580
|
}
|
|
2404
2581
|
}), t;
|
|
2405
2582
|
}
|
|
@@ -2419,20 +2596,20 @@ const I = class I {
|
|
|
2419
2596
|
statusbar: t.statusbar ?? !0,
|
|
2420
2597
|
readonly: t.readonly ?? !1,
|
|
2421
2598
|
draftKey: t.draftKey ?? (typeof location < "u" ? location.pathname : "default"),
|
|
2422
|
-
fontFamilyFormats: t.fontFamilyFormats ??
|
|
2599
|
+
fontFamilyFormats: t.fontFamilyFormats ?? pt,
|
|
2423
2600
|
imageFileTypes: t.imageFileTypes ?? ["image/jpeg", "image/jpg", "image/png", "image/gif", "image/bmp", "image/webp"],
|
|
2424
2601
|
videoFileTypes: t.videoFileTypes ?? ["video/mp4", "video/webm", "video/ogg"]
|
|
2425
|
-
}, this.imageUploadHandler = t.imageUploadHandler, this.onImageUploadError = t.onImageUploadError, this.videoUploadHandler = t.videoUploadHandler, this.onVideoUploadError = t.onVideoUploadError, this.contentStyle = t.contentStyle, this.applyTheme(t), this.lang = this.options.language, this.draftStorageKey = "tmclone-draft:" + this.options.draftKey, this.initDOM(), this.bindEvents(), this.initUI(), this.recordRevision(), this.options.onReady(this);
|
|
2602
|
+
}, this.imageUploadHandler = t.imageUploadHandler, this.onImageUploadError = t.onImageUploadError, this.videoUploadHandler = t.videoUploadHandler, this.onVideoUploadError = t.onVideoUploadError, this.contentStyle = t.contentStyle, this.applyTheme(t), this.lang = this.options.language, this.draftStorageKey = "tmclone-draft:" + this.options.draftKey, this.initDOM(), this.bindEvents(), this.initUI(), this.recordRevision(), this.stampExistingImages(), this.options.onReady(this);
|
|
2426
2603
|
}
|
|
2427
2604
|
t(t) {
|
|
2428
|
-
const e =
|
|
2605
|
+
const e = O(this.lang)[t];
|
|
2429
2606
|
return typeof e == "string" ? e : e.join(",");
|
|
2430
2607
|
}
|
|
2431
2608
|
tArr(t) {
|
|
2432
|
-
return
|
|
2609
|
+
return O(this.lang)[t];
|
|
2433
2610
|
}
|
|
2434
2611
|
dir() {
|
|
2435
|
-
return
|
|
2612
|
+
return O(this.lang).dir;
|
|
2436
2613
|
}
|
|
2437
2614
|
/* ---------------------------------------------------------- DOM setup */
|
|
2438
2615
|
initDOM() {
|
|
@@ -2445,7 +2622,7 @@ const I = class I {
|
|
|
2445
2622
|
</span>
|
|
2446
2623
|
`, this.sbHelp = this.statusbar.querySelector(".mid"), this.sbWords = this.statusbar.querySelector(".words");
|
|
2447
2624
|
const e = this.statusbar.querySelector(".grip");
|
|
2448
|
-
this.bindGrip(e), this.shell.appendChild(this.menubar), this.shell.appendChild(this.toolbar), this.shell.appendChild(this.ed), this.shell.appendChild(this.statusbar), this.contentStyle && (this.contentStyleEl = document.createElement("style"), this.contentStyleEl.textContent = this.scopeContentStyle(this.contentStyle), this.shell.appendChild(this.contentStyleEl)), t.appendChild(this.shell),
|
|
2625
|
+
this.bindGrip(e), this.shell.appendChild(this.menubar), this.shell.appendChild(this.toolbar), this.shell.appendChild(this.ed), this.shell.appendChild(this.statusbar), this.contentStyle && (this.contentStyleEl = document.createElement("style"), this.contentStyleEl.textContent = this.scopeContentStyle(this.contentStyle), this.shell.appendChild(this.contentStyleEl)), t.appendChild(this.shell), Gt(), this.options.statusbar || (this.statusbar.style.display = "none"), this.imgInput = document.createElement("input"), this.imgInput.type = "file", this.imgInput.accept = this.options.imageFileTypes.join(","), this.imgInput.style.display = "none", t.appendChild(this.imgInput), this.vidInput = document.createElement("input"), this.vidInput.type = "file", this.vidInput.accept = this.options.videoFileTypes.join(","), this.vidInput.style.display = "none", t.appendChild(this.vidInput), this.docInput = document.createElement("input"), this.docInput.type = "file", this.docInput.accept = ".docx,application/vnd.openxmlformats-officedocument.wordprocessingml.document", this.docInput.style.display = "none", t.appendChild(this.docInput);
|
|
2449
2626
|
}
|
|
2450
2627
|
/** Theme options land as CSS variables on the document root rather than the editor
|
|
2451
2628
|
* shell, because dialogs, popups and floating context toolbars are appended to
|
|
@@ -2465,12 +2642,12 @@ const I = class I {
|
|
|
2465
2642
|
let e = 0, i = 0;
|
|
2466
2643
|
const s = (l) => {
|
|
2467
2644
|
e = l.clientY, i = this.ed.offsetHeight, l.preventDefault();
|
|
2468
|
-
const
|
|
2645
|
+
const n = (r) => {
|
|
2469
2646
|
this.ed.style.height = Math.max(120, i + r.clientY - e) + "px";
|
|
2470
|
-
},
|
|
2471
|
-
window.removeEventListener("mousemove",
|
|
2647
|
+
}, o = () => {
|
|
2648
|
+
window.removeEventListener("mousemove", n), window.removeEventListener("mouseup", o);
|
|
2472
2649
|
};
|
|
2473
|
-
window.addEventListener("mousemove",
|
|
2650
|
+
window.addEventListener("mousemove", n), window.addEventListener("mouseup", o);
|
|
2474
2651
|
};
|
|
2475
2652
|
t.addEventListener("mousedown", s), this.listeners.push(() => t.removeEventListener("mousedown", s));
|
|
2476
2653
|
}
|
|
@@ -2488,46 +2665,46 @@ const I = class I {
|
|
|
2488
2665
|
}), this.on(this.ed, "keydown", (t) => {
|
|
2489
2666
|
t.altKey && t.key === "0" && (t.preventDefault(), this.helpDlg()), (t.key === "Delete" || t.key === "Backspace") && this.phActive && (t.preventDefault(), this.removeImgPlaceholder()), (t.key === "Delete" || t.key === "Backspace") && this.vphActive && (t.preventDefault(), this.removeVphPlaceholder()), t.key === "`" && !t.ctrlKey && !t.metaKey && !t.altKey && this.tryCodeTyping(t), t.key === "Enter" && !t.shiftKey && !t.ctrlKey && !t.metaKey && !t.altKey && this.tryExitBlockquote(t);
|
|
2490
2667
|
}), this.on(this.ed, "paste", (t) => this.handlePaste(t)), this.on(this.ed, "drop", (t) => {
|
|
2491
|
-
var l,
|
|
2668
|
+
var l, n, o, r;
|
|
2492
2669
|
t.preventDefault();
|
|
2493
2670
|
const e = t.target, i = (l = e.closest) == null ? void 0 : l.call(e, ".img-ph:not(.vid-ph)");
|
|
2494
2671
|
if (i && this.ed.contains(i) && !this.options.readonly) {
|
|
2495
|
-
const
|
|
2496
|
-
|
|
2672
|
+
const a = Array.from(((n = t.dataTransfer) == null ? void 0 : n.files) || []).find((d) => d.type.startsWith("image/"));
|
|
2673
|
+
a && this.readImageFileInto(a, i);
|
|
2497
2674
|
return;
|
|
2498
2675
|
}
|
|
2499
|
-
const s = (
|
|
2676
|
+
const s = (o = e.closest) == null ? void 0 : o.call(e, ".vid-ph");
|
|
2500
2677
|
if (s && this.ed.contains(s) && !this.options.readonly) {
|
|
2501
|
-
const
|
|
2502
|
-
|
|
2678
|
+
const a = Array.from(((r = t.dataTransfer) == null ? void 0 : r.files) || []).find((d) => d.type.startsWith("video/"));
|
|
2679
|
+
a && this.readVideoFileInto(a, s);
|
|
2503
2680
|
}
|
|
2504
2681
|
}), this.on(this.ed, "dragover", (t) => t.preventDefault()), this.on(this.ed, "mousedown", (t) => {
|
|
2505
|
-
var
|
|
2506
|
-
const e = t.target, i = (
|
|
2682
|
+
var d, p, u, g, m, f, b;
|
|
2683
|
+
const e = t.target, i = (d = e.closest) == null ? void 0 : d.call(e, "table");
|
|
2507
2684
|
i && this.ed.contains(i) ? this.selectTableForResize(i) : this.clearTableHandles();
|
|
2508
|
-
const s = (
|
|
2685
|
+
const s = (p = e.closest) == null ? void 0 : p.call(e, ".img-ph:not(.vid-ph)");
|
|
2509
2686
|
s && this.ed.contains(s) && !this.options.readonly ? (t.preventDefault(), this.ed.focus(), this.selectImgPlaceholder(s)) : this.clearImgPlaceholderSel();
|
|
2510
|
-
const l = (
|
|
2687
|
+
const l = (u = e.closest) == null ? void 0 : u.call(e, ".vid-ph");
|
|
2511
2688
|
l && this.ed.contains(l) && !this.options.readonly ? (t.preventDefault(), this.ed.focus(), this.selectVphPlaceholder(l)) : this.clearVphPlaceholderSel();
|
|
2512
|
-
const
|
|
2513
|
-
|
|
2514
|
-
const
|
|
2515
|
-
|
|
2516
|
-
const r = (
|
|
2689
|
+
const n = (g = e.closest) == null ? void 0 : g.call(e, ".tpl");
|
|
2690
|
+
n && this.ed.contains(n) && !this.options.readonly ? this.selectTemplate(n) : this.clearTplSel();
|
|
2691
|
+
const o = (m = e.closest) == null ? void 0 : m.call(e, "pre.code-block");
|
|
2692
|
+
o && this.ed.contains(o) && !this.options.readonly ? (t.preventDefault(), this.selectCodeEl(o)) : this.clearCodeSel();
|
|
2693
|
+
const r = (f = e.closest) == null ? void 0 : f.call(e, "img");
|
|
2517
2694
|
r && this.ed.contains(r) && !this.options.readonly ? (t.preventDefault(), this.selectImage(r)) : this.clearImageHandles();
|
|
2518
|
-
const
|
|
2519
|
-
|
|
2695
|
+
const a = (b = e.closest) == null ? void 0 : b.call(e, "video, .video-embed");
|
|
2696
|
+
a && this.ed.contains(a) && !this.options.readonly ? (t.preventDefault(), this.selectVideo(a)) : this.clearVidHandles();
|
|
2520
2697
|
}), this.on(this.ed, "mouseover", (t) => {
|
|
2521
2698
|
var i, s;
|
|
2522
2699
|
if (this.options.readonly) return;
|
|
2523
2700
|
const e = (s = (i = t.target).closest) == null ? void 0 : s.call(i, "img");
|
|
2524
2701
|
e && this.ed.contains(e) && (this.cancelImgHide(), this.selectImage(e));
|
|
2525
2702
|
}), this.on(this.ed, "mouseout", (t) => {
|
|
2526
|
-
var s, l,
|
|
2703
|
+
var s, l, n, o;
|
|
2527
2704
|
const e = (l = (s = t.target).closest) == null ? void 0 : l.call(s, "img");
|
|
2528
2705
|
if (!e) return;
|
|
2529
2706
|
const i = t.relatedTarget;
|
|
2530
|
-
i && ((
|
|
2707
|
+
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();
|
|
2531
2708
|
}), this.on(this.ed, "scroll", () => {
|
|
2532
2709
|
this.positionTableHandles(), this.positionImageHandles(), this.positionImgPhCtx(), this.positionTplCtx(), this.positionVphCtx(), this.positionVidCtx(), this.positionCodeCtx();
|
|
2533
2710
|
}), this.onWin(
|
|
@@ -2555,11 +2732,7 @@ const I = class I {
|
|
|
2555
2732
|
}
|
|
2556
2733
|
const i = new FileReader();
|
|
2557
2734
|
i.onload = () => {
|
|
2558
|
-
this.restoreSel(),
|
|
2559
|
-
"insertHTML",
|
|
2560
|
-
!1,
|
|
2561
|
-
`<img src="${i.result}" title="${t.name.replace(/"/g, "")}" alt="">`
|
|
2562
|
-
), this.onChange();
|
|
2735
|
+
this.restoreSel(), this.insertImageHTML(i.result, t.name.replace(/"/g, "")), this.onChange();
|
|
2563
2736
|
}, i.readAsDataURL(t);
|
|
2564
2737
|
}), this.on(this.vidInput, "change", () => {
|
|
2565
2738
|
var s;
|
|
@@ -2613,33 +2786,44 @@ const I = class I {
|
|
|
2613
2786
|
* content with no strongly-directional character anywhere falls back to the
|
|
2614
2787
|
* editor's current direction. */
|
|
2615
2788
|
getContentForEmail() {
|
|
2616
|
-
const t = (o,
|
|
2617
|
-
const
|
|
2618
|
-
o.setAttribute("style",
|
|
2789
|
+
const t = (o, r) => {
|
|
2790
|
+
const a = (o.getAttribute("style") || "").trim();
|
|
2791
|
+
o.setAttribute("style", a ? a.replace(/;?$/, "; ") + r : r);
|
|
2619
2792
|
}, e = document.createElement("div");
|
|
2620
2793
|
e.innerHTML = this.ed.innerHTML;
|
|
2621
2794
|
let i = null;
|
|
2622
2795
|
e.querySelectorAll("[dir]").forEach((o) => {
|
|
2623
|
-
const
|
|
2624
|
-
if (
|
|
2625
|
-
const
|
|
2626
|
-
i || (i =
|
|
2627
|
-
}), e.querySelectorAll(
|
|
2628
|
-
const
|
|
2629
|
-
if (
|
|
2630
|
-
const
|
|
2631
|
-
if (!
|
|
2632
|
-
i || (i =
|
|
2633
|
-
const
|
|
2634
|
-
t(o,
|
|
2796
|
+
const r = (o.getAttribute("dir") || "").toLowerCase();
|
|
2797
|
+
if (r !== "rtl" && r !== "ltr") return;
|
|
2798
|
+
const a = r;
|
|
2799
|
+
i || (i = a), /text-align\s*:/i.test(o.getAttribute("style") || "") || t(o, `text-align:${a === "rtl" ? "right" : "left"}`);
|
|
2800
|
+
}), e.querySelectorAll(Jt).forEach((o) => {
|
|
2801
|
+
const r = (o.getAttribute("dir") || "").toLowerCase();
|
|
2802
|
+
if (r === "rtl" || r === "ltr") return;
|
|
2803
|
+
const a = te(at(o));
|
|
2804
|
+
if (!a) return;
|
|
2805
|
+
i || (i = a), o.setAttribute("dir", a);
|
|
2806
|
+
const d = /text-align\s*:/i.test(o.getAttribute("style") || "");
|
|
2807
|
+
t(o, d ? `direction:${a}` : `direction:${a};text-align:${a === "rtl" ? "right" : "left"}`);
|
|
2635
2808
|
});
|
|
2636
|
-
const s =
|
|
2809
|
+
const s = this.ed.querySelectorAll("img");
|
|
2810
|
+
e.querySelectorAll("img").forEach((o, r) => {
|
|
2811
|
+
if (o.closest(".tpl-media")) return;
|
|
2812
|
+
const a = s[r], d = Math.round((a == null ? void 0 : a.getBoundingClientRect().width) || 0);
|
|
2813
|
+
d > 0 && !o.getAttribute("width") && o.setAttribute("width", String(d));
|
|
2814
|
+
const p = o.getAttribute("style") || "";
|
|
2815
|
+
d > 0 && !/(^|;)\s*width\s*:/i.test(p) && t(o, `width:${d}px`), /max-width\s*:/i.test(o.getAttribute("style") || "") || t(o, "max-width:100%"), /(^|;)\s*height\s*:/i.test(o.getAttribute("style") || "") || t(o, "height:auto");
|
|
2816
|
+
}), de(e), e.querySelectorAll("table").forEach((o) => {
|
|
2817
|
+
const r = o.getAttribute("style") || "";
|
|
2818
|
+
/border-collapse\s*:/i.test(r) || t(o, "border-collapse:collapse"), !/border-spacing\s*:/i.test(r) && !o.hasAttribute("cellspacing") && o.setAttribute("cellspacing", "0");
|
|
2819
|
+
});
|
|
2820
|
+
const l = i || this.ed.getAttribute("dir") || this.dir();
|
|
2637
2821
|
return e.querySelectorAll("table:not([dir])").forEach((o) => {
|
|
2638
|
-
o.setAttribute("dir",
|
|
2639
|
-
}), `<div dir="${
|
|
2822
|
+
o.setAttribute("dir", l), /direction\s*:/i.test(o.getAttribute("style") || "") || t(o, `direction:${l}`);
|
|
2823
|
+
}), `<div dir="${l}" style="direction:${l};text-align:${l === "rtl" ? "right" : "left"}">${e.innerHTML}</div>`;
|
|
2640
2824
|
}
|
|
2641
2825
|
setContent(t) {
|
|
2642
|
-
this.ed.innerHTML = t || "<p><br></p>", this.refreshState(), this.clearTableHandles(), this.clearImageHandles(), this.clearImgPlaceholderSel(), this.clearTplSel(), this.clearVphPlaceholderSel(), this.clearVidHandles(), this.clearCodeSel(), this.clearSelToolbar(), this.onChange();
|
|
2826
|
+
this.ed.innerHTML = t || "<p><br></p>", this.refreshState(), this.clearTableHandles(), this.clearImageHandles(), this.clearImgPlaceholderSel(), this.clearTplSel(), this.clearVphPlaceholderSel(), this.clearVidHandles(), this.clearCodeSel(), this.clearSelToolbar(), this.onChange(), this.stampExistingImages();
|
|
2643
2827
|
}
|
|
2644
2828
|
insertContent(t) {
|
|
2645
2829
|
this.restoreSel(), document.execCommand("insertHTML", !1, t), this.saveSel(), this.refreshState(), this.onChange();
|
|
@@ -2651,7 +2835,7 @@ const I = class I {
|
|
|
2651
2835
|
this.ed.focus();
|
|
2652
2836
|
}
|
|
2653
2837
|
async importWordFile(t) {
|
|
2654
|
-
const e = await
|
|
2838
|
+
const e = await Wt(t);
|
|
2655
2839
|
this.recordRevision(), this.setContent(e), this.recordRevision();
|
|
2656
2840
|
}
|
|
2657
2841
|
restoreDraft() {
|
|
@@ -2710,8 +2894,8 @@ const I = class I {
|
|
|
2710
2894
|
t.preventDefault();
|
|
2711
2895
|
const l = document.createElement("p");
|
|
2712
2896
|
l.appendChild(document.createElement("br")), s.after(l), i.remove(), s.firstElementChild || s.remove();
|
|
2713
|
-
const
|
|
2714
|
-
|
|
2897
|
+
const n = document.createRange();
|
|
2898
|
+
n.setStart(l, 0), n.collapse(!0), e.removeAllRanges(), e.addRange(n), this.saveSel(), this.onChange();
|
|
2715
2899
|
}
|
|
2716
2900
|
selectedBlocks() {
|
|
2717
2901
|
const t = window.getSelection();
|
|
@@ -2761,30 +2945,30 @@ const I = class I {
|
|
|
2761
2945
|
s.className = "revprev";
|
|
2762
2946
|
const l = document.createElement("button");
|
|
2763
2947
|
l.type = "button", l.className = "revrestore", l.textContent = this.t("restore");
|
|
2764
|
-
let
|
|
2765
|
-
const
|
|
2948
|
+
let n = this.revisions.length - 1;
|
|
2949
|
+
const o = new Intl.DateTimeFormat(this.lang === "ar" ? "ar-AE" : "en-GB", {
|
|
2766
2950
|
year: "numeric",
|
|
2767
2951
|
month: "short",
|
|
2768
2952
|
day: "numeric",
|
|
2769
2953
|
hour: "2-digit",
|
|
2770
2954
|
minute: "2-digit",
|
|
2771
2955
|
second: "2-digit"
|
|
2772
|
-
}), r = {},
|
|
2773
|
-
|
|
2956
|
+
}), r = {}, a = (d) => {
|
|
2957
|
+
n = d, this.revisions.forEach((p, u) => {
|
|
2774
2958
|
var g;
|
|
2775
|
-
return (g = r[
|
|
2776
|
-
}), s.innerHTML = this.revisions[
|
|
2959
|
+
return (g = r[u]) == null ? void 0 : g.classList.toggle("on", u === d);
|
|
2960
|
+
}), s.innerHTML = this.revisions[d].html, l.disabled = d === this.revisions.length - 1;
|
|
2777
2961
|
};
|
|
2778
|
-
for (let
|
|
2779
|
-
const
|
|
2780
|
-
|
|
2781
|
-
const g = (new DOMParser().parseFromString(
|
|
2782
|
-
|
|
2962
|
+
for (let d = this.revisions.length - 1; d >= 0; d--) {
|
|
2963
|
+
const p = this.revisions[d], u = document.createElement("button");
|
|
2964
|
+
u.type = "button";
|
|
2965
|
+
const g = (new DOMParser().parseFromString(p.html, "text/html").body.textContent || "").trim(), m = g ? g.split(/\s+/).length : 0, f = d === this.revisions.length - 1;
|
|
2966
|
+
u.innerHTML = `<span>${f ? this.t("currentver") : o.format(new Date(p.time))}</span><span class="wc">${m} ${this.t("words")}</span>`, u.addEventListener("click", () => a(d)), r[d] = u, i.appendChild(u);
|
|
2783
2967
|
}
|
|
2784
2968
|
i.append(l), l.addEventListener("click", () => {
|
|
2785
|
-
const
|
|
2786
|
-
|
|
2787
|
-
}), e.append(i, s), t.appendChild(e),
|
|
2969
|
+
const d = this.revisions[n];
|
|
2970
|
+
d && (this.recordRevision(), this.setContent(d.html), this.recordRevision(), this.closeDlg());
|
|
2971
|
+
}), e.append(i, s), t.appendChild(e), a(n);
|
|
2788
2972
|
});
|
|
2789
2973
|
}
|
|
2790
2974
|
/* ---------------------------------------------------------- popups / menus */
|
|
@@ -2818,13 +3002,13 @@ const I = class I {
|
|
|
2818
3002
|
const i = e.getBoundingClientRect(), s = e.closest(".pop");
|
|
2819
3003
|
this.closeSubFrom(s ? this.subLevelOf(s) : 0);
|
|
2820
3004
|
const l = document.createElement("div");
|
|
2821
|
-
l.className = "pop sub", l.dir = this.dir(), t.subBuild ? t.subBuild(l) : t.sub && this.menuItems(l, t.sub), l.addEventListener("mousedown", (
|
|
2822
|
-
|
|
3005
|
+
l.className = "pop sub", l.dir = this.dir(), t.subBuild ? t.subBuild(l) : t.sub && this.menuItems(l, t.sub), l.addEventListener("mousedown", (a) => {
|
|
3006
|
+
a.target.tagName !== "INPUT" && a.preventDefault();
|
|
2823
3007
|
}), document.body.appendChild(l);
|
|
2824
|
-
let
|
|
2825
|
-
|
|
3008
|
+
let o = this.dir() === "rtl" ? i.left - l.offsetWidth + 2 : i.right - 2;
|
|
3009
|
+
o = Math.max(8, Math.min(o + scrollX, scrollX + innerWidth - l.offsetWidth - 8));
|
|
2826
3010
|
let r = i.top + scrollY - 6;
|
|
2827
|
-
r = Math.max(8 + scrollY, Math.min(r, scrollY + innerHeight - l.offsetHeight - 8)), l.style.left =
|
|
3011
|
+
r = Math.max(8 + scrollY, Math.min(r, scrollY + innerHeight - l.offsetHeight - 8)), l.style.left = o + "px", l.style.top = r + "px", this.subStack.push(l);
|
|
2828
3012
|
}
|
|
2829
3013
|
popup(t, e, i) {
|
|
2830
3014
|
if (this.openPop && this.popAnchor === t) {
|
|
@@ -2836,11 +3020,11 @@ const I = class I {
|
|
|
2836
3020
|
s.className = "pop" + (i ? " " + i : ""), s.dir = this.dir(), e(s), document.body.appendChild(s);
|
|
2837
3021
|
const l = t.getBoundingClientRect();
|
|
2838
3022
|
s.style.minWidth = Math.max(160, Math.round(l.width)) + "px";
|
|
2839
|
-
let
|
|
2840
|
-
|
|
3023
|
+
let n = l.bottom + scrollY + 2;
|
|
3024
|
+
n = Math.max(8 + scrollY, Math.min(n, scrollY + innerHeight - s.offsetHeight - 8)), s.style.top = n + "px";
|
|
2841
3025
|
let r = this.dir() === "rtl" ? l.right - s.offsetWidth : l.left;
|
|
2842
|
-
r = Math.max(8, Math.min(r + scrollX, scrollX + innerWidth - s.offsetWidth - 8)), s.style.left = r + "px", s.addEventListener("mousedown", (
|
|
2843
|
-
|
|
3026
|
+
r = Math.max(8, Math.min(r + scrollX, scrollX + innerWidth - s.offsetWidth - 8)), s.style.left = r + "px", s.addEventListener("mousedown", (a) => {
|
|
3027
|
+
a.target.tagName !== "INPUT" && a.preventDefault();
|
|
2844
3028
|
}), this.openPop = s, this.popAnchor = t, t.classList.add("open");
|
|
2845
3029
|
}
|
|
2846
3030
|
menuItems(t, e) {
|
|
@@ -2850,44 +3034,44 @@ const I = class I {
|
|
|
2850
3034
|
return;
|
|
2851
3035
|
}
|
|
2852
3036
|
const s = !!(i.sub || i.subBuild), l = document.createElement("button");
|
|
2853
|
-
l.className = "mi" + (i.on ? " on" : ""), l.innerHTML = `<span class="ic">${i.icon || ""}</span><span class="prev" ${i.previewStyle ? `style="${i.previewStyle}"` : ""}>${i.label}</span>${i.shortcut ? `<span class="sc">${i.shortcut}</span>` : ""}${s ? `<span class="subarrow">${
|
|
3037
|
+
l.className = "mi" + (i.on ? " on" : ""), l.innerHTML = `<span class="ic">${i.icon || ""}</span><span class="prev" ${i.previewStyle ? `style="${i.previewStyle}"` : ""}>${i.label}</span>${i.shortcut ? `<span class="sc">${i.shortcut}</span>` : ""}${s ? `<span class="subarrow">${c.chev}</span>` : ""}`, l.addEventListener("click", () => {
|
|
2854
3038
|
i.action && (this.closePop(), i.action());
|
|
2855
3039
|
}), l.addEventListener("mouseenter", () => {
|
|
2856
|
-
var
|
|
2857
|
-
s ? this.openSubFor(i, l) : this.closeSubFrom(this.subLevelOf(t)), (
|
|
3040
|
+
var n;
|
|
3041
|
+
s ? this.openSubFor(i, l) : this.closeSubFrom(this.subLevelOf(t)), (n = i.hover) == null || n.call(i, !0);
|
|
2858
3042
|
}), l.addEventListener("mouseleave", () => {
|
|
2859
|
-
var
|
|
2860
|
-
return (
|
|
3043
|
+
var n;
|
|
3044
|
+
return (n = i.hover) == null ? void 0 : n.call(i, !1);
|
|
2861
3045
|
}), t.appendChild(l);
|
|
2862
3046
|
});
|
|
2863
3047
|
}
|
|
2864
3048
|
/* ---------------------------------------------------------- toolbar builders */
|
|
2865
3049
|
tbtn(t, e, i, s) {
|
|
2866
3050
|
const l = document.createElement("button");
|
|
2867
|
-
return l.className = "tbtn", l.type = "button", l.title = e, l.innerHTML = t, s && (l.dataset.id = s), l.addEventListener("mousedown", (
|
|
3051
|
+
return l.className = "tbtn", l.type = "button", l.title = e, l.innerHTML = t, s && (l.dataset.id = s), l.addEventListener("mousedown", (n) => n.preventDefault()), l.addEventListener("click", i), l;
|
|
2868
3052
|
}
|
|
2869
3053
|
/** Font-size increase / decrease step button. */
|
|
2870
3054
|
stepBtn(t) {
|
|
2871
|
-
const e = t > 0 ? "+" : "−", i = t > 0 ?
|
|
3055
|
+
const e = t > 0 ? "+" : "−", i = t > 0 ? c.fontsizeup : c.fontsizedown, s = this.tbtn(i, this.t("fontsize") + " " + e, () => this.stepFontSize(t));
|
|
2872
3056
|
return s.addEventListener("mousedown", () => this.saveSel()), s;
|
|
2873
3057
|
}
|
|
2874
3058
|
/** Toolbar icon button that opens a popup menu anchored to itself. */
|
|
2875
3059
|
menuTbtn(t, e, i, s) {
|
|
2876
3060
|
const l = this.tbtn(t, e, () => i(l), s);
|
|
2877
|
-
return l.classList.add("hasmenu"), l.insertAdjacentHTML("beforeend",
|
|
3061
|
+
return l.classList.add("hasmenu"), l.insertAdjacentHTML("beforeend", c.chev), l.addEventListener("mousedown", () => this.saveSel()), l;
|
|
2878
3062
|
}
|
|
2879
3063
|
/** Quick text-color chips plus a "more" chip that opens the full palette. */
|
|
2880
3064
|
colorChips() {
|
|
2881
3065
|
const t = (s) => {
|
|
2882
3066
|
const l = document.createElement("button");
|
|
2883
|
-
return l.type = "button", l.className = "cchip", l.title = s, l.addEventListener("mousedown", (
|
|
2884
|
-
|
|
3067
|
+
return l.type = "button", l.className = "cchip", l.title = s, l.addEventListener("mousedown", (n) => {
|
|
3068
|
+
n.preventDefault(), this.saveSel();
|
|
2885
3069
|
}), l;
|
|
2886
|
-
}, e =
|
|
3070
|
+
}, e = ft.map((s) => {
|
|
2887
3071
|
const l = t(this.t("forecolor"));
|
|
2888
3072
|
return l.style.background = s, l.addEventListener("click", () => this.applyColor("fore", s)), l;
|
|
2889
3073
|
}), i = t(this.t("forecolor"));
|
|
2890
|
-
return i.classList.add("more"), i.dataset.cb = "fore", i.innerHTML =
|
|
3074
|
+
return i.classList.add("more"), i.dataset.cb = "fore", i.innerHTML = c.chev, i.addEventListener("click", () => this.colorMenu(i, "fore")), [...e, i];
|
|
2891
3075
|
}
|
|
2892
3076
|
group(...t) {
|
|
2893
3077
|
const e = document.createElement("div");
|
|
@@ -2897,45 +3081,45 @@ const I = class I {
|
|
|
2897
3081
|
}
|
|
2898
3082
|
tsel(t, e, i, s) {
|
|
2899
3083
|
const l = document.createElement("button");
|
|
2900
|
-
return l.className = "tsel " + t, l.type = "button", l.dataset.id = e, l.innerHTML = `<span class="lbl empty">${i || ""}</span>${
|
|
2901
|
-
|
|
3084
|
+
return l.className = "tsel " + t, l.type = "button", l.dataset.id = e, l.innerHTML = `<span class="lbl empty">${i || ""}</span>${c.chev}`, l.addEventListener("mousedown", (n) => {
|
|
3085
|
+
n.preventDefault(), this.saveSel();
|
|
2902
3086
|
}), l.addEventListener("click", () => s(l)), l;
|
|
2903
3087
|
}
|
|
2904
3088
|
setListStyle(t, e) {
|
|
2905
|
-
var l,
|
|
3089
|
+
var l, n;
|
|
2906
3090
|
this.restoreSel();
|
|
2907
3091
|
const i = window.getSelection();
|
|
2908
3092
|
if (!i) return;
|
|
2909
3093
|
let s = (l = this.closestBlock(i.anchorNode)) == null ? void 0 : l.closest(t);
|
|
2910
|
-
s || (this.exec(t === "ol" ? "insertOrderedList" : "insertUnorderedList"), s = (
|
|
3094
|
+
s || (this.exec(t === "ol" ? "insertOrderedList" : "insertUnorderedList"), s = (n = this.closestBlock(i.anchorNode)) == null ? void 0 : n.closest(t)), s && (s.style.listStyleType = e), this.saveSel(), this.onChange();
|
|
2911
3095
|
}
|
|
2912
3096
|
listMenu(t, e) {
|
|
2913
|
-
var
|
|
3097
|
+
var a;
|
|
2914
3098
|
const i = e === "ol" ? "insertOrderedList" : "insertUnorderedList", s = e === "ol" ? [
|
|
2915
|
-
["lower-alpha",
|
|
2916
|
-
["lower-roman",
|
|
2917
|
-
["upper-alpha",
|
|
2918
|
-
["upper-roman",
|
|
3099
|
+
["lower-alpha", c.ol_alpha],
|
|
3100
|
+
["lower-roman", c.ol_roman],
|
|
3101
|
+
["upper-alpha", c.ol_alphau],
|
|
3102
|
+
["upper-roman", c.ol_romanu]
|
|
2919
3103
|
] : [
|
|
2920
|
-
["circle",
|
|
2921
|
-
["square",
|
|
2922
|
-
], l = this.tArr(e === "ol" ? "liststyles_ol" : "liststyles_ul").slice(1),
|
|
2923
|
-
this.popup(t, (
|
|
2924
|
-
this.menuItems(
|
|
3104
|
+
["circle", c.ul_circle],
|
|
3105
|
+
["square", c.ul_square]
|
|
3106
|
+
], l = this.tArr(e === "ol" ? "liststyles_ol" : "liststyles_ul").slice(1), n = window.getSelection(), o = n ? (a = this.closestBlock(n.anchorNode)) == null ? void 0 : a.closest(e) : null, r = o ? o.style.listStyleType : "";
|
|
3107
|
+
this.popup(t, (d) => {
|
|
3108
|
+
this.menuItems(d, [
|
|
2925
3109
|
{
|
|
2926
3110
|
label: this.t(e === "ol" ? "numlist" : "bullist"),
|
|
2927
|
-
icon: e === "ol" ?
|
|
3111
|
+
icon: e === "ol" ? c.numlist : c.bullist,
|
|
2928
3112
|
on: document.queryCommandState(i),
|
|
2929
3113
|
action: () => this.exec(i)
|
|
2930
3114
|
}
|
|
2931
|
-
]),
|
|
2932
|
-
const
|
|
2933
|
-
|
|
2934
|
-
const
|
|
2935
|
-
|
|
2936
|
-
this.closePop(), this.setListStyle(e,
|
|
2937
|
-
}),
|
|
2938
|
-
}),
|
|
3115
|
+
]), d.insertAdjacentHTML("beforeend", '<div class="sep"></div>');
|
|
3116
|
+
const p = document.createElement("div");
|
|
3117
|
+
p.className = "mi-grid", s.forEach(([u, g], m) => {
|
|
3118
|
+
const f = document.createElement("button");
|
|
3119
|
+
f.className = "mi" + (r === u ? " on" : ""), f.innerHTML = `<span class="ic">${g}</span><span class="prev">${l[m]}</span>`, f.addEventListener("click", () => {
|
|
3120
|
+
this.closePop(), this.setListStyle(e, u);
|
|
3121
|
+
}), p.appendChild(f);
|
|
3122
|
+
}), d.appendChild(p);
|
|
2939
3123
|
});
|
|
2940
3124
|
}
|
|
2941
3125
|
/** Shared color-picker popup body — swatch grid plus the current-color /
|
|
@@ -2943,26 +3127,26 @@ const I = class I {
|
|
|
2943
3127
|
* table cell-background menu all show the identical popup. */
|
|
2944
3128
|
buildPaletteInto(t, e, i) {
|
|
2945
3129
|
const s = document.createElement("div");
|
|
2946
|
-
s.className = "cpal",
|
|
2947
|
-
const
|
|
2948
|
-
|
|
2949
|
-
this.closePop(), i(
|
|
2950
|
-
}), s.appendChild(
|
|
3130
|
+
s.className = "cpal", vt.forEach((p) => {
|
|
3131
|
+
const u = document.createElement("button");
|
|
3132
|
+
u.type = "button", u.style.background = p, u.title = p, u.addEventListener("click", () => {
|
|
3133
|
+
this.closePop(), i(p);
|
|
3134
|
+
}), s.appendChild(u);
|
|
2951
3135
|
}), t.appendChild(s), t.insertAdjacentHTML("beforeend", '<div class="sep"></div>');
|
|
2952
3136
|
const l = document.createElement("div");
|
|
2953
3137
|
l.className = "cfoot";
|
|
2954
|
-
const
|
|
2955
|
-
|
|
3138
|
+
const n = /^#[0-9a-f]{6}$/i.test(e) ? e : "#000000", o = document.createElement("div");
|
|
3139
|
+
o.className = "cswatch cur", o.title = this.t("currentcolor"), o.style.background = n, o.innerHTML = c.check;
|
|
2956
3140
|
const r = document.createElement("button");
|
|
2957
3141
|
r.type = "button", r.className = "cswatch nocolor", r.title = this.t("removecolor"), r.addEventListener("click", () => {
|
|
2958
3142
|
this.closePop(), i(null);
|
|
2959
3143
|
});
|
|
2960
|
-
const
|
|
2961
|
-
|
|
2962
|
-
const
|
|
2963
|
-
|
|
2964
|
-
this.closePop(), i(
|
|
2965
|
-
}),
|
|
3144
|
+
const a = document.createElement("label");
|
|
3145
|
+
a.className = "cswatch cwheel", a.title = this.t("customcolor"), a.innerHTML = c.palette;
|
|
3146
|
+
const d = document.createElement("input");
|
|
3147
|
+
d.type = "color", d.value = n, d.addEventListener("change", () => {
|
|
3148
|
+
this.closePop(), i(d.value);
|
|
3149
|
+
}), a.appendChild(d), l.append(o, r, a), t.appendChild(l);
|
|
2966
3150
|
}
|
|
2967
3151
|
colorMenu(t, e) {
|
|
2968
3152
|
this.popup(
|
|
@@ -2992,7 +3176,7 @@ const I = class I {
|
|
|
2992
3176
|
this.popup(t, (e) => this.menuItems(e, this.fontItems()));
|
|
2993
3177
|
}
|
|
2994
3178
|
sizeItems() {
|
|
2995
|
-
return
|
|
3179
|
+
return ut.map((t) => ({
|
|
2996
3180
|
label: t,
|
|
2997
3181
|
on: this.currentSize() === t,
|
|
2998
3182
|
action: () => this.applyFontSize(t)
|
|
@@ -3008,19 +3192,19 @@ const I = class I {
|
|
|
3008
3192
|
const t = window.getSelection();
|
|
3009
3193
|
if (!t) return;
|
|
3010
3194
|
if (!t.rangeCount) {
|
|
3011
|
-
const
|
|
3012
|
-
|
|
3195
|
+
const n = document.createRange();
|
|
3196
|
+
n.selectNodeContents(this.ed), n.collapse(!0), t.addRange(n);
|
|
3013
3197
|
}
|
|
3014
3198
|
if (!t.isCollapsed) return;
|
|
3015
3199
|
const e = t.getRangeAt(0), i = e.startContainer;
|
|
3016
3200
|
if (i.nodeType === 3) {
|
|
3017
|
-
const
|
|
3018
|
-
let
|
|
3019
|
-
for (;
|
|
3020
|
-
for (; r <
|
|
3021
|
-
if (r >
|
|
3022
|
-
const
|
|
3023
|
-
|
|
3201
|
+
const n = i.data;
|
|
3202
|
+
let o = e.startOffset, r = e.startOffset;
|
|
3203
|
+
for (; o > 0 && /\S/.test(n[o - 1]); ) o--;
|
|
3204
|
+
for (; r < n.length && /\S/.test(n[r]); ) r++;
|
|
3205
|
+
if (r > o) {
|
|
3206
|
+
const a = document.createRange();
|
|
3207
|
+
a.setStart(i, o), a.setEnd(i, r), t.removeAllRanges(), t.addRange(a), this.savedRange = a.cloneRange();
|
|
3024
3208
|
return;
|
|
3025
3209
|
}
|
|
3026
3210
|
}
|
|
@@ -3045,7 +3229,7 @@ const I = class I {
|
|
|
3045
3229
|
this.saveSel(), this.refreshState(), this.onChange();
|
|
3046
3230
|
}
|
|
3047
3231
|
stepFontSize(t) {
|
|
3048
|
-
const e = parseInt(this.currentSize(), 10) || 14, i = Math.min(
|
|
3232
|
+
const e = parseInt(this.currentSize(), 10) || 14, i = Math.min(gt, Math.max(mt, e + t));
|
|
3049
3233
|
i !== e && this.applyFontSize(i + "px");
|
|
3050
3234
|
}
|
|
3051
3235
|
/* ------------------------------------------------ case / spacing / link */
|
|
@@ -3054,21 +3238,21 @@ const I = class I {
|
|
|
3054
3238
|
const e = window.getSelection();
|
|
3055
3239
|
if (!e || !e.rangeCount || e.isCollapsed) return;
|
|
3056
3240
|
const i = e.getRangeAt(0), s = document.createTreeWalker(this.ed, NodeFilter.SHOW_TEXT), l = [];
|
|
3057
|
-
let
|
|
3058
|
-
for (;
|
|
3059
|
-
l.forEach((
|
|
3060
|
-
const r =
|
|
3061
|
-
if (
|
|
3062
|
-
const
|
|
3063
|
-
let
|
|
3064
|
-
t === "lower" ?
|
|
3241
|
+
let n;
|
|
3242
|
+
for (; n = s.nextNode(); ) i.intersectsNode(n) && l.push(n);
|
|
3243
|
+
l.forEach((o) => {
|
|
3244
|
+
const r = o === i.startContainer ? i.startOffset : 0, a = o === i.endContainer ? i.endOffset : o.data.length;
|
|
3245
|
+
if (a <= r) return;
|
|
3246
|
+
const d = o.data.slice(r, a);
|
|
3247
|
+
let p = d;
|
|
3248
|
+
t === "lower" ? p = d.toLowerCase() : t === "upper" ? p = d.toUpperCase() : p = d.replace(/(^|\s)(\S)/g, (u, g, m) => g + m.toUpperCase()), o.replaceData(r, a - r, p);
|
|
3065
3249
|
}), this.saveSel(), this.refreshState(), this.onChange();
|
|
3066
3250
|
}
|
|
3067
3251
|
caseItems() {
|
|
3068
3252
|
return [
|
|
3069
|
-
{ label: this.t("lowercase"), icon:
|
|
3070
|
-
{ label: this.t("uppercase"), icon:
|
|
3071
|
-
{ label: this.t("capitalize"), icon:
|
|
3253
|
+
{ label: this.t("lowercase"), icon: c.lowercaseic, action: () => this.transformCase("lower") },
|
|
3254
|
+
{ label: this.t("uppercase"), icon: c.uppercaseic, action: () => this.transformCase("upper") },
|
|
3255
|
+
{ label: this.t("capitalize"), icon: c.capitalizeic, action: () => this.transformCase("capitalize") }
|
|
3072
3256
|
];
|
|
3073
3257
|
}
|
|
3074
3258
|
caseMenu(t) {
|
|
@@ -3097,13 +3281,13 @@ const I = class I {
|
|
|
3097
3281
|
];
|
|
3098
3282
|
}
|
|
3099
3283
|
lineHeightMenu(t) {
|
|
3100
|
-
this.popup(t, (e) => this.menuItems(e, this.blockStyleItems("lineHeight",
|
|
3284
|
+
this.popup(t, (e) => this.menuItems(e, this.blockStyleItems("lineHeight", W)));
|
|
3101
3285
|
}
|
|
3102
3286
|
wordSpacingMenu(t) {
|
|
3103
|
-
this.popup(t, (e) => this.menuItems(e, this.blockStyleItems("wordSpacing",
|
|
3287
|
+
this.popup(t, (e) => this.menuItems(e, this.blockStyleItems("wordSpacing", V)));
|
|
3104
3288
|
}
|
|
3105
3289
|
letterSpacingMenu(t) {
|
|
3106
|
-
this.popup(t, (e) => this.menuItems(e, this.blockStyleItems("letterSpacing",
|
|
3290
|
+
this.popup(t, (e) => this.menuItems(e, this.blockStyleItems("letterSpacing", j)));
|
|
3107
3291
|
}
|
|
3108
3292
|
closestAnchor() {
|
|
3109
3293
|
const t = window.getSelection();
|
|
@@ -3149,14 +3333,14 @@ const I = class I {
|
|
|
3149
3333
|
(s) => {
|
|
3150
3334
|
const l = document.createElement("div");
|
|
3151
3335
|
l.style.cssText = "display:flex;align-items:center;gap:10px;margin:10px 0;min-width:360px";
|
|
3152
|
-
const
|
|
3153
|
-
|
|
3336
|
+
const n = document.createElement("span");
|
|
3337
|
+
n.style.cssText = "width:60px;color:#556;flex:none", n.textContent = this.t("linkurl"), e = document.createElement("input"), e.type = "url", e.placeholder = "https://", e.style.cssText = "flex:1;border:1px solid #cfd6df;border-radius:6px;padding:7px 9px;font:14px inherit", e.value = (t == null ? void 0 : t.getAttribute("href")) || "", l.append(n, e), s.appendChild(l), setTimeout(() => e.focus(), 0);
|
|
3154
3338
|
},
|
|
3155
3339
|
i
|
|
3156
3340
|
);
|
|
3157
3341
|
}
|
|
3158
3342
|
blockItems() {
|
|
3159
|
-
return
|
|
3343
|
+
return Q.map(([t]) => ({
|
|
3160
3344
|
label: this.blockLabel(t),
|
|
3161
3345
|
previewStyle: t.startsWith("h") ? `font-weight:700;font-size:${22 - 2 * +t[1]}px` : t === "pre" ? "font-family:monospace" : "",
|
|
3162
3346
|
on: this.currentBlock() === t,
|
|
@@ -3168,10 +3352,10 @@ const I = class I {
|
|
|
3168
3352
|
}
|
|
3169
3353
|
alignItems() {
|
|
3170
3354
|
return [
|
|
3171
|
-
["justifyLeft", "alignleft",
|
|
3172
|
-
["justifyCenter", "aligncenter",
|
|
3173
|
-
["justifyRight", "alignright",
|
|
3174
|
-
["justifyFull", "alignjustify",
|
|
3355
|
+
["justifyLeft", "alignleft", c.alignleft],
|
|
3356
|
+
["justifyCenter", "aligncenter", c.aligncenter],
|
|
3357
|
+
["justifyRight", "alignright", c.alignright],
|
|
3358
|
+
["justifyFull", "alignjustify", c.alignjustify]
|
|
3175
3359
|
].map(([e, i, s]) => ({
|
|
3176
3360
|
label: this.t(i),
|
|
3177
3361
|
icon: s,
|
|
@@ -3193,15 +3377,15 @@ const I = class I {
|
|
|
3193
3377
|
s.className = "tgrid";
|
|
3194
3378
|
const l = document.createElement("div");
|
|
3195
3379
|
l.className = "tgridlbl", l.textContent = "1 × 1";
|
|
3196
|
-
const
|
|
3197
|
-
for (let
|
|
3380
|
+
const n = [];
|
|
3381
|
+
for (let o = 0; o < 8; o++)
|
|
3198
3382
|
for (let r = 0; r < 10; r++) {
|
|
3199
|
-
const
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
}),
|
|
3203
|
-
this.closePop(), this.insertTable(
|
|
3204
|
-
}),
|
|
3383
|
+
const a = document.createElement("span");
|
|
3384
|
+
a.dataset.r = String(o), a.dataset.c = String(r), a.addEventListener("mouseenter", () => {
|
|
3385
|
+
n.forEach((d) => d.classList.toggle("hot", +d.dataset.r <= o && +d.dataset.c <= r)), l.textContent = r + 1 + " × " + (o + 1);
|
|
3386
|
+
}), a.addEventListener("click", () => {
|
|
3387
|
+
this.closePop(), this.insertTable(o + 1, r + 1), e == null || e();
|
|
3388
|
+
}), n.push(a), s.appendChild(a);
|
|
3205
3389
|
}
|
|
3206
3390
|
i.append(s, l), t.appendChild(i);
|
|
3207
3391
|
}
|
|
@@ -3232,73 +3416,73 @@ const I = class I {
|
|
|
3232
3416
|
* behavior changes, just named lookup. Only `forecolor` yields multiple elements
|
|
3233
3417
|
* (the quick color chips); everything else yields one. */
|
|
3234
3418
|
buildToolbarRegistry() {
|
|
3235
|
-
const t = this.tbtn(
|
|
3236
|
-
undo: () => this.tbtn(
|
|
3237
|
-
redo: () => this.tbtn(
|
|
3238
|
-
preview: () => this.tbtn(
|
|
3239
|
-
print: () => this.tbtn(
|
|
3240
|
-
importword: () => this.tbtn(
|
|
3241
|
-
revhistory: () => this.tbtn(
|
|
3419
|
+
const t = this.tbtn(c.tableic, this.t("quicktable"), () => this.tableGrid(t)), e = {
|
|
3420
|
+
undo: () => this.tbtn(c.undo, this.t("undo"), () => this.exec("undo"), "undo"),
|
|
3421
|
+
redo: () => this.tbtn(c.redo, this.t("redo"), () => this.exec("redo"), "redo"),
|
|
3422
|
+
preview: () => this.tbtn(c.prevw, this.t("preview"), () => this.previewDlg()),
|
|
3423
|
+
print: () => this.tbtn(c.printic, this.t("print"), () => this.printDoc()),
|
|
3424
|
+
importword: () => this.tbtn(c.wordic, this.t("importword"), () => this.pickWordDoc()),
|
|
3425
|
+
revhistory: () => this.tbtn(c.historyic, this.t("revhistory"), () => this.revisionDlg()),
|
|
3242
3426
|
fontfamily: () => this.tsel("w-font", "fontsel", "", (i) => this.fontMenu(i)),
|
|
3243
3427
|
fontsize: () => this.tsel("w-size", "sizesel", "", (i) => this.sizeMenu(i)),
|
|
3244
3428
|
fontsizeincrease: () => this.stepBtn(1),
|
|
3245
3429
|
fontsizedecrease: () => this.stepBtn(-1),
|
|
3246
|
-
bold: () => this.tbtn(
|
|
3247
|
-
italic: () => this.tbtn(
|
|
3248
|
-
underline: () => this.tbtn(
|
|
3249
|
-
strikethrough: () => this.tbtn(
|
|
3430
|
+
bold: () => this.tbtn(c.bold, this.t("bold"), () => this.exec("bold"), "bold"),
|
|
3431
|
+
italic: () => this.tbtn(c.italic, this.t("italic"), () => this.exec("italic"), "italic"),
|
|
3432
|
+
underline: () => this.tbtn(c.underline, this.t("underline"), () => this.exec("underline"), "underline"),
|
|
3433
|
+
strikethrough: () => this.tbtn(c.strikethrough, this.t("strikethrough"), () => this.exec("strikeThrough"), "strikeThrough"),
|
|
3250
3434
|
forecolor: () => this.colorChips(),
|
|
3251
3435
|
backcolor: () => this.menuTbtn(
|
|
3252
|
-
|
|
3436
|
+
c.backcolor + '<span class="colorbar" data-cb="back"></span>',
|
|
3253
3437
|
this.t("backcolor"),
|
|
3254
3438
|
(i) => this.colorMenu(i, "back")
|
|
3255
3439
|
),
|
|
3256
|
-
alignleft: () => this.tbtn(
|
|
3257
|
-
aligncenter: () => this.tbtn(
|
|
3258
|
-
alignright: () => this.tbtn(
|
|
3259
|
-
alignjustify: () => this.tbtn(
|
|
3260
|
-
bullist: () => this.menuTbtn(
|
|
3261
|
-
numlist: () => this.menuTbtn(
|
|
3262
|
-
outdent: () => this.tbtn(
|
|
3263
|
-
indent: () => this.tbtn(
|
|
3264
|
-
link: () => this.tbtn(
|
|
3265
|
-
blockquote: () => this.tbtn(
|
|
3266
|
-
code: () => this.tbtn(
|
|
3267
|
-
codesample: () => this.tbtn(
|
|
3268
|
-
changecase: () => this.menuTbtn(
|
|
3269
|
-
lineheight: () => this.menuTbtn(
|
|
3270
|
-
wordspacing: () => this.menuTbtn(
|
|
3271
|
-
letterspacing: () => this.menuTbtn(
|
|
3272
|
-
removeformat: () => this.tbtn(
|
|
3440
|
+
alignleft: () => this.tbtn(c.alignleft, this.t("alignleft"), () => this.exec("justifyLeft"), "justifyLeft"),
|
|
3441
|
+
aligncenter: () => this.tbtn(c.aligncenter, this.t("aligncenter"), () => this.exec("justifyCenter"), "justifyCenter"),
|
|
3442
|
+
alignright: () => this.tbtn(c.alignright, this.t("alignright"), () => this.exec("justifyRight"), "justifyRight"),
|
|
3443
|
+
alignjustify: () => this.tbtn(c.alignjustify, this.t("alignjustify"), () => this.exec("justifyFull"), "justifyFull"),
|
|
3444
|
+
bullist: () => this.menuTbtn(c.bullist, this.t("bullist"), (i) => this.listMenu(i, "ul"), "insertUnorderedList"),
|
|
3445
|
+
numlist: () => this.menuTbtn(c.numlist, this.t("numlist"), (i) => this.listMenu(i, "ol"), "insertOrderedList"),
|
|
3446
|
+
outdent: () => this.tbtn(c.outdent, this.t("outdent"), () => this.exec("outdent")),
|
|
3447
|
+
indent: () => this.tbtn(c.indent, this.t("indent"), () => this.exec("indent")),
|
|
3448
|
+
link: () => this.tbtn(c.link, this.t("linkttl"), () => this.linkDlg()),
|
|
3449
|
+
blockquote: () => this.tbtn(c.quote, this.t("quote"), () => this.toggleBlock("blockquote"), "blockquote"),
|
|
3450
|
+
code: () => this.tbtn(c.inlinecodeic, this.t("code"), () => this.toggleInlineCode(), "code"),
|
|
3451
|
+
codesample: () => this.tbtn(c.codesampleic, this.t("codesample"), () => this.codeDlg()),
|
|
3452
|
+
changecase: () => this.menuTbtn(c.caseic, this.t("changecase"), (i) => this.caseMenu(i)),
|
|
3453
|
+
lineheight: () => this.menuTbtn(c.lineheight, this.t("lineheight"), (i) => this.lineHeightMenu(i)),
|
|
3454
|
+
wordspacing: () => this.menuTbtn(c.wordspacing, this.t("wordspacing"), (i) => this.wordSpacingMenu(i)),
|
|
3455
|
+
letterspacing: () => this.menuTbtn(c.letterspacing, this.t("letterspacing"), (i) => this.letterSpacingMenu(i)),
|
|
3456
|
+
removeformat: () => this.tbtn(c.clearformatic, this.t("removeformat"), () => this.exec("removeFormat")),
|
|
3273
3457
|
blocks: () => this.tsel("w-block", "blocksel", this.t("para"), (i) => this.blocksMenu(i)),
|
|
3274
|
-
ltr: () => this.tbtn(
|
|
3275
|
-
rtl: () => this.tbtn(
|
|
3276
|
-
quickimage: () => this.tbtn(
|
|
3277
|
-
quickvideo: () => this.tbtn(
|
|
3458
|
+
ltr: () => this.tbtn(c.ltr, this.t("ltr"), () => this.setDir("ltr"), "ltr"),
|
|
3459
|
+
rtl: () => this.tbtn(c.rtl, this.t("rtl"), () => this.setDir("rtl"), "rtl"),
|
|
3460
|
+
quickimage: () => this.tbtn(c.image, this.t("quickimage"), () => this.insertImagePlaceholder()),
|
|
3461
|
+
quickvideo: () => this.tbtn(c.video, this.t("quickvideo"), () => this.videoDlg()),
|
|
3278
3462
|
quicktable: () => t,
|
|
3279
|
-
template: () => this.menuTbtn(
|
|
3280
|
-
charmap: () => this.tbtn(
|
|
3281
|
-
emoji: () => this.tbtn(
|
|
3282
|
-
fullscreen: () => this.tbtn(
|
|
3283
|
-
sourcecode: () => this.tbtn(
|
|
3463
|
+
template: () => this.menuTbtn(c.templateic, this.t("template"), (i) => this.templateMenu(i)),
|
|
3464
|
+
charmap: () => this.tbtn(c.charic, this.t("charmap"), () => this.charMap()),
|
|
3465
|
+
emoji: () => this.tbtn(c.emojiic, this.t("emoji"), () => this.emojiMap()),
|
|
3466
|
+
fullscreen: () => this.tbtn(c.fullscreen, this.t("fullscreen"), () => this.toggleFullscreen(), "fullscreen"),
|
|
3467
|
+
sourcecode: () => this.tbtn(c.srcic, this.t("sourcecode"), () => this.sourceDlg())
|
|
3284
3468
|
};
|
|
3285
3469
|
return e.styles = e.blocks, e.image = e.quickimage, e.media = e.quickvideo, e.table = e.quicktable, e;
|
|
3286
3470
|
}
|
|
3287
3471
|
buildToolbar() {
|
|
3288
3472
|
this.toolbar.innerHTML = "";
|
|
3289
|
-
const t = this.options.toolbar === !0 ?
|
|
3473
|
+
const t = this.options.toolbar === !0 ? ht : this.options.toolbar, e = this.buildToolbarRegistry();
|
|
3290
3474
|
this.parseToolbarString(t).forEach((i) => {
|
|
3291
3475
|
const s = [];
|
|
3292
3476
|
i.forEach((l) => {
|
|
3293
|
-
const
|
|
3294
|
-
if (!
|
|
3477
|
+
const n = e[l];
|
|
3478
|
+
if (!n) {
|
|
3295
3479
|
console.warn(`FableEditor: unknown toolbar item "${l}"`);
|
|
3296
3480
|
return;
|
|
3297
3481
|
}
|
|
3298
|
-
const
|
|
3299
|
-
Array.isArray(
|
|
3482
|
+
const o = n();
|
|
3483
|
+
Array.isArray(o) ? s.push(...o) : s.push(o);
|
|
3300
3484
|
}), s.length && this.toolbar.appendChild(this.group(...s));
|
|
3301
|
-
}), this.tbrMore = this.tbtn(
|
|
3485
|
+
}), this.tbrMore = this.tbtn(c.more, this.t("more"), () => {
|
|
3302
3486
|
this.tbrExpanded = !this.tbrExpanded, this.updateToolbarOverflow();
|
|
3303
3487
|
}), this.tbrMore.classList.add("tbr-more"), this.toolbar.appendChild(this.tbrMore), this.syncColorSwatches(this.toolbar), this.updateToolbarOverflow();
|
|
3304
3488
|
}
|
|
@@ -3328,134 +3512,134 @@ const I = class I {
|
|
|
3328
3512
|
this.menubar.innerHTML = "";
|
|
3329
3513
|
const t = {
|
|
3330
3514
|
file: [
|
|
3331
|
-
this.mItem("newdoc",
|
|
3515
|
+
this.mItem("newdoc", c.newic, () => {
|
|
3332
3516
|
this.recordRevision(), this.ed.innerHTML = "<p><br></p>", this.onChange();
|
|
3333
3517
|
}),
|
|
3334
3518
|
"|",
|
|
3335
|
-
this.mItem("importword",
|
|
3336
|
-
this.mItem("restoredraft",
|
|
3519
|
+
this.mItem("importword", c.wordic, () => this.pickWordDoc()),
|
|
3520
|
+
this.mItem("restoredraft", c.draftic, () => {
|
|
3337
3521
|
this.restoreDraft() || alert(this.t("draftempty"));
|
|
3338
3522
|
}),
|
|
3339
|
-
this.mItem("revhistory",
|
|
3523
|
+
this.mItem("revhistory", c.historyic, () => this.revisionDlg()),
|
|
3340
3524
|
"|",
|
|
3341
|
-
this.mItem("preview",
|
|
3342
|
-
this.mItem("print",
|
|
3525
|
+
this.mItem("preview", c.prevw, () => this.previewDlg()),
|
|
3526
|
+
this.mItem("print", c.printic, () => this.printDoc(), "Ctrl+P")
|
|
3343
3527
|
],
|
|
3344
3528
|
edit: [
|
|
3345
|
-
this.mItem("undo",
|
|
3346
|
-
this.mItem("redo",
|
|
3529
|
+
this.mItem("undo", c.undo, () => this.exec("undo"), "Ctrl+Z"),
|
|
3530
|
+
this.mItem("redo", c.redo, () => this.exec("redo"), "Ctrl+Y"),
|
|
3347
3531
|
"|",
|
|
3348
|
-
this.mItem("cut",
|
|
3349
|
-
this.mItem("copy",
|
|
3350
|
-
this.mItem("paste",
|
|
3532
|
+
this.mItem("cut", c.cutic, () => this.exec("cut"), "Ctrl+X"),
|
|
3533
|
+
this.mItem("copy", c.copyic, () => this.exec("copy"), "Ctrl+C"),
|
|
3534
|
+
this.mItem("paste", c.pasteic, () => alert(this.t("pastehint")), "Ctrl+V"),
|
|
3351
3535
|
"|",
|
|
3352
|
-
this.mItem("selectall",
|
|
3536
|
+
this.mItem("selectall", c.selall, () => this.exec("selectAll"), "Ctrl+A")
|
|
3353
3537
|
],
|
|
3354
3538
|
view: [
|
|
3355
|
-
this.mItem("fullscreen",
|
|
3356
|
-
this.mItem("preview",
|
|
3357
|
-
this.mItem("sourcecode",
|
|
3539
|
+
this.mItem("fullscreen", c.fullscreen, () => this.toggleFullscreen()),
|
|
3540
|
+
this.mItem("preview", c.prevw, () => this.previewDlg()),
|
|
3541
|
+
this.mItem("sourcecode", c.srcic, () => this.sourceDlg())
|
|
3358
3542
|
],
|
|
3359
3543
|
insert: [
|
|
3360
|
-
this.mItem("link",
|
|
3361
|
-
this.mItem("image",
|
|
3362
|
-
this.mItem("video",
|
|
3363
|
-
{ label: this.t("inserttable"), icon:
|
|
3364
|
-
this.mItem("codesample",
|
|
3365
|
-
{ label: this.t("template"), icon:
|
|
3366
|
-
this.mItem("hr",
|
|
3544
|
+
this.mItem("link", c.link, () => this.linkDlg()),
|
|
3545
|
+
this.mItem("image", c.image, () => this.insertImagePlaceholder()),
|
|
3546
|
+
this.mItem("video", c.video, () => this.videoDlg()),
|
|
3547
|
+
{ label: this.t("inserttable"), icon: c.tableic, action: () => this.tableGrid(this.menubar.querySelector('[data-menu-key="table"]') || this.menubar) },
|
|
3548
|
+
this.mItem("codesample", c.codesampleic, () => this.codeDlg()),
|
|
3549
|
+
{ label: this.t("template"), icon: c.templateic, subBuild: (s) => this.buildTemplatePickInto(s) },
|
|
3550
|
+
this.mItem("hr", c.hric, () => this.exec("insertHorizontalRule")),
|
|
3367
3551
|
"|",
|
|
3368
|
-
this.mItem("charmap",
|
|
3369
|
-
this.mItem("emoji",
|
|
3552
|
+
this.mItem("charmap", c.charic, () => this.charMap()),
|
|
3553
|
+
this.mItem("emoji", c.emojiic, () => this.emojiMap()),
|
|
3370
3554
|
this.mItem(
|
|
3371
3555
|
"datetime",
|
|
3372
|
-
|
|
3556
|
+
c.dateic,
|
|
3373
3557
|
() => this.exec("insertText", (/* @__PURE__ */ new Date()).toLocaleString(this.lang === "ar" ? "ar-AE" : "en-GB"))
|
|
3374
3558
|
),
|
|
3375
3559
|
"|",
|
|
3376
3560
|
{
|
|
3377
3561
|
label: this.t("pagebreak"),
|
|
3378
|
-
icon:
|
|
3562
|
+
icon: c.pbic,
|
|
3379
3563
|
action: () => {
|
|
3380
3564
|
this.restoreSel(), document.execCommand("insertHTML", !1, '<hr class="pagebreak"><p><br></p>'), this.onChange();
|
|
3381
3565
|
}
|
|
3382
3566
|
},
|
|
3383
|
-
this.mItem("nbsp",
|
|
3567
|
+
this.mItem("nbsp", c.nbspic, () => this.exec("insertText", " "))
|
|
3384
3568
|
],
|
|
3385
3569
|
format: [
|
|
3386
|
-
this.mItem("bold",
|
|
3387
|
-
this.mItem("italic",
|
|
3388
|
-
this.mItem("underline",
|
|
3389
|
-
this.mItem("strikethrough",
|
|
3390
|
-
this.mItem("superscript",
|
|
3391
|
-
this.mItem("subscript",
|
|
3392
|
-
this.mItem("code",
|
|
3393
|
-
this.mItem("quote",
|
|
3570
|
+
this.mItem("bold", c.bold, () => this.exec("bold"), "Ctrl+B"),
|
|
3571
|
+
this.mItem("italic", c.italic, () => this.exec("italic"), "Ctrl+I"),
|
|
3572
|
+
this.mItem("underline", c.underline, () => this.exec("underline"), "Ctrl+U"),
|
|
3573
|
+
this.mItem("strikethrough", c.strikethrough, () => this.exec("strikeThrough")),
|
|
3574
|
+
this.mItem("superscript", c.superscriptic, () => this.exec("superscript")),
|
|
3575
|
+
this.mItem("subscript", c.subscriptic, () => this.exec("subscript")),
|
|
3576
|
+
this.mItem("code", c.inlinecodeic, () => this.toggleInlineCode()),
|
|
3577
|
+
this.mItem("quote", c.quote, () => this.toggleBlock("blockquote")),
|
|
3394
3578
|
"|",
|
|
3395
3579
|
{ label: this.t("fontfamily"), subBuild: (s) => this.menuItems(s, this.fontItems()) },
|
|
3396
3580
|
{ label: this.t("fontsize"), subBuild: (s) => this.menuItems(s, this.sizeItems()) },
|
|
3397
3581
|
{ label: this.t("blocks"), subBuild: (s) => this.menuItems(s, this.blockItems()) },
|
|
3398
3582
|
{ label: this.t("align"), subBuild: (s) => this.menuItems(s, this.alignItems()) },
|
|
3399
|
-
{ label: this.t("lineheight"), icon:
|
|
3400
|
-
{ label: this.t("wordspacing"), icon:
|
|
3401
|
-
{ label: this.t("letterspacing"), icon:
|
|
3583
|
+
{ label: this.t("lineheight"), icon: c.lineheight, subBuild: (s) => this.menuItems(s, this.blockStyleItems("lineHeight", W)) },
|
|
3584
|
+
{ label: this.t("wordspacing"), icon: c.wordspacing, subBuild: (s) => this.menuItems(s, this.blockStyleItems("wordSpacing", V)) },
|
|
3585
|
+
{ label: this.t("letterspacing"), icon: c.letterspacing, subBuild: (s) => this.menuItems(s, this.blockStyleItems("letterSpacing", j)) },
|
|
3402
3586
|
"|",
|
|
3403
|
-
{ label: this.t("forecolor"), icon:
|
|
3404
|
-
{ label: this.t("backcolor"), icon:
|
|
3587
|
+
{ label: this.t("forecolor"), icon: c.palette, subBuild: (s) => this.buildPaletteInto(s, this.foreColor, (l) => this.applyColor("fore", l)) },
|
|
3588
|
+
{ label: this.t("backcolor"), icon: c.backcolor, subBuild: (s) => this.buildPaletteInto(s, this.backColor, (l) => this.applyColor("back", l)) },
|
|
3405
3589
|
"|",
|
|
3406
|
-
this.mItem("bullist",
|
|
3407
|
-
this.mItem("numlist",
|
|
3408
|
-
this.mItem("outdent",
|
|
3409
|
-
this.mItem("indent",
|
|
3590
|
+
this.mItem("bullist", c.bullist, () => this.exec("insertUnorderedList")),
|
|
3591
|
+
this.mItem("numlist", c.numlist, () => this.exec("insertOrderedList")),
|
|
3592
|
+
this.mItem("outdent", c.outdent, () => this.exec("outdent")),
|
|
3593
|
+
this.mItem("indent", c.indent, () => this.exec("indent")),
|
|
3410
3594
|
"|",
|
|
3411
|
-
this.mItem("ltr",
|
|
3412
|
-
this.mItem("rtl",
|
|
3595
|
+
this.mItem("ltr", c.ltr, () => this.setDir("ltr")),
|
|
3596
|
+
this.mItem("rtl", c.rtl, () => this.setDir("rtl")),
|
|
3413
3597
|
"|",
|
|
3414
|
-
{ label: this.t("changecase"), icon:
|
|
3598
|
+
{ label: this.t("changecase"), icon: c.caseic, sub: this.caseItems() },
|
|
3415
3599
|
"|",
|
|
3416
|
-
this.mItem("clearformat",
|
|
3600
|
+
this.mItem("clearformat", c.clearformatic, () => this.exec("removeFormat"))
|
|
3417
3601
|
],
|
|
3418
|
-
tools: [this.mItem("sourcecode",
|
|
3602
|
+
tools: [this.mItem("sourcecode", c.srcic, () => this.sourceDlg()), this.mItem("wordcount", c.wcic, () => this.wordCountDlg())],
|
|
3419
3603
|
table: [
|
|
3420
|
-
{ label: this.t("inserttable"), icon:
|
|
3604
|
+
{ label: this.t("inserttable"), icon: c.tableic, subBuild: (s) => this.buildTableGridInto(s) },
|
|
3421
3605
|
"|",
|
|
3422
3606
|
{
|
|
3423
3607
|
label: this.t("cell"),
|
|
3424
3608
|
sub: [
|
|
3425
|
-
{ label: this.t("cellprops"), icon:
|
|
3426
|
-
{ label: this.t("cellbg"), icon:
|
|
3609
|
+
{ label: this.t("cellprops"), icon: c.tableic, action: () => this.cellPropsDlg() },
|
|
3610
|
+
{ label: this.t("cellbg"), icon: c.palette, subBuild: (s) => this.buildCellFillInto(s) }
|
|
3427
3611
|
]
|
|
3428
3612
|
},
|
|
3429
3613
|
{
|
|
3430
3614
|
label: this.t("row"),
|
|
3431
3615
|
sub: [
|
|
3432
|
-
{ label: this.t("rowabove"), icon:
|
|
3433
|
-
{ label: this.t("rowbelow"), icon:
|
|
3434
|
-
{ label: this.t("delrow"), icon:
|
|
3616
|
+
{ label: this.t("rowabove"), icon: c.rowbefore, action: () => this.tableOp("rowabove"), hover: (s) => this.setOpTarget(s ? "row" : null) },
|
|
3617
|
+
{ label: this.t("rowbelow"), icon: c.rowafter, action: () => this.tableOp("rowbelow"), hover: (s) => this.setOpTarget(s ? "row" : null) },
|
|
3618
|
+
{ label: this.t("delrow"), icon: c.rowdelete, action: () => this.tableOp("delrow"), hover: (s) => this.setOpTarget(s ? "row" : null) },
|
|
3435
3619
|
"|",
|
|
3436
|
-
{ label: this.t("moverowup"), icon:
|
|
3437
|
-
{ label: this.t("moverowdown"), icon:
|
|
3620
|
+
{ label: this.t("moverowup"), icon: c.moverowup, action: () => this.tableMove("rowup"), hover: (s) => this.setOpTarget(s ? "row" : null) },
|
|
3621
|
+
{ label: this.t("moverowdown"), icon: c.moverowdown, action: () => this.tableMove("rowdown"), hover: (s) => this.setOpTarget(s ? "row" : null) },
|
|
3438
3622
|
"|",
|
|
3439
|
-
{ label: this.t("rowprops"), icon:
|
|
3623
|
+
{ label: this.t("rowprops"), icon: c.tableic, action: () => this.rowPropsDlg(), hover: (s) => this.setOpTarget(s ? "row" : null) }
|
|
3440
3624
|
]
|
|
3441
3625
|
},
|
|
3442
3626
|
{
|
|
3443
3627
|
label: this.t("column"),
|
|
3444
3628
|
sub: [
|
|
3445
|
-
{ label: this.t("colbefore"), icon:
|
|
3446
|
-
{ label: this.t("colafter"), icon:
|
|
3447
|
-
{ label: this.t("delcol"), icon:
|
|
3629
|
+
{ label: this.t("colbefore"), icon: c.colbefore, action: () => this.tableOp("colbefore"), hover: (s) => this.setOpTarget(s ? "col" : null) },
|
|
3630
|
+
{ label: this.t("colafter"), icon: c.colafter, action: () => this.tableOp("colafter"), hover: (s) => this.setOpTarget(s ? "col" : null) },
|
|
3631
|
+
{ label: this.t("delcol"), icon: c.coldelete, action: () => this.tableOp("delcol"), hover: (s) => this.setOpTarget(s ? "col" : null) },
|
|
3448
3632
|
"|",
|
|
3449
|
-
{ label: this.t("movecolleft"), icon:
|
|
3450
|
-
{ label: this.t("movecolright"), icon:
|
|
3633
|
+
{ label: this.t("movecolleft"), icon: c.movecolleft, action: () => this.tableMove("colleft"), hover: (s) => this.setOpTarget(s ? "col" : null) },
|
|
3634
|
+
{ label: this.t("movecolright"), icon: c.movecolright, action: () => this.tableMove("colright"), hover: (s) => this.setOpTarget(s ? "col" : null) },
|
|
3451
3635
|
"|",
|
|
3452
|
-
{ label: this.t("colprops"), icon:
|
|
3636
|
+
{ label: this.t("colprops"), icon: c.tableic, action: () => this.colPropsDlg(), hover: (s) => this.setOpTarget(s ? "col" : null) }
|
|
3453
3637
|
]
|
|
3454
3638
|
},
|
|
3455
3639
|
"|",
|
|
3456
3640
|
{
|
|
3457
3641
|
label: this.t("tablepropsttl"),
|
|
3458
|
-
icon:
|
|
3642
|
+
icon: c.tableic,
|
|
3459
3643
|
action: () => {
|
|
3460
3644
|
const s = this.currentCell();
|
|
3461
3645
|
if (!s) {
|
|
@@ -3465,10 +3649,10 @@ const I = class I {
|
|
|
3465
3649
|
this.tblActive = s.closest("table"), this.tablePropsDlg();
|
|
3466
3650
|
}
|
|
3467
3651
|
},
|
|
3468
|
-
{ label: this.t("deltable"), icon:
|
|
3652
|
+
{ label: this.t("deltable"), icon: c.trash, action: () => this.tableOp("deltable") }
|
|
3469
3653
|
],
|
|
3470
|
-
help: [this.mItem("helpttl",
|
|
3471
|
-
}, e = this.options.menubar === !0 ?
|
|
3654
|
+
help: [this.mItem("helpttl", c.helpic, () => this.helpDlg(), "Alt+0")]
|
|
3655
|
+
}, e = this.options.menubar === !0 ? dt : this.options.menubar, i = /* @__PURE__ */ new Set();
|
|
3472
3656
|
e.split(/\s+/).filter(Boolean).forEach((s) => {
|
|
3473
3657
|
if (i.has(s)) return;
|
|
3474
3658
|
if (i.add(s), !t[s]) {
|
|
@@ -3476,36 +3660,36 @@ const I = class I {
|
|
|
3476
3660
|
return;
|
|
3477
3661
|
}
|
|
3478
3662
|
const l = document.createElement("button");
|
|
3479
|
-
l.type = "button", l.textContent = this.t(s), l.dataset.menuKey = s, l.addEventListener("mousedown", (
|
|
3480
|
-
|
|
3481
|
-
}), l.addEventListener("click", () => this.popup(l, (
|
|
3663
|
+
l.type = "button", l.textContent = this.t(s), l.dataset.menuKey = s, l.addEventListener("mousedown", (n) => {
|
|
3664
|
+
n.preventDefault(), this.saveSel();
|
|
3665
|
+
}), l.addEventListener("click", () => this.popup(l, (n) => this.menuItems(n, t[s]))), this.menubar.appendChild(l);
|
|
3482
3666
|
});
|
|
3483
3667
|
}
|
|
3484
3668
|
/* ---------------------------------------------------------- table ops */
|
|
3485
3669
|
tableOp(t) {
|
|
3486
|
-
var r,
|
|
3670
|
+
var r, a, d;
|
|
3487
3671
|
this.restoreSel();
|
|
3488
3672
|
const e = window.getSelection();
|
|
3489
3673
|
if (!e) return;
|
|
3490
|
-
const i = ((r = this.closestBlock(e.anchorNode)) == null ? void 0 : r.closest("td,th")) || (e.anchorNode && e.anchorNode.nodeType === 1 ? (
|
|
3674
|
+
const i = ((r = this.closestBlock(e.anchorNode)) == null ? void 0 : r.closest("td,th")) || (e.anchorNode && e.anchorNode.nodeType === 1 ? (d = (a = e.anchorNode).closest) == null ? void 0 : d.call(a, "td,th") : null);
|
|
3491
3675
|
if (!i) return;
|
|
3492
|
-
const s = i.parentElement, l = i.closest("table"),
|
|
3493
|
-
const
|
|
3494
|
-
return Array.from(s.children).forEach((
|
|
3495
|
-
const g = document.createElement("td"),
|
|
3496
|
-
|
|
3497
|
-
}),
|
|
3676
|
+
const s = i.parentElement, l = i.closest("table"), n = Array.from(s.children).indexOf(i), o = () => {
|
|
3677
|
+
const p = s.cloneNode(!1);
|
|
3678
|
+
return Array.from(s.children).forEach((u) => {
|
|
3679
|
+
const g = document.createElement("td"), m = u.getAttribute("style");
|
|
3680
|
+
m && g.setAttribute("style", m), g.style.removeProperty("background-color"), g.innerHTML = "<br>", p.appendChild(g);
|
|
3681
|
+
}), p;
|
|
3498
3682
|
};
|
|
3499
|
-
if (t === "rowabove" && s.before(
|
|
3500
|
-
const
|
|
3501
|
-
s.remove(),
|
|
3683
|
+
if (t === "rowabove" && s.before(o()), t === "rowbelow" && s.after(o()), t === "delrow") {
|
|
3684
|
+
const p = s.parentElement;
|
|
3685
|
+
s.remove(), p.querySelector("tr") || l.remove();
|
|
3502
3686
|
}
|
|
3503
|
-
(t === "colbefore" || t === "colafter") && l.querySelectorAll("tr").forEach((
|
|
3504
|
-
const
|
|
3505
|
-
|
|
3506
|
-
}), t === "delcol" && (l.querySelectorAll("tr").forEach((
|
|
3507
|
-
var
|
|
3508
|
-
return (
|
|
3687
|
+
(t === "colbefore" || t === "colafter") && l.querySelectorAll("tr").forEach((p) => {
|
|
3688
|
+
const u = p.children[Math.min(n, p.children.length - 1)], g = document.createElement("td"), m = u.getAttribute("style");
|
|
3689
|
+
m && g.setAttribute("style", m), g.style.removeProperty("width"), g.style.removeProperty("background-color"), g.innerHTML = "<br>", t === "colbefore" ? u.before(g) : u.after(g);
|
|
3690
|
+
}), t === "delcol" && (l.querySelectorAll("tr").forEach((p) => {
|
|
3691
|
+
var u;
|
|
3692
|
+
return (u = p.children[n]) == null ? void 0 : u.remove();
|
|
3509
3693
|
}), l.querySelector("td,th") || l.remove()), t === "deltable" && l.remove(), this.onChange(), this.positionTableHandles();
|
|
3510
3694
|
}
|
|
3511
3695
|
/** Reorders the current row/column: 'rowup'/'rowdown' swap the caret's row with
|
|
@@ -3525,16 +3709,16 @@ const I = class I {
|
|
|
3525
3709
|
r && r.after(i);
|
|
3526
3710
|
}
|
|
3527
3711
|
t === "colleft" && l > 0 && s.querySelectorAll("tr").forEach((r) => {
|
|
3528
|
-
const
|
|
3529
|
-
|
|
3712
|
+
const a = r.children[l], d = r.children[l - 1];
|
|
3713
|
+
a && d && d.before(a);
|
|
3530
3714
|
}), t === "colright" && s.querySelectorAll("tr").forEach((r) => {
|
|
3531
|
-
const
|
|
3532
|
-
|
|
3715
|
+
const a = r.children[l], d = r.children[l + 1];
|
|
3716
|
+
a && d && d.after(a);
|
|
3533
3717
|
});
|
|
3534
|
-
const
|
|
3535
|
-
|
|
3536
|
-
const
|
|
3537
|
-
|
|
3718
|
+
const n = document.createRange();
|
|
3719
|
+
n.selectNodeContents(e), n.collapse(!0);
|
|
3720
|
+
const o = window.getSelection();
|
|
3721
|
+
o && (o.removeAllRanges(), o.addRange(n)), this.saveSel(), this.onChange(), this.positionTableHandles(), this.positionCellMarker();
|
|
3538
3722
|
}
|
|
3539
3723
|
/** Align the whole table via auto margins — same semantics as the align
|
|
3540
3724
|
* field in the table-properties dialog. */
|
|
@@ -3571,26 +3755,26 @@ const I = class I {
|
|
|
3571
3755
|
tablePropsDlg() {
|
|
3572
3756
|
const t = this.tblActive;
|
|
3573
3757
|
if (!t) return;
|
|
3574
|
-
let e, i, s, l,
|
|
3575
|
-
const
|
|
3758
|
+
let e, i, s, l, n;
|
|
3759
|
+
const o = "display:flex;align-items:center;gap:10px;margin:10px 0", r = "width:120px;color:#556;flex:none", a = "flex:1;border:1px solid #cfd6df;border-radius:6px;padding:7px 9px;font:14px inherit", d = t.querySelector("td,th"), p = t.style.width || "", u = d && d.style.padding ? parseFloat(d.style.padding) : "", g = t.style.borderSpacing ? parseFloat(t.style.borderSpacing) : "", m = t.style.borderWidth ? parseFloat(t.style.borderWidth) : "", f = t.style.marginLeft, b = t.style.marginRight, y = f === "auto" && b === "auto" ? "center" : f === "auto" ? "right" : b === "auto" && f === "0" ? "left" : "";
|
|
3576
3760
|
this.dialog(
|
|
3577
3761
|
this.t("tablepropsttl"),
|
|
3578
3762
|
(C) => {
|
|
3579
|
-
const
|
|
3763
|
+
const S = (w, k) => {
|
|
3580
3764
|
const L = document.createElement("div");
|
|
3581
|
-
L.style.cssText =
|
|
3582
|
-
const
|
|
3583
|
-
|
|
3765
|
+
L.style.cssText = o;
|
|
3766
|
+
const H = document.createElement("span");
|
|
3767
|
+
H.style.cssText = r, H.textContent = this.t(w), L.append(H, k), C.appendChild(L);
|
|
3584
3768
|
};
|
|
3585
|
-
e = document.createElement("input"), e.type = "text", e.style.cssText =
|
|
3769
|
+
e = document.createElement("input"), e.type = "text", e.style.cssText = a, e.placeholder = "e.g. 600px or 100%", e.value = p, S("tblwidth", e), i = document.createElement("input"), i.type = "number", i.min = "0", i.style.cssText = a, i.value = String(u), S("tblcellpadding", i), s = document.createElement("input"), s.type = "number", s.min = "0", s.style.cssText = a, s.value = String(g), S("tblcellspacing", s), l = document.createElement("input"), l.type = "number", l.min = "0", l.style.cssText = a, l.value = String(m), S("tblborder", l), n = document.createElement("select"), n.style.cssText = a, [
|
|
3586
3770
|
["", "alignnone"],
|
|
3587
3771
|
["left", "alignleft"],
|
|
3588
3772
|
["center", "aligncenter"],
|
|
3589
3773
|
["right", "alignright"]
|
|
3590
|
-
].forEach(([w,
|
|
3774
|
+
].forEach(([w, k]) => {
|
|
3591
3775
|
const L = document.createElement("option");
|
|
3592
|
-
L.value = w, L.textContent = this.t(
|
|
3593
|
-
}),
|
|
3776
|
+
L.value = w, L.textContent = this.t(k), w === y && (L.selected = !0), n.appendChild(L);
|
|
3777
|
+
}), S("tblalign", n);
|
|
3594
3778
|
},
|
|
3595
3779
|
[
|
|
3596
3780
|
{ label: this.t("cancel"), action: () => this.closeDlg() },
|
|
@@ -3603,7 +3787,7 @@ const I = class I {
|
|
|
3603
3787
|
cellpadding: i.value.trim(),
|
|
3604
3788
|
cellspacing: s.value.trim(),
|
|
3605
3789
|
border: l.value.trim(),
|
|
3606
|
-
align:
|
|
3790
|
+
align: n.value
|
|
3607
3791
|
}), this.closeDlg(), this.onChange(), this.positionTableHandles();
|
|
3608
3792
|
}
|
|
3609
3793
|
}
|
|
@@ -3642,8 +3826,8 @@ const I = class I {
|
|
|
3642
3826
|
formSelect(t, e) {
|
|
3643
3827
|
const i = document.createElement("select");
|
|
3644
3828
|
return i.style.cssText = "flex:1;border:1px solid #cfd6df;border-radius:6px;padding:7px 9px;font:14px inherit;background:#fff", t.forEach(([s, l]) => {
|
|
3645
|
-
const
|
|
3646
|
-
|
|
3829
|
+
const n = document.createElement("option");
|
|
3830
|
+
n.value = s, n.textContent = l, s === e && (n.selected = !0), i.appendChild(n);
|
|
3647
3831
|
}), i;
|
|
3648
3832
|
}
|
|
3649
3833
|
formBg(t) {
|
|
@@ -3653,8 +3837,8 @@ const I = class I {
|
|
|
3653
3837
|
s.type = "color", s.value = i || "#ffffff", s.style.cssText = "width:36px;height:29px;border:1px solid #cfd6df;border-radius:4px;padding:1px;background:none;cursor:pointer";
|
|
3654
3838
|
const l = document.createElement("label");
|
|
3655
3839
|
l.style.cssText = "display:flex;align-items:center;gap:6px;cursor:pointer;color:#556";
|
|
3656
|
-
const
|
|
3657
|
-
return
|
|
3840
|
+
const n = document.createElement("input");
|
|
3841
|
+
return n.type = "checkbox", n.checked = !!i, l.append(n, document.createTextNode(this.t("fill"))), s.addEventListener("input", () => n.checked = !0), e.append(s, l), { wrap: e, color: s, fill: n };
|
|
3658
3842
|
}
|
|
3659
3843
|
setOrClear(t, e, i) {
|
|
3660
3844
|
i ? t.style.setProperty(e, /^(width|height)$/.test(e) && /^\d+$/.test(i) ? i + "px" : i) : t.style.removeProperty(e);
|
|
@@ -3665,11 +3849,11 @@ const I = class I {
|
|
|
3665
3849
|
alert(this.t("nocell"));
|
|
3666
3850
|
return;
|
|
3667
3851
|
}
|
|
3668
|
-
let e, i, s, l,
|
|
3852
|
+
let e, i, s, l, n;
|
|
3669
3853
|
this.dialog(
|
|
3670
3854
|
this.t("cellprops").replace("…", ""),
|
|
3671
|
-
(
|
|
3672
|
-
e = this.formInput(t.style.width, "e.g. 120px / 25%"), this.formRow(
|
|
3855
|
+
(o) => {
|
|
3856
|
+
e = this.formInput(t.style.width, "e.g. 120px / 25%"), this.formRow(o, this.t("tblwidth"), e), i = this.formInput(t.style.height, "e.g. 40px"), this.formRow(o, this.t("tblheight"), i), s = this.formSelect(
|
|
3673
3857
|
[
|
|
3674
3858
|
["", this.t("alignnone")],
|
|
3675
3859
|
["left", this.t("alignleft")],
|
|
@@ -3677,7 +3861,7 @@ const I = class I {
|
|
|
3677
3861
|
["right", this.t("alignright")]
|
|
3678
3862
|
],
|
|
3679
3863
|
t.style.textAlign || ""
|
|
3680
|
-
), this.formRow(
|
|
3864
|
+
), this.formRow(o, this.t("tblalign"), s), l = this.formSelect(
|
|
3681
3865
|
[
|
|
3682
3866
|
["", this.t("alignnone")],
|
|
3683
3867
|
["top", this.t("valigntop")],
|
|
@@ -3685,7 +3869,7 @@ const I = class I {
|
|
|
3685
3869
|
["bottom", this.t("valignbottom")]
|
|
3686
3870
|
],
|
|
3687
3871
|
t.style.verticalAlign || ""
|
|
3688
|
-
), this.formRow(
|
|
3872
|
+
), this.formRow(o, this.t("valign"), l), n = this.formBg(t.style.backgroundColor || ""), this.formRow(o, this.t("backcolor"), n.wrap);
|
|
3689
3873
|
},
|
|
3690
3874
|
[
|
|
3691
3875
|
{ label: this.t("cancel"), action: () => this.closeDlg() },
|
|
@@ -3693,7 +3877,7 @@ const I = class I {
|
|
|
3693
3877
|
label: this.t("save"),
|
|
3694
3878
|
primary: !0,
|
|
3695
3879
|
action: () => {
|
|
3696
|
-
this.setOrClear(t, "width", e.value.trim()), this.setOrClear(t, "height", i.value.trim()), this.setOrClear(t, "text-align", s.value), this.setOrClear(t, "vertical-align", l.value), this.setOrClear(t, "background-color",
|
|
3880
|
+
this.setOrClear(t, "width", e.value.trim()), this.setOrClear(t, "height", i.value.trim()), this.setOrClear(t, "text-align", s.value), this.setOrClear(t, "vertical-align", l.value), this.setOrClear(t, "background-color", n.fill.checked ? n.color.value : ""), this.closeDlg(), this.onChange(), this.positionTableHandles();
|
|
3697
3881
|
}
|
|
3698
3882
|
}
|
|
3699
3883
|
]
|
|
@@ -3731,11 +3915,11 @@ const I = class I {
|
|
|
3731
3915
|
return;
|
|
3732
3916
|
}
|
|
3733
3917
|
const e = t.parentElement, i = t.closest("table"), s = Array.from(e.children).indexOf(t), l = Array.from(i.rows).map((r) => r.cells[s]).filter(Boolean);
|
|
3734
|
-
let
|
|
3918
|
+
let n, o;
|
|
3735
3919
|
this.dialog(
|
|
3736
3920
|
this.t("colprops").replace("…", ""),
|
|
3737
3921
|
(r) => {
|
|
3738
|
-
|
|
3922
|
+
n = this.formInput(t.style.width, "e.g. 120px / 25%"), this.formRow(r, this.t("tblwidth"), n), o = this.formBg(t.style.backgroundColor || ""), this.formRow(r, this.t("backcolor"), o.wrap);
|
|
3739
3923
|
},
|
|
3740
3924
|
[
|
|
3741
3925
|
{ label: this.t("cancel"), action: () => this.closeDlg() },
|
|
@@ -3744,7 +3928,7 @@ const I = class I {
|
|
|
3744
3928
|
primary: !0,
|
|
3745
3929
|
action: () => {
|
|
3746
3930
|
l.forEach((r) => {
|
|
3747
|
-
this.setOrClear(r, "width",
|
|
3931
|
+
this.setOrClear(r, "width", n.value.trim()), this.setOrClear(r, "background-color", o.fill.checked ? o.color.value : "");
|
|
3748
3932
|
}), this.closeDlg(), this.onChange(), this.positionTableHandles();
|
|
3749
3933
|
}
|
|
3750
3934
|
}
|
|
@@ -3760,8 +3944,8 @@ const I = class I {
|
|
|
3760
3944
|
const s = document.createElement("div");
|
|
3761
3945
|
s.className = "dlg", s.dir = this.dir(), s.innerHTML = `<header><span>${t}</span><button type="button">×</button></header>
|
|
3762
3946
|
<div class="body"></div><footer></footer>`, s.querySelector("header button").onclick = () => this.closeDlg(), e(s.querySelector(".body")), (i || [{ label: this.t("close"), primary: !0, action: () => this.closeDlg() }]).forEach((l) => {
|
|
3763
|
-
const
|
|
3764
|
-
|
|
3947
|
+
const n = document.createElement("button");
|
|
3948
|
+
n.type = "button", n.textContent = l.label, l.primary && (n.className = "pri"), n.onclick = l.action, s.querySelector("footer").appendChild(n);
|
|
3765
3949
|
}), this.dlgOvl.appendChild(s), this.dlgOvl.addEventListener("mousedown", (l) => {
|
|
3766
3950
|
l.target === this.dlgOvl && this.closeDlg();
|
|
3767
3951
|
}), document.body.appendChild(this.dlgOvl);
|
|
@@ -3811,8 +3995,12 @@ const I = class I {
|
|
|
3811
3995
|
}
|
|
3812
3996
|
previewDlg() {
|
|
3813
3997
|
this.dialog(this.t("previewttl"), (t) => {
|
|
3998
|
+
var s;
|
|
3999
|
+
(s = t.closest(".dlg")) == null || s.classList.add("dlg-preview");
|
|
3814
4000
|
const e = document.createElement("div");
|
|
3815
|
-
e.
|
|
4001
|
+
e.className = "pv-box";
|
|
4002
|
+
const i = this.contentWidth();
|
|
4003
|
+
e.style.cssText = `width:${i > 0 ? Math.round(i) : 640}px;max-width:100%;max-height:52vh;overflow:auto;border:1px solid #e3e3e3;border-radius:6px;padding:14px;font-family:Helvetica,Arial,sans-serif;font-size:14px`, e.innerHTML = this.ed.innerHTML, t.appendChild(e);
|
|
3816
4004
|
});
|
|
3817
4005
|
}
|
|
3818
4006
|
/** Two-pane picker shared by the special-character map and the emoji map:
|
|
@@ -3821,31 +4009,31 @@ const I = class I {
|
|
|
3821
4009
|
this.saveSel(), this.dialog(t, (s) => {
|
|
3822
4010
|
const l = document.createElement("div");
|
|
3823
4011
|
l.className = "chmap";
|
|
3824
|
-
const o = document.createElement("div");
|
|
3825
|
-
o.className = "chtabs";
|
|
3826
4012
|
const n = document.createElement("div");
|
|
3827
|
-
n.className = "
|
|
4013
|
+
n.className = "chtabs";
|
|
4014
|
+
const o = document.createElement("div");
|
|
4015
|
+
o.className = "chpanel";
|
|
3828
4016
|
const r = document.createElement("div");
|
|
3829
|
-
r.className = "chgrid" + (i ? " emgrid" : ""),
|
|
3830
|
-
const
|
|
3831
|
-
|
|
3832
|
-
const
|
|
3833
|
-
|
|
3834
|
-
this.closeDlg(), this.exec("insertText",
|
|
3835
|
-
}, r.appendChild(
|
|
3836
|
-
}),
|
|
4017
|
+
r.className = "chgrid" + (i ? " emgrid" : ""), o.appendChild(r);
|
|
4018
|
+
const a = (d) => {
|
|
4019
|
+
n.querySelectorAll("button").forEach((p, u) => p.classList.toggle("on", u === d)), r.innerHTML = "", e[d].chars.forEach((p) => {
|
|
4020
|
+
const u = document.createElement("button");
|
|
4021
|
+
u.type = "button", u.textContent = p, u.onclick = () => {
|
|
4022
|
+
this.closeDlg(), this.exec("insertText", p);
|
|
4023
|
+
}, r.appendChild(u);
|
|
4024
|
+
}), o.scrollTop = 0;
|
|
3837
4025
|
};
|
|
3838
|
-
e.forEach((
|
|
3839
|
-
const
|
|
3840
|
-
|
|
3841
|
-
}), l.append(
|
|
4026
|
+
e.forEach((d, p) => {
|
|
4027
|
+
const u = document.createElement("button");
|
|
4028
|
+
u.type = "button", u.textContent = this.t(d.key), u.addEventListener("click", () => a(p)), n.appendChild(u);
|
|
4029
|
+
}), l.append(n, o), s.appendChild(l), a(0);
|
|
3842
4030
|
});
|
|
3843
4031
|
}
|
|
3844
4032
|
charMap() {
|
|
3845
|
-
this.glyphPickerDlg(this.t("charmap").replace("…", ""),
|
|
4033
|
+
this.glyphPickerDlg(this.t("charmap").replace("…", ""), bt, !1);
|
|
3846
4034
|
}
|
|
3847
4035
|
emojiMap() {
|
|
3848
|
-
this.glyphPickerDlg(this.t("emoji").replace("…", ""),
|
|
4036
|
+
this.glyphPickerDlg(this.t("emoji").replace("…", ""), yt, !0);
|
|
3849
4037
|
}
|
|
3850
4038
|
printDoc() {
|
|
3851
4039
|
const t = window.open("", "_blank");
|
|
@@ -3858,7 +4046,7 @@ const I = class I {
|
|
|
3858
4046
|
}
|
|
3859
4047
|
/* ---------------------------------------------- image upload placeholder */
|
|
3860
4048
|
imgPhHTML(t) {
|
|
3861
|
-
return `<div class="img-ph"${t ? ` id="${t}"` : ""} contenteditable="false">${
|
|
4049
|
+
return `<div class="img-ph"${t ? ` id="${t}"` : ""} contenteditable="false">${c.image}<span>${this.t("dropimage")}</span></div>`;
|
|
3862
4050
|
}
|
|
3863
4051
|
insertImagePlaceholder() {
|
|
3864
4052
|
this.restoreSel();
|
|
@@ -3882,11 +4070,11 @@ const I = class I {
|
|
|
3882
4070
|
var e;
|
|
3883
4071
|
const t = this.phCtx;
|
|
3884
4072
|
t && (t.innerHTML = "", t.append(
|
|
3885
|
-
this.ctxBtn(
|
|
4073
|
+
this.ctxBtn(c.uploadic, this.t("uploadimg"), () => {
|
|
3886
4074
|
this.phUploadTarget = this.phActive, this.pickImage();
|
|
3887
4075
|
}),
|
|
3888
|
-
this.ctxBtn(
|
|
3889
|
-
), (e = this.phActive) != null && e.closest(".tpl-media") && t.append(this.ctxBtn(
|
|
4076
|
+
this.ctxBtn(c.link, this.t("imagelink"), () => this.renderPhCtxUrlInput())
|
|
4077
|
+
), (e = this.phActive) != null && e.closest(".tpl-media") && t.append(this.ctxBtn(c.video, this.t("quickvideo"), () => this.swapPlaceholderKind("video"))), t.append(this.ctxSep(), this.ctxBtn(c.trash, this.t("deleteimg"), () => this.removeImgPlaceholder())), this.positionImgPhCtx());
|
|
3890
4078
|
}
|
|
3891
4079
|
/** Swaps a template slot's placeholder between image and video kinds, so the
|
|
3892
4080
|
* same media slot can be filled with either. */
|
|
@@ -3907,17 +4095,17 @@ const I = class I {
|
|
|
3907
4095
|
const i = document.createElement("button");
|
|
3908
4096
|
i.type = "button", i.className = "txtbtn", i.textContent = this.t("insertimg");
|
|
3909
4097
|
const s = () => {
|
|
3910
|
-
const l = e.value.trim(),
|
|
3911
|
-
if (!
|
|
4098
|
+
const l = e.value.trim(), n = this.phActive;
|
|
4099
|
+
if (!n) return;
|
|
3912
4100
|
if (!/^(https?:|data:image\/|blob:)/i.test(l)) {
|
|
3913
4101
|
e.classList.add("err"), e.focus();
|
|
3914
4102
|
return;
|
|
3915
4103
|
}
|
|
3916
4104
|
i.disabled = !0, e.disabled = !0;
|
|
3917
|
-
const
|
|
3918
|
-
|
|
4105
|
+
const o = new Image();
|
|
4106
|
+
o.onload = () => this.replacePlaceholderWithImage(n, l, ""), o.onerror = () => {
|
|
3919
4107
|
i.disabled = !1, e.disabled = !1, e.classList.add("err"), e.focus();
|
|
3920
|
-
},
|
|
4108
|
+
}, o.src = l;
|
|
3921
4109
|
};
|
|
3922
4110
|
i.addEventListener("click", s), e.addEventListener("input", () => e.classList.remove("err")), e.addEventListener("keydown", (l) => {
|
|
3923
4111
|
l.key === "Enter" ? (l.preventDefault(), s()) : l.key === "Escape" && (l.stopPropagation(), this.renderPhCtxButtons());
|
|
@@ -3943,13 +4131,64 @@ const I = class I {
|
|
|
3943
4131
|
s && (s.textContent = this.t("uploading")), this.imageUploadHandler(t).then((l) => {
|
|
3944
4132
|
this.ed.contains(e) && this.replacePlaceholderWithImage(e, l, i);
|
|
3945
4133
|
}).catch((l) => {
|
|
3946
|
-
var
|
|
3947
|
-
this.ed.contains(e) && (e.classList.remove("uploading"), e.classList.add("upload-error"), s && (s.textContent = this.t("uploadfailed")), (
|
|
4134
|
+
var n;
|
|
4135
|
+
this.ed.contains(e) && (e.classList.remove("uploading"), e.classList.add("upload-error"), s && (s.textContent = this.t("uploadfailed")), (n = this.onImageUploadError) == null || n.call(this, l, t));
|
|
3948
4136
|
});
|
|
3949
4137
|
}
|
|
3950
4138
|
replacePlaceholderWithImage(t, e, i) {
|
|
3951
4139
|
const s = document.createElement("img");
|
|
3952
|
-
s.src = e, s.alt = "", i && (s.title = i), t.replaceWith(s), this.phActive === t && this.clearImgPlaceholderSel(), this.refreshState(), this.onChange();
|
|
4140
|
+
s.src = e, s.alt = "", i && (s.title = i), t.replaceWith(s), this.stampImageSize(s), this.phActive === t && this.clearImgPlaceholderSel(), this.refreshState(), this.onChange();
|
|
4141
|
+
}
|
|
4142
|
+
/** Width of the editor's text column — the width `.earea img { max-width:100% }`
|
|
4143
|
+
* clamps an oversized image to. */
|
|
4144
|
+
contentWidth() {
|
|
4145
|
+
const t = getComputedStyle(this.ed), e = (parseFloat(t.paddingLeft) || 0) + (parseFloat(t.paddingRight) || 0);
|
|
4146
|
+
return Math.max(0, this.ed.clientWidth - e);
|
|
4147
|
+
}
|
|
4148
|
+
/** Inserts an <img> through execCommand and stamps its size once it has decoded.
|
|
4149
|
+
* A throwaway id is the only way to get a handle on what insertHTML created. */
|
|
4150
|
+
insertImageHTML(t, e) {
|
|
4151
|
+
const i = "fable-img-" + Date.now().toString(36) + Math.random().toString(36).slice(2, 6);
|
|
4152
|
+
document.execCommand(
|
|
4153
|
+
"insertHTML",
|
|
4154
|
+
!1,
|
|
4155
|
+
`<img id="${i}" src="${t}"${e ? ` title="${e}"` : ""} alt="">`
|
|
4156
|
+
);
|
|
4157
|
+
const s = this.ed.querySelector("#" + i);
|
|
4158
|
+
s && (s.removeAttribute("id"), this.stampImageSize(s));
|
|
4159
|
+
}
|
|
4160
|
+
/** Gives a newly inserted image an explicit size so it renders the same in the
|
|
4161
|
+
* editor, in Preview and in a sent email. Without it the image only looks right
|
|
4162
|
+
* inside `.earea`, whose `max-width:100%` rule exists nowhere else — which is why
|
|
4163
|
+
* the same picture came out at a different size once the mail was sent.
|
|
4164
|
+
* Leaves alone: images inside a template media slot (deliberately fluid) and any
|
|
4165
|
+
* image that already carries a size from its source. */
|
|
4166
|
+
stampImageSize(t, e) {
|
|
4167
|
+
const i = (l) => {
|
|
4168
|
+
e ? e(l) : l && this.onChange();
|
|
4169
|
+
}, s = () => {
|
|
4170
|
+
if (!this.ed.contains(t) || t.closest(".tpl-media") || t.getAttribute("width") || t.getAttribute("height") || t.style.width || t.style.height) return i(!1);
|
|
4171
|
+
const l = t.naturalWidth;
|
|
4172
|
+
if (!l) return i(!1);
|
|
4173
|
+
const n = this.contentWidth(), o = Math.round(n > 0 ? Math.min(l, n) : l);
|
|
4174
|
+
t.setAttribute("width", String(o)), t.style.width = o + "px", t.style.height = "auto", i(!0);
|
|
4175
|
+
};
|
|
4176
|
+
t.complete && t.naturalWidth ? s() : (t.addEventListener("load", s, { once: !0 }), t.addEventListener("error", () => i(!1), { once: !0 }));
|
|
4177
|
+
}
|
|
4178
|
+
/** Sizes images in content that arrived from outside the editor — a document saved
|
|
4179
|
+
* before the editor started recording image sizes. Without this such a document
|
|
4180
|
+
* keeps rendering at one size here and another in a sent mail. Images that already
|
|
4181
|
+
* carry a size, and template slots, are left alone, so content written by a
|
|
4182
|
+
* current version passes through untouched. Emits one change after the images have
|
|
4183
|
+
* settled rather than one per image, and none at all if nothing needed stamping. */
|
|
4184
|
+
stampExistingImages() {
|
|
4185
|
+
const t = Array.from(this.ed.querySelectorAll("img"));
|
|
4186
|
+
if (!t.length) return;
|
|
4187
|
+
let e = t.length, i = !1;
|
|
4188
|
+
const s = (l) => {
|
|
4189
|
+
l && (i = !0), --e === 0 && i && this.onChange();
|
|
4190
|
+
};
|
|
4191
|
+
t.forEach((l) => this.stampImageSize(l, s));
|
|
3953
4192
|
}
|
|
3954
4193
|
positionImgPhCtx() {
|
|
3955
4194
|
if (this.phActive && !document.body.contains(this.phActive)) {
|
|
@@ -3968,7 +4207,7 @@ const I = class I {
|
|
|
3968
4207
|
this.vidInput.value = "", this.vidInput.click();
|
|
3969
4208
|
}
|
|
3970
4209
|
vidPhHTML(t) {
|
|
3971
|
-
return `<div class="img-ph vid-ph"${t ? ` id="${t}"` : ""} contenteditable="false">${
|
|
4210
|
+
return `<div class="img-ph vid-ph"${t ? ` id="${t}"` : ""} contenteditable="false">${c.video}<span>${this.t("dropvideo")}</span></div>`;
|
|
3972
4211
|
}
|
|
3973
4212
|
insertVideoPlaceholder() {
|
|
3974
4213
|
this.restoreSel();
|
|
@@ -3992,11 +4231,11 @@ const I = class I {
|
|
|
3992
4231
|
var e;
|
|
3993
4232
|
const t = this.vphCtx;
|
|
3994
4233
|
t && (t.innerHTML = "", t.append(
|
|
3995
|
-
this.ctxBtn(
|
|
4234
|
+
this.ctxBtn(c.uploadic, this.t("uploadvideo"), () => {
|
|
3996
4235
|
this.vphUploadTarget = this.vphActive, this.pickVideo();
|
|
3997
4236
|
}),
|
|
3998
|
-
this.ctxBtn(
|
|
3999
|
-
), (e = this.vphActive) != null && e.closest(".tpl-media") && t.append(this.ctxBtn(
|
|
4237
|
+
this.ctxBtn(c.link, this.t("videolink"), () => this.renderVphCtxUrlInput())
|
|
4238
|
+
), (e = this.vphActive) != null && e.closest(".tpl-media") && t.append(this.ctxBtn(c.image, this.t("quickimage"), () => this.swapPlaceholderKind("image"))), t.append(this.ctxSep(), this.ctxBtn(c.trash, this.t("deletevideo"), () => this.removeVphPlaceholder())), this.positionVphCtx());
|
|
4000
4239
|
}
|
|
4001
4240
|
renderVphCtxUrlInput() {
|
|
4002
4241
|
const t = this.vphCtx;
|
|
@@ -4007,20 +4246,20 @@ const I = class I {
|
|
|
4007
4246
|
const i = document.createElement("button");
|
|
4008
4247
|
i.type = "button", i.className = "txtbtn", i.textContent = this.t("insertvideo");
|
|
4009
4248
|
const s = () => {
|
|
4010
|
-
const l = e.value.trim(),
|
|
4011
|
-
if (!
|
|
4249
|
+
const l = e.value.trim(), n = this.vphActive;
|
|
4250
|
+
if (!n) return;
|
|
4012
4251
|
if (!/^(https?:|data:video\/|blob:)/i.test(l)) {
|
|
4013
4252
|
e.classList.add("err"), e.focus();
|
|
4014
4253
|
return;
|
|
4015
4254
|
}
|
|
4016
|
-
const
|
|
4017
|
-
if (
|
|
4018
|
-
this.replacePlaceholderWithEmbed(
|
|
4255
|
+
const o = this.videoEmbedUrl(l);
|
|
4256
|
+
if (o) {
|
|
4257
|
+
this.replacePlaceholderWithEmbed(n, o);
|
|
4019
4258
|
return;
|
|
4020
4259
|
}
|
|
4021
4260
|
i.disabled = !0, e.disabled = !0;
|
|
4022
4261
|
const r = document.createElement("video");
|
|
4023
|
-
r.preload = "metadata", r.onloadedmetadata = () => this.replacePlaceholderWithVideo(
|
|
4262
|
+
r.preload = "metadata", r.onloadedmetadata = () => this.replacePlaceholderWithVideo(n, l, ""), r.onerror = () => {
|
|
4024
4263
|
i.disabled = !1, e.disabled = !1, e.classList.add("err"), e.focus();
|
|
4025
4264
|
}, r.src = l;
|
|
4026
4265
|
};
|
|
@@ -4048,8 +4287,8 @@ const I = class I {
|
|
|
4048
4287
|
s && (s.textContent = this.t("uploading")), this.videoUploadHandler(t).then((l) => {
|
|
4049
4288
|
this.ed.contains(e) && this.replacePlaceholderWithVideo(e, l, i);
|
|
4050
4289
|
}).catch((l) => {
|
|
4051
|
-
var
|
|
4052
|
-
this.ed.contains(e) && (e.classList.remove("uploading"), e.classList.add("upload-error"), s && (s.textContent = this.t("uploadfailed")), (
|
|
4290
|
+
var n;
|
|
4291
|
+
this.ed.contains(e) && (e.classList.remove("uploading"), e.classList.add("upload-error"), s && (s.textContent = this.t("uploadfailed")), (n = this.onVideoUploadError) == null || n.call(this, l, t));
|
|
4053
4292
|
});
|
|
4054
4293
|
}
|
|
4055
4294
|
replacePlaceholderWithVideo(t, e, i) {
|
|
@@ -4088,24 +4327,24 @@ const I = class I {
|
|
|
4088
4327
|
const e = document.createElement("div");
|
|
4089
4328
|
e.className = "imgctx", e.dir = this.dir();
|
|
4090
4329
|
const i = () => {
|
|
4091
|
-
var
|
|
4092
|
-
const
|
|
4093
|
-
(
|
|
4094
|
-
}, s = (
|
|
4095
|
-
this.setVideoAlign(t,
|
|
4096
|
-
}, l = t.style.float === "left",
|
|
4097
|
-
const g = this.ctxBtn(
|
|
4098
|
-
return g.classList.toggle("on",
|
|
4330
|
+
var d;
|
|
4331
|
+
const a = this.buildVideoCtxToolbar(t);
|
|
4332
|
+
(d = this.vidCtx) == null || d.replaceWith(a), this.vidCtx = a, this.positionVidCtx();
|
|
4333
|
+
}, s = (a) => {
|
|
4334
|
+
this.setVideoAlign(t, a), i();
|
|
4335
|
+
}, l = t.style.float === "left", n = t.style.float === "right", o = !l && !n && t.style.marginLeft === "auto" && t.style.marginRight === "auto", r = (a, d, p, u) => {
|
|
4336
|
+
const g = this.ctxBtn(a, d, u);
|
|
4337
|
+
return g.classList.toggle("on", p), g;
|
|
4099
4338
|
};
|
|
4100
4339
|
return e.append(
|
|
4101
|
-
r(
|
|
4102
|
-
r(
|
|
4103
|
-
r(
|
|
4340
|
+
r(c.alignleft, this.t("alignleft"), l, () => s("left")),
|
|
4341
|
+
r(c.aligncenter, this.t("aligncenter"), o, () => s("center")),
|
|
4342
|
+
r(c.alignright, this.t("alignright"), n, () => s("right")),
|
|
4104
4343
|
this.ctxSep(),
|
|
4105
|
-
r(
|
|
4344
|
+
r(c.trash, this.t("deletevideo"), !1, () => {
|
|
4106
4345
|
t.remove(), this.clearVidHandles(), this.onChange();
|
|
4107
4346
|
})
|
|
4108
|
-
), e.addEventListener("mousedown", (
|
|
4347
|
+
), e.addEventListener("mousedown", (a) => a.preventDefault()), e.addEventListener("mouseenter", () => this.cancelVidHide()), e.addEventListener("mouseleave", () => {
|
|
4109
4348
|
this.cancelVidHide(), this.vidHideTimer = window.setTimeout(() => this.clearVidHandles(), 250);
|
|
4110
4349
|
}), document.body.appendChild(e), e;
|
|
4111
4350
|
}
|
|
@@ -4142,68 +4381,68 @@ const I = class I {
|
|
|
4142
4381
|
* (videoUploadHandler when configured, else inline base64). */
|
|
4143
4382
|
videoDlg() {
|
|
4144
4383
|
this.saveSel();
|
|
4145
|
-
let t, e, i, s, l,
|
|
4146
|
-
const
|
|
4147
|
-
const
|
|
4148
|
-
|
|
4149
|
-
const
|
|
4150
|
-
return
|
|
4384
|
+
let t, e, i, s, l, n;
|
|
4385
|
+
const o = (a, d) => {
|
|
4386
|
+
const p = document.createElement("div");
|
|
4387
|
+
p.className = "dfield";
|
|
4388
|
+
const u = document.createElement("label");
|
|
4389
|
+
return u.textContent = this.t(a), p.append(u, d), p;
|
|
4151
4390
|
}, r = () => {
|
|
4152
|
-
const
|
|
4153
|
-
return
|
|
4391
|
+
const a = document.createElement("input");
|
|
4392
|
+
return a.type = "url", a;
|
|
4154
4393
|
};
|
|
4155
4394
|
this.dialog(
|
|
4156
4395
|
this.t("videodlgttl"),
|
|
4157
|
-
(
|
|
4158
|
-
const
|
|
4159
|
-
|
|
4160
|
-
const
|
|
4161
|
-
const
|
|
4162
|
-
|
|
4396
|
+
(a) => {
|
|
4397
|
+
const d = document.createElement("div");
|
|
4398
|
+
d.className = "dtabs";
|
|
4399
|
+
const p = [], u = (f, b) => {
|
|
4400
|
+
const y = document.createElement("button");
|
|
4401
|
+
y.type = "button", y.textContent = this.t(f);
|
|
4163
4402
|
const C = document.createElement("div");
|
|
4164
4403
|
C.className = "dtabpanel", b(C);
|
|
4165
|
-
const
|
|
4166
|
-
|
|
4167
|
-
}, g = (
|
|
4168
|
-
|
|
4404
|
+
const S = p.length;
|
|
4405
|
+
p.push(C), y.addEventListener("click", () => g(S)), d.appendChild(y);
|
|
4406
|
+
}, g = (f) => {
|
|
4407
|
+
d.querySelectorAll("button").forEach((b, y) => b.classList.toggle("on", y === f)), p.forEach((b, y) => b.style.display = y === f ? "" : "none");
|
|
4169
4408
|
};
|
|
4170
|
-
|
|
4409
|
+
u("vidgeneral", (f) => {
|
|
4171
4410
|
t = r(), t.placeholder = this.t("videourlph");
|
|
4172
4411
|
const b = document.createElement("div");
|
|
4173
4412
|
b.className = "drow";
|
|
4174
|
-
const
|
|
4175
|
-
|
|
4413
|
+
const y = document.createElement("button");
|
|
4414
|
+
y.type = "button", y.className = "txtbtn", y.textContent = this.t("uploadvideo");
|
|
4176
4415
|
const C = document.createElement("input");
|
|
4177
|
-
C.type = "file", C.accept = this.options.videoFileTypes.join(","), C.style.display = "none",
|
|
4416
|
+
C.type = "file", C.accept = this.options.videoFileTypes.join(","), C.style.display = "none", y.addEventListener("click", () => {
|
|
4178
4417
|
C.value = "", C.click();
|
|
4179
4418
|
}), C.addEventListener("change", () => {
|
|
4180
4419
|
var L;
|
|
4181
4420
|
const w = (L = C.files) == null ? void 0 : L[0];
|
|
4182
4421
|
if (!w) return;
|
|
4183
|
-
|
|
4184
|
-
const
|
|
4185
|
-
t.value =
|
|
4422
|
+
y.disabled = !0, y.textContent = this.t("uploading");
|
|
4423
|
+
const k = (H) => {
|
|
4424
|
+
t.value = H, y.disabled = !1, y.textContent = this.t("uploadvideo");
|
|
4186
4425
|
};
|
|
4187
4426
|
if (this.videoUploadHandler)
|
|
4188
|
-
this.videoUploadHandler(w).then(
|
|
4189
|
-
var
|
|
4190
|
-
|
|
4427
|
+
this.videoUploadHandler(w).then(k).catch((H) => {
|
|
4428
|
+
var U;
|
|
4429
|
+
y.disabled = !1, y.textContent = this.t("uploadfailed"), (U = this.onVideoUploadError) == null || U.call(this, H, w);
|
|
4191
4430
|
});
|
|
4192
4431
|
else {
|
|
4193
|
-
const
|
|
4194
|
-
|
|
4432
|
+
const H = new FileReader();
|
|
4433
|
+
H.onload = () => k(H.result), H.readAsDataURL(w);
|
|
4195
4434
|
}
|
|
4196
|
-
}), b.append(t,
|
|
4197
|
-
const
|
|
4198
|
-
|
|
4199
|
-
}),
|
|
4435
|
+
}), b.append(t, y, C), t.style.flex = "1", f.appendChild(o("vidsource", b));
|
|
4436
|
+
const S = document.createElement("div");
|
|
4437
|
+
S.className = "drow", e = document.createElement("input"), e.type = "number", e.value = "560", i = document.createElement("input"), i.type = "number", i.value = "314", S.append(o("tblwidth", e), o("tblheight", i)), f.appendChild(S);
|
|
4438
|
+
}), u("vidembed", (f) => {
|
|
4200
4439
|
const b = document.createElement("p");
|
|
4201
|
-
b.textContent = this.t("vidembedhint"), b.style.cssText = "margin:0 0 8px;color:#556;font-size:13.5px", s = document.createElement("textarea"), s.style.cssText = "width:100%;box-sizing:border-box;height:160px",
|
|
4202
|
-
}),
|
|
4203
|
-
l = r(),
|
|
4440
|
+
b.textContent = this.t("vidembedhint"), b.style.cssText = "margin:0 0 8px;color:#556;font-size:13.5px", s = document.createElement("textarea"), s.style.cssText = "width:100%;box-sizing:border-box;height:160px", f.append(b, s);
|
|
4441
|
+
}), u("vidadvanced", (f) => {
|
|
4442
|
+
l = r(), n = r(), f.append(o("vidaltsource", l), o("vidposter", n));
|
|
4204
4443
|
});
|
|
4205
|
-
const
|
|
4206
|
-
|
|
4444
|
+
const m = document.createElement("div");
|
|
4445
|
+
m.className = "dtabbody", p.forEach((f) => m.appendChild(f)), a.append(d, m), g(0), setTimeout(() => t.focus(), 0);
|
|
4207
4446
|
},
|
|
4208
4447
|
[
|
|
4209
4448
|
{ label: this.t("cancel"), action: () => this.closeDlg() },
|
|
@@ -4211,21 +4450,21 @@ const I = class I {
|
|
|
4211
4450
|
label: this.t("save"),
|
|
4212
4451
|
primary: !0,
|
|
4213
4452
|
action: () => {
|
|
4214
|
-
const
|
|
4215
|
-
if (this.closeDlg(), !
|
|
4216
|
-
if (this.restoreSel(),
|
|
4217
|
-
document.execCommand("insertHTML", !1, `<span class="video-embed" contenteditable="false">${
|
|
4453
|
+
const a = s.value.trim(), d = t.value.trim(), p = parseInt(e.value, 10) || 560, u = parseInt(i.value, 10) || 314;
|
|
4454
|
+
if (this.closeDlg(), !a && !d) return;
|
|
4455
|
+
if (this.restoreSel(), a) {
|
|
4456
|
+
document.execCommand("insertHTML", !1, `<span class="video-embed" contenteditable="false">${a}</span>`), this.onChange();
|
|
4218
4457
|
return;
|
|
4219
4458
|
}
|
|
4220
|
-
const g = this.videoEmbedUrl(
|
|
4459
|
+
const g = this.videoEmbedUrl(d);
|
|
4221
4460
|
if (g)
|
|
4222
|
-
document.execCommand("insertHTML", !1, this.videoEmbedHTML(g,
|
|
4461
|
+
document.execCommand("insertHTML", !1, this.videoEmbedHTML(g, p, u));
|
|
4223
4462
|
else {
|
|
4224
|
-
const
|
|
4463
|
+
const m = l.value.trim(), f = n.value.trim();
|
|
4225
4464
|
document.execCommand(
|
|
4226
4465
|
"insertHTML",
|
|
4227
4466
|
!1,
|
|
4228
|
-
`<video controls width="${
|
|
4467
|
+
`<video controls width="${p}" height="${u}"${f ? ` poster="${this.escapeAttr(f)}"` : ""}><source src="${this.escapeAttr(d)}">${m ? `<source src="${this.escapeAttr(m)}">` : ""}</video>`
|
|
4229
4468
|
);
|
|
4230
4469
|
}
|
|
4231
4470
|
this.onChange();
|
|
@@ -4276,22 +4515,22 @@ const I = class I {
|
|
|
4276
4515
|
/** Typing `snippet` converts to an inline <code> run the moment the closing
|
|
4277
4516
|
* backtick is typed, so code can be marked up without reaching for the toolbar. */
|
|
4278
4517
|
tryCodeTyping(t) {
|
|
4279
|
-
var
|
|
4518
|
+
var d;
|
|
4280
4519
|
const e = window.getSelection();
|
|
4281
4520
|
if (!e || !e.isCollapsed || !e.anchorNode) return;
|
|
4282
4521
|
const i = e.anchorNode;
|
|
4283
|
-
if (i.nodeType !== Node.TEXT_NODE || !this.ed.contains(i) || (
|
|
4522
|
+
if (i.nodeType !== Node.TEXT_NODE || !this.ed.contains(i) || (d = i.parentElement) != null && d.closest("code, pre")) return;
|
|
4284
4523
|
const l = (i.textContent || "").slice(0, e.anchorOffset).match(/(?:^|[^`])`([^`]+)$/);
|
|
4285
4524
|
if (!l) return;
|
|
4286
|
-
const
|
|
4287
|
-
if (/^\s|\s$/.test(
|
|
4525
|
+
const n = l[1];
|
|
4526
|
+
if (/^\s|\s$/.test(n)) return;
|
|
4288
4527
|
t.preventDefault();
|
|
4289
|
-
const
|
|
4290
|
-
|
|
4528
|
+
const o = document.createRange();
|
|
4529
|
+
o.setStart(i, e.anchorOffset - n.length - 1), o.setEnd(i, e.anchorOffset), o.deleteContents();
|
|
4291
4530
|
const r = document.createElement("code");
|
|
4292
|
-
r.textContent =
|
|
4293
|
-
const
|
|
4294
|
-
|
|
4531
|
+
r.textContent = n, o.insertNode(r);
|
|
4532
|
+
const a = document.createRange();
|
|
4533
|
+
a.setStartAfter(r), a.collapse(!0), e.removeAllRanges(), e.addRange(a), this.saveSel(), this.onChange();
|
|
4295
4534
|
}
|
|
4296
4535
|
/** Custom dropdown for dialog fields (a native <select> popup can't be styled):
|
|
4297
4536
|
* a field-styled button showing the current choice that opens a floating,
|
|
@@ -4303,22 +4542,22 @@ const I = class I {
|
|
|
4303
4542
|
s.className = "dsel";
|
|
4304
4543
|
const l = document.createElement("button");
|
|
4305
4544
|
l.type = "button", l.className = "dsel-btn";
|
|
4306
|
-
const
|
|
4307
|
-
|
|
4308
|
-
const
|
|
4309
|
-
return
|
|
4310
|
-
const
|
|
4311
|
-
|
|
4312
|
-
i =
|
|
4313
|
-
}),
|
|
4545
|
+
const n = document.createElement("span");
|
|
4546
|
+
n.className = "lbl", n.textContent = ((r = t.find(([a]) => a === e)) == null ? void 0 : r[1]) || "", l.append(n), l.insertAdjacentHTML("beforeend", c.chev);
|
|
4547
|
+
const o = document.createElement("div");
|
|
4548
|
+
return o.className = "dsel-list", t.forEach(([a, d]) => {
|
|
4549
|
+
const p = document.createElement("button");
|
|
4550
|
+
p.type = "button", p.textContent = d, p.classList.toggle("on", a === i), p.addEventListener("click", () => {
|
|
4551
|
+
i = a, n.textContent = d, o.querySelectorAll("button").forEach((u) => u.classList.toggle("on", u === p)), s.classList.remove("open"), l.focus();
|
|
4552
|
+
}), o.appendChild(p);
|
|
4314
4553
|
}), l.addEventListener("click", () => {
|
|
4315
|
-
var
|
|
4316
|
-
s.classList.toggle("open"), s.classList.contains("open") && ((
|
|
4317
|
-
}), s.addEventListener("focusout", (
|
|
4318
|
-
s.contains(
|
|
4319
|
-
}), s.addEventListener("keydown", (
|
|
4320
|
-
|
|
4321
|
-
}), s.append(l,
|
|
4554
|
+
var a;
|
|
4555
|
+
s.classList.toggle("open"), s.classList.contains("open") && ((a = o.querySelector(".on")) == null || a.scrollIntoView({ block: "nearest" }));
|
|
4556
|
+
}), s.addEventListener("focusout", (a) => {
|
|
4557
|
+
s.contains(a.relatedTarget) || s.classList.remove("open");
|
|
4558
|
+
}), s.addEventListener("keydown", (a) => {
|
|
4559
|
+
a.key === "Escape" && s.classList.contains("open") && (a.stopPropagation(), s.classList.remove("open"), l.focus());
|
|
4560
|
+
}), s.append(l, o), { el: s, value: () => i };
|
|
4322
4561
|
}
|
|
4323
4562
|
/** Insert/edit-code-sample dialog: language dropdown + monospace textarea to
|
|
4324
4563
|
* paste or type code into. Inserts a non-editable <pre class="code-block">
|
|
@@ -4329,11 +4568,11 @@ const I = class I {
|
|
|
4329
4568
|
this.dialog(
|
|
4330
4569
|
this.t("codedlgttl"),
|
|
4331
4570
|
(s) => {
|
|
4332
|
-
var
|
|
4571
|
+
var o;
|
|
4333
4572
|
const l = document.createElement("div");
|
|
4334
4573
|
l.className = "dfield";
|
|
4335
|
-
const
|
|
4336
|
-
|
|
4574
|
+
const n = document.createElement("label");
|
|
4575
|
+
n.textContent = this.t("codelang"), e = this.dlgSelect(X, (t == null ? void 0 : t.dataset.lang) || "plain"), l.append(n, e.el), i = document.createElement("textarea"), i.className = "code-input", i.spellcheck = !1, i.value = ((o = t == null ? void 0 : t.querySelector("code")) == null ? void 0 : o.textContent) || "", i.placeholder = "const answer = 42;", s.append(l, i), setTimeout(() => i.focus(), 0);
|
|
4337
4576
|
},
|
|
4338
4577
|
[
|
|
4339
4578
|
{ label: this.t("cancel"), action: () => this.closeDlg() },
|
|
@@ -4341,11 +4580,11 @@ const I = class I {
|
|
|
4341
4580
|
label: this.t("save"),
|
|
4342
4581
|
primary: !0,
|
|
4343
4582
|
action: () => {
|
|
4344
|
-
var
|
|
4345
|
-
const s = i.value.replace(/\s+$/, ""), l = e.value(),
|
|
4583
|
+
var o;
|
|
4584
|
+
const s = i.value.replace(/\s+$/, ""), l = e.value(), n = ((o = X.find(([r]) => r === l)) == null ? void 0 : o[1]) || l;
|
|
4346
4585
|
if (this.closeDlg(), !!s.trim()) {
|
|
4347
4586
|
if (t) {
|
|
4348
|
-
t.dataset.lang = l, t.setAttribute("data-lang-label",
|
|
4587
|
+
t.dataset.lang = l, t.setAttribute("data-lang-label", n);
|
|
4349
4588
|
const r = t.querySelector("code") || t;
|
|
4350
4589
|
r.textContent = s, this.clearCodeSel(), this.onChange();
|
|
4351
4590
|
return;
|
|
@@ -4353,7 +4592,7 @@ const I = class I {
|
|
|
4353
4592
|
this.restoreSel(), document.execCommand(
|
|
4354
4593
|
"insertHTML",
|
|
4355
4594
|
!1,
|
|
4356
|
-
`<pre class="code-block" contenteditable="false" data-lang="${l}" data-lang-label="${this.escapeAttr(
|
|
4595
|
+
`<pre class="code-block" contenteditable="false" data-lang="${l}" data-lang-label="${this.escapeAttr(n)}"><code>${this.escHtml(s)}</code></pre><p><br></p>`
|
|
4357
4596
|
), this.onChange();
|
|
4358
4597
|
}
|
|
4359
4598
|
}
|
|
@@ -4371,10 +4610,10 @@ const I = class I {
|
|
|
4371
4610
|
buildCodeCtxToolbar(t) {
|
|
4372
4611
|
const e = document.createElement("div");
|
|
4373
4612
|
return e.className = "imgctx", e.dir = this.dir(), e.append(
|
|
4374
|
-
this.ctxBtn(
|
|
4375
|
-
this.ctxBtn(
|
|
4613
|
+
this.ctxBtn(c.editic, this.t("editcode"), () => this.codeDlg(t)),
|
|
4614
|
+
this.ctxBtn(c.copyic, this.t("copycode"), () => this.copyCodeBlock(t)),
|
|
4376
4615
|
this.ctxSep(),
|
|
4377
|
-
this.ctxBtn(
|
|
4616
|
+
this.ctxBtn(c.trash, this.t("deletecode"), () => {
|
|
4378
4617
|
t.remove(), this.clearCodeSel(), this.onChange();
|
|
4379
4618
|
})
|
|
4380
4619
|
), e.addEventListener("mousedown", (i) => i.preventDefault()), document.body.appendChild(e), e;
|
|
@@ -4410,14 +4649,14 @@ const I = class I {
|
|
|
4410
4649
|
/** Miniature div-based mockup of a layout, mirroring what the block looks
|
|
4411
4650
|
like in the editor: grey box = image slot, bars = heading/paragraph. */
|
|
4412
4651
|
tplPreviewHTML(t) {
|
|
4413
|
-
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>`,
|
|
4414
|
-
return t === "img-left" ? `<span class="pv">${
|
|
4652
|
+
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));
|
|
4653
|
+
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>`;
|
|
4415
4654
|
}
|
|
4416
4655
|
buildTemplatePickInto(t, e) {
|
|
4417
4656
|
const i = document.createElement("div");
|
|
4418
|
-
i.className = "tplpick",
|
|
4657
|
+
i.className = "tplpick", $.forEach((s) => {
|
|
4419
4658
|
const l = document.createElement("button");
|
|
4420
|
-
l.type = "button", l.className = "tpltile", l.title = this.t(
|
|
4659
|
+
l.type = "button", l.className = "tpltile", l.title = this.t(_[s]), l.innerHTML = this.tplPreviewHTML(s) + `<span class="tpllbl">${this.t(_[s])}</span>`, l.addEventListener("click", () => {
|
|
4421
4660
|
this.closePop(), this.insertTemplate(s), e == null || e();
|
|
4422
4661
|
}), i.appendChild(l);
|
|
4423
4662
|
}), t.appendChild(i);
|
|
@@ -4436,15 +4675,15 @@ const I = class I {
|
|
|
4436
4675
|
}
|
|
4437
4676
|
renderTplCtxButtons() {
|
|
4438
4677
|
const t = this.tplCtx, e = this.tplActive;
|
|
4439
|
-
!t || !e || (t.innerHTML = "",
|
|
4440
|
-
const s = this.ctxBtn(
|
|
4678
|
+
!t || !e || (t.innerHTML = "", $.forEach((i) => {
|
|
4679
|
+
const s = this.ctxBtn(jt[i], this.t(_[i]), () => this.setTplLayout(i));
|
|
4441
4680
|
s.classList.toggle("on", e.classList.contains("tpl-" + i)), t.appendChild(s);
|
|
4442
|
-
}), t.append(this.ctxSep(), this.ctxBtn(
|
|
4681
|
+
}), t.append(this.ctxSep(), this.ctxBtn(c.trash, this.t("deltemplate"), () => this.removeTemplate())), this.positionTplCtx());
|
|
4443
4682
|
}
|
|
4444
4683
|
setTplLayout(t) {
|
|
4445
4684
|
const e = this.tplActive;
|
|
4446
4685
|
if (!e) return;
|
|
4447
|
-
|
|
4686
|
+
$.forEach((l) => e.classList.remove("tpl-" + l)), e.classList.add("tpl-" + t);
|
|
4448
4687
|
const i = e.querySelector(":scope > .tpl-media"), s = e.querySelector(":scope > .tpl-text");
|
|
4449
4688
|
i && s && (t === "img-center" ? e.appendChild(i) : e.insertBefore(i, s)), this.renderTplCtxButtons(), this.positionImgPhCtx(), this.positionImageHandles(), this.onChange();
|
|
4450
4689
|
}
|
|
@@ -4476,7 +4715,7 @@ const I = class I {
|
|
|
4476
4715
|
/* ---------------------------------------------------------- table resize */
|
|
4477
4716
|
clearTableHandles() {
|
|
4478
4717
|
var t, e, i, s, l;
|
|
4479
|
-
(t = this.tblCorner) == null || t.remove(), this.tblCorner = null, this.tblColBars.forEach((
|
|
4718
|
+
(t = this.tblCorner) == null || t.remove(), this.tblCorner = null, this.tblColBars.forEach((n) => n.remove()), this.tblColBars = [], (e = this.tblCtx) == null || e.remove(), this.tblCtx = null, (i = this.tblCellMark) == null || i.remove(), this.tblCellMark = null, (s = this.tblOpMark) == null || s.remove(), this.tblOpMark = null, this.tblOpMarkKind = null, (l = this.tblActive) == null || l.classList.remove("tbl-selected"), this.tblActive = null;
|
|
4480
4719
|
}
|
|
4481
4720
|
/** Blue outline around the cell that holds the caret, so it is clear
|
|
4482
4721
|
which cell / row / column the table operations will target. */
|
|
@@ -4496,15 +4735,15 @@ const I = class I {
|
|
|
4496
4735
|
this.tblOpMarkKind = t, this.positionOpMark();
|
|
4497
4736
|
}
|
|
4498
4737
|
positionOpMark() {
|
|
4499
|
-
var
|
|
4738
|
+
var d;
|
|
4500
4739
|
const t = this.tblOpMarkKind, e = t ? this.currentCell() : null;
|
|
4501
4740
|
if (!t || !e || !this.tblActive || e.closest("table") !== this.tblActive) {
|
|
4502
|
-
(
|
|
4741
|
+
(d = this.tblOpMark) == null || d.remove(), this.tblOpMark = null;
|
|
4503
4742
|
return;
|
|
4504
4743
|
}
|
|
4505
4744
|
this.tblOpMark || (this.tblOpMark = document.createElement("div"), this.tblOpMark.className = "tbl-opmark", document.body.appendChild(this.tblOpMark));
|
|
4506
|
-
const i = this.tblActive.getBoundingClientRect(), s = e.getBoundingClientRect(), l = e.parentElement.getBoundingClientRect(),
|
|
4507
|
-
this.tblOpMark.style.left =
|
|
4745
|
+
const i = this.tblActive.getBoundingClientRect(), s = e.getBoundingClientRect(), l = e.parentElement.getBoundingClientRect(), n = t === "row" ? l.left : s.left, o = t === "row" ? l.top : i.top, r = t === "row" ? l.width : s.width, a = t === "row" ? l.height : i.height;
|
|
4746
|
+
this.tblOpMark.style.left = n + scrollX + "px", this.tblOpMark.style.top = o + scrollY + "px", this.tblOpMark.style.width = r + "px", this.tblOpMark.style.height = a + "px";
|
|
4508
4747
|
}
|
|
4509
4748
|
/** Lowest allowed top for floating context toolbars — keeps them from
|
|
4510
4749
|
covering the editor menubar/toolbar when the target sits on the first line. */
|
|
@@ -4513,7 +4752,7 @@ const I = class I {
|
|
|
4513
4752
|
}
|
|
4514
4753
|
ctxBtn(t, e, i, s) {
|
|
4515
4754
|
const l = document.createElement("button");
|
|
4516
|
-
return l.type = "button", l.title = e, l.innerHTML = t, s && (l.dataset.id = s), l.addEventListener("mousedown", (
|
|
4755
|
+
return l.type = "button", l.title = e, l.innerHTML = t, s && (l.dataset.id = s), l.addEventListener("mousedown", (n) => n.preventDefault()), l.addEventListener("click", i), l;
|
|
4517
4756
|
}
|
|
4518
4757
|
ctxSep() {
|
|
4519
4758
|
const t = document.createElement("div");
|
|
@@ -4522,27 +4761,27 @@ const I = class I {
|
|
|
4522
4761
|
buildTableCtxToolbar() {
|
|
4523
4762
|
const t = document.createElement("div");
|
|
4524
4763
|
t.className = "tblctx", t.dir = this.dir();
|
|
4525
|
-
const e = (s, l) => (s.addEventListener("mouseenter", () => this.setOpTarget(l)), s.addEventListener("mouseleave", () => this.setOpTarget(null)), s), i = this.ctxBtn(
|
|
4764
|
+
const e = (s, l) => (s.addEventListener("mouseenter", () => this.setOpTarget(l)), s.addEventListener("mouseleave", () => this.setOpTarget(null)), s), i = this.ctxBtn(c.palette, this.t("cellbg"), () => this.cellFillMenu(i));
|
|
4526
4765
|
return t.append(
|
|
4527
|
-
e(this.ctxBtn(
|
|
4528
|
-
e(this.ctxBtn(
|
|
4529
|
-
e(this.ctxBtn(
|
|
4530
|
-
e(this.ctxBtn(
|
|
4531
|
-
e(this.ctxBtn(
|
|
4766
|
+
e(this.ctxBtn(c.rowbefore, this.t("rowabove"), () => this.tableOp("rowabove")), "row"),
|
|
4767
|
+
e(this.ctxBtn(c.rowafter, this.t("rowbelow"), () => this.tableOp("rowbelow")), "row"),
|
|
4768
|
+
e(this.ctxBtn(c.moverowup, this.t("moverowup"), () => this.tableMove("rowup")), "row"),
|
|
4769
|
+
e(this.ctxBtn(c.moverowdown, this.t("moverowdown"), () => this.tableMove("rowdown")), "row"),
|
|
4770
|
+
e(this.ctxBtn(c.rowdelete, this.t("delrow"), () => this.tableOp("delrow")), "row"),
|
|
4532
4771
|
this.ctxSep(),
|
|
4533
|
-
e(this.ctxBtn(
|
|
4534
|
-
e(this.ctxBtn(
|
|
4535
|
-
e(this.ctxBtn(
|
|
4536
|
-
e(this.ctxBtn(
|
|
4537
|
-
e(this.ctxBtn(
|
|
4772
|
+
e(this.ctxBtn(c.colbefore, this.t("colbefore"), () => this.tableOp("colbefore")), "col"),
|
|
4773
|
+
e(this.ctxBtn(c.colafter, this.t("colafter"), () => this.tableOp("colafter")), "col"),
|
|
4774
|
+
e(this.ctxBtn(c.movecolleft, this.t("movecolleft"), () => this.tableMove("colleft")), "col"),
|
|
4775
|
+
e(this.ctxBtn(c.movecolright, this.t("movecolright"), () => this.tableMove("colright")), "col"),
|
|
4776
|
+
e(this.ctxBtn(c.coldelete, this.t("delcol"), () => this.tableOp("delcol")), "col"),
|
|
4538
4777
|
this.ctxSep(),
|
|
4539
|
-
this.ctxBtn(
|
|
4540
|
-
this.ctxBtn(
|
|
4541
|
-
this.ctxBtn(
|
|
4778
|
+
this.ctxBtn(c.alignleft, this.t("tblalignleft"), () => this.alignTable("left")),
|
|
4779
|
+
this.ctxBtn(c.aligncenter, this.t("tblaligncenter"), () => this.alignTable("center")),
|
|
4780
|
+
this.ctxBtn(c.alignright, this.t("tblalignright"), () => this.alignTable("right")),
|
|
4542
4781
|
this.ctxSep(),
|
|
4543
4782
|
i,
|
|
4544
|
-
this.ctxBtn(
|
|
4545
|
-
this.ctxBtn(
|
|
4783
|
+
this.ctxBtn(c.trash, this.t("deltable"), () => this.tableOp("deltable")),
|
|
4784
|
+
this.ctxBtn(c.tableic, this.t("tablepropsttl"), () => this.tablePropsDlg())
|
|
4546
4785
|
), document.body.appendChild(t), t;
|
|
4547
4786
|
}
|
|
4548
4787
|
positionTableHandles() {
|
|
@@ -4550,20 +4789,20 @@ const I = class I {
|
|
|
4550
4789
|
this.clearTableHandles();
|
|
4551
4790
|
return;
|
|
4552
4791
|
}
|
|
4553
|
-
const t = this.ed.getAttribute("dir") === "rtl", e = this.tblActive.getBoundingClientRect(), i = e.top + scrollY, s = e.left + scrollX, l = e.right + scrollX,
|
|
4554
|
-
if (this.tblCorner && (this.tblCorner.style.top =
|
|
4555
|
-
const r = this.tblCtx.offsetWidth,
|
|
4556
|
-
let
|
|
4557
|
-
|
|
4558
|
-
let
|
|
4559
|
-
|
|
4792
|
+
const t = this.ed.getAttribute("dir") === "rtl", e = this.tblActive.getBoundingClientRect(), i = e.top + scrollY, s = e.left + scrollX, l = e.right + scrollX, n = e.bottom + scrollY;
|
|
4793
|
+
if (this.tblCorner && (this.tblCorner.style.top = n - 5 + "px", this.tblCorner.style.left = (t ? s - 5 : l - 5) + "px", this.tblCorner.style.cursor = t ? "nesw-resize" : "nwse-resize"), this.tblCtx) {
|
|
4794
|
+
const r = this.tblCtx.offsetWidth, a = this.tblCtx.offsetHeight;
|
|
4795
|
+
let d = s + (l - s) / 2 - r / 2;
|
|
4796
|
+
d = Math.max(8 + scrollX, Math.min(d, scrollX + innerWidth - r - 8));
|
|
4797
|
+
let p = i - a - 8;
|
|
4798
|
+
p < this.ctxMinTop() && (p = n + 8), this.tblCtx.style.left = d + "px", this.tblCtx.style.top = p + "px";
|
|
4560
4799
|
}
|
|
4561
4800
|
this.tblColBars.forEach((r) => r.remove()), this.tblColBars = [];
|
|
4562
|
-
const
|
|
4563
|
-
if (
|
|
4564
|
-
for (let r = 0; r <
|
|
4565
|
-
const
|
|
4566
|
-
|
|
4801
|
+
const o = this.tblActive.rows[0];
|
|
4802
|
+
if (o)
|
|
4803
|
+
for (let r = 0; r < o.cells.length - 1; r++) {
|
|
4804
|
+
const a = o.cells[r].getBoundingClientRect(), d = (t ? a.left : a.right) + scrollX, p = document.createElement("div");
|
|
4805
|
+
p.className = "tbl-colbar", p.style.top = i + "px", p.style.left = d + "px", p.style.height = n - i + "px", document.body.appendChild(p), p.addEventListener("mousedown", (u) => this.startColBarDrag(u, r)), this.tblColBars.push(p);
|
|
4567
4806
|
}
|
|
4568
4807
|
this.positionCellMarker(), this.positionOpMark();
|
|
4569
4808
|
}
|
|
@@ -4581,31 +4820,31 @@ const I = class I {
|
|
|
4581
4820
|
const e = this.tblActive;
|
|
4582
4821
|
if (!e) return;
|
|
4583
4822
|
const i = this.ed.getAttribute("dir") === "rtl", s = t.clientX, l = e.getBoundingClientRect().width;
|
|
4584
|
-
e.style.tableLayout = e.style.tableLayout || "fixed", this.withNoTextSelect((
|
|
4585
|
-
const
|
|
4586
|
-
const
|
|
4587
|
-
e.style.width = Math.max(60, Math.round(l +
|
|
4823
|
+
e.style.tableLayout = e.style.tableLayout || "fixed", this.withNoTextSelect((n) => {
|
|
4824
|
+
const o = (a) => {
|
|
4825
|
+
const d = i ? -(a.clientX - s) : a.clientX - s;
|
|
4826
|
+
e.style.width = Math.max(60, Math.round(l + d)) + "px", this.positionTableHandles();
|
|
4588
4827
|
}, r = () => {
|
|
4589
|
-
window.removeEventListener("mousemove",
|
|
4828
|
+
window.removeEventListener("mousemove", o), window.removeEventListener("mouseup", r), n(), this.onChange();
|
|
4590
4829
|
};
|
|
4591
|
-
window.addEventListener("mousemove",
|
|
4830
|
+
window.addEventListener("mousemove", o), window.addEventListener("mouseup", r);
|
|
4592
4831
|
});
|
|
4593
4832
|
}
|
|
4594
4833
|
startColBarDrag(t, e) {
|
|
4595
4834
|
t.preventDefault(), t.stopPropagation();
|
|
4596
4835
|
const i = this.tblActive;
|
|
4597
4836
|
if (!i) return;
|
|
4598
|
-
const s = this.ed.getAttribute("dir") === "rtl", l = Array.from(i.rows),
|
|
4599
|
-
if (!
|
|
4600
|
-
const r = t.clientX,
|
|
4601
|
-
i.style.tableLayout = "fixed", this.withNoTextSelect((
|
|
4602
|
-
const
|
|
4603
|
-
const
|
|
4604
|
-
|
|
4837
|
+
const s = this.ed.getAttribute("dir") === "rtl", l = Array.from(i.rows), n = l.map((p) => p.cells[e]).filter(Boolean), o = l.map((p) => p.cells[e + 1]).filter(Boolean);
|
|
4838
|
+
if (!n.length || !o.length) return;
|
|
4839
|
+
const r = t.clientX, a = n[0].getBoundingClientRect().width, d = o[0].getBoundingClientRect().width;
|
|
4840
|
+
i.style.tableLayout = "fixed", this.withNoTextSelect((p) => {
|
|
4841
|
+
const u = (m) => {
|
|
4842
|
+
const f = (s ? -1 : 1) * (m.clientX - r);
|
|
4843
|
+
n.forEach((b) => b.style.width = Math.max(24, Math.round(a + f)) + "px"), o.forEach((b) => b.style.width = Math.max(24, Math.round(d - f)) + "px"), this.positionTableHandles();
|
|
4605
4844
|
}, g = () => {
|
|
4606
|
-
window.removeEventListener("mousemove",
|
|
4845
|
+
window.removeEventListener("mousemove", u), window.removeEventListener("mouseup", g), p(), this.onChange();
|
|
4607
4846
|
};
|
|
4608
|
-
window.addEventListener("mousemove",
|
|
4847
|
+
window.addEventListener("mousemove", u), window.addEventListener("mouseup", g);
|
|
4609
4848
|
});
|
|
4610
4849
|
}
|
|
4611
4850
|
/* ---------------------------------------------------------- image toolbar / resize */
|
|
@@ -4620,7 +4859,7 @@ const I = class I {
|
|
|
4620
4859
|
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;
|
|
4621
4860
|
}
|
|
4622
4861
|
selectImage(t) {
|
|
4623
|
-
this.imgActive !== t && (this.clearImageHandles(), this.imgActive = t, t.classList.add("img-selected"), this.imgHandles =
|
|
4862
|
+
this.imgActive !== t && (this.clearImageHandles(), this.imgActive = t, t.classList.add("img-selected"), this.imgHandles = Vt.map((e) => {
|
|
4624
4863
|
const i = document.createElement("div");
|
|
4625
4864
|
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;
|
|
4626
4865
|
}), this.imgCtx = this.buildImageCtxToolbar(t), this.positionImageHandles());
|
|
@@ -4629,39 +4868,39 @@ const I = class I {
|
|
|
4629
4868
|
const e = document.createElement("div");
|
|
4630
4869
|
e.className = "imgctx", e.dir = this.dir();
|
|
4631
4870
|
const i = () => {
|
|
4632
|
-
var
|
|
4633
|
-
const
|
|
4634
|
-
(
|
|
4635
|
-
}, s = (
|
|
4636
|
-
this.setImageAlign(t,
|
|
4637
|
-
}, l = t.style.float === "left",
|
|
4638
|
-
const g = this.ctxBtn(
|
|
4639
|
-
return g.classList.toggle("on",
|
|
4871
|
+
var d;
|
|
4872
|
+
const a = this.buildImageCtxToolbar(t);
|
|
4873
|
+
(d = this.imgCtx) == null || d.replaceWith(a), this.imgCtx = a, this.positionImageHandles();
|
|
4874
|
+
}, s = (a) => {
|
|
4875
|
+
this.setImageAlign(t, a), i();
|
|
4876
|
+
}, l = t.style.float === "left", n = t.style.float === "right", o = !l && !n && t.style.marginLeft === "auto" && t.style.marginRight === "auto", r = (a, d, p, u) => {
|
|
4877
|
+
const g = this.ctxBtn(a, d, u);
|
|
4878
|
+
return g.classList.toggle("on", p), g;
|
|
4640
4879
|
};
|
|
4641
4880
|
return e.append(
|
|
4642
|
-
r(
|
|
4643
|
-
r(
|
|
4644
|
-
r(
|
|
4881
|
+
r(c.alignleft, this.t("alignleft"), l, () => s("left")),
|
|
4882
|
+
r(c.aligncenter, this.t("aligncenter"), o, () => s("center")),
|
|
4883
|
+
r(c.alignright, this.t("alignright"), n, () => s("right")),
|
|
4645
4884
|
this.ctxSep(),
|
|
4646
|
-
r(
|
|
4885
|
+
r(c.rotateleft, this.t("rotateleft"), !1, () => {
|
|
4647
4886
|
this.rotateImage(t, -90), i();
|
|
4648
4887
|
}),
|
|
4649
|
-
r(
|
|
4888
|
+
r(c.rotateright, this.t("rotateright"), !1, () => {
|
|
4650
4889
|
this.rotateImage(t, 90), i();
|
|
4651
4890
|
}),
|
|
4652
4891
|
this.ctxSep(),
|
|
4653
|
-
r(
|
|
4892
|
+
r(c.fliphorizontal, this.t("fliphorizontal"), t.dataset.flipx === "1", () => {
|
|
4654
4893
|
this.flipImage(t, "x"), i();
|
|
4655
4894
|
}),
|
|
4656
|
-
r(
|
|
4895
|
+
r(c.flipvertical, this.t("flipvertical"), t.dataset.flipy === "1", () => {
|
|
4657
4896
|
this.flipImage(t, "y"), i();
|
|
4658
4897
|
}),
|
|
4659
4898
|
this.ctxSep(),
|
|
4660
|
-
r(
|
|
4661
|
-
const
|
|
4662
|
-
|
|
4899
|
+
r(c.trash, this.t("deleteimg"), !1, () => {
|
|
4900
|
+
const a = t.closest(".tpl-media");
|
|
4901
|
+
a && this.ed.contains(a) ? t.outerHTML = this.imgPhHTML() : t.remove(), this.clearImageHandles(), this.onChange();
|
|
4663
4902
|
})
|
|
4664
|
-
), e.addEventListener("mousedown", (
|
|
4903
|
+
), e.addEventListener("mousedown", (a) => a.preventDefault()), e.addEventListener("mouseenter", () => this.cancelImgHide()), e.addEventListener("mouseleave", () => this.scheduleImgHide()), document.body.appendChild(e), e;
|
|
4665
4904
|
}
|
|
4666
4905
|
setImageAlign(t, e) {
|
|
4667
4906
|
t.style.float = "", t.style.display = "", t.style.marginLeft = "", t.style.marginRight = "", t.style.marginBottom = "", e === "left" ? (t.style.float = "left", t.style.marginInlineEnd = "1em", t.style.marginBottom = "0.5em") : e === "right" ? (t.style.float = "right", t.style.marginInlineStart = "1em", t.style.marginBottom = "0.5em") : (t.style.display = "block", t.style.marginLeft = "auto", t.style.marginRight = "auto"), this.onChange();
|
|
@@ -4683,21 +4922,21 @@ const I = class I {
|
|
|
4683
4922
|
this.clearImageHandles();
|
|
4684
4923
|
return;
|
|
4685
4924
|
}
|
|
4686
|
-
const t = this.imgActive.getBoundingClientRect(), e = t.top + scrollY, i = t.left + scrollX, s = t.right + scrollX, l = t.bottom + scrollY,
|
|
4925
|
+
const t = this.imgActive.getBoundingClientRect(), e = t.top + scrollY, i = t.left + scrollX, s = t.right + scrollX, l = t.bottom + scrollY, n = {
|
|
4687
4926
|
nw: [i, e],
|
|
4688
4927
|
ne: [s, e],
|
|
4689
4928
|
sw: [i, l],
|
|
4690
4929
|
se: [s, l]
|
|
4691
4930
|
};
|
|
4692
|
-
if (this.imgHandles.forEach((
|
|
4693
|
-
const [r,
|
|
4694
|
-
|
|
4931
|
+
if (this.imgHandles.forEach((o) => {
|
|
4932
|
+
const [r, a] = n[o.dataset.corner];
|
|
4933
|
+
o.style.left = r - 5 + "px", o.style.top = a - 5 + "px";
|
|
4695
4934
|
}), this.imgCtx) {
|
|
4696
|
-
const
|
|
4697
|
-
let
|
|
4698
|
-
|
|
4699
|
-
let
|
|
4700
|
-
|
|
4935
|
+
const o = this.imgCtx.offsetWidth, r = this.imgCtx.offsetHeight;
|
|
4936
|
+
let a = i + (s - i) / 2 - o / 2;
|
|
4937
|
+
a = Math.max(8 + scrollX, Math.min(a, scrollX + innerWidth - o - 8));
|
|
4938
|
+
let d = e - r - 8;
|
|
4939
|
+
d < this.ctxMinTop() && (d = l + 8), this.imgCtx.style.left = a + "px", this.imgCtx.style.top = d + "px";
|
|
4701
4940
|
}
|
|
4702
4941
|
}
|
|
4703
4942
|
startImageResizeDrag(t, e) {
|
|
@@ -4705,14 +4944,16 @@ const I = class I {
|
|
|
4705
4944
|
const i = this.imgActive;
|
|
4706
4945
|
if (!i) return;
|
|
4707
4946
|
this.cancelImgHide();
|
|
4708
|
-
const s = t.clientX, l = i.getBoundingClientRect().width,
|
|
4709
|
-
this.withNoTextSelect((
|
|
4710
|
-
const r = (
|
|
4711
|
-
i.style.width = Math.max(24, Math.round(l +
|
|
4712
|
-
},
|
|
4713
|
-
window.removeEventListener("mousemove", r), window.removeEventListener("mouseup",
|
|
4947
|
+
const s = t.clientX, l = i.getBoundingClientRect().width, n = e === "nw" || e === "sw" ? -1 : 1;
|
|
4948
|
+
this.withNoTextSelect((o) => {
|
|
4949
|
+
const r = (d) => {
|
|
4950
|
+
i.style.width = Math.max(24, Math.round(l + n * (d.clientX - s))) + "px", i.style.height = "auto", this.positionImageHandles();
|
|
4951
|
+
}, a = () => {
|
|
4952
|
+
window.removeEventListener("mousemove", r), window.removeEventListener("mouseup", a), o();
|
|
4953
|
+
const d = parseInt(i.style.width, 10);
|
|
4954
|
+
d > 0 && !i.closest(".tpl-media") && (i.setAttribute("width", String(d)), i.removeAttribute("height")), this.onChange();
|
|
4714
4955
|
};
|
|
4715
|
-
window.addEventListener("mousemove", r), window.addEventListener("mouseup",
|
|
4956
|
+
window.addEventListener("mousemove", r), window.addEventListener("mouseup", a);
|
|
4716
4957
|
});
|
|
4717
4958
|
}
|
|
4718
4959
|
/* ---------------------------------------------------------- selection bubble toolbar */
|
|
@@ -4751,40 +4992,40 @@ const I = class I {
|
|
|
4751
4992
|
this.selCtx || (this.selCtx = this.buildSelToolbar()), this.positionSelToolbar(e);
|
|
4752
4993
|
}
|
|
4753
4994
|
buildSelToolbar() {
|
|
4754
|
-
var
|
|
4995
|
+
var o;
|
|
4755
4996
|
const t = document.createElement("div");
|
|
4756
4997
|
t.className = "selctx", t.dir = this.dir();
|
|
4757
4998
|
const e = this.ctxBtn(
|
|
4758
4999
|
'<b style="font:600 15px/1 Georgia,serif">A</b><span class="colorbar" data-cb="fore"></span>',
|
|
4759
5000
|
this.t("forecolor"),
|
|
4760
5001
|
() => this.colorMenu(e, "fore")
|
|
4761
|
-
), i = this.ctxBtn(
|
|
4762
|
-
(
|
|
4763
|
-
const s = this.ctxBtn(
|
|
5002
|
+
), i = this.ctxBtn(c.backcolor, this.t("backcolor"), () => this.colorMenu(i, "back"));
|
|
5003
|
+
(o = i.querySelector("svg")) == null || o.insertAdjacentHTML("afterend", '<span class="colorbar" data-cb="back"></span>');
|
|
5004
|
+
const s = this.ctxBtn(c.caseic, this.t("changecase"), () => this.caseMenu(s)), l = this.ctxBtn(c.lineheight, this.t("lineheight"), () => this.lineHeightMenu(l)), n = this.ctxBtn(c.wordspacing, this.t("wordspacing"), () => this.wordSpacingMenu(n));
|
|
4764
5005
|
return t.append(
|
|
4765
|
-
this.ctxBtn(
|
|
4766
|
-
this.ctxBtn(
|
|
5006
|
+
this.ctxBtn(c.bold, this.t("bold"), () => this.exec("bold"), "bold"),
|
|
5007
|
+
this.ctxBtn(c.italic, this.t("italic"), () => this.exec("italic"), "italic"),
|
|
4767
5008
|
e,
|
|
4768
5009
|
i,
|
|
4769
5010
|
this.ctxSep(),
|
|
4770
|
-
this.ctxBtn(
|
|
4771
|
-
this.ctxBtn(
|
|
5011
|
+
this.ctxBtn(c.quote, this.t("quote"), () => this.toggleBlock("blockquote"), "blockquote"),
|
|
5012
|
+
this.ctxBtn(c.inlinecodeic, this.t("code"), () => this.toggleInlineCode(), "code"),
|
|
4772
5013
|
this.ctxBtn('<b style="font:700 12px/1 Arial,sans-serif">H2</b>', this.blockLabel("h2"), () => this.toggleBlock("h2"), "h2"),
|
|
4773
5014
|
this.ctxBtn('<b style="font:700 12px/1 Arial,sans-serif">H3</b>', this.blockLabel("h3"), () => this.toggleBlock("h3"), "h3"),
|
|
4774
5015
|
this.ctxSep(),
|
|
4775
|
-
this.ctxBtn(
|
|
5016
|
+
this.ctxBtn(c.link, this.t("linkttl"), () => this.linkDlg()),
|
|
4776
5017
|
s,
|
|
4777
5018
|
l,
|
|
4778
|
-
|
|
5019
|
+
n
|
|
4779
5020
|
), t.addEventListener("mousedown", (r) => r.preventDefault()), document.body.appendChild(t), this.syncColorSwatches(t), t;
|
|
4780
5021
|
}
|
|
4781
5022
|
positionSelToolbar(t) {
|
|
4782
5023
|
if (!this.selCtx) return;
|
|
4783
|
-
const e = t.getBoundingClientRect(), i = e.top + scrollY, s = e.left + scrollX, l = e.right + scrollX,
|
|
4784
|
-
let
|
|
4785
|
-
|
|
4786
|
-
let
|
|
4787
|
-
|
|
5024
|
+
const e = t.getBoundingClientRect(), i = e.top + scrollY, s = e.left + scrollX, l = e.right + scrollX, n = e.bottom + scrollY, o = this.selCtx.offsetWidth, r = this.selCtx.offsetHeight;
|
|
5025
|
+
let a = s + (l - s) / 2 - o / 2;
|
|
5026
|
+
a = Math.max(8 + scrollX, Math.min(a, scrollX + innerWidth - o - 8));
|
|
5027
|
+
let d = i - r - 8;
|
|
5028
|
+
d < this.ctxMinTop() && (d = n + 8), this.selCtx.style.left = a + "px", this.selCtx.style.top = d + "px";
|
|
4788
5029
|
}
|
|
4789
5030
|
repositionSelToolbar() {
|
|
4790
5031
|
if (!this.selCtx) return;
|
|
@@ -4817,9 +5058,9 @@ const I = class I {
|
|
|
4817
5058
|
return t > 0 ? t + "px" : "";
|
|
4818
5059
|
}
|
|
4819
5060
|
refreshState() {
|
|
4820
|
-
var r,
|
|
5061
|
+
var r, a, d;
|
|
4821
5062
|
const t = window.getSelection(), e = t ? this.ed.contains(t.anchorNode) : !1, i = this.currentBlock();
|
|
4822
|
-
[this.toolbar, this.selCtx].filter(Boolean).forEach((
|
|
5063
|
+
[this.toolbar, this.selCtx].filter(Boolean).forEach((p) => {
|
|
4823
5064
|
[
|
|
4824
5065
|
"bold",
|
|
4825
5066
|
"italic",
|
|
@@ -4832,22 +5073,22 @@ const I = class I {
|
|
|
4832
5073
|
"insertOrderedList",
|
|
4833
5074
|
"insertUnorderedList"
|
|
4834
5075
|
].forEach((g) => {
|
|
4835
|
-
const
|
|
4836
|
-
|
|
5076
|
+
const m = p.querySelector(`[data-id=${g}]`);
|
|
5077
|
+
m && m.classList.toggle("on", e && document.queryCommandState(g));
|
|
4837
5078
|
}), ["h2", "h3", "blockquote"].forEach((g) => {
|
|
4838
|
-
const
|
|
4839
|
-
|
|
5079
|
+
const m = p.querySelector(`[data-id=${g}]`);
|
|
5080
|
+
m && m.classList.toggle("on", e && i === g);
|
|
4840
5081
|
});
|
|
4841
|
-
const
|
|
4842
|
-
|
|
5082
|
+
const u = p.querySelector("[data-id=code]");
|
|
5083
|
+
u && u.classList.toggle("on", e && !!this.closestInlineCode());
|
|
4843
5084
|
});
|
|
4844
|
-
const l = t ? this.closestBlock(t.anchorNode) : null,
|
|
4845
|
-
(
|
|
4846
|
-
const
|
|
4847
|
-
const
|
|
4848
|
-
|
|
5085
|
+
const l = t ? this.closestBlock(t.anchorNode) : null, n = ((r = l == null ? void 0 : l.closest("[dir]")) == null ? void 0 : r.getAttribute("dir")) || this.ed.getAttribute("dir") || this.dir();
|
|
5086
|
+
(a = this.toolbar.querySelector("[data-id=ltr]")) == null || a.classList.toggle("on", e && n === "ltr"), (d = this.toolbar.querySelector("[data-id=rtl]")) == null || d.classList.toggle("on", e && n === "rtl");
|
|
5087
|
+
const o = (p, u, g) => {
|
|
5088
|
+
const m = this.toolbar.querySelector(`[data-id=${p}] .lbl`);
|
|
5089
|
+
m && (m.textContent = u || g || "", m.classList.toggle("empty", !u));
|
|
4849
5090
|
};
|
|
4850
|
-
|
|
5091
|
+
o("fontsel", this.currentFont()), o("sizesel", this.currentSize().replace("px", "")), e && o("blocksel", Q.some((p) => p[0] === i) ? this.blockLabel(i) : this.t("para")), this.sbWords.textContent = this.countWords() + " " + this.t("words");
|
|
4851
5092
|
}
|
|
4852
5093
|
countWords() {
|
|
4853
5094
|
const t = (this.ed.textContent || "").trim();
|
|
@@ -4862,18 +5103,75 @@ const I = class I {
|
|
|
4862
5103
|
if (s && !i) {
|
|
4863
5104
|
const l = new FileReader();
|
|
4864
5105
|
l.onload = () => {
|
|
4865
|
-
|
|
5106
|
+
this.insertImageHTML(l.result), this.onChange();
|
|
4866
5107
|
}, l.readAsDataURL(s.getAsFile());
|
|
4867
5108
|
return;
|
|
4868
5109
|
}
|
|
4869
5110
|
if (!i) {
|
|
4870
|
-
const l = e.getData("text/plain"),
|
|
4871
|
-
if (
|
|
4872
|
-
document.execCommand("insertHTML", !1, this.videoEmbedHTML(
|
|
5111
|
+
const l = e.getData("text/plain"), n = /^\S+$/.test(l.trim()) ? this.videoEmbedUrl(l.trim()) : null;
|
|
5112
|
+
if (n) {
|
|
5113
|
+
document.execCommand("insertHTML", !1, this.videoEmbedHTML(n)), this.onChange();
|
|
5114
|
+
return;
|
|
5115
|
+
}
|
|
5116
|
+
}
|
|
5117
|
+
i ? this.pasteRichHTML(i, e, s) : (document.execCommand("insertHTML", !1, It(e.getData("text/plain"))), this.onChange());
|
|
5118
|
+
}
|
|
5119
|
+
/** Rich-HTML paste. Before the (untouched) paste engine runs, pictures Word left
|
|
5120
|
+
* behind as unreadable file:// refs are pulled out of the clipboard's RTF flavor
|
|
5121
|
+
* and inlined — the same pairing TinyMCE PowerPaste does for
|
|
5122
|
+
* powerpaste_allow_local_images. Everything the engine already handled is
|
|
5123
|
+
* unaffected: with no RTF, or no recoverable picture, the HTML reaches it
|
|
5124
|
+
* byte-identical to before. */
|
|
5125
|
+
pasteRichHTML(t, e, i) {
|
|
5126
|
+
let s = [];
|
|
5127
|
+
const l = e.getData("text/rtf");
|
|
5128
|
+
if (l) {
|
|
5129
|
+
const n = Pt(t, l);
|
|
5130
|
+
t = n.html, s = n.injected;
|
|
5131
|
+
}
|
|
5132
|
+
if (i && Ot(t) === 1) {
|
|
5133
|
+
const n = i.getAsFile();
|
|
5134
|
+
if (n) {
|
|
5135
|
+
const o = t;
|
|
5136
|
+
this.saveSel();
|
|
5137
|
+
const r = new FileReader();
|
|
5138
|
+
r.onload = () => {
|
|
5139
|
+
const a = nt(o, [r.result]);
|
|
5140
|
+
this.finishRichPaste(a.html, s.concat(a.injected), !0);
|
|
5141
|
+
}, r.onerror = () => this.finishRichPaste(o, s, !0), r.readAsDataURL(n);
|
|
4873
5142
|
return;
|
|
4874
5143
|
}
|
|
4875
5144
|
}
|
|
4876
|
-
|
|
5145
|
+
this.finishRichPaste(t, s);
|
|
5146
|
+
}
|
|
5147
|
+
/** Hands recovered pictures to the host's imageUploadHandler when one is
|
|
5148
|
+
* configured (PowerPaste's automatic_uploads equivalent), then inserts. Without a
|
|
5149
|
+
* handler they stay inline base64, which is what PowerPaste does by default. */
|
|
5150
|
+
finishRichPaste(t, e, i = !1) {
|
|
5151
|
+
if (!this.imageUploadHandler || !e.length) {
|
|
5152
|
+
this.insertPastedHTML(t, i);
|
|
5153
|
+
return;
|
|
5154
|
+
}
|
|
5155
|
+
const s = this.imageUploadHandler, l = e.filter((n, o) => e.indexOf(n) === o);
|
|
5156
|
+
i || this.saveSel(), Promise.all(
|
|
5157
|
+
l.map((n, o) => {
|
|
5158
|
+
const r = Ft(n, "pasted-image-" + (o + 1));
|
|
5159
|
+
return r ? s(r).catch((a) => {
|
|
5160
|
+
var d;
|
|
5161
|
+
return (d = this.onImageUploadError) == null || d.call(this, a, r), n;
|
|
5162
|
+
}) : Promise.resolve(n);
|
|
5163
|
+
})
|
|
5164
|
+
).then((n) => {
|
|
5165
|
+
let o = t;
|
|
5166
|
+
l.forEach((r, a) => {
|
|
5167
|
+
n[a] !== r && (o = o.split(r).join(n[a]));
|
|
5168
|
+
}), this.insertPastedHTML(o, !0);
|
|
5169
|
+
});
|
|
5170
|
+
}
|
|
5171
|
+
/** `deferred` means the insert is happening after an async hop, so the caret the
|
|
5172
|
+
* paste started from has to be put back first. */
|
|
5173
|
+
insertPastedHTML(t, e = !1) {
|
|
5174
|
+
e && this.restoreSel(), document.execCommand("insertHTML", !1, At(t, this.dir())), e && this.saveSel(), this.onChange();
|
|
4877
5175
|
}
|
|
4878
5176
|
/* ---------------------------------------------------------- init */
|
|
4879
5177
|
initUI() {
|
|
@@ -4881,18 +5179,18 @@ const I = class I {
|
|
|
4881
5179
|
}
|
|
4882
5180
|
};
|
|
4883
5181
|
I.instanceCounter = 0, I.TBR_COLLAPSE_MAX = 992;
|
|
4884
|
-
let
|
|
5182
|
+
let st = I;
|
|
4885
5183
|
export {
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
|
|
5184
|
+
Q as BLOCKS,
|
|
5185
|
+
pe as CHARS,
|
|
5186
|
+
vt as COLORS,
|
|
5187
|
+
pt as FONTS,
|
|
5188
|
+
st as FableEditor,
|
|
5189
|
+
ct as I18N,
|
|
5190
|
+
c as IC,
|
|
5191
|
+
ut as SIZES,
|
|
5192
|
+
ue as TXT,
|
|
5193
|
+
At as cleanPastedHTML,
|
|
5194
|
+
O as getStrings,
|
|
5195
|
+
It as normalizeTextPaste
|
|
4898
5196
|
};
|