nuvra 0.1.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.
- package/LICENSE +21 -0
- package/README.md +163 -0
- package/dist/components/document-editor.vue.d.ts +82 -0
- package/dist/components/editor-bubble-menus.vue.d.ts +14 -0
- package/dist/components/editor-canvas.vue.d.ts +30 -0
- package/dist/components/editor-color-picker.vue.d.ts +15 -0
- package/dist/components/editor-find-bar.vue.d.ts +24 -0
- package/dist/components/editor-object-overlay.vue.d.ts +10 -0
- package/dist/components/editor-page-setup.vue.d.ts +12 -0
- package/dist/components/editor-status-bar.vue.d.ts +36 -0
- package/dist/components/editor-table-picker.vue.d.ts +16 -0
- package/dist/components/editor-toolbar.vue.d.ts +38 -0
- package/dist/core/engine/blocks.d.ts +37 -0
- package/dist/core/engine/clipboard.d.ts +23 -0
- package/dist/core/engine/dom.d.ts +64 -0
- package/dist/core/engine/editing.d.ts +44 -0
- package/dist/core/engine/engine.d.ts +319 -0
- package/dist/core/engine/history.d.ts +43 -0
- package/dist/core/engine/input-rules.d.ts +17 -0
- package/dist/core/engine/keymap.d.ts +7 -0
- package/dist/core/engine/lists.d.ts +29 -0
- package/dist/core/engine/marks.d.ts +50 -0
- package/dist/core/engine/schema.d.ts +37 -0
- package/dist/core/engine/search.d.ts +65 -0
- package/dist/core/engine/selection.d.ts +30 -0
- package/dist/core/engine/tables.d.ts +59 -0
- package/dist/core/export.d.ts +21 -0
- package/dist/core/labels.d.ts +150 -0
- package/dist/core/page.d.ts +109 -0
- package/dist/core/pagination.d.ts +23 -0
- package/dist/core/types.d.ts +3 -0
- package/dist/core/ui-state.d.ts +79 -0
- package/dist/editor.vue.d.ts +50 -0
- package/dist/export-cyOnlakM.js +59 -0
- package/dist/export-cyOnlakM.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +4900 -0
- package/dist/index.js.map +1 -0
- package/dist/page-CEEleKNI.js +93 -0
- package/dist/page-CEEleKNI.js.map +1 -0
- package/dist/style.css +2 -0
- package/package.json +72 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,4900 @@
|
|
|
1
|
+
import { a as e, i as t, n, r, t as i } from "./page-CEEleKNI.js";
|
|
2
|
+
import { Fragment as a, Teleport as o, computed as s, createBlock as c, createCommentVNode as l, createElementBlock as u, createElementVNode as d, createTextVNode as f, createVNode as p, defineComponent as m, mergeModels as h, mergeProps as g, nextTick as _, normalizeClass as v, normalizeStyle as y, onBeforeUnmount as ee, onMounted as te, openBlock as b, ref as x, renderList as S, resolveDynamicComponent as C, shallowRef as w, toDisplayString as T, unref as E, useCssVars as D, useModel as ne, vModelText as re, vShow as ie, watch as O, withCtx as k, withDirectives as ae, withModifiers as A } from "vue";
|
|
3
|
+
import { ElButton as oe, ElCheckbox as se, ElDropdown as j, ElDropdownItem as M, ElDropdownMenu as N, ElInput as P, ElInputNumber as F, ElPopover as I, useZIndex as ce } from "element-plus";
|
|
4
|
+
import { BetweenHorizontalEnd as le, BetweenHorizontalStart as ue, BetweenVerticalEnd as de, BetweenVerticalStart as fe, Bold as pe, CalendarDays as me, CaseSensitive as he, ChevronDown as L, ChevronRight as R, ChevronUp as ge, Code as _e, Columns2 as z, Ellipsis as B, ExternalLink as ve, FileCode as ye, FileDown as be, FileSliders as xe, FileText as Se, FileType as Ce, Grid2x2X as we, Grid3x3 as Te, Highlighter as Ee, ImagePlus as De, Italic as Oe, Languages as ke, Link as Ae, List as je, ListIndentDecrease as Me, ListIndentIncrease as Ne, ListOrdered as Pe, ListTodo as Fe, Maximize2 as Ie, Minimize2 as Le, Minus as Re, MoveHorizontal as ze, Omega as Be, PanelTop as Ve, Pencil as He, PilcrowLeft as Ue, PilcrowRight as We, Plus as Ge, Printer as Ke, Quote as qe, RectangleHorizontal as Je, RectangleVertical as Ye, Redo2 as Xe, RemoveFormatting as Ze, Rows2 as Qe, ScrollText as $e, Search as et, SeparatorHorizontal as tt, SquareCode as nt, SquareSplitVertical as rt, Strikethrough as it, Subscript as at, Superscript as ot, TableCellsMerge as st, TableCellsSplit as ct, TextAlignCenter as lt, TextAlignEnd as ut, TextAlignJustify as dt, TextAlignStart as ft, TextCursorInput as pt, Trash2 as mt, Underline as ht, Undo2 as gt, UnfoldVertical as _t, Unlink as vt, Upload as yt, WholeWord as bt, X as xt } from "@lucide/vue";
|
|
5
|
+
//#region src/core/engine/dom.ts
|
|
6
|
+
var St = /* @__PURE__ */ new Set([
|
|
7
|
+
"P",
|
|
8
|
+
"H1",
|
|
9
|
+
"H2",
|
|
10
|
+
"H3",
|
|
11
|
+
"H4",
|
|
12
|
+
"H5",
|
|
13
|
+
"H6",
|
|
14
|
+
"PRE"
|
|
15
|
+
]), Ct = /* @__PURE__ */ new Set(["UL", "OL"]), wt = /* @__PURE__ */ new Set([
|
|
16
|
+
"STRONG",
|
|
17
|
+
"EM",
|
|
18
|
+
"U",
|
|
19
|
+
"S",
|
|
20
|
+
"CODE",
|
|
21
|
+
"SUB",
|
|
22
|
+
"SUP",
|
|
23
|
+
"A",
|
|
24
|
+
"MARK",
|
|
25
|
+
"SPAN"
|
|
26
|
+
]), Tt = "strong, em, u, s, code, sub, sup, a, mark, span", Et = "p, h1, h2, h3, h4, h5, h6, pre", Dt = "data-doc-trailing", Ot = `img, br:not([${Dt}])`, V = (e) => e?.nodeType === Node.ELEMENT_NODE, H = (e) => e?.nodeType === Node.TEXT_NODE, kt = (e) => V(e) && St.has(e.tagName), At = (e) => V(e) && Ct.has(e.tagName), jt = (e) => V(e) && wt.has(e.tagName), Mt = (e) => V(e) && e.matches("hr, img, div[data-type=\"page-break\"]"), Nt = (e) => V(e) && e.tagName === "BR", Pt = (e) => Nt(e) && e.hasAttribute("data-doc-trailing"), Ft = (e, t, n) => {
|
|
27
|
+
let r = e;
|
|
28
|
+
for (; r && r !== t;) {
|
|
29
|
+
if (V(r) && n(r)) return r;
|
|
30
|
+
r = r.parentNode;
|
|
31
|
+
}
|
|
32
|
+
return null;
|
|
33
|
+
}, It = (e, t, n) => Ft(e, t, (e) => typeof n == "string" ? e.tagName === n : n.has(e.tagName)), U = (e, t) => Ft(e, t, (e) => St.has(e.tagName)), W = (e, t = {}, n = []) => {
|
|
34
|
+
let r = document.createElement(e);
|
|
35
|
+
for (let [e, n] of Object.entries(t)) r.setAttribute(e, n);
|
|
36
|
+
return r.append(...n), r;
|
|
37
|
+
}, Lt = () => W("br", { [Dt]: "" }), Rt = (e = []) => {
|
|
38
|
+
let t = W("p", {}, e);
|
|
39
|
+
return G(t), t;
|
|
40
|
+
}, zt = (e) => (e.textContent ?? "") !== "" || e.querySelector(Ot) !== null, Bt = (e) => (e.textContent ?? "") === "" && e.querySelector("img") === null && e.querySelectorAll("br").length <= 1, Vt = (e, t) => {
|
|
41
|
+
let n = t === void 0 ? e.lastChild : t?.previousSibling ?? null;
|
|
42
|
+
for (; n && H(n) && n.data === "";) n = n.previousSibling;
|
|
43
|
+
return n;
|
|
44
|
+
}, G = (e) => {
|
|
45
|
+
if (e.tagName === "PRE") return;
|
|
46
|
+
if (Bt(e)) {
|
|
47
|
+
let t = e.firstChild, n = e.childNodes.length === 1;
|
|
48
|
+
if (n && Nt(t)) {
|
|
49
|
+
t.setAttribute(Dt, "");
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (n && Pt(t)) return;
|
|
53
|
+
for (let t of Array.from(e.querySelectorAll("br"))) t.remove();
|
|
54
|
+
e.append(Lt());
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
let t = Vt(e), n = Nt(t) && t.hasAttribute("data-doc-trailing") ? t : null, r = n ? Vt(e, n) : t, i = r === null || Nt(r);
|
|
58
|
+
i && !n && e.append(Lt()), !i && n && n.remove();
|
|
59
|
+
}, K = (e) => {
|
|
60
|
+
e.replaceWith(...Array.from(e.childNodes));
|
|
61
|
+
}, Ht = (e, t) => {
|
|
62
|
+
let n = document.createElement(t);
|
|
63
|
+
for (let t of Array.from(e.attributes)) n.setAttribute(t.name, t.value);
|
|
64
|
+
return n.append(...Array.from(e.childNodes)), e.replaceWith(n), n;
|
|
65
|
+
}, Ut = (e, t) => e.attributes.length === t.attributes.length && Array.from(e.attributes).every((e) => t.getAttribute(e.name) === e.value), Wt = (e) => {
|
|
66
|
+
let t = Array.from(e.querySelectorAll(Tt));
|
|
67
|
+
for (let e = t.length - 1; e >= 0; --e) {
|
|
68
|
+
let n = t[e];
|
|
69
|
+
n && !zt(n) && n.remove();
|
|
70
|
+
}
|
|
71
|
+
}, Gt = (e) => {
|
|
72
|
+
let t = (e) => {
|
|
73
|
+
let n = e.firstChild;
|
|
74
|
+
for (; n;) {
|
|
75
|
+
let e = n.nextSibling;
|
|
76
|
+
if (jt(n) && jt(e) && n.tagName === e.tagName && Ut(n, e)) {
|
|
77
|
+
n.append(...Array.from(e.childNodes)), e.remove();
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
V(n) && t(n), n = e;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
t(e), e.normalize();
|
|
84
|
+
}, Kt = (e) => Array.from(e.querySelectorAll(Et)), qt = (e, t) => {
|
|
85
|
+
let n = U(t.startContainer, e);
|
|
86
|
+
return t.collapsed || n === U(t.endContainer, e) ? n ? [n] : [] : Kt(e).filter((e) => t.intersectsNode(e));
|
|
87
|
+
}, Jt = (e, t, n, r) => {
|
|
88
|
+
let i = document.createRange();
|
|
89
|
+
return i.selectNodeContents(e), r ? i.setStart(t, n) : i.setEnd(t, n), i;
|
|
90
|
+
}, Yt = (e) => e.toString() === "" && e.cloneContents().querySelector(Ot) === null, Xt = (e, t, n) => Yt(Jt(e, t, n, !1)), Zt = (e, t, n) => Yt(Jt(e, t, n, !0)), Qt = (e) => e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), $t = "data-doc-gap", en = "doc-cell-selected", tn = 48, nn = 10, rn = 96, an = 2.54, on = 25.4, sn = .75, cn = 2, ln = 32, un = 127, dn = /* @__PURE__ */ new Set([
|
|
91
|
+
"P",
|
|
92
|
+
"H1",
|
|
93
|
+
"H2",
|
|
94
|
+
"H3",
|
|
95
|
+
"H4",
|
|
96
|
+
"H5",
|
|
97
|
+
"H6",
|
|
98
|
+
"PRE",
|
|
99
|
+
"BLOCKQUOTE",
|
|
100
|
+
"UL",
|
|
101
|
+
"OL",
|
|
102
|
+
"TABLE",
|
|
103
|
+
"HR",
|
|
104
|
+
"IMG",
|
|
105
|
+
"DIV"
|
|
106
|
+
]), fn = /* @__PURE__ */ new Set([
|
|
107
|
+
"SCRIPT",
|
|
108
|
+
"STYLE",
|
|
109
|
+
"TITLE",
|
|
110
|
+
"META",
|
|
111
|
+
"LINK",
|
|
112
|
+
"BASE",
|
|
113
|
+
"HEAD",
|
|
114
|
+
"IFRAME",
|
|
115
|
+
"FRAME",
|
|
116
|
+
"OBJECT",
|
|
117
|
+
"EMBED",
|
|
118
|
+
"NOSCRIPT",
|
|
119
|
+
"TEMPLATE",
|
|
120
|
+
"SVG",
|
|
121
|
+
"MATH",
|
|
122
|
+
"CANVAS",
|
|
123
|
+
"VIDEO",
|
|
124
|
+
"AUDIO",
|
|
125
|
+
"SOURCE",
|
|
126
|
+
"SELECT",
|
|
127
|
+
"TEXTAREA",
|
|
128
|
+
"BUTTON",
|
|
129
|
+
"INPUT",
|
|
130
|
+
"FORM"
|
|
131
|
+
]), pn = {
|
|
132
|
+
DT: "p",
|
|
133
|
+
DD: "p",
|
|
134
|
+
ADDRESS: "p",
|
|
135
|
+
FIGCAPTION: "p"
|
|
136
|
+
}, mn = /* @__PURE__ */ new Set([
|
|
137
|
+
"LI",
|
|
138
|
+
"TR",
|
|
139
|
+
"TD",
|
|
140
|
+
"TH",
|
|
141
|
+
"TBODY",
|
|
142
|
+
"THEAD",
|
|
143
|
+
"TFOOT",
|
|
144
|
+
"COLGROUP",
|
|
145
|
+
"COL"
|
|
146
|
+
]), hn = /^[a-z][a-z0-9+.-]*:/i, gn = /^(transparent|initial|inherit|white|#fff(fff)?|rgba?\(255, 255, 255(, 1)?\))$/i, _n = (e) => V(e) && dn.has(e.tagName), vn = (e) => Number.isFinite(e) ? Math.min(nn, Math.max(0, Math.round(e))) : 0, yn = (e, t) => {
|
|
147
|
+
let n = vn(t);
|
|
148
|
+
n ? (e.dataset.indent = String(n), e.style.marginLeft = `${n * tn}px`) : (delete e.dataset.indent, e.style.removeProperty("margin-left")), e.getAttribute("style") || e.removeAttribute("style");
|
|
149
|
+
}, bn = (e, t = !1) => {
|
|
150
|
+
let n = e?.trim();
|
|
151
|
+
if (!n) return null;
|
|
152
|
+
let r = Array.from(n).filter((e) => {
|
|
153
|
+
let t = e.charCodeAt(0);
|
|
154
|
+
return t > ln && t !== un;
|
|
155
|
+
}).join("").toLowerCase();
|
|
156
|
+
return (t ? /^(https?:|data:image\/|blob:)/ : /^(https?:|mailto:|tel:)/).test(r) || !hn.test(r) ? n : null;
|
|
157
|
+
}, xn = (e) => {
|
|
158
|
+
let t = Number.parseFloat(e);
|
|
159
|
+
return Number.isFinite(t) ? e.endsWith("pt") ? t / sn : e.endsWith("cm") ? t * rn / an : e.endsWith("mm") ? t * rn / on : e.endsWith("in") ? t * rn : /^[\d.]+(px)?$/.test(e.trim()) ? t : 0 : 0;
|
|
160
|
+
}, Sn = (e) => {
|
|
161
|
+
let t = Number.parseFloat(e);
|
|
162
|
+
if (!Number.isFinite(t) || t <= 0) return null;
|
|
163
|
+
let n = e.endsWith("pt") ? t : e.endsWith("px") ? t * sn : null;
|
|
164
|
+
return n === null ? null : `${Math.round(n * cn) / cn}pt`;
|
|
165
|
+
}, q = (e, t, n = {}) => t.length ? [W(e, n, t)] : [], Cn = (e, t) => {
|
|
166
|
+
let n = e.style.textAlign || e.getAttribute("align") || "";
|
|
167
|
+
[
|
|
168
|
+
"center",
|
|
169
|
+
"right",
|
|
170
|
+
"justify"
|
|
171
|
+
].includes(n) && (t.style.textAlign = n);
|
|
172
|
+
let r = e.style.lineHeight;
|
|
173
|
+
r && r !== "normal" && !r.endsWith("%") && (t.style.lineHeight = r);
|
|
174
|
+
let i = e.dataset.indent ? Number.parseInt(e.dataset.indent, 10) : xn(e.style.marginLeft) / tn;
|
|
175
|
+
vn(i) && yn(t, i);
|
|
176
|
+
let a = e.getAttribute("dir");
|
|
177
|
+
(a === "ltr" || a === "rtl") && t.setAttribute("dir", a);
|
|
178
|
+
}, wn = (e, t) => {
|
|
179
|
+
let n = t;
|
|
180
|
+
if (!n.length) return n;
|
|
181
|
+
let { style: r } = e, i = r.fontWeight;
|
|
182
|
+
(i === "bold" || Number(i) >= 600) && (n = q("strong", n)), r.fontStyle === "italic" && (n = q("em", n));
|
|
183
|
+
let a = `${r.textDecorationLine} ${r.textDecoration}`;
|
|
184
|
+
a.includes("underline") && (n = q("u", n)), a.includes("line-through") && (n = q("s", n)), r.verticalAlign === "super" && (n = q("sup", n)), r.verticalAlign === "sub" && (n = q("sub", n));
|
|
185
|
+
let o = [], s = r.color || e.getAttribute("color");
|
|
186
|
+
s && !/^(inherit|initial|windowtext)$/i.test(s) && o.push(`color: ${s}`);
|
|
187
|
+
let c = r.fontFamily || e.getAttribute("face");
|
|
188
|
+
c && !/^(inherit|initial)$/i.test(c) && o.push(`font-family: ${c}`);
|
|
189
|
+
let l = Sn(r.fontSize);
|
|
190
|
+
l && o.push(`font-size: ${l}`), o.length && (n = q("span", n, { style: o.join("; ") }));
|
|
191
|
+
let u = r.backgroundColor;
|
|
192
|
+
return u && !gn.test(u) && (n = q("mark", n, {
|
|
193
|
+
"data-color": u,
|
|
194
|
+
style: `background-color: ${u}; color: inherit`
|
|
195
|
+
})), n;
|
|
196
|
+
}, Tn = (e, t = !1) => Array.from(e.childNodes).flatMap((e) => kn(e, t)), En = (e) => {
|
|
197
|
+
let t = bn(e.getAttribute("src"), !0);
|
|
198
|
+
if (!t) return [];
|
|
199
|
+
let n = W("img", { src: t });
|
|
200
|
+
for (let t of ["alt", "title"]) {
|
|
201
|
+
let r = e.getAttribute(t);
|
|
202
|
+
r && n.setAttribute(t, r);
|
|
203
|
+
}
|
|
204
|
+
for (let t of ["width", "height"]) {
|
|
205
|
+
let r = Number.parseInt(e.getAttribute(t) ?? e.style[t] ?? "", 10);
|
|
206
|
+
r > 0 && n.setAttribute(t, String(r));
|
|
207
|
+
}
|
|
208
|
+
let r = e.getAttribute("data-align");
|
|
209
|
+
return n.setAttribute("data-align", r === "left" || r === "right" ? r : "center"), [n];
|
|
210
|
+
}, Dn = (e) => {
|
|
211
|
+
let t = W("table"), n = Array.from(e.querySelectorAll(":scope > colgroup > col, :scope > col")).map((e) => xn(e.style.width || e.getAttribute("width") || ""));
|
|
212
|
+
if (n.length && n.every((e) => e > 0)) {
|
|
213
|
+
let e = n.map((e) => W("col", { style: `width: ${Math.round(e)}px` }));
|
|
214
|
+
t.append(W("colgroup", {}, e)), t.style.width = `${Math.round(n.reduce((e, t) => e + t, 0))}px`;
|
|
215
|
+
}
|
|
216
|
+
let r = W("tbody");
|
|
217
|
+
for (let t of Array.from(e.rows)) {
|
|
218
|
+
let e = W("tr");
|
|
219
|
+
for (let n of Array.from(t.cells)) {
|
|
220
|
+
let t = W(n.tagName === "TH" ? "th" : "td", {}, Tn(n));
|
|
221
|
+
n.colSpan > 1 && t.setAttribute("colspan", String(n.colSpan)), n.rowSpan > 1 && t.setAttribute("rowspan", String(n.rowSpan)), e.append(t);
|
|
222
|
+
}
|
|
223
|
+
r.append(e);
|
|
224
|
+
}
|
|
225
|
+
return t.append(r), t;
|
|
226
|
+
}, On = (e) => {
|
|
227
|
+
let t = e.querySelector(":scope > div"), n = t ? Tn(t) : Array.from(e.childNodes).filter((e) => !(V(e) && e.tagName === "LABEL")).flatMap((e) => kn(e, !1));
|
|
228
|
+
return W("li", {
|
|
229
|
+
"data-type": "taskItem",
|
|
230
|
+
"data-checked": String(e.getAttribute("data-checked") === "true")
|
|
231
|
+
}, n);
|
|
232
|
+
}, kn = (e, t) => {
|
|
233
|
+
if (H(e)) {
|
|
234
|
+
let n = t ? e.data : e.data.replace(/[\t\n\r ]+/g, " ");
|
|
235
|
+
return n ? [document.createTextNode(n)] : [];
|
|
236
|
+
}
|
|
237
|
+
if (!V(e)) return [];
|
|
238
|
+
let n = e.tagName.toUpperCase();
|
|
239
|
+
if (fn.has(n)) return [];
|
|
240
|
+
let r = () => Tn(e);
|
|
241
|
+
switch (n) {
|
|
242
|
+
case "P":
|
|
243
|
+
case "H1":
|
|
244
|
+
case "H2":
|
|
245
|
+
case "H3":
|
|
246
|
+
case "H4":
|
|
247
|
+
case "H5":
|
|
248
|
+
case "H6":
|
|
249
|
+
case "DT":
|
|
250
|
+
case "DD":
|
|
251
|
+
case "ADDRESS":
|
|
252
|
+
case "FIGCAPTION": {
|
|
253
|
+
let t = W(pn[n] ?? n.toLowerCase(), {}, r());
|
|
254
|
+
return Cn(e, t), [t];
|
|
255
|
+
}
|
|
256
|
+
case "DIV": {
|
|
257
|
+
if (e.getAttribute("data-type") === "page-break") return [W("div", {
|
|
258
|
+
"data-type": "page-break",
|
|
259
|
+
class: "doc-page-break"
|
|
260
|
+
})];
|
|
261
|
+
let t = r();
|
|
262
|
+
if (t.some(_n)) return t;
|
|
263
|
+
let n = W("p", {}, t);
|
|
264
|
+
return Cn(e, n), t.length ? [n] : [];
|
|
265
|
+
}
|
|
266
|
+
case "BLOCKQUOTE": return [W("blockquote", {}, r())];
|
|
267
|
+
case "PRE": return [W("pre", {}, [W("code", {}, [e.textContent ?? ""])])];
|
|
268
|
+
case "UL":
|
|
269
|
+
case "OL": {
|
|
270
|
+
let t = e.getAttribute("data-type") === "taskList", i = W(n === "OL" ? "ol" : "ul", t ? { "data-type": "taskList" } : {}, r()), a = Number.parseInt(e.getAttribute("start") ?? "", 10);
|
|
271
|
+
return n === "OL" && a > 1 && i.setAttribute("start", String(a)), [i];
|
|
272
|
+
}
|
|
273
|
+
case "LI": return [e.getAttribute("data-type") === "taskItem" ? On(e) : W("li", {}, r())];
|
|
274
|
+
case "TABLE": return [Dn(e)];
|
|
275
|
+
case "HR": return [W("hr")];
|
|
276
|
+
case "IMG": return En(e);
|
|
277
|
+
case "BR": return [W("br")];
|
|
278
|
+
case "A": {
|
|
279
|
+
let t = bn(e.getAttribute("href")), n = wn(e, r());
|
|
280
|
+
if (!t) return n;
|
|
281
|
+
let i = {
|
|
282
|
+
href: t,
|
|
283
|
+
rel: "noopener noreferrer nofollow"
|
|
284
|
+
};
|
|
285
|
+
return e.getAttribute("target") === "_blank" && (i.target = "_blank"), q("a", n, i);
|
|
286
|
+
}
|
|
287
|
+
case "STRONG":
|
|
288
|
+
case "B": return /^(normal|400)$/.test(e.style.fontWeight) ? wn(e, r()) : q("strong", wn(e, r()));
|
|
289
|
+
case "EM":
|
|
290
|
+
case "I":
|
|
291
|
+
case "CITE":
|
|
292
|
+
case "DFN":
|
|
293
|
+
case "VAR": return q("em", wn(e, r()));
|
|
294
|
+
case "U":
|
|
295
|
+
case "INS": return q("u", wn(e, r()));
|
|
296
|
+
case "S":
|
|
297
|
+
case "STRIKE":
|
|
298
|
+
case "DEL": return q("s", wn(e, r()));
|
|
299
|
+
case "CODE":
|
|
300
|
+
case "KBD":
|
|
301
|
+
case "SAMP":
|
|
302
|
+
case "TT": return q("code", [document.createTextNode(e.textContent ?? "")]);
|
|
303
|
+
case "SUB":
|
|
304
|
+
case "SUP": return q(n.toLowerCase(), wn(e, r()));
|
|
305
|
+
case "MARK": {
|
|
306
|
+
let t = e.getAttribute("data-color") || e.style.backgroundColor, n = t ? {
|
|
307
|
+
"data-color": t,
|
|
308
|
+
style: `background-color: ${t}; color: inherit`
|
|
309
|
+
} : {};
|
|
310
|
+
return q("mark", r(), n);
|
|
311
|
+
}
|
|
312
|
+
default: return wn(e, r());
|
|
313
|
+
}
|
|
314
|
+
}, An = (e) => e.getAttribute("data-type") === "taskItem" ? e.querySelector(":scope > div") ?? e : e, jn = (e) => {
|
|
315
|
+
let t = e.getAttribute("data-checked") === "true";
|
|
316
|
+
e.setAttribute("data-type", "taskItem"), e.setAttribute("data-checked", String(t));
|
|
317
|
+
let n = e.querySelector(":scope > label");
|
|
318
|
+
n || (n = W("label", {}, [W("input", { type: "checkbox" }), W("span")]), e.prepend(n)), n.setAttribute("contenteditable", "false");
|
|
319
|
+
let r = n.querySelector("input") ?? n.appendChild(W("input", { type: "checkbox" }));
|
|
320
|
+
r.checked = t, r.toggleAttribute("checked", t);
|
|
321
|
+
let i = e.querySelector(":scope > div");
|
|
322
|
+
i || (i = W("div"), e.append(i));
|
|
323
|
+
for (let t of Array.from(e.childNodes)) t !== n && t !== i && i.append(t);
|
|
324
|
+
return i;
|
|
325
|
+
}, Mn = (e) => {
|
|
326
|
+
e.removeAttribute("data-type"), e.removeAttribute("data-checked"), e.querySelector(":scope > label")?.remove();
|
|
327
|
+
let t = e.querySelector(":scope > div");
|
|
328
|
+
t && K(t);
|
|
329
|
+
}, Nn = (e) => {
|
|
330
|
+
let t = e.getAttribute("data-type") === "taskList";
|
|
331
|
+
for (let t of Array.from(e.childNodes)) if (!(V(t) && t.tagName === "LI")) {
|
|
332
|
+
if (H(t) && t.data.trim() === "") t.remove();
|
|
333
|
+
else if (At(t) && V(t.previousSibling) && t.previousSibling.tagName === "LI") An(t.previousSibling).append(t);
|
|
334
|
+
else {
|
|
335
|
+
let e = W("li");
|
|
336
|
+
t.replaceWith(e), e.append(t);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
for (let n of Array.from(e.children)) t ? jn(n) : Mn(n), Bn(An(n));
|
|
340
|
+
e.children.length || e.remove();
|
|
341
|
+
}, Pn = (e) => {
|
|
342
|
+
let t = Array.from(e.querySelectorAll(":scope > thead > tr, :scope > tbody > tr, :scope > tfoot > tr, :scope > tr")), n = e.querySelector(":scope > colgroup"), r = W("tbody", {}, t);
|
|
343
|
+
e.replaceChildren(...n ? [n] : [], r);
|
|
344
|
+
for (let e of t) {
|
|
345
|
+
for (let t of Array.from(e.childNodes)) (!V(t) || t.tagName !== "TD" && t.tagName !== "TH") && t.remove();
|
|
346
|
+
e.children.length || e.remove();
|
|
347
|
+
for (let t of Array.from(e.children)) Bn(t);
|
|
348
|
+
}
|
|
349
|
+
r.children.length || e.remove();
|
|
350
|
+
}, Fn = (e) => {
|
|
351
|
+
let t = e.firstElementChild, n = e.childNodes.length === 1 && t?.tagName === "CODE" && Array.from(t.childNodes).every((e) => H(e) || Pt(e)), r = e.textContent ?? "", i = n && t ? t : W("code", {}, [r]);
|
|
352
|
+
n || e.replaceChildren(i);
|
|
353
|
+
let a = Array.from(i.childNodes).find(Pt), o = r === "" || r.endsWith("\n");
|
|
354
|
+
o && !a && i.append(Lt()), !o && a && a.remove();
|
|
355
|
+
}, In = (e, t) => {
|
|
356
|
+
let n = document.createRange();
|
|
357
|
+
n.setStartBefore(t), n.setEnd(e, e.childNodes.length);
|
|
358
|
+
let r = n.extractContents();
|
|
359
|
+
r.querySelector("img")?.remove();
|
|
360
|
+
let i = e.cloneNode(!1);
|
|
361
|
+
i.append(r), e.after(t, i);
|
|
362
|
+
for (let t of [e, i]) zt(t) || t.remove();
|
|
363
|
+
return i;
|
|
364
|
+
}, Ln = (e) => {
|
|
365
|
+
for (let t of Array.from(e.children)) _n(t) && t.tagName !== "IMG" && (/^(P|H[1-6])$/.test(t.tagName) ? K(t) : e.after(t));
|
|
366
|
+
let t = e.querySelector("img");
|
|
367
|
+
if (t) {
|
|
368
|
+
let n = In(e, t);
|
|
369
|
+
if (n.isConnected && Ln(n), !e.isConnected) return;
|
|
370
|
+
}
|
|
371
|
+
Wt(e), Gt(e), G(e);
|
|
372
|
+
}, Rn = (e) => {
|
|
373
|
+
switch (e.tagName) {
|
|
374
|
+
case "PRE":
|
|
375
|
+
Fn(e);
|
|
376
|
+
break;
|
|
377
|
+
case "BLOCKQUOTE":
|
|
378
|
+
Bn(e);
|
|
379
|
+
break;
|
|
380
|
+
case "UL":
|
|
381
|
+
case "OL":
|
|
382
|
+
Nn(e);
|
|
383
|
+
break;
|
|
384
|
+
case "TABLE":
|
|
385
|
+
Pn(e);
|
|
386
|
+
break;
|
|
387
|
+
case "IMG":
|
|
388
|
+
case "HR": break;
|
|
389
|
+
case "DIV":
|
|
390
|
+
e.replaceChildren(), e.className = "doc-page-break";
|
|
391
|
+
break;
|
|
392
|
+
default: Ln(e);
|
|
393
|
+
}
|
|
394
|
+
}, zn = (e) => V(e) && (mn.has(e.tagName) || e.tagName === "DIV" && e.getAttribute("data-type") !== "page-break"), Bn = (e, t = !1) => {
|
|
395
|
+
let n = !0;
|
|
396
|
+
for (; n;) {
|
|
397
|
+
n = !1;
|
|
398
|
+
for (let t of Array.from(e.childNodes)) zn(t) && (K(t), n = !0);
|
|
399
|
+
}
|
|
400
|
+
let r = [], i = (t) => {
|
|
401
|
+
if (r.length) {
|
|
402
|
+
if (r.some((e) => H(e) ? e.data.trim() !== "" : V(e) && (Nt(e) || zt(e)))) e.insertBefore(Rt(r), t);
|
|
403
|
+
else for (let e of r) e.parentNode?.removeChild(e);
|
|
404
|
+
r = [];
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
for (let t of Array.from(e.childNodes)) _n(t) ? (i(t), Rn(t)) : r.push(t);
|
|
408
|
+
i(null);
|
|
409
|
+
for (let t of Array.from(e.childNodes)) V(t) && t.tagName === "P" && t.querySelector("img, p, ul, ol, table") && Ln(t);
|
|
410
|
+
e.firstChild || e.appendChild(Rt()), t && !(V(e.lastChild) && e.lastChild.tagName === "P") && e.appendChild(Rt());
|
|
411
|
+
}, Vn = (e) => {
|
|
412
|
+
let t = new DOMParser().parseFromString(e, "text/html"), n = document.createDocumentFragment();
|
|
413
|
+
return n.append(...Tn(t.body)), Bn(n), n;
|
|
414
|
+
}, Hn = (e, t) => {
|
|
415
|
+
for (let t of Array.from(e.querySelectorAll(`[${$t}]`))) t.style.removeProperty("margin-top"), t.removeAttribute($t), t.getAttribute("style") || t.removeAttribute("style");
|
|
416
|
+
for (let t of Array.from(e.querySelectorAll(`.${en}`))) t.classList.remove(en), t.classList.length || t.removeAttribute("class");
|
|
417
|
+
if (t) {
|
|
418
|
+
for (let t of Array.from(e.querySelectorAll(`br[${Dt}]`))) t.remove();
|
|
419
|
+
for (let t of Array.from(e.querySelectorAll("label[contenteditable]"))) t.removeAttribute("contenteditable");
|
|
420
|
+
}
|
|
421
|
+
}, Un = (e) => {
|
|
422
|
+
let t = e.cloneNode(!0);
|
|
423
|
+
return Hn(t, !0), t.innerHTML;
|
|
424
|
+
}, Wn = (e) => {
|
|
425
|
+
let t = e.firstElementChild;
|
|
426
|
+
return e.childElementCount === 1 && t?.tagName === "P" && !t.hasAttribute("style") && (t.textContent ?? "") === "" && t.querySelector("img, br:not([data-doc-trailing])") === null;
|
|
427
|
+
}, Gn = /* @__PURE__ */ new Set([
|
|
428
|
+
"BLOCKQUOTE",
|
|
429
|
+
"TD",
|
|
430
|
+
"TH",
|
|
431
|
+
"LI"
|
|
432
|
+
]), Kn = (e, t) => Ft(e.parentNode, t, (e) => Gn.has(e.tagName) || e.tagName === "DIV" && e.parentElement?.getAttribute("data-type") === "taskItem") ?? t, qn = (e, t) => {
|
|
433
|
+
let n = t;
|
|
434
|
+
for (; n.parentNode && n.parentNode !== e;) n = n.parentNode;
|
|
435
|
+
return n;
|
|
436
|
+
}, Jn = (e) => {
|
|
437
|
+
e.getAttribute("style") || e.removeAttribute("style");
|
|
438
|
+
}, Yn = (e, t) => {
|
|
439
|
+
let n = (e.textContent ?? "").replace(/\n$/, "").split("\n").map((e) => {
|
|
440
|
+
let n = document.createElement(t.toLowerCase());
|
|
441
|
+
return e && n.append(e), G(n), n;
|
|
442
|
+
});
|
|
443
|
+
e.replaceWith(...n);
|
|
444
|
+
}, Xn = (e, t, n) => {
|
|
445
|
+
for (let r of qt(e, t)) r.tagName !== n && (r.tagName === "PRE" ? Yn(r, n) : G(Ht(r, n.toLowerCase())));
|
|
446
|
+
}, Zn = (e, t) => {
|
|
447
|
+
let n = qt(e, t);
|
|
448
|
+
if (n.length && n.every((e) => e.tagName === "PRE")) {
|
|
449
|
+
Xn(e, t, "P");
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
for (let e of n) {
|
|
453
|
+
if (e.tagName === "PRE") continue;
|
|
454
|
+
let t = e.textContent ?? "", n = W("code", {}, t ? [t] : [Lt()]);
|
|
455
|
+
e.replaceWith(W("pre", {}, [n]));
|
|
456
|
+
}
|
|
457
|
+
}, Qn = (e, t) => {
|
|
458
|
+
let n = qt(e, t), r = n[0], i = n.at(-1);
|
|
459
|
+
if (!r || !i) return;
|
|
460
|
+
let a = n.map((t) => It(t, e, "BLOCKQUOTE"));
|
|
461
|
+
if (a.every(Boolean)) {
|
|
462
|
+
for (let e of new Set(a)) e && K(e);
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
let o = Kn(r, e);
|
|
466
|
+
for (; o !== e && !o.contains(i);) o = Kn(o, e);
|
|
467
|
+
let s = qn(o, r), c = qn(o, i), l = W("blockquote");
|
|
468
|
+
s.parentNode?.insertBefore(l, s);
|
|
469
|
+
let u = s;
|
|
470
|
+
for (; u;) {
|
|
471
|
+
let e = u === c ? null : u.nextSibling;
|
|
472
|
+
l.append(u), u = e;
|
|
473
|
+
}
|
|
474
|
+
}, $n = (e, t, n) => {
|
|
475
|
+
for (let r of qt(e, t)) r.tagName !== "PRE" && (n === "left" ? r.style.removeProperty("text-align") : r.style.textAlign = n, Jn(r));
|
|
476
|
+
}, er = (e, t, n) => {
|
|
477
|
+
for (let r of qt(e, t)) r.tagName !== "PRE" && (n ? r.style.lineHeight = n : r.style.removeProperty("line-height"), Jn(r));
|
|
478
|
+
}, tr = (e, t, n) => {
|
|
479
|
+
for (let r of qt(e, t)) n === "auto" ? r.removeAttribute("dir") : r.setAttribute("dir", n);
|
|
480
|
+
}, nr = (e) => Number.parseInt(e.dataset.indent ?? "0", 10) || 0, rr = (e, t, n) => {
|
|
481
|
+
let r = !1;
|
|
482
|
+
for (let i of qt(e, t)) {
|
|
483
|
+
if (i.tagName === "PRE" || It(i, e, "LI")) continue;
|
|
484
|
+
let t = nr(i);
|
|
485
|
+
yn(i, t + n), r ||= nr(i) !== t;
|
|
486
|
+
}
|
|
487
|
+
return r;
|
|
488
|
+
}, ir = (e, t, n) => {
|
|
489
|
+
let r = document.createRange();
|
|
490
|
+
r.setStart(t, n), r.setEnd(e, e.childNodes.length);
|
|
491
|
+
let i = e.cloneNode(!1);
|
|
492
|
+
i.append(r.extractContents()), e.after(i);
|
|
493
|
+
for (let t of [e, i]) Wt(t), G(t);
|
|
494
|
+
return i;
|
|
495
|
+
}, ar = (e, t, n) => {
|
|
496
|
+
let r = U(t.startContainer, e);
|
|
497
|
+
if (!r) {
|
|
498
|
+
let t = Rt();
|
|
499
|
+
return e.append(n, t), t;
|
|
500
|
+
}
|
|
501
|
+
if (Bt(r) || Xt(r, t.startContainer, t.startOffset)) return r.before(n), r;
|
|
502
|
+
if (Zt(r, t.endContainer, t.endOffset)) {
|
|
503
|
+
r.after(n);
|
|
504
|
+
let e = n.nextElementSibling;
|
|
505
|
+
if (kt(e)) return e;
|
|
506
|
+
let t = Rt();
|
|
507
|
+
return n.after(t), t;
|
|
508
|
+
}
|
|
509
|
+
let i = ir(r, t.startContainer, t.startOffset);
|
|
510
|
+
return r.after(n), i;
|
|
511
|
+
}, J = (e) => e.tagName === "OL" ? "orderedList" : e.getAttribute("data-type") === "taskList" ? "taskList" : "bulletList", Y = (e, t) => It(e, t, "LI"), or = (e, t) => {
|
|
512
|
+
let n = Y(t, e)?.parentElement;
|
|
513
|
+
return n && At(n) ? J(n) : null;
|
|
514
|
+
}, sr = (e) => e === "orderedList" ? W("ol") : W("ul", e === "taskList" ? { "data-type": "taskList" } : {}), cr = (e, t) => {
|
|
515
|
+
let n = W("li");
|
|
516
|
+
return e === "taskList" ? (n.setAttribute("data-checked", "false"), jn(n).append(...t)) : n.append(...t), n;
|
|
517
|
+
}, lr = (e, t) => {
|
|
518
|
+
let n = e.getAttribute("data-type") === "taskItem";
|
|
519
|
+
if (t === "taskList" && !n && jn(e), t === "taskList" || !n) return;
|
|
520
|
+
e.removeAttribute("data-type"), e.removeAttribute("data-checked"), e.querySelector(":scope > label")?.remove();
|
|
521
|
+
let r = e.querySelector(":scope > div");
|
|
522
|
+
r && K(r);
|
|
523
|
+
}, ur = (e, t) => {
|
|
524
|
+
if (J(e) === t) return e;
|
|
525
|
+
let n = t === "orderedList" ? "OL" : "UL", r = e.tagName === n ? e : Ht(e, n.toLowerCase());
|
|
526
|
+
r.removeAttribute("start"), t === "taskList" ? r.setAttribute("data-type", "taskList") : r.removeAttribute("data-type");
|
|
527
|
+
for (let e of Array.from(r.children)) lr(e, t);
|
|
528
|
+
return r;
|
|
529
|
+
}, dr = (e) => {
|
|
530
|
+
let t = e.previousElementSibling, n = e;
|
|
531
|
+
t && At(t) && J(t) === J(e) && (t.append(...Array.from(e.children)), e.remove(), n = t);
|
|
532
|
+
let r = n.nextElementSibling;
|
|
533
|
+
r && At(r) && J(r) === J(n) && (n.append(...Array.from(r.children)), r.remove());
|
|
534
|
+
}, fr = (e, t) => {
|
|
535
|
+
let n = t.parentElement;
|
|
536
|
+
if (!n || !At(n)) return;
|
|
537
|
+
let r = J(n), i = [];
|
|
538
|
+
for (let e = t.nextElementSibling; e; e = e.nextElementSibling) i.push(e);
|
|
539
|
+
let a = Kn(n, e), o = a.tagName === "LI" ? a : a.tagName === "DIV" ? a.parentElement : null;
|
|
540
|
+
if (o?.tagName === "LI") {
|
|
541
|
+
if (i.length) {
|
|
542
|
+
let e = sr(r);
|
|
543
|
+
e.append(...i), An(t).append(e);
|
|
544
|
+
}
|
|
545
|
+
o.after(t);
|
|
546
|
+
let e = o.parentElement;
|
|
547
|
+
e && lr(t, J(e));
|
|
548
|
+
} else {
|
|
549
|
+
if (i.length) {
|
|
550
|
+
let e = n.cloneNode(!1);
|
|
551
|
+
e.removeAttribute("start"), e.append(...i), n.after(e);
|
|
552
|
+
}
|
|
553
|
+
n.after(...Array.from(An(t).childNodes)), t.remove();
|
|
554
|
+
}
|
|
555
|
+
n.children.length || n.remove();
|
|
556
|
+
}, pr = (e) => {
|
|
557
|
+
let t = e.previousElementSibling, n = e.parentElement;
|
|
558
|
+
if (!t || !n) return !1;
|
|
559
|
+
let r = An(t), i = r.lastElementChild;
|
|
560
|
+
return i && At(i) && J(i) === J(n) || (i = sr(J(n)), r.append(i)), i.append(e), !0;
|
|
561
|
+
}, mr = (e, t) => {
|
|
562
|
+
let n = qt(e, t).map((t) => Y(t, e));
|
|
563
|
+
return [...new Set(n.filter((e) => e !== null))];
|
|
564
|
+
}, hr = (e, t, n) => {
|
|
565
|
+
let r = mr(e, t);
|
|
566
|
+
if (!r.length) return !1;
|
|
567
|
+
if (n > 0) return r.map((e) => pr(e)).some(Boolean);
|
|
568
|
+
for (let t of r.reverse()) fr(e, t);
|
|
569
|
+
return !0;
|
|
570
|
+
}, gr = (e, t) => {
|
|
571
|
+
for (let n = Y(t, e); n; n = Y(t, e)) fr(e, n);
|
|
572
|
+
}, _r = (e, t, n) => {
|
|
573
|
+
let r = qt(e, t), i = r[0], a = r.at(-1);
|
|
574
|
+
if (!i || !a) return;
|
|
575
|
+
let o = r.map((t) => Y(t, e));
|
|
576
|
+
if (o.every(Boolean)) {
|
|
577
|
+
let t = [...new Set(o.map((e) => e?.parentElement))];
|
|
578
|
+
if (t.every((e) => J(e) === n)) for (let t of [...new Set(o)].reverse()) t && fr(e, t);
|
|
579
|
+
else for (let e of t) dr(ur(e, n));
|
|
580
|
+
return;
|
|
581
|
+
}
|
|
582
|
+
let s = Kn(i, e);
|
|
583
|
+
for (; s !== e && !s.contains(a);) s = Kn(s, e);
|
|
584
|
+
let c = qn(s, i), l = qn(s, a), u = [];
|
|
585
|
+
for (let e = c; e; e = e === l ? null : e.nextSibling) u.push(e);
|
|
586
|
+
let d = sr(n);
|
|
587
|
+
c.parentNode?.insertBefore(d, c);
|
|
588
|
+
for (let e of u) if (At(e)) {
|
|
589
|
+
let t = ur(e, n);
|
|
590
|
+
d.append(...Array.from(t.children)), t.remove();
|
|
591
|
+
} else d.append(cr(n, [e]));
|
|
592
|
+
dr(d);
|
|
593
|
+
}, vr = (e, t) => {
|
|
594
|
+
let n = e.parentElement, r = An(e), i = [];
|
|
595
|
+
for (let e = qn(r, t); e; e = e.nextSibling) i.push(e);
|
|
596
|
+
let a = cr(J(n), i);
|
|
597
|
+
return e.after(a), a;
|
|
598
|
+
}, yr = (e) => {
|
|
599
|
+
let t = e.getAttribute("data-checked") !== "true";
|
|
600
|
+
e.setAttribute("data-checked", String(t));
|
|
601
|
+
let n = e.querySelector(":scope > label input");
|
|
602
|
+
n && (n.checked = t, n.toggleAttribute("checked", t));
|
|
603
|
+
}, br = "#fef08a", xr = {
|
|
604
|
+
bold: "STRONG",
|
|
605
|
+
italic: "EM",
|
|
606
|
+
underline: "U",
|
|
607
|
+
strike: "S",
|
|
608
|
+
code: "CODE",
|
|
609
|
+
subscript: "SUB",
|
|
610
|
+
superscript: "SUP"
|
|
611
|
+
}, Sr = {
|
|
612
|
+
color: "color",
|
|
613
|
+
fontFamily: "font-family",
|
|
614
|
+
fontSize: "font-size"
|
|
615
|
+
}, Cr = /* @__PURE__ */ new Set([
|
|
616
|
+
"STRONG",
|
|
617
|
+
"EM",
|
|
618
|
+
"U",
|
|
619
|
+
"S",
|
|
620
|
+
"CODE",
|
|
621
|
+
"SUB",
|
|
622
|
+
"SUP",
|
|
623
|
+
"SPAN",
|
|
624
|
+
"MARK",
|
|
625
|
+
"A"
|
|
626
|
+
]), wr = "noopener noreferrer nofollow", Tr = (e, t, n) => Ft(e, U(e, t) ?? t, n), Er = (e, t, n) => Tr(e, t, (e) => e.tagName === n), Dr = (e, t, n) => Tr(e, t, (e) => e.tagName === "SPAN" && e.style.getPropertyValue(n) !== ""), Or = (e, t) => Tr(e, t, (e) => e.tagName === "MARK"), kr = (e, t) => Ft(e, t, (e) => e.tagName === "A"), Ar = (e) => {
|
|
627
|
+
let { endContainer: t, endOffset: n } = e;
|
|
628
|
+
H(t) && n > 0 && n < t.length && t.splitText(n);
|
|
629
|
+
let { startContainer: r, startOffset: i } = e;
|
|
630
|
+
H(r) && i > 0 && i < r.length && r.splitText(i);
|
|
631
|
+
}, jr = (e, t) => {
|
|
632
|
+
if (t.collapsed) return [];
|
|
633
|
+
let n = t.commonAncestorContainer, r = H(n) ? n.parentNode ?? e : n, i = [], a = document.createTreeWalker(r, NodeFilter.SHOW_TEXT);
|
|
634
|
+
for (let n = a.nextNode(); n; n = a.nextNode()) {
|
|
635
|
+
let r = n;
|
|
636
|
+
if (!t.intersectsNode(r)) continue;
|
|
637
|
+
let a = U(r, e);
|
|
638
|
+
if (!a || a.tagName === "PRE") continue;
|
|
639
|
+
let o = r === t.startContainer ? t.startOffset : 0;
|
|
640
|
+
(r === t.endContainer ? t.endOffset : r.length) > o && i.push(r);
|
|
641
|
+
}
|
|
642
|
+
return i;
|
|
643
|
+
}, Mr = (e) => {
|
|
644
|
+
let t = e.parentNode;
|
|
645
|
+
if (e.previousSibling) {
|
|
646
|
+
let n = t.cloneNode(!1);
|
|
647
|
+
for (; t.firstChild && t.firstChild !== e;) n.append(t.firstChild);
|
|
648
|
+
t.before(n);
|
|
649
|
+
}
|
|
650
|
+
if (e.nextSibling) {
|
|
651
|
+
let n = t.cloneNode(!1);
|
|
652
|
+
for (; e.nextSibling;) n.append(e.nextSibling);
|
|
653
|
+
t.after(n);
|
|
654
|
+
}
|
|
655
|
+
}, Nr = (e, t) => {
|
|
656
|
+
let n = e;
|
|
657
|
+
for (; n !== t && n.parentNode;) Mr(n), n = n.parentNode;
|
|
658
|
+
return t;
|
|
659
|
+
}, Pr = (e, t) => {
|
|
660
|
+
let n = document.createElement(t);
|
|
661
|
+
return e.before(n), n.append(e), n;
|
|
662
|
+
}, Fr = (e, t) => {
|
|
663
|
+
e.setAttribute("data-color", t), e.setAttribute("style", `background-color: ${t}; color: inherit`);
|
|
664
|
+
}, Ir = (e, t) => {
|
|
665
|
+
let n = new Set(t.map((t) => U(t, e)));
|
|
666
|
+
for (let e of n) e?.isConnected && (Wt(e), Gt(e), G(e));
|
|
667
|
+
}, Lr = (e, t, n) => {
|
|
668
|
+
Ar(t);
|
|
669
|
+
let r = jr(e, t);
|
|
670
|
+
for (let e of r) n(e);
|
|
671
|
+
return Ir(e, r), r.length > 0;
|
|
672
|
+
}, Rr = (e, t, n) => {
|
|
673
|
+
let r = xr[n];
|
|
674
|
+
if (t.collapsed) return Er(t.startContainer, e, r) !== null;
|
|
675
|
+
let i = jr(e, t);
|
|
676
|
+
return i.length > 0 && i.every((t) => Er(t, e, r) !== null);
|
|
677
|
+
}, zr = (e, t, n) => {
|
|
678
|
+
let r = xr[n];
|
|
679
|
+
Ar(t);
|
|
680
|
+
let i = jr(e, t), a = i.length > 0 && i.every((t) => Er(t, e, r) !== null), o = n === "subscript" ? xr.superscript : n === "superscript" ? xr.subscript : null;
|
|
681
|
+
for (let t of i) {
|
|
682
|
+
let n = Er(t, e, r);
|
|
683
|
+
if (a) {
|
|
684
|
+
n && K(Nr(t, n));
|
|
685
|
+
continue;
|
|
686
|
+
}
|
|
687
|
+
let i = o ? Er(t, e, o) : null;
|
|
688
|
+
i && K(Nr(t, i)), n || Pr(t, r);
|
|
689
|
+
}
|
|
690
|
+
Ir(e, i);
|
|
691
|
+
}, Br = (e, t, n, r) => {
|
|
692
|
+
let i = Sr[n];
|
|
693
|
+
Lr(e, t, (t) => {
|
|
694
|
+
let n = Dr(t, e, i);
|
|
695
|
+
if (n) {
|
|
696
|
+
let e = Nr(t, n);
|
|
697
|
+
r ? e.style.setProperty(i, r) : e.style.removeProperty(i), e.getAttribute("style") || K(e);
|
|
698
|
+
} else r && Pr(t, "span").style.setProperty(i, r);
|
|
699
|
+
});
|
|
700
|
+
}, Vr = (e, t, n) => {
|
|
701
|
+
Lr(e, t, (t) => {
|
|
702
|
+
let r = Or(t, e);
|
|
703
|
+
if (r) {
|
|
704
|
+
let e = Nr(t, r);
|
|
705
|
+
n ? Fr(e, n) : K(e);
|
|
706
|
+
} else n && Fr(Pr(t, "mark"), n);
|
|
707
|
+
});
|
|
708
|
+
}, Hr = (e, t, n, r) => Lr(e, t, (t) => {
|
|
709
|
+
let i = kr(t, e);
|
|
710
|
+
i && K(Nr(t, i));
|
|
711
|
+
let a = Pr(t, "a");
|
|
712
|
+
a.setAttribute("href", n), a.setAttribute("rel", wr), r && a.setAttribute("target", r);
|
|
713
|
+
}), Ur = (e, t) => {
|
|
714
|
+
Lr(e, t, (t) => {
|
|
715
|
+
let n = kr(t, e);
|
|
716
|
+
n && K(Nr(t, n));
|
|
717
|
+
});
|
|
718
|
+
}, Wr = (e, t) => {
|
|
719
|
+
let n = (e) => Cr.has(e.tagName);
|
|
720
|
+
Lr(e, t, (t) => {
|
|
721
|
+
let r = Tr(t, e, n);
|
|
722
|
+
for (; r;) K(Nr(t, r)), r = Tr(t, e, n);
|
|
723
|
+
});
|
|
724
|
+
}, Gr = (e, t) => {
|
|
725
|
+
let n = {};
|
|
726
|
+
for (let [r, i] of Object.entries(xr)) n[r] = Er(t, e, i) !== null;
|
|
727
|
+
return n;
|
|
728
|
+
}, Kr = (e, t, n) => Dr(t, e, Sr[n])?.style.getPropertyValue(Sr[n]) ?? "", qr = (e, t) => {
|
|
729
|
+
let n = Or(t, e);
|
|
730
|
+
return n ? n.getAttribute("data-color") || n.style.backgroundColor || "#fef08a" : "";
|
|
731
|
+
}, Jr = (e, t, n, r) => {
|
|
732
|
+
let i = U(t.startContainer, e);
|
|
733
|
+
if (!i) return;
|
|
734
|
+
let a = t.startContainer, o = {
|
|
735
|
+
...Gr(e, a),
|
|
736
|
+
...r.marks
|
|
737
|
+
}, s = {
|
|
738
|
+
color: Kr(e, a, "color"),
|
|
739
|
+
fontFamily: Kr(e, a, "fontFamily"),
|
|
740
|
+
fontSize: Kr(e, a, "fontSize")
|
|
741
|
+
};
|
|
742
|
+
for (let [e, t] of Object.entries(r.styles)) s[e] = t ?? "";
|
|
743
|
+
let c = r.highlight === void 0 ? qr(e, a) : r.highlight ?? "", l = kr(a, e), u = document.createRange();
|
|
744
|
+
u.setStart(t.startContainer, t.startOffset), u.setEnd(i, i.childNodes.length);
|
|
745
|
+
let d = u.extractContents(), f = d.firstChild;
|
|
746
|
+
i.append(d);
|
|
747
|
+
let p = document.createTextNode(n), m = (e) => {
|
|
748
|
+
e.append(p), p = e;
|
|
749
|
+
};
|
|
750
|
+
for (let [e, t] of Object.entries(xr)) o[e] && m(document.createElement(t));
|
|
751
|
+
let h = Object.keys(Sr).filter((e) => s[e]).map((e) => `${Sr[e]}: ${s[e]}`);
|
|
752
|
+
if (h.length) {
|
|
753
|
+
let e = document.createElement("span");
|
|
754
|
+
e.setAttribute("style", h.join("; ")), m(e);
|
|
755
|
+
}
|
|
756
|
+
if (c) {
|
|
757
|
+
let e = document.createElement("mark");
|
|
758
|
+
Fr(e, c), m(e);
|
|
759
|
+
}
|
|
760
|
+
l && V(f) && l.contains(a) && m(l.cloneNode(!1)), i.insertBefore(p, f && f.parentNode === i ? f : null), Wt(i), Gt(i), G(i);
|
|
761
|
+
}, Yr = {
|
|
762
|
+
headingLevel: 0,
|
|
763
|
+
fontFamily: "",
|
|
764
|
+
fontSize: "",
|
|
765
|
+
lineHeight: "",
|
|
766
|
+
color: "",
|
|
767
|
+
highlight: "",
|
|
768
|
+
align: "left",
|
|
769
|
+
direction: "auto",
|
|
770
|
+
bold: !1,
|
|
771
|
+
italic: !1,
|
|
772
|
+
underline: !1,
|
|
773
|
+
strike: !1,
|
|
774
|
+
code: !1,
|
|
775
|
+
subscript: !1,
|
|
776
|
+
superscript: !1,
|
|
777
|
+
link: !1,
|
|
778
|
+
bulletList: !1,
|
|
779
|
+
orderedList: !1,
|
|
780
|
+
taskList: !1,
|
|
781
|
+
blockquote: !1,
|
|
782
|
+
codeBlock: !1,
|
|
783
|
+
canUndo: !1,
|
|
784
|
+
canRedo: !1
|
|
785
|
+
}, Xr = [
|
|
786
|
+
"bold",
|
|
787
|
+
"italic",
|
|
788
|
+
"underline",
|
|
789
|
+
"strike",
|
|
790
|
+
"code",
|
|
791
|
+
"subscript",
|
|
792
|
+
"superscript"
|
|
793
|
+
], Zr = (e) => e.replace(/["']/g, "").replace(/\s*,\s*/g, ", ").trim(), Qr = (e) => {
|
|
794
|
+
let t = e?.style.textAlign ?? "";
|
|
795
|
+
return t === "center" || t === "right" || t === "justify" ? t : "left";
|
|
796
|
+
}, $r = (e) => {
|
|
797
|
+
let t = e?.getAttribute("dir");
|
|
798
|
+
return t === "rtl" || t === "ltr" ? t : "auto";
|
|
799
|
+
}, ei = ({ root: e, range: t, pending: n, canUndo: r, canRedo: i }) => {
|
|
800
|
+
if (!t) return {
|
|
801
|
+
...Yr,
|
|
802
|
+
canUndo: r,
|
|
803
|
+
canRedo: i
|
|
804
|
+
};
|
|
805
|
+
let a = t.collapsed ? t.startContainer : jr(e, t)[0] ?? t.startContainer, o = U(a, e), s = Object.fromEntries(Xr.map((n) => [n, Rr(e, t, n)])), c = {
|
|
806
|
+
color: Kr(e, a, "color"),
|
|
807
|
+
fontFamily: Zr(Kr(e, a, "fontFamily")),
|
|
808
|
+
fontSize: Kr(e, a, "fontSize")
|
|
809
|
+
}, l = qr(e, a);
|
|
810
|
+
if (t.collapsed && n) {
|
|
811
|
+
Object.assign(s, n.marks);
|
|
812
|
+
for (let [e, t] of Object.entries(n.styles)) c[e] = e === "fontFamily" ? Zr(t ?? "") : t ?? "";
|
|
813
|
+
n.highlight !== void 0 && (l = n.highlight ?? "");
|
|
814
|
+
}
|
|
815
|
+
let u = or(e, a), d = o && /^H[1-6]$/.test(o.tagName) ? Number(o.tagName[1]) : 0;
|
|
816
|
+
return {
|
|
817
|
+
...s,
|
|
818
|
+
...c,
|
|
819
|
+
headingLevel: d,
|
|
820
|
+
highlight: l,
|
|
821
|
+
lineHeight: o?.style.lineHeight ?? "",
|
|
822
|
+
align: Qr(o),
|
|
823
|
+
direction: $r(o),
|
|
824
|
+
link: kr(a, e) !== null,
|
|
825
|
+
bulletList: u === "bulletList",
|
|
826
|
+
orderedList: u === "orderedList",
|
|
827
|
+
taskList: u === "taskList",
|
|
828
|
+
blockquote: It(a, e, "BLOCKQUOTE") !== null,
|
|
829
|
+
codeBlock: o?.tagName === "PRE",
|
|
830
|
+
canUndo: r,
|
|
831
|
+
canRedo: i
|
|
832
|
+
};
|
|
833
|
+
}, ti = (e, t) => Object.keys(e).every((n) => e[n] === t[n]), ni = /^image\//, ri = /^(?:https?:\/\/|www\.)\S+$/i, ii = (e) => ({
|
|
834
|
+
html: e?.getData("text/html") ?? "",
|
|
835
|
+
text: e?.getData("text/plain") ?? "",
|
|
836
|
+
files: Array.from(e?.files ?? [])
|
|
837
|
+
}), ai = (e) => e.files.filter((e) => ni.test(e.type)), oi = (e) => {
|
|
838
|
+
let t = e.text.trim();
|
|
839
|
+
return ri.test(t) ? t.startsWith("www.") ? `https://${t}` : t : null;
|
|
840
|
+
}, si = (e) => {
|
|
841
|
+
let t = document.createDocumentFragment(), n = e.replace(/\r\n?/g, "\n").split("\n");
|
|
842
|
+
n.length > 1 && n.at(-1) === "" && n.pop();
|
|
843
|
+
for (let e of n) t.append(Rt(e ? [document.createTextNode(e)] : []));
|
|
844
|
+
return t;
|
|
845
|
+
}, ci = (e) => e.html ? Vn(e.html) : e.text ? si(e.text) : null, li = (e, t) => {
|
|
846
|
+
let n = qt(e, t);
|
|
847
|
+
return n.length < 2 ? t.toString() : n.map((e) => {
|
|
848
|
+
let n = document.createRange();
|
|
849
|
+
return n.selectNodeContents(e), e.contains(t.startContainer) && n.setStart(t.startContainer, t.startOffset), e.contains(t.endContainer) && n.setEnd(t.endContainer, t.endOffset), n.toString();
|
|
850
|
+
}).join("\n");
|
|
851
|
+
}, ui = (e, t, n) => {
|
|
852
|
+
let r = document.createElement("div");
|
|
853
|
+
r.append(n.cloneContents()), Hn(r, !0), e.setData("text/html", r.innerHTML), e.setData("text/plain", li(t, n));
|
|
854
|
+
}, di = (e, t) => {
|
|
855
|
+
let n = document;
|
|
856
|
+
if (!n.caretPositionFromPoint) return n.caretRangeFromPoint?.(e, t) ?? null;
|
|
857
|
+
let r = n.caretPositionFromPoint(e, t);
|
|
858
|
+
if (!r) return null;
|
|
859
|
+
let i = document.createRange();
|
|
860
|
+
return i.setStart(r.offsetNode, r.offset), i.collapse(!0), i;
|
|
861
|
+
}, fi = (e) => Array.prototype.indexOf.call(e.parentNode?.childNodes ?? [], e), pi = (e, t) => H(e) ? U(e, t) ? e.data.length : null : Nt(e) ? +!e.hasAttribute("data-doc-trailing") : Mt(e) ? 1 : null, mi = (e) => {
|
|
862
|
+
let t = [], n = document.createTreeWalker(e, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT), r = 0, i;
|
|
863
|
+
for (let a = n.nextNode(); a; a = n.nextNode()) {
|
|
864
|
+
let n = pi(a, e);
|
|
865
|
+
if (n === null) continue;
|
|
866
|
+
let o = U(a, e);
|
|
867
|
+
i !== void 0 && o !== i && (r += 1), i = o, t.push({
|
|
868
|
+
node: a,
|
|
869
|
+
start: r,
|
|
870
|
+
size: n,
|
|
871
|
+
block: o
|
|
872
|
+
}), r += n;
|
|
873
|
+
}
|
|
874
|
+
return t;
|
|
875
|
+
}, hi = (e, t, n, r) => {
|
|
876
|
+
if (H(n)) {
|
|
877
|
+
let e = t.find((e) => e.node === n);
|
|
878
|
+
if (e) return e.start + Math.min(r, e.size);
|
|
879
|
+
}
|
|
880
|
+
let i = document.createRange();
|
|
881
|
+
i.setStart(n, r);
|
|
882
|
+
let a = U(n, e), o = null;
|
|
883
|
+
for (let e of t) {
|
|
884
|
+
if (i.comparePoint(e.node, 0) > 0) return !o || e.block === a ? e.start : o.start + o.size;
|
|
885
|
+
o = e;
|
|
886
|
+
}
|
|
887
|
+
return o ? o.start + o.size : 0;
|
|
888
|
+
}, gi = (e, t, n) => {
|
|
889
|
+
for (let r of t) {
|
|
890
|
+
if (n > r.start + r.size) continue;
|
|
891
|
+
let t = Math.max(n, r.start);
|
|
892
|
+
if (H(r.node)) return {
|
|
893
|
+
node: r.node,
|
|
894
|
+
offset: t - r.start
|
|
895
|
+
};
|
|
896
|
+
let i = r.node.parentNode ?? e, a = fi(r.node);
|
|
897
|
+
return {
|
|
898
|
+
node: i,
|
|
899
|
+
offset: t === r.start || Pt(r.node) ? a : a + 1
|
|
900
|
+
};
|
|
901
|
+
}
|
|
902
|
+
let r = t.at(-1);
|
|
903
|
+
return r ? H(r.node) ? {
|
|
904
|
+
node: r.node,
|
|
905
|
+
offset: r.size
|
|
906
|
+
} : {
|
|
907
|
+
node: r.node.parentNode ?? e,
|
|
908
|
+
offset: fi(r.node) + +!Pt(r.node)
|
|
909
|
+
} : {
|
|
910
|
+
node: e,
|
|
911
|
+
offset: 0
|
|
912
|
+
};
|
|
913
|
+
}, X = (e) => {
|
|
914
|
+
let t = document.getSelection();
|
|
915
|
+
if (!t || t.rangeCount === 0) return null;
|
|
916
|
+
let n = t.getRangeAt(0);
|
|
917
|
+
return e.contains(n.startContainer) && e.contains(n.endContainer) ? n : null;
|
|
918
|
+
}, _i = (e) => {
|
|
919
|
+
let t = document.getSelection();
|
|
920
|
+
t && (t.removeAllRanges(), t.addRange(e));
|
|
921
|
+
}, vi = (e, t) => {
|
|
922
|
+
let n = document.createRange();
|
|
923
|
+
return n.setStart(e, t), n.collapse(!0), _i(n), n;
|
|
924
|
+
}, yi = (e) => {
|
|
925
|
+
let t = [], n = document.createTreeWalker(e, NodeFilter.SHOW_TEXT);
|
|
926
|
+
for (let e = n.nextNode(); e; e = n.nextNode()) t.push(e);
|
|
927
|
+
return t;
|
|
928
|
+
}, bi = (e) => {
|
|
929
|
+
let t = yi(e)[0];
|
|
930
|
+
return vi(t || e, 0);
|
|
931
|
+
}, xi = (e) => {
|
|
932
|
+
let t = yi(e).at(-1);
|
|
933
|
+
if (t) return vi(t, t.data.length);
|
|
934
|
+
let n = Array.from(e.childNodes).find(Pt);
|
|
935
|
+
return vi(e, n ? fi(n) : e.childNodes.length);
|
|
936
|
+
}, Si = (e, t) => {
|
|
937
|
+
let n = mi(e), r = hi(e, n, t.startContainer, t.startOffset);
|
|
938
|
+
return {
|
|
939
|
+
anchor: r,
|
|
940
|
+
focus: t.collapsed ? r : hi(e, n, t.endContainer, t.endOffset)
|
|
941
|
+
};
|
|
942
|
+
}, Ci = (e, t) => {
|
|
943
|
+
let n = mi(e), r = gi(e, n, Math.min(t.anchor, t.focus)), i = gi(e, n, Math.max(t.anchor, t.focus)), a = document.createRange();
|
|
944
|
+
return a.setStart(r.node, r.offset), a.setEnd(i.node, i.offset), a;
|
|
945
|
+
}, wi = (e) => {
|
|
946
|
+
let t = document.getSelection(), { anchorNode: n, focusNode: r } = t ?? {};
|
|
947
|
+
if (!t || !n || !r || !e.contains(n) || !e.contains(r)) return null;
|
|
948
|
+
let i = mi(e);
|
|
949
|
+
return {
|
|
950
|
+
anchor: hi(e, i, n, t.anchorOffset),
|
|
951
|
+
focus: hi(e, i, r, t.focusOffset)
|
|
952
|
+
};
|
|
953
|
+
}, Ti = (e, t) => {
|
|
954
|
+
let n = mi(e), r = gi(e, n, t.anchor), i = gi(e, n, t.focus);
|
|
955
|
+
document.getSelection()?.setBaseAndExtent(r.node, r.offset, i.node, i.offset);
|
|
956
|
+
}, Ei = (e) => {
|
|
957
|
+
let t = X(e);
|
|
958
|
+
t && (V(t.startContainer) ? t.startContainer : t.startContainer.parentElement)?.scrollIntoView({
|
|
959
|
+
block: "nearest",
|
|
960
|
+
inline: "nearest"
|
|
961
|
+
});
|
|
962
|
+
}, Di = /* @__PURE__ */ new Set([
|
|
963
|
+
"TD",
|
|
964
|
+
"TH",
|
|
965
|
+
"TR",
|
|
966
|
+
"TBODY",
|
|
967
|
+
"TABLE"
|
|
968
|
+
]), Oi = /* @__PURE__ */ new Set(["TD", "TH"]), ki = /^H[1-6]$/, Ai = (e, t) => It(e, t, Oi), ji = (e) => {
|
|
969
|
+
let t = document.createTreeWalker(e, NodeFilter.SHOW_TEXT).nextNode();
|
|
970
|
+
return t ? {
|
|
971
|
+
node: t,
|
|
972
|
+
offset: 0
|
|
973
|
+
} : {
|
|
974
|
+
node: e,
|
|
975
|
+
offset: 0
|
|
976
|
+
};
|
|
977
|
+
}, Mi = (e) => {
|
|
978
|
+
let t = document.createTreeWalker(e, NodeFilter.SHOW_TEXT), n = null;
|
|
979
|
+
for (let e = t.nextNode(); e; e = t.nextNode()) n = e;
|
|
980
|
+
if (n) return {
|
|
981
|
+
node: n,
|
|
982
|
+
offset: n.length
|
|
983
|
+
};
|
|
984
|
+
let r = e.tagName === "PRE" ? e.querySelector("code") ?? e : e, i = Array.from(r.childNodes).find(Pt);
|
|
985
|
+
return {
|
|
986
|
+
node: r,
|
|
987
|
+
offset: i ? fi(i) : r.childNodes.length
|
|
988
|
+
};
|
|
989
|
+
}, Ni = (e, t) => {
|
|
990
|
+
let n = e;
|
|
991
|
+
for (; n && n !== t && V(n) && !Di.has(n.tagName) && !n.querySelector("p, h1, h2, h3, h4, h5, h6, pre, hr, img, div[data-type=\"page-break\"], table");) {
|
|
992
|
+
let e = n.parentNode;
|
|
993
|
+
n.remove(), n = e;
|
|
994
|
+
}
|
|
995
|
+
}, Pi = (e) => {
|
|
996
|
+
Wt(e), Gt(e), G(e);
|
|
997
|
+
}, Fi = (e, t, n) => {
|
|
998
|
+
let r = Mi(e);
|
|
999
|
+
if (e.tagName === "PRE" || t.tagName === "PRE") {
|
|
1000
|
+
let n = document.createTextNode(t.textContent ?? ""), r = e.tagName === "PRE" ? e.querySelector("code") ?? e : e, i = Array.from(r.childNodes).find(Pt) ?? null;
|
|
1001
|
+
r.insertBefore(n, i);
|
|
1002
|
+
} else {
|
|
1003
|
+
for (let t of Array.from(e.childNodes).filter(Pt)) t.remove();
|
|
1004
|
+
e.append(...Array.from(t.childNodes).filter((e) => !Pt(e)));
|
|
1005
|
+
}
|
|
1006
|
+
let i = t.parentNode;
|
|
1007
|
+
return t.remove(), Ni(i, n), e.tagName !== "PRE" && (Wt(e), G(e)), r;
|
|
1008
|
+
}, Ii = (e, t) => {
|
|
1009
|
+
if (t.collapsed) return;
|
|
1010
|
+
if (Ai(t.startContainer, e) !== Ai(t.endContainer, e)) {
|
|
1011
|
+
for (let n of qt(e, t)) {
|
|
1012
|
+
let e = document.createRange();
|
|
1013
|
+
e.selectNodeContents(n), n.contains(t.startContainer) && e.setStart(t.startContainer, t.startOffset), n.contains(t.endContainer) && e.setEnd(t.endContainer, t.endOffset), e.deleteContents(), Pi(n);
|
|
1014
|
+
}
|
|
1015
|
+
return;
|
|
1016
|
+
}
|
|
1017
|
+
let n = U(t.startContainer, e), r = U(t.endContainer, e);
|
|
1018
|
+
t.deleteContents(), n?.isConnected && r?.isConnected && n !== r && Fi(n, r, e), n?.isConnected && Pi(n);
|
|
1019
|
+
}, Li = (e) => {
|
|
1020
|
+
let t = e.parentElement;
|
|
1021
|
+
if (t?.tagName !== "BLOCKQUOTE") return;
|
|
1022
|
+
let n = [];
|
|
1023
|
+
for (let t = e.nextSibling; t; t = t.nextSibling) n.push(t);
|
|
1024
|
+
if (t.after(e), n.length) {
|
|
1025
|
+
let r = t.cloneNode(!1);
|
|
1026
|
+
r.append(...n), e.after(r);
|
|
1027
|
+
}
|
|
1028
|
+
t.childElementCount || t.remove();
|
|
1029
|
+
}, Ri = (e, t) => {
|
|
1030
|
+
let n = Kt(e);
|
|
1031
|
+
return n[n.indexOf(t) - 1] ?? null;
|
|
1032
|
+
}, zi = (e, t) => {
|
|
1033
|
+
let n = Kt(e);
|
|
1034
|
+
return n[n.indexOf(t) + 1] ?? null;
|
|
1035
|
+
}, Bi = (e, t) => {
|
|
1036
|
+
let n = Y(t, e);
|
|
1037
|
+
if (n && An(n).firstElementChild === t) return fr(e, n), ji(t);
|
|
1038
|
+
if (t.parentElement?.tagName === "BLOCKQUOTE" && t.parentElement.firstElementChild === t) return Li(t), ji(t);
|
|
1039
|
+
let r = Kn(t, e), i = qn(r, t).previousElementSibling;
|
|
1040
|
+
if (Mt(i)) return i.remove(), ji(t);
|
|
1041
|
+
if (i?.tagName === "TABLE") {
|
|
1042
|
+
Bt(t) && r.childElementCount > 1 && t.remove();
|
|
1043
|
+
let e = i.querySelector("tr:last-child > :last-child"), n = e ? Array.from(e.querySelectorAll(Et)).at(-1) : null;
|
|
1044
|
+
return n ? Mi(n) : null;
|
|
1045
|
+
}
|
|
1046
|
+
let a = Ri(e, t);
|
|
1047
|
+
return !a || Ai(a, e) !== Ai(t, e) ? null : Fi(a, t, e);
|
|
1048
|
+
}, Vi = (e, t) => {
|
|
1049
|
+
let n = qn(Kn(t, e), t) === t ? t.nextElementSibling : null;
|
|
1050
|
+
if (Mt(n)) return n.remove(), Mi(t);
|
|
1051
|
+
if (n?.tagName === "TABLE") return null;
|
|
1052
|
+
let r = zi(e, t);
|
|
1053
|
+
if (!r || Ai(r, e) !== Ai(t, e)) return null;
|
|
1054
|
+
let i = Y(r, e), a = Fi(t, r, e);
|
|
1055
|
+
if (i?.isConnected && Y(t, e) !== i) {
|
|
1056
|
+
let n = Y(t, e);
|
|
1057
|
+
n && (An(n).append(...Array.from(An(i).childNodes)), i.remove());
|
|
1058
|
+
}
|
|
1059
|
+
return a;
|
|
1060
|
+
}, Hi = (e, t) => {
|
|
1061
|
+
let n = Gi(e, t, "\n"), r = e.querySelector("code") ?? e;
|
|
1062
|
+
return (e.textContent ?? "").endsWith("\n") && !Array.from(r.childNodes).some(Pt) && r.append(Lt()), n;
|
|
1063
|
+
}, Ui = (e, t) => {
|
|
1064
|
+
let n = U(t.startContainer, e);
|
|
1065
|
+
if (!n) return null;
|
|
1066
|
+
if (n.tagName === "PRE") return Hi(n, t);
|
|
1067
|
+
let r = Y(n, e);
|
|
1068
|
+
if (r && Bt(n) && An(r).childElementCount === 1) return fr(e, r), ji(n);
|
|
1069
|
+
if (n.parentElement?.tagName === "BLOCKQUOTE" && Bt(n)) return Li(n), ji(n);
|
|
1070
|
+
let i = Zt(n, t.startContainer, t.startOffset), a = ir(n, t.startContainer, t.startOffset);
|
|
1071
|
+
return i && ki.test(n.tagName) && (a = Ht(a, "p")), r && n.parentElement === An(r) && vr(r, a), ji(a);
|
|
1072
|
+
}, Wi = (e, t) => {
|
|
1073
|
+
let n = U(t.startContainer, e);
|
|
1074
|
+
if (!n) return null;
|
|
1075
|
+
if (n.tagName === "PRE") return Hi(n, t);
|
|
1076
|
+
let r = document.createElement("br");
|
|
1077
|
+
return t.insertNode(r), G(n), {
|
|
1078
|
+
node: r.parentNode ?? n,
|
|
1079
|
+
offset: fi(r) + 1
|
|
1080
|
+
};
|
|
1081
|
+
}, Gi = (e, t, n) => {
|
|
1082
|
+
let { startContainer: r, startOffset: i } = t;
|
|
1083
|
+
if (!U(r, e) && !H(r)) {
|
|
1084
|
+
let e = Rt();
|
|
1085
|
+
r.insertBefore(e, r.childNodes[i] ?? null), r = e, i = 0;
|
|
1086
|
+
}
|
|
1087
|
+
if (H(r)) return r.insertData(i, n), {
|
|
1088
|
+
node: r,
|
|
1089
|
+
offset: i + n.length
|
|
1090
|
+
};
|
|
1091
|
+
let a = r.childNodes[i - 1];
|
|
1092
|
+
if (H(a)) return a.appendData(n), {
|
|
1093
|
+
node: a,
|
|
1094
|
+
offset: a.length
|
|
1095
|
+
};
|
|
1096
|
+
let o = r.childNodes[i] ?? null;
|
|
1097
|
+
if (H(o)) return o.insertData(0, n), {
|
|
1098
|
+
node: o,
|
|
1099
|
+
offset: n.length
|
|
1100
|
+
};
|
|
1101
|
+
let s = document.createTextNode(n);
|
|
1102
|
+
return r.insertBefore(s, o), kt(r) && G(r), {
|
|
1103
|
+
node: s,
|
|
1104
|
+
offset: n.length
|
|
1105
|
+
};
|
|
1106
|
+
}, Ki = (e, t, n) => {
|
|
1107
|
+
let r = Array.from(n.childNodes), i = r[0], a = r.at(-1);
|
|
1108
|
+
if (!i || !a) return null;
|
|
1109
|
+
let o = U(t.startContainer, e);
|
|
1110
|
+
if (!o) return e.append(n), kt(a) ? Mi(a) : null;
|
|
1111
|
+
if (o.tagName === "PRE") return Gi(e, t, r.map((e) => e.textContent ?? "").join("\n"));
|
|
1112
|
+
if (r.length === 1 && V(i) && i.tagName === "P") {
|
|
1113
|
+
let e = Array.from(i.childNodes).filter((e) => !Pt(e)), n = e.at(-1);
|
|
1114
|
+
if (!n) return {
|
|
1115
|
+
node: t.startContainer,
|
|
1116
|
+
offset: t.startOffset
|
|
1117
|
+
};
|
|
1118
|
+
let r = document.createDocumentFragment();
|
|
1119
|
+
return r.append(...e), t.insertNode(r), G(o), H(n) ? {
|
|
1120
|
+
node: n,
|
|
1121
|
+
offset: n.length
|
|
1122
|
+
} : {
|
|
1123
|
+
node: n.parentNode ?? o,
|
|
1124
|
+
offset: fi(n) + 1
|
|
1125
|
+
};
|
|
1126
|
+
}
|
|
1127
|
+
let s = ir(o, t.startContainer, t.startOffset);
|
|
1128
|
+
o.after(...r), V(i) && i.tagName === "P" && !Bt(o) && Fi(o, i, e);
|
|
1129
|
+
let c;
|
|
1130
|
+
return kt(a) && a.isConnected && a.tagName !== "PRE" ? Bt(s) ? (c = Mi(a), s.remove()) : c = Fi(a, s, e) : c = ji(s), o.isConnected && Bt(o) && o.nextElementSibling && o.remove(), c;
|
|
1131
|
+
}, qi = (e, t) => t.collapsed && Xt(e, t.startContainer, t.startOffset), Ji = (e, t) => t.collapsed && Zt(e, t.startContainer, t.startOffset), Yi = 800, Xi = 200, Zi = class {
|
|
1132
|
+
limit;
|
|
1133
|
+
undoStack = [];
|
|
1134
|
+
redoStack = [];
|
|
1135
|
+
lastKind = null;
|
|
1136
|
+
lastTime = 0;
|
|
1137
|
+
constructor(e = Xi) {
|
|
1138
|
+
this.limit = e;
|
|
1139
|
+
}
|
|
1140
|
+
get canUndo() {
|
|
1141
|
+
return this.undoStack.length > 0;
|
|
1142
|
+
}
|
|
1143
|
+
get canRedo() {
|
|
1144
|
+
return this.redoStack.length > 0;
|
|
1145
|
+
}
|
|
1146
|
+
record(e, t) {
|
|
1147
|
+
let n = Date.now(), r = t === "typing" && this.lastKind === "typing" && n - this.lastTime < Yi;
|
|
1148
|
+
this.lastKind = t, this.lastTime = n, !r && (this.push(this.undoStack, this.share(e())), this.redoStack.length = 0);
|
|
1149
|
+
}
|
|
1150
|
+
breakGroup() {
|
|
1151
|
+
this.lastKind = null;
|
|
1152
|
+
}
|
|
1153
|
+
undo(e) {
|
|
1154
|
+
let t = this.undoStack.pop();
|
|
1155
|
+
return t ? (this.push(this.redoStack, this.share(e)), this.lastKind = null, t) : null;
|
|
1156
|
+
}
|
|
1157
|
+
redo(e) {
|
|
1158
|
+
let t = this.redoStack.pop();
|
|
1159
|
+
return t ? (this.push(this.undoStack, this.share(e)), this.lastKind = null, t) : null;
|
|
1160
|
+
}
|
|
1161
|
+
clear() {
|
|
1162
|
+
this.undoStack.length = 0, this.redoStack.length = 0, this.lastKind = null;
|
|
1163
|
+
}
|
|
1164
|
+
push(e, t) {
|
|
1165
|
+
e.push(t), e.length > this.limit && e.shift();
|
|
1166
|
+
}
|
|
1167
|
+
share(e) {
|
|
1168
|
+
let t = this.undoStack.at(-1) ?? this.redoStack.at(-1);
|
|
1169
|
+
if (!t) return e;
|
|
1170
|
+
let n = new Map(t.blocks.map((e) => [e, e]));
|
|
1171
|
+
return {
|
|
1172
|
+
...e,
|
|
1173
|
+
blocks: e.blocks.map((e) => n.get(e) ?? e)
|
|
1174
|
+
};
|
|
1175
|
+
}
|
|
1176
|
+
}, Qi = "\xA0", $i = /* @__PURE__ */ new Set([
|
|
1177
|
+
" ",
|
|
1178
|
+
"`",
|
|
1179
|
+
"-"
|
|
1180
|
+
]), ea = "*_~`=", ta = [
|
|
1181
|
+
[/--$/, "—"],
|
|
1182
|
+
[/\.\.\.$/, "…"],
|
|
1183
|
+
[/<-$/, "←"],
|
|
1184
|
+
[/->$/, "→"],
|
|
1185
|
+
[/\(c\)$/i, "©"],
|
|
1186
|
+
[/\(r\)$/i, "®"],
|
|
1187
|
+
[/\(tm\)$/i, "™"],
|
|
1188
|
+
[/\(sm\)$/i, "℠"],
|
|
1189
|
+
[/\+\/-$/, "±"],
|
|
1190
|
+
[/!=$/, "≠"],
|
|
1191
|
+
[/<<$/, "«"],
|
|
1192
|
+
[/>>$/, "»"],
|
|
1193
|
+
[/(?<=\d ?)[x*](?= ?\d$)/, "×"]
|
|
1194
|
+
], na = [
|
|
1195
|
+
{
|
|
1196
|
+
pattern: /(\*\*|__)([^*_\s](?:[^*_]*[^*_\s])?)\1$/,
|
|
1197
|
+
mark: "bold"
|
|
1198
|
+
},
|
|
1199
|
+
{
|
|
1200
|
+
pattern: /~~([^~\s](?:[^~]*[^~\s])?)~~$/,
|
|
1201
|
+
mark: "strike"
|
|
1202
|
+
},
|
|
1203
|
+
{
|
|
1204
|
+
pattern: /==([^=\s](?:[^=]*[^=\s])?)==$/,
|
|
1205
|
+
mark: "highlight"
|
|
1206
|
+
},
|
|
1207
|
+
{
|
|
1208
|
+
pattern: /`([^`]+)`$/,
|
|
1209
|
+
mark: "code"
|
|
1210
|
+
},
|
|
1211
|
+
{
|
|
1212
|
+
pattern: /(?<![*_\w])(\*|_)([^*_\s](?:[^*_]*[^*_\s])?)\1$/,
|
|
1213
|
+
mark: "italic"
|
|
1214
|
+
}
|
|
1215
|
+
], ra = {
|
|
1216
|
+
highlight: "==",
|
|
1217
|
+
strike: "~~",
|
|
1218
|
+
code: "`"
|
|
1219
|
+
}, ia = [
|
|
1220
|
+
{
|
|
1221
|
+
pattern: /^(#{1,6}) $/,
|
|
1222
|
+
kind: "heading"
|
|
1223
|
+
},
|
|
1224
|
+
{
|
|
1225
|
+
pattern: /^\[( |x)\] $/i,
|
|
1226
|
+
kind: "taskList"
|
|
1227
|
+
},
|
|
1228
|
+
{
|
|
1229
|
+
pattern: /^[-+*] $/,
|
|
1230
|
+
kind: "bulletList"
|
|
1231
|
+
},
|
|
1232
|
+
{
|
|
1233
|
+
pattern: /^(\d+)\. $/,
|
|
1234
|
+
kind: "orderedList"
|
|
1235
|
+
},
|
|
1236
|
+
{
|
|
1237
|
+
pattern: /^> $/,
|
|
1238
|
+
kind: "blockquote"
|
|
1239
|
+
},
|
|
1240
|
+
{
|
|
1241
|
+
pattern: /^```$/,
|
|
1242
|
+
kind: "codeBlock"
|
|
1243
|
+
},
|
|
1244
|
+
{
|
|
1245
|
+
pattern: /^(?:---|—-|___ |\*\*\* )$/,
|
|
1246
|
+
kind: "rule"
|
|
1247
|
+
}
|
|
1248
|
+
], aa = /(?:^|\s)((?:https?:\/\/|www\.)[^\s]+[^\s.,;:!?)])\s$/, oa = /[\s([{«]/, sa = (e, t) => {
|
|
1249
|
+
let n = document.createRange();
|
|
1250
|
+
n.setStart(e, 0), n.setEnd(t.startContainer, t.startOffset);
|
|
1251
|
+
let r = [], i = "", a = document.createTreeWalker(e, NodeFilter.SHOW_TEXT);
|
|
1252
|
+
for (let e = a.nextNode(); e; e = a.nextNode()) {
|
|
1253
|
+
if (!H(e) || !n.intersectsNode(e)) continue;
|
|
1254
|
+
let a = e === t.startContainer ? e.data.slice(0, t.startOffset) : e.data;
|
|
1255
|
+
if (n.comparePoint(e, 0) > 0) break;
|
|
1256
|
+
r.push({
|
|
1257
|
+
node: e,
|
|
1258
|
+
start: i.length
|
|
1259
|
+
}), i += a.replaceAll(Qi, " ");
|
|
1260
|
+
}
|
|
1261
|
+
return {
|
|
1262
|
+
text: i,
|
|
1263
|
+
segments: r
|
|
1264
|
+
};
|
|
1265
|
+
}, ca = ({ segments: e }, t, n) => {
|
|
1266
|
+
let r = e.find((e) => t >= e.start && t <= e.start + e.node.length), i = [...e].reverse().find((e) => n >= e.start && n <= e.start + e.node.length);
|
|
1267
|
+
if (!r || !i) return null;
|
|
1268
|
+
let a = document.createRange();
|
|
1269
|
+
return a.setStart(r.node, t - r.start), a.setEnd(i.node, n - i.start), a;
|
|
1270
|
+
}, la = (e, t, n, r) => {
|
|
1271
|
+
let i = ca(e, t, n);
|
|
1272
|
+
if (!i) return null;
|
|
1273
|
+
i.deleteContents();
|
|
1274
|
+
let a = document.createTextNode(r);
|
|
1275
|
+
return i.insertNode(a), {
|
|
1276
|
+
node: a,
|
|
1277
|
+
offset: r.length
|
|
1278
|
+
};
|
|
1279
|
+
}, ua = (e, t, n) => {
|
|
1280
|
+
if (t.tagName === "PRE") return null;
|
|
1281
|
+
for (let { pattern: r, kind: i } of ia) {
|
|
1282
|
+
let a = n.text.match(r);
|
|
1283
|
+
if (!a) continue;
|
|
1284
|
+
let o = i === "bulletList" || i === "orderedList" || i === "taskList";
|
|
1285
|
+
return i === "heading" && (t.tagName !== "P" || Y(t, e) !== null) || o && or(e, t) === i ? null : () => {
|
|
1286
|
+
ca(n, 0, n.text.length)?.deleteContents(), G(t);
|
|
1287
|
+
let r = document.createRange();
|
|
1288
|
+
r.selectNodeContents(t);
|
|
1289
|
+
let o = t.parentNode, s = o ? Array.prototype.indexOf.call(o.childNodes, t) : -1, c = t;
|
|
1290
|
+
if (i === "heading") c = Ht(t, `h${a[1]?.length ?? 1}`);
|
|
1291
|
+
else if (i === "blockquote") Qn(e, r);
|
|
1292
|
+
else if (i === "codeBlock") {
|
|
1293
|
+
Zn(e, r);
|
|
1294
|
+
let t = o?.childNodes[s], n = t instanceof HTMLElement ? t.querySelector("code") ?? t : null;
|
|
1295
|
+
return { caret: n ? ji(n) : null };
|
|
1296
|
+
} else if (i === "rule") t.before(W("hr"));
|
|
1297
|
+
else {
|
|
1298
|
+
_r(e, r, i);
|
|
1299
|
+
let n = Y(t, e);
|
|
1300
|
+
i === "taskList" && a[1]?.toLowerCase() === "x" && n && yr(n);
|
|
1301
|
+
let o = Number.parseInt(a[1] ?? "", 10);
|
|
1302
|
+
i === "orderedList" && o > 1 && n?.parentElement?.setAttribute("start", String(o));
|
|
1303
|
+
}
|
|
1304
|
+
return { caret: c.isConnected ? ji(c) : null };
|
|
1305
|
+
};
|
|
1306
|
+
}
|
|
1307
|
+
return null;
|
|
1308
|
+
}, da = (e, t) => {
|
|
1309
|
+
for (let { pattern: n, mark: r } of na) {
|
|
1310
|
+
let i = t.text.match(n);
|
|
1311
|
+
if (!i || i.index === void 0) continue;
|
|
1312
|
+
let a = i.length === 3, o = a ? i[1] ?? "" : ra[r] ?? "", s = (a ? i[2] : i[1]) ?? "", c = i.index, l = c + o.length, u = l + s.length;
|
|
1313
|
+
return () => {
|
|
1314
|
+
ca(t, u, t.text.length)?.deleteContents(), ca(t, c, l)?.deleteContents();
|
|
1315
|
+
let n = U(t.segments[0]?.node, e), i = t.segments.at(-1)?.node;
|
|
1316
|
+
if (!n || !i) return { caret: null };
|
|
1317
|
+
let a = document.createRange();
|
|
1318
|
+
a.setStart(i, i.length);
|
|
1319
|
+
let o = sa(n, a), d = ca(o, o.text.length - s.length, o.text.length);
|
|
1320
|
+
if (!d) return { caret: null };
|
|
1321
|
+
r === "highlight" ? Vr(e, d, br) : zr(e, d, r);
|
|
1322
|
+
let f = r === "highlight" ? {
|
|
1323
|
+
marks: {},
|
|
1324
|
+
styles: {},
|
|
1325
|
+
highlight: null
|
|
1326
|
+
} : {
|
|
1327
|
+
marks: { [r]: !1 },
|
|
1328
|
+
styles: {}
|
|
1329
|
+
};
|
|
1330
|
+
return {
|
|
1331
|
+
caret: {
|
|
1332
|
+
node: d.endContainer,
|
|
1333
|
+
offset: d.endOffset
|
|
1334
|
+
},
|
|
1335
|
+
pending: f
|
|
1336
|
+
};
|
|
1337
|
+
};
|
|
1338
|
+
}
|
|
1339
|
+
return null;
|
|
1340
|
+
}, fa = (e, t) => {
|
|
1341
|
+
let { text: n } = e;
|
|
1342
|
+
if (t === "\"" || t === "'") {
|
|
1343
|
+
let r = n.slice(-2, -1), i = r === "" || oa.test(r), a = t === "\"" ? i ? "“" : "”" : i ? "‘" : "’";
|
|
1344
|
+
return () => ({ caret: la(e, n.length - 1, n.length, a) });
|
|
1345
|
+
}
|
|
1346
|
+
for (let [t, r] of ta) {
|
|
1347
|
+
let i = n.match(t);
|
|
1348
|
+
if (!i || i.index === void 0) continue;
|
|
1349
|
+
let a = i.index, o = a + i[0].length;
|
|
1350
|
+
return () => ({ caret: la(e, a, o, r) });
|
|
1351
|
+
}
|
|
1352
|
+
return null;
|
|
1353
|
+
}, pa = (e, t, n) => {
|
|
1354
|
+
let r = t.text.match(aa);
|
|
1355
|
+
if (!r?.[1] || kr(n.startContainer, e)) return null;
|
|
1356
|
+
let i = r[1], a = t.text.length - 1 - i.length;
|
|
1357
|
+
return () => {
|
|
1358
|
+
let n = ca(t, a, a + i.length);
|
|
1359
|
+
return n && Hr(e, n, i.startsWith("www.") ? `https://${i}` : i, null), { caret: null };
|
|
1360
|
+
};
|
|
1361
|
+
}, ma = (e, t, n) => {
|
|
1362
|
+
let r = U(t.startContainer, e);
|
|
1363
|
+
if (!r || !t.collapsed || It(t.startContainer, e, "CODE")) return null;
|
|
1364
|
+
let i = sa(r, t);
|
|
1365
|
+
return i.text ? ($i.has(n) ? ua(e, r, i) : null) ?? (ea.includes(n) ? da(e, i) : null) ?? (n === " " ? pa(e, i, t) : null) ?? fa(i, n) : null;
|
|
1366
|
+
}, ha = typeof navigator < "u" && /Mac|iPhone|iPad/.test(navigator.userAgent), ga = {
|
|
1367
|
+
KeyZ: "redo",
|
|
1368
|
+
KeyS: "strike",
|
|
1369
|
+
KeyL: "alignLeft",
|
|
1370
|
+
KeyE: "alignCenter",
|
|
1371
|
+
KeyR: "alignRight",
|
|
1372
|
+
KeyJ: "alignJustify",
|
|
1373
|
+
Digit7: "orderedList",
|
|
1374
|
+
Digit8: "bulletList",
|
|
1375
|
+
Digit9: "taskList",
|
|
1376
|
+
KeyB: "blockquote",
|
|
1377
|
+
KeyH: "highlight"
|
|
1378
|
+
}, _a = {
|
|
1379
|
+
KeyZ: "undo",
|
|
1380
|
+
KeyY: "redo",
|
|
1381
|
+
KeyB: "bold",
|
|
1382
|
+
KeyI: "italic",
|
|
1383
|
+
KeyU: "underline",
|
|
1384
|
+
KeyE: "code",
|
|
1385
|
+
Comma: "subscript",
|
|
1386
|
+
Period: "superscript",
|
|
1387
|
+
Enter: "pageBreak",
|
|
1388
|
+
NumpadEnter: "pageBreak"
|
|
1389
|
+
}, va = "Digit0", ya = "KeyC", ba = /^Digit([1-6])$/, xa = (e) => {
|
|
1390
|
+
if (!(ha ? e.metaKey && !e.ctrlKey : e.ctrlKey && !e.metaKey) || e.getModifierState?.("AltGraph")) return null;
|
|
1391
|
+
let { code: t, shiftKey: n, altKey: r } = e;
|
|
1392
|
+
if (!r) return (n ? ga[t] : _a[t]) ?? null;
|
|
1393
|
+
if (n) return null;
|
|
1394
|
+
if (t === va) return "paragraph";
|
|
1395
|
+
if (t === ya) return "codeBlock";
|
|
1396
|
+
let i = ba.exec(t)?.[1];
|
|
1397
|
+
return i ? `heading${i}` : null;
|
|
1398
|
+
}, Sa = "doc-search", Ca = "doc-search-current", wa = String.raw`(?<![\p{L}\p{N}_'‘’ʻ])`, Ta = String.raw`(?![\p{L}\p{N}_'‘’ʻ])`, Ea = () => typeof CSS < "u" && "highlights" in CSS && typeof Highlight < "u", Da = (e, t, n) => {
|
|
1399
|
+
let r = e.find((e) => t >= e.start && t < e.start + e.node.length), i = e.find((e) => n > e.start && n <= e.start + e.node.length);
|
|
1400
|
+
if (!r || !i) return null;
|
|
1401
|
+
let a = document.createRange();
|
|
1402
|
+
return a.setStart(r.node, t - r.start), a.setEnd(i.node, n - i.start), a;
|
|
1403
|
+
}, Oa = class {
|
|
1404
|
+
root;
|
|
1405
|
+
onChange;
|
|
1406
|
+
term = "";
|
|
1407
|
+
options = {
|
|
1408
|
+
caseSensitive: !1,
|
|
1409
|
+
wholeWord: !1
|
|
1410
|
+
};
|
|
1411
|
+
results = [];
|
|
1412
|
+
index = -1;
|
|
1413
|
+
constructor(e, t) {
|
|
1414
|
+
this.root = e, this.onChange = t;
|
|
1415
|
+
}
|
|
1416
|
+
get state() {
|
|
1417
|
+
return {
|
|
1418
|
+
total: this.results.length,
|
|
1419
|
+
current: this.index + 1
|
|
1420
|
+
};
|
|
1421
|
+
}
|
|
1422
|
+
get active() {
|
|
1423
|
+
return this.term !== "";
|
|
1424
|
+
}
|
|
1425
|
+
setQuery(e, t = {}) {
|
|
1426
|
+
this.term = e, this.options = {
|
|
1427
|
+
...this.options,
|
|
1428
|
+
...t
|
|
1429
|
+
}, this.refresh(!0);
|
|
1430
|
+
}
|
|
1431
|
+
refresh(e = !1) {
|
|
1432
|
+
this.results = this.term ? this.find() : [], this.index = e || this.index < 0 ? this.results.length ? 0 : -1 : Math.min(this.index, this.results.length - 1), this.paint(), this.onChange(this.state);
|
|
1433
|
+
}
|
|
1434
|
+
next() {
|
|
1435
|
+
this.results.length && (this.index = (this.index + 1) % this.results.length, this.reveal());
|
|
1436
|
+
}
|
|
1437
|
+
previous() {
|
|
1438
|
+
this.results.length && (this.index = (this.index - 1 + this.results.length) % this.results.length, this.reveal());
|
|
1439
|
+
}
|
|
1440
|
+
replaceCurrent(e) {
|
|
1441
|
+
let t = this.results[this.index];
|
|
1442
|
+
return !t || t.collapsed ? !1 : (this.replaceRange(t, e), this.refresh(), !0);
|
|
1443
|
+
}
|
|
1444
|
+
replaceAll(e) {
|
|
1445
|
+
let t = [...this.results].reverse();
|
|
1446
|
+
for (let n of t) this.replaceRange(n, e);
|
|
1447
|
+
return this.refresh(!0), t.length;
|
|
1448
|
+
}
|
|
1449
|
+
clear() {
|
|
1450
|
+
this.term = "", this.results = [], this.index = -1, Ea() && (CSS.highlights.delete(Sa), CSS.highlights.delete(Ca)), this.onChange(this.state);
|
|
1451
|
+
}
|
|
1452
|
+
find() {
|
|
1453
|
+
let e = Qt(this.term), t = this.options.wholeWord ? `${wa}${e}${Ta}` : e, n = new RegExp(t, this.options.caseSensitive ? "gu" : "giu"), r = [];
|
|
1454
|
+
for (let e of Kt(this.root)) {
|
|
1455
|
+
let t = [], i = "", a = document.createTreeWalker(e, NodeFilter.SHOW_TEXT | NodeFilter.SHOW_ELEMENT);
|
|
1456
|
+
for (let e = a.nextNode(); e; e = a.nextNode()) H(e) ? (t.push({
|
|
1457
|
+
node: e,
|
|
1458
|
+
start: i.length
|
|
1459
|
+
}), i += e.data) : Nt(e) && (i += "\n");
|
|
1460
|
+
if (i) for (let e of i.matchAll(n)) {
|
|
1461
|
+
if (!e[0]) continue;
|
|
1462
|
+
let n = Da(t, e.index, e.index + e[0].length);
|
|
1463
|
+
n && r.push(n);
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1466
|
+
return r;
|
|
1467
|
+
}
|
|
1468
|
+
paint() {
|
|
1469
|
+
if (!Ea()) return;
|
|
1470
|
+
let e = this.results[this.index], t = new Highlight();
|
|
1471
|
+
for (let n of this.results) n !== e && t.add(n);
|
|
1472
|
+
CSS.highlights.set(Sa, t), e ? CSS.highlights.set(Ca, new Highlight(e)) : CSS.highlights.delete(Ca);
|
|
1473
|
+
}
|
|
1474
|
+
reveal() {
|
|
1475
|
+
this.paint(), this.results[this.index]?.startContainer.parentElement?.scrollIntoView({
|
|
1476
|
+
block: "center",
|
|
1477
|
+
inline: "nearest"
|
|
1478
|
+
}), this.onChange(this.state);
|
|
1479
|
+
}
|
|
1480
|
+
replaceRange(e, t) {
|
|
1481
|
+
e.deleteContents(), t && e.insertNode(document.createTextNode(t));
|
|
1482
|
+
}
|
|
1483
|
+
}, ka = 40, Aa = 80, Z = (e) => Math.max(1, e), ja = (e) => Array.from(e.querySelectorAll(":scope > tbody > tr")), Q = (e) => {
|
|
1484
|
+
let t = ja(e), n = t.map(() => []), r = /* @__PURE__ */ new Map();
|
|
1485
|
+
return t.forEach((e, i) => {
|
|
1486
|
+
let a = n[i] ?? [], o = 0;
|
|
1487
|
+
for (let s of Array.from(e.cells)) {
|
|
1488
|
+
for (; a[o];) o += 1;
|
|
1489
|
+
r.set(s, {
|
|
1490
|
+
row: i,
|
|
1491
|
+
col: o
|
|
1492
|
+
});
|
|
1493
|
+
for (let e = 0; e < Z(s.rowSpan) && i + e < t.length; e += 1) {
|
|
1494
|
+
let t = n[i + e];
|
|
1495
|
+
for (let e = 0; e < Z(s.colSpan); e += 1) t && (t[o + e] = s);
|
|
1496
|
+
}
|
|
1497
|
+
o += Z(s.colSpan);
|
|
1498
|
+
}
|
|
1499
|
+
}), {
|
|
1500
|
+
rows: t,
|
|
1501
|
+
grid: n,
|
|
1502
|
+
positions: r,
|
|
1503
|
+
width: Math.max(0, ...n.map((e) => e.length))
|
|
1504
|
+
};
|
|
1505
|
+
}, Ma = (e, t, n) => {
|
|
1506
|
+
n > 1 ? e.setAttribute(t, String(n)) : e.removeAttribute(t);
|
|
1507
|
+
}, Na = (e) => W(e === "TH" ? "th" : "td", {}, [Rt()]), Pa = (e, t) => (e.grid[t] ?? []).every((e) => e === void 0 || e.tagName === "TH"), Fa = (e, t, n) => {
|
|
1508
|
+
let r = W("tbody");
|
|
1509
|
+
for (let i = 0; i < e; i += 1) {
|
|
1510
|
+
let e = W("tr");
|
|
1511
|
+
for (let r = 0; r < t; r += 1) e.append(Na(n && i === 0 ? "TH" : "TD"));
|
|
1512
|
+
r.append(e);
|
|
1513
|
+
}
|
|
1514
|
+
return W("table", {}, [r]);
|
|
1515
|
+
}, Ia = (e, t, n, r) => {
|
|
1516
|
+
let i = e.rows[t];
|
|
1517
|
+
for (let a = n; a < e.width; a += 1) {
|
|
1518
|
+
let n = e.grid[t]?.[a];
|
|
1519
|
+
if (n && n !== r && n.parentElement === i && e.positions.get(n)?.col === a) return n;
|
|
1520
|
+
}
|
|
1521
|
+
return null;
|
|
1522
|
+
}, La = (e, t) => {
|
|
1523
|
+
let n = e.closest("table");
|
|
1524
|
+
if (!n) return;
|
|
1525
|
+
let r = Q(n), i = r.positions.get(e);
|
|
1526
|
+
if (!i) return;
|
|
1527
|
+
let a = t === "before" ? i.row : i.row + Z(e.rowSpan), o = W("tr"), s = /* @__PURE__ */ new Set();
|
|
1528
|
+
for (let e = 0; e < r.width; e += 1) {
|
|
1529
|
+
let t = r.grid[a - 1]?.[e], n = r.grid[a]?.[e];
|
|
1530
|
+
if (t && t === n) {
|
|
1531
|
+
s.has(t) || Ma(t, "rowspan", t.rowSpan + 1), s.add(t);
|
|
1532
|
+
continue;
|
|
1533
|
+
}
|
|
1534
|
+
let c = r.grid[i.row]?.[e]?.tagName === "TH" && !Pa(r, i.row);
|
|
1535
|
+
o.append(Na(c ? "TH" : "TD"));
|
|
1536
|
+
}
|
|
1537
|
+
let c = r.rows[t === "before" ? i.row : a - 1];
|
|
1538
|
+
t === "before" ? c?.before(o) : c?.after(o);
|
|
1539
|
+
}, Ra = (e, t) => {
|
|
1540
|
+
let n = Q(e), r = n.rows[t];
|
|
1541
|
+
if (!r) return;
|
|
1542
|
+
let i = /* @__PURE__ */ new Set();
|
|
1543
|
+
for (let e = 0; e < n.width; e += 1) {
|
|
1544
|
+
let r = n.grid[t]?.[e];
|
|
1545
|
+
if (!r || i.has(r) || (i.add(r), r.rowSpan <= 1)) continue;
|
|
1546
|
+
let a = n.positions.get(r);
|
|
1547
|
+
if (Ma(r, "rowspan", r.rowSpan - 1), a?.row === t) {
|
|
1548
|
+
let e = n.rows[t + 1], i = Ia(n, t + 1, a.col + Z(r.colSpan));
|
|
1549
|
+
e?.insertBefore(r, i);
|
|
1550
|
+
}
|
|
1551
|
+
}
|
|
1552
|
+
r.remove();
|
|
1553
|
+
}, za = (e) => {
|
|
1554
|
+
let t = e.closest("table"), n = t ? Q(t).positions.get(e) : void 0;
|
|
1555
|
+
if (t && n) {
|
|
1556
|
+
for (let r = n.row + Z(e.rowSpan) - 1; r >= n.row; --r) Ra(t, r);
|
|
1557
|
+
ja(t).length || t.remove();
|
|
1558
|
+
}
|
|
1559
|
+
}, Ba = (e, t) => {
|
|
1560
|
+
let n = e.closest("table");
|
|
1561
|
+
if (!n) return;
|
|
1562
|
+
let r = Q(n), i = r.positions.get(e);
|
|
1563
|
+
if (!i) return;
|
|
1564
|
+
let a = t === "before" ? i.col : i.col + Z(e.colSpan), o = /* @__PURE__ */ new Set();
|
|
1565
|
+
r.rows.forEach((e, t) => {
|
|
1566
|
+
let n = r.grid[t]?.[a - 1], i = r.grid[t]?.[a];
|
|
1567
|
+
if (n && n === i) {
|
|
1568
|
+
o.has(n) || Ma(n, "colspan", n.colSpan + 1), o.add(n);
|
|
1569
|
+
return;
|
|
1570
|
+
}
|
|
1571
|
+
let s = Ia(r, t, a);
|
|
1572
|
+
e.insertBefore(Na(Pa(r, t) ? "TH" : "TD"), s);
|
|
1573
|
+
});
|
|
1574
|
+
let s = n.querySelectorAll(":scope > colgroup > col");
|
|
1575
|
+
if (!s.length) return;
|
|
1576
|
+
let c = W("col", { style: `width: ${Aa}px` });
|
|
1577
|
+
n.querySelector(":scope > colgroup")?.insertBefore(c, s[a] ?? null);
|
|
1578
|
+
}, Va = (e, t) => {
|
|
1579
|
+
let n = Q(e), r = /* @__PURE__ */ new Set();
|
|
1580
|
+
n.rows.forEach((e, i) => {
|
|
1581
|
+
let a = n.grid[i]?.[t];
|
|
1582
|
+
a && !r.has(a) && (r.add(a), a.colSpan > 1 ? Ma(a, "colspan", a.colSpan - 1) : a.remove());
|
|
1583
|
+
}), e.querySelectorAll(":scope > colgroup > col")[t]?.remove();
|
|
1584
|
+
for (let t of ja(e)) t.cells.length || t.remove();
|
|
1585
|
+
}, Ha = (e) => {
|
|
1586
|
+
let t = e.closest("table"), n = t ? Q(t).positions.get(e) : void 0;
|
|
1587
|
+
if (t && n) {
|
|
1588
|
+
for (let r = n.col + Z(e.colSpan) - 1; r >= n.col; --r) Va(t, r);
|
|
1589
|
+
t.querySelector("td, th") || t.remove();
|
|
1590
|
+
}
|
|
1591
|
+
}, Ua = (e, t) => {
|
|
1592
|
+
let n = e.closest("table");
|
|
1593
|
+
if (!n || t.closest("table") !== n) return null;
|
|
1594
|
+
let r = Q(n), i = r.positions.get(e), a = r.positions.get(t);
|
|
1595
|
+
if (!i || !a) return null;
|
|
1596
|
+
let o = {
|
|
1597
|
+
table: n,
|
|
1598
|
+
top: Math.min(i.row, a.row),
|
|
1599
|
+
left: Math.min(i.col, a.col),
|
|
1600
|
+
bottom: Math.max(i.row + e.rowSpan - 1, a.row + t.rowSpan - 1),
|
|
1601
|
+
right: Math.max(i.col + e.colSpan - 1, a.col + t.colSpan - 1)
|
|
1602
|
+
}, s = !0;
|
|
1603
|
+
for (; s;) {
|
|
1604
|
+
s = !1;
|
|
1605
|
+
for (let e = o.top; e <= o.bottom; e += 1) for (let t = o.left; t <= o.right; t += 1) {
|
|
1606
|
+
let n = r.grid[e]?.[t], i = n ? r.positions.get(n) : void 0;
|
|
1607
|
+
if (!n || !i) continue;
|
|
1608
|
+
let a = i.row + Z(n.rowSpan) - 1, c = i.col + Z(n.colSpan) - 1;
|
|
1609
|
+
(i.row < o.top || i.col < o.left || a > o.bottom || c > o.right) && (o.top = Math.min(o.top, i.row), o.left = Math.min(o.left, i.col), o.bottom = Math.max(o.bottom, a), o.right = Math.max(o.right, c), s = !0);
|
|
1610
|
+
}
|
|
1611
|
+
}
|
|
1612
|
+
return o;
|
|
1613
|
+
}, Wa = (e) => {
|
|
1614
|
+
let t = Q(e.table), n = /* @__PURE__ */ new Set();
|
|
1615
|
+
for (let r = e.top; r <= e.bottom; r += 1) for (let i = e.left; i <= e.right; i += 1) {
|
|
1616
|
+
let e = t.grid[r]?.[i];
|
|
1617
|
+
e && n.add(e);
|
|
1618
|
+
}
|
|
1619
|
+
return [...n];
|
|
1620
|
+
}, Ga = (e) => e !== null && Wa(e).length > 1, Ka = (e) => {
|
|
1621
|
+
let [t, ...n] = Wa(e);
|
|
1622
|
+
if (!t || !n.length) return null;
|
|
1623
|
+
for (let e of n) {
|
|
1624
|
+
let n = Array.from(e.childNodes).filter((e) => !(e instanceof HTMLElement && e.tagName === "P" && (e.textContent ?? "") === ""));
|
|
1625
|
+
t.append(...n), e.remove();
|
|
1626
|
+
}
|
|
1627
|
+
Ma(t, "colspan", e.right - e.left + 1), Ma(t, "rowspan", e.bottom - e.top + 1);
|
|
1628
|
+
for (let t of ja(e.table)) {
|
|
1629
|
+
if (t.cells.length) continue;
|
|
1630
|
+
let n = Q(e.table), r = n.rows.indexOf(t);
|
|
1631
|
+
for (let e of new Set(n.grid[r] ?? [])) e && Ma(e, "rowspan", e.rowSpan - 1);
|
|
1632
|
+
t.remove();
|
|
1633
|
+
}
|
|
1634
|
+
return t;
|
|
1635
|
+
}, qa = (e) => e !== null && (e.colSpan > 1 || e.rowSpan > 1), Ja = (e) => {
|
|
1636
|
+
let t = e.closest("table");
|
|
1637
|
+
if (!t || !qa(e)) return;
|
|
1638
|
+
let n = Q(t), r = n.positions.get(e);
|
|
1639
|
+
if (!r) return;
|
|
1640
|
+
let i = Z(e.rowSpan), a = Z(e.colSpan);
|
|
1641
|
+
Ma(e, "colspan", 1), Ma(e, "rowspan", 1);
|
|
1642
|
+
for (let t = r.row; t < r.row + i; t += 1) {
|
|
1643
|
+
let i = n.rows[t], o = Ia(n, t, r.col + a, e);
|
|
1644
|
+
for (let n = r.col; n < r.col + a; n += 1) (t !== r.row || n !== r.col) && i?.insertBefore(Na(e.tagName), o);
|
|
1645
|
+
}
|
|
1646
|
+
}, Ya = (e) => {
|
|
1647
|
+
let t = ja(e)[0];
|
|
1648
|
+
if (!t) return;
|
|
1649
|
+
let n = Array.from(t.cells), r = n.every((e) => e.tagName === "TH");
|
|
1650
|
+
for (let e of n) Ht(e, r ? "td" : "th");
|
|
1651
|
+
}, Xa = (e) => Array.from(e.querySelectorAll(":scope > tbody > tr > td, :scope > tbody > tr > th")), Za = (e, t) => {
|
|
1652
|
+
let n = e.closest("table");
|
|
1653
|
+
if (!n) return null;
|
|
1654
|
+
let r = Xa(n), i = r[r.indexOf(e) + t];
|
|
1655
|
+
if (i || t < 0) return i ?? null;
|
|
1656
|
+
let a = ja(n).at(-1)?.cells[0];
|
|
1657
|
+
return a ? (La(a, "after"), ja(n).at(-1)?.cells[0] ?? null) : null;
|
|
1658
|
+
}, Qa = (e, t, n) => e.grid.map((e) => e[t]).find((e) => e && e.colSpan === 1)?.offsetWidth || n, $a = (e) => {
|
|
1659
|
+
let t = Q(e), n = e.querySelector(":scope > colgroup");
|
|
1660
|
+
if (n && n.children.length === t.width) return Array.from(n.children);
|
|
1661
|
+
let r = e.offsetWidth / Math.max(1, t.width), i = W("colgroup", {}, Array.from({ length: t.width }, (e, n) => Qa(t, n, r)).map((e) => W("col", { style: `width: ${Math.round(e)}px` })));
|
|
1662
|
+
return n?.remove(), e.prepend(i), Array.from(i.children);
|
|
1663
|
+
}, eo = (e, t) => {
|
|
1664
|
+
let n = e.querySelectorAll(":scope > colgroup > col")[t], r = n ? Number.parseFloat(n.style.width) : 0;
|
|
1665
|
+
if (r) return r;
|
|
1666
|
+
let i = Q(e);
|
|
1667
|
+
return i.grid.map((e) => e[t]).find((e) => e && e.colSpan === 1)?.offsetWidth ?? e.offsetWidth / Math.max(1, i.width);
|
|
1668
|
+
}, to = (e, t, n) => {
|
|
1669
|
+
let r = $a(e), i = r[t];
|
|
1670
|
+
if (!i) return;
|
|
1671
|
+
i.style.width = `${Math.max(ka, Math.round(n))}px`;
|
|
1672
|
+
let a = r.reduce((e, t) => e + (Number.parseFloat(t.style.width) || 0), 0);
|
|
1673
|
+
e.style.width = `${a}px`;
|
|
1674
|
+
}, no = (e, t, n, r) => {
|
|
1675
|
+
let i = t.getBoundingClientRect(), a = Q(e).positions.get(t);
|
|
1676
|
+
return a ? Math.abs(n - i.right) <= r ? a.col + Z(t.colSpan) - 1 : Math.abs(n - i.left) <= r && a.col > 0 ? a.col - 1 : null : null;
|
|
1677
|
+
}, ro = (e, t) => {
|
|
1678
|
+
for (let t of Array.from(e.querySelectorAll(`.${en}`))) t.classList.remove(en), t.classList.length || t.removeAttribute("class");
|
|
1679
|
+
for (let e of t) e.classList.add(en);
|
|
1680
|
+
}, io = /* @__PURE__ */ new Set(["TD", "TH"]), ao = "p, h1, h2, h3, h4, h5, h6, pre", oo = 150, so = "#fef08a", co = 0, lo = 1, uo = [
|
|
1681
|
+
"color",
|
|
1682
|
+
"fontFamily",
|
|
1683
|
+
"fontSize"
|
|
1684
|
+
], fo = (e) => "node" in e, po = class {
|
|
1685
|
+
root;
|
|
1686
|
+
options;
|
|
1687
|
+
history = new Zi();
|
|
1688
|
+
search;
|
|
1689
|
+
listeners = /* @__PURE__ */ new Map();
|
|
1690
|
+
disposers = [];
|
|
1691
|
+
editable;
|
|
1692
|
+
composingText = !1;
|
|
1693
|
+
lastRange = null;
|
|
1694
|
+
pending = null;
|
|
1695
|
+
internalSelectionUntil = 0;
|
|
1696
|
+
cellAnchor = null;
|
|
1697
|
+
cellRect = null;
|
|
1698
|
+
dragRange = null;
|
|
1699
|
+
selectedImageElement = null;
|
|
1700
|
+
constructor(e, t) {
|
|
1701
|
+
this.root = e, this.options = t, this.editable = t.editable, this.search = new Oa(e, (e) => this.emit("search", e)), e.classList.add("doc-content"), e.setAttribute("role", "textbox"), e.setAttribute("aria-multiline", "true"), e.spellcheck = !0, e.contentEditable = String(t.editable), this.setContent(t.content), this.listen(e, "beforeinput", this.onBeforeInput), this.listen(e, "input", this.onInput), this.listen(e, "keydown", this.onKeyDown), this.listen(e, "paste", this.onPaste), this.listen(e, "copy", this.onCopy), this.listen(e, "cut", this.onCut), this.listen(e, "dragstart", this.onDragStart), this.listen(e, "dragend", this.onDragEnd), this.listen(e, "dragover", this.onDragOver), this.listen(e, "drop", this.onDrop), this.listen(e, "mousedown", this.onMouseDown), this.listen(e, "mousemove", this.onMouseMove), this.listen(e, "click", this.onClick), this.listen(e, "compositionstart", this.onCompositionStart), this.listen(e, "compositionend", this.onCompositionEnd), this.listen(e, "focus", () => this.emit("focus", void 0)), this.listen(e, "blur", () => this.emit("blur", void 0)), this.listen(document, "selectionchange", this.onSelectionChange), this.listen(document, "mouseup", () => {
|
|
1702
|
+
this.cellAnchor = null;
|
|
1703
|
+
});
|
|
1704
|
+
}
|
|
1705
|
+
on(e, t) {
|
|
1706
|
+
let n = this.listeners.get(e) ?? /* @__PURE__ */ new Set();
|
|
1707
|
+
return n.add(t), this.listeners.set(e, n), () => n.delete(t);
|
|
1708
|
+
}
|
|
1709
|
+
destroy() {
|
|
1710
|
+
for (let e of this.disposers) e();
|
|
1711
|
+
this.disposers.length = 0, this.listeners.clear(), this.search.clear();
|
|
1712
|
+
}
|
|
1713
|
+
emit(e, t) {
|
|
1714
|
+
for (let n of this.listeners.get(e) ?? []) n(t);
|
|
1715
|
+
}
|
|
1716
|
+
listen(e, t, n) {
|
|
1717
|
+
let r = n;
|
|
1718
|
+
e.addEventListener(t, r), this.disposers.push(() => e.removeEventListener(t, r));
|
|
1719
|
+
}
|
|
1720
|
+
get isEmpty() {
|
|
1721
|
+
return Wn(this.root);
|
|
1722
|
+
}
|
|
1723
|
+
get isEditable() {
|
|
1724
|
+
return this.editable;
|
|
1725
|
+
}
|
|
1726
|
+
get composing() {
|
|
1727
|
+
return this.composingText;
|
|
1728
|
+
}
|
|
1729
|
+
get selectedImage() {
|
|
1730
|
+
return this.selectedImageElement?.isConnected ? this.selectedImageElement : null;
|
|
1731
|
+
}
|
|
1732
|
+
get hasCellSelection() {
|
|
1733
|
+
return this.cellRect !== null;
|
|
1734
|
+
}
|
|
1735
|
+
getHTML() {
|
|
1736
|
+
return Un(this.root);
|
|
1737
|
+
}
|
|
1738
|
+
setContent(e, { addToHistory: t = !1, emitUpdate: n = !1 } = {}) {
|
|
1739
|
+
let r = t ? this.snapshot() : null;
|
|
1740
|
+
this.root.replaceChildren(Vn(e)), Bn(this.root, !0), r ? this.history.record(() => r, "command") : this.history.clear(), this.pending = null, this.selectImage(null), this.clearCellSelection(), this.refresh(n);
|
|
1741
|
+
}
|
|
1742
|
+
setEditable(e) {
|
|
1743
|
+
this.editable = e, this.root.contentEditable = String(e), this.emit("selection", void 0);
|
|
1744
|
+
}
|
|
1745
|
+
getStats() {
|
|
1746
|
+
let e = Kt(this.root).map((e) => e.textContent ?? "");
|
|
1747
|
+
return {
|
|
1748
|
+
characters: e.reduce((e, t) => e + t.length, 0),
|
|
1749
|
+
words: e.join(" ").split(/\s+/).filter(Boolean).length
|
|
1750
|
+
};
|
|
1751
|
+
}
|
|
1752
|
+
getState() {
|
|
1753
|
+
return ei({
|
|
1754
|
+
root: this.root,
|
|
1755
|
+
range: this.currentRange(),
|
|
1756
|
+
pending: this.pending,
|
|
1757
|
+
canUndo: this.editable && this.history.canUndo,
|
|
1758
|
+
canRedo: this.editable && this.history.canRedo
|
|
1759
|
+
});
|
|
1760
|
+
}
|
|
1761
|
+
getSelectedText() {
|
|
1762
|
+
return this.currentRange()?.toString() ?? "";
|
|
1763
|
+
}
|
|
1764
|
+
focus(e) {
|
|
1765
|
+
this.expectInternalSelection(), this.root.focus({ preventScroll: !0 });
|
|
1766
|
+
let t = Kt(this.root), n = t[0], r = t.at(-1);
|
|
1767
|
+
e === "start" && n ? bi(n) : e === "end" && r ? xi(r) : !X(this.root) && this.lastRange?.startContainer.isConnected && _i(this.lastRange);
|
|
1768
|
+
}
|
|
1769
|
+
expectInternalSelection() {
|
|
1770
|
+
this.internalSelectionUntil = performance.now() + oo;
|
|
1771
|
+
}
|
|
1772
|
+
currentRange() {
|
|
1773
|
+
let e = X(this.root);
|
|
1774
|
+
if (e) return e;
|
|
1775
|
+
let t = this.lastRange;
|
|
1776
|
+
return t && this.root.contains(t.startContainer) && this.root.contains(t.endContainer) ? t.cloneRange() : null;
|
|
1777
|
+
}
|
|
1778
|
+
snapshot(e = wi(this.root)) {
|
|
1779
|
+
let t = this.root.cloneNode(!0);
|
|
1780
|
+
return Hn(t, !1), {
|
|
1781
|
+
blocks: Array.from(t.children, (e) => e.outerHTML),
|
|
1782
|
+
bookmark: e
|
|
1783
|
+
};
|
|
1784
|
+
}
|
|
1785
|
+
refresh(e = !0) {
|
|
1786
|
+
this.root.classList.toggle("is-empty", this.isEmpty), this.root.style.setProperty("--doc-placeholder", JSON.stringify(this.options.placeholder())), this.search.active && this.search.refresh(), e && this.emit("update", void 0), this.emit("selection", void 0);
|
|
1787
|
+
}
|
|
1788
|
+
exec(e, t = "command") {
|
|
1789
|
+
if (!this.editable) return !1;
|
|
1790
|
+
let n = this.currentRange();
|
|
1791
|
+
if (!n) return !1;
|
|
1792
|
+
let r = Si(this.root, n), i = t === "command" ? this.snapshot(r) : null;
|
|
1793
|
+
t === "typing" && this.history.record(() => this.snapshot(r), "typing");
|
|
1794
|
+
let a = e(n);
|
|
1795
|
+
return a !== null && (i && this.history.record(() => i, "command"), this.finishEdit(a ?? r), !0);
|
|
1796
|
+
}
|
|
1797
|
+
finishEdit(e) {
|
|
1798
|
+
let t = null;
|
|
1799
|
+
if (!fo(e)) t = e;
|
|
1800
|
+
else if (e.node.isConnected && this.root.contains(e.node)) {
|
|
1801
|
+
let n = document.createRange();
|
|
1802
|
+
n.setStart(e.node, e.offset), t = Si(this.root, n);
|
|
1803
|
+
}
|
|
1804
|
+
Bn(this.root, !0), this.expectInternalSelection(), document.activeElement !== this.root && this.root.focus({ preventScroll: !0 }), t && Ti(this.root, t), this.lastRange = X(this.root)?.cloneRange() ?? this.lastRange, this.refresh(), Ei(this.root);
|
|
1805
|
+
}
|
|
1806
|
+
mutate(e) {
|
|
1807
|
+
if (!this.editable) return;
|
|
1808
|
+
let t = this.snapshot();
|
|
1809
|
+
e(), this.history.record(() => t, "command"), this.refresh();
|
|
1810
|
+
}
|
|
1811
|
+
collapsedAfterDelete(e) {
|
|
1812
|
+
if (e.collapsed) return e;
|
|
1813
|
+
let { anchor: t } = Si(this.root, e);
|
|
1814
|
+
return Ii(this.root, e), Bn(this.root, !0), Ci(this.root, {
|
|
1815
|
+
anchor: t,
|
|
1816
|
+
focus: t
|
|
1817
|
+
});
|
|
1818
|
+
}
|
|
1819
|
+
deleteSelection() {
|
|
1820
|
+
this.exec((e) => {
|
|
1821
|
+
let { anchor: t } = Si(this.root, e);
|
|
1822
|
+
return Ii(this.root, e), {
|
|
1823
|
+
anchor: t,
|
|
1824
|
+
focus: t
|
|
1825
|
+
};
|
|
1826
|
+
});
|
|
1827
|
+
}
|
|
1828
|
+
characterCount() {
|
|
1829
|
+
return Kt(this.root).reduce((e, t) => e + (t.textContent?.length ?? 0), 0);
|
|
1830
|
+
}
|
|
1831
|
+
exceedsLimit(e) {
|
|
1832
|
+
return this.options.maxLength > 0 && this.characterCount() + e > this.options.maxLength;
|
|
1833
|
+
}
|
|
1834
|
+
onSelectionChange = () => {
|
|
1835
|
+
let e = X(this.root);
|
|
1836
|
+
e && (this.lastRange = e.cloneRange(), performance.now() > this.internalSelectionUntil && (this.pending = null, this.history.breakGroup()), this.emit("selection", void 0));
|
|
1837
|
+
};
|
|
1838
|
+
onBeforeInput = (e) => {
|
|
1839
|
+
if (!this.editable) {
|
|
1840
|
+
e.preventDefault();
|
|
1841
|
+
return;
|
|
1842
|
+
}
|
|
1843
|
+
let t = e.inputType;
|
|
1844
|
+
if (t === "historyUndo" || t === "historyRedo") {
|
|
1845
|
+
e.preventDefault(), t === "historyUndo" ? this.undo() : this.redo();
|
|
1846
|
+
return;
|
|
1847
|
+
}
|
|
1848
|
+
if (t.startsWith("format") || t === "insertFromPaste" || t === "insertFromDrop") {
|
|
1849
|
+
e.preventDefault();
|
|
1850
|
+
return;
|
|
1851
|
+
}
|
|
1852
|
+
if (this.cellRect && (t.startsWith("delete") || t.startsWith("insert"))) {
|
|
1853
|
+
e.preventDefault(), t.startsWith("delete") && this.clearSelectedCells();
|
|
1854
|
+
return;
|
|
1855
|
+
}
|
|
1856
|
+
let n = X(this.root);
|
|
1857
|
+
n && !this.composingText && t !== "insertCompositionText" && (this.expectInternalSelection(), t === "insertParagraph" || t === "insertLineBreak" ? (e.preventDefault(), this.splitLine(t === "insertLineBreak")) : t === "insertText" || t === "insertReplacementText" ? this.handleTextInput(e, n) : t.startsWith("delete") && this.handleDeleteInput(e, n));
|
|
1858
|
+
};
|
|
1859
|
+
handleTextInput(e, t) {
|
|
1860
|
+
let n = e.data ?? e.dataTransfer?.getData("text/plain") ?? "";
|
|
1861
|
+
if (this.exceedsLimit(n.length)) {
|
|
1862
|
+
e.preventDefault();
|
|
1863
|
+
return;
|
|
1864
|
+
}
|
|
1865
|
+
let r = U(t.startContainer, this.root);
|
|
1866
|
+
if (e.inputType === "insertText" && (!t.collapsed || this.pending || !r)) {
|
|
1867
|
+
e.preventDefault(), this.insertText(n);
|
|
1868
|
+
return;
|
|
1869
|
+
}
|
|
1870
|
+
this.history.record(() => this.snapshot(), "typing");
|
|
1871
|
+
}
|
|
1872
|
+
handleDeleteInput(e, t) {
|
|
1873
|
+
if (!t.collapsed) {
|
|
1874
|
+
e.preventDefault(), this.deleteSelection();
|
|
1875
|
+
return;
|
|
1876
|
+
}
|
|
1877
|
+
let n = U(t.startContainer, this.root), r = e.inputType.includes("Backward");
|
|
1878
|
+
if (n && (r ? qi(n, t) : Ji(n, t))) {
|
|
1879
|
+
e.preventDefault(), this.exec(() => r ? Bi(this.root, n) : Vi(this.root, n));
|
|
1880
|
+
return;
|
|
1881
|
+
}
|
|
1882
|
+
this.history.record(() => this.snapshot(), "typing");
|
|
1883
|
+
}
|
|
1884
|
+
onInput = (e) => {
|
|
1885
|
+
this.expectInternalSelection(), this.repairStructure();
|
|
1886
|
+
let { inputType: t, data: n } = e;
|
|
1887
|
+
!this.composingText && t === "insertText" && n && this.applyInputRule(n), this.refresh();
|
|
1888
|
+
};
|
|
1889
|
+
repairStructure() {
|
|
1890
|
+
if (!this.root.firstChild || Array.from(this.root.childNodes).some((e) => !_n(e) || e.tagName === "DIV" && e.getAttribute("data-type") !== "page-break")) {
|
|
1891
|
+
let e = wi(this.root);
|
|
1892
|
+
Bn(this.root, !0), e && Ti(this.root, e);
|
|
1893
|
+
return;
|
|
1894
|
+
}
|
|
1895
|
+
let e = U(X(this.root)?.startContainer, this.root);
|
|
1896
|
+
e && e.tagName !== "PRE" && G(e);
|
|
1897
|
+
}
|
|
1898
|
+
applyInputRule(e) {
|
|
1899
|
+
let t = X(this.root), n = t ? ma(this.root, t, e) : null;
|
|
1900
|
+
if (!n) return;
|
|
1901
|
+
let r;
|
|
1902
|
+
this.exec(() => {
|
|
1903
|
+
let e = n();
|
|
1904
|
+
return r = e.pending, e.caret ?? void 0;
|
|
1905
|
+
}), r && (this.pending = r);
|
|
1906
|
+
}
|
|
1907
|
+
onKeyDown = (e) => {
|
|
1908
|
+
if (e.isComposing || this.composingText) return;
|
|
1909
|
+
let t = xa(e);
|
|
1910
|
+
if (t) {
|
|
1911
|
+
e.preventDefault(), this.runKeyCommand(t);
|
|
1912
|
+
return;
|
|
1913
|
+
}
|
|
1914
|
+
if (!this.editable) return;
|
|
1915
|
+
let n = e.key === "Backspace" || e.key === "Delete";
|
|
1916
|
+
n && this.selectedImage ? (e.preventDefault(), this.removeImage(this.selectedImage)) : n && this.cellRect ? (e.preventDefault(), this.clearSelectedCells()) : e.key === "Tab" ? this.handleTab(e) : e.key === "Escape" && (this.clearCellSelection(), this.selectImage(null));
|
|
1917
|
+
};
|
|
1918
|
+
handleTab(e) {
|
|
1919
|
+
let t = X(this.root);
|
|
1920
|
+
if (!t) return;
|
|
1921
|
+
let n = e.shiftKey ? -1 : 1, r = It(t.startContainer, this.root, io);
|
|
1922
|
+
if (r) {
|
|
1923
|
+
e.preventDefault(), this.moveToSiblingCell(r, n);
|
|
1924
|
+
return;
|
|
1925
|
+
}
|
|
1926
|
+
if (Y(t.startContainer, this.root)) {
|
|
1927
|
+
e.preventDefault(), this.exec((e) => hr(this.root, e, n) ? void 0 : null);
|
|
1928
|
+
return;
|
|
1929
|
+
}
|
|
1930
|
+
let i = U(t.startContainer, this.root);
|
|
1931
|
+
if (i && i.tagName !== "PRE") {
|
|
1932
|
+
if (e.preventDefault(), n > 0 && t.collapsed && !qi(i, t)) {
|
|
1933
|
+
this.insertText(" ");
|
|
1934
|
+
return;
|
|
1935
|
+
}
|
|
1936
|
+
this.exec((e) => rr(this.root, e, n) ? void 0 : null);
|
|
1937
|
+
}
|
|
1938
|
+
}
|
|
1939
|
+
moveToSiblingCell(e, t) {
|
|
1940
|
+
let n = e.closest("table")?.querySelector("tr:last-child > :last-child");
|
|
1941
|
+
if (t > 0 && !n?.isSameNode(e)) {
|
|
1942
|
+
let n = Za(e, t)?.querySelector(ao);
|
|
1943
|
+
n && (this.expectInternalSelection(), xi(n));
|
|
1944
|
+
return;
|
|
1945
|
+
}
|
|
1946
|
+
this.exec(() => {
|
|
1947
|
+
let n = Za(e, t)?.querySelector(ao);
|
|
1948
|
+
return n ? Mi(n) : null;
|
|
1949
|
+
});
|
|
1950
|
+
}
|
|
1951
|
+
runKeyCommand(e) {
|
|
1952
|
+
let t = /^heading([1-6])$/.exec(e)?.[1];
|
|
1953
|
+
if (t) {
|
|
1954
|
+
this.setBlockType(`H${t}`);
|
|
1955
|
+
return;
|
|
1956
|
+
}
|
|
1957
|
+
let n = {
|
|
1958
|
+
undo: () => this.undo(),
|
|
1959
|
+
redo: () => this.redo(),
|
|
1960
|
+
highlight: () => this.setHighlight(this.getState().highlight ? null : so),
|
|
1961
|
+
paragraph: () => this.setBlockType("P"),
|
|
1962
|
+
alignLeft: () => this.setTextAlign("left"),
|
|
1963
|
+
alignCenter: () => this.setTextAlign("center"),
|
|
1964
|
+
alignRight: () => this.setTextAlign("right"),
|
|
1965
|
+
alignJustify: () => this.setTextAlign("justify"),
|
|
1966
|
+
bulletList: () => this.toggleList("bulletList"),
|
|
1967
|
+
orderedList: () => this.toggleList("orderedList"),
|
|
1968
|
+
taskList: () => this.toggleList("taskList"),
|
|
1969
|
+
blockquote: () => this.toggleBlockquote(),
|
|
1970
|
+
codeBlock: () => this.toggleCodeBlock(),
|
|
1971
|
+
pageBreak: () => this.insertPageBreak()
|
|
1972
|
+
}[e];
|
|
1973
|
+
n ? n() : this.toggleMark(e);
|
|
1974
|
+
}
|
|
1975
|
+
onPaste = (e) => {
|
|
1976
|
+
if (e.preventDefault(), !this.editable) return;
|
|
1977
|
+
let t = ii(e.clipboardData), n = ai(t);
|
|
1978
|
+
if (n.length && !t.html && !t.text) {
|
|
1979
|
+
this.options.onImageFiles(n);
|
|
1980
|
+
return;
|
|
1981
|
+
}
|
|
1982
|
+
let r = oi(t), i = this.currentRange();
|
|
1983
|
+
if (r && i && !i.collapsed && !It(i.startContainer, this.root, "PRE")) {
|
|
1984
|
+
this.setLink(r, null);
|
|
1985
|
+
return;
|
|
1986
|
+
}
|
|
1987
|
+
this.insertTransfer(t);
|
|
1988
|
+
};
|
|
1989
|
+
insertTransfer(e) {
|
|
1990
|
+
let t = this.currentRange(), n = t && U(t.startContainer, this.root)?.tagName === "PRE" ? si(e.text) : ci(e);
|
|
1991
|
+
n && !this.exceedsLimit(n.textContent?.length ?? 0) && this.exec((e) => Ki(this.root, this.collapsedAfterDelete(e), n) ?? void 0);
|
|
1992
|
+
}
|
|
1993
|
+
onCopy = (e) => {
|
|
1994
|
+
let t = X(this.root);
|
|
1995
|
+
t && !t.collapsed && e.clipboardData && (e.preventDefault(), ui(e.clipboardData, this.root, t));
|
|
1996
|
+
};
|
|
1997
|
+
onCut = (e) => {
|
|
1998
|
+
let t = X(this.root);
|
|
1999
|
+
t && !t.collapsed && e.clipboardData && (e.preventDefault(), ui(e.clipboardData, this.root, t), this.deleteSelection());
|
|
2000
|
+
};
|
|
2001
|
+
onDragStart = (e) => {
|
|
2002
|
+
let t = X(this.root);
|
|
2003
|
+
t && !t.collapsed && e.dataTransfer && (this.dragRange = t.cloneRange(), ui(e.dataTransfer, this.root, t), e.dataTransfer.effectAllowed = "copyMove");
|
|
2004
|
+
};
|
|
2005
|
+
onDragEnd = () => {
|
|
2006
|
+
this.dragRange = null;
|
|
2007
|
+
};
|
|
2008
|
+
onDragOver = (e) => {
|
|
2009
|
+
this.editable && e.preventDefault();
|
|
2010
|
+
};
|
|
2011
|
+
onDrop = (e) => {
|
|
2012
|
+
e.preventDefault();
|
|
2013
|
+
let t = this.dragRange;
|
|
2014
|
+
if (this.dragRange = null, !this.editable) return;
|
|
2015
|
+
let n = di(e.clientX, e.clientY);
|
|
2016
|
+
if (!n || !this.root.contains(n.startContainer)) return;
|
|
2017
|
+
let r = ii(e.dataTransfer), i = ai(r);
|
|
2018
|
+
if (this.expectInternalSelection(), this.root.focus({ preventScroll: !0 }), i.length) {
|
|
2019
|
+
_i(n), this.options.onImageFiles(i);
|
|
2020
|
+
return;
|
|
2021
|
+
}
|
|
2022
|
+
let a = ci(r);
|
|
2023
|
+
if (!a) return;
|
|
2024
|
+
let o = this.snapshot(), s = Si(this.root, n).anchor;
|
|
2025
|
+
if (t && !t.collapsed && !e.ctrlKey && this.root.contains(t.startContainer)) {
|
|
2026
|
+
let e = Si(this.root, t);
|
|
2027
|
+
if (s > e.anchor && s < e.focus) return;
|
|
2028
|
+
Ii(this.root, t), Bn(this.root, !0), s >= e.focus && (s -= e.focus - e.anchor);
|
|
2029
|
+
}
|
|
2030
|
+
let c = Ci(this.root, {
|
|
2031
|
+
anchor: s,
|
|
2032
|
+
focus: s
|
|
2033
|
+
}), l = Ki(this.root, c, a);
|
|
2034
|
+
this.history.record(() => o, "command"), this.finishEdit(l ?? {
|
|
2035
|
+
anchor: s,
|
|
2036
|
+
focus: s
|
|
2037
|
+
});
|
|
2038
|
+
};
|
|
2039
|
+
onMouseDown = (e) => {
|
|
2040
|
+
let t = e.target;
|
|
2041
|
+
if (this.clearCellSelection(), t.tagName === "IMG" && this.root.contains(t)) {
|
|
2042
|
+
this.selectImage(t);
|
|
2043
|
+
let e = document.createRange();
|
|
2044
|
+
e.selectNode(t), this.expectInternalSelection(), _i(e);
|
|
2045
|
+
} else this.selectImage(null);
|
|
2046
|
+
this.cellAnchor = e.button === co ? It(t, this.root, io) : null;
|
|
2047
|
+
};
|
|
2048
|
+
onMouseMove = (e) => {
|
|
2049
|
+
if (!this.cellAnchor || !(e.buttons & lo)) return;
|
|
2050
|
+
let t = It(e.target, this.root, io);
|
|
2051
|
+
if (!t || t === this.cellAnchor) return;
|
|
2052
|
+
let n = Ua(this.cellAnchor, t);
|
|
2053
|
+
n && (this.cellRect = n, ro(this.root, Wa(n)), this.root.classList.add("has-cell-selection"), this.emit("selection", void 0));
|
|
2054
|
+
};
|
|
2055
|
+
onClick = (e) => {
|
|
2056
|
+
let t = e.target;
|
|
2057
|
+
if (t instanceof HTMLInputElement && t.type === "checkbox") {
|
|
2058
|
+
let n = t.closest("li[data-type=\"taskItem\"]");
|
|
2059
|
+
if (!this.editable || !n || !this.root.contains(n)) {
|
|
2060
|
+
e.preventDefault();
|
|
2061
|
+
return;
|
|
2062
|
+
}
|
|
2063
|
+
let r = t.checked;
|
|
2064
|
+
this.mutate(() => {
|
|
2065
|
+
n.setAttribute("data-checked", String(r)), t.toggleAttribute("checked", r);
|
|
2066
|
+
});
|
|
2067
|
+
return;
|
|
2068
|
+
}
|
|
2069
|
+
let n = t.closest("a");
|
|
2070
|
+
n && this.root.contains(n) && (e.ctrlKey || e.metaKey) && (e.preventDefault(), window.open(n.href, "_blank", "noopener,noreferrer"));
|
|
2071
|
+
};
|
|
2072
|
+
onCompositionStart = () => {
|
|
2073
|
+
let e = X(this.root);
|
|
2074
|
+
e && !e.collapsed ? this.deleteSelection() : this.history.record(() => this.snapshot(), "typing"), this.composingText = !0, this.emit("composition", !0);
|
|
2075
|
+
};
|
|
2076
|
+
onCompositionEnd = () => {
|
|
2077
|
+
this.composingText = !1, this.repairStructure(), this.refresh(), this.emit("composition", !1);
|
|
2078
|
+
};
|
|
2079
|
+
undo() {
|
|
2080
|
+
if (!this.editable) return;
|
|
2081
|
+
let e = this.history.undo(this.snapshot());
|
|
2082
|
+
e && this.restoreSnapshot(e);
|
|
2083
|
+
}
|
|
2084
|
+
redo() {
|
|
2085
|
+
if (!this.editable) return;
|
|
2086
|
+
let e = this.history.redo(this.snapshot());
|
|
2087
|
+
e && this.restoreSnapshot(e);
|
|
2088
|
+
}
|
|
2089
|
+
restoreSnapshot(e) {
|
|
2090
|
+
this.root.innerHTML = e.blocks.join(""), this.pending = null, this.selectImage(null), this.clearCellSelection(), this.expectInternalSelection(), this.root.focus({ preventScroll: !0 }), e.bookmark && Ti(this.root, e.bookmark), this.refresh(), Ei(this.root);
|
|
2091
|
+
}
|
|
2092
|
+
insertText(e) {
|
|
2093
|
+
if (this.exceedsLimit(e.length)) return;
|
|
2094
|
+
let t = this.pending;
|
|
2095
|
+
this.exec((n) => {
|
|
2096
|
+
let r = this.collapsedAfterDelete(n);
|
|
2097
|
+
if (t && U(r.startContainer, this.root)) {
|
|
2098
|
+
let { anchor: n } = Si(this.root, r);
|
|
2099
|
+
return Jr(this.root, r, e, t), {
|
|
2100
|
+
anchor: n + e.length,
|
|
2101
|
+
focus: n + e.length
|
|
2102
|
+
};
|
|
2103
|
+
}
|
|
2104
|
+
return Gi(this.root, r, e);
|
|
2105
|
+
}, "typing"), this.pending = null;
|
|
2106
|
+
}
|
|
2107
|
+
captureFormat(e) {
|
|
2108
|
+
let t = e.startContainer, n = Object.fromEntries(Object.entries(Gr(this.root, t)).filter(([, e]) => e)), r = Object.fromEntries(uo.map((e) => [e, Kr(this.root, t, e)]).filter(([, e]) => e)), i = qr(this.root, t);
|
|
2109
|
+
return !Object.keys(n).length && !Object.keys(r).length && !i ? null : {
|
|
2110
|
+
marks: n,
|
|
2111
|
+
styles: r,
|
|
2112
|
+
...i ? { highlight: i } : {}
|
|
2113
|
+
};
|
|
2114
|
+
}
|
|
2115
|
+
splitLine(e) {
|
|
2116
|
+
let t = this.currentRange(), n = t ? this.pending ?? this.captureFormat(t) : null;
|
|
2117
|
+
this.exec((t) => {
|
|
2118
|
+
let n = this.collapsedAfterDelete(t);
|
|
2119
|
+
return (e ? Wi : Ui)(this.root, n);
|
|
2120
|
+
});
|
|
2121
|
+
let r = U(X(this.root)?.startContainer, this.root);
|
|
2122
|
+
n && r && Bt(r) && (this.pending = n);
|
|
2123
|
+
}
|
|
2124
|
+
toggleMark(e) {
|
|
2125
|
+
let t = this.currentRange();
|
|
2126
|
+
if (t && this.editable) {
|
|
2127
|
+
if (t.collapsed) {
|
|
2128
|
+
let t = this.getState()[e];
|
|
2129
|
+
this.setPending({ marks: {
|
|
2130
|
+
...this.pending?.marks,
|
|
2131
|
+
[e]: !t
|
|
2132
|
+
} });
|
|
2133
|
+
return;
|
|
2134
|
+
}
|
|
2135
|
+
this.exec((t) => {
|
|
2136
|
+
zr(this.root, t, e);
|
|
2137
|
+
});
|
|
2138
|
+
}
|
|
2139
|
+
}
|
|
2140
|
+
setTextStyle(e, t) {
|
|
2141
|
+
let n = this.currentRange();
|
|
2142
|
+
if (n && this.editable) {
|
|
2143
|
+
if (n.collapsed) {
|
|
2144
|
+
this.setPending({ styles: {
|
|
2145
|
+
...this.pending?.styles,
|
|
2146
|
+
[e]: t
|
|
2147
|
+
} });
|
|
2148
|
+
return;
|
|
2149
|
+
}
|
|
2150
|
+
this.exec((n) => {
|
|
2151
|
+
Br(this.root, n, e, t);
|
|
2152
|
+
});
|
|
2153
|
+
}
|
|
2154
|
+
}
|
|
2155
|
+
setHighlight(e) {
|
|
2156
|
+
let t = this.currentRange();
|
|
2157
|
+
if (t && this.editable) {
|
|
2158
|
+
if (t.collapsed) {
|
|
2159
|
+
this.setPending({ highlight: e });
|
|
2160
|
+
return;
|
|
2161
|
+
}
|
|
2162
|
+
this.exec((t) => {
|
|
2163
|
+
Vr(this.root, t, e);
|
|
2164
|
+
});
|
|
2165
|
+
}
|
|
2166
|
+
}
|
|
2167
|
+
setPending(e) {
|
|
2168
|
+
this.pending = {
|
|
2169
|
+
marks: {},
|
|
2170
|
+
styles: {},
|
|
2171
|
+
...this.pending,
|
|
2172
|
+
...e
|
|
2173
|
+
}, this.focus(), this.emit("selection", void 0);
|
|
2174
|
+
}
|
|
2175
|
+
clearFormatting() {
|
|
2176
|
+
this.exec((e) => {
|
|
2177
|
+
let t = qt(this.root, e);
|
|
2178
|
+
e.collapsed || Wr(this.root, e);
|
|
2179
|
+
for (let e of t) {
|
|
2180
|
+
if (!e.isConnected) continue;
|
|
2181
|
+
gr(this.root, e);
|
|
2182
|
+
let t = It(e, this.root, "BLOCKQUOTE");
|
|
2183
|
+
t && K(t), e.removeAttribute("style"), e.removeAttribute("data-indent");
|
|
2184
|
+
let n = document.createRange();
|
|
2185
|
+
n.selectNodeContents(e), Xn(this.root, n, "P");
|
|
2186
|
+
}
|
|
2187
|
+
});
|
|
2188
|
+
}
|
|
2189
|
+
setBlockType(e) {
|
|
2190
|
+
this.exec((t) => {
|
|
2191
|
+
Xn(this.root, t, e);
|
|
2192
|
+
});
|
|
2193
|
+
}
|
|
2194
|
+
toggleBlockquote() {
|
|
2195
|
+
this.exec((e) => {
|
|
2196
|
+
Qn(this.root, e);
|
|
2197
|
+
});
|
|
2198
|
+
}
|
|
2199
|
+
toggleCodeBlock() {
|
|
2200
|
+
this.exec((e) => {
|
|
2201
|
+
Zn(this.root, e);
|
|
2202
|
+
});
|
|
2203
|
+
}
|
|
2204
|
+
setTextAlign(e) {
|
|
2205
|
+
this.exec((t) => {
|
|
2206
|
+
$n(this.root, t, e);
|
|
2207
|
+
});
|
|
2208
|
+
}
|
|
2209
|
+
setLineHeight(e) {
|
|
2210
|
+
this.exec((t) => {
|
|
2211
|
+
er(this.root, t, e);
|
|
2212
|
+
});
|
|
2213
|
+
}
|
|
2214
|
+
setTextDirection(e) {
|
|
2215
|
+
this.exec((t) => {
|
|
2216
|
+
tr(this.root, t, e);
|
|
2217
|
+
});
|
|
2218
|
+
}
|
|
2219
|
+
toggleList(e) {
|
|
2220
|
+
this.exec((t) => {
|
|
2221
|
+
_r(this.root, t, e);
|
|
2222
|
+
});
|
|
2223
|
+
}
|
|
2224
|
+
indent(e) {
|
|
2225
|
+
this.exec((t) => (Y(t.startContainer, this.root) === null ? rr(this.root, t, e) : hr(this.root, t, e)) ? void 0 : null);
|
|
2226
|
+
}
|
|
2227
|
+
insertBlock(e, t) {
|
|
2228
|
+
this.exec((n) => {
|
|
2229
|
+
let r = ar(this.root, this.collapsedAfterDelete(n), e), i = t?.(e);
|
|
2230
|
+
return ji(i ?? r);
|
|
2231
|
+
});
|
|
2232
|
+
}
|
|
2233
|
+
insertHorizontalRule() {
|
|
2234
|
+
this.insertBlock(W("hr"));
|
|
2235
|
+
}
|
|
2236
|
+
insertPageBreak() {
|
|
2237
|
+
this.insertBlock(W("div", {
|
|
2238
|
+
"data-type": "page-break",
|
|
2239
|
+
class: "doc-page-break"
|
|
2240
|
+
}));
|
|
2241
|
+
}
|
|
2242
|
+
getActiveLink() {
|
|
2243
|
+
let e = this.currentRange();
|
|
2244
|
+
return e ? kr(e.startContainer, this.root) : null;
|
|
2245
|
+
}
|
|
2246
|
+
setLink(e, t, n) {
|
|
2247
|
+
let r = bn(e);
|
|
2248
|
+
r && this.exec((e) => {
|
|
2249
|
+
let i = kr(e.startContainer, this.root);
|
|
2250
|
+
if (e.collapsed && i && e.selectNodeContents(i), !e.collapsed) {
|
|
2251
|
+
Hr(this.root, e, r, t);
|
|
2252
|
+
return;
|
|
2253
|
+
}
|
|
2254
|
+
let a = n || r, o = Gi(this.root, e, a), s = document.createRange();
|
|
2255
|
+
return s.setStart(o.node, o.offset - a.length), s.setEnd(o.node, o.offset), Hr(this.root, s, r, t), {
|
|
2256
|
+
node: s.endContainer,
|
|
2257
|
+
offset: s.endOffset
|
|
2258
|
+
};
|
|
2259
|
+
});
|
|
2260
|
+
}
|
|
2261
|
+
unsetLink() {
|
|
2262
|
+
this.exec((e) => {
|
|
2263
|
+
let t = kr(e.startContainer, this.root);
|
|
2264
|
+
e.collapsed && t && e.selectNodeContents(t), Ur(this.root, e);
|
|
2265
|
+
});
|
|
2266
|
+
}
|
|
2267
|
+
insertImage(e, t = "") {
|
|
2268
|
+
let n = bn(e, !0);
|
|
2269
|
+
n && this.insertBlock(W("img", {
|
|
2270
|
+
src: n,
|
|
2271
|
+
alt: t,
|
|
2272
|
+
"data-align": "center"
|
|
2273
|
+
}));
|
|
2274
|
+
}
|
|
2275
|
+
selectImage(e) {
|
|
2276
|
+
this.selectedImageElement !== e && (this.selectedImageElement = e, this.emit("selection", void 0));
|
|
2277
|
+
}
|
|
2278
|
+
updateImage(e, t) {
|
|
2279
|
+
this.mutate(() => {
|
|
2280
|
+
for (let [n, r] of Object.entries(t)) {
|
|
2281
|
+
let t = n === "align" ? "data-align" : n;
|
|
2282
|
+
r == null || r === "" ? e.removeAttribute(t) : e.setAttribute(t, String(r));
|
|
2283
|
+
}
|
|
2284
|
+
});
|
|
2285
|
+
}
|
|
2286
|
+
removeImage(e) {
|
|
2287
|
+
this.selectImage(null), this.exec(() => {
|
|
2288
|
+
let t = e.nextElementSibling, n = e.previousElementSibling;
|
|
2289
|
+
return e.remove(), kt(t) ? ji(t) : kt(n) ? Mi(n) : void 0;
|
|
2290
|
+
});
|
|
2291
|
+
}
|
|
2292
|
+
getActiveCell() {
|
|
2293
|
+
let e = this.currentRange();
|
|
2294
|
+
return e ? It(e.startContainer, this.root, io) : null;
|
|
2295
|
+
}
|
|
2296
|
+
canMergeCells() {
|
|
2297
|
+
return Ga(this.cellRect);
|
|
2298
|
+
}
|
|
2299
|
+
canSplitCell() {
|
|
2300
|
+
return qa(this.getActiveCell());
|
|
2301
|
+
}
|
|
2302
|
+
resizeColumn(e, t, n) {
|
|
2303
|
+
this.mutate(() => to(e, t, n));
|
|
2304
|
+
}
|
|
2305
|
+
insertTable(e, t, n) {
|
|
2306
|
+
this.insertBlock(Fa(e, t, n), (e) => e.querySelector("p"));
|
|
2307
|
+
}
|
|
2308
|
+
tableCommand(e) {
|
|
2309
|
+
let t = this.getActiveCell() ?? (this.cellRect ? Wa(this.cellRect)[0] : null), n = t?.closest("table");
|
|
2310
|
+
if (!t || !n) return;
|
|
2311
|
+
let r = this.cellRect;
|
|
2312
|
+
this.clearCellSelection(), this.exec(() => {
|
|
2313
|
+
switch (e) {
|
|
2314
|
+
case "addRowBefore":
|
|
2315
|
+
case "addRowAfter":
|
|
2316
|
+
La(t, e === "addRowBefore" ? "before" : "after");
|
|
2317
|
+
return;
|
|
2318
|
+
case "addColumnBefore":
|
|
2319
|
+
case "addColumnAfter":
|
|
2320
|
+
Ba(t, e === "addColumnBefore" ? "before" : "after");
|
|
2321
|
+
return;
|
|
2322
|
+
case "deleteRow":
|
|
2323
|
+
za(t);
|
|
2324
|
+
return;
|
|
2325
|
+
case "deleteColumn":
|
|
2326
|
+
Ha(t);
|
|
2327
|
+
return;
|
|
2328
|
+
case "mergeCells": {
|
|
2329
|
+
let e = (r ? Ka(r) : null)?.querySelector(ao);
|
|
2330
|
+
return e ? Mi(e) : null;
|
|
2331
|
+
}
|
|
2332
|
+
case "splitCell":
|
|
2333
|
+
if (!qa(t)) return null;
|
|
2334
|
+
Ja(t);
|
|
2335
|
+
return;
|
|
2336
|
+
case "toggleHeaderRow":
|
|
2337
|
+
Ya(n);
|
|
2338
|
+
return;
|
|
2339
|
+
default: {
|
|
2340
|
+
let e = n.nextElementSibling;
|
|
2341
|
+
return n.remove(), kt(e) ? ji(e) : void 0;
|
|
2342
|
+
}
|
|
2343
|
+
}
|
|
2344
|
+
});
|
|
2345
|
+
}
|
|
2346
|
+
clearCellSelection() {
|
|
2347
|
+
this.cellRect && (this.cellRect = null, ro(this.root, []), this.root.classList.remove("has-cell-selection"), this.emit("selection", void 0));
|
|
2348
|
+
}
|
|
2349
|
+
clearSelectedCells() {
|
|
2350
|
+
let e = this.cellRect;
|
|
2351
|
+
e && this.mutate(() => {
|
|
2352
|
+
for (let t of Wa(e)) t.replaceChildren(Rt());
|
|
2353
|
+
});
|
|
2354
|
+
}
|
|
2355
|
+
replaceMatch(e) {
|
|
2356
|
+
this.mutate(() => {
|
|
2357
|
+
this.search.replaceCurrent(e), Bn(this.root, !0);
|
|
2358
|
+
});
|
|
2359
|
+
}
|
|
2360
|
+
replaceAllMatches(e) {
|
|
2361
|
+
this.mutate(() => {
|
|
2362
|
+
this.search.replaceAll(e), Bn(this.root, !0);
|
|
2363
|
+
});
|
|
2364
|
+
}
|
|
2365
|
+
}, mo = {
|
|
2366
|
+
"editor.align": "Tekislash",
|
|
2367
|
+
"editor.align.center": "Markazga",
|
|
2368
|
+
"editor.align.justify": "Ikki tomonga",
|
|
2369
|
+
"editor.align.left": "Chapga",
|
|
2370
|
+
"editor.align.right": "O‘ngga",
|
|
2371
|
+
"editor.apply": "Qo‘llash",
|
|
2372
|
+
"editor.bold": "Qalin",
|
|
2373
|
+
"editor.bulletList": "Belgili ro‘yxat",
|
|
2374
|
+
"editor.clearFormatting": "Formatni tozalash",
|
|
2375
|
+
"editor.close": "Yopish",
|
|
2376
|
+
"editor.codeBlock": "Kod bloki",
|
|
2377
|
+
"editor.colors.automatic": "Avtomatik",
|
|
2378
|
+
"editor.colors.custom": "Boshqa rang…",
|
|
2379
|
+
"editor.colors.none": "Rangsiz",
|
|
2380
|
+
"editor.defaultFont": "Standart shrift",
|
|
2381
|
+
"editor.defaultLineHeight": "Standart",
|
|
2382
|
+
"editor.defaultSize": "Standart o‘lcham",
|
|
2383
|
+
"editor.delete": "O‘chirish",
|
|
2384
|
+
"editor.direction.auto": "Avtomatik yo‘nalish",
|
|
2385
|
+
"editor.direction.ltr": "Chapdan o‘ngga",
|
|
2386
|
+
"editor.direction.rtl": "O‘ngdan chapga",
|
|
2387
|
+
"editor.document": "Hujjat",
|
|
2388
|
+
"editor.editLink": "Havolani tahrirlash",
|
|
2389
|
+
"editor.enterFullscreen": "To‘liq ekran",
|
|
2390
|
+
"editor.exitFullscreen": "To‘liq ekrandan chiqish",
|
|
2391
|
+
"editor.exportHtml": "HTML sifatida yuklab olish",
|
|
2392
|
+
"editor.exportWord": "Word (.doc) sifatida yuklab olish",
|
|
2393
|
+
"editor.fitWidth": "Kenglikka moslash",
|
|
2394
|
+
"editor.fontFamily": "Shrift",
|
|
2395
|
+
"editor.fontSize": "Shrift o‘lchami",
|
|
2396
|
+
"editor.heading": "Sarlavha {level}",
|
|
2397
|
+
"editor.highlight": "Belgilash rangi",
|
|
2398
|
+
"editor.horizontalRule": "Gorizontal chiziq",
|
|
2399
|
+
"editor.image": "Rasm",
|
|
2400
|
+
"editor.imageAlt": "Muqobil matn (alt)",
|
|
2401
|
+
"editor.imageReadError": "Rasmni o‘qib bo‘lmadi",
|
|
2402
|
+
"editor.imageSizeError": "Rasm hajmi {size} MB dan oshmasligi kerak",
|
|
2403
|
+
"editor.imageTypeError": "Faqat rasm fayllarini qo‘shish mumkin",
|
|
2404
|
+
"editor.imageUploadError": "Rasmni yuklab bo‘lmadi",
|
|
2405
|
+
"editor.indent": "Chekinishni oshirish",
|
|
2406
|
+
"editor.inlineCode": "Kod",
|
|
2407
|
+
"editor.insert": "Qo‘shish",
|
|
2408
|
+
"editor.insertDate": "Bugungi sana",
|
|
2409
|
+
"editor.insertMore": "Boshqa elementlar",
|
|
2410
|
+
"editor.italic": "Kursiv",
|
|
2411
|
+
"editor.lineHeight": "Qator oralig‘i",
|
|
2412
|
+
"editor.link": "Havola",
|
|
2413
|
+
"editor.linkNewTab": "Yangi oynada ochish",
|
|
2414
|
+
"editor.linkText": "Matn",
|
|
2415
|
+
"editor.linkUrl": "Manzil (URL)",
|
|
2416
|
+
"editor.more": "Yana",
|
|
2417
|
+
"editor.moreFormatting": "Boshqa formatlar",
|
|
2418
|
+
"editor.or": "yoki havola orqali",
|
|
2419
|
+
"editor.orderedList": "Raqamli ro‘yxat",
|
|
2420
|
+
"editor.outdent": "Chekinishni kamaytirish",
|
|
2421
|
+
"editor.page.customMargins": "Aniq qiymatlar (mm)",
|
|
2422
|
+
"editor.page.landscape": "Albom",
|
|
2423
|
+
"editor.page.marginBottom": "Pastki",
|
|
2424
|
+
"editor.page.marginLeft": "Chap",
|
|
2425
|
+
"editor.page.marginRight": "O‘ng",
|
|
2426
|
+
"editor.page.marginTop": "Yuqori",
|
|
2427
|
+
"editor.page.margins": "Hoshiyalar",
|
|
2428
|
+
"editor.page.margins.moderate": "O‘rtacha",
|
|
2429
|
+
"editor.page.margins.narrow": "Tor",
|
|
2430
|
+
"editor.page.margins.normal": "Oddiy",
|
|
2431
|
+
"editor.page.margins.official": "Rasmiy hujjat",
|
|
2432
|
+
"editor.page.margins.wide": "Keng",
|
|
2433
|
+
"editor.page.orientation": "Yo‘nalish",
|
|
2434
|
+
"editor.page.portrait": "Kitob",
|
|
2435
|
+
"editor.page.setup": "Sahifa sozlamalari",
|
|
2436
|
+
"editor.page.size": "Qog‘oz o‘lchami",
|
|
2437
|
+
"editor.pageBreak": "Sahifa uzilishi",
|
|
2438
|
+
"editor.paragraph": "Oddiy matn",
|
|
2439
|
+
"editor.placeholder": "Hujjat matnini kiriting…",
|
|
2440
|
+
"editor.print": "Chop etish / PDF",
|
|
2441
|
+
"editor.quote": "Iqtibos",
|
|
2442
|
+
"editor.redo": "Qaytarish",
|
|
2443
|
+
"editor.replace.all": "Barchasini",
|
|
2444
|
+
"editor.replace.one": "Almashtirish",
|
|
2445
|
+
"editor.replace.placeholder": "Almashtirish",
|
|
2446
|
+
"editor.replace.toggle": "Almashtirishni ko‘rsatish",
|
|
2447
|
+
"editor.search.caseSensitive": "Katta-kichik harfni farqlash",
|
|
2448
|
+
"editor.search.next": "Keyingisi",
|
|
2449
|
+
"editor.search.placeholder": "Qidirish",
|
|
2450
|
+
"editor.search.previous": "Oldingisi",
|
|
2451
|
+
"editor.search.title": "Qidirish va almashtirish",
|
|
2452
|
+
"editor.search.wholeWord": "Butun so‘z",
|
|
2453
|
+
"editor.source": "HTML kod",
|
|
2454
|
+
"editor.specialCharacters": "Maxsus belgilar",
|
|
2455
|
+
"editor.status.characters": "{count} belgi",
|
|
2456
|
+
"editor.status.page": "Sahifa {current} / {total}",
|
|
2457
|
+
"editor.status.words": "{count} so‘z",
|
|
2458
|
+
"editor.strike": "Ustidan chizilgan",
|
|
2459
|
+
"editor.subscript": "Pastki indeks",
|
|
2460
|
+
"editor.superscript": "Yuqori indeks",
|
|
2461
|
+
"editor.table.addColumnAfter": "O‘ngga ustun qo‘shish",
|
|
2462
|
+
"editor.table.addColumnBefore": "Chapga ustun qo‘shish",
|
|
2463
|
+
"editor.table.addRowAfter": "Pastga qator qo‘shish",
|
|
2464
|
+
"editor.table.addRowBefore": "Yuqoriga qator qo‘shish",
|
|
2465
|
+
"editor.table.delete": "Jadvalni o‘chirish",
|
|
2466
|
+
"editor.table.deleteColumn": "Ustunni o‘chirish",
|
|
2467
|
+
"editor.table.deleteRow": "Qatorni o‘chirish",
|
|
2468
|
+
"editor.table.headerRow": "Sarlavha qatori",
|
|
2469
|
+
"editor.table.insert": "Jadval qo‘shish",
|
|
2470
|
+
"editor.table.mergeCells": "Kataklarni birlashtirish",
|
|
2471
|
+
"editor.table.pickSize": "O‘lchamni tanlang",
|
|
2472
|
+
"editor.table.splitCell": "Katakni ajratish",
|
|
2473
|
+
"editor.table.title": "Jadval",
|
|
2474
|
+
"editor.taskList": "Vazifalar ro‘yxati",
|
|
2475
|
+
"editor.textColor": "Matn rangi",
|
|
2476
|
+
"editor.textDirection": "Matn yo‘nalishi",
|
|
2477
|
+
"editor.textStyle": "Matn uslubi",
|
|
2478
|
+
"editor.toolbar": "Muharrir asboblari",
|
|
2479
|
+
"editor.underline": "Tagiga chizilgan",
|
|
2480
|
+
"editor.undo": "Bekor qilish",
|
|
2481
|
+
"editor.unlink": "Havolani olib tashlash",
|
|
2482
|
+
"editor.uploadImage": "Kompyuterdan yuklash",
|
|
2483
|
+
"editor.uploading": "Rasm yuklanmoqda…",
|
|
2484
|
+
"editor.view.page": "Sahifa ko‘rinishi",
|
|
2485
|
+
"editor.view.web": "Veb ko‘rinish",
|
|
2486
|
+
"editor.zoom": "Masshtab",
|
|
2487
|
+
"editor.zoomIn": "Kattalashtirish",
|
|
2488
|
+
"editor.zoomOut": "Kichraytirish",
|
|
2489
|
+
"editor.zoomReset": "100% ga qaytarish"
|
|
2490
|
+
}, ho = mo, go, _o = (e) => {
|
|
2491
|
+
go = e;
|
|
2492
|
+
}, vo = typeof navigator < "u" && /Mac|iPhone|iPad/.test(navigator.userAgent), yo = /\{(\w+)\}/g, $ = (e, t) => {
|
|
2493
|
+
let n = go?.(e, t);
|
|
2494
|
+
if (n !== void 0) return n;
|
|
2495
|
+
let r = mo[e];
|
|
2496
|
+
return t ? r.replace(yo, (e, n) => String(t[n] ?? "")) : r;
|
|
2497
|
+
}, bo = (e) => vo ? e.replace(/Mod\+/g, "⌘").replace(/Shift\+/g, "⇧").replace(/Alt\+/g, "⌥") : e.replace(/Mod/g, "Ctrl"), xo = (e, t) => `${$(e)} (${bo(t)})`, So = 1, Co = 1, wo = (e) => Number.parseFloat(e.getAttribute("data-doc-gap") ?? "") || 0, To = (e, t) => {
|
|
2498
|
+
let n = Math.max(0, Math.round(t));
|
|
2499
|
+
if (n !== wo(e)) {
|
|
2500
|
+
if (n) {
|
|
2501
|
+
e.setAttribute($t, String(n)), e.style.marginTop = `${n}px`;
|
|
2502
|
+
return;
|
|
2503
|
+
}
|
|
2504
|
+
e.removeAttribute($t), e.style.removeProperty("margin-top"), e.getAttribute("style") || e.removeAttribute("style");
|
|
2505
|
+
}
|
|
2506
|
+
}, Eo = (e) => e && Number.parseFloat(getComputedStyle(e).marginBottom) || 0, Do = (e, t) => {
|
|
2507
|
+
let n = t.height + t.gap, r = (e) => Math.round(e * n + t.marginTop), i = (e) => Math.round(e * n + t.height - t.marginBottom), a = Array.from(e.children), o = 0, s = a.map((e, t) => {
|
|
2508
|
+
let n = wo(e);
|
|
2509
|
+
if (n) {
|
|
2510
|
+
let e = t > 0 ? Eo(a[t - 1]) : 0;
|
|
2511
|
+
o += t > 0 ? Math.max(n, e) - e : n;
|
|
2512
|
+
}
|
|
2513
|
+
return {
|
|
2514
|
+
element: e,
|
|
2515
|
+
top: e.offsetTop - o,
|
|
2516
|
+
height: e.offsetHeight
|
|
2517
|
+
};
|
|
2518
|
+
}), c = [], l = 0, u = 0, d = !1;
|
|
2519
|
+
return s.forEach(({ element: e, top: t, height: n }, o) => {
|
|
2520
|
+
let s = t + l;
|
|
2521
|
+
s > r(u) + So && (d || s + n > i(u) + So) && (u += 1);
|
|
2522
|
+
let f = r(u), p = 0;
|
|
2523
|
+
if (s < f - So) {
|
|
2524
|
+
let e = f - s;
|
|
2525
|
+
p = o > 0 ? e + Eo(a[o - 1]) : e, l += e, s = f;
|
|
2526
|
+
}
|
|
2527
|
+
for (c.push(p); s + n > i(u) + So;) u += 1;
|
|
2528
|
+
d = e.getAttribute("data-type") === "page-break";
|
|
2529
|
+
}), a.forEach((e, t) => {
|
|
2530
|
+
To(e, c[t] ?? 0);
|
|
2531
|
+
}), u + 1;
|
|
2532
|
+
}, Oo = (e) => {
|
|
2533
|
+
for (let t of Array.from(e.querySelectorAll(`:scope > [${$t}]`))) To(t, 0);
|
|
2534
|
+
return Co;
|
|
2535
|
+
}, ko = (e, t) => {
|
|
2536
|
+
let n = null, r = 0, i = Co, a = () => {
|
|
2537
|
+
if (r = 0, !e.isConnected || t.isComposing()) return;
|
|
2538
|
+
let a = n ? Do(e, n) : Oo(e);
|
|
2539
|
+
a !== i && (i = a, t.onPageCount(a));
|
|
2540
|
+
}, o = () => {
|
|
2541
|
+
r ||= requestAnimationFrame(a);
|
|
2542
|
+
}, s = typeof ResizeObserver > "u" ? null : new ResizeObserver(o);
|
|
2543
|
+
return s?.observe(e), e.addEventListener("load", o, !0), document.fonts?.ready.then(o), {
|
|
2544
|
+
setMetrics: (e) => {
|
|
2545
|
+
n = e, o();
|
|
2546
|
+
},
|
|
2547
|
+
schedule: o,
|
|
2548
|
+
destroy: () => {
|
|
2549
|
+
s?.disconnect(), e.removeEventListener("load", o, !0), r && cancelAnimationFrame(r), r = 0;
|
|
2550
|
+
}
|
|
2551
|
+
};
|
|
2552
|
+
}, Ao = ["aria-label"], jo = ["href", "title"], Mo = ["aria-label", "title"], No = ["aria-label", "title"], Po = [
|
|
2553
|
+
"aria-label",
|
|
2554
|
+
"title",
|
|
2555
|
+
"onClick"
|
|
2556
|
+
], Fo = ["aria-label", "title"], Io = ["aria-label", "title"], Lo = {
|
|
2557
|
+
key: 0,
|
|
2558
|
+
class: "doc-bubble__divider"
|
|
2559
|
+
}, Ro = [
|
|
2560
|
+
"aria-label",
|
|
2561
|
+
"disabled",
|
|
2562
|
+
"title",
|
|
2563
|
+
"onClick"
|
|
2564
|
+
], zo = 8, Bo = /*@__PURE__*/ m({
|
|
2565
|
+
name: "EditorBubbleMenus",
|
|
2566
|
+
__name: "editor-bubble-menus",
|
|
2567
|
+
props: {
|
|
2568
|
+
engine: {},
|
|
2569
|
+
scrollTarget: {}
|
|
2570
|
+
},
|
|
2571
|
+
emits: ["editLink"],
|
|
2572
|
+
setup(e, { emit: t }) {
|
|
2573
|
+
let n = e, r = t, i = [
|
|
2574
|
+
{
|
|
2575
|
+
value: "left",
|
|
2576
|
+
icon: ft,
|
|
2577
|
+
label: "editor.align.left"
|
|
2578
|
+
},
|
|
2579
|
+
{
|
|
2580
|
+
value: "center",
|
|
2581
|
+
icon: lt,
|
|
2582
|
+
label: "editor.align.center"
|
|
2583
|
+
},
|
|
2584
|
+
{
|
|
2585
|
+
value: "right",
|
|
2586
|
+
icon: ut,
|
|
2587
|
+
label: "editor.align.right"
|
|
2588
|
+
}
|
|
2589
|
+
], m = [
|
|
2590
|
+
[
|
|
2591
|
+
{
|
|
2592
|
+
command: "addRowBefore",
|
|
2593
|
+
icon: ue,
|
|
2594
|
+
label: "editor.table.addRowBefore"
|
|
2595
|
+
},
|
|
2596
|
+
{
|
|
2597
|
+
command: "addRowAfter",
|
|
2598
|
+
icon: le,
|
|
2599
|
+
label: "editor.table.addRowAfter"
|
|
2600
|
+
},
|
|
2601
|
+
{
|
|
2602
|
+
command: "deleteRow",
|
|
2603
|
+
icon: Qe,
|
|
2604
|
+
label: "editor.table.deleteRow",
|
|
2605
|
+
danger: !0
|
|
2606
|
+
}
|
|
2607
|
+
],
|
|
2608
|
+
[
|
|
2609
|
+
{
|
|
2610
|
+
command: "addColumnBefore",
|
|
2611
|
+
icon: fe,
|
|
2612
|
+
label: "editor.table.addColumnBefore"
|
|
2613
|
+
},
|
|
2614
|
+
{
|
|
2615
|
+
command: "addColumnAfter",
|
|
2616
|
+
icon: de,
|
|
2617
|
+
label: "editor.table.addColumnAfter"
|
|
2618
|
+
},
|
|
2619
|
+
{
|
|
2620
|
+
command: "deleteColumn",
|
|
2621
|
+
icon: z,
|
|
2622
|
+
label: "editor.table.deleteColumn",
|
|
2623
|
+
danger: !0
|
|
2624
|
+
}
|
|
2625
|
+
],
|
|
2626
|
+
[
|
|
2627
|
+
{
|
|
2628
|
+
command: "mergeCells",
|
|
2629
|
+
icon: st,
|
|
2630
|
+
label: "editor.table.mergeCells"
|
|
2631
|
+
},
|
|
2632
|
+
{
|
|
2633
|
+
command: "splitCell",
|
|
2634
|
+
icon: ct,
|
|
2635
|
+
label: "editor.table.splitCell"
|
|
2636
|
+
},
|
|
2637
|
+
{
|
|
2638
|
+
command: "toggleHeaderRow",
|
|
2639
|
+
icon: Ve,
|
|
2640
|
+
label: "editor.table.headerRow"
|
|
2641
|
+
}
|
|
2642
|
+
],
|
|
2643
|
+
[{
|
|
2644
|
+
command: "deleteTable",
|
|
2645
|
+
icon: we,
|
|
2646
|
+
label: "editor.table.delete",
|
|
2647
|
+
danger: !0
|
|
2648
|
+
}]
|
|
2649
|
+
], h = x(null), g = x({
|
|
2650
|
+
left: 0,
|
|
2651
|
+
top: 0
|
|
2652
|
+
}), w = x(!1), D = x(), ne = x(), re = x(""), ie = x("center"), O = x(""), ae = x(!1), se = x(!1), j = x(!1), M = x(), { nextZIndex: N } = ce(), F = null, I = 0, pe = [], me = s(() => h.value === "link" ? $("editor.link") : h.value === "image" ? $("editor.image") : $("editor.table.title")), he = () => document.activeElement === n.engine.root, L = () => {
|
|
2653
|
+
let { engine: e } = n;
|
|
2654
|
+
if (!e.isEditable) return null;
|
|
2655
|
+
let t = e.selectedImage;
|
|
2656
|
+
if (t) return {
|
|
2657
|
+
kind: "image",
|
|
2658
|
+
reference: t,
|
|
2659
|
+
placement: "above"
|
|
2660
|
+
};
|
|
2661
|
+
if (!he() && !e.hasCellSelection) return null;
|
|
2662
|
+
let r = e.getActiveLink();
|
|
2663
|
+
if (r && (document.getSelection()?.isCollapsed ?? !0)) return {
|
|
2664
|
+
kind: "link",
|
|
2665
|
+
reference: r,
|
|
2666
|
+
placement: "below"
|
|
2667
|
+
};
|
|
2668
|
+
let i = e.getActiveCell()?.closest("table");
|
|
2669
|
+
return i ? {
|
|
2670
|
+
kind: "table",
|
|
2671
|
+
reference: i,
|
|
2672
|
+
placement: "above"
|
|
2673
|
+
} : null;
|
|
2674
|
+
}, R = () => {
|
|
2675
|
+
let e = D.value, t = F?.reference;
|
|
2676
|
+
if (!e || !t?.isConnected) return;
|
|
2677
|
+
let r = t.getBoundingClientRect(), i = n.scrollTarget.getBoundingClientRect();
|
|
2678
|
+
w.value = r.bottom < i.top || r.top > i.bottom;
|
|
2679
|
+
let { offsetWidth: a, offsetHeight: o } = e, s = F?.placement === "below", c = s ? r.bottom + zo : r.top - o - zo;
|
|
2680
|
+
s && c + o > i.bottom - zo && (c = r.top - o - zo), !s && c < i.top + zo && (c = i.top + zo);
|
|
2681
|
+
let l = s ? r.left : r.left + r.width / 2 - a / 2, u = Math.min(Math.max(l, i.left + zo), Math.max(i.left + zo, i.right - a - zo));
|
|
2682
|
+
g.value = {
|
|
2683
|
+
left: u,
|
|
2684
|
+
top: c
|
|
2685
|
+
};
|
|
2686
|
+
}, ge = ({ kind: e, reference: t }) => {
|
|
2687
|
+
if (e === "link" && (re.value = t.getAttribute("href") ?? ""), e === "image") {
|
|
2688
|
+
let e = t.getAttribute("data-align");
|
|
2689
|
+
ie.value = e === "left" || e === "right" ? e : "center", ae.value || (O.value = t.getAttribute("alt") ?? "");
|
|
2690
|
+
}
|
|
2691
|
+
e === "table" && (se.value = n.engine.canMergeCells(), j.value = n.engine.canSplitCell());
|
|
2692
|
+
}, _e = () => {
|
|
2693
|
+
if (I = 0, D.value?.contains(document.activeElement)) {
|
|
2694
|
+
R();
|
|
2695
|
+
return;
|
|
2696
|
+
}
|
|
2697
|
+
let e = L();
|
|
2698
|
+
F = e, e?.kind !== "image" && (ae.value = !1), e && !h.value && (M.value = N()), h.value = e?.kind ?? null, e && (ge(e), _(R));
|
|
2699
|
+
}, B = () => {
|
|
2700
|
+
I ||= requestAnimationFrame(_e);
|
|
2701
|
+
}, ye = () => requestAnimationFrame(R), be = (e) => {
|
|
2702
|
+
n.engine.tableCommand(e), B();
|
|
2703
|
+
}, xe = (e) => {
|
|
2704
|
+
let t = n.engine.selectedImage;
|
|
2705
|
+
t && n.engine.updateImage(t, { align: e }), B();
|
|
2706
|
+
}, Se = async () => {
|
|
2707
|
+
ae.value = !0, await _(), ne.value?.focus();
|
|
2708
|
+
}, Ce = () => {
|
|
2709
|
+
let e = F?.kind === "image" ? F.reference : null;
|
|
2710
|
+
ae.value = !1, e && n.engine.updateImage(e, { alt: O.value.trim() || null }), n.engine.root.focus({ preventScroll: !0 }), B();
|
|
2711
|
+
}, Te = () => {
|
|
2712
|
+
let e = n.engine.selectedImage;
|
|
2713
|
+
e && n.engine.removeImage(e);
|
|
2714
|
+
}, Ee = (e) => e === "mergeCells" && !se.value || e === "splitCell" && !j.value;
|
|
2715
|
+
return te(() => {
|
|
2716
|
+
n.scrollTarget.addEventListener("scroll", ye, { passive: !0 }), window.addEventListener("resize", B), document.addEventListener("focusin", B), document.addEventListener("focusout", B), pe.push(n.engine.on("selection", B), n.engine.on("update", B), n.engine.on("blur", B), () => n.scrollTarget.removeEventListener("scroll", ye), () => window.removeEventListener("resize", B), () => document.removeEventListener("focusin", B), () => document.removeEventListener("focusout", B)), B();
|
|
2717
|
+
}), ee(() => {
|
|
2718
|
+
for (let e of pe) e();
|
|
2719
|
+
cancelAnimationFrame(I);
|
|
2720
|
+
}), (t, n) => (b(), c(o, { to: "body" }, [h.value ? (b(), u("div", {
|
|
2721
|
+
key: 0,
|
|
2722
|
+
ref_key: "menuRef",
|
|
2723
|
+
ref: D,
|
|
2724
|
+
class: v(["doc-bubble-host doc-bubble", { "is-hidden": w.value }]),
|
|
2725
|
+
role: "toolbar",
|
|
2726
|
+
"aria-label": me.value,
|
|
2727
|
+
style: y({
|
|
2728
|
+
left: `${g.value.left}px`,
|
|
2729
|
+
top: `${g.value.top}px`,
|
|
2730
|
+
zIndex: M.value
|
|
2731
|
+
})
|
|
2732
|
+
}, [h.value === "link" ? (b(), u(a, { key: 0 }, [
|
|
2733
|
+
d("a", {
|
|
2734
|
+
class: "doc-bubble__link",
|
|
2735
|
+
target: "_blank",
|
|
2736
|
+
rel: "noopener noreferrer",
|
|
2737
|
+
href: re.value,
|
|
2738
|
+
title: re.value
|
|
2739
|
+
}, [p(E(ve), { size: 13 }), d("span", null, T(re.value), 1)], 8, jo),
|
|
2740
|
+
n[9] ||= d("span", { class: "doc-bubble__divider" }, null, -1),
|
|
2741
|
+
d("button", {
|
|
2742
|
+
type: "button",
|
|
2743
|
+
class: "doc-tb-button",
|
|
2744
|
+
"aria-label": E($)("editor.editLink"),
|
|
2745
|
+
title: E($)("editor.editLink"),
|
|
2746
|
+
onMousedown: n[0] ||= A(() => {}, ["prevent"]),
|
|
2747
|
+
onClick: n[1] ||= (e) => r("editLink")
|
|
2748
|
+
}, [p(E(He), { size: 15 })], 40, Mo),
|
|
2749
|
+
d("button", {
|
|
2750
|
+
type: "button",
|
|
2751
|
+
class: "doc-tb-button",
|
|
2752
|
+
"aria-label": E($)("editor.unlink"),
|
|
2753
|
+
title: E($)("editor.unlink"),
|
|
2754
|
+
onMousedown: n[2] ||= A(() => {}, ["prevent"]),
|
|
2755
|
+
onClick: n[3] ||= (t) => e.engine.unsetLink()
|
|
2756
|
+
}, [p(E(vt), { size: 15 })], 40, No)
|
|
2757
|
+
], 64)) : h.value === "image" ? (b(), u(a, { key: 1 }, [ae.value ? (b(), u("form", {
|
|
2758
|
+
key: 0,
|
|
2759
|
+
class: "doc-bubble__form",
|
|
2760
|
+
onSubmit: A(Ce, ["prevent"])
|
|
2761
|
+
}, [p(E(P), {
|
|
2762
|
+
ref_key: "altInput",
|
|
2763
|
+
ref: ne,
|
|
2764
|
+
modelValue: O.value,
|
|
2765
|
+
"onUpdate:modelValue": n[4] ||= (e) => O.value = e,
|
|
2766
|
+
size: "small",
|
|
2767
|
+
ariaLabel: E($)("editor.imageAlt"),
|
|
2768
|
+
placeholder: E($)("editor.imageAlt")
|
|
2769
|
+
}, null, 8, [
|
|
2770
|
+
"modelValue",
|
|
2771
|
+
"ariaLabel",
|
|
2772
|
+
"placeholder"
|
|
2773
|
+
]), p(E(oe), {
|
|
2774
|
+
"native-type": "submit",
|
|
2775
|
+
size: "small",
|
|
2776
|
+
type: "primary"
|
|
2777
|
+
}, {
|
|
2778
|
+
default: k(() => [f(T(E($)("editor.apply")), 1)]),
|
|
2779
|
+
_: 1
|
|
2780
|
+
})], 32)) : (b(), u(a, { key: 1 }, [
|
|
2781
|
+
(b(), u(a, null, S(i, (e) => d("button", {
|
|
2782
|
+
key: e.value,
|
|
2783
|
+
type: "button",
|
|
2784
|
+
class: v(["doc-tb-button", { "is-active": ie.value === e.value }]),
|
|
2785
|
+
"aria-label": E($)(e.label),
|
|
2786
|
+
title: E($)(e.label),
|
|
2787
|
+
onMousedown: n[5] ||= A(() => {}, ["prevent"]),
|
|
2788
|
+
onClick: (t) => xe(e.value)
|
|
2789
|
+
}, [(b(), c(C(e.icon), { size: 15 }))], 42, Po)), 64)),
|
|
2790
|
+
n[10] ||= d("span", { class: "doc-bubble__divider" }, null, -1),
|
|
2791
|
+
d("button", {
|
|
2792
|
+
type: "button",
|
|
2793
|
+
class: "doc-tb-button",
|
|
2794
|
+
"aria-label": E($)("editor.imageAlt"),
|
|
2795
|
+
title: E($)("editor.imageAlt"),
|
|
2796
|
+
onMousedown: n[6] ||= A(() => {}, ["prevent"]),
|
|
2797
|
+
onClick: Se
|
|
2798
|
+
}, [p(E(pt), { size: 15 })], 40, Fo),
|
|
2799
|
+
d("button", {
|
|
2800
|
+
type: "button",
|
|
2801
|
+
class: "doc-tb-button is-danger",
|
|
2802
|
+
"aria-label": E($)("editor.delete"),
|
|
2803
|
+
title: E($)("editor.delete"),
|
|
2804
|
+
onMousedown: n[7] ||= A(() => {}, ["prevent"]),
|
|
2805
|
+
onClick: Te
|
|
2806
|
+
}, [p(E(mt), { size: 15 })], 40, Io)
|
|
2807
|
+
], 64))], 64)) : (b(), u(a, { key: 2 }, S(m, (e, t) => (b(), u(a, { key: t }, [t ? (b(), u("span", Lo)) : l("", !0), (b(!0), u(a, null, S(e, (e) => (b(), u("button", {
|
|
2808
|
+
key: e.command,
|
|
2809
|
+
type: "button",
|
|
2810
|
+
class: v(["doc-tb-button", { "is-danger": "danger" in e }]),
|
|
2811
|
+
"aria-label": E($)(e.label),
|
|
2812
|
+
disabled: Ee(e.command),
|
|
2813
|
+
title: E($)(e.label),
|
|
2814
|
+
onMousedown: n[8] ||= A(() => {}, ["prevent"]),
|
|
2815
|
+
onClick: (t) => be(e.command)
|
|
2816
|
+
}, [(b(), c(C(e.icon), { size: 15 }))], 42, Ro))), 128))], 64))), 64))], 14, Ao)) : l("", !0)]));
|
|
2817
|
+
}
|
|
2818
|
+
}), Vo = (e, t) => {
|
|
2819
|
+
let n = e.__vccOpts || e;
|
|
2820
|
+
for (let [e, r] of t) n[e] = r;
|
|
2821
|
+
return n;
|
|
2822
|
+
}, Ho = /*#__PURE__*/ Vo(Bo, [["__scopeId", "data-v-491ba8f4"]]), Uo = {
|
|
2823
|
+
class: "object-overlay",
|
|
2824
|
+
"aria-hidden": "true"
|
|
2825
|
+
}, Wo = ["onPointerdown"], Go = {
|
|
2826
|
+
key: 0,
|
|
2827
|
+
class: "object-overlay__size"
|
|
2828
|
+
}, Ko = 4, qo = 40, Jo = 40, Yo = "is-column-resize", Xo = 100, Zo = 0, Qo = /*#__PURE__*/ Vo(/* @__PURE__ */ m({
|
|
2829
|
+
name: "EditorObjectOverlay",
|
|
2830
|
+
__name: "editor-object-overlay",
|
|
2831
|
+
props: {
|
|
2832
|
+
engine: {},
|
|
2833
|
+
zoom: {}
|
|
2834
|
+
},
|
|
2835
|
+
setup(e) {
|
|
2836
|
+
let t = e, n = [
|
|
2837
|
+
"top-left",
|
|
2838
|
+
"top-right",
|
|
2839
|
+
"bottom-left",
|
|
2840
|
+
"bottom-right"
|
|
2841
|
+
], r = x(null), i = x(null), o = x(null), s = 0, c = null, f = !1, p = [], m = (e) => `${e}px`, h = () => t.zoom / Xo, g = (e) => {
|
|
2842
|
+
let n = t.engine.root.getBoundingClientRect(), r = e.getBoundingClientRect(), i = h();
|
|
2843
|
+
return {
|
|
2844
|
+
left: (r.left - n.left) / i,
|
|
2845
|
+
top: (r.top - n.top) / i,
|
|
2846
|
+
width: r.width / i,
|
|
2847
|
+
height: r.height / i
|
|
2848
|
+
};
|
|
2849
|
+
}, _ = () => {
|
|
2850
|
+
s = 0;
|
|
2851
|
+
let e = t.engine.selectedImage;
|
|
2852
|
+
r.value = e && t.engine.isEditable ? g(e) : null;
|
|
2853
|
+
}, C = () => {
|
|
2854
|
+
s ||= requestAnimationFrame(_);
|
|
2855
|
+
}, w = () => {
|
|
2856
|
+
let { root: e } = t.engine, n = getComputedStyle(e);
|
|
2857
|
+
return e.clientWidth - Number.parseFloat(n.paddingLeft) - Number.parseFloat(n.paddingRight);
|
|
2858
|
+
}, E = (e, n) => {
|
|
2859
|
+
let r = t.engine.selectedImage;
|
|
2860
|
+
if (!r) return;
|
|
2861
|
+
let a = n.clientX, o = r.getBoundingClientRect().width / h(), s = r.naturalWidth && r.naturalHeight ? r.naturalHeight / r.naturalWidth : r.offsetHeight / Math.max(1, r.offsetWidth), c = {
|
|
2862
|
+
width: r.getAttribute("width"),
|
|
2863
|
+
height: r.getAttribute("height")
|
|
2864
|
+
}, l = e.endsWith("left") ? -1 : 1, u = w(), d = Math.round(o), f = (e) => {
|
|
2865
|
+
let t = o + (e.clientX - a) / h() * l;
|
|
2866
|
+
d = Math.round(Math.min(u, Math.max(qo, t))), r.setAttribute("width", String(d)), r.setAttribute("height", String(Math.round(d * s))), i.value = {
|
|
2867
|
+
width: d,
|
|
2868
|
+
height: Math.round(d * s)
|
|
2869
|
+
}, C();
|
|
2870
|
+
}, p = () => {
|
|
2871
|
+
window.removeEventListener("pointermove", f), window.removeEventListener("pointerup", p), i.value = null;
|
|
2872
|
+
for (let [e, t] of Object.entries(c)) t === null ? r.removeAttribute(e) : r.setAttribute(e, t);
|
|
2873
|
+
d !== Math.round(o) && t.engine.updateImage(r, {
|
|
2874
|
+
width: d,
|
|
2875
|
+
height: Math.round(d * s)
|
|
2876
|
+
}), C();
|
|
2877
|
+
};
|
|
2878
|
+
window.addEventListener("pointermove", f), window.addEventListener("pointerup", p);
|
|
2879
|
+
}, D = (e) => {
|
|
2880
|
+
if (f || e.buttons) return;
|
|
2881
|
+
let n = e.target.closest?.("td, th"), r = n?.closest("table") ?? null, i = n && r && t.engine.isEditable && t.engine.root.contains(r) ? no(r, n, e.clientX, Ko * h()) : null;
|
|
2882
|
+
c = i !== null && r ? {
|
|
2883
|
+
table: r,
|
|
2884
|
+
index: i
|
|
2885
|
+
} : null, t.engine.root.classList.toggle(Yo, c !== null);
|
|
2886
|
+
}, ne = (e) => {
|
|
2887
|
+
if (!c || e.button !== Zo) return;
|
|
2888
|
+
e.preventDefault(), e.stopPropagation();
|
|
2889
|
+
let { table: n, index: r } = c, i = e.clientX, a = eo(n, r), s = g(n), l = (i - t.engine.root.getBoundingClientRect().left) / h(), u = a;
|
|
2890
|
+
f = !0, o.value = {
|
|
2891
|
+
left: l,
|
|
2892
|
+
top: s.top,
|
|
2893
|
+
height: s.height
|
|
2894
|
+
};
|
|
2895
|
+
let d = (e) => {
|
|
2896
|
+
u = Math.max(Jo, a + (e.clientX - i) / h()), o.value = {
|
|
2897
|
+
left: l + u - a,
|
|
2898
|
+
top: s.top,
|
|
2899
|
+
height: s.height
|
|
2900
|
+
};
|
|
2901
|
+
}, p = () => {
|
|
2902
|
+
window.removeEventListener("mousemove", d), window.removeEventListener("mouseup", p), f = !1, o.value = null, Math.round(u) !== Math.round(a) && t.engine.resizeColumn(n, r, u);
|
|
2903
|
+
};
|
|
2904
|
+
window.addEventListener("mousemove", d), window.addEventListener("mouseup", p);
|
|
2905
|
+
};
|
|
2906
|
+
return O(() => t.zoom, C), te(() => {
|
|
2907
|
+
let { root: e } = t.engine;
|
|
2908
|
+
e.addEventListener("mousemove", D), e.addEventListener("mousedown", ne, !0), p.push(t.engine.on("selection", C), t.engine.on("update", C), () => e.removeEventListener("mousemove", D), () => e.removeEventListener("mousedown", ne, !0)), C();
|
|
2909
|
+
}), ee(() => {
|
|
2910
|
+
for (let e of p) e();
|
|
2911
|
+
cancelAnimationFrame(s);
|
|
2912
|
+
}), (e, t) => (b(), u("div", Uo, [r.value ? (b(), u("div", {
|
|
2913
|
+
key: 0,
|
|
2914
|
+
class: "object-overlay__image",
|
|
2915
|
+
style: y({
|
|
2916
|
+
left: m(r.value.left),
|
|
2917
|
+
top: m(r.value.top),
|
|
2918
|
+
width: m(r.value.width),
|
|
2919
|
+
height: m(r.value.height)
|
|
2920
|
+
})
|
|
2921
|
+
}, [(b(), u(a, null, S(n, (e) => d("span", {
|
|
2922
|
+
key: e,
|
|
2923
|
+
class: v(["object-overlay__handle", `is-${e}`]),
|
|
2924
|
+
onPointerdown: A((t) => E(e, t), ["prevent", "stop"])
|
|
2925
|
+
}, null, 42, Wo)), 64)), i.value ? (b(), u("span", Go, T(i.value.width) + " × " + T(i.value.height), 1)) : l("", !0)], 4)) : l("", !0), o.value ? (b(), u("div", {
|
|
2926
|
+
key: 1,
|
|
2927
|
+
class: "object-overlay__guide",
|
|
2928
|
+
style: y({
|
|
2929
|
+
left: m(o.value.left),
|
|
2930
|
+
top: m(o.value.top),
|
|
2931
|
+
height: m(o.value.height)
|
|
2932
|
+
})
|
|
2933
|
+
}, null, 4)) : l("", !0)]));
|
|
2934
|
+
}
|
|
2935
|
+
}), [["__scopeId", "data-v-7da0d742"]]), $o = {
|
|
2936
|
+
key: 0,
|
|
2937
|
+
class: "doc-canvas__sheets",
|
|
2938
|
+
"aria-hidden": "true"
|
|
2939
|
+
}, es = { class: "doc-canvas__page-number" }, ts = 100, ns = 2, rs = 0, is = /*#__PURE__*/ Vo(/* @__PURE__ */ m({
|
|
2940
|
+
name: "EditorCanvas",
|
|
2941
|
+
__name: "editor-canvas",
|
|
2942
|
+
props: {
|
|
2943
|
+
autoHeight: { type: Boolean },
|
|
2944
|
+
engine: {},
|
|
2945
|
+
metrics: {},
|
|
2946
|
+
pageCount: {},
|
|
2947
|
+
viewMode: {},
|
|
2948
|
+
zoom: {}
|
|
2949
|
+
},
|
|
2950
|
+
emits: ["resize"],
|
|
2951
|
+
setup(e, { expose: t, emit: n }) {
|
|
2952
|
+
let r = e, i = n, o = x(), f = x(), p = x(), m = x({
|
|
2953
|
+
width: 0,
|
|
2954
|
+
height: 0
|
|
2955
|
+
}), h = x(0), g, _ = (e) => `${e}px`, C = (e, t, n) => Math.min(Math.max(e, t), n), w = s(() => r.zoom / ts), E = s(() => r.metrics.height + r.metrics.gap), D = s(() => r.viewMode === "page" ? r.metrics.width : Math.max(1, m.value.width / w.value)), ne = s(() => r.autoHeight ? `max(0px, calc((var(--doc-editor-min-height) - 2 * var(--doc-editor-canvas-padding)) / ${w.value}))` : _(m.value.height / w.value)), re = s(() => {
|
|
2956
|
+
let { metrics: e, pageCount: t, viewMode: n } = r;
|
|
2957
|
+
return {
|
|
2958
|
+
width: _(D.value),
|
|
2959
|
+
minHeight: n === "web" ? ne.value : void 0,
|
|
2960
|
+
transform: w.value === 1 ? void 0 : `scale(${w.value})`,
|
|
2961
|
+
"--page-height": _(e.height),
|
|
2962
|
+
"--pages-height": _(t * E.value - e.gap),
|
|
2963
|
+
"--margin-top": _(e.marginTop),
|
|
2964
|
+
"--margin-right": _(e.marginRight),
|
|
2965
|
+
"--margin-bottom": _(e.marginBottom),
|
|
2966
|
+
"--margin-left": _(e.marginLeft),
|
|
2967
|
+
"--page-break-label": JSON.stringify($("editor.pageBreak"))
|
|
2968
|
+
};
|
|
2969
|
+
}), ie = s(() => ({
|
|
2970
|
+
width: _(D.value * w.value),
|
|
2971
|
+
height: _(h.value * w.value)
|
|
2972
|
+
})), O = (e) => {
|
|
2973
|
+
let t = o.value, n = p.value, i = e.target;
|
|
2974
|
+
if (!t || !n || !r.engine || e.button !== rs || i !== t && !i.classList.contains("doc-canvas__sizer") || i === t && (e.offsetX >= t.clientWidth || e.offsetY >= t.clientHeight)) return;
|
|
2975
|
+
e.preventDefault();
|
|
2976
|
+
let a = n.getBoundingClientRect(), s = di(C(e.clientX, a.left + ns, a.right - ns), C(e.clientY, a.top + ns, a.bottom - ns));
|
|
2977
|
+
s && n.contains(s.startContainer) ? (n.focus({ preventScroll: !0 }), _i(s)) : r.engine.focus("end");
|
|
2978
|
+
}, k = () => m.value.width ? Math.floor(m.value.width / r.metrics.width * ts) : 0, ae = 0, A = (e, t) => {
|
|
2979
|
+
ae = 0, h.value = t.offsetHeight;
|
|
2980
|
+
let n = getComputedStyle(e), r = e.clientWidth - Number.parseFloat(n.paddingLeft) - Number.parseFloat(n.paddingRight), a = e.clientHeight - Number.parseFloat(n.paddingTop) - Number.parseFloat(n.paddingBottom);
|
|
2981
|
+
r <= 0 || r === m.value.width && a === m.value.height || (m.value = {
|
|
2982
|
+
width: r,
|
|
2983
|
+
height: a
|
|
2984
|
+
}, i("resize", r));
|
|
2985
|
+
};
|
|
2986
|
+
return te(() => {
|
|
2987
|
+
let e = o.value, t = f.value;
|
|
2988
|
+
!e || !t || typeof ResizeObserver > "u" || (g = new ResizeObserver(() => {
|
|
2989
|
+
ae ||= requestAnimationFrame(() => A(e, t));
|
|
2990
|
+
}), g.observe(e), g.observe(t));
|
|
2991
|
+
}), ee(() => {
|
|
2992
|
+
g?.disconnect(), cancelAnimationFrame(ae);
|
|
2993
|
+
}), t({
|
|
2994
|
+
contentElement: p,
|
|
2995
|
+
getFitWidthZoom: k,
|
|
2996
|
+
scrollElement: o
|
|
2997
|
+
}), (t, n) => (b(), u("div", {
|
|
2998
|
+
ref_key: "scrollRef",
|
|
2999
|
+
ref: o,
|
|
3000
|
+
class: v(["doc-canvas", [`is-${e.viewMode}`, { "is-auto": e.autoHeight }]]),
|
|
3001
|
+
onMousedown: O
|
|
3002
|
+
}, [d("div", {
|
|
3003
|
+
class: "doc-canvas__sizer",
|
|
3004
|
+
style: y(ie.value)
|
|
3005
|
+
}, [d("div", {
|
|
3006
|
+
ref_key: "stageRef",
|
|
3007
|
+
ref: f,
|
|
3008
|
+
class: "doc-canvas__stage",
|
|
3009
|
+
style: y(re.value)
|
|
3010
|
+
}, [
|
|
3011
|
+
e.viewMode === "page" ? (b(), u("div", $o, [(b(!0), u(a, null, S(e.pageCount, (e) => (b(), u("div", {
|
|
3012
|
+
key: e,
|
|
3013
|
+
class: "doc-canvas__sheet",
|
|
3014
|
+
style: y({ top: _((e - 1) * E.value) })
|
|
3015
|
+
}, [d("span", es, T(e), 1)], 4))), 128))])) : l("", !0),
|
|
3016
|
+
d("div", {
|
|
3017
|
+
ref_key: "contentRef",
|
|
3018
|
+
ref: p,
|
|
3019
|
+
class: "doc-canvas__content"
|
|
3020
|
+
}, null, 512),
|
|
3021
|
+
e.engine ? (b(), c(Qo, {
|
|
3022
|
+
key: 1,
|
|
3023
|
+
engine: e.engine,
|
|
3024
|
+
zoom: e.zoom
|
|
3025
|
+
}, null, 8, ["engine", "zoom"])) : l("", !0)
|
|
3026
|
+
], 4)], 4)], 34));
|
|
3027
|
+
}
|
|
3028
|
+
}), [["__scopeId", "data-v-10cbe4d1"]]), as = ["aria-label"], os = [
|
|
3029
|
+
"title",
|
|
3030
|
+
"aria-label",
|
|
3031
|
+
"aria-expanded"
|
|
3032
|
+
], ss = { class: "find-bar__rows" }, cs = { class: "find-bar__row" }, ls = { class: "find-bar__count" }, us = [
|
|
3033
|
+
"title",
|
|
3034
|
+
"aria-label",
|
|
3035
|
+
"aria-pressed"
|
|
3036
|
+
], ds = [
|
|
3037
|
+
"title",
|
|
3038
|
+
"aria-label",
|
|
3039
|
+
"aria-pressed"
|
|
3040
|
+
], fs = [
|
|
3041
|
+
"disabled",
|
|
3042
|
+
"title",
|
|
3043
|
+
"aria-label"
|
|
3044
|
+
], ps = [
|
|
3045
|
+
"disabled",
|
|
3046
|
+
"title",
|
|
3047
|
+
"aria-label"
|
|
3048
|
+
], ms = ["title", "aria-label"], hs = {
|
|
3049
|
+
key: 0,
|
|
3050
|
+
class: "find-bar__row"
|
|
3051
|
+
}, gs = ["disabled"], _s = ["disabled"], vs = 120, ys = /*#__PURE__*/ Vo(/* @__PURE__ */ m({
|
|
3052
|
+
name: "EditorFindBar",
|
|
3053
|
+
__name: "editor-find-bar",
|
|
3054
|
+
props: /*@__PURE__*/ h({
|
|
3055
|
+
engine: {},
|
|
3056
|
+
readonly: { type: Boolean }
|
|
3057
|
+
}, {
|
|
3058
|
+
replace: {
|
|
3059
|
+
type: Boolean,
|
|
3060
|
+
default: !1
|
|
3061
|
+
},
|
|
3062
|
+
replaceModifiers: {}
|
|
3063
|
+
}),
|
|
3064
|
+
emits: /*@__PURE__*/ h(["close"], ["update:replace"]),
|
|
3065
|
+
setup(e, { expose: t, emit: n }) {
|
|
3066
|
+
let r = e, i = n, a = ne(e, "replace"), o = x(), s = x(""), c = x(""), f = x(!1), m = x(!1), h = x(r.engine.search.state), g, y = () => {
|
|
3067
|
+
o.value?.focus(), o.value?.select();
|
|
3068
|
+
}, S = () => r.engine.search.setQuery(s.value, {
|
|
3069
|
+
caseSensitive: f.value,
|
|
3070
|
+
wholeWord: m.value
|
|
3071
|
+
}), C = (e) => e instanceof KeyboardEvent && e.key === "Enter" ? e : null, w = (e) => {
|
|
3072
|
+
let t = C(e);
|
|
3073
|
+
t && (t.preventDefault(), t.shiftKey ? r.engine.search.previous() : r.engine.search.next());
|
|
3074
|
+
}, D = (e) => {
|
|
3075
|
+
let t = C(e);
|
|
3076
|
+
t && (t.preventDefault(), r.engine.replaceMatch(c.value));
|
|
3077
|
+
};
|
|
3078
|
+
return O([
|
|
3079
|
+
s,
|
|
3080
|
+
f,
|
|
3081
|
+
m
|
|
3082
|
+
], S), te(async () => {
|
|
3083
|
+
g = r.engine.on("search", (e) => {
|
|
3084
|
+
h.value = e;
|
|
3085
|
+
});
|
|
3086
|
+
let e = r.engine.getSelectedText();
|
|
3087
|
+
e && e.length <= vs && !e.includes("\n") && (s.value = e), await _(), y();
|
|
3088
|
+
}), ee(() => {
|
|
3089
|
+
g?.(), r.engine.search.clear();
|
|
3090
|
+
}), t({ focus: y }), (t, n) => (b(), u("div", {
|
|
3091
|
+
class: "find-bar",
|
|
3092
|
+
role: "search",
|
|
3093
|
+
"aria-label": E($)("editor.search.title")
|
|
3094
|
+
}, [e.readonly ? l("", !0) : (b(), u("button", {
|
|
3095
|
+
key: 0,
|
|
3096
|
+
type: "button",
|
|
3097
|
+
class: v(["doc-tb-button", { "is-active": a.value }]),
|
|
3098
|
+
title: E($)("editor.replace.toggle"),
|
|
3099
|
+
"aria-label": E($)("editor.replace.toggle"),
|
|
3100
|
+
"aria-expanded": a.value,
|
|
3101
|
+
onClick: n[0] ||= (e) => a.value = !a.value
|
|
3102
|
+
}, [p(E(R), {
|
|
3103
|
+
class: "find-bar__chevron",
|
|
3104
|
+
size: 14
|
|
3105
|
+
})], 10, os)), d("div", ss, [d("div", cs, [
|
|
3106
|
+
p(E(P), {
|
|
3107
|
+
ref_key: "searchInput",
|
|
3108
|
+
ref: o,
|
|
3109
|
+
modelValue: s.value,
|
|
3110
|
+
"onUpdate:modelValue": n[1] ||= (e) => s.value = e,
|
|
3111
|
+
class: "find-bar__input",
|
|
3112
|
+
size: "small",
|
|
3113
|
+
placeholder: E($)("editor.search.placeholder"),
|
|
3114
|
+
ariaLabel: E($)("editor.search.placeholder"),
|
|
3115
|
+
onKeydown: w
|
|
3116
|
+
}, {
|
|
3117
|
+
suffix: k(() => [d("span", ls, T(h.value.current) + "/" + T(h.value.total), 1)]),
|
|
3118
|
+
_: 1
|
|
3119
|
+
}, 8, [
|
|
3120
|
+
"modelValue",
|
|
3121
|
+
"placeholder",
|
|
3122
|
+
"ariaLabel"
|
|
3123
|
+
]),
|
|
3124
|
+
d("button", {
|
|
3125
|
+
type: "button",
|
|
3126
|
+
class: v(["doc-tb-button", { "is-active": f.value }]),
|
|
3127
|
+
title: E($)("editor.search.caseSensitive"),
|
|
3128
|
+
"aria-label": E($)("editor.search.caseSensitive"),
|
|
3129
|
+
"aria-pressed": f.value,
|
|
3130
|
+
onClick: n[2] ||= (e) => f.value = !f.value
|
|
3131
|
+
}, [p(E(he), { size: 16 })], 10, us),
|
|
3132
|
+
d("button", {
|
|
3133
|
+
type: "button",
|
|
3134
|
+
class: v(["doc-tb-button", { "is-active": m.value }]),
|
|
3135
|
+
title: E($)("editor.search.wholeWord"),
|
|
3136
|
+
"aria-label": E($)("editor.search.wholeWord"),
|
|
3137
|
+
"aria-pressed": m.value,
|
|
3138
|
+
onClick: n[3] ||= (e) => m.value = !m.value
|
|
3139
|
+
}, [p(E(bt), { size: 16 })], 10, ds),
|
|
3140
|
+
d("button", {
|
|
3141
|
+
type: "button",
|
|
3142
|
+
class: "doc-tb-button",
|
|
3143
|
+
disabled: !h.value.total,
|
|
3144
|
+
title: `${E($)("editor.search.previous")} (${E(bo)("Shift+Enter")})`,
|
|
3145
|
+
"aria-label": E($)("editor.search.previous"),
|
|
3146
|
+
onClick: n[4] ||= (t) => e.engine.search.previous()
|
|
3147
|
+
}, [p(E(ge), { size: 16 })], 8, fs),
|
|
3148
|
+
d("button", {
|
|
3149
|
+
type: "button",
|
|
3150
|
+
class: "doc-tb-button",
|
|
3151
|
+
disabled: !h.value.total,
|
|
3152
|
+
title: `${E($)("editor.search.next")} (Enter)`,
|
|
3153
|
+
"aria-label": E($)("editor.search.next"),
|
|
3154
|
+
onClick: n[5] ||= (t) => e.engine.search.next()
|
|
3155
|
+
}, [p(E(L), { size: 16 })], 8, ps),
|
|
3156
|
+
d("button", {
|
|
3157
|
+
type: "button",
|
|
3158
|
+
class: "doc-tb-button",
|
|
3159
|
+
title: `${E($)("editor.close")} (Esc)`,
|
|
3160
|
+
"aria-label": E($)("editor.close"),
|
|
3161
|
+
onClick: n[6] ||= (e) => i("close")
|
|
3162
|
+
}, [p(E(xt), { size: 16 })], 8, ms)
|
|
3163
|
+
]), a.value && !e.readonly ? (b(), u("div", hs, [
|
|
3164
|
+
p(E(P), {
|
|
3165
|
+
modelValue: c.value,
|
|
3166
|
+
"onUpdate:modelValue": n[7] ||= (e) => c.value = e,
|
|
3167
|
+
class: "find-bar__input",
|
|
3168
|
+
size: "small",
|
|
3169
|
+
placeholder: E($)("editor.replace.placeholder"),
|
|
3170
|
+
ariaLabel: E($)("editor.replace.placeholder"),
|
|
3171
|
+
onKeydown: D
|
|
3172
|
+
}, null, 8, [
|
|
3173
|
+
"modelValue",
|
|
3174
|
+
"placeholder",
|
|
3175
|
+
"ariaLabel"
|
|
3176
|
+
]),
|
|
3177
|
+
d("button", {
|
|
3178
|
+
type: "button",
|
|
3179
|
+
class: "doc-tb-button find-bar__text-button",
|
|
3180
|
+
disabled: !h.value.total,
|
|
3181
|
+
onClick: n[8] ||= (t) => e.engine.replaceMatch(c.value)
|
|
3182
|
+
}, T(E($)("editor.replace.one")), 9, gs),
|
|
3183
|
+
d("button", {
|
|
3184
|
+
type: "button",
|
|
3185
|
+
class: "doc-tb-button find-bar__text-button",
|
|
3186
|
+
disabled: !h.value.total,
|
|
3187
|
+
onClick: n[9] ||= (t) => e.engine.replaceAllMatches(c.value)
|
|
3188
|
+
}, T(E($)("editor.replace.all")), 9, _s)
|
|
3189
|
+
])) : l("", !0)])], 8, as));
|
|
3190
|
+
}
|
|
3191
|
+
}), [["__scopeId", "data-v-4e66f75e"]]), bs = { class: "status-bar" }, xs = {
|
|
3192
|
+
class: "status-bar__info",
|
|
3193
|
+
"aria-live": "polite"
|
|
3194
|
+
}, Ss = { key: 0 }, Cs = { key: 2 }, ws = { class: "status-bar__controls" }, Ts = ["aria-label"], Es = [
|
|
3195
|
+
"title",
|
|
3196
|
+
"aria-label",
|
|
3197
|
+
"aria-checked",
|
|
3198
|
+
"onClick"
|
|
3199
|
+
], Ds = [
|
|
3200
|
+
"disabled",
|
|
3201
|
+
"title",
|
|
3202
|
+
"aria-label"
|
|
3203
|
+
], Os = [
|
|
3204
|
+
"min",
|
|
3205
|
+
"max",
|
|
3206
|
+
"step",
|
|
3207
|
+
"value",
|
|
3208
|
+
"aria-label"
|
|
3209
|
+
], ks = [
|
|
3210
|
+
"disabled",
|
|
3211
|
+
"title",
|
|
3212
|
+
"aria-label"
|
|
3213
|
+
], As = ["title", "aria-label"], js = ["title", "aria-label"], Ms = ["title", "aria-label"], Ns = 100, Ps = /*#__PURE__*/ Vo(/* @__PURE__ */ m({
|
|
3214
|
+
name: "EditorStatusBar",
|
|
3215
|
+
__name: "editor-status-bar",
|
|
3216
|
+
props: /*@__PURE__*/ h({
|
|
3217
|
+
characters: {},
|
|
3218
|
+
currentPage: {},
|
|
3219
|
+
fullscreen: { type: Boolean },
|
|
3220
|
+
maxLength: {},
|
|
3221
|
+
pageCount: {},
|
|
3222
|
+
words: {}
|
|
3223
|
+
}, {
|
|
3224
|
+
zoom: { required: !0 },
|
|
3225
|
+
zoomModifiers: {},
|
|
3226
|
+
viewMode: { required: !0 },
|
|
3227
|
+
viewModeModifiers: {}
|
|
3228
|
+
}),
|
|
3229
|
+
emits: /*@__PURE__*/ h(["fitWidth", "toggleFullscreen"], ["update:zoom", "update:viewMode"]),
|
|
3230
|
+
setup(e, { emit: t }) {
|
|
3231
|
+
D((e) => ({ v5617940e: o }));
|
|
3232
|
+
let n = t, r = ne(e, "zoom"), i = ne(e, "viewMode"), o = (Ns - 30) / 170, s = [{
|
|
3233
|
+
value: "page",
|
|
3234
|
+
icon: Se,
|
|
3235
|
+
label: "editor.view.page"
|
|
3236
|
+
}, {
|
|
3237
|
+
value: "web",
|
|
3238
|
+
icon: $e,
|
|
3239
|
+
label: "editor.view.web"
|
|
3240
|
+
}], f = (e) => {
|
|
3241
|
+
r.value = Math.min(200, Math.max(30, Math.round(e / 10) * 10));
|
|
3242
|
+
}, m = (e) => f(Number(e.target.value));
|
|
3243
|
+
return (t, o) => (b(), u("footer", bs, [d("div", xs, [
|
|
3244
|
+
i.value === "page" ? (b(), u("span", Ss, T(E($)("editor.status.page", {
|
|
3245
|
+
current: e.currentPage,
|
|
3246
|
+
total: e.pageCount
|
|
3247
|
+
})), 1)) : l("", !0),
|
|
3248
|
+
d("span", null, T(E($)("editor.status.words", { count: e.words })), 1),
|
|
3249
|
+
e.maxLength ? (b(), u("span", {
|
|
3250
|
+
key: 1,
|
|
3251
|
+
class: v({ "is-limit": e.characters >= e.maxLength })
|
|
3252
|
+
}, T(e.characters) + " / " + T(e.maxLength), 3)) : (b(), u("span", Cs, T(E($)("editor.status.characters", { count: e.characters })), 1))
|
|
3253
|
+
]), d("div", ws, [
|
|
3254
|
+
d("div", {
|
|
3255
|
+
class: "status-bar__segmented",
|
|
3256
|
+
role: "radiogroup",
|
|
3257
|
+
"aria-label": E($)("editor.view.page")
|
|
3258
|
+
}, [(b(), u(a, null, S(s, (e) => d("button", {
|
|
3259
|
+
key: e.value,
|
|
3260
|
+
type: "button",
|
|
3261
|
+
class: v(["doc-tb-button", { "is-active": i.value === e.value }]),
|
|
3262
|
+
role: "radio",
|
|
3263
|
+
title: E($)(e.label),
|
|
3264
|
+
"aria-label": E($)(e.label),
|
|
3265
|
+
"aria-checked": i.value === e.value,
|
|
3266
|
+
onClick: (t) => i.value = e.value
|
|
3267
|
+
}, [(b(), c(C(e.icon), { size: 14 }))], 10, Es)), 64))], 8, Ts),
|
|
3268
|
+
d("button", {
|
|
3269
|
+
type: "button",
|
|
3270
|
+
class: "doc-tb-button status-bar__zoom-step",
|
|
3271
|
+
disabled: r.value <= E(30),
|
|
3272
|
+
title: E($)("editor.zoomOut"),
|
|
3273
|
+
"aria-label": E($)("editor.zoomOut"),
|
|
3274
|
+
onClick: o[0] ||= (e) => f(r.value - E(10))
|
|
3275
|
+
}, [p(E(Re), { size: 12 })], 8, Ds),
|
|
3276
|
+
d("input", {
|
|
3277
|
+
class: "status-bar__slider",
|
|
3278
|
+
type: "range",
|
|
3279
|
+
min: E(30),
|
|
3280
|
+
max: E(200),
|
|
3281
|
+
step: E(10),
|
|
3282
|
+
value: r.value,
|
|
3283
|
+
"aria-label": E($)("editor.zoom"),
|
|
3284
|
+
onInput: m
|
|
3285
|
+
}, null, 40, Os),
|
|
3286
|
+
d("button", {
|
|
3287
|
+
type: "button",
|
|
3288
|
+
class: "doc-tb-button status-bar__zoom-step",
|
|
3289
|
+
disabled: r.value >= E(200),
|
|
3290
|
+
title: E($)("editor.zoomIn"),
|
|
3291
|
+
"aria-label": E($)("editor.zoomIn"),
|
|
3292
|
+
onClick: o[1] ||= (e) => f(r.value + E(10))
|
|
3293
|
+
}, [p(E(Ge), { size: 12 })], 8, ks),
|
|
3294
|
+
d("button", {
|
|
3295
|
+
type: "button",
|
|
3296
|
+
class: "doc-tb-button status-bar__zoom",
|
|
3297
|
+
title: E($)("editor.zoomReset"),
|
|
3298
|
+
"aria-label": E($)("editor.zoomReset"),
|
|
3299
|
+
onClick: o[2] ||= (e) => f(Ns)
|
|
3300
|
+
}, T(r.value) + "% ", 9, As),
|
|
3301
|
+
i.value === "page" ? (b(), u("button", {
|
|
3302
|
+
key: 0,
|
|
3303
|
+
type: "button",
|
|
3304
|
+
class: "doc-tb-button",
|
|
3305
|
+
title: E($)("editor.fitWidth"),
|
|
3306
|
+
"aria-label": E($)("editor.fitWidth"),
|
|
3307
|
+
onClick: o[3] ||= (e) => n("fitWidth")
|
|
3308
|
+
}, [p(E(ze), { size: 14 })], 8, js)) : l("", !0),
|
|
3309
|
+
d("button", {
|
|
3310
|
+
type: "button",
|
|
3311
|
+
class: "doc-tb-button",
|
|
3312
|
+
title: E($)(e.fullscreen ? "editor.exitFullscreen" : "editor.enterFullscreen"),
|
|
3313
|
+
"aria-label": E($)(e.fullscreen ? "editor.exitFullscreen" : "editor.enterFullscreen"),
|
|
3314
|
+
onClick: o[4] ||= (e) => n("toggleFullscreen")
|
|
3315
|
+
}, [(b(), c(C(e.fullscreen ? E(Le) : E(Ie)), { size: 14 }))], 8, Ms)
|
|
3316
|
+
])]));
|
|
3317
|
+
}
|
|
3318
|
+
}), [["__scopeId", "data-v-3938214e"]]), Fs = { class: "color-picker" }, Is = [
|
|
3319
|
+
"disabled",
|
|
3320
|
+
"title",
|
|
3321
|
+
"aria-label"
|
|
3322
|
+
], Ls = {
|
|
3323
|
+
key: 0,
|
|
3324
|
+
class: "color-picker__letter"
|
|
3325
|
+
}, Rs = ["disabled", "aria-label"], zs = { class: "palette" }, Bs = { class: "palette__grid" }, Vs = [
|
|
3326
|
+
"title",
|
|
3327
|
+
"aria-label",
|
|
3328
|
+
"onClick"
|
|
3329
|
+
], Hs = { class: "palette__custom" }, Us = ["value"], Ws = 236, Gs = /*#__PURE__*/ Vo(/* @__PURE__ */ m({
|
|
3330
|
+
name: "EditorColorPicker",
|
|
3331
|
+
__name: "editor-color-picker",
|
|
3332
|
+
props: {
|
|
3333
|
+
current: {},
|
|
3334
|
+
disabled: { type: Boolean },
|
|
3335
|
+
mode: {}
|
|
3336
|
+
},
|
|
3337
|
+
emits: ["select"],
|
|
3338
|
+
setup(e, { emit: t }) {
|
|
3339
|
+
let n = e, r = t, i = /* @__PURE__ */ "#000000.#434343.#666666.#999999.#b7b7b7.#cccccc.#d9d9d9.#efefef.#f3f3f3.#ffffff.#980000.#ff0000.#ff9900.#ffff00.#00ff00.#00ffff.#4a86e8.#0000ff.#9900ff.#ff00ff.#e6b8af.#f4cccc.#fce5cd.#fff2cc.#d9ead3.#d0e0e3.#c9daf8.#cfe2f3.#d9d2e9.#ead1dc.#dd7e6b.#ea9999.#f9cb9c.#ffe599.#b6d7a8.#a2c4c9.#a4c2f4.#9fc5e8.#b4a7d6.#d5a6bd.#a61c00.#cc0000.#e69138.#f1c232.#6aa84f.#45818e.#3c78d8.#3d85c6.#674ea7.#a64d79.#5b0f00.#660000.#783f04.#7f6000.#274e13.#0c343d.#1c4587.#073763.#20124d.#4c1130".split("."), o = {
|
|
3340
|
+
text: "#cc0000",
|
|
3341
|
+
highlight: "#ffff00"
|
|
3342
|
+
}, s = x(!1), l = x(o[n.mode]), m = $(n.mode === "text" ? "editor.textColor" : "editor.highlight"), h = (e) => {
|
|
3343
|
+
e && (l.value = e), s.value = !1, r("select", e);
|
|
3344
|
+
}, g = (e) => h(e.target.value);
|
|
3345
|
+
return (t, n) => (b(), u("div", Fs, [d("button", {
|
|
3346
|
+
type: "button",
|
|
3347
|
+
class: "doc-tb-button color-picker__apply",
|
|
3348
|
+
disabled: e.disabled,
|
|
3349
|
+
title: E(m),
|
|
3350
|
+
"aria-label": E(m),
|
|
3351
|
+
onMousedown: n[0] ||= A(() => {}, ["prevent"]),
|
|
3352
|
+
onClick: n[1] ||= (e) => h(l.value)
|
|
3353
|
+
}, [e.mode === "text" ? (b(), u("span", Ls, "A")) : (b(), c(E(Ee), {
|
|
3354
|
+
key: 1,
|
|
3355
|
+
size: 15
|
|
3356
|
+
})), d("span", {
|
|
3357
|
+
class: "color-picker__bar",
|
|
3358
|
+
style: y({ background: l.value })
|
|
3359
|
+
}, null, 4)], 40, Is), p(E(I), {
|
|
3360
|
+
visible: s.value,
|
|
3361
|
+
"onUpdate:visible": n[4] ||= (e) => s.value = e,
|
|
3362
|
+
trigger: "click",
|
|
3363
|
+
placement: "bottom-start",
|
|
3364
|
+
"popper-class": "doc-editor-popper",
|
|
3365
|
+
width: Ws,
|
|
3366
|
+
disabled: e.disabled,
|
|
3367
|
+
"show-arrow": !1
|
|
3368
|
+
}, {
|
|
3369
|
+
reference: k(() => [d("button", {
|
|
3370
|
+
type: "button",
|
|
3371
|
+
class: "doc-tb-button doc-tb-button--caret",
|
|
3372
|
+
disabled: e.disabled,
|
|
3373
|
+
"aria-label": E(m),
|
|
3374
|
+
onMousedown: n[2] ||= A(() => {}, ["prevent"])
|
|
3375
|
+
}, [p(E(L), { size: 12 })], 40, Rs)]),
|
|
3376
|
+
default: k(() => [d("div", zs, [
|
|
3377
|
+
d("button", {
|
|
3378
|
+
type: "button",
|
|
3379
|
+
class: "palette__reset",
|
|
3380
|
+
onClick: n[3] ||= (e) => h(null)
|
|
3381
|
+
}, [d("span", { class: v(["palette__reset-swatch", `is-${e.mode}`]) }, null, 2), f(" " + T(E($)(e.mode === "text" ? "editor.colors.automatic" : "editor.colors.none")), 1)]),
|
|
3382
|
+
d("div", Bs, [(b(), u(a, null, S(i, (t) => d("button", {
|
|
3383
|
+
key: t,
|
|
3384
|
+
type: "button",
|
|
3385
|
+
class: v(["palette__swatch", { "is-selected": t === e.current.toLowerCase() }]),
|
|
3386
|
+
style: y({ background: t }),
|
|
3387
|
+
title: t,
|
|
3388
|
+
"aria-label": `${E(m)}: ${t}`,
|
|
3389
|
+
onClick: (e) => h(t)
|
|
3390
|
+
}, null, 14, Vs)), 64))]),
|
|
3391
|
+
d("label", Hs, [d("input", {
|
|
3392
|
+
type: "color",
|
|
3393
|
+
value: l.value,
|
|
3394
|
+
onChange: g
|
|
3395
|
+
}, null, 40, Us), f(" " + T(E($)("editor.colors.custom")), 1)])
|
|
3396
|
+
])]),
|
|
3397
|
+
_: 1
|
|
3398
|
+
}, 8, ["visible", "disabled"])]));
|
|
3399
|
+
}
|
|
3400
|
+
}), [["__scopeId", "data-v-1e543a8f"]]), Ks = { class: "page-setup" }, qs = { class: "page-setup__section" }, Js = { class: "page-setup__grid page-setup__grid--sizes" }, Ys = ["aria-pressed", "onClick"], Xs = { class: "page-setup__section" }, Zs = { class: "page-setup__grid" }, Qs = ["aria-pressed", "onClick"], $s = { class: "page-setup__section" }, ec = { class: "page-setup__grid page-setup__grid--presets" }, tc = ["title", "onClick"], nc = { class: "page-setup__caption" }, rc = { class: "page-setup__grid" }, ic = /*#__PURE__*/ Vo(/* @__PURE__ */ m({
|
|
3401
|
+
name: "EditorPageSetup",
|
|
3402
|
+
__name: "editor-page-setup",
|
|
3403
|
+
props: { page: {} },
|
|
3404
|
+
emits: ["change"],
|
|
3405
|
+
setup(t, { emit: r }) {
|
|
3406
|
+
let o = t, s = r, l = Object.keys(n), m = [{
|
|
3407
|
+
value: "portrait",
|
|
3408
|
+
icon: Ye,
|
|
3409
|
+
label: "editor.page.portrait"
|
|
3410
|
+
}, {
|
|
3411
|
+
value: "landscape",
|
|
3412
|
+
icon: Je,
|
|
3413
|
+
label: "editor.page.landscape"
|
|
3414
|
+
}], h = [
|
|
3415
|
+
{
|
|
3416
|
+
side: "top",
|
|
3417
|
+
label: "editor.page.marginTop"
|
|
3418
|
+
},
|
|
3419
|
+
{
|
|
3420
|
+
side: "bottom",
|
|
3421
|
+
label: "editor.page.marginBottom"
|
|
3422
|
+
},
|
|
3423
|
+
{
|
|
3424
|
+
side: "left",
|
|
3425
|
+
label: "editor.page.marginLeft"
|
|
3426
|
+
},
|
|
3427
|
+
{
|
|
3428
|
+
side: "right",
|
|
3429
|
+
label: "editor.page.marginRight"
|
|
3430
|
+
}
|
|
3431
|
+
], g = {
|
|
3432
|
+
min: 0,
|
|
3433
|
+
max: 100,
|
|
3434
|
+
step: 1,
|
|
3435
|
+
precision: 1
|
|
3436
|
+
}, _ = (e) => s("change", {
|
|
3437
|
+
...o.page,
|
|
3438
|
+
...e
|
|
3439
|
+
}), y = (e) => _({ size: e }), ee = (e) => _({ orientation: e }), te = (e) => _({ margins: { ...e } }), x = (e, t) => _({ margins: {
|
|
3440
|
+
...o.page.margins,
|
|
3441
|
+
[e]: t ?? 0
|
|
3442
|
+
} }), w = ({ top: e, bottom: t, left: n, right: r }) => [
|
|
3443
|
+
`${$("editor.page.marginTop")} ${e}`,
|
|
3444
|
+
`${$("editor.page.marginBottom")} ${t}`,
|
|
3445
|
+
`${$("editor.page.marginLeft")} ${n}`,
|
|
3446
|
+
`${$("editor.page.marginRight")} ${r} mm`
|
|
3447
|
+
].join(" · ");
|
|
3448
|
+
return (r, o) => (b(), u("div", Ks, [
|
|
3449
|
+
d("section", qs, [d("h4", null, T(E($)("editor.page.size")), 1), d("div", Js, [(b(!0), u(a, null, S(E(l), (e) => (b(), u("button", {
|
|
3450
|
+
key: e,
|
|
3451
|
+
type: "button",
|
|
3452
|
+
class: v(["page-setup__chip", { "is-active": t.page.size === e }]),
|
|
3453
|
+
"aria-pressed": t.page.size === e,
|
|
3454
|
+
onClick: (t) => y(e)
|
|
3455
|
+
}, [d("strong", null, T(E(n)[e].label), 1), d("small", null, T(E(n)[e].width) + "×" + T(E(n)[e].height), 1)], 10, Ys))), 128))])]),
|
|
3456
|
+
d("section", Xs, [d("h4", null, T(E($)("editor.page.orientation")), 1), d("div", Zs, [(b(), u(a, null, S(m, (e) => d("button", {
|
|
3457
|
+
key: e.value,
|
|
3458
|
+
type: "button",
|
|
3459
|
+
class: v(["page-setup__chip page-setup__chip--row", { "is-active": t.page.orientation === e.value }]),
|
|
3460
|
+
"aria-pressed": t.page.orientation === e.value,
|
|
3461
|
+
onClick: (t) => ee(e.value)
|
|
3462
|
+
}, [(b(), c(C(e.icon), { size: 16 })), f(" " + T(E($)(e.label)), 1)], 10, Qs)), 64))])]),
|
|
3463
|
+
d("section", $s, [
|
|
3464
|
+
d("h4", null, T(E($)("editor.page.margins")), 1),
|
|
3465
|
+
d("div", ec, [(b(!0), u(a, null, S(E(i), (n) => (b(), u("button", {
|
|
3466
|
+
key: n.key,
|
|
3467
|
+
type: "button",
|
|
3468
|
+
class: v(["page-setup__chip", { "is-active": E(e)(n.margins, t.page.margins) }]),
|
|
3469
|
+
title: w(n.margins),
|
|
3470
|
+
onClick: (e) => te(n.margins)
|
|
3471
|
+
}, T(E($)(`editor.page.margins.${n.key}`)), 11, tc))), 128))]),
|
|
3472
|
+
d("span", nc, T(E($)("editor.page.customMargins")), 1),
|
|
3473
|
+
d("div", rc, [(b(), u(a, null, S(h, (e) => d("label", {
|
|
3474
|
+
key: e.side,
|
|
3475
|
+
class: "page-setup__field"
|
|
3476
|
+
}, [d("span", null, T(E($)(e.label)), 1), p(E(F), {
|
|
3477
|
+
size: "small",
|
|
3478
|
+
"controls-position": "right",
|
|
3479
|
+
"model-value": t.page.margins[e.side],
|
|
3480
|
+
min: g.min,
|
|
3481
|
+
max: g.max,
|
|
3482
|
+
step: g.step,
|
|
3483
|
+
precision: g.precision,
|
|
3484
|
+
onChange: (t) => x(e.side, t)
|
|
3485
|
+
}, null, 8, [
|
|
3486
|
+
"model-value",
|
|
3487
|
+
"min",
|
|
3488
|
+
"max",
|
|
3489
|
+
"step",
|
|
3490
|
+
"precision",
|
|
3491
|
+
"onChange"
|
|
3492
|
+
])])), 64))])
|
|
3493
|
+
])
|
|
3494
|
+
]));
|
|
3495
|
+
}
|
|
3496
|
+
}), [["__scopeId", "data-v-3c249e34"]]), ac = { class: "table-picker" }, oc = [
|
|
3497
|
+
"aria-label",
|
|
3498
|
+
"onMouseenter",
|
|
3499
|
+
"onFocus",
|
|
3500
|
+
"onClick"
|
|
3501
|
+
], sc = { class: "table-picker__size" }, cc = 8, lc = 10, uc = /*#__PURE__*/ Vo(/* @__PURE__ */ m({
|
|
3502
|
+
name: "EditorTablePicker",
|
|
3503
|
+
__name: "editor-table-picker",
|
|
3504
|
+
emits: ["select"],
|
|
3505
|
+
setup(e, { emit: t }) {
|
|
3506
|
+
let n = t, r = {
|
|
3507
|
+
rows: 0,
|
|
3508
|
+
cols: 0
|
|
3509
|
+
}, i = x(r), o = x(!1), c = s(() => i.value.rows ? `${i.value.cols} × ${i.value.rows}` : $("editor.table.pickSize")), l = (e, t) => {
|
|
3510
|
+
i.value = {
|
|
3511
|
+
rows: e,
|
|
3512
|
+
cols: t
|
|
3513
|
+
};
|
|
3514
|
+
}, m = () => {
|
|
3515
|
+
i.value = r;
|
|
3516
|
+
}, h = (e, t) => e <= i.value.rows && t <= i.value.cols, g = (e) => {
|
|
3517
|
+
o.value = e === !0;
|
|
3518
|
+
};
|
|
3519
|
+
return (e, t) => (b(), u("div", ac, [
|
|
3520
|
+
d("div", {
|
|
3521
|
+
class: "table-picker__grid",
|
|
3522
|
+
onMouseleave: m
|
|
3523
|
+
}, [(b(), u(a, null, S(cc, (e) => (b(), u(a, { key: e }, [(b(), u(a, null, S(lc, (t) => d("button", {
|
|
3524
|
+
key: `${e}-${t}`,
|
|
3525
|
+
type: "button",
|
|
3526
|
+
class: v(["table-picker__cell", { "is-active": h(e, t) }]),
|
|
3527
|
+
"aria-label": `${E($)("editor.table.insert")}: ${t} × ${e}`,
|
|
3528
|
+
onMouseenter: (n) => l(e, t),
|
|
3529
|
+
onFocus: (n) => l(e, t),
|
|
3530
|
+
onClick: (r) => n("select", {
|
|
3531
|
+
rows: e,
|
|
3532
|
+
cols: t,
|
|
3533
|
+
withHeaderRow: o.value
|
|
3534
|
+
})
|
|
3535
|
+
}, null, 42, oc)), 64))], 64))), 64))], 32),
|
|
3536
|
+
d("strong", sc, T(c.value), 1),
|
|
3537
|
+
p(E(se), {
|
|
3538
|
+
size: "small",
|
|
3539
|
+
"model-value": o.value,
|
|
3540
|
+
onChange: g
|
|
3541
|
+
}, {
|
|
3542
|
+
default: k(() => [f(T(E($)("editor.table.headerRow")), 1)]),
|
|
3543
|
+
_: 1
|
|
3544
|
+
}, 8, ["model-value"])
|
|
3545
|
+
]));
|
|
3546
|
+
}
|
|
3547
|
+
}), [["__scopeId", "data-v-a07514e8"]]), dc = ["aria-label"], fc = { class: "doc-toolbar__group" }, pc = [
|
|
3548
|
+
"aria-label",
|
|
3549
|
+
"disabled",
|
|
3550
|
+
"title"
|
|
3551
|
+
], mc = [
|
|
3552
|
+
"aria-label",
|
|
3553
|
+
"disabled",
|
|
3554
|
+
"title"
|
|
3555
|
+
], hc = { class: "doc-toolbar__group" }, gc = ["disabled", "title"], _c = { class: "doc-tb-button__label" }, vc = { class: "doc-menu__hint" }, yc = { class: "doc-menu__hint" }, bc = ["disabled", "title"], xc = { class: "doc-tb-button__label" }, Sc = ["disabled", "title"], Cc = { class: "doc-tb-button__label" }, wc = { class: "doc-toolbar__group" }, Tc = [
|
|
3556
|
+
"aria-label",
|
|
3557
|
+
"aria-pressed",
|
|
3558
|
+
"disabled",
|
|
3559
|
+
"title",
|
|
3560
|
+
"onClick"
|
|
3561
|
+
], Ec = [
|
|
3562
|
+
"aria-label",
|
|
3563
|
+
"disabled",
|
|
3564
|
+
"title"
|
|
3565
|
+
], Dc = { class: "doc-menu__hint" }, Oc = { class: "doc-menu__hint" }, kc = { class: "doc-menu__hint" }, Ac = { class: "doc-menu__hint" }, jc = { class: "doc-toolbar__group" }, Mc = [
|
|
3566
|
+
"aria-label",
|
|
3567
|
+
"disabled",
|
|
3568
|
+
"title"
|
|
3569
|
+
], Nc = { class: "doc-menu__hint" }, Pc = [
|
|
3570
|
+
"aria-label",
|
|
3571
|
+
"disabled",
|
|
3572
|
+
"title"
|
|
3573
|
+
], Fc = [
|
|
3574
|
+
"aria-label",
|
|
3575
|
+
"disabled",
|
|
3576
|
+
"title"
|
|
3577
|
+
], Ic = [
|
|
3578
|
+
"aria-label",
|
|
3579
|
+
"aria-pressed",
|
|
3580
|
+
"disabled",
|
|
3581
|
+
"title",
|
|
3582
|
+
"onClick"
|
|
3583
|
+
], Lc = [
|
|
3584
|
+
"aria-label",
|
|
3585
|
+
"disabled",
|
|
3586
|
+
"title"
|
|
3587
|
+
], Rc = [
|
|
3588
|
+
"aria-label",
|
|
3589
|
+
"disabled",
|
|
3590
|
+
"title"
|
|
3591
|
+
], zc = { class: "doc-toolbar__group" }, Bc = [
|
|
3592
|
+
"aria-label",
|
|
3593
|
+
"disabled",
|
|
3594
|
+
"title"
|
|
3595
|
+
], Vc = { key: 0 }, Hc = { class: "doc-toolbar__form-actions" }, Uc = [
|
|
3596
|
+
"aria-label",
|
|
3597
|
+
"disabled",
|
|
3598
|
+
"title"
|
|
3599
|
+
], Wc = { class: "doc-toolbar__form" }, Gc = { class: "doc-toolbar__caption" }, Kc = [
|
|
3600
|
+
"aria-label",
|
|
3601
|
+
"disabled",
|
|
3602
|
+
"title"
|
|
3603
|
+
], qc = [
|
|
3604
|
+
"aria-label",
|
|
3605
|
+
"disabled",
|
|
3606
|
+
"title"
|
|
3607
|
+
], Jc = { class: "doc-toolbar__characters" }, Yc = ["title", "onClick"], Xc = [
|
|
3608
|
+
"aria-label",
|
|
3609
|
+
"disabled",
|
|
3610
|
+
"title"
|
|
3611
|
+
], Zc = { class: "doc-menu__hint" }, Qc = { class: "doc-toolbar__group" }, $c = [
|
|
3612
|
+
"aria-label",
|
|
3613
|
+
"disabled",
|
|
3614
|
+
"title"
|
|
3615
|
+
], el = ["aria-label", "title"], tl = ["aria-label", "title"], nl = { class: "doc-menu__hint" }, rl = "default", il = "Times New Roman", al = 12, ol = .75, sl = 4, cl = /*#__PURE__*/ Vo(/* @__PURE__ */ m({
|
|
3616
|
+
name: "EditorToolbar",
|
|
3617
|
+
__name: "editor-toolbar",
|
|
3618
|
+
props: {
|
|
3619
|
+
disabled: { type: Boolean },
|
|
3620
|
+
engine: {},
|
|
3621
|
+
findOpen: { type: Boolean },
|
|
3622
|
+
fullscreen: { type: Boolean },
|
|
3623
|
+
page: {},
|
|
3624
|
+
sourceMode: { type: Boolean },
|
|
3625
|
+
state: {},
|
|
3626
|
+
uploading: { type: Boolean }
|
|
3627
|
+
},
|
|
3628
|
+
emits: [
|
|
3629
|
+
"find",
|
|
3630
|
+
"insertImages",
|
|
3631
|
+
"menu",
|
|
3632
|
+
"update:page"
|
|
3633
|
+
],
|
|
3634
|
+
setup(e, { expose: t, emit: n }) {
|
|
3635
|
+
let r = e, i = n, o = [
|
|
3636
|
+
{
|
|
3637
|
+
label: "Times New Roman",
|
|
3638
|
+
value: "'Times New Roman', Times, serif"
|
|
3639
|
+
},
|
|
3640
|
+
{
|
|
3641
|
+
label: "Arial",
|
|
3642
|
+
value: "Arial, Helvetica, sans-serif"
|
|
3643
|
+
},
|
|
3644
|
+
{
|
|
3645
|
+
label: "Calibri",
|
|
3646
|
+
value: "Calibri, Carlito, sans-serif"
|
|
3647
|
+
},
|
|
3648
|
+
{
|
|
3649
|
+
label: "Cambria",
|
|
3650
|
+
value: "Cambria, Caladea, serif"
|
|
3651
|
+
},
|
|
3652
|
+
{
|
|
3653
|
+
label: "Georgia",
|
|
3654
|
+
value: "Georgia, serif"
|
|
3655
|
+
},
|
|
3656
|
+
{
|
|
3657
|
+
label: "Tahoma",
|
|
3658
|
+
value: "Tahoma, Verdana, sans-serif"
|
|
3659
|
+
},
|
|
3660
|
+
{
|
|
3661
|
+
label: "Verdana",
|
|
3662
|
+
value: "Verdana, sans-serif"
|
|
3663
|
+
},
|
|
3664
|
+
{
|
|
3665
|
+
label: "Courier New",
|
|
3666
|
+
value: "'Courier New', Courier, monospace"
|
|
3667
|
+
}
|
|
3668
|
+
].map((e) => ({
|
|
3669
|
+
...e,
|
|
3670
|
+
normalized: Zr(e.value)
|
|
3671
|
+
})), m = [
|
|
3672
|
+
8,
|
|
3673
|
+
9,
|
|
3674
|
+
10,
|
|
3675
|
+
11,
|
|
3676
|
+
12,
|
|
3677
|
+
14,
|
|
3678
|
+
16,
|
|
3679
|
+
18,
|
|
3680
|
+
20,
|
|
3681
|
+
24,
|
|
3682
|
+
28,
|
|
3683
|
+
36,
|
|
3684
|
+
48,
|
|
3685
|
+
72
|
|
3686
|
+
], h = [
|
|
3687
|
+
"1",
|
|
3688
|
+
"1.15",
|
|
3689
|
+
"1.5",
|
|
3690
|
+
"2",
|
|
3691
|
+
"2.5",
|
|
3692
|
+
"3"
|
|
3693
|
+
], g = [
|
|
3694
|
+
{
|
|
3695
|
+
value: "left",
|
|
3696
|
+
icon: ft,
|
|
3697
|
+
label: "editor.align.left",
|
|
3698
|
+
shortcut: "Mod+Shift+L"
|
|
3699
|
+
},
|
|
3700
|
+
{
|
|
3701
|
+
value: "center",
|
|
3702
|
+
icon: lt,
|
|
3703
|
+
label: "editor.align.center",
|
|
3704
|
+
shortcut: "Mod+Shift+E"
|
|
3705
|
+
},
|
|
3706
|
+
{
|
|
3707
|
+
value: "right",
|
|
3708
|
+
icon: ut,
|
|
3709
|
+
label: "editor.align.right",
|
|
3710
|
+
shortcut: "Mod+Shift+R"
|
|
3711
|
+
},
|
|
3712
|
+
{
|
|
3713
|
+
value: "justify",
|
|
3714
|
+
icon: dt,
|
|
3715
|
+
label: "editor.align.justify",
|
|
3716
|
+
shortcut: "Mod+Shift+J"
|
|
3717
|
+
}
|
|
3718
|
+
], _ = [
|
|
3719
|
+
{
|
|
3720
|
+
value: "auto",
|
|
3721
|
+
icon: ke,
|
|
3722
|
+
label: "editor.direction.auto"
|
|
3723
|
+
},
|
|
3724
|
+
{
|
|
3725
|
+
value: "ltr",
|
|
3726
|
+
icon: We,
|
|
3727
|
+
label: "editor.direction.ltr"
|
|
3728
|
+
},
|
|
3729
|
+
{
|
|
3730
|
+
value: "rtl",
|
|
3731
|
+
icon: Ue,
|
|
3732
|
+
label: "editor.direction.rtl"
|
|
3733
|
+
}
|
|
3734
|
+
], ee = [
|
|
3735
|
+
{
|
|
3736
|
+
key: "bold",
|
|
3737
|
+
icon: pe,
|
|
3738
|
+
label: "editor.bold",
|
|
3739
|
+
shortcut: "Mod+B",
|
|
3740
|
+
toggle: (e) => e.toggleMark("bold")
|
|
3741
|
+
},
|
|
3742
|
+
{
|
|
3743
|
+
key: "italic",
|
|
3744
|
+
icon: Oe,
|
|
3745
|
+
label: "editor.italic",
|
|
3746
|
+
shortcut: "Mod+I",
|
|
3747
|
+
toggle: (e) => e.toggleMark("italic")
|
|
3748
|
+
},
|
|
3749
|
+
{
|
|
3750
|
+
key: "underline",
|
|
3751
|
+
icon: ht,
|
|
3752
|
+
label: "editor.underline",
|
|
3753
|
+
shortcut: "Mod+U",
|
|
3754
|
+
toggle: (e) => e.toggleMark("underline")
|
|
3755
|
+
}
|
|
3756
|
+
], te = [
|
|
3757
|
+
{
|
|
3758
|
+
key: "bulletList",
|
|
3759
|
+
icon: je,
|
|
3760
|
+
label: "editor.bulletList",
|
|
3761
|
+
shortcut: "Mod+Shift+8",
|
|
3762
|
+
toggle: (e) => e.toggleList("bulletList")
|
|
3763
|
+
},
|
|
3764
|
+
{
|
|
3765
|
+
key: "orderedList",
|
|
3766
|
+
icon: Pe,
|
|
3767
|
+
label: "editor.orderedList",
|
|
3768
|
+
shortcut: "Mod+Shift+7",
|
|
3769
|
+
toggle: (e) => e.toggleList("orderedList")
|
|
3770
|
+
},
|
|
3771
|
+
{
|
|
3772
|
+
key: "taskList",
|
|
3773
|
+
icon: Fe,
|
|
3774
|
+
label: "editor.taskList",
|
|
3775
|
+
shortcut: "Mod+Shift+9",
|
|
3776
|
+
toggle: (e) => e.toggleList("taskList")
|
|
3777
|
+
}
|
|
3778
|
+
], w = [
|
|
3779
|
+
"strike",
|
|
3780
|
+
"subscript",
|
|
3781
|
+
"superscript",
|
|
3782
|
+
"code"
|
|
3783
|
+
], D = /* @__PURE__ */ "«.».„.“.”.‘.’.—.–.….№.§.©.®.™.°.±.×.÷.≈.≠.≤.≥.∞.€.$.£.¥.←.→.↑.↓.•.✓.✗.¶".split("."), ne = /^(https?:|mailto:|tel:|\/|#)/i, re = /^[^\s@]+@[^\s@]+\.[^\s@]+$/, ie = /^(https?:\/\/|\/)/i, O = x(!1), ae = x(), F = x(""), ce = x(""), le = x(!1), ue = x(!1), de = x(!1), fe = x(""), he = x(), R = x(!1), ge = x(!1), z = s(() => r.disabled || r.sourceMode), ve = s(() => r.state.headingLevel ? $("editor.heading", { level: r.state.headingLevel }) : r.state.codeBlock ? $("editor.codeBlock") : r.state.blockquote ? $("editor.quote") : $("editor.paragraph")), Se = s(() => {
|
|
3784
|
+
let e = r.state.fontFamily;
|
|
3785
|
+
return e ? o.find((t) => t.normalized === e)?.label ?? (e.split(",")[0] ?? e).trim() : il;
|
|
3786
|
+
}), we = s(() => {
|
|
3787
|
+
let e = Number.parseFloat(r.state.fontSize);
|
|
3788
|
+
if (!Number.isFinite(e)) return String(al);
|
|
3789
|
+
let t = r.state.fontSize.endsWith("px") ? e * ol : e;
|
|
3790
|
+
return String(Math.round(t * 2) / 2);
|
|
3791
|
+
}), Ee = s(() => g.find((e) => e.value === r.state.align)?.icon ?? ft), Re = s(() => _.find((e) => e.value === r.state.direction)?.icon ?? ke), ze = (e) => {
|
|
3792
|
+
switch (e) {
|
|
3793
|
+
case "paragraph":
|
|
3794
|
+
r.engine.setBlockType("P");
|
|
3795
|
+
break;
|
|
3796
|
+
case "blockquote":
|
|
3797
|
+
r.engine.toggleBlockquote();
|
|
3798
|
+
break;
|
|
3799
|
+
case "codeBlock":
|
|
3800
|
+
r.engine.toggleCodeBlock();
|
|
3801
|
+
break;
|
|
3802
|
+
default: r.engine.setBlockType(`H${Number(e)}`);
|
|
3803
|
+
}
|
|
3804
|
+
}, Ve = (e) => {
|
|
3805
|
+
let t = String(e);
|
|
3806
|
+
r.engine.setTextStyle("fontFamily", t === rl ? null : t);
|
|
3807
|
+
}, He = (e) => {
|
|
3808
|
+
let t = String(e);
|
|
3809
|
+
r.engine.setTextStyle("fontSize", t === rl ? null : `${t}pt`);
|
|
3810
|
+
}, Je = (e) => {
|
|
3811
|
+
let t = String(e);
|
|
3812
|
+
r.engine.setLineHeight(t === rl ? null : t);
|
|
3813
|
+
}, Ye = (e) => r.engine.setTextAlign(String(e)), Qe = (e) => r.engine.setTextDirection(String(e)), $e = (e) => {
|
|
3814
|
+
w.includes(e) ? r.engine.toggleMark(e) : r.engine.clearFormatting();
|
|
3815
|
+
}, st = () => {
|
|
3816
|
+
let e = /* @__PURE__ */ new Date(), t = (e) => String(e).padStart(2, "0");
|
|
3817
|
+
return `${t(e.getDate())}.${t(e.getMonth() + 1)}.${e.getFullYear()}`;
|
|
3818
|
+
}, ct = (e) => {
|
|
3819
|
+
switch (e) {
|
|
3820
|
+
case "pageBreak":
|
|
3821
|
+
r.engine.insertPageBreak();
|
|
3822
|
+
break;
|
|
3823
|
+
case "date":
|
|
3824
|
+
r.engine.insertText(st());
|
|
3825
|
+
break;
|
|
3826
|
+
default: r.engine.insertHorizontalRule();
|
|
3827
|
+
}
|
|
3828
|
+
}, pt = (e) => i("menu", e), mt = () => {
|
|
3829
|
+
let e = r.engine.getActiveLink();
|
|
3830
|
+
F.value = e?.getAttribute("href") ?? "", le.value = e?.getAttribute("target") === "_blank", ue.value = !e && !r.engine.getSelectedText(), ce.value = "";
|
|
3831
|
+
}, vt = () => {
|
|
3832
|
+
z.value || (O.value = !0);
|
|
3833
|
+
}, bt = (e) => {
|
|
3834
|
+
let t = e.trim();
|
|
3835
|
+
return !t || ne.test(t) ? t : re.test(t) ? `mailto:${t}` : `https://${t}`;
|
|
3836
|
+
}, xt = (e) => {
|
|
3837
|
+
le.value = !!e;
|
|
3838
|
+
}, St = () => {
|
|
3839
|
+
O.value = !1, r.engine.unsetLink();
|
|
3840
|
+
}, Ct = () => {
|
|
3841
|
+
let e = bt(F.value);
|
|
3842
|
+
if (!e) return St();
|
|
3843
|
+
O.value = !1, r.engine.setLink(e, le.value ? "_blank" : null, ue.value ? ce.value.trim() : void 0);
|
|
3844
|
+
}, wt = () => {
|
|
3845
|
+
de.value = !1, he.value?.click();
|
|
3846
|
+
}, Tt = (e) => {
|
|
3847
|
+
let t = e.target, n = Array.from(t.files ?? []);
|
|
3848
|
+
t.value = "", n.length && i("insertImages", n);
|
|
3849
|
+
}, Et = () => {
|
|
3850
|
+
let e = fe.value.trim();
|
|
3851
|
+
ie.test(e) && (de.value = !1, fe.value = "", r.engine.insertImage(e));
|
|
3852
|
+
}, Dt = (e) => {
|
|
3853
|
+
R.value = !1, r.engine.insertTable(e.rows, e.cols, e.withHeaderRow);
|
|
3854
|
+
}, Ot = (e) => {
|
|
3855
|
+
ge.value = !1, r.engine.insertText(e);
|
|
3856
|
+
};
|
|
3857
|
+
return t({ openLink: vt }), (t, n) => (b(), u("div", {
|
|
3858
|
+
class: "doc-toolbar",
|
|
3859
|
+
role: "toolbar",
|
|
3860
|
+
"aria-label": E($)("editor.toolbar")
|
|
3861
|
+
}, [
|
|
3862
|
+
d("div", fc, [d("button", {
|
|
3863
|
+
type: "button",
|
|
3864
|
+
class: "doc-tb-button",
|
|
3865
|
+
"aria-label": E($)("editor.undo"),
|
|
3866
|
+
disabled: z.value || !e.state.canUndo,
|
|
3867
|
+
title: E(xo)("editor.undo", "Mod+Z"),
|
|
3868
|
+
onMousedown: n[0] ||= A(() => {}, ["prevent"]),
|
|
3869
|
+
onClick: n[1] ||= (t) => e.engine.undo()
|
|
3870
|
+
}, [p(E(gt), { size: 16 })], 40, pc), d("button", {
|
|
3871
|
+
type: "button",
|
|
3872
|
+
class: "doc-tb-button",
|
|
3873
|
+
"aria-label": E($)("editor.redo"),
|
|
3874
|
+
disabled: z.value || !e.state.canRedo,
|
|
3875
|
+
title: E(xo)("editor.redo", "Mod+Y"),
|
|
3876
|
+
onMousedown: n[2] ||= A(() => {}, ["prevent"]),
|
|
3877
|
+
onClick: n[3] ||= (t) => e.engine.redo()
|
|
3878
|
+
}, [p(E(Xe), { size: 16 })], 40, mc)]),
|
|
3879
|
+
n[38] ||= d("span", { class: "doc-toolbar__divider" }, null, -1),
|
|
3880
|
+
d("div", hc, [
|
|
3881
|
+
p(E(j), {
|
|
3882
|
+
"popper-class": "doc-editor-popper",
|
|
3883
|
+
trigger: "click",
|
|
3884
|
+
disabled: z.value,
|
|
3885
|
+
onCommand: ze
|
|
3886
|
+
}, {
|
|
3887
|
+
dropdown: k(() => [p(E(N), { class: "doc-menu" }, {
|
|
3888
|
+
default: k(() => [
|
|
3889
|
+
p(E(M), {
|
|
3890
|
+
command: "paragraph",
|
|
3891
|
+
class: v({ "is-selected": !e.state.headingLevel && !e.state.codeBlock && !e.state.blockquote })
|
|
3892
|
+
}, {
|
|
3893
|
+
default: k(() => [f(T(E($)("editor.paragraph")) + " ", 1), d("span", vc, T(E(bo)("Mod+Alt+0")), 1)]),
|
|
3894
|
+
_: 1
|
|
3895
|
+
}, 8, ["class"]),
|
|
3896
|
+
(b(), u(a, null, S(sl, (t) => p(E(M), {
|
|
3897
|
+
key: t,
|
|
3898
|
+
class: v({ "is-selected": e.state.headingLevel === t }),
|
|
3899
|
+
command: t
|
|
3900
|
+
}, {
|
|
3901
|
+
default: k(() => [d("span", { class: v(`doc-menu__h${t}`) }, T(E($)("editor.heading", { level: t })), 3), d("span", yc, T(E(bo)(`Mod+Alt+${t}`)), 1)]),
|
|
3902
|
+
_: 2
|
|
3903
|
+
}, 1032, ["class", "command"])), 64)),
|
|
3904
|
+
p(E(M), {
|
|
3905
|
+
command: "blockquote",
|
|
3906
|
+
divided: "",
|
|
3907
|
+
class: v({ "is-selected": e.state.blockquote })
|
|
3908
|
+
}, {
|
|
3909
|
+
default: k(() => [p(E(qe), { size: 14 }), f(" " + T(E($)("editor.quote")), 1)]),
|
|
3910
|
+
_: 1
|
|
3911
|
+
}, 8, ["class"]),
|
|
3912
|
+
p(E(M), {
|
|
3913
|
+
command: "codeBlock",
|
|
3914
|
+
class: v({ "is-selected": e.state.codeBlock })
|
|
3915
|
+
}, {
|
|
3916
|
+
default: k(() => [p(E(nt), { size: 14 }), f(" " + T(E($)("editor.codeBlock")), 1)]),
|
|
3917
|
+
_: 1
|
|
3918
|
+
}, 8, ["class"])
|
|
3919
|
+
]),
|
|
3920
|
+
_: 1
|
|
3921
|
+
})]),
|
|
3922
|
+
default: k(() => [d("button", {
|
|
3923
|
+
type: "button",
|
|
3924
|
+
class: "doc-tb-button doc-tb-button--select doc-toolbar__block",
|
|
3925
|
+
disabled: z.value,
|
|
3926
|
+
title: E($)("editor.textStyle"),
|
|
3927
|
+
onMousedown: n[4] ||= A(() => {}, ["prevent"])
|
|
3928
|
+
}, [d("span", _c, T(ve.value), 1), p(E(L), { size: 12 })], 40, gc)]),
|
|
3929
|
+
_: 1
|
|
3930
|
+
}, 8, ["disabled"]),
|
|
3931
|
+
p(E(j), {
|
|
3932
|
+
"max-height": "320px",
|
|
3933
|
+
"popper-class": "doc-editor-popper",
|
|
3934
|
+
trigger: "click",
|
|
3935
|
+
disabled: z.value,
|
|
3936
|
+
onCommand: Ve
|
|
3937
|
+
}, {
|
|
3938
|
+
dropdown: k(() => [p(E(N), { class: "doc-menu" }, {
|
|
3939
|
+
default: k(() => [p(E(M), {
|
|
3940
|
+
class: v({ "is-selected": !e.state.fontFamily }),
|
|
3941
|
+
command: rl
|
|
3942
|
+
}, {
|
|
3943
|
+
default: k(() => [f(T(E($)("editor.defaultFont")), 1)]),
|
|
3944
|
+
_: 1
|
|
3945
|
+
}, 8, ["class"]), (b(!0), u(a, null, S(E(o), (t) => (b(), c(E(M), {
|
|
3946
|
+
key: t.value,
|
|
3947
|
+
class: v({ "is-selected": e.state.fontFamily === t.normalized }),
|
|
3948
|
+
command: t.value,
|
|
3949
|
+
style: y({ fontFamily: t.value })
|
|
3950
|
+
}, {
|
|
3951
|
+
default: k(() => [f(T(t.label), 1)]),
|
|
3952
|
+
_: 2
|
|
3953
|
+
}, 1032, [
|
|
3954
|
+
"class",
|
|
3955
|
+
"command",
|
|
3956
|
+
"style"
|
|
3957
|
+
]))), 128))]),
|
|
3958
|
+
_: 1
|
|
3959
|
+
})]),
|
|
3960
|
+
default: k(() => [d("button", {
|
|
3961
|
+
type: "button",
|
|
3962
|
+
class: "doc-tb-button doc-tb-button--select doc-toolbar__font",
|
|
3963
|
+
disabled: z.value,
|
|
3964
|
+
title: E($)("editor.fontFamily"),
|
|
3965
|
+
onMousedown: n[5] ||= A(() => {}, ["prevent"])
|
|
3966
|
+
}, [d("span", xc, T(Se.value), 1), p(E(L), { size: 12 })], 40, bc)]),
|
|
3967
|
+
_: 1
|
|
3968
|
+
}, 8, ["disabled"]),
|
|
3969
|
+
p(E(j), {
|
|
3970
|
+
"max-height": "320px",
|
|
3971
|
+
"popper-class": "doc-editor-popper",
|
|
3972
|
+
trigger: "click",
|
|
3973
|
+
disabled: z.value,
|
|
3974
|
+
onCommand: He
|
|
3975
|
+
}, {
|
|
3976
|
+
dropdown: k(() => [p(E(N), { class: "doc-menu doc-toolbar__size-menu" }, {
|
|
3977
|
+
default: k(() => [p(E(M), {
|
|
3978
|
+
class: v({ "is-selected": !e.state.fontSize }),
|
|
3979
|
+
command: rl
|
|
3980
|
+
}, {
|
|
3981
|
+
default: k(() => [f(T(E($)("editor.defaultSize")), 1)]),
|
|
3982
|
+
_: 1
|
|
3983
|
+
}, 8, ["class"]), (b(), u(a, null, S(m, (t) => p(E(M), {
|
|
3984
|
+
key: t,
|
|
3985
|
+
class: v({ "is-selected": e.state.fontSize === `${t}pt` }),
|
|
3986
|
+
command: t
|
|
3987
|
+
}, {
|
|
3988
|
+
default: k(() => [f(T(t), 1)]),
|
|
3989
|
+
_: 2
|
|
3990
|
+
}, 1032, ["class", "command"])), 64))]),
|
|
3991
|
+
_: 1
|
|
3992
|
+
})]),
|
|
3993
|
+
default: k(() => [d("button", {
|
|
3994
|
+
type: "button",
|
|
3995
|
+
class: "doc-tb-button doc-tb-button--select doc-toolbar__size",
|
|
3996
|
+
disabled: z.value,
|
|
3997
|
+
title: E($)("editor.fontSize"),
|
|
3998
|
+
onMousedown: n[6] ||= A(() => {}, ["prevent"])
|
|
3999
|
+
}, [d("span", Cc, T(we.value), 1), p(E(L), { size: 12 })], 40, Sc)]),
|
|
4000
|
+
_: 1
|
|
4001
|
+
}, 8, ["disabled"])
|
|
4002
|
+
]),
|
|
4003
|
+
n[39] ||= d("span", { class: "doc-toolbar__divider" }, null, -1),
|
|
4004
|
+
d("div", wc, [
|
|
4005
|
+
(b(), u(a, null, S(ee, (t) => d("button", {
|
|
4006
|
+
key: t.key,
|
|
4007
|
+
type: "button",
|
|
4008
|
+
class: v(["doc-tb-button", { "is-active": e.state[t.key] }]),
|
|
4009
|
+
"aria-label": E($)(t.label),
|
|
4010
|
+
"aria-pressed": e.state[t.key],
|
|
4011
|
+
disabled: z.value,
|
|
4012
|
+
title: E(xo)(t.label, t.shortcut),
|
|
4013
|
+
onMousedown: n[7] ||= A(() => {}, ["prevent"]),
|
|
4014
|
+
onClick: (n) => t.toggle(e.engine)
|
|
4015
|
+
}, [(b(), c(C(t.icon), { size: 16 }))], 42, Tc)), 64)),
|
|
4016
|
+
p(E(j), {
|
|
4017
|
+
"popper-class": "doc-editor-popper",
|
|
4018
|
+
trigger: "click",
|
|
4019
|
+
disabled: z.value,
|
|
4020
|
+
onCommand: $e
|
|
4021
|
+
}, {
|
|
4022
|
+
dropdown: k(() => [p(E(N), { class: "doc-menu" }, {
|
|
4023
|
+
default: k(() => [
|
|
4024
|
+
p(E(M), {
|
|
4025
|
+
command: "strike",
|
|
4026
|
+
class: v({ "is-selected": e.state.strike })
|
|
4027
|
+
}, {
|
|
4028
|
+
default: k(() => [
|
|
4029
|
+
p(E(it), { size: 14 }),
|
|
4030
|
+
f(" " + T(E($)("editor.strike")) + " ", 1),
|
|
4031
|
+
d("span", Dc, T(E(bo)("Mod+Shift+S")), 1)
|
|
4032
|
+
]),
|
|
4033
|
+
_: 1
|
|
4034
|
+
}, 8, ["class"]),
|
|
4035
|
+
p(E(M), {
|
|
4036
|
+
command: "subscript",
|
|
4037
|
+
class: v({ "is-selected": e.state.subscript })
|
|
4038
|
+
}, {
|
|
4039
|
+
default: k(() => [
|
|
4040
|
+
p(E(at), { size: 14 }),
|
|
4041
|
+
f(" " + T(E($)("editor.subscript")) + " ", 1),
|
|
4042
|
+
d("span", Oc, T(E(bo)("Mod+,")), 1)
|
|
4043
|
+
]),
|
|
4044
|
+
_: 1
|
|
4045
|
+
}, 8, ["class"]),
|
|
4046
|
+
p(E(M), {
|
|
4047
|
+
command: "superscript",
|
|
4048
|
+
class: v({ "is-selected": e.state.superscript })
|
|
4049
|
+
}, {
|
|
4050
|
+
default: k(() => [
|
|
4051
|
+
p(E(ot), { size: 14 }),
|
|
4052
|
+
f(" " + T(E($)("editor.superscript")) + " ", 1),
|
|
4053
|
+
d("span", kc, T(E(bo)("Mod+.")), 1)
|
|
4054
|
+
]),
|
|
4055
|
+
_: 1
|
|
4056
|
+
}, 8, ["class"]),
|
|
4057
|
+
p(E(M), {
|
|
4058
|
+
command: "code",
|
|
4059
|
+
class: v({ "is-selected": e.state.code })
|
|
4060
|
+
}, {
|
|
4061
|
+
default: k(() => [
|
|
4062
|
+
p(E(_e), { size: 14 }),
|
|
4063
|
+
f(" " + T(E($)("editor.inlineCode")) + " ", 1),
|
|
4064
|
+
d("span", Ac, T(E(bo)("Mod+E")), 1)
|
|
4065
|
+
]),
|
|
4066
|
+
_: 1
|
|
4067
|
+
}, 8, ["class"]),
|
|
4068
|
+
p(E(M), {
|
|
4069
|
+
command: "clear",
|
|
4070
|
+
divided: ""
|
|
4071
|
+
}, {
|
|
4072
|
+
default: k(() => [p(E(Ze), { size: 14 }), f(" " + T(E($)("editor.clearFormatting")), 1)]),
|
|
4073
|
+
_: 1
|
|
4074
|
+
})
|
|
4075
|
+
]),
|
|
4076
|
+
_: 1
|
|
4077
|
+
})]),
|
|
4078
|
+
default: k(() => [d("button", {
|
|
4079
|
+
type: "button",
|
|
4080
|
+
class: v(["doc-tb-button doc-tb-button--caret", { "is-active": e.state.strike || e.state.subscript || e.state.superscript || e.state.code }]),
|
|
4081
|
+
"aria-label": E($)("editor.moreFormatting"),
|
|
4082
|
+
disabled: z.value,
|
|
4083
|
+
title: E($)("editor.moreFormatting"),
|
|
4084
|
+
onMousedown: n[8] ||= A(() => {}, ["prevent"])
|
|
4085
|
+
}, [p(E(L), { size: 12 })], 42, Ec)]),
|
|
4086
|
+
_: 1
|
|
4087
|
+
}, 8, ["disabled"]),
|
|
4088
|
+
p(Gs, {
|
|
4089
|
+
mode: "text",
|
|
4090
|
+
current: e.state.color,
|
|
4091
|
+
disabled: z.value,
|
|
4092
|
+
onSelect: n[9] ||= (t) => e.engine.setTextStyle("color", t)
|
|
4093
|
+
}, null, 8, ["current", "disabled"]),
|
|
4094
|
+
p(Gs, {
|
|
4095
|
+
mode: "highlight",
|
|
4096
|
+
current: e.state.highlight,
|
|
4097
|
+
disabled: z.value,
|
|
4098
|
+
onSelect: n[10] ||= (t) => e.engine.setHighlight(t)
|
|
4099
|
+
}, null, 8, ["current", "disabled"])
|
|
4100
|
+
]),
|
|
4101
|
+
n[40] ||= d("span", { class: "doc-toolbar__divider" }, null, -1),
|
|
4102
|
+
d("div", jc, [
|
|
4103
|
+
p(E(j), {
|
|
4104
|
+
"popper-class": "doc-editor-popper",
|
|
4105
|
+
trigger: "click",
|
|
4106
|
+
disabled: z.value,
|
|
4107
|
+
onCommand: Ye
|
|
4108
|
+
}, {
|
|
4109
|
+
dropdown: k(() => [p(E(N), { class: "doc-menu" }, {
|
|
4110
|
+
default: k(() => [(b(), u(a, null, S(g, (t) => p(E(M), {
|
|
4111
|
+
key: t.value,
|
|
4112
|
+
class: v({ "is-selected": e.state.align === t.value }),
|
|
4113
|
+
command: t.value
|
|
4114
|
+
}, {
|
|
4115
|
+
default: k(() => [
|
|
4116
|
+
(b(), c(C(t.icon), { size: 14 })),
|
|
4117
|
+
f(" " + T(E($)(t.label)) + " ", 1),
|
|
4118
|
+
d("span", Nc, T(E(bo)(t.shortcut)), 1)
|
|
4119
|
+
]),
|
|
4120
|
+
_: 2
|
|
4121
|
+
}, 1032, ["class", "command"])), 64))]),
|
|
4122
|
+
_: 1
|
|
4123
|
+
})]),
|
|
4124
|
+
default: k(() => [d("button", {
|
|
4125
|
+
type: "button",
|
|
4126
|
+
class: "doc-tb-button doc-tb-button--select",
|
|
4127
|
+
"aria-label": E($)("editor.align"),
|
|
4128
|
+
disabled: z.value,
|
|
4129
|
+
title: E($)("editor.align"),
|
|
4130
|
+
onMousedown: n[11] ||= A(() => {}, ["prevent"])
|
|
4131
|
+
}, [(b(), c(C(Ee.value), { size: 16 })), p(E(L), { size: 12 })], 40, Mc)]),
|
|
4132
|
+
_: 1
|
|
4133
|
+
}, 8, ["disabled"]),
|
|
4134
|
+
p(E(j), {
|
|
4135
|
+
"popper-class": "doc-editor-popper",
|
|
4136
|
+
trigger: "click",
|
|
4137
|
+
disabled: z.value,
|
|
4138
|
+
onCommand: Je
|
|
4139
|
+
}, {
|
|
4140
|
+
dropdown: k(() => [p(E(N), { class: "doc-menu" }, {
|
|
4141
|
+
default: k(() => [p(E(M), {
|
|
4142
|
+
class: v({ "is-selected": !e.state.lineHeight }),
|
|
4143
|
+
command: rl
|
|
4144
|
+
}, {
|
|
4145
|
+
default: k(() => [f(T(E($)("editor.defaultLineHeight")), 1)]),
|
|
4146
|
+
_: 1
|
|
4147
|
+
}, 8, ["class"]), (b(), u(a, null, S(h, (t) => p(E(M), {
|
|
4148
|
+
key: t,
|
|
4149
|
+
class: v({ "is-selected": e.state.lineHeight === t }),
|
|
4150
|
+
command: t
|
|
4151
|
+
}, {
|
|
4152
|
+
default: k(() => [f(T(t), 1)]),
|
|
4153
|
+
_: 2
|
|
4154
|
+
}, 1032, ["class", "command"])), 64))]),
|
|
4155
|
+
_: 1
|
|
4156
|
+
})]),
|
|
4157
|
+
default: k(() => [d("button", {
|
|
4158
|
+
type: "button",
|
|
4159
|
+
class: "doc-tb-button doc-tb-button--select",
|
|
4160
|
+
"aria-label": E($)("editor.lineHeight"),
|
|
4161
|
+
disabled: z.value,
|
|
4162
|
+
title: E($)("editor.lineHeight"),
|
|
4163
|
+
onMousedown: n[12] ||= A(() => {}, ["prevent"])
|
|
4164
|
+
}, [p(E(_t), { size: 16 }), p(E(L), { size: 12 })], 40, Pc)]),
|
|
4165
|
+
_: 1
|
|
4166
|
+
}, 8, ["disabled"]),
|
|
4167
|
+
p(E(j), {
|
|
4168
|
+
"popper-class": "doc-editor-popper",
|
|
4169
|
+
trigger: "click",
|
|
4170
|
+
disabled: z.value,
|
|
4171
|
+
onCommand: Qe
|
|
4172
|
+
}, {
|
|
4173
|
+
dropdown: k(() => [p(E(N), { class: "doc-menu" }, {
|
|
4174
|
+
default: k(() => [(b(), u(a, null, S(_, (t) => p(E(M), {
|
|
4175
|
+
key: t.value,
|
|
4176
|
+
class: v({ "is-selected": e.state.direction === t.value }),
|
|
4177
|
+
command: t.value
|
|
4178
|
+
}, {
|
|
4179
|
+
default: k(() => [(b(), c(C(t.icon), { size: 14 })), f(" " + T(E($)(t.label)), 1)]),
|
|
4180
|
+
_: 2
|
|
4181
|
+
}, 1032, ["class", "command"])), 64))]),
|
|
4182
|
+
_: 1
|
|
4183
|
+
})]),
|
|
4184
|
+
default: k(() => [d("button", {
|
|
4185
|
+
type: "button",
|
|
4186
|
+
class: "doc-tb-button doc-tb-button--select",
|
|
4187
|
+
"aria-label": E($)("editor.textDirection"),
|
|
4188
|
+
disabled: z.value,
|
|
4189
|
+
title: E($)("editor.textDirection"),
|
|
4190
|
+
onMousedown: n[13] ||= A(() => {}, ["prevent"])
|
|
4191
|
+
}, [(b(), c(C(Re.value), { size: 16 })), p(E(L), { size: 12 })], 40, Fc)]),
|
|
4192
|
+
_: 1
|
|
4193
|
+
}, 8, ["disabled"]),
|
|
4194
|
+
(b(), u(a, null, S(te, (t) => d("button", {
|
|
4195
|
+
key: t.key,
|
|
4196
|
+
type: "button",
|
|
4197
|
+
class: v(["doc-tb-button", { "is-active": e.state[t.key] }]),
|
|
4198
|
+
"aria-label": E($)(t.label),
|
|
4199
|
+
"aria-pressed": e.state[t.key],
|
|
4200
|
+
disabled: z.value,
|
|
4201
|
+
title: E(xo)(t.label, t.shortcut),
|
|
4202
|
+
onMousedown: n[14] ||= A(() => {}, ["prevent"]),
|
|
4203
|
+
onClick: (n) => t.toggle(e.engine)
|
|
4204
|
+
}, [(b(), c(C(t.icon), { size: 16 }))], 42, Ic)), 64)),
|
|
4205
|
+
d("button", {
|
|
4206
|
+
type: "button",
|
|
4207
|
+
class: "doc-tb-button",
|
|
4208
|
+
"aria-label": E($)("editor.outdent"),
|
|
4209
|
+
disabled: z.value,
|
|
4210
|
+
title: E(xo)("editor.outdent", "Shift+Tab"),
|
|
4211
|
+
onMousedown: n[15] ||= A(() => {}, ["prevent"]),
|
|
4212
|
+
onClick: n[16] ||= (t) => e.engine.indent(-1)
|
|
4213
|
+
}, [p(E(Me), { size: 16 })], 40, Lc),
|
|
4214
|
+
d("button", {
|
|
4215
|
+
type: "button",
|
|
4216
|
+
class: "doc-tb-button",
|
|
4217
|
+
"aria-label": E($)("editor.indent"),
|
|
4218
|
+
disabled: z.value,
|
|
4219
|
+
title: E(xo)("editor.indent", "Tab"),
|
|
4220
|
+
onMousedown: n[17] ||= A(() => {}, ["prevent"]),
|
|
4221
|
+
onClick: n[18] ||= (t) => e.engine.indent(1)
|
|
4222
|
+
}, [p(E(Ne), { size: 16 })], 40, Rc)
|
|
4223
|
+
]),
|
|
4224
|
+
n[41] ||= d("span", { class: "doc-toolbar__divider" }, null, -1),
|
|
4225
|
+
d("div", zc, [
|
|
4226
|
+
p(E(I), {
|
|
4227
|
+
visible: O.value,
|
|
4228
|
+
"onUpdate:visible": n[22] ||= (e) => O.value = e,
|
|
4229
|
+
placement: "bottom-start",
|
|
4230
|
+
"popper-class": "doc-editor-popper",
|
|
4231
|
+
trigger: "click",
|
|
4232
|
+
disabled: z.value,
|
|
4233
|
+
width: 300,
|
|
4234
|
+
onAfterEnter: n[23] ||= (e) => ae.value?.focus(),
|
|
4235
|
+
onBeforeEnter: mt
|
|
4236
|
+
}, {
|
|
4237
|
+
reference: k(() => [d("button", {
|
|
4238
|
+
type: "button",
|
|
4239
|
+
class: v(["doc-tb-button", { "is-active": e.state.link }]),
|
|
4240
|
+
"aria-label": E($)("editor.link"),
|
|
4241
|
+
disabled: z.value,
|
|
4242
|
+
title: E(xo)("editor.link", "Mod+K"),
|
|
4243
|
+
onMousedown: n[19] ||= A(() => {}, ["prevent"])
|
|
4244
|
+
}, [p(E(Ae), { size: 16 })], 42, Bc)]),
|
|
4245
|
+
default: k(() => [d("form", {
|
|
4246
|
+
class: "doc-toolbar__form",
|
|
4247
|
+
onSubmit: A(Ct, ["prevent"])
|
|
4248
|
+
}, [
|
|
4249
|
+
ue.value ? (b(), u("label", Vc, [f(T(E($)("editor.linkText")) + " ", 1), p(E(P), {
|
|
4250
|
+
modelValue: ce.value,
|
|
4251
|
+
"onUpdate:modelValue": n[20] ||= (e) => ce.value = e,
|
|
4252
|
+
size: "small"
|
|
4253
|
+
}, null, 8, ["modelValue"])])) : l("", !0),
|
|
4254
|
+
d("label", null, [f(T(E($)("editor.linkUrl")) + " ", 1), p(E(P), {
|
|
4255
|
+
ref_key: "linkInput",
|
|
4256
|
+
ref: ae,
|
|
4257
|
+
modelValue: F.value,
|
|
4258
|
+
"onUpdate:modelValue": n[21] ||= (e) => F.value = e,
|
|
4259
|
+
placeholder: "https://",
|
|
4260
|
+
size: "small"
|
|
4261
|
+
}, null, 8, ["modelValue"])]),
|
|
4262
|
+
p(E(se), {
|
|
4263
|
+
size: "small",
|
|
4264
|
+
"model-value": le.value,
|
|
4265
|
+
onChange: xt
|
|
4266
|
+
}, {
|
|
4267
|
+
default: k(() => [f(T(E($)("editor.linkNewTab")), 1)]),
|
|
4268
|
+
_: 1
|
|
4269
|
+
}, 8, ["model-value"]),
|
|
4270
|
+
d("div", Hc, [e.state.link ? (b(), c(E(oe), {
|
|
4271
|
+
key: 0,
|
|
4272
|
+
size: "small",
|
|
4273
|
+
text: "",
|
|
4274
|
+
type: "danger",
|
|
4275
|
+
onClick: St
|
|
4276
|
+
}, {
|
|
4277
|
+
default: k(() => [f(T(E($)("editor.unlink")), 1)]),
|
|
4278
|
+
_: 1
|
|
4279
|
+
})) : l("", !0), p(E(oe), {
|
|
4280
|
+
"native-type": "submit",
|
|
4281
|
+
size: "small",
|
|
4282
|
+
type: "primary"
|
|
4283
|
+
}, {
|
|
4284
|
+
default: k(() => [f(T(E($)("editor.apply")), 1)]),
|
|
4285
|
+
_: 1
|
|
4286
|
+
})])
|
|
4287
|
+
], 32)]),
|
|
4288
|
+
_: 1
|
|
4289
|
+
}, 8, ["visible", "disabled"]),
|
|
4290
|
+
p(E(I), {
|
|
4291
|
+
visible: de.value,
|
|
4292
|
+
"onUpdate:visible": n[26] ||= (e) => de.value = e,
|
|
4293
|
+
placement: "bottom-start",
|
|
4294
|
+
"popper-class": "doc-editor-popper",
|
|
4295
|
+
trigger: "click",
|
|
4296
|
+
disabled: z.value,
|
|
4297
|
+
width: 300
|
|
4298
|
+
}, {
|
|
4299
|
+
reference: k(() => [d("button", {
|
|
4300
|
+
type: "button",
|
|
4301
|
+
class: "doc-tb-button",
|
|
4302
|
+
"aria-label": E($)("editor.image"),
|
|
4303
|
+
disabled: z.value,
|
|
4304
|
+
title: E($)("editor.image"),
|
|
4305
|
+
onMousedown: n[24] ||= A(() => {}, ["prevent"])
|
|
4306
|
+
}, [p(E(De), { size: 16 })], 40, Uc)]),
|
|
4307
|
+
default: k(() => [d("div", Wc, [
|
|
4308
|
+
p(E(oe), {
|
|
4309
|
+
size: "small",
|
|
4310
|
+
icon: E(yt),
|
|
4311
|
+
loading: e.uploading,
|
|
4312
|
+
onClick: wt
|
|
4313
|
+
}, {
|
|
4314
|
+
default: k(() => [f(T(E($)("editor.uploadImage")), 1)]),
|
|
4315
|
+
_: 1
|
|
4316
|
+
}, 8, ["icon", "loading"]),
|
|
4317
|
+
d("span", Gc, T(E($)("editor.or")), 1),
|
|
4318
|
+
d("form", {
|
|
4319
|
+
class: "doc-toolbar__inline-form",
|
|
4320
|
+
onSubmit: A(Et, ["prevent"])
|
|
4321
|
+
}, [p(E(P), {
|
|
4322
|
+
modelValue: fe.value,
|
|
4323
|
+
"onUpdate:modelValue": n[25] ||= (e) => fe.value = e,
|
|
4324
|
+
placeholder: "https://example.com/image.png",
|
|
4325
|
+
size: "small",
|
|
4326
|
+
ariaLabel: E($)("editor.image")
|
|
4327
|
+
}, null, 8, ["modelValue", "ariaLabel"]), p(E(oe), {
|
|
4328
|
+
"native-type": "submit",
|
|
4329
|
+
size: "small",
|
|
4330
|
+
type: "primary",
|
|
4331
|
+
disabled: !fe.value.trim()
|
|
4332
|
+
}, {
|
|
4333
|
+
default: k(() => [f(T(E($)("editor.insert")), 1)]),
|
|
4334
|
+
_: 1
|
|
4335
|
+
}, 8, ["disabled"])], 32)
|
|
4336
|
+
])]),
|
|
4337
|
+
_: 1
|
|
4338
|
+
}, 8, ["visible", "disabled"]),
|
|
4339
|
+
d("input", {
|
|
4340
|
+
ref_key: "fileInput",
|
|
4341
|
+
ref: he,
|
|
4342
|
+
type: "file",
|
|
4343
|
+
accept: "image/*",
|
|
4344
|
+
hidden: "",
|
|
4345
|
+
multiple: "",
|
|
4346
|
+
onChange: Tt
|
|
4347
|
+
}, null, 544),
|
|
4348
|
+
p(E(I), {
|
|
4349
|
+
visible: R.value,
|
|
4350
|
+
"onUpdate:visible": n[28] ||= (e) => R.value = e,
|
|
4351
|
+
placement: "bottom-start",
|
|
4352
|
+
"popper-class": "doc-editor-popper",
|
|
4353
|
+
trigger: "click",
|
|
4354
|
+
disabled: z.value,
|
|
4355
|
+
width: 212
|
|
4356
|
+
}, {
|
|
4357
|
+
reference: k(() => [d("button", {
|
|
4358
|
+
type: "button",
|
|
4359
|
+
class: "doc-tb-button",
|
|
4360
|
+
"aria-label": E($)("editor.table.insert"),
|
|
4361
|
+
disabled: z.value,
|
|
4362
|
+
title: E($)("editor.table.insert"),
|
|
4363
|
+
onMousedown: n[27] ||= A(() => {}, ["prevent"])
|
|
4364
|
+
}, [p(E(Te), { size: 16 })], 40, Kc)]),
|
|
4365
|
+
default: k(() => [R.value ? (b(), c(uc, {
|
|
4366
|
+
key: 0,
|
|
4367
|
+
onSelect: Dt
|
|
4368
|
+
})) : l("", !0)]),
|
|
4369
|
+
_: 1
|
|
4370
|
+
}, 8, ["visible", "disabled"]),
|
|
4371
|
+
p(E(I), {
|
|
4372
|
+
visible: ge.value,
|
|
4373
|
+
"onUpdate:visible": n[31] ||= (e) => ge.value = e,
|
|
4374
|
+
placement: "bottom-start",
|
|
4375
|
+
"popper-class": "doc-editor-popper",
|
|
4376
|
+
trigger: "click",
|
|
4377
|
+
disabled: z.value,
|
|
4378
|
+
width: 258
|
|
4379
|
+
}, {
|
|
4380
|
+
reference: k(() => [d("button", {
|
|
4381
|
+
type: "button",
|
|
4382
|
+
class: "doc-tb-button",
|
|
4383
|
+
"aria-label": E($)("editor.specialCharacters"),
|
|
4384
|
+
disabled: z.value,
|
|
4385
|
+
title: E($)("editor.specialCharacters"),
|
|
4386
|
+
onMousedown: n[29] ||= A(() => {}, ["prevent"])
|
|
4387
|
+
}, [p(E(Be), { size: 16 })], 40, qc)]),
|
|
4388
|
+
default: k(() => [d("div", Jc, [(b(), u(a, null, S(D, (e) => d("button", {
|
|
4389
|
+
key: e,
|
|
4390
|
+
type: "button",
|
|
4391
|
+
title: e,
|
|
4392
|
+
onMousedown: n[30] ||= A(() => {}, ["prevent"]),
|
|
4393
|
+
onClick: (t) => Ot(e)
|
|
4394
|
+
}, T(e), 41, Yc)), 64))])]),
|
|
4395
|
+
_: 1
|
|
4396
|
+
}, 8, ["visible", "disabled"]),
|
|
4397
|
+
p(E(j), {
|
|
4398
|
+
"popper-class": "doc-editor-popper",
|
|
4399
|
+
trigger: "click",
|
|
4400
|
+
disabled: z.value,
|
|
4401
|
+
onCommand: ct
|
|
4402
|
+
}, {
|
|
4403
|
+
dropdown: k(() => [p(E(N), { class: "doc-menu" }, {
|
|
4404
|
+
default: k(() => [
|
|
4405
|
+
p(E(M), { command: "pageBreak" }, {
|
|
4406
|
+
default: k(() => [
|
|
4407
|
+
p(E(rt), { size: 14 }),
|
|
4408
|
+
f(" " + T(E($)("editor.pageBreak")) + " ", 1),
|
|
4409
|
+
d("span", Zc, T(E(bo)("Mod+Enter")), 1)
|
|
4410
|
+
]),
|
|
4411
|
+
_: 1
|
|
4412
|
+
}),
|
|
4413
|
+
p(E(M), { command: "horizontalRule" }, {
|
|
4414
|
+
default: k(() => [p(E(tt), { size: 14 }), f(" " + T(E($)("editor.horizontalRule")), 1)]),
|
|
4415
|
+
_: 1
|
|
4416
|
+
}),
|
|
4417
|
+
p(E(M), { command: "date" }, {
|
|
4418
|
+
default: k(() => [p(E(me), { size: 14 }), f(" " + T(E($)("editor.insertDate")), 1)]),
|
|
4419
|
+
_: 1
|
|
4420
|
+
})
|
|
4421
|
+
]),
|
|
4422
|
+
_: 1
|
|
4423
|
+
})]),
|
|
4424
|
+
default: k(() => [d("button", {
|
|
4425
|
+
type: "button",
|
|
4426
|
+
class: "doc-tb-button doc-tb-button--select",
|
|
4427
|
+
"aria-label": E($)("editor.insertMore"),
|
|
4428
|
+
disabled: z.value,
|
|
4429
|
+
title: E($)("editor.insertMore"),
|
|
4430
|
+
onMousedown: n[32] ||= A(() => {}, ["prevent"])
|
|
4431
|
+
}, [p(E(Ge), { size: 16 }), p(E(L), { size: 12 })], 40, Xc)]),
|
|
4432
|
+
_: 1
|
|
4433
|
+
}, 8, ["disabled"])
|
|
4434
|
+
]),
|
|
4435
|
+
n[42] ||= d("span", { class: "doc-toolbar__spacer" }, null, -1),
|
|
4436
|
+
d("div", Qc, [
|
|
4437
|
+
d("button", {
|
|
4438
|
+
type: "button",
|
|
4439
|
+
class: v(["doc-tb-button", { "is-active": e.findOpen }]),
|
|
4440
|
+
"aria-label": E($)("editor.search.title"),
|
|
4441
|
+
disabled: e.sourceMode,
|
|
4442
|
+
title: E(xo)("editor.search.title", "Mod+F"),
|
|
4443
|
+
onMousedown: n[33] ||= A(() => {}, ["prevent"]),
|
|
4444
|
+
onClick: n[34] ||= (e) => i("find")
|
|
4445
|
+
}, [p(E(et), { size: 16 })], 42, $c),
|
|
4446
|
+
p(E(I), {
|
|
4447
|
+
placement: "bottom-end",
|
|
4448
|
+
"popper-class": "doc-editor-popper",
|
|
4449
|
+
trigger: "click",
|
|
4450
|
+
width: 316
|
|
4451
|
+
}, {
|
|
4452
|
+
reference: k(() => [d("button", {
|
|
4453
|
+
type: "button",
|
|
4454
|
+
class: "doc-tb-button",
|
|
4455
|
+
"aria-label": E($)("editor.page.setup"),
|
|
4456
|
+
title: E($)("editor.page.setup"),
|
|
4457
|
+
onMousedown: n[35] ||= A(() => {}, ["prevent"])
|
|
4458
|
+
}, [p(E(xe), { size: 16 })], 40, el)]),
|
|
4459
|
+
default: k(() => [p(ic, {
|
|
4460
|
+
page: e.page,
|
|
4461
|
+
onChange: n[36] ||= (e) => i("update:page", e)
|
|
4462
|
+
}, null, 8, ["page"])]),
|
|
4463
|
+
_: 1
|
|
4464
|
+
}),
|
|
4465
|
+
p(E(j), {
|
|
4466
|
+
placement: "bottom-end",
|
|
4467
|
+
"popper-class": "doc-editor-popper",
|
|
4468
|
+
trigger: "click",
|
|
4469
|
+
onCommand: pt
|
|
4470
|
+
}, {
|
|
4471
|
+
dropdown: k(() => [p(E(N), { class: "doc-menu" }, {
|
|
4472
|
+
default: k(() => [
|
|
4473
|
+
p(E(M), { command: "print" }, {
|
|
4474
|
+
default: k(() => [
|
|
4475
|
+
p(E(Ke), { size: 14 }),
|
|
4476
|
+
f(" " + T(E($)("editor.print")) + " ", 1),
|
|
4477
|
+
d("span", nl, T(E(bo)("Mod+P")), 1)
|
|
4478
|
+
]),
|
|
4479
|
+
_: 1
|
|
4480
|
+
}),
|
|
4481
|
+
p(E(M), { command: "exportWord" }, {
|
|
4482
|
+
default: k(() => [p(E(Ce), { size: 14 }), f(" " + T(E($)("editor.exportWord")), 1)]),
|
|
4483
|
+
_: 1
|
|
4484
|
+
}),
|
|
4485
|
+
p(E(M), { command: "exportHtml" }, {
|
|
4486
|
+
default: k(() => [p(E(be), { size: 14 }), f(" " + T(E($)("editor.exportHtml")), 1)]),
|
|
4487
|
+
_: 1
|
|
4488
|
+
}),
|
|
4489
|
+
p(E(M), {
|
|
4490
|
+
command: "source",
|
|
4491
|
+
divided: "",
|
|
4492
|
+
class: v({ "is-selected": e.sourceMode })
|
|
4493
|
+
}, {
|
|
4494
|
+
default: k(() => [p(E(ye), { size: 14 }), f(" " + T(E($)("editor.source")), 1)]),
|
|
4495
|
+
_: 1
|
|
4496
|
+
}, 8, ["class"]),
|
|
4497
|
+
p(E(M), { command: "fullscreen" }, {
|
|
4498
|
+
default: k(() => [(b(), c(C(e.fullscreen ? E(Le) : E(Ie)), { size: 14 })), f(" " + T(E($)(e.fullscreen ? "editor.exitFullscreen" : "editor.enterFullscreen")), 1)]),
|
|
4499
|
+
_: 1
|
|
4500
|
+
})
|
|
4501
|
+
]),
|
|
4502
|
+
_: 1
|
|
4503
|
+
})]),
|
|
4504
|
+
default: k(() => [d("button", {
|
|
4505
|
+
type: "button",
|
|
4506
|
+
class: "doc-tb-button",
|
|
4507
|
+
"aria-label": E($)("editor.more"),
|
|
4508
|
+
title: E($)("editor.more"),
|
|
4509
|
+
onMousedown: n[37] ||= A(() => {}, ["prevent"])
|
|
4510
|
+
}, [p(E(B), { size: 16 })], 40, tl)]),
|
|
4511
|
+
_: 1
|
|
4512
|
+
})
|
|
4513
|
+
])
|
|
4514
|
+
], 8, dc));
|
|
4515
|
+
}
|
|
4516
|
+
}), [["__scopeId", "data-v-7a9485af"]]), ll = { class: "document-editor__body" }, ul = ["aria-label", "readonly"], dl = {
|
|
4517
|
+
key: 2,
|
|
4518
|
+
class: "document-editor__uploading",
|
|
4519
|
+
role: "status"
|
|
4520
|
+
}, fl = 200, pl = 1048576, ml = 100, hl = /*#__PURE__*/ Vo(/* @__PURE__ */ m({
|
|
4521
|
+
name: "DocumentEditor",
|
|
4522
|
+
inheritAttrs: !1,
|
|
4523
|
+
__name: "document-editor",
|
|
4524
|
+
props: /*@__PURE__*/ h({
|
|
4525
|
+
autofocus: {
|
|
4526
|
+
type: Boolean,
|
|
4527
|
+
default: !1
|
|
4528
|
+
},
|
|
4529
|
+
canvasPadding: { default: 50 },
|
|
4530
|
+
defaultViewMode: { default: "page" },
|
|
4531
|
+
disabled: {
|
|
4532
|
+
type: Boolean,
|
|
4533
|
+
default: !1
|
|
4534
|
+
},
|
|
4535
|
+
height: { default: 760 },
|
|
4536
|
+
maxHeight: { default: 600 },
|
|
4537
|
+
maxImageSizeMb: { default: 10 },
|
|
4538
|
+
maxLength: { default: 0 },
|
|
4539
|
+
minHeight: { default: 240 },
|
|
4540
|
+
placeholder: { default: "" },
|
|
4541
|
+
title: { default: "" },
|
|
4542
|
+
uploadImage: {
|
|
4543
|
+
type: Function,
|
|
4544
|
+
default: void 0
|
|
4545
|
+
}
|
|
4546
|
+
}, {
|
|
4547
|
+
modelValue: { default: "" },
|
|
4548
|
+
modelModifiers: {},
|
|
4549
|
+
page: { default: r },
|
|
4550
|
+
pageModifiers: {}
|
|
4551
|
+
}),
|
|
4552
|
+
emits: /*@__PURE__*/ h([
|
|
4553
|
+
"blur",
|
|
4554
|
+
"focus",
|
|
4555
|
+
"uploadError"
|
|
4556
|
+
], ["update:modelValue", "update:page"]),
|
|
4557
|
+
setup(e, { expose: n, emit: r }) {
|
|
4558
|
+
let i = e, a = r, f = ne(e, "modelValue"), m = ne(e, "page"), h = /^image\//, v = /(<\/(?:p|h[1-6]|li|ul|ol|blockquote|pre|table|thead|tbody|tr|div)>|<hr>)(?!\n)/g, y = (e) => typeof e == "number" ? `${e}px` : e, S = x(), C = x(), D = x(), k = x(), A = w(null), oe = w("body"), se = x(), j = x(i.defaultViewMode), M = x(ml), N = x(!1), P = x(!1), F = x(""), I = x(!1), le = x(!1), ue = x(!1), de = x(1), fe = x(1), pe = w(Yr), me = w({
|
|
4559
|
+
words: 0,
|
|
4560
|
+
characters: 0
|
|
4561
|
+
}), { nextZIndex: he } = ce(), L = null, R = f.value, ge = !1, _e, z = 0, B = "", ve = !0, ye = 0, be = [], xe = s(() => t(m.value)), Se = s(() => C.value?.scrollElement), Ce = s(() => i.height === "auto" && !N.value), we = s(() => ({
|
|
4562
|
+
"--doc-editor-canvas-padding": y(i.canvasPadding),
|
|
4563
|
+
"--doc-editor-height": y(i.height),
|
|
4564
|
+
"--doc-editor-min-height": y(i.minHeight),
|
|
4565
|
+
"--doc-editor-max-height": y(i.maxHeight),
|
|
4566
|
+
zIndex: N.value ? se.value : void 0
|
|
4567
|
+
})), Te = () => {
|
|
4568
|
+
A.value && (me.value = A.value.getStats());
|
|
4569
|
+
}, Ee = () => {
|
|
4570
|
+
clearTimeout(_e), _e = void 0, ge = !1;
|
|
4571
|
+
let e = A.value;
|
|
4572
|
+
if (!e) return;
|
|
4573
|
+
Te();
|
|
4574
|
+
let t = e.isEmpty ? "" : e.getHTML();
|
|
4575
|
+
t !== R && (R = t, f.value = t);
|
|
4576
|
+
}, De = () => {
|
|
4577
|
+
ge = !0, clearTimeout(_e), _e = setTimeout(Ee, fl);
|
|
4578
|
+
}, Oe = () => {
|
|
4579
|
+
let e = A.value, t = document.getSelection();
|
|
4580
|
+
if (!e || j.value !== "page" || de.value < 2 || !t?.rangeCount) return 1;
|
|
4581
|
+
let n = t.getRangeAt(0), r = n.startContainer;
|
|
4582
|
+
if (!e.root.contains(r)) return fe.value;
|
|
4583
|
+
let i = n.getClientRects()[0] ?? (r instanceof Element ? r : r.parentElement)?.getBoundingClientRect();
|
|
4584
|
+
if (!i) return fe.value;
|
|
4585
|
+
let a = (i.top - e.root.getBoundingClientRect().top) / (M.value / ml), o = Math.floor(a / (xe.value.height + xe.value.gap)) + 1;
|
|
4586
|
+
return Math.min(de.value, Math.max(1, o));
|
|
4587
|
+
}, ke = () => {
|
|
4588
|
+
z = 0;
|
|
4589
|
+
let e = A.value;
|
|
4590
|
+
if (!e) return;
|
|
4591
|
+
let t = e.getState();
|
|
4592
|
+
ti(pe.value, t) || (pe.value = t), fe.value = Oe();
|
|
4593
|
+
}, Ae = () => {
|
|
4594
|
+
z ||= requestAnimationFrame(ke);
|
|
4595
|
+
}, je = (e) => new Promise((t, n) => {
|
|
4596
|
+
let r = new FileReader();
|
|
4597
|
+
r.onload = () => typeof r.result == "string" ? t(r.result) : n(Error($("editor.imageReadError"))), r.onerror = () => n(r.error ?? Error($("editor.imageReadError"))), r.readAsDataURL(e);
|
|
4598
|
+
}), Me = (e) => h.test(e.type) ? e.size > i.maxImageSizeMb * pl ? Error($("editor.imageSizeError", { size: i.maxImageSizeMb })) : null : Error($("editor.imageTypeError")), Ne = async (e) => {
|
|
4599
|
+
if (A.value && !i.disabled && e.length) {
|
|
4600
|
+
ue.value = !0;
|
|
4601
|
+
try {
|
|
4602
|
+
for (let t of e) {
|
|
4603
|
+
let e = Me(t);
|
|
4604
|
+
if (e) {
|
|
4605
|
+
a("uploadError", e);
|
|
4606
|
+
continue;
|
|
4607
|
+
}
|
|
4608
|
+
try {
|
|
4609
|
+
let e = i.uploadImage ? await i.uploadImage(t) : await je(t);
|
|
4610
|
+
e ? A.value?.insertImage(e, t.name) : a("uploadError", Error($("editor.imageUploadError")));
|
|
4611
|
+
} catch (e) {
|
|
4612
|
+
a("uploadError", e);
|
|
4613
|
+
}
|
|
4614
|
+
}
|
|
4615
|
+
} finally {
|
|
4616
|
+
ue.value = !1;
|
|
4617
|
+
}
|
|
4618
|
+
}
|
|
4619
|
+
}, Pe = (e) => {
|
|
4620
|
+
P.value || (e && !i.disabled && (le.value = !0), I.value && k.value?.focus(), I.value = !0);
|
|
4621
|
+
}, Fe = () => {
|
|
4622
|
+
I.value = !1, A.value?.focus();
|
|
4623
|
+
}, Ie = () => I.value ? Fe() : Pe(!1), Le = (e) => e.replace(v, "$1\n"), Re = () => {
|
|
4624
|
+
let e = A.value;
|
|
4625
|
+
if (e) {
|
|
4626
|
+
if (!P.value) {
|
|
4627
|
+
ge && Ee(), I.value = !1, F.value = Le(e.getHTML()), P.value = !0;
|
|
4628
|
+
return;
|
|
4629
|
+
}
|
|
4630
|
+
P.value = !1, i.disabled || (e.setContent(F.value, {
|
|
4631
|
+
addToHistory: !0,
|
|
4632
|
+
emitUpdate: !0
|
|
4633
|
+
}), Ee()), _(() => e.focus());
|
|
4634
|
+
}
|
|
4635
|
+
}, ze = () => ({
|
|
4636
|
+
html: A.value && !A.value.isEmpty ? A.value.getHTML() : f.value,
|
|
4637
|
+
page: m.value,
|
|
4638
|
+
title: i.title || $("editor.document")
|
|
4639
|
+
}), Be = async () => {
|
|
4640
|
+
let { buildPrintableHtml: e, printHtml: t } = await import("./export-cyOnlakM.js");
|
|
4641
|
+
t(e(ze()));
|
|
4642
|
+
}, Ve = async (e) => {
|
|
4643
|
+
let { buildPrintableHtml: t, buildWordHtml: n, downloadFile: r, toFileName: i } = await import("./export-cyOnlakM.js"), a = ze(), o = i(a.title);
|
|
4644
|
+
e === "word" ? r(n(a), `${o}.doc`, "application/msword") : r(t(a), `${o}.html`, "text/html;charset=utf-8");
|
|
4645
|
+
}, He = (e) => {
|
|
4646
|
+
switch (e) {
|
|
4647
|
+
case "source":
|
|
4648
|
+
Re();
|
|
4649
|
+
break;
|
|
4650
|
+
case "print":
|
|
4651
|
+
Be();
|
|
4652
|
+
break;
|
|
4653
|
+
case "exportHtml":
|
|
4654
|
+
Ve("html");
|
|
4655
|
+
break;
|
|
4656
|
+
case "exportWord":
|
|
4657
|
+
Ve("word");
|
|
4658
|
+
break;
|
|
4659
|
+
default: N.value = !N.value;
|
|
4660
|
+
}
|
|
4661
|
+
}, Ue = (e) => {
|
|
4662
|
+
ve = !1, M.value = Math.min(200, Math.max(30, e));
|
|
4663
|
+
}, We = () => {
|
|
4664
|
+
let e = C.value?.getFitWidthZoom();
|
|
4665
|
+
e && Ue(e);
|
|
4666
|
+
}, Ge = () => {
|
|
4667
|
+
if (!ve || !ye || j.value !== "page") return;
|
|
4668
|
+
let e = Math.floor(ye / xe.value.width * ml);
|
|
4669
|
+
M.value = Math.min(ml, Math.max(30, e));
|
|
4670
|
+
}, Ke = (e) => {
|
|
4671
|
+
ye = e, Ge();
|
|
4672
|
+
}, qe = (e) => {
|
|
4673
|
+
let t = e.ctrlKey || e.metaKey, n = e.code;
|
|
4674
|
+
t && !e.altKey && !e.shiftKey && n === "KeyF" ? (e.preventDefault(), Pe(!1)) : t && !e.altKey && n === "KeyH" ? (e.preventDefault(), Pe(!0)) : t && n === "KeyK" && !i.disabled && !P.value ? (e.preventDefault(), D.value?.openLink()) : t && n === "KeyP" ? (e.preventDefault(), Be()) : e.key === "Escape" && I.value ? (e.stopPropagation(), Fe()) : e.key === "Escape" && N.value && (e.stopPropagation(), N.value = !1);
|
|
4675
|
+
};
|
|
4676
|
+
return O(f, (e) => {
|
|
4677
|
+
let t = A.value;
|
|
4678
|
+
t && e !== R && (clearTimeout(_e), ge = !1, R = e, t.setContent(e), Te(), L?.schedule());
|
|
4679
|
+
}), O(() => i.disabled, (e) => A.value?.setEditable(!e)), O([xe, j], ([e, t]) => L?.setMetrics(t === "page" ? e : null)), O([
|
|
4680
|
+
de,
|
|
4681
|
+
M,
|
|
4682
|
+
j
|
|
4683
|
+
], Ae), O([xe, j], Ge), O(N, (e) => {
|
|
4684
|
+
e ? (oe.value = S.value?.closest(".el-dialog, .el-drawer") ?? "body", se.value = he(), B = document.body.style.overflow, document.body.style.overflow = "hidden") : document.body.style.overflow = B, _(() => A.value?.focus());
|
|
4685
|
+
}), te(() => {
|
|
4686
|
+
let e = C.value?.contentElement;
|
|
4687
|
+
if (!e) return;
|
|
4688
|
+
let t = new po(e, {
|
|
4689
|
+
content: f.value,
|
|
4690
|
+
editable: !i.disabled,
|
|
4691
|
+
maxLength: i.maxLength,
|
|
4692
|
+
placeholder: () => i.placeholder || $("editor.placeholder"),
|
|
4693
|
+
onImageFiles: (e) => void Ne(e)
|
|
4694
|
+
});
|
|
4695
|
+
e.setAttribute("aria-label", i.title || $("editor.document")), L = ko(e, {
|
|
4696
|
+
onPageCount: (e) => {
|
|
4697
|
+
de.value = e;
|
|
4698
|
+
},
|
|
4699
|
+
isComposing: () => t.composing
|
|
4700
|
+
}), L.setMetrics(j.value === "page" ? xe.value : null), be.push(t.on("update", () => {
|
|
4701
|
+
De(), L?.schedule();
|
|
4702
|
+
}), t.on("selection", Ae), t.on("composition", (e) => {
|
|
4703
|
+
e || L?.schedule();
|
|
4704
|
+
}), t.on("focus", () => a("focus")), t.on("blur", () => {
|
|
4705
|
+
ge && Ee(), a("blur");
|
|
4706
|
+
})), A.value = t, Te(), Ae(), i.autofocus && t.focus("end");
|
|
4707
|
+
}), ee(() => {
|
|
4708
|
+
ge && Ee(), cancelAnimationFrame(z);
|
|
4709
|
+
for (let e of be) e();
|
|
4710
|
+
L?.destroy(), A.value?.destroy(), N.value && (document.body.style.overflow = B);
|
|
4711
|
+
}), n({
|
|
4712
|
+
engine: A,
|
|
4713
|
+
exportHtml: () => Ve("html"),
|
|
4714
|
+
exportWord: () => Ve("word"),
|
|
4715
|
+
focus: () => A.value?.focus(),
|
|
4716
|
+
getHTML: () => (Ee(), R),
|
|
4717
|
+
print: Be
|
|
4718
|
+
}), (t, n) => (b(), c(o, {
|
|
4719
|
+
to: oe.value,
|
|
4720
|
+
disabled: !N.value
|
|
4721
|
+
}, [d("section", g({
|
|
4722
|
+
ref_key: "sectionRef",
|
|
4723
|
+
ref: S
|
|
4724
|
+
}, t.$attrs, {
|
|
4725
|
+
class: ["document-editor", {
|
|
4726
|
+
"is-auto-height": Ce.value,
|
|
4727
|
+
"is-fullscreen": N.value
|
|
4728
|
+
}],
|
|
4729
|
+
style: we.value,
|
|
4730
|
+
onKeydown: qe
|
|
4731
|
+
}), [
|
|
4732
|
+
A.value ? (b(), c(cl, {
|
|
4733
|
+
key: 0,
|
|
4734
|
+
ref_key: "toolbarRef",
|
|
4735
|
+
ref: D,
|
|
4736
|
+
disabled: e.disabled,
|
|
4737
|
+
engine: A.value,
|
|
4738
|
+
"find-open": I.value,
|
|
4739
|
+
fullscreen: N.value,
|
|
4740
|
+
page: m.value,
|
|
4741
|
+
"source-mode": P.value,
|
|
4742
|
+
state: pe.value,
|
|
4743
|
+
uploading: ue.value,
|
|
4744
|
+
onFind: Ie,
|
|
4745
|
+
onInsertImages: Ne,
|
|
4746
|
+
onMenu: He,
|
|
4747
|
+
"onUpdate:page": n[0] ||= (e) => m.value = e
|
|
4748
|
+
}, null, 8, [
|
|
4749
|
+
"disabled",
|
|
4750
|
+
"engine",
|
|
4751
|
+
"find-open",
|
|
4752
|
+
"fullscreen",
|
|
4753
|
+
"page",
|
|
4754
|
+
"source-mode",
|
|
4755
|
+
"state",
|
|
4756
|
+
"uploading"
|
|
4757
|
+
])) : l("", !0),
|
|
4758
|
+
d("div", ll, [
|
|
4759
|
+
ae(p(is, {
|
|
4760
|
+
ref_key: "canvasRef",
|
|
4761
|
+
ref: C,
|
|
4762
|
+
"auto-height": Ce.value,
|
|
4763
|
+
engine: A.value,
|
|
4764
|
+
metrics: xe.value,
|
|
4765
|
+
"page-count": de.value,
|
|
4766
|
+
"view-mode": j.value,
|
|
4767
|
+
zoom: M.value,
|
|
4768
|
+
onResize: Ke
|
|
4769
|
+
}, null, 8, [
|
|
4770
|
+
"auto-height",
|
|
4771
|
+
"engine",
|
|
4772
|
+
"metrics",
|
|
4773
|
+
"page-count",
|
|
4774
|
+
"view-mode",
|
|
4775
|
+
"zoom"
|
|
4776
|
+
]), [[ie, !P.value]]),
|
|
4777
|
+
P.value ? ae((b(), u("textarea", {
|
|
4778
|
+
key: 0,
|
|
4779
|
+
"onUpdate:modelValue": n[1] ||= (e) => F.value = e,
|
|
4780
|
+
class: "document-editor__source",
|
|
4781
|
+
spellcheck: "false",
|
|
4782
|
+
"aria-label": E($)("editor.source"),
|
|
4783
|
+
readonly: e.disabled
|
|
4784
|
+
}, null, 8, ul)), [[re, F.value]]) : l("", !0),
|
|
4785
|
+
A.value && I.value && !P.value ? (b(), c(ys, {
|
|
4786
|
+
key: 1,
|
|
4787
|
+
ref_key: "findBarRef",
|
|
4788
|
+
ref: k,
|
|
4789
|
+
replace: le.value,
|
|
4790
|
+
"onUpdate:replace": n[2] ||= (e) => le.value = e,
|
|
4791
|
+
engine: A.value,
|
|
4792
|
+
readonly: e.disabled,
|
|
4793
|
+
onClose: Fe
|
|
4794
|
+
}, null, 8, [
|
|
4795
|
+
"replace",
|
|
4796
|
+
"engine",
|
|
4797
|
+
"readonly"
|
|
4798
|
+
])) : l("", !0),
|
|
4799
|
+
ue.value ? (b(), u("div", dl, T(E($)("editor.uploading")), 1)) : l("", !0)
|
|
4800
|
+
]),
|
|
4801
|
+
p(Ps, {
|
|
4802
|
+
"view-mode": j.value,
|
|
4803
|
+
"onUpdate:viewMode": n[3] ||= (e) => j.value = e,
|
|
4804
|
+
characters: me.value.characters,
|
|
4805
|
+
"current-page": fe.value,
|
|
4806
|
+
fullscreen: N.value,
|
|
4807
|
+
"max-length": e.maxLength,
|
|
4808
|
+
"page-count": de.value,
|
|
4809
|
+
words: me.value.words,
|
|
4810
|
+
zoom: M.value,
|
|
4811
|
+
onFitWidth: We,
|
|
4812
|
+
onToggleFullscreen: n[4] ||= (e) => N.value = !N.value,
|
|
4813
|
+
"onUpdate:zoom": Ue
|
|
4814
|
+
}, null, 8, [
|
|
4815
|
+
"view-mode",
|
|
4816
|
+
"characters",
|
|
4817
|
+
"current-page",
|
|
4818
|
+
"fullscreen",
|
|
4819
|
+
"max-length",
|
|
4820
|
+
"page-count",
|
|
4821
|
+
"words",
|
|
4822
|
+
"zoom"
|
|
4823
|
+
]),
|
|
4824
|
+
A.value && Se.value && !e.disabled && !P.value ? (b(), c(Ho, {
|
|
4825
|
+
key: 1,
|
|
4826
|
+
engine: A.value,
|
|
4827
|
+
"scroll-target": Se.value,
|
|
4828
|
+
onEditLink: n[5] ||= (e) => D.value?.openLink()
|
|
4829
|
+
}, null, 8, ["engine", "scroll-target"])) : l("", !0)
|
|
4830
|
+
], 16)], 8, ["to", "disabled"]));
|
|
4831
|
+
}
|
|
4832
|
+
}), [["__scopeId", "data-v-319ed1dc"]]), gl = /* @__PURE__ */ m({
|
|
4833
|
+
name: "RichTextEditor",
|
|
4834
|
+
__name: "editor",
|
|
4835
|
+
props: /*@__PURE__*/ h({
|
|
4836
|
+
autofocus: {
|
|
4837
|
+
type: Boolean,
|
|
4838
|
+
default: !1
|
|
4839
|
+
},
|
|
4840
|
+
canvasPadding: { default: 50 },
|
|
4841
|
+
disabled: {
|
|
4842
|
+
type: Boolean,
|
|
4843
|
+
default: !1
|
|
4844
|
+
},
|
|
4845
|
+
maxHeight: { default: 600 },
|
|
4846
|
+
maxImageSizeMb: { default: 10 },
|
|
4847
|
+
maxLength: { default: 0 },
|
|
4848
|
+
minHeight: { default: 240 },
|
|
4849
|
+
placeholder: { default: "" },
|
|
4850
|
+
uploadImage: {
|
|
4851
|
+
type: Function,
|
|
4852
|
+
default: void 0
|
|
4853
|
+
}
|
|
4854
|
+
}, {
|
|
4855
|
+
modelValue: { default: "" },
|
|
4856
|
+
modelModifiers: {}
|
|
4857
|
+
}),
|
|
4858
|
+
emits: /*@__PURE__*/ h([
|
|
4859
|
+
"blur",
|
|
4860
|
+
"focus",
|
|
4861
|
+
"uploadError"
|
|
4862
|
+
], ["update:modelValue"]),
|
|
4863
|
+
setup(e, { emit: t }) {
|
|
4864
|
+
let n = t, r = ne(e, "modelValue");
|
|
4865
|
+
return (t, i) => (b(), c(hl, {
|
|
4866
|
+
modelValue: r.value,
|
|
4867
|
+
"onUpdate:modelValue": i[0] ||= (e) => r.value = e,
|
|
4868
|
+
class: "rich-text-editor",
|
|
4869
|
+
"default-view-mode": "web",
|
|
4870
|
+
height: "auto",
|
|
4871
|
+
autofocus: e.autofocus,
|
|
4872
|
+
"canvas-padding": e.canvasPadding,
|
|
4873
|
+
disabled: e.disabled,
|
|
4874
|
+
"max-height": e.maxHeight,
|
|
4875
|
+
"max-image-size-mb": e.maxImageSizeMb,
|
|
4876
|
+
"max-length": e.maxLength,
|
|
4877
|
+
"min-height": e.minHeight,
|
|
4878
|
+
placeholder: e.placeholder,
|
|
4879
|
+
"upload-image": e.uploadImage,
|
|
4880
|
+
onBlur: i[1] ||= (e) => n("blur"),
|
|
4881
|
+
onFocus: i[2] ||= (e) => n("focus"),
|
|
4882
|
+
onUploadError: i[3] ||= (e) => n("uploadError", e)
|
|
4883
|
+
}, null, 8, [
|
|
4884
|
+
"modelValue",
|
|
4885
|
+
"autofocus",
|
|
4886
|
+
"canvas-padding",
|
|
4887
|
+
"disabled",
|
|
4888
|
+
"max-height",
|
|
4889
|
+
"max-image-size-mb",
|
|
4890
|
+
"max-length",
|
|
4891
|
+
"min-height",
|
|
4892
|
+
"placeholder",
|
|
4893
|
+
"upload-image"
|
|
4894
|
+
]));
|
|
4895
|
+
}
|
|
4896
|
+
});
|
|
4897
|
+
//#endregion
|
|
4898
|
+
export { hl as DocumentEditor, gl as Editor, r as createPageSettings, ho as editorMessages, _o as setEditorTranslator };
|
|
4899
|
+
|
|
4900
|
+
//# sourceMappingURL=index.js.map
|