@markweave/react 0.5.0 → 0.5.1

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
@@ -41,27 +41,27 @@ import { MarkweaveAskAiError as xr, acceptMarkweaveAskAiResult as Sr, calculateM
41
41
  import { normalizeMarkdownLinkHref as Rr } from "markweave/internal/plugins/markdown/markdown-input";
42
42
  import { setMarkweaveTableMenuAxisTarget as zr } from "markweave/internal/plugins/table/table-clipboard";
43
43
  import { applyTableAxisAlignment as Br, applyTableAxisBackgroundColor as Vr, applyTableAxisTextColor as Hr, calculateAnchoredTableMenuPosition as Ur, calculateAnchoredTableSubmenuPosition as Wr, calculateTableAxisHandleLayout as Gr, calculateTableExtendButtonLayout as Kr, canRunTableCommand as qr, executeTableMenuCommand as Jr, formatTableCopyFeedback as Yr, getActiveTableElement as Xr, getTableAxisDropIndexAtPoint as Zr, getTableAxisFormattingState as Qr, getTableAxisTargetRect as $r, getTableControlAxisSelectionModel as ei, getTableMenuBoundaryRect as ti, getTableMenuItemGroup as ni, getTableMenuItemLabel as ri, getTableMenuItems as ii, getTableSelectionTargetRect as ai, measureTableSelectionOverlay as oi, moveTargetedTableAxis as si, selectTableAxisFromCell as ci, tableColorOptions as li, tableCopyFeedbackTimeoutMs as ui, tableHorizontalAlignmentOptions as di, tableMenuLabel as fi, tableVerticalAlignmentOptions as pi, targetTableAxisFromCell as mi } from "markweave/internal/plugins/table/table-ui-model";
44
- import { createMarkweaveTocState as hi, emptyMarkweaveTocState as gi, getActiveMarkweaveTocId as _i, getMarkweaveInnerTocRailHeight as vi, getMarkweaveTocItemsFromState as yi, getValidMarkweaveTocActiveId as bi, normalizeMarkweaveInnerTocPlacement as xi, observeMarkweaveInnerTocContainerPosition as Si, scrollToMarkweaveTocItem as Ci } from "markweave/internal/core/toc-state";
45
- import { normalizeMarkweaveCanvasColor as wi, normalizeMarkweaveTheme as Ti } from "markweave/internal/core/theme";
46
- import { splitMarkweaveLargeMarkdown as Ei } from "markweave/internal/core/large-document";
47
- import { createMarkweaveSearchController as Di } from "markweave/internal/plugins/search/search-controller";
48
- import { createMarkweaveAiEditController as Oi } from "markweave/internal/plugins/ai-edit/ai-edit-controller";
44
+ import { createMarkweaveTocState as hi, emptyMarkweaveTocState as gi, getActiveMarkweaveTocId as _i, getMarkweaveInnerTocRailHeight as vi, getMarkweaveTocItemsFromState as yi, getValidMarkweaveTocActiveId as bi, normalizeMarkweaveInnerTocPlacement as xi, observeMarkweaveInnerTocContainerPosition as Si, observeMarkweaveInnerTocRailOverflow as Ci, scrollToMarkweaveTocItem as wi } from "markweave/internal/core/toc-state";
45
+ import { normalizeMarkweaveCanvasColor as Ti, normalizeMarkweaveTheme as Ei } from "markweave/internal/core/theme";
46
+ import { splitMarkweaveLargeMarkdown as Di } from "markweave/internal/core/large-document";
47
+ import { createMarkweaveSearchController as Oi } from "markweave/internal/plugins/search/search-controller";
48
+ import { createMarkweaveAiEditController as ki } from "markweave/internal/plugins/ai-edit/ai-edit-controller";
49
49
  //#region src/editor-mode-state.ts
50
- var ki = {
50
+ var Ai = {
51
51
  mode: "live",
52
52
  editable: !0
53
53
  };
54
- function Ai(e) {
55
- return Re((t) => at(e, t), () => tt(e), () => ki);
54
+ function ji(e) {
55
+ return Re((t) => at(e, t), () => tt(e), () => Ai);
56
56
  }
57
57
  //#endregion
58
58
  //#region src/media/image-node.tsx
59
- var ji = Ze;
60
- function Mi(e) {
59
+ var Mi = Ze;
60
+ function Ni(e) {
61
61
  return e instanceof Element && !!e.closest("[data-markweave-image-ui=\"true\"]");
62
62
  }
63
- function Ni(e) {
64
- 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 = nt(Ai(r)), p = et(o.attrs.src), m = ji(o.attrs.align), h = $e(o.attrs.width), g = et(o.attrs.caption), _ = J(null), v = zi(p, l.resolveMediaSource, _, s), y = v?.src ?? (l.resolveMediaSource ? null : p), b = J(null), [x, S] = Y(!1), [C, w] = Y(!1), [T, E] = Y(!1), [D, ee] = Y(""), [O, k] = Y(null), [A, j] = Y(!1), [M, te] = Y(!!g), [N, P] = Y(g ?? ""), ne = f && (!p || C), re = () => {
63
+ function Pi(e) {
64
+ 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 = nt(ji(r)), p = et(o.attrs.src), m = Mi(o.attrs.align), h = $e(o.attrs.width), g = et(o.attrs.caption), _ = J(null), v = Bi(p, l.resolveMediaSource, _, s), y = v?.src ?? (l.resolveMediaSource ? null : p), b = J(null), [x, S] = Y(!1), [C, w] = Y(!1), [T, E] = Y(!1), [D, ee] = Y(""), [O, k] = Y(null), [A, j] = Y(!1), [M, te] = Y(!!g), [N, P] = Y(g ?? ""), ne = f && (!p || C), re = () => {
65
65
  y && ot({
66
66
  src: y,
67
67
  alt: et(o.attrs.alt) ?? "",
@@ -147,9 +147,9 @@ function Ni(e) {
147
147
  onPointerEnter: () => S(!0),
148
148
  onPointerLeave: () => S(!1),
149
149
  onMouseDown: (e) => {
150
- f && !Mi(e.target) && F();
150
+ f && !Ni(e.target) && F();
151
151
  },
152
- children: ne ? /* @__PURE__ */ Z(Pi, {
152
+ children: ne ? /* @__PURE__ */ Z(Fi, {
153
153
  dragActive: T,
154
154
  error: O,
155
155
  inputValue: D,
@@ -163,7 +163,7 @@ function Ni(e) {
163
163
  onInputChange: ee,
164
164
  onSubmit: L
165
165
  }) : /* @__PURE__ */ Q(lt, { children: [
166
- f ? /* @__PURE__ */ Z(Fi, {
166
+ f ? /* @__PURE__ */ Z(Ii, {
167
167
  align: m,
168
168
  captionActive: M || !!g,
169
169
  messages: u,
@@ -219,12 +219,12 @@ function Ni(e) {
219
219
  children: d.preview
220
220
  })]
221
221
  }) : null,
222
- f ? /* @__PURE__ */ Z(Li, {
222
+ f ? /* @__PURE__ */ Z(Ri, {
223
223
  side: "left",
224
224
  messages: u,
225
225
  onPointerDown: se
226
226
  }) : null,
227
- f ? /* @__PURE__ */ Z(Li, {
227
+ f ? /* @__PURE__ */ Z(Ri, {
228
228
  side: "right",
229
229
  messages: u,
230
230
  onPointerDown: se
@@ -250,7 +250,7 @@ function Ni(e) {
250
250
  ] })
251
251
  });
252
252
  }
253
- function Pi({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitting: i, messages: a, onCancel: o, onDragActiveChange: s, onDrop: c, onFileChange: l, onInputChange: u, onSubmit: d }) {
253
+ function Fi({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitting: i, messages: a, onCancel: o, onDragActiveChange: s, onDrop: c, onFileChange: l, onInputChange: u, onSubmit: d }) {
254
254
  let f = a.image;
255
255
  return /* @__PURE__ */ Q("section", {
256
256
  className: "markweave-image-upload-placeholder",
@@ -332,7 +332,7 @@ function Pi({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
332
332
  ]
333
333
  });
334
334
  }
335
- function Fi({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i, onDelete: a, onDownload: o, onPreview: s, onReplace: c }) {
335
+ function Ii({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i, onDelete: a, onDownload: o, onPreview: s, onReplace: c }) {
336
336
  let u = n.image;
337
337
  return /* @__PURE__ */ Q("div", {
338
338
  className: "markweave-image-toolbar",
@@ -340,21 +340,21 @@ function Fi({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i,
340
340
  "data-markweave-image-ui": "true",
341
341
  "aria-label": u.toolsAriaLabel,
342
342
  children: [
343
- /* @__PURE__ */ Z(Ii, {
343
+ /* @__PURE__ */ Z(Li, {
344
344
  testId: "markweave-image-align-left",
345
345
  label: u.alignLeft,
346
346
  icon: d,
347
347
  active: e === "left",
348
348
  onClick: () => r("left")
349
349
  }),
350
- /* @__PURE__ */ Z(Ii, {
350
+ /* @__PURE__ */ Z(Li, {
351
351
  testId: "markweave-image-align-center",
352
352
  label: u.alignCenter,
353
353
  icon: l,
354
354
  active: e === "center",
355
355
  onClick: () => r("center")
356
356
  }),
357
- /* @__PURE__ */ Z(Ii, {
357
+ /* @__PURE__ */ Z(Li, {
358
358
  testId: "markweave-image-align-right",
359
359
  label: u.alignRight,
360
360
  icon: f,
@@ -365,26 +365,26 @@ function Fi({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i,
365
365
  className: "markweave-image-toolbar-divider",
366
366
  "aria-hidden": "true"
367
367
  }),
368
- /* @__PURE__ */ Z(Ii, {
368
+ /* @__PURE__ */ Z(Li, {
369
369
  testId: "markweave-image-caption",
370
370
  label: u.caption,
371
371
  icon: ee,
372
372
  active: t,
373
373
  onClick: i
374
374
  }),
375
- /* @__PURE__ */ Z(Ii, {
375
+ /* @__PURE__ */ Z(Li, {
376
376
  testId: "markweave-image-preview",
377
377
  label: u.preview,
378
378
  icon: I,
379
379
  onClick: s
380
380
  }),
381
- /* @__PURE__ */ Z(Ii, {
381
+ /* @__PURE__ */ Z(Li, {
382
382
  testId: "markweave-image-download",
383
383
  label: u.download,
384
384
  icon: re,
385
385
  onClick: o
386
386
  }),
387
- /* @__PURE__ */ Z(Ii, {
387
+ /* @__PURE__ */ Z(Li, {
388
388
  testId: "markweave-image-replace",
389
389
  label: u.replace,
390
390
  icon: _e,
@@ -394,7 +394,7 @@ function Fi({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i,
394
394
  className: "markweave-image-toolbar-divider",
395
395
  "aria-hidden": "true"
396
396
  }),
397
- /* @__PURE__ */ Z(Ii, {
397
+ /* @__PURE__ */ Z(Li, {
398
398
  testId: "markweave-image-delete",
399
399
  label: u.delete,
400
400
  icon: je,
@@ -403,7 +403,7 @@ function Fi({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i,
403
403
  ]
404
404
  });
405
405
  }
406
- function Ii({ active: e = !1, icon: t, label: n, onClick: r, testId: i }) {
406
+ function Li({ active: e = !1, icon: t, label: n, onClick: r, testId: i }) {
407
407
  return /* @__PURE__ */ Q("button", {
408
408
  type: "button",
409
409
  "aria-label": n,
@@ -422,7 +422,7 @@ function Ii({ active: e = !1, icon: t, label: n, onClick: r, testId: i }) {
422
422
  })]
423
423
  });
424
424
  }
425
- function Li({ messages: e, onPointerDown: t, side: n }) {
425
+ function Ri({ messages: e, onPointerDown: t, side: n }) {
426
426
  return /* @__PURE__ */ Z("button", {
427
427
  type: "button",
428
428
  className: "markweave-image-resize-handle",
@@ -433,7 +433,7 @@ function Li({ messages: e, onPointerDown: t, side: n }) {
433
433
  onPointerDown: (e) => t(n, e)
434
434
  });
435
435
  }
436
- var Ri = Ve.extend({
436
+ var zi = Ve.extend({
437
437
  addOptions() {
438
438
  return {
439
439
  ...this.parent?.(),
@@ -444,7 +444,7 @@ var Ri = Ve.extend({
444
444
  },
445
445
  addNodeView() {
446
446
  if (typeof document > "u") return null;
447
- let e = o(Ni, { stopEvent: ({ event: e }) => Mi(e.target) }), t = this.options.resolveMediaSource;
447
+ let e = o(Pi, { stopEvent: ({ event: e }) => Ni(e.target) }), t = this.options.resolveMediaSource;
448
448
  if (!t) return e;
449
449
  let r = st({
450
450
  messages: this.options.messages ?? n("zh"),
@@ -454,7 +454,7 @@ var Ri = Ve.extend({
454
454
  return (t) => et(t.node.attrs.src) ? r(t) : e(t);
455
455
  }
456
456
  });
457
- function zi(e, t, n, r) {
457
+ function Bi(e, t, n, r) {
458
458
  let [i, a] = Y(t ? "background" : "visible"), [o, s] = Y(() => !t && e ? { src: e } : null);
459
459
  return K(() => {
460
460
  s(!t && e ? { src: e } : null), a(t ? "background" : "visible");
@@ -500,16 +500,16 @@ function zi(e, t, n, r) {
500
500
  }
501
501
  //#endregion
502
502
  //#region src/media/video-node.tsx
503
- function Bi(e) {
503
+ function Vi(e) {
504
504
  return e instanceof Element && !!e.closest("[data-markweave-video-ui=\"true\"], iframe[data-markweave-video-embed], video[data-markweave-video]");
505
505
  }
506
- function Vi(e) {
507
- 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 = nt(Ai(r)), p = et(o.attrs.src), m = et(o.attrs.embedUrl), h = et(o.attrs.provider), g = m ? Qe(m, h) : null, _ = et(o.attrs.mimeType), v = et(o.attrs.title), y = J(null), [b, x] = Y(!1), [S, C] = Y(""), [w, T] = Y(null), [E, D] = Y(!1), ee = f && !p, O = () => {
506
+ function Hi(e) {
507
+ 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 = nt(ji(r)), p = et(o.attrs.src), m = et(o.attrs.embedUrl), h = et(o.attrs.provider), g = m ? Qe(m, h) : null, _ = et(o.attrs.mimeType), v = et(o.attrs.title), y = J(null), [b, x] = Y(!1), [S, C] = Y(""), [w, T] = Y(null), [E, D] = Y(!1), ee = f && !p, O = () => {
508
508
  if (!f) return;
509
509
  let e = i();
510
510
  typeof e == "number" && r.chain().focus().setNodeSelection(e).run();
511
511
  }, k = (e) => {
512
- f && (Bi(e.target) || (e.preventDefault(), O()));
512
+ f && (Vi(e.target) || (e.preventDefault(), O()));
513
513
  }, A = (e) => {
514
514
  f && (e.key === "Delete" || e.key === "Backspace") && s && (e.preventDefault(), t());
515
515
  }, j = async (e) => {
@@ -535,7 +535,7 @@ function Vi(e) {
535
535
  "data-testid": "markweave-video-node",
536
536
  "data-empty": "true",
537
537
  "data-selected": "false",
538
- children: /* @__PURE__ */ Z(Hi, {
538
+ children: /* @__PURE__ */ Z(Ui, {
539
539
  dragActive: b,
540
540
  error: w,
541
541
  fileInputRef: y,
@@ -616,7 +616,7 @@ function Vi(e) {
616
616
  })
617
617
  });
618
618
  }
619
- function Hi({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitting: i, messages: a, onCancel: o, onDragActiveChange: s, onDrop: c, onFileChange: l, onInputChange: u, onSubmit: d }) {
619
+ function Ui({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitting: i, messages: a, onCancel: o, onDragActiveChange: s, onDrop: c, onFileChange: l, onInputChange: u, onSubmit: d }) {
620
620
  let f = a.video;
621
621
  return /* @__PURE__ */ Q("section", {
622
622
  className: "markweave-video-upload-placeholder",
@@ -698,7 +698,7 @@ function Hi({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
698
698
  ]
699
699
  });
700
700
  }
701
- var Ui = He.extend({
701
+ var Wi = He.extend({
702
702
  addOptions() {
703
703
  return {
704
704
  ...this.parent?.(),
@@ -708,29 +708,29 @@ var Ui = He.extend({
708
708
  };
709
709
  },
710
710
  addNodeView() {
711
- return typeof document > "u" ? null : o(Vi, { stopEvent: ({ event: e }) => Bi(e.target) });
711
+ return typeof document > "u" ? null : o(Hi, { stopEvent: ({ event: e }) => Vi(e.target) });
712
712
  }
713
713
  });
714
714
  //#endregion
715
715
  //#region src/link-card-node.tsx
716
- function Wi(e) {
716
+ function Gi(e) {
717
717
  return e instanceof Element && !!e.closest("[data-markweave-link-card-ui=\"true\"]");
718
718
  }
719
- function Gi(e) {
719
+ function Ki(e) {
720
720
  return typeof navigator < "u" && navigator.clipboard?.writeText ? navigator.clipboard.writeText(e).catch(() => void 0) : Promise.resolve();
721
721
  }
722
- function Ki(e) {
722
+ function qi(e) {
723
723
  !e || typeof window > "u" || window.open(e, "_blank", "noopener,noreferrer");
724
724
  }
725
- function qi(e) {
725
+ function Ji(e) {
726
726
  try {
727
727
  return new URL(e).host;
728
728
  } catch {
729
729
  return e;
730
730
  }
731
731
  }
732
- function Ji(e) {
733
- 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 = nt(Ai(r)), f = dt(o.attrs), [p, m] = Y(!1), [h, g] = Y(!1), [_, v] = Y(!1), [y, b] = Y(f?.title ?? ""), [x, S] = Y(f?.href ?? ""), C = J(null);
732
+ function Yi(e) {
733
+ 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 = nt(ji(r)), f = dt(o.attrs), [p, m] = Y(!1), [h, g] = Y(!1), [_, v] = Y(!1), [y, b] = Y(f?.title ?? ""), [x, S] = Y(f?.href ?? ""), C = J(null);
734
734
  if (K(() => () => C.current?.abort(), []), K(() => {
735
735
  b(f?.title ?? ""), S(f?.href ?? ""), v(!1);
736
736
  }, [f?.href, f?.title]), !f) return null;
@@ -759,7 +759,7 @@ function Ji(e) {
759
759
  }, T = () => {
760
760
  let e = i();
761
761
  typeof e == "number" && pt(r, e);
762
- }, E = _ ? null : f.imageUrl, D = qi(f.href);
762
+ }, E = _ ? null : f.imageUrl, D = Ji(f.href);
763
763
  return /* @__PURE__ */ Q(a, {
764
764
  as: "article",
765
765
  className: "markweave-link-card",
@@ -770,10 +770,10 @@ function Ji(e) {
770
770
  onMouseEnter: () => m(!0),
771
771
  onMouseLeave: () => m(!1),
772
772
  onMouseDown: (e) => {
773
- Wi(e.target) || e.preventDefault();
773
+ Gi(e.target) || e.preventDefault();
774
774
  },
775
775
  onClick: (e) => {
776
- Wi(e.target) || (e.preventDefault(), Ki(f.href));
776
+ Gi(e.target) || (e.preventDefault(), qi(f.href));
777
777
  },
778
778
  children: [
779
779
  /* @__PURE__ */ Q("a", {
@@ -811,19 +811,19 @@ function Ji(e) {
811
811
  "data-markweave-link-card-ui": "true",
812
812
  "aria-label": u.toolsAriaLabel,
813
813
  children: [
814
- /* @__PURE__ */ Z(Yi, {
814
+ /* @__PURE__ */ Z(Xi, {
815
815
  label: u.convertToLink,
816
816
  icon: le,
817
817
  onClick: T,
818
818
  testId: "markweave-link-card-convert"
819
819
  }),
820
- /* @__PURE__ */ Z(Yi, {
820
+ /* @__PURE__ */ Z(Xi, {
821
821
  label: u.copyAddress,
822
822
  icon: P,
823
- onClick: () => void Gi(f.href),
823
+ onClick: () => void Ki(f.href),
824
824
  testId: "markweave-link-card-copy"
825
825
  }),
826
- /* @__PURE__ */ Z(Yi, {
826
+ /* @__PURE__ */ Z(Xi, {
827
827
  label: u.edit,
828
828
  icon: me,
829
829
  onClick: (e) => {
@@ -841,7 +841,7 @@ function Ji(e) {
841
841
  },
842
842
  testId: "markweave-link-card-edit"
843
843
  }),
844
- /* @__PURE__ */ Z(Yi, {
844
+ /* @__PURE__ */ Z(Xi, {
845
845
  label: u.delete,
846
846
  icon: je,
847
847
  onClick: t,
@@ -878,7 +878,7 @@ function Ji(e) {
878
878
  ]
879
879
  });
880
880
  }
881
- function Yi({ icon: e, label: t, onClick: n, testId: r }) {
881
+ function Xi({ icon: e, label: t, onClick: n, testId: r }) {
882
882
  return /* @__PURE__ */ Q("button", {
883
883
  type: "button",
884
884
  "aria-label": t,
@@ -895,7 +895,7 @@ function Yi({ icon: e, label: t, onClick: n, testId: r }) {
895
895
  })]
896
896
  });
897
897
  }
898
- var Xi = ht.extend({
898
+ var Zi = ht.extend({
899
899
  addOptions() {
900
900
  return {
901
901
  ...this.parent?.(),
@@ -904,23 +904,23 @@ var Xi = ht.extend({
904
904
  };
905
905
  },
906
906
  addNodeView() {
907
- return typeof document > "u" ? null : o(Ji, { stopEvent: ({ event: e }) => Wi(e.target) });
907
+ return typeof document > "u" ? null : o(Yi, { stopEvent: ({ event: e }) => Gi(e.target) });
908
908
  }
909
909
  });
910
910
  //#endregion
911
911
  //#region src/create-editor-extensions.ts
912
- function Zi(t = {}) {
912
+ function Qi(t = {}) {
913
913
  return e({
914
914
  lang: t.lang,
915
915
  onImageUpload: t.onImageUpload,
916
- linkCardExtension: Xi.configure({
916
+ linkCardExtension: Zi.configure({
917
917
  lang: t.lang,
918
918
  messages: n(t.lang),
919
919
  resolver: t.linkCardResolver
920
920
  }),
921
921
  mediaExtensions: ut({
922
- image: Ri,
923
- video: Ui,
922
+ image: zi,
923
+ video: Wi,
924
924
  lang: t.lang,
925
925
  onImageUpload: t.onImageUpload,
926
926
  onVideoUpload: t.onVideoUpload,
@@ -930,7 +930,7 @@ function Zi(t = {}) {
930
930
  }
931
931
  //#endregion
932
932
  //#region src/ui/codeblock/CodeBlockControls.tsx
933
- function Qi(e) {
933
+ function $i(e) {
934
934
  return e === "clipboard" ? /* @__PURE__ */ Q(lt, { 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(lt, { children: [/* @__PURE__ */ Z("circle", {
935
935
  cx: "10",
936
936
  cy: "10",
@@ -967,7 +967,7 @@ function Qi(e) {
967
967
  /* @__PURE__ */ Z("path", { d: "m14 14 4 4" })
968
968
  ] }) : e === "reset" ? /* @__PURE__ */ Q(lt, { 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" });
969
969
  }
970
- function $i({ icon: e }) {
970
+ function ea({ icon: e }) {
971
971
  return /* @__PURE__ */ Z("svg", {
972
972
  viewBox: "0 0 24 24",
973
973
  "aria-hidden": "true",
@@ -978,11 +978,11 @@ function $i({ icon: e }) {
978
978
  strokeLinecap: "round",
979
979
  strokeLinejoin: "round",
980
980
  strokeWidth: "1.8",
981
- children: Qi(e)
981
+ children: $i(e)
982
982
  })
983
983
  });
984
984
  }
985
- function ea({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, readOnly: i = !1 }) {
985
+ function ta({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, readOnly: i = !1 }) {
986
986
  let a = J(null), o = J(null), s = J(null), c = J(null), l = J(null), u = J(null), d = J({
987
987
  active: !1,
988
988
  lastX: 0,
@@ -1279,7 +1279,7 @@ function ea({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1279
1279
  "data-testid": "markweave-codeblock-language",
1280
1280
  onMouseDown: (e) => e.preventDefault(),
1281
1281
  onClick: he,
1282
- children: [/* @__PURE__ */ Z("span", { children: se }), /* @__PURE__ */ Z($i, { icon: "chevron" })]
1282
+ children: [/* @__PURE__ */ Z("span", { children: se }), /* @__PURE__ */ Z(ea, { icon: "chevron" })]
1283
1283
  }),
1284
1284
  oe ? /* @__PURE__ */ Z("button", {
1285
1285
  type: "button",
@@ -1290,7 +1290,7 @@ function ea({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1290
1290
  "data-collapsed": B ? "true" : "false",
1291
1291
  onMouseDown: (e) => e.preventDefault(),
1292
1292
  onClick: be,
1293
- children: /* @__PURE__ */ Z($i, { icon: "chevron" })
1293
+ children: /* @__PURE__ */ Z(ea, { icon: "chevron" })
1294
1294
  }) : null,
1295
1295
  /* @__PURE__ */ Q("span", {
1296
1296
  className: "markweave-codeblock-copy-wrap",
@@ -1306,7 +1306,7 @@ function ea({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1306
1306
  onFocus: () => O(!0),
1307
1307
  onBlur: () => O(!1),
1308
1308
  onClick: W,
1309
- children: /* @__PURE__ */ Z($i, { icon: ce === "copied" ? "check" : "clipboard" })
1309
+ children: /* @__PURE__ */ Z(ea, { icon: ce === "copied" ? "check" : "clipboard" })
1310
1310
  }), ee ? /* @__PURE__ */ Z("span", {
1311
1311
  className: "markweave-codeblock-tooltip",
1312
1312
  role: "tooltip",
@@ -1325,7 +1325,7 @@ function ea({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1325
1325
  disabled: !ue,
1326
1326
  onMouseDown: (e) => e.preventDefault(),
1327
1327
  onClick: Se,
1328
- children: /* @__PURE__ */ Z($i, { icon: "expand" })
1328
+ children: /* @__PURE__ */ Z(ea, { icon: "expand" })
1329
1329
  }), /* @__PURE__ */ Z("button", {
1330
1330
  type: "button",
1331
1331
  className: "markweave-codeblock-icon-button",
@@ -1334,7 +1334,7 @@ function ea({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1334
1334
  disabled: !ue,
1335
1335
  onMouseDown: (e) => e.preventDefault(),
1336
1336
  onClick: xe,
1337
- children: /* @__PURE__ */ Z($i, { icon: "download" })
1337
+ children: /* @__PURE__ */ Z(ea, { icon: "download" })
1338
1338
  })]
1339
1339
  }) : null
1340
1340
  ]
@@ -1363,7 +1363,7 @@ function ea({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1363
1363
  "data-testid": "markweave-codeblock-language-search",
1364
1364
  onChange: (e) => ge(e.target.value),
1365
1365
  onKeyDown: _e
1366
- }), /* @__PURE__ */ Z($i, { icon: "search" })]
1366
+ }), /* @__PURE__ */ Z(ea, { icon: "search" })]
1367
1367
  }), /* @__PURE__ */ Z("div", {
1368
1368
  ref: l,
1369
1369
  id: u.current ?? void 0,
@@ -1384,7 +1384,7 @@ function ea({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1384
1384
  onMouseDown: (e) => e.preventDefault(),
1385
1385
  onMouseEnter: () => T(t),
1386
1386
  onClick: () => me(e.language),
1387
- children: [/* @__PURE__ */ Z("span", { children: e.label }), n ? /* @__PURE__ */ Z($i, { icon: "check" }) : null]
1387
+ children: [/* @__PURE__ */ Z("span", { children: e.label }), n ? /* @__PURE__ */ Z(ea, { icon: "check" }) : null]
1388
1388
  }, e.language);
1389
1389
  })
1390
1390
  })]
@@ -1410,7 +1410,7 @@ function ea({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1410
1410
  onFocus: () => M("zoom-out"),
1411
1411
  onBlur: () => M(null),
1412
1412
  onClick: () => we(-Zn),
1413
- children: /* @__PURE__ */ Z($i, { icon: "zoomOut" })
1413
+ children: /* @__PURE__ */ Z(ea, { icon: "zoomOut" })
1414
1414
  }),
1415
1415
  /* @__PURE__ */ Z("span", {
1416
1416
  className: "markweave-mermaid-fullscreen-zoom-label",
@@ -1427,7 +1427,7 @@ function ea({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1427
1427
  onFocus: () => M("zoom-in"),
1428
1428
  onBlur: () => M(null),
1429
1429
  onClick: () => we(Zn),
1430
- children: /* @__PURE__ */ Z($i, { icon: "zoomIn" })
1430
+ children: /* @__PURE__ */ Z(ea, { icon: "zoomIn" })
1431
1431
  }),
1432
1432
  /* @__PURE__ */ Z("button", {
1433
1433
  type: "button",
@@ -1439,7 +1439,7 @@ function ea({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1439
1439
  onFocus: () => M("reset"),
1440
1440
  onBlur: () => M(null),
1441
1441
  onClick: Te,
1442
- children: /* @__PURE__ */ Z($i, { icon: "reset" })
1442
+ children: /* @__PURE__ */ Z(ea, { icon: "reset" })
1443
1443
  }),
1444
1444
  j ? /* @__PURE__ */ Z("span", {
1445
1445
  className: "markweave-mermaid-fullscreen-tooltip",
@@ -1455,7 +1455,7 @@ function ea({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1455
1455
  "aria-label": "Close fullscreen Mermaid preview",
1456
1456
  "data-testid": "markweave-mermaid-fullscreen-close",
1457
1457
  onClick: Ce,
1458
- children: /* @__PURE__ */ Z($i, { icon: "close" })
1458
+ children: /* @__PURE__ */ Z(ea, { icon: "close" })
1459
1459
  }),
1460
1460
  /* @__PURE__ */ Z("div", {
1461
1461
  className: "markweave-mermaid-fullscreen-viewport",
@@ -1486,25 +1486,25 @@ function ea({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1486
1486
  }
1487
1487
  //#endregion
1488
1488
  //#region src/ui/floating-toolbar/FloatingToolbar.tsx
1489
- var ta = n("zh");
1490
- function na() {
1489
+ var na = n("zh");
1490
+ function ra() {
1491
1491
  return typeof performance > "u" ? Date.now() : performance.now();
1492
1492
  }
1493
- function ra(e, t) {
1493
+ function ia(e, t) {
1494
1494
  return {
1495
1495
  "--markweave-toolbar-motion-duration": `${e.motionDurationMs}ms`,
1496
1496
  "--markweave-toolbar-motion-easing": e.motionEasing,
1497
1497
  marginLeft: t === 0 ? void 0 : `${t}px`
1498
1498
  };
1499
1499
  }
1500
- function ia(e, t) {
1500
+ function aa(e, t) {
1501
1501
  let n = e?.getBoundingClientRect().height ?? 0, r = t?.getBoundingClientRect().height ?? 0;
1502
1502
  return Math.max(n, r, 44);
1503
1503
  }
1504
- function aa(e) {
1504
+ function oa(e) {
1505
1505
  if (e !== null) return { "--markweave-floating-toolbar-tooltip-left": `${e}px` };
1506
1506
  }
1507
- function oa(e, t, n, r) {
1507
+ function sa(e, t, n, r) {
1508
1508
  let i = {
1509
1509
  bottom: t + r,
1510
1510
  height: r,
@@ -1520,26 +1520,26 @@ function oa(e, t, n, r) {
1520
1520
  toJSON: () => i
1521
1521
  };
1522
1522
  }
1523
- function sa(e) {
1523
+ function ca(e) {
1524
1524
  return e.width > 0 && e.height > 0;
1525
1525
  }
1526
- function ca(e) {
1526
+ function la(e) {
1527
1527
  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));
1528
- return oa(t, n, r - t, i - n);
1528
+ return sa(t, n, r - t, i - n);
1529
1529
  }
1530
- function la(e, t) {
1530
+ function ua(e, t) {
1531
1531
  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;
1532
1532
  return r(t.anchorNode) && r(t.focusNode);
1533
1533
  }
1534
- function ua(e) {
1534
+ function da(e) {
1535
1535
  if (typeof e.getClientRects != "function") return null;
1536
- let t = Array.from(e.getClientRects()).filter(sa).map((e) => oa(e.left, e.top, e.width, e.height));
1536
+ let t = Array.from(e.getClientRects()).filter(ca).map((e) => sa(e.left, e.top, e.width, e.height));
1537
1537
  if (t.length > 0) return t;
1538
1538
  if (typeof e.getBoundingClientRect != "function") return null;
1539
1539
  let n = e.getBoundingClientRect();
1540
- return sa(n) ? [oa(n.left, n.top, n.width, n.height)] : null;
1540
+ return ca(n) ? [sa(n.left, n.top, n.width, n.height)] : null;
1541
1541
  }
1542
- function da(e, t) {
1542
+ function fa(e, t) {
1543
1543
  if (t.rangeCount === 0) return null;
1544
1544
  let n = t.getRangeAt(0);
1545
1545
  try {
@@ -1552,8 +1552,8 @@ function da(e, t) {
1552
1552
  return null;
1553
1553
  }
1554
1554
  }
1555
- function fa(e, t) {
1556
- let n = da(e, t);
1555
+ function pa(e, t) {
1556
+ let n = fa(e, t);
1557
1557
  if (!n) return !1;
1558
1558
  let { selection: r } = e.state, i = {
1559
1559
  from: Math.min(r.from, r.to),
@@ -1561,48 +1561,48 @@ function fa(e, t) {
1561
1561
  };
1562
1562
  return n.from === i.from && n.to === i.to;
1563
1563
  }
1564
- function pa(e) {
1564
+ function ma(e) {
1565
1565
  let t = e.view.dom.ownerDocument.getSelection();
1566
- return !t || t.rangeCount === 0 || t.isCollapsed || !la(e, t) || !fa(e, t) ? null : ua(t.getRangeAt(0));
1566
+ return !t || t.rangeCount === 0 || t.isCollapsed || !ua(e, t) || !pa(e, t) ? null : da(t.getRangeAt(0));
1567
1567
  }
1568
- function ma(e) {
1568
+ function ha(e) {
1569
1569
  let { selection: t } = e.state;
1570
1570
  if (t.empty) return null;
1571
1571
  let n = Math.min(t.from, t.to), r = Math.max(t.from, t.to);
1572
1572
  try {
1573
1573
  let t = e.view.domAtPos(n), i = e.view.domAtPos(r), a = e.view.dom.ownerDocument.createRange();
1574
- return a.setStart(t.node, t.offset), a.setEnd(i.node, i.offset), ua(a);
1574
+ return a.setStart(t.node, t.offset), a.setEnd(i.node, i.offset), da(a);
1575
1575
  } catch {
1576
1576
  return null;
1577
1577
  }
1578
1578
  }
1579
- function ha(e) {
1579
+ function ga(e) {
1580
1580
  let { selection: t } = e.state;
1581
1581
  if (t.empty) return null;
1582
- 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 = oa(c, o, Math.max(i.right, a.right) - c, s - o);
1583
- return sa(l) ? [l] : null;
1584
- }
1585
- function ga(e) {
1586
- return pa(e) ?? ma(e) ?? ha(e);
1582
+ 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 = sa(c, o, Math.max(i.right, a.right) - c, s - o);
1583
+ return ca(l) ? [l] : null;
1587
1584
  }
1588
1585
  function _a(e) {
1589
- let t = ga(e);
1590
- return t && t.length > 0 ? ca(t) : null;
1586
+ return ma(e) ?? ha(e) ?? ga(e);
1591
1587
  }
1592
1588
  function va(e) {
1589
+ let t = _a(e);
1590
+ return t && t.length > 0 ? la(t) : null;
1591
+ }
1592
+ function ya(e) {
1593
1593
  return {
1594
- getBoundingClientRect: () => _a(e) ?? oa(0, 0, 0, 0),
1595
- getClientRects: () => ga(e) ?? []
1594
+ getBoundingClientRect: () => va(e) ?? sa(0, 0, 0, 0),
1595
+ getClientRects: () => _a(e) ?? []
1596
1596
  };
1597
1597
  }
1598
- function ya(e) {
1598
+ function ba(e) {
1599
1599
  return e === "ask-ai" || e === "block-type" || e === "link" || e === "color" || e === "more";
1600
1600
  }
1601
- function ba(e, t, n) {
1601
+ function xa(e, t, n) {
1602
1602
  n?.(rr(e, t)), e.commands.focus();
1603
1603
  }
1604
- var xa = "markweave-floating-toolbar";
1605
- function Sa({ editor: e, lang: t = "zh", messages: n = ta, selectionSnapshot: r, askAi: i, onRewriteSelection: a }) {
1604
+ var Sa = "markweave-floating-toolbar";
1605
+ function Ca({ editor: e, lang: t = "zh", messages: n = na, selectionSnapshot: r, askAi: i, onRewriteSelection: a }) {
1606
1606
  let o = q(() => cr(n), [n]), s = Nt(r, { editable: e.isEditable }), [c, l] = Y(s), [u, d] = Y(null), [f, p] = Y(null), [m, h] = Y(null), [g, _] = Y("input"), [v, y] = Y(""), [b, x] = Y(""), [S, C] = Y(""), [w, T] = Y(""), [E, D] = Y(""), [ee, O] = Y(""), [k, A] = Y(null), [j, M] = Y(0), [te, N] = Y(s.boundaryPadding), [P, ne] = Y("bottom"), re = J(0), F = J(null), I = J(null), ie = J(null), ae = J(null), L = J(null), R = J(null), z = J(null), B = J(null), V = J(null), oe = J(""), se = i?.enabled === !0 && typeof i.handler == "function", ce = ir(e, c.variant, n, { askAiEnabled: se }), le = ur(ce.find((e) => e.id === u) ?? null), ue = Rr(E), H = G(() => {
1607
1607
  V.current !== null && (window.cancelAnimationFrame(V.current), V.current = null);
1608
1608
  }, []), U = G((t = !0) => {
@@ -1610,7 +1610,7 @@ function Sa({ editor: e, lang: t = "zh", messages: n = ta, selectionSnapshot: r,
1610
1610
  }, [H, e]), de = G(() => {
1611
1611
  let t = F.current, n = e.view.dom.closest(".markweave-editor-frame");
1612
1612
  if (!t || !(n instanceof HTMLElement)) return;
1613
- let r = t.getBoundingClientRect(), i = n.getBoundingClientRect(), a = ia(t, I.current), o = re.current, s = Ot({
1613
+ let r = t.getBoundingClientRect(), i = n.getBoundingClientRect(), a = aa(t, I.current), o = re.current, s = Ot({
1614
1614
  toolbarRect: {
1615
1615
  left: r.left - o,
1616
1616
  top: r.top,
@@ -1650,13 +1650,13 @@ function Sa({ editor: e, lang: t = "zh", messages: n = ta, selectionSnapshot: r,
1650
1650
  }, [de]), pe = G(() => Ar(e)?.target.kind === "table" ? {
1651
1651
  getBoundingClientRect: () => {
1652
1652
  let t = jr(e);
1653
- return t ? oa(t.left, t.top, t.width, t.height) : oa(0, 0, 0, 0);
1653
+ return t ? sa(t.left, t.top, t.width, t.height) : sa(0, 0, 0, 0);
1654
1654
  },
1655
1655
  getClientRects: () => {
1656
1656
  let t = jr(e);
1657
- return t ? [oa(t.left, t.top, t.width, t.height)] : [];
1657
+ return t ? [sa(t.left, t.top, t.width, t.height)] : [];
1658
1658
  }
1659
- } : va(e), [e]), me = G((e) => {
1659
+ } : ya(e), [e]), me = G((e) => {
1660
1660
  ie.current = e, e?.classList.contains("markweave-ask-ai-popover") && (e.dataset.positioned = "false");
1661
1661
  }, []), he = G(() => {
1662
1662
  let t = F.current, n = ie.current, r = e.view.dom.closest(".markweave-editor-frame");
@@ -1712,7 +1712,7 @@ function Sa({ editor: e, lang: t = "zh", messages: n = ta, selectionSnapshot: r,
1712
1712
  te
1713
1713
  ]);
1714
1714
  K(() => {
1715
- let e = na();
1715
+ let e = ra();
1716
1716
  l((t) => It(t, s, e));
1717
1717
  }, [
1718
1718
  s.hiddenReason,
@@ -1727,8 +1727,8 @@ function Sa({ editor: e, lang: t = "zh", messages: n = ta, selectionSnapshot: r,
1727
1727
  s.visibility
1728
1728
  ]), K(() => {
1729
1729
  if (c.motionStartedAtMs === null || c.motionDurationMs <= 0) return;
1730
- let e = Math.max(0, c.motionStartedAtMs + c.motionDurationMs - na()), t = window.setTimeout(() => {
1731
- l((e) => Et(e, na()));
1730
+ let e = Math.max(0, c.motionStartedAtMs + c.motionDurationMs - ra()), t = window.setTimeout(() => {
1731
+ l((e) => Et(e, ra()));
1732
1732
  }, e);
1733
1733
  return () => {
1734
1734
  window.clearTimeout(t);
@@ -1822,10 +1822,10 @@ function Sa({ editor: e, lang: t = "zh", messages: n = ta, selectionSnapshot: r,
1822
1822
  });
1823
1823
  return () => window.cancelAnimationFrame(e);
1824
1824
  }, [m]), K(() => {
1825
- m !== "ask-ai" || e.isDestroyed || e.view.dispatch(e.state.tr.setMeta(xa, "show").setMeta("addToHistory", !1));
1825
+ m !== "ask-ai" || e.isDestroyed || e.view.dispatch(e.state.tr.setMeta(Sa, "show").setMeta("addToHistory", !1));
1826
1826
  }, [e, m]);
1827
1827
  let _e = (t) => {
1828
- if (ya(t.id)) {
1828
+ if (ba(t.id)) {
1829
1829
  let n = t.id;
1830
1830
  if (m === n) {
1831
1831
  n === "ask-ai" ? U(!0) : h(null);
@@ -1848,7 +1848,7 @@ function Sa({ editor: e, lang: t = "zh", messages: n = ta, selectionSnapshot: r,
1848
1848
  return;
1849
1849
  }
1850
1850
  if (h(null), t.id === "improve") {
1851
- ba(e, "rewrite-selection", a);
1851
+ xa(e, "rewrite-selection", a);
1852
1852
  return;
1853
1853
  }
1854
1854
  t.run(), e.commands.focus();
@@ -1925,7 +1925,7 @@ function Sa({ editor: e, lang: t = "zh", messages: n = ta, selectionSnapshot: r,
1925
1925
  return /* @__PURE__ */ Z(tr, {
1926
1926
  ref: F,
1927
1927
  editor: e,
1928
- pluginKey: xa,
1928
+ pluginKey: Sa,
1929
1929
  className: `markweave-floating-toolbar markweave-floating-toolbar--${c.variant} markweave-floating-toolbar--motion-${c.motionPhase}`,
1930
1930
  "data-motion": c.motionPhase,
1931
1931
  "data-position-strategy": ge.strategy,
@@ -1933,7 +1933,7 @@ function Sa({ editor: e, lang: t = "zh", messages: n = ta, selectionSnapshot: r,
1933
1933
  "data-popover-placement": m ? P : void 0,
1934
1934
  "data-ask-ai-session": m === "ask-ai" ? "open" : "closed",
1935
1935
  "data-testid": "markweave-floating-toolbar",
1936
- style: ra(c, j),
1936
+ style: ia(c, j),
1937
1937
  updateDelay: 0,
1938
1938
  getReferencedVirtualElement: pe,
1939
1939
  options: ge,
@@ -1950,7 +1950,7 @@ function Sa({ editor: e, lang: t = "zh", messages: n = ta, selectionSnapshot: r,
1950
1950
  className: "markweave-floating-toolbar-content",
1951
1951
  "data-menu": m ?? "none",
1952
1952
  children: [
1953
- ce.map((e, t) => /* @__PURE__ */ Z(Ta, {
1953
+ ce.map((e, t) => /* @__PURE__ */ Z(Ea, {
1954
1954
  button: e,
1955
1955
  expanded: m === e.id,
1956
1956
  showDivider: t > 0 && ce[t - 1].group !== e.group,
@@ -1959,13 +1959,13 @@ function Sa({ editor: e, lang: t = "zh", messages: n = ta, selectionSnapshot: r,
1959
1959
  onTooltipChange: we,
1960
1960
  onRun: _e
1961
1961
  }, e.id)),
1962
- m === "block-type" ? /* @__PURE__ */ Z(Da, {
1962
+ m === "block-type" ? /* @__PURE__ */ Z(Oa, {
1963
1963
  editor: e,
1964
1964
  messages: n,
1965
1965
  onPopoverRef: me,
1966
1966
  onClose: () => h(null)
1967
1967
  }) : null,
1968
- m === "ask-ai" ? /* @__PURE__ */ Z(wa, {
1968
+ m === "ask-ai" ? /* @__PURE__ */ Z(Ta, {
1969
1969
  inputRef: L,
1970
1970
  messages: n,
1971
1971
  phase: g,
@@ -1982,7 +1982,7 @@ function Sa({ editor: e, lang: t = "zh", messages: n = ta, selectionSnapshot: r,
1982
1982
  onDiscard: () => U(!0),
1983
1983
  onPopoverRef: me
1984
1984
  }) : null,
1985
- m === "link" ? /* @__PURE__ */ Z(Ca, {
1985
+ m === "link" ? /* @__PURE__ */ Z(wa, {
1986
1986
  inputRef: ae,
1987
1987
  messages: n,
1988
1988
  value: E,
@@ -1995,13 +1995,13 @@ function Sa({ editor: e, lang: t = "zh", messages: n = ta, selectionSnapshot: r,
1995
1995
  onRemove: Ce,
1996
1996
  onPopoverRef: me
1997
1997
  }) : null,
1998
- m === "color" ? /* @__PURE__ */ Z(ka, {
1998
+ m === "color" ? /* @__PURE__ */ Z(Aa, {
1999
1999
  editor: e,
2000
2000
  messages: n,
2001
2001
  onPopoverRef: me,
2002
2002
  onClose: () => h(null)
2003
2003
  }) : null,
2004
- m === "more" ? /* @__PURE__ */ Z(ja, {
2004
+ m === "more" ? /* @__PURE__ */ Z(Ma, {
2005
2005
  editor: e,
2006
2006
  messages: n,
2007
2007
  activeTooltipId: u,
@@ -2015,14 +2015,14 @@ function Sa({ editor: e, lang: t = "zh", messages: n = ta, selectionSnapshot: r,
2015
2015
  "data-testid": "markweave-floating-toolbar-tooltip",
2016
2016
  "data-button-id": le.buttonId,
2017
2017
  "data-active": le.active,
2018
- style: aa(f),
2018
+ style: oa(f),
2019
2019
  children: le.label
2020
2020
  }) : null
2021
2021
  ]
2022
2022
  })
2023
2023
  });
2024
2024
  }
2025
- function Ca({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRemove: a, onValueChange: o, onApply: s, onOpen: c, onRemove: l, onPopoverRef: u }) {
2025
+ function wa({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRemove: a, onValueChange: o, onApply: s, onOpen: c, onRemove: l, onPopoverRef: u }) {
2026
2026
  let d = sr(t);
2027
2027
  return /* @__PURE__ */ Q("form", {
2028
2028
  ref: u,
@@ -2075,7 +2075,7 @@ function Ca({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRe
2075
2075
  })]
2076
2076
  });
2077
2077
  }
2078
- function wa({ inputRef: e, messages: t, phase: n, prompt: r, hasStreamedContent: i, error: a, onPromptChange: o, onSubmit: s, onStop: c, onAccept: l, onRetry: u, onDiscard: d, onPopoverRef: f }) {
2078
+ function Ta({ inputRef: e, messages: t, phase: n, prompt: r, hasStreamedContent: i, error: a, onPromptChange: o, onSubmit: s, onStop: c, onAccept: l, onRetry: u, onDiscard: d, onPopoverRef: f }) {
2079
2079
  let p = n === "input" || n === "result" || n === "error";
2080
2080
  return /* @__PURE__ */ Q("section", {
2081
2081
  ref: f,
@@ -2185,7 +2185,7 @@ function wa({ inputRef: e, messages: t, phase: n, prompt: r, hasStreamedContent:
2185
2185
  ]
2186
2186
  });
2187
2187
  }
2188
- function Ta({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointerDown: i, onTooltipChange: a, onRun: o }) {
2188
+ function Ea({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointerDown: i, onTooltipChange: a, onRun: o }) {
2189
2189
  return /* @__PURE__ */ Q(lt, { children: [n ? /* @__PURE__ */ Z("span", {
2190
2190
  className: "markweave-floating-toolbar-divider",
2191
2191
  "aria-hidden": "true"
@@ -2193,7 +2193,7 @@ function Ta({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointe
2193
2193
  type: "button",
2194
2194
  className: `markweave-floating-toolbar-button markweave-floating-toolbar-button--${e.id}`,
2195
2195
  "aria-label": e.label,
2196
- "aria-expanded": ya(e.id) ? t : void 0,
2196
+ "aria-expanded": ba(e.id) ? t : void 0,
2197
2197
  "data-active": e.active || t,
2198
2198
  "data-tooltip-active": r ? "true" : "false",
2199
2199
  "data-testid": `markweave-floating-toolbar-button-${e.id}`,
@@ -2203,13 +2203,13 @@ function Ta({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointe
2203
2203
  onMouseEnter: (t) => a(e.id, t.currentTarget),
2204
2204
  onMouseLeave: () => a(null),
2205
2205
  onClick: () => o(e),
2206
- children: /* @__PURE__ */ Z(Ea, {
2206
+ children: /* @__PURE__ */ Z(Da, {
2207
2207
  button: e,
2208
2208
  expanded: t
2209
2209
  })
2210
2210
  })] });
2211
2211
  }
2212
- function Ea({ button: e, expanded: t }) {
2212
+ function Da({ button: e, expanded: t }) {
2213
2213
  return e.id === "improve" || e.id === "ask-ai" ? /* @__PURE__ */ Q("span", {
2214
2214
  className: "markweave-floating-toolbar-button-inner",
2215
2215
  children: [/* @__PURE__ */ Z($, { name: "sparkles" }), /* @__PURE__ */ Z("span", { children: e.glyph })]
@@ -2227,7 +2227,7 @@ function Ea({ button: e, expanded: t }) {
2227
2227
  }), /* @__PURE__ */ Z($, { name: t ? "chevron-up" : "chevron-down" })]
2228
2228
  }) : /* @__PURE__ */ Z($, { name: "more" });
2229
2229
  }
2230
- function Da({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
2230
+ function Oa({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
2231
2231
  let i = sr(t), a = dr(t);
2232
2232
  return /* @__PURE__ */ Q("div", {
2233
2233
  ref: n,
@@ -2246,21 +2246,21 @@ function Da({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
2246
2246
  },
2247
2247
  children: [/* @__PURE__ */ Z("span", {
2248
2248
  className: "markweave-floating-toolbar-menu-icon",
2249
- children: /* @__PURE__ */ Z(Oa, { option: t })
2249
+ children: /* @__PURE__ */ Z(ka, { option: t })
2250
2250
  }), /* @__PURE__ */ Z("span", { children: t.label })]
2251
2251
  }, t.id))]
2252
2252
  });
2253
2253
  }
2254
- function Oa({ option: e }) {
2254
+ function ka({ option: e }) {
2255
2255
  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 });
2256
2256
  }
2257
- function ka({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
2257
+ function Aa({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
2258
2258
  let i = sr(t), a = e.getAttributes("textStyle").color, o = e.getAttributes("highlight").color;
2259
2259
  return /* @__PURE__ */ Q("div", {
2260
2260
  ref: n,
2261
2261
  className: "markweave-floating-toolbar-popover markweave-floating-toolbar-color-popover",
2262
2262
  "data-testid": "markweave-floating-toolbar-color-menu",
2263
- children: [/* @__PURE__ */ Z(Aa, {
2263
+ children: [/* @__PURE__ */ Z(ja, {
2264
2264
  title: i.textColorTitle,
2265
2265
  mode: "text",
2266
2266
  activeColor: a ?? null,
@@ -2268,7 +2268,7 @@ function ka({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
2268
2268
  onSelect: (t) => {
2269
2269
  yr(e, t), r();
2270
2270
  }
2271
- }), /* @__PURE__ */ Z(Aa, {
2271
+ }), /* @__PURE__ */ Z(ja, {
2272
2272
  title: i.highlightColorTitle,
2273
2273
  mode: "highlight",
2274
2274
  activeColor: o ?? null,
@@ -2279,7 +2279,7 @@ function ka({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
2279
2279
  })]
2280
2280
  });
2281
2281
  }
2282
- function Aa({ title: e, mode: t, activeColor: n, options: r, onSelect: i }) {
2282
+ function ja({ title: e, mode: t, activeColor: n, options: r, onSelect: i }) {
2283
2283
  return /* @__PURE__ */ Q("section", {
2284
2284
  className: "markweave-floating-toolbar-color-section",
2285
2285
  "aria-label": e,
@@ -2308,13 +2308,13 @@ function Aa({ title: e, mode: t, activeColor: n, options: r, onSelect: i }) {
2308
2308
  })]
2309
2309
  });
2310
2310
  }
2311
- function ja({ editor: e, messages: t, activeTooltipId: n, onPopoverRef: r, onTooltipChange: i, onClose: a }) {
2311
+ function Ma({ editor: e, messages: t, activeTooltipId: n, onPopoverRef: r, onTooltipChange: i, onClose: a }) {
2312
2312
  let o = cr(t);
2313
2313
  return /* @__PURE__ */ Z("div", {
2314
2314
  ref: r,
2315
2315
  className: "markweave-floating-toolbar-popover markweave-floating-toolbar-more-menu",
2316
2316
  "data-testid": "markweave-floating-toolbar-more-menu",
2317
- children: o.map((t, r) => /* @__PURE__ */ Z(Ma, {
2317
+ children: o.map((t, r) => /* @__PURE__ */ Z(Na, {
2318
2318
  action: t,
2319
2319
  active: fr(e, t.id),
2320
2320
  tooltipActive: n === t.id,
@@ -2326,7 +2326,7 @@ function ja({ editor: e, messages: t, activeTooltipId: n, onPopoverRef: r, onToo
2326
2326
  }, t.id))
2327
2327
  });
2328
2328
  }
2329
- function Ma({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipChange: i, onRun: a }) {
2329
+ function Na({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipChange: i, onRun: a }) {
2330
2330
  return /* @__PURE__ */ Q(lt, { children: [r ? /* @__PURE__ */ Z("span", {
2331
2331
  className: "markweave-floating-toolbar-divider",
2332
2332
  "aria-hidden": "true"
@@ -2342,7 +2342,7 @@ function Ma({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipC
2342
2342
  onMouseEnter: () => i(e.id),
2343
2343
  onMouseLeave: () => i(null),
2344
2344
  onClick: a,
2345
- children: /* @__PURE__ */ Z(Na, { id: e.id })
2345
+ children: /* @__PURE__ */ Z(Pa, { id: e.id })
2346
2346
  }), n ? /* @__PURE__ */ Z("div", {
2347
2347
  className: "markweave-floating-toolbar-tooltip markweave-floating-toolbar-tooltip--more",
2348
2348
  role: "tooltip",
@@ -2350,10 +2350,10 @@ function Ma({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipC
2350
2350
  }) : null]
2351
2351
  })] });
2352
2352
  }
2353
- function Na({ id: e }) {
2353
+ function Pa({ id: e }) {
2354
2354
  return e === "superscript" ? /* @__PURE__ */ Z($, { name: "superscript" }) : e === "subscript" ? /* @__PURE__ */ Z($, { name: "subscript" }) : e === "inline-math" ? /* @__PURE__ */ Z($, { name: "math" }) : Z($, { name: e });
2355
2355
  }
2356
- var Pa = {
2356
+ var Fa = {
2357
2357
  sparkles: xe,
2358
2358
  "arrow-up": b,
2359
2359
  check: O,
@@ -2389,7 +2389,7 @@ var Pa = {
2389
2389
  x: Ie
2390
2390
  };
2391
2391
  function $({ name: e }) {
2392
- let t = Pa[e];
2392
+ let t = Fa[e];
2393
2393
  return /* @__PURE__ */ Z(t, {
2394
2394
  "aria-hidden": "true",
2395
2395
  absoluteStrokeWidth: !0,
@@ -2399,7 +2399,7 @@ function $({ name: e }) {
2399
2399
  }
2400
2400
  //#endregion
2401
2401
  //#region src/ui/math/MathEditorPopover.tsx
2402
- function Fa({ editor: e, messages: t, onClose: n, target: r }) {
2402
+ function Ia({ editor: e, messages: t, onClose: n, target: r }) {
2403
2403
  let i = J(null), a = J(null), [o, s] = Y(r.latex), [c, l] = Y(null), u = t.math, d = q(() => $t(e, r) ?? 1, [e, r]), f = q(() => en(e, r), [e, r]), p = q(() => o === r.latex && f ? {
2404
2404
  html: f,
2405
2405
  error: !1
@@ -2584,7 +2584,7 @@ function Fa({ editor: e, messages: t, onClose: n, target: r }) {
2584
2584
  }
2585
2585
  //#endregion
2586
2586
  //#region src/ui/slash-command/SlashCommandMenu.tsx
2587
- var Ia = n("zh"), La = {
2587
+ var La = n("zh"), Ra = {
2588
2588
  type: Ae,
2589
2589
  "heading-1": ie,
2590
2590
  "heading-2": ae,
@@ -2607,8 +2607,8 @@ var Ia = n("zh"), La = {
2607
2607
  video: Fe,
2608
2608
  attachment: pe
2609
2609
  };
2610
- function Ra({ name: e }) {
2611
- let t = La[e];
2610
+ function za({ name: e }) {
2611
+ let t = Ra[e];
2612
2612
  return /* @__PURE__ */ Z(t, {
2613
2613
  "aria-hidden": "true",
2614
2614
  absoluteStrokeWidth: !0,
@@ -2616,7 +2616,7 @@ function Ra({ name: e }) {
2616
2616
  strokeWidth: 1.6
2617
2617
  });
2618
2618
  }
2619
- function za(e, t, n) {
2619
+ function Ba(e, t, n) {
2620
2620
  return !fn(e) || !n ? {
2621
2621
  visible: !1,
2622
2622
  empty: !1,
@@ -2631,16 +2631,16 @@ function za(e, t, n) {
2631
2631
  activeIndex: Math.min(t.length - 1, Math.max(0, e.activeIndex))
2632
2632
  };
2633
2633
  }
2634
- function Ba(e, t) {
2634
+ function Va(e, t) {
2635
2635
  return Object.values(t.slash.groups).map((t) => ({
2636
2636
  group: t,
2637
2637
  commands: e.filter((e) => e.group === t)
2638
2638
  })).filter((e) => e.commands.length > 0);
2639
2639
  }
2640
- function Va(e, t) {
2640
+ function Ha(e, t) {
2641
2641
  return t.slash.uploadKindLabels[e] ?? t.slash.uploadKindLabels.upload;
2642
2642
  }
2643
- function Ha({ command: e, messages: t, onBack: n, onSelect: r }) {
2643
+ function Ua({ command: e, messages: t, onBack: n, onSelect: r }) {
2644
2644
  let [i, a] = Y(""), [o, s] = Y(0), c = q(() => {
2645
2645
  let e = i.trim().toLowerCase();
2646
2646
  return (e ? t.slash.emojiItems.filter((t) => [
@@ -2707,7 +2707,7 @@ function Ha({ command: e, messages: t, onBack: n, onSelect: r }) {
2707
2707
  ]
2708
2708
  });
2709
2709
  }
2710
- function Ua({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
2710
+ function Wa({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
2711
2711
  let a = e.uploadKind ?? "attachment", [o, s] = Y(""), [c, l] = Y(null), [u, d] = Y(null), [f, p] = Y(!1), m = async (t) => {
2712
2712
  r(e, { uploadResult: await X({
2713
2713
  kind: a,
@@ -2747,7 +2747,7 @@ function Ua({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
2747
2747
  onMouseDown: (e) => e.preventDefault(),
2748
2748
  onClick: n,
2749
2749
  children: t.common.back
2750
- }), /* @__PURE__ */ Z("span", { children: Va(a, t) })]
2750
+ }), /* @__PURE__ */ Z("span", { children: Ha(a, t) })]
2751
2751
  }),
2752
2752
  /* @__PURE__ */ Q("label", {
2753
2753
  className: "markweave-slash-upload-field",
@@ -2795,10 +2795,10 @@ function Ua({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
2795
2795
  ]
2796
2796
  });
2797
2797
  }
2798
- function Wa({ commands: e, messages: t = Ia, state: n, position: r, inputCommand: i, onActiveIndexChange: a, onInputCommandChange: o, onSelect: s, onUpload: c }) {
2799
- let l = za(n, e, r);
2798
+ function Ga({ commands: e, messages: t = La, state: n, position: r, inputCommand: i, onActiveIndexChange: a, onInputCommandChange: o, onSelect: s, onUpload: c }) {
2799
+ let l = Ba(n, e, r);
2800
2800
  if (!l.visible || !r) return null;
2801
- let u = Ba(e, t), d = {
2801
+ let u = Va(e, t), d = {
2802
2802
  left: r.left,
2803
2803
  top: r.top,
2804
2804
  maxHeight: r.maxHeight,
@@ -2820,12 +2820,12 @@ function Wa({ commands: e, messages: t = Ia, state: n, position: r, inputCommand
2820
2820
  "aria-label": t.slash.ariaLabel,
2821
2821
  "data-placement": r.placement,
2822
2822
  "data-testid": "markweave-slash-menu",
2823
- children: i?.inputKind === "emoji" ? /* @__PURE__ */ Z(Ha, {
2823
+ children: i?.inputKind === "emoji" ? /* @__PURE__ */ Z(Ua, {
2824
2824
  command: i,
2825
2825
  messages: t,
2826
2826
  onBack: m,
2827
2827
  onSelect: s
2828
- }) : i?.inputKind === "upload" ? /* @__PURE__ */ Z(Ua, {
2828
+ }) : i?.inputKind === "upload" ? /* @__PURE__ */ Z(Wa, {
2829
2829
  command: i,
2830
2830
  messages: t,
2831
2831
  onBack: m,
@@ -2869,7 +2869,7 @@ function Wa({ commands: e, messages: t = Ia, state: n, position: r, inputCommand
2869
2869
  }
2870
2870
  },
2871
2871
  children: [
2872
- /* @__PURE__ */ Z(Ra, { name: t.icon }),
2872
+ /* @__PURE__ */ Z(za, { name: t.icon }),
2873
2873
  /* @__PURE__ */ Z("span", { children: t.label }),
2874
2874
  o && t.disabledReason ? /* @__PURE__ */ Z("small", { children: t.disabledReason }) : null
2875
2875
  ]
@@ -2881,7 +2881,7 @@ function Wa({ commands: e, messages: t = Ia, state: n, position: r, inputCommand
2881
2881
  }
2882
2882
  //#endregion
2883
2883
  //#region src/ui/table/TableControls.tsx
2884
- var Ga = n("zh"), Ka = {
2884
+ var Ka = n("zh"), qa = {
2885
2885
  "move-left": v,
2886
2886
  "move-right": y,
2887
2887
  "move-up": b,
@@ -2901,7 +2901,7 @@ var Ga = n("zh"), Ka = {
2901
2901
  split: ke,
2902
2902
  "ask-ai": xe,
2903
2903
  delete: je
2904
- }, qa = {
2904
+ }, Ja = {
2905
2905
  left: d,
2906
2906
  center: l,
2907
2907
  right: f,
@@ -2909,7 +2909,7 @@ var Ga = n("zh"), Ka = {
2909
2909
  middle: p,
2910
2910
  bottom: m
2911
2911
  };
2912
- function Ja({ active: e, editor: t, interactionState: n = Tn, messages: r = Ga, onCopyPayload: i, onCommandResult: a, askAi: o }) {
2912
+ function Ya({ active: e, editor: t, interactionState: n = Tn, messages: r = Ka, onCopyPayload: i, onCommandResult: a, askAi: o }) {
2913
2913
  let [s, c] = Y(null), [l, u] = Y(null), [d, f] = Y("row-edge"), [p, m] = Y(null), [h, g] = Y(null), [_, v] = Y(null), [y, b] = Y(null), [x, S] = Y(null), [C, w] = Y(null), [T, E] = Y(null), [, D] = Y(0), ee = J(null), O = J(null), [k, A] = Y(null), M = J(null), te = J(null), N = J(null), P = J(null), ne = J(null), re = J(null), F = J(null), I = e ? Cn(t.state) : null;
2914
2914
  if (K(() => {
2915
2915
  if (!k) return;
@@ -3281,7 +3281,7 @@ function Ja({ active: e, editor: t, interactionState: n = Tn, messages: r = Ga,
3281
3281
  className: "markweave-table-menu-scroll",
3282
3282
  style: p ? { maxHeight: Math.max(1, p.maxHeight - 12) } : void 0,
3283
3283
  children: se.map((e, n) => {
3284
- let i = ni(e), a = n === 0 ? i : ni(se[n - 1]), o = n > 0 && a !== i, d = s === "row" || s === "column" ? s : "selection", f = e.submenuId ? !0 : e.id === "edit-with-ai" ? V && wr(t, d) : e.commandId === null ? !1 : qr(t, e.commandId), p = ri(e, r), m = Ka[e.icon];
3284
+ let i = ni(e), a = n === 0 ? i : ni(se[n - 1]), o = n > 0 && a !== i, d = s === "row" || s === "column" ? s : "selection", f = e.submenuId ? !0 : e.id === "edit-with-ai" ? V && wr(t, d) : e.commandId === null ? !1 : qr(t, e.commandId), p = ri(e, r), m = qa[e.icon];
3285
3285
  return /* @__PURE__ */ Q("button", {
3286
3286
  type: "button",
3287
3287
  role: "menuitem",
@@ -3407,7 +3407,7 @@ function Ja({ active: e, editor: t, interactionState: n = Tn, messages: r = Ga,
3407
3407
  onKeyDown: de,
3408
3408
  children: [
3409
3409
  di.map((e) => {
3410
- let n = qa[e], i = W?.textAlign === e;
3410
+ let n = Ja[e], i = W?.textAlign === e;
3411
3411
  return /* @__PURE__ */ Q("button", {
3412
3412
  type: "button",
3413
3413
  role: "menuitemradio",
@@ -3425,7 +3425,7 @@ function Ja({ active: e, editor: t, interactionState: n = Tn, messages: r = Ga,
3425
3425
  }),
3426
3426
  /* @__PURE__ */ Z("div", { className: "markweave-table-submenu-separator" }),
3427
3427
  pi.map((e) => {
3428
- let n = qa[e], i = W?.verticalAlign === e;
3428
+ let n = Ja[e], i = W?.verticalAlign === e;
3429
3429
  return /* @__PURE__ */ Q("button", {
3430
3430
  type: "button",
3431
3431
  role: "menuitemradio",
@@ -3450,7 +3450,7 @@ function Ja({ active: e, editor: t, interactionState: n = Tn, messages: r = Ga,
3450
3450
  }
3451
3451
  //#endregion
3452
3452
  //#region src/ui/table/TableSelectionOverlay.tsx
3453
- function Ya({ editor: e, focusState: t }) {
3453
+ function Xa({ editor: e, focusState: t }) {
3454
3454
  let [n, r] = Y(null);
3455
3455
  return Le(() => {
3456
3456
  if (t.mode !== "cell-selection") {
@@ -3494,16 +3494,18 @@ function Ya({ editor: e, focusState: t }) {
3494
3494
  }
3495
3495
  //#endregion
3496
3496
  //#region src/ui/toc/MarkweaveInnerToc.tsx
3497
- function Xa(e, t) {
3497
+ function Za(e, t) {
3498
3498
  return `${e.toc.itemAriaLabel}: ${t.text}`;
3499
3499
  }
3500
- function Za({ editor: e, state: t, messages: n, editable: r, placement: i }) {
3500
+ function Qa({ editor: e, state: t, messages: n, editable: r, placement: i }) {
3501
3501
  let a = J(null);
3502
3502
  if (K(() => {
3503
3503
  if (!(i !== "container" || !a.current)) return Si(a.current);
3504
- }, [i]), !t.items.length) return null;
3504
+ }, [i]), K(() => {
3505
+ if (!(!a.current || !t.items.length)) return Ci(a.current, t.items.length);
3506
+ }, [t.items.length]), !t.items.length) return null;
3505
3507
  let o = (t) => {
3506
- Ci(e, t, {
3508
+ wi(e, t, {
3507
3509
  behavior: "smooth",
3508
3510
  focus: r
3509
3511
  });
@@ -3531,7 +3533,7 @@ function Za({ editor: e, state: t, messages: n, editable: r, placement: i }) {
3531
3533
  "data-level": e.level,
3532
3534
  "data-active": e.active ? "true" : "false",
3533
3535
  "aria-current": e.active ? "location" : void 0,
3534
- "aria-label": Xa(n, e),
3536
+ "aria-label": Za(n, e),
3535
3537
  title: e.text,
3536
3538
  onClick: () => o(e),
3537
3539
  children: e.text
@@ -3542,7 +3544,7 @@ function Za({ editor: e, state: t, messages: n, editable: r, placement: i }) {
3542
3544
  }
3543
3545
  //#endregion
3544
3546
  //#region src/MarkweaveEditor.tsx
3545
- var Qa = {
3547
+ var $a = {
3546
3548
  active: !1,
3547
3549
  mode: "outside",
3548
3550
  activeCellPos: null,
@@ -3550,21 +3552,21 @@ var Qa = {
3550
3552
  selectedCellCount: 0,
3551
3553
  selectionFrom: 0,
3552
3554
  selectionTo: 0
3553
- }, $a = {
3555
+ }, eo = {
3554
3556
  active: !1,
3555
3557
  language: Vt.defaultLanguage,
3556
3558
  mermaidPreviewMode: "code",
3557
3559
  pos: null,
3558
3560
  text: ""
3559
- }, eo = Yt({
3561
+ }, to = Yt({
3560
3562
  active: !1,
3561
3563
  mode: "code",
3562
3564
  source: ""
3563
3565
  });
3564
- function to(e) {
3566
+ function no(e) {
3565
3567
  return En.getState(e.state) ?? Tn;
3566
3568
  }
3567
- function no(e) {
3569
+ function ro(e) {
3568
3570
  if (!e || typeof window > "u") return null;
3569
3571
  let t = e.parentElement;
3570
3572
  for (; t;) {
@@ -3574,18 +3576,18 @@ function no(e) {
3574
3576
  }
3575
3577
  return null;
3576
3578
  }
3577
- function ro(e) {
3579
+ function io(e) {
3578
3580
  return typeof window > "u" || typeof window.requestAnimationFrame != "function" ? globalThis.setTimeout(() => e(0), 0) : window.requestAnimationFrame(e);
3579
3581
  }
3580
- function io(e) {
3582
+ function ao(e) {
3581
3583
  if (typeof window < "u" && typeof window.cancelAnimationFrame == "function") {
3582
3584
  window.cancelAnimationFrame(e);
3583
3585
  return;
3584
3586
  }
3585
3587
  globalThis.clearTimeout(e);
3586
3588
  }
3587
- function ao({ askAi: e, ariaLabel: i, autoFocusFirstTableBodyCell: a = !1, autofocus: o = !1, content: c, contentFormat: l, defaultContent: u = "", defaultContentFormat: d, editable: f = !0, innerToc: p = !0, innerTocPlacement: m, lang: h, mode: g = "live", theme: _, canvasColor: v, onEditWithAi: y, onExtractToNote: b, onRewriteSelection: x, onAiEditControllerChange: S, onRuntimeStateChange: C, onSearchControllerChange: w, onSlashCommandUpload: T, onTableCommandResult: E, onTableCopyPayload: D, onTocChange: ee, onUpdate: O, linkCardResolver: k, resolveMediaSource: A } = {}) {
3588
- let j = rt(g), M = Ti(_), te = wi(v), N = xi(m), P = j === "live" && f !== !1, ne = Ct(c === void 0 ? d : l), re = c ?? u, F = typeof re == "string" && re.length >= 2e5, I = c === void 0 && ne === "markdown" && F && typeof re == "string", ie = J(I ? re : null), [ae, L] = Y(I), R = J({
3589
+ function oo({ askAi: e, ariaLabel: i, autoFocusFirstTableBodyCell: a = !1, autofocus: o = !1, content: c, contentFormat: l, defaultContent: u = "", defaultContentFormat: d, editable: f = !0, innerToc: p = !0, innerTocPlacement: m, lang: h, mode: g = "live", theme: _, canvasColor: v, onEditWithAi: y, onExtractToNote: b, onRewriteSelection: x, onAiEditControllerChange: S, onRuntimeStateChange: C, onSearchControllerChange: w, onSlashCommandUpload: T, onTableCommandResult: E, onTableCopyPayload: D, onTocChange: ee, onUpdate: O, linkCardResolver: k, resolveMediaSource: A } = {}) {
3590
+ let j = rt(g), M = Ei(_), te = Ti(v), N = xi(m), P = j === "live" && f !== !1, ne = Ct(c === void 0 ? d : l), re = c ?? u, F = typeof re == "string" && re.length >= 2e5, I = c === void 0 && ne === "markdown" && F && typeof re == "string", ie = J(I ? re : null), [ae, L] = Y(I), R = J({
3589
3591
  editorMode: j,
3590
3592
  effectiveEditable: P
3591
3593
  });
@@ -3603,7 +3605,7 @@ function ao({ askAi: e, ariaLabel: i, autoFocusFirstTableBodyCell: a = !1, autof
3603
3605
  le.current = S;
3604
3606
  let ue = J(k);
3605
3607
  ue.current = k;
3606
- let H = q(() => Zi({
3608
+ let H = q(() => Qi({
3607
3609
  lang: B,
3608
3610
  onImageUpload: (e) => {
3609
3611
  if (se.current) return se.current(e);
@@ -3663,7 +3665,7 @@ function ao({ askAi: e, ariaLabel: i, autoFocusFirstTableBodyCell: a = !1, autof
3663
3665
  let r = zt(e);
3664
3666
  r.active && r.language === "mermaid" && ve(r.mermaidPreviewMode);
3665
3667
  }, []), ze = G((e) => {
3666
- Se(to(e));
3668
+ Se(no(e));
3667
3669
  }, []), X = s({
3668
3670
  shouldRerenderOnTransaction: !1,
3669
3671
  extensions: H,
@@ -3726,7 +3728,7 @@ function ao({ askAi: e, ariaLabel: i, autoFocusFirstTableBodyCell: a = !1, autof
3726
3728
  De.current = !0;
3727
3729
  try {
3728
3730
  let n = !0;
3729
- for (let r of Ei(e)) {
3731
+ for (let r of Di(e)) {
3730
3732
  if (await new Promise((e) => window.setTimeout(e, 0)), t) return;
3731
3733
  let e = X.markdown?.parse(r);
3732
3734
  if (!e) throw Error("Markdown parser is unavailable.");
@@ -3752,11 +3754,11 @@ function ao({ askAi: e, ariaLabel: i, autoFocusFirstTableBodyCell: a = !1, autof
3752
3754
  Re,
3753
3755
  ze
3754
3756
  ]), K(() => {
3755
- if (X) return ce.current?.(Di(X)), () => {
3757
+ if (X) return ce.current?.(Oi(X)), () => {
3756
3758
  ce.current?.(null);
3757
3759
  };
3758
3760
  }, [X]), K(() => {
3759
- if (X) return le.current?.(Oi(X)), () => {
3761
+ if (X) return le.current?.(ki(X)), () => {
3760
3762
  le.current?.(null);
3761
3763
  };
3762
3764
  }, [X]), K(() => {
@@ -3818,11 +3820,11 @@ function ao({ askAi: e, ariaLabel: i, autoFocusFirstTableBodyCell: a = !1, autof
3818
3820
  Ve,
3819
3821
  Ie
3820
3822
  ]);
3821
- let He = q(() => X ? zt(X) : $a, [
3823
+ let He = q(() => X ? zt(X) : eo, [
3822
3824
  X,
3823
3825
  Te,
3824
3826
  U
3825
- ]), Ue = q(() => X ? Cn(X.state) : Qa, [
3827
+ ]), Ue = q(() => X ? Cn(X.state) : $a, [
3826
3828
  X,
3827
3829
  Te,
3828
3830
  U,
@@ -3831,7 +3833,7 @@ function ao({ askAi: e, ariaLabel: i, autoFocusFirstTableBodyCell: a = !1, autof
3831
3833
  active: Ge,
3832
3834
  mode: _e,
3833
3835
  source: He.text
3834
- }) : eo, [
3836
+ }) : to, [
3835
3837
  He.text,
3836
3838
  X,
3837
3839
  Ge,
@@ -3856,12 +3858,12 @@ function ao({ askAi: e, ariaLabel: i, autoFocusFirstTableBodyCell: a = !1, autof
3856
3858
  }, [Je]), K(() => {
3857
3859
  if (!X || !Je.length || typeof window > "u") return;
3858
3860
  let e = null, t = () => {
3859
- e !== null && io(e), e = ro(() => {
3861
+ e !== null && ao(e), e = io(() => {
3860
3862
  e = null, Ze();
3861
3863
  });
3862
- }, n = no(X.view.dom);
3864
+ }, n = ro(X.view.dom);
3863
3865
  return window.addEventListener("scroll", t, { passive: !0 }), window.addEventListener("resize", t), n?.addEventListener("scroll", t, { passive: !0 }), t(), () => {
3864
- window.removeEventListener("scroll", t), window.removeEventListener("resize", t), n?.removeEventListener("scroll", t), e !== null && io(e);
3866
+ window.removeEventListener("scroll", t), window.removeEventListener("resize", t), n?.removeEventListener("scroll", t), e !== null && ao(e);
3865
3867
  };
3866
3868
  }, [
3867
3869
  X,
@@ -4077,24 +4079,24 @@ function ao({ askAi: e, ariaLabel: i, autoFocusFirstTableBodyCell: a = !1, autof
4077
4079
  actions: nt
4078
4080
  };
4079
4081
  }
4080
- function oo({ className: e, ...t }) {
4081
- let n = ao(t);
4082
+ function so({ className: e, ...t }) {
4083
+ let n = oo(t);
4082
4084
  if (!n.editor) return null;
4083
4085
  let r = [n.frameProps.className, e].filter(Boolean).join(" ");
4084
4086
  return /* @__PURE__ */ Q("section", {
4085
4087
  ...n.frameProps,
4086
4088
  className: r,
4087
4089
  children: [
4088
- n.overlayProps.floatingToolbar ? /* @__PURE__ */ Z(Sa, { ...n.overlayProps.floatingToolbar }) : null,
4089
- n.overlayProps.slashCommandMenu ? /* @__PURE__ */ Z(Wa, { ...n.overlayProps.slashCommandMenu }) : null,
4090
- n.overlayProps.tableControls ? /* @__PURE__ */ Z(Ja, { ...n.overlayProps.tableControls }) : null,
4091
- n.overlayProps.tableSelectionOverlay ? /* @__PURE__ */ Z(Ya, { ...n.overlayProps.tableSelectionOverlay }) : null,
4092
- n.overlayProps.codeBlockControls ? /* @__PURE__ */ Z(ea, { ...n.overlayProps.codeBlockControls }) : null,
4093
- n.overlayProps.innerToc ? /* @__PURE__ */ Z(Za, { ...n.overlayProps.innerToc }) : null,
4094
- n.overlayProps.mathEditorPopover ? /* @__PURE__ */ Z(Fa, { ...n.overlayProps.mathEditorPopover }) : null,
4090
+ n.overlayProps.floatingToolbar ? /* @__PURE__ */ Z(Ca, { ...n.overlayProps.floatingToolbar }) : null,
4091
+ n.overlayProps.slashCommandMenu ? /* @__PURE__ */ Z(Ga, { ...n.overlayProps.slashCommandMenu }) : null,
4092
+ n.overlayProps.tableControls ? /* @__PURE__ */ Z(Ya, { ...n.overlayProps.tableControls }) : null,
4093
+ n.overlayProps.tableSelectionOverlay ? /* @__PURE__ */ Z(Xa, { ...n.overlayProps.tableSelectionOverlay }) : null,
4094
+ n.overlayProps.codeBlockControls ? /* @__PURE__ */ Z(ta, { ...n.overlayProps.codeBlockControls }) : null,
4095
+ n.overlayProps.innerToc ? /* @__PURE__ */ Z(Qa, { ...n.overlayProps.innerToc }) : null,
4096
+ n.overlayProps.mathEditorPopover ? /* @__PURE__ */ Z(Ia, { ...n.overlayProps.mathEditorPopover }) : null,
4095
4097
  /* @__PURE__ */ Z(i, { editor: n.editor })
4096
4098
  ]
4097
4099
  });
4098
4100
  }
4099
4101
  //#endregion
4100
- export { oo as MarkweaveEditor, gt as createMarkweaveAiEditController, Zi as createMarkweaveEditorExtensions, Zi as createMarkweaveReactEditorExtensions, ao as useMarkweaveEditorController };
4102
+ export { so as MarkweaveEditor, gt as createMarkweaveAiEditController, Qi as createMarkweaveEditorExtensions, Qi as createMarkweaveReactEditorExtensions, oo as useMarkweaveEditorController };