@connectedxm/entity-editor 0.0.8 → 0.0.9
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 +244 -241
- package/dist/src/Editor.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import a from "react";
|
|
2
2
|
var ue = { exports: {} }, ee = {};
|
|
3
|
-
var
|
|
3
|
+
var Le;
|
|
4
4
|
function qe() {
|
|
5
|
-
if (
|
|
6
|
-
|
|
7
|
-
var e = /* @__PURE__ */ Symbol.for("react.transitional.element"),
|
|
5
|
+
if (Le) return ee;
|
|
6
|
+
Le = 1;
|
|
7
|
+
var e = /* @__PURE__ */ Symbol.for("react.transitional.element"), t = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
8
8
|
function s(o, r, i) {
|
|
9
9
|
var c = null;
|
|
10
10
|
if (i !== void 0 && (c = "" + i), r.key !== void 0 && (c = "" + r.key), "key" in r) {
|
|
@@ -20,152 +20,152 @@ function qe() {
|
|
|
20
20
|
props: i
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
return ee.Fragment =
|
|
23
|
+
return ee.Fragment = t, ee.jsx = s, ee.jsxs = s, ee;
|
|
24
24
|
}
|
|
25
25
|
var te = {};
|
|
26
|
-
var
|
|
26
|
+
var $e;
|
|
27
27
|
function He() {
|
|
28
|
-
return
|
|
29
|
-
function e(
|
|
30
|
-
if (
|
|
31
|
-
if (typeof
|
|
32
|
-
return
|
|
33
|
-
if (typeof
|
|
34
|
-
switch (
|
|
28
|
+
return $e || ($e = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
29
|
+
function e(n) {
|
|
30
|
+
if (n == null) return null;
|
|
31
|
+
if (typeof n == "function")
|
|
32
|
+
return n.$$typeof === N ? null : n.displayName || n.name || null;
|
|
33
|
+
if (typeof n == "string") return n;
|
|
34
|
+
switch (n) {
|
|
35
35
|
case U:
|
|
36
36
|
return "Fragment";
|
|
37
|
-
case
|
|
37
|
+
case W:
|
|
38
38
|
return "Profiler";
|
|
39
39
|
case O:
|
|
40
40
|
return "StrictMode";
|
|
41
|
-
case
|
|
41
|
+
case z:
|
|
42
42
|
return "Suspense";
|
|
43
43
|
case X:
|
|
44
44
|
return "SuspenseList";
|
|
45
45
|
case ce:
|
|
46
46
|
return "Activity";
|
|
47
47
|
}
|
|
48
|
-
if (typeof
|
|
49
|
-
switch (typeof
|
|
48
|
+
if (typeof n == "object")
|
|
49
|
+
switch (typeof n.tag == "number" && console.error(
|
|
50
50
|
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
51
|
-
),
|
|
52
|
-
case
|
|
51
|
+
), n.$$typeof) {
|
|
52
|
+
case L:
|
|
53
53
|
return "Portal";
|
|
54
54
|
case be:
|
|
55
|
-
return
|
|
55
|
+
return n.displayName || "Context";
|
|
56
56
|
case ie:
|
|
57
|
-
return (
|
|
58
|
-
case
|
|
59
|
-
var u =
|
|
60
|
-
return
|
|
57
|
+
return (n._context.displayName || "Context") + ".Consumer";
|
|
58
|
+
case C:
|
|
59
|
+
var u = n.render;
|
|
60
|
+
return n = n.displayName, n || (n = u.displayName || u.name || "", n = n !== "" ? "ForwardRef(" + n + ")" : "ForwardRef"), n;
|
|
61
61
|
case we:
|
|
62
|
-
return u =
|
|
62
|
+
return u = n.displayName || null, u !== null ? u : e(n.type) || "Memo";
|
|
63
63
|
case q:
|
|
64
|
-
u =
|
|
64
|
+
u = n._payload, n = n._init;
|
|
65
65
|
try {
|
|
66
|
-
return e(
|
|
66
|
+
return e(n(u));
|
|
67
67
|
} catch {
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
return null;
|
|
71
71
|
}
|
|
72
|
-
function n
|
|
73
|
-
return "" +
|
|
72
|
+
function t(n) {
|
|
73
|
+
return "" + n;
|
|
74
74
|
}
|
|
75
|
-
function s(
|
|
75
|
+
function s(n) {
|
|
76
76
|
try {
|
|
77
|
-
n
|
|
77
|
+
t(n);
|
|
78
78
|
var u = !1;
|
|
79
79
|
} catch {
|
|
80
80
|
u = !0;
|
|
81
81
|
}
|
|
82
82
|
if (u) {
|
|
83
83
|
u = console;
|
|
84
|
-
var m = u.error, S = typeof Symbol == "function" && Symbol.toStringTag &&
|
|
84
|
+
var m = u.error, S = typeof Symbol == "function" && Symbol.toStringTag && n[Symbol.toStringTag] || n.constructor.name || "Object";
|
|
85
85
|
return m.call(
|
|
86
86
|
u,
|
|
87
87
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
88
88
|
S
|
|
89
|
-
), n
|
|
89
|
+
), t(n);
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
function o(
|
|
93
|
-
if (
|
|
94
|
-
if (typeof
|
|
92
|
+
function o(n) {
|
|
93
|
+
if (n === U) return "<>";
|
|
94
|
+
if (typeof n == "object" && n !== null && n.$$typeof === q)
|
|
95
95
|
return "<...>";
|
|
96
96
|
try {
|
|
97
|
-
var u = e(
|
|
97
|
+
var u = e(n);
|
|
98
98
|
return u ? "<" + u + ">" : "<...>";
|
|
99
99
|
} catch {
|
|
100
100
|
return "<...>";
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
function r() {
|
|
104
|
-
var
|
|
105
|
-
return
|
|
104
|
+
var n = T.A;
|
|
105
|
+
return n === null ? null : n.getOwner();
|
|
106
106
|
}
|
|
107
107
|
function i() {
|
|
108
108
|
return Error("react-stack-top-frame");
|
|
109
109
|
}
|
|
110
|
-
function c(
|
|
111
|
-
if (
|
|
112
|
-
var u = Object.getOwnPropertyDescriptor(
|
|
110
|
+
function c(n) {
|
|
111
|
+
if (P.call(n, "key")) {
|
|
112
|
+
var u = Object.getOwnPropertyDescriptor(n, "key").get;
|
|
113
113
|
if (u && u.isReactWarning) return !1;
|
|
114
114
|
}
|
|
115
|
-
return
|
|
115
|
+
return n.key !== void 0;
|
|
116
116
|
}
|
|
117
|
-
function l(
|
|
117
|
+
function l(n, u) {
|
|
118
118
|
function m() {
|
|
119
119
|
Z || (Z = !0, console.error(
|
|
120
120
|
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
121
121
|
u
|
|
122
122
|
));
|
|
123
123
|
}
|
|
124
|
-
m.isReactWarning = !0, Object.defineProperty(
|
|
124
|
+
m.isReactWarning = !0, Object.defineProperty(n, "key", {
|
|
125
125
|
get: m,
|
|
126
126
|
configurable: !0
|
|
127
127
|
});
|
|
128
128
|
}
|
|
129
129
|
function f() {
|
|
130
|
-
var
|
|
131
|
-
return
|
|
130
|
+
var n = e(this.type);
|
|
131
|
+
return G[n] || (G[n] = !0, console.error(
|
|
132
132
|
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
133
|
-
)),
|
|
133
|
+
)), n = this.props.ref, n !== void 0 ? n : null;
|
|
134
134
|
}
|
|
135
|
-
function R(
|
|
135
|
+
function R(n, u, m, S, B, F) {
|
|
136
136
|
var k = m.ref;
|
|
137
|
-
return
|
|
138
|
-
$$typeof:
|
|
139
|
-
type:
|
|
137
|
+
return n = {
|
|
138
|
+
$$typeof: M,
|
|
139
|
+
type: n,
|
|
140
140
|
key: u,
|
|
141
141
|
props: m,
|
|
142
142
|
_owner: S
|
|
143
|
-
}, (k !== void 0 ? k : null) !== null ? Object.defineProperty(
|
|
143
|
+
}, (k !== void 0 ? k : null) !== null ? Object.defineProperty(n, "ref", {
|
|
144
144
|
enumerable: !1,
|
|
145
145
|
get: f
|
|
146
|
-
}) : Object.defineProperty(
|
|
146
|
+
}) : Object.defineProperty(n, "ref", { enumerable: !1, value: null }), n._store = {}, Object.defineProperty(n._store, "validated", {
|
|
147
147
|
configurable: !1,
|
|
148
148
|
enumerable: !1,
|
|
149
149
|
writable: !0,
|
|
150
150
|
value: 0
|
|
151
|
-
}), Object.defineProperty(
|
|
151
|
+
}), Object.defineProperty(n, "_debugInfo", {
|
|
152
152
|
configurable: !1,
|
|
153
153
|
enumerable: !1,
|
|
154
154
|
writable: !0,
|
|
155
155
|
value: null
|
|
156
|
-
}), Object.defineProperty(
|
|
156
|
+
}), Object.defineProperty(n, "_debugStack", {
|
|
157
157
|
configurable: !1,
|
|
158
158
|
enumerable: !1,
|
|
159
159
|
writable: !0,
|
|
160
|
-
value:
|
|
161
|
-
}), Object.defineProperty(
|
|
160
|
+
value: B
|
|
161
|
+
}), Object.defineProperty(n, "_debugTask", {
|
|
162
162
|
configurable: !1,
|
|
163
163
|
enumerable: !1,
|
|
164
164
|
writable: !0,
|
|
165
165
|
value: F
|
|
166
|
-
}), Object.freeze && (Object.freeze(
|
|
166
|
+
}), Object.freeze && (Object.freeze(n.props), Object.freeze(n)), n;
|
|
167
167
|
}
|
|
168
|
-
function y(
|
|
168
|
+
function y(n, u, m, S, B, F) {
|
|
169
169
|
var k = u.children;
|
|
170
170
|
if (k !== void 0)
|
|
171
171
|
if (S)
|
|
@@ -178,12 +178,12 @@ function He() {
|
|
|
178
178
|
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
179
179
|
);
|
|
180
180
|
else K(k);
|
|
181
|
-
if (
|
|
182
|
-
k = e(
|
|
183
|
-
var
|
|
184
|
-
return
|
|
181
|
+
if (P.call(u, "key")) {
|
|
182
|
+
k = e(n);
|
|
183
|
+
var D = Object.keys(u).filter(function(ve) {
|
|
184
|
+
return ve !== "key";
|
|
185
185
|
});
|
|
186
|
-
S = 0 <
|
|
186
|
+
S = 0 < D.length ? "{key: someKey, " + D.join(": ..., ") + ": ...}" : "{key: someKey}", J[k + S] || (D = 0 < D.length ? "{" + D.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
187
187
|
`A props object containing a "key" prop is being spread into JSX:
|
|
188
188
|
let props = %s;
|
|
189
189
|
<%s {...props} />
|
|
@@ -192,9 +192,9 @@ React keys must be passed directly to JSX without using spread:
|
|
|
192
192
|
<%s key={someKey} {...props} />`,
|
|
193
193
|
S,
|
|
194
194
|
k,
|
|
195
|
-
|
|
195
|
+
D,
|
|
196
196
|
k
|
|
197
|
-
),
|
|
197
|
+
), J[k + S] = !0);
|
|
198
198
|
}
|
|
199
199
|
if (k = null, m !== void 0 && (s(m), k = "" + m), c(u) && (s(u.key), k = "" + u.key), "key" in u) {
|
|
200
200
|
m = {};
|
|
@@ -203,67 +203,67 @@ React keys must be passed directly to JSX without using spread:
|
|
|
203
203
|
} else m = u;
|
|
204
204
|
return k && l(
|
|
205
205
|
m,
|
|
206
|
-
typeof
|
|
206
|
+
typeof n == "function" ? n.displayName || n.name || "Unknown" : n
|
|
207
207
|
), R(
|
|
208
|
-
|
|
208
|
+
n,
|
|
209
209
|
k,
|
|
210
210
|
m,
|
|
211
211
|
r(),
|
|
212
|
-
|
|
212
|
+
B,
|
|
213
213
|
F
|
|
214
214
|
);
|
|
215
215
|
}
|
|
216
|
-
function K(
|
|
217
|
-
|
|
216
|
+
function K(n) {
|
|
217
|
+
v(n) ? n._store && (n._store.validated = 1) : typeof n == "object" && n !== null && n.$$typeof === q && (n._payload.status === "fulfilled" ? v(n._payload.value) && n._payload.value._store && (n._payload.value._store.validated = 1) : n._store && (n._store.validated = 1));
|
|
218
218
|
}
|
|
219
|
-
function
|
|
220
|
-
return typeof
|
|
219
|
+
function v(n) {
|
|
220
|
+
return typeof n == "object" && n !== null && n.$$typeof === M;
|
|
221
221
|
}
|
|
222
|
-
var w = a,
|
|
222
|
+
var w = a, M = /* @__PURE__ */ Symbol.for("react.transitional.element"), L = /* @__PURE__ */ Symbol.for("react.portal"), U = /* @__PURE__ */ Symbol.for("react.fragment"), O = /* @__PURE__ */ Symbol.for("react.strict_mode"), W = /* @__PURE__ */ Symbol.for("react.profiler"), ie = /* @__PURE__ */ Symbol.for("react.consumer"), be = /* @__PURE__ */ Symbol.for("react.context"), C = /* @__PURE__ */ Symbol.for("react.forward_ref"), z = /* @__PURE__ */ Symbol.for("react.suspense"), X = /* @__PURE__ */ Symbol.for("react.suspense_list"), we = /* @__PURE__ */ Symbol.for("react.memo"), q = /* @__PURE__ */ Symbol.for("react.lazy"), ce = /* @__PURE__ */ Symbol.for("react.activity"), N = /* @__PURE__ */ Symbol.for("react.client.reference"), T = w.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, P = Object.prototype.hasOwnProperty, H = Array.isArray, V = console.createTask ? console.createTask : function() {
|
|
223
223
|
return null;
|
|
224
224
|
};
|
|
225
225
|
w = {
|
|
226
|
-
react_stack_bottom_frame: function(
|
|
227
|
-
return
|
|
226
|
+
react_stack_bottom_frame: function(n) {
|
|
227
|
+
return n();
|
|
228
228
|
}
|
|
229
229
|
};
|
|
230
|
-
var Z,
|
|
230
|
+
var Z, G = {}, j = w.react_stack_bottom_frame.bind(
|
|
231
231
|
w,
|
|
232
232
|
i
|
|
233
|
-
)(),
|
|
234
|
-
te.Fragment = U, te.jsx = function(
|
|
235
|
-
var S = 1e4 >
|
|
233
|
+
)(), $ = V(o(i)), J = {};
|
|
234
|
+
te.Fragment = U, te.jsx = function(n, u, m) {
|
|
235
|
+
var S = 1e4 > T.recentlyCreatedOwnerStacks++;
|
|
236
236
|
return y(
|
|
237
|
-
|
|
237
|
+
n,
|
|
238
238
|
u,
|
|
239
239
|
m,
|
|
240
240
|
!1,
|
|
241
241
|
S ? Error("react-stack-top-frame") : j,
|
|
242
|
-
S ?
|
|
242
|
+
S ? V(o(n)) : $
|
|
243
243
|
);
|
|
244
|
-
}, te.jsxs = function(
|
|
245
|
-
var S = 1e4 >
|
|
244
|
+
}, te.jsxs = function(n, u, m) {
|
|
245
|
+
var S = 1e4 > T.recentlyCreatedOwnerStacks++;
|
|
246
246
|
return y(
|
|
247
|
-
|
|
247
|
+
n,
|
|
248
248
|
u,
|
|
249
249
|
m,
|
|
250
250
|
!0,
|
|
251
251
|
S ? Error("react-stack-top-frame") : j,
|
|
252
|
-
S ?
|
|
252
|
+
S ? V(o(n)) : $
|
|
253
253
|
);
|
|
254
254
|
};
|
|
255
255
|
})()), te;
|
|
256
256
|
}
|
|
257
|
-
var
|
|
257
|
+
var Be;
|
|
258
258
|
function Ze() {
|
|
259
|
-
return
|
|
259
|
+
return Be || (Be = 1, process.env.NODE_ENV === "production" ? ue.exports = qe() : ue.exports = He()), ue.exports;
|
|
260
260
|
}
|
|
261
|
-
var
|
|
262
|
-
const
|
|
263
|
-
const
|
|
264
|
-
if (!
|
|
265
|
-
if (
|
|
266
|
-
const s =
|
|
261
|
+
var Y = Ze();
|
|
262
|
+
const De = (e) => {
|
|
263
|
+
const t = window.getSelection();
|
|
264
|
+
if (!t || !e) return { start: 0, end: 0 };
|
|
265
|
+
if (t.anchorNode && e.contains(t.anchorNode)) {
|
|
266
|
+
const s = t.getRangeAt(0), o = s.cloneRange();
|
|
267
267
|
o.selectNodeContents(e), o.setEnd(s.startContainer, s.startOffset);
|
|
268
268
|
const r = o.toString().length, i = s.cloneRange();
|
|
269
269
|
i.selectNodeContents(e), i.setEnd(s.endContainer, s.endOffset);
|
|
@@ -271,13 +271,13 @@ const Be = (e) => {
|
|
|
271
271
|
return { start: r, end: c };
|
|
272
272
|
} else
|
|
273
273
|
return null;
|
|
274
|
-
}, Qe = (e,
|
|
274
|
+
}, Qe = (e, t) => {
|
|
275
275
|
const s = document.createTreeWalker(e, NodeFilter.SHOW_TEXT);
|
|
276
276
|
let o = 0, r = s.nextNode(), i = null, c = null, l = 0, f = 0;
|
|
277
277
|
for (; r; ) {
|
|
278
278
|
const R = o + (r.textContent?.length || 0);
|
|
279
|
-
if (!i && R >=
|
|
280
|
-
c = r, f =
|
|
279
|
+
if (!i && R >= t.start && (i = r, l = t.start - o), !c && R >= t.end) {
|
|
280
|
+
c = r, f = t.end - o;
|
|
281
281
|
break;
|
|
282
282
|
}
|
|
283
283
|
o = R, r = s.nextNode();
|
|
@@ -294,38 +294,38 @@ const Be = (e) => {
|
|
|
294
294
|
const y = window.getSelection();
|
|
295
295
|
y?.removeAllRanges(), y?.addRange(R);
|
|
296
296
|
}
|
|
297
|
-
}, et = (e,
|
|
297
|
+
}, et = (e, t, s) => {
|
|
298
298
|
let o = "", r = "", i = "", c = "";
|
|
299
|
-
|
|
299
|
+
t.includes("bold") && (r = "bold"), t.includes("italic") && (i = "italic"), (t.includes("underline") || e === "link") && (c += "underline"), t.includes("strike") && (c += " line-through"), e !== "segment" && (o = "#1da1f2", e === "mention" && s.mentionColor ? o = s.mentionColor : e === "interest" && s.interestColor ? o = s.interestColor : e === "link" && s.linkColor && (o = s.linkColor));
|
|
300
300
|
let l = "";
|
|
301
301
|
return o && (l += `color: ${o}; `), r && (l += `font-weight: ${r}; `), i && (l += `font-style: ${i}; `), c && (l += `text-decoration: ${c}; `), l;
|
|
302
|
-
},
|
|
303
|
-
if (
|
|
302
|
+
}, Ye = (e, t, s) => {
|
|
303
|
+
if (t.length === 0)
|
|
304
304
|
return e;
|
|
305
305
|
let o = "", r = 0;
|
|
306
|
-
return
|
|
306
|
+
return t.forEach((i) => {
|
|
307
307
|
r < i.startIndex && (o += e.slice(r, i.startIndex));
|
|
308
308
|
const c = e.slice(i.startIndex, i.endIndex), l = et(i.type, i.marks, s);
|
|
309
309
|
o += `<span style="${l}">${c}</span>`, r = i.endIndex;
|
|
310
310
|
}), o += e.slice(r), o;
|
|
311
|
-
}, tt = (e,
|
|
311
|
+
}, tt = (e, t) => {
|
|
312
312
|
let s = !1;
|
|
313
|
-
e.key === "Enter" && !e.shiftKey ? (e.preventDefault(), document.execCommand("insertLineBreak"), s = !0) : (e.metaKey || e.ctrlKey) && (e.key === "b" ? (
|
|
313
|
+
e.key === "Enter" && !e.shiftKey ? (e.preventDefault(), document.execCommand("insertLineBreak"), s = !0) : (e.metaKey || e.ctrlKey) && (e.key === "b" ? (t("bold"), s = !0) : e.key === "i" ? (t("italic"), s = !0) : e.key === "u" ? (t("underline"), s = !0) : e.key === "s" && (t("strike"), s = !0)), s && e.preventDefault();
|
|
314
314
|
}, he = 128, nt = "()[]{}", We = "", rt = new RegExp(
|
|
315
315
|
"^(?:(?:(?:https?|ftp):)?\\/\\/)(?:\\S+(?::\\S*)?@)?(?:(?!(?:10|127)(?:\\.\\d{1,3}){3})(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z0-9\\u00a1-\\uffff][a-z0-9\\u00a1-\\uffff_-]{0,62})?[a-z0-9\\u00a1-\\uffff]\\.)+(?:[a-z\\u00a1-\\uffff]{2,}\\.?))(?::\\d{2,5})?(?:[/?#]\\S*)?$",
|
|
316
316
|
"i"
|
|
317
|
-
), ze = (e,
|
|
318
|
-
const s =
|
|
317
|
+
), ze = (e, t) => {
|
|
318
|
+
const s = je(
|
|
319
319
|
e,
|
|
320
|
-
|
|
320
|
+
t,
|
|
321
321
|
nt,
|
|
322
322
|
We
|
|
323
323
|
);
|
|
324
324
|
return s?.search.match(rt) ? s : null;
|
|
325
|
-
}, me = (e) => (e & he) !== 0,
|
|
326
|
-
const s =
|
|
325
|
+
}, me = (e) => (e & he) !== 0, Ae = (e, t) => t ? e | he : e & ~he, Re = 32, st = /^@[a-zA-Z0-9_'-]+$/, ot = `.,!?;()[]{}"'<>#`, ge = "@", Ve = (e, t) => {
|
|
326
|
+
const s = je(
|
|
327
327
|
e,
|
|
328
|
-
|
|
328
|
+
t,
|
|
329
329
|
ot,
|
|
330
330
|
ge
|
|
331
331
|
);
|
|
@@ -333,21 +333,21 @@ const Be = (e) => {
|
|
|
333
333
|
type: "mention",
|
|
334
334
|
...s
|
|
335
335
|
} : null;
|
|
336
|
-
}, ke = (e) => (e & Re) !== 0,
|
|
337
|
-
if (e ===
|
|
336
|
+
}, ke = (e) => (e & Re) !== 0, ye = (e, t) => t ? e | Re : e & ~Re, ne = 2, ae = (e) => (e & ne) !== 0, Oe = (e, t) => t ? e | ne : e & ~ne, re = 4, fe = (e) => (e & re) !== 0, Te = (e, t) => t ? e | re : e & ~re, se = 16, de = (e) => (e & se) !== 0, Ce = (e, t) => t ? e | se : e & ~se, oe = 8, Ee = (e) => (e & oe) !== 0, Pe = (e, t) => t ? e | oe : e & ~oe, Fe = (e, t) => {
|
|
337
|
+
if (e === t) return null;
|
|
338
338
|
let s = 0;
|
|
339
|
-
for (; s < e.length && s <
|
|
339
|
+
for (; s < e.length && s < t.length && e[s] === t[s]; )
|
|
340
340
|
s++;
|
|
341
|
-
let o = e.length, r =
|
|
342
|
-
for (; o > s && r > s && e[o - 1] ===
|
|
341
|
+
let o = e.length, r = t.length;
|
|
342
|
+
for (; o > s && r > s && e[o - 1] === t[r - 1]; )
|
|
343
343
|
o--, r--;
|
|
344
344
|
return {
|
|
345
345
|
position: s,
|
|
346
346
|
deletedLength: o - s,
|
|
347
|
-
insertedText:
|
|
347
|
+
insertedText: t.slice(s, r)
|
|
348
348
|
};
|
|
349
|
-
},
|
|
350
|
-
let r =
|
|
349
|
+
}, xe = (e, t, s, o) => {
|
|
350
|
+
let r = t;
|
|
351
351
|
for (; r < e.length; ) {
|
|
352
352
|
const c = p(e, r);
|
|
353
353
|
if (s(c))
|
|
@@ -356,7 +356,7 @@ const Be = (e) => {
|
|
|
356
356
|
break;
|
|
357
357
|
r++;
|
|
358
358
|
}
|
|
359
|
-
let i =
|
|
359
|
+
let i = t - 1;
|
|
360
360
|
for (; i >= 0; ) {
|
|
361
361
|
const c = p(e, i);
|
|
362
362
|
if (s(c))
|
|
@@ -366,22 +366,22 @@ const Be = (e) => {
|
|
|
366
366
|
i--;
|
|
367
367
|
}
|
|
368
368
|
return e;
|
|
369
|
-
},
|
|
370
|
-
if (!
|
|
371
|
-
const { position: o, deletedLength: r, insertedText: i } =
|
|
369
|
+
}, Ke = (e, t, s) => {
|
|
370
|
+
if (!t) return e;
|
|
371
|
+
const { position: o, deletedLength: r, insertedText: i } = t, c = i.length;
|
|
372
372
|
let l = [...e];
|
|
373
373
|
const f = p(l, o);
|
|
374
|
-
if (ke(f) ? l =
|
|
374
|
+
if (ke(f) ? l = xe(l, o, ke, ye) : Ie(f) ? l = xe(l, o, Ie, Me) : me(f) && (l = xe(l, o, me, Ae)), r > 0 && l.splice(o, r), c > 0) {
|
|
375
375
|
let R = 0;
|
|
376
|
-
s.bold && (R =
|
|
376
|
+
s.bold && (R = Oe(R, !0)), s.italic && (R = Te(R, !0)), s.underline && (R = Pe(R, !0)), s.strike && (R = Ce(R, !0));
|
|
377
377
|
const y = new Array(c).fill(R);
|
|
378
378
|
l.splice(o, 0, ...y);
|
|
379
379
|
}
|
|
380
380
|
return l;
|
|
381
|
-
}, it = (e) => /\s/.test(e) || /[\u2000-\u200B\u2028\u2029\u3000]/.test(e),
|
|
382
|
-
if (
|
|
381
|
+
}, it = (e) => /\s/.test(e) || /[\u2000-\u200B\u2028\u2029\u3000]/.test(e), je = (e, t, s, o) => {
|
|
382
|
+
if (t <= 0 || t > e.length)
|
|
383
383
|
return null;
|
|
384
|
-
let r = "", i =
|
|
384
|
+
let r = "", i = t - 1, c = t;
|
|
385
385
|
const l = (f) => it(f) || s.includes(f);
|
|
386
386
|
for (let f = i; f >= 0; f--) {
|
|
387
387
|
if (l(e[f])) {
|
|
@@ -406,28 +406,28 @@ const Be = (e) => {
|
|
|
406
406
|
startIndex: i,
|
|
407
407
|
endIndex: c
|
|
408
408
|
};
|
|
409
|
-
}, _e = 64, ct = `.,!?;()[]{}"'<>@`, lt = /^#[\w-]+$/, Se = "#", Ge = (e,
|
|
410
|
-
const s =
|
|
409
|
+
}, _e = 64, ct = `.,!?;()[]{}"'<>@`, lt = /^#[\w-]+$/, Se = "#", Ge = (e, t) => {
|
|
410
|
+
const s = je(
|
|
411
411
|
e,
|
|
412
|
-
|
|
412
|
+
t,
|
|
413
413
|
ct,
|
|
414
414
|
Se
|
|
415
415
|
);
|
|
416
416
|
return s?.search.match(lt) ? s : null;
|
|
417
|
-
}, Ie = (e) => (e & _e) !== 0,
|
|
418
|
-
(s) => s.startIndex <=
|
|
419
|
-
), at = (e,
|
|
417
|
+
}, Ie = (e) => (e & _e) !== 0, Me = (e, t) => t ? e | _e : e & ~_e, ut = (e, t) => e.find(
|
|
418
|
+
(s) => s.startIndex <= t && s.endIndex > t
|
|
419
|
+
), at = (e, t, s) => {
|
|
420
420
|
const o = [];
|
|
421
421
|
let r = 0;
|
|
422
|
-
for (; r <
|
|
423
|
-
const i = p(
|
|
422
|
+
for (; r < t.length; ) {
|
|
423
|
+
const i = p(t, r);
|
|
424
424
|
if (i === 0 || i === 1) {
|
|
425
425
|
r++;
|
|
426
426
|
continue;
|
|
427
427
|
}
|
|
428
428
|
const c = r;
|
|
429
429
|
let l = r;
|
|
430
|
-
for (; l + 1 <
|
|
430
|
+
for (; l + 1 < t.length && p(t, l + 1) === i; )
|
|
431
431
|
l++;
|
|
432
432
|
const f = ft(i, s), R = dt(i), y = {
|
|
433
433
|
type: f,
|
|
@@ -444,44 +444,44 @@ const Be = (e) => {
|
|
|
444
444
|
o.push(y), r = l + 1;
|
|
445
445
|
}
|
|
446
446
|
return o;
|
|
447
|
-
}, ft = (e,
|
|
448
|
-
const
|
|
449
|
-
return e & ne &&
|
|
450
|
-
}, p = (e,
|
|
451
|
-
const s = e[
|
|
447
|
+
}, ft = (e, t) => e & Re && t.mentions ? "mention" : e & _e && t.interests ? "interest" : e & he && t.links ? "link" : (e & (ne | re | oe | se), "segment"), dt = (e) => {
|
|
448
|
+
const t = [];
|
|
449
|
+
return e & ne && t.push("bold"), e & re && t.push("italic"), e & oe && t.push("underline"), e & se && t.push("strike"), t;
|
|
450
|
+
}, p = (e, t) => {
|
|
451
|
+
const s = e[t];
|
|
452
452
|
return typeof s != "number" ? 0 : s;
|
|
453
|
-
}, Ne = (e,
|
|
454
|
-
const o = p(e,
|
|
453
|
+
}, Ne = (e, t, s) => {
|
|
454
|
+
const o = p(e, t);
|
|
455
455
|
switch (s) {
|
|
456
456
|
case "mention":
|
|
457
|
-
return
|
|
457
|
+
return ye(o, !0);
|
|
458
458
|
case "interest":
|
|
459
|
-
return
|
|
459
|
+
return Me(o, !0);
|
|
460
460
|
case "link":
|
|
461
|
-
return
|
|
461
|
+
return Ae(o, !0);
|
|
462
462
|
}
|
|
463
463
|
return o;
|
|
464
|
-
}, Et = (e,
|
|
465
|
-
let r = p(e,
|
|
464
|
+
}, Et = (e, t, s, o) => {
|
|
465
|
+
let r = p(e, t);
|
|
466
466
|
switch (s) {
|
|
467
467
|
case "bold":
|
|
468
|
-
r =
|
|
468
|
+
r = Oe(r, o);
|
|
469
469
|
break;
|
|
470
470
|
case "italic":
|
|
471
|
-
r =
|
|
471
|
+
r = Te(r, o);
|
|
472
472
|
break;
|
|
473
473
|
case "underline":
|
|
474
474
|
r = Pe(r, o);
|
|
475
475
|
break;
|
|
476
476
|
case "strike":
|
|
477
|
-
r =
|
|
477
|
+
r = Ce(r, o);
|
|
478
478
|
break;
|
|
479
479
|
default:
|
|
480
480
|
return e;
|
|
481
481
|
}
|
|
482
|
-
return e[
|
|
483
|
-
}, ht = (e,
|
|
484
|
-
const o = p(e,
|
|
482
|
+
return e[t] = r, e;
|
|
483
|
+
}, ht = (e, t, s) => {
|
|
484
|
+
const o = p(e, t);
|
|
485
485
|
switch (s) {
|
|
486
486
|
case "bold":
|
|
487
487
|
return ae(o);
|
|
@@ -494,37 +494,37 @@ const Be = (e) => {
|
|
|
494
494
|
default:
|
|
495
495
|
throw Error(`Invalid mark type: ${s}`);
|
|
496
496
|
}
|
|
497
|
-
}, mt = (e,
|
|
498
|
-
for (let r = e; r <
|
|
497
|
+
}, mt = (e, t, s, o) => {
|
|
498
|
+
for (let r = e; r < t; r++)
|
|
499
499
|
if (!ht(o, r, s)) return !1;
|
|
500
500
|
return !0;
|
|
501
|
-
},
|
|
501
|
+
}, Ue = (e) => ke(e) || Ie(e) || me(e), Rt = (e, t, s, o) => {
|
|
502
502
|
let r = [...e];
|
|
503
|
-
for (;
|
|
504
|
-
|
|
505
|
-
for (;
|
|
503
|
+
for (; Ue(p(e, t - 1)) && t > 0; )
|
|
504
|
+
t--;
|
|
505
|
+
for (; Ue(p(e, s)) && s < e.length; )
|
|
506
506
|
s++;
|
|
507
507
|
let i = !0;
|
|
508
|
-
mt(
|
|
509
|
-
for (let c =
|
|
508
|
+
mt(t, s, o, r) && (i = !1);
|
|
509
|
+
for (let c = t; c < s; c++)
|
|
510
510
|
r = Et(r, c, o, i);
|
|
511
511
|
return r;
|
|
512
|
-
},
|
|
512
|
+
}, pe = (e, t) => {
|
|
513
513
|
const s = new Array(e.length).fill(0);
|
|
514
514
|
for (let o = 0; o < e.length; o++) {
|
|
515
515
|
let r = 0;
|
|
516
|
-
const i = ut(
|
|
516
|
+
const i = ut(t, o);
|
|
517
517
|
if (i) {
|
|
518
|
-
i.type === "mention" ? r =
|
|
518
|
+
i.type === "mention" ? r = ye(r, !0) : i.type === "interest" ? r = Me(r, !0) : i.type === "link" && (r = Ae(r, !0));
|
|
519
519
|
for (const c of i.marks)
|
|
520
|
-
c === "bold" ? r =
|
|
520
|
+
c === "bold" ? r = Oe(r, !0) : c === "italic" ? r = Te(r, !0) : c === "underline" ? r = Pe(r, !0) : c === "strike" && (r = Ce(r, !0));
|
|
521
521
|
}
|
|
522
522
|
s[o] = r;
|
|
523
523
|
}
|
|
524
524
|
return s;
|
|
525
525
|
}, gt = {}, kt = {}, St = ({
|
|
526
526
|
ref: e,
|
|
527
|
-
initialPlainText:
|
|
527
|
+
initialPlainText: t = "",
|
|
528
528
|
initialEntities: s = [],
|
|
529
529
|
onMentionSearch: o,
|
|
530
530
|
onMarkStateChange: r,
|
|
@@ -536,48 +536,48 @@ const Be = (e) => {
|
|
|
536
536
|
debug: y = !1,
|
|
537
537
|
...K
|
|
538
538
|
}) => {
|
|
539
|
-
const
|
|
539
|
+
const v = a.useRef(null), [w, M] = a.useState(t), [L, U] = a.useState({
|
|
540
540
|
bold: !1,
|
|
541
541
|
italic: !1,
|
|
542
542
|
underline: !1,
|
|
543
543
|
strike: !1
|
|
544
|
-
}), [O,
|
|
545
|
-
|
|
546
|
-
),
|
|
544
|
+
}), [O, W] = a.useState(null), [ie, be] = a.useState({ start: 0, end: 0 }), [C, z] = a.useState(!1), [X, we] = a.useState(!1), [q, ce] = a.useState(!1), [N, T] = a.useState(
|
|
545
|
+
pe(t, s)
|
|
546
|
+
), P = a.useMemo(() => at(w, N, l), [w, N, l]), H = a.useRef(o), V = a.useRef(r), Z = a.useRef(C), G = a.useRef(!1), j = a.useRef({
|
|
547
547
|
start: 0,
|
|
548
548
|
end: 0
|
|
549
|
-
}),
|
|
549
|
+
}), $ = a.useRef(null), J = a.useRef(!1), n = a.useRef(null), u = a.useRef(!1), m = a.useRef(null), S = a.useRef(null), B = a.useRef(i), F = a.useRef(c);
|
|
550
550
|
a.useEffect(() => {
|
|
551
551
|
H.current = o;
|
|
552
552
|
}, [o]), a.useEffect(() => {
|
|
553
|
-
|
|
553
|
+
V.current = r;
|
|
554
554
|
}, [r]), a.useEffect(() => {
|
|
555
|
-
|
|
555
|
+
B.current = i;
|
|
556
556
|
}, [i]), a.useEffect(() => {
|
|
557
557
|
F.current = c;
|
|
558
558
|
}, [c]), a.useEffect(() => {
|
|
559
|
-
Z.current =
|
|
560
|
-
}, [
|
|
561
|
-
if (
|
|
559
|
+
Z.current = C;
|
|
560
|
+
}, [C]), a.useEffect(() => {
|
|
561
|
+
if (n.current && clearTimeout(n.current), O === null) {
|
|
562
562
|
H.current?.(null);
|
|
563
563
|
return;
|
|
564
564
|
}
|
|
565
|
-
return
|
|
565
|
+
return n.current = setTimeout(() => {
|
|
566
566
|
H.current?.(O);
|
|
567
567
|
}, 300), () => {
|
|
568
|
-
|
|
568
|
+
n.current && clearTimeout(n.current);
|
|
569
569
|
};
|
|
570
570
|
}, [O]), a.useEffect(() => {
|
|
571
|
-
|
|
572
|
-
}, [
|
|
571
|
+
V.current?.(L);
|
|
572
|
+
}, [L]);
|
|
573
573
|
const k = a.useCallback(
|
|
574
574
|
(h) => {
|
|
575
|
-
if (
|
|
575
|
+
if (z(!0), !v.current)
|
|
576
576
|
return;
|
|
577
577
|
const { start: I, end: b } = j.current;
|
|
578
578
|
if (I !== b) {
|
|
579
579
|
const d = Rt(N, I, b, h);
|
|
580
|
-
|
|
580
|
+
T(d);
|
|
581
581
|
}
|
|
582
582
|
U((d) => {
|
|
583
583
|
const g = { ...d };
|
|
@@ -590,48 +590,51 @@ const Be = (e) => {
|
|
|
590
590
|
e,
|
|
591
591
|
() => ({
|
|
592
592
|
selectEntity: (h, I, b, d) => {
|
|
593
|
-
if (!
|
|
593
|
+
if (!v.current) return;
|
|
594
594
|
let g = [...N];
|
|
595
595
|
h === "mention" ? d = ge + d : h === "interest" ? d = Se + d : h === "link" && (d = We + d);
|
|
596
|
-
const E = w.slice(0, I) + d + w.slice(b), A =
|
|
597
|
-
A ? g =
|
|
596
|
+
const E = w.slice(0, I) + d + w.slice(b), A = Fe(w, E);
|
|
597
|
+
A ? g = Ke(N, A, L) : g = pe(E, P);
|
|
598
598
|
for (let _ = I; _ < I + d.length; _++)
|
|
599
599
|
g[_] = Ne(g, _, h);
|
|
600
|
-
const
|
|
600
|
+
const x = I + d.length;
|
|
601
601
|
j.current = {
|
|
602
|
-
start:
|
|
603
|
-
end:
|
|
604
|
-
}, u.current = !0,
|
|
602
|
+
start: x,
|
|
603
|
+
end: x
|
|
604
|
+
}, u.current = !0, M(E), T(g), W(null);
|
|
605
605
|
},
|
|
606
606
|
toggleMark: k,
|
|
607
607
|
clear: () => {
|
|
608
|
-
|
|
608
|
+
M(""), T([]);
|
|
609
|
+
},
|
|
610
|
+
reset: () => {
|
|
611
|
+
M(t), T(pe(t, s)), W(null);
|
|
609
612
|
},
|
|
610
613
|
focus: () => {
|
|
611
|
-
|
|
614
|
+
v.current?.focus();
|
|
612
615
|
},
|
|
613
616
|
getState: () => ({
|
|
614
617
|
plainText: w,
|
|
615
|
-
entities:
|
|
616
|
-
markState:
|
|
618
|
+
entities: P,
|
|
619
|
+
markState: L
|
|
617
620
|
})
|
|
618
621
|
}),
|
|
619
|
-
[N, w,
|
|
622
|
+
[N, w, P, L, k]
|
|
620
623
|
), a.useEffect(() => {
|
|
621
|
-
if (
|
|
622
|
-
|
|
623
|
-
const h =
|
|
624
|
-
|
|
624
|
+
if (v.current && !X) {
|
|
625
|
+
v.current.textContent = w;
|
|
626
|
+
const h = Ye(w, P, f);
|
|
627
|
+
v.current.innerHTML = h, we(!0);
|
|
625
628
|
}
|
|
626
629
|
}, []), a.useLayoutEffect(() => {
|
|
627
|
-
if (!
|
|
628
|
-
const h = u.current ? j.current :
|
|
630
|
+
if (!v.current || !X) return;
|
|
631
|
+
const h = u.current ? j.current : De(v.current) ?? j.current;
|
|
629
632
|
u.current = !1;
|
|
630
|
-
const I =
|
|
631
|
-
|
|
632
|
-
|
|
633
|
+
const I = Ye(w, P, f);
|
|
634
|
+
J.current = !0, v.current.innerHTML = I, Qe(v.current, h), queueMicrotask(() => {
|
|
635
|
+
J.current = !1;
|
|
633
636
|
});
|
|
634
|
-
}, [
|
|
637
|
+
}, [P, f, X]), a.useEffect(() => {
|
|
635
638
|
let { start: h, end: I } = ie, b = null;
|
|
636
639
|
if (!ke(p(N, h - 1))) {
|
|
637
640
|
const _ = Ve(w, h);
|
|
@@ -642,7 +645,7 @@ const Be = (e) => {
|
|
|
642
645
|
endIndex: _.endIndex
|
|
643
646
|
});
|
|
644
647
|
}
|
|
645
|
-
if (b ? (!O || b.startIndex !== O.startIndex || b.endIndex !== O.endIndex || b.search !== O.search) &&
|
|
648
|
+
if (b ? (!O || b.startIndex !== O.startIndex || b.endIndex !== O.endIndex || b.search !== O.search) && W(b) : O && W(null), C) return;
|
|
646
649
|
let d = !0, g = !0, E = !0, A = !0;
|
|
647
650
|
if (h === I)
|
|
648
651
|
if (h > 0) {
|
|
@@ -663,16 +666,16 @@ const Be = (e) => {
|
|
|
663
666
|
underline: E,
|
|
664
667
|
strike: A
|
|
665
668
|
});
|
|
666
|
-
}, [ie, N, w,
|
|
667
|
-
const
|
|
668
|
-
if (!
|
|
669
|
+
}, [ie, N, w, C]);
|
|
670
|
+
const D = (h) => {
|
|
671
|
+
if (!v.current) return;
|
|
669
672
|
if (h.target.textContent.length === 0) {
|
|
670
|
-
|
|
673
|
+
M(""), T([]), C && z(!1);
|
|
671
674
|
return;
|
|
672
675
|
}
|
|
673
|
-
const I = h.target.innerText || "", b =
|
|
676
|
+
const I = h.target.innerText || "", b = Fe(w, I);
|
|
674
677
|
if (b) {
|
|
675
|
-
let d =
|
|
678
|
+
let d = Ke(N, b, L);
|
|
676
679
|
if (b.deletedLength === 0 && b.insertedText === " " && b.position > 0) {
|
|
677
680
|
const g = b.position;
|
|
678
681
|
if (!me(p(d, g - 1))) {
|
|
@@ -680,17 +683,17 @@ const Be = (e) => {
|
|
|
680
683
|
if (E && E.endIndex === g) {
|
|
681
684
|
const A = `${E.startIndex}:${E.endIndex}:${E.search}`;
|
|
682
685
|
if (m.current !== A) {
|
|
683
|
-
for (let
|
|
684
|
-
d[
|
|
685
|
-
if (m.current = A,
|
|
686
|
-
const
|
|
686
|
+
for (let x = E.startIndex; x < E.endIndex; x++)
|
|
687
|
+
d[x] = Ne(d, x, "link");
|
|
688
|
+
if (m.current = A, B.current) {
|
|
689
|
+
const x = {
|
|
687
690
|
type: "link",
|
|
688
691
|
startIndex: E.startIndex,
|
|
689
692
|
endIndex: E.endIndex,
|
|
690
693
|
marks: [],
|
|
691
694
|
href: E.search
|
|
692
695
|
};
|
|
693
|
-
|
|
696
|
+
B.current(x);
|
|
694
697
|
}
|
|
695
698
|
}
|
|
696
699
|
}
|
|
@@ -700,62 +703,62 @@ const Be = (e) => {
|
|
|
700
703
|
if (E && E.endIndex === g) {
|
|
701
704
|
const A = `${E.startIndex}:${E.endIndex}:${E.search}`;
|
|
702
705
|
if (S.current !== A) {
|
|
703
|
-
for (let
|
|
704
|
-
d[
|
|
706
|
+
for (let x = E.startIndex; x < E.endIndex; x++)
|
|
707
|
+
d[x] = Ne(d, x, "interest");
|
|
705
708
|
if (S.current = A, F.current) {
|
|
706
|
-
const
|
|
709
|
+
const x = {
|
|
707
710
|
type: "interest",
|
|
708
711
|
startIndex: E.startIndex,
|
|
709
712
|
endIndex: E.endIndex,
|
|
710
713
|
marks: [],
|
|
711
714
|
interest: E.search.replace(Se, "")
|
|
712
715
|
};
|
|
713
|
-
F.current(
|
|
716
|
+
F.current(x);
|
|
714
717
|
}
|
|
715
718
|
}
|
|
716
719
|
}
|
|
717
720
|
}
|
|
718
721
|
}
|
|
719
|
-
|
|
720
|
-
|
|
722
|
+
T(d), G.current = !0, setTimeout(() => {
|
|
723
|
+
G.current = !1;
|
|
721
724
|
}, 50);
|
|
722
|
-
} else
|
|
723
|
-
|
|
725
|
+
} else C && z(!1);
|
|
726
|
+
M(I);
|
|
724
727
|
}, Q = (h) => {
|
|
725
|
-
|
|
726
|
-
},
|
|
728
|
+
v.current && tt(h, k);
|
|
729
|
+
}, ve = () => {
|
|
727
730
|
ce(!0);
|
|
728
731
|
}, Je = () => {
|
|
729
732
|
ce(!1);
|
|
730
733
|
};
|
|
731
734
|
a.useEffect(() => {
|
|
732
735
|
const h = () => {
|
|
733
|
-
if (
|
|
734
|
-
const I =
|
|
736
|
+
if (J.current) return;
|
|
737
|
+
const I = De(v.current) ?? {
|
|
735
738
|
start: 0,
|
|
736
739
|
end: 0
|
|
737
740
|
}, b = j.current;
|
|
738
|
-
(I.start !== b.start || I.end !== b.end) && (j.current = I, Z.current && !
|
|
741
|
+
(I.start !== b.start || I.end !== b.end) && (j.current = I, Z.current && !G.current && z(!1), $.current && clearTimeout($.current), $.current = setTimeout(() => {
|
|
739
742
|
be(I);
|
|
740
743
|
}, 500));
|
|
741
744
|
};
|
|
742
745
|
return document.addEventListener("selectionchange", h), () => {
|
|
743
|
-
document.removeEventListener("selectionchange", h),
|
|
746
|
+
document.removeEventListener("selectionchange", h), $.current && clearTimeout($.current);
|
|
744
747
|
};
|
|
745
748
|
}, []);
|
|
746
749
|
const Xe = w.length === 0 && R && !q;
|
|
747
|
-
return /* @__PURE__ */
|
|
748
|
-
/* @__PURE__ */
|
|
749
|
-
/* @__PURE__ */
|
|
750
|
+
return /* @__PURE__ */ Y.jsxs(Y.Fragment, { children: [
|
|
751
|
+
/* @__PURE__ */ Y.jsxs("div", { style: { position: "relative" }, children: [
|
|
752
|
+
/* @__PURE__ */ Y.jsx(
|
|
750
753
|
"div",
|
|
751
754
|
{
|
|
752
|
-
ref:
|
|
755
|
+
ref: v,
|
|
753
756
|
style: { ...K.style, position: "relative", zIndex: 2 },
|
|
754
757
|
className: K.className,
|
|
755
758
|
contentEditable: !0,
|
|
756
759
|
onKeyDown: Q,
|
|
757
|
-
onInput:
|
|
758
|
-
onFocus:
|
|
760
|
+
onInput: D,
|
|
761
|
+
onFocus: ve,
|
|
759
762
|
onBlur: Je,
|
|
760
763
|
role: "textbox",
|
|
761
764
|
"aria-multiline": "true",
|
|
@@ -763,7 +766,7 @@ const Be = (e) => {
|
|
|
763
766
|
autoFocus: !1
|
|
764
767
|
}
|
|
765
768
|
),
|
|
766
|
-
Xe && /* @__PURE__ */
|
|
769
|
+
Xe && /* @__PURE__ */ Y.jsx(
|
|
767
770
|
"div",
|
|
768
771
|
{
|
|
769
772
|
style: {
|
|
@@ -777,11 +780,11 @@ const Be = (e) => {
|
|
|
777
780
|
pointerEvents: "none"
|
|
778
781
|
},
|
|
779
782
|
"aria-hidden": "true",
|
|
780
|
-
children: /* @__PURE__ */
|
|
783
|
+
children: /* @__PURE__ */ Y.jsx("p", { style: { margin: 0 }, children: R })
|
|
781
784
|
}
|
|
782
785
|
)
|
|
783
786
|
] }),
|
|
784
|
-
y && /* @__PURE__ */
|
|
787
|
+
y && /* @__PURE__ */ Y.jsx("div", { style: {}, children: /* @__PURE__ */ Y.jsx("pre", { children: JSON.stringify(N) }) })
|
|
785
788
|
] });
|
|
786
789
|
};
|
|
787
790
|
export {
|
package/dist/src/Editor.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export interface EditorRef {
|
|
|
4
4
|
selectEntity: (entityType: EntityType, startIndex: number, endIndex: number, newText: string) => void;
|
|
5
5
|
toggleMark: (markType: MarkType) => void;
|
|
6
6
|
clear: () => void;
|
|
7
|
+
reset: () => void;
|
|
7
8
|
focus: () => void;
|
|
8
9
|
getState: () => {
|
|
9
10
|
plainText: string;
|