@ryzeup/richtexteditor 1.0.26 → 1.0.27
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 +338 -299
- package/dist/index.js +2 -2
- package/dist/index.umd.js +3 -3
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -11,7 +11,7 @@ var ze = (r, s, u) => s in r ? pt(r, s, { enumerable: !0, configurable: !0, writ
|
|
|
11
11
|
return r;
|
|
12
12
|
}, se = (r, s) => vt(r, yt(s));
|
|
13
13
|
import * as Ct from "react";
|
|
14
|
-
import i, { useRef as
|
|
14
|
+
import i, { useRef as W, useState as D, useEffect as U } from "react";
|
|
15
15
|
import { createPortal as bt } from "react-dom";
|
|
16
16
|
window.React = Ct;
|
|
17
17
|
var je = {
|
|
@@ -21,17 +21,17 @@ var je = {
|
|
|
21
21
|
style: void 0,
|
|
22
22
|
attr: void 0
|
|
23
23
|
}, De = i.createContext && /* @__PURE__ */ i.createContext(je), Lt = ["attr", "size", "title"];
|
|
24
|
-
function
|
|
24
|
+
function xt(r, s) {
|
|
25
25
|
if (r == null) return {};
|
|
26
|
-
var u =
|
|
26
|
+
var u = Rt(r, s), g, p;
|
|
27
27
|
if (Object.getOwnPropertySymbols) {
|
|
28
|
-
var
|
|
29
|
-
for (p = 0; p <
|
|
30
|
-
g =
|
|
28
|
+
var b = Object.getOwnPropertySymbols(r);
|
|
29
|
+
for (p = 0; p < b.length; p++)
|
|
30
|
+
g = b[p], !(s.indexOf(g) >= 0) && Object.prototype.propertyIsEnumerable.call(r, g) && (u[g] = r[g]);
|
|
31
31
|
}
|
|
32
32
|
return u;
|
|
33
33
|
}
|
|
34
|
-
function
|
|
34
|
+
function Rt(r, s) {
|
|
35
35
|
if (r == null) return {};
|
|
36
36
|
var u = {};
|
|
37
37
|
for (var g in r)
|
|
@@ -41,17 +41,17 @@ function xt(r, s) {
|
|
|
41
41
|
}
|
|
42
42
|
return u;
|
|
43
43
|
}
|
|
44
|
-
function
|
|
45
|
-
return
|
|
44
|
+
function ee() {
|
|
45
|
+
return ee = Object.assign ? Object.assign.bind() : function(r) {
|
|
46
46
|
for (var s = 1; s < arguments.length; s++) {
|
|
47
47
|
var u = arguments[s];
|
|
48
48
|
for (var g in u)
|
|
49
49
|
Object.prototype.hasOwnProperty.call(u, g) && (r[g] = u[g]);
|
|
50
50
|
}
|
|
51
51
|
return r;
|
|
52
|
-
},
|
|
52
|
+
}, ee.apply(this, arguments);
|
|
53
53
|
}
|
|
54
|
-
function
|
|
54
|
+
function He(r, s) {
|
|
55
55
|
var u = Object.keys(r);
|
|
56
56
|
if (Object.getOwnPropertySymbols) {
|
|
57
57
|
var g = Object.getOwnPropertySymbols(r);
|
|
@@ -61,12 +61,12 @@ function Oe(r, s) {
|
|
|
61
61
|
}
|
|
62
62
|
return u;
|
|
63
63
|
}
|
|
64
|
-
function
|
|
64
|
+
function te(r) {
|
|
65
65
|
for (var s = 1; s < arguments.length; s++) {
|
|
66
66
|
var u = arguments[s] != null ? arguments[s] : {};
|
|
67
|
-
s % 2 ?
|
|
67
|
+
s % 2 ? He(Object(u), !0).forEach(function(g) {
|
|
68
68
|
St(r, g, u[g]);
|
|
69
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(r, Object.getOwnPropertyDescriptors(u)) :
|
|
69
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(r, Object.getOwnPropertyDescriptors(u)) : He(Object(u)).forEach(function(g) {
|
|
70
70
|
Object.defineProperty(r, g, Object.getOwnPropertyDescriptor(u, g));
|
|
71
71
|
});
|
|
72
72
|
}
|
|
@@ -76,10 +76,10 @@ function St(r, s, u) {
|
|
|
76
76
|
return s = Mt(s), s in r ? Object.defineProperty(r, s, { value: u, enumerable: !0, configurable: !0, writable: !0 }) : r[s] = u, r;
|
|
77
77
|
}
|
|
78
78
|
function Mt(r) {
|
|
79
|
-
var s =
|
|
79
|
+
var s = Tt(r, "string");
|
|
80
80
|
return typeof s == "symbol" ? s : s + "";
|
|
81
81
|
}
|
|
82
|
-
function
|
|
82
|
+
function Tt(r, s) {
|
|
83
83
|
if (typeof r != "object" || !r) return r;
|
|
84
84
|
var u = r[Symbol.toPrimitive];
|
|
85
85
|
if (u !== void 0) {
|
|
@@ -90,35 +90,35 @@ function At(r, s) {
|
|
|
90
90
|
return (s === "string" ? String : Number)(r);
|
|
91
91
|
}
|
|
92
92
|
function Fe(r) {
|
|
93
|
-
return r && r.map((s, u) => /* @__PURE__ */ i.createElement(s.tag,
|
|
93
|
+
return r && r.map((s, u) => /* @__PURE__ */ i.createElement(s.tag, te({
|
|
94
94
|
key: u
|
|
95
95
|
}, s.attr), Fe(s.child)));
|
|
96
96
|
}
|
|
97
97
|
function N(r) {
|
|
98
|
-
return (s) => /* @__PURE__ */ i.createElement(
|
|
99
|
-
attr:
|
|
98
|
+
return (s) => /* @__PURE__ */ i.createElement(At, ee({
|
|
99
|
+
attr: te({}, r.attr)
|
|
100
100
|
}, s), Fe(r.child));
|
|
101
101
|
}
|
|
102
|
-
function
|
|
102
|
+
function At(r) {
|
|
103
103
|
var s = (u) => {
|
|
104
104
|
var {
|
|
105
105
|
attr: g,
|
|
106
106
|
size: p,
|
|
107
|
-
title:
|
|
108
|
-
} = r,
|
|
109
|
-
return u.className && (E = u.className), r.className && (E = (E ? E + " " : "") + r.className), /* @__PURE__ */ i.createElement("svg",
|
|
107
|
+
title: b
|
|
108
|
+
} = r, S = xt(r, Lt), T = p || u.size || "1em", E;
|
|
109
|
+
return u.className && (E = u.className), r.className && (E = (E ? E + " " : "") + r.className), /* @__PURE__ */ i.createElement("svg", ee({
|
|
110
110
|
stroke: "currentColor",
|
|
111
111
|
fill: "currentColor",
|
|
112
112
|
strokeWidth: "0"
|
|
113
|
-
}, u.attr, g,
|
|
113
|
+
}, u.attr, g, S, {
|
|
114
114
|
className: E,
|
|
115
|
-
style:
|
|
115
|
+
style: te(te({
|
|
116
116
|
color: r.color || u.color
|
|
117
117
|
}, u.style), r.style),
|
|
118
118
|
height: T,
|
|
119
119
|
width: T,
|
|
120
120
|
xmlns: "http://www.w3.org/2000/svg"
|
|
121
|
-
}),
|
|
121
|
+
}), b && /* @__PURE__ */ i.createElement("title", null, b), r.children);
|
|
122
122
|
};
|
|
123
123
|
return De !== void 0 ? /* @__PURE__ */ i.createElement(De.Consumer, null, (u) => s(u)) : s(je);
|
|
124
124
|
}
|
|
@@ -134,10 +134,10 @@ function zt(r) {
|
|
|
134
134
|
function Dt(r) {
|
|
135
135
|
return N({ attr: { viewBox: "0 0 512 512" }, child: [{ tag: "path", attr: { d: "M24 56c0-13.3 10.7-24 24-24l32 0c13.3 0 24 10.7 24 24l0 120 16 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-80 0c-13.3 0-24-10.7-24-24s10.7-24 24-24l16 0 0-96-8 0C34.7 80 24 69.3 24 56zM86.7 341.2c-6.5-7.4-18.3-6.9-24 1.2L51.5 357.9c-7.7 10.8-22.7 13.3-33.5 5.6s-13.3-22.7-5.6-33.5l11.1-15.6c23.7-33.2 72.3-35.6 99.2-4.9c21.3 24.4 20.8 60.9-1.1 84.7L86.8 432l33.2 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-88 0c-9.5 0-18.2-5.6-22-14.4s-2.1-18.9 4.3-25.9l72-78c5.3-5.8 5.4-14.6 .3-20.5zM224 64l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 160l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 160l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32z" }, child: [] }] })(r);
|
|
136
136
|
}
|
|
137
|
-
function
|
|
137
|
+
function Ht(r) {
|
|
138
138
|
return N({ attr: { viewBox: "0 0 448 512" }, child: [{ tag: "path", attr: { d: "M12.83 352h262.34A12.82 12.82 0 0 0 288 339.17v-38.34A12.82 12.82 0 0 0 275.17 288H12.83A12.82 12.82 0 0 0 0 300.83v38.34A12.82 12.82 0 0 0 12.83 352zm0-256h262.34A12.82 12.82 0 0 0 288 83.17V44.83A12.82 12.82 0 0 0 275.17 32H12.83A12.82 12.82 0 0 0 0 44.83v38.34A12.82 12.82 0 0 0 12.83 96zM432 160H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0 256H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z" }, child: [] }] })(r);
|
|
139
139
|
}
|
|
140
|
-
function
|
|
140
|
+
function Ot(r) {
|
|
141
141
|
return N({ attr: { viewBox: "0 0 384 512" }, child: [{ tag: "path", attr: { d: "M333.49 238a122 122 0 0 0 27-65.21C367.87 96.49 308 32 233.42 32H34a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h31.87v288H34a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h209.32c70.8 0 134.14-51.75 141-122.4 4.74-48.45-16.39-92.06-50.83-119.6zM145.66 112h87.76a48 48 0 0 1 0 96h-87.76zm87.76 288h-87.76V288h87.76a56 56 0 0 1 0 112z" }, child: [] }] })(r);
|
|
142
142
|
}
|
|
143
143
|
function _t(r) {
|
|
@@ -161,10 +161,10 @@ function qt(r) {
|
|
|
161
161
|
function Bt(r) {
|
|
162
162
|
return N({ attr: { viewBox: "0 0 256 256", fill: "currentColor" }, child: [{ tag: "path", attr: { d: "M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM56.84,75.58a8,8,0,0,1,3.58-10.74l16-8A8,8,0,0,1,88,64v48a8,8,0,0,1-16,0V76.94l-4.42,2.22A8,8,0,0,1,56.84,75.58ZM92,180a8,8,0,0,1,0,16H68a8,8,0,0,1-6.4-12.8l21.67-28.89A3.92,3.92,0,0,0,84,152a4,4,0,0,0-7.77-1.33,8,8,0,0,1-15.09-5.34,20,20,0,1,1,35,18.53L84,180Zm100,4H120a8,8,0,0,1,0-16h72a8,8,0,0,1,0,16Zm0-48H120a8,8,0,0,1,0-16h72a8,8,0,0,1,0,16Zm0-48H120a8,8,0,0,1,0-16h72a8,8,0,0,1,0,16Z" }, child: [] }] })(r);
|
|
163
163
|
}
|
|
164
|
-
function
|
|
164
|
+
function Vt(r) {
|
|
165
165
|
return N({ attr: { viewBox: "0 0 24 24", fill: "currentColor" }, child: [{ tag: "path", attr: { d: "M2 18H9V20H2V18ZM2 11H11V13H2V11ZM2 4H22V6H2V4ZM20.674 13.0251L21.8301 12.634L22.8301 14.366L21.914 15.1711C21.9704 15.4386 22 15.7158 22 16C22 16.2842 21.9704 16.5614 21.914 16.8289L22.8301 17.634L21.8301 19.366L20.674 18.9749C20.2635 19.3441 19.7763 19.6295 19.2391 19.8044L19 21H17L16.7609 19.8044C16.2237 19.6295 15.7365 19.3441 15.326 18.9749L14.1699 19.366L13.1699 17.634L14.086 16.8289C14.0296 16.5614 14 16.2842 14 16C14 15.7158 14.0296 15.4386 14.086 15.1711L13.1699 14.366L14.1699 12.634L15.326 13.0251C15.7365 12.6559 16.2237 12.3705 16.7609 12.1956L17 11H19L19.2391 12.1956C19.7763 12.3705 20.2635 12.6559 20.674 13.0251ZM18 17C18.5523 17 19 16.5523 19 16C19 15.4477 18.5523 15 18 15C17.4477 15 17 15.4477 17 16C17 16.5523 17.4477 17 18 17Z" }, child: [] }] })(r);
|
|
166
166
|
}
|
|
167
|
-
function
|
|
167
|
+
function Ut(r) {
|
|
168
168
|
return N({ attr: { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }, child: [{ tag: "path", attr: { d: "M12 21h-7a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v7" }, child: [] }, { tag: "path", attr: { d: "M3 10h18" }, child: [] }, { tag: "path", attr: { d: "M10 3v18" }, child: [] }, { tag: "path", attr: { d: "M19.001 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0" }, child: [] }, { tag: "path", attr: { d: "M19.001 15.5v1.5" }, child: [] }, { tag: "path", attr: { d: "M19.001 21v1.5" }, child: [] }, { tag: "path", attr: { d: "M22.032 17.25l-1.299 .75" }, child: [] }, { tag: "path", attr: { d: "M17.27 20l-1.3 .75" }, child: [] }, { tag: "path", attr: { d: "M15.97 17.25l1.3 .75" }, child: [] }, { tag: "path", attr: { d: "M20.733 20l1.3 .75" }, child: [] }] })(r);
|
|
169
169
|
}
|
|
170
170
|
function $t(r) {
|
|
@@ -295,30 +295,30 @@ const Xt = [
|
|
|
295
295
|
handleFontSizeChange: g,
|
|
296
296
|
handleFontFamilyChange: p,
|
|
297
297
|
// insertListBlock,
|
|
298
|
-
insertEmoji:
|
|
299
|
-
handleLink:
|
|
298
|
+
insertEmoji: b,
|
|
299
|
+
handleLink: S,
|
|
300
300
|
removeFormatting: T,
|
|
301
301
|
visibleActions: E,
|
|
302
|
-
className:
|
|
303
|
-
style:
|
|
302
|
+
className: w,
|
|
303
|
+
style: x
|
|
304
304
|
}) => {
|
|
305
|
-
var
|
|
306
|
-
const
|
|
305
|
+
var X, B;
|
|
306
|
+
const R = W(null), H = W(null), k = W(null), [O, j] = D(!1), [P, z] = D({
|
|
307
307
|
x: 0,
|
|
308
308
|
y: 0
|
|
309
309
|
});
|
|
310
|
-
|
|
311
|
-
const f = (
|
|
312
|
-
!
|
|
310
|
+
U(() => {
|
|
311
|
+
const f = (L) => {
|
|
312
|
+
!L.target.closest(".rte-emoji-popup") && !L.target.closest("button[title='Emoji']") && j(!1);
|
|
313
313
|
};
|
|
314
314
|
return document.addEventListener("mousedown", f), () => document.removeEventListener("mousedown", f);
|
|
315
315
|
}, []);
|
|
316
|
-
const
|
|
317
|
-
var
|
|
316
|
+
const _ = (f) => {
|
|
317
|
+
var V;
|
|
318
318
|
f.preventDefault();
|
|
319
|
-
const
|
|
320
|
-
if (
|
|
321
|
-
switch (
|
|
319
|
+
const L = f.currentTarget.dataset.command;
|
|
320
|
+
if (L)
|
|
321
|
+
switch (L) {
|
|
322
322
|
case "bold":
|
|
323
323
|
case "italic":
|
|
324
324
|
case "underline":
|
|
@@ -327,20 +327,20 @@ const Xt = [
|
|
|
327
327
|
case "insertOrderedList":
|
|
328
328
|
case "insertStaticOrderedList":
|
|
329
329
|
case "removeFormat":
|
|
330
|
-
r(
|
|
330
|
+
r(L);
|
|
331
331
|
break;
|
|
332
332
|
case "insertImage": {
|
|
333
|
-
(
|
|
333
|
+
(V = R.current) == null || V.click();
|
|
334
334
|
break;
|
|
335
335
|
}
|
|
336
336
|
default:
|
|
337
|
-
console.warn("Unknown command:",
|
|
337
|
+
console.warn("Unknown command:", L);
|
|
338
338
|
}
|
|
339
|
-
},
|
|
339
|
+
}, $ = (f) => {
|
|
340
340
|
r("foreColor", f.target.value);
|
|
341
|
-
},
|
|
341
|
+
}, Z = (f) => {
|
|
342
342
|
r("backColor", f.target.value);
|
|
343
|
-
}, [
|
|
343
|
+
}, [M, F] = D({
|
|
344
344
|
bold: !1,
|
|
345
345
|
italic: !1,
|
|
346
346
|
underline: !1,
|
|
@@ -357,9 +357,9 @@ const Xt = [
|
|
|
357
357
|
color: !1,
|
|
358
358
|
highlight: !1
|
|
359
359
|
});
|
|
360
|
-
return
|
|
360
|
+
return U(() => {
|
|
361
361
|
const f = () => {
|
|
362
|
-
|
|
362
|
+
F({
|
|
363
363
|
bold: document.queryCommandState("bold"),
|
|
364
364
|
italic: document.queryCommandState("italic"),
|
|
365
365
|
underline: document.queryCommandState("underline"),
|
|
@@ -379,67 +379,67 @@ const Xt = [
|
|
|
379
379
|
};
|
|
380
380
|
return document.addEventListener("selectionchange", f), () => document.removeEventListener("selectionchange", f);
|
|
381
381
|
}, []), /* @__PURE__ */ i.createElement("div", {
|
|
382
|
-
className: `rte-toolbar ${
|
|
383
|
-
style:
|
|
382
|
+
className: `rte-toolbar ${w || ""}`,
|
|
383
|
+
style: x
|
|
384
384
|
}, E.bold && /* @__PURE__ */ i.createElement("button", {
|
|
385
385
|
"data-command": "bold",
|
|
386
386
|
title: "Bold",
|
|
387
|
-
onMouseDown:
|
|
388
|
-
className:
|
|
389
|
-
}, /* @__PURE__ */ i.createElement(
|
|
387
|
+
onMouseDown: _,
|
|
388
|
+
className: M.bold ? "rte-active" : ""
|
|
389
|
+
}, /* @__PURE__ */ i.createElement(Ot, null)), E.italic && /* @__PURE__ */ i.createElement("button", {
|
|
390
390
|
"data-command": "italic",
|
|
391
391
|
title: "Italic",
|
|
392
|
-
onMouseDown:
|
|
393
|
-
className:
|
|
392
|
+
onMouseDown: _,
|
|
393
|
+
className: M.italic ? "rte-active" : ""
|
|
394
394
|
}, /* @__PURE__ */ i.createElement(jt, null)), E.underline && /* @__PURE__ */ i.createElement("button", {
|
|
395
395
|
"data-command": "underline",
|
|
396
396
|
title: "Underline",
|
|
397
|
-
onMouseDown:
|
|
398
|
-
className:
|
|
397
|
+
onMouseDown: _,
|
|
398
|
+
className: M.underline ? "rte-active" : ""
|
|
399
399
|
}, /* @__PURE__ */ i.createElement(qt, null)), E.unorderedList && /* @__PURE__ */ i.createElement("button", {
|
|
400
400
|
"data-command": "insertUnorderedList",
|
|
401
|
-
onMouseDown:
|
|
401
|
+
onMouseDown: _,
|
|
402
402
|
title: "UnorderedList",
|
|
403
|
-
className:
|
|
404
|
-
}, /* @__PURE__ */ i.createElement(
|
|
403
|
+
className: M.unorderedList ? "rte-active" : ""
|
|
404
|
+
}, /* @__PURE__ */ i.createElement(Vt, null)), E.staticUnorderedList && /* @__PURE__ */ i.createElement("button", {
|
|
405
405
|
"data-command": "insertStaticUnorderedList",
|
|
406
|
-
onMouseDown:
|
|
406
|
+
onMouseDown: _,
|
|
407
407
|
title: "StaticUnorderedList",
|
|
408
|
-
className:
|
|
408
|
+
className: M.unorderedList ? "rte-active" : ""
|
|
409
409
|
}, /* @__PURE__ */ i.createElement(It, null)), E.orderedList && /* @__PURE__ */ i.createElement("button", {
|
|
410
410
|
"data-command": "insertOrderedList",
|
|
411
411
|
title: "OrderedList",
|
|
412
|
-
onMouseDown:
|
|
413
|
-
className:
|
|
412
|
+
onMouseDown: _,
|
|
413
|
+
className: M.orderedList ? "rte-active" : "",
|
|
414
414
|
style: {
|
|
415
415
|
fontSize: "medium"
|
|
416
416
|
}
|
|
417
417
|
}, /* @__PURE__ */ i.createElement(Bt, null)), E.staticOrderedList && /* @__PURE__ */ i.createElement("button", {
|
|
418
418
|
"data-command": "insertStaticOrderedList",
|
|
419
419
|
title: "StaticOrderedList",
|
|
420
|
-
onMouseDown:
|
|
421
|
-
className:
|
|
420
|
+
onMouseDown: _,
|
|
421
|
+
className: M.orderedList ? "rte-active" : ""
|
|
422
422
|
}, /* @__PURE__ */ i.createElement(Dt, null)), E.link && /* @__PURE__ */ i.createElement("button", {
|
|
423
423
|
"data-command": "createLink",
|
|
424
424
|
title: "Link",
|
|
425
|
-
onClick:
|
|
426
|
-
className:
|
|
425
|
+
onClick: S,
|
|
426
|
+
className: M.link ? "rte-active" : ""
|
|
427
427
|
}, /* @__PURE__ */ i.createElement(Ft, null)), E.removeFormat && /* @__PURE__ */ i.createElement("button", {
|
|
428
428
|
"data-command": "Remove format",
|
|
429
429
|
title: "removeFormat",
|
|
430
430
|
onMouseDown: (f) => {
|
|
431
431
|
f.preventDefault(), s(), T();
|
|
432
432
|
},
|
|
433
|
-
className:
|
|
433
|
+
className: M.removeFormat ? "rte-active" : ""
|
|
434
434
|
}, /* @__PURE__ */ i.createElement(Zt, null)), E.image && /* @__PURE__ */ i.createElement("button", {
|
|
435
435
|
"data-command": "insertImage",
|
|
436
436
|
title: "Image",
|
|
437
|
-
onMouseDown:
|
|
438
|
-
className:
|
|
437
|
+
onMouseDown: _,
|
|
438
|
+
className: M.image ? "rte-active" : ""
|
|
439
439
|
}, /* @__PURE__ */ i.createElement(zt, null)), /* @__PURE__ */ i.createElement("input", {
|
|
440
440
|
type: "file",
|
|
441
441
|
accept: "image/*",
|
|
442
|
-
ref:
|
|
442
|
+
ref: R,
|
|
443
443
|
style: {
|
|
444
444
|
display: "none"
|
|
445
445
|
},
|
|
@@ -452,29 +452,29 @@ const Xt = [
|
|
|
452
452
|
title: "Emoji",
|
|
453
453
|
onMouseDown: (f) => {
|
|
454
454
|
f.preventDefault(), s();
|
|
455
|
-
const
|
|
456
|
-
|
|
457
|
-
x:
|
|
458
|
-
y:
|
|
455
|
+
const L = f.currentTarget.getBoundingClientRect();
|
|
456
|
+
z({
|
|
457
|
+
x: L.left,
|
|
458
|
+
y: L.bottom + 8
|
|
459
459
|
// small spacing
|
|
460
|
-
}),
|
|
460
|
+
}), j((V) => !V);
|
|
461
461
|
},
|
|
462
|
-
className:
|
|
463
|
-
}, /* @__PURE__ */ i.createElement(Pt, null)),
|
|
462
|
+
className: M.emoji ? "rte-active" : ""
|
|
463
|
+
}, /* @__PURE__ */ i.createElement(Pt, null)), O && /* @__PURE__ */ bt(/* @__PURE__ */ i.createElement("div", {
|
|
464
464
|
className: "rte-emoji-popup",
|
|
465
465
|
style: {
|
|
466
466
|
top: P.y,
|
|
467
467
|
left: P.x
|
|
468
468
|
}
|
|
469
|
-
}, Xt.map((f,
|
|
470
|
-
key:
|
|
469
|
+
}, Xt.map((f, L) => /* @__PURE__ */ i.createElement("span", {
|
|
470
|
+
key: L,
|
|
471
471
|
style: {
|
|
472
472
|
fontSize: "20px",
|
|
473
473
|
cursor: "pointer",
|
|
474
474
|
textAlign: "center"
|
|
475
475
|
},
|
|
476
|
-
onMouseDown: (
|
|
477
|
-
|
|
476
|
+
onMouseDown: (V) => {
|
|
477
|
+
V.preventDefault(), b(f), j(!1);
|
|
478
478
|
}
|
|
479
479
|
}, f))), document.body)), E.color && /* @__PURE__ */ i.createElement("div", {
|
|
480
480
|
style: {
|
|
@@ -483,24 +483,24 @@ const Xt = [
|
|
|
483
483
|
}, /* @__PURE__ */ i.createElement("button", {
|
|
484
484
|
title: "Text Color",
|
|
485
485
|
onMouseDown: (f) => {
|
|
486
|
-
var
|
|
487
|
-
f.preventDefault(), s(), (
|
|
486
|
+
var L;
|
|
487
|
+
f.preventDefault(), s(), (L = H.current) == null || L.click();
|
|
488
488
|
},
|
|
489
489
|
style: {
|
|
490
490
|
display: "flex",
|
|
491
491
|
alignItems: "center",
|
|
492
492
|
justifyContent: "center",
|
|
493
|
-
color: ((
|
|
493
|
+
color: ((X = H.current) == null ? void 0 : X.value) || "#000",
|
|
494
494
|
fontSize: "18px"
|
|
495
495
|
},
|
|
496
|
-
className:
|
|
496
|
+
className: M.color ? "rte-active" : ""
|
|
497
497
|
}, /* @__PURE__ */ i.createElement(Wt, null)), /* @__PURE__ */ i.createElement("input", {
|
|
498
|
-
ref:
|
|
498
|
+
ref: H,
|
|
499
499
|
type: "color",
|
|
500
500
|
defaultValue: "#000000",
|
|
501
501
|
onChange: (f) => {
|
|
502
|
-
var
|
|
503
|
-
|
|
502
|
+
var L;
|
|
503
|
+
$(f), ((L = f.target.parentElement) == null ? void 0 : L.querySelector("button")).style.color = f.target.value;
|
|
504
504
|
},
|
|
505
505
|
style: {
|
|
506
506
|
position: "absolute",
|
|
@@ -516,23 +516,23 @@ const Xt = [
|
|
|
516
516
|
}, /* @__PURE__ */ i.createElement("button", {
|
|
517
517
|
title: "Highlight",
|
|
518
518
|
onMouseDown: (f) => {
|
|
519
|
-
var
|
|
520
|
-
f.preventDefault(), s(), (
|
|
519
|
+
var L;
|
|
520
|
+
f.preventDefault(), s(), (L = k.current) == null || L.click();
|
|
521
521
|
},
|
|
522
522
|
style: {
|
|
523
523
|
display: "flex",
|
|
524
524
|
alignItems: "center",
|
|
525
525
|
justifyContent: "center",
|
|
526
|
-
color: ((
|
|
526
|
+
color: ((B = k.current) == null ? void 0 : B.value) || "#000",
|
|
527
527
|
fontSize: "18px"
|
|
528
528
|
},
|
|
529
|
-
className:
|
|
529
|
+
className: M.highlight ? "rte-active" : ""
|
|
530
530
|
}, /* @__PURE__ */ i.createElement(_t, null)), /* @__PURE__ */ i.createElement("input", {
|
|
531
|
-
ref:
|
|
531
|
+
ref: k,
|
|
532
532
|
type: "color",
|
|
533
533
|
onChange: (f) => {
|
|
534
|
-
var
|
|
535
|
-
|
|
534
|
+
var L;
|
|
535
|
+
Z(f), ((L = f.target.parentElement) == null ? void 0 : L.querySelector("button")).style.color = f.target.value;
|
|
536
536
|
},
|
|
537
537
|
defaultValue: "#000000",
|
|
538
538
|
style: {
|
|
@@ -546,30 +546,30 @@ const Xt = [
|
|
|
546
546
|
title: "Align Left",
|
|
547
547
|
onMouseDown: (f) => f.preventDefault(),
|
|
548
548
|
onClick: () => r("justifyLeft"),
|
|
549
|
-
className:
|
|
550
|
-
}, /* @__PURE__ */ i.createElement(
|
|
549
|
+
className: M.alignLeft ? "rte-active" : ""
|
|
550
|
+
}, /* @__PURE__ */ i.createElement(Ht, null)), /* @__PURE__ */ i.createElement("button", {
|
|
551
551
|
title: "Align Center",
|
|
552
552
|
onMouseDown: (f) => f.preventDefault(),
|
|
553
553
|
onClick: () => r("justifyCenter"),
|
|
554
|
-
className:
|
|
554
|
+
className: M.alignCenter ? "rte-active" : ""
|
|
555
555
|
}, /* @__PURE__ */ i.createElement(Nt, null)), /* @__PURE__ */ i.createElement("button", {
|
|
556
556
|
title: "Align Right",
|
|
557
557
|
onMouseDown: (f) => f.preventDefault(),
|
|
558
558
|
onClick: () => r("justifyRight"),
|
|
559
|
-
className:
|
|
559
|
+
className: M.alignRight ? "rte-active" : ""
|
|
560
560
|
}, /* @__PURE__ */ i.createElement(kt, null))), E.table && /* @__PURE__ */ i.createElement("button", {
|
|
561
561
|
title: "Insert Dynamic Table",
|
|
562
562
|
onMouseDown: (f) => f.preventDefault(),
|
|
563
563
|
onClick: () => r("insertTable"),
|
|
564
|
-
className:
|
|
564
|
+
className: M.table ? "rte-active" : "",
|
|
565
565
|
style: {
|
|
566
566
|
fontSize: "medium"
|
|
567
567
|
}
|
|
568
|
-
}, /* @__PURE__ */ i.createElement(
|
|
568
|
+
}, /* @__PURE__ */ i.createElement(Ut, null)), E.table && /* @__PURE__ */ i.createElement("button", {
|
|
569
569
|
title: "Insert Static Table",
|
|
570
570
|
onMouseDown: (f) => f.preventDefault(),
|
|
571
571
|
onClick: () => r("insertStaticTable"),
|
|
572
|
-
className:
|
|
572
|
+
className: M.table ? "rte-active" : "",
|
|
573
573
|
style: {
|
|
574
574
|
fontSize: "medium"
|
|
575
575
|
}
|
|
@@ -601,7 +601,7 @@ const Xt = [
|
|
|
601
601
|
disabled: !0
|
|
602
602
|
}, "Font Size"), Array.from({
|
|
603
603
|
length: 16
|
|
604
|
-
}, (f,
|
|
604
|
+
}, (f, L) => 10 + L).map((f) => /* @__PURE__ */ i.createElement("option", {
|
|
605
605
|
key: f,
|
|
606
606
|
value: f
|
|
607
607
|
}, f, "px"))));
|
|
@@ -611,70 +611,70 @@ const Xt = [
|
|
|
611
611
|
filtered: u,
|
|
612
612
|
insertMention: g,
|
|
613
613
|
onClose: p,
|
|
614
|
-
query:
|
|
614
|
+
query: b
|
|
615
615
|
}) => {
|
|
616
|
-
const
|
|
617
|
-
return
|
|
616
|
+
const S = W(null), [T, E] = D(0);
|
|
617
|
+
return U(() => {
|
|
618
618
|
r && E(0);
|
|
619
|
-
}, [r]),
|
|
620
|
-
const
|
|
621
|
-
|
|
619
|
+
}, [r]), U(() => {
|
|
620
|
+
const w = (x) => {
|
|
621
|
+
S.current && !S.current.contains(x.target) && p();
|
|
622
622
|
};
|
|
623
|
-
return r && document.addEventListener("mousedown",
|
|
624
|
-
document.removeEventListener("mousedown",
|
|
623
|
+
return r && document.addEventListener("mousedown", w), () => {
|
|
624
|
+
document.removeEventListener("mousedown", w);
|
|
625
625
|
};
|
|
626
|
-
}, [r, p]),
|
|
626
|
+
}, [r, p]), U(() => {
|
|
627
627
|
if (!r) return;
|
|
628
|
-
const
|
|
629
|
-
if (!(!r || u.length === 0) && (
|
|
630
|
-
|
|
631
|
-
const
|
|
632
|
-
|
|
628
|
+
const w = (x) => {
|
|
629
|
+
if (!(!r || u.length === 0) && (x.key === "ArrowDown" && (x.preventDefault(), E((R) => Math.min(R + 1, u.length - 1))), x.key === "ArrowUp" && (x.preventDefault(), E((R) => Math.max(R - 1, 0))), x.key === "Enter")) {
|
|
630
|
+
x.preventDefault();
|
|
631
|
+
const R = u[T];
|
|
632
|
+
R && g(R);
|
|
633
633
|
}
|
|
634
634
|
};
|
|
635
|
-
return window.addEventListener("keydown",
|
|
636
|
-
}, [r, u, T]),
|
|
637
|
-
if (!
|
|
638
|
-
const
|
|
639
|
-
|
|
635
|
+
return window.addEventListener("keydown", w), () => window.removeEventListener("keydown", w);
|
|
636
|
+
}, [r, u, T]), U(() => {
|
|
637
|
+
if (!S.current) return;
|
|
638
|
+
const x = S.current.querySelectorAll("li")[T];
|
|
639
|
+
x && x.scrollIntoView({
|
|
640
640
|
block: "nearest",
|
|
641
641
|
behavior: "smooth"
|
|
642
642
|
});
|
|
643
643
|
}, [T]), r ? /* @__PURE__ */ i.createElement("ul", {
|
|
644
|
-
ref:
|
|
644
|
+
ref: S,
|
|
645
645
|
className: "rte-popup",
|
|
646
646
|
style: {
|
|
647
647
|
top: s.y,
|
|
648
648
|
left: s.x
|
|
649
649
|
}
|
|
650
650
|
}, u.length > 0 ? u.map(({
|
|
651
|
-
name:
|
|
652
|
-
value:
|
|
653
|
-
},
|
|
654
|
-
const
|
|
655
|
-
let
|
|
656
|
-
if (
|
|
657
|
-
const P =
|
|
658
|
-
|
|
651
|
+
name: w,
|
|
652
|
+
value: x
|
|
653
|
+
}, R) => {
|
|
654
|
+
const H = w.toLowerCase(), k = b.toLowerCase(), O = H.indexOf(k);
|
|
655
|
+
let j = w;
|
|
656
|
+
if (O !== -1 && b.length > 0) {
|
|
657
|
+
const P = O + b.length;
|
|
658
|
+
j = w.substring(0, O) + `<span class="rte-highlight">${w.substring(O, P)}</span>` + w.substring(P);
|
|
659
659
|
}
|
|
660
660
|
return /* @__PURE__ */ i.createElement("li", {
|
|
661
|
-
key:
|
|
661
|
+
key: x,
|
|
662
662
|
onMouseDown: (P) => {
|
|
663
663
|
P.preventDefault(), g({
|
|
664
|
-
name:
|
|
665
|
-
value:
|
|
664
|
+
name: w,
|
|
665
|
+
value: x
|
|
666
666
|
});
|
|
667
667
|
},
|
|
668
668
|
style: {
|
|
669
669
|
padding: "6px 12px",
|
|
670
670
|
cursor: "pointer",
|
|
671
671
|
fontSize: "14px",
|
|
672
|
-
background:
|
|
672
|
+
background: R === T ? "#dce8ff" : "white"
|
|
673
673
|
},
|
|
674
674
|
dangerouslySetInnerHTML: {
|
|
675
|
-
__html:
|
|
675
|
+
__html: j
|
|
676
676
|
},
|
|
677
|
-
onMouseEnter: () => E(
|
|
677
|
+
onMouseEnter: () => E(R)
|
|
678
678
|
});
|
|
679
679
|
}) : /* @__PURE__ */ i.createElement("li", {
|
|
680
680
|
style: {
|
|
@@ -683,10 +683,10 @@ const Xt = [
|
|
|
683
683
|
}
|
|
684
684
|
}, "No matches")) : null;
|
|
685
685
|
};
|
|
686
|
-
function
|
|
686
|
+
function Oe(r) {
|
|
687
687
|
return N({ attr: { viewBox: "0 0 24 24" }, child: [{ tag: "g", attr: { id: "Circle_Minus" }, child: [{ tag: "g", attr: {}, child: [{ tag: "path", attr: { d: "M15,11.5h0a.5.5,0,0,1,0,1H9a.5.5,0,0,1,0-1Z" }, child: [] }, { tag: "path", attr: { d: "M12,21.934A9.933,9.933,0,1,1,21.932,12,9.945,9.945,0,0,1,12,21.934ZM12,3.068A8.933,8.933,0,1,0,20.932,12,8.944,8.944,0,0,0,12,3.068Z" }, child: [] }] }] }] })(r);
|
|
688
688
|
}
|
|
689
|
-
function
|
|
689
|
+
function G(r) {
|
|
690
690
|
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);
|
|
691
691
|
}
|
|
692
692
|
const Qt = ({
|
|
@@ -697,42 +697,81 @@ const Qt = ({
|
|
|
697
697
|
onClose: p
|
|
698
698
|
}) => {
|
|
699
699
|
if (!r) return null;
|
|
700
|
-
const
|
|
700
|
+
const b = {
|
|
701
701
|
top: u,
|
|
702
702
|
left: s
|
|
703
703
|
};
|
|
704
704
|
return /* @__PURE__ */ i.createElement("div", {
|
|
705
|
-
style:
|
|
705
|
+
style: b,
|
|
706
706
|
className: "rte-table-menu",
|
|
707
707
|
onMouseLeave: p
|
|
708
708
|
}, /* @__PURE__ */ i.createElement("button", {
|
|
709
709
|
onClick: () => g("insertRowAbove")
|
|
710
|
-
}, /* @__PURE__ */ i.createElement(
|
|
710
|
+
}, /* @__PURE__ */ i.createElement(G, null), " Insert row above"), /* @__PURE__ */ i.createElement("button", {
|
|
711
711
|
onClick: () => g("insertRowBelow")
|
|
712
|
-
}, /* @__PURE__ */ i.createElement(
|
|
712
|
+
}, /* @__PURE__ */ i.createElement(G, null), " Insert row below"), /* @__PURE__ */ i.createElement("button", {
|
|
713
713
|
onClick: () => g("insertColLeft")
|
|
714
|
-
}, /* @__PURE__ */ i.createElement(
|
|
714
|
+
}, /* @__PURE__ */ i.createElement(G, null), " Insert col left"), /* @__PURE__ */ i.createElement("button", {
|
|
715
715
|
onClick: () => g("insertColRight")
|
|
716
|
-
}, /* @__PURE__ */ i.createElement(
|
|
716
|
+
}, /* @__PURE__ */ i.createElement(G, null), " Insert col right"), /* @__PURE__ */ i.createElement("button", {
|
|
717
717
|
onClick: () => g("deleteRow")
|
|
718
|
-
}, /* @__PURE__ */ i.createElement(
|
|
718
|
+
}, /* @__PURE__ */ i.createElement(Oe, null), " Delete row"), /* @__PURE__ */ i.createElement("button", {
|
|
719
719
|
onClick: () => g("deleteCol")
|
|
720
|
-
}, /* @__PURE__ */ i.createElement(
|
|
720
|
+
}, /* @__PURE__ */ i.createElement(Oe, null), " Delete column"));
|
|
721
721
|
}, Jt = ({
|
|
722
722
|
html: r,
|
|
723
723
|
className: s,
|
|
724
724
|
style: u
|
|
725
725
|
}) => {
|
|
726
|
-
const g = (
|
|
727
|
-
const
|
|
728
|
-
if (
|
|
729
|
-
|
|
730
|
-
const T =
|
|
726
|
+
const g = (b) => {
|
|
727
|
+
const S = b.target;
|
|
728
|
+
if (S.tagName === "A") {
|
|
729
|
+
b.preventDefault();
|
|
730
|
+
const T = S.href;
|
|
731
731
|
T && window.open(T, "_blank", "noopener,noreferrer");
|
|
732
732
|
}
|
|
733
|
-
}, p = (
|
|
734
|
-
|
|
735
|
-
|
|
733
|
+
}, p = (b) => {
|
|
734
|
+
const S = document.createElement("div");
|
|
735
|
+
S.innerHTML = b;
|
|
736
|
+
const T = document.createTreeWalker(S, NodeFilter.SHOW_TEXT, null), E = [];
|
|
737
|
+
for (; T.nextNode(); ) {
|
|
738
|
+
const w = T.currentNode;
|
|
739
|
+
w.nodeValue && /{{\s*[\s\S]*?\s*}}/.test(w.nodeValue) && E.push(w);
|
|
740
|
+
}
|
|
741
|
+
return E.forEach((w) => {
|
|
742
|
+
var P;
|
|
743
|
+
const x = w.nodeValue || "", R = w.parentElement;
|
|
744
|
+
if (!R) return;
|
|
745
|
+
let H = R, k = !1;
|
|
746
|
+
for (; H; ) {
|
|
747
|
+
if (H.tagName === "FONT" && H.getAttribute("color")) {
|
|
748
|
+
k = !0;
|
|
749
|
+
break;
|
|
750
|
+
}
|
|
751
|
+
const z = (P = H.style) == null ? void 0 : P.color;
|
|
752
|
+
if (z && z !== "") {
|
|
753
|
+
k = !0;
|
|
754
|
+
break;
|
|
755
|
+
}
|
|
756
|
+
const _ = window.getComputedStyle(H);
|
|
757
|
+
if (_.color && _.color !== "rgb(0, 0, 0)" && _.color !== "rgba(0, 0, 0, 0)") {
|
|
758
|
+
k = !0;
|
|
759
|
+
break;
|
|
760
|
+
}
|
|
761
|
+
H = H.parentElement;
|
|
762
|
+
}
|
|
763
|
+
const O = document.createDocumentFragment();
|
|
764
|
+
let j = 0;
|
|
765
|
+
x.replace(/{{\s*([\s\S]*?)\s*}}/g, (z, _, $) => {
|
|
766
|
+
if ($ > j && O.appendChild(document.createTextNode(x.slice(j, $))), k)
|
|
767
|
+
O.appendChild(document.createTextNode(z));
|
|
768
|
+
else {
|
|
769
|
+
const Z = document.createElement("span");
|
|
770
|
+
Z.style.color = "blue", Z.textContent = z, O.appendChild(Z);
|
|
771
|
+
}
|
|
772
|
+
return j = $ + z.length, z;
|
|
773
|
+
}), j < x.length && O.appendChild(document.createTextNode(x.slice(j))), R.replaceChild(O, w);
|
|
774
|
+
}), S.innerHTML = S.innerHTML.replace(/{{#arrayData}}/g, "").replace(/{{\/arrayData}}/g, ""), S.innerHTML;
|
|
736
775
|
};
|
|
737
776
|
return /* @__PURE__ */ i.createElement("div", {
|
|
738
777
|
className: `rte-preview ${s || ""}`,
|
|
@@ -748,16 +787,16 @@ const Qt = ({
|
|
|
748
787
|
onClose: u,
|
|
749
788
|
onInsert: g
|
|
750
789
|
}) => {
|
|
751
|
-
const [p,
|
|
752
|
-
if (
|
|
753
|
-
r ? (
|
|
790
|
+
const [p, b] = D(""), [S, T] = D(""), [E, w] = D(""), [x, R] = D("_self");
|
|
791
|
+
if (U(() => {
|
|
792
|
+
r ? (b(s.url || ""), T(s.text || ""), w(s.title || ""), R(s.target || "_self")) : (b(""), T(""), w(""), R("_self"));
|
|
754
793
|
}, [r, s]), !r) return null;
|
|
755
|
-
const
|
|
794
|
+
const H = () => {
|
|
756
795
|
g({
|
|
757
796
|
url: p,
|
|
758
|
-
text:
|
|
797
|
+
text: S,
|
|
759
798
|
title: E,
|
|
760
|
-
target:
|
|
799
|
+
target: x
|
|
761
800
|
});
|
|
762
801
|
};
|
|
763
802
|
return /* @__PURE__ */ i.createElement(i.Fragment, null, /* @__PURE__ */ i.createElement("div", {
|
|
@@ -772,23 +811,23 @@ const Qt = ({
|
|
|
772
811
|
className: "rte-link-modal__input",
|
|
773
812
|
placeholder: "URL",
|
|
774
813
|
value: p,
|
|
775
|
-
onChange: (
|
|
814
|
+
onChange: (k) => b(k.target.value)
|
|
776
815
|
}), /* @__PURE__ */ i.createElement("input", {
|
|
777
816
|
type: "text",
|
|
778
817
|
className: "rte-link-modal__input",
|
|
779
818
|
placeholder: "Text to Display",
|
|
780
|
-
value:
|
|
781
|
-
onChange: (
|
|
819
|
+
value: S,
|
|
820
|
+
onChange: (k) => T(k.target.value)
|
|
782
821
|
}), /* @__PURE__ */ i.createElement("input", {
|
|
783
822
|
type: "text",
|
|
784
823
|
className: "rte-link-modal__input",
|
|
785
824
|
placeholder: "Title",
|
|
786
825
|
value: E,
|
|
787
|
-
onChange: (
|
|
826
|
+
onChange: (k) => w(k.target.value)
|
|
788
827
|
}), /* @__PURE__ */ i.createElement("select", {
|
|
789
828
|
className: "rte-link-modal__select",
|
|
790
|
-
value:
|
|
791
|
-
onChange: (
|
|
829
|
+
value: x,
|
|
830
|
+
onChange: (k) => R(k.target.value)
|
|
792
831
|
}, /* @__PURE__ */ i.createElement("option", {
|
|
793
832
|
value: "_self"
|
|
794
833
|
}, "Same tab"), /* @__PURE__ */ i.createElement("option", {
|
|
@@ -800,7 +839,7 @@ const Qt = ({
|
|
|
800
839
|
onClick: u
|
|
801
840
|
}, "Cancel"), /* @__PURE__ */ i.createElement("button", {
|
|
802
841
|
className: "rte-link-modal__btn rte-link-modal__btn--ok",
|
|
803
|
-
onClick:
|
|
842
|
+
onClick: H
|
|
804
843
|
}, "OK"))));
|
|
805
844
|
};
|
|
806
845
|
function _e(r) {
|
|
@@ -831,26 +870,26 @@ const rn = ({
|
|
|
831
870
|
staticOrderedList: !1
|
|
832
871
|
},
|
|
833
872
|
classNames: p = {},
|
|
834
|
-
styles:
|
|
835
|
-
handleGetHtml:
|
|
873
|
+
styles: b = {},
|
|
874
|
+
handleGetHtml: S = () => {
|
|
836
875
|
},
|
|
837
876
|
onChange: T = () => {
|
|
838
877
|
},
|
|
839
878
|
value: E,
|
|
840
|
-
onMentionSelect:
|
|
879
|
+
onMentionSelect: w = () => {
|
|
841
880
|
},
|
|
842
|
-
handleAddAttributes:
|
|
881
|
+
handleAddAttributes: x = () => {
|
|
843
882
|
}
|
|
844
883
|
}) => {
|
|
845
|
-
var Ee, we, Ce, be, Le,
|
|
846
|
-
const
|
|
884
|
+
var Ee, we, Ce, be, Le, xe, Re, Se, Me, Te, Ae, Ne;
|
|
885
|
+
const R = W(null), [H, k] = D(E != null && E.length ? E : " "), [O, j] = D(""), [P, z] = D(!1), [_, $] = D({
|
|
847
886
|
x: 0,
|
|
848
887
|
y: 0
|
|
849
|
-
}), [
|
|
888
|
+
}), [Z, M] = D([]), F = W(null), X = W(null), [B, f] = D({
|
|
850
889
|
visible: !1,
|
|
851
890
|
x: 0,
|
|
852
891
|
y: 0
|
|
853
|
-
}), [
|
|
892
|
+
}), [L, V] = D(!1), J = W(null), [Ie, de] = D({
|
|
854
893
|
url: "",
|
|
855
894
|
text: "",
|
|
856
895
|
title: "",
|
|
@@ -866,71 +905,71 @@ const rn = ({
|
|
|
866
905
|
staticOrderedList: (be = g.staticOrderedList) != null ? be : !0,
|
|
867
906
|
align: !0,
|
|
868
907
|
link: (Le = g.link) != null ? Le : !1,
|
|
869
|
-
image: (
|
|
870
|
-
emoji: (
|
|
908
|
+
image: (xe = g.image) != null ? xe : !1,
|
|
909
|
+
emoji: (Re = g.emoji) != null ? Re : !1,
|
|
871
910
|
table: (Se = g.table) != null ? Se : !1,
|
|
872
911
|
color: (Me = g.color) != null ? Me : !1,
|
|
873
|
-
fontFamily: (
|
|
874
|
-
fontSize: (
|
|
912
|
+
fontFamily: (Te = g.fontFamily) != null ? Te : !1,
|
|
913
|
+
fontSize: (Ae = g.fontSize) != null ? Ae : !1,
|
|
875
914
|
highlight: (Ne = g.fontSize) != null ? Ne : !1
|
|
876
|
-
}, [qe, ne] =
|
|
915
|
+
}, [qe, ne] = D(""), [ue, re] = D([]), q = () => R.current, A = () => {
|
|
877
916
|
const e = Be(), t = /^<div[^>]*style=["'][^"']*font-size\s*:\s*\d+px[^"']*["'][^>]*>/.test(e.trim());
|
|
878
917
|
let n = e;
|
|
879
918
|
t || (n = `<div style="font-size:12px">${e}</div>`), n = n.replace(/<(ul|ol)([^>]*)>[\s\S]*?<\/\1>/g, (o, h, y) => {
|
|
880
919
|
if (/list-type=["']static["']/.test(y) || o.includes("data-hidden-array-start") || o.includes("data-hidden-array-end")) return o;
|
|
881
|
-
const m = `<${h}${y}>`, c = '<span data-hidden-array-start="true" style="display:none">{{#arrayData}}</span>', v = '<span data-hidden-array-end="true" style="display:none">{{/arrayData}}</span>',
|
|
882
|
-
return `${m}${c}${
|
|
883
|
-
}),
|
|
920
|
+
const m = `<${h}${y}>`, c = '<span data-hidden-array-start="true" style="display:none">{{#arrayData}}</span>', v = '<span data-hidden-array-end="true" style="display:none">{{/arrayData}}</span>', C = `</${h}>`, I = o.replace(new RegExp(`^${m}`), "").replace(new RegExp(`${C}$`), "");
|
|
921
|
+
return `${m}${c}${I}${v}${C}`;
|
|
922
|
+
}), j(n), S == null || S(n);
|
|
884
923
|
const a = ct(e);
|
|
885
924
|
T(a);
|
|
886
925
|
const d = Ye(), l = _e(d);
|
|
887
|
-
JSON.stringify(l) !== JSON.stringify(ue) && (re(l),
|
|
926
|
+
JSON.stringify(l) !== JSON.stringify(ue) && (re(l), w(l));
|
|
888
927
|
}, Be = () => {
|
|
889
|
-
const e =
|
|
890
|
-
if (!e) return
|
|
928
|
+
const e = q();
|
|
929
|
+
if (!e) return H;
|
|
891
930
|
const t = e.cloneNode(!0);
|
|
892
931
|
t.querySelectorAll("table div").forEach((a) => a.remove()), t.querySelectorAll("table").forEach((a) => {
|
|
893
932
|
a.removeAttribute("data-has-resize-handle");
|
|
894
933
|
}), t.querySelectorAll(".rte-cell-highlight").forEach((a) => a.classList.remove("rte-cell-highlight"));
|
|
895
934
|
let n = t.innerHTML;
|
|
896
|
-
return n =
|
|
897
|
-
},
|
|
935
|
+
return n = Ve(n), n;
|
|
936
|
+
}, Ve = (e) => {
|
|
898
937
|
const t = document.createElement("div");
|
|
899
938
|
return t.innerHTML = e, t.querySelectorAll("tbody").forEach((n) => {
|
|
900
939
|
n.getAttribute("table-type") === "static" || (n.innerHTML = `{{#arrayData}}${n.innerHTML}{{/arrayData}}`);
|
|
901
940
|
}), t.innerHTML;
|
|
902
|
-
},
|
|
941
|
+
}, K = () => {
|
|
903
942
|
const e = window.getSelection();
|
|
904
943
|
if (!e || e.rangeCount === 0) return;
|
|
905
944
|
const t = document.getElementById("rte-editor-body");
|
|
906
945
|
if (!t) return;
|
|
907
946
|
const n = e.getRangeAt(0);
|
|
908
|
-
t.contains(n.startContainer) && (
|
|
909
|
-
},
|
|
947
|
+
t.contains(n.startContainer) && (F.current = n.cloneRange());
|
|
948
|
+
}, Y = () => {
|
|
910
949
|
const e = window.getSelection();
|
|
911
|
-
!e || !
|
|
950
|
+
!e || !F.current || (e.removeAllRanges(), e.addRange(F.current));
|
|
912
951
|
}, me = (e, t) => {
|
|
913
952
|
const n = window.getSelection();
|
|
914
|
-
n && n.rangeCount > 0 && (
|
|
953
|
+
n && n.rangeCount > 0 && (F.current = n.getRangeAt(0)), Y(), document.execCommand(e, !1, t), A();
|
|
915
954
|
};
|
|
916
|
-
|
|
917
|
-
const e =
|
|
955
|
+
U(() => {
|
|
956
|
+
const e = q();
|
|
918
957
|
if (!e || !E) return;
|
|
919
|
-
const t =
|
|
958
|
+
const t = Ue(E);
|
|
920
959
|
e.innerHTML = t, A();
|
|
921
960
|
}, []);
|
|
922
|
-
const
|
|
923
|
-
|
|
961
|
+
const Ue = (e) => e.replace(/(<table[\s\S]*?>[\s\S]*?<\/table>)/g, (t) => t.replace(/{{#arrayData}}/g, "").replace(/{{\/arrayData}}/g, ""));
|
|
962
|
+
U(() => () => {
|
|
924
963
|
document.removeEventListener("mousemove", null), document.removeEventListener("mouseup", null);
|
|
925
|
-
}, []),
|
|
926
|
-
|
|
964
|
+
}, []), U(() => {
|
|
965
|
+
x && x((e) => {
|
|
927
966
|
Ke(e);
|
|
928
967
|
});
|
|
929
|
-
}, []),
|
|
930
|
-
const e =
|
|
968
|
+
}, []), U(() => {
|
|
969
|
+
const e = q();
|
|
931
970
|
if (!e) return;
|
|
932
971
|
e.querySelectorAll("table").forEach((n) => {
|
|
933
|
-
n.hasAttribute("data-has-resize-handle") || (le(n), n.querySelectorAll("th, td").forEach((d) =>
|
|
972
|
+
n.hasAttribute("data-has-resize-handle") || (le(n), n.querySelectorAll("th, td").forEach((d) => Q(d)));
|
|
934
973
|
});
|
|
935
974
|
}, []);
|
|
936
975
|
const ge = (e) => {
|
|
@@ -949,22 +988,22 @@ const rn = ({
|
|
|
949
988
|
c || (c = document.createElement(e), c.style.margin = "0", c.style.paddingLeft = "20px", d.appendChild(c)), o = c, l = document.createElement("li"), l.textContent = "", o.appendChild(l);
|
|
950
989
|
} else {
|
|
951
990
|
document.execCommand(e === "ul" ? "insertUnorderedList" : "insertOrderedList");
|
|
952
|
-
const c =
|
|
991
|
+
const c = q();
|
|
953
992
|
if (o = c == null ? void 0 : c.querySelector(`${e}:last-child`), !o) return;
|
|
954
993
|
h && o.setAttribute("list-type", "static"), l = o.querySelector("li:last-child");
|
|
955
994
|
}
|
|
956
995
|
const y = document.createRange();
|
|
957
|
-
y.setStart(l, 0), y.collapse(!0), n.removeAllRanges(), n.addRange(y), (m =
|
|
996
|
+
y.setStart(l, 0), y.collapse(!0), n.removeAllRanges(), n.addRange(y), (m = q()) == null || m.focus(), A();
|
|
958
997
|
}, ae = (e, t) => {
|
|
959
998
|
e === "insertOrderedList" || e === "insertStaticOrderedList" ? fe("ol", e) : e === "insertUnorderedList" || e === "insertStaticUnorderedList" ? fe("ul", e) : e.startsWith("justify") ? dt(e) : me(e, t), e === "insertTable" && pe(), e === "insertStaticTable" && pe("insertStaticTable");
|
|
960
999
|
}, $e = (e) => {
|
|
961
1000
|
const t = document.createElement("span");
|
|
962
1001
|
t.textContent = "", e.insertNode(t), e.setStartAfter(t), e.collapse(!0);
|
|
963
1002
|
const n = t.getBoundingClientRect();
|
|
964
|
-
t.remove(),
|
|
1003
|
+
t.remove(), $({
|
|
965
1004
|
x: n.left,
|
|
966
1005
|
y: n.bottom + window.scrollY
|
|
967
|
-
}),
|
|
1006
|
+
}), M(r || []), z(!0), X.current = e.cloneRange();
|
|
968
1007
|
}, We = () => {
|
|
969
1008
|
const e = window.getSelection();
|
|
970
1009
|
if (!e || e.rangeCount === 0) return null;
|
|
@@ -988,7 +1027,7 @@ const rn = ({
|
|
|
988
1027
|
const t = window.getSelection();
|
|
989
1028
|
if (!t) return;
|
|
990
1029
|
const n = We();
|
|
991
|
-
n ? (t.removeAllRanges(), t.addRange(n)) :
|
|
1030
|
+
n ? (t.removeAllRanges(), t.addRange(n)) : X.current && (t.removeAllRanges(), t.addRange(X.current));
|
|
992
1031
|
const a = document.createElement("span");
|
|
993
1032
|
a.textContent = `{{${e.name}}}`, a.style.display = "inline", a.setAttribute("data-mention", e.value || e.name || "");
|
|
994
1033
|
try {
|
|
@@ -996,10 +1035,10 @@ const rn = ({
|
|
|
996
1035
|
if (o)
|
|
997
1036
|
o.deleteContents(), o.insertNode(a);
|
|
998
1037
|
else {
|
|
999
|
-
const m = document.createRange(), c =
|
|
1038
|
+
const m = document.createRange(), c = q();
|
|
1000
1039
|
m.selectNodeContents(c), m.collapse(!1), m.insertNode(a);
|
|
1001
1040
|
}
|
|
1002
|
-
const h = document.createTextNode("
|
|
1041
|
+
const h = document.createTextNode("");
|
|
1003
1042
|
a.after(h);
|
|
1004
1043
|
const y = document.createRange();
|
|
1005
1044
|
y.setStartAfter(h), y.collapse(!0), t.removeAllRanges(), t.addRange(y);
|
|
@@ -1007,12 +1046,12 @@ const rn = ({
|
|
|
1007
1046
|
console.error("insertMention error:", o);
|
|
1008
1047
|
}
|
|
1009
1048
|
let d = _e([...ue, e]);
|
|
1010
|
-
re(d),
|
|
1049
|
+
re(d), w(d), z(!1), (l = q()) == null || l.focus(), A();
|
|
1011
1050
|
}, Xe = (e) => {
|
|
1012
|
-
const t =
|
|
1051
|
+
const t = q();
|
|
1013
1052
|
if (!t) return;
|
|
1014
1053
|
let n = null;
|
|
1015
|
-
|
|
1054
|
+
F.current && t.contains(F.current.startContainer) ? n = F.current.cloneRange() : (n = document.createRange(), n.selectNodeContents(t), n.collapse(!1));
|
|
1016
1055
|
const a = window.getSelection();
|
|
1017
1056
|
if (!a) return;
|
|
1018
1057
|
a.removeAllRanges(), a.addRange(n);
|
|
@@ -1021,14 +1060,14 @@ const rn = ({
|
|
|
1021
1060
|
const l = document.createTextNode(" ");
|
|
1022
1061
|
d.after(l);
|
|
1023
1062
|
const o = document.createRange();
|
|
1024
|
-
o.setStartAfter(l), o.collapse(!0), a.removeAllRanges(), a.addRange(o),
|
|
1063
|
+
o.setStartAfter(l), o.collapse(!0), a.removeAllRanges(), a.addRange(o), F.current = o.cloneRange(), t.focus();
|
|
1025
1064
|
}, Ke = (e) => {
|
|
1026
1065
|
e.forEach((t) => Xe(t)), re((t) => {
|
|
1027
1066
|
const n = [...t, ...e], a = Array.from(new Map(n.map((d) => [d.name, d])).values());
|
|
1028
|
-
return
|
|
1067
|
+
return w(a), a;
|
|
1029
1068
|
}), A();
|
|
1030
1069
|
}, Ye = () => {
|
|
1031
|
-
const e =
|
|
1070
|
+
const e = q();
|
|
1032
1071
|
if (!e) return [];
|
|
1033
1072
|
const t = e.querySelectorAll("span[data-mention]"), n = [];
|
|
1034
1073
|
return t.forEach((a) => {
|
|
@@ -1058,8 +1097,8 @@ const rn = ({
|
|
|
1058
1097
|
if (c) {
|
|
1059
1098
|
const v = document.createElement("p");
|
|
1060
1099
|
v.innerHTML = "<br />", (d = c.parentElement) == null || d.insertBefore(v, c.nextSibling), c.removeChild(o);
|
|
1061
|
-
const
|
|
1062
|
-
|
|
1100
|
+
const C = document.createRange();
|
|
1101
|
+
C.setStart(v, 0), C.collapse(!0), l == null || l.removeAllRanges(), l == null || l.addRange(C);
|
|
1063
1102
|
}
|
|
1064
1103
|
}
|
|
1065
1104
|
A();
|
|
@@ -1084,7 +1123,7 @@ const rn = ({
|
|
|
1084
1123
|
if (oe(a))
|
|
1085
1124
|
return;
|
|
1086
1125
|
setTimeout(() => {
|
|
1087
|
-
$e(n.getRangeAt(0)), ne(""),
|
|
1126
|
+
$e(n.getRangeAt(0)), ne(""), M(r), z(!0);
|
|
1088
1127
|
}, 0);
|
|
1089
1128
|
return;
|
|
1090
1129
|
}
|
|
@@ -1105,40 +1144,40 @@ const rn = ({
|
|
|
1105
1144
|
const e = window.getSelection();
|
|
1106
1145
|
if (!e || !e.anchorNode) return;
|
|
1107
1146
|
if (oe(e.anchorNode)) {
|
|
1108
|
-
|
|
1147
|
+
z(!1);
|
|
1109
1148
|
return;
|
|
1110
1149
|
}
|
|
1111
1150
|
let t = e.anchorNode.textContent || "";
|
|
1112
1151
|
t = t.replace(/\u00A0/g, " ");
|
|
1113
1152
|
const n = t.match(/@([^\n]*)$/);
|
|
1114
1153
|
if (!n) {
|
|
1115
|
-
|
|
1154
|
+
z(!1);
|
|
1116
1155
|
return;
|
|
1117
1156
|
}
|
|
1118
1157
|
const a = n[1].trim().toLowerCase();
|
|
1119
1158
|
ne(a);
|
|
1120
1159
|
const d = r.filter((l) => l.name.toLowerCase().includes(a));
|
|
1121
|
-
d.length > 0 ? (
|
|
1160
|
+
d.length > 0 ? (M(d), z(!0)) : z(!1);
|
|
1122
1161
|
}, Ge = (e) => {
|
|
1123
1162
|
var a;
|
|
1124
1163
|
const t = (a = e.target.files) == null ? void 0 : a[0];
|
|
1125
1164
|
if (!t) return;
|
|
1126
1165
|
const n = new FileReader();
|
|
1127
1166
|
n.onload = (d) => {
|
|
1128
|
-
var
|
|
1129
|
-
const l = (
|
|
1130
|
-
|
|
1167
|
+
var C;
|
|
1168
|
+
const l = (C = d.target) == null ? void 0 : C.result;
|
|
1169
|
+
Y();
|
|
1131
1170
|
const o = window.getSelection();
|
|
1132
1171
|
let h = o && o.rangeCount ? o.getRangeAt(0) : null;
|
|
1133
1172
|
const y = document.createElement("img");
|
|
1134
1173
|
y.src = l, y.alt = t.name || "image", y.className = "rte-inserted-image", y.contentEditable = "true";
|
|
1135
|
-
const m =
|
|
1174
|
+
const m = q();
|
|
1136
1175
|
if (!h || !m) {
|
|
1137
1176
|
m == null || m.appendChild(y);
|
|
1138
|
-
const
|
|
1139
|
-
m == null || m.appendChild(
|
|
1177
|
+
const I = document.createTextNode(" ");
|
|
1178
|
+
m == null || m.appendChild(I);
|
|
1140
1179
|
const ie = document.createRange();
|
|
1141
|
-
ie.setStartAfter(
|
|
1180
|
+
ie.setStartAfter(I), ie.collapse(!0), o == null || o.removeAllRanges(), o == null || o.addRange(ie), m == null || m.focus(), A(), e.target.value = "";
|
|
1142
1181
|
return;
|
|
1143
1182
|
}
|
|
1144
1183
|
h.deleteContents(), h.insertNode(y);
|
|
@@ -1149,14 +1188,14 @@ const rn = ({
|
|
|
1149
1188
|
}, n.readAsDataURL(t);
|
|
1150
1189
|
}, et = (e) => {
|
|
1151
1190
|
var d;
|
|
1152
|
-
|
|
1191
|
+
Y();
|
|
1153
1192
|
const t = window.getSelection();
|
|
1154
1193
|
if (!(t != null && t.rangeCount)) return;
|
|
1155
1194
|
const n = t.getRangeAt(0), a = document.createTextNode(e);
|
|
1156
|
-
n.insertNode(a), n.setStartAfter(a), n.collapse(!0), t.removeAllRanges(), t.addRange(n), (d =
|
|
1195
|
+
n.insertNode(a), n.setStartAfter(a), n.collapse(!0), t.removeAllRanges(), t.addRange(n), (d = q()) == null || d.focus(), A();
|
|
1157
1196
|
}, pe = (e) => {
|
|
1158
1197
|
var c;
|
|
1159
|
-
ft(),
|
|
1198
|
+
ft(), Y();
|
|
1160
1199
|
const t = document.createElement("table");
|
|
1161
1200
|
t.style.borderCollapse = "collapse", t.style.width = "100%", t.style.border = "1px solid #ccc", t.style.margin = "8px 0", t.style.position = "relative", t.style.textAlign = "center", p.table && t.classList.add(p.table);
|
|
1162
1201
|
const n = document.createElement("thead");
|
|
@@ -1168,10 +1207,10 @@ const rn = ({
|
|
|
1168
1207
|
const l = document.createElement("tr");
|
|
1169
1208
|
p.tr && l.classList.add(p.tr);
|
|
1170
1209
|
for (let v = 0; v < 2; v++) {
|
|
1171
|
-
const
|
|
1172
|
-
|
|
1173
|
-
const
|
|
1174
|
-
|
|
1210
|
+
const C = document.createElement("th");
|
|
1211
|
+
C.textContent = "", C.style.border = "1px solid #999", C.style.padding = "4px", C.style.position = "relative", C.style.backgroundColor = "lightgray", C.style.height = "20px", p.th && C.classList.add(p.th);
|
|
1212
|
+
const I = document.createElement("td");
|
|
1213
|
+
I.textContent = "", I.style.border = "1px solid #999", I.style.padding = "4px", I.style.position = "relative", I.style.backgroundColor = "#fff", I.style.height = "20px", p.td && I.classList.add(p.td), Q(C), Q(I), d.appendChild(C), l.appendChild(I);
|
|
1175
1214
|
}
|
|
1176
1215
|
n.appendChild(d), a.appendChild(l), t.appendChild(n), t.appendChild(a), le(t);
|
|
1177
1216
|
const o = window.getSelection();
|
|
@@ -1181,7 +1220,7 @@ const rn = ({
|
|
|
1181
1220
|
const y = document.createElement("p");
|
|
1182
1221
|
y.innerHTML = "<br/>", t.after(y);
|
|
1183
1222
|
const m = document.createRange();
|
|
1184
|
-
m.setStart(y, 0), m.collapse(!0), o.removeAllRanges(), o.addRange(m), (c =
|
|
1223
|
+
m.setStart(y, 0), m.collapse(!0), o.removeAllRanges(), o.addRange(m), (c = q()) == null || c.focus(), A();
|
|
1185
1224
|
}, le = (e) => {
|
|
1186
1225
|
if (e.dataset.hasResizeHandle === "true") return;
|
|
1187
1226
|
const t = document.createElement("div");
|
|
@@ -1202,14 +1241,14 @@ const rn = ({
|
|
|
1202
1241
|
const h = e.getBoundingClientRect();
|
|
1203
1242
|
d = h.width, l = h.height;
|
|
1204
1243
|
const y = (c) => {
|
|
1205
|
-
const v = Math.max(100, d + (c.clientX - n)),
|
|
1206
|
-
e.style.width = `${v}px`, e.style.height = `${
|
|
1244
|
+
const v = Math.max(100, d + (c.clientX - n)), C = Math.max(20, l + (c.clientY - a));
|
|
1245
|
+
e.style.width = `${v}px`, e.style.height = `${C}px`, A();
|
|
1207
1246
|
}, m = () => {
|
|
1208
1247
|
document.removeEventListener("mousemove", y), document.removeEventListener("mouseup", m), A();
|
|
1209
1248
|
};
|
|
1210
1249
|
document.addEventListener("mousemove", y), document.addEventListener("mouseup", m);
|
|
1211
1250
|
}), e.appendChild(t);
|
|
1212
|
-
},
|
|
1251
|
+
}, Q = (e) => {
|
|
1213
1252
|
const t = document.createElement("div"), n = document.createElement("div");
|
|
1214
1253
|
Object.assign(t.style, {
|
|
1215
1254
|
position: "absolute",
|
|
@@ -1263,10 +1302,10 @@ const rn = ({
|
|
|
1263
1302
|
}, ve = () => {
|
|
1264
1303
|
document.querySelectorAll(".rte-cell-highlight").forEach((e) => e.classList.remove("rte-cell-highlight"));
|
|
1265
1304
|
}, rt = (e) => {
|
|
1266
|
-
if (!
|
|
1267
|
-
const t =
|
|
1305
|
+
if (!B.cell) return;
|
|
1306
|
+
const t = B.cell.closest("table"), n = B.cell.cellIndex, a = B.cell.parentElement.rowIndex, d = (l) => {
|
|
1268
1307
|
const o = l.tagName.toLowerCase(), h = document.createElement(o);
|
|
1269
|
-
return h.textContent = "", h.style.cssText = l.style.cssText,
|
|
1308
|
+
return h.textContent = "", h.style.cssText = l.style.cssText, Q(h), h;
|
|
1270
1309
|
};
|
|
1271
1310
|
switch (e) {
|
|
1272
1311
|
case "insertRowAbove": {
|
|
@@ -1306,20 +1345,20 @@ const rn = ({
|
|
|
1306
1345
|
});
|
|
1307
1346
|
break;
|
|
1308
1347
|
}
|
|
1309
|
-
A(), f(se(ce({},
|
|
1348
|
+
A(), f(se(ce({}, B), {
|
|
1310
1349
|
visible: !1
|
|
1311
1350
|
})), ve();
|
|
1312
1351
|
}, at = () => {
|
|
1313
|
-
|
|
1352
|
+
K(), J.current = F.current, de({
|
|
1314
1353
|
url: "",
|
|
1315
1354
|
text: "",
|
|
1316
1355
|
title: "",
|
|
1317
1356
|
target: "_self"
|
|
1318
|
-
}),
|
|
1357
|
+
}), V(!0);
|
|
1319
1358
|
}, ot = (e) => {
|
|
1320
1359
|
const t = window.getSelection();
|
|
1321
|
-
if (!t || !
|
|
1322
|
-
t.removeAllRanges(), t.addRange(
|
|
1360
|
+
if (!t || !J.current) return;
|
|
1361
|
+
t.removeAllRanges(), t.addRange(J.current);
|
|
1323
1362
|
let n = e.url.trim();
|
|
1324
1363
|
/^https?:\/\//i.test(n) || (n = "https://" + n);
|
|
1325
1364
|
const a = document.createElement("a");
|
|
@@ -1329,7 +1368,7 @@ const rn = ({
|
|
|
1329
1368
|
const l = document.createTextNode(" ");
|
|
1330
1369
|
a.after(l);
|
|
1331
1370
|
const o = document.createRange();
|
|
1332
|
-
o.setStartAfter(l), o.collapse(!0), t.removeAllRanges(), t.addRange(o),
|
|
1371
|
+
o.setStartAfter(l), o.collapse(!0), t.removeAllRanges(), t.addRange(o), V(!1), A();
|
|
1333
1372
|
}, lt = (e) => {
|
|
1334
1373
|
const t = e.target;
|
|
1335
1374
|
if (t.tagName === "A") {
|
|
@@ -1340,37 +1379,37 @@ const rn = ({
|
|
|
1340
1379
|
}
|
|
1341
1380
|
e.preventDefault();
|
|
1342
1381
|
const a = document.createRange();
|
|
1343
|
-
a.selectNode(n),
|
|
1382
|
+
a.selectNode(n), J.current = a, de({
|
|
1344
1383
|
url: n.href,
|
|
1345
1384
|
text: n.textContent || n.href,
|
|
1346
1385
|
title: n.title,
|
|
1347
1386
|
target: n.target
|
|
1348
|
-
}),
|
|
1387
|
+
}), V(!0);
|
|
1349
1388
|
}
|
|
1350
1389
|
}, it = () => {
|
|
1351
|
-
const e =
|
|
1390
|
+
const e = q();
|
|
1352
1391
|
if (!e) return;
|
|
1353
1392
|
const t = window.getSelection();
|
|
1354
|
-
if ((!t || t.rangeCount === 0) &&
|
|
1393
|
+
if ((!t || t.rangeCount === 0) && F.current) {
|
|
1355
1394
|
const c = window.getSelection();
|
|
1356
|
-
c == null || c.removeAllRanges(), c == null || c.addRange(
|
|
1395
|
+
c == null || c.removeAllRanges(), c == null || c.addRange(F.current);
|
|
1357
1396
|
}
|
|
1358
1397
|
const n = window.getSelection();
|
|
1359
1398
|
if (!n || n.rangeCount === 0) return;
|
|
1360
1399
|
const a = n.getRangeAt(0);
|
|
1361
|
-
|
|
1400
|
+
Y(), document.execCommand("removeFormat", !1);
|
|
1362
1401
|
const d = a.cloneContents(), l = document.createElement("div");
|
|
1363
1402
|
l.appendChild(d);
|
|
1364
1403
|
const o = document.createTreeWalker(l, NodeFilter.SHOW_ELEMENT, null), h = [];
|
|
1365
1404
|
for (; o.nextNode(); ) {
|
|
1366
|
-
const c = o.currentNode, v = c.tagName.toUpperCase(),
|
|
1367
|
-
v !== "A" && !
|
|
1405
|
+
const c = o.currentNode, v = c.tagName.toUpperCase(), C = c.getAttribute && c.getAttribute("data-mention") !== null;
|
|
1406
|
+
v !== "A" && !C && h.push(c);
|
|
1368
1407
|
}
|
|
1369
1408
|
for (let c = h.length - 1; c >= 0; c--) {
|
|
1370
|
-
const v = h[c],
|
|
1371
|
-
if (
|
|
1372
|
-
for (; v.firstChild; )
|
|
1373
|
-
|
|
1409
|
+
const v = h[c], C = v.parentNode;
|
|
1410
|
+
if (C) {
|
|
1411
|
+
for (; v.firstChild; ) C.insertBefore(v.firstChild, v);
|
|
1412
|
+
C.removeChild(v);
|
|
1374
1413
|
}
|
|
1375
1414
|
}
|
|
1376
1415
|
l.querySelectorAll("[style]").forEach((c) => c.removeAttribute("style")), a.deleteContents();
|
|
@@ -1455,16 +1494,16 @@ const rn = ({
|
|
|
1455
1494
|
const h = document.createDocumentFragment();
|
|
1456
1495
|
for (; a.firstChild; ) h.appendChild(a.firstChild);
|
|
1457
1496
|
o.insertNode(h), o.collapse(!1), l.removeAllRanges(), l.addRange(o);
|
|
1458
|
-
const y =
|
|
1497
|
+
const y = R.current;
|
|
1459
1498
|
y && (y.querySelectorAll("table").forEach((m) => {
|
|
1460
1499
|
const c = m;
|
|
1461
1500
|
c.hasAttribute("data-has-resize-handle") || (le(c), c.querySelectorAll("th, td").forEach((v) => {
|
|
1462
|
-
const
|
|
1463
|
-
|
|
1501
|
+
const C = v;
|
|
1502
|
+
C.dataset.hasResizeHandles || Q(C);
|
|
1464
1503
|
}));
|
|
1465
1504
|
}), A());
|
|
1466
1505
|
}, mt = (e) => {
|
|
1467
|
-
|
|
1506
|
+
Y();
|
|
1468
1507
|
const t = window.getSelection();
|
|
1469
1508
|
if (!t || !t.rangeCount) return;
|
|
1470
1509
|
const n = t.getRangeAt(0), a = document.createElement("span");
|
|
@@ -1494,25 +1533,25 @@ const rn = ({
|
|
|
1494
1533
|
} = e, a = document.createElement("span");
|
|
1495
1534
|
a.textContent = "", t.insertNode(a);
|
|
1496
1535
|
const d = a.getBoundingClientRect();
|
|
1497
|
-
a.remove(),
|
|
1536
|
+
a.remove(), $({
|
|
1498
1537
|
x: d.left,
|
|
1499
1538
|
y: d.bottom + window.scrollY
|
|
1500
1539
|
}), ne(n.toLowerCase());
|
|
1501
1540
|
const l = r.filter((o) => o.name.toLowerCase().includes(n.toLowerCase()));
|
|
1502
|
-
|
|
1541
|
+
M(l), z(!0), X.current = t.cloneRange();
|
|
1503
1542
|
};
|
|
1504
1543
|
function ft() {
|
|
1505
|
-
const e =
|
|
1544
|
+
const e = R.current;
|
|
1506
1545
|
if (!e) return;
|
|
1507
1546
|
const t = window.getSelection();
|
|
1508
1547
|
if (!t || t.rangeCount > 0 && e.contains(t.anchorNode))
|
|
1509
1548
|
return;
|
|
1510
1549
|
const n = document.createRange();
|
|
1511
|
-
n.selectNodeContents(e), n.collapse(!1), t.removeAllRanges(), t.addRange(n),
|
|
1550
|
+
n.selectNodeContents(e), n.collapse(!1), t.removeAllRanges(), t.addRange(n), F.current = n.cloneRange();
|
|
1512
1551
|
}
|
|
1513
1552
|
const ht = (e) => {
|
|
1514
1553
|
const t = e.target;
|
|
1515
|
-
if (!t || !(t.textContent || "").match(/{{([\s\S]+?)}}/) || !
|
|
1554
|
+
if (!t || !(t.textContent || "").match(/{{([\s\S]+?)}}/) || !R.current) return;
|
|
1516
1555
|
let l = t.firstChild;
|
|
1517
1556
|
if ((!l || l.nodeType !== Node.TEXT_NODE) && (l = t.childNodes[0]), !l || l.nodeType !== Node.TEXT_NODE) return;
|
|
1518
1557
|
const o = l.textContent || "", h = o.indexOf("{{"), y = o.indexOf("}}");
|
|
@@ -1524,14 +1563,14 @@ const rn = ({
|
|
|
1524
1563
|
};
|
|
1525
1564
|
return /* @__PURE__ */ i.createElement("div", {
|
|
1526
1565
|
className: `rte-wrapper ${(p == null ? void 0 : p.wrapper) || ""}`,
|
|
1527
|
-
style:
|
|
1566
|
+
style: b.wrapper
|
|
1528
1567
|
}, /* @__PURE__ */ i.createElement("div", {
|
|
1529
1568
|
style: {
|
|
1530
1569
|
flex: 1
|
|
1531
1570
|
}
|
|
1532
1571
|
}, /* @__PURE__ */ i.createElement(Kt, {
|
|
1533
1572
|
exec: ae,
|
|
1534
|
-
saveSelection:
|
|
1573
|
+
saveSelection: K,
|
|
1535
1574
|
handleFileChange: Ge,
|
|
1536
1575
|
handleFontSizeChange: (e) => mt(e.target.value),
|
|
1537
1576
|
handleFontFamilyChange: (e) => ae("fontName", e.target.value),
|
|
@@ -1540,58 +1579,58 @@ const rn = ({
|
|
|
1540
1579
|
removeFormatting: it,
|
|
1541
1580
|
visibleActions: Pe,
|
|
1542
1581
|
className: p.toolbar,
|
|
1543
|
-
style:
|
|
1582
|
+
style: b.toolbar
|
|
1544
1583
|
}), /* @__PURE__ */ i.createElement("div", {
|
|
1545
|
-
ref:
|
|
1584
|
+
ref: R,
|
|
1546
1585
|
id: "rte-editor-body",
|
|
1547
1586
|
className: `rte-editor ${(p == null ? void 0 : p.editor) || ""}`,
|
|
1548
|
-
style:
|
|
1587
|
+
style: b.editor,
|
|
1549
1588
|
contentEditable: !0,
|
|
1550
1589
|
suppressContentEditableWarning: !0,
|
|
1551
1590
|
onPaste: ut,
|
|
1552
1591
|
onKeyUp: () => {
|
|
1553
|
-
|
|
1592
|
+
K(), ye();
|
|
1554
1593
|
},
|
|
1555
|
-
onMouseUp:
|
|
1594
|
+
onMouseUp: K,
|
|
1556
1595
|
onInput: () => {
|
|
1557
|
-
he(),
|
|
1596
|
+
he(), K();
|
|
1558
1597
|
},
|
|
1559
1598
|
onKeyDown: Qe,
|
|
1560
1599
|
onBeforeInput: Je,
|
|
1561
1600
|
onContextMenu: nt,
|
|
1562
1601
|
onClick: (e) => {
|
|
1563
|
-
lt(e),
|
|
1602
|
+
lt(e), K(), ye();
|
|
1564
1603
|
},
|
|
1565
1604
|
onDoubleClick: ht
|
|
1566
1605
|
}), /* @__PURE__ */ i.createElement(Yt, {
|
|
1567
1606
|
show: P,
|
|
1568
|
-
position:
|
|
1569
|
-
filtered:
|
|
1607
|
+
position: _,
|
|
1608
|
+
filtered: Z,
|
|
1570
1609
|
insertMention: Ze,
|
|
1571
|
-
onClose: () =>
|
|
1610
|
+
onClose: () => z(!1),
|
|
1572
1611
|
query: qe
|
|
1573
1612
|
}), s && /* @__PURE__ */ i.createElement("div", {
|
|
1574
1613
|
className: `rte-output ${(p == null ? void 0 : p.output) || ""}`,
|
|
1575
|
-
style:
|
|
1576
|
-
}, /* @__PURE__ */ i.createElement("h4", null, "Output HTML:"), /* @__PURE__ */ i.createElement("p", null,
|
|
1577
|
-
visible:
|
|
1578
|
-
x:
|
|
1579
|
-
y:
|
|
1614
|
+
style: b.output
|
|
1615
|
+
}, /* @__PURE__ */ i.createElement("h4", null, "Output HTML:"), /* @__PURE__ */ i.createElement("p", null, O)), /* @__PURE__ */ i.createElement(Qt, {
|
|
1616
|
+
visible: B.visible,
|
|
1617
|
+
x: B.x,
|
|
1618
|
+
y: B.y,
|
|
1580
1619
|
onAction: rt,
|
|
1581
1620
|
onClose: () => {
|
|
1582
|
-
f(se(ce({},
|
|
1621
|
+
f(se(ce({}, B), {
|
|
1583
1622
|
visible: !1
|
|
1584
1623
|
})), ve();
|
|
1585
1624
|
}
|
|
1586
1625
|
}), /* @__PURE__ */ i.createElement(Gt, {
|
|
1587
|
-
visible:
|
|
1626
|
+
visible: L,
|
|
1588
1627
|
linkData: Ie,
|
|
1589
|
-
onClose: () =>
|
|
1628
|
+
onClose: () => V(!1),
|
|
1590
1629
|
onInsert: ot
|
|
1591
1630
|
})), u ? /* @__PURE__ */ i.createElement(Jt, {
|
|
1592
1631
|
className: p.preview,
|
|
1593
|
-
style:
|
|
1594
|
-
html:
|
|
1632
|
+
style: b.preview,
|
|
1633
|
+
html: O
|
|
1595
1634
|
}) : null);
|
|
1596
1635
|
};
|
|
1597
1636
|
export {
|