lexical-medium-editor 1.2.13 → 1.2.14

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.
@@ -1,42 +1,42 @@
1
1
  import './lexical-medium-editor.css';
2
- import { jsxs as I, Fragment as be, jsx as a } from "react/jsx-runtime";
2
+ import { jsxs as $, Fragment as be, jsx as l } from "react/jsx-runtime";
3
3
  import { AutoFocusPlugin as we } from "@lexical/react/LexicalAutoFocusPlugin";
4
- import { LexicalComposer as Ke } from "@lexical/react/LexicalComposer";
5
- import { RichTextPlugin as Fe } from "@lexical/react/LexicalRichTextPlugin";
4
+ import { LexicalComposer as Fe } from "@lexical/react/LexicalComposer";
5
+ import { RichTextPlugin as Ke } from "@lexical/react/LexicalRichTextPlugin";
6
6
  import { HistoryPlugin as We } from "@lexical/react/LexicalHistoryPlugin";
7
7
  import { LexicalErrorBoundary as Ge } from "@lexical/react/LexicalErrorBoundary";
8
- import { useLexicalComposerContext as p } from "@lexical/react/LexicalComposerContext";
9
- import { createCommand as _, $getSelection as N, $isRangeSelection as f, $createParagraphNode as F, COMMAND_PRIORITY_HIGH as m, $getRoot as U, CLICK_COMMAND as ze, COMMAND_PRIORITY_LOW as Le, TextNode as W, $isParagraphNode as B, $getCharacterOffsets as qe, FORMAT_TEXT_COMMAND as J, SELECTION_CHANGE_COMMAND as A, BLUR_COMMAND as ie, $getNodeByKey as G, $isLineBreakNode as w, $getPreviousSelection as Y, KEY_BACKSPACE_COMMAND as se, $isNodeSelection as ae, PASTE_COMMAND as Ue, $setSelection as Me, KEY_ARROW_RIGHT_COMMAND as Ye, $getAdjacentNode as oe, $createTextNode as Qe, COMMAND_PRIORITY_NORMAL as je, KEY_ENTER_COMMAND as Xe, $isTextNode as Ve, ParagraphNode as Ze, $createLineBreakNode as Je, KEY_TAB_COMMAND as et } from "lexical";
10
- import { useEffect as u, useState as b, useRef as z, useLayoutEffect as tt } from "react";
8
+ import { useLexicalComposerContext as T } from "@lexical/react/LexicalComposerContext";
9
+ import { createCommand as B, $getSelection as p, $isRangeSelection as C, $createParagraphNode as K, COMMAND_PRIORITY_HIGH as N, $getRoot as U, CLICK_COMMAND as ze, COMMAND_PRIORITY_LOW as Le, TextNode as W, $isParagraphNode as k, $getCharacterOffsets as qe, FORMAT_TEXT_COMMAND as ee, SELECTION_CHANGE_COMMAND as A, BLUR_COMMAND as X, $getNodeByKey as G, $isLineBreakNode as w, $getPreviousSelection as Y, KEY_BACKSPACE_COMMAND as se, $isNodeSelection as ae, PASTE_COMMAND as Ue, $setSelection as Me, KEY_ARROW_RIGHT_COMMAND as Ye, $getAdjacentNode as re, $createTextNode as Qe, COMMAND_PRIORITY_NORMAL as je, KEY_ENTER_COMMAND as Xe, $isTextNode as Ve, ParagraphNode as Ze, $createLineBreakNode as Je, KEY_TAB_COMMAND as et } from "lexical";
10
+ import { useEffect as u, useState as L, useRef as z, useLayoutEffect as tt } from "react";
11
11
  import { createPortal as le } from "react-dom";
12
12
  import { $findMatchingParent as E, $dfs as nt } from "@lexical/utils";
13
- import { Toolbar as ce, TextField as ot, Input as Ie, Group as K, Button as v, ToggleButton as H, Separator as ue, ComboBox as rt, Popover as $e, ListBox as it, ListBoxItem as st, DialogTrigger as at, FileTrigger as lt } from "react-aria-components";
13
+ import { Toolbar as ce, TextField as ot, Input as Ie, Group as F, Button as O, ToggleButton as H, Separator as ue, ComboBox as rt, Popover as $e, ListBox as it, ListBoxItem as st, DialogTrigger as at, FileTrigger as lt } from "react-aria-components";
14
14
  import { IconCheck as ct, IconX as dt, IconBold as ut, IconItalic as gt, IconCode as ft, IconTextSize as mt, IconBlockquote as ht, IconLink as Nt, IconCaretDownFilled as Ct, IconPlus as pt, IconPhoto as Tt, IconCodePlus as Et, IconLineDashed as bt } from "@tabler/icons-react";
15
15
  import { $isAtNodeEnd as ge, $setBlocksType as Se, createDOMRange as Lt } from "@lexical/selection";
16
- import { $createHeadingNode as xe, HeadingNode as Mt, $createQuoteNode as It, $isHeadingNode as re, $isQuoteNode as $t } from "@lexical/rich-text";
16
+ import { $createHeadingNode as xe, HeadingNode as Mt, $createQuoteNode as It, $isHeadingNode as ie, $isQuoteNode as $t } from "@lexical/rich-text";
17
17
  import { $toggleLink as St, $isLinkNode as xt } from "@lexical/link";
18
- import { $isListNode as yt, $isListItemNode as fe, $insertList as me } from "@lexical/list";
19
- import { $ as k, a as R, b as D, H as Ot, c as vt, I as he, d as Ne, e as Pt, M as Q, f as Dt, g as ee, h as O, i as At, j as te } from "./ImageNode-BhH71HMX.js";
20
- import { $isCodeNode as j, getCodeLanguages as _t, getLanguageFriendlyName as ne, registerCodeHighlighting as kt, $createCodeNode as Ce } from "@lexical/code";
18
+ import { $isListNode as vt, $isListItemNode as fe, $insertList as me } from "@lexical/list";
19
+ import { $ as _, a as R, b as D, H as yt, c as Ot, I as he, d as Ne, e as Pt, M as Q, f as Dt, g as te, h as y, i as At, j as ne } from "./ImageNode-BhH71HMX.js";
20
+ import { $isCodeNode as j, getCodeLanguages as Bt, getLanguageFriendlyName as oe, registerCodeHighlighting as _t, $createCodeNode as Ce } from "@lexical/code";
21
21
  import { NodeEventPlugin as de } from "@lexical/react/LexicalNodeEventPlugin";
22
- import { ListPlugin as Bt } from "@lexical/react/LexicalListPlugin";
22
+ import { ListPlugin as kt } from "@lexical/react/LexicalListPlugin";
23
23
  import { OnChangePlugin as Ht } from "@lexical/react/LexicalOnChangePlugin";
24
24
  import { ContentEditable as Rt } from "@lexical/react/LexicalContentEditable";
25
25
  import { ClearEditorPlugin as wt } from "@lexical/react/LexicalClearEditorPlugin";
