fable-editor 1.2.1 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -18
- package/README.md +226 -226
- package/dist/angular/README.md +226 -224
- package/dist/angular/core/editor.d.ts +6 -0
- package/dist/angular/core/i18n.d.ts +1 -0
- package/dist/angular/esm2022/core/editor.mjs +98 -81
- package/dist/angular/esm2022/core/i18n.mjs +3 -1
- package/dist/angular/fesm2022/fable-editor.mjs +99 -80
- package/dist/angular/fesm2022/fable-editor.mjs.map +1 -1
- package/dist/core/editor.d.ts +6 -0
- package/dist/core/editor.d.ts.map +1 -1
- package/dist/core/i18n.d.ts +1 -0
- package/dist/core/i18n.d.ts.map +1 -1
- package/dist/core/index.cjs +3 -3
- package/dist/core/index.mjs +420 -411
- package/dist/react/index.cjs +12 -12
- package/dist/react/index.mjs +645 -636
- package/package.json +113 -113
package/dist/core/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const et = {
|
|
2
2
|
en: {
|
|
3
3
|
dir: "ltr",
|
|
4
4
|
file: "File",
|
|
@@ -53,6 +53,7 @@ const K = {
|
|
|
53
53
|
aligncenter: "Align center",
|
|
54
54
|
alignright: "Align right",
|
|
55
55
|
alignjustify: "Justify",
|
|
56
|
+
align: "Align",
|
|
56
57
|
numlist: "Numbered list",
|
|
57
58
|
bullist: "Bullet list",
|
|
58
59
|
forecolor: "Text color",
|
|
@@ -244,6 +245,7 @@ const K = {
|
|
|
244
245
|
aligncenter: "توسيط",
|
|
245
246
|
alignright: "محاذاة لليمين",
|
|
246
247
|
alignjustify: "ضبط",
|
|
248
|
+
align: "محاذاة",
|
|
247
249
|
numlist: "قائمة رقمية",
|
|
248
250
|
bullist: "قائمة نقطية",
|
|
249
251
|
forecolor: "لون النص",
|
|
@@ -383,9 +385,9 @@ const K = {
|
|
|
383
385
|
}
|
|
384
386
|
};
|
|
385
387
|
function R(p) {
|
|
386
|
-
return
|
|
388
|
+
return et[p];
|
|
387
389
|
}
|
|
388
|
-
const
|
|
390
|
+
const it = "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", st = "file edit view insert format tools table help", lt = [
|
|
389
391
|
["Andale Mono", "andale mono,times"],
|
|
390
392
|
["Arial", "arial,helvetica,sans-serif"],
|
|
391
393
|
["Arial Black", "arial black,avant garde"],
|
|
@@ -405,7 +407,7 @@ const J = "undo redo | preview print | importword revhistory | fontfamily fontsi
|
|
|
405
407
|
["Verdana", "verdana,geneva"],
|
|
406
408
|
["Webdings", "webdings"],
|
|
407
409
|
["Wingdings", "wingdings,zapf dingbats"]
|
|
408
|
-
],
|
|
410
|
+
], ot = ["8px", "9px", "10px", "11px", "12px", "14px", "16px", "18px", "20px", "24px", "28px", "32px", "36px", "48px", "72px", "96px"], nt = 1, rt = 100, _ = ["1", "1.15", "1.4", "1.5", "1.75", "2", "2.5", "3"], V = ["1px", "2px", "4px", "6px", "8px", "12px"], W = ["0.5px", "1px", "1.5px", "2px", "3px", "4px"], U = [
|
|
409
411
|
["plain", "Plain text"],
|
|
410
412
|
["html", "HTML/XML"],
|
|
411
413
|
["css", "CSS"],
|
|
@@ -422,7 +424,7 @@ const J = "undo redo | preview print | importword revhistory | fontfamily fontsi
|
|
|
422
424
|
["rust", "Rust"],
|
|
423
425
|
["sql", "SQL"],
|
|
424
426
|
["bash", "Bash/Shell"]
|
|
425
|
-
],
|
|
427
|
+
], j = [
|
|
426
428
|
["p", "para"],
|
|
427
429
|
["h1", "heading1"],
|
|
428
430
|
["h2", "heading2"],
|
|
@@ -1522,7 +1524,7 @@ const J = "undo redo | preview print | importword revhistory | fontfamily fontsi
|
|
|
1522
1524
|
"🇲🇦"
|
|
1523
1525
|
]
|
|
1524
1526
|
}
|
|
1525
|
-
],
|
|
1527
|
+
], Zt = [
|
|
1526
1528
|
"©",
|
|
1527
1529
|
"®",
|
|
1528
1530
|
"™",
|
|
@@ -1575,7 +1577,7 @@ const J = "undo redo | preview print | importword revhistory | fontfamily fontsi
|
|
|
1575
1577
|
'<path d="M10 6h10M10 12h10M10 18h10"/>' + p.map(
|
|
1576
1578
|
(e, i) => `<text x="2.5" y="${8.4 + i * 6}" font-size="${t}" stroke="none" fill="#222f3e" font-family="Arial">${e}</text>`
|
|
1577
1579
|
).join("")
|
|
1578
|
-
),
|
|
1580
|
+
), a = {
|
|
1579
1581
|
bold: f(
|
|
1580
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"
|
|
1581
1583
|
),
|
|
@@ -1906,7 +1908,7 @@ const J = "undo redo | preview print | importword revhistory | fontfamily fontsi
|
|
|
1906
1908
|
"box-sizing",
|
|
1907
1909
|
"list-style-type",
|
|
1908
1910
|
"white-space"
|
|
1909
|
-
]),
|
|
1911
|
+
]), X = {
|
|
1910
1912
|
"*": ["dir", "lang", "colspan", "rowspan"],
|
|
1911
1913
|
a: ["href", "target", "rel", "title"],
|
|
1912
1914
|
img: ["src", "alt", "width", "height", "title"],
|
|
@@ -1945,18 +1947,18 @@ function ft(p) {
|
|
|
1945
1947
|
const l = [], o = s[0];
|
|
1946
1948
|
s.forEach((n) => {
|
|
1947
1949
|
var x, C, M;
|
|
1948
|
-
const
|
|
1950
|
+
const c = +(((x = (n.getAttribute("style") || "").match(/level(\d+)/i)) == null ? void 0 : x[1]) || 1), h = Array.from(n.querySelectorAll("span")).find(
|
|
1949
1951
|
(w) => /mso-list\s*:\s*ignore/i.test(w.getAttribute("style") || "")
|
|
1950
1952
|
), d = h ? ((C = h.textContent) == null ? void 0 : C.trim()) || "" : (((M = n.textContent) == null ? void 0 : M.trim().match(/^\S{1,4}/)) || [""])[0], { ordered: m, style: g } = gt(d);
|
|
1951
|
-
for (h && h.remove(); l.length && l[l.length - 1].level >
|
|
1952
|
-
if (!l.length || l[l.length - 1].level <
|
|
1953
|
+
for (h && h.remove(); l.length && l[l.length - 1].level > c; ) l.pop();
|
|
1954
|
+
if (!l.length || l[l.length - 1].level < c) {
|
|
1953
1955
|
const w = p.createElement(m ? "ol" : "ul");
|
|
1954
1956
|
if (m && g && (w.style.listStyleType = g), l.length) {
|
|
1955
1957
|
const k = l[l.length - 1].list;
|
|
1956
1958
|
(k.lastElementChild || k).appendChild(w);
|
|
1957
1959
|
} else
|
|
1958
1960
|
o.parentNode.insertBefore(w, o);
|
|
1959
|
-
l.push({ list: w, level:
|
|
1961
|
+
l.push({ list: w, level: c });
|
|
1960
1962
|
}
|
|
1961
1963
|
const u = p.createElement("li"), v = D(n), b = ["text-align", "direction", "unicode-bidi", "color", "font-size", "font-family", "background-color"].filter((w) => v[w]).map((w) => w + ":" + v[w]).join(";");
|
|
1962
1964
|
for (b && u.setAttribute("style", b), n.getAttribute("dir") && u.setAttribute("dir", n.getAttribute("dir")); n.firstChild; ) u.appendChild(n.firstChild);
|
|
@@ -2001,8 +2003,8 @@ function N(p, t) {
|
|
|
2001
2003
|
if (s === "font") {
|
|
2002
2004
|
const r = t.createElement("span");
|
|
2003
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"));
|
|
2004
|
-
const
|
|
2005
|
-
if (
|
|
2006
|
+
const c = i.getAttribute("size");
|
|
2007
|
+
if (c && !r.style.fontSize) {
|
|
2006
2008
|
const h = {
|
|
2007
2009
|
1: "8pt",
|
|
2008
2010
|
2: "10pt",
|
|
@@ -2012,7 +2014,7 @@ function N(p, t) {
|
|
|
2012
2014
|
6: "24pt",
|
|
2013
2015
|
7: "36pt"
|
|
2014
2016
|
};
|
|
2015
|
-
h[
|
|
2017
|
+
h[c] && (r.style.fontSize = h[c]);
|
|
2016
2018
|
}
|
|
2017
2019
|
for (; i.firstChild; ) r.appendChild(i.firstChild);
|
|
2018
2020
|
i.replaceWith(r), N(r, t);
|
|
@@ -2022,10 +2024,10 @@ function N(p, t) {
|
|
|
2022
2024
|
i.remove();
|
|
2023
2025
|
return;
|
|
2024
2026
|
}
|
|
2025
|
-
const l = /* @__PURE__ */ new Set([...
|
|
2027
|
+
const l = /* @__PURE__ */ new Set([...X["*"] || [], ...X[s] || []]);
|
|
2026
2028
|
if (Array.from(i.attributes).forEach((r) => {
|
|
2027
|
-
const
|
|
2028
|
-
|
|
2029
|
+
const c = r.name.toLowerCase();
|
|
2030
|
+
c !== "style" && !l.has(c) && i.removeAttribute(r.name);
|
|
2029
2031
|
}), s === "a") {
|
|
2030
2032
|
const r = i.getAttribute("href") || "";
|
|
2031
2033
|
/^(https?:|mailto:|tel:|#)/i.test(r) || i.removeAttribute("href");
|
|
@@ -2033,14 +2035,14 @@ function N(p, t) {
|
|
|
2033
2035
|
if (s === "img") {
|
|
2034
2036
|
const r = i.getAttribute("src") || "";
|
|
2035
2037
|
if (!/^(https?:|data:image\/|blob:)/i.test(r)) {
|
|
2036
|
-
const
|
|
2037
|
-
|
|
2038
|
+
const c = t.createElement("span");
|
|
2039
|
+
c.textContent = "[local image — paste it separately]", c.setAttribute("style", "color:#a33;font-style:italic;font-size:12px"), i.replaceWith(c);
|
|
2038
2040
|
return;
|
|
2039
2041
|
}
|
|
2040
2042
|
}
|
|
2041
2043
|
const o = D(i), n = [];
|
|
2042
|
-
for (const [r,
|
|
2043
|
-
mt.has(r) && (/expression|javascript|url\s*\(\s*['"]?\s*file:/i.test(
|
|
2044
|
+
for (const [r, c] of Object.entries(o))
|
|
2045
|
+
mt.has(r) && (/expression|javascript|url\s*\(\s*['"]?\s*file:/i.test(c) || r === "font-weight" && /^(400|normal)$/i.test(c) || r === "font-style" && /^normal$/i.test(c) || r === "text-decoration" && /^none$/i.test(c) || n.push(r + ":" + c));
|
|
2044
2046
|
if (n.length ? i.setAttribute("style", n.join(";")) : i.removeAttribute("style"), i.removeAttribute("class"), N(i, t), s === "span" && !i.attributes.length) {
|
|
2045
2047
|
for (; i.firstChild; ) i.parentNode.insertBefore(i.firstChild, i);
|
|
2046
2048
|
i.remove();
|
|
@@ -2057,8 +2059,8 @@ function yt(p) {
|
|
|
2057
2059
|
const o = /([^{}]+)\{([^}]*)\}/g;
|
|
2058
2060
|
for (; l = o.exec(s); ) {
|
|
2059
2061
|
const n = l[2].split(";").map((r) => {
|
|
2060
|
-
const
|
|
2061
|
-
return
|
|
2062
|
+
const c = r.indexOf(":");
|
|
2063
|
+
return c < 1 ? null : [r.slice(0, c).trim().toLowerCase(), r.slice(c + 1).trim()];
|
|
2062
2064
|
}).filter((r) => !!r && !!r[1]);
|
|
2063
2065
|
n.length && l[1].split(",").map((r) => r.trim()).filter((r) => r && !r.startsWith("@")).forEach((r) => t.push({ sel: r, decls: n }));
|
|
2064
2066
|
}
|
|
@@ -2077,25 +2079,25 @@ function xt(p, t) {
|
|
|
2077
2079
|
}
|
|
2078
2080
|
l.forEach((o) => {
|
|
2079
2081
|
let n = e.get(o);
|
|
2080
|
-
n || (n = {}, e.set(o, n)), s.forEach(([r,
|
|
2081
|
-
n[r] =
|
|
2082
|
+
n || (n = {}, e.set(o, n)), s.forEach(([r, c]) => {
|
|
2083
|
+
n[r] = c;
|
|
2082
2084
|
});
|
|
2083
2085
|
});
|
|
2084
2086
|
}), e.forEach((i, s) => {
|
|
2085
2087
|
const l = D(s), o = s.hasAttribute("dir"), n = s.hasAttribute("align"), r = Object.entries(i).filter(([d]) => !(d in l || (d === "direction" || d === "unicode-bidi") && o || d === "text-align" && (n || o) || (d === "background" || d === "background-color") && s.hasAttribute("bgcolor")));
|
|
2086
2088
|
if (!r.length) return;
|
|
2087
|
-
const
|
|
2088
|
-
s.setAttribute("style", h ?
|
|
2089
|
+
const c = r.map(([d, m]) => d + ":" + m).join(";"), h = s.getAttribute("style");
|
|
2090
|
+
s.setAttribute("style", h ? c + ";" + h : c);
|
|
2089
2091
|
});
|
|
2090
2092
|
}
|
|
2091
|
-
function
|
|
2093
|
+
function tt(p) {
|
|
2092
2094
|
return p.replace(/[ﭐ-﷿ﹰ-ﻼ]+/g, (t) => t.normalize("NFKC"));
|
|
2093
2095
|
}
|
|
2094
2096
|
function Ct(p) {
|
|
2095
2097
|
const t = p.createTreeWalker(p.body, NodeFilter.SHOW_TEXT, null);
|
|
2096
2098
|
let e;
|
|
2097
2099
|
for (; e = t.nextNode(); )
|
|
2098
|
-
/[ﭐ-﷿ﹰ-ﻼ]/.test(e.nodeValue || "") && (e.nodeValue =
|
|
2100
|
+
/[ﭐ-﷿ﹰ-ﻼ]/.test(e.nodeValue || "") && (e.nodeValue = tt(e.nodeValue || ""));
|
|
2099
2101
|
}
|
|
2100
2102
|
function wt(p, t = "ltr") {
|
|
2101
2103
|
const e = yt(p), i = new DOMParser().parseFromString(ut(p), "text/html");
|
|
@@ -2109,7 +2111,7 @@ function wt(p, t = "ltr") {
|
|
|
2109
2111
|
return i.body.innerHTML.trim();
|
|
2110
2112
|
}
|
|
2111
2113
|
function Tt(p) {
|
|
2112
|
-
const t =
|
|
2114
|
+
const t = tt(p).replace(/\r/g, ""), e = (i) => i.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
2113
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);
|
|
2114
2116
|
}
|
|
2115
2117
|
function Mt(p) {
|
|
@@ -2125,12 +2127,12 @@ function Mt(p) {
|
|
|
2125
2127
|
let l = t.getUint32(i + 16, !0);
|
|
2126
2128
|
const o = new TextDecoder();
|
|
2127
2129
|
for (let n = 0; n < s && t.getUint32(l, !0) === 33639248; n++) {
|
|
2128
|
-
const r = t.getUint16(l + 10, !0),
|
|
2129
|
-
e.set(u, { name: u, method: r, compSize:
|
|
2130
|
+
const r = t.getUint16(l + 10, !0), c = t.getUint32(l + 20, !0), h = t.getUint16(l + 28, !0), d = t.getUint16(l + 30, !0), m = t.getUint16(l + 32, !0), g = t.getUint32(l + 42, !0), u = o.decode(new Uint8Array(p, l + 46, h));
|
|
2131
|
+
e.set(u, { name: u, method: r, compSize: c, localOffset: g }), l += 46 + h + d + m;
|
|
2130
2132
|
}
|
|
2131
2133
|
return e;
|
|
2132
2134
|
}
|
|
2133
|
-
async function
|
|
2135
|
+
async function Q(p, t) {
|
|
2134
2136
|
const e = new DataView(p, t.localOffset);
|
|
2135
2137
|
if (e.getUint32(0, !0) !== 67324752) throw new Error("Bad local header");
|
|
2136
2138
|
const i = e.getUint16(26, !0), s = e.getUint16(28, !0), l = t.localOffset + 30 + i + s, o = new Uint8Array(p.slice(l, l + t.compSize));
|
|
@@ -2139,7 +2141,7 @@ async function U(p, t) {
|
|
|
2139
2141
|
const n = new Blob([o]).stream().pipeThrough(new DecompressionStream("deflate-raw"));
|
|
2140
2142
|
return new Uint8Array(await new Response(n).arrayBuffer());
|
|
2141
2143
|
}
|
|
2142
|
-
const
|
|
2144
|
+
const G = (p) => p.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """), P = (p, t) => Array.from(p.children).filter((e) => e.localName === t), S = (p, ...t) => {
|
|
2143
2145
|
let e = p;
|
|
2144
2146
|
for (const i of t) {
|
|
2145
2147
|
if (!e) return null;
|
|
@@ -2151,12 +2153,12 @@ const j = (p) => p.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, "&
|
|
|
2151
2153
|
for (const e of Array.from(p.attributes))
|
|
2152
2154
|
if (e.localName === t) return e.value;
|
|
2153
2155
|
return "";
|
|
2154
|
-
},
|
|
2156
|
+
}, B = (p, t) => {
|
|
2155
2157
|
const e = p ? S(p, t) : null;
|
|
2156
2158
|
if (!e) return !1;
|
|
2157
2159
|
const i = T(e);
|
|
2158
2160
|
return i !== "false" && i !== "0";
|
|
2159
|
-
},
|
|
2161
|
+
}, Y = {
|
|
2160
2162
|
yellow: "#FFFF00",
|
|
2161
2163
|
green: "#00FF00",
|
|
2162
2164
|
cyan: "#00FFFF",
|
|
@@ -2226,8 +2228,8 @@ class Lt {
|
|
|
2226
2228
|
l ? s = "h" + l[1] : /^Title$/i.test(i) && (s = "h1");
|
|
2227
2229
|
const o = [], n = T(S(t, "pPr", "jc"));
|
|
2228
2230
|
n === "center" ? o.push("text-align:center") : n === "right" || n === "end" ? o.push("text-align:right") : (n === "both" || n === "distribute") && o.push("text-align:justify"), e && S(e, "bidi") && o.push("direction:rtl");
|
|
2229
|
-
const r = this.runsOf(t),
|
|
2230
|
-
return `<${s}${
|
|
2231
|
+
const r = this.runsOf(t), c = o.length ? ` style="${o.join(";")}"` : "";
|
|
2232
|
+
return `<${s}${c}>${r || "<br>"}</${s}>`;
|
|
2231
2233
|
}
|
|
2232
2234
|
runsOf(t) {
|
|
2233
2235
|
let e = "";
|
|
@@ -2238,7 +2240,7 @@ class Lt {
|
|
|
2238
2240
|
const l = T(i, "anchor");
|
|
2239
2241
|
!s && l && (s = "#" + l);
|
|
2240
2242
|
const o = this.runsOf(i);
|
|
2241
|
-
e += s ? `<a href="${
|
|
2243
|
+
e += s ? `<a href="${G(s)}">${o}</a>` : o;
|
|
2242
2244
|
} else (i.localName === "smartTag" || i.localName === "ins") && (e += this.runsOf(i));
|
|
2243
2245
|
return e;
|
|
2244
2246
|
}
|
|
@@ -2246,16 +2248,16 @@ class Lt {
|
|
|
2246
2248
|
const e = S(t, "rPr");
|
|
2247
2249
|
let i = "";
|
|
2248
2250
|
for (const d of Array.from(t.children))
|
|
2249
|
-
d.localName === "t" ? i +=
|
|
2251
|
+
d.localName === "t" ? i += G(d.textContent || "") : d.localName === "br" || d.localName === "cr" ? i += "<br>" : d.localName === "tab" ? i += " " : (d.localName === "drawing" || d.localName === "pict" || d.localName === "object") && (i += this.convertImage(d));
|
|
2250
2252
|
if (!i) return "";
|
|
2251
2253
|
const s = [], l = T(e ? S(e, "color") : null);
|
|
2252
2254
|
l && l !== "auto" && s.push("color:#" + l);
|
|
2253
2255
|
const o = T(e ? S(e, "highlight") : null);
|
|
2254
|
-
o &&
|
|
2256
|
+
o && Y[o] && s.push("background-color:" + Y[o]);
|
|
2255
2257
|
const n = parseFloat(T(e ? S(e, "sz") : null));
|
|
2256
2258
|
n && s.push("font-size:" + Math.round(n / 2 * (4 / 3)) + "px");
|
|
2257
|
-
const r = e ? S(e, "rFonts") : null,
|
|
2258
|
-
|
|
2259
|
+
const r = e ? S(e, "rFonts") : null, c = T(r, "ascii") || T(r, "cs");
|
|
2260
|
+
c && s.push(`font-family:'${c}'`), 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(S(e, "u")) !== "none" && (i = `<u>${i}</u>`), B(e, "strike") && (i = `<s>${i}</s>`);
|
|
2259
2261
|
const h = T(e ? S(e, "vertAlign") : null);
|
|
2260
2262
|
return h === "superscript" ? i = `<sup>${i}</sup>` : h === "subscript" && (i = `<sub>${i}</sub>`), i;
|
|
2261
2263
|
}
|
|
@@ -2293,7 +2295,7 @@ class Lt {
|
|
|
2293
2295
|
async function Ht(p) {
|
|
2294
2296
|
const t = p instanceof ArrayBuffer ? p : await p.arrayBuffer(), e = Mt(t), i = new TextDecoder(), s = async (u) => {
|
|
2295
2297
|
const v = e.get(u);
|
|
2296
|
-
return v ? new DOMParser().parseFromString(i.decode(await
|
|
2298
|
+
return v ? new DOMParser().parseFromString(i.decode(await Q(t, v)), "application/xml") : null;
|
|
2297
2299
|
}, l = await s("word/document.xml"), o = l == null ? void 0 : l.getElementsByTagName("*");
|
|
2298
2300
|
let n = null;
|
|
2299
2301
|
if (o) {
|
|
@@ -2304,21 +2306,21 @@ async function Ht(p) {
|
|
|
2304
2306
|
}
|
|
2305
2307
|
}
|
|
2306
2308
|
if (!n) throw new Error("word/document.xml missing or invalid");
|
|
2307
|
-
const r = /* @__PURE__ */ new Map(),
|
|
2309
|
+
const r = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), h = await s("word/_rels/document.xml.rels");
|
|
2308
2310
|
if (h)
|
|
2309
2311
|
for (const u of Array.from(h.getElementsByTagName("*"))) {
|
|
2310
2312
|
if (u.localName !== "Relationship") continue;
|
|
2311
2313
|
const v = u.getAttribute("Id") || "", b = u.getAttribute("Target") || "", x = u.getAttribute("Type") || "";
|
|
2312
|
-
/hyperlink/i.test(x) ? r.set(v, b) : /image/i.test(x) &&
|
|
2314
|
+
/hyperlink/i.test(x) ? r.set(v, b) : /image/i.test(x) && c.set(v, b);
|
|
2313
2315
|
}
|
|
2314
2316
|
const d = /* @__PURE__ */ new Map();
|
|
2315
|
-
for (const [u, v] of
|
|
2317
|
+
for (const [u, v] of c) {
|
|
2316
2318
|
const b = v.startsWith("/") ? v.slice(1) : "word/" + v.replace(/^\.\//, ""), x = e.get(b);
|
|
2317
2319
|
if (!x) continue;
|
|
2318
2320
|
const C = (b.split(".").pop() || "").toLowerCase(), M = St[C];
|
|
2319
2321
|
if (M)
|
|
2320
2322
|
try {
|
|
2321
|
-
d.set(u, `data:${M};base64,${Et(await
|
|
2323
|
+
d.set(u, `data:${M};base64,${Et(await Q(t, x))}`);
|
|
2322
2324
|
} catch {
|
|
2323
2325
|
}
|
|
2324
2326
|
}
|
|
@@ -2343,23 +2345,23 @@ const kt = ["nw", "ne", "sw", "se"], F = ["img-left", "img-right", "img-top", "i
|
|
|
2343
2345
|
"img-right": "tplimgright",
|
|
2344
2346
|
"img-top": "tplimgtop",
|
|
2345
2347
|
"img-center": "tplimgcenter"
|
|
2346
|
-
},
|
|
2347
|
-
"img-left":
|
|
2348
|
-
"img-right":
|
|
2349
|
-
"img-top":
|
|
2350
|
-
"img-center":
|
|
2351
|
-
},
|
|
2352
|
-
let E = null,
|
|
2353
|
-
function
|
|
2354
|
-
clearTimeout($),
|
|
2348
|
+
}, It = {
|
|
2349
|
+
"img-left": a.tplleft,
|
|
2350
|
+
"img-right": a.tplright,
|
|
2351
|
+
"img-top": a.tpltop,
|
|
2352
|
+
"img-center": a.tplcenter
|
|
2353
|
+
}, At = ".tox,.pop,.tblctx,.imgctx,.selctx,.dlg";
|
|
2354
|
+
let E = null, I = null, $ = 0, K = !1;
|
|
2355
|
+
function Z() {
|
|
2356
|
+
clearTimeout($), I = null, E && E.classList.remove("show");
|
|
2355
2357
|
}
|
|
2356
2358
|
function qt(p) {
|
|
2357
2359
|
const t = p.dataset.tip;
|
|
2358
2360
|
if (!t) return;
|
|
2359
|
-
|
|
2361
|
+
I = p, clearTimeout($);
|
|
2360
2362
|
const e = E && E.classList.contains("show") ? 60 : 350;
|
|
2361
2363
|
$ = window.setTimeout(() => {
|
|
2362
|
-
if (
|
|
2364
|
+
if (I !== p || !document.contains(p)) return;
|
|
2363
2365
|
E || (E = document.createElement("div"), E.className = "etip", document.body.appendChild(E)), E.textContent = t, E.classList.add("show");
|
|
2364
2366
|
const i = p.getBoundingClientRect(), s = E.offsetWidth, l = E.offsetHeight;
|
|
2365
2367
|
let o = i.left + i.width / 2 - s / 2;
|
|
@@ -2368,22 +2370,22 @@ function qt(p) {
|
|
|
2368
2370
|
n + l > innerHeight - 6 && (n = i.top - l - 7), E.style.left = o + "px", E.style.top = n + "px";
|
|
2369
2371
|
}, e);
|
|
2370
2372
|
}
|
|
2371
|
-
function
|
|
2372
|
-
|
|
2373
|
+
function Bt() {
|
|
2374
|
+
K || (K = !0, document.addEventListener("mouseover", (p) => {
|
|
2373
2375
|
const t = p.target, e = t.closest ? t.closest("[title],[data-tip]") : null;
|
|
2374
|
-
if (!e || !e.closest(
|
|
2375
|
-
e !==
|
|
2376
|
+
if (!e || !e.closest(At) || e.closest(".earea")) {
|
|
2377
|
+
e !== I && Z();
|
|
2376
2378
|
return;
|
|
2377
2379
|
}
|
|
2378
2380
|
const i = e.getAttribute("title");
|
|
2379
|
-
i && (e.dataset.tip = i, e.removeAttribute("title"), e.getAttribute("aria-label") || e.setAttribute("aria-label", i)), e !==
|
|
2381
|
+
i && (e.dataset.tip = i, e.removeAttribute("title"), e.getAttribute("aria-label") || e.setAttribute("aria-label", i)), e !== I && qt(e);
|
|
2380
2382
|
}), document.addEventListener("mouseout", (p) => {
|
|
2381
|
-
|
|
2382
|
-
}), document.addEventListener("mousedown",
|
|
2383
|
+
I && !I.contains(p.relatedTarget) && Z();
|
|
2384
|
+
}), document.addEventListener("mousedown", Z, !0), addEventListener("scroll", Z, !0));
|
|
2383
2385
|
}
|
|
2384
|
-
const
|
|
2386
|
+
const A = class A {
|
|
2385
2387
|
constructor(t) {
|
|
2386
|
-
this.lang = "en", this.contentClass = "fable-content-" +
|
|
2388
|
+
this.lang = "en", this.contentClass = "fable-content-" + A.instanceCounter++, this.contentStyleEl = null, this.savedRange = null, this.foreColor = "#000000", this.backColor = "#FACC15", this.openPop = null, this.openSubEl = null, this.popAnchor = null, this.dlgOvl = null, this.tblActive = null, this.tblCorner = null, this.tblColBars = [], this.tblCtx = null, this.tblCellMark = null, this.tblOpMark = null, this.tblOpMarkKind = null, this.imgActive = null, this.imgHandles = [], this.imgCtx = null, this.imgHideTimer = null, this.phActive = null, this.phCtx = null, this.phUploadTarget = null, this.vidActive = null, this.vidCtx = null, this.vidHideTimer = null, this.vphActive = null, this.vphCtx = null, this.vphUploadTarget = null, this.selCtx = null, this.tbrMore = null, this.tbrExpanded = !1, this.codeActive = null, this.codeCtx = null, this.tplActive = null, this.tplCtx = null, this.revisions = [], this.revTimer = null, this.draftTimer = null, this.draftStorageKey = "", this.listeners = [], this.isDestroyed = !1, this.options = {
|
|
2387
2389
|
target: t.target,
|
|
2388
2390
|
language: t.language || "en",
|
|
2389
2391
|
height: t.height ?? 302,
|
|
@@ -2397,7 +2399,7 @@ const I = class I {
|
|
|
2397
2399
|
statusbar: t.statusbar ?? !0,
|
|
2398
2400
|
readonly: t.readonly ?? !1,
|
|
2399
2401
|
draftKey: t.draftKey ?? (typeof location < "u" ? location.pathname : "default"),
|
|
2400
|
-
fontFamilyFormats: t.fontFamilyFormats ??
|
|
2402
|
+
fontFamilyFormats: t.fontFamilyFormats ?? lt,
|
|
2401
2403
|
imageFileTypes: t.imageFileTypes ?? ["image/jpeg", "image/jpg", "image/png", "image/gif", "image/bmp", "image/webp"],
|
|
2402
2404
|
videoFileTypes: t.videoFileTypes ?? ["video/mp4", "video/webm", "video/ogg"]
|
|
2403
2405
|
}, 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);
|
|
@@ -2423,7 +2425,7 @@ const I = class I {
|
|
|
2423
2425
|
</span>
|
|
2424
2426
|
`, this.sbHelp = this.statusbar.querySelector(".mid"), this.sbWords = this.statusbar.querySelector(".words");
|
|
2425
2427
|
const e = this.statusbar.querySelector(".grip");
|
|
2426
|
-
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),
|
|
2428
|
+
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), Bt(), 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);
|
|
2427
2429
|
}
|
|
2428
2430
|
/** Theme options land as CSS variables on the document root rather than the editor
|
|
2429
2431
|
* shell, because dialogs, popups and floating context toolbars are appended to
|
|
@@ -2470,14 +2472,14 @@ const I = class I {
|
|
|
2470
2472
|
t.preventDefault();
|
|
2471
2473
|
const e = t.target, i = (l = e.closest) == null ? void 0 : l.call(e, ".img-ph:not(.vid-ph)");
|
|
2472
2474
|
if (i && this.ed.contains(i) && !this.options.readonly) {
|
|
2473
|
-
const
|
|
2474
|
-
|
|
2475
|
+
const c = Array.from(((o = t.dataTransfer) == null ? void 0 : o.files) || []).find((h) => h.type.startsWith("image/"));
|
|
2476
|
+
c && this.readImageFileInto(c, i);
|
|
2475
2477
|
return;
|
|
2476
2478
|
}
|
|
2477
2479
|
const s = (n = e.closest) == null ? void 0 : n.call(e, ".vid-ph");
|
|
2478
2480
|
if (s && this.ed.contains(s) && !this.options.readonly) {
|
|
2479
|
-
const
|
|
2480
|
-
|
|
2481
|
+
const c = Array.from(((r = t.dataTransfer) == null ? void 0 : r.files) || []).find((h) => h.type.startsWith("video/"));
|
|
2482
|
+
c && this.readVideoFileInto(c, s);
|
|
2481
2483
|
}
|
|
2482
2484
|
}), this.on(this.ed, "dragover", (t) => t.preventDefault()), this.on(this.ed, "mousedown", (t) => {
|
|
2483
2485
|
var h, d, m, g, u, v, b;
|
|
@@ -2493,8 +2495,8 @@ const I = class I {
|
|
|
2493
2495
|
n && this.ed.contains(n) && !this.options.readonly ? (t.preventDefault(), this.selectCodeEl(n)) : this.clearCodeSel();
|
|
2494
2496
|
const r = (v = e.closest) == null ? void 0 : v.call(e, "img");
|
|
2495
2497
|
r && this.ed.contains(r) && !this.options.readonly ? (t.preventDefault(), this.selectImage(r)) : this.clearImageHandles();
|
|
2496
|
-
const
|
|
2497
|
-
|
|
2498
|
+
const c = (b = e.closest) == null ? void 0 : b.call(e, "video, .video-embed");
|
|
2499
|
+
c && this.ed.contains(c) && !this.options.readonly ? (t.preventDefault(), this.selectVideo(c)) : this.clearVidHandles();
|
|
2498
2500
|
}), this.on(this.ed, "mouseover", (t) => {
|
|
2499
2501
|
var i, s;
|
|
2500
2502
|
if (this.options.readonly) return;
|
|
@@ -2692,7 +2694,7 @@ const I = class I {
|
|
|
2692
2694
|
hour: "2-digit",
|
|
2693
2695
|
minute: "2-digit",
|
|
2694
2696
|
second: "2-digit"
|
|
2695
|
-
}), r = {},
|
|
2697
|
+
}), r = {}, c = (h) => {
|
|
2696
2698
|
o = h, this.revisions.forEach((d, m) => {
|
|
2697
2699
|
var g;
|
|
2698
2700
|
return (g = r[m]) == null ? void 0 : g.classList.toggle("on", m === h);
|
|
@@ -2702,12 +2704,12 @@ const I = class I {
|
|
|
2702
2704
|
const d = this.revisions[h], m = document.createElement("button");
|
|
2703
2705
|
m.type = "button";
|
|
2704
2706
|
const g = (new DOMParser().parseFromString(d.html, "text/html").body.textContent || "").trim(), u = g ? g.split(/\s+/).length : 0, v = h === this.revisions.length - 1;
|
|
2705
|
-
m.innerHTML = `<span>${v ? this.t("currentver") : n.format(new Date(d.time))}</span><span class="wc">${u} ${this.t("words")}</span>`, m.addEventListener("click", () =>
|
|
2707
|
+
m.innerHTML = `<span>${v ? this.t("currentver") : n.format(new Date(d.time))}</span><span class="wc">${u} ${this.t("words")}</span>`, m.addEventListener("click", () => c(h)), r[h] = m, i.appendChild(m);
|
|
2706
2708
|
}
|
|
2707
2709
|
i.append(l), l.addEventListener("click", () => {
|
|
2708
2710
|
const h = this.revisions[o];
|
|
2709
2711
|
h && (this.recordRevision(), this.setContent(h.html), this.recordRevision(), this.closeDlg());
|
|
2710
|
-
}), e.append(i, s), t.appendChild(e),
|
|
2712
|
+
}), e.append(i, s), t.appendChild(e), c(o);
|
|
2711
2713
|
});
|
|
2712
2714
|
}
|
|
2713
2715
|
/* ---------------------------------------------------------- popups / menus */
|
|
@@ -2753,7 +2755,7 @@ const I = class I {
|
|
|
2753
2755
|
return;
|
|
2754
2756
|
}
|
|
2755
2757
|
const s = !!(i.sub || i.subBuild), l = document.createElement("button");
|
|
2756
|
-
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">${
|
|
2758
|
+
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">${a.chev}</span>` : ""}`, l.addEventListener("click", () => {
|
|
2757
2759
|
i.action && (this.closePop(), i.action());
|
|
2758
2760
|
}), l.addEventListener("mouseenter", () => {
|
|
2759
2761
|
var o;
|
|
@@ -2771,13 +2773,13 @@ const I = class I {
|
|
|
2771
2773
|
}
|
|
2772
2774
|
/** Font-size increase / decrease step button. */
|
|
2773
2775
|
stepBtn(t) {
|
|
2774
|
-
const e = t > 0 ? "+" : "−", i = t > 0 ?
|
|
2776
|
+
const e = t > 0 ? "+" : "−", i = t > 0 ? a.fontsizeup : a.fontsizedown, s = this.tbtn(i, this.t("fontsize") + " " + e, () => this.stepFontSize(t));
|
|
2775
2777
|
return s.addEventListener("mousedown", () => this.saveSel()), s;
|
|
2776
2778
|
}
|
|
2777
2779
|
/** Toolbar icon button that opens a popup menu anchored to itself. */
|
|
2778
2780
|
menuTbtn(t, e, i, s) {
|
|
2779
2781
|
const l = this.tbtn(t, e, () => i(l), s);
|
|
2780
|
-
return l.classList.add("hasmenu"), l.insertAdjacentHTML("beforeend",
|
|
2782
|
+
return l.classList.add("hasmenu"), l.insertAdjacentHTML("beforeend", a.chev), l.addEventListener("mousedown", () => this.saveSel()), l;
|
|
2781
2783
|
}
|
|
2782
2784
|
/** Quick text-color chips plus a "more" chip that opens the full palette. */
|
|
2783
2785
|
colorChips() {
|
|
@@ -2790,7 +2792,7 @@ const I = class I {
|
|
|
2790
2792
|
const l = t(this.t("forecolor"));
|
|
2791
2793
|
return l.style.background = s, l.addEventListener("click", () => this.applyColor("fore", s)), l;
|
|
2792
2794
|
}), i = t(this.t("forecolor"));
|
|
2793
|
-
return i.classList.add("more"), i.dataset.cb = "fore", i.innerHTML =
|
|
2795
|
+
return i.classList.add("more"), i.dataset.cb = "fore", i.innerHTML = a.chev, i.addEventListener("click", () => this.colorMenu(i, "fore")), [...e, i];
|
|
2794
2796
|
}
|
|
2795
2797
|
group(...t) {
|
|
2796
2798
|
const e = document.createElement("div");
|
|
@@ -2800,7 +2802,7 @@ const I = class I {
|
|
|
2800
2802
|
}
|
|
2801
2803
|
tsel(t, e, i, s) {
|
|
2802
2804
|
const l = document.createElement("button");
|
|
2803
|
-
return l.className = "tsel " + t, l.type = "button", l.dataset.id = e, l.innerHTML = `<span class="lbl empty">${i || ""}</span>${
|
|
2805
|
+
return l.className = "tsel " + t, l.type = "button", l.dataset.id = e, l.innerHTML = `<span class="lbl empty">${i || ""}</span>${a.chev}`, l.addEventListener("mousedown", (o) => {
|
|
2804
2806
|
o.preventDefault(), this.saveSel();
|
|
2805
2807
|
}), l.addEventListener("click", () => s(l)), l;
|
|
2806
2808
|
}
|
|
@@ -2813,21 +2815,21 @@ const I = class I {
|
|
|
2813
2815
|
s || (this.exec(t === "ol" ? "insertOrderedList" : "insertUnorderedList"), s = (o = this.closestBlock(i.anchorNode)) == null ? void 0 : o.closest(t)), s && (s.style.listStyleType = e), this.saveSel(), this.onChange();
|
|
2814
2816
|
}
|
|
2815
2817
|
listMenu(t, e) {
|
|
2816
|
-
var
|
|
2818
|
+
var c;
|
|
2817
2819
|
const i = e === "ol" ? "insertOrderedList" : "insertUnorderedList", s = e === "ol" ? [
|
|
2818
|
-
["lower-alpha",
|
|
2819
|
-
["lower-roman",
|
|
2820
|
-
["upper-alpha",
|
|
2821
|
-
["upper-roman",
|
|
2820
|
+
["lower-alpha", a.ol_alpha],
|
|
2821
|
+
["lower-roman", a.ol_roman],
|
|
2822
|
+
["upper-alpha", a.ol_alphau],
|
|
2823
|
+
["upper-roman", a.ol_romanu]
|
|
2822
2824
|
] : [
|
|
2823
|
-
["circle",
|
|
2824
|
-
["square",
|
|
2825
|
-
], l = this.tArr(e === "ol" ? "liststyles_ol" : "liststyles_ul").slice(1), o = window.getSelection(), n = o ? (
|
|
2825
|
+
["circle", a.ul_circle],
|
|
2826
|
+
["square", a.ul_square]
|
|
2827
|
+
], l = this.tArr(e === "ol" ? "liststyles_ol" : "liststyles_ul").slice(1), o = window.getSelection(), n = o ? (c = this.closestBlock(o.anchorNode)) == null ? void 0 : c.closest(e) : null, r = n ? n.style.listStyleType : "";
|
|
2826
2828
|
this.popup(t, (h) => {
|
|
2827
2829
|
this.menuItems(h, [
|
|
2828
2830
|
{
|
|
2829
2831
|
label: this.t(e === "ol" ? "numlist" : "bullist"),
|
|
2830
|
-
icon: e === "ol" ?
|
|
2832
|
+
icon: e === "ol" ? a.numlist : a.bullist,
|
|
2831
2833
|
on: document.queryCommandState(i),
|
|
2832
2834
|
action: () => this.exec(i)
|
|
2833
2835
|
}
|
|
@@ -2855,17 +2857,17 @@ const I = class I {
|
|
|
2855
2857
|
const l = document.createElement("div");
|
|
2856
2858
|
l.className = "cfoot";
|
|
2857
2859
|
const o = /^#[0-9a-f]{6}$/i.test(e) ? e : "#000000", n = document.createElement("div");
|
|
2858
|
-
n.className = "cswatch cur", n.title = this.t("currentcolor"), n.style.background = o, n.innerHTML =
|
|
2860
|
+
n.className = "cswatch cur", n.title = this.t("currentcolor"), n.style.background = o, n.innerHTML = a.check;
|
|
2859
2861
|
const r = document.createElement("button");
|
|
2860
2862
|
r.type = "button", r.className = "cswatch nocolor", r.title = this.t("removecolor"), r.addEventListener("click", () => {
|
|
2861
2863
|
this.closePop(), i(null);
|
|
2862
2864
|
});
|
|
2863
|
-
const
|
|
2864
|
-
|
|
2865
|
+
const c = document.createElement("label");
|
|
2866
|
+
c.className = "cswatch cwheel", c.title = this.t("customcolor"), c.innerHTML = a.palette;
|
|
2865
2867
|
const h = document.createElement("input");
|
|
2866
2868
|
h.type = "color", h.value = o, h.addEventListener("change", () => {
|
|
2867
2869
|
this.closePop(), i(h.value);
|
|
2868
|
-
}),
|
|
2870
|
+
}), c.appendChild(h), l.append(n, r, c), t.appendChild(l);
|
|
2869
2871
|
}
|
|
2870
2872
|
colorMenu(t, e) {
|
|
2871
2873
|
this.popup(
|
|
@@ -2883,30 +2885,26 @@ const I = class I {
|
|
|
2883
2885
|
syncColorSwatches(t) {
|
|
2884
2886
|
t.querySelectorAll("[data-cb=fore]").forEach((e) => e.style.background = this.foreColor), t.querySelectorAll("[data-cb=back]").forEach((e) => e.style.background = this.backColor);
|
|
2885
2887
|
}
|
|
2888
|
+
fontItems() {
|
|
2889
|
+
return this.options.fontFamilyFormats.map(([t, e]) => ({
|
|
2890
|
+
label: t,
|
|
2891
|
+
previewStyle: `font-family:${e}`,
|
|
2892
|
+
on: this.currentFont() === t,
|
|
2893
|
+
action: () => this.exec("fontName", e)
|
|
2894
|
+
}));
|
|
2895
|
+
}
|
|
2886
2896
|
fontMenu(t) {
|
|
2887
|
-
this.popup(t, (e) =>
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
}))
|
|
2896
|
-
);
|
|
2897
|
-
});
|
|
2897
|
+
this.popup(t, (e) => this.menuItems(e, this.fontItems()));
|
|
2898
|
+
}
|
|
2899
|
+
sizeItems() {
|
|
2900
|
+
return ot.map((t) => ({
|
|
2901
|
+
label: t,
|
|
2902
|
+
on: this.currentSize() === t,
|
|
2903
|
+
action: () => this.applyFontSize(t)
|
|
2904
|
+
}));
|
|
2898
2905
|
}
|
|
2899
2906
|
sizeMenu(t) {
|
|
2900
|
-
this.popup(t, (e) =>
|
|
2901
|
-
this.menuItems(
|
|
2902
|
-
e,
|
|
2903
|
-
it.map((i) => ({
|
|
2904
|
-
label: i,
|
|
2905
|
-
on: this.currentSize() === i,
|
|
2906
|
-
action: () => this.applyFontSize(i)
|
|
2907
|
-
}))
|
|
2908
|
-
);
|
|
2909
|
-
});
|
|
2907
|
+
this.popup(t, (e) => this.menuItems(e, this.sizeItems()));
|
|
2910
2908
|
}
|
|
2911
2909
|
/** Font sizing needs a non-collapsed range. With a bare caret, grow the
|
|
2912
2910
|
selection to the word under it; in an empty spot, select a zero-width
|
|
@@ -2926,8 +2924,8 @@ const I = class I {
|
|
|
2926
2924
|
for (; n > 0 && /\S/.test(o[n - 1]); ) n--;
|
|
2927
2925
|
for (; r < o.length && /\S/.test(o[r]); ) r++;
|
|
2928
2926
|
if (r > n) {
|
|
2929
|
-
const
|
|
2930
|
-
|
|
2927
|
+
const c = document.createRange();
|
|
2928
|
+
c.setStart(i, n), c.setEnd(i, r), t.removeAllRanges(), t.addRange(c), this.savedRange = c.cloneRange();
|
|
2931
2929
|
return;
|
|
2932
2930
|
}
|
|
2933
2931
|
}
|
|
@@ -2952,7 +2950,7 @@ const I = class I {
|
|
|
2952
2950
|
this.saveSel(), this.refreshState(), this.onChange();
|
|
2953
2951
|
}
|
|
2954
2952
|
stepFontSize(t) {
|
|
2955
|
-
const e = parseInt(this.currentSize(), 10) || 14, i = Math.min(
|
|
2953
|
+
const e = parseInt(this.currentSize(), 10) || 14, i = Math.min(rt, Math.max(nt, e + t));
|
|
2956
2954
|
i !== e && this.applyFontSize(i + "px");
|
|
2957
2955
|
}
|
|
2958
2956
|
/* ------------------------------------------------ case / spacing / link */
|
|
@@ -2964,21 +2962,22 @@ const I = class I {
|
|
|
2964
2962
|
let o;
|
|
2965
2963
|
for (; o = s.nextNode(); ) i.intersectsNode(o) && l.push(o);
|
|
2966
2964
|
l.forEach((n) => {
|
|
2967
|
-
const r = n === i.startContainer ? i.startOffset : 0,
|
|
2968
|
-
if (
|
|
2969
|
-
const h = n.data.slice(r,
|
|
2965
|
+
const r = n === i.startContainer ? i.startOffset : 0, c = n === i.endContainer ? i.endOffset : n.data.length;
|
|
2966
|
+
if (c <= r) return;
|
|
2967
|
+
const h = n.data.slice(r, c);
|
|
2970
2968
|
let d = h;
|
|
2971
|
-
t === "lower" ? d = h.toLowerCase() : t === "upper" ? d = h.toUpperCase() : d = h.replace(/(^|\s)(\S)/g, (m, g, u) => g + u.toUpperCase()), n.replaceData(r,
|
|
2969
|
+
t === "lower" ? d = h.toLowerCase() : t === "upper" ? d = h.toUpperCase() : d = h.replace(/(^|\s)(\S)/g, (m, g, u) => g + u.toUpperCase()), n.replaceData(r, c - r, d);
|
|
2972
2970
|
}), this.saveSel(), this.refreshState(), this.onChange();
|
|
2973
2971
|
}
|
|
2972
|
+
caseItems() {
|
|
2973
|
+
return [
|
|
2974
|
+
{ label: this.t("lowercase"), icon: a.lowercaseic, action: () => this.transformCase("lower") },
|
|
2975
|
+
{ label: this.t("uppercase"), icon: a.uppercaseic, action: () => this.transformCase("upper") },
|
|
2976
|
+
{ label: this.t("capitalize"), icon: a.capitalizeic, action: () => this.transformCase("capitalize") }
|
|
2977
|
+
];
|
|
2978
|
+
}
|
|
2974
2979
|
caseMenu(t) {
|
|
2975
|
-
this.popup(t, (e) =>
|
|
2976
|
-
this.menuItems(e, [
|
|
2977
|
-
{ label: this.t("lowercase"), icon: c.lowercaseic, action: () => this.transformCase("lower") },
|
|
2978
|
-
{ label: this.t("uppercase"), icon: c.uppercaseic, action: () => this.transformCase("upper") },
|
|
2979
|
-
{ label: this.t("capitalize"), icon: c.capitalizeic, action: () => this.transformCase("capitalize") }
|
|
2980
|
-
]);
|
|
2981
|
-
});
|
|
2980
|
+
this.popup(t, (e) => this.menuItems(e, this.caseItems()));
|
|
2982
2981
|
}
|
|
2983
2982
|
applyBlockStyle(t, e) {
|
|
2984
2983
|
this.restoreSel();
|
|
@@ -2991,44 +2990,25 @@ const I = class I {
|
|
|
2991
2990
|
const e = window.getSelection(), i = e ? this.closestBlock(e.anchorNode) : null;
|
|
2992
2991
|
return i && i.style[t] || "";
|
|
2993
2992
|
}
|
|
2993
|
+
blockStyleItems(t, e) {
|
|
2994
|
+
const i = this.currentBlockStyle(t);
|
|
2995
|
+
return [
|
|
2996
|
+
{ label: this.t("normal"), on: !i, action: () => this.applyBlockStyle(t, "") },
|
|
2997
|
+
...e.map((s) => ({
|
|
2998
|
+
label: s,
|
|
2999
|
+
on: i === s,
|
|
3000
|
+
action: () => this.applyBlockStyle(t, s)
|
|
3001
|
+
}))
|
|
3002
|
+
];
|
|
3003
|
+
}
|
|
2994
3004
|
lineHeightMenu(t) {
|
|
2995
|
-
|
|
2996
|
-
this.popup(t, (i) => {
|
|
2997
|
-
this.menuItems(i, [
|
|
2998
|
-
{ label: this.t("normal"), on: !e, action: () => this.applyBlockStyle("lineHeight", "") },
|
|
2999
|
-
...ot.map((s) => ({
|
|
3000
|
-
label: s,
|
|
3001
|
-
on: e === s,
|
|
3002
|
-
action: () => this.applyBlockStyle("lineHeight", s)
|
|
3003
|
-
}))
|
|
3004
|
-
]);
|
|
3005
|
-
});
|
|
3005
|
+
this.popup(t, (e) => this.menuItems(e, this.blockStyleItems("lineHeight", _)));
|
|
3006
3006
|
}
|
|
3007
3007
|
wordSpacingMenu(t) {
|
|
3008
|
-
|
|
3009
|
-
this.popup(t, (i) => {
|
|
3010
|
-
this.menuItems(i, [
|
|
3011
|
-
{ label: this.t("normal"), on: !e, action: () => this.applyBlockStyle("wordSpacing", "") },
|
|
3012
|
-
...nt.map((s) => ({
|
|
3013
|
-
label: s,
|
|
3014
|
-
on: e === s,
|
|
3015
|
-
action: () => this.applyBlockStyle("wordSpacing", s)
|
|
3016
|
-
}))
|
|
3017
|
-
]);
|
|
3018
|
-
});
|
|
3008
|
+
this.popup(t, (e) => this.menuItems(e, this.blockStyleItems("wordSpacing", V)));
|
|
3019
3009
|
}
|
|
3020
3010
|
letterSpacingMenu(t) {
|
|
3021
|
-
|
|
3022
|
-
this.popup(t, (i) => {
|
|
3023
|
-
this.menuItems(i, [
|
|
3024
|
-
{ label: this.t("normal"), on: !e, action: () => this.applyBlockStyle("letterSpacing", "") },
|
|
3025
|
-
...rt.map((s) => ({
|
|
3026
|
-
label: s,
|
|
3027
|
-
on: e === s,
|
|
3028
|
-
action: () => this.applyBlockStyle("letterSpacing", s)
|
|
3029
|
-
}))
|
|
3030
|
-
]);
|
|
3031
|
-
});
|
|
3011
|
+
this.popup(t, (e) => this.menuItems(e, this.blockStyleItems("letterSpacing", W)));
|
|
3032
3012
|
}
|
|
3033
3013
|
closestAnchor() {
|
|
3034
3014
|
const t = window.getSelection();
|
|
@@ -3080,18 +3060,29 @@ const I = class I {
|
|
|
3080
3060
|
i
|
|
3081
3061
|
);
|
|
3082
3062
|
}
|
|
3063
|
+
blockItems() {
|
|
3064
|
+
return j.map(([t]) => ({
|
|
3065
|
+
label: this.blockLabel(t),
|
|
3066
|
+
previewStyle: t.startsWith("h") ? `font-weight:700;font-size:${22 - 2 * +t[1]}px` : t === "pre" ? "font-family:monospace" : "",
|
|
3067
|
+
on: this.currentBlock() === t,
|
|
3068
|
+
action: () => this.exec("formatBlock", "<" + t + ">")
|
|
3069
|
+
}));
|
|
3070
|
+
}
|
|
3083
3071
|
blocksMenu(t) {
|
|
3084
|
-
this.popup(t, (e) =>
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
)
|
|
3094
|
-
|
|
3072
|
+
this.popup(t, (e) => this.menuItems(e, this.blockItems()));
|
|
3073
|
+
}
|
|
3074
|
+
alignItems() {
|
|
3075
|
+
return [
|
|
3076
|
+
["justifyLeft", "alignleft", a.alignleft],
|
|
3077
|
+
["justifyCenter", "aligncenter", a.aligncenter],
|
|
3078
|
+
["justifyRight", "alignright", a.alignright],
|
|
3079
|
+
["justifyFull", "alignjustify", a.alignjustify]
|
|
3080
|
+
].map(([e, i, s]) => ({
|
|
3081
|
+
label: this.t(i),
|
|
3082
|
+
icon: s,
|
|
3083
|
+
on: document.queryCommandState(e),
|
|
3084
|
+
action: () => this.exec(e)
|
|
3085
|
+
}));
|
|
3095
3086
|
}
|
|
3096
3087
|
blockLabel(t) {
|
|
3097
3088
|
return t === "p" ? this.t("para") : t === "pre" ? this.t("pre") : this.t("heading") + " " + t[1];
|
|
@@ -3110,12 +3101,12 @@ const I = class I {
|
|
|
3110
3101
|
const o = [];
|
|
3111
3102
|
for (let n = 0; n < 8; n++)
|
|
3112
3103
|
for (let r = 0; r < 10; r++) {
|
|
3113
|
-
const
|
|
3114
|
-
|
|
3104
|
+
const c = document.createElement("span");
|
|
3105
|
+
c.dataset.r = String(n), c.dataset.c = String(r), c.addEventListener("mouseenter", () => {
|
|
3115
3106
|
o.forEach((h) => h.classList.toggle("hot", +h.dataset.r <= n && +h.dataset.c <= r)), l.textContent = r + 1 + " × " + (n + 1);
|
|
3116
|
-
}),
|
|
3107
|
+
}), c.addEventListener("click", () => {
|
|
3117
3108
|
this.closePop(), this.insertTable(n + 1, r + 1), e == null || e();
|
|
3118
|
-
}), o.push(
|
|
3109
|
+
}), o.push(c), s.appendChild(c);
|
|
3119
3110
|
}
|
|
3120
3111
|
i.append(s, l), t.appendChild(i);
|
|
3121
3112
|
}
|
|
@@ -3146,61 +3137,61 @@ const I = class I {
|
|
|
3146
3137
|
* behavior changes, just named lookup. Only `forecolor` yields multiple elements
|
|
3147
3138
|
* (the quick color chips); everything else yields one. */
|
|
3148
3139
|
buildToolbarRegistry() {
|
|
3149
|
-
const t = this.tbtn(
|
|
3150
|
-
undo: () => this.tbtn(
|
|
3151
|
-
redo: () => this.tbtn(
|
|
3152
|
-
preview: () => this.tbtn(
|
|
3153
|
-
print: () => this.tbtn(
|
|
3154
|
-
importword: () => this.tbtn(
|
|
3155
|
-
revhistory: () => this.tbtn(
|
|
3140
|
+
const t = this.tbtn(a.tableic, this.t("quicktable"), () => this.tableGrid(t)), e = {
|
|
3141
|
+
undo: () => this.tbtn(a.undo, this.t("undo"), () => this.exec("undo")),
|
|
3142
|
+
redo: () => this.tbtn(a.redo, this.t("redo"), () => this.exec("redo")),
|
|
3143
|
+
preview: () => this.tbtn(a.prevw, this.t("preview"), () => this.previewDlg()),
|
|
3144
|
+
print: () => this.tbtn(a.printic, this.t("print"), () => this.printDoc()),
|
|
3145
|
+
importword: () => this.tbtn(a.wordic, this.t("importword"), () => this.pickWordDoc()),
|
|
3146
|
+
revhistory: () => this.tbtn(a.historyic, this.t("revhistory"), () => this.revisionDlg()),
|
|
3156
3147
|
fontfamily: () => this.tsel("w-font", "fontsel", "", (i) => this.fontMenu(i)),
|
|
3157
3148
|
fontsize: () => this.tsel("w-size", "sizesel", "", (i) => this.sizeMenu(i)),
|
|
3158
3149
|
fontsizeincrease: () => this.stepBtn(1),
|
|
3159
3150
|
fontsizedecrease: () => this.stepBtn(-1),
|
|
3160
|
-
bold: () => this.tbtn(
|
|
3161
|
-
italic: () => this.tbtn(
|
|
3162
|
-
underline: () => this.tbtn(
|
|
3163
|
-
strikethrough: () => this.tbtn(
|
|
3151
|
+
bold: () => this.tbtn(a.bold, this.t("bold"), () => this.exec("bold"), "bold"),
|
|
3152
|
+
italic: () => this.tbtn(a.italic, this.t("italic"), () => this.exec("italic"), "italic"),
|
|
3153
|
+
underline: () => this.tbtn(a.underline, this.t("underline"), () => this.exec("underline"), "underline"),
|
|
3154
|
+
strikethrough: () => this.tbtn(a.strikethrough, this.t("strikethrough"), () => this.exec("strikeThrough"), "strikeThrough"),
|
|
3164
3155
|
forecolor: () => this.colorChips(),
|
|
3165
3156
|
backcolor: () => this.menuTbtn(
|
|
3166
|
-
|
|
3157
|
+
a.backcolor + '<span class="colorbar" data-cb="back"></span>',
|
|
3167
3158
|
this.t("backcolor"),
|
|
3168
3159
|
(i) => this.colorMenu(i, "back")
|
|
3169
3160
|
),
|
|
3170
|
-
alignleft: () => this.tbtn(
|
|
3171
|
-
aligncenter: () => this.tbtn(
|
|
3172
|
-
alignright: () => this.tbtn(
|
|
3173
|
-
alignjustify: () => this.tbtn(
|
|
3174
|
-
bullist: () => this.menuTbtn(
|
|
3175
|
-
numlist: () => this.menuTbtn(
|
|
3176
|
-
outdent: () => this.tbtn(
|
|
3177
|
-
indent: () => this.tbtn(
|
|
3178
|
-
link: () => this.tbtn(
|
|
3179
|
-
blockquote: () => this.tbtn(
|
|
3180
|
-
code: () => this.tbtn(
|
|
3181
|
-
codesample: () => this.tbtn(
|
|
3182
|
-
changecase: () => this.menuTbtn(
|
|
3183
|
-
lineheight: () => this.menuTbtn(
|
|
3184
|
-
wordspacing: () => this.menuTbtn(
|
|
3185
|
-
letterspacing: () => this.menuTbtn(
|
|
3186
|
-
removeformat: () => this.tbtn(
|
|
3161
|
+
alignleft: () => this.tbtn(a.alignleft, this.t("alignleft"), () => this.exec("justifyLeft"), "justifyLeft"),
|
|
3162
|
+
aligncenter: () => this.tbtn(a.aligncenter, this.t("aligncenter"), () => this.exec("justifyCenter"), "justifyCenter"),
|
|
3163
|
+
alignright: () => this.tbtn(a.alignright, this.t("alignright"), () => this.exec("justifyRight"), "justifyRight"),
|
|
3164
|
+
alignjustify: () => this.tbtn(a.alignjustify, this.t("alignjustify"), () => this.exec("justifyFull"), "justifyFull"),
|
|
3165
|
+
bullist: () => this.menuTbtn(a.bullist, this.t("bullist"), (i) => this.listMenu(i, "ul"), "insertUnorderedList"),
|
|
3166
|
+
numlist: () => this.menuTbtn(a.numlist, this.t("numlist"), (i) => this.listMenu(i, "ol"), "insertOrderedList"),
|
|
3167
|
+
outdent: () => this.tbtn(a.outdent, this.t("outdent"), () => this.exec("outdent")),
|
|
3168
|
+
indent: () => this.tbtn(a.indent, this.t("indent"), () => this.exec("indent")),
|
|
3169
|
+
link: () => this.tbtn(a.link, this.t("linkttl"), () => this.linkDlg()),
|
|
3170
|
+
blockquote: () => this.tbtn(a.quote, this.t("quote"), () => this.toggleBlock("blockquote"), "blockquote"),
|
|
3171
|
+
code: () => this.tbtn(a.inlinecodeic, this.t("code"), () => this.toggleInlineCode(), "code"),
|
|
3172
|
+
codesample: () => this.tbtn(a.codesampleic, this.t("codesample"), () => this.codeDlg()),
|
|
3173
|
+
changecase: () => this.menuTbtn(a.caseic, this.t("changecase"), (i) => this.caseMenu(i)),
|
|
3174
|
+
lineheight: () => this.menuTbtn(a.lineheight, this.t("lineheight"), (i) => this.lineHeightMenu(i)),
|
|
3175
|
+
wordspacing: () => this.menuTbtn(a.wordspacing, this.t("wordspacing"), (i) => this.wordSpacingMenu(i)),
|
|
3176
|
+
letterspacing: () => this.menuTbtn(a.letterspacing, this.t("letterspacing"), (i) => this.letterSpacingMenu(i)),
|
|
3177
|
+
removeformat: () => this.tbtn(a.clearformatic, this.t("removeformat"), () => this.exec("removeFormat")),
|
|
3187
3178
|
blocks: () => this.tsel("w-block", "blocksel", this.t("para"), (i) => this.blocksMenu(i)),
|
|
3188
|
-
ltr: () => this.tbtn(
|
|
3189
|
-
rtl: () => this.tbtn(
|
|
3190
|
-
quickimage: () => this.tbtn(
|
|
3191
|
-
quickvideo: () => this.tbtn(
|
|
3179
|
+
ltr: () => this.tbtn(a.ltr, this.t("ltr"), () => this.setDir("ltr"), "ltr"),
|
|
3180
|
+
rtl: () => this.tbtn(a.rtl, this.t("rtl"), () => this.setDir("rtl"), "rtl"),
|
|
3181
|
+
quickimage: () => this.tbtn(a.image, this.t("quickimage"), () => this.insertImagePlaceholder()),
|
|
3182
|
+
quickvideo: () => this.tbtn(a.video, this.t("quickvideo"), () => this.videoDlg()),
|
|
3192
3183
|
quicktable: () => t,
|
|
3193
|
-
template: () => this.menuTbtn(
|
|
3194
|
-
charmap: () => this.tbtn(
|
|
3195
|
-
emoji: () => this.tbtn(
|
|
3196
|
-
fullscreen: () => this.tbtn(
|
|
3197
|
-
sourcecode: () => this.tbtn(
|
|
3184
|
+
template: () => this.menuTbtn(a.templateic, this.t("template"), (i) => this.templateMenu(i)),
|
|
3185
|
+
charmap: () => this.tbtn(a.charic, this.t("charmap"), () => this.charMap()),
|
|
3186
|
+
emoji: () => this.tbtn(a.emojiic, this.t("emoji"), () => this.emojiMap()),
|
|
3187
|
+
fullscreen: () => this.tbtn(a.fullscreen, this.t("fullscreen"), () => this.toggleFullscreen(), "fullscreen"),
|
|
3188
|
+
sourcecode: () => this.tbtn(a.srcic, this.t("sourcecode"), () => this.sourceDlg())
|
|
3198
3189
|
};
|
|
3199
3190
|
return e.styles = e.blocks, e.image = e.quickimage, e.media = e.quickvideo, e.table = e.quicktable, e;
|
|
3200
3191
|
}
|
|
3201
3192
|
buildToolbar() {
|
|
3202
3193
|
this.toolbar.innerHTML = "";
|
|
3203
|
-
const t = this.options.toolbar === !0 ?
|
|
3194
|
+
const t = this.options.toolbar === !0 ? it : this.options.toolbar, e = this.buildToolbarRegistry();
|
|
3204
3195
|
this.parseToolbarString(t).forEach((i) => {
|
|
3205
3196
|
const s = [];
|
|
3206
3197
|
i.forEach((l) => {
|
|
@@ -3212,7 +3203,7 @@ const I = class I {
|
|
|
3212
3203
|
const n = o();
|
|
3213
3204
|
Array.isArray(n) ? s.push(...n) : s.push(n);
|
|
3214
3205
|
}), s.length && this.toolbar.appendChild(this.group(...s));
|
|
3215
|
-
}), this.tbrMore = this.tbtn(
|
|
3206
|
+
}), this.tbrMore = this.tbtn(a.more, this.t("more"), () => {
|
|
3216
3207
|
this.tbrExpanded = !this.tbrExpanded, this.updateToolbarOverflow();
|
|
3217
3208
|
}), this.tbrMore.classList.add("tbr-more"), this.toolbar.appendChild(this.tbrMore), this.syncColorSwatches(this.toolbar), this.updateToolbarOverflow();
|
|
3218
3209
|
}
|
|
@@ -3227,7 +3218,7 @@ const I = class I {
|
|
|
3227
3218
|
t.classList.add("tbr-measure");
|
|
3228
3219
|
const e = t.scrollWidth > t.clientWidth + 1;
|
|
3229
3220
|
t.classList.remove("tbr-measure");
|
|
3230
|
-
const i = this.shell.offsetWidth <
|
|
3221
|
+
const i = this.shell.offsetWidth < A.TBR_COLLAPSE_MAX;
|
|
3231
3222
|
if (!e || !i) {
|
|
3232
3223
|
this.tbrExpanded = !1, t.classList.remove("collapsible", "expanded"), this.tbrMore.classList.remove("on");
|
|
3233
3224
|
return;
|
|
@@ -3242,116 +3233,134 @@ const I = class I {
|
|
|
3242
3233
|
this.menubar.innerHTML = "";
|
|
3243
3234
|
const t = {
|
|
3244
3235
|
file: [
|
|
3245
|
-
this.mItem("newdoc",
|
|
3236
|
+
this.mItem("newdoc", a.newic, () => {
|
|
3246
3237
|
this.recordRevision(), this.ed.innerHTML = "<p><br></p>", this.onChange();
|
|
3247
3238
|
}),
|
|
3248
3239
|
"|",
|
|
3249
|
-
this.mItem("importword",
|
|
3250
|
-
this.mItem("restoredraft",
|
|
3240
|
+
this.mItem("importword", a.wordic, () => this.pickWordDoc()),
|
|
3241
|
+
this.mItem("restoredraft", a.draftic, () => {
|
|
3251
3242
|
this.restoreDraft() || alert(this.t("draftempty"));
|
|
3252
3243
|
}),
|
|
3253
|
-
this.mItem("revhistory",
|
|
3244
|
+
this.mItem("revhistory", a.historyic, () => this.revisionDlg()),
|
|
3254
3245
|
"|",
|
|
3255
|
-
this.mItem("preview",
|
|
3256
|
-
this.mItem("print",
|
|
3246
|
+
this.mItem("preview", a.prevw, () => this.previewDlg()),
|
|
3247
|
+
this.mItem("print", a.printic, () => this.printDoc(), "Ctrl+P")
|
|
3257
3248
|
],
|
|
3258
3249
|
edit: [
|
|
3259
|
-
this.mItem("undo",
|
|
3260
|
-
this.mItem("redo",
|
|
3250
|
+
this.mItem("undo", a.undo, () => this.exec("undo"), "Ctrl+Z"),
|
|
3251
|
+
this.mItem("redo", a.redo, () => this.exec("redo"), "Ctrl+Y"),
|
|
3261
3252
|
"|",
|
|
3262
|
-
this.mItem("cut",
|
|
3263
|
-
this.mItem("copy",
|
|
3264
|
-
this.mItem("paste",
|
|
3253
|
+
this.mItem("cut", a.cutic, () => this.exec("cut"), "Ctrl+X"),
|
|
3254
|
+
this.mItem("copy", a.copyic, () => this.exec("copy"), "Ctrl+C"),
|
|
3255
|
+
this.mItem("paste", a.pasteic, () => alert(this.t("pastehint")), "Ctrl+V"),
|
|
3265
3256
|
"|",
|
|
3266
|
-
this.mItem("selectall",
|
|
3257
|
+
this.mItem("selectall", a.selall, () => this.exec("selectAll"), "Ctrl+A")
|
|
3267
3258
|
],
|
|
3268
3259
|
view: [
|
|
3269
|
-
this.mItem("fullscreen",
|
|
3270
|
-
this.mItem("preview",
|
|
3271
|
-
this.mItem("sourcecode",
|
|
3260
|
+
this.mItem("fullscreen", a.fullscreen, () => this.toggleFullscreen()),
|
|
3261
|
+
this.mItem("preview", a.prevw, () => this.previewDlg()),
|
|
3262
|
+
this.mItem("sourcecode", a.srcic, () => this.sourceDlg())
|
|
3272
3263
|
],
|
|
3273
3264
|
insert: [
|
|
3274
|
-
this.mItem("link",
|
|
3275
|
-
this.mItem("image",
|
|
3276
|
-
this.mItem("video",
|
|
3277
|
-
{ label: this.t("inserttable"), icon:
|
|
3278
|
-
this.mItem("codesample",
|
|
3279
|
-
{ label: this.t("template"), icon:
|
|
3280
|
-
this.mItem("hr",
|
|
3265
|
+
this.mItem("link", a.link, () => this.linkDlg()),
|
|
3266
|
+
this.mItem("image", a.image, () => this.insertImagePlaceholder()),
|
|
3267
|
+
this.mItem("video", a.video, () => this.videoDlg()),
|
|
3268
|
+
{ label: this.t("inserttable"), icon: a.tableic, action: () => this.tableGrid(this.menubar.querySelector('[data-menu-key="table"]') || this.menubar) },
|
|
3269
|
+
this.mItem("codesample", a.codesampleic, () => this.codeDlg()),
|
|
3270
|
+
{ label: this.t("template"), icon: a.templateic, subBuild: (s) => this.buildTemplatePickInto(s) },
|
|
3271
|
+
this.mItem("hr", a.hric, () => this.exec("insertHorizontalRule")),
|
|
3281
3272
|
"|",
|
|
3282
|
-
this.mItem("charmap",
|
|
3283
|
-
this.mItem("emoji",
|
|
3273
|
+
this.mItem("charmap", a.charic, () => this.charMap()),
|
|
3274
|
+
this.mItem("emoji", a.emojiic, () => this.emojiMap()),
|
|
3284
3275
|
this.mItem(
|
|
3285
3276
|
"datetime",
|
|
3286
|
-
|
|
3277
|
+
a.dateic,
|
|
3287
3278
|
() => this.exec("insertText", (/* @__PURE__ */ new Date()).toLocaleString(this.lang === "ar" ? "ar-AE" : "en-GB"))
|
|
3288
3279
|
),
|
|
3289
3280
|
"|",
|
|
3290
3281
|
{
|
|
3291
3282
|
label: this.t("pagebreak"),
|
|
3292
|
-
icon:
|
|
3283
|
+
icon: a.pbic,
|
|
3293
3284
|
action: () => {
|
|
3294
3285
|
this.restoreSel(), document.execCommand("insertHTML", !1, '<hr class="pagebreak"><p><br></p>'), this.onChange();
|
|
3295
3286
|
}
|
|
3296
3287
|
},
|
|
3297
|
-
this.mItem("nbsp",
|
|
3288
|
+
this.mItem("nbsp", a.nbspic, () => this.exec("insertText", " "))
|
|
3298
3289
|
],
|
|
3299
3290
|
format: [
|
|
3300
|
-
this.mItem("bold",
|
|
3301
|
-
this.mItem("italic",
|
|
3302
|
-
this.mItem("underline",
|
|
3303
|
-
this.mItem("strikethrough",
|
|
3304
|
-
this.mItem("superscript",
|
|
3305
|
-
this.mItem("subscript",
|
|
3306
|
-
this.mItem("code",
|
|
3291
|
+
this.mItem("bold", a.bold, () => this.exec("bold"), "Ctrl+B"),
|
|
3292
|
+
this.mItem("italic", a.italic, () => this.exec("italic"), "Ctrl+I"),
|
|
3293
|
+
this.mItem("underline", a.underline, () => this.exec("underline"), "Ctrl+U"),
|
|
3294
|
+
this.mItem("strikethrough", a.strikethrough, () => this.exec("strikeThrough")),
|
|
3295
|
+
this.mItem("superscript", a.superscriptic, () => this.exec("superscript")),
|
|
3296
|
+
this.mItem("subscript", a.subscriptic, () => this.exec("subscript")),
|
|
3297
|
+
this.mItem("code", a.inlinecodeic, () => this.toggleInlineCode()),
|
|
3298
|
+
this.mItem("quote", a.quote, () => this.toggleBlock("blockquote")),
|
|
3299
|
+
"|",
|
|
3300
|
+
{ label: this.t("fontfamily"), subBuild: (s) => this.menuItems(s, this.fontItems()) },
|
|
3301
|
+
{ label: this.t("fontsize"), subBuild: (s) => this.menuItems(s, this.sizeItems()) },
|
|
3302
|
+
{ label: this.t("blocks"), subBuild: (s) => this.menuItems(s, this.blockItems()) },
|
|
3303
|
+
{ label: this.t("align"), subBuild: (s) => this.menuItems(s, this.alignItems()) },
|
|
3304
|
+
{ label: this.t("lineheight"), icon: a.lineheight, subBuild: (s) => this.menuItems(s, this.blockStyleItems("lineHeight", _)) },
|
|
3305
|
+
{ label: this.t("wordspacing"), icon: a.wordspacing, subBuild: (s) => this.menuItems(s, this.blockStyleItems("wordSpacing", V)) },
|
|
3306
|
+
{ label: this.t("letterspacing"), icon: a.letterspacing, subBuild: (s) => this.menuItems(s, this.blockStyleItems("letterSpacing", W)) },
|
|
3307
|
+
"|",
|
|
3308
|
+
{ label: this.t("forecolor"), icon: a.palette, subBuild: (s) => this.buildPaletteInto(s, this.foreColor, (l) => this.applyColor("fore", l)) },
|
|
3309
|
+
{ label: this.t("backcolor"), icon: a.backcolor, subBuild: (s) => this.buildPaletteInto(s, this.backColor, (l) => this.applyColor("back", l)) },
|
|
3310
|
+
"|",
|
|
3311
|
+
this.mItem("bullist", a.bullist, () => this.exec("insertUnorderedList")),
|
|
3312
|
+
this.mItem("numlist", a.numlist, () => this.exec("insertOrderedList")),
|
|
3313
|
+
this.mItem("outdent", a.outdent, () => this.exec("outdent")),
|
|
3314
|
+
this.mItem("indent", a.indent, () => this.exec("indent")),
|
|
3315
|
+
"|",
|
|
3316
|
+
this.mItem("ltr", a.ltr, () => this.setDir("ltr")),
|
|
3317
|
+
this.mItem("rtl", a.rtl, () => this.setDir("rtl")),
|
|
3307
3318
|
"|",
|
|
3308
|
-
this.
|
|
3309
|
-
this.mItem("uppercase", c.uppercaseic, () => this.transformCase("upper")),
|
|
3310
|
-
this.mItem("capitalize", c.capitalizeic, () => this.transformCase("capitalize")),
|
|
3319
|
+
{ label: this.t("changecase"), icon: a.caseic, sub: this.caseItems() },
|
|
3311
3320
|
"|",
|
|
3312
|
-
this.mItem("clearformat",
|
|
3321
|
+
this.mItem("clearformat", a.clearformatic, () => this.exec("removeFormat"))
|
|
3313
3322
|
],
|
|
3314
|
-
tools: [this.mItem("sourcecode",
|
|
3323
|
+
tools: [this.mItem("sourcecode", a.srcic, () => this.sourceDlg()), this.mItem("wordcount", a.wcic, () => this.wordCountDlg())],
|
|
3315
3324
|
table: [
|
|
3316
|
-
{ label: this.t("inserttable"), icon:
|
|
3325
|
+
{ label: this.t("inserttable"), icon: a.tableic, subBuild: (s) => this.buildTableGridInto(s) },
|
|
3317
3326
|
"|",
|
|
3318
3327
|
{
|
|
3319
3328
|
label: this.t("cell"),
|
|
3320
3329
|
sub: [
|
|
3321
|
-
{ label: this.t("cellprops"), icon:
|
|
3322
|
-
{ label: this.t("cellbg"), icon:
|
|
3330
|
+
{ label: this.t("cellprops"), icon: a.tableic, action: () => this.cellPropsDlg() },
|
|
3331
|
+
{ label: this.t("cellbg"), icon: a.palette, subBuild: (s) => this.buildCellFillInto(s) }
|
|
3323
3332
|
]
|
|
3324
3333
|
},
|
|
3325
3334
|
{
|
|
3326
3335
|
label: this.t("row"),
|
|
3327
3336
|
sub: [
|
|
3328
|
-
{ label: this.t("rowabove"), icon:
|
|
3329
|
-
{ label: this.t("rowbelow"), icon:
|
|
3330
|
-
{ label: this.t("delrow"), icon:
|
|
3337
|
+
{ label: this.t("rowabove"), icon: a.rowbefore, action: () => this.tableOp("rowabove"), hover: (s) => this.setOpTarget(s ? "row" : null) },
|
|
3338
|
+
{ label: this.t("rowbelow"), icon: a.rowafter, action: () => this.tableOp("rowbelow"), hover: (s) => this.setOpTarget(s ? "row" : null) },
|
|
3339
|
+
{ label: this.t("delrow"), icon: a.rowdelete, action: () => this.tableOp("delrow"), hover: (s) => this.setOpTarget(s ? "row" : null) },
|
|
3331
3340
|
"|",
|
|
3332
|
-
{ label: this.t("moverowup"), icon:
|
|
3333
|
-
{ label: this.t("moverowdown"), icon:
|
|
3341
|
+
{ label: this.t("moverowup"), icon: a.moverowup, action: () => this.tableMove("rowup"), hover: (s) => this.setOpTarget(s ? "row" : null) },
|
|
3342
|
+
{ label: this.t("moverowdown"), icon: a.moverowdown, action: () => this.tableMove("rowdown"), hover: (s) => this.setOpTarget(s ? "row" : null) },
|
|
3334
3343
|
"|",
|
|
3335
|
-
{ label: this.t("rowprops"), icon:
|
|
3344
|
+
{ label: this.t("rowprops"), icon: a.tableic, action: () => this.rowPropsDlg(), hover: (s) => this.setOpTarget(s ? "row" : null) }
|
|
3336
3345
|
]
|
|
3337
3346
|
},
|
|
3338
3347
|
{
|
|
3339
3348
|
label: this.t("column"),
|
|
3340
3349
|
sub: [
|
|
3341
|
-
{ label: this.t("colbefore"), icon:
|
|
3342
|
-
{ label: this.t("colafter"), icon:
|
|
3343
|
-
{ label: this.t("delcol"), icon:
|
|
3350
|
+
{ label: this.t("colbefore"), icon: a.colbefore, action: () => this.tableOp("colbefore"), hover: (s) => this.setOpTarget(s ? "col" : null) },
|
|
3351
|
+
{ label: this.t("colafter"), icon: a.colafter, action: () => this.tableOp("colafter"), hover: (s) => this.setOpTarget(s ? "col" : null) },
|
|
3352
|
+
{ label: this.t("delcol"), icon: a.coldelete, action: () => this.tableOp("delcol"), hover: (s) => this.setOpTarget(s ? "col" : null) },
|
|
3344
3353
|
"|",
|
|
3345
|
-
{ label: this.t("movecolleft"), icon:
|
|
3346
|
-
{ label: this.t("movecolright"), icon:
|
|
3354
|
+
{ label: this.t("movecolleft"), icon: a.movecolleft, action: () => this.tableMove("colleft"), hover: (s) => this.setOpTarget(s ? "col" : null) },
|
|
3355
|
+
{ label: this.t("movecolright"), icon: a.movecolright, action: () => this.tableMove("colright"), hover: (s) => this.setOpTarget(s ? "col" : null) },
|
|
3347
3356
|
"|",
|
|
3348
|
-
{ label: this.t("colprops"), icon:
|
|
3357
|
+
{ label: this.t("colprops"), icon: a.tableic, action: () => this.colPropsDlg(), hover: (s) => this.setOpTarget(s ? "col" : null) }
|
|
3349
3358
|
]
|
|
3350
3359
|
},
|
|
3351
3360
|
"|",
|
|
3352
3361
|
{
|
|
3353
3362
|
label: this.t("tablepropsttl"),
|
|
3354
|
-
icon:
|
|
3363
|
+
icon: a.tableic,
|
|
3355
3364
|
action: () => {
|
|
3356
3365
|
const s = this.currentCell();
|
|
3357
3366
|
if (!s) {
|
|
@@ -3361,10 +3370,10 @@ const I = class I {
|
|
|
3361
3370
|
this.tblActive = s.closest("table"), this.tablePropsDlg();
|
|
3362
3371
|
}
|
|
3363
3372
|
},
|
|
3364
|
-
{ label: this.t("deltable"), icon:
|
|
3373
|
+
{ label: this.t("deltable"), icon: a.trash, action: () => this.tableOp("deltable") }
|
|
3365
3374
|
],
|
|
3366
|
-
help: [this.mItem("helpttl",
|
|
3367
|
-
}, e = this.options.menubar === !0 ?
|
|
3375
|
+
help: [this.mItem("helpttl", a.helpic, () => this.helpDlg(), "Alt+0")]
|
|
3376
|
+
}, e = this.options.menubar === !0 ? st : this.options.menubar, i = /* @__PURE__ */ new Set();
|
|
3368
3377
|
e.split(/\s+/).filter(Boolean).forEach((s) => {
|
|
3369
3378
|
if (i.has(s)) return;
|
|
3370
3379
|
if (i.add(s), !t[s]) {
|
|
@@ -3379,11 +3388,11 @@ const I = class I {
|
|
|
3379
3388
|
}
|
|
3380
3389
|
/* ---------------------------------------------------------- table ops */
|
|
3381
3390
|
tableOp(t) {
|
|
3382
|
-
var r,
|
|
3391
|
+
var r, c, h;
|
|
3383
3392
|
this.restoreSel();
|
|
3384
3393
|
const e = window.getSelection();
|
|
3385
3394
|
if (!e) return;
|
|
3386
|
-
const i = ((r = this.closestBlock(e.anchorNode)) == null ? void 0 : r.closest("td,th")) || (e.anchorNode && e.anchorNode.nodeType === 1 ? (h = (
|
|
3395
|
+
const i = ((r = this.closestBlock(e.anchorNode)) == null ? void 0 : r.closest("td,th")) || (e.anchorNode && e.anchorNode.nodeType === 1 ? (h = (c = e.anchorNode).closest) == null ? void 0 : h.call(c, "td,th") : null);
|
|
3387
3396
|
if (!i) return;
|
|
3388
3397
|
const s = i.parentElement, l = i.closest("table"), o = Array.from(s.children).indexOf(i), n = () => {
|
|
3389
3398
|
const d = s.cloneNode(!1);
|
|
@@ -3421,11 +3430,11 @@ const I = class I {
|
|
|
3421
3430
|
r && r.after(i);
|
|
3422
3431
|
}
|
|
3423
3432
|
t === "colleft" && l > 0 && s.querySelectorAll("tr").forEach((r) => {
|
|
3424
|
-
const
|
|
3425
|
-
|
|
3433
|
+
const c = r.children[l], h = r.children[l - 1];
|
|
3434
|
+
c && h && h.before(c);
|
|
3426
3435
|
}), t === "colright" && s.querySelectorAll("tr").forEach((r) => {
|
|
3427
|
-
const
|
|
3428
|
-
|
|
3436
|
+
const c = r.children[l], h = r.children[l + 1];
|
|
3437
|
+
c && h && h.after(c);
|
|
3429
3438
|
});
|
|
3430
3439
|
const o = document.createRange();
|
|
3431
3440
|
o.selectNodeContents(e), o.collapse(!0);
|
|
@@ -3468,7 +3477,7 @@ const I = class I {
|
|
|
3468
3477
|
const t = this.tblActive;
|
|
3469
3478
|
if (!t) return;
|
|
3470
3479
|
let e, i, s, l, o;
|
|
3471
|
-
const n = "display:flex;align-items:center;gap:10px;margin:10px 0", r = "width:120px;color:#556;flex:none",
|
|
3480
|
+
const n = "display:flex;align-items:center;gap:10px;margin:10px 0", r = "width:120px;color:#556;flex:none", c = "flex:1;border:1px solid #cfd6df;border-radius:6px;padding:7px 9px;font:14px inherit", h = t.querySelector("td,th"), d = t.style.width || "", m = h && h.style.padding ? parseFloat(h.style.padding) : "", g = t.style.borderSpacing ? parseFloat(t.style.borderSpacing) : "", u = t.style.borderWidth ? parseFloat(t.style.borderWidth) : "", v = t.style.marginLeft, b = t.style.marginRight, x = v === "auto" && b === "auto" ? "center" : v === "auto" ? "right" : b === "auto" && v === "0" ? "left" : "";
|
|
3472
3481
|
this.dialog(
|
|
3473
3482
|
this.t("tablepropsttl"),
|
|
3474
3483
|
(C) => {
|
|
@@ -3478,7 +3487,7 @@ const I = class I {
|
|
|
3478
3487
|
const H = document.createElement("span");
|
|
3479
3488
|
H.style.cssText = r, H.textContent = this.t(w), L.append(H, k), C.appendChild(L);
|
|
3480
3489
|
};
|
|
3481
|
-
e = document.createElement("input"), e.type = "text", e.style.cssText =
|
|
3490
|
+
e = document.createElement("input"), e.type = "text", e.style.cssText = c, e.placeholder = "e.g. 600px or 100%", e.value = d, M("tblwidth", e), i = document.createElement("input"), i.type = "number", i.min = "0", i.style.cssText = c, i.value = String(m), M("tblcellpadding", i), s = document.createElement("input"), s.type = "number", s.min = "0", s.style.cssText = c, s.value = String(g), M("tblcellspacing", s), l = document.createElement("input"), l.type = "number", l.min = "0", l.style.cssText = c, l.value = String(u), M("tblborder", l), o = document.createElement("select"), o.style.cssText = c, [
|
|
3482
3491
|
["", "alignnone"],
|
|
3483
3492
|
["left", "alignleft"],
|
|
3484
3493
|
["center", "aligncenter"],
|
|
@@ -3723,7 +3732,7 @@ const I = class I {
|
|
|
3723
3732
|
n.className = "chpanel";
|
|
3724
3733
|
const r = document.createElement("div");
|
|
3725
3734
|
r.className = "chgrid" + (i ? " emgrid" : ""), n.appendChild(r);
|
|
3726
|
-
const
|
|
3735
|
+
const c = (h) => {
|
|
3727
3736
|
o.querySelectorAll("button").forEach((d, m) => d.classList.toggle("on", m === h)), r.innerHTML = "", e[h].chars.forEach((d) => {
|
|
3728
3737
|
const m = document.createElement("button");
|
|
3729
3738
|
m.type = "button", m.textContent = d, m.onclick = () => {
|
|
@@ -3733,8 +3742,8 @@ const I = class I {
|
|
|
3733
3742
|
};
|
|
3734
3743
|
e.forEach((h, d) => {
|
|
3735
3744
|
const m = document.createElement("button");
|
|
3736
|
-
m.type = "button", m.textContent = this.t(h.key), m.addEventListener("click", () =>
|
|
3737
|
-
}), l.append(o, n), s.appendChild(l),
|
|
3745
|
+
m.type = "button", m.textContent = this.t(h.key), m.addEventListener("click", () => c(d)), o.appendChild(m);
|
|
3746
|
+
}), l.append(o, n), s.appendChild(l), c(0);
|
|
3738
3747
|
});
|
|
3739
3748
|
}
|
|
3740
3749
|
charMap() {
|
|
@@ -3754,7 +3763,7 @@ const I = class I {
|
|
|
3754
3763
|
}
|
|
3755
3764
|
/* ---------------------------------------------- image upload placeholder */
|
|
3756
3765
|
imgPhHTML(t) {
|
|
3757
|
-
return `<div class="img-ph"${t ? ` id="${t}"` : ""} contenteditable="false">${
|
|
3766
|
+
return `<div class="img-ph"${t ? ` id="${t}"` : ""} contenteditable="false">${a.image}<span>${this.t("dropimage")}</span></div>`;
|
|
3758
3767
|
}
|
|
3759
3768
|
insertImagePlaceholder() {
|
|
3760
3769
|
this.restoreSel();
|
|
@@ -3778,11 +3787,11 @@ const I = class I {
|
|
|
3778
3787
|
var e;
|
|
3779
3788
|
const t = this.phCtx;
|
|
3780
3789
|
t && (t.innerHTML = "", t.append(
|
|
3781
|
-
this.ctxBtn(
|
|
3790
|
+
this.ctxBtn(a.uploadic, this.t("uploadimg"), () => {
|
|
3782
3791
|
this.phUploadTarget = this.phActive, this.pickImage();
|
|
3783
3792
|
}),
|
|
3784
|
-
this.ctxBtn(
|
|
3785
|
-
), (e = this.phActive) != null && e.closest(".tpl-media") && t.append(this.ctxBtn(
|
|
3793
|
+
this.ctxBtn(a.link, this.t("imagelink"), () => this.renderPhCtxUrlInput())
|
|
3794
|
+
), (e = this.phActive) != null && e.closest(".tpl-media") && t.append(this.ctxBtn(a.video, this.t("quickvideo"), () => this.swapPlaceholderKind("video"))), t.append(this.ctxSep(), this.ctxBtn(a.trash, this.t("deleteimg"), () => this.removeImgPlaceholder())), this.positionImgPhCtx());
|
|
3786
3795
|
}
|
|
3787
3796
|
/** Swaps a template slot's placeholder between image and video kinds, so the
|
|
3788
3797
|
* same media slot can be filled with either. */
|
|
@@ -3864,7 +3873,7 @@ const I = class I {
|
|
|
3864
3873
|
this.vidInput.value = "", this.vidInput.click();
|
|
3865
3874
|
}
|
|
3866
3875
|
vidPhHTML(t) {
|
|
3867
|
-
return `<div class="img-ph vid-ph"${t ? ` id="${t}"` : ""} contenteditable="false">${
|
|
3876
|
+
return `<div class="img-ph vid-ph"${t ? ` id="${t}"` : ""} contenteditable="false">${a.video}<span>${this.t("dropvideo")}</span></div>`;
|
|
3868
3877
|
}
|
|
3869
3878
|
insertVideoPlaceholder() {
|
|
3870
3879
|
this.restoreSel();
|
|
@@ -3888,11 +3897,11 @@ const I = class I {
|
|
|
3888
3897
|
var e;
|
|
3889
3898
|
const t = this.vphCtx;
|
|
3890
3899
|
t && (t.innerHTML = "", t.append(
|
|
3891
|
-
this.ctxBtn(
|
|
3900
|
+
this.ctxBtn(a.uploadic, this.t("uploadvideo"), () => {
|
|
3892
3901
|
this.vphUploadTarget = this.vphActive, this.pickVideo();
|
|
3893
3902
|
}),
|
|
3894
|
-
this.ctxBtn(
|
|
3895
|
-
), (e = this.vphActive) != null && e.closest(".tpl-media") && t.append(this.ctxBtn(
|
|
3903
|
+
this.ctxBtn(a.link, this.t("videolink"), () => this.renderVphCtxUrlInput())
|
|
3904
|
+
), (e = this.vphActive) != null && e.closest(".tpl-media") && t.append(this.ctxBtn(a.image, this.t("quickimage"), () => this.swapPlaceholderKind("image"))), t.append(this.ctxSep(), this.ctxBtn(a.trash, this.t("deletevideo"), () => this.removeVphPlaceholder())), this.positionVphCtx());
|
|
3896
3905
|
}
|
|
3897
3906
|
renderVphCtxUrlInput() {
|
|
3898
3907
|
const t = this.vphCtx;
|
|
@@ -3985,23 +3994,23 @@ const I = class I {
|
|
|
3985
3994
|
e.className = "imgctx", e.dir = this.dir();
|
|
3986
3995
|
const i = () => {
|
|
3987
3996
|
var h;
|
|
3988
|
-
const
|
|
3989
|
-
(h = this.vidCtx) == null || h.replaceWith(
|
|
3990
|
-
}, s = (
|
|
3991
|
-
this.setVideoAlign(t,
|
|
3992
|
-
}, l = t.style.float === "left", o = t.style.float === "right", n = !l && !o && t.style.marginLeft === "auto" && t.style.marginRight === "auto", r = (
|
|
3993
|
-
const g = this.ctxBtn(
|
|
3997
|
+
const c = this.buildVideoCtxToolbar(t);
|
|
3998
|
+
(h = this.vidCtx) == null || h.replaceWith(c), this.vidCtx = c, this.positionVidCtx();
|
|
3999
|
+
}, s = (c) => {
|
|
4000
|
+
this.setVideoAlign(t, c), i();
|
|
4001
|
+
}, l = t.style.float === "left", o = t.style.float === "right", n = !l && !o && t.style.marginLeft === "auto" && t.style.marginRight === "auto", r = (c, h, d, m) => {
|
|
4002
|
+
const g = this.ctxBtn(c, h, m);
|
|
3994
4003
|
return g.classList.toggle("on", d), g;
|
|
3995
4004
|
};
|
|
3996
4005
|
return e.append(
|
|
3997
|
-
r(
|
|
3998
|
-
r(
|
|
3999
|
-
r(
|
|
4006
|
+
r(a.alignleft, this.t("alignleft"), l, () => s("left")),
|
|
4007
|
+
r(a.aligncenter, this.t("aligncenter"), n, () => s("center")),
|
|
4008
|
+
r(a.alignright, this.t("alignright"), o, () => s("right")),
|
|
4000
4009
|
this.ctxSep(),
|
|
4001
|
-
r(
|
|
4010
|
+
r(a.trash, this.t("deletevideo"), !1, () => {
|
|
4002
4011
|
t.remove(), this.clearVidHandles(), this.onChange();
|
|
4003
4012
|
})
|
|
4004
|
-
), e.addEventListener("mousedown", (
|
|
4013
|
+
), e.addEventListener("mousedown", (c) => c.preventDefault()), e.addEventListener("mouseenter", () => this.cancelVidHide()), e.addEventListener("mouseleave", () => {
|
|
4005
4014
|
this.cancelVidHide(), this.vidHideTimer = window.setTimeout(() => this.clearVidHandles(), 250);
|
|
4006
4015
|
}), document.body.appendChild(e), e;
|
|
4007
4016
|
}
|
|
@@ -4039,18 +4048,18 @@ const I = class I {
|
|
|
4039
4048
|
videoDlg() {
|
|
4040
4049
|
this.saveSel();
|
|
4041
4050
|
let t, e, i, s, l, o;
|
|
4042
|
-
const n = (
|
|
4051
|
+
const n = (c, h) => {
|
|
4043
4052
|
const d = document.createElement("div");
|
|
4044
4053
|
d.className = "dfield";
|
|
4045
4054
|
const m = document.createElement("label");
|
|
4046
|
-
return m.textContent = this.t(
|
|
4055
|
+
return m.textContent = this.t(c), d.append(m, h), d;
|
|
4047
4056
|
}, r = () => {
|
|
4048
|
-
const
|
|
4049
|
-
return
|
|
4057
|
+
const c = document.createElement("input");
|
|
4058
|
+
return c.type = "url", c;
|
|
4050
4059
|
};
|
|
4051
4060
|
this.dialog(
|
|
4052
4061
|
this.t("videodlgttl"),
|
|
4053
|
-
(
|
|
4062
|
+
(c) => {
|
|
4054
4063
|
const h = document.createElement("div");
|
|
4055
4064
|
h.className = "dtabs";
|
|
4056
4065
|
const d = [], m = (v, b) => {
|
|
@@ -4099,7 +4108,7 @@ const I = class I {
|
|
|
4099
4108
|
l = r(), o = r(), v.append(n("vidaltsource", l), n("vidposter", o));
|
|
4100
4109
|
});
|
|
4101
4110
|
const u = document.createElement("div");
|
|
4102
|
-
u.className = "dtabbody", d.forEach((v) => u.appendChild(v)),
|
|
4111
|
+
u.className = "dtabbody", d.forEach((v) => u.appendChild(v)), c.append(h, u), g(0), setTimeout(() => t.focus(), 0);
|
|
4103
4112
|
},
|
|
4104
4113
|
[
|
|
4105
4114
|
{ label: this.t("cancel"), action: () => this.closeDlg() },
|
|
@@ -4107,10 +4116,10 @@ const I = class I {
|
|
|
4107
4116
|
label: this.t("save"),
|
|
4108
4117
|
primary: !0,
|
|
4109
4118
|
action: () => {
|
|
4110
|
-
const
|
|
4111
|
-
if (this.closeDlg(), !
|
|
4112
|
-
if (this.restoreSel(),
|
|
4113
|
-
document.execCommand("insertHTML", !1, `<span class="video-embed" contenteditable="false">${
|
|
4119
|
+
const c = s.value.trim(), h = t.value.trim(), d = parseInt(e.value, 10) || 560, m = parseInt(i.value, 10) || 314;
|
|
4120
|
+
if (this.closeDlg(), !c && !h) return;
|
|
4121
|
+
if (this.restoreSel(), c) {
|
|
4122
|
+
document.execCommand("insertHTML", !1, `<span class="video-embed" contenteditable="false">${c}</span>`), this.onChange();
|
|
4114
4123
|
return;
|
|
4115
4124
|
}
|
|
4116
4125
|
const g = this.videoEmbedUrl(h);
|
|
@@ -4186,8 +4195,8 @@ const I = class I {
|
|
|
4186
4195
|
n.setStart(i, e.anchorOffset - o.length - 1), n.setEnd(i, e.anchorOffset), n.deleteContents();
|
|
4187
4196
|
const r = document.createElement("code");
|
|
4188
4197
|
r.textContent = o, n.insertNode(r);
|
|
4189
|
-
const
|
|
4190
|
-
|
|
4198
|
+
const c = document.createRange();
|
|
4199
|
+
c.setStartAfter(r), c.collapse(!0), e.removeAllRanges(), e.addRange(c), this.saveSel(), this.onChange();
|
|
4191
4200
|
}
|
|
4192
4201
|
/** Custom dropdown for dialog fields (a native <select> popup can't be styled):
|
|
4193
4202
|
* a field-styled button showing the current choice that opens a floating,
|
|
@@ -4200,20 +4209,20 @@ const I = class I {
|
|
|
4200
4209
|
const l = document.createElement("button");
|
|
4201
4210
|
l.type = "button", l.className = "dsel-btn";
|
|
4202
4211
|
const o = document.createElement("span");
|
|
4203
|
-
o.className = "lbl", o.textContent = ((r = t.find(([
|
|
4212
|
+
o.className = "lbl", o.textContent = ((r = t.find(([c]) => c === e)) == null ? void 0 : r[1]) || "", l.append(o), l.insertAdjacentHTML("beforeend", a.chev);
|
|
4204
4213
|
const n = document.createElement("div");
|
|
4205
|
-
return n.className = "dsel-list", t.forEach(([
|
|
4214
|
+
return n.className = "dsel-list", t.forEach(([c, h]) => {
|
|
4206
4215
|
const d = document.createElement("button");
|
|
4207
|
-
d.type = "button", d.textContent = h, d.classList.toggle("on",
|
|
4208
|
-
i =
|
|
4216
|
+
d.type = "button", d.textContent = h, d.classList.toggle("on", c === i), d.addEventListener("click", () => {
|
|
4217
|
+
i = c, o.textContent = h, n.querySelectorAll("button").forEach((m) => m.classList.toggle("on", m === d)), s.classList.remove("open"), l.focus();
|
|
4209
4218
|
}), n.appendChild(d);
|
|
4210
4219
|
}), l.addEventListener("click", () => {
|
|
4211
|
-
var
|
|
4212
|
-
s.classList.toggle("open"), s.classList.contains("open") && ((
|
|
4213
|
-
}), s.addEventListener("focusout", (
|
|
4214
|
-
s.contains(
|
|
4215
|
-
}), s.addEventListener("keydown", (
|
|
4216
|
-
|
|
4220
|
+
var c;
|
|
4221
|
+
s.classList.toggle("open"), s.classList.contains("open") && ((c = n.querySelector(".on")) == null || c.scrollIntoView({ block: "nearest" }));
|
|
4222
|
+
}), s.addEventListener("focusout", (c) => {
|
|
4223
|
+
s.contains(c.relatedTarget) || s.classList.remove("open");
|
|
4224
|
+
}), s.addEventListener("keydown", (c) => {
|
|
4225
|
+
c.key === "Escape" && s.classList.contains("open") && (c.stopPropagation(), s.classList.remove("open"), l.focus());
|
|
4217
4226
|
}), s.append(l, n), { el: s, value: () => i };
|
|
4218
4227
|
}
|
|
4219
4228
|
/** Insert/edit-code-sample dialog: language dropdown + monospace textarea to
|
|
@@ -4229,7 +4238,7 @@ const I = class I {
|
|
|
4229
4238
|
const l = document.createElement("div");
|
|
4230
4239
|
l.className = "dfield";
|
|
4231
4240
|
const o = document.createElement("label");
|
|
4232
|
-
o.textContent = this.t("codelang"), e = this.dlgSelect(
|
|
4241
|
+
o.textContent = this.t("codelang"), e = this.dlgSelect(U, (t == null ? void 0 : t.dataset.lang) || "plain"), l.append(o, e.el), i = document.createElement("textarea"), i.className = "code-input", i.spellcheck = !1, i.value = ((n = t == null ? void 0 : t.querySelector("code")) == null ? void 0 : n.textContent) || "", i.placeholder = "const answer = 42;", s.append(l, i), setTimeout(() => i.focus(), 0);
|
|
4233
4242
|
},
|
|
4234
4243
|
[
|
|
4235
4244
|
{ label: this.t("cancel"), action: () => this.closeDlg() },
|
|
@@ -4238,7 +4247,7 @@ const I = class I {
|
|
|
4238
4247
|
primary: !0,
|
|
4239
4248
|
action: () => {
|
|
4240
4249
|
var n;
|
|
4241
|
-
const s = i.value.replace(/\s+$/, ""), l = e.value(), o = ((n =
|
|
4250
|
+
const s = i.value.replace(/\s+$/, ""), l = e.value(), o = ((n = U.find(([r]) => r === l)) == null ? void 0 : n[1]) || l;
|
|
4242
4251
|
if (this.closeDlg(), !!s.trim()) {
|
|
4243
4252
|
if (t) {
|
|
4244
4253
|
t.dataset.lang = l, t.setAttribute("data-lang-label", o);
|
|
@@ -4267,10 +4276,10 @@ const I = class I {
|
|
|
4267
4276
|
buildCodeCtxToolbar(t) {
|
|
4268
4277
|
const e = document.createElement("div");
|
|
4269
4278
|
return e.className = "imgctx", e.dir = this.dir(), e.append(
|
|
4270
|
-
this.ctxBtn(
|
|
4271
|
-
this.ctxBtn(
|
|
4279
|
+
this.ctxBtn(a.editic, this.t("editcode"), () => this.codeDlg(t)),
|
|
4280
|
+
this.ctxBtn(a.copyic, this.t("copycode"), () => this.copyCodeBlock(t)),
|
|
4272
4281
|
this.ctxSep(),
|
|
4273
|
-
this.ctxBtn(
|
|
4282
|
+
this.ctxBtn(a.trash, this.t("deletecode"), () => {
|
|
4274
4283
|
t.remove(), this.clearCodeSel(), this.onChange();
|
|
4275
4284
|
})
|
|
4276
4285
|
), e.addEventListener("mousedown", (i) => i.preventDefault()), document.body.appendChild(e), e;
|
|
@@ -4333,9 +4342,9 @@ const I = class I {
|
|
|
4333
4342
|
renderTplCtxButtons() {
|
|
4334
4343
|
const t = this.tplCtx, e = this.tplActive;
|
|
4335
4344
|
!t || !e || (t.innerHTML = "", F.forEach((i) => {
|
|
4336
|
-
const s = this.ctxBtn(
|
|
4345
|
+
const s = this.ctxBtn(It[i], this.t(O[i]), () => this.setTplLayout(i));
|
|
4337
4346
|
s.classList.toggle("on", e.classList.contains("tpl-" + i)), t.appendChild(s);
|
|
4338
|
-
}), t.append(this.ctxSep(), this.ctxBtn(
|
|
4347
|
+
}), t.append(this.ctxSep(), this.ctxBtn(a.trash, this.t("deltemplate"), () => this.removeTemplate())), this.positionTplCtx());
|
|
4339
4348
|
}
|
|
4340
4349
|
setTplLayout(t) {
|
|
4341
4350
|
const e = this.tplActive;
|
|
@@ -4399,8 +4408,8 @@ const I = class I {
|
|
|
4399
4408
|
return;
|
|
4400
4409
|
}
|
|
4401
4410
|
this.tblOpMark || (this.tblOpMark = document.createElement("div"), this.tblOpMark.className = "tbl-opmark", document.body.appendChild(this.tblOpMark));
|
|
4402
|
-
const i = this.tblActive.getBoundingClientRect(), s = e.getBoundingClientRect(), l = e.parentElement.getBoundingClientRect(), o = t === "row" ? l.left : s.left, n = t === "row" ? l.top : i.top, r = t === "row" ? l.width : s.width,
|
|
4403
|
-
this.tblOpMark.style.left = o + scrollX + "px", this.tblOpMark.style.top = n + scrollY + "px", this.tblOpMark.style.width = r + "px", this.tblOpMark.style.height =
|
|
4411
|
+
const i = this.tblActive.getBoundingClientRect(), s = e.getBoundingClientRect(), l = e.parentElement.getBoundingClientRect(), o = t === "row" ? l.left : s.left, n = t === "row" ? l.top : i.top, r = t === "row" ? l.width : s.width, c = t === "row" ? l.height : i.height;
|
|
4412
|
+
this.tblOpMark.style.left = o + scrollX + "px", this.tblOpMark.style.top = n + scrollY + "px", this.tblOpMark.style.width = r + "px", this.tblOpMark.style.height = c + "px";
|
|
4404
4413
|
}
|
|
4405
4414
|
/** Lowest allowed top for floating context toolbars — keeps them from
|
|
4406
4415
|
covering the editor menubar/toolbar when the target sits on the first line. */
|
|
@@ -4418,27 +4427,27 @@ const I = class I {
|
|
|
4418
4427
|
buildTableCtxToolbar() {
|
|
4419
4428
|
const t = document.createElement("div");
|
|
4420
4429
|
t.className = "tblctx", t.dir = this.dir();
|
|
4421
|
-
const e = (s, l) => (s.addEventListener("mouseenter", () => this.setOpTarget(l)), s.addEventListener("mouseleave", () => this.setOpTarget(null)), s), i = this.ctxBtn(
|
|
4430
|
+
const e = (s, l) => (s.addEventListener("mouseenter", () => this.setOpTarget(l)), s.addEventListener("mouseleave", () => this.setOpTarget(null)), s), i = this.ctxBtn(a.palette, this.t("cellbg"), () => this.cellFillMenu(i));
|
|
4422
4431
|
return t.append(
|
|
4423
|
-
e(this.ctxBtn(
|
|
4424
|
-
e(this.ctxBtn(
|
|
4425
|
-
e(this.ctxBtn(
|
|
4426
|
-
e(this.ctxBtn(
|
|
4427
|
-
e(this.ctxBtn(
|
|
4432
|
+
e(this.ctxBtn(a.rowbefore, this.t("rowabove"), () => this.tableOp("rowabove")), "row"),
|
|
4433
|
+
e(this.ctxBtn(a.rowafter, this.t("rowbelow"), () => this.tableOp("rowbelow")), "row"),
|
|
4434
|
+
e(this.ctxBtn(a.moverowup, this.t("moverowup"), () => this.tableMove("rowup")), "row"),
|
|
4435
|
+
e(this.ctxBtn(a.moverowdown, this.t("moverowdown"), () => this.tableMove("rowdown")), "row"),
|
|
4436
|
+
e(this.ctxBtn(a.rowdelete, this.t("delrow"), () => this.tableOp("delrow")), "row"),
|
|
4428
4437
|
this.ctxSep(),
|
|
4429
|
-
e(this.ctxBtn(
|
|
4430
|
-
e(this.ctxBtn(
|
|
4431
|
-
e(this.ctxBtn(
|
|
4432
|
-
e(this.ctxBtn(
|
|
4433
|
-
e(this.ctxBtn(
|
|
4438
|
+
e(this.ctxBtn(a.colbefore, this.t("colbefore"), () => this.tableOp("colbefore")), "col"),
|
|
4439
|
+
e(this.ctxBtn(a.colafter, this.t("colafter"), () => this.tableOp("colafter")), "col"),
|
|
4440
|
+
e(this.ctxBtn(a.movecolleft, this.t("movecolleft"), () => this.tableMove("colleft")), "col"),
|
|
4441
|
+
e(this.ctxBtn(a.movecolright, this.t("movecolright"), () => this.tableMove("colright")), "col"),
|
|
4442
|
+
e(this.ctxBtn(a.coldelete, this.t("delcol"), () => this.tableOp("delcol")), "col"),
|
|
4434
4443
|
this.ctxSep(),
|
|
4435
|
-
this.ctxBtn(
|
|
4436
|
-
this.ctxBtn(
|
|
4437
|
-
this.ctxBtn(
|
|
4444
|
+
this.ctxBtn(a.alignleft, this.t("tblalignleft"), () => this.alignTable("left")),
|
|
4445
|
+
this.ctxBtn(a.aligncenter, this.t("tblaligncenter"), () => this.alignTable("center")),
|
|
4446
|
+
this.ctxBtn(a.alignright, this.t("tblalignright"), () => this.alignTable("right")),
|
|
4438
4447
|
this.ctxSep(),
|
|
4439
4448
|
i,
|
|
4440
|
-
this.ctxBtn(
|
|
4441
|
-
this.ctxBtn(
|
|
4449
|
+
this.ctxBtn(a.trash, this.t("deltable"), () => this.tableOp("deltable")),
|
|
4450
|
+
this.ctxBtn(a.tableic, this.t("tablepropsttl"), () => this.tablePropsDlg())
|
|
4442
4451
|
), document.body.appendChild(t), t;
|
|
4443
4452
|
}
|
|
4444
4453
|
positionTableHandles() {
|
|
@@ -4448,17 +4457,17 @@ const I = class I {
|
|
|
4448
4457
|
}
|
|
4449
4458
|
const t = this.ed.getAttribute("dir") === "rtl", e = this.tblActive.getBoundingClientRect(), i = e.top + scrollY, s = e.left + scrollX, l = e.right + scrollX, o = e.bottom + scrollY;
|
|
4450
4459
|
if (this.tblCorner && (this.tblCorner.style.top = o - 5 + "px", this.tblCorner.style.left = (t ? s - 5 : l - 5) + "px", this.tblCorner.style.cursor = t ? "nesw-resize" : "nwse-resize"), this.tblCtx) {
|
|
4451
|
-
const r = this.tblCtx.offsetWidth,
|
|
4460
|
+
const r = this.tblCtx.offsetWidth, c = this.tblCtx.offsetHeight;
|
|
4452
4461
|
let h = s + (l - s) / 2 - r / 2;
|
|
4453
4462
|
h = Math.max(8 + scrollX, Math.min(h, scrollX + innerWidth - r - 8));
|
|
4454
|
-
let d = i -
|
|
4463
|
+
let d = i - c - 8;
|
|
4455
4464
|
d < this.ctxMinTop() && (d = o + 8), this.tblCtx.style.left = h + "px", this.tblCtx.style.top = d + "px";
|
|
4456
4465
|
}
|
|
4457
4466
|
this.tblColBars.forEach((r) => r.remove()), this.tblColBars = [];
|
|
4458
4467
|
const n = this.tblActive.rows[0];
|
|
4459
4468
|
if (n)
|
|
4460
4469
|
for (let r = 0; r < n.cells.length - 1; r++) {
|
|
4461
|
-
const
|
|
4470
|
+
const c = n.cells[r].getBoundingClientRect(), h = (t ? c.left : c.right) + scrollX, d = document.createElement("div");
|
|
4462
4471
|
d.className = "tbl-colbar", d.style.top = i + "px", d.style.left = h + "px", d.style.height = o - i + "px", document.body.appendChild(d), d.addEventListener("mousedown", (m) => this.startColBarDrag(m, r)), this.tblColBars.push(d);
|
|
4463
4472
|
}
|
|
4464
4473
|
this.positionCellMarker(), this.positionOpMark();
|
|
@@ -4478,8 +4487,8 @@ const I = class I {
|
|
|
4478
4487
|
if (!e) return;
|
|
4479
4488
|
const i = this.ed.getAttribute("dir") === "rtl", s = t.clientX, l = e.getBoundingClientRect().width;
|
|
4480
4489
|
e.style.tableLayout = e.style.tableLayout || "fixed", this.withNoTextSelect((o) => {
|
|
4481
|
-
const n = (
|
|
4482
|
-
const h = i ? -(
|
|
4490
|
+
const n = (c) => {
|
|
4491
|
+
const h = i ? -(c.clientX - s) : c.clientX - s;
|
|
4483
4492
|
e.style.width = Math.max(60, Math.round(l + h)) + "px", this.positionTableHandles();
|
|
4484
4493
|
}, r = () => {
|
|
4485
4494
|
window.removeEventListener("mousemove", n), window.removeEventListener("mouseup", r), o(), this.onChange();
|
|
@@ -4493,11 +4502,11 @@ const I = class I {
|
|
|
4493
4502
|
if (!i) return;
|
|
4494
4503
|
const s = this.ed.getAttribute("dir") === "rtl", l = Array.from(i.rows), o = l.map((d) => d.cells[e]).filter(Boolean), n = l.map((d) => d.cells[e + 1]).filter(Boolean);
|
|
4495
4504
|
if (!o.length || !n.length) return;
|
|
4496
|
-
const r = t.clientX,
|
|
4505
|
+
const r = t.clientX, c = o[0].getBoundingClientRect().width, h = n[0].getBoundingClientRect().width;
|
|
4497
4506
|
i.style.tableLayout = "fixed", this.withNoTextSelect((d) => {
|
|
4498
4507
|
const m = (u) => {
|
|
4499
4508
|
const v = (s ? -1 : 1) * (u.clientX - r);
|
|
4500
|
-
o.forEach((b) => b.style.width = Math.max(24, Math.round(
|
|
4509
|
+
o.forEach((b) => b.style.width = Math.max(24, Math.round(c + v)) + "px"), n.forEach((b) => b.style.width = Math.max(24, Math.round(h - v)) + "px"), this.positionTableHandles();
|
|
4501
4510
|
}, g = () => {
|
|
4502
4511
|
window.removeEventListener("mousemove", m), window.removeEventListener("mouseup", g), d(), this.onChange();
|
|
4503
4512
|
};
|
|
@@ -4526,38 +4535,38 @@ const I = class I {
|
|
|
4526
4535
|
e.className = "imgctx", e.dir = this.dir();
|
|
4527
4536
|
const i = () => {
|
|
4528
4537
|
var h;
|
|
4529
|
-
const
|
|
4530
|
-
(h = this.imgCtx) == null || h.replaceWith(
|
|
4531
|
-
}, s = (
|
|
4532
|
-
this.setImageAlign(t,
|
|
4533
|
-
}, l = t.style.float === "left", o = t.style.float === "right", n = !l && !o && t.style.marginLeft === "auto" && t.style.marginRight === "auto", r = (
|
|
4534
|
-
const g = this.ctxBtn(
|
|
4538
|
+
const c = this.buildImageCtxToolbar(t);
|
|
4539
|
+
(h = this.imgCtx) == null || h.replaceWith(c), this.imgCtx = c, this.positionImageHandles();
|
|
4540
|
+
}, s = (c) => {
|
|
4541
|
+
this.setImageAlign(t, c), i();
|
|
4542
|
+
}, l = t.style.float === "left", o = t.style.float === "right", n = !l && !o && t.style.marginLeft === "auto" && t.style.marginRight === "auto", r = (c, h, d, m) => {
|
|
4543
|
+
const g = this.ctxBtn(c, h, m);
|
|
4535
4544
|
return g.classList.toggle("on", d), g;
|
|
4536
4545
|
};
|
|
4537
4546
|
return e.append(
|
|
4538
|
-
r(
|
|
4539
|
-
r(
|
|
4540
|
-
r(
|
|
4547
|
+
r(a.alignleft, this.t("alignleft"), l, () => s("left")),
|
|
4548
|
+
r(a.aligncenter, this.t("aligncenter"), n, () => s("center")),
|
|
4549
|
+
r(a.alignright, this.t("alignright"), o, () => s("right")),
|
|
4541
4550
|
this.ctxSep(),
|
|
4542
|
-
r(
|
|
4551
|
+
r(a.rotateleft, this.t("rotateleft"), !1, () => {
|
|
4543
4552
|
this.rotateImage(t, -90), i();
|
|
4544
4553
|
}),
|
|
4545
|
-
r(
|
|
4554
|
+
r(a.rotateright, this.t("rotateright"), !1, () => {
|
|
4546
4555
|
this.rotateImage(t, 90), i();
|
|
4547
4556
|
}),
|
|
4548
4557
|
this.ctxSep(),
|
|
4549
|
-
r(
|
|
4558
|
+
r(a.fliphorizontal, this.t("fliphorizontal"), t.dataset.flipx === "1", () => {
|
|
4550
4559
|
this.flipImage(t, "x"), i();
|
|
4551
4560
|
}),
|
|
4552
|
-
r(
|
|
4561
|
+
r(a.flipvertical, this.t("flipvertical"), t.dataset.flipy === "1", () => {
|
|
4553
4562
|
this.flipImage(t, "y"), i();
|
|
4554
4563
|
}),
|
|
4555
4564
|
this.ctxSep(),
|
|
4556
|
-
r(
|
|
4557
|
-
const
|
|
4558
|
-
|
|
4565
|
+
r(a.trash, this.t("deleteimg"), !1, () => {
|
|
4566
|
+
const c = t.closest(".tpl-media");
|
|
4567
|
+
c && this.ed.contains(c) ? t.outerHTML = this.imgPhHTML() : t.remove(), this.clearImageHandles(), this.onChange();
|
|
4559
4568
|
})
|
|
4560
|
-
), e.addEventListener("mousedown", (
|
|
4569
|
+
), e.addEventListener("mousedown", (c) => c.preventDefault()), e.addEventListener("mouseenter", () => this.cancelImgHide()), e.addEventListener("mouseleave", () => this.scheduleImgHide()), document.body.appendChild(e), e;
|
|
4561
4570
|
}
|
|
4562
4571
|
setImageAlign(t, e) {
|
|
4563
4572
|
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();
|
|
@@ -4586,14 +4595,14 @@ const I = class I {
|
|
|
4586
4595
|
se: [s, l]
|
|
4587
4596
|
};
|
|
4588
4597
|
if (this.imgHandles.forEach((n) => {
|
|
4589
|
-
const [r,
|
|
4590
|
-
n.style.left = r - 5 + "px", n.style.top =
|
|
4598
|
+
const [r, c] = o[n.dataset.corner];
|
|
4599
|
+
n.style.left = r - 5 + "px", n.style.top = c - 5 + "px";
|
|
4591
4600
|
}), this.imgCtx) {
|
|
4592
4601
|
const n = this.imgCtx.offsetWidth, r = this.imgCtx.offsetHeight;
|
|
4593
|
-
let
|
|
4594
|
-
|
|
4602
|
+
let c = i + (s - i) / 2 - n / 2;
|
|
4603
|
+
c = Math.max(8 + scrollX, Math.min(c, scrollX + innerWidth - n - 8));
|
|
4595
4604
|
let h = e - r - 8;
|
|
4596
|
-
h < this.ctxMinTop() && (h = l + 8), this.imgCtx.style.left =
|
|
4605
|
+
h < this.ctxMinTop() && (h = l + 8), this.imgCtx.style.left = c + "px", this.imgCtx.style.top = h + "px";
|
|
4597
4606
|
}
|
|
4598
4607
|
}
|
|
4599
4608
|
startImageResizeDrag(t, e) {
|
|
@@ -4605,10 +4614,10 @@ const I = class I {
|
|
|
4605
4614
|
this.withNoTextSelect((n) => {
|
|
4606
4615
|
const r = (h) => {
|
|
4607
4616
|
i.style.width = Math.max(24, Math.round(l + o * (h.clientX - s))) + "px", i.style.height = "auto", this.positionImageHandles();
|
|
4608
|
-
},
|
|
4609
|
-
window.removeEventListener("mousemove", r), window.removeEventListener("mouseup",
|
|
4617
|
+
}, c = () => {
|
|
4618
|
+
window.removeEventListener("mousemove", r), window.removeEventListener("mouseup", c), n(), this.onChange();
|
|
4610
4619
|
};
|
|
4611
|
-
window.addEventListener("mousemove", r), window.addEventListener("mouseup",
|
|
4620
|
+
window.addEventListener("mousemove", r), window.addEventListener("mouseup", c);
|
|
4612
4621
|
});
|
|
4613
4622
|
}
|
|
4614
4623
|
/* ---------------------------------------------------------- selection bubble toolbar */
|
|
@@ -4639,21 +4648,21 @@ const I = class I {
|
|
|
4639
4648
|
'<b style="font:600 15px/1 Georgia,serif">A</b><span class="colorbar" data-cb="fore"></span>',
|
|
4640
4649
|
this.t("forecolor"),
|
|
4641
4650
|
() => this.colorMenu(e, "fore")
|
|
4642
|
-
), i = this.ctxBtn(
|
|
4651
|
+
), i = this.ctxBtn(a.backcolor, this.t("backcolor"), () => this.colorMenu(i, "back"));
|
|
4643
4652
|
(n = i.querySelector("svg")) == null || n.insertAdjacentHTML("afterend", '<span class="colorbar" data-cb="back"></span>');
|
|
4644
|
-
const s = this.ctxBtn(
|
|
4653
|
+
const s = this.ctxBtn(a.caseic, this.t("changecase"), () => this.caseMenu(s)), l = this.ctxBtn(a.lineheight, this.t("lineheight"), () => this.lineHeightMenu(l)), o = this.ctxBtn(a.wordspacing, this.t("wordspacing"), () => this.wordSpacingMenu(o));
|
|
4645
4654
|
return t.append(
|
|
4646
|
-
this.ctxBtn(
|
|
4647
|
-
this.ctxBtn(
|
|
4655
|
+
this.ctxBtn(a.bold, this.t("bold"), () => this.exec("bold"), "bold"),
|
|
4656
|
+
this.ctxBtn(a.italic, this.t("italic"), () => this.exec("italic"), "italic"),
|
|
4648
4657
|
e,
|
|
4649
4658
|
i,
|
|
4650
4659
|
this.ctxSep(),
|
|
4651
|
-
this.ctxBtn(
|
|
4652
|
-
this.ctxBtn(
|
|
4660
|
+
this.ctxBtn(a.quote, this.t("quote"), () => this.toggleBlock("blockquote"), "blockquote"),
|
|
4661
|
+
this.ctxBtn(a.inlinecodeic, this.t("code"), () => this.toggleInlineCode(), "code"),
|
|
4653
4662
|
this.ctxBtn('<b style="font:700 12px/1 Arial,sans-serif">H2</b>', this.blockLabel("h2"), () => this.toggleBlock("h2"), "h2"),
|
|
4654
4663
|
this.ctxBtn('<b style="font:700 12px/1 Arial,sans-serif">H3</b>', this.blockLabel("h3"), () => this.toggleBlock("h3"), "h3"),
|
|
4655
4664
|
this.ctxSep(),
|
|
4656
|
-
this.ctxBtn(
|
|
4665
|
+
this.ctxBtn(a.link, this.t("linkttl"), () => this.linkDlg()),
|
|
4657
4666
|
s,
|
|
4658
4667
|
l,
|
|
4659
4668
|
o
|
|
@@ -4662,10 +4671,10 @@ const I = class I {
|
|
|
4662
4671
|
positionSelToolbar(t) {
|
|
4663
4672
|
if (!this.selCtx) return;
|
|
4664
4673
|
const e = t.getBoundingClientRect(), i = e.top + scrollY, s = e.left + scrollX, l = e.right + scrollX, o = e.bottom + scrollY, n = this.selCtx.offsetWidth, r = this.selCtx.offsetHeight;
|
|
4665
|
-
let
|
|
4666
|
-
|
|
4674
|
+
let c = s + (l - s) / 2 - n / 2;
|
|
4675
|
+
c = Math.max(8 + scrollX, Math.min(c, scrollX + innerWidth - n - 8));
|
|
4667
4676
|
let h = i - r - 8;
|
|
4668
|
-
h < this.ctxMinTop() && (h = o + 8), this.selCtx.style.left =
|
|
4677
|
+
h < this.ctxMinTop() && (h = o + 8), this.selCtx.style.left = c + "px", this.selCtx.style.top = h + "px";
|
|
4669
4678
|
}
|
|
4670
4679
|
repositionSelToolbar() {
|
|
4671
4680
|
if (!this.selCtx) return;
|
|
@@ -4693,7 +4702,7 @@ const I = class I {
|
|
|
4693
4702
|
return t > 0 ? t + "px" : "";
|
|
4694
4703
|
}
|
|
4695
4704
|
refreshState() {
|
|
4696
|
-
var r,
|
|
4705
|
+
var r, c, h;
|
|
4697
4706
|
const t = window.getSelection(), e = t ? this.ed.contains(t.anchorNode) : !1, i = this.currentBlock();
|
|
4698
4707
|
[this.toolbar, this.selCtx].filter(Boolean).forEach((d) => {
|
|
4699
4708
|
[
|
|
@@ -4718,12 +4727,12 @@ const I = class I {
|
|
|
4718
4727
|
m && m.classList.toggle("on", e && !!this.closestInlineCode());
|
|
4719
4728
|
});
|
|
4720
4729
|
const l = t ? this.closestBlock(t.anchorNode) : null, o = ((r = l == null ? void 0 : l.closest("[dir]")) == null ? void 0 : r.getAttribute("dir")) || this.ed.getAttribute("dir") || this.dir();
|
|
4721
|
-
(
|
|
4730
|
+
(c = this.toolbar.querySelector("[data-id=ltr]")) == null || c.classList.toggle("on", e && o === "ltr"), (h = this.toolbar.querySelector("[data-id=rtl]")) == null || h.classList.toggle("on", e && o === "rtl");
|
|
4722
4731
|
const n = (d, m, g) => {
|
|
4723
4732
|
const u = this.toolbar.querySelector(`[data-id=${d}] .lbl`);
|
|
4724
4733
|
u && (u.textContent = m || g || "", u.classList.toggle("empty", !m));
|
|
4725
4734
|
};
|
|
4726
|
-
n("fontsel", this.currentFont()), n("sizesel", this.currentSize().replace("px", "")), e && n("blocksel",
|
|
4735
|
+
n("fontsel", this.currentFont()), n("sizesel", this.currentSize().replace("px", "")), e && n("blocksel", j.some((d) => d[0] === i) ? this.blockLabel(i) : this.t("para")), this.sbWords.textContent = this.countWords() + " " + this.t("words");
|
|
4727
4736
|
}
|
|
4728
4737
|
countWords() {
|
|
4729
4738
|
const t = (this.ed.textContent || "").trim();
|
|
@@ -4756,17 +4765,17 @@ const I = class I {
|
|
|
4756
4765
|
this.closePop(), this.closeDlg(), this.clearTableHandles(), this.clearImgPlaceholderSel(), this.clearVphPlaceholderSel(), this.clearVidHandles(), this.clearCodeSel(), this.shell.dir = this.dir(), this.ed.dir = this.dir(), this.options.menubar ? this.buildMenubar() : this.menubar.style.display = "none", this.options.toolbar ? this.buildToolbar() : this.toolbar.style.display = "none", this.sbHelp.textContent = this.t("statushelp"), this.refreshState();
|
|
4757
4766
|
}
|
|
4758
4767
|
};
|
|
4759
|
-
|
|
4760
|
-
let
|
|
4768
|
+
A.instanceCounter = 0, A.TBR_COLLAPSE_MAX = 992;
|
|
4769
|
+
let J = A;
|
|
4761
4770
|
export {
|
|
4762
|
-
|
|
4763
|
-
|
|
4771
|
+
j as BLOCKS,
|
|
4772
|
+
Zt as CHARS,
|
|
4764
4773
|
ct as COLORS,
|
|
4765
|
-
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
|
|
4774
|
+
lt as FONTS,
|
|
4775
|
+
J as FableEditor,
|
|
4776
|
+
et as I18N,
|
|
4777
|
+
a as IC,
|
|
4778
|
+
ot as SIZES,
|
|
4770
4779
|
Nt as TXT,
|
|
4771
4780
|
wt as cleanPastedHTML,
|
|
4772
4781
|
R as getStrings,
|