@editora/react 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1,47 +1,47 @@
1
- import { jsx as l, jsxs as N, Fragment as F } from "react/jsx-runtime";
2
- import ee, { useRef as E, useState as R, useEffect as T, useMemo as j } from "react";
3
- import { KeyboardShortcutManager as _, PluginManager as te, Editor as ne } from "@editora/core";
4
- const oe = ({
1
+ import { jsx as l, jsxs as R, Fragment as B } from "react/jsx-runtime";
2
+ import ee, { useRef as E, useState as N, useEffect as A, useMemo as j } from "react";
3
+ import { KeyboardShortcutManager as _, PluginManager as te, Editor as ne, StatusBar as oe, calculateTextStats as re, countLines as ae, getCursorPosition as le, getSelectionInfo as ie } from "@editora/core";
4
+ const ce = ({
5
5
  isOpen: e,
6
6
  options: t,
7
- onSelect: d,
8
- onClose: c,
7
+ onSelect: m,
8
+ onClose: s,
9
9
  anchorRef: i,
10
10
  className: r = ""
11
11
  }) => {
12
- const m = E(null), [f, g] = R({ top: 0, left: 0 });
13
- return T(() => {
12
+ const g = E(null), [d, h] = N({ top: 0, left: 0 });
13
+ return A(() => {
14
14
  if (e && i.current) {
15
- const o = i.current.getBoundingClientRect(), s = 120, h = t.length * 36;
16
- let b = o.bottom + 4, u = o.left;
17
- const v = window.innerWidth, p = window.innerHeight;
18
- u + s > v && (u = v - s - 8), b + h > p && (b = o.top - h - 4), g({ top: b, left: u });
15
+ const o = i.current.getBoundingClientRect(), u = 120, v = t.length * 36;
16
+ let C = o.bottom + 4, c = o.left;
17
+ const f = window.innerWidth, b = window.innerHeight;
18
+ c + u > f && (c = f - u - 8), C + v > b && (C = o.top - v - 4), h({ top: C, left: c });
19
19
  }
20
- }, [e, i, t.length]), T(() => {
21
- if (e && i.current && m.current) {
22
- const o = i.current.getBoundingClientRect(), s = m.current.getBoundingClientRect();
23
- let h = o.bottom + 4, b = o.left;
24
- const u = window.innerWidth, v = window.innerHeight;
25
- b + s.width > u && (b = u - s.width - 8), h + s.height > v && (h = o.top - s.height - 4), g({ top: h, left: b });
20
+ }, [e, i, t.length]), A(() => {
21
+ if (e && i.current && g.current) {
22
+ const o = i.current.getBoundingClientRect(), u = g.current.getBoundingClientRect();
23
+ let v = o.bottom + 4, C = o.left;
24
+ const c = window.innerWidth, f = window.innerHeight;
25
+ C + u.width > c && (C = c - u.width - 8), v + u.height > f && (v = o.top - u.height - 4), h({ top: v, left: C });
26
26
  }
27
- }, [e]), T(() => {
28
- const o = (h) => {
29
- m.current && !m.current.contains(h.target) && i.current && !i.current.contains(h.target) && c();
30
- }, s = (h) => {
31
- h.key === "Escape" && c();
27
+ }, [e]), A(() => {
28
+ const o = (v) => {
29
+ g.current && !g.current.contains(v.target) && i.current && !i.current.contains(v.target) && s();
30
+ }, u = (v) => {
31
+ v.key === "Escape" && s();
32
32
  };
33
- return e && (document.addEventListener("mousedown", o), document.addEventListener("keydown", s)), () => {
34
- document.removeEventListener("mousedown", o), document.removeEventListener("keydown", s);
33
+ return e && (document.addEventListener("mousedown", o), document.addEventListener("keydown", u)), () => {
34
+ document.removeEventListener("mousedown", o), document.removeEventListener("keydown", u);
35
35
  };
36
- }, [e, c, i]), e ? /* @__PURE__ */ l(
36
+ }, [e, s, i]), e ? /* @__PURE__ */ l(
37
37
  "div",
38
38
  {
39
- ref: m,
39
+ ref: g,
40
40
  className: `rte-inline-menu ${r}`,
41
41
  style: {
42
42
  position: "fixed",
43
- top: f.top,
44
- left: f.left,
43
+ top: d.top,
44
+ left: d.left,
45
45
  zIndex: 1e3,
46
46
  background: "white",
47
47
  border: "1px solid #ccc",
@@ -56,7 +56,7 @@ const oe = ({
56
56
  {
57
57
  className: "rte-inline-menu-item",
58
58
  onClick: () => {
59
- d(o.value), c();
59
+ m(o.value), s();
60
60
  },
61
61
  style: {
62
62
  padding: "8px 12px",
@@ -67,11 +67,11 @@ const oe = ({
67
67
  overflow: "hidden",
68
68
  textOverflow: "ellipsis"
69
69
  },
70
- onMouseEnter: (s) => {
71
- s.currentTarget.style.backgroundColor = "#f5f5f5";
70
+ onMouseEnter: (u) => {
71
+ u.currentTarget.style.backgroundColor = "#f5f5f5";
72
72
  },
73
- onMouseLeave: (s) => {
74
- s.currentTarget.style.backgroundColor = "transparent";
73
+ onMouseLeave: (u) => {
74
+ u.currentTarget.style.backgroundColor = "transparent";
75
75
  },
76
76
  children: o.label
77
77
  },
@@ -82,16 +82,16 @@ const oe = ({
82
82
  }, V = ({
83
83
  editor: e,
84
84
  position: t = "top",
85
- sticky: d = !1,
86
- floating: c = !1
85
+ sticky: m = !1,
86
+ floating: s = !1
87
87
  }) => {
88
- const [i, r] = R(null), [m, f] = R(null), [g, o] = R(null), [s, h] = R(null), [b, u] = R(!1), v = E({}), p = E(null), y = E(null), C = E(null), w = e.pluginManager.getToolbarItems();
89
- T(() => {
88
+ const [i, r] = N(null), [g, d] = N(null), [h, o] = N(null), [u, v] = N(null), [C, c] = N(!1), f = E({}), b = E(null), p = E(null), y = E(null), w = e.pluginManager.getToolbarItems();
89
+ A(() => {
90
90
  const n = () => {
91
- if (!p.current || !y.current) return;
92
- const W = p.current.clientWidth, H = 16, Y = 40, U = 4, Z = W - H - Y - U;
91
+ if (!b.current || !p.current) return;
92
+ const W = b.current.clientWidth, H = 16, Y = 40, U = 4, Z = W - H - Y - U;
93
93
  let q = 0, P = 0;
94
- const $ = y.current.children;
94
+ const $ = p.current.children;
95
95
  for (let z = 0; z < $.length; z++) {
96
96
  const K = $[z].offsetWidth + U;
97
97
  if (q + K <= Z)
@@ -99,49 +99,49 @@ const oe = ({
99
99
  else
100
100
  break;
101
101
  }
102
- h(Math.max(1, P));
102
+ v(Math.max(1, P));
103
103
  }, a = requestAnimationFrame(() => {
104
104
  n();
105
- }), x = new ResizeObserver(() => {
105
+ }), k = new ResizeObserver(() => {
106
106
  n();
107
107
  });
108
- p.current && x.observe(p.current);
109
- const S = new MutationObserver(() => {
108
+ b.current && k.observe(b.current);
109
+ const M = new MutationObserver(() => {
110
110
  n();
111
111
  });
112
- return y.current && S.observe(y.current, {
112
+ return p.current && M.observe(p.current, {
113
113
  childList: !0,
114
114
  subtree: !0
115
115
  }), () => {
116
- cancelAnimationFrame(a), x.disconnect(), S.disconnect();
116
+ cancelAnimationFrame(a), k.disconnect(), M.disconnect();
117
117
  };
118
118
  }, [w.length]);
119
- const L = (n) => (v.current[n] || (v.current[n] = ee.createRef()), v.current[n]), k = (n, a) => {
120
- const x = p.current?.closest("[data-editora-editor]"), S = x?.querySelector(".rte-content");
121
- if (S && S.focus(), g && (n === "setTextAlignment" || n === "setFontFamily" || n === "setBlockType")) {
119
+ const S = (n) => (f.current[n] || (f.current[n] = ee.createRef()), f.current[n]), x = (n, a) => {
120
+ const k = b.current?.closest("[data-editora-editor]"), M = k?.querySelector(".rte-content");
121
+ if (M && M.focus(), h && (n === "setTextAlignment" || n === "setFontFamily" || n === "setBlockType")) {
122
122
  const H = window.getSelection();
123
- H && (H.removeAllRanges(), H.addRange(g)), o(null);
123
+ H && (H.removeAllRanges(), H.addRange(h)), o(null);
124
124
  }
125
125
  typeof window < "u" && window.executeEditorCommand && window.executeEditorCommand(n, a), r(null);
126
- const W = x?.querySelector(".rte-content");
126
+ const W = k?.querySelector(".rte-content");
127
127
  W && W.focus();
128
- }, A = (n) => {
128
+ }, T = (n) => {
129
129
  const a = window.getSelection();
130
130
  a && a.rangeCount > 0 && o(a.getRangeAt(0).cloneRange()), r(i === n ? null : n);
131
- }, M = (n) => {
131
+ }, L = (n) => {
132
132
  const a = window.getSelection();
133
- a && a.rangeCount > 0 && o(a.getRangeAt(0).cloneRange()), f(m === n ? null : n), r(null);
133
+ a && a.rangeCount > 0 && o(a.getRangeAt(0).cloneRange()), d(g === n ? null : n), r(null);
134
134
  }, I = (n, a) => {
135
- if (g) {
136
- const x = window.getSelection();
137
- x && (x.removeAllRanges(), x.addRange(g)), o(null);
135
+ if (h) {
136
+ const k = window.getSelection();
137
+ k && (k.removeAllRanges(), k.addRange(h)), o(null);
138
138
  }
139
- k(n, a), f(null);
139
+ x(n, a), d(null);
140
140
  }, D = (n, a) => n && n.startsWith("<svg") && n.endsWith("</svg>") ? /* @__PURE__ */ l("span", { dangerouslySetInnerHTML: { __html: n } }) : n && n.length === 1 && /^[BIUSH]$/.test(n) ? /* @__PURE__ */ l("span", { style: { fontWeight: "bold", fontSize: "14px", lineHeight: "1" }, children: n }) : n || "⚪";
141
- if (c)
141
+ if (s)
142
142
  return null;
143
143
  const Q = {
144
- ...d && {
144
+ ...m && {
145
145
  position: "sticky",
146
146
  top: 0,
147
147
  zIndex: 100,
@@ -152,44 +152,44 @@ const oe = ({
152
152
  order: 2
153
153
  // Move to bottom in flex container
154
154
  }
155
- }, O = (n) => n.map((a, x) => /* @__PURE__ */ l(
155
+ }, O = (n) => n.map((a, k) => /* @__PURE__ */ l(
156
156
  "div",
157
157
  {
158
158
  className: "rte-toolbar-item",
159
159
  style: {
160
- display: s !== null && x >= s ? "none" : "flex"
160
+ display: u !== null && k >= u ? "none" : "flex"
161
161
  },
162
- children: a.type === "dropdown" ? /* @__PURE__ */ N("div", { className: "rte-toolbar-dropdown", children: [
163
- /* @__PURE__ */ N(
162
+ children: a.type === "dropdown" ? /* @__PURE__ */ R("div", { className: "rte-toolbar-dropdown", children: [
163
+ /* @__PURE__ */ R(
164
164
  "button",
165
165
  {
166
166
  className: "rte-toolbar-button",
167
167
  "data-command": a.command,
168
168
  "data-active": "false",
169
- onClick: () => A(a.command),
169
+ onClick: () => T(a.command),
170
170
  children: [
171
171
  a.label,
172
172
  " ▼"
173
173
  ]
174
174
  }
175
175
  ),
176
- i === a.command && /* @__PURE__ */ l("div", { className: "rte-toolbar-dropdown-menu", children: a.options?.map((S) => /* @__PURE__ */ l(
176
+ i === a.command && /* @__PURE__ */ l("div", { className: "rte-toolbar-dropdown-menu", children: a.options?.map((M) => /* @__PURE__ */ l(
177
177
  "div",
178
178
  {
179
179
  className: "rte-toolbar-dropdown-item",
180
- onClick: () => k(a.command, S.value),
181
- children: S.label
180
+ onClick: () => x(a.command, M.value),
181
+ children: M.label
182
182
  },
183
- S.value
183
+ M.value
184
184
  )) })
185
185
  ] }) : a.type === "inline-menu" ? /* @__PURE__ */ l(
186
186
  "button",
187
187
  {
188
- ref: L(a.command),
188
+ ref: S(a.command),
189
189
  className: "rte-toolbar-button",
190
190
  "data-command": a.command,
191
191
  "data-active": "false",
192
- onClick: () => M(a.command),
192
+ onClick: () => L(a.command),
193
193
  title: a.label,
194
194
  children: D(a.icon, a.command)
195
195
  }
@@ -199,11 +199,11 @@ const oe = ({
199
199
  type: "text",
200
200
  className: `rte-toolbar-input ${a.label.toLowerCase().replace(/\s+/g, "-")}`,
201
201
  placeholder: a.placeholder,
202
- onChange: (S) => k(a.command, S.target.value),
203
- onKeyDown: (S) => {
204
- S.key === "Enter" && k(
202
+ onChange: (M) => x(a.command, M.target.value),
203
+ onKeyDown: (M) => {
204
+ M.key === "Enter" && x(
205
205
  a.command,
206
- S.target.value
206
+ M.target.value
207
207
  );
208
208
  },
209
209
  title: a.label
@@ -227,66 +227,66 @@ const oe = ({
227
227
  className: "rte-toolbar-button",
228
228
  "data-command": a.command,
229
229
  "data-active": "false",
230
- onClick: () => k(a.command),
230
+ onClick: () => x(a.command),
231
231
  title: a.label,
232
232
  children: D(a.icon, a.command)
233
233
  }
234
234
  )
235
235
  },
236
- x
236
+ k
237
237
  ));
238
- return /* @__PURE__ */ N(F, { children: [
239
- /* @__PURE__ */ N("div", { className: "rte-toolbar-wrapper", style: Q, children: [
240
- /* @__PURE__ */ N("div", { className: "rte-toolbar", ref: p, children: [
241
- /* @__PURE__ */ l("div", { className: "rte-toolbar-items-container", ref: y, children: O(w) }),
242
- s !== null && s < w.length && /* @__PURE__ */ l(
238
+ return /* @__PURE__ */ R(B, { children: [
239
+ /* @__PURE__ */ R("div", { className: "rte-toolbar-wrapper", style: Q, children: [
240
+ /* @__PURE__ */ R("div", { className: "rte-toolbar", ref: b, children: [
241
+ /* @__PURE__ */ l("div", { className: "rte-toolbar-items-container", ref: p, children: O(w) }),
242
+ u !== null && u < w.length && /* @__PURE__ */ l(
243
243
  "button",
244
244
  {
245
- ref: C,
246
- className: `rte-toolbar-more-button ${b ? "active" : ""}`,
247
- onClick: () => u(!b),
245
+ ref: y,
246
+ className: `rte-toolbar-more-button ${C ? "active" : ""}`,
247
+ onClick: () => c(!C),
248
248
  title: "Show more options",
249
249
  "aria-label": "More toolbar options",
250
250
  children: "☰"
251
251
  }
252
252
  )
253
253
  ] }),
254
- s !== null && s < w.length && /* @__PURE__ */ l(
254
+ u !== null && u < w.length && /* @__PURE__ */ l(
255
255
  "div",
256
256
  {
257
- className: `rte-toolbar-expanded-row ${b ? "show" : ""}`,
257
+ className: `rte-toolbar-expanded-row ${C ? "show" : ""}`,
258
258
  children: w.map(
259
- (n, a) => a >= (s || 0) && /* @__PURE__ */ l("div", { className: "rte-toolbar-item", children: n.type === "dropdown" ? /* @__PURE__ */ N("div", { className: "rte-toolbar-dropdown", children: [
260
- /* @__PURE__ */ N(
259
+ (n, a) => a >= (u || 0) && /* @__PURE__ */ l("div", { className: "rte-toolbar-item", children: n.type === "dropdown" ? /* @__PURE__ */ R("div", { className: "rte-toolbar-dropdown", children: [
260
+ /* @__PURE__ */ R(
261
261
  "button",
262
262
  {
263
263
  className: "rte-toolbar-button",
264
264
  "data-command": n.command,
265
265
  "data-active": "false",
266
- onClick: () => A(n.command),
266
+ onClick: () => T(n.command),
267
267
  children: [
268
268
  n.label,
269
269
  " ▼"
270
270
  ]
271
271
  }
272
272
  ),
273
- i === n.command && /* @__PURE__ */ l("div", { className: "rte-toolbar-dropdown-menu", children: n.options?.map((x) => /* @__PURE__ */ l(
273
+ i === n.command && /* @__PURE__ */ l("div", { className: "rte-toolbar-dropdown-menu", children: n.options?.map((k) => /* @__PURE__ */ l(
274
274
  "div",
275
275
  {
276
276
  className: "rte-toolbar-dropdown-item",
277
- onClick: () => k(n.command, x.value),
278
- children: x.label
277
+ onClick: () => x(n.command, k.value),
278
+ children: k.label
279
279
  },
280
- x.value
280
+ k.value
281
281
  )) })
282
282
  ] }) : n.type === "inline-menu" ? /* @__PURE__ */ l(
283
283
  "button",
284
284
  {
285
- ref: L(n.command),
285
+ ref: S(n.command),
286
286
  className: "rte-toolbar-button",
287
287
  "data-command": n.command,
288
288
  "data-active": "false",
289
- onClick: () => M(n.command),
289
+ onClick: () => L(n.command),
290
290
  title: n.label,
291
291
  children: D(n.icon, n.command)
292
292
  }
@@ -296,11 +296,11 @@ const oe = ({
296
296
  type: "text",
297
297
  className: "rte-toolbar-input",
298
298
  placeholder: n.placeholder,
299
- onChange: (x) => k(n.command, x.target.value),
300
- onKeyDown: (x) => {
301
- x.key === "Enter" && k(
299
+ onChange: (k) => x(n.command, k.target.value),
300
+ onKeyDown: (k) => {
301
+ k.key === "Enter" && x(
302
302
  n.command,
303
- x.target.value
303
+ k.target.value
304
304
  );
305
305
  },
306
306
  title: n.label
@@ -311,7 +311,7 @@ const oe = ({
311
311
  className: "rte-toolbar-button",
312
312
  "data-command": n.command,
313
313
  "data-active": "false",
314
- onClick: () => k(n.command),
314
+ onClick: () => x(n.command),
315
315
  title: n.label,
316
316
  children: D(n.icon, n.command)
317
317
  }
@@ -321,32 +321,32 @@ const oe = ({
321
321
  )
322
322
  ] }),
323
323
  w.map((n) => n.type === "inline-menu" ? /* @__PURE__ */ l(
324
- oe,
324
+ ce,
325
325
  {
326
- isOpen: m === n.command,
326
+ isOpen: g === n.command,
327
327
  options: n.options || [],
328
328
  onSelect: (a) => I(n.command, a),
329
- onClose: () => f(null),
330
- anchorRef: L(n.command)
329
+ onClose: () => d(null),
330
+ anchorRef: S(n.command)
331
331
  },
332
332
  `menu-${n.command}`
333
333
  ) : null)
334
334
  ] });
335
335
  };
336
- function re(e, t) {
337
- const d = E(), c = E("");
338
- return T(() => {
336
+ function se(e, t) {
337
+ const m = E(), s = E("");
338
+ return A(() => {
339
339
  if (!t?.enabled) return;
340
- const r = t.intervalMs || 3e4, m = t.storageKey || "rte-autosave", f = t.provider || "localStorage", g = async () => {
340
+ const r = t.intervalMs || 3e4, g = t.storageKey || "rte-autosave", d = t.provider || "localStorage", h = async () => {
341
341
  const o = e();
342
- if (o !== c.current) {
343
- if (c.current = o, f === "localStorage")
342
+ if (o !== s.current) {
343
+ if (s.current = o, d === "localStorage")
344
344
  try {
345
- localStorage.setItem(m, o), localStorage.setItem(`${m}-timestamp`, Date.now().toString()), console.log("[Autosave] Content saved to localStorage");
346
- } catch (s) {
347
- console.error("[Autosave] Failed to save to localStorage:", s);
345
+ localStorage.setItem(g, o), localStorage.setItem(`${g}-timestamp`, Date.now().toString()), console.log("[Autosave] Content saved to localStorage");
346
+ } catch (u) {
347
+ console.error("[Autosave] Failed to save to localStorage:", u);
348
348
  }
349
- else if (f === "api" && t.apiUrl)
349
+ else if (d === "api" && t.apiUrl)
350
350
  try {
351
351
  await fetch(t.apiUrl, {
352
352
  method: "POST",
@@ -355,29 +355,29 @@ function re(e, t) {
355
355
  },
356
356
  body: JSON.stringify({ content: o, timestamp: Date.now() })
357
357
  }), console.log("[Autosave] Content saved to API");
358
- } catch (s) {
359
- console.error("[Autosave] Failed to save to API:", s);
358
+ } catch (u) {
359
+ console.error("[Autosave] Failed to save to API:", u);
360
360
  }
361
361
  }
362
362
  };
363
- return d.current = setInterval(g, r), () => {
364
- d.current && clearInterval(d.current);
363
+ return m.current = setInterval(h, r), () => {
364
+ m.current && clearInterval(m.current);
365
365
  };
366
366
  }, [t?.enabled, t?.intervalMs, t?.storageKey, t?.provider, t?.apiUrl, e]), { restore: () => {
367
367
  if (!t?.enabled) return null;
368
368
  const r = t.storageKey || "rte-autosave";
369
369
  if ((t.provider || "localStorage") === "localStorage")
370
370
  try {
371
- const f = localStorage.getItem(r), g = localStorage.getItem(`${r}-timestamp`);
372
- if (f && g)
373
- return console.log("[Autosave] Restored from localStorage, saved at:", new Date(parseInt(g))), f;
374
- } catch (f) {
375
- console.error("[Autosave] Failed to restore from localStorage:", f);
371
+ const d = localStorage.getItem(r), h = localStorage.getItem(`${r}-timestamp`);
372
+ if (d && h)
373
+ return console.log("[Autosave] Restored from localStorage, saved at:", new Date(parseInt(h))), d;
374
+ } catch (d) {
375
+ console.error("[Autosave] Failed to restore from localStorage:", d);
376
376
  }
377
377
  return null;
378
378
  } };
379
379
  }
380
- const ae = [
380
+ const de = [
381
381
  "p",
382
382
  "br",
383
383
  "strong",
@@ -413,7 +413,7 @@ const ae = [
413
413
  "sup",
414
414
  "sub",
415
415
  "hr"
416
- ], le = {
416
+ ], ue = {
417
417
  "*": ["class", "style", "id", "data-*"],
418
418
  a: ["href", "target", "rel", "title"],
419
419
  img: ["src", "alt", "width", "height", "loading"],
@@ -423,130 +423,130 @@ const ae = [
423
423
  td: ["colspan", "rowspan", "align", "valign"],
424
424
  th: ["colspan", "rowspan", "align", "valign"]
425
425
  };
426
- function G(e, t, d) {
426
+ function G(e, t, m) {
427
427
  if (t?.sanitize === !1)
428
428
  return e;
429
- const c = t?.allowedTags && t.allowedTags.length > 0 ? t.allowedTags : ae, i = t?.allowedAttributes || le, r = document.createElement("div");
430
- return r.innerHTML = e, X(r, c, i), r.innerHTML;
429
+ const s = t?.allowedTags && t.allowedTags.length > 0 ? t.allowedTags : de, i = t?.allowedAttributes || ue, r = document.createElement("div");
430
+ return r.innerHTML = e, X(r, s, i), r.innerHTML;
431
431
  }
432
- function X(e, t, d) {
433
- const c = Array.from(e.childNodes);
434
- for (const i of c)
432
+ function X(e, t, m) {
433
+ const s = Array.from(e.childNodes);
434
+ for (const i of s)
435
435
  if (i.nodeType === Node.ELEMENT_NODE) {
436
- const r = i, m = r.tagName.toLowerCase();
437
- if (!t.includes(m)) {
436
+ const r = i, g = r.tagName.toLowerCase();
437
+ if (!t.includes(g)) {
438
438
  for (; r.firstChild; )
439
439
  e.insertBefore(r.firstChild, r);
440
440
  e.removeChild(r);
441
441
  continue;
442
442
  }
443
- ie(r, d), X(r, t, d);
443
+ fe(r, m), X(r, t, m);
444
444
  } else {
445
445
  if (i.nodeType === Node.TEXT_NODE)
446
446
  continue;
447
447
  e.removeChild(i);
448
448
  }
449
449
  }
450
- function ie(e, t) {
451
- const d = e.tagName.toLowerCase(), c = Array.from(e.attributes), i = t[d] || [], r = t["*"] || [], m = [...i, ...r];
452
- for (const f of c) {
453
- const g = f.name.toLowerCase();
450
+ function fe(e, t) {
451
+ const m = e.tagName.toLowerCase(), s = Array.from(e.attributes), i = t[m] || [], r = t["*"] || [], g = [...i, ...r];
452
+ for (const d of s) {
453
+ const h = d.name.toLowerCase();
454
454
  let o = !1;
455
- m.includes(g) && (o = !0);
456
- for (const s of m)
457
- if (s.endsWith("*")) {
458
- const h = s.slice(0, -1);
459
- if (g.startsWith(h)) {
455
+ g.includes(h) && (o = !0);
456
+ for (const u of g)
457
+ if (u.endsWith("*")) {
458
+ const v = u.slice(0, -1);
459
+ if (h.startsWith(v)) {
460
460
  o = !0;
461
461
  break;
462
462
  }
463
463
  }
464
- (g.startsWith("on") || // Event handlers
465
- g === "javascript:" || g === "href" && f.value.trim().toLowerCase().startsWith("javascript:") || g === "src" && f.value.trim().toLowerCase().startsWith("javascript:")) && (o = !1), o || e.removeAttribute(f.name);
464
+ (h.startsWith("on") || // Event handlers
465
+ h === "javascript:" || h === "href" && d.value.trim().toLowerCase().startsWith("javascript:") || h === "src" && d.value.trim().toLowerCase().startsWith("javascript:")) && (o = !1), o || e.removeAttribute(d.name);
466
466
  }
467
467
  e.hasAttribute("href") && (e.getAttribute("href") || "").trim().toLowerCase().startsWith("javascript:") && e.removeAttribute("href"), e.hasAttribute("src") && (e.getAttribute("src") || "").trim().toLowerCase().startsWith("javascript:") && e.removeAttribute("src");
468
468
  }
469
- function ce(e, t, d) {
470
- return d?.sanitizeOnPaste === !1 ? e : G(e, t);
469
+ function me(e, t, m) {
470
+ return m?.sanitizeOnPaste === !1 ? e : G(e, t);
471
471
  }
472
- function se(e, t, d) {
473
- return d?.sanitizeOnInput === !1 ? e : G(e, t);
472
+ function ge(e, t, m) {
473
+ return m?.sanitizeOnInput === !1 ? e : G(e, t);
474
474
  }
475
- const de = ({
475
+ const be = ({
476
476
  editor: e,
477
477
  defaultValue: t,
478
- value: d,
479
- onChange: c,
478
+ value: m,
479
+ onChange: s,
480
480
  pasteConfig: i,
481
481
  contentConfig: r,
482
- securityConfig: m,
483
- performanceConfig: f,
484
- autosaveConfig: g
482
+ securityConfig: g,
483
+ performanceConfig: d,
484
+ autosaveConfig: h
485
485
  }) => {
486
- const o = E(null), s = d !== void 0, h = E(), { restore: b } = re(
486
+ const o = E(null), u = m !== void 0, v = E(), { restore: C } = se(
487
487
  () => o.current?.innerHTML || "",
488
- g
488
+ h
489
489
  );
490
- return T(() => {
490
+ return A(() => {
491
491
  if (!o.current) return;
492
- const u = b(), v = u || d || t;
493
- v && o.current.innerHTML !== v && (o.current.innerHTML = v, u && c && c(u));
494
- }, []), T(() => {
495
- !o.current || !s || d !== o.current.innerHTML && (o.current.innerHTML = d);
496
- }, [d, s]), T(() => {
492
+ const c = C(), f = c || m || t;
493
+ f && o.current.innerHTML !== f && (o.current.innerHTML = f, c && s && s(c));
494
+ }, []), A(() => {
495
+ !o.current || !u || m !== o.current.innerHTML && (o.current.innerHTML = m);
496
+ }, [m, u]), A(() => {
497
497
  if (!o.current) return;
498
- const u = () => {
499
- if (!o.current || !c) return;
500
- let C = o.current.innerHTML;
501
- if (m?.sanitizeOnInput !== !1 && r?.sanitize !== !1 && (C = se(C, r, m), C !== o.current.innerHTML)) {
502
- const w = window.getSelection(), L = w && w.rangeCount > 0 ? w.getRangeAt(0) : null;
503
- if (o.current.innerHTML = C, L && w)
498
+ const c = () => {
499
+ if (!o.current || !s) return;
500
+ let y = o.current.innerHTML;
501
+ if (g?.sanitizeOnInput !== !1 && r?.sanitize !== !1 && (y = ge(y, r, g), y !== o.current.innerHTML)) {
502
+ const w = window.getSelection(), S = w && w.rangeCount > 0 ? w.getRangeAt(0) : null;
503
+ if (o.current.innerHTML = y, S && w)
504
504
  try {
505
- w.removeAllRanges(), w.addRange(L);
505
+ w.removeAllRanges(), w.addRange(S);
506
506
  } catch {
507
507
  }
508
508
  }
509
- f?.debounceInputMs ? (h.current && clearTimeout(h.current), h.current = setTimeout(() => {
510
- c(C);
511
- }, f.debounceInputMs)) : c(C);
512
- }, v = (C) => {
513
- C.preventDefault();
514
- let w = C.clipboardData?.getData("text/html");
515
- const L = C.clipboardData?.getData("text/plain");
509
+ d?.debounceInputMs ? (v.current && clearTimeout(v.current), v.current = setTimeout(() => {
510
+ s(y);
511
+ }, d.debounceInputMs)) : s(y);
512
+ }, f = (y) => {
513
+ y.preventDefault();
514
+ let w = y.clipboardData?.getData("text/html");
515
+ const S = y.clipboardData?.getData("text/plain");
516
516
  if (i?.clean || !i?.keepFormatting) {
517
- L && document.execCommand("insertText", !1, L);
517
+ S && document.execCommand("insertText", !1, S);
518
518
  return;
519
519
  }
520
520
  if (w) {
521
- m?.sanitizeOnPaste !== !1 && r?.sanitize !== !1 && (w = ce(w, r, m));
522
- const k = window.getSelection();
523
- if (k && k.rangeCount > 0) {
524
- const A = k.getRangeAt(0);
525
- A.deleteContents();
526
- const M = document.createElement("div");
527
- M.innerHTML = w;
521
+ g?.sanitizeOnPaste !== !1 && r?.sanitize !== !1 && (w = me(w, r, g));
522
+ const x = window.getSelection();
523
+ if (x && x.rangeCount > 0) {
524
+ const T = x.getRangeAt(0);
525
+ T.deleteContents();
526
+ const L = document.createElement("div");
527
+ L.innerHTML = w;
528
528
  const I = document.createDocumentFragment();
529
- for (; M.firstChild; )
530
- I.appendChild(M.firstChild);
531
- A.insertNode(I), A.collapse(!1), k.removeAllRanges(), k.addRange(A);
529
+ for (; L.firstChild; )
530
+ I.appendChild(L.firstChild);
531
+ T.insertNode(I), T.collapse(!1), x.removeAllRanges(), x.addRange(T);
532
532
  }
533
- } else L && document.execCommand("insertText", !1, L);
534
- }, p = (C) => {
535
- const w = C.target;
533
+ } else S && document.execCommand("insertText", !1, S);
534
+ }, b = (y) => {
535
+ const w = y.target;
536
536
  (w.tagName === "IMG" || w.tagName === "VIDEO") && (w.style.resize = "both", w.style.overflow = "auto", w.style.display = "inline-block");
537
- }, y = o.current;
538
- return y.addEventListener("input", u), y.addEventListener("paste", v), y.addEventListener("click", p), y.focus(), () => {
539
- h.current && clearTimeout(h.current), y.removeEventListener("input", u), y.removeEventListener("paste", v), y.removeEventListener("click", p);
537
+ }, p = o.current;
538
+ return p.addEventListener("input", c), p.addEventListener("paste", f), p.addEventListener("click", b), p.focus(), () => {
539
+ v.current && clearTimeout(v.current), p.removeEventListener("input", c), p.removeEventListener("paste", f), p.removeEventListener("click", b);
540
540
  };
541
- }, [e, c, i, r, m, f]), T(() => {
541
+ }, [e, s, i, r, g, d]), A(() => {
542
542
  if (!o.current || typeof window > "u") return;
543
- const u = new _(), v = o.current, p = (y) => {
544
- u.handleKeyDown(y, (C, w) => {
545
- typeof window < "u" && window.executeEditorCommand && window.executeEditorCommand(C, w);
543
+ const c = new _(), f = o.current, b = (p) => {
544
+ c.handleKeyDown(p, (y, w) => {
545
+ typeof window < "u" && window.executeEditorCommand && window.executeEditorCommand(y, w);
546
546
  });
547
547
  };
548
- return v.addEventListener("keydown", p), () => {
549
- v.removeEventListener("keydown", p);
548
+ return f.addEventListener("keydown", b), () => {
549
+ f.removeEventListener("keydown", b);
550
550
  };
551
551
  }, []), /* @__PURE__ */ l(
552
552
  "div",
@@ -561,7 +561,7 @@ const de = ({
561
561
  padding: "16px",
562
562
  outline: "none",
563
563
  border: "1px solid #ddd",
564
- borderRadius: "4px",
564
+ borderRadius: "0px 0px 4px 4px",
565
565
  fontSize: "14px",
566
566
  lineHeight: "1.5",
567
567
  overflow: "auto",
@@ -573,54 +573,54 @@ const de = ({
573
573
  children: /* @__PURE__ */ l("p", { children: /* @__PURE__ */ l("br", {}) })
574
574
  }
575
575
  );
576
- }, ue = ({
576
+ }, he = ({
577
577
  editor: e,
578
578
  isEnabled: t
579
579
  }) => {
580
- const [d, c] = R(!1), [i, r] = R({ top: 0, left: 0 }), m = E(null), f = E(null), g = E(null), o = E(null);
581
- T(() => {
580
+ const [m, s] = N(!1), [i, r] = N({ top: 0, left: 0 }), g = E(null), d = E(null), h = E(null), o = E(null);
581
+ A(() => {
582
582
  if (!t) {
583
- c(!1);
583
+ s(!1);
584
584
  return;
585
585
  }
586
- o.current = m.current?.closest("[data-editora-editor]");
587
- const h = () => {
588
- g.current && clearTimeout(g.current);
589
- const u = window.getSelection();
590
- if (!u || u.rangeCount === 0) {
591
- c(!1), f.current = null;
586
+ o.current = g.current?.closest("[data-editora-editor]");
587
+ const v = () => {
588
+ h.current && clearTimeout(h.current);
589
+ const c = window.getSelection();
590
+ if (!c || c.rangeCount === 0) {
591
+ s(!1), d.current = null;
592
592
  return;
593
593
  }
594
- const v = u.getRangeAt(0), p = u.toString().trim(), y = o.current?.querySelector(".rte-content");
595
- if (!y || !y.contains(v.commonAncestorContainer)) {
596
- c(!1), f.current = null;
594
+ const f = c.getRangeAt(0), b = c.toString().trim(), p = o.current?.querySelector(".rte-content");
595
+ if (!p || !p.contains(f.commonAncestorContainer)) {
596
+ s(!1), d.current = null;
597
597
  return;
598
598
  }
599
- if (p.length > 0) {
600
- const C = v.getBoundingClientRect(), w = y.getBoundingClientRect(), L = 300;
601
- if (C && w) {
602
- const k = C.top - 50;
603
- let A = C.left + C.width / 2;
604
- const M = L / 2, I = w.left, D = w.right;
605
- A - M < I && (A = I + M + 10), A + M > D && (A = D - M - 10), r({ top: k, left: A }), g.current = setTimeout(() => {
606
- c(!0), f.current = v.cloneRange();
599
+ if (b.length > 0) {
600
+ const y = f.getBoundingClientRect(), w = p.getBoundingClientRect(), S = 300;
601
+ if (y && w) {
602
+ const x = y.top - 50;
603
+ let T = y.left + y.width / 2;
604
+ const L = S / 2, I = w.left, D = w.right;
605
+ T - L < I && (T = I + L + 10), T + L > D && (T = D - L - 10), r({ top: x, left: T }), h.current = setTimeout(() => {
606
+ s(!0), d.current = f.cloneRange();
607
607
  }, 300);
608
608
  }
609
609
  } else
610
- c(!1), f.current = null;
611
- }, b = (u) => {
612
- m.current && !m.current.contains(u.target) && (window.getSelection(), o.current?.querySelector(".rte-content")?.contains(u.target) || (c(!1), f.current = null));
610
+ s(!1), d.current = null;
611
+ }, C = (c) => {
612
+ g.current && !g.current.contains(c.target) && (window.getSelection(), o.current?.querySelector(".rte-content")?.contains(c.target) || (s(!1), d.current = null));
613
613
  };
614
- return document.addEventListener("selectionchange", h), document.addEventListener("mousedown", b), document.addEventListener("keydown", (u) => {
615
- u.key === "Escape" && (c(!1), f.current = null);
614
+ return document.addEventListener("selectionchange", v), document.addEventListener("mousedown", C), document.addEventListener("keydown", (c) => {
615
+ c.key === "Escape" && (s(!1), d.current = null);
616
616
  }), () => {
617
- document.removeEventListener("selectionchange", h), document.removeEventListener("mousedown", b), g.current && clearTimeout(g.current);
617
+ document.removeEventListener("selectionchange", v), document.removeEventListener("mousedown", C), h.current && clearTimeout(h.current);
618
618
  };
619
619
  }, [t]);
620
- const s = (h, b) => {
621
- if (!f.current) return;
622
- const u = o.current?.querySelector(".rte-content");
623
- u && u.focus(), {
620
+ const u = (v, C) => {
621
+ if (!d.current) return;
622
+ const c = o.current?.querySelector(".rte-content");
623
+ c && c.focus(), {
624
624
  toggleBold: () => document.execCommand("bold", !1),
625
625
  toggleItalic: () => document.execCommand("italic", !1),
626
626
  toggleUnderline: () => document.execCommand("underline", !1),
@@ -632,27 +632,27 @@ const de = ({
632
632
  document.execCommand("removeFormat", !1), document.execCommand("unlink", !1);
633
633
  },
634
634
  toggleCode: () => {
635
- const p = window.getSelection();
636
- if (p && p.rangeCount > 0) {
637
- const y = p.getRangeAt(0), C = document.createElement("code");
638
- y.surroundContents(C);
635
+ const b = window.getSelection();
636
+ if (b && b.rangeCount > 0) {
637
+ const p = b.getRangeAt(0), y = document.createElement("code");
638
+ p.surroundContents(y);
639
639
  }
640
640
  },
641
641
  setBlockType: () => {
642
- if (b === "blockquote") {
643
- const p = window.getSelection();
644
- if (p && p.rangeCount > 0) {
645
- const y = p.getRangeAt(0);
646
- (y.commonAncestorContainer.nodeType === Node.TEXT_NODE ? y.commonAncestorContainer.parentElement : y.commonAncestorContainer)?.closest?.("blockquote") ? document.execCommand("formatBlock", !1, "p") : document.execCommand("formatBlock", !1, "blockquote");
642
+ if (C === "blockquote") {
643
+ const b = window.getSelection();
644
+ if (b && b.rangeCount > 0) {
645
+ const p = b.getRangeAt(0);
646
+ (p.commonAncestorContainer.nodeType === Node.TEXT_NODE ? p.commonAncestorContainer.parentElement : p.commonAncestorContainer)?.closest?.("blockquote") ? document.execCommand("formatBlock", !1, "p") : document.execCommand("formatBlock", !1, "blockquote");
647
647
  }
648
- } else b && document.execCommand("formatBlock", !1, b);
648
+ } else C && document.execCommand("formatBlock", !1, C);
649
649
  }
650
- }[h]?.(), c(!1), f.current = null, u && u.focus();
650
+ }[v]?.(), s(!1), d.current = null, c && c.focus();
651
651
  };
652
- return !t || !d ? null : /* @__PURE__ */ N(
652
+ return !t || !m ? null : /* @__PURE__ */ R(
653
653
  "div",
654
654
  {
655
- ref: m,
655
+ ref: g,
656
656
  className: "floating-toolbar",
657
657
  style: {
658
658
  position: "fixed",
@@ -674,7 +674,7 @@ const de = ({
674
674
  "button",
675
675
  {
676
676
  className: "floating-toolbar-btn",
677
- onClick: () => s("toggleBold"),
677
+ onClick: () => u("toggleBold"),
678
678
  title: "Bold (Ctrl+B)",
679
679
  children: /* @__PURE__ */ l("strong", { children: "B" })
680
680
  }
@@ -683,7 +683,7 @@ const de = ({
683
683
  "button",
684
684
  {
685
685
  className: "floating-toolbar-btn",
686
- onClick: () => s("toggleItalic"),
686
+ onClick: () => u("toggleItalic"),
687
687
  title: "Italic (Ctrl+I)",
688
688
  children: /* @__PURE__ */ l("em", { children: "I" })
689
689
  }
@@ -692,7 +692,7 @@ const de = ({
692
692
  "button",
693
693
  {
694
694
  className: "floating-toolbar-btn",
695
- onClick: () => s("toggleUnderline"),
695
+ onClick: () => u("toggleUnderline"),
696
696
  title: "Underline (Ctrl+U)",
697
697
  children: /* @__PURE__ */ l("u", { children: "U" })
698
698
  }
@@ -701,7 +701,7 @@ const de = ({
701
701
  "button",
702
702
  {
703
703
  className: "floating-toolbar-btn",
704
- onClick: () => s("toggleStrikethrough"),
704
+ onClick: () => u("toggleStrikethrough"),
705
705
  title: "Strikethrough",
706
706
  children: /* @__PURE__ */ l("s", { children: "S" })
707
707
  }
@@ -711,7 +711,7 @@ const de = ({
711
711
  "button",
712
712
  {
713
713
  className: "floating-toolbar-btn",
714
- onClick: () => s("clearFormatting"),
714
+ onClick: () => u("clearFormatting"),
715
715
  title: "Clear Formatting",
716
716
  children: "⌫"
717
717
  }
@@ -720,7 +720,7 @@ const de = ({
720
720
  "button",
721
721
  {
722
722
  className: "floating-toolbar-btn",
723
- onClick: () => s("createLink"),
723
+ onClick: () => u("createLink"),
724
724
  title: "Insert Link",
725
725
  children: "🔗"
726
726
  }
@@ -729,7 +729,7 @@ const de = ({
729
729
  "button",
730
730
  {
731
731
  className: "floating-toolbar-btn",
732
- onClick: () => s("toggleCode"),
732
+ onClick: () => u("toggleCode"),
733
733
  title: "Code",
734
734
  children: "Code"
735
735
  }
@@ -739,7 +739,7 @@ const de = ({
739
739
  "button",
740
740
  {
741
741
  className: "floating-toolbar-btn",
742
- onClick: () => s("setBlockType", "blockquote"),
742
+ onClick: () => u("setBlockType", "blockquote"),
743
743
  title: "Quote",
744
744
  children: "❝"
745
745
  }
@@ -747,24 +747,28 @@ const de = ({
747
747
  ]
748
748
  }
749
749
  );
750
- }, fe = ({
750
+ }, we = ({
751
751
  plugins: e,
752
752
  children: t
753
753
  }) => {
754
- const d = e.filter((i) => i.context?.provider);
755
- return d.length === 0 ? /* @__PURE__ */ l(F, { children: t }) : d.reduce(
754
+ const m = e.filter((i) => i.context?.provider);
755
+ return m.length === 0 ? /* @__PURE__ */ l(B, { children: t }) : m.reduce(
756
756
  (i, r) => {
757
- const m = r.context.provider;
758
- return /* @__PURE__ */ l(m, { children: i }, r.name);
757
+ const g = r.context.provider;
758
+ return /* @__PURE__ */ l(g, { children: i }, r.name);
759
759
  },
760
- /* @__PURE__ */ l(F, { children: t })
760
+ /* @__PURE__ */ l(B, { children: t })
761
761
  );
762
- }, me = {
762
+ }, ve = {
763
763
  toolbar: {
764
764
  items: [],
765
765
  floating: !1,
766
766
  sticky: !1
767
767
  },
768
+ statusbar: {
769
+ enabled: !1,
770
+ position: "bottom"
771
+ },
768
772
  menubar: {
769
773
  enabled: !1,
770
774
  items: []
@@ -828,16 +832,17 @@ const de = ({
828
832
  }
829
833
  };
830
834
  function J(e, t) {
831
- const d = { ...e };
832
- for (const c in t) {
833
- const i = t[c], r = d[c];
834
- i !== void 0 && (typeof i == "object" && i !== null && !Array.isArray(i) && typeof r == "object" && r !== null && !Array.isArray(r) ? d[c] = J(r, i) : d[c] = i);
835
+ const m = { ...e };
836
+ for (const s in t) {
837
+ const i = t[s], r = m[s];
838
+ i !== void 0 && (typeof i == "object" && i !== null && !Array.isArray(i) && typeof r == "object" && r !== null && !Array.isArray(r) ? m[s] = J(r, i) : m[s] = i);
835
839
  }
836
- return d;
840
+ return m;
837
841
  }
838
- function ge(e) {
839
- const t = J(me, {
842
+ function pe(e) {
843
+ const t = J(ve, {
840
844
  toolbar: e.toolbar,
845
+ statusbar: e.statusbar,
841
846
  menubar: e.menubar,
842
847
  contextMenu: e.contextMenu,
843
848
  media: e.media,
@@ -869,19 +874,19 @@ function ge(e) {
869
874
  onChange: e.onChange,
870
875
  onInit: e.onInit,
871
876
  onDestroy: e.onDestroy,
872
- plugins: Array.isArray(e.plugins) ? e.plugins.filter((c) => typeof c != "string") : [],
877
+ plugins: Array.isArray(e.plugins) ? e.plugins.filter((s) => typeof s != "string") : [],
873
878
  pluginConfig: e.pluginConfig || {}
874
879
  };
875
880
  }
876
- const B = /* @__PURE__ */ new Map();
881
+ const F = /* @__PURE__ */ new Map();
877
882
  typeof window < "u" && (window.registerEditorCommand = (e, t) => {
878
- B.set(e, t);
883
+ F.set(e, t);
879
884
  }, window.executeEditorCommand = (e, t) => {
880
- const d = B.get(e);
881
- return d ? d(t) : (console.warn(`No handler registered for command: ${e}`), !1);
885
+ const m = F.get(e);
886
+ return m ? m(t) : (console.warn(`No handler registered for command: ${e}`), !1);
882
887
  });
883
- const be = (e) => {
884
- const t = j(() => ge(e), [
888
+ const ye = (e) => {
889
+ const t = j(() => pe(e), [
885
890
  e.id,
886
891
  e.className,
887
892
  e.value,
@@ -902,61 +907,93 @@ const be = (e) => {
902
907
  e.security,
903
908
  e.floatingToolbar,
904
909
  e.mediaConfig
905
- ]), d = E(null), c = E(null), i = E(e.onInit), r = E(e.onDestroy), m = E(null);
906
- T(() => {
910
+ ]), m = E(null), s = E(null), i = E(e.onInit), r = E(e.onDestroy), g = E(null), d = E(null), h = E(null);
911
+ A(() => {
907
912
  i.current = e.onInit, r.current = e.onDestroy;
908
913
  });
909
- const f = j(() => {
910
- const h = new te();
911
- t.plugins.forEach((u) => {
912
- h.register(u), u.commands && typeof window < "u" && Object.entries(u.commands).forEach(([v, p]) => {
913
- B.set(v, p);
914
+ const o = j(() => {
915
+ const c = new te();
916
+ t.plugins.forEach((b) => {
917
+ c.register(b), b.commands && typeof window < "u" && Object.entries(b.commands).forEach(([p, y]) => {
918
+ F.set(p, y);
914
919
  });
915
920
  });
916
- const b = new ne(h);
917
- return d.current = b, b;
921
+ const f = new ne(c);
922
+ return m.current = f, f;
918
923
  }, [t.plugins]);
919
- T(() => {
920
- const h = {
921
- getHTML: () => m.current?.querySelector(".rte-content")?.innerHTML || "",
922
- setHTML: (b) => {
923
- const u = m.current?.querySelector(".rte-content");
924
- u && (u.innerHTML = b);
924
+ A(() => {
925
+ const c = {
926
+ getHTML: () => g.current?.querySelector(".rte-content")?.innerHTML || "",
927
+ setHTML: (f) => {
928
+ const b = g.current?.querySelector(".rte-content");
929
+ b && (b.innerHTML = f);
925
930
  },
926
- execCommand: (b, u) => {
927
- typeof window < "u" && window.executeEditorCommand && window.executeEditorCommand(b, u);
931
+ execCommand: (f, b) => {
932
+ typeof window < "u" && window.executeEditorCommand && window.executeEditorCommand(f, b);
928
933
  },
929
- registerCommand: (b, u) => {
930
- typeof window < "u" && window.registerEditorCommand && window.registerEditorCommand(b, u);
934
+ registerCommand: (f, b) => {
935
+ typeof window < "u" && window.registerEditorCommand && window.registerEditorCommand(f, b);
931
936
  },
932
937
  focus: () => {
933
- m.current?.querySelector(".rte-content")?.focus();
938
+ g.current?.querySelector(".rte-content")?.focus();
934
939
  },
935
940
  blur: () => {
936
- m.current?.querySelector(".rte-content")?.blur();
941
+ g.current?.querySelector(".rte-content")?.blur();
937
942
  },
938
943
  destroy: () => {
939
944
  r.current && r.current();
940
945
  },
941
- onChange: (b) => () => {
946
+ onChange: (f) => () => {
942
947
  },
943
948
  getState: () => ({
944
949
  plugins: t.plugins,
945
950
  config: t
946
951
  }),
947
952
  toolbar: {
948
- items: f.toolbar?.items || []
953
+ items: o.toolbar?.items || []
949
954
  }
950
955
  };
951
- return c.current = h, i.current && i.current(h), () => {
956
+ return s.current = c, i.current && i.current(c), () => {
952
957
  r.current && r.current();
953
958
  };
954
- }, []);
955
- const g = t.toolbar.floating ?? !1, o = t.toolbar.position || "top", s = t.toolbar.sticky ?? !1;
956
- return /* @__PURE__ */ l(fe, { plugins: t.plugins, children: /* @__PURE__ */ N(
959
+ }, []), A(() => {
960
+ if (t.statusbar.enabled && h.current && g.current) {
961
+ d.current || (d.current = new oe({
962
+ enabled: !0,
963
+ position: t.statusbar.position
964
+ }), d.current.create(h.current));
965
+ const c = g.current.querySelector(".rte-content");
966
+ if (c) {
967
+ const f = () => {
968
+ const b = c.textContent || "", { words: p, chars: y } = re(b), w = ae(c), S = window.getSelection();
969
+ let x, T;
970
+ if (S && S.rangeCount > 0) {
971
+ const L = S.getRangeAt(0);
972
+ x = le(c, L), L.collapsed || (T = ie(L, x), x = void 0);
973
+ }
974
+ d.current?.update({
975
+ wordCount: p,
976
+ charCount: y,
977
+ lineCount: w,
978
+ cursorPosition: x,
979
+ selectionInfo: T
980
+ });
981
+ };
982
+ return c.addEventListener("input", f), c.addEventListener("selectionchange", f), document.addEventListener("selectionchange", f), f(), () => {
983
+ c.removeEventListener("input", f), c.removeEventListener("selectionchange", f), document.removeEventListener("selectionchange", f);
984
+ };
985
+ }
986
+ } else
987
+ d.current && (d.current.destroy(), d.current = null);
988
+ return () => {
989
+ d.current && (d.current.destroy(), d.current = null);
990
+ };
991
+ }, [t.statusbar.enabled, t.statusbar.position]);
992
+ const u = t.toolbar.floating ?? !1, v = t.toolbar.position || "top", C = t.toolbar.sticky ?? !1;
993
+ return /* @__PURE__ */ l(we, { plugins: t.plugins, children: /* @__PURE__ */ R(
957
994
  "div",
958
995
  {
959
- ref: m,
996
+ ref: g,
960
997
  id: t.id,
961
998
  "data-editora-editor": !0,
962
999
  className: `rte-editor ${t.className || ""}`,
@@ -967,19 +1004,19 @@ const be = (e) => {
967
1004
  height: "100%"
968
1005
  },
969
1006
  children: [
970
- o !== "bottom" && /* @__PURE__ */ l(
1007
+ v !== "bottom" && /* @__PURE__ */ l(
971
1008
  V,
972
1009
  {
973
- editor: f,
974
- position: o,
975
- sticky: s,
976
- floating: g
1010
+ editor: o,
1011
+ position: v,
1012
+ sticky: C,
1013
+ floating: u
977
1014
  }
978
1015
  ),
979
1016
  /* @__PURE__ */ l(
980
- de,
1017
+ be,
981
1018
  {
982
- editor: f,
1019
+ editor: o,
983
1020
  defaultValue: t.defaultValue,
984
1021
  value: t.value,
985
1022
  onChange: t.onChange,
@@ -990,43 +1027,51 @@ const be = (e) => {
990
1027
  autosaveConfig: t.autosave
991
1028
  }
992
1029
  ),
993
- o === "bottom" && /* @__PURE__ */ l(
1030
+ v === "bottom" && /* @__PURE__ */ l(
994
1031
  V,
995
1032
  {
996
- editor: f,
997
- position: o,
998
- sticky: s,
999
- floating: g
1033
+ editor: o,
1034
+ position: v,
1035
+ sticky: C,
1036
+ floating: u
1000
1037
  }
1001
1038
  ),
1002
1039
  /* @__PURE__ */ l(
1003
- ue,
1040
+ he,
1041
+ {
1042
+ editor: o,
1043
+ isEnabled: u
1044
+ }
1045
+ ),
1046
+ t.statusbar.enabled && /* @__PURE__ */ l(
1047
+ "div",
1004
1048
  {
1005
- editor: f,
1006
- isEnabled: g
1049
+ ref: h,
1050
+ className: "editora-statusbar-container",
1051
+ style: { order: t.statusbar.position === "top" ? -1 : 1 }
1007
1052
  }
1008
1053
  )
1009
1054
  ]
1010
1055
  }
1011
1056
  ) });
1012
- }, ye = (e) => /* @__PURE__ */ l(be, { ...e });
1013
- function Ce(e = {}) {
1014
- const t = E(null), d = E(e.onCommand);
1015
- return T(() => {
1016
- d.current = e.onCommand;
1017
- }), T(() => {
1057
+ }, Se = (e) => /* @__PURE__ */ l(ye, { ...e });
1058
+ function Te(e = {}) {
1059
+ const t = E(null), m = E(e.onCommand);
1060
+ return A(() => {
1061
+ m.current = e.onCommand;
1062
+ }), A(() => {
1018
1063
  if (typeof window > "u" || e.enabled === !1) return;
1019
- const c = new _(e);
1020
- t.current = c;
1021
- const i = (m) => c.handleKeyDown(m, (g, o) => {
1022
- d.current && d.current(g, o), typeof window < "u" && window.executeEditorCommand && window.executeEditorCommand(g, o);
1064
+ const s = new _(e);
1065
+ t.current = s;
1066
+ const i = (g) => s.handleKeyDown(g, (h, o) => {
1067
+ m.current && m.current(h, o), typeof window < "u" && window.executeEditorCommand && window.executeEditorCommand(h, o);
1023
1068
  }), r = e.editorElement || document;
1024
1069
  return r && r.addEventListener("keydown", i), () => {
1025
1070
  r && r.removeEventListener("keydown", i);
1026
1071
  };
1027
1072
  }, [e.editorElement, e.enabled, e.shortcuts, e.customShortcuts]), {
1028
1073
  getShortcuts: () => t.current?.getAllShortcuts() || [],
1029
- getShortcutForCommand: (c) => t.current?.getShortcutForCommand(c),
1074
+ getShortcutForCommand: (s) => t.current?.getShortcutForCommand(s),
1030
1075
  getShortcutsHelp: () => t.current?.getShortcutsHelp() || "",
1031
1076
  enable: () => t.current?.enable(),
1032
1077
  disable: () => t.current?.disable(),
@@ -1034,11 +1079,11 @@ function Ce(e = {}) {
1034
1079
  };
1035
1080
  }
1036
1081
  export {
1037
- de as EditorContent,
1038
- ye as EditoraEditor,
1039
- oe as InlineMenu,
1040
- ye as RichTextEditor,
1082
+ be as EditorContent,
1083
+ Se as EditoraEditor,
1084
+ ce as InlineMenu,
1085
+ Se as RichTextEditor,
1041
1086
  V as Toolbar,
1042
- ge as mergeConfig,
1043
- Ce as useKeyboardShortcuts
1087
+ pe as mergeConfig,
1088
+ Te as useKeyboardShortcuts
1044
1089
  };