@connectedxm/entity-editor 0.0.9 → 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 CHANGED
@@ -1,69 +1,69 @@
1
1
  import a from "react";
2
- var ue = { exports: {} }, ee = {};
3
- var Le;
4
- function qe() {
5
- if (Le) return ee;
6
- Le = 1;
2
+ var ue = { exports: {} }, Z = {};
3
+ var Me;
4
+ function Ze() {
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
- function s(o, r, i) {
9
- var c = null;
10
- if (i !== void 0 && (c = "" + i), r.key !== void 0 && (c = "" + r.key), "key" in r) {
11
- i = {};
12
- for (var l in r)
13
- l !== "key" && (i[l] = r[l]);
14
- } else i = r;
15
- return r = i.ref, {
8
+ function s(o, r, c) {
9
+ var i = null;
10
+ if (c !== void 0 && (i = "" + c), r.key !== void 0 && (i = "" + r.key), "key" in r) {
11
+ c = {};
12
+ for (var u in r)
13
+ u !== "key" && (c[u] = r[u]);
14
+ } else c = r;
15
+ return r = c.ref, {
16
16
  $$typeof: e,
17
17
  type: o,
18
- key: c,
18
+ key: i,
19
19
  ref: r !== void 0 ? r : null,
20
- props: i
20
+ props: c
21
21
  };
22
22
  }
23
- return ee.Fragment = t, ee.jsx = s, ee.jsxs = s, ee;
23
+ return Z.Fragment = t, Z.jsx = s, Z.jsxs = s, Z;
24
24
  }
25
- var te = {};
25
+ var Q = {};
26
26
  var $e;
27
- function He() {
27
+ function Qe() {
28
28
  return $e || ($e = 1, process.env.NODE_ENV !== "production" && (function() {
29
29
  function e(n) {
30
30
  if (n == null) return null;
31
31
  if (typeof n == "function")
32
- return n.$$typeof === N ? null : n.displayName || n.name || null;
32
+ return n.$$typeof === ie ? null : n.displayName || n.name || null;
33
33
  if (typeof n == "string") return n;
34
34
  switch (n) {
35
- case U:
35
+ case O:
36
36
  return "Fragment";
37
- case W:
37
+ case T:
38
38
  return "Profiler";
39
- case O:
39
+ case oe:
40
40
  return "StrictMode";
41
- case z:
41
+ case P:
42
42
  return "Suspense";
43
- case X:
43
+ case V:
44
44
  return "SuspenseList";
45
- case ce:
45
+ case we:
46
46
  return "Activity";
47
47
  }
48
48
  if (typeof n == "object")
49
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
51
  ), n.$$typeof) {
52
- case L:
52
+ case D:
53
53
  return "Portal";
54
- case be:
54
+ case ce:
55
55
  return n.displayName || "Context";
56
- case ie:
56
+ case z:
57
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
- case we:
62
- return u = n.displayName || null, u !== null ? u : e(n.type) || "Memo";
58
+ case be:
59
+ var l = n.render;
60
+ return n = n.displayName, n || (n = l.displayName || l.name || "", n = n !== "" ? "ForwardRef(" + n + ")" : "ForwardRef"), n;
61
+ case X:
62
+ return l = n.displayName || null, l !== null ? l : e(n.type) || "Memo";
63
63
  case q:
64
- u = n._payload, n = n._init;
64
+ l = n._payload, n = n._init;
65
65
  try {
66
- return e(n(u));
66
+ return e(n(l));
67
67
  } catch {
68
68
  }
69
69
  }
@@ -75,50 +75,50 @@ function He() {
75
75
  function s(n) {
76
76
  try {
77
77
  t(n);
78
- var u = !1;
78
+ var l = !1;
79
79
  } catch {
80
- u = !0;
80
+ l = !0;
81
81
  }
82
- if (u) {
83
- u = console;
84
- var m = u.error, S = typeof Symbol == "function" && Symbol.toStringTag && n[Symbol.toStringTag] || n.constructor.name || "Object";
82
+ if (l) {
83
+ l = console;
84
+ var m = l.error, S = typeof Symbol == "function" && Symbol.toStringTag && n[Symbol.toStringTag] || n.constructor.name || "Object";
85
85
  return m.call(
86
- u,
86
+ l,
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
89
  ), t(n);
90
90
  }
91
91
  }
92
92
  function o(n) {
93
- if (n === U) return "<>";
93
+ if (n === O) return "<>";
94
94
  if (typeof n == "object" && n !== null && n.$$typeof === q)
95
95
  return "<...>";
96
96
  try {
97
- var u = e(n);
98
- return u ? "<" + u + ">" : "<...>";
97
+ var l = e(n);
98
+ return l ? "<" + l + ">" : "<...>";
99
99
  } catch {
100
100
  return "<...>";
101
101
  }
102
102
  }
103
103
  function r() {
104
- var n = T.A;
104
+ var n = x.A;
105
105
  return n === null ? null : n.getOwner();
106
106
  }
107
- function i() {
107
+ function c() {
108
108
  return Error("react-stack-top-frame");
109
109
  }
110
- function c(n) {
111
- if (P.call(n, "key")) {
112
- var u = Object.getOwnPropertyDescriptor(n, "key").get;
113
- if (u && u.isReactWarning) return !1;
110
+ function i(n) {
111
+ if (j.call(n, "key")) {
112
+ var l = Object.getOwnPropertyDescriptor(n, "key").get;
113
+ if (l && l.isReactWarning) return !1;
114
114
  }
115
115
  return n.key !== void 0;
116
116
  }
117
- function l(n, u) {
117
+ function u(n, l) {
118
118
  function m() {
119
- Z || (Z = !0, console.error(
119
+ G || (G = !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
- u
121
+ l
122
122
  ));
123
123
  }
124
124
  m.isReactWarning = !0, Object.defineProperty(n, "key", {
@@ -128,16 +128,16 @@ function He() {
128
128
  }
129
129
  function f() {
130
130
  var n = e(this.type);
131
- return G[n] || (G[n] = !0, console.error(
131
+ return H[n] || (H[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(n, u, m, S, B, F) {
135
+ function R(n, l, m, S, F, K) {
136
136
  var k = m.ref;
137
137
  return n = {
138
- $$typeof: M,
138
+ $$typeof: v,
139
139
  type: n,
140
- key: u,
140
+ key: l,
141
141
  props: m,
142
142
  _owner: S
143
143
  }, (k !== void 0 ? k : null) !== null ? Object.defineProperty(n, "ref", {
@@ -157,33 +157,33 @@ function He() {
157
157
  configurable: !1,
158
158
  enumerable: !1,
159
159
  writable: !0,
160
- value: B
160
+ value: F
161
161
  }), Object.defineProperty(n, "_debugTask", {
162
162
  configurable: !1,
163
163
  enumerable: !1,
164
164
  writable: !0,
165
- value: F
165
+ value: K
166
166
  }), Object.freeze && (Object.freeze(n.props), Object.freeze(n)), n;
167
167
  }
168
- function y(n, u, m, S, B, F) {
169
- var k = u.children;
168
+ function y(n, l, m, S, F, K) {
169
+ var k = l.children;
170
170
  if (k !== void 0)
171
171
  if (S)
172
- if (H(k)) {
172
+ if (L(k)) {
173
173
  for (S = 0; S < k.length; S++)
174
- K(k[S]);
174
+ se(k[S]);
175
175
  Object.freeze && Object.freeze(k);
176
176
  } else
177
177
  console.error(
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
- else K(k);
181
- if (P.call(u, "key")) {
180
+ else se(k);
181
+ if (j.call(l, "key")) {
182
182
  k = e(n);
183
- var D = Object.keys(u).filter(function(ve) {
183
+ var C = Object.keys(l).filter(function(ve) {
184
184
  return ve !== "key";
185
185
  });
186
- S = 0 < D.length ? "{key: someKey, " + D.join(": ..., ") + ": ...}" : "{key: someKey}", J[k + S] || (D = 0 < D.length ? "{" + D.join(": ..., ") + ": ...}" : "{}", console.error(
186
+ S = 0 < C.length ? "{key: someKey, " + C.join(": ..., ") + ": ...}" : "{key: someKey}", $[k + S] || (C = 0 < C.length ? "{" + C.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,16 +192,16 @@ React keys must be passed directly to JSX without using spread:
192
192
  <%s key={someKey} {...props} />`,
193
193
  S,
194
194
  k,
195
- D,
195
+ C,
196
196
  k
197
- ), J[k + S] = !0);
197
+ ), $[k + S] = !0);
198
198
  }
199
- if (k = null, m !== void 0 && (s(m), k = "" + m), c(u) && (s(u.key), k = "" + u.key), "key" in u) {
199
+ if (k = null, m !== void 0 && (s(m), k = "" + m), i(l) && (s(l.key), k = "" + l.key), "key" in l) {
200
200
  m = {};
201
- for (var Q in u)
202
- Q !== "key" && (m[Q] = u[Q]);
203
- } else m = u;
204
- return k && l(
201
+ for (var U in l)
202
+ U !== "key" && (m[U] = l[U]);
203
+ } else m = l;
204
+ return k && u(
205
205
  m,
206
206
  typeof n == "function" ? n.displayName || n.name || "Unknown" : n
207
207
  ), R(
@@ -209,17 +209,17 @@ React keys must be passed directly to JSX without using spread:
209
209
  k,
210
210
  m,
211
211
  r(),
212
- B,
213
- F
212
+ F,
213
+ K
214
214
  );
215
215
  }
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));
216
+ function se(n) {
217
+ W(n) ? n._store && (n._store.validated = 1) : typeof n == "object" && n !== null && n.$$typeof === q && (n._payload.status === "fulfilled" ? W(n._payload.value) && n._payload.value._store && (n._payload.value._store.validated = 1) : n._store && (n._store.validated = 1));
218
218
  }
219
- function v(n) {
220
- return typeof n == "object" && n !== null && n.$$typeof === M;
219
+ function W(n) {
220
+ return typeof n == "object" && n !== null && n.$$typeof === v;
221
221
  }
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() {
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 = {
@@ -227,113 +227,113 @@ React keys must be passed directly to JSX without using spread:
227
227
  return n();
228
228
  }
229
229
  };
230
- var Z, G = {}, j = w.react_stack_bottom_frame.bind(
230
+ var G, H = {}, J = w.react_stack_bottom_frame.bind(
231
231
  w,
232
- i
233
- )(), $ = V(o(i)), J = {};
234
- te.Fragment = U, te.jsx = function(n, u, m) {
235
- var S = 1e4 > T.recentlyCreatedOwnerStacks++;
232
+ c
233
+ )(), M = Y(o(c)), $ = {};
234
+ Q.Fragment = O, Q.jsx = function(n, l, m) {
235
+ var S = 1e4 > x.recentlyCreatedOwnerStacks++;
236
236
  return y(
237
237
  n,
238
- u,
238
+ l,
239
239
  m,
240
240
  !1,
241
- S ? Error("react-stack-top-frame") : j,
242
- S ? V(o(n)) : $
241
+ S ? Error("react-stack-top-frame") : J,
242
+ S ? Y(o(n)) : M
243
243
  );
244
- }, te.jsxs = function(n, u, m) {
245
- var S = 1e4 > T.recentlyCreatedOwnerStacks++;
244
+ }, Q.jsxs = function(n, l, m) {
245
+ var S = 1e4 > x.recentlyCreatedOwnerStacks++;
246
246
  return y(
247
247
  n,
248
- u,
248
+ l,
249
249
  m,
250
250
  !0,
251
- S ? Error("react-stack-top-frame") : j,
252
- S ? V(o(n)) : $
251
+ S ? Error("react-stack-top-frame") : J,
252
+ S ? Y(o(n)) : M
253
253
  );
254
254
  };
255
- })()), te;
255
+ })()), Q;
256
256
  }
257
257
  var Be;
258
- function Ze() {
259
- return Be || (Be = 1, process.env.NODE_ENV === "production" ? ue.exports = qe() : ue.exports = He()), ue.exports;
258
+ function et() {
259
+ return Be || (Be = 1, process.env.NODE_ENV === "production" ? ue.exports = Ze() : ue.exports = Qe()), ue.exports;
260
260
  }
261
- var Y = Ze();
261
+ var B = et();
262
262
  const De = (e) => {
263
263
  const t = window.getSelection();
264
264
  if (!t || !e) return { start: 0, end: 0 };
265
265
  if (t.anchorNode && e.contains(t.anchorNode)) {
266
266
  const s = t.getRangeAt(0), o = s.cloneRange();
267
267
  o.selectNodeContents(e), o.setEnd(s.startContainer, s.startOffset);
268
- const r = o.toString().length, i = s.cloneRange();
269
- i.selectNodeContents(e), i.setEnd(s.endContainer, s.endOffset);
270
- const c = i.toString().length;
271
- return { start: r, end: c };
268
+ const r = o.toString().length, c = s.cloneRange();
269
+ c.selectNodeContents(e), c.setEnd(s.endContainer, s.endOffset);
270
+ const i = c.toString().length;
271
+ return { start: r, end: i };
272
272
  } else
273
273
  return null;
274
- }, Qe = (e, t) => {
274
+ }, tt = (e, t) => {
275
275
  const s = document.createTreeWalker(e, NodeFilter.SHOW_TEXT);
276
- let o = 0, r = s.nextNode(), i = null, c = null, l = 0, f = 0;
276
+ let o = 0, r = s.nextNode(), c = null, i = null, u = 0, f = 0;
277
277
  for (; r; ) {
278
278
  const R = o + (r.textContent?.length || 0);
279
- if (!i && R >= t.start && (i = r, l = t.start - o), !c && R >= t.end) {
280
- c = r, f = t.end - o;
279
+ if (!c && R >= t.start && (c = r, u = t.start - o), !i && R >= t.end) {
280
+ i = r, f = t.end - o;
281
281
  break;
282
282
  }
283
283
  o = R, r = s.nextNode();
284
284
  }
285
- if (i && c) {
285
+ if (c && i) {
286
286
  const R = document.createRange();
287
287
  R.setStart(
288
- i,
289
- Math.min(l, i.textContent?.length || 0)
290
- ), R.setEnd(
291
288
  c,
292
- Math.min(f, c.textContent?.length || 0)
289
+ Math.min(u, c.textContent?.length || 0)
290
+ ), R.setEnd(
291
+ i,
292
+ Math.min(f, i.textContent?.length || 0)
293
293
  );
294
294
  const y = window.getSelection();
295
295
  y?.removeAllRanges(), y?.addRange(R);
296
296
  }
297
- }, et = (e, t, s) => {
298
- let o = "", r = "", i = "", c = "";
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
- let l = "";
301
- return o && (l += `color: ${o}; `), r && (l += `font-weight: ${r}; `), i && (l += `font-style: ${i}; `), c && (l += `text-decoration: ${c}; `), l;
297
+ }, nt = (e, t, s) => {
298
+ let o = "", r = "", c = "", i = "";
299
+ t.includes("bold") && (r = "bold"), t.includes("italic") && (c = "italic"), (t.includes("underline") || e === "link") && (i += "underline"), t.includes("strike") && (i += " 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
+ let u = "";
301
+ return o && (u += `color: ${o}; `), r && (u += `font-weight: ${r}; `), c && (u += `font-style: ${c}; `), i && (u += `text-decoration: ${i}; `), u;
302
302
  }, Ye = (e, t, s) => {
303
303
  if (t.length === 0)
304
304
  return e;
305
305
  let o = "", r = 0;
306
- return t.forEach((i) => {
307
- r < i.startIndex && (o += e.slice(r, i.startIndex));
308
- const c = e.slice(i.startIndex, i.endIndex), l = et(i.type, i.marks, s);
309
- o += `<span style="${l}">${c}</span>`, r = i.endIndex;
306
+ return t.forEach((c) => {
307
+ r < c.startIndex && (o += e.slice(r, c.startIndex));
308
+ const i = e.slice(c.startIndex, c.endIndex), u = nt(c.type, c.marks, s);
309
+ o += `<span style="${u}">${i}</span>`, r = c.endIndex;
310
310
  }), o += e.slice(r), o;
311
- }, tt = (e, t) => {
311
+ }, rt = (e, t) => {
312
312
  let s = !1;
313
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
- }, he = 128, nt = "()[]{}", We = "", rt = new RegExp(
314
+ }, he = 128, st = "()[]{}", We = "", ot = 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
317
  ), ze = (e, t) => {
318
318
  const s = je(
319
319
  e,
320
320
  t,
321
- nt,
321
+ st,
322
322
  We
323
323
  );
324
- return s?.search.match(rt) ? s : null;
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) => {
324
+ return s?.search.match(ot) ? s : null;
325
+ }, me = (e) => (e & he) !== 0, Ae = (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,
329
- ot,
329
+ it,
330
330
  ge
331
331
  );
332
- return s?.search.match(st) ? {
332
+ return s?.search.match(ct) ? {
333
333
  type: "mention",
334
334
  ...s
335
335
  } : null;
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) => {
336
+ }, ke = (e) => (e & Re) !== 0, ye = (e, t) => t ? e | Re : e & ~Re, ee = 2, ae = (e) => (e & ee) !== 0, Oe = (e, t) => t ? e | ee : e & ~ee, te = 4, fe = (e) => (e & te) !== 0, Te = (e, t) => t ? e | te : e & ~te, ne = 16, de = (e) => (e & ne) !== 0, Ce = (e, t) => t ? e | ne : e & ~ne, re = 8, Ee = (e) => (e & re) !== 0, Pe = (e, t) => t ? e | re : e & ~re, Fe = (e, t) => {
337
337
  if (e === t) return null;
338
338
  let s = 0;
339
339
  for (; s < e.length && s < t.length && e[s] === t[s]; )
@@ -349,104 +349,101 @@ const De = (e) => {
349
349
  }, xe = (e, t, s, o) => {
350
350
  let r = t;
351
351
  for (; r < e.length; ) {
352
- const c = p(e, r);
353
- if (s(c))
354
- e[r] = o(c, !1);
352
+ const i = p(e, r);
353
+ if (s(i))
354
+ e[r] = o(i, !1);
355
355
  else
356
356
  break;
357
357
  r++;
358
358
  }
359
- let i = t - 1;
360
- for (; i >= 0; ) {
361
- const c = p(e, i);
362
- if (s(c))
363
- e[i] = o(c, !1);
359
+ let c = t - 1;
360
+ for (; c >= 0; ) {
361
+ const i = p(e, c);
362
+ if (s(i))
363
+ e[c] = o(i, !1);
364
364
  else
365
365
  break;
366
- i--;
366
+ c--;
367
367
  }
368
368
  return e;
369
369
  }, Ke = (e, t, s) => {
370
370
  if (!t) return e;
371
- const { position: o, deletedLength: r, insertedText: i } = t, c = i.length;
372
- let l = [...e];
373
- const f = p(l, o);
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) {
371
+ const { position: o, deletedLength: r, insertedText: c } = t, i = c.length;
372
+ let u = [...e];
373
+ const f = p(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, 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
- const y = new Array(c).fill(R);
378
- l.splice(o, 0, ...y);
377
+ const y = new Array(i).fill(R);
378
+ u.splice(o, 0, ...y);
379
379
  }
380
- return l;
381
- }, it = (e) => /\s/.test(e) || /[\u2000-\u200B\u2028\u2029\u3000]/.test(e), je = (e, t, s, o) => {
380
+ return u;
381
+ }, lt = (e) => /\s/.test(e) || /[\u2000-\u200B\u2028\u2029\u3000]/.test(e), je = (e, t, s, o) => {
382
382
  if (t <= 0 || t > e.length)
383
383
  return null;
384
- let r = "", i = t - 1, c = t;
385
- const l = (f) => it(f) || s.includes(f);
386
- for (let f = i; f >= 0; f--) {
387
- if (l(e[f])) {
388
- i = f + 1;
384
+ let r = "", c = t - 1, i = t;
385
+ const u = (f) => lt(f) || s.includes(f);
386
+ for (let f = c; f >= 0; f--) {
387
+ if (u(e[f])) {
388
+ c = f + 1;
389
389
  break;
390
390
  }
391
- f === 0 && (i = 0), r = e[f] + r;
391
+ f === 0 && (c = 0), r = e[f] + r;
392
392
  }
393
- for (let f = c; f < e.length; f++) {
394
- if (l(e[f])) {
395
- c = f;
393
+ for (let f = i; f < e.length; f++) {
394
+ if (u(e[f])) {
395
+ i = f;
396
396
  break;
397
397
  }
398
398
  if (o && e[f] === o) {
399
- c = f;
399
+ i = f;
400
400
  break;
401
401
  }
402
- f === e.length - 1 && (c = e.length), r = r + e[f];
402
+ f === e.length - 1 && (i = e.length), r = r + e[f];
403
403
  }
404
404
  return {
405
- search: e.slice(i, c),
406
- startIndex: i,
407
- endIndex: c
405
+ search: e.slice(c, i),
406
+ startIndex: c,
407
+ endIndex: i
408
408
  };
409
- }, _e = 64, ct = `.,!?;()[]{}"'<>@`, lt = /^#[\w-]+$/, Se = "#", Ge = (e, t) => {
409
+ }, _e = 64, ut = `.,!?;()[]{}"'<>@`, at = /^#[a-zA-Z0-9-]+$/, Se = "#", Je = (e, t) => {
410
410
  const s = je(
411
411
  e,
412
412
  t,
413
- ct,
413
+ ut,
414
414
  Se
415
415
  );
416
- return s?.search.match(lt) ? s : null;
417
- }, Ie = (e) => (e & _e) !== 0, Me = (e, t) => t ? e | _e : e & ~_e, ut = (e, t) => e.find(
416
+ return s?.search.match(at) ? s : null;
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
- ), at = (e, t, s) => {
419
+ ), dt = (e, t, s) => {
420
420
  const o = [];
421
421
  let r = 0;
422
422
  for (; r < t.length; ) {
423
- const i = p(t, r);
424
- if (i === 0 || i === 1) {
423
+ const c = p(t, r);
424
+ if (c === 0 || c === 1) {
425
425
  r++;
426
426
  continue;
427
427
  }
428
- const c = r;
429
- let l = r;
430
- for (; l + 1 < t.length && p(t, l + 1) === i; )
431
- l++;
432
- const f = ft(i, s), R = dt(i), y = {
428
+ const i = r;
429
+ let u = r;
430
+ for (; u + 1 < t.length && p(t, u + 1) === c; )
431
+ u++;
432
+ const f = Et(c, s), R = ht(c), y = {
433
433
  type: f,
434
- startIndex: c,
435
- endIndex: l + 1,
434
+ startIndex: i,
435
+ endIndex: u + 1,
436
436
  marks: R,
437
- username: f === "mention" ? Ve(e, l)?.search.replace(ge, "") : void 0,
438
- interest: f === "interest" ? Ge(e, l)?.search.replace(
439
- Se,
440
- ""
441
- ) : void 0,
442
- href: f === "link" ? ze(e, l)?.search : void 0
437
+ username: f === "mention" ? Ve(e, u)?.search.replace(ge, "") : void 0,
438
+ interest: f === "interest" ? Je(e, u)?.search.replace(Se, "").toLowerCase() : void 0,
439
+ href: f === "link" ? ze(e, u)?.search : void 0
443
440
  };
444
- o.push(y), r = l + 1;
441
+ o.push(y), r = u + 1;
445
442
  }
446
443
  return o;
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) => {
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
- return e & ne && t.push("bold"), e & re && t.push("italic"), e & oe && t.push("underline"), e & se && t.push("strike"), t;
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
  }, p = (e, t) => {
451
448
  const s = e[t];
452
449
  return typeof s != "number" ? 0 : s;
@@ -456,12 +453,12 @@ const De = (e) => {
456
453
  case "mention":
457
454
  return ye(o, !0);
458
455
  case "interest":
459
- return Me(o, !0);
456
+ return Le(o, !0);
460
457
  case "link":
461
458
  return Ae(o, !0);
462
459
  }
463
460
  return o;
464
- }, Et = (e, t, s, o) => {
461
+ }, mt = (e, t, s, o) => {
465
462
  let r = p(e, t);
466
463
  switch (s) {
467
464
  case "bold":
@@ -480,7 +477,7 @@ const De = (e) => {
480
477
  return e;
481
478
  }
482
479
  return e[t] = r, e;
483
- }, ht = (e, t, s) => {
480
+ }, Rt = (e, t, s) => {
484
481
  const o = p(e, t);
485
482
  switch (s) {
486
483
  case "bold":
@@ -494,150 +491,157 @@ const De = (e) => {
494
491
  default:
495
492
  throw Error(`Invalid mark type: ${s}`);
496
493
  }
497
- }, mt = (e, t, s, o) => {
494
+ }, gt = (e, t, s, o) => {
498
495
  for (let r = e; r < t; r++)
499
- if (!ht(o, r, s)) return !1;
496
+ if (!Rt(o, r, s)) return !1;
500
497
  return !0;
501
- }, Ue = (e) => ke(e) || Ie(e) || me(e), Rt = (e, t, s, o) => {
498
+ }, Ue = (e) => ke(e) || Ie(e) || me(e), kt = (e, t, s, o) => {
502
499
  let r = [...e];
503
500
  for (; Ue(p(e, t - 1)) && t > 0; )
504
501
  t--;
505
502
  for (; Ue(p(e, s)) && s < e.length; )
506
503
  s++;
507
- let i = !0;
508
- mt(t, s, o, r) && (i = !1);
509
- for (let c = t; c < s; c++)
510
- r = Et(r, c, o, i);
504
+ let c = !0;
505
+ gt(t, s, o, r) && (c = !1);
506
+ for (let i = t; i < s; i++)
507
+ r = mt(r, i, o, c);
511
508
  return r;
512
509
  }, pe = (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
- const i = ut(t, o);
517
- if (i) {
518
- i.type === "mention" ? r = ye(r, !0) : i.type === "interest" ? r = Me(r, !0) : i.type === "link" && (r = Ae(r, !0));
519
- for (const c of i.marks)
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));
513
+ const c = ft(t, o);
514
+ if (c) {
515
+ c.type === "mention" ? r = ye(r, !0) : c.type === "interest" ? r = Le(r, !0) : c.type === "link" && (r = Ae(r, !0));
516
+ for (const i of c.marks)
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
  }
522
519
  s[o] = r;
523
520
  }
524
521
  return s;
525
- }, gt = {}, kt = {}, St = ({
522
+ }, _t = {}, St = {}, bt = ({
526
523
  ref: e,
527
524
  initialPlainText: t = "",
528
525
  initialEntities: s = [],
529
526
  onMentionSearch: o,
530
527
  onMarkStateChange: r,
531
- onLinkCreated: i,
532
- onInterestCreated: c,
533
- options: l = gt,
534
- entityStyles: f = kt,
535
- placeholder: R = "",
536
- debug: y = !1,
537
- ...K
528
+ onLinkCreated: c,
529
+ onInterestCreated: i,
530
+ onGetState: u,
531
+ options: f = _t,
532
+ entityStyles: R = St,
533
+ placeholder: y = "",
534
+ debug: se = !1,
535
+ ...W
538
536
  }) => {
539
- const v = a.useRef(null), [w, M] = a.useState(t), [L, U] = a.useState({
537
+ const w = a.useRef(null), [v, D] = a.useState(t), [O, oe] = a.useState({
540
538
  bold: !1,
541
539
  italic: !1,
542
540
  underline: !1,
543
541
  strike: !1
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(
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(
545
543
  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({
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({
547
545
  start: 0,
548
546
  end: 0
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);
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);
550
548
  a.useEffect(() => {
551
- H.current = o;
549
+ Y.current = o;
552
550
  }, [o]), a.useEffect(() => {
553
- V.current = r;
551
+ G.current = r;
554
552
  }, [r]), a.useEffect(() => {
555
- B.current = i;
556
- }, [i]), a.useEffect(() => {
557
- F.current = c;
553
+ K.current = c;
558
554
  }, [c]), a.useEffect(() => {
559
- Z.current = C;
560
- }, [C]), a.useEffect(() => {
561
- if (n.current && clearTimeout(n.current), O === null) {
562
- H.current?.(null);
555
+ k.current = i;
556
+ }, [i]), a.useEffect(() => {
557
+ C.current = u;
558
+ }, [u]), a.useEffect(() => {
559
+ H.current = P;
560
+ }, [P]), a.useEffect(() => {
561
+ if (l.current && clearTimeout(l.current), T === null) {
562
+ Y.current?.(null);
563
563
  return;
564
564
  }
565
- return n.current = setTimeout(() => {
566
- H.current?.(O);
565
+ return l.current = setTimeout(() => {
566
+ Y.current?.(T);
567
567
  }, 300), () => {
568
- n.current && clearTimeout(n.current);
568
+ l.current && clearTimeout(l.current);
569
569
  };
570
- }, [O]), a.useEffect(() => {
571
- V.current?.(L);
572
- }, [L]);
573
- const k = a.useCallback(
570
+ }, [T]), a.useEffect(() => {
571
+ G.current?.(O);
572
+ }, [O]);
573
+ const U = a.useCallback(
574
574
  (h) => {
575
- if (z(!0), !v.current)
575
+ if (V(!0), !w.current)
576
576
  return;
577
- const { start: I, end: b } = j.current;
577
+ const { start: I, end: b } = M.current;
578
578
  if (I !== b) {
579
- const d = Rt(N, I, b, h);
580
- T(d);
579
+ const d = kt(x, I, b, h);
580
+ j(d);
581
581
  }
582
- U((d) => {
582
+ oe((d) => {
583
583
  const g = { ...d };
584
584
  return h === "bold" ? g.bold = !d.bold : h === "italic" ? g.italic = !d.italic : h === "underline" ? g.underline = !d.underline : h === "strike" && (g.strike = !d.strike), g;
585
585
  });
586
586
  },
587
- [N]
587
+ [x]
588
588
  );
589
589
  a.useImperativeHandle(
590
590
  e,
591
591
  () => ({
592
592
  selectEntity: (h, I, b, d) => {
593
- if (!v.current) return;
594
- let g = [...N];
593
+ if (!w.current) return;
594
+ let g = [...x];
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 = Fe(w, E);
597
- A ? g = Ke(N, A, L) : g = pe(E, P);
596
+ const E = v.slice(0, I) + d + v.slice(b), A = Fe(v, E);
597
+ A ? g = Ke(x, A, O) : g = pe(E, L);
598
598
  for (let _ = I; _ < I + d.length; _++)
599
599
  g[_] = Ne(g, _, h);
600
- const x = I + d.length;
601
- j.current = {
602
- start: x,
603
- end: x
604
- }, u.current = !0, M(E), T(g), W(null);
600
+ const N = I + d.length;
601
+ M.current = {
602
+ start: N,
603
+ end: N
604
+ }, m.current = !0, D(E), j(g), z(null);
605
605
  },
606
- toggleMark: k,
606
+ toggleMark: U,
607
607
  clear: () => {
608
- M(""), T([]);
608
+ D(""), j([]);
609
609
  },
610
610
  reset: () => {
611
- M(t), T(pe(t, s)), W(null);
611
+ D(t), j(pe(t, s)), z(null);
612
612
  },
613
613
  focus: () => {
614
- v.current?.focus();
614
+ w.current?.focus();
615
615
  },
616
- getState: () => ({
617
- plainText: w,
618
- entities: P,
619
- markState: L
616
+ getState: () => (C.current && C.current({
617
+ plainText: v,
618
+ entities: L,
619
+ markState: O
620
+ }), {
621
+ plainText: v,
622
+ entities: L,
623
+ markState: O
620
624
  })
621
625
  }),
622
- [N, w, P, L, k]
626
+ [x, v, L, O, U]
623
627
  ), a.useEffect(() => {
624
- if (v.current && !X) {
625
- v.current.textContent = w;
626
- const h = Ye(w, P, f);
627
- v.current.innerHTML = h, we(!0);
628
+ if (w.current && !X) {
629
+ w.current.textContent = v;
630
+ const h = Ye(v, L, R);
631
+ w.current.innerHTML = h, q(!0);
628
632
  }
629
633
  }, []), a.useLayoutEffect(() => {
630
- if (!v.current || !X) return;
631
- const h = u.current ? j.current : De(v.current) ?? j.current;
632
- u.current = !1;
633
- const I = Ye(w, P, f);
634
- J.current = !0, v.current.innerHTML = I, Qe(v.current, h), queueMicrotask(() => {
635
- J.current = !1;
634
+ if (!w.current || !X) return;
635
+ const h = m.current ? M.current : De(w.current) ?? M.current;
636
+ m.current = !1;
637
+ const I = Ye(v, L, R);
638
+ n.current = !0, w.current.innerHTML = I, tt(w.current, h), queueMicrotask(() => {
639
+ n.current = !1;
636
640
  });
637
- }, [P, f, X]), a.useEffect(() => {
638
- let { start: h, end: I } = ie, b = null;
639
- if (!ke(p(N, h - 1))) {
640
- const _ = Ve(w, h);
641
+ }, [L, R, X]), a.useEffect(() => {
642
+ let { start: h, end: I } = ce, b = null;
643
+ if (!ke(p(x, h - 1))) {
644
+ const _ = Ve(v, h);
641
645
  _ && (b = {
642
646
  type: "mention",
643
647
  search: _.search.replace(ge, ""),
@@ -645,100 +649,100 @@ const De = (e) => {
645
649
  endIndex: _.endIndex
646
650
  });
647
651
  }
648
- if (b ? (!O || b.startIndex !== O.startIndex || b.endIndex !== O.endIndex || b.search !== O.search) && W(b) : O && W(null), C) return;
652
+ if (b ? (!T || b.startIndex !== T.startIndex || b.endIndex !== T.endIndex || b.search !== T.search) && z(b) : T && z(null), P) return;
649
653
  let d = !0, g = !0, E = !0, A = !0;
650
654
  if (h === I)
651
655
  if (h > 0) {
652
- const _ = p(N, h - 1);
656
+ const _ = p(x, h - 1);
653
657
  d = ae(_), g = fe(_), E = Ee(_), A = de(_);
654
658
  } else {
655
- const _ = p(N, h);
659
+ const _ = p(x, h);
656
660
  d = ae(_), g = fe(_), E = Ee(_), A = de(_);
657
661
  }
658
662
  else
659
663
  for (let _ = h; _ < I; _++) {
660
- const le = p(N, _);
664
+ const le = p(x, _);
661
665
  d = ae(le) ? d : !1, g = fe(le) ? g : !1, E = Ee(le) ? E : !1, A = de(le) ? A : !1;
662
666
  }
663
- U({
667
+ oe({
664
668
  bold: d,
665
669
  italic: g,
666
670
  underline: E,
667
671
  strike: A
668
672
  });
669
- }, [ie, N, w, C]);
670
- const D = (h) => {
671
- if (!v.current) return;
673
+ }, [ce, x, v, P]);
674
+ const ve = (h) => {
675
+ if (!w.current) return;
672
676
  if (h.target.textContent.length === 0) {
673
- M(""), T([]), C && z(!1);
677
+ D(""), j([]), P && V(!1);
674
678
  return;
675
679
  }
676
- const I = h.target.innerText || "", b = Fe(w, I);
680
+ const I = h.target.innerText || "", b = Fe(v, I);
677
681
  if (b) {
678
- let d = Ke(N, b, L);
682
+ let d = Ke(x, b, O);
679
683
  if (b.deletedLength === 0 && b.insertedText === " " && b.position > 0) {
680
684
  const g = b.position;
681
685
  if (!me(p(d, g - 1))) {
682
686
  const E = ze(I, g);
683
687
  if (E && E.endIndex === g) {
684
688
  const A = `${E.startIndex}:${E.endIndex}:${E.search}`;
685
- if (m.current !== A) {
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 = {
689
+ if (S.current !== A) {
690
+ for (let N = E.startIndex; N < E.endIndex; N++)
691
+ d[N] = Ne(d, N, "link");
692
+ if (S.current = A, K.current) {
693
+ const N = {
690
694
  type: "link",
691
695
  startIndex: E.startIndex,
692
696
  endIndex: E.endIndex,
693
697
  marks: [],
694
698
  href: E.search
695
699
  };
696
- B.current(x);
700
+ K.current(N);
697
701
  }
698
702
  }
699
703
  }
700
704
  }
701
705
  if (!Ie(p(d, g - 1))) {
702
- const E = Ge(I, g);
706
+ const E = Je(I, g);
703
707
  if (E && E.endIndex === g) {
704
708
  const A = `${E.startIndex}:${E.endIndex}:${E.search}`;
705
- if (S.current !== A) {
706
- for (let x = E.startIndex; x < E.endIndex; x++)
707
- d[x] = Ne(d, x, "interest");
708
- if (S.current = A, F.current) {
709
- const x = {
709
+ if (F.current !== A) {
710
+ for (let N = E.startIndex; N < E.endIndex; N++)
711
+ d[N] = Ne(d, N, "interest");
712
+ if (F.current = A, k.current) {
713
+ const N = {
710
714
  type: "interest",
711
715
  startIndex: E.startIndex,
712
716
  endIndex: E.endIndex,
713
717
  marks: [],
714
- interest: E.search.replace(Se, "")
718
+ interest: E.search.replace(Se, "").toLowerCase()
715
719
  };
716
- F.current(x);
720
+ k.current(N);
717
721
  }
718
722
  }
719
723
  }
720
724
  }
721
725
  }
722
- T(d), G.current = !0, setTimeout(() => {
723
- G.current = !1;
726
+ j(d), J.current = !0, setTimeout(() => {
727
+ J.current = !1;
724
728
  }, 50);
725
- } else C && z(!1);
726
- M(I);
727
- }, Q = (h) => {
728
- v.current && tt(h, k);
729
- }, ve = () => {
730
- ce(!0);
731
- }, Je = () => {
732
- ce(!1);
729
+ } else P && V(!1);
730
+ D(I);
731
+ }, Xe = (h) => {
732
+ w.current && rt(h, U);
733
+ }, qe = () => {
734
+ ie(!0);
735
+ }, Ge = () => {
736
+ ie(!1);
733
737
  };
734
738
  a.useEffect(() => {
735
739
  const h = () => {
736
- if (J.current) return;
737
- const I = De(v.current) ?? {
740
+ if (n.current) return;
741
+ const I = De(w.current) ?? {
738
742
  start: 0,
739
743
  end: 0
740
- }, b = j.current;
741
- (I.start !== b.start || I.end !== b.end) && (j.current = I, Z.current && !G.current && z(!1), $.current && clearTimeout($.current), $.current = setTimeout(() => {
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(() => {
742
746
  be(I);
743
747
  }, 500));
744
748
  };
@@ -746,31 +750,31 @@ const De = (e) => {
746
750
  document.removeEventListener("selectionchange", h), $.current && clearTimeout($.current);
747
751
  };
748
752
  }, []);
749
- const Xe = w.length === 0 && R && !q;
750
- return /* @__PURE__ */ Y.jsxs(Y.Fragment, { children: [
751
- /* @__PURE__ */ Y.jsxs("div", { style: { position: "relative" }, children: [
752
- /* @__PURE__ */ Y.jsx(
753
+ const He = v.length === 0 && y && !we;
754
+ return /* @__PURE__ */ B.jsxs(B.Fragment, { children: [
755
+ /* @__PURE__ */ B.jsxs("div", { style: { position: "relative" }, children: [
756
+ /* @__PURE__ */ B.jsx(
753
757
  "div",
754
758
  {
755
- ref: v,
756
- style: { ...K.style, position: "relative", zIndex: 2 },
757
- className: K.className,
759
+ ref: w,
760
+ style: { ...W.style, position: "relative", zIndex: 2 },
761
+ className: W.className,
758
762
  contentEditable: !0,
759
- onKeyDown: Q,
760
- onInput: D,
761
- onFocus: ve,
762
- onBlur: Je,
763
+ onKeyDown: Xe,
764
+ onInput: ve,
765
+ onFocus: qe,
766
+ onBlur: Ge,
763
767
  role: "textbox",
764
768
  "aria-multiline": "true",
765
769
  autoCapitalize: "off",
766
770
  autoFocus: !1
767
771
  }
768
772
  ),
769
- Xe && /* @__PURE__ */ Y.jsx(
773
+ He && /* @__PURE__ */ B.jsx(
770
774
  "div",
771
775
  {
772
776
  style: {
773
- ...K.style,
777
+ ...W.style,
774
778
  position: "absolute",
775
779
  top: 0,
776
780
  left: 0,
@@ -780,13 +784,13 @@ const De = (e) => {
780
784
  pointerEvents: "none"
781
785
  },
782
786
  "aria-hidden": "true",
783
- children: /* @__PURE__ */ Y.jsx("p", { style: { margin: 0 }, children: R })
787
+ children: /* @__PURE__ */ B.jsx("p", { style: { margin: 0 }, children: y })
784
788
  }
785
789
  )
786
790
  ] }),
787
- y && /* @__PURE__ */ Y.jsx("div", { style: {}, children: /* @__PURE__ */ Y.jsx("pre", { children: JSON.stringify(N) }) })
791
+ se && /* @__PURE__ */ B.jsx("div", { style: {}, children: /* @__PURE__ */ B.jsx("pre", { children: JSON.stringify(x) }) })
788
792
  ] });
789
793
  };
790
794
  export {
791
- St as Editor
795
+ bt as Editor
792
796
  };
@@ -1,16 +1,17 @@
1
1
  import { default as React } from 'react';
2
2
  import { Entity, EntityOptions, StyleOptions, EntityType, MarkState, MarkType, MentionSearch } from './interfaces';
3
+ export interface EditorState {
4
+ plainText: string;
5
+ entities: Entity[];
6
+ markState: MarkState;
7
+ }
3
8
  export interface EditorRef {
4
9
  selectEntity: (entityType: EntityType, startIndex: number, endIndex: number, newText: string) => void;
5
10
  toggleMark: (markType: MarkType) => void;
6
11
  clear: () => void;
7
12
  reset: () => void;
8
13
  focus: () => void;
9
- getState: () => {
10
- plainText: string;
11
- entities: Entity[];
12
- markState: MarkState;
13
- };
14
+ getState: () => EditorState;
14
15
  }
15
16
  export interface EditorProps {
16
17
  ref: React.RefObject<EditorRef | null>;
@@ -20,6 +21,7 @@ export interface EditorProps {
20
21
  onMarkStateChange?: (markState: MarkState) => void;
21
22
  onLinkCreated?: (link: Entity) => void;
22
23
  onInterestCreated?: (interest: Entity) => void;
24
+ onGetState?: (state: EditorState) => void;
23
25
  style?: React.CSSProperties;
24
26
  className?: string;
25
27
  options?: EntityOptions;
@@ -27,4 +29,4 @@ export interface EditorProps {
27
29
  placeholder?: string;
28
30
  debug?: boolean;
29
31
  }
30
- export declare const Editor: ({ ref, initialPlainText, initialEntities, onMentionSearch, onMarkStateChange, onLinkCreated, onInterestCreated, options, entityStyles, placeholder, debug, ...props }: EditorProps) => import("react/jsx-runtime").JSX.Element;
32
+ export declare const Editor: ({ ref, initialPlainText, initialEntities, onMentionSearch, onMarkStateChange, onLinkCreated, onInterestCreated, onGetState, options, entityStyles, placeholder, debug, ...props }: EditorProps) => import("react/jsx-runtime").JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@connectedxm/entity-editor",
3
- "version": "0.0.9",
3
+ "version": "0.0.11",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "dist/index.umd.js",