lexical-medium-editor 1.2.14 → 1.2.16

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