@connectedxm/entity-editor 0.0.2 → 0.0.4

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,5 +1,5 @@
1
- import C, { useState as xe, useRef as he, useEffect as $e } from "react";
2
- var J = { exports: {} }, B = {};
1
+ import A, { useState as $e, useRef as me, useEffect as Ye } from "react";
2
+ var X = { exports: {} }, x = {};
3
3
  /**
4
4
  * @license React
5
5
  * react-jsx-runtime.production.js
@@ -9,29 +9,29 @@ var J = { exports: {} }, B = {};
9
9
  * This source code is licensed under the MIT license found in the
10
10
  * LICENSE file in the root directory of this source tree.
11
11
  */
12
- var Ne;
13
- function Ye() {
14
- if (Ne) return B;
15
- Ne = 1;
12
+ var Ae;
13
+ function Fe() {
14
+ if (Ae) return x;
15
+ Ae = 1;
16
16
  var e = Symbol.for("react.transitional.element"), t = Symbol.for("react.fragment");
17
- function r(s, n, i) {
17
+ function n(s, o, i) {
18
18
  var c = null;
19
- if (i !== void 0 && (c = "" + i), n.key !== void 0 && (c = "" + n.key), "key" in n) {
19
+ if (i !== void 0 && (c = "" + i), o.key !== void 0 && (c = "" + o.key), "key" in o) {
20
20
  i = {};
21
- for (var l in n)
22
- l !== "key" && (i[l] = n[l]);
23
- } else i = n;
24
- return n = i.ref, {
21
+ for (var u in o)
22
+ u !== "key" && (i[u] = o[u]);
23
+ } else i = o;
24
+ return o = i.ref, {
25
25
  $$typeof: e,
26
26
  type: s,
27
27
  key: c,
28
- ref: n !== void 0 ? n : null,
28
+ ref: o !== void 0 ? o : null,
29
29
  props: i
30
30
  };
31
31
  }
32
- return B.Fragment = t, B.jsx = r, B.jsxs = r, B;
32
+ return x.Fragment = t, x.jsx = n, x.jsxs = n, x;
33
33
  }
34
- var x = {};
34
+ var D = {};
35
35
  /**
36
36
  * @license React
37
37
  * react-jsx-runtime.development.js
@@ -41,377 +41,380 @@ var x = {};
41
41
  * This source code is licensed under the MIT license found in the
42
42
  * LICENSE file in the root directory of this source tree.
43
43
  */
44
- var Ae;
44
+ var Oe;
45
45
  function We() {
46
- return Ae || (Ae = 1, process.env.NODE_ENV !== "production" && (function() {
47
- function e(o) {
48
- if (o == null) return null;
49
- if (typeof o == "function")
50
- return o.$$typeof === u ? null : o.displayName || o.name || null;
51
- if (typeof o == "string") return o;
52
- switch (o) {
53
- case L:
46
+ return Oe || (Oe = 1, process.env.NODE_ENV !== "production" && (function() {
47
+ function e(r) {
48
+ if (r == null) return null;
49
+ if (typeof r == "function")
50
+ return r.$$typeof === V ? null : r.displayName || r.name || null;
51
+ if (typeof r == "string") return r;
52
+ switch (r) {
53
+ case O:
54
54
  return "Fragment";
55
55
  case F:
56
56
  return "Profiler";
57
- case U:
57
+ case le:
58
58
  return "StrictMode";
59
- case M:
59
+ case ae:
60
60
  return "Suspense";
61
- case z:
61
+ case U:
62
62
  return "SuspenseList";
63
- case ae:
63
+ case z:
64
64
  return "Activity";
65
65
  }
66
- if (typeof o == "object")
67
- switch (typeof o.tag == "number" && console.error(
66
+ if (typeof r == "object")
67
+ switch (typeof r.tag == "number" && console.error(
68
68
  "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
69
- ), o.$$typeof) {
70
- case T:
69
+ ), r.$$typeof) {
70
+ case v:
71
71
  return "Portal";
72
+ case K:
73
+ return (r.displayName || "Context") + ".Provider";
74
+ case W:
75
+ return (r._context.displayName || "Context") + ".Consumer";
72
76
  case ue:
73
- return (o.displayName || "Context") + ".Provider";
74
- case V:
75
- return (o._context.displayName || "Context") + ".Consumer";
76
- case v:
77
- var a = o.render;
78
- return o = o.displayName, o || (o = a.displayName || a.name || "", o = o !== "" ? "ForwardRef(" + o + ")" : "ForwardRef"), o;
79
- case G:
80
- return a = o.displayName || null, a !== null ? a : e(o.type) || "Memo";
81
- case X:
82
- a = o._payload, o = o._init;
77
+ var l = r.render;
78
+ return r = r.displayName, r || (r = l.displayName || l.name || "", r = r !== "" ? "ForwardRef(" + r + ")" : "ForwardRef"), r;
79
+ case S:
80
+ return l = r.displayName || null, l !== null ? l : e(r.type) || "Memo";
81
+ case I:
82
+ l = r._payload, r = r._init;
83
83
  try {
84
- return e(o(a));
84
+ return e(r(l));
85
85
  } catch {
86
86
  }
87
87
  }
88
88
  return null;
89
89
  }
90
- function t(o) {
91
- return "" + o;
90
+ function t(r) {
91
+ return "" + r;
92
92
  }
93
- function r(o) {
93
+ function n(r) {
94
94
  try {
95
- t(o);
96
- var a = !1;
95
+ t(r);
96
+ var l = !1;
97
97
  } catch {
98
- a = !0;
98
+ l = !0;
99
99
  }
100
- if (a) {
101
- a = console;
102
- var m = a.error, k = typeof Symbol == "function" && Symbol.toStringTag && o[Symbol.toStringTag] || o.constructor.name || "Object";
103
- return m.call(
104
- a,
100
+ if (l) {
101
+ l = console;
102
+ var d = l.error, g = typeof Symbol == "function" && Symbol.toStringTag && r[Symbol.toStringTag] || r.constructor.name || "Object";
103
+ return d.call(
104
+ l,
105
105
  "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
106
- k
107
- ), t(o);
106
+ g
107
+ ), t(r);
108
108
  }
109
109
  }
110
- function s(o) {
111
- if (o === L) return "<>";
112
- if (typeof o == "object" && o !== null && o.$$typeof === X)
110
+ function s(r) {
111
+ if (r === O) return "<>";
112
+ if (typeof r == "object" && r !== null && r.$$typeof === I)
113
113
  return "<...>";
114
114
  try {
115
- var a = e(o);
116
- return a ? "<" + a + ">" : "<...>";
115
+ var l = e(r);
116
+ return l ? "<" + l + ">" : "<...>";
117
117
  } catch {
118
118
  return "<...>";
119
119
  }
120
120
  }
121
- function n() {
122
- var o = g.A;
123
- return o === null ? null : o.getOwner();
121
+ function o() {
122
+ var r = M.A;
123
+ return r === null ? null : r.getOwner();
124
124
  }
125
125
  function i() {
126
126
  return Error("react-stack-top-frame");
127
127
  }
128
- function c(o) {
129
- if (d.call(o, "key")) {
130
- var a = Object.getOwnPropertyDescriptor(o, "key").get;
131
- if (a && a.isReactWarning) return !1;
128
+ function c(r) {
129
+ if (G.call(r, "key")) {
130
+ var l = Object.getOwnPropertyDescriptor(r, "key").get;
131
+ if (l && l.isReactWarning) return !1;
132
132
  }
133
- return o.key !== void 0;
133
+ return r.key !== void 0;
134
134
  }
135
- function l(o, a) {
136
- function m() {
137
- A || (A = !0, console.error(
135
+ function u(r, l) {
136
+ function d() {
137
+ J || (J = !0, console.error(
138
138
  "%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)",
139
- a
139
+ l
140
140
  ));
141
141
  }
142
- m.isReactWarning = !0, Object.defineProperty(o, "key", {
143
- get: m,
142
+ d.isReactWarning = !0, Object.defineProperty(r, "key", {
143
+ get: d,
144
144
  configurable: !0
145
145
  });
146
146
  }
147
147
  function f() {
148
- var o = e(this.type);
149
- return O[o] || (O[o] = !0, console.error(
148
+ var r = e(this.type);
149
+ return a[r] || (a[r] = !0, console.error(
150
150
  "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
- )), o = this.props.ref, o !== void 0 ? o : null;
151
+ )), r = this.props.ref, r !== void 0 ? r : null;
152
152
  }
153
- function h(o, a, m, k, P, I, fe, de) {
154
- return m = I.ref, o = {
155
- $$typeof: S,
156
- type: o,
157
- key: a,
158
- props: I,
159
- _owner: P
160
- }, (m !== void 0 ? m : null) !== null ? Object.defineProperty(o, "ref", {
153
+ function m(r, l, d, g, R, w, de, Ee) {
154
+ return d = w.ref, r = {
155
+ $$typeof: j,
156
+ type: r,
157
+ key: l,
158
+ props: w,
159
+ _owner: R
160
+ }, (d !== void 0 ? d : null) !== null ? Object.defineProperty(r, "ref", {
161
161
  enumerable: !1,
162
162
  get: f
163
- }) : Object.defineProperty(o, "ref", { enumerable: !1, value: null }), o._store = {}, Object.defineProperty(o._store, "validated", {
163
+ }) : Object.defineProperty(r, "ref", { enumerable: !1, value: null }), r._store = {}, Object.defineProperty(r._store, "validated", {
164
164
  configurable: !1,
165
165
  enumerable: !1,
166
166
  writable: !0,
167
167
  value: 0
168
- }), Object.defineProperty(o, "_debugInfo", {
168
+ }), Object.defineProperty(r, "_debugInfo", {
169
169
  configurable: !1,
170
170
  enumerable: !1,
171
171
  writable: !0,
172
172
  value: null
173
- }), Object.defineProperty(o, "_debugStack", {
173
+ }), Object.defineProperty(r, "_debugStack", {
174
174
  configurable: !1,
175
175
  enumerable: !1,
176
176
  writable: !0,
177
- value: fe
178
- }), Object.defineProperty(o, "_debugTask", {
177
+ value: de
178
+ }), Object.defineProperty(r, "_debugTask", {
179
179
  configurable: !1,
180
180
  enumerable: !1,
181
181
  writable: !0,
182
- value: de
183
- }), Object.freeze && (Object.freeze(o.props), Object.freeze(o)), o;
182
+ value: Ee
183
+ }), Object.freeze && (Object.freeze(r.props), Object.freeze(r)), r;
184
184
  }
185
- function N(o, a, m, k, P, I, fe, de) {
186
- var b = a.children;
187
- if (b !== void 0)
188
- if (k)
189
- if (E(b)) {
190
- for (k = 0; k < b.length; k++)
191
- le(b[k]);
192
- Object.freeze && Object.freeze(b);
185
+ function N(r, l, d, g, R, w, de, Ee) {
186
+ var k = l.children;
187
+ if (k !== void 0)
188
+ if (g)
189
+ if (fe(k)) {
190
+ for (g = 0; g < k.length; g++)
191
+ p(k[g]);
192
+ Object.freeze && Object.freeze(k);
193
193
  } else
194
194
  console.error(
195
195
  "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
196
196
  );
197
- else le(b);
198
- if (d.call(a, "key")) {
199
- b = e(o);
200
- var D = Object.keys(a).filter(function(Be) {
201
- return Be !== "key";
197
+ else p(k);
198
+ if (G.call(l, "key")) {
199
+ k = e(r);
200
+ var P = Object.keys(l).filter(function(Le) {
201
+ return Le !== "key";
202
202
  });
203
- k = 0 < D.length ? "{key: someKey, " + D.join(": ..., ") + ": ...}" : "{key: someKey}", p[b + k] || (D = 0 < D.length ? "{" + D.join(": ..., ") + ": ...}" : "{}", console.error(
203
+ g = 0 < P.length ? "{key: someKey, " + P.join(": ..., ") + ": ...}" : "{key: someKey}", h[k + g] || (P = 0 < P.length ? "{" + P.join(": ..., ") + ": ...}" : "{}", console.error(
204
204
  `A props object containing a "key" prop is being spread into JSX:
205
205
  let props = %s;
206
206
  <%s {...props} />
207
207
  React keys must be passed directly to JSX without using spread:
208
208
  let props = %s;
209
209
  <%s key={someKey} {...props} />`,
210
+ g,
210
211
  k,
211
- b,
212
- D,
213
- b
214
- ), p[b + k] = !0);
212
+ P,
213
+ k
214
+ ), h[k + g] = !0);
215
215
  }
216
- if (b = null, m !== void 0 && (r(m), b = "" + m), c(a) && (r(a.key), b = "" + a.key), "key" in a) {
217
- m = {};
218
- for (var Ee in a)
219
- Ee !== "key" && (m[Ee] = a[Ee]);
220
- } else m = a;
221
- return b && l(
222
- m,
223
- typeof o == "function" ? o.displayName || o.name || "Unknown" : o
224
- ), h(
225
- o,
226
- b,
227
- I,
228
- P,
229
- n(),
230
- m,
231
- fe,
232
- de
216
+ if (k = null, d !== void 0 && (n(d), k = "" + d), c(l) && (n(l.key), k = "" + l.key), "key" in l) {
217
+ d = {};
218
+ for (var he in l)
219
+ he !== "key" && (d[he] = l[he]);
220
+ } else d = l;
221
+ return k && u(
222
+ d,
223
+ typeof r == "function" ? r.displayName || r.name || "Unknown" : r
224
+ ), m(
225
+ r,
226
+ k,
227
+ w,
228
+ R,
229
+ o(),
230
+ d,
231
+ de,
232
+ Ee
233
233
  );
234
234
  }
235
- function le(o) {
236
- typeof o == "object" && o !== null && o.$$typeof === S && o._store && (o._store.validated = 1);
235
+ function p(r) {
236
+ typeof r == "object" && r !== null && r.$$typeof === j && r._store && (r._store.validated = 1);
237
237
  }
238
- var j = C, S = Symbol.for("react.transitional.element"), T = Symbol.for("react.portal"), L = Symbol.for("react.fragment"), U = Symbol.for("react.strict_mode"), F = Symbol.for("react.profiler"), V = Symbol.for("react.consumer"), ue = Symbol.for("react.context"), v = Symbol.for("react.forward_ref"), M = Symbol.for("react.suspense"), z = Symbol.for("react.suspense_list"), G = Symbol.for("react.memo"), X = Symbol.for("react.lazy"), ae = Symbol.for("react.activity"), u = Symbol.for("react.client.reference"), g = j.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, d = Object.prototype.hasOwnProperty, E = Array.isArray, R = console.createTask ? console.createTask : function() {
238
+ var C = A, j = Symbol.for("react.transitional.element"), v = 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"), S = Symbol.for("react.memo"), I = Symbol.for("react.lazy"), z = Symbol.for("react.activity"), V = Symbol.for("react.client.reference"), M = C.__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
239
  return null;
240
240
  };
241
- j = {
242
- react_stack_bottom_frame: function(o) {
243
- return o();
241
+ C = {
242
+ react_stack_bottom_frame: function(r) {
243
+ return r();
244
244
  }
245
245
  };
246
- var A, O = {}, y = j.react_stack_bottom_frame.bind(
247
- j,
246
+ var J, a = {}, _ = C.react_stack_bottom_frame.bind(
247
+ C,
248
248
  i
249
- )(), _ = R(s(i)), p = {};
250
- x.Fragment = L, x.jsx = function(o, a, m, k, P) {
251
- var I = 1e4 > g.recentlyCreatedOwnerStacks++;
249
+ )(), E = T(s(i)), h = {};
250
+ D.Fragment = O, D.jsx = function(r, l, d, g, R) {
251
+ var w = 1e4 > M.recentlyCreatedOwnerStacks++;
252
252
  return N(
253
- o,
254
- a,
255
- m,
253
+ r,
254
+ l,
255
+ d,
256
256
  !1,
257
- k,
258
- P,
259
- I ? Error("react-stack-top-frame") : y,
260
- I ? R(s(o)) : _
257
+ g,
258
+ R,
259
+ w ? Error("react-stack-top-frame") : _,
260
+ w ? T(s(r)) : E
261
261
  );
262
- }, x.jsxs = function(o, a, m, k, P) {
263
- var I = 1e4 > g.recentlyCreatedOwnerStacks++;
262
+ }, D.jsxs = function(r, l, d, g, R) {
263
+ var w = 1e4 > M.recentlyCreatedOwnerStacks++;
264
264
  return N(
265
- o,
266
- a,
267
- m,
265
+ r,
266
+ l,
267
+ d,
268
268
  !0,
269
- k,
270
- P,
271
- I ? Error("react-stack-top-frame") : y,
272
- I ? R(s(o)) : _
269
+ g,
270
+ R,
271
+ w ? Error("react-stack-top-frame") : _,
272
+ w ? T(s(r)) : E
273
273
  );
274
274
  };
275
- })()), x;
275
+ })()), D;
276
276
  }
277
- var Oe;
277
+ var Ie;
278
278
  function Ke() {
279
- return Oe || (Oe = 1, process.env.NODE_ENV === "production" ? J.exports = Ye() : J.exports = We()), J.exports;
279
+ return Ie || (Ie = 1, process.env.NODE_ENV === "production" ? X.exports = Fe() : X.exports = We()), X.exports;
280
280
  }
281
- var Ue = Ke();
282
- const Ie = () => {
281
+ var y = Ke();
282
+ const ye = () => {
283
283
  const e = window.getSelection(), t = document.getElementById("entity-editor");
284
284
  if (!e || !t) return { start: 0, end: 0 };
285
285
  if (e.anchorNode && t.contains(e.anchorNode)) {
286
- const r = e.getRangeAt(0), s = r.cloneRange();
287
- s.selectNodeContents(t), s.setEnd(r.startContainer, r.startOffset);
288
- const n = s.toString().length, i = r.cloneRange();
289
- i.selectNodeContents(t), i.setEnd(r.endContainer, r.endOffset);
286
+ const n = e.getRangeAt(0), s = n.cloneRange();
287
+ s.selectNodeContents(t), s.setEnd(n.startContainer, n.startOffset);
288
+ const o = s.toString().length, i = n.cloneRange();
289
+ i.selectNodeContents(t), i.setEnd(n.endContainer, n.endOffset);
290
290
  const c = i.toString().length;
291
- return { start: n, end: c };
291
+ return { start: o, end: c };
292
292
  } else
293
293
  return null;
294
- }, Fe = (e, t) => {
295
- const r = document.createTreeWalker(e, NodeFilter.SHOW_TEXT);
296
- let s = 0, n = r.nextNode(), i = null, c = null, l = 0, f = 0;
297
- for (; n; ) {
298
- const h = s + (n.textContent?.length || 0);
299
- if (!i && h >= t.start && (i = n, l = t.start - s), !c && h >= t.end) {
300
- c = n, f = t.end - s;
294
+ }, Ue = (e, t) => {
295
+ const n = document.createTreeWalker(e, NodeFilter.SHOW_TEXT);
296
+ let s = 0, o = n.nextNode(), i = null, c = null, u = 0, f = 0;
297
+ for (; o; ) {
298
+ const m = s + (o.textContent?.length || 0);
299
+ if (!i && m >= t.start && (i = o, u = t.start - s), !c && m >= t.end) {
300
+ c = o, f = t.end - s;
301
301
  break;
302
302
  }
303
- s = h, n = r.nextNode();
303
+ s = m, o = n.nextNode();
304
304
  }
305
305
  if (i && c) {
306
- const h = document.createRange();
307
- h.setStart(
306
+ const m = document.createRange();
307
+ m.setStart(
308
308
  i,
309
- Math.min(l, i.textContent?.length || 0)
310
- ), h.setEnd(
309
+ Math.min(u, i.textContent?.length || 0)
310
+ ), m.setEnd(
311
311
  c,
312
312
  Math.min(f, c.textContent?.length || 0)
313
313
  );
314
314
  const N = window.getSelection();
315
- N?.removeAllRanges(), N?.addRange(h);
315
+ N?.removeAllRanges(), N?.addRange(m);
316
316
  }
317
- }, Ve = (e, t, r) => {
318
- let s = "", n = "", i = "", c = "";
319
- t.includes("bold") && (n = "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" && r.mentionColor ? s = r.mentionColor : e === "interest" && r.interestColor ? s = r.interestColor : e === "link" && r.linkColor && (s = r.linkColor));
320
- let l = "";
321
- return s && (l += `color: ${s}; `), n && (l += `font-weight: ${n}; `), i && (l += `font-style: ${i}; `), c && (l += `text-decoration: ${c}; `), l;
322
- }, Ce = (e, t, r) => {
317
+ }, ze = (e, t, n) => {
318
+ let s = "", o = "", i = "", c = "";
319
+ 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
+ let u = "";
321
+ return s && (u += `color: ${s}; `), o && (u += `font-weight: ${o}; `), i && (u += `font-style: ${i}; `), c && (u += `text-decoration: ${c}; `), u;
322
+ }, Ce = (e, t, n) => {
323
323
  if (t.length === 0)
324
324
  return e;
325
- let s = "", n = 0;
325
+ let s = "", o = 0;
326
326
  return t.forEach((i) => {
327
- n < i.startIndex && (s += e.slice(n, i.startIndex));
328
- const c = e.slice(i.startIndex, i.endIndex), l = Ve(i.type, i.marks, r);
329
- s += `<span style="${l}">${c}</span>`, n = i.endIndex;
330
- }), s += e.slice(n), s;
331
- }, ze = (e, t) => {
332
- let r = !1;
333
- e.key === "Enter" && !e.shiftKey ? (e.preventDefault(), document.execCommand("insertLineBreak"), r = !0) : (e.metaKey || e.ctrlKey) && (e.key === "b" ? (t("bold"), r = !0) : e.key === "i" ? (t("italic"), r = !0) : e.key === "u" ? (t("underline"), r = !0) : e.key === "s" && (t("strike"), r = !0)), r && e.preventDefault();
334
- }, ee = 128, Ge = /^(?<protocol>[a-z\-]+)?:?(?<host>\/\/.*\.[^\/]+)$/, Xe = "()[]{}", pe = "", Me = (e, t) => {
335
- const r = Se(
327
+ o < i.startIndex && (s += e.slice(o, i.startIndex));
328
+ const c = e.slice(i.startIndex, i.endIndex), u = ze(i.type, i.marks, n);
329
+ s += `<span style="${u}">${c}</span>`, o = i.endIndex;
330
+ }), s += e.slice(o), s;
331
+ }, Ve = (e, t) => {
332
+ let n = !1;
333
+ e.key === "Enter" && !e.shiftKey ? (e.preventDefault(), document.execCommand("insertLineBreak"), n = !0) : (e.metaKey || e.ctrlKey) && (e.key === "b" ? (t("bold"), n = !0) : e.key === "i" ? (t("italic"), n = !0) : e.key === "u" ? (t("underline"), n = !0) : e.key === "s" && (t("strike"), n = !0)), n && e.preventDefault();
334
+ }, ee = 128, Ge = "()[]{}", Te = "", Je = new RegExp(
335
+ "^(?:(?:(?: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*)?$",
336
+ "i"
337
+ ), xe = (e, t) => {
338
+ const n = ve(
336
339
  e,
337
340
  t,
338
- Xe,
339
- pe
341
+ Ge,
342
+ Te
340
343
  );
341
- return r?.search.match(Ge) ? {
344
+ return n?.search.match(Je) ? {
342
345
  type: "link",
343
- ...r
346
+ ...n
344
347
  } : null;
345
- }, te = (e) => (e & ee) !== 0, ge = (e, t) => t ? e | ee : e & ~ee, re = 32, Je = /^@[a-zA-Z0-9_'-]+$/, qe = `.,!?;()[]{}"'<>#`, ne = "@", De = (e, t) => {
346
- const r = Se(
348
+ }, te = (e) => (e & ee) !== 0, Re = (e, t) => t ? e | ee : e & ~ee, re = 32, Xe = /^@[a-zA-Z0-9_'-]+$/, qe = `.,!?;()[]{}"'<>#`, ne = "@", De = (e, t) => {
349
+ const n = ve(
347
350
  e,
348
351
  t,
349
352
  qe,
350
353
  ne
351
354
  );
352
- return r?.search.match(Je) ? {
355
+ return n?.search.match(Xe) ? {
353
356
  type: "mention",
354
- ...r
357
+ ...n
355
358
  } : null;
356
- }, oe = (e) => (e & re) !== 0, Re = (e, t) => t ? e | re : e & ~re, $ = 2, q = (e) => (e & $) !== 0, _e = (e, t) => t ? e | $ : e & ~$, Y = 4, H = (e) => (e & Y) !== 0, ke = (e, t) => t ? e | Y : e & ~Y, W = 16, Z = (e) => (e & W) !== 0, be = (e, t) => t ? e | W : e & ~W, K = 8, Q = (e) => (e & K) !== 0, we = (e, t) => t ? e | K : e & ~K, ye = (e, t) => {
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, L = 4, H = (e) => (e & L) !== 0, be = (e, t) => t ? e | L : e & ~L, $ = 16, Z = (e) => (e & $) !== 0, Se = (e, t) => t ? e | $ : e & ~$, Y = 8, Q = (e) => (e & Y) !== 0, we = (e, t) => t ? e | Y : e & ~Y, je = (e, t) => {
357
360
  if (e === t) return null;
358
- let r = 0;
359
- for (; r < e.length && r < t.length && e[r] === t[r]; )
360
- r++;
361
- let s = e.length, n = t.length;
362
- for (; s > r && n > r && e[s - 1] === t[n - 1]; )
363
- s--, n--;
361
+ let n = 0;
362
+ for (; n < e.length && n < t.length && e[n] === t[n]; )
363
+ n++;
364
+ let s = e.length, o = t.length;
365
+ for (; s > n && o > n && e[s - 1] === t[o - 1]; )
366
+ s--, o--;
364
367
  return {
365
- position: r,
366
- deletedLength: s - r,
367
- insertedText: t.slice(r, n)
368
+ position: n,
369
+ deletedLength: s - n,
370
+ insertedText: t.slice(n, o)
368
371
  };
369
- }, me = (e, t, r, s) => {
370
- let n = t;
371
- for (; n < e.length; ) {
372
- const c = w(e, n);
373
- if (r(c))
374
- e[n] = s(c, !1);
372
+ }, ge = (e, t, n, s) => {
373
+ let o = t;
374
+ for (; o < e.length; ) {
375
+ const c = b(e, o);
376
+ if (n(c))
377
+ e[o] = s(c, !1);
375
378
  else
376
379
  break;
377
- n++;
380
+ o++;
378
381
  }
379
382
  let i = t - 1;
380
383
  for (; i >= 0; ) {
381
- const c = w(e, i);
382
- if (r(c))
384
+ const c = b(e, i);
385
+ if (n(c))
383
386
  e[i] = s(c, !1);
384
387
  else
385
388
  break;
386
389
  i--;
387
390
  }
388
391
  return e;
389
- }, Pe = (e, t, r) => {
392
+ }, Pe = (e, t, n) => {
390
393
  if (!t) return e;
391
- const { position: s, deletedLength: n, insertedText: i } = t, c = i.length;
392
- let l = [...e];
393
- const f = w(l, s);
394
- if (oe(f) ? l = me(l, s, oe, Re) : ce(f) ? l = me(l, s, ce, ve) : te(f) && (l = me(l, s, te, ge)), n > 0 && l.splice(s, n), c > 0) {
395
- let h = 0;
396
- r.bold && (h = _e(h, !0)), r.italic && (h = ke(h, !0)), r.underline && (h = we(h, !0)), r.strike && (h = be(h, !0));
397
- const N = new Array(c).fill(h);
398
- l.splice(s, 0, ...N);
394
+ const { position: s, deletedLength: o, insertedText: i } = t, c = i.length;
395
+ let u = [...e];
396
+ const f = b(u, s);
397
+ 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
+ let m = 0;
399
+ n.bold && (m = ke(m, !0)), n.italic && (m = be(m, !0)), n.underline && (m = we(m, !0)), n.strike && (m = Se(m, !0));
400
+ const N = new Array(c).fill(m);
401
+ u.splice(s, 0, ...N);
399
402
  }
400
- return l;
401
- }, He = (e) => /\s/.test(e) || /[\u2000-\u200B\u2028\u2029\u3000]/.test(e), Se = (e, t, r, s) => {
403
+ return u;
404
+ }, He = (e) => /\s/.test(e) || /[\u2000-\u200B\u2028\u2029\u3000]/.test(e), ve = (e, t, n, s) => {
402
405
  if (t <= 0 || t > e.length)
403
406
  return null;
404
- let n = "", i = t - 1, c = t;
405
- const l = (f) => He(f) || r.includes(f);
407
+ let o = "", i = t - 1, c = t;
408
+ const u = (f) => He(f) || n.includes(f);
406
409
  for (let f = i; f >= 0; f--) {
407
- if (l(e[f])) {
410
+ if (u(e[f])) {
408
411
  i = f + 1;
409
412
  break;
410
413
  }
411
- f === 0 && (i = 0), n = e[f] + n;
414
+ f === 0 && (i = 0), o = e[f] + o;
412
415
  }
413
416
  for (let f = c; f < e.length; f++) {
414
- if (l(e[f])) {
417
+ if (u(e[f])) {
415
418
  c = f;
416
419
  break;
417
420
  }
@@ -419,93 +422,93 @@ const Ie = () => {
419
422
  c = f;
420
423
  break;
421
424
  }
422
- f === e.length - 1 && (c = e.length), n = n + e[f];
425
+ f === e.length - 1 && (c = e.length), o = o + e[f];
423
426
  }
424
427
  return {
425
428
  search: e.slice(i, c),
426
429
  startIndex: i,
427
430
  endIndex: c
428
431
  };
429
- }, se = 64, Ze = `.,!?;()[]{}"'<>@`, Qe = /^#[\w-]+$/, ie = "#", Le = (e, t) => {
430
- const r = Se(
432
+ }, se = 64, Ze = `.,!?;()[]{}"'<>@`, Qe = /^#[\w-]+$/, ie = "#", Be = (e, t) => {
433
+ const n = ve(
431
434
  e,
432
435
  t,
433
436
  Ze,
434
437
  ie
435
438
  );
436
- return r?.search.match(Qe) ? {
439
+ return n?.search.match(Qe) ? {
437
440
  type: "interest",
438
- ...r
441
+ ...n
439
442
  } : null;
440
- }, ce = (e) => (e & se) !== 0, ve = (e, t) => t ? e | se : e & ~se, et = (e, t) => e.find(
441
- (r) => r.startIndex <= t && r.endIndex > t
442
- ), tt = (e, t, r) => {
443
+ }, ce = (e) => (e & se) !== 0, Ne = (e, t) => t ? e | se : e & ~se, et = (e, t) => e.find(
444
+ (n) => n.startIndex <= t && n.endIndex > t
445
+ ), tt = (e, t, n) => {
443
446
  const s = [];
444
- let n = 0;
445
- for (; n < t.length; ) {
446
- const i = w(t, n);
447
+ let o = 0;
448
+ for (; o < t.length; ) {
449
+ const i = b(t, o);
447
450
  if (i === 0 || i === 1) {
448
- n++;
451
+ o++;
449
452
  continue;
450
453
  }
451
- const c = n;
452
- let l = n;
453
- for (; l + 1 < t.length && w(t, l + 1) === i; )
454
- l++;
455
- const f = rt(i, r), h = nt(i), N = {
454
+ const c = o;
455
+ let u = o;
456
+ for (; u + 1 < t.length && b(t, u + 1) === i; )
457
+ u++;
458
+ const f = rt(i, n), m = nt(i), N = {
456
459
  type: f,
457
460
  startIndex: c,
458
- endIndex: l + 1,
459
- marks: h,
460
- username: f === "mention" ? De(e, l)?.search.replace(ne, "") : void 0,
461
- interest: f === "interest" ? Le(e, l)?.search.replace(
461
+ endIndex: u + 1,
462
+ marks: m,
463
+ username: f === "mention" ? De(e, u)?.search.replace(ne, "") : void 0,
464
+ interest: f === "interest" ? Be(e, u)?.search.replace(
462
465
  ie,
463
466
  ""
464
467
  ) : void 0,
465
- href: f === "link" ? Me(e, c)?.search : void 0
468
+ href: f === "link" ? xe(e, u)?.search : void 0
466
469
  };
467
- s.push(N), n = l + 1;
470
+ s.push(N), o = u + 1;
468
471
  }
469
472
  return s;
470
- }, rt = (e, t) => e & re && t.mentions ? "mention" : e & se && t.interests ? "interest" : e & ee && t.links ? "link" : (e & ($ | Y | K | W), "segment"), nt = (e) => {
473
+ }, rt = (e, t) => e & re && t.mentions ? "mention" : e & se && t.interests ? "interest" : e & ee && t.links ? "link" : (e & (B | L | Y | $), "segment"), nt = (e) => {
471
474
  const t = [];
472
- return e & $ && t.push("bold"), e & Y && t.push("italic"), e & K && t.push("underline"), e & W && t.push("strike"), t;
473
- }, w = (e, t) => {
474
- const r = e[t];
475
- return typeof r != "number" ? 0 : r;
476
- }, ot = (e, t, r) => {
477
- const s = w(e, t);
478
- switch (r) {
475
+ return e & B && t.push("bold"), e & L && t.push("italic"), e & Y && t.push("underline"), e & $ && t.push("strike"), t;
476
+ }, b = (e, t) => {
477
+ const n = e[t];
478
+ return typeof n != "number" ? 0 : n;
479
+ }, ot = (e, t, n) => {
480
+ const s = b(e, t);
481
+ switch (n) {
479
482
  case "mention":
480
- return Re(s, !0);
483
+ return _e(s, !0);
481
484
  case "interest":
482
- return ve(s, !0);
485
+ return Ne(s, !0);
483
486
  case "link":
484
- return ge(s, !0);
487
+ return Re(s, !0);
485
488
  }
486
489
  return s;
487
- }, st = (e, t, r, s) => {
488
- let n = w(e, t);
489
- switch (r) {
490
+ }, st = (e, t, n, s) => {
491
+ let o = b(e, t);
492
+ switch (n) {
490
493
  case "bold":
491
- n = _e(n, s);
494
+ o = ke(o, s);
492
495
  break;
493
496
  case "italic":
494
- n = ke(n, s);
497
+ o = be(o, s);
495
498
  break;
496
499
  case "underline":
497
- n = we(n, s);
500
+ o = we(o, s);
498
501
  break;
499
502
  case "strike":
500
- n = be(n, s);
503
+ o = Se(o, s);
501
504
  break;
502
505
  default:
503
506
  return e;
504
507
  }
505
- return e[t] = n, e;
506
- }, it = (e, t, r) => {
507
- const s = w(e, t);
508
- switch (r) {
508
+ return e[t] = o, e;
509
+ }, it = (e, t, n) => {
510
+ const s = b(e, t);
511
+ switch (n) {
509
512
  case "bold":
510
513
  return q(s);
511
514
  case "italic":
@@ -515,160 +518,195 @@ const Ie = () => {
515
518
  case "strike":
516
519
  return Z(s);
517
520
  default:
518
- throw Error(`Invalid mark type: ${r}`);
521
+ throw Error(`Invalid mark type: ${n}`);
519
522
  }
520
- }, ct = (e, t, r, s) => {
521
- for (let n = e; n < t; n++)
522
- if (!it(s, n, r)) return !1;
523
+ }, ct = (e, t, n, s) => {
524
+ for (let o = e; o < t; o++)
525
+ if (!it(s, o, n)) return !1;
523
526
  return !0;
524
- }, je = (e) => oe(e) || ce(e) || te(e), lt = (e, t, r, s) => {
525
- let n = [...e];
526
- for (; je(w(e, t - 1)) && t > 0; )
527
+ }, pe = (e) => oe(e) || ce(e) || te(e), lt = (e, t, n, s) => {
528
+ let o = [...e];
529
+ for (; pe(b(e, t - 1)) && t > 0; )
527
530
  t--;
528
- for (; je(w(e, r)) && r < e.length; )
529
- r++;
531
+ for (; pe(b(e, n)) && n < e.length; )
532
+ n++;
530
533
  let i = !0;
531
- ct(t, r, s, n) && (i = !1);
532
- for (let c = t; c < r; c++)
533
- n = st(n, c, s, i);
534
- return n;
535
- }, Te = (e, t) => {
536
- const r = new Array(e.length).fill(0);
534
+ ct(t, n, s, o) && (i = !1);
535
+ for (let c = t; c < n; c++)
536
+ o = st(o, c, s, i);
537
+ return o;
538
+ }, Me = (e, t) => {
539
+ const n = new Array(e.length).fill(0);
537
540
  for (let s = 0; s < e.length; s++) {
538
- let n = 0;
541
+ let o = 0;
539
542
  const i = et(t, s);
540
543
  if (i) {
541
- i.type === "mention" ? n = Re(n, !0) : i.type === "interest" ? n = ve(n, !0) : i.type === "link" && (n = ge(n, !0));
544
+ i.type === "mention" ? o = _e(o, !0) : i.type === "interest" ? o = Ne(o, !0) : i.type === "link" && (o = Re(o, !0));
542
545
  for (const c of i.marks)
543
- c === "bold" ? n = _e(n, !0) : c === "italic" ? n = ke(n, !0) : c === "underline" ? n = we(n, !0) : c === "strike" && (n = be(n, !0));
546
+ c === "bold" ? o = ke(o, !0) : c === "italic" ? o = be(o, !0) : c === "underline" ? o = we(o, !0) : c === "strike" && (o = Se(o, !0));
544
547
  }
545
- r[s] = n;
548
+ n[s] = o;
546
549
  }
547
- return r;
548
- }, ut = (e, t, r) => {
549
- const [s, n] = xe(e), i = he(Date.now()), c = he(null), l = he(null);
550
- return $e(() => (c.current && clearTimeout(c.current), l.current && clearTimeout(l.current), Date.now() - i.current, c.current = setTimeout(() => {
551
- n(e), i.current = Date.now();
550
+ return n;
551
+ }, ut = (e, t, n) => {
552
+ const [s, o] = $e(e), i = me(Date.now()), c = me(null), u = me(null);
553
+ return Ye(() => (c.current && clearTimeout(c.current), u.current && clearTimeout(u.current), Date.now() - i.current, c.current = setTimeout(() => {
554
+ o(e), i.current = Date.now();
552
555
  }, t), () => {
553
- c.current && clearTimeout(c.current), l.current && clearTimeout(l.current);
554
- }), [e, t, r]), s;
556
+ c.current && clearTimeout(c.current), u.current && clearTimeout(u.current);
557
+ }), [e, t, n]), s;
555
558
  }, ft = ({
556
559
  ref: e,
557
560
  plainText: t = "",
558
- setPlainText: r,
561
+ setPlainText: n,
559
562
  entities: s = [],
560
- setEntities: n,
563
+ setEntities: o,
561
564
  markState: i,
562
565
  setMarkState: c,
563
- search: l,
566
+ search: u,
564
567
  setSearch: f,
565
- options: h = {},
568
+ options: m = {},
566
569
  entityStyles: N = {},
567
- debug: le = !1,
570
+ placeholder: p = "",
571
+ debug: C = !1,
568
572
  ...j
569
573
  }) => {
570
- const S = C.useRef(null), [T, L] = C.useState({ start: 0, end: 0 }), [U, F] = C.useState(!1), [V, ue] = C.useState(!1), [v, M] = C.useState(
571
- Te(t, s)
574
+ const v = 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), [S, I] = A.useState(
575
+ Me(t, s)
572
576
  );
573
577
  e.current = {
574
- selectEntity: (u, g, d, E) => {
575
- if (!S.current) return;
576
- let R = [...v];
577
- u === "mention" ? E = ne + E : u === "interest" ? E = ie + E : u === "link" && (E = pe + E);
578
- const A = t.slice(0, g) + E + t.slice(d), O = ye(t, A);
579
- O ? R = Pe(v, O, i) : R = Te(A, s);
580
- for (let y = g; y < g + E.length; y++)
581
- R[y] = ot(R, y, u);
582
- r(A), M(R), f(null);
578
+ selectEntity: (a, _, E, h) => {
579
+ if (!v.current) return;
580
+ let r = [...S];
581
+ a === "mention" ? h = ne + h : a === "interest" ? h = ie + h : a === "link" && (h = Te + h);
582
+ const l = t.slice(0, _) + h + t.slice(E), d = je(t, l);
583
+ d ? r = Pe(S, d, i) : r = Me(l, s);
584
+ for (let g = _; g < _ + h.length; g++)
585
+ r[g] = ot(r, g, a);
586
+ n(l), I(r), f(null);
583
587
  },
584
- toggleMark: (u) => {
585
- G(u);
588
+ toggleMark: (a) => {
589
+ V(a);
590
+ },
591
+ clear: () => {
592
+ n(""), I([]), o([]);
586
593
  }
587
- }, C.useEffect(() => {
588
- if (S.current) {
589
- S.current.textContent = t;
590
- const u = Ce(t, s, N);
591
- S.current.innerHTML = u, V || ue(!0);
594
+ }, A.useEffect(() => {
595
+ if (v.current) {
596
+ v.current.textContent = t;
597
+ const a = Ce(t, s, N);
598
+ v.current.innerHTML = a, K || ue(!0);
592
599
  }
593
- }, []), C.useEffect(() => {
594
- if (!S.current) return;
595
- const u = tt(t, v, h), g = Ie() ?? T, d = Ce(t, u, N);
596
- S.current.innerHTML = d, n(u), V && Fe(S.current, g);
597
- }, [v]);
598
- const z = ut(T, 500);
599
- C.useEffect(() => {
600
- let { start: u, end: g } = z, d = null;
601
- if (!d && !oe(w(v, u - 1)) && (d = De(t, u), d && (d.search = d.search.replace(ne, ""))), !d && !ce(w(v, u - 1)) && (d = Le(t, u), d && (d.search = d.search.replace(ie, ""))), !d && !te(w(v, u - 1)) && (d = Me(t, u)), d ? f(d) : l && f(null), U) return;
602
- let E = !0, R = !0, A = !0, O = !0;
603
- if (u === g)
604
- if (u > 0) {
605
- const _ = w(v, u - 1);
606
- E = q(_), R = H(_), A = Q(_), O = Z(_);
600
+ }, []), A.useEffect(() => {
601
+ if (!v.current) return;
602
+ const a = tt(t, S, m), _ = ye() ?? O, E = Ce(t, a, N);
603
+ v.current.innerHTML = E, o(a), K && Ue(v.current, _);
604
+ }, [S]);
605
+ const z = ut(O, 500);
606
+ A.useEffect(() => {
607
+ let { start: a, end: _ } = z, E = null;
608
+ if (!E && !oe(b(S, a - 1)) && (E = De(t, a), E && (E.search = E.search.replace(ne, ""))), !E && !ce(b(S, a - 1)) && (E = Be(t, a), E && (E.search = E.search.replace(ie, ""))), !E && !te(b(S, a - 1)) && (E = xe(t, a)), E ? f(E) : u && f(null), F) return;
609
+ let h = !0, r = !0, l = !0, d = !0;
610
+ if (a === _)
611
+ if (a > 0) {
612
+ const R = b(S, a - 1);
613
+ h = q(R), r = H(R), l = Q(R), d = Z(R);
607
614
  } else {
608
- const _ = w(v, u);
609
- E = q(_), R = H(_), A = Q(_), O = Z(_);
615
+ const R = b(S, a);
616
+ h = q(R), r = H(R), l = Q(R), d = Z(R);
610
617
  }
611
618
  else
612
- for (let _ = u; _ < g; _++) {
613
- const p = w(v, _);
614
- E = q(p) ? E : !1, R = H(p) ? R : !1, A = Q(p) ? A : !1, O = Z(p) ? O : !1;
619
+ for (let R = a; R < _; R++) {
620
+ const w = b(S, R);
621
+ h = q(w) ? h : !1, r = H(w) ? r : !1, l = Q(w) ? l : !1, d = Z(w) ? d : !1;
615
622
  }
616
623
  c({
617
- bold: E,
618
- italic: R,
619
- underline: A,
620
- strike: O
624
+ bold: h,
625
+ italic: r,
626
+ underline: l,
627
+ strike: d
621
628
  });
622
629
  }, [z]);
623
- const G = (u) => {
624
- if (F(!0), !S.current)
630
+ const V = (a) => {
631
+ if (W(!0), !v.current)
625
632
  return;
626
- const { start: g, end: d } = T;
627
- if (g !== d) {
628
- const R = lt(v, g, d, u);
629
- M(R);
633
+ const { start: _, end: E } = O;
634
+ if (_ !== E) {
635
+ const r = lt(S, _, E, a);
636
+ I(r);
630
637
  }
631
- const E = { ...i };
632
- u === "bold" ? E.bold = !i.bold : u === "italic" ? E.italic = !i.italic : u === "underline" ? E.underline = !i.underline : u === "strike" && (E.strike = !i.strike), c(E);
633
- }, X = (u) => {
634
- if (!S.current) return;
635
- if (U && F(!1), u.target.textContent.length === 0) {
636
- r(""), M([]), n([]);
638
+ const h = { ...i };
639
+ 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
+ }, M = (a) => {
641
+ if (!v.current) return;
642
+ if (F && W(!1), a.target.textContent.length === 0) {
643
+ n(""), I([]), o([]);
637
644
  return;
638
645
  }
639
- const g = u.target.innerText || "", d = ye(t, g);
640
- if (d) {
641
- const E = Pe(
642
- v,
643
- d,
646
+ const _ = a.target.innerText || "", E = je(t, _);
647
+ if (E) {
648
+ const h = Pe(
649
+ S,
650
+ E,
644
651
  i
645
652
  );
646
- M(E);
653
+ I(h);
647
654
  }
648
- r(g);
649
- }, ae = (u) => {
650
- S.current && ze(u, G);
655
+ n(_);
656
+ }, G = (a) => {
657
+ v.current && Ve(a, V);
658
+ }, fe = () => {
659
+ U(!0);
660
+ }, T = () => {
661
+ U(!1);
651
662
  };
652
- return C.useEffect(() => {
653
- const u = () => {
654
- const g = Ie() ?? { start: 0, end: 0 };
655
- (g.start !== T.start || g.end !== T.end) && L(g);
663
+ A.useEffect(() => {
664
+ const a = () => {
665
+ const _ = ye() ?? { start: 0, end: 0 };
666
+ (_.start !== O.start || _.end !== O.end) && le(_);
656
667
  };
657
- return document.addEventListener("selectionchange", u), () => {
658
- document.removeEventListener("selectionchange", u);
668
+ return document.addEventListener("selectionchange", a), () => {
669
+ document.removeEventListener("selectionchange", a);
659
670
  };
660
- }, []), /* @__PURE__ */ Ue.jsx(
661
- "div",
662
- {
663
- id: "entity-editor",
664
- ref: S,
665
- style: j.style,
666
- className: j.className,
667
- contentEditable: !0,
668
- onKeyDown: ae,
669
- onInput: X
670
- }
671
- );
671
+ }, []);
672
+ const J = t.length === 0 && p && !ae;
673
+ return /* @__PURE__ */ y.jsxs(y.Fragment, { children: [
674
+ /* @__PURE__ */ y.jsxs("div", { style: { position: "relative" }, children: [
675
+ /* @__PURE__ */ y.jsx(
676
+ "div",
677
+ {
678
+ id: "entity-editor",
679
+ ref: v,
680
+ style: { ...j.style, position: "relative", zIndex: 2 },
681
+ className: j.className,
682
+ contentEditable: !0,
683
+ onKeyDown: G,
684
+ onInput: M,
685
+ onFocus: fe,
686
+ onBlur: T,
687
+ role: "textbox",
688
+ "aria-multiline": "true"
689
+ }
690
+ ),
691
+ J && /* @__PURE__ */ y.jsx(
692
+ "div",
693
+ {
694
+ style: {
695
+ ...j.style,
696
+ position: "absolute",
697
+ top: 0,
698
+ left: 0,
699
+ right: 0,
700
+ bottom: 0,
701
+ color: "#9ca3af"
702
+ },
703
+ "aria-hidden": "true",
704
+ children: /* @__PURE__ */ y.jsx("p", { children: p })
705
+ }
706
+ )
707
+ ] }),
708
+ C && /* @__PURE__ */ y.jsx("div", { style: {}, children: /* @__PURE__ */ y.jsx("pre", { children: JSON.stringify(S) }) })
709
+ ] });
672
710
  };
673
711
  export {
674
712
  ft as Editor
@@ -3,8 +3,9 @@ import { Entity, EntityOptions, StyleOptions, EntityType, MarkState, MarkType, S
3
3
  export interface EditorRef {
4
4
  selectEntity: (entityType: EntityType, startIndex: number, endIndex: number, newText: string) => void;
5
5
  toggleMark: (markType: MarkType) => void;
6
+ clear: () => void;
6
7
  }
7
- interface EditorProps {
8
+ export interface EditorProps {
8
9
  ref: React.RefObject<EditorRef | null>;
9
10
  plainText: string;
10
11
  setPlainText: (plainText: string) => void;
@@ -18,7 +19,7 @@ interface EditorProps {
18
19
  className?: string;
19
20
  options?: EntityOptions;
20
21
  entityStyles?: StyleOptions;
22
+ placeholder?: string;
21
23
  debug?: boolean;
22
24
  }
23
- export declare const Editor: ({ ref, plainText, setPlainText, entities, setEntities, markState, setMarkState, search, setSearch, options, entityStyles, debug, ...props }: EditorProps) => import("react/jsx-runtime").JSX.Element;
24
- export {};
25
+ export declare const Editor: ({ ref, plainText, setPlainText, entities, setEntities, markState, setMarkState, search, setSearch, options, entityStyles, placeholder, debug, ...props }: EditorProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,8 +1,8 @@
1
1
  import { SearchEntity } from '../../interfaces';
2
2
  export declare const LINK_MASK = 128;
3
- export declare const LINK_REGEX: RegExp;
4
3
  export declare const LINK_BOUNDARIES = "()[]{}";
5
4
  export declare const LINK_KEY = "";
5
+ export declare const LINK_REGEX: RegExp;
6
6
  export declare const getLinkWord: (plainText: string, position: number) => SearchEntity | null;
7
7
  export declare const isLink: (value: number) => boolean;
8
8
  export declare const setLink: (value: number, link: boolean) => number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@connectedxm/entity-editor",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "dist/index.umd.js",