@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 +378 -369
- package/dist/index.js +3 -3
- package/dist/index.umd.js +3 -3
- package/dist/richtexteditor.css +1 -1
- package/package.json +1 -1
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
|
|
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 =
|
|
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,
|
|
26
|
+
var d = wt(r, s), m, y;
|
|
27
27
|
if (Object.getOwnPropertySymbols) {
|
|
28
28
|
var w = Object.getOwnPropertySymbols(r);
|
|
29
|
-
for (
|
|
30
|
-
m = w[
|
|
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(
|
|
59
|
-
return Object.getOwnPropertyDescriptor(r,
|
|
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__ */
|
|
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__ */
|
|
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:
|
|
106
|
+
size: y,
|
|
107
107
|
title: w
|
|
108
|
-
} = r, R = Et(r, yt), M =
|
|
109
|
-
return d.className && (E = d.className), r.className && (E = (E ? E + " " : "") + r.className), /* @__PURE__ */
|
|
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__ */
|
|
121
|
+
}), w && /* @__PURE__ */ l.createElement("title", null, w), r.children);
|
|
122
122
|
};
|
|
123
|
-
return Me !== void 0 ? /* @__PURE__ */
|
|
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
|
|
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
|
|
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:
|
|
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 =
|
|
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
|
-
|
|
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
|
|
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
|
|
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__ */
|
|
370
|
+
}, []), /* @__PURE__ */ l.createElement("div", {
|
|
371
371
|
className: `rte-toolbar ${x || ""}`,
|
|
372
372
|
style: L
|
|
373
|
-
}, E.bold && /* @__PURE__ */
|
|
373
|
+
}, E.bold && /* @__PURE__ */ l.createElement("button", {
|
|
374
374
|
"data-command": "bold",
|
|
375
375
|
title: "Bold",
|
|
376
|
-
onMouseDown:
|
|
376
|
+
onMouseDown: V,
|
|
377
377
|
className: z.bold ? "rte-active" : ""
|
|
378
|
-
}, /* @__PURE__ */
|
|
378
|
+
}, /* @__PURE__ */ l.createElement(kt, null)), E.italic && /* @__PURE__ */ l.createElement("button", {
|
|
379
379
|
"data-command": "italic",
|
|
380
380
|
title: "Italic",
|
|
381
|
-
onMouseDown:
|
|
381
|
+
onMouseDown: V,
|
|
382
382
|
className: z.italic ? "rte-active" : ""
|
|
383
|
-
}, /* @__PURE__ */
|
|
383
|
+
}, /* @__PURE__ */ l.createElement(Tt, null)), E.underline && /* @__PURE__ */ l.createElement("button", {
|
|
384
384
|
"data-command": "underline",
|
|
385
385
|
title: "Underline",
|
|
386
|
-
onMouseDown:
|
|
386
|
+
onMouseDown: V,
|
|
387
387
|
className: z.underline ? "rte-active" : ""
|
|
388
|
-
}, /* @__PURE__ */
|
|
388
|
+
}, /* @__PURE__ */ l.createElement(jt, null)), E.unorderedList && /* @__PURE__ */ l.createElement("button", {
|
|
389
389
|
"data-command": "insertUnorderedList",
|
|
390
|
-
onMouseDown:
|
|
390
|
+
onMouseDown: V,
|
|
391
391
|
title: "UnorderedList",
|
|
392
392
|
className: z.unorderedList ? "rte-active" : ""
|
|
393
|
-
}, /* @__PURE__ */
|
|
393
|
+
}, /* @__PURE__ */ l.createElement(Ot, null)), E.orderedList && /* @__PURE__ */ l.createElement("button", {
|
|
394
394
|
"data-command": "insertOrderedList",
|
|
395
395
|
title: "OrderedList",
|
|
396
|
-
onMouseDown:
|
|
396
|
+
onMouseDown: V,
|
|
397
397
|
className: z.orderedList ? "rte-active" : ""
|
|
398
|
-
}, /* @__PURE__ */
|
|
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__ */
|
|
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__ */
|
|
410
|
+
}, /* @__PURE__ */ l.createElement(It, null)), E.image && /* @__PURE__ */ l.createElement("button", {
|
|
411
411
|
"data-command": "insertImage",
|
|
412
412
|
title: "Image",
|
|
413
|
-
onMouseDown:
|
|
413
|
+
onMouseDown: V,
|
|
414
414
|
className: z.image ? "rte-active" : ""
|
|
415
|
-
}, /* @__PURE__ */
|
|
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__ */
|
|
423
|
+
}), E.emoji && /* @__PURE__ */ l.createElement("div", {
|
|
424
424
|
style: {
|
|
425
425
|
position: "relative"
|
|
426
426
|
}
|
|
427
|
-
}, /* @__PURE__ */
|
|
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__ */
|
|
439
|
+
}, /* @__PURE__ */ l.createElement(Ht, null)), q && /* @__PURE__ */ vt(/* @__PURE__ */ l.createElement("div", {
|
|
440
440
|
className: "rte-emoji-popup",
|
|
441
441
|
style: {
|
|
442
|
-
top:
|
|
443
|
-
left:
|
|
442
|
+
top: I.y,
|
|
443
|
+
left: I.x
|
|
444
444
|
}
|
|
445
|
-
}, Pt.map((h, C) => /* @__PURE__ */
|
|
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__ */
|
|
455
|
+
}, h))), document.body)), E.color && /* @__PURE__ */ l.createElement("div", {
|
|
456
456
|
style: {
|
|
457
457
|
position: "relative"
|
|
458
458
|
}
|
|
459
|
-
}, /* @__PURE__ */
|
|
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__ */
|
|
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__ */
|
|
488
|
+
})), E.highlight && /* @__PURE__ */ l.createElement("div", {
|
|
489
489
|
style: {
|
|
490
490
|
position: "relative"
|
|
491
491
|
}
|
|
492
|
-
}, /* @__PURE__ */
|
|
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__ */
|
|
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__ */
|
|
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__ */
|
|
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__ */
|
|
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__ */
|
|
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__ */
|
|
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:
|
|
546
|
-
}, /* @__PURE__ */
|
|
545
|
+
onChange: y
|
|
546
|
+
}, /* @__PURE__ */ l.createElement("option", {
|
|
547
547
|
value: "",
|
|
548
548
|
disabled: !0
|
|
549
|
-
}, "Font Family"), /* @__PURE__ */
|
|
549
|
+
}, "Font Family"), /* @__PURE__ */ l.createElement("option", {
|
|
550
550
|
value: "Arial"
|
|
551
|
-
}, "Arial"), /* @__PURE__ */
|
|
551
|
+
}, "Arial"), /* @__PURE__ */ l.createElement("option", {
|
|
552
552
|
value: "Georgia"
|
|
553
|
-
}, "Georgia"), /* @__PURE__ */
|
|
553
|
+
}, "Georgia"), /* @__PURE__ */ l.createElement("option", {
|
|
554
554
|
value: "Times New Roman"
|
|
555
|
-
}, "Times New Roman"), /* @__PURE__ */
|
|
555
|
+
}, "Times New Roman"), /* @__PURE__ */ l.createElement("option", {
|
|
556
556
|
value: "Courier New"
|
|
557
|
-
}, "Courier New"), /* @__PURE__ */
|
|
557
|
+
}, "Courier New"), /* @__PURE__ */ l.createElement("option", {
|
|
558
558
|
value: "Verdana"
|
|
559
|
-
}, "Verdana")), E.fontSize && /* @__PURE__ */
|
|
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__ */
|
|
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__ */
|
|
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:
|
|
578
|
+
onClose: y,
|
|
579
579
|
query: w
|
|
580
580
|
}) => {
|
|
581
|
-
const R =
|
|
582
|
-
return
|
|
581
|
+
const R = U(null), [M, E] = k(0);
|
|
582
|
+
return F(() => {
|
|
583
583
|
r && E(0);
|
|
584
|
-
}, [r]),
|
|
584
|
+
}, [r]), F(() => {
|
|
585
585
|
const x = (L) => {
|
|
586
|
-
R.current && !R.current.contains(L.target) &&
|
|
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,
|
|
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]),
|
|
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__ */
|
|
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
|
|
623
|
-
B = x.substring(0, q) + `<span class="rte-highlight">${x.substring(q,
|
|
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__ */
|
|
625
|
+
return /* @__PURE__ */ l.createElement("li", {
|
|
626
626
|
key: L,
|
|
627
|
-
onMouseDown: (
|
|
628
|
-
|
|
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__ */
|
|
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
|
|
657
|
+
const Vt = ({
|
|
658
658
|
visible: r,
|
|
659
659
|
x: s,
|
|
660
660
|
y: d,
|
|
661
661
|
onAction: m,
|
|
662
|
-
onClose:
|
|
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__ */
|
|
669
|
+
return /* @__PURE__ */ l.createElement("div", {
|
|
670
670
|
style: w,
|
|
671
671
|
className: "rte-table-menu",
|
|
672
|
-
onMouseLeave:
|
|
673
|
-
}, /* @__PURE__ */
|
|
672
|
+
onMouseLeave: y
|
|
673
|
+
}, /* @__PURE__ */ l.createElement("button", {
|
|
674
674
|
onClick: () => m("insertRowAbove")
|
|
675
|
-
}, /* @__PURE__ */
|
|
675
|
+
}, /* @__PURE__ */ l.createElement(Q, null), " Insert row above"), /* @__PURE__ */ l.createElement("button", {
|
|
676
676
|
onClick: () => m("insertRowBelow")
|
|
677
|
-
}, /* @__PURE__ */
|
|
677
|
+
}, /* @__PURE__ */ l.createElement(Q, null), " Insert row below"), /* @__PURE__ */ l.createElement("button", {
|
|
678
678
|
onClick: () => m("insertColLeft")
|
|
679
|
-
}, /* @__PURE__ */
|
|
679
|
+
}, /* @__PURE__ */ l.createElement(Q, null), " Insert col left"), /* @__PURE__ */ l.createElement("button", {
|
|
680
680
|
onClick: () => m("insertColRight")
|
|
681
|
-
}, /* @__PURE__ */
|
|
681
|
+
}, /* @__PURE__ */ l.createElement(Q, null), " Insert col right"), /* @__PURE__ */ l.createElement("button", {
|
|
682
682
|
onClick: () => m("deleteRow")
|
|
683
|
-
}, /* @__PURE__ */
|
|
683
|
+
}, /* @__PURE__ */ l.createElement(ke, null), " Delete row"), /* @__PURE__ */ l.createElement("button", {
|
|
684
684
|
onClick: () => m("deleteCol")
|
|
685
|
-
}, /* @__PURE__ */
|
|
686
|
-
},
|
|
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
|
-
},
|
|
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__ */
|
|
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:
|
|
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 [
|
|
717
|
-
if (
|
|
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:
|
|
722
|
+
url: y,
|
|
723
723
|
text: R,
|
|
724
724
|
title: E,
|
|
725
725
|
target: L
|
|
726
726
|
});
|
|
727
727
|
};
|
|
728
|
-
return /* @__PURE__ */
|
|
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__ */
|
|
731
|
+
}), /* @__PURE__ */ l.createElement("div", {
|
|
732
732
|
className: "rte-link-modal"
|
|
733
|
-
}, /* @__PURE__ */
|
|
733
|
+
}, /* @__PURE__ */ l.createElement("h4", {
|
|
734
734
|
className: "rte-link-modal__title"
|
|
735
|
-
},
|
|
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:
|
|
739
|
+
value: y,
|
|
740
740
|
onChange: (T) => w(T.target.value)
|
|
741
|
-
}), /* @__PURE__ */
|
|
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__ */
|
|
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__ */
|
|
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__ */
|
|
757
|
+
}, /* @__PURE__ */ l.createElement("option", {
|
|
758
758
|
value: "_self"
|
|
759
|
-
}, "Same tab"), /* @__PURE__ */
|
|
759
|
+
}, "Same tab"), /* @__PURE__ */ l.createElement("option", {
|
|
760
760
|
value: "_blank"
|
|
761
|
-
}, "New tab")), /* @__PURE__ */
|
|
761
|
+
}, "New tab")), /* @__PURE__ */ l.createElement("div", {
|
|
762
762
|
className: "rte-link-modal__actions"
|
|
763
|
-
}, /* @__PURE__ */
|
|
763
|
+
}, /* @__PURE__ */ l.createElement("button", {
|
|
764
764
|
className: "rte-link-modal__btn",
|
|
765
765
|
onClick: d
|
|
766
|
-
}, "Cancel"), /* @__PURE__ */
|
|
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:
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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,
|
|
839
|
-
<span data-hidden-array-start="true" style="display:none">{{#arrayData}}</span>`), n = n.replace(/<\/(ul|ol)>/g, (c,
|
|
840
|
-
const
|
|
841
|
-
M(
|
|
842
|
-
const i = $e(),
|
|
843
|
-
JSON.stringify(
|
|
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((
|
|
849
|
-
|
|
850
|
-
}), t.querySelectorAll(".rte-cell-highlight").forEach((
|
|
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 =
|
|
853
|
-
},
|
|
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
|
-
|
|
867
|
+
F(() => {
|
|
868
868
|
const e = O();
|
|
869
869
|
if (!e || !E) return;
|
|
870
|
-
const t =
|
|
870
|
+
const t = Ie(E);
|
|
871
871
|
e.innerHTML = t, S();
|
|
872
872
|
}, []);
|
|
873
|
-
const
|
|
874
|
-
|
|
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
|
-
}, []),
|
|
876
|
+
}, []), F(() => {
|
|
877
877
|
L && L((e) => {
|
|
878
|
-
|
|
878
|
+
Ue(e);
|
|
879
879
|
});
|
|
880
|
-
}, []),
|
|
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") || (
|
|
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
|
|
892
|
+
var p;
|
|
893
893
|
const t = window.getSelection();
|
|
894
894
|
if (!(t != null && t.rangeCount)) return;
|
|
895
|
-
const n = t.getRangeAt(0),
|
|
896
|
-
let i,
|
|
897
|
-
if (
|
|
898
|
-
let
|
|
899
|
-
|
|
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
|
|
903
|
-
if (
|
|
904
|
-
i =
|
|
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), (
|
|
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
|
|
925
|
-
for (
|
|
926
|
-
if (
|
|
927
|
-
const i =
|
|
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
|
|
930
|
-
return
|
|
929
|
+
const p = document.createRange();
|
|
930
|
+
return p.setStart(a, c), p.setEnd(a, o), p;
|
|
931
931
|
}
|
|
932
932
|
}
|
|
933
|
-
|
|
933
|
+
a = a.previousSibling;
|
|
934
934
|
}
|
|
935
935
|
return null;
|
|
936
936
|
}, Be = (e) => {
|
|
937
|
-
var
|
|
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
|
|
943
|
-
|
|
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(
|
|
947
|
+
c.deleteContents(), c.insertNode(a);
|
|
948
948
|
else {
|
|
949
|
-
const
|
|
950
|
-
|
|
949
|
+
const g = document.createRange(), u = O();
|
|
950
|
+
g.selectNodeContents(u), g.collapse(!1), g.insertNode(a);
|
|
951
951
|
}
|
|
952
|
-
const
|
|
953
|
-
|
|
954
|
-
const
|
|
955
|
-
|
|
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), (
|
|
961
|
-
},
|
|
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
|
|
967
|
-
if (!
|
|
968
|
-
|
|
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
|
|
972
|
-
i.after(
|
|
971
|
+
const o = document.createTextNode(" ");
|
|
972
|
+
i.after(o);
|
|
973
973
|
const c = document.createRange();
|
|
974
|
-
c.setStartAfter(
|
|
975
|
-
},
|
|
976
|
-
e.forEach((t) =>
|
|
977
|
-
const n = [...t, ...e],
|
|
978
|
-
return x(
|
|
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((
|
|
985
|
-
const i =
|
|
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,
|
|
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
|
|
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
|
|
1000
|
-
if (
|
|
1001
|
-
|
|
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 />", (
|
|
1004
|
-
const
|
|
1005
|
-
|
|
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
|
|
1010
|
-
|
|
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(
|
|
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
|
|
1023
|
-
if (
|
|
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 (
|
|
1043
|
+
if (I) {
|
|
1031
1044
|
setTimeout(() => fe(), 0);
|
|
1032
1045
|
return;
|
|
1033
1046
|
}
|
|
1034
|
-
},
|
|
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 (
|
|
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
|
|
1058
|
-
te(
|
|
1059
|
-
const i = r.filter((
|
|
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
|
|
1063
|
-
const t = (
|
|
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
|
|
1081
|
+
const o = (b = i.target) == null ? void 0 : b.result;
|
|
1069
1082
|
K();
|
|
1070
1083
|
const c = window.getSelection();
|
|
1071
|
-
let
|
|
1072
|
-
const
|
|
1073
|
-
|
|
1074
|
-
const
|
|
1075
|
-
if (!
|
|
1076
|
-
|
|
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
|
-
|
|
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),
|
|
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
|
-
|
|
1096
|
+
p.deleteContents(), p.insertNode(v);
|
|
1084
1097
|
const u = document.createTextNode(" ");
|
|
1085
|
-
|
|
1086
|
-
const
|
|
1087
|
-
|
|
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),
|
|
1095
|
-
n.insertNode(
|
|
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
|
|
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",
|
|
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
|
-
|
|
1115
|
+
y.thead && t.classList.add(y.thead);
|
|
1103
1116
|
const n = document.createElement("tbody");
|
|
1104
|
-
|
|
1105
|
-
const
|
|
1106
|
-
|
|
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
|
-
|
|
1121
|
+
y.tr && i.classList.add(y.tr);
|
|
1109
1122
|
for (let u = 0; u < 2; u++) {
|
|
1110
|
-
const
|
|
1111
|
-
|
|
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",
|
|
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(
|
|
1116
|
-
const
|
|
1117
|
-
if (!(
|
|
1118
|
-
const c =
|
|
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
|
|
1121
|
-
|
|
1122
|
-
const
|
|
1123
|
-
|
|
1124
|
-
},
|
|
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.
|
|
1138
|
-
let n = 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,
|
|
1141
|
-
const
|
|
1142
|
-
i =
|
|
1143
|
-
const
|
|
1144
|
-
const
|
|
1145
|
-
e.style.width = `${
|
|
1146
|
-
},
|
|
1147
|
-
document.removeEventListener("mousemove",
|
|
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",
|
|
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
|
|
1192
|
+
let a = 0, i = 0, o = 0, c = 0;
|
|
1184
1193
|
t.addEventListener("mousedown", (u) => {
|
|
1185
|
-
u.preventDefault(),
|
|
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",
|
|
1196
|
+
u.preventDefault(), i = u.clientY, c = e.offsetHeight, document.addEventListener("mousemove", v), document.addEventListener("mouseup", g);
|
|
1188
1197
|
});
|
|
1189
|
-
const
|
|
1190
|
-
const
|
|
1191
|
-
e.style.width = `${Math.max(30,
|
|
1192
|
-
},
|
|
1193
|
-
const
|
|
1194
|
-
e.style.height = `${Math.max(20,
|
|
1195
|
-
},
|
|
1196
|
-
document.removeEventListener("mousemove",
|
|
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((
|
|
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,
|
|
1211
|
-
const c =
|
|
1212
|
-
return
|
|
1219
|
+
const t = H.cell.closest("table"), n = H.cell.cellIndex, a = H.cell.parentElement.rowIndex, i = (o) => {
|
|
1220
|
+
const c = o.tagName.toLowerCase(), p = document.createElement(c);
|
|
1221
|
+
return p.textContent = "", p.style.cssText = o.style.cssText, X(p), p;
|
|
1213
1222
|
};
|
|
1214
1223
|
switch (e) {
|
|
1215
1224
|
case "insertRowAbove": {
|
|
1216
|
-
const
|
|
1217
|
-
Array.from(
|
|
1218
|
-
c.appendChild(i(
|
|
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
|
|
1224
|
-
Array.from(
|
|
1225
|
-
c.appendChild(i(
|
|
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((
|
|
1231
|
-
const c =
|
|
1232
|
-
|
|
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((
|
|
1238
|
-
const c =
|
|
1239
|
-
|
|
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(
|
|
1253
|
+
t.rows.length > 1 && t.deleteRow(a);
|
|
1245
1254
|
break;
|
|
1246
1255
|
case "deleteCol":
|
|
1247
|
-
Array.from(t.rows).forEach((
|
|
1248
|
-
|
|
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
|
|
1269
|
-
|
|
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(
|
|
1272
|
-
const
|
|
1273
|
-
|
|
1280
|
+
i.deleteContents(), i.insertNode(a);
|
|
1281
|
+
const o = document.createTextNode(" ");
|
|
1282
|
+
a.after(o);
|
|
1274
1283
|
const c = document.createRange();
|
|
1275
|
-
c.setStartAfter(
|
|
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
|
|
1286
|
-
|
|
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
|
|
1312
|
+
const a = n.getRangeAt(0);
|
|
1304
1313
|
K(), document.execCommand("removeFormat", !1);
|
|
1305
|
-
const i =
|
|
1306
|
-
|
|
1307
|
-
const c = document.createTreeWalker(
|
|
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,
|
|
1310
|
-
|
|
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 =
|
|
1313
|
-
const
|
|
1321
|
+
for (let u = p.length - 1; u >= 0; u--) {
|
|
1322
|
+
const f = p[u], b = f.parentNode;
|
|
1314
1323
|
if (b) {
|
|
1315
|
-
for (;
|
|
1316
|
-
b.removeChild(
|
|
1324
|
+
for (; f.firstChild; ) b.insertBefore(f.firstChild, f);
|
|
1325
|
+
b.removeChild(f);
|
|
1317
1326
|
}
|
|
1318
1327
|
}
|
|
1319
|
-
|
|
1320
|
-
const
|
|
1321
|
-
for (;
|
|
1322
|
-
|
|
1323
|
-
const
|
|
1324
|
-
|
|
1325
|
-
},
|
|
1326
|
-
var
|
|
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
|
-
}), ((
|
|
1348
|
+
}), ((a = n.textContent) == null ? void 0 : a.replace(/\n{3,}/g, `
|
|
1340
1349
|
|
|
1341
1350
|
`).trim()) || "";
|
|
1342
1351
|
};
|
|
1343
|
-
function
|
|
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
|
|
1349
|
-
const
|
|
1350
|
-
return
|
|
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,
|
|
1353
|
-
return Array.from(
|
|
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(
|
|
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 =
|
|
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((
|
|
1366
|
-
|
|
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
|
|
1373
|
-
const u = t[
|
|
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((
|
|
1377
|
-
/<img\s/i.test(
|
|
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
|
|
1383
|
-
|
|
1384
|
-
const i = (
|
|
1385
|
-
|
|
1386
|
-
const
|
|
1387
|
-
|
|
1388
|
-
}),
|
|
1389
|
-
const
|
|
1390
|
-
|
|
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
|
-
|
|
1394
|
-
const
|
|
1395
|
-
if (!
|
|
1396
|
-
const c =
|
|
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
|
|
1399
|
-
for (;
|
|
1400
|
-
c.insertNode(
|
|
1401
|
-
const
|
|
1402
|
-
|
|
1403
|
-
const u =
|
|
1404
|
-
u.hasAttribute("data-has-resize-handle") || (
|
|
1405
|
-
const b =
|
|
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),
|
|
1414
|
-
|
|
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(
|
|
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 (
|
|
1422
|
-
const n = t.textContent || "",
|
|
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
|
|
1425
|
-
if (
|
|
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,
|
|
1436
|
+
return c.setStart(t, i), c.setEnd(t, a), {
|
|
1428
1437
|
range: c,
|
|
1429
|
-
query:
|
|
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,
|
|
1438
|
-
|
|
1439
|
-
const i =
|
|
1440
|
-
|
|
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
|
|
1445
|
-
z(
|
|
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__ */
|
|
1457
|
-
className: `rte-wrapper ${(
|
|
1465
|
+
return /* @__PURE__ */ l.createElement("div", {
|
|
1466
|
+
className: `rte-wrapper ${(y == null ? void 0 : y.wrapper) || ""}`,
|
|
1458
1467
|
style: w.wrapper
|
|
1459
|
-
}, /* @__PURE__ */
|
|
1468
|
+
}, /* @__PURE__ */ l.createElement("div", {
|
|
1460
1469
|
style: {
|
|
1461
1470
|
flex: 1
|
|
1462
1471
|
}
|
|
1463
|
-
}, /* @__PURE__ */
|
|
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:
|
|
1482
|
+
className: y.toolbar,
|
|
1474
1483
|
style: w.toolbar
|
|
1475
|
-
}), /* @__PURE__ */
|
|
1484
|
+
}), /* @__PURE__ */ l.createElement("div", {
|
|
1476
1485
|
ref: A,
|
|
1477
1486
|
id: "rte-editor-body",
|
|
1478
|
-
className: `rte-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__ */
|
|
1497
|
-
show:
|
|
1498
|
-
position:
|
|
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__ */
|
|
1504
|
-
className: `rte-output ${(
|
|
1512
|
+
}), s && /* @__PURE__ */ l.createElement("div", {
|
|
1513
|
+
className: `rte-output ${(y == null ? void 0 : y.output) || ""}`,
|
|
1505
1514
|
style: w.output
|
|
1506
|
-
}, /* @__PURE__ */
|
|
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__ */
|
|
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__ */
|
|
1522
|
-
className:
|
|
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
|
-
|
|
1538
|
+
Ut as RtePreview,
|
|
1530
1539
|
qt as RteToolbar
|
|
1531
1540
|
};
|