@markweave/react 0.2.2 → 0.2.4

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