@markweave/react 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.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,22 @@ 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
+ linkCardExtension: zr.configure({
847
848
  lang: t.lang,
848
849
  messages: n(t.lang),
849
850
  resolver: t.linkCardResolver
850
851
  }),
851
852
  mediaExtensions: Be({
852
- image: Dr,
853
- video: jr,
853
+ image: Or,
854
+ video: Mr,
854
855
  lang: t.lang,
855
856
  onImageUpload: t.onImageUpload,
856
857
  onVideoUpload: t.onVideoUpload
@@ -859,7 +860,7 @@ function zr(t = {}) {
859
860
  }
860
861
  //#endregion
861
862
  //#region src/ui/codeblock/CodeBlockControls.tsx
862
- function Br(e) {
863
+ function Vr(e) {
863
864
  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
865
  cx: "10",
865
866
  cy: "10",
@@ -896,7 +897,7 @@ function Br(e) {
896
897
  /* @__PURE__ */ Z("path", { d: "m14 14 4 4" })
897
898
  ] }) : 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
899
  }
899
- function Vr({ icon: e }) {
900
+ function Hr({ icon: e }) {
900
901
  return /* @__PURE__ */ Z("svg", {
901
902
  viewBox: "0 0 24 24",
902
903
  "aria-hidden": "true",
@@ -907,20 +908,20 @@ function Vr({ icon: e }) {
907
908
  strokeLinecap: "round",
908
909
  strokeLinejoin: "round",
909
910
  strokeWidth: "1.8",
910
- children: Br(e)
911
+ children: Vr(e)
911
912
  })
912
913
  });
913
914
  }
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({
915
+ function Ur({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, readOnly: i = !1 }) {
916
+ let a = K(null), o = K(null), s = K(null), c = K({
916
917
  active: !1,
917
918
  lastX: 0,
918
919
  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,
920
+ }), [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 ? {
921
+ ...F,
922
+ pos: F.pos,
922
923
  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]);
924
+ } : 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
925
  if (U(() => {
925
926
  i && (v(!1), b(""));
926
927
  }, [i]), U(() => {
@@ -973,7 +974,7 @@ function Hr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
973
974
  document.removeEventListener("keydown", e);
974
975
  };
975
976
  }, [t, T]), U(() => {
976
- if (!R || !_) return;
977
+ if (!te || !_) return;
977
978
  let e = (e) => {
978
979
  e.key === "Escape" && (v(!1), t.view.focus());
979
980
  }, n = (e) => {
@@ -983,10 +984,10 @@ function Hr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
983
984
  document.removeEventListener("keydown", e), document.removeEventListener("mousedown", n);
984
985
  };
985
986
  }, [
986
- R,
987
+ te,
987
988
  t,
988
989
  _
989
- ]), ve(() => {
990
+ ]), W(() => {
990
991
  let e = () => {
991
992
  let e = a.current;
992
993
  if (!e) return;
@@ -1009,15 +1010,15 @@ function Hr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1009
1010
  j,
1010
1011
  t,
1011
1012
  se
1012
- ]), ve(() => {
1013
- if (!z || !L) {
1013
+ ]), W(() => {
1014
+ if (!ne || !L) {
1014
1015
  f(null), g(null);
1015
1016
  return;
1016
1017
  }
1017
1018
  let e = () => {
1018
1019
  let e = a.current;
1019
1020
  if (!e) return;
1020
- let n = ln(t, L.pos, ie), r = e.getBoundingClientRect(), i = un(n, r);
1021
+ let n = ln(t, L.pos, B), r = e.getBoundingClientRect(), i = un(n, r);
1021
1022
  if (!i) {
1022
1023
  f((e) => e?.pos === L.pos ? e : null), g((e) => _ ? e : null);
1023
1024
  return;
@@ -1037,13 +1038,13 @@ function Hr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1037
1038
  window.removeEventListener("resize", e), window.removeEventListener("scroll", e, !0);
1038
1039
  };
1039
1040
  }, [
1040
- z,
1041
+ ne,
1041
1042
  j,
1042
1043
  L?.pos,
1043
1044
  t,
1044
1045
  _,
1045
- ie
1046
- ]), !z && oe.length === 0 && !T) return null;
1046
+ B
1047
+ ]), !ne && oe.length === 0 && !T) return null;
1047
1048
  let le = d ? {
1048
1049
  top: d.top,
1049
1050
  right: d.right
@@ -1059,17 +1060,17 @@ function Hr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1059
1060
  S(mt(pt(t), e ? "copied" : "failed")), t.view.focus();
1060
1061
  }, de = (e, n) => {
1061
1062
  if (i) {
1062
- St(t, e.pos, n) && N((e) => e + 1);
1063
+ St(t, e.pos, n) && P((e) => e + 1);
1063
1064
  return;
1064
1065
  }
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());
1066
+ let a = F.active && F.pos === e.pos;
1067
+ vt(t, e.pos, n) && (r(n), P((e) => e + 1), a && t.view.focus());
1067
1068
  }, fe = (e) => {
1068
1069
  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());
1070
+ let n = F.active && F.pos === L.pos;
1071
+ _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
1072
  }, pe = () => {
1072
- i || !L || gt(t, L.pos, !ne) && (M((e) => e + 1), u(null));
1073
+ i || !L || gt(t, L.pos, !z) && (M((e) => e + 1), u(null));
1073
1074
  }, me = () => {
1074
1075
  if (!L) return;
1075
1076
  let e = gn(t, L.pos);
@@ -1101,15 +1102,15 @@ function Hr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1101
1102
  lastX: 0,
1102
1103
  lastY: 0
1103
1104
  }, A(!1);
1104
- }, ye = (e) => {
1105
+ }, ve = (e) => {
1105
1106
  e.preventDefault(), _e(e.deltaY < 0 ? yn : -yn);
1106
- }, be = (e) => {
1107
+ }, ye = (e) => {
1107
1108
  e.button === 0 && (e.preventDefault(), c.current = {
1108
1109
  active: !0,
1109
1110
  lastX: e.clientX,
1110
1111
  lastY: e.clientY
1111
1112
  }, A(!0));
1112
- }, xe = (e) => {
1113
+ }, be = (e) => {
1113
1114
  let t = c.current;
1114
1115
  if (!t.active) return;
1115
1116
  let n = e.clientX - t.lastX, r = e.clientY - t.lastY;
@@ -1118,7 +1119,7 @@ function Hr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1118
1119
  lastX: e.clientX,
1119
1120
  lastY: e.clientY
1120
1121
  }, E((e) => bn(e, n, r));
1121
- }, q = () => {
1122
+ }, xe = () => {
1122
1123
  c.current = {
1123
1124
  active: !1,
1124
1125
  lastX: 0,
@@ -1152,11 +1153,11 @@ function Hr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1152
1153
  }, t))
1153
1154
  }, e.pos);
1154
1155
  }),
1155
- z ? /* @__PURE__ */ Q("div", {
1156
+ ne ? /* @__PURE__ */ Q("div", {
1156
1157
  className: "markweave-codeblock-controls",
1157
1158
  "data-testid": "markweave-codeblock-controls",
1158
1159
  "data-positioned": d ? "true" : "false",
1159
- "data-collapsed": ne ? "true" : "false",
1160
+ "data-collapsed": z ? "true" : "false",
1160
1161
  "data-read-only": i ? "true" : "false",
1161
1162
  "aria-label": "Code block controls",
1162
1163
  style: le,
@@ -1165,7 +1166,7 @@ function Hr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1165
1166
  className: "markweave-codeblock-language-button markweave-codeblock-language-label",
1166
1167
  "aria-label": "Code block language",
1167
1168
  "data-testid": "markweave-codeblock-language",
1168
- children: /* @__PURE__ */ Z("span", { children: B })
1169
+ children: /* @__PURE__ */ Z("span", { children: ie })
1169
1170
  }) : /* @__PURE__ */ Q("button", {
1170
1171
  ref: o,
1171
1172
  type: "button",
@@ -1176,18 +1177,18 @@ function Hr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1176
1177
  "data-testid": "markweave-codeblock-language",
1177
1178
  onMouseDown: (e) => e.preventDefault(),
1178
1179
  onClick: () => v((e) => !e),
1179
- children: [/* @__PURE__ */ Z("span", { children: B }), /* @__PURE__ */ Z(Vr, { icon: "chevron" })]
1180
+ children: [/* @__PURE__ */ Z("span", { children: ie }), /* @__PURE__ */ Z(Hr, { icon: "chevron" })]
1180
1181
  }),
1181
1182
  re ? /* @__PURE__ */ Z("button", {
1182
1183
  type: "button",
1183
1184
  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",
1185
+ "aria-label": z ? "Expand code block" : "Collapse code block",
1186
+ title: z ? "Expand code block" : "Collapse code block",
1186
1187
  "data-testid": "markweave-codeblock-collapse",
1187
- "data-collapsed": ne ? "true" : "false",
1188
+ "data-collapsed": z ? "true" : "false",
1188
1189
  onMouseDown: (e) => e.preventDefault(),
1189
1190
  onClick: pe,
1190
- children: /* @__PURE__ */ Z(Vr, { icon: "chevron" })
1191
+ children: /* @__PURE__ */ Z(Hr, { icon: "chevron" })
1191
1192
  }) : null,
1192
1193
  /* @__PURE__ */ Q("span", {
1193
1194
  className: "markweave-codeblock-copy-wrap",
@@ -1196,14 +1197,14 @@ function Hr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1196
1197
  className: "markweave-codeblock-icon-button",
1197
1198
  "aria-label": "Copy to clipboard",
1198
1199
  "data-testid": "markweave-codeblock-copy",
1199
- "data-copy-state": V,
1200
+ "data-copy-state": ae,
1200
1201
  onMouseDown: (e) => e.preventDefault(),
1201
1202
  onMouseEnter: () => w(!0),
1202
1203
  onMouseLeave: () => w(!1),
1203
1204
  onFocus: () => w(!0),
1204
1205
  onBlur: () => w(!1),
1205
1206
  onClick: ue,
1206
- children: /* @__PURE__ */ Z(Vr, { icon: V === "copied" ? "check" : "clipboard" })
1207
+ children: /* @__PURE__ */ Z(Hr, { icon: ae === "copied" ? "check" : "clipboard" })
1207
1208
  }), C ? /* @__PURE__ */ Z("span", {
1208
1209
  className: "markweave-codeblock-tooltip",
1209
1210
  role: "tooltip",
@@ -1211,7 +1212,7 @@ function Hr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1211
1212
  children: "Copy to clipboard"
1212
1213
  }) : null]
1213
1214
  }),
