@connectedxm/entity-editor 0.0.10 → 0.0.11
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 +28 -31
- 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;
|
|
@@ -371,7 +371,7 @@ const De = (e) => {
|
|
|
371
371
|
const { position: o, deletedLength: r, insertedText: c } = t, i = c.length;
|
|
372
372
|
let u = [...e];
|
|
373
373
|
const f = p(u, o);
|
|
374
|
-
if (ke(f) ? u = xe(u, o, ke, ye) : Ie(f) ? u = xe(u, o, Ie,
|
|
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, Ae)), 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,7 +414,7 @@ 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 = [];
|
|
@@ -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;
|
|
@@ -456,7 +453,7 @@ const De = (e) => {
|
|
|
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
458
|
return Ae(o, !0);
|
|
462
459
|
}
|
|
@@ -515,7 +512,7 @@ const De = (e) => {
|
|
|
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 = Ae(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
|
}
|
|
@@ -544,7 +541,7 @@ const De = (e) => {
|
|
|
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
543
|
pe(t, s)
|
|
547
|
-
),
|
|
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);
|
|
@@ -597,11 +594,11 @@ const De = (e) => {
|
|
|
597
594
|
let g = [...x];
|
|
598
595
|
h === "mention" ? d = ge + d : h === "interest" ? d = Se + d : h === "link" && (d = We + d);
|
|
599
596
|
const E = v.slice(0, I) + d + v.slice(b), A = Fe(v, E);
|
|
600
|
-
A ? g = Ke(x, A, O) : g = pe(E,
|
|
597
|
+
A ? g = Ke(x, A, O) : g = pe(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);
|
|
@@ -618,30 +615,30 @@ const De = (e) => {
|
|
|
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
643
|
if (!ke(p(x, h - 1))) {
|
|
647
644
|
const _ = Ve(v, h);
|
|
@@ -718,7 +715,7 @@ const De = (e) => {
|
|
|
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
|
};
|