@connectedxm/entity-editor 0.0.10 → 0.0.12
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 +62 -65
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import a from "react";
|
|
2
2
|
var ue = { exports: {} }, Z = {};
|
|
3
|
-
var
|
|
3
|
+
var Me;
|
|
4
4
|
function Ze() {
|
|
5
|
-
if (
|
|
6
|
-
|
|
5
|
+
if (Me) return Z;
|
|
6
|
+
Me = 1;
|
|
7
7
|
var e = /* @__PURE__ */ Symbol.for("react.transitional.element"), t = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
8
8
|
function s(o, r, c) {
|
|
9
9
|
var i = null;
|
|
@@ -169,7 +169,7 @@ function Qe() {
|
|
|
169
169
|
var k = l.children;
|
|
170
170
|
if (k !== void 0)
|
|
171
171
|
if (S)
|
|
172
|
-
if (
|
|
172
|
+
if (L(k)) {
|
|
173
173
|
for (S = 0; S < k.length; S++)
|
|
174
174
|
se(k[S]);
|
|
175
175
|
Object.freeze && Object.freeze(k);
|
|
@@ -219,7 +219,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
219
219
|
function W(n) {
|
|
220
220
|
return typeof n == "object" && n !== null && n.$$typeof === v;
|
|
221
221
|
}
|
|
222
|
-
var w = a, v = /* @__PURE__ */ Symbol.for("react.transitional.element"), D = /* @__PURE__ */ Symbol.for("react.portal"), O = /* @__PURE__ */ Symbol.for("react.fragment"), oe = /* @__PURE__ */ Symbol.for("react.strict_mode"), T = /* @__PURE__ */ Symbol.for("react.profiler"), z = /* @__PURE__ */ Symbol.for("react.consumer"), ce = /* @__PURE__ */ Symbol.for("react.context"), be = /* @__PURE__ */ Symbol.for("react.forward_ref"), P = /* @__PURE__ */ Symbol.for("react.suspense"), V = /* @__PURE__ */ Symbol.for("react.suspense_list"), X = /* @__PURE__ */ Symbol.for("react.memo"), q = /* @__PURE__ */ Symbol.for("react.lazy"), we = /* @__PURE__ */ Symbol.for("react.activity"), ie = /* @__PURE__ */ Symbol.for("react.client.reference"), x = w.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, j = Object.prototype.hasOwnProperty,
|
|
222
|
+
var w = a, v = /* @__PURE__ */ Symbol.for("react.transitional.element"), D = /* @__PURE__ */ Symbol.for("react.portal"), O = /* @__PURE__ */ Symbol.for("react.fragment"), oe = /* @__PURE__ */ Symbol.for("react.strict_mode"), T = /* @__PURE__ */ Symbol.for("react.profiler"), z = /* @__PURE__ */ Symbol.for("react.consumer"), ce = /* @__PURE__ */ Symbol.for("react.context"), be = /* @__PURE__ */ Symbol.for("react.forward_ref"), P = /* @__PURE__ */ Symbol.for("react.suspense"), V = /* @__PURE__ */ Symbol.for("react.suspense_list"), X = /* @__PURE__ */ Symbol.for("react.memo"), q = /* @__PURE__ */ Symbol.for("react.lazy"), we = /* @__PURE__ */ Symbol.for("react.activity"), ie = /* @__PURE__ */ Symbol.for("react.client.reference"), x = w.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, j = Object.prototype.hasOwnProperty, L = Array.isArray, Y = console.createTask ? console.createTask : function() {
|
|
223
223
|
return null;
|
|
224
224
|
};
|
|
225
225
|
w = {
|
|
@@ -230,7 +230,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
230
230
|
var G, H = {}, J = w.react_stack_bottom_frame.bind(
|
|
231
231
|
w,
|
|
232
232
|
c
|
|
233
|
-
)(),
|
|
233
|
+
)(), M = Y(o(c)), $ = {};
|
|
234
234
|
Q.Fragment = O, Q.jsx = function(n, l, m) {
|
|
235
235
|
var S = 1e4 > x.recentlyCreatedOwnerStacks++;
|
|
236
236
|
return y(
|
|
@@ -239,7 +239,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
239
239
|
m,
|
|
240
240
|
!1,
|
|
241
241
|
S ? Error("react-stack-top-frame") : J,
|
|
242
|
-
S ? Y(o(n)) :
|
|
242
|
+
S ? Y(o(n)) : M
|
|
243
243
|
);
|
|
244
244
|
}, Q.jsxs = function(n, l, m) {
|
|
245
245
|
var S = 1e4 > x.recentlyCreatedOwnerStacks++;
|
|
@@ -249,7 +249,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
249
249
|
m,
|
|
250
250
|
!0,
|
|
251
251
|
S ? Error("react-stack-top-frame") : J,
|
|
252
|
-
S ? Y(o(n)) :
|
|
252
|
+
S ? Y(o(n)) : M
|
|
253
253
|
);
|
|
254
254
|
};
|
|
255
255
|
})()), Q;
|
|
@@ -322,7 +322,7 @@ const De = (e) => {
|
|
|
322
322
|
We
|
|
323
323
|
);
|
|
324
324
|
return s?.search.match(ot) ? s : null;
|
|
325
|
-
}, me = (e) => (e & he) !== 0,
|
|
325
|
+
}, me = (e) => (e & he) !== 0, pe = (e, t) => t ? e | he : e & ~he, Re = 32, ct = /^@[a-zA-Z0-9_'-]+$/, it = `.,!?;()[]{}"'<>#`, ge = "@", Ve = (e, t) => {
|
|
326
326
|
const s = je(
|
|
327
327
|
e,
|
|
328
328
|
t,
|
|
@@ -349,7 +349,7 @@ const De = (e) => {
|
|
|
349
349
|
}, xe = (e, t, s, o) => {
|
|
350
350
|
let r = t;
|
|
351
351
|
for (; r < e.length; ) {
|
|
352
|
-
const i =
|
|
352
|
+
const i = A(e, r);
|
|
353
353
|
if (s(i))
|
|
354
354
|
e[r] = o(i, !1);
|
|
355
355
|
else
|
|
@@ -358,7 +358,7 @@ const De = (e) => {
|
|
|
358
358
|
}
|
|
359
359
|
let c = t - 1;
|
|
360
360
|
for (; c >= 0; ) {
|
|
361
|
-
const i =
|
|
361
|
+
const i = A(e, c);
|
|
362
362
|
if (s(i))
|
|
363
363
|
e[c] = o(i, !1);
|
|
364
364
|
else
|
|
@@ -370,8 +370,8 @@ const De = (e) => {
|
|
|
370
370
|
if (!t) return e;
|
|
371
371
|
const { position: o, deletedLength: r, insertedText: c } = t, i = c.length;
|
|
372
372
|
let u = [...e];
|
|
373
|
-
const f =
|
|
374
|
-
if (ke(f) ? u = xe(u, o, ke, ye) : Ie(f) ? u = xe(u, o, Ie,
|
|
373
|
+
const f = A(u, o);
|
|
374
|
+
if (ke(f) ? u = xe(u, o, ke, ye) : Ie(f) ? u = xe(u, o, Ie, Le) : me(f) && (u = xe(u, o, me, pe)), r > 0 && u.splice(o, r), i > 0) {
|
|
375
375
|
let R = 0;
|
|
376
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(i).fill(R);
|
|
@@ -406,7 +406,7 @@ const De = (e) => {
|
|
|
406
406
|
startIndex: c,
|
|
407
407
|
endIndex: i
|
|
408
408
|
};
|
|
409
|
-
}, _e = 64, ut = `.,!?;()[]{}"'<>@`, at = /^#[
|
|
409
|
+
}, _e = 64, ut = `.,!?;()[]{}"'<>@`, at = /^#[a-zA-Z0-9-]+$/, Se = "#", Je = (e, t) => {
|
|
410
410
|
const s = je(
|
|
411
411
|
e,
|
|
412
412
|
t,
|
|
@@ -414,20 +414,20 @@ const De = (e) => {
|
|
|
414
414
|
Se
|
|
415
415
|
);
|
|
416
416
|
return s?.search.match(at) ? s : null;
|
|
417
|
-
}, Ie = (e) => (e & _e) !== 0,
|
|
417
|
+
}, Ie = (e) => (e & _e) !== 0, Le = (e, t) => t ? e | _e : e & ~_e, ft = (e, t) => e.find(
|
|
418
418
|
(s) => s.startIndex <= t && s.endIndex > t
|
|
419
419
|
), dt = (e, t, s) => {
|
|
420
420
|
const o = [];
|
|
421
421
|
let r = 0;
|
|
422
422
|
for (; r < t.length; ) {
|
|
423
|
-
const c =
|
|
423
|
+
const c = A(t, r);
|
|
424
424
|
if (c === 0 || c === 1) {
|
|
425
425
|
r++;
|
|
426
426
|
continue;
|
|
427
427
|
}
|
|
428
428
|
const i = r;
|
|
429
429
|
let u = r;
|
|
430
|
-
for (; u + 1 < t.length &&
|
|
430
|
+
for (; u + 1 < t.length && A(t, u + 1) === c; )
|
|
431
431
|
u++;
|
|
432
432
|
const f = Et(c, s), R = ht(c), y = {
|
|
433
433
|
type: f,
|
|
@@ -435,10 +435,7 @@ const De = (e) => {
|
|
|
435
435
|
endIndex: u + 1,
|
|
436
436
|
marks: R,
|
|
437
437
|
username: f === "mention" ? Ve(e, u)?.search.replace(ge, "") : void 0,
|
|
438
|
-
interest: f === "interest" ? Je(e, u)?.search.replace(
|
|
439
|
-
Se,
|
|
440
|
-
""
|
|
441
|
-
) : void 0,
|
|
438
|
+
interest: f === "interest" ? Je(e, u)?.search.replace(Se, "").toLowerCase() : void 0,
|
|
442
439
|
href: f === "link" ? ze(e, u)?.search : void 0
|
|
443
440
|
};
|
|
444
441
|
o.push(y), r = u + 1;
|
|
@@ -447,22 +444,22 @@ const De = (e) => {
|
|
|
447
444
|
}, Et = (e, t) => e & Re && t.mentions ? "mention" : e & _e && t.interests ? "interest" : e & he && t.links ? "link" : (e & (ee | te | re | ne), "segment"), ht = (e) => {
|
|
448
445
|
const t = [];
|
|
449
446
|
return e & ee && t.push("bold"), e & te && t.push("italic"), e & re && t.push("underline"), e & ne && t.push("strike"), t;
|
|
450
|
-
},
|
|
447
|
+
}, A = (e, t) => {
|
|
451
448
|
const s = e[t];
|
|
452
449
|
return typeof s != "number" ? 0 : s;
|
|
453
450
|
}, Ne = (e, t, s) => {
|
|
454
|
-
const o =
|
|
451
|
+
const o = A(e, t);
|
|
455
452
|
switch (s) {
|
|
456
453
|
case "mention":
|
|
457
454
|
return ye(o, !0);
|
|
458
455
|
case "interest":
|
|
459
|
-
return
|
|
456
|
+
return Le(o, !0);
|
|
460
457
|
case "link":
|
|
461
|
-
return
|
|
458
|
+
return pe(o, !0);
|
|
462
459
|
}
|
|
463
460
|
return o;
|
|
464
461
|
}, mt = (e, t, s, o) => {
|
|
465
|
-
let r =
|
|
462
|
+
let r = A(e, t);
|
|
466
463
|
switch (s) {
|
|
467
464
|
case "bold":
|
|
468
465
|
r = Oe(r, o);
|
|
@@ -481,7 +478,7 @@ const De = (e) => {
|
|
|
481
478
|
}
|
|
482
479
|
return e[t] = r, e;
|
|
483
480
|
}, Rt = (e, t, s) => {
|
|
484
|
-
const o =
|
|
481
|
+
const o = A(e, t);
|
|
485
482
|
switch (s) {
|
|
486
483
|
case "bold":
|
|
487
484
|
return ae(o);
|
|
@@ -500,22 +497,22 @@ const De = (e) => {
|
|
|
500
497
|
return !0;
|
|
501
498
|
}, Ue = (e) => ke(e) || Ie(e) || me(e), kt = (e, t, s, o) => {
|
|
502
499
|
let r = [...e];
|
|
503
|
-
for (; Ue(
|
|
500
|
+
for (; Ue(A(e, t - 1)) && t > 0; )
|
|
504
501
|
t--;
|
|
505
|
-
for (; Ue(
|
|
502
|
+
for (; Ue(A(e, s)) && s < e.length; )
|
|
506
503
|
s++;
|
|
507
504
|
let c = !0;
|
|
508
505
|
gt(t, s, o, r) && (c = !1);
|
|
509
506
|
for (let i = t; i < s; i++)
|
|
510
507
|
r = mt(r, i, o, c);
|
|
511
508
|
return r;
|
|
512
|
-
},
|
|
509
|
+
}, Ae = (e, t) => {
|
|
513
510
|
const s = new Array(e.length).fill(0);
|
|
514
511
|
for (let o = 0; o < e.length; o++) {
|
|
515
512
|
let r = 0;
|
|
516
513
|
const c = ft(t, o);
|
|
517
514
|
if (c) {
|
|
518
|
-
c.type === "mention" ? r = ye(r, !0) : c.type === "interest" ? r =
|
|
515
|
+
c.type === "mention" ? r = ye(r, !0) : c.type === "interest" ? r = Le(r, !0) : c.type === "link" && (r = pe(r, !0));
|
|
519
516
|
for (const i of c.marks)
|
|
520
517
|
i === "bold" ? r = Oe(r, !0) : i === "italic" ? r = Te(r, !0) : i === "underline" ? r = Pe(r, !0) : i === "strike" && (r = Ce(r, !0));
|
|
521
518
|
}
|
|
@@ -543,8 +540,8 @@ const De = (e) => {
|
|
|
543
540
|
underline: !1,
|
|
544
541
|
strike: !1
|
|
545
542
|
}), [T, z] = a.useState(null), [ce, be] = a.useState({ start: 0, end: 0 }), [P, V] = a.useState(!1), [X, q] = a.useState(!1), [we, ie] = a.useState(!1), [x, j] = a.useState(
|
|
546
|
-
|
|
547
|
-
),
|
|
543
|
+
Ae(t, s)
|
|
544
|
+
), L = a.useMemo(() => dt(v, x, f), [v, x, f]), Y = a.useRef(o), G = a.useRef(r), H = a.useRef(P), J = a.useRef(!1), M = a.useRef({
|
|
548
545
|
start: 0,
|
|
549
546
|
end: 0
|
|
550
547
|
}), $ = a.useRef(null), n = a.useRef(!1), l = a.useRef(null), m = a.useRef(!1), S = a.useRef(null), F = a.useRef(null), K = a.useRef(c), k = a.useRef(i), C = a.useRef(u);
|
|
@@ -577,7 +574,7 @@ const De = (e) => {
|
|
|
577
574
|
(h) => {
|
|
578
575
|
if (V(!0), !w.current)
|
|
579
576
|
return;
|
|
580
|
-
const { start: I, end: b } =
|
|
577
|
+
const { start: I, end: b } = M.current;
|
|
581
578
|
if (I !== b) {
|
|
582
579
|
const d = kt(x, I, b, h);
|
|
583
580
|
j(d);
|
|
@@ -596,12 +593,12 @@ const De = (e) => {
|
|
|
596
593
|
if (!w.current) return;
|
|
597
594
|
let g = [...x];
|
|
598
595
|
h === "mention" ? d = ge + d : h === "interest" ? d = Se + d : h === "link" && (d = We + d);
|
|
599
|
-
const E = v.slice(0, I) + d + v.slice(b),
|
|
600
|
-
|
|
596
|
+
const E = v.slice(0, I) + d + v.slice(b), p = Fe(v, E);
|
|
597
|
+
p ? g = Ke(x, p, O) : g = Ae(E, L);
|
|
601
598
|
for (let _ = I; _ < I + d.length; _++)
|
|
602
599
|
g[_] = Ne(g, _, h);
|
|
603
600
|
const N = I + d.length;
|
|
604
|
-
|
|
601
|
+
M.current = {
|
|
605
602
|
start: N,
|
|
606
603
|
end: N
|
|
607
604
|
}, m.current = !0, D(E), j(g), z(null);
|
|
@@ -611,39 +608,39 @@ const De = (e) => {
|
|
|
611
608
|
D(""), j([]);
|
|
612
609
|
},
|
|
613
610
|
reset: () => {
|
|
614
|
-
D(t), j(
|
|
611
|
+
D(t), j(Ae(t, s)), z(null);
|
|
615
612
|
},
|
|
616
613
|
focus: () => {
|
|
617
614
|
w.current?.focus();
|
|
618
615
|
},
|
|
619
616
|
getState: () => (C.current && C.current({
|
|
620
617
|
plainText: v,
|
|
621
|
-
entities:
|
|
618
|
+
entities: L,
|
|
622
619
|
markState: O
|
|
623
620
|
}), {
|
|
624
621
|
plainText: v,
|
|
625
|
-
entities:
|
|
622
|
+
entities: L,
|
|
626
623
|
markState: O
|
|
627
624
|
})
|
|
628
625
|
}),
|
|
629
|
-
[x, v,
|
|
626
|
+
[x, v, L, O, U]
|
|
630
627
|
), a.useEffect(() => {
|
|
631
628
|
if (w.current && !X) {
|
|
632
629
|
w.current.textContent = v;
|
|
633
|
-
const h = Ye(v,
|
|
630
|
+
const h = Ye(v, L, R);
|
|
634
631
|
w.current.innerHTML = h, q(!0);
|
|
635
632
|
}
|
|
636
633
|
}, []), a.useLayoutEffect(() => {
|
|
637
634
|
if (!w.current || !X) return;
|
|
638
|
-
const h = m.current ?
|
|
635
|
+
const h = m.current ? M.current : De(w.current) ?? M.current;
|
|
639
636
|
m.current = !1;
|
|
640
|
-
const I = Ye(v,
|
|
637
|
+
const I = Ye(v, L, R);
|
|
641
638
|
n.current = !0, w.current.innerHTML = I, tt(w.current, h), queueMicrotask(() => {
|
|
642
639
|
n.current = !1;
|
|
643
640
|
});
|
|
644
|
-
}, [
|
|
641
|
+
}, [L, R, X]), a.useEffect(() => {
|
|
645
642
|
let { start: h, end: I } = ce, b = null;
|
|
646
|
-
if (!ke(
|
|
643
|
+
if (f.mentions && !ke(A(x, h - 1))) {
|
|
647
644
|
const _ = Ve(v, h);
|
|
648
645
|
_ && (b = {
|
|
649
646
|
type: "mention",
|
|
@@ -653,25 +650,25 @@ const De = (e) => {
|
|
|
653
650
|
});
|
|
654
651
|
}
|
|
655
652
|
if (b ? (!T || b.startIndex !== T.startIndex || b.endIndex !== T.endIndex || b.search !== T.search) && z(b) : T && z(null), P) return;
|
|
656
|
-
let d = !0, g = !0, E = !0,
|
|
653
|
+
let d = !0, g = !0, E = !0, p = !0;
|
|
657
654
|
if (h === I)
|
|
658
655
|
if (h > 0) {
|
|
659
|
-
const _ =
|
|
660
|
-
d = ae(_), g = fe(_), E = Ee(_),
|
|
656
|
+
const _ = A(x, h - 1);
|
|
657
|
+
d = ae(_), g = fe(_), E = Ee(_), p = de(_);
|
|
661
658
|
} else {
|
|
662
|
-
const _ =
|
|
663
|
-
d = ae(_), g = fe(_), E = Ee(_),
|
|
659
|
+
const _ = A(x, h);
|
|
660
|
+
d = ae(_), g = fe(_), E = Ee(_), p = de(_);
|
|
664
661
|
}
|
|
665
662
|
else
|
|
666
663
|
for (let _ = h; _ < I; _++) {
|
|
667
|
-
const le =
|
|
668
|
-
d = ae(le) ? d : !1, g = fe(le) ? g : !1, E = Ee(le) ? E : !1,
|
|
664
|
+
const le = A(x, _);
|
|
665
|
+
d = ae(le) ? d : !1, g = fe(le) ? g : !1, E = Ee(le) ? E : !1, p = de(le) ? p : !1;
|
|
669
666
|
}
|
|
670
667
|
oe({
|
|
671
668
|
bold: d,
|
|
672
669
|
italic: g,
|
|
673
670
|
underline: E,
|
|
674
|
-
strike:
|
|
671
|
+
strike: p
|
|
675
672
|
});
|
|
676
673
|
}, [ce, x, v, P]);
|
|
677
674
|
const ve = (h) => {
|
|
@@ -685,14 +682,14 @@ const De = (e) => {
|
|
|
685
682
|
let d = Ke(x, b, O);
|
|
686
683
|
if (b.deletedLength === 0 && b.insertedText === " " && b.position > 0) {
|
|
687
684
|
const g = b.position;
|
|
688
|
-
if (!me(
|
|
685
|
+
if (f.links && !me(A(d, g - 1))) {
|
|
689
686
|
const E = ze(I, g);
|
|
690
687
|
if (E && E.endIndex === g) {
|
|
691
|
-
const
|
|
692
|
-
if (S.current !==
|
|
688
|
+
const p = `${E.startIndex}:${E.endIndex}:${E.search}`;
|
|
689
|
+
if (S.current !== p) {
|
|
693
690
|
for (let N = E.startIndex; N < E.endIndex; N++)
|
|
694
691
|
d[N] = Ne(d, N, "link");
|
|
695
|
-
if (S.current =
|
|
692
|
+
if (S.current = p, K.current) {
|
|
696
693
|
const N = {
|
|
697
694
|
type: "link",
|
|
698
695
|
startIndex: E.startIndex,
|
|
@@ -705,20 +702,20 @@ const De = (e) => {
|
|
|
705
702
|
}
|
|
706
703
|
}
|
|
707
704
|
}
|
|
708
|
-
if (!Ie(
|
|
705
|
+
if (f.interests && !Ie(A(d, g - 1))) {
|
|
709
706
|
const E = Je(I, g);
|
|
710
707
|
if (E && E.endIndex === g) {
|
|
711
|
-
const
|
|
712
|
-
if (F.current !==
|
|
708
|
+
const p = `${E.startIndex}:${E.endIndex}:${E.search}`;
|
|
709
|
+
if (F.current !== p) {
|
|
713
710
|
for (let N = E.startIndex; N < E.endIndex; N++)
|
|
714
711
|
d[N] = Ne(d, N, "interest");
|
|
715
|
-
if (F.current =
|
|
712
|
+
if (F.current = p, k.current) {
|
|
716
713
|
const N = {
|
|
717
714
|
type: "interest",
|
|
718
715
|
startIndex: E.startIndex,
|
|
719
716
|
endIndex: E.endIndex,
|
|
720
717
|
marks: [],
|
|
721
|
-
interest: E.search.replace(Se, "")
|
|
718
|
+
interest: E.search.replace(Se, "").toLowerCase()
|
|
722
719
|
};
|
|
723
720
|
k.current(N);
|
|
724
721
|
}
|
|
@@ -744,8 +741,8 @@ const De = (e) => {
|
|
|
744
741
|
const I = De(w.current) ?? {
|
|
745
742
|
start: 0,
|
|
746
743
|
end: 0
|
|
747
|
-
}, b =
|
|
748
|
-
(I.start !== b.start || I.end !== b.end) && (
|
|
744
|
+
}, b = M.current;
|
|
745
|
+
(I.start !== b.start || I.end !== b.end) && (M.current = I, H.current && !J.current && V(!1), $.current && clearTimeout($.current), $.current = setTimeout(() => {
|
|
749
746
|
be(I);
|
|
750
747
|
}, 500));
|
|
751
748
|
};
|