@connectedxm/entity-editor 0.0.2 → 0.0.3

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 L = {};
35
35
  /**
36
36
  * @license React
37
37
  * react-jsx-runtime.development.js
@@ -41,377 +41,377 @@ 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 === z ? 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 V:
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 y:
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 === y)
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 = T.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: I,
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) {
197
+ else p(k);
198
+ if (G.call(l, "key")) {
199
+ k = e(r);
200
+ var j = Object.keys(l).filter(function(Be) {
201
201
  return Be !== "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 < j.length ? "{key: someKey, " + j.join(": ..., ") + ": ...}" : "{key: someKey}", h[k + g] || (j = 0 < j.length ? "{" + j.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
+ j,
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 === I && 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 P = A, I = 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"), y = Symbol.for("react.lazy"), V = Symbol.for("react.activity"), z = Symbol.for("react.client.reference"), T = P.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, G = Object.prototype.hasOwnProperty, fe = Array.isArray, M = console.createTask ? console.createTask : function() {
239
239
  return null;
240
240
  };
241
- j = {
242
- react_stack_bottom_frame: function(o) {
243
- return o();
241
+ P = {
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 = {}, _ = P.react_stack_bottom_frame.bind(
247
+ P,
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 = M(s(i)), h = {};
250
+ L.Fragment = O, L.jsx = function(r, l, d, g, R) {
251
+ var w = 1e4 > T.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 ? M(s(r)) : E
261
261
  );
262
- }, x.jsxs = function(o, a, m, k, P) {
263
- var I = 1e4 > g.recentlyCreatedOwnerStacks++;
262
+ }, L.jsxs = function(r, l, d, g, R) {
263
+ var w = 1e4 > T.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 ? M(s(r)) : E
273
273
  );
274
274
  };
275
- })()), x;
275
+ })()), L;
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 C = 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
+ }, Ve = (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;
327
+ o < i.startIndex && (s += e.slice(o, i.startIndex));
328
+ const c = e.slice(i.startIndex, i.endIndex), u = Ve(i.type, i.marks, n);
329
+ s += `<span style="${u}">${c}</span>`, o = i.endIndex;
330
+ }), s += e.slice(o), s;
331
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(
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 = /^(?<protocol>[a-z\-]+)?:?(?<host>\/\/.*\.[^\/]+)$/, Je = "()[]{}", Me = "", xe = (e, t) => {
335
+ const n = ve(
336
336
  e,
337
337
  t,
338
- Xe,
339
- pe
338
+ Je,
339
+ Me
340
340
  );
341
- return r?.search.match(Ge) ? {
341
+ return n?.search.match(Ge) ? {
342
342
  type: "link",
343
- ...r
343
+ ...n
344
344
  } : 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(
345
+ }, te = (e) => (e & ee) !== 0, Re = (e, t) => t ? e | ee : e & ~ee, re = 32, Xe = /^@[a-zA-Z0-9_'-]+$/, qe = `.,!?;()[]{}"'<>#`, ne = "@", Le = (e, t) => {
346
+ const n = ve(
347
347
  e,
348
348
  t,
349
349
  qe,
350
350
  ne
351
351
  );
352
- return r?.search.match(Je) ? {
352
+ return n?.search.match(Xe) ? {
353
353
  type: "mention",
354
- ...r
354
+ ...n
355
355
  } : 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) => {
356
+ }, oe = (e) => (e & re) !== 0, _e = (e, t) => t ? e | re : e & ~re, D = 2, q = (e) => (e & D) !== 0, ke = (e, t) => t ? e | D : e & ~D, B = 4, H = (e) => (e & B) !== 0, be = (e, t) => t ? e | B : e & ~B, $ = 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, Pe = (e, t) => {
357
357
  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--;
358
+ let n = 0;
359
+ for (; n < e.length && n < t.length && e[n] === t[n]; )
360
+ n++;
361
+ let s = e.length, o = t.length;
362
+ for (; s > n && o > n && e[s - 1] === t[o - 1]; )
363
+ s--, o--;
364
364
  return {
365
- position: r,
366
- deletedLength: s - r,
367
- insertedText: t.slice(r, n)
365
+ position: n,
366
+ deletedLength: s - n,
367
+ insertedText: t.slice(n, o)
368
368
  };
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);
369
+ }, ge = (e, t, n, s) => {
370
+ let o = t;
371
+ for (; o < e.length; ) {
372
+ const c = b(e, o);
373
+ if (n(c))
374
+ e[o] = s(c, !1);
375
375
  else
376
376
  break;
377
- n++;
377
+ o++;
378
378
  }
379
379
  let i = t - 1;
380
380
  for (; i >= 0; ) {
381
- const c = w(e, i);
382
- if (r(c))
381
+ const c = b(e, i);
382
+ if (n(c))
383
383
  e[i] = s(c, !1);
384
384
  else
385
385
  break;
386
386
  i--;
387
387
  }
388
388
  return e;
389
- }, Pe = (e, t, r) => {
389
+ }, je = (e, t, n) => {
390
390
  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);
391
+ const { position: s, deletedLength: o, insertedText: i } = t, c = i.length;
392
+ let u = [...e];
393
+ const f = b(u, s);
394
+ 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) {
395
+ let m = 0;
396
+ n.bold && (m = ke(m, !0)), n.italic && (m = be(m, !0)), n.underline && (m = we(m, !0)), n.strike && (m = Se(m, !0));
397
+ const N = new Array(c).fill(m);
398
+ u.splice(s, 0, ...N);
399
399
  }
400
- return l;
401
- }, He = (e) => /\s/.test(e) || /[\u2000-\u200B\u2028\u2029\u3000]/.test(e), Se = (e, t, r, s) => {
400
+ return u;
401
+ }, He = (e) => /\s/.test(e) || /[\u2000-\u200B\u2028\u2029\u3000]/.test(e), ve = (e, t, n, s) => {
402
402
  if (t <= 0 || t > e.length)
403
403
  return null;
404
- let n = "", i = t - 1, c = t;
405
- const l = (f) => He(f) || r.includes(f);
404
+ let o = "", i = t - 1, c = t;
405
+ const u = (f) => He(f) || n.includes(f);
406
406
  for (let f = i; f >= 0; f--) {
407
- if (l(e[f])) {
407
+ if (u(e[f])) {
408
408
  i = f + 1;
409
409
  break;
410
410
  }
411
- f === 0 && (i = 0), n = e[f] + n;
411
+ f === 0 && (i = 0), o = e[f] + o;
412
412
  }
413
413
  for (let f = c; f < e.length; f++) {
414
- if (l(e[f])) {
414
+ if (u(e[f])) {
415
415
  c = f;
416
416
  break;
417
417
  }
@@ -419,93 +419,93 @@ const Ie = () => {
419
419
  c = f;
420
420
  break;
421
421
  }
422
- f === e.length - 1 && (c = e.length), n = n + e[f];
422
+ f === e.length - 1 && (c = e.length), o = o + e[f];
423
423
  }
424
424
  return {
425
425
  search: e.slice(i, c),
426
426
  startIndex: i,
427
427
  endIndex: c
428
428
  };
429
- }, se = 64, Ze = `.,!?;()[]{}"'<>@`, Qe = /^#[\w-]+$/, ie = "#", Le = (e, t) => {
430
- const r = Se(
429
+ }, se = 64, Ze = `.,!?;()[]{}"'<>@`, Qe = /^#[\w-]+$/, ie = "#", De = (e, t) => {
430
+ const n = ve(
431
431
  e,
432
432
  t,
433
433
  Ze,
434
434
  ie
435
435
  );
436
- return r?.search.match(Qe) ? {
436
+ return n?.search.match(Qe) ? {
437
437
  type: "interest",
438
- ...r
438
+ ...n
439
439
  } : 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) => {
440
+ }, ce = (e) => (e & se) !== 0, Ne = (e, t) => t ? e | se : e & ~se, et = (e, t) => e.find(
441
+ (n) => n.startIndex <= t && n.endIndex > t
442
+ ), tt = (e, t, n) => {
443
443
  const s = [];
444
- let n = 0;
445
- for (; n < t.length; ) {
446
- const i = w(t, n);
444
+ let o = 0;
445
+ for (; o < t.length; ) {
446
+ const i = b(t, o);
447
447
  if (i === 0 || i === 1) {
448
- n++;
448
+ o++;
449
449
  continue;
450
450
  }
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 = {
451
+ const c = o;
452
+ let u = o;
453
+ for (; u + 1 < t.length && b(t, u + 1) === i; )
454
+ u++;
455
+ const f = rt(i, n), m = nt(i), N = {
456
456
  type: f,
457
457
  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(
458
+ endIndex: u + 1,
459
+ marks: m,
460
+ username: f === "mention" ? Le(e, u)?.search.replace(ne, "") : void 0,
461
+ interest: f === "interest" ? De(e, u)?.search.replace(
462
462
  ie,
463
463
  ""
464
464
  ) : void 0,
465
- href: f === "link" ? Me(e, c)?.search : void 0
465
+ href: f === "link" ? xe(e, u)?.search : void 0
466
466
  };
467
- s.push(N), n = l + 1;
467
+ s.push(N), o = u + 1;
468
468
  }
469
469
  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) => {
470
+ }, rt = (e, t) => e & re && t.mentions ? "mention" : e & se && t.interests ? "interest" : e & ee && t.links ? "link" : (e & (D | B | Y | $), "segment"), nt = (e) => {
471
471
  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) {
472
+ return e & D && t.push("bold"), e & B && t.push("italic"), e & Y && t.push("underline"), e & $ && t.push("strike"), t;
473
+ }, b = (e, t) => {
474
+ const n = e[t];
475
+ return typeof n != "number" ? 0 : n;
476
+ }, ot = (e, t, n) => {
477
+ const s = b(e, t);
478
+ switch (n) {
479
479
  case "mention":
480
- return Re(s, !0);
480
+ return _e(s, !0);
481
481
  case "interest":
482
- return ve(s, !0);
482
+ return Ne(s, !0);
483
483
  case "link":
484
- return ge(s, !0);
484
+ return Re(s, !0);
485
485
  }
486
486
  return s;
487
- }, st = (e, t, r, s) => {
488
- let n = w(e, t);
489
- switch (r) {
487
+ }, st = (e, t, n, s) => {
488
+ let o = b(e, t);
489
+ switch (n) {
490
490
  case "bold":
491
- n = _e(n, s);
491
+ o = ke(o, s);
492
492
  break;
493
493
  case "italic":
494
- n = ke(n, s);
494
+ o = be(o, s);
495
495
  break;
496
496
  case "underline":
497
- n = we(n, s);
497
+ o = we(o, s);
498
498
  break;
499
499
  case "strike":
500
- n = be(n, s);
500
+ o = Se(o, s);
501
501
  break;
502
502
  default:
503
503
  return e;
504
504
  }
505
- return e[t] = n, e;
506
- }, it = (e, t, r) => {
507
- const s = w(e, t);
508
- switch (r) {
505
+ return e[t] = o, e;
506
+ }, it = (e, t, n) => {
507
+ const s = b(e, t);
508
+ switch (n) {
509
509
  case "bold":
510
510
  return q(s);
511
511
  case "italic":
@@ -515,160 +515,192 @@ const Ie = () => {
515
515
  case "strike":
516
516
  return Z(s);
517
517
  default:
518
- throw Error(`Invalid mark type: ${r}`);
518
+ throw Error(`Invalid mark type: ${n}`);
519
519
  }
520
- }, ct = (e, t, r, s) => {
521
- for (let n = e; n < t; n++)
522
- if (!it(s, n, r)) return !1;
520
+ }, ct = (e, t, n, s) => {
521
+ for (let o = e; o < t; o++)
522
+ if (!it(s, o, n)) return !1;
523
523
  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; )
524
+ }, pe = (e) => oe(e) || ce(e) || te(e), lt = (e, t, n, s) => {
525
+ let o = [...e];
526
+ for (; pe(b(e, t - 1)) && t > 0; )
527
527
  t--;
528
- for (; je(w(e, r)) && r < e.length; )
529
- r++;
528
+ for (; pe(b(e, n)) && n < e.length; )
529
+ n++;
530
530
  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;
531
+ ct(t, n, s, o) && (i = !1);
532
+ for (let c = t; c < n; c++)
533
+ o = st(o, c, s, i);
534
+ return o;
535
535
  }, Te = (e, t) => {
536
- const r = new Array(e.length).fill(0);
536
+ const n = new Array(e.length).fill(0);
537
537
  for (let s = 0; s < e.length; s++) {
538
- let n = 0;
538
+ let o = 0;
539
539
  const i = et(t, s);
540
540
  if (i) {
541
- i.type === "mention" ? n = Re(n, !0) : i.type === "interest" ? n = ve(n, !0) : i.type === "link" && (n = ge(n, !0));
541
+ i.type === "mention" ? o = _e(o, !0) : i.type === "interest" ? o = Ne(o, !0) : i.type === "link" && (o = Re(o, !0));
542
542
  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));
543
+ 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
544
  }
545
- r[s] = n;
545
+ n[s] = o;
546
546
  }
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();
547
+ return n;
548
+ }, ut = (e, t, n) => {
549
+ const [s, o] = $e(e), i = me(Date.now()), c = me(null), u = me(null);
550
+ return Ye(() => (c.current && clearTimeout(c.current), u.current && clearTimeout(u.current), Date.now() - i.current, c.current = setTimeout(() => {
551
+ o(e), i.current = Date.now();
552
552
  }, t), () => {
553
- c.current && clearTimeout(c.current), l.current && clearTimeout(l.current);
554
- }), [e, t, r]), s;
553
+ c.current && clearTimeout(c.current), u.current && clearTimeout(u.current);
554
+ }), [e, t, n]), s;
555
555
  }, ft = ({
556
556
  ref: e,
557
557
  plainText: t = "",
558
- setPlainText: r,
558
+ setPlainText: n,
559
559
  entities: s = [],
560
- setEntities: n,
560
+ setEntities: o,
561
561
  markState: i,
562
562
  setMarkState: c,
563
- search: l,
563
+ search: u,
564
564
  setSearch: f,
565
- options: h = {},
565
+ options: m = {},
566
566
  entityStyles: N = {},
567
- debug: le = !1,
568
- ...j
567
+ placeholder: p = "",
568
+ debug: P = !1,
569
+ ...I
569
570
  }) => {
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
+ 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, y] = A.useState(
571
572
  Te(t, s)
572
573
  );
573
574
  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);
575
+ selectEntity: (a, _, E, h) => {
576
+ if (!v.current) return;
577
+ let r = [...S];
578
+ a === "mention" ? h = ne + h : a === "interest" ? h = ie + h : a === "link" && (h = Me + h);
579
+ const l = t.slice(0, _) + h + t.slice(E), d = Pe(t, l);
580
+ d ? r = je(S, d, i) : r = Te(l, s);
581
+ for (let g = _; g < _ + h.length; g++)
582
+ r[g] = ot(r, g, a);
583
+ n(l), y(r), f(null);
583
584
  },
584
- toggleMark: (u) => {
585
- G(u);
585
+ toggleMark: (a) => {
586
+ z(a);
586
587
  }
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);
588
+ }, A.useEffect(() => {
589
+ if (v.current) {
590
+ v.current.textContent = t;
591
+ const a = Ce(t, s, N);
592
+ v.current.innerHTML = a, K || ue(!0);
592
593
  }
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(_);
594
+ }, []), A.useEffect(() => {
595
+ if (!v.current) return;
596
+ const a = tt(t, S, m), _ = ye() ?? O, E = Ce(t, a, N);
597
+ v.current.innerHTML = E, o(a), K && Ue(v.current, _);
598
+ }, [S]);
599
+ const V = ut(O, 500);
600
+ A.useEffect(() => {
601
+ let { start: a, end: _ } = V, E = null;
602
+ if (!E && !oe(b(S, a - 1)) && (E = Le(t, a), E && (E.search = E.search.replace(ne, ""))), !E && !ce(b(S, a - 1)) && (E = De(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;
603
+ let h = !0, r = !0, l = !0, d = !0;
604
+ if (a === _)
605
+ if (a > 0) {
606
+ const R = b(S, a - 1);
607
+ h = q(R), r = H(R), l = Q(R), d = Z(R);
607
608
  } else {
608
- const _ = w(v, u);
609
- E = q(_), R = H(_), A = Q(_), O = Z(_);
609
+ const R = b(S, a);
610
+ h = q(R), r = H(R), l = Q(R), d = Z(R);
610
611
  }
611
612
  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;
613
+ for (let R = a; R < _; R++) {
614
+ const w = b(S, R);
615
+ h = q(w) ? h : !1, r = H(w) ? r : !1, l = Q(w) ? l : !1, d = Z(w) ? d : !1;
615
616
  }
616
617
  c({
617
- bold: E,
618
- italic: R,
619
- underline: A,
620
- strike: O
618
+ bold: h,
619
+ italic: r,
620
+ underline: l,
621
+ strike: d
621
622
  });
622
- }, [z]);
623
- const G = (u) => {
624
- if (F(!0), !S.current)
623
+ }, [V]);
624
+ const z = (a) => {
625
+ if (W(!0), !v.current)
625
626
  return;
626
- const { start: g, end: d } = T;
627
- if (g !== d) {
628
- const R = lt(v, g, d, u);
629
- M(R);
627
+ const { start: _, end: E } = O;
628
+ if (_ !== E) {
629
+ const r = lt(S, _, E, a);
630
+ y(r);
630
631
  }
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([]);
632
+ const h = { ...i };
633
+ 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);
634
+ }, T = (a) => {
635
+ if (!v.current) return;
636
+ if (F && W(!1), a.target.textContent.length === 0) {
637
+ n(""), y([]), o([]);
637
638
  return;
638
639
  }
639
- const g = u.target.innerText || "", d = ye(t, g);
640
- if (d) {
641
- const E = Pe(
642
- v,
643
- d,
640
+ const _ = a.target.innerText || "", E = Pe(t, _);
641
+ if (E) {
642
+ const h = je(
643
+ S,
644
+ E,
644
645
  i
645
646
  );
646
- M(E);
647
+ y(h);
647
648
  }
648
- r(g);
649
- }, ae = (u) => {
650
- S.current && ze(u, G);
649
+ n(_);
650
+ }, G = (a) => {
651
+ v.current && ze(a, z);
652
+ }, fe = () => {
653
+ U(!0);
654
+ }, M = () => {
655
+ U(!1);
651
656
  };
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);
657
+ A.useEffect(() => {
658
+ const a = () => {
659
+ const _ = ye() ?? { start: 0, end: 0 };
660
+ (_.start !== O.start || _.end !== O.end) && le(_);
656
661
  };
657
- return document.addEventListener("selectionchange", u), () => {
658
- document.removeEventListener("selectionchange", u);
662
+ return document.addEventListener("selectionchange", a), () => {
663
+ document.removeEventListener("selectionchange", a);
659
664
  };
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
- );
665
+ }, []);
666
+ const J = t.length === 0 && p && !ae;
667
+ return /* @__PURE__ */ C.jsxs(C.Fragment, { children: [
668
+ /* @__PURE__ */ C.jsxs("div", { style: { position: "relative" }, children: [
669
+ /* @__PURE__ */ C.jsx(
670
+ "div",
671
+ {
672
+ id: "entity-editor",
673
+ ref: v,
674
+ style: { ...I.style, position: "relative", zIndex: 2 },
675
+ className: I.className,
676
+ contentEditable: !0,
677
+ onKeyDown: G,
678
+ onInput: T,
679
+ onFocus: fe,
680
+ onBlur: M,
681
+ role: "textbox",
682
+ "aria-multiline": "true"
683
+ }
684
+ ),
685
+ J && /* @__PURE__ */ C.jsx(
686
+ "div",
687
+ {
688
+ style: {
689
+ position: "absolute",
690
+ top: 0,
691
+ left: 0,
692
+ paddingTop: I.style?.paddingTop,
693
+ paddingLeft: I.style?.paddingLeft,
694
+ padding: I.style?.padding,
695
+ color: "#9ca3af"
696
+ },
697
+ "aria-hidden": "true",
698
+ children: p
699
+ }
700
+ )
701
+ ] }),
702
+ P && /* @__PURE__ */ C.jsx("div", { style: {}, children: /* @__PURE__ */ C.jsx("pre", { children: JSON.stringify(S) }) })
703
+ ] });
672
704
  };
673
705
  export {
674
706
  ft as Editor
@@ -4,7 +4,7 @@ export interface EditorRef {
4
4
  selectEntity: (entityType: EntityType, startIndex: number, endIndex: number, newText: string) => void;
5
5
  toggleMark: (markType: MarkType) => void;
6
6
  }
7
- interface EditorProps {
7
+ export interface EditorProps {
8
8
  ref: React.RefObject<EditorRef | null>;
9
9
  plainText: string;
10
10
  setPlainText: (plainText: string) => void;
@@ -18,7 +18,7 @@ interface EditorProps {
18
18
  className?: string;
19
19
  options?: EntityOptions;
20
20
  entityStyles?: StyleOptions;
21
+ placeholder?: string;
21
22
  debug?: boolean;
22
23
  }
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 {};
24
+ 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;
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.3",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "dist/index.umd.js",