@ryzeup/richtexteditor 1.0.23 → 1.0.24

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