@markweave/react 0.1.8 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import { createMarkweaveEditorExtensions as e } from "markweave/internal/editor-core/create-editor-extensions";
2
2
  import { getLocalizedSlashCommandSpecs as t, getMarkweaveMessages as n, normalizeMarkweaveLang as r } from "markweave/internal/i18n";
3
3
  import { EditorContent as i, NodeViewWrapper as a, ReactNodeViewRenderer as o, useEditor as s } from "@tiptap/react";
4
- import { AlertTriangle as c, AlignCenter as l, AlignJustify as u, AlignLeft as d, AlignRight as f, Bold as p, Braces as m, Captions as h, Check as g, CheckCircle2 as _, ChevronDown as v, ChevronUp as y, CircleX as b, Code2 as x, Copy as S, CornerDownLeft as C, Download as w, ExternalLink as T, Eye as E, Heading1 as D, Heading2 as O, Heading3 as k, Image as A, ImageUp as j, IndentDecrease as M, IndentIncrease as ee, Info as N, Italic as P, Lightbulb as te, Link2 as F, List as I, ListChecks as ne, ListOrdered as L, Minus as re, MoreVertical as R, Paperclip as z, Pencil as ie, Quote as ae, Replace as oe, Sigma as se, SmilePlus as ce, Sparkles as le, Strikethrough as ue, Subscript as de, Superscript as fe, Table2 as pe, Text as me, Trash2 as he, Type as ge, Underline as _e, Upload as ve, Video as ye } from "lucide-react";
5
- import { useCallback as B, useEffect as V, useLayoutEffect as be, useMemo as H, useRef as U, useState as W, useSyncExternalStore as G } from "react";
6
- import { detectUploadSource as xe, getDirectUploadResult as Se, resolveMarkweaveUploadResult as Ce } from "markweave/internal/plugins/slash-command/upload";
7
- import { MarkweaveCoreImage as we, MarkweaveCoreVideo as Te, attrsFromMarkweaveImageUploadResult as K, attrsFromMarkweaveVideoUploadResult as Ee, attrsFromMarkweaveVideoUrl as De, clampMarkweaveImageWidth as Oe, createMarkweaveImageUploadRequest as ke, createMarkweaveVideoUploadRequest as q, downloadMarkweaveImage as Ae, markweaveVideoIframeAllow as je, normalizeMarkweaveCoreImageAlign as Me, normalizeMarkweaveVideoEmbedUrl as Ne, numberAttribute as Pe, stringAttribute as J } from "markweave/internal/plugins/media/core-media-nodes";
8
- import { getMarkweaveEditorModeState as Y, isMarkweaveEditorLiveEditable as Fe, normalizeMarkweaveEditorMode as Ie, setMarkweaveEditorModeState as Le, subscribeToMarkweaveEditorMode as Re } from "markweave/internal/core/editor-mode-state";
4
+ import { AlertTriangle as c, AlignCenter as l, AlignJustify as u, AlignLeft as d, AlignRight as f, Bold as p, Braces as m, Captions as h, Check as g, CheckCircle2 as _, ChevronDown as v, ChevronUp as y, CircleX as b, Code2 as x, Copy as S, CornerDownLeft as C, Download as w, ExternalLink as T, Eye as E, Heading1 as D, Heading2 as O, Heading3 as k, Image as A, ImageUp as j, IndentDecrease as M, IndentIncrease as ee, Info as N, Italic as P, Lightbulb as F, Link2 as I, List as L, ListChecks as R, ListOrdered as te, Minus as ne, MoreVertical as z, Paperclip as re, Pencil as B, Quote as V, Replace as ie, Sigma as ae, SmilePlus as oe, Sparkles as se, Strikethrough as ce, Subscript as le, Superscript as ue, Table2 as de, Text as fe, Trash2 as pe, Type as me, Underline as he, Upload as ge, Video as _e } from "lucide-react";
5
+ import { useCallback as H, useEffect as U, useLayoutEffect as ve, useMemo as W, useRef as G, useState as K, useSyncExternalStore as ye } from "react";
6
+ import { detectUploadSource as be, getDirectUploadResult as xe, resolveMarkweaveUploadResult as q } from "markweave/internal/plugins/slash-command/upload";
7
+ import { MarkweaveCoreImage as Se, MarkweaveCoreVideo as Ce, attrsFromMarkweaveImageUploadResult as we, attrsFromMarkweaveVideoUploadResult as Te, attrsFromMarkweaveVideoUrl as Ee, clampMarkweaveImageWidth as De, createMarkweaveImageUploadRequest as Oe, createMarkweaveVideoUploadRequest as ke, downloadMarkweaveImage as Ae, markweaveVideoIframeAllow as J, normalizeMarkweaveCoreImageAlign as je, normalizeMarkweaveVideoEmbedUrl as Me, numberAttribute as Ne, stringAttribute as Pe } from "markweave/internal/plugins/media/core-media-nodes";
8
+ import { getMarkweaveEditorModeState as Fe, isMarkweaveEditorLiveEditable as Ie, normalizeMarkweaveEditorMode as Le, setMarkweaveEditorModeState as Re, subscribeToMarkweaveEditorMode as Y } from "markweave/internal/core/editor-mode-state";
9
9
  import { openMarkweaveImagePreview as ze } from "markweave/internal/plugins/media/image-preview";
10
10
  import { Fragment as X, jsx as Z, jsxs as Q } from "react/jsx-runtime";
11
11
  import { createMarkweaveAdapterMediaExtensions as Be } from "markweave/internal/plugins/media/media-extension-factory";
@@ -37,26 +37,26 @@ import { normalizeMarkdownLinkHref as Hn } from "markweave/internal/plugins/mark
37
37
  import { setMarkweaveTableMenuAxisTarget as Un } from "markweave/internal/plugins/table/table-clipboard";
38
38
  import { calculateAnchoredTableMenuPosition as Wn, calculateTableEdgeHandlePosition as Gn, canRunTableCommand as Kn, executeTableMenuCommand as qn, formatTableCopyFeedback as Jn, getActiveTableElement as Yn, getAvailableCellMenuCommandSpecs as Xn, getTableAxisTargetRect as Zn, getTableControlAxisSelectionModel as Qn, getTableEditWithAiRequest as $n, getTableMenuItemGroup as er, getTableMenuItemLabel as tr, getTableMenuItems as nr, getTableSelectionTargetRect as rr, measureTableSelectionOverlay as ir, selectTableAxisFromCell as ar, tableCopyFeedbackTimeoutMs as or, tableMenuLabel as sr } from "markweave/internal/plugins/table/table-ui-model";
39
39
  import { createMarkweaveTocState as cr, emptyMarkweaveTocState as lr, getActiveMarkweaveTocId as ur, getMarkweaveTocItems as dr, getValidMarkweaveTocActiveId as fr, normalizeMarkweaveInnerTocPlacement as pr, observeMarkweaveInnerTocContainerPosition as mr, scrollToMarkweaveTocItem as hr } from "markweave/internal/core/toc-state";
40
- import { normalizeMarkweaveTheme as gr } from "markweave/internal/core/theme";
40
+ import { normalizeMarkweaveCanvasColor as gr, normalizeMarkweaveTheme as _r } from "markweave/internal/core/theme";
41
41
  //#region src/editor-mode-state.ts