1214
- te && ie === "preview" ? /* @__PURE__ */ Q("div", {
1215
+ R && B === "preview" ? /* @__PURE__ */ Q("div", {
1215
1216
  className: "markweave-mermaid-preview-actions",
1216
1217
  "data-testid": "markweave-mermaid-preview-actions",
1217
1218
  children: [/* @__PURE__ */ Z("button", {
@@ -1219,24 +1220,24 @@ function Hr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1219
1220
  className: "markweave-codeblock-icon-button",
1220
1221
  "aria-label": "Fullscreen Mermaid preview",
1221
1222
  "data-testid": "markweave-mermaid-fullscreen",
1222
- disabled: !ae,
1223
+ disabled: !V,
1223
1224
  onMouseDown: (e) => e.preventDefault(),
1224
1225
  onClick: he,
1225
- children: /* @__PURE__ */ Z(Vr, { icon: "expand" })
1226
+ children: /* @__PURE__ */ Z(Hr, { icon: "expand" })
1226
1227
  }), /* @__PURE__ */ Z("button", {
1227
1228
  type: "button",
1228
1229
  className: "markweave-codeblock-icon-button",
1229
1230
  "aria-label": "Download Mermaid SVG",
1230
1231
  "data-testid": "markweave-mermaid-download",
1231
- disabled: !ae,
1232
+ disabled: !V,
1232
1233
  onMouseDown: (e) => e.preventDefault(),
1233
1234
  onClick: me,
1234
- children: /* @__PURE__ */ Z(Vr, { icon: "download" })
1235
+ children: /* @__PURE__ */ Z(Hr, { icon: "download" })
1235
1236
  })]
1236
1237
  }) : null
1237
1238
  ]
1238
1239
  }) : null,
1239
- re && z && _ ? /* @__PURE__ */ Q("div", {
1240
+ re && ne && _ ? /* @__PURE__ */ Q("div", {
1240
1241
  className: "markweave-codeblock-language-menu",
1241
1242
  role: "listbox",
1242
1243
  "aria-label": "Code block languages",
@@ -1257,7 +1258,7 @@ function Hr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1257
1258
  onKeyDown: (e) => {
1258
1259
  e.key === "Escape" && (e.preventDefault(), v(!1), t.view.focus());
1259
1260
  }
1260
- }), /* @__PURE__ */ Z(Vr, { icon: "search" })]
1261
+ }), /* @__PURE__ */ Z(Hr, { icon: "search" })]
1261
1262
  }), /* @__PURE__ */ Z("div", {
1262
1263
  className: "markweave-codeblock-language-list",
1263
1264
  children: ce.map((e) => {
@@ -1270,7 +1271,7 @@ function Hr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1270
1271
  "data-active": t ? "true" : "false",
1271
1272
  onMouseDown: (e) => e.preventDefault(),
1272
1273
  onClick: () => fe(e.language),
1273
- children: [/* @__PURE__ */ Z("span", { children: e.label }), t ? /* @__PURE__ */ Z(Vr, { icon: "check" }) : null]
1274
+ children: [/* @__PURE__ */ Z("span", { children: e.label }), t ? /* @__PURE__ */ Z(Hr, { icon: "check" }) : null]
1274
1275
  }, e.language);
1275
1276
  })
1276
1277
  })]
@@ -1296,7 +1297,7 @@ function Hr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1296
1297
  onFocus: () => O("zoom-out"),
1297
1298
  onBlur: () => O(null),
1298
1299
  onClick: () => _e(-yn),
1299
- children: /* @__PURE__ */ Z(Vr, { icon: "zoomOut" })
1300
+ children: /* @__PURE__ */ Z(Hr, { icon: "zoomOut" })
1300
1301
  }),
1301
1302
  /* @__PURE__ */ Z("span", {
1302
1303
  className: "markweave-mermaid-fullscreen-zoom-label",
@@ -1313,7 +1314,7 @@ function Hr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1313
1314
  onFocus: () => O("zoom-in"),
1314
1315
  onBlur: () => O(null),
1315
1316
  onClick: () => _e(yn),
1316
- children: /* @__PURE__ */ Z(Vr, { icon: "zoomIn" })
1317
+ children: /* @__PURE__ */ Z(Hr, { icon: "zoomIn" })
1317
1318
  }),
1318
1319
  /* @__PURE__ */ Z("button", {
1319
1320
  type: "button",
@@ -1325,7 +1326,7 @@ function Hr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1325
1326
  onFocus: () => O("reset"),
1326
1327
  onBlur: () => O(null),
1327
1328
  onClick: H,
1328
- children: /* @__PURE__ */ Z(Vr, { icon: "reset" })
1329
+ children: /* @__PURE__ */ Z(Hr, { icon: "reset" })
1329
1330
  }),
1330
1331
  D ? /* @__PURE__ */ Z("span", {
1331
1332
  className: "markweave-mermaid-fullscreen-tooltip",
@@ -1341,17 +1342,17 @@ function Hr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1341
1342
  "aria-label": "Close fullscreen Mermaid preview",
1342
1343
  "data-testid": "markweave-mermaid-fullscreen-close",
1343
1344
  onClick: ge,
1344
- children: /* @__PURE__ */ Z(Vr, { icon: "close" })
1345
+ children: /* @__PURE__ */ Z(Hr, { icon: "close" })
1345
1346
  }),
