@connectedxm/entity-editor 0.0.11 → 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 +37 -37
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -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, Le) : me(f) && (u = xe(u, o, me,
|
|
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);
|
|
@@ -420,14 +420,14 @@ const De = (e) => {
|
|
|
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,
|
|
@@ -444,22 +444,22 @@ const De = (e) => {
|
|
|
444
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) => {
|
|
445
445
|
const t = [];
|
|
446
446
|
return e & ee && t.push("bold"), e & te && t.push("italic"), e & re && t.push("underline"), e & ne && t.push("strike"), t;
|
|
447
|
-
},
|
|
447
|
+
}, A = (e, t) => {
|
|
448
448
|
const s = e[t];
|
|
449
449
|
return typeof s != "number" ? 0 : s;
|
|
450
450
|
}, Ne = (e, t, s) => {
|
|
451
|
-
const o =
|
|
451
|
+
const o = A(e, t);
|
|
452
452
|
switch (s) {
|
|
453
453
|
case "mention":
|
|
454
454
|
return ye(o, !0);
|
|
455
455
|
case "interest":
|
|
456
456
|
return Le(o, !0);
|
|
457
457
|
case "link":
|
|
458
|
-
return
|
|
458
|
+
return pe(o, !0);
|
|
459
459
|
}
|
|
460
460
|
return o;
|
|
461
461
|
}, mt = (e, t, s, o) => {
|
|
462
|
-
let r =
|
|
462
|
+
let r = A(e, t);
|
|
463
463
|
switch (s) {
|
|
464
464
|
case "bold":
|
|
465
465
|
r = Oe(r, o);
|
|
@@ -478,7 +478,7 @@ const De = (e) => {
|
|
|
478
478
|
}
|
|
479
479
|
return e[t] = r, e;
|
|
480
480
|
}, Rt = (e, t, s) => {
|
|
481
|
-
const o =
|
|
481
|
+
const o = A(e, t);
|
|
482
482
|
switch (s) {
|
|
483
483
|
case "bold":
|
|
484
484
|
return ae(o);
|
|
@@ -497,22 +497,22 @@ const De = (e) => {
|
|
|
497
497
|
return !0;
|
|
498
498
|
}, Ue = (e) => ke(e) || Ie(e) || me(e), kt = (e, t, s, o) => {
|
|
499
499
|
let r = [...e];
|
|
500
|
-
for (; Ue(
|
|
500
|
+
for (; Ue(A(e, t - 1)) && t > 0; )
|
|
501
501
|
t--;
|
|
502
|
-
for (; Ue(
|
|
502
|
+
for (; Ue(A(e, s)) && s < e.length; )
|
|
503
503
|
s++;
|
|
504
504
|
let c = !0;
|
|
505
505
|
gt(t, s, o, r) && (c = !1);
|
|
506
506
|
for (let i = t; i < s; i++)
|
|
507
507
|
r = mt(r, i, o, c);
|
|
508
508
|
return r;
|
|
509
|
-
},
|
|
509
|
+
}, Ae = (e, t) => {
|
|
510
510
|
const s = new Array(e.length).fill(0);
|
|
511
511
|
for (let o = 0; o < e.length; o++) {
|
|
512
512
|
let r = 0;
|
|
513
513
|
const c = ft(t, o);
|
|
514
514
|
if (c) {
|
|
515
|
-
c.type === "mention" ? r = ye(r, !0) : c.type === "interest" ? r = Le(r, !0) : c.type === "link" && (r =
|
|
515
|
+
c.type === "mention" ? r = ye(r, !0) : c.type === "interest" ? r = Le(r, !0) : c.type === "link" && (r = pe(r, !0));
|
|
516
516
|
for (const i of c.marks)
|
|
517
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));
|
|
518
518
|
}
|
|
@@ -540,7 +540,7 @@ const De = (e) => {
|
|
|
540
540
|
underline: !1,
|
|
541
541
|
strike: !1
|
|
542
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(
|
|
543
|
-
|
|
543
|
+
Ae(t, s)
|
|
544
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({
|
|
545
545
|
start: 0,
|
|
546
546
|
end: 0
|
|
@@ -593,8 +593,8 @@ const De = (e) => {
|
|
|
593
593
|
if (!w.current) return;
|
|
594
594
|
let g = [...x];
|
|
595
595
|
h === "mention" ? d = ge + d : h === "interest" ? d = Se + d : h === "link" && (d = We + d);
|
|
596
|
-
const E = v.slice(0, I) + d + v.slice(b),
|
|
597
|
-
|
|
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);
|
|
598
598
|
for (let _ = I; _ < I + d.length; _++)
|
|
599
599
|
g[_] = Ne(g, _, h);
|
|
600
600
|
const N = I + d.length;
|
|
@@ -608,7 +608,7 @@ const De = (e) => {
|
|
|
608
608
|
D(""), j([]);
|
|
609
609
|
},
|
|
610
610
|
reset: () => {
|
|
611
|
-
D(t), j(
|
|
611
|
+
D(t), j(Ae(t, s)), z(null);
|
|
612
612
|
},
|
|
613
613
|
focus: () => {
|
|
614
614
|
w.current?.focus();
|
|
@@ -640,7 +640,7 @@ const De = (e) => {
|
|
|
640
640
|
});
|
|
641
641
|
}, [L, R, X]), a.useEffect(() => {
|
|
642
642
|
let { start: h, end: I } = ce, b = null;
|
|
643
|
-
if (!ke(
|
|
643
|
+
if (f.mentions && !ke(A(x, h - 1))) {
|
|
644
644
|
const _ = Ve(v, h);
|
|
645
645
|
_ && (b = {
|
|
646
646
|
type: "mention",
|
|
@@ -650,25 +650,25 @@ const De = (e) => {
|
|
|
650
650
|
});
|
|
651
651
|
}
|
|
652
652
|
if (b ? (!T || b.startIndex !== T.startIndex || b.endIndex !== T.endIndex || b.search !== T.search) && z(b) : T && z(null), P) return;
|
|
653
|
-
let d = !0, g = !0, E = !0,
|
|
653
|
+
let d = !0, g = !0, E = !0, p = !0;
|
|
654
654
|
if (h === I)
|
|
655
655
|
if (h > 0) {
|
|
656
|
-
const _ =
|
|
657
|
-
d = ae(_), g = fe(_), E = Ee(_),
|
|
656
|
+
const _ = A(x, h - 1);
|
|
657
|
+
d = ae(_), g = fe(_), E = Ee(_), p = de(_);
|
|
658
658
|
} else {
|
|
659
|
-
const _ =
|
|
660
|
-
d = ae(_), g = fe(_), E = Ee(_),
|
|
659
|
+
const _ = A(x, h);
|
|
660
|
+
d = ae(_), g = fe(_), E = Ee(_), p = de(_);
|
|
661
661
|
}
|
|
662
662
|
else
|
|
663
663
|
for (let _ = h; _ < I; _++) {
|
|
664
|
-
const le =
|
|
665
|
-
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;
|
|
666
666
|
}
|
|
667
667
|
oe({
|
|
668
668
|
bold: d,
|
|
669
669
|
italic: g,
|
|
670
670
|
underline: E,
|
|
671
|
-
strike:
|
|
671
|
+
strike: p
|
|
672
672
|
});
|
|
673
673
|
}, [ce, x, v, P]);
|
|
674
674
|
const ve = (h) => {
|
|
@@ -682,14 +682,14 @@ const De = (e) => {
|
|
|
682
682
|
let d = Ke(x, b, O);
|
|
683
683
|
if (b.deletedLength === 0 && b.insertedText === " " && b.position > 0) {
|
|
684
684
|
const g = b.position;
|
|
685
|
-
if (!me(
|
|
685
|
+
if (f.links && !me(A(d, g - 1))) {
|
|
686
686
|
const E = ze(I, g);
|
|
687
687
|
if (E && E.endIndex === g) {
|
|
688
|
-
const
|
|
689
|
-
if (S.current !==
|
|
688
|
+
const p = `${E.startIndex}:${E.endIndex}:${E.search}`;
|
|
689
|
+
if (S.current !== p) {
|
|
690
690
|
for (let N = E.startIndex; N < E.endIndex; N++)
|
|
691
691
|
d[N] = Ne(d, N, "link");
|
|
692
|
-
if (S.current =
|
|
692
|
+
if (S.current = p, K.current) {
|
|
693
693
|
const N = {
|
|
694
694
|
type: "link",
|
|
695
695
|
startIndex: E.startIndex,
|
|
@@ -702,14 +702,14 @@ const De = (e) => {
|
|
|
702
702
|
}
|
|
703
703
|
}
|
|
704
704
|
}
|
|
705
|
-
if (!Ie(
|
|
705
|
+
if (f.interests && !Ie(A(d, g - 1))) {
|
|
706
706
|
const E = Je(I, g);
|
|
707
707
|
if (E && E.endIndex === g) {
|
|
708
|
-
const
|
|
709
|
-
if (F.current !==
|
|
708
|
+
const p = `${E.startIndex}:${E.endIndex}:${E.search}`;
|
|
709
|
+
if (F.current !== p) {
|
|
710
710
|
for (let N = E.startIndex; N < E.endIndex; N++)
|
|
711
711
|
d[N] = Ne(d, N, "interest");
|
|
712
|
-
if (F.current =
|
|
712
|
+
if (F.current = p, k.current) {
|
|
713
713
|
const N = {
|
|
714
714
|
type: "interest",
|
|
715
715
|
startIndex: E.startIndex,
|