@daneshnaik/rich-text-editor 1.0.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 +160 -0
- package/dist/rich-text-editor.js +1543 -0
- package/dist/rich-text-editor.umd.cjs +17 -0
- package/dist/style.css +1 -0
- package/dist/vite.svg +1 -0
- package/package.json +66 -0
|
@@ -0,0 +1,1543 @@
|
|
|
1
|
+
import { jsx as e, jsxs as i } from "react/jsx-runtime";
|
|
2
|
+
import { useState as b, useEffect as oe, useRef as J } from "react";
|
|
3
|
+
const It = ({ isOpen: D, onClose: z, onInsert: Y, onRemove: re, isEditing: he = !1, initialUrl: O = "", initialText: Z = "", existingLinks: F = [] }) => {
|
|
4
|
+
const [X, G] = b(O), [ee, K] = b(Z);
|
|
5
|
+
return oe(() => {
|
|
6
|
+
D && (G(O || ""), K(Z || ""));
|
|
7
|
+
}, [D, O, Z]), D ? /* @__PURE__ */ e("div", { className: "modal-overlay", onClick: z, children: /* @__PURE__ */ i("div", { className: "modal-content", onClick: (L) => L.stopPropagation(), children: [
|
|
8
|
+
/* @__PURE__ */ i("div", { className: "modal-header", children: [
|
|
9
|
+
/* @__PURE__ */ e("h3", { children: "Insert Link" }),
|
|
10
|
+
/* @__PURE__ */ e("button", { className: "modal-close", onClick: z, children: "×" })
|
|
11
|
+
] }),
|
|
12
|
+
/* @__PURE__ */ i("div", { className: "modal-body", children: [
|
|
13
|
+
/* @__PURE__ */ i("div", { className: "form-group", children: [
|
|
14
|
+
/* @__PURE__ */ e("label", { children: "URL:" }),
|
|
15
|
+
/* @__PURE__ */ e(
|
|
16
|
+
"input",
|
|
17
|
+
{
|
|
18
|
+
type: "text",
|
|
19
|
+
className: "form-input",
|
|
20
|
+
placeholder: "https://example.com",
|
|
21
|
+
value: X,
|
|
22
|
+
onChange: (L) => G(L.target.value)
|
|
23
|
+
}
|
|
24
|
+
)
|
|
25
|
+
] }),
|
|
26
|
+
/* @__PURE__ */ i("div", { className: "form-group", children: [
|
|
27
|
+
/* @__PURE__ */ e("label", { children: "Display text:" }),
|
|
28
|
+
/* @__PURE__ */ e(
|
|
29
|
+
"input",
|
|
30
|
+
{
|
|
31
|
+
type: "text",
|
|
32
|
+
className: "form-input",
|
|
33
|
+
value: ee,
|
|
34
|
+
onChange: (L) => K(L.target.value)
|
|
35
|
+
}
|
|
36
|
+
)
|
|
37
|
+
] }),
|
|
38
|
+
F && F.length > 0 && /* @__PURE__ */ i("div", { className: "form-group", children: [
|
|
39
|
+
/* @__PURE__ */ e("label", { children: "Existing links:" }),
|
|
40
|
+
/* @__PURE__ */ e("ul", { className: "existing-links", style: { maxHeight: 160, overflow: "auto", paddingLeft: 16 }, children: F.map((L, ue) => /* @__PURE__ */ i("li", { style: { display: "flex", gap: 8, alignItems: "center", marginBottom: 6 }, children: [
|
|
41
|
+
/* @__PURE__ */ e("a", { href: L.href, target: "_blank", rel: "noreferrer", children: L.text || L.href }),
|
|
42
|
+
/* @__PURE__ */ e("button", { type: "button", className: "toolbar-btn", onClick: () => {
|
|
43
|
+
G(L.href), K(L.text || L.href);
|
|
44
|
+
}, style: { marginLeft: "auto" }, children: "Use" })
|
|
45
|
+
] }, ue)) })
|
|
46
|
+
] })
|
|
47
|
+
] }),
|
|
48
|
+
/* @__PURE__ */ i("div", { className: "modal-footer", children: [
|
|
49
|
+
/* @__PURE__ */ e("button", { className: "btn-secondary", onClick: z, children: "Cancel" }),
|
|
50
|
+
he && re && /* @__PURE__ */ e("button", { className: "btn-secondary", onClick: () => {
|
|
51
|
+
re(), z();
|
|
52
|
+
}, style: { marginRight: 8 }, children: "Remove Link" }),
|
|
53
|
+
/* @__PURE__ */ e(
|
|
54
|
+
"button",
|
|
55
|
+
{
|
|
56
|
+
className: "btn-primary",
|
|
57
|
+
onClick: () => {
|
|
58
|
+
Y({ url: X || "", text: ee || X || "" });
|
|
59
|
+
},
|
|
60
|
+
children: "Insert"
|
|
61
|
+
}
|
|
62
|
+
)
|
|
63
|
+
] })
|
|
64
|
+
] }) }) : null;
|
|
65
|
+
}, qt = () => {
|
|
66
|
+
const [D, z] = b(""), [Y, re] = b(!1), [he, O] = b(!1), [Z, F] = b(!1), [X, G] = b(""), [ee, K] = b(!1), [L, ue] = b({ rows: 1, cols: 1 }), [ze, me] = b(!1), [Ve, j] = b(!1), [_, Oe] = b(""), [pe, je] = b(""), [ye, B] = b(""), [De, ae] = b(!1), [be, Ce] = b(3), [xe, we] = b(3), [ke, Xe] = b("a4"), [V, _e] = b({
|
|
67
|
+
bold: !1,
|
|
68
|
+
italic: !1,
|
|
69
|
+
underline: !1,
|
|
70
|
+
strikeThrough: !1,
|
|
71
|
+
justifyLeft: !1,
|
|
72
|
+
justifyCenter: !1,
|
|
73
|
+
justifyRight: !1,
|
|
74
|
+
insertUnorderedList: !1,
|
|
75
|
+
insertOrderedList: !1
|
|
76
|
+
}), Ne = () => {
|
|
77
|
+
try {
|
|
78
|
+
const t = {
|
|
79
|
+
bold: document.queryCommandState("bold"),
|
|
80
|
+
italic: document.queryCommandState("italic"),
|
|
81
|
+
underline: document.queryCommandState("underline"),
|
|
82
|
+
strikeThrough: document.queryCommandState("strikeThrough"),
|
|
83
|
+
justifyLeft: document.queryCommandState("justifyLeft"),
|
|
84
|
+
justifyCenter: document.queryCommandState("justifyCenter"),
|
|
85
|
+
justifyRight: document.queryCommandState("justifyRight"),
|
|
86
|
+
insertUnorderedList: document.queryCommandState("insertUnorderedList"),
|
|
87
|
+
insertOrderedList: document.queryCommandState("insertOrderedList")
|
|
88
|
+
};
|
|
89
|
+
_e(t);
|
|
90
|
+
try {
|
|
91
|
+
const n = window.getSelection(), l = n && n.anchorNode ? n.anchorNode.nodeType === 3 ? n.anchorNode.parentElement : n.anchorNode : null;
|
|
92
|
+
let r = "";
|
|
93
|
+
try {
|
|
94
|
+
r = document.queryCommandValue && document.queryCommandValue("fontName") || "";
|
|
95
|
+
} catch {
|
|
96
|
+
r = "";
|
|
97
|
+
}
|
|
98
|
+
!r && l && (r = (window.getComputedStyle(l).fontFamily || "").split(",")[0].replace(/["']/g, "").trim()), r && (r = String(r).replace(/^[<>"']+|[<>"']+$/g, "").split(",")[0].trim(), Le(r), Qe((u) => u.includes(r) ? u : [r, ...u]));
|
|
99
|
+
let a = "";
|
|
100
|
+
try {
|
|
101
|
+
a = document.queryCommandValue("fontSize") || "";
|
|
102
|
+
} catch {
|
|
103
|
+
a = "";
|
|
104
|
+
}
|
|
105
|
+
if (!a && l) {
|
|
106
|
+
const u = parseFloat(window.getComputedStyle(l).fontSize || "16");
|
|
107
|
+
u < 12 ? a = "1" : u < 16 ? a = "2" : u < 18 ? a = "3" : u < 22 ? a = "4" : u < 26 ? a = "5" : u < 32 ? a = "6" : a = "7";
|
|
108
|
+
}
|
|
109
|
+
a && Se(String(a));
|
|
110
|
+
let h = "";
|
|
111
|
+
try {
|
|
112
|
+
h = document.queryCommandValue && document.queryCommandValue("formatBlock") || "";
|
|
113
|
+
} catch {
|
|
114
|
+
h = "";
|
|
115
|
+
}
|
|
116
|
+
if (!h && l) {
|
|
117
|
+
let u = l;
|
|
118
|
+
for (; u && u !== f.current; ) {
|
|
119
|
+
if (u.tagName && /H[1-6]|P|BLOCKQUOTE|DIV/.test(u.tagName)) {
|
|
120
|
+
h = u.tagName.toLowerCase();
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
u = u.parentElement;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
h && (h = String(h).replace(/[<>]/g, "").toLowerCase(), /^(p|h[1-6]|blockquote)$/.test(h) || (h = "p"), fe(h));
|
|
127
|
+
} catch {
|
|
128
|
+
}
|
|
129
|
+
} catch {
|
|
130
|
+
}
|
|
131
|
+
}, [Ye, Le] = b("Arial"), [Ge, Se] = b("3"), [Ke, fe] = b("p"), [Bt, Qe] = b([
|
|
132
|
+
"Arial",
|
|
133
|
+
"Helvetica",
|
|
134
|
+
"Segoe UI",
|
|
135
|
+
"Roboto",
|
|
136
|
+
"Open Sans",
|
|
137
|
+
"Lato",
|
|
138
|
+
"Montserrat",
|
|
139
|
+
"Source Sans Pro",
|
|
140
|
+
"Tahoma",
|
|
141
|
+
"Verdana",
|
|
142
|
+
"Trebuchet MS",
|
|
143
|
+
"Georgia",
|
|
144
|
+
"Times New Roman",
|
|
145
|
+
"Palatino Linotype",
|
|
146
|
+
"Garamond",
|
|
147
|
+
"Courier New",
|
|
148
|
+
"Brush Script MT",
|
|
149
|
+
"Impact",
|
|
150
|
+
"Comic Sans MS",
|
|
151
|
+
"Candara",
|
|
152
|
+
"Cambria",
|
|
153
|
+
"Calibri",
|
|
154
|
+
"Merriweather",
|
|
155
|
+
"Noto Sans",
|
|
156
|
+
"Palatino",
|
|
157
|
+
"Bookman",
|
|
158
|
+
"Lucida Sans",
|
|
159
|
+
"Righteous",
|
|
160
|
+
"Poppins"
|
|
161
|
+
]), f = J(null), Te = J(null), q = J(null), N = J(null), E = J(null), Je = J(null), v = (t, n = null) => {
|
|
162
|
+
try {
|
|
163
|
+
document.execCommand(t, !1, n);
|
|
164
|
+
} catch (l) {
|
|
165
|
+
console.error("execCommand failed:", l);
|
|
166
|
+
}
|
|
167
|
+
}, Ze = () => {
|
|
168
|
+
f.current && (z(f.current.innerHTML), Ne());
|
|
169
|
+
};
|
|
170
|
+
oe(() => {
|
|
171
|
+
const t = () => {
|
|
172
|
+
(document.activeElement === f.current || f.current?.contains(document.activeElement)) && Ne();
|
|
173
|
+
};
|
|
174
|
+
return document.addEventListener("selectionchange", t), () => document.removeEventListener("selectionchange", t);
|
|
175
|
+
}, []);
|
|
176
|
+
const [te, ne] = b({ open: !1, initialUrl: "", initialText: "", existingLinks: [] }), et = () => {
|
|
177
|
+
let t = "";
|
|
178
|
+
try {
|
|
179
|
+
const l = window.getSelection();
|
|
180
|
+
if (l && l.rangeCount > 0) {
|
|
181
|
+
const r = l.getRangeAt(0);
|
|
182
|
+
if (f.current && f.current.contains(r.commonAncestorContainer)) {
|
|
183
|
+
q.current = r, l.isCollapsed || (t = l.toString().trim());
|
|
184
|
+
try {
|
|
185
|
+
const a = r.commonAncestorContainer.nodeType === 3 ? r.commonAncestorContainer.parentElement : r.commonAncestorContainer, h = a && a.closest ? a.closest("a") : null;
|
|
186
|
+
h && f.current.contains(h) ? N.current = h : N.current = null;
|
|
187
|
+
} catch {
|
|
188
|
+
N.current = null;
|
|
189
|
+
}
|
|
190
|
+
} else
|
|
191
|
+
q.current = null, N.current = null;
|
|
192
|
+
}
|
|
193
|
+
} catch {
|
|
194
|
+
q.current = null, N.current = null;
|
|
195
|
+
}
|
|
196
|
+
const n = [];
|
|
197
|
+
try {
|
|
198
|
+
const l = f.current;
|
|
199
|
+
l && l.querySelectorAll("a").forEach((a) => n.push({ href: a.getAttribute("href"), text: a.innerText }));
|
|
200
|
+
} catch {
|
|
201
|
+
}
|
|
202
|
+
N.current ? ne({ open: !0, initialUrl: N.current.getAttribute("href") || "", initialText: N.current.innerText || "", existingLinks: n, isEditing: !0 }) : ne({ open: !0, initialUrl: "", initialText: t, existingLinks: n, isEditing: !1 });
|
|
203
|
+
}, tt = ({ url: t, text: n }) => {
|
|
204
|
+
if (ne((l) => ({ ...l, open: !1 })), !t) {
|
|
205
|
+
q.current = null, N.current = null;
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
try {
|
|
209
|
+
const l = window.getSelection();
|
|
210
|
+
l.removeAllRanges(), q.current && l.addRange(q.current);
|
|
211
|
+
} catch {
|
|
212
|
+
}
|
|
213
|
+
try {
|
|
214
|
+
if (N.current)
|
|
215
|
+
try {
|
|
216
|
+
N.current.setAttribute("href", t), N.current.setAttribute("target", "_blank"), N.current.setAttribute("rel", "noopener noreferrer"), N.current.innerText = n || t;
|
|
217
|
+
} catch {
|
|
218
|
+
const l = (a) => String(a).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """), r = `<a href="${l(t)}" target="_blank" rel="noopener noreferrer" contenteditable="false">${l(n || t)}</a>`;
|
|
219
|
+
v("insertHTML", r);
|
|
220
|
+
}
|
|
221
|
+
else if (f.current) {
|
|
222
|
+
f.current.focus();
|
|
223
|
+
const l = (a) => String(a).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """), r = `<a href="${l(t)}" target="_blank" rel="noopener noreferrer" contenteditable="false">${l(n || t)}</a>`;
|
|
224
|
+
v("insertHTML", r);
|
|
225
|
+
}
|
|
226
|
+
} catch {
|
|
227
|
+
try {
|
|
228
|
+
v("createLink", t);
|
|
229
|
+
} catch {
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
q.current = null, N.current = null;
|
|
233
|
+
}, nt = () => {
|
|
234
|
+
if (!N.current) return;
|
|
235
|
+
const t = N.current, n = t.innerText || t.getAttribute("href") || "", l = document.createTextNode(n);
|
|
236
|
+
t.parentNode.replaceChild(l, t), N.current = null, ne((r) => ({ ...r, open: !1 }));
|
|
237
|
+
}, lt = (t) => {
|
|
238
|
+
v("foreColor", t.target.value);
|
|
239
|
+
}, ot = (t) => {
|
|
240
|
+
v("hiliteColor", t.target.value);
|
|
241
|
+
}, rt = (t) => {
|
|
242
|
+
const n = t && t.target ? t.target.value : t;
|
|
243
|
+
v("fontSize", n), Se(String(n));
|
|
244
|
+
}, at = (t) => {
|
|
245
|
+
const n = t && t.target ? t.target.value : t;
|
|
246
|
+
v("fontName", n), Le(String(n));
|
|
247
|
+
}, ct = () => {
|
|
248
|
+
F(!0);
|
|
249
|
+
}, it = () => {
|
|
250
|
+
X && (Me(X), G(""), F(!1));
|
|
251
|
+
}, st = (t) => {
|
|
252
|
+
const n = t.target.files?.[0];
|
|
253
|
+
if (n && n.type.startsWith("image/")) {
|
|
254
|
+
const l = new FileReader();
|
|
255
|
+
l.onload = (r) => {
|
|
256
|
+
const a = r.target?.result;
|
|
257
|
+
Me(a), F(!1);
|
|
258
|
+
}, l.readAsDataURL(n);
|
|
259
|
+
}
|
|
260
|
+
}, Me = (t) => {
|
|
261
|
+
if (!f.current) return;
|
|
262
|
+
f.current.focus();
|
|
263
|
+
const n = document.createElement("div");
|
|
264
|
+
n.className = "editable-image-wrap", n.contentEditable = "false";
|
|
265
|
+
const l = document.createElement("img");
|
|
266
|
+
l.src = t, l.alt = "Image", l.style.maxWidth = "100%", l.style.height = "auto", n.appendChild(l);
|
|
267
|
+
try {
|
|
268
|
+
const r = window.getSelection();
|
|
269
|
+
if (r && r.rangeCount > 0) {
|
|
270
|
+
const a = r.getRangeAt(0);
|
|
271
|
+
a.deleteContents(), a.insertNode(n), a.setStartAfter(n), a.collapse(!0), r.removeAllRanges(), r.addRange(a);
|
|
272
|
+
} else
|
|
273
|
+
f.current.appendChild(n);
|
|
274
|
+
} catch {
|
|
275
|
+
f.current.appendChild(n);
|
|
276
|
+
}
|
|
277
|
+
setTimeout(() => Ee(n), 50);
|
|
278
|
+
}, Ee = (t) => {
|
|
279
|
+
if (!t || t.dataset.enhanced) return;
|
|
280
|
+
const n = t.querySelector("img");
|
|
281
|
+
if (!n) return;
|
|
282
|
+
const l = (u) => {
|
|
283
|
+
u.stopPropagation();
|
|
284
|
+
try {
|
|
285
|
+
f.current?.querySelectorAll(".editable-image-wrap")?.forEach((S) => S.classList.remove("selected"));
|
|
286
|
+
} catch {
|
|
287
|
+
}
|
|
288
|
+
t.classList.add("selected");
|
|
289
|
+
};
|
|
290
|
+
t.addEventListener("click", l);
|
|
291
|
+
const r = document.createElement("div");
|
|
292
|
+
r.className = "image-controls";
|
|
293
|
+
const a = (u, x, S) => {
|
|
294
|
+
const R = document.createElement("button");
|
|
295
|
+
return R.type = "button", R.className = "image-control-btn", R.title = u, R.innerHTML = x, R.addEventListener("click", (U) => {
|
|
296
|
+
U.stopPropagation(), S();
|
|
297
|
+
}), R;
|
|
298
|
+
}, h = () => {
|
|
299
|
+
const u = document.createElement("div");
|
|
300
|
+
return u.className = "image-control-divider", u;
|
|
301
|
+
};
|
|
302
|
+
r.appendChild(a("Align Left", "⇤", () => {
|
|
303
|
+
t.style.display = "block", t.style.marginLeft = "0", t.style.marginRight = "auto";
|
|
304
|
+
})), r.appendChild(a("Center", "≡", () => {
|
|
305
|
+
t.style.display = "block", t.style.marginLeft = "auto", t.style.marginRight = "auto";
|
|
306
|
+
})), r.appendChild(a("Align Right", "⇥", () => {
|
|
307
|
+
t.style.display = "block", t.style.marginLeft = "auto", t.style.marginRight = "0";
|
|
308
|
+
})), r.appendChild(h()), r.appendChild(a("Original Size", "1:1", () => {
|
|
309
|
+
n.style.width = "", n.style.height = "", n.style.maxWidth = "100%";
|
|
310
|
+
})), r.appendChild(a("50% Width", "50%", () => {
|
|
311
|
+
n.style.width = "50%", n.style.height = "auto";
|
|
312
|
+
})), r.appendChild(a("75% Width", "75%", () => {
|
|
313
|
+
n.style.width = "75%", n.style.height = "auto";
|
|
314
|
+
})), r.appendChild(h()), r.appendChild(a("Delete Image", "×", () => {
|
|
315
|
+
confirm("Delete this image?") && t.remove();
|
|
316
|
+
})), t.appendChild(r), ["nw", "ne", "sw", "se"].forEach((u) => {
|
|
317
|
+
const x = document.createElement("div");
|
|
318
|
+
x.className = `image-resize-handle ${u}`, x.addEventListener("mousedown", (S) => {
|
|
319
|
+
S.preventDefault(), S.stopPropagation(), dt(S, n, u);
|
|
320
|
+
}), t.appendChild(x);
|
|
321
|
+
}), t.dataset.enhanced = "1";
|
|
322
|
+
}, dt = (t, n, l) => {
|
|
323
|
+
const r = t.clientX, a = n.offsetWidth, h = n.offsetHeight, u = a / h, x = (R) => {
|
|
324
|
+
const U = R.clientX - r;
|
|
325
|
+
let A = a;
|
|
326
|
+
l.includes("e") ? A = Math.max(50, a + U) : l.includes("w") && (A = Math.max(50, a - U));
|
|
327
|
+
const Q = A / u;
|
|
328
|
+
n.style.width = A + "px", n.style.height = Q + "px", n.style.maxWidth = "none";
|
|
329
|
+
}, S = () => {
|
|
330
|
+
document.removeEventListener("mousemove", x), document.removeEventListener("mouseup", S), document.body.style.cursor = "";
|
|
331
|
+
};
|
|
332
|
+
document.addEventListener("mousemove", x), document.addEventListener("mouseup", S);
|
|
333
|
+
};
|
|
334
|
+
oe(() => {
|
|
335
|
+
const t = f.current;
|
|
336
|
+
if (!t) return;
|
|
337
|
+
const n = (l) => {
|
|
338
|
+
try {
|
|
339
|
+
const r = l.target.closest && l.target.closest("a");
|
|
340
|
+
if (r && r.getAttribute("href")) {
|
|
341
|
+
const a = r.getAttribute("href");
|
|
342
|
+
if (l.metaKey || l.ctrlKey || l.shiftKey) return;
|
|
343
|
+
l.preventDefault(), window.open(a, "_blank");
|
|
344
|
+
}
|
|
345
|
+
} catch {
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
return t.addEventListener("click", n), () => t.removeEventListener("click", n);
|
|
349
|
+
}, []);
|
|
350
|
+
const ht = (t) => {
|
|
351
|
+
v("formatBlock", t), fe(t);
|
|
352
|
+
}, Re = (t, n) => {
|
|
353
|
+
try {
|
|
354
|
+
const h = window.getSelection();
|
|
355
|
+
if (h.removeAllRanges(), q.current)
|
|
356
|
+
h.addRange(q.current);
|
|
357
|
+
else if (f.current) {
|
|
358
|
+
f.current.focus();
|
|
359
|
+
const u = document.createRange();
|
|
360
|
+
u.selectNodeContents(f.current), u.collapse(!1), h.removeAllRanges(), h.addRange(u);
|
|
361
|
+
}
|
|
362
|
+
} catch {
|
|
363
|
+
}
|
|
364
|
+
const l = typeof t == "number" ? t : be, r = typeof n == "number" ? n : xe;
|
|
365
|
+
let a = '<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse; width: auto; margin: 16px 0;">';
|
|
366
|
+
a += "<thead><tr>";
|
|
367
|
+
for (let h = 0; h < r; h++)
|
|
368
|
+
a += `<th style="border: 1px solid #cbd5e1; padding: 12px 16px; background: #f8f9fa; text-align: left; font-weight: 700;">Header ${h + 1}</th>`;
|
|
369
|
+
a += "</tr></thead>", a += "<tbody>";
|
|
370
|
+
for (let h = 0; h < l; h++) {
|
|
371
|
+
a += "<tr>";
|
|
372
|
+
for (let u = 0; u < r; u++)
|
|
373
|
+
a += `<td style="border: 1px solid #cbd5e1; padding: 12px 16px; background: #fff;">Cell ${h + 1}-${u + 1}</td>`;
|
|
374
|
+
a += "</tr>";
|
|
375
|
+
}
|
|
376
|
+
a += "</tbody></table>", v("insertHTML", a), setTimeout(() => {
|
|
377
|
+
try {
|
|
378
|
+
const h = f.current;
|
|
379
|
+
if (!h) return;
|
|
380
|
+
const u = h.querySelector("table:last-of-type");
|
|
381
|
+
u && Ae(u);
|
|
382
|
+
} catch {
|
|
383
|
+
}
|
|
384
|
+
}, 20), ae(!1), Ce(3), we(3);
|
|
385
|
+
}, ut = (t, n) => {
|
|
386
|
+
ue({ rows: t + 1, cols: n + 1 });
|
|
387
|
+
}, mt = (t, n) => {
|
|
388
|
+
Re(t + 1, n + 1), K(!1);
|
|
389
|
+
}, ge = () => {
|
|
390
|
+
if (!_ || !f.current) {
|
|
391
|
+
B("Enter text to find");
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
394
|
+
try {
|
|
395
|
+
const t = window.find(_, !1, !1, !1, !1, !0, !1);
|
|
396
|
+
B(t ? "Found" : "No matches found");
|
|
397
|
+
} catch {
|
|
398
|
+
B("Search not available in this browser");
|
|
399
|
+
}
|
|
400
|
+
}, pt = () => {
|
|
401
|
+
if (!_ || !f.current) {
|
|
402
|
+
B("Enter text to find");
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
try {
|
|
406
|
+
const t = window.getSelection();
|
|
407
|
+
if (t && t.toString().toLowerCase() === _.toLowerCase()) {
|
|
408
|
+
const n = t.getRangeAt(0);
|
|
409
|
+
n.deleteContents(), n.insertNode(document.createTextNode(pe)), B("Replaced 1 occurrence"), setTimeout(() => ge(), 100);
|
|
410
|
+
} else
|
|
411
|
+
ge();
|
|
412
|
+
} catch {
|
|
413
|
+
B("Replace failed");
|
|
414
|
+
}
|
|
415
|
+
}, ft = () => {
|
|
416
|
+
if (!_ || !f.current) {
|
|
417
|
+
B("Enter text to find");
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
try {
|
|
421
|
+
let t = 0;
|
|
422
|
+
const n = f.current.textContent || "", l = new RegExp(_.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "gi"), r = n.match(l);
|
|
423
|
+
if (!r || r.length === 0) {
|
|
424
|
+
B("No matches found");
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
const a = document.createTreeWalker(
|
|
428
|
+
f.current,
|
|
429
|
+
NodeFilter.SHOW_TEXT,
|
|
430
|
+
null,
|
|
431
|
+
!1
|
|
432
|
+
), h = [];
|
|
433
|
+
let u;
|
|
434
|
+
for (; u = a.nextNode(); )
|
|
435
|
+
l.test(u.nodeValue) && h.push(u);
|
|
436
|
+
h.forEach((x) => {
|
|
437
|
+
const S = x.nodeValue.replace(l, pe), R = (x.nodeValue.match(l) || []).length;
|
|
438
|
+
t += R, x.nodeValue = S;
|
|
439
|
+
}), z(f.current.innerHTML), B(`Replaced ${t} occurrence(s)`);
|
|
440
|
+
} catch {
|
|
441
|
+
B("Replace all failed");
|
|
442
|
+
}
|
|
443
|
+
}, Ae = (t) => {
|
|
444
|
+
if (!t || t.dataset.enhanced) return;
|
|
445
|
+
const n = document.createElement("div");
|
|
446
|
+
n.className = "editable-table-wrap", t.parentNode.insertBefore(n, t), n.appendChild(t);
|
|
447
|
+
const l = (o) => {
|
|
448
|
+
const d = o.target.closest("td,th");
|
|
449
|
+
if (d) {
|
|
450
|
+
if (o.shiftKey && E.current && E.current !== d) {
|
|
451
|
+
try {
|
|
452
|
+
f.current.querySelectorAll(".selected-cell").forEach((s) => s.classList.remove("selected-cell"));
|
|
453
|
+
} catch {
|
|
454
|
+
}
|
|
455
|
+
Ht(E.current, d, t), E.current = d;
|
|
456
|
+
return;
|
|
457
|
+
}
|
|
458
|
+
try {
|
|
459
|
+
f.current.querySelectorAll(".selected-cell").forEach((s) => s.classList.remove("selected-cell"));
|
|
460
|
+
} catch {
|
|
461
|
+
}
|
|
462
|
+
d.classList.add("selected-cell"), E.current = d;
|
|
463
|
+
}
|
|
464
|
+
}, r = (o) => {
|
|
465
|
+
try {
|
|
466
|
+
f.current?.querySelectorAll(".editable-table-wrap")?.forEach((c) => c.classList.remove("selected"));
|
|
467
|
+
} catch {
|
|
468
|
+
}
|
|
469
|
+
n.classList.add("selected"), l(o);
|
|
470
|
+
};
|
|
471
|
+
t.addEventListener("click", r);
|
|
472
|
+
try {
|
|
473
|
+
t.querySelectorAll("td,th").forEach((d) => d.addEventListener("click", l));
|
|
474
|
+
} catch {
|
|
475
|
+
}
|
|
476
|
+
const a = document.createElement("div");
|
|
477
|
+
a.className = "table-controls";
|
|
478
|
+
const h = (o, d, c) => {
|
|
479
|
+
const s = document.createElement("button");
|
|
480
|
+
return s.type = "button", s.className = "table-control-btn", s.title = o, s.innerHTML = d, s.addEventListener("click", (m) => {
|
|
481
|
+
m.stopPropagation(), c(t);
|
|
482
|
+
}), s;
|
|
483
|
+
};
|
|
484
|
+
a.appendChild(h("Add Row Below", "+R", (o) => He(o))), a.appendChild(h("Add Column Right", "+C", (o) => Ie(o))), a.appendChild(h("Delete Row", "-R", (o) => vt(o))), a.appendChild(h("Delete Column", "-C", (o) => yt(o))), a.appendChild(h("Delete Table", "×", (o) => Be(o)));
|
|
485
|
+
const u = document.createElement("input");
|
|
486
|
+
u.type = "color", u.style.display = "none", u.addEventListener("input", (o) => {
|
|
487
|
+
try {
|
|
488
|
+
const d = o.target.value;
|
|
489
|
+
E.current && (E.current.style.background = d);
|
|
490
|
+
} catch {
|
|
491
|
+
}
|
|
492
|
+
});
|
|
493
|
+
const x = document.createElement("input");
|
|
494
|
+
x.type = "color", x.style.display = "none", x.addEventListener("input", (o) => {
|
|
495
|
+
try {
|
|
496
|
+
const d = o.target.value;
|
|
497
|
+
let c = [];
|
|
498
|
+
const s = t.querySelector("thead");
|
|
499
|
+
s ? c = Array.from(s.querySelectorAll("th")) : t.rows && t.rows[0] && (c = Array.from(t.rows[0].cells)), c.forEach((m) => {
|
|
500
|
+
m.style.background = d, m.style.color = R(d);
|
|
501
|
+
});
|
|
502
|
+
} catch {
|
|
503
|
+
}
|
|
504
|
+
});
|
|
505
|
+
const S = () => {
|
|
506
|
+
try {
|
|
507
|
+
const o = t.querySelector("thead");
|
|
508
|
+
(o ? Array.from(o.querySelectorAll("th")) : t.rows[0] ? Array.from(t.rows[0].cells) : []).forEach((c) => {
|
|
509
|
+
c.style.background = "", c.style.color = "";
|
|
510
|
+
});
|
|
511
|
+
} catch {
|
|
512
|
+
}
|
|
513
|
+
}, R = (o) => {
|
|
514
|
+
if (!o) return "#000";
|
|
515
|
+
const d = o.replace("#", ""), c = parseInt(d.substr(0, 2), 16), s = parseInt(d.substr(2, 2), 16), m = parseInt(d.substr(4, 2), 16);
|
|
516
|
+
return (c * 299 + s * 587 + m * 114) / 1e3 >= 128 ? "#000" : "#fff";
|
|
517
|
+
}, U = (o) => {
|
|
518
|
+
const d = [];
|
|
519
|
+
for (let c = 0; c < o.rows.length; c++) {
|
|
520
|
+
const s = o.rows[c];
|
|
521
|
+
d[c] = d[c] || [];
|
|
522
|
+
let m = 0;
|
|
523
|
+
for (let p = 0; p < s.cells.length; p++) {
|
|
524
|
+
const g = s.cells[p];
|
|
525
|
+
for (; d[c][m]; ) m++;
|
|
526
|
+
const w = parseInt(g.getAttribute("rowspan") || g.rowSpan || 1, 10), y = parseInt(g.getAttribute("colspan") || g.colSpan || 1, 10);
|
|
527
|
+
for (let k = 0; k < w; k++)
|
|
528
|
+
for (let C = 0; C < y; C++)
|
|
529
|
+
d[c + k] = d[c + k] || [], d[c + k][m + C] = g;
|
|
530
|
+
m += y;
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
return d;
|
|
534
|
+
}, A = (o, d) => {
|
|
535
|
+
const c = U(o);
|
|
536
|
+
for (let s = 0; s < c.length; s++) {
|
|
537
|
+
const m = c[s] || [];
|
|
538
|
+
for (let p = 0; p < m.length; p++)
|
|
539
|
+
if (m[p] === d) return { r: s, c: p, matrix: c };
|
|
540
|
+
}
|
|
541
|
+
return null;
|
|
542
|
+
}, Q = (o, d) => {
|
|
543
|
+
const c = U(o);
|
|
544
|
+
let s = 1 / 0, m = 1 / 0, p = -1 / 0, g = -1 / 0;
|
|
545
|
+
const w = new Set(d);
|
|
546
|
+
for (let M = 0; M < c.length; M++)
|
|
547
|
+
for (let H = 0; H < (c[M] || []).length; H++) {
|
|
548
|
+
const $ = c[M][H];
|
|
549
|
+
!$ || !w.has($) || (s = Math.min(s, M), m = Math.min(m, H), p = Math.max(p, M), g = Math.max(g, H));
|
|
550
|
+
}
|
|
551
|
+
if (s === 1 / 0) return;
|
|
552
|
+
const y = c[s][m], k = /* @__PURE__ */ new Set();
|
|
553
|
+
let C = "";
|
|
554
|
+
for (let M = s; M <= p; M++)
|
|
555
|
+
for (let H = m; H <= g; H++) {
|
|
556
|
+
const $ = c[M][H];
|
|
557
|
+
$ && ($ !== y && k.add($), C.includes($.innerHTML) || (C += (C ? "<br/>" : "") + $.innerHTML));
|
|
558
|
+
}
|
|
559
|
+
const T = p - s + 1, W = g - m + 1;
|
|
560
|
+
try {
|
|
561
|
+
y.rowSpan = T, y.colSpan = W, y.innerHTML = C;
|
|
562
|
+
} catch {
|
|
563
|
+
}
|
|
564
|
+
k.forEach((M) => {
|
|
565
|
+
try {
|
|
566
|
+
M.remove();
|
|
567
|
+
} catch {
|
|
568
|
+
}
|
|
569
|
+
});
|
|
570
|
+
try {
|
|
571
|
+
y.classList.add("selected-cell"), E.current = y;
|
|
572
|
+
} catch {
|
|
573
|
+
}
|
|
574
|
+
}, I = (o, d, c) => {
|
|
575
|
+
const s = A(c, o);
|
|
576
|
+
if (!s) return;
|
|
577
|
+
const { r: m, c: p, matrix: g } = s, w = parseInt(o.getAttribute("rowspan") || o.rowSpan || 1, 10), y = parseInt(o.getAttribute("colspan") || o.colSpan || 1, 10);
|
|
578
|
+
let k = m, C = p;
|
|
579
|
+
if (d === "right" && (C = p + y), d === "left" && (C = p - 1), d === "down" && (k = m + w), d === "up" && (k = m - 1), !g[k] || typeof g[k][C] > "u") return;
|
|
580
|
+
const T = g[k][C];
|
|
581
|
+
if (!T || T === o) return;
|
|
582
|
+
const W = Math.min(m, k), M = Math.max(m, k + (parseInt(T.getAttribute("rowspan") || T.rowSpan || 1, 10) - 1)), H = Math.min(p, C), $ = Math.max(p + (y - 1), C + (parseInt(T.getAttribute("colspan") || T.colSpan || 1, 10) - 1)), Pe = /* @__PURE__ */ new Set();
|
|
583
|
+
for (let de = W; de <= M; de++)
|
|
584
|
+
for (let ve = H; ve <= $; ve++) {
|
|
585
|
+
const $e = g[de] && g[de][ve];
|
|
586
|
+
$e && Pe.add($e);
|
|
587
|
+
}
|
|
588
|
+
Q(c, Pe);
|
|
589
|
+
}, We = (o, d, c) => {
|
|
590
|
+
try {
|
|
591
|
+
if (d === "vertical") {
|
|
592
|
+
const s = parseInt(o.getAttribute("rowspan") || o.rowSpan || 1, 10);
|
|
593
|
+
if (s <= 1) return;
|
|
594
|
+
const m = A(c, o);
|
|
595
|
+
if (!m) return;
|
|
596
|
+
const { r: p, c: g } = m;
|
|
597
|
+
o.rowSpan = 1;
|
|
598
|
+
for (let w = 1; w < s; w++) {
|
|
599
|
+
const y = c.rows[p + w];
|
|
600
|
+
if (y) {
|
|
601
|
+
const k = (() => {
|
|
602
|
+
let T = 0;
|
|
603
|
+
for (let W = 0; W < y.cells.length; W++) {
|
|
604
|
+
const M = y.cells[W], H = parseInt(M.getAttribute("colspan") || M.colSpan || 1, 10);
|
|
605
|
+
if (T >= g) return W;
|
|
606
|
+
T += H;
|
|
607
|
+
}
|
|
608
|
+
return y.cells.length;
|
|
609
|
+
})(), C = y.insertCell(k);
|
|
610
|
+
C.innerHTML = "";
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
} else if (d === "horizontal") {
|
|
614
|
+
const s = parseInt(o.getAttribute("colspan") || o.colSpan || 1, 10);
|
|
615
|
+
if (s <= 1) return;
|
|
616
|
+
const m = o.parentElement, p = Array.prototype.indexOf.call(m.children, o);
|
|
617
|
+
o.colSpan = 1;
|
|
618
|
+
for (let g = 1; g < s; g++) {
|
|
619
|
+
const w = m.insertCell(p + g);
|
|
620
|
+
w.innerHTML = "";
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
} catch {
|
|
624
|
+
}
|
|
625
|
+
}, Et = (o, d) => {
|
|
626
|
+
const c = A(d, o);
|
|
627
|
+
if (!c) return;
|
|
628
|
+
const { r: s, matrix: m } = c;
|
|
629
|
+
try {
|
|
630
|
+
f.current.querySelectorAll(".selected-cell").forEach((g) => g.classList.remove("selected-cell"));
|
|
631
|
+
} catch {
|
|
632
|
+
}
|
|
633
|
+
for (let p = 0; p < (m[s] || []).length; p++) {
|
|
634
|
+
const g = m[s][p];
|
|
635
|
+
g && g.classList.add("selected-cell");
|
|
636
|
+
}
|
|
637
|
+
}, Rt = (o, d) => {
|
|
638
|
+
const c = A(d, o);
|
|
639
|
+
if (!c) return;
|
|
640
|
+
const { c: s, matrix: m } = c;
|
|
641
|
+
try {
|
|
642
|
+
f.current.querySelectorAll(".selected-cell").forEach((g) => g.classList.remove("selected-cell"));
|
|
643
|
+
} catch {
|
|
644
|
+
}
|
|
645
|
+
for (let p = 0; p < m.length; p++) {
|
|
646
|
+
const g = m[p] && m[p][s];
|
|
647
|
+
g && g.classList.add("selected-cell");
|
|
648
|
+
}
|
|
649
|
+
}, At = (o) => {
|
|
650
|
+
try {
|
|
651
|
+
f.current.querySelectorAll(".selected-cell").forEach((c) => c.classList.remove("selected-cell"));
|
|
652
|
+
} catch {
|
|
653
|
+
}
|
|
654
|
+
try {
|
|
655
|
+
o.querySelectorAll("td,th").forEach((c) => c.classList.add("selected-cell"));
|
|
656
|
+
} catch {
|
|
657
|
+
}
|
|
658
|
+
}, Ht = (o, d, c) => {
|
|
659
|
+
const s = A(c, o), m = A(c, d);
|
|
660
|
+
if (!s || !m) return;
|
|
661
|
+
const p = Math.min(s.r, m.r), g = Math.max(s.r, m.r), w = Math.min(s.c, m.c), y = Math.max(s.c, m.c);
|
|
662
|
+
try {
|
|
663
|
+
f.current.querySelectorAll(".selected-cell").forEach((T) => T.classList.remove("selected-cell"));
|
|
664
|
+
} catch {
|
|
665
|
+
}
|
|
666
|
+
const k = s.matrix;
|
|
667
|
+
for (let C = p; C <= g; C++)
|
|
668
|
+
for (let T = w; T <= y; T++) {
|
|
669
|
+
const W = k[C] && k[C][T];
|
|
670
|
+
W && W.classList.add("selected-cell");
|
|
671
|
+
}
|
|
672
|
+
};
|
|
673
|
+
a.appendChild(u), a.appendChild(h("Cell Color", "■", () => {
|
|
674
|
+
if (!E.current) {
|
|
675
|
+
alert("Select a table cell first");
|
|
676
|
+
return;
|
|
677
|
+
}
|
|
678
|
+
u.click();
|
|
679
|
+
})), a.appendChild(x), a.appendChild(h("Header Color", "🎨", () => {
|
|
680
|
+
try {
|
|
681
|
+
const o = t.rows[0];
|
|
682
|
+
if (!o) return alert("Table has no rows");
|
|
683
|
+
if (!(o.cells[0] && o.cells[0].tagName.toLowerCase() === "th")) {
|
|
684
|
+
const c = document.createElement("thead"), s = t.rows[0], m = document.createElement("tr");
|
|
685
|
+
for (let p = 0; p < s.cells.length; p++) {
|
|
686
|
+
const g = document.createElement("th");
|
|
687
|
+
g.innerHTML = s.cells[p].innerHTML, m.appendChild(g);
|
|
688
|
+
}
|
|
689
|
+
c.appendChild(m), t.deleteRow(0), t.insertBefore(c, t.firstChild);
|
|
690
|
+
}
|
|
691
|
+
} catch {
|
|
692
|
+
}
|
|
693
|
+
x.click();
|
|
694
|
+
})), a.appendChild(h("Clear Header Color", "✖", () => {
|
|
695
|
+
S();
|
|
696
|
+
})), a.appendChild(h("Toggle Header", "H", () => {
|
|
697
|
+
try {
|
|
698
|
+
const o = t.rows[0];
|
|
699
|
+
if (!o) return;
|
|
700
|
+
if (o.cells[0] && o.cells[0].tagName.toLowerCase() === "th") {
|
|
701
|
+
const c = document.createElement("tbody");
|
|
702
|
+
for (let s = 0; s < t.rows.length; s++) {
|
|
703
|
+
const m = t.rows[0], p = document.createElement("tr"), g = m.cells;
|
|
704
|
+
for (let w = 0; w < g.length; w++) {
|
|
705
|
+
const y = document.createElement("td");
|
|
706
|
+
y.innerHTML = g[w].innerHTML, y.style.cssText = g[w].style.cssText, p.appendChild(y);
|
|
707
|
+
}
|
|
708
|
+
c.appendChild(p), t.deleteRow(0);
|
|
709
|
+
}
|
|
710
|
+
t.appendChild(c);
|
|
711
|
+
} else {
|
|
712
|
+
const c = document.createElement("thead"), s = t.rows[0], m = document.createElement("tr"), p = s.cells;
|
|
713
|
+
for (let g = 0; g < p.length; g++) {
|
|
714
|
+
const w = document.createElement("th");
|
|
715
|
+
w.innerHTML = p[g].innerHTML, w.style.cssText = p[g].style.cssText, m.appendChild(w);
|
|
716
|
+
}
|
|
717
|
+
c.appendChild(m), t.deleteRow(0), t.insertBefore(c, t.firstChild);
|
|
718
|
+
}
|
|
719
|
+
} catch {
|
|
720
|
+
}
|
|
721
|
+
})), n.appendChild(a), ["nw", "ne", "sw", "se"].forEach((o) => {
|
|
722
|
+
const d = document.createElement("div");
|
|
723
|
+
d.className = `table-resize-handle ${o}`, d.addEventListener("mousedown", (c) => {
|
|
724
|
+
c.preventDefault(), c.stopPropagation(), gt(c, n, t, o);
|
|
725
|
+
}), n.appendChild(d);
|
|
726
|
+
});
|
|
727
|
+
const ce = document.createElement("div");
|
|
728
|
+
ce.className = "table-drag-handle", ce.title = "Drag to move table", n.appendChild(ce);
|
|
729
|
+
const P = document.createElement("div");
|
|
730
|
+
P.className = "table-context-menu", P.innerHTML = `
|
|
731
|
+
<button type="button" data-action="select-row">Select row</button>
|
|
732
|
+
<button type="button" data-action="select-column">Select column</button>
|
|
733
|
+
<button type="button" data-action="select-table">Select table</button>
|
|
734
|
+
<hr/>
|
|
735
|
+
<button type="button" data-action="merge-up">Merge cell up</button>
|
|
736
|
+
<button type="button" data-action="merge-right">Merge cell right</button>
|
|
737
|
+
<button type="button" data-action="merge-down">Merge cell down</button>
|
|
738
|
+
<button type="button" data-action="merge-left">Merge cell left</button>
|
|
739
|
+
<hr/>
|
|
740
|
+
<button type="button" data-action="split-vertical">Split cell vertically</button>
|
|
741
|
+
<button type="button" data-action="split-horizontal">Split cell horizontally</button>
|
|
742
|
+
<hr/>
|
|
743
|
+
<button type="button" data-action="add-row">Add row below</button>
|
|
744
|
+
<button type="button" data-action="add-col">Add column right</button>
|
|
745
|
+
<button type="button" data-action="delete-table">Delete table</button>
|
|
746
|
+
`, P.style.display = "none", n.appendChild(P);
|
|
747
|
+
const ie = (o, d, c) => {
|
|
748
|
+
o ? (P.style.display = "block", P.style.left = typeof d == "number" ? d + "px" : "8px", P.style.top = typeof c == "number" ? c + "px" : "36px") : P.style.display = "none";
|
|
749
|
+
};
|
|
750
|
+
P.addEventListener("click", (o) => {
|
|
751
|
+
o.stopPropagation();
|
|
752
|
+
const d = o.target.closest("button[data-action]");
|
|
753
|
+
if (!d) return;
|
|
754
|
+
const c = d.getAttribute("data-action");
|
|
755
|
+
try {
|
|
756
|
+
const s = E.current || t.rows[0].cells[0];
|
|
757
|
+
if (!s) return;
|
|
758
|
+
c === "select-row" && Et(s, t), c === "select-column" && Rt(s, t), c === "select-table" && At(t), c === "merge-right" && I(s, "right", t), c === "merge-left" && I(s, "left", t), c === "merge-up" && I(s, "up", t), c === "merge-down" && I(s, "down", t), c === "split-vertical" && We(s, "vertical", t), c === "split-horizontal" && We(s, "horizontal", t), c === "add-row" && He(t), c === "add-col" && Ie(t), c === "delete-table" && Be(t);
|
|
759
|
+
} catch {
|
|
760
|
+
}
|
|
761
|
+
ie(!1);
|
|
762
|
+
});
|
|
763
|
+
const Fe = h("Table Menu", "⋮", () => {
|
|
764
|
+
ie(P.style.display !== "block");
|
|
765
|
+
});
|
|
766
|
+
Fe.className += " table-menu-btn", a.appendChild(Fe), n.addEventListener("contextmenu", (o) => {
|
|
767
|
+
o.preventDefault(), q.current = null, E.current = o.target.closest("td,th") || E.current;
|
|
768
|
+
const d = n.getBoundingClientRect();
|
|
769
|
+
ie(!0, o.clientX - d.left, o.clientY - d.top);
|
|
770
|
+
}), document.addEventListener("click", (o) => {
|
|
771
|
+
n.contains(o.target) || ie(!1);
|
|
772
|
+
});
|
|
773
|
+
let se = !1, le = null;
|
|
774
|
+
const qe = (o) => {
|
|
775
|
+
if (!se) return;
|
|
776
|
+
const d = o.clientX - le.x, c = o.clientY - le.y;
|
|
777
|
+
n.style.transform = `translate(${le.tx + d}px, ${le.ty + c}px)`;
|
|
778
|
+
}, Ue = () => {
|
|
779
|
+
if (!se) return;
|
|
780
|
+
se = !1, document.removeEventListener("mousemove", qe), document.removeEventListener("mouseup", Ue);
|
|
781
|
+
const o = n.style.transform.match(/translate\((-?\d+)px,\s*(-?\d+)px\)/);
|
|
782
|
+
if (o) {
|
|
783
|
+
const d = parseInt(o[1], 10), c = parseInt(o[2], 10);
|
|
784
|
+
n.style.left = n.offsetLeft + d + "px", n.style.top = n.offsetTop + c + "px", n.style.transform = "", n.style.position = "absolute";
|
|
785
|
+
}
|
|
786
|
+
};
|
|
787
|
+
ce.addEventListener("mousedown", (o) => {
|
|
788
|
+
o.preventDefault(), o.stopPropagation(), se = !0, le = { x: o.clientX, y: o.clientY, tx: 0, ty: 0 }, document.addEventListener("mousemove", qe), document.addEventListener("mouseup", Ue);
|
|
789
|
+
}), t.dataset.enhanced = "1";
|
|
790
|
+
}, gt = (t, n, l, r) => {
|
|
791
|
+
const a = t.clientX, h = t.clientY, u = l.offsetWidth, x = l.offsetHeight, S = (U) => {
|
|
792
|
+
const A = U.clientX - a, Q = U.clientY - h;
|
|
793
|
+
if (r.includes("e")) {
|
|
794
|
+
const I = Math.max(200, u + A);
|
|
795
|
+
l.style.width = I + "px";
|
|
796
|
+
} else if (r.includes("w")) {
|
|
797
|
+
const I = Math.max(200, u - A);
|
|
798
|
+
l.style.width = I + "px";
|
|
799
|
+
}
|
|
800
|
+
if (r.includes("s")) {
|
|
801
|
+
const I = Math.max(100, x + Q);
|
|
802
|
+
l.style.height = I + "px";
|
|
803
|
+
} else if (r.includes("n")) {
|
|
804
|
+
const I = Math.max(100, x - Q);
|
|
805
|
+
l.style.height = I + "px";
|
|
806
|
+
}
|
|
807
|
+
}, R = () => {
|
|
808
|
+
document.removeEventListener("mousemove", S), document.removeEventListener("mouseup", R), document.body.style.cursor = "";
|
|
809
|
+
};
|
|
810
|
+
document.addEventListener("mousemove", S), document.addEventListener("mouseup", R);
|
|
811
|
+
}, He = (t) => {
|
|
812
|
+
const n = E.current;
|
|
813
|
+
let l = -1;
|
|
814
|
+
n && (l = n.parentElement.rowIndex);
|
|
815
|
+
const r = t.rows[0] ? t.rows[0].cells.length : t.tBodies[0] && t.tBodies[0].rows[0] ? t.tBodies[0].rows[0].cells.length : 1, a = t.insertRow(l + 1);
|
|
816
|
+
for (let h = 0; h < r; h++) {
|
|
817
|
+
const u = a.insertCell(-1);
|
|
818
|
+
u.innerHTML = `Cell ${a.rowIndex}-${h + 1}`;
|
|
819
|
+
}
|
|
820
|
+
}, Ie = (t) => {
|
|
821
|
+
const n = E.current;
|
|
822
|
+
let l = -1;
|
|
823
|
+
n && (l = Array.prototype.indexOf.call(n.parentElement.children, n));
|
|
824
|
+
for (let r = 0; r < t.rows.length; r++) {
|
|
825
|
+
const a = t.rows[r], h = l + 1, u = a.insertCell(h);
|
|
826
|
+
u.innerHTML = "";
|
|
827
|
+
}
|
|
828
|
+
}, vt = (t) => {
|
|
829
|
+
if (t.rows.length <= 1) return;
|
|
830
|
+
const n = E.current;
|
|
831
|
+
let l = n ? n.parentElement.rowIndex : t.rows.length - 1;
|
|
832
|
+
t.deleteRow(l);
|
|
833
|
+
}, yt = (t) => {
|
|
834
|
+
const n = t.rows[0] ? t.rows[0].cells.length : 0;
|
|
835
|
+
if (n <= 1) return;
|
|
836
|
+
const l = E.current;
|
|
837
|
+
let r = l ? Array.prototype.indexOf.call(l.parentElement.children, l) : n - 1;
|
|
838
|
+
for (let a = 0; a < t.rows.length; a++) {
|
|
839
|
+
const h = t.rows[a];
|
|
840
|
+
h.cells[r] && h.deleteCell(r);
|
|
841
|
+
}
|
|
842
|
+
}, Be = (t) => {
|
|
843
|
+
const n = t.closest(".editable-table-wrap");
|
|
844
|
+
n ? n.remove() : t.remove();
|
|
845
|
+
}, bt = () => {
|
|
846
|
+
try {
|
|
847
|
+
const t = f.current;
|
|
848
|
+
if (!t) return;
|
|
849
|
+
t.querySelectorAll("table").forEach((l) => Ae(l));
|
|
850
|
+
} catch {
|
|
851
|
+
}
|
|
852
|
+
}, Ct = () => {
|
|
853
|
+
try {
|
|
854
|
+
const t = f.current;
|
|
855
|
+
if (!t) return;
|
|
856
|
+
t.querySelectorAll("img:not(.editable-image-wrap img)").forEach((l) => {
|
|
857
|
+
if (!l.closest(".editable-image-wrap")) {
|
|
858
|
+
const r = document.createElement("div");
|
|
859
|
+
r.className = "editable-image-wrap", r.contentEditable = "false", l.parentNode.insertBefore(r, l), r.appendChild(l), Ee(r);
|
|
860
|
+
}
|
|
861
|
+
});
|
|
862
|
+
} catch {
|
|
863
|
+
}
|
|
864
|
+
}, xt = () => {
|
|
865
|
+
re(!Y);
|
|
866
|
+
}, wt = () => {
|
|
867
|
+
const t = f.current?.innerHTML || "", n = new Blob([t], { type: "text/html" }), l = URL.createObjectURL(n), r = document.createElement("a");
|
|
868
|
+
r.href = l, r.download = "document.html", r.click(), URL.revokeObjectURL(l);
|
|
869
|
+
};
|
|
870
|
+
oe(() => {
|
|
871
|
+
const t = () => {
|
|
872
|
+
const n = f.current?.innerText || "", l = new Blob([n], { type: "text/plain" }), r = URL.createObjectURL(l), a = document.createElement("a");
|
|
873
|
+
a.href = r, a.download = "document.txt", a.click(), URL.revokeObjectURL(r);
|
|
874
|
+
};
|
|
875
|
+
try {
|
|
876
|
+
window._exportAsText = t;
|
|
877
|
+
} catch {
|
|
878
|
+
}
|
|
879
|
+
return () => {
|
|
880
|
+
try {
|
|
881
|
+
delete window._exportAsText;
|
|
882
|
+
} catch {
|
|
883
|
+
}
|
|
884
|
+
};
|
|
885
|
+
}, []), oe(() => {
|
|
886
|
+
const t = (n) => {
|
|
887
|
+
try {
|
|
888
|
+
const l = n.target.closest(".editable-table-wrap"), r = n.target.closest(".editable-image-wrap");
|
|
889
|
+
!l && f.current && f.current.querySelectorAll(".editable-table-wrap.selected").forEach((h) => h.classList.remove("selected")), !r && f.current && f.current.querySelectorAll(".editable-image-wrap.selected").forEach((h) => h.classList.remove("selected"));
|
|
890
|
+
} catch {
|
|
891
|
+
}
|
|
892
|
+
};
|
|
893
|
+
return document.addEventListener("click", t), () => document.removeEventListener("click", t);
|
|
894
|
+
}, []);
|
|
895
|
+
const kt = (t) => {
|
|
896
|
+
const n = t.target.files?.[0];
|
|
897
|
+
if (n) {
|
|
898
|
+
const l = new FileReader();
|
|
899
|
+
l.onload = (r) => {
|
|
900
|
+
const a = r.target?.result;
|
|
901
|
+
f.current && (f.current.innerHTML = a, z(a), setTimeout(() => {
|
|
902
|
+
bt(), Ct();
|
|
903
|
+
}, 50));
|
|
904
|
+
}, l.readAsText(n);
|
|
905
|
+
}
|
|
906
|
+
}, Nt = () => {
|
|
907
|
+
O(!0);
|
|
908
|
+
}, Lt = () => {
|
|
909
|
+
const t = f.current?.innerHTML || "";
|
|
910
|
+
navigator.clipboard.writeText(t).then(() => {
|
|
911
|
+
alert("HTML copied to clipboard!");
|
|
912
|
+
});
|
|
913
|
+
}, St = () => {
|
|
914
|
+
confirm("Are you sure you want to clear all content?") && f.current && (v("selectAll"), v("delete"), z(""));
|
|
915
|
+
}, Tt = () => {
|
|
916
|
+
const t = prompt("Enter your code:");
|
|
917
|
+
if (t) {
|
|
918
|
+
const n = `<pre><code>${t}</code></pre>`;
|
|
919
|
+
v("insertHTML", n);
|
|
920
|
+
}
|
|
921
|
+
}, Mt = () => {
|
|
922
|
+
v("formatBlock", "blockquote");
|
|
923
|
+
};
|
|
924
|
+
return /* @__PURE__ */ i("div", { className: `editor-container ${Y ? "fullscreen" : ""}`, children: [
|
|
925
|
+
/* @__PURE__ */ e(
|
|
926
|
+
"input",
|
|
927
|
+
{
|
|
928
|
+
type: "file",
|
|
929
|
+
ref: Te,
|
|
930
|
+
onChange: kt,
|
|
931
|
+
accept: ".html,.txt",
|
|
932
|
+
style: { display: "none" }
|
|
933
|
+
}
|
|
934
|
+
),
|
|
935
|
+
/* @__PURE__ */ e("div", { className: "editor-content", children: /* @__PURE__ */ i("div", { className: `page-card size-${ke}`, children: [
|
|
936
|
+
/* @__PURE__ */ i("div", { className: "editor-toolbar", children: [
|
|
937
|
+
/* @__PURE__ */ i("div", { className: "toolbar-group", children: [
|
|
938
|
+
/* @__PURE__ */ e(
|
|
939
|
+
"button",
|
|
940
|
+
{
|
|
941
|
+
className: "toolbar-btn",
|
|
942
|
+
onClick: () => v("undo"),
|
|
943
|
+
title: "Undo",
|
|
944
|
+
children: /* @__PURE__ */ i("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
945
|
+
/* @__PURE__ */ e("path", { d: "M3 7v6h6" }),
|
|
946
|
+
/* @__PURE__ */ e("path", { d: "M21 17a9 9 0 00-9-9 9 9 0 00-6 2.3L3 13" })
|
|
947
|
+
] })
|
|
948
|
+
}
|
|
949
|
+
),
|
|
950
|
+
/* @__PURE__ */ e(
|
|
951
|
+
"button",
|
|
952
|
+
{
|
|
953
|
+
className: "toolbar-btn",
|
|
954
|
+
onClick: () => v("redo"),
|
|
955
|
+
title: "Redo",
|
|
956
|
+
children: /* @__PURE__ */ i("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
957
|
+
/* @__PURE__ */ e("path", { d: "M21 7v6h-6" }),
|
|
958
|
+
/* @__PURE__ */ e("path", { d: "M3 17a9 9 0 019-9 9 9 0 016 2.3l3 2.7" })
|
|
959
|
+
] })
|
|
960
|
+
}
|
|
961
|
+
)
|
|
962
|
+
] }),
|
|
963
|
+
/* @__PURE__ */ e("div", { className: "toolbar-divider" }),
|
|
964
|
+
/* @__PURE__ */ i("div", { className: "toolbar-group", children: [
|
|
965
|
+
/* @__PURE__ */ i(
|
|
966
|
+
"select",
|
|
967
|
+
{
|
|
968
|
+
className: "toolbar-select",
|
|
969
|
+
onChange: at,
|
|
970
|
+
value: Ye,
|
|
971
|
+
children: [
|
|
972
|
+
/* @__PURE__ */ e("option", { value: "Arial", children: "Arial" }),
|
|
973
|
+
/* @__PURE__ */ e("option", { value: "Helvetica", children: "Helvetica" }),
|
|
974
|
+
/* @__PURE__ */ e("option", { value: "Segoe UI", children: "Segoe UI" }),
|
|
975
|
+
/* @__PURE__ */ e("option", { value: "Roboto", children: "Roboto" }),
|
|
976
|
+
/* @__PURE__ */ e("option", { value: "Open Sans", children: "Open Sans" }),
|
|
977
|
+
/* @__PURE__ */ e("option", { value: "Lato", children: "Lato" }),
|
|
978
|
+
/* @__PURE__ */ e("option", { value: "Montserrat", children: "Montserrat" }),
|
|
979
|
+
/* @__PURE__ */ e("option", { value: "Source Sans Pro", children: "Source Sans Pro" }),
|
|
980
|
+
/* @__PURE__ */ e("option", { value: "Tahoma", children: "Tahoma" }),
|
|
981
|
+
/* @__PURE__ */ e("option", { value: "Verdana", children: "Verdana" }),
|
|
982
|
+
/* @__PURE__ */ e("option", { value: "Trebuchet MS", children: "Trebuchet MS" }),
|
|
983
|
+
/* @__PURE__ */ e("option", { value: "Georgia", children: "Georgia" }),
|
|
984
|
+
/* @__PURE__ */ e("option", { value: "Times New Roman", children: "Times New Roman" }),
|
|
985
|
+
/* @__PURE__ */ e("option", { value: "Palatino Linotype", children: "Palatino Linotype" }),
|
|
986
|
+
/* @__PURE__ */ e("option", { value: "Garamond", children: "Garamond" }),
|
|
987
|
+
/* @__PURE__ */ e("option", { value: "Courier New", children: "Courier New" }),
|
|
988
|
+
/* @__PURE__ */ e("option", { value: "Brush Script MT", children: "Brush Script MT" }),
|
|
989
|
+
/* @__PURE__ */ e("option", { value: "Impact", children: "Impact" }),
|
|
990
|
+
/* @__PURE__ */ e("option", { value: "Comic Sans MS", children: "Comic Sans MS" }),
|
|
991
|
+
/* @__PURE__ */ e("option", { value: "Candara", children: "Candara" }),
|
|
992
|
+
/* @__PURE__ */ e("option", { value: "Cambria", children: "Cambria" }),
|
|
993
|
+
/* @__PURE__ */ e("option", { value: "Calibri", children: "Calibri" }),
|
|
994
|
+
/* @__PURE__ */ e("option", { value: "Merriweather", children: "Merriweather" }),
|
|
995
|
+
/* @__PURE__ */ e("option", { value: "Noto Sans", children: "Noto Sans" }),
|
|
996
|
+
/* @__PURE__ */ e("option", { value: "Palatino", children: "Palatino" }),
|
|
997
|
+
/* @__PURE__ */ e("option", { value: "Bookman", children: "Bookman" }),
|
|
998
|
+
/* @__PURE__ */ e("option", { value: "Lucida Sans", children: "Lucida Sans" }),
|
|
999
|
+
/* @__PURE__ */ e("option", { value: "Righteous", children: "Righteous" }),
|
|
1000
|
+
/* @__PURE__ */ e("option", { value: "Poppins", children: "Poppins" })
|
|
1001
|
+
]
|
|
1002
|
+
}
|
|
1003
|
+
),
|
|
1004
|
+
/* @__PURE__ */ i(
|
|
1005
|
+
"select",
|
|
1006
|
+
{
|
|
1007
|
+
className: "toolbar-select",
|
|
1008
|
+
onChange: rt,
|
|
1009
|
+
value: Ge,
|
|
1010
|
+
children: [
|
|
1011
|
+
/* @__PURE__ */ e("option", { value: "1", children: "Small" }),
|
|
1012
|
+
/* @__PURE__ */ e("option", { value: "3", children: "Normal" }),
|
|
1013
|
+
/* @__PURE__ */ e("option", { value: "5", children: "Large" }),
|
|
1014
|
+
/* @__PURE__ */ e("option", { value: "7", children: "Huge" })
|
|
1015
|
+
]
|
|
1016
|
+
}
|
|
1017
|
+
),
|
|
1018
|
+
/* @__PURE__ */ i(
|
|
1019
|
+
"select",
|
|
1020
|
+
{
|
|
1021
|
+
className: "toolbar-select",
|
|
1022
|
+
onChange: (t) => {
|
|
1023
|
+
ht(t.target.value), fe(t.target.value);
|
|
1024
|
+
},
|
|
1025
|
+
value: Ke,
|
|
1026
|
+
children: [
|
|
1027
|
+
/* @__PURE__ */ e("option", { value: "p", children: "Paragraph" }),
|
|
1028
|
+
/* @__PURE__ */ e("option", { value: "h1", children: "Heading 1" }),
|
|
1029
|
+
/* @__PURE__ */ e("option", { value: "h2", children: "Heading 2" }),
|
|
1030
|
+
/* @__PURE__ */ e("option", { value: "h3", children: "Heading 3" }),
|
|
1031
|
+
/* @__PURE__ */ e("option", { value: "h4", children: "Heading 4" })
|
|
1032
|
+
]
|
|
1033
|
+
}
|
|
1034
|
+
)
|
|
1035
|
+
] }),
|
|
1036
|
+
/* @__PURE__ */ e("div", { className: "toolbar-divider" }),
|
|
1037
|
+
/* @__PURE__ */ i("div", { className: "toolbar-group", children: [
|
|
1038
|
+
/* @__PURE__ */ e(
|
|
1039
|
+
"button",
|
|
1040
|
+
{
|
|
1041
|
+
className: `toolbar-btn ${V.bold ? "active" : ""}`,
|
|
1042
|
+
onClick: () => v("bold"),
|
|
1043
|
+
title: "Bold",
|
|
1044
|
+
children: /* @__PURE__ */ i("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", children: [
|
|
1045
|
+
/* @__PURE__ */ e("path", { d: "M6 4h8a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z" }),
|
|
1046
|
+
/* @__PURE__ */ e("path", { d: "M6 12h9a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z" })
|
|
1047
|
+
] })
|
|
1048
|
+
}
|
|
1049
|
+
),
|
|
1050
|
+
/* @__PURE__ */ e(
|
|
1051
|
+
"button",
|
|
1052
|
+
{
|
|
1053
|
+
className: `toolbar-btn ${V.italic ? "active" : ""}`,
|
|
1054
|
+
onClick: () => v("italic"),
|
|
1055
|
+
title: "Italic",
|
|
1056
|
+
children: /* @__PURE__ */ i("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
1057
|
+
/* @__PURE__ */ e("line", { x1: "19", y1: "4", x2: "10", y2: "4" }),
|
|
1058
|
+
/* @__PURE__ */ e("line", { x1: "14", y1: "20", x2: "5", y2: "20" }),
|
|
1059
|
+
/* @__PURE__ */ e("line", { x1: "15", y1: "4", x2: "9", y2: "20" })
|
|
1060
|
+
] })
|
|
1061
|
+
}
|
|
1062
|
+
),
|
|
1063
|
+
/* @__PURE__ */ e(
|
|
1064
|
+
"button",
|
|
1065
|
+
{
|
|
1066
|
+
className: `toolbar-btn ${V.underline ? "active" : ""}`,
|
|
1067
|
+
onClick: () => v("underline"),
|
|
1068
|
+
title: "Underline",
|
|
1069
|
+
children: /* @__PURE__ */ i("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
1070
|
+
/* @__PURE__ */ e("path", { d: "M6 3v7a6 6 0 0 0 6 6 6 6 0 0 0 6-6V3" }),
|
|
1071
|
+
/* @__PURE__ */ e("line", { x1: "4", y1: "21", x2: "20", y2: "21" })
|
|
1072
|
+
] })
|
|
1073
|
+
}
|
|
1074
|
+
),
|
|
1075
|
+
/* @__PURE__ */ e(
|
|
1076
|
+
"button",
|
|
1077
|
+
{
|
|
1078
|
+
className: `toolbar-btn ${V.strikeThrough ? "active" : ""}`,
|
|
1079
|
+
onClick: () => v("strikeThrough"),
|
|
1080
|
+
title: "Strikethrough",
|
|
1081
|
+
children: /* @__PURE__ */ i("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
1082
|
+
/* @__PURE__ */ e("path", { d: "M16 4H9a3 3 0 0 0-2.83 4" }),
|
|
1083
|
+
/* @__PURE__ */ e("path", { d: "M14 12a4 4 0 0 1 0 8H6" }),
|
|
1084
|
+
/* @__PURE__ */ e("line", { x1: "4", y1: "12", x2: "20", y2: "12" })
|
|
1085
|
+
] })
|
|
1086
|
+
}
|
|
1087
|
+
)
|
|
1088
|
+
] }),
|
|
1089
|
+
/* @__PURE__ */ e("div", { className: "toolbar-divider" }),
|
|
1090
|
+
/* @__PURE__ */ i("div", { className: "toolbar-group", children: [
|
|
1091
|
+
/* @__PURE__ */ i("div", { className: "color-picker-wrapper", "data-tooltip": "Text color", "aria-label": "Text color picker", children: [
|
|
1092
|
+
/* @__PURE__ */ e(
|
|
1093
|
+
"input",
|
|
1094
|
+
{
|
|
1095
|
+
type: "color",
|
|
1096
|
+
onChange: lt,
|
|
1097
|
+
className: "color-picker",
|
|
1098
|
+
title: "Text Color",
|
|
1099
|
+
defaultValue: "#111827",
|
|
1100
|
+
"aria-label": "Text color"
|
|
1101
|
+
}
|
|
1102
|
+
),
|
|
1103
|
+
/* @__PURE__ */ e("span", { className: "color-label", children: "A" }),
|
|
1104
|
+
/* @__PURE__ */ e("span", { className: "color-caption", children: "Text color" })
|
|
1105
|
+
] }),
|
|
1106
|
+
/* @__PURE__ */ i("div", { className: "color-picker-wrapper", "data-tooltip": "Highlight / background color", "aria-label": "Background color picker", children: [
|
|
1107
|
+
/* @__PURE__ */ e(
|
|
1108
|
+
"input",
|
|
1109
|
+
{
|
|
1110
|
+
type: "color",
|
|
1111
|
+
onChange: ot,
|
|
1112
|
+
className: "color-picker",
|
|
1113
|
+
title: "Background Color",
|
|
1114
|
+
defaultValue: "#ffffff",
|
|
1115
|
+
"aria-label": "Background color"
|
|
1116
|
+
}
|
|
1117
|
+
),
|
|
1118
|
+
/* @__PURE__ */ e("span", { className: "color-label", children: "◼" }),
|
|
1119
|
+
/* @__PURE__ */ e("span", { className: "color-caption", children: "Highlight" })
|
|
1120
|
+
] })
|
|
1121
|
+
] }),
|
|
1122
|
+
/* @__PURE__ */ e("div", { className: "toolbar-divider" }),
|
|
1123
|
+
/* @__PURE__ */ e("div", { className: "toolbar-group", children: /* @__PURE__ */ i("div", { style: { position: "relative", display: "inline-block" }, children: [
|
|
1124
|
+
/* @__PURE__ */ e(
|
|
1125
|
+
"button",
|
|
1126
|
+
{
|
|
1127
|
+
className: "toolbar-btn",
|
|
1128
|
+
onClick: () => j((t) => !t),
|
|
1129
|
+
title: "More formatting",
|
|
1130
|
+
children: /* @__PURE__ */ i("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
1131
|
+
/* @__PURE__ */ e("circle", { cx: "5", cy: "6", r: "1.2" }),
|
|
1132
|
+
/* @__PURE__ */ e("circle", { cx: "5", cy: "12", r: "1.2" }),
|
|
1133
|
+
/* @__PURE__ */ e("circle", { cx: "5", cy: "18", r: "1.2" }),
|
|
1134
|
+
/* @__PURE__ */ e("line", { x1: "10", y1: "6", x2: "21", y2: "6" }),
|
|
1135
|
+
/* @__PURE__ */ e("line", { x1: "10", y1: "12", x2: "21", y2: "12" }),
|
|
1136
|
+
/* @__PURE__ */ e("line", { x1: "10", y1: "18", x2: "21", y2: "18" })
|
|
1137
|
+
] })
|
|
1138
|
+
}
|
|
1139
|
+
),
|
|
1140
|
+
Ve && /* @__PURE__ */ i("div", { className: "toolbar-dropdown-panel", onClick: (t) => t.stopPropagation(), children: [
|
|
1141
|
+
/* @__PURE__ */ i("div", { className: "toolbar-dropdown-row", children: [
|
|
1142
|
+
/* @__PURE__ */ e("button", { className: `toolbar-btn ${V.justifyLeft ? "active" : ""}`, onClick: () => {
|
|
1143
|
+
v("justifyLeft"), j(!1);
|
|
1144
|
+
}, title: "Align Left", children: /* @__PURE__ */ i("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
1145
|
+
/* @__PURE__ */ e("line", { x1: "17", y1: "10", x2: "3", y2: "10" }),
|
|
1146
|
+
/* @__PURE__ */ e("line", { x1: "21", y1: "6", x2: "3", y2: "6" }),
|
|
1147
|
+
/* @__PURE__ */ e("line", { x1: "21", y1: "14", x2: "3", y2: "14" })
|
|
1148
|
+
] }) }),
|
|
1149
|
+
/* @__PURE__ */ e("button", { className: `toolbar-btn ${V.justifyCenter ? "active" : ""}`, onClick: () => {
|
|
1150
|
+
v("justifyCenter"), j(!1);
|
|
1151
|
+
}, title: "Align Center", children: /* @__PURE__ */ i("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
1152
|
+
/* @__PURE__ */ e("line", { x1: "18", y1: "10", x2: "6", y2: "10" }),
|
|
1153
|
+
/* @__PURE__ */ e("line", { x1: "21", y1: "6", x2: "3", y2: "6" }),
|
|
1154
|
+
/* @__PURE__ */ e("line", { x1: "21", y1: "14", x2: "3", y2: "14" })
|
|
1155
|
+
] }) }),
|
|
1156
|
+
/* @__PURE__ */ e("button", { className: `toolbar-btn ${V.justifyRight ? "active" : ""}`, onClick: () => {
|
|
1157
|
+
v("justifyRight"), j(!1);
|
|
1158
|
+
}, title: "Align Right", children: /* @__PURE__ */ i("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
1159
|
+
/* @__PURE__ */ e("line", { x1: "21", y1: "10", x2: "7", y2: "10" }),
|
|
1160
|
+
/* @__PURE__ */ e("line", { x1: "21", y1: "6", x2: "3", y2: "6" }),
|
|
1161
|
+
/* @__PURE__ */ e("line", { x1: "21", y1: "14", x2: "3", y2: "14" })
|
|
1162
|
+
] }) })
|
|
1163
|
+
] }),
|
|
1164
|
+
/* @__PURE__ */ e("div", { className: "toolbar-dropdown-sep" }),
|
|
1165
|
+
/* @__PURE__ */ i("div", { className: "toolbar-dropdown-row", children: [
|
|
1166
|
+
/* @__PURE__ */ e("button", { className: `toolbar-btn ${V.insertUnorderedList ? "active" : ""}`, onClick: () => {
|
|
1167
|
+
v("insertUnorderedList"), j(!1);
|
|
1168
|
+
}, title: "Bullet List", children: /* @__PURE__ */ i("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
1169
|
+
/* @__PURE__ */ e("line", { x1: "8", y1: "6", x2: "21", y2: "6" }),
|
|
1170
|
+
/* @__PURE__ */ e("line", { x1: "8", y1: "12", x2: "21", y2: "12" }),
|
|
1171
|
+
/* @__PURE__ */ e("circle", { cx: "4", cy: "6", r: "1", fill: "currentColor" })
|
|
1172
|
+
] }) }),
|
|
1173
|
+
/* @__PURE__ */ e("button", { className: `toolbar-btn ${V.insertOrderedList ? "active" : ""}`, onClick: () => {
|
|
1174
|
+
v("insertOrderedList"), j(!1);
|
|
1175
|
+
}, title: "Numbered List", children: /* @__PURE__ */ i("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
1176
|
+
/* @__PURE__ */ e("line", { x1: "10", y1: "6", x2: "21", y2: "6" }),
|
|
1177
|
+
/* @__PURE__ */ e("line", { x1: "10", y1: "12", x2: "21", y2: "12" })
|
|
1178
|
+
] }) }),
|
|
1179
|
+
/* @__PURE__ */ e("button", { className: "toolbar-btn", onClick: () => {
|
|
1180
|
+
v("indent"), j(!1);
|
|
1181
|
+
}, title: "Indent", children: /* @__PURE__ */ e("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ e("line", { x1: "21", y1: "4", x2: "9", y2: "4" }) }) }),
|
|
1182
|
+
/* @__PURE__ */ e("button", { className: "toolbar-btn", onClick: () => {
|
|
1183
|
+
v("outdent"), j(!1);
|
|
1184
|
+
}, title: "Outdent", children: /* @__PURE__ */ e("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ e("line", { x1: "21", y1: "4", x2: "9", y2: "4" }) }) })
|
|
1185
|
+
] })
|
|
1186
|
+
] })
|
|
1187
|
+
] }) }),
|
|
1188
|
+
/* @__PURE__ */ e("div", { className: "toolbar-divider" }),
|
|
1189
|
+
/* @__PURE__ */ i("div", { className: "toolbar-group", children: [
|
|
1190
|
+
/* @__PURE__ */ e(
|
|
1191
|
+
"button",
|
|
1192
|
+
{
|
|
1193
|
+
className: "toolbar-btn",
|
|
1194
|
+
onClick: et,
|
|
1195
|
+
title: "Insert Link",
|
|
1196
|
+
children: /* @__PURE__ */ i("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
1197
|
+
/* @__PURE__ */ e("path", { d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" }),
|
|
1198
|
+
/* @__PURE__ */ e("path", { d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" })
|
|
1199
|
+
] })
|
|
1200
|
+
}
|
|
1201
|
+
),
|
|
1202
|
+
/* @__PURE__ */ e(
|
|
1203
|
+
"button",
|
|
1204
|
+
{
|
|
1205
|
+
className: "toolbar-btn",
|
|
1206
|
+
onClick: ct,
|
|
1207
|
+
title: "Insert Image",
|
|
1208
|
+
children: /* @__PURE__ */ i("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
1209
|
+
/* @__PURE__ */ e("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2", ry: "2" }),
|
|
1210
|
+
/* @__PURE__ */ e("circle", { cx: "8.5", cy: "8.5", r: "1.5" }),
|
|
1211
|
+
/* @__PURE__ */ e("polyline", { points: "21 15 16 10 5 21" })
|
|
1212
|
+
] })
|
|
1213
|
+
}
|
|
1214
|
+
),
|
|
1215
|
+
/* @__PURE__ */ i("div", { style: { position: "relative", display: "inline-block" }, children: [
|
|
1216
|
+
/* @__PURE__ */ e(
|
|
1217
|
+
"button",
|
|
1218
|
+
{
|
|
1219
|
+
className: "toolbar-btn",
|
|
1220
|
+
onClick: () => K(!ee),
|
|
1221
|
+
title: "Insert Table",
|
|
1222
|
+
children: /* @__PURE__ */ i("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
1223
|
+
/* @__PURE__ */ e("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2", ry: "2" }),
|
|
1224
|
+
/* @__PURE__ */ e("line", { x1: "3", y1: "9", x2: "21", y2: "9" }),
|
|
1225
|
+
/* @__PURE__ */ e("line", { x1: "3", y1: "15", x2: "21", y2: "15" }),
|
|
1226
|
+
/* @__PURE__ */ e("line", { x1: "9", y1: "3", x2: "9", y2: "21" }),
|
|
1227
|
+
/* @__PURE__ */ e("line", { x1: "15", y1: "3", x2: "15", y2: "21" })
|
|
1228
|
+
] })
|
|
1229
|
+
}
|
|
1230
|
+
),
|
|
1231
|
+
ee && /* @__PURE__ */ i("div", { className: "table-size-picker show", children: [
|
|
1232
|
+
/* @__PURE__ */ e(
|
|
1233
|
+
"div",
|
|
1234
|
+
{
|
|
1235
|
+
className: "table-size-grid",
|
|
1236
|
+
style: { gridTemplateColumns: "repeat(10, 18px)" },
|
|
1237
|
+
children: Array.from(
|
|
1238
|
+
{ length: 10 },
|
|
1239
|
+
(t, n) => Array.from({ length: 10 }, (l, r) => /* @__PURE__ */ e(
|
|
1240
|
+
"div",
|
|
1241
|
+
{
|
|
1242
|
+
className: `table-cell-preview ${n < L.rows && r < L.cols ? "hover" : ""}`,
|
|
1243
|
+
onMouseEnter: () => ut(n, r),
|
|
1244
|
+
onClick: () => mt(n, r)
|
|
1245
|
+
},
|
|
1246
|
+
`${n}-${r}`
|
|
1247
|
+
))
|
|
1248
|
+
).flat()
|
|
1249
|
+
}
|
|
1250
|
+
),
|
|
1251
|
+
/* @__PURE__ */ i("div", { className: "table-size-label", children: [
|
|
1252
|
+
L.rows,
|
|
1253
|
+
" × ",
|
|
1254
|
+
L.cols
|
|
1255
|
+
] })
|
|
1256
|
+
] })
|
|
1257
|
+
] }),
|
|
1258
|
+
/* @__PURE__ */ e(
|
|
1259
|
+
"button",
|
|
1260
|
+
{
|
|
1261
|
+
className: "toolbar-btn",
|
|
1262
|
+
onClick: () => me(!0),
|
|
1263
|
+
title: "Find and Replace",
|
|
1264
|
+
children: /* @__PURE__ */ i("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
1265
|
+
/* @__PURE__ */ e("circle", { cx: "11", cy: "11", r: "8" }),
|
|
1266
|
+
/* @__PURE__ */ e("path", { d: "m21 21-4.35-4.35" })
|
|
1267
|
+
] })
|
|
1268
|
+
}
|
|
1269
|
+
),
|
|
1270
|
+
/* @__PURE__ */ e(
|
|
1271
|
+
"button",
|
|
1272
|
+
{
|
|
1273
|
+
className: "toolbar-btn",
|
|
1274
|
+
onClick: () => v("insertHorizontalRule"),
|
|
1275
|
+
title: "Horizontal Rule",
|
|
1276
|
+
children: /* @__PURE__ */ e("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ e("line", { x1: "3", y1: "12", x2: "21", y2: "12" }) })
|
|
1277
|
+
}
|
|
1278
|
+
),
|
|
1279
|
+
/* @__PURE__ */ e(
|
|
1280
|
+
"button",
|
|
1281
|
+
{
|
|
1282
|
+
className: "toolbar-btn",
|
|
1283
|
+
onClick: Mt,
|
|
1284
|
+
title: "Insert Quote",
|
|
1285
|
+
children: /* @__PURE__ */ i("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
1286
|
+
/* @__PURE__ */ e("path", { d: "M3 21c3 0 7-1 7-8V5c0-1.25-.756-2.017-2-2H4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2 1 0 1 0 1 1v1c0 1-1 2-2 2s-1 .008-1 1.031V20c0 1 0 1 1 1z" }),
|
|
1287
|
+
/* @__PURE__ */ e("path", { d: "M15 21c3 0 7-1 7-8V5c0-1.25-.757-2.017-2-2h-4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2h.75c0 2.25.25 4-2.75 4v3c0 1 0 1 1 1z" })
|
|
1288
|
+
] })
|
|
1289
|
+
}
|
|
1290
|
+
),
|
|
1291
|
+
/* @__PURE__ */ e(
|
|
1292
|
+
"button",
|
|
1293
|
+
{
|
|
1294
|
+
className: "toolbar-btn",
|
|
1295
|
+
onClick: Tt,
|
|
1296
|
+
title: "Code Block",
|
|
1297
|
+
children: /* @__PURE__ */ i("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
1298
|
+
/* @__PURE__ */ e("polyline", { points: "16 18 22 12 16 6" }),
|
|
1299
|
+
/* @__PURE__ */ e("polyline", { points: "8 6 2 12 8 18" })
|
|
1300
|
+
] })
|
|
1301
|
+
}
|
|
1302
|
+
)
|
|
1303
|
+
] }),
|
|
1304
|
+
/* @__PURE__ */ e("div", { className: "toolbar-divider" }),
|
|
1305
|
+
/* @__PURE__ */ i("div", { className: "toolbar-group", children: [
|
|
1306
|
+
/* @__PURE__ */ i(
|
|
1307
|
+
"select",
|
|
1308
|
+
{
|
|
1309
|
+
className: "toolbar-select",
|
|
1310
|
+
value: ke,
|
|
1311
|
+
onChange: (t) => Xe(t.target.value),
|
|
1312
|
+
title: "Page size",
|
|
1313
|
+
"aria-label": "Page size",
|
|
1314
|
+
children: [
|
|
1315
|
+
/* @__PURE__ */ e("option", { value: "a0", children: "A0" }),
|
|
1316
|
+
/* @__PURE__ */ e("option", { value: "a1", children: "A1" }),
|
|
1317
|
+
/* @__PURE__ */ e("option", { value: "a2", children: "A2" }),
|
|
1318
|
+
/* @__PURE__ */ e("option", { value: "a3", children: "A3" }),
|
|
1319
|
+
/* @__PURE__ */ e("option", { value: "a4", children: "A4" }),
|
|
1320
|
+
/* @__PURE__ */ e("option", { value: "a5", children: "A5" }),
|
|
1321
|
+
/* @__PURE__ */ e("option", { value: "a6", children: "A6" }),
|
|
1322
|
+
/* @__PURE__ */ e("option", { value: "b0", children: "B0" }),
|
|
1323
|
+
/* @__PURE__ */ e("option", { value: "b1", children: "B1" }),
|
|
1324
|
+
/* @__PURE__ */ e("option", { value: "b2", children: "B2" }),
|
|
1325
|
+
/* @__PURE__ */ e("option", { value: "b3", children: "B3" }),
|
|
1326
|
+
/* @__PURE__ */ e("option", { value: "b4", children: "B4" }),
|
|
1327
|
+
/* @__PURE__ */ e("option", { value: "b5", children: "B5" }),
|
|
1328
|
+
/* @__PURE__ */ e("option", { value: "letter", children: "Letter" }),
|
|
1329
|
+
/* @__PURE__ */ e("option", { value: "legal", children: "Legal" }),
|
|
1330
|
+
/* @__PURE__ */ e("option", { value: "ledger", children: "Ledger" }),
|
|
1331
|
+
/* @__PURE__ */ e("option", { value: "tabloid", children: "Tabloid" }),
|
|
1332
|
+
/* @__PURE__ */ e("option", { value: "executive", children: "Executive" }),
|
|
1333
|
+
/* @__PURE__ */ e("option", { value: "statement", children: "Statement" }),
|
|
1334
|
+
/* @__PURE__ */ e("option", { value: "folio", children: "Folio" }),
|
|
1335
|
+
/* @__PURE__ */ e("option", { value: "c4", children: "C4" }),
|
|
1336
|
+
/* @__PURE__ */ e("option", { value: "c5", children: "C5" }),
|
|
1337
|
+
/* @__PURE__ */ e("option", { value: "monarch", children: "Monarch" }),
|
|
1338
|
+
/* @__PURE__ */ e("option", { value: "dl-envelope", children: "Envelope DL" }),
|
|
1339
|
+
/* @__PURE__ */ e("option", { value: "c6-envelope", children: "Envelope C6" }),
|
|
1340
|
+
/* @__PURE__ */ e("option", { value: "custom", children: "Custom" })
|
|
1341
|
+
]
|
|
1342
|
+
}
|
|
1343
|
+
),
|
|
1344
|
+
/* @__PURE__ */ e("button", { className: "toolbar-btn", onClick: () => Te.current?.click(), title: "Import", children: /* @__PURE__ */ i("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
1345
|
+
/* @__PURE__ */ e("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }),
|
|
1346
|
+
/* @__PURE__ */ e("polyline", { points: "7 10 12 15 17 10" }),
|
|
1347
|
+
/* @__PURE__ */ e("line", { x1: "12", y1: "15", x2: "12", y2: "3" })
|
|
1348
|
+
] }) }),
|
|
1349
|
+
/* @__PURE__ */ e("button", { className: "toolbar-btn", onClick: wt, title: "Export HTML", children: /* @__PURE__ */ i("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
1350
|
+
/* @__PURE__ */ e("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }),
|
|
1351
|
+
/* @__PURE__ */ e("polyline", { points: "17 8 12 3 7 8" }),
|
|
1352
|
+
/* @__PURE__ */ e("line", { x1: "12", y1: "3", x2: "12", y2: "15" })
|
|
1353
|
+
] }) }),
|
|
1354
|
+
/* @__PURE__ */ e("button", { className: "toolbar-btn", onClick: Nt, title: "View HTML", children: /* @__PURE__ */ i("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
1355
|
+
/* @__PURE__ */ e("polyline", { points: "16 18 22 12 16 6" }),
|
|
1356
|
+
/* @__PURE__ */ e("polyline", { points: "8 6 2 12 8 18" })
|
|
1357
|
+
] }) }),
|
|
1358
|
+
/* @__PURE__ */ e("button", { className: "toolbar-btn", onClick: St, title: "Clear All", children: /* @__PURE__ */ i("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
1359
|
+
/* @__PURE__ */ e("polyline", { points: "3 6 5 6 21 6" }),
|
|
1360
|
+
/* @__PURE__ */ e("path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" })
|
|
1361
|
+
] }) }),
|
|
1362
|
+
/* @__PURE__ */ e("button", { className: "toolbar-btn", onClick: xt, title: Y ? "Exit Fullscreen" : "Fullscreen", children: /* @__PURE__ */ e("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: Y ? /* @__PURE__ */ e("path", { d: "M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 1 2-2h3M3 16h3a2 2 0 0 1 2 2v3" }) : /* @__PURE__ */ e("path", { d: "M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7" }) }) })
|
|
1363
|
+
] }),
|
|
1364
|
+
/* @__PURE__ */ e("div", { className: "toolbar-divider" }),
|
|
1365
|
+
/* @__PURE__ */ e("div", { className: "toolbar-group", children: /* @__PURE__ */ e(
|
|
1366
|
+
"button",
|
|
1367
|
+
{
|
|
1368
|
+
className: "toolbar-btn",
|
|
1369
|
+
onClick: () => v("removeFormat"),
|
|
1370
|
+
title: "Clear Formatting",
|
|
1371
|
+
children: /* @__PURE__ */ i("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
1372
|
+
/* @__PURE__ */ e("path", { d: "M4 7h16M9 20h6M12 4v16" }),
|
|
1373
|
+
/* @__PURE__ */ e("line", { x1: "3", y1: "3", x2: "21", y2: "21", strokeWidth: "1.5" })
|
|
1374
|
+
] })
|
|
1375
|
+
}
|
|
1376
|
+
) })
|
|
1377
|
+
] }),
|
|
1378
|
+
/* @__PURE__ */ e(
|
|
1379
|
+
"div",
|
|
1380
|
+
{
|
|
1381
|
+
ref: f,
|
|
1382
|
+
className: "page-body",
|
|
1383
|
+
contentEditable: !0,
|
|
1384
|
+
onInput: Ze,
|
|
1385
|
+
suppressContentEditableWarning: !0
|
|
1386
|
+
}
|
|
1387
|
+
)
|
|
1388
|
+
] }) }),
|
|
1389
|
+
/* @__PURE__ */ i("div", { className: "status-bar-bottom", children: [
|
|
1390
|
+
/* @__PURE__ */ i("span", { className: "status-item", children: [
|
|
1391
|
+
"Characters: ",
|
|
1392
|
+
D.replace(/<[^>]*>/g, "").length
|
|
1393
|
+
] }),
|
|
1394
|
+
/* @__PURE__ */ e("span", { className: "status-item", children: "•" }),
|
|
1395
|
+
/* @__PURE__ */ i("span", { className: "status-item", children: [
|
|
1396
|
+
"Words: ",
|
|
1397
|
+
D.replace(/<[^>]*>/g, "").trim().split(/\s+/).filter((t) => t).length
|
|
1398
|
+
] })
|
|
1399
|
+
] }),
|
|
1400
|
+
De && /* @__PURE__ */ e("div", { className: "modal-overlay", onClick: () => ae(!1), children: /* @__PURE__ */ i("div", { className: "modal-content", onClick: (t) => t.stopPropagation(), children: [
|
|
1401
|
+
/* @__PURE__ */ i("div", { className: "modal-header", children: [
|
|
1402
|
+
/* @__PURE__ */ e("h3", { children: "Insert Table" }),
|
|
1403
|
+
/* @__PURE__ */ e("button", { className: "modal-close", onClick: () => ae(!1), children: "×" })
|
|
1404
|
+
] }),
|
|
1405
|
+
/* @__PURE__ */ i("div", { className: "modal-body", children: [
|
|
1406
|
+
/* @__PURE__ */ i("div", { className: "form-group", children: [
|
|
1407
|
+
/* @__PURE__ */ e("label", { children: "Rows:" }),
|
|
1408
|
+
/* @__PURE__ */ e(
|
|
1409
|
+
"input",
|
|
1410
|
+
{
|
|
1411
|
+
type: "number",
|
|
1412
|
+
min: "1",
|
|
1413
|
+
max: "20",
|
|
1414
|
+
value: be,
|
|
1415
|
+
onChange: (t) => Ce(parseInt(t.target.value) || 1),
|
|
1416
|
+
className: "form-input"
|
|
1417
|
+
}
|
|
1418
|
+
)
|
|
1419
|
+
] }),
|
|
1420
|
+
/* @__PURE__ */ i("div", { className: "form-group", children: [
|
|
1421
|
+
/* @__PURE__ */ e("label", { children: "Columns:" }),
|
|
1422
|
+
/* @__PURE__ */ e(
|
|
1423
|
+
"input",
|
|
1424
|
+
{
|
|
1425
|
+
type: "number",
|
|
1426
|
+
min: "1",
|
|
1427
|
+
max: "10",
|
|
1428
|
+
value: xe,
|
|
1429
|
+
onChange: (t) => we(parseInt(t.target.value) || 1),
|
|
1430
|
+
className: "form-input"
|
|
1431
|
+
}
|
|
1432
|
+
)
|
|
1433
|
+
] })
|
|
1434
|
+
] }),
|
|
1435
|
+
/* @__PURE__ */ i("div", { className: "modal-footer", children: [
|
|
1436
|
+
/* @__PURE__ */ e("button", { className: "btn-secondary", onClick: () => ae(!1), children: "Cancel" }),
|
|
1437
|
+
/* @__PURE__ */ e("button", { className: "btn-primary", onClick: Re, children: "Insert Table" })
|
|
1438
|
+
] })
|
|
1439
|
+
] }) }),
|
|
1440
|
+
he && /* @__PURE__ */ e("div", { className: "modal-overlay", onClick: () => O(!1), children: /* @__PURE__ */ i("div", { className: "modal-content modal-large", onClick: (t) => t.stopPropagation(), children: [
|
|
1441
|
+
/* @__PURE__ */ i("div", { className: "modal-header", children: [
|
|
1442
|
+
/* @__PURE__ */ e("h3", { children: "HTML Source Code" }),
|
|
1443
|
+
/* @__PURE__ */ e("button", { className: "modal-close", onClick: () => O(!1), children: "×" })
|
|
1444
|
+
] }),
|
|
1445
|
+
/* @__PURE__ */ e("div", { className: "modal-body", children: /* @__PURE__ */ e("pre", { className: "html-preview", children: D || "" }) }),
|
|
1446
|
+
/* @__PURE__ */ i("div", { className: "modal-footer", children: [
|
|
1447
|
+
/* @__PURE__ */ e("button", { className: "btn-secondary", onClick: () => O(!1), children: "Close" }),
|
|
1448
|
+
/* @__PURE__ */ e("button", { className: "btn-primary", onClick: Lt, children: "Copy HTML" })
|
|
1449
|
+
] })
|
|
1450
|
+
] }) }),
|
|
1451
|
+
ze && /* @__PURE__ */ e("div", { className: "link-modal-overlay", onClick: () => me(!1), children: /* @__PURE__ */ i("div", { className: "find-replace-modal", onClick: (t) => t.stopPropagation(), children: [
|
|
1452
|
+
/* @__PURE__ */ e("h3", { children: "Find and Replace" }),
|
|
1453
|
+
/* @__PURE__ */ i("div", { className: "find-replace-group", children: [
|
|
1454
|
+
/* @__PURE__ */ e("label", { children: "Find:" }),
|
|
1455
|
+
/* @__PURE__ */ e(
|
|
1456
|
+
"input",
|
|
1457
|
+
{
|
|
1458
|
+
type: "text",
|
|
1459
|
+
className: "find-replace-input",
|
|
1460
|
+
value: _,
|
|
1461
|
+
onChange: (t) => Oe(t.target.value),
|
|
1462
|
+
placeholder: "Enter text to find...",
|
|
1463
|
+
autoFocus: !0
|
|
1464
|
+
}
|
|
1465
|
+
)
|
|
1466
|
+
] }),
|
|
1467
|
+
/* @__PURE__ */ i("div", { className: "find-replace-group", children: [
|
|
1468
|
+
/* @__PURE__ */ e("label", { children: "Replace with:" }),
|
|
1469
|
+
/* @__PURE__ */ e(
|
|
1470
|
+
"input",
|
|
1471
|
+
{
|
|
1472
|
+
type: "text",
|
|
1473
|
+
className: "find-replace-input",
|
|
1474
|
+
value: pe,
|
|
1475
|
+
onChange: (t) => je(t.target.value),
|
|
1476
|
+
placeholder: "Enter replacement text..."
|
|
1477
|
+
}
|
|
1478
|
+
)
|
|
1479
|
+
] }),
|
|
1480
|
+
ye && /* @__PURE__ */ e("div", { className: "find-replace-status", children: ye }),
|
|
1481
|
+
/* @__PURE__ */ i("div", { className: "find-replace-buttons", children: [
|
|
1482
|
+
/* @__PURE__ */ e("button", { className: "find-replace-btn primary", onClick: ge, children: "Find Next" }),
|
|
1483
|
+
/* @__PURE__ */ e("button", { className: "find-replace-btn", onClick: pt, children: "Replace" }),
|
|
1484
|
+
/* @__PURE__ */ e("button", { className: "find-replace-btn", onClick: ft, children: "Replace All" }),
|
|
1485
|
+
/* @__PURE__ */ e("button", { className: "find-replace-btn", onClick: () => me(!1), children: "Close" })
|
|
1486
|
+
] })
|
|
1487
|
+
] }) }),
|
|
1488
|
+
Z && /* @__PURE__ */ e("div", { className: "modal-overlay", onClick: () => F(!1), children: /* @__PURE__ */ i("div", { className: "modal-content", onClick: (t) => t.stopPropagation(), children: [
|
|
1489
|
+
/* @__PURE__ */ i("div", { className: "modal-header", children: [
|
|
1490
|
+
/* @__PURE__ */ e("h3", { children: "Insert Image" }),
|
|
1491
|
+
/* @__PURE__ */ e("button", { className: "modal-close", onClick: () => F(!1), children: "×" })
|
|
1492
|
+
] }),
|
|
1493
|
+
/* @__PURE__ */ i("div", { className: "modal-body", children: [
|
|
1494
|
+
/* @__PURE__ */ i("div", { className: "form-group", children: [
|
|
1495
|
+
/* @__PURE__ */ e("label", { children: "Image URL:" }),
|
|
1496
|
+
/* @__PURE__ */ e(
|
|
1497
|
+
"input",
|
|
1498
|
+
{
|
|
1499
|
+
type: "text",
|
|
1500
|
+
placeholder: "https://example.com/image.jpg",
|
|
1501
|
+
value: X,
|
|
1502
|
+
onChange: (t) => G(t.target.value),
|
|
1503
|
+
className: "form-input"
|
|
1504
|
+
}
|
|
1505
|
+
),
|
|
1506
|
+
/* @__PURE__ */ e("button", { className: "btn-primary", onClick: it, style: { marginTop: "10px", width: "100%" }, children: "Insert from URL" })
|
|
1507
|
+
] }),
|
|
1508
|
+
/* @__PURE__ */ i("div", { className: "form-group", style: { marginTop: "20px" }, children: [
|
|
1509
|
+
/* @__PURE__ */ e("label", { children: "Or upload from your device:" }),
|
|
1510
|
+
/* @__PURE__ */ e(
|
|
1511
|
+
"input",
|
|
1512
|
+
{
|
|
1513
|
+
type: "file",
|
|
1514
|
+
ref: Je,
|
|
1515
|
+
onChange: st,
|
|
1516
|
+
accept: "image/*",
|
|
1517
|
+
className: "form-input",
|
|
1518
|
+
style: { padding: "8px" }
|
|
1519
|
+
}
|
|
1520
|
+
)
|
|
1521
|
+
] })
|
|
1522
|
+
] }),
|
|
1523
|
+
/* @__PURE__ */ e("div", { className: "modal-footer", children: /* @__PURE__ */ e("button", { className: "btn-secondary", onClick: () => F(!1), children: "Cancel" }) })
|
|
1524
|
+
] }) }),
|
|
1525
|
+
/* @__PURE__ */ e(
|
|
1526
|
+
It,
|
|
1527
|
+
{
|
|
1528
|
+
isOpen: te.open,
|
|
1529
|
+
onClose: () => ne((t) => ({ ...t, open: !1 })),
|
|
1530
|
+
onInsert: tt,
|
|
1531
|
+
onRemove: nt,
|
|
1532
|
+
isEditing: !!te.isEditing,
|
|
1533
|
+
initialUrl: te.initialUrl,
|
|
1534
|
+
initialText: te.initialText,
|
|
1535
|
+
existingLinks: te.existingLinks
|
|
1536
|
+
}
|
|
1537
|
+
)
|
|
1538
|
+
] });
|
|
1539
|
+
};
|
|
1540
|
+
export {
|
|
1541
|
+
It as LinkModal,
|
|
1542
|
+
qt as RichTextEditor
|
|
1543
|
+
};
|