@markweave/react 0.2.5 → 0.2.6

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,10 +1,10 @@
1
1
  import { createMarkweaveEditorExtensions as e } from "markweave/internal/editor-core/create-editor-extensions";
2
2
  import { getLocalizedSlashCommandSpecs as t, getMarkweaveMessages as n, normalizeMarkweaveLang as r } from "markweave/internal/i18n";
3
3
  import { EditorContent as i, NodeViewWrapper as a, ReactNodeViewRenderer as o, useEditor as s } from "@tiptap/react";
4
- import { AlertTriangle as c, AlignCenter as l, AlignJustify as u, AlignLeft as d, AlignRight as f, Bold as p, Braces as m, Captions as h, Check as g, CheckCircle2 as _, ChevronDown as v, ChevronUp as y, CircleX as b, Code2 as x, Copy as S, CornerDownLeft as C, Download as w, ExternalLink as T, Eye as E, Heading1 as D, Heading2 as O, Heading3 as k, Image as A, ImageUp as j, IndentDecrease as M, IndentIncrease as N, Info as P, Italic as F, Lightbulb as ee, Link2 as I, List as L, ListChecks as te, ListOrdered as R, Minus as z, MoreVertical as ne, Paperclip as re, Pencil as ie, Quote as ae, Replace as B, Sigma as V, SmilePlus as oe, Sparkles as se, Strikethrough as ce, Subscript as le, Superscript as ue, Table2 as de, Text as fe, Trash2 as pe, Type as me, Underline as he, Upload as ge, Video as _e } from "lucide-react";
5
- import { useCallback as H, useEffect as U, useLayoutEffect as W, useMemo as G, useRef as K, useState as q, useSyncExternalStore as ve } from "react";
6
- import { detectUploadSource as ye, getDirectUploadResult as be, resolveMarkweaveUploadResult as xe } from "markweave/internal/plugins/slash-command/upload";
7
- import { MarkweaveCoreImage as Se, MarkweaveCoreVideo as Ce, attrsFromMarkweaveImageUploadResult as we, attrsFromMarkweaveVideoUploadResult as Te, attrsFromMarkweaveVideoUrl as Ee, clampMarkweaveImageWidth as De, createMarkweaveImageUploadRequest as Oe, createMarkweaveVideoUploadRequest as ke, downloadMarkweaveImage as Ae, markweaveVideoIframeAllow as je, normalizeMarkweaveCoreImageAlign as Me, normalizeMarkweaveVideoEmbedUrl as J, numberAttribute as Ne, stringAttribute as Y } from "markweave/internal/plugins/media/core-media-nodes";
4
+ import { AlertTriangle as c, AlignCenter as l, AlignJustify as u, AlignLeft as d, AlignRight as f, Bold as p, Braces as m, Captions as h, Check as g, CheckCircle2 as _, ChevronDown as v, ChevronUp as y, CircleX as b, Code2 as x, Copy as S, CornerDownLeft as C, Download as w, ExternalLink as T, Eye as E, Heading1 as D, Heading2 as O, Heading3 as k, Image as A, ImageUp as j, IndentDecrease as M, IndentIncrease as N, Info as P, Italic as F, Lightbulb as ee, Link2 as te, List as I, ListChecks as L, ListOrdered as ne, Minus as re, MoreVertical as R, Paperclip as ie, Pencil as ae, Quote as oe, Replace as z, Sigma as B, SmilePlus as se, Sparkles as ce, Strikethrough as le, Subscript as ue, Superscript as de, Table2 as fe, Text as pe, Trash2 as me, Type as he, Underline as ge, Upload as _e, Video as ve } from "lucide-react";
5
+ import { useCallback as V, useEffect as H, useLayoutEffect as U, useMemo as W, useRef as G, useState as K, useSyncExternalStore as ye } from "react";
6
+ import { detectUploadSource as be, getDirectUploadResult as xe, resolveMarkweaveUploadResult as Se } from "markweave/internal/plugins/slash-command/upload";
7
+ import { MarkweaveCoreImage as Ce, MarkweaveCoreVideo as we, attrsFromMarkweaveImageUploadResult as Te, attrsFromMarkweaveVideoUploadResult as Ee, attrsFromMarkweaveVideoUrl as De, clampMarkweaveImageWidth as Oe, createMarkweaveImageUploadRequest as q, createMarkweaveVideoUploadRequest as ke, downloadMarkweaveImage as Ae, markweaveVideoIframeAllow as je, normalizeMarkweaveCoreImageAlign as Me, normalizeMarkweaveVideoEmbedUrl as J, numberAttribute as Ne, stringAttribute as Y } from "markweave/internal/plugins/media/core-media-nodes";
8
8
  import { getMarkweaveEditorModeState as Pe, isMarkweaveEditorLiveEditable as Fe, normalizeMarkweaveEditorMode as Ie, setMarkweaveEditorModeState as Le, subscribeToMarkweaveEditorMode as Re } from "markweave/internal/core/editor-mode-state";
9
9
  import { openMarkweaveImagePreview as ze } from "markweave/internal/plugins/media/image-preview";
10
10
  import { Fragment as X, jsx as Z, jsxs as Q } from "react/jsx-runtime";
@@ -29,32 +29,33 @@ import { getFirstTableDebugSnapshot as Kt } from "markweave/internal/plugins/tab
29
29
  import { focusFirstTableBodyCell as qt } from "markweave/internal/plugins/table/table-focus-position";
30
30
  import { getTableFocusState as Jt } from "markweave/internal/plugins/table/table-focus-state";
31
31
  import { getTableSelectionOverlayState as Yt, initialTableInteractionState as Xt, tableInteractionPluginKey as Zt } from "markweave/internal/plugins/table/table-interaction-layer";
32
- import { calculateCodeBlockLanguageMenuPosition as Qt, clampFullscreenScale as $t, codeBlockCopyFeedbackTimeoutMs as en, copyCodeBlockText as tn, createCodeBlockOverlayPosition as nn, createMermaidFullscreenViewerState as rn, createMermaidTabPosition as an, focusCodeBlockTarget as on, formatCodeBlockLanguageLabel as sn, formatFullscreenZoom as cn, getActiveCodeBlockElement as ln, getAnchoredRect as un, getCodeBlockLanguageItems as dn, getCodeBlockPositionFromEventTarget as fn, getCodeBlockStateAtPosition as pn, getFrameElement as mn, getMermaidCodeBlockTargets as hn, getMermaidSvgMarkup as gn, isCodeBlockTargetCollapsed as _n, mergeStableMermaidTabPositions as vn, mermaidFullscreenZoomStep as yn, moveMermaidFullscreenViewer as bn } from "markweave/internal/plugins/codeblock/codeblock-ui-model";
33
- import { BubbleMenu as xn } from "@tiptap/react/menus";
34
- import { createMarkweaveFrameScheduler as Sn } from "markweave/internal/editor-core/frame-scheduler";
35
- import { applyFloatingToolbarLink as Cn, createFloatingToolbarAssistantRequest as wn, getFloatingToolbarButtonModels as Tn, getFloatingToolbarHighlightColorOptions as En, getFloatingToolbarLinkHref as Dn, getFloatingToolbarMessageSet as On, getFloatingToolbarMoreActions as kn, getFloatingToolbarTextColorOptions as An, getFloatingToolbarTooltipModel as jn, getFloatingToolbarTurnIntoOptions as Mn, isFloatingToolbarMoreActionActive as Nn, isFloatingToolbarTurnIntoActive as Pn, openFloatingToolbarLinkHref as Fn, preventFloatingToolbarPointerFocusLoss as In, removeFloatingToolbarLink as Ln, runFloatingToolbarMoreAction as Rn, setFloatingToolbarHighlightColor as zn, setFloatingToolbarTextColor as Bn, setFloatingToolbarTurnInto as Vn } from "markweave/internal/editor-core/floating-toolbar-model";
36
- import { normalizeMarkdownLinkHref as Hn } from "markweave/internal/plugins/markdown/markdown-input";
37
- import { setMarkweaveTableMenuAxisTarget as Un } from "markweave/internal/plugins/table/table-clipboard";
38
- import { calculateAnchoredTableMenuPosition as Wn, calculateTableEdgeHandlePosition as Gn, canRunTableCommand as Kn, executeTableMenuCommand as qn, formatTableCopyFeedback as Jn, getActiveTableElement as Yn, getAvailableCellMenuCommandSpecs as Xn, getTableAxisTargetRect as Zn, getTableControlAxisSelectionModel as Qn, getTableEditWithAiRequest as $n, getTableMenuItemGroup as er, getTableMenuItemLabel as tr, getTableMenuItems as nr, getTableSelectionTargetRect as rr, measureTableSelectionOverlay as ir, selectTableAxisFromCell as ar, tableCopyFeedbackTimeoutMs as or, tableMenuLabel as sr } from "markweave/internal/plugins/table/table-ui-model";
39
- import { createMarkweaveTocState as cr, emptyMarkweaveTocState as lr, getActiveMarkweaveTocId as ur, getMarkweaveTocItems as dr, getValidMarkweaveTocActiveId as fr, normalizeMarkweaveInnerTocPlacement as pr, observeMarkweaveInnerTocContainerPosition as mr, scrollToMarkweaveTocItem as hr } from "markweave/internal/core/toc-state";
40
- import { normalizeMarkweaveCanvasColor as gr, normalizeMarkweaveTheme as _r } from "markweave/internal/core/theme";
41
- import { createMarkweaveSearchController as vr } from "markweave/internal/plugins/search/search-controller";
32
+ import { saveMarkweaveBrowserFile as Qt } from "markweave/internal/core/browser-file-save";
33
+ import { calculateCodeBlockLanguageMenuPosition as $t, clampFullscreenScale as en, codeBlockCopyFeedbackTimeoutMs as tn, copyCodeBlockText as nn, createCodeBlockLanguageMenuDomId as rn, createCodeBlockOverlayPosition as an, createMermaidFullscreenViewerState as on, createMermaidTabPosition as sn, focusCodeBlockTarget as cn, formatCodeBlockLanguageLabel as ln, formatFullscreenZoom as un, getActiveCodeBlockElement as dn, getAnchoredRect as fn, getCodeBlockLanguageItems as pn, getCodeBlockLanguageOptionDomId as mn, getCodeBlockPositionFromEventTarget as hn, getCodeBlockStateAtPosition as gn, getFrameElement as _n, getInitialCodeBlockLanguageItemIndex as vn, getMermaidCodeBlockTargets as yn, getMermaidSvgMarkup as bn, isCodeBlockTargetCollapsed as xn, mergeStableMermaidTabPositions as Sn, mermaidFullscreenZoomStep as Cn, moveCodeBlockLanguageItemIndex as wn, moveMermaidFullscreenViewer as Tn, scrollCodeBlockLanguageItemIntoView as En } from "markweave/internal/plugins/codeblock/codeblock-ui-model";
34
+ import { BubbleMenu as Dn } from "@tiptap/react/menus";
35
+ import { createMarkweaveFrameScheduler as On } from "markweave/internal/editor-core/frame-scheduler";
36
+ import { applyFloatingToolbarLink as kn, createFloatingToolbarAssistantRequest as An, getFloatingToolbarButtonModels as jn, getFloatingToolbarHighlightColorOptions as Mn, getFloatingToolbarLinkHref as Nn, getFloatingToolbarMessageSet as Pn, getFloatingToolbarMoreActions as Fn, getFloatingToolbarTextColorOptions as In, getFloatingToolbarTooltipModel as Ln, getFloatingToolbarTurnIntoOptions as Rn, isFloatingToolbarMoreActionActive as zn, isFloatingToolbarTurnIntoActive as Bn, openFloatingToolbarLinkHref as Vn, preventFloatingToolbarPointerFocusLoss as Hn, removeFloatingToolbarLink as Un, runFloatingToolbarMoreAction as Wn, setFloatingToolbarHighlightColor as Gn, setFloatingToolbarTextColor as Kn, setFloatingToolbarTurnInto as qn } from "markweave/internal/editor-core/floating-toolbar-model";
37
+ import { normalizeMarkdownLinkHref as Jn } from "markweave/internal/plugins/markdown/markdown-input";
38
+ import { setMarkweaveTableMenuAxisTarget as Yn } from "markweave/internal/plugins/table/table-clipboard";
39
+ import { calculateAnchoredTableMenuPosition as Xn, calculateTableEdgeHandlePosition as Zn, canRunTableCommand as Qn, executeTableMenuCommand as $n, formatTableCopyFeedback as er, getActiveTableElement as tr, getAvailableCellMenuCommandSpecs as nr, getTableAxisTargetRect as rr, getTableControlAxisSelectionModel as ir, getTableEditWithAiRequest as ar, getTableMenuItemGroup as or, getTableMenuItemLabel as sr, getTableMenuItems as cr, getTableSelectionTargetRect as lr, measureTableSelectionOverlay as ur, selectTableAxisFromCell as dr, tableCopyFeedbackTimeoutMs as fr, tableMenuLabel as pr } from "markweave/internal/plugins/table/table-ui-model";
40
+ import { createMarkweaveTocState as mr, emptyMarkweaveTocState as hr, getActiveMarkweaveTocId as gr, getMarkweaveTocItems as _r, getValidMarkweaveTocActiveId as vr, normalizeMarkweaveInnerTocPlacement as yr, observeMarkweaveInnerTocContainerPosition as br, scrollToMarkweaveTocItem as xr } from "markweave/internal/core/toc-state";
41
+ import { normalizeMarkweaveCanvasColor as Sr, normalizeMarkweaveTheme as Cr } from "markweave/internal/core/theme";
42
+ import { createMarkweaveSearchController as wr } from "markweave/internal/plugins/search/search-controller";
42
43
  //#region src/editor-mode-state.ts
