@ryzeup/richtexteditor 1.0.22 → 1.0.24

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.es.js CHANGED
@@ -11,7 +11,7 @@ var Ae = (r, s, d) => s in r ? ut(r, s, { enumerable: !0, configurable: !0, writ
11
11
  return r;
12
12
  }, ie = (r, s) => mt(r, gt(s));
13
13
  import * as pt from "react";
14
- import a, { useRef as V, useState as k, useEffect as I } from "react";
14
+ import l, { useRef as U, useState as k, useEffect as F } from "react";
15
15
  import { createPortal as vt } from "react-dom";
16
16
  window.React = pt;
17
17
  var Te = {
@@ -20,14 +20,14 @@ var Te = {
20
20
  className: void 0,
21
21
  style: void 0,
22
22
  attr: void 0
23
- }, Me = a.createContext && /* @__PURE__ */ a.createContext(Te), yt = ["attr", "size", "title"];
23
+ }, Me = l.createContext && /* @__PURE__ */ l.createContext(Te), yt = ["attr", "size", "title"];
24
24
  function Et(r, s) {
25
25
  if (r == null) return {};
26
- var d = wt(r, s), m, p;
26
+ var d = wt(r, s), m, y;
27
27
  if (Object.getOwnPropertySymbols) {
28
28
  var w = Object.getOwnPropertySymbols(r);
29
- for (p = 0; p < w.length; p++)
30
- m = w[p], !(s.indexOf(m) >= 0) && Object.prototype.propertyIsEnumerable.call(r, m) && (d[m] = r[m]);
29
+ for (y = 0; y < w.length; y++)
30
+ m = w[y], !(s.indexOf(m) >= 0) && Object.prototype.propertyIsEnumerable.call(r, m) && (d[m] = r[m]);
31
31
  }
32
32
  return d;
33
33
  }
@@ -55,8 +55,8 @@ function ze(r, s) {
55
55
  var d = Object.keys(r);
56
56
  if (Object.getOwnPropertySymbols) {
57
57
  var m = Object.getOwnPropertySymbols(r);
58
- s && (m = m.filter(function(p) {
59
- return Object.getOwnPropertyDescriptor(r, p).enumerable;
58
+ s && (m = m.filter(function(y) {
59
+ return Object.getOwnPropertyDescriptor(r, y).enumerable;
60
60
  })), d.push.apply(d, m);
61
61
  }
62
62
  return d;
@@ -90,12 +90,12 @@ function Rt(r, s) {
90
90
  return (s === "string" ? String : Number)(r);
91
91
  }
92
92
  function De(r) {
93
- return r && r.map((s, d) => /* @__PURE__ */ a.createElement(s.tag, G({
93
+ return r && r.map((s, d) => /* @__PURE__ */ l.createElement(s.tag, G({
94
94
  key: d
95
95
  }, s.attr), De(s.child)));
96
96
  }
97
97
  function N(r) {
98
- return (s) => /* @__PURE__ */ a.createElement(xt, J({
98
+ return (s) => /* @__PURE__ */ l.createElement(xt, J({
99
99
  attr: G({}, r.attr)
100
100
  }, s), De(r.child));
101
101
  }
@@ -103,10 +103,10 @@ function xt(r) {
103
103
  var s = (d) => {
104
104
  var {
105
105
  attr: m,
106
- size: p,
106
+ size: y,
107
107
  title: w
108
- } = r, R = Et(r, yt), M = p || d.size || "1em", E;
109
- return d.className && (E = d.className), r.className && (E = (E ? E + " " : "") + r.className), /* @__PURE__ */ a.createElement("svg", J({
108
+ } = r, R = Et(r, yt), M = y || d.size || "1em", E;
109
+ return d.className && (E = d.className), r.className && (E = (E ? E + " " : "") + r.className), /* @__PURE__ */ l.createElement("svg", J({
110
110
  stroke: "currentColor",
111
111
  fill: "currentColor",
112
112
  strokeWidth: "0"
@@ -118,9 +118,9 @@ function xt(r) {
118
118
  height: M,
119
119
  width: M,
120
120
  xmlns: "http://www.w3.org/2000/svg"
121
- }), w && /* @__PURE__ */ a.createElement("title", null, w), r.children);
121
+ }), w && /* @__PURE__ */ l.createElement("title", null, w), r.children);
122
122
  };
123
- return Me !== void 0 ? /* @__PURE__ */ a.createElement(Me.Consumer, null, (d) => s(d)) : s(Te);
123
+ return Me !== void 0 ? /* @__PURE__ */ l.createElement(Me.Consumer, null, (d) => s(d)) : s(Te);
124
124
  }
125
125
  function Lt(r) {
126
126
  return N({ attr: { viewBox: "0 0 448 512" }, child: [{ tag: "path", attr: { d: "M352 64c0-17.7-14.3-32-32-32L128 32c-17.7 0-32 14.3-32 32s14.3 32 32 32l192 0c17.7 0 32-14.3 32-32zm96 128c0-17.7-14.3-32-32-32L32 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l384 0c17.7 0 32-14.3 32-32zM0 448c0 17.7 14.3 32 32 32l384 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L32 416c-17.7 0-32 14.3-32 32zM352 320c0-17.7-14.3-32-32-32l-192 0c-17.7 0-32 14.3-32 32s14.3 32 32 32l192 0c17.7 0 32-14.3 32-32z" }, child: [] }] })(r);
@@ -149,10 +149,10 @@ function Tt(r) {
149
149
  function Dt(r) {
150
150
  return N({ attr: { viewBox: "0 0 512 512" }, child: [{ tag: "path", attr: { d: "M326.612 185.391c59.747 59.809 58.927 155.698.36 214.59-.11.12-.24.25-.36.37l-67.2 67.2c-59.27 59.27-155.699 59.262-214.96 0-59.27-59.26-59.27-155.7 0-214.96l37.106-37.106c9.84-9.84 26.786-3.3 27.294 10.606.648 17.722 3.826 35.527 9.69 52.721 1.986 5.822.567 12.262-3.783 16.612l-13.087 13.087c-28.026 28.026-28.905 73.66-1.155 101.96 28.024 28.579 74.086 28.749 102.325.51l67.2-67.19c28.191-28.191 28.073-73.757 0-101.83-3.701-3.694-7.429-6.564-10.341-8.569a16.037 16.037 0 0 1-6.947-12.606c-.396-10.567 3.348-21.456 11.698-29.806l21.054-21.055c5.521-5.521 14.182-6.199 20.584-1.731a152.482 152.482 0 0 1 20.522 17.197zM467.547 44.449c-59.261-59.262-155.69-59.27-214.96 0l-67.2 67.2c-.12.12-.25.25-.36.37-58.566 58.892-59.387 154.781.36 214.59a152.454 152.454 0 0 0 20.521 17.196c6.402 4.468 15.064 3.789 20.584-1.731l21.054-21.055c8.35-8.35 12.094-19.239 11.698-29.806a16.037 16.037 0 0 0-6.947-12.606c-2.912-2.005-6.64-4.875-10.341-8.569-28.073-28.073-28.191-73.639 0-101.83l67.2-67.19c28.239-28.239 74.3-28.069 102.325.51 27.75 28.3 26.872 73.934-1.155 101.96l-13.087 13.087c-4.35 4.35-5.769 10.79-3.783 16.612 5.864 17.194 9.042 34.999 9.69 52.721.509 13.906 17.454 20.446 27.294 10.606l37.106-37.106c59.271-59.259 59.271-155.699.001-214.959z" }, child: [] }] })(r);
151
151
  }
152
- function Ht(r) {
152
+ function Ot(r) {
153
153
  return N({ attr: { viewBox: "0 0 512 512" }, child: [{ tag: "path", attr: { d: "M80 368H16a16 16 0 0 0-16 16v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16v-64a16 16 0 0 0-16-16zm0-320H16A16 16 0 0 0 0 64v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16V64a16 16 0 0 0-16-16zm0 160H16a16 16 0 0 0-16 16v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16v-64a16 16 0 0 0-16-16zm416 176H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0-320H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16V80a16 16 0 0 0-16-16zm0 160H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z" }, child: [] }] })(r);
154
154
  }
155
- function Ot(r) {
155
+ function Ht(r) {
156
156
  return N({ attr: { viewBox: "0 0 496 512" }, child: [{ tag: "path", attr: { d: "M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm80 168c17.7 0 32 14.3 32 32s-14.3 32-32 32-32-14.3-32-32 14.3-32 32-32zm-160 0c17.7 0 32 14.3 32 32s-14.3 32-32 32-32-14.3-32-32 14.3-32 32-32zm194.8 170.2C334.3 380.4 292.5 400 248 400s-86.3-19.6-114.8-53.8c-13.6-16.3 11-36.7 24.6-20.5 22.4 26.9 55.2 42.2 90.2 42.2s67.8-15.4 90.2-42.2c13.4-16.2 38.1 4.2 24.6 20.5z" }, child: [] }] })(r);
157
157
  }
158
158
  function _t(r) {
@@ -161,10 +161,10 @@ function _t(r) {
161
161
  function jt(r) {
162
162
  return N({ attr: { viewBox: "0 0 448 512" }, child: [{ tag: "path", attr: { d: "M32 64h32v160c0 88.22 71.78 160 160 160s160-71.78 160-160V64h32a16 16 0 0 0 16-16V16a16 16 0 0 0-16-16H272a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h32v160a80 80 0 0 1-160 0V64h32a16 16 0 0 0 16-16V16a16 16 0 0 0-16-16H32a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16zm400 384H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z" }, child: [] }] })(r);
163
163
  }
164
- function It(r) {
164
+ function Ft(r) {
165
165
  return N({ attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { fill: "none", d: "M0 0h24v24H0z" }, child: [] }, { tag: "path", attr: { d: "M2 20h20v4H2v-4zm3.49-3h2.42l1.27-3.58h5.65L16.09 17h2.42L13.25 3h-2.5L5.49 17zm4.42-5.61 2.03-5.79h.12l2.03 5.79H9.91z" }, child: [] }] })(r);
166
166
  }
167
- function Ft(r) {
167
+ function It(r) {
168
168
  return N({ attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { fill: "none", d: "M0 0h24v24H0V0z" }, child: [] }, { tag: "path", attr: { d: "M20 8V5H6.39l3 3h1.83l-.55 1.28 2.09 2.1L14.21 8zM3.41 4.86 2 6.27l6.97 6.97L6.5 19h3l1.57-3.66L16.73 21l1.41-1.41z" }, child: [] }] })(r);
169
169
  }
170
170
  const Pt = [
@@ -284,7 +284,7 @@ const Pt = [
284
284
  saveSelection: s,
285
285
  handleFileChange: d,
286
286
  handleFontSizeChange: m,
287
- handleFontFamilyChange: p,
287
+ handleFontFamilyChange: y,
288
288
  // insertListBlock,
289
289
  insertEmoji: w,
290
290
  handleLink: R,
@@ -293,18 +293,18 @@ const Pt = [
293
293
  className: x,
294
294
  style: L
295
295
  }) => {
296
- var $, O;
297
- const A = V(null), P = V(null), T = V(null), [q, B] = k(!1), [F, _] = k({
296
+ var $, H;
297
+ const A = U(null), P = U(null), T = U(null), [q, B] = k(!1), [I, _] = k({
298
298
  x: 0,
299
299
  y: 0
300
300
  });
301
- I(() => {
301
+ F(() => {
302
302
  const h = (C) => {
303
303
  !C.target.closest(".rte-emoji-popup") && !C.target.closest("button[title='Emoji']") && B(!1);
304
304
  };
305
305
  return document.addEventListener("mousedown", h), () => document.removeEventListener("mousedown", h);
306
306
  }, []);
307
- const U = (h) => {
307
+ const V = (h) => {
308
308
  var j;
309
309
  h.preventDefault();
310
310
  const C = h.currentTarget.dataset.command;
@@ -346,7 +346,7 @@ const Pt = [
346
346
  color: !1,
347
347
  highlight: !1
348
348
  });
349
- return I(() => {
349
+ return F(() => {
350
350
  const h = () => {
351
351
  D({
352
352
  bold: document.queryCommandState("bold"),
@@ -367,52 +367,52 @@ const Pt = [
367
367
  });
368
368
  };
369
369
  return document.addEventListener("selectionchange", h), () => document.removeEventListener("selectionchange", h);
370
- }, []), /* @__PURE__ */ a.createElement("div", {
370
+ }, []), /* @__PURE__ */ l.createElement("div", {
371
371
  className: `rte-toolbar ${x || ""}`,
372
372
  style: L
373
- }, E.bold && /* @__PURE__ */ a.createElement("button", {
373
+ }, E.bold && /* @__PURE__ */ l.createElement("button", {
374
374
  "data-command": "bold",
375
375
  title: "Bold",
376
- onMouseDown: U,
376
+ onMouseDown: V,
377
377
  className: z.bold ? "rte-active" : ""
378
- }, /* @__PURE__ */ a.createElement(kt, null)), E.italic && /* @__PURE__ */ a.createElement("button", {
378
+ }, /* @__PURE__ */ l.createElement(kt, null)), E.italic && /* @__PURE__ */ l.createElement("button", {
379
379
  "data-command": "italic",
380
380
  title: "Italic",
381
- onMouseDown: U,
381
+ onMouseDown: V,
382
382
  className: z.italic ? "rte-active" : ""
383
- }, /* @__PURE__ */ a.createElement(Tt, null)), E.underline && /* @__PURE__ */ a.createElement("button", {
383
+ }, /* @__PURE__ */ l.createElement(Tt, null)), E.underline && /* @__PURE__ */ l.createElement("button", {
384
384
  "data-command": "underline",
385
385
  title: "Underline",
386
- onMouseDown: U,
386
+ onMouseDown: V,
387
387
  className: z.underline ? "rte-active" : ""
388
- }, /* @__PURE__ */ a.createElement(jt, null)), E.unorderedList && /* @__PURE__ */ a.createElement("button", {
388
+ }, /* @__PURE__ */ l.createElement(jt, null)), E.unorderedList && /* @__PURE__ */ l.createElement("button", {
389
389
  "data-command": "insertUnorderedList",
390
- onMouseDown: U,
390
+ onMouseDown: V,
391
391
  title: "UnorderedList",
392
392
  className: z.unorderedList ? "rte-active" : ""
393
- }, /* @__PURE__ */ a.createElement(Ht, null)), E.orderedList && /* @__PURE__ */ a.createElement("button", {
393
+ }, /* @__PURE__ */ l.createElement(Ot, null)), E.orderedList && /* @__PURE__ */ l.createElement("button", {
394
394
  "data-command": "insertOrderedList",
395
395
  title: "OrderedList",
396
- onMouseDown: U,
396
+ onMouseDown: V,
397
397
  className: z.orderedList ? "rte-active" : ""
398
- }, /* @__PURE__ */ a.createElement(Mt, null)), E.link && /* @__PURE__ */ a.createElement("button", {
398
+ }, /* @__PURE__ */ l.createElement(Mt, null)), E.link && /* @__PURE__ */ l.createElement("button", {
399
399
  "data-command": "createLink",
400
400
  title: "Link",
401
401
  onClick: R,
402
402
  className: z.link ? "rte-active" : ""
403
- }, /* @__PURE__ */ a.createElement(Dt, null)), E.removeFormat && /* @__PURE__ */ a.createElement("button", {
403
+ }, /* @__PURE__ */ l.createElement(Dt, null)), E.removeFormat && /* @__PURE__ */ l.createElement("button", {
404
404
  "data-command": "Remove format",
405
405
  title: "removeFormat",
406
406
  onMouseDown: (h) => {
407
407
  h.preventDefault(), s(), M();
408
408
  },
409
409
  className: z.removeFormat ? "rte-active" : ""
410
- }, /* @__PURE__ */ a.createElement(Ft, null)), E.image && /* @__PURE__ */ a.createElement("button", {
410
+ }, /* @__PURE__ */ l.createElement(It, null)), E.image && /* @__PURE__ */ l.createElement("button", {
411
411
  "data-command": "insertImage",
412
412
  title: "Image",
413
- onMouseDown: U,
413
+ onMouseDown: V,
414
414
  className: z.image ? "rte-active" : ""
415
- }, /* @__PURE__ */ a.createElement(At, null)), /* @__PURE__ */ a.createElement("input", {
415
+ }, /* @__PURE__ */ l.createElement(At, null)), /* @__PURE__ */ l.createElement("input", {
416
416
  type: "file",
417
417
  accept: "image/*",
418
418
  ref: A,
@@ -420,11 +420,11 @@ const Pt = [
420
420
  display: "none"
421
421
  },
422
422
  onChange: d
423
- }), E.emoji && /* @__PURE__ */ a.createElement("div", {
423
+ }), E.emoji && /* @__PURE__ */ l.createElement("div", {
424
424
  style: {
425
425
  position: "relative"
426
426
  }
427
- }, /* @__PURE__ */ a.createElement("button", {
427
+ }, /* @__PURE__ */ l.createElement("button", {
428
428
  title: "Emoji",
429
429
  onMouseDown: (h) => {
430
430
  h.preventDefault(), s();
@@ -436,13 +436,13 @@ const Pt = [
436
436
  }), B((j) => !j);
437
437
  },
438
438
  className: z.emoji ? "rte-active" : ""
439
- }, /* @__PURE__ */ a.createElement(Ot, null)), q && /* @__PURE__ */ vt(/* @__PURE__ */ a.createElement("div", {
439
+ }, /* @__PURE__ */ l.createElement(Ht, null)), q && /* @__PURE__ */ vt(/* @__PURE__ */ l.createElement("div", {
440
440
  className: "rte-emoji-popup",
441
441
  style: {
442
- top: F.y,
443
- left: F.x
442
+ top: I.y,
443
+ left: I.x
444
444
  }
445
- }, Pt.map((h, C) => /* @__PURE__ */ a.createElement("span", {
445
+ }, Pt.map((h, C) => /* @__PURE__ */ l.createElement("span", {
446
446
  key: C,
447
447
  style: {
448
448
  fontSize: "20px",
@@ -452,11 +452,11 @@ const Pt = [
452
452
  onMouseDown: (j) => {
453
453
  j.preventDefault(), w(h), B(!1);
454
454
  }
455
- }, h))), document.body)), E.color && /* @__PURE__ */ a.createElement("div", {
455
+ }, h))), document.body)), E.color && /* @__PURE__ */ l.createElement("div", {
456
456
  style: {
457
457
  position: "relative"
458
458
  }
459
- }, /* @__PURE__ */ a.createElement("button", {
459
+ }, /* @__PURE__ */ l.createElement("button", {
460
460
  title: "Text Color",
461
461
  onMouseDown: (h) => {
462
462
  var C;
@@ -470,7 +470,7 @@ const Pt = [
470
470
  fontSize: "18px"
471
471
  },
472
472
  className: z.color ? "rte-active" : ""
473
- }, /* @__PURE__ */ a.createElement(It, null)), /* @__PURE__ */ a.createElement("input", {
473
+ }, /* @__PURE__ */ l.createElement(Ft, null)), /* @__PURE__ */ l.createElement("input", {
474
474
  ref: P,
475
475
  type: "color",
476
476
  defaultValue: "#000000",
@@ -485,11 +485,11 @@ const Pt = [
485
485
  height: 0,
486
486
  pointerEvents: "none"
487
487
  }
488
- })), E.highlight && /* @__PURE__ */ a.createElement("div", {
488
+ })), E.highlight && /* @__PURE__ */ l.createElement("div", {
489
489
  style: {
490
490
  position: "relative"
491
491
  }
492
- }, /* @__PURE__ */ a.createElement("button", {
492
+ }, /* @__PURE__ */ l.createElement("button", {
493
493
  title: "Highlight",
494
494
  onMouseDown: (h) => {
495
495
  var C;
@@ -499,11 +499,11 @@ const Pt = [
499
499
  display: "flex",
500
500
  alignItems: "center",
501
501
  justifyContent: "center",
502
- color: ((O = T.current) == null ? void 0 : O.value) || "#000",
502
+ color: ((H = T.current) == null ? void 0 : H.value) || "#000",
503
503
  fontSize: "18px"
504
504
  },
505
505
  className: z.highlight ? "rte-active" : ""
506
- }, /* @__PURE__ */ a.createElement(Nt, null)), /* @__PURE__ */ a.createElement("input", {
506
+ }, /* @__PURE__ */ l.createElement(Nt, null)), /* @__PURE__ */ l.createElement("input", {
507
507
  ref: T,
508
508
  type: "color",
509
509
  onChange: (h) => {
@@ -518,55 +518,55 @@ const Pt = [
518
518
  height: 0,
519
519
  pointerEvents: "none"
520
520
  }
521
- })), E.align && /* @__PURE__ */ a.createElement(a.Fragment, null, /* @__PURE__ */ a.createElement("button", {
521
+ })), E.align && /* @__PURE__ */ l.createElement(l.Fragment, null, /* @__PURE__ */ l.createElement("button", {
522
522
  title: "Align Left",
523
523
  onMouseDown: (h) => h.preventDefault(),
524
524
  onClick: () => r("justifyLeft"),
525
525
  className: z.alignLeft ? "rte-active" : ""
526
- }, /* @__PURE__ */ a.createElement(zt, null)), /* @__PURE__ */ a.createElement("button", {
526
+ }, /* @__PURE__ */ l.createElement(zt, null)), /* @__PURE__ */ l.createElement("button", {
527
527
  title: "Align Center",
528
528
  onMouseDown: (h) => h.preventDefault(),
529
529
  onClick: () => r("justifyCenter"),
530
530
  className: z.alignCenter ? "rte-active" : ""
531
- }, /* @__PURE__ */ a.createElement(Lt, null)), /* @__PURE__ */ a.createElement("button", {
531
+ }, /* @__PURE__ */ l.createElement(Lt, null)), /* @__PURE__ */ l.createElement("button", {
532
532
  title: "Align Right",
533
533
  onMouseDown: (h) => h.preventDefault(),
534
534
  onClick: () => r("justifyRight"),
535
535
  className: z.alignRight ? "rte-active" : ""
536
- }, /* @__PURE__ */ a.createElement(St, null))), E.table && /* @__PURE__ */ a.createElement("button", {
536
+ }, /* @__PURE__ */ l.createElement(St, null))), E.table && /* @__PURE__ */ l.createElement("button", {
537
537
  title: "Insert Table",
538
538
  onMouseDown: (h) => h.preventDefault(),
539
539
  onClick: () => r("insertTable"),
540
540
  className: z.table ? "rte-active" : ""
541
- }, /* @__PURE__ */ a.createElement(_t, null)), E.fontFamily && /* @__PURE__ */ a.createElement("select", {
541
+ }, /* @__PURE__ */ l.createElement(_t, null)), E.fontFamily && /* @__PURE__ */ l.createElement("select", {
542
542
  className: "rte-dropdown",
543
543
  defaultValue: "",
544
544
  onMouseDown: () => s(),
545
- onChange: p
546
- }, /* @__PURE__ */ a.createElement("option", {
545
+ onChange: y
546
+ }, /* @__PURE__ */ l.createElement("option", {
547
547
  value: "",
548
548
  disabled: !0
549
- }, "Font Family"), /* @__PURE__ */ a.createElement("option", {
549
+ }, "Font Family"), /* @__PURE__ */ l.createElement("option", {
550
550
  value: "Arial"
551
- }, "Arial"), /* @__PURE__ */ a.createElement("option", {
551
+ }, "Arial"), /* @__PURE__ */ l.createElement("option", {
552
552
  value: "Georgia"
553
- }, "Georgia"), /* @__PURE__ */ a.createElement("option", {
553
+ }, "Georgia"), /* @__PURE__ */ l.createElement("option", {
554
554
  value: "Times New Roman"
555
- }, "Times New Roman"), /* @__PURE__ */ a.createElement("option", {
555
+ }, "Times New Roman"), /* @__PURE__ */ l.createElement("option", {
556
556
  value: "Courier New"
557
- }, "Courier New"), /* @__PURE__ */ a.createElement("option", {
557
+ }, "Courier New"), /* @__PURE__ */ l.createElement("option", {
558
558
  value: "Verdana"
559
- }, "Verdana")), E.fontSize && /* @__PURE__ */ a.createElement("select", {
559
+ }, "Verdana")), E.fontSize && /* @__PURE__ */ l.createElement("select", {
560
560
  className: "rte-dropdown rte-fontsize-dropdown",
561
561
  defaultValue: "",
562
562
  onMouseDown: () => s(),
563
563
  onChange: m
564
- }, /* @__PURE__ */ a.createElement("option", {
564
+ }, /* @__PURE__ */ l.createElement("option", {
565
565
  value: "",
566
566
  disabled: !0
567
567
  }, "Font Size"), Array.from({
568
568
  length: 16
569
- }, (h, C) => 10 + C).map((h) => /* @__PURE__ */ a.createElement("option", {
569
+ }, (h, C) => 10 + C).map((h) => /* @__PURE__ */ l.createElement("option", {
570
570
  key: h,
571
571
  value: h
572
572
  }, h, "px"))));
@@ -575,20 +575,20 @@ const Pt = [
575
575
  position: s,
576
576
  filtered: d,
577
577
  insertMention: m,
578
- onClose: p,
578
+ onClose: y,
579
579
  query: w
580
580
  }) => {
581
- const R = V(null), [M, E] = k(0);
582
- return I(() => {
581
+ const R = U(null), [M, E] = k(0);
582
+ return F(() => {
583
583
  r && E(0);
584
- }, [r]), I(() => {
584
+ }, [r]), F(() => {
585
585
  const x = (L) => {
586
- R.current && !R.current.contains(L.target) && p();
586
+ R.current && !R.current.contains(L.target) && y();
587
587
  };
588
588
  return r && document.addEventListener("mousedown", x), () => {
589
589
  document.removeEventListener("mousedown", x);
590
590
  };
591
- }, [r, p]), I(() => {
591
+ }, [r, y]), F(() => {
592
592
  if (!r) return;
593
593
  const x = (L) => {
594
594
  if (!(!r || d.length === 0) && (L.key === "ArrowDown" && (L.preventDefault(), E((A) => Math.min(A + 1, d.length - 1))), L.key === "ArrowUp" && (L.preventDefault(), E((A) => Math.max(A - 1, 0))), L.key === "Enter")) {
@@ -598,14 +598,14 @@ const Pt = [
598
598
  }
599
599
  };
600
600
  return window.addEventListener("keydown", x), () => window.removeEventListener("keydown", x);
601
- }, [r, d, M]), I(() => {
601
+ }, [r, d, M]), F(() => {
602
602
  if (!R.current) return;
603
603
  const L = R.current.querySelectorAll("li")[M];
604
604
  L && L.scrollIntoView({
605
605
  block: "nearest",
606
606
  behavior: "smooth"
607
607
  });
608
- }, [M]), r ? /* @__PURE__ */ a.createElement("ul", {
608
+ }, [M]), r ? /* @__PURE__ */ l.createElement("ul", {
609
609
  ref: R,
610
610
  className: "rte-popup",
611
611
  style: {
@@ -619,13 +619,13 @@ const Pt = [
619
619
  const P = x.toLowerCase(), T = w.toLowerCase(), q = P.indexOf(T);
620
620
  let B = x;
621
621
  if (q !== -1 && w.length > 0) {
622
- const F = q + w.length;
623
- B = x.substring(0, q) + `<span class="rte-highlight">${x.substring(q, F)}</span>` + x.substring(F);
622
+ const I = q + w.length;
623
+ B = x.substring(0, q) + `<span class="rte-highlight">${x.substring(q, I)}</span>` + x.substring(I);
624
624
  }
625
- return /* @__PURE__ */ a.createElement("li", {
625
+ return /* @__PURE__ */ l.createElement("li", {
626
626
  key: L,
627
- onMouseDown: (F) => {
628
- F.preventDefault(), m({
627
+ onMouseDown: (I) => {
628
+ I.preventDefault(), m({
629
629
  name: x,
630
630
  value: L
631
631
  });
@@ -641,7 +641,7 @@ const Pt = [
641
641
  },
642
642
  onMouseEnter: () => E(A)
643
643
  });
644
- }) : /* @__PURE__ */ a.createElement("li", {
644
+ }) : /* @__PURE__ */ l.createElement("li", {
645
645
  style: {
646
646
  padding: "6px 12px",
647
647
  color: "#999"
@@ -654,36 +654,36 @@ function ke(r) {
654
654
  function Q(r) {
655
655
  return N({ attr: { viewBox: "0 0 24 24" }, child: [{ tag: "g", attr: { id: "Circle_Plus" }, child: [{ tag: "g", attr: {}, child: [{ tag: "path", attr: { d: "M15,12.5H12.5V15a.5.5,0,0,1-1,0V12.5H9a.5.5,0,0,1,0-1h2.5V9a.5.5,0,0,1,1,0v2.5H15A.5.5,0,0,1,15,12.5Z" }, child: [] }, { tag: "path", attr: { d: "M12,21.932A9.934,9.934,0,1,1,21.932,12,9.944,9.944,0,0,1,12,21.932ZM12,3.065A8.934,8.934,0,1,0,20.932,12,8.944,8.944,0,0,0,12,3.065Z" }, child: [] }] }] }] })(r);
656
656
  }
657
- const Ut = ({
657
+ const Vt = ({
658
658
  visible: r,
659
659
  x: s,
660
660
  y: d,
661
661
  onAction: m,
662
- onClose: p
662
+ onClose: y
663
663
  }) => {
664
664
  if (!r) return null;
665
665
  const w = {
666
666
  top: d,
667
667
  left: s
668
668
  };
669
- return /* @__PURE__ */ a.createElement("div", {
669
+ return /* @__PURE__ */ l.createElement("div", {
670
670
  style: w,
671
671
  className: "rte-table-menu",
672
- onMouseLeave: p
673
- }, /* @__PURE__ */ a.createElement("button", {
672
+ onMouseLeave: y
673
+ }, /* @__PURE__ */ l.createElement("button", {
674
674
  onClick: () => m("insertRowAbove")
675
- }, /* @__PURE__ */ a.createElement(Q, null), " Insert row above"), /* @__PURE__ */ a.createElement("button", {
675
+ }, /* @__PURE__ */ l.createElement(Q, null), " Insert row above"), /* @__PURE__ */ l.createElement("button", {
676
676
  onClick: () => m("insertRowBelow")
677
- }, /* @__PURE__ */ a.createElement(Q, null), " Insert row below"), /* @__PURE__ */ a.createElement("button", {
677
+ }, /* @__PURE__ */ l.createElement(Q, null), " Insert row below"), /* @__PURE__ */ l.createElement("button", {
678
678
  onClick: () => m("insertColLeft")
679
- }, /* @__PURE__ */ a.createElement(Q, null), " Insert col left"), /* @__PURE__ */ a.createElement("button", {
679
+ }, /* @__PURE__ */ l.createElement(Q, null), " Insert col left"), /* @__PURE__ */ l.createElement("button", {
680
680
  onClick: () => m("insertColRight")
681
- }, /* @__PURE__ */ a.createElement(Q, null), " Insert col right"), /* @__PURE__ */ a.createElement("button", {
681
+ }, /* @__PURE__ */ l.createElement(Q, null), " Insert col right"), /* @__PURE__ */ l.createElement("button", {
682
682
  onClick: () => m("deleteRow")
683
- }, /* @__PURE__ */ a.createElement(ke, null), " Delete row"), /* @__PURE__ */ a.createElement("button", {
683
+ }, /* @__PURE__ */ l.createElement(ke, null), " Delete row"), /* @__PURE__ */ l.createElement("button", {
684
684
  onClick: () => m("deleteCol")
685
- }, /* @__PURE__ */ a.createElement(ke, null), " Delete column"));
686
- }, Vt = ({
685
+ }, /* @__PURE__ */ l.createElement(ke, null), " Delete column"));
686
+ }, Ut = ({
687
687
  html: r,
688
688
  className: s,
689
689
  style: d
@@ -695,16 +695,16 @@ const Ut = ({
695
695
  const M = R.href;
696
696
  M && window.open(M, "_blank", "noopener,noreferrer");
697
697
  }
698
- }, p = (w) => {
698
+ }, y = (w) => {
699
699
  let R = w.replace(/{{\s*(.*?)\s*}}/g, (M, E) => `<span style="color: blue">${E}</span>`);
700
700
  return R = R.replace(/#arrayData/g, ""), R = R.replace(/\/arrayData/g, ""), R;
701
701
  };
702
- return /* @__PURE__ */ a.createElement("div", {
702
+ return /* @__PURE__ */ l.createElement("div", {
703
703
  className: `rte-preview ${s || ""}`,
704
704
  style: d,
705
705
  onClick: m,
706
706
  dangerouslySetInnerHTML: {
707
- __html: p(r)
707
+ __html: y(r)
708
708
  }
709
709
  });
710
710
  }, $t = ({
@@ -713,57 +713,57 @@ const Ut = ({
713
713
  onClose: d,
714
714
  onInsert: m
715
715
  }) => {
716
- const [p, w] = k(""), [R, M] = k(""), [E, x] = k(""), [L, A] = k("_self");
717
- if (I(() => {
716
+ const [y, w] = k(""), [R, M] = k(""), [E, x] = k(""), [L, A] = k("_self");
717
+ if (F(() => {
718
718
  r ? (w(s.url || ""), M(s.text || ""), x(s.title || ""), A(s.target || "_self")) : (w(""), M(""), x(""), A("_self"));
719
719
  }, [r, s]), !r) return null;
720
720
  const P = () => {
721
721
  m({
722
- url: p,
722
+ url: y,
723
723
  text: R,
724
724
  title: E,
725
725
  target: L
726
726
  });
727
727
  };
728
- return /* @__PURE__ */ a.createElement(a.Fragment, null, /* @__PURE__ */ a.createElement("div", {
728
+ return /* @__PURE__ */ l.createElement(l.Fragment, null, /* @__PURE__ */ l.createElement("div", {
729
729
  className: "rte-link-modal-overlay",
730
730
  onClick: d
731
- }), /* @__PURE__ */ a.createElement("div", {
731
+ }), /* @__PURE__ */ l.createElement("div", {
732
732
  className: "rte-link-modal"
733
- }, /* @__PURE__ */ a.createElement("h4", {
733
+ }, /* @__PURE__ */ l.createElement("h4", {
734
734
  className: "rte-link-modal__title"
735
- }, p ? "Edit Link" : "Insert Link"), /* @__PURE__ */ a.createElement("input", {
735
+ }, y ? "Edit Link" : "Insert Link"), /* @__PURE__ */ l.createElement("input", {
736
736
  type: "text",
737
737
  className: "rte-link-modal__input",
738
738
  placeholder: "URL",
739
- value: p,
739
+ value: y,
740
740
  onChange: (T) => w(T.target.value)
741
- }), /* @__PURE__ */ a.createElement("input", {
741
+ }), /* @__PURE__ */ l.createElement("input", {
742
742
  type: "text",
743
743
  className: "rte-link-modal__input",
744
744
  placeholder: "Text to Display",
745
745
  value: R,
746
746
  onChange: (T) => M(T.target.value)
747
- }), /* @__PURE__ */ a.createElement("input", {
747
+ }), /* @__PURE__ */ l.createElement("input", {
748
748
  type: "text",
749
749
  className: "rte-link-modal__input",
750
750
  placeholder: "Title",
751
751
  value: E,
752
752
  onChange: (T) => x(T.target.value)
753
- }), /* @__PURE__ */ a.createElement("select", {
753
+ }), /* @__PURE__ */ l.createElement("select", {
754
754
  className: "rte-link-modal__select",
755
755
  value: L,
756
756
  onChange: (T) => A(T.target.value)
757
- }, /* @__PURE__ */ a.createElement("option", {
757
+ }, /* @__PURE__ */ l.createElement("option", {
758
758
  value: "_self"
759
- }, "Same tab"), /* @__PURE__ */ a.createElement("option", {
759
+ }, "Same tab"), /* @__PURE__ */ l.createElement("option", {
760
760
  value: "_blank"
761
- }, "New tab")), /* @__PURE__ */ a.createElement("div", {
761
+ }, "New tab")), /* @__PURE__ */ l.createElement("div", {
762
762
  className: "rte-link-modal__actions"
763
- }, /* @__PURE__ */ a.createElement("button", {
763
+ }, /* @__PURE__ */ l.createElement("button", {
764
764
  className: "rte-link-modal__btn",
765
765
  onClick: d
766
- }, "Cancel"), /* @__PURE__ */ a.createElement("button", {
766
+ }, "Cancel"), /* @__PURE__ */ l.createElement("button", {
767
767
  className: "rte-link-modal__btn rte-link-modal__btn--ok",
768
768
  onClick: P
769
769
  }, "OK"))));
@@ -791,7 +791,7 @@ const Yt = ({
791
791
  fontSize: !1,
792
792
  highlight: !1
793
793
  },
794
- classNames: p = {},
794
+ classNames: y = {},
795
795
  styles: w = {},
796
796
  handleGetHtml: R = () => {
797
797
  },
@@ -804,19 +804,19 @@ const Yt = ({
804
804
  }
805
805
  }) => {
806
806
  var ve, ye, Ee, we, Ce, be, Re, xe;
807
- const A = V(null), [P, T] = k(E != null && E.length ? E : " "), [q, B] = k(""), [F, _] = k(!1), [U, Y] = k({
807
+ const A = U(null), [P, T] = k(E != null && E.length ? E : " "), [q, B] = k(""), [I, _] = k(!1), [V, Y] = k({
808
808
  x: 0,
809
809
  y: 0
810
- }), [ee, z] = k([]), D = V(null), $ = V(null), [O, h] = k({
810
+ }), [ee, z] = k([]), D = U(null), $ = U(null), [H, h] = k({
811
811
  visible: !1,
812
812
  x: 0,
813
813
  y: 0
814
- }), [C, j] = k(!1), Z = V(null), [He, se] = k({
814
+ }), [C, j] = k(!1), Z = U(null), [Oe, se] = k({
815
815
  url: "",
816
816
  text: "",
817
817
  title: "",
818
818
  target: "_self"
819
- }), Oe = {
819
+ }), He = {
820
820
  bold: !0,
821
821
  italic: !0,
822
822
  underline: !0,
@@ -832,23 +832,25 @@ const Yt = ({
832
832
  fontFamily: (be = m.fontFamily) != null ? be : !1,
833
833
  fontSize: (Re = m.fontSize) != null ? Re : !1,
834
834
  highlight: (xe = m.fontSize) != null ? xe : !1
835
- }, [_e, te] = k(""), [de, ne] = k([]), H = () => A.current, S = () => {
835
+ }, [_e, te] = k(""), [de, ne] = k([]), O = () => A.current, S = () => {
836
836
  const e = je(), t = /^<div[^>]*style=["'][^"']*font-size\s*:\s*\d+px[^"']*["'][^>]*>/.test(e.trim());
837
837
  let n = e;
838
- t || (n = `<div style="font-size:12px">${e}</div>`), n = n.replace(/<(ul|ol)([^>]*)>/g, (c, v, y) => /data-hidden-array-start/.test(c) ? c : `<${v}${y}>
839
- <span data-hidden-array-start="true" style="display:none">{{#arrayData}}</span>`), n = n.replace(/<\/(ul|ol)>/g, (c, v) => /data-hidden-array-end/.test(c) ? c : `<span data-hidden-array-end="true" style="display:none">{{/arrayData}}</span></${v}>`), B(n), R == null || R(n);
840
- const o = ot(e);
841
- M(o);
842
- const i = $e(), l = Ne(i);
843
- JSON.stringify(l) !== JSON.stringify(de) && (ne(l), x(l));
838
+ t || (n = `<div style="font-size:12px">${e}</div>`), n = n.replace(/<(ul|ol)([^>]*)>/g, (c, p, v) => /data-hidden-array-start/.test(c) ? c : `<${p}${v}>
839
+ <span data-hidden-array-start="true" style="display:none">{{#arrayData}}</span>`), n = n.replace(/<\/(ul|ol)>/g, (c, p) => /data-hidden-array-end/.test(c) ? c : `<span data-hidden-array-end="true" style="display:none">{{/arrayData}}</span></${p}>`), B(n), R == null || R(n);
840
+ const a = at(e);
841
+ M(a);
842
+ const i = $e(), o = Ne(i);
843
+ JSON.stringify(o) !== JSON.stringify(de) && (ne(o), x(o));
844
844
  }, je = () => {
845
- const e = H();
845
+ const e = O();
846
846
  if (!e) return P;
847
847
  const t = e.cloneNode(!0);
848
- t.querySelectorAll("table div").forEach((o) => o.remove()), t.querySelectorAll(".rte-cell-highlight").forEach((o) => o.classList.remove("rte-cell-highlight"));
848
+ t.querySelectorAll("table div").forEach((a) => a.remove()), t.querySelectorAll("table").forEach((a) => {
849
+ a.removeAttribute("data-has-resize-handle");
850
+ }), t.querySelectorAll(".rte-cell-highlight").forEach((a) => a.classList.remove("rte-cell-highlight"));
849
851
  let n = t.innerHTML;
850
- return n = Ie(n), n;
851
- }, Ie = (e) => e.replace(/<tbody[^>]*>/g, "<tbody>{{#arrayData}}").replace(/<\/tbody>/g, "{{/arrayData}}</tbody>"), W = () => {
852
+ return n = Fe(n), n;
853
+ }, Fe = (e) => e.replace(/<tbody[^>]*>/g, "<tbody>{{#arrayData}}").replace(/<\/tbody>/g, "{{/arrayData}}</tbody>"), W = () => {
852
854
  const e = window.getSelection();
853
855
  if (!e || e.rangeCount === 0) return;
854
856
  const t = document.getElementById("rte-editor-body");
@@ -862,24 +864,24 @@ const Yt = ({
862
864
  const n = window.getSelection();
863
865
  n && n.rangeCount > 0 && (D.current = n.getRangeAt(0)), K(), document.execCommand(e, !1, t), S();
864
866
  };
865
- I(() => {
866
- const e = H();
867
+ F(() => {
868
+ const e = O();
867
869
  if (!e || !E) return;
868
- const t = Fe(E);
870
+ const t = Ie(E);
869
871
  e.innerHTML = t, S();
870
872
  }, []);
871
- const Fe = (e) => e.replace(/<span[^>]*data-hidden-table-start[^>]*>.*?<\/span>/g, "").replace(/<span[^>]*data-hidden-table-end[^>]*>.*?<\/span>/g, "").replace(/{{#arrayData}}/g, "").replace(/{{\/arrayData}}/g, "");
872
- I(() => () => {
873
+ const Ie = (e) => e.replace(/<span[^>]*data-hidden-table-start[^>]*>.*?<\/span>/g, "").replace(/<span[^>]*data-hidden-table-end[^>]*>.*?<\/span>/g, "").replace(/{{#arrayData}}/g, "").replace(/{{\/arrayData}}/g, "");
874
+ F(() => () => {
873
875
  document.removeEventListener("mousemove", null), document.removeEventListener("mouseup", null);
874
- }, []), I(() => {
876
+ }, []), F(() => {
875
877
  L && L((e) => {
876
- Ve(e);
878
+ Ue(e);
877
879
  });
878
- }, []), I(() => {
879
- const e = H();
880
+ }, []), F(() => {
881
+ const e = O();
880
882
  if (!e) return;
881
883
  e.querySelectorAll("table").forEach((n) => {
882
- n.dataset.hasResizeHandle !== "true" && (ae(n), n.querySelectorAll("th, td").forEach((i) => X(i)));
884
+ n.hasAttribute("data-has-resize-handle") || (oe(n), n.querySelectorAll("th, td").forEach((i) => X(i)));
883
885
  });
884
886
  }, []);
885
887
  const me = (e) => {
@@ -887,22 +889,22 @@ const Yt = ({
887
889
  e = e.parentNode;
888
890
  return e;
889
891
  }, ge = (e) => {
890
- var v;
892
+ var p;
891
893
  const t = window.getSelection();
892
894
  if (!(t != null && t.rangeCount)) return;
893
- const n = t.getRangeAt(0), o = me(n.startContainer);
894
- let i, l;
895
- if (o) {
896
- let y = o.querySelector(e);
897
- y || (y = document.createElement(e), y.style.margin = "0", y.style.paddingLeft = "20px", o.appendChild(y)), l = y, i = document.createElement("li"), i.textContent = "​", l.appendChild(i);
895
+ const n = t.getRangeAt(0), a = me(n.startContainer);
896
+ let i, o;
897
+ if (a) {
898
+ let v = a.querySelector(e);
899
+ v || (v = document.createElement(e), v.style.margin = "0", v.style.paddingLeft = "20px", a.appendChild(v)), o = v, i = document.createElement("li"), i.textContent = "​", o.appendChild(i);
898
900
  } else {
899
901
  document.execCommand(e === "ul" ? "insertUnorderedList" : "insertOrderedList");
900
- const y = H();
901
- if (l = y == null ? void 0 : y.querySelector(`${e}:last-child`), !l) return;
902
- i = l.querySelector("li:last-child");
902
+ const v = O();
903
+ if (o = v == null ? void 0 : v.querySelector(`${e}:last-child`), !o) return;
904
+ i = o.querySelector("li:last-child");
903
905
  }
904
906
  const c = document.createRange();
905
- c.setStart(i, 0), c.collapse(!0), t.removeAllRanges(), t.addRange(c), (v = H()) == null || v.focus(), S();
907
+ c.setStart(i, 0), c.collapse(!0), t.removeAllRanges(), t.addRange(c), (p = O()) == null || p.focus(), S();
906
908
  }, re = (e, t) => {
907
909
  e === "insertOrderedList" ? ge("ol") : e === "insertUnorderedList" ? ge("ul") : e.startsWith("justify") ? lt(e) : ue(e, t), e === "insertTable" && Ze();
908
910
  }, Pe = (e) => {
@@ -919,117 +921,130 @@ const Yt = ({
919
921
  const t = e.anchorNode;
920
922
  let n = e.anchorOffset;
921
923
  if (!t) return null;
922
- let o = t;
923
- for (o.nodeType !== Node.TEXT_NODE && (o.childNodes && o.childNodes[n] ? o = o.childNodes[n] : o = t.previousSibling); o; ) {
924
- if (o.nodeType === Node.TEXT_NODE) {
925
- const i = o.textContent || "", l = o === t ? n : i.length, c = i.lastIndexOf("@", l - 1);
924
+ let a = t;
925
+ for (a.nodeType !== Node.TEXT_NODE && (a.childNodes && a.childNodes[n] ? a = a.childNodes[n] : a = t.previousSibling); a; ) {
926
+ if (a.nodeType === Node.TEXT_NODE) {
927
+ const i = a.textContent || "", o = a === t ? n : i.length, c = i.lastIndexOf("@", o - 1);
926
928
  if (c !== -1) {
927
- const v = document.createRange();
928
- return v.setStart(o, c), v.setEnd(o, l), v;
929
+ const p = document.createRange();
930
+ return p.setStart(a, c), p.setEnd(a, o), p;
929
931
  }
930
932
  }
931
- o = o.previousSibling;
933
+ a = a.previousSibling;
932
934
  }
933
935
  return null;
934
936
  }, Be = (e) => {
935
- var l;
937
+ var o;
936
938
  const t = window.getSelection();
937
939
  if (!t) return;
938
940
  const n = qe();
939
941
  n ? (t.removeAllRanges(), t.addRange(n)) : $.current && (t.removeAllRanges(), t.addRange($.current));
940
- const o = document.createElement("span");
941
- o.textContent = `{{${e.name}}}`, o.style.display = "inline", o.setAttribute("data-mention", e.value || e.name || "");
942
+ const a = document.createElement("span");
943
+ a.textContent = `{{${e.name}}}`, a.style.display = "inline", a.setAttribute("data-mention", e.value || e.name || "");
942
944
  try {
943
945
  const c = t.rangeCount ? t.getRangeAt(0) : null;
944
946
  if (c)
945
- c.deleteContents(), c.insertNode(o);
947
+ c.deleteContents(), c.insertNode(a);
946
948
  else {
947
- const f = document.createRange(), u = H();
948
- f.selectNodeContents(u), f.collapse(!1), f.insertNode(o);
949
+ const g = document.createRange(), u = O();
950
+ g.selectNodeContents(u), g.collapse(!1), g.insertNode(a);
949
951
  }
950
- const v = document.createTextNode(" ");
951
- o.after(v);
952
- const y = document.createRange();
953
- y.setStartAfter(v), y.collapse(!0), t.removeAllRanges(), t.addRange(y);
952
+ const p = document.createTextNode(" ");
953
+ a.after(p);
954
+ const v = document.createRange();
955
+ v.setStartAfter(p), v.collapse(!0), t.removeAllRanges(), t.addRange(v);
954
956
  } catch (c) {
955
957
  console.error("insertMention error:", c);
956
958
  }
957
959
  let i = Ne([...de, e]);
958
- ne(i), x(i), _(!1), (l = H()) == null || l.focus(), S();
959
- }, Ue = (e) => {
960
- const t = H();
960
+ ne(i), x(i), _(!1), (o = O()) == null || o.focus(), S();
961
+ }, Ve = (e) => {
962
+ const t = O();
961
963
  if (!t) return;
962
964
  let n = null;
963
965
  D.current && t.contains(D.current.startContainer) ? n = D.current.cloneRange() : (n = document.createRange(), n.selectNodeContents(t), n.collapse(!1));
964
- const o = window.getSelection();
965
- if (!o) return;
966
- o.removeAllRanges(), o.addRange(n);
966
+ const a = window.getSelection();
967
+ if (!a) return;
968
+ a.removeAllRanges(), a.addRange(n);
967
969
  const i = document.createElement("span");
968
970
  i.textContent = `{{${e.name}}}`, i.style.display = "inline", i.setAttribute("data-mention", e.value || e.name), n.insertNode(i);
969
- const l = document.createTextNode(" ");
970
- i.after(l);
971
+ const o = document.createTextNode(" ");
972
+ i.after(o);
971
973
  const c = document.createRange();
972
- c.setStartAfter(l), c.collapse(!0), o.removeAllRanges(), o.addRange(c), D.current = c.cloneRange(), t.focus();
973
- }, Ve = (e) => {
974
- e.forEach((t) => Ue(t)), ne((t) => {
975
- const n = [...t, ...e], o = Array.from(new Map(n.map((i) => [i.name, i])).values());
976
- return x(o), o;
974
+ c.setStartAfter(o), c.collapse(!0), a.removeAllRanges(), a.addRange(c), D.current = c.cloneRange(), t.focus();
975
+ }, Ue = (e) => {
976
+ e.forEach((t) => Ve(t)), ne((t) => {
977
+ const n = [...t, ...e], a = Array.from(new Map(n.map((i) => [i.name, i])).values());
978
+ return x(a), a;
977
979
  }), S();
978
980
  }, $e = () => {
979
- const e = H();
981
+ const e = O();
980
982
  if (!e) return [];
981
983
  const t = e.querySelectorAll("span[data-mention]"), n = [];
982
- return t.forEach((o) => {
983
- const i = o.getAttribute("data-mention") || "", c = (o.textContent || "").match(/{{(.+?)}}/);
984
+ return t.forEach((a) => {
985
+ const i = a.getAttribute("data-mention") || "", c = (a.textContent || "").match(/{{(.+?)}}/);
984
986
  c && n.push({
985
987
  name: c[1],
986
988
  value: i
987
989
  });
988
990
  }), n;
989
991
  }, We = (e) => {
990
- var n, o, i;
992
+ var n, a, i;
991
993
  const t = e.key.toLowerCase();
992
994
  if ((e.ctrlKey || e.metaKey) && ["b", "i", "u"].includes(t) && (e.preventDefault(), re(t === "b" ? "bold" : t === "i" ? "italic" : t === "u" ? "underline" : "")), e.shiftKey && e.key === "2" && e.preventDefault(), e.key === "Enter") {
993
- const l = window.getSelection(), c = l != null && l.anchorNode ? me(l.anchorNode) : null;
995
+ const o = window.getSelection(), c = o != null && o.anchorNode ? me(o.anchorNode) : null;
994
996
  if (!c) return;
995
997
  if (((n = c.textContent) == null ? void 0 : n.replace(/\u200B/g, "").trim()) === "") {
996
998
  e.preventDefault();
997
- const y = c.parentElement, f = y == null ? void 0 : y.closest("li");
998
- if (f) {
999
- y == null || y.removeChild(c);
999
+ const v = c.parentElement, g = v == null ? void 0 : v.closest("li");
1000
+ if (g) {
1001
+ v == null || v.removeChild(c);
1000
1002
  const u = document.createElement("p");
1001
- u.innerHTML = "<br />", (o = f.parentElement) == null || o.insertBefore(u, f.nextSibling);
1002
- const g = document.createRange();
1003
- g.setStart(u, 0), g.collapse(!0), l == null || l.removeAllRanges(), l == null || l.addRange(g);
1003
+ u.innerHTML = "<br />", (a = g.parentElement) == null || a.insertBefore(u, g.nextSibling);
1004
+ const f = document.createRange();
1005
+ f.setStart(u, 0), f.collapse(!0), o == null || o.removeAllRanges(), o == null || o.addRange(f);
1004
1006
  } else {
1005
1007
  const u = c.closest("ul, ol");
1006
1008
  if (u) {
1007
- const g = document.createElement("p");
1008
- g.innerHTML = "<br />", (i = u.parentElement) == null || i.insertBefore(g, u.nextSibling), u.removeChild(c);
1009
+ const f = document.createElement("p");
1010
+ f.innerHTML = "<br />", (i = u.parentElement) == null || i.insertBefore(f, u.nextSibling), u.removeChild(c);
1009
1011
  const b = document.createRange();
1010
- b.setStart(g, 0), b.collapse(!0), l == null || l.removeAllRanges(), l == null || l.addRange(b);
1012
+ b.setStart(f, 0), b.collapse(!0), o == null || o.removeAllRanges(), o == null || o.addRange(b);
1011
1013
  }
1012
1014
  }
1013
1015
  S();
1014
1016
  }
1015
1017
  }
1018
+ if (t === "backspace" || t === "delete") {
1019
+ const o = window.getSelection();
1020
+ if (!o || o.rangeCount === 0) return;
1021
+ const c = o.getRangeAt(0);
1022
+ if (c.cloneContents().querySelector("table")) {
1023
+ console.log("Deleting full table...");
1024
+ return;
1025
+ }
1026
+ if (c.cloneContents().querySelectorAll(".rte-resize-handle").length > 0) {
1027
+ e.preventDefault(), e.stopPropagation();
1028
+ return;
1029
+ }
1030
+ }
1016
1031
  }, Ke = (e) => {
1017
1032
  if (e.data === "@") {
1018
1033
  const n = window.getSelection();
1019
1034
  if (!(n != null && n.rangeCount)) return;
1020
- const o = n.anchorNode;
1021
- if (oe(o))
1035
+ const a = n.anchorNode;
1036
+ if (ae(a))
1022
1037
  return;
1023
1038
  setTimeout(() => {
1024
1039
  Pe(n.getRangeAt(0)), te(""), z(r), _(!0);
1025
1040
  }, 0);
1026
1041
  return;
1027
1042
  }
1028
- if (F) {
1043
+ if (I) {
1029
1044
  setTimeout(() => fe(), 0);
1030
1045
  return;
1031
1046
  }
1032
- }, oe = (e) => {
1047
+ }, ae = (e) => {
1033
1048
  if (!e) return !1;
1034
1049
  let t = e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement;
1035
1050
  for (; t; ) {
@@ -1041,7 +1056,7 @@ const Yt = ({
1041
1056
  S();
1042
1057
  const e = window.getSelection();
1043
1058
  if (!e || !e.anchorNode) return;
1044
- if (oe(e.anchorNode)) {
1059
+ if (ae(e.anchorNode)) {
1045
1060
  _(!1);
1046
1061
  return;
1047
1062
  }
@@ -1052,74 +1067,74 @@ const Yt = ({
1052
1067
  _(!1);
1053
1068
  return;
1054
1069
  }
1055
- const o = n[1].trim().toLowerCase();
1056
- te(o);
1057
- const i = r.filter((l) => l.name.toLowerCase().includes(o));
1070
+ const a = n[1].trim().toLowerCase();
1071
+ te(a);
1072
+ const i = r.filter((o) => o.name.toLowerCase().includes(a));
1058
1073
  i.length > 0 ? (z(i), _(!0)) : _(!1);
1059
1074
  }, Xe = (e) => {
1060
- var o;
1061
- const t = (o = e.target.files) == null ? void 0 : o[0];
1075
+ var a;
1076
+ const t = (a = e.target.files) == null ? void 0 : a[0];
1062
1077
  if (!t) return;
1063
1078
  const n = new FileReader();
1064
1079
  n.onload = (i) => {
1065
1080
  var b;
1066
- const l = (b = i.target) == null ? void 0 : b.result;
1081
+ const o = (b = i.target) == null ? void 0 : b.result;
1067
1082
  K();
1068
1083
  const c = window.getSelection();
1069
- let v = c && c.rangeCount ? c.getRangeAt(0) : null;
1070
- const y = document.createElement("img");
1071
- y.src = l, y.alt = t.name || "image", y.className = "rte-inserted-image", y.contentEditable = "true";
1072
- const f = H();
1073
- if (!v || !f) {
1074
- f == null || f.appendChild(y);
1084
+ let p = c && c.rangeCount ? c.getRangeAt(0) : null;
1085
+ const v = document.createElement("img");
1086
+ v.src = o, v.alt = t.name || "image", v.className = "rte-inserted-image", v.contentEditable = "true";
1087
+ const g = O();
1088
+ if (!p || !g) {
1089
+ g == null || g.appendChild(v);
1075
1090
  const Le = document.createTextNode(" ");
1076
- f == null || f.appendChild(Le);
1091
+ g == null || g.appendChild(Le);
1077
1092
  const le = document.createRange();
1078
- le.setStartAfter(Le), le.collapse(!0), c == null || c.removeAllRanges(), c == null || c.addRange(le), f == null || f.focus(), S(), e.target.value = "";
1093
+ le.setStartAfter(Le), le.collapse(!0), c == null || c.removeAllRanges(), c == null || c.addRange(le), g == null || g.focus(), S(), e.target.value = "";
1079
1094
  return;
1080
1095
  }
1081
- v.deleteContents(), v.insertNode(y);
1096
+ p.deleteContents(), p.insertNode(v);
1082
1097
  const u = document.createTextNode(" ");
1083
- y.after(u);
1084
- const g = document.createRange();
1085
- g.setStartAfter(u), g.collapse(!0), c.removeAllRanges(), c.addRange(g), f.focus(), S(), e.target.value = "";
1098
+ v.after(u);
1099
+ const f = document.createRange();
1100
+ f.setStartAfter(u), f.collapse(!0), c.removeAllRanges(), c.addRange(f), g.focus(), S(), e.target.value = "";
1086
1101
  }, n.readAsDataURL(t);
1087
1102
  }, Ye = (e) => {
1088
1103
  var i;
1089
1104
  K();
1090
1105
  const t = window.getSelection();
1091
1106
  if (!(t != null && t.rangeCount)) return;
1092
- const n = t.getRangeAt(0), o = document.createTextNode(e);
1093
- n.insertNode(o), n.setStartAfter(o), n.collapse(!0), t.removeAllRanges(), t.addRange(n), (i = H()) == null || i.focus(), S();
1107
+ const n = t.getRangeAt(0), a = document.createTextNode(e);
1108
+ n.insertNode(a), n.setStartAfter(a), n.collapse(!0), t.removeAllRanges(), t.addRange(n), (i = O()) == null || i.focus(), S();
1094
1109
  }, Ze = () => {
1095
- var f;
1110
+ var g;
1096
1111
  dt(), K();
1097
1112
  const e = document.createElement("table");
1098
- e.style.borderCollapse = "collapse", e.style.width = "100%", e.style.border = "1px solid #ccc", e.style.margin = "8px 0", e.style.position = "relative", e.style.textAlign = "center", p.table && e.classList.add(p.table);
1113
+ e.style.borderCollapse = "collapse", e.style.width = "100%", e.style.border = "1px solid #ccc", e.style.margin = "8px 0", e.style.position = "relative", e.style.textAlign = "center", y.table && e.classList.add(y.table);
1099
1114
  const t = document.createElement("thead");
1100
- p.thead && t.classList.add(p.thead);
1115
+ y.thead && t.classList.add(y.thead);
1101
1116
  const n = document.createElement("tbody");
1102
- p.tbody && n.classList.add(p.tbody);
1103
- const o = document.createElement("tr");
1104
- p.tr && o.classList.add(p.tr);
1117
+ y.tbody && n.classList.add(y.tbody);
1118
+ const a = document.createElement("tr");
1119
+ y.tr && a.classList.add(y.tr);
1105
1120
  const i = document.createElement("tr");
1106
- p.tr && i.classList.add(p.tr);
1121
+ y.tr && i.classList.add(y.tr);
1107
1122
  for (let u = 0; u < 2; u++) {
1108
- const g = document.createElement("th");
1109
- g.textContent = "", g.style.border = "1px solid #999", g.style.padding = "4px", g.style.position = "relative", g.style.backgroundColor = "lightgray", g.style.height = "20px", p.th && g.classList.add(p.th);
1123
+ const f = document.createElement("th");
1124
+ f.textContent = "", f.style.border = "1px solid #999", f.style.padding = "4px", f.style.position = "relative", f.style.backgroundColor = "lightgray", f.style.height = "20px", y.th && f.classList.add(y.th);
1110
1125
  const b = document.createElement("td");
1111
- b.textContent = "", b.style.border = "1px solid #999", b.style.padding = "4px", b.style.position = "relative", b.style.backgroundColor = "#fff", b.style.height = "20px", p.td && b.classList.add(p.td), X(g), X(b), o.appendChild(g), i.appendChild(b);
1126
+ b.textContent = "", b.style.border = "1px solid #999", b.style.padding = "4px", b.style.position = "relative", b.style.backgroundColor = "#fff", b.style.height = "20px", y.td && b.classList.add(y.td), X(f), X(b), a.appendChild(f), i.appendChild(b);
1112
1127
  }
1113
- t.appendChild(o), n.appendChild(i), e.appendChild(t), e.appendChild(n), ae(e);
1114
- const l = window.getSelection();
1115
- if (!(l != null && l.rangeCount)) return;
1116
- const c = l.getRangeAt(0);
1128
+ t.appendChild(a), n.appendChild(i), e.appendChild(t), e.appendChild(n), oe(e);
1129
+ const o = window.getSelection();
1130
+ if (!(o != null && o.rangeCount)) return;
1131
+ const c = o.getRangeAt(0);
1117
1132
  c.collapse(!1), c.insertNode(e);
1118
- const v = document.createElement("p");
1119
- v.innerHTML = "<br/>", e.after(v);
1120
- const y = document.createRange();
1121
- y.setStart(v, 0), y.collapse(!0), l.removeAllRanges(), l.addRange(y), (f = H()) == null || f.focus(), S();
1122
- }, ae = (e) => {
1133
+ const p = document.createElement("p");
1134
+ p.innerHTML = "<br/>", e.after(p);
1135
+ const v = document.createRange();
1136
+ v.setStart(p, 0), v.collapse(!0), o.removeAllRanges(), o.addRange(v), (g = O()) == null || g.focus(), S();
1137
+ }, oe = (e) => {
1123
1138
  if (e.dataset.hasResizeHandle === "true") return;
1124
1139
  const t = document.createElement("div");
1125
1140
  Object.assign(t.style, {
@@ -1132,19 +1147,19 @@ const Yt = ({
1132
1147
  cursor: "nwse-resize",
1133
1148
  zIndex: "20",
1134
1149
  borderRadius: "2px"
1135
- }), t.style.userSelect = "none", t.contentEditable = "false", t.dataset.hasResizeHandle = "true";
1136
- let n = 0, o = 0, i = 0, l = 0;
1150
+ }), t.contentEditable = "false", t.dataset.hasResizeHandle = "true", t.classList.add("rte-resize-handle");
1151
+ let n = 0, a = 0, i = 0, o = 0;
1137
1152
  t.addEventListener("mousedown", (c) => {
1138
- c.preventDefault(), n = c.clientX, o = c.clientY;
1139
- const v = e.getBoundingClientRect();
1140
- i = v.width, l = v.height;
1141
- const y = (u) => {
1142
- const g = Math.max(100, i + (u.clientX - n)), b = Math.max(20, l + (u.clientY - o));
1143
- e.style.width = `${g}px`, e.style.height = `${b}px`, S();
1144
- }, f = () => {
1145
- document.removeEventListener("mousemove", y), document.removeEventListener("mouseup", f), S();
1153
+ c.preventDefault(), n = c.clientX, a = c.clientY;
1154
+ const p = e.getBoundingClientRect();
1155
+ i = p.width, o = p.height;
1156
+ const v = (u) => {
1157
+ const f = Math.max(100, i + (u.clientX - n)), b = Math.max(20, o + (u.clientY - a));
1158
+ e.style.width = `${f}px`, e.style.height = `${b}px`, S();
1159
+ }, g = () => {
1160
+ document.removeEventListener("mousemove", v), document.removeEventListener("mouseup", g), S();
1146
1161
  };
1147
- document.addEventListener("mousemove", y), document.addEventListener("mouseup", f);
1162
+ document.addEventListener("mousemove", v), document.addEventListener("mouseup", g);
1148
1163
  }), e.appendChild(t);
1149
1164
  }, X = (e) => {
1150
1165
  const t = document.createElement("div"), n = document.createElement("div");
@@ -1157,12 +1172,10 @@ const Yt = ({
1157
1172
  cursor: "col-resize",
1158
1173
  background: "rgba(0,0,0,0.15)",
1159
1174
  zIndex: "10",
1160
- userSelect: "none",
1161
- WebkitUserSelect: "none",
1162
1175
  MozUserSelect: "none",
1163
1176
  msUserSelect: "none",
1164
1177
  pointerEvents: "auto"
1165
- }), t.contentEditable = "false", Object.assign(n.style, {
1178
+ }), t.contentEditable = "false", t.classList.add("rte-resize-handle"), Object.assign(n.style, {
1166
1179
  position: "absolute",
1167
1180
  bottom: "0",
1168
1181
  left: "0",
@@ -1171,31 +1184,29 @@ const Yt = ({
1171
1184
  cursor: "row-resize",
1172
1185
  background: "rgba(0,0,0,0.15)",
1173
1186
  zIndex: "10",
1174
- userSelect: "none",
1175
- WebkitUserSelect: "none",
1176
1187
  MozUserSelect: "none",
1177
1188
  msUserSelect: "none",
1178
1189
  pointerEvents: "auto"
1179
- }), n.contentEditable = "false", Qe(e, t, n), e.appendChild(t), e.appendChild(n);
1190
+ }), n.contentEditable = "false", n.classList.add("rte-resize-handle"), Qe(e, t, n), e.appendChild(t), e.appendChild(n);
1180
1191
  }, Qe = (e, t, n) => {
1181
- let o = 0, i = 0, l = 0, c = 0;
1192
+ let a = 0, i = 0, o = 0, c = 0;
1182
1193
  t.addEventListener("mousedown", (u) => {
1183
- u.preventDefault(), o = u.clientX, l = e.offsetWidth, document.addEventListener("mousemove", v), document.addEventListener("mouseup", f);
1194
+ u.preventDefault(), a = u.clientX, o = e.offsetWidth, document.addEventListener("mousemove", p), document.addEventListener("mouseup", g);
1184
1195
  }), n.addEventListener("mousedown", (u) => {
1185
- u.preventDefault(), i = u.clientY, c = e.offsetHeight, document.addEventListener("mousemove", y), document.addEventListener("mouseup", f);
1196
+ u.preventDefault(), i = u.clientY, c = e.offsetHeight, document.addEventListener("mousemove", v), document.addEventListener("mouseup", g);
1186
1197
  });
1187
- const v = (u) => {
1188
- const g = l + (u.clientX - o);
1189
- e.style.width = `${Math.max(30, g)}px`, S();
1190
- }, y = (u) => {
1191
- const g = c + (u.clientY - i);
1192
- e.style.height = `${Math.max(20, g)}px`, S();
1193
- }, f = () => {
1194
- document.removeEventListener("mousemove", v), document.removeEventListener("mousemove", y), document.removeEventListener("mouseup", f), S();
1198
+ const p = (u) => {
1199
+ const f = o + (u.clientX - a);
1200
+ e.style.width = `${Math.max(30, f)}px`, S();
1201
+ }, v = (u) => {
1202
+ const f = c + (u.clientY - i);
1203
+ e.style.height = `${Math.max(20, f)}px`, S();
1204
+ }, g = () => {
1205
+ document.removeEventListener("mousemove", p), document.removeEventListener("mousemove", v), document.removeEventListener("mouseup", g), S();
1195
1206
  };
1196
1207
  }, Je = (e) => {
1197
1208
  const n = e.target.closest("td, th");
1198
- n && (e.preventDefault(), document.querySelectorAll(".rte-cell-highlight").forEach((o) => o.classList.remove("rte-cell-highlight")), n.classList.add("rte-cell-highlight"), h({
1209
+ n && (e.preventDefault(), document.querySelectorAll(".rte-cell-highlight").forEach((a) => a.classList.remove("rte-cell-highlight")), n.classList.add("rte-cell-highlight"), h({
1199
1210
  visible: !0,
1200
1211
  x: e.clientX,
1201
1212
  y: e.clientY,
@@ -1204,50 +1215,50 @@ const Yt = ({
1204
1215
  }, he = () => {
1205
1216
  document.querySelectorAll(".rte-cell-highlight").forEach((e) => e.classList.remove("rte-cell-highlight"));
1206
1217
  }, Ge = (e) => {
1207
- if (!O.cell) return;
1208
- const t = O.cell.closest("table"), n = O.cell.cellIndex, o = O.cell.parentElement.rowIndex, i = (l) => {
1209
- const c = l.tagName.toLowerCase(), v = document.createElement(c);
1210
- return v.textContent = "", v.style.cssText = l.style.cssText, X(v), v;
1218
+ if (!H.cell) return;
1219
+ const t = H.cell.closest("table"), n = H.cell.cellIndex, a = H.cell.parentElement.rowIndex, i = (o) => {
1220
+ const c = o.tagName.toLowerCase(), p = document.createElement(c);
1221
+ return p.textContent = "", p.style.cssText = o.style.cssText, X(p), p;
1211
1222
  };
1212
1223
  switch (e) {
1213
1224
  case "insertRowAbove": {
1214
- const l = t.rows[o], c = t.insertRow(o);
1215
- Array.from(l.cells).forEach((v) => {
1216
- c.appendChild(i(v));
1225
+ const o = t.rows[a], c = t.insertRow(a);
1226
+ Array.from(o.cells).forEach((p) => {
1227
+ c.appendChild(i(p));
1217
1228
  });
1218
1229
  break;
1219
1230
  }
1220
1231
  case "insertRowBelow": {
1221
- const l = t.rows[o], c = t.insertRow(o + 1);
1222
- Array.from(l.cells).forEach((v) => {
1223
- c.appendChild(i(v));
1232
+ const o = t.rows[a], c = t.insertRow(a + 1);
1233
+ Array.from(o.cells).forEach((p) => {
1234
+ c.appendChild(i(p));
1224
1235
  });
1225
1236
  break;
1226
1237
  }
1227
1238
  case "insertColLeft": {
1228
- Array.from(t.rows).forEach((l) => {
1229
- const c = l.cells[n];
1230
- l.insertBefore(i(c), c);
1239
+ Array.from(t.rows).forEach((o) => {
1240
+ const c = o.cells[n];
1241
+ o.insertBefore(i(c), c);
1231
1242
  });
1232
1243
  break;
1233
1244
  }
1234
1245
  case "insertColRight": {
1235
- Array.from(t.rows).forEach((l) => {
1236
- const c = l.cells[n];
1237
- l.insertBefore(i(c), c.nextSibling);
1246
+ Array.from(t.rows).forEach((o) => {
1247
+ const c = o.cells[n];
1248
+ o.insertBefore(i(c), c.nextSibling);
1238
1249
  });
1239
1250
  break;
1240
1251
  }
1241
1252
  case "deleteRow":
1242
- t.rows.length > 1 && t.deleteRow(o);
1253
+ t.rows.length > 1 && t.deleteRow(a);
1243
1254
  break;
1244
1255
  case "deleteCol":
1245
- Array.from(t.rows).forEach((l) => {
1246
- l.cells[n] && l.deleteCell(n);
1256
+ Array.from(t.rows).forEach((o) => {
1257
+ o.cells[n] && o.deleteCell(n);
1247
1258
  });
1248
1259
  break;
1249
1260
  }
1250
- S(), h(ie(ce({}, O), {
1261
+ S(), h(ie(ce({}, H), {
1251
1262
  visible: !1
1252
1263
  })), he();
1253
1264
  }, et = () => {
@@ -1263,14 +1274,14 @@ const Yt = ({
1263
1274
  t.removeAllRanges(), t.addRange(Z.current);
1264
1275
  let n = e.url.trim();
1265
1276
  /^https?:\/\//i.test(n) || (n = "https://" + n);
1266
- const o = document.createElement("a");
1267
- o.href = n, o.style.cursor = "pointer", o.style.outline = "none", o.textContent = e.text || n, o.title = e.title, o.target = e.target, o.contentEditable = "true";
1277
+ const a = document.createElement("a");
1278
+ a.href = n, a.style.cursor = "pointer", a.style.outline = "none", a.textContent = e.text || n, a.title = e.title, a.target = e.target, a.contentEditable = "true";
1268
1279
  const i = t.getRangeAt(0);
1269
- i.deleteContents(), i.insertNode(o);
1270
- const l = document.createTextNode(" ");
1271
- o.after(l);
1280
+ i.deleteContents(), i.insertNode(a);
1281
+ const o = document.createTextNode(" ");
1282
+ a.after(o);
1272
1283
  const c = document.createRange();
1273
- c.setStartAfter(l), c.collapse(!0), t.removeAllRanges(), t.addRange(c), j(!1), S();
1284
+ c.setStartAfter(o), c.collapse(!0), t.removeAllRanges(), t.addRange(c), j(!1), S();
1274
1285
  }, nt = (e) => {
1275
1286
  const t = e.target;
1276
1287
  if (t.tagName === "A") {
@@ -1280,8 +1291,8 @@ const Yt = ({
1280
1291
  return;
1281
1292
  }
1282
1293
  e.preventDefault();
1283
- const o = document.createRange();
1284
- o.selectNode(n), Z.current = o, se({
1294
+ const a = document.createRange();
1295
+ a.selectNode(n), Z.current = a, se({
1285
1296
  url: n.href,
1286
1297
  text: n.textContent || n.href,
1287
1298
  title: n.title,
@@ -1289,7 +1300,7 @@ const Yt = ({
1289
1300
  }), j(!0);
1290
1301
  }
1291
1302
  }, rt = () => {
1292
- const e = H();
1303
+ const e = O();
1293
1304
  if (!e) return;
1294
1305
  const t = window.getSelection();
1295
1306
  if ((!t || t.rangeCount === 0) && D.current) {
@@ -1298,30 +1309,30 @@ const Yt = ({
1298
1309
  }
1299
1310
  const n = window.getSelection();
1300
1311
  if (!n || n.rangeCount === 0) return;
1301
- const o = n.getRangeAt(0);
1312
+ const a = n.getRangeAt(0);
1302
1313
  K(), document.execCommand("removeFormat", !1);
1303
- const i = o.cloneContents(), l = document.createElement("div");
1304
- l.appendChild(i);
1305
- const c = document.createTreeWalker(l, NodeFilter.SHOW_ELEMENT, null), v = [];
1314
+ const i = a.cloneContents(), o = document.createElement("div");
1315
+ o.appendChild(i);
1316
+ const c = document.createTreeWalker(o, NodeFilter.SHOW_ELEMENT, null), p = [];
1306
1317
  for (; c.nextNode(); ) {
1307
- const u = c.currentNode, g = u.tagName.toUpperCase(), b = u.getAttribute && u.getAttribute("data-mention") !== null;
1308
- g !== "A" && !b && v.push(u);
1318
+ const u = c.currentNode, f = u.tagName.toUpperCase(), b = u.getAttribute && u.getAttribute("data-mention") !== null;
1319
+ f !== "A" && !b && p.push(u);
1309
1320
  }
1310
- for (let u = v.length - 1; u >= 0; u--) {
1311
- const g = v[u], b = g.parentNode;
1321
+ for (let u = p.length - 1; u >= 0; u--) {
1322
+ const f = p[u], b = f.parentNode;
1312
1323
  if (b) {
1313
- for (; g.firstChild; ) b.insertBefore(g.firstChild, g);
1314
- b.removeChild(g);
1324
+ for (; f.firstChild; ) b.insertBefore(f.firstChild, f);
1325
+ b.removeChild(f);
1315
1326
  }
1316
1327
  }
1317
- l.querySelectorAll("[style]").forEach((u) => u.removeAttribute("style")), o.deleteContents();
1318
- const y = document.createDocumentFragment();
1319
- for (; l.firstChild; ) y.appendChild(l.firstChild);
1320
- o.insertNode(y);
1321
- const f = document.createRange();
1322
- f.setStartAfter(o.endContainer.nodeType === Node.TEXT_NODE ? o.endContainer : o.startContainer), f.collapse(!0), n.removeAllRanges(), n.addRange(f), e.normalize(), S();
1323
- }, ot = (e) => {
1324
- var o;
1328
+ o.querySelectorAll("[style]").forEach((u) => u.removeAttribute("style")), a.deleteContents();
1329
+ const v = document.createDocumentFragment();
1330
+ for (; o.firstChild; ) v.appendChild(o.firstChild);
1331
+ a.insertNode(v);
1332
+ const g = document.createRange();
1333
+ g.setStartAfter(a.endContainer.nodeType === Node.TEXT_NODE ? a.endContainer : a.startContainer), g.collapse(!0), n.removeAllRanges(), n.addRange(g), e.normalize(), S();
1334
+ }, at = (e) => {
1335
+ var a;
1325
1336
  let t = e;
1326
1337
  t = t.replace(/{{#arrayData\d*}}/g, ""), t = t.replace(/{{\/arrayData\d*}}/g, "");
1327
1338
  const n = document.createElement("div");
@@ -1334,73 +1345,73 @@ const Yt = ({
1334
1345
  }), n.querySelectorAll("table").forEach((i) => {
1335
1346
  i.insertAdjacentText("afterend", `
1336
1347
  `);
1337
- }), ((o = n.textContent) == null ? void 0 : o.replace(/\n{3,}/g, `
1348
+ }), ((a = n.textContent) == null ? void 0 : a.replace(/\n{3,}/g, `
1338
1349
 
1339
1350
  `).trim()) || "";
1340
1351
  };
1341
- function at() {
1352
+ function ot() {
1342
1353
  const e = window.getSelection();
1343
1354
  if (!e || e.rangeCount === 0) return [];
1344
1355
  const t = e.getRangeAt(0);
1345
1356
  if (t.collapsed) {
1346
- let l = t.startContainer, c = l.nodeType === Node.ELEMENT_NODE ? l : l.parentElement;
1347
- const v = c == null ? void 0 : c.closest("td, th");
1348
- return v ? [v] : [];
1357
+ let o = t.startContainer, c = o.nodeType === Node.ELEMENT_NODE ? o : o.parentElement;
1358
+ const p = c == null ? void 0 : c.closest("td, th");
1359
+ return p ? [p] : [];
1349
1360
  }
1350
- const n = t.commonAncestorContainer, o = n.nodeType === Node.ELEMENT_NODE ? n : n.parentElement;
1351
- return Array.from(o.querySelectorAll("td, th")).filter((l) => {
1361
+ const n = t.commonAncestorContainer, a = n.nodeType === Node.ELEMENT_NODE ? n : n.parentElement;
1362
+ return Array.from(a.querySelectorAll("td, th")).filter((o) => {
1352
1363
  const c = document.createRange();
1353
- return c.selectNodeContents(l), t.compareBoundaryPoints(Range.END_TO_START, c) < 0 && t.compareBoundaryPoints(Range.START_TO_END, c) > 0;
1364
+ return c.selectNodeContents(o), t.compareBoundaryPoints(Range.END_TO_START, c) < 0 && t.compareBoundaryPoints(Range.START_TO_END, c) > 0;
1354
1365
  });
1355
1366
  }
1356
1367
  function lt(e) {
1357
- const t = at();
1368
+ const t = ot();
1358
1369
  if (t.length === 0) {
1359
1370
  ue(e);
1360
1371
  return;
1361
1372
  }
1362
1373
  let n = "left";
1363
- e === "justifyCenter" && (n = "center"), e === "justifyRight" && (n = "right"), t.forEach((o) => {
1364
- o.style.textAlign = n;
1374
+ e === "justifyCenter" && (n = "center"), e === "justifyRight" && (n = "right"), t.forEach((a) => {
1375
+ a.style.textAlign = n;
1365
1376
  }), S();
1366
1377
  }
1367
1378
  const ct = (e) => {
1368
1379
  e.preventDefault();
1369
1380
  const t = e.clipboardData.items;
1370
- for (let f = 0; f < t.length; f++) {
1371
- const u = t[f];
1381
+ for (let g = 0; g < t.length; g++) {
1382
+ const u = t[g];
1372
1383
  if (u.kind === "file" && u.type.startsWith("image/"))
1373
1384
  return;
1374
- u.kind === "string" && u.getAsString((g) => {
1375
- /<img\s/i.test(g);
1385
+ u.kind === "string" && u.getAsString((f) => {
1386
+ /<img\s/i.test(f);
1376
1387
  });
1377
1388
  }
1378
1389
  const n = e.clipboardData.getData("text/html") || "";
1379
1390
  if (!n) return;
1380
- const o = document.createElement("div");
1381
- o.innerHTML = n;
1382
- const i = (f) => {
1383
- f.style.borderCollapse = "collapse", f.style.width = "100%", f.style.border = "1px solid #ccc", f.style.margin = "8px 0", f.style.position = "relative", f.style.textAlign = "center", f.querySelectorAll("th").forEach((u) => {
1384
- const g = u;
1385
- g.style.border = "1px solid #999", g.style.padding = "4px", g.style.position = "relative", g.style.backgroundColor = "lightgray", g.style.height = "20px";
1386
- }), f.querySelectorAll("td").forEach((u) => {
1387
- const g = u;
1388
- g.style.border = "1px solid #999", g.style.padding = "4px", g.style.position = "relative", g.style.backgroundColor = "#fff", g.style.height = "20px";
1391
+ const a = document.createElement("div");
1392
+ a.innerHTML = n;
1393
+ const i = (g) => {
1394
+ g.style.borderCollapse = "collapse", g.style.width = "100%", g.style.border = "1px solid #ccc", g.style.margin = "8px 0", g.style.position = "relative", g.style.textAlign = "center", g.querySelectorAll("th").forEach((u) => {
1395
+ const f = u;
1396
+ f.style.border = "1px solid #999", f.style.padding = "4px", f.style.position = "relative", f.style.backgroundColor = "lightgray", f.style.height = "20px";
1397
+ }), g.querySelectorAll("td").forEach((u) => {
1398
+ const f = u;
1399
+ f.style.border = "1px solid #999", f.style.padding = "4px", f.style.position = "relative", f.style.backgroundColor = "#fff", f.style.height = "20px";
1389
1400
  });
1390
1401
  };
1391
- o.querySelectorAll("table").forEach((f) => i(f));
1392
- const l = window.getSelection();
1393
- if (!l || !l.rangeCount) return;
1394
- const c = l.getRangeAt(0);
1402
+ a.querySelectorAll("table").forEach((g) => i(g));
1403
+ const o = window.getSelection();
1404
+ if (!o || !o.rangeCount) return;
1405
+ const c = o.getRangeAt(0);
1395
1406
  c.deleteContents();
1396
- const v = document.createDocumentFragment();
1397
- for (; o.firstChild; ) v.appendChild(o.firstChild);
1398
- c.insertNode(v), c.collapse(!1), l.removeAllRanges(), l.addRange(c);
1399
- const y = A.current;
1400
- y && (y.querySelectorAll("table").forEach((f) => {
1401
- const u = f;
1402
- u.dataset.hasResizeHandle !== "true" && (ae(u), u.dataset.hasResizeHandle = "true", u.querySelectorAll("th, td").forEach((g) => {
1403
- const b = g;
1407
+ const p = document.createDocumentFragment();
1408
+ for (; a.firstChild; ) p.appendChild(a.firstChild);
1409
+ c.insertNode(p), c.collapse(!1), o.removeAllRanges(), o.addRange(c);
1410
+ const v = A.current;
1411
+ v && (v.querySelectorAll("table").forEach((g) => {
1412
+ const u = g;
1413
+ u.hasAttribute("data-has-resize-handle") || (oe(u), u.querySelectorAll("th, td").forEach((f) => {
1414
+ const b = f;
1404
1415
  b.dataset.hasResizeHandles || X(b);
1405
1416
  }));
1406
1417
  }), S());
@@ -1408,23 +1419,23 @@ const Yt = ({
1408
1419
  K();
1409
1420
  const t = window.getSelection();
1410
1421
  if (!t || !t.rangeCount) return;
1411
- const n = t.getRangeAt(0), o = document.createElement("span");
1412
- o.style.fontSize = `${e}px`, o.appendChild(n.extractContents()), n.insertNode(o);
1422
+ const n = t.getRangeAt(0), a = document.createElement("span");
1423
+ a.style.fontSize = `${e}px`, a.appendChild(n.extractContents()), n.insertNode(a);
1413
1424
  const i = document.createRange();
1414
- i.setStartAfter(o), i.collapse(!0), t.removeAllRanges(), t.addRange(i), S();
1425
+ i.setStartAfter(a), i.collapse(!0), t.removeAllRanges(), t.addRange(i), S();
1415
1426
  }, st = () => {
1416
1427
  const e = window.getSelection();
1417
1428
  if (!e || !e.anchorNode) return null;
1418
1429
  const t = e.anchorNode;
1419
- if (oe(t) || t.nodeType !== Node.TEXT_NODE) return null;
1420
- const n = t.textContent || "", o = e.anchorOffset, i = n.lastIndexOf("@", o - 1);
1430
+ if (ae(t) || t.nodeType !== Node.TEXT_NODE) return null;
1431
+ const n = t.textContent || "", a = e.anchorOffset, i = n.lastIndexOf("@", a - 1);
1421
1432
  if (i === -1) return null;
1422
- const l = n.substring(i + 1, o);
1423
- if (l.includes(" ") || l.includes(" ")) return null;
1433
+ const o = n.substring(i + 1, a);
1434
+ if (o.includes(" ") || o.includes(" ")) return null;
1424
1435
  const c = document.createRange();
1425
- return c.setStart(t, i), c.setEnd(t, o), {
1436
+ return c.setStart(t, i), c.setEnd(t, a), {
1426
1437
  range: c,
1427
- query: l
1438
+ query: o
1428
1439
  };
1429
1440
  }, pe = () => {
1430
1441
  const e = st();
@@ -1432,15 +1443,15 @@ const Yt = ({
1432
1443
  const {
1433
1444
  range: t,
1434
1445
  query: n
1435
- } = e, o = document.createElement("span");
1436
- o.textContent = "​", t.insertNode(o);
1437
- const i = o.getBoundingClientRect();
1438
- o.remove(), Y({
1446
+ } = e, a = document.createElement("span");
1447
+ a.textContent = "​", t.insertNode(a);
1448
+ const i = a.getBoundingClientRect();
1449
+ a.remove(), Y({
1439
1450
  x: i.left,
1440
1451
  y: i.bottom + window.scrollY
1441
1452
  }), te(n.toLowerCase());
1442
- const l = r.filter((c) => c.name.toLowerCase().includes(n.toLowerCase()));
1443
- z(l), _(!0), $.current = t.cloneRange();
1453
+ const o = r.filter((c) => c.name.toLowerCase().includes(n.toLowerCase()));
1454
+ z(o), _(!0), $.current = t.cloneRange();
1444
1455
  };
1445
1456
  function dt() {
1446
1457
  const e = A.current;
@@ -1451,14 +1462,14 @@ const Yt = ({
1451
1462
  const n = document.createRange();
1452
1463
  n.selectNodeContents(e), n.collapse(!1), t.removeAllRanges(), t.addRange(n), D.current = n.cloneRange();
1453
1464
  }
1454
- return /* @__PURE__ */ a.createElement("div", {
1455
- className: `rte-wrapper ${(p == null ? void 0 : p.wrapper) || ""}`,
1465
+ return /* @__PURE__ */ l.createElement("div", {
1466
+ className: `rte-wrapper ${(y == null ? void 0 : y.wrapper) || ""}`,
1456
1467
  style: w.wrapper
1457
- }, /* @__PURE__ */ a.createElement("div", {
1468
+ }, /* @__PURE__ */ l.createElement("div", {
1458
1469
  style: {
1459
1470
  flex: 1
1460
1471
  }
1461
- }, /* @__PURE__ */ a.createElement(qt, {
1472
+ }, /* @__PURE__ */ l.createElement(qt, {
1462
1473
  exec: re,
1463
1474
  saveSelection: W,
1464
1475
  handleFileChange: Xe,
@@ -1467,13 +1478,13 @@ const Yt = ({
1467
1478
  insertEmoji: Ye,
1468
1479
  handleLink: et,
1469
1480
  removeFormatting: rt,
1470
- visibleActions: Oe,
1471
- className: p.toolbar,
1481
+ visibleActions: He,
1482
+ className: y.toolbar,
1472
1483
  style: w.toolbar
1473
- }), /* @__PURE__ */ a.createElement("div", {
1484
+ }), /* @__PURE__ */ l.createElement("div", {
1474
1485
  ref: A,
1475
1486
  id: "rte-editor-body",
1476
- className: `rte-editor ${(p == null ? void 0 : p.editor) || ""}`,
1487
+ className: `rte-editor ${(y == null ? void 0 : y.editor) || ""}`,
1477
1488
  style: w.editor,
1478
1489
  contentEditable: !0,
1479
1490
  suppressContentEditableWarning: !0,
@@ -1491,39 +1502,39 @@ const Yt = ({
1491
1502
  onClick: (e) => {
1492
1503
  nt(e), W(), pe();
1493
1504
  }
1494
- }), /* @__PURE__ */ a.createElement(Bt, {
1495
- show: F,
1496
- position: U,
1505
+ }), /* @__PURE__ */ l.createElement(Bt, {
1506
+ show: I,
1507
+ position: V,
1497
1508
  filtered: ee,
1498
1509
  insertMention: Be,
1499
1510
  onClose: () => _(!1),
1500
1511
  query: _e
1501
- }), s && /* @__PURE__ */ a.createElement("div", {
1502
- className: `rte-output ${(p == null ? void 0 : p.output) || ""}`,
1512
+ }), s && /* @__PURE__ */ l.createElement("div", {
1513
+ className: `rte-output ${(y == null ? void 0 : y.output) || ""}`,
1503
1514
  style: w.output
1504
- }, /* @__PURE__ */ a.createElement("h4", null, "Output HTML:"), /* @__PURE__ */ a.createElement("p", null, q)), /* @__PURE__ */ a.createElement(Ut, {
1505
- visible: O.visible,
1506
- x: O.x,
1507
- y: O.y,
1515
+ }, /* @__PURE__ */ l.createElement("h4", null, "Output HTML:"), /* @__PURE__ */ l.createElement("p", null, q)), /* @__PURE__ */ l.createElement(Vt, {
1516
+ visible: H.visible,
1517
+ x: H.x,
1518
+ y: H.y,
1508
1519
  onAction: Ge,
1509
1520
  onClose: () => {
1510
- h(ie(ce({}, O), {
1521
+ h(ie(ce({}, H), {
1511
1522
  visible: !1
1512
1523
  })), he();
1513
1524
  }
1514
- }), /* @__PURE__ */ a.createElement($t, {
1525
+ }), /* @__PURE__ */ l.createElement($t, {
1515
1526
  visible: C,
1516
- linkData: He,
1527
+ linkData: Oe,
1517
1528
  onClose: () => j(!1),
1518
1529
  onInsert: tt
1519
- })), d ? /* @__PURE__ */ a.createElement(Vt, {
1520
- className: p.preview,
1530
+ })), d ? /* @__PURE__ */ l.createElement(Ut, {
1531
+ className: y.preview,
1521
1532
  style: w.preview,
1522
1533
  html: q
1523
1534
  }) : null);
1524
1535
  };
1525
1536
  export {
1526
1537
  Yt as RichTextEditor,
1527
- Vt as RtePreview,
1538
+ Ut as RtePreview,
1528
1539
  qt as RteToolbar
1529
1540
  };