@markweave/react 0.1.0 → 0.1.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
@@ -1,9 +1,9 @@
1
1
  import { createMarkweaveEditorExtensions as e } from "markweave/internal/editor-core/create-editor-extensions";
2
2
  import { EditorContent as t, NodeViewWrapper as n, ReactNodeViewRenderer as r, useEditor as i } from "@tiptap/react";
3
- import { AlertTriangle as a, AlignCenter as o, AlignJustify as s, AlignLeft as c, AlignRight as l, Bold as u, Braces as d, Captions as f, Check as p, CheckCircle2 as m, ChevronDown as h, ChevronUp as g, CircleX as _, Code2 as v, CornerDownLeft as y, Download as b, ExternalLink as x, Heading1 as S, Heading2 as C, Heading3 as w, Image as T, ImageUp as E, IndentDecrease as D, IndentIncrease as O, Info as k, Italic as A, Lightbulb as j, Link2 as ee, List as M, ListChecks as N, ListOrdered as P, Minus as te, MoreVertical as ne, Paperclip as F, Quote as I, Replace as re, Sigma as L, SmilePlus as R, Sparkles as ie, Strikethrough as ae, Subscript as oe, Superscript as se, Table2 as ce, Text as z, Trash2 as le, Type as ue, Underline as de, Upload as B, Video as fe } from "lucide-react";
4
- import { useCallback as V, useEffect as H, useLayoutEffect as U, useMemo as W, useRef as G, useState as K, useSyncExternalStore as pe } from "react";
5
- import { detectUploadSource as me, getDirectUploadResult as he, resolveMarkweaveUploadResult as q } from "markweave/internal/plugins/slash-command/upload";
6
- import { MarkweaveCoreImage as ge, MarkweaveCoreVideo as _e, attrsFromMarkweaveImageUploadResult as ve, attrsFromMarkweaveVideoUploadResult as ye, attrsFromMarkweaveVideoUrl as be, clampMarkweaveImageWidth as xe, createMarkweaveImageUploadRequest as J, createMarkweaveVideoUploadRequest as Se, downloadMarkweaveImage as Ce, markweaveVideoIframeAllow as we, normalizeMarkweaveCoreImageAlign as Te, normalizeMarkweaveVideoEmbedUrl as Ee, numberAttribute as De, stringAttribute as Y } from "markweave/internal/plugins/media/core-media-nodes";
3
+ import { AlertTriangle as a, AlignCenter as o, AlignJustify as s, AlignLeft as c, AlignRight as l, Bold as u, Braces as d, Captions as f, Check as p, CheckCircle2 as m, ChevronDown as h, ChevronUp as g, CircleX as _, Code2 as v, CornerDownLeft as y, Download as b, ExternalLink as x, Heading1 as S, Heading2 as C, Heading3 as w, Image as T, ImageUp as E, IndentDecrease as D, IndentIncrease as O, Info as k, Italic as A, Lightbulb as j, Link2 as M, List as N, ListChecks as P, ListOrdered as F, Minus as I, MoreVertical as ee, Paperclip as L, Quote as R, Replace as te, Sigma as z, SmilePlus as ne, Sparkles as re, Strikethrough as ie, Subscript as ae, Superscript as oe, Table2 as se, Text as ce, Trash2 as le, Type as ue, Underline as de, Upload as fe, Video as pe } from "lucide-react";
4
+ import { useCallback as B, useEffect as V, useLayoutEffect as H, useMemo as U, useRef as W, useState as G, useSyncExternalStore as me } from "react";
5
+ import { detectUploadSource as he, getDirectUploadResult as ge, resolveMarkweaveUploadResult as K } from "markweave/internal/plugins/slash-command/upload";
6
+ import { MarkweaveCoreImage as _e, MarkweaveCoreVideo as q, attrsFromMarkweaveImageUploadResult as ve, attrsFromMarkweaveVideoUploadResult as ye, attrsFromMarkweaveVideoUrl as be, clampMarkweaveImageWidth as xe, createMarkweaveImageUploadRequest as Se, createMarkweaveVideoUploadRequest as Ce, downloadMarkweaveImage as J, markweaveVideoIframeAllow as we, normalizeMarkweaveCoreImageAlign as Te, normalizeMarkweaveVideoEmbedUrl as Ee, numberAttribute as De, stringAttribute as Y } from "markweave/internal/plugins/media/core-media-nodes";
7
7
  import { getLocalizedSlashCommandSpecs as Oe, getMarkweaveMessages as ke, normalizeMarkweaveLang as Ae } from "markweave/internal/i18n";
8
8
  import { getMarkweaveEditorModeState as je, isMarkweaveEditorLiveEditable as Me, normalizeMarkweaveEditorMode as Ne, setMarkweaveEditorModeState as Pe, subscribeToMarkweaveEditorMode as Fe } from "markweave/internal/core/editor-mode-state";
9
9
  import { Fragment as X, jsx as Z, jsxs as Q } from "react/jsx-runtime";