1346
1347
  /* @__PURE__ */ Z("div", {
1347
1348
  className: "markweave-mermaid-fullscreen-viewport",
1348
1349
  "data-testid": "markweave-mermaid-fullscreen-viewport",
1349
1350
  "data-dragging": k ? "true" : "false",
1350
- onWheel: ye,
1351
- onMouseDown: be,
1352
- onMouseMove: xe,
1353
- onMouseUp: q,
1354
- onMouseLeave: q,
1351
+ onWheel: ve,
1352
+ onMouseDown: ye,
1353
+ onMouseMove: be,
1354
+ onMouseUp: xe,
1355
+ onMouseLeave: xe,
1355
1356
  children: /* @__PURE__ */ Z("div", {
1356
1357
  className: "markweave-mermaid-fullscreen-content",
1357
1358
  "data-testid": "markweave-mermaid-fullscreen-content",
@@ -1372,25 +1373,25 @@ function Hr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1372
1373
  }
1373
1374
  //#endregion
1374
1375
  //#region src/ui/floating-toolbar/FloatingToolbar.tsx
1375
- var Ur = n("zh");
1376
- function Wr() {
1376
+ var Wr = n("zh");
1377
+ function Gr() {
1377
1378
  return typeof performance > "u" ? Date.now() : performance.now();
1378
1379
  }
1379
- function Gr(e, t) {
1380
+ function Kr(e, t) {
1380
1381
  return {
1381
1382
  "--markweave-toolbar-motion-duration": `${e.motionDurationMs}ms`,
1382
1383
  "--markweave-toolbar-motion-easing": e.motionEasing,
1383
1384
  marginLeft: t === 0 ? void 0 : `${t}px`
1384
1385
  };
1385
1386
  }
1386
- function Kr(e, t) {
1387
+ function qr(e, t) {
1387
1388
  let n = e?.getBoundingClientRect().height ?? 0, r = t?.getBoundingClientRect().height ?? 0;
1388
1389
  return Math.max(n, r, 44);
1389
1390
  }
1390
- function qr(e) {
1391
+ function Jr(e) {
1391
1392
  if (e !== null) return { "--markweave-floating-toolbar-tooltip-left": `${e}px` };
1392
1393
  }
1393
- function Jr(e, t, n, r) {
1394
+ function Yr(e, t, n, r) {
1394
1395
  let i = {
1395
1396
  bottom: t + r,
1396
1397
  height: r,
@@ -1406,26 +1407,26 @@ function Jr(e, t, n, r) {
1406
1407
  toJSON: () => i
1407
1408
  };
1408
1409
  }
1409
- function Yr(e) {
1410
+ function Xr(e) {
1410
1411
  return e.width > 0 && e.height > 0;
1411
1412
  }
1412
- function Xr(e) {
1413
+ function Zr(e) {
1413
1414
  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);
1415
+ return Yr(t, n, r - t, i - n);
1415
1416
  }
1416
- function Zr(e, t) {
1417
+ function Qr(e, t) {
1417
1418
  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
1419
  return r(t.anchorNode) && r(t.focusNode);
1419
1420
  }
1420
- function Qr(e) {
1421
+ function $r(e) {
1421
1422
  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));
1423
+ let t = Array.from(e.getClientRects()).filter(Xr).map((e) => Yr(e.left, e.top, e.width, e.height));
1423
1424
  if (t.length > 0) return t;
1424
1425
  if (typeof e.getBoundingClientRect != "function") return null;
1425
1426
  let n = e.getBoundingClientRect();
1426
- return Yr(n) ? [Jr(n.left, n.top, n.width, n.height)] : null;
1427
+ return Xr(n) ? [Yr(n.left, n.top, n.width, n.height)] : null;
1427
1428
  }
1428
- function $r(e, t) {
1429
+ function ei(e, t) {
1429
1430
  if (t.rangeCount === 0) return null;
1430
1431
  let n = t.getRangeAt(0);
1431
1432
  try {
@@ -1438,8 +1439,8 @@ function $r(e, t) {
1438
1439
  return null;
1439
1440
  }
1440
1441
  }
1441
- function ei(e, t) {
1442
- let n = $r(e, t);
1442
+ function ti(e, t) {
1443
+ let n = ei(e, t);
1443
1444
  if (!n) return !1;
1444
1445
  let { selection: r } = e.state, i = {
1445
1446
  from: Math.min(r.from, r.to),
@@ -1447,51 +1448,51 @@ function ei(e, t) {
1447
1448
  };
1448
1449
  return n.from === i.from && n.to === i.to;
1449
1450
  }
1450
- function ti(e) {
1451
+ function ni(e) {
1451
1452
  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));
1453
+ return !t || t.rangeCount === 0 || t.isCollapsed || !Qr(e, t) || !ti(e, t) ? null : $r(t.getRangeAt(0));
1453
1454
  }
1454
- function ni(e) {
1455
+ function ri(e) {
1455
1456
  let { selection: t } = e.state;
1456
1457
  if (t.empty) return null;
1457
1458
  let n = Math.min(t.from, t.to), r = Math.max(t.from, t.to);
1458
1459
  try {
1459
1460
  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);
1461
+ return a.setStart(t.node, t.offset), a.setEnd(i.node, i.offset), $r(a);
1461
1462
  } catch {
1462
1463
  return null;
1463
1464
  }
1464
1465
  }
1465
- function ri(e) {
1466
+ function ii(e) {
1466
1467
  let { selection: t } = e.state;
1467
1468
  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);
1469
+ 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);
1470
+ return Xr(l) ? [l] : null;
1473
1471
  }
1474
1472
  function ai(e) {
1475
- let t = ii(e);
1476
- return t && t.length > 0 ? Xr(t) : null;
1473
+ return ni(e) ?? ri(e) ?? ii(e);
1477
1474
  }
1478
1475
  function oi(e) {
1476
+ let t = ai(e);
1477
+ return t && t.length > 0 ? Zr(t) : null;
1478
+ }
1479
+ function si(e) {
1479
1480
  return {
1480
- getBoundingClientRect: () => ai(e) ?? Jr(0, 0, 0, 0),
1481
- getClientRects: () => ii(e) ?? []
1481
+ getBoundingClientRect: () => oi(e) ?? Yr(0, 0, 0, 0),
1482
+ getClientRects: () => ai(e) ?? []
1482
1483
  };
1483
1484
  }
1484
- function si(e) {
1485
+ function ci(e) {
1485
1486
  return e === "block-type" || e === "link" || e === "color" || e === "more";
1486
1487
  }
1487
- function ci(e, t, n) {
1488
+ function li(e, t, n) {
1488
1489
  n?.(wn(e, t)), e.commands.focus();
1489
1490
  }
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(() => {
1491
+ function ui({ editor: e, messages: t = Wr, selectionSnapshot: n, onRewriteSelection: r }) {
1492
+ 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
1493
  let t = D.current, n = e.view.dom.closest(".markweave-editor-frame");
1493
1494
  if (!t || !(n instanceof HTMLElement)) return;
1494
- let r = t.getBoundingClientRect(), i = n.getBoundingClientRect(), a = Kr(t, O.current), s = E.current, c = nt({
1495
+ let r = t.getBoundingClientRect(), i = n.getBoundingClientRect(), a = qr(t, O.current), s = E.current, c = nt({
1495
1496
  toolbarRect: {
1496
1497
  left: r.left - s,
1497
1498
  top: r.top,
@@ -1524,13 +1525,13 @@ function li({ editor: e, messages: t = Ur, selectionSnapshot: n, onRewriteSelect
1524
1525
  e.view.dom,
1525
1526
  o.boundaryPadding,
1526
1527
  o.offset
1527
- ]), P = H(() => {
1528
+ ]), F = H(() => {
1528
1529
  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) => {
1530
+ }, []), ee = H(() => {
1531
+ P();
1532
+ }, [P]), I = H(() => si(e), [e]), L = H((e) => {
1532
1533
  k.current = e;
1533
- }, []), R = H(() => {
1534
+ }, []), te = H(() => {
1534
1535
  let t = D.current, n = k.current, r = e.view.dom.closest(".markweave-editor-frame");
1535
1536
  if (!f || !t || !n) return;
1536
1537
  let i = t.getBoundingClientRect(), a = n.getBoundingClientRect(), s = r?.getBoundingClientRect() ?? null, c = rt({
@@ -1549,18 +1550,18 @@ function li({ editor: e, messages: t = Ur, selectionSnapshot: n, onRewriteSelect
1549
1550
  e.view.dom,
1550
1551
  f,
1551
1552
  o.boundaryPadding
1552
- ]), te = W(() => ({
1553
+ ]), R = G(() => ({
1553
1554
  ...ot(o, { topBoundaryPadding: S }),
1554
- onShow: P,
1555
- onUpdate: F
1555
+ onShow: F,
1556
+ onUpdate: ee
1556
1557
  }), [
1557
- P,
1558
1558
  F,
1559
+ ee,
1559
1560
  o,
1560
1561
  S
1561
1562
  ]);
1562
1563
  U(() => {
1563
- let e = Wr();
1564
+ let e = Gr();
1564
1565
  s((t) => ut(t, a, e));
1565
1566
  }, [
1566
1567
  a.hiddenReason,
@@ -1575,8 +1576,8 @@ function li({ editor: e, messages: t = Ur, selectionSnapshot: n, onRewriteSelect
1575
1576
  a.visibility
1576
1577
  ]), U(() => {
1577
1578
  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()));
1579
+ let e = Math.max(0, o.motionStartedAtMs + o.motionDurationMs - Gr()), t = window.setTimeout(() => {
1580
+ s((e) => et(e, Gr()));
1580
1581
  }, e);
1581
1582
  return () => {
1582
1583
  window.clearTimeout(t);
@@ -1585,17 +1586,17 @@ function li({ editor: e, messages: t = Ur, selectionSnapshot: n, onRewriteSelect
1585
1586
  o.motionDurationMs,
1586
1587
  o.motionPhase,
1587
1588
  o.motionStartedAtMs
1588
- ]), ve(() => {
1589
+ ]), W(() => {
1589
1590
  if (o.visibility !== "visible") {
1590
1591
  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
1592
  return;
1592
1593
  }
1593
- let e = Sn(N);
1594
+ let e = Sn(P);
1594
1595
  return e.schedule(), window.addEventListener("resize", e.schedule), window.addEventListener("scroll", e.schedule, !0), () => {
1595
1596
  e.cancel(), window.removeEventListener("resize", e.schedule), window.removeEventListener("scroll", e.schedule, !0);
1596
1597
  };
1597
1598
  }, [
1598
- N,
1599
+ P,
1599
1600
  e.view.dom,
1600
1601
  f,
1601
1602
  n?.from,
@@ -1603,13 +1604,13 @@ function li({ editor: e, messages: t = Ur, selectionSnapshot: n, onRewriteSelect
1603
1604
  o.variant,
1604
1605
  o.visibility,
1605
1606
  j.length
1606
- ]), ve(() => {
1607
+ ]), W(() => {
1607
1608
  if (!f) return;
1608
- let e = Sn(R);
1609
+ let e = Sn(te);
1609
1610
  return e.schedule(), window.addEventListener("resize", e.schedule), window.addEventListener("scroll", e.schedule, !0), () => {
1610
1611
  e.cancel(), window.removeEventListener("resize", e.schedule), window.removeEventListener("scroll", e.schedule, !0);
1611
1612
  };
1612
- }, [f, R]), U(() => {
1613
+ }, [f, te]), U(() => {
1613
1614
  f === "more" && i.some((e) => e.id === c) || j.some((e) => e.id === c) || (l(null), d(null));
1614
1615
  }, [
1615
1616
  i,
@@ -1633,8 +1634,8 @@ function li({ editor: e, messages: t = Ur, selectionSnapshot: n, onRewriteSelect
1633
1634
  });
1634
1635
  return () => window.cancelAnimationFrame(e);
1635
1636
  }, [f]);
1636
- let ne = (t) => {
1637
- if (si(t.id)) {
1637
+ let z = (t) => {
1638
+ if (ci(t.id)) {
1638
1639
  let n = t.id;
1639
1640
  if (n === "link") {
1640
1641
  let t = Dn(e);
@@ -1647,23 +1648,23 @@ function li({ editor: e, messages: t = Ur, selectionSnapshot: n, onRewriteSelect
1647
1648
  return;
1648
1649
  }
1649
1650
  if (p(null), t.id === "improve") {
1650
- ci(e, "rewrite-selection", r);
1651
+ li(e, "rewrite-selection", r);
1651
1652
  return;
1652
1653
  }
1653
1654
  t.run(), e.commands.focus();
1654
- }, z = () => {
1655
+ }, ne = () => {
1655
1656
  p(null), e.commands.focus();
1656
1657
  }, re = () => {
1657
1658
  v && e.commands.setTextSelection(v);
1658
- }, B = () => {
1659
- re(), Cn(e, m) && z();
1660
- }, V = () => {
1659
+ }, ie = () => {
1660
+ re(), Cn(e, m) && ne();
1661
+ }, ae = () => {
1661
1662
  if (re(), Ln(e)) {
1662
- h(""), _(""), z();
1663
+ h(""), _(""), ne();
1663
1664
  return;
1664
1665
  }
1665
1666
  m.trim() && h("");
1666
- }, ie = (e, t) => {
1667
+ }, B = (e, t) => {
1667
1668
  if (l(e), !e || !t || !O.current) {
1668
1669
  d(null);
1669
1670
  return;
@@ -1676,55 +1677,55 @@ function li({ editor: e, messages: t = Ur, selectionSnapshot: n, onRewriteSelect
1676
1677
  editor: e,
1677
1678
  className: `markweave-floating-toolbar markweave-floating-toolbar--${o.variant} markweave-floating-toolbar--motion-${o.motionPhase}`,
1678
1679
  "data-motion": o.motionPhase,
1679
- "data-position-strategy": te.strategy,
1680
+ "data-position-strategy": R.strategy,
1680
1681
  "data-boundary-padding": o.boundaryPadding,
1681
1682
  "data-popover-placement": f ? w : void 0,
1682
1683
  "data-testid": "markweave-floating-toolbar",
1683
- style: Gr(o, b),
1684
+ style: Kr(o, b),
1684
1685
  updateDelay: 0,
1685
1686
  getReferencedVirtualElement: I,
1686
- options: te,
1687
+ options: R,
1687
1688
  shouldShow: ({ editor: e }) => e.isEditable && lt(at(e)),
1688
1689
  children: /* @__PURE__ */ Q("div", {
1689
1690
  ref: O,
1690
1691
  className: "markweave-floating-toolbar-content",
1691
1692
  "data-menu": f ?? "none",
1692
1693
  children: [
1693
- j.map((e, t) => /* @__PURE__ */ Z(di, {
1694
+ j.map((e, t) => /* @__PURE__ */ Z(fi, {
1694
1695
  button: e,
1695
1696
  expanded: f === e.id,
1696
1697
  showDivider: t > 0 && j[t - 1].group !== e.group,
1697
1698
  tooltipActive: c === e.id,
1698
1699
  onPointerDown: In,
1699
- onTooltipChange: ie,
1700
- onRun: ne
1700
+ onTooltipChange: B,
1701
+ onRun: z
1701
1702
  }, e.id)),
1702
- f === "block-type" ? /* @__PURE__ */ Z(pi, {
1703
+ f === "block-type" ? /* @__PURE__ */ Z(mi, {
1703
1704
  editor: e,
1704
1705
  messages: t,
1705
1706
  onPopoverRef: L,
1706
1707
  onClose: () => p(null)
1707
1708
  }) : null,
1708
- f === "link" ? /* @__PURE__ */ Z(ui, {
1709
+ f === "link" ? /* @__PURE__ */ Z(di, {
1709
1710
  inputRef: A,
1710
1711
  messages: t,
1711
1712
  value: m,
1712
- canApply: !!ee,
1713
- canOpen: !!ee,
1713
+ canApply: !!N,
1714
+ canOpen: !!N,
1714
1715
  canRemove: !!(g || m.trim()),
1715
1716
  onValueChange: h,
1716
- onApply: B,
1717
+ onApply: ie,
1717
1718
  onOpen: () => Fn(m),
1718
- onRemove: V,
1719
+ onRemove: ae,
1719
1720
  onPopoverRef: L
1720
1721
  }) : null,
1721
- f === "color" ? /* @__PURE__ */ Z(hi, {
1722
+ f === "color" ? /* @__PURE__ */ Z(gi, {
1722
1723
  editor: e,
1723
1724
  messages: t,
1724
1725
  onPopoverRef: L,
1725
1726
  onClose: () => p(null)
1726
1727
  }) : null,
1727
- f === "more" ? /* @__PURE__ */ Z(_i, {
1728
+ f === "more" ? /* @__PURE__ */ Z(vi, {
1728
1729
  editor: e,
1729
1730
  messages: t,
1730
1731
  activeTooltipId: c,
@@ -1738,14 +1739,14 @@ function li({ editor: e, messages: t = Ur, selectionSnapshot: n, onRewriteSelect
1738
1739
  "data-testid": "markweave-floating-toolbar-tooltip",
1739
1740
  "data-button-id": M.buttonId,
1740
1741
  "data-active": M.active,
1741
- style: qr(u),
1742
+ style: Jr(u),
1742
1743
  children: M.label
1743
1744
  }) : null
1744
1745
  ]
1745
1746
  })
1746
1747
  });
1747
1748
  }
1748
- function ui({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRemove: a, onValueChange: o, onApply: s, onOpen: c, onRemove: l, onPopoverRef: u }) {
1749
+ 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
1750
  let d = On(t);
1750
1751
  return /* @__PURE__ */ Q("form", {
1751
1752
  ref: u,
@@ -1798,7 +1799,7 @@ function ui({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRe
1798
1799
  })]
1799
1800
  });
1800
1801
  }
1801
- function di({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointerDown: i, onTooltipChange: a, onRun: o }) {
1802
+ function fi({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointerDown: i, onTooltipChange: a, onRun: o }) {
1802
1803
  return /* @__PURE__ */ Q(X, { children: [n ? /* @__PURE__ */ Z("span", {
1803
1804
  className: "markweave-floating-toolbar-divider",
1804
1805
  "aria-hidden": "true"
@@ -1806,7 +1807,7 @@ function di({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointe
1806
1807
  type: "button",
1807
1808
  className: `markweave-floating-toolbar-button markweave-floating-toolbar-button--${e.id}`,
1808
1809
  "aria-label": e.label,
1809
- "aria-expanded": si(e.id) ? t : void 0,
1810
+ "aria-expanded": ci(e.id) ? t : void 0,
1810
1811
  "data-active": e.active || t,
1811
1812
  "data-tooltip-active": r ? "true" : "false",
1812
1813
  "data-testid": `markweave-floating-toolbar-button-${e.id}`,
@@ -1816,13 +1817,13 @@ function di({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointe
1816
1817
  onMouseEnter: (t) => a(e.id, t.currentTarget),
1817
1818
  onMouseLeave: () => a(null),
1818
1819
  onClick: () => o(e),
1819
- children: /* @__PURE__ */ Z(fi, {
1820
+ children: /* @__PURE__ */ Z(pi, {
1820
1821
  button: e,
1821
1822
  expanded: t
1822
1823
  })
1823
1824
  })] });
1824
1825
  }
1825
- function fi({ button: e, expanded: t }) {
1826
+ function pi({ button: e, expanded: t }) {
1826
1827
  return e.id === "improve" ? /* @__PURE__ */ Q("span", {
1827
1828
  className: "markweave-floating-toolbar-button-inner",
1828
1829
  children: [/* @__PURE__ */ Z($, { name: "sparkles" }), /* @__PURE__ */ Z("span", { children: e.glyph })]
@@ -1840,7 +1841,7 @@ function fi({ button: e, expanded: t }) {
1840
1841
  }), /* @__PURE__ */ Z($, { name: t ? "chevron-up" : "chevron-down" })]
1841
1842
  }) : /* @__PURE__ */ Z($, { name: "more" });
1842
1843
  }
1843
- function pi({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
1844
+ function mi({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
1844
1845
  let i = On(t), a = Mn(t);
1845
1846
  return /* @__PURE__ */ Q("div", {
1846
1847
  ref: n,
@@ -1859,21 +1860,21 @@ function pi({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
1859
1860
  },
1860
1861
  children: [/* @__PURE__ */ Z("span", {
1861
1862
  className: "markweave-floating-toolbar-menu-icon",
1862
- children: /* @__PURE__ */ Z(mi, { option: t })
1863
+ children: /* @__PURE__ */ Z(hi, { option: t })
1863
1864
  }), /* @__PURE__ */ Z("span", { children: t.label })]
1864
1865
  }, t.id))]
1865
1866
  });
1866
1867
  }
1867
- function mi({ option: e }) {
1868
+ function hi({ option: e }) {
1868
1869
  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
1870
  }
1870
- function hi({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
1871
+ function gi({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
1871
1872
  let i = On(t), a = e.getAttributes("textStyle").color, o = e.getAttributes("highlight").color;
1872
1873
  return /* @__PURE__ */ Q("div", {
1873
1874
  ref: n,
1874
1875
  className: "markweave-floating-toolbar-popover markweave-floating-toolbar-color-popover",
1875
1876
  "data-testid": "markweave-floating-toolbar-color-menu",
1876
- children: [/* @__PURE__ */ Z(gi, {
1877
+ children: [/* @__PURE__ */ Z(_i, {
1877
1878
  title: i.textColorTitle,
1878
1879
  mode: "text",
1879
1880
  activeColor: a ?? null,
@@ -1881,7 +1882,7 @@ function hi({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
1881
1882
  onSelect: (t) => {
1882
1883
  Bn(e, t), r();
1883
1884
  }
1884
- }), /* @__PURE__ */ Z(gi, {
1885
+ }), /* @__PURE__ */ Z(_i, {
1885
1886
  title: i.highlightColorTitle,
1886
1887
  mode: "highlight",
1887
1888
  activeColor: o ?? null,
@@ -1892,7 +1893,7 @@ function hi({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
1892
1893
  })]
1893
1894
  });
1894
1895
  }
1895
- function gi({ title: e, mode: t, activeColor: n, options: r, onSelect: i }) {
1896
+ function _i({ title: e, mode: t, activeColor: n, options: r, onSelect: i }) {
1896
1897
  return /* @__PURE__ */ Q("section", {
1897
1898
  className: "markweave-floating-toolbar-color-section",
1898
1899
  "aria-label": e,
@@ -1921,13 +1922,13 @@ function gi({ title: e, mode: t, activeColor: n, options: r, onSelect: i }) {
1921
1922
  })]
1922
1923
  });
1923
1924
  }
1924
- function _i({ editor: e, messages: t, activeTooltipId: n, onPopoverRef: r, onTooltipChange: i, onClose: a }) {
1925
+ function vi({ editor: e, messages: t, activeTooltipId: n, onPopoverRef: r, onTooltipChange: i, onClose: a }) {
1925
1926
  let o = kn(t);
1926
1927
  return /* @__PURE__ */ Z("div", {
1927
1928
  ref: r,
1928
1929
  className: "markweave-floating-toolbar-popover markweave-floating-toolbar-more-menu",
1929
1930
  "data-testid": "markweave-floating-toolbar-more-menu",
1930
- children: o.map((t, r) => /* @__PURE__ */ Z(vi, {
1931
+ children: o.map((t, r) => /* @__PURE__ */ Z(yi, {
1931
1932
  action: t,
1932
1933
  active: Nn(e, t.id),
1933
1934
  tooltipActive: n === t.id,
@@ -1939,7 +1940,7 @@ function _i({ editor: e, messages: t, activeTooltipId: n, onPopoverRef: r, onToo
1939
1940
  }, t.id))
1940
1941
  });
1941
1942
  }
1942
- function vi({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipChange: i, onRun: a }) {
1943
+ function yi({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipChange: i, onRun: a }) {
1943
1944
  return /* @__PURE__ */ Q(X, { children: [r ? /* @__PURE__ */ Z("span", {
1944
1945
  className: "markweave-floating-toolbar-divider",
1945
1946
  "aria-hidden": "true"
@@ -1955,7 +1956,7 @@ function vi({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipC
1955
1956
  onMouseEnter: () => i(e.id),
1956
1957
  onMouseLeave: () => i(null),
1957
1958
  onClick: a,
1958
- children: /* @__PURE__ */ Z(yi, { id: e.id })
1959
+ children: /* @__PURE__ */ Z(bi, { id: e.id })
1959
1960
  }), n ? /* @__PURE__ */ Z("div", {
1960
1961
  className: "markweave-floating-toolbar-tooltip markweave-floating-toolbar-tooltip--more",
1961
1962
  role: "tooltip",
@@ -1963,41 +1964,41 @@ function vi({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipC
1963
1964
  }) : null]
1964
1965
  })] });
1965
1966
  }
1966
- function yi({ id: e }) {
1967
+ function bi({ id: e }) {
1967
1968
  return e === "superscript" ? /* @__PURE__ */ Z($, { name: "superscript" }) : e === "subscript" ? /* @__PURE__ */ Z($, { name: "subscript" }) : e === "inline-math" ? /* @__PURE__ */ Z($, { name: "math" }) : Z($, { name: e });
1968
1969
  }
1969
- var bi = {
1970
+ var xi = {
1970
1971
  sparkles: se,
1971
1972
  "chevron-down": v,
1972
1973
  "chevron-up": y,
1973
1974
  "corner-down-left": C,
1974
1975
  "external-link": T,
1975
1976
  bold: p,
1976
- italic: P,
1977
+ italic: F,
1977
1978
  underline: he,
1978
1979
  strike: ce,
1979
1980
  "inline-code": x,
1980
1981
  link: I,
1981
- more: z,
1982
+ more: ne,
1982
1983
  text: me,
1983
1984
  "bullet-list": L,
1984
- "numbered-list": te,
1985
- "todo-list": R,
1986
- quote: V,
1985
+ "numbered-list": R,
1986
+ "todo-list": te,
1987
+ quote: ae,
1987
1988
  "code-block": m,
1988
1989
  superscript: ue,
1989
1990
  subscript: le,
1990
- math: ae,
1991
+ math: V,
1991
1992
  "align-left": d,
1992
1993
  "align-center": l,
1993
1994
  "align-right": f,
1994
1995
  "align-justify": u,
1995
1996
  "decrease-indent": M,
1996
- "increase-indent": ee,
1997
+ "increase-indent": N,
1997
1998
  trash: pe
1998
1999
  };
1999
2000
  function $({ name: e }) {
2000
- let t = bi[e];
2001
+ let t = xi[e];
2001
2002
  return /* @__PURE__ */ Z(t, {
2002
2003
  "aria-hidden": "true",
2003
2004
  absoluteStrokeWidth: !0,
@@ -2007,8 +2008,8 @@ function $({ name: e }) {
2007
2008
  }
2008
2009
  //#endregion
2009
2010
  //#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 ? {
2011
+ function Si({ editor: e, messages: t, onClose: n, target: r }) {
2012
+ 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
2013
  html: f,
2013
2014
  error: !1
2014
2015
  } : Mt(o, r.kind, e), [
@@ -2192,31 +2193,31 @@ function xi({ editor: e, messages: t, onClose: n, target: r }) {
2192
2193
  }
2193
2194
  //#endregion
2194
2195
  //#region src/ui/slash-command/SlashCommandMenu.tsx
2195
- var Si = n("zh"), Ci = {
2196
+ var Ci = n("zh"), wi = {
2196
2197
  type: fe,
2197
2198
  "heading-1": D,
2198
2199
  "heading-2": O,
2199
2200
  "heading-3": k,
2200
2201
  "bullet-list": L,
2201
- "ordered-list": te,
2202
- "task-list": R,
2203
- blockquote: V,
2202
+ "ordered-list": R,
2203
+ "task-list": te,
2204
+ blockquote: ae,
2204
2205
  "code-block": m,
2205
- info: N,
2206
- tip: F,
2206
+ info: P,
2207
+ tip: ee,
2207
2208
  warning: c,
2208
2209
  error: b,
2209
2210
  success: _,
2210
2211
  emoji: oe,
2211
- math: ae,
2212
+ math: V,
2212
2213
  table: de,
2213
- separator: ne,
2214
+ separator: z,
2214
2215
  image: A,
2215
2216
  video: _e,
2216
2217
  attachment: re
2217
2218
  };
2218
- function wi({ name: e }) {
2219
- let t = Ci[e];
2219
+ function Ti({ name: e }) {
2220
+ let t = wi[e];
2220
2221
  return /* @__PURE__ */ Z(t, {
2221
2222
  "aria-hidden": "true",
2222
2223
  absoluteStrokeWidth: !0,
@@ -2224,7 +2225,7 @@ function wi({ name: e }) {
2224
2225
  strokeWidth: 1.6
2225
2226
  });
2226
2227
  }
2227
- function Ti(e, t, n) {
2228
+ function Ei(e, t, n) {
2228
2229
  return !zt(e) || !n ? {
2229
2230
  visible: !1,
2230
2231
  empty: !1,
@@ -2239,17 +2240,17 @@ function Ti(e, t, n) {
2239
2240
  activeIndex: Math.min(t.length - 1, Math.max(0, e.activeIndex))
2240
2241
  };
2241
2242
  }
2242
- function Ei(e, t) {
2243
+ function Di(e, t) {
2243
2244
  return Object.values(t.slash.groups).map((t) => ({
2244
2245
  group: t,
2245
2246
  commands: e.filter((e) => e.group === t)
2246
2247
  })).filter((e) => e.commands.length > 0);
2247
2248
  }
2248
- function Di(e, t) {
2249
+ function Oi(e, t) {
2249
2250
  return t.slash.uploadKindLabels[e] ?? t.slash.uploadKindLabels.upload;
2250
2251
  }
2251
- function Oi({ command: e, messages: t, onBack: n, onSelect: r }) {
2252
- let [i, a] = K(""), [o, s] = K(0), c = W(() => {
2252
+ function ki({ command: e, messages: t, onBack: n, onSelect: r }) {
2253
+ let [i, a] = q(""), [o, s] = q(0), c = G(() => {
2253
2254
  let e = i.trim().toLowerCase();
2254
2255
  return (e ? t.slash.emojiItems.filter((t) => [
2255
2256
  t.emoji,
@@ -2315,9 +2316,9 @@ function Oi({ command: e, messages: t, onBack: n, onSelect: r }) {
2315
2316
  ]
2316
2317
  });
2317
2318
  }
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({
2319
+ function Ai({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
2320
+ let a = e.uploadKind ?? "attachment", [o, s] = q(""), [c, l] = q(null), [u, d] = q(null), [f, p] = q(!1), m = async (t) => {
2321
+ r(e, { uploadResult: await xe({
2321
2322
  kind: a,
2322
2323
  source: t,
2323
2324
  trigger: "slash-command"
@@ -2337,7 +2338,7 @@ function ki({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
2337
2338
  d(t.slash.uploadRequiredError);
2338
2339
  return;
2339
2340
  }
2340
- await m(be(o));
2341
+ await m(ye(o));
2341
2342
  } catch (e) {
2342
2343
  d(e instanceof Error ? e.message : t.slash.uploadFailedError);
2343
2344
  } finally {
@@ -2355,7 +2356,7 @@ function ki({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
2355
2356
  onMouseDown: (e) => e.preventDefault(),
2356
2357
  onClick: n,
2357
2358
  children: t.common.back
2358
- }), /* @__PURE__ */ Z("span", { children: Di(a, t) })]
2359
+ }), /* @__PURE__ */ Z("span", { children: Oi(a, t) })]
2359
2360
  }),
2360
2361
  /* @__PURE__ */ Q("label", {
2361
2362
  className: "markweave-slash-upload-field",
@@ -2403,10 +2404,10 @@ function ki({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
2403
2404
  ]
2404
2405
  });
2405
2406
  }
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);
2407
+ function ji({ commands: e, messages: t = Ci, state: n, position: r, inputCommand: i, onActiveIndexChange: a, onInputCommandChange: o, onSelect: s, onUpload: c }) {
2408
+ let l = Ei(n, e, r);
2408
2409
  if (!l.visible || !r) return null;
2409
- let u = Ei(e, t), d = {
2410
+ let u = Di(e, t), d = {
2410
2411
  left: r.left,
2411
2412
  top: r.top,
2412
2413
  maxHeight: r.maxHeight,
@@ -2428,12 +2429,12 @@ function Ai({ commands: e, messages: t = Si, state: n, position: r, inputCommand
2428
2429
  "aria-label": t.slash.ariaLabel,
2429
2430
  "data-placement": r.placement,
2430
2431
  "data-testid": "markweave-slash-menu",
2431
- children: i?.inputKind === "emoji" ? /* @__PURE__ */ Z(Oi, {
2432
+ children: i?.inputKind === "emoji" ? /* @__PURE__ */ Z(ki, {
2432
2433
  command: i,
2433
2434
  messages: t,
2434
2435
  onBack: m,
2435
2436
  onSelect: s
2436
- }) : i?.inputKind === "upload" ? /* @__PURE__ */ Z(ki, {
2437
+ }) : i?.inputKind === "upload" ? /* @__PURE__ */ Z(Ai, {
2437
2438
  command: i,
2438
2439
  messages: t,
2439
2440
  onBack: m,
@@ -2477,7 +2478,7 @@ function Ai({ commands: e, messages: t = Si, state: n, position: r, inputCommand
2477
2478
  }
2478
2479
  },
2479
2480
  children: [
2480
- /* @__PURE__ */ Z(wi, { name: t.icon }),
2481
+ /* @__PURE__ */ Z(Ti, { name: t.icon }),
2481
2482
  /* @__PURE__ */ Z("span", { children: t.label }),
2482
2483
  o && t.disabledReason ? /* @__PURE__ */ Z("small", { children: t.disabledReason }) : null
2483
2484
  ]
@@ -2489,9 +2490,9 @@ function Ai({ commands: e, messages: t = Si, state: n, position: r, inputCommand
2489
2490
  }
2490
2491
  //#endregion
2491
2492
  //#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;
2493
+ var Mi = n("zh");
2494
+ function Ni({ active: e, editor: t, interactionState: n = Xt, messages: r = Mi, onCopyPayload: i, onCommandResult: a, onEditWithAi: o }) {
2495
+ 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
2496
  if (U(() => {
2496
2497
  if (!y) return;
2497
2498
  let e = window.setTimeout(() => {
@@ -2500,7 +2501,7 @@ function Mi({ active: e, editor: t, interactionState: n = Xt, messages: r = ji,
2500
2501
  return () => {
2501
2502
  window.clearTimeout(e);
2502
2503
  };
2503
- }, [y]), ve(() => {
2504
+ }, [y]), W(() => {
2504
2505
  if (!e) {
2505
2506
  m(null), g(null), v(null), b(null);
2506
2507
  return;
@@ -2540,7 +2541,7 @@ function Mi({ active: e, editor: t, interactionState: n = Xt, messages: r = ji,
2540
2541
  n.hoverVisualRowIndex,
2541
2542
  l,
2542
2543
  s
2543
- ]), ve(() => {
2544
+ ]), W(() => {
2544
2545
  if (!e || !s) {
2545
2546
  f(null);
2546
2547
  return;
@@ -2603,7 +2604,7 @@ function Mi({ active: e, editor: t, interactionState: n = Xt, messages: r = ji,
2603
2604
  i !== null && ar(t, i, e, { visualIndex: a }), D(e, r);
2604
2605
  }, A = () => {
2605
2606
  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) => {
2607
+ }, 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
2608
  let o = await qn({
2608
2609
  editor: t,
2609
2610
  commandId: e,
@@ -2611,7 +2612,7 @@ function Mi({ active: e, editor: t, interactionState: n = Xt, messages: r = ji,
2611
2612
  messages: r
2612
2613
  });
2613
2614
  return o.copyFeedback ? (b(o.copyFeedback), o.copyPayload && i?.(o.copyPayload)) : b(null), a?.(o.commandResult), o.success;
2614
- }, F = (e) => {
2615
+ }, ee = (e) => {
2615
2616
  let n = $n(t, e);
2616
2617
  n && o?.(n), c(null), t.view.focus();
2617
2618
  };
@@ -2685,7 +2686,7 @@ function Mi({ active: e, editor: t, interactionState: n = Xt, messages: r = ji,
2685
2686
  children: "..."
2686
2687
  })
2687
2688
  }) : null,
2688
- ee && _ ? /* @__PURE__ */ Z("button", {
2689
+ N && _ ? /* @__PURE__ */ Z("button", {
2689
2690
  type: "button",
2690
2691
  ref: T,
2691
2692
  className: "markweave-table-edge-handle markweave-table-edge-handle--selection",
@@ -2716,8 +2717,8 @@ function Mi({ active: e, editor: t, interactionState: n = Xt, messages: r = ji,
2716
2717
  left: d.left,
2717
2718
  top: d.top
2718
2719
  } : 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);
2720
+ children: P.map((e, n) => {
2721
+ 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
2722
  return /* @__PURE__ */ Z("button", {
2722
2723
  type: "button",
2723
2724
  role: "menuitem",
@@ -2732,10 +2733,10 @@ function Mi({ active: e, editor: t, interactionState: n = Xt, messages: r = ji,
2732
2733
  onClick: () => {
2733
2734
  if (u) {
2734
2735
  if (e.commandId === null) {
2735
- F(s === "row" || s === "column" ? s : "selection");
2736
+ ee(s === "row" || s === "column" ? s : "selection");
2736
2737
  return;
2737
2738
  }
2738
- P(e.commandId).finally(() => c(null));
2739
+ F(e.commandId).finally(() => c(null));
2739
2740
  }
2740
2741
  },
2741
2742
  children: d
@@ -2747,9 +2748,9 @@ function Mi({ active: e, editor: t, interactionState: n = Xt, messages: r = ji,
2747
2748
  }
2748
2749
  //#endregion
2749
2750
  //#region src/ui/table/TableSelectionOverlay.tsx
2750
- function Ni({ editor: e, focusState: t }) {
2751
- let [n, r] = K(null);
2752
- return ve(() => {
2751
+ function Pi({ editor: e, focusState: t }) {
2752
+ let [n, r] = q(null);
2753
+ return W(() => {
2753
2754
  if (t.mode !== "cell-selection") {
2754
2755
  r(null);
2755
2756
  return;
@@ -2790,11 +2791,11 @@ function Ni({ editor: e, focusState: t }) {
2790
2791
  }
2791
2792
  //#endregion
2792
2793
  //#region src/ui/toc/MarkweaveInnerToc.tsx
2793
- function Pi(e, t) {
2794
+ function Fi(e, t) {
2794
2795
  return `${e.toc.itemAriaLabel}: ${t.text}`;
2795
2796
  }
2796
- function Fi({ editor: e, state: t, messages: n, editable: r, placement: i }) {
2797
- let a = G(null);
2797
+ function Ii({ editor: e, state: t, messages: n, editable: r, placement: i }) {
2798
+ let a = K(null);
2798
2799
  if (U(() => {
2799
2800
  if (!(i !== "container" || !a.current)) return mr(a.current);
2800
2801
  }, [i]), !t.items.length) return null;
@@ -2826,7 +2827,7 @@ function Fi({ editor: e, state: t, messages: n, editable: r, placement: i }) {
2826
2827
  "data-level": e.level,
2827
2828
  "data-active": e.active ? "true" : "false",
2828
2829
  "aria-current": e.active ? "location" : void 0,
2829
- "aria-label": Pi(n, e),
2830
+ "aria-label": Fi(n, e),
2830
2831
  title: e.text,
2831
2832
  onClick: () => o(e),
2832
2833
  children: e.text
@@ -2837,7 +2838,7 @@ function Fi({ editor: e, state: t, messages: n, editable: r, placement: i }) {
2837
2838
  }
2838
2839
  //#endregion
2839
2840
  //#region src/MarkweaveEditor.tsx
2840
- var Ii = {
2841
+ var Li = {
2841
2842
  active: !1,
2842
2843
  mode: "outside",
2843
2844
  activeCellPos: null,
@@ -2845,21 +2846,21 @@ var Ii = {
2845
2846
  selectedCellCount: 0,
2846
2847
  selectionFrom: 0,
2847
2848
  selectionTo: 0
2848
- }, Li = {
2849
+ }, Ri = {
2849
2850
  active: !1,
2850
2851
  language: ht.defaultLanguage,
2851
2852
  mermaidPreviewMode: "code",
2852
2853
  pos: null,
2853
2854
  text: ""
2854
- }, Ri = Ct({
2855
+ }, zi = Ct({
2855
2856
  active: !1,
2856
2857
  mode: "code",
2857
2858
  source: ""
2858
2859
  });
2859
- function zi(e) {
2860
+ function Bi(e) {
2860
2861
  return Zt.getState(e.state) ?? Xt;
2861
2862
  }
2862
- function Bi(e) {
2863
+ function Vi(e) {
2863
2864
  if (!e || typeof window > "u") return null;
2864
2865
  let t = e.parentElement;
2865
2866
  for (; t;) {
@@ -2869,91 +2870,93 @@ function Bi(e) {
2869
2870
  }
2870
2871
  return null;
2871
2872
  }
2872
- function Vi(e) {
2873
+ function Hi(e) {
2873
2874
  return typeof window > "u" || typeof window.requestAnimationFrame != "function" ? globalThis.setTimeout(() => e(0), 0) : window.requestAnimationFrame(e);
2874
2875
  }
2875
- function Hi(e) {
2876
+ function Ui(e) {
2876
2877
  if (typeof window < "u" && typeof window.cancelAnimationFrame == "function") {
2877
2878
  window.cancelAnimationFrame(e);
2878
2879
  return;
2879
2880
  }
2880
2881
  globalThis.clearTimeout(e);
2881
2882
  }
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
2883
+ 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 } = {}) {
2884
+ 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({
2885
+ editorMode: k,
2886
+ effectiveEditable: N
2886
2887
  });
2887
- N.current = {
2888
- editorMode: O,
2889
- effectiveEditable: M
2888
+ F.current = {
2889
+ editorMode: k,
2890
+ effectiveEditable: N
2890
2891
  };
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,
2892
+ let ee = K(null);
2893
+ ee.current === null && (ee.current = r(m));
2894
+ let I = ee.current, L = G(() => n(I), [I]), te = G(() => t(I), [I]), R = K(C);
2895
+ R.current = C;
2896
+ let z = K(S);
2897
+ z.current = S;
2898
+ let ne = K(O);
2899
+ ne.current = O;
2900
+ let re = G(() => Br({
2901
+ lang: I,
2899
2902
  onImageUpload: (e) => {
2900
2903
  if (R.current) return R.current(e);
2901
- let t = xe(e);
2904
+ let t = be(e);
2902
2905
  if (!t) throw Error("File upload requires an upload handler.");
2903
2906
  return t;
2904
2907
  },
2905
2908
  onVideoUpload: (e) => {
2906
2909
  if (R.current) return R.current(e);
2907
- let t = xe(e);
2910
+ let t = be(e);
2908
2911
  if (!t) throw Error("File upload requires an upload handler.");
2909
2912
  return t;
2910
2913
  },
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({
2914
+ linkCardResolver: (e) => ne.current?.(e) ?? Promise.resolve(null)
2915
+ }), [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
2916
  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 = {
2917
+ format: P
2918
+ }), Se = K(null), Ce = K(null), we = K({ onUpdate: D }), Te = G(() => It(B.query, te), [te, B.query]);
2919
+ we.current = { onUpdate: D }, xe.current = {
2917
2920
  content: o,
2918
- format: ee
2921
+ format: P
2919
2922
  };
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);
2923
+ let Ee = H(() => {
2924
+ Ce.current !== null && (window.clearTimeout(Ce.current), Ce.current = null), ve((e) => e + 1);
2925
+ }, []), De = H(() => {
2926
+ Ce.current !== null && window.clearTimeout(Ce.current), Ce.current = window.setTimeout(() => {
2927
+ Ce.current = null, ve((e) => e + 1);
2925
2928
  }, ct);
2926
2929
  }, []);
2927
2930
  U(() => () => {
2928
- q.current !== null && window.clearTimeout(q.current);
2931
+ Ce.current !== null && window.clearTimeout(Ce.current);
2929
2932
  }, []);
2930
- let Ee = H(() => {
2931
- ae(null), se(null), V(Wt);
2932
- }, []), De = H((e) => {
2933
+ let Oe = H(() => {
2934
+ se(null), le(null), V(Wt);
2935
+ }, []), ke = H((e) => {
2933
2936
  let t = Ut(e.state);
2934
2937
  if (!t) {
2935
- V((e) => e.name === "idle" ? e : Wt), ae(null), se(null);
2938
+ V((e) => e.name === "idle" ? e : Wt), se(null), le(null);
2936
2939
  return;
2937
2940
  }
2938
2941
  let n = e.coordsAtPos(t.cursor), r = e.coordsAtPos(t.triggerFrom), i = e.dom.closest(".markweave-editor-frame")?.getBoundingClientRect();
2939
- ae(Ht(n, {
2942
+ se(Ht(n, {
2940
2943
  frameRect: i,
2941
2944
  triggerRect: r
2942
2945
  })), V((e) => Vt(e, t));
2943
- }, []), Oe = H((e) => De(e.view), [De]), ke = H((e) => {
2946
+ }, []), Ae = H((e) => ke(e.view), [ke]), je = H((e) => {
2944
2947
  let t = at(e);
2945
- re((e) => tt(e, t) ? e : t);
2948
+ ae((e) => tt(e, t) ? e : t);
2946
2949
  let n = jt(e);
2947
- n && (Nt(e, n, !0), de(n));
2950
+ n && (Nt(e, n, !0), pe(n));
2948
2951
  let r = pt(e);
2949
- r.active && r.language === "mermaid" && le(r.mermaidPreviewMode);
2950
- }, []), Ae = H((e) => {
2951
- pe(zi(e));
2952
+ r.active && r.language === "mermaid" && de(r.mermaidPreviewMode);
2953
+ }, []), Me = H((e) => {
2954
+ he(Bi(e));
2952
2955
  }, []), J = s({
2953
- extensions: ne,
2956
+ extensions: re,
2954
2957
  content: o ?? l,
2955
- contentType: Je(ee),
2956
- editable: M,
2958
+ contentType: Je(P),
2959
+ editable: N,
2957
2960
  autofocus: a,
2958
2961
  editorProps: {
2959
2962
  attributes: {
@@ -2964,36 +2967,36 @@ function Ui({ ariaLabel: e, autoFocusFirstTableBodyCell: i = !1, autofocus: a =
2964
2967
  spellcheck: "false",
2965
2968
  translate: "no"
2966
2969
  },
2967
- handleClick: (e, t, n) => N.current.effectiveEditable ? !1 : Qe(n),
2970
+ handleClick: (e, t, n) => F.current.effectiveEditable ? !1 : Qe(n),
2968
2971
  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),
2972
+ compositionstart: () => F.current.effectiveEditable ? (V((e) => Gt(e, { type: "composition-start" })), se(null), !1) : !1,
2973
+ compositionend: (e) => (F.current.effectiveEditable && window.setTimeout(() => ke(e), 0), !1),
2971
2974
  click: (e, t) => {
2972
- if (N.current.effectiveEditable) {
2975
+ if (F.current.effectiveEditable) {
2973
2976
  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);
2977
+ return n ? (t.preventDefault(), t.stopPropagation(), Oe(), Pt(e, n, !0), Ft(e, n), pe(n), !0) : (pe(null), !1);
2975
2978
  }
2976
2979
  return Qe(t);
2977
2980
  }
2978
2981
  }
2979
2982
  },
2980
2983
  onSelectionUpdate: ({ editor: e }) => {
2981
- ke(e);
2984
+ je(e);
2982
2985
  },
2983
2986
  onCreate: ({ editor: e }) => {
2984
- i && N.current.effectiveEditable && qt(e), Ae(e), ke(e), we();
2987
+ i && F.current.effectiveEditable && qt(e), Me(e), je(e), Ee();
2985
2988
  },
2986
2989
  onTransaction: ({ editor: e, transaction: t }) => {
2987
- Ae(e), (t.docChanged || yt(t)) && Te(), t.docChanged && de((t) => {
2990
+ Me(e), (t.docChanged || yt(t)) && De(), t.docChanged && pe((t) => {
2988
2991
  if (!t) return null;
2989
2992
  let n = kt(e, t.pos);
2990
2993
  return n?.kind === t.kind ? n : null;
2991
2994
  });
2992
2995
  },
2993
2996
  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 = {
2997
+ je(e), F.current.effectiveEditable && Ae(e), ye.current || we.current.onUpdate?.(qe(e, { onContentRead: (t, n) => {
2998
+ let r = xe.current;
2999
+ r.content !== void 0 && t === r.format && (Se.current = {
2997
3000
  content: n,
2998
3001
  format: t,
2999
3002
  doc: e.state.doc
@@ -3002,148 +3005,152 @@ function Ui({ ariaLabel: e, autoFocusFirstTableBodyCell: i = !1, autofocus: a =
3002
3005
  }
3003
3006
  });
3004
3007
  U(() => {
3005
- J && (J.setEditable(M), Re(J, {
3006
- mode: O,
3007
- editable: M
3008
- }), xt(J, M ? "live" : "view"), we(), M || Ee());
3008
+ if (J) return z.current?.(vr(J)), () => {
3009
+ z.current?.(null);
3010
+ };
3011
+ }, [J]), U(() => {
3012
+ J && (J.setEditable(N), Le(J, {
3013
+ mode: k,
3014
+ editable: N
3015
+ }), xt(J, N ? "live" : "view"), Ee(), N || Oe());
3009
3016
  }, [
3010
- Ee,
3017
+ Oe,
3011
3018
  J,
3012
- O,
3013
- M,
3014
- we
3019
+ k,
3020
+ N,
3021
+ Ee
3015
3022
  ]), U(() => {
3016
- J && bt(J, k);
3017
- }, [J, k]), U(() => {
3023
+ J && bt(J, A);
3024
+ }, [J, A]), U(() => {
3018
3025
  let e = Ze(c);
3019
3026
  if (!(!J || o === void 0)) {
3020
- if (Xe(J, be.current, o, e)) {
3021
- be.current = null;
3027
+ if (Xe(J, Se.current, o, e)) {
3028
+ Se.current = null;
3022
3029
  return;
3023
3030
  }
3024
- be.current = null, !Ye(J, o, e) && (ve.current = !0, J.commands.setContent(o, {
3031
+ Se.current = null, !Ye(J, o, e) && (ye.current = !0, J.commands.setContent(o, {
3025
3032
  contentType: Je(e),
3026
3033
  emitUpdate: !1
3027
- }), ve.current = !1, ke(J), M && Oe(J), Ae(J), we());
3034
+ }), ye.current = !1, je(J), N && Ae(J), Me(J), Ee());
3028
3035
  }
3029
3036
  }, [
3030
3037
  o,
3031
3038
  c,
3032
- M,
3039
+ N,
3033
3040
  J,
3034
- we,
3035
- ke,
3036
- Oe,
3037
- Ae
3041
+ Ee,
3042
+ je,
3043
+ Ae,
3044
+ Me
3038
3045
  ]), U(() => {
3039
- if (!ie) return;
3046
+ if (!oe) return;
3040
3047
  let e = (e) => {
3041
3048
  let t = e.target;
3042
- t instanceof Element && (t.closest(".markweave-slash-menu") || t.closest(".markweave-slash-trigger") || Ee());
3049
+ t instanceof Element && (t.closest(".markweave-slash-menu") || t.closest(".markweave-slash-trigger") || Oe());
3043
3050
  };
3044
3051
  return document.addEventListener("pointerdown", e, !0), () => document.removeEventListener("pointerdown", e, !0);
3045
- }, [Ee, ie]);
3046
- let je = W(() => J ? pt(J) : Li, [
3052
+ }, [Oe, oe]);
3053
+ let Ne = G(() => J ? pt(J) : Ri, [
3047
3054
  J,
3048
- ge,
3049
- z
3050
- ]), Me = W(() => J ? Jt(J.state) : Ii, [
3055
+ W,
3056
+ ie
3057
+ ]), Y = G(() => J ? Jt(J.state) : Li, [
3051
3058
  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,
3059
+ W,
3060
+ ie,
3061
+ me
3062
+ ]), Pe = ie?.currentNode === "codeBlock", Fe = Pe && Ne.language === "mermaid", Re = G(() => J ? Ct({
3063
+ active: Fe,
3064
+ mode: ue,
3065
+ source: Ne.text
3066
+ }) : zi, [
3067
+ Ne.text,
3061
3068
  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);
3069
+ Fe,
3070
+ ue
3071
+ ]), 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(() => {
3072
+ if (!J || !X.length) {
3073
+ _e(null);
3067
3074
  return;
3068
3075
  }
3069
- let e = ur(J, Y);
3070
- he((t) => t === e ? t : e);
3071
- }, [J, Y]);
3076
+ let e = ur(J, X);
3077
+ _e((t) => t === e ? t : e);
3078
+ }, [J, X]);
3072
3079
  U(() => {
3073
- he((e) => {
3074
- let t = fr(Y, e);
3080
+ _e((e) => {
3081
+ let t = fr(X, e);
3075
3082
  return e === t ? e : t;
3076
3083
  });
3077
- }, [Y]), U(() => {
3078
- if (!J || !Y.length || typeof window > "u") return;
3084
+ }, [X]), U(() => {
3085
+ if (!J || !X.length || typeof window > "u") return;
3079
3086
  let e = null, t = () => {
3080
- e !== null && Hi(e), e = Vi(() => {
3081
- e = null, Z();
3087
+ e !== null && Ui(e), e = Hi(() => {
3088
+ e = null, Be();
3082
3089
  });
3083
- }, n = Bi(J.view.dom);
3090
+ }, n = Vi(J.view.dom);
3084
3091
  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);
3092
+ window.removeEventListener("scroll", t), window.removeEventListener("resize", t), n?.removeEventListener("scroll", t), e !== null && Ui(e);
3086
3093
  };
3087
3094
  }, [
3088
3095
  J,
3089
- Y.length,
3090
- Z
3096
+ X.length,
3097
+ Be
3091
3098
  ]);
3092
- let Q = W(() => $e({
3093
- revision: ge,
3094
- mode: O,
3095
- editable: M,
3096
- toc: X,
3097
- selection: z,
3099
+ let Ve = G(() => $e({
3100
+ revision: W,
3101
+ mode: k,
3102
+ editable: N,
3103
+ toc: Q,
3104
+ selection: ie,
3098
3105
  slash: B,
3099
- table: Me,
3100
- tableInteraction: fe,
3101
- codeBlock: je,
3102
- mermaid: Fe,
3103
- tableDebugSnapshot: Ie
3106
+ table: Y,
3107
+ tableInteraction: me,
3108
+ codeBlock: Ne,
3109
+ mermaid: Re,
3110
+ tableDebugSnapshot: ze
3104
3111
  }), [
3105
- je,
3106
- O,
3107
- M,
3108
- Fe,
3109
- ge,
3110
- z,
3112
+ Ne,
3113
+ k,
3114
+ N,
3115
+ Re,
3116
+ W,
3117
+ ie,
3111
3118
  B,
3112
- Ie,
3113
- Me,
3114
- fe,
3115
- X
3119
+ ze,
3120
+ Y,
3121
+ me,
3122
+ Q
3116
3123
  ]);
3117
3124
  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)) {
3125
+ x?.(Ve);
3126
+ }, [x, Ve]), U(() => {
3127
+ E?.(Q);
3128
+ }, [E, Q]);
3129
+ let He = H((e, t) => {
3130
+ if (!(!J || !N) && Lt(e)) {
3124
3131
  if (e.inputKind && !t?.emoji && !t?.uploadResult) {
3125
- se(e);
3132
+ le(e);
3126
3133
  return;
3127
3134
  }
3128
- Bt(J, B, e, t), V((e) => Gt(e, { type: "execute" })), Ee();
3135
+ Bt(J, B, e, t), V((e) => Gt(e, { type: "execute" })), Oe();
3129
3136
  }
3130
3137
  }, [
3131
- Ee,
3132
- M,
3138
+ Oe,
3139
+ N,
3133
3140
  J,
3134
3141
  B
3135
- ]), Ve = H((e) => {
3142
+ ]), Ue = H((e) => {
3136
3143
  V((t) => Gt(t, {
3137
3144
  type: "set-active",
3138
3145
  index: e,
3139
- optionCount: Ce.length
3146
+ optionCount: Te.length
3140
3147
  }));
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) });
3148
+ }, [Te.length]), We = H((e) => {
3149
+ if (!J || ce || !N) return;
3150
+ let t = Rt(B, Te, e.key, { isComposing: e.nativeEvent.isComposing || Ke(J.state) });
3144
3151
  if (t.type !== "ignore") {
3145
3152
  if (t.type === "close") {
3146
- e.preventDefault(), V((e) => Gt(e, { type: "escape" })), Ee();
3153
+ e.preventDefault(), V((e) => Gt(e, { type: "escape" })), Oe();
3147
3154
  return;
3148
3155
  }
3149
3156
  if (t.type === "move-active") {
@@ -3154,18 +3161,18 @@ function Ui({ ariaLabel: e, autoFocusFirstTableBodyCell: i = !1, autofocus: a =
3154
3161
  }));
3155
3162
  return;
3156
3163
  }
3157
- t.type === "execute-active" && (e.preventDefault(), Be(t.command));
3164
+ t.type === "execute-active" && (e.preventDefault(), He(t.command));
3158
3165
  }
3159
3166
  }, [
3160
- Ee,
3161
- M,
3167
+ Oe,
3168
+ N,
3162
3169
  J,
3163
- Ce,
3164
- Be,
3165
- oe,
3170
+ Te,
3171
+ He,
3172
+ ce,
3166
3173
  B
3167
- ]), Ue = W(() => ({
3168
- closeSlashMenu: Ee,
3174
+ ]), Ge = G(() => ({
3175
+ closeSlashMenu: Oe,
3169
3176
  focusFirstTableBodyCell: () => J ? qt(J) : !1,
3170
3177
  setContent: (e, t = {}) => {
3171
3178
  if (!J) return !1;
@@ -3173,142 +3180,142 @@ function Ui({ ariaLabel: e, autoFocusFirstTableBodyCell: i = !1, autofocus: a =
3173
3180
  return J.commands.setContent(e, {
3174
3181
  contentType: Je(n),
3175
3182
  emitUpdate: t.emitUpdate ?? !1
3176
- }), t.focusFirstTableBodyCell && qt(J), ke(J), M && Oe(J), Ae(J), we(), !0;
3183
+ }), t.focusFirstTableBodyCell && qt(J), je(J), N && Ae(J), Me(J), Ee(), !0;
3177
3184
  }
3178
3185
  }), [
3179
- Ee,
3180
- M,
3181
- J,
3182
- we,
3183
- ke,
3184
3186
  Oe,
3185
- Ae
3187
+ N,
3188
+ J,
3189
+ Ee,
3190
+ je,
3191
+ Ae,
3192
+ Me
3186
3193
  ]);
3187
3194
  return {
3188
3195
  editor: J,
3189
- frameProps: W(() => ({
3196
+ frameProps: G(() => ({
3190
3197
  className: "markweave-editor-frame",
3191
- "aria-label": e ?? I.common.editorAriaLabel,
3198
+ "aria-label": e ?? L.common.editorAriaLabel,
3192
3199
  "data-testid": "markweave-editor-frame",
3193
- "data-markweave-mode": O,
3194
- "data-markweave-theme": k,
3195
- style: A ? { "--markweave-canvas": A } : void 0,
3200
+ "data-markweave-mode": k,
3201
+ "data-markweave-theme": A,
3202
+ style: j ? { "--markweave-canvas": j } : void 0,
3196
3203
  "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
3204
+ "data-markweave-inner-toc-placement": M,
3205
+ "data-mermaid-mode": Re.mode,
3206
+ "data-table-focus-mode": Y.mode,
3207
+ onKeyDownCapture: We
3201
3208
  }), [
3202
3209
  e,
3203
- O,
3204
- He,
3210
+ k,
3211
+ We,
3205
3212
  f,
3206
- Fe.mode,
3207
- I.common.editorAriaLabel,
3208
- A,
3213
+ Re.mode,
3214
+ L.common.editorAriaLabel,
3209
3215
  j,
3210
- k,
3211
- Me.mode
3216
+ M,
3217
+ A,
3218
+ Y.mode
3212
3219
  ]),
3213
- overlayProps: W(() => ({
3214
- floatingToolbar: J && M ? {
3220
+ overlayProps: G(() => ({
3221
+ floatingToolbar: J && N ? {
3215
3222
  editor: J,
3216
- messages: I,
3217
- selectionSnapshot: z,
3223
+ messages: L,
3224
+ selectionSnapshot: ie,
3218
3225
  onRewriteSelection: b,
3219
3226
  onExtractToNote: y
3220
3227
  } : null,
3221
- slashCommandMenu: J && M ? {
3222
- commands: Ce,
3228
+ slashCommandMenu: J && N ? {
3229
+ commands: Te,
3223
3230
  state: B,
3224
- position: ie,
3225
- inputCommand: oe,
3226
- messages: I,
3227
- onActiveIndexChange: Ve,
3228
- onInputCommandChange: se,
3229
- onSelect: Be,
3230
- onUpload: S
3231
+ position: oe,
3232
+ inputCommand: ce,
3233
+ messages: L,
3234
+ onActiveIndexChange: Ue,
3235
+ onInputCommandChange: le,
3236
+ onSelect: He,
3237
+ onUpload: C
3231
3238
  } : null,
3232
- tableControls: J && M ? {
3239
+ tableControls: J && N ? {
3233
3240
  editor: J,
3234
- active: Me.active,
3235
- interactionState: fe,
3236
- messages: I,
3237
- onCopyPayload: w,
3238
- onCommandResult: C,
3241
+ active: Y.active,
3242
+ interactionState: me,
3243
+ messages: L,
3244
+ onCopyPayload: T,
3245
+ onCommandResult: w,
3239
3246
  onEditWithAi: v
3240
3247
  } : null,
3241
- tableSelectionOverlay: J && M ? {
3248
+ tableSelectionOverlay: J && N ? {
3242
3249
  editor: J,
3243
- focusState: Me
3250
+ focusState: Y
3244
3251
  } : null,
3245
3252
  codeBlockControls: J ? {
3246
3253
  editor: J,
3247
- active: M && Ne,
3248
- mermaidMode: ce,
3249
- onMermaidModeChange: le,
3250
- readOnly: !M
3254
+ active: N && Pe,
3255
+ mermaidMode: ue,
3256
+ onMermaidModeChange: de,
3257
+ readOnly: !N
3251
3258
  } : null,
3252
- innerToc: J && f && X.items.length ? {
3259
+ innerToc: J && f && Q.items.length ? {
3253
3260
  editor: J,
3254
- editable: M,
3255
- messages: I,
3256
- placement: j,
3257
- state: X
3261
+ editable: N,
3262
+ messages: L,
3263
+ placement: M,
3264
+ state: Q
3258
3265
  } : null,
3259
- mathEditorPopover: J && M && ue ? {
3266
+ mathEditorPopover: J && N && fe ? {
3260
3267
  editor: J,
3261
- messages: I,
3262
- target: ue,
3263
- onClose: () => de(null)
3268
+ messages: L,
3269
+ target: fe,
3270
+ onClose: () => pe(null)
3264
3271
  } : null
3265
3272
  }), [
3266
- M,
3273
+ N,
3267
3274
  J,
3268
- Ce,
3275
+ Te,
3269
3276
  f,
3270
- Ne,
3271
- ce,
3272
- I,
3277
+ Pe,
3273
3278
  ue,
3279
+ L,
3280
+ fe,
3274
3281
  v,
3275
3282
  y,
3276
3283
  b,
3277
- S,
3278
3284
  C,
3279
3285
  w,
3280
- Be,
3281
- z,
3282
- Ve,
3283
- oe,
3286
+ T,
3287
+ He,
3284
3288
  ie,
3289
+ Ue,
3290
+ ce,
3291
+ oe,
3285
3292
  B,
3286
- Me,
3287
- fe,
3288
- X
3293
+ Y,
3294
+ me,
3295
+ Q
3289
3296
  ]),
3290
- runtimeSnapshot: Q,
3291
- actions: Ue
3297
+ runtimeSnapshot: Ve,
3298
+ actions: Ge
3292
3299
  };
3293
3300
  }
3294
- function Wi({ className: e, ...t }) {
3295
- let n = Ui(t);
3301
+ function Gi({ className: e, ...t }) {
3302
+ let n = Wi(t);
3296
3303
  if (!n.editor) return null;
3297
3304
  let r = [n.frameProps.className, e].filter(Boolean).join(" ");
3298
3305
  return /* @__PURE__ */ Q("section", {
3299
3306
  ...n.frameProps,
3300
3307
  className: r,
3301
3308
  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,
3309
+ n.overlayProps.floatingToolbar ? /* @__PURE__ */ Z(ui, { ...n.overlayProps.floatingToolbar }) : null,
3310
+ n.overlayProps.slashCommandMenu ? /* @__PURE__ */ Z(ji, { ...n.overlayProps.slashCommandMenu }) : null,
3311
+ n.overlayProps.tableControls ? /* @__PURE__ */ Z(Ni, { ...n.overlayProps.tableControls }) : null,
3312
+ n.overlayProps.tableSelectionOverlay ? /* @__PURE__ */ Z(Pi, { ...n.overlayProps.tableSelectionOverlay }) : null,
3313
+ n.overlayProps.codeBlockControls ? /* @__PURE__ */ Z(Ur, { ...n.overlayProps.codeBlockControls }) : null,
3314
+ n.overlayProps.innerToc ? /* @__PURE__ */ Z(Ii, { ...n.overlayProps.innerToc }) : null,
3315
+ n.overlayProps.mathEditorPopover ? /* @__PURE__ */ Z(Si, { ...n.overlayProps.mathEditorPopover }) : null,
3309
3316
  /* @__PURE__ */ Z(i, { editor: n.editor })
3310
3317
  ]
3311
3318
  });
3312
3319
  }
3313
3320
  //#endregion
3314
- export { Wi as MarkweaveEditor, zr as createMarkweaveEditorExtensions, zr as createMarkweaveReactEditorExtensions, Ui as useMarkweaveEditorController };
3321
+ export { Gi as MarkweaveEditor, Br as createMarkweaveEditorExtensions, Br as createMarkweaveReactEditorExtensions, Wi as useMarkweaveEditorController };