@daneshnaik/rich-text-editor 1.0.1 → 1.0.3

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/README.md CHANGED
@@ -84,6 +84,33 @@ function App() {
84
84
  export default App;
85
85
  ```
86
86
 
87
+ ### Exporting / Printing (Only toolbar + page)
88
+
89
+ The package includes CSS helpers so consumers can print or export only the editor canvas and toolbar (no surrounding app chrome).
90
+
91
+ - Print: the package defines `@media print` rules that automatically hide other page content and show only `.editor-toolbar` and `.editor-container`.
92
+ - Programmatic export: use the `export-only` helper class on `document.body` to hide everything except the editor, then trigger `window.print()` or your capture routine.
93
+
94
+ Example button (optional):
95
+
96
+ ```jsx
97
+ import React from 'react';
98
+ import ExportButton from './components/ExportButton'; // or from package export when bundled
99
+
100
+ function MyEditorPage() {
101
+ return (
102
+ <div>
103
+ <RichTextEditor />
104
+ <ExportButton />
105
+ </div>
106
+ );
107
+ }
108
+
109
+ export default MyEditorPage;
110
+ ```
111
+
112
+ If you're bundling the library for npm, include the `ExportButton` in your published module exports so consumers can import it directly from the package.
113
+
87
114
  ## Requirements
88
115
 
89
116
  - React 18.0.0 or higher
@@ -1,10 +1,10 @@
1
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);
2
+ import { useState as b, useEffect as oe, useRef as Q } from "react";
3
+ const It = ({ isOpen: J, onClose: z, onInsert: _, onRemove: re, isEditing: he = !1, initialUrl: O = "", initialText: Z = "", existingLinks: F = [] }) => {
4
+ const [D, Y] = b(O), [ee, G] = b(Z);
5
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: [
6
+ J && (Y(O || ""), G(Z || ""));
7
+ }, [J, O, Z]), J ? /* @__PURE__ */ e("div", { className: "modal-overlay", onClick: z, children: /* @__PURE__ */ i("div", { className: "modal-content", onClick: (L) => L.stopPropagation(), children: [
8
8
  /* @__PURE__ */ i("div", { className: "modal-header", children: [
9
9
  /* @__PURE__ */ e("h3", { children: "Insert Link" }),
10
10
  /* @__PURE__ */ e("button", { className: "modal-close", onClick: z, children: "×" })
@@ -18,8 +18,8 @@ const It = ({ isOpen: D, onClose: z, onInsert: Y, onRemove: re, isEditing: he =
18
18
  type: "text",
19
19
  className: "form-input",
20
20
  placeholder: "https://example.com",
21
- value: X,
22
- onChange: (L) => G(L.target.value)
21
+ value: D,
22
+ onChange: (L) => Y(L.target.value)
23
23
  }
24
24
  )
25
25
  ] }),
@@ -31,7 +31,7 @@ const It = ({ isOpen: D, onClose: z, onInsert: Y, onRemove: re, isEditing: he =
31
31
  type: "text",
32
32
  className: "form-input",
33
33
  value: ee,
34
- onChange: (L) => K(L.target.value)
34
+ onChange: (L) => G(L.target.value)
35
35
  }
36
36
  )
37
37
  ] }),
@@ -40,7 +40,7 @@ const It = ({ isOpen: D, onClose: z, onInsert: Y, onRemove: re, isEditing: he =
40
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
41
  /* @__PURE__ */ e("a", { href: L.href, target: "_blank", rel: "noreferrer", children: L.text || L.href }),
42
42
  /* @__PURE__ */ e("button", { type: "button", className: "toolbar-btn", onClick: () => {
43
- G(L.href), K(L.text || L.href);
43
+ Y(L.href), G(L.text || L.href);
44
44
  }, style: { marginLeft: "auto" }, children: "Use" })
45
45
  ] }, ue)) })
46
46
  ] })
@@ -55,7 +55,7 @@ const It = ({ isOpen: D, onClose: z, onInsert: Y, onRemove: re, isEditing: he =
55
55
  {
56
56
  className: "btn-primary",
57
57
  onClick: () => {
58
- Y({ url: X || "", text: ee || X || "" });
58
+ _({ url: D || "", text: ee || D || "" });
59
59
  },
60
60
  children: "Insert"
61
61
  }
@@ -63,7 +63,7 @@ const It = ({ isOpen: D, onClose: z, onInsert: Y, onRemove: re, isEditing: he =
63
63
  ] })
64
64
  ] }) }) : null;
65
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({
66
+ const [J, z] = b(""), [_, re] = b(!1), [he, O] = b(!1), [Z, F] = b(!1), [D, Y] = b(""), [ee, G] = b(!1), [L, ue] = b({ rows: 1, cols: 1 }), [ze, me] = b(!1), [Ve, j] = b(!1), [X, 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
67
  bold: !1,
68
68
  italic: !1,
69
69
  underline: !1,
@@ -158,7 +158,7 @@ const It = ({ isOpen: D, onClose: z, onInsert: Y, onRemove: re, isEditing: he =
158
158
  "Lucida Sans",
159
159
  "Righteous",
160
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) => {
161
+ ]), f = Q(null), Te = Q(null), q = Q(null), N = Q(null), E = Q(null), Je = Q(null), v = (t, n = null) => {
162
162
  try {
163
163
  document.execCommand(t, !1, n);
164
164
  } catch (l) {
@@ -247,7 +247,7 @@ const It = ({ isOpen: D, onClose: z, onInsert: Y, onRemove: re, isEditing: he =
247
247
  }, ct = () => {
248
248
  F(!0);
249
249
  }, it = () => {
250
- X && (Me(X), G(""), F(!1));
250
+ D && (Me(D), Y(""), F(!1));
251
251
  }, st = (t) => {
252
252
  const n = t.target.files?.[0];
253
253
  if (n && n.type.startsWith("image/")) {
@@ -324,8 +324,8 @@ const It = ({ isOpen: D, onClose: z, onInsert: Y, onRemove: re, isEditing: he =
324
324
  const U = R.clientX - r;
325
325
  let A = a;
326
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";
327
+ const K = A / u;
328
+ n.style.width = A + "px", n.style.height = K + "px", n.style.maxWidth = "none";
329
329
  }, S = () => {
330
330
  document.removeEventListener("mousemove", x), document.removeEventListener("mouseup", S), document.body.style.cursor = "";
331
331
  };
@@ -385,26 +385,26 @@ const It = ({ isOpen: D, onClose: z, onInsert: Y, onRemove: re, isEditing: he =
385
385
  }, ut = (t, n) => {
386
386
  ue({ rows: t + 1, cols: n + 1 });
387
387
  }, mt = (t, n) => {
388
- Re(t + 1, n + 1), K(!1);
388
+ Re(t + 1, n + 1), G(!1);
389
389
  }, ge = () => {
390
- if (!_ || !f.current) {
390
+ if (!X || !f.current) {
391
391
  B("Enter text to find");
392
392
  return;
393
393
  }
394
394
  try {
395
- const t = window.find(_, !1, !1, !1, !1, !0, !1);
395
+ const t = window.find(X, !1, !1, !1, !1, !0, !1);
396
396
  B(t ? "Found" : "No matches found");
397
397
  } catch {
398
398
  B("Search not available in this browser");
399
399
  }
400
400
  }, pt = () => {
401
- if (!_ || !f.current) {
401
+ if (!X || !f.current) {
402
402
  B("Enter text to find");
403
403
  return;
404
404
  }
405
405
  try {
406
406
  const t = window.getSelection();
407
- if (t && t.toString().toLowerCase() === _.toLowerCase()) {
407
+ if (t && t.toString().toLowerCase() === X.toLowerCase()) {
408
408
  const n = t.getRangeAt(0);
409
409
  n.deleteContents(), n.insertNode(document.createTextNode(pe)), B("Replaced 1 occurrence"), setTimeout(() => ge(), 100);
410
410
  } else
@@ -413,13 +413,13 @@ const It = ({ isOpen: D, onClose: z, onInsert: Y, onRemove: re, isEditing: he =
413
413
  B("Replace failed");
414
414
  }
415
415
  }, ft = () => {
416
- if (!_ || !f.current) {
416
+ if (!X || !f.current) {
417
417
  B("Enter text to find");
418
418
  return;
419
419
  }
420
420
  try {
421
421
  let t = 0;
422
- const n = f.current.textContent || "", l = new RegExp(_.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "gi"), r = n.match(l);
422
+ const n = f.current.textContent || "", l = new RegExp(X.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "gi"), r = n.match(l);
423
423
  if (!r || r.length === 0) {
424
424
  B("No matches found");
425
425
  return;
@@ -539,7 +539,7 @@ const It = ({ isOpen: D, onClose: z, onInsert: Y, onRemove: re, isEditing: he =
539
539
  if (m[p] === d) return { r: s, c: p, matrix: c };
540
540
  }
541
541
  return null;
542
- }, Q = (o, d) => {
542
+ }, K = (o, d) => {
543
543
  const c = U(o);
544
544
  let s = 1 / 0, m = 1 / 0, p = -1 / 0, g = -1 / 0;
545
545
  const w = new Set(d);
@@ -585,7 +585,7 @@ const It = ({ isOpen: D, onClose: z, onInsert: Y, onRemove: re, isEditing: he =
585
585
  const $e = g[de] && g[de][ve];
586
586
  $e && Pe.add($e);
587
587
  }
588
- Q(c, Pe);
588
+ K(c, Pe);
589
589
  }, We = (o, d, c) => {
590
590
  try {
591
591
  if (d === "vertical") {
@@ -789,7 +789,7 @@ const It = ({ isOpen: D, onClose: z, onInsert: Y, onRemove: re, isEditing: he =
789
789
  }), t.dataset.enhanced = "1";
790
790
  }, gt = (t, n, l, r) => {
791
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;
792
+ const A = U.clientX - a, K = U.clientY - h;
793
793
  if (r.includes("e")) {
794
794
  const I = Math.max(200, u + A);
795
795
  l.style.width = I + "px";
@@ -798,10 +798,10 @@ const It = ({ isOpen: D, onClose: z, onInsert: Y, onRemove: re, isEditing: he =
798
798
  l.style.width = I + "px";
799
799
  }
800
800
  if (r.includes("s")) {
801
- const I = Math.max(100, x + Q);
801
+ const I = Math.max(100, x + K);
802
802
  l.style.height = I + "px";
803
803
  } else if (r.includes("n")) {
804
- const I = Math.max(100, x - Q);
804
+ const I = Math.max(100, x - K);
805
805
  l.style.height = I + "px";
806
806
  }
807
807
  }, R = () => {
@@ -862,7 +862,7 @@ const It = ({ isOpen: D, onClose: z, onInsert: Y, onRemove: re, isEditing: he =
862
862
  } catch {
863
863
  }
864
864
  }, xt = () => {
865
- re(!Y);
865
+ re(!_);
866
866
  }, wt = () => {
867
867
  const t = f.current?.innerHTML || "", n = new Blob([t], { type: "text/html" }), l = URL.createObjectURL(n), r = document.createElement("a");
868
868
  r.href = l, r.download = "document.html", r.click(), URL.revokeObjectURL(l);
@@ -921,7 +921,7 @@ const It = ({ isOpen: D, onClose: z, onInsert: Y, onRemove: re, isEditing: he =
921
921
  }, Mt = () => {
922
922
  v("formatBlock", "blockquote");
923
923
  };
924
- return /* @__PURE__ */ i("div", { className: `editor-container ${Y ? "fullscreen" : ""}`, children: [
924
+ return /* @__PURE__ */ i("div", { className: `editor-container ${_ ? "fullscreen" : ""}`, children: [
925
925
  /* @__PURE__ */ e(
926
926
  "input",
927
927
  {
@@ -1217,7 +1217,7 @@ const It = ({ isOpen: D, onClose: z, onInsert: Y, onRemove: re, isEditing: he =
1217
1217
  "button",
1218
1218
  {
1219
1219
  className: "toolbar-btn",
1220
- onClick: () => K(!ee),
1220
+ onClick: () => G(!ee),
1221
1221
  title: "Insert Table",
1222
1222
  children: /* @__PURE__ */ i("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
1223
1223
  /* @__PURE__ */ e("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2", ry: "2" }),
@@ -1359,7 +1359,7 @@ const It = ({ isOpen: D, onClose: z, onInsert: Y, onRemove: re, isEditing: he =
1359
1359
  /* @__PURE__ */ e("polyline", { points: "3 6 5 6 21 6" }),
1360
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
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" }) }) })
1362
+ /* @__PURE__ */ e("button", { className: "toolbar-btn", onClick: xt, title: _ ? "Exit Fullscreen" : "Fullscreen", children: /* @__PURE__ */ e("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: _ ? /* @__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
1363
  ] }),
1364
1364
  /* @__PURE__ */ e("div", { className: "toolbar-divider" }),
1365
1365
  /* @__PURE__ */ e("div", { className: "toolbar-group", children: /* @__PURE__ */ e(
@@ -1387,17 +1387,6 @@ const It = ({ isOpen: D, onClose: z, onInsert: Y, onRemove: re, isEditing: he =
1387
1387
  }
1388
1388
  )
1389
1389
  ] }) }),
1390
- /* @__PURE__ */ i("div", { className: "status-bar-bottom", children: [
1391
- /* @__PURE__ */ i("span", { className: "status-item", children: [
1392
- "Characters: ",
1393
- D.replace(/<[^>]*>/g, "").length
1394
- ] }),
1395
- /* @__PURE__ */ e("span", { className: "status-item", children: "•" }),
1396
- /* @__PURE__ */ i("span", { className: "status-item", children: [
1397
- "Words: ",
1398
- D.replace(/<[^>]*>/g, "").trim().split(/\s+/).filter((t) => t).length
1399
- ] })
1400
- ] }),
1401
1390
  De && /* @__PURE__ */ e("div", { className: "modal-overlay", onClick: () => ae(!1), children: /* @__PURE__ */ i("div", { className: "modal-content", onClick: (t) => t.stopPropagation(), children: [
1402
1391
  /* @__PURE__ */ i("div", { className: "modal-header", children: [
1403
1392
  /* @__PURE__ */ e("h3", { children: "Insert Table" }),
@@ -1443,7 +1432,7 @@ const It = ({ isOpen: D, onClose: z, onInsert: Y, onRemove: re, isEditing: he =
1443
1432
  /* @__PURE__ */ e("h3", { children: "HTML Source Code" }),
1444
1433
  /* @__PURE__ */ e("button", { className: "modal-close", onClick: () => O(!1), children: "×" })
1445
1434
  ] }),
1446
- /* @__PURE__ */ e("div", { className: "modal-body", children: /* @__PURE__ */ e("pre", { className: "html-preview", children: D || "" }) }),
1435
+ /* @__PURE__ */ e("div", { className: "modal-body", children: /* @__PURE__ */ e("pre", { className: "html-preview", children: J || "" }) }),
1447
1436
  /* @__PURE__ */ i("div", { className: "modal-footer", children: [
1448
1437
  /* @__PURE__ */ e("button", { className: "btn-secondary", onClick: () => O(!1), children: "Close" }),
1449
1438
  /* @__PURE__ */ e("button", { className: "btn-primary", onClick: Lt, children: "Copy HTML" })
@@ -1458,7 +1447,7 @@ const It = ({ isOpen: D, onClose: z, onInsert: Y, onRemove: re, isEditing: he =
1458
1447
  {
1459
1448
  type: "text",
1460
1449
  className: "find-replace-input",
1461
- value: _,
1450
+ value: X,
1462
1451
  onChange: (t) => Oe(t.target.value),
1463
1452
  placeholder: "Enter text to find...",
1464
1453
  autoFocus: !0
@@ -1499,8 +1488,8 @@ const It = ({ isOpen: D, onClose: z, onInsert: Y, onRemove: re, isEditing: he =
1499
1488
  {
1500
1489
  type: "text",
1501
1490
  placeholder: "https://example.com/image.jpg",
1502
- value: X,
1503
- onChange: (t) => G(t.target.value),
1491
+ value: D,
1492
+ onChange: (t) => Y(t.target.value),
1504
1493
  className: "form-input"
1505
1494
  }
1506
1495
  ),
@@ -1,4 +1,4 @@
1
- (function(z,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],e):(z=typeof globalThis<"u"?globalThis:z||self,e(z.RichTextEditor={},z["react/jsx-runtime"],z.React))})(this,(function(z,e,v){"use strict";const ve=({isOpen:X,onClose:j,onInsert:G,onRemove:oe,isEditing:ie=!1,initialUrl:V="",initialText:Z="",existingLinks:q=[]})=>{const[_,K]=v.useState(V),[R,Q]=v.useState(Z);return v.useEffect(()=>{X&&(K(V||""),Q(Z||""))},[X,V,Z]),X?e.jsx("div",{className:"modal-overlay",onClick:j,children:e.jsxs("div",{className:"modal-content",onClick:N=>N.stopPropagation(),children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{children:"Insert Link"}),e.jsx("button",{className:"modal-close",onClick:j,children:"×"})]}),e.jsxs("div",{className:"modal-body",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"URL:"}),e.jsx("input",{type:"text",className:"form-input",placeholder:"https://example.com",value:_,onChange:N=>K(N.target.value)})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Display text:"}),e.jsx("input",{type:"text",className:"form-input",value:R,onChange:N=>Q(N.target.value)})]}),q&&q.length>0&&e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Existing links:"}),e.jsx("ul",{className:"existing-links",style:{maxHeight:160,overflow:"auto",paddingLeft:16},children:q.map((N,de)=>e.jsxs("li",{style:{display:"flex",gap:8,alignItems:"center",marginBottom:6},children:[e.jsx("a",{href:N.href,target:"_blank",rel:"noreferrer",children:N.text||N.href}),e.jsx("button",{type:"button",className:"toolbar-btn",onClick:()=>{K(N.href),Q(N.text||N.href)},style:{marginLeft:"auto"},children:"Use"})]},de))})]})]}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("button",{className:"btn-secondary",onClick:j,children:"Cancel"}),ie&&oe&&e.jsx("button",{className:"btn-secondary",onClick:()=>{oe(),j()},style:{marginRight:8},children:"Remove Link"}),e.jsx("button",{className:"btn-primary",onClick:()=>{G({url:_||"",text:R||_||""})},children:"Insert"})]})]})}):null},ze=()=>{const[X,j]=v.useState(""),[G,oe]=v.useState(!1),[ie,V]=v.useState(!1),[Z,q]=v.useState(!1),[_,K]=v.useState(""),[R,Q]=v.useState(!1),[N,de]=v.useState({rows:1,cols:1}),[je,he]=v.useState(!1),[Oe,D]=v.useState(!1),[Y,Ve]=v.useState(""),[pe,De]=v.useState(""),[ye,B]=v.useState(""),[Xe,ne]=v.useState(!1),[me,be]=v.useState(3),[Ce,xe]=v.useState(3),[we,_e]=v.useState("a4"),[O,Ye]=v.useState({bold:!1,italic:!1,underline:!1,strikeThrough:!1,justifyLeft:!1,justifyCenter:!1,justifyRight:!1,insertUnorderedList:!1,insertOrderedList:!1}),ke=()=>{try{const t={bold:document.queryCommandState("bold"),italic:document.queryCommandState("italic"),underline:document.queryCommandState("underline"),strikeThrough:document.queryCommandState("strikeThrough"),justifyLeft:document.queryCommandState("justifyLeft"),justifyCenter:document.queryCommandState("justifyCenter"),justifyRight:document.queryCommandState("justifyRight"),insertUnorderedList:document.queryCommandState("insertUnorderedList"),insertOrderedList:document.queryCommandState("insertOrderedList")};Ye(t);try{const l=window.getSelection(),o=l&&l.anchorNode?l.anchorNode.nodeType===3?l.anchorNode.parentElement:l.anchorNode:null;let r="";try{r=document.queryCommandValue&&document.queryCommandValue("fontName")||""}catch{r=""}!r&&o&&(r=(window.getComputedStyle(o).fontFamily||"").split(",")[0].replace(/["']/g,"").trim()),r&&(r=String(r).replace(/^[<>"']+|[<>"']+$/g,"").split(",")[0].trim(),Ne(r),Je(h=>h.includes(r)?h:[r,...h]));let a="";try{a=document.queryCommandValue("fontSize")||""}catch{a=""}if(!a&&o){const h=parseFloat(window.getComputedStyle(o).fontSize||"16");h<12?a="1":h<16?a="2":h<18?a="3":h<22?a="4":h<26?a="5":h<32?a="6":a="7"}a&&Se(String(a));let d="";try{d=document.queryCommandValue&&document.queryCommandValue("formatBlock")||""}catch{d=""}if(!d&&o){let h=o;for(;h&&h!==u.current;){if(h.tagName&&/H[1-6]|P|BLOCKQUOTE|DIV/.test(h.tagName)){d=h.tagName.toLowerCase();break}h=h.parentElement}}d&&(d=String(d).replace(/[<>]/g,"").toLowerCase(),/^(p|h[1-6]|blockquote)$/.test(d)||(d="p"),fe(d))}catch{}}catch{}},[Ge,Ne]=v.useState("Arial"),[Ke,Se]=v.useState("3"),[Qe,fe]=v.useState("p"),[Bt,Je]=v.useState(["Arial","Helvetica","Segoe UI","Roboto","Open Sans","Lato","Montserrat","Source Sans Pro","Tahoma","Verdana","Trebuchet MS","Georgia","Times New Roman","Palatino Linotype","Garamond","Courier New","Brush Script MT","Impact","Comic Sans MS","Candara","Cambria","Calibri","Merriweather","Noto Sans","Palatino","Bookman","Lucida Sans","Righteous","Poppins"]),u=v.useRef(null),Le=v.useRef(null),F=v.useRef(null),k=v.useRef(null),M=v.useRef(null),Ze=v.useRef(null),y=(t,l=null)=>{try{document.execCommand(t,!1,l)}catch(o){console.error("execCommand failed:",o)}},Re=()=>{u.current&&(j(u.current.innerHTML),ke())};v.useEffect(()=>{const t=()=>{(document.activeElement===u.current||u.current?.contains(document.activeElement))&&ke()};return document.addEventListener("selectionchange",t),()=>document.removeEventListener("selectionchange",t)},[]);const[ee,te]=v.useState({open:!1,initialUrl:"",initialText:"",existingLinks:[]}),et=()=>{let t="";try{const o=window.getSelection();if(o&&o.rangeCount>0){const r=o.getRangeAt(0);if(u.current&&u.current.contains(r.commonAncestorContainer)){F.current=r,o.isCollapsed||(t=o.toString().trim());try{const a=r.commonAncestorContainer.nodeType===3?r.commonAncestorContainer.parentElement:r.commonAncestorContainer,d=a&&a.closest?a.closest("a"):null;d&&u.current.contains(d)?k.current=d:k.current=null}catch{k.current=null}}else F.current=null,k.current=null}}catch{F.current=null,k.current=null}const l=[];try{const o=u.current;o&&o.querySelectorAll("a").forEach(a=>l.push({href:a.getAttribute("href"),text:a.innerText}))}catch{}k.current?te({open:!0,initialUrl:k.current.getAttribute("href")||"",initialText:k.current.innerText||"",existingLinks:l,isEditing:!0}):te({open:!0,initialUrl:"",initialText:t,existingLinks:l,isEditing:!1})},tt=({url:t,text:l})=>{if(te(o=>({...o,open:!1})),!t){F.current=null,k.current=null;return}try{const o=window.getSelection();o.removeAllRanges(),F.current&&o.addRange(F.current)}catch{}try{if(k.current)try{k.current.setAttribute("href",t),k.current.setAttribute("target","_blank"),k.current.setAttribute("rel","noopener noreferrer"),k.current.innerText=l||t}catch{const o=a=>String(a).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),r=`<a href="${o(t)}" target="_blank" rel="noopener noreferrer" contenteditable="false">${o(l||t)}</a>`;y("insertHTML",r)}else if(u.current){u.current.focus();const o=a=>String(a).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),r=`<a href="${o(t)}" target="_blank" rel="noopener noreferrer" contenteditable="false">${o(l||t)}</a>`;y("insertHTML",r)}}catch{try{y("createLink",t)}catch{}}F.current=null,k.current=null},lt=()=>{if(!k.current)return;const t=k.current,l=t.innerText||t.getAttribute("href")||"",o=document.createTextNode(l);t.parentNode.replaceChild(o,t),k.current=null,te(r=>({...r,open:!1}))},ot=t=>{y("foreColor",t.target.value)},nt=t=>{y("hiliteColor",t.target.value)},rt=t=>{const l=t&&t.target?t.target.value:t;y("fontSize",l),Se(String(l))},at=t=>{const l=t&&t.target?t.target.value:t;y("fontName",l),Ne(String(l))},ct=()=>{q(!0)},st=()=>{_&&(Te(_),K(""),q(!1))},it=t=>{const l=t.target.files?.[0];if(l&&l.type.startsWith("image/")){const o=new FileReader;o.onload=r=>{const a=r.target?.result;Te(a),q(!1)},o.readAsDataURL(l)}},Te=t=>{if(!u.current)return;u.current.focus();const l=document.createElement("div");l.className="editable-image-wrap",l.contentEditable="false";const o=document.createElement("img");o.src=t,o.alt="Image",o.style.maxWidth="100%",o.style.height="auto",l.appendChild(o);try{const r=window.getSelection();if(r&&r.rangeCount>0){const a=r.getRangeAt(0);a.deleteContents(),a.insertNode(l),a.setStartAfter(l),a.collapse(!0),r.removeAllRanges(),r.addRange(a)}else u.current.appendChild(l)}catch{u.current.appendChild(l)}setTimeout(()=>Me(l),50)},Me=t=>{if(!t||t.dataset.enhanced)return;const l=t.querySelector("img");if(!l)return;const o=h=>{h.stopPropagation();try{u.current?.querySelectorAll(".editable-image-wrap")?.forEach(S=>S.classList.remove("selected"))}catch{}t.classList.add("selected")};t.addEventListener("click",o);const r=document.createElement("div");r.className="image-controls";const a=(h,C,S)=>{const E=document.createElement("button");return E.type="button",E.className="image-control-btn",E.title=h,E.innerHTML=C,E.addEventListener("click",U=>{U.stopPropagation(),S()}),E},d=()=>{const h=document.createElement("div");return h.className="image-control-divider",h};r.appendChild(a("Align Left","&#8676;",()=>{t.style.display="block",t.style.marginLeft="0",t.style.marginRight="auto"})),r.appendChild(a("Center","&#8801;",()=>{t.style.display="block",t.style.marginLeft="auto",t.style.marginRight="auto"})),r.appendChild(a("Align Right","&#8677;",()=>{t.style.display="block",t.style.marginLeft="auto",t.style.marginRight="0"})),r.appendChild(d()),r.appendChild(a("Original Size","1:1",()=>{l.style.width="",l.style.height="",l.style.maxWidth="100%"})),r.appendChild(a("50% Width","50%",()=>{l.style.width="50%",l.style.height="auto"})),r.appendChild(a("75% Width","75%",()=>{l.style.width="75%",l.style.height="auto"})),r.appendChild(d()),r.appendChild(a("Delete Image","×",()=>{confirm("Delete this image?")&&t.remove()})),t.appendChild(r),["nw","ne","sw","se"].forEach(h=>{const C=document.createElement("div");C.className=`image-resize-handle ${h}`,C.addEventListener("mousedown",S=>{S.preventDefault(),S.stopPropagation(),dt(S,l,h)}),t.appendChild(C)}),t.dataset.enhanced="1"},dt=(t,l,o)=>{const r=t.clientX,a=l.offsetWidth,d=l.offsetHeight,h=a/d,C=E=>{const U=E.clientX-r;let A=a;o.includes("e")?A=Math.max(50,a+U):o.includes("w")&&(A=Math.max(50,a-U));const J=A/h;l.style.width=A+"px",l.style.height=J+"px",l.style.maxWidth="none"},S=()=>{document.removeEventListener("mousemove",C),document.removeEventListener("mouseup",S),document.body.style.cursor=""};document.addEventListener("mousemove",C),document.addEventListener("mouseup",S)};v.useEffect(()=>{const t=u.current;if(!t)return;const l=o=>{try{const r=o.target.closest&&o.target.closest("a");if(r&&r.getAttribute("href")){const a=r.getAttribute("href");if(o.metaKey||o.ctrlKey||o.shiftKey)return;o.preventDefault(),window.open(a,"_blank")}}catch{}};return t.addEventListener("click",l),()=>t.removeEventListener("click",l)},[]);const ht=t=>{y("formatBlock",t),fe(t)},Ee=(t,l)=>{try{const d=window.getSelection();if(d.removeAllRanges(),F.current)d.addRange(F.current);else if(u.current){u.current.focus();const h=document.createRange();h.selectNodeContents(u.current),h.collapse(!1),d.removeAllRanges(),d.addRange(h)}}catch{}const o=typeof t=="number"?t:me,r=typeof l=="number"?l:Ce;let a='<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse; width: auto; margin: 16px 0;">';a+="<thead><tr>";for(let d=0;d<r;d++)a+=`<th style="border: 1px solid #cbd5e1; padding: 12px 16px; background: #f8f9fa; text-align: left; font-weight: 700;">Header ${d+1}</th>`;a+="</tr></thead>",a+="<tbody>";for(let d=0;d<o;d++){a+="<tr>";for(let h=0;h<r;h++)a+=`<td style="border: 1px solid #cbd5e1; padding: 12px 16px; background: #fff;">Cell ${d+1}-${h+1}</td>`;a+="</tr>"}a+="</tbody></table>",y("insertHTML",a),setTimeout(()=>{try{const d=u.current;if(!d)return;const h=d.querySelector("table:last-of-type");h&&Ae(h)}catch{}},20),ne(!1),be(3),xe(3)},pt=(t,l)=>{de({rows:t+1,cols:l+1})},ft=(t,l)=>{Ee(t+1,l+1),Q(!1)},ue=()=>{if(!Y||!u.current){B("Enter text to find");return}try{const t=window.find(Y,!1,!1,!1,!1,!0,!1);B(t?"Found":"No matches found")}catch{B("Search not available in this browser")}},ut=()=>{if(!Y||!u.current){B("Enter text to find");return}try{const t=window.getSelection();if(t&&t.toString().toLowerCase()===Y.toLowerCase()){const l=t.getRangeAt(0);l.deleteContents(),l.insertNode(document.createTextNode(pe)),B("Replaced 1 occurrence"),setTimeout(()=>ue(),100)}else ue()}catch{B("Replace failed")}},gt=()=>{if(!Y||!u.current){B("Enter text to find");return}try{let t=0;const l=u.current.textContent||"",o=new RegExp(Y.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"gi"),r=l.match(o);if(!r||r.length===0){B("No matches found");return}const a=document.createTreeWalker(u.current,NodeFilter.SHOW_TEXT,null,!1),d=[];let h;for(;h=a.nextNode();)o.test(h.nodeValue)&&d.push(h);d.forEach(C=>{const S=C.nodeValue.replace(o,pe),E=(C.nodeValue.match(o)||[]).length;t+=E,C.nodeValue=S}),j(u.current.innerHTML),B(`Replaced ${t} occurrence(s)`)}catch{B("Replace all failed")}},Ae=t=>{if(!t||t.dataset.enhanced)return;const l=document.createElement("div");l.className="editable-table-wrap",t.parentNode.insertBefore(l,t),l.appendChild(t);const o=n=>{const i=n.target.closest("td,th");if(i){if(n.shiftKey&&M.current&&M.current!==i){try{u.current.querySelectorAll(".selected-cell").forEach(s=>s.classList.remove("selected-cell"))}catch{}It(M.current,i,t),M.current=i;return}try{u.current.querySelectorAll(".selected-cell").forEach(s=>s.classList.remove("selected-cell"))}catch{}i.classList.add("selected-cell"),M.current=i}},r=n=>{try{u.current?.querySelectorAll(".editable-table-wrap")?.forEach(c=>c.classList.remove("selected"))}catch{}l.classList.add("selected"),o(n)};t.addEventListener("click",r);try{t.querySelectorAll("td,th").forEach(i=>i.addEventListener("click",o))}catch{}const a=document.createElement("div");a.className="table-controls";const d=(n,i,c)=>{const s=document.createElement("button");return s.type="button",s.className="table-control-btn",s.title=n,s.innerHTML=i,s.addEventListener("click",p=>{p.stopPropagation(),c(t)}),s};a.appendChild(d("Add Row Below","+R",n=>He(n))),a.appendChild(d("Add Column Right","+C",n=>Ie(n))),a.appendChild(d("Delete Row","-R",n=>yt(n))),a.appendChild(d("Delete Column","-C",n=>mt(n))),a.appendChild(d("Delete Table","×",n=>Be(n)));const h=document.createElement("input");h.type="color",h.style.display="none",h.addEventListener("input",n=>{try{const i=n.target.value;M.current&&(M.current.style.background=i)}catch{}});const C=document.createElement("input");C.type="color",C.style.display="none",C.addEventListener("input",n=>{try{const i=n.target.value;let c=[];const s=t.querySelector("thead");s?c=Array.from(s.querySelectorAll("th")):t.rows&&t.rows[0]&&(c=Array.from(t.rows[0].cells)),c.forEach(p=>{p.style.background=i,p.style.color=E(i)})}catch{}});const S=()=>{try{const n=t.querySelector("thead");(n?Array.from(n.querySelectorAll("th")):t.rows[0]?Array.from(t.rows[0].cells):[]).forEach(c=>{c.style.background="",c.style.color=""})}catch{}},E=n=>{if(!n)return"#000";const i=n.replace("#",""),c=parseInt(i.substr(0,2),16),s=parseInt(i.substr(2,2),16),p=parseInt(i.substr(4,2),16);return(c*299+s*587+p*114)/1e3>=128?"#000":"#fff"},U=n=>{const i=[];for(let c=0;c<n.rows.length;c++){const s=n.rows[c];i[c]=i[c]||[];let p=0;for(let f=0;f<s.cells.length;f++){const g=s.cells[f];for(;i[c][p];)p++;const x=parseInt(g.getAttribute("rowspan")||g.rowSpan||1,10),m=parseInt(g.getAttribute("colspan")||g.colSpan||1,10);for(let w=0;w<x;w++)for(let b=0;b<m;b++)i[c+w]=i[c+w]||[],i[c+w][p+b]=g;p+=m}}return i},A=(n,i)=>{const c=U(n);for(let s=0;s<c.length;s++){const p=c[s]||[];for(let f=0;f<p.length;f++)if(p[f]===i)return{r:s,c:f,matrix:c}}return null},J=(n,i)=>{const c=U(n);let s=1/0,p=1/0,f=-1/0,g=-1/0;const x=new Set(i);for(let T=0;T<c.length;T++)for(let H=0;H<(c[T]||[]).length;H++){const $=c[T][H];!$||!x.has($)||(s=Math.min(s,T),p=Math.min(p,H),f=Math.max(f,T),g=Math.max(g,H))}if(s===1/0)return;const m=c[s][p],w=new Set;let b="";for(let T=s;T<=f;T++)for(let H=p;H<=g;H++){const $=c[T][H];$&&($!==m&&w.add($),b.includes($.innerHTML)||(b+=(b?"<br/>":"")+$.innerHTML))}const L=f-s+1,W=g-p+1;try{m.rowSpan=L,m.colSpan=W,m.innerHTML=b}catch{}w.forEach(T=>{try{T.remove()}catch{}});try{m.classList.add("selected-cell"),M.current=m}catch{}},I=(n,i,c)=>{const s=A(c,n);if(!s)return;const{r:p,c:f,matrix:g}=s,x=parseInt(n.getAttribute("rowspan")||n.rowSpan||1,10),m=parseInt(n.getAttribute("colspan")||n.colSpan||1,10);let w=p,b=f;if(i==="right"&&(b=f+m),i==="left"&&(b=f-1),i==="down"&&(w=p+x),i==="up"&&(w=p-1),!g[w]||typeof g[w][b]>"u")return;const L=g[w][b];if(!L||L===n)return;const W=Math.min(p,w),T=Math.max(p,w+(parseInt(L.getAttribute("rowspan")||L.rowSpan||1,10)-1)),H=Math.min(f,b),$=Math.max(f+(m-1),b+(parseInt(L.getAttribute("colspan")||L.colSpan||1,10)-1)),Pe=new Set;for(let se=W;se<=T;se++)for(let ge=H;ge<=$;ge++){const $e=g[se]&&g[se][ge];$e&&Pe.add($e)}J(c,Pe)},We=(n,i,c)=>{try{if(i==="vertical"){const s=parseInt(n.getAttribute("rowspan")||n.rowSpan||1,10);if(s<=1)return;const p=A(c,n);if(!p)return;const{r:f,c:g}=p;n.rowSpan=1;for(let x=1;x<s;x++){const m=c.rows[f+x];if(m){const w=(()=>{let L=0;for(let W=0;W<m.cells.length;W++){const T=m.cells[W],H=parseInt(T.getAttribute("colspan")||T.colSpan||1,10);if(L>=g)return W;L+=H}return m.cells.length})(),b=m.insertCell(w);b.innerHTML=""}}}else if(i==="horizontal"){const s=parseInt(n.getAttribute("colspan")||n.colSpan||1,10);if(s<=1)return;const p=n.parentElement,f=Array.prototype.indexOf.call(p.children,n);n.colSpan=1;for(let g=1;g<s;g++){const x=p.insertCell(f+g);x.innerHTML=""}}}catch{}},Et=(n,i)=>{const c=A(i,n);if(!c)return;const{r:s,matrix:p}=c;try{u.current.querySelectorAll(".selected-cell").forEach(g=>g.classList.remove("selected-cell"))}catch{}for(let f=0;f<(p[s]||[]).length;f++){const g=p[s][f];g&&g.classList.add("selected-cell")}},At=(n,i)=>{const c=A(i,n);if(!c)return;const{c:s,matrix:p}=c;try{u.current.querySelectorAll(".selected-cell").forEach(g=>g.classList.remove("selected-cell"))}catch{}for(let f=0;f<p.length;f++){const g=p[f]&&p[f][s];g&&g.classList.add("selected-cell")}},Ht=n=>{try{u.current.querySelectorAll(".selected-cell").forEach(c=>c.classList.remove("selected-cell"))}catch{}try{n.querySelectorAll("td,th").forEach(c=>c.classList.add("selected-cell"))}catch{}},It=(n,i,c)=>{const s=A(c,n),p=A(c,i);if(!s||!p)return;const f=Math.min(s.r,p.r),g=Math.max(s.r,p.r),x=Math.min(s.c,p.c),m=Math.max(s.c,p.c);try{u.current.querySelectorAll(".selected-cell").forEach(L=>L.classList.remove("selected-cell"))}catch{}const w=s.matrix;for(let b=f;b<=g;b++)for(let L=x;L<=m;L++){const W=w[b]&&w[b][L];W&&W.classList.add("selected-cell")}};a.appendChild(h),a.appendChild(d("Cell Color","■",()=>{if(!M.current){alert("Select a table cell first");return}h.click()})),a.appendChild(C),a.appendChild(d("Header Color","🎨",()=>{try{const n=t.rows[0];if(!n)return alert("Table has no rows");if(!(n.cells[0]&&n.cells[0].tagName.toLowerCase()==="th")){const c=document.createElement("thead"),s=t.rows[0],p=document.createElement("tr");for(let f=0;f<s.cells.length;f++){const g=document.createElement("th");g.innerHTML=s.cells[f].innerHTML,p.appendChild(g)}c.appendChild(p),t.deleteRow(0),t.insertBefore(c,t.firstChild)}}catch{}C.click()})),a.appendChild(d("Clear Header Color","✖",()=>{S()})),a.appendChild(d("Toggle Header","H",()=>{try{const n=t.rows[0];if(!n)return;if(n.cells[0]&&n.cells[0].tagName.toLowerCase()==="th"){const c=document.createElement("tbody");for(let s=0;s<t.rows.length;s++){const p=t.rows[0],f=document.createElement("tr"),g=p.cells;for(let x=0;x<g.length;x++){const m=document.createElement("td");m.innerHTML=g[x].innerHTML,m.style.cssText=g[x].style.cssText,f.appendChild(m)}c.appendChild(f),t.deleteRow(0)}t.appendChild(c)}else{const c=document.createElement("thead"),s=t.rows[0],p=document.createElement("tr"),f=s.cells;for(let g=0;g<f.length;g++){const x=document.createElement("th");x.innerHTML=f[g].innerHTML,x.style.cssText=f[g].style.cssText,p.appendChild(x)}c.appendChild(p),t.deleteRow(0),t.insertBefore(c,t.firstChild)}}catch{}})),l.appendChild(a),["nw","ne","sw","se"].forEach(n=>{const i=document.createElement("div");i.className=`table-resize-handle ${n}`,i.addEventListener("mousedown",c=>{c.preventDefault(),c.stopPropagation(),vt(c,l,t,n)}),l.appendChild(i)});const re=document.createElement("div");re.className="table-drag-handle",re.title="Drag to move table",l.appendChild(re);const P=document.createElement("div");P.className="table-context-menu",P.innerHTML=`
1
+ (function(z,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],e):(z=typeof globalThis<"u"?globalThis:z||self,e(z.RichTextEditor={},z["react/jsx-runtime"],z.React))})(this,(function(z,e,v){"use strict";const ve=({isOpen:J,onClose:j,onInsert:Y,onRemove:le,isEditing:ie=!1,initialUrl:V="",initialText:Z="",existingLinks:q=[]})=>{const[X,G]=v.useState(V),[R,K]=v.useState(Z);return v.useEffect(()=>{J&&(G(V||""),K(Z||""))},[J,V,Z]),J?e.jsx("div",{className:"modal-overlay",onClick:j,children:e.jsxs("div",{className:"modal-content",onClick:N=>N.stopPropagation(),children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{children:"Insert Link"}),e.jsx("button",{className:"modal-close",onClick:j,children:"×"})]}),e.jsxs("div",{className:"modal-body",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"URL:"}),e.jsx("input",{type:"text",className:"form-input",placeholder:"https://example.com",value:X,onChange:N=>G(N.target.value)})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Display text:"}),e.jsx("input",{type:"text",className:"form-input",value:R,onChange:N=>K(N.target.value)})]}),q&&q.length>0&&e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Existing links:"}),e.jsx("ul",{className:"existing-links",style:{maxHeight:160,overflow:"auto",paddingLeft:16},children:q.map((N,de)=>e.jsxs("li",{style:{display:"flex",gap:8,alignItems:"center",marginBottom:6},children:[e.jsx("a",{href:N.href,target:"_blank",rel:"noreferrer",children:N.text||N.href}),e.jsx("button",{type:"button",className:"toolbar-btn",onClick:()=>{G(N.href),K(N.text||N.href)},style:{marginLeft:"auto"},children:"Use"})]},de))})]})]}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("button",{className:"btn-secondary",onClick:j,children:"Cancel"}),ie&&le&&e.jsx("button",{className:"btn-secondary",onClick:()=>{le(),j()},style:{marginRight:8},children:"Remove Link"}),e.jsx("button",{className:"btn-primary",onClick:()=>{Y({url:X||"",text:R||X||""})},children:"Insert"})]})]})}):null},ze=()=>{const[J,j]=v.useState(""),[Y,le]=v.useState(!1),[ie,V]=v.useState(!1),[Z,q]=v.useState(!1),[X,G]=v.useState(""),[R,K]=v.useState(!1),[N,de]=v.useState({rows:1,cols:1}),[je,he]=v.useState(!1),[Oe,D]=v.useState(!1),[_,Ve]=v.useState(""),[pe,De]=v.useState(""),[ye,B]=v.useState(""),[Xe,ne]=v.useState(!1),[me,be]=v.useState(3),[Ce,xe]=v.useState(3),[we,_e]=v.useState("a4"),[O,Ye]=v.useState({bold:!1,italic:!1,underline:!1,strikeThrough:!1,justifyLeft:!1,justifyCenter:!1,justifyRight:!1,insertUnorderedList:!1,insertOrderedList:!1}),ke=()=>{try{const t={bold:document.queryCommandState("bold"),italic:document.queryCommandState("italic"),underline:document.queryCommandState("underline"),strikeThrough:document.queryCommandState("strikeThrough"),justifyLeft:document.queryCommandState("justifyLeft"),justifyCenter:document.queryCommandState("justifyCenter"),justifyRight:document.queryCommandState("justifyRight"),insertUnorderedList:document.queryCommandState("insertUnorderedList"),insertOrderedList:document.queryCommandState("insertOrderedList")};Ye(t);try{const o=window.getSelection(),l=o&&o.anchorNode?o.anchorNode.nodeType===3?o.anchorNode.parentElement:o.anchorNode:null;let r="";try{r=document.queryCommandValue&&document.queryCommandValue("fontName")||""}catch{r=""}!r&&l&&(r=(window.getComputedStyle(l).fontFamily||"").split(",")[0].replace(/["']/g,"").trim()),r&&(r=String(r).replace(/^[<>"']+|[<>"']+$/g,"").split(",")[0].trim(),Ne(r),Je(h=>h.includes(r)?h:[r,...h]));let a="";try{a=document.queryCommandValue("fontSize")||""}catch{a=""}if(!a&&l){const h=parseFloat(window.getComputedStyle(l).fontSize||"16");h<12?a="1":h<16?a="2":h<18?a="3":h<22?a="4":h<26?a="5":h<32?a="6":a="7"}a&&Se(String(a));let d="";try{d=document.queryCommandValue&&document.queryCommandValue("formatBlock")||""}catch{d=""}if(!d&&l){let h=l;for(;h&&h!==u.current;){if(h.tagName&&/H[1-6]|P|BLOCKQUOTE|DIV/.test(h.tagName)){d=h.tagName.toLowerCase();break}h=h.parentElement}}d&&(d=String(d).replace(/[<>]/g,"").toLowerCase(),/^(p|h[1-6]|blockquote)$/.test(d)||(d="p"),fe(d))}catch{}}catch{}},[Ge,Ne]=v.useState("Arial"),[Ke,Se]=v.useState("3"),[Qe,fe]=v.useState("p"),[Bt,Je]=v.useState(["Arial","Helvetica","Segoe UI","Roboto","Open Sans","Lato","Montserrat","Source Sans Pro","Tahoma","Verdana","Trebuchet MS","Georgia","Times New Roman","Palatino Linotype","Garamond","Courier New","Brush Script MT","Impact","Comic Sans MS","Candara","Cambria","Calibri","Merriweather","Noto Sans","Palatino","Bookman","Lucida Sans","Righteous","Poppins"]),u=v.useRef(null),Le=v.useRef(null),F=v.useRef(null),k=v.useRef(null),M=v.useRef(null),Ze=v.useRef(null),y=(t,o=null)=>{try{document.execCommand(t,!1,o)}catch(l){console.error("execCommand failed:",l)}},Re=()=>{u.current&&(j(u.current.innerHTML),ke())};v.useEffect(()=>{const t=()=>{(document.activeElement===u.current||u.current?.contains(document.activeElement))&&ke()};return document.addEventListener("selectionchange",t),()=>document.removeEventListener("selectionchange",t)},[]);const[ee,te]=v.useState({open:!1,initialUrl:"",initialText:"",existingLinks:[]}),et=()=>{let t="";try{const l=window.getSelection();if(l&&l.rangeCount>0){const r=l.getRangeAt(0);if(u.current&&u.current.contains(r.commonAncestorContainer)){F.current=r,l.isCollapsed||(t=l.toString().trim());try{const a=r.commonAncestorContainer.nodeType===3?r.commonAncestorContainer.parentElement:r.commonAncestorContainer,d=a&&a.closest?a.closest("a"):null;d&&u.current.contains(d)?k.current=d:k.current=null}catch{k.current=null}}else F.current=null,k.current=null}}catch{F.current=null,k.current=null}const o=[];try{const l=u.current;l&&l.querySelectorAll("a").forEach(a=>o.push({href:a.getAttribute("href"),text:a.innerText}))}catch{}k.current?te({open:!0,initialUrl:k.current.getAttribute("href")||"",initialText:k.current.innerText||"",existingLinks:o,isEditing:!0}):te({open:!0,initialUrl:"",initialText:t,existingLinks:o,isEditing:!1})},tt=({url:t,text:o})=>{if(te(l=>({...l,open:!1})),!t){F.current=null,k.current=null;return}try{const l=window.getSelection();l.removeAllRanges(),F.current&&l.addRange(F.current)}catch{}try{if(k.current)try{k.current.setAttribute("href",t),k.current.setAttribute("target","_blank"),k.current.setAttribute("rel","noopener noreferrer"),k.current.innerText=o||t}catch{const l=a=>String(a).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),r=`<a href="${l(t)}" target="_blank" rel="noopener noreferrer" contenteditable="false">${l(o||t)}</a>`;y("insertHTML",r)}else if(u.current){u.current.focus();const l=a=>String(a).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),r=`<a href="${l(t)}" target="_blank" rel="noopener noreferrer" contenteditable="false">${l(o||t)}</a>`;y("insertHTML",r)}}catch{try{y("createLink",t)}catch{}}F.current=null,k.current=null},ot=()=>{if(!k.current)return;const t=k.current,o=t.innerText||t.getAttribute("href")||"",l=document.createTextNode(o);t.parentNode.replaceChild(l,t),k.current=null,te(r=>({...r,open:!1}))},lt=t=>{y("foreColor",t.target.value)},nt=t=>{y("hiliteColor",t.target.value)},rt=t=>{const o=t&&t.target?t.target.value:t;y("fontSize",o),Se(String(o))},at=t=>{const o=t&&t.target?t.target.value:t;y("fontName",o),Ne(String(o))},ct=()=>{q(!0)},st=()=>{X&&(Te(X),G(""),q(!1))},it=t=>{const o=t.target.files?.[0];if(o&&o.type.startsWith("image/")){const l=new FileReader;l.onload=r=>{const a=r.target?.result;Te(a),q(!1)},l.readAsDataURL(o)}},Te=t=>{if(!u.current)return;u.current.focus();const o=document.createElement("div");o.className="editable-image-wrap",o.contentEditable="false";const l=document.createElement("img");l.src=t,l.alt="Image",l.style.maxWidth="100%",l.style.height="auto",o.appendChild(l);try{const r=window.getSelection();if(r&&r.rangeCount>0){const a=r.getRangeAt(0);a.deleteContents(),a.insertNode(o),a.setStartAfter(o),a.collapse(!0),r.removeAllRanges(),r.addRange(a)}else u.current.appendChild(o)}catch{u.current.appendChild(o)}setTimeout(()=>Me(o),50)},Me=t=>{if(!t||t.dataset.enhanced)return;const o=t.querySelector("img");if(!o)return;const l=h=>{h.stopPropagation();try{u.current?.querySelectorAll(".editable-image-wrap")?.forEach(S=>S.classList.remove("selected"))}catch{}t.classList.add("selected")};t.addEventListener("click",l);const r=document.createElement("div");r.className="image-controls";const a=(h,C,S)=>{const E=document.createElement("button");return E.type="button",E.className="image-control-btn",E.title=h,E.innerHTML=C,E.addEventListener("click",U=>{U.stopPropagation(),S()}),E},d=()=>{const h=document.createElement("div");return h.className="image-control-divider",h};r.appendChild(a("Align Left","&#8676;",()=>{t.style.display="block",t.style.marginLeft="0",t.style.marginRight="auto"})),r.appendChild(a("Center","&#8801;",()=>{t.style.display="block",t.style.marginLeft="auto",t.style.marginRight="auto"})),r.appendChild(a("Align Right","&#8677;",()=>{t.style.display="block",t.style.marginLeft="auto",t.style.marginRight="0"})),r.appendChild(d()),r.appendChild(a("Original Size","1:1",()=>{o.style.width="",o.style.height="",o.style.maxWidth="100%"})),r.appendChild(a("50% Width","50%",()=>{o.style.width="50%",o.style.height="auto"})),r.appendChild(a("75% Width","75%",()=>{o.style.width="75%",o.style.height="auto"})),r.appendChild(d()),r.appendChild(a("Delete Image","×",()=>{confirm("Delete this image?")&&t.remove()})),t.appendChild(r),["nw","ne","sw","se"].forEach(h=>{const C=document.createElement("div");C.className=`image-resize-handle ${h}`,C.addEventListener("mousedown",S=>{S.preventDefault(),S.stopPropagation(),dt(S,o,h)}),t.appendChild(C)}),t.dataset.enhanced="1"},dt=(t,o,l)=>{const r=t.clientX,a=o.offsetWidth,d=o.offsetHeight,h=a/d,C=E=>{const U=E.clientX-r;let A=a;l.includes("e")?A=Math.max(50,a+U):l.includes("w")&&(A=Math.max(50,a-U));const Q=A/h;o.style.width=A+"px",o.style.height=Q+"px",o.style.maxWidth="none"},S=()=>{document.removeEventListener("mousemove",C),document.removeEventListener("mouseup",S),document.body.style.cursor=""};document.addEventListener("mousemove",C),document.addEventListener("mouseup",S)};v.useEffect(()=>{const t=u.current;if(!t)return;const o=l=>{try{const r=l.target.closest&&l.target.closest("a");if(r&&r.getAttribute("href")){const a=r.getAttribute("href");if(l.metaKey||l.ctrlKey||l.shiftKey)return;l.preventDefault(),window.open(a,"_blank")}}catch{}};return t.addEventListener("click",o),()=>t.removeEventListener("click",o)},[]);const ht=t=>{y("formatBlock",t),fe(t)},Ee=(t,o)=>{try{const d=window.getSelection();if(d.removeAllRanges(),F.current)d.addRange(F.current);else if(u.current){u.current.focus();const h=document.createRange();h.selectNodeContents(u.current),h.collapse(!1),d.removeAllRanges(),d.addRange(h)}}catch{}const l=typeof t=="number"?t:me,r=typeof o=="number"?o:Ce;let a='<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse; width: auto; margin: 16px 0;">';a+="<thead><tr>";for(let d=0;d<r;d++)a+=`<th style="border: 1px solid #cbd5e1; padding: 12px 16px; background: #f8f9fa; text-align: left; font-weight: 700;">Header ${d+1}</th>`;a+="</tr></thead>",a+="<tbody>";for(let d=0;d<l;d++){a+="<tr>";for(let h=0;h<r;h++)a+=`<td style="border: 1px solid #cbd5e1; padding: 12px 16px; background: #fff;">Cell ${d+1}-${h+1}</td>`;a+="</tr>"}a+="</tbody></table>",y("insertHTML",a),setTimeout(()=>{try{const d=u.current;if(!d)return;const h=d.querySelector("table:last-of-type");h&&Ae(h)}catch{}},20),ne(!1),be(3),xe(3)},pt=(t,o)=>{de({rows:t+1,cols:o+1})},ft=(t,o)=>{Ee(t+1,o+1),K(!1)},ue=()=>{if(!_||!u.current){B("Enter text to find");return}try{const t=window.find(_,!1,!1,!1,!1,!0,!1);B(t?"Found":"No matches found")}catch{B("Search not available in this browser")}},ut=()=>{if(!_||!u.current){B("Enter text to find");return}try{const t=window.getSelection();if(t&&t.toString().toLowerCase()===_.toLowerCase()){const o=t.getRangeAt(0);o.deleteContents(),o.insertNode(document.createTextNode(pe)),B("Replaced 1 occurrence"),setTimeout(()=>ue(),100)}else ue()}catch{B("Replace failed")}},gt=()=>{if(!_||!u.current){B("Enter text to find");return}try{let t=0;const o=u.current.textContent||"",l=new RegExp(_.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"gi"),r=o.match(l);if(!r||r.length===0){B("No matches found");return}const a=document.createTreeWalker(u.current,NodeFilter.SHOW_TEXT,null,!1),d=[];let h;for(;h=a.nextNode();)l.test(h.nodeValue)&&d.push(h);d.forEach(C=>{const S=C.nodeValue.replace(l,pe),E=(C.nodeValue.match(l)||[]).length;t+=E,C.nodeValue=S}),j(u.current.innerHTML),B(`Replaced ${t} occurrence(s)`)}catch{B("Replace all failed")}},Ae=t=>{if(!t||t.dataset.enhanced)return;const o=document.createElement("div");o.className="editable-table-wrap",t.parentNode.insertBefore(o,t),o.appendChild(t);const l=n=>{const i=n.target.closest("td,th");if(i){if(n.shiftKey&&M.current&&M.current!==i){try{u.current.querySelectorAll(".selected-cell").forEach(s=>s.classList.remove("selected-cell"))}catch{}It(M.current,i,t),M.current=i;return}try{u.current.querySelectorAll(".selected-cell").forEach(s=>s.classList.remove("selected-cell"))}catch{}i.classList.add("selected-cell"),M.current=i}},r=n=>{try{u.current?.querySelectorAll(".editable-table-wrap")?.forEach(c=>c.classList.remove("selected"))}catch{}o.classList.add("selected"),l(n)};t.addEventListener("click",r);try{t.querySelectorAll("td,th").forEach(i=>i.addEventListener("click",l))}catch{}const a=document.createElement("div");a.className="table-controls";const d=(n,i,c)=>{const s=document.createElement("button");return s.type="button",s.className="table-control-btn",s.title=n,s.innerHTML=i,s.addEventListener("click",p=>{p.stopPropagation(),c(t)}),s};a.appendChild(d("Add Row Below","+R",n=>He(n))),a.appendChild(d("Add Column Right","+C",n=>Ie(n))),a.appendChild(d("Delete Row","-R",n=>yt(n))),a.appendChild(d("Delete Column","-C",n=>mt(n))),a.appendChild(d("Delete Table","×",n=>Be(n)));const h=document.createElement("input");h.type="color",h.style.display="none",h.addEventListener("input",n=>{try{const i=n.target.value;M.current&&(M.current.style.background=i)}catch{}});const C=document.createElement("input");C.type="color",C.style.display="none",C.addEventListener("input",n=>{try{const i=n.target.value;let c=[];const s=t.querySelector("thead");s?c=Array.from(s.querySelectorAll("th")):t.rows&&t.rows[0]&&(c=Array.from(t.rows[0].cells)),c.forEach(p=>{p.style.background=i,p.style.color=E(i)})}catch{}});const S=()=>{try{const n=t.querySelector("thead");(n?Array.from(n.querySelectorAll("th")):t.rows[0]?Array.from(t.rows[0].cells):[]).forEach(c=>{c.style.background="",c.style.color=""})}catch{}},E=n=>{if(!n)return"#000";const i=n.replace("#",""),c=parseInt(i.substr(0,2),16),s=parseInt(i.substr(2,2),16),p=parseInt(i.substr(4,2),16);return(c*299+s*587+p*114)/1e3>=128?"#000":"#fff"},U=n=>{const i=[];for(let c=0;c<n.rows.length;c++){const s=n.rows[c];i[c]=i[c]||[];let p=0;for(let f=0;f<s.cells.length;f++){const g=s.cells[f];for(;i[c][p];)p++;const x=parseInt(g.getAttribute("rowspan")||g.rowSpan||1,10),m=parseInt(g.getAttribute("colspan")||g.colSpan||1,10);for(let w=0;w<x;w++)for(let b=0;b<m;b++)i[c+w]=i[c+w]||[],i[c+w][p+b]=g;p+=m}}return i},A=(n,i)=>{const c=U(n);for(let s=0;s<c.length;s++){const p=c[s]||[];for(let f=0;f<p.length;f++)if(p[f]===i)return{r:s,c:f,matrix:c}}return null},Q=(n,i)=>{const c=U(n);let s=1/0,p=1/0,f=-1/0,g=-1/0;const x=new Set(i);for(let T=0;T<c.length;T++)for(let H=0;H<(c[T]||[]).length;H++){const $=c[T][H];!$||!x.has($)||(s=Math.min(s,T),p=Math.min(p,H),f=Math.max(f,T),g=Math.max(g,H))}if(s===1/0)return;const m=c[s][p],w=new Set;let b="";for(let T=s;T<=f;T++)for(let H=p;H<=g;H++){const $=c[T][H];$&&($!==m&&w.add($),b.includes($.innerHTML)||(b+=(b?"<br/>":"")+$.innerHTML))}const L=f-s+1,W=g-p+1;try{m.rowSpan=L,m.colSpan=W,m.innerHTML=b}catch{}w.forEach(T=>{try{T.remove()}catch{}});try{m.classList.add("selected-cell"),M.current=m}catch{}},I=(n,i,c)=>{const s=A(c,n);if(!s)return;const{r:p,c:f,matrix:g}=s,x=parseInt(n.getAttribute("rowspan")||n.rowSpan||1,10),m=parseInt(n.getAttribute("colspan")||n.colSpan||1,10);let w=p,b=f;if(i==="right"&&(b=f+m),i==="left"&&(b=f-1),i==="down"&&(w=p+x),i==="up"&&(w=p-1),!g[w]||typeof g[w][b]>"u")return;const L=g[w][b];if(!L||L===n)return;const W=Math.min(p,w),T=Math.max(p,w+(parseInt(L.getAttribute("rowspan")||L.rowSpan||1,10)-1)),H=Math.min(f,b),$=Math.max(f+(m-1),b+(parseInt(L.getAttribute("colspan")||L.colSpan||1,10)-1)),Pe=new Set;for(let se=W;se<=T;se++)for(let ge=H;ge<=$;ge++){const $e=g[se]&&g[se][ge];$e&&Pe.add($e)}Q(c,Pe)},We=(n,i,c)=>{try{if(i==="vertical"){const s=parseInt(n.getAttribute("rowspan")||n.rowSpan||1,10);if(s<=1)return;const p=A(c,n);if(!p)return;const{r:f,c:g}=p;n.rowSpan=1;for(let x=1;x<s;x++){const m=c.rows[f+x];if(m){const w=(()=>{let L=0;for(let W=0;W<m.cells.length;W++){const T=m.cells[W],H=parseInt(T.getAttribute("colspan")||T.colSpan||1,10);if(L>=g)return W;L+=H}return m.cells.length})(),b=m.insertCell(w);b.innerHTML=""}}}else if(i==="horizontal"){const s=parseInt(n.getAttribute("colspan")||n.colSpan||1,10);if(s<=1)return;const p=n.parentElement,f=Array.prototype.indexOf.call(p.children,n);n.colSpan=1;for(let g=1;g<s;g++){const x=p.insertCell(f+g);x.innerHTML=""}}}catch{}},Et=(n,i)=>{const c=A(i,n);if(!c)return;const{r:s,matrix:p}=c;try{u.current.querySelectorAll(".selected-cell").forEach(g=>g.classList.remove("selected-cell"))}catch{}for(let f=0;f<(p[s]||[]).length;f++){const g=p[s][f];g&&g.classList.add("selected-cell")}},At=(n,i)=>{const c=A(i,n);if(!c)return;const{c:s,matrix:p}=c;try{u.current.querySelectorAll(".selected-cell").forEach(g=>g.classList.remove("selected-cell"))}catch{}for(let f=0;f<p.length;f++){const g=p[f]&&p[f][s];g&&g.classList.add("selected-cell")}},Ht=n=>{try{u.current.querySelectorAll(".selected-cell").forEach(c=>c.classList.remove("selected-cell"))}catch{}try{n.querySelectorAll("td,th").forEach(c=>c.classList.add("selected-cell"))}catch{}},It=(n,i,c)=>{const s=A(c,n),p=A(c,i);if(!s||!p)return;const f=Math.min(s.r,p.r),g=Math.max(s.r,p.r),x=Math.min(s.c,p.c),m=Math.max(s.c,p.c);try{u.current.querySelectorAll(".selected-cell").forEach(L=>L.classList.remove("selected-cell"))}catch{}const w=s.matrix;for(let b=f;b<=g;b++)for(let L=x;L<=m;L++){const W=w[b]&&w[b][L];W&&W.classList.add("selected-cell")}};a.appendChild(h),a.appendChild(d("Cell Color","■",()=>{if(!M.current){alert("Select a table cell first");return}h.click()})),a.appendChild(C),a.appendChild(d("Header Color","🎨",()=>{try{const n=t.rows[0];if(!n)return alert("Table has no rows");if(!(n.cells[0]&&n.cells[0].tagName.toLowerCase()==="th")){const c=document.createElement("thead"),s=t.rows[0],p=document.createElement("tr");for(let f=0;f<s.cells.length;f++){const g=document.createElement("th");g.innerHTML=s.cells[f].innerHTML,p.appendChild(g)}c.appendChild(p),t.deleteRow(0),t.insertBefore(c,t.firstChild)}}catch{}C.click()})),a.appendChild(d("Clear Header Color","✖",()=>{S()})),a.appendChild(d("Toggle Header","H",()=>{try{const n=t.rows[0];if(!n)return;if(n.cells[0]&&n.cells[0].tagName.toLowerCase()==="th"){const c=document.createElement("tbody");for(let s=0;s<t.rows.length;s++){const p=t.rows[0],f=document.createElement("tr"),g=p.cells;for(let x=0;x<g.length;x++){const m=document.createElement("td");m.innerHTML=g[x].innerHTML,m.style.cssText=g[x].style.cssText,f.appendChild(m)}c.appendChild(f),t.deleteRow(0)}t.appendChild(c)}else{const c=document.createElement("thead"),s=t.rows[0],p=document.createElement("tr"),f=s.cells;for(let g=0;g<f.length;g++){const x=document.createElement("th");x.innerHTML=f[g].innerHTML,x.style.cssText=f[g].style.cssText,p.appendChild(x)}c.appendChild(p),t.deleteRow(0),t.insertBefore(c,t.firstChild)}}catch{}})),o.appendChild(a),["nw","ne","sw","se"].forEach(n=>{const i=document.createElement("div");i.className=`table-resize-handle ${n}`,i.addEventListener("mousedown",c=>{c.preventDefault(),c.stopPropagation(),vt(c,o,t,n)}),o.appendChild(i)});const re=document.createElement("div");re.className="table-drag-handle",re.title="Drag to move table",o.appendChild(re);const P=document.createElement("div");P.className="table-context-menu",P.innerHTML=`
2
2
  <button type="button" data-action="select-row">Select row</button>
3
3
  <button type="button" data-action="select-column">Select column</button>
4
4
  <button type="button" data-action="select-table">Select table</button>
@@ -14,4 +14,4 @@
14
14
  <button type="button" data-action="add-row">Add row below</button>
15
15
  <button type="button" data-action="add-col">Add column right</button>
16
16
  <button type="button" data-action="delete-table">Delete table</button>
17
- `,P.style.display="none",l.appendChild(P);const ae=(n,i,c)=>{n?(P.style.display="block",P.style.left=typeof i=="number"?i+"px":"8px",P.style.top=typeof c=="number"?c+"px":"36px"):P.style.display="none"};P.addEventListener("click",n=>{n.stopPropagation();const i=n.target.closest("button[data-action]");if(!i)return;const c=i.getAttribute("data-action");try{const s=M.current||t.rows[0].cells[0];if(!s)return;c==="select-row"&&Et(s,t),c==="select-column"&&At(s,t),c==="select-table"&&Ht(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)}catch{}ae(!1)});const qe=d("Table Menu","&#8942;",()=>{ae(P.style.display!=="block")});qe.className+=" table-menu-btn",a.appendChild(qe),l.addEventListener("contextmenu",n=>{n.preventDefault(),F.current=null,M.current=n.target.closest("td,th")||M.current;const i=l.getBoundingClientRect();ae(!0,n.clientX-i.left,n.clientY-i.top)}),document.addEventListener("click",n=>{l.contains(n.target)||ae(!1)});let ce=!1,le=null;const Fe=n=>{if(!ce)return;const i=n.clientX-le.x,c=n.clientY-le.y;l.style.transform=`translate(${le.tx+i}px, ${le.ty+c}px)`},Ue=()=>{if(!ce)return;ce=!1,document.removeEventListener("mousemove",Fe),document.removeEventListener("mouseup",Ue);const n=l.style.transform.match(/translate\((-?\d+)px,\s*(-?\d+)px\)/);if(n){const i=parseInt(n[1],10),c=parseInt(n[2],10);l.style.left=l.offsetLeft+i+"px",l.style.top=l.offsetTop+c+"px",l.style.transform="",l.style.position="absolute"}};re.addEventListener("mousedown",n=>{n.preventDefault(),n.stopPropagation(),ce=!0,le={x:n.clientX,y:n.clientY,tx:0,ty:0},document.addEventListener("mousemove",Fe),document.addEventListener("mouseup",Ue)}),t.dataset.enhanced="1"},vt=(t,l,o,r)=>{const a=t.clientX,d=t.clientY,h=o.offsetWidth,C=o.offsetHeight,S=U=>{const A=U.clientX-a,J=U.clientY-d;if(r.includes("e")){const I=Math.max(200,h+A);o.style.width=I+"px"}else if(r.includes("w")){const I=Math.max(200,h-A);o.style.width=I+"px"}if(r.includes("s")){const I=Math.max(100,C+J);o.style.height=I+"px"}else if(r.includes("n")){const I=Math.max(100,C-J);o.style.height=I+"px"}},E=()=>{document.removeEventListener("mousemove",S),document.removeEventListener("mouseup",E),document.body.style.cursor=""};document.addEventListener("mousemove",S),document.addEventListener("mouseup",E)},He=t=>{const l=M.current;let o=-1;l&&(o=l.parentElement.rowIndex);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(o+1);for(let d=0;d<r;d++){const h=a.insertCell(-1);h.innerHTML=`Cell ${a.rowIndex}-${d+1}`}},Ie=t=>{const l=M.current;let o=-1;l&&(o=Array.prototype.indexOf.call(l.parentElement.children,l));for(let r=0;r<t.rows.length;r++){const a=t.rows[r],d=o+1,h=a.insertCell(d);h.innerHTML=""}},yt=t=>{if(t.rows.length<=1)return;const l=M.current;let o=l?l.parentElement.rowIndex:t.rows.length-1;t.deleteRow(o)},mt=t=>{const l=t.rows[0]?t.rows[0].cells.length:0;if(l<=1)return;const o=M.current;let r=o?Array.prototype.indexOf.call(o.parentElement.children,o):l-1;for(let a=0;a<t.rows.length;a++){const d=t.rows[a];d.cells[r]&&d.deleteCell(r)}},Be=t=>{const l=t.closest(".editable-table-wrap");l?l.remove():t.remove()},bt=()=>{try{const t=u.current;if(!t)return;t.querySelectorAll("table").forEach(o=>Ae(o))}catch{}},Ct=()=>{try{const t=u.current;if(!t)return;t.querySelectorAll("img:not(.editable-image-wrap img)").forEach(o=>{if(!o.closest(".editable-image-wrap")){const r=document.createElement("div");r.className="editable-image-wrap",r.contentEditable="false",o.parentNode.insertBefore(r,o),r.appendChild(o),Me(r)}})}catch{}},xt=()=>{oe(!G)},wt=()=>{const t=u.current?.innerHTML||"",l=new Blob([t],{type:"text/html"}),o=URL.createObjectURL(l),r=document.createElement("a");r.href=o,r.download="document.html",r.click(),URL.revokeObjectURL(o)};v.useEffect(()=>{const t=()=>{const l=u.current?.innerText||"",o=new Blob([l],{type:"text/plain"}),r=URL.createObjectURL(o),a=document.createElement("a");a.href=r,a.download="document.txt",a.click(),URL.revokeObjectURL(r)};try{window._exportAsText=t}catch{}return()=>{try{delete window._exportAsText}catch{}}},[]),v.useEffect(()=>{const t=l=>{try{const o=l.target.closest(".editable-table-wrap"),r=l.target.closest(".editable-image-wrap");!o&&u.current&&u.current.querySelectorAll(".editable-table-wrap.selected").forEach(d=>d.classList.remove("selected")),!r&&u.current&&u.current.querySelectorAll(".editable-image-wrap.selected").forEach(d=>d.classList.remove("selected"))}catch{}};return document.addEventListener("click",t),()=>document.removeEventListener("click",t)},[]);const kt=t=>{const l=t.target.files?.[0];if(l){const o=new FileReader;o.onload=r=>{const a=r.target?.result;u.current&&(u.current.innerHTML=a,j(a),setTimeout(()=>{bt(),Ct()},50))},o.readAsText(l)}},Nt=()=>{V(!0)},St=()=>{const t=u.current?.innerHTML||"";navigator.clipboard.writeText(t).then(()=>{alert("HTML copied to clipboard!")})},Lt=()=>{confirm("Are you sure you want to clear all content?")&&u.current&&(y("selectAll"),y("delete"),j(""))},Tt=()=>{const t=prompt("Enter your code:");if(t){const l=`<pre><code>${t}</code></pre>`;y("insertHTML",l)}},Mt=()=>{y("formatBlock","blockquote")};return e.jsxs("div",{className:`editor-container ${G?"fullscreen":""}`,children:[e.jsx("input",{type:"file",ref:Le,onChange:kt,accept:".html,.txt",style:{display:"none"}}),e.jsx("div",{className:"editor-content",children:e.jsxs("div",{className:`page-card size-${we}`,children:[e.jsxs("div",{className:"editor-toolbar",children:[e.jsxs("div",{className:"toolbar-group",children:[e.jsx("button",{className:"toolbar-btn",onClick:()=>y("undo"),title:"Undo",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M3 7v6h6"}),e.jsx("path",{d:"M21 17a9 9 0 00-9-9 9 9 0 00-6 2.3L3 13"})]})}),e.jsx("button",{className:"toolbar-btn",onClick:()=>y("redo"),title:"Redo",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M21 7v6h-6"}),e.jsx("path",{d:"M3 17a9 9 0 019-9 9 9 0 016 2.3l3 2.7"})]})})]}),e.jsx("div",{className:"toolbar-divider"}),e.jsxs("div",{className:"toolbar-group",children:[e.jsxs("select",{className:"toolbar-select",onChange:at,value:Ge,children:[e.jsx("option",{value:"Arial",children:"Arial"}),e.jsx("option",{value:"Helvetica",children:"Helvetica"}),e.jsx("option",{value:"Segoe UI",children:"Segoe UI"}),e.jsx("option",{value:"Roboto",children:"Roboto"}),e.jsx("option",{value:"Open Sans",children:"Open Sans"}),e.jsx("option",{value:"Lato",children:"Lato"}),e.jsx("option",{value:"Montserrat",children:"Montserrat"}),e.jsx("option",{value:"Source Sans Pro",children:"Source Sans Pro"}),e.jsx("option",{value:"Tahoma",children:"Tahoma"}),e.jsx("option",{value:"Verdana",children:"Verdana"}),e.jsx("option",{value:"Trebuchet MS",children:"Trebuchet MS"}),e.jsx("option",{value:"Georgia",children:"Georgia"}),e.jsx("option",{value:"Times New Roman",children:"Times New Roman"}),e.jsx("option",{value:"Palatino Linotype",children:"Palatino Linotype"}),e.jsx("option",{value:"Garamond",children:"Garamond"}),e.jsx("option",{value:"Courier New",children:"Courier New"}),e.jsx("option",{value:"Brush Script MT",children:"Brush Script MT"}),e.jsx("option",{value:"Impact",children:"Impact"}),e.jsx("option",{value:"Comic Sans MS",children:"Comic Sans MS"}),e.jsx("option",{value:"Candara",children:"Candara"}),e.jsx("option",{value:"Cambria",children:"Cambria"}),e.jsx("option",{value:"Calibri",children:"Calibri"}),e.jsx("option",{value:"Merriweather",children:"Merriweather"}),e.jsx("option",{value:"Noto Sans",children:"Noto Sans"}),e.jsx("option",{value:"Palatino",children:"Palatino"}),e.jsx("option",{value:"Bookman",children:"Bookman"}),e.jsx("option",{value:"Lucida Sans",children:"Lucida Sans"}),e.jsx("option",{value:"Righteous",children:"Righteous"}),e.jsx("option",{value:"Poppins",children:"Poppins"})]}),e.jsxs("select",{className:"toolbar-select",onChange:rt,value:Ke,children:[e.jsx("option",{value:"1",children:"Small"}),e.jsx("option",{value:"3",children:"Normal"}),e.jsx("option",{value:"5",children:"Large"}),e.jsx("option",{value:"7",children:"Huge"})]}),e.jsxs("select",{className:"toolbar-select",onChange:t=>{ht(t.target.value),fe(t.target.value)},value:Qe,children:[e.jsx("option",{value:"p",children:"Paragraph"}),e.jsx("option",{value:"h1",children:"Heading 1"}),e.jsx("option",{value:"h2",children:"Heading 2"}),e.jsx("option",{value:"h3",children:"Heading 3"}),e.jsx("option",{value:"h4",children:"Heading 4"})]})]}),e.jsx("div",{className:"toolbar-divider"}),e.jsxs("div",{className:"toolbar-group",children:[e.jsx("button",{className:`toolbar-btn ${O.bold?"active":""}`,onClick:()=>y("bold"),title:"Bold",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[e.jsx("path",{d:"M6 4h8a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z"}),e.jsx("path",{d:"M6 12h9a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z"})]})}),e.jsx("button",{className:`toolbar-btn ${O.italic?"active":""}`,onClick:()=>y("italic"),title:"Italic",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("line",{x1:"19",y1:"4",x2:"10",y2:"4"}),e.jsx("line",{x1:"14",y1:"20",x2:"5",y2:"20"}),e.jsx("line",{x1:"15",y1:"4",x2:"9",y2:"20"})]})}),e.jsx("button",{className:`toolbar-btn ${O.underline?"active":""}`,onClick:()=>y("underline"),title:"Underline",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M6 3v7a6 6 0 0 0 6 6 6 6 0 0 0 6-6V3"}),e.jsx("line",{x1:"4",y1:"21",x2:"20",y2:"21"})]})}),e.jsx("button",{className:`toolbar-btn ${O.strikeThrough?"active":""}`,onClick:()=>y("strikeThrough"),title:"Strikethrough",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M16 4H9a3 3 0 0 0-2.83 4"}),e.jsx("path",{d:"M14 12a4 4 0 0 1 0 8H6"}),e.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})]})})]}),e.jsx("div",{className:"toolbar-divider"}),e.jsxs("div",{className:"toolbar-group",children:[e.jsxs("div",{className:"color-picker-wrapper","data-tooltip":"Text color","aria-label":"Text color picker",children:[e.jsx("input",{type:"color",onChange:ot,className:"color-picker",title:"Text Color",defaultValue:"#111827","aria-label":"Text color"}),e.jsx("span",{className:"color-label",children:"A"}),e.jsx("span",{className:"color-caption",children:"Text color"})]}),e.jsxs("div",{className:"color-picker-wrapper","data-tooltip":"Highlight / background color","aria-label":"Background color picker",children:[e.jsx("input",{type:"color",onChange:nt,className:"color-picker",title:"Background Color",defaultValue:"#ffffff","aria-label":"Background color"}),e.jsx("span",{className:"color-label",children:"◼"}),e.jsx("span",{className:"color-caption",children:"Highlight"})]})]}),e.jsx("div",{className:"toolbar-divider"}),e.jsx("div",{className:"toolbar-group",children:e.jsxs("div",{style:{position:"relative",display:"inline-block"},children:[e.jsx("button",{className:"toolbar-btn",onClick:()=>D(t=>!t),title:"More formatting",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("circle",{cx:"5",cy:"6",r:"1.2"}),e.jsx("circle",{cx:"5",cy:"12",r:"1.2"}),e.jsx("circle",{cx:"5",cy:"18",r:"1.2"}),e.jsx("line",{x1:"10",y1:"6",x2:"21",y2:"6"}),e.jsx("line",{x1:"10",y1:"12",x2:"21",y2:"12"}),e.jsx("line",{x1:"10",y1:"18",x2:"21",y2:"18"})]})}),Oe&&e.jsxs("div",{className:"toolbar-dropdown-panel",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"toolbar-dropdown-row",children:[e.jsx("button",{className:`toolbar-btn ${O.justifyLeft?"active":""}`,onClick:()=>{y("justifyLeft"),D(!1)},title:"Align Left",children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("line",{x1:"17",y1:"10",x2:"3",y2:"10"}),e.jsx("line",{x1:"21",y1:"6",x2:"3",y2:"6"}),e.jsx("line",{x1:"21",y1:"14",x2:"3",y2:"14"})]})}),e.jsx("button",{className:`toolbar-btn ${O.justifyCenter?"active":""}`,onClick:()=>{y("justifyCenter"),D(!1)},title:"Align Center",children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("line",{x1:"18",y1:"10",x2:"6",y2:"10"}),e.jsx("line",{x1:"21",y1:"6",x2:"3",y2:"6"}),e.jsx("line",{x1:"21",y1:"14",x2:"3",y2:"14"})]})}),e.jsx("button",{className:`toolbar-btn ${O.justifyRight?"active":""}`,onClick:()=>{y("justifyRight"),D(!1)},title:"Align Right",children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("line",{x1:"21",y1:"10",x2:"7",y2:"10"}),e.jsx("line",{x1:"21",y1:"6",x2:"3",y2:"6"}),e.jsx("line",{x1:"21",y1:"14",x2:"3",y2:"14"})]})})]}),e.jsx("div",{className:"toolbar-dropdown-sep"}),e.jsxs("div",{className:"toolbar-dropdown-row",children:[e.jsx("button",{className:`toolbar-btn ${O.insertUnorderedList?"active":""}`,onClick:()=>{y("insertUnorderedList"),D(!1)},title:"Bullet List",children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("line",{x1:"8",y1:"6",x2:"21",y2:"6"}),e.jsx("line",{x1:"8",y1:"12",x2:"21",y2:"12"}),e.jsx("circle",{cx:"4",cy:"6",r:"1",fill:"currentColor"})]})}),e.jsx("button",{className:`toolbar-btn ${O.insertOrderedList?"active":""}`,onClick:()=>{y("insertOrderedList"),D(!1)},title:"Numbered List",children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("line",{x1:"10",y1:"6",x2:"21",y2:"6"}),e.jsx("line",{x1:"10",y1:"12",x2:"21",y2:"12"})]})}),e.jsx("button",{className:"toolbar-btn",onClick:()=>{y("indent"),D(!1)},title:"Indent",children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("line",{x1:"21",y1:"4",x2:"9",y2:"4"})})}),e.jsx("button",{className:"toolbar-btn",onClick:()=>{y("outdent"),D(!1)},title:"Outdent",children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("line",{x1:"21",y1:"4",x2:"9",y2:"4"})})})]})]})]})}),e.jsx("div",{className:"toolbar-divider"}),e.jsxs("div",{className:"toolbar-group",children:[e.jsx("button",{className:"toolbar-btn",onClick:et,title:"Insert Link",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),e.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})}),e.jsx("button",{className:"toolbar-btn",onClick:ct,title:"Insert Image",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),e.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),e.jsx("polyline",{points:"21 15 16 10 5 21"})]})}),e.jsxs("div",{style:{position:"relative",display:"inline-block"},children:[e.jsx("button",{className:"toolbar-btn",onClick:()=>Q(!R),title:"Insert Table",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),e.jsx("line",{x1:"3",y1:"9",x2:"21",y2:"9"}),e.jsx("line",{x1:"3",y1:"15",x2:"21",y2:"15"}),e.jsx("line",{x1:"9",y1:"3",x2:"9",y2:"21"}),e.jsx("line",{x1:"15",y1:"3",x2:"15",y2:"21"})]})}),R&&e.jsxs("div",{className:"table-size-picker show",children:[e.jsx("div",{className:"table-size-grid",style:{gridTemplateColumns:"repeat(10, 18px)"},children:Array.from({length:10},(t,l)=>Array.from({length:10},(o,r)=>e.jsx("div",{className:`table-cell-preview ${l<N.rows&&r<N.cols?"hover":""}`,onMouseEnter:()=>pt(l,r),onClick:()=>ft(l,r)},`${l}-${r}`))).flat()}),e.jsxs("div",{className:"table-size-label",children:[N.rows," × ",N.cols]})]})]}),e.jsx("button",{className:"toolbar-btn",onClick:()=>he(!0),title:"Find and Replace",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("path",{d:"m21 21-4.35-4.35"})]})}),e.jsx("button",{className:"toolbar-btn",onClick:()=>y("insertHorizontalRule"),title:"Horizontal Rule",children:e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("line",{x1:"3",y1:"12",x2:"21",y2:"12"})})}),e.jsx("button",{className:"toolbar-btn",onClick:Mt,title:"Insert Quote",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("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"}),e.jsx("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"})]})}),e.jsx("button",{className:"toolbar-btn",onClick:Tt,title:"Code Block",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("polyline",{points:"16 18 22 12 16 6"}),e.jsx("polyline",{points:"8 6 2 12 8 18"})]})})]}),e.jsx("div",{className:"toolbar-divider"}),e.jsxs("div",{className:"toolbar-group",children:[e.jsxs("select",{className:"toolbar-select",value:we,onChange:t=>_e(t.target.value),title:"Page size","aria-label":"Page size",children:[e.jsx("option",{value:"a0",children:"A0"}),e.jsx("option",{value:"a1",children:"A1"}),e.jsx("option",{value:"a2",children:"A2"}),e.jsx("option",{value:"a3",children:"A3"}),e.jsx("option",{value:"a4",children:"A4"}),e.jsx("option",{value:"a5",children:"A5"}),e.jsx("option",{value:"a6",children:"A6"}),e.jsx("option",{value:"b0",children:"B0"}),e.jsx("option",{value:"b1",children:"B1"}),e.jsx("option",{value:"b2",children:"B2"}),e.jsx("option",{value:"b3",children:"B3"}),e.jsx("option",{value:"b4",children:"B4"}),e.jsx("option",{value:"b5",children:"B5"}),e.jsx("option",{value:"letter",children:"Letter"}),e.jsx("option",{value:"legal",children:"Legal"}),e.jsx("option",{value:"ledger",children:"Ledger"}),e.jsx("option",{value:"tabloid",children:"Tabloid"}),e.jsx("option",{value:"executive",children:"Executive"}),e.jsx("option",{value:"statement",children:"Statement"}),e.jsx("option",{value:"folio",children:"Folio"}),e.jsx("option",{value:"c4",children:"C4"}),e.jsx("option",{value:"c5",children:"C5"}),e.jsx("option",{value:"monarch",children:"Monarch"}),e.jsx("option",{value:"dl-envelope",children:"Envelope DL"}),e.jsx("option",{value:"c6-envelope",children:"Envelope C6"}),e.jsx("option",{value:"custom",children:"Custom"})]}),e.jsx("button",{className:"toolbar-btn",onClick:()=>Le.current?.click(),title:"Import",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("polyline",{points:"7 10 12 15 17 10"}),e.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}),e.jsx("button",{className:"toolbar-btn",onClick:wt,title:"Export HTML",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("polyline",{points:"17 8 12 3 7 8"}),e.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"15"})]})}),e.jsx("button",{className:"toolbar-btn",onClick:Nt,title:"View HTML",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("polyline",{points:"16 18 22 12 16 6"}),e.jsx("polyline",{points:"8 6 2 12 8 18"})]})}),e.jsx("button",{className:"toolbar-btn",onClick:Lt,title:"Clear All",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("polyline",{points:"3 6 5 6 21 6"}),e.jsx("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"})]})}),e.jsx("button",{className:"toolbar-btn",onClick:xt,title:G?"Exit Fullscreen":"Fullscreen",children:e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:G?e.jsx("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"}):e.jsx("path",{d:"M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7"})})})]}),e.jsx("div",{className:"toolbar-divider"}),e.jsx("div",{className:"toolbar-group",children:e.jsx("button",{className:"toolbar-btn",onClick:()=>y("removeFormat"),title:"Clear Formatting",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M4 7h16M9 20h6M12 4v16"}),e.jsx("line",{x1:"3",y1:"3",x2:"21",y2:"21",strokeWidth:"1.5"})]})})})]}),e.jsx("div",{ref:u,className:"page-body",contentEditable:!0,onInput:Re,suppressContentEditableWarning:!0,"data-placeholder":"Start typing your content here..."})]})}),e.jsxs("div",{className:"status-bar-bottom",children:[e.jsxs("span",{className:"status-item",children:["Characters: ",X.replace(/<[^>]*>/g,"").length]}),e.jsx("span",{className:"status-item",children:"•"}),e.jsxs("span",{className:"status-item",children:["Words: ",X.replace(/<[^>]*>/g,"").trim().split(/\s+/).filter(t=>t).length]})]}),Xe&&e.jsx("div",{className:"modal-overlay",onClick:()=>ne(!1),children:e.jsxs("div",{className:"modal-content",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{children:"Insert Table"}),e.jsx("button",{className:"modal-close",onClick:()=>ne(!1),children:"×"})]}),e.jsxs("div",{className:"modal-body",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Rows:"}),e.jsx("input",{type:"number",min:"1",max:"20",value:me,onChange:t=>be(parseInt(t.target.value)||1),className:"form-input"})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Columns:"}),e.jsx("input",{type:"number",min:"1",max:"10",value:Ce,onChange:t=>xe(parseInt(t.target.value)||1),className:"form-input"})]})]}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("button",{className:"btn-secondary",onClick:()=>ne(!1),children:"Cancel"}),e.jsx("button",{className:"btn-primary",onClick:Ee,children:"Insert Table"})]})]})}),ie&&e.jsx("div",{className:"modal-overlay",onClick:()=>V(!1),children:e.jsxs("div",{className:"modal-content modal-large",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{children:"HTML Source Code"}),e.jsx("button",{className:"modal-close",onClick:()=>V(!1),children:"×"})]}),e.jsx("div",{className:"modal-body",children:e.jsx("pre",{className:"html-preview",children:X||""})}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("button",{className:"btn-secondary",onClick:()=>V(!1),children:"Close"}),e.jsx("button",{className:"btn-primary",onClick:St,children:"Copy HTML"})]})]})}),je&&e.jsx("div",{className:"link-modal-overlay",onClick:()=>he(!1),children:e.jsxs("div",{className:"find-replace-modal",onClick:t=>t.stopPropagation(),children:[e.jsx("h3",{children:"Find and Replace"}),e.jsxs("div",{className:"find-replace-group",children:[e.jsx("label",{children:"Find:"}),e.jsx("input",{type:"text",className:"find-replace-input",value:Y,onChange:t=>Ve(t.target.value),placeholder:"Enter text to find...",autoFocus:!0})]}),e.jsxs("div",{className:"find-replace-group",children:[e.jsx("label",{children:"Replace with:"}),e.jsx("input",{type:"text",className:"find-replace-input",value:pe,onChange:t=>De(t.target.value),placeholder:"Enter replacement text..."})]}),ye&&e.jsx("div",{className:"find-replace-status",children:ye}),e.jsxs("div",{className:"find-replace-buttons",children:[e.jsx("button",{className:"find-replace-btn primary",onClick:ue,children:"Find Next"}),e.jsx("button",{className:"find-replace-btn",onClick:ut,children:"Replace"}),e.jsx("button",{className:"find-replace-btn",onClick:gt,children:"Replace All"}),e.jsx("button",{className:"find-replace-btn",onClick:()=>he(!1),children:"Close"})]})]})}),Z&&e.jsx("div",{className:"modal-overlay",onClick:()=>q(!1),children:e.jsxs("div",{className:"modal-content",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{children:"Insert Image"}),e.jsx("button",{className:"modal-close",onClick:()=>q(!1),children:"×"})]}),e.jsxs("div",{className:"modal-body",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Image URL:"}),e.jsx("input",{type:"text",placeholder:"https://example.com/image.jpg",value:_,onChange:t=>K(t.target.value),className:"form-input"}),e.jsx("button",{className:"btn-primary",onClick:st,style:{marginTop:"10px",width:"100%"},children:"Insert from URL"})]}),e.jsxs("div",{className:"form-group",style:{marginTop:"20px"},children:[e.jsx("label",{children:"Or upload from your device:"}),e.jsx("input",{type:"file",ref:Ze,onChange:it,accept:"image/*",className:"form-input",style:{padding:"8px"}})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsx("button",{className:"btn-secondary",onClick:()=>q(!1),children:"Cancel"})})]})}),e.jsx(ve,{isOpen:ee.open,onClose:()=>te(t=>({...t,open:!1})),onInsert:tt,onRemove:lt,isEditing:!!ee.isEditing,initialUrl:ee.initialUrl,initialText:ee.initialText,existingLinks:ee.existingLinks})]})};z.LinkModal=ve,z.RichTextEditor=ze,Object.defineProperty(z,Symbol.toStringTag,{value:"Module"})}));
17
+ `,P.style.display="none",o.appendChild(P);const ae=(n,i,c)=>{n?(P.style.display="block",P.style.left=typeof i=="number"?i+"px":"8px",P.style.top=typeof c=="number"?c+"px":"36px"):P.style.display="none"};P.addEventListener("click",n=>{n.stopPropagation();const i=n.target.closest("button[data-action]");if(!i)return;const c=i.getAttribute("data-action");try{const s=M.current||t.rows[0].cells[0];if(!s)return;c==="select-row"&&Et(s,t),c==="select-column"&&At(s,t),c==="select-table"&&Ht(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)}catch{}ae(!1)});const qe=d("Table Menu","&#8942;",()=>{ae(P.style.display!=="block")});qe.className+=" table-menu-btn",a.appendChild(qe),o.addEventListener("contextmenu",n=>{n.preventDefault(),F.current=null,M.current=n.target.closest("td,th")||M.current;const i=o.getBoundingClientRect();ae(!0,n.clientX-i.left,n.clientY-i.top)}),document.addEventListener("click",n=>{o.contains(n.target)||ae(!1)});let ce=!1,oe=null;const Fe=n=>{if(!ce)return;const i=n.clientX-oe.x,c=n.clientY-oe.y;o.style.transform=`translate(${oe.tx+i}px, ${oe.ty+c}px)`},Ue=()=>{if(!ce)return;ce=!1,document.removeEventListener("mousemove",Fe),document.removeEventListener("mouseup",Ue);const n=o.style.transform.match(/translate\((-?\d+)px,\s*(-?\d+)px\)/);if(n){const i=parseInt(n[1],10),c=parseInt(n[2],10);o.style.left=o.offsetLeft+i+"px",o.style.top=o.offsetTop+c+"px",o.style.transform="",o.style.position="absolute"}};re.addEventListener("mousedown",n=>{n.preventDefault(),n.stopPropagation(),ce=!0,oe={x:n.clientX,y:n.clientY,tx:0,ty:0},document.addEventListener("mousemove",Fe),document.addEventListener("mouseup",Ue)}),t.dataset.enhanced="1"},vt=(t,o,l,r)=>{const a=t.clientX,d=t.clientY,h=l.offsetWidth,C=l.offsetHeight,S=U=>{const A=U.clientX-a,Q=U.clientY-d;if(r.includes("e")){const I=Math.max(200,h+A);l.style.width=I+"px"}else if(r.includes("w")){const I=Math.max(200,h-A);l.style.width=I+"px"}if(r.includes("s")){const I=Math.max(100,C+Q);l.style.height=I+"px"}else if(r.includes("n")){const I=Math.max(100,C-Q);l.style.height=I+"px"}},E=()=>{document.removeEventListener("mousemove",S),document.removeEventListener("mouseup",E),document.body.style.cursor=""};document.addEventListener("mousemove",S),document.addEventListener("mouseup",E)},He=t=>{const o=M.current;let l=-1;o&&(l=o.parentElement.rowIndex);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);for(let d=0;d<r;d++){const h=a.insertCell(-1);h.innerHTML=`Cell ${a.rowIndex}-${d+1}`}},Ie=t=>{const o=M.current;let l=-1;o&&(l=Array.prototype.indexOf.call(o.parentElement.children,o));for(let r=0;r<t.rows.length;r++){const a=t.rows[r],d=l+1,h=a.insertCell(d);h.innerHTML=""}},yt=t=>{if(t.rows.length<=1)return;const o=M.current;let l=o?o.parentElement.rowIndex:t.rows.length-1;t.deleteRow(l)},mt=t=>{const o=t.rows[0]?t.rows[0].cells.length:0;if(o<=1)return;const l=M.current;let r=l?Array.prototype.indexOf.call(l.parentElement.children,l):o-1;for(let a=0;a<t.rows.length;a++){const d=t.rows[a];d.cells[r]&&d.deleteCell(r)}},Be=t=>{const o=t.closest(".editable-table-wrap");o?o.remove():t.remove()},bt=()=>{try{const t=u.current;if(!t)return;t.querySelectorAll("table").forEach(l=>Ae(l))}catch{}},Ct=()=>{try{const t=u.current;if(!t)return;t.querySelectorAll("img:not(.editable-image-wrap img)").forEach(l=>{if(!l.closest(".editable-image-wrap")){const r=document.createElement("div");r.className="editable-image-wrap",r.contentEditable="false",l.parentNode.insertBefore(r,l),r.appendChild(l),Me(r)}})}catch{}},xt=()=>{le(!Y)},wt=()=>{const t=u.current?.innerHTML||"",o=new Blob([t],{type:"text/html"}),l=URL.createObjectURL(o),r=document.createElement("a");r.href=l,r.download="document.html",r.click(),URL.revokeObjectURL(l)};v.useEffect(()=>{const t=()=>{const o=u.current?.innerText||"",l=new Blob([o],{type:"text/plain"}),r=URL.createObjectURL(l),a=document.createElement("a");a.href=r,a.download="document.txt",a.click(),URL.revokeObjectURL(r)};try{window._exportAsText=t}catch{}return()=>{try{delete window._exportAsText}catch{}}},[]),v.useEffect(()=>{const t=o=>{try{const l=o.target.closest(".editable-table-wrap"),r=o.target.closest(".editable-image-wrap");!l&&u.current&&u.current.querySelectorAll(".editable-table-wrap.selected").forEach(d=>d.classList.remove("selected")),!r&&u.current&&u.current.querySelectorAll(".editable-image-wrap.selected").forEach(d=>d.classList.remove("selected"))}catch{}};return document.addEventListener("click",t),()=>document.removeEventListener("click",t)},[]);const kt=t=>{const o=t.target.files?.[0];if(o){const l=new FileReader;l.onload=r=>{const a=r.target?.result;u.current&&(u.current.innerHTML=a,j(a),setTimeout(()=>{bt(),Ct()},50))},l.readAsText(o)}},Nt=()=>{V(!0)},St=()=>{const t=u.current?.innerHTML||"";navigator.clipboard.writeText(t).then(()=>{alert("HTML copied to clipboard!")})},Lt=()=>{confirm("Are you sure you want to clear all content?")&&u.current&&(y("selectAll"),y("delete"),j(""))},Tt=()=>{const t=prompt("Enter your code:");if(t){const o=`<pre><code>${t}</code></pre>`;y("insertHTML",o)}},Mt=()=>{y("formatBlock","blockquote")};return e.jsxs("div",{className:`editor-container ${Y?"fullscreen":""}`,children:[e.jsx("input",{type:"file",ref:Le,onChange:kt,accept:".html,.txt",style:{display:"none"}}),e.jsx("div",{className:"editor-content",children:e.jsxs("div",{className:`page-card size-${we}`,children:[e.jsxs("div",{className:"editor-toolbar",children:[e.jsxs("div",{className:"toolbar-group",children:[e.jsx("button",{className:"toolbar-btn",onClick:()=>y("undo"),title:"Undo",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M3 7v6h6"}),e.jsx("path",{d:"M21 17a9 9 0 00-9-9 9 9 0 00-6 2.3L3 13"})]})}),e.jsx("button",{className:"toolbar-btn",onClick:()=>y("redo"),title:"Redo",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M21 7v6h-6"}),e.jsx("path",{d:"M3 17a9 9 0 019-9 9 9 0 016 2.3l3 2.7"})]})})]}),e.jsx("div",{className:"toolbar-divider"}),e.jsxs("div",{className:"toolbar-group",children:[e.jsxs("select",{className:"toolbar-select",onChange:at,value:Ge,children:[e.jsx("option",{value:"Arial",children:"Arial"}),e.jsx("option",{value:"Helvetica",children:"Helvetica"}),e.jsx("option",{value:"Segoe UI",children:"Segoe UI"}),e.jsx("option",{value:"Roboto",children:"Roboto"}),e.jsx("option",{value:"Open Sans",children:"Open Sans"}),e.jsx("option",{value:"Lato",children:"Lato"}),e.jsx("option",{value:"Montserrat",children:"Montserrat"}),e.jsx("option",{value:"Source Sans Pro",children:"Source Sans Pro"}),e.jsx("option",{value:"Tahoma",children:"Tahoma"}),e.jsx("option",{value:"Verdana",children:"Verdana"}),e.jsx("option",{value:"Trebuchet MS",children:"Trebuchet MS"}),e.jsx("option",{value:"Georgia",children:"Georgia"}),e.jsx("option",{value:"Times New Roman",children:"Times New Roman"}),e.jsx("option",{value:"Palatino Linotype",children:"Palatino Linotype"}),e.jsx("option",{value:"Garamond",children:"Garamond"}),e.jsx("option",{value:"Courier New",children:"Courier New"}),e.jsx("option",{value:"Brush Script MT",children:"Brush Script MT"}),e.jsx("option",{value:"Impact",children:"Impact"}),e.jsx("option",{value:"Comic Sans MS",children:"Comic Sans MS"}),e.jsx("option",{value:"Candara",children:"Candara"}),e.jsx("option",{value:"Cambria",children:"Cambria"}),e.jsx("option",{value:"Calibri",children:"Calibri"}),e.jsx("option",{value:"Merriweather",children:"Merriweather"}),e.jsx("option",{value:"Noto Sans",children:"Noto Sans"}),e.jsx("option",{value:"Palatino",children:"Palatino"}),e.jsx("option",{value:"Bookman",children:"Bookman"}),e.jsx("option",{value:"Lucida Sans",children:"Lucida Sans"}),e.jsx("option",{value:"Righteous",children:"Righteous"}),e.jsx("option",{value:"Poppins",children:"Poppins"})]}),e.jsxs("select",{className:"toolbar-select",onChange:rt,value:Ke,children:[e.jsx("option",{value:"1",children:"Small"}),e.jsx("option",{value:"3",children:"Normal"}),e.jsx("option",{value:"5",children:"Large"}),e.jsx("option",{value:"7",children:"Huge"})]}),e.jsxs("select",{className:"toolbar-select",onChange:t=>{ht(t.target.value),fe(t.target.value)},value:Qe,children:[e.jsx("option",{value:"p",children:"Paragraph"}),e.jsx("option",{value:"h1",children:"Heading 1"}),e.jsx("option",{value:"h2",children:"Heading 2"}),e.jsx("option",{value:"h3",children:"Heading 3"}),e.jsx("option",{value:"h4",children:"Heading 4"})]})]}),e.jsx("div",{className:"toolbar-divider"}),e.jsxs("div",{className:"toolbar-group",children:[e.jsx("button",{className:`toolbar-btn ${O.bold?"active":""}`,onClick:()=>y("bold"),title:"Bold",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[e.jsx("path",{d:"M6 4h8a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z"}),e.jsx("path",{d:"M6 12h9a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z"})]})}),e.jsx("button",{className:`toolbar-btn ${O.italic?"active":""}`,onClick:()=>y("italic"),title:"Italic",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("line",{x1:"19",y1:"4",x2:"10",y2:"4"}),e.jsx("line",{x1:"14",y1:"20",x2:"5",y2:"20"}),e.jsx("line",{x1:"15",y1:"4",x2:"9",y2:"20"})]})}),e.jsx("button",{className:`toolbar-btn ${O.underline?"active":""}`,onClick:()=>y("underline"),title:"Underline",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M6 3v7a6 6 0 0 0 6 6 6 6 0 0 0 6-6V3"}),e.jsx("line",{x1:"4",y1:"21",x2:"20",y2:"21"})]})}),e.jsx("button",{className:`toolbar-btn ${O.strikeThrough?"active":""}`,onClick:()=>y("strikeThrough"),title:"Strikethrough",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M16 4H9a3 3 0 0 0-2.83 4"}),e.jsx("path",{d:"M14 12a4 4 0 0 1 0 8H6"}),e.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})]})})]}),e.jsx("div",{className:"toolbar-divider"}),e.jsxs("div",{className:"toolbar-group",children:[e.jsxs("div",{className:"color-picker-wrapper","data-tooltip":"Text color","aria-label":"Text color picker",children:[e.jsx("input",{type:"color",onChange:lt,className:"color-picker",title:"Text Color",defaultValue:"#111827","aria-label":"Text color"}),e.jsx("span",{className:"color-label",children:"A"}),e.jsx("span",{className:"color-caption",children:"Text color"})]}),e.jsxs("div",{className:"color-picker-wrapper","data-tooltip":"Highlight / background color","aria-label":"Background color picker",children:[e.jsx("input",{type:"color",onChange:nt,className:"color-picker",title:"Background Color",defaultValue:"#ffffff","aria-label":"Background color"}),e.jsx("span",{className:"color-label",children:"◼"}),e.jsx("span",{className:"color-caption",children:"Highlight"})]})]}),e.jsx("div",{className:"toolbar-divider"}),e.jsx("div",{className:"toolbar-group",children:e.jsxs("div",{style:{position:"relative",display:"inline-block"},children:[e.jsx("button",{className:"toolbar-btn",onClick:()=>D(t=>!t),title:"More formatting",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("circle",{cx:"5",cy:"6",r:"1.2"}),e.jsx("circle",{cx:"5",cy:"12",r:"1.2"}),e.jsx("circle",{cx:"5",cy:"18",r:"1.2"}),e.jsx("line",{x1:"10",y1:"6",x2:"21",y2:"6"}),e.jsx("line",{x1:"10",y1:"12",x2:"21",y2:"12"}),e.jsx("line",{x1:"10",y1:"18",x2:"21",y2:"18"})]})}),Oe&&e.jsxs("div",{className:"toolbar-dropdown-panel",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"toolbar-dropdown-row",children:[e.jsx("button",{className:`toolbar-btn ${O.justifyLeft?"active":""}`,onClick:()=>{y("justifyLeft"),D(!1)},title:"Align Left",children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("line",{x1:"17",y1:"10",x2:"3",y2:"10"}),e.jsx("line",{x1:"21",y1:"6",x2:"3",y2:"6"}),e.jsx("line",{x1:"21",y1:"14",x2:"3",y2:"14"})]})}),e.jsx("button",{className:`toolbar-btn ${O.justifyCenter?"active":""}`,onClick:()=>{y("justifyCenter"),D(!1)},title:"Align Center",children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("line",{x1:"18",y1:"10",x2:"6",y2:"10"}),e.jsx("line",{x1:"21",y1:"6",x2:"3",y2:"6"}),e.jsx("line",{x1:"21",y1:"14",x2:"3",y2:"14"})]})}),e.jsx("button",{className:`toolbar-btn ${O.justifyRight?"active":""}`,onClick:()=>{y("justifyRight"),D(!1)},title:"Align Right",children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("line",{x1:"21",y1:"10",x2:"7",y2:"10"}),e.jsx("line",{x1:"21",y1:"6",x2:"3",y2:"6"}),e.jsx("line",{x1:"21",y1:"14",x2:"3",y2:"14"})]})})]}),e.jsx("div",{className:"toolbar-dropdown-sep"}),e.jsxs("div",{className:"toolbar-dropdown-row",children:[e.jsx("button",{className:`toolbar-btn ${O.insertUnorderedList?"active":""}`,onClick:()=>{y("insertUnorderedList"),D(!1)},title:"Bullet List",children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("line",{x1:"8",y1:"6",x2:"21",y2:"6"}),e.jsx("line",{x1:"8",y1:"12",x2:"21",y2:"12"}),e.jsx("circle",{cx:"4",cy:"6",r:"1",fill:"currentColor"})]})}),e.jsx("button",{className:`toolbar-btn ${O.insertOrderedList?"active":""}`,onClick:()=>{y("insertOrderedList"),D(!1)},title:"Numbered List",children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("line",{x1:"10",y1:"6",x2:"21",y2:"6"}),e.jsx("line",{x1:"10",y1:"12",x2:"21",y2:"12"})]})}),e.jsx("button",{className:"toolbar-btn",onClick:()=>{y("indent"),D(!1)},title:"Indent",children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("line",{x1:"21",y1:"4",x2:"9",y2:"4"})})}),e.jsx("button",{className:"toolbar-btn",onClick:()=>{y("outdent"),D(!1)},title:"Outdent",children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("line",{x1:"21",y1:"4",x2:"9",y2:"4"})})})]})]})]})}),e.jsx("div",{className:"toolbar-divider"}),e.jsxs("div",{className:"toolbar-group",children:[e.jsx("button",{className:"toolbar-btn",onClick:et,title:"Insert Link",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),e.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})}),e.jsx("button",{className:"toolbar-btn",onClick:ct,title:"Insert Image",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),e.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),e.jsx("polyline",{points:"21 15 16 10 5 21"})]})}),e.jsxs("div",{style:{position:"relative",display:"inline-block"},children:[e.jsx("button",{className:"toolbar-btn",onClick:()=>K(!R),title:"Insert Table",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),e.jsx("line",{x1:"3",y1:"9",x2:"21",y2:"9"}),e.jsx("line",{x1:"3",y1:"15",x2:"21",y2:"15"}),e.jsx("line",{x1:"9",y1:"3",x2:"9",y2:"21"}),e.jsx("line",{x1:"15",y1:"3",x2:"15",y2:"21"})]})}),R&&e.jsxs("div",{className:"table-size-picker show",children:[e.jsx("div",{className:"table-size-grid",style:{gridTemplateColumns:"repeat(10, 18px)"},children:Array.from({length:10},(t,o)=>Array.from({length:10},(l,r)=>e.jsx("div",{className:`table-cell-preview ${o<N.rows&&r<N.cols?"hover":""}`,onMouseEnter:()=>pt(o,r),onClick:()=>ft(o,r)},`${o}-${r}`))).flat()}),e.jsxs("div",{className:"table-size-label",children:[N.rows," × ",N.cols]})]})]}),e.jsx("button",{className:"toolbar-btn",onClick:()=>he(!0),title:"Find and Replace",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("path",{d:"m21 21-4.35-4.35"})]})}),e.jsx("button",{className:"toolbar-btn",onClick:()=>y("insertHorizontalRule"),title:"Horizontal Rule",children:e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("line",{x1:"3",y1:"12",x2:"21",y2:"12"})})}),e.jsx("button",{className:"toolbar-btn",onClick:Mt,title:"Insert Quote",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("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"}),e.jsx("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"})]})}),e.jsx("button",{className:"toolbar-btn",onClick:Tt,title:"Code Block",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("polyline",{points:"16 18 22 12 16 6"}),e.jsx("polyline",{points:"8 6 2 12 8 18"})]})})]}),e.jsx("div",{className:"toolbar-divider"}),e.jsxs("div",{className:"toolbar-group",children:[e.jsxs("select",{className:"toolbar-select",value:we,onChange:t=>_e(t.target.value),title:"Page size","aria-label":"Page size",children:[e.jsx("option",{value:"a0",children:"A0"}),e.jsx("option",{value:"a1",children:"A1"}),e.jsx("option",{value:"a2",children:"A2"}),e.jsx("option",{value:"a3",children:"A3"}),e.jsx("option",{value:"a4",children:"A4"}),e.jsx("option",{value:"a5",children:"A5"}),e.jsx("option",{value:"a6",children:"A6"}),e.jsx("option",{value:"b0",children:"B0"}),e.jsx("option",{value:"b1",children:"B1"}),e.jsx("option",{value:"b2",children:"B2"}),e.jsx("option",{value:"b3",children:"B3"}),e.jsx("option",{value:"b4",children:"B4"}),e.jsx("option",{value:"b5",children:"B5"}),e.jsx("option",{value:"letter",children:"Letter"}),e.jsx("option",{value:"legal",children:"Legal"}),e.jsx("option",{value:"ledger",children:"Ledger"}),e.jsx("option",{value:"tabloid",children:"Tabloid"}),e.jsx("option",{value:"executive",children:"Executive"}),e.jsx("option",{value:"statement",children:"Statement"}),e.jsx("option",{value:"folio",children:"Folio"}),e.jsx("option",{value:"c4",children:"C4"}),e.jsx("option",{value:"c5",children:"C5"}),e.jsx("option",{value:"monarch",children:"Monarch"}),e.jsx("option",{value:"dl-envelope",children:"Envelope DL"}),e.jsx("option",{value:"c6-envelope",children:"Envelope C6"}),e.jsx("option",{value:"custom",children:"Custom"})]}),e.jsx("button",{className:"toolbar-btn",onClick:()=>Le.current?.click(),title:"Import",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("polyline",{points:"7 10 12 15 17 10"}),e.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}),e.jsx("button",{className:"toolbar-btn",onClick:wt,title:"Export HTML",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("polyline",{points:"17 8 12 3 7 8"}),e.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"15"})]})}),e.jsx("button",{className:"toolbar-btn",onClick:Nt,title:"View HTML",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("polyline",{points:"16 18 22 12 16 6"}),e.jsx("polyline",{points:"8 6 2 12 8 18"})]})}),e.jsx("button",{className:"toolbar-btn",onClick:Lt,title:"Clear All",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("polyline",{points:"3 6 5 6 21 6"}),e.jsx("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"})]})}),e.jsx("button",{className:"toolbar-btn",onClick:xt,title:Y?"Exit Fullscreen":"Fullscreen",children:e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:Y?e.jsx("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"}):e.jsx("path",{d:"M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7"})})})]}),e.jsx("div",{className:"toolbar-divider"}),e.jsx("div",{className:"toolbar-group",children:e.jsx("button",{className:"toolbar-btn",onClick:()=>y("removeFormat"),title:"Clear Formatting",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M4 7h16M9 20h6M12 4v16"}),e.jsx("line",{x1:"3",y1:"3",x2:"21",y2:"21",strokeWidth:"1.5"})]})})})]}),e.jsx("div",{ref:u,className:"page-body",contentEditable:!0,onInput:Re,suppressContentEditableWarning:!0,"data-placeholder":"Start typing your content here..."})]})}),Xe&&e.jsx("div",{className:"modal-overlay",onClick:()=>ne(!1),children:e.jsxs("div",{className:"modal-content",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{children:"Insert Table"}),e.jsx("button",{className:"modal-close",onClick:()=>ne(!1),children:"×"})]}),e.jsxs("div",{className:"modal-body",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Rows:"}),e.jsx("input",{type:"number",min:"1",max:"20",value:me,onChange:t=>be(parseInt(t.target.value)||1),className:"form-input"})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Columns:"}),e.jsx("input",{type:"number",min:"1",max:"10",value:Ce,onChange:t=>xe(parseInt(t.target.value)||1),className:"form-input"})]})]}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("button",{className:"btn-secondary",onClick:()=>ne(!1),children:"Cancel"}),e.jsx("button",{className:"btn-primary",onClick:Ee,children:"Insert Table"})]})]})}),ie&&e.jsx("div",{className:"modal-overlay",onClick:()=>V(!1),children:e.jsxs("div",{className:"modal-content modal-large",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{children:"HTML Source Code"}),e.jsx("button",{className:"modal-close",onClick:()=>V(!1),children:"×"})]}),e.jsx("div",{className:"modal-body",children:e.jsx("pre",{className:"html-preview",children:J||""})}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("button",{className:"btn-secondary",onClick:()=>V(!1),children:"Close"}),e.jsx("button",{className:"btn-primary",onClick:St,children:"Copy HTML"})]})]})}),je&&e.jsx("div",{className:"link-modal-overlay",onClick:()=>he(!1),children:e.jsxs("div",{className:"find-replace-modal",onClick:t=>t.stopPropagation(),children:[e.jsx("h3",{children:"Find and Replace"}),e.jsxs("div",{className:"find-replace-group",children:[e.jsx("label",{children:"Find:"}),e.jsx("input",{type:"text",className:"find-replace-input",value:_,onChange:t=>Ve(t.target.value),placeholder:"Enter text to find...",autoFocus:!0})]}),e.jsxs("div",{className:"find-replace-group",children:[e.jsx("label",{children:"Replace with:"}),e.jsx("input",{type:"text",className:"find-replace-input",value:pe,onChange:t=>De(t.target.value),placeholder:"Enter replacement text..."})]}),ye&&e.jsx("div",{className:"find-replace-status",children:ye}),e.jsxs("div",{className:"find-replace-buttons",children:[e.jsx("button",{className:"find-replace-btn primary",onClick:ue,children:"Find Next"}),e.jsx("button",{className:"find-replace-btn",onClick:ut,children:"Replace"}),e.jsx("button",{className:"find-replace-btn",onClick:gt,children:"Replace All"}),e.jsx("button",{className:"find-replace-btn",onClick:()=>he(!1),children:"Close"})]})]})}),Z&&e.jsx("div",{className:"modal-overlay",onClick:()=>q(!1),children:e.jsxs("div",{className:"modal-content",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{children:"Insert Image"}),e.jsx("button",{className:"modal-close",onClick:()=>q(!1),children:"×"})]}),e.jsxs("div",{className:"modal-body",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Image URL:"}),e.jsx("input",{type:"text",placeholder:"https://example.com/image.jpg",value:X,onChange:t=>G(t.target.value),className:"form-input"}),e.jsx("button",{className:"btn-primary",onClick:st,style:{marginTop:"10px",width:"100%"},children:"Insert from URL"})]}),e.jsxs("div",{className:"form-group",style:{marginTop:"20px"},children:[e.jsx("label",{children:"Or upload from your device:"}),e.jsx("input",{type:"file",ref:Ze,onChange:it,accept:"image/*",className:"form-input",style:{padding:"8px"}})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsx("button",{className:"btn-secondary",onClick:()=>q(!1),children:"Cancel"})})]})}),e.jsx(ve,{isOpen:ee.open,onClose:()=>te(t=>({...t,open:!1})),onInsert:tt,onRemove:ot,isEditing:!!ee.isEditing,initialUrl:ee.initialUrl,initialText:ee.initialText,existingLinks:ee.existingLinks})]})};z.LinkModal=ve,z.RichTextEditor=ze,Object.defineProperty(z,Symbol.toStringTag,{value:"Module"})}));
package/dist/style.css CHANGED
@@ -1 +1 @@
1
- *{margin:0;padding:0;box-sizing:border-box}:root{--toolbar-height: 64px;--toolbar-row-height: 44px;--toolbar-rows: 2;--toolbar-gap: 8px}.editor-container{width:100%;max-width:100%;margin:0;min-height:600px;height:auto;background:#f8f9fa;border-radius:0;box-shadow:none;overflow:visible;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif;display:block;transition:all .3s cubic-bezier(.4,0,.2,1);position:relative;padding-top:0;padding-bottom:0}.editor-container.fullscreen{width:100vw;height:100vh;max-width:100%;margin:0;border-radius:0;z-index:9999}.editor-header,.editor-title,.editor-brand,.editor-badge,.editor-actions,.action-btn{display:none}.action-btn svg{display:none}.page-card .page-body{height:auto;overflow:visible;-webkit-overflow-scrolling:touch}.action-btn.active{display:none}.page-card .page-body img{max-width:100%;height:auto}.page-card .page-body:focus{outline:none!important;box-shadow:none!important}.page-card .page-body[contenteditable]{border:none!important;outline:none!important;box-shadow:none!important}.editor-toolbar{display:flex;gap:var(--toolbar-gap);padding:12px 24px;align-items:center;border-bottom:1px solid #e0e0e0;background:#fff;position:sticky;top:0;left:0;right:0;z-index:100;flex-wrap:wrap;flex-shrink:0;box-shadow:0 1px 3px #0000000f;max-height:calc((var(--toolbar-row-height) * var(--toolbar-rows)) + 24px);overflow:visible}.toolbar-group{display:flex;gap:4px;align-items:center;padding:0;position:relative;flex:0 1 auto}.toolbar-group:not(:last-child):after{content:"";width:1px;height:24px;background:#e0e0e0;margin-left:8px}.toolbar-btn{display:inline-flex;align-items:center;justify-content:center;min-width:32px;height:32px;padding:6px;border-radius:4px;background:transparent;color:#5f6368;cursor:pointer;transition:all .15s ease;border:none;position:relative;flex:0 0 auto}.toolbar-btn svg{width:18px;height:18px;stroke-width:2}.toolbar-btn:hover{background:#f1f3f4;color:#202124}.toolbar-btn:active{background:#e8eaed;transform:scale(.95)}.toolbar-btn.active{background:#e8f0fe;color:#1967d2}.toolbar-select{height:32px;padding:6px 28px 6px 12px;border:1px solid #dadce0;border-radius:4px;background:#fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1L6 6L11 1' stroke='%235f6368' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 8px center;background-size:12px;color:#202124;appearance:none;min-width:88px;font-weight:500;font-size:14px;cursor:pointer;transition:all .15s ease;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif;flex:0 1 140px}.toolbar-select:hover{border-color:#5f6368;background-color:#f8f9fa}.toolbar-select:focus{outline:none;border-color:#1967d2;box-shadow:0 0 0 2px #1967d21a}.color-picker-wrapper{width:32px;height:32px;border:1px solid #d1d5db;border-radius:6px;background:#fff;position:relative;overflow:hidden;cursor:pointer;transition:all .15s ease}.color-picker-wrapper:hover{border-color:#9ca3af;box-shadow:0 2px 4px #0000000f}.toolbar-dropdown-panel{position:absolute;top:calc(100% + 4px);left:0;background:#fff;border:1px solid #d1d5db;border-radius:6px;padding:6px;box-shadow:0 4px 16px #0000001f;z-index:2000;display:flex;gap:4px;align-items:center;max-width:400px;overflow-x:auto;overflow-y:hidden}.toolbar-dropdown-panel::-webkit-scrollbar{height:6px}.toolbar-dropdown-panel::-webkit-scrollbar-track{background:#f3f4f6;border-radius:3px}.toolbar-dropdown-panel::-webkit-scrollbar-thumb{background:#d1d5db;border-radius:3px}.toolbar-dropdown-panel .toolbar-btn{min-width:32px;width:32px;height:32px;flex-shrink:0;border:1px solid #e5e7eb}.toolbar-dropdown-panel .toolbar-btn:hover{background:#f3f4f6;border-color:#3b82f6}.color-picker-wrapper input[type=color]{position:absolute;left:0;top:0;width:100%;height:100%;border:none;padding:0;cursor:pointer}.color-picker-wrapper .color-label{position:absolute;right:4px;bottom:4px;font-size:9px;color:#6b7280;pointer-events:none;font-weight:600}.color-picker-wrapper:focus-within{box-shadow:0 6px 18px #0000001f,0 0 0 4px #22c55e0f;border-color:var(--accent)}.editor-content{flex:1;overflow-y:auto;overflow-x:hidden;background:#f8f9fa;padding:24px;display:flex;justify-content:center;align-items:flex-start;width:100%}.page-card{width:794px;margin:0 auto 24px;background:var(--card-bg);border-radius:0;box-shadow:0 4px 20px #00000014;padding:0;border:1px solid var(--border);border-top:none;display:flex;flex-direction:column;overflow:visible}.page-card .page-body{background:var(--editor-bg);min-height:1000px;padding:64px 96px;border-radius:0;box-shadow:none;border:none;color:#202124;overflow-wrap:break-word;word-wrap:break-word;overflow:visible;flex:1;font-size:16px;line-height:1.6;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif;outline:none;cursor:text}.page-card.size-a4{width:794px;min-height:1123px}.page-card.size-letter{width:816px;min-height:1056px}.page-card.size-a3{width:1122px;min-height:1587px}.page-card.size-legal{width:816px;min-height:1344px}.page-card.size-custom{width:900px;min-height:1200px}.page-card{display:block;box-sizing:border-box}.page-card .page-body{height:auto;overflow:visible}.page-card .page-body table{width:100%;max-width:100%;table-layout:fixed;border-collapse:collapse}.page-card .page-body *{max-width:100%}.page-card .page-body th,.page-card .page-body td{white-space:normal;word-break:break-word;box-sizing:border-box}@media(max-width:1300px){.page-card.size-a3{width:calc(100% - 48px);height:auto}}@media(max-width:1000px){.page-card.size-a4,.page-card.size-letter,.page-card.size-legal,.page-card.size-custom{width:calc(100% - 48px);height:auto}.page-card .page-body{padding:32px 48px}}@media(max-width:768px){.page-card{width:calc(100% - 24px)!important}.page-card .page-body{padding:24px 32px}}.page-size-select{height:36px;padding:6px 10px;border-radius:8px;border:1px solid var(--border);background:#fff;color:var(--text-color);font-weight:600;margin-right:8px}.page-card .page-body h1{font-size:40px;font-weight:700;line-height:1.2;margin:24px 0 16px;color:#202124;letter-spacing:-.5px}.page-card .page-body h1 .page-card .page-body thead th{background:#0f172a88;color:#fff}.page-card .page-body h2{font-size:32px;font-weight:700;line-height:1.3;margin:20px 0 12px;color:#202124;letter-spacing:-.3px}.page-card .page-body h3{font-size:24px;font-weight:600;line-height:1.4;margin:16px 0 10px;color:#202124}.page-card .page-body h4{font-size:20px;font-weight:600;line-height:1.4;margin:14px 0 8px;color:#202124}.page-card .page-body p{margin:0 0 12px;line-height:1.6;color:#3c4043}.page-card .page-body[data-placeholder]:empty:before{content:attr(data-placeholder);color:#9aa0a6;font-style:italic;pointer-events:none;position:absolute}.page-card .page-body strong,.page-card .page-body b{font-weight:700;color:#202124}.page-card .page-body em,.page-card .page-body i{font-style:italic}.page-card .page-body ul,.page-card .page-body ol{margin:12px 0;padding-left:28px}.page-card .page-body li{margin:6px 0;line-height:1.6;color:#3c4043}.editor-content:focus{outline:none;background:var(--editor-bg)}.editor-content p{margin:0 0 16px;transition:color .2s ease}.editor-content h3,.editor-content h4,.editor-content h5,.editor-content h6{color:var(--text-color);margin:24px 0 16px;font-weight:700;transition:color .2s ease}.editor-content a{color:var(--accent);text-decoration:underline}.page-card .page-body a{color:#1d4ed8;text-decoration:underline;cursor:pointer}.page-card .page-body a:hover{opacity:.92}.page-card .page-body a[contenteditable=false]{cursor:pointer}.editable-image-wrap{position:relative;display:inline-block;margin:4px;max-width:100%;vertical-align:top;width:fit-content}.editable-image-wrap.selected{outline:3px solid #3b82f6;outline-offset:2px;box-shadow:0 0 0 1px #3b82f633}.editable-image-wrap img{display:block;max-width:100%;height:auto}.image-resize-handle{position:absolute;width:12px;height:12px;background:#3b82f6;border:2px solid #fff;border-radius:50%;box-shadow:0 2px 6px #0003;z-index:20;display:none}.editable-image-wrap.selected .image-resize-handle{display:block}.image-resize-handle.nw{top:-6px;left:-6px;cursor:nw-resize}.image-resize-handle.ne{top:-6px;right:-6px;cursor:ne-resize}.image-resize-handle.sw{bottom:-6px;left:-6px;cursor:sw-resize}.image-resize-handle.se{bottom:-6px;right:-6px;cursor:se-resize}.image-resize-handle:hover{background:#2563eb;transform:scale(1.2)}.image-controls{position:absolute;bottom:-44px;left:50%;transform:translate(-50%);display:none;gap:4px;background:#fff;border:1px solid #cbd5e1;padding:6px 8px;border-radius:6px;box-shadow:0 4px 12px #00000026;z-index:100;white-space:nowrap}.editable-image-wrap.selected .image-controls{display:flex}.image-control-btn{min-width:32px;height:32px;display:inline-flex;align-items:center;justify-content:center;font-weight:600;font-size:11px;background:#fff;border:1px solid #e5e7eb;border-radius:4px;cursor:pointer;color:#374151;transition:all .15s ease;padding:0 8px}.image-control-btn:hover{background:#3b82f6;color:#fff;border-color:#3b82f6;transform:translateY(-1px);box-shadow:0 2px 6px #0000001a}.image-control-btn svg{width:14px;height:14px}.image-control-divider{width:1px;height:24px;background:#e5e7eb;margin:0 4px}.editor-content img{max-width:100%;height:auto;border-radius:6px;margin:12px 0}.editor-content hr{border:none;border-top:1px solid var(--border);margin:20px 0}.editor-content blockquote{border-left:4px solid var(--border);padding-left:12px;color:var(--muted);font-style:italic}.editor-content code{background:var(--surface-1);color:var(--text-color);padding:3px 6px;border-radius:4px;font-family:Monaco,Menlo,monospace}.editor-content table{border-collapse:collapse;width:100%;margin:16px 0;background:var(--editor-bg);border-radius:0;overflow:visible;box-shadow:none;position:relative}.editor-content table th{background:#f8f9fa;color:var(--text-color);font-weight:700;text-align:left;padding:12px 16px;border:1px solid #cbd5e1;font-size:14px}.editor-content table td{padding:12px 16px;border:1px solid #cbd5e1;color:var(--text-color);background:#fff;font-size:14px}.editor-content table tr:hover td{background:#fefce8}.editable-table-wrap{position:relative;margin:20px 0;display:inline-block;min-width:200px}.editable-table-wrap.selected{outline:3px solid #fbbf24;outline-offset:2px;box-shadow:0 0 0 1px #fbbf2433}.table-resize-handle{position:absolute;width:14px;height:14px;background:#fbbf24;border:2px solid #fff;border-radius:50%;box-shadow:0 2px 6px #0003;cursor:nwse-resize;z-index:20;display:none}.editable-table-wrap.selected .table-resize-handle{display:block}.table-resize-handle.nw{top:-7px;left:-7px;cursor:nw-resize}.table-resize-handle.ne{top:-7px;right:-7px;cursor:ne-resize}.table-resize-handle.sw{bottom:-7px;left:-7px;cursor:sw-resize}.table-resize-handle.se{bottom:-7px;right:-7px;cursor:se-resize}.table-resize-handle:hover{background:#f59e0b;transform:scale(1.2)}.table-controls{position:absolute;top:-48px;left:0;display:none;gap:4px;background:#fff;border:1px solid #cbd5e1;padding:6px;border-radius:6px;box-shadow:0 4px 12px #0000001a;z-index:100}.editable-table-wrap.selected .table-controls{display:flex}.table-control-btn{min-width:32px;height:32px;display:inline-flex;align-items:center;justify-content:center;font-weight:600;font-size:11px;background:#fff;border:1px solid #e5e7eb;border-radius:4px;cursor:pointer;color:#374151;transition:all .15s ease}.table-control-btn:hover{background:#fbbf24;color:#fff;border-color:#fbbf24;transform:translateY(-1px);box-shadow:0 2px 6px #0000001a}.editor-content pre{background:#0b0b0b;color:#f7f7f7;padding:16px;border-radius:8px;overflow-x:auto;margin:16px 0}.editor-content pre code{background:none;color:inherit;padding:0;font-family:Monaco,Menlo,monospace}.editor-footer,.status-bar,.status-item{display:none}.status-bar-bottom{display:flex;gap:12px;padding:12px 24px;background:#f8f9fa;border-top:1px solid #e0e0e0;font-size:13px;color:#5f6368;justify-content:flex-end;width:100%;box-sizing:border-box;position:relative;bottom:0;left:0;z-index:10}.status-bar-bottom .status-item{display:inline;white-space:nowrap;padding:0;background:none;border:none}.status-item:hover{transform:translateY(-2px);box-shadow:0 4px 8px #0000000f}.editor-content::-webkit-scrollbar,.modal-body::-webkit-scrollbar{width:12px}.editor-content::-webkit-scrollbar-track,.modal-body::-webkit-scrollbar-track{background:#f3f4f6;border-radius:6px}.editor-content::-webkit-scrollbar-thumb,.modal-body::-webkit-scrollbar-thumb{background:#9aa3ad;border-radius:6px;border:2px solid #f3f4f6}.modal-overlay,.link-modal-overlay{position:fixed;inset:0;background:#00000080;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px);display:flex;align-items:center;justify-content:center;z-index:10000;animation:rte-fadeIn .18s ease}@keyframes rte-fadeIn{0%{opacity:0}to{opacity:1}}.modal-content{background:var(--card-bg);border-radius:12px;box-shadow:0 25px 50px -12px #00000040;width:90%;max-width:680px;max-height:90vh;overflow:hidden;display:flex;flex-direction:column;animation:rte-slideUp .28s ease}@keyframes rte-slideUp{0%{transform:translateY(12px);opacity:0}to{transform:translateY(0);opacity:1}}.modal-header{display:flex;justify-content:space-between;align-items:center;padding:18px 20px;background:var(--header-bg);color:#fff}.modal-header h3{margin:0;font-size:18px;font-weight:600}.modal-close{background:#ffffff0f;border:1px solid rgba(255,255,255,.08);color:#fff;width:36px;height:36px;border-radius:8px;display:flex;align-items:center;justify-content:center;cursor:pointer}.modal-close:hover{background:#ffffff1f;transform:rotate(90deg)}.modal-body{padding:20px;overflow-y:auto;flex:1}.modal-footer{display:flex;justify-content:flex-end;gap:12px;padding:16px 20px;background:var(--surface-1);border-top:1px solid var(--border)}.form-group{margin-bottom:16px}.form-group label{display:block;margin-bottom:8px;font-weight:600;color:var(--muted);font-size:14px}.form-input{width:100%;padding:10px 12px;border:1px solid var(--border);border-radius:8px;font-size:15px;font-family:inherit}.form-input:focus{outline:none;box-shadow:0 0 0 4px #0000000a;border-color:var(--border)}.btn-primary{padding:10px 20px;background:var(--inverse-bg);color:#fff;border:none;border-radius:8px;font-weight:600;cursor:pointer}.btn-primary:hover{transform:translateY(-2px);box-shadow:0 6px 12px #00000014}.btn-secondary{padding:10px 20px;background:var(--editor-bg);color:var(--text-color);border:1px solid var(--border);border-radius:8px;cursor:pointer}.html-preview{background:#0b0b0b;color:#f7f7f7;padding:16px;border-radius:8px;overflow-x:auto;font-size:13px;font-family:Monaco,Menlo,monospace;white-space:pre-wrap;word-break:break-all}.editor-content::selection{background:#11182714;color:var(--text-color)}.table-size-picker{position:absolute;top:calc(100% + 4px);left:0;background:#fff;border:1px solid #d1d5db;border-radius:8px;padding:12px;box-shadow:0 10px 25px #0000001a,0 4px 8px #0000000f;z-index:2000;display:none}.table-size-picker.show{display:block}.table-size-grid{display:grid;gap:2px;cursor:pointer}.table-drag-handle{width:18px;height:18px;border-radius:4px;background:#0000000f;position:absolute;top:8px;left:8px;display:flex;align-items:center;justify-content:center;cursor:grab;z-index:1500}.table-drag-handle:active{cursor:grabbing}.table-context-menu{position:absolute;right:8px;top:36px;background:#fff;border:1px solid #d1d5db;border-radius:8px;padding:8px;box-shadow:0 8px 30px #0000001f;display:flex;flex-direction:column;gap:6px;min-width:160px;z-index:2000}.table-context-menu button{background:transparent;border:none;text-align:left;padding:8px 10px;border-radius:6px;cursor:pointer}.table-context-menu button:hover{background:#f3f4f6}.table-context-menu hr{border:none;height:1px;background:#eef2f7;margin:6px 0}.table-cell-preview{width:18px;height:18px;border:1px solid #d1d5db;background:#fff;transition:all .1s;border-radius:2px}.table-cell-preview.hover{background:#3b82f6;border-color:#2563eb}.table-size-label{text-align:center;margin-top:8px;font-size:12px;color:#6b7280;font-weight:600}.page-card .page-body td.selected-cell,.page-card .page-body th.selected-cell{outline:2px solid rgba(59,130,246,.9);background:#3b82f60f}.find-replace-modal{background:#fff;padding:24px;border-radius:12px;box-shadow:0 20px 50px #00000026;max-width:450px;width:90%}.find-replace-modal h3{margin:0 0 20px;font-size:18px;color:#1e293b;font-weight:700}.find-replace-group{margin-bottom:16px}.find-replace-group label{display:block;margin-bottom:6px;font-size:13px;color:#475569;font-weight:600}.find-replace-input{width:100%;padding:8px 12px;border:1px solid #cbd5e1;border-radius:6px;font-size:14px;transition:all .15s ease}.find-replace-input:focus{outline:none;border-color:#3b82f6;box-shadow:0 0 0 3px #3b82f61a}.find-replace-buttons{display:flex;gap:8px;margin-top:20px;flex-wrap:wrap}.find-replace-btn{padding:8px 16px;border-radius:6px;font-size:13px;font-weight:600;cursor:pointer;border:1px solid #cbd5e1;background:#fff;color:#374151;transition:all .15s}.find-replace-btn:hover{background:#f8fafc;border-color:#94a3b8}.find-replace-btn.primary{background:#3b82f6;color:#fff;border-color:#3b82f6}.find-replace-btn.primary:hover{background:#2563eb;border-color:#2563eb}.find-replace-status{margin-top:12px;font-size:13px;color:#64748b;min-height:18px;font-weight:500}.editor-content::-moz-selection{background:#11182714;color:var(--text-color)}@keyframes editorFadeIn{0%{opacity:0}to{opacity:1}}@keyframes slideDown{0%{transform:translateY(-20px);opacity:0}to{transform:translateY(0);opacity:1}}@keyframes slideUp{0%{transform:translateY(20px);opacity:0}to{transform:translateY(0);opacity:1}}@keyframes fadeInLeft{0%{transform:translate(-20px);opacity:0}to{transform:translate(0);opacity:1}}@keyframes fadeInRight{0%{transform:translate(20px);opacity:0}to{transform:translate(0);opacity:1}}@keyframes fadeInUp{0%{transform:translateY(30px);opacity:0}to{transform:translateY(0);opacity:1}}@keyframes pulse{0%,to{opacity:.5}50%{opacity:.8}}@media(max-width:1024px){.editor-content{padding:40px 60px}.editor-header,.editor-toolbar,.editor-footer{padding-left:24px;padding-right:24px}}@media(max-width:768px){.editor-container{margin:0}.editor-header{flex-direction:column;gap:12px;align-items:flex-start;padding:16px 20px}.editor-title{font-size:18px}.action-btn span{display:none}.action-btn{padding:8px;min-width:40px}.editor-toolbar{padding:12px 20px;top:auto;position:relative}.toolbar-group{padding:2px}.toolbar-btn{width:38px;height:38px}.toolbar-select{min-width:110px;height:38px;font-size:13px}.color-picker-wrapper{width:38px;height:38px}.editor-content{padding:24px 20px;min-height:400px;font-size:16px}.editor-footer{padding:12px 20px;position:relative}.modal-content{width:95%;max-width:620px}}@media print{.editor-header,.editor-toolbar,.editor-footer{display:none}.editor-container{box-shadow:none;border:none}.editor-content{max-height:none}}
1
+ *{margin:0;padding:0;box-sizing:border-box}:root{--toolbar-height: 64px;--toolbar-row-height: 44px;--toolbar-rows: 2;--toolbar-gap: 8px}.editor-container{width:100%;max-width:100%;margin:0;min-height:600px;height:auto;background:#f8f9fa;border-radius:0;box-shadow:none;overflow:visible;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif;display:block;transition:all .3s cubic-bezier(.4,0,.2,1);position:relative;padding-top:0;padding-bottom:0}.editor-container.fullscreen{width:100vw;height:100vh;max-width:100%;margin:0;border-radius:0;z-index:9999}.editor-header,.editor-title,.editor-brand,.editor-badge,.editor-actions,.action-btn{display:none}.action-btn svg{display:none}.page-card .page-body{height:auto;overflow:visible;-webkit-overflow-scrolling:touch}.action-btn.active{display:none}.page-card .page-body img{max-width:100%;height:auto}.page-card .page-body:focus{outline:none!important;box-shadow:none!important}.page-card .page-body[contenteditable]{border:none!important;outline:none!important;box-shadow:none!important}.editor-toolbar{display:flex;gap:var(--toolbar-gap);padding:12px 24px;align-items:center;border-bottom:1px solid #e0e0e0;background:#fff;position:sticky;top:0;left:0;right:0;z-index:100;flex-wrap:wrap;flex-shrink:0;box-shadow:0 1px 3px #0000000f;max-height:calc((var(--toolbar-row-height) * var(--toolbar-rows)) + 24px);overflow:visible}.toolbar-group{display:flex;gap:4px;align-items:center;padding:0;position:relative;flex:0 1 auto}.toolbar-group:not(:last-child):after{content:"";width:1px;height:24px;background:#e0e0e0;margin-left:8px}.toolbar-btn{display:inline-flex;align-items:center;justify-content:center;min-width:32px;height:32px;padding:6px;border-radius:4px;background:transparent;color:#5f6368;cursor:pointer;transition:all .15s ease;border:none;position:relative;flex:0 0 auto}.toolbar-btn svg{width:18px;height:18px;stroke-width:2}.toolbar-btn:hover{background:#f1f3f4;color:#202124}.toolbar-btn:active{background:#e8eaed;transform:scale(.95)}.toolbar-btn.active{background:#e8f0fe;color:#1967d2}.toolbar-select{height:32px;padding:6px 28px 6px 12px;border:1px solid #dadce0;border-radius:4px;background:#fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1L6 6L11 1' stroke='%235f6368' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 8px center;background-size:12px;color:#202124;appearance:none;min-width:88px;font-weight:500;font-size:14px;cursor:pointer;transition:all .15s ease;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif;flex:0 1 140px}.toolbar-select:hover{border-color:#5f6368;background-color:#f8f9fa}.toolbar-select:focus{outline:none;border-color:#1967d2;box-shadow:0 0 0 2px #1967d21a}.color-picker-wrapper{width:32px;height:32px;border:1px solid #d1d5db;border-radius:6px;background:#fff;position:relative;overflow:hidden;cursor:pointer;transition:all .15s ease}.color-picker-wrapper:hover{border-color:#9ca3af;box-shadow:0 2px 4px #0000000f}.toolbar-dropdown-panel{position:absolute;top:calc(100% + 4px);left:0;background:#fff;border:1px solid #d1d5db;border-radius:6px;padding:6px;box-shadow:0 4px 16px #0000001f;z-index:2000;display:flex;gap:4px;align-items:center;max-width:400px;overflow-x:auto;overflow-y:hidden}.toolbar-dropdown-panel::-webkit-scrollbar{height:6px}.toolbar-dropdown-panel::-webkit-scrollbar-track{background:#f3f4f6;border-radius:3px}.toolbar-dropdown-panel::-webkit-scrollbar-thumb{background:#d1d5db;border-radius:3px}.toolbar-dropdown-panel .toolbar-btn{min-width:32px;width:32px;height:32px;flex-shrink:0;border:1px solid #e5e7eb}.toolbar-dropdown-panel .toolbar-btn:hover{background:#f3f4f6;border-color:#3b82f6}.color-picker-wrapper input[type=color]{position:absolute;left:0;top:0;width:100%;height:100%;border:none;padding:0;cursor:pointer}.color-picker-wrapper .color-label{position:absolute;right:4px;bottom:4px;font-size:9px;color:#6b7280;pointer-events:none;font-weight:600}.color-picker-wrapper:focus-within{box-shadow:0 6px 18px #0000001f,0 0 0 4px #22c55e0f;border-color:var(--accent)}.editor-content{flex:1;overflow-y:auto;overflow-x:hidden;background:#f8f9fa;padding:24px;display:flex;justify-content:center;align-items:flex-start;width:100%}.page-card{width:794px;margin:0 auto 24px;background:var(--card-bg);border-radius:0;box-shadow:0 4px 20px #00000014;padding:0;border:1px solid var(--border);border-top:none;display:flex;flex-direction:column;overflow:visible}.page-card .page-body{background:var(--editor-bg);min-height:1000px;padding:64px 96px;border-radius:0;box-shadow:none;border:none;color:#202124;overflow-wrap:break-word;word-wrap:break-word;overflow:visible;flex:1;font-size:16px;line-height:1.6;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif;outline:none;cursor:text}.page-card.size-a4{width:794px;min-height:1123px}.page-card.size-letter{width:816px;min-height:1056px}.page-card.size-a3{width:1122px;min-height:1587px}.page-card.size-legal{width:816px;min-height:1344px}.page-card.size-custom{width:900px;min-height:1200px}.page-card{display:block;box-sizing:border-box}.page-card .page-body{height:auto;overflow:visible}.page-card .page-body table{width:100%;max-width:100%;table-layout:fixed;border-collapse:collapse}.page-card .page-body *{max-width:100%}.page-card .page-body th,.page-card .page-body td{white-space:normal;word-break:break-word;box-sizing:border-box}@media(max-width:1300px){.page-card.size-a3{width:calc(100% - 48px);height:auto}}@media(max-width:1000px){.page-card.size-a4,.page-card.size-letter,.page-card.size-legal,.page-card.size-custom{width:calc(100% - 48px);height:auto}.page-card .page-body{padding:32px 48px}}@media(max-width:768px){.page-card{width:calc(100% - 24px)!important}.page-card .page-body{padding:24px 32px}}.page-size-select{height:36px;padding:6px 10px;border-radius:8px;border:1px solid var(--border);background:#fff;color:var(--text-color);font-weight:600;margin-right:8px}.page-card .page-body h1{font-size:40px;font-weight:700;line-height:1.2;margin:24px 0 16px;color:#202124;letter-spacing:-.5px}.page-card .page-body h1 .page-card .page-body thead th{background:#0f172a88;color:#fff}.page-card .page-body h2{font-size:32px;font-weight:700;line-height:1.3;margin:20px 0 12px;color:#202124;letter-spacing:-.3px}.page-card .page-body h3{font-size:24px;font-weight:600;line-height:1.4;margin:16px 0 10px;color:#202124}.page-card .page-body h4{font-size:20px;font-weight:600;line-height:1.4;margin:14px 0 8px;color:#202124}.page-card .page-body p{margin:0 0 12px;line-height:1.6;color:#3c4043}.page-card .page-body[data-placeholder]:empty:before{content:attr(data-placeholder);color:#9aa0a6;font-style:italic;pointer-events:none;position:absolute}.page-card .page-body strong,.page-card .page-body b{font-weight:700;color:#202124}.page-card .page-body em,.page-card .page-body i{font-style:italic}.page-card .page-body ul,.page-card .page-body ol{margin:12px 0;padding-left:28px}.page-card .page-body li{margin:6px 0;line-height:1.6;color:#3c4043}.editor-content:focus{outline:none;background:var(--editor-bg)}.editor-content p{margin:0 0 16px;transition:color .2s ease}.editor-content h3,.editor-content h4,.editor-content h5,.editor-content h6{color:var(--text-color);margin:24px 0 16px;font-weight:700;transition:color .2s ease}.editor-content a{color:var(--accent);text-decoration:underline}.page-card .page-body a{color:#1d4ed8;text-decoration:underline;cursor:pointer}.page-card .page-body a:hover{opacity:.92}.page-card .page-body a[contenteditable=false]{cursor:pointer}.editable-image-wrap{position:relative;display:inline-block;margin:4px;max-width:100%;vertical-align:top;width:fit-content}.editable-image-wrap.selected{outline:3px solid #3b82f6;outline-offset:2px;box-shadow:0 0 0 1px #3b82f633}.editable-image-wrap img{display:block;max-width:100%;height:auto}.image-resize-handle{position:absolute;width:12px;height:12px;background:#3b82f6;border:2px solid #fff;border-radius:50%;box-shadow:0 2px 6px #0003;z-index:20;display:none}.editable-image-wrap.selected .image-resize-handle{display:block}.image-resize-handle.nw{top:-6px;left:-6px;cursor:nw-resize}.image-resize-handle.ne{top:-6px;right:-6px;cursor:ne-resize}.image-resize-handle.sw{bottom:-6px;left:-6px;cursor:sw-resize}.image-resize-handle.se{bottom:-6px;right:-6px;cursor:se-resize}.image-resize-handle:hover{background:#2563eb;transform:scale(1.2)}.image-controls{position:absolute;bottom:-44px;left:50%;transform:translate(-50%);display:none;gap:4px;background:#fff;border:1px solid #cbd5e1;padding:6px 8px;border-radius:6px;box-shadow:0 4px 12px #00000026;z-index:100;white-space:nowrap}.editable-image-wrap.selected .image-controls{display:flex}.image-control-btn{min-width:32px;height:32px;display:inline-flex;align-items:center;justify-content:center;font-weight:600;font-size:11px;background:#fff;border:1px solid #e5e7eb;border-radius:4px;cursor:pointer;color:#374151;transition:all .15s ease;padding:0 8px}.image-control-btn:hover{background:#3b82f6;color:#fff;border-color:#3b82f6;transform:translateY(-1px);box-shadow:0 2px 6px #0000001a}.image-control-btn svg{width:14px;height:14px}.image-control-divider{width:1px;height:24px;background:#e5e7eb;margin:0 4px}.editor-content img{max-width:100%;height:auto;border-radius:6px;margin:12px 0}.editor-content hr{border:none;border-top:1px solid var(--border);margin:20px 0}.editor-content blockquote{border-left:4px solid var(--border);padding-left:12px;color:var(--muted);font-style:italic}.editor-content code{background:var(--surface-1);color:var(--text-color);padding:3px 6px;border-radius:4px;font-family:Monaco,Menlo,monospace}.editor-content table{border-collapse:collapse;width:100%;margin:16px 0;background:var(--editor-bg);border-radius:0;overflow:visible;box-shadow:none;position:relative}.editor-content table th{background:#f8f9fa;color:var(--text-color);font-weight:700;text-align:left;padding:12px 16px;border:1px solid #cbd5e1;font-size:14px}.editor-content table td{padding:12px 16px;border:1px solid #cbd5e1;color:var(--text-color);background:#fff;font-size:14px}.editor-content table tr:hover td{background:#fefce8}.editable-table-wrap{position:relative;margin:20px 0;display:inline-block;min-width:200px}.editable-table-wrap.selected{outline:3px solid #fbbf24;outline-offset:2px;box-shadow:0 0 0 1px #fbbf2433}.table-resize-handle{position:absolute;width:14px;height:14px;background:#fbbf24;border:2px solid #fff;border-radius:50%;box-shadow:0 2px 6px #0003;cursor:nwse-resize;z-index:20;display:none}.editable-table-wrap.selected .table-resize-handle{display:block}.table-resize-handle.nw{top:-7px;left:-7px;cursor:nw-resize}.table-resize-handle.ne{top:-7px;right:-7px;cursor:ne-resize}.table-resize-handle.sw{bottom:-7px;left:-7px;cursor:sw-resize}.table-resize-handle.se{bottom:-7px;right:-7px;cursor:se-resize}.table-resize-handle:hover{background:#f59e0b;transform:scale(1.2)}.table-controls{position:absolute;top:-48px;left:0;display:none;gap:4px;background:#fff;border:1px solid #cbd5e1;padding:6px;border-radius:6px;box-shadow:0 4px 12px #0000001a;z-index:100}.editable-table-wrap.selected .table-controls{display:flex}.table-control-btn{min-width:32px;height:32px;display:inline-flex;align-items:center;justify-content:center;font-weight:600;font-size:11px;background:#fff;border:1px solid #e5e7eb;border-radius:4px;cursor:pointer;color:#374151;transition:all .15s ease}.table-control-btn:hover{background:#fbbf24;color:#fff;border-color:#fbbf24;transform:translateY(-1px);box-shadow:0 2px 6px #0000001a}.editor-content pre{background:#0b0b0b;color:#f7f7f7;padding:16px;border-radius:8px;overflow-x:auto;margin:16px 0}.editor-content pre code{background:none;color:inherit;padding:0;font-family:Monaco,Menlo,monospace}.editor-footer,.status-bar,.status-item,.status-bar-bottom{display:none}.status-bar-bottom .status-item{display:inline;white-space:nowrap;padding:0;background:none;border:none}.status-item:hover{transform:translateY(-2px);box-shadow:0 4px 8px #0000000f}.editor-content::-webkit-scrollbar,.modal-body::-webkit-scrollbar{width:12px}.editor-content::-webkit-scrollbar-track,.modal-body::-webkit-scrollbar-track{background:#f3f4f6;border-radius:6px}.editor-content::-webkit-scrollbar-thumb,.modal-body::-webkit-scrollbar-thumb{background:#9aa3ad;border-radius:6px;border:2px solid #f3f4f6}.modal-overlay,.link-modal-overlay{position:fixed;inset:0;background:#00000080;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px);display:flex;align-items:center;justify-content:center;z-index:10000;animation:rte-fadeIn .18s ease}@keyframes rte-fadeIn{0%{opacity:0}to{opacity:1}}.modal-content{background:var(--card-bg);border-radius:12px;box-shadow:0 25px 50px -12px #00000040;width:90%;max-width:680px;max-height:90vh;overflow:hidden;display:flex;flex-direction:column;animation:rte-slideUp .28s ease}@keyframes rte-slideUp{0%{transform:translateY(12px);opacity:0}to{transform:translateY(0);opacity:1}}.modal-header{display:flex;justify-content:space-between;align-items:center;padding:18px 20px;background:var(--header-bg);color:#fff}.modal-header h3{margin:0;font-size:18px;font-weight:600}.modal-close{background:#ffffff0f;border:1px solid rgba(255,255,255,.08);color:#fff;width:36px;height:36px;border-radius:8px;display:flex;align-items:center;justify-content:center;cursor:pointer}.modal-close:hover{background:#ffffff1f;transform:rotate(90deg)}.modal-body{padding:20px;overflow-y:auto;flex:1}.modal-footer{display:flex;justify-content:flex-end;gap:12px;padding:16px 20px;background:var(--surface-1);border-top:1px solid var(--border)}.form-group{margin-bottom:16px}.form-group label{display:block;margin-bottom:8px;font-weight:600;color:var(--muted);font-size:14px}.form-input{width:100%;padding:10px 12px;border:1px solid var(--border);border-radius:8px;font-size:15px;font-family:inherit}.form-input:focus{outline:none;box-shadow:0 0 0 4px #0000000a;border-color:var(--border)}.btn-primary{padding:10px 20px;background:var(--inverse-bg);color:#fff;border:none;border-radius:8px;font-weight:600;cursor:pointer}.btn-primary:hover{transform:translateY(-2px);box-shadow:0 6px 12px #00000014}.btn-secondary{padding:10px 20px;background:var(--editor-bg);color:var(--text-color);border:1px solid var(--border);border-radius:8px;cursor:pointer}.html-preview{background:#0b0b0b;color:#f7f7f7;padding:16px;border-radius:8px;overflow-x:auto;font-size:13px;font-family:Monaco,Menlo,monospace;white-space:pre-wrap;word-break:break-all}.editor-content::selection{background:#11182714;color:var(--text-color)}.table-size-picker{position:absolute;top:calc(100% + 4px);left:0;background:#fff;border:1px solid #d1d5db;border-radius:8px;padding:12px;box-shadow:0 10px 25px #0000001a,0 4px 8px #0000000f;z-index:2000;display:none}.table-size-picker.show{display:block}.table-size-grid{display:grid;gap:2px;cursor:pointer}.table-drag-handle{width:18px;height:18px;border-radius:4px;background:#0000000f;position:absolute;top:8px;left:8px;display:flex;align-items:center;justify-content:center;cursor:grab;z-index:1500}.table-drag-handle:active{cursor:grabbing}.table-context-menu{position:absolute;right:8px;top:36px;background:#fff;border:1px solid #d1d5db;border-radius:8px;padding:8px;box-shadow:0 8px 30px #0000001f;display:flex;flex-direction:column;gap:6px;min-width:160px;z-index:2000}.table-context-menu button{background:transparent;border:none;text-align:left;padding:8px 10px;border-radius:6px;cursor:pointer}.table-context-menu button:hover{background:#f3f4f6}.table-context-menu hr{border:none;height:1px;background:#eef2f7;margin:6px 0}.table-cell-preview{width:18px;height:18px;border:1px solid #d1d5db;background:#fff;transition:all .1s;border-radius:2px}.table-cell-preview.hover{background:#3b82f6;border-color:#2563eb}.table-size-label{text-align:center;margin-top:8px;font-size:12px;color:#6b7280;font-weight:600}.page-card .page-body td.selected-cell,.page-card .page-body th.selected-cell{outline:2px solid rgba(59,130,246,.9);background:#3b82f60f}.find-replace-modal{background:#fff;padding:24px;border-radius:12px;box-shadow:0 20px 50px #00000026;max-width:450px;width:90%}.find-replace-modal h3{margin:0 0 20px;font-size:18px;color:#1e293b;font-weight:700}.find-replace-group{margin-bottom:16px}.find-replace-group label{display:block;margin-bottom:6px;font-size:13px;color:#475569;font-weight:600}.find-replace-input{width:100%;padding:8px 12px;border:1px solid #cbd5e1;border-radius:6px;font-size:14px;transition:all .15s ease}.find-replace-input:focus{outline:none;border-color:#3b82f6;box-shadow:0 0 0 3px #3b82f61a}.find-replace-buttons{display:flex;gap:8px;margin-top:20px;flex-wrap:wrap}.find-replace-btn{padding:8px 16px;border-radius:6px;font-size:13px;font-weight:600;cursor:pointer;border:1px solid #cbd5e1;background:#fff;color:#374151;transition:all .15s}.find-replace-btn:hover{background:#f8fafc;border-color:#94a3b8}.find-replace-btn.primary{background:#3b82f6;color:#fff;border-color:#3b82f6}.find-replace-btn.primary:hover{background:#2563eb;border-color:#2563eb}.find-replace-status{margin-top:12px;font-size:13px;color:#64748b;min-height:18px;font-weight:500}.editor-content::-moz-selection{background:#11182714;color:var(--text-color)}@keyframes editorFadeIn{0%{opacity:0}to{opacity:1}}@keyframes slideDown{0%{transform:translateY(-20px);opacity:0}to{transform:translateY(0);opacity:1}}@keyframes slideUp{0%{transform:translateY(20px);opacity:0}to{transform:translateY(0);opacity:1}}@keyframes fadeInLeft{0%{transform:translate(-20px);opacity:0}to{transform:translate(0);opacity:1}}@media print{body *{visibility:hidden!important}.editor-toolbar,.editor-container,.editor-container *{visibility:visible!important}.editor-container{position:absolute!important;left:0!important;top:0!important;width:100%!important}.editor-toolbar{position:fixed!important;top:0!important;left:0!important;right:0!important;z-index:9999!important}.page-card,.page-card .page-body{background:#fff!important;box-shadow:none!important;border:none!important}}body.export-only *{display:none!important}body.export-only .editor-toolbar,body.export-only .editor-container,body.export-only .editor-container *{display:block!important}body.export-only{background:transparent!important}@keyframes fadeInRight{0%{transform:translate(20px);opacity:0}to{transform:translate(0);opacity:1}}@keyframes fadeInUp{0%{transform:translateY(30px);opacity:0}to{transform:translateY(0);opacity:1}}@keyframes pulse{0%,to{opacity:.5}50%{opacity:.8}}@media(max-width:1024px){.editor-content{padding:40px 60px}.editor-header,.editor-toolbar,.editor-footer{padding-left:24px;padding-right:24px}}@media(max-width:768px){.editor-container{margin:0}.editor-header{flex-direction:column;gap:12px;align-items:flex-start;padding:16px 20px}.editor-title{font-size:18px}.action-btn span{display:none}.action-btn{padding:8px;min-width:40px}.editor-toolbar{padding:12px 20px;top:auto;position:relative}.toolbar-group{padding:2px}.toolbar-btn{width:38px;height:38px}.toolbar-select{min-width:110px;height:38px;font-size:13px}.color-picker-wrapper{width:38px;height:38px}.editor-content{padding:24px 20px;min-height:400px;font-size:16px}.editor-footer{padding:12px 20px;position:relative}.modal-content{width:95%;max-width:620px}}@media print{.editor-header,.editor-toolbar,.editor-footer{display:none}.editor-container{box-shadow:none;border:none}.editor-content{max-height:none}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@daneshnaik/rich-text-editor",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "A powerful and feature-rich WYSIWYG rich text editor for React with table editing, image handling, and extensive formatting options",
5
5
  "type": "module",
6
6
  "main": "./dist/rich-text-editor.umd.cjs",