@@ -31,31 +31,31 @@ import { applyFloatingToolbarLink as cn, createFloatingToolbarAssistantRequest a
31
31
  import { normalizeMarkdownLinkHref as Dn } from "markweave/internal/plugins/markdown/markdown-input";
32
32
  import { setMarkweaveTableMenuAxisTarget as On } from "markweave/internal/plugins/table/table-clipboard";
33
33
  import { calculateAnchoredTableMenuPosition as kn, calculateTableEdgeHandlePosition as An, canRunTableCommand as jn, executeTableMenuCommand as Mn, formatTableCopyFeedback as Nn, getActiveTableElement as Pn, getAvailableCellMenuCommandSpecs as Fn, getTableAxisTargetRect as In, getTableControlAxisSelectionModel as Ln, getTableEditWithAiRequest as Rn, getTableMenuItemGroup as zn, getTableMenuItemLabel as Bn, getTableMenuItems as Vn, getTableSelectionTargetRect as Hn, measureTableSelectionOverlay as Un, selectTableAxisFromCell as Wn, tableCopyFeedbackTimeoutMs as Gn, tableMenuLabel as Kn } from "markweave/internal/plugins/table/table-ui-model";
34
- import { createMarkweaveTocState as qn, emptyMarkweaveTocState as Jn, getActiveMarkweaveTocId as Yn, getMarkweaveTocItems as Xn, getValidMarkweaveTocActiveId as Zn, scrollToMarkweaveTocItem as Qn } from "markweave/internal/core/toc-state";
34
+ import { createMarkweaveTocState as qn, emptyMarkweaveTocState as Jn, getActiveMarkweaveTocId as Yn, getMarkweaveTocItems as Xn, getValidMarkweaveTocActiveId as Zn, normalizeMarkweaveInnerTocPlacement as Qn, observeMarkweaveInnerTocContainerPosition as $n, scrollToMarkweaveTocItem as er } from "markweave/internal/core/toc-state";
35
35
  //#region src/editor-mode-state.ts
36
- var $n = {
36
+ var tr = {
37
37
  mode: "live",
38
38
  editable: !0
39
39
  };
40
- function er(e) {
41
- return pe((t) => Fe(e, t), () => je(e), () => $n);
40
+ function nr(e) {
41
+ return me((t) => Fe(e, t), () => je(e), () => tr);
42
42
  }
43
43
  //#endregion
44
44
  //#region src/media/image-node.tsx
45
- var tr = Te;
46
- function nr(e) {
45
+ var rr = Te;
46
+ function ir(e) {
47
47
  return e instanceof Element && !!e.closest("[data-markweave-image-ui=\"true\"]");
48
48
  }
49
- function rr(e) {
50
- let { deleteNode: t, editor: r, getPos: i, node: a, selected: o, updateAttributes: s } = e, c = e.extension.options, l = c.messages ?? ke("zh"), u = l.image, d = Me(er(r)), f = Y(a.attrs.src), p = tr(a.attrs.align), m = De(a.attrs.width), h = Y(a.attrs.caption), g = G(null), _ = G(null), [v, y] = K(!1), [b, x] = K(!1), [S, C] = K(!1), [w, T] = K(""), [E, D] = K(null), [O, k] = K(!1), [A, j] = K(!!h), [ee, M] = K(h ?? ""), N = d && (!f || b);
51
- H(() => {
52
- A || M(h ?? "");
49
+ function ar(e) {
50
+ let { deleteNode: t, editor: r, getPos: i, node: a, selected: o, updateAttributes: s } = e, c = e.extension.options, l = c.messages ?? ke("zh"), u = l.image, d = Me(nr(r)), f = Y(a.attrs.src), p = rr(a.attrs.align), m = De(a.attrs.width), h = Y(a.attrs.caption), g = W(null), _ = W(null), [v, y] = G(!1), [b, x] = G(!1), [S, C] = G(!1), [w, T] = G(""), [E, D] = G(null), [O, k] = G(!1), [A, j] = G(!!h), [M, N] = G(h ?? ""), P = d && (!f || b);
51
+ V(() => {
52
+ A || N(h ?? "");
53
53
  }, [h, A]);
54
- let P = () => {
54
+ let F = () => {
55
55
  if (!d) return;
56
56
  let e = i();
57
57
  typeof e == "number" && r.chain().focus().setNodeSelection(e).run();
58
- }, te = () => {
58
+ }, I = () => {
59
59
  if (d) {
60
60
  if (T(""), D(null), C(!1), f) {
61
61
  x(!1);
@@ -63,11 +63,11 @@ function rr(e) {
63
63
  }
64
64
  t();
65
65
  }
66
- }, ne = async (e) => {
66
+ }, ee = async (e) => {
67
67
  if (d) {
68
68
  D(null), k(!0);
69
69
  try {
70
- let t = await q(J(e, f && b ? "image-replace" : "image-insert"), c.onUpload);
70
+ let t = await K(Se(e, f && b ? "image-replace" : "image-insert"), c.onUpload);
71
71
  s(ve(a.attrs, t)), x(!1), T("");
72
72
  } catch (e) {
73
73
  D(e instanceof Error ? e.message : u.uploadFailedError);
@@ -75,31 +75,31 @@ function rr(e) {
75
75
  k(!1), C(!1);
76
76
  }
77
77
  }
78
- }, F = () => {
78
+ }, L = () => {
79
79
  if (d) {
80
80
  if (!w.trim()) {
81
81
  D(u.uploadRequiredError);
82
82
  return;
83
83
  }
84
- ne(me(w));
84
+ ee(he(w));
85
85
  }
86
- }, I = (e) => {
87
- !d || !e || ne({
86
+ }, R = (e) => {
87
+ !d || !e || ee({
88
88
  type: "file",
89
89
  file: e,
90
90
  mimeType: e.type
91
91
  });
92
+ }, te = (e) => {
93
+ R(e.currentTarget.files?.[0] ?? null), e.currentTarget.value = "";
94
+ }, z = (e) => {
95
+ e.preventDefault(), e.stopPropagation(), d && R(e.dataTransfer.files?.[0] ?? null);
96
+ }, ne = () => {
97
+ d && (j((e) => !e), A || N(h ?? ""));
92
98
  }, re = (e) => {
93
- I(e.currentTarget.files?.[0] ?? null), e.currentTarget.value = "";
94
- }, L = (e) => {
95
- e.preventDefault(), e.stopPropagation(), d && I(e.dataTransfer.files?.[0] ?? null);
96
- }, R = () => {
97
- d && (j((e) => !e), A || M(h ?? ""));
98
- }, ie = (e) => {
99
- d && (M(e), s({ caption: e.trim() ? e : null }));
100
- }, ae = (e, t) => {
99
+ d && (N(e), s({ caption: e.trim() ? e : null }));
100
+ }, ie = (e, t) => {
101
101
  if (t.preventDefault(), t.stopPropagation(), !d) return;
102
- P();
102
+ F();
103
103
  let n = g.current;
104
104
  if (!n) return;
105
105
  let r = t.clientX, i = n.getBoundingClientRect().width || m || 320, a = n.closest(".markweave-editor-surface")?.getBoundingClientRect().width ?? n.parentElement?.getBoundingClientRect().width ?? i, o = (t) => {
@@ -117,35 +117,35 @@ function rr(e) {
117
117
  "data-align": p,
118
118
  "data-selected": d && o ? "true" : "false",
119
119
  "data-hovered": d && v ? "true" : "false",
120
- "data-empty": N ? "true" : "false",
120
+ "data-empty": P ? "true" : "false",
121
121
  onPointerEnter: () => y(!0),
122
122
  onPointerLeave: () => y(!1),
123
123
  onMouseDown: (e) => {
124
- d && !nr(e.target) && P();
124
+ d && !ir(e.target) && F();
125
125
  },
126
- children: N ? /* @__PURE__ */ Z(ir, {
126
+ children: P ? /* @__PURE__ */ Z(or, {
127
127
  dragActive: S,
128
128
  error: E,
129
129
  inputValue: w,
130
130
  isSubmitting: O,
131
131
  fileInputRef: _,
132
132
  messages: l,
133
- onCancel: te,
134
- onDrop: L,
133
+ onCancel: I,
134
+ onDrop: z,
135
135
  onDragActiveChange: C,
136
- onFileChange: re,
136
+ onFileChange: te,
137
137
  onInputChange: T,
138
- onSubmit: F
138
+ onSubmit: L
139
139
  }) : /* @__PURE__ */ Q(X, { children: [
140
- d ? /* @__PURE__ */ Z(ar, {
140
+ d ? /* @__PURE__ */ Z(sr, {
141
141
  align: p,
142
142
  captionActive: A || !!h,
143
143
  messages: l,
144
144
  onAlign: (e) => s({ align: e }),
145
- onCaption: R,
145
+ onCaption: ne,
146
146
  onDelete: t,
147
147
  onDownload: () => {
148
- f && Ce(f);
148
+ f && J(f);
149
149
  },
150
150
  onReplace: () => {
151
151
  T(""), D(null), x(!0);
@@ -167,15 +167,15 @@ function rr(e) {
167
167
  "data-testid": "markweave-image-readonly-empty",
168
168
  "aria-hidden": "true"
169
169
  }),
170
- d ? /* @__PURE__ */ Z(sr, {
170
+ d ? /* @__PURE__ */ Z(lr, {
171
171
  side: "left",
172
172
  messages: l,
173
- onPointerDown: ae
173
+ onPointerDown: ie
174
174
  }) : null,
175
- d ? /* @__PURE__ */ Z(sr, {
175
+ d ? /* @__PURE__ */ Z(lr, {
176
176
  side: "right",
177
177
  messages: l,
178
- onPointerDown: ae
178
+ onPointerDown: ie
179
179
  }) : null
180
180
  ]
181
181
  }),
@@ -183,10 +183,10 @@ function rr(e) {
183
183
  className: "markweave-image-caption-input",
184
184
  "data-markweave-image-ui": "true",
185
185
  "data-testid": "markweave-image-caption-input",
186
- value: ee,
186
+ value: M,
187
187
  placeholder: u.captionPlaceholder,
188
188
  "aria-label": u.captionAriaLabel,
189
- onChange: (e) => ie(e.currentTarget.value),
189
+ onChange: (e) => re(e.currentTarget.value),
190
190
  onKeyDown: (e) => {
191
191
  e.key === "Escape" && (e.preventDefault(), j(!1));
192
192
  }
@@ -198,7 +198,7 @@ function rr(e) {
198
198
  ] })
199
199
  });
200
200
  }
201
- function ir({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitting: i, messages: a, onCancel: o, onDragActiveChange: s, onDrop: c, onFileChange: l, onInputChange: u, onSubmit: d }) {
201
+ function or({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitting: i, messages: a, onCancel: o, onDragActiveChange: s, onDrop: c, onFileChange: l, onInputChange: u, onSubmit: d }) {
202
202
  let f = a.image;
203
203
  return /* @__PURE__ */ Q("section", {
204
204
  className: "markweave-image-upload-placeholder",
@@ -280,7 +280,7 @@ function ir({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
280
280
  ]
281
281
  });
282
282
  }
283
- function ar({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i, onDelete: a, onDownload: s, onReplace: u }) {
283
+ function sr({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i, onDelete: a, onDownload: s, onReplace: u }) {
284
284
  let d = n.image;
285
285
  return /* @__PURE__ */ Q("div", {
286
286
  className: "markweave-image-toolbar",
@@ -288,21 +288,21 @@ function ar({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i,
288
288
  "data-markweave-image-ui": "true",
289
289
  "aria-label": d.toolsAriaLabel,
290
290
  children: [
291
- /* @__PURE__ */ Z(or, {
291
+ /* @__PURE__ */ Z(cr, {
292
292
  testId: "markweave-image-align-left",
293
293
  label: d.alignLeft,
294
294
  icon: c,
295
295
  active: e === "left",
296
296
  onClick: () => r("left")
297
297
  }),
298
- /* @__PURE__ */ Z(or, {
298
+ /* @__PURE__ */ Z(cr, {
299
299
  testId: "markweave-image-align-center",
300
300
  label: d.alignCenter,
301
301
  icon: o,
302
302
  active: e === "center",
303
303
  onClick: () => r("center")
304
304
  }),
305
- /* @__PURE__ */ Z(or, {
305
+ /* @__PURE__ */ Z(cr, {
306
306
  testId: "markweave-image-align-right",
307
307
  label: d.alignRight,
308
308
  icon: l,
@@ -313,30 +313,30 @@ function ar({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i,
313
313
  className: "markweave-image-toolbar-divider",
314
314
  "aria-hidden": "true"
315
315
  }),
316
- /* @__PURE__ */ Z(or, {
316
+ /* @__PURE__ */ Z(cr, {
317
317
  testId: "markweave-image-caption",
318
318
  label: d.caption,
319
319
  icon: f,
320
320
  active: t,
321
321
  onClick: i
322
322
  }),
323
- /* @__PURE__ */ Z(or, {
323
+ /* @__PURE__ */ Z(cr, {
324
324
  testId: "markweave-image-download",
325
325
  label: d.download,
326
326
  icon: b,
327
327
  onClick: s
328
328
  }),
329
- /* @__PURE__ */ Z(or, {
329
+ /* @__PURE__ */ Z(cr, {
330
330
  testId: "markweave-image-replace",
331
331
  label: d.replace,
332
- icon: re,
332
+ icon: te,
333
333
  onClick: u
334
334
  }),
335
335
  /* @__PURE__ */ Z("span", {
336
336
  className: "markweave-image-toolbar-divider",
337
337
  "aria-hidden": "true"
338
338
  }),
339
- /* @__PURE__ */ Z(or, {
339
+ /* @__PURE__ */ Z(cr, {
340
340
  testId: "markweave-image-delete",
341
341
  label: d.delete,
342
342
  icon: le,
@@ -345,7 +345,7 @@ function ar({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i,
345
345
  ]
346
346
  });
347
347
  }
348
- function or({ active: e = !1, icon: t, label: n, onClick: r, testId: i }) {
348
+ function cr({ active: e = !1, icon: t, label: n, onClick: r, testId: i }) {
349
349
  return /* @__PURE__ */ Q("button", {
350
350
  type: "button",
351
351
  "aria-label": n,
@@ -364,7 +364,7 @@ function or({ active: e = !1, icon: t, label: n, onClick: r, testId: i }) {
364
364
  })]
365
365
  });
366
366
  }
367
- function sr({ messages: e, onPointerDown: t, side: n }) {
367
+ function lr({ messages: e, onPointerDown: t, side: n }) {
368
368
  return /* @__PURE__ */ Z("button", {
369
369
  type: "button",
370
370
  className: "markweave-image-resize-handle",
@@ -375,7 +375,7 @@ function sr({ messages: e, onPointerDown: t, side: n }) {
375
375
  onPointerDown: (e) => t(n, e)
376
376
  });
377
377
  }
378
- var cr = ge.extend({
378
+ var ur = _e.extend({
379
379
  addOptions() {
380
380
  return {
381
381
  ...this.parent?.(),
@@ -384,28 +384,28 @@ var cr = ge.extend({
384
384
  };
385
385
  },
386
386
  addNodeView() {
387
- return typeof document > "u" ? null : r(rr, { stopEvent: ({ event: e }) => nr(e.target) });
387
+ return typeof document > "u" ? null : r(ar, { stopEvent: ({ event: e }) => ir(e.target) });
388
388
  }
389
389
  });
390
390
  //#endregion
391
391
  //#region src/media/video-node.tsx
392
- function lr(e) {
392
+ function dr(e) {
393
393
  return e instanceof Element && !!e.closest("[data-markweave-video-ui=\"true\"], iframe[data-markweave-video-embed], video[data-markweave-video]");
394
394
  }
395
- function ur(e) {
396
- let { deleteNode: t, editor: r, getPos: i, node: a, selected: o, updateAttributes: s } = e, c = e.extension.options, l = c.messages ?? ke("zh"), u = l.video, d = Me(er(r)), f = Y(a.attrs.src), p = Y(a.attrs.embedUrl), m = Y(a.attrs.provider), h = p ? Ee(p, m) : null, g = Y(a.attrs.mimeType), _ = Y(a.attrs.title), v = G(null), [y, b] = K(!1), [x, S] = K(""), [C, w] = K(null), [T, E] = K(!1), D = d && !f, O = () => {
395
+ function fr(e) {
396
+ let { deleteNode: t, editor: r, getPos: i, node: a, selected: o, updateAttributes: s } = e, c = e.extension.options, l = c.messages ?? ke("zh"), u = l.video, d = Me(nr(r)), f = Y(a.attrs.src), p = Y(a.attrs.embedUrl), m = Y(a.attrs.provider), h = p ? Ee(p, m) : null, g = Y(a.attrs.mimeType), _ = Y(a.attrs.title), v = W(null), [y, b] = G(!1), [x, S] = G(""), [C, w] = G(null), [T, E] = G(!1), D = d && !f, O = () => {
397
397
  if (!d) return;
398
398
  let e = i();
399
399
  typeof e == "number" && r.chain().focus().setNodeSelection(e).run();
400
400
  }, k = (e) => {
401
- d && (lr(e.target) || (e.preventDefault(), O()));
401
+ d && (dr(e.target) || (e.preventDefault(), O()));
402
402
  }, A = (e) => {
403
403
  d && (e.key === "Delete" || e.key === "Backspace") && o && (e.preventDefault(), t());
404
404
  }, j = async (e) => {
405
405
  if (!(!d || !e)) {
406
406
  w(null), E(!0);
407
407
  try {
408
- let t = await q(Se({
408
+ let t = await K(Ce({
409
409
  type: "file",
410
410
  file: e,
411
411
  mimeType: e.type
@@ -424,7 +424,7 @@ function ur(e) {
424
424
  "data-testid": "markweave-video-node",
425
425
  "data-empty": "true",
426
426
  "data-selected": "false",
427
- children: /* @__PURE__ */ Z(dr, {
427
+ children: /* @__PURE__ */ Z(pr, {
428
428
  dragActive: y,
429
429
  error: C,
430
430
  fileInputRef: v,
@@ -503,7 +503,7 @@ function ur(e) {
503
503
  })
504
504
  });
505
505
  }
506
- function dr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitting: i, messages: a, onCancel: o, onDragActiveChange: s, onDrop: c, onFileChange: l, onInputChange: u, onSubmit: d }) {
506
+ function pr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitting: i, messages: a, onCancel: o, onDragActiveChange: s, onDrop: c, onFileChange: l, onInputChange: u, onSubmit: d }) {
507
507
  let f = a.video;
508
508
  return /* @__PURE__ */ Q("section", {
509
509
  className: "markweave-video-upload-placeholder",
@@ -530,7 +530,7 @@ function dr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
530
530
  /* @__PURE__ */ Z("div", {
531
531
  className: "markweave-video-upload-icon",
532
532
  "aria-hidden": "true",
533
- children: /* @__PURE__ */ Z(fe, {
533
+ children: /* @__PURE__ */ Z(pe, {
534
534
  size: 46,
535
535
  strokeWidth: 1.6
536
536
  })
@@ -565,7 +565,7 @@ function dr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
565
565
  "data-testid": "markweave-video-upload-submit",
566
566
  disabled: i || !r.trim(),
567
567
  onClick: d,
568
- children: [/* @__PURE__ */ Z(B, {
568
+ children: [/* @__PURE__ */ Z(fe, {
569
569
  size: 16,
570
570
  strokeWidth: 1.8
571
571
  }), a.common.insert]
@@ -585,7 +585,7 @@ function dr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
585
585
  ]
586
586
  });
587
587
  }
588
- var fr = _e.extend({
588
+ var mr = q.extend({
589
589
  addOptions() {
590
590
  return {
591
591
  ...this.parent?.(),
@@ -594,17 +594,17 @@ var fr = _e.extend({
594
594
  };
595
595
  },
596
596
  addNodeView() {
597
- return typeof document > "u" ? null : r(ur, { stopEvent: ({ event: e }) => lr(e.target) });
597
+ return typeof document > "u" ? null : r(fr, { stopEvent: ({ event: e }) => dr(e.target) });
598
598
  }
599
599
  });
600
600
  //#endregion
601
601
  //#region src/create-editor-extensions.ts
602
- function pr(t = {}) {
602
+ function hr(t = {}) {
603
603
  return e({
604
604
  lang: t.lang,
605
605
  mediaExtensions: Ie({
606
- image: cr,
607
- video: fr,
606
+ image: ur,
607
+ video: mr,
608
608
  lang: t.lang,
609
609
  onImageUpload: t.onImageUpload,
610
610
  onVideoUpload: t.onVideoUpload
@@ -613,7 +613,7 @@ function pr(t = {}) {
613
613
  }
614
614
  //#endregion
615
615
  //#region src/ui/codeblock/CodeBlockControls.tsx
616
- function mr(e) {
616
+ function gr(e) {
617
617
  return e === "clipboard" ? /* @__PURE__ */ Q(X, { children: [/* @__PURE__ */ Z("path", { d: "M9 4.5h6a1.5 1.5 0 0 1 1.5 1.5v11A1.5 1.5 0 0 1 15 18.5H7A1.5 1.5 0 0 1 5.5 17V6A1.5 1.5 0 0 1 7 4.5h2" }), /* @__PURE__ */ Z("path", { d: "M8.5 5.5v-1A1.5 1.5 0 0 1 10 3h2a1.5 1.5 0 0 1 1.5 1.5v1h-5Z" })] }) : e === "search" ? /* @__PURE__ */ Q(X, { children: [/* @__PURE__ */ Z("circle", {
618
618
  cx: "10",
619
619
  cy: "10",
@@ -650,7 +650,7 @@ function mr(e) {
650
650
  /* @__PURE__ */ Z("path", { d: "m14 14 4 4" })
651
651
  ] }) : e === "reset" ? /* @__PURE__ */ Q(X, { children: [/* @__PURE__ */ Z("path", { d: "M6.5 8.5A6 6 0 1 1 6 15" }), /* @__PURE__ */ Z("path", { d: "M6.5 8.5H3.5v-3" })] }) : /* @__PURE__ */ Z("path", { d: "m6 9 6 6 6-6" });
652
652
  }
653
- function hr({ icon: e }) {
653
+ function _r({ icon: e }) {
654
654
  return /* @__PURE__ */ Z("svg", {
655
655
  viewBox: "0 0 24 24",
656
656
  "aria-hidden": "true",
@@ -661,23 +661,23 @@ function hr({ icon: e }) {
661
661
  strokeLinecap: "round",
662
662
  strokeLinejoin: "round",
663
663
  strokeWidth: "1.8",
664
- children: mr(e)
664
+ children: gr(e)
665
665
  })
666
666
  });
667
667
  }
668
- function gr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, readOnly: i = !1 }) {
669
- let a = G(null), o = G(null), s = G(null), c = G({
668
+ function vr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, readOnly: i = !1 }) {
669
+ let a = W(null), o = W(null), s = W(null), c = W({
670
670
  active: !1,
671
671
  lastX: 0,
672
672
  lastY: 0
673
- }), [l, u] = K(null), [d, f] = K(null), [p, m] = K([]), [h, g] = K(null), [_, v] = K(!1), [y, b] = K(""), [x, S] = K(null), [C, w] = K(!1), [T, E] = K(null), [D, O] = K(null), [k, A] = K(!1), [j, ee] = K(0), [M, N] = K(0), P = et(t), te = Qt(t, l), ne = !i && e && P.active && P.pos !== null ? {
674
- ...P,
675
- pos: P.pos,
673
+ }), [l, u] = G(null), [d, f] = G(null), [p, m] = G([]), [h, g] = G(null), [_, v] = G(!1), [y, b] = G(""), [x, S] = G(null), [C, w] = G(!1), [T, E] = G(null), [D, O] = G(null), [k, A] = G(!1), [j, M] = G(0), [N, P] = G(0), F = et(t), I = Qt(t, l), ee = !i && e && F.active && F.pos !== null ? {
674
+ ...F,
675
+ pos: F.pos,
676
676
  active: !0
677
- } : null, F = te ?? ne, I = F !== null, re = F?.language === "mermaid", L = nn(t, F), R = I && F !== null && !L, ie = !i, ae = Kt(F ? F.language : "text"), oe = x?.status ?? "idle", se = F?.mermaidPreviewMode ?? n, ce = re && se === "preview", z = en(t), le = `${M}|${z.map((e) => `${e.pos}:${e.mermaidPreviewMode}:${e.text.length}`).join("|")}`, ue = W(() => Xt(y.trim().toLowerCase()), [y]);
678
- if (H(() => {
677
+ } : null, L = I ?? ee, R = L !== null, te = L?.language === "mermaid", z = nn(t, L), ne = R && L !== null && !z, re = !i, ie = Kt(L ? L.language : "text"), ae = x?.status ?? "idle", oe = L?.mermaidPreviewMode ?? n, se = te && oe === "preview", ce = en(t), le = `${N}|${ce.map((e) => `${e.pos}:${e.mermaidPreviewMode}:${e.text.length}`).join("|")}`, ue = U(() => Xt(y.trim().toLowerCase()), [y]);
678
+ if (V(() => {
679
679
  i && (v(!1), b(""));
680
- }, [i]), H(() => {
680
+ }, [i]), V(() => {
681
681
  if (!x) return;
682
682
  let e = window.setTimeout(() => {
683
683
  S(null);
@@ -685,21 +685,21 @@ function gr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
685
685
  return () => {
686
686
  window.clearTimeout(e);
687
687
  };
688
- }, [x]), H(() => {
688
+ }, [x]), V(() => {
689
689
  S(null), v(!1), b(""), E(null), O(null), A(!1);
690
690
  }, [
691
691
  e,
692
- F?.language,
693
- F?.pos,
694
- F?.text
695
- ]), H(() => {
692
+ L?.language,
693
+ L?.pos,
694
+ L?.text
695
+ ]), V(() => {
696
696
  let e = ({ transaction: e }) => {
697
- e.getMeta(Qe) && ee((e) => e + 1);
697
+ e.getMeta(Qe) && M((e) => e + 1);
698
698
  };
699
699
  return t.on("transaction", e), () => {
700
700
  t.off("transaction", e);
701
701
  };
702
- }, [t]), H(() => {
702
+ }, [t]), V(() => {
703
703
  let e = t.view.dom.closest(".markweave-editor-frame");
704
704
  if (!e) return;
705
705
  let n = (e) => {
@@ -712,9 +712,9 @@ function gr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
712
712
  return e.addEventListener("mousemove", n), e.addEventListener("mouseleave", r), () => {
713
713
  e.removeEventListener("mousemove", n), e.removeEventListener("mouseleave", r);
714
714
  };
715
- }, [t, _]), H(() => {
715
+ }, [t, _]), V(() => {
716
716
  _ && s.current?.focus({ preventScroll: !0 });
717
- }, [_]), H(() => {
717
+ }, [_]), V(() => {
718
718
  if (!T) return;
719
719
  let e = (e) => {
720
720
  e.key === "Escape" && (E(null), O(null), A(!1), c.current = {
@@ -726,8 +726,8 @@ function gr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
726
726
  return document.addEventListener("keydown", e), () => {
727
727
  document.removeEventListener("keydown", e);
728
728
  };
729
- }, [t, T]), H(() => {
730
- if (!I || !_) return;
729
+ }, [t, T]), V(() => {
730
+ if (!R || !_) return;
731
731
  let e = (e) => {
732
732
  e.key === "Escape" && (v(!1), t.view.focus());
733
733
  }, n = (e) => {
@@ -737,22 +737,22 @@ function gr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
737
737
  document.removeEventListener("keydown", e), document.removeEventListener("mousedown", n);
738
738
  };
739
739
  }, [
740
- I,
740
+ R,
741
741
  t,
742
742
  _
743
- ]), U(() => {
743
+ ]), H(() => {
744
744
  let e = () => {
745
745
  let e = a.current;
746
746
  if (!e) return;
747
- if (!$t(e) || z.length === 0) {
747
+ if (!$t(e) || ce.length === 0) {
748
748
  m([]);
749
749
  return;
750
750
  }
751
- let n = e.getBoundingClientRect(), r = z.flatMap((e) => {
751
+ let n = e.getBoundingClientRect(), r = ce.flatMap((e) => {
752
752
  let r = Yt(Jt(t, e.pos, e.mermaidPreviewMode), n);
753
753
  return r ? [Wt(e, r, n)] : [];
754
754
  });
755
- m((e) => rn(e, r, z.map((e) => e.pos)));
755
+ m((e) => rn(e, r, ce.map((e) => e.pos)));
756
756
  };
757
757
  e();
758
758
  let n = window.requestAnimationFrame(e);
@@ -763,20 +763,20 @@ function gr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
763
763
  j,
764
764
  t,
765
765
  le
766
- ]), U(() => {
767
- if (!R || !F) {
766
+ ]), H(() => {
767
+ if (!ne || !L) {
768
768
  f(null), g(null);
769
769
  return;
770
770
  }
771
771
  let e = () => {
772
772
  let e = a.current;
773
773
  if (!e) return;
774
- let n = Jt(t, F.pos, se), r = e.getBoundingClientRect(), i = Yt(n, r);
774
+ let n = Jt(t, L.pos, oe), r = e.getBoundingClientRect(), i = Yt(n, r);
775
775
  if (!i) {
776
- f((e) => e?.pos === F.pos ? e : null), g((e) => _ ? e : null);
776
+ f((e) => e?.pos === L.pos ? e : null), g((e) => _ ? e : null);
777
777
  return;
778
778
  }
779
- let s = Ht(F.pos, i, r);
779
+ let s = Ht(L.pos, i, r);
780
780
  if (f(s), _ && o.current) {
781
781
  let e = o.current.getBoundingClientRect();
782
782
  g(Rt({
@@ -791,72 +791,72 @@ function gr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
791
791
  window.removeEventListener("resize", e), window.removeEventListener("scroll", e, !0);
792
792
  };
793
793
  }, [
794
- R,
794
+ ne,
795
795
  j,
796
- F?.pos,
796
+ L?.pos,
797
797
  t,
798
798
  _,
799
- se
800
- ]), !R && z.length === 0 && !T) return null;
799
+ oe
800
+ ]), !ne && ce.length === 0 && !T) return null;
801
801
  let de = d ? {
802
802
  top: d.top,
803
803
  right: d.right
804
- } : void 0, B = async () => {
804
+ } : void 0, fe = async () => {
805
805
  if (i) {
806
- if (!F) return;
807
- let e = await Vt(F.text);
808
- S(tt(F, e ? "copied" : "failed"));
806
+ if (!L) return;
807
+ let e = await Vt(L.text);
808
+ S(tt(L, e ? "copied" : "failed"));
809
809
  return;
810
810
  }
811
- if (!Gt(t, F)) return;
811
+ if (!Gt(t, L)) return;
812
812
  let e = await $e(t);
813
813
  S(tt(et(t), e ? "copied" : "failed")), t.view.focus();
814
- }, fe = (e, n) => {
814
+ }, pe = (e, n) => {
815
815
  if (i) {
816
- ct(t, e.pos, n) && N((e) => e + 1);
816
+ ct(t, e.pos, n) && P((e) => e + 1);
817
817
  return;
818
818
  }
819
- let a = P.active && P.pos === e.pos;
820
- at(t, e.pos, n) && (r(n), N((e) => e + 1), a && t.view.focus());
821
- }, V = (e) => {
822
- if (i || !F) return;
823
- let n = P.active && P.pos === F.pos;
824
- it(t, F.pos, e) && (e === "mermaid" && at(t, F.pos, "preview") && r("preview"), v(!1), b(""), N((e) => e + 1), n && t.view.focus());
825
- }, pe = () => {
826
- i || !F || rt(t, F.pos, !L) && (ee((e) => e + 1), u(null));
819
+ let a = F.active && F.pos === e.pos;
820
+ at(t, e.pos, n) && (r(n), P((e) => e + 1), a && t.view.focus());
821
+ }, B = (e) => {
822
+ if (i || !L) return;
823
+ let n = F.active && F.pos === L.pos;
824
+ it(t, L.pos, e) && (e === "mermaid" && at(t, L.pos, "preview") && r("preview"), v(!1), b(""), P((e) => e + 1), n && t.view.focus());
827
825
  }, me = () => {
828
- if (!F) return;
829
- let e = tn(t, F.pos);
826
+ i || !L || rt(t, L.pos, !z) && (M((e) => e + 1), u(null));
827
+ }, he = () => {
828
+ if (!L) return;
829
+ let e = tn(t, L.pos);
830
830
  if (!e) return;
831
831
  let n = new Blob([e], { type: "image/svg+xml" }), r = URL.createObjectURL(n), i = document.createElement("a");
832
832
  i.href = r, i.download = "markweave-mermaid.svg", i.click(), URL.revokeObjectURL(r), t.view.focus();
833
- }, he = () => {
834
- if (!F) return;
835
- let e = tn(t, F.pos);
833
+ }, ge = () => {
834
+ if (!L) return;
835
+ let e = tn(t, L.pos);
836
836
  e && (E(Ut(e)), O(null), A(!1), c.current = {
837
837
  active: !1,
838
838
  lastX: 0,
839
839
  lastY: 0
840
840
  });
841
- }, q = () => {
841
+ }, K = () => {
842
842
  E(null), O(null), A(!1), c.current = {
843
843
  active: !1,
844
844
  lastX: 0,
845
845
  lastY: 0
846
846
  }, t.view.focus();
847
- }, ge = (e) => {
847
+ }, _e = (e) => {
848
848
  E((t) => t && {
849
849
  ...t,
850
850
  scale: zt(t.scale + e)
851
851
  });
852
- }, _e = () => {
852
+ }, q = () => {
853
853
  E((e) => e && Ut(e.svg)), c.current = {
854
854
  active: !1,
855
855
  lastX: 0,
856
856
  lastY: 0
857
857
  }, A(!1);
858
858
  }, ve = (e) => {
859
- e.preventDefault(), ge(e.deltaY < 0 ? an : -an);
859
+ e.preventDefault(), _e(e.deltaY < 0 ? an : -an);
860
860
  }, ye = (e) => {
861
861
  e.button === 0 && (e.preventDefault(), c.current = {
862
862
  active: !0,
@@ -885,7 +885,7 @@ function gr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
885
885
  "data-testid": "markweave-codeblock-overlay",
886
886
  "data-read-only": i ? "true" : "false",
887
887
  children: [
888
- z.map((e) => {
888
+ ce.map((e) => {
889
889
  let t = p.find((t) => t.pos === e.pos);
890
890
  return /* @__PURE__ */ Z("div", {
891
891
  className: "markweave-mermaid-tabs",
@@ -901,16 +901,16 @@ function gr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
901
901
  "data-testid": `markweave-mermaid-mode-${t}`,
902
902
  "data-active": e.mermaidPreviewMode === t,
903
903
  onMouseDown: (e) => e.preventDefault(),
904
- onClick: () => fe(e, t),
904
+ onClick: () => pe(e, t),
905
905
  children: t === "code" ? "Code" : "Preview"
906
906
  }, t))
907
907
  }, e.pos);
908
908
  }),
909
- R ? /* @__PURE__ */ Q("div", {
909
+ ne ? /* @__PURE__ */ Q("div", {
910
910
  className: "markweave-codeblock-controls",
911
911
  "data-testid": "markweave-codeblock-controls",
912
912
  "data-positioned": d ? "true" : "false",
913
- "data-collapsed": L ? "true" : "false",
913
+ "data-collapsed": z ? "true" : "false",
914
914
  "data-read-only": i ? "true" : "false",
915
915
  "aria-label": "Code block controls",
916
916
  style: de,
@@ -919,7 +919,7 @@ function gr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
919
919
  className: "markweave-codeblock-language-button markweave-codeblock-language-label",
920
920
  "aria-label": "Code block language",
921
921
  "data-testid": "markweave-codeblock-language",
922
- children: /* @__PURE__ */ Z("span", { children: ae })
922
+ children: /* @__PURE__ */ Z("span", { children: ie })
923
923
  }) : /* @__PURE__ */ Q("button", {
924
924
  ref: o,
925
925
  type: "button",
@@ -930,18 +930,18 @@ function gr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
930
930
  "data-testid": "markweave-codeblock-language",
931
931
  onMouseDown: (e) => e.preventDefault(),
932
932
  onClick: () => v((e) => !e),
933
- children: [/* @__PURE__ */ Z("span", { children: ae }), /* @__PURE__ */ Z(hr, { icon: "chevron" })]
933
+ children: [/* @__PURE__ */ Z("span", { children: ie }), /* @__PURE__ */ Z(_r, { icon: "chevron" })]
934
934
  }),
935
- ie ? /* @__PURE__ */ Z("button", {
935
+ re ? /* @__PURE__ */ Z("button", {
936
936
  type: "button",
937
937
  className: "markweave-codeblock-icon-button markweave-codeblock-collapse-button",
938
- "aria-label": L ? "Expand code block" : "Collapse code block",
939
- title: L ? "Expand code block" : "Collapse code block",
938
+ "aria-label": z ? "Expand code block" : "Collapse code block",
939
+ title: z ? "Expand code block" : "Collapse code block",
940
940
  "data-testid": "markweave-codeblock-collapse",
941
- "data-collapsed": L ? "true" : "false",
941
+ "data-collapsed": z ? "true" : "false",
942
942
  onMouseDown: (e) => e.preventDefault(),
943
- onClick: pe,
944
- children: /* @__PURE__ */ Z(hr, { icon: "chevron" })
943
+ onClick: me,
944
+ children: /* @__PURE__ */ Z(_r, { icon: "chevron" })
945
945
  }) : null,
946
946
  /* @__PURE__ */ Q("span", {
947
947
  className: "markweave-codeblock-copy-wrap",
@@ -950,14 +950,14 @@ function gr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
950
950
  className: "markweave-codeblock-icon-button",
951
951
  "aria-label": "Copy to clipboard",
952
952
  "data-testid": "markweave-codeblock-copy",
953
- "data-copy-state": oe,
953
+ "data-copy-state": ae,
954
954
  onMouseDown: (e) => e.preventDefault(),
955
955
  onMouseEnter: () => w(!0),
956
956
  onMouseLeave: () => w(!1),
957
957
  onFocus: () => w(!0),
958
958
  onBlur: () => w(!1),
959
- onClick: B,
960
- children: /* @__PURE__ */ Z(hr, { icon: oe === "copied" ? "check" : "clipboard" })
959
+ onClick: fe,
960
+ children: /* @__PURE__ */ Z(_r, { icon: ae === "copied" ? "check" : "clipboard" })
961
961
  }), C ? /* @__PURE__ */ Z("span", {
962
962
  className: "markweave-codeblock-tooltip",
963
963
  role: "tooltip",
@@ -965,7 +965,7 @@ function gr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
965
965
  children: "Copy to clipboard"
966
966
  }) : null]
967
967
  }),
968
- re && se === "preview" ? /* @__PURE__ */ Q("div", {
968
+ te && oe === "preview" ? /* @__PURE__ */ Q("div", {
969
969
  className: "markweave-mermaid-preview-actions",
970
970
  "data-testid": "markweave-mermaid-preview-actions",
971
971
  children: [/* @__PURE__ */ Z("button", {
@@ -973,24 +973,24 @@ function gr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
973
973
  className: "markweave-codeblock-icon-button",
974
974
  "aria-label": "Fullscreen Mermaid preview",
975
975
  "data-testid": "markweave-mermaid-fullscreen",
976
- disabled: !ce,
976
+ disabled: !se,
977
977
  onMouseDown: (e) => e.preventDefault(),
978
- onClick: he,
979
- children: /* @__PURE__ */ Z(hr, { icon: "expand" })
978
+ onClick: ge,
979
+ children: /* @__PURE__ */ Z(_r, { icon: "expand" })
980
980
  }), /* @__PURE__ */ Z("button", {
981
981
  type: "button",
982
982
  className: "markweave-codeblock-icon-button",
983
983
  "aria-label": "Download Mermaid SVG",
984
984
  "data-testid": "markweave-mermaid-download",
985
- disabled: !ce,
985
+ disabled: !se,
986
986
  onMouseDown: (e) => e.preventDefault(),
987
- onClick: me,
988
- children: /* @__PURE__ */ Z(hr, { icon: "download" })
987
+ onClick: he,
988
+ children: /* @__PURE__ */ Z(_r, { icon: "download" })
989
989
  })]
990
990
  }) : null
991
991
  ]
992
992
  }) : null,
993
- ie && R && _ ? /* @__PURE__ */ Q("div", {
993
+ re && ne && _ ? /* @__PURE__ */ Q("div", {
994
994
  className: "markweave-codeblock-language-menu",
995
995
  role: "listbox",
996
996
  "aria-label": "Code block languages",
@@ -1011,11 +1011,11 @@ function gr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1011
1011
  onKeyDown: (e) => {
1012
1012
  e.key === "Escape" && (e.preventDefault(), v(!1), t.view.focus());
1013
1013
  }
1014
- }), /* @__PURE__ */ Z(hr, { icon: "search" })]
1014
+ }), /* @__PURE__ */ Z(_r, { icon: "search" })]
1015
1015
  }), /* @__PURE__ */ Z("div", {
1016
1016
  className: "markweave-codeblock-language-list",
1017
1017
  children: ue.map((e) => {
1018
- let t = e.language === F.language;
1018
+ let t = e.language === L.language;
1019
1019
  return /* @__PURE__ */ Q("button", {
1020
1020
  type: "button",
1021
1021
  role: "option",
@@ -1023,8 +1023,8 @@ function gr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1023
1023
  "data-testid": `markweave-codeblock-language-option-${e.language}`,
1024
1024
  "data-active": t ? "true" : "false",
1025
1025
  onMouseDown: (e) => e.preventDefault(),
1026
- onClick: () => V(e.language),
1027
- children: [/* @__PURE__ */ Z("span", { children: e.label }), t ? /* @__PURE__ */ Z(hr, { icon: "check" }) : null]
1026
+ onClick: () => B(e.language),
1027
+ children: [/* @__PURE__ */ Z("span", { children: e.label }), t ? /* @__PURE__ */ Z(_r, { icon: "check" }) : null]
1028
1028
  }, e.language);
1029
1029
  })
1030
1030
  })]
@@ -1049,8 +1049,8 @@ function gr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1049
1049
  onMouseLeave: () => O(null),
1050
1050
  onFocus: () => O("zoom-out"),
1051
1051
  onBlur: () => O(null),
1052
- onClick: () => ge(-an),
1053
- children: /* @__PURE__ */ Z(hr, { icon: "zoomOut" })
1052
+ onClick: () => _e(-an),
1053
+ children: /* @__PURE__ */ Z(_r, { icon: "zoomOut" })
1054
1054
  }),
1055
1055
  /* @__PURE__ */ Z("span", {
1056
1056
  className: "markweave-mermaid-fullscreen-zoom-label",
@@ -1066,8 +1066,8 @@ function gr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1066
1066
  onMouseLeave: () => O(null),
1067
1067
  onFocus: () => O("zoom-in"),
1068
1068
  onBlur: () => O(null),
1069
- onClick: () => ge(an),
1070
- children: /* @__PURE__ */ Z(hr, { icon: "zoomIn" })
1069
+ onClick: () => _e(an),
1070
+ children: /* @__PURE__ */ Z(_r, { icon: "zoomIn" })
1071
1071
  }),
1072
1072
  /* @__PURE__ */ Z("button", {
1073
1073
  type: "button",
@@ -1078,8 +1078,8 @@ function gr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1078
1078
  onMouseLeave: () => O(null),
1079
1079
  onFocus: () => O("reset"),
1080
1080
  onBlur: () => O(null),
1081
- onClick: _e,
1082
- children: /* @__PURE__ */ Z(hr, { icon: "reset" })
1081
+ onClick: q,
1082
+ children: /* @__PURE__ */ Z(_r, { icon: "reset" })
1083
1083
  }),
1084
1084
  D ? /* @__PURE__ */ Z("span", {
1085
1085
  className: "markweave-mermaid-fullscreen-tooltip",
@@ -1094,8 +1094,8 @@ function gr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1094
1094
  className: "markweave-mermaid-fullscreen-close",
1095
1095
  "aria-label": "Close fullscreen Mermaid preview",
1096
1096
  "data-testid": "markweave-mermaid-fullscreen-close",
1097
- onClick: q,
1098
- children: /* @__PURE__ */ Z(hr, { icon: "close" })
1097
+ onClick: K,
1098
+ children: /* @__PURE__ */ Z(_r, { icon: "close" })
1099
1099
  }),
1100
1100
  /* @__PURE__ */ Z("div", {
1101
1101
  className: "markweave-mermaid-fullscreen-viewport",
@@ -1126,25 +1126,25 @@ function gr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1126
1126
  }
1127
1127
  //#endregion
1128
1128
  //#region src/ui/floating-toolbar/FloatingToolbar.tsx
1129
- var _r = ke("zh");
1130
- function vr() {
1129
+ var yr = ke("zh");
1130
+ function br() {
1131
1131
  return typeof performance > "u" ? Date.now() : performance.now();
1132
1132
  }
1133
- function yr(e, t) {
1133
+ function xr(e, t) {
1134
1134
  return {
1135
1135
  "--markweave-toolbar-motion-duration": `${e.motionDurationMs}ms`,
1136
1136
  "--markweave-toolbar-motion-easing": e.motionEasing,
1137
1137
  marginLeft: t === 0 ? void 0 : `${t}px`
1138
1138
  };
1139
1139
  }
1140
- function br(e, t) {
1140
+ function Sr(e, t) {
1141
1141
  let n = e?.getBoundingClientRect().height ?? 0, r = t?.getBoundingClientRect().height ?? 0;
1142
1142
  return Math.max(n, r, 44);
1143
1143
  }
1144
- function xr(e) {
1144
+ function Cr(e) {
1145
1145
  if (e !== null) return { "--markweave-floating-toolbar-tooltip-left": `${e}px` };
1146
1146
  }
1147
- function Sr(e, t, n, r) {
1147
+ function wr(e, t, n, r) {
1148
1148
  let i = {
1149
1149
  bottom: t + r,
1150
1150
  height: r,
@@ -1160,26 +1160,26 @@ function Sr(e, t, n, r) {
1160
1160
  toJSON: () => i
1161
1161
  };
1162
1162
  }
1163
- function Cr(e) {
1163
+ function Tr(e) {
1164
1164
  return e.width > 0 && e.height > 0;
1165
1165
  }
1166
- function wr(e) {
1166
+ function Er(e) {
1167
1167
  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));
1168
- return Sr(t, n, r - t, i - n);
1168
+ return wr(t, n, r - t, i - n);
1169
1169
  }
1170
- function Tr(e, t) {
1170
+ function Dr(e, t) {
1171
1171
  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;
1172
1172
  return r(t.anchorNode) && r(t.focusNode);
1173
1173
  }
1174
- function Er(e) {
1174
+ function Or(e) {
1175
1175
  if (typeof e.getClientRects != "function") return null;
1176
- let t = Array.from(e.getClientRects()).filter(Cr).map((e) => Sr(e.left, e.top, e.width, e.height));
1176
+ let t = Array.from(e.getClientRects()).filter(Tr).map((e) => wr(e.left, e.top, e.width, e.height));
1177
1177
  if (t.length > 0) return t;
1178
1178
  if (typeof e.getBoundingClientRect != "function") return null;
1179
1179
  let n = e.getBoundingClientRect();
1180
- return Cr(n) ? [Sr(n.left, n.top, n.width, n.height)] : null;
1180
+ return Tr(n) ? [wr(n.left, n.top, n.width, n.height)] : null;
1181
1181
  }
1182
- function Dr(e, t) {
1182
+ function kr(e, t) {
1183
1183
  if (t.rangeCount === 0) return null;
1184
1184
  let n = t.getRangeAt(0);
1185
1185
  try {
@@ -1192,8 +1192,8 @@ function Dr(e, t) {
1192
1192
  return null;
1193
1193
  }
1194
1194
  }
1195
- function Or(e, t) {
1196
- let n = Dr(e, t);
1195
+ function Ar(e, t) {
1196
+ let n = kr(e, t);
1197
1197
  if (!n) return !1;
1198
1198
  let { selection: r } = e.state, i = {
1199
1199
  from: Math.min(r.from, r.to),
@@ -1201,51 +1201,51 @@ function Or(e, t) {
1201
1201
  };
1202
1202
  return n.from === i.from && n.to === i.to;
1203
1203
  }
1204
- function kr(e) {
1204
+ function jr(e) {
1205
1205
  let t = e.view.dom.ownerDocument.getSelection();
1206
- return !t || t.rangeCount === 0 || t.isCollapsed || !Tr(e, t) || !Or(e, t) ? null : Er(t.getRangeAt(0));
1206
+ return !t || t.rangeCount === 0 || t.isCollapsed || !Dr(e, t) || !Ar(e, t) ? null : Or(t.getRangeAt(0));
1207
1207
  }
1208
- function Ar(e) {
1208
+ function Mr(e) {
1209
1209
  let { selection: t } = e.state;
1210
1210
  if (t.empty) return null;
1211
1211
  let n = Math.min(t.from, t.to), r = Math.max(t.from, t.to);
1212
1212
  try {
1213
1213
  let t = e.view.domAtPos(n), i = e.view.domAtPos(r), a = e.view.dom.ownerDocument.createRange();
1214
- return a.setStart(t.node, t.offset), a.setEnd(i.node, i.offset), Er(a);
1214
+ return a.setStart(t.node, t.offset), a.setEnd(i.node, i.offset), Or(a);
1215
1215
  } catch {
1216
1216
  return null;
1217
1217
  }
1218
1218
  }
1219
- function jr(e) {
1219
+ function Nr(e) {
1220
1220
  let { selection: t } = e.state;
1221
1221
  if (t.empty) return null;
1222
- 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 = Sr(c, o, Math.max(i.right, a.right) - c, s - o);
1223
- return Cr(l) ? [l] : null;
1222
+ 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 = wr(c, o, Math.max(i.right, a.right) - c, s - o);
1223
+ return Tr(l) ? [l] : null;
1224
1224
  }
1225
- function Mr(e) {
1226
- return kr(e) ?? Ar(e) ?? jr(e);
1225
+ function Pr(e) {
1226
+ return jr(e) ?? Mr(e) ?? Nr(e);
1227
1227
  }
1228
- function Nr(e) {
1229
- let t = Mr(e);
1230
- return t && t.length > 0 ? wr(t) : null;
1228
+ function Fr(e) {
1229
+ let t = Pr(e);
1230
+ return t && t.length > 0 ? Er(t) : null;
1231
1231
  }
1232
- function Pr(e) {
1232
+ function Ir(e) {
1233
1233
  return {
1234
- getBoundingClientRect: () => Nr(e) ?? Sr(0, 0, 0, 0),
1235
- getClientRects: () => Mr(e) ?? []
1234
+ getBoundingClientRect: () => Fr(e) ?? wr(0, 0, 0, 0),
1235
+ getClientRects: () => Pr(e) ?? []
1236
1236
  };
1237
1237
  }
1238
- function Fr(e) {
1238
+ function Lr(e) {
1239
1239
  return e === "block-type" || e === "link" || e === "color" || e === "more";
1240
1240
  }
1241
- function Ir(e, t, n) {
1241
+ function Rr(e, t, n) {
1242
1242
  n?.(ln(e, t)), e.commands.focus();
1243
1243
  }
1244
- function Lr({ editor: e, messages: t = _r, selectionSnapshot: n, onRewriteSelection: r }) {
1245
- let i = W(() => mn(t), [t]), a = Ye(n, { editable: e.isEditable }), [o, s] = K(a), [c, l] = K(null), [u, d] = K(null), [f, p] = K(null), [m, h] = K(""), [g, _] = K(""), [v, y] = K(null), [b, x] = K(0), [S, C] = K(a.boundaryPadding), w = G(0), T = G(null), E = G(null), D = G(null), O = un(e, o.variant, t), k = gn(O.find((e) => e.id === c) ?? null), A = Dn(m), j = V(() => {
1244
+ function zr({ editor: e, messages: t = yr, selectionSnapshot: n, onRewriteSelection: r }) {
1245
+ let i = U(() => mn(t), [t]), a = Ye(n, { editable: e.isEditable }), [o, s] = G(a), [c, l] = G(null), [u, d] = G(null), [f, p] = G(null), [m, h] = G(""), [g, _] = G(""), [v, y] = G(null), [b, x] = G(0), [S, C] = G(a.boundaryPadding), w = W(0), T = W(null), E = W(null), D = W(null), O = un(e, o.variant, t), k = gn(O.find((e) => e.id === c) ?? null), A = Dn(m), j = B(() => {
1246
1246
  let t = T.current, n = e.view.dom.closest(".markweave-editor-frame");
1247
1247
  if (!t || !(n instanceof HTMLElement)) return;
1248
- let r = t.getBoundingClientRect(), i = n.getBoundingClientRect(), a = br(t, E.current), s = w.current, c = Ge({
1248
+ let r = t.getBoundingClientRect(), i = n.getBoundingClientRect(), a = Sr(t, E.current), s = w.current, c = Ge({
1249
1249
  toolbarRect: {
1250
1250
  left: r.left - s,
1251
1251
  top: r.top,
@@ -1278,22 +1278,22 @@ function Lr({ editor: e, messages: t = _r, selectionSnapshot: n, onRewriteSelect
1278
1278
  e.view.dom,
1279
1279
  o.boundaryPadding,
1280
1280
  o.offset
1281
- ]), ee = V(() => {
1281
+ ]), M = B(() => {
1282
1282
  T.current && (T.current.style.visibility = "hidden", T.current.style.opacity = "0");
1283
- }, []), M = V(() => {
1283
+ }, []), N = B(() => {
1284
1284
  j();
1285
- }, [j]), N = V(() => Pr(e), [e]), P = W(() => ({
1285
+ }, [j]), P = B(() => Ir(e), [e]), F = U(() => ({
1286
1286
  ...Je(o, { topBoundaryPadding: S }),
1287
- onShow: ee,
1288
- onUpdate: M
1287
+ onShow: M,
1288
+ onUpdate: N
1289
1289
  }), [
1290
- ee,
1291
1290
  M,
1291
+ N,
1292
1292
  o,
1293
1293
  S
1294
1294
  ]);
1295
- H(() => {
1296
- let e = vr();
1295
+ V(() => {
1296
+ let e = br();
1297
1297
  s((t) => Ze(t, a, e));
1298
1298
  }, [
1299
1299
  a.hiddenReason,
@@ -1306,10 +1306,10 @@ function Lr({ editor: e, messages: t = _r, selectionSnapshot: n, onRewriteSelect
1306
1306
  a.updateDelayMs,
1307
1307
  a.variant,
1308
1308
  a.visibility
1309
- ]), H(() => {
1309
+ ]), V(() => {
1310
1310
  if (o.motionStartedAtMs === null || o.motionDurationMs <= 0) return;
1311
- let e = Math.max(0, o.motionStartedAtMs + o.motionDurationMs - vr()), t = window.setTimeout(() => {
1312
- s((e) => We(e, vr()));
1311
+ let e = Math.max(0, o.motionStartedAtMs + o.motionDurationMs - br()), t = window.setTimeout(() => {
1312
+ s((e) => We(e, br()));
1313
1313
  }, e);
1314
1314
  return () => {
1315
1315
  window.clearTimeout(t);
@@ -1318,7 +1318,7 @@ function Lr({ editor: e, messages: t = _r, selectionSnapshot: n, onRewriteSelect
1318
1318
  o.motionDurationMs,
1319
1319
  o.motionPhase,
1320
1320
  o.motionStartedAtMs
1321
- ]), U(() => {
1321
+ ]), H(() => {
1322
1322
  if (o.visibility !== "visible") {
1323
1323
  w.current = 0, T.current && (T.current.style.marginLeft = "", T.current.style.visibility = "hidden", T.current.style.opacity = "0"), x(0), C(o.boundaryPadding);
1324
1324
  return;
@@ -1336,14 +1336,14 @@ function Lr({ editor: e, messages: t = _r, selectionSnapshot: n, onRewriteSelect
1336
1336
  o.variant,
1337
1337
  o.visibility,
1338
1338
  O.length
1339
- ]), H(() => {
1339
+ ]), V(() => {
1340
1340
  f === "more" && i.some((e) => e.id === c) || O.some((e) => e.id === c) || (l(null), d(null));
1341
1341
  }, [
1342
1342
  i,
1343
1343
  f,
1344
1344
  c,
1345
1345
  O
1346
- ]), H(() => {
1346
+ ]), V(() => {
1347
1347
  if (!f) return;
1348
1348
  let t = (e) => {
1349
1349
  E.current?.contains(e.target) || p(null);
@@ -1353,15 +1353,15 @@ function Lr({ editor: e, messages: t = _r, selectionSnapshot: n, onRewriteSelect
1353
1353
  return document.addEventListener("pointerdown", t, !0), document.addEventListener("keydown", n, !0), () => {
1354
1354
  document.removeEventListener("pointerdown", t, !0), document.removeEventListener("keydown", n, !0);
1355
1355
  };
1356
- }, [e, f]), H(() => {
1356
+ }, [e, f]), V(() => {
1357
1357
  if (f !== "link") return;
1358
1358
  let e = window.requestAnimationFrame(() => {
1359
1359
  D.current?.focus(), D.current?.select();
1360
1360
  });
1361
1361
  return () => window.cancelAnimationFrame(e);
1362
1362
  }, [f]);
1363
- let te = (t) => {
1364
- if (Fr(t.id)) {
1363
+ let I = (t) => {
1364
+ if (Lr(t.id)) {
1365
1365
  let n = t.id;
1366
1366
  if (n === "link") {
1367
1367
  let t = fn(e);
@@ -1374,23 +1374,23 @@ function Lr({ editor: e, messages: t = _r, selectionSnapshot: n, onRewriteSelect
1374
1374
  return;
1375
1375
  }
1376
1376
  if (p(null), t.id === "improve") {
1377
- Ir(e, "rewrite-selection", r);
1377
+ Rr(e, "rewrite-selection", r);
1378
1378
  return;
1379
1379
  }
1380
1380
  t.run(), e.commands.focus();
1381
- }, ne = () => {
1381
+ }, ee = () => {
1382
1382
  p(null), e.commands.focus();
1383
- }, F = () => {
1383
+ }, L = () => {
1384
1384
  v && e.commands.setTextSelection(v);
1385
- }, I = () => {
1386
- F(), cn(e, m) && ne();
1387
- }, re = () => {
1388
- if (F(), Sn(e)) {
1389
- h(""), _(""), ne();
1385
+ }, R = () => {
1386
+ L(), cn(e, m) && ee();
1387
+ }, te = () => {
1388
+ if (L(), Sn(e)) {
1389
+ h(""), _(""), ee();
1390
1390
  return;
1391
1391
  }
1392
1392
  m.trim() && h("");
1393
- }, L = (e, t) => {
1393
+ }, z = (e, t) => {
1394
1394
  if (l(e), !e || !t || !E.current) {
1395
1395
  d(null);
1396
1396
  return;
@@ -1403,34 +1403,34 @@ function Lr({ editor: e, messages: t = _r, selectionSnapshot: n, onRewriteSelect
1403
1403
  editor: e,
1404
1404
  className: `markweave-floating-toolbar markweave-floating-toolbar--${o.variant} markweave-floating-toolbar--motion-${o.motionPhase}`,
1405
1405
  "data-motion": o.motionPhase,
1406
- "data-position-strategy": P.strategy,
1406
+ "data-position-strategy": F.strategy,
1407
1407
  "data-boundary-padding": o.boundaryPadding,
1408
1408
  "data-testid": "markweave-floating-toolbar",
1409
- style: yr(o, b),
1409
+ style: xr(o, b),
1410
1410
  updateDelay: 0,
1411
- getReferencedVirtualElement: N,
1412
- options: P,
1411
+ getReferencedVirtualElement: P,
1412
+ options: F,
1413
1413
  shouldShow: ({ editor: e }) => e.isEditable && Xe(qe(e)),
1414
1414
  children: /* @__PURE__ */ Q("div", {
1415
1415
  ref: E,
1416
1416
  className: "markweave-floating-toolbar-content",
1417
1417
  "data-menu": f ?? "none",
1418
1418
  children: [
1419
- O.map((e, t) => /* @__PURE__ */ Z(zr, {
1419
+ O.map((e, t) => /* @__PURE__ */ Z(Vr, {
1420
1420
  button: e,
1421
1421
  expanded: f === e.id,
1422
1422
  showDivider: t > 0 && O[t - 1].group !== e.group,
1423
1423
  tooltipActive: c === e.id,
1424
1424
  onPointerDown: xn,
1425
- onTooltipChange: L,
1426
- onRun: te
1425
+ onTooltipChange: z,
1426
+ onRun: I
1427
1427
  }, e.id)),
1428
- f === "block-type" ? /* @__PURE__ */ Z(Vr, {
1428
+ f === "block-type" ? /* @__PURE__ */ Z(Ur, {
1429
1429
  editor: e,
1430
1430
  messages: t,
1431
1431
  onClose: () => p(null)
1432
1432
  }) : null,
1433
- f === "link" ? /* @__PURE__ */ Z(Rr, {
1433
+ f === "link" ? /* @__PURE__ */ Z(Br, {
1434
1434
  inputRef: D,
1435
1435
  messages: t,
1436
1436
  value: m,
@@ -1438,16 +1438,16 @@ function Lr({ editor: e, messages: t = _r, selectionSnapshot: n, onRewriteSelect
1438
1438
  canOpen: !!A,
1439
1439
  canRemove: !!(g || m.trim()),
1440
1440
  onValueChange: h,
1441
- onApply: I,
1441
+ onApply: R,
1442
1442
  onOpen: () => bn(m),
1443
- onRemove: re
1443
+ onRemove: te
1444
1444
  }) : null,
1445
- f === "color" ? /* @__PURE__ */ Z(Ur, {
1445
+ f === "color" ? /* @__PURE__ */ Z(Gr, {
1446
1446
  editor: e,
1447
1447
  messages: t,
1448
1448
  onClose: () => p(null)
1449
1449
  }) : null,
1450
- f === "more" ? /* @__PURE__ */ Z(Gr, {
1450
+ f === "more" ? /* @__PURE__ */ Z(qr, {
1451
1451
  editor: e,
1452
1452
  messages: t,
1453
1453
  activeTooltipId: c,
@@ -1460,14 +1460,14 @@ function Lr({ editor: e, messages: t = _r, selectionSnapshot: n, onRewriteSelect
1460
1460
  "data-testid": "markweave-floating-toolbar-tooltip",
1461
1461
  "data-button-id": k.buttonId,
1462
1462
  "data-active": k.active,
1463
- style: xr(u),
1463
+ style: Cr(u),
1464
1464
  children: k.label
1465
1465
  }) : null
1466
1466
  ]
1467
1467
  })
1468
1468
  });
1469
1469
  }
1470
- function Rr({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRemove: a, onValueChange: o, onApply: s, onOpen: c, onRemove: l }) {
1470
+ function Br({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRemove: a, onValueChange: o, onApply: s, onOpen: c, onRemove: l }) {
1471
1471
  let u = pn(t);
1472
1472
  return /* @__PURE__ */ Q("form", {
1473
1473
  className: "markweave-floating-toolbar-popover markweave-floating-toolbar-link-popover",
@@ -1519,7 +1519,7 @@ function Rr({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRe
1519
1519
  })]
1520
1520
  });
1521
1521
  }
1522
- function zr({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointerDown: i, onTooltipChange: a, onRun: o }) {
1522
+ function Vr({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointerDown: i, onTooltipChange: a, onRun: o }) {
1523
1523
  return /* @__PURE__ */ Q(X, { children: [n ? /* @__PURE__ */ Z("span", {
1524
1524
  className: "markweave-floating-toolbar-divider",
1525
1525
  "aria-hidden": "true"
@@ -1527,7 +1527,7 @@ function zr({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointe
1527
1527
  type: "button",
1528
1528
  className: `markweave-floating-toolbar-button markweave-floating-toolbar-button--${e.id}`,
1529
1529
  "aria-label": e.label,
1530
- "aria-expanded": Fr(e.id) ? t : void 0,
1530
+ "aria-expanded": Lr(e.id) ? t : void 0,
1531
1531
  "data-active": e.active || t,
1532
1532
  "data-tooltip-active": r ? "true" : "false",
1533
1533
  "data-testid": `markweave-floating-toolbar-button-${e.id}`,
@@ -1537,13 +1537,13 @@ function zr({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointe
1537
1537
  onMouseEnter: (t) => a(e.id, t.currentTarget),
1538
1538
  onMouseLeave: () => a(null),
1539
1539
  onClick: () => o(e),
1540
- children: /* @__PURE__ */ Z(Br, {
1540
+ children: /* @__PURE__ */ Z(Hr, {
1541
1541
  button: e,
1542
1542
  expanded: t
1543
1543
  })
1544
1544
  })] });
1545
1545
  }
1546
- function Br({ button: e, expanded: t }) {
1546
+ function Hr({ button: e, expanded: t }) {
1547
1547
  return e.id === "improve" ? /* @__PURE__ */ Q("span", {
1548
1548
  className: "markweave-floating-toolbar-button-inner",
1549
1549
  children: [/* @__PURE__ */ Z($, { name: "sparkles" }), /* @__PURE__ */ Z("span", { children: e.glyph })]
@@ -1561,7 +1561,7 @@ function Br({ button: e, expanded: t }) {
1561
1561
  }), /* @__PURE__ */ Z($, { name: t ? "chevron-up" : "chevron-down" })]
1562
1562
  }) : /* @__PURE__ */ Z($, { name: "more" });
1563
1563
  }
1564
- function Vr({ editor: e, messages: t, onClose: n }) {
1564
+ function Ur({ editor: e, messages: t, onClose: n }) {
1565
1565
  let r = pn(t), i = _n(t);
1566
1566
  return /* @__PURE__ */ Q("div", {
1567
1567
  className: "markweave-floating-toolbar-popover markweave-floating-toolbar-turn-menu",
@@ -1579,20 +1579,20 @@ function Vr({ editor: e, messages: t, onClose: n }) {
1579
1579
  },
1580
1580
  children: [/* @__PURE__ */ Z("span", {
1581
1581
  className: "markweave-floating-toolbar-menu-icon",
1582
- children: /* @__PURE__ */ Z(Hr, { option: t })
1582
+ children: /* @__PURE__ */ Z(Wr, { option: t })
1583
1583
  }), /* @__PURE__ */ Z("span", { children: t.label })]
1584
1584
  }, t.id))]
1585
1585
  });
1586
1586
  }
1587
- function Hr({ option: e }) {
1587
+ function Wr({ option: e }) {
1588
1588
  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 });
1589
1589
  }
1590
- function Ur({ editor: e, messages: t, onClose: n }) {
1590
+ function Gr({ editor: e, messages: t, onClose: n }) {
1591
1591
  let r = pn(t), i = e.getAttributes("textStyle").color, a = e.getAttributes("highlight").color;
1592
1592
  return /* @__PURE__ */ Q("div", {
1593
1593
  className: "markweave-floating-toolbar-popover markweave-floating-toolbar-color-popover",
1594
1594
  "data-testid": "markweave-floating-toolbar-color-menu",
1595
- children: [/* @__PURE__ */ Z(Wr, {
1595
+ children: [/* @__PURE__ */ Z(Kr, {
1596
1596
  title: r.textColorTitle,
1597
1597
  mode: "text",
1598
1598
  activeColor: i ?? null,
@@ -1600,7 +1600,7 @@ function Ur({ editor: e, messages: t, onClose: n }) {
1600
1600
  onSelect: (t) => {
1601
1601
  Tn(e, t), n();
1602
1602
  }
1603
- }), /* @__PURE__ */ Z(Wr, {
1603
+ }), /* @__PURE__ */ Z(Kr, {
1604
1604
  title: r.highlightColorTitle,
1605
1605
  mode: "highlight",
1606
1606
  activeColor: a ?? null,
@@ -1611,7 +1611,7 @@ function Ur({ editor: e, messages: t, onClose: n }) {
1611
1611
  })]
1612
1612
  });
1613
1613
  }
1614
- function Wr({ title: e, mode: t, activeColor: n, options: r, onSelect: i }) {
1614
+ function Kr({ title: e, mode: t, activeColor: n, options: r, onSelect: i }) {
1615
1615
  return /* @__PURE__ */ Q("section", {
1616
1616
  className: "markweave-floating-toolbar-color-section",
1617
1617
  "aria-label": e,
@@ -1640,12 +1640,12 @@ function Wr({ title: e, mode: t, activeColor: n, options: r, onSelect: i }) {
1640
1640
  })]
1641
1641
  });
1642
1642
  }
1643
- function Gr({ editor: e, messages: t, activeTooltipId: n, onTooltipChange: r, onClose: i }) {
1643
+ function qr({ editor: e, messages: t, activeTooltipId: n, onTooltipChange: r, onClose: i }) {
1644
1644
  let a = mn(t);
1645
1645
  return /* @__PURE__ */ Z("div", {
1646
1646
  className: "markweave-floating-toolbar-popover markweave-floating-toolbar-more-menu",
1647
1647
  "data-testid": "markweave-floating-toolbar-more-menu",
1648
- children: a.map((t, o) => /* @__PURE__ */ Z(Kr, {
1648
+ children: a.map((t, o) => /* @__PURE__ */ Z(Jr, {
1649
1649
  action: t,
1650
1650
  active: vn(e, t.id),
1651
1651
  tooltipActive: n === t.id,
@@ -1657,7 +1657,7 @@ function Gr({ editor: e, messages: t, activeTooltipId: n, onTooltipChange: r, on
1657
1657
  }, t.id))
1658
1658
  });
1659
1659
  }
1660
- function Kr({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipChange: i, onRun: a }) {
1660
+ function Jr({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipChange: i, onRun: a }) {
1661
1661
  return /* @__PURE__ */ Q(X, { children: [r ? /* @__PURE__ */ Z("span", {
1662
1662
  className: "markweave-floating-toolbar-divider",
1663
1663
  "aria-hidden": "true"
@@ -1673,7 +1673,7 @@ function Kr({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipC
1673
1673
  onMouseEnter: () => i(e.id),
1674
1674
  onMouseLeave: () => i(null),
1675
1675
  onClick: a,
1676
- children: /* @__PURE__ */ Z(qr, { id: e.id })
1676
+ children: /* @__PURE__ */ Z(Yr, { id: e.id })
1677
1677
  }), n ? /* @__PURE__ */ Z("div", {
1678
1678
  className: "markweave-floating-toolbar-tooltip markweave-floating-toolbar-tooltip--more",
1679
1679
  role: "tooltip",
@@ -1681,11 +1681,11 @@ function Kr({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipC
1681
1681
  }) : null]
1682
1682
  })] });
1683
1683
  }
1684
- function qr({ id: e }) {
1684
+ function Yr({ id: e }) {
1685
1685
  return e === "superscript" ? /* @__PURE__ */ Z($, { name: "superscript" }) : e === "subscript" ? /* @__PURE__ */ Z($, { name: "subscript" }) : e === "inline-math" ? /* @__PURE__ */ Z($, { name: "math" }) : Z($, { name: e });
1686
1686
  }
1687
- var Jr = {
1688
- sparkles: ie,
1687
+ var Xr = {
1688
+ sparkles: re,
1689
1689
  "chevron-down": h,
1690
1690
  "chevron-up": g,
1691
1691
  "corner-down-left": y,
@@ -1693,19 +1693,19 @@ var Jr = {
1693
1693
  bold: u,
1694
1694
  italic: A,
1695
1695
  underline: de,
1696
- strike: ae,
1696
+ strike: ie,
1697
1697
  "inline-code": v,
1698
- link: ee,
1699
- more: ne,
1698
+ link: M,
1699
+ more: ee,
1700
1700
  text: ue,
1701
- "bullet-list": M,
1702
- "numbered-list": P,
1703
- "todo-list": N,
1704
- quote: I,
1701
+ "bullet-list": N,
1702
+ "numbered-list": F,
1703
+ "todo-list": P,
1704
+ quote: R,
1705
1705
  "code-block": d,
1706
- superscript: se,
1707
- subscript: oe,
1708
- math: L,
1706
+ superscript: oe,
1707
+ subscript: ae,
1708
+ math: z,
1709
1709
  "align-left": c,
1710
1710
  "align-center": o,
1711
1711
  "align-right": l,
@@ -1715,7 +1715,7 @@ var Jr = {
1715
1715
  trash: le
1716
1716
  };
1717
1717
  function $({ name: e }) {
1718
- let t = Jr[e];
1718
+ let t = Xr[e];
1719
1719
  return /* @__PURE__ */ Z(t, {
1720
1720
  "aria-hidden": "true",
1721
1721
  absoluteStrokeWidth: !0,
@@ -1725,8 +1725,8 @@ function $({ name: e }) {
1725
1725
  }
1726
1726
  //#endregion
1727
1727
  //#region src/ui/math/MathEditorPopover.tsx
1728
- function Yr({ editor: e, messages: t, onClose: n, target: r }) {
1729
- let i = G(null), a = G(null), [o, s] = K(r.latex), [c, l] = K(null), u = t.math, d = W(() => pt(e, r) ?? 1, [e, r]), f = W(() => mt(e, r), [e, r]), m = W(() => o === r.latex && f ? {
1728
+ function Zr({ editor: e, messages: t, onClose: n, target: r }) {
1729
+ let i = W(null), a = W(null), [o, s] = G(r.latex), [c, l] = G(null), u = t.math, d = U(() => pt(e, r) ?? 1, [e, r]), f = U(() => mt(e, r), [e, r]), m = U(() => o === r.latex && f ? {
1730
1730
  html: f,
1731
1731
  error: !1
1732
1732
  } : vt(o, r.kind, e), [
@@ -1735,7 +1735,7 @@ function Yr({ editor: e, messages: t, onClose: n, target: r }) {
1735
1735
  r.kind,
1736
1736
  r.latex,
1737
1737
  o
1738
- ]), h = o.trim().length > 0, g = V(() => {
1738
+ ]), h = o.trim().length > 0, g = B(() => {
1739
1739
  if (typeof window > "u") return;
1740
1740
  let t = ft(e, r), i = e.view.dom.closest(".markweave-editor-frame")?.getBoundingClientRect();
1741
1741
  if (!t || !i) {
@@ -1756,9 +1756,9 @@ function Yr({ editor: e, messages: t, onClose: n, target: r }) {
1756
1756
  r,
1757
1757
  o
1758
1758
  ]);
1759
- H(() => {
1759
+ V(() => {
1760
1760
  s(r.latex);
1761
- }, [r.latex, r.pos]), H(() => {
1761
+ }, [r.latex, r.pos]), V(() => {
1762
1762
  yt(e, r, !0), g();
1763
1763
  let t = window.requestAnimationFrame(() => {
1764
1764
  a.current?.focus({ preventScroll: !0 }), a.current?.select(), g();
@@ -1771,14 +1771,14 @@ function Yr({ editor: e, messages: t, onClose: n, target: r }) {
1771
1771
  n,
1772
1772
  r,
1773
1773
  g
1774
- ]), H(() => {
1774
+ ]), V(() => {
1775
1775
  let e = (e) => {
1776
1776
  let t = e.target;
1777
1777
  t instanceof Node && (i.current?.contains(t) || t instanceof Element && t.closest(".tiptap-mathematics-render") || n());
1778
1778
  };
1779
1779
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
1780
1780
  }, [n]);
1781
- let _ = V(() => {
1781
+ let _ = B(() => {
1782
1782
  h && ut(e, r, o) && n();
1783
1783
  }, [
1784
1784
  h,
@@ -1910,31 +1910,31 @@ function Yr({ editor: e, messages: t, onClose: n, target: r }) {
1910
1910
  }
1911
1911
  //#endregion
1912
1912
  //#region src/ui/slash-command/SlashCommandMenu.tsx
1913
- var Xr = ke("zh"), Zr = {
1914
- type: z,
1913
+ var Qr = ke("zh"), $r = {
1914
+ type: ce,
1915
1915
  "heading-1": S,
1916
1916
  "heading-2": C,
1917
1917
  "heading-3": w,
1918
- "bullet-list": M,
1919
- "ordered-list": P,
1920
- "task-list": N,
1921
- blockquote: I,
1918
+ "bullet-list": N,
1919
+ "ordered-list": F,
1920
+ "task-list": P,
1921
+ blockquote: R,
1922
1922
  "code-block": d,
1923
1923
  info: k,
1924
1924
  tip: j,
1925
1925
  warning: a,
1926
1926
  error: _,
1927
1927
  success: m,
1928
- emoji: R,
1929
- math: L,
1930
- table: ce,
1931
- separator: te,
1928
+ emoji: ne,
1929
+ math: z,
1930
+ table: se,
1931
+ separator: I,
1932
1932
  image: T,
1933
- video: fe,
1934
- attachment: F
1933
+ video: pe,
1934
+ attachment: L
1935
1935
  };
1936
- function Qr({ name: e }) {
1937
- let t = Zr[e];
1936
+ function ei({ name: e }) {
1937
+ let t = $r[e];
1938
1938
  return /* @__PURE__ */ Z(t, {
1939
1939
  "aria-hidden": "true",
1940
1940
  absoluteStrokeWidth: !0,
@@ -1942,7 +1942,7 @@ function Qr({ name: e }) {
1942
1942
  strokeWidth: 1.6
1943
1943
  });
1944
1944
  }
1945
- function $r(e, t, n) {
1945
+ function ti(e, t, n) {
1946
1946
  return !Tt(e) || !n ? {
1947
1947
  visible: !1,
1948
1948
  empty: !1,
@@ -1957,17 +1957,17 @@ function $r(e, t, n) {
1957
1957
  activeIndex: Math.min(t.length - 1, Math.max(0, e.activeIndex))
1958
1958
  };
1959
1959
  }
1960
- function ei(e, t) {
1960
+ function ni(e, t) {
1961
1961
  return Object.values(t.slash.groups).map((t) => ({
1962
1962
  group: t,
1963
1963
  commands: e.filter((e) => e.group === t)
1964
1964
  })).filter((e) => e.commands.length > 0);
1965
1965
  }
1966
- function ti(e, t) {
1966
+ function ri(e, t) {
1967
1967
  return t.slash.uploadKindLabels[e] ?? t.slash.uploadKindLabels.upload;
1968
1968
  }
1969
- function ni({ command: e, messages: t, onBack: n, onSelect: r }) {
1970
- let [i, a] = K(""), [o, s] = K(0), c = W(() => {
1969
+ function ii({ command: e, messages: t, onBack: n, onSelect: r }) {
1970
+ let [i, a] = G(""), [o, s] = G(0), c = U(() => {
1971
1971
  let e = i.trim().toLowerCase();
1972
1972
  return (e ? t.slash.emojiItems.filter((t) => [
1973
1973
  t.emoji,
@@ -2033,9 +2033,9 @@ function ni({ command: e, messages: t, onBack: n, onSelect: r }) {
2033
2033
  ]
2034
2034
  });
2035
2035
  }
2036
- function ri({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
2037
- let a = e.uploadKind ?? "attachment", [o, s] = K(""), [c, l] = K(null), [u, d] = K(null), [f, p] = K(!1), m = async (t) => {
2038
- r(e, { uploadResult: await q({
2036
+ function ai({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
2037
+ let a = e.uploadKind ?? "attachment", [o, s] = G(""), [c, l] = G(null), [u, d] = G(null), [f, p] = G(!1), m = async (t) => {
2038
+ r(e, { uploadResult: await K({
2039
2039
  kind: a,
2040
2040
  source: t,
2041
2041
  trigger: "slash-command"
@@ -2055,7 +2055,7 @@ function ri({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
2055
2055
  d(t.slash.uploadRequiredError);
2056
2056
  return;
2057
2057
  }
2058
- await m(me(o));
2058
+ await m(he(o));
2059
2059
  } catch (e) {
2060
2060
  d(e instanceof Error ? e.message : t.slash.uploadFailedError);
2061
2061
  } finally {
@@ -2073,7 +2073,7 @@ function ri({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
2073
2073
  onMouseDown: (e) => e.preventDefault(),
2074
2074
  onClick: n,
2075
2075
  children: t.common.back
2076
- }), /* @__PURE__ */ Z("span", { children: ti(a, t) })]
2076
+ }), /* @__PURE__ */ Z("span", { children: ri(a, t) })]
2077
2077
  }),
2078
2078
  /* @__PURE__ */ Q("label", {
2079
2079
  className: "markweave-slash-upload-field",
@@ -2121,10 +2121,10 @@ function ri({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
2121
2121
  ]
2122
2122
  });
2123
2123
  }
2124
- function ii({ commands: e, messages: t = Xr, state: n, position: r, inputCommand: i, onActiveIndexChange: a, onInputCommandChange: o, onSelect: s, onUpload: c }) {
2125
- let l = $r(n, e, r);
2124
+ function oi({ commands: e, messages: t = Qr, state: n, position: r, inputCommand: i, onActiveIndexChange: a, onInputCommandChange: o, onSelect: s, onUpload: c }) {
2125
+ let l = ti(n, e, r);
2126
2126
  if (!l.visible || !r) return null;
2127
- let u = ei(e, t), d = {
2127
+ let u = ni(e, t), d = {
2128
2128
  left: r.left,
2129
2129
  top: r.top,
2130
2130
  maxHeight: r.maxHeight,
@@ -2146,12 +2146,12 @@ function ii({ commands: e, messages: t = Xr, state: n, position: r, inputCommand
2146
2146
  "aria-label": t.slash.ariaLabel,
2147
2147
  "data-placement": r.placement,
2148
2148
  "data-testid": "markweave-slash-menu",
2149
- children: i?.inputKind === "emoji" ? /* @__PURE__ */ Z(ni, {
2149
+ children: i?.inputKind === "emoji" ? /* @__PURE__ */ Z(ii, {
2150
2150
  command: i,
2151
2151
  messages: t,
2152
2152
  onBack: m,
2153
2153
  onSelect: s
2154
- }) : i?.inputKind === "upload" ? /* @__PURE__ */ Z(ri, {
2154
+ }) : i?.inputKind === "upload" ? /* @__PURE__ */ Z(ai, {
2155
2155
  command: i,
2156
2156
  messages: t,
2157
2157
  onBack: m,
@@ -2195,7 +2195,7 @@ function ii({ commands: e, messages: t = Xr, state: n, position: r, inputCommand
2195
2195
  }
2196
2196
  },
2197
2197
  children: [
2198
- /* @__PURE__ */ Z(Qr, { name: t.icon }),
2198
+ /* @__PURE__ */ Z(ei, { name: t.icon }),
2199
2199
  /* @__PURE__ */ Z("span", { children: t.label }),
2200
2200
  o && t.disabledReason ? /* @__PURE__ */ Z("small", { children: t.disabledReason }) : null
2201
2201
  ]
@@ -2207,10 +2207,10 @@ function ii({ commands: e, messages: t = Xr, state: n, position: r, inputCommand
2207
2207
  }
2208
2208
  //#endregion
2209
2209
  //#region src/ui/table/TableControls.tsx
2210
- var ai = ke("zh");
2211
- function oi({ active: e, editor: t, interactionState: n = It, messages: r = ai, onCopyPayload: i, onCommandResult: a, onEditWithAi: o }) {
2212
- let [s, c] = K(null), [l, u] = K("row-edge"), [d, f] = K(null), [p, m] = K(null), [h, g] = K(null), [_, v] = K(null), [y, b] = K(null), x = G(null), S = G(null), C = G(null), w = G(null), T = G(null), E = e ? Pt(t.state) : null;
2213
- if (H(() => {
2210
+ var si = ke("zh");
2211
+ function ci({ active: e, editor: t, interactionState: n = It, messages: r = si, onCopyPayload: i, onCommandResult: a, onEditWithAi: o }) {
2212
+ let [s, c] = G(null), [l, u] = G("row-edge"), [d, f] = G(null), [p, m] = G(null), [h, g] = G(null), [_, v] = G(null), [y, b] = G(null), x = W(null), S = W(null), C = W(null), w = W(null), T = W(null), E = e ? Pt(t.state) : null;
2213
+ if (V(() => {
2214
2214
  if (!y) return;
2215
2215
  let e = window.setTimeout(() => {
2216
2216
  b(null);
@@ -2218,7 +2218,7 @@ function oi({ active: e, editor: t, interactionState: n = It, messages: r = ai,
2218
2218
  return () => {
2219
2219
  window.clearTimeout(e);
2220
2220
  };
2221
- }, [y]), U(() => {
2221
+ }, [y]), H(() => {
2222
2222
  if (!e) {
2223
2223
  m(null), g(null), v(null), b(null);
2224
2224
  return;
@@ -2258,7 +2258,7 @@ function oi({ active: e, editor: t, interactionState: n = It, messages: r = ai,
2258
2258
  n.hoverVisualRowIndex,
2259
2259
  l,
2260
2260
  s
2261
- ]), U(() => {
2261
+ ]), H(() => {
2262
2262
  if (!e || !s) {
2263
2263
  f(null);
2264
2264
  return;
@@ -2296,7 +2296,7 @@ function oi({ active: e, editor: t, interactionState: n = It, messages: r = ai,
2296
2296
  p,
2297
2297
  h,
2298
2298
  _
2299
- ]), H(() => {
2299
+ ]), V(() => {
2300
2300
  if (!e || !s) return;
2301
2301
  let n = (e) => {
2302
2302
  e.key === "Escape" && (c(null), t.view.focus());
@@ -2321,7 +2321,7 @@ function oi({ active: e, editor: t, interactionState: n = It, messages: r = ai,
2321
2321
  i !== null && Wn(t, i, e, { visualIndex: a }), D(e, r);
2322
2322
  }, A = () => {
2323
2323
  O(), D("selection", "selection-edge");
2324
- }, j = Ln(t, n, "row", E?.activeCellPos ?? null), ee = Ln(t, n, "column", E?.activeCellPos ?? null), M = Fn(t).length > 0, N = s ? Vn(t, s) : [], P = async (e, n) => {
2324
+ }, j = Ln(t, n, "row", E?.activeCellPos ?? null), M = Ln(t, n, "column", E?.activeCellPos ?? null), N = Fn(t).length > 0, P = s ? Vn(t, s) : [], F = async (e, n) => {
2325
2325
  let o = await Mn({
2326
2326
  editor: t,
2327
2327
  commandId: e,
@@ -2329,7 +2329,7 @@ function oi({ active: e, editor: t, interactionState: n = It, messages: r = ai,
2329
2329
  messages: r
2330
2330
  });
2331
2331
  return o.copyFeedback ? (b(o.copyFeedback), o.copyPayload && i?.(o.copyPayload)) : b(null), a?.(o.commandResult), o.success;
2332
- }, te = (e) => {
2332
+ }, I = (e) => {
2333
2333
  let n = Rn(t, e);
2334
2334
  n && o?.(n), c(null), t.view.focus();
2335
2335
  };
@@ -2386,10 +2386,10 @@ function oi({ active: e, editor: t, interactionState: n = It, messages: r = ai,
2386
2386
  "aria-haspopup": "menu",
2387
2387
  title: r.table.columnActions,
2388
2388
  "data-testid": "markweave-table-hover-column-handle",
2389
- "data-axis-index": ee?.index ?? "",
2390
- "data-axis-selected-cells": ee?.selectedCellCount ?? "",
2391
- "data-axis-visual-cells": ee?.visualCellCount ?? "",
2392
- "data-axis-visual-size": ee?.visualWidth ?? "",
2389
+ "data-axis-index": M?.index ?? "",
2390
+ "data-axis-selected-cells": M?.selectedCellCount ?? "",
2391
+ "data-axis-visual-cells": M?.visualCellCount ?? "",
2392
+ "data-axis-visual-size": M?.visualWidth ?? "",
2393
2393
  style: {
2394
2394
  left: h.left,
2395
2395
  top: h.top
@@ -2403,7 +2403,7 @@ function oi({ active: e, editor: t, interactionState: n = It, messages: r = ai,
2403
2403
  children: "..."
2404
2404
  })
2405
2405
  }) : null,
2406
- M && _ ? /* @__PURE__ */ Z("button", {
2406
+ N && _ ? /* @__PURE__ */ Z("button", {
2407
2407
  type: "button",
2408
2408
  ref: T,
2409
2409
  className: "markweave-table-edge-handle markweave-table-edge-handle--selection",
@@ -2434,8 +2434,8 @@ function oi({ active: e, editor: t, interactionState: n = It, messages: r = ai,
2434
2434
  left: d.left,
2435
2435
  top: d.top
2436
2436
  } : void 0,
2437
- children: N.map((e, n) => {
2438
- let i = zn(e), a = n === 0 ? i : zn(N[n - 1]), l = n > 0 && a !== i, u = e.commandId === null ? !!o : jn(t, e.commandId), d = Bn(e, r);
2437
+ children: P.map((e, n) => {
2438
+ let i = zn(e), a = n === 0 ? i : zn(P[n - 1]), l = n > 0 && a !== i, u = e.commandId === null ? !!o : jn(t, e.commandId), d = Bn(e, r);
2439
2439
  return /* @__PURE__ */ Z("button", {
2440
2440
  type: "button",
2441
2441
  role: "menuitem",
@@ -2450,10 +2450,10 @@ function oi({ active: e, editor: t, interactionState: n = It, messages: r = ai,
2450
2450
  onClick: () => {
2451
2451
  if (u) {
2452
2452
  if (e.commandId === null) {
2453
- te(s === "row" || s === "column" ? s : "selection");
2453
+ I(s === "row" || s === "column" ? s : "selection");
2454
2454
  return;
2455
2455
  }
2456
- P(e.commandId).finally(() => c(null));
2456
+ F(e.commandId).finally(() => c(null));
2457
2457
  }
2458
2458
  },
2459
2459
  children: d
@@ -2465,9 +2465,9 @@ function oi({ active: e, editor: t, interactionState: n = It, messages: r = ai,
2465
2465
  }
2466
2466
  //#endregion
2467
2467
  //#region src/ui/table/TableSelectionOverlay.tsx
2468
- function si({ editor: e, focusState: t }) {
2469
- let [n, r] = K(null);
2470
- return U(() => {
2468
+ function li({ editor: e, focusState: t }) {
2469
+ let [n, r] = G(null);
2470
+ return H(() => {
2471
2471
  if (t.mode !== "cell-selection") {
2472
2472
  r(null);
2473
2473
  return;
@@ -2508,18 +2508,22 @@ function si({ editor: e, focusState: t }) {
2508
2508
  }
2509
2509
  //#endregion
2510
2510
  //#region src/ui/toc/MarkweaveInnerToc.tsx
2511
- function ci(e, t) {
2511
+ function ui(e, t) {
2512
2512
  return `${e.toc.itemAriaLabel}: ${t.text}`;
2513
2513
  }
2514
- function li({ editor: e, state: t, messages: n, editable: r }) {
2515
- if (!t.items.length) return null;
2516
- let i = (t) => {
2517
- Qn(e, t, {
2514
+ function di({ editor: e, state: t, messages: n, editable: r, placement: i }) {
2515
+ let a = W(null);
2516
+ if (V(() => {
2517
+ if (!(i !== "container" || !a.current)) return $n(a.current);
2518
+ }, [i]), !t.items.length) return null;
2519
+ let o = (t) => {
2520
+ er(e, t, {
2518
2521
  behavior: "smooth",
2519
2522
  focus: r
2520
2523
  });
2521
2524
  };
2522
2525
  return /* @__PURE__ */ Q("nav", {
2526
+ ref: a,
2523
2527
  className: "markweave-inner-toc",
2524
2528
  "data-testid": "markweave-inner-toc",
2525
2529
  "aria-label": n.toc.ariaLabel,
@@ -2540,9 +2544,9 @@ function li({ editor: e, state: t, messages: n, editable: r }) {
2540
2544
  "data-level": e.level,
2541
2545
  "data-active": e.active ? "true" : "false",
2542
2546
  "aria-current": e.active ? "location" : void 0,
2543
- "aria-label": ci(n, e),
2547
+ "aria-label": ui(n, e),
2544
2548
  title: e.text,
2545
- onClick: () => i(e),
2549
+ onClick: () => o(e),
2546
2550
  children: e.text
2547
2551
  }, e.id))
2548
2552
  })
@@ -2551,7 +2555,7 @@ function li({ editor: e, state: t, messages: n, editable: r }) {
2551
2555
  }
2552
2556
  //#endregion
2553
2557
  //#region src/MarkweaveEditor.tsx
2554
- var ui = {
2558
+ var fi = {
2555
2559
  active: !1,
2556
2560
  mode: "outside",
2557
2561
  activeCellPos: null,
@@ -2559,21 +2563,21 @@ var ui = {
2559
2563
  selectedCellCount: 0,
2560
2564
  selectionFrom: 0,
2561
2565
  selectionTo: 0
2562
- }, di = {
2566
+ }, pi = {
2563
2567
  active: !1,
2564
2568
  language: nt.defaultLanguage,
2565
2569
  mermaidPreviewMode: "code",
2566
2570
  pos: null,
2567
2571
  text: ""
2568
- }, fi = lt({
2572
+ }, mi = lt({
2569
2573
  active: !1,
2570
2574
  mode: "code",
2571
2575
  source: ""
2572
2576
  });
2573
- function pi(e) {
2577
+ function hi(e) {
2574
2578
  return Lt.getState(e.state) ?? It;
2575
2579
  }
2576
- function mi(e) {
2580
+ function gi(e) {
2577
2581
  if (!e || typeof window > "u") return null;
2578
2582
  let t = e.parentElement;
2579
2583
  for (; t;) {
@@ -2583,71 +2587,71 @@ function mi(e) {
2583
2587
  }
2584
2588
  return null;
2585
2589
  }
2586
- function hi(e) {
2590
+ function _i(e) {
2587
2591
  return typeof window > "u" || typeof window.requestAnimationFrame != "function" ? globalThis.setTimeout(() => e(0), 0) : window.requestAnimationFrame(e);
2588
2592
  }
2589
- function gi(e) {
2593
+ function vi(e) {
2590
2594
  if (typeof window < "u" && typeof window.cancelAnimationFrame == "function") {
2591
2595
  window.cancelAnimationFrame(e);
2592
2596
  return;
2593
2597
  }
2594
2598
  globalThis.clearTimeout(e);
2595
2599
  }
2596
- function _i({ ariaLabel: e, autoFocusFirstTableBodyCell: t = !1, autofocus: n = !1, content: r, contentFormat: a, defaultContent: o = "", defaultContentFormat: s, editable: c = !0, innerToc: l = !0, lang: u, mode: d = "live", onEditWithAi: f, onExtractToNote: p, onRewriteSelection: m, onRuntimeStateChange: h, onSlashCommandUpload: g, onTableCommandResult: _, onTableCopyPayload: v, onTocChange: y, onUpdate: b } = {}) {
2597
- let x = Ne(d), S = x === "live" && c !== !1, C = Ve(r === void 0 ? s : a), w = G({
2598
- editorMode: x,
2599
- effectiveEditable: S
2600
+ function yi({ ariaLabel: e, autoFocusFirstTableBodyCell: t = !1, autofocus: n = !1, content: r, contentFormat: a, defaultContent: o = "", defaultContentFormat: s, editable: c = !0, innerToc: l = !0, innerTocPlacement: u, lang: d, mode: f = "live", onEditWithAi: p, onExtractToNote: m, onRewriteSelection: h, onRuntimeStateChange: g, onSlashCommandUpload: _, onTableCommandResult: v, onTableCopyPayload: y, onTocChange: b, onUpdate: x } = {}) {
2601
+ let S = Ne(f), C = Qn(u), w = S === "live" && c !== !1, T = Ve(r === void 0 ? s : a), E = W({
2602
+ editorMode: S,
2603
+ effectiveEditable: w
2600
2604
  });
2601
- w.current = {
2602
- editorMode: x,
2603
- effectiveEditable: S
2605
+ E.current = {
2606
+ editorMode: S,
2607
+ effectiveEditable: w
2604
2608
  };
2605
- let T = G(null);
2606
- T.current === null && (T.current = Ae(u));
2607
- let E = T.current, D = W(() => ke(E), [E]), O = W(() => Oe(E), [E]), k = G(g);
2608
- k.current = g;
2609
- let A = W(() => pr({
2610
- lang: E,
2609
+ let D = W(null);
2610
+ D.current === null && (D.current = Ae(d));
2611
+ let O = D.current, k = U(() => ke(O), [O]), A = U(() => Oe(O), [O]), j = W(_);
2612
+ j.current = _;
2613
+ let M = U(() => hr({
2614
+ lang: O,
2611
2615
  onImageUpload: (e) => {
2612
- if (k.current) return k.current(e);
2613
- let t = he(e);
2616
+ if (j.current) return j.current(e);
2617
+ let t = ge(e);
2614
2618
  if (!t) throw Error("File upload requires an upload handler.");
2615
2619
  return t;
2616
2620
  },
2617
2621
  onVideoUpload: (e) => {
2618
- if (k.current) return k.current(e);
2619
- let t = he(e);
2622
+ if (j.current) return j.current(e);
2623
+ let t = ge(e);
2620
2624
  if (!t) throw Error("File upload requires an upload handler.");
2621
2625
  return t;
2622
2626
  }
2623
- }), [E]), [j, ee] = K(null), [M, N] = K(At), [P, te] = K(null), [ne, F] = K(null), [I, re] = K("code"), [L, R] = K(null), [ie, ae] = K(It), [oe, se] = K(null), [ce, z] = K(0), le = G(!1), ue = G({ onUpdate: b }), de = W(() => St(M.query, O), [O, M.query]);
2624
- ue.current = { onUpdate: b };
2625
- let B = V(() => {
2626
- te(null), F(null), N(At);
2627
- }, []), fe = V((e) => {
2627
+ }), [O]), [N, P] = G(null), [F, I] = G(At), [ee, L] = G(null), [R, te] = G(null), [z, ne] = G("code"), [re, ie] = G(null), [ae, oe] = G(It), [se, ce] = G(null), [le, ue] = G(0), de = W(!1), fe = W({ onUpdate: x }), pe = U(() => St(F.query, A), [A, F.query]);
2628
+ fe.current = { onUpdate: x };
2629
+ let H = B(() => {
2630
+ L(null), te(null), I(At);
2631
+ }, []), me = B((e) => {
2628
2632
  let t = kt(e.state);
2629
2633
  if (!t) {
2630
- N((e) => e.name === "idle" ? e : At), te(null), F(null);
2634
+ I((e) => e.name === "idle" ? e : At), L(null), te(null);
2631
2635
  return;
2632
2636
  }
2633
2637
  let n = e.coordsAtPos(t.cursor), r = e.coordsAtPos(t.triggerFrom), i = e.dom.closest(".markweave-editor-frame")?.getBoundingClientRect();
2634
- te(Ot(n, {
2638
+ L(Ot(n, {
2635
2639
  frameRect: i,
2636
2640
  triggerRect: r
2637
- })), N((e) => Dt(e, t));
2638
- }, []), U = V((e) => fe(e.view), [fe]), pe = V((e) => {
2639
- ee(qe(e));
2641
+ })), I((e) => Dt(e, t));
2642
+ }, []), he = B((e) => me(e.view), [me]), K = B((e) => {
2643
+ P(qe(e));
2640
2644
  let t = _t(e);
2641
- t && (yt(e, t, !0), R(t));
2645
+ t && (yt(e, t, !0), ie(t));
2642
2646
  let n = et(e);
2643
- n.active && n.language === "mermaid" && re(n.mermaidPreviewMode);
2644
- }, []), me = V((e) => {
2645
- ae(pi(e));
2647
+ n.active && n.language === "mermaid" && ne(n.mermaidPreviewMode);
2648
+ }, []), _e = B((e) => {
2649
+ oe(hi(e));
2646
2650
  }, []), q = i({
2647
- extensions: A,
2651
+ extensions: M,
2648
2652
  content: r ?? o,
2649
- contentType: ze(C),
2650
- editable: S,
2653
+ contentType: ze(T),
2654
+ editable: w,
2651
2655
  autofocus: n,
2652
2656
  editorProps: {
2653
2657
  attributes: {
@@ -2658,190 +2662,190 @@ function _i({ ariaLabel: e, autoFocusFirstTableBodyCell: t = !1, autofocus: n =
2658
2662
  spellcheck: "false",
2659
2663
  translate: "no"
2660
2664
  },
2661
- handleClick: (e, t, n) => w.current.effectiveEditable ? !1 : He(n),
2665
+ handleClick: (e, t, n) => E.current.effectiveEditable ? !1 : He(n),
2662
2666
  handleDOMEvents: {
2663
- compositionstart: () => w.current.effectiveEditable ? (N((e) => jt(e, { type: "composition-start" })), te(null), !1) : !1,
2664
- compositionend: (e) => (w.current.effectiveEditable && window.setTimeout(() => fe(e), 0), !1),
2667
+ compositionstart: () => E.current.effectiveEditable ? (I((e) => jt(e, { type: "composition-start" })), L(null), !1) : !1,
2668
+ compositionend: (e) => (E.current.effectiveEditable && window.setTimeout(() => me(e), 0), !1),
2665
2669
  click: (e, t) => {
2666
- if (w.current.effectiveEditable) {
2670
+ if (E.current.effectiveEditable) {
2667
2671
  let n = gt(e, t);
2668
- return n ? (t.preventDefault(), t.stopPropagation(), B(), bt(e, n, !0), xt(e, n), R(n), !0) : (R(null), !1);
2672
+ return n ? (t.preventDefault(), t.stopPropagation(), H(), bt(e, n, !0), xt(e, n), ie(n), !0) : (ie(null), !1);
2669
2673
  }
2670
2674
  return He(t);
2671
2675
  }
2672
2676
  }
2673
2677
  },
2674
2678
  onSelectionUpdate: ({ editor: e }) => {
2675
- pe(e);
2679
+ K(e);
2676
2680
  },
2677
2681
  onCreate: ({ editor: e }) => {
2678
- t && w.current.effectiveEditable && Nt(e), me(e), pe(e), z((e) => e + 1);
2682
+ t && E.current.effectiveEditable && Nt(e), _e(e), K(e), ue((e) => e + 1);
2679
2683
  },
2680
2684
  onTransaction: ({ editor: e, transaction: t }) => {
2681
- me(e), (t.docChanged || ot(t)) && z((e) => e + 1), t.docChanged && R((t) => {
2685
+ _e(e), (t.docChanged || ot(t)) && ue((e) => e + 1), t.docChanged && ie((t) => {
2682
2686
  if (!t) return null;
2683
2687
  let n = ht(e, t.pos);
2684
2688
  return n?.kind === t.kind ? n : null;
2685
2689
  });
2686
2690
  },
2687
2691
  onUpdate: ({ editor: e }) => {
2688
- pe(e), w.current.effectiveEditable && U(e), le.current || ue.current.onUpdate?.(Re(e));
2692
+ K(e), E.current.effectiveEditable && he(e), de.current || fe.current.onUpdate?.(Re(e));
2689
2693
  }
2690
2694
  });
2691
- H(() => {
2692
- q && (q.setEditable(S), Pe(q, {
2693
- mode: x,
2694
- editable: S
2695
- }), st(q, S ? "live" : "view"), S || B());
2695
+ V(() => {
2696
+ q && (q.setEditable(w), Pe(q, {
2697
+ mode: S,
2698
+ editable: w
2699
+ }), st(q, w ? "live" : "view"), w || H());
2696
2700
  }, [
2697
- B,
2701
+ H,
2698
2702
  q,
2699
- x,
2700
- S
2701
- ]), H(() => {
2702
- !q || r === void 0 || Be(q, r, Ve(a)) || (le.current = !0, q.commands.setContent(r, {
2703
+ S,
2704
+ w
2705
+ ]), V(() => {
2706
+ !q || r === void 0 || Be(q, r, Ve(a)) || (de.current = !0, q.commands.setContent(r, {
2703
2707
  contentType: ze(Ve(a)),
2704
2708
  emitUpdate: !1
2705
- }), le.current = !1, pe(q), S && U(q), me(q), z((e) => e + 1));
2709
+ }), de.current = !1, K(q), w && he(q), _e(q), ue((e) => e + 1));
2706
2710
  }, [
2707
2711
  r,
2708
2712
  a,
2709
- S,
2713
+ w,
2710
2714
  q,
2711
- pe,
2712
- U,
2713
- me
2714
- ]), H(() => {
2715
- if (!P) return;
2715
+ K,
2716
+ he,
2717
+ _e
2718
+ ]), V(() => {
2719
+ if (!ee) return;
2716
2720
  let e = (e) => {
2717
2721
  let t = e.target;
2718
- t instanceof Element && (t.closest(".markweave-slash-menu") || t.closest(".markweave-slash-trigger") || B());
2722
+ t instanceof Element && (t.closest(".markweave-slash-menu") || t.closest(".markweave-slash-trigger") || H());
2719
2723
  };
2720
2724
  return document.addEventListener("pointerdown", e, !0), () => document.removeEventListener("pointerdown", e, !0);
2721
- }, [B, P]);
2722
- let ge = W(() => q ? et(q) : di, [
2725
+ }, [H, ee]);
2726
+ let ve = U(() => q ? et(q) : pi, [
2723
2727
  q,
2724
- ce,
2725
- j
2726
- ]), _e = W(() => q ? Pt(q.state) : ui, [
2728
+ le,
2729
+ N
2730
+ ]), ye = U(() => q ? Pt(q.state) : fi, [
2727
2731
  q,
2728
- ce,
2729
- j,
2730
- ie
2731
- ]), ve = j?.currentNode === "codeBlock", ye = ve && ge.language === "mermaid", be = W(() => q ? lt({
2732
- active: ye,
2733
- mode: I,
2734
- source: ge.text
2735
- }) : fi, [
2736
- ge.text,
2732
+ le,
2733
+ N,
2734
+ ae
2735
+ ]), be = N?.currentNode === "codeBlock", xe = be && ve.language === "mermaid", Se = U(() => q ? lt({
2736
+ active: xe,
2737
+ mode: z,
2738
+ source: ve.text
2739
+ }) : mi, [
2740
+ ve.text,
2737
2741
  q,
2738
- ye,
2739
- I
2740
- ]), xe = W(() => q ? Mt(q.state) : null, [q, ce]), J = W(() => q ? Xn(q.state.doc) : Jn.items, [q, ce]), Se = W(() => Zn(J, oe), [oe, J]), Ce = W(() => qn(J, Se), [Se, J]), we = V(() => {
2742
+ xe,
2743
+ z
2744
+ ]), Ce = U(() => q ? Mt(q.state) : null, [q, le]), J = U(() => q ? Xn(q.state.doc) : Jn.items, [q, le]), we = U(() => Zn(J, se), [se, J]), Te = U(() => qn(J, we), [we, J]), Ee = B(() => {
2741
2745
  if (!q || !J.length) {
2742
- se(null);
2746
+ ce(null);
2743
2747
  return;
2744
2748
  }
2745
2749
  let e = Yn(q, J);
2746
- se((t) => t === e ? t : e);
2750
+ ce((t) => t === e ? t : e);
2747
2751
  }, [q, J]);
2748
- H(() => {
2749
- se((e) => {
2752
+ V(() => {
2753
+ ce((e) => {
2750
2754
  let t = Zn(J, e);
2751
2755
  return e === t ? e : t;
2752
2756
  });
2753
- }, [J]), H(() => {
2757
+ }, [J]), V(() => {
2754
2758
  if (!q || !J.length || typeof window > "u") return;
2755
2759
  let e = null, t = () => {
2756
- e !== null && gi(e), e = hi(() => {
2757
- e = null, we();
2760
+ e !== null && vi(e), e = _i(() => {
2761
+ e = null, Ee();
2758
2762
  });
2759
- }, n = mi(q.view.dom);
2763
+ }, n = gi(q.view.dom);
2760
2764
  return window.addEventListener("scroll", t, { passive: !0 }), window.addEventListener("resize", t), n?.addEventListener("scroll", t, { passive: !0 }), t(), () => {
2761
- window.removeEventListener("scroll", t), window.removeEventListener("resize", t), n?.removeEventListener("scroll", t), e !== null && gi(e);
2765
+ window.removeEventListener("scroll", t), window.removeEventListener("resize", t), n?.removeEventListener("scroll", t), e !== null && vi(e);
2762
2766
  };
2763
2767
  }, [
2764
2768
  q,
2765
2769
  J.length,
2766
- we
2770
+ Ee
2767
2771
  ]);
2768
- let Te = W(() => Ue({
2769
- revision: ce,
2770
- mode: x,
2771
- editable: S,
2772
- toc: Ce,
2773
- selection: j,
2774
- slash: M,
2775
- table: _e,
2776
- tableInteraction: ie,
2777
- codeBlock: ge,
2778
- mermaid: be,
2779
- tableDebugSnapshot: xe
2772
+ let De = U(() => Ue({
2773
+ revision: le,
2774
+ mode: S,
2775
+ editable: w,
2776
+ toc: Te,
2777
+ selection: N,
2778
+ slash: F,
2779
+ table: ye,
2780
+ tableInteraction: ae,
2781
+ codeBlock: ve,
2782
+ mermaid: Se,
2783
+ tableDebugSnapshot: Ce
2780
2784
  }), [
2781
- ge,
2782
- x,
2785
+ ve,
2783
2786
  S,
2784
- be,
2785
- ce,
2786
- j,
2787
- M,
2788
- xe,
2789
- _e,
2790
- ie,
2791
- Ce
2787
+ w,
2788
+ Se,
2789
+ le,
2790
+ N,
2791
+ F,
2792
+ Ce,
2793
+ ye,
2794
+ ae,
2795
+ Te
2792
2796
  ]);
2793
- H(() => {
2794
- h?.(Te);
2795
- }, [h, Te]), H(() => {
2796
- y?.(Ce);
2797
- }, [y, Ce]);
2798
- let Ee = V((e, t) => {
2799
- if (!(!q || !S) && Ct(e)) {
2797
+ V(() => {
2798
+ g?.(De);
2799
+ }, [g, De]), V(() => {
2800
+ b?.(Te);
2801
+ }, [b, Te]);
2802
+ let Y = B((e, t) => {
2803
+ if (!(!q || !w) && Ct(e)) {
2800
2804
  if (e.inputKind && !t?.emoji && !t?.uploadResult) {
2801
- F(e);
2805
+ te(e);
2802
2806
  return;
2803
2807
  }
2804
- Et(q, M, e, t), N((e) => jt(e, { type: "execute" })), B();
2808
+ Et(q, F, e, t), I((e) => jt(e, { type: "execute" })), H();
2805
2809
  }
2806
2810
  }, [
2807
- B,
2808
- S,
2811
+ H,
2812
+ w,
2809
2813
  q,
2810
- M
2811
- ]), De = V((e) => {
2812
- N((t) => jt(t, {
2814
+ F
2815
+ ]), je = B((e) => {
2816
+ I((t) => jt(t, {
2813
2817
  type: "set-active",
2814
2818
  index: e,
2815
- optionCount: de.length
2819
+ optionCount: pe.length
2816
2820
  }));
2817
- }, [de.length]), Y = V((e) => {
2818
- if (!q || ne || !S) return;
2819
- let t = wt(M, de, e.key, { isComposing: e.nativeEvent.isComposing || Le(q.state) });
2821
+ }, [pe.length]), Me = B((e) => {
2822
+ if (!q || R || !w) return;
2823
+ let t = wt(F, pe, e.key, { isComposing: e.nativeEvent.isComposing || Le(q.state) });
2820
2824
  if (t.type !== "ignore") {
2821
2825
  if (t.type === "close") {
2822
- e.preventDefault(), N((e) => jt(e, { type: "escape" })), B();
2826
+ e.preventDefault(), I((e) => jt(e, { type: "escape" })), H();
2823
2827
  return;
2824
2828
  }
2825
2829
  if (t.type === "move-active") {
2826
- e.preventDefault(), N((e) => jt(e, {
2830
+ e.preventDefault(), I((e) => jt(e, {
2827
2831
  type: "move-active",
2828
2832
  delta: t.delta,
2829
2833
  optionCount: t.optionCount
2830
2834
  }));
2831
2835
  return;
2832
2836
  }
2833
- t.type === "execute-active" && (e.preventDefault(), Ee(t.command));
2837
+ t.type === "execute-active" && (e.preventDefault(), Y(t.command));
2834
2838
  }
2835
2839
  }, [
2836
- B,
2837
- S,
2840
+ H,
2841
+ w,
2838
2842
  q,
2839
- de,
2840
- Ee,
2841
- ne,
2842
- M
2843
- ]), je = W(() => ({
2844
- closeSlashMenu: B,
2843
+ pe,
2844
+ Y,
2845
+ R,
2846
+ F
2847
+ ]), Fe = U(() => ({
2848
+ closeSlashMenu: H,
2845
2849
  focusFirstTableBodyCell: () => q ? Nt(q) : !1,
2846
2850
  setContent: (e, t = {}) => {
2847
2851
  if (!q) return !1;
@@ -2849,134 +2853,137 @@ function _i({ ariaLabel: e, autoFocusFirstTableBodyCell: t = !1, autofocus: n =
2849
2853
  return q.commands.setContent(e, {
2850
2854
  contentType: ze(n),
2851
2855
  emitUpdate: t.emitUpdate ?? !1
2852
- }), t.focusFirstTableBodyCell && Nt(q), pe(q), S && U(q), me(q), z((e) => e + 1), !0;
2856
+ }), t.focusFirstTableBodyCell && Nt(q), K(q), w && he(q), _e(q), ue((e) => e + 1), !0;
2853
2857
  }
2854
2858
  }), [
2855
- B,
2856
- S,
2859
+ H,
2860
+ w,
2857
2861
  q,
2858
- pe,
2859
- U,
2860
- me
2862
+ K,
2863
+ he,
2864
+ _e
2861
2865
  ]);
2862
2866
  return {
2863
2867
  editor: q,
2864
- frameProps: W(() => ({
2868
+ frameProps: U(() => ({
2865
2869
  className: "markweave-editor-frame",
2866
- "aria-label": e ?? D.common.editorAriaLabel,
2870
+ "aria-label": e ?? k.common.editorAriaLabel,
2867
2871
  "data-testid": "markweave-editor-frame",
2868
- "data-markweave-mode": x,
2872
+ "data-markweave-mode": S,
2869
2873
  "data-markweave-inner-toc": l ? "true" : "false",
2870
- "data-mermaid-mode": be.mode,
2871
- "data-table-focus-mode": _e.mode,
2872
- onKeyDownCapture: Y
2874
+ "data-markweave-inner-toc-placement": C,
2875
+ "data-mermaid-mode": Se.mode,
2876
+ "data-table-focus-mode": ye.mode,
2877
+ onKeyDownCapture: Me
2873
2878
  }), [
2874
2879
  e,
2875
- x,
2876
- Y,
2880
+ S,
2881
+ Me,
2877
2882
  l,
2878
- be.mode,
2879
- D.common.editorAriaLabel,
2880
- _e.mode
2883
+ Se.mode,
2884
+ k.common.editorAriaLabel,
2885
+ C,
2886
+ ye.mode
2881
2887
  ]),
2882
- overlayProps: W(() => ({
2883
- floatingToolbar: q && S ? {
2888
+ overlayProps: U(() => ({
2889
+ floatingToolbar: q && w ? {
2884
2890
  editor: q,
2885
- messages: D,
2886
- selectionSnapshot: j,
2887
- onRewriteSelection: m,
2888
- onExtractToNote: p
2891
+ messages: k,
2892
+ selectionSnapshot: N,
2893
+ onRewriteSelection: h,
2894
+ onExtractToNote: m
2889
2895
  } : null,
2890
- slashCommandMenu: q && S ? {
2891
- commands: de,
2892
- state: M,
2893
- position: P,
2894
- inputCommand: ne,
2895
- messages: D,
2896
- onActiveIndexChange: De,
2897
- onInputCommandChange: F,
2898
- onSelect: Ee,
2899
- onUpload: g
2896
+ slashCommandMenu: q && w ? {
2897
+ commands: pe,
2898
+ state: F,
2899
+ position: ee,
2900
+ inputCommand: R,
2901
+ messages: k,
2902
+ onActiveIndexChange: je,
2903
+ onInputCommandChange: te,
2904
+ onSelect: Y,
2905
+ onUpload: _
2900
2906
  } : null,
2901
- tableControls: q && S ? {
2907
+ tableControls: q && w ? {
2902
2908
  editor: q,
2903
- active: _e.active,
2904
- interactionState: ie,
2905
- messages: D,
2906
- onCopyPayload: v,
2907
- onCommandResult: _,
2908
- onEditWithAi: f
2909
+ active: ye.active,
2910
+ interactionState: ae,
2911
+ messages: k,
2912
+ onCopyPayload: y,
2913
+ onCommandResult: v,
2914
+ onEditWithAi: p
2909
2915
  } : null,
2910
- tableSelectionOverlay: q && S ? {
2916
+ tableSelectionOverlay: q && w ? {
2911
2917
  editor: q,
2912
- focusState: _e
2918
+ focusState: ye
2913
2919
  } : null,
2914
2920
  codeBlockControls: q ? {
2915
2921
  editor: q,
2916
- active: S && ve,
2917
- mermaidMode: I,
2918
- onMermaidModeChange: re,
2919
- readOnly: !S
2922
+ active: w && be,
2923
+ mermaidMode: z,
2924
+ onMermaidModeChange: ne,
2925
+ readOnly: !w
2920
2926
  } : null,
2921
- innerToc: q && l && Ce.items.length ? {
2927
+ innerToc: q && l && Te.items.length ? {
2922
2928
  editor: q,
2923
- editable: S,
2924
- messages: D,
2925
- state: Ce
2929
+ editable: w,
2930
+ messages: k,
2931
+ placement: C,
2932
+ state: Te
2926
2933
  } : null,
2927
- mathEditorPopover: q && S && L ? {
2934
+ mathEditorPopover: q && w && re ? {
2928
2935
  editor: q,
2929
- messages: D,
2930
- target: L,
2931
- onClose: () => R(null)
2936
+ messages: k,
2937
+ target: re,
2938
+ onClose: () => ie(null)
2932
2939
  } : null
2933
2940
  }), [
2934
- S,
2941
+ w,
2935
2942
  q,
2936
- de,
2943
+ pe,
2937
2944
  l,
2938
- ve,
2939
- I,
2940
- D,
2941
- L,
2942
- f,
2945
+ be,
2946
+ z,
2947
+ k,
2948
+ re,
2943
2949
  p,
2944
2950
  m,
2945
- g,
2951
+ h,
2946
2952
  _,
2947
2953
  v,
2948
- Ee,
2949
- j,
2950
- De,
2951
- ne,
2952
- P,
2953
- M,
2954
- _e,
2955
- ie,
2956
- Ce
2954
+ y,
2955
+ Y,
2956
+ N,
2957
+ je,
2958
+ R,
2959
+ ee,
2960
+ F,
2961
+ ye,
2962
+ ae,
2963
+ Te
2957
2964
  ]),
2958
- runtimeSnapshot: Te,
2959
- actions: je
2965
+ runtimeSnapshot: De,
2966
+ actions: Fe
2960
2967
  };
2961
2968
  }
2962
- function vi({ className: e, ...n }) {
2963
- let r = _i(n);
2969
+ function bi({ className: e, ...n }) {
2970
+ let r = yi(n);
2964
2971
  if (!r.editor) return null;
2965
2972
  let i = [r.frameProps.className, e].filter(Boolean).join(" ");
2966
2973
  return /* @__PURE__ */ Q("section", {
2967
2974
  ...r.frameProps,
2968
2975
  className: i,
2969
2976
  children: [
2970
- r.overlayProps.floatingToolbar ? /* @__PURE__ */ Z(Lr, { ...r.overlayProps.floatingToolbar }) : null,
2971
- r.overlayProps.slashCommandMenu ? /* @__PURE__ */ Z(ii, { ...r.overlayProps.slashCommandMenu }) : null,
2972
- r.overlayProps.tableControls ? /* @__PURE__ */ Z(oi, { ...r.overlayProps.tableControls }) : null,
2973
- r.overlayProps.tableSelectionOverlay ? /* @__PURE__ */ Z(si, { ...r.overlayProps.tableSelectionOverlay }) : null,
2974
- r.overlayProps.codeBlockControls ? /* @__PURE__ */ Z(gr, { ...r.overlayProps.codeBlockControls }) : null,
2975
- r.overlayProps.innerToc ? /* @__PURE__ */ Z(li, { ...r.overlayProps.innerToc }) : null,
2976
- r.overlayProps.mathEditorPopover ? /* @__PURE__ */ Z(Yr, { ...r.overlayProps.mathEditorPopover }) : null,
2977
+ r.overlayProps.floatingToolbar ? /* @__PURE__ */ Z(zr, { ...r.overlayProps.floatingToolbar }) : null,
2978
+ r.overlayProps.slashCommandMenu ? /* @__PURE__ */ Z(oi, { ...r.overlayProps.slashCommandMenu }) : null,
2979
+ r.overlayProps.tableControls ? /* @__PURE__ */ Z(ci, { ...r.overlayProps.tableControls }) : null,
2980
+ r.overlayProps.tableSelectionOverlay ? /* @__PURE__ */ Z(li, { ...r.overlayProps.tableSelectionOverlay }) : null,
2981
+ r.overlayProps.codeBlockControls ? /* @__PURE__ */ Z(vr, { ...r.overlayProps.codeBlockControls }) : null,
2982
+ r.overlayProps.innerToc ? /* @__PURE__ */ Z(di, { ...r.overlayProps.innerToc }) : null,
2983
+ r.overlayProps.mathEditorPopover ? /* @__PURE__ */ Z(Zr, { ...r.overlayProps.mathEditorPopover }) : null,
2977
2984
  /* @__PURE__ */ Z(t, { editor: r.editor })
2978
2985
  ]
2979
2986
  });
2980
2987
  }
2981
2988
  //#endregion
2982
- export { vi as MarkweaveEditor, pr as createMarkweaveEditorExtensions, pr as createMarkweaveReactEditorExtensions, _i as useMarkweaveEditorController };
2989
+ export { bi as MarkweaveEditor, hr as createMarkweaveEditorExtensions, hr as createMarkweaveReactEditorExtensions, yi as useMarkweaveEditorController };