26
- const $ = -1e3;
27
- function Kt(e, s, t = 0) {
26
+ const S = -1e3;
27
+ function Ft(e, s, t = 0) {
28
28
  if (!s || !s.current)
29
29
  return console.error("Invalid popover reference"), {
30
- x: $,
31
- y: $
30
+ x: S,
31
+ y: S
32
32
  };
33
- const n = s.current, { x: i, y: o } = e, { width: r, height: c } = n.getBoundingClientRect(), l = i - r / 2, d = o - c - t;
33
+ const n = s.current, { x: i, y: r } = e, { width: o, height: a } = n.getBoundingClientRect(), c = i - o / 2, d = r - a - t;
34
34
  return {
35
- x: l,
35
+ x: c,
36
36
  y: d
37
37
  };
38
38
  }
39
- function Ft(e) {
39
+ function Kt(e) {
40
40
  if (!e || typeof e.getBoundingClientRect != "function")
41
41
  return console.error("Invalid DOM range"), null;
42
42
  const s = e.getBoundingClientRect(), t = s.left + s.width / 2, n = s.top + window.scrollY;
@@ -48,34 +48,34 @@ function Ft(e) {
48
48
  function Wt(e, s, t = 0) {
49
49
  if (!s || !s.current)
50
50
  return console.error("Invalid popover reference"), {
51
- x: $,
52
- y: $
51
+ x: S,
52
+ y: S
53
53
  };
54
- const { x: n, y: i } = e, o = s.current, { width: r, height: c } = o.getBoundingClientRect(), l = n - r - t, d = i - c / 2;
54
+ const { x: n, y: i } = e, r = s.current, { width: o, height: a } = r.getBoundingClientRect(), c = n - o - t, d = i - a / 2;
55
55
  return {
56
- x: l,
56
+ x: c,
57
57
  y: d
58
58
  };
59
59
  }
60
60
  function Gt(e, s, t = 16, n = 12) {
61
61
  if (!s || !s.current)
62
62
  return console.error("Invalid popover reference"), {
63
- x: $,
64
- y: $
63
+ x: S,
64
+ y: S
65
65
  };
66
- const i = s.current, { x: o, y: r } = e, { width: c } = i.getBoundingClientRect(), l = o - c - t, d = r + n;
66
+ const i = s.current, { x: r, y: o } = e, { width: a } = i.getBoundingClientRect(), c = r - a - t, d = o + n;
67
67
  return {
68
- x: l,
68
+ x: c,
69
69
  y: d
70
70
  };
71
71
  }
72
- const ye = _("TOGGLE_HEADING_COMMAND"), Oe = _("TOGGLE_QUOTE_COMMAND"), ve = _("TOGGLE_LINK_COMMAND");
73
- function X(e) {
72
+ const ve = B("TOGGLE_HEADING_COMMAND"), ye = B("TOGGLE_QUOTE_COMMAND"), Oe = B("TOGGLE_LINK_COMMAND");
73
+ function V(e) {
74
74
  const s = e.anchor, t = e.focus, n = e.anchor.getNode(), i = e.focus.getNode();
75
75
  return n === i ? n : e.isBackward() ? ge(t) ? n : i : ge(s) ? n : i;
76
76
  }
77
77
  function pe(e) {
78
- const s = E(e, re);
78
+ const s = E(e, ie);
79
79
  return s ? s.getTag() : null;
80
80
  }
81
81
  function zt(e) {
@@ -88,37 +88,37 @@ function zt(e) {
88
88
  const n = pe(t[0]);
89
89
  if (!n) return s;
90
90
  if (t.every(
91
- (o) => pe(o) === n
91
+ (r) => pe(r) === n
92
92
  )) {
93
- const o = {
93
+ const r = {
94
94
  h1: "isHeadingOne",
95
95
  h2: "isHeadingTwo",
96
96
  h3: "isHeadingThree"
97
97
  }[n];
98
- o && (s[o] = !0);
98
+ r && (s[r] = !0);
99
99
  }
100
100
  return s;
101
101
  }
102
102
  function qt() {
103
- const [e] = p();
103
+ const [e] = T();
104
104
  return u(() => e.registerCommand(
105
- ye,
105
+ ve,
106
106
  (t) => {
107
- const { isHeadingOne: n, isHeadingTwo: i, isHeadingThree: o } = t, r = N();
108
- if (f(r)) {
109
- let c;
110
- n || i ? c = "h3" : o ? c = null : c = "h2", Se(
111
- r,
112
- () => c ? xe(c) : F()
107
+ const { isHeadingOne: n, isHeadingTwo: i, isHeadingThree: r } = t, o = p();
108
+ if (C(o)) {
109
+ let a;
110
+ n || i ? a = "h3" : r ? a = null : a = "h2", Se(
111
+ o,
112
+ () => a ? xe(a) : K()
113
113
  );
114
114
  }
115
115
  return !0;
116
116
  },
117
- m
117
+ N
118
118
  ), [e]), null;
119
119
  }
120
120
  function Ut() {
121
- const [e] = p();
121
+ const [e] = T();
122
122
  return u(() => {
123
123
  const s = e.registerNodeTransform(
124
124
  Mt,
@@ -127,8 +127,8 @@ function Ut() {
127
127
  return;
128
128
  const i = U().getFirstChild();
129
129
  if (i !== null && t.is(i)) {
130
- const o = t.getChildren(), r = xe("h1");
131
- r.append(...o), t.replace(r);
130
+ const r = t.getChildren(), o = xe("h1");
131
+ o.append(...r), t.replace(o);
132
132
  }
133
133
  }
134
134
  );
@@ -145,101 +145,101 @@ function Qt(e) {
145
145
  return s.length ? s.length > 0 && s.every((t) => Yt(t)) : !1;
146
146
  }
147
147
  function jt() {
148
- const [e] = p();
148
+ const [e] = T();
149
149
  return u(() => e.registerCommand(
150
- Oe,
150
+ ye,
151
151
  (t) => {
152
- const n = N();
153
- return f(n) && Se(
152
+ const n = p();
153
+ return C(n) && Se(
154
154
  n,
155
- () => t.isQuote ? F() : It()
155
+ () => t.isQuote ? K() : It()
156
156
  ), !0;
157
157
  },
158
- m
158
+ N
159
159
  ), [e]), null;
160
160
  }
161
161
  function Pe(e) {
162
- if (!f(e))
162
+ if (!C(e))
163
163
  return null;
164
- const s = X(e);
164
+ const s = V(e);
165
165
  return E(s, xt);
166
166
  }
167
167
  function Xt() {
168
- const [e] = p();
168
+ const [e] = T();
169
169
  return u(() => e.registerCommand(
170
170
  ze,
171
171
  (t) => {
172
- const n = N(), i = Pe(n);
172
+ const n = p(), i = Pe(n);
173
173
  return i && (t.metaKey || t.ctrlKey) ? (window.open(i.getURL(), "_blank"), !0) : !1;
174
174
  },
175
175
  Le
176
176
  ), [e]), u(() => e.registerCommand(
177
- ve,
177
+ Oe,
178
178
  (t) => (St(t), !0),
179
- m
179
+ N
180
180
  ), [e]), null;
181
181
  }
182
182
  function Vt() {
183
- const [e] = p(), s = "heading-above";
183
+ const [e] = T(), s = "heading-above";
184
184
  return u(() => e.registerNodeTransform(
185
185
  W,
186
186
  (n) => {
187
- const i = E(n, B) || E(n, yt);
188
- if (!i || re(i))
187
+ const i = E(n, k) || E(n, vt);
188
+ if (!i || ie(i))
189
189
  return;
190
- const o = i, r = e.getElementByKey(o.getKey());
191
- if (!r)
190
+ const r = i, o = e.getElementByKey(r.getKey());
191
+ if (!o)
192
192
  return;
193
- const c = o.getPreviousSibling(), l = re(c), d = r.classList.contains(s);
194
- l && !d ? r.classList.add(s) : !l && d && r.classList.remove(s);
193
+ const a = r.getPreviousSibling(), c = ie(a), d = o.classList.contains(s);
194
+ c && !d ? o.classList.add(s) : !c && d && o.classList.remove(s);
195
195
  }
196
196
  ), [e]), null;
197
197
  }
198
198
  function Zt({ isHeadingOneFirst: e }) {
199
- return /* @__PURE__ */ I(be, { children: [
200
- /* @__PURE__ */ a(qt, {}),
201
- e && /* @__PURE__ */ a(Ut, {}),
202
- /* @__PURE__ */ a(jt, {}),
203
- /* @__PURE__ */ a(Xt, {}),
204
- /* @__PURE__ */ a(Vt, {})
199
+ return /* @__PURE__ */ $(be, { children: [
200
+ /* @__PURE__ */ l(qt, {}),
201
+ e && /* @__PURE__ */ l(Ut, {}),
202
+ /* @__PURE__ */ l(jt, {}),
203
+ /* @__PURE__ */ l(Xt, {}),
204
+ /* @__PURE__ */ l(Vt, {})
205
205
  ] });
206
206
  }
207
207
  function Jt({ style: e, closeToolbar: s, existingLinkURL: t }) {
208
- const [n] = p(), [i, o] = b(t);
209
- return /* @__PURE__ */ I(ce, { style: e, "aria-details": "link toolbar", id: "link-toolbar", children: [
210
- /* @__PURE__ */ a(
208
+ const [n] = T(), [i, r] = L(t);
209
+ return /* @__PURE__ */ $(ce, { style: e, "aria-details": "link toolbar", id: "link-toolbar", children: [
210
+ /* @__PURE__ */ l(
211
211
  ot,
212
212
  {
213
213
  "aria-label": "url",
214
214
  autoFocus: !0,
215
215
  defaultValue: i,
216
- onChange: o,
217
- children: /* @__PURE__ */ a(Ie, { placeholder: "Enter Link" })
216
+ onChange: r,
217
+ children: /* @__PURE__ */ l(Ie, { placeholder: "Enter Link" })
218
218
  }
219
219
  ),
220
- /* @__PURE__ */ I(K, { "aria-label": "edit link", children: [
221
- /* @__PURE__ */ a(
222
- v,
220
+ /* @__PURE__ */ $(F, { "aria-label": "edit link", children: [
221
+ /* @__PURE__ */ l(
222
+ O,
223
223
  {
224
224
  "aria-label": "Update link",
225
225
  onPress: () => {
226
- const r = i === "" ? null : i;
227
- n.dispatchCommand(ve, r), s();
226
+ const o = i === "" ? null : i;
227
+ n.dispatchCommand(Oe, o), s();
228
228
  },
229
- children: /* @__PURE__ */ a(ct, { size: y })
229
+ children: /* @__PURE__ */ l(ct, { size: v })
230
230
  }
231
231
  ),
232
- /* @__PURE__ */ a(v, { "aria-label": "Discard changes", onPress: s, children: /* @__PURE__ */ a(dt, { size: y }) })
232
+ /* @__PURE__ */ l(O, { "aria-label": "Discard changes", onPress: s, children: /* @__PURE__ */ l(dt, { size: v }) })
233
233
  ] }),
234
- /* @__PURE__ */ a("div", { className: "inline-toolbar-pointer" })
234
+ /* @__PURE__ */ l("div", { className: "inline-toolbar-pointer" })
235
235
  ] });
236
236
  }
237
- const y = 24, en = 16;
237
+ const v = 24, en = 16;
238
238
  function tn({ editor: e }) {
239
- const [s, t] = b(null), [n, i] = b({
240
- x: $,
241
- y: $
242
- }), o = z(null), [r, c] = b({
239
+ const [s, t] = L(null), [n, i] = L({
240
+ x: S,
241
+ y: S
242
+ }), r = z(null), [o, a] = L({
243
243
  isBold: !1,
244
244
  isItalic: !1,
245
245
  isCode: !1,
@@ -247,84 +247,84 @@ function tn({ editor: e }) {
247
247
  isHeadingTwo: !1,
248
248
  isHeadingThree: !1,
249
249
  isQuote: !1
250
- }), [l, d] = b(!1), [C, h] = b(0), [L, x] = b(""), T = (g) => {
251
- if (f(g)) {
252
- c({
250
+ }), [c, d] = L(!1), [m, f] = L(0), [b, I] = L(""), h = (g) => {
251
+ if (C(g)) {
252
+ a({
253
253
  isBold: g.hasFormat("bold"),
254
254
  isItalic: g.hasFormat("italic"),
255
255
  isCode: g.hasFormat("code"),
256
256
  isQuote: Qt(g)
257
257
  });
258
258
  const M = zt(g);
259
- c((P) => ({
259
+ a((P) => ({
260
260
  ...P,
261
261
  ...M
262
262
  }));
263
- const S = Pe(g);
264
- x(S ? S.getURL() : "");
263
+ const x = Pe(g);
264
+ I(x ? x.getURL() : "");
265
265
  }
266
266
  };
267
267
  return u(() => {
268
268
  e.read(() => {
269
- const g = N();
270
- T(g);
269
+ const g = p();
270
+ h(g);
271
271
  });
272
272
  }, [e]), u(() => e.registerUpdateListener(
273
273
  ({ editorState: M }) => {
274
274
  M.read(() => {
275
- const S = N();
276
- T(S);
275
+ const x = p();
276
+ h(x);
277
277
  });
278
278
  }
279
279
  ), [e]), u(() => {
280
280
  e.read(() => {
281
- const g = N();
282
- if (f(g)) {
283
- const [M, S] = g.getStartEndPoints(), [P, V] = [
281
+ const g = p();
282
+ if (C(g)) {
283
+ const [M, x] = g.getStartEndPoints(), [P, Z] = [
284
284
  M.getNode(),
285
- S.getNode()
286
- ], [Z, He] = qe(g), Re = Lt(
285
+ x.getNode()
286
+ ], [J, He] = qe(g), Re = Lt(
287
287
  e,
288
288
  P,
289
+ J,
289
290
  Z,
290
- V,
291
291
  He
292
292
  );
293
- t(Ft(Re));
293
+ t(Kt(Re));
294
294
  }
295
295
  });
296
- }, [e, r]), u(() => {
296
+ }, [e, o]), u(() => {
297
297
  var g;
298
298
  s ? (i(
299
- Kt(
299
+ Ft(
300
300
  s,
301
- o,
301
+ r,
302
302
  en
303
303
  )
304
304
  ), setTimeout(() => {
305
305
  var M;
306
- (M = o.current) == null || M.classList.add("visible");
307
- }, 50)) : (g = o.current) == null || g.classList.remove("visible");
306
+ (M = r.current) == null || M.classList.add("visible");
307
+ }, 50)) : (g = r.current) == null || g.classList.remove("visible");
308
308
  }, [s]), tt(() => {
309
- if (o.current) {
310
- const g = window.getComputedStyle(o.current), M = parseFloat(g.width);
311
- h(M);
309
+ if (r.current) {
310
+ const g = window.getComputedStyle(r.current), M = parseFloat(g.width);
311
+ f(M);
312
312
  }
313
- }, [s]), s && (l ? /* @__PURE__ */ a(
313
+ }, [s]), s && (c ? /* @__PURE__ */ l(
314
314
  Jt,
315
315
  {
316
316
  style: {
317
317
  position: "absolute",
318
318
  top: n.y,
319
319
  left: n.x,
320
- width: C
320
+ width: m
321
321
  },
322
322
  closeToolbar: () => {
323
323
  d(!1), t(null);
324
324
  },
325
- existingLinkURL: L
325
+ existingLinkURL: b
326
326
  }
327
- ) : /* @__PURE__ */ I(
327
+ ) : /* @__PURE__ */ $(
328
328
  ce,
329
329
  {
330
330
  style: {
@@ -334,187 +334,207 @@ function tn({ editor: e }) {
334
334
  },
335
335
  "aria-label": "Text formatting",
336
336
  id: "inline-toolbar",
337
- ref: o,
337
+ ref: r,
338
338
  children: [
339
- /* @__PURE__ */ I(K, { "aria-label": "Style", children: [
340
- /* @__PURE__ */ a(
339
+ /* @__PURE__ */ $(F, { "aria-label": "Style", children: [
340
+ /* @__PURE__ */ l(
341
341
  H,
342
342
  {
343
343
  "aria-label": "Bold",
344
- isSelected: r.isBold,
345
- isDisabled: r.isCode || r.isHeadingOne || r.isHeadingTwo || r.isHeadingThree,
346
- onChange: () => e.dispatchCommand(J, "bold"),
347
- children: /* @__PURE__ */ a(ut, { size: y })
344
+ isSelected: o.isBold,
345
+ isDisabled: o.isCode || o.isHeadingOne || o.isHeadingTwo || o.isHeadingThree,
346
+ onChange: () => e.dispatchCommand(ee, "bold"),
347
+ children: /* @__PURE__ */ l(ut, { size: v })
348
348
  }
349
349
  ),
350
- /* @__PURE__ */ a(
350
+ /* @__PURE__ */ l(
351
351
  H,
352
352
  {
353
353
  "aria-label": "Italic",
354
- isSelected: r.isItalic,
355
- isDisabled: r.isCode || r.isHeadingOne,
356
- onChange: () => e.dispatchCommand(J, "italic"),
357
- children: /* @__PURE__ */ a(gt, { size: y })
354
+ isSelected: o.isItalic,
355
+ isDisabled: o.isCode || o.isHeadingOne,
356
+ onChange: () => e.dispatchCommand(ee, "italic"),
357
+ children: /* @__PURE__ */ l(gt, { size: v })
358
358
  }
359
359
  ),
360
- /* @__PURE__ */ a(
360
+ /* @__PURE__ */ l(
361
361
  H,
362
362
  {
363
363
  "aria-label": "inline-code",
364
- isDisabled: r.isHeadingOne,
365
- isSelected: r.isCode,
366
- onChange: () => e.dispatchCommand(J, "code"),
367
- children: /* @__PURE__ */ a(ft, { size: y })
364
+ isDisabled: o.isHeadingOne,
365
+ isSelected: o.isCode,
366
+ onChange: () => e.dispatchCommand(ee, "code"),
367
+ children: /* @__PURE__ */ l(ft, { size: v })
368
368
  }
369
369
  )
370
370
  ] }),
371
- /* @__PURE__ */ a(ue, { orientation: "vertical" }),
372
- /* @__PURE__ */ I(K, { "aria-label": "Text Blocks", children: [
373
- /* @__PURE__ */ a(
371
+ /* @__PURE__ */ l(ue, { orientation: "vertical" }),
372
+ /* @__PURE__ */ $(F, { "aria-label": "Text Blocks", children: [
373
+ /* @__PURE__ */ l(
374
374
  H,
375
375
  {
376
376
  "aria-label": "Heading",
377
- isSelected: r.isHeadingOne || r.isHeadingTwo || r.isHeadingThree,
378
- onChange: () => e.dispatchCommand(ye, r),
379
- children: /* @__PURE__ */ a(mt, { size: y })
377
+ isSelected: o.isHeadingOne || o.isHeadingTwo || o.isHeadingThree,
378
+ onChange: () => e.dispatchCommand(ve, o),
379
+ children: /* @__PURE__ */ l(mt, { size: v })
380
380
  }
381
381
  ),
382
- /* @__PURE__ */ a(
382
+ /* @__PURE__ */ l(
383
383
  H,
384
384
  {
385
385
  "aria-label": "Quote",
386
- isSelected: r.isQuote,
387
- onChange: () => e.dispatchCommand(Oe, r),
388
- children: /* @__PURE__ */ a(ht, { size: y })
386
+ isSelected: o.isQuote,
387
+ onChange: () => e.dispatchCommand(ye, o),
388
+ children: /* @__PURE__ */ l(ht, { size: v })
389
389
  }
390
390
  )
391
391
  ] }),
392
- /* @__PURE__ */ a(ue, { orientation: "vertical" }),
393
- /* @__PURE__ */ a(K, { "aria-label": "Links", children: /* @__PURE__ */ a(
394
- v,
392
+ /* @__PURE__ */ l(ue, { orientation: "vertical" }),
393
+ /* @__PURE__ */ l(F, { "aria-label": "Links", children: /* @__PURE__ */ l(
394
+ O,
395
395
  {
396
396
  onPress: () => d(!0),
397
- isDisabled: r.isHeadingOne,
398
- children: /* @__PURE__ */ a(Nt, { size: y })
397
+ isDisabled: o.isHeadingOne,
398
+ children: /* @__PURE__ */ l(Nt, { size: v })
399
399
  }
400
400
  ) }),
401
- /* @__PURE__ */ a("div", { className: "inline-toolbar-pointer" })
401
+ /* @__PURE__ */ l("div", { className: "inline-toolbar-pointer" })
402
402
  ]
403
403
  }
404
404
  ));
405
405
  }
406
406
  const nn = document.body;
407
407
  function on() {
408
- const [e, s] = b(!1), [t] = p();
408
+ const [e, s] = L(!1), [t] = T();
409
409
  return u(() => t.registerCommand(
410
410
  A,
411
411
  () => {
412
- const i = N();
413
- if (!f(i) || i.isCollapsed())
412
+ const i = p();
413
+ if (!C(i) || i.isCollapsed())
414
414
  return s(!1), !1;
415
- const o = i.getNodes(), r = o.some((d) => k(d)), c = o.length === 1 && (R(o[0]) || E(o[0], D)), l = o.some(
415
+ const r = i.getNodes(), o = r.some((d) => _(d)), a = r.length === 1 && (R(r[0]) || E(r[0], D)), c = r.some(
416
416
  (d) => E(d, j)
417
417
  );
418
- return s(!r && !c && !l), !1;
418
+ return s(!o && !a && !c), !1;
419
419
  },
420
- m
420
+ N
421
421
  ), [t]), u(() => t.registerCommand(
422
- ie,
422
+ X,
423
423
  () => (setTimeout(() => {
424
- const i = document.getElementById("inline-toolbar"), o = document.getElementById("link-toolbar"), r = document.activeElement;
425
- i && (i === r || i.contains(r)) || o && (o === r || o.contains(r)) || s(!1);
424
+ const i = document.getElementById("inline-toolbar"), r = document.getElementById("link-toolbar"), o = document.activeElement;
425
+ i && (i === o || i.contains(o)) || r && (r === o || r.contains(o)) || s(!1);
426
426
  }, 0), !1),
427
- m
428
- ), [t]), e && le(/* @__PURE__ */ a(tn, { editor: t }), nn);
427
+ N
428
+ ), [t]), e && le(/* @__PURE__ */ l(tn, { editor: t }), nn);
429
429
  }
430
430
  function rn({ codeBlockCoords: e, codeNodeKey: s }) {
431
- const [t] = p(), [n, i] = b({
432
- x: $,
433
- y: $
434
- }), o = z(null), [r, c] = b(""), l = _t(), d = Array.from(
435
- new Set(l.map((h) => ne(h)))
436
- ), C = {};
437
- return l.forEach((h) => {
438
- const L = ne(h);
439
- C[L] || (C[L] = h);
431
+ const [t] = T(), [n, i] = L({
432
+ x: S,
433
+ y: S
434
+ }), r = z(null), [o, a] = L(""), c = Bt(), d = Array.from(
435
+ new Set(c.map((f) => oe(f)))
436
+ ), m = {};
437
+ return c.forEach((f) => {
438
+ const b = oe(f);
439
+ m[b] || (m[b] = f);
440
440
  }), u(() => {
441
- i(Gt(e, o));
441
+ i(Gt(e, r));
442
442
  }, [e]), u(() => {
443
443
  t.read(() => {
444
444
  if (s) {
445
- const L = G(s).getLanguage();
446
- c(ne(L));
445
+ const b = G(s).getLanguage();
446
+ a(oe(b));
447
447
  }
448
448
  });
449
- }, [t, s]), /* @__PURE__ */ I(
449
+ }, [t, s]), /* @__PURE__ */ $(
450
450
  rt,
451
451
  {
452
- ref: o,
452
+ ref: r,
453
453
  style: {
454
454
  position: "absolute",
455
455
  top: n.y,
456
456
  left: n.x
457
457
  },
458
458
  "aria-label": "Code menu",
459
- inputValue: r,
460
- onInputChange: (h) => {
461
- const L = C[h];
459
+ inputValue: o,
460
+ onInputChange: (f) => {
461
+ const b = m[f];
462
462
  t.dispatchCommand(Ae, [
463
463
  s,
464
- L
465
- ]), c(h);
464
+ b
465
+ ]), a(f);
466
466
  },
467
467
  children: [
468
- /* @__PURE__ */ I("div", { children: [
469
- /* @__PURE__ */ a(Ie, {}),
470
- /* @__PURE__ */ a(v, { children: /* @__PURE__ */ a(Ct, { size: 24 }) })
468
+ /* @__PURE__ */ $("div", { children: [
469
+ /* @__PURE__ */ l(Ie, {}),
470
+ /* @__PURE__ */ l(O, { children: /* @__PURE__ */ l(Ct, { size: 24 }) })
471
471
  ] }),
472
- /* @__PURE__ */ a($e, { children: /* @__PURE__ */ a(it, { children: d.map((h, L) => /* @__PURE__ */ a(st, { children: h }, L)) }) })
472
+ /* @__PURE__ */ l($e, { children: /* @__PURE__ */ l(it, { children: d.map((f, b) => /* @__PURE__ */ l(st, { children: f }, b)) }) })
473
473
  ]
474
474
  }
475
475
  );
476
476
  }
477
- const sn = document.body, De = _(
477
+ const sn = document.body, De = B(
478
478
  "INSERT_CODE_BLOCK_COMMAND"
479
- ), Ae = _(
479
+ ), Ae = B(
480
480
  "SET_CODE_LANGUAGE_COMMAND"
481
481
  );
482
482
  function an() {
483
- const [e, s] = b(null), [t, n] = b(null), [i] = p();
484
- return u(() => i.registerCommand(
483
+ const [e, s] = L(null), [t, n] = L(null), [i, r] = L(!1), [o] = T(), a = () => {
484
+ s(null), n(null);
485
+ };
486
+ return u(() => o.registerCommand(
485
487
  A,
486
488
  () => {
487
- const r = N();
488
- if (!f(r))
489
- return s(null), !1;
490
- const c = X(r), l = E(c, j);
491
- if (l) {
492
- const C = i.getElementByKey(l.getKey()).getBoundingClientRect(), h = C.right, L = C.top + window.scrollY;
493
- s({ x: h, y: L }), n(l.getKey());
489
+ const d = o.getRootElement();
490
+ if (d) {
491
+ const I = d === document.activeElement || d.contains(document.activeElement);
492
+ r((h) => h === I ? h : I);
493
+ }
494
+ const m = p();
495
+ if (!C(m))
496
+ return a(), !1;
497
+ const f = V(m), b = E(f, j);
498
+ if (b) {
499
+ const h = o.getElementByKey(b.getKey()).getBoundingClientRect(), g = h.right, M = h.top + window.scrollY;
500
+ s({ x: g, y: M }), n(b.getKey());
494
501
  } else
495
- s(null);
502
+ a();
496
503
  return !1;
497
504
  },
498
- m
499
- ), [i]), e && le(
500
- /* @__PURE__ */ a(rn, { codeBlockCoords: e, codeNodeKey: t }),
505
+ N
506
+ ), [o]), u(() => o.registerCommand(
507
+ X,
508
+ () => (r(!1), a(), !1),
509
+ N
510
+ ), [o]), u(() => {
511
+ const c = () => {
512
+ r(!0);
513
+ }, d = () => {
514
+ r(!1), a();
515
+ };
516
+ return o.registerRootListener((m, f) => {
517
+ m && (m.addEventListener("focus", c), m.addEventListener("blur", d)), f && (f.removeEventListener("focus", c), f.removeEventListener("blur", d));
518
+ });
519
+ }, [o]), e && i && le(
520
+ /* @__PURE__ */ l(rn, { codeBlockCoords: e, codeNodeKey: t }),
501
521
  sn
502
522
  );
503
523
  }
504
524
  function ln() {
505
- const [e] = p();
506
- return u(() => kt(e), [e]), u(() => e.registerNodeTransform(W, (t) => {
525
+ const [e] = T();
526
+ return u(() => _t(e), [e]), u(() => e.registerNodeTransform(W, (t) => {
507
527
  if (!t.isSimpleText())
508
528
  return;
509
529
  const n = t.getTextContent();
510
530
  if (n.startsWith("``` ")) {
511
- const i = t.getPreviousSibling(), o = E(t, B), r = o !== null && o.getChildrenSize() === 1, c = w(i);
512
- if (r || c) {
531
+ const i = t.getPreviousSibling(), r = E(t, k), o = r !== null && r.getChildrenSize() === 1, a = w(i);
532
+ if (o || a) {
513
533
  if (n.length > 4)
514
534
  return;
515
- const l = Ce();
516
- t.replace(l), l.select();
517
- const d = l.getNextSibling();
535
+ const c = Ce();
536
+ t.replace(c), c.select();
537
+ const d = c.getNextSibling();
518
538
  w(d) && d.remove();
519
539
  return;
520
540
  }
@@ -523,7 +543,7 @@ function ln() {
523
543
  De,
524
544
  () => {
525
545
  const t = Y();
526
- if (f(t)) {
546
+ if (C(t)) {
527
547
  const n = Ce();
528
548
  return t.insertNodes([n]), n.selectStart(), setTimeout(() => {
529
549
  e.focus();
@@ -531,91 +551,91 @@ function ln() {
531
551
  }
532
552
  return !1;
533
553
  },
534
- m
554
+ N
535
555
  ), [e]), u(() => e.registerCommand(
536
556
  Ae,
537
557
  (t) => {
538
- const [n, i] = t, o = G(n);
539
- return j(o) ? (o.setLanguage(i), !0) : !1;
558
+ const [n, i] = t, r = G(n);
559
+ return j(r) ? (r.setLanguage(i), !0) : !1;
540
560
  },
541
- m
561
+ N
542
562
  ), [e]), u(() => e.registerCommand(
543
563
  se,
544
564
  (t) => {
545
- const n = N();
546
- if (!f(n) || !n.isCollapsed())
565
+ const n = p();
566
+ if (!C(n) || !n.isCollapsed())
547
567
  return !1;
548
- const i = n.anchor.getNode(), o = E(i, j);
549
- return o && n.anchor.offset === 0 && o.getTextContent() === "" ? (o.remove(), !0) : !1;
568
+ const i = n.anchor.getNode(), r = E(i, j);
569
+ return r && n.anchor.offset === 0 && r.getTextContent() === "" ? (r.remove(), !0) : !1;
550
570
  },
551
- m
571
+ N
552
572
  ), [e]), null;
553
573
  }
554
574
  function cn() {
555
- return /* @__PURE__ */ I(be, { children: [
556
- /* @__PURE__ */ a(ln, {}),
557
- /* @__PURE__ */ a(an, {})
575
+ return /* @__PURE__ */ $(be, { children: [
576
+ /* @__PURE__ */ l(ln, {}),
577
+ /* @__PURE__ */ l(an, {})
558
578
  ] });
559
579
  }
560
- const _e = _(
580
+ const Be = B(
561
581
  "INSERT_HORIZONTAL_DIVIDER_COMMAND"
562
582
  );
563
583
  function dn() {
564
- const [e] = p();
584
+ const [e] = T();
565
585
  return u(() => {
566
- if (!e.hasNodes([Ot]))
586
+ if (!e.hasNodes([yt]))
567
587
  throw new Error("HorizontalDividerNode not registered on editor");
568
588
  return e.registerCommand(
569
- _e,
589
+ Be,
570
590
  () => {
571
591
  const t = Y();
572
- if (f(t)) {
573
- const n = vt();
592
+ if (C(t)) {
593
+ const n = Ot();
574
594
  t.insertNodes([n]);
575
595
  let i = n.getNextSibling() || n.getParent().getNextSibling();
576
- return i || (i = F(), n.insertAfter(i)), i.selectStart(), setTimeout(() => {
596
+ return i || (i = K(), n.insertAfter(i)), i.selectStart(), setTimeout(() => {
577
597
  e.focus();
578
598
  }, 0), !0;
579
599
  }
580
600
  return !1;
581
601
  },
582
- m
602
+ N
583
603
  );
584
604
  }, [e]), null;
585
605
  }
586
- const ke = _("INSERT_IMAGE_COMMAND"), Te = "selected";
606
+ const _e = B("INSERT_IMAGE_COMMAND"), Te = "selected";
587
607
  function un(e) {
588
608
  return e && e.type && e.type.startsWith("image/");
589
609
  }
590
610
  function gn() {
591
- const [e] = p(), s = z(null);
611
+ const [e] = T(), s = z(null);
592
612
  return u(() => {
593
613
  if (!e.hasNode(he))
594
614
  throw new Error("ImagePlugin: ImageNode not registered on editor");
595
615
  return e.registerCommand(
596
- ke,
616
+ _e,
597
617
  (n) => {
598
- const i = n, o = Y();
599
- if (f(o)) {
600
- const r = Ne(i);
601
- o.insertNodes([r]);
602
- let c = r.getNextSibling() || r.getParent().getNextSibling();
603
- return c || (c = F(), r.insertAfter(c)), r.select(), !0;
618
+ const i = n, r = Y();
619
+ if (C(r)) {
620
+ const o = Ne(i);
621
+ r.insertNodes([o]);
622
+ let a = o.getNextSibling() || o.getParent().getNextSibling();
623
+ return a || (a = K(), o.insertAfter(a)), o.select(), !0;
604
624
  }
605
625
  return !1;
606
626
  },
607
- m
627
+ N
608
628
  );
609
629
  }, [e]), u(() => e.registerCommand(
610
630
  A,
611
631
  () => {
612
632
  s.current && (s.current.classList.remove(Te), s.current = null);
613
- const n = N();
633
+ const n = p();
614
634
  if (ae(n) && n.getNodes().length === 1) {
615
635
  const i = n.getNodes()[0];
616
636
  if (Pt(i)) {
617
- const o = e.getElementByKey(i.getKey());
618
- o.classList.add(Te), s.current = o;
637
+ const r = e.getElementByKey(i.getKey());
638
+ r.classList.add(Te), s.current = r;
619
639
  }
620
640
  }
621
641
  return !1;
@@ -627,22 +647,22 @@ function gn() {
627
647
  const i = n.clipboardData;
628
648
  if (!i)
629
649
  return !1;
630
- const r = Array.from(i.files).filter(un);
631
- if (r.length === 1) {
650
+ const o = Array.from(i.files).filter(un);
651
+ if (o.length === 1) {
632
652
  n.preventDefault();
633
- const c = r[0], l = N() || Y();
634
- if (!f(l))
653
+ const a = o[0], c = p() || Y();
654
+ if (!C(c))
635
655
  return !1;
636
- const d = URL.createObjectURL(c), C = Ne(d);
637
- l.insertNodes([C]);
638
- let h = C.getNextSibling() || C.getParent().getNextSibling();
639
- return h || (h = F(), C.insertAfter(h)), C.select(), !0;
656
+ const d = URL.createObjectURL(a), m = Ne(d);
657
+ c.insertNodes([m]);
658
+ let f = m.getNextSibling() || m.getParent().getNextSibling();
659
+ return f || (f = K(), m.insertAfter(f)), m.select(), !0;
640
660
  }
641
661
  return !1;
642
662
  },
643
- m
663
+ N
644
664
  ), [e]), // Make the Image selectable
645
- /* @__PURE__ */ a(
665
+ /* @__PURE__ */ l(
646
666
  de,
647
667
  {
648
668
  nodeType: he,
@@ -655,9 +675,9 @@ function gn() {
655
675
  }
656
676
  const q = 24;
657
677
  function fn() {
658
- const [e] = p();
659
- return /* @__PURE__ */ a(ce, { "aria-label": "Block toolbar", id: "block-toolbar", children: /* @__PURE__ */ I(K, { "aria-label": "Media", children: [
660
- /* @__PURE__ */ a(
678
+ const [e] = T();
679
+ return /* @__PURE__ */ l(ce, { "aria-label": "Block toolbar", id: "block-toolbar", children: /* @__PURE__ */ $(F, { "aria-label": "Media", children: [
680
+ /* @__PURE__ */ l(
661
681
  lt,
662
682
  {
663
683
  acceptedFileTypes: ["image/png", "image/jpeg", "image/gif"],
@@ -670,39 +690,39 @@ function fn() {
670
690
  return;
671
691
  }
672
692
  const i = new FileReader();
673
- i.onload = (o) => {
674
- var c;
675
- const r = (c = o.target) == null ? void 0 : c.result;
676
- typeof r == "string" ? e.dispatchCommand(ke, r) : alert("Failed to read file as Data URL.");
677
- }, i.onerror = (o) => {
678
- console.error("Error reading file:", o), alert("Error reading file.");
693
+ i.onload = (r) => {
694
+ var a;
695
+ const o = (a = r.target) == null ? void 0 : a.result;
696
+ typeof o == "string" ? e.dispatchCommand(_e, o) : alert("Failed to read file as Data URL.");
697
+ }, i.onerror = (r) => {
698
+ console.error("Error reading file:", r), alert("Error reading file.");
679
699
  }, i.readAsDataURL(n);
680
700
  },
681
701
  allowsMultiple: !1,
682
- children: /* @__PURE__ */ a(v, { "aria-label": "image", children: /* @__PURE__ */ a(Tt, { size: q }) })
702
+ children: /* @__PURE__ */ l(O, { "aria-label": "image", children: /* @__PURE__ */ l(Tt, { size: q }) })
683
703
  }
684
704
  ),
685
- /* @__PURE__ */ a(
686
- v,
705
+ /* @__PURE__ */ l(
706
+ O,
687
707
  {
688
708
  "aria-label": "code block",
689
709
  onPress: () => {
690
710
  e.dispatchCommand(De, void 0);
691
711
  },
692
- children: /* @__PURE__ */ a(Et, { size: q })
712
+ children: /* @__PURE__ */ l(Et, { size: q })
693
713
  }
694
714
  ),
695
- /* @__PURE__ */ a(
696
- v,
715
+ /* @__PURE__ */ l(
716
+ O,
697
717
  {
698
718
  "aria-label": "horizontal divider",
699
719
  onPress: () => {
700
720
  e.dispatchCommand(
701
- _e,
721
+ Be,
702
722
  void 0
703
723
  );
704
724
  },
705
- children: /* @__PURE__ */ a(bt, { size: q })
725
+ children: /* @__PURE__ */ l(bt, { size: q })
706
726
  }
707
727
  )
708
728
  ] }) });
@@ -713,35 +733,35 @@ function mn({
713
733
  toolbarTriggerId: t,
714
734
  toolbarPopoverId: n
715
735
  }) {
716
- const [i, o] = b({
717
- x: $,
718
- y: $
719
- }), r = z(null);
736
+ const [i, r] = L({
737
+ x: S,
738
+ y: S
739
+ }), o = z(null);
720
740
  return u(() => {
721
- o(
741
+ r(
722
742
  Wt(
723
743
  e,
724
- r,
744
+ o,
725
745
  s
726
746
  )
727
747
  );
728
- }, [e]), /* @__PURE__ */ I(at, { children: [
729
- /* @__PURE__ */ a(
730
- v,
748
+ }, [e]), /* @__PURE__ */ $(at, { children: [
749
+ /* @__PURE__ */ l(
750
+ O,
731
751
  {
732
752
  "aria-label": "Block toolbar trigger",
733
753
  className: "block-toolbar-trigger",
734
754
  id: t,
735
- ref: r,
755
+ ref: o,
736
756
  style: {
737
757
  position: "absolute",
738
758
  top: i.y,
739
759
  left: i.x
740
760
  },
741
- children: /* @__PURE__ */ a(pt, { size: q })
761
+ children: /* @__PURE__ */ l(pt, { size: q })
742
762
  }
743
763
  ),
744
- /* @__PURE__ */ a(
764
+ /* @__PURE__ */ l(
745
765
  $e,
746
766
  {
747
767
  className: "block-toolbar-popover",
@@ -749,60 +769,60 @@ function mn({
749
769
  placement: "end",
750
770
  shouldFlip: !1,
751
771
  offset: s,
752
- children: /* @__PURE__ */ a(fn, {})
772
+ children: /* @__PURE__ */ l(fn, {})
753
773
  }
754
774
  )
755
775
  ] });
756
776
  }
757
777
  const hn = document.body;
758
778
  function Nn({ toolbarGap: e }) {
759
- const [s, t] = b(null), [n] = p(), [i, o] = b(!1), [r, c] = b(!1), l = z(Math.random().toString(36).substring(2, 9)), d = `block-toolbar-trigger-${l.current}`, C = `block-toolbar-popover-${l.current}`, h = () => o(!0), L = (x) => {
779
+ const [s, t] = L(null), [n] = T(), [i, r] = L(!1), [o, a] = L(!1), c = z(Math.random().toString(36).substring(2, 9)), d = `block-toolbar-trigger-${c.current}`, m = `block-toolbar-popover-${c.current}`, f = () => r(!0), b = (I) => {
760
780
  setTimeout(() => {
761
- const T = document.getElementById(d);
762
- T && (T === document.activeElement || T.contains(document.activeElement) || T.contains(x.relatedTarget)) || o(!1);
781
+ const h = document.getElementById(d);
782
+ h && (h === document.activeElement || h.contains(document.activeElement) || h.contains(I.relatedTarget)) || r(!1);
763
783
  }, 10);
764
784
  };
765
785
  return u(() => {
766
- const x = () => {
767
- const g = !!document.getElementById(C);
768
- c(g);
769
- }, T = new MutationObserver(x);
770
- return T.observe(document.body, {
786
+ const I = () => {
787
+ const g = !!document.getElementById(m);
788
+ a(g);
789
+ }, h = new MutationObserver(I);
790
+ return h.observe(document.body, {
771
791
  childList: !0,
772
792
  subtree: !0
773
- }), x(), () => T.disconnect();
793
+ }), I(), () => h.disconnect();
774
794
  }, []), u(() => n.registerRootListener(
775
- (T, g) => {
776
- T && (T.addEventListener("focus", h), T.addEventListener("blur", L)), g && (g.removeEventListener("focus", h), g.removeEventListener("blur", L));
795
+ (h, g) => {
796
+ h && (h.addEventListener("focus", f), h.addEventListener("blur", b)), g && (g.removeEventListener("focus", f), g.removeEventListener("blur", b));
777
797
  }
778
798
  ), [n]), u(() => n.registerCommand(
779
799
  A,
780
800
  () => {
781
- const T = n.getRootElement();
782
- if (T) {
783
- const S = T === document.activeElement || T.contains(document.activeElement);
784
- S !== i && o(S);
801
+ const h = n.getRootElement();
802
+ if (h) {
803
+ const x = h === document.activeElement || h.contains(document.activeElement);
804
+ x !== i && r(x);
785
805
  }
786
- const g = N();
787
- if (!f(g) || !g.isCollapsed())
806
+ const g = p();
807
+ if (!C(g) || !g.isCollapsed())
788
808
  return t(null), !1;
789
- const M = X(g);
790
- if (B(M) && M.getTextContent() === "") {
791
- const P = n.getElementByKey(M.getKey()).getBoundingClientRect(), V = P.left, Z = P.top + P.height / 2 + window.scrollY;
792
- t({ x: V, y: Z });
809
+ const M = V(g);
810
+ if (k(M) && M.getTextContent() === "") {
811
+ const P = n.getElementByKey(M.getKey()).getBoundingClientRect(), Z = P.left, J = P.top + P.height / 2 + window.scrollY;
812
+ t({ x: Z, y: J });
793
813
  } else
794
814
  t(null);
795
815
  return !1;
796
816
  },
797
- m
798
- ), [n]), s && (i || r) && le(
799
- /* @__PURE__ */ a(
817
+ N
818
+ ), [n]), s && (i || o) && le(
819
+ /* @__PURE__ */ l(
800
820
  mn,
801
821
  {
802
822
  selectionRectCoords: s,
803
823
  TOOLBAR_OFFSET: e,
804
824
  toolbarTriggerId: d,
805
- toolbarPopoverId: C
825
+ toolbarPopoverId: m
806
826
  }
807
827
  ),
808
828
  hn
@@ -814,21 +834,21 @@ const Cn = [
814
834
  ], pn = [
815
835
  ["$$", "$$"],
816
836
  ["\\[", "\\]"]
817
- ], Ee = (e) => e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), Be = (e, s) => {
837
+ ], Ee = (e) => e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), ke = (e, s) => {
818
838
  let t = null;
819
839
  for (const [n, i] of s) {
820
- const r = new RegExp(
840
+ const o = new RegExp(
821
841
  `(.*?)(${Ee(n)})(.*?)(${Ee(i)})`,
822
842
  "g"
823
843
  ).exec(e);
824
- if (r) {
825
- const c = r[3];
826
- if (c && c.trim() !== "") {
827
- const l = r.index + r[1].length, d = r.index + r[0].length;
828
- (!t || l < t.start) && (t = {
829
- start: l,
844
+ if (o) {
845
+ const a = o[3];
846
+ if (a && a.trim() !== "") {
847
+ const c = o.index + o[1].length, d = o.index + o[0].length;
848
+ (!t || c < t.start) && (t = {
849
+ start: c,
830
850
  end: d,
831
- content: n + c + i
851
+ content: n + a + i
832
852
  });
833
853
  }
834
854
  }
@@ -836,7 +856,7 @@ const Cn = [
836
856
  return t;
837
857
  };
838
858
  function Tn() {
839
- const [e] = p();
859
+ const [e] = T();
840
860
  return u(() => {
841
861
  if (!e.hasNodes([Q, Dt]))
842
862
  throw new Error(
@@ -845,46 +865,46 @@ function Tn() {
845
865
  }, [e]), u(() => e.registerNodeTransform(W, (t) => {
846
866
  if (!t.isSimpleText() || R(t) || E(t, D))
847
867
  return;
848
- const n = t.getTextContent(), i = Be(n, Cn);
868
+ const n = t.getTextContent(), i = ke(n, Cn);
849
869
  if (i) {
850
- const { start: o, end: r, content: c } = i;
851
- let l;
852
- const d = O(c, !0);
853
- return o === 0 ? ([l] = t.splitText(r), l.insertBefore(d), l.remove()) : ([, l] = t.splitText(o, r), l.replace(d)), d;
870
+ const { start: r, end: o, content: a } = i;
871
+ let c;
872
+ const d = y(a, !0);
873
+ return r === 0 ? ([c] = t.splitText(o), c.insertBefore(d), c.remove()) : ([, c] = t.splitText(r, o), c.replace(d)), d;
854
874
  }
855
875
  }), [e]), u(() => e.registerCommand(
856
876
  A,
857
877
  () => {
858
- const t = N(), n = /* @__PURE__ */ new Set();
878
+ const t = p(), n = /* @__PURE__ */ new Set();
859
879
  if (ae(t)) {
860
- const r = t.getNodes();
861
- if (r.length === 1 && k(r[0])) {
862
- const c = r[0];
863
- if (c.isInline()) {
864
- let l = c.getEquation();
865
- l.startsWith("$") && l.endsWith("$") ? l = l.slice(1, -1) : l.startsWith("\\(") && l.endsWith("\\)") && (l = l.slice(2, -2));
866
- const d = ee(l);
867
- return c.replace(d), d.select(), !0;
880
+ const o = t.getNodes();
881
+ if (o.length === 1 && _(o[0])) {
882
+ const a = o[0];
883
+ if (a.isInline()) {
884
+ let c = a.getEquation();
885
+ c.startsWith("$") && c.endsWith("$") ? c = c.slice(1, -1) : c.startsWith("\\(") && c.endsWith("\\)") && (c = c.slice(2, -2));
886
+ const d = te(c);
887
+ return a.replace(d), d.select(), !0;
868
888
  }
869
889
  }
870
- } else f(t) && t.getNodes().forEach((r) => n.add(r.getKey()));
871
- return U().getAllTextNodes().forEach((r) => {
872
- if (R(r) && !n.has(r.getKey())) {
873
- let c = r.getTextContent();
874
- if (!c) {
875
- r.remove();
890
+ } else C(t) && t.getNodes().forEach((o) => n.add(o.getKey()));
891
+ return U().getAllTextNodes().forEach((o) => {
892
+ if (R(o) && !n.has(o.getKey())) {
893
+ let a = o.getTextContent();
894
+ if (!a) {
895
+ o.remove();
876
896
  return;
877
897
  }
878
- let l = !1;
879
- c.startsWith("$") && c.endsWith("$") && c.length >= 2 && (c = c.slice(1, -1), l = !0);
880
- const d = l ? O(`$$${c}$$`, !1) : O(`$${c}$`, !0);
881
- r.replace(d);
898
+ let c = !1;
899
+ a.startsWith("$") && a.endsWith("$") && a.length >= 2 && (a = a.slice(1, -1), c = !0);
900
+ const d = c ? y(`$$${a}$$`, !1) : y(`$${a}$`, !0);
901
+ o.replace(d);
882
902
  }
883
903
  }), !1;
884
904
  },
885
- m
905
+ N
886
906
  ), [e]), u(() => e.registerCommand(
887
- ie,
907
+ X,
888
908
  () => (e.update(() => {
889
909
  U().getAllTextNodes().forEach((n) => {
890
910
  if (R(n)) {
@@ -893,58 +913,58 @@ function Tn() {
893
913
  n.remove();
894
914
  return;
895
915
  }
896
- let o = !1;
897
- i.startsWith("$") && i.endsWith("$") && i.length >= 2 && (i = i.slice(1, -1), o = !0);
898
- const r = o ? O(`$$${i}$$`, !1) : O(`$${i}$`, !0);
899
- n.replace(r), Me(null);
916
+ let r = !1;
917
+ i.startsWith("$") && i.endsWith("$") && i.length >= 2 && (i = i.slice(1, -1), r = !0);
918
+ const o = r ? y(`$$${i}$$`, !1) : y(`$${i}$`, !0);
919
+ n.replace(o), Me(null);
900
920
  }
901
921
  });
902
922
  }), !1),
903
- m
923
+ N
904
924
  ), [e]), u(() => e.registerCommand(
905
925
  Ye,
906
926
  (s) => {
907
- const t = N();
908
- if (!f(t) || !t.isCollapsed())
927
+ const t = p();
928
+ if (!C(t) || !t.isCollapsed())
909
929
  return !1;
910
- const n = oe(t.anchor, !1);
911
- if (k(n) && n.isInline()) {
912
- let o = n.getEquation();
913
- o.startsWith("$") && o.endsWith("$") ? o = o.slice(1, -1) : o.startsWith("\\(") && o.endsWith("\\)") && (o = o.slice(2, -2));
914
- const r = ee(o);
915
- return n.replace(r), r.select(0, 0), !0;
930
+ const n = re(t.anchor, !1);
931
+ if (_(n) && n.isInline()) {
932
+ let r = n.getEquation();
933
+ r.startsWith("$") && r.endsWith("$") ? r = r.slice(1, -1) : r.startsWith("\\(") && r.endsWith("\\)") && (r = r.slice(2, -2));
934
+ const o = te(r);
935
+ return n.replace(o), o.select(0, 0), !0;
916
936
  }
917
937
  return !1;
918
938
  },
919
- m
939
+ N
920
940
  ), [e]), u(() => e.registerCommand(
921
941
  se,
922
942
  (s) => {
923
- const t = N();
924
- if (!f(t) || !t.isCollapsed())
943
+ const t = p();
944
+ if (!C(t) || !t.isCollapsed())
925
945
  return !1;
926
- const n = oe(t.anchor, !0);
927
- if (k(n) && n.isInline()) {
928
- let o = n.getEquation();
929
- o.startsWith("$") && o.endsWith("$") ? o = o.slice(1, -1) : o.startsWith("\\(") && o.endsWith("\\)") && (o = o.slice(2, -2));
930
- const r = ee(o);
931
- return n.replace(r), r.select(), !0;
946
+ const n = re(t.anchor, !0);
947
+ if (_(n) && n.isInline()) {
948
+ let r = n.getEquation();
949
+ r.startsWith("$") && r.endsWith("$") ? r = r.slice(1, -1) : r.startsWith("\\(") && r.endsWith("\\)") && (r = r.slice(2, -2));
950
+ const o = te(r);
951
+ return n.replace(o), o.select(), !0;
932
952
  }
933
953
  return !1;
934
954
  },
935
- m
955
+ N
936
956
  ), [e]), u(() => e.registerCommand(
937
957
  A,
938
958
  () => {
939
- const s = N();
940
- if (!f(s) || !s.isCollapsed())
959
+ const s = p();
960
+ if (!C(s) || !s.isCollapsed())
941
961
  return !1;
942
962
  const t = s.anchor.getNode();
943
963
  return R(t) && (t.getNextSibling() || t.insertAfter(Qe(" "))), !1;
944
964
  },
945
965
  je
946
966
  ), [e]), // Register click event for MathNode
947
- /* @__PURE__ */ a(
967
+ /* @__PURE__ */ l(
948
968
  de,
949
969
  {
950
970
  nodeType: Q,
@@ -957,7 +977,7 @@ function Tn() {
957
977
  );
958
978
  }
959
979
  function En() {
960
- const [e] = p();
980
+ const [e] = T();
961
981
  return u(() => {
962
982
  if (!e.hasNodes([Q, At]))
963
983
  throw new Error(
@@ -968,60 +988,60 @@ function En() {
968
988
  return;
969
989
  const n = t.getTextContent();
970
990
  if (n.startsWith("$$ ")) {
971
- const o = t.getPreviousSibling(), r = E(t, B), c = r !== null && r.getChildrenSize() === 1, l = w(o);
972
- if (c || l) {
991
+ const r = t.getPreviousSibling(), o = E(t, k), a = o !== null && o.getChildrenSize() === 1, c = w(r);
992
+ if (a || c) {
973
993
  if (n.length > 3)
974
994
  return;
975
- const d = te("");
995
+ const d = ne("");
976
996
  t.replace(d), d.select();
977
- const C = d.getNextSibling();
978
- w(C) && C.remove();
997
+ const m = d.getNextSibling();
998
+ w(m) && m.remove();
979
999
  return;
980
1000
  }
981
1001
  }
982
- const i = Be(n, pn);
1002
+ const i = ke(n, pn);
983
1003
  if (i) {
984
- const { start: o, end: r, content: c } = i;
985
- let l;
986
- const d = O(c, !1);
987
- return o === 0 ? ([l] = t.splitText(r), l.insertBefore(d), l.remove()) : ([, l] = t.splitText(o, r), l.replace(d)), d;
1004
+ const { start: r, end: o, content: a } = i;
1005
+ let c;
1006
+ const d = y(a, !1);
1007
+ return r === 0 ? ([c] = t.splitText(o), c.insertBefore(d), c.remove()) : ([, c] = t.splitText(r, o), c.replace(d)), d;
988
1008
  }
989
1009
  }), [e]), u(() => e.registerCommand(
990
1010
  A,
991
1011
  () => {
992
- const t = N(), n = /* @__PURE__ */ new Set();
1012
+ const t = p(), n = /* @__PURE__ */ new Set();
993
1013
  if (ae(t)) {
994
- const r = t.getNodes();
995
- if (r.length === 1 && k(r[0])) {
996
- const c = r[0];
997
- if (!c.isInline()) {
998
- let l = c.getEquation();
999
- (l.startsWith("$$") && l.endsWith("$$") || l.startsWith("\\[") && l.endsWith("\\]")) && (l = l.slice(2, -2));
1000
- const d = te(l);
1001
- return c.replace(d), d.select(), !0;
1014
+ const o = t.getNodes();
1015
+ if (o.length === 1 && _(o[0])) {
1016
+ const a = o[0];
1017
+ if (!a.isInline()) {
1018
+ let c = a.getEquation();
1019
+ (c.startsWith("$$") && c.endsWith("$$") || c.startsWith("\\[") && c.endsWith("\\]")) && (c = c.slice(2, -2));
1020
+ const d = ne(c);
1021
+ return a.replace(d), d.select(), !0;
1002
1022
  }
1003
1023
  }
1004
- } else f(t) && t.getNodes().forEach((r) => {
1005
- n.add(r.getKey());
1006
- const c = E(r, D);
1007
- c && n.add(c.getKey());
1024
+ } else C(t) && t.getNodes().forEach((o) => {
1025
+ n.add(o.getKey());
1026
+ const a = E(o, D);
1027
+ a && n.add(a.getKey());
1008
1028
  });
1009
- const o = e.getEditorState()._nodeMap;
1010
- for (const [, r] of o)
1011
- if (D(r) && r.isAttached() && !n.has(r.getKey())) {
1012
- const c = r.getTextContent();
1013
- if (!c) {
1014
- r.remove();
1029
+ const r = e.getEditorState()._nodeMap;
1030
+ for (const [, o] of r)
1031
+ if (D(o) && o.isAttached() && !n.has(o.getKey())) {
1032
+ const a = o.getTextContent();
1033
+ if (!a) {
1034
+ o.remove();
1015
1035
  continue;
1016
1036
  }
1017
- const l = O(`$$${c}$$`, !1);
1018
- r.replace(l);
1037
+ const c = y(`$$${a}$$`, !1);
1038
+ o.replace(c);
1019
1039
  }
1020
1040
  return !1;
1021
1041
  },
1022
- m
1042
+ N
1023
1043
  ), [e]), u(() => e.registerCommand(
1024
- ie,
1044
+ X,
1025
1045
  () => (e.update(() => {
1026
1046
  const s = U();
1027
1047
  nt(s).forEach(({ node: n }) => {
@@ -1031,17 +1051,17 @@ function En() {
1031
1051
  n.remove();
1032
1052
  return;
1033
1053
  }
1034
- const o = O(`$$${i}$$`, !1);
1035
- n.replace(o), Me(null);
1054
+ const r = y(`$$${i}$$`, !1);
1055
+ n.replace(r), Me(null);
1036
1056
  }
1037
1057
  });
1038
1058
  }), !1),
1039
- m
1059
+ N
1040
1060
  ), [e]), u(() => e.registerCommand(
1041
1061
  Xe,
1042
1062
  () => {
1043
- const t = N();
1044
- if (!f(t))
1063
+ const t = p();
1064
+ if (!C(t))
1045
1065
  return !1;
1046
1066
  const n = t.getNodes()[0], i = E(
1047
1067
  n,
@@ -1049,27 +1069,27 @@ function En() {
1049
1069
  );
1050
1070
  if (!i)
1051
1071
  return !1;
1052
- const o = i.getLastChild();
1053
- return t.isCollapsed() && (t.anchor.getNode().getKey() === i.getKey() && t.anchor.offset === 0 && i.getChildrenSize() === 0 || o && w(o) && t.anchor.getNode().getKey() === i.getKey() && t.anchor.offset === i.getChildrenSize() || o && Ve(o) && t.anchor.getNode().getKey() === o.getKey() && t.anchor.offset === o.getTextContent().length) ? !1 : (t.insertLineBreak(), !0);
1072
+ const r = i.getLastChild();
1073
+ return t.isCollapsed() && (t.anchor.getNode().getKey() === i.getKey() && t.anchor.offset === 0 && i.getChildrenSize() === 0 || r && w(r) && t.anchor.getNode().getKey() === i.getKey() && t.anchor.offset === i.getChildrenSize() || r && Ve(r) && t.anchor.getNode().getKey() === r.getKey() && t.anchor.offset === r.getTextContent().length) ? !1 : (t.insertLineBreak(), !0);
1054
1074
  },
1055
- m
1075
+ N
1056
1076
  ), [e]), u(() => e.registerCommand(
1057
1077
  se,
1058
1078
  (s) => {
1059
- const t = N();
1060
- if (!f(t) || !t.isCollapsed())
1079
+ const t = p();
1080
+ if (!C(t) || !t.isCollapsed())
1061
1081
  return !1;
1062
- const n = oe(t.anchor, !0);
1063
- if (k(n) && !n.isInline()) {
1064
- let o = n.getEquation();
1065
- (o.startsWith("$$") && o.endsWith("$$") || o.startsWith("\\[") && o.endsWith("\\]")) && (o = o.slice(2, -2));
1066
- const r = te(o);
1067
- return n.replace(r), r.select(), !0;
1082
+ const n = re(t.anchor, !0);
1083
+ if (_(n) && !n.isInline()) {
1084
+ let r = n.getEquation();
1085
+ (r.startsWith("$$") && r.endsWith("$$") || r.startsWith("\\[") && r.endsWith("\\]")) && (r = r.slice(2, -2));
1086
+ const o = ne(r);
1087
+ return n.replace(o), o.select(), !0;
1068
1088
  }
1069
1089
  return !1;
1070
1090
  },
1071
- m
1072
- ), [e]), /* @__PURE__ */ a(
1091
+ N
1092
+ ), [e]), /* @__PURE__ */ l(
1073
1093
  de,
1074
1094
  {
1075
1095
  nodeType: Q,
@@ -1083,7 +1103,7 @@ function En() {
1083
1103
  }
1084
1104
  const bn = 3;
1085
1105
  function Ln() {
1086
- const [e] = p();
1106
+ const [e] = T();
1087
1107
  return u(() => e.registerNodeTransform(
1088
1108
  Ze,
1089
1109
  (t) => {
@@ -1094,39 +1114,39 @@ function Ln() {
1094
1114
  }
1095
1115
  }
1096
1116
  ), [e]), u(() => e.registerNodeTransform(W, (t) => {
1097
- if (!E(t, B) || E(t, B).getFirstDescendant() !== t)
1117
+ if (!E(t, k) || E(t, k).getFirstDescendant() !== t)
1098
1118
  return;
1099
- const i = N();
1100
- if (f(i) && i.isCollapsed()) {
1101
- const r = i.anchor.offset;
1102
- t.getTextContent() === "1. " && r === 3 ? (me("number"), t.setTextContent("")) : t.getTextContent() === "- " && r === 2 && (me("bullet"), t.setTextContent(""));
1119
+ const i = p();
1120
+ if (C(i) && i.isCollapsed()) {
1121
+ const o = i.anchor.offset;
1122
+ t.getTextContent() === "1. " && o === 3 ? (me("number"), t.setTextContent("")) : t.getTextContent() === "- " && o === 2 && (me("bullet"), t.setTextContent(""));
1103
1123
  }
1104
1124
  }), [e]), u(() => e.registerCommand(
1105
1125
  et,
1106
1126
  (t) => {
1107
- const n = N();
1108
- if (!f(n))
1127
+ const n = p();
1128
+ if (!C(n))
1109
1129
  return !1;
1110
- const i = X(n), o = E(i, fe);
1111
- if (!o)
1130
+ const i = V(n), r = E(i, fe);
1131
+ if (!r)
1112
1132
  return !1;
1113
- const r = o.getIndent();
1133
+ const o = r.getIndent();
1114
1134
  if (t.shiftKey) {
1115
- if (r <= 0)
1135
+ if (o <= 0)
1116
1136
  return !1;
1117
- o.setIndent(r - 1);
1137
+ r.setIndent(o - 1);
1118
1138
  } else {
1119
- if (r > bn)
1139
+ if (o > bn)
1120
1140
  return !1;
1121
- o.setIndent(r + 1);
1141
+ r.setIndent(o + 1);
1122
1142
  }
1123
1143
  return !0;
1124
1144
  },
1125
- m
1145
+ N
1126
1146
  ), [e]), null;
1127
1147
  }
1128
1148
  function Mn() {
1129
- const [e] = p(), s = (t) => {
1149
+ const [e] = T(), s = (t) => {
1130
1150
  t.key === "Tab" && t.preventDefault();
1131
1151
  };
1132
1152
  return u(() => e.registerRootListener(
@@ -1136,7 +1156,7 @@ function Mn() {
1136
1156
  ), [e]), null;
1137
1157
  }
1138
1158
  function In({ editorRef: e }) {
1139
- const [s] = p();
1159
+ const [s] = T();
1140
1160
  return u(() => {
1141
1161
  if (e)
1142
1162
  return e.current = s, () => {
@@ -1150,32 +1170,32 @@ function jn({
1150
1170
  editorRef: t,
1151
1171
  blockToolbarGap: n,
1152
1172
  spellCheck: i,
1153
- isHeadingOneFirst: o
1173
+ isHeadingOneFirst: r
1154
1174
  }) {
1155
- return /* @__PURE__ */ I(Ke, { initialConfig: e, children: [
1156
- /* @__PURE__ */ a(
1157
- Fe,
1175
+ return /* @__PURE__ */ $(Fe, { initialConfig: e, children: [
1176
+ /* @__PURE__ */ l(
1177
+ Ke,
1158
1178
  {
1159
- contentEditable: /* @__PURE__ */ a(Rt, { spellCheck: i, className: "editor-input" }),
1179
+ contentEditable: /* @__PURE__ */ l(Rt, { spellCheck: i, className: "editor-input" }),
1160
1180
  ErrorBoundary: Ge
1161
1181
  }
1162
1182
  ),
1163
- /* @__PURE__ */ a(Zt, { isHeadingOneFirst: o }),
1164
- /* @__PURE__ */ a(on, {}),
1165
- /* @__PURE__ */ a(Nn, { toolbarGap: n }),
1166
- /* @__PURE__ */ a(we, {}),
1167
- /* @__PURE__ */ a(We, {}),
1168
- /* @__PURE__ */ a(Tn, {}),
1169
- /* @__PURE__ */ a(En, {}),
1170
- /* @__PURE__ */ a(cn, {}),
1171
- /* @__PURE__ */ a(dn, {}),
1172
- /* @__PURE__ */ a(gn, {}),
1173
- /* @__PURE__ */ a(Bt, {}),
1174
- /* @__PURE__ */ a(Ln, {}),
1175
- /* @__PURE__ */ a(Mn, {}),
1176
- /* @__PURE__ */ a(Ht, { onChange: s }),
1177
- /* @__PURE__ */ a(In, { editorRef: t }),
1178
- /* @__PURE__ */ a(wt, {})
1183
+ /* @__PURE__ */ l(Zt, { isHeadingOneFirst: r }),
1184
+ /* @__PURE__ */ l(on, {}),
1185
+ /* @__PURE__ */ l(Nn, { toolbarGap: n }),
1186
+ /* @__PURE__ */ l(we, {}),
1187
+ /* @__PURE__ */ l(We, {}),
1188
+ /* @__PURE__ */ l(Tn, {}),
1189
+ /* @__PURE__ */ l(En, {}),
1190
+ /* @__PURE__ */ l(cn, {}),
1191
+ /* @__PURE__ */ l(dn, {}),
1192
+ /* @__PURE__ */ l(gn, {}),
1193
+ /* @__PURE__ */ l(kt, {}),
1194
+ /* @__PURE__ */ l(Ln, {}),
1195
+ /* @__PURE__ */ l(Mn, {}),
1196
+ /* @__PURE__ */ l(Ht, { onChange: s }),
1197
+ /* @__PURE__ */ l(In, { editorRef: t }),
1198
+ /* @__PURE__ */ l(wt, {})
1179
1199
  ] });
1180
1200
  }
1181
1201
  export {