43
- var yr = {
44
+ var Tr = {
44
45
  mode: "live",
45
46
  editable: !0
46
47
  };
47
- function br(e) {
48
- return ve((t) => Re(e, t), () => Pe(e), () => yr);
48
+ function Er(e) {
49
+ return ye((t) => Re(e, t), () => Pe(e), () => Tr);
49
50
  }
50
51
  //#endregion
51
52
  //#region src/media/image-node.tsx
52
- var xr = Me;
53
- function Sr(e) {
53
+ var Dr = Me;
54
+ function Or(e) {
54
55
  return e instanceof Element && !!e.closest("[data-markweave-image-ui=\"true\"]");
55
56
  }
56
- function Cr(e) {
57
- let { deleteNode: t, editor: r, getPos: i, node: o, selected: s, updateAttributes: c } = e, l = e.extension.options, u = l.messages ?? n("zh"), d = u.image, f = Fe(br(r)), p = Y(o.attrs.src), m = xr(o.attrs.align), h = Ne(o.attrs.width), g = Y(o.attrs.caption), _ = K(null), v = K(null), [y, b] = q(!1), [x, S] = q(!1), [C, w] = q(!1), [T, D] = q(""), [O, k] = q(null), [A, j] = q(!1), [M, N] = q(!!g), [P, F] = q(g ?? ""), ee = f && (!p || x), I = () => {
57
+ function kr(e) {
58
+ let { deleteNode: t, editor: r, getPos: i, node: o, selected: s, updateAttributes: c } = e, l = e.extension.options, u = l.messages ?? n("zh"), d = u.image, f = Fe(Er(r)), p = Y(o.attrs.src), m = Dr(o.attrs.align), h = Ne(o.attrs.width), g = Y(o.attrs.caption), _ = G(null), v = G(null), [y, b] = K(!1), [x, S] = K(!1), [C, w] = K(!1), [T, D] = K(""), [O, k] = K(null), [A, j] = K(!1), [M, N] = K(!!g), [P, F] = K(g ?? ""), ee = f && (!p || x), te = () => {
58
59
  p && ze({
59
60
  src: p,
60
61
  alt: Y(o.attrs.alt) ?? "",
@@ -67,14 +68,14 @@ function Cr(e) {
67
68
  }
68
69
  });
69
70
  };
70
- U(() => {
71
+ H(() => {
71
72
  M || F(g ?? "");
72
73
  }, [g, M]);
73
- let L = () => {
74
+ let I = () => {
74
75
  if (!f) return;
75
76
  let e = i();
76
77
  typeof e == "number" && r.chain().focus().setNodeSelection(e).run();
77
- }, te = () => {
78
+ }, L = () => {
78
79
  if (f) {
79
80
  if (D(""), k(null), w(!1), p) {
80
81
  S(!1);
@@ -82,48 +83,48 @@ function Cr(e) {
82
83
  }
83
84
  t();
84
85
  }
85
- }, R = async (e) => {
86
+ }, ne = async (e) => {
86
87
  if (f) {
87
88
  k(null), j(!0);
88
89
  try {
89
- let t = await xe(Oe(e, p && x ? "image-replace" : "image-insert"), l.onUpload);
90
- c(we(o.attrs, t)), S(!1), D("");
90
+ let t = await Se(q(e, p && x ? "image-replace" : "image-insert"), l.onUpload);
91
+ c(Te(o.attrs, t)), S(!1), D("");
91
92
  } catch (e) {
92
93
  k(e instanceof Error ? e.message : d.uploadFailedError);
93
94
  } finally {
94
95
  j(!1), w(!1);
95
96
  }
96
97
  }
97
- }, z = () => {
98
+ }, re = () => {
98
99
  if (f) {
99
100
  if (!T.trim()) {
100
101
  k(d.uploadRequiredError);
101
102
  return;
102
103
  }
103
- R(ye(T));
104
+ ne(be(T));
104
105
  }
105
- }, ne = (e) => {
106
- !f || !e || R({
106
+ }, R = (e) => {
107
+ !f || !e || ne({
107
108
  type: "file",
108
109
  file: e,
109
110
  mimeType: e.type
110
111
  });
111
- }, re = (e) => {
112
- ne(e.currentTarget.files?.[0] ?? null), e.currentTarget.value = "";
113
112
  }, ie = (e) => {
114
- e.preventDefault(), e.stopPropagation(), f && ne(e.dataTransfer.files?.[0] ?? null);
115
- }, ae = () => {
113
+ R(e.currentTarget.files?.[0] ?? null), e.currentTarget.value = "";
114
+ }, ae = (e) => {
115
+ e.preventDefault(), e.stopPropagation(), f && R(e.dataTransfer.files?.[0] ?? null);
116
+ }, oe = () => {
116
117
  f && (N((e) => !e), M || F(g ?? ""));
117
- }, B = (e) => {
118
+ }, z = (e) => {
118
119
  f && (F(e), c({ caption: e.trim() ? e : null }));
119
- }, V = (e, t) => {
120
+ }, B = (e, t) => {
120
121
  if (t.preventDefault(), t.stopPropagation(), !f) return;
121
- L();
122
+ I();
122
123
  let n = _.current;
123
124
  if (!n) return;
124
125
  let r = t.clientX, i = n.getBoundingClientRect().width || h || 320, a = n.closest(".markweave-editor-surface")?.getBoundingClientRect().width ?? n.parentElement?.getBoundingClientRect().width ?? i, o = (t) => {
125
126
  let n = e === "right" ? t.clientX - r : r - t.clientX;
126
- c({ width: De(i + n, a) });
127
+ c({ width: Oe(i + n, a) });
127
128
  }, s = () => {
128
129
  window.removeEventListener("pointermove", o), window.removeEventListener("pointerup", s);
129
130
  };
@@ -140,33 +141,33 @@ function Cr(e) {
140
141
  onPointerEnter: () => b(!0),
141
142
  onPointerLeave: () => b(!1),
142
143
  onMouseDown: (e) => {
143
- f && !Sr(e.target) && L();
144
+ f && !Or(e.target) && I();
144
145
  },
145
- children: ee ? /* @__PURE__ */ Z(wr, {
146
+ children: ee ? /* @__PURE__ */ Z(Ar, {
146
147
  dragActive: C,
147
148
  error: O,
148
149
  inputValue: T,
149
150
  isSubmitting: A,
150
151
  fileInputRef: v,
151
152
  messages: u,
152
- onCancel: te,
153
- onDrop: ie,
153
+ onCancel: L,
154
+ onDrop: ae,
154
155
  onDragActiveChange: w,
155
- onFileChange: re,
156
+ onFileChange: ie,
156
157
  onInputChange: D,
157
- onSubmit: z
158
+ onSubmit: re
158
159
  }) : /* @__PURE__ */ Q(X, { children: [
159
- f ? /* @__PURE__ */ Z(Tr, {
160
+ f ? /* @__PURE__ */ Z(jr, {
160
161
  align: m,
161
162
  captionActive: M || !!g,
162
163
  messages: u,
163
164
  onAlign: (e) => c({ align: e }),
164
- onCaption: ae,
165
+ onCaption: oe,
165
166
  onDelete: t,
166
167
  onDownload: () => {
167
168
  p && Ae(p);
168
169
  },
169
- onPreview: I,
170
+ onPreview: te,
170
171
  onReplace: () => {
171
172
  D(""), k(null), S(!0);
172
173
  }
@@ -195,7 +196,7 @@ function Cr(e) {
195
196
  "aria-label": d.preview,
196
197
  title: d.preview,
197
198
  onMouseDown: (e) => e.preventDefault(),
198
- onClick: I,
199
+ onClick: te,
199
200
  children: [/* @__PURE__ */ Z(E, {
200
201
  size: 16,
201
202
  strokeWidth: 1.8
@@ -205,15 +206,15 @@ function Cr(e) {
205
206
  children: d.preview
206
207
  })]
207
208
  }) : null,
208
- f ? /* @__PURE__ */ Z(Dr, {
209
+ f ? /* @__PURE__ */ Z(Nr, {
209
210
  side: "left",
210
211
  messages: u,
211
- onPointerDown: V
212
+ onPointerDown: B
212
213
  }) : null,
213
- f ? /* @__PURE__ */ Z(Dr, {
214
+ f ? /* @__PURE__ */ Z(Nr, {
214
215
  side: "right",
215
216
  messages: u,
216
- onPointerDown: V
217
+ onPointerDown: B
217
218
  }) : null
218
219
  ]
219
220
  }),
@@ -224,7 +225,7 @@ function Cr(e) {
224
225
  value: P,
225
226
  placeholder: d.captionPlaceholder,
226
227
  "aria-label": d.captionAriaLabel,
227
- onChange: (e) => B(e.currentTarget.value),
228
+ onChange: (e) => z(e.currentTarget.value),
228
229
  onKeyDown: (e) => {
229
230
  e.key === "Escape" && (e.preventDefault(), N(!1));
230
231
  }
@@ -236,7 +237,7 @@ function Cr(e) {
236
237
  ] })
237
238
  });
238
239
  }
239
- function wr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitting: i, messages: a, onCancel: o, onDragActiveChange: s, onDrop: c, onFileChange: l, onInputChange: u, onSubmit: d }) {
240
+ function Ar({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitting: i, messages: a, onCancel: o, onDragActiveChange: s, onDrop: c, onFileChange: l, onInputChange: u, onSubmit: d }) {
240
241
  let f = a.image;
241
242
  return /* @__PURE__ */ Q("section", {
242
243
  className: "markweave-image-upload-placeholder",
@@ -318,7 +319,7 @@ function wr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
318
319
  ]
319
320
  });
320
321
  }
321
- function Tr({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i, onDelete: a, onDownload: o, onPreview: s, onReplace: c }) {
322
+ function jr({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i, onDelete: a, onDownload: o, onPreview: s, onReplace: c }) {
322
323
  let u = n.image;
323
324
  return /* @__PURE__ */ Q("div", {
324
325
  className: "markweave-image-toolbar",
@@ -326,21 +327,21 @@ function Tr({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i,
326
327
  "data-markweave-image-ui": "true",
327
328
  "aria-label": u.toolsAriaLabel,
328
329
  children: [
329
- /* @__PURE__ */ Z(Er, {
330
+ /* @__PURE__ */ Z(Mr, {
330
331
  testId: "markweave-image-align-left",
331
332
  label: u.alignLeft,
332
333
  icon: d,
333
334
  active: e === "left",
334
335
  onClick: () => r("left")
335
336
  }),
336
- /* @__PURE__ */ Z(Er, {
337
+ /* @__PURE__ */ Z(Mr, {
337
338
  testId: "markweave-image-align-center",
338
339
  label: u.alignCenter,
339
340
  icon: l,
340
341
  active: e === "center",
341
342
  onClick: () => r("center")
342
343
  }),
343
- /* @__PURE__ */ Z(Er, {
344
+ /* @__PURE__ */ Z(Mr, {
344
345
  testId: "markweave-image-align-right",
345
346
  label: u.alignRight,
346
347
  icon: f,
@@ -351,45 +352,45 @@ function Tr({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i,
351
352
  className: "markweave-image-toolbar-divider",
352
353
  "aria-hidden": "true"
353
354
  }),
354
- /* @__PURE__ */ Z(Er, {
355
+ /* @__PURE__ */ Z(Mr, {
355
356
  testId: "markweave-image-caption",
356
357
  label: u.caption,
357
358
  icon: h,
358
359
  active: t,
359
360
  onClick: i
360
361
  }),
361
- /* @__PURE__ */ Z(Er, {
362
+ /* @__PURE__ */ Z(Mr, {
362
363
  testId: "markweave-image-preview",
363
364
  label: u.preview,
364
365
  icon: E,
365
366
  onClick: s
366
367
  }),
367
- /* @__PURE__ */ Z(Er, {
368
+ /* @__PURE__ */ Z(Mr, {
368
369
  testId: "markweave-image-download",
369
370
  label: u.download,
370
371
  icon: w,
371
372
  onClick: o
372
373
  }),
373
- /* @__PURE__ */ Z(Er, {
374
+ /* @__PURE__ */ Z(Mr, {
374
375
  testId: "markweave-image-replace",
375
376
  label: u.replace,
376
- icon: B,
377
+ icon: z,
377
378
  onClick: c
378
379
  }),
379
380
  /* @__PURE__ */ Z("span", {
380
381
  className: "markweave-image-toolbar-divider",
381
382
  "aria-hidden": "true"
382
383
  }),
383
- /* @__PURE__ */ Z(Er, {
384
+ /* @__PURE__ */ Z(Mr, {
384
385
  testId: "markweave-image-delete",
385
386
  label: u.delete,
386
- icon: pe,
387
+ icon: me,
387
388
  onClick: a
388
389
  })
389
390
  ]
390
391
  });
391
392
  }
392
- function Er({ active: e = !1, icon: t, label: n, onClick: r, testId: i }) {
393
+ function Mr({ active: e = !1, icon: t, label: n, onClick: r, testId: i }) {
393
394
  return /* @__PURE__ */ Q("button", {
394
395
  type: "button",
395
396
  "aria-label": n,
@@ -408,7 +409,7 @@ function Er({ active: e = !1, icon: t, label: n, onClick: r, testId: i }) {
408
409
  })]
409
410
  });
410
411
  }
411
- function Dr({ messages: e, onPointerDown: t, side: n }) {
412
+ function Nr({ messages: e, onPointerDown: t, side: n }) {
412
413
  return /* @__PURE__ */ Z("button", {
413
414
  type: "button",
414
415
  className: "markweave-image-resize-handle",
@@ -419,7 +420,7 @@ function Dr({ messages: e, onPointerDown: t, side: n }) {
419
420
  onPointerDown: (e) => t(n, e)
420
421
  });
421
422
  }
422
- var Or = Se.extend({
423
+ var Pr = Ce.extend({
423
424
  addOptions() {
424
425
  return {
425
426
  ...this.parent?.(),
@@ -428,33 +429,33 @@ var Or = Se.extend({
428
429
  };
429
430
  },
430
431
  addNodeView() {
431
- return typeof document > "u" ? null : o(Cr, { stopEvent: ({ event: e }) => Sr(e.target) });
432
+ return typeof document > "u" ? null : o(kr, { stopEvent: ({ event: e }) => Or(e.target) });
432
433
  }
433
434
  });
434
435
  //#endregion
435
436
  //#region src/media/video-node.tsx
436
- function kr(e) {
437
+ function Fr(e) {
437
438
  return e instanceof Element && !!e.closest("[data-markweave-video-ui=\"true\"], iframe[data-markweave-video-embed], video[data-markweave-video]");
438
439
  }
439
- function Ar(e) {
440
- let { deleteNode: t, editor: r, getPos: i, node: o, selected: s, updateAttributes: c } = e, l = e.extension.options, u = l.messages ?? n("zh"), d = u.video, f = Fe(br(r)), p = Y(o.attrs.src), m = Y(o.attrs.embedUrl), h = Y(o.attrs.provider), g = m ? J(m, h) : null, _ = Y(o.attrs.mimeType), v = Y(o.attrs.title), y = K(null), [b, x] = q(!1), [S, C] = q(""), [w, T] = q(null), [E, D] = q(!1), O = f && !p, k = () => {
440
+ function Ir(e) {
441
+ let { deleteNode: t, editor: r, getPos: i, node: o, selected: s, updateAttributes: c } = e, l = e.extension.options, u = l.messages ?? n("zh"), d = u.video, f = Fe(Er(r)), p = Y(o.attrs.src), m = Y(o.attrs.embedUrl), h = Y(o.attrs.provider), g = m ? J(m, h) : null, _ = Y(o.attrs.mimeType), v = Y(o.attrs.title), y = G(null), [b, x] = K(!1), [S, C] = K(""), [w, T] = K(null), [E, D] = K(!1), O = f && !p, k = () => {
441
442
  if (!f) return;
442
443
  let e = i();
443
444
  typeof e == "number" && r.chain().focus().setNodeSelection(e).run();
444
445
  }, A = (e) => {
445
- f && (kr(e.target) || (e.preventDefault(), k()));
446
+ f && (Fr(e.target) || (e.preventDefault(), k()));
446
447
  }, j = (e) => {
447
448
  f && (e.key === "Delete" || e.key === "Backspace") && s && (e.preventDefault(), t());
448
449
  }, M = async (e) => {
449
450
  if (!(!f || !e)) {
450
451
  T(null), D(!0);
451
452
  try {
452
- let t = await xe(ke({
453
+ let t = await Se(ke({
453
454
  type: "file",
454
455
  file: e,
455
456
  mimeType: e.type
456
457
  }), l.onUpload);
457
- c(Te(t)), C("");
458
+ c(Ee(t)), C("");
458
459
  } catch (e) {
459
460
  T(e instanceof Error ? e.message : d.uploadFailedError);
460
461
  } finally {
@@ -468,7 +469,7 @@ function Ar(e) {
468
469
  "data-testid": "markweave-video-node",
469
470
  "data-empty": "true",
470
471
  "data-selected": "false",
471
- children: /* @__PURE__ */ Z(jr, {
472
+ children: /* @__PURE__ */ Z(Lr, {
472
473
  dragActive: b,
473
474
  error: w,
474
475
  fileInputRef: y,
@@ -486,7 +487,7 @@ function Ar(e) {
486
487
  onInputChange: C,
487
488
  onSubmit: () => {
488
489
  if (!f) return;
489
- let e = Ee(S);
490
+ let e = De(S);
490
491
  if (!e) {
491
492
  T(d.unsupportedUrlError);
492
493
  return;
@@ -549,7 +550,7 @@ function Ar(e) {
549
550
  })
550
551
  });
551
552
  }
552
- function jr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitting: i, messages: a, onCancel: o, onDragActiveChange: s, onDrop: c, onFileChange: l, onInputChange: u, onSubmit: d }) {
553
+ function Lr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitting: i, messages: a, onCancel: o, onDragActiveChange: s, onDrop: c, onFileChange: l, onInputChange: u, onSubmit: d }) {
553
554
  let f = a.video;
554
555
  return /* @__PURE__ */ Q("section", {
555
556
  className: "markweave-video-upload-placeholder",
@@ -576,7 +577,7 @@ function jr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
576
577
  /* @__PURE__ */ Z("div", {
577
578
  className: "markweave-video-upload-icon",
578
579
  "aria-hidden": "true",
579
- children: /* @__PURE__ */ Z(_e, {
580
+ children: /* @__PURE__ */ Z(ve, {
580
581
  size: 46,
581
582
  strokeWidth: 1.6
582
583
  })
@@ -611,7 +612,7 @@ function jr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
611
612
  "data-testid": "markweave-video-upload-submit",
612
613
  disabled: i || !r.trim(),
613
614
  onClick: d,
614
- children: [/* @__PURE__ */ Z(ge, {
615
+ children: [/* @__PURE__ */ Z(_e, {
615
616
  size: 16,
616
617
  strokeWidth: 1.8
617
618
  }), a.common.insert]
@@ -631,7 +632,7 @@ function jr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
631
632
  ]
632
633
  });
633
634
  }
634
- var Mr = Ce.extend({
635
+ var Rr = we.extend({
635
636
  addOptions() {
636
637
  return {
637
638
  ...this.parent?.(),
@@ -640,30 +641,30 @@ var Mr = Ce.extend({
640
641
  };
641
642
  },
642
643
  addNodeView() {
643
- return typeof document > "u" ? null : o(Ar, { stopEvent: ({ event: e }) => kr(e.target) });
644
+ return typeof document > "u" ? null : o(Ir, { stopEvent: ({ event: e }) => Fr(e.target) });
644
645
  }
645
646
  });
646
647
  //#endregion
647
648
  //#region src/link-card-node.tsx
648
- function Nr(e) {
649
+ function zr(e) {
649
650
  return e instanceof Element && !!e.closest("[data-markweave-link-card-ui=\"true\"]");
650
651
  }
651
- function Pr(e) {
652
+ function Br(e) {
652
653
  return typeof navigator < "u" && navigator.clipboard?.writeText ? navigator.clipboard.writeText(e).catch(() => void 0) : Promise.resolve();
653
654
  }
654
- function Fr(e) {
655
+ function Vr(e) {
655
656
  !e || typeof window > "u" || window.open(e, "_blank", "noopener,noreferrer");
656
657
  }
657
- function Ir(e) {
658
+ function Hr(e) {
658
659
  try {
659
660
  return new URL(e).host;
660
661
  } catch {
661
662
  return e;
662
663
  }
663
664
  }
664
- function Lr(e) {
665
- let { deleteNode: t, editor: r, getPos: i, node: o, updateAttributes: s } = e, c = e.extension.options, l = c.messages ?? n("zh"), u = l.linkCard, d = Fe(br(r)), f = Ve(o.attrs), [p, m] = q(!1), [h, g] = q(!1), [_, v] = q(!1), [y, b] = q(f?.title ?? ""), [x, C] = q(f?.href ?? ""), w = K(null);
666
- if (U(() => () => w.current?.abort(), []), U(() => {
665
+ function Ur(e) {
666
+ let { deleteNode: t, editor: r, getPos: i, node: o, updateAttributes: s } = e, c = e.extension.options, l = c.messages ?? n("zh"), u = l.linkCard, d = Fe(Er(r)), f = Ve(o.attrs), [p, m] = K(!1), [h, g] = K(!1), [_, v] = K(!1), [y, b] = K(f?.title ?? ""), [x, C] = K(f?.href ?? ""), w = G(null);
667
+ if (H(() => () => w.current?.abort(), []), H(() => {
667
668
  b(f?.title ?? ""), C(f?.href ?? ""), v(!1);
668
669
  }, [f?.href, f?.title]), !f) return null;
669
670
  let T = async (e) => {
@@ -691,7 +692,7 @@ function Lr(e) {
691
692
  }, E = () => {
692
693
  let e = i();
693
694
  typeof e == "number" && Ue(r, e);
694
- }, D = _ ? null : f.imageUrl, O = Ir(f.href);
695
+ }, D = _ ? null : f.imageUrl, O = Hr(f.href);
695
696
  return /* @__PURE__ */ Q(a, {
696
697
  as: "article",
697
698
  className: "markweave-link-card",
@@ -702,10 +703,10 @@ function Lr(e) {
702
703
  onMouseEnter: () => m(!0),
703
704
  onMouseLeave: () => m(!1),
704
705
  onMouseDown: (e) => {
705
- Nr(e.target) || e.preventDefault();
706
+ zr(e.target) || e.preventDefault();
706
707
  },
707
708
  onClick: (e) => {
708
- Nr(e.target) || (e.preventDefault(), Fr(f.href));
709
+ zr(e.target) || (e.preventDefault(), Vr(f.href));
709
710
  },
710
711
  children: [
711
712
  /* @__PURE__ */ Q("a", {
@@ -743,21 +744,21 @@ function Lr(e) {
743
744
  "data-markweave-link-card-ui": "true",
744
745
  "aria-label": u.toolsAriaLabel,
745
746
  children: [
746
- /* @__PURE__ */ Z(Rr, {
747
+ /* @__PURE__ */ Z(Wr, {
747
748
  label: u.convertToLink,
748
- icon: I,
749
+ icon: te,
749
750
  onClick: E,
750
751
  testId: "markweave-link-card-convert"
751
752
  }),
752
- /* @__PURE__ */ Z(Rr, {
753
+ /* @__PURE__ */ Z(Wr, {
753
754
  label: u.copyAddress,
754
755
  icon: S,
755
- onClick: () => void Pr(f.href),
756
+ onClick: () => void Br(f.href),
756
757
  testId: "markweave-link-card-copy"
757
758
  }),
758
- /* @__PURE__ */ Z(Rr, {
759
+ /* @__PURE__ */ Z(Wr, {
759
760
  label: u.edit,
760
- icon: ie,
761
+ icon: ae,
761
762
  onClick: (e) => {
762
763
  let t = i();
763
764
  typeof t == "number" && We({
@@ -773,9 +774,9 @@ function Lr(e) {
773
774
  },
774
775
  testId: "markweave-link-card-edit"
775
776
  }),
776
- /* @__PURE__ */ Z(Rr, {
777
+ /* @__PURE__ */ Z(Wr, {
777
778
  label: u.delete,
778
- icon: pe,
779
+ icon: me,
779
780
  onClick: t,
780
781
  testId: "markweave-link-card-delete"
781
782
  })
@@ -803,14 +804,14 @@ function Lr(e) {
803
804
  type: "submit",
804
805
  "aria-label": u.edit,
805
806
  disabled: !He(x),
806
- children: /* @__PURE__ */ Z(I, { size: 16 })
807
+ children: /* @__PURE__ */ Z(te, { size: 16 })
807
808
  })
808
809
  ]
809
810
  }) : null
810
811
  ]
811
812
  });
812
813
  }
813
- function Rr({ icon: e, label: t, onClick: n, testId: r }) {
814
+ function Wr({ icon: e, label: t, onClick: n, testId: r }) {
814
815
  return /* @__PURE__ */ Q("button", {
815
816
  type: "button",
816
817
  "aria-label": t,
@@ -827,7 +828,7 @@ function Rr({ icon: e, label: t, onClick: n, testId: r }) {
827
828
  })]
828
829
  });
829
830
  }
830
- var zr = Ge.extend({
831
+ var Gr = Ge.extend({
831
832
  addOptions() {
832
833
  return {
833
834
  ...this.parent?.(),
@@ -836,23 +837,23 @@ var zr = Ge.extend({
836
837
  };
837
838
  },
838
839
  addNodeView() {
839
- return typeof document > "u" ? null : o(Lr, { stopEvent: ({ event: e }) => Nr(e.target) });
840
+ return typeof document > "u" ? null : o(Ur, { stopEvent: ({ event: e }) => zr(e.target) });
840
841
  }
841
842
  });
842
843
  //#endregion
843
844
  //#region src/create-editor-extensions.ts
844
- function Br(t = {}) {
845
+ function Kr(t = {}) {
845
846
  return e({
846
847
  lang: t.lang,
847
848
  onImageUpload: t.onImageUpload,
848
- linkCardExtension: zr.configure({
849
+ linkCardExtension: Gr.configure({
849
850
  lang: t.lang,
850
851
  messages: n(t.lang),
851
852
  resolver: t.linkCardResolver
852
853
  }),
853
854
  mediaExtensions: Be({
854
- image: Or,
855
- video: Mr,
855
+ image: Pr,
856
+ video: Rr,
856
857
  lang: t.lang,
857
858
  onImageUpload: t.onImageUpload,
858
859
  onVideoUpload: t.onVideoUpload
@@ -861,7 +862,7 @@ function Br(t = {}) {
861
862
  }
862
863
  //#endregion
863
864
  //#region src/ui/codeblock/CodeBlockControls.tsx
864
- function Vr(e) {
865
+ function qr(e) {
865
866
  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", {
866
867
  cx: "10",
867
868
  cy: "10",
@@ -898,7 +899,7 @@ function Vr(e) {
898
899
  /* @__PURE__ */ Z("path", { d: "m14 14 4 4" })
899
900
  ] }) : 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" });
900
901
  }
901
- function Hr({ icon: e }) {
902
+ function Jr({ icon: e }) {
902
903
  return /* @__PURE__ */ Z("svg", {
903
904
  viewBox: "0 0 24 24",
904
905
  "aria-hidden": "true",
@@ -909,63 +910,71 @@ function Hr({ icon: e }) {
909
910
  strokeLinecap: "round",
910
911
  strokeLinejoin: "round",
911
912
  strokeWidth: "1.8",
912
- children: Vr(e)
913
+ children: qr(e)
913
914
  })
914
915
  });
915
916
  }
916
- function Ur({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, readOnly: i = !1 }) {
917
- let a = K(null), o = K(null), s = K(null), c = K({
917
+ function Yr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, readOnly: i = !1 }) {
918
+ let a = G(null), o = G(null), s = G(null), c = G(null), l = G(null), u = G({
918
919
  active: !1,
919
920
  lastX: 0,
920
921
  lastY: 0
921
- }), [l, u] = q(null), [d, f] = q(null), [p, m] = q([]), [h, g] = q(null), [_, v] = q(!1), [y, b] = q(""), [x, S] = q(null), [C, w] = q(!1), [T, E] = q(null), [D, O] = q(null), [k, A] = q(!1), [j, M] = q(0), [N, P] = q(0), F = pt(t), ee = pn(t, l), I = !i && e && F.active && F.pos !== null ? {
922
- ...F,
923
- pos: F.pos,
922
+ }), [d, f] = K(null), [p, m] = K(null), [h, g] = K([]), [_, v] = K(null), [y, b] = K(!1), [x, S] = K(""), [C, w] = K(-1), [T, E] = K(null), [D, O] = K(!1), [k, A] = K(null), [j, M] = K(null), [N, P] = K(!1), [F, ee] = K(0), [te, I] = K(0), L = pt(t), ne = gn(t, d), re = !i && e && L.active && L.pos !== null ? {
923
+ ...L,
924
+ pos: L.pos,
924
925
  active: !0
925
- } : null, L = ee ?? I, te = L !== null, R = L?.language === "mermaid", z = _n(t, L), ne = te && L !== null && !z, re = !i, ie = sn(L ? L.language : "text"), ae = x?.status ?? "idle", B = L?.mermaidPreviewMode ?? n, V = R && B === "preview", oe = hn(t), se = `${N}|${oe.map((e) => `${e.pos}:${e.mermaidPreviewMode}:${e.text.length}`).join("|")}`, ce = G(() => dn(y.trim().toLowerCase()), [y]);
926
- if (U(() => {
927
- i && (v(!1), b(""));
928
- }, [i]), U(() => {
929
- if (!x) return;
926
+ } : null, R = ne ?? re, ie = R !== null, ae = R?.language === "mermaid", oe = xn(t, R), z = ie && R !== null && !oe, B = !i, se = ln(R ? R.language : "text"), ce = T?.status ?? "idle", le = R?.mermaidPreviewMode ?? n, ue = ae && le === "preview", de = yn(t), fe = `${te}|${de.map((e) => `${e.pos}:${e.mermaidPreviewMode}:${e.text.length}`).join("|")}`, pe = W(() => pn(x.trim().toLowerCase()), [x]);
927
+ if (H(() => {
928
+ i && (b(!1), S(""), w(-1));
929
+ }, [i]), H(() => {
930
+ if (!T) return;
930
931
  let e = window.setTimeout(() => {
931
- S(null);
932
- }, en);
932
+ E(null);
933
+ }, tn);
933
934
  return () => {
934
935
  window.clearTimeout(e);
935
936
  };
936
- }, [x]), U(() => {
937
- S(null), v(!1), b(""), E(null), O(null), A(!1);
937
+ }, [T]), H(() => {
938
+ E(null), b(!1), S(""), w(-1), A(null), M(null), P(!1);
938
939
  }, [
939
940
  e,
940
- L?.language,
941
- L?.pos,
942
- L?.text
943
- ]), U(() => {
941
+ R?.language,
942
+ R?.pos,
943
+ R?.text
944
+ ]), H(() => {
944
945
  let e = ({ transaction: e }) => {
945
- e.getMeta(dt) && M((e) => e + 1);
946
+ e.getMeta(dt) && ee((e) => e + 1);
946
947
  };
947
948
  return t.on("transaction", e), () => {
948
949
  t.off("transaction", e);
949
950
  };
950
- }, [t]), U(() => {
951
+ }, [t]), H(() => {
951
952
  let e = t.view.dom.closest(".markweave-editor-frame");
952
953
  if (!e) return;
953
954
  let n = (e) => {
954
- if (e.target instanceof Node && a.current?.contains(e.target) || _) return;
955
- let n = pn(t, fn(t, e.target)), r = n && !_n(t, n) ? n.pos : null;
956
- u((e) => e === r ? e : r);
955
+ if (e.target instanceof Node && a.current?.contains(e.target) || y) return;
956
+ let n = gn(t, hn(t, e.target)), r = n && !xn(t, n) ? n.pos : null;
957
+ f((e) => e === r ? e : r);
957
958
  }, r = () => {
958
- _ || u(null);
959
+ y || f(null);
959
960
  };
960
961
  return e.addEventListener("mousemove", n), e.addEventListener("mouseleave", r), () => {
961
962
  e.removeEventListener("mousemove", n), e.removeEventListener("mouseleave", r);
962
963
  };
963
- }, [t, _]), U(() => {
964
- _ && s.current?.focus({ preventScroll: !0 });
965
- }, [_]), U(() => {
966
- if (!T) return;
964
+ }, [t, y]), H(() => {
965
+ y && s.current?.focus({ preventScroll: !0 });
966
+ }, [y]), U(() => {
967
+ if (!y || C < 0) return;
968
+ let e = c.current, t = e?.querySelector(`[data-language-index="${C}"]`);
969
+ e && t && En(e, t);
970
+ }, [
971
+ C,
972
+ pe,
973
+ y
974
+ ]), H(() => {
975
+ if (!k) return;
967
976
  let e = (e) => {
968
- e.key === "Escape" && (E(null), O(null), A(!1), c.current = {
977
+ e.key === "Escape" && (A(null), M(null), P(!1), u.current = {
969
978
  active: !1,
970
979
  lastX: 0,
971
980
  lastY: 0
@@ -974,33 +983,33 @@ function Ur({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
974
983
  return document.addEventListener("keydown", e), () => {
975
984
  document.removeEventListener("keydown", e);
976
985
  };
977
- }, [t, T]), U(() => {
978
- if (!te || !_) return;
986
+ }, [t, k]), H(() => {
987
+ if (!ie || !y) return;
979
988
  let e = (e) => {
980
- e.key === "Escape" && (v(!1), t.view.focus());
989
+ e.key === "Escape" && (b(!1), w(-1), t.view.focus());
981
990
  }, n = (e) => {
982
- e.target instanceof Node && a.current?.contains(e.target) || v(!1);
991
+ e.target instanceof Node && a.current?.contains(e.target) || (b(!1), w(-1));
983
992
  };
984
993
  return document.addEventListener("keydown", e), document.addEventListener("mousedown", n), () => {
985
994
  document.removeEventListener("keydown", e), document.removeEventListener("mousedown", n);
986
995
  };
987
996
  }, [
988
- te,
997
+ ie,
989
998
  t,
990
- _
991
- ]), W(() => {
999
+ y
1000
+ ]), U(() => {
992
1001
  let e = () => {
993
1002
  let e = a.current;
994
1003
  if (!e) return;
995
- if (!mn(e) || oe.length === 0) {
996
- m([]);
1004
+ if (!_n(e) || de.length === 0) {
1005
+ g([]);
997
1006
  return;
998
1007
  }
999
- let n = e.getBoundingClientRect(), r = oe.flatMap((e) => {
1000
- let r = un(ln(t, e.pos, e.mermaidPreviewMode), n);
1001
- return r ? [an(e, r, n)] : [];
1008
+ let n = e.getBoundingClientRect(), r = de.flatMap((e) => {
1009
+ let r = fn(dn(t, e.pos, e.mermaidPreviewMode), n);
1010
+ return r ? [sn(e, r, n)] : [];
1002
1011
  });
1003
- m((e) => vn(e, r, oe.map((e) => e.pos)));
1012
+ g((e) => Sn(e, r, de.map((e) => e.pos)));
1004
1013
  };
1005
1014
  e();
1006
1015
  let n = window.requestAnimationFrame(e);
@@ -1008,26 +1017,26 @@ function Ur({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1008
1017
  window.cancelAnimationFrame(n), window.removeEventListener("resize", e), window.removeEventListener("scroll", e, !0);
1009
1018
  };
1010
1019
  }, [
1011
- j,
1020
+ F,
1012
1021
  t,
1013
- se
1014
- ]), W(() => {
1015
- if (!ne || !L) {
1016
- f(null), g(null);
1022
+ fe
1023
+ ]), U(() => {
1024
+ if (!z || !R) {
1025
+ m(null), v(null);
1017
1026
  return;
1018
1027
  }
1019
1028
  let e = () => {
1020
1029
  let e = a.current;
1021
1030
  if (!e) return;
1022
- let n = ln(t, L.pos, B), r = e.getBoundingClientRect(), i = un(n, r);
1031
+ let n = dn(t, R.pos, le), r = e.getBoundingClientRect(), i = fn(n, r);
1023
1032
  if (!i) {
1024
- f((e) => e?.pos === L.pos ? e : null), g((e) => _ ? e : null);
1033
+ m((e) => e?.pos === R.pos ? e : null), v((e) => y ? e : null);
1025
1034
  return;
1026
1035
  }
1027
- let s = nn(L.pos, i, r);
1028
- if (f(s), _ && o.current) {
1036
+ let s = an(R.pos, i, r);
1037
+ if (m(s), y && o.current) {
1029
1038
  let e = o.current.getBoundingClientRect();
1030
- g(Qt({
1039
+ v($t({
1031
1040
  overlayRect: r,
1032
1041
  buttonRect: e,
1033
1042
  windowWidth: window.innerWidth,
@@ -1039,93 +1048,115 @@ function Ur({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1039
1048
  window.removeEventListener("resize", e), window.removeEventListener("scroll", e, !0);
1040
1049
  };
1041
1050
  }, [
1042
- ne,
1043
- j,
1044
- L?.pos,
1051
+ z,
1052
+ F,
1053
+ R?.pos,
1045
1054
  t,
1046
- _,
1047
- B
1048
- ]), !ne && oe.length === 0 && !T) return null;
1049
- let le = d ? {
1050
- top: d.top,
1051
- right: d.right
1052
- } : void 0, ue = async () => {
1055
+ y,
1056
+ le
1057
+ ]), !z && de.length === 0 && !k) return null;
1058
+ let me = p ? {
1059
+ top: p.top,
1060
+ right: p.right
1061
+ } : void 0, he = async () => {
1053
1062
  if (i) {
1054
- if (!L) return;
1055
- let e = await tn(L.text);
1056
- S(mt(L, e ? "copied" : "failed"));
1063
+ if (!R) return;
1064
+ let e = await nn(R.text);
1065
+ E(mt(R, e ? "copied" : "failed"));
1057
1066
  return;
1058
1067
  }
1059
- if (!on(t, L)) return;
1068
+ if (!cn(t, R)) return;
1060
1069
  let e = await ft(t);
1061
- S(mt(pt(t), e ? "copied" : "failed")), t.view.focus();
1062
- }, de = (e, n) => {
1070
+ E(mt(pt(t), e ? "copied" : "failed")), t.view.focus();
1071
+ }, ge = (e, n) => {
1063
1072
  if (i) {
1064
- St(t, e.pos, n) && P((e) => e + 1);
1073
+ St(t, e.pos, n) && I((e) => e + 1);
1065
1074
  return;
1066
1075
  }
1067
- let a = F.active && F.pos === e.pos;
1068
- vt(t, e.pos, n) && (r(n), P((e) => e + 1), a && t.view.focus());
1069
- }, fe = (e) => {
1070
- if (i || !L) return;
1071
- let n = F.active && F.pos === L.pos;
1072
- _t(t, L.pos, e) && (e === "mermaid" && vt(t, L.pos, "preview") && r("preview"), v(!1), b(""), P((e) => e + 1), n && t.view.focus());
1073
- }, pe = () => {
1074
- i || !L || gt(t, L.pos, !z) && (M((e) => e + 1), u(null));
1075
- }, me = () => {
1076
- if (!L) return;
1077
- let e = gn(t, L.pos);
1078
- if (!e) return;
1079
- let n = new Blob([e], { type: "image/svg+xml" }), r = URL.createObjectURL(n), i = document.createElement("a");
1080
- i.href = r, i.download = "markweave-mermaid.svg", i.click(), URL.revokeObjectURL(r), t.view.focus();
1081
- }, he = () => {
1082
- if (!L) return;
1083
- let e = gn(t, L.pos);
1084
- e && (E(rn(e)), O(null), A(!1), c.current = {
1076
+ let a = L.active && L.pos === e.pos;
1077
+ vt(t, e.pos, n) && (r(n), I((e) => e + 1), a && t.view.focus());
1078
+ }, _e = (e) => {
1079
+ if (i || !R) return;
1080
+ let n = L.active && L.pos === R.pos;
1081
+ _t(t, R.pos, e) && (e === "mermaid" && vt(t, R.pos, "preview") && r("preview"), b(!1), S(""), w(-1), I((e) => e + 1), n && t.view.focus());
1082
+ }, ve = () => {
1083
+ let e = !y;
1084
+ e && l.current === null && (l.current = rn()), w(e ? vn(pe, R?.language ?? null) : -1), b(e);
1085
+ }, V = (e) => {
1086
+ let t = pn(e);
1087
+ S(e), w(vn(t, e.trim() ? null : R?.language ?? null));
1088
+ }, ye = (e) => {
1089
+ if (!e.nativeEvent.isComposing) {
1090
+ if (e.key === "ArrowDown" || e.key === "ArrowUp") {
1091
+ e.preventDefault(), w((t) => wn(t, pe.length, e.key === "ArrowUp" ? "previous" : "next"));
1092
+ return;
1093
+ }
1094
+ if (e.key === "Enter") {
1095
+ let t = pe[C];
1096
+ t && (e.preventDefault(), _e(t.language));
1097
+ return;
1098
+ }
1099
+ e.key === "Escape" && (e.preventDefault(), b(!1), w(-1), t.view.focus());
1100
+ }
1101
+ }, be = pe[C], xe = l.current && be ? mn(l.current, be.language) : void 0, Se = () => {
1102
+ i || !R || gt(t, R.pos, !oe) && (ee((e) => e + 1), f(null));
1103
+ }, Ce = () => {
1104
+ if (!R) return;
1105
+ let e = bn(t, R.pos);
1106
+ e && Qt({
1107
+ data: new Blob([e], { type: "image/svg+xml" }),
1108
+ fileName: "markweave-mermaid.svg",
1109
+ onSettled: () => t.view.focus(),
1110
+ ownerDocument: document
1111
+ });
1112
+ }, we = () => {
1113
+ if (!R) return;
1114
+ let e = bn(t, R.pos);
1115
+ e && (A(on(e)), M(null), P(!1), u.current = {
1085
1116
  active: !1,
1086
1117
  lastX: 0,
1087
1118
  lastY: 0
1088
1119
  });
1089
- }, ge = () => {
1090
- E(null), O(null), A(!1), c.current = {
1120
+ }, Te = () => {
1121
+ A(null), M(null), P(!1), u.current = {
1091
1122
  active: !1,
1092
1123
  lastX: 0,
1093
1124
  lastY: 0
1094
1125
  }, t.view.focus();
1095
- }, _e = (e) => {
1096
- E((t) => t && {
1126
+ }, Ee = (e) => {
1127
+ A((t) => t && {
1097
1128
  ...t,
1098
- scale: $t(t.scale + e)
1129
+ scale: en(t.scale + e)
1099
1130
  });
1100
- }, H = () => {
1101
- E((e) => e && rn(e.svg)), c.current = {
1131
+ }, De = () => {
1132
+ A((e) => e && on(e.svg)), u.current = {
1102
1133
  active: !1,
1103
1134
  lastX: 0,
1104
1135
  lastY: 0
1105
- }, A(!1);
1106
- }, ve = (e) => {
1107
- e.preventDefault(), _e(e.deltaY < 0 ? yn : -yn);
1108
- }, ye = (e) => {
1109
- e.button === 0 && (e.preventDefault(), c.current = {
1136
+ }, P(!1);
1137
+ }, Oe = (e) => {
1138
+ e.preventDefault(), Ee(e.deltaY < 0 ? Cn : -Cn);
1139
+ }, q = (e) => {
1140
+ e.button === 0 && (e.preventDefault(), u.current = {
1110
1141
  active: !0,
1111
1142
  lastX: e.clientX,
1112
1143
  lastY: e.clientY
1113
- }, A(!0));
1114
- }, be = (e) => {
1115
- let t = c.current;
1144
+ }, P(!0));
1145
+ }, ke = (e) => {
1146
+ let t = u.current;
1116
1147
  if (!t.active) return;
1117
1148
  let n = e.clientX - t.lastX, r = e.clientY - t.lastY;
1118
- c.current = {
1149
+ u.current = {
1119
1150
  active: !0,
1120
1151
  lastX: e.clientX,
1121
1152
  lastY: e.clientY
1122
- }, E((e) => bn(e, n, r));
1123
- }, xe = () => {
1124
- c.current = {
1153
+ }, A((e) => Tn(e, n, r));
1154
+ }, Ae = () => {
1155
+ u.current = {
1125
1156
  active: !1,
1126
1157
  lastX: 0,
1127
1158
  lastY: 0
1128
- }, A(!1);
1159
+ }, P(!1);
1129
1160
  };
1130
1161
  return /* @__PURE__ */ Q("div", {
1131
1162
  ref: a,
@@ -1133,8 +1164,8 @@ function Ur({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1133
1164
  "data-testid": "markweave-codeblock-overlay",
1134
1165
  "data-read-only": i ? "true" : "false",
1135
1166
  children: [
1136
- oe.map((e) => {
1137
- let t = p.find((t) => t.pos === e.pos);
1167
+ de.map((e) => {
1168
+ let t = h.find((t) => t.pos === e.pos);
1138
1169
  return /* @__PURE__ */ Z("div", {
1139
1170
  className: "markweave-mermaid-tabs",
1140
1171
  "data-testid": "markweave-mermaid-tabs",
@@ -1149,47 +1180,47 @@ function Ur({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1149
1180
  "data-testid": `markweave-mermaid-mode-${t}`,
1150
1181
  "data-active": e.mermaidPreviewMode === t,
1151
1182
  onMouseDown: (e) => e.preventDefault(),
1152
- onClick: () => de(e, t),
1183
+ onClick: () => ge(e, t),
1153
1184
  children: t === "code" ? "Code" : "Preview"
1154
1185
  }, t))
1155
1186
  }, e.pos);
1156
1187
  }),
1157
- ne ? /* @__PURE__ */ Q("div", {
1188
+ z ? /* @__PURE__ */ Q("div", {
1158
1189
  className: "markweave-codeblock-controls",
1159
1190
  "data-testid": "markweave-codeblock-controls",
1160
- "data-positioned": d ? "true" : "false",
1161
- "data-collapsed": z ? "true" : "false",
1191
+ "data-positioned": p ? "true" : "false",
1192
+ "data-collapsed": oe ? "true" : "false",
1162
1193
  "data-read-only": i ? "true" : "false",
1163
1194
  "aria-label": "Code block controls",
1164
- style: le,
1195
+ style: me,
1165
1196
  children: [
1166
1197
  i ? /* @__PURE__ */ Z("span", {
1167
1198
  className: "markweave-codeblock-language-button markweave-codeblock-language-label",
1168
1199
  "aria-label": "Code block language",
1169
1200
  "data-testid": "markweave-codeblock-language",
1170
- children: /* @__PURE__ */ Z("span", { children: ie })
1201
+ children: /* @__PURE__ */ Z("span", { children: se })
1171
1202
  }) : /* @__PURE__ */ Q("button", {
1172
1203
  ref: o,
1173
1204
  type: "button",
1174
1205
  className: "markweave-codeblock-language-button",
1175
1206
  "aria-label": "Code block language",
1176
- "aria-expanded": _,
1207
+ "aria-expanded": y,
1177
1208
  "aria-haspopup": "listbox",
1178
1209
  "data-testid": "markweave-codeblock-language",
1179
1210
  onMouseDown: (e) => e.preventDefault(),
1180
- onClick: () => v((e) => !e),
1181
- children: [/* @__PURE__ */ Z("span", { children: ie }), /* @__PURE__ */ Z(Hr, { icon: "chevron" })]
1211
+ onClick: ve,
1212
+ children: [/* @__PURE__ */ Z("span", { children: se }), /* @__PURE__ */ Z(Jr, { icon: "chevron" })]
1182
1213
  }),
1183
- re ? /* @__PURE__ */ Z("button", {
1214
+ B ? /* @__PURE__ */ Z("button", {
1184
1215
  type: "button",
1185
1216
  className: "markweave-codeblock-icon-button markweave-codeblock-collapse-button",
1186
- "aria-label": z ? "Expand code block" : "Collapse code block",
1187
- title: z ? "Expand code block" : "Collapse code block",
1217
+ "aria-label": oe ? "Expand code block" : "Collapse code block",
1218
+ title: oe ? "Expand code block" : "Collapse code block",
1188
1219
  "data-testid": "markweave-codeblock-collapse",
1189
- "data-collapsed": z ? "true" : "false",
1220
+ "data-collapsed": oe ? "true" : "false",
1190
1221
  onMouseDown: (e) => e.preventDefault(),
1191
- onClick: pe,
1192
- children: /* @__PURE__ */ Z(Hr, { icon: "chevron" })
1222
+ onClick: Se,
1223
+ children: /* @__PURE__ */ Z(Jr, { icon: "chevron" })
1193
1224
  }) : null,
1194
1225
  /* @__PURE__ */ Q("span", {
1195
1226
  className: "markweave-codeblock-copy-wrap",
@@ -1198,22 +1229,22 @@ function Ur({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1198
1229
  className: "markweave-codeblock-icon-button",
1199
1230
  "aria-label": "Copy to clipboard",
1200
1231
  "data-testid": "markweave-codeblock-copy",
1201
- "data-copy-state": ae,
1232
+ "data-copy-state": ce,
1202
1233
  onMouseDown: (e) => e.preventDefault(),
1203
- onMouseEnter: () => w(!0),
1204
- onMouseLeave: () => w(!1),
1205
- onFocus: () => w(!0),
1206
- onBlur: () => w(!1),
1207
- onClick: ue,
1208
- children: /* @__PURE__ */ Z(Hr, { icon: ae === "copied" ? "check" : "clipboard" })
1209
- }), C ? /* @__PURE__ */ Z("span", {
1234
+ onMouseEnter: () => O(!0),
1235
+ onMouseLeave: () => O(!1),
1236
+ onFocus: () => O(!0),
1237
+ onBlur: () => O(!1),
1238
+ onClick: he,
1239
+ children: /* @__PURE__ */ Z(Jr, { icon: ce === "copied" ? "check" : "clipboard" })
1240
+ }), D ? /* @__PURE__ */ Z("span", {
1210
1241
  className: "markweave-codeblock-tooltip",
1211
1242
  role: "tooltip",
1212
1243
  "data-testid": "markweave-codeblock-copy-tooltip",
1213
1244
  children: "Copy to clipboard"
1214
1245
  }) : null]
1215
1246
  }),
1216
- R && B === "preview" ? /* @__PURE__ */ Q("div", {
1247
+ ae && le === "preview" ? /* @__PURE__ */ Q("div", {
1217
1248
  className: "markweave-mermaid-preview-actions",
1218
1249
  "data-testid": "markweave-mermaid-preview-actions",
1219
1250
  children: [/* @__PURE__ */ Z("button", {
@@ -1221,63 +1252,73 @@ function Ur({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1221
1252
  className: "markweave-codeblock-icon-button",
1222
1253
  "aria-label": "Fullscreen Mermaid preview",
1223
1254
  "data-testid": "markweave-mermaid-fullscreen",
1224
- disabled: !V,
1255
+ disabled: !ue,
1225
1256
  onMouseDown: (e) => e.preventDefault(),
1226
- onClick: he,
1227
- children: /* @__PURE__ */ Z(Hr, { icon: "expand" })
1257
+ onClick: we,
1258
+ children: /* @__PURE__ */ Z(Jr, { icon: "expand" })
1228
1259
  }), /* @__PURE__ */ Z("button", {
1229
1260
  type: "button",
1230
1261
  className: "markweave-codeblock-icon-button",
1231
1262
  "aria-label": "Download Mermaid SVG",
1232
1263
  "data-testid": "markweave-mermaid-download",
1233
- disabled: !V,
1264
+ disabled: !ue,
1234
1265
  onMouseDown: (e) => e.preventDefault(),
1235
- onClick: me,
1236
- children: /* @__PURE__ */ Z(Hr, { icon: "download" })
1266
+ onClick: Ce,
1267
+ children: /* @__PURE__ */ Z(Jr, { icon: "download" })
1237
1268
  })]
1238
1269
  }) : null
1239
1270
  ]
1240
1271
  }) : null,
1241
- re && ne && _ ? /* @__PURE__ */ Q("div", {
1272
+ B && z && y ? /* @__PURE__ */ Q("div", {
1242
1273
  className: "markweave-codeblock-language-menu",
1243
- role: "listbox",
1244
- "aria-label": "Code block languages",
1245
1274
  "data-testid": "markweave-codeblock-language-menu",
1246
- "data-positioned": h ? "true" : "false",
1247
- style: h ? {
1248
- left: h.left,
1249
- top: h.top
1275
+ "data-positioned": _ ? "true" : "false",
1276
+ style: _ ? {
1277
+ left: _.left,
1278
+ top: _.top
1250
1279
  } : void 0,
1251
1280
  children: [/* @__PURE__ */ Q("label", {
1252
1281
  className: "markweave-codeblock-language-search",
1253
1282
  children: [/* @__PURE__ */ Z("input", {
1254
1283
  ref: s,
1255
- value: y,
1284
+ role: "combobox",
1285
+ "aria-autocomplete": "list",
1286
+ "aria-controls": l.current ?? void 0,
1287
+ "aria-expanded": "true",
1288
+ "aria-activedescendant": xe,
1289
+ "aria-label": "Search code block languages",
1290
+ value: x,
1256
1291
  placeholder: "Search...",
1257
1292
  "data-testid": "markweave-codeblock-language-search",
1258
- onChange: (e) => b(e.target.value),
1259
- onKeyDown: (e) => {
1260
- e.key === "Escape" && (e.preventDefault(), v(!1), t.view.focus());
1261
- }
1262
- }), /* @__PURE__ */ Z(Hr, { icon: "search" })]
1293
+ onChange: (e) => V(e.target.value),
1294
+ onKeyDown: ye
1295
+ }), /* @__PURE__ */ Z(Jr, { icon: "search" })]
1263
1296
  }), /* @__PURE__ */ Z("div", {
1297
+ ref: c,
1298
+ id: l.current ?? void 0,
1264
1299
  className: "markweave-codeblock-language-list",
1265
- children: ce.map((e) => {
1266
- let t = e.language === L.language;
1300
+ role: "listbox",
1301
+ "aria-label": "Code block languages",
1302
+ children: pe.map((e, t) => {
1303
+ let n = e.language === R.language, r = t === C;
1267
1304
  return /* @__PURE__ */ Q("button", {
1305
+ id: l.current ? mn(l.current, e.language) : void 0,
1268
1306
  type: "button",
1269
1307
  role: "option",
1270
- "aria-selected": t,
1308
+ "aria-selected": n,
1271
1309
  "data-testid": `markweave-codeblock-language-option-${e.language}`,
1272
- "data-active": t ? "true" : "false",
1310
+ "data-active": n ? "true" : "false",
1311
+ "data-highlighted": r ? "true" : "false",
1312
+ "data-language-index": t,
1273
1313
  onMouseDown: (e) => e.preventDefault(),
1274
- onClick: () => fe(e.language),
1275
- children: [/* @__PURE__ */ Z("span", { children: e.label }), t ? /* @__PURE__ */ Z(Hr, { icon: "check" }) : null]
1314
+ onMouseEnter: () => w(t),
1315
+ onClick: () => _e(e.language),
1316
+ children: [/* @__PURE__ */ Z("span", { children: e.label }), n ? /* @__PURE__ */ Z(Jr, { icon: "check" }) : null]
1276
1317
  }, e.language);
1277
1318
  })
1278
1319
  })]
1279
1320
  }) : null,
1280
- T ? /* @__PURE__ */ Q("div", {
1321
+ k ? /* @__PURE__ */ Q("div", {
1281
1322
  className: "markweave-mermaid-fullscreen-layer",
1282
1323
  role: "dialog",
1283
1324
  "aria-modal": "true",
@@ -1293,47 +1334,47 @@ function Ur({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1293
1334
  className: "markweave-mermaid-fullscreen-control",
1294
1335
  "aria-label": "Zoom out",
1295
1336
  "data-testid": "markweave-mermaid-fullscreen-zoom-out",
1296
- onMouseEnter: () => O("zoom-out"),
1297
- onMouseLeave: () => O(null),
1298
- onFocus: () => O("zoom-out"),
1299
- onBlur: () => O(null),
1300
- onClick: () => _e(-yn),
1301
- children: /* @__PURE__ */ Z(Hr, { icon: "zoomOut" })
1337
+ onMouseEnter: () => M("zoom-out"),
1338
+ onMouseLeave: () => M(null),
1339
+ onFocus: () => M("zoom-out"),
1340
+ onBlur: () => M(null),
1341
+ onClick: () => Ee(-Cn),
1342
+ children: /* @__PURE__ */ Z(Jr, { icon: "zoomOut" })
1302
1343
  }),
1303
1344
  /* @__PURE__ */ Z("span", {
1304
1345
  className: "markweave-mermaid-fullscreen-zoom-label",
1305
1346
  "data-testid": "markweave-mermaid-fullscreen-zoom-label",
1306
- children: cn(T.scale)
1347
+ children: un(k.scale)
1307
1348
  }),
1308
1349
  /* @__PURE__ */ Z("button", {
1309
1350
  type: "button",
1310
1351
  className: "markweave-mermaid-fullscreen-control",
1311
1352
  "aria-label": "Zoom in",
1312
1353
  "data-testid": "markweave-mermaid-fullscreen-zoom-in",
1313
- onMouseEnter: () => O("zoom-in"),
1314
- onMouseLeave: () => O(null),
1315
- onFocus: () => O("zoom-in"),
1316
- onBlur: () => O(null),
1317
- onClick: () => _e(yn),
1318
- children: /* @__PURE__ */ Z(Hr, { icon: "zoomIn" })
1354
+ onMouseEnter: () => M("zoom-in"),
1355
+ onMouseLeave: () => M(null),
1356
+ onFocus: () => M("zoom-in"),
1357
+ onBlur: () => M(null),
1358
+ onClick: () => Ee(Cn),
1359
+ children: /* @__PURE__ */ Z(Jr, { icon: "zoomIn" })
1319
1360
  }),
1320
1361
  /* @__PURE__ */ Z("button", {
1321
1362
  type: "button",
1322
1363
  className: "markweave-mermaid-fullscreen-control",
1323
1364
  "aria-label": "Reset zoom",
1324
1365
  "data-testid": "markweave-mermaid-fullscreen-reset",
1325
- onMouseEnter: () => O("reset"),
1326
- onMouseLeave: () => O(null),
1327
- onFocus: () => O("reset"),
1328
- onBlur: () => O(null),
1329
- onClick: H,
1330
- children: /* @__PURE__ */ Z(Hr, { icon: "reset" })
1366
+ onMouseEnter: () => M("reset"),
1367
+ onMouseLeave: () => M(null),
1368
+ onFocus: () => M("reset"),
1369
+ onBlur: () => M(null),
1370
+ onClick: De,
1371
+ children: /* @__PURE__ */ Z(Jr, { icon: "reset" })
1331
1372
  }),
1332
- D ? /* @__PURE__ */ Z("span", {
1373
+ j ? /* @__PURE__ */ Z("span", {
1333
1374
  className: "markweave-mermaid-fullscreen-tooltip",
1334
1375
  role: "tooltip",
1335
1376
  "data-testid": "markweave-mermaid-fullscreen-tooltip",
1336
- children: D === "zoom-out" ? "Zoom out" : D === "zoom-in" ? "Zoom in" : "Reset"
1377
+ children: j === "zoom-out" ? "Zoom out" : j === "zoom-in" ? "Zoom in" : "Reset"
1337
1378
  }) : null
1338
1379
  ]
1339
1380
  }),
@@ -1342,29 +1383,29 @@ function Ur({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1342
1383
  className: "markweave-mermaid-fullscreen-close",
1343
1384
  "aria-label": "Close fullscreen Mermaid preview",
1344
1385
  "data-testid": "markweave-mermaid-fullscreen-close",
1345
- onClick: ge,
1346
- children: /* @__PURE__ */ Z(Hr, { icon: "close" })
1386
+ onClick: Te,
1387
+ children: /* @__PURE__ */ Z(Jr, { icon: "close" })
1347
1388
  }),
1348
1389
  /* @__PURE__ */ Z("div", {
1349
1390
  className: "markweave-mermaid-fullscreen-viewport",
1350
1391
  "data-testid": "markweave-mermaid-fullscreen-viewport",
1351
- "data-dragging": k ? "true" : "false",
1352
- onWheel: ve,
1353
- onMouseDown: ye,
1354
- onMouseMove: be,
1355
- onMouseUp: xe,
1356
- onMouseLeave: xe,
1392
+ "data-dragging": N ? "true" : "false",
1393
+ onWheel: Oe,
1394
+ onMouseDown: q,
1395
+ onMouseMove: ke,
1396
+ onMouseUp: Ae,
1397
+ onMouseLeave: Ae,
1357
1398
  children: /* @__PURE__ */ Z("div", {
1358
1399
  className: "markweave-mermaid-fullscreen-content",
1359
1400
  "data-testid": "markweave-mermaid-fullscreen-content",
1360
- "data-scale-percent": Math.round(T.scale * 100),
1361
- "data-translate": `${Math.round(T.translateX)},${Math.round(T.translateY)}`,
1401
+ "data-scale-percent": Math.round(k.scale * 100),
1402
+ "data-translate": `${Math.round(k.translateX)},${Math.round(k.translateY)}`,
1362
1403
  style: {
1363
- width: `${T.width}px`,
1364
- height: `${T.height}px`,
1365
- transform: `translate(${T.translateX}px, ${T.translateY}px) scale(${T.scale})`
1404
+ width: `${k.width}px`,
1405
+ height: `${k.height}px`,
1406
+ transform: `translate(${k.translateX}px, ${k.translateY}px) scale(${k.scale})`
1366
1407
  },
1367
- dangerouslySetInnerHTML: { __html: T.svg }
1408
+ dangerouslySetInnerHTML: { __html: k.svg }
1368
1409
  })
1369
1410
  })
1370
1411
  ]
@@ -1374,25 +1415,25 @@ function Ur({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1374
1415
  }
1375
1416
  //#endregion
1376
1417
  //#region src/ui/floating-toolbar/FloatingToolbar.tsx
1377
- var Wr = n("zh");
1378
- function Gr() {
1418
+ var Xr = n("zh");
1419
+ function Zr() {
1379
1420
  return typeof performance > "u" ? Date.now() : performance.now();
1380
1421
  }
1381
- function Kr(e, t) {
1422
+ function Qr(e, t) {
1382
1423
  return {
1383
1424
  "--markweave-toolbar-motion-duration": `${e.motionDurationMs}ms`,
1384
1425
  "--markweave-toolbar-motion-easing": e.motionEasing,
1385
1426
  marginLeft: t === 0 ? void 0 : `${t}px`
1386
1427
  };
1387
1428
  }
1388
- function qr(e, t) {
1429
+ function $r(e, t) {
1389
1430
  let n = e?.getBoundingClientRect().height ?? 0, r = t?.getBoundingClientRect().height ?? 0;
1390
1431
  return Math.max(n, r, 44);
1391
1432
  }
1392
- function Jr(e) {
1433
+ function ei(e) {
1393
1434
  if (e !== null) return { "--markweave-floating-toolbar-tooltip-left": `${e}px` };
1394
1435
  }
1395
- function Yr(e, t, n, r) {
1436
+ function ti(e, t, n, r) {
1396
1437
  let i = {
1397
1438
  bottom: t + r,
1398
1439
  height: r,
@@ -1408,26 +1449,26 @@ function Yr(e, t, n, r) {
1408
1449
  toJSON: () => i
1409
1450
  };
1410
1451
  }
1411
- function Xr(e) {
1452
+ function ni(e) {
1412
1453
  return e.width > 0 && e.height > 0;
1413
1454
  }
1414
- function Zr(e) {
1455
+ function ri(e) {
1415
1456
  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));
1416
- return Yr(t, n, r - t, i - n);
1457
+ return ti(t, n, r - t, i - n);
1417
1458
  }
1418
- function Qr(e, t) {
1459
+ function ii(e, t) {
1419
1460
  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;
1420
1461
  return r(t.anchorNode) && r(t.focusNode);
1421
1462
  }
1422
- function $r(e) {
1463
+ function ai(e) {
1423
1464
  if (typeof e.getClientRects != "function") return null;
1424
- let t = Array.from(e.getClientRects()).filter(Xr).map((e) => Yr(e.left, e.top, e.width, e.height));
1465
+ let t = Array.from(e.getClientRects()).filter(ni).map((e) => ti(e.left, e.top, e.width, e.height));
1425
1466
  if (t.length > 0) return t;
1426
1467
  if (typeof e.getBoundingClientRect != "function") return null;
1427
1468
  let n = e.getBoundingClientRect();
1428
- return Xr(n) ? [Yr(n.left, n.top, n.width, n.height)] : null;
1469
+ return ni(n) ? [ti(n.left, n.top, n.width, n.height)] : null;
1429
1470
  }
1430
- function ei(e, t) {
1471
+ function oi(e, t) {
1431
1472
  if (t.rangeCount === 0) return null;
1432
1473
  let n = t.getRangeAt(0);
1433
1474
  try {
@@ -1440,8 +1481,8 @@ function ei(e, t) {
1440
1481
  return null;
1441
1482
  }
1442
1483
  }
1443
- function ti(e, t) {
1444
- let n = ei(e, t);
1484
+ function si(e, t) {
1485
+ let n = oi(e, t);
1445
1486
  if (!n) return !1;
1446
1487
  let { selection: r } = e.state, i = {
1447
1488
  from: Math.min(r.from, r.to),
@@ -1449,51 +1490,51 @@ function ti(e, t) {
1449
1490
  };
1450
1491
  return n.from === i.from && n.to === i.to;
1451
1492
  }
1452
- function ni(e) {
1493
+ function ci(e) {
1453
1494
  let t = e.view.dom.ownerDocument.getSelection();
1454
- return !t || t.rangeCount === 0 || t.isCollapsed || !Qr(e, t) || !ti(e, t) ? null : $r(t.getRangeAt(0));
1495
+ return !t || t.rangeCount === 0 || t.isCollapsed || !ii(e, t) || !si(e, t) ? null : ai(t.getRangeAt(0));
1455
1496
  }
1456
- function ri(e) {
1497
+ function li(e) {
1457
1498
  let { selection: t } = e.state;
1458
1499
  if (t.empty) return null;
1459
1500
  let n = Math.min(t.from, t.to), r = Math.max(t.from, t.to);
1460
1501
  try {
1461
1502
  let t = e.view.domAtPos(n), i = e.view.domAtPos(r), a = e.view.dom.ownerDocument.createRange();
1462
- return a.setStart(t.node, t.offset), a.setEnd(i.node, i.offset), $r(a);
1503
+ return a.setStart(t.node, t.offset), a.setEnd(i.node, i.offset), ai(a);
1463
1504
  } catch {
1464
1505
  return null;
1465
1506
  }
1466
1507
  }
1467
- function ii(e) {
1508
+ function ui(e) {
1468
1509
  let { selection: t } = e.state;
1469
1510
  if (t.empty) return null;
1470
- let n = Math.min(t.from, t.to), r = Math.max(t.from, t.to), i = e.view.coordsAtPos(n), a = e.view.coordsAtPos(r, -1), o = Math.min(i.top, a.top), s = Math.max(i.bottom, a.bottom), c = Math.min(i.left, a.left), l = Yr(c, o, Math.max(i.right, a.right) - c, s - o);
1471
- return Xr(l) ? [l] : null;
1511
+ 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 = ti(c, o, Math.max(i.right, a.right) - c, s - o);
1512
+ return ni(l) ? [l] : null;
1472
1513
  }
1473
- function ai(e) {
1474
- return ni(e) ?? ri(e) ?? ii(e);
1514
+ function di(e) {
1515
+ return ci(e) ?? li(e) ?? ui(e);
1475
1516
  }
1476
- function oi(e) {
1477
- let t = ai(e);
1478
- return t && t.length > 0 ? Zr(t) : null;
1517
+ function fi(e) {
1518
+ let t = di(e);
1519
+ return t && t.length > 0 ? ri(t) : null;
1479
1520
  }
1480
- function si(e) {
1521
+ function pi(e) {
1481
1522
  return {
1482
- getBoundingClientRect: () => oi(e) ?? Yr(0, 0, 0, 0),
1483
- getClientRects: () => ai(e) ?? []
1523
+ getBoundingClientRect: () => fi(e) ?? ti(0, 0, 0, 0),
1524
+ getClientRects: () => di(e) ?? []
1484
1525
  };
1485
1526
  }
1486
- function ci(e) {
1527
+ function mi(e) {
1487
1528
  return e === "block-type" || e === "link" || e === "color" || e === "more";
1488
1529
  }
1489
- function li(e, t, n) {
1490
- n?.(wn(e, t)), e.commands.focus();
1530
+ function hi(e, t, n) {
1531
+ n?.(An(e, t)), e.commands.focus();
1491
1532
  }
1492
- function ui({ editor: e, messages: t = Wr, selectionSnapshot: n, onRewriteSelection: r }) {
1493
- let i = G(() => kn(t), [t]), a = st(n, { editable: e.isEditable }), [o, s] = q(a), [c, l] = q(null), [u, d] = q(null), [f, p] = q(null), [m, h] = q(""), [g, _] = q(""), [v, y] = q(null), [b, x] = q(0), [S, C] = q(a.boundaryPadding), [w, T] = q("bottom"), E = K(0), D = K(null), O = K(null), k = K(null), A = K(null), j = Tn(e, o.variant, t), M = jn(j.find((e) => e.id === c) ?? null), N = Hn(m), P = H(() => {
1533
+ function gi({ editor: e, messages: t = Xr, selectionSnapshot: n, onRewriteSelection: r }) {
1534
+ let i = W(() => Fn(t), [t]), a = st(n, { editable: e.isEditable }), [o, s] = K(a), [c, l] = K(null), [u, d] = K(null), [f, p] = K(null), [m, h] = K(""), [g, _] = K(""), [v, y] = K(null), [b, x] = K(0), [S, C] = K(a.boundaryPadding), [w, T] = K("bottom"), E = G(0), D = G(null), O = G(null), k = G(null), A = G(null), j = jn(e, o.variant, t), M = Ln(j.find((e) => e.id === c) ?? null), N = Jn(m), P = V(() => {
1494
1535
  let t = D.current, n = e.view.dom.closest(".markweave-editor-frame");
1495
1536
  if (!t || !(n instanceof HTMLElement)) return;
1496
- let r = t.getBoundingClientRect(), i = n.getBoundingClientRect(), a = qr(t, O.current), s = E.current, c = nt({
1537
+ let r = t.getBoundingClientRect(), i = n.getBoundingClientRect(), a = $r(t, O.current), s = E.current, c = nt({
1497
1538
  toolbarRect: {
1498
1539
  left: r.left - s,
1499
1540
  top: r.top,
@@ -1526,13 +1567,13 @@ function ui({ editor: e, messages: t = Wr, selectionSnapshot: n, onRewriteSelect
1526
1567
  e.view.dom,
1527
1568
  o.boundaryPadding,
1528
1569
  o.offset
1529
- ]), F = H(() => {
1570
+ ]), F = V(() => {
1530
1571
  D.current && (D.current.style.visibility = "hidden", D.current.style.opacity = "0");
1531
- }, []), ee = H(() => {
1572
+ }, []), ee = V(() => {
1532
1573
  P();
1533
- }, [P]), I = H(() => si(e), [e]), L = H((e) => {
1574
+ }, [P]), te = V(() => pi(e), [e]), I = V((e) => {
1534
1575
  k.current = e;
1535
- }, []), te = H(() => {
1576
+ }, []), L = V(() => {
1536
1577
  let t = D.current, n = k.current, r = e.view.dom.closest(".markweave-editor-frame");
1537
1578
  if (!f || !t || !n) return;
1538
1579
  let i = t.getBoundingClientRect(), a = n.getBoundingClientRect(), s = r?.getBoundingClientRect() ?? null, c = rt({
@@ -1551,7 +1592,7 @@ function ui({ editor: e, messages: t = Wr, selectionSnapshot: n, onRewriteSelect
1551
1592
  e.view.dom,
1552
1593
  f,
1553
1594
  o.boundaryPadding
1554
- ]), R = G(() => ({
1595
+ ]), ne = W(() => ({
1555
1596
  ...ot(o, { topBoundaryPadding: S }),
1556
1597
  onShow: F,
1557
1598
  onUpdate: ee
@@ -1561,8 +1602,8 @@ function ui({ editor: e, messages: t = Wr, selectionSnapshot: n, onRewriteSelect
1561
1602
  o,
1562
1603
  S
1563
1604
  ]);
1564
- U(() => {
1565
- let e = Gr();
1605
+ H(() => {
1606
+ let e = Zr();
1566
1607
  s((t) => ut(t, a, e));
1567
1608
  }, [
1568
1609
  a.hiddenReason,
@@ -1575,10 +1616,10 @@ function ui({ editor: e, messages: t = Wr, selectionSnapshot: n, onRewriteSelect
1575
1616
  a.updateDelayMs,
1576
1617
  a.variant,
1577
1618
  a.visibility
1578
- ]), U(() => {
1619
+ ]), H(() => {
1579
1620
  if (o.motionStartedAtMs === null || o.motionDurationMs <= 0) return;
1580
- let e = Math.max(0, o.motionStartedAtMs + o.motionDurationMs - Gr()), t = window.setTimeout(() => {
1581
- s((e) => et(e, Gr()));
1621
+ let e = Math.max(0, o.motionStartedAtMs + o.motionDurationMs - Zr()), t = window.setTimeout(() => {
1622
+ s((e) => et(e, Zr()));
1582
1623
  }, e);
1583
1624
  return () => {
1584
1625
  window.clearTimeout(t);
@@ -1587,12 +1628,12 @@ function ui({ editor: e, messages: t = Wr, selectionSnapshot: n, onRewriteSelect
1587
1628
  o.motionDurationMs,
1588
1629
  o.motionPhase,
1589
1630
  o.motionStartedAtMs
1590
- ]), W(() => {
1631
+ ]), U(() => {
1591
1632
  if (o.visibility !== "visible") {
1592
1633
  E.current = 0, D.current && (D.current.style.marginLeft = "", D.current.style.visibility = "hidden", D.current.style.opacity = "0"), x(0), C(o.boundaryPadding);
1593
1634
  return;
1594
1635
  }
1595
- let e = Sn(P);
1636
+ let e = On(P);
1596
1637
  return e.schedule(), window.addEventListener("resize", e.schedule), window.addEventListener("scroll", e.schedule, !0), () => {
1597
1638
  e.cancel(), window.removeEventListener("resize", e.schedule), window.removeEventListener("scroll", e.schedule, !0);
1598
1639
  };
@@ -1605,20 +1646,20 @@ function ui({ editor: e, messages: t = Wr, selectionSnapshot: n, onRewriteSelect
1605
1646
  o.variant,
1606
1647
  o.visibility,
1607
1648
  j.length
1608
- ]), W(() => {
1649
+ ]), U(() => {
1609
1650
  if (!f) return;
1610
- let e = Sn(te);
1651
+ let e = On(L);
1611
1652
  return e.schedule(), window.addEventListener("resize", e.schedule), window.addEventListener("scroll", e.schedule, !0), () => {
1612
1653
  e.cancel(), window.removeEventListener("resize", e.schedule), window.removeEventListener("scroll", e.schedule, !0);
1613
1654
  };
1614
- }, [f, te]), U(() => {
1655
+ }, [f, L]), H(() => {
1615
1656
  f === "more" && i.some((e) => e.id === c) || j.some((e) => e.id === c) || (l(null), d(null));
1616
1657
  }, [
1617
1658
  i,
1618
1659
  f,
1619
1660
  c,
1620
1661
  j
1621
- ]), U(() => {
1662
+ ]), H(() => {
1622
1663
  if (!f) return;
1623
1664
  let t = (e) => {
1624
1665
  O.current?.contains(e.target) || p(null);
@@ -1628,18 +1669,18 @@ function ui({ editor: e, messages: t = Wr, selectionSnapshot: n, onRewriteSelect
1628
1669
  return document.addEventListener("pointerdown", t, !0), document.addEventListener("keydown", n, !0), () => {
1629
1670
  document.removeEventListener("pointerdown", t, !0), document.removeEventListener("keydown", n, !0);
1630
1671
  };
1631
- }, [e, f]), U(() => {
1672
+ }, [e, f]), H(() => {
1632
1673
  if (f !== "link") return;
1633
1674
  let e = window.requestAnimationFrame(() => {
1634
1675
  A.current?.focus(), A.current?.select();
1635
1676
  });
1636
1677
  return () => window.cancelAnimationFrame(e);
1637
1678
  }, [f]);
1638
- let z = (t) => {
1639
- if (ci(t.id)) {
1679
+ let re = (t) => {
1680
+ if (mi(t.id)) {
1640
1681
  let n = t.id;
1641
1682
  if (n === "link") {
1642
- let t = Dn(e);
1683
+ let t = Nn(e);
1643
1684
  h(t), _(t), y({
1644
1685
  from: Math.min(e.state.selection.from, e.state.selection.to),
1645
1686
  to: Math.max(e.state.selection.from, e.state.selection.to)
@@ -1649,23 +1690,23 @@ function ui({ editor: e, messages: t = Wr, selectionSnapshot: n, onRewriteSelect
1649
1690
  return;
1650
1691
  }
1651
1692
  if (p(null), t.id === "improve") {
1652
- li(e, "rewrite-selection", r);
1693
+ hi(e, "rewrite-selection", r);
1653
1694
  return;
1654
1695
  }
1655
1696
  t.run(), e.commands.focus();
1656
- }, ne = () => {
1697
+ }, R = () => {
1657
1698
  p(null), e.commands.focus();
1658
- }, re = () => {
1659
- v && e.commands.setTextSelection(v);
1660
1699
  }, ie = () => {
1661
- re(), Cn(e, m) && ne();
1700
+ v && e.commands.setTextSelection(v);
1662
1701
  }, ae = () => {
1663
- if (re(), Ln(e)) {
1664
- h(""), _(""), ne();
1702
+ ie(), kn(e, m) && R();
1703
+ }, oe = () => {
1704
+ if (ie(), Un(e)) {
1705
+ h(""), _(""), R();
1665
1706
  return;
1666
1707
  }
1667
1708
  m.trim() && h("");
1668
- }, B = (e, t) => {
1709
+ }, z = (e, t) => {
1669
1710
  if (l(e), !e || !t || !O.current) {
1670
1711
  d(null);
1671
1712
  return;
@@ -1673,41 +1714,41 @@ function ui({ editor: e, messages: t = Wr, selectionSnapshot: n, onRewriteSelect
1673
1714
  let n = t.getBoundingClientRect(), r = O.current.getBoundingClientRect();
1674
1715
  d(n.left + n.width / 2 - r.left);
1675
1716
  };
1676
- return /* @__PURE__ */ Z(xn, {
1717
+ return /* @__PURE__ */ Z(Dn, {
1677
1718
  ref: D,
1678
1719
  editor: e,
1679
1720
  className: `markweave-floating-toolbar markweave-floating-toolbar--${o.variant} markweave-floating-toolbar--motion-${o.motionPhase}`,
1680
1721
  "data-motion": o.motionPhase,
1681
- "data-position-strategy": R.strategy,
1722
+ "data-position-strategy": ne.strategy,
1682
1723
  "data-boundary-padding": o.boundaryPadding,
1683
1724
  "data-popover-placement": f ? w : void 0,
1684
1725
  "data-testid": "markweave-floating-toolbar",
1685
- style: Kr(o, b),
1726
+ style: Qr(o, b),
1686
1727
  updateDelay: 0,
1687
- getReferencedVirtualElement: I,
1688
- options: R,
1728
+ getReferencedVirtualElement: te,
1729
+ options: ne,
1689
1730
  shouldShow: ({ editor: e }) => e.isEditable && lt(at(e)),
1690
1731
  children: /* @__PURE__ */ Q("div", {
1691
1732
  ref: O,
1692
1733
  className: "markweave-floating-toolbar-content",
1693
1734
  "data-menu": f ?? "none",
1694
1735
  children: [
1695
- j.map((e, t) => /* @__PURE__ */ Z(fi, {
1736
+ j.map((e, t) => /* @__PURE__ */ Z(vi, {
1696
1737
  button: e,
1697
1738
  expanded: f === e.id,
1698
1739
  showDivider: t > 0 && j[t - 1].group !== e.group,
1699
1740
  tooltipActive: c === e.id,
1700
- onPointerDown: In,
1701
- onTooltipChange: B,
1702
- onRun: z
1741
+ onPointerDown: Hn,
1742
+ onTooltipChange: z,
1743
+ onRun: re
1703
1744
  }, e.id)),
1704
- f === "block-type" ? /* @__PURE__ */ Z(mi, {
1745
+ f === "block-type" ? /* @__PURE__ */ Z(bi, {
1705
1746
  editor: e,
1706
1747
  messages: t,
1707
- onPopoverRef: L,
1748
+ onPopoverRef: I,
1708
1749
  onClose: () => p(null)
1709
1750
  }) : null,
1710
- f === "link" ? /* @__PURE__ */ Z(di, {
1751
+ f === "link" ? /* @__PURE__ */ Z(_i, {
1711
1752
  inputRef: A,
1712
1753
  messages: t,
1713
1754
  value: m,
@@ -1715,22 +1756,22 @@ function ui({ editor: e, messages: t = Wr, selectionSnapshot: n, onRewriteSelect
1715
1756
  canOpen: !!N,
1716
1757
  canRemove: !!(g || m.trim()),
1717
1758
  onValueChange: h,
1718
- onApply: ie,
1719
- onOpen: () => Fn(m),
1720
- onRemove: ae,
1721
- onPopoverRef: L
1759
+ onApply: ae,
1760
+ onOpen: () => Vn(m),
1761
+ onRemove: oe,
1762
+ onPopoverRef: I
1722
1763
  }) : null,
1723
- f === "color" ? /* @__PURE__ */ Z(gi, {
1764
+ f === "color" ? /* @__PURE__ */ Z(Si, {
1724
1765
  editor: e,
1725
1766
  messages: t,
1726
- onPopoverRef: L,
1767
+ onPopoverRef: I,
1727
1768
  onClose: () => p(null)
1728
1769
  }) : null,
1729
- f === "more" ? /* @__PURE__ */ Z(vi, {
1770
+ f === "more" ? /* @__PURE__ */ Z(wi, {
1730
1771
  editor: e,
1731
1772
  messages: t,
1732
1773
  activeTooltipId: c,
1733
- onPopoverRef: L,
1774
+ onPopoverRef: I,
1734
1775
  onTooltipChange: l,
1735
1776
  onClose: () => p(null)
1736
1777
  }) : null,
@@ -1740,15 +1781,15 @@ function ui({ editor: e, messages: t = Wr, selectionSnapshot: n, onRewriteSelect
1740
1781
  "data-testid": "markweave-floating-toolbar-tooltip",
1741
1782
  "data-button-id": M.buttonId,
1742
1783
  "data-active": M.active,
1743
- style: Jr(u),
1784
+ style: ei(u),
1744
1785
  children: M.label
1745
1786
  }) : null
1746
1787
  ]
1747
1788
  })
1748
1789
  });
1749
1790
  }
1750
- function di({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRemove: a, onValueChange: o, onApply: s, onOpen: c, onRemove: l, onPopoverRef: u }) {
1751
- let d = On(t);
1791
+ function _i({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRemove: a, onValueChange: o, onApply: s, onOpen: c, onRemove: l, onPopoverRef: u }) {
1792
+ let d = Pn(t);
1752
1793
  return /* @__PURE__ */ Q("form", {
1753
1794
  ref: u,
1754
1795
  className: "markweave-floating-toolbar-popover markweave-floating-toolbar-link-popover",
@@ -1771,7 +1812,7 @@ function di({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRe
1771
1812
  "aria-label": d.applyLink,
1772
1813
  "data-testid": "markweave-floating-toolbar-link-apply",
1773
1814
  disabled: !r,
1774
- onMouseDown: In,
1815
+ onMouseDown: Hn,
1775
1816
  children: /* @__PURE__ */ Z($, { name: "corner-down-left" })
1776
1817
  }),
1777
1818
  /* @__PURE__ */ Z("span", {
@@ -1783,7 +1824,7 @@ function di({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRe
1783
1824
  "aria-label": d.openLink,
1784
1825
  "data-testid": "markweave-floating-toolbar-link-open",
1785
1826
  disabled: !i,
1786
- onMouseDown: In,
1827
+ onMouseDown: Hn,
1787
1828
  onClick: c,
1788
1829
  children: /* @__PURE__ */ Z($, { name: "external-link" })
1789
1830
  }),
@@ -1792,7 +1833,7 @@ function di({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRe
1792
1833
  "aria-label": d.removeLink,
1793
1834
  "data-testid": "markweave-floating-toolbar-link-remove",
1794
1835
  disabled: !a,
1795
- onMouseDown: In,
1836
+ onMouseDown: Hn,
1796
1837
  onClick: l,
1797
1838
  children: /* @__PURE__ */ Z($, { name: "trash" })
1798
1839
  })
@@ -1800,7 +1841,7 @@ function di({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRe
1800
1841
  })]
1801
1842
  });
1802
1843
  }
1803
- function fi({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointerDown: i, onTooltipChange: a, onRun: o }) {
1844
+ function vi({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointerDown: i, onTooltipChange: a, onRun: o }) {
1804
1845
  return /* @__PURE__ */ Q(X, { children: [n ? /* @__PURE__ */ Z("span", {
1805
1846
  className: "markweave-floating-toolbar-divider",
1806
1847
  "aria-hidden": "true"
@@ -1808,7 +1849,7 @@ function fi({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointe
1808
1849
  type: "button",
1809
1850
  className: `markweave-floating-toolbar-button markweave-floating-toolbar-button--${e.id}`,
1810
1851
  "aria-label": e.label,
1811
- "aria-expanded": ci(e.id) ? t : void 0,
1852
+ "aria-expanded": mi(e.id) ? t : void 0,
1812
1853
  "data-active": e.active || t,
1813
1854
  "data-tooltip-active": r ? "true" : "false",
1814
1855
  "data-testid": `markweave-floating-toolbar-button-${e.id}`,
@@ -1818,13 +1859,13 @@ function fi({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointe
1818
1859
  onMouseEnter: (t) => a(e.id, t.currentTarget),
1819
1860
  onMouseLeave: () => a(null),
1820
1861
  onClick: () => o(e),
1821
- children: /* @__PURE__ */ Z(pi, {
1862
+ children: /* @__PURE__ */ Z(yi, {
1822
1863
  button: e,
1823
1864
  expanded: t
1824
1865
  })
1825
1866
  })] });
1826
1867
  }
1827
- function pi({ button: e, expanded: t }) {
1868
+ function yi({ button: e, expanded: t }) {
1828
1869
  return e.id === "improve" ? /* @__PURE__ */ Q("span", {
1829
1870
  className: "markweave-floating-toolbar-button-inner",
1830
1871
  children: [/* @__PURE__ */ Z($, { name: "sparkles" }), /* @__PURE__ */ Z("span", { children: e.glyph })]
@@ -1842,8 +1883,8 @@ function pi({ button: e, expanded: t }) {
1842
1883
  }), /* @__PURE__ */ Z($, { name: t ? "chevron-up" : "chevron-down" })]
1843
1884
  }) : /* @__PURE__ */ Z($, { name: "more" });
1844
1885
  }
1845
- function mi({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
1846
- let i = On(t), a = Mn(t);
1886
+ function bi({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
1887
+ let i = Pn(t), a = Rn(t);
1847
1888
  return /* @__PURE__ */ Q("div", {
1848
1889
  ref: n,
1849
1890
  className: "markweave-floating-toolbar-popover markweave-floating-toolbar-turn-menu",
@@ -1853,48 +1894,48 @@ function mi({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
1853
1894
  children: i.turnIntoTitle
1854
1895
  }), a.map((t) => /* @__PURE__ */ Q("button", {
1855
1896
  type: "button",
1856
- "data-active": Pn(e, t.id),
1897
+ "data-active": Bn(e, t.id),
1857
1898
  "data-testid": `markweave-floating-toolbar-turn-${t.id}`,
1858
- onMouseDown: In,
1899
+ onMouseDown: Hn,
1859
1900
  onClick: () => {
1860
- Vn(e, t.id), r();
1901
+ qn(e, t.id), r();
1861
1902
  },
1862
1903
  children: [/* @__PURE__ */ Z("span", {
1863
1904
  className: "markweave-floating-toolbar-menu-icon",
1864
- children: /* @__PURE__ */ Z(hi, { option: t })
1905
+ children: /* @__PURE__ */ Z(xi, { option: t })
1865
1906
  }), /* @__PURE__ */ Z("span", { children: t.label })]
1866
1907
  }, t.id))]
1867
1908
  });
1868
1909
  }
1869
- function hi({ option: e }) {
1910
+ function xi({ option: e }) {
1870
1911
  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 });
1871
1912
  }
1872
- function gi({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
1873
- let i = On(t), a = e.getAttributes("textStyle").color, o = e.getAttributes("highlight").color;
1913
+ function Si({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
1914
+ let i = Pn(t), a = e.getAttributes("textStyle").color, o = e.getAttributes("highlight").color;
1874
1915
  return /* @__PURE__ */ Q("div", {
1875
1916
  ref: n,
1876
1917
  className: "markweave-floating-toolbar-popover markweave-floating-toolbar-color-popover",
1877
1918
  "data-testid": "markweave-floating-toolbar-color-menu",
1878
- children: [/* @__PURE__ */ Z(_i, {
1919
+ children: [/* @__PURE__ */ Z(Ci, {
1879
1920
  title: i.textColorTitle,
1880
1921
  mode: "text",
1881
1922
  activeColor: a ?? null,
1882
- options: An(t),
1923
+ options: In(t),
1883
1924
  onSelect: (t) => {
1884
- Bn(e, t), r();
1925
+ Kn(e, t), r();
1885
1926
  }
1886
- }), /* @__PURE__ */ Z(_i, {
1927
+ }), /* @__PURE__ */ Z(Ci, {
1887
1928
  title: i.highlightColorTitle,
1888
1929
  mode: "highlight",
1889
1930
  activeColor: o ?? null,
1890
- options: En(t),
1931
+ options: Mn(t),
1891
1932
  onSelect: (t) => {
1892
- zn(e, t), r();
1933
+ Gn(e, t), r();
1893
1934
  }
1894
1935
  })]
1895
1936
  });
1896
1937
  }
1897
- function _i({ title: e, mode: t, activeColor: n, options: r, onSelect: i }) {
1938
+ function Ci({ title: e, mode: t, activeColor: n, options: r, onSelect: i }) {
1898
1939
  return /* @__PURE__ */ Q("section", {
1899
1940
  className: "markweave-floating-toolbar-color-section",
1900
1941
  "aria-label": e,
@@ -1908,7 +1949,7 @@ function _i({ title: e, mode: t, activeColor: n, options: r, onSelect: i }) {
1908
1949
  "aria-label": e.label,
1909
1950
  "data-active": e.value === n || e.value === null && !n,
1910
1951
  "data-testid": `markweave-floating-toolbar-${t}-${e.id}`,
1911
- onMouseDown: In,
1952
+ onMouseDown: Hn,
1912
1953
  onClick: () => i(e.value),
1913
1954
  children: t === "text" ? /* @__PURE__ */ Z("span", {
1914
1955
  className: "markweave-floating-toolbar-text-swatch",
@@ -1923,25 +1964,25 @@ function _i({ title: e, mode: t, activeColor: n, options: r, onSelect: i }) {
1923
1964
  })]
1924
1965
  });
1925
1966
  }
1926
- function vi({ editor: e, messages: t, activeTooltipId: n, onPopoverRef: r, onTooltipChange: i, onClose: a }) {
1927
- let o = kn(t);
1967
+ function wi({ editor: e, messages: t, activeTooltipId: n, onPopoverRef: r, onTooltipChange: i, onClose: a }) {
1968
+ let o = Fn(t);
1928
1969
  return /* @__PURE__ */ Z("div", {
1929
1970
  ref: r,
1930
1971
  className: "markweave-floating-toolbar-popover markweave-floating-toolbar-more-menu",
1931
1972
  "data-testid": "markweave-floating-toolbar-more-menu",
1932
- children: o.map((t, r) => /* @__PURE__ */ Z(yi, {
1973
+ children: o.map((t, r) => /* @__PURE__ */ Z(Ti, {
1933
1974
  action: t,
1934
- active: Nn(e, t.id),
1975
+ active: zn(e, t.id),
1935
1976
  tooltipActive: n === t.id,
1936
1977
  showDivider: r > 0 && o[r - 1].group !== t.group,
1937
1978
  onTooltipChange: i,
1938
1979
  onRun: () => {
1939
- Rn(e, t.id), a();
1980
+ Wn(e, t.id), a();
1940
1981
  }
1941
1982
  }, t.id))
1942
1983
  });
1943
1984
  }
1944
- function yi({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipChange: i, onRun: a }) {
1985
+ function Ti({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipChange: i, onRun: a }) {
1945
1986
  return /* @__PURE__ */ Q(X, { children: [r ? /* @__PURE__ */ Z("span", {
1946
1987
  className: "markweave-floating-toolbar-divider",
1947
1988
  "aria-hidden": "true"
@@ -1953,11 +1994,11 @@ function yi({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipC
1953
1994
  "data-active": t,
1954
1995
  "data-tooltip-active": n ? "true" : "false",
1955
1996
  "data-testid": `markweave-floating-toolbar-more-${e.id}`,
1956
- onMouseDown: In,
1997
+ onMouseDown: Hn,
1957
1998
  onMouseEnter: () => i(e.id),
1958
1999
  onMouseLeave: () => i(null),
1959
2000
  onClick: a,
1960
- children: /* @__PURE__ */ Z(bi, { id: e.id })
2001
+ children: /* @__PURE__ */ Z(Ei, { id: e.id })
1961
2002
  }), n ? /* @__PURE__ */ Z("div", {
1962
2003
  className: "markweave-floating-toolbar-tooltip markweave-floating-toolbar-tooltip--more",
1963
2004
  role: "tooltip",
@@ -1965,41 +2006,41 @@ function yi({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipC
1965
2006
  }) : null]
1966
2007
  })] });
1967
2008
  }
1968
- function bi({ id: e }) {
2009
+ function Ei({ id: e }) {
1969
2010
  return e === "superscript" ? /* @__PURE__ */ Z($, { name: "superscript" }) : e === "subscript" ? /* @__PURE__ */ Z($, { name: "subscript" }) : e === "inline-math" ? /* @__PURE__ */ Z($, { name: "math" }) : Z($, { name: e });
1970
2011
  }
1971
- var xi = {
1972
- sparkles: se,
2012
+ var Di = {
2013
+ sparkles: ce,
1973
2014
  "chevron-down": v,
1974
2015
  "chevron-up": y,
1975
2016
  "corner-down-left": C,
1976
2017
  "external-link": T,
1977
2018
  bold: p,
1978
2019
  italic: F,
1979
- underline: he,
1980
- strike: ce,
2020
+ underline: ge,
2021
+ strike: le,
1981
2022
  "inline-code": x,
1982
- link: I,
1983
- more: ne,
1984
- text: me,
1985
- "bullet-list": L,
1986
- "numbered-list": R,
1987
- "todo-list": te,
1988
- quote: ae,
2023
+ link: te,
2024
+ more: R,
2025
+ text: he,
2026
+ "bullet-list": I,
2027
+ "numbered-list": ne,
2028
+ "todo-list": L,
2029
+ quote: oe,
1989
2030
  "code-block": m,
1990
- superscript: ue,
1991
- subscript: le,
1992
- math: V,
2031
+ superscript: de,
2032
+ subscript: ue,
2033
+ math: B,
1993
2034
  "align-left": d,
1994
2035
  "align-center": l,
1995
2036
  "align-right": f,
1996
2037
  "align-justify": u,
1997
2038
  "decrease-indent": M,
1998
2039
  "increase-indent": N,
1999
- trash: pe
2040
+ trash: me
2000
2041
  };
2001
2042
  function $({ name: e }) {
2002
- let t = xi[e];
2043
+ let t = Di[e];
2003
2044
  return /* @__PURE__ */ Z(t, {
2004
2045
  "aria-hidden": "true",
2005
2046
  absoluteStrokeWidth: !0,
@@ -2009,8 +2050,8 @@ function $({ name: e }) {
2009
2050
  }
2010
2051
  //#endregion
2011
2052
  //#region src/ui/math/MathEditorPopover.tsx
2012
- function Si({ editor: e, messages: t, onClose: n, target: r }) {
2013
- let i = K(null), a = K(null), [o, s] = q(r.latex), [c, l] = q(null), u = t.math, d = G(() => Dt(e, r) ?? 1, [e, r]), f = G(() => Ot(e, r), [e, r]), p = G(() => o === r.latex && f ? {
2053
+ function Oi({ editor: e, messages: t, onClose: n, target: r }) {
2054
+ let i = G(null), a = G(null), [o, s] = K(r.latex), [c, l] = K(null), u = t.math, d = W(() => Dt(e, r) ?? 1, [e, r]), f = W(() => Ot(e, r), [e, r]), p = W(() => o === r.latex && f ? {
2014
2055
  html: f,
2015
2056
  error: !1
2016
2057
  } : Mt(o, r.kind, e), [
@@ -2019,7 +2060,7 @@ function Si({ editor: e, messages: t, onClose: n, target: r }) {
2019
2060
  r.kind,
2020
2061
  r.latex,
2021
2062
  o
2022
- ]), m = o.trim().length > 0, h = H(() => {
2063
+ ]), m = o.trim().length > 0, h = V(() => {
2023
2064
  if (typeof window > "u") return;
2024
2065
  let t = Et(e, r), i = e.view.dom.closest(".markweave-editor-frame")?.getBoundingClientRect();
2025
2066
  if (!t || !i) {
@@ -2040,9 +2081,9 @@ function Si({ editor: e, messages: t, onClose: n, target: r }) {
2040
2081
  r,
2041
2082
  o
2042
2083
  ]);
2043
- U(() => {
2084
+ H(() => {
2044
2085
  s(r.latex);
2045
- }, [r.latex, r.pos]), U(() => {
2086
+ }, [r.latex, r.pos]), H(() => {
2046
2087
  Nt(e, r, !0), h();
2047
2088
  let t = window.requestAnimationFrame(() => {
2048
2089
  a.current?.focus({ preventScroll: !0 }), a.current?.select(), h();
@@ -2055,14 +2096,14 @@ function Si({ editor: e, messages: t, onClose: n, target: r }) {
2055
2096
  n,
2056
2097
  r,
2057
2098
  h
2058
- ]), U(() => {
2099
+ ]), H(() => {
2059
2100
  let e = (e) => {
2060
2101
  let t = e.target;
2061
2102
  t instanceof Node && (i.current?.contains(t) || t instanceof Element && t.closest(".tiptap-mathematics-render") || n());
2062
2103
  };
2063
2104
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
2064
2105
  }, [n]);
2065
- let _ = H(() => {
2106
+ let _ = V(() => {
2066
2107
  m && wt(e, r, o) && n();
2067
2108
  }, [
2068
2109
  m,
@@ -2194,31 +2235,31 @@ function Si({ editor: e, messages: t, onClose: n, target: r }) {
2194
2235
  }
2195
2236
  //#endregion
2196
2237
  //#region src/ui/slash-command/SlashCommandMenu.tsx
2197
- var Ci = n("zh"), wi = {
2198
- type: fe,
2238
+ var ki = n("zh"), Ai = {
2239
+ type: pe,
2199
2240
  "heading-1": D,
2200
2241
  "heading-2": O,
2201
2242
  "heading-3": k,
2202
- "bullet-list": L,
2203
- "ordered-list": R,
2204
- "task-list": te,
2205
- blockquote: ae,
2243
+ "bullet-list": I,
2244
+ "ordered-list": ne,
2245
+ "task-list": L,
2246
+ blockquote: oe,
2206
2247
  "code-block": m,
2207
2248
  info: P,
2208
2249
  tip: ee,
2209
2250
  warning: c,
2210
2251
  error: b,
2211
2252
  success: _,
2212
- emoji: oe,
2213
- math: V,
2214
- table: de,
2215
- separator: z,
2253
+ emoji: se,
2254
+ math: B,
2255
+ table: fe,
2256
+ separator: re,
2216
2257
  image: A,
2217
- video: _e,
2218
- attachment: re
2258
+ video: ve,
2259
+ attachment: ie
2219
2260
  };
2220
- function Ti({ name: e }) {
2221
- let t = wi[e];
2261
+ function ji({ name: e }) {
2262
+ let t = Ai[e];
2222
2263
  return /* @__PURE__ */ Z(t, {
2223
2264
  "aria-hidden": "true",
2224
2265
  absoluteStrokeWidth: !0,
@@ -2226,7 +2267,7 @@ function Ti({ name: e }) {
2226
2267
  strokeWidth: 1.6
2227
2268
  });
2228
2269
  }
2229
- function Ei(e, t, n) {
2270
+ function Mi(e, t, n) {
2230
2271
  return !zt(e) || !n ? {
2231
2272
  visible: !1,
2232
2273
  empty: !1,
@@ -2241,17 +2282,17 @@ function Ei(e, t, n) {
2241
2282
  activeIndex: Math.min(t.length - 1, Math.max(0, e.activeIndex))
2242
2283
  };
2243
2284
  }
2244
- function Di(e, t) {
2285
+ function Ni(e, t) {
2245
2286
  return Object.values(t.slash.groups).map((t) => ({
2246
2287
  group: t,
2247
2288
  commands: e.filter((e) => e.group === t)
2248
2289
  })).filter((e) => e.commands.length > 0);
2249
2290
  }
2250
- function Oi(e, t) {
2291
+ function Pi(e, t) {
2251
2292
  return t.slash.uploadKindLabels[e] ?? t.slash.uploadKindLabels.upload;
2252
2293
  }
2253
- function ki({ command: e, messages: t, onBack: n, onSelect: r }) {
2254
- let [i, a] = q(""), [o, s] = q(0), c = G(() => {
2294
+ function Fi({ command: e, messages: t, onBack: n, onSelect: r }) {
2295
+ let [i, a] = K(""), [o, s] = K(0), c = W(() => {
2255
2296
  let e = i.trim().toLowerCase();
2256
2297
  return (e ? t.slash.emojiItems.filter((t) => [
2257
2298
  t.emoji,
@@ -2317,9 +2358,9 @@ function ki({ command: e, messages: t, onBack: n, onSelect: r }) {
2317
2358
  ]
2318
2359
  });
2319
2360
  }
2320
- function Ai({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
2321
- let a = e.uploadKind ?? "attachment", [o, s] = q(""), [c, l] = q(null), [u, d] = q(null), [f, p] = q(!1), m = async (t) => {
2322
- r(e, { uploadResult: await xe({
2361
+ function Ii({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
2362
+ let a = e.uploadKind ?? "attachment", [o, s] = K(""), [c, l] = K(null), [u, d] = K(null), [f, p] = K(!1), m = async (t) => {
2363
+ r(e, { uploadResult: await Se({
2323
2364
  kind: a,
2324
2365
  source: t,
2325
2366
  trigger: "slash-command"
@@ -2339,7 +2380,7 @@ function Ai({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
2339
2380
  d(t.slash.uploadRequiredError);
2340
2381
  return;
2341
2382
  }
2342
- await m(ye(o));
2383
+ await m(be(o));
2343
2384
  } catch (e) {
2344
2385
  d(e instanceof Error ? e.message : t.slash.uploadFailedError);
2345
2386
  } finally {
@@ -2357,7 +2398,7 @@ function Ai({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
2357
2398
  onMouseDown: (e) => e.preventDefault(),
2358
2399
  onClick: n,
2359
2400
  children: t.common.back
2360
- }), /* @__PURE__ */ Z("span", { children: Oi(a, t) })]
2401
+ }), /* @__PURE__ */ Z("span", { children: Pi(a, t) })]
2361
2402
  }),
2362
2403
  /* @__PURE__ */ Q("label", {
2363
2404
  className: "markweave-slash-upload-field",
@@ -2405,10 +2446,10 @@ function Ai({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
2405
2446
  ]
2406
2447
  });
2407
2448
  }
2408
- function ji({ commands: e, messages: t = Ci, state: n, position: r, inputCommand: i, onActiveIndexChange: a, onInputCommandChange: o, onSelect: s, onUpload: c }) {
2409
- let l = Ei(n, e, r);
2449
+ function Li({ commands: e, messages: t = ki, state: n, position: r, inputCommand: i, onActiveIndexChange: a, onInputCommandChange: o, onSelect: s, onUpload: c }) {
2450
+ let l = Mi(n, e, r);
2410
2451
  if (!l.visible || !r) return null;
2411
- let u = Di(e, t), d = {
2452
+ let u = Ni(e, t), d = {
2412
2453
  left: r.left,
2413
2454
  top: r.top,
2414
2455
  maxHeight: r.maxHeight,
@@ -2430,12 +2471,12 @@ function ji({ commands: e, messages: t = Ci, state: n, position: r, inputCommand
2430
2471
  "aria-label": t.slash.ariaLabel,
2431
2472
  "data-placement": r.placement,
2432
2473
  "data-testid": "markweave-slash-menu",
2433
- children: i?.inputKind === "emoji" ? /* @__PURE__ */ Z(ki, {
2474
+ children: i?.inputKind === "emoji" ? /* @__PURE__ */ Z(Fi, {
2434
2475
  command: i,
2435
2476
  messages: t,
2436
2477
  onBack: m,
2437
2478
  onSelect: s
2438
- }) : i?.inputKind === "upload" ? /* @__PURE__ */ Z(Ai, {
2479
+ }) : i?.inputKind === "upload" ? /* @__PURE__ */ Z(Ii, {
2439
2480
  command: i,
2440
2481
  messages: t,
2441
2482
  onBack: m,
@@ -2479,7 +2520,7 @@ function ji({ commands: e, messages: t = Ci, state: n, position: r, inputCommand
2479
2520
  }
2480
2521
  },
2481
2522
  children: [
2482
- /* @__PURE__ */ Z(Ti, { name: t.icon }),
2523
+ /* @__PURE__ */ Z(ji, { name: t.icon }),
2483
2524
  /* @__PURE__ */ Z("span", { children: t.label }),
2484
2525
  o && t.disabledReason ? /* @__PURE__ */ Z("small", { children: t.disabledReason }) : null
2485
2526
  ]
@@ -2491,38 +2532,38 @@ function ji({ commands: e, messages: t = Ci, state: n, position: r, inputCommand
2491
2532
  }
2492
2533
  //#endregion
2493
2534
  //#region src/ui/table/TableControls.tsx
2494
- var Mi = n("zh");
2495
- function Ni({ active: e, editor: t, interactionState: n = Xt, messages: r = Mi, onCopyPayload: i, onCommandResult: a, onEditWithAi: o }) {
2496
- let [s, c] = q(null), [l, u] = q("row-edge"), [d, f] = q(null), [p, m] = q(null), [h, g] = q(null), [_, v] = q(null), [y, b] = q(null), x = K(null), S = K(null), C = K(null), w = K(null), T = K(null), E = e ? Jt(t.state) : null;
2497
- if (U(() => {
2535
+ var Ri = n("zh");
2536
+ function zi({ active: e, editor: t, interactionState: n = Xt, messages: r = Ri, onCopyPayload: i, onCommandResult: a, onEditWithAi: o }) {
2537
+ let [s, c] = K(null), [l, u] = K("row-edge"), [d, f] = K(null), [p, m] = K(null), [h, g] = K(null), [_, v] = K(null), [y, b] = K(null), x = G(null), S = G(null), C = G(null), w = G(null), T = G(null), E = e ? Jt(t.state) : null;
2538
+ if (H(() => {
2498
2539
  if (!y) return;
2499
2540
  let e = window.setTimeout(() => {
2500
2541
  b(null);
2501
- }, or);
2542
+ }, fr);
2502
2543
  return () => {
2503
2544
  window.clearTimeout(e);
2504
2545
  };
2505
- }, [y]), W(() => {
2546
+ }, [y]), U(() => {
2506
2547
  if (!e) {
2507
2548
  m(null), g(null), v(null), b(null);
2508
2549
  return;
2509
2550
  }
2510
2551
  let r = () => {
2511
- let e = t.view.dom.closest(".markweave-editor-frame") ?? t.view.dom.parentElement, r = Qn(t, n, "row", E?.activeCellPos ?? null), i = Qn(t, n, "column", E?.activeCellPos ?? null), a = r ? Zn(t, r) : null, o = i ? Zn(t, i) : null, c = Xn(t).length > 0 ? rr(t) : null;
2552
+ let e = t.view.dom.closest(".markweave-editor-frame") ?? t.view.dom.parentElement, r = ir(t, n, "row", E?.activeCellPos ?? null), i = ir(t, n, "column", E?.activeCellPos ?? null), a = r ? rr(t, r) : null, o = i ? rr(t, i) : null, c = nr(t).length > 0 ? lr(t) : null;
2512
2553
  if (!e) {
2513
2554
  m(null), g(null), v(null);
2514
2555
  return;
2515
2556
  }
2516
2557
  let u = e.getBoundingClientRect();
2517
- a ? m(Gn({
2558
+ a ? m(Zn({
2518
2559
  targetRect: a,
2519
2560
  frameRect: u,
2520
2561
  kind: "row"
2521
- })) : s === "row" && l === "row-edge" || m(null), o ? g(Gn({
2562
+ })) : s === "row" && l === "row-edge" || m(null), o ? g(Zn({
2522
2563
  targetRect: o,
2523
2564
  frameRect: u,
2524
2565
  kind: "column"
2525
- })) : s === "column" && l === "column-edge" || g(null), c ? v(Gn({
2566
+ })) : s === "column" && l === "column-edge" || g(null), c ? v(Zn({
2526
2567
  targetRect: c,
2527
2568
  frameRect: u,
2528
2569
  kind: "selection"
@@ -2542,7 +2583,7 @@ function Ni({ active: e, editor: t, interactionState: n = Xt, messages: r = Mi,
2542
2583
  n.hoverVisualRowIndex,
2543
2584
  l,
2544
2585
  s
2545
- ]), W(() => {
2586
+ ]), U(() => {
2546
2587
  if (!e || !s) {
2547
2588
  f(null);
2548
2589
  return;
@@ -2553,12 +2594,12 @@ function Ni({ active: e, editor: t, interactionState: n = Xt, messages: r = Mi,
2553
2594
  f(null);
2554
2595
  return;
2555
2596
  }
2556
- let i = n.getBoundingClientRect(), a = s === "row" ? Yn(t)?.getBoundingClientRect() : null, o = a ? {
2597
+ let i = n.getBoundingClientRect(), a = s === "row" ? tr(t)?.getBoundingClientRect() : null, o = a ? {
2557
2598
  left: i.left,
2558
2599
  top: a.top,
2559
2600
  width: i.width,
2560
2601
  height: i.height
2561
- } : i, c = e.getBoundingClientRect(), u = r.getBoundingClientRect(), d = Wn({
2602
+ } : i, c = e.getBoundingClientRect(), u = r.getBoundingClientRect(), d = Xn({
2562
2603
  anchorRect: o,
2563
2604
  frameRect: c,
2564
2605
  menuSize: {
@@ -2580,7 +2621,7 @@ function Ni({ active: e, editor: t, interactionState: n = Xt, messages: r = Mi,
2580
2621
  p,
2581
2622
  h,
2582
2623
  _
2583
- ]), U(() => {
2624
+ ]), H(() => {
2584
2625
  if (!e || !s) return;
2585
2626
  let n = (e) => {
2586
2627
  e.key === "Escape" && (c(null), t.view.focus());
@@ -2599,14 +2640,14 @@ function Ni({ active: e, editor: t, interactionState: n = Xt, messages: r = Mi,
2599
2640
  let n = s === e && l === t;
2600
2641
  u(t), c(n ? null : e);
2601
2642
  }, O = () => {
2602
- t.view.dispatch(Un(t.state.tr, null));
2643
+ t.view.dispatch(Yn(t.state.tr, null));
2603
2644
  }, k = (e, r) => {
2604
2645
  let i = n.hoverCellPos ?? E?.activeCellPos ?? null, a = n.hoverCellPos === null ? null : e === "row" ? n.hoverVisualRowIndex : n.hoverVisualColumnIndex;
2605
- i !== null && ar(t, i, e, { visualIndex: a }), D(e, r);
2646
+ i !== null && dr(t, i, e, { visualIndex: a }), D(e, r);
2606
2647
  }, A = () => {
2607
2648
  O(), D("selection", "selection-edge");
2608
- }, j = Qn(t, n, "row", E?.activeCellPos ?? null), M = Qn(t, n, "column", E?.activeCellPos ?? null), N = Xn(t).length > 0, P = s ? nr(t, s) : [], F = async (e, n) => {
2609
- let o = await qn({
2649
+ }, j = ir(t, n, "row", E?.activeCellPos ?? null), M = ir(t, n, "column", E?.activeCellPos ?? null), N = nr(t).length > 0, P = s ? cr(t, s) : [], F = async (e, n) => {
2650
+ let o = await $n({
2610
2651
  editor: t,
2611
2652
  commandId: e,
2612
2653
  menu: n ?? s ?? "selection",
@@ -2614,7 +2655,7 @@ function Ni({ active: e, editor: t, interactionState: n = Xt, messages: r = Mi,
2614
2655
  });
2615
2656
  return o.copyFeedback ? (b(o.copyFeedback), o.copyPayload && i?.(o.copyPayload)) : b(null), a?.(o.commandResult), o.success;
2616
2657
  }, ee = (e) => {
2617
- let n = $n(t, e);
2658
+ let n = ar(t, e);
2618
2659
  n && o?.(n), c(null), t.view.focus();
2619
2660
  };
2620
2661
  return /* @__PURE__ */ Q("div", {
@@ -2633,7 +2674,7 @@ function Ni({ active: e, editor: t, interactionState: n = Xt, messages: r = Mi,
2633
2674
  "data-copy-kind": y.kind,
2634
2675
  "data-text-length": y.textLength,
2635
2676
  "data-html-length": y.htmlLength,
2636
- children: Jn(y)
2677
+ children: er(y)
2637
2678
  }) : null,
2638
2679
  p ? /* @__PURE__ */ Z("button", {
2639
2680
  type: "button",
@@ -2711,7 +2752,7 @@ function Ni({ active: e, editor: t, interactionState: n = Xt, messages: r = Mi,
2711
2752
  ref: S,
2712
2753
  className: "markweave-table-menu",
2713
2754
  role: "menu",
2714
- "aria-label": sr(s, r),
2755
+ "aria-label": pr(s, r),
2715
2756
  "data-testid": "markweave-table-menu",
2716
2757
  "data-positioned": d ? "true" : "false",
2717
2758
  style: d ? {
@@ -2719,7 +2760,7 @@ function Ni({ active: e, editor: t, interactionState: n = Xt, messages: r = Mi,
2719
2760
  top: d.top
2720
2761
  } : void 0,
2721
2762
  children: P.map((e, n) => {
2722
- let i = er(e), a = n === 0 ? i : er(P[n - 1]), l = n > 0 && a !== i, u = e.commandId === null ? !!o : Kn(t, e.commandId), d = tr(e, r);
2763
+ let i = or(e), a = n === 0 ? i : or(P[n - 1]), l = n > 0 && a !== i, u = e.commandId === null ? !!o : Qn(t, e.commandId), d = sr(e, r);
2723
2764
  return /* @__PURE__ */ Z("button", {
2724
2765
  type: "button",
2725
2766
  role: "menuitem",
@@ -2749,15 +2790,15 @@ function Ni({ active: e, editor: t, interactionState: n = Xt, messages: r = Mi,
2749
2790
  }
2750
2791
  //#endregion
2751
2792
  //#region src/ui/table/TableSelectionOverlay.tsx
2752
- function Pi({ editor: e, focusState: t }) {
2753
- let [n, r] = q(null);
2754
- return W(() => {
2793
+ function Bi({ editor: e, focusState: t }) {
2794
+ let [n, r] = K(null);
2795
+ return U(() => {
2755
2796
  if (t.mode !== "cell-selection") {
2756
2797
  r(null);
2757
2798
  return;
2758
2799
  }
2759
2800
  let n = () => {
2760
- r(ir(e, Yt(e.state)));
2801
+ r(ur(e, Yt(e.state)));
2761
2802
  };
2762
2803
  return n(), window.addEventListener("resize", n), window.addEventListener("scroll", n, !0), () => {
2763
2804
  window.removeEventListener("resize", n), window.removeEventListener("scroll", n, !0);
@@ -2792,16 +2833,16 @@ function Pi({ editor: e, focusState: t }) {
2792
2833
  }
2793
2834
  //#endregion
2794
2835
  //#region src/ui/toc/MarkweaveInnerToc.tsx
2795
- function Fi(e, t) {
2836
+ function Vi(e, t) {
2796
2837
  return `${e.toc.itemAriaLabel}: ${t.text}`;
2797
2838
  }
2798
- function Ii({ editor: e, state: t, messages: n, editable: r, placement: i }) {
2799
- let a = K(null);
2800
- if (U(() => {
2801
- if (!(i !== "container" || !a.current)) return mr(a.current);
2839
+ function Hi({ editor: e, state: t, messages: n, editable: r, placement: i }) {
2840
+ let a = G(null);
2841
+ if (H(() => {
2842
+ if (!(i !== "container" || !a.current)) return br(a.current);
2802
2843
  }, [i]), !t.items.length) return null;
2803
2844
  let o = (t) => {
2804
- hr(e, t, {
2845
+ xr(e, t, {
2805
2846
  behavior: "smooth",
2806
2847
  focus: r
2807
2848
  });
@@ -2828,7 +2869,7 @@ function Ii({ editor: e, state: t, messages: n, editable: r, placement: i }) {
2828
2869
  "data-level": e.level,
2829
2870
  "data-active": e.active ? "true" : "false",
2830
2871
  "aria-current": e.active ? "location" : void 0,
2831
- "aria-label": Fi(n, e),
2872
+ "aria-label": Vi(n, e),
2832
2873
  title: e.text,
2833
2874
  onClick: () => o(e),
2834
2875
  children: e.text
@@ -2839,7 +2880,7 @@ function Ii({ editor: e, state: t, messages: n, editable: r, placement: i }) {
2839
2880
  }
2840
2881
  //#endregion
2841
2882
  //#region src/MarkweaveEditor.tsx
2842
- var Li = {
2883
+ var Ui = {
2843
2884
  active: !1,
2844
2885
  mode: "outside",
2845
2886
  activeCellPos: null,
@@ -2847,21 +2888,21 @@ var Li = {
2847
2888
  selectedCellCount: 0,
2848
2889
  selectionFrom: 0,
2849
2890
  selectionTo: 0
2850
- }, Ri = {
2891
+ }, Wi = {
2851
2892
  active: !1,
2852
2893
  language: ht.defaultLanguage,
2853
2894
  mermaidPreviewMode: "code",
2854
2895
  pos: null,
2855
2896
  text: ""
2856
- }, zi = Ct({
2897
+ }, Gi = Ct({
2857
2898
  active: !1,
2858
2899
  mode: "code",
2859
2900
  source: ""
2860
2901
  });
2861
- function Bi(e) {
2902
+ function Ki(e) {
2862
2903
  return Zt.getState(e.state) ?? Xt;
2863
2904
  }
2864
- function Vi(e) {
2905
+ function qi(e) {
2865
2906
  if (!e || typeof window > "u") return null;
2866
2907
  let t = e.parentElement;
2867
2908
  for (; t;) {
@@ -2871,18 +2912,18 @@ function Vi(e) {
2871
2912
  }
2872
2913
  return null;
2873
2914
  }
2874
- function Hi(e) {
2915
+ function Ji(e) {
2875
2916
  return typeof window > "u" || typeof window.requestAnimationFrame != "function" ? globalThis.setTimeout(() => e(0), 0) : window.requestAnimationFrame(e);
2876
2917
  }
2877
- function Ui(e) {
2918
+ function Yi(e) {
2878
2919
  if (typeof window < "u" && typeof window.cancelAnimationFrame == "function") {
2879
2920
  window.cancelAnimationFrame(e);
2880
2921
  return;
2881
2922
  }
2882
2923
  globalThis.clearTimeout(e);
2883
2924
  }
2884
- function Wi({ ariaLabel: e, autoFocusFirstTableBodyCell: i = !1, autofocus: a = !1, content: o, contentFormat: c, defaultContent: l = "", defaultContentFormat: u, editable: d = !0, innerToc: f = !0, innerTocPlacement: p, lang: m, mode: h = "live", theme: g, canvasColor: _, onEditWithAi: v, onExtractToNote: y, onRewriteSelection: b, onRuntimeStateChange: x, onSearchControllerChange: S, onSlashCommandUpload: C, onTableCommandResult: w, onTableCopyPayload: T, onTocChange: E, onUpdate: D, linkCardResolver: O } = {}) {
2885
- let k = Ie(h), A = _r(g), j = gr(_), M = pr(p), N = k === "live" && d !== !1, P = Ze(o === void 0 ? u : c), F = K({
2925
+ function Xi({ ariaLabel: e, autoFocusFirstTableBodyCell: i = !1, autofocus: a = !1, content: o, contentFormat: c, defaultContent: l = "", defaultContentFormat: u, editable: d = !0, innerToc: f = !0, innerTocPlacement: p, lang: m, mode: h = "live", theme: g, canvasColor: _, onEditWithAi: v, onExtractToNote: y, onRewriteSelection: b, onRuntimeStateChange: x, onSearchControllerChange: S, onSlashCommandUpload: C, onTableCommandResult: w, onTableCopyPayload: T, onTocChange: E, onUpdate: D, linkCardResolver: O } = {}) {
2926
+ let k = Ie(h), A = Cr(g), j = Sr(_), M = yr(p), N = k === "live" && d !== !1, P = Ze(o === void 0 ? u : c), F = G({
2886
2927
  editorMode: k,
2887
2928
  effectiveEditable: N
2888
2929
  });
@@ -2890,71 +2931,71 @@ function Wi({ ariaLabel: e, autoFocusFirstTableBodyCell: i = !1, autofocus: a =
2890
2931
  editorMode: k,
2891
2932
  effectiveEditable: N
2892
2933
  };
2893
- let ee = K(null);
2934
+ let ee = G(null);
2894
2935
  ee.current === null && (ee.current = r(m));
2895
- let I = ee.current, L = G(() => n(I), [I]), te = G(() => t(I), [I]), R = K(C);
2896
- R.current = C;
2897
- let z = K(S);
2898
- z.current = S;
2899
- let ne = K(O);
2900
- ne.current = O;
2901
- let re = G(() => Br({
2902
- lang: I,
2936
+ let te = ee.current, I = W(() => n(te), [te]), L = W(() => t(te), [te]), ne = G(C);
2937
+ ne.current = C;
2938
+ let re = G(S);
2939
+ re.current = S;
2940
+ let R = G(O);
2941
+ R.current = O;
2942
+ let ie = W(() => Kr({
2943
+ lang: te,
2903
2944
  onImageUpload: (e) => {
2904
- if (R.current) return R.current(e);
2905
- let t = be(e);
2945
+ if (ne.current) return ne.current(e);
2946
+ let t = xe(e);
2906
2947
  if (!t) throw Error("File upload requires an upload handler.");
2907
2948
  return t;
2908
2949
  },
2909
2950
  onVideoUpload: (e) => {
2910
- if (R.current) return R.current(e);
2911
- let t = be(e);
2951
+ if (ne.current) return ne.current(e);
2952
+ let t = xe(e);
2912
2953
  if (!t) throw Error("File upload requires an upload handler.");
2913
2954
  return t;
2914
2955
  },
2915
- linkCardResolver: (e) => ne.current?.(e) ?? Promise.resolve(null)
2916
- }), [I]), [ie, ae] = q(null), [B, V] = q(Wt), [oe, se] = q(null), [ce, le] = q(null), [ue, de] = q("code"), [fe, pe] = q(null), [me, he] = q(Xt), [ge, _e] = q(null), [W, ve] = q(0), ye = K(!1), xe = K({
2956
+ linkCardResolver: (e) => R.current?.(e) ?? Promise.resolve(null)
2957
+ }), [te]), [ae, oe] = K(null), [z, B] = K(Wt), [se, ce] = K(null), [le, ue] = K(null), [de, fe] = K("code"), [pe, me] = K(null), [he, ge] = K(Xt), [_e, ve] = K(null), [U, ye] = K(0), be = G(!1), Se = G({
2917
2958
  content: o,
2918
2959
  format: P
2919
- }), Se = K(null), Ce = K(null), we = K({ onUpdate: D }), Te = G(() => It(B.query, te), [te, B.query]);
2920
- we.current = { onUpdate: D }, xe.current = {
2960
+ }), Ce = G(null), we = G(null), Te = G({ onUpdate: D }), Ee = W(() => It(z.query, L), [L, z.query]);
2961
+ Te.current = { onUpdate: D }, Se.current = {
2921
2962
  content: o,
2922
2963
  format: P
2923
2964
  };
2924
- let Ee = H(() => {
2925
- Ce.current !== null && (window.clearTimeout(Ce.current), Ce.current = null), ve((e) => e + 1);
2926
- }, []), De = H(() => {
2927
- Ce.current !== null && window.clearTimeout(Ce.current), Ce.current = window.setTimeout(() => {
2928
- Ce.current = null, ve((e) => e + 1);
2965
+ let De = V(() => {
2966
+ we.current !== null && (window.clearTimeout(we.current), we.current = null), ye((e) => e + 1);
2967
+ }, []), Oe = V(() => {
2968
+ we.current !== null && window.clearTimeout(we.current), we.current = window.setTimeout(() => {
2969
+ we.current = null, ye((e) => e + 1);
2929
2970
  }, ct);
2930
2971
  }, []);
2931
- U(() => () => {
2932
- Ce.current !== null && window.clearTimeout(Ce.current);
2972
+ H(() => () => {
2973
+ we.current !== null && window.clearTimeout(we.current);
2933
2974
  }, []);
2934
- let Oe = H(() => {
2935
- se(null), le(null), V(Wt);
2936
- }, []), ke = H((e) => {
2975
+ let q = V(() => {
2976
+ ce(null), ue(null), B(Wt);
2977
+ }, []), ke = V((e) => {
2937
2978
  let t = Ut(e.state);
2938
2979
  if (!t) {
2939
- V((e) => e.name === "idle" ? e : Wt), se(null), le(null);
2980
+ B((e) => e.name === "idle" ? e : Wt), ce(null), ue(null);
2940
2981
  return;
2941
2982
  }
2942
2983
  let n = e.coordsAtPos(t.cursor), r = e.coordsAtPos(t.triggerFrom), i = e.dom.closest(".markweave-editor-frame")?.getBoundingClientRect();
2943
- se(Ht(n, {
2984
+ ce(Ht(n, {
2944
2985
  frameRect: i,
2945
2986
  triggerRect: r
2946
- })), V((e) => Vt(e, t));
2947
- }, []), Ae = H((e) => ke(e.view), [ke]), je = H((e) => {
2987
+ })), B((e) => Vt(e, t));
2988
+ }, []), Ae = V((e) => ke(e.view), [ke]), je = V((e) => {
2948
2989
  let t = at(e);
2949
- ae((e) => tt(e, t) ? e : t);
2990
+ oe((e) => tt(e, t) ? e : t);
2950
2991
  let n = jt(e);
2951
- n && (Nt(e, n, !0), pe(n));
2992
+ n && (Nt(e, n, !0), me(n));
2952
2993
  let r = pt(e);
2953
- r.active && r.language === "mermaid" && de(r.mermaidPreviewMode);
2954
- }, []), Me = H((e) => {
2955
- he(Bi(e));
2994
+ r.active && r.language === "mermaid" && fe(r.mermaidPreviewMode);
2995
+ }, []), Me = V((e) => {
2996
+ ge(Ki(e));
2956
2997
  }, []), J = s({
2957
- extensions: re,
2998
+ extensions: ie,
2958
2999
  content: o ?? l,
2959
3000
  contentType: Je(P),
2960
3001
  editable: N,
@@ -2970,12 +3011,12 @@ function Wi({ ariaLabel: e, autoFocusFirstTableBodyCell: i = !1, autofocus: a =
2970
3011
  },
2971
3012
  handleClick: (e, t, n) => F.current.effectiveEditable ? !1 : Qe(n),
2972
3013
  handleDOMEvents: {
2973
- compositionstart: () => F.current.effectiveEditable ? (V((e) => Gt(e, { type: "composition-start" })), se(null), !1) : !1,
3014
+ compositionstart: () => F.current.effectiveEditable ? (B((e) => Gt(e, { type: "composition-start" })), ce(null), !1) : !1,
2974
3015
  compositionend: (e) => (F.current.effectiveEditable && window.setTimeout(() => ke(e), 0), !1),
2975
3016
  click: (e, t) => {
2976
3017
  if (F.current.effectiveEditable) {
2977
3018
  let n = At(e, t);
2978
- return n ? (t.preventDefault(), t.stopPropagation(), Oe(), Pt(e, n, !0), Ft(e, n), pe(n), !0) : (pe(null), !1);
3019
+ return n ? (t.preventDefault(), t.stopPropagation(), q(), Pt(e, n, !0), Ft(e, n), me(n), !0) : (me(null), !1);
2979
3020
  }
2980
3021
  return Qe(t);
2981
3022
  }
@@ -2985,19 +3026,19 @@ function Wi({ ariaLabel: e, autoFocusFirstTableBodyCell: i = !1, autofocus: a =
2985
3026
  je(e);
2986
3027
  },
2987
3028
  onCreate: ({ editor: e }) => {
2988
- i && F.current.effectiveEditable && qt(e), Me(e), je(e), Ee();
3029
+ i && F.current.effectiveEditable && qt(e), Me(e), je(e), De();
2989
3030
  },
2990
3031
  onTransaction: ({ editor: e, transaction: t }) => {
2991
- Me(e), (t.docChanged || yt(t)) && De(), t.docChanged && pe((t) => {
3032
+ Me(e), (t.docChanged || yt(t)) && Oe(), t.docChanged && me((t) => {
2992
3033
  if (!t) return null;
2993
3034
  let n = kt(e, t.pos);
2994
3035
  return n?.kind === t.kind ? n : null;
2995
3036
  });
2996
3037
  },
2997
3038
  onUpdate: ({ editor: e }) => {
2998
- je(e), F.current.effectiveEditable && Ae(e), ye.current || we.current.onUpdate?.(qe(e, { onContentRead: (t, n) => {
2999
- let r = xe.current;
3000
- r.content !== void 0 && t === r.format && (Se.current = {
3039
+ je(e), F.current.effectiveEditable && Ae(e), be.current || Te.current.onUpdate?.(qe(e, { onContentRead: (t, n) => {
3040
+ let r = Se.current;
3041
+ r.content !== void 0 && t === r.format && (Ce.current = {
3001
3042
  content: n,
3002
3043
  format: t,
3003
3044
  doc: e.state.doc
@@ -3005,107 +3046,107 @@ function Wi({ ariaLabel: e, autoFocusFirstTableBodyCell: i = !1, autofocus: a =
3005
3046
  } }));
3006
3047
  }
3007
3048
  });
3008
- U(() => {
3009
- if (J) return z.current?.(vr(J)), () => {
3010
- z.current?.(null);
3049
+ H(() => {
3050
+ if (J) return re.current?.(wr(J)), () => {
3051
+ re.current?.(null);
3011
3052
  };
3012
- }, [J]), U(() => {
3053
+ }, [J]), H(() => {
3013
3054
  J && (J.setEditable(N), Le(J, {
3014
3055
  mode: k,
3015
3056
  editable: N
3016
- }), xt(J, N ? "live" : "view"), Ee(), N || Oe());
3057
+ }), xt(J, N ? "live" : "view"), De(), N || q());
3017
3058
  }, [
3018
- Oe,
3059
+ q,
3019
3060
  J,
3020
3061
  k,
3021
3062
  N,
3022
- Ee
3023
- ]), U(() => {
3063
+ De
3064
+ ]), H(() => {
3024
3065
  J && bt(J, A);
3025
- }, [J, A]), U(() => {
3066
+ }, [J, A]), H(() => {
3026
3067
  let e = Ze(c);
3027
3068
  if (!(!J || o === void 0)) {
3028
- if (Xe(J, Se.current, o, e)) {
3029
- Se.current = null;
3069
+ if (Xe(J, Ce.current, o, e)) {
3070
+ Ce.current = null;
3030
3071
  return;
3031
3072
  }
3032
- Se.current = null, !Ye(J, o, e) && (ye.current = !0, J.commands.setContent(o, {
3073
+ Ce.current = null, !Ye(J, o, e) && (be.current = !0, J.commands.setContent(o, {
3033
3074
  contentType: Je(e),
3034
3075
  emitUpdate: !1
3035
- }), ye.current = !1, je(J), N && Ae(J), Me(J), Ee());
3076
+ }), be.current = !1, je(J), N && Ae(J), Me(J), De());
3036
3077
  }
3037
3078
  }, [
3038
3079
  o,
3039
3080
  c,
3040
3081
  N,
3041
3082
  J,
3042
- Ee,
3083
+ De,
3043
3084
  je,
3044
3085
  Ae,
3045
3086
  Me
3046
- ]), U(() => {
3047
- if (!oe) return;
3087
+ ]), H(() => {
3088
+ if (!se) return;
3048
3089
  let e = (e) => {
3049
3090
  let t = e.target;
3050
- t instanceof Element && (t.closest(".markweave-slash-menu") || t.closest(".markweave-slash-trigger") || Oe());
3091
+ t instanceof Element && (t.closest(".markweave-slash-menu") || t.closest(".markweave-slash-trigger") || q());
3051
3092
  };
3052
3093
  return document.addEventListener("pointerdown", e, !0), () => document.removeEventListener("pointerdown", e, !0);
3053
- }, [Oe, oe]);
3054
- let Ne = G(() => J ? pt(J) : Ri, [
3094
+ }, [q, se]);
3095
+ let Ne = W(() => J ? pt(J) : Wi, [
3055
3096
  J,
3056
- W,
3057
- ie
3058
- ]), Y = G(() => J ? Jt(J.state) : Li, [
3097
+ U,
3098
+ ae
3099
+ ]), Y = W(() => J ? Jt(J.state) : Ui, [
3059
3100
  J,
3060
- W,
3061
- ie,
3062
- me
3063
- ]), Pe = ie?.currentNode === "codeBlock", Fe = Pe && Ne.language === "mermaid", Re = G(() => J ? Ct({
3101
+ U,
3102
+ ae,
3103
+ he
3104
+ ]), Pe = ae?.currentNode === "codeBlock", Fe = Pe && Ne.language === "mermaid", Re = W(() => J ? Ct({
3064
3105
  active: Fe,
3065
- mode: ue,
3106
+ mode: de,
3066
3107
  source: Ne.text
3067
- }) : zi, [
3108
+ }) : Gi, [
3068
3109
  Ne.text,
3069
3110
  J,
3070
3111
  Fe,
3071
- ue
3072
- ]), ze = G(() => J ? Kt(J.state) : null, [J, W]), X = G(() => J ? dr(J.state.doc) : lr.items, [J, W]), Z = G(() => fr(X, ge), [ge, X]), Q = G(() => cr(X, Z), [Z, X]), Be = H(() => {
3112
+ de
3113
+ ]), ze = W(() => J ? Kt(J.state) : null, [J, U]), X = W(() => J ? _r(J.state.doc) : hr.items, [J, U]), Z = W(() => vr(X, _e), [_e, X]), Q = W(() => mr(X, Z), [Z, X]), Be = V(() => {
3073
3114
  if (!J || !X.length) {
3074
- _e(null);
3115
+ ve(null);
3075
3116
  return;
3076
3117
  }
3077
- let e = ur(J, X);
3078
- _e((t) => t === e ? t : e);
3118
+ let e = gr(J, X);
3119
+ ve((t) => t === e ? t : e);
3079
3120
  }, [J, X]);
3080
- U(() => {
3081
- _e((e) => {
3082
- let t = fr(X, e);
3121
+ H(() => {
3122
+ ve((e) => {
3123
+ let t = vr(X, e);
3083
3124
  return e === t ? e : t;
3084
3125
  });
3085
- }, [X]), U(() => {
3126
+ }, [X]), H(() => {
3086
3127
  if (!J || !X.length || typeof window > "u") return;
3087
3128
  let e = null, t = () => {
3088
- e !== null && Ui(e), e = Hi(() => {
3129
+ e !== null && Yi(e), e = Ji(() => {
3089
3130
  e = null, Be();
3090
3131
  });
3091
- }, n = Vi(J.view.dom);
3132
+ }, n = qi(J.view.dom);
3092
3133
  return window.addEventListener("scroll", t, { passive: !0 }), window.addEventListener("resize", t), n?.addEventListener("scroll", t, { passive: !0 }), t(), () => {
3093
- window.removeEventListener("scroll", t), window.removeEventListener("resize", t), n?.removeEventListener("scroll", t), e !== null && Ui(e);
3134
+ window.removeEventListener("scroll", t), window.removeEventListener("resize", t), n?.removeEventListener("scroll", t), e !== null && Yi(e);
3094
3135
  };
3095
3136
  }, [
3096
3137
  J,
3097
3138
  X.length,
3098
3139
  Be
3099
3140
  ]);
3100
- let Ve = G(() => $e({
3101
- revision: W,
3141
+ let Ve = W(() => $e({
3142
+ revision: U,
3102
3143
  mode: k,
3103
3144
  editable: N,
3104
3145
  toc: Q,
3105
- selection: ie,
3106
- slash: B,
3146
+ selection: ae,
3147
+ slash: z,
3107
3148
  table: Y,
3108
- tableInteraction: me,
3149
+ tableInteraction: he,
3109
3150
  codeBlock: Ne,
3110
3151
  mermaid: Re,
3111
3152
  tableDebugSnapshot: ze
@@ -3114,48 +3155,48 @@ function Wi({ ariaLabel: e, autoFocusFirstTableBodyCell: i = !1, autofocus: a =
3114
3155
  k,
3115
3156
  N,
3116
3157
  Re,
3117
- W,
3118
- ie,
3119
- B,
3158
+ U,
3159
+ ae,
3160
+ z,
3120
3161
  ze,
3121
3162
  Y,
3122
- me,
3163
+ he,
3123
3164
  Q
3124
3165
  ]);
3125
- U(() => {
3166
+ H(() => {
3126
3167
  x?.(Ve);
3127
- }, [x, Ve]), U(() => {
3168
+ }, [x, Ve]), H(() => {
3128
3169
  E?.(Q);
3129
3170
  }, [E, Q]);
3130
- let He = H((e, t) => {
3171
+ let He = V((e, t) => {
3131
3172
  if (!(!J || !N) && Lt(e)) {
3132
3173
  if (e.inputKind && !t?.emoji && !t?.uploadResult) {
3133
- le(e);
3174
+ ue(e);
3134
3175
  return;
3135
3176
  }
3136
- Bt(J, B, e, t), V((e) => Gt(e, { type: "execute" })), Oe();
3177
+ Bt(J, z, e, t), B((e) => Gt(e, { type: "execute" })), q();
3137
3178
  }
3138
3179
  }, [
3139
- Oe,
3180
+ q,
3140
3181
  N,
3141
3182
  J,
3142
- B
3143
- ]), Ue = H((e) => {
3144
- V((t) => Gt(t, {
3183
+ z
3184
+ ]), Ue = V((e) => {
3185
+ B((t) => Gt(t, {
3145
3186
  type: "set-active",
3146
3187
  index: e,
3147
- optionCount: Te.length
3188
+ optionCount: Ee.length
3148
3189
  }));
3149
- }, [Te.length]), We = H((e) => {
3150
- if (!J || ce || !N) return;
3151
- let t = Rt(B, Te, e.key, { isComposing: e.nativeEvent.isComposing || Ke(J.state) });
3190
+ }, [Ee.length]), We = V((e) => {
3191
+ if (!J || le || !N) return;
3192
+ let t = Rt(z, Ee, e.key, { isComposing: e.nativeEvent.isComposing || Ke(J.state) });
3152
3193
  if (t.type !== "ignore") {
3153
3194
  if (t.type === "close") {
3154
- e.preventDefault(), V((e) => Gt(e, { type: "escape" })), Oe();
3195
+ e.preventDefault(), B((e) => Gt(e, { type: "escape" })), q();
3155
3196
  return;
3156
3197
  }
3157
3198
  if (t.type === "move-active") {
3158
- e.preventDefault(), V((e) => Gt(e, {
3199
+ e.preventDefault(), B((e) => Gt(e, {
3159
3200
  type: "move-active",
3160
3201
  delta: t.delta,
3161
3202
  optionCount: t.optionCount
@@ -3165,15 +3206,15 @@ function Wi({ ariaLabel: e, autoFocusFirstTableBodyCell: i = !1, autofocus: a =
3165
3206
  t.type === "execute-active" && (e.preventDefault(), He(t.command));
3166
3207
  }
3167
3208
  }, [
3168
- Oe,
3209
+ q,
3169
3210
  N,
3170
3211
  J,
3171
- Te,
3212
+ Ee,
3172
3213
  He,
3173
- ce,
3174
- B
3175
- ]), Ge = G(() => ({
3176
- closeSlashMenu: Oe,
3214
+ le,
3215
+ z
3216
+ ]), Ge = W(() => ({
3217
+ closeSlashMenu: q,
3177
3218
  focusFirstTableBodyCell: () => J ? qt(J) : !1,
3178
3219
  setContent: (e, t = {}) => {
3179
3220
  if (!J) return !1;
@@ -3181,22 +3222,22 @@ function Wi({ ariaLabel: e, autoFocusFirstTableBodyCell: i = !1, autofocus: a =
3181
3222
  return J.commands.setContent(e, {
3182
3223
  contentType: Je(n),
3183
3224
  emitUpdate: t.emitUpdate ?? !1
3184
- }), t.focusFirstTableBodyCell && qt(J), je(J), N && Ae(J), Me(J), Ee(), !0;
3225
+ }), t.focusFirstTableBodyCell && qt(J), je(J), N && Ae(J), Me(J), De(), !0;
3185
3226
  }
3186
3227
  }), [
3187
- Oe,
3228
+ q,
3188
3229
  N,
3189
3230
  J,
3190
- Ee,
3231
+ De,
3191
3232
  je,
3192
3233
  Ae,
3193
3234
  Me
3194
3235
  ]);
3195
3236
  return {
3196
3237
  editor: J,
3197
- frameProps: G(() => ({
3238
+ frameProps: W(() => ({
3198
3239
  className: "markweave-editor-frame",
3199
- "aria-label": e ?? L.common.editorAriaLabel,
3240
+ "aria-label": e ?? I.common.editorAriaLabel,
3200
3241
  "data-testid": "markweave-editor-frame",
3201
3242
  "data-markweave-mode": k,
3202
3243
  "data-markweave-theme": A,
@@ -3212,36 +3253,36 @@ function Wi({ ariaLabel: e, autoFocusFirstTableBodyCell: i = !1, autofocus: a =
3212
3253
  We,
3213
3254
  f,
3214
3255
  Re.mode,
3215
- L.common.editorAriaLabel,
3256
+ I.common.editorAriaLabel,
3216
3257
  j,
3217
3258
  M,
3218
3259
  A,
3219
3260
  Y.mode
3220
3261
  ]),
3221
- overlayProps: G(() => ({
3262
+ overlayProps: W(() => ({
3222
3263
  floatingToolbar: J && N ? {
3223
3264
  editor: J,
3224
- messages: L,
3225
- selectionSnapshot: ie,
3265
+ messages: I,
3266
+ selectionSnapshot: ae,
3226
3267
  onRewriteSelection: b,
3227
3268
  onExtractToNote: y
3228
3269
  } : null,
3229
3270
  slashCommandMenu: J && N ? {
3230
- commands: Te,
3231
- state: B,
3232
- position: oe,
3233
- inputCommand: ce,
3234
- messages: L,
3271
+ commands: Ee,
3272
+ state: z,
3273
+ position: se,
3274
+ inputCommand: le,
3275
+ messages: I,
3235
3276
  onActiveIndexChange: Ue,
3236
- onInputCommandChange: le,
3277
+ onInputCommandChange: ue,
3237
3278
  onSelect: He,
3238
3279
  onUpload: C
3239
3280
  } : null,
3240
3281
  tableControls: J && N ? {
3241
3282
  editor: J,
3242
3283
  active: Y.active,
3243
- interactionState: me,
3244
- messages: L,
3284
+ interactionState: he,
3285
+ messages: I,
3245
3286
  onCopyPayload: T,
3246
3287
  onCommandResult: w,
3247
3288
  onEditWithAi: v
@@ -3253,32 +3294,32 @@ function Wi({ ariaLabel: e, autoFocusFirstTableBodyCell: i = !1, autofocus: a =
3253
3294
  codeBlockControls: J ? {
3254
3295
  editor: J,
3255
3296
  active: N && Pe,
3256
- mermaidMode: ue,
3257
- onMermaidModeChange: de,
3297
+ mermaidMode: de,
3298
+ onMermaidModeChange: fe,
3258
3299
  readOnly: !N
3259
3300
  } : null,
3260
3301
  innerToc: J && f && Q.items.length ? {
3261
3302
  editor: J,
3262
3303
  editable: N,
3263
- messages: L,
3304
+ messages: I,
3264
3305
  placement: M,
3265
3306
  state: Q
3266
3307
  } : null,
3267
- mathEditorPopover: J && N && fe ? {
3308
+ mathEditorPopover: J && N && pe ? {
3268
3309
  editor: J,
3269
- messages: L,
3270
- target: fe,
3271
- onClose: () => pe(null)
3310
+ messages: I,
3311
+ target: pe,
3312
+ onClose: () => me(null)
3272
3313
  } : null
3273
3314
  }), [
3274
3315
  N,
3275
3316
  J,
3276
- Te,
3317
+ Ee,
3277
3318
  f,
3278
3319
  Pe,
3279
- ue,
3280
- L,
3281
- fe,
3320
+ de,
3321
+ I,
3322
+ pe,
3282
3323
  v,
3283
3324
  y,
3284
3325
  b,
@@ -3286,37 +3327,37 @@ function Wi({ ariaLabel: e, autoFocusFirstTableBodyCell: i = !1, autofocus: a =
3286
3327
  w,
3287
3328
  T,
3288
3329
  He,
3289
- ie,
3330
+ ae,
3290
3331
  Ue,
3291
- ce,
3292
- oe,
3293
- B,
3332
+ le,
3333
+ se,
3334
+ z,
3294
3335
  Y,
3295
- me,
3336
+ he,
3296
3337
  Q
3297
3338
  ]),
3298
3339
  runtimeSnapshot: Ve,
3299
3340
  actions: Ge
3300
3341
  };
3301
3342
  }
3302
- function Gi({ className: e, ...t }) {
3303
- let n = Wi(t);
3343
+ function Zi({ className: e, ...t }) {
3344
+ let n = Xi(t);
3304
3345
  if (!n.editor) return null;
3305
3346
  let r = [n.frameProps.className, e].filter(Boolean).join(" ");
3306
3347
  return /* @__PURE__ */ Q("section", {
3307
3348
  ...n.frameProps,
3308
3349
  className: r,
3309
3350
  children: [
3310
- n.overlayProps.floatingToolbar ? /* @__PURE__ */ Z(ui, { ...n.overlayProps.floatingToolbar }) : null,
3311
- n.overlayProps.slashCommandMenu ? /* @__PURE__ */ Z(ji, { ...n.overlayProps.slashCommandMenu }) : null,
3312
- n.overlayProps.tableControls ? /* @__PURE__ */ Z(Ni, { ...n.overlayProps.tableControls }) : null,
3313
- n.overlayProps.tableSelectionOverlay ? /* @__PURE__ */ Z(Pi, { ...n.overlayProps.tableSelectionOverlay }) : null,
3314
- n.overlayProps.codeBlockControls ? /* @__PURE__ */ Z(Ur, { ...n.overlayProps.codeBlockControls }) : null,
3315
- n.overlayProps.innerToc ? /* @__PURE__ */ Z(Ii, { ...n.overlayProps.innerToc }) : null,
3316
- n.overlayProps.mathEditorPopover ? /* @__PURE__ */ Z(Si, { ...n.overlayProps.mathEditorPopover }) : null,
3351
+ n.overlayProps.floatingToolbar ? /* @__PURE__ */ Z(gi, { ...n.overlayProps.floatingToolbar }) : null,
3352
+ n.overlayProps.slashCommandMenu ? /* @__PURE__ */ Z(Li, { ...n.overlayProps.slashCommandMenu }) : null,
3353
+ n.overlayProps.tableControls ? /* @__PURE__ */ Z(zi, { ...n.overlayProps.tableControls }) : null,
3354
+ n.overlayProps.tableSelectionOverlay ? /* @__PURE__ */ Z(Bi, { ...n.overlayProps.tableSelectionOverlay }) : null,
3355
+ n.overlayProps.codeBlockControls ? /* @__PURE__ */ Z(Yr, { ...n.overlayProps.codeBlockControls }) : null,
3356
+ n.overlayProps.innerToc ? /* @__PURE__ */ Z(Hi, { ...n.overlayProps.innerToc }) : null,
3357
+ n.overlayProps.mathEditorPopover ? /* @__PURE__ */ Z(Oi, { ...n.overlayProps.mathEditorPopover }) : null,
3317
3358
  /* @__PURE__ */ Z(i, { editor: n.editor })
3318
3359
  ]
3319
3360
  });
3320
3361
  }
3321
3362
  //#endregion
3322
- export { Gi as MarkweaveEditor, Br as createMarkweaveEditorExtensions, Br as createMarkweaveReactEditorExtensions, Wi as useMarkweaveEditorController };
3363
+ export { Zi as MarkweaveEditor, Kr as createMarkweaveEditorExtensions, Kr as createMarkweaveReactEditorExtensions, Xi as useMarkweaveEditorController };