fable-editor 1.3.2 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -407,7 +407,7 @@ const dt = "undo redo | preview print | importword revhistory | fontfamily fonts
407
407
  ["Verdana", "verdana,geneva"],
408
408
  ["Webdings", "webdings"],
409
409
  ["Wingdings", "wingdings,zapf dingbats"]
410
- ], mt = ["8px", "9px", "10px", "11px", "12px", "14px", "16px", "18px", "20px", "24px", "28px", "32px", "36px", "48px", "72px", "96px"], gt = 1, ft = 100, W = ["1", "1.15", "1.4", "1.5", "1.75", "2", "2.5", "3"], V = ["1px", "2px", "4px", "6px", "8px", "12px"], j = ["0.5px", "1px", "1.5px", "2px", "3px", "4px"], X = [
410
+ ], mt = ["8px", "9px", "10px", "11px", "12px", "14px", "16px", "18px", "20px", "24px", "28px", "32px", "36px", "48px", "72px", "96px"], gt = 1, ft = 100, U = ["1", "1.15", "1.4", "1.5", "1.75", "2", "2.5", "3"], V = ["1px", "2px", "4px", "6px", "8px", "12px"], j = ["0.5px", "1px", "1.5px", "2px", "3px", "4px"], X = [
411
411
  ["plain", "Plain text"],
412
412
  ["html", "HTML/XML"],
413
413
  ["css", "CSS"],
@@ -1944,12 +1944,12 @@ function Et(h) {
1944
1944
  const l = s.previousElementSibling;
1945
1945
  i && l && i[i.length - 1] === l ? i.push(s) : (i = [s], e.push(i));
1946
1946
  }), e.forEach((s) => {
1947
- const l = [], o = s[0];
1948
- s.forEach((n) => {
1947
+ const l = [], n = s[0];
1948
+ s.forEach((r) => {
1949
1949
  var y, w, S;
1950
- const a = +(((y = (n.getAttribute("style") || "").match(/level(\d+)/i)) == null ? void 0 : y[1]) || 1), d = Array.from(n.querySelectorAll("span")).find(
1950
+ const a = +(((y = (r.getAttribute("style") || "").match(/level(\d+)/i)) == null ? void 0 : y[1]) || 1), d = Array.from(r.querySelectorAll("span")).find(
1951
1951
  (C) => /mso-list\s*:\s*ignore/i.test(C.getAttribute("style") || "")
1952
- ), p = d ? ((w = d.textContent) == null ? void 0 : w.trim()) || "" : (((S = n.textContent) == null ? void 0 : S.trim().match(/^\S{1,4}/)) || [""])[0], { ordered: u, style: g } = St(p);
1952
+ ), p = d ? ((w = d.textContent) == null ? void 0 : w.trim()) || "" : (((S = r.textContent) == null ? void 0 : S.trim().match(/^\S{1,4}/)) || [""])[0], { ordered: u, style: g } = St(p);
1953
1953
  for (d && d.remove(); l.length && l[l.length - 1].level > a; ) l.pop();
1954
1954
  if (!l.length || l[l.length - 1].level < a) {
1955
1955
  const C = h.createElement(u ? "ol" : "ul");
@@ -1957,12 +1957,12 @@ function Et(h) {
1957
1957
  const k = l[l.length - 1].list;
1958
1958
  (k.lastElementChild || k).appendChild(C);
1959
1959
  } else
1960
- o.parentNode.insertBefore(C, o);
1960
+ n.parentNode.insertBefore(C, n);
1961
1961
  l.push({ list: C, level: a });
1962
1962
  }
1963
- const m = h.createElement("li"), f = D(n), b = ["text-align", "direction", "unicode-bidi", "color", "font-size", "font-family", "background-color"].filter((C) => f[C]).map((C) => C + ":" + f[C]).join(";");
1964
- for (b && m.setAttribute("style", b), n.getAttribute("dir") && m.setAttribute("dir", n.getAttribute("dir")); n.firstChild; ) m.appendChild(n.firstChild);
1965
- l[l.length - 1].list.appendChild(m), n.remove();
1963
+ const m = h.createElement("li"), f = D(r), b = ["text-align", "direction", "unicode-bidi", "color", "font-size", "font-family", "background-color"].filter((C) => f[C]).map((C) => C + ":" + f[C]).join(";");
1964
+ for (b && m.setAttribute("style", b), r.getAttribute("dir") && m.setAttribute("dir", r.getAttribute("dir")); r.firstChild; ) m.appendChild(r.firstChild);
1965
+ l[l.length - 1].list.appendChild(m), r.remove();
1966
1966
  });
1967
1967
  });
1968
1968
  }
@@ -2001,10 +2001,10 @@ function Z(h, t) {
2001
2001
  const i = e, s = i.tagName.toLowerCase();
2002
2002
  if (!wt.has(s)) {
2003
2003
  if (s === "font") {
2004
- const r = t.createElement("span");
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 o = t.createElement("span");
2005
+ i.getAttribute("style") && o.setAttribute("style", i.getAttribute("style")), i.getAttribute("color") && (o.style.color = i.getAttribute("color")), i.getAttribute("face") && (o.style.fontFamily = i.getAttribute("face"));
2006
2006
  const a = i.getAttribute("size");
2007
- if (a && !r.style.fontSize) {
2007
+ if (a && !o.style.fontSize) {
2008
2008
  const d = {
2009
2009
  1: "8pt",
2010
2010
  2: "10pt",
@@ -2014,10 +2014,10 @@ function Z(h, t) {
2014
2014
  6: "24pt",
2015
2015
  7: "36pt"
2016
2016
  };
2017
- d[a] && (r.style.fontSize = d[a]);
2017
+ d[a] && (o.style.fontSize = d[a]);
2018
2018
  }
2019
- for (; i.firstChild; ) r.appendChild(i.firstChild);
2020
- i.replaceWith(r), Z(r, t);
2019
+ for (; i.firstChild; ) o.appendChild(i.firstChild);
2020
+ i.replaceWith(o), Z(o, t);
2021
2021
  return;
2022
2022
  }
2023
2023
  for (Z(i, t); i.firstChild; ) i.parentNode.insertBefore(i.firstChild, i);
@@ -2025,25 +2025,25 @@ function Z(h, t) {
2025
2025
  return;
2026
2026
  }
2027
2027
  const l = /* @__PURE__ */ new Set([...G["*"] || [], ...G[s] || []]);
2028
- if (Array.from(i.attributes).forEach((r) => {
2029
- const a = r.name.toLowerCase();
2030
- a !== "style" && !l.has(a) && i.removeAttribute(r.name);
2028
+ if (Array.from(i.attributes).forEach((o) => {
2029
+ const a = o.name.toLowerCase();
2030
+ a !== "style" && !l.has(a) && i.removeAttribute(o.name);
2031
2031
  }), s === "a") {
2032
- const r = i.getAttribute("href") || "";
2033
- /^(https?:|mailto:|tel:|#)/i.test(r) || i.removeAttribute("href");
2032
+ const o = i.getAttribute("href") || "";
2033
+ /^(https?:|mailto:|tel:|#)/i.test(o) || i.removeAttribute("href");
2034
2034
  }
2035
2035
  if (s === "img") {
2036
- const r = i.getAttribute("src") || "";
2037
- if (!/^(https?:|data:image\/|blob:)/i.test(r)) {
2036
+ const o = i.getAttribute("src") || "";
2037
+ if (!/^(https?:|data:image\/|blob:)/i.test(o)) {
2038
2038
  const a = t.createElement("span");
2039
2039
  a.textContent = "[local image — paste it separately]", a.setAttribute("style", "color:#a33;font-style:italic;font-size:12px"), i.replaceWith(a);
2040
2040
  return;
2041
2041
  }
2042
2042
  }
2043
- const o = D(i), n = [];
2044
- for (const [r, a] of Object.entries(o))
2045
- Ct.has(r) && (/expression|javascript|url\s*\(\s*['"]?\s*file:/i.test(a) || r === "font-weight" && /^(400|normal)$/i.test(a) || r === "font-style" && /^normal$/i.test(a) || r === "text-decoration" && /^none$/i.test(a) || n.push(r + ":" + a));
2046
- if (n.length ? i.setAttribute("style", n.join(";")) : i.removeAttribute("style"), i.removeAttribute("class"), Z(i, t), s === "span" && !i.attributes.length) {
2043
+ const n = D(i), r = [];
2044
+ for (const [o, a] of Object.entries(n))
2045
+ Ct.has(o) && (/expression|javascript|url\s*\(\s*['"]?\s*file:/i.test(a) || o === "font-weight" && /^(400|normal)$/i.test(a) || o === "font-style" && /^normal$/i.test(a) || o === "text-decoration" && /^none$/i.test(a) || r.push(o + ":" + a));
2046
+ if (r.length ? i.setAttribute("style", r.join(";")) : i.removeAttribute("style"), i.removeAttribute("class"), Z(i, t), s === "span" && !i.attributes.length) {
2047
2047
  for (; i.firstChild; ) i.parentNode.insertBefore(i.firstChild, i);
2048
2048
  i.remove();
2049
2049
  }
@@ -2056,13 +2056,13 @@ function Ht(h) {
2056
2056
  let s = i[1].replace(/<!--|-->/g, "").replace(/\/\*[\s\S]*?\*\//g, "");
2057
2057
  s = s.replace(/@media[^{]*\{(?:[^{}]*\{[^{}]*\})*[^{}]*\}/gi, ""), s = s.replace(/@[\w-]+[^{]*\{[^{}]*\}/g, "");
2058
2058
  let l;
2059
- const o = /([^{}]+)\{([^}]*)\}/g;
2060
- for (; l = o.exec(s); ) {
2061
- const n = l[2].split(";").map((r) => {
2062
- const a = r.indexOf(":");
2063
- return a < 1 ? null : [r.slice(0, a).trim().toLowerCase(), r.slice(a + 1).trim()];
2064
- }).filter((r) => !!r && !!r[1]);
2065
- n.length && l[1].split(",").map((r) => r.trim()).filter((r) => r && !r.startsWith("@")).forEach((r) => t.push({ sel: r, decls: n }));
2059
+ const n = /([^{}]+)\{([^}]*)\}/g;
2060
+ for (; l = n.exec(s); ) {
2061
+ const r = l[2].split(";").map((o) => {
2062
+ const a = o.indexOf(":");
2063
+ return a < 1 ? null : [o.slice(0, a).trim().toLowerCase(), o.slice(a + 1).trim()];
2064
+ }).filter((o) => !!o && !!o[1]);
2065
+ r.length && l[1].split(",").map((o) => o.trim()).filter((o) => o && !o.startsWith("@")).forEach((o) => t.push({ sel: o, decls: r }));
2066
2066
  }
2067
2067
  }
2068
2068
  return t;
@@ -2077,16 +2077,16 @@ function kt(h, t) {
2077
2077
  } catch {
2078
2078
  return;
2079
2079
  }
2080
- l.forEach((o) => {
2081
- let n = e.get(o);
2082
- n || (n = {}, e.set(o, n)), s.forEach(([r, a]) => {
2083
- n[r] = a;
2080
+ l.forEach((n) => {
2081
+ let r = e.get(n);
2082
+ r || (r = {}, e.set(n, r)), s.forEach(([o, a]) => {
2083
+ r[o] = a;
2084
2084
  });
2085
2085
  });
2086
2086
  }), e.forEach((i, s) => {
2087
- const l = D(s), o = s.hasAttribute("dir"), n = s.hasAttribute("align"), r = Object.entries(i).filter(([p]) => !(p in l || (p === "direction" || p === "unicode-bidi") && o || p === "text-align" && (n || o) || (p === "background" || p === "background-color") && s.hasAttribute("bgcolor")));
2088
- if (!r.length) return;
2089
- const a = r.map(([p, u]) => p + ":" + u).join(";"), d = s.getAttribute("style");
2087
+ const l = D(s), n = s.hasAttribute("dir"), r = s.hasAttribute("align"), o = Object.entries(i).filter(([p]) => !(p in l || (p === "direction" || p === "unicode-bidi") && n || p === "text-align" && (r || n) || (p === "background" || p === "background-color") && s.hasAttribute("bgcolor")));
2088
+ if (!o.length) return;
2089
+ const a = o.map(([p, u]) => p + ":" + u).join(";"), d = s.getAttribute("style");
2090
2090
  s.setAttribute("style", d ? a + ";" + d : a);
2091
2091
  });
2092
2092
  }
@@ -2103,8 +2103,8 @@ function It(h, t = "ltr") {
2103
2103
  const e = Ht(h), i = new DOMParser().parseFromString(Tt(h), "text/html");
2104
2104
  kt(i, e), /class="?Mso|mso-|urn:schemas-microsoft-com/i.test(i.body.innerHTML) && Et(i), Mt(i), Lt(i), Z(i.body, i), At(i);
2105
2105
  const s = (l) => {
2106
- var o;
2107
- return l && l.tagName === "P" && !((o = l.textContent) != null && o.trim()) && !l.querySelector("img,table");
2106
+ var n;
2107
+ return l && l.tagName === "P" && !((n = l.textContent) != null && n.trim()) && !l.querySelector("img,table");
2108
2108
  };
2109
2109
  for (; s(i.body.firstElementChild); ) i.body.firstElementChild.remove();
2110
2110
  for (; s(i.body.lastElementChild); ) i.body.lastElementChild.remove();
@@ -2124,18 +2124,18 @@ function Y(h, t) {
2124
2124
  s += i.length;
2125
2125
  continue;
2126
2126
  }
2127
- let o = 0, n = s;
2128
- for (; n < h.length; n++) {
2129
- const r = h[n];
2130
- if (r === "\\") {
2131
- n++;
2127
+ let n = 0, r = s;
2128
+ for (; r < h.length; r++) {
2129
+ const o = h[r];
2130
+ if (o === "\\") {
2131
+ r++;
2132
2132
  continue;
2133
2133
  }
2134
- if (r === "{") o++;
2135
- else if (r === "}" && (o--, !o))
2134
+ if (o === "{") n++;
2135
+ else if (o === "}" && (n--, !n))
2136
2136
  break;
2137
2137
  }
2138
- e.push({ start: s, end: n + 1, body: h.slice(s + i.length, n) }), s = n + 1;
2138
+ e.push({ start: s, end: r + 1, body: h.slice(s + i.length, r) }), s = r + 1;
2139
2139
  }
2140
2140
  return e;
2141
2141
  }
@@ -2201,10 +2201,10 @@ function Ot(h) {
2201
2201
  const t = (i, s) => {
2202
2202
  const l = Ft(i, "src");
2203
2203
  if (!l) return null;
2204
- const o = l.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2205
- if (new RegExp(`<img\\b[^>]*\\bsrc\\s*=\\s*["']?` + o, "i").test(h)) return null;
2206
- const n = (s.match(/<v:shape\b[^>]*\sstyle\s*=\s*(?:"([^"]*)"|'([^']*)')/i) || []).slice(1).find(Boolean) || "", r = J((n.match(/(?:^|;)\s*width\s*:\s*([^;]+)/i) || [])[1] || ""), a = J((n.match(/(?:^|;)\s*height\s*:\s*([^;]+)/i) || [])[1] || "");
2207
- return '<img src="' + l.replace(/"/g, "&quot;") + '"' + (r ? ' width="' + r + '"' : "") + (a ? ' height="' + a + '"' : "") + ">";
2204
+ const n = l.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2205
+ if (new RegExp(`<img\\b[^>]*\\bsrc\\s*=\\s*["']?` + n, "i").test(h)) return null;
2206
+ const r = (s.match(/<v:shape\b[^>]*\sstyle\s*=\s*(?:"([^"]*)"|'([^']*)')/i) || []).slice(1).find(Boolean) || "", o = J((r.match(/(?:^|;)\s*width\s*:\s*([^;]+)/i) || [])[1] || ""), a = J((r.match(/(?:^|;)\s*height\s*:\s*([^;]+)/i) || [])[1] || "");
2207
+ return '<img src="' + l.replace(/"/g, "&quot;") + '"' + (o ? ' width="' + o + '"' : "") + (a ? ' height="' + a + '"' : "") + ">";
2208
2208
  };
2209
2209
  let e = h.replace(/<!--\[if [^\]]*\]>([\s\S]*?)<!\[endif\]-->/gi, (i, s) => {
2210
2210
  const l = s.match(/<v:imagedata\b[^>]*>/i);
@@ -2220,10 +2220,10 @@ function rt(h, t) {
2220
2220
  const e = [];
2221
2221
  let i = 0;
2222
2222
  return { html: Ot(h).replace(/<img\b[^>]*>/gi, (l) => {
2223
- const o = (l.match(/\ssrc\s*=\s*["']?([^"'\s>]+)/i) || [])[1] || "";
2224
- if (ot.test(o)) return l;
2225
- const n = t[i++];
2226
- return n ? (e.push(n), /\ssrc\s*=\s*["']/i.test(l) ? l.replace(/(\ssrc\s*=\s*)(["'])[^"']*\2/i, '$1"' + n + '"') : l.replace(/(\ssrc\s*=\s*)[^\s>]+/i, '$1"' + n + '"')) : l;
2223
+ const n = (l.match(/\ssrc\s*=\s*["']?([^"'\s>]+)/i) || [])[1] || "";
2224
+ if (ot.test(n)) return l;
2225
+ const r = t[i++];
2226
+ return r ? (e.push(r), /\ssrc\s*=\s*["']/i.test(l) ? l.replace(/(\ssrc\s*=\s*)(["'])[^"']*\2/i, '$1"' + r + '"') : l.replace(/(\ssrc\s*=\s*)[^\s>]+/i, '$1"' + r + '"')) : l;
2227
2227
  }), injected: e };
2228
2228
  }
2229
2229
  function $t(h, t) {
@@ -2242,38 +2242,38 @@ function zt(h, t) {
2242
2242
  const i = (e[1].split("/")[1] || "png").replace(/[^a-z0-9]/gi, "") || "png";
2243
2243
  try {
2244
2244
  const s = atob(e[2]), l = new Uint8Array(s.length);
2245
- for (let o = 0; o < s.length; o++) l[o] = s.charCodeAt(o);
2245
+ for (let n = 0; n < s.length; n++) l[n] = s.charCodeAt(n);
2246
2246
  return new File([l], t + "." + (i === "jpeg" ? "jpg" : i), { type: e[1] });
2247
2247
  } catch {
2248
2248
  return null;
2249
2249
  }
2250
2250
  }
2251
- function Ut(h) {
2251
+ function Wt(h) {
2252
2252
  const t = new DataView(h), e = /* @__PURE__ */ new Map();
2253
2253
  let i = -1;
2254
- for (let n = h.byteLength - 22; n >= Math.max(0, h.byteLength - 22 - 65535); n--)
2255
- if (t.getUint32(n, !0) === 101010256) {
2256
- i = n;
2254
+ for (let r = h.byteLength - 22; r >= Math.max(0, h.byteLength - 22 - 65535); r--)
2255
+ if (t.getUint32(r, !0) === 101010256) {
2256
+ i = r;
2257
2257
  break;
2258
2258
  }
2259
2259
  if (i < 0) throw new Error("EOCD not found");
2260
2260
  const s = t.getUint16(i + 10, !0);
2261
2261
  let l = t.getUint32(i + 16, !0);
2262
- const o = new TextDecoder();
2263
- for (let n = 0; n < s && t.getUint32(l, !0) === 33639248; n++) {
2264
- const r = t.getUint16(l + 10, !0), a = t.getUint32(l + 20, !0), d = t.getUint16(l + 28, !0), p = t.getUint16(l + 30, !0), u = t.getUint16(l + 32, !0), g = t.getUint32(l + 42, !0), m = o.decode(new Uint8Array(h, l + 46, d));
2265
- e.set(m, { name: m, method: r, compSize: a, localOffset: g }), l += 46 + d + p + u;
2262
+ const n = new TextDecoder();
2263
+ for (let r = 0; r < s && t.getUint32(l, !0) === 33639248; r++) {
2264
+ const o = t.getUint16(l + 10, !0), a = t.getUint32(l + 20, !0), d = t.getUint16(l + 28, !0), p = t.getUint16(l + 30, !0), u = t.getUint16(l + 32, !0), g = t.getUint32(l + 42, !0), m = n.decode(new Uint8Array(h, l + 46, d));
2265
+ e.set(m, { name: m, method: o, compSize: a, localOffset: g }), l += 46 + d + p + u;
2266
2266
  }
2267
2267
  return e;
2268
2268
  }
2269
2269
  async function tt(h, t) {
2270
2270
  const e = new DataView(h, t.localOffset);
2271
2271
  if (e.getUint32(0, !0) !== 67324752) throw new Error("Bad local header");
2272
- const i = e.getUint16(26, !0), s = e.getUint16(28, !0), l = t.localOffset + 30 + i + s, o = new Uint8Array(h.slice(l, l + t.compSize));
2273
- if (t.method === 0) return o;
2272
+ const i = e.getUint16(26, !0), s = e.getUint16(28, !0), l = t.localOffset + 30 + i + s, n = new Uint8Array(h.slice(l, l + t.compSize));
2273
+ if (t.method === 0) return n;
2274
2274
  if (t.method !== 8) throw new Error("Unsupported compression method " + t.method);
2275
- const n = new Blob([o]).stream().pipeThrough(new DecompressionStream("deflate-raw"));
2276
- return new Uint8Array(await new Response(n).arrayBuffer());
2275
+ const r = new Blob([n]).stream().pipeThrough(new DecompressionStream("deflate-raw"));
2276
+ return new Uint8Array(await new Response(r).arrayBuffer());
2277
2277
  }
2278
2278
  const et = (h) => h.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;"), P = (h, t) => Array.from(h.children).filter((e) => e.localName === t), E = (h, ...t) => {
2279
2279
  let e = h;
@@ -2309,7 +2309,7 @@ const et = (h) => h.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "
2309
2309
  lightGray: "#D3D3D3",
2310
2310
  black: "#000000",
2311
2311
  white: "#FFFFFF"
2312
- }, Wt = {
2312
+ }, Ut = {
2313
2313
  png: "image/png",
2314
2314
  jpg: "image/jpeg",
2315
2315
  jpeg: "image/jpeg",
@@ -2334,12 +2334,12 @@ class jt {
2334
2334
  };
2335
2335
  for (const l of Array.from(t.children))
2336
2336
  if (l.localName === "p") {
2337
- const o = this.paraList(l);
2338
- if (o) {
2339
- const n = o.ilvl + 1;
2340
- for (; i.length > n; ) e += `</${i.pop()}>`;
2341
- for (i.length === n && i[n - 1] !== o.type && (e += `</${i.pop()}>`); i.length < n; )
2342
- e += `<${o.type}>`, i.push(o.type);
2337
+ const n = this.paraList(l);
2338
+ if (n) {
2339
+ const r = n.ilvl + 1;
2340
+ for (; i.length > r; ) e += `</${i.pop()}>`;
2341
+ for (i.length === r && i[r - 1] !== n.type && (e += `</${i.pop()}>`); i.length < r; )
2342
+ e += `<${n.type}>`, i.push(n.type);
2343
2343
  e += `<li>${this.runsOf(l) || "<br>"}</li>`;
2344
2344
  continue;
2345
2345
  }
@@ -2360,10 +2360,10 @@ class jt {
2360
2360
  let s = "p";
2361
2361
  const l = /^Heading([1-6])$/i.exec(i);
2362
2362
  l ? s = "h" + l[1] : /^Title$/i.test(i) && (s = "h1");
2363
- const o = [], n = T(E(t, "pPr", "jc"));
2364
- 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 && E(e, "bidi") && o.push("direction:rtl");
2365
- const r = this.runsOf(t), a = o.length ? ` style="${o.join(";")}"` : "";
2366
- return `<${s}${a}>${r || "<br>"}</${s}>`;
2363
+ const n = [], r = T(E(t, "pPr", "jc"));
2364
+ r === "center" ? n.push("text-align:center") : r === "right" || r === "end" ? n.push("text-align:right") : (r === "both" || r === "distribute") && n.push("text-align:justify"), e && E(e, "bidi") && n.push("direction:rtl");
2365
+ const o = this.runsOf(t), a = n.length ? ` style="${n.join(";")}"` : "";
2366
+ return `<${s}${a}>${o || "<br>"}</${s}>`;
2367
2367
  }
2368
2368
  runsOf(t) {
2369
2369
  let e = "";
@@ -2373,8 +2373,8 @@ class jt {
2373
2373
  let s = this.rels.get(T(i, "id")) || "";
2374
2374
  const l = T(i, "anchor");
2375
2375
  !s && l && (s = "#" + l);
2376
- const o = this.runsOf(i);
2377
- e += s ? `<a href="${et(s)}">${o}</a>` : o;
2376
+ const n = this.runsOf(i);
2377
+ e += s ? `<a href="${et(s)}">${n}</a>` : n;
2378
2378
  } else (i.localName === "smartTag" || i.localName === "ins") && (e += this.runsOf(i));
2379
2379
  return e;
2380
2380
  }
@@ -2386,40 +2386,40 @@ class jt {
2386
2386
  if (!i) return "";
2387
2387
  const s = [], l = T(e ? E(e, "color") : null);
2388
2388
  l && l !== "auto" && s.push("color:#" + l);
2389
- const o = T(e ? E(e, "highlight") : null);
2390
- o && it[o] && s.push("background-color:" + it[o]);
2391
- const n = parseFloat(T(e ? E(e, "sz") : null));
2392
- n && s.push("font-size:" + Math.round(n / 2 * (4 / 3)) + "px");
2393
- const r = e ? E(e, "rFonts") : null, a = T(r, "ascii") || T(r, "cs");
2389
+ const n = T(e ? E(e, "highlight") : null);
2390
+ n && it[n] && s.push("background-color:" + it[n]);
2391
+ const r = parseFloat(T(e ? E(e, "sz") : null));
2392
+ r && s.push("font-size:" + Math.round(r / 2 * (4 / 3)) + "px");
2393
+ const o = e ? E(e, "rFonts") : null, a = T(o, "ascii") || T(o, "cs");
2394
2394
  a && s.push(`font-family:'${a}'`), s.length && (i = `<span style="${s.join(";")}">${i}</span>`), B(e, "b") && (i = `<strong>${i}</strong>`), B(e, "i") && (i = `<em>${i}</em>`), B(e, "u") && T(E(e, "u")) !== "none" && (i = `<u>${i}</u>`), B(e, "strike") && (i = `<s>${i}</s>`);
2395
2395
  const d = T(e ? E(e, "vertAlign") : null);
2396
2396
  return d === "superscript" ? i = `<sup>${i}</sup>` : d === "subscript" && (i = `<sub>${i}</sub>`), i;
2397
2397
  }
2398
2398
  convertImage(t) {
2399
2399
  let e = "", i = 0;
2400
- const s = (n) => {
2401
- if (n.localName === "blip" && (e = e || T(n, "embed") || T(n, "link")), n.localName === "imagedata" && (e = e || T(n, "id")), n.localName === "extent") {
2402
- const r = parseFloat(n.getAttribute("cx") || "0");
2403
- r && (i = Math.round(r / 9525));
2400
+ const s = (r) => {
2401
+ if (r.localName === "blip" && (e = e || T(r, "embed") || T(r, "link")), r.localName === "imagedata" && (e = e || T(r, "id")), r.localName === "extent") {
2402
+ const o = parseFloat(r.getAttribute("cx") || "0");
2403
+ o && (i = Math.round(o / 9525));
2404
2404
  }
2405
- for (const r of Array.from(n.children)) s(r);
2405
+ for (const o of Array.from(r.children)) s(o);
2406
2406
  };
2407
2407
  if (s(t), !e) return "";
2408
2408
  const l = this.images.get(e);
2409
2409
  if (!l) return "";
2410
- const o = i ? ` width="${i}"` : "";
2411
- return `<img src="${l}" alt=""${o}>`;
2410
+ const n = i ? ` width="${i}"` : "";
2411
+ return `<img src="${l}" alt=""${n}>`;
2412
2412
  }
2413
2413
  convertTable(t) {
2414
2414
  let e = '<table style="border-collapse:collapse;width:100%"><tbody>';
2415
2415
  for (const i of P(t, "tr")) {
2416
2416
  e += "<tr>";
2417
2417
  for (const s of P(i, "tc")) {
2418
- const l = parseInt(T(E(s, "tcPr", "gridSpan")) || "1", 10) || 1, o = l > 1 ? ` colspan="${l}"` : "";
2419
- let n = "";
2420
- for (const r of Array.from(s.children))
2421
- r.localName === "p" ? n += this.convertPara(r) : r.localName === "tbl" && (n += this.convertTable(r));
2422
- e += `<td style="border:1px solid #b9c2cc"${o}>${n || "<br>"}</td>`;
2418
+ const l = parseInt(T(E(s, "tcPr", "gridSpan")) || "1", 10) || 1, n = l > 1 ? ` colspan="${l}"` : "";
2419
+ let r = "";
2420
+ for (const o of Array.from(s.children))
2421
+ o.localName === "p" ? r += this.convertPara(o) : o.localName === "tbl" && (r += this.convertTable(o));
2422
+ e += `<td style="border:1px solid #b9c2cc"${n}>${r || "<br>"}</td>`;
2423
2423
  }
2424
2424
  e += "</tr>";
2425
2425
  }
@@ -2427,31 +2427,31 @@ class jt {
2427
2427
  }
2428
2428
  }
2429
2429
  async function Xt(h) {
2430
- const t = h instanceof ArrayBuffer ? h : await h.arrayBuffer(), e = Ut(t), i = new TextDecoder(), s = async (m) => {
2430
+ const t = h instanceof ArrayBuffer ? h : await h.arrayBuffer(), e = Wt(t), i = new TextDecoder(), s = async (m) => {
2431
2431
  const f = e.get(m);
2432
2432
  return f ? new DOMParser().parseFromString(i.decode(await tt(t, f)), "application/xml") : null;
2433
- }, l = await s("word/document.xml"), o = l == null ? void 0 : l.getElementsByTagName("*");
2434
- let n = null;
2435
- if (o) {
2436
- for (const m of Array.from(o))
2433
+ }, l = await s("word/document.xml"), n = l == null ? void 0 : l.getElementsByTagName("*");
2434
+ let r = null;
2435
+ if (n) {
2436
+ for (const m of Array.from(n))
2437
2437
  if (m.localName === "body") {
2438
- n = m;
2438
+ r = m;
2439
2439
  break;
2440
2440
  }
2441
2441
  }
2442
- if (!n) throw new Error("word/document.xml missing or invalid");
2443
- const r = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), d = await s("word/_rels/document.xml.rels");
2442
+ if (!r) throw new Error("word/document.xml missing or invalid");
2443
+ const o = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), d = await s("word/_rels/document.xml.rels");
2444
2444
  if (d)
2445
2445
  for (const m of Array.from(d.getElementsByTagName("*"))) {
2446
2446
  if (m.localName !== "Relationship") continue;
2447
2447
  const f = m.getAttribute("Id") || "", b = m.getAttribute("Target") || "", y = m.getAttribute("Type") || "";
2448
- /hyperlink/i.test(y) ? r.set(f, b) : /image/i.test(y) && a.set(f, b);
2448
+ /hyperlink/i.test(y) ? o.set(f, b) : /image/i.test(y) && a.set(f, b);
2449
2449
  }
2450
2450
  const p = /* @__PURE__ */ new Map();
2451
2451
  for (const [m, f] of a) {
2452
2452
  const b = f.startsWith("/") ? f.slice(1) : "word/" + f.replace(/^\.\//, ""), y = e.get(b);
2453
2453
  if (!y) continue;
2454
- const w = (b.split(".").pop() || "").toLowerCase(), S = Wt[w];
2454
+ const w = (b.split(".").pop() || "").toLowerCase(), S = Ut[w];
2455
2455
  if (S)
2456
2456
  try {
2457
2457
  p.set(m, `data:${S};base64,${Vt(await tt(t, y))}`);
@@ -2472,7 +2472,7 @@ async function Xt(h) {
2472
2472
  u.set(y, m.get(w) || "ul");
2473
2473
  }
2474
2474
  }
2475
- return new jt(r, p, u).convertBody(n);
2475
+ return new jt(o, p, u).convertBody(r);
2476
2476
  }
2477
2477
  const Qt = ["nw", "ne", "sw", "se"], $ = ["img-left", "img-right", "img-top", "img-center"], _ = {
2478
2478
  "img-left": "tplimgleft",
@@ -2498,10 +2498,10 @@ function Kt(h) {
2498
2498
  if (A !== h || !document.contains(h)) return;
2499
2499
  M || (M = document.createElement("div"), M.className = "etip", document.body.appendChild(M)), M.textContent = t, M.classList.add("show");
2500
2500
  const i = h.getBoundingClientRect(), s = M.offsetWidth, l = M.offsetHeight;
2501
- let o = i.left + i.width / 2 - s / 2;
2502
- o = Math.max(6, Math.min(o, innerWidth - s - 6));
2503
- let n = i.bottom + 7;
2504
- n + l > innerHeight - 6 && (n = i.top - l - 7), M.style.left = o + "px", M.style.top = n + "px";
2501
+ let n = i.left + i.width / 2 - s / 2;
2502
+ n = Math.max(6, Math.min(n, innerWidth - s - 6));
2503
+ let r = i.bottom + 7;
2504
+ r + l > innerHeight - 6 && (r = i.top - l - 7), M.style.left = n + "px", M.style.top = r + "px";
2505
2505
  }, e);
2506
2506
  }
2507
2507
  function Jt() {
@@ -2561,7 +2561,7 @@ function me(h) {
2561
2561
  bottom: { width: null, style: null, color: null },
2562
2562
  left: { width: null, style: null, color: null }
2563
2563
  }, s = [];
2564
- let l = !1, o = !1;
2564
+ let l = !1, n = !1;
2565
2565
  if (e.split(";").forEach((a) => {
2566
2566
  const d = a.indexOf(":");
2567
2567
  if (d < 1) {
@@ -2574,7 +2574,7 @@ function me(h) {
2574
2574
  return;
2575
2575
  }
2576
2576
  if (ce.test(u)) {
2577
- o = !0;
2577
+ n = !0;
2578
2578
  return;
2579
2579
  }
2580
2580
  l = !0;
@@ -2594,9 +2594,9 @@ function me(h) {
2594
2594
  i[y] = { ...b };
2595
2595
  });
2596
2596
  }
2597
- }), o || !l) return;
2598
- const n = R.map((a) => ue(i[a])), r = s.slice();
2599
- n.every((a) => a && a === n[0]) ? r.push("border:" + n[0]) : R.forEach((a, d) => n[d] && r.push(`border-${a}:` + n[d])), t.setAttribute("style", r.join(";"));
2597
+ }), n || !l) return;
2598
+ const r = R.map((a) => ue(i[a])), o = s.slice();
2599
+ r.every((a) => a && a === r[0]) ? o.push("border:" + r[0]) : R.forEach((a, d) => r[d] && o.push(`border-${a}:` + r[d])), t.setAttribute("style", o.join(";"));
2600
2600
  });
2601
2601
  }
2602
2602
  function ct(h) {
@@ -2673,12 +2673,12 @@ const I = class I {
2673
2673
  let e = 0, i = 0;
2674
2674
  const s = (l) => {
2675
2675
  e = l.clientY, i = this.ed.offsetHeight, l.preventDefault();
2676
- const o = (r) => {
2677
- this.ed.style.height = Math.max(120, i + r.clientY - e) + "px";
2678
- }, n = () => {
2679
- window.removeEventListener("mousemove", o), window.removeEventListener("mouseup", n);
2676
+ const n = (o) => {
2677
+ this.ed.style.height = Math.max(120, i + o.clientY - e) + "px";
2678
+ }, r = () => {
2679
+ window.removeEventListener("mousemove", n), window.removeEventListener("mouseup", r);
2680
2680
  };
2681
- window.addEventListener("mousemove", o), window.addEventListener("mouseup", n);
2681
+ window.addEventListener("mousemove", n), window.addEventListener("mouseup", r);
2682
2682
  };
2683
2683
  t.addEventListener("mousedown", s), this.listeners.push(() => t.removeEventListener("mousedown", s));
2684
2684
  }
@@ -2696,17 +2696,17 @@ const I = class I {
2696
2696
  }), this.on(this.ed, "keydown", (t) => {
2697
2697
  t.altKey && t.key === "0" && (t.preventDefault(), this.helpDlg()), (t.key === "Delete" || t.key === "Backspace") && this.phActive && (t.preventDefault(), this.removeImgPlaceholder()), (t.key === "Delete" || t.key === "Backspace") && this.vphActive && (t.preventDefault(), this.removeVphPlaceholder()), t.key === "`" && !t.ctrlKey && !t.metaKey && !t.altKey && this.tryCodeTyping(t), t.key === "Enter" && !t.shiftKey && !t.ctrlKey && !t.metaKey && !t.altKey && this.tryExitBlockquote(t);
2698
2698
  }), this.on(this.ed, "paste", (t) => this.handlePaste(t)), this.on(this.ed, "drop", (t) => {
2699
- var l, o, n, r;
2699
+ var l, n, r, o;
2700
2700
  t.preventDefault();
2701
2701
  const e = t.target, i = (l = e.closest) == null ? void 0 : l.call(e, ".img-ph:not(.vid-ph)");
2702
2702
  if (i && this.ed.contains(i) && !this.options.readonly) {
2703
- const a = Array.from(((o = t.dataTransfer) == null ? void 0 : o.files) || []).find((d) => d.type.startsWith("image/"));
2703
+ const a = Array.from(((n = t.dataTransfer) == null ? void 0 : n.files) || []).find((d) => d.type.startsWith("image/"));
2704
2704
  a && this.readImageFileInto(a, i);
2705
2705
  return;
2706
2706
  }
2707
- const s = (n = e.closest) == null ? void 0 : n.call(e, ".vid-ph");
2707
+ const s = (r = e.closest) == null ? void 0 : r.call(e, ".vid-ph");
2708
2708
  if (s && this.ed.contains(s) && !this.options.readonly) {
2709
- const a = Array.from(((r = t.dataTransfer) == null ? void 0 : r.files) || []).find((d) => d.type.startsWith("video/"));
2709
+ const a = Array.from(((o = t.dataTransfer) == null ? void 0 : o.files) || []).find((d) => d.type.startsWith("video/"));
2710
2710
  a && this.readVideoFileInto(a, s);
2711
2711
  }
2712
2712
  }), this.on(this.ed, "dragover", (t) => t.preventDefault()), this.on(this.ed, "mousedown", (t) => {
@@ -2717,12 +2717,12 @@ const I = class I {
2717
2717
  s && this.ed.contains(s) && !this.options.readonly ? (t.preventDefault(), this.ed.focus(), this.selectImgPlaceholder(s)) : this.clearImgPlaceholderSel();
2718
2718
  const l = (u = e.closest) == null ? void 0 : u.call(e, ".vid-ph");
2719
2719
  l && this.ed.contains(l) && !this.options.readonly ? (t.preventDefault(), this.ed.focus(), this.selectVphPlaceholder(l)) : this.clearVphPlaceholderSel();
2720
- const o = (g = e.closest) == null ? void 0 : g.call(e, ".tpl");
2721
- o && this.ed.contains(o) && !this.options.readonly ? this.selectTemplate(o) : this.clearTplSel();
2722
- const n = (m = e.closest) == null ? void 0 : m.call(e, "pre.code-block");
2723
- n && this.ed.contains(n) && !this.options.readonly ? (t.preventDefault(), this.selectCodeEl(n)) : this.clearCodeSel();
2724
- const r = (f = e.closest) == null ? void 0 : f.call(e, "img");
2725
- r && this.ed.contains(r) && !this.options.readonly ? (t.preventDefault(), this.selectImage(r)) : this.clearImageHandles();
2720
+ const n = (g = e.closest) == null ? void 0 : g.call(e, ".tpl");
2721
+ n && this.ed.contains(n) && !this.options.readonly ? this.selectTemplate(n) : this.clearTplSel();
2722
+ const r = (m = e.closest) == null ? void 0 : m.call(e, "pre.code-block");
2723
+ r && this.ed.contains(r) && !this.options.readonly ? (t.preventDefault(), this.selectCodeEl(r)) : this.clearCodeSel();
2724
+ const o = (f = e.closest) == null ? void 0 : f.call(e, "img");
2725
+ o && this.ed.contains(o) && !this.options.readonly ? (t.preventDefault(), this.selectImage(o)) : this.clearImageHandles();
2726
2726
  const a = (b = e.closest) == null ? void 0 : b.call(e, "video, .video-embed");
2727
2727
  a && this.ed.contains(a) && !this.options.readonly ? (t.preventDefault(), this.selectVideo(a)) : this.clearVidHandles();
2728
2728
  }), this.on(this.ed, "mouseover", (t) => {
@@ -2731,11 +2731,11 @@ const I = class I {
2731
2731
  const e = (s = (i = t.target).closest) == null ? void 0 : s.call(i, "img");
2732
2732
  e && this.ed.contains(e) && (this.cancelImgHide(), this.selectImage(e));
2733
2733
  }), this.on(this.ed, "mouseout", (t) => {
2734
- var s, l, o, n;
2734
+ var s, l, n, r;
2735
2735
  const e = (l = (s = t.target).closest) == null ? void 0 : l.call(s, "img");
2736
2736
  if (!e) return;
2737
2737
  const i = t.relatedTarget;
2738
- i && ((o = this.imgCtx) != null && o.contains(i) || this.imgHandles.some((r) => r.contains(i)) || ((n = i.closest) == null ? void 0 : n.call(i, "img")) === e) || this.scheduleImgHide();
2738
+ i && ((n = this.imgCtx) != null && n.contains(i) || this.imgHandles.some((o) => o.contains(i)) || ((r = i.closest) == null ? void 0 : r.call(i, "img")) === e) || this.scheduleImgHide();
2739
2739
  }), this.on(this.ed, "scroll", () => {
2740
2740
  this.positionTableHandles(), this.positionImageHandles(), this.positionImgPhCtx(), this.positionTplCtx(), this.positionVphCtx(), this.positionVidCtx(), this.positionCodeCtx();
2741
2741
  }), this.onWin(
@@ -2817,41 +2817,42 @@ const I = class I {
2817
2817
  * content with no strongly-directional character anywhere falls back to the
2818
2818
  * editor's current direction. */
2819
2819
  getContentForEmail() {
2820
- const t = (n, r) => {
2821
- const a = (n.getAttribute("style") || "").trim();
2822
- n.setAttribute("style", a ? a.replace(/;?$/, "; ") + r : r);
2823
- }, e = document.createElement("div");
2824
- e.innerHTML = this.ed.innerHTML;
2825
- let i = null;
2826
- e.querySelectorAll("[dir]").forEach((n) => {
2827
- const r = (n.getAttribute("dir") || "").toLowerCase();
2828
- if (r !== "rtl" && r !== "ltr") return;
2829
- const a = r;
2830
- i || (i = a), /text-align\s*:/i.test(n.getAttribute("style") || "") || t(n, `text-align:${a === "rtl" ? "right" : "left"}`);
2831
- }), e.querySelectorAll(ie).forEach((n) => {
2832
- const r = (n.getAttribute("dir") || "").toLowerCase();
2833
- if (r === "rtl" || r === "ltr") return;
2834
- const a = se(ct(n));
2835
- if (!a) return;
2836
- i || (i = a), n.setAttribute("dir", a);
2837
- const d = /text-align\s*:/i.test(n.getAttribute("style") || "");
2838
- t(n, d ? `direction:${a}` : `direction:${a};text-align:${a === "rtl" ? "right" : "left"}`);
2820
+ const t = (o, a) => {
2821
+ const d = (o.getAttribute("style") || "").trim();
2822
+ o.setAttribute("style", d ? d.replace(/;?$/, "; ") + a : a);
2823
+ }, e = (o, a) => {
2824
+ const d = (o.getAttribute("style") || "").split(";").map((p) => p.trim()).filter((p) => p && !/^width\s*:/i.test(p));
2825
+ d.push(`width:${a}px`), o.setAttribute("style", d.join("; "));
2826
+ }, i = document.createElement("div");
2827
+ i.innerHTML = this.ed.innerHTML;
2828
+ let s = null;
2829
+ i.querySelectorAll("[dir]").forEach((o) => {
2830
+ const a = (o.getAttribute("dir") || "").toLowerCase();
2831
+ if (a !== "rtl" && a !== "ltr") return;
2832
+ const d = a;
2833
+ s || (s = d), /text-align\s*:/i.test(o.getAttribute("style") || "") || t(o, `text-align:${d === "rtl" ? "right" : "left"}`);
2834
+ }), i.querySelectorAll(ie).forEach((o) => {
2835
+ const a = (o.getAttribute("dir") || "").toLowerCase();
2836
+ if (a === "rtl" || a === "ltr") return;
2837
+ const d = se(ct(o));
2838
+ if (!d) return;
2839
+ s || (s = d), o.setAttribute("dir", d);
2840
+ const p = /text-align\s*:/i.test(o.getAttribute("style") || "");
2841
+ t(o, p ? `direction:${d}` : `direction:${d};text-align:${d === "rtl" ? "right" : "left"}`);
2839
2842
  });
2840
- const s = this.ed.querySelectorAll("img");
2841
- e.querySelectorAll("img").forEach((n, r) => {
2842
- if (n.closest(".tpl-media")) return;
2843
- const a = s[r], d = Math.round((a == null ? void 0 : a.getBoundingClientRect().width) || 0);
2844
- d > 0 && !n.getAttribute("width") && n.setAttribute("width", String(d));
2845
- const p = n.getAttribute("style") || "";
2846
- d > 0 && !/(^|;)\s*width\s*:/i.test(p) && t(n, `width:${d}px`), /max-width\s*:/i.test(n.getAttribute("style") || "") || t(n, "max-width:100%"), /(^|;)\s*height\s*:/i.test(n.getAttribute("style") || "") || t(n, "height:auto");
2847
- }), me(e), e.querySelectorAll("table").forEach((n) => {
2848
- const r = n.getAttribute("style") || "";
2849
- /border-collapse\s*:/i.test(r) || t(n, "border-collapse:collapse"), !/border-spacing\s*:/i.test(r) && !n.hasAttribute("cellspacing") && n.setAttribute("cellspacing", "0");
2843
+ const l = this.ed.querySelectorAll("img");
2844
+ i.querySelectorAll("img").forEach((o, a) => {
2845
+ if (o.closest(".tpl-media")) return;
2846
+ const d = l[a], p = Math.round((d == null ? void 0 : d.offsetWidth) || 0);
2847
+ p > 0 && (o.setAttribute("width", String(p)), o.removeAttribute("height"), e(o, p)), /max-width\s*:/i.test(o.getAttribute("style") || "") || t(o, "max-width:100%"), /(^|;)\s*height\s*:/i.test(o.getAttribute("style") || "") || t(o, "height:auto");
2848
+ }), me(i), i.querySelectorAll("table").forEach((o) => {
2849
+ const a = o.getAttribute("style") || "";
2850
+ /border-collapse\s*:/i.test(a) || t(o, "border-collapse:collapse"), !/border-spacing\s*:/i.test(a) && !o.hasAttribute("cellspacing") && o.setAttribute("cellspacing", "0");
2850
2851
  });
2851
- const l = i || this.ed.getAttribute("dir") || this.dir();
2852
- return e.querySelectorAll("table:not([dir])").forEach((n) => {
2853
- n.setAttribute("dir", l), /direction\s*:/i.test(n.getAttribute("style") || "") || t(n, `direction:${l}`);
2854
- }), `<div dir="${l}" style="direction:${l};text-align:${l === "rtl" ? "right" : "left"}">${e.innerHTML}</div>`;
2852
+ const n = s || this.ed.getAttribute("dir") || this.dir();
2853
+ return i.querySelectorAll("table:not([dir])").forEach((o) => {
2854
+ o.setAttribute("dir", n), /direction\s*:/i.test(o.getAttribute("style") || "") || t(o, `direction:${n}`);
2855
+ }), `<div dir="${n}" style="direction:${n};text-align:${n === "rtl" ? "right" : "left"}">${i.innerHTML}</div>`;
2855
2856
  }
2856
2857
  setContent(t) {
2857
2858
  this.ed.innerHTML = t || "<p><br></p>", this.refreshState(), this.clearTableHandles(), this.clearImageHandles(), this.clearImgPlaceholderSel(), this.clearTplSel(), this.clearVphPlaceholderSel(), this.clearVidHandles(), this.clearCodeSel(), this.clearSelToolbar(), this.onChange(), this.stampExistingImages();
@@ -2925,8 +2926,8 @@ const I = class I {
2925
2926
  t.preventDefault();
2926
2927
  const l = document.createElement("p");
2927
2928
  l.appendChild(document.createElement("br")), s.after(l), i.remove(), s.firstElementChild || s.remove();
2928
- const o = document.createRange();
2929
- o.setStart(l, 0), o.collapse(!0), e.removeAllRanges(), e.addRange(o), this.saveSel(), this.onChange();
2929
+ const n = document.createRange();
2930
+ n.setStart(l, 0), n.collapse(!0), e.removeAllRanges(), e.addRange(n), this.saveSel(), this.onChange();
2930
2931
  }
2931
2932
  selectedBlocks() {
2932
2933
  const t = window.getSelection();
@@ -2976,30 +2977,30 @@ const I = class I {
2976
2977
  s.className = "revprev";
2977
2978
  const l = document.createElement("button");
2978
2979
  l.type = "button", l.className = "revrestore", l.textContent = this.t("restore");
2979
- let o = this.revisions.length - 1;
2980
- const n = new Intl.DateTimeFormat(this.lang === "ar" ? "ar-AE" : "en-GB", {
2980
+ let n = this.revisions.length - 1;
2981
+ const r = new Intl.DateTimeFormat(this.lang === "ar" ? "ar-AE" : "en-GB", {
2981
2982
  year: "numeric",
2982
2983
  month: "short",
2983
2984
  day: "numeric",
2984
2985
  hour: "2-digit",
2985
2986
  minute: "2-digit",
2986
2987
  second: "2-digit"
2987
- }), r = {}, a = (d) => {
2988
- o = d, this.revisions.forEach((p, u) => {
2988
+ }), o = {}, a = (d) => {
2989
+ n = d, this.revisions.forEach((p, u) => {
2989
2990
  var g;
2990
- return (g = r[u]) == null ? void 0 : g.classList.toggle("on", u === d);
2991
+ return (g = o[u]) == null ? void 0 : g.classList.toggle("on", u === d);
2991
2992
  }), s.innerHTML = this.revisions[d].html, l.disabled = d === this.revisions.length - 1;
2992
2993
  };
2993
2994
  for (let d = this.revisions.length - 1; d >= 0; d--) {
2994
2995
  const p = this.revisions[d], u = document.createElement("button");
2995
2996
  u.type = "button";
2996
2997
  const g = (new DOMParser().parseFromString(p.html, "text/html").body.textContent || "").trim(), m = g ? g.split(/\s+/).length : 0, f = d === this.revisions.length - 1;
2997
- u.innerHTML = `<span>${f ? this.t("currentver") : n.format(new Date(p.time))}</span><span class="wc">${m} ${this.t("words")}</span>`, u.addEventListener("click", () => a(d)), r[d] = u, i.appendChild(u);
2998
+ u.innerHTML = `<span>${f ? this.t("currentver") : r.format(new Date(p.time))}</span><span class="wc">${m} ${this.t("words")}</span>`, u.addEventListener("click", () => a(d)), o[d] = u, i.appendChild(u);
2998
2999
  }
2999
3000
  i.append(l), l.addEventListener("click", () => {
3000
- const d = this.revisions[o];
3001
+ const d = this.revisions[n];
3001
3002
  d && (this.recordRevision(), this.setContent(d.html), this.recordRevision(), this.closeDlg());
3002
- }), e.append(i, s), t.appendChild(e), a(o);
3003
+ }), e.append(i, s), t.appendChild(e), a(n);
3003
3004
  });
3004
3005
  }
3005
3006
  /* ---------------------------------------------------------- popups / menus */
@@ -3036,10 +3037,10 @@ const I = class I {
3036
3037
  l.className = "pop sub", l.dir = this.dir(), t.subBuild ? t.subBuild(l) : t.sub && this.menuItems(l, t.sub), l.addEventListener("mousedown", (a) => {
3037
3038
  a.target.tagName !== "INPUT" && a.preventDefault();
3038
3039
  }), document.body.appendChild(l);
3039
- let n = this.dir() === "rtl" ? i.left - l.offsetWidth + 2 : i.right - 2;
3040
- n = Math.max(8, Math.min(n + scrollX, scrollX + innerWidth - l.offsetWidth - 8));
3041
- let r = i.top + scrollY - 6;
3042
- r = Math.max(8 + scrollY, Math.min(r, scrollY + innerHeight - l.offsetHeight - 8)), l.style.left = n + "px", l.style.top = r + "px", this.subStack.push(l);
3040
+ let r = this.dir() === "rtl" ? i.left - l.offsetWidth + 2 : i.right - 2;
3041
+ r = Math.max(8, Math.min(r + scrollX, scrollX + innerWidth - l.offsetWidth - 8));
3042
+ let o = i.top + scrollY - 6;
3043
+ o = Math.max(8 + scrollY, Math.min(o, scrollY + innerHeight - l.offsetHeight - 8)), l.style.left = r + "px", l.style.top = o + "px", this.subStack.push(l);
3043
3044
  }
3044
3045
  popup(t, e, i) {
3045
3046
  if (this.openPop && this.popAnchor === t) {
@@ -3051,10 +3052,10 @@ const I = class I {
3051
3052
  s.className = "pop" + (i ? " " + i : ""), s.dir = this.dir(), e(s), document.body.appendChild(s);
3052
3053
  const l = t.getBoundingClientRect();
3053
3054
  s.style.minWidth = Math.max(160, Math.round(l.width)) + "px";
3054
- let o = l.bottom + scrollY + 2;
3055
- o = Math.max(8 + scrollY, Math.min(o, scrollY + innerHeight - s.offsetHeight - 8)), s.style.top = o + "px";
3056
- let r = this.dir() === "rtl" ? l.right - s.offsetWidth : l.left;
3057
- r = Math.max(8, Math.min(r + scrollX, scrollX + innerWidth - s.offsetWidth - 8)), s.style.left = r + "px", s.addEventListener("mousedown", (a) => {
3055
+ let n = l.bottom + scrollY + 2;
3056
+ n = Math.max(8 + scrollY, Math.min(n, scrollY + innerHeight - s.offsetHeight - 8)), s.style.top = n + "px";
3057
+ let o = this.dir() === "rtl" ? l.right - s.offsetWidth : l.left;
3058
+ o = Math.max(8, Math.min(o + scrollX, scrollX + innerWidth - s.offsetWidth - 8)), s.style.left = o + "px", s.addEventListener("mousedown", (a) => {
3058
3059
  a.target.tagName !== "INPUT" && a.preventDefault();
3059
3060
  }), this.openPop = s, this.popAnchor = t, t.classList.add("open");
3060
3061
  }
@@ -3068,18 +3069,18 @@ const I = class I {
3068
3069
  l.className = "mi" + (i.on ? " on" : ""), l.innerHTML = `<span class="ic">${i.icon || ""}</span><span class="prev" ${i.previewStyle ? `style="${i.previewStyle}"` : ""}>${i.label}</span>${i.shortcut ? `<span class="sc">${i.shortcut}</span>` : ""}${s ? `<span class="subarrow">${c.chev}</span>` : ""}`, l.addEventListener("click", () => {
3069
3070
  i.action && (this.closePop(), i.action());
3070
3071
  }), l.addEventListener("mouseenter", () => {
3071
- var o;
3072
- s ? this.openSubFor(i, l) : this.closeSubFrom(this.subLevelOf(t)), (o = i.hover) == null || o.call(i, !0);
3072
+ var n;
3073
+ s ? this.openSubFor(i, l) : this.closeSubFrom(this.subLevelOf(t)), (n = i.hover) == null || n.call(i, !0);
3073
3074
  }), l.addEventListener("mouseleave", () => {
3074
- var o;
3075
- return (o = i.hover) == null ? void 0 : o.call(i, !1);
3075
+ var n;
3076
+ return (n = i.hover) == null ? void 0 : n.call(i, !1);
3076
3077
  }), t.appendChild(l);
3077
3078
  });
3078
3079
  }
3079
3080
  /* ---------------------------------------------------------- toolbar builders */
3080
3081
  tbtn(t, e, i, s) {
3081
3082
  const l = document.createElement("button");
3082
- return l.className = "tbtn", l.type = "button", l.title = e, l.innerHTML = t, s && (l.dataset.id = s), l.addEventListener("mousedown", (o) => o.preventDefault()), l.addEventListener("click", i), l;
3083
+ return l.className = "tbtn", l.type = "button", l.title = e, l.innerHTML = t, s && (l.dataset.id = s), l.addEventListener("mousedown", (n) => n.preventDefault()), l.addEventListener("click", i), l;
3083
3084
  }
3084
3085
  /** Font-size increase / decrease step button. */
3085
3086
  stepBtn(t) {
@@ -3095,8 +3096,8 @@ const I = class I {
3095
3096
  colorChips() {
3096
3097
  const t = (s) => {
3097
3098
  const l = document.createElement("button");
3098
- return l.type = "button", l.className = "cchip", l.title = s, l.addEventListener("mousedown", (o) => {
3099
- o.preventDefault(), this.saveSel();
3099
+ return l.type = "button", l.className = "cchip", l.title = s, l.addEventListener("mousedown", (n) => {
3100
+ n.preventDefault(), this.saveSel();
3100
3101
  }), l;
3101
3102
  }, e = vt.map((s) => {
3102
3103
  const l = t(this.t("forecolor"));
@@ -3112,17 +3113,17 @@ const I = class I {
3112
3113
  }
3113
3114
  tsel(t, e, i, s) {
3114
3115
  const l = document.createElement("button");
3115
- return l.className = "tsel " + t, l.type = "button", l.dataset.id = e, l.innerHTML = `<span class="lbl empty">${i || ""}</span>${c.chev}`, l.addEventListener("mousedown", (o) => {
3116
- o.preventDefault(), this.saveSel();
3116
+ return l.className = "tsel " + t, l.type = "button", l.dataset.id = e, l.innerHTML = `<span class="lbl empty">${i || ""}</span>${c.chev}`, l.addEventListener("mousedown", (n) => {
3117
+ n.preventDefault(), this.saveSel();
3117
3118
  }), l.addEventListener("click", () => s(l)), l;
3118
3119
  }
3119
3120
  setListStyle(t, e) {
3120
- var l, o;
3121
+ var l, n;
3121
3122
  this.restoreSel();
3122
3123
  const i = window.getSelection();
3123
3124
  if (!i) return;
3124
3125
  let s = (l = this.closestBlock(i.anchorNode)) == null ? void 0 : l.closest(t);
3125
- 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();
3126
+ s || (this.exec(t === "ol" ? "insertOrderedList" : "insertUnorderedList"), s = (n = this.closestBlock(i.anchorNode)) == null ? void 0 : n.closest(t)), s && (s.style.listStyleType = e), this.saveSel(), this.onChange();
3126
3127
  }
3127
3128
  listMenu(t, e) {
3128
3129
  var a;
@@ -3134,7 +3135,7 @@ const I = class I {
3134
3135
  ] : [
3135
3136
  ["circle", c.ul_circle],
3136
3137
  ["square", c.ul_square]
3137
- ], l = this.tArr(e === "ol" ? "liststyles_ol" : "liststyles_ul").slice(1), o = window.getSelection(), n = o ? (a = this.closestBlock(o.anchorNode)) == null ? void 0 : a.closest(e) : null, r = n ? n.style.listStyleType : "";
3138
+ ], l = this.tArr(e === "ol" ? "liststyles_ol" : "liststyles_ul").slice(1), n = window.getSelection(), r = n ? (a = this.closestBlock(n.anchorNode)) == null ? void 0 : a.closest(e) : null, o = r ? r.style.listStyleType : "";
3138
3139
  this.popup(t, (d) => {
3139
3140
  this.menuItems(d, [
3140
3141
  {
@@ -3147,7 +3148,7 @@ const I = class I {
3147
3148
  const p = document.createElement("div");
3148
3149
  p.className = "mi-grid", s.forEach(([u, g], m) => {
3149
3150
  const f = document.createElement("button");
3150
- f.className = "mi" + (r === u ? " on" : ""), f.innerHTML = `<span class="ic">${g}</span><span class="prev">${l[m]}</span>`, f.addEventListener("click", () => {
3151
+ f.className = "mi" + (o === u ? " on" : ""), f.innerHTML = `<span class="ic">${g}</span><span class="prev">${l[m]}</span>`, f.addEventListener("click", () => {
3151
3152
  this.closePop(), this.setListStyle(e, u);
3152
3153
  }), p.appendChild(f);
3153
3154
  }), d.appendChild(p);
@@ -3166,18 +3167,18 @@ const I = class I {
3166
3167
  }), t.appendChild(s), t.insertAdjacentHTML("beforeend", '<div class="sep"></div>');
3167
3168
  const l = document.createElement("div");
3168
3169
  l.className = "cfoot";
3169
- const o = /^#[0-9a-f]{6}$/i.test(e) ? e : "#000000", n = document.createElement("div");
3170
- n.className = "cswatch cur", n.title = this.t("currentcolor"), n.style.background = o, n.innerHTML = c.check;
3171
- const r = document.createElement("button");
3172
- r.type = "button", r.className = "cswatch nocolor", r.title = this.t("removecolor"), r.addEventListener("click", () => {
3170
+ const n = /^#[0-9a-f]{6}$/i.test(e) ? e : "#000000", r = document.createElement("div");
3171
+ r.className = "cswatch cur", r.title = this.t("currentcolor"), r.style.background = n, r.innerHTML = c.check;
3172
+ const o = document.createElement("button");
3173
+ o.type = "button", o.className = "cswatch nocolor", o.title = this.t("removecolor"), o.addEventListener("click", () => {
3173
3174
  this.closePop(), i(null);
3174
3175
  });
3175
3176
  const a = document.createElement("label");
3176
3177
  a.className = "cswatch cwheel", a.title = this.t("customcolor"), a.innerHTML = c.palette;
3177
3178
  const d = document.createElement("input");
3178
- d.type = "color", d.value = o, d.addEventListener("change", () => {
3179
+ d.type = "color", d.value = n, d.addEventListener("change", () => {
3179
3180
  this.closePop(), i(d.value);
3180
- }), a.appendChild(d), l.append(n, r, a), t.appendChild(l);
3181
+ }), a.appendChild(d), l.append(r, o, a), t.appendChild(l);
3181
3182
  }
3182
3183
  colorMenu(t, e) {
3183
3184
  this.popup(
@@ -3223,19 +3224,19 @@ const I = class I {
3223
3224
  const t = window.getSelection();
3224
3225
  if (!t) return;
3225
3226
  if (!t.rangeCount) {
3226
- const o = document.createRange();
3227
- o.selectNodeContents(this.ed), o.collapse(!0), t.addRange(o);
3227
+ const n = document.createRange();
3228
+ n.selectNodeContents(this.ed), n.collapse(!0), t.addRange(n);
3228
3229
  }
3229
3230
  if (!t.isCollapsed) return;
3230
3231
  const e = t.getRangeAt(0), i = e.startContainer;
3231
3232
  if (i.nodeType === 3) {
3232
- const o = i.data;
3233
- let n = e.startOffset, r = e.startOffset;
3234
- for (; n > 0 && /\S/.test(o[n - 1]); ) n--;
3235
- for (; r < o.length && /\S/.test(o[r]); ) r++;
3236
- if (r > n) {
3233
+ const n = i.data;
3234
+ let r = e.startOffset, o = e.startOffset;
3235
+ for (; r > 0 && /\S/.test(n[r - 1]); ) r--;
3236
+ for (; o < n.length && /\S/.test(n[o]); ) o++;
3237
+ if (o > r) {
3237
3238
  const a = document.createRange();
3238
- a.setStart(i, n), a.setEnd(i, r), t.removeAllRanges(), t.addRange(a), this.savedRange = a.cloneRange();
3239
+ a.setStart(i, r), a.setEnd(i, o), t.removeAllRanges(), t.addRange(a), this.savedRange = a.cloneRange();
3239
3240
  return;
3240
3241
  }
3241
3242
  }
@@ -3269,14 +3270,14 @@ const I = class I {
3269
3270
  const e = window.getSelection();
3270
3271
  if (!e || !e.rangeCount || e.isCollapsed) return;
3271
3272
  const i = e.getRangeAt(0), s = document.createTreeWalker(this.ed, NodeFilter.SHOW_TEXT), l = [];
3272
- let o;
3273
- for (; o = s.nextNode(); ) i.intersectsNode(o) && l.push(o);
3274
- l.forEach((n) => {
3275
- const r = n === i.startContainer ? i.startOffset : 0, a = n === i.endContainer ? i.endOffset : n.data.length;
3276
- if (a <= r) return;
3277
- const d = n.data.slice(r, a);
3273
+ let n;
3274
+ for (; n = s.nextNode(); ) i.intersectsNode(n) && l.push(n);
3275
+ l.forEach((r) => {
3276
+ const o = r === i.startContainer ? i.startOffset : 0, a = r === i.endContainer ? i.endOffset : r.data.length;
3277
+ if (a <= o) return;
3278
+ const d = r.data.slice(o, a);
3278
3279
  let p = d;
3279
- t === "lower" ? p = d.toLowerCase() : t === "upper" ? p = d.toUpperCase() : p = d.replace(/(^|\s)(\S)/g, (u, g, m) => g + m.toUpperCase()), n.replaceData(r, a - r, p);
3280
+ t === "lower" ? p = d.toLowerCase() : t === "upper" ? p = d.toUpperCase() : p = d.replace(/(^|\s)(\S)/g, (u, g, m) => g + m.toUpperCase()), r.replaceData(o, a - o, p);
3280
3281
  }), this.saveSel(), this.refreshState(), this.onChange();
3281
3282
  }
3282
3283
  caseItems() {
@@ -3312,7 +3313,7 @@ const I = class I {
3312
3313
  ];
3313
3314
  }
3314
3315
  lineHeightMenu(t) {
3315
- this.popup(t, (e) => this.menuItems(e, this.blockStyleItems("lineHeight", W)));
3316
+ this.popup(t, (e) => this.menuItems(e, this.blockStyleItems("lineHeight", U)));
3316
3317
  }
3317
3318
  wordSpacingMenu(t) {
3318
3319
  this.popup(t, (e) => this.menuItems(e, this.blockStyleItems("wordSpacing", V)));
@@ -3364,8 +3365,8 @@ const I = class I {
3364
3365
  (s) => {
3365
3366
  const l = document.createElement("div");
3366
3367
  l.style.cssText = "display:flex;align-items:center;gap:10px;margin:10px 0;min-width:360px";
3367
- const o = document.createElement("span");
3368
- o.style.cssText = "width:60px;color:#556;flex:none", o.textContent = this.t("linkurl"), e = document.createElement("input"), e.type = "url", e.placeholder = "https://", e.style.cssText = "flex:1;border:1px solid #cfd6df;border-radius:6px;padding:7px 9px;font:14px inherit", e.value = (t == null ? void 0 : t.getAttribute("href")) || "", l.append(o, e), s.appendChild(l), setTimeout(() => e.focus(), 0);
3368
+ const n = document.createElement("span");
3369
+ n.style.cssText = "width:60px;color:#556;flex:none", n.textContent = this.t("linkurl"), e = document.createElement("input"), e.type = "url", e.placeholder = "https://", e.style.cssText = "flex:1;border:1px solid #cfd6df;border-radius:6px;padding:7px 9px;font:14px inherit", e.value = (t == null ? void 0 : t.getAttribute("href")) || "", l.append(n, e), s.appendChild(l), setTimeout(() => e.focus(), 0);
3369
3370
  },
3370
3371
  i
3371
3372
  );
@@ -3408,15 +3409,15 @@ const I = class I {
3408
3409
  s.className = "tgrid";
3409
3410
  const l = document.createElement("div");
3410
3411
  l.className = "tgridlbl", l.textContent = "1 × 1";
3411
- const o = [];
3412
- for (let n = 0; n < 8; n++)
3413
- for (let r = 0; r < 10; r++) {
3412
+ const n = [];
3413
+ for (let r = 0; r < 8; r++)
3414
+ for (let o = 0; o < 10; o++) {
3414
3415
  const a = document.createElement("span");
3415
- a.dataset.r = String(n), a.dataset.c = String(r), a.addEventListener("mouseenter", () => {
3416
- o.forEach((d) => d.classList.toggle("hot", +d.dataset.r <= n && +d.dataset.c <= r)), l.textContent = r + 1 + " × " + (n + 1);
3416
+ a.dataset.r = String(r), a.dataset.c = String(o), a.addEventListener("mouseenter", () => {
3417
+ n.forEach((d) => d.classList.toggle("hot", +d.dataset.r <= r && +d.dataset.c <= o)), l.textContent = o + 1 + " × " + (r + 1);
3417
3418
  }), a.addEventListener("click", () => {
3418
- this.closePop(), this.insertTable(n + 1, r + 1), e == null || e();
3419
- }), o.push(a), s.appendChild(a);
3419
+ this.closePop(), this.insertTable(r + 1, o + 1), e == null || e();
3420
+ }), n.push(a), s.appendChild(a);
3420
3421
  }
3421
3422
  i.append(s, l), t.appendChild(i);
3422
3423
  }
@@ -3505,13 +3506,13 @@ const I = class I {
3505
3506
  this.parseToolbarString(t).forEach((i) => {
3506
3507
  const s = [];
3507
3508
  i.forEach((l) => {
3508
- const o = e[l];
3509
- if (!o) {
3509
+ const n = e[l];
3510
+ if (!n) {
3510
3511
  console.warn(`FableEditor: unknown toolbar item "${l}"`);
3511
3512
  return;
3512
3513
  }
3513
- const n = o();
3514
- Array.isArray(n) ? s.push(...n) : s.push(n);
3514
+ const r = n();
3515
+ Array.isArray(r) ? s.push(...r) : s.push(r);
3515
3516
  }), s.length && this.toolbar.appendChild(this.group(...s));
3516
3517
  }), this.tbrMore = this.tbtn(c.more, this.t("more"), () => {
3517
3518
  this.tbrExpanded = !this.tbrExpanded, this.updateToolbarOverflow();
@@ -3611,7 +3612,7 @@ const I = class I {
3611
3612
  { label: this.t("fontsize"), subBuild: (s) => this.menuItems(s, this.sizeItems()) },
3612
3613
  { label: this.t("blocks"), subBuild: (s) => this.menuItems(s, this.blockItems()) },
3613
3614
  { label: this.t("align"), subBuild: (s) => this.menuItems(s, this.alignItems()) },
3614
- { label: this.t("lineheight"), icon: c.lineheight, subBuild: (s) => this.menuItems(s, this.blockStyleItems("lineHeight", W)) },
3615
+ { label: this.t("lineheight"), icon: c.lineheight, subBuild: (s) => this.menuItems(s, this.blockStyleItems("lineHeight", U)) },
3615
3616
  { label: this.t("wordspacing"), icon: c.wordspacing, subBuild: (s) => this.menuItems(s, this.blockStyleItems("wordSpacing", V)) },
3616
3617
  { label: this.t("letterspacing"), icon: c.letterspacing, subBuild: (s) => this.menuItems(s, this.blockStyleItems("letterSpacing", j)) },
3617
3618
  "|",
@@ -3691,36 +3692,36 @@ const I = class I {
3691
3692
  return;
3692
3693
  }
3693
3694
  const l = document.createElement("button");
3694
- l.type = "button", l.textContent = this.t(s), l.dataset.menuKey = s, l.addEventListener("mousedown", (o) => {
3695
- o.preventDefault(), this.saveSel();
3696
- }), l.addEventListener("click", () => this.popup(l, (o) => this.menuItems(o, t[s]))), this.menubar.appendChild(l);
3695
+ l.type = "button", l.textContent = this.t(s), l.dataset.menuKey = s, l.addEventListener("mousedown", (n) => {
3696
+ n.preventDefault(), this.saveSel();
3697
+ }), l.addEventListener("click", () => this.popup(l, (n) => this.menuItems(n, t[s]))), this.menubar.appendChild(l);
3697
3698
  });
3698
3699
  }
3699
3700
  /* ---------------------------------------------------------- table ops */
3700
3701
  tableOp(t) {
3701
- var r, a, d;
3702
+ var o, a, d;
3702
3703
  this.restoreSel();
3703
3704
  const e = window.getSelection();
3704
3705
  if (!e) return;
3705
- const i = ((r = this.closestBlock(e.anchorNode)) == null ? void 0 : r.closest("td,th")) || (e.anchorNode && e.anchorNode.nodeType === 1 ? (d = (a = e.anchorNode).closest) == null ? void 0 : d.call(a, "td,th") : null);
3706
+ const i = ((o = this.closestBlock(e.anchorNode)) == null ? void 0 : o.closest("td,th")) || (e.anchorNode && e.anchorNode.nodeType === 1 ? (d = (a = e.anchorNode).closest) == null ? void 0 : d.call(a, "td,th") : null);
3706
3707
  if (!i) return;
3707
- const s = i.parentElement, l = i.closest("table"), o = Array.from(s.children).indexOf(i), n = () => {
3708
+ const s = i.parentElement, l = i.closest("table"), n = Array.from(s.children).indexOf(i), r = () => {
3708
3709
  const p = s.cloneNode(!1);
3709
3710
  return Array.from(s.children).forEach((u) => {
3710
3711
  const g = document.createElement("td"), m = u.getAttribute("style");
3711
3712
  m && g.setAttribute("style", m), g.style.removeProperty("background-color"), g.innerHTML = "<br>", p.appendChild(g);
3712
3713
  }), p;
3713
3714
  };
3714
- if (t === "rowabove" && s.before(n()), t === "rowbelow" && s.after(n()), t === "delrow") {
3715
+ if (t === "rowabove" && s.before(r()), t === "rowbelow" && s.after(r()), t === "delrow") {
3715
3716
  const p = s.parentElement;
3716
3717
  s.remove(), p.querySelector("tr") || l.remove();
3717
3718
  }
3718
3719
  (t === "colbefore" || t === "colafter") && l.querySelectorAll("tr").forEach((p) => {
3719
- const u = p.children[Math.min(o, p.children.length - 1)], g = document.createElement("td"), m = u.getAttribute("style");
3720
+ const u = p.children[Math.min(n, p.children.length - 1)], g = document.createElement("td"), m = u.getAttribute("style");
3720
3721
  m && g.setAttribute("style", m), g.style.removeProperty("width"), g.style.removeProperty("background-color"), g.innerHTML = "<br>", t === "colbefore" ? u.before(g) : u.after(g);
3721
3722
  }), t === "delcol" && (l.querySelectorAll("tr").forEach((p) => {
3722
3723
  var u;
3723
- return (u = p.children[o]) == null ? void 0 : u.remove();
3724
+ return (u = p.children[n]) == null ? void 0 : u.remove();
3724
3725
  }), l.querySelector("td,th") || l.remove()), t === "deltable" && l.remove(), this.onChange(), this.positionTableHandles();
3725
3726
  }
3726
3727
  /** Reorders the current row/column: 'rowup'/'rowdown' swap the caret's row with
@@ -3732,24 +3733,24 @@ const I = class I {
3732
3733
  if (!e) return;
3733
3734
  const i = e.parentElement, s = e.closest("table"), l = Array.from(i.children).indexOf(e);
3734
3735
  if (t === "rowup") {
3735
- const r = i.previousElementSibling;
3736
- r && r.before(i);
3736
+ const o = i.previousElementSibling;
3737
+ o && o.before(i);
3737
3738
  }
3738
3739
  if (t === "rowdown") {
3739
- const r = i.nextElementSibling;
3740
- r && r.after(i);
3740
+ const o = i.nextElementSibling;
3741
+ o && o.after(i);
3741
3742
  }
3742
- t === "colleft" && l > 0 && s.querySelectorAll("tr").forEach((r) => {
3743
- const a = r.children[l], d = r.children[l - 1];
3743
+ t === "colleft" && l > 0 && s.querySelectorAll("tr").forEach((o) => {
3744
+ const a = o.children[l], d = o.children[l - 1];
3744
3745
  a && d && d.before(a);
3745
- }), t === "colright" && s.querySelectorAll("tr").forEach((r) => {
3746
- const a = r.children[l], d = r.children[l + 1];
3746
+ }), t === "colright" && s.querySelectorAll("tr").forEach((o) => {
3747
+ const a = o.children[l], d = o.children[l + 1];
3747
3748
  a && d && d.after(a);
3748
3749
  });
3749
- const o = document.createRange();
3750
- o.selectNodeContents(e), o.collapse(!0);
3751
- const n = window.getSelection();
3752
- n && (n.removeAllRanges(), n.addRange(o)), this.saveSel(), this.onChange(), this.positionTableHandles(), this.positionCellMarker();
3750
+ const n = document.createRange();
3751
+ n.selectNodeContents(e), n.collapse(!0);
3752
+ const r = window.getSelection();
3753
+ r && (r.removeAllRanges(), r.addRange(n)), this.saveSel(), this.onChange(), this.positionTableHandles(), this.positionCellMarker();
3753
3754
  }
3754
3755
  /** Align the whole table via auto margins — same semantics as the align
3755
3756
  * field in the table-properties dialog. */
@@ -3786,26 +3787,26 @@ const I = class I {
3786
3787
  tablePropsDlg() {
3787
3788
  const t = this.tblActive;
3788
3789
  if (!t) return;
3789
- let e, i, s, l, o;
3790
- const n = "display:flex;align-items:center;gap:10px;margin:10px 0", r = "width:120px;color:#556;flex:none", a = "flex:1;border:1px solid #cfd6df;border-radius:6px;padding:7px 9px;font:14px inherit", d = t.querySelector("td,th"), p = t.style.width || "", u = d && d.style.padding ? parseFloat(d.style.padding) : "", g = t.style.borderSpacing ? parseFloat(t.style.borderSpacing) : "", m = t.style.borderWidth ? parseFloat(t.style.borderWidth) : "", f = t.style.marginLeft, b = t.style.marginRight, y = f === "auto" && b === "auto" ? "center" : f === "auto" ? "right" : b === "auto" && f === "0" ? "left" : "";
3790
+ let e, i, s, l, n;
3791
+ const r = "display:flex;align-items:center;gap:10px;margin:10px 0", o = "width:120px;color:#556;flex:none", a = "flex:1;border:1px solid #cfd6df;border-radius:6px;padding:7px 9px;font:14px inherit", d = t.querySelector("td,th"), p = t.style.width || "", u = d && d.style.padding ? parseFloat(d.style.padding) : "", g = t.style.borderSpacing ? parseFloat(t.style.borderSpacing) : "", m = t.style.borderWidth ? parseFloat(t.style.borderWidth) : "", f = t.style.marginLeft, b = t.style.marginRight, y = f === "auto" && b === "auto" ? "center" : f === "auto" ? "right" : b === "auto" && f === "0" ? "left" : "";
3791
3792
  this.dialog(
3792
3793
  this.t("tablepropsttl"),
3793
3794
  (w) => {
3794
3795
  const S = (C, k) => {
3795
3796
  const L = document.createElement("div");
3796
- L.style.cssText = n;
3797
+ L.style.cssText = r;
3797
3798
  const H = document.createElement("span");
3798
- H.style.cssText = r, H.textContent = this.t(C), L.append(H, k), w.appendChild(L);
3799
+ H.style.cssText = o, H.textContent = this.t(C), L.append(H, k), w.appendChild(L);
3799
3800
  };
3800
- e = document.createElement("input"), e.type = "text", e.style.cssText = a, e.placeholder = "e.g. 600px or 100%", e.value = p, S("tblwidth", e), i = document.createElement("input"), i.type = "number", i.min = "0", i.style.cssText = a, i.value = String(u), S("tblcellpadding", i), s = document.createElement("input"), s.type = "number", s.min = "0", s.style.cssText = a, s.value = String(g), S("tblcellspacing", s), l = document.createElement("input"), l.type = "number", l.min = "0", l.style.cssText = a, l.value = String(m), S("tblborder", l), o = document.createElement("select"), o.style.cssText = a, [
3801
+ e = document.createElement("input"), e.type = "text", e.style.cssText = a, e.placeholder = "e.g. 600px or 100%", e.value = p, S("tblwidth", e), i = document.createElement("input"), i.type = "number", i.min = "0", i.style.cssText = a, i.value = String(u), S("tblcellpadding", i), s = document.createElement("input"), s.type = "number", s.min = "0", s.style.cssText = a, s.value = String(g), S("tblcellspacing", s), l = document.createElement("input"), l.type = "number", l.min = "0", l.style.cssText = a, l.value = String(m), S("tblborder", l), n = document.createElement("select"), n.style.cssText = a, [
3801
3802
  ["", "alignnone"],
3802
3803
  ["left", "alignleft"],
3803
3804
  ["center", "aligncenter"],
3804
3805
  ["right", "alignright"]
3805
3806
  ].forEach(([C, k]) => {
3806
3807
  const L = document.createElement("option");
3807
- L.value = C, L.textContent = this.t(k), C === y && (L.selected = !0), o.appendChild(L);
3808
- }), S("tblalign", o);
3808
+ L.value = C, L.textContent = this.t(k), C === y && (L.selected = !0), n.appendChild(L);
3809
+ }), S("tblalign", n);
3809
3810
  },
3810
3811
  [
3811
3812
  { label: this.t("cancel"), action: () => this.closeDlg() },
@@ -3818,7 +3819,7 @@ const I = class I {
3818
3819
  cellpadding: i.value.trim(),
3819
3820
  cellspacing: s.value.trim(),
3820
3821
  border: l.value.trim(),
3821
- align: o.value
3822
+ align: n.value
3822
3823
  }), this.closeDlg(), this.onChange(), this.positionTableHandles();
3823
3824
  }
3824
3825
  }
@@ -3857,8 +3858,8 @@ const I = class I {
3857
3858
  formSelect(t, e) {
3858
3859
  const i = document.createElement("select");
3859
3860
  return i.style.cssText = "flex:1;border:1px solid #cfd6df;border-radius:6px;padding:7px 9px;font:14px inherit;background:#fff", t.forEach(([s, l]) => {
3860
- const o = document.createElement("option");
3861
- o.value = s, o.textContent = l, s === e && (o.selected = !0), i.appendChild(o);
3861
+ const n = document.createElement("option");
3862
+ n.value = s, n.textContent = l, s === e && (n.selected = !0), i.appendChild(n);
3862
3863
  }), i;
3863
3864
  }
3864
3865
  formBg(t) {
@@ -3868,8 +3869,8 @@ const I = class I {
3868
3869
  s.type = "color", s.value = i || "#ffffff", s.style.cssText = "width:36px;height:29px;border:1px solid #cfd6df;border-radius:4px;padding:1px;background:none;cursor:pointer";
3869
3870
  const l = document.createElement("label");
3870
3871
  l.style.cssText = "display:flex;align-items:center;gap:6px;cursor:pointer;color:#556";
3871
- const o = document.createElement("input");
3872
- return o.type = "checkbox", o.checked = !!i, l.append(o, document.createTextNode(this.t("fill"))), s.addEventListener("input", () => o.checked = !0), e.append(s, l), { wrap: e, color: s, fill: o };
3872
+ const n = document.createElement("input");
3873
+ return n.type = "checkbox", n.checked = !!i, l.append(n, document.createTextNode(this.t("fill"))), s.addEventListener("input", () => n.checked = !0), e.append(s, l), { wrap: e, color: s, fill: n };
3873
3874
  }
3874
3875
  setOrClear(t, e, i) {
3875
3876
  i ? t.style.setProperty(e, /^(width|height)$/.test(e) && /^\d+$/.test(i) ? i + "px" : i) : t.style.removeProperty(e);
@@ -3880,11 +3881,11 @@ const I = class I {
3880
3881
  alert(this.t("nocell"));
3881
3882
  return;
3882
3883
  }
3883
- let e, i, s, l, o;
3884
+ let e, i, s, l, n;
3884
3885
  this.dialog(
3885
3886
  this.t("cellprops").replace("…", ""),
3886
- (n) => {
3887
- e = this.formInput(t.style.width, "e.g. 120px / 25%"), this.formRow(n, this.t("tblwidth"), e), i = this.formInput(t.style.height, "e.g. 40px"), this.formRow(n, this.t("tblheight"), i), s = this.formSelect(
3887
+ (r) => {
3888
+ e = this.formInput(t.style.width, "e.g. 120px / 25%"), this.formRow(r, this.t("tblwidth"), e), i = this.formInput(t.style.height, "e.g. 40px"), this.formRow(r, this.t("tblheight"), i), s = this.formSelect(
3888
3889
  [
3889
3890
  ["", this.t("alignnone")],
3890
3891
  ["left", this.t("alignleft")],
@@ -3892,7 +3893,7 @@ const I = class I {
3892
3893
  ["right", this.t("alignright")]
3893
3894
  ],
3894
3895
  t.style.textAlign || ""
3895
- ), this.formRow(n, this.t("tblalign"), s), l = this.formSelect(
3896
+ ), this.formRow(r, this.t("tblalign"), s), l = this.formSelect(
3896
3897
  [
3897
3898
  ["", this.t("alignnone")],
3898
3899
  ["top", this.t("valigntop")],
@@ -3900,7 +3901,7 @@ const I = class I {
3900
3901
  ["bottom", this.t("valignbottom")]
3901
3902
  ],
3902
3903
  t.style.verticalAlign || ""
3903
- ), this.formRow(n, this.t("valign"), l), o = this.formBg(t.style.backgroundColor || ""), this.formRow(n, this.t("backcolor"), o.wrap);
3904
+ ), this.formRow(r, this.t("valign"), l), n = this.formBg(t.style.backgroundColor || ""), this.formRow(r, this.t("backcolor"), n.wrap);
3904
3905
  },
3905
3906
  [
3906
3907
  { label: this.t("cancel"), action: () => this.closeDlg() },
@@ -3908,7 +3909,7 @@ const I = class I {
3908
3909
  label: this.t("save"),
3909
3910
  primary: !0,
3910
3911
  action: () => {
3911
- this.setOrClear(t, "width", e.value.trim()), this.setOrClear(t, "height", i.value.trim()), this.setOrClear(t, "text-align", s.value), this.setOrClear(t, "vertical-align", l.value), this.setOrClear(t, "background-color", o.fill.checked ? o.color.value : ""), this.closeDlg(), this.onChange(), this.positionTableHandles();
3912
+ this.setOrClear(t, "width", e.value.trim()), this.setOrClear(t, "height", i.value.trim()), this.setOrClear(t, "text-align", s.value), this.setOrClear(t, "vertical-align", l.value), this.setOrClear(t, "background-color", n.fill.checked ? n.color.value : ""), this.closeDlg(), this.onChange(), this.positionTableHandles();
3912
3913
  }
3913
3914
  }
3914
3915
  ]
@@ -3945,12 +3946,12 @@ const I = class I {
3945
3946
  alert(this.t("nocell"));
3946
3947
  return;
3947
3948
  }
3948
- const e = t.parentElement, i = t.closest("table"), s = Array.from(e.children).indexOf(t), l = Array.from(i.rows).map((r) => r.cells[s]).filter(Boolean);
3949
- let o, n;
3949
+ const e = t.parentElement, i = t.closest("table"), s = Array.from(e.children).indexOf(t), l = Array.from(i.rows).map((o) => o.cells[s]).filter(Boolean);
3950
+ let n, r;
3950
3951
  this.dialog(
3951
3952
  this.t("colprops").replace("…", ""),
3952
- (r) => {
3953
- o = this.formInput(t.style.width, "e.g. 120px / 25%"), this.formRow(r, this.t("tblwidth"), o), n = this.formBg(t.style.backgroundColor || ""), this.formRow(r, this.t("backcolor"), n.wrap);
3953
+ (o) => {
3954
+ n = this.formInput(t.style.width, "e.g. 120px / 25%"), this.formRow(o, this.t("tblwidth"), n), r = this.formBg(t.style.backgroundColor || ""), this.formRow(o, this.t("backcolor"), r.wrap);
3954
3955
  },
3955
3956
  [
3956
3957
  { label: this.t("cancel"), action: () => this.closeDlg() },
@@ -3958,8 +3959,8 @@ const I = class I {
3958
3959
  label: this.t("save"),
3959
3960
  primary: !0,
3960
3961
  action: () => {
3961
- l.forEach((r) => {
3962
- this.setOrClear(r, "width", o.value.trim()), this.setOrClear(r, "background-color", n.fill.checked ? n.color.value : "");
3962
+ l.forEach((o) => {
3963
+ this.setOrClear(o, "width", n.value.trim()), this.setOrClear(o, "background-color", r.fill.checked ? r.color.value : "");
3963
3964
  }), this.closeDlg(), this.onChange(), this.positionTableHandles();
3964
3965
  }
3965
3966
  }
@@ -3975,8 +3976,8 @@ const I = class I {
3975
3976
  const s = document.createElement("div");
3976
3977
  s.className = "dlg", s.dir = this.dir(), s.innerHTML = `<header><span>${t}</span><button type="button">×</button></header>
3977
3978
  <div class="body"></div><footer></footer>`, s.querySelector("header button").onclick = () => this.closeDlg(), e(s.querySelector(".body")), (i || [{ label: this.t("close"), primary: !0, action: () => this.closeDlg() }]).forEach((l) => {
3978
- const o = document.createElement("button");
3979
- o.type = "button", o.textContent = l.label, l.primary && (o.className = "pri"), o.onclick = l.action, s.querySelector("footer").appendChild(o);
3979
+ const n = document.createElement("button");
3980
+ n.type = "button", n.textContent = l.label, l.primary && (n.className = "pri"), n.onclick = l.action, s.querySelector("footer").appendChild(n);
3980
3981
  }), this.dlgOvl.appendChild(s), this.dlgOvl.addEventListener("mousedown", (l) => {
3981
3982
  l.target === this.dlgOvl && this.closeDlg();
3982
3983
  }), document.body.appendChild(this.dlgOvl);
@@ -4031,7 +4032,7 @@ const I = class I {
4031
4032
  const e = document.createElement("div");
4032
4033
  e.className = "pv-box";
4033
4034
  const i = this.contentWidth();
4034
- e.style.cssText = `width:${i > 0 ? Math.round(i) : 640}px;max-width:100%;max-height:52vh;overflow:auto;border:1px solid #e3e3e3;border-radius:6px;padding:14px;font-family:Helvetica,Arial,sans-serif;font-size:14px`, e.innerHTML = this.ed.innerHTML, t.appendChild(e);
4035
+ e.style.cssText = `width:${i > 0 ? Math.round(i) : 640}px;max-width:100%;max-height:52vh;overflow:auto;box-sizing:content-box;border:1px solid #e3e3e3;border-radius:6px;padding:14px;font-family:Helvetica,Arial,sans-serif;font-size:14px`, e.innerHTML = this.ed.innerHTML, t.appendChild(e);
4035
4036
  });
4036
4037
  }
4037
4038
  /** Two-pane picker shared by the special-character map and the emoji map:
@@ -4040,24 +4041,24 @@ const I = class I {
4040
4041
  this.saveSel(), this.dialog(t, (s) => {
4041
4042
  const l = document.createElement("div");
4042
4043
  l.className = "chmap";
4043
- const o = document.createElement("div");
4044
- o.className = "chtabs";
4045
4044
  const n = document.createElement("div");
4046
- n.className = "chpanel";
4045
+ n.className = "chtabs";
4047
4046
  const r = document.createElement("div");
4048
- r.className = "chgrid" + (i ? " emgrid" : ""), n.appendChild(r);
4047
+ r.className = "chpanel";
4048
+ const o = document.createElement("div");
4049
+ o.className = "chgrid" + (i ? " emgrid" : ""), r.appendChild(o);
4049
4050
  const a = (d) => {
4050
- o.querySelectorAll("button").forEach((p, u) => p.classList.toggle("on", u === d)), r.innerHTML = "", e[d].chars.forEach((p) => {
4051
+ n.querySelectorAll("button").forEach((p, u) => p.classList.toggle("on", u === d)), o.innerHTML = "", e[d].chars.forEach((p) => {
4051
4052
  const u = document.createElement("button");
4052
4053
  u.type = "button", u.textContent = p, u.onclick = () => {
4053
4054
  this.closeDlg(), this.exec("insertText", p);
4054
- }, r.appendChild(u);
4055
- }), n.scrollTop = 0;
4055
+ }, o.appendChild(u);
4056
+ }), r.scrollTop = 0;
4056
4057
  };
4057
4058
  e.forEach((d, p) => {
4058
4059
  const u = document.createElement("button");
4059
- u.type = "button", u.textContent = this.t(d.key), u.addEventListener("click", () => a(p)), o.appendChild(u);
4060
- }), l.append(o, n), s.appendChild(l), a(0);
4060
+ u.type = "button", u.textContent = this.t(d.key), u.addEventListener("click", () => a(p)), n.appendChild(u);
4061
+ }), l.append(n, r), s.appendChild(l), a(0);
4061
4062
  });
4062
4063
  }
4063
4064
  charMap() {
@@ -4126,17 +4127,17 @@ const I = class I {
4126
4127
  const i = document.createElement("button");
4127
4128
  i.type = "button", i.className = "txtbtn", i.textContent = this.t("insertimg");
4128
4129
  const s = () => {
4129
- const l = e.value.trim(), o = this.phActive;
4130
- if (!o) return;
4130
+ const l = e.value.trim(), n = this.phActive;
4131
+ if (!n) return;
4131
4132
  if (!/^(https?:|data:image\/|blob:)/i.test(l)) {
4132
4133
  e.classList.add("err"), e.focus();
4133
4134
  return;
4134
4135
  }
4135
4136
  i.disabled = !0, e.disabled = !0;
4136
- const n = new Image();
4137
- n.onload = () => this.replacePlaceholderWithImage(o, l, ""), n.onerror = () => {
4137
+ const r = new Image();
4138
+ r.onload = () => this.replacePlaceholderWithImage(n, l, ""), r.onerror = () => {
4138
4139
  i.disabled = !1, e.disabled = !1, e.classList.add("err"), e.focus();
4139
- }, n.src = l;
4140
+ }, r.src = l;
4140
4141
  };
4141
4142
  i.addEventListener("click", s), e.addEventListener("input", () => e.classList.remove("err")), e.addEventListener("keydown", (l) => {
4142
4143
  l.key === "Enter" ? (l.preventDefault(), s()) : l.key === "Escape" && (l.stopPropagation(), this.renderPhCtxButtons());
@@ -4162,8 +4163,8 @@ const I = class I {
4162
4163
  s && (s.textContent = this.t("uploading")), this.imageUploadHandler(t).then((l) => {
4163
4164
  this.ed.contains(e) && this.replacePlaceholderWithImage(e, l, i);
4164
4165
  }).catch((l) => {
4165
- var o;
4166
- this.ed.contains(e) && (e.classList.remove("uploading"), e.classList.add("upload-error"), s && (s.textContent = this.t("uploadfailed")), (o = this.onImageUploadError) == null || o.call(this, l, t));
4166
+ var n;
4167
+ this.ed.contains(e) && (e.classList.remove("uploading"), e.classList.add("upload-error"), s && (s.textContent = this.t("uploadfailed")), (n = this.onImageUploadError) == null || n.call(this, l, t));
4167
4168
  });
4168
4169
  }
4169
4170
  replacePlaceholderWithImage(t, e, i) {
@@ -4201,8 +4202,8 @@ const I = class I {
4201
4202
  if (!this.ed.contains(t) || t.closest(".tpl-media") || t.getAttribute("width") || t.getAttribute("height") || t.style.width || t.style.height) return i(!1);
4202
4203
  const l = t.naturalWidth;
4203
4204
  if (!l) return i(!1);
4204
- const o = this.contentWidth(), n = Math.round(o > 0 ? Math.min(l, o) : l);
4205
- t.setAttribute("width", String(n)), t.style.width = n + "px", t.style.height = "auto", i(!0);
4205
+ const n = this.contentWidth(), r = Math.round(n > 0 ? Math.min(l, n) : l);
4206
+ t.setAttribute("width", String(r)), t.style.width = r + "px", t.style.height = "auto", i(!0);
4206
4207
  };
4207
4208
  t.complete && t.naturalWidth ? s() : (t.addEventListener("load", s, { once: !0 }), t.addEventListener("error", () => i(!1), { once: !0 }));
4208
4209
  }
@@ -4277,22 +4278,22 @@ const I = class I {
4277
4278
  const i = document.createElement("button");
4278
4279
  i.type = "button", i.className = "txtbtn", i.textContent = this.t("insertvideo");
4279
4280
  const s = () => {
4280
- const l = e.value.trim(), o = this.vphActive;
4281
- if (!o) return;
4281
+ const l = e.value.trim(), n = this.vphActive;
4282
+ if (!n) return;
4282
4283
  if (!/^(https?:|data:video\/|blob:)/i.test(l)) {
4283
4284
  e.classList.add("err"), e.focus();
4284
4285
  return;
4285
4286
  }
4286
- const n = this.videoEmbedUrl(l);
4287
- if (n) {
4288
- this.replacePlaceholderWithEmbed(o, n);
4287
+ const r = this.videoEmbedUrl(l);
4288
+ if (r) {
4289
+ this.replacePlaceholderWithEmbed(n, r);
4289
4290
  return;
4290
4291
  }
4291
4292
  i.disabled = !0, e.disabled = !0;
4292
- const r = document.createElement("video");
4293
- r.preload = "metadata", r.onloadedmetadata = () => this.replacePlaceholderWithVideo(o, l, ""), r.onerror = () => {
4293
+ const o = document.createElement("video");
4294
+ o.preload = "metadata", o.onloadedmetadata = () => this.replacePlaceholderWithVideo(n, l, ""), o.onerror = () => {
4294
4295
  i.disabled = !1, e.disabled = !1, e.classList.add("err"), e.focus();
4295
- }, r.src = l;
4296
+ }, o.src = l;
4296
4297
  };
4297
4298
  i.addEventListener("click", s), e.addEventListener("input", () => e.classList.remove("err")), e.addEventListener("keydown", (l) => {
4298
4299
  l.key === "Enter" ? (l.preventDefault(), s()) : l.key === "Escape" && (l.stopPropagation(), this.renderVphCtxButtons());
@@ -4318,8 +4319,8 @@ const I = class I {
4318
4319
  s && (s.textContent = this.t("uploading")), this.videoUploadHandler(t).then((l) => {
4319
4320
  this.ed.contains(e) && this.replacePlaceholderWithVideo(e, l, i);
4320
4321
  }).catch((l) => {
4321
- var o;
4322
- this.ed.contains(e) && (e.classList.remove("uploading"), e.classList.add("upload-error"), s && (s.textContent = this.t("uploadfailed")), (o = this.onVideoUploadError) == null || o.call(this, l, t));
4322
+ var n;
4323
+ this.ed.contains(e) && (e.classList.remove("uploading"), e.classList.add("upload-error"), s && (s.textContent = this.t("uploadfailed")), (n = this.onVideoUploadError) == null || n.call(this, l, t));
4323
4324
  });
4324
4325
  }
4325
4326
  replacePlaceholderWithVideo(t, e, i) {
@@ -4363,16 +4364,16 @@ const I = class I {
4363
4364
  (d = this.vidCtx) == null || d.replaceWith(a), this.vidCtx = a, this.positionVidCtx();
4364
4365
  }, s = (a) => {
4365
4366
  this.setVideoAlign(t, a), i();
4366
- }, l = t.style.float === "left", o = t.style.float === "right", n = !l && !o && t.style.marginLeft === "auto" && t.style.marginRight === "auto", r = (a, d, p, u) => {
4367
+ }, l = t.style.float === "left", n = t.style.float === "right", r = !l && !n && t.style.marginLeft === "auto" && t.style.marginRight === "auto", o = (a, d, p, u) => {
4367
4368
  const g = this.ctxBtn(a, d, u);
4368
4369
  return g.classList.toggle("on", p), g;
4369
4370
  };
4370
4371
  return e.append(
4371
- r(c.alignleft, this.t("alignleft"), l, () => s("left")),
4372
- r(c.aligncenter, this.t("aligncenter"), n, () => s("center")),
4373
- r(c.alignright, this.t("alignright"), o, () => s("right")),
4372
+ o(c.alignleft, this.t("alignleft"), l, () => s("left")),
4373
+ o(c.aligncenter, this.t("aligncenter"), r, () => s("center")),
4374
+ o(c.alignright, this.t("alignright"), n, () => s("right")),
4374
4375
  this.ctxSep(),
4375
- r(c.trash, this.t("deletevideo"), !1, () => {
4376
+ o(c.trash, this.t("deletevideo"), !1, () => {
4376
4377
  t.remove(), this.clearVidHandles(), this.onChange();
4377
4378
  })
4378
4379
  ), e.addEventListener("mousedown", (a) => a.preventDefault()), e.addEventListener("mouseenter", () => this.cancelVidHide()), e.addEventListener("mouseleave", () => {
@@ -4412,13 +4413,13 @@ const I = class I {
4412
4413
  * (videoUploadHandler when configured, else inline base64). */
4413
4414
  videoDlg() {
4414
4415
  this.saveSel();
4415
- let t, e, i, s, l, o;
4416
- const n = (a, d) => {
4416
+ let t, e, i, s, l, n;
4417
+ const r = (a, d) => {
4417
4418
  const p = document.createElement("div");
4418
4419
  p.className = "dfield";
4419
4420
  const u = document.createElement("label");
4420
4421
  return u.textContent = this.t(a), p.append(u, d), p;
4421
- }, r = () => {
4422
+ }, o = () => {
4422
4423
  const a = document.createElement("input");
4423
4424
  return a.type = "url", a;
4424
4425
  };
@@ -4438,7 +4439,7 @@ const I = class I {
4438
4439
  d.querySelectorAll("button").forEach((b, y) => b.classList.toggle("on", y === f)), p.forEach((b, y) => b.style.display = y === f ? "" : "none");
4439
4440
  };
4440
4441
  u("vidgeneral", (f) => {
4441
- t = r(), t.placeholder = this.t("videourlph");
4442
+ t = o(), t.placeholder = this.t("videourlph");
4442
4443
  const b = document.createElement("div");
4443
4444
  b.className = "drow";
4444
4445
  const y = document.createElement("button");
@@ -4456,21 +4457,21 @@ const I = class I {
4456
4457
  };
4457
4458
  if (this.videoUploadHandler)
4458
4459
  this.videoUploadHandler(C).then(k).catch((H) => {
4459
- var U;
4460
- y.disabled = !1, y.textContent = this.t("uploadfailed"), (U = this.onVideoUploadError) == null || U.call(this, H, C);
4460
+ var W;
4461
+ y.disabled = !1, y.textContent = this.t("uploadfailed"), (W = this.onVideoUploadError) == null || W.call(this, H, C);
4461
4462
  });
4462
4463
  else {
4463
4464
  const H = new FileReader();
4464
4465
  H.onload = () => k(H.result), H.readAsDataURL(C);
4465
4466
  }
4466
- }), b.append(t, y, w), t.style.flex = "1", f.appendChild(n("vidsource", b));
4467
+ }), b.append(t, y, w), t.style.flex = "1", f.appendChild(r("vidsource", b));
4467
4468
  const S = document.createElement("div");
4468
- S.className = "drow", e = document.createElement("input"), e.type = "number", e.value = "560", i = document.createElement("input"), i.type = "number", i.value = "314", S.append(n("tblwidth", e), n("tblheight", i)), f.appendChild(S);
4469
+ S.className = "drow", e = document.createElement("input"), e.type = "number", e.value = "560", i = document.createElement("input"), i.type = "number", i.value = "314", S.append(r("tblwidth", e), r("tblheight", i)), f.appendChild(S);
4469
4470
  }), u("vidembed", (f) => {
4470
4471
  const b = document.createElement("p");
4471
4472
  b.textContent = this.t("vidembedhint"), b.style.cssText = "margin:0 0 8px;color:#556;font-size:13.5px", s = document.createElement("textarea"), s.style.cssText = "width:100%;box-sizing:border-box;height:160px", f.append(b, s);
4472
4473
  }), u("vidadvanced", (f) => {
4473
- l = r(), o = r(), f.append(n("vidaltsource", l), n("vidposter", o));
4474
+ l = o(), n = o(), f.append(r("vidaltsource", l), r("vidposter", n));
4474
4475
  });
4475
4476
  const m = document.createElement("div");
4476
4477
  m.className = "dtabbody", p.forEach((f) => m.appendChild(f)), a.append(d, m), g(0), setTimeout(() => t.focus(), 0);
@@ -4491,7 +4492,7 @@ const I = class I {
4491
4492
  if (g)
4492
4493
  document.execCommand("insertHTML", !1, this.videoEmbedHTML(g, p, u));
4493
4494
  else {
4494
- const m = l.value.trim(), f = o.value.trim();
4495
+ const m = l.value.trim(), f = n.value.trim();
4495
4496
  document.execCommand(
4496
4497
  "insertHTML",
4497
4498
  !1,
@@ -4553,42 +4554,42 @@ const I = class I {
4553
4554
  if (i.nodeType !== Node.TEXT_NODE || !this.ed.contains(i) || (d = i.parentElement) != null && d.closest("code, pre")) return;
4554
4555
  const l = (i.textContent || "").slice(0, e.anchorOffset).match(/(?:^|[^`])`([^`]+)$/);
4555
4556
  if (!l) return;
4556
- const o = l[1];
4557
- if (/^\s|\s$/.test(o)) return;
4557
+ const n = l[1];
4558
+ if (/^\s|\s$/.test(n)) return;
4558
4559
  t.preventDefault();
4559
- const n = document.createRange();
4560
- n.setStart(i, e.anchorOffset - o.length - 1), n.setEnd(i, e.anchorOffset), n.deleteContents();
4561
- const r = document.createElement("code");
4562
- r.textContent = o, n.insertNode(r);
4560
+ const r = document.createRange();
4561
+ r.setStart(i, e.anchorOffset - n.length - 1), r.setEnd(i, e.anchorOffset), r.deleteContents();
4562
+ const o = document.createElement("code");
4563
+ o.textContent = n, r.insertNode(o);
4563
4564
  const a = document.createRange();
4564
- a.setStartAfter(r), a.collapse(!0), e.removeAllRanges(), e.addRange(a), this.saveSel(), this.onChange();
4565
+ a.setStartAfter(o), a.collapse(!0), e.removeAllRanges(), e.addRange(a), this.saveSel(), this.onChange();
4565
4566
  }
4566
4567
  /** Custom dropdown for dialog fields (a native <select> popup can't be styled):
4567
4568
  * a field-styled button showing the current choice that opens a floating,
4568
4569
  * scrollable option list. Read the current choice via `.value()`. */
4569
4570
  dlgSelect(t, e) {
4570
- var r;
4571
+ var o;
4571
4572
  let i = e;
4572
4573
  const s = document.createElement("div");
4573
4574
  s.className = "dsel";
4574
4575
  const l = document.createElement("button");
4575
4576
  l.type = "button", l.className = "dsel-btn";
4576
- const o = document.createElement("span");
4577
- o.className = "lbl", o.textContent = ((r = t.find(([a]) => a === e)) == null ? void 0 : r[1]) || "", l.append(o), l.insertAdjacentHTML("beforeend", c.chev);
4578
- const n = document.createElement("div");
4579
- return n.className = "dsel-list", t.forEach(([a, d]) => {
4577
+ const n = document.createElement("span");
4578
+ n.className = "lbl", n.textContent = ((o = t.find(([a]) => a === e)) == null ? void 0 : o[1]) || "", l.append(n), l.insertAdjacentHTML("beforeend", c.chev);
4579
+ const r = document.createElement("div");
4580
+ return r.className = "dsel-list", t.forEach(([a, d]) => {
4580
4581
  const p = document.createElement("button");
4581
4582
  p.type = "button", p.textContent = d, p.classList.toggle("on", a === i), p.addEventListener("click", () => {
4582
- i = a, o.textContent = d, n.querySelectorAll("button").forEach((u) => u.classList.toggle("on", u === p)), s.classList.remove("open"), l.focus();
4583
- }), n.appendChild(p);
4583
+ i = a, n.textContent = d, r.querySelectorAll("button").forEach((u) => u.classList.toggle("on", u === p)), s.classList.remove("open"), l.focus();
4584
+ }), r.appendChild(p);
4584
4585
  }), l.addEventListener("click", () => {
4585
4586
  var a;
4586
- s.classList.toggle("open"), s.classList.contains("open") && ((a = n.querySelector(".on")) == null || a.scrollIntoView({ block: "nearest" }));
4587
+ s.classList.toggle("open"), s.classList.contains("open") && ((a = r.querySelector(".on")) == null || a.scrollIntoView({ block: "nearest" }));
4587
4588
  }), s.addEventListener("focusout", (a) => {
4588
4589
  s.contains(a.relatedTarget) || s.classList.remove("open");
4589
4590
  }), s.addEventListener("keydown", (a) => {
4590
4591
  a.key === "Escape" && s.classList.contains("open") && (a.stopPropagation(), s.classList.remove("open"), l.focus());
4591
- }), s.append(l, n), { el: s, value: () => i };
4592
+ }), s.append(l, r), { el: s, value: () => i };
4592
4593
  }
4593
4594
  /** Insert/edit-code-sample dialog: language dropdown + monospace textarea to
4594
4595
  * paste or type code into. Inserts a non-editable <pre class="code-block">
@@ -4599,11 +4600,11 @@ const I = class I {
4599
4600
  this.dialog(
4600
4601
  this.t("codedlgttl"),
4601
4602
  (s) => {
4602
- var n;
4603
+ var r;
4603
4604
  const l = document.createElement("div");
4604
4605
  l.className = "dfield";
4605
- const o = document.createElement("label");
4606
- o.textContent = this.t("codelang"), e = this.dlgSelect(X, (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);
4606
+ const n = document.createElement("label");
4607
+ n.textContent = this.t("codelang"), e = this.dlgSelect(X, (t == null ? void 0 : t.dataset.lang) || "plain"), l.append(n, e.el), i = document.createElement("textarea"), i.className = "code-input", i.spellcheck = !1, i.value = ((r = t == null ? void 0 : t.querySelector("code")) == null ? void 0 : r.textContent) || "", i.placeholder = "const answer = 42;", s.append(l, i), setTimeout(() => i.focus(), 0);
4607
4608
  },
4608
4609
  [
4609
4610
  { label: this.t("cancel"), action: () => this.closeDlg() },
@@ -4611,19 +4612,19 @@ const I = class I {
4611
4612
  label: this.t("save"),
4612
4613
  primary: !0,
4613
4614
  action: () => {
4614
- var n;
4615
- const s = i.value.replace(/\s+$/, ""), l = e.value(), o = ((n = X.find(([r]) => r === l)) == null ? void 0 : n[1]) || l;
4615
+ var r;
4616
+ const s = i.value.replace(/\s+$/, ""), l = e.value(), n = ((r = X.find(([o]) => o === l)) == null ? void 0 : r[1]) || l;
4616
4617
  if (this.closeDlg(), !!s.trim()) {
4617
4618
  if (t) {
4618
- t.dataset.lang = l, t.setAttribute("data-lang-label", o);
4619
- const r = t.querySelector("code") || t;
4620
- r.textContent = s, this.clearCodeSel(), this.onChange();
4619
+ t.dataset.lang = l, t.setAttribute("data-lang-label", n);
4620
+ const o = t.querySelector("code") || t;
4621
+ o.textContent = s, this.clearCodeSel(), this.onChange();
4621
4622
  return;
4622
4623
  }
4623
4624
  this.restoreSel(), document.execCommand(
4624
4625
  "insertHTML",
4625
4626
  !1,
4626
- `<pre class="code-block" contenteditable="false" data-lang="${l}" data-lang-label="${this.escapeAttr(o)}"><code>${this.escHtml(s)}</code></pre><p><br></p>`
4627
+ `<pre class="code-block" contenteditable="false" data-lang="${l}" data-lang-label="${this.escapeAttr(n)}"><code>${this.escHtml(s)}</code></pre><p><br></p>`
4627
4628
  ), this.onChange();
4628
4629
  }
4629
4630
  }
@@ -4680,8 +4681,8 @@ const I = class I {
4680
4681
  /** Miniature div-based mockup of a layout, mirroring what the block looks
4681
4682
  like in the editor: grey box = image slot, bars = heading/paragraph. */
4682
4683
  tplPreviewHTML(t) {
4683
- const e = '<span class="pv-img"></span>', i = '<span class="pv-h"></span>', s = (r) => `<span class="pv-l" style="width:${r}%"></span>`, l = (r) => `<span class="pv-col">${r}</span>`, o = (r) => `<span class="pv-row">${r}</span>`, n = l(i + s(100) + s(88));
4684
- return t === "img-left" ? `<span class="pv">${o(e + n)}${s(100)}${s(72)}</span>` : t === "img-right" ? `<span class="pv">${o(n + e)}${s(100)}${s(72)}</span>` : t === "img-top" ? `<span class="pv pv-c">${e}${i}${s(100)}${s(72)}</span>` : `<span class="pv pv-c">${i}${s(100)}${s(72)}${e}</span>`;
4684
+ const e = '<span class="pv-img"></span>', i = '<span class="pv-h"></span>', s = (o) => `<span class="pv-l" style="width:${o}%"></span>`, l = (o) => `<span class="pv-col">${o}</span>`, n = (o) => `<span class="pv-row">${o}</span>`, r = l(i + s(100) + s(88));
4685
+ return t === "img-left" ? `<span class="pv">${n(e + r)}${s(100)}${s(72)}</span>` : t === "img-right" ? `<span class="pv">${n(r + e)}${s(100)}${s(72)}</span>` : t === "img-top" ? `<span class="pv pv-c">${e}${i}${s(100)}${s(72)}</span>` : `<span class="pv pv-c">${i}${s(100)}${s(72)}${e}</span>`;
4685
4686
  }
4686
4687
  buildTemplatePickInto(t, e) {
4687
4688
  const i = document.createElement("div");
@@ -4746,7 +4747,7 @@ const I = class I {
4746
4747
  /* ---------------------------------------------------------- table resize */
4747
4748
  clearTableHandles() {
4748
4749
  var t, e, i, s, l;
4749
- (t = this.tblCorner) == null || t.remove(), this.tblCorner = null, this.tblColBars.forEach((o) => o.remove()), this.tblColBars = [], (e = this.tblCtx) == null || e.remove(), this.tblCtx = null, (i = this.tblCellMark) == null || i.remove(), this.tblCellMark = null, (s = this.tblOpMark) == null || s.remove(), this.tblOpMark = null, this.tblOpMarkKind = null, (l = this.tblActive) == null || l.classList.remove("tbl-selected"), this.tblActive = null;
4750
+ (t = this.tblCorner) == null || t.remove(), this.tblCorner = null, this.tblColBars.forEach((n) => n.remove()), this.tblColBars = [], (e = this.tblCtx) == null || e.remove(), this.tblCtx = null, (i = this.tblCellMark) == null || i.remove(), this.tblCellMark = null, (s = this.tblOpMark) == null || s.remove(), this.tblOpMark = null, this.tblOpMarkKind = null, (l = this.tblActive) == null || l.classList.remove("tbl-selected"), this.tblActive = null;
4750
4751
  }
4751
4752
  /** Blue outline around the cell that holds the caret, so it is clear
4752
4753
  which cell / row / column the table operations will target. */
@@ -4773,8 +4774,8 @@ const I = class I {
4773
4774
  return;
4774
4775
  }
4775
4776
  this.tblOpMark || (this.tblOpMark = document.createElement("div"), this.tblOpMark.className = "tbl-opmark", document.body.appendChild(this.tblOpMark));
4776
- 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, a = t === "row" ? l.height : i.height;
4777
- this.tblOpMark.style.left = o + scrollX + "px", this.tblOpMark.style.top = n + scrollY + "px", this.tblOpMark.style.width = r + "px", this.tblOpMark.style.height = a + "px";
4777
+ const i = this.tblActive.getBoundingClientRect(), s = e.getBoundingClientRect(), l = e.parentElement.getBoundingClientRect(), n = t === "row" ? l.left : s.left, r = t === "row" ? l.top : i.top, o = t === "row" ? l.width : s.width, a = t === "row" ? l.height : i.height;
4778
+ this.tblOpMark.style.left = n + scrollX + "px", this.tblOpMark.style.top = r + scrollY + "px", this.tblOpMark.style.width = o + "px", this.tblOpMark.style.height = a + "px";
4778
4779
  }
4779
4780
  /** Lowest allowed top for floating context toolbars — keeps them from
4780
4781
  covering the editor menubar/toolbar when the target sits on the first line. */
@@ -4783,7 +4784,7 @@ const I = class I {
4783
4784
  }
4784
4785
  ctxBtn(t, e, i, s) {
4785
4786
  const l = document.createElement("button");
4786
- return l.type = "button", l.title = e, l.innerHTML = t, s && (l.dataset.id = s), l.addEventListener("mousedown", (o) => o.preventDefault()), l.addEventListener("click", i), l;
4787
+ return l.type = "button", l.title = e, l.innerHTML = t, s && (l.dataset.id = s), l.addEventListener("mousedown", (n) => n.preventDefault()), l.addEventListener("click", i), l;
4787
4788
  }
4788
4789
  ctxSep() {
4789
4790
  const t = document.createElement("div");
@@ -4820,20 +4821,20 @@ const I = class I {
4820
4821
  this.clearTableHandles();
4821
4822
  return;
4822
4823
  }
4823
- 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;
4824
- 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) {
4825
- const r = this.tblCtx.offsetWidth, a = this.tblCtx.offsetHeight;
4826
- let d = s + (l - s) / 2 - r / 2;
4827
- d = Math.max(8 + scrollX, Math.min(d, scrollX + innerWidth - r - 8));
4824
+ const t = this.ed.getAttribute("dir") === "rtl", e = this.tblActive.getBoundingClientRect(), i = e.top + scrollY, s = e.left + scrollX, l = e.right + scrollX, n = e.bottom + scrollY;
4825
+ if (this.tblCorner && (this.tblCorner.style.top = n - 5 + "px", this.tblCorner.style.left = (t ? s - 5 : l - 5) + "px", this.tblCorner.style.cursor = t ? "nesw-resize" : "nwse-resize"), this.tblCtx) {
4826
+ const o = this.tblCtx.offsetWidth, a = this.tblCtx.offsetHeight;
4827
+ let d = s + (l - s) / 2 - o / 2;
4828
+ d = Math.max(8 + scrollX, Math.min(d, scrollX + innerWidth - o - 8));
4828
4829
  let p = i - a - 8;
4829
- p < this.ctxMinTop() && (p = o + 8), this.tblCtx.style.left = d + "px", this.tblCtx.style.top = p + "px";
4830
+ p < this.ctxMinTop() && (p = n + 8), this.tblCtx.style.left = d + "px", this.tblCtx.style.top = p + "px";
4830
4831
  }
4831
- this.tblColBars.forEach((r) => r.remove()), this.tblColBars = [];
4832
- const n = this.tblActive.rows[0];
4833
- if (n)
4834
- for (let r = 0; r < n.cells.length - 1; r++) {
4835
- const a = n.cells[r].getBoundingClientRect(), d = (t ? a.left : a.right) + scrollX, p = document.createElement("div");
4836
- p.className = "tbl-colbar", p.style.top = i + "px", p.style.left = d + "px", p.style.height = o - i + "px", document.body.appendChild(p), p.addEventListener("mousedown", (u) => this.startColBarDrag(u, r)), this.tblColBars.push(p);
4832
+ this.tblColBars.forEach((o) => o.remove()), this.tblColBars = [];
4833
+ const r = this.tblActive.rows[0];
4834
+ if (r)
4835
+ for (let o = 0; o < r.cells.length - 1; o++) {
4836
+ const a = r.cells[o].getBoundingClientRect(), d = (t ? a.left : a.right) + scrollX, p = document.createElement("div");
4837
+ p.className = "tbl-colbar", p.style.top = i + "px", p.style.left = d + "px", p.style.height = n - i + "px", document.body.appendChild(p), p.addEventListener("mousedown", (u) => this.startColBarDrag(u, o)), this.tblColBars.push(p);
4837
4838
  }
4838
4839
  this.positionCellMarker(), this.positionOpMark();
4839
4840
  }
@@ -4851,27 +4852,27 @@ const I = class I {
4851
4852
  const e = this.tblActive;
4852
4853
  if (!e) return;
4853
4854
  const i = this.ed.getAttribute("dir") === "rtl", s = t.clientX, l = e.getBoundingClientRect().width;
4854
- e.style.tableLayout = e.style.tableLayout || "fixed", this.withNoTextSelect((o) => {
4855
- const n = (a) => {
4855
+ e.style.tableLayout = e.style.tableLayout || "fixed", this.withNoTextSelect((n) => {
4856
+ const r = (a) => {
4856
4857
  const d = i ? -(a.clientX - s) : a.clientX - s;
4857
4858
  e.style.width = Math.max(60, Math.round(l + d)) + "px", this.positionTableHandles();
4858
- }, r = () => {
4859
- window.removeEventListener("mousemove", n), window.removeEventListener("mouseup", r), o(), this.onChange();
4859
+ }, o = () => {
4860
+ window.removeEventListener("mousemove", r), window.removeEventListener("mouseup", o), n(), this.onChange();
4860
4861
  };
4861
- window.addEventListener("mousemove", n), window.addEventListener("mouseup", r);
4862
+ window.addEventListener("mousemove", r), window.addEventListener("mouseup", o);
4862
4863
  });
4863
4864
  }
4864
4865
  startColBarDrag(t, e) {
4865
4866
  t.preventDefault(), t.stopPropagation();
4866
4867
  const i = this.tblActive;
4867
4868
  if (!i) return;
4868
- const s = this.ed.getAttribute("dir") === "rtl", l = Array.from(i.rows), o = l.map((p) => p.cells[e]).filter(Boolean), n = l.map((p) => p.cells[e + 1]).filter(Boolean);
4869
- if (!o.length || !n.length) return;
4870
- const r = t.clientX, a = o[0].getBoundingClientRect().width, d = n[0].getBoundingClientRect().width;
4869
+ const s = this.ed.getAttribute("dir") === "rtl", l = Array.from(i.rows), n = l.map((p) => p.cells[e]).filter(Boolean), r = l.map((p) => p.cells[e + 1]).filter(Boolean);
4870
+ if (!n.length || !r.length) return;
4871
+ const o = t.clientX, a = n[0].getBoundingClientRect().width, d = r[0].getBoundingClientRect().width;
4871
4872
  i.style.tableLayout = "fixed", this.withNoTextSelect((p) => {
4872
4873
  const u = (m) => {
4873
- const f = (s ? -1 : 1) * (m.clientX - r);
4874
- o.forEach((b) => b.style.width = Math.max(24, Math.round(a + f)) + "px"), n.forEach((b) => b.style.width = Math.max(24, Math.round(d - f)) + "px"), this.positionTableHandles();
4874
+ const f = (s ? -1 : 1) * (m.clientX - o);
4875
+ n.forEach((b) => b.style.width = Math.max(24, Math.round(a + f)) + "px"), r.forEach((b) => b.style.width = Math.max(24, Math.round(d - f)) + "px"), this.positionTableHandles();
4875
4876
  }, g = () => {
4876
4877
  window.removeEventListener("mousemove", u), window.removeEventListener("mouseup", g), p(), this.onChange();
4877
4878
  };
@@ -4904,30 +4905,30 @@ const I = class I {
4904
4905
  (d = this.imgCtx) == null || d.replaceWith(a), this.imgCtx = a, this.positionImageHandles();
4905
4906
  }, s = (a) => {
4906
4907
  this.setImageAlign(t, a), i();
4907
- }, l = t.style.float === "left", o = t.style.float === "right", n = !l && !o && t.style.marginLeft === "auto" && t.style.marginRight === "auto", r = (a, d, p, u) => {
4908
+ }, l = t.style.float === "left", n = t.style.float === "right", r = !l && !n && t.style.marginLeft === "auto" && t.style.marginRight === "auto", o = (a, d, p, u) => {
4908
4909
  const g = this.ctxBtn(a, d, u);
4909
4910
  return g.classList.toggle("on", p), g;
4910
4911
  };
4911
4912
  return e.append(
4912
- r(c.alignleft, this.t("alignleft"), l, () => s("left")),
4913
- r(c.aligncenter, this.t("aligncenter"), n, () => s("center")),
4914
- r(c.alignright, this.t("alignright"), o, () => s("right")),
4913
+ o(c.alignleft, this.t("alignleft"), l, () => s("left")),
4914
+ o(c.aligncenter, this.t("aligncenter"), r, () => s("center")),
4915
+ o(c.alignright, this.t("alignright"), n, () => s("right")),
4915
4916
  this.ctxSep(),
4916
- r(c.rotateleft, this.t("rotateleft"), !1, () => {
4917
+ o(c.rotateleft, this.t("rotateleft"), !1, () => {
4917
4918
  this.rotateImage(t, -90), i();
4918
4919
  }),
4919
- r(c.rotateright, this.t("rotateright"), !1, () => {
4920
+ o(c.rotateright, this.t("rotateright"), !1, () => {
4920
4921
  this.rotateImage(t, 90), i();
4921
4922
  }),
4922
4923
  this.ctxSep(),
4923
- r(c.fliphorizontal, this.t("fliphorizontal"), t.dataset.flipx === "1", () => {
4924
+ o(c.fliphorizontal, this.t("fliphorizontal"), t.dataset.flipx === "1", () => {
4924
4925
  this.flipImage(t, "x"), i();
4925
4926
  }),
4926
- r(c.flipvertical, this.t("flipvertical"), t.dataset.flipy === "1", () => {
4927
+ o(c.flipvertical, this.t("flipvertical"), t.dataset.flipy === "1", () => {
4927
4928
  this.flipImage(t, "y"), i();
4928
4929
  }),
4929
4930
  this.ctxSep(),
4930
- r(c.trash, this.t("deleteimg"), !1, () => {
4931
+ o(c.trash, this.t("deleteimg"), !1, () => {
4931
4932
  const a = t.closest(".tpl-media");
4932
4933
  a && this.ed.contains(a) ? t.outerHTML = this.imgPhHTML() : t.remove(), this.clearImageHandles(), this.onChange();
4933
4934
  })
@@ -4953,20 +4954,20 @@ const I = class I {
4953
4954
  this.clearImageHandles();
4954
4955
  return;
4955
4956
  }
4956
- const t = this.imgActive.getBoundingClientRect(), e = t.top + scrollY, i = t.left + scrollX, s = t.right + scrollX, l = t.bottom + scrollY, o = {
4957
+ const t = this.imgActive.getBoundingClientRect(), e = t.top + scrollY, i = t.left + scrollX, s = t.right + scrollX, l = t.bottom + scrollY, n = {
4957
4958
  nw: [i, e],
4958
4959
  ne: [s, e],
4959
4960
  sw: [i, l],
4960
4961
  se: [s, l]
4961
4962
  };
4962
- if (this.imgHandles.forEach((n) => {
4963
- const [r, a] = o[n.dataset.corner];
4964
- n.style.left = r - 5 + "px", n.style.top = a - 5 + "px";
4963
+ if (this.imgHandles.forEach((r) => {
4964
+ const [o, a] = n[r.dataset.corner];
4965
+ r.style.left = o - 5 + "px", r.style.top = a - 5 + "px";
4965
4966
  }), this.imgCtx) {
4966
- const n = this.imgCtx.offsetWidth, r = this.imgCtx.offsetHeight;
4967
- let a = i + (s - i) / 2 - n / 2;
4968
- a = Math.max(8 + scrollX, Math.min(a, scrollX + innerWidth - n - 8));
4969
- let d = e - r - 8;
4967
+ const r = this.imgCtx.offsetWidth, o = this.imgCtx.offsetHeight;
4968
+ let a = i + (s - i) / 2 - r / 2;
4969
+ a = Math.max(8 + scrollX, Math.min(a, scrollX + innerWidth - r - 8));
4970
+ let d = e - o - 8;
4970
4971
  d < this.ctxMinTop() && (d = l + 8), this.imgCtx.style.left = a + "px", this.imgCtx.style.top = d + "px";
4971
4972
  }
4972
4973
  }
@@ -4975,16 +4976,17 @@ const I = class I {
4975
4976
  const i = this.imgActive;
4976
4977
  if (!i) return;
4977
4978
  this.cancelImgHide();
4978
- const s = t.clientX, l = i.getBoundingClientRect().width, o = e === "nw" || e === "sw" ? -1 : 1;
4979
- this.withNoTextSelect((n) => {
4980
- const r = (d) => {
4981
- i.style.width = Math.max(24, Math.round(l + o * (d.clientX - s))) + "px", i.style.height = "auto", this.positionImageHandles();
4982
- }, a = () => {
4983
- window.removeEventListener("mousemove", r), window.removeEventListener("mouseup", a), n();
4984
- const d = parseInt(i.style.width, 10);
4985
- d > 0 && !i.closest(".tpl-media") && (i.setAttribute("width", String(d)), i.removeAttribute("height")), this.onChange();
4979
+ const s = t.clientX, l = i.offsetWidth || i.getBoundingClientRect().width, n = e === "nw" || e === "sw" ? -1 : 1, r = Math.round(this.contentWidth());
4980
+ this.withNoTextSelect((o) => {
4981
+ const a = (p) => {
4982
+ let u = Math.max(24, Math.round(l + n * (p.clientX - s)));
4983
+ r > 0 && (u = Math.min(u, r)), i.style.width = u + "px", i.style.height = "auto", this.positionImageHandles();
4984
+ }, d = () => {
4985
+ window.removeEventListener("mousemove", a), window.removeEventListener("mouseup", d), o();
4986
+ const p = Math.round(i.offsetWidth) || parseInt(i.style.width, 10);
4987
+ p > 0 && !i.closest(".tpl-media") && (i.style.width = p + "px", i.setAttribute("width", String(p)), i.removeAttribute("height")), this.onChange();
4986
4988
  };
4987
- window.addEventListener("mousemove", r), window.addEventListener("mouseup", a);
4989
+ window.addEventListener("mousemove", a), window.addEventListener("mouseup", d);
4988
4990
  });
4989
4991
  }
4990
4992
  /* ---------------------------------------------------------- selection bubble toolbar */
@@ -5023,7 +5025,7 @@ const I = class I {
5023
5025
  this.selCtx || (this.selCtx = this.buildSelToolbar()), this.positionSelToolbar(e);
5024
5026
  }
5025
5027
  buildSelToolbar() {
5026
- var n;
5028
+ var r;
5027
5029
  const t = document.createElement("div");
5028
5030
  t.className = "selctx", t.dir = this.dir();
5029
5031
  const e = this.ctxBtn(
@@ -5031,8 +5033,8 @@ const I = class I {
5031
5033
  this.t("forecolor"),
5032
5034
  () => this.colorMenu(e, "fore")
5033
5035
  ), i = this.ctxBtn(c.backcolor, this.t("backcolor"), () => this.colorMenu(i, "back"));
5034
- (n = i.querySelector("svg")) == null || n.insertAdjacentHTML("afterend", '<span class="colorbar" data-cb="back"></span>');
5035
- const s = this.ctxBtn(c.caseic, this.t("changecase"), () => this.caseMenu(s)), l = this.ctxBtn(c.lineheight, this.t("lineheight"), () => this.lineHeightMenu(l)), o = this.ctxBtn(c.wordspacing, this.t("wordspacing"), () => this.wordSpacingMenu(o));
5036
+ (r = i.querySelector("svg")) == null || r.insertAdjacentHTML("afterend", '<span class="colorbar" data-cb="back"></span>');
5037
+ const s = this.ctxBtn(c.caseic, this.t("changecase"), () => this.caseMenu(s)), l = this.ctxBtn(c.lineheight, this.t("lineheight"), () => this.lineHeightMenu(l)), n = this.ctxBtn(c.wordspacing, this.t("wordspacing"), () => this.wordSpacingMenu(n));
5036
5038
  return t.append(
5037
5039
  this.ctxBtn(c.bold, this.t("bold"), () => this.exec("bold"), "bold"),
5038
5040
  this.ctxBtn(c.italic, this.t("italic"), () => this.exec("italic"), "italic"),
@@ -5047,16 +5049,16 @@ const I = class I {
5047
5049
  this.ctxBtn(c.link, this.t("linkttl"), () => this.linkDlg()),
5048
5050
  s,
5049
5051
  l,
5050
- o
5051
- ), t.addEventListener("mousedown", (r) => r.preventDefault()), document.body.appendChild(t), this.syncColorSwatches(t), t;
5052
+ n
5053
+ ), t.addEventListener("mousedown", (o) => o.preventDefault()), document.body.appendChild(t), this.syncColorSwatches(t), t;
5052
5054
  }
5053
5055
  positionSelToolbar(t) {
5054
5056
  if (!this.selCtx) return;
5055
- 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;
5056
- let a = s + (l - s) / 2 - n / 2;
5057
- a = Math.max(8 + scrollX, Math.min(a, scrollX + innerWidth - n - 8));
5058
- let d = i - r - 8;
5059
- d < this.ctxMinTop() && (d = o + 8), this.selCtx.style.left = a + "px", this.selCtx.style.top = d + "px";
5057
+ const e = t.getBoundingClientRect(), i = e.top + scrollY, s = e.left + scrollX, l = e.right + scrollX, n = e.bottom + scrollY, r = this.selCtx.offsetWidth, o = this.selCtx.offsetHeight;
5058
+ let a = s + (l - s) / 2 - r / 2;
5059
+ a = Math.max(8 + scrollX, Math.min(a, scrollX + innerWidth - r - 8));
5060
+ let d = i - o - 8;
5061
+ d < this.ctxMinTop() && (d = n + 8), this.selCtx.style.left = a + "px", this.selCtx.style.top = d + "px";
5060
5062
  }
5061
5063
  repositionSelToolbar() {
5062
5064
  if (!this.selCtx) return;
@@ -5089,7 +5091,7 @@ const I = class I {
5089
5091
  return t > 0 ? t + "px" : "";
5090
5092
  }
5091
5093
  refreshState() {
5092
- var r, a, d;
5094
+ var o, a, d;
5093
5095
  const t = window.getSelection(), e = t ? this.ed.contains(t.anchorNode) : !1, i = this.currentBlock();
5094
5096
  [this.toolbar, this.selCtx].filter(Boolean).forEach((p) => {
5095
5097
  [
@@ -5113,13 +5115,13 @@ const I = class I {
5113
5115
  const u = p.querySelector("[data-id=code]");
5114
5116
  u && u.classList.toggle("on", e && !!this.closestInlineCode());
5115
5117
  });
5116
- 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();
5117
- (a = this.toolbar.querySelector("[data-id=ltr]")) == null || a.classList.toggle("on", e && o === "ltr"), (d = this.toolbar.querySelector("[data-id=rtl]")) == null || d.classList.toggle("on", e && o === "rtl");
5118
- const n = (p, u, g) => {
5118
+ const l = t ? this.closestBlock(t.anchorNode) : null, n = ((o = l == null ? void 0 : l.closest("[dir]")) == null ? void 0 : o.getAttribute("dir")) || this.ed.getAttribute("dir") || this.dir();
5119
+ (a = this.toolbar.querySelector("[data-id=ltr]")) == null || a.classList.toggle("on", e && n === "ltr"), (d = this.toolbar.querySelector("[data-id=rtl]")) == null || d.classList.toggle("on", e && n === "rtl");
5120
+ const r = (p, u, g) => {
5119
5121
  const m = this.toolbar.querySelector(`[data-id=${p}] .lbl`);
5120
5122
  m && (m.textContent = u || g || "", m.classList.toggle("empty", !u));
5121
5123
  };
5122
- n("fontsel", this.currentFont()), n("sizesel", this.currentSize().replace("px", "")), e && n("blocksel", Q.some((p) => p[0] === i) ? this.blockLabel(i) : this.t("para")), this.sbWords.textContent = this.countWords() + " " + this.t("words");
5124
+ r("fontsel", this.currentFont()), r("sizesel", this.currentSize().replace("px", "")), e && r("blocksel", Q.some((p) => p[0] === i) ? this.blockLabel(i) : this.t("para")), this.sbWords.textContent = this.countWords() + " " + this.t("words");
5123
5125
  }
5124
5126
  countWords() {
5125
5127
  const t = (this.ed.textContent || "").trim();
@@ -5139,9 +5141,9 @@ const I = class I {
5139
5141
  return;
5140
5142
  }
5141
5143
  if (!i) {
5142
- const l = e.getData("text/plain"), o = /^\S+$/.test(l.trim()) ? this.videoEmbedUrl(l.trim()) : null;
5143
- if (o) {
5144
- document.execCommand("insertHTML", !1, this.videoEmbedHTML(o)), this.onChange();
5144
+ const l = e.getData("text/plain"), n = /^\S+$/.test(l.trim()) ? this.videoEmbedUrl(l.trim()) : null;
5145
+ if (n) {
5146
+ document.execCommand("insertHTML", !1, this.videoEmbedHTML(n)), this.onChange();
5145
5147
  return;
5146
5148
  }
5147
5149
  }
@@ -5157,19 +5159,19 @@ const I = class I {
5157
5159
  let s = [];
5158
5160
  const l = e.getData("text/rtf");
5159
5161
  if (l) {
5160
- const o = $t(t, l);
5161
- t = o.html, s = o.injected;
5162
+ const n = $t(t, l);
5163
+ t = n.html, s = n.injected;
5162
5164
  }
5163
5165
  if (i && _t(t) === 1) {
5164
- const o = i.getAsFile();
5165
- if (o) {
5166
- const n = t;
5166
+ const n = i.getAsFile();
5167
+ if (n) {
5168
+ const r = t;
5167
5169
  this.saveSel();
5168
- const r = new FileReader();
5169
- r.onload = () => {
5170
- const a = rt(n, [r.result]);
5170
+ const o = new FileReader();
5171
+ o.onload = () => {
5172
+ const a = rt(r, [o.result]);
5171
5173
  this.finishRichPaste(a.html, s.concat(a.injected), !0);
5172
- }, r.onerror = () => this.finishRichPaste(n, s, !0), r.readAsDataURL(o);
5174
+ }, o.onerror = () => this.finishRichPaste(r, s, !0), o.readAsDataURL(n);
5173
5175
  return;
5174
5176
  }
5175
5177
  }
@@ -5183,20 +5185,20 @@ const I = class I {
5183
5185
  this.insertPastedHTML(t, i);
5184
5186
  return;
5185
5187
  }
5186
- const s = this.imageUploadHandler, l = e.filter((o, n) => e.indexOf(o) === n);
5188
+ const s = this.imageUploadHandler, l = e.filter((n, r) => e.indexOf(n) === r);
5187
5189
  i || this.saveSel(), Promise.all(
5188
- l.map((o, n) => {
5189
- const r = zt(o, "pasted-image-" + (n + 1));
5190
- return r ? s(r).catch((a) => {
5190
+ l.map((n, r) => {
5191
+ const o = zt(n, "pasted-image-" + (r + 1));
5192
+ return o ? s(o).catch((a) => {
5191
5193
  var d;
5192
- return (d = this.onImageUploadError) == null || d.call(this, a, r), o;
5193
- }) : Promise.resolve(o);
5194
+ return (d = this.onImageUploadError) == null || d.call(this, a, o), n;
5195
+ }) : Promise.resolve(n);
5194
5196
  })
5195
- ).then((o) => {
5196
- let n = t;
5197
- l.forEach((r, a) => {
5198
- o[a] !== r && (n = n.split(r).join(o[a]));
5199
- }), this.insertPastedHTML(n, !0);
5197
+ ).then((n) => {
5198
+ let r = t;
5199
+ l.forEach((o, a) => {
5200
+ n[a] !== o && (r = r.split(o).join(n[a]));
5201
+ }), this.insertPastedHTML(r, !0);
5200
5202
  });
5201
5203
  }
5202
5204
  /** `deferred` means the insert is happening after an async hop, so the caret the