@ryzeup/richtexteditor 1.0.21 → 1.0.23

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 z, useEffect as I } from "react";
14
+ import a, { useRef as V, useState as k, useEffect as I } from "react";
15
15
  import { createPortal as vt } from "react-dom";
16
16
  window.React = pt;
17
17
  var Te = {
@@ -51,7 +51,7 @@ function J() {
51
51
  return r;
52
52
  }, J.apply(this, arguments);
53
53
  }
54
- function ke(r, s) {
54
+ function ze(r, s) {
55
55
  var d = Object.keys(r);
56
56
  if (Object.getOwnPropertySymbols) {
57
57
  var m = Object.getOwnPropertySymbols(r);
@@ -64,9 +64,9 @@ function ke(r, s) {
64
64
  function G(r) {
65
65
  for (var s = 1; s < arguments.length; s++) {
66
66
  var d = arguments[s] != null ? arguments[s] : {};
67
- s % 2 ? ke(Object(d), !0).forEach(function(m) {
67
+ s % 2 ? ze(Object(d), !0).forEach(function(m) {
68
68
  Ct(r, m, d[m]);
69
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(r, Object.getOwnPropertyDescriptors(d)) : ke(Object(d)).forEach(function(m) {
69
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(r, Object.getOwnPropertyDescriptors(d)) : ze(Object(d)).forEach(function(m) {
70
70
  Object.defineProperty(r, m, Object.getOwnPropertyDescriptor(d, m));
71
71
  });
72
72
  }
@@ -134,10 +134,10 @@ function At(r) {
134
134
  function Mt(r) {
135
135
  return N({ attr: { viewBox: "0 0 512 512" }, child: [{ tag: "path", attr: { d: "M24 56c0-13.3 10.7-24 24-24l32 0c13.3 0 24 10.7 24 24l0 120 16 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-80 0c-13.3 0-24-10.7-24-24s10.7-24 24-24l16 0 0-96-8 0C34.7 80 24 69.3 24 56zM86.7 341.2c-6.5-7.4-18.3-6.9-24 1.2L51.5 357.9c-7.7 10.8-22.7 13.3-33.5 5.6s-13.3-22.7-5.6-33.5l11.1-15.6c23.7-33.2 72.3-35.6 99.2-4.9c21.3 24.4 20.8 60.9-1.1 84.7L86.8 432l33.2 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-88 0c-9.5 0-18.2-5.6-22-14.4s-2.1-18.9 4.3-25.9l72-78c5.3-5.8 5.4-14.6 .3-20.5zM224 64l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 160l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 160l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32z" }, child: [] }] })(r);
136
136
  }
137
- function kt(r) {
137
+ function zt(r) {
138
138
  return N({ attr: { viewBox: "0 0 448 512" }, child: [{ tag: "path", attr: { d: "M12.83 352h262.34A12.82 12.82 0 0 0 288 339.17v-38.34A12.82 12.82 0 0 0 275.17 288H12.83A12.82 12.82 0 0 0 0 300.83v38.34A12.82 12.82 0 0 0 12.83 352zm0-256h262.34A12.82 12.82 0 0 0 288 83.17V44.83A12.82 12.82 0 0 0 275.17 32H12.83A12.82 12.82 0 0 0 0 44.83v38.34A12.82 12.82 0 0 0 12.83 96zM432 160H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0 256H16a16 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);
139
139
  }
140
- function zt(r) {
140
+ function kt(r) {
141
141
  return N({ attr: { viewBox: "0 0 384 512" }, child: [{ tag: "path", attr: { d: "M333.49 238a122 122 0 0 0 27-65.21C367.87 96.49 308 32 233.42 32H34a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h31.87v288H34a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h209.32c70.8 0 134.14-51.75 141-122.4 4.74-48.45-16.39-92.06-50.83-119.6zM145.66 112h87.76a48 48 0 0 1 0 96h-87.76zm87.76 288h-87.76V288h87.76a56 56 0 0 1 0 112z" }, child: [] }] })(r);
142
142
  }
143
143
  function Nt(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) {
@@ -293,8 +293,8 @@ 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] = z(!1), [F, _] = z({
296
+ var $, H;
297
+ const A = V(null), P = V(null), T = V(null), [q, B] = k(!1), [F, _] = k({
298
298
  x: 0,
299
299
  y: 0
300
300
  });
@@ -329,7 +329,7 @@ const Pt = [
329
329
  r("foreColor", h.target.value);
330
330
  }, ee = (h) => {
331
331
  r("backColor", h.target.value);
332
- }, [k, D] = z({
332
+ }, [z, D] = k({
333
333
  bold: !1,
334
334
  italic: !1,
335
335
  underline: !1,
@@ -374,44 +374,44 @@ const Pt = [
374
374
  "data-command": "bold",
375
375
  title: "Bold",
376
376
  onMouseDown: U,
377
- className: k.bold ? "rte-active" : ""
378
- }, /* @__PURE__ */ a.createElement(zt, null)), E.italic && /* @__PURE__ */ a.createElement("button", {
377
+ className: z.bold ? "rte-active" : ""
378
+ }, /* @__PURE__ */ a.createElement(kt, null)), E.italic && /* @__PURE__ */ a.createElement("button", {
379
379
  "data-command": "italic",
380
380
  title: "Italic",
381
381
  onMouseDown: U,
382
- className: k.italic ? "rte-active" : ""
382
+ className: z.italic ? "rte-active" : ""
383
383
  }, /* @__PURE__ */ a.createElement(Tt, null)), E.underline && /* @__PURE__ */ a.createElement("button", {
384
384
  "data-command": "underline",
385
385
  title: "Underline",
386
386
  onMouseDown: U,
387
- className: k.underline ? "rte-active" : ""
387
+ className: z.underline ? "rte-active" : ""
388
388
  }, /* @__PURE__ */ a.createElement(jt, null)), E.unorderedList && /* @__PURE__ */ a.createElement("button", {
389
389
  "data-command": "insertUnorderedList",
390
390
  onMouseDown: U,
391
391
  title: "UnorderedList",
392
- className: k.unorderedList ? "rte-active" : ""
393
- }, /* @__PURE__ */ a.createElement(Ht, null)), E.orderedList && /* @__PURE__ */ a.createElement("button", {
392
+ className: z.unorderedList ? "rte-active" : ""
393
+ }, /* @__PURE__ */ a.createElement(Ot, null)), E.orderedList && /* @__PURE__ */ a.createElement("button", {
394
394
  "data-command": "insertOrderedList",
395
395
  title: "OrderedList",
396
396
  onMouseDown: U,
397
- className: k.orderedList ? "rte-active" : ""
397
+ className: z.orderedList ? "rte-active" : ""
398
398
  }, /* @__PURE__ */ a.createElement(Mt, null)), E.link && /* @__PURE__ */ a.createElement("button", {
399
399
  "data-command": "createLink",
400
400
  title: "Link",
401
401
  onClick: R,
402
- className: k.link ? "rte-active" : ""
402
+ className: z.link ? "rte-active" : ""
403
403
  }, /* @__PURE__ */ a.createElement(Dt, null)), E.removeFormat && /* @__PURE__ */ a.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
- className: k.removeFormat ? "rte-active" : ""
409
+ className: z.removeFormat ? "rte-active" : ""
410
410
  }, /* @__PURE__ */ a.createElement(Ft, null)), E.image && /* @__PURE__ */ a.createElement("button", {
411
411
  "data-command": "insertImage",
412
412
  title: "Image",
413
413
  onMouseDown: U,
414
- className: k.image ? "rte-active" : ""
414
+ className: z.image ? "rte-active" : ""
415
415
  }, /* @__PURE__ */ a.createElement(At, null)), /* @__PURE__ */ a.createElement("input", {
416
416
  type: "file",
417
417
  accept: "image/*",
@@ -435,8 +435,8 @@ const Pt = [
435
435
  // small spacing
436
436
  }), B((j) => !j);
437
437
  },
438
- className: k.emoji ? "rte-active" : ""
439
- }, /* @__PURE__ */ a.createElement(Ot, null)), q && /* @__PURE__ */ vt(/* @__PURE__ */ a.createElement("div", {
438
+ className: z.emoji ? "rte-active" : ""
439
+ }, /* @__PURE__ */ a.createElement(Ht, null)), q && /* @__PURE__ */ vt(/* @__PURE__ */ a.createElement("div", {
440
440
  className: "rte-emoji-popup",
441
441
  style: {
442
442
  top: F.y,
@@ -469,7 +469,7 @@ const Pt = [
469
469
  color: (($ = P.current) == null ? void 0 : $.value) || "#000",
470
470
  fontSize: "18px"
471
471
  },
472
- className: k.color ? "rte-active" : ""
472
+ className: z.color ? "rte-active" : ""
473
473
  }, /* @__PURE__ */ a.createElement(It, null)), /* @__PURE__ */ a.createElement("input", {
474
474
  ref: P,
475
475
  type: "color",
@@ -499,10 +499,10 @@ 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
- className: k.highlight ? "rte-active" : ""
505
+ className: z.highlight ? "rte-active" : ""
506
506
  }, /* @__PURE__ */ a.createElement(Nt, null)), /* @__PURE__ */ a.createElement("input", {
507
507
  ref: T,
508
508
  type: "color",
@@ -522,22 +522,22 @@ const Pt = [
522
522
  title: "Align Left",
523
523
  onMouseDown: (h) => h.preventDefault(),
524
524
  onClick: () => r("justifyLeft"),
525
- className: k.alignLeft ? "rte-active" : ""
526
- }, /* @__PURE__ */ a.createElement(kt, null)), /* @__PURE__ */ a.createElement("button", {
525
+ className: z.alignLeft ? "rte-active" : ""
526
+ }, /* @__PURE__ */ a.createElement(zt, null)), /* @__PURE__ */ a.createElement("button", {
527
527
  title: "Align Center",
528
528
  onMouseDown: (h) => h.preventDefault(),
529
529
  onClick: () => r("justifyCenter"),
530
- className: k.alignCenter ? "rte-active" : ""
530
+ className: z.alignCenter ? "rte-active" : ""
531
531
  }, /* @__PURE__ */ a.createElement(Lt, null)), /* @__PURE__ */ a.createElement("button", {
532
532
  title: "Align Right",
533
533
  onMouseDown: (h) => h.preventDefault(),
534
534
  onClick: () => r("justifyRight"),
535
- className: k.alignRight ? "rte-active" : ""
535
+ className: z.alignRight ? "rte-active" : ""
536
536
  }, /* @__PURE__ */ a.createElement(St, null))), E.table && /* @__PURE__ */ a.createElement("button", {
537
537
  title: "Insert Table",
538
538
  onMouseDown: (h) => h.preventDefault(),
539
539
  onClick: () => r("insertTable"),
540
- className: k.table ? "rte-active" : ""
540
+ className: z.table ? "rte-active" : ""
541
541
  }, /* @__PURE__ */ a.createElement(_t, null)), E.fontFamily && /* @__PURE__ */ a.createElement("select", {
542
542
  className: "rte-dropdown",
543
543
  defaultValue: "",
@@ -578,7 +578,7 @@ const Pt = [
578
578
  onClose: p,
579
579
  query: w
580
580
  }) => {
581
- const R = V(null), [M, E] = z(0);
581
+ const R = V(null), [M, E] = k(0);
582
582
  return I(() => {
583
583
  r && E(0);
584
584
  }, [r]), I(() => {
@@ -648,7 +648,7 @@ const Pt = [
648
648
  }
649
649
  }, "No matches")) : null;
650
650
  };
651
- function ze(r) {
651
+ function ke(r) {
652
652
  return N({ attr: { viewBox: "0 0 24 24" }, child: [{ tag: "g", attr: { id: "Circle_Minus" }, child: [{ tag: "g", attr: {}, child: [{ tag: "path", attr: { d: "M15,11.5h0a.5.5,0,0,1,0,1H9a.5.5,0,0,1,0-1Z" }, child: [] }, { tag: "path", attr: { d: "M12,21.934A9.933,9.933,0,1,1,21.932,12,9.945,9.945,0,0,1,12,21.934ZM12,3.068A8.933,8.933,0,1,0,20.932,12,8.944,8.944,0,0,0,12,3.068Z" }, child: [] }] }] }] })(r);
653
653
  }
654
654
  function Q(r) {
@@ -680,9 +680,9 @@ const Ut = ({
680
680
  onClick: () => m("insertColRight")
681
681
  }, /* @__PURE__ */ a.createElement(Q, null), " Insert col right"), /* @__PURE__ */ a.createElement("button", {
682
682
  onClick: () => m("deleteRow")
683
- }, /* @__PURE__ */ a.createElement(ze, null), " Delete row"), /* @__PURE__ */ a.createElement("button", {
683
+ }, /* @__PURE__ */ a.createElement(ke, null), " Delete row"), /* @__PURE__ */ a.createElement("button", {
684
684
  onClick: () => m("deleteCol")
685
- }, /* @__PURE__ */ a.createElement(ze, null), " Delete column"));
685
+ }, /* @__PURE__ */ a.createElement(ke, null), " Delete column"));
686
686
  }, Vt = ({
687
687
  html: r,
688
688
  className: s,
@@ -713,7 +713,7 @@ const Ut = ({
713
713
  onClose: d,
714
714
  onInsert: m
715
715
  }) => {
716
- const [p, w] = z(""), [R, M] = z(""), [E, x] = z(""), [L, A] = z("_self");
716
+ const [p, w] = k(""), [R, M] = k(""), [E, x] = k(""), [L, A] = k("_self");
717
717
  if (I(() => {
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;
@@ -769,7 +769,13 @@ const Ut = ({
769
769
  }, "OK"))));
770
770
  };
771
771
  function Ne(r) {
772
- return Array.from(new Map(r.map((s) => [s.value, s])).values());
772
+ const s = /* @__PURE__ */ new Map();
773
+ return r.forEach((d) => {
774
+ s.set(d.name, d.value);
775
+ }), Array.from(s.entries()).map(([d, m]) => ({
776
+ name: d,
777
+ value: m
778
+ }));
773
779
  }
774
780
  const Yt = ({
775
781
  atSuggestions: r = [],
@@ -798,19 +804,19 @@ const Yt = ({
798
804
  }
799
805
  }) => {
800
806
  var ve, ye, Ee, we, Ce, be, Re, xe;
801
- const A = V(null), [P, T] = z(E != null && E.length ? E : " "), [q, B] = z(""), [F, _] = z(!1), [U, Y] = z({
807
+ const A = V(null), [P, T] = k(E != null && E.length ? E : " "), [q, B] = k(""), [F, _] = k(!1), [U, Y] = k({
802
808
  x: 0,
803
809
  y: 0
804
- }), [ee, k] = z([]), D = V(null), $ = V(null), [O, h] = z({
810
+ }), [ee, z] = k([]), D = V(null), $ = V(null), [H, h] = k({
805
811
  visible: !1,
806
812
  x: 0,
807
813
  y: 0
808
- }), [C, j] = z(!1), Z = V(null), [He, se] = z({
814
+ }), [C, j] = k(!1), Z = V(null), [Oe, se] = k({
809
815
  url: "",
810
816
  text: "",
811
817
  title: "",
812
818
  target: "_self"
813
- }), Oe = {
819
+ }), He = {
814
820
  bold: !0,
815
821
  italic: !0,
816
822
  underline: !0,
@@ -826,7 +832,7 @@ const Yt = ({
826
832
  fontFamily: (be = m.fontFamily) != null ? be : !1,
827
833
  fontSize: (Re = m.fontSize) != null ? Re : !1,
828
834
  highlight: (xe = m.fontSize) != null ? xe : !1
829
- }, [_e, te] = z(""), [de, ne] = z([]), H = () => A.current, S = () => {
835
+ }, [_e, te] = k(""), [de, ne] = k([]), O = () => A.current, S = () => {
830
836
  const e = je(), t = /^<div[^>]*style=["'][^"']*font-size\s*:\s*\d+px[^"']*["'][^>]*>/.test(e.trim());
831
837
  let n = e;
832
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}>
@@ -836,10 +842,12 @@ const Yt = ({
836
842
  const i = $e(), l = Ne(i);
837
843
  JSON.stringify(l) !== JSON.stringify(de) && (ne(l), x(l));
838
844
  }, je = () => {
839
- const e = H();
845
+ const e = O();
840
846
  if (!e) return P;
841
847
  const t = e.cloneNode(!0);
842
- 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((o) => o.remove()), t.querySelectorAll("table").forEach((o) => {
849
+ o.removeAttribute("data-has-resize-handle");
850
+ }), t.querySelectorAll(".rte-cell-highlight").forEach((o) => o.classList.remove("rte-cell-highlight"));
843
851
  let n = t.innerHTML;
844
852
  return n = Ie(n), n;
845
853
  }, Ie = (e) => e.replace(/<tbody[^>]*>/g, "<tbody>{{#arrayData}}").replace(/<\/tbody>/g, "{{/arrayData}}</tbody>"), W = () => {
@@ -857,7 +865,7 @@ const Yt = ({
857
865
  n && n.rangeCount > 0 && (D.current = n.getRangeAt(0)), K(), document.execCommand(e, !1, t), S();
858
866
  };
859
867
  I(() => {
860
- const e = H();
868
+ const e = O();
861
869
  if (!e || !E) return;
862
870
  const t = Fe(E);
863
871
  e.innerHTML = t, S();
@@ -870,10 +878,10 @@ const Yt = ({
870
878
  Ve(e);
871
879
  });
872
880
  }, []), I(() => {
873
- const e = H();
881
+ const e = O();
874
882
  if (!e) return;
875
883
  e.querySelectorAll("table").forEach((n) => {
876
- ae(n), n.querySelectorAll("th, td").forEach((i) => X(i));
884
+ n.hasAttribute("data-has-resize-handle") || (ae(n), n.querySelectorAll("th, td").forEach((i) => X(i)));
877
885
  });
878
886
  }, []);
879
887
  const me = (e) => {
@@ -891,12 +899,12 @@ const Yt = ({
891
899
  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);
892
900
  } else {
893
901
  document.execCommand(e === "ul" ? "insertUnorderedList" : "insertOrderedList");
894
- const y = H();
902
+ const y = O();
895
903
  if (l = y == null ? void 0 : y.querySelector(`${e}:last-child`), !l) return;
896
904
  i = l.querySelector("li:last-child");
897
905
  }
898
906
  const c = document.createRange();
899
- 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), (v = O()) == null || v.focus(), S();
900
908
  }, re = (e, t) => {
901
909
  e === "insertOrderedList" ? ge("ol") : e === "insertUnorderedList" ? ge("ul") : e.startsWith("justify") ? lt(e) : ue(e, t), e === "insertTable" && Ze();
902
910
  }, Pe = (e) => {
@@ -906,7 +914,7 @@ const Yt = ({
906
914
  t.remove(), Y({
907
915
  x: n.left,
908
916
  y: n.bottom + window.scrollY
909
- }), k(r || []), _(!0), $.current = e.cloneRange();
917
+ }), z(r || []), _(!0), $.current = e.cloneRange();
910
918
  }, qe = () => {
911
919
  const e = window.getSelection();
912
920
  if (!e || e.rangeCount === 0) return null;
@@ -938,7 +946,7 @@ const Yt = ({
938
946
  if (c)
939
947
  c.deleteContents(), c.insertNode(o);
940
948
  else {
941
- const f = document.createRange(), u = H();
949
+ const f = document.createRange(), u = O();
942
950
  f.selectNodeContents(u), f.collapse(!1), f.insertNode(o);
943
951
  }
944
952
  const v = document.createTextNode(" ");
@@ -949,9 +957,9 @@ const Yt = ({
949
957
  console.error("insertMention error:", c);
950
958
  }
951
959
  let i = Ne([...de, e]);
952
- ne(i), x(i), _(!1), (l = H()) == null || l.focus(), S();
960
+ ne(i), x(i), _(!1), (l = O()) == null || l.focus(), S();
953
961
  }, Ue = (e) => {
954
- const t = H();
962
+ const t = O();
955
963
  if (!t) return;
956
964
  let n = null;
957
965
  D.current && t.contains(D.current.startContainer) ? n = D.current.cloneRange() : (n = document.createRange(), n.selectNodeContents(t), n.collapse(!1));
@@ -970,7 +978,7 @@ const Yt = ({
970
978
  return x(o), o;
971
979
  }), S();
972
980
  }, $e = () => {
973
- const e = H();
981
+ const e = O();
974
982
  if (!e) return [];
975
983
  const t = e.querySelectorAll("span[data-mention]"), n = [];
976
984
  return t.forEach((o) => {
@@ -1015,7 +1023,7 @@ const Yt = ({
1015
1023
  if (oe(o))
1016
1024
  return;
1017
1025
  setTimeout(() => {
1018
- Pe(n.getRangeAt(0)), te(""), k(r), _(!0);
1026
+ Pe(n.getRangeAt(0)), te(""), z(r), _(!0);
1019
1027
  }, 0);
1020
1028
  return;
1021
1029
  }
@@ -1049,7 +1057,7 @@ const Yt = ({
1049
1057
  const o = n[1].trim().toLowerCase();
1050
1058
  te(o);
1051
1059
  const i = r.filter((l) => l.name.toLowerCase().includes(o));
1052
- i.length > 0 ? (k(i), _(!0)) : _(!1);
1060
+ i.length > 0 ? (z(i), _(!0)) : _(!1);
1053
1061
  }, Xe = (e) => {
1054
1062
  var o;
1055
1063
  const t = (o = e.target.files) == null ? void 0 : o[0];
@@ -1063,7 +1071,7 @@ const Yt = ({
1063
1071
  let v = c && c.rangeCount ? c.getRangeAt(0) : null;
1064
1072
  const y = document.createElement("img");
1065
1073
  y.src = l, y.alt = t.name || "image", y.className = "rte-inserted-image", y.contentEditable = "true";
1066
- const f = H();
1074
+ const f = O();
1067
1075
  if (!v || !f) {
1068
1076
  f == null || f.appendChild(y);
1069
1077
  const Le = document.createTextNode(" ");
@@ -1084,7 +1092,7 @@ const Yt = ({
1084
1092
  const t = window.getSelection();
1085
1093
  if (!(t != null && t.rangeCount)) return;
1086
1094
  const n = t.getRangeAt(0), o = document.createTextNode(e);
1087
- n.insertNode(o), n.setStartAfter(o), n.collapse(!0), t.removeAllRanges(), t.addRange(n), (i = H()) == null || i.focus(), S();
1095
+ n.insertNode(o), n.setStartAfter(o), n.collapse(!0), t.removeAllRanges(), t.addRange(n), (i = O()) == null || i.focus(), S();
1088
1096
  }, Ze = () => {
1089
1097
  var f;
1090
1098
  dt(), K();
@@ -1112,8 +1120,9 @@ const Yt = ({
1112
1120
  const v = document.createElement("p");
1113
1121
  v.innerHTML = "<br/>", e.after(v);
1114
1122
  const y = document.createRange();
1115
- y.setStart(v, 0), y.collapse(!0), l.removeAllRanges(), l.addRange(y), (f = H()) == null || f.focus(), S();
1123
+ y.setStart(v, 0), y.collapse(!0), l.removeAllRanges(), l.addRange(y), (f = O()) == null || f.focus(), S();
1116
1124
  }, ae = (e) => {
1125
+ if (e.dataset.hasResizeHandle === "true") return;
1117
1126
  const t = document.createElement("div");
1118
1127
  Object.assign(t.style, {
1119
1128
  position: "absolute",
@@ -1125,7 +1134,7 @@ const Yt = ({
1125
1134
  cursor: "nwse-resize",
1126
1135
  zIndex: "20",
1127
1136
  borderRadius: "2px"
1128
- }), t.style.userSelect = "none", t.contentEditable = "false";
1137
+ }), t.style.userSelect = "none", t.contentEditable = "false", t.dataset.hasResizeHandle = "true";
1129
1138
  let n = 0, o = 0, i = 0, l = 0;
1130
1139
  t.addEventListener("mousedown", (c) => {
1131
1140
  c.preventDefault(), n = c.clientX, o = c.clientY;
@@ -1197,8 +1206,8 @@ const Yt = ({
1197
1206
  }, he = () => {
1198
1207
  document.querySelectorAll(".rte-cell-highlight").forEach((e) => e.classList.remove("rte-cell-highlight"));
1199
1208
  }, Ge = (e) => {
1200
- if (!O.cell) return;
1201
- const t = O.cell.closest("table"), n = O.cell.cellIndex, o = O.cell.parentElement.rowIndex, i = (l) => {
1209
+ if (!H.cell) return;
1210
+ const t = H.cell.closest("table"), n = H.cell.cellIndex, o = H.cell.parentElement.rowIndex, i = (l) => {
1202
1211
  const c = l.tagName.toLowerCase(), v = document.createElement(c);
1203
1212
  return v.textContent = "", v.style.cssText = l.style.cssText, X(v), v;
1204
1213
  };
@@ -1240,7 +1249,7 @@ const Yt = ({
1240
1249
  });
1241
1250
  break;
1242
1251
  }
1243
- S(), h(ie(ce({}, O), {
1252
+ S(), h(ie(ce({}, H), {
1244
1253
  visible: !1
1245
1254
  })), he();
1246
1255
  }, et = () => {
@@ -1282,7 +1291,7 @@ const Yt = ({
1282
1291
  }), j(!0);
1283
1292
  }
1284
1293
  }, rt = () => {
1285
- const e = H();
1294
+ const e = O();
1286
1295
  if (!e) return;
1287
1296
  const t = window.getSelection();
1288
1297
  if ((!t || t.rangeCount === 0) && D.current) {
@@ -1392,10 +1401,10 @@ const Yt = ({
1392
1401
  const y = A.current;
1393
1402
  y && (y.querySelectorAll("table").forEach((f) => {
1394
1403
  const u = f;
1395
- u.dataset.hasResizeHandle || (ae(u), u.dataset.hasResizeHandle = "true"), u.querySelectorAll("th, td").forEach((g) => {
1404
+ u.hasAttribute("data-has-resize-handle") || (ae(u), u.querySelectorAll("th, td").forEach((g) => {
1396
1405
  const b = g;
1397
- b.dataset.hasResizeHandles || (X(b), b.dataset.hasResizeHandles = "true");
1398
- });
1406
+ b.dataset.hasResizeHandles || X(b);
1407
+ }));
1399
1408
  }), S());
1400
1409
  }, it = (e) => {
1401
1410
  K();
@@ -1433,7 +1442,7 @@ const Yt = ({
1433
1442
  y: i.bottom + window.scrollY
1434
1443
  }), te(n.toLowerCase());
1435
1444
  const l = r.filter((c) => c.name.toLowerCase().includes(n.toLowerCase()));
1436
- k(l), _(!0), $.current = t.cloneRange();
1445
+ z(l), _(!0), $.current = t.cloneRange();
1437
1446
  };
1438
1447
  function dt() {
1439
1448
  const e = A.current;
@@ -1460,7 +1469,7 @@ const Yt = ({
1460
1469
  insertEmoji: Ye,
1461
1470
  handleLink: et,
1462
1471
  removeFormatting: rt,
1463
- visibleActions: Oe,
1472
+ visibleActions: He,
1464
1473
  className: p.toolbar,
1465
1474
  style: w.toolbar
1466
1475
  }), /* @__PURE__ */ a.createElement("div", {
@@ -1495,18 +1504,18 @@ const Yt = ({
1495
1504
  className: `rte-output ${(p == null ? void 0 : p.output) || ""}`,
1496
1505
  style: w.output
1497
1506
  }, /* @__PURE__ */ a.createElement("h4", null, "Output HTML:"), /* @__PURE__ */ a.createElement("p", null, q)), /* @__PURE__ */ a.createElement(Ut, {
1498
- visible: O.visible,
1499
- x: O.x,
1500
- y: O.y,
1507
+ visible: H.visible,
1508
+ x: H.x,
1509
+ y: H.y,
1501
1510
  onAction: Ge,
1502
1511
  onClose: () => {
1503
- h(ie(ce({}, O), {
1512
+ h(ie(ce({}, H), {
1504
1513
  visible: !1
1505
1514
  })), he();
1506
1515
  }
1507
1516
  }), /* @__PURE__ */ a.createElement($t, {
1508
1517
  visible: C,
1509
- linkData: He,
1518
+ linkData: Oe,
1510
1519
  onClose: () => j(!1),
1511
1520
  onInsert: tt
1512
1521
  })), d ? /* @__PURE__ */ a.createElement(Vt, {
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- "use strict";var dt=Object.defineProperty,ut=Object.defineProperties;var mt=Object.getOwnPropertyDescriptors;var Re=Object.getOwnPropertySymbols;var ft=Object.prototype.hasOwnProperty,gt=Object.prototype.propertyIsEnumerable;var xe=(a,i,d)=>i in a?dt(a,i,{enumerable:!0,configurable:!0,writable:!0,value:d}):a[i]=d,ae=(a,i)=>{for(var d in i||(i={}))ft.call(i,d)&&xe(a,d,i[d]);if(Re)for(var d of Re(i))gt.call(i,d)&&xe(a,d,i[d]);return a},oe=(a,i)=>ut(a,mt(i));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react"),ht=require("react-dom");function pt(a){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const d in a)if(d!=="default"){const m=Object.getOwnPropertyDescriptor(a,d);Object.defineProperty(i,d,m.get?m:{enumerable:!0,get:()=>a[d]})}}return i.default=a,Object.freeze(i)}const vt=pt(r);window.React=vt;var ke={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Se=r.createContext&&r.createContext(ke),yt=["attr","size","title"];function Et(a,i){if(a==null)return{};var d=wt(a,i),m,p;if(Object.getOwnPropertySymbols){var w=Object.getOwnPropertySymbols(a);for(p=0;p<w.length;p++)m=w[p],!(i.indexOf(m)>=0)&&Object.prototype.propertyIsEnumerable.call(a,m)&&(d[m]=a[m])}return d}function wt(a,i){if(a==null)return{};var d={};for(var m in a)if(Object.prototype.hasOwnProperty.call(a,m)){if(i.indexOf(m)>=0)continue;d[m]=a[m]}return d}function Y(){return Y=Object.assign?Object.assign.bind():function(a){for(var i=1;i<arguments.length;i++){var d=arguments[i];for(var m in d)Object.prototype.hasOwnProperty.call(d,m)&&(a[m]=d[m])}return a},Y.apply(this,arguments)}function Le(a,i){var d=Object.keys(a);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(a);i&&(m=m.filter(function(p){return Object.getOwnPropertyDescriptor(a,p).enumerable})),d.push.apply(d,m)}return d}function Z(a){for(var i=1;i<arguments.length;i++){var d=arguments[i]!=null?arguments[i]:{};i%2?Le(Object(d),!0).forEach(function(m){Ct(a,m,d[m])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(d)):Le(Object(d)).forEach(function(m){Object.defineProperty(a,m,Object.getOwnPropertyDescriptor(d,m))})}return a}function Ct(a,i,d){return i=bt(i),i in a?Object.defineProperty(a,i,{value:d,enumerable:!0,configurable:!0,writable:!0}):a[i]=d,a}function bt(a){var i=Rt(a,"string");return typeof i=="symbol"?i:i+""}function Rt(a,i){if(typeof a!="object"||!a)return a;var d=a[Symbol.toPrimitive];if(d!==void 0){var m=d.call(a,i);if(typeof m!="object")return m;throw new TypeError("@@toPrimitive must return a primitive value.")}return(i==="string"?String:Number)(a)}function ze(a){return a&&a.map((i,d)=>r.createElement(i.tag,Z({key:d},i.attr),ze(i.child)))}function z(a){return i=>r.createElement(xt,Y({attr:Z({},a.attr)},i),ze(a.child))}function xt(a){var i=d=>{var{attr:m,size:p,title:w}=a,R=Et(a,yt),A=p||d.size||"1em",E;return d.className&&(E=d.className),a.className&&(E=(E?E+" ":"")+a.className),r.createElement("svg",Y({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},d.attr,m,R,{className:E,style:Z(Z({color:a.color||d.color},d.style),a.style),height:A,width:A,xmlns:"http://www.w3.org/2000/svg"}),w&&r.createElement("title",null,w),a.children)};return Se!==void 0?r.createElement(Se.Consumer,null,d=>i(d)):i(ke)}function St(a){return z({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:[]}]})(a)}function Lt(a){return z({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M448 64c0 17.7-14.3 32-32 32L192 96c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zm0 256c0 17.7-14.3 32-32 32l-224 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zM0 192c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 224c-17.7 0-32-14.3-32-32zM448 448c0 17.7-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32s14.3-32 32-32l384 0c17.7 0 32 14.3 32 32z"},child:[]}]})(a)}function Mt(a){return z({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M0 96C0 60.7 28.7 32 64 32l384 0c35.3 0 64 28.7 64 64l0 320c0 35.3-28.7 64-64 64L64 480c-35.3 0-64-28.7-64-64L0 96zM323.8 202.5c-4.5-6.6-11.9-10.5-19.8-10.5s-15.4 3.9-19.8 10.5l-87 127.6L170.7 297c-4.6-5.7-11.5-9-18.7-9s-14.2 3.3-18.7 9l-64 80c-5.8 7.2-6.9 17.1-2.9 25.4s12.4 13.6 21.6 13.6l96 0 32 0 208 0c8.9 0 17.1-4.9 21.2-12.8s3.6-17.4-1.4-24.7l-120-176zM112 192a48 48 0 1 0 0-96 48 48 0 1 0 0 96z"},child:[]}]})(a)}function At(a){return z({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M24 56c0-13.3 10.7-24 24-24l32 0c13.3 0 24 10.7 24 24l0 120 16 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-80 0c-13.3 0-24-10.7-24-24s10.7-24 24-24l16 0 0-96-8 0C34.7 80 24 69.3 24 56zM86.7 341.2c-6.5-7.4-18.3-6.9-24 1.2L51.5 357.9c-7.7 10.8-22.7 13.3-33.5 5.6s-13.3-22.7-5.6-33.5l11.1-15.6c23.7-33.2 72.3-35.6 99.2-4.9c21.3 24.4 20.8 60.9-1.1 84.7L86.8 432l33.2 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-88 0c-9.5 0-18.2-5.6-22-14.4s-2.1-18.9 4.3-25.9l72-78c5.3-5.8 5.4-14.6 .3-20.5zM224 64l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 160l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 160l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32z"},child:[]}]})(a)}function kt(a){return z({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M12.83 352h262.34A12.82 12.82 0 0 0 288 339.17v-38.34A12.82 12.82 0 0 0 275.17 288H12.83A12.82 12.82 0 0 0 0 300.83v38.34A12.82 12.82 0 0 0 12.83 352zm0-256h262.34A12.82 12.82 0 0 0 288 83.17V44.83A12.82 12.82 0 0 0 275.17 32H12.83A12.82 12.82 0 0 0 0 44.83v38.34A12.82 12.82 0 0 0 12.83 96zM432 160H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0 256H16a16 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:[]}]})(a)}function zt(a){return z({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M333.49 238a122 122 0 0 0 27-65.21C367.87 96.49 308 32 233.42 32H34a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h31.87v288H34a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h209.32c70.8 0 134.14-51.75 141-122.4 4.74-48.45-16.39-92.06-50.83-119.6zM145.66 112h87.76a48 48 0 0 1 0 96h-87.76zm87.76 288h-87.76V288h87.76a56 56 0 0 1 0 112z"},child:[]}]})(a)}function Nt(a){return z({attr:{viewBox:"0 0 544 512"},child:[{tag:"path",attr:{d:"M0 479.98L99.92 512l35.45-35.45-67.04-67.04L0 479.98zm124.61-240.01a36.592 36.592 0 0 0-10.79 38.1l13.05 42.83-50.93 50.94 96.23 96.23 50.86-50.86 42.74 13.08c13.73 4.2 28.65-.01 38.15-10.78l35.55-41.64-173.34-173.34-41.52 35.44zm403.31-160.7l-63.2-63.2c-20.49-20.49-53.38-21.52-75.12-2.35L190.55 183.68l169.77 169.78L530.27 154.4c19.18-21.74 18.15-54.63-2.35-75.13z"},child:[]}]})(a)}function Tt(a){return z({attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M320 48v32a16 16 0 0 1-16 16h-62.76l-80 320H208a16 16 0 0 1 16 16v32a16 16 0 0 1-16 16H16a16 16 0 0 1-16-16v-32a16 16 0 0 1 16-16h62.76l80-320H112a16 16 0 0 1-16-16V48a16 16 0 0 1 16-16h192a16 16 0 0 1 16 16z"},child:[]}]})(a)}function Dt(a){return z({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:[]}]})(a)}function Ot(a){return z({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:[]}]})(a)}function Ht(a){return z({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:[]}]})(a)}function jt(a){return z({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M464 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h416c26.51 0 48-21.49 48-48V80c0-26.51-21.49-48-48-48zM224 416H64v-96h160v96zm0-160H64v-96h160v96zm224 160H288v-96h160v96zm0-160H288v-96h160v96z"},child:[]}]})(a)}function _t(a){return z({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:[]}]})(a)}function It(a){return z({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:[]}]})(a)}function Pt(a){return z({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:[]}]})(a)}const Ft=["😀","😁","😂","đŸ¤Ŗ","😃","😄","😅","😉","😊","😍","😘","😜","😎","đŸ˜ĸ","😭","😡","🤔","🙄","😇","đŸĨ°","🤩","🤗","😴","😋","đŸ˜Ŧ","🤤","đŸ˜ļ‍đŸŒĢī¸","😷","🤕","🤑","🤠","😈","đŸ‘ģ","💀","🤖","đŸļ","🐱","đŸŧ","🐸","đŸĻ„","🐷","đŸĩ","🐰","đŸ¯","đŸĻ","🐮","🌞","🌙","⭐","🌈","đŸ”Ĩ","💧","â„ī¸","⚡","â˜€ī¸","🌸","🌹","🍎","🍕","🍩","🍔","🍟","🍇","🍉","🍓","🍒","đŸĨ­","đŸĨ‘","🎉","🎂","🎁","🎈","đŸŽļ","đŸŽĩ","🏆","âšŊ","🏀","🏸","🏏","đŸ•šī¸","👋","🤚","đŸ–ī¸","✋","🖖","👍","👎","👌","🤌","🤏","✊","👊","🤛","🤜","â˜ī¸","👆","👇","👈","👉","🤟","🤘","🤙","🙌","👏","🙏","âœī¸","💅","🤲","👏","đŸĢļ","👐"],Ne=({exec:a,saveSelection:i,handleFileChange:d,handleFontSizeChange:m,handleFontFamilyChange:p,insertEmoji:w,handleLink:R,removeFormatting:A,visibleActions:E,className:x,style:S})=>{var B,O;const M=r.useRef(null),I=r.useRef(null),N=r.useRef(null),[P,F]=r.useState(!1),[_,H]=r.useState({x:0,y:0});r.useEffect(()=>{const h=C=>{!C.target.closest(".rte-emoji-popup")&&!C.target.closest("button[title='Emoji']")&&F(!1)};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[]);const q=h=>{var j;h.preventDefault();const C=h.currentTarget.dataset.command;if(C)switch(C){case"bold":case"italic":case"underline":case"insertUnorderedList":case"insertOrderedList":case"removeFormat":a(C);break;case"insertImage":{(j=M.current)==null||j.click();break}default:console.warn("Unknown command:",C)}},W=h=>{a("foreColor",h.target.value)},Q=h=>{a("backColor",h.target.value)},[k,T]=r.useState({bold:!1,italic:!1,underline:!1,unorderedList:!1,orderedList:!1,alignLeft:!1,alignCenter:!1,alignRight:!1,removeFormat:!1,link:!1,image:!1,emoji:!1,table:!1,color:!1,highlight:!1});return r.useEffect(()=>{const h=()=>{T({bold:document.queryCommandState("bold"),italic:document.queryCommandState("italic"),underline:document.queryCommandState("underline"),unorderedList:document.queryCommandState("insertUnorderedList"),orderedList:document.queryCommandState("insertOrderedList"),alignLeft:document.queryCommandState("justifyLeft"),alignCenter:document.queryCommandState("justifyCenter"),alignRight:document.queryCommandState("justifyRight"),removeFormat:document.queryCommandState("removeFormat"),link:document.queryCommandState("createLink"),image:document.queryCommandState("insertImage"),emoji:document.queryCommandState("insertEmoji"),table:document.queryCommandState("insertTable"),color:document.queryCommandState("foreColor"),highlight:document.queryCommandState("backColor")})};return document.addEventListener("selectionchange",h),()=>document.removeEventListener("selectionchange",h)},[]),r.createElement("div",{className:`rte-toolbar ${x||""}`,style:S},E.bold&&r.createElement("button",{"data-command":"bold",title:"Bold",onMouseDown:q,className:k.bold?"rte-active":""},r.createElement(zt,null)),E.italic&&r.createElement("button",{"data-command":"italic",title:"Italic",onMouseDown:q,className:k.italic?"rte-active":""},r.createElement(Tt,null)),E.underline&&r.createElement("button",{"data-command":"underline",title:"Underline",onMouseDown:q,className:k.underline?"rte-active":""},r.createElement(_t,null)),E.unorderedList&&r.createElement("button",{"data-command":"insertUnorderedList",onMouseDown:q,title:"UnorderedList",className:k.unorderedList?"rte-active":""},r.createElement(Ot,null)),E.orderedList&&r.createElement("button",{"data-command":"insertOrderedList",title:"OrderedList",onMouseDown:q,className:k.orderedList?"rte-active":""},r.createElement(At,null)),E.link&&r.createElement("button",{"data-command":"createLink",title:"Link",onClick:R,className:k.link?"rte-active":""},r.createElement(Dt,null)),E.removeFormat&&r.createElement("button",{"data-command":"Remove format",title:"removeFormat",onMouseDown:h=>{h.preventDefault(),i(),A()},className:k.removeFormat?"rte-active":""},r.createElement(Pt,null)),E.image&&r.createElement("button",{"data-command":"insertImage",title:"Image",onMouseDown:q,className:k.image?"rte-active":""},r.createElement(Mt,null)),r.createElement("input",{type:"file",accept:"image/*",ref:M,style:{display:"none"},onChange:d}),E.emoji&&r.createElement("div",{style:{position:"relative"}},r.createElement("button",{title:"Emoji",onMouseDown:h=>{h.preventDefault(),i();const C=h.currentTarget.getBoundingClientRect();H({x:C.left,y:C.bottom+8}),F(j=>!j)},className:k.emoji?"rte-active":""},r.createElement(Ht,null)),P&&ht.createPortal(r.createElement("div",{className:"rte-emoji-popup",style:{top:_.y,left:_.x}},Ft.map((h,C)=>r.createElement("span",{key:C,style:{fontSize:"20px",cursor:"pointer",textAlign:"center"},onMouseDown:j=>{j.preventDefault(),w(h),F(!1)}},h))),document.body)),E.color&&r.createElement("div",{style:{position:"relative"}},r.createElement("button",{title:"Text Color",onMouseDown:h=>{var C;h.preventDefault(),i(),(C=I.current)==null||C.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((B=I.current)==null?void 0:B.value)||"#000",fontSize:"18px"},className:k.color?"rte-active":""},r.createElement(It,null)),r.createElement("input",{ref:I,type:"color",defaultValue:"#000000",onChange:h=>{var C;W(h),((C=h.target.parentElement)==null?void 0:C.querySelector("button")).style.color=h.target.value},style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),E.highlight&&r.createElement("div",{style:{position:"relative"}},r.createElement("button",{title:"Highlight",onMouseDown:h=>{var C;h.preventDefault(),i(),(C=N.current)==null||C.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((O=N.current)==null?void 0:O.value)||"#000",fontSize:"18px"},className:k.highlight?"rte-active":""},r.createElement(Nt,null)),r.createElement("input",{ref:N,type:"color",onChange:h=>{var C;Q(h),((C=h.target.parentElement)==null?void 0:C.querySelector("button")).style.color=h.target.value},defaultValue:"#000000",style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),E.align&&r.createElement(r.Fragment,null,r.createElement("button",{title:"Align Left",onMouseDown:h=>h.preventDefault(),onClick:()=>a("justifyLeft"),className:k.alignLeft?"rte-active":""},r.createElement(kt,null)),r.createElement("button",{title:"Align Center",onMouseDown:h=>h.preventDefault(),onClick:()=>a("justifyCenter"),className:k.alignCenter?"rte-active":""},r.createElement(St,null)),r.createElement("button",{title:"Align Right",onMouseDown:h=>h.preventDefault(),onClick:()=>a("justifyRight"),className:k.alignRight?"rte-active":""},r.createElement(Lt,null))),E.table&&r.createElement("button",{title:"Insert Table",onMouseDown:h=>h.preventDefault(),onClick:()=>a("insertTable"),className:k.table?"rte-active":""},r.createElement(jt,null)),E.fontFamily&&r.createElement("select",{className:"rte-dropdown",defaultValue:"",onMouseDown:()=>i(),onChange:p},r.createElement("option",{value:"",disabled:!0},"Font Family"),r.createElement("option",{value:"Arial"},"Arial"),r.createElement("option",{value:"Georgia"},"Georgia"),r.createElement("option",{value:"Times New Roman"},"Times New Roman"),r.createElement("option",{value:"Courier New"},"Courier New"),r.createElement("option",{value:"Verdana"},"Verdana")),E.fontSize&&r.createElement("select",{className:"rte-dropdown rte-fontsize-dropdown",defaultValue:"",onMouseDown:()=>i(),onChange:m},r.createElement("option",{value:"",disabled:!0},"Font Size"),Array.from({length:16},(h,C)=>10+C).map(h=>r.createElement("option",{key:h,value:h},h,"px"))))},qt=({show:a,position:i,filtered:d,insertMention:m,onClose:p,query:w})=>{const R=r.useRef(null),[A,E]=r.useState(0);return r.useEffect(()=>{a&&E(0)},[a]),r.useEffect(()=>{const x=S=>{R.current&&!R.current.contains(S.target)&&p()};return a&&document.addEventListener("mousedown",x),()=>{document.removeEventListener("mousedown",x)}},[a,p]),r.useEffect(()=>{if(!a)return;const x=S=>{if(!(!a||d.length===0)&&(S.key==="ArrowDown"&&(S.preventDefault(),E(M=>Math.min(M+1,d.length-1))),S.key==="ArrowUp"&&(S.preventDefault(),E(M=>Math.max(M-1,0))),S.key==="Enter")){S.preventDefault();const M=d[A];M&&m(M)}};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[a,d,A]),r.useEffect(()=>{if(!R.current)return;const S=R.current.querySelectorAll("li")[A];S&&S.scrollIntoView({block:"nearest",behavior:"smooth"})},[A]),a?r.createElement("ul",{ref:R,className:"rte-popup",style:{top:i.y,left:i.x}},d.length>0?d.map(({name:x,value:S},M)=>{const I=x.toLowerCase(),N=w.toLowerCase(),P=I.indexOf(N);let F=x;if(P!==-1&&w.length>0){const _=P+w.length;F=x.substring(0,P)+`<span class="rte-highlight">${x.substring(P,_)}</span>`+x.substring(_)}return r.createElement("li",{key:S,onMouseDown:_=>{_.preventDefault(),m({name:x,value:S})},style:{padding:"6px 12px",cursor:"pointer",fontSize:"14px",background:M===A?"#dce8ff":"white"},dangerouslySetInnerHTML:{__html:F},onMouseEnter:()=>E(M)})}):r.createElement("li",{style:{padding:"6px 12px",color:"#999"}},"No matches")):null};function Me(a){return z({attr:{viewBox:"0 0 24 24"},child:[{tag:"g",attr:{id:"Circle_Minus"},child:[{tag:"g",attr:{},child:[{tag:"path",attr:{d:"M15,11.5h0a.5.5,0,0,1,0,1H9a.5.5,0,0,1,0-1Z"},child:[]},{tag:"path",attr:{d:"M12,21.934A9.933,9.933,0,1,1,21.932,12,9.945,9.945,0,0,1,12,21.934ZM12,3.068A8.933,8.933,0,1,0,20.932,12,8.944,8.944,0,0,0,12,3.068Z"},child:[]}]}]}]})(a)}function X(a){return z({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:[]}]}]}]})(a)}const Bt=({visible:a,x:i,y:d,onAction:m,onClose:p})=>{if(!a)return null;const w={top:d,left:i};return r.createElement("div",{style:w,className:"rte-table-menu",onMouseLeave:p},r.createElement("button",{onClick:()=>m("insertRowAbove")},r.createElement(X,null)," Insert row above"),r.createElement("button",{onClick:()=>m("insertRowBelow")},r.createElement(X,null)," Insert row below"),r.createElement("button",{onClick:()=>m("insertColLeft")},r.createElement(X,null)," Insert col left"),r.createElement("button",{onClick:()=>m("insertColRight")},r.createElement(X,null)," Insert col right"),r.createElement("button",{onClick:()=>m("deleteRow")},r.createElement(Me,null)," Delete row"),r.createElement("button",{onClick:()=>m("deleteCol")},r.createElement(Me,null)," Delete column"))},Te=({html:a,className:i,style:d})=>{const m=w=>{const R=w.target;if(R.tagName==="A"){w.preventDefault();const A=R.href;A&&window.open(A,"_blank","noopener,noreferrer")}},p=w=>{let R=w.replace(/{{\s*(.*?)\s*}}/g,(A,E)=>`<span style="color: blue">${E}</span>`);return R=R.replace(/#arrayData/g,""),R=R.replace(/\/arrayData/g,""),R};return r.createElement("div",{className:`rte-preview ${i||""}`,style:d,onClick:m,dangerouslySetInnerHTML:{__html:p(a)}})},Ut=({visible:a,linkData:i,onClose:d,onInsert:m})=>{const[p,w]=r.useState(""),[R,A]=r.useState(""),[E,x]=r.useState(""),[S,M]=r.useState("_self");if(r.useEffect(()=>{a?(w(i.url||""),A(i.text||""),x(i.title||""),M(i.target||"_self")):(w(""),A(""),x(""),M("_self"))},[a,i]),!a)return null;const I=()=>{m({url:p,text:R,title:E,target:S})};return r.createElement(r.Fragment,null,r.createElement("div",{className:"rte-link-modal-overlay",onClick:d}),r.createElement("div",{className:"rte-link-modal"},r.createElement("h4",{className:"rte-link-modal__title"},p?"Edit Link":"Insert Link"),r.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"URL",value:p,onChange:N=>w(N.target.value)}),r.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Text to Display",value:R,onChange:N=>A(N.target.value)}),r.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Title",value:E,onChange:N=>x(N.target.value)}),r.createElement("select",{className:"rte-link-modal__select",value:S,onChange:N=>M(N.target.value)},r.createElement("option",{value:"_self"},"Same tab"),r.createElement("option",{value:"_blank"},"New tab")),r.createElement("div",{className:"rte-link-modal__actions"},r.createElement("button",{className:"rte-link-modal__btn",onClick:d},"Cancel"),r.createElement("button",{className:"rte-link-modal__btn rte-link-modal__btn--ok",onClick:I},"OK"))))};function Ae(a){return Array.from(new Map(a.map(i=>[i.value,i])).values())}const Vt=({atSuggestions:a=[],showOutput:i=!1,showPreview:d=!1,toolbarConfig:m={link:!1,image:!1,emoji:!1,table:!1,color:!1,fontFamily:!1,fontSize:!1,highlight:!1},classNames:p={},styles:w={},handleGetHtml:R=()=>{},onChange:A=()=>{},value:E,onMentionSelect:x=()=>{},handleAddAttributes:S=()=>{}})=>{var ge,he,pe,ve,ye,Ee,we,Ce;const M=r.useRef(null),[I,N]=r.useState(E!=null&&E.length?E:" "),[P,F]=r.useState(""),[_,H]=r.useState(!1),[q,W]=r.useState({x:0,y:0}),[Q,k]=r.useState([]),T=r.useRef(null),B=r.useRef(null),[O,h]=r.useState({visible:!1,x:0,y:0}),[C,j]=r.useState(!1),K=r.useRef(null),[De,le]=r.useState({url:"",text:"",title:"",target:"_self"}),Oe={bold:!0,italic:!0,underline:!0,removeFormat:!0,unorderedList:!0,orderedList:!0,align:!0,link:(ge=m.link)!=null?ge:!1,image:(he=m.image)!=null?he:!1,emoji:(pe=m.emoji)!=null?pe:!1,table:(ve=m.table)!=null?ve:!1,color:(ye=m.color)!=null?ye:!1,fontFamily:(Ee=m.fontFamily)!=null?Ee:!1,fontSize:(we=m.fontSize)!=null?we:!1,highlight:(Ce=m.fontSize)!=null?Ce:!1},[He,J]=r.useState(""),[ce,G]=r.useState([]),D=()=>M.current,L=()=>{const e=je(),t=/^<div[^>]*style=["'][^"']*font-size\s*:\s*\d+px[^"']*["'][^>]*>/.test(e.trim());let n=e;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}>
2
- <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}>`),F(n),R==null||R(n);const o=rt(e);A(o);const s=Ve(),l=Ae(s);JSON.stringify(l)!==JSON.stringify(ce)&&(G(l),x(l))},je=()=>{const e=D();if(!e)return I;const t=e.cloneNode(!0);t.querySelectorAll("table div").forEach(o=>o.remove()),t.querySelectorAll(".rte-cell-highlight").forEach(o=>o.classList.remove("rte-cell-highlight"));let n=t.innerHTML;return n=_e(n),n},_e=e=>e.replace(/<tbody[^>]*>/g,"<tbody>{{#arrayData}}").replace(/<\/tbody>/g,"{{/arrayData}}</tbody>"),U=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return;const t=document.getElementById("rte-editor-body");if(!t)return;const n=e.getRangeAt(0);t.contains(n.startContainer)&&(T.current=n.cloneRange())},V=()=>{const e=window.getSelection();!e||!T.current||(e.removeAllRanges(),e.addRange(T.current))},ie=(e,t)=>{const n=window.getSelection();n&&n.rangeCount>0&&(T.current=n.getRangeAt(0)),V(),document.execCommand(e,!1,t),L()};r.useEffect(()=>{const e=D();if(!e||!E)return;const t=Ie(E);e.innerHTML=t,L()},[]);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,"");r.useEffect(()=>()=>{document.removeEventListener("mousemove",null),document.removeEventListener("mouseup",null)},[]),r.useEffect(()=>{S&&S(e=>{Ue(e)})},[]),r.useEffect(()=>{const e=D();if(!e)return;e.querySelectorAll("table").forEach(n=>{ne(n),n.querySelectorAll("th, td").forEach(s=>$(s))})},[]);const se=e=>{for(;e&&e.nodeName!=="LI";)e=e.parentNode;return e},de=e=>{var v;const t=window.getSelection();if(!(t!=null&&t.rangeCount))return;const n=t.getRangeAt(0),o=se(n.startContainer);let s,l;if(o){let y=o.querySelector(e);y||(y=document.createElement(e),y.style.margin="0",y.style.paddingLeft="20px",o.appendChild(y)),l=y,s=document.createElement("li"),s.textContent="​",l.appendChild(s)}else{document.execCommand(e==="ul"?"insertUnorderedList":"insertOrderedList");const y=D();if(l=y==null?void 0:y.querySelector(`${e}:last-child`),!l)return;s=l.querySelector("li:last-child")}const c=document.createRange();c.setStart(s,0),c.collapse(!0),t.removeAllRanges(),t.addRange(c),(v=D())==null||v.focus(),L()},ee=(e,t)=>{e==="insertOrderedList"?de("ol"):e==="insertUnorderedList"?de("ul"):e.startsWith("justify")?ot(e):ie(e,t),e==="insertTable"&&Ye()},Pe=e=>{const t=document.createElement("span");t.textContent="​",e.insertNode(t),e.setStartAfter(t),e.collapse(!0);const n=t.getBoundingClientRect();t.remove(),W({x:n.left,y:n.bottom+window.scrollY}),k(a||[]),H(!0),B.current=e.cloneRange()},Fe=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return null;const t=e.anchorNode;let n=e.anchorOffset;if(!t)return null;let o=t;for(o.nodeType!==Node.TEXT_NODE&&(o.childNodes&&o.childNodes[n]?o=o.childNodes[n]:o=t.previousSibling);o;){if(o.nodeType===Node.TEXT_NODE){const s=o.textContent||"",l=o===t?n:s.length,c=s.lastIndexOf("@",l-1);if(c!==-1){const v=document.createRange();return v.setStart(o,c),v.setEnd(o,l),v}}o=o.previousSibling}return null},qe=e=>{var l;const t=window.getSelection();if(!t)return;const n=Fe();n?(t.removeAllRanges(),t.addRange(n)):B.current&&(t.removeAllRanges(),t.addRange(B.current));const o=document.createElement("span");o.textContent=`{{${e.name}}}`,o.style.display="inline",o.setAttribute("data-mention",e.value||e.name||"");try{const c=t.rangeCount?t.getRangeAt(0):null;if(c)c.deleteContents(),c.insertNode(o);else{const g=document.createRange(),u=D();g.selectNodeContents(u),g.collapse(!1),g.insertNode(o)}const v=document.createTextNode(" ");o.after(v);const y=document.createRange();y.setStartAfter(v),y.collapse(!0),t.removeAllRanges(),t.addRange(y)}catch(c){console.error("insertMention error:",c)}let s=Ae([...ce,e]);G(s),x(s),H(!1),(l=D())==null||l.focus(),L()},Be=e=>{const t=D();if(!t)return;let n=null;T.current&&t.contains(T.current.startContainer)?n=T.current.cloneRange():(n=document.createRange(),n.selectNodeContents(t),n.collapse(!1));const o=window.getSelection();if(!o)return;o.removeAllRanges(),o.addRange(n);const s=document.createElement("span");s.textContent=`{{${e.name}}}`,s.style.display="inline",s.setAttribute("data-mention",e.value||e.name),n.insertNode(s);const l=document.createTextNode(" ");s.after(l);const c=document.createRange();c.setStartAfter(l),c.collapse(!0),o.removeAllRanges(),o.addRange(c),T.current=c.cloneRange(),t.focus()},Ue=e=>{e.forEach(t=>Be(t)),G(t=>{const n=[...t,...e],o=Array.from(new Map(n.map(s=>[s.name,s])).values());return x(o),o}),L()},Ve=()=>{const e=D();if(!e)return[];const t=e.querySelectorAll("span[data-mention]"),n=[];return t.forEach(o=>{const s=o.getAttribute("data-mention")||"",c=(o.textContent||"").match(/{{(.+?)}}/);c&&n.push({name:c[1],value:s})}),n},$e=e=>{var n,o,s;const t=e.key.toLowerCase();if((e.ctrlKey||e.metaKey)&&["b","i","u"].includes(t)&&(e.preventDefault(),ee(t==="b"?"bold":t==="i"?"italic":t==="u"?"underline":"")),e.shiftKey&&e.key==="2"&&e.preventDefault(),e.key==="Enter"){const l=window.getSelection(),c=l!=null&&l.anchorNode?se(l.anchorNode):null;if(!c)return;if(((n=c.textContent)==null?void 0:n.replace(/\u200B/g,"").trim())===""){e.preventDefault();const y=c.parentElement,g=y==null?void 0:y.closest("li");if(g){y==null||y.removeChild(c);const u=document.createElement("p");u.innerHTML="<br />",(o=g.parentElement)==null||o.insertBefore(u,g.nextSibling);const f=document.createRange();f.setStart(u,0),f.collapse(!0),l==null||l.removeAllRanges(),l==null||l.addRange(f)}else{const u=c.closest("ul, ol");if(u){const f=document.createElement("p");f.innerHTML="<br />",(s=u.parentElement)==null||s.insertBefore(f,u.nextSibling),u.removeChild(c);const b=document.createRange();b.setStart(f,0),b.collapse(!0),l==null||l.removeAllRanges(),l==null||l.addRange(b)}}L()}}},We=e=>{if(e.data==="@"){const n=window.getSelection();if(!(n!=null&&n.rangeCount))return;const o=n.anchorNode;if(te(o))return;setTimeout(()=>{Pe(n.getRangeAt(0)),J(""),k(a),H(!0)},0);return}if(_){setTimeout(()=>ue(),0);return}},te=e=>{if(!e)return!1;let t=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;for(;t;){if(t.tagName==="TH")return!0;t=t.parentElement}return!1},ue=()=>{L();const e=window.getSelection();if(!e||!e.anchorNode)return;if(te(e.anchorNode)){H(!1);return}let t=e.anchorNode.textContent||"";t=t.replace(/\u00A0/g," ");const n=t.match(/@([^\n]*)$/);if(!n){H(!1);return}const o=n[1].trim().toLowerCase();J(o);const s=a.filter(l=>l.name.toLowerCase().includes(o));s.length>0?(k(s),H(!0)):H(!1)},Ke=e=>{var o;const t=(o=e.target.files)==null?void 0:o[0];if(!t)return;const n=new FileReader;n.onload=s=>{var b;const l=(b=s.target)==null?void 0:b.result;V();const c=window.getSelection();let v=c&&c.rangeCount?c.getRangeAt(0):null;const y=document.createElement("img");y.src=l,y.alt=t.name||"image",y.className="rte-inserted-image",y.contentEditable="true";const g=D();if(!v||!g){g==null||g.appendChild(y);const be=document.createTextNode(" ");g==null||g.appendChild(be);const re=document.createRange();re.setStartAfter(be),re.collapse(!0),c==null||c.removeAllRanges(),c==null||c.addRange(re),g==null||g.focus(),L(),e.target.value="";return}v.deleteContents(),v.insertNode(y);const u=document.createTextNode(" ");y.after(u);const f=document.createRange();f.setStartAfter(u),f.collapse(!0),c.removeAllRanges(),c.addRange(f),g.focus(),L(),e.target.value=""},n.readAsDataURL(t)},Xe=e=>{var s;V();const t=window.getSelection();if(!(t!=null&&t.rangeCount))return;const n=t.getRangeAt(0),o=document.createTextNode(e);n.insertNode(o),n.setStartAfter(o),n.collapse(!0),t.removeAllRanges(),t.addRange(n),(s=D())==null||s.focus(),L()},Ye=()=>{var g;st(),V();const e=document.createElement("table");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);const t=document.createElement("thead");p.thead&&t.classList.add(p.thead);const n=document.createElement("tbody");p.tbody&&n.classList.add(p.tbody);const o=document.createElement("tr");p.tr&&o.classList.add(p.tr);const s=document.createElement("tr");p.tr&&s.classList.add(p.tr);for(let u=0;u<2;u++){const f=document.createElement("th");f.textContent="",f.style.border="1px solid #999",f.style.padding="4px",f.style.position="relative",f.style.backgroundColor="lightgray",f.style.height="20px",p.th&&f.classList.add(p.th);const b=document.createElement("td");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),$(f),$(b),o.appendChild(f),s.appendChild(b)}t.appendChild(o),n.appendChild(s),e.appendChild(t),e.appendChild(n),ne(e);const l=window.getSelection();if(!(l!=null&&l.rangeCount))return;const c=l.getRangeAt(0);c.collapse(!1),c.insertNode(e);const v=document.createElement("p");v.innerHTML="<br/>",e.after(v);const y=document.createRange();y.setStart(v,0),y.collapse(!0),l.removeAllRanges(),l.addRange(y),(g=D())==null||g.focus(),L()},ne=e=>{const t=document.createElement("div");Object.assign(t.style,{position:"absolute",width:"14px",height:"14px",right:"0",bottom:"0",background:"rgba(0,0,0,0.25)",cursor:"nwse-resize",zIndex:"20",borderRadius:"2px"}),t.style.userSelect="none",t.contentEditable="false";let n=0,o=0,s=0,l=0;t.addEventListener("mousedown",c=>{c.preventDefault(),n=c.clientX,o=c.clientY;const v=e.getBoundingClientRect();s=v.width,l=v.height;const y=u=>{const f=Math.max(100,s+(u.clientX-n)),b=Math.max(20,l+(u.clientY-o));e.style.width=`${f}px`,e.style.height=`${b}px`,L()},g=()=>{document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",g),L()};document.addEventListener("mousemove",y),document.addEventListener("mouseup",g)}),e.appendChild(t)},$=e=>{const t=document.createElement("div"),n=document.createElement("div");Object.assign(t.style,{position:"absolute",right:"0",top:"0",width:"4px",height:"100%",cursor:"col-resize",background:"rgba(0,0,0,0.15)",zIndex:"10",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none",pointerEvents:"auto"}),t.contentEditable="false",Object.assign(n.style,{position:"absolute",bottom:"0",left:"0",width:"100%",height:"4px",cursor:"row-resize",background:"rgba(0,0,0,0.15)",zIndex:"10",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none",pointerEvents:"auto"}),n.contentEditable="false",Ze(e,t,n),e.appendChild(t),e.appendChild(n)},Ze=(e,t,n)=>{let o=0,s=0,l=0,c=0;t.addEventListener("mousedown",u=>{u.preventDefault(),o=u.clientX,l=e.offsetWidth,document.addEventListener("mousemove",v),document.addEventListener("mouseup",g)}),n.addEventListener("mousedown",u=>{u.preventDefault(),s=u.clientY,c=e.offsetHeight,document.addEventListener("mousemove",y),document.addEventListener("mouseup",g)});const v=u=>{const f=l+(u.clientX-o);e.style.width=`${Math.max(30,f)}px`,L()},y=u=>{const f=c+(u.clientY-s);e.style.height=`${Math.max(20,f)}px`,L()},g=()=>{document.removeEventListener("mousemove",v),document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",g),L()}},Qe=e=>{const n=e.target.closest("td, th");n&&(e.preventDefault(),document.querySelectorAll(".rte-cell-highlight").forEach(o=>o.classList.remove("rte-cell-highlight")),n.classList.add("rte-cell-highlight"),h({visible:!0,x:e.clientX,y:e.clientY,cell:n}))},me=()=>{document.querySelectorAll(".rte-cell-highlight").forEach(e=>e.classList.remove("rte-cell-highlight"))},Je=e=>{if(!O.cell)return;const t=O.cell.closest("table"),n=O.cell.cellIndex,o=O.cell.parentElement.rowIndex,s=l=>{const c=l.tagName.toLowerCase(),v=document.createElement(c);return v.textContent="",v.style.cssText=l.style.cssText,$(v),v};switch(e){case"insertRowAbove":{const l=t.rows[o],c=t.insertRow(o);Array.from(l.cells).forEach(v=>{c.appendChild(s(v))});break}case"insertRowBelow":{const l=t.rows[o],c=t.insertRow(o+1);Array.from(l.cells).forEach(v=>{c.appendChild(s(v))});break}case"insertColLeft":{Array.from(t.rows).forEach(l=>{const c=l.cells[n];l.insertBefore(s(c),c)});break}case"insertColRight":{Array.from(t.rows).forEach(l=>{const c=l.cells[n];l.insertBefore(s(c),c.nextSibling)});break}case"deleteRow":t.rows.length>1&&t.deleteRow(o);break;case"deleteCol":Array.from(t.rows).forEach(l=>{l.cells[n]&&l.deleteCell(n)});break}L(),h(oe(ae({},O),{visible:!1})),me()},Ge=()=>{U(),K.current=T.current,le({url:"",text:"",title:"",target:"_self"}),j(!0)},et=e=>{const t=window.getSelection();if(!t||!K.current)return;t.removeAllRanges(),t.addRange(K.current);let n=e.url.trim();/^https?:\/\//i.test(n)||(n="https://"+n);const o=document.createElement("a");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";const s=t.getRangeAt(0);s.deleteContents(),s.insertNode(o);const l=document.createTextNode(" ");o.after(l);const c=document.createRange();c.setStartAfter(l),c.collapse(!0),t.removeAllRanges(),t.addRange(c),j(!1),L()},tt=e=>{const t=e.target;if(t.tagName==="A"){const n=t;if(e.ctrlKey||e.metaKey){window.open(n.href,"_blank","noopener,noreferrer");return}e.preventDefault();const o=document.createRange();o.selectNode(n),K.current=o,le({url:n.href,text:n.textContent||n.href,title:n.title,target:n.target}),j(!0)}},nt=()=>{const e=D();if(!e)return;const t=window.getSelection();if((!t||t.rangeCount===0)&&T.current){const u=window.getSelection();u==null||u.removeAllRanges(),u==null||u.addRange(T.current)}const n=window.getSelection();if(!n||n.rangeCount===0)return;const o=n.getRangeAt(0);V(),document.execCommand("removeFormat",!1);const s=o.cloneContents(),l=document.createElement("div");l.appendChild(s);const c=document.createTreeWalker(l,NodeFilter.SHOW_ELEMENT,null),v=[];for(;c.nextNode();){const u=c.currentNode,f=u.tagName.toUpperCase(),b=u.getAttribute&&u.getAttribute("data-mention")!==null;f!=="A"&&!b&&v.push(u)}for(let u=v.length-1;u>=0;u--){const f=v[u],b=f.parentNode;if(b){for(;f.firstChild;)b.insertBefore(f.firstChild,f);b.removeChild(f)}}l.querySelectorAll("[style]").forEach(u=>u.removeAttribute("style")),o.deleteContents();const y=document.createDocumentFragment();for(;l.firstChild;)y.appendChild(l.firstChild);o.insertNode(y);const g=document.createRange();g.setStartAfter(o.endContainer.nodeType===Node.TEXT_NODE?o.endContainer:o.startContainer),g.collapse(!0),n.removeAllRanges(),n.addRange(g),e.normalize(),L()},rt=e=>{var o;let t=e;t=t.replace(/{{#arrayData\d*}}/g,""),t=t.replace(/{{\/arrayData\d*}}/g,"");const n=document.createElement("div");return n.innerHTML=t,n.querySelectorAll("br").forEach(s=>{s.replaceWith(`
1
+ "use strict";var dt=Object.defineProperty,ut=Object.defineProperties;var mt=Object.getOwnPropertyDescriptors;var Re=Object.getOwnPropertySymbols;var ft=Object.prototype.hasOwnProperty,gt=Object.prototype.propertyIsEnumerable;var xe=(a,i,d)=>i in a?dt(a,i,{enumerable:!0,configurable:!0,writable:!0,value:d}):a[i]=d,ae=(a,i)=>{for(var d in i||(i={}))ft.call(i,d)&&xe(a,d,i[d]);if(Re)for(var d of Re(i))gt.call(i,d)&&xe(a,d,i[d]);return a},oe=(a,i)=>ut(a,mt(i));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react"),ht=require("react-dom");function pt(a){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const d in a)if(d!=="default"){const m=Object.getOwnPropertyDescriptor(a,d);Object.defineProperty(i,d,m.get?m:{enumerable:!0,get:()=>a[d]})}}return i.default=a,Object.freeze(i)}const vt=pt(r);window.React=vt;var ze={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Se=r.createContext&&r.createContext(ze),yt=["attr","size","title"];function Et(a,i){if(a==null)return{};var d=wt(a,i),m,p;if(Object.getOwnPropertySymbols){var w=Object.getOwnPropertySymbols(a);for(p=0;p<w.length;p++)m=w[p],!(i.indexOf(m)>=0)&&Object.prototype.propertyIsEnumerable.call(a,m)&&(d[m]=a[m])}return d}function wt(a,i){if(a==null)return{};var d={};for(var m in a)if(Object.prototype.hasOwnProperty.call(a,m)){if(i.indexOf(m)>=0)continue;d[m]=a[m]}return d}function Y(){return Y=Object.assign?Object.assign.bind():function(a){for(var i=1;i<arguments.length;i++){var d=arguments[i];for(var m in d)Object.prototype.hasOwnProperty.call(d,m)&&(a[m]=d[m])}return a},Y.apply(this,arguments)}function Le(a,i){var d=Object.keys(a);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(a);i&&(m=m.filter(function(p){return Object.getOwnPropertyDescriptor(a,p).enumerable})),d.push.apply(d,m)}return d}function Z(a){for(var i=1;i<arguments.length;i++){var d=arguments[i]!=null?arguments[i]:{};i%2?Le(Object(d),!0).forEach(function(m){Ct(a,m,d[m])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(d)):Le(Object(d)).forEach(function(m){Object.defineProperty(a,m,Object.getOwnPropertyDescriptor(d,m))})}return a}function Ct(a,i,d){return i=bt(i),i in a?Object.defineProperty(a,i,{value:d,enumerable:!0,configurable:!0,writable:!0}):a[i]=d,a}function bt(a){var i=Rt(a,"string");return typeof i=="symbol"?i:i+""}function Rt(a,i){if(typeof a!="object"||!a)return a;var d=a[Symbol.toPrimitive];if(d!==void 0){var m=d.call(a,i);if(typeof m!="object")return m;throw new TypeError("@@toPrimitive must return a primitive value.")}return(i==="string"?String:Number)(a)}function ke(a){return a&&a.map((i,d)=>r.createElement(i.tag,Z({key:d},i.attr),ke(i.child)))}function k(a){return i=>r.createElement(xt,Y({attr:Z({},a.attr)},i),ke(a.child))}function xt(a){var i=d=>{var{attr:m,size:p,title:w}=a,R=Et(a,yt),M=p||d.size||"1em",E;return d.className&&(E=d.className),a.className&&(E=(E?E+" ":"")+a.className),r.createElement("svg",Y({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},d.attr,m,R,{className:E,style:Z(Z({color:a.color||d.color},d.style),a.style),height:M,width:M,xmlns:"http://www.w3.org/2000/svg"}),w&&r.createElement("title",null,w),a.children)};return Se!==void 0?r.createElement(Se.Consumer,null,d=>i(d)):i(ze)}function St(a){return k({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:[]}]})(a)}function Lt(a){return k({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M448 64c0 17.7-14.3 32-32 32L192 96c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zm0 256c0 17.7-14.3 32-32 32l-224 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zM0 192c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 224c-17.7 0-32-14.3-32-32zM448 448c0 17.7-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32s14.3-32 32-32l384 0c17.7 0 32 14.3 32 32z"},child:[]}]})(a)}function At(a){return k({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M0 96C0 60.7 28.7 32 64 32l384 0c35.3 0 64 28.7 64 64l0 320c0 35.3-28.7 64-64 64L64 480c-35.3 0-64-28.7-64-64L0 96zM323.8 202.5c-4.5-6.6-11.9-10.5-19.8-10.5s-15.4 3.9-19.8 10.5l-87 127.6L170.7 297c-4.6-5.7-11.5-9-18.7-9s-14.2 3.3-18.7 9l-64 80c-5.8 7.2-6.9 17.1-2.9 25.4s12.4 13.6 21.6 13.6l96 0 32 0 208 0c8.9 0 17.1-4.9 21.2-12.8s3.6-17.4-1.4-24.7l-120-176zM112 192a48 48 0 1 0 0-96 48 48 0 1 0 0 96z"},child:[]}]})(a)}function Mt(a){return k({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M24 56c0-13.3 10.7-24 24-24l32 0c13.3 0 24 10.7 24 24l0 120 16 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-80 0c-13.3 0-24-10.7-24-24s10.7-24 24-24l16 0 0-96-8 0C34.7 80 24 69.3 24 56zM86.7 341.2c-6.5-7.4-18.3-6.9-24 1.2L51.5 357.9c-7.7 10.8-22.7 13.3-33.5 5.6s-13.3-22.7-5.6-33.5l11.1-15.6c23.7-33.2 72.3-35.6 99.2-4.9c21.3 24.4 20.8 60.9-1.1 84.7L86.8 432l33.2 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-88 0c-9.5 0-18.2-5.6-22-14.4s-2.1-18.9 4.3-25.9l72-78c5.3-5.8 5.4-14.6 .3-20.5zM224 64l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 160l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 160l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32z"},child:[]}]})(a)}function zt(a){return k({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M12.83 352h262.34A12.82 12.82 0 0 0 288 339.17v-38.34A12.82 12.82 0 0 0 275.17 288H12.83A12.82 12.82 0 0 0 0 300.83v38.34A12.82 12.82 0 0 0 12.83 352zm0-256h262.34A12.82 12.82 0 0 0 288 83.17V44.83A12.82 12.82 0 0 0 275.17 32H12.83A12.82 12.82 0 0 0 0 44.83v38.34A12.82 12.82 0 0 0 12.83 96zM432 160H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0 256H16a16 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:[]}]})(a)}function kt(a){return k({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M333.49 238a122 122 0 0 0 27-65.21C367.87 96.49 308 32 233.42 32H34a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h31.87v288H34a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h209.32c70.8 0 134.14-51.75 141-122.4 4.74-48.45-16.39-92.06-50.83-119.6zM145.66 112h87.76a48 48 0 0 1 0 96h-87.76zm87.76 288h-87.76V288h87.76a56 56 0 0 1 0 112z"},child:[]}]})(a)}function Nt(a){return k({attr:{viewBox:"0 0 544 512"},child:[{tag:"path",attr:{d:"M0 479.98L99.92 512l35.45-35.45-67.04-67.04L0 479.98zm124.61-240.01a36.592 36.592 0 0 0-10.79 38.1l13.05 42.83-50.93 50.94 96.23 96.23 50.86-50.86 42.74 13.08c13.73 4.2 28.65-.01 38.15-10.78l35.55-41.64-173.34-173.34-41.52 35.44zm403.31-160.7l-63.2-63.2c-20.49-20.49-53.38-21.52-75.12-2.35L190.55 183.68l169.77 169.78L530.27 154.4c19.18-21.74 18.15-54.63-2.35-75.13z"},child:[]}]})(a)}function Tt(a){return k({attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M320 48v32a16 16 0 0 1-16 16h-62.76l-80 320H208a16 16 0 0 1 16 16v32a16 16 0 0 1-16 16H16a16 16 0 0 1-16-16v-32a16 16 0 0 1 16-16h62.76l80-320H112a16 16 0 0 1-16-16V48a16 16 0 0 1 16-16h192a16 16 0 0 1 16 16z"},child:[]}]})(a)}function Dt(a){return k({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:[]}]})(a)}function Ot(a){return k({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:[]}]})(a)}function Ht(a){return k({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:[]}]})(a)}function jt(a){return k({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M464 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h416c26.51 0 48-21.49 48-48V80c0-26.51-21.49-48-48-48zM224 416H64v-96h160v96zm0-160H64v-96h160v96zm224 160H288v-96h160v96zm0-160H288v-96h160v96z"},child:[]}]})(a)}function _t(a){return k({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:[]}]})(a)}function It(a){return k({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:[]}]})(a)}function Pt(a){return k({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:[]}]})(a)}const Ft=["😀","😁","😂","đŸ¤Ŗ","😃","😄","😅","😉","😊","😍","😘","😜","😎","đŸ˜ĸ","😭","😡","🤔","🙄","😇","đŸĨ°","🤩","🤗","😴","😋","đŸ˜Ŧ","🤤","đŸ˜ļ‍đŸŒĢī¸","😷","🤕","🤑","🤠","😈","đŸ‘ģ","💀","🤖","đŸļ","🐱","đŸŧ","🐸","đŸĻ„","🐷","đŸĩ","🐰","đŸ¯","đŸĻ","🐮","🌞","🌙","⭐","🌈","đŸ”Ĩ","💧","â„ī¸","⚡","â˜€ī¸","🌸","🌹","🍎","🍕","🍩","🍔","🍟","🍇","🍉","🍓","🍒","đŸĨ­","đŸĨ‘","🎉","🎂","🎁","🎈","đŸŽļ","đŸŽĩ","🏆","âšŊ","🏀","🏸","🏏","đŸ•šī¸","👋","🤚","đŸ–ī¸","✋","🖖","👍","👎","👌","🤌","🤏","✊","👊","🤛","🤜","â˜ī¸","👆","👇","👈","👉","🤟","🤘","🤙","🙌","👏","🙏","âœī¸","💅","🤲","👏","đŸĢļ","👐"],Ne=({exec:a,saveSelection:i,handleFileChange:d,handleFontSizeChange:m,handleFontFamilyChange:p,insertEmoji:w,handleLink:R,removeFormatting:M,visibleActions:E,className:x,style:S})=>{var B,O;const A=r.useRef(null),I=r.useRef(null),N=r.useRef(null),[P,F]=r.useState(!1),[_,H]=r.useState({x:0,y:0});r.useEffect(()=>{const h=C=>{!C.target.closest(".rte-emoji-popup")&&!C.target.closest("button[title='Emoji']")&&F(!1)};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[]);const q=h=>{var j;h.preventDefault();const C=h.currentTarget.dataset.command;if(C)switch(C){case"bold":case"italic":case"underline":case"insertUnorderedList":case"insertOrderedList":case"removeFormat":a(C);break;case"insertImage":{(j=A.current)==null||j.click();break}default:console.warn("Unknown command:",C)}},W=h=>{a("foreColor",h.target.value)},Q=h=>{a("backColor",h.target.value)},[z,T]=r.useState({bold:!1,italic:!1,underline:!1,unorderedList:!1,orderedList:!1,alignLeft:!1,alignCenter:!1,alignRight:!1,removeFormat:!1,link:!1,image:!1,emoji:!1,table:!1,color:!1,highlight:!1});return r.useEffect(()=>{const h=()=>{T({bold:document.queryCommandState("bold"),italic:document.queryCommandState("italic"),underline:document.queryCommandState("underline"),unorderedList:document.queryCommandState("insertUnorderedList"),orderedList:document.queryCommandState("insertOrderedList"),alignLeft:document.queryCommandState("justifyLeft"),alignCenter:document.queryCommandState("justifyCenter"),alignRight:document.queryCommandState("justifyRight"),removeFormat:document.queryCommandState("removeFormat"),link:document.queryCommandState("createLink"),image:document.queryCommandState("insertImage"),emoji:document.queryCommandState("insertEmoji"),table:document.queryCommandState("insertTable"),color:document.queryCommandState("foreColor"),highlight:document.queryCommandState("backColor")})};return document.addEventListener("selectionchange",h),()=>document.removeEventListener("selectionchange",h)},[]),r.createElement("div",{className:`rte-toolbar ${x||""}`,style:S},E.bold&&r.createElement("button",{"data-command":"bold",title:"Bold",onMouseDown:q,className:z.bold?"rte-active":""},r.createElement(kt,null)),E.italic&&r.createElement("button",{"data-command":"italic",title:"Italic",onMouseDown:q,className:z.italic?"rte-active":""},r.createElement(Tt,null)),E.underline&&r.createElement("button",{"data-command":"underline",title:"Underline",onMouseDown:q,className:z.underline?"rte-active":""},r.createElement(_t,null)),E.unorderedList&&r.createElement("button",{"data-command":"insertUnorderedList",onMouseDown:q,title:"UnorderedList",className:z.unorderedList?"rte-active":""},r.createElement(Ot,null)),E.orderedList&&r.createElement("button",{"data-command":"insertOrderedList",title:"OrderedList",onMouseDown:q,className:z.orderedList?"rte-active":""},r.createElement(Mt,null)),E.link&&r.createElement("button",{"data-command":"createLink",title:"Link",onClick:R,className:z.link?"rte-active":""},r.createElement(Dt,null)),E.removeFormat&&r.createElement("button",{"data-command":"Remove format",title:"removeFormat",onMouseDown:h=>{h.preventDefault(),i(),M()},className:z.removeFormat?"rte-active":""},r.createElement(Pt,null)),E.image&&r.createElement("button",{"data-command":"insertImage",title:"Image",onMouseDown:q,className:z.image?"rte-active":""},r.createElement(At,null)),r.createElement("input",{type:"file",accept:"image/*",ref:A,style:{display:"none"},onChange:d}),E.emoji&&r.createElement("div",{style:{position:"relative"}},r.createElement("button",{title:"Emoji",onMouseDown:h=>{h.preventDefault(),i();const C=h.currentTarget.getBoundingClientRect();H({x:C.left,y:C.bottom+8}),F(j=>!j)},className:z.emoji?"rte-active":""},r.createElement(Ht,null)),P&&ht.createPortal(r.createElement("div",{className:"rte-emoji-popup",style:{top:_.y,left:_.x}},Ft.map((h,C)=>r.createElement("span",{key:C,style:{fontSize:"20px",cursor:"pointer",textAlign:"center"},onMouseDown:j=>{j.preventDefault(),w(h),F(!1)}},h))),document.body)),E.color&&r.createElement("div",{style:{position:"relative"}},r.createElement("button",{title:"Text Color",onMouseDown:h=>{var C;h.preventDefault(),i(),(C=I.current)==null||C.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((B=I.current)==null?void 0:B.value)||"#000",fontSize:"18px"},className:z.color?"rte-active":""},r.createElement(It,null)),r.createElement("input",{ref:I,type:"color",defaultValue:"#000000",onChange:h=>{var C;W(h),((C=h.target.parentElement)==null?void 0:C.querySelector("button")).style.color=h.target.value},style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),E.highlight&&r.createElement("div",{style:{position:"relative"}},r.createElement("button",{title:"Highlight",onMouseDown:h=>{var C;h.preventDefault(),i(),(C=N.current)==null||C.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((O=N.current)==null?void 0:O.value)||"#000",fontSize:"18px"},className:z.highlight?"rte-active":""},r.createElement(Nt,null)),r.createElement("input",{ref:N,type:"color",onChange:h=>{var C;Q(h),((C=h.target.parentElement)==null?void 0:C.querySelector("button")).style.color=h.target.value},defaultValue:"#000000",style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),E.align&&r.createElement(r.Fragment,null,r.createElement("button",{title:"Align Left",onMouseDown:h=>h.preventDefault(),onClick:()=>a("justifyLeft"),className:z.alignLeft?"rte-active":""},r.createElement(zt,null)),r.createElement("button",{title:"Align Center",onMouseDown:h=>h.preventDefault(),onClick:()=>a("justifyCenter"),className:z.alignCenter?"rte-active":""},r.createElement(St,null)),r.createElement("button",{title:"Align Right",onMouseDown:h=>h.preventDefault(),onClick:()=>a("justifyRight"),className:z.alignRight?"rte-active":""},r.createElement(Lt,null))),E.table&&r.createElement("button",{title:"Insert Table",onMouseDown:h=>h.preventDefault(),onClick:()=>a("insertTable"),className:z.table?"rte-active":""},r.createElement(jt,null)),E.fontFamily&&r.createElement("select",{className:"rte-dropdown",defaultValue:"",onMouseDown:()=>i(),onChange:p},r.createElement("option",{value:"",disabled:!0},"Font Family"),r.createElement("option",{value:"Arial"},"Arial"),r.createElement("option",{value:"Georgia"},"Georgia"),r.createElement("option",{value:"Times New Roman"},"Times New Roman"),r.createElement("option",{value:"Courier New"},"Courier New"),r.createElement("option",{value:"Verdana"},"Verdana")),E.fontSize&&r.createElement("select",{className:"rte-dropdown rte-fontsize-dropdown",defaultValue:"",onMouseDown:()=>i(),onChange:m},r.createElement("option",{value:"",disabled:!0},"Font Size"),Array.from({length:16},(h,C)=>10+C).map(h=>r.createElement("option",{key:h,value:h},h,"px"))))},qt=({show:a,position:i,filtered:d,insertMention:m,onClose:p,query:w})=>{const R=r.useRef(null),[M,E]=r.useState(0);return r.useEffect(()=>{a&&E(0)},[a]),r.useEffect(()=>{const x=S=>{R.current&&!R.current.contains(S.target)&&p()};return a&&document.addEventListener("mousedown",x),()=>{document.removeEventListener("mousedown",x)}},[a,p]),r.useEffect(()=>{if(!a)return;const x=S=>{if(!(!a||d.length===0)&&(S.key==="ArrowDown"&&(S.preventDefault(),E(A=>Math.min(A+1,d.length-1))),S.key==="ArrowUp"&&(S.preventDefault(),E(A=>Math.max(A-1,0))),S.key==="Enter")){S.preventDefault();const A=d[M];A&&m(A)}};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[a,d,M]),r.useEffect(()=>{if(!R.current)return;const S=R.current.querySelectorAll("li")[M];S&&S.scrollIntoView({block:"nearest",behavior:"smooth"})},[M]),a?r.createElement("ul",{ref:R,className:"rte-popup",style:{top:i.y,left:i.x}},d.length>0?d.map(({name:x,value:S},A)=>{const I=x.toLowerCase(),N=w.toLowerCase(),P=I.indexOf(N);let F=x;if(P!==-1&&w.length>0){const _=P+w.length;F=x.substring(0,P)+`<span class="rte-highlight">${x.substring(P,_)}</span>`+x.substring(_)}return r.createElement("li",{key:S,onMouseDown:_=>{_.preventDefault(),m({name:x,value:S})},style:{padding:"6px 12px",cursor:"pointer",fontSize:"14px",background:A===M?"#dce8ff":"white"},dangerouslySetInnerHTML:{__html:F},onMouseEnter:()=>E(A)})}):r.createElement("li",{style:{padding:"6px 12px",color:"#999"}},"No matches")):null};function Ae(a){return k({attr:{viewBox:"0 0 24 24"},child:[{tag:"g",attr:{id:"Circle_Minus"},child:[{tag:"g",attr:{},child:[{tag:"path",attr:{d:"M15,11.5h0a.5.5,0,0,1,0,1H9a.5.5,0,0,1,0-1Z"},child:[]},{tag:"path",attr:{d:"M12,21.934A9.933,9.933,0,1,1,21.932,12,9.945,9.945,0,0,1,12,21.934ZM12,3.068A8.933,8.933,0,1,0,20.932,12,8.944,8.944,0,0,0,12,3.068Z"},child:[]}]}]}]})(a)}function X(a){return k({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:[]}]}]}]})(a)}const Bt=({visible:a,x:i,y:d,onAction:m,onClose:p})=>{if(!a)return null;const w={top:d,left:i};return r.createElement("div",{style:w,className:"rte-table-menu",onMouseLeave:p},r.createElement("button",{onClick:()=>m("insertRowAbove")},r.createElement(X,null)," Insert row above"),r.createElement("button",{onClick:()=>m("insertRowBelow")},r.createElement(X,null)," Insert row below"),r.createElement("button",{onClick:()=>m("insertColLeft")},r.createElement(X,null)," Insert col left"),r.createElement("button",{onClick:()=>m("insertColRight")},r.createElement(X,null)," Insert col right"),r.createElement("button",{onClick:()=>m("deleteRow")},r.createElement(Ae,null)," Delete row"),r.createElement("button",{onClick:()=>m("deleteCol")},r.createElement(Ae,null)," Delete column"))},Te=({html:a,className:i,style:d})=>{const m=w=>{const R=w.target;if(R.tagName==="A"){w.preventDefault();const M=R.href;M&&window.open(M,"_blank","noopener,noreferrer")}},p=w=>{let R=w.replace(/{{\s*(.*?)\s*}}/g,(M,E)=>`<span style="color: blue">${E}</span>`);return R=R.replace(/#arrayData/g,""),R=R.replace(/\/arrayData/g,""),R};return r.createElement("div",{className:`rte-preview ${i||""}`,style:d,onClick:m,dangerouslySetInnerHTML:{__html:p(a)}})},Ut=({visible:a,linkData:i,onClose:d,onInsert:m})=>{const[p,w]=r.useState(""),[R,M]=r.useState(""),[E,x]=r.useState(""),[S,A]=r.useState("_self");if(r.useEffect(()=>{a?(w(i.url||""),M(i.text||""),x(i.title||""),A(i.target||"_self")):(w(""),M(""),x(""),A("_self"))},[a,i]),!a)return null;const I=()=>{m({url:p,text:R,title:E,target:S})};return r.createElement(r.Fragment,null,r.createElement("div",{className:"rte-link-modal-overlay",onClick:d}),r.createElement("div",{className:"rte-link-modal"},r.createElement("h4",{className:"rte-link-modal__title"},p?"Edit Link":"Insert Link"),r.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"URL",value:p,onChange:N=>w(N.target.value)}),r.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Text to Display",value:R,onChange:N=>M(N.target.value)}),r.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Title",value:E,onChange:N=>x(N.target.value)}),r.createElement("select",{className:"rte-link-modal__select",value:S,onChange:N=>A(N.target.value)},r.createElement("option",{value:"_self"},"Same tab"),r.createElement("option",{value:"_blank"},"New tab")),r.createElement("div",{className:"rte-link-modal__actions"},r.createElement("button",{className:"rte-link-modal__btn",onClick:d},"Cancel"),r.createElement("button",{className:"rte-link-modal__btn rte-link-modal__btn--ok",onClick:I},"OK"))))};function Me(a){const i=new Map;return a.forEach(d=>{i.set(d.name,d.value)}),Array.from(i.entries()).map(([d,m])=>({name:d,value:m}))}const Vt=({atSuggestions:a=[],showOutput:i=!1,showPreview:d=!1,toolbarConfig:m={link:!1,image:!1,emoji:!1,table:!1,color:!1,fontFamily:!1,fontSize:!1,highlight:!1},classNames:p={},styles:w={},handleGetHtml:R=()=>{},onChange:M=()=>{},value:E,onMentionSelect:x=()=>{},handleAddAttributes:S=()=>{}})=>{var ge,he,pe,ve,ye,Ee,we,Ce;const A=r.useRef(null),[I,N]=r.useState(E!=null&&E.length?E:" "),[P,F]=r.useState(""),[_,H]=r.useState(!1),[q,W]=r.useState({x:0,y:0}),[Q,z]=r.useState([]),T=r.useRef(null),B=r.useRef(null),[O,h]=r.useState({visible:!1,x:0,y:0}),[C,j]=r.useState(!1),K=r.useRef(null),[De,le]=r.useState({url:"",text:"",title:"",target:"_self"}),Oe={bold:!0,italic:!0,underline:!0,removeFormat:!0,unorderedList:!0,orderedList:!0,align:!0,link:(ge=m.link)!=null?ge:!1,image:(he=m.image)!=null?he:!1,emoji:(pe=m.emoji)!=null?pe:!1,table:(ve=m.table)!=null?ve:!1,color:(ye=m.color)!=null?ye:!1,fontFamily:(Ee=m.fontFamily)!=null?Ee:!1,fontSize:(we=m.fontSize)!=null?we:!1,highlight:(Ce=m.fontSize)!=null?Ce:!1},[He,J]=r.useState(""),[ce,G]=r.useState([]),D=()=>A.current,L=()=>{const e=je(),t=/^<div[^>]*style=["'][^"']*font-size\s*:\s*\d+px[^"']*["'][^>]*>/.test(e.trim());let n=e;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}>
2
+ <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}>`),F(n),R==null||R(n);const o=rt(e);M(o);const s=Ve(),l=Me(s);JSON.stringify(l)!==JSON.stringify(ce)&&(G(l),x(l))},je=()=>{const e=D();if(!e)return I;const t=e.cloneNode(!0);t.querySelectorAll("table div").forEach(o=>o.remove()),t.querySelectorAll("table").forEach(o=>{o.removeAttribute("data-has-resize-handle")}),t.querySelectorAll(".rte-cell-highlight").forEach(o=>o.classList.remove("rte-cell-highlight"));let n=t.innerHTML;return n=_e(n),n},_e=e=>e.replace(/<tbody[^>]*>/g,"<tbody>{{#arrayData}}").replace(/<\/tbody>/g,"{{/arrayData}}</tbody>"),U=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return;const t=document.getElementById("rte-editor-body");if(!t)return;const n=e.getRangeAt(0);t.contains(n.startContainer)&&(T.current=n.cloneRange())},V=()=>{const e=window.getSelection();!e||!T.current||(e.removeAllRanges(),e.addRange(T.current))},ie=(e,t)=>{const n=window.getSelection();n&&n.rangeCount>0&&(T.current=n.getRangeAt(0)),V(),document.execCommand(e,!1,t),L()};r.useEffect(()=>{const e=D();if(!e||!E)return;const t=Ie(E);e.innerHTML=t,L()},[]);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,"");r.useEffect(()=>()=>{document.removeEventListener("mousemove",null),document.removeEventListener("mouseup",null)},[]),r.useEffect(()=>{S&&S(e=>{Ue(e)})},[]),r.useEffect(()=>{const e=D();if(!e)return;e.querySelectorAll("table").forEach(n=>{n.hasAttribute("data-has-resize-handle")||(ne(n),n.querySelectorAll("th, td").forEach(s=>$(s)))})},[]);const se=e=>{for(;e&&e.nodeName!=="LI";)e=e.parentNode;return e},de=e=>{var v;const t=window.getSelection();if(!(t!=null&&t.rangeCount))return;const n=t.getRangeAt(0),o=se(n.startContainer);let s,l;if(o){let y=o.querySelector(e);y||(y=document.createElement(e),y.style.margin="0",y.style.paddingLeft="20px",o.appendChild(y)),l=y,s=document.createElement("li"),s.textContent="​",l.appendChild(s)}else{document.execCommand(e==="ul"?"insertUnorderedList":"insertOrderedList");const y=D();if(l=y==null?void 0:y.querySelector(`${e}:last-child`),!l)return;s=l.querySelector("li:last-child")}const c=document.createRange();c.setStart(s,0),c.collapse(!0),t.removeAllRanges(),t.addRange(c),(v=D())==null||v.focus(),L()},ee=(e,t)=>{e==="insertOrderedList"?de("ol"):e==="insertUnorderedList"?de("ul"):e.startsWith("justify")?ot(e):ie(e,t),e==="insertTable"&&Ye()},Pe=e=>{const t=document.createElement("span");t.textContent="​",e.insertNode(t),e.setStartAfter(t),e.collapse(!0);const n=t.getBoundingClientRect();t.remove(),W({x:n.left,y:n.bottom+window.scrollY}),z(a||[]),H(!0),B.current=e.cloneRange()},Fe=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return null;const t=e.anchorNode;let n=e.anchorOffset;if(!t)return null;let o=t;for(o.nodeType!==Node.TEXT_NODE&&(o.childNodes&&o.childNodes[n]?o=o.childNodes[n]:o=t.previousSibling);o;){if(o.nodeType===Node.TEXT_NODE){const s=o.textContent||"",l=o===t?n:s.length,c=s.lastIndexOf("@",l-1);if(c!==-1){const v=document.createRange();return v.setStart(o,c),v.setEnd(o,l),v}}o=o.previousSibling}return null},qe=e=>{var l;const t=window.getSelection();if(!t)return;const n=Fe();n?(t.removeAllRanges(),t.addRange(n)):B.current&&(t.removeAllRanges(),t.addRange(B.current));const o=document.createElement("span");o.textContent=`{{${e.name}}}`,o.style.display="inline",o.setAttribute("data-mention",e.value||e.name||"");try{const c=t.rangeCount?t.getRangeAt(0):null;if(c)c.deleteContents(),c.insertNode(o);else{const g=document.createRange(),u=D();g.selectNodeContents(u),g.collapse(!1),g.insertNode(o)}const v=document.createTextNode(" ");o.after(v);const y=document.createRange();y.setStartAfter(v),y.collapse(!0),t.removeAllRanges(),t.addRange(y)}catch(c){console.error("insertMention error:",c)}let s=Me([...ce,e]);G(s),x(s),H(!1),(l=D())==null||l.focus(),L()},Be=e=>{const t=D();if(!t)return;let n=null;T.current&&t.contains(T.current.startContainer)?n=T.current.cloneRange():(n=document.createRange(),n.selectNodeContents(t),n.collapse(!1));const o=window.getSelection();if(!o)return;o.removeAllRanges(),o.addRange(n);const s=document.createElement("span");s.textContent=`{{${e.name}}}`,s.style.display="inline",s.setAttribute("data-mention",e.value||e.name),n.insertNode(s);const l=document.createTextNode(" ");s.after(l);const c=document.createRange();c.setStartAfter(l),c.collapse(!0),o.removeAllRanges(),o.addRange(c),T.current=c.cloneRange(),t.focus()},Ue=e=>{e.forEach(t=>Be(t)),G(t=>{const n=[...t,...e],o=Array.from(new Map(n.map(s=>[s.name,s])).values());return x(o),o}),L()},Ve=()=>{const e=D();if(!e)return[];const t=e.querySelectorAll("span[data-mention]"),n=[];return t.forEach(o=>{const s=o.getAttribute("data-mention")||"",c=(o.textContent||"").match(/{{(.+?)}}/);c&&n.push({name:c[1],value:s})}),n},$e=e=>{var n,o,s;const t=e.key.toLowerCase();if((e.ctrlKey||e.metaKey)&&["b","i","u"].includes(t)&&(e.preventDefault(),ee(t==="b"?"bold":t==="i"?"italic":t==="u"?"underline":"")),e.shiftKey&&e.key==="2"&&e.preventDefault(),e.key==="Enter"){const l=window.getSelection(),c=l!=null&&l.anchorNode?se(l.anchorNode):null;if(!c)return;if(((n=c.textContent)==null?void 0:n.replace(/\u200B/g,"").trim())===""){e.preventDefault();const y=c.parentElement,g=y==null?void 0:y.closest("li");if(g){y==null||y.removeChild(c);const u=document.createElement("p");u.innerHTML="<br />",(o=g.parentElement)==null||o.insertBefore(u,g.nextSibling);const f=document.createRange();f.setStart(u,0),f.collapse(!0),l==null||l.removeAllRanges(),l==null||l.addRange(f)}else{const u=c.closest("ul, ol");if(u){const f=document.createElement("p");f.innerHTML="<br />",(s=u.parentElement)==null||s.insertBefore(f,u.nextSibling),u.removeChild(c);const b=document.createRange();b.setStart(f,0),b.collapse(!0),l==null||l.removeAllRanges(),l==null||l.addRange(b)}}L()}}},We=e=>{if(e.data==="@"){const n=window.getSelection();if(!(n!=null&&n.rangeCount))return;const o=n.anchorNode;if(te(o))return;setTimeout(()=>{Pe(n.getRangeAt(0)),J(""),z(a),H(!0)},0);return}if(_){setTimeout(()=>ue(),0);return}},te=e=>{if(!e)return!1;let t=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;for(;t;){if(t.tagName==="TH")return!0;t=t.parentElement}return!1},ue=()=>{L();const e=window.getSelection();if(!e||!e.anchorNode)return;if(te(e.anchorNode)){H(!1);return}let t=e.anchorNode.textContent||"";t=t.replace(/\u00A0/g," ");const n=t.match(/@([^\n]*)$/);if(!n){H(!1);return}const o=n[1].trim().toLowerCase();J(o);const s=a.filter(l=>l.name.toLowerCase().includes(o));s.length>0?(z(s),H(!0)):H(!1)},Ke=e=>{var o;const t=(o=e.target.files)==null?void 0:o[0];if(!t)return;const n=new FileReader;n.onload=s=>{var b;const l=(b=s.target)==null?void 0:b.result;V();const c=window.getSelection();let v=c&&c.rangeCount?c.getRangeAt(0):null;const y=document.createElement("img");y.src=l,y.alt=t.name||"image",y.className="rte-inserted-image",y.contentEditable="true";const g=D();if(!v||!g){g==null||g.appendChild(y);const be=document.createTextNode(" ");g==null||g.appendChild(be);const re=document.createRange();re.setStartAfter(be),re.collapse(!0),c==null||c.removeAllRanges(),c==null||c.addRange(re),g==null||g.focus(),L(),e.target.value="";return}v.deleteContents(),v.insertNode(y);const u=document.createTextNode(" ");y.after(u);const f=document.createRange();f.setStartAfter(u),f.collapse(!0),c.removeAllRanges(),c.addRange(f),g.focus(),L(),e.target.value=""},n.readAsDataURL(t)},Xe=e=>{var s;V();const t=window.getSelection();if(!(t!=null&&t.rangeCount))return;const n=t.getRangeAt(0),o=document.createTextNode(e);n.insertNode(o),n.setStartAfter(o),n.collapse(!0),t.removeAllRanges(),t.addRange(n),(s=D())==null||s.focus(),L()},Ye=()=>{var g;st(),V();const e=document.createElement("table");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);const t=document.createElement("thead");p.thead&&t.classList.add(p.thead);const n=document.createElement("tbody");p.tbody&&n.classList.add(p.tbody);const o=document.createElement("tr");p.tr&&o.classList.add(p.tr);const s=document.createElement("tr");p.tr&&s.classList.add(p.tr);for(let u=0;u<2;u++){const f=document.createElement("th");f.textContent="",f.style.border="1px solid #999",f.style.padding="4px",f.style.position="relative",f.style.backgroundColor="lightgray",f.style.height="20px",p.th&&f.classList.add(p.th);const b=document.createElement("td");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),$(f),$(b),o.appendChild(f),s.appendChild(b)}t.appendChild(o),n.appendChild(s),e.appendChild(t),e.appendChild(n),ne(e);const l=window.getSelection();if(!(l!=null&&l.rangeCount))return;const c=l.getRangeAt(0);c.collapse(!1),c.insertNode(e);const v=document.createElement("p");v.innerHTML="<br/>",e.after(v);const y=document.createRange();y.setStart(v,0),y.collapse(!0),l.removeAllRanges(),l.addRange(y),(g=D())==null||g.focus(),L()},ne=e=>{if(e.dataset.hasResizeHandle==="true")return;const t=document.createElement("div");Object.assign(t.style,{position:"absolute",width:"14px",height:"14px",right:"0",bottom:"0",background:"rgba(0,0,0,0.25)",cursor:"nwse-resize",zIndex:"20",borderRadius:"2px"}),t.style.userSelect="none",t.contentEditable="false",t.dataset.hasResizeHandle="true";let n=0,o=0,s=0,l=0;t.addEventListener("mousedown",c=>{c.preventDefault(),n=c.clientX,o=c.clientY;const v=e.getBoundingClientRect();s=v.width,l=v.height;const y=u=>{const f=Math.max(100,s+(u.clientX-n)),b=Math.max(20,l+(u.clientY-o));e.style.width=`${f}px`,e.style.height=`${b}px`,L()},g=()=>{document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",g),L()};document.addEventListener("mousemove",y),document.addEventListener("mouseup",g)}),e.appendChild(t)},$=e=>{const t=document.createElement("div"),n=document.createElement("div");Object.assign(t.style,{position:"absolute",right:"0",top:"0",width:"4px",height:"100%",cursor:"col-resize",background:"rgba(0,0,0,0.15)",zIndex:"10",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none",pointerEvents:"auto"}),t.contentEditable="false",Object.assign(n.style,{position:"absolute",bottom:"0",left:"0",width:"100%",height:"4px",cursor:"row-resize",background:"rgba(0,0,0,0.15)",zIndex:"10",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none",pointerEvents:"auto"}),n.contentEditable="false",Ze(e,t,n),e.appendChild(t),e.appendChild(n)},Ze=(e,t,n)=>{let o=0,s=0,l=0,c=0;t.addEventListener("mousedown",u=>{u.preventDefault(),o=u.clientX,l=e.offsetWidth,document.addEventListener("mousemove",v),document.addEventListener("mouseup",g)}),n.addEventListener("mousedown",u=>{u.preventDefault(),s=u.clientY,c=e.offsetHeight,document.addEventListener("mousemove",y),document.addEventListener("mouseup",g)});const v=u=>{const f=l+(u.clientX-o);e.style.width=`${Math.max(30,f)}px`,L()},y=u=>{const f=c+(u.clientY-s);e.style.height=`${Math.max(20,f)}px`,L()},g=()=>{document.removeEventListener("mousemove",v),document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",g),L()}},Qe=e=>{const n=e.target.closest("td, th");n&&(e.preventDefault(),document.querySelectorAll(".rte-cell-highlight").forEach(o=>o.classList.remove("rte-cell-highlight")),n.classList.add("rte-cell-highlight"),h({visible:!0,x:e.clientX,y:e.clientY,cell:n}))},me=()=>{document.querySelectorAll(".rte-cell-highlight").forEach(e=>e.classList.remove("rte-cell-highlight"))},Je=e=>{if(!O.cell)return;const t=O.cell.closest("table"),n=O.cell.cellIndex,o=O.cell.parentElement.rowIndex,s=l=>{const c=l.tagName.toLowerCase(),v=document.createElement(c);return v.textContent="",v.style.cssText=l.style.cssText,$(v),v};switch(e){case"insertRowAbove":{const l=t.rows[o],c=t.insertRow(o);Array.from(l.cells).forEach(v=>{c.appendChild(s(v))});break}case"insertRowBelow":{const l=t.rows[o],c=t.insertRow(o+1);Array.from(l.cells).forEach(v=>{c.appendChild(s(v))});break}case"insertColLeft":{Array.from(t.rows).forEach(l=>{const c=l.cells[n];l.insertBefore(s(c),c)});break}case"insertColRight":{Array.from(t.rows).forEach(l=>{const c=l.cells[n];l.insertBefore(s(c),c.nextSibling)});break}case"deleteRow":t.rows.length>1&&t.deleteRow(o);break;case"deleteCol":Array.from(t.rows).forEach(l=>{l.cells[n]&&l.deleteCell(n)});break}L(),h(oe(ae({},O),{visible:!1})),me()},Ge=()=>{U(),K.current=T.current,le({url:"",text:"",title:"",target:"_self"}),j(!0)},et=e=>{const t=window.getSelection();if(!t||!K.current)return;t.removeAllRanges(),t.addRange(K.current);let n=e.url.trim();/^https?:\/\//i.test(n)||(n="https://"+n);const o=document.createElement("a");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";const s=t.getRangeAt(0);s.deleteContents(),s.insertNode(o);const l=document.createTextNode(" ");o.after(l);const c=document.createRange();c.setStartAfter(l),c.collapse(!0),t.removeAllRanges(),t.addRange(c),j(!1),L()},tt=e=>{const t=e.target;if(t.tagName==="A"){const n=t;if(e.ctrlKey||e.metaKey){window.open(n.href,"_blank","noopener,noreferrer");return}e.preventDefault();const o=document.createRange();o.selectNode(n),K.current=o,le({url:n.href,text:n.textContent||n.href,title:n.title,target:n.target}),j(!0)}},nt=()=>{const e=D();if(!e)return;const t=window.getSelection();if((!t||t.rangeCount===0)&&T.current){const u=window.getSelection();u==null||u.removeAllRanges(),u==null||u.addRange(T.current)}const n=window.getSelection();if(!n||n.rangeCount===0)return;const o=n.getRangeAt(0);V(),document.execCommand("removeFormat",!1);const s=o.cloneContents(),l=document.createElement("div");l.appendChild(s);const c=document.createTreeWalker(l,NodeFilter.SHOW_ELEMENT,null),v=[];for(;c.nextNode();){const u=c.currentNode,f=u.tagName.toUpperCase(),b=u.getAttribute&&u.getAttribute("data-mention")!==null;f!=="A"&&!b&&v.push(u)}for(let u=v.length-1;u>=0;u--){const f=v[u],b=f.parentNode;if(b){for(;f.firstChild;)b.insertBefore(f.firstChild,f);b.removeChild(f)}}l.querySelectorAll("[style]").forEach(u=>u.removeAttribute("style")),o.deleteContents();const y=document.createDocumentFragment();for(;l.firstChild;)y.appendChild(l.firstChild);o.insertNode(y);const g=document.createRange();g.setStartAfter(o.endContainer.nodeType===Node.TEXT_NODE?o.endContainer:o.startContainer),g.collapse(!0),n.removeAllRanges(),n.addRange(g),e.normalize(),L()},rt=e=>{var o;let t=e;t=t.replace(/{{#arrayData\d*}}/g,""),t=t.replace(/{{\/arrayData\d*}}/g,"");const n=document.createElement("div");return n.innerHTML=t,n.querySelectorAll("br").forEach(s=>{s.replaceWith(`
3
3
  `)}),n.querySelectorAll("p, div, tr").forEach(s=>{s.insertAdjacentText("afterend",`
4
4
  `)}),n.querySelectorAll("table").forEach(s=>{s.insertAdjacentText("afterend",`
5
5
  `)}),((o=n.textContent)==null?void 0:o.replace(/\n{3,}/g,`
6
6
 
7
- `).trim())||""};function at(){const e=window.getSelection();if(!e||e.rangeCount===0)return[];const t=e.getRangeAt(0);if(t.collapsed){let l=t.startContainer,c=l.nodeType===Node.ELEMENT_NODE?l:l.parentElement;const v=c==null?void 0:c.closest("td, th");return v?[v]:[]}const n=t.commonAncestorContainer,o=n.nodeType===Node.ELEMENT_NODE?n:n.parentElement;return Array.from(o.querySelectorAll("td, th")).filter(l=>{const c=document.createRange();return c.selectNodeContents(l),t.compareBoundaryPoints(Range.END_TO_START,c)<0&&t.compareBoundaryPoints(Range.START_TO_END,c)>0})}function ot(e){const t=at();if(t.length===0){ie(e);return}let n="left";e==="justifyCenter"&&(n="center"),e==="justifyRight"&&(n="right"),t.forEach(o=>{o.style.textAlign=n}),L()}const lt=e=>{e.preventDefault();const t=e.clipboardData.items;for(let g=0;g<t.length;g++){const u=t[g];if(u.kind==="file"&&u.type.startsWith("image/"))return;u.kind==="string"&&u.getAsString(f=>{/<img\s/i.test(f)})}const n=e.clipboardData.getData("text/html")||"";if(!n)return;const o=document.createElement("div");o.innerHTML=n;const s=g=>{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=>{const f=u;f.style.border="1px solid #999",f.style.padding="4px",f.style.position="relative",f.style.backgroundColor="lightgray",f.style.height="20px"}),g.querySelectorAll("td").forEach(u=>{const f=u;f.style.border="1px solid #999",f.style.padding="4px",f.style.position="relative",f.style.backgroundColor="#fff",f.style.height="20px"})};o.querySelectorAll("table").forEach(g=>s(g));const l=window.getSelection();if(!l||!l.rangeCount)return;const c=l.getRangeAt(0);c.deleteContents();const v=document.createDocumentFragment();for(;o.firstChild;)v.appendChild(o.firstChild);c.insertNode(v),c.collapse(!1),l.removeAllRanges(),l.addRange(c);const y=M.current;y&&(y.querySelectorAll("table").forEach(g=>{const u=g;u.dataset.hasResizeHandle||(ne(u),u.dataset.hasResizeHandle="true"),u.querySelectorAll("th, td").forEach(f=>{const b=f;b.dataset.hasResizeHandles||($(b),b.dataset.hasResizeHandles="true")})}),L())},ct=e=>{V();const t=window.getSelection();if(!t||!t.rangeCount)return;const n=t.getRangeAt(0),o=document.createElement("span");o.style.fontSize=`${e}px`,o.appendChild(n.extractContents()),n.insertNode(o);const s=document.createRange();s.setStartAfter(o),s.collapse(!0),t.removeAllRanges(),t.addRange(s),L()},it=()=>{const e=window.getSelection();if(!e||!e.anchorNode)return null;const t=e.anchorNode;if(te(t)||t.nodeType!==Node.TEXT_NODE)return null;const n=t.textContent||"",o=e.anchorOffset,s=n.lastIndexOf("@",o-1);if(s===-1)return null;const l=n.substring(s+1,o);if(l.includes(" ")||l.includes(" "))return null;const c=document.createRange();return c.setStart(t,s),c.setEnd(t,o),{range:c,query:l}},fe=()=>{const e=it();if(!e)return;const{range:t,query:n}=e,o=document.createElement("span");o.textContent="​",t.insertNode(o);const s=o.getBoundingClientRect();o.remove(),W({x:s.left,y:s.bottom+window.scrollY}),J(n.toLowerCase());const l=a.filter(c=>c.name.toLowerCase().includes(n.toLowerCase()));k(l),H(!0),B.current=t.cloneRange()};function st(){const e=M.current;if(!e)return;const t=window.getSelection();if(!t||t.rangeCount>0&&e.contains(t.anchorNode))return;const n=document.createRange();n.selectNodeContents(e),n.collapse(!1),t.removeAllRanges(),t.addRange(n),T.current=n.cloneRange()}return r.createElement("div",{className:`rte-wrapper ${(p==null?void 0:p.wrapper)||""}`,style:w.wrapper},r.createElement("div",{style:{flex:1}},r.createElement(Ne,{exec:ee,saveSelection:U,handleFileChange:Ke,handleFontSizeChange:e=>ct(e.target.value),handleFontFamilyChange:e=>ee("fontName",e.target.value),insertEmoji:Xe,handleLink:Ge,removeFormatting:nt,visibleActions:Oe,className:p.toolbar,style:w.toolbar}),r.createElement("div",{ref:M,id:"rte-editor-body",className:`rte-editor ${(p==null?void 0:p.editor)||""}`,style:w.editor,contentEditable:!0,suppressContentEditableWarning:!0,onPaste:lt,onKeyUp:()=>{U(),fe()},onMouseUp:U,onInput:()=>{ue(),U()},onKeyDown:$e,onBeforeInput:We,onContextMenu:Qe,onClick:e=>{tt(e),U(),fe()}}),r.createElement(qt,{show:_,position:q,filtered:Q,insertMention:qe,onClose:()=>H(!1),query:He}),i&&r.createElement("div",{className:`rte-output ${(p==null?void 0:p.output)||""}`,style:w.output},r.createElement("h4",null,"Output HTML:"),r.createElement("p",null,P)),r.createElement(Bt,{visible:O.visible,x:O.x,y:O.y,onAction:Je,onClose:()=>{h(oe(ae({},O),{visible:!1})),me()}}),r.createElement(Ut,{visible:C,linkData:De,onClose:()=>j(!1),onInsert:et})),d?r.createElement(Te,{className:p.preview,style:w.preview,html:P}):null)};exports.RichTextEditor=Vt;exports.RtePreview=Te;exports.RteToolbar=Ne;
7
+ `).trim())||""};function at(){const e=window.getSelection();if(!e||e.rangeCount===0)return[];const t=e.getRangeAt(0);if(t.collapsed){let l=t.startContainer,c=l.nodeType===Node.ELEMENT_NODE?l:l.parentElement;const v=c==null?void 0:c.closest("td, th");return v?[v]:[]}const n=t.commonAncestorContainer,o=n.nodeType===Node.ELEMENT_NODE?n:n.parentElement;return Array.from(o.querySelectorAll("td, th")).filter(l=>{const c=document.createRange();return c.selectNodeContents(l),t.compareBoundaryPoints(Range.END_TO_START,c)<0&&t.compareBoundaryPoints(Range.START_TO_END,c)>0})}function ot(e){const t=at();if(t.length===0){ie(e);return}let n="left";e==="justifyCenter"&&(n="center"),e==="justifyRight"&&(n="right"),t.forEach(o=>{o.style.textAlign=n}),L()}const lt=e=>{e.preventDefault();const t=e.clipboardData.items;for(let g=0;g<t.length;g++){const u=t[g];if(u.kind==="file"&&u.type.startsWith("image/"))return;u.kind==="string"&&u.getAsString(f=>{/<img\s/i.test(f)})}const n=e.clipboardData.getData("text/html")||"";if(!n)return;const o=document.createElement("div");o.innerHTML=n;const s=g=>{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=>{const f=u;f.style.border="1px solid #999",f.style.padding="4px",f.style.position="relative",f.style.backgroundColor="lightgray",f.style.height="20px"}),g.querySelectorAll("td").forEach(u=>{const f=u;f.style.border="1px solid #999",f.style.padding="4px",f.style.position="relative",f.style.backgroundColor="#fff",f.style.height="20px"})};o.querySelectorAll("table").forEach(g=>s(g));const l=window.getSelection();if(!l||!l.rangeCount)return;const c=l.getRangeAt(0);c.deleteContents();const v=document.createDocumentFragment();for(;o.firstChild;)v.appendChild(o.firstChild);c.insertNode(v),c.collapse(!1),l.removeAllRanges(),l.addRange(c);const y=A.current;y&&(y.querySelectorAll("table").forEach(g=>{const u=g;u.hasAttribute("data-has-resize-handle")||(ne(u),u.querySelectorAll("th, td").forEach(f=>{const b=f;b.dataset.hasResizeHandles||$(b)}))}),L())},ct=e=>{V();const t=window.getSelection();if(!t||!t.rangeCount)return;const n=t.getRangeAt(0),o=document.createElement("span");o.style.fontSize=`${e}px`,o.appendChild(n.extractContents()),n.insertNode(o);const s=document.createRange();s.setStartAfter(o),s.collapse(!0),t.removeAllRanges(),t.addRange(s),L()},it=()=>{const e=window.getSelection();if(!e||!e.anchorNode)return null;const t=e.anchorNode;if(te(t)||t.nodeType!==Node.TEXT_NODE)return null;const n=t.textContent||"",o=e.anchorOffset,s=n.lastIndexOf("@",o-1);if(s===-1)return null;const l=n.substring(s+1,o);if(l.includes(" ")||l.includes(" "))return null;const c=document.createRange();return c.setStart(t,s),c.setEnd(t,o),{range:c,query:l}},fe=()=>{const e=it();if(!e)return;const{range:t,query:n}=e,o=document.createElement("span");o.textContent="​",t.insertNode(o);const s=o.getBoundingClientRect();o.remove(),W({x:s.left,y:s.bottom+window.scrollY}),J(n.toLowerCase());const l=a.filter(c=>c.name.toLowerCase().includes(n.toLowerCase()));z(l),H(!0),B.current=t.cloneRange()};function st(){const e=A.current;if(!e)return;const t=window.getSelection();if(!t||t.rangeCount>0&&e.contains(t.anchorNode))return;const n=document.createRange();n.selectNodeContents(e),n.collapse(!1),t.removeAllRanges(),t.addRange(n),T.current=n.cloneRange()}return r.createElement("div",{className:`rte-wrapper ${(p==null?void 0:p.wrapper)||""}`,style:w.wrapper},r.createElement("div",{style:{flex:1}},r.createElement(Ne,{exec:ee,saveSelection:U,handleFileChange:Ke,handleFontSizeChange:e=>ct(e.target.value),handleFontFamilyChange:e=>ee("fontName",e.target.value),insertEmoji:Xe,handleLink:Ge,removeFormatting:nt,visibleActions:Oe,className:p.toolbar,style:w.toolbar}),r.createElement("div",{ref:A,id:"rte-editor-body",className:`rte-editor ${(p==null?void 0:p.editor)||""}`,style:w.editor,contentEditable:!0,suppressContentEditableWarning:!0,onPaste:lt,onKeyUp:()=>{U(),fe()},onMouseUp:U,onInput:()=>{ue(),U()},onKeyDown:$e,onBeforeInput:We,onContextMenu:Qe,onClick:e=>{tt(e),U(),fe()}}),r.createElement(qt,{show:_,position:q,filtered:Q,insertMention:qe,onClose:()=>H(!1),query:He}),i&&r.createElement("div",{className:`rte-output ${(p==null?void 0:p.output)||""}`,style:w.output},r.createElement("h4",null,"Output HTML:"),r.createElement("p",null,P)),r.createElement(Bt,{visible:O.visible,x:O.x,y:O.y,onAction:Je,onClose:()=>{h(oe(ae({},O),{visible:!1})),me()}}),r.createElement(Ut,{visible:C,linkData:De,onClose:()=>j(!1),onInsert:et})),d?r.createElement(Te,{className:p.preview,style:w.preview,html:P}):null)};exports.RichTextEditor=Vt;exports.RtePreview=Te;exports.RteToolbar=Ne;
package/dist/index.umd.js CHANGED
@@ -1,7 +1,7 @@
1
- (function(k,n){typeof exports=="object"&&typeof module!="undefined"?n(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],n):(k=typeof globalThis!="undefined"?globalThis:k||self,n(k.RichTextEditor={},k.React,k.ReactDOM))})(this,(function(k,n,j){"use strict";var Bt=Object.defineProperty,Rt=Object.defineProperties;var Ut=Object.getOwnPropertyDescriptors;var Oe=Object.getOwnPropertySymbols;var Vt=Object.prototype.hasOwnProperty,$t=Object.prototype.propertyIsEnumerable;var He=(k,n,j)=>n in k?Bt(k,n,{enumerable:!0,configurable:!0,writable:!0,value:j}):k[n]=j,ae=(k,n)=>{for(var j in n||(n={}))Vt.call(n,j)&&He(k,j,n[j]);if(Oe)for(var j of Oe(n))$t.call(n,j)&&He(k,j,n[j]);return k},ie=(k,n)=>Rt(k,Ut(n));function je(o){const c=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const u in o)if(u!=="default"){const m=Object.getOwnPropertyDescriptor(o,u);Object.defineProperty(c,u,m.get?m:{enumerable:!0,get:()=>o[u]})}}return c.default=o,Object.freeze(c)}const _e=je(n);window.React=_e;var se={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},ce=n.createContext&&n.createContext(se),Ie=["attr","size","title"];function Pe(o,c){if(o==null)return{};var u=Fe(o,c),m,p;if(Object.getOwnPropertySymbols){var w=Object.getOwnPropertySymbols(o);for(p=0;p<w.length;p++)m=w[p],!(c.indexOf(m)>=0)&&Object.prototype.propertyIsEnumerable.call(o,m)&&(u[m]=o[m])}return u}function Fe(o,c){if(o==null)return{};var u={};for(var m in o)if(Object.prototype.hasOwnProperty.call(o,m)){if(c.indexOf(m)>=0)continue;u[m]=o[m]}return u}function X(){return X=Object.assign?Object.assign.bind():function(o){for(var c=1;c<arguments.length;c++){var u=arguments[c];for(var m in u)Object.prototype.hasOwnProperty.call(u,m)&&(o[m]=u[m])}return o},X.apply(this,arguments)}function de(o,c){var u=Object.keys(o);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(o);c&&(m=m.filter(function(p){return Object.getOwnPropertyDescriptor(o,p).enumerable})),u.push.apply(u,m)}return u}function Y(o){for(var c=1;c<arguments.length;c++){var u=arguments[c]!=null?arguments[c]:{};c%2?de(Object(u),!0).forEach(function(m){qe(o,m,u[m])}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(u)):de(Object(u)).forEach(function(m){Object.defineProperty(o,m,Object.getOwnPropertyDescriptor(u,m))})}return o}function qe(o,c,u){return c=Be(c),c in o?Object.defineProperty(o,c,{value:u,enumerable:!0,configurable:!0,writable:!0}):o[c]=u,o}function Be(o){var c=Re(o,"string");return typeof c=="symbol"?c:c+""}function Re(o,c){if(typeof o!="object"||!o)return o;var u=o[Symbol.toPrimitive];if(u!==void 0){var m=u.call(o,c);if(typeof m!="object")return m;throw new TypeError("@@toPrimitive must return a primitive value.")}return(c==="string"?String:Number)(o)}function ue(o){return o&&o.map((c,u)=>n.createElement(c.tag,Y({key:u},c.attr),ue(c.child)))}function T(o){return c=>n.createElement(Ue,X({attr:Y({},o.attr)},c),ue(o.child))}function Ue(o){var c=u=>{var{attr:m,size:p,title:w}=o,x=Pe(o,Ie),z=p||u.size||"1em",E;return u.className&&(E=u.className),o.className&&(E=(E?E+" ":"")+o.className),n.createElement("svg",X({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},u.attr,m,x,{className:E,style:Y(Y({color:o.color||u.color},u.style),o.style),height:z,width:z,xmlns:"http://www.w3.org/2000/svg"}),w&&n.createElement("title",null,w),o.children)};return ce!==void 0?n.createElement(ce.Consumer,null,u=>c(u)):c(se)}function Ve(o){return T({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:[]}]})(o)}function $e(o){return T({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M448 64c0 17.7-14.3 32-32 32L192 96c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zm0 256c0 17.7-14.3 32-32 32l-224 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zM0 192c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 224c-17.7 0-32-14.3-32-32zM448 448c0 17.7-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32s14.3-32 32-32l384 0c17.7 0 32 14.3 32 32z"},child:[]}]})(o)}function We(o){return T({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M0 96C0 60.7 28.7 32 64 32l384 0c35.3 0 64 28.7 64 64l0 320c0 35.3-28.7 64-64 64L64 480c-35.3 0-64-28.7-64-64L0 96zM323.8 202.5c-4.5-6.6-11.9-10.5-19.8-10.5s-15.4 3.9-19.8 10.5l-87 127.6L170.7 297c-4.6-5.7-11.5-9-18.7-9s-14.2 3.3-18.7 9l-64 80c-5.8 7.2-6.9 17.1-2.9 25.4s12.4 13.6 21.6 13.6l96 0 32 0 208 0c8.9 0 17.1-4.9 21.2-12.8s3.6-17.4-1.4-24.7l-120-176zM112 192a48 48 0 1 0 0-96 48 48 0 1 0 0 96z"},child:[]}]})(o)}function Ke(o){return T({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M24 56c0-13.3 10.7-24 24-24l32 0c13.3 0 24 10.7 24 24l0 120 16 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-80 0c-13.3 0-24-10.7-24-24s10.7-24 24-24l16 0 0-96-8 0C34.7 80 24 69.3 24 56zM86.7 341.2c-6.5-7.4-18.3-6.9-24 1.2L51.5 357.9c-7.7 10.8-22.7 13.3-33.5 5.6s-13.3-22.7-5.6-33.5l11.1-15.6c23.7-33.2 72.3-35.6 99.2-4.9c21.3 24.4 20.8 60.9-1.1 84.7L86.8 432l33.2 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-88 0c-9.5 0-18.2-5.6-22-14.4s-2.1-18.9 4.3-25.9l72-78c5.3-5.8 5.4-14.6 .3-20.5zM224 64l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 160l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 160l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32z"},child:[]}]})(o)}function Xe(o){return T({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M12.83 352h262.34A12.82 12.82 0 0 0 288 339.17v-38.34A12.82 12.82 0 0 0 275.17 288H12.83A12.82 12.82 0 0 0 0 300.83v38.34A12.82 12.82 0 0 0 12.83 352zm0-256h262.34A12.82 12.82 0 0 0 288 83.17V44.83A12.82 12.82 0 0 0 275.17 32H12.83A12.82 12.82 0 0 0 0 44.83v38.34A12.82 12.82 0 0 0 12.83 96zM432 160H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0 256H16a16 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:[]}]})(o)}function Ye(o){return T({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M333.49 238a122 122 0 0 0 27-65.21C367.87 96.49 308 32 233.42 32H34a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h31.87v288H34a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h209.32c70.8 0 134.14-51.75 141-122.4 4.74-48.45-16.39-92.06-50.83-119.6zM145.66 112h87.76a48 48 0 0 1 0 96h-87.76zm87.76 288h-87.76V288h87.76a56 56 0 0 1 0 112z"},child:[]}]})(o)}function Ze(o){return T({attr:{viewBox:"0 0 544 512"},child:[{tag:"path",attr:{d:"M0 479.98L99.92 512l35.45-35.45-67.04-67.04L0 479.98zm124.61-240.01a36.592 36.592 0 0 0-10.79 38.1l13.05 42.83-50.93 50.94 96.23 96.23 50.86-50.86 42.74 13.08c13.73 4.2 28.65-.01 38.15-10.78l35.55-41.64-173.34-173.34-41.52 35.44zm403.31-160.7l-63.2-63.2c-20.49-20.49-53.38-21.52-75.12-2.35L190.55 183.68l169.77 169.78L530.27 154.4c19.18-21.74 18.15-54.63-2.35-75.13z"},child:[]}]})(o)}function Qe(o){return T({attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M320 48v32a16 16 0 0 1-16 16h-62.76l-80 320H208a16 16 0 0 1 16 16v32a16 16 0 0 1-16 16H16a16 16 0 0 1-16-16v-32a16 16 0 0 1 16-16h62.76l80-320H112a16 16 0 0 1-16-16V48a16 16 0 0 1 16-16h192a16 16 0 0 1 16 16z"},child:[]}]})(o)}function Je(o){return T({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:[]}]})(o)}function Ge(o){return T({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:[]}]})(o)}function et(o){return T({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:[]}]})(o)}function tt(o){return T({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M464 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h416c26.51 0 48-21.49 48-48V80c0-26.51-21.49-48-48-48zM224 416H64v-96h160v96zm0-160H64v-96h160v96zm224 160H288v-96h160v96zm0-160H288v-96h160v96z"},child:[]}]})(o)}function nt(o){return T({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:[]}]})(o)}function rt(o){return T({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:[]}]})(o)}function ot(o){return T({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:[]}]})(o)}const lt=["😀","😁","😂","đŸ¤Ŗ","😃","😄","😅","😉","😊","😍","😘","😜","😎","đŸ˜ĸ","😭","😡","🤔","🙄","😇","đŸĨ°","🤩","🤗","😴","😋","đŸ˜Ŧ","🤤","đŸ˜ļ‍đŸŒĢī¸","😷","🤕","🤑","🤠","😈","đŸ‘ģ","💀","🤖","đŸļ","🐱","đŸŧ","🐸","đŸĻ„","🐷","đŸĩ","🐰","đŸ¯","đŸĻ","🐮","🌞","🌙","⭐","🌈","đŸ”Ĩ","💧","â„ī¸","⚡","â˜€ī¸","🌸","🌹","🍎","🍕","🍩","🍔","🍟","🍇","🍉","🍓","🍒","đŸĨ­","đŸĨ‘","🎉","🎂","🎁","🎈","đŸŽļ","đŸŽĩ","🏆","âšŊ","🏀","🏸","🏏","đŸ•šī¸","👋","🤚","đŸ–ī¸","✋","🖖","👍","👎","👌","🤌","🤏","✊","👊","🤛","🤜","â˜ī¸","👆","👇","👈","👉","🤟","🤘","🤙","🙌","👏","🙏","âœī¸","💅","🤲","👏","đŸĢļ","👐"],me=({exec:o,saveSelection:c,handleFileChange:u,handleFontSizeChange:m,handleFontFamilyChange:p,insertEmoji:w,handleLink:x,removeFormatting:z,visibleActions:E,className:S,style:L})=>{var V,_;const A=n.useRef(null),q=n.useRef(null),D=n.useRef(null),[B,R]=n.useState(!1),[F,I]=n.useState({x:0,y:0});n.useEffect(()=>{const h=C=>{!C.target.closest(".rte-emoji-popup")&&!C.target.closest("button[title='Emoji']")&&R(!1)};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[]);const U=h=>{var P;h.preventDefault();const C=h.currentTarget.dataset.command;if(C)switch(C){case"bold":case"italic":case"underline":case"insertUnorderedList":case"insertOrderedList":case"removeFormat":o(C);break;case"insertImage":{(P=A.current)==null||P.click();break}default:console.warn("Unknown command:",C)}},Q=h=>{o("foreColor",h.target.value)},G=h=>{o("backColor",h.target.value)},[N,O]=n.useState({bold:!1,italic:!1,underline:!1,unorderedList:!1,orderedList:!1,alignLeft:!1,alignCenter:!1,alignRight:!1,removeFormat:!1,link:!1,image:!1,emoji:!1,table:!1,color:!1,highlight:!1});return n.useEffect(()=>{const h=()=>{O({bold:document.queryCommandState("bold"),italic:document.queryCommandState("italic"),underline:document.queryCommandState("underline"),unorderedList:document.queryCommandState("insertUnorderedList"),orderedList:document.queryCommandState("insertOrderedList"),alignLeft:document.queryCommandState("justifyLeft"),alignCenter:document.queryCommandState("justifyCenter"),alignRight:document.queryCommandState("justifyRight"),removeFormat:document.queryCommandState("removeFormat"),link:document.queryCommandState("createLink"),image:document.queryCommandState("insertImage"),emoji:document.queryCommandState("insertEmoji"),table:document.queryCommandState("insertTable"),color:document.queryCommandState("foreColor"),highlight:document.queryCommandState("backColor")})};return document.addEventListener("selectionchange",h),()=>document.removeEventListener("selectionchange",h)},[]),n.createElement("div",{className:`rte-toolbar ${S||""}`,style:L},E.bold&&n.createElement("button",{"data-command":"bold",title:"Bold",onMouseDown:U,className:N.bold?"rte-active":""},n.createElement(Ye,null)),E.italic&&n.createElement("button",{"data-command":"italic",title:"Italic",onMouseDown:U,className:N.italic?"rte-active":""},n.createElement(Qe,null)),E.underline&&n.createElement("button",{"data-command":"underline",title:"Underline",onMouseDown:U,className:N.underline?"rte-active":""},n.createElement(nt,null)),E.unorderedList&&n.createElement("button",{"data-command":"insertUnorderedList",onMouseDown:U,title:"UnorderedList",className:N.unorderedList?"rte-active":""},n.createElement(Ge,null)),E.orderedList&&n.createElement("button",{"data-command":"insertOrderedList",title:"OrderedList",onMouseDown:U,className:N.orderedList?"rte-active":""},n.createElement(Ke,null)),E.link&&n.createElement("button",{"data-command":"createLink",title:"Link",onClick:x,className:N.link?"rte-active":""},n.createElement(Je,null)),E.removeFormat&&n.createElement("button",{"data-command":"Remove format",title:"removeFormat",onMouseDown:h=>{h.preventDefault(),c(),z()},className:N.removeFormat?"rte-active":""},n.createElement(ot,null)),E.image&&n.createElement("button",{"data-command":"insertImage",title:"Image",onMouseDown:U,className:N.image?"rte-active":""},n.createElement(We,null)),n.createElement("input",{type:"file",accept:"image/*",ref:A,style:{display:"none"},onChange:u}),E.emoji&&n.createElement("div",{style:{position:"relative"}},n.createElement("button",{title:"Emoji",onMouseDown:h=>{h.preventDefault(),c();const C=h.currentTarget.getBoundingClientRect();I({x:C.left,y:C.bottom+8}),R(P=>!P)},className:N.emoji?"rte-active":""},n.createElement(et,null)),B&&j.createPortal(n.createElement("div",{className:"rte-emoji-popup",style:{top:F.y,left:F.x}},lt.map((h,C)=>n.createElement("span",{key:C,style:{fontSize:"20px",cursor:"pointer",textAlign:"center"},onMouseDown:P=>{P.preventDefault(),w(h),R(!1)}},h))),document.body)),E.color&&n.createElement("div",{style:{position:"relative"}},n.createElement("button",{title:"Text Color",onMouseDown:h=>{var C;h.preventDefault(),c(),(C=q.current)==null||C.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((V=q.current)==null?void 0:V.value)||"#000",fontSize:"18px"},className:N.color?"rte-active":""},n.createElement(rt,null)),n.createElement("input",{ref:q,type:"color",defaultValue:"#000000",onChange:h=>{var C;Q(h),((C=h.target.parentElement)==null?void 0:C.querySelector("button")).style.color=h.target.value},style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),E.highlight&&n.createElement("div",{style:{position:"relative"}},n.createElement("button",{title:"Highlight",onMouseDown:h=>{var C;h.preventDefault(),c(),(C=D.current)==null||C.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((_=D.current)==null?void 0:_.value)||"#000",fontSize:"18px"},className:N.highlight?"rte-active":""},n.createElement(Ze,null)),n.createElement("input",{ref:D,type:"color",onChange:h=>{var C;G(h),((C=h.target.parentElement)==null?void 0:C.querySelector("button")).style.color=h.target.value},defaultValue:"#000000",style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),E.align&&n.createElement(n.Fragment,null,n.createElement("button",{title:"Align Left",onMouseDown:h=>h.preventDefault(),onClick:()=>o("justifyLeft"),className:N.alignLeft?"rte-active":""},n.createElement(Xe,null)),n.createElement("button",{title:"Align Center",onMouseDown:h=>h.preventDefault(),onClick:()=>o("justifyCenter"),className:N.alignCenter?"rte-active":""},n.createElement(Ve,null)),n.createElement("button",{title:"Align Right",onMouseDown:h=>h.preventDefault(),onClick:()=>o("justifyRight"),className:N.alignRight?"rte-active":""},n.createElement($e,null))),E.table&&n.createElement("button",{title:"Insert Table",onMouseDown:h=>h.preventDefault(),onClick:()=>o("insertTable"),className:N.table?"rte-active":""},n.createElement(tt,null)),E.fontFamily&&n.createElement("select",{className:"rte-dropdown",defaultValue:"",onMouseDown:()=>c(),onChange:p},n.createElement("option",{value:"",disabled:!0},"Font Family"),n.createElement("option",{value:"Arial"},"Arial"),n.createElement("option",{value:"Georgia"},"Georgia"),n.createElement("option",{value:"Times New Roman"},"Times New Roman"),n.createElement("option",{value:"Courier New"},"Courier New"),n.createElement("option",{value:"Verdana"},"Verdana")),E.fontSize&&n.createElement("select",{className:"rte-dropdown rte-fontsize-dropdown",defaultValue:"",onMouseDown:()=>c(),onChange:m},n.createElement("option",{value:"",disabled:!0},"Font Size"),Array.from({length:16},(h,C)=>10+C).map(h=>n.createElement("option",{key:h,value:h},h,"px"))))},at=({show:o,position:c,filtered:u,insertMention:m,onClose:p,query:w})=>{const x=n.useRef(null),[z,E]=n.useState(0);return n.useEffect(()=>{o&&E(0)},[o]),n.useEffect(()=>{const S=L=>{x.current&&!x.current.contains(L.target)&&p()};return o&&document.addEventListener("mousedown",S),()=>{document.removeEventListener("mousedown",S)}},[o,p]),n.useEffect(()=>{if(!o)return;const S=L=>{if(!(!o||u.length===0)&&(L.key==="ArrowDown"&&(L.preventDefault(),E(A=>Math.min(A+1,u.length-1))),L.key==="ArrowUp"&&(L.preventDefault(),E(A=>Math.max(A-1,0))),L.key==="Enter")){L.preventDefault();const A=u[z];A&&m(A)}};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[o,u,z]),n.useEffect(()=>{if(!x.current)return;const L=x.current.querySelectorAll("li")[z];L&&L.scrollIntoView({block:"nearest",behavior:"smooth"})},[z]),o?n.createElement("ul",{ref:x,className:"rte-popup",style:{top:c.y,left:c.x}},u.length>0?u.map(({name:S,value:L},A)=>{const q=S.toLowerCase(),D=w.toLowerCase(),B=q.indexOf(D);let R=S;if(B!==-1&&w.length>0){const F=B+w.length;R=S.substring(0,B)+`<span class="rte-highlight">${S.substring(B,F)}</span>`+S.substring(F)}return n.createElement("li",{key:L,onMouseDown:F=>{F.preventDefault(),m({name:S,value:L})},style:{padding:"6px 12px",cursor:"pointer",fontSize:"14px",background:A===z?"#dce8ff":"white"},dangerouslySetInnerHTML:{__html:R},onMouseEnter:()=>E(A)})}):n.createElement("li",{style:{padding:"6px 12px",color:"#999"}},"No matches")):null};function fe(o){return T({attr:{viewBox:"0 0 24 24"},child:[{tag:"g",attr:{id:"Circle_Minus"},child:[{tag:"g",attr:{},child:[{tag:"path",attr:{d:"M15,11.5h0a.5.5,0,0,1,0,1H9a.5.5,0,0,1,0-1Z"},child:[]},{tag:"path",attr:{d:"M12,21.934A9.933,9.933,0,1,1,21.932,12,9.945,9.945,0,0,1,12,21.934ZM12,3.068A8.933,8.933,0,1,0,20.932,12,8.944,8.944,0,0,0,12,3.068Z"},child:[]}]}]}]})(o)}function Z(o){return T({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:[]}]}]}]})(o)}const it=({visible:o,x:c,y:u,onAction:m,onClose:p})=>{if(!o)return null;const w={top:u,left:c};return n.createElement("div",{style:w,className:"rte-table-menu",onMouseLeave:p},n.createElement("button",{onClick:()=>m("insertRowAbove")},n.createElement(Z,null)," Insert row above"),n.createElement("button",{onClick:()=>m("insertRowBelow")},n.createElement(Z,null)," Insert row below"),n.createElement("button",{onClick:()=>m("insertColLeft")},n.createElement(Z,null)," Insert col left"),n.createElement("button",{onClick:()=>m("insertColRight")},n.createElement(Z,null)," Insert col right"),n.createElement("button",{onClick:()=>m("deleteRow")},n.createElement(fe,null)," Delete row"),n.createElement("button",{onClick:()=>m("deleteCol")},n.createElement(fe,null)," Delete column"))},ge=({html:o,className:c,style:u})=>{const m=w=>{const x=w.target;if(x.tagName==="A"){w.preventDefault();const z=x.href;z&&window.open(z,"_blank","noopener,noreferrer")}},p=w=>{let x=w.replace(/{{\s*(.*?)\s*}}/g,(z,E)=>`<span style="color: blue">${E}</span>`);return x=x.replace(/#arrayData/g,""),x=x.replace(/\/arrayData/g,""),x};return n.createElement("div",{className:`rte-preview ${c||""}`,style:u,onClick:m,dangerouslySetInnerHTML:{__html:p(o)}})},st=({visible:o,linkData:c,onClose:u,onInsert:m})=>{const[p,w]=n.useState(""),[x,z]=n.useState(""),[E,S]=n.useState(""),[L,A]=n.useState("_self");if(n.useEffect(()=>{o?(w(c.url||""),z(c.text||""),S(c.title||""),A(c.target||"_self")):(w(""),z(""),S(""),A("_self"))},[o,c]),!o)return null;const q=()=>{m({url:p,text:x,title:E,target:L})};return n.createElement(n.Fragment,null,n.createElement("div",{className:"rte-link-modal-overlay",onClick:u}),n.createElement("div",{className:"rte-link-modal"},n.createElement("h4",{className:"rte-link-modal__title"},p?"Edit Link":"Insert Link"),n.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"URL",value:p,onChange:D=>w(D.target.value)}),n.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Text to Display",value:x,onChange:D=>z(D.target.value)}),n.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Title",value:E,onChange:D=>S(D.target.value)}),n.createElement("select",{className:"rte-link-modal__select",value:L,onChange:D=>A(D.target.value)},n.createElement("option",{value:"_self"},"Same tab"),n.createElement("option",{value:"_blank"},"New tab")),n.createElement("div",{className:"rte-link-modal__actions"},n.createElement("button",{className:"rte-link-modal__btn",onClick:u},"Cancel"),n.createElement("button",{className:"rte-link-modal__btn rte-link-modal__btn--ok",onClick:q},"OK"))))};function he(o){return Array.from(new Map(o.map(c=>[c.value,c])).values())}const ct=({atSuggestions:o=[],showOutput:c=!1,showPreview:u=!1,toolbarConfig:m={link:!1,image:!1,emoji:!1,table:!1,color:!1,fontFamily:!1,fontSize:!1,highlight:!1},classNames:p={},styles:w={},handleGetHtml:x=()=>{},onChange:z=()=>{},value:E,onMentionSelect:S=()=>{},handleAddAttributes:L=()=>{}})=>{var Se,Le,Me,Ae,ke,ze,Ne,Te;const A=n.useRef(null),[q,D]=n.useState(E!=null&&E.length?E:" "),[B,R]=n.useState(""),[F,I]=n.useState(!1),[U,Q]=n.useState({x:0,y:0}),[G,N]=n.useState([]),O=n.useRef(null),V=n.useRef(null),[_,h]=n.useState({visible:!1,x:0,y:0}),[C,P]=n.useState(!1),J=n.useRef(null),[dt,pe]=n.useState({url:"",text:"",title:"",target:"_self"}),ut={bold:!0,italic:!0,underline:!0,removeFormat:!0,unorderedList:!0,orderedList:!0,align:!0,link:(Se=m.link)!=null?Se:!1,image:(Le=m.image)!=null?Le:!1,emoji:(Me=m.emoji)!=null?Me:!1,table:(Ae=m.table)!=null?Ae:!1,color:(ke=m.color)!=null?ke:!1,fontFamily:(ze=m.fontFamily)!=null?ze:!1,fontSize:(Ne=m.fontSize)!=null?Ne:!1,highlight:(Te=m.fontSize)!=null?Te:!1},[mt,ee]=n.useState(""),[ve,te]=n.useState([]),H=()=>A.current,M=()=>{const e=ft(),t=/^<div[^>]*style=["'][^"']*font-size\s*:\s*\d+px[^"']*["'][^>]*>/.test(e.trim());let r=e;t||(r=`<div style="font-size:12px">${e}</div>`),r=r.replace(/<(ul|ol)([^>]*)>/g,(i,v,y)=>/data-hidden-array-start/.test(i)?i:`<${v}${y}>
2
- <span data-hidden-array-start="true" style="display:none">{{#arrayData}}</span>`),r=r.replace(/<\/(ul|ol)>/g,(i,v)=>/data-hidden-array-end/.test(i)?i:`<span data-hidden-array-end="true" style="display:none">{{/arrayData}}</span></${v}>`),R(r),x==null||x(r);const l=Ht(e);z(l);const s=Ct(),a=he(s);JSON.stringify(a)!==JSON.stringify(ve)&&(te(a),S(a))},ft=()=>{const e=H();if(!e)return q;const t=e.cloneNode(!0);t.querySelectorAll("table div").forEach(l=>l.remove()),t.querySelectorAll(".rte-cell-highlight").forEach(l=>l.classList.remove("rte-cell-highlight"));let r=t.innerHTML;return r=gt(r),r},gt=e=>e.replace(/<tbody[^>]*>/g,"<tbody>{{#arrayData}}").replace(/<\/tbody>/g,"{{/arrayData}}</tbody>"),$=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return;const t=document.getElementById("rte-editor-body");if(!t)return;const r=e.getRangeAt(0);t.contains(r.startContainer)&&(O.current=r.cloneRange())},W=()=>{const e=window.getSelection();!e||!O.current||(e.removeAllRanges(),e.addRange(O.current))},ye=(e,t)=>{const r=window.getSelection();r&&r.rangeCount>0&&(O.current=r.getRangeAt(0)),W(),document.execCommand(e,!1,t),M()};n.useEffect(()=>{const e=H();if(!e||!E)return;const t=ht(E);e.innerHTML=t,M()},[]);const ht=e=>e.replace(/<span[^>]*data-hidden-table-start[^>]*>.*?<\/span>/g,"").replace(/<span[^>]*data-hidden-table-end[^>]*>.*?<\/span>/g,"").replace(/{{#arrayData}}/g,"").replace(/{{\/arrayData}}/g,"");n.useEffect(()=>()=>{document.removeEventListener("mousemove",null),document.removeEventListener("mouseup",null)},[]),n.useEffect(()=>{L&&L(e=>{wt(e)})},[]),n.useEffect(()=>{const e=H();if(!e)return;e.querySelectorAll("table").forEach(r=>{oe(r),r.querySelectorAll("th, td").forEach(s=>K(s))})},[]);const Ee=e=>{for(;e&&e.nodeName!=="LI";)e=e.parentNode;return e},we=e=>{var v;const t=window.getSelection();if(!(t!=null&&t.rangeCount))return;const r=t.getRangeAt(0),l=Ee(r.startContainer);let s,a;if(l){let y=l.querySelector(e);y||(y=document.createElement(e),y.style.margin="0",y.style.paddingLeft="20px",l.appendChild(y)),a=y,s=document.createElement("li"),s.textContent="​",a.appendChild(s)}else{document.execCommand(e==="ul"?"insertUnorderedList":"insertOrderedList");const y=H();if(a=y==null?void 0:y.querySelector(`${e}:last-child`),!a)return;s=a.querySelector("li:last-child")}const i=document.createRange();i.setStart(s,0),i.collapse(!0),t.removeAllRanges(),t.addRange(i),(v=H())==null||v.focus(),M()},ne=(e,t)=>{e==="insertOrderedList"?we("ol"):e==="insertUnorderedList"?we("ul"):e.startsWith("justify")?_t(e):ye(e,t),e==="insertTable"&&Mt()},pt=e=>{const t=document.createElement("span");t.textContent="​",e.insertNode(t),e.setStartAfter(t),e.collapse(!0);const r=t.getBoundingClientRect();t.remove(),Q({x:r.left,y:r.bottom+window.scrollY}),N(o||[]),I(!0),V.current=e.cloneRange()},vt=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return null;const t=e.anchorNode;let r=e.anchorOffset;if(!t)return null;let l=t;for(l.nodeType!==Node.TEXT_NODE&&(l.childNodes&&l.childNodes[r]?l=l.childNodes[r]:l=t.previousSibling);l;){if(l.nodeType===Node.TEXT_NODE){const s=l.textContent||"",a=l===t?r:s.length,i=s.lastIndexOf("@",a-1);if(i!==-1){const v=document.createRange();return v.setStart(l,i),v.setEnd(l,a),v}}l=l.previousSibling}return null},yt=e=>{var a;const t=window.getSelection();if(!t)return;const r=vt();r?(t.removeAllRanges(),t.addRange(r)):V.current&&(t.removeAllRanges(),t.addRange(V.current));const l=document.createElement("span");l.textContent=`{{${e.name}}}`,l.style.display="inline",l.setAttribute("data-mention",e.value||e.name||"");try{const i=t.rangeCount?t.getRangeAt(0):null;if(i)i.deleteContents(),i.insertNode(l);else{const g=document.createRange(),d=H();g.selectNodeContents(d),g.collapse(!1),g.insertNode(l)}const v=document.createTextNode(" ");l.after(v);const y=document.createRange();y.setStartAfter(v),y.collapse(!0),t.removeAllRanges(),t.addRange(y)}catch(i){console.error("insertMention error:",i)}let s=he([...ve,e]);te(s),S(s),I(!1),(a=H())==null||a.focus(),M()},Et=e=>{const t=H();if(!t)return;let r=null;O.current&&t.contains(O.current.startContainer)?r=O.current.cloneRange():(r=document.createRange(),r.selectNodeContents(t),r.collapse(!1));const l=window.getSelection();if(!l)return;l.removeAllRanges(),l.addRange(r);const s=document.createElement("span");s.textContent=`{{${e.name}}}`,s.style.display="inline",s.setAttribute("data-mention",e.value||e.name),r.insertNode(s);const a=document.createTextNode(" ");s.after(a);const i=document.createRange();i.setStartAfter(a),i.collapse(!0),l.removeAllRanges(),l.addRange(i),O.current=i.cloneRange(),t.focus()},wt=e=>{e.forEach(t=>Et(t)),te(t=>{const r=[...t,...e],l=Array.from(new Map(r.map(s=>[s.name,s])).values());return S(l),l}),M()},Ct=()=>{const e=H();if(!e)return[];const t=e.querySelectorAll("span[data-mention]"),r=[];return t.forEach(l=>{const s=l.getAttribute("data-mention")||"",i=(l.textContent||"").match(/{{(.+?)}}/);i&&r.push({name:i[1],value:s})}),r},bt=e=>{var r,l,s;const t=e.key.toLowerCase();if((e.ctrlKey||e.metaKey)&&["b","i","u"].includes(t)&&(e.preventDefault(),ne(t==="b"?"bold":t==="i"?"italic":t==="u"?"underline":"")),e.shiftKey&&e.key==="2"&&e.preventDefault(),e.key==="Enter"){const a=window.getSelection(),i=a!=null&&a.anchorNode?Ee(a.anchorNode):null;if(!i)return;if(((r=i.textContent)==null?void 0:r.replace(/\u200B/g,"").trim())===""){e.preventDefault();const y=i.parentElement,g=y==null?void 0:y.closest("li");if(g){y==null||y.removeChild(i);const d=document.createElement("p");d.innerHTML="<br />",(l=g.parentElement)==null||l.insertBefore(d,g.nextSibling);const f=document.createRange();f.setStart(d,0),f.collapse(!0),a==null||a.removeAllRanges(),a==null||a.addRange(f)}else{const d=i.closest("ul, ol");if(d){const f=document.createElement("p");f.innerHTML="<br />",(s=d.parentElement)==null||s.insertBefore(f,d.nextSibling),d.removeChild(i);const b=document.createRange();b.setStart(f,0),b.collapse(!0),a==null||a.removeAllRanges(),a==null||a.addRange(b)}}M()}}},xt=e=>{if(e.data==="@"){const r=window.getSelection();if(!(r!=null&&r.rangeCount))return;const l=r.anchorNode;if(re(l))return;setTimeout(()=>{pt(r.getRangeAt(0)),ee(""),N(o),I(!0)},0);return}if(F){setTimeout(()=>Ce(),0);return}},re=e=>{if(!e)return!1;let t=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;for(;t;){if(t.tagName==="TH")return!0;t=t.parentElement}return!1},Ce=()=>{M();const e=window.getSelection();if(!e||!e.anchorNode)return;if(re(e.anchorNode)){I(!1);return}let t=e.anchorNode.textContent||"";t=t.replace(/\u00A0/g," ");const r=t.match(/@([^\n]*)$/);if(!r){I(!1);return}const l=r[1].trim().toLowerCase();ee(l);const s=o.filter(a=>a.name.toLowerCase().includes(l));s.length>0?(N(s),I(!0)):I(!1)},St=e=>{var l;const t=(l=e.target.files)==null?void 0:l[0];if(!t)return;const r=new FileReader;r.onload=s=>{var b;const a=(b=s.target)==null?void 0:b.result;W();const i=window.getSelection();let v=i&&i.rangeCount?i.getRangeAt(0):null;const y=document.createElement("img");y.src=a,y.alt=t.name||"image",y.className="rte-inserted-image",y.contentEditable="true";const g=H();if(!v||!g){g==null||g.appendChild(y);const De=document.createTextNode(" ");g==null||g.appendChild(De);const le=document.createRange();le.setStartAfter(De),le.collapse(!0),i==null||i.removeAllRanges(),i==null||i.addRange(le),g==null||g.focus(),M(),e.target.value="";return}v.deleteContents(),v.insertNode(y);const d=document.createTextNode(" ");y.after(d);const f=document.createRange();f.setStartAfter(d),f.collapse(!0),i.removeAllRanges(),i.addRange(f),g.focus(),M(),e.target.value=""},r.readAsDataURL(t)},Lt=e=>{var s;W();const t=window.getSelection();if(!(t!=null&&t.rangeCount))return;const r=t.getRangeAt(0),l=document.createTextNode(e);r.insertNode(l),r.setStartAfter(l),r.collapse(!0),t.removeAllRanges(),t.addRange(r),(s=H())==null||s.focus(),M()},Mt=()=>{var g;qt(),W();const e=document.createElement("table");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);const t=document.createElement("thead");p.thead&&t.classList.add(p.thead);const r=document.createElement("tbody");p.tbody&&r.classList.add(p.tbody);const l=document.createElement("tr");p.tr&&l.classList.add(p.tr);const s=document.createElement("tr");p.tr&&s.classList.add(p.tr);for(let d=0;d<2;d++){const f=document.createElement("th");f.textContent="",f.style.border="1px solid #999",f.style.padding="4px",f.style.position="relative",f.style.backgroundColor="lightgray",f.style.height="20px",p.th&&f.classList.add(p.th);const b=document.createElement("td");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),K(f),K(b),l.appendChild(f),s.appendChild(b)}t.appendChild(l),r.appendChild(s),e.appendChild(t),e.appendChild(r),oe(e);const a=window.getSelection();if(!(a!=null&&a.rangeCount))return;const i=a.getRangeAt(0);i.collapse(!1),i.insertNode(e);const v=document.createElement("p");v.innerHTML="<br/>",e.after(v);const y=document.createRange();y.setStart(v,0),y.collapse(!0),a.removeAllRanges(),a.addRange(y),(g=H())==null||g.focus(),M()},oe=e=>{const t=document.createElement("div");Object.assign(t.style,{position:"absolute",width:"14px",height:"14px",right:"0",bottom:"0",background:"rgba(0,0,0,0.25)",cursor:"nwse-resize",zIndex:"20",borderRadius:"2px"}),t.style.userSelect="none",t.contentEditable="false";let r=0,l=0,s=0,a=0;t.addEventListener("mousedown",i=>{i.preventDefault(),r=i.clientX,l=i.clientY;const v=e.getBoundingClientRect();s=v.width,a=v.height;const y=d=>{const f=Math.max(100,s+(d.clientX-r)),b=Math.max(20,a+(d.clientY-l));e.style.width=`${f}px`,e.style.height=`${b}px`,M()},g=()=>{document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",g),M()};document.addEventListener("mousemove",y),document.addEventListener("mouseup",g)}),e.appendChild(t)},K=e=>{const t=document.createElement("div"),r=document.createElement("div");Object.assign(t.style,{position:"absolute",right:"0",top:"0",width:"4px",height:"100%",cursor:"col-resize",background:"rgba(0,0,0,0.15)",zIndex:"10",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none",pointerEvents:"auto"}),t.contentEditable="false",Object.assign(r.style,{position:"absolute",bottom:"0",left:"0",width:"100%",height:"4px",cursor:"row-resize",background:"rgba(0,0,0,0.15)",zIndex:"10",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none",pointerEvents:"auto"}),r.contentEditable="false",At(e,t,r),e.appendChild(t),e.appendChild(r)},At=(e,t,r)=>{let l=0,s=0,a=0,i=0;t.addEventListener("mousedown",d=>{d.preventDefault(),l=d.clientX,a=e.offsetWidth,document.addEventListener("mousemove",v),document.addEventListener("mouseup",g)}),r.addEventListener("mousedown",d=>{d.preventDefault(),s=d.clientY,i=e.offsetHeight,document.addEventListener("mousemove",y),document.addEventListener("mouseup",g)});const v=d=>{const f=a+(d.clientX-l);e.style.width=`${Math.max(30,f)}px`,M()},y=d=>{const f=i+(d.clientY-s);e.style.height=`${Math.max(20,f)}px`,M()},g=()=>{document.removeEventListener("mousemove",v),document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",g),M()}},kt=e=>{const r=e.target.closest("td, th");r&&(e.preventDefault(),document.querySelectorAll(".rte-cell-highlight").forEach(l=>l.classList.remove("rte-cell-highlight")),r.classList.add("rte-cell-highlight"),h({visible:!0,x:e.clientX,y:e.clientY,cell:r}))},be=()=>{document.querySelectorAll(".rte-cell-highlight").forEach(e=>e.classList.remove("rte-cell-highlight"))},zt=e=>{if(!_.cell)return;const t=_.cell.closest("table"),r=_.cell.cellIndex,l=_.cell.parentElement.rowIndex,s=a=>{const i=a.tagName.toLowerCase(),v=document.createElement(i);return v.textContent="",v.style.cssText=a.style.cssText,K(v),v};switch(e){case"insertRowAbove":{const a=t.rows[l],i=t.insertRow(l);Array.from(a.cells).forEach(v=>{i.appendChild(s(v))});break}case"insertRowBelow":{const a=t.rows[l],i=t.insertRow(l+1);Array.from(a.cells).forEach(v=>{i.appendChild(s(v))});break}case"insertColLeft":{Array.from(t.rows).forEach(a=>{const i=a.cells[r];a.insertBefore(s(i),i)});break}case"insertColRight":{Array.from(t.rows).forEach(a=>{const i=a.cells[r];a.insertBefore(s(i),i.nextSibling)});break}case"deleteRow":t.rows.length>1&&t.deleteRow(l);break;case"deleteCol":Array.from(t.rows).forEach(a=>{a.cells[r]&&a.deleteCell(r)});break}M(),h(ie(ae({},_),{visible:!1})),be()},Nt=()=>{$(),J.current=O.current,pe({url:"",text:"",title:"",target:"_self"}),P(!0)},Tt=e=>{const t=window.getSelection();if(!t||!J.current)return;t.removeAllRanges(),t.addRange(J.current);let r=e.url.trim();/^https?:\/\//i.test(r)||(r="https://"+r);const l=document.createElement("a");l.href=r,l.style.cursor="pointer",l.style.outline="none",l.textContent=e.text||r,l.title=e.title,l.target=e.target,l.contentEditable="true";const s=t.getRangeAt(0);s.deleteContents(),s.insertNode(l);const a=document.createTextNode(" ");l.after(a);const i=document.createRange();i.setStartAfter(a),i.collapse(!0),t.removeAllRanges(),t.addRange(i),P(!1),M()},Dt=e=>{const t=e.target;if(t.tagName==="A"){const r=t;if(e.ctrlKey||e.metaKey){window.open(r.href,"_blank","noopener,noreferrer");return}e.preventDefault();const l=document.createRange();l.selectNode(r),J.current=l,pe({url:r.href,text:r.textContent||r.href,title:r.title,target:r.target}),P(!0)}},Ot=()=>{const e=H();if(!e)return;const t=window.getSelection();if((!t||t.rangeCount===0)&&O.current){const d=window.getSelection();d==null||d.removeAllRanges(),d==null||d.addRange(O.current)}const r=window.getSelection();if(!r||r.rangeCount===0)return;const l=r.getRangeAt(0);W(),document.execCommand("removeFormat",!1);const s=l.cloneContents(),a=document.createElement("div");a.appendChild(s);const i=document.createTreeWalker(a,NodeFilter.SHOW_ELEMENT,null),v=[];for(;i.nextNode();){const d=i.currentNode,f=d.tagName.toUpperCase(),b=d.getAttribute&&d.getAttribute("data-mention")!==null;f!=="A"&&!b&&v.push(d)}for(let d=v.length-1;d>=0;d--){const f=v[d],b=f.parentNode;if(b){for(;f.firstChild;)b.insertBefore(f.firstChild,f);b.removeChild(f)}}a.querySelectorAll("[style]").forEach(d=>d.removeAttribute("style")),l.deleteContents();const y=document.createDocumentFragment();for(;a.firstChild;)y.appendChild(a.firstChild);l.insertNode(y);const g=document.createRange();g.setStartAfter(l.endContainer.nodeType===Node.TEXT_NODE?l.endContainer:l.startContainer),g.collapse(!0),r.removeAllRanges(),r.addRange(g),e.normalize(),M()},Ht=e=>{var l;let t=e;t=t.replace(/{{#arrayData\d*}}/g,""),t=t.replace(/{{\/arrayData\d*}}/g,"");const r=document.createElement("div");return r.innerHTML=t,r.querySelectorAll("br").forEach(s=>{s.replaceWith(`
1
+ (function(z,n){typeof exports=="object"&&typeof module!="undefined"?n(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],n):(z=typeof globalThis!="undefined"?globalThis:z||self,n(z.RichTextEditor={},z.React,z.ReactDOM))})(this,(function(z,n,j){"use strict";var Bt=Object.defineProperty,Rt=Object.defineProperties;var Ut=Object.getOwnPropertyDescriptors;var Oe=Object.getOwnPropertySymbols;var Vt=Object.prototype.hasOwnProperty,$t=Object.prototype.propertyIsEnumerable;var He=(z,n,j)=>n in z?Bt(z,n,{enumerable:!0,configurable:!0,writable:!0,value:j}):z[n]=j,ae=(z,n)=>{for(var j in n||(n={}))Vt.call(n,j)&&He(z,j,n[j]);if(Oe)for(var j of Oe(n))$t.call(n,j)&&He(z,j,n[j]);return z},ie=(z,n)=>Rt(z,Ut(n));function je(l){const c=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(l){for(const d in l)if(d!=="default"){const m=Object.getOwnPropertyDescriptor(l,d);Object.defineProperty(c,d,m.get?m:{enumerable:!0,get:()=>l[d]})}}return c.default=l,Object.freeze(c)}const _e=je(n);window.React=_e;var se={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},ce=n.createContext&&n.createContext(se),Ie=["attr","size","title"];function Pe(l,c){if(l==null)return{};var d=Fe(l,c),m,p;if(Object.getOwnPropertySymbols){var w=Object.getOwnPropertySymbols(l);for(p=0;p<w.length;p++)m=w[p],!(c.indexOf(m)>=0)&&Object.prototype.propertyIsEnumerable.call(l,m)&&(d[m]=l[m])}return d}function Fe(l,c){if(l==null)return{};var d={};for(var m in l)if(Object.prototype.hasOwnProperty.call(l,m)){if(c.indexOf(m)>=0)continue;d[m]=l[m]}return d}function X(){return X=Object.assign?Object.assign.bind():function(l){for(var c=1;c<arguments.length;c++){var d=arguments[c];for(var m in d)Object.prototype.hasOwnProperty.call(d,m)&&(l[m]=d[m])}return l},X.apply(this,arguments)}function de(l,c){var d=Object.keys(l);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(l);c&&(m=m.filter(function(p){return Object.getOwnPropertyDescriptor(l,p).enumerable})),d.push.apply(d,m)}return d}function Y(l){for(var c=1;c<arguments.length;c++){var d=arguments[c]!=null?arguments[c]:{};c%2?de(Object(d),!0).forEach(function(m){qe(l,m,d[m])}):Object.getOwnPropertyDescriptors?Object.defineProperties(l,Object.getOwnPropertyDescriptors(d)):de(Object(d)).forEach(function(m){Object.defineProperty(l,m,Object.getOwnPropertyDescriptor(d,m))})}return l}function qe(l,c,d){return c=Be(c),c in l?Object.defineProperty(l,c,{value:d,enumerable:!0,configurable:!0,writable:!0}):l[c]=d,l}function Be(l){var c=Re(l,"string");return typeof c=="symbol"?c:c+""}function Re(l,c){if(typeof l!="object"||!l)return l;var d=l[Symbol.toPrimitive];if(d!==void 0){var m=d.call(l,c);if(typeof m!="object")return m;throw new TypeError("@@toPrimitive must return a primitive value.")}return(c==="string"?String:Number)(l)}function ue(l){return l&&l.map((c,d)=>n.createElement(c.tag,Y({key:d},c.attr),ue(c.child)))}function T(l){return c=>n.createElement(Ue,X({attr:Y({},l.attr)},c),ue(l.child))}function Ue(l){var c=d=>{var{attr:m,size:p,title:w}=l,x=Pe(l,Ie),k=p||d.size||"1em",E;return d.className&&(E=d.className),l.className&&(E=(E?E+" ":"")+l.className),n.createElement("svg",X({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},d.attr,m,x,{className:E,style:Y(Y({color:l.color||d.color},d.style),l.style),height:k,width:k,xmlns:"http://www.w3.org/2000/svg"}),w&&n.createElement("title",null,w),l.children)};return ce!==void 0?n.createElement(ce.Consumer,null,d=>c(d)):c(se)}function Ve(l){return T({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:[]}]})(l)}function $e(l){return T({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M448 64c0 17.7-14.3 32-32 32L192 96c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zm0 256c0 17.7-14.3 32-32 32l-224 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zM0 192c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 224c-17.7 0-32-14.3-32-32zM448 448c0 17.7-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32s14.3-32 32-32l384 0c17.7 0 32 14.3 32 32z"},child:[]}]})(l)}function We(l){return T({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M0 96C0 60.7 28.7 32 64 32l384 0c35.3 0 64 28.7 64 64l0 320c0 35.3-28.7 64-64 64L64 480c-35.3 0-64-28.7-64-64L0 96zM323.8 202.5c-4.5-6.6-11.9-10.5-19.8-10.5s-15.4 3.9-19.8 10.5l-87 127.6L170.7 297c-4.6-5.7-11.5-9-18.7-9s-14.2 3.3-18.7 9l-64 80c-5.8 7.2-6.9 17.1-2.9 25.4s12.4 13.6 21.6 13.6l96 0 32 0 208 0c8.9 0 17.1-4.9 21.2-12.8s3.6-17.4-1.4-24.7l-120-176zM112 192a48 48 0 1 0 0-96 48 48 0 1 0 0 96z"},child:[]}]})(l)}function Ke(l){return T({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M24 56c0-13.3 10.7-24 24-24l32 0c13.3 0 24 10.7 24 24l0 120 16 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-80 0c-13.3 0-24-10.7-24-24s10.7-24 24-24l16 0 0-96-8 0C34.7 80 24 69.3 24 56zM86.7 341.2c-6.5-7.4-18.3-6.9-24 1.2L51.5 357.9c-7.7 10.8-22.7 13.3-33.5 5.6s-13.3-22.7-5.6-33.5l11.1-15.6c23.7-33.2 72.3-35.6 99.2-4.9c21.3 24.4 20.8 60.9-1.1 84.7L86.8 432l33.2 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-88 0c-9.5 0-18.2-5.6-22-14.4s-2.1-18.9 4.3-25.9l72-78c5.3-5.8 5.4-14.6 .3-20.5zM224 64l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 160l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 160l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32z"},child:[]}]})(l)}function Xe(l){return T({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M12.83 352h262.34A12.82 12.82 0 0 0 288 339.17v-38.34A12.82 12.82 0 0 0 275.17 288H12.83A12.82 12.82 0 0 0 0 300.83v38.34A12.82 12.82 0 0 0 12.83 352zm0-256h262.34A12.82 12.82 0 0 0 288 83.17V44.83A12.82 12.82 0 0 0 275.17 32H12.83A12.82 12.82 0 0 0 0 44.83v38.34A12.82 12.82 0 0 0 12.83 96zM432 160H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0 256H16a16 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:[]}]})(l)}function Ye(l){return T({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M333.49 238a122 122 0 0 0 27-65.21C367.87 96.49 308 32 233.42 32H34a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h31.87v288H34a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h209.32c70.8 0 134.14-51.75 141-122.4 4.74-48.45-16.39-92.06-50.83-119.6zM145.66 112h87.76a48 48 0 0 1 0 96h-87.76zm87.76 288h-87.76V288h87.76a56 56 0 0 1 0 112z"},child:[]}]})(l)}function Ze(l){return T({attr:{viewBox:"0 0 544 512"},child:[{tag:"path",attr:{d:"M0 479.98L99.92 512l35.45-35.45-67.04-67.04L0 479.98zm124.61-240.01a36.592 36.592 0 0 0-10.79 38.1l13.05 42.83-50.93 50.94 96.23 96.23 50.86-50.86 42.74 13.08c13.73 4.2 28.65-.01 38.15-10.78l35.55-41.64-173.34-173.34-41.52 35.44zm403.31-160.7l-63.2-63.2c-20.49-20.49-53.38-21.52-75.12-2.35L190.55 183.68l169.77 169.78L530.27 154.4c19.18-21.74 18.15-54.63-2.35-75.13z"},child:[]}]})(l)}function Qe(l){return T({attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M320 48v32a16 16 0 0 1-16 16h-62.76l-80 320H208a16 16 0 0 1 16 16v32a16 16 0 0 1-16 16H16a16 16 0 0 1-16-16v-32a16 16 0 0 1 16-16h62.76l80-320H112a16 16 0 0 1-16-16V48a16 16 0 0 1 16-16h192a16 16 0 0 1 16 16z"},child:[]}]})(l)}function Je(l){return T({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:[]}]})(l)}function Ge(l){return T({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:[]}]})(l)}function et(l){return T({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:[]}]})(l)}function tt(l){return T({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M464 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h416c26.51 0 48-21.49 48-48V80c0-26.51-21.49-48-48-48zM224 416H64v-96h160v96zm0-160H64v-96h160v96zm224 160H288v-96h160v96zm0-160H288v-96h160v96z"},child:[]}]})(l)}function nt(l){return T({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:[]}]})(l)}function rt(l){return T({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:[]}]})(l)}function ot(l){return T({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:[]}]})(l)}const lt=["😀","😁","😂","đŸ¤Ŗ","😃","😄","😅","😉","😊","😍","😘","😜","😎","đŸ˜ĸ","😭","😡","🤔","🙄","😇","đŸĨ°","🤩","🤗","😴","😋","đŸ˜Ŧ","🤤","đŸ˜ļ‍đŸŒĢī¸","😷","🤕","🤑","🤠","😈","đŸ‘ģ","💀","🤖","đŸļ","🐱","đŸŧ","🐸","đŸĻ„","🐷","đŸĩ","🐰","đŸ¯","đŸĻ","🐮","🌞","🌙","⭐","🌈","đŸ”Ĩ","💧","â„ī¸","⚡","â˜€ī¸","🌸","🌹","🍎","🍕","🍩","🍔","🍟","🍇","🍉","🍓","🍒","đŸĨ­","đŸĨ‘","🎉","🎂","🎁","🎈","đŸŽļ","đŸŽĩ","🏆","âšŊ","🏀","🏸","🏏","đŸ•šī¸","👋","🤚","đŸ–ī¸","✋","🖖","👍","👎","👌","🤌","🤏","✊","👊","🤛","🤜","â˜ī¸","👆","👇","👈","👉","🤟","🤘","🤙","🙌","👏","🙏","âœī¸","💅","🤲","👏","đŸĢļ","👐"],me=({exec:l,saveSelection:c,handleFileChange:d,handleFontSizeChange:m,handleFontFamilyChange:p,insertEmoji:w,handleLink:x,removeFormatting:k,visibleActions:E,className:S,style:L})=>{var V,_;const M=n.useRef(null),q=n.useRef(null),D=n.useRef(null),[B,R]=n.useState(!1),[F,I]=n.useState({x:0,y:0});n.useEffect(()=>{const h=C=>{!C.target.closest(".rte-emoji-popup")&&!C.target.closest("button[title='Emoji']")&&R(!1)};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[]);const U=h=>{var P;h.preventDefault();const C=h.currentTarget.dataset.command;if(C)switch(C){case"bold":case"italic":case"underline":case"insertUnorderedList":case"insertOrderedList":case"removeFormat":l(C);break;case"insertImage":{(P=M.current)==null||P.click();break}default:console.warn("Unknown command:",C)}},Q=h=>{l("foreColor",h.target.value)},G=h=>{l("backColor",h.target.value)},[N,O]=n.useState({bold:!1,italic:!1,underline:!1,unorderedList:!1,orderedList:!1,alignLeft:!1,alignCenter:!1,alignRight:!1,removeFormat:!1,link:!1,image:!1,emoji:!1,table:!1,color:!1,highlight:!1});return n.useEffect(()=>{const h=()=>{O({bold:document.queryCommandState("bold"),italic:document.queryCommandState("italic"),underline:document.queryCommandState("underline"),unorderedList:document.queryCommandState("insertUnorderedList"),orderedList:document.queryCommandState("insertOrderedList"),alignLeft:document.queryCommandState("justifyLeft"),alignCenter:document.queryCommandState("justifyCenter"),alignRight:document.queryCommandState("justifyRight"),removeFormat:document.queryCommandState("removeFormat"),link:document.queryCommandState("createLink"),image:document.queryCommandState("insertImage"),emoji:document.queryCommandState("insertEmoji"),table:document.queryCommandState("insertTable"),color:document.queryCommandState("foreColor"),highlight:document.queryCommandState("backColor")})};return document.addEventListener("selectionchange",h),()=>document.removeEventListener("selectionchange",h)},[]),n.createElement("div",{className:`rte-toolbar ${S||""}`,style:L},E.bold&&n.createElement("button",{"data-command":"bold",title:"Bold",onMouseDown:U,className:N.bold?"rte-active":""},n.createElement(Ye,null)),E.italic&&n.createElement("button",{"data-command":"italic",title:"Italic",onMouseDown:U,className:N.italic?"rte-active":""},n.createElement(Qe,null)),E.underline&&n.createElement("button",{"data-command":"underline",title:"Underline",onMouseDown:U,className:N.underline?"rte-active":""},n.createElement(nt,null)),E.unorderedList&&n.createElement("button",{"data-command":"insertUnorderedList",onMouseDown:U,title:"UnorderedList",className:N.unorderedList?"rte-active":""},n.createElement(Ge,null)),E.orderedList&&n.createElement("button",{"data-command":"insertOrderedList",title:"OrderedList",onMouseDown:U,className:N.orderedList?"rte-active":""},n.createElement(Ke,null)),E.link&&n.createElement("button",{"data-command":"createLink",title:"Link",onClick:x,className:N.link?"rte-active":""},n.createElement(Je,null)),E.removeFormat&&n.createElement("button",{"data-command":"Remove format",title:"removeFormat",onMouseDown:h=>{h.preventDefault(),c(),k()},className:N.removeFormat?"rte-active":""},n.createElement(ot,null)),E.image&&n.createElement("button",{"data-command":"insertImage",title:"Image",onMouseDown:U,className:N.image?"rte-active":""},n.createElement(We,null)),n.createElement("input",{type:"file",accept:"image/*",ref:M,style:{display:"none"},onChange:d}),E.emoji&&n.createElement("div",{style:{position:"relative"}},n.createElement("button",{title:"Emoji",onMouseDown:h=>{h.preventDefault(),c();const C=h.currentTarget.getBoundingClientRect();I({x:C.left,y:C.bottom+8}),R(P=>!P)},className:N.emoji?"rte-active":""},n.createElement(et,null)),B&&j.createPortal(n.createElement("div",{className:"rte-emoji-popup",style:{top:F.y,left:F.x}},lt.map((h,C)=>n.createElement("span",{key:C,style:{fontSize:"20px",cursor:"pointer",textAlign:"center"},onMouseDown:P=>{P.preventDefault(),w(h),R(!1)}},h))),document.body)),E.color&&n.createElement("div",{style:{position:"relative"}},n.createElement("button",{title:"Text Color",onMouseDown:h=>{var C;h.preventDefault(),c(),(C=q.current)==null||C.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((V=q.current)==null?void 0:V.value)||"#000",fontSize:"18px"},className:N.color?"rte-active":""},n.createElement(rt,null)),n.createElement("input",{ref:q,type:"color",defaultValue:"#000000",onChange:h=>{var C;Q(h),((C=h.target.parentElement)==null?void 0:C.querySelector("button")).style.color=h.target.value},style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),E.highlight&&n.createElement("div",{style:{position:"relative"}},n.createElement("button",{title:"Highlight",onMouseDown:h=>{var C;h.preventDefault(),c(),(C=D.current)==null||C.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((_=D.current)==null?void 0:_.value)||"#000",fontSize:"18px"},className:N.highlight?"rte-active":""},n.createElement(Ze,null)),n.createElement("input",{ref:D,type:"color",onChange:h=>{var C;G(h),((C=h.target.parentElement)==null?void 0:C.querySelector("button")).style.color=h.target.value},defaultValue:"#000000",style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),E.align&&n.createElement(n.Fragment,null,n.createElement("button",{title:"Align Left",onMouseDown:h=>h.preventDefault(),onClick:()=>l("justifyLeft"),className:N.alignLeft?"rte-active":""},n.createElement(Xe,null)),n.createElement("button",{title:"Align Center",onMouseDown:h=>h.preventDefault(),onClick:()=>l("justifyCenter"),className:N.alignCenter?"rte-active":""},n.createElement(Ve,null)),n.createElement("button",{title:"Align Right",onMouseDown:h=>h.preventDefault(),onClick:()=>l("justifyRight"),className:N.alignRight?"rte-active":""},n.createElement($e,null))),E.table&&n.createElement("button",{title:"Insert Table",onMouseDown:h=>h.preventDefault(),onClick:()=>l("insertTable"),className:N.table?"rte-active":""},n.createElement(tt,null)),E.fontFamily&&n.createElement("select",{className:"rte-dropdown",defaultValue:"",onMouseDown:()=>c(),onChange:p},n.createElement("option",{value:"",disabled:!0},"Font Family"),n.createElement("option",{value:"Arial"},"Arial"),n.createElement("option",{value:"Georgia"},"Georgia"),n.createElement("option",{value:"Times New Roman"},"Times New Roman"),n.createElement("option",{value:"Courier New"},"Courier New"),n.createElement("option",{value:"Verdana"},"Verdana")),E.fontSize&&n.createElement("select",{className:"rte-dropdown rte-fontsize-dropdown",defaultValue:"",onMouseDown:()=>c(),onChange:m},n.createElement("option",{value:"",disabled:!0},"Font Size"),Array.from({length:16},(h,C)=>10+C).map(h=>n.createElement("option",{key:h,value:h},h,"px"))))},at=({show:l,position:c,filtered:d,insertMention:m,onClose:p,query:w})=>{const x=n.useRef(null),[k,E]=n.useState(0);return n.useEffect(()=>{l&&E(0)},[l]),n.useEffect(()=>{const S=L=>{x.current&&!x.current.contains(L.target)&&p()};return l&&document.addEventListener("mousedown",S),()=>{document.removeEventListener("mousedown",S)}},[l,p]),n.useEffect(()=>{if(!l)return;const S=L=>{if(!(!l||d.length===0)&&(L.key==="ArrowDown"&&(L.preventDefault(),E(M=>Math.min(M+1,d.length-1))),L.key==="ArrowUp"&&(L.preventDefault(),E(M=>Math.max(M-1,0))),L.key==="Enter")){L.preventDefault();const M=d[k];M&&m(M)}};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[l,d,k]),n.useEffect(()=>{if(!x.current)return;const L=x.current.querySelectorAll("li")[k];L&&L.scrollIntoView({block:"nearest",behavior:"smooth"})},[k]),l?n.createElement("ul",{ref:x,className:"rte-popup",style:{top:c.y,left:c.x}},d.length>0?d.map(({name:S,value:L},M)=>{const q=S.toLowerCase(),D=w.toLowerCase(),B=q.indexOf(D);let R=S;if(B!==-1&&w.length>0){const F=B+w.length;R=S.substring(0,B)+`<span class="rte-highlight">${S.substring(B,F)}</span>`+S.substring(F)}return n.createElement("li",{key:L,onMouseDown:F=>{F.preventDefault(),m({name:S,value:L})},style:{padding:"6px 12px",cursor:"pointer",fontSize:"14px",background:M===k?"#dce8ff":"white"},dangerouslySetInnerHTML:{__html:R},onMouseEnter:()=>E(M)})}):n.createElement("li",{style:{padding:"6px 12px",color:"#999"}},"No matches")):null};function fe(l){return T({attr:{viewBox:"0 0 24 24"},child:[{tag:"g",attr:{id:"Circle_Minus"},child:[{tag:"g",attr:{},child:[{tag:"path",attr:{d:"M15,11.5h0a.5.5,0,0,1,0,1H9a.5.5,0,0,1,0-1Z"},child:[]},{tag:"path",attr:{d:"M12,21.934A9.933,9.933,0,1,1,21.932,12,9.945,9.945,0,0,1,12,21.934ZM12,3.068A8.933,8.933,0,1,0,20.932,12,8.944,8.944,0,0,0,12,3.068Z"},child:[]}]}]}]})(l)}function Z(l){return T({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:[]}]}]}]})(l)}const it=({visible:l,x:c,y:d,onAction:m,onClose:p})=>{if(!l)return null;const w={top:d,left:c};return n.createElement("div",{style:w,className:"rte-table-menu",onMouseLeave:p},n.createElement("button",{onClick:()=>m("insertRowAbove")},n.createElement(Z,null)," Insert row above"),n.createElement("button",{onClick:()=>m("insertRowBelow")},n.createElement(Z,null)," Insert row below"),n.createElement("button",{onClick:()=>m("insertColLeft")},n.createElement(Z,null)," Insert col left"),n.createElement("button",{onClick:()=>m("insertColRight")},n.createElement(Z,null)," Insert col right"),n.createElement("button",{onClick:()=>m("deleteRow")},n.createElement(fe,null)," Delete row"),n.createElement("button",{onClick:()=>m("deleteCol")},n.createElement(fe,null)," Delete column"))},ge=({html:l,className:c,style:d})=>{const m=w=>{const x=w.target;if(x.tagName==="A"){w.preventDefault();const k=x.href;k&&window.open(k,"_blank","noopener,noreferrer")}},p=w=>{let x=w.replace(/{{\s*(.*?)\s*}}/g,(k,E)=>`<span style="color: blue">${E}</span>`);return x=x.replace(/#arrayData/g,""),x=x.replace(/\/arrayData/g,""),x};return n.createElement("div",{className:`rte-preview ${c||""}`,style:d,onClick:m,dangerouslySetInnerHTML:{__html:p(l)}})},st=({visible:l,linkData:c,onClose:d,onInsert:m})=>{const[p,w]=n.useState(""),[x,k]=n.useState(""),[E,S]=n.useState(""),[L,M]=n.useState("_self");if(n.useEffect(()=>{l?(w(c.url||""),k(c.text||""),S(c.title||""),M(c.target||"_self")):(w(""),k(""),S(""),M("_self"))},[l,c]),!l)return null;const q=()=>{m({url:p,text:x,title:E,target:L})};return n.createElement(n.Fragment,null,n.createElement("div",{className:"rte-link-modal-overlay",onClick:d}),n.createElement("div",{className:"rte-link-modal"},n.createElement("h4",{className:"rte-link-modal__title"},p?"Edit Link":"Insert Link"),n.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"URL",value:p,onChange:D=>w(D.target.value)}),n.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Text to Display",value:x,onChange:D=>k(D.target.value)}),n.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Title",value:E,onChange:D=>S(D.target.value)}),n.createElement("select",{className:"rte-link-modal__select",value:L,onChange:D=>M(D.target.value)},n.createElement("option",{value:"_self"},"Same tab"),n.createElement("option",{value:"_blank"},"New tab")),n.createElement("div",{className:"rte-link-modal__actions"},n.createElement("button",{className:"rte-link-modal__btn",onClick:d},"Cancel"),n.createElement("button",{className:"rte-link-modal__btn rte-link-modal__btn--ok",onClick:q},"OK"))))};function he(l){const c=new Map;return l.forEach(d=>{c.set(d.name,d.value)}),Array.from(c.entries()).map(([d,m])=>({name:d,value:m}))}const ct=({atSuggestions:l=[],showOutput:c=!1,showPreview:d=!1,toolbarConfig:m={link:!1,image:!1,emoji:!1,table:!1,color:!1,fontFamily:!1,fontSize:!1,highlight:!1},classNames:p={},styles:w={},handleGetHtml:x=()=>{},onChange:k=()=>{},value:E,onMentionSelect:S=()=>{},handleAddAttributes:L=()=>{}})=>{var Se,Le,Ae,Me,ze,ke,Ne,Te;const M=n.useRef(null),[q,D]=n.useState(E!=null&&E.length?E:" "),[B,R]=n.useState(""),[F,I]=n.useState(!1),[U,Q]=n.useState({x:0,y:0}),[G,N]=n.useState([]),O=n.useRef(null),V=n.useRef(null),[_,h]=n.useState({visible:!1,x:0,y:0}),[C,P]=n.useState(!1),J=n.useRef(null),[dt,pe]=n.useState({url:"",text:"",title:"",target:"_self"}),ut={bold:!0,italic:!0,underline:!0,removeFormat:!0,unorderedList:!0,orderedList:!0,align:!0,link:(Se=m.link)!=null?Se:!1,image:(Le=m.image)!=null?Le:!1,emoji:(Ae=m.emoji)!=null?Ae:!1,table:(Me=m.table)!=null?Me:!1,color:(ze=m.color)!=null?ze:!1,fontFamily:(ke=m.fontFamily)!=null?ke:!1,fontSize:(Ne=m.fontSize)!=null?Ne:!1,highlight:(Te=m.fontSize)!=null?Te:!1},[mt,ee]=n.useState(""),[ve,te]=n.useState([]),H=()=>M.current,A=()=>{const e=ft(),t=/^<div[^>]*style=["'][^"']*font-size\s*:\s*\d+px[^"']*["'][^>]*>/.test(e.trim());let r=e;t||(r=`<div style="font-size:12px">${e}</div>`),r=r.replace(/<(ul|ol)([^>]*)>/g,(i,v,y)=>/data-hidden-array-start/.test(i)?i:`<${v}${y}>
2
+ <span data-hidden-array-start="true" style="display:none">{{#arrayData}}</span>`),r=r.replace(/<\/(ul|ol)>/g,(i,v)=>/data-hidden-array-end/.test(i)?i:`<span data-hidden-array-end="true" style="display:none">{{/arrayData}}</span></${v}>`),R(r),x==null||x(r);const o=Ht(e);k(o);const s=Ct(),a=he(s);JSON.stringify(a)!==JSON.stringify(ve)&&(te(a),S(a))},ft=()=>{const e=H();if(!e)return q;const t=e.cloneNode(!0);t.querySelectorAll("table div").forEach(o=>o.remove()),t.querySelectorAll("table").forEach(o=>{o.removeAttribute("data-has-resize-handle")}),t.querySelectorAll(".rte-cell-highlight").forEach(o=>o.classList.remove("rte-cell-highlight"));let r=t.innerHTML;return r=gt(r),r},gt=e=>e.replace(/<tbody[^>]*>/g,"<tbody>{{#arrayData}}").replace(/<\/tbody>/g,"{{/arrayData}}</tbody>"),$=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return;const t=document.getElementById("rte-editor-body");if(!t)return;const r=e.getRangeAt(0);t.contains(r.startContainer)&&(O.current=r.cloneRange())},W=()=>{const e=window.getSelection();!e||!O.current||(e.removeAllRanges(),e.addRange(O.current))},ye=(e,t)=>{const r=window.getSelection();r&&r.rangeCount>0&&(O.current=r.getRangeAt(0)),W(),document.execCommand(e,!1,t),A()};n.useEffect(()=>{const e=H();if(!e||!E)return;const t=ht(E);e.innerHTML=t,A()},[]);const ht=e=>e.replace(/<span[^>]*data-hidden-table-start[^>]*>.*?<\/span>/g,"").replace(/<span[^>]*data-hidden-table-end[^>]*>.*?<\/span>/g,"").replace(/{{#arrayData}}/g,"").replace(/{{\/arrayData}}/g,"");n.useEffect(()=>()=>{document.removeEventListener("mousemove",null),document.removeEventListener("mouseup",null)},[]),n.useEffect(()=>{L&&L(e=>{wt(e)})},[]),n.useEffect(()=>{const e=H();if(!e)return;e.querySelectorAll("table").forEach(r=>{r.hasAttribute("data-has-resize-handle")||(oe(r),r.querySelectorAll("th, td").forEach(s=>K(s)))})},[]);const Ee=e=>{for(;e&&e.nodeName!=="LI";)e=e.parentNode;return e},we=e=>{var v;const t=window.getSelection();if(!(t!=null&&t.rangeCount))return;const r=t.getRangeAt(0),o=Ee(r.startContainer);let s,a;if(o){let y=o.querySelector(e);y||(y=document.createElement(e),y.style.margin="0",y.style.paddingLeft="20px",o.appendChild(y)),a=y,s=document.createElement("li"),s.textContent="​",a.appendChild(s)}else{document.execCommand(e==="ul"?"insertUnorderedList":"insertOrderedList");const y=H();if(a=y==null?void 0:y.querySelector(`${e}:last-child`),!a)return;s=a.querySelector("li:last-child")}const i=document.createRange();i.setStart(s,0),i.collapse(!0),t.removeAllRanges(),t.addRange(i),(v=H())==null||v.focus(),A()},ne=(e,t)=>{e==="insertOrderedList"?we("ol"):e==="insertUnorderedList"?we("ul"):e.startsWith("justify")?_t(e):ye(e,t),e==="insertTable"&&At()},pt=e=>{const t=document.createElement("span");t.textContent="​",e.insertNode(t),e.setStartAfter(t),e.collapse(!0);const r=t.getBoundingClientRect();t.remove(),Q({x:r.left,y:r.bottom+window.scrollY}),N(l||[]),I(!0),V.current=e.cloneRange()},vt=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return null;const t=e.anchorNode;let r=e.anchorOffset;if(!t)return null;let o=t;for(o.nodeType!==Node.TEXT_NODE&&(o.childNodes&&o.childNodes[r]?o=o.childNodes[r]:o=t.previousSibling);o;){if(o.nodeType===Node.TEXT_NODE){const s=o.textContent||"",a=o===t?r:s.length,i=s.lastIndexOf("@",a-1);if(i!==-1){const v=document.createRange();return v.setStart(o,i),v.setEnd(o,a),v}}o=o.previousSibling}return null},yt=e=>{var a;const t=window.getSelection();if(!t)return;const r=vt();r?(t.removeAllRanges(),t.addRange(r)):V.current&&(t.removeAllRanges(),t.addRange(V.current));const o=document.createElement("span");o.textContent=`{{${e.name}}}`,o.style.display="inline",o.setAttribute("data-mention",e.value||e.name||"");try{const i=t.rangeCount?t.getRangeAt(0):null;if(i)i.deleteContents(),i.insertNode(o);else{const g=document.createRange(),u=H();g.selectNodeContents(u),g.collapse(!1),g.insertNode(o)}const v=document.createTextNode(" ");o.after(v);const y=document.createRange();y.setStartAfter(v),y.collapse(!0),t.removeAllRanges(),t.addRange(y)}catch(i){console.error("insertMention error:",i)}let s=he([...ve,e]);te(s),S(s),I(!1),(a=H())==null||a.focus(),A()},Et=e=>{const t=H();if(!t)return;let r=null;O.current&&t.contains(O.current.startContainer)?r=O.current.cloneRange():(r=document.createRange(),r.selectNodeContents(t),r.collapse(!1));const o=window.getSelection();if(!o)return;o.removeAllRanges(),o.addRange(r);const s=document.createElement("span");s.textContent=`{{${e.name}}}`,s.style.display="inline",s.setAttribute("data-mention",e.value||e.name),r.insertNode(s);const a=document.createTextNode(" ");s.after(a);const i=document.createRange();i.setStartAfter(a),i.collapse(!0),o.removeAllRanges(),o.addRange(i),O.current=i.cloneRange(),t.focus()},wt=e=>{e.forEach(t=>Et(t)),te(t=>{const r=[...t,...e],o=Array.from(new Map(r.map(s=>[s.name,s])).values());return S(o),o}),A()},Ct=()=>{const e=H();if(!e)return[];const t=e.querySelectorAll("span[data-mention]"),r=[];return t.forEach(o=>{const s=o.getAttribute("data-mention")||"",i=(o.textContent||"").match(/{{(.+?)}}/);i&&r.push({name:i[1],value:s})}),r},bt=e=>{var r,o,s;const t=e.key.toLowerCase();if((e.ctrlKey||e.metaKey)&&["b","i","u"].includes(t)&&(e.preventDefault(),ne(t==="b"?"bold":t==="i"?"italic":t==="u"?"underline":"")),e.shiftKey&&e.key==="2"&&e.preventDefault(),e.key==="Enter"){const a=window.getSelection(),i=a!=null&&a.anchorNode?Ee(a.anchorNode):null;if(!i)return;if(((r=i.textContent)==null?void 0:r.replace(/\u200B/g,"").trim())===""){e.preventDefault();const y=i.parentElement,g=y==null?void 0:y.closest("li");if(g){y==null||y.removeChild(i);const u=document.createElement("p");u.innerHTML="<br />",(o=g.parentElement)==null||o.insertBefore(u,g.nextSibling);const f=document.createRange();f.setStart(u,0),f.collapse(!0),a==null||a.removeAllRanges(),a==null||a.addRange(f)}else{const u=i.closest("ul, ol");if(u){const f=document.createElement("p");f.innerHTML="<br />",(s=u.parentElement)==null||s.insertBefore(f,u.nextSibling),u.removeChild(i);const b=document.createRange();b.setStart(f,0),b.collapse(!0),a==null||a.removeAllRanges(),a==null||a.addRange(b)}}A()}}},xt=e=>{if(e.data==="@"){const r=window.getSelection();if(!(r!=null&&r.rangeCount))return;const o=r.anchorNode;if(re(o))return;setTimeout(()=>{pt(r.getRangeAt(0)),ee(""),N(l),I(!0)},0);return}if(F){setTimeout(()=>Ce(),0);return}},re=e=>{if(!e)return!1;let t=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;for(;t;){if(t.tagName==="TH")return!0;t=t.parentElement}return!1},Ce=()=>{A();const e=window.getSelection();if(!e||!e.anchorNode)return;if(re(e.anchorNode)){I(!1);return}let t=e.anchorNode.textContent||"";t=t.replace(/\u00A0/g," ");const r=t.match(/@([^\n]*)$/);if(!r){I(!1);return}const o=r[1].trim().toLowerCase();ee(o);const s=l.filter(a=>a.name.toLowerCase().includes(o));s.length>0?(N(s),I(!0)):I(!1)},St=e=>{var o;const t=(o=e.target.files)==null?void 0:o[0];if(!t)return;const r=new FileReader;r.onload=s=>{var b;const a=(b=s.target)==null?void 0:b.result;W();const i=window.getSelection();let v=i&&i.rangeCount?i.getRangeAt(0):null;const y=document.createElement("img");y.src=a,y.alt=t.name||"image",y.className="rte-inserted-image",y.contentEditable="true";const g=H();if(!v||!g){g==null||g.appendChild(y);const De=document.createTextNode(" ");g==null||g.appendChild(De);const le=document.createRange();le.setStartAfter(De),le.collapse(!0),i==null||i.removeAllRanges(),i==null||i.addRange(le),g==null||g.focus(),A(),e.target.value="";return}v.deleteContents(),v.insertNode(y);const u=document.createTextNode(" ");y.after(u);const f=document.createRange();f.setStartAfter(u),f.collapse(!0),i.removeAllRanges(),i.addRange(f),g.focus(),A(),e.target.value=""},r.readAsDataURL(t)},Lt=e=>{var s;W();const t=window.getSelection();if(!(t!=null&&t.rangeCount))return;const r=t.getRangeAt(0),o=document.createTextNode(e);r.insertNode(o),r.setStartAfter(o),r.collapse(!0),t.removeAllRanges(),t.addRange(r),(s=H())==null||s.focus(),A()},At=()=>{var g;qt(),W();const e=document.createElement("table");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);const t=document.createElement("thead");p.thead&&t.classList.add(p.thead);const r=document.createElement("tbody");p.tbody&&r.classList.add(p.tbody);const o=document.createElement("tr");p.tr&&o.classList.add(p.tr);const s=document.createElement("tr");p.tr&&s.classList.add(p.tr);for(let u=0;u<2;u++){const f=document.createElement("th");f.textContent="",f.style.border="1px solid #999",f.style.padding="4px",f.style.position="relative",f.style.backgroundColor="lightgray",f.style.height="20px",p.th&&f.classList.add(p.th);const b=document.createElement("td");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),K(f),K(b),o.appendChild(f),s.appendChild(b)}t.appendChild(o),r.appendChild(s),e.appendChild(t),e.appendChild(r),oe(e);const a=window.getSelection();if(!(a!=null&&a.rangeCount))return;const i=a.getRangeAt(0);i.collapse(!1),i.insertNode(e);const v=document.createElement("p");v.innerHTML="<br/>",e.after(v);const y=document.createRange();y.setStart(v,0),y.collapse(!0),a.removeAllRanges(),a.addRange(y),(g=H())==null||g.focus(),A()},oe=e=>{if(e.dataset.hasResizeHandle==="true")return;const t=document.createElement("div");Object.assign(t.style,{position:"absolute",width:"14px",height:"14px",right:"0",bottom:"0",background:"rgba(0,0,0,0.25)",cursor:"nwse-resize",zIndex:"20",borderRadius:"2px"}),t.style.userSelect="none",t.contentEditable="false",t.dataset.hasResizeHandle="true";let r=0,o=0,s=0,a=0;t.addEventListener("mousedown",i=>{i.preventDefault(),r=i.clientX,o=i.clientY;const v=e.getBoundingClientRect();s=v.width,a=v.height;const y=u=>{const f=Math.max(100,s+(u.clientX-r)),b=Math.max(20,a+(u.clientY-o));e.style.width=`${f}px`,e.style.height=`${b}px`,A()},g=()=>{document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",g),A()};document.addEventListener("mousemove",y),document.addEventListener("mouseup",g)}),e.appendChild(t)},K=e=>{const t=document.createElement("div"),r=document.createElement("div");Object.assign(t.style,{position:"absolute",right:"0",top:"0",width:"4px",height:"100%",cursor:"col-resize",background:"rgba(0,0,0,0.15)",zIndex:"10",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none",pointerEvents:"auto"}),t.contentEditable="false",Object.assign(r.style,{position:"absolute",bottom:"0",left:"0",width:"100%",height:"4px",cursor:"row-resize",background:"rgba(0,0,0,0.15)",zIndex:"10",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none",pointerEvents:"auto"}),r.contentEditable="false",Mt(e,t,r),e.appendChild(t),e.appendChild(r)},Mt=(e,t,r)=>{let o=0,s=0,a=0,i=0;t.addEventListener("mousedown",u=>{u.preventDefault(),o=u.clientX,a=e.offsetWidth,document.addEventListener("mousemove",v),document.addEventListener("mouseup",g)}),r.addEventListener("mousedown",u=>{u.preventDefault(),s=u.clientY,i=e.offsetHeight,document.addEventListener("mousemove",y),document.addEventListener("mouseup",g)});const v=u=>{const f=a+(u.clientX-o);e.style.width=`${Math.max(30,f)}px`,A()},y=u=>{const f=i+(u.clientY-s);e.style.height=`${Math.max(20,f)}px`,A()},g=()=>{document.removeEventListener("mousemove",v),document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",g),A()}},zt=e=>{const r=e.target.closest("td, th");r&&(e.preventDefault(),document.querySelectorAll(".rte-cell-highlight").forEach(o=>o.classList.remove("rte-cell-highlight")),r.classList.add("rte-cell-highlight"),h({visible:!0,x:e.clientX,y:e.clientY,cell:r}))},be=()=>{document.querySelectorAll(".rte-cell-highlight").forEach(e=>e.classList.remove("rte-cell-highlight"))},kt=e=>{if(!_.cell)return;const t=_.cell.closest("table"),r=_.cell.cellIndex,o=_.cell.parentElement.rowIndex,s=a=>{const i=a.tagName.toLowerCase(),v=document.createElement(i);return v.textContent="",v.style.cssText=a.style.cssText,K(v),v};switch(e){case"insertRowAbove":{const a=t.rows[o],i=t.insertRow(o);Array.from(a.cells).forEach(v=>{i.appendChild(s(v))});break}case"insertRowBelow":{const a=t.rows[o],i=t.insertRow(o+1);Array.from(a.cells).forEach(v=>{i.appendChild(s(v))});break}case"insertColLeft":{Array.from(t.rows).forEach(a=>{const i=a.cells[r];a.insertBefore(s(i),i)});break}case"insertColRight":{Array.from(t.rows).forEach(a=>{const i=a.cells[r];a.insertBefore(s(i),i.nextSibling)});break}case"deleteRow":t.rows.length>1&&t.deleteRow(o);break;case"deleteCol":Array.from(t.rows).forEach(a=>{a.cells[r]&&a.deleteCell(r)});break}A(),h(ie(ae({},_),{visible:!1})),be()},Nt=()=>{$(),J.current=O.current,pe({url:"",text:"",title:"",target:"_self"}),P(!0)},Tt=e=>{const t=window.getSelection();if(!t||!J.current)return;t.removeAllRanges(),t.addRange(J.current);let r=e.url.trim();/^https?:\/\//i.test(r)||(r="https://"+r);const o=document.createElement("a");o.href=r,o.style.cursor="pointer",o.style.outline="none",o.textContent=e.text||r,o.title=e.title,o.target=e.target,o.contentEditable="true";const s=t.getRangeAt(0);s.deleteContents(),s.insertNode(o);const a=document.createTextNode(" ");o.after(a);const i=document.createRange();i.setStartAfter(a),i.collapse(!0),t.removeAllRanges(),t.addRange(i),P(!1),A()},Dt=e=>{const t=e.target;if(t.tagName==="A"){const r=t;if(e.ctrlKey||e.metaKey){window.open(r.href,"_blank","noopener,noreferrer");return}e.preventDefault();const o=document.createRange();o.selectNode(r),J.current=o,pe({url:r.href,text:r.textContent||r.href,title:r.title,target:r.target}),P(!0)}},Ot=()=>{const e=H();if(!e)return;const t=window.getSelection();if((!t||t.rangeCount===0)&&O.current){const u=window.getSelection();u==null||u.removeAllRanges(),u==null||u.addRange(O.current)}const r=window.getSelection();if(!r||r.rangeCount===0)return;const o=r.getRangeAt(0);W(),document.execCommand("removeFormat",!1);const s=o.cloneContents(),a=document.createElement("div");a.appendChild(s);const i=document.createTreeWalker(a,NodeFilter.SHOW_ELEMENT,null),v=[];for(;i.nextNode();){const u=i.currentNode,f=u.tagName.toUpperCase(),b=u.getAttribute&&u.getAttribute("data-mention")!==null;f!=="A"&&!b&&v.push(u)}for(let u=v.length-1;u>=0;u--){const f=v[u],b=f.parentNode;if(b){for(;f.firstChild;)b.insertBefore(f.firstChild,f);b.removeChild(f)}}a.querySelectorAll("[style]").forEach(u=>u.removeAttribute("style")),o.deleteContents();const y=document.createDocumentFragment();for(;a.firstChild;)y.appendChild(a.firstChild);o.insertNode(y);const g=document.createRange();g.setStartAfter(o.endContainer.nodeType===Node.TEXT_NODE?o.endContainer:o.startContainer),g.collapse(!0),r.removeAllRanges(),r.addRange(g),e.normalize(),A()},Ht=e=>{var o;let t=e;t=t.replace(/{{#arrayData\d*}}/g,""),t=t.replace(/{{\/arrayData\d*}}/g,"");const r=document.createElement("div");return r.innerHTML=t,r.querySelectorAll("br").forEach(s=>{s.replaceWith(`
3
3
  `)}),r.querySelectorAll("p, div, tr").forEach(s=>{s.insertAdjacentText("afterend",`
4
4
  `)}),r.querySelectorAll("table").forEach(s=>{s.insertAdjacentText("afterend",`
5
- `)}),((l=r.textContent)==null?void 0:l.replace(/\n{3,}/g,`
5
+ `)}),((o=r.textContent)==null?void 0:o.replace(/\n{3,}/g,`
6
6
 
7
- `).trim())||""};function jt(){const e=window.getSelection();if(!e||e.rangeCount===0)return[];const t=e.getRangeAt(0);if(t.collapsed){let a=t.startContainer,i=a.nodeType===Node.ELEMENT_NODE?a:a.parentElement;const v=i==null?void 0:i.closest("td, th");return v?[v]:[]}const r=t.commonAncestorContainer,l=r.nodeType===Node.ELEMENT_NODE?r:r.parentElement;return Array.from(l.querySelectorAll("td, th")).filter(a=>{const i=document.createRange();return i.selectNodeContents(a),t.compareBoundaryPoints(Range.END_TO_START,i)<0&&t.compareBoundaryPoints(Range.START_TO_END,i)>0})}function _t(e){const t=jt();if(t.length===0){ye(e);return}let r="left";e==="justifyCenter"&&(r="center"),e==="justifyRight"&&(r="right"),t.forEach(l=>{l.style.textAlign=r}),M()}const It=e=>{e.preventDefault();const t=e.clipboardData.items;for(let g=0;g<t.length;g++){const d=t[g];if(d.kind==="file"&&d.type.startsWith("image/"))return;d.kind==="string"&&d.getAsString(f=>{/<img\s/i.test(f)})}const r=e.clipboardData.getData("text/html")||"";if(!r)return;const l=document.createElement("div");l.innerHTML=r;const s=g=>{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(d=>{const f=d;f.style.border="1px solid #999",f.style.padding="4px",f.style.position="relative",f.style.backgroundColor="lightgray",f.style.height="20px"}),g.querySelectorAll("td").forEach(d=>{const f=d;f.style.border="1px solid #999",f.style.padding="4px",f.style.position="relative",f.style.backgroundColor="#fff",f.style.height="20px"})};l.querySelectorAll("table").forEach(g=>s(g));const a=window.getSelection();if(!a||!a.rangeCount)return;const i=a.getRangeAt(0);i.deleteContents();const v=document.createDocumentFragment();for(;l.firstChild;)v.appendChild(l.firstChild);i.insertNode(v),i.collapse(!1),a.removeAllRanges(),a.addRange(i);const y=A.current;y&&(y.querySelectorAll("table").forEach(g=>{const d=g;d.dataset.hasResizeHandle||(oe(d),d.dataset.hasResizeHandle="true"),d.querySelectorAll("th, td").forEach(f=>{const b=f;b.dataset.hasResizeHandles||(K(b),b.dataset.hasResizeHandles="true")})}),M())},Pt=e=>{W();const t=window.getSelection();if(!t||!t.rangeCount)return;const r=t.getRangeAt(0),l=document.createElement("span");l.style.fontSize=`${e}px`,l.appendChild(r.extractContents()),r.insertNode(l);const s=document.createRange();s.setStartAfter(l),s.collapse(!0),t.removeAllRanges(),t.addRange(s),M()},Ft=()=>{const e=window.getSelection();if(!e||!e.anchorNode)return null;const t=e.anchorNode;if(re(t)||t.nodeType!==Node.TEXT_NODE)return null;const r=t.textContent||"",l=e.anchorOffset,s=r.lastIndexOf("@",l-1);if(s===-1)return null;const a=r.substring(s+1,l);if(a.includes(" ")||a.includes(" "))return null;const i=document.createRange();return i.setStart(t,s),i.setEnd(t,l),{range:i,query:a}},xe=()=>{const e=Ft();if(!e)return;const{range:t,query:r}=e,l=document.createElement("span");l.textContent="​",t.insertNode(l);const s=l.getBoundingClientRect();l.remove(),Q({x:s.left,y:s.bottom+window.scrollY}),ee(r.toLowerCase());const a=o.filter(i=>i.name.toLowerCase().includes(r.toLowerCase()));N(a),I(!0),V.current=t.cloneRange()};function qt(){const e=A.current;if(!e)return;const t=window.getSelection();if(!t||t.rangeCount>0&&e.contains(t.anchorNode))return;const r=document.createRange();r.selectNodeContents(e),r.collapse(!1),t.removeAllRanges(),t.addRange(r),O.current=r.cloneRange()}return n.createElement("div",{className:`rte-wrapper ${(p==null?void 0:p.wrapper)||""}`,style:w.wrapper},n.createElement("div",{style:{flex:1}},n.createElement(me,{exec:ne,saveSelection:$,handleFileChange:St,handleFontSizeChange:e=>Pt(e.target.value),handleFontFamilyChange:e=>ne("fontName",e.target.value),insertEmoji:Lt,handleLink:Nt,removeFormatting:Ot,visibleActions:ut,className:p.toolbar,style:w.toolbar}),n.createElement("div",{ref:A,id:"rte-editor-body",className:`rte-editor ${(p==null?void 0:p.editor)||""}`,style:w.editor,contentEditable:!0,suppressContentEditableWarning:!0,onPaste:It,onKeyUp:()=>{$(),xe()},onMouseUp:$,onInput:()=>{Ce(),$()},onKeyDown:bt,onBeforeInput:xt,onContextMenu:kt,onClick:e=>{Dt(e),$(),xe()}}),n.createElement(at,{show:F,position:U,filtered:G,insertMention:yt,onClose:()=>I(!1),query:mt}),c&&n.createElement("div",{className:`rte-output ${(p==null?void 0:p.output)||""}`,style:w.output},n.createElement("h4",null,"Output HTML:"),n.createElement("p",null,B)),n.createElement(it,{visible:_.visible,x:_.x,y:_.y,onAction:zt,onClose:()=>{h(ie(ae({},_),{visible:!1})),be()}}),n.createElement(st,{visible:C,linkData:dt,onClose:()=>P(!1),onInsert:Tt})),u?n.createElement(ge,{className:p.preview,style:w.preview,html:B}):null)};k.RichTextEditor=ct,k.RtePreview=ge,k.RteToolbar=me,Object.defineProperty(k,Symbol.toStringTag,{value:"Module"})}));
7
+ `).trim())||""};function jt(){const e=window.getSelection();if(!e||e.rangeCount===0)return[];const t=e.getRangeAt(0);if(t.collapsed){let a=t.startContainer,i=a.nodeType===Node.ELEMENT_NODE?a:a.parentElement;const v=i==null?void 0:i.closest("td, th");return v?[v]:[]}const r=t.commonAncestorContainer,o=r.nodeType===Node.ELEMENT_NODE?r:r.parentElement;return Array.from(o.querySelectorAll("td, th")).filter(a=>{const i=document.createRange();return i.selectNodeContents(a),t.compareBoundaryPoints(Range.END_TO_START,i)<0&&t.compareBoundaryPoints(Range.START_TO_END,i)>0})}function _t(e){const t=jt();if(t.length===0){ye(e);return}let r="left";e==="justifyCenter"&&(r="center"),e==="justifyRight"&&(r="right"),t.forEach(o=>{o.style.textAlign=r}),A()}const It=e=>{e.preventDefault();const t=e.clipboardData.items;for(let g=0;g<t.length;g++){const u=t[g];if(u.kind==="file"&&u.type.startsWith("image/"))return;u.kind==="string"&&u.getAsString(f=>{/<img\s/i.test(f)})}const r=e.clipboardData.getData("text/html")||"";if(!r)return;const o=document.createElement("div");o.innerHTML=r;const s=g=>{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=>{const f=u;f.style.border="1px solid #999",f.style.padding="4px",f.style.position="relative",f.style.backgroundColor="lightgray",f.style.height="20px"}),g.querySelectorAll("td").forEach(u=>{const f=u;f.style.border="1px solid #999",f.style.padding="4px",f.style.position="relative",f.style.backgroundColor="#fff",f.style.height="20px"})};o.querySelectorAll("table").forEach(g=>s(g));const a=window.getSelection();if(!a||!a.rangeCount)return;const i=a.getRangeAt(0);i.deleteContents();const v=document.createDocumentFragment();for(;o.firstChild;)v.appendChild(o.firstChild);i.insertNode(v),i.collapse(!1),a.removeAllRanges(),a.addRange(i);const y=M.current;y&&(y.querySelectorAll("table").forEach(g=>{const u=g;u.hasAttribute("data-has-resize-handle")||(oe(u),u.querySelectorAll("th, td").forEach(f=>{const b=f;b.dataset.hasResizeHandles||K(b)}))}),A())},Pt=e=>{W();const t=window.getSelection();if(!t||!t.rangeCount)return;const r=t.getRangeAt(0),o=document.createElement("span");o.style.fontSize=`${e}px`,o.appendChild(r.extractContents()),r.insertNode(o);const s=document.createRange();s.setStartAfter(o),s.collapse(!0),t.removeAllRanges(),t.addRange(s),A()},Ft=()=>{const e=window.getSelection();if(!e||!e.anchorNode)return null;const t=e.anchorNode;if(re(t)||t.nodeType!==Node.TEXT_NODE)return null;const r=t.textContent||"",o=e.anchorOffset,s=r.lastIndexOf("@",o-1);if(s===-1)return null;const a=r.substring(s+1,o);if(a.includes(" ")||a.includes(" "))return null;const i=document.createRange();return i.setStart(t,s),i.setEnd(t,o),{range:i,query:a}},xe=()=>{const e=Ft();if(!e)return;const{range:t,query:r}=e,o=document.createElement("span");o.textContent="​",t.insertNode(o);const s=o.getBoundingClientRect();o.remove(),Q({x:s.left,y:s.bottom+window.scrollY}),ee(r.toLowerCase());const a=l.filter(i=>i.name.toLowerCase().includes(r.toLowerCase()));N(a),I(!0),V.current=t.cloneRange()};function qt(){const e=M.current;if(!e)return;const t=window.getSelection();if(!t||t.rangeCount>0&&e.contains(t.anchorNode))return;const r=document.createRange();r.selectNodeContents(e),r.collapse(!1),t.removeAllRanges(),t.addRange(r),O.current=r.cloneRange()}return n.createElement("div",{className:`rte-wrapper ${(p==null?void 0:p.wrapper)||""}`,style:w.wrapper},n.createElement("div",{style:{flex:1}},n.createElement(me,{exec:ne,saveSelection:$,handleFileChange:St,handleFontSizeChange:e=>Pt(e.target.value),handleFontFamilyChange:e=>ne("fontName",e.target.value),insertEmoji:Lt,handleLink:Nt,removeFormatting:Ot,visibleActions:ut,className:p.toolbar,style:w.toolbar}),n.createElement("div",{ref:M,id:"rte-editor-body",className:`rte-editor ${(p==null?void 0:p.editor)||""}`,style:w.editor,contentEditable:!0,suppressContentEditableWarning:!0,onPaste:It,onKeyUp:()=>{$(),xe()},onMouseUp:$,onInput:()=>{Ce(),$()},onKeyDown:bt,onBeforeInput:xt,onContextMenu:zt,onClick:e=>{Dt(e),$(),xe()}}),n.createElement(at,{show:F,position:U,filtered:G,insertMention:yt,onClose:()=>I(!1),query:mt}),c&&n.createElement("div",{className:`rte-output ${(p==null?void 0:p.output)||""}`,style:w.output},n.createElement("h4",null,"Output HTML:"),n.createElement("p",null,B)),n.createElement(it,{visible:_.visible,x:_.x,y:_.y,onAction:kt,onClose:()=>{h(ie(ae({},_),{visible:!1})),be()}}),n.createElement(st,{visible:C,linkData:dt,onClose:()=>P(!1),onInsert:Tt})),d?n.createElement(ge,{className:p.preview,style:w.preview,html:B}):null)};z.RichTextEditor=ct,z.RtePreview=ge,z.RteToolbar=me,Object.defineProperty(z,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ryzeup/richtexteditor",
3
- "version": "1.0.21",
3
+ "version": "1.0.23",
4
4
  "description": "A React Rich Text Editor component",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",