@markweave/react 0.4.3 → 0.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -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, getMarkweaveTocItemsFromState as vi, getValidMarkweaveTocActiveId as yi, normalizeMarkweaveInnerTocPlacement as bi, observeMarkweaveInnerTocContainerPosition as xi, scrollToMarkweaveTocItem as Si } from "markweave/internal/core/toc-state";
45
- import { normalizeMarkweaveCanvasColor as Ci, normalizeMarkweaveTheme as wi } from "markweave/internal/core/theme";
46
- import { splitMarkweaveLargeMarkdown as Ti } from "markweave/internal/core/large-document";
47
- import { createMarkweaveSearchController as Ei } from "markweave/internal/plugins/search/search-controller";
48
- import { createMarkweaveAiEditController as Di } 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, 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";
49
49
  //#region src/editor-mode-state.ts
50
- var Oi = {
50
+ var ki = {
51
51
  mode: "live",
52
52
  editable: !0
53
53
  };
54
- function ki(e) {
55
- return Re((t) => at(e, t), () => tt(e), () => Oi);
54
+ function Ai(e) {
55
+ return Re((t) => at(e, t), () => tt(e), () => ki);
56
56
  }
57
57
  //#endregion
58
58
  //#region src/media/image-node.tsx
59
- var Ai = Ze;
60
- function ji(e) {
59
+ var ji = Ze;
60
+ function Mi(e) {
61
61
  return e instanceof Element && !!e.closest("[data-markweave-image-ui=\"true\"]");
62
62
  }
63
- function Mi(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(ki(r)), p = et(o.attrs.src), m = Ai(o.attrs.align), h = $e(o.attrs.width), g = et(o.attrs.caption), _ = J(null), v = Ri(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 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 = () => {
65
65
  y && ot({
66
66
  src: y,
67
67
  alt: et(o.attrs.alt) ?? "",
@@ -147,9 +147,9 @@ function Mi(e) {
147
147
  onPointerEnter: () => S(!0),
148
148
  onPointerLeave: () => S(!1),
149
149
  onMouseDown: (e) => {
150
- f && !ji(e.target) && F();
150
+ f && !Mi(e.target) && F();
151
151
  },
152
- children: ne ? /* @__PURE__ */ Z(Ni, {
152
+ children: ne ? /* @__PURE__ */ Z(Pi, {
153
153
  dragActive: T,
154
154
  error: O,
155
155
  inputValue: D,
@@ -163,7 +163,7 @@ function Mi(e) {
163
163
  onInputChange: ee,
164
164
  onSubmit: L
165
165
  }) : /* @__PURE__ */ Q(lt, { children: [
166
- f ? /* @__PURE__ */ Z(Pi, {
166
+ f ? /* @__PURE__ */ Z(Fi, {
167
167
  align: m,
168
168
  captionActive: M || !!g,
169
169
  messages: u,
@@ -219,12 +219,12 @@ function Mi(e) {
219
219
  children: d.preview
220
220
  })]
221
221
  }) : null,
222
- f ? /* @__PURE__ */ Z(Ii, {
222
+ f ? /* @__PURE__ */ Z(Li, {
223
223
  side: "left",
224
224
  messages: u,
225
225
  onPointerDown: se
226
226
  }) : null,
227
- f ? /* @__PURE__ */ Z(Ii, {
227
+ f ? /* @__PURE__ */ Z(Li, {
228
228
  side: "right",
229
229
  messages: u,
230
230
  onPointerDown: se
@@ -250,7 +250,7 @@ function Mi(e) {
250
250
  ] })
251
251
  });
252
252
  }
253
- function Ni({ 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 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 }) {
254
254
  let f = a.image;
255
255
  return /* @__PURE__ */ Q("section", {
256
256
  className: "markweave-image-upload-placeholder",
@@ -332,7 +332,7 @@ function Ni({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
332
332
  ]
333
333
  });
334
334
  }
335
- function Pi({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i, onDelete: a, onDownload: o, onPreview: s, onReplace: c }) {
335
+ function Fi({ 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 Pi({ 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(Fi, {
343
+ /* @__PURE__ */ Z(Ii, {
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(Fi, {
350
+ /* @__PURE__ */ Z(Ii, {
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(Fi, {
357
+ /* @__PURE__ */ Z(Ii, {
358
358
  testId: "markweave-image-align-right",
359
359
  label: u.alignRight,
360
360
  icon: f,
@@ -365,26 +365,26 @@ function Pi({ 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(Fi, {
368
+ /* @__PURE__ */ Z(Ii, {
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(Fi, {
375
+ /* @__PURE__ */ Z(Ii, {
376
376
  testId: "markweave-image-preview",
377
377
  label: u.preview,
378
378
  icon: I,
379
379
  onClick: s
380
380
  }),
381
- /* @__PURE__ */ Z(Fi, {
381
+ /* @__PURE__ */ Z(Ii, {
382
382
  testId: "markweave-image-download",
383
383
  label: u.download,
384
384
  icon: re,
385
385
  onClick: o
386
386
  }),
387
- /* @__PURE__ */ Z(Fi, {
387
+ /* @__PURE__ */ Z(Ii, {
388
388
  testId: "markweave-image-replace",
389
389
  label: u.replace,
390
390
  icon: _e,
@@ -394,7 +394,7 @@ function Pi({ 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(Fi, {
397
+ /* @__PURE__ */ Z(Ii, {
398
398
  testId: "markweave-image-delete",
399
399
  label: u.delete,
400
400
  icon: je,
@@ -403,7 +403,7 @@ function Pi({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i,
403
403
  ]
404
404
  });
405
405
  }
406
- function Fi({ active: e = !1, icon: t, label: n, onClick: r, testId: i }) {
406
+ function Ii({ 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 Fi({ active: e = !1, icon: t, label: n, onClick: r, testId: i }) {
422
422
  })]
423
423
  });
424
424
  }
425
- function Ii({ messages: e, onPointerDown: t, side: n }) {
425
+ function Li({ 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 Ii({ messages: e, onPointerDown: t, side: n }) {
433
433
  onPointerDown: (e) => t(n, e)
434
434
  });
435
435
  }
436
- var Li = Ve.extend({
436
+ var Ri = Ve.extend({
437
437
  addOptions() {
438
438
  return {
439
439
  ...this.parent?.(),
@@ -444,7 +444,7 @@ var Li = Ve.extend({
444
444
  },
445
445
  addNodeView() {
446
446
  if (typeof document > "u") return null;
447
- let e = o(Mi, { stopEvent: ({ event: e }) => ji(e.target) }), t = this.options.resolveMediaSource;
447
+ let e = o(Ni, { stopEvent: ({ event: e }) => Mi(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 Li = Ve.extend({
454
454
  return (t) => et(t.node.attrs.src) ? r(t) : e(t);
455
455
  }
456
456
  });
457
- function Ri(e, t, n, r) {
457
+ function zi(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 Ri(e, t, n, r) {
500
500
  }
501
501
  //#endregion
502
502
  //#region src/media/video-node.tsx
503
- function zi(e) {
503
+ function Bi(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 Bi(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(ki(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 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 = () => {
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 && (zi(e.target) || (e.preventDefault(), O()));
512
+ f && (Bi(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 Bi(e) {
535
535
  "data-testid": "markweave-video-node",
536
536
  "data-empty": "true",
537
537
  "data-selected": "false",
538
- children: /* @__PURE__ */ Z(Vi, {
538
+ children: /* @__PURE__ */ Z(Hi, {
539
539
  dragActive: b,
540
540
  error: w,
541
541
  fileInputRef: y,
@@ -616,7 +616,7 @@ function Bi(e) {
616
616
  })
617
617
  });
618
618
  }
619
- function Vi({ 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 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 }) {
620
620
  let f = a.video;
621
621
  return /* @__PURE__ */ Q("section", {
622
622
  className: "markweave-video-upload-placeholder",
@@ -698,7 +698,7 @@ function Vi({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
698
698
  ]
699
699
  });
700
700
  }
701
- var Hi = He.extend({
701
+ var Ui = He.extend({
702
702
  addOptions() {
703
703
  return {
704
704
  ...this.parent?.(),
@@ -708,29 +708,29 @@ var Hi = He.extend({
708
708
  };
709
709
  },
710
710
  addNodeView() {
711
- return typeof document > "u" ? null : o(Bi, { stopEvent: ({ event: e }) => zi(e.target) });
711
+ return typeof document > "u" ? null : o(Vi, { stopEvent: ({ event: e }) => Bi(e.target) });
712
712
  }
713
713
  });
714
714
  //#endregion
715
715
  //#region src/link-card-node.tsx
716
- function Ui(e) {
716
+ function Wi(e) {
717
717
  return e instanceof Element && !!e.closest("[data-markweave-link-card-ui=\"true\"]");
718
718
  }
719
- function Wi(e) {
719
+ function Gi(e) {
720
720
  return typeof navigator < "u" && navigator.clipboard?.writeText ? navigator.clipboard.writeText(e).catch(() => void 0) : Promise.resolve();
721
721
  }
722
- function Gi(e) {
722
+ function Ki(e) {
723
723
  !e || typeof window > "u" || window.open(e, "_blank", "noopener,noreferrer");
724
724
  }
725
- function Ki(e) {
725
+ function qi(e) {
726
726
  try {
727
727
  return new URL(e).host;
728
728
  } catch {
729
729
  return e;
730
730
  }
731
731
  }
732
- function qi(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(ki(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 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);
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 qi(e) {
759
759
  }, T = () => {
760
760
  let e = i();
761
761
  typeof e == "number" && pt(r, e);
762
- }, E = _ ? null : f.imageUrl, D = Ki(f.href);
762
+ }, E = _ ? null : f.imageUrl, D = qi(f.href);
763
763
  return /* @__PURE__ */ Q(a, {
764
764
  as: "article",
765
765
  className: "markweave-link-card",
@@ -770,10 +770,10 @@ function qi(e) {
770
770
  onMouseEnter: () => m(!0),
771
771
  onMouseLeave: () => m(!1),
772
772
  onMouseDown: (e) => {
773
- Ui(e.target) || e.preventDefault();
773
+ Wi(e.target) || e.preventDefault();
774
774
  },
775
775
  onClick: (e) => {
776
- Ui(e.target) || (e.preventDefault(), Gi(f.href));
776
+ Wi(e.target) || (e.preventDefault(), Ki(f.href));
777
777
  },
778
778
  children: [
779
779
  /* @__PURE__ */ Q("a", {
@@ -811,19 +811,19 @@ function qi(e) {
811
811
  "data-markweave-link-card-ui": "true",
812
812
  "aria-label": u.toolsAriaLabel,
813
813
  children: [
814
- /* @__PURE__ */ Z(Ji, {
814
+ /* @__PURE__ */ Z(Yi, {
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(Ji, {
820
+ /* @__PURE__ */ Z(Yi, {
821
821
  label: u.copyAddress,
822
822
  icon: P,
823
- onClick: () => void Wi(f.href),
823
+ onClick: () => void Gi(f.href),
824
824
  testId: "markweave-link-card-copy"
825
825
  }),
826
- /* @__PURE__ */ Z(Ji, {
826
+ /* @__PURE__ */ Z(Yi, {
827
827
  label: u.edit,
828
828
  icon: me,
829
829
  onClick: (e) => {
@@ -841,7 +841,7 @@ function qi(e) {
841
841
  },
842
842
  testId: "markweave-link-card-edit"
843
843
  }),
844
- /* @__PURE__ */ Z(Ji, {
844
+ /* @__PURE__ */ Z(Yi, {
845
845
  label: u.delete,
846
846
  icon: je,
847
847
  onClick: t,
@@ -878,7 +878,7 @@ function qi(e) {
878
878
  ]
879
879
  });
880
880
  }
881
- function Ji({ icon: e, label: t, onClick: n, testId: r }) {
881
+ function Yi({ 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 Ji({ icon: e, label: t, onClick: n, testId: r }) {
895
895
  })]
896
896
  });
897
897
  }
898
- var Yi = ht.extend({
898
+ var Xi = ht.extend({
899
899
  addOptions() {
900
900
  return {
901
901
  ...this.parent?.(),
@@ -904,23 +904,23 @@ var Yi = ht.extend({
904
904
  };
905
905
  },
906
906
  addNodeView() {
907
- return typeof document > "u" ? null : o(qi, { stopEvent: ({ event: e }) => Ui(e.target) });
907
+ return typeof document > "u" ? null : o(Ji, { stopEvent: ({ event: e }) => Wi(e.target) });
908
908
  }
909
909
  });
910
910
  //#endregion
911
911
  //#region src/create-editor-extensions.ts
912
- function Xi(t = {}) {
912
+ function Zi(t = {}) {
913
913
  return e({
914
914
  lang: t.lang,
915
915
  onImageUpload: t.onImageUpload,
916
- linkCardExtension: Yi.configure({
916
+ linkCardExtension: Xi.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: Li,
923
- video: Hi,
922
+ image: Ri,
923
+ video: Ui,
924
924
  lang: t.lang,
925
925
  onImageUpload: t.onImageUpload,
926
926
  onVideoUpload: t.onVideoUpload,
@@ -930,7 +930,7 @@ function Xi(t = {}) {
930
930
  }
931
931
  //#endregion
932
932
  //#region src/ui/codeblock/CodeBlockControls.tsx
933
- function Zi(e) {
933
+ function Qi(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 Zi(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 Qi({ icon: e }) {
970
+ function $i({ 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 Qi({ icon: e }) {
978
978
  strokeLinecap: "round",
979
979
  strokeLinejoin: "round",
980
980
  strokeWidth: "1.8",
981
- children: Zi(e)
981
+ children: Qi(e)
982
982
  })
983
983
  });
984
984
  }
985
- function $i({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, readOnly: i = !1 }) {
985
+ function ea({ 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 $i({ 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(Qi, { icon: "chevron" })]
1282
+ children: [/* @__PURE__ */ Z("span", { children: se }), /* @__PURE__ */ Z($i, { icon: "chevron" })]
1283
1283
  }),
1284
1284
  oe ? /* @__PURE__ */ Z("button", {
1285
1285
  type: "button",
@@ -1290,7 +1290,7 @@ function $i({ 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(Qi, { icon: "chevron" })
1293
+ children: /* @__PURE__ */ Z($i, { icon: "chevron" })
1294
1294
  }) : null,
1295
1295
  /* @__PURE__ */ Q("span", {
1296
1296
  className: "markweave-codeblock-copy-wrap",
@@ -1306,7 +1306,7 @@ function $i({ 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(Qi, { icon: ce === "copied" ? "check" : "clipboard" })
1309
+ children: /* @__PURE__ */ Z($i, { 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 $i({ 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(Qi, { icon: "expand" })
1328
+ children: /* @__PURE__ */ Z($i, { icon: "expand" })
1329
1329
  }), /* @__PURE__ */ Z("button", {
1330
1330
  type: "button",
1331
1331
  className: "markweave-codeblock-icon-button",
@@ -1334,7 +1334,7 @@ function $i({ 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(Qi, { icon: "download" })
1337
+ children: /* @__PURE__ */ Z($i, { icon: "download" })
1338
1338
  })]
1339
1339
  }) : null
1340
1340
  ]
@@ -1363,7 +1363,7 @@ function $i({ 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(Qi, { icon: "search" })]
1366
+ }), /* @__PURE__ */ Z($i, { icon: "search" })]
1367
1367
  }), /* @__PURE__ */ Z("div", {
1368
1368
  ref: l,
1369
1369
  id: u.current ?? void 0,
@@ -1384,7 +1384,7 @@ function $i({ 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(Qi, { icon: "check" }) : null]
1387
+ children: [/* @__PURE__ */ Z("span", { children: e.label }), n ? /* @__PURE__ */ Z($i, { icon: "check" }) : null]
1388
1388
  }, e.language);
1389
1389
  })
1390
1390
  })]
@@ -1410,7 +1410,7 @@ function $i({ 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(Qi, { icon: "zoomOut" })
1413
+ children: /* @__PURE__ */ Z($i, { icon: "zoomOut" })
1414
1414
  }),
1415
1415
  /* @__PURE__ */ Z("span", {
1416
1416
  className: "markweave-mermaid-fullscreen-zoom-label",
@@ -1427,7 +1427,7 @@ function $i({ 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(Qi, { icon: "zoomIn" })
1430
+ children: /* @__PURE__ */ Z($i, { icon: "zoomIn" })
1431
1431
  }),
1432
1432
  /* @__PURE__ */ Z("button", {
1433
1433
  type: "button",
@@ -1439,7 +1439,7 @@ function $i({ 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(Qi, { icon: "reset" })
1442
+ children: /* @__PURE__ */ Z($i, { icon: "reset" })
1443
1443
  }),
1444
1444
  j ? /* @__PURE__ */ Z("span", {
1445
1445
  className: "markweave-mermaid-fullscreen-tooltip",
@@ -1455,7 +1455,7 @@ function $i({ 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(Qi, { icon: "close" })
1458
+ children: /* @__PURE__ */ Z($i, { icon: "close" })
1459
1459
  }),
1460
1460
  /* @__PURE__ */ Z("div", {
1461
1461
  className: "markweave-mermaid-fullscreen-viewport",
@@ -1486,25 +1486,25 @@ function $i({ 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 ea = n("zh");
1490
- function ta() {
1489
+ var ta = n("zh");
1490
+ function na() {
1491
1491
  return typeof performance > "u" ? Date.now() : performance.now();
1492
1492
  }
1493
- function na(e, t) {
1493
+ function ra(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 ra(e, t) {
1500
+ function ia(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 ia(e) {
1504
+ function aa(e) {
1505
1505
  if (e !== null) return { "--markweave-floating-toolbar-tooltip-left": `${e}px` };
1506
1506
  }
1507
- function aa(e, t, n, r) {
1507
+ function oa(e, t, n, r) {
1508
1508
  let i = {
1509
1509
  bottom: t + r,
1510
1510
  height: r,
@@ -1520,26 +1520,26 @@ function aa(e, t, n, r) {
1520
1520
  toJSON: () => i
1521
1521
  };
1522
1522
  }
1523
- function oa(e) {
1523
+ function sa(e) {
1524
1524
  return e.width > 0 && e.height > 0;
1525
1525
  }
1526
- function sa(e) {
1526
+ function ca(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 aa(t, n, r - t, i - n);
1528
+ return oa(t, n, r - t, i - n);
1529
1529
  }
1530
- function ca(e, t) {
1530
+ function la(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 la(e) {
1534
+ function ua(e) {
1535
1535
  if (typeof e.getClientRects != "function") return null;
1536
- let t = Array.from(e.getClientRects()).filter(oa).map((e) => aa(e.left, e.top, e.width, e.height));
1536
+ let t = Array.from(e.getClientRects()).filter(sa).map((e) => oa(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 oa(n) ? [aa(n.left, n.top, n.width, n.height)] : null;
1540
+ return sa(n) ? [oa(n.left, n.top, n.width, n.height)] : null;
1541
1541
  }
1542
- function ua(e, t) {
1542
+ function da(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 ua(e, t) {
1552
1552
  return null;
1553
1553
  }
1554
1554
  }
1555
- function da(e, t) {
1556
- let n = ua(e, t);
1555
+ function fa(e, t) {
1556
+ let n = da(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 da(e, t) {
1561
1561
  };
1562
1562
  return n.from === i.from && n.to === i.to;
1563
1563
  }
1564
- function fa(e) {
1564
+ function pa(e) {
1565
1565
  let t = e.view.dom.ownerDocument.getSelection();
1566
- return !t || t.rangeCount === 0 || t.isCollapsed || !ca(e, t) || !da(e, t) ? null : la(t.getRangeAt(0));
1566
+ return !t || t.rangeCount === 0 || t.isCollapsed || !la(e, t) || !fa(e, t) ? null : ua(t.getRangeAt(0));
1567
1567
  }
1568
- function pa(e) {
1568
+ function ma(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), la(a);
1574
+ return a.setStart(t.node, t.offset), a.setEnd(i.node, i.offset), ua(a);
1575
1575
  } catch {
1576
1576
  return null;
1577
1577
  }
1578
1578
  }
1579
- function ma(e) {
1579
+ function ha(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 = aa(c, o, Math.max(i.right, a.right) - c, s - o);
1583
- return oa(l) ? [l] : null;
1584
- }
1585
- function ha(e) {
1586
- return fa(e) ?? pa(e) ?? ma(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 = oa(c, o, Math.max(i.right, a.right) - c, s - o);
1583
+ return sa(l) ? [l] : null;
1587
1584
  }
1588
1585
  function ga(e) {
1589
- let t = ha(e);
1590
- return t && t.length > 0 ? sa(t) : null;
1586
+ return pa(e) ?? ma(e) ?? ha(e);
1591
1587
  }
1592
1588
  function _a(e) {
1589
+ let t = ga(e);
1590
+ return t && t.length > 0 ? ca(t) : null;
1591
+ }
1592
+ function va(e) {
1593
1593
  return {
1594
- getBoundingClientRect: () => ga(e) ?? aa(0, 0, 0, 0),
1595
- getClientRects: () => ha(e) ?? []
1594
+ getBoundingClientRect: () => _a(e) ?? oa(0, 0, 0, 0),
1595
+ getClientRects: () => ga(e) ?? []
1596
1596
  };
1597
1597
  }
1598
- function va(e) {
1598
+ function ya(e) {
1599
1599
  return e === "ask-ai" || e === "block-type" || e === "link" || e === "color" || e === "more";
1600
1600
  }
1601
- function ya(e, t, n) {
1601
+ function ba(e, t, n) {
1602
1602
  n?.(rr(e, t)), e.commands.focus();
1603
1603
  }
1604
- var ba = "markweave-floating-toolbar";
1605
- function xa({ editor: e, lang: t = "zh", messages: n = ea, selectionSnapshot: r, askAi: i, onRewriteSelection: a }) {
1604
+ var xa = "markweave-floating-toolbar";
1605
+ function Sa({ editor: e, lang: t = "zh", messages: n = ta, 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 xa({ editor: e, lang: t = "zh", messages: n = ea, 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 = ra(t, I.current), o = re.current, s = Ot({
1613
+ let r = t.getBoundingClientRect(), i = n.getBoundingClientRect(), a = ia(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 xa({ editor: e, lang: t = "zh", messages: n = ea, selectionSnapshot: r,
1650
1650
  }, [de]), pe = G(() => Ar(e)?.target.kind === "table" ? {
1651
1651
  getBoundingClientRect: () => {
1652
1652
  let t = jr(e);
1653
- return t ? aa(t.left, t.top, t.width, t.height) : aa(0, 0, 0, 0);
1653
+ return t ? oa(t.left, t.top, t.width, t.height) : oa(0, 0, 0, 0);
1654
1654
  },
1655
1655
  getClientRects: () => {
1656
1656
  let t = jr(e);
1657
- return t ? [aa(t.left, t.top, t.width, t.height)] : [];
1657
+ return t ? [oa(t.left, t.top, t.width, t.height)] : [];
1658
1658
  }
1659
- } : _a(e), [e]), me = G((e) => {
1659
+ } : va(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 xa({ editor: e, lang: t = "zh", messages: n = ea, selectionSnapshot: r,
1712
1712
  te
1713
1713
  ]);
1714
1714
  K(() => {
1715
- let e = ta();
1715
+ let e = na();
1716
1716
  l((t) => It(t, s, e));
1717
1717
  }, [
1718
1718
  s.hiddenReason,
@@ -1727,8 +1727,8 @@ function xa({ editor: e, lang: t = "zh", messages: n = ea, 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 - ta()), t = window.setTimeout(() => {
1731
- l((e) => Et(e, ta()));
1730
+ let e = Math.max(0, c.motionStartedAtMs + c.motionDurationMs - na()), t = window.setTimeout(() => {
1731
+ l((e) => Et(e, na()));
1732
1732
  }, e);
1733
1733
  return () => {
1734
1734
  window.clearTimeout(t);
@@ -1822,10 +1822,10 @@ function xa({ editor: e, lang: t = "zh", messages: n = ea, 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(ba, "show").setMeta("addToHistory", !1));
1825
+ m !== "ask-ai" || e.isDestroyed || e.view.dispatch(e.state.tr.setMeta(xa, "show").setMeta("addToHistory", !1));
1826
1826
  }, [e, m]);
1827
1827
  let _e = (t) => {
1828
- if (va(t.id)) {
1828
+ if (ya(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 xa({ editor: e, lang: t = "zh", messages: n = ea, selectionSnapshot: r,
1848
1848
  return;
1849
1849
  }
1850
1850
  if (h(null), t.id === "improve") {
1851
- ya(e, "rewrite-selection", a);
1851
+ ba(e, "rewrite-selection", a);
1852
1852
  return;
1853
1853
  }
1854
1854
  t.run(), e.commands.focus();
@@ -1925,7 +1925,7 @@ function xa({ editor: e, lang: t = "zh", messages: n = ea, selectionSnapshot: r,
1925
1925
  return /* @__PURE__ */ Z(tr, {
1926
1926
  ref: F,
1927
1927
  editor: e,
1928
- pluginKey: ba,
1928
+ pluginKey: xa,
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 xa({ editor: e, lang: t = "zh", messages: n = ea, 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: na(c, j),
1936
+ style: ra(c, j),
1937
1937
  updateDelay: 0,
1938
1938
  getReferencedVirtualElement: pe,
1939
1939
  options: ge,
@@ -1950,7 +1950,7 @@ function xa({ editor: e, lang: t = "zh", messages: n = ea, 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(wa, {
1953
+ ce.map((e, t) => /* @__PURE__ */ Z(Ta, {
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 xa({ editor: e, lang: t = "zh", messages: n = ea, selectionSnapshot: r,
1959
1959
  onTooltipChange: we,
1960
1960
  onRun: _e
1961
1961
  }, e.id)),
1962
- m === "block-type" ? /* @__PURE__ */ Z(Ea, {
1962
+ m === "block-type" ? /* @__PURE__ */ Z(Da, {
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(Ca, {
1968
+ m === "ask-ai" ? /* @__PURE__ */ Z(wa, {
1969
1969
  inputRef: L,
1970
1970
  messages: n,
1971
1971
  phase: g,
@@ -1982,7 +1982,7 @@ function xa({ editor: e, lang: t = "zh", messages: n = ea, selectionSnapshot: r,
1982
1982
  onDiscard: () => U(!0),
1983
1983
  onPopoverRef: me
1984
1984
  }) : null,
1985
- m === "link" ? /* @__PURE__ */ Z(Sa, {
1985
+ m === "link" ? /* @__PURE__ */ Z(Ca, {
1986
1986
  inputRef: ae,
1987
1987
  messages: n,
1988
1988
  value: E,
@@ -1995,13 +1995,13 @@ function xa({ editor: e, lang: t = "zh", messages: n = ea, selectionSnapshot: r,
1995
1995
  onRemove: Ce,
1996
1996
  onPopoverRef: me
1997
1997
  }) : null,
1998
- m === "color" ? /* @__PURE__ */ Z(Oa, {
1998
+ m === "color" ? /* @__PURE__ */ Z(ka, {
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(Aa, {
2004
+ m === "more" ? /* @__PURE__ */ Z(ja, {
2005
2005
  editor: e,
2006
2006
  messages: n,
2007
2007
  activeTooltipId: u,
@@ -2015,14 +2015,14 @@ function xa({ editor: e, lang: t = "zh", messages: n = ea, 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: ia(f),
2018
+ style: aa(f),
2019
2019
  children: le.label
2020
2020
  }) : null
2021
2021
  ]
2022
2022
  })
2023
2023
  });
2024
2024
  }
2025
- function Sa({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRemove: a, onValueChange: o, onApply: s, onOpen: c, onRemove: l, onPopoverRef: u }) {
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 }) {
2026
2026
  let d = sr(t);
2027
2027
  return /* @__PURE__ */ Q("form", {
2028
2028
  ref: u,
@@ -2075,7 +2075,7 @@ function Sa({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRe
2075
2075
  })]
2076
2076
  });
2077
2077
  }
2078
- function Ca({ 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 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 }) {
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 Ca({ inputRef: e, messages: t, phase: n, prompt: r, hasStreamedContent:
2185
2185
  ]
2186
2186
  });
2187
2187
  }
2188
- function wa({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointerDown: i, onTooltipChange: a, onRun: o }) {
2188
+ function Ta({ 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 wa({ 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": va(e.id) ? t : void 0,
2196
+ "aria-expanded": ya(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 wa({ 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(Ta, {
2206
+ children: /* @__PURE__ */ Z(Ea, {
2207
2207
  button: e,
2208
2208
  expanded: t
2209
2209
  })
2210
2210
  })] });
2211
2211
  }
2212
- function Ta({ button: e, expanded: t }) {
2212
+ function Ea({ 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 Ta({ button: e, expanded: t }) {
2227
2227
  }), /* @__PURE__ */ Z($, { name: t ? "chevron-up" : "chevron-down" })]
2228
2228
  }) : /* @__PURE__ */ Z($, { name: "more" });
2229
2229
  }
2230
- function Ea({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
2230
+ function Da({ 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 Ea({ 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(Da, { option: t })
2249
+ children: /* @__PURE__ */ Z(Oa, { option: t })
2250
2250
  }), /* @__PURE__ */ Z("span", { children: t.label })]
2251
2251
  }, t.id))]
2252
2252
  });
2253
2253
  }
2254
- function Da({ option: e }) {
2254
+ function Oa({ 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 Oa({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
2257
+ function ka({ 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(ka, {
2263
+ children: [/* @__PURE__ */ Z(Aa, {
2264
2264
  title: i.textColorTitle,
2265
2265
  mode: "text",
2266
2266
  activeColor: a ?? null,
@@ -2268,7 +2268,7 @@ function Oa({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
2268
2268
  onSelect: (t) => {
2269
2269
  yr(e, t), r();
2270
2270
  }
2271
- }), /* @__PURE__ */ Z(ka, {
2271
+ }), /* @__PURE__ */ Z(Aa, {
2272
2272
  title: i.highlightColorTitle,
2273
2273
  mode: "highlight",
2274
2274
  activeColor: o ?? null,
@@ -2279,7 +2279,7 @@ function Oa({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
2279
2279
  })]
2280
2280
  });
2281
2281
  }
2282
- function ka({ title: e, mode: t, activeColor: n, options: r, onSelect: i }) {
2282
+ function Aa({ 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 ka({ title: e, mode: t, activeColor: n, options: r, onSelect: i }) {
2308
2308
  })]
2309
2309
  });
2310
2310
  }
2311
- function Aa({ editor: e, messages: t, activeTooltipId: n, onPopoverRef: r, onTooltipChange: i, onClose: a }) {
2311
+ function ja({ 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(ja, {
2317
+ children: o.map((t, r) => /* @__PURE__ */ Z(Ma, {
2318
2318
  action: t,
2319
2319
  active: fr(e, t.id),
2320
2320
  tooltipActive: n === t.id,
@@ -2326,7 +2326,7 @@ function Aa({ editor: e, messages: t, activeTooltipId: n, onPopoverRef: r, onToo
2326
2326
  }, t.id))
2327
2327
  });
2328
2328
  }
2329
- function ja({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipChange: i, onRun: a }) {
2329
+ function Ma({ 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 ja({ 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(Ma, { id: e.id })
2345
+ children: /* @__PURE__ */ Z(Na, { 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 ja({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipC
2350
2350
  }) : null]
2351
2351
  })] });
2352
2352
  }
2353
- function Ma({ id: e }) {
2353
+ function Na({ 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 Na = {
2356
+ var Pa = {
2357
2357
  sparkles: xe,
2358
2358
  "arrow-up": b,
2359
2359
  check: O,
@@ -2389,7 +2389,7 @@ var Na = {
2389
2389
  x: Ie
2390
2390
  };
2391
2391
  function $({ name: e }) {
2392
- let t = Na[e];
2392
+ let t = Pa[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 Pa({ editor: e, messages: t, onClose: n, target: r }) {
2402
+ function Fa({ 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 Pa({ editor: e, messages: t, onClose: n, target: r }) {
2584
2584
  }
2585
2585
  //#endregion
2586
2586
  //#region src/ui/slash-command/SlashCommandMenu.tsx
2587
- var Fa = n("zh"), Ia = {
2587
+ var Ia = n("zh"), La = {
2588
2588
  type: Ae,
2589
2589
  "heading-1": ie,
2590
2590
  "heading-2": ae,
@@ -2607,8 +2607,8 @@ var Fa = n("zh"), Ia = {
2607
2607
  video: Fe,
2608
2608
  attachment: pe
2609
2609
  };
2610
- function La({ name: e }) {
2611
- let t = Ia[e];
2610
+ function Ra({ name: e }) {
2611
+ let t = La[e];
2612
2612
  return /* @__PURE__ */ Z(t, {
2613
2613
  "aria-hidden": "true",
2614
2614
  absoluteStrokeWidth: !0,
@@ -2616,7 +2616,7 @@ function La({ name: e }) {
2616
2616
  strokeWidth: 1.6
2617
2617
  });
2618
2618
  }
2619
- function Ra(e, t, n) {
2619
+ function za(e, t, n) {
2620
2620
  return !fn(e) || !n ? {
2621
2621
  visible: !1,
2622
2622
  empty: !1,
@@ -2631,16 +2631,16 @@ function Ra(e, t, n) {
2631
2631
  activeIndex: Math.min(t.length - 1, Math.max(0, e.activeIndex))
2632
2632
  };
2633
2633
  }
2634
- function za(e, t) {
2634
+ function Ba(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 Ba(e, t) {
2640
+ function Va(e, t) {
2641
2641
  return t.slash.uploadKindLabels[e] ?? t.slash.uploadKindLabels.upload;
2642
2642
  }
2643
- function Va({ command: e, messages: t, onBack: n, onSelect: r }) {
2643
+ function Ha({ 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 Va({ command: e, messages: t, onBack: n, onSelect: r }) {
2707
2707
  ]
2708
2708
  });
2709
2709
  }
2710
- function Ha({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
2710
+ function Ua({ 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 Ha({ 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: Ba(a, t) })]
2750
+ }), /* @__PURE__ */ Z("span", { children: Va(a, t) })]
2751
2751
  }),
2752
2752
  /* @__PURE__ */ Q("label", {
2753
2753
  className: "markweave-slash-upload-field",
@@ -2795,10 +2795,10 @@ function Ha({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
2795
2795
  ]
2796
2796
  });
2797
2797
  }
2798
- function Ua({ commands: e, messages: t = Fa, state: n, position: r, inputCommand: i, onActiveIndexChange: a, onInputCommandChange: o, onSelect: s, onUpload: c }) {
2799
- let l = Ra(n, e, r);
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);
2800
2800
  if (!l.visible || !r) return null;
2801
- let u = za(e, t), d = {
2801
+ let u = Ba(e, t), d = {
2802
2802
  left: r.left,
2803
2803
  top: r.top,
2804
2804
  maxHeight: r.maxHeight,
@@ -2820,12 +2820,12 @@ function Ua({ commands: e, messages: t = Fa, 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(Va, {
2823
+ children: i?.inputKind === "emoji" ? /* @__PURE__ */ Z(Ha, {
2824
2824
  command: i,
2825
2825
  messages: t,
2826
2826
  onBack: m,
2827
2827
  onSelect: s
2828
- }) : i?.inputKind === "upload" ? /* @__PURE__ */ Z(Ha, {
2828
+ }) : i?.inputKind === "upload" ? /* @__PURE__ */ Z(Ua, {
2829
2829
  command: i,
2830
2830
  messages: t,
2831
2831
  onBack: m,
@@ -2869,7 +2869,7 @@ function Ua({ commands: e, messages: t = Fa, state: n, position: r, inputCommand
2869
2869
  }
2870
2870
  },
2871
2871
  children: [
2872
- /* @__PURE__ */ Z(La, { name: t.icon }),
2872
+ /* @__PURE__ */ Z(Ra, { 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 Ua({ commands: e, messages: t = Fa, state: n, position: r, inputCommand
2881
2881
  }
2882
2882
  //#endregion
2883
2883
  //#region src/ui/table/TableControls.tsx
2884
- var Wa = n("zh"), Ga = {
2884
+ var Ga = n("zh"), Ka = {
2885
2885
  "move-left": v,
2886
2886
  "move-right": y,
2887
2887
  "move-up": b,
@@ -2901,7 +2901,7 @@ var Wa = n("zh"), Ga = {
2901
2901
  split: ke,
2902
2902
  "ask-ai": xe,
2903
2903
  delete: je
2904
- }, Ka = {
2904
+ }, qa = {
2905
2905
  left: d,
2906
2906
  center: l,
2907
2907
  right: f,
@@ -2909,7 +2909,7 @@ var Wa = n("zh"), Ga = {
2909
2909
  middle: p,
2910
2910
  bottom: m
2911
2911
  };
2912
- function qa({ active: e, editor: t, interactionState: n = Tn, messages: r = Wa, onCopyPayload: i, onCommandResult: a, askAi: o }) {
2912
+ function Ja({ active: e, editor: t, interactionState: n = Tn, messages: r = Ga, 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 qa({ active: e, editor: t, interactionState: n = Tn, messages: r = Wa,
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 = Ga[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 = Ka[e.icon];
3285
3285
  return /* @__PURE__ */ Q("button", {
3286
3286
  type: "button",
3287
3287
  role: "menuitem",
@@ -3407,7 +3407,7 @@ function qa({ active: e, editor: t, interactionState: n = Tn, messages: r = Wa,
3407
3407
  onKeyDown: de,
3408
3408
  children: [
3409
3409
  di.map((e) => {
3410
- let n = Ka[e], i = W?.textAlign === e;
3410
+ let n = qa[e], i = W?.textAlign === e;
3411
3411
  return /* @__PURE__ */ Q("button", {
3412
3412
  type: "button",
3413
3413
  role: "menuitemradio",
@@ -3425,7 +3425,7 @@ function qa({ active: e, editor: t, interactionState: n = Tn, messages: r = Wa,
3425
3425
  }),
3426
3426
  /* @__PURE__ */ Z("div", { className: "markweave-table-submenu-separator" }),
3427
3427
  pi.map((e) => {
3428
- let n = Ka[e], i = W?.verticalAlign === e;
3428
+ let n = qa[e], i = W?.verticalAlign === e;
3429
3429
  return /* @__PURE__ */ Q("button", {
3430
3430
  type: "button",
3431
3431
  role: "menuitemradio",
@@ -3450,7 +3450,7 @@ function qa({ active: e, editor: t, interactionState: n = Tn, messages: r = Wa,
3450
3450
  }
3451
3451
  //#endregion
3452
3452
  //#region src/ui/table/TableSelectionOverlay.tsx
3453
- function Ja({ editor: e, focusState: t }) {
3453
+ function Ya({ 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,16 @@ function Ja({ editor: e, focusState: t }) {
3494
3494
  }
3495
3495
  //#endregion
3496
3496
  //#region src/ui/toc/MarkweaveInnerToc.tsx
3497
- function Ya(e, t) {
3497
+ function Xa(e, t) {
3498
3498
  return `${e.toc.itemAriaLabel}: ${t.text}`;
3499
3499
  }
3500
- function Xa({ editor: e, state: t, messages: n, editable: r, placement: i }) {
3500
+ function Za({ editor: e, state: t, messages: n, editable: r, placement: i }) {
3501
3501
  let a = J(null);
3502
3502
  if (K(() => {
3503
- if (!(i !== "container" || !a.current)) return xi(a.current);
3503
+ if (!(i !== "container" || !a.current)) return Si(a.current);
3504
3504
  }, [i]), !t.items.length) return null;
3505
3505
  let o = (t) => {
3506
- Si(e, t, {
3506
+ Ci(e, t, {
3507
3507
  behavior: "smooth",
3508
3508
  focus: r
3509
3509
  });
@@ -3513,6 +3513,7 @@ function Xa({ editor: e, state: t, messages: n, editable: r, placement: i }) {
3513
3513
  className: "markweave-inner-toc",
3514
3514
  "data-testid": "markweave-inner-toc",
3515
3515
  "aria-label": n.toc.ariaLabel,
3516
+ style: { "--markweave-inner-toc-rail-height": vi(t.items.length) },
3516
3517
  children: [/* @__PURE__ */ Z("div", {
3517
3518
  className: "markweave-inner-toc-rail",
3518
3519
  "aria-hidden": "true",
@@ -3530,7 +3531,7 @@ function Xa({ editor: e, state: t, messages: n, editable: r, placement: i }) {
3530
3531
  "data-level": e.level,
3531
3532
  "data-active": e.active ? "true" : "false",
3532
3533
  "aria-current": e.active ? "location" : void 0,
3533
- "aria-label": Ya(n, e),
3534
+ "aria-label": Xa(n, e),
3534
3535
  title: e.text,
3535
3536
  onClick: () => o(e),
3536
3537
  children: e.text
@@ -3541,7 +3542,7 @@ function Xa({ editor: e, state: t, messages: n, editable: r, placement: i }) {
3541
3542
  }
3542
3543
  //#endregion
3543
3544
  //#region src/MarkweaveEditor.tsx
3544
- var Za = {
3545
+ var Qa = {
3545
3546
  active: !1,
3546
3547
  mode: "outside",
3547
3548
  activeCellPos: null,
@@ -3549,21 +3550,21 @@ var Za = {
3549
3550
  selectedCellCount: 0,
3550
3551
  selectionFrom: 0,
3551
3552
  selectionTo: 0
3552
- }, Qa = {
3553
+ }, $a = {
3553
3554
  active: !1,
3554
3555
  language: Vt.defaultLanguage,
3555
3556
  mermaidPreviewMode: "code",
3556
3557
  pos: null,
3557
3558
  text: ""
3558
- }, $a = Yt({
3559
+ }, eo = Yt({
3559
3560
  active: !1,
3560
3561
  mode: "code",
3561
3562
  source: ""
3562
3563
  });
3563
- function eo(e) {
3564
+ function to(e) {
3564
3565
  return En.getState(e.state) ?? Tn;
3565
3566
  }
3566
- function to(e) {
3567
+ function no(e) {
3567
3568
  if (!e || typeof window > "u") return null;
3568
3569
  let t = e.parentElement;
3569
3570
  for (; t;) {
@@ -3573,18 +3574,18 @@ function to(e) {
3573
3574
  }
3574
3575
  return null;
3575
3576
  }
3576
- function no(e) {
3577
+ function ro(e) {
3577
3578
  return typeof window > "u" || typeof window.requestAnimationFrame != "function" ? globalThis.setTimeout(() => e(0), 0) : window.requestAnimationFrame(e);
3578
3579
  }
3579
- function ro(e) {
3580
+ function io(e) {
3580
3581
  if (typeof window < "u" && typeof window.cancelAnimationFrame == "function") {
3581
3582
  window.cancelAnimationFrame(e);
3582
3583
  return;
3583
3584
  }
3584
3585
  globalThis.clearTimeout(e);
3585
3586
  }
3586
- function io({ 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 } = {}) {
3587
- let j = rt(g), M = wi(_), te = Ci(v), N = bi(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({
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({
3588
3589
  editorMode: j,
3589
3590
  effectiveEditable: P
3590
3591
  });
@@ -3602,7 +3603,7 @@ function io({ askAi: e, ariaLabel: i, autoFocusFirstTableBodyCell: a = !1, autof
3602
3603
  le.current = S;
3603
3604
  let ue = J(k);
3604
3605
  ue.current = k;
3605
- let H = q(() => Xi({
3606
+ let H = q(() => Zi({
3606
3607
  lang: B,
3607
3608
  onImageUpload: (e) => {
3608
3609
  if (se.current) return se.current(e);
@@ -3662,7 +3663,7 @@ function io({ askAi: e, ariaLabel: i, autoFocusFirstTableBodyCell: a = !1, autof
3662
3663
  let r = zt(e);
3663
3664
  r.active && r.language === "mermaid" && ve(r.mermaidPreviewMode);
3664
3665
  }, []), ze = G((e) => {
3665
- Se(eo(e));
3666
+ Se(to(e));
3666
3667
  }, []), X = s({
3667
3668
  shouldRerenderOnTransaction: !1,
3668
3669
  extensions: H,
@@ -3725,7 +3726,7 @@ function io({ askAi: e, ariaLabel: i, autoFocusFirstTableBodyCell: a = !1, autof
3725
3726
  De.current = !0;
3726
3727
  try {
3727
3728
  let n = !0;
3728
- for (let r of Ti(e)) {
3729
+ for (let r of Ei(e)) {
3729
3730
  if (await new Promise((e) => window.setTimeout(e, 0)), t) return;
3730
3731
  let e = X.markdown?.parse(r);
3731
3732
  if (!e) throw Error("Markdown parser is unavailable.");
@@ -3751,11 +3752,11 @@ function io({ askAi: e, ariaLabel: i, autoFocusFirstTableBodyCell: a = !1, autof
3751
3752
  Re,
3752
3753
  ze
3753
3754
  ]), K(() => {
3754
- if (X) return ce.current?.(Ei(X)), () => {
3755
+ if (X) return ce.current?.(Di(X)), () => {
3755
3756
  ce.current?.(null);
3756
3757
  };
3757
3758
  }, [X]), K(() => {
3758
- if (X) return le.current?.(Di(X)), () => {
3759
+ if (X) return le.current?.(Oi(X)), () => {
3759
3760
  le.current?.(null);
3760
3761
  };
3761
3762
  }, [X]), K(() => {
@@ -3817,11 +3818,11 @@ function io({ askAi: e, ariaLabel: i, autoFocusFirstTableBodyCell: a = !1, autof
3817
3818
  Ve,
3818
3819
  Ie
3819
3820
  ]);
3820
- let He = q(() => X ? zt(X) : Qa, [
3821
+ let He = q(() => X ? zt(X) : $a, [
3821
3822
  X,
3822
3823
  Te,
3823
3824
  U
3824
- ]), Ue = q(() => X ? Cn(X.state) : Za, [
3825
+ ]), Ue = q(() => X ? Cn(X.state) : Qa, [
3825
3826
  X,
3826
3827
  Te,
3827
3828
  U,
@@ -3830,7 +3831,7 @@ function io({ askAi: e, ariaLabel: i, autoFocusFirstTableBodyCell: a = !1, autof
3830
3831
  active: Ge,
3831
3832
  mode: _e,
3832
3833
  source: He.text
3833
- }) : $a, [
3834
+ }) : eo, [
3834
3835
  He.text,
3835
3836
  X,
3836
3837
  Ge,
@@ -3839,7 +3840,7 @@ function io({ askAi: e, ariaLabel: i, autoFocusFirstTableBodyCell: a = !1, autof
3839
3840
  X,
3840
3841
  C,
3841
3842
  Te
3842
- ]), Je = q(() => X ? vi(X.state) : gi.items, [X, Te]), Ye = q(() => yi(Je, Ce), [Ce, Je]), Xe = q(() => hi(Je, Ye), [Ye, Je]), Ze = G(() => {
3843
+ ]), Je = q(() => X ? yi(X.state) : gi.items, [X, Te]), Ye = q(() => bi(Je, Ce), [Ce, Je]), Xe = q(() => hi(Je, Ye), [Ye, Je]), Ze = G(() => {
3843
3844
  if (!X || !Je.length) {
3844
3845
  we(null);
3845
3846
  return;
@@ -3849,18 +3850,18 @@ function io({ askAi: e, ariaLabel: i, autoFocusFirstTableBodyCell: a = !1, autof
3849
3850
  }, [X, Je]);
3850
3851
  K(() => {
3851
3852
  we((e) => {
3852
- let t = yi(Je, e);
3853
+ let t = bi(Je, e);
3853
3854
  return e === t ? e : t;
3854
3855
  });
3855
3856
  }, [Je]), K(() => {
3856
3857
  if (!X || !Je.length || typeof window > "u") return;
3857
3858
  let e = null, t = () => {
3858
- e !== null && ro(e), e = no(() => {
3859
+ e !== null && io(e), e = ro(() => {
3859
3860
  e = null, Ze();
3860
3861
  });
3861
- }, n = to(X.view.dom);
3862
+ }, n = no(X.view.dom);
3862
3863
  return window.addEventListener("scroll", t, { passive: !0 }), window.addEventListener("resize", t), n?.addEventListener("scroll", t, { passive: !0 }), t(), () => {
3863
- window.removeEventListener("scroll", t), window.removeEventListener("resize", t), n?.removeEventListener("scroll", t), e !== null && ro(e);
3864
+ window.removeEventListener("scroll", t), window.removeEventListener("resize", t), n?.removeEventListener("scroll", t), e !== null && io(e);
3864
3865
  };
3865
3866
  }, [
3866
3867
  X,
@@ -4076,24 +4077,24 @@ function io({ askAi: e, ariaLabel: i, autoFocusFirstTableBodyCell: a = !1, autof
4076
4077
  actions: nt
4077
4078
  };
4078
4079
  }
4079
- function ao({ className: e, ...t }) {
4080
- let n = io(t);
4080
+ function oo({ className: e, ...t }) {
4081
+ let n = ao(t);
4081
4082
  if (!n.editor) return null;
4082
4083
  let r = [n.frameProps.className, e].filter(Boolean).join(" ");
4083
4084
  return /* @__PURE__ */ Q("section", {
4084
4085
  ...n.frameProps,
4085
4086
  className: r,
4086
4087
  children: [
4087
- n.overlayProps.floatingToolbar ? /* @__PURE__ */ Z(xa, { ...n.overlayProps.floatingToolbar }) : null,
4088
- n.overlayProps.slashCommandMenu ? /* @__PURE__ */ Z(Ua, { ...n.overlayProps.slashCommandMenu }) : null,
4089
- n.overlayProps.tableControls ? /* @__PURE__ */ Z(qa, { ...n.overlayProps.tableControls }) : null,
4090
- n.overlayProps.tableSelectionOverlay ? /* @__PURE__ */ Z(Ja, { ...n.overlayProps.tableSelectionOverlay }) : null,
4091
- n.overlayProps.codeBlockControls ? /* @__PURE__ */ Z($i, { ...n.overlayProps.codeBlockControls }) : null,
4092
- n.overlayProps.innerToc ? /* @__PURE__ */ Z(Xa, { ...n.overlayProps.innerToc }) : null,
4093
- n.overlayProps.mathEditorPopover ? /* @__PURE__ */ Z(Pa, { ...n.overlayProps.mathEditorPopover }) : null,
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,
4094
4095
  /* @__PURE__ */ Z(i, { editor: n.editor })
4095
4096
  ]
4096
4097
  });
4097
4098
  }
4098
4099
  //#endregion
4099
- export { ao as MarkweaveEditor, gt as createMarkweaveAiEditController, Xi as createMarkweaveEditorExtensions, Xi as createMarkweaveReactEditorExtensions, io as useMarkweaveEditorController };
4100
+ export { oo as MarkweaveEditor, gt as createMarkweaveAiEditController, Zi as createMarkweaveEditorExtensions, Zi as createMarkweaveReactEditorExtensions, ao as useMarkweaveEditorController };