@connectedxm/entity-editor 0.0.4 → 0.0.5
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 +109 -128
- package/dist/src/helpers/dom.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
import A, { useState as $e, useRef as me, useEffect as Ye } from "react";
|
|
2
2
|
var X = { exports: {} }, x = {};
|
|
3
|
-
/**
|
|
4
|
-
* @license React
|
|
5
|
-
* react-jsx-runtime.production.js
|
|
6
|
-
*
|
|
7
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the MIT license found in the
|
|
10
|
-
* LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/
|
|
12
3
|
var Ae;
|
|
13
4
|
function Fe() {
|
|
14
5
|
if (Ae) return x;
|
|
@@ -31,16 +22,7 @@ function Fe() {
|
|
|
31
22
|
}
|
|
32
23
|
return x.Fragment = t, x.jsx = n, x.jsxs = n, x;
|
|
33
24
|
}
|
|
34
|
-
var
|
|
35
|
-
/**
|
|
36
|
-
* @license React
|
|
37
|
-
* react-jsx-runtime.development.js
|
|
38
|
-
*
|
|
39
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
40
|
-
*
|
|
41
|
-
* This source code is licensed under the MIT license found in the
|
|
42
|
-
* LICENSE file in the root directory of this source tree.
|
|
43
|
-
*/
|
|
25
|
+
var L = {};
|
|
44
26
|
var Oe;
|
|
45
27
|
function We() {
|
|
46
28
|
return Oe || (Oe = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
@@ -67,7 +49,7 @@ function We() {
|
|
|
67
49
|
switch (typeof r.tag == "number" && console.error(
|
|
68
50
|
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
69
51
|
), r.$$typeof) {
|
|
70
|
-
case
|
|
52
|
+
case b:
|
|
71
53
|
return "Portal";
|
|
72
54
|
case K:
|
|
73
55
|
return (r.displayName || "Context") + ".Provider";
|
|
@@ -76,7 +58,7 @@ function We() {
|
|
|
76
58
|
case ue:
|
|
77
59
|
var l = r.render;
|
|
78
60
|
return r = r.displayName, r || (r = l.displayName || l.name || "", r = r !== "" ? "ForwardRef(" + r + ")" : "ForwardRef"), r;
|
|
79
|
-
case
|
|
61
|
+
case w:
|
|
80
62
|
return l = r.displayName || null, l !== null ? l : e(r.type) || "Memo";
|
|
81
63
|
case I:
|
|
82
64
|
l = r._payload, r = r._init;
|
|
@@ -99,11 +81,11 @@ function We() {
|
|
|
99
81
|
}
|
|
100
82
|
if (l) {
|
|
101
83
|
l = console;
|
|
102
|
-
var d = l.error,
|
|
84
|
+
var d = l.error, R = typeof Symbol == "function" && Symbol.toStringTag && r[Symbol.toStringTag] || r.constructor.name || "Object";
|
|
103
85
|
return d.call(
|
|
104
86
|
l,
|
|
105
87
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
106
|
-
|
|
88
|
+
R
|
|
107
89
|
), t(r);
|
|
108
90
|
}
|
|
109
91
|
}
|
|
@@ -150,13 +132,13 @@ function We() {
|
|
|
150
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."
|
|
151
133
|
)), r = this.props.ref, r !== void 0 ? r : null;
|
|
152
134
|
}
|
|
153
|
-
function m(r, l, d,
|
|
154
|
-
return d =
|
|
135
|
+
function m(r, l, d, R, _, v, de, Ee) {
|
|
136
|
+
return d = v.ref, r = {
|
|
155
137
|
$$typeof: j,
|
|
156
138
|
type: r,
|
|
157
139
|
key: l,
|
|
158
|
-
props:
|
|
159
|
-
_owner:
|
|
140
|
+
props: v,
|
|
141
|
+
_owner: _
|
|
160
142
|
}, (d !== void 0 ? d : null) !== null ? Object.defineProperty(r, "ref", {
|
|
161
143
|
enumerable: !1,
|
|
162
144
|
get: f
|
|
@@ -182,13 +164,13 @@ function We() {
|
|
|
182
164
|
value: Ee
|
|
183
165
|
}), Object.freeze && (Object.freeze(r.props), Object.freeze(r)), r;
|
|
184
166
|
}
|
|
185
|
-
function N(r, l, d,
|
|
167
|
+
function N(r, l, d, R, _, v, de, Ee) {
|
|
186
168
|
var k = l.children;
|
|
187
169
|
if (k !== void 0)
|
|
188
|
-
if (
|
|
170
|
+
if (R)
|
|
189
171
|
if (fe(k)) {
|
|
190
|
-
for (
|
|
191
|
-
p(k[
|
|
172
|
+
for (R = 0; R < k.length; R++)
|
|
173
|
+
p(k[R]);
|
|
192
174
|
Object.freeze && Object.freeze(k);
|
|
193
175
|
} else
|
|
194
176
|
console.error(
|
|
@@ -197,21 +179,21 @@ function We() {
|
|
|
197
179
|
else p(k);
|
|
198
180
|
if (G.call(l, "key")) {
|
|
199
181
|
k = e(r);
|
|
200
|
-
var P = Object.keys(l).filter(function(
|
|
201
|
-
return
|
|
182
|
+
var P = Object.keys(l).filter(function(De) {
|
|
183
|
+
return De !== "key";
|
|
202
184
|
});
|
|
203
|
-
|
|
185
|
+
R = 0 < P.length ? "{key: someKey, " + P.join(": ..., ") + ": ...}" : "{key: someKey}", h[k + R] || (P = 0 < P.length ? "{" + P.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
204
186
|
`A props object containing a "key" prop is being spread into JSX:
|
|
205
187
|
let props = %s;
|
|
206
188
|
<%s {...props} />
|
|
207
189
|
React keys must be passed directly to JSX without using spread:
|
|
208
190
|
let props = %s;
|
|
209
191
|
<%s key={someKey} {...props} />`,
|
|
210
|
-
|
|
192
|
+
R,
|
|
211
193
|
k,
|
|
212
194
|
P,
|
|
213
195
|
k
|
|
214
|
-
), h[k +
|
|
196
|
+
), h[k + R] = !0);
|
|
215
197
|
}
|
|
216
198
|
if (k = null, d !== void 0 && (n(d), k = "" + d), c(l) && (n(l.key), k = "" + l.key), "key" in l) {
|
|
217
199
|
d = {};
|
|
@@ -224,8 +206,8 @@ React keys must be passed directly to JSX without using spread:
|
|
|
224
206
|
), m(
|
|
225
207
|
r,
|
|
226
208
|
k,
|
|
227
|
-
|
|
228
|
-
|
|
209
|
+
v,
|
|
210
|
+
_,
|
|
229
211
|
o(),
|
|
230
212
|
d,
|
|
231
213
|
de,
|
|
@@ -235,58 +217,58 @@ React keys must be passed directly to JSX without using spread:
|
|
|
235
217
|
function p(r) {
|
|
236
218
|
typeof r == "object" && r !== null && r.$$typeof === j && r._store && (r._store.validated = 1);
|
|
237
219
|
}
|
|
238
|
-
var
|
|
220
|
+
var y = A, j = Symbol.for("react.transitional.element"), b = Symbol.for("react.portal"), O = Symbol.for("react.fragment"), le = Symbol.for("react.strict_mode"), F = Symbol.for("react.profiler"), W = Symbol.for("react.consumer"), K = Symbol.for("react.context"), ue = Symbol.for("react.forward_ref"), ae = Symbol.for("react.suspense"), U = Symbol.for("react.suspense_list"), w = Symbol.for("react.memo"), I = Symbol.for("react.lazy"), z = Symbol.for("react.activity"), V = Symbol.for("react.client.reference"), M = y.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, G = Object.prototype.hasOwnProperty, fe = Array.isArray, T = console.createTask ? console.createTask : function() {
|
|
239
221
|
return null;
|
|
240
222
|
};
|
|
241
|
-
|
|
223
|
+
y = {
|
|
242
224
|
react_stack_bottom_frame: function(r) {
|
|
243
225
|
return r();
|
|
244
226
|
}
|
|
245
227
|
};
|
|
246
|
-
var J, a = {},
|
|
247
|
-
|
|
228
|
+
var J, a = {}, g = y.react_stack_bottom_frame.bind(
|
|
229
|
+
y,
|
|
248
230
|
i
|
|
249
231
|
)(), E = T(s(i)), h = {};
|
|
250
|
-
|
|
251
|
-
var
|
|
232
|
+
L.Fragment = O, L.jsx = function(r, l, d, R, _) {
|
|
233
|
+
var v = 1e4 > M.recentlyCreatedOwnerStacks++;
|
|
252
234
|
return N(
|
|
253
235
|
r,
|
|
254
236
|
l,
|
|
255
237
|
d,
|
|
256
238
|
!1,
|
|
257
|
-
g,
|
|
258
239
|
R,
|
|
259
|
-
|
|
260
|
-
|
|
240
|
+
_,
|
|
241
|
+
v ? Error("react-stack-top-frame") : g,
|
|
242
|
+
v ? T(s(r)) : E
|
|
261
243
|
);
|
|
262
|
-
},
|
|
263
|
-
var
|
|
244
|
+
}, L.jsxs = function(r, l, d, R, _) {
|
|
245
|
+
var v = 1e4 > M.recentlyCreatedOwnerStacks++;
|
|
264
246
|
return N(
|
|
265
247
|
r,
|
|
266
248
|
l,
|
|
267
249
|
d,
|
|
268
250
|
!0,
|
|
269
|
-
g,
|
|
270
251
|
R,
|
|
271
|
-
|
|
272
|
-
|
|
252
|
+
_,
|
|
253
|
+
v ? Error("react-stack-top-frame") : g,
|
|
254
|
+
v ? T(s(r)) : E
|
|
273
255
|
);
|
|
274
256
|
};
|
|
275
|
-
})()),
|
|
257
|
+
})()), L;
|
|
276
258
|
}
|
|
277
259
|
var Ie;
|
|
278
260
|
function Ke() {
|
|
279
261
|
return Ie || (Ie = 1, process.env.NODE_ENV === "production" ? X.exports = Fe() : X.exports = We()), X.exports;
|
|
280
262
|
}
|
|
281
|
-
var
|
|
282
|
-
const
|
|
283
|
-
const
|
|
284
|
-
if (!
|
|
285
|
-
if (
|
|
286
|
-
const n =
|
|
287
|
-
s.selectNodeContents(
|
|
263
|
+
var C = Ke();
|
|
264
|
+
const Ce = (e) => {
|
|
265
|
+
const t = window.getSelection();
|
|
266
|
+
if (!t || !e) return { start: 0, end: 0 };
|
|
267
|
+
if (t.anchorNode && e.contains(t.anchorNode)) {
|
|
268
|
+
const n = t.getRangeAt(0), s = n.cloneRange();
|
|
269
|
+
s.selectNodeContents(e), s.setEnd(n.startContainer, n.startOffset);
|
|
288
270
|
const o = s.toString().length, i = n.cloneRange();
|
|
289
|
-
i.selectNodeContents(
|
|
271
|
+
i.selectNodeContents(e), i.setEnd(n.endContainer, n.endOffset);
|
|
290
272
|
const c = i.toString().length;
|
|
291
273
|
return { start: o, end: c };
|
|
292
274
|
} else
|
|
@@ -319,7 +301,7 @@ const ye = () => {
|
|
|
319
301
|
t.includes("bold") && (o = "bold"), t.includes("italic") && (i = "italic"), (t.includes("underline") || e === "link") && (c += "underline"), t.includes("strike") && (c += " line-through"), e !== "segment" && (s = "#1da1f2", e === "mention" && n.mentionColor ? s = n.mentionColor : e === "interest" && n.interestColor ? s = n.interestColor : e === "link" && n.linkColor && (s = n.linkColor));
|
|
320
302
|
let u = "";
|
|
321
303
|
return s && (u += `color: ${s}; `), o && (u += `font-weight: ${o}; `), i && (u += `font-style: ${i}; `), c && (u += `text-decoration: ${c}; `), u;
|
|
322
|
-
},
|
|
304
|
+
}, ye = (e, t, n) => {
|
|
323
305
|
if (t.length === 0)
|
|
324
306
|
return e;
|
|
325
307
|
let s = "", o = 0;
|
|
@@ -345,7 +327,7 @@ const ye = () => {
|
|
|
345
327
|
type: "link",
|
|
346
328
|
...n
|
|
347
329
|
} : null;
|
|
348
|
-
}, te = (e) => (e & ee) !== 0, Re = (e, t) => t ? e | ee : e & ~ee, re = 32, Xe = /^@[a-zA-Z0-9_'-]+$/, qe = `.,!?;()[]{}"'<>#`, ne = "@",
|
|
330
|
+
}, te = (e) => (e & ee) !== 0, Re = (e, t) => t ? e | ee : e & ~ee, re = 32, Xe = /^@[a-zA-Z0-9_'-]+$/, qe = `.,!?;()[]{}"'<>#`, ne = "@", Le = (e, t) => {
|
|
349
331
|
const n = ve(
|
|
350
332
|
e,
|
|
351
333
|
t,
|
|
@@ -356,7 +338,7 @@ const ye = () => {
|
|
|
356
338
|
type: "mention",
|
|
357
339
|
...n
|
|
358
340
|
} : null;
|
|
359
|
-
}, oe = (e) => (e & re) !== 0, _e = (e, t) => t ? e | re : e & ~re, B = 2, q = (e) => (e & B) !== 0, ke = (e, t) => t ? e | B : e & ~B,
|
|
341
|
+
}, oe = (e) => (e & re) !== 0, _e = (e, t) => t ? e | re : e & ~re, B = 2, q = (e) => (e & B) !== 0, ke = (e, t) => t ? e | B : e & ~B, D = 4, H = (e) => (e & D) !== 0, Se = (e, t) => t ? e | D : e & ~D, $ = 16, Z = (e) => (e & $) !== 0, be = (e, t) => t ? e | $ : e & ~$, Y = 8, Q = (e) => (e & Y) !== 0, we = (e, t) => t ? e | Y : e & ~Y, je = (e, t) => {
|
|
360
342
|
if (e === t) return null;
|
|
361
343
|
let n = 0;
|
|
362
344
|
for (; n < e.length && n < t.length && e[n] === t[n]; )
|
|
@@ -372,7 +354,7 @@ const ye = () => {
|
|
|
372
354
|
}, ge = (e, t, n, s) => {
|
|
373
355
|
let o = t;
|
|
374
356
|
for (; o < e.length; ) {
|
|
375
|
-
const c =
|
|
357
|
+
const c = S(e, o);
|
|
376
358
|
if (n(c))
|
|
377
359
|
e[o] = s(c, !1);
|
|
378
360
|
else
|
|
@@ -381,7 +363,7 @@ const ye = () => {
|
|
|
381
363
|
}
|
|
382
364
|
let i = t - 1;
|
|
383
365
|
for (; i >= 0; ) {
|
|
384
|
-
const c =
|
|
366
|
+
const c = S(e, i);
|
|
385
367
|
if (n(c))
|
|
386
368
|
e[i] = s(c, !1);
|
|
387
369
|
else
|
|
@@ -393,10 +375,10 @@ const ye = () => {
|
|
|
393
375
|
if (!t) return e;
|
|
394
376
|
const { position: s, deletedLength: o, insertedText: i } = t, c = i.length;
|
|
395
377
|
let u = [...e];
|
|
396
|
-
const f =
|
|
378
|
+
const f = S(u, s);
|
|
397
379
|
if (oe(f) ? u = ge(u, s, oe, _e) : ce(f) ? u = ge(u, s, ce, Ne) : te(f) && (u = ge(u, s, te, Re)), o > 0 && u.splice(s, o), c > 0) {
|
|
398
380
|
let m = 0;
|
|
399
|
-
n.bold && (m = ke(m, !0)), n.italic && (m =
|
|
381
|
+
n.bold && (m = ke(m, !0)), n.italic && (m = Se(m, !0)), n.underline && (m = we(m, !0)), n.strike && (m = be(m, !0));
|
|
400
382
|
const N = new Array(c).fill(m);
|
|
401
383
|
u.splice(s, 0, ...N);
|
|
402
384
|
}
|
|
@@ -446,21 +428,21 @@ const ye = () => {
|
|
|
446
428
|
const s = [];
|
|
447
429
|
let o = 0;
|
|
448
430
|
for (; o < t.length; ) {
|
|
449
|
-
const i =
|
|
431
|
+
const i = S(t, o);
|
|
450
432
|
if (i === 0 || i === 1) {
|
|
451
433
|
o++;
|
|
452
434
|
continue;
|
|
453
435
|
}
|
|
454
436
|
const c = o;
|
|
455
437
|
let u = o;
|
|
456
|
-
for (; u + 1 < t.length &&
|
|
438
|
+
for (; u + 1 < t.length && S(t, u + 1) === i; )
|
|
457
439
|
u++;
|
|
458
440
|
const f = rt(i, n), m = nt(i), N = {
|
|
459
441
|
type: f,
|
|
460
442
|
startIndex: c,
|
|
461
443
|
endIndex: u + 1,
|
|
462
444
|
marks: m,
|
|
463
|
-
username: f === "mention" ?
|
|
445
|
+
username: f === "mention" ? Le(e, u)?.search.replace(ne, "") : void 0,
|
|
464
446
|
interest: f === "interest" ? Be(e, u)?.search.replace(
|
|
465
447
|
ie,
|
|
466
448
|
""
|
|
@@ -470,14 +452,14 @@ const ye = () => {
|
|
|
470
452
|
s.push(N), o = u + 1;
|
|
471
453
|
}
|
|
472
454
|
return s;
|
|
473
|
-
}, rt = (e, t) => e & re && t.mentions ? "mention" : e & se && t.interests ? "interest" : e & ee && t.links ? "link" : (e & (B |
|
|
455
|
+
}, rt = (e, t) => e & re && t.mentions ? "mention" : e & se && t.interests ? "interest" : e & ee && t.links ? "link" : (e & (B | D | Y | $), "segment"), nt = (e) => {
|
|
474
456
|
const t = [];
|
|
475
|
-
return e & B && t.push("bold"), e &
|
|
476
|
-
},
|
|
457
|
+
return e & B && t.push("bold"), e & D && t.push("italic"), e & Y && t.push("underline"), e & $ && t.push("strike"), t;
|
|
458
|
+
}, S = (e, t) => {
|
|
477
459
|
const n = e[t];
|
|
478
460
|
return typeof n != "number" ? 0 : n;
|
|
479
461
|
}, ot = (e, t, n) => {
|
|
480
|
-
const s =
|
|
462
|
+
const s = S(e, t);
|
|
481
463
|
switch (n) {
|
|
482
464
|
case "mention":
|
|
483
465
|
return _e(s, !0);
|
|
@@ -488,26 +470,26 @@ const ye = () => {
|
|
|
488
470
|
}
|
|
489
471
|
return s;
|
|
490
472
|
}, st = (e, t, n, s) => {
|
|
491
|
-
let o =
|
|
473
|
+
let o = S(e, t);
|
|
492
474
|
switch (n) {
|
|
493
475
|
case "bold":
|
|
494
476
|
o = ke(o, s);
|
|
495
477
|
break;
|
|
496
478
|
case "italic":
|
|
497
|
-
o =
|
|
479
|
+
o = Se(o, s);
|
|
498
480
|
break;
|
|
499
481
|
case "underline":
|
|
500
482
|
o = we(o, s);
|
|
501
483
|
break;
|
|
502
484
|
case "strike":
|
|
503
|
-
o =
|
|
485
|
+
o = be(o, s);
|
|
504
486
|
break;
|
|
505
487
|
default:
|
|
506
488
|
return e;
|
|
507
489
|
}
|
|
508
490
|
return e[t] = o, e;
|
|
509
491
|
}, it = (e, t, n) => {
|
|
510
|
-
const s =
|
|
492
|
+
const s = S(e, t);
|
|
511
493
|
switch (n) {
|
|
512
494
|
case "bold":
|
|
513
495
|
return q(s);
|
|
@@ -526,9 +508,9 @@ const ye = () => {
|
|
|
526
508
|
return !0;
|
|
527
509
|
}, pe = (e) => oe(e) || ce(e) || te(e), lt = (e, t, n, s) => {
|
|
528
510
|
let o = [...e];
|
|
529
|
-
for (; pe(
|
|
511
|
+
for (; pe(S(e, t - 1)) && t > 0; )
|
|
530
512
|
t--;
|
|
531
|
-
for (; pe(
|
|
513
|
+
for (; pe(S(e, n)) && n < e.length; )
|
|
532
514
|
n++;
|
|
533
515
|
let i = !0;
|
|
534
516
|
ct(t, n, s, o) && (i = !1);
|
|
@@ -543,7 +525,7 @@ const ye = () => {
|
|
|
543
525
|
if (i) {
|
|
544
526
|
i.type === "mention" ? o = _e(o, !0) : i.type === "interest" ? o = Ne(o, !0) : i.type === "link" && (o = Re(o, !0));
|
|
545
527
|
for (const c of i.marks)
|
|
546
|
-
c === "bold" ? o = ke(o, !0) : c === "italic" ? o =
|
|
528
|
+
c === "bold" ? o = ke(o, !0) : c === "italic" ? o = Se(o, !0) : c === "underline" ? o = we(o, !0) : c === "strike" && (o = be(o, !0));
|
|
547
529
|
}
|
|
548
530
|
n[s] = o;
|
|
549
531
|
}
|
|
@@ -568,21 +550,21 @@ const ye = () => {
|
|
|
568
550
|
options: m = {},
|
|
569
551
|
entityStyles: N = {},
|
|
570
552
|
placeholder: p = "",
|
|
571
|
-
debug:
|
|
553
|
+
debug: y = !1,
|
|
572
554
|
...j
|
|
573
555
|
}) => {
|
|
574
|
-
const
|
|
556
|
+
const b = A.useRef(null), [O, le] = A.useState({ start: 0, end: 0 }), [F, W] = A.useState(!1), [K, ue] = A.useState(!1), [ae, U] = A.useState(!1), [w, I] = A.useState(
|
|
575
557
|
Me(t, s)
|
|
576
558
|
);
|
|
577
559
|
e.current = {
|
|
578
|
-
selectEntity: (a,
|
|
579
|
-
if (!
|
|
580
|
-
let r = [...
|
|
560
|
+
selectEntity: (a, g, E, h) => {
|
|
561
|
+
if (!b.current) return;
|
|
562
|
+
let r = [...w];
|
|
581
563
|
a === "mention" ? h = ne + h : a === "interest" ? h = ie + h : a === "link" && (h = Te + h);
|
|
582
|
-
const l = t.slice(0,
|
|
583
|
-
d ? r = Pe(
|
|
584
|
-
for (let
|
|
585
|
-
r[
|
|
564
|
+
const l = t.slice(0, g) + h + t.slice(E), d = je(t, l);
|
|
565
|
+
d ? r = Pe(w, d, i) : r = Me(l, s);
|
|
566
|
+
for (let R = g; R < g + h.length; R++)
|
|
567
|
+
r[R] = ot(r, R, a);
|
|
586
568
|
n(l), I(r), f(null);
|
|
587
569
|
},
|
|
588
570
|
toggleMark: (a) => {
|
|
@@ -592,33 +574,33 @@ const ye = () => {
|
|
|
592
574
|
n(""), I([]), o([]);
|
|
593
575
|
}
|
|
594
576
|
}, A.useEffect(() => {
|
|
595
|
-
if (
|
|
596
|
-
|
|
597
|
-
const a =
|
|
598
|
-
|
|
577
|
+
if (b.current) {
|
|
578
|
+
b.current.textContent = t;
|
|
579
|
+
const a = ye(t, s, N);
|
|
580
|
+
b.current.innerHTML = a, K || ue(!0);
|
|
599
581
|
}
|
|
600
582
|
}, []), A.useEffect(() => {
|
|
601
|
-
if (!
|
|
602
|
-
const a = tt(t,
|
|
603
|
-
|
|
604
|
-
}, [
|
|
583
|
+
if (!b.current) return;
|
|
584
|
+
const a = tt(t, w, m), g = Ce(b.current) ?? O, E = ye(t, a, N);
|
|
585
|
+
b.current.innerHTML = E, o(a), K && Ue(b.current, g);
|
|
586
|
+
}, [w]);
|
|
605
587
|
const z = ut(O, 500);
|
|
606
588
|
A.useEffect(() => {
|
|
607
|
-
let { start: a, end:
|
|
608
|
-
if (!E && !oe(
|
|
589
|
+
let { start: a, end: g } = z, E = null;
|
|
590
|
+
if (!E && !oe(S(w, a - 1)) && (E = Le(t, a), E && (E.search = E.search.replace(ne, ""))), !E && !ce(S(w, a - 1)) && (E = Be(t, a), E && (E.search = E.search.replace(ie, ""))), !E && !te(S(w, a - 1)) && (E = xe(t, a)), E ? f(E) : u && f(null), F) return;
|
|
609
591
|
let h = !0, r = !0, l = !0, d = !0;
|
|
610
|
-
if (a ===
|
|
592
|
+
if (a === g)
|
|
611
593
|
if (a > 0) {
|
|
612
|
-
const
|
|
613
|
-
h = q(
|
|
594
|
+
const _ = S(w, a - 1);
|
|
595
|
+
h = q(_), r = H(_), l = Q(_), d = Z(_);
|
|
614
596
|
} else {
|
|
615
|
-
const
|
|
616
|
-
h = q(
|
|
597
|
+
const _ = S(w, a);
|
|
598
|
+
h = q(_), r = H(_), l = Q(_), d = Z(_);
|
|
617
599
|
}
|
|
618
600
|
else
|
|
619
|
-
for (let
|
|
620
|
-
const
|
|
621
|
-
h = q(
|
|
601
|
+
for (let _ = a; _ < g; _++) {
|
|
602
|
+
const v = S(w, _);
|
|
603
|
+
h = q(v) ? h : !1, r = H(v) ? r : !1, l = Q(v) ? l : !1, d = Z(v) ? d : !1;
|
|
622
604
|
}
|
|
623
605
|
c({
|
|
624
606
|
bold: h,
|
|
@@ -628,33 +610,33 @@ const ye = () => {
|
|
|
628
610
|
});
|
|
629
611
|
}, [z]);
|
|
630
612
|
const V = (a) => {
|
|
631
|
-
if (W(!0), !
|
|
613
|
+
if (W(!0), !b.current)
|
|
632
614
|
return;
|
|
633
|
-
const { start:
|
|
634
|
-
if (
|
|
635
|
-
const r = lt(
|
|
615
|
+
const { start: g, end: E } = O;
|
|
616
|
+
if (g !== E) {
|
|
617
|
+
const r = lt(w, g, E, a);
|
|
636
618
|
I(r);
|
|
637
619
|
}
|
|
638
620
|
const h = { ...i };
|
|
639
621
|
a === "bold" ? h.bold = !i.bold : a === "italic" ? h.italic = !i.italic : a === "underline" ? h.underline = !i.underline : a === "strike" && (h.strike = !i.strike), c(h);
|
|
640
622
|
}, M = (a) => {
|
|
641
|
-
if (!
|
|
623
|
+
if (!b.current) return;
|
|
642
624
|
if (F && W(!1), a.target.textContent.length === 0) {
|
|
643
625
|
n(""), I([]), o([]);
|
|
644
626
|
return;
|
|
645
627
|
}
|
|
646
|
-
const
|
|
628
|
+
const g = a.target.innerText || "", E = je(t, g);
|
|
647
629
|
if (E) {
|
|
648
630
|
const h = Pe(
|
|
649
|
-
|
|
631
|
+
w,
|
|
650
632
|
E,
|
|
651
633
|
i
|
|
652
634
|
);
|
|
653
635
|
I(h);
|
|
654
636
|
}
|
|
655
|
-
n(
|
|
637
|
+
n(g);
|
|
656
638
|
}, G = (a) => {
|
|
657
|
-
|
|
639
|
+
b.current && Ve(a, V);
|
|
658
640
|
}, fe = () => {
|
|
659
641
|
U(!0);
|
|
660
642
|
}, T = () => {
|
|
@@ -662,21 +644,20 @@ const ye = () => {
|
|
|
662
644
|
};
|
|
663
645
|
A.useEffect(() => {
|
|
664
646
|
const a = () => {
|
|
665
|
-
const
|
|
666
|
-
(
|
|
647
|
+
const g = Ce(b.current);
|
|
648
|
+
g && (g.start !== O.start || g.end !== O.end) && le(g);
|
|
667
649
|
};
|
|
668
650
|
return document.addEventListener("selectionchange", a), () => {
|
|
669
651
|
document.removeEventListener("selectionchange", a);
|
|
670
652
|
};
|
|
671
653
|
}, []);
|
|
672
654
|
const J = t.length === 0 && p && !ae;
|
|
673
|
-
return /* @__PURE__ */
|
|
674
|
-
/* @__PURE__ */
|
|
675
|
-
/* @__PURE__ */
|
|
655
|
+
return /* @__PURE__ */ C.jsxs(C.Fragment, { children: [
|
|
656
|
+
/* @__PURE__ */ C.jsxs("div", { style: { position: "relative" }, children: [
|
|
657
|
+
/* @__PURE__ */ C.jsx(
|
|
676
658
|
"div",
|
|
677
659
|
{
|
|
678
|
-
|
|
679
|
-
ref: v,
|
|
660
|
+
ref: b,
|
|
680
661
|
style: { ...j.style, position: "relative", zIndex: 2 },
|
|
681
662
|
className: j.className,
|
|
682
663
|
contentEditable: !0,
|
|
@@ -688,7 +669,7 @@ const ye = () => {
|
|
|
688
669
|
"aria-multiline": "true"
|
|
689
670
|
}
|
|
690
671
|
),
|
|
691
|
-
J && /* @__PURE__ */
|
|
672
|
+
J && /* @__PURE__ */ C.jsx(
|
|
692
673
|
"div",
|
|
693
674
|
{
|
|
694
675
|
style: {
|
|
@@ -701,11 +682,11 @@ const ye = () => {
|
|
|
701
682
|
color: "#9ca3af"
|
|
702
683
|
},
|
|
703
684
|
"aria-hidden": "true",
|
|
704
|
-
children: /* @__PURE__ */
|
|
685
|
+
children: /* @__PURE__ */ C.jsx("p", { children: p })
|
|
705
686
|
}
|
|
706
687
|
)
|
|
707
688
|
] }),
|
|
708
|
-
|
|
689
|
+
y && /* @__PURE__ */ C.jsx("div", { style: {}, children: /* @__PURE__ */ C.jsx("pre", { children: JSON.stringify(w) }) })
|
|
709
690
|
] });
|
|
710
691
|
};
|
|
711
692
|
export {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Entity, SelectionRange, StyleOptions } from '../interfaces';
|
|
2
|
-
export declare const getSelection: () => SelectionRange | null;
|
|
2
|
+
export declare const getSelection: (editableDiv: HTMLElement | null) => SelectionRange | null;
|
|
3
3
|
export declare const setSelection: (div: HTMLDivElement, selectionRange: SelectionRange) => void;
|
|
4
4
|
export declare const buildHtml: (plainText: string, entities: Entity[], styles: StyleOptions) => string;
|