42
- var _r = {
42
+ var vr = {
43
43
  mode: "live",
44
44
  editable: !0
45
45
  };
46
- function vr(e) {
47
- return G((t) => Re(e, t), () => Y(e), () => _r);
46
+ function yr(e) {
47
+ return ye((t) => Y(e, t), () => Fe(e), () => vr);
48
48
  }
49
49
  //#endregion
50
50
  //#region src/media/image-node.tsx
51
- var yr = Me;
52
- function br(e) {
51
+ var br = je;
52
+ function xr(e) {
53
53
  return e instanceof Element && !!e.closest("[data-markweave-image-ui=\"true\"]");
54
54
  }
55
- function xr(e) {
56
- let { deleteNode: t, editor: r, getPos: i, node: o, selected: s, updateAttributes: c } = e, l = e.extension.options, u = l.messages ?? n("zh"), d = u.image, f = Fe(vr(r)), p = J(o.attrs.src), m = yr(o.attrs.align), h = Pe(o.attrs.width), g = J(o.attrs.caption), _ = U(null), v = U(null), [y, b] = W(!1), [x, S] = W(!1), [C, w] = W(!1), [T, D] = W(""), [O, k] = W(null), [A, j] = W(!1), [M, ee] = W(!!g), [N, P] = W(g ?? ""), te = f && (!p || x), F = () => {
55
+ function Sr(e) {
56
+ let { deleteNode: t, editor: r, getPos: i, node: o, selected: s, updateAttributes: c } = e, l = e.extension.options, u = l.messages ?? n("zh"), d = u.image, f = Ie(yr(r)), p = Pe(o.attrs.src), m = br(o.attrs.align), h = Ne(o.attrs.width), g = Pe(o.attrs.caption), _ = G(null), v = G(null), [y, b] = K(!1), [x, S] = K(!1), [C, w] = K(!1), [T, D] = K(""), [O, k] = K(null), [A, j] = K(!1), [M, ee] = K(!!g), [N, P] = K(g ?? ""), F = f && (!p || x), I = () => {
57
57
  p && ze({
58
58
  src: p,
59
- alt: J(o.attrs.alt) ?? "",
59
+ alt: Pe(o.attrs.alt) ?? "",
60
60
  messages: {
61
61
  dialogAriaLabel: d.previewDialogAriaLabel,
62
62
  zoomOut: d.previewZoomOut,
@@ -66,14 +66,14 @@ function xr(e) {
66
66
  }
67
67
  });
68
68
  };
69
- V(() => {
69
+ U(() => {
70
70
  M || P(g ?? "");
71
71
  }, [g, M]);
72
- let I = () => {
72
+ let L = () => {
73
73
  if (!f) return;
74
74
  let e = i();
75
75
  typeof e == "number" && r.chain().focus().setNodeSelection(e).run();
76
- }, ne = () => {
76
+ }, R = () => {
77
77
  if (f) {
78
78
  if (D(""), k(null), w(!1), p) {
79
79
  S(!1);
@@ -81,48 +81,48 @@ function xr(e) {
81
81
  }
82
82
  t();
83
83
  }
84
- }, L = async (e) => {
84
+ }, te = async (e) => {
85
85
  if (f) {
86
86
  k(null), j(!0);
87
87
  try {
88
- let t = await Ce(ke(e, p && x ? "image-replace" : "image-insert"), l.onUpload);
89
- c(K(o.attrs, t)), S(!1), D("");
88
+ let t = await q(Oe(e, p && x ? "image-replace" : "image-insert"), l.onUpload);
89
+ c(we(o.attrs, t)), S(!1), D("");
90
90
  } catch (e) {
91
91
  k(e instanceof Error ? e.message : d.uploadFailedError);
92
92
  } finally {
93
93
  j(!1), w(!1);
94
94
  }
95
95
  }
96
- }, re = () => {
96
+ }, ne = () => {
97
97
  if (f) {
98
98
  if (!T.trim()) {
99
99
  k(d.uploadRequiredError);
100
100
  return;
101
101
  }
102
- L(xe(T));
102
+ te(be(T));
103
103
  }
104
- }, R = (e) => {
105
- !f || !e || L({
104
+ }, z = (e) => {
105
+ !f || !e || te({
106
106
  type: "file",
107
107
  file: e,
108
108
  mimeType: e.type
109
109
  });
110
- }, z = (e) => {
111
- R(e.currentTarget.files?.[0] ?? null), e.currentTarget.value = "";
112
- }, ie = (e) => {
113
- e.preventDefault(), e.stopPropagation(), f && R(e.dataTransfer.files?.[0] ?? null);
114
- }, ae = () => {
110
+ }, re = (e) => {
111
+ z(e.currentTarget.files?.[0] ?? null), e.currentTarget.value = "";
112
+ }, B = (e) => {
113
+ e.preventDefault(), e.stopPropagation(), f && z(e.dataTransfer.files?.[0] ?? null);
114
+ }, V = () => {
115
115
  f && (ee((e) => !e), M || P(g ?? ""));
116
- }, oe = (e) => {
116
+ }, ie = (e) => {
117
117
  f && (P(e), c({ caption: e.trim() ? e : null }));
118
- }, se = (e, t) => {
118
+ }, ae = (e, t) => {
119
119
  if (t.preventDefault(), t.stopPropagation(), !f) return;
120
- I();
120
+ L();
121
121
  let n = _.current;
122
122
  if (!n) return;
123
123
  let r = t.clientX, i = n.getBoundingClientRect().width || h || 320, a = n.closest(".markweave-editor-surface")?.getBoundingClientRect().width ?? n.parentElement?.getBoundingClientRect().width ?? i, o = (t) => {
124
124
  let n = e === "right" ? t.clientX - r : r - t.clientX;
125
- c({ width: Oe(i + n, a) });
125
+ c({ width: De(i + n, a) });
126
126
  }, s = () => {
127
127
  window.removeEventListener("pointermove", o), window.removeEventListener("pointerup", s);
128
128
  };
@@ -135,37 +135,37 @@ function xr(e) {
135
135
  "data-align": m,
136
136
  "data-selected": f && s ? "true" : "false",
137
137
  "data-hovered": y ? "true" : "false",
138
- "data-empty": te ? "true" : "false",
138
+ "data-empty": F ? "true" : "false",
139
139
  onPointerEnter: () => b(!0),
140
140
  onPointerLeave: () => b(!1),
141
141
  onMouseDown: (e) => {
142
- f && !br(e.target) && I();
142
+ f && !xr(e.target) && L();
143
143
  },
144
- children: te ? /* @__PURE__ */ Z(Sr, {
144
+ children: F ? /* @__PURE__ */ Z(Cr, {
145
145
  dragActive: C,
146
146
  error: O,
147
147
  inputValue: T,
148
148
  isSubmitting: A,
149
149
  fileInputRef: v,
150
150
  messages: u,
151
- onCancel: ne,
152
- onDrop: ie,
151
+ onCancel: R,
152
+ onDrop: B,
153
153
  onDragActiveChange: w,
154
- onFileChange: z,
154
+ onFileChange: re,
155
155
  onInputChange: D,
156
- onSubmit: re
156
+ onSubmit: ne
157
157
  }) : /* @__PURE__ */ Q(X, { children: [
158
- f ? /* @__PURE__ */ Z(Cr, {
158
+ f ? /* @__PURE__ */ Z(wr, {
159
159
  align: m,
160
160
  captionActive: M || !!g,
161
161
  messages: u,
162
162
  onAlign: (e) => c({ align: e }),
163
- onCaption: ae,
163
+ onCaption: V,
164
164
  onDelete: t,
165
165
  onDownload: () => {
166
166
  p && Ae(p);
167
167
  },
168
- onPreview: F,
168
+ onPreview: I,
169
169
  onReplace: () => {
170
170
  D(""), k(null), S(!0);
171
171
  }
@@ -178,8 +178,8 @@ function xr(e) {
178
178
  p ? /* @__PURE__ */ Z("img", {
179
179
  className: "markweave-image",
180
180
  src: p,
181
- alt: J(o.attrs.alt) ?? "",
182
- title: J(o.attrs.title) ?? void 0,
181
+ alt: Pe(o.attrs.alt) ?? "",
182
+ title: Pe(o.attrs.title) ?? void 0,
183
183
  draggable: !1
184
184
  }) : /* @__PURE__ */ Z("div", {
185
185
  className: "markweave-image-readonly-empty",
@@ -194,7 +194,7 @@ function xr(e) {
194
194
  "aria-label": d.preview,
195
195
  title: d.preview,
196
196
  onMouseDown: (e) => e.preventDefault(),
197
- onClick: F,
197
+ onClick: I,
198
198
  children: [/* @__PURE__ */ Z(E, {
199
199
  size: 16,
200
200
  strokeWidth: 1.8
@@ -204,15 +204,15 @@ function xr(e) {
204
204
  children: d.preview
205
205
  })]
206
206
  }) : null,
207
- f ? /* @__PURE__ */ Z(Tr, {
207
+ f ? /* @__PURE__ */ Z(Er, {
208
208
  side: "left",
209
209
  messages: u,
210
- onPointerDown: se
210
+ onPointerDown: ae
211
211
  }) : null,
212
- f ? /* @__PURE__ */ Z(Tr, {
212
+ f ? /* @__PURE__ */ Z(Er, {
213
213
  side: "right",
214
214
  messages: u,
215
- onPointerDown: se
215
+ onPointerDown: ae
216
216
  }) : null
217
217
  ]
218
218
  }),
@@ -223,7 +223,7 @@ function xr(e) {
223
223
  value: N,
224
224
  placeholder: d.captionPlaceholder,
225
225
  "aria-label": d.captionAriaLabel,
226
- onChange: (e) => oe(e.currentTarget.value),
226
+ onChange: (e) => ie(e.currentTarget.value),
227
227
  onKeyDown: (e) => {
228
228
  e.key === "Escape" && (e.preventDefault(), ee(!1));
229
229
  }
@@ -235,7 +235,7 @@ function xr(e) {
235
235
  ] })
236
236
  });
237
237
  }
238
- function Sr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitting: i, messages: a, onCancel: o, onDragActiveChange: s, onDrop: c, onFileChange: l, onInputChange: u, onSubmit: d }) {
238
+ function Cr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitting: i, messages: a, onCancel: o, onDragActiveChange: s, onDrop: c, onFileChange: l, onInputChange: u, onSubmit: d }) {
239
239
  let f = a.image;
240
240
  return /* @__PURE__ */ Q("section", {
241
241
  className: "markweave-image-upload-placeholder",
@@ -317,7 +317,7 @@ function Sr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
317
317
  ]
318
318
  });
319
319
  }
320
- function Cr({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i, onDelete: a, onDownload: o, onPreview: s, onReplace: c }) {
320
+ function wr({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i, onDelete: a, onDownload: o, onPreview: s, onReplace: c }) {
321
321
  let u = n.image;
322
322
  return /* @__PURE__ */ Q("div", {
323
323
  className: "markweave-image-toolbar",
@@ -325,21 +325,21 @@ function Cr({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i,
325
325
  "data-markweave-image-ui": "true",
326
326
  "aria-label": u.toolsAriaLabel,
327
327
  children: [
328
- /* @__PURE__ */ Z(wr, {
328
+ /* @__PURE__ */ Z(Tr, {
329
329
  testId: "markweave-image-align-left",
330
330
  label: u.alignLeft,
331
331
  icon: d,
332
332
  active: e === "left",
333
333
  onClick: () => r("left")
334
334
  }),
335
- /* @__PURE__ */ Z(wr, {
335
+ /* @__PURE__ */ Z(Tr, {
336
336
  testId: "markweave-image-align-center",
337
337
  label: u.alignCenter,
338
338
  icon: l,
339
339
  active: e === "center",
340
340
  onClick: () => r("center")
341
341
  }),
342
- /* @__PURE__ */ Z(wr, {
342
+ /* @__PURE__ */ Z(Tr, {
343
343
  testId: "markweave-image-align-right",
344
344
  label: u.alignRight,
345
345
  icon: f,
@@ -350,45 +350,45 @@ function Cr({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i,
350
350
  className: "markweave-image-toolbar-divider",
351
351
  "aria-hidden": "true"
352
352
  }),
353
- /* @__PURE__ */ Z(wr, {
353
+ /* @__PURE__ */ Z(Tr, {
354
354
  testId: "markweave-image-caption",
355
355
  label: u.caption,
356
356
  icon: h,
357
357
  active: t,
358
358
  onClick: i
359
359
  }),
360
- /* @__PURE__ */ Z(wr, {
360
+ /* @__PURE__ */ Z(Tr, {
361
361
  testId: "markweave-image-preview",
362
362
  label: u.preview,
363
363
  icon: E,
364
364
  onClick: s
365
365
  }),
366
- /* @__PURE__ */ Z(wr, {
366
+ /* @__PURE__ */ Z(Tr, {
367
367
  testId: "markweave-image-download",
368
368
  label: u.download,
369
369
  icon: w,
370
370
  onClick: o
371
371
  }),
372
- /* @__PURE__ */ Z(wr, {
372
+ /* @__PURE__ */ Z(Tr, {
373
373
  testId: "markweave-image-replace",
374
374
  label: u.replace,
375
- icon: oe,
375
+ icon: ie,
376
376
  onClick: c
377
377
  }),
378
378
  /* @__PURE__ */ Z("span", {
379
379
  className: "markweave-image-toolbar-divider",
380
380
  "aria-hidden": "true"
381
381
  }),
382
- /* @__PURE__ */ Z(wr, {
382
+ /* @__PURE__ */ Z(Tr, {
383
383
  testId: "markweave-image-delete",
384
384
  label: u.delete,
385
- icon: he,
385
+ icon: pe,
386
386
  onClick: a
387
387
  })
388
388
  ]
389
389
  });
390
390
  }
391
- function wr({ active: e = !1, icon: t, label: n, onClick: r, testId: i }) {
391
+ function Tr({ active: e = !1, icon: t, label: n, onClick: r, testId: i }) {
392
392
  return /* @__PURE__ */ Q("button", {
393
393
  type: "button",
394
394
  "aria-label": n,
@@ -407,7 +407,7 @@ function wr({ active: e = !1, icon: t, label: n, onClick: r, testId: i }) {
407
407
  })]
408
408
  });
409
409
  }
410
- function Tr({ messages: e, onPointerDown: t, side: n }) {
410
+ function Er({ messages: e, onPointerDown: t, side: n }) {
411
411
  return /* @__PURE__ */ Z("button", {
412
412
  type: "button",
413
413
  className: "markweave-image-resize-handle",
@@ -418,7 +418,7 @@ function Tr({ messages: e, onPointerDown: t, side: n }) {
418
418
  onPointerDown: (e) => t(n, e)
419
419
  });
420
420
  }
421
- var Er = we.extend({
421
+ var Dr = Se.extend({
422
422
  addOptions() {
423
423
  return {
424
424
  ...this.parent?.(),
@@ -427,33 +427,33 @@ var Er = we.extend({
427
427
  };
428
428
  },
429
429
  addNodeView() {
430
- return typeof document > "u" ? null : o(xr, { stopEvent: ({ event: e }) => br(e.target) });
430
+ return typeof document > "u" ? null : o(Sr, { stopEvent: ({ event: e }) => xr(e.target) });
431
431
  }
432
432
  });
433
433
  //#endregion
434
434
  //#region src/media/video-node.tsx
435
- function Dr(e) {
435
+ function Or(e) {
436
436
  return e instanceof Element && !!e.closest("[data-markweave-video-ui=\"true\"], iframe[data-markweave-video-embed], video[data-markweave-video]");
437
437
  }
438
- function Or(e) {
439
- let { deleteNode: t, editor: r, getPos: i, node: o, selected: s, updateAttributes: c } = e, l = e.extension.options, u = l.messages ?? n("zh"), d = u.video, f = Fe(vr(r)), p = J(o.attrs.src), m = J(o.attrs.embedUrl), h = J(o.attrs.provider), g = m ? Ne(m, h) : null, _ = J(o.attrs.mimeType), v = J(o.attrs.title), y = U(null), [b, x] = W(!1), [S, C] = W(""), [w, T] = W(null), [E, D] = W(!1), O = f && !p, k = () => {
438
+ function kr(e) {
439
+ let { deleteNode: t, editor: r, getPos: i, node: o, selected: s, updateAttributes: c } = e, l = e.extension.options, u = l.messages ?? n("zh"), d = u.video, f = Ie(yr(r)), p = Pe(o.attrs.src), m = Pe(o.attrs.embedUrl), h = Pe(o.attrs.provider), g = m ? Me(m, h) : null, _ = Pe(o.attrs.mimeType), v = Pe(o.attrs.title), y = G(null), [b, x] = K(!1), [S, C] = K(""), [w, T] = K(null), [E, D] = K(!1), O = f && !p, k = () => {
440
440
  if (!f) return;
441
441
  let e = i();
442
442
  typeof e == "number" && r.chain().focus().setNodeSelection(e).run();
443
443
  }, A = (e) => {
444
- f && (Dr(e.target) || (e.preventDefault(), k()));
444
+ f && (Or(e.target) || (e.preventDefault(), k()));
445
445
  }, j = (e) => {
446
446
  f && (e.key === "Delete" || e.key === "Backspace") && s && (e.preventDefault(), t());
447
447
  }, M = async (e) => {
448
448
  if (!(!f || !e)) {
449
449
  T(null), D(!0);
450
450
  try {
451
- let t = await Ce(q({
451
+ let t = await q(ke({
452
452
  type: "file",
453
453
  file: e,
454
454
  mimeType: e.type
455
455
  }), l.onUpload);
456
- c(Ee(t)), C("");
456
+ c(Te(t)), C("");
457
457
  } catch (e) {
458
458
  T(e instanceof Error ? e.message : d.uploadFailedError);
459
459
  } finally {
@@ -467,7 +467,7 @@ function Or(e) {
467
467
  "data-testid": "markweave-video-node",
468
468
  "data-empty": "true",
469
469
  "data-selected": "false",
470
- children: /* @__PURE__ */ Z(kr, {
470
+ children: /* @__PURE__ */ Z(Ar, {
471
471
  dragActive: b,
472
472
  error: w,
473
473
  fileInputRef: y,
@@ -485,7 +485,7 @@ function Or(e) {
485
485
  onInputChange: C,
486
486
  onSubmit: () => {
487
487
  if (!f) return;
488
- let e = De(S);
488
+ let e = Ee(S);
489
489
  if (!e) {
490
490
  T(d.unsupportedUrlError);
491
491
  return;
@@ -514,7 +514,7 @@ function Or(e) {
514
514
  "data-markweave-video-embed": "true",
515
515
  "data-markweave-video-provider": h ?? void 0,
516
516
  "data-markweave-video-src": p ?? void 0,
517
- allow: je,
517
+ allow: J,
518
518
  loading: "lazy",
519
519
  allowFullScreen: !0
520
520
  }), f ? /* @__PURE__ */ Z("button", {
@@ -548,7 +548,7 @@ function Or(e) {
548
548
  })
549
549
  });
550
550
  }
551
- function kr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitting: i, messages: a, onCancel: o, onDragActiveChange: s, onDrop: c, onFileChange: l, onInputChange: u, onSubmit: d }) {
551
+ function Ar({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitting: i, messages: a, onCancel: o, onDragActiveChange: s, onDrop: c, onFileChange: l, onInputChange: u, onSubmit: d }) {
552
552
  let f = a.video;
553
553
  return /* @__PURE__ */ Q("section", {
554
554
  className: "markweave-video-upload-placeholder",
@@ -575,7 +575,7 @@ function kr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
575
575
  /* @__PURE__ */ Z("div", {
576
576
  className: "markweave-video-upload-icon",
577
577
  "aria-hidden": "true",
578
- children: /* @__PURE__ */ Z(ye, {
578
+ children: /* @__PURE__ */ Z(_e, {
579
579
  size: 46,
580
580
  strokeWidth: 1.6
581
581
  })
@@ -610,7 +610,7 @@ function kr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
610
610
  "data-testid": "markweave-video-upload-submit",
611
611
  disabled: i || !r.trim(),
612
612
  onClick: d,
613
- children: [/* @__PURE__ */ Z(ve, {
613
+ children: [/* @__PURE__ */ Z(ge, {
614
614
  size: 16,
615
615
  strokeWidth: 1.8
616
616
  }), a.common.insert]
@@ -630,7 +630,7 @@ function kr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
630
630
  ]
631
631
  });
632
632
  }
633
- var Ar = Te.extend({
633
+ var jr = Ce.extend({
634
634
  addOptions() {
635
635
  return {
636
636
  ...this.parent?.(),
@@ -639,30 +639,30 @@ var Ar = Te.extend({
639
639
  };
640
640
  },
641
641
  addNodeView() {
642
- return typeof document > "u" ? null : o(Or, { stopEvent: ({ event: e }) => Dr(e.target) });
642
+ return typeof document > "u" ? null : o(kr, { stopEvent: ({ event: e }) => Or(e.target) });
643
643
  }
644
644
  });
645
645
  //#endregion
646
646
  //#region src/link-card-node.tsx
647
- function jr(e) {
647
+ function Mr(e) {
648
648
  return e instanceof Element && !!e.closest("[data-markweave-link-card-ui=\"true\"]");
649
649
  }
650
- function Mr(e) {
650
+ function Nr(e) {
651
651
  return typeof navigator < "u" && navigator.clipboard?.writeText ? navigator.clipboard.writeText(e).catch(() => void 0) : Promise.resolve();
652
652
  }
653
- function Nr(e) {
653
+ function Pr(e) {
654
654
  !e || typeof window > "u" || window.open(e, "_blank", "noopener,noreferrer");
655
655
  }
656
- function Pr(e) {
656
+ function Fr(e) {
657
657
  try {
658
658
  return new URL(e).host;
659
659
  } catch {
660
660
  return e;
661
661
  }
662
662
  }
663
- function Fr(e) {
664
- let { deleteNode: t, editor: r, getPos: i, node: o, updateAttributes: s } = e, c = e.extension.options, l = c.messages ?? n("zh"), u = l.linkCard, d = Fe(vr(r)), f = Ve(o.attrs), [p, m] = W(!1), [h, g] = W(!1), [_, v] = W(!1), [y, b] = W(f?.title ?? ""), [x, C] = W(f?.href ?? ""), w = U(null);
665
- if (V(() => () => w.current?.abort(), []), V(() => {
663
+ function Ir(e) {
664
+ let { deleteNode: t, editor: r, getPos: i, node: o, updateAttributes: s } = e, c = e.extension.options, l = c.messages ?? n("zh"), u = l.linkCard, d = Ie(yr(r)), f = Ve(o.attrs), [p, m] = K(!1), [h, g] = K(!1), [_, v] = K(!1), [y, b] = K(f?.title ?? ""), [x, C] = K(f?.href ?? ""), w = G(null);
665
+ if (U(() => () => w.current?.abort(), []), U(() => {
666
666
  b(f?.title ?? ""), C(f?.href ?? ""), v(!1);
667
667
  }, [f?.href, f?.title]), !f) return null;
668
668
  let T = async (e) => {
@@ -690,7 +690,7 @@ function Fr(e) {
690
690
  }, E = () => {
691
691
  let e = i();
692
692
  typeof e == "number" && Ue(r, e);
693
- }, D = _ ? null : f.imageUrl, O = Pr(f.href);
693
+ }, D = _ ? null : f.imageUrl, O = Fr(f.href);
694
694
  return /* @__PURE__ */ Q(a, {
695
695
  as: "article",
696
696
  className: "markweave-link-card",
@@ -701,10 +701,10 @@ function Fr(e) {
701
701
  onMouseEnter: () => m(!0),
702
702
  onMouseLeave: () => m(!1),
703
703
  onMouseDown: (e) => {
704
- jr(e.target) || e.preventDefault();
704
+ Mr(e.target) || e.preventDefault();
705
705
  },
706
706
  onClick: (e) => {
707
- jr(e.target) || (e.preventDefault(), Nr(f.href));
707
+ Mr(e.target) || (e.preventDefault(), Pr(f.href));
708
708
  },
709
709
  children: [
710
710
  /* @__PURE__ */ Q("a", {
@@ -742,21 +742,21 @@ function Fr(e) {
742
742
  "data-markweave-link-card-ui": "true",
743
743
  "aria-label": u.toolsAriaLabel,
744
744
  children: [
745
- /* @__PURE__ */ Z(Ir, {
745
+ /* @__PURE__ */ Z(Lr, {
746
746
  label: u.convertToLink,
747
- icon: F,
747
+ icon: I,
748
748
  onClick: E,
749
749
  testId: "markweave-link-card-convert"
750
750
  }),
751
- /* @__PURE__ */ Z(Ir, {
751
+ /* @__PURE__ */ Z(Lr, {
752
752
  label: u.copyAddress,
753
753
  icon: S,
754
- onClick: () => void Mr(f.href),
754
+ onClick: () => void Nr(f.href),
755
755
  testId: "markweave-link-card-copy"
756
756
  }),
757
- /* @__PURE__ */ Z(Ir, {
757
+ /* @__PURE__ */ Z(Lr, {
758
758
  label: u.edit,
759
- icon: ie,
759
+ icon: B,
760
760
  onClick: (e) => {
761
761
  let t = i();
762
762
  typeof t == "number" && We({
@@ -772,9 +772,9 @@ function Fr(e) {
772
772
  },
773
773
  testId: "markweave-link-card-edit"
774
774
  }),
775
- /* @__PURE__ */ Z(Ir, {
775
+ /* @__PURE__ */ Z(Lr, {
776
776
  label: u.delete,
777
- icon: he,
777
+ icon: pe,
778
778
  onClick: t,
779
779
  testId: "markweave-link-card-delete"
780
780
  })
@@ -802,14 +802,14 @@ function Fr(e) {
802
802
  type: "submit",
803
803
  "aria-label": u.edit,
804
804
  disabled: !He(x),
805
- children: /* @__PURE__ */ Z(F, { size: 16 })
805
+ children: /* @__PURE__ */ Z(I, { size: 16 })
806
806
  })
807
807
  ]
808
808
  }) : null
809
809
  ]
810
810
  });
811
811
  }
812
- function Ir({ icon: e, label: t, onClick: n, testId: r }) {
812
+ function Lr({ icon: e, label: t, onClick: n, testId: r }) {
813
813
  return /* @__PURE__ */ Q("button", {
814
814
  type: "button",
815
815
  "aria-label": t,
@@ -826,7 +826,7 @@ function Ir({ icon: e, label: t, onClick: n, testId: r }) {
826
826
  })]
827
827
  });
828
828
  }
829
- var Lr = Ge.extend({
829
+ var Rr = Ge.extend({
830
830
  addOptions() {
831
831
  return {
832
832
  ...this.parent?.(),
@@ -835,22 +835,22 @@ var Lr = Ge.extend({
835
835
  };
836
836
  },
837
837
  addNodeView() {
838
- return typeof document > "u" ? null : o(Fr, { stopEvent: ({ event: e }) => jr(e.target) });
838
+ return typeof document > "u" ? null : o(Ir, { stopEvent: ({ event: e }) => Mr(e.target) });
839
839
  }
840
840
  });
841
841
  //#endregion
842
842
  //#region src/create-editor-extensions.ts
843
- function Rr(t = {}) {
843
+ function zr(t = {}) {
844
844
  return e({
845
845
  lang: t.lang,
846
- linkCardExtension: Lr.configure({
846
+ linkCardExtension: Rr.configure({
847
847
  lang: t.lang,
848
848
  messages: n(t.lang),
849
849
  resolver: t.linkCardResolver
850
850
  }),
851
851
  mediaExtensions: Be({
852
- image: Er,
853
- video: Ar,
852
+ image: Dr,
853
+ video: jr,
854
854
  lang: t.lang,
855
855
  onImageUpload: t.onImageUpload,
856
856
  onVideoUpload: t.onVideoUpload
@@ -859,7 +859,7 @@ function Rr(t = {}) {
859
859
  }
860
860
  //#endregion
861
861
  //#region src/ui/codeblock/CodeBlockControls.tsx
862
- function zr(e) {
862
+ function Br(e) {
863
863
  return e === "clipboard" ? /* @__PURE__ */ Q(X, { children: [/* @__PURE__ */ Z("path", { d: "M9 4.5h6a1.5 1.5 0 0 1 1.5 1.5v11A1.5 1.5 0 0 1 15 18.5H7A1.5 1.5 0 0 1 5.5 17V6A1.5 1.5 0 0 1 7 4.5h2" }), /* @__PURE__ */ Z("path", { d: "M8.5 5.5v-1A1.5 1.5 0 0 1 10 3h2a1.5 1.5 0 0 1 1.5 1.5v1h-5Z" })] }) : e === "search" ? /* @__PURE__ */ Q(X, { children: [/* @__PURE__ */ Z("circle", {
864
864
  cx: "10",
865
865
  cy: "10",
@@ -896,7 +896,7 @@ function zr(e) {
896
896
  /* @__PURE__ */ Z("path", { d: "m14 14 4 4" })
897
897
  ] }) : e === "reset" ? /* @__PURE__ */ Q(X, { children: [/* @__PURE__ */ Z("path", { d: "M6.5 8.5A6 6 0 1 1 6 15" }), /* @__PURE__ */ Z("path", { d: "M6.5 8.5H3.5v-3" })] }) : /* @__PURE__ */ Z("path", { d: "m6 9 6 6 6-6" });
898
898
  }
899
- function Br({ icon: e }) {
899
+ function Vr({ icon: e }) {
900
900
  return /* @__PURE__ */ Z("svg", {
901
901
  viewBox: "0 0 24 24",
902
902
  "aria-hidden": "true",
@@ -907,23 +907,23 @@ function Br({ icon: e }) {
907
907
  strokeLinecap: "round",
908
908
  strokeLinejoin: "round",
909
909
  strokeWidth: "1.8",
910
- children: zr(e)
910
+ children: Br(e)
911
911
  })
912
912
  });
913
913
  }
914
- function Vr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, readOnly: i = !1 }) {
915
- let a = U(null), o = U(null), s = U(null), c = U({
914
+ function Hr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, readOnly: i = !1 }) {
915
+ let a = G(null), o = G(null), s = G(null), c = G({
916
916
  active: !1,
917
917
  lastX: 0,
918
918
  lastY: 0
919
- }), [l, u] = W(null), [d, f] = W(null), [p, m] = W([]), [h, g] = W(null), [_, v] = W(!1), [y, b] = W(""), [x, S] = W(null), [C, w] = W(!1), [T, E] = W(null), [D, O] = W(null), [k, A] = W(!1), [j, M] = W(0), [ee, N] = W(0), P = pt(t), te = pn(t, l), F = !i && e && P.active && P.pos !== null ? {
919
+ }), [l, u] = K(null), [d, f] = K(null), [p, m] = K([]), [h, g] = K(null), [_, v] = K(!1), [y, b] = K(""), [x, S] = K(null), [C, w] = K(!1), [T, E] = K(null), [D, O] = K(null), [k, A] = K(!1), [j, M] = K(0), [ee, N] = K(0), P = pt(t), F = pn(t, l), I = !i && e && P.active && P.pos !== null ? {
920
920
  ...P,
921
921
  pos: P.pos,
922
922
  active: !0
923
- } : null, I = te ?? F, ne = I !== null, L = I?.language === "mermaid", re = _n(t, I), R = ne && I !== null && !re, z = !i, ie = sn(I ? I.language : "text"), ae = x?.status ?? "idle", oe = I?.mermaidPreviewMode ?? n, se = L && oe === "preview", ce = hn(t), le = `${ee}|${ce.map((e) => `${e.pos}:${e.mermaidPreviewMode}:${e.text.length}`).join("|")}`, ue = H(() => dn(y.trim().toLowerCase()), [y]);
924
- if (V(() => {
923
+ } : null, L = F ?? I, R = L !== null, te = L?.language === "mermaid", ne = _n(t, L), z = R && L !== null && !ne, re = !i, B = sn(L ? L.language : "text"), V = x?.status ?? "idle", ie = L?.mermaidPreviewMode ?? n, ae = te && ie === "preview", oe = hn(t), se = `${ee}|${oe.map((e) => `${e.pos}:${e.mermaidPreviewMode}:${e.text.length}`).join("|")}`, ce = W(() => dn(y.trim().toLowerCase()), [y]);
924
+ if (U(() => {
925
925
  i && (v(!1), b(""));
926
- }, [i]), V(() => {
926
+ }, [i]), U(() => {
927
927
  if (!x) return;
928
928
  let e = window.setTimeout(() => {
929
929
  S(null);
@@ -931,21 +931,21 @@ function Vr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
931
931
  return () => {
932
932
  window.clearTimeout(e);
933
933
  };
934
- }, [x]), V(() => {
934
+ }, [x]), U(() => {
935
935
  S(null), v(!1), b(""), E(null), O(null), A(!1);
936
936
  }, [
937
937
  e,
938
- I?.language,
939
- I?.pos,
940
- I?.text
941
- ]), V(() => {
938
+ L?.language,
939
+ L?.pos,
940
+ L?.text
941
+ ]), U(() => {
942
942
  let e = ({ transaction: e }) => {
943
943
  e.getMeta(dt) && M((e) => e + 1);
944
944
  };
945
945
  return t.on("transaction", e), () => {
946
946
  t.off("transaction", e);
947
947
  };
948
- }, [t]), V(() => {
948
+ }, [t]), U(() => {
949
949
  let e = t.view.dom.closest(".markweave-editor-frame");
950
950
  if (!e) return;
951
951
  let n = (e) => {
@@ -958,9 +958,9 @@ function Vr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
958
958
  return e.addEventListener("mousemove", n), e.addEventListener("mouseleave", r), () => {
959
959
  e.removeEventListener("mousemove", n), e.removeEventListener("mouseleave", r);
960
960
  };
961
- }, [t, _]), V(() => {
961
+ }, [t, _]), U(() => {
962
962
  _ && s.current?.focus({ preventScroll: !0 });
963
- }, [_]), V(() => {
963
+ }, [_]), U(() => {
964
964
  if (!T) return;
965
965
  let e = (e) => {
966
966
  e.key === "Escape" && (E(null), O(null), A(!1), c.current = {
@@ -972,8 +972,8 @@ function Vr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
972
972
  return document.addEventListener("keydown", e), () => {
973
973
  document.removeEventListener("keydown", e);
974
974
  };
975
- }, [t, T]), V(() => {
976
- if (!ne || !_) return;
975
+ }, [t, T]), U(() => {
976
+ if (!R || !_) return;
977
977
  let e = (e) => {
978
978
  e.key === "Escape" && (v(!1), t.view.focus());
979
979
  }, n = (e) => {
@@ -983,22 +983,22 @@ function Vr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
983
983
  document.removeEventListener("keydown", e), document.removeEventListener("mousedown", n);
984
984
  };
985
985
  }, [
986
- ne,
986
+ R,
987
987
  t,
988
988
  _
989
- ]), be(() => {
989
+ ]), ve(() => {
990
990
  let e = () => {
991
991
  let e = a.current;
992
992
  if (!e) return;
993
- if (!mn(e) || ce.length === 0) {
993
+ if (!mn(e) || oe.length === 0) {
994
994
  m([]);
995
995
  return;
996
996
  }
997
- let n = e.getBoundingClientRect(), r = ce.flatMap((e) => {
997
+ let n = e.getBoundingClientRect(), r = oe.flatMap((e) => {
998
998
  let r = un(ln(t, e.pos, e.mermaidPreviewMode), n);
999
999
  return r ? [an(e, r, n)] : [];
1000
1000
  });
1001
- m((e) => vn(e, r, ce.map((e) => e.pos)));
1001
+ m((e) => vn(e, r, oe.map((e) => e.pos)));
1002
1002
  };
1003
1003
  e();
1004
1004
  let n = window.requestAnimationFrame(e);
@@ -1008,21 +1008,21 @@ function Vr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1008
1008
  }, [
1009
1009
  j,
1010
1010
  t,
1011
- le
1012
- ]), be(() => {
1013
- if (!R || !I) {
1011
+ se
1012
+ ]), ve(() => {
1013
+ if (!z || !L) {
1014
1014
  f(null), g(null);
1015
1015
  return;
1016
1016
  }
1017
1017
  let e = () => {
1018
1018
  let e = a.current;
1019
1019
  if (!e) return;
1020
- let n = ln(t, I.pos, oe), r = e.getBoundingClientRect(), i = un(n, r);
1020
+ let n = ln(t, L.pos, ie), r = e.getBoundingClientRect(), i = un(n, r);
1021
1021
  if (!i) {
1022
- f((e) => e?.pos === I.pos ? e : null), g((e) => _ ? e : null);
1022
+ f((e) => e?.pos === L.pos ? e : null), g((e) => _ ? e : null);
1023
1023
  return;
1024
1024
  }
1025
- let s = nn(I.pos, i, r);
1025
+ let s = nn(L.pos, i, r);
1026
1026
  if (f(s), _ && o.current) {
1027
1027
  let e = o.current.getBoundingClientRect();
1028
1028
  g(Qt({
@@ -1037,79 +1037,79 @@ function Vr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1037
1037
  window.removeEventListener("resize", e), window.removeEventListener("scroll", e, !0);
1038
1038
  };
1039
1039
  }, [
1040
- R,
1040
+ z,
1041
1041
  j,
1042
- I?.pos,
1042
+ L?.pos,
1043
1043
  t,
1044
1044
  _,
1045
- oe
1046
- ]), !R && ce.length === 0 && !T) return null;
1047
- let de = d ? {
1045
+ ie
1046
+ ]), !z && oe.length === 0 && !T) return null;
1047
+ let le = d ? {
1048
1048
  top: d.top,
1049
1049
  right: d.right
1050
- } : void 0, fe = async () => {
1050
+ } : void 0, ue = async () => {
1051
1051
  if (i) {
1052
- if (!I) return;
1053
- let e = await tn(I.text);
1054
- S(mt(I, e ? "copied" : "failed"));
1052
+ if (!L) return;
1053
+ let e = await tn(L.text);
1054
+ S(mt(L, e ? "copied" : "failed"));
1055
1055
  return;
1056
1056
  }
1057
- if (!on(t, I)) return;
1057
+ if (!on(t, L)) return;
1058
1058
  let e = await ft(t);
1059
1059
  S(mt(pt(t), e ? "copied" : "failed")), t.view.focus();
1060
- }, pe = (e, n) => {
1060
+ }, de = (e, n) => {
1061
1061
  if (i) {
1062
1062
  St(t, e.pos, n) && N((e) => e + 1);
1063
1063
  return;
1064
1064
  }
1065
1065
  let a = P.active && P.pos === e.pos;
1066
1066
  vt(t, e.pos, n) && (r(n), N((e) => e + 1), a && t.view.focus());
1067
- }, me = (e) => {
1068
- if (i || !I) return;
1069
- let n = P.active && P.pos === I.pos;
1070
- _t(t, I.pos, e) && (e === "mermaid" && vt(t, I.pos, "preview") && r("preview"), v(!1), b(""), N((e) => e + 1), n && t.view.focus());
1071
- }, he = () => {
1072
- i || !I || gt(t, I.pos, !re) && (M((e) => e + 1), u(null));
1073
- }, ge = () => {
1074
- if (!I) return;
1075
- let e = gn(t, I.pos);
1067
+ }, fe = (e) => {
1068
+ if (i || !L) return;
1069
+ let n = P.active && P.pos === L.pos;
1070
+ _t(t, L.pos, e) && (e === "mermaid" && vt(t, L.pos, "preview") && r("preview"), v(!1), b(""), N((e) => e + 1), n && t.view.focus());
1071
+ }, pe = () => {
1072
+ i || !L || gt(t, L.pos, !ne) && (M((e) => e + 1), u(null));
1073
+ }, me = () => {
1074
+ if (!L) return;
1075
+ let e = gn(t, L.pos);
1076
1076
  if (!e) return;
1077
1077
  let n = new Blob([e], { type: "image/svg+xml" }), r = URL.createObjectURL(n), i = document.createElement("a");
1078
1078
  i.href = r, i.download = "markweave-mermaid.svg", i.click(), URL.revokeObjectURL(r), t.view.focus();
1079
- }, _e = () => {
1080
- if (!I) return;
1081
- let e = gn(t, I.pos);
1079
+ }, he = () => {
1080
+ if (!L) return;
1081
+ let e = gn(t, L.pos);
1082
1082
  e && (E(rn(e)), O(null), A(!1), c.current = {
1083
1083
  active: !1,
1084
1084
  lastX: 0,
1085
1085
  lastY: 0
1086
1086
  });
1087
- }, ve = () => {
1087
+ }, ge = () => {
1088
1088
  E(null), O(null), A(!1), c.current = {
1089
1089
  active: !1,
1090
1090
  lastX: 0,
1091
1091
  lastY: 0
1092
1092
  }, t.view.focus();
1093
- }, ye = (e) => {
1093
+ }, _e = (e) => {
1094
1094
  E((t) => t && {
1095
1095
  ...t,
1096
1096
  scale: $t(t.scale + e)
1097
1097
  });
1098
- }, B = () => {
1098
+ }, H = () => {
1099
1099
  E((e) => e && rn(e.svg)), c.current = {
1100
1100
  active: !1,
1101
1101
  lastX: 0,
1102
1102
  lastY: 0
1103
1103
  }, A(!1);
1104
- }, G = (e) => {
1105
- e.preventDefault(), ye(e.deltaY < 0 ? yn : -yn);
1106
- }, xe = (e) => {
1104
+ }, ye = (e) => {
1105
+ e.preventDefault(), _e(e.deltaY < 0 ? yn : -yn);
1106
+ }, be = (e) => {
1107
1107
  e.button === 0 && (e.preventDefault(), c.current = {
1108
1108
  active: !0,
1109
1109
  lastX: e.clientX,
1110
1110
  lastY: e.clientY
1111
1111
  }, A(!0));
1112
- }, Se = (e) => {
1112
+ }, xe = (e) => {
1113
1113
  let t = c.current;
1114
1114
  if (!t.active) return;
1115
1115
  let n = e.clientX - t.lastX, r = e.clientY - t.lastY;
@@ -1118,7 +1118,7 @@ function Vr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1118
1118
  lastX: e.clientX,
1119
1119
  lastY: e.clientY
1120
1120
  }, E((e) => bn(e, n, r));
1121
- }, Ce = () => {
1121
+ }, q = () => {
1122
1122
  c.current = {
1123
1123
  active: !1,
1124
1124
  lastX: 0,
@@ -1131,7 +1131,7 @@ function Vr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1131
1131
  "data-testid": "markweave-codeblock-overlay",
1132
1132
  "data-read-only": i ? "true" : "false",
1133
1133
  children: [
1134
- ce.map((e) => {
1134
+ oe.map((e) => {
1135
1135
  let t = p.find((t) => t.pos === e.pos);
1136
1136
  return /* @__PURE__ */ Z("div", {
1137
1137
  className: "markweave-mermaid-tabs",
@@ -1147,25 +1147,25 @@ function Vr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1147
1147
  "data-testid": `markweave-mermaid-mode-${t}`,
1148
1148
  "data-active": e.mermaidPreviewMode === t,
1149
1149
  onMouseDown: (e) => e.preventDefault(),
1150
- onClick: () => pe(e, t),
1150
+ onClick: () => de(e, t),
1151
1151
  children: t === "code" ? "Code" : "Preview"
1152
1152
  }, t))
1153
1153
  }, e.pos);
1154
1154
  }),
1155
- R ? /* @__PURE__ */ Q("div", {
1155
+ z ? /* @__PURE__ */ Q("div", {
1156
1156
  className: "markweave-codeblock-controls",
1157
1157
  "data-testid": "markweave-codeblock-controls",
1158
1158
  "data-positioned": d ? "true" : "false",
1159
- "data-collapsed": re ? "true" : "false",
1159
+ "data-collapsed": ne ? "true" : "false",
1160
1160
  "data-read-only": i ? "true" : "false",
1161
1161
  "aria-label": "Code block controls",
1162
- style: de,
1162
+ style: le,
1163
1163
  children: [
1164
1164
  i ? /* @__PURE__ */ Z("span", {
1165
1165
  className: "markweave-codeblock-language-button markweave-codeblock-language-label",
1166
1166
  "aria-label": "Code block language",
1167
1167
  "data-testid": "markweave-codeblock-language",
1168
- children: /* @__PURE__ */ Z("span", { children: ie })
1168
+ children: /* @__PURE__ */ Z("span", { children: B })
1169
1169
  }) : /* @__PURE__ */ Q("button", {
1170
1170
  ref: o,
1171
1171
  type: "button",
@@ -1176,18 +1176,18 @@ function Vr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1176
1176
  "data-testid": "markweave-codeblock-language",
1177
1177
  onMouseDown: (e) => e.preventDefault(),
1178
1178
  onClick: () => v((e) => !e),
1179
- children: [/* @__PURE__ */ Z("span", { children: ie }), /* @__PURE__ */ Z(Br, { icon: "chevron" })]
1179
+ children: [/* @__PURE__ */ Z("span", { children: B }), /* @__PURE__ */ Z(Vr, { icon: "chevron" })]
1180
1180
  }),
1181
- z ? /* @__PURE__ */ Z("button", {
1181
+ re ? /* @__PURE__ */ Z("button", {
1182
1182
  type: "button",
1183
1183
  className: "markweave-codeblock-icon-button markweave-codeblock-collapse-button",
1184
- "aria-label": re ? "Expand code block" : "Collapse code block",
1185
- title: re ? "Expand code block" : "Collapse code block",
1184
+ "aria-label": ne ? "Expand code block" : "Collapse code block",
1185
+ title: ne ? "Expand code block" : "Collapse code block",
1186
1186
  "data-testid": "markweave-codeblock-collapse",
1187
- "data-collapsed": re ? "true" : "false",
1187
+ "data-collapsed": ne ? "true" : "false",
1188
1188
  onMouseDown: (e) => e.preventDefault(),
1189
- onClick: he,
1190
- children: /* @__PURE__ */ Z(Br, { icon: "chevron" })
1189
+ onClick: pe,
1190
+ children: /* @__PURE__ */ Z(Vr, { icon: "chevron" })
1191
1191
  }) : null,
1192
1192
  /* @__PURE__ */ Q("span", {
1193
1193
  className: "markweave-codeblock-copy-wrap",
@@ -1196,14 +1196,14 @@ function Vr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1196
1196
  className: "markweave-codeblock-icon-button",
1197
1197
  "aria-label": "Copy to clipboard",
1198
1198
  "data-testid": "markweave-codeblock-copy",
1199
- "data-copy-state": ae,
1199
+ "data-copy-state": V,
1200
1200
  onMouseDown: (e) => e.preventDefault(),
1201
1201
  onMouseEnter: () => w(!0),
1202
1202
  onMouseLeave: () => w(!1),
1203
1203
  onFocus: () => w(!0),
1204
1204
  onBlur: () => w(!1),
1205
- onClick: fe,
1206
- children: /* @__PURE__ */ Z(Br, { icon: ae === "copied" ? "check" : "clipboard" })
1205
+ onClick: ue,
1206
+ children: /* @__PURE__ */ Z(Vr, { icon: V === "copied" ? "check" : "clipboard" })
1207
1207
  }), C ? /* @__PURE__ */ Z("span", {
1208
1208
  className: "markweave-codeblock-tooltip",
1209
1209
  role: "tooltip",
@@ -1211,7 +1211,7 @@ function Vr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1211
1211
  children: "Copy to clipboard"
1212
1212
  }) : null]
1213
1213
  }),
1214
- L && oe === "preview" ? /* @__PURE__ */ Q("div", {
1214
+ te && ie === "preview" ? /* @__PURE__ */ Q("div", {
1215
1215
  className: "markweave-mermaid-preview-actions",
1216
1216
  "data-testid": "markweave-mermaid-preview-actions",
1217
1217
  children: [/* @__PURE__ */ Z("button", {
@@ -1219,24 +1219,24 @@ function Vr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1219
1219
  className: "markweave-codeblock-icon-button",
1220
1220
  "aria-label": "Fullscreen Mermaid preview",
1221
1221
  "data-testid": "markweave-mermaid-fullscreen",
1222
- disabled: !se,
1222
+ disabled: !ae,
1223
1223
  onMouseDown: (e) => e.preventDefault(),
1224
- onClick: _e,
1225
- children: /* @__PURE__ */ Z(Br, { icon: "expand" })
1224
+ onClick: he,
1225
+ children: /* @__PURE__ */ Z(Vr, { icon: "expand" })
1226
1226
  }), /* @__PURE__ */ Z("button", {
1227
1227
  type: "button",
1228
1228
  className: "markweave-codeblock-icon-button",
1229
1229
  "aria-label": "Download Mermaid SVG",
1230
1230
  "data-testid": "markweave-mermaid-download",
1231
- disabled: !se,
1231
+ disabled: !ae,
1232
1232
  onMouseDown: (e) => e.preventDefault(),
1233
- onClick: ge,
1234
- children: /* @__PURE__ */ Z(Br, { icon: "download" })
1233
+ onClick: me,
1234
+ children: /* @__PURE__ */ Z(Vr, { icon: "download" })
1235
1235
  })]
1236
1236
  }) : null
1237
1237
  ]
1238
1238
  }) : null,
1239
- z && R && _ ? /* @__PURE__ */ Q("div", {
1239
+ re && z && _ ? /* @__PURE__ */ Q("div", {
1240
1240
  className: "markweave-codeblock-language-menu",
1241
1241
  role: "listbox",
1242
1242
  "aria-label": "Code block languages",
@@ -1257,11 +1257,11 @@ function Vr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1257
1257
  onKeyDown: (e) => {
1258
1258
  e.key === "Escape" && (e.preventDefault(), v(!1), t.view.focus());
1259
1259
  }
1260
- }), /* @__PURE__ */ Z(Br, { icon: "search" })]
1260
+ }), /* @__PURE__ */ Z(Vr, { icon: "search" })]
1261
1261
  }), /* @__PURE__ */ Z("div", {
1262
1262
  className: "markweave-codeblock-language-list",
1263
- children: ue.map((e) => {
1264
- let t = e.language === I.language;
1263
+ children: ce.map((e) => {
1264
+ let t = e.language === L.language;
1265
1265
  return /* @__PURE__ */ Q("button", {
1266
1266
  type: "button",
1267
1267
  role: "option",
@@ -1269,8 +1269,8 @@ function Vr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1269
1269
  "data-testid": `markweave-codeblock-language-option-${e.language}`,
1270
1270
  "data-active": t ? "true" : "false",
1271
1271
  onMouseDown: (e) => e.preventDefault(),
1272
- onClick: () => me(e.language),
1273
- children: [/* @__PURE__ */ Z("span", { children: e.label }), t ? /* @__PURE__ */ Z(Br, { icon: "check" }) : null]
1272
+ onClick: () => fe(e.language),
1273
+ children: [/* @__PURE__ */ Z("span", { children: e.label }), t ? /* @__PURE__ */ Z(Vr, { icon: "check" }) : null]
1274
1274
  }, e.language);
1275
1275
  })
1276
1276
  })]
@@ -1295,8 +1295,8 @@ function Vr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1295
1295
  onMouseLeave: () => O(null),
1296
1296
  onFocus: () => O("zoom-out"),
1297
1297
  onBlur: () => O(null),
1298
- onClick: () => ye(-yn),
1299
- children: /* @__PURE__ */ Z(Br, { icon: "zoomOut" })
1298
+ onClick: () => _e(-yn),
1299
+ children: /* @__PURE__ */ Z(Vr, { icon: "zoomOut" })
1300
1300
  }),
1301
1301
  /* @__PURE__ */ Z("span", {
1302
1302
  className: "markweave-mermaid-fullscreen-zoom-label",
@@ -1312,8 +1312,8 @@ function Vr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1312
1312
  onMouseLeave: () => O(null),
1313
1313
  onFocus: () => O("zoom-in"),
1314
1314
  onBlur: () => O(null),
1315
- onClick: () => ye(yn),
1316
- children: /* @__PURE__ */ Z(Br, { icon: "zoomIn" })
1315
+ onClick: () => _e(yn),
1316
+ children: /* @__PURE__ */ Z(Vr, { icon: "zoomIn" })
1317
1317
  }),
1318
1318
  /* @__PURE__ */ Z("button", {
1319
1319
  type: "button",
@@ -1324,8 +1324,8 @@ function Vr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1324
1324
  onMouseLeave: () => O(null),
1325
1325
  onFocus: () => O("reset"),
1326
1326
  onBlur: () => O(null),
1327
- onClick: B,
1328
- children: /* @__PURE__ */ Z(Br, { icon: "reset" })
1327
+ onClick: H,
1328
+ children: /* @__PURE__ */ Z(Vr, { icon: "reset" })
1329
1329
  }),
1330
1330
  D ? /* @__PURE__ */ Z("span", {
1331
1331
  className: "markweave-mermaid-fullscreen-tooltip",
@@ -1340,18 +1340,18 @@ function Vr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1340
1340
  className: "markweave-mermaid-fullscreen-close",
1341
1341
  "aria-label": "Close fullscreen Mermaid preview",
1342
1342
  "data-testid": "markweave-mermaid-fullscreen-close",
1343
- onClick: ve,
1344
- children: /* @__PURE__ */ Z(Br, { icon: "close" })
1343
+ onClick: ge,
1344
+ children: /* @__PURE__ */ Z(Vr, { icon: "close" })
1345
1345
  }),
1346
1346
  /* @__PURE__ */ Z("div", {
1347
1347
  className: "markweave-mermaid-fullscreen-viewport",
1348
1348
  "data-testid": "markweave-mermaid-fullscreen-viewport",
1349
1349
  "data-dragging": k ? "true" : "false",
1350
- onWheel: G,
1351
- onMouseDown: xe,
1352
- onMouseMove: Se,
1353
- onMouseUp: Ce,
1354
- onMouseLeave: Ce,
1350
+ onWheel: ye,
1351
+ onMouseDown: be,
1352
+ onMouseMove: xe,
1353
+ onMouseUp: q,
1354
+ onMouseLeave: q,
1355
1355
  children: /* @__PURE__ */ Z("div", {
1356
1356
  className: "markweave-mermaid-fullscreen-content",
1357
1357
  "data-testid": "markweave-mermaid-fullscreen-content",
@@ -1372,25 +1372,25 @@ function Vr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1372
1372
  }
1373
1373
  //#endregion
1374
1374
  //#region src/ui/floating-toolbar/FloatingToolbar.tsx
1375
- var Hr = n("zh");
1376
- function Ur() {
1375
+ var Ur = n("zh");
1376
+ function Wr() {
1377
1377
  return typeof performance > "u" ? Date.now() : performance.now();
1378
1378
  }
1379
- function Wr(e, t) {
1379
+ function Gr(e, t) {
1380
1380
  return {
1381
1381
  "--markweave-toolbar-motion-duration": `${e.motionDurationMs}ms`,
1382
1382
  "--markweave-toolbar-motion-easing": e.motionEasing,
1383
1383
  marginLeft: t === 0 ? void 0 : `${t}px`
1384
1384
  };
1385
1385
  }
1386
- function Gr(e, t) {
1386
+ function Kr(e, t) {
1387
1387
  let n = e?.getBoundingClientRect().height ?? 0, r = t?.getBoundingClientRect().height ?? 0;
1388
1388
  return Math.max(n, r, 44);
1389
1389
  }
1390
- function Kr(e) {
1390
+ function qr(e) {
1391
1391
  if (e !== null) return { "--markweave-floating-toolbar-tooltip-left": `${e}px` };
1392
1392
  }
1393
- function qr(e, t, n, r) {
1393
+ function Jr(e, t, n, r) {
1394
1394
  let i = {
1395
1395
  bottom: t + r,
1396
1396
  height: r,
@@ -1406,26 +1406,26 @@ function qr(e, t, n, r) {
1406
1406
  toJSON: () => i
1407
1407
  };
1408
1408
  }
1409
- function Jr(e) {
1409
+ function Yr(e) {
1410
1410
  return e.width > 0 && e.height > 0;
1411
1411
  }
1412
- function Yr(e) {
1412
+ function Xr(e) {
1413
1413
  let t = Math.min(...e.map((e) => e.left)), n = Math.min(...e.map((e) => e.top)), r = Math.max(...e.map((e) => e.right)), i = Math.max(...e.map((e) => e.bottom));
1414
- return qr(t, n, r - t, i - n);
1414
+ return Jr(t, n, r - t, i - n);
1415
1415
  }
1416
- function Xr(e, t) {
1416
+ function Zr(e, t) {
1417
1417
  let n = e.view.dom.ownerDocument.defaultView?.Node.ELEMENT_NODE ?? 1, r = (t) => t ? e.view.dom.contains(t.nodeType === n ? t : t.parentNode) : !1;
1418
1418
  return r(t.anchorNode) && r(t.focusNode);
1419
1419
  }
1420
- function Zr(e) {
1420
+ function Qr(e) {
1421
1421
  if (typeof e.getClientRects != "function") return null;
1422
- let t = Array.from(e.getClientRects()).filter(Jr).map((e) => qr(e.left, e.top, e.width, e.height));
1422
+ let t = Array.from(e.getClientRects()).filter(Yr).map((e) => Jr(e.left, e.top, e.width, e.height));
1423
1423
  if (t.length > 0) return t;
1424
1424
  if (typeof e.getBoundingClientRect != "function") return null;
1425
1425
  let n = e.getBoundingClientRect();
1426
- return Jr(n) ? [qr(n.left, n.top, n.width, n.height)] : null;
1426
+ return Yr(n) ? [Jr(n.left, n.top, n.width, n.height)] : null;
1427
1427
  }
1428
- function Qr(e, t) {
1428
+ function $r(e, t) {
1429
1429
  if (t.rangeCount === 0) return null;
1430
1430
  let n = t.getRangeAt(0);
1431
1431
  try {
@@ -1438,8 +1438,8 @@ function Qr(e, t) {
1438
1438
  return null;
1439
1439
  }
1440
1440
  }
1441
- function $r(e, t) {
1442
- let n = Qr(e, t);
1441
+ function ei(e, t) {
1442
+ let n = $r(e, t);
1443
1443
  if (!n) return !1;
1444
1444
  let { selection: r } = e.state, i = {
1445
1445
  from: Math.min(r.from, r.to),
@@ -1447,51 +1447,51 @@ function $r(e, t) {
1447
1447
  };
1448
1448
  return n.from === i.from && n.to === i.to;
1449
1449
  }
1450
- function ei(e) {
1450
+ function ti(e) {
1451
1451
  let t = e.view.dom.ownerDocument.getSelection();
1452
- return !t || t.rangeCount === 0 || t.isCollapsed || !Xr(e, t) || !$r(e, t) ? null : Zr(t.getRangeAt(0));
1452
+ return !t || t.rangeCount === 0 || t.isCollapsed || !Zr(e, t) || !ei(e, t) ? null : Qr(t.getRangeAt(0));
1453
1453
  }
1454
- function ti(e) {
1454
+ function ni(e) {
1455
1455
  let { selection: t } = e.state;
1456
1456
  if (t.empty) return null;
1457
1457
  let n = Math.min(t.from, t.to), r = Math.max(t.from, t.to);
1458
1458
  try {
1459
1459
  let t = e.view.domAtPos(n), i = e.view.domAtPos(r), a = e.view.dom.ownerDocument.createRange();
1460
- return a.setStart(t.node, t.offset), a.setEnd(i.node, i.offset), Zr(a);
1460
+ return a.setStart(t.node, t.offset), a.setEnd(i.node, i.offset), Qr(a);
1461
1461
  } catch {
1462
1462
  return null;
1463
1463
  }
1464
1464
  }
1465
- function ni(e) {
1465
+ function ri(e) {
1466
1466
  let { selection: t } = e.state;
1467
1467
  if (t.empty) return null;
1468
- let n = Math.min(t.from, t.to), r = Math.max(t.from, t.to), i = e.view.coordsAtPos(n), a = e.view.coordsAtPos(r, -1), o = Math.min(i.top, a.top), s = Math.max(i.bottom, a.bottom), c = Math.min(i.left, a.left), l = qr(c, o, Math.max(i.right, a.right) - c, s - o);
1469
- return Jr(l) ? [l] : null;
1470
- }
1471
- function ri(e) {
1472
- return ei(e) ?? ti(e) ?? ni(e);
1468
+ let n = Math.min(t.from, t.to), r = Math.max(t.from, t.to), i = e.view.coordsAtPos(n), a = e.view.coordsAtPos(r, -1), o = Math.min(i.top, a.top), s = Math.max(i.bottom, a.bottom), c = Math.min(i.left, a.left), l = Jr(c, o, Math.max(i.right, a.right) - c, s - o);
1469
+ return Yr(l) ? [l] : null;
1473
1470
  }
1474
1471
  function ii(e) {
1475
- let t = ri(e);
1476
- return t && t.length > 0 ? Yr(t) : null;
1472
+ return ti(e) ?? ni(e) ?? ri(e);
1477
1473
  }
1478
1474
  function ai(e) {
1475
+ let t = ii(e);
1476
+ return t && t.length > 0 ? Xr(t) : null;
1477
+ }
1478
+ function oi(e) {
1479
1479
  return {
1480
- getBoundingClientRect: () => ii(e) ?? qr(0, 0, 0, 0),
1481
- getClientRects: () => ri(e) ?? []
1480
+ getBoundingClientRect: () => ai(e) ?? Jr(0, 0, 0, 0),
1481
+ getClientRects: () => ii(e) ?? []
1482
1482
  };
1483
1483
  }
1484
- function oi(e) {
1484
+ function si(e) {
1485
1485
  return e === "block-type" || e === "link" || e === "color" || e === "more";
1486
1486
  }
1487
- function si(e, t, n) {
1487
+ function ci(e, t, n) {
1488
1488
  n?.(wn(e, t)), e.commands.focus();
1489
1489
  }
1490
- function ci({ editor: e, messages: t = Hr, selectionSnapshot: n, onRewriteSelection: r }) {
1491
- let i = H(() => kn(t), [t]), a = st(n, { editable: e.isEditable }), [o, s] = W(a), [c, l] = W(null), [u, d] = W(null), [f, p] = W(null), [m, h] = W(""), [g, _] = W(""), [v, y] = W(null), [b, x] = W(0), [S, C] = W(a.boundaryPadding), [w, T] = W("bottom"), E = U(0), D = U(null), O = U(null), k = U(null), A = U(null), j = Tn(e, o.variant, t), M = jn(j.find((e) => e.id === c) ?? null), ee = Hn(m), N = B(() => {
1490
+ function li({ editor: e, messages: t = Ur, selectionSnapshot: n, onRewriteSelection: r }) {
1491
+ let i = W(() => kn(t), [t]), a = st(n, { editable: e.isEditable }), [o, s] = K(a), [c, l] = K(null), [u, d] = K(null), [f, p] = K(null), [m, h] = K(""), [g, _] = K(""), [v, y] = K(null), [b, x] = K(0), [S, C] = K(a.boundaryPadding), [w, T] = K("bottom"), E = G(0), D = G(null), O = G(null), k = G(null), A = G(null), j = Tn(e, o.variant, t), M = jn(j.find((e) => e.id === c) ?? null), ee = Hn(m), N = H(() => {
1492
1492
  let t = D.current, n = e.view.dom.closest(".markweave-editor-frame");
1493
1493
  if (!t || !(n instanceof HTMLElement)) return;
1494
- let r = t.getBoundingClientRect(), i = n.getBoundingClientRect(), a = Gr(t, O.current), s = E.current, c = nt({
1494
+ let r = t.getBoundingClientRect(), i = n.getBoundingClientRect(), a = Kr(t, O.current), s = E.current, c = nt({
1495
1495
  toolbarRect: {
1496
1496
  left: r.left - s,
1497
1497
  top: r.top,
@@ -1524,13 +1524,13 @@ function ci({ editor: e, messages: t = Hr, selectionSnapshot: n, onRewriteSelect
1524
1524
  e.view.dom,
1525
1525
  o.boundaryPadding,
1526
1526
  o.offset
1527
- ]), P = B(() => {
1527
+ ]), P = H(() => {
1528
1528
  D.current && (D.current.style.visibility = "hidden", D.current.style.opacity = "0");
1529
- }, []), te = B(() => {
1529
+ }, []), F = H(() => {
1530
1530
  N();
1531
- }, [N]), F = B(() => ai(e), [e]), I = B((e) => {
1531
+ }, [N]), I = H(() => oi(e), [e]), L = H((e) => {
1532
1532
  k.current = e;
1533
- }, []), ne = B(() => {
1533
+ }, []), R = H(() => {
1534
1534
  let t = D.current, n = k.current, r = e.view.dom.closest(".markweave-editor-frame");
1535
1535
  if (!f || !t || !n) return;
1536
1536
  let i = t.getBoundingClientRect(), a = n.getBoundingClientRect(), s = r?.getBoundingClientRect() ?? null, c = rt({
@@ -1549,18 +1549,18 @@ function ci({ editor: e, messages: t = Hr, selectionSnapshot: n, onRewriteSelect
1549
1549
  e.view.dom,
1550
1550
  f,
1551
1551
  o.boundaryPadding
1552
- ]), L = H(() => ({
1552
+ ]), te = W(() => ({
1553
1553
  ...ot(o, { topBoundaryPadding: S }),
1554
1554
  onShow: P,
1555
- onUpdate: te
1555
+ onUpdate: F
1556
1556
  }), [
1557
1557
  P,
1558
- te,
1558
+ F,
1559
1559
  o,
1560
1560
  S
1561
1561
  ]);
1562
- V(() => {
1563
- let e = Ur();
1562
+ U(() => {
1563
+ let e = Wr();
1564
1564
  s((t) => ut(t, a, e));
1565
1565
  }, [
1566
1566
  a.hiddenReason,
@@ -1573,10 +1573,10 @@ function ci({ editor: e, messages: t = Hr, selectionSnapshot: n, onRewriteSelect
1573
1573
  a.updateDelayMs,
1574
1574
  a.variant,
1575
1575
  a.visibility
1576
- ]), V(() => {
1576
+ ]), U(() => {
1577
1577
  if (o.motionStartedAtMs === null || o.motionDurationMs <= 0) return;
1578
- let e = Math.max(0, o.motionStartedAtMs + o.motionDurationMs - Ur()), t = window.setTimeout(() => {
1579
- s((e) => et(e, Ur()));
1578
+ let e = Math.max(0, o.motionStartedAtMs + o.motionDurationMs - Wr()), t = window.setTimeout(() => {
1579
+ s((e) => et(e, Wr()));
1580
1580
  }, e);
1581
1581
  return () => {
1582
1582
  window.clearTimeout(t);
@@ -1585,7 +1585,7 @@ function ci({ editor: e, messages: t = Hr, selectionSnapshot: n, onRewriteSelect
1585
1585
  o.motionDurationMs,
1586
1586
  o.motionPhase,
1587
1587
  o.motionStartedAtMs
1588
- ]), be(() => {
1588
+ ]), ve(() => {
1589
1589
  if (o.visibility !== "visible") {
1590
1590
  E.current = 0, D.current && (D.current.style.marginLeft = "", D.current.style.visibility = "hidden", D.current.style.opacity = "0"), x(0), C(o.boundaryPadding);
1591
1591
  return;
@@ -1603,20 +1603,20 @@ function ci({ editor: e, messages: t = Hr, selectionSnapshot: n, onRewriteSelect
1603
1603
  o.variant,
1604
1604
  o.visibility,
1605
1605
  j.length
1606
- ]), be(() => {
1606
+ ]), ve(() => {
1607
1607
  if (!f) return;
1608
- let e = Sn(ne);
1608
+ let e = Sn(R);
1609
1609
  return e.schedule(), window.addEventListener("resize", e.schedule), window.addEventListener("scroll", e.schedule, !0), () => {
1610
1610
  e.cancel(), window.removeEventListener("resize", e.schedule), window.removeEventListener("scroll", e.schedule, !0);
1611
1611
  };
1612
- }, [f, ne]), V(() => {
1612
+ }, [f, R]), U(() => {
1613
1613
  f === "more" && i.some((e) => e.id === c) || j.some((e) => e.id === c) || (l(null), d(null));
1614
1614
  }, [
1615
1615
  i,
1616
1616
  f,
1617
1617
  c,
1618
1618
  j
1619
- ]), V(() => {
1619
+ ]), U(() => {
1620
1620
  if (!f) return;
1621
1621
  let t = (e) => {
1622
1622
  O.current?.contains(e.target) || p(null);
@@ -1626,15 +1626,15 @@ function ci({ editor: e, messages: t = Hr, selectionSnapshot: n, onRewriteSelect
1626
1626
  return document.addEventListener("pointerdown", t, !0), document.addEventListener("keydown", n, !0), () => {
1627
1627
  document.removeEventListener("pointerdown", t, !0), document.removeEventListener("keydown", n, !0);
1628
1628
  };
1629
- }, [e, f]), V(() => {
1629
+ }, [e, f]), U(() => {
1630
1630
  if (f !== "link") return;
1631
1631
  let e = window.requestAnimationFrame(() => {
1632
1632
  A.current?.focus(), A.current?.select();
1633
1633
  });
1634
1634
  return () => window.cancelAnimationFrame(e);
1635
1635
  }, [f]);
1636
- let re = (t) => {
1637
- if (oi(t.id)) {
1636
+ let ne = (t) => {
1637
+ if (si(t.id)) {
1638
1638
  let n = t.id;
1639
1639
  if (n === "link") {
1640
1640
  let t = Dn(e);
@@ -1647,23 +1647,23 @@ function ci({ editor: e, messages: t = Hr, selectionSnapshot: n, onRewriteSelect
1647
1647
  return;
1648
1648
  }
1649
1649
  if (p(null), t.id === "improve") {
1650
- si(e, "rewrite-selection", r);
1650
+ ci(e, "rewrite-selection", r);
1651
1651
  return;
1652
1652
  }
1653
1653
  t.run(), e.commands.focus();
1654
- }, R = () => {
1655
- p(null), e.commands.focus();
1656
1654
  }, z = () => {
1655
+ p(null), e.commands.focus();
1656
+ }, re = () => {
1657
1657
  v && e.commands.setTextSelection(v);
1658
- }, ie = () => {
1659
- z(), Cn(e, m) && R();
1660
- }, ae = () => {
1661
- if (z(), Ln(e)) {
1662
- h(""), _(""), R();
1658
+ }, B = () => {
1659
+ re(), Cn(e, m) && z();
1660
+ }, V = () => {
1661
+ if (re(), Ln(e)) {
1662
+ h(""), _(""), z();
1663
1663
  return;
1664
1664
  }
1665
1665
  m.trim() && h("");
1666
- }, oe = (e, t) => {
1666
+ }, ie = (e, t) => {
1667
1667
  if (l(e), !e || !t || !O.current) {
1668
1668
  d(null);
1669
1669
  return;
@@ -1676,36 +1676,36 @@ function ci({ editor: e, messages: t = Hr, selectionSnapshot: n, onRewriteSelect
1676
1676
  editor: e,
1677
1677
  className: `markweave-floating-toolbar markweave-floating-toolbar--${o.variant} markweave-floating-toolbar--motion-${o.motionPhase}`,
1678
1678
  "data-motion": o.motionPhase,
1679
- "data-position-strategy": L.strategy,
1679
+ "data-position-strategy": te.strategy,
1680
1680
  "data-boundary-padding": o.boundaryPadding,
1681
1681
  "data-popover-placement": f ? w : void 0,
1682
1682
  "data-testid": "markweave-floating-toolbar",
1683
- style: Wr(o, b),
1683
+ style: Gr(o, b),
1684
1684
  updateDelay: 0,
1685
- getReferencedVirtualElement: F,
1686
- options: L,
1685
+ getReferencedVirtualElement: I,
1686
+ options: te,
1687
1687
  shouldShow: ({ editor: e }) => e.isEditable && lt(at(e)),
1688
1688
  children: /* @__PURE__ */ Q("div", {
1689
1689
  ref: O,
1690
1690
  className: "markweave-floating-toolbar-content",
1691
1691
  "data-menu": f ?? "none",
1692
1692
  children: [
1693
- j.map((e, t) => /* @__PURE__ */ Z(ui, {
1693
+ j.map((e, t) => /* @__PURE__ */ Z(di, {
1694
1694
  button: e,
1695
1695
  expanded: f === e.id,
1696
1696
  showDivider: t > 0 && j[t - 1].group !== e.group,
1697
1697
  tooltipActive: c === e.id,
1698
1698
  onPointerDown: In,
1699
- onTooltipChange: oe,
1700
- onRun: re
1699
+ onTooltipChange: ie,
1700
+ onRun: ne
1701
1701
  }, e.id)),
1702
- f === "block-type" ? /* @__PURE__ */ Z(fi, {
1702
+ f === "block-type" ? /* @__PURE__ */ Z(pi, {
1703
1703
  editor: e,
1704
1704
  messages: t,
1705
- onPopoverRef: I,
1705
+ onPopoverRef: L,
1706
1706
  onClose: () => p(null)
1707
1707
  }) : null,
1708
- f === "link" ? /* @__PURE__ */ Z(li, {
1708
+ f === "link" ? /* @__PURE__ */ Z(ui, {
1709
1709
  inputRef: A,
1710
1710
  messages: t,
1711
1711
  value: m,
@@ -1713,22 +1713,22 @@ function ci({ editor: e, messages: t = Hr, selectionSnapshot: n, onRewriteSelect
1713
1713
  canOpen: !!ee,
1714
1714
  canRemove: !!(g || m.trim()),
1715
1715
  onValueChange: h,
1716
- onApply: ie,
1716
+ onApply: B,
1717
1717
  onOpen: () => Fn(m),
1718
- onRemove: ae,
1719
- onPopoverRef: I
1718
+ onRemove: V,
1719
+ onPopoverRef: L
1720
1720
  }) : null,
1721
- f === "color" ? /* @__PURE__ */ Z(mi, {
1721
+ f === "color" ? /* @__PURE__ */ Z(hi, {
1722
1722
  editor: e,
1723
1723
  messages: t,
1724
- onPopoverRef: I,
1724
+ onPopoverRef: L,
1725
1725
  onClose: () => p(null)
1726
1726
  }) : null,
1727
- f === "more" ? /* @__PURE__ */ Z(gi, {
1727
+ f === "more" ? /* @__PURE__ */ Z(_i, {
1728
1728
  editor: e,
1729
1729
  messages: t,
1730
1730
  activeTooltipId: c,
1731
- onPopoverRef: I,
1731
+ onPopoverRef: L,
1732
1732
  onTooltipChange: l,
1733
1733
  onClose: () => p(null)
1734
1734
  }) : null,
@@ -1738,14 +1738,14 @@ function ci({ editor: e, messages: t = Hr, selectionSnapshot: n, onRewriteSelect
1738
1738
  "data-testid": "markweave-floating-toolbar-tooltip",
1739
1739
  "data-button-id": M.buttonId,
1740
1740
  "data-active": M.active,
1741
- style: Kr(u),
1741
+ style: qr(u),
1742
1742
  children: M.label
1743
1743
  }) : null
1744
1744
  ]
1745
1745
  })
1746
1746
  });
1747
1747
  }
1748
- function li({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRemove: a, onValueChange: o, onApply: s, onOpen: c, onRemove: l, onPopoverRef: u }) {
1748
+ function ui({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRemove: a, onValueChange: o, onApply: s, onOpen: c, onRemove: l, onPopoverRef: u }) {
1749
1749
  let d = On(t);
1750
1750
  return /* @__PURE__ */ Q("form", {
1751
1751
  ref: u,
@@ -1798,7 +1798,7 @@ function li({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRe
1798
1798
  })]
1799
1799
  });
1800
1800
  }
1801
- function ui({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointerDown: i, onTooltipChange: a, onRun: o }) {
1801
+ function di({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointerDown: i, onTooltipChange: a, onRun: o }) {
1802
1802
  return /* @__PURE__ */ Q(X, { children: [n ? /* @__PURE__ */ Z("span", {
1803
1803
  className: "markweave-floating-toolbar-divider",
1804
1804
  "aria-hidden": "true"
@@ -1806,7 +1806,7 @@ function ui({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointe
1806
1806
  type: "button",
1807
1807
  className: `markweave-floating-toolbar-button markweave-floating-toolbar-button--${e.id}`,
1808
1808
  "aria-label": e.label,
1809
- "aria-expanded": oi(e.id) ? t : void 0,
1809
+ "aria-expanded": si(e.id) ? t : void 0,
1810
1810
  "data-active": e.active || t,
1811
1811
  "data-tooltip-active": r ? "true" : "false",
1812
1812
  "data-testid": `markweave-floating-toolbar-button-${e.id}`,
@@ -1816,13 +1816,13 @@ function ui({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointe
1816
1816
  onMouseEnter: (t) => a(e.id, t.currentTarget),
1817
1817
  onMouseLeave: () => a(null),
1818
1818
  onClick: () => o(e),
1819
- children: /* @__PURE__ */ Z(di, {
1819
+ children: /* @__PURE__ */ Z(fi, {
1820
1820
  button: e,
1821
1821
  expanded: t
1822
1822
  })
1823
1823
  })] });
1824
1824
  }
1825
- function di({ button: e, expanded: t }) {
1825
+ function fi({ button: e, expanded: t }) {
1826
1826
  return e.id === "improve" ? /* @__PURE__ */ Q("span", {
1827
1827
  className: "markweave-floating-toolbar-button-inner",
1828
1828
  children: [/* @__PURE__ */ Z($, { name: "sparkles" }), /* @__PURE__ */ Z("span", { children: e.glyph })]
@@ -1840,7 +1840,7 @@ function di({ button: e, expanded: t }) {
1840
1840
  }), /* @__PURE__ */ Z($, { name: t ? "chevron-up" : "chevron-down" })]
1841
1841
  }) : /* @__PURE__ */ Z($, { name: "more" });
1842
1842
  }
1843
- function fi({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
1843
+ function pi({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
1844
1844
  let i = On(t), a = Mn(t);
1845
1845
  return /* @__PURE__ */ Q("div", {
1846
1846
  ref: n,
@@ -1859,21 +1859,21 @@ function fi({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
1859
1859
  },
1860
1860
  children: [/* @__PURE__ */ Z("span", {
1861
1861
  className: "markweave-floating-toolbar-menu-icon",
1862
- children: /* @__PURE__ */ Z(pi, { option: t })
1862
+ children: /* @__PURE__ */ Z(mi, { option: t })
1863
1863
  }), /* @__PURE__ */ Z("span", { children: t.label })]
1864
1864
  }, t.id))]
1865
1865
  });
1866
1866
  }
1867
- function pi({ option: e }) {
1867
+ function mi({ option: e }) {
1868
1868
  return e.id === "paragraph" ? /* @__PURE__ */ Z($, { name: "text" }) : e.glyph === "bullet-list" || e.glyph === "numbered-list" || e.glyph === "todo-list" || e.glyph === "quote" || e.glyph === "code-block" ? /* @__PURE__ */ Z($, { name: e.glyph }) : /* @__PURE__ */ Z("span", { children: e.glyph });
1869
1869
  }
1870
- function mi({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
1870
+ function hi({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
1871
1871
  let i = On(t), a = e.getAttributes("textStyle").color, o = e.getAttributes("highlight").color;
1872
1872
  return /* @__PURE__ */ Q("div", {
1873
1873
  ref: n,
1874
1874
  className: "markweave-floating-toolbar-popover markweave-floating-toolbar-color-popover",
1875
1875
  "data-testid": "markweave-floating-toolbar-color-menu",
1876
- children: [/* @__PURE__ */ Z(hi, {
1876
+ children: [/* @__PURE__ */ Z(gi, {
1877
1877
  title: i.textColorTitle,
1878
1878
  mode: "text",
1879
1879
  activeColor: a ?? null,
@@ -1881,7 +1881,7 @@ function mi({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
1881
1881
  onSelect: (t) => {
1882
1882
  Bn(e, t), r();
1883
1883
  }
1884
- }), /* @__PURE__ */ Z(hi, {
1884
+ }), /* @__PURE__ */ Z(gi, {
1885
1885
  title: i.highlightColorTitle,
1886
1886
  mode: "highlight",
1887
1887
  activeColor: o ?? null,
@@ -1892,7 +1892,7 @@ function mi({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
1892
1892
  })]
1893
1893
  });
1894
1894
  }
1895
- function hi({ title: e, mode: t, activeColor: n, options: r, onSelect: i }) {
1895
+ function gi({ title: e, mode: t, activeColor: n, options: r, onSelect: i }) {
1896
1896
  return /* @__PURE__ */ Q("section", {
1897
1897
  className: "markweave-floating-toolbar-color-section",
1898
1898
  "aria-label": e,
@@ -1921,13 +1921,13 @@ function hi({ title: e, mode: t, activeColor: n, options: r, onSelect: i }) {
1921
1921
  })]
1922
1922
  });
1923
1923
  }
1924
- function gi({ editor: e, messages: t, activeTooltipId: n, onPopoverRef: r, onTooltipChange: i, onClose: a }) {
1924
+ function _i({ editor: e, messages: t, activeTooltipId: n, onPopoverRef: r, onTooltipChange: i, onClose: a }) {
1925
1925
  let o = kn(t);
1926
1926
  return /* @__PURE__ */ Z("div", {
1927
1927
  ref: r,
1928
1928
  className: "markweave-floating-toolbar-popover markweave-floating-toolbar-more-menu",
1929
1929
  "data-testid": "markweave-floating-toolbar-more-menu",
1930
- children: o.map((t, r) => /* @__PURE__ */ Z(_i, {
1930
+ children: o.map((t, r) => /* @__PURE__ */ Z(vi, {
1931
1931
  action: t,
1932
1932
  active: Nn(e, t.id),
1933
1933
  tooltipActive: n === t.id,
@@ -1939,7 +1939,7 @@ function gi({ editor: e, messages: t, activeTooltipId: n, onPopoverRef: r, onToo
1939
1939
  }, t.id))
1940
1940
  });
1941
1941
  }
1942
- function _i({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipChange: i, onRun: a }) {
1942
+ function vi({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipChange: i, onRun: a }) {
1943
1943
  return /* @__PURE__ */ Q(X, { children: [r ? /* @__PURE__ */ Z("span", {
1944
1944
  className: "markweave-floating-toolbar-divider",
1945
1945
  "aria-hidden": "true"
@@ -1955,7 +1955,7 @@ function _i({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipC
1955
1955
  onMouseEnter: () => i(e.id),
1956
1956
  onMouseLeave: () => i(null),
1957
1957
  onClick: a,
1958
- children: /* @__PURE__ */ Z(vi, { id: e.id })
1958
+ children: /* @__PURE__ */ Z(yi, { id: e.id })
1959
1959
  }), n ? /* @__PURE__ */ Z("div", {
1960
1960
  className: "markweave-floating-toolbar-tooltip markweave-floating-toolbar-tooltip--more",
1961
1961
  role: "tooltip",
@@ -1963,41 +1963,41 @@ function _i({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipC
1963
1963
  }) : null]
1964
1964
  })] });
1965
1965
  }
1966
- function vi({ id: e }) {
1966
+ function yi({ id: e }) {
1967
1967
  return e === "superscript" ? /* @__PURE__ */ Z($, { name: "superscript" }) : e === "subscript" ? /* @__PURE__ */ Z($, { name: "subscript" }) : e === "inline-math" ? /* @__PURE__ */ Z($, { name: "math" }) : Z($, { name: e });
1968
1968
  }
1969
- var yi = {
1970
- sparkles: le,
1969
+ var bi = {
1970
+ sparkles: se,
1971
1971
  "chevron-down": v,
1972
1972
  "chevron-up": y,
1973
1973
  "corner-down-left": C,
1974
1974
  "external-link": T,
1975
1975
  bold: p,
1976
1976
  italic: P,
1977
- underline: _e,
1978
- strike: ue,
1977
+ underline: he,
1978
+ strike: ce,
1979
1979
  "inline-code": x,
1980
- link: F,
1981
- more: R,
1982
- text: ge,
1983
- "bullet-list": I,
1984
- "numbered-list": L,
1985
- "todo-list": ne,
1986
- quote: ae,
1980
+ link: I,
1981
+ more: z,
1982
+ text: me,
1983
+ "bullet-list": L,
1984
+ "numbered-list": te,
1985
+ "todo-list": R,
1986
+ quote: V,
1987
1987
  "code-block": m,
1988
- superscript: fe,
1989
- subscript: de,
1990
- math: se,
1988
+ superscript: ue,
1989
+ subscript: le,
1990
+ math: ae,
1991
1991
  "align-left": d,
1992
1992
  "align-center": l,
1993
1993
  "align-right": f,
1994
1994
  "align-justify": u,
1995
1995
  "decrease-indent": M,
1996
1996
  "increase-indent": ee,
1997
- trash: he
1997
+ trash: pe
1998
1998
  };
1999
1999
  function $({ name: e }) {
2000
- let t = yi[e];
2000
+ let t = bi[e];
2001
2001
  return /* @__PURE__ */ Z(t, {
2002
2002
  "aria-hidden": "true",
2003
2003
  absoluteStrokeWidth: !0,
@@ -2007,8 +2007,8 @@ function $({ name: e }) {
2007
2007
  }
2008
2008
  //#endregion
2009
2009
  //#region src/ui/math/MathEditorPopover.tsx
2010
- function bi({ editor: e, messages: t, onClose: n, target: r }) {
2011
- let i = U(null), a = U(null), [o, s] = W(r.latex), [c, l] = W(null), u = t.math, d = H(() => Dt(e, r) ?? 1, [e, r]), f = H(() => Ot(e, r), [e, r]), p = H(() => o === r.latex && f ? {
2010
+ function xi({ editor: e, messages: t, onClose: n, target: r }) {
2011
+ let i = G(null), a = G(null), [o, s] = K(r.latex), [c, l] = K(null), u = t.math, d = W(() => Dt(e, r) ?? 1, [e, r]), f = W(() => Ot(e, r), [e, r]), p = W(() => o === r.latex && f ? {
2012
2012
  html: f,
2013
2013
  error: !1
2014
2014
  } : Mt(o, r.kind, e), [
@@ -2017,7 +2017,7 @@ function bi({ editor: e, messages: t, onClose: n, target: r }) {
2017
2017
  r.kind,
2018
2018
  r.latex,
2019
2019
  o
2020
- ]), m = o.trim().length > 0, h = B(() => {
2020
+ ]), m = o.trim().length > 0, h = H(() => {
2021
2021
  if (typeof window > "u") return;
2022
2022
  let t = Et(e, r), i = e.view.dom.closest(".markweave-editor-frame")?.getBoundingClientRect();
2023
2023
  if (!t || !i) {
@@ -2038,9 +2038,9 @@ function bi({ editor: e, messages: t, onClose: n, target: r }) {
2038
2038
  r,
2039
2039
  o
2040
2040
  ]);
2041
- V(() => {
2041
+ U(() => {
2042
2042
  s(r.latex);
2043
- }, [r.latex, r.pos]), V(() => {
2043
+ }, [r.latex, r.pos]), U(() => {
2044
2044
  Nt(e, r, !0), h();
2045
2045
  let t = window.requestAnimationFrame(() => {
2046
2046
  a.current?.focus({ preventScroll: !0 }), a.current?.select(), h();
@@ -2053,14 +2053,14 @@ function bi({ editor: e, messages: t, onClose: n, target: r }) {
2053
2053
  n,
2054
2054
  r,
2055
2055
  h
2056
- ]), V(() => {
2056
+ ]), U(() => {
2057
2057
  let e = (e) => {
2058
2058
  let t = e.target;
2059
2059
  t instanceof Node && (i.current?.contains(t) || t instanceof Element && t.closest(".tiptap-mathematics-render") || n());
2060
2060
  };
2061
2061
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
2062
2062
  }, [n]);
2063
- let _ = B(() => {
2063
+ let _ = H(() => {
2064
2064
  m && wt(e, r, o) && n();
2065
2065
  }, [
2066
2066
  m,
@@ -2192,31 +2192,31 @@ function bi({ editor: e, messages: t, onClose: n, target: r }) {
2192
2192
  }
2193
2193
  //#endregion
2194
2194
  //#region src/ui/slash-command/SlashCommandMenu.tsx
2195
- var xi = n("zh"), Si = {
2196
- type: me,
2195
+ var Si = n("zh"), Ci = {
2196
+ type: fe,
2197
2197
  "heading-1": D,
2198
2198
  "heading-2": O,
2199
2199
  "heading-3": k,
2200
- "bullet-list": I,
2201
- "ordered-list": L,
2202
- "task-list": ne,
2203
- blockquote: ae,
2200
+ "bullet-list": L,
2201
+ "ordered-list": te,
2202
+ "task-list": R,
2203
+ blockquote: V,
2204
2204
  "code-block": m,
2205
2205
  info: N,
2206
- tip: te,
2206
+ tip: F,
2207
2207
  warning: c,
2208
2208
  error: b,
2209
2209
  success: _,
2210
- emoji: ce,
2211
- math: se,
2212
- table: pe,
2213
- separator: re,
2210
+ emoji: oe,
2211
+ math: ae,
2212
+ table: de,
2213
+ separator: ne,
2214
2214
  image: A,
2215
- video: ye,
2216
- attachment: z
2215
+ video: _e,
2216
+ attachment: re
2217
2217
  };
2218
- function Ci({ name: e }) {
2219
- let t = Si[e];
2218
+ function wi({ name: e }) {
2219
+ let t = Ci[e];
2220
2220
  return /* @__PURE__ */ Z(t, {
2221
2221
  "aria-hidden": "true",
2222
2222
  absoluteStrokeWidth: !0,
@@ -2224,7 +2224,7 @@ function Ci({ name: e }) {
2224
2224
  strokeWidth: 1.6
2225
2225
  });
2226
2226
  }
2227
- function wi(e, t, n) {
2227
+ function Ti(e, t, n) {
2228
2228
  return !zt(e) || !n ? {
2229
2229
  visible: !1,
2230
2230
  empty: !1,
@@ -2239,17 +2239,17 @@ function wi(e, t, n) {
2239
2239
  activeIndex: Math.min(t.length - 1, Math.max(0, e.activeIndex))
2240
2240
  };
2241
2241
  }
2242
- function Ti(e, t) {
2242
+ function Ei(e, t) {
2243
2243
  return Object.values(t.slash.groups).map((t) => ({
2244
2244
  group: t,
2245
2245
  commands: e.filter((e) => e.group === t)
2246
2246
  })).filter((e) => e.commands.length > 0);
2247
2247
  }
2248
- function Ei(e, t) {
2248
+ function Di(e, t) {
2249
2249
  return t.slash.uploadKindLabels[e] ?? t.slash.uploadKindLabels.upload;
2250
2250
  }
2251
- function Di({ command: e, messages: t, onBack: n, onSelect: r }) {
2252
- let [i, a] = W(""), [o, s] = W(0), c = H(() => {
2251
+ function Oi({ command: e, messages: t, onBack: n, onSelect: r }) {
2252
+ let [i, a] = K(""), [o, s] = K(0), c = W(() => {
2253
2253
  let e = i.trim().toLowerCase();
2254
2254
  return (e ? t.slash.emojiItems.filter((t) => [
2255
2255
  t.emoji,
@@ -2315,9 +2315,9 @@ function Di({ command: e, messages: t, onBack: n, onSelect: r }) {
2315
2315
  ]
2316
2316
  });
2317
2317
  }
2318
- function Oi({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
2319
- let a = e.uploadKind ?? "attachment", [o, s] = W(""), [c, l] = W(null), [u, d] = W(null), [f, p] = W(!1), m = async (t) => {
2320
- r(e, { uploadResult: await Ce({
2318
+ function ki({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
2319
+ let a = e.uploadKind ?? "attachment", [o, s] = K(""), [c, l] = K(null), [u, d] = K(null), [f, p] = K(!1), m = async (t) => {
2320
+ r(e, { uploadResult: await q({
2321
2321
  kind: a,
2322
2322
  source: t,
2323
2323
  trigger: "slash-command"
@@ -2337,7 +2337,7 @@ function Oi({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
2337
2337
  d(t.slash.uploadRequiredError);
2338
2338
  return;
2339
2339
  }
2340
- await m(xe(o));
2340
+ await m(be(o));
2341
2341
  } catch (e) {
2342
2342
  d(e instanceof Error ? e.message : t.slash.uploadFailedError);
2343
2343
  } finally {
@@ -2355,7 +2355,7 @@ function Oi({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
2355
2355
  onMouseDown: (e) => e.preventDefault(),
2356
2356
  onClick: n,
2357
2357
  children: t.common.back
2358
- }), /* @__PURE__ */ Z("span", { children: Ei(a, t) })]
2358
+ }), /* @__PURE__ */ Z("span", { children: Di(a, t) })]
2359
2359
  }),
2360
2360
  /* @__PURE__ */ Q("label", {
2361
2361
  className: "markweave-slash-upload-field",
@@ -2403,10 +2403,10 @@ function Oi({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
2403
2403
  ]
2404
2404
  });
2405
2405
  }
2406
- function ki({ commands: e, messages: t = xi, state: n, position: r, inputCommand: i, onActiveIndexChange: a, onInputCommandChange: o, onSelect: s, onUpload: c }) {
2407
- let l = wi(n, e, r);
2406
+ function Ai({ commands: e, messages: t = Si, state: n, position: r, inputCommand: i, onActiveIndexChange: a, onInputCommandChange: o, onSelect: s, onUpload: c }) {
2407
+ let l = Ti(n, e, r);
2408
2408
  if (!l.visible || !r) return null;
2409
- let u = Ti(e, t), d = {
2409
+ let u = Ei(e, t), d = {
2410
2410
  left: r.left,
2411
2411
  top: r.top,
2412
2412
  maxHeight: r.maxHeight,
@@ -2428,12 +2428,12 @@ function ki({ commands: e, messages: t = xi, state: n, position: r, inputCommand
2428
2428
  "aria-label": t.slash.ariaLabel,
2429
2429
  "data-placement": r.placement,
2430
2430
  "data-testid": "markweave-slash-menu",
2431
- children: i?.inputKind === "emoji" ? /* @__PURE__ */ Z(Di, {
2431
+ children: i?.inputKind === "emoji" ? /* @__PURE__ */ Z(Oi, {
2432
2432
  command: i,
2433
2433
  messages: t,
2434
2434
  onBack: m,
2435
2435
  onSelect: s
2436
- }) : i?.inputKind === "upload" ? /* @__PURE__ */ Z(Oi, {
2436
+ }) : i?.inputKind === "upload" ? /* @__PURE__ */ Z(ki, {
2437
2437
  command: i,
2438
2438
  messages: t,
2439
2439
  onBack: m,
@@ -2477,7 +2477,7 @@ function ki({ commands: e, messages: t = xi, state: n, position: r, inputCommand
2477
2477
  }
2478
2478
  },
2479
2479
  children: [
2480
- /* @__PURE__ */ Z(Ci, { name: t.icon }),
2480
+ /* @__PURE__ */ Z(wi, { name: t.icon }),
2481
2481
  /* @__PURE__ */ Z("span", { children: t.label }),
2482
2482
  o && t.disabledReason ? /* @__PURE__ */ Z("small", { children: t.disabledReason }) : null
2483
2483
  ]
@@ -2489,10 +2489,10 @@ function ki({ commands: e, messages: t = xi, state: n, position: r, inputCommand
2489
2489
  }
2490
2490
  //#endregion
2491
2491
  //#region src/ui/table/TableControls.tsx
2492
- var Ai = n("zh");
2493
- function ji({ active: e, editor: t, interactionState: n = Xt, messages: r = Ai, onCopyPayload: i, onCommandResult: a, onEditWithAi: o }) {
2494
- let [s, c] = W(null), [l, u] = W("row-edge"), [d, f] = W(null), [p, m] = W(null), [h, g] = W(null), [_, v] = W(null), [y, b] = W(null), x = U(null), S = U(null), C = U(null), w = U(null), T = U(null), E = e ? Jt(t.state) : null;
2495
- if (V(() => {
2492
+ var ji = n("zh");
2493
+ function Mi({ active: e, editor: t, interactionState: n = Xt, messages: r = ji, onCopyPayload: i, onCommandResult: a, onEditWithAi: o }) {
2494
+ let [s, c] = K(null), [l, u] = K("row-edge"), [d, f] = K(null), [p, m] = K(null), [h, g] = K(null), [_, v] = K(null), [y, b] = K(null), x = G(null), S = G(null), C = G(null), w = G(null), T = G(null), E = e ? Jt(t.state) : null;
2495
+ if (U(() => {
2496
2496
  if (!y) return;
2497
2497
  let e = window.setTimeout(() => {
2498
2498
  b(null);
@@ -2500,7 +2500,7 @@ function ji({ active: e, editor: t, interactionState: n = Xt, messages: r = Ai,
2500
2500
  return () => {
2501
2501
  window.clearTimeout(e);
2502
2502
  };
2503
- }, [y]), be(() => {
2503
+ }, [y]), ve(() => {
2504
2504
  if (!e) {
2505
2505
  m(null), g(null), v(null), b(null);
2506
2506
  return;
@@ -2540,7 +2540,7 @@ function ji({ active: e, editor: t, interactionState: n = Xt, messages: r = Ai,
2540
2540
  n.hoverVisualRowIndex,
2541
2541
  l,
2542
2542
  s
2543
- ]), be(() => {
2543
+ ]), ve(() => {
2544
2544
  if (!e || !s) {
2545
2545
  f(null);
2546
2546
  return;
@@ -2578,7 +2578,7 @@ function ji({ active: e, editor: t, interactionState: n = Xt, messages: r = Ai,
2578
2578
  p,
2579
2579
  h,
2580
2580
  _
2581
- ]), V(() => {
2581
+ ]), U(() => {
2582
2582
  if (!e || !s) return;
2583
2583
  let n = (e) => {
2584
2584
  e.key === "Escape" && (c(null), t.view.focus());
@@ -2611,7 +2611,7 @@ function ji({ active: e, editor: t, interactionState: n = Xt, messages: r = Ai,
2611
2611
  messages: r
2612
2612
  });
2613
2613
  return o.copyFeedback ? (b(o.copyFeedback), o.copyPayload && i?.(o.copyPayload)) : b(null), a?.(o.commandResult), o.success;
2614
- }, te = (e) => {
2614
+ }, F = (e) => {
2615
2615
  let n = $n(t, e);
2616
2616
  n && o?.(n), c(null), t.view.focus();
2617
2617
  };
@@ -2732,7 +2732,7 @@ function ji({ active: e, editor: t, interactionState: n = Xt, messages: r = Ai,
2732
2732
  onClick: () => {
2733
2733
  if (u) {
2734
2734
  if (e.commandId === null) {
2735
- te(s === "row" || s === "column" ? s : "selection");
2735
+ F(s === "row" || s === "column" ? s : "selection");
2736
2736
  return;
2737
2737
  }
2738
2738
  P(e.commandId).finally(() => c(null));
@@ -2747,9 +2747,9 @@ function ji({ active: e, editor: t, interactionState: n = Xt, messages: r = Ai,
2747
2747
  }
2748
2748
  //#endregion
2749
2749
  //#region src/ui/table/TableSelectionOverlay.tsx
2750
- function Mi({ editor: e, focusState: t }) {
2751
- let [n, r] = W(null);
2752
- return be(() => {
2750
+ function Ni({ editor: e, focusState: t }) {
2751
+ let [n, r] = K(null);
2752
+ return ve(() => {
2753
2753
  if (t.mode !== "cell-selection") {
2754
2754
  r(null);
2755
2755
  return;
@@ -2790,12 +2790,12 @@ function Mi({ editor: e, focusState: t }) {
2790
2790
  }
2791
2791
  //#endregion
2792
2792
  //#region src/ui/toc/MarkweaveInnerToc.tsx
2793
- function Ni(e, t) {
2793
+ function Pi(e, t) {
2794
2794
  return `${e.toc.itemAriaLabel}: ${t.text}`;
2795
2795
  }
2796
- function Pi({ editor: e, state: t, messages: n, editable: r, placement: i }) {
2797
- let a = U(null);
2798
- if (V(() => {
2796
+ function Fi({ editor: e, state: t, messages: n, editable: r, placement: i }) {
2797
+ let a = G(null);
2798
+ if (U(() => {
2799
2799
  if (!(i !== "container" || !a.current)) return mr(a.current);
2800
2800
  }, [i]), !t.items.length) return null;
2801
2801
  let o = (t) => {
@@ -2826,7 +2826,7 @@ function Pi({ editor: e, state: t, messages: n, editable: r, placement: i }) {
2826
2826
  "data-level": e.level,
2827
2827
  "data-active": e.active ? "true" : "false",
2828
2828
  "aria-current": e.active ? "location" : void 0,
2829
- "aria-label": Ni(n, e),
2829
+ "aria-label": Pi(n, e),
2830
2830
  title: e.text,
2831
2831
  onClick: () => o(e),
2832
2832
  children: e.text
@@ -2837,7 +2837,7 @@ function Pi({ editor: e, state: t, messages: n, editable: r, placement: i }) {
2837
2837
  }
2838
2838
  //#endregion
2839
2839
  //#region src/MarkweaveEditor.tsx
2840
- var Fi = {
2840
+ var Ii = {
2841
2841
  active: !1,
2842
2842
  mode: "outside",
2843
2843
  activeCellPos: null,
@@ -2845,21 +2845,21 @@ var Fi = {
2845
2845
  selectedCellCount: 0,
2846
2846
  selectionFrom: 0,
2847
2847
  selectionTo: 0
2848
- }, Ii = {
2848
+ }, Li = {
2849
2849
  active: !1,
2850
2850
  language: ht.defaultLanguage,
2851
2851
  mermaidPreviewMode: "code",
2852
2852
  pos: null,
2853
2853
  text: ""
2854
- }, Li = Ct({
2854
+ }, Ri = Ct({
2855
2855
  active: !1,
2856
2856
  mode: "code",
2857
2857
  source: ""
2858
2858
  });
2859
- function Ri(e) {
2859
+ function zi(e) {
2860
2860
  return Zt.getState(e.state) ?? Xt;
2861
2861
  }
2862
- function zi(e) {
2862
+ function Bi(e) {
2863
2863
  if (!e || typeof window > "u") return null;
2864
2864
  let t = e.parentElement;
2865
2865
  for (; t;) {
@@ -2869,91 +2869,91 @@ function zi(e) {
2869
2869
  }
2870
2870
  return null;
2871
2871
  }
2872
- function Bi(e) {
2872
+ function Vi(e) {
2873
2873
  return typeof window > "u" || typeof window.requestAnimationFrame != "function" ? globalThis.setTimeout(() => e(0), 0) : window.requestAnimationFrame(e);
2874
2874
  }
2875
- function Vi(e) {
2875
+ function Hi(e) {
2876
2876
  if (typeof window < "u" && typeof window.cancelAnimationFrame == "function") {
2877
2877
  window.cancelAnimationFrame(e);
2878
2878
  return;
2879
2879
  }
2880
2880
  globalThis.clearTimeout(e);
2881
2881
  }
2882
- function Hi({ ariaLabel: e, autoFocusFirstTableBodyCell: i = !1, autofocus: a = !1, content: o, contentFormat: c, defaultContent: l = "", defaultContentFormat: u, editable: d = !0, innerToc: f = !0, innerTocPlacement: p, lang: m, mode: h = "live", theme: g, onEditWithAi: _, onExtractToNote: v, onRewriteSelection: y, onRuntimeStateChange: b, onSlashCommandUpload: x, onTableCommandResult: S, onTableCopyPayload: C, onTocChange: w, onUpdate: T, linkCardResolver: E } = {}) {
2883
- let D = Ie(h), O = gr(g), k = pr(p), A = D === "live" && d !== !1, j = Ze(o === void 0 ? u : c), M = U({
2884
- editorMode: D,
2885
- effectiveEditable: A
2882
+ function Ui({ ariaLabel: e, autoFocusFirstTableBodyCell: i = !1, autofocus: a = !1, content: o, contentFormat: c, defaultContent: l = "", defaultContentFormat: u, editable: d = !0, innerToc: f = !0, innerTocPlacement: p, lang: m, mode: h = "live", theme: g, canvasColor: _, onEditWithAi: v, onExtractToNote: y, onRewriteSelection: b, onRuntimeStateChange: x, onSlashCommandUpload: S, onTableCommandResult: C, onTableCopyPayload: w, onTocChange: T, onUpdate: E, linkCardResolver: D } = {}) {
2883
+ let O = Le(h), k = _r(g), A = gr(_), j = pr(p), M = O === "live" && d !== !1, ee = Ze(o === void 0 ? u : c), N = G({
2884
+ editorMode: O,
2885
+ effectiveEditable: M
2886
2886
  });
2887
- M.current = {
2888
- editorMode: D,
2889
- effectiveEditable: A
2887
+ N.current = {
2888
+ editorMode: O,
2889
+ effectiveEditable: M
2890
2890
  };
2891
- let ee = U(null);
2892
- ee.current === null && (ee.current = r(m));
2893
- let N = ee.current, P = H(() => n(N), [N]), te = H(() => t(N), [N]), F = U(x);
2894
- F.current = x;
2895
- let I = U(E);
2896
- I.current = E;
2897
- let ne = H(() => Rr({
2898
- lang: N,
2891
+ let P = G(null);
2892
+ P.current === null && (P.current = r(m));
2893
+ let F = P.current, I = W(() => n(F), [F]), L = W(() => t(F), [F]), R = G(S);
2894
+ R.current = S;
2895
+ let te = G(D);
2896
+ te.current = D;
2897
+ let ne = W(() => zr({
2898
+ lang: F,
2899
2899
  onImageUpload: (e) => {
2900
- if (F.current) return F.current(e);
2901
- let t = Se(e);
2900
+ if (R.current) return R.current(e);
2901
+ let t = xe(e);
2902
2902
  if (!t) throw Error("File upload requires an upload handler.");
2903
2903
  return t;
2904
2904
  },
2905
2905
  onVideoUpload: (e) => {
2906
- if (F.current) return F.current(e);
2907
- let t = Se(e);
2906
+ if (R.current) return R.current(e);
2907
+ let t = xe(e);
2908
2908
  if (!t) throw Error("File upload requires an upload handler.");
2909
2909
  return t;
2910
2910
  },
2911
- linkCardResolver: (e) => I.current?.(e) ?? Promise.resolve(null)
2912
- }), [N]), [L, re] = W(null), [R, z] = W(Wt), [ie, ae] = W(null), [oe, se] = W(null), [ce, le] = W("code"), [ue, de] = W(null), [fe, pe] = W(Xt), [me, he] = W(null), [ge, _e] = W(0), ve = U(!1), ye = U({
2911
+ linkCardResolver: (e) => te.current?.(e) ?? Promise.resolve(null)
2912
+ }), [F]), [z, re] = K(null), [B, V] = K(Wt), [ie, ae] = K(null), [oe, se] = K(null), [ce, le] = K("code"), [ue, de] = K(null), [fe, pe] = K(Xt), [me, he] = K(null), [ge, _e] = K(0), ve = G(!1), ye = G({
2913
2913
  content: o,
2914
- format: j
2915
- }), be = U(null), G = U(null), xe = U({ onUpdate: T }), Ce = H(() => It(R.query, te), [te, R.query]);
2916
- xe.current = { onUpdate: T }, ye.current = {
2914
+ format: ee
2915
+ }), be = G(null), q = G(null), Se = G({ onUpdate: E }), Ce = W(() => It(B.query, L), [L, B.query]);
2916
+ Se.current = { onUpdate: E }, ye.current = {
2917
2917
  content: o,
2918
- format: j
2918
+ format: ee
2919
2919
  };
2920
- let we = B(() => {
2921
- G.current !== null && (window.clearTimeout(G.current), G.current = null), _e((e) => e + 1);
2922
- }, []), Te = B(() => {
2923
- G.current !== null && window.clearTimeout(G.current), G.current = window.setTimeout(() => {
2924
- G.current = null, _e((e) => e + 1);
2920
+ let we = H(() => {
2921
+ q.current !== null && (window.clearTimeout(q.current), q.current = null), _e((e) => e + 1);
2922
+ }, []), Te = H(() => {
2923
+ q.current !== null && window.clearTimeout(q.current), q.current = window.setTimeout(() => {
2924
+ q.current = null, _e((e) => e + 1);
2925
2925
  }, ct);
2926
2926
  }, []);
2927
- V(() => () => {
2928
- G.current !== null && window.clearTimeout(G.current);
2927
+ U(() => () => {
2928
+ q.current !== null && window.clearTimeout(q.current);
2929
2929
  }, []);
2930
- let K = B(() => {
2931
- ae(null), se(null), z(Wt);
2932
- }, []), Ee = B((e) => {
2930
+ let Ee = H(() => {
2931
+ ae(null), se(null), V(Wt);
2932
+ }, []), De = H((e) => {
2933
2933
  let t = Ut(e.state);
2934
2934
  if (!t) {
2935
- z((e) => e.name === "idle" ? e : Wt), ae(null), se(null);
2935
+ V((e) => e.name === "idle" ? e : Wt), ae(null), se(null);
2936
2936
  return;
2937
2937
  }
2938
2938
  let n = e.coordsAtPos(t.cursor), r = e.coordsAtPos(t.triggerFrom), i = e.dom.closest(".markweave-editor-frame")?.getBoundingClientRect();
2939
2939
  ae(Ht(n, {
2940
2940
  frameRect: i,
2941
2941
  triggerRect: r
2942
- })), z((e) => Vt(e, t));
2943
- }, []), De = B((e) => Ee(e.view), [Ee]), Oe = B((e) => {
2942
+ })), V((e) => Vt(e, t));
2943
+ }, []), Oe = H((e) => De(e.view), [De]), ke = H((e) => {
2944
2944
  let t = at(e);
2945
2945
  re((e) => tt(e, t) ? e : t);
2946
2946
  let n = jt(e);
2947
2947
  n && (Nt(e, n, !0), de(n));
2948
2948
  let r = pt(e);
2949
2949
  r.active && r.language === "mermaid" && le(r.mermaidPreviewMode);
2950
- }, []), ke = B((e) => {
2951
- pe(Ri(e));
2952
- }, []), q = s({
2950
+ }, []), Ae = H((e) => {
2951
+ pe(zi(e));
2952
+ }, []), J = s({
2953
2953
  extensions: ne,
2954
2954
  content: o ?? l,
2955
- contentType: Je(j),
2956
- editable: A,
2955
+ contentType: Je(ee),
2956
+ editable: M,
2957
2957
  autofocus: a,
2958
2958
  editorProps: {
2959
2959
  attributes: {
@@ -2964,34 +2964,34 @@ function Hi({ ariaLabel: e, autoFocusFirstTableBodyCell: i = !1, autofocus: a =
2964
2964
  spellcheck: "false",
2965
2965
  translate: "no"
2966
2966
  },
2967
- handleClick: (e, t, n) => M.current.effectiveEditable ? !1 : Qe(n),
2967
+ handleClick: (e, t, n) => N.current.effectiveEditable ? !1 : Qe(n),
2968
2968
  handleDOMEvents: {
2969
- compositionstart: () => M.current.effectiveEditable ? (z((e) => Gt(e, { type: "composition-start" })), ae(null), !1) : !1,
2970
- compositionend: (e) => (M.current.effectiveEditable && window.setTimeout(() => Ee(e), 0), !1),
2969
+ compositionstart: () => N.current.effectiveEditable ? (V((e) => Gt(e, { type: "composition-start" })), ae(null), !1) : !1,
2970
+ compositionend: (e) => (N.current.effectiveEditable && window.setTimeout(() => De(e), 0), !1),
2971
2971
  click: (e, t) => {
2972
- if (M.current.effectiveEditable) {
2972
+ if (N.current.effectiveEditable) {
2973
2973
  let n = At(e, t);
2974
- return n ? (t.preventDefault(), t.stopPropagation(), K(), Pt(e, n, !0), Ft(e, n), de(n), !0) : (de(null), !1);
2974
+ return n ? (t.preventDefault(), t.stopPropagation(), Ee(), Pt(e, n, !0), Ft(e, n), de(n), !0) : (de(null), !1);
2975
2975
  }
2976
2976
  return Qe(t);
2977
2977
  }
2978
2978
  }
2979
2979
  },
2980
2980
  onSelectionUpdate: ({ editor: e }) => {
2981
- Oe(e);
2981
+ ke(e);
2982
2982
  },
2983
2983
  onCreate: ({ editor: e }) => {
2984
- i && M.current.effectiveEditable && qt(e), ke(e), Oe(e), we();
2984
+ i && N.current.effectiveEditable && qt(e), Ae(e), ke(e), we();
2985
2985
  },
2986
2986
  onTransaction: ({ editor: e, transaction: t }) => {
2987
- ke(e), (t.docChanged || yt(t)) && Te(), t.docChanged && de((t) => {
2987
+ Ae(e), (t.docChanged || yt(t)) && Te(), t.docChanged && de((t) => {
2988
2988
  if (!t) return null;
2989
2989
  let n = kt(e, t.pos);
2990
2990
  return n?.kind === t.kind ? n : null;
2991
2991
  });
2992
2992
  },
2993
2993
  onUpdate: ({ editor: e }) => {
2994
- Oe(e), M.current.effectiveEditable && De(e), ve.current || xe.current.onUpdate?.(qe(e, { onContentRead: (t, n) => {
2994
+ ke(e), N.current.effectiveEditable && Oe(e), ve.current || Se.current.onUpdate?.(qe(e, { onContentRead: (t, n) => {
2995
2995
  let r = ye.current;
2996
2996
  r.content !== void 0 && t === r.format && (be.current = {
2997
2997
  content: n,
@@ -3001,312 +3001,314 @@ function Hi({ ariaLabel: e, autoFocusFirstTableBodyCell: i = !1, autofocus: a =
3001
3001
  } }));
3002
3002
  }
3003
3003
  });
3004
- V(() => {
3005
- q && (q.setEditable(A), Le(q, {
3006
- mode: D,
3007
- editable: A
3008
- }), xt(q, A ? "live" : "view"), we(), A || K());
3004
+ U(() => {
3005
+ J && (J.setEditable(M), Re(J, {
3006
+ mode: O,
3007
+ editable: M
3008
+ }), xt(J, M ? "live" : "view"), we(), M || Ee());
3009
3009
  }, [
3010
- K,
3011
- q,
3012
- D,
3013
- A,
3010
+ Ee,
3011
+ J,
3012
+ O,
3013
+ M,
3014
3014
  we
3015
- ]), V(() => {
3016
- q && bt(q, O);
3017
- }, [q, O]), V(() => {
3015
+ ]), U(() => {
3016
+ J && bt(J, k);
3017
+ }, [J, k]), U(() => {
3018
3018
  let e = Ze(c);
3019
- if (!(!q || o === void 0)) {
3020
- if (Xe(q, be.current, o, e)) {
3019
+ if (!(!J || o === void 0)) {
3020
+ if (Xe(J, be.current, o, e)) {
3021
3021
  be.current = null;
3022
3022
  return;
3023
3023
  }
3024
- be.current = null, !Ye(q, o, e) && (ve.current = !0, q.commands.setContent(o, {
3024
+ be.current = null, !Ye(J, o, e) && (ve.current = !0, J.commands.setContent(o, {
3025
3025
  contentType: Je(e),
3026
3026
  emitUpdate: !1
3027
- }), ve.current = !1, Oe(q), A && De(q), ke(q), we());
3027
+ }), ve.current = !1, ke(J), M && Oe(J), Ae(J), we());
3028
3028
  }
3029
3029
  }, [
3030
3030
  o,
3031
3031
  c,
3032
- A,
3033
- q,
3032
+ M,
3033
+ J,
3034
3034
  we,
3035
+ ke,
3035
3036
  Oe,
3036
- De,
3037
- ke
3038
- ]), V(() => {
3037
+ Ae
3038
+ ]), U(() => {
3039
3039
  if (!ie) return;
3040
3040
  let e = (e) => {
3041
3041
  let t = e.target;
3042
- t instanceof Element && (t.closest(".markweave-slash-menu") || t.closest(".markweave-slash-trigger") || K());
3042
+ t instanceof Element && (t.closest(".markweave-slash-menu") || t.closest(".markweave-slash-trigger") || Ee());
3043
3043
  };
3044
3044
  return document.addEventListener("pointerdown", e, !0), () => document.removeEventListener("pointerdown", e, !0);
3045
- }, [K, ie]);
3046
- let Ae = H(() => q ? pt(q) : Ii, [
3047
- q,
3045
+ }, [Ee, ie]);
3046
+ let je = W(() => J ? pt(J) : Li, [
3047
+ J,
3048
3048
  ge,
3049
- L
3050
- ]), je = H(() => q ? Jt(q.state) : Fi, [
3051
- q,
3049
+ z
3050
+ ]), Me = W(() => J ? Jt(J.state) : Ii, [
3051
+ J,
3052
3052
  ge,
3053
- L,
3053
+ z,
3054
3054
  fe
3055
- ]), Me = L?.currentNode === "codeBlock", Ne = Me && Ae.language === "mermaid", Pe = H(() => q ? Ct({
3056
- active: Ne,
3055
+ ]), Ne = z?.currentNode === "codeBlock", Pe = Ne && je.language === "mermaid", Fe = W(() => J ? Ct({
3056
+ active: Pe,
3057
3057
  mode: ce,
3058
- source: Ae.text
3059
- }) : Li, [
3060
- Ae.text,
3061
- q,
3062
- Ne,
3058
+ source: je.text
3059
+ }) : Ri, [
3060
+ je.text,
3061
+ J,
3062
+ Pe,
3063
3063
  ce
3064
- ]), J = H(() => q ? Kt(q.state) : null, [q, ge]), Y = H(() => q ? dr(q.state.doc) : lr.items, [q, ge]), Fe = H(() => fr(Y, me), [me, Y]), Re = H(() => cr(Y, Fe), [Fe, Y]), ze = B(() => {
3065
- if (!q || !Y.length) {
3064
+ ]), Ie = W(() => J ? Kt(J.state) : null, [J, ge]), Y = W(() => J ? dr(J.state.doc) : lr.items, [J, ge]), ze = W(() => fr(Y, me), [me, Y]), X = W(() => cr(Y, ze), [ze, Y]), Z = H(() => {
3065
+ if (!J || !Y.length) {
3066
3066
  he(null);
3067
3067
  return;
3068
3068
  }
3069
- let e = ur(q, Y);
3069
+ let e = ur(J, Y);
3070
3070
  he((t) => t === e ? t : e);
3071
- }, [q, Y]);
3072
- V(() => {
3071
+ }, [J, Y]);
3072
+ U(() => {
3073
3073
  he((e) => {
3074
3074
  let t = fr(Y, e);
3075
3075
  return e === t ? e : t;
3076
3076
  });
3077
- }, [Y]), V(() => {
3078
- if (!q || !Y.length || typeof window > "u") return;
3077
+ }, [Y]), U(() => {
3078
+ if (!J || !Y.length || typeof window > "u") return;
3079
3079
  let e = null, t = () => {
3080
- e !== null && Vi(e), e = Bi(() => {
3081
- e = null, ze();
3080
+ e !== null && Hi(e), e = Vi(() => {
3081
+ e = null, Z();
3082
3082
  });
3083
- }, n = zi(q.view.dom);
3083
+ }, n = Bi(J.view.dom);
3084
3084
  return window.addEventListener("scroll", t, { passive: !0 }), window.addEventListener("resize", t), n?.addEventListener("scroll", t, { passive: !0 }), t(), () => {
3085
- window.removeEventListener("scroll", t), window.removeEventListener("resize", t), n?.removeEventListener("scroll", t), e !== null && Vi(e);
3085
+ window.removeEventListener("scroll", t), window.removeEventListener("resize", t), n?.removeEventListener("scroll", t), e !== null && Hi(e);
3086
3086
  };
3087
3087
  }, [
3088
- q,
3088
+ J,
3089
3089
  Y.length,
3090
- ze
3090
+ Z
3091
3091
  ]);
3092
- let X = H(() => $e({
3092
+ let Q = W(() => $e({
3093
3093
  revision: ge,
3094
- mode: D,
3095
- editable: A,
3096
- toc: Re,
3097
- selection: L,
3098
- slash: R,
3099
- table: je,
3094
+ mode: O,
3095
+ editable: M,
3096
+ toc: X,
3097
+ selection: z,
3098
+ slash: B,
3099
+ table: Me,
3100
3100
  tableInteraction: fe,
3101
- codeBlock: Ae,
3102
- mermaid: Pe,
3103
- tableDebugSnapshot: J
3101
+ codeBlock: je,
3102
+ mermaid: Fe,
3103
+ tableDebugSnapshot: Ie
3104
3104
  }), [
3105
- Ae,
3106
- D,
3107
- A,
3108
- Pe,
3109
- ge,
3110
- L,
3111
- R,
3112
- J,
3113
3105
  je,
3106
+ O,
3107
+ M,
3108
+ Fe,
3109
+ ge,
3110
+ z,
3111
+ B,
3112
+ Ie,
3113
+ Me,
3114
3114
  fe,
3115
- Re
3115
+ X
3116
3116
  ]);
3117
- V(() => {
3118
- b?.(X);
3119
- }, [b, X]), V(() => {
3120
- w?.(Re);
3121
- }, [w, Re]);
3122
- let Z = B((e, t) => {
3123
- if (!(!q || !A) && Lt(e)) {
3117
+ U(() => {
3118
+ x?.(Q);
3119
+ }, [x, Q]), U(() => {
3120
+ T?.(X);
3121
+ }, [T, X]);
3122
+ let Be = H((e, t) => {
3123
+ if (!(!J || !M) && Lt(e)) {
3124
3124
  if (e.inputKind && !t?.emoji && !t?.uploadResult) {
3125
3125
  se(e);
3126
3126
  return;
3127
3127
  }
3128
- Bt(q, R, e, t), z((e) => Gt(e, { type: "execute" })), K();
3128
+ Bt(J, B, e, t), V((e) => Gt(e, { type: "execute" })), Ee();
3129
3129
  }
3130
3130
  }, [
3131
- K,
3132
- A,
3133
- q,
3134
- R
3135
- ]), Q = B((e) => {
3136
- z((t) => Gt(t, {
3131
+ Ee,
3132
+ M,
3133
+ J,
3134
+ B
3135
+ ]), Ve = H((e) => {
3136
+ V((t) => Gt(t, {
3137
3137
  type: "set-active",
3138
3138
  index: e,
3139
3139
  optionCount: Ce.length
3140
3140
  }));
3141
- }, [Ce.length]), Be = B((e) => {
3142
- if (!q || oe || !A) return;
3143
- let t = Rt(R, Ce, e.key, { isComposing: e.nativeEvent.isComposing || Ke(q.state) });
3141
+ }, [Ce.length]), He = H((e) => {
3142
+ if (!J || oe || !M) return;
3143
+ let t = Rt(B, Ce, e.key, { isComposing: e.nativeEvent.isComposing || Ke(J.state) });
3144
3144
  if (t.type !== "ignore") {
3145
3145
  if (t.type === "close") {
3146
- e.preventDefault(), z((e) => Gt(e, { type: "escape" })), K();
3146
+ e.preventDefault(), V((e) => Gt(e, { type: "escape" })), Ee();
3147
3147
  return;
3148
3148
  }
3149
3149
  if (t.type === "move-active") {
3150
- e.preventDefault(), z((e) => Gt(e, {
3150
+ e.preventDefault(), V((e) => Gt(e, {
3151
3151
  type: "move-active",
3152
3152
  delta: t.delta,
3153
3153
  optionCount: t.optionCount
3154
3154
  }));
3155
3155
  return;
3156
3156
  }
3157
- t.type === "execute-active" && (e.preventDefault(), Z(t.command));
3157
+ t.type === "execute-active" && (e.preventDefault(), Be(t.command));
3158
3158
  }
3159
3159
  }, [
3160
- K,
3161
- A,
3162
- q,
3160
+ Ee,
3161
+ M,
3162
+ J,
3163
3163
  Ce,
3164
- Z,
3164
+ Be,
3165
3165
  oe,
3166
- R
3167
- ]), Ve = H(() => ({
3168
- closeSlashMenu: K,
3169
- focusFirstTableBodyCell: () => q ? qt(q) : !1,
3166
+ B
3167
+ ]), Ue = W(() => ({
3168
+ closeSlashMenu: Ee,
3169
+ focusFirstTableBodyCell: () => J ? qt(J) : !1,
3170
3170
  setContent: (e, t = {}) => {
3171
- if (!q) return !1;
3171
+ if (!J) return !1;
3172
3172
  let n = Ze(t.format);
3173
- return q.commands.setContent(e, {
3173
+ return J.commands.setContent(e, {
3174
3174
  contentType: Je(n),
3175
3175
  emitUpdate: t.emitUpdate ?? !1
3176
- }), t.focusFirstTableBodyCell && qt(q), Oe(q), A && De(q), ke(q), we(), !0;
3176
+ }), t.focusFirstTableBodyCell && qt(J), ke(J), M && Oe(J), Ae(J), we(), !0;
3177
3177
  }
3178
3178
  }), [
3179
- K,
3180
- A,
3181
- q,
3179
+ Ee,
3180
+ M,
3181
+ J,
3182
3182
  we,
3183
+ ke,
3183
3184
  Oe,
3184
- De,
3185
- ke
3185
+ Ae
3186
3186
  ]);
3187
3187
  return {
3188
- editor: q,
3189
- frameProps: H(() => ({
3188
+ editor: J,
3189
+ frameProps: W(() => ({
3190
3190
  className: "markweave-editor-frame",
3191
- "aria-label": e ?? P.common.editorAriaLabel,
3191
+ "aria-label": e ?? I.common.editorAriaLabel,
3192
3192
  "data-testid": "markweave-editor-frame",
3193
- "data-markweave-mode": D,
3194
- "data-markweave-theme": O,
3193
+ "data-markweave-mode": O,
3194
+ "data-markweave-theme": k,
3195
+ style: A ? { "--markweave-canvas": A } : void 0,
3195
3196
  "data-markweave-inner-toc": f ? "true" : "false",
3196
- "data-markweave-inner-toc-placement": k,
3197
- "data-mermaid-mode": Pe.mode,
3198
- "data-table-focus-mode": je.mode,
3199
- onKeyDownCapture: Be
3197
+ "data-markweave-inner-toc-placement": j,
3198
+ "data-mermaid-mode": Fe.mode,
3199
+ "data-table-focus-mode": Me.mode,
3200
+ onKeyDownCapture: He
3200
3201
  }), [
3201
3202
  e,
3202
- D,
3203
- Be,
3203
+ O,
3204
+ He,
3204
3205
  f,
3205
- Pe.mode,
3206
- P.common.editorAriaLabel,
3206
+ Fe.mode,
3207
+ I.common.editorAriaLabel,
3208
+ A,
3209
+ j,
3207
3210
  k,
3208
- O,
3209
- je.mode
3211
+ Me.mode
3210
3212
  ]),
3211
- overlayProps: H(() => ({
3212
- floatingToolbar: q && A ? {
3213
- editor: q,
3214
- messages: P,
3215
- selectionSnapshot: L,
3216
- onRewriteSelection: y,
3217
- onExtractToNote: v
3213
+ overlayProps: W(() => ({
3214
+ floatingToolbar: J && M ? {
3215
+ editor: J,
3216
+ messages: I,
3217
+ selectionSnapshot: z,
3218
+ onRewriteSelection: b,
3219
+ onExtractToNote: y
3218
3220
  } : null,
3219
- slashCommandMenu: q && A ? {
3221
+ slashCommandMenu: J && M ? {
3220
3222
  commands: Ce,
3221
- state: R,
3223
+ state: B,
3222
3224
  position: ie,
3223
3225
  inputCommand: oe,
3224
- messages: P,
3225
- onActiveIndexChange: Q,
3226
+ messages: I,
3227
+ onActiveIndexChange: Ve,
3226
3228
  onInputCommandChange: se,
3227
- onSelect: Z,
3228
- onUpload: x
3229
+ onSelect: Be,
3230
+ onUpload: S
3229
3231
  } : null,
3230
- tableControls: q && A ? {
3231
- editor: q,
3232
- active: je.active,
3232
+ tableControls: J && M ? {
3233
+ editor: J,
3234
+ active: Me.active,
3233
3235
  interactionState: fe,
3234
- messages: P,
3235
- onCopyPayload: C,
3236
- onCommandResult: S,
3237
- onEditWithAi: _
3236
+ messages: I,
3237
+ onCopyPayload: w,
3238
+ onCommandResult: C,
3239
+ onEditWithAi: v
3238
3240
  } : null,
3239
- tableSelectionOverlay: q && A ? {
3240
- editor: q,
3241
- focusState: je
3241
+ tableSelectionOverlay: J && M ? {
3242
+ editor: J,
3243
+ focusState: Me
3242
3244
  } : null,
3243
- codeBlockControls: q ? {
3244
- editor: q,
3245
- active: A && Me,
3245
+ codeBlockControls: J ? {
3246
+ editor: J,
3247
+ active: M && Ne,
3246
3248
  mermaidMode: ce,
3247
3249
  onMermaidModeChange: le,
3248
- readOnly: !A
3250
+ readOnly: !M
3249
3251
  } : null,
3250
- innerToc: q && f && Re.items.length ? {
3251
- editor: q,
3252
- editable: A,
3253
- messages: P,
3254
- placement: k,
3255
- state: Re
3252
+ innerToc: J && f && X.items.length ? {
3253
+ editor: J,
3254
+ editable: M,
3255
+ messages: I,
3256
+ placement: j,
3257
+ state: X
3256
3258
  } : null,
3257
- mathEditorPopover: q && A && ue ? {
3258
- editor: q,
3259
- messages: P,
3259
+ mathEditorPopover: J && M && ue ? {
3260
+ editor: J,
3261
+ messages: I,
3260
3262
  target: ue,
3261
3263
  onClose: () => de(null)
3262
3264
  } : null
3263
3265
  }), [
3264
- A,
3265
- q,
3266
+ M,
3267
+ J,
3266
3268
  Ce,
3267
3269
  f,
3268
- Me,
3270
+ Ne,
3269
3271
  ce,
3270
- P,
3272
+ I,
3271
3273
  ue,
3272
- _,
3273
3274
  v,
3274
3275
  y,
3275
- x,
3276
+ b,
3276
3277
  S,
3277
3278
  C,
3278
- Z,
3279
- L,
3280
- Q,
3279
+ w,
3280
+ Be,
3281
+ z,
3282
+ Ve,
3281
3283
  oe,
3282
3284
  ie,
3283
- R,
3284
- je,
3285
+ B,
3286
+ Me,
3285
3287
  fe,
3286
- Re
3288
+ X
3287
3289
  ]),
3288
- runtimeSnapshot: X,
3289
- actions: Ve
3290
+ runtimeSnapshot: Q,
3291
+ actions: Ue
3290
3292
  };
3291
3293
  }
3292
- function Ui({ className: e, ...t }) {
3293
- let n = Hi(t);
3294
+ function Wi({ className: e, ...t }) {
3295
+ let n = Ui(t);
3294
3296
  if (!n.editor) return null;
3295
3297
  let r = [n.frameProps.className, e].filter(Boolean).join(" ");
3296
3298
  return /* @__PURE__ */ Q("section", {
3297
3299
  ...n.frameProps,
3298
3300
  className: r,
3299
3301
  children: [
3300
- n.overlayProps.floatingToolbar ? /* @__PURE__ */ Z(ci, { ...n.overlayProps.floatingToolbar }) : null,
3301
- n.overlayProps.slashCommandMenu ? /* @__PURE__ */ Z(ki, { ...n.overlayProps.slashCommandMenu }) : null,
3302
- n.overlayProps.tableControls ? /* @__PURE__ */ Z(ji, { ...n.overlayProps.tableControls }) : null,
3303
- n.overlayProps.tableSelectionOverlay ? /* @__PURE__ */ Z(Mi, { ...n.overlayProps.tableSelectionOverlay }) : null,
3304
- n.overlayProps.codeBlockControls ? /* @__PURE__ */ Z(Vr, { ...n.overlayProps.codeBlockControls }) : null,
3305
- n.overlayProps.innerToc ? /* @__PURE__ */ Z(Pi, { ...n.overlayProps.innerToc }) : null,
3306
- n.overlayProps.mathEditorPopover ? /* @__PURE__ */ Z(bi, { ...n.overlayProps.mathEditorPopover }) : null,
3302
+ n.overlayProps.floatingToolbar ? /* @__PURE__ */ Z(li, { ...n.overlayProps.floatingToolbar }) : null,
3303
+ n.overlayProps.slashCommandMenu ? /* @__PURE__ */ Z(Ai, { ...n.overlayProps.slashCommandMenu }) : null,
3304
+ n.overlayProps.tableControls ? /* @__PURE__ */ Z(Mi, { ...n.overlayProps.tableControls }) : null,
3305
+ n.overlayProps.tableSelectionOverlay ? /* @__PURE__ */ Z(Ni, { ...n.overlayProps.tableSelectionOverlay }) : null,
3306
+ n.overlayProps.codeBlockControls ? /* @__PURE__ */ Z(Hr, { ...n.overlayProps.codeBlockControls }) : null,
3307
+ n.overlayProps.innerToc ? /* @__PURE__ */ Z(Fi, { ...n.overlayProps.innerToc }) : null,
3308
+ n.overlayProps.mathEditorPopover ? /* @__PURE__ */ Z(xi, { ...n.overlayProps.mathEditorPopover }) : null,
3307
3309
  /* @__PURE__ */ Z(i, { editor: n.editor })
3308
3310
  ]
3309
3311
  });
3310
3312
  }
3311
3313
  //#endregion
3312
- export { Ui as MarkweaveEditor, Rr as createMarkweaveEditorExtensions, Rr as createMarkweaveReactEditorExtensions, Hi as useMarkweaveEditorController };
3314
+ export { Wi as MarkweaveEditor, zr as createMarkweaveEditorExtensions, zr as createMarkweaveReactEditorExtensions, Ui as useMarkweaveEditorController };