@markweave/react 0.1.6 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import { createMarkweaveEditorExtensions as e } from "markweave/internal/editor-core/create-editor-extensions";
2
2
  import { EditorContent as t, NodeViewWrapper as n, ReactNodeViewRenderer as r, useEditor as i } from "@tiptap/react";
3
- import { AlertTriangle as a, AlignCenter as o, AlignJustify as s, AlignLeft as c, AlignRight as l, Bold as u, Braces as d, Captions as f, Check as p, CheckCircle2 as m, ChevronDown as h, ChevronUp as g, CircleX as _, Code2 as v, CornerDownLeft as y, Download as b, ExternalLink as x, Eye as S, Heading1 as ee, Heading2 as C, Heading3 as w, Image as T, ImageUp as E, IndentDecrease as D, IndentIncrease as O, Info as k, Italic as A, Lightbulb as j, Link2 as M, List as N, ListChecks as P, ListOrdered as F, Minus as te, MoreVertical as I, Paperclip as L, Quote as ne, Replace as R, Sigma as z, SmilePlus as re, Sparkles as ie, Strikethrough as ae, Subscript as oe, Superscript as se, Table2 as ce, Text as le, Trash2 as ue, Type as de, Underline as fe, Upload as pe, Video as B } from "lucide-react";
4
- import { useCallback as V, useEffect as H, useLayoutEffect as me, useMemo as U, useRef as W, useState as G, useSyncExternalStore as he } from "react";
5
- import { detectUploadSource as ge, getDirectUploadResult as _e, resolveMarkweaveUploadResult as ve } from "markweave/internal/plugins/slash-command/upload";
6
- import { MarkweaveCoreImage as K, MarkweaveCoreVideo as ye, attrsFromMarkweaveImageUploadResult as be, attrsFromMarkweaveVideoUploadResult as xe, attrsFromMarkweaveVideoUrl as Se, clampMarkweaveImageWidth as q, createMarkweaveImageUploadRequest as Ce, createMarkweaveVideoUploadRequest as we, downloadMarkweaveImage as Te, markweaveVideoIframeAllow as Ee, normalizeMarkweaveCoreImageAlign as De, normalizeMarkweaveVideoEmbedUrl as Oe, numberAttribute as J, stringAttribute as Y } from "markweave/internal/plugins/media/core-media-nodes";
7
- import { getLocalizedSlashCommandSpecs as ke, getMarkweaveMessages as Ae, normalizeMarkweaveLang as je } from "markweave/internal/i18n";
8
- import { getMarkweaveEditorModeState as Me, isMarkweaveEditorLiveEditable as Ne, normalizeMarkweaveEditorMode as Pe, setMarkweaveEditorModeState as Fe, subscribeToMarkweaveEditorMode as Ie } from "markweave/internal/core/editor-mode-state";
3
+ import { AlertTriangle as a, AlignCenter as o, AlignJustify as s, AlignLeft as c, AlignRight as l, Bold as u, Braces as d, Captions as f, Check as p, CheckCircle2 as m, ChevronDown as h, ChevronUp as g, CircleX as _, Code2 as v, CornerDownLeft as y, Download as b, ExternalLink as x, Eye as S, Heading1 as C, Heading2 as w, Heading3 as T, Image as E, ImageUp as D, IndentDecrease as O, IndentIncrease as ee, Info as k, Italic as A, Lightbulb as j, Link2 as te, List as M, ListChecks as N, ListOrdered as ne, Minus as P, MoreVertical as F, Paperclip as I, Quote as re, Replace as L, Sigma as R, SmilePlus as ie, Sparkles as ae, Strikethrough as oe, Subscript as z, Superscript as se, Table2 as ce, Text as le, Trash2 as ue, Type as de, Underline as fe, Upload as pe, Video as me } from "lucide-react";
4
+ import { useCallback as B, useEffect as V, useLayoutEffect as he, useMemo as H, useRef as U, useState as W, useSyncExternalStore as ge } from "react";
5
+ import { detectUploadSource as _e, getDirectUploadResult as ve, resolveMarkweaveUploadResult as G } from "markweave/internal/plugins/slash-command/upload";
6
+ import { MarkweaveCoreImage as ye, MarkweaveCoreVideo as be, attrsFromMarkweaveImageUploadResult as K, attrsFromMarkweaveVideoUploadResult as xe, attrsFromMarkweaveVideoUrl as Se, clampMarkweaveImageWidth as Ce, createMarkweaveImageUploadRequest as we, createMarkweaveVideoUploadRequest as q, downloadMarkweaveImage as Te, markweaveVideoIframeAllow as Ee, normalizeMarkweaveCoreImageAlign as De, normalizeMarkweaveVideoEmbedUrl as Oe, numberAttribute as ke, stringAttribute as J } from "markweave/internal/plugins/media/core-media-nodes";
7
+ import { getLocalizedSlashCommandSpecs as Ae, getMarkweaveMessages as je, normalizeMarkweaveLang as Me } from "markweave/internal/i18n";
8
+ import { getMarkweaveEditorModeState as Y, isMarkweaveEditorLiveEditable as Ne, normalizeMarkweaveEditorMode as Pe, setMarkweaveEditorModeState as Fe, subscribeToMarkweaveEditorMode as Ie } from "markweave/internal/core/editor-mode-state";
9
9
  import { openMarkweaveImagePreview as Le } from "markweave/internal/plugins/media/image-preview";
10
10
  import { Fragment as X, jsx as Z, jsxs as Q } from "react/jsx-runtime";
11
11
  import { createMarkweaveAdapterMediaExtensions as Re } from "markweave/internal/plugins/media/media-extension-factory";
@@ -15,44 +15,45 @@ import { openMarkweaveReadonlyLinkFromEvent as Ge } from "markweave/internal/edi
15
15
  import { createMarkweaveEditorRuntimeSnapshot as Ke } from "markweave/internal/editor-core/runtime-snapshot";
16
16
  import { advanceFloatingToolbarMotionState as qe, areEditorSelectionSnapshotsEquivalent as Je, calculateFloatingToolbarFrameShift as Ye, calculateFloatingToolbarPopoverPlacement as Xe, calculateFloatingToolbarTopBoundary as Ze, createSelectionSnapshot as Qe, getFloatingToolbarFloatingOptions as $e, getFloatingToolbarState as et, markweaveRuntimeProjectionDelayMs as tt, shouldShowFloatingToolbar as nt, transitionFloatingToolbarState as rt } from "markweave/internal/editor-core/selection-state";
17
17
  import { codeBlockCollapsePluginKey as it, copyActiveCodeBlock as at, getActiveCodeBlockState as ot, getCodeBlockCopyFeedbackSnapshot as st, markweaveCodeBlockBehavior as ct, setCodeBlockCollapsedAtPosition as lt, setCodeBlockLanguageAtPosition as ut, setCodeBlockMermaidPreviewModeAtPosition as dt } from "markweave/internal/plugins/codeblock/codeblock-behavior";
18
- import { isMermaidInlinePreviewTransaction as ft, setMermaidInlinePreviewEditorMode as pt, setReadonlyMermaidPreviewMode as mt } from "markweave/internal/plugins/mermaid/mermaid-inline-preview";
19
- import { getMermaidPreviewState as ht } from "markweave/internal/plugins/mermaid/mermaid-renderer";
20
- import { applyMarkweaveMathLatex as gt, calculateMarkweaveMathPopoverPosition as _t, getMarkweaveMathAnchorRect as vt, getMarkweaveMathBlockIndex as yt, getMarkweaveMathRenderedHtml as bt, getMarkweaveMathTargetAtPos as xt, getMarkweaveMathTargetFromDomEvent as St, getMarkweaveMathTargetFromSelection as Ct, renderMarkweaveMathPreview as wt, setMarkweaveMathEditingDomState as Tt, setMarkweaveMathEditingDomStateInView as Et, setMarkweaveMathSelectionInView as Dt } from "markweave/internal/plugins/math/math-ui-model";
21
- import { filterSlashCommands as Ot, isExecutableSlashCommand as kt } from "markweave/internal/plugins/slash-command/command-spec";
22
- import { getSlashCommandKeyboardAction as At, isSlashCommandMenuState as jt } from "markweave/internal/plugins/slash-command/slash-keyboard";
23
- import { executeSlashCommand as Mt, getNextSlashCommandState as Nt, getSlashCommandAnchoredMenuPosition as Pt, getSlashCommandContext as Ft } from "markweave/internal/plugins/slash-command/slash-runtime";
24
- import { initialSlashCommandState as It, reduceSlashCommandState as Lt } from "markweave/internal/plugins/slash-command/slash-state";
25
- import { getFirstTableDebugSnapshot as Rt } from "markweave/internal/plugins/table/table-debug-snapshot";
26
- import { focusFirstTableBodyCell as zt } from "markweave/internal/plugins/table/table-focus-position";
27
- import { getTableFocusState as Bt } from "markweave/internal/plugins/table/table-focus-state";
28
- import { getTableSelectionOverlayState as Vt, initialTableInteractionState as Ht, tableInteractionPluginKey as Ut } from "markweave/internal/plugins/table/table-interaction-layer";
29
- import { calculateCodeBlockLanguageMenuPosition as Wt, clampFullscreenScale as Gt, codeBlockCopyFeedbackTimeoutMs as Kt, copyCodeBlockText as qt, createCodeBlockOverlayPosition as Jt, createMermaidFullscreenViewerState as Yt, createMermaidTabPosition as Xt, focusCodeBlockTarget as Zt, formatCodeBlockLanguageLabel as Qt, formatFullscreenZoom as $t, getActiveCodeBlockElement as en, getAnchoredRect as tn, getCodeBlockLanguageItems as nn, getCodeBlockPositionFromEventTarget as rn, getCodeBlockStateAtPosition as an, getFrameElement as on, getMermaidCodeBlockTargets as sn, getMermaidSvgMarkup as cn, isCodeBlockTargetCollapsed as ln, mergeStableMermaidTabPositions as un, mermaidFullscreenZoomStep as dn, moveMermaidFullscreenViewer as fn } from "markweave/internal/plugins/codeblock/codeblock-ui-model";
30
- import { BubbleMenu as pn } from "@tiptap/react/menus";
31
- import { createMarkweaveFrameScheduler as mn } from "markweave/internal/editor-core/frame-scheduler";
32
- import { applyFloatingToolbarLink as hn, createFloatingToolbarAssistantRequest as gn, getFloatingToolbarButtonModels as _n, getFloatingToolbarHighlightColorOptions as vn, getFloatingToolbarLinkHref as yn, getFloatingToolbarMessageSet as bn, getFloatingToolbarMoreActions as xn, getFloatingToolbarTextColorOptions as Sn, getFloatingToolbarTooltipModel as Cn, getFloatingToolbarTurnIntoOptions as wn, isFloatingToolbarMoreActionActive as Tn, isFloatingToolbarTurnIntoActive as En, openFloatingToolbarLinkHref as Dn, preventFloatingToolbarPointerFocusLoss as On, removeFloatingToolbarLink as kn, runFloatingToolbarMoreAction as An, setFloatingToolbarHighlightColor as jn, setFloatingToolbarTextColor as Mn, setFloatingToolbarTurnInto as Nn } from "markweave/internal/editor-core/floating-toolbar-model";
33
- import { normalizeMarkdownLinkHref as Pn } from "markweave/internal/plugins/markdown/markdown-input";
34
- import { setMarkweaveTableMenuAxisTarget as Fn } from "markweave/internal/plugins/table/table-clipboard";
35
- import { calculateAnchoredTableMenuPosition as In, calculateTableEdgeHandlePosition as Ln, canRunTableCommand as Rn, executeTableMenuCommand as zn, formatTableCopyFeedback as Bn, getActiveTableElement as Vn, getAvailableCellMenuCommandSpecs as Hn, getTableAxisTargetRect as Un, getTableControlAxisSelectionModel as Wn, getTableEditWithAiRequest as Gn, getTableMenuItemGroup as Kn, getTableMenuItemLabel as qn, getTableMenuItems as Jn, getTableSelectionTargetRect as Yn, measureTableSelectionOverlay as Xn, selectTableAxisFromCell as Zn, tableCopyFeedbackTimeoutMs as Qn, tableMenuLabel as $n } from "markweave/internal/plugins/table/table-ui-model";
36
- import { createMarkweaveTocState as er, emptyMarkweaveTocState as tr, getActiveMarkweaveTocId as nr, getMarkweaveTocItems as rr, getValidMarkweaveTocActiveId as ir, normalizeMarkweaveInnerTocPlacement as ar, observeMarkweaveInnerTocContainerPosition as or, scrollToMarkweaveTocItem as sr } from "markweave/internal/core/toc-state";
18
+ import { isMermaidInlinePreviewTransaction as ft, setMarkweaveMermaidTheme as pt, setMermaidInlinePreviewEditorMode as mt, setReadonlyMermaidPreviewMode as ht } from "markweave/internal/plugins/mermaid/mermaid-inline-preview";
19
+ import { getMermaidPreviewState as gt } from "markweave/internal/plugins/mermaid/mermaid-renderer";
20
+ import { applyMarkweaveMathLatex as _t, calculateMarkweaveMathPopoverPosition as vt, getMarkweaveMathAnchorRect as yt, getMarkweaveMathBlockIndex as bt, getMarkweaveMathRenderedHtml as xt, getMarkweaveMathTargetAtPos as St, getMarkweaveMathTargetFromDomEvent as Ct, getMarkweaveMathTargetFromSelection as wt, renderMarkweaveMathPreview as Tt, setMarkweaveMathEditingDomState as Et, setMarkweaveMathEditingDomStateInView as Dt, setMarkweaveMathSelectionInView as Ot } from "markweave/internal/plugins/math/math-ui-model";
21
+ import { filterSlashCommands as kt, isExecutableSlashCommand as At } from "markweave/internal/plugins/slash-command/command-spec";
22
+ import { getSlashCommandKeyboardAction as jt, isSlashCommandMenuState as Mt } from "markweave/internal/plugins/slash-command/slash-keyboard";
23
+ import { executeSlashCommand as Nt, getNextSlashCommandState as Pt, getSlashCommandAnchoredMenuPosition as Ft, getSlashCommandContext as It } from "markweave/internal/plugins/slash-command/slash-runtime";
24
+ import { initialSlashCommandState as Lt, reduceSlashCommandState as Rt } from "markweave/internal/plugins/slash-command/slash-state";
25
+ import { getFirstTableDebugSnapshot as zt } from "markweave/internal/plugins/table/table-debug-snapshot";
26
+ import { focusFirstTableBodyCell as Bt } from "markweave/internal/plugins/table/table-focus-position";
27
+ import { getTableFocusState as Vt } from "markweave/internal/plugins/table/table-focus-state";
28
+ import { getTableSelectionOverlayState as Ht, initialTableInteractionState as Ut, tableInteractionPluginKey as Wt } from "markweave/internal/plugins/table/table-interaction-layer";
29
+ import { calculateCodeBlockLanguageMenuPosition as Gt, clampFullscreenScale as Kt, codeBlockCopyFeedbackTimeoutMs as qt, copyCodeBlockText as Jt, createCodeBlockOverlayPosition as Yt, createMermaidFullscreenViewerState as Xt, createMermaidTabPosition as Zt, focusCodeBlockTarget as Qt, formatCodeBlockLanguageLabel as $t, formatFullscreenZoom as en, getActiveCodeBlockElement as tn, getAnchoredRect as nn, getCodeBlockLanguageItems as rn, getCodeBlockPositionFromEventTarget as an, getCodeBlockStateAtPosition as on, getFrameElement as sn, getMermaidCodeBlockTargets as cn, getMermaidSvgMarkup as ln, isCodeBlockTargetCollapsed as un, mergeStableMermaidTabPositions as dn, mermaidFullscreenZoomStep as fn, moveMermaidFullscreenViewer as pn } from "markweave/internal/plugins/codeblock/codeblock-ui-model";
30
+ import { BubbleMenu as mn } from "@tiptap/react/menus";
31
+ import { createMarkweaveFrameScheduler as hn } from "markweave/internal/editor-core/frame-scheduler";
32
+ import { applyFloatingToolbarLink as gn, createFloatingToolbarAssistantRequest as _n, getFloatingToolbarButtonModels as vn, getFloatingToolbarHighlightColorOptions as yn, getFloatingToolbarLinkHref as bn, getFloatingToolbarMessageSet as xn, getFloatingToolbarMoreActions as Sn, getFloatingToolbarTextColorOptions as Cn, getFloatingToolbarTooltipModel as wn, getFloatingToolbarTurnIntoOptions as Tn, isFloatingToolbarMoreActionActive as En, isFloatingToolbarTurnIntoActive as Dn, openFloatingToolbarLinkHref as On, preventFloatingToolbarPointerFocusLoss as kn, removeFloatingToolbarLink as An, runFloatingToolbarMoreAction as jn, setFloatingToolbarHighlightColor as Mn, setFloatingToolbarTextColor as Nn, setFloatingToolbarTurnInto as Pn } from "markweave/internal/editor-core/floating-toolbar-model";
33
+ import { normalizeMarkdownLinkHref as Fn } from "markweave/internal/plugins/markdown/markdown-input";
34
+ import { setMarkweaveTableMenuAxisTarget as In } from "markweave/internal/plugins/table/table-clipboard";
35
+ import { calculateAnchoredTableMenuPosition as Ln, calculateTableEdgeHandlePosition as Rn, canRunTableCommand as zn, executeTableMenuCommand as Bn, formatTableCopyFeedback as Vn, getActiveTableElement as Hn, getAvailableCellMenuCommandSpecs as Un, getTableAxisTargetRect as Wn, getTableControlAxisSelectionModel as Gn, getTableEditWithAiRequest as Kn, getTableMenuItemGroup as qn, getTableMenuItemLabel as Jn, getTableMenuItems as Yn, getTableSelectionTargetRect as Xn, measureTableSelectionOverlay as Zn, selectTableAxisFromCell as Qn, tableCopyFeedbackTimeoutMs as $n, tableMenuLabel as er } from "markweave/internal/plugins/table/table-ui-model";
36
+ import { createMarkweaveTocState as tr, emptyMarkweaveTocState as nr, getActiveMarkweaveTocId as rr, getMarkweaveTocItems as ir, getValidMarkweaveTocActiveId as ar, normalizeMarkweaveInnerTocPlacement as or, observeMarkweaveInnerTocContainerPosition as sr, scrollToMarkweaveTocItem as cr } from "markweave/internal/core/toc-state";
37
+ import { normalizeMarkweaveTheme as lr } from "markweave/internal/core/theme";
37
38
  //#region src/editor-mode-state.ts
38
- var cr = {
39
+ var ur = {
39
40
  mode: "live",
40
41
  editable: !0
41
42
  };
42
- function lr(e) {
43
- return he((t) => Ie(e, t), () => Me(e), () => cr);
43
+ function dr(e) {
44
+ return ge((t) => Ie(e, t), () => Y(e), () => ur);
44
45
  }
45
46
  //#endregion
46
47
  //#region src/media/image-node.tsx
47
- var ur = De;
48
- function dr(e) {
48
+ var fr = De;
49
+ function pr(e) {
49
50
  return e instanceof Element && !!e.closest("[data-markweave-image-ui=\"true\"]");
50
51
  }
51
- function fr(e) {
52
- let { deleteNode: t, editor: r, getPos: i, node: a, selected: o, updateAttributes: s } = e, c = e.extension.options, l = c.messages ?? Ae("zh"), u = l.image, d = Ne(lr(r)), f = Y(a.attrs.src), p = ur(a.attrs.align), m = J(a.attrs.width), h = Y(a.attrs.caption), g = W(null), _ = W(null), [v, y] = G(!1), [b, x] = G(!1), [ee, C] = G(!1), [w, T] = G(""), [E, D] = G(null), [O, k] = G(!1), [A, j] = G(!!h), [M, N] = G(h ?? ""), P = d && (!f || b), F = () => {
52
+ function mr(e) {
53
+ let { deleteNode: t, editor: r, getPos: i, node: a, selected: o, updateAttributes: s } = e, c = e.extension.options, l = c.messages ?? je("zh"), u = l.image, d = Ne(dr(r)), f = J(a.attrs.src), p = fr(a.attrs.align), m = ke(a.attrs.width), h = J(a.attrs.caption), g = U(null), _ = U(null), [v, y] = W(!1), [b, x] = W(!1), [C, w] = W(!1), [T, E] = W(""), [D, O] = W(null), [ee, k] = W(!1), [A, j] = W(!!h), [te, M] = W(h ?? ""), N = d && (!f || b), ne = () => {
53
54
  f && Le({
54
55
  src: f,
55
- alt: Y(a.attrs.alt) ?? "",
56
+ alt: J(a.attrs.alt) ?? "",
56
57
  messages: {
57
58
  dialogAriaLabel: u.previewDialogAriaLabel,
58
59
  zoomOut: u.previewZoomOut,
@@ -62,63 +63,63 @@ function fr(e) {
62
63
  }
63
64
  });
64
65
  };
65
- H(() => {
66
- A || N(h ?? "");
66
+ V(() => {
67
+ A || M(h ?? "");
67
68
  }, [h, A]);
68
- let te = () => {
69
+ let P = () => {
69
70
  if (!d) return;
70
71
  let e = i();
71
72
  typeof e == "number" && r.chain().focus().setNodeSelection(e).run();
72
- }, I = () => {
73
+ }, F = () => {
73
74
  if (d) {
74
- if (T(""), D(null), C(!1), f) {
75
+ if (E(""), O(null), w(!1), f) {
75
76
  x(!1);
76
77
  return;
77
78
  }
78
79
  t();
79
80
  }
80
- }, L = async (e) => {
81
+ }, I = async (e) => {
81
82
  if (d) {
82
- D(null), k(!0);
83
+ O(null), k(!0);
83
84
  try {
84
- let t = await ve(Ce(e, f && b ? "image-replace" : "image-insert"), c.onUpload);
85
- s(be(a.attrs, t)), x(!1), T("");
85
+ let t = await G(we(e, f && b ? "image-replace" : "image-insert"), c.onUpload);
86
+ s(K(a.attrs, t)), x(!1), E("");
86
87
  } catch (e) {
87
- D(e instanceof Error ? e.message : u.uploadFailedError);
88
+ O(e instanceof Error ? e.message : u.uploadFailedError);
88
89
  } finally {
89
- k(!1), C(!1);
90
+ k(!1), w(!1);
90
91
  }
91
92
  }
92
- }, ne = () => {
93
+ }, re = () => {
93
94
  if (d) {
94
- if (!w.trim()) {
95
- D(u.uploadRequiredError);
95
+ if (!T.trim()) {
96
+ O(u.uploadRequiredError);
96
97
  return;
97
98
  }
98
- L(ge(w));
99
+ I(_e(T));
99
100
  }
100
- }, R = (e) => {
101
- !d || !e || L({
101
+ }, L = (e) => {
102
+ !d || !e || I({
102
103
  type: "file",
103
104
  file: e,
104
105
  mimeType: e.type
105
106
  });
106
- }, z = (e) => {
107
- R(e.currentTarget.files?.[0] ?? null), e.currentTarget.value = "";
108
- }, re = (e) => {
109
- e.preventDefault(), e.stopPropagation(), d && R(e.dataTransfer.files?.[0] ?? null);
110
- }, ie = () => {
111
- d && (j((e) => !e), A || N(h ?? ""));
112
- }, ae = (e) => {
113
- d && (N(e), s({ caption: e.trim() ? e : null }));
114
- }, oe = (e, t) => {
107
+ }, R = (e) => {
108
+ L(e.currentTarget.files?.[0] ?? null), e.currentTarget.value = "";
109
+ }, ie = (e) => {
110
+ e.preventDefault(), e.stopPropagation(), d && L(e.dataTransfer.files?.[0] ?? null);
111
+ }, ae = () => {
112
+ d && (j((e) => !e), A || M(h ?? ""));
113
+ }, oe = (e) => {
114
+ d && (M(e), s({ caption: e.trim() ? e : null }));
115
+ }, z = (e, t) => {
115
116
  if (t.preventDefault(), t.stopPropagation(), !d) return;
116
- te();
117
+ P();
117
118
  let n = g.current;
118
119
  if (!n) return;
119
120
  let r = t.clientX, i = n.getBoundingClientRect().width || m || 320, a = n.closest(".markweave-editor-surface")?.getBoundingClientRect().width ?? n.parentElement?.getBoundingClientRect().width ?? i, o = (t) => {
120
121
  let n = e === "right" ? t.clientX - r : r - t.clientX;
121
- s({ width: q(i + n, a) });
122
+ s({ width: Ce(i + n, a) });
122
123
  }, c = () => {
123
124
  window.removeEventListener("pointermove", o), window.removeEventListener("pointerup", c);
124
125
  };
@@ -131,39 +132,39 @@ function fr(e) {
131
132
  "data-align": p,
132
133
  "data-selected": d && o ? "true" : "false",
133
134
  "data-hovered": v ? "true" : "false",
134
- "data-empty": P ? "true" : "false",
135
+ "data-empty": N ? "true" : "false",
135
136
  onPointerEnter: () => y(!0),
136
137
  onPointerLeave: () => y(!1),
137
138
  onMouseDown: (e) => {
138
- d && !dr(e.target) && te();
139
+ d && !pr(e.target) && P();
139
140
  },
140
- children: P ? /* @__PURE__ */ Z(pr, {
141
- dragActive: ee,
142
- error: E,
143
- inputValue: w,
144
- isSubmitting: O,
141
+ children: N ? /* @__PURE__ */ Z(hr, {
142
+ dragActive: C,
143
+ error: D,
144
+ inputValue: T,
145
+ isSubmitting: ee,
145
146
  fileInputRef: _,
146
147
  messages: l,
147
- onCancel: I,
148
- onDrop: re,
149
- onDragActiveChange: C,
150
- onFileChange: z,
151
- onInputChange: T,
152
- onSubmit: ne
148
+ onCancel: F,
149
+ onDrop: ie,
150
+ onDragActiveChange: w,
151
+ onFileChange: R,
152
+ onInputChange: E,
153
+ onSubmit: re
153
154
  }) : /* @__PURE__ */ Q(X, { children: [
154
- d ? /* @__PURE__ */ Z(mr, {
155
+ d ? /* @__PURE__ */ Z(gr, {
155
156
  align: p,
156
157
  captionActive: A || !!h,
157
158
  messages: l,
158
159
  onAlign: (e) => s({ align: e }),
159
- onCaption: ie,
160
+ onCaption: ae,
160
161
  onDelete: t,
161
162
  onDownload: () => {
162
163
  f && Te(f);
163
164
  },
164
- onPreview: F,
165
+ onPreview: ne,
165
166
  onReplace: () => {
166
- T(""), D(null), x(!0);
167
+ E(""), O(null), x(!0);
167
168
  }
168
169
  }) : null,
169
170
  /* @__PURE__ */ Q("div", {
@@ -174,8 +175,8 @@ function fr(e) {
174
175
  f ? /* @__PURE__ */ Z("img", {
175
176
  className: "markweave-image",
176
177
  src: f,
177
- alt: Y(a.attrs.alt) ?? "",
178
- title: Y(a.attrs.title) ?? void 0,
178
+ alt: J(a.attrs.alt) ?? "",
179
+ title: J(a.attrs.title) ?? void 0,
179
180
  draggable: !1
180
181
  }) : /* @__PURE__ */ Z("div", {
181
182
  className: "markweave-image-readonly-empty",
@@ -190,7 +191,7 @@ function fr(e) {
190
191
  "aria-label": u.preview,
191
192
  title: u.preview,
192
193
  onMouseDown: (e) => e.preventDefault(),
193
- onClick: F,
194
+ onClick: ne,
194
195
  children: [/* @__PURE__ */ Z(S, {
195
196
  size: 16,
196
197
  strokeWidth: 1.8
@@ -200,15 +201,15 @@ function fr(e) {
200
201
  children: u.preview
201
202
  })]
202
203
  }) : null,
203
- d ? /* @__PURE__ */ Z(gr, {
204
+ d ? /* @__PURE__ */ Z(vr, {
204
205
  side: "left",
205
206
  messages: l,
206
- onPointerDown: oe
207
+ onPointerDown: z
207
208
  }) : null,
208
- d ? /* @__PURE__ */ Z(gr, {
209
+ d ? /* @__PURE__ */ Z(vr, {
209
210
  side: "right",
210
211
  messages: l,
211
- onPointerDown: oe
212
+ onPointerDown: z
212
213
  }) : null
213
214
  ]
214
215
  }),
@@ -216,10 +217,10 @@ function fr(e) {
216
217
  className: "markweave-image-caption-input",
217
218
  "data-markweave-image-ui": "true",
218
219
  "data-testid": "markweave-image-caption-input",
219
- value: M,
220
+ value: te,
220
221
  placeholder: u.captionPlaceholder,
221
222
  "aria-label": u.captionAriaLabel,
222
- onChange: (e) => ae(e.currentTarget.value),
223
+ onChange: (e) => oe(e.currentTarget.value),
223
224
  onKeyDown: (e) => {
224
225
  e.key === "Escape" && (e.preventDefault(), j(!1));
225
226
  }
@@ -231,7 +232,7 @@ function fr(e) {
231
232
  ] })
232
233
  });
233
234
  }
234
- function pr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitting: i, messages: a, onCancel: o, onDragActiveChange: s, onDrop: c, onFileChange: l, onInputChange: u, onSubmit: d }) {
235
+ function hr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitting: i, messages: a, onCancel: o, onDragActiveChange: s, onDrop: c, onFileChange: l, onInputChange: u, onSubmit: d }) {
235
236
  let f = a.image;
236
237
  return /* @__PURE__ */ Q("section", {
237
238
  className: "markweave-image-upload-placeholder",
@@ -258,7 +259,7 @@ function pr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
258
259
  /* @__PURE__ */ Z("div", {
259
260
  className: "markweave-image-upload-icon",
260
261
  "aria-hidden": "true",
261
- children: /* @__PURE__ */ Z(E, {
262
+ children: /* @__PURE__ */ Z(D, {
262
263
  size: 46,
263
264
  strokeWidth: 1.6
264
265
  })
@@ -293,7 +294,7 @@ function pr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
293
294
  "data-testid": "markweave-image-upload-submit",
294
295
  disabled: i || !r.trim(),
295
296
  onClick: d,
296
- children: [/* @__PURE__ */ Z(E, {
297
+ children: [/* @__PURE__ */ Z(D, {
297
298
  size: 16,
298
299
  strokeWidth: 1.8
299
300
  }), a.common.insert]
@@ -313,7 +314,7 @@ function pr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
313
314
  ]
314
315
  });
315
316
  }
316
- function mr({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i, onDelete: a, onDownload: s, onPreview: u, onReplace: d }) {
317
+ function gr({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i, onDelete: a, onDownload: s, onPreview: u, onReplace: d }) {
317
318
  let p = n.image;
318
319
  return /* @__PURE__ */ Q("div", {
319
320
  className: "markweave-image-toolbar",
@@ -321,21 +322,21 @@ function mr({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i,
321
322
  "data-markweave-image-ui": "true",
322
323
  "aria-label": p.toolsAriaLabel,
323
324
  children: [
324
- /* @__PURE__ */ Z(hr, {
325
+ /* @__PURE__ */ Z(_r, {
325
326
  testId: "markweave-image-align-left",
326
327
  label: p.alignLeft,
327
328
  icon: c,
328
329
  active: e === "left",
329
330
  onClick: () => r("left")
330
331
  }),
331
- /* @__PURE__ */ Z(hr, {
332
+ /* @__PURE__ */ Z(_r, {
332
333
  testId: "markweave-image-align-center",
333
334
  label: p.alignCenter,
334
335
  icon: o,
335
336
  active: e === "center",
336
337
  onClick: () => r("center")
337
338
  }),
338
- /* @__PURE__ */ Z(hr, {
339
+ /* @__PURE__ */ Z(_r, {
339
340
  testId: "markweave-image-align-right",
340
341
  label: p.alignRight,
341
342
  icon: l,
@@ -346,36 +347,36 @@ function mr({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i,
346
347
  className: "markweave-image-toolbar-divider",
347
348
  "aria-hidden": "true"
348
349
  }),
349
- /* @__PURE__ */ Z(hr, {
350
+ /* @__PURE__ */ Z(_r, {
350
351
  testId: "markweave-image-caption",
351
352
  label: p.caption,
352
353
  icon: f,
353
354
  active: t,
354
355
  onClick: i
355
356
  }),
356
- /* @__PURE__ */ Z(hr, {
357
+ /* @__PURE__ */ Z(_r, {
357
358
  testId: "markweave-image-preview",
358
359
  label: p.preview,
359
360
  icon: S,
360
361
  onClick: u
361
362
  }),
362
- /* @__PURE__ */ Z(hr, {
363
+ /* @__PURE__ */ Z(_r, {
363
364
  testId: "markweave-image-download",
364
365
  label: p.download,
365
366
  icon: b,
366
367
  onClick: s
367
368
  }),
368
- /* @__PURE__ */ Z(hr, {
369
+ /* @__PURE__ */ Z(_r, {
369
370
  testId: "markweave-image-replace",
370
371
  label: p.replace,
371
- icon: R,
372
+ icon: L,
372
373
  onClick: d
373
374
  }),
374
375
  /* @__PURE__ */ Z("span", {
375
376
  className: "markweave-image-toolbar-divider",
376
377
  "aria-hidden": "true"
377
378
  }),
378
- /* @__PURE__ */ Z(hr, {
379
+ /* @__PURE__ */ Z(_r, {
379
380
  testId: "markweave-image-delete",
380
381
  label: p.delete,
381
382
  icon: ue,
@@ -384,7 +385,7 @@ function mr({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i,
384
385
  ]
385
386
  });
386
387
  }
387
- function hr({ active: e = !1, icon: t, label: n, onClick: r, testId: i }) {
388
+ function _r({ active: e = !1, icon: t, label: n, onClick: r, testId: i }) {
388
389
  return /* @__PURE__ */ Q("button", {
389
390
  type: "button",
390
391
  "aria-label": n,
@@ -403,7 +404,7 @@ function hr({ active: e = !1, icon: t, label: n, onClick: r, testId: i }) {
403
404
  })]
404
405
  });
405
406
  }
406
- function gr({ messages: e, onPointerDown: t, side: n }) {
407
+ function vr({ messages: e, onPointerDown: t, side: n }) {
407
408
  return /* @__PURE__ */ Z("button", {
408
409
  type: "button",
409
410
  className: "markweave-image-resize-handle",
@@ -414,61 +415,61 @@ function gr({ messages: e, onPointerDown: t, side: n }) {
414
415
  onPointerDown: (e) => t(n, e)
415
416
  });
416
417
  }
417
- var _r = K.extend({
418
+ var yr = ye.extend({
418
419
  addOptions() {
419
420
  return {
420
421
  ...this.parent?.(),
421
- messages: Ae("zh"),
422
+ messages: je("zh"),
422
423
  onUpload: void 0
423
424
  };
424
425
  },
425
426
  addNodeView() {
426
- return typeof document > "u" ? null : r(fr, { stopEvent: ({ event: e }) => dr(e.target) });
427
+ return typeof document > "u" ? null : r(mr, { stopEvent: ({ event: e }) => pr(e.target) });
427
428
  }
428
429
  });
429
430
  //#endregion
430
431
  //#region src/media/video-node.tsx
431
- function vr(e) {
432
+ function br(e) {
432
433
  return e instanceof Element && !!e.closest("[data-markweave-video-ui=\"true\"], iframe[data-markweave-video-embed], video[data-markweave-video]");
433
434
  }
434
- function yr(e) {
435
- let { deleteNode: t, editor: r, getPos: i, node: a, selected: o, updateAttributes: s } = e, c = e.extension.options, l = c.messages ?? Ae("zh"), u = l.video, d = Ne(lr(r)), f = Y(a.attrs.src), p = Y(a.attrs.embedUrl), m = Y(a.attrs.provider), h = p ? Oe(p, m) : null, g = Y(a.attrs.mimeType), _ = Y(a.attrs.title), v = W(null), [y, b] = G(!1), [x, S] = G(""), [ee, C] = G(null), [w, T] = G(!1), E = d && !f, D = () => {
435
+ function xr(e) {
436
+ let { deleteNode: t, editor: r, getPos: i, node: a, selected: o, updateAttributes: s } = e, c = e.extension.options, l = c.messages ?? je("zh"), u = l.video, d = Ne(dr(r)), f = J(a.attrs.src), p = J(a.attrs.embedUrl), m = J(a.attrs.provider), h = p ? Oe(p, m) : null, g = J(a.attrs.mimeType), _ = J(a.attrs.title), v = U(null), [y, b] = W(!1), [x, S] = W(""), [C, w] = W(null), [T, E] = W(!1), D = d && !f, O = () => {
436
437
  if (!d) return;
437
438
  let e = i();
438
439
  typeof e == "number" && r.chain().focus().setNodeSelection(e).run();
439
- }, O = (e) => {
440
- d && (vr(e.target) || (e.preventDefault(), D()));
440
+ }, ee = (e) => {
441
+ d && (br(e.target) || (e.preventDefault(), O()));
441
442
  }, k = (e) => {
442
443
  d && (e.key === "Delete" || e.key === "Backspace") && o && (e.preventDefault(), t());
443
444
  }, A = async (e) => {
444
445
  if (!(!d || !e)) {
445
- C(null), T(!0);
446
+ w(null), E(!0);
446
447
  try {
447
- let t = await ve(we({
448
+ let t = await G(q({
448
449
  type: "file",
449
450
  file: e,
450
451
  mimeType: e.type
451
452
  }), c.onUpload);
452
453
  s(xe(t)), S("");
453
454
  } catch (e) {
454
- C(e instanceof Error ? e.message : u.uploadFailedError);
455
+ w(e instanceof Error ? e.message : u.uploadFailedError);
455
456
  } finally {
456
- T(!1), b(!1);
457
+ E(!1), b(!1);
457
458
  }
458
459
  }
459
460
  };
460
- return E ? /* @__PURE__ */ Z(n, {
461
+ return D ? /* @__PURE__ */ Z(n, {
461
462
  as: "figure",
462
463
  className: "markweave-video-node",
463
464
  "data-testid": "markweave-video-node",
464
465
  "data-empty": "true",
465
466
  "data-selected": "false",
466
- children: /* @__PURE__ */ Z(br, {
467
+ children: /* @__PURE__ */ Z(Sr, {
467
468
  dragActive: y,
468
- error: ee,
469
+ error: C,
469
470
  fileInputRef: v,
470
471
  inputValue: x,
471
- isSubmitting: w,
472
+ isSubmitting: T,
472
473
  messages: l,
473
474
  onCancel: t,
474
475
  onDragActiveChange: b,
@@ -483,10 +484,10 @@ function yr(e) {
483
484
  if (!d) return;
484
485
  let e = Se(x);
485
486
  if (!e) {
486
- C(u.unsupportedUrlError);
487
+ w(u.unsupportedUrlError);
487
488
  return;
488
489
  }
489
- C(null), s(e), S("");
490
+ w(null), s(e), S("");
490
491
  }
491
492
  })
492
493
  }) : /* @__PURE__ */ Z(n, {
@@ -498,9 +499,9 @@ function yr(e) {
498
499
  "data-selected": d && o ? "true" : "false",
499
500
  tabIndex: d ? 0 : void 0,
500
501
  "aria-label": u.nodeAriaLabel,
501
- onFocus: D,
502
+ onFocus: O,
502
503
  onKeyDown: k,
503
- onMouseDown: O,
504
+ onMouseDown: ee,
504
505
  children: h ? /* @__PURE__ */ Q("div", {
505
506
  className: "markweave-video-embed",
506
507
  children: [/* @__PURE__ */ Z("iframe", {
@@ -544,7 +545,7 @@ function yr(e) {
544
545
  })
545
546
  });
546
547
  }
547
- function br({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitting: i, messages: a, onCancel: o, onDragActiveChange: s, onDrop: c, onFileChange: l, onInputChange: u, onSubmit: d }) {
548
+ function Sr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitting: i, messages: a, onCancel: o, onDragActiveChange: s, onDrop: c, onFileChange: l, onInputChange: u, onSubmit: d }) {
548
549
  let f = a.video;
549
550
  return /* @__PURE__ */ Q("section", {
550
551
  className: "markweave-video-upload-placeholder",
@@ -571,7 +572,7 @@ function br({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
571
572
  /* @__PURE__ */ Z("div", {
572
573
  className: "markweave-video-upload-icon",
573
574
  "aria-hidden": "true",
574
- children: /* @__PURE__ */ Z(B, {
575
+ children: /* @__PURE__ */ Z(me, {
575
576
  size: 46,
576
577
  strokeWidth: 1.6
577
578
  })
@@ -626,26 +627,26 @@ function br({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
626
627
  ]
627
628
  });
628
629
  }
629
- var xr = ye.extend({
630
+ var Cr = be.extend({
630
631
  addOptions() {
631
632
  return {
632
633
  ...this.parent?.(),
633
- messages: Ae("zh"),
634
+ messages: je("zh"),
634
635
  onUpload: void 0
635
636
  };
636
637
  },
637
638
  addNodeView() {
638
- return typeof document > "u" ? null : r(yr, { stopEvent: ({ event: e }) => vr(e.target) });
639
+ return typeof document > "u" ? null : r(xr, { stopEvent: ({ event: e }) => br(e.target) });
639
640
  }
640
641
  });
641
642
  //#endregion
642
643
  //#region src/create-editor-extensions.ts
643
- function Sr(t = {}) {
644
+ function wr(t = {}) {
644
645
  return e({
645
646
  lang: t.lang,
646
647
  mediaExtensions: Re({
647
- image: _r,
648
- video: xr,
648
+ image: yr,
649
+ video: Cr,
649
650
  lang: t.lang,
650
651
  onImageUpload: t.onImageUpload,
651
652
  onVideoUpload: t.onVideoUpload
@@ -654,7 +655,7 @@ function Sr(t = {}) {
654
655
  }
655
656
  //#endregion
656
657
  //#region src/ui/codeblock/CodeBlockControls.tsx
657
- function Cr(e) {
658
+ function Tr(e) {
658
659
  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", {
659
660
  cx: "10",
660
661
  cy: "10",
@@ -691,7 +692,7 @@ function Cr(e) {
691
692
  /* @__PURE__ */ Z("path", { d: "m14 14 4 4" })
692
693
  ] }) : 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" });
693
694
  }
694
- function wr({ icon: e }) {
695
+ function Er({ icon: e }) {
695
696
  return /* @__PURE__ */ Z("svg", {
696
697
  viewBox: "0 0 24 24",
697
698
  "aria-hidden": "true",
@@ -702,50 +703,50 @@ function wr({ icon: e }) {
702
703
  strokeLinecap: "round",
703
704
  strokeLinejoin: "round",
704
705
  strokeWidth: "1.8",
705
- children: Cr(e)
706
+ children: Tr(e)
706
707
  })
707
708
  });
708
709
  }
709
- function Tr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, readOnly: i = !1 }) {
710
- let a = W(null), o = W(null), s = W(null), c = W({
710
+ function Dr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, readOnly: i = !1 }) {
711
+ let a = U(null), o = U(null), s = U(null), c = U({
711
712
  active: !1,
712
713
  lastX: 0,
713
714
  lastY: 0
714
- }), [l, u] = G(null), [d, f] = G(null), [p, m] = G([]), [h, g] = G(null), [_, v] = G(!1), [y, b] = G(""), [x, S] = G(null), [ee, C] = G(!1), [w, T] = G(null), [E, D] = G(null), [O, k] = G(!1), [A, j] = G(0), [M, N] = G(0), P = ot(t), F = an(t, l), te = !i && e && P.active && P.pos !== null ? {
715
- ...P,
716
- pos: P.pos,
715
+ }), [l, u] = W(null), [d, f] = W(null), [p, m] = W([]), [h, g] = W(null), [_, v] = W(!1), [y, b] = W(""), [x, S] = W(null), [C, w] = W(!1), [T, E] = W(null), [D, O] = W(null), [ee, k] = W(!1), [A, j] = W(0), [te, M] = W(0), N = ot(t), ne = on(t, l), P = !i && e && N.active && N.pos !== null ? {
716
+ ...N,
717
+ pos: N.pos,
717
718
  active: !0
718
- } : null, I = F ?? te, L = I !== null, ne = I?.language === "mermaid", R = ln(t, I), z = L && I !== null && !R, re = !i, ie = Qt(I ? I.language : "text"), ae = x?.status ?? "idle", oe = I?.mermaidPreviewMode ?? n, se = ne && oe === "preview", ce = sn(t), le = `${M}|${ce.map((e) => `${e.pos}:${e.mermaidPreviewMode}:${e.text.length}`).join("|")}`, ue = U(() => nn(y.trim().toLowerCase()), [y]);
719
- if (H(() => {
719
+ } : null, F = ne ?? P, I = F !== null, re = F?.language === "mermaid", L = un(t, F), R = I && F !== null && !L, ie = !i, ae = $t(F ? F.language : "text"), oe = x?.status ?? "idle", z = F?.mermaidPreviewMode ?? n, se = re && z === "preview", ce = cn(t), le = `${te}|${ce.map((e) => `${e.pos}:${e.mermaidPreviewMode}:${e.text.length}`).join("|")}`, ue = H(() => rn(y.trim().toLowerCase()), [y]);
720
+ if (V(() => {
720
721
  i && (v(!1), b(""));
721
- }, [i]), H(() => {
722
+ }, [i]), V(() => {
722
723
  if (!x) return;
723
724
  let e = window.setTimeout(() => {
724
725
  S(null);
725
- }, Kt);
726
+ }, qt);
726
727
  return () => {
727
728
  window.clearTimeout(e);
728
729
  };
729
- }, [x]), H(() => {
730
- S(null), v(!1), b(""), T(null), D(null), k(!1);
730
+ }, [x]), V(() => {
731
+ S(null), v(!1), b(""), E(null), O(null), k(!1);
731
732
  }, [
732
733
  e,
733
- I?.language,
734
- I?.pos,
735
- I?.text
736
- ]), H(() => {
734
+ F?.language,
735
+ F?.pos,
736
+ F?.text
737
+ ]), V(() => {
737
738
  let e = ({ transaction: e }) => {
738
739
  e.getMeta(it) && j((e) => e + 1);
739
740
  };
740
741
  return t.on("transaction", e), () => {
741
742
  t.off("transaction", e);
742
743
  };
743
- }, [t]), H(() => {
744
+ }, [t]), V(() => {
744
745
  let e = t.view.dom.closest(".markweave-editor-frame");
745
746
  if (!e) return;
746
747
  let n = (e) => {
747
748
  if (e.target instanceof Node && a.current?.contains(e.target) || _) return;
748
- let n = an(t, rn(t, e.target)), r = n && !ln(t, n) ? n.pos : null;
749
+ let n = on(t, an(t, e.target)), r = n && !un(t, n) ? n.pos : null;
749
750
  u((e) => e === r ? e : r);
750
751
  }, r = () => {
751
752
  _ || u(null);
@@ -753,12 +754,12 @@ function Tr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
753
754
  return e.addEventListener("mousemove", n), e.addEventListener("mouseleave", r), () => {
754
755
  e.removeEventListener("mousemove", n), e.removeEventListener("mouseleave", r);
755
756
  };
756
- }, [t, _]), H(() => {
757
+ }, [t, _]), V(() => {
757
758
  _ && s.current?.focus({ preventScroll: !0 });
758
- }, [_]), H(() => {
759
- if (!w) return;
759
+ }, [_]), V(() => {
760
+ if (!T) return;
760
761
  let e = (e) => {
761
- e.key === "Escape" && (T(null), D(null), k(!1), c.current = {
762
+ e.key === "Escape" && (E(null), O(null), k(!1), c.current = {
762
763
  active: !1,
763
764
  lastX: 0,
764
765
  lastY: 0
@@ -767,8 +768,8 @@ function Tr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
767
768
  return document.addEventListener("keydown", e), () => {
768
769
  document.removeEventListener("keydown", e);
769
770
  };
770
- }, [t, w]), H(() => {
771
- if (!L || !_) return;
771
+ }, [t, T]), V(() => {
772
+ if (!I || !_) return;
772
773
  let e = (e) => {
773
774
  e.key === "Escape" && (v(!1), t.view.focus());
774
775
  }, n = (e) => {
@@ -778,22 +779,22 @@ function Tr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
778
779
  document.removeEventListener("keydown", e), document.removeEventListener("mousedown", n);
779
780
  };
780
781
  }, [
781
- L,
782
+ I,
782
783
  t,
783
784
  _
784
- ]), me(() => {
785
+ ]), he(() => {
785
786
  let e = () => {
786
787
  let e = a.current;
787
788
  if (!e) return;
788
- if (!on(e) || ce.length === 0) {
789
+ if (!sn(e) || ce.length === 0) {
789
790
  m([]);
790
791
  return;
791
792
  }
792
793
  let n = e.getBoundingClientRect(), r = ce.flatMap((e) => {
793
- let r = tn(en(t, e.pos, e.mermaidPreviewMode), n);
794
- return r ? [Xt(e, r, n)] : [];
794
+ let r = nn(tn(t, e.pos, e.mermaidPreviewMode), n);
795
+ return r ? [Zt(e, r, n)] : [];
795
796
  });
796
- m((e) => un(e, r, ce.map((e) => e.pos)));
797
+ m((e) => dn(e, r, ce.map((e) => e.pos)));
797
798
  };
798
799
  e();
799
800
  let n = window.requestAnimationFrame(e);
@@ -804,23 +805,23 @@ function Tr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
804
805
  A,
805
806
  t,
806
807
  le
807
- ]), me(() => {
808
- if (!z || !I) {
808
+ ]), he(() => {
809
+ if (!R || !F) {
809
810
  f(null), g(null);
810
811
  return;
811
812
  }
812
813
  let e = () => {
813
814
  let e = a.current;
814
815
  if (!e) return;
815
- let n = en(t, I.pos, oe), r = e.getBoundingClientRect(), i = tn(n, r);
816
+ let n = tn(t, F.pos, z), r = e.getBoundingClientRect(), i = nn(n, r);
816
817
  if (!i) {
817
- f((e) => e?.pos === I.pos ? e : null), g((e) => _ ? e : null);
818
+ f((e) => e?.pos === F.pos ? e : null), g((e) => _ ? e : null);
818
819
  return;
819
820
  }
820
- let s = Jt(I.pos, i, r);
821
+ let s = Yt(F.pos, i, r);
821
822
  if (f(s), _ && o.current) {
822
823
  let e = o.current.getBoundingClientRect();
823
- g(Wt({
824
+ g(Gt({
824
825
  overlayRect: r,
825
826
  buttonRect: e,
826
827
  windowWidth: window.innerWidth,
@@ -832,73 +833,73 @@ function Tr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
832
833
  window.removeEventListener("resize", e), window.removeEventListener("scroll", e, !0);
833
834
  };
834
835
  }, [
835
- z,
836
+ R,
836
837
  A,
837
- I?.pos,
838
+ F?.pos,
838
839
  t,
839
840
  _,
840
- oe
841
- ]), !z && ce.length === 0 && !w) return null;
841
+ z
842
+ ]), !R && ce.length === 0 && !T) return null;
842
843
  let de = d ? {
843
844
  top: d.top,
844
845
  right: d.right
845
846
  } : void 0, fe = async () => {
846
847
  if (i) {
847
- if (!I) return;
848
- let e = await qt(I.text);
849
- S(st(I, e ? "copied" : "failed"));
848
+ if (!F) return;
849
+ let e = await Jt(F.text);
850
+ S(st(F, e ? "copied" : "failed"));
850
851
  return;
851
852
  }
852
- if (!Zt(t, I)) return;
853
+ if (!Qt(t, F)) return;
853
854
  let e = await at(t);
854
855
  S(st(ot(t), e ? "copied" : "failed")), t.view.focus();
855
856
  }, pe = (e, n) => {
856
857
  if (i) {
857
- mt(t, e.pos, n) && N((e) => e + 1);
858
+ ht(t, e.pos, n) && M((e) => e + 1);
858
859
  return;
859
860
  }
860
- let a = P.active && P.pos === e.pos;
861
- dt(t, e.pos, n) && (r(n), N((e) => e + 1), a && t.view.focus());
862
- }, B = (e) => {
863
- if (i || !I) return;
864
- let n = P.active && P.pos === I.pos;
865
- ut(t, I.pos, e) && (e === "mermaid" && dt(t, I.pos, "preview") && r("preview"), v(!1), b(""), N((e) => e + 1), n && t.view.focus());
866
- }, V = () => {
867
- i || !I || lt(t, I.pos, !R) && (j((e) => e + 1), u(null));
868
- }, he = () => {
869
- if (!I) return;
870
- let e = cn(t, I.pos);
861
+ let a = N.active && N.pos === e.pos;
862
+ dt(t, e.pos, n) && (r(n), M((e) => e + 1), a && t.view.focus());
863
+ }, me = (e) => {
864
+ if (i || !F) return;
865
+ let n = N.active && N.pos === F.pos;
866
+ ut(t, F.pos, e) && (e === "mermaid" && dt(t, F.pos, "preview") && r("preview"), v(!1), b(""), M((e) => e + 1), n && t.view.focus());
867
+ }, B = () => {
868
+ i || !F || lt(t, F.pos, !L) && (j((e) => e + 1), u(null));
869
+ }, ge = () => {
870
+ if (!F) return;
871
+ let e = ln(t, F.pos);
871
872
  if (!e) return;
872
873
  let n = new Blob([e], { type: "image/svg+xml" }), r = URL.createObjectURL(n), i = document.createElement("a");
873
874
  i.href = r, i.download = "markweave-mermaid.svg", i.click(), URL.revokeObjectURL(r), t.view.focus();
874
- }, ge = () => {
875
- if (!I) return;
876
- let e = cn(t, I.pos);
877
- e && (T(Yt(e)), D(null), k(!1), c.current = {
875
+ }, _e = () => {
876
+ if (!F) return;
877
+ let e = ln(t, F.pos);
878
+ e && (E(Xt(e)), O(null), k(!1), c.current = {
878
879
  active: !1,
879
880
  lastX: 0,
880
881
  lastY: 0
881
882
  });
882
- }, _e = () => {
883
- T(null), D(null), k(!1), c.current = {
883
+ }, ve = () => {
884
+ E(null), O(null), k(!1), c.current = {
884
885
  active: !1,
885
886
  lastX: 0,
886
887
  lastY: 0
887
888
  }, t.view.focus();
888
- }, ve = (e) => {
889
- T((t) => t && {
889
+ }, G = (e) => {
890
+ E((t) => t && {
890
891
  ...t,
891
- scale: Gt(t.scale + e)
892
+ scale: Kt(t.scale + e)
892
893
  });
893
- }, K = () => {
894
- T((e) => e && Yt(e.svg)), c.current = {
894
+ }, ye = () => {
895
+ E((e) => e && Xt(e.svg)), c.current = {
895
896
  active: !1,
896
897
  lastX: 0,
897
898
  lastY: 0
898
899
  }, k(!1);
899
- }, ye = (e) => {
900
- e.preventDefault(), ve(e.deltaY < 0 ? dn : -dn);
901
900
  }, be = (e) => {
901
+ e.preventDefault(), G(e.deltaY < 0 ? fn : -fn);
902
+ }, K = (e) => {
902
903
  e.button === 0 && (e.preventDefault(), c.current = {
903
904
  active: !0,
904
905
  lastX: e.clientX,
@@ -912,7 +913,7 @@ function Tr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
912
913
  active: !0,
913
914
  lastX: e.clientX,
914
915
  lastY: e.clientY
915
- }, T((e) => fn(e, n, r));
916
+ }, E((e) => pn(e, n, r));
916
917
  }, Se = () => {
917
918
  c.current = {
918
919
  active: !1,
@@ -947,11 +948,11 @@ function Tr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
947
948
  }, t))
948
949
  }, e.pos);
949
950
  }),
950
- z ? /* @__PURE__ */ Q("div", {
951
+ R ? /* @__PURE__ */ Q("div", {
951
952
  className: "markweave-codeblock-controls",
952
953
  "data-testid": "markweave-codeblock-controls",
953
954
  "data-positioned": d ? "true" : "false",
954
- "data-collapsed": R ? "true" : "false",
955
+ "data-collapsed": L ? "true" : "false",
955
956
  "data-read-only": i ? "true" : "false",
956
957
  "aria-label": "Code block controls",
957
958
  style: de,
@@ -960,7 +961,7 @@ function Tr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
960
961
  className: "markweave-codeblock-language-button markweave-codeblock-language-label",
961
962
  "aria-label": "Code block language",
962
963
  "data-testid": "markweave-codeblock-language",
963
- children: /* @__PURE__ */ Z("span", { children: ie })
964
+ children: /* @__PURE__ */ Z("span", { children: ae })
964
965
  }) : /* @__PURE__ */ Q("button", {
965
966
  ref: o,
966
967
  type: "button",
@@ -971,18 +972,18 @@ function Tr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
971
972
  "data-testid": "markweave-codeblock-language",
972
973
  onMouseDown: (e) => e.preventDefault(),
973
974
  onClick: () => v((e) => !e),
974
- children: [/* @__PURE__ */ Z("span", { children: ie }), /* @__PURE__ */ Z(wr, { icon: "chevron" })]
975
+ children: [/* @__PURE__ */ Z("span", { children: ae }), /* @__PURE__ */ Z(Er, { icon: "chevron" })]
975
976
  }),
976
- re ? /* @__PURE__ */ Z("button", {
977
+ ie ? /* @__PURE__ */ Z("button", {
977
978
  type: "button",
978
979
  className: "markweave-codeblock-icon-button markweave-codeblock-collapse-button",
979
- "aria-label": R ? "Expand code block" : "Collapse code block",
980
- title: R ? "Expand code block" : "Collapse code block",
980
+ "aria-label": L ? "Expand code block" : "Collapse code block",
981
+ title: L ? "Expand code block" : "Collapse code block",
981
982
  "data-testid": "markweave-codeblock-collapse",
982
- "data-collapsed": R ? "true" : "false",
983
+ "data-collapsed": L ? "true" : "false",
983
984
  onMouseDown: (e) => e.preventDefault(),
984
- onClick: V,
985
- children: /* @__PURE__ */ Z(wr, { icon: "chevron" })
985
+ onClick: B,
986
+ children: /* @__PURE__ */ Z(Er, { icon: "chevron" })
986
987
  }) : null,
987
988
  /* @__PURE__ */ Q("span", {
988
989
  className: "markweave-codeblock-copy-wrap",
@@ -991,22 +992,22 @@ function Tr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
991
992
  className: "markweave-codeblock-icon-button",
992
993
  "aria-label": "Copy to clipboard",
993
994
  "data-testid": "markweave-codeblock-copy",
994
- "data-copy-state": ae,
995
+ "data-copy-state": oe,
995
996
  onMouseDown: (e) => e.preventDefault(),
996
- onMouseEnter: () => C(!0),
997
- onMouseLeave: () => C(!1),
998
- onFocus: () => C(!0),
999
- onBlur: () => C(!1),
997
+ onMouseEnter: () => w(!0),
998
+ onMouseLeave: () => w(!1),
999
+ onFocus: () => w(!0),
1000
+ onBlur: () => w(!1),
1000
1001
  onClick: fe,
1001
- children: /* @__PURE__ */ Z(wr, { icon: ae === "copied" ? "check" : "clipboard" })
1002
- }), ee ? /* @__PURE__ */ Z("span", {
1002
+ children: /* @__PURE__ */ Z(Er, { icon: oe === "copied" ? "check" : "clipboard" })
1003
+ }), C ? /* @__PURE__ */ Z("span", {
1003
1004
  className: "markweave-codeblock-tooltip",
1004
1005
  role: "tooltip",
1005
1006
  "data-testid": "markweave-codeblock-copy-tooltip",
1006
1007
  children: "Copy to clipboard"
1007
1008
  }) : null]
1008
1009
  }),
1009
- ne && oe === "preview" ? /* @__PURE__ */ Q("div", {
1010
+ re && z === "preview" ? /* @__PURE__ */ Q("div", {
1010
1011
  className: "markweave-mermaid-preview-actions",
1011
1012
  "data-testid": "markweave-mermaid-preview-actions",
1012
1013
  children: [/* @__PURE__ */ Z("button", {
@@ -1016,8 +1017,8 @@ function Tr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1016
1017
  "data-testid": "markweave-mermaid-fullscreen",
1017
1018
  disabled: !se,
1018
1019
  onMouseDown: (e) => e.preventDefault(),
1019
- onClick: ge,
1020
- children: /* @__PURE__ */ Z(wr, { icon: "expand" })
1020
+ onClick: _e,
1021
+ children: /* @__PURE__ */ Z(Er, { icon: "expand" })
1021
1022
  }), /* @__PURE__ */ Z("button", {
1022
1023
  type: "button",
1023
1024
  className: "markweave-codeblock-icon-button",
@@ -1025,13 +1026,13 @@ function Tr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1025
1026
  "data-testid": "markweave-mermaid-download",
1026
1027
  disabled: !se,
1027
1028
  onMouseDown: (e) => e.preventDefault(),
1028
- onClick: he,
1029
- children: /* @__PURE__ */ Z(wr, { icon: "download" })
1029
+ onClick: ge,
1030
+ children: /* @__PURE__ */ Z(Er, { icon: "download" })
1030
1031
  })]
1031
1032
  }) : null
1032
1033
  ]
1033
1034
  }) : null,
1034
- re && z && _ ? /* @__PURE__ */ Q("div", {
1035
+ ie && R && _ ? /* @__PURE__ */ Q("div", {
1035
1036
  className: "markweave-codeblock-language-menu",
1036
1037
  role: "listbox",
1037
1038
  "aria-label": "Code block languages",
@@ -1052,11 +1053,11 @@ function Tr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1052
1053
  onKeyDown: (e) => {
1053
1054
  e.key === "Escape" && (e.preventDefault(), v(!1), t.view.focus());
1054
1055
  }
1055
- }), /* @__PURE__ */ Z(wr, { icon: "search" })]
1056
+ }), /* @__PURE__ */ Z(Er, { icon: "search" })]
1056
1057
  }), /* @__PURE__ */ Z("div", {
1057
1058
  className: "markweave-codeblock-language-list",
1058
1059
  children: ue.map((e) => {
1059
- let t = e.language === I.language;
1060
+ let t = e.language === F.language;
1060
1061
  return /* @__PURE__ */ Q("button", {
1061
1062
  type: "button",
1062
1063
  role: "option",
@@ -1064,13 +1065,13 @@ function Tr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1064
1065
  "data-testid": `markweave-codeblock-language-option-${e.language}`,
1065
1066
  "data-active": t ? "true" : "false",
1066
1067
  onMouseDown: (e) => e.preventDefault(),
1067
- onClick: () => B(e.language),
1068
- children: [/* @__PURE__ */ Z("span", { children: e.label }), t ? /* @__PURE__ */ Z(wr, { icon: "check" }) : null]
1068
+ onClick: () => me(e.language),
1069
+ children: [/* @__PURE__ */ Z("span", { children: e.label }), t ? /* @__PURE__ */ Z(Er, { icon: "check" }) : null]
1069
1070
  }, e.language);
1070
1071
  })
1071
1072
  })]
1072
1073
  }) : null,
1073
- w ? /* @__PURE__ */ Q("div", {
1074
+ T ? /* @__PURE__ */ Q("div", {
1074
1075
  className: "markweave-mermaid-fullscreen-layer",
1075
1076
  role: "dialog",
1076
1077
  "aria-modal": "true",
@@ -1086,47 +1087,47 @@ function Tr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1086
1087
  className: "markweave-mermaid-fullscreen-control",
1087
1088
  "aria-label": "Zoom out",
1088
1089
  "data-testid": "markweave-mermaid-fullscreen-zoom-out",
1089
- onMouseEnter: () => D("zoom-out"),
1090
- onMouseLeave: () => D(null),
1091
- onFocus: () => D("zoom-out"),
1092
- onBlur: () => D(null),
1093
- onClick: () => ve(-dn),
1094
- children: /* @__PURE__ */ Z(wr, { icon: "zoomOut" })
1090
+ onMouseEnter: () => O("zoom-out"),
1091
+ onMouseLeave: () => O(null),
1092
+ onFocus: () => O("zoom-out"),
1093
+ onBlur: () => O(null),
1094
+ onClick: () => G(-fn),
1095
+ children: /* @__PURE__ */ Z(Er, { icon: "zoomOut" })
1095
1096
  }),
1096
1097
  /* @__PURE__ */ Z("span", {
1097
1098
  className: "markweave-mermaid-fullscreen-zoom-label",
1098
1099
  "data-testid": "markweave-mermaid-fullscreen-zoom-label",
1099
- children: $t(w.scale)
1100
+ children: en(T.scale)
1100
1101
  }),
1101
1102
  /* @__PURE__ */ Z("button", {
1102
1103
  type: "button",
1103
1104
  className: "markweave-mermaid-fullscreen-control",
1104
1105
  "aria-label": "Zoom in",
1105
1106
  "data-testid": "markweave-mermaid-fullscreen-zoom-in",
1106
- onMouseEnter: () => D("zoom-in"),
1107
- onMouseLeave: () => D(null),
1108
- onFocus: () => D("zoom-in"),
1109
- onBlur: () => D(null),
1110
- onClick: () => ve(dn),
1111
- children: /* @__PURE__ */ Z(wr, { icon: "zoomIn" })
1107
+ onMouseEnter: () => O("zoom-in"),
1108
+ onMouseLeave: () => O(null),
1109
+ onFocus: () => O("zoom-in"),
1110
+ onBlur: () => O(null),
1111
+ onClick: () => G(fn),
1112
+ children: /* @__PURE__ */ Z(Er, { icon: "zoomIn" })
1112
1113
  }),
1113
1114
  /* @__PURE__ */ Z("button", {
1114
1115
  type: "button",
1115
1116
  className: "markweave-mermaid-fullscreen-control",
1116
1117
  "aria-label": "Reset zoom",
1117
1118
  "data-testid": "markweave-mermaid-fullscreen-reset",
1118
- onMouseEnter: () => D("reset"),
1119
- onMouseLeave: () => D(null),
1120
- onFocus: () => D("reset"),
1121
- onBlur: () => D(null),
1122
- onClick: K,
1123
- children: /* @__PURE__ */ Z(wr, { icon: "reset" })
1119
+ onMouseEnter: () => O("reset"),
1120
+ onMouseLeave: () => O(null),
1121
+ onFocus: () => O("reset"),
1122
+ onBlur: () => O(null),
1123
+ onClick: ye,
1124
+ children: /* @__PURE__ */ Z(Er, { icon: "reset" })
1124
1125
  }),
1125
- E ? /* @__PURE__ */ Z("span", {
1126
+ D ? /* @__PURE__ */ Z("span", {
1126
1127
  className: "markweave-mermaid-fullscreen-tooltip",
1127
1128
  role: "tooltip",
1128
1129
  "data-testid": "markweave-mermaid-fullscreen-tooltip",
1129
- children: E === "zoom-out" ? "Zoom out" : E === "zoom-in" ? "Zoom in" : "Reset"
1130
+ children: D === "zoom-out" ? "Zoom out" : D === "zoom-in" ? "Zoom in" : "Reset"
1130
1131
  }) : null
1131
1132
  ]
1132
1133
  }),
@@ -1135,29 +1136,29 @@ function Tr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1135
1136
  className: "markweave-mermaid-fullscreen-close",
1136
1137
  "aria-label": "Close fullscreen Mermaid preview",
1137
1138
  "data-testid": "markweave-mermaid-fullscreen-close",
1138
- onClick: _e,
1139
- children: /* @__PURE__ */ Z(wr, { icon: "close" })
1139
+ onClick: ve,
1140
+ children: /* @__PURE__ */ Z(Er, { icon: "close" })
1140
1141
  }),
1141
1142
  /* @__PURE__ */ Z("div", {
1142
1143
  className: "markweave-mermaid-fullscreen-viewport",
1143
1144
  "data-testid": "markweave-mermaid-fullscreen-viewport",
1144
- "data-dragging": O ? "true" : "false",
1145
- onWheel: ye,
1146
- onMouseDown: be,
1145
+ "data-dragging": ee ? "true" : "false",
1146
+ onWheel: be,
1147
+ onMouseDown: K,
1147
1148
  onMouseMove: xe,
1148
1149
  onMouseUp: Se,
1149
1150
  onMouseLeave: Se,
1150
1151
  children: /* @__PURE__ */ Z("div", {
1151
1152
  className: "markweave-mermaid-fullscreen-content",
1152
1153
  "data-testid": "markweave-mermaid-fullscreen-content",
1153
- "data-scale-percent": Math.round(w.scale * 100),
1154
- "data-translate": `${Math.round(w.translateX)},${Math.round(w.translateY)}`,
1154
+ "data-scale-percent": Math.round(T.scale * 100),
1155
+ "data-translate": `${Math.round(T.translateX)},${Math.round(T.translateY)}`,
1155
1156
  style: {
1156
- width: `${w.width}px`,
1157
- height: `${w.height}px`,
1158
- transform: `translate(${w.translateX}px, ${w.translateY}px) scale(${w.scale})`
1157
+ width: `${T.width}px`,
1158
+ height: `${T.height}px`,
1159
+ transform: `translate(${T.translateX}px, ${T.translateY}px) scale(${T.scale})`
1159
1160
  },
1160
- dangerouslySetInnerHTML: { __html: w.svg }
1161
+ dangerouslySetInnerHTML: { __html: T.svg }
1161
1162
  })
1162
1163
  })
1163
1164
  ]
@@ -1167,25 +1168,25 @@ function Tr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1167
1168
  }
1168
1169
  //#endregion
1169
1170
  //#region src/ui/floating-toolbar/FloatingToolbar.tsx
1170
- var Er = Ae("zh");
1171
- function Dr() {
1171
+ var Or = je("zh");
1172
+ function kr() {
1172
1173
  return typeof performance > "u" ? Date.now() : performance.now();
1173
1174
  }
1174
- function Or(e, t) {
1175
+ function Ar(e, t) {
1175
1176
  return {
1176
1177
  "--markweave-toolbar-motion-duration": `${e.motionDurationMs}ms`,
1177
1178
  "--markweave-toolbar-motion-easing": e.motionEasing,
1178
1179
  marginLeft: t === 0 ? void 0 : `${t}px`
1179
1180
  };
1180
1181
  }
1181
- function kr(e, t) {
1182
+ function jr(e, t) {
1182
1183
  let n = e?.getBoundingClientRect().height ?? 0, r = t?.getBoundingClientRect().height ?? 0;
1183
1184
  return Math.max(n, r, 44);
1184
1185
  }
1185
- function Ar(e) {
1186
+ function Mr(e) {
1186
1187
  if (e !== null) return { "--markweave-floating-toolbar-tooltip-left": `${e}px` };
1187
1188
  }
1188
- function jr(e, t, n, r) {
1189
+ function Nr(e, t, n, r) {
1189
1190
  let i = {
1190
1191
  bottom: t + r,
1191
1192
  height: r,
@@ -1201,26 +1202,26 @@ function jr(e, t, n, r) {
1201
1202
  toJSON: () => i
1202
1203
  };
1203
1204
  }
1204
- function Mr(e) {
1205
+ function Pr(e) {
1205
1206
  return e.width > 0 && e.height > 0;
1206
1207
  }
1207
- function Nr(e) {
1208
+ function Fr(e) {
1208
1209
  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));
1209
- return jr(t, n, r - t, i - n);
1210
+ return Nr(t, n, r - t, i - n);
1210
1211
  }
1211
- function Pr(e, t) {
1212
+ function Ir(e, t) {
1212
1213
  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;
1213
1214
  return r(t.anchorNode) && r(t.focusNode);
1214
1215
  }
1215
- function Fr(e) {
1216
+ function Lr(e) {
1216
1217
  if (typeof e.getClientRects != "function") return null;
1217
- let t = Array.from(e.getClientRects()).filter(Mr).map((e) => jr(e.left, e.top, e.width, e.height));
1218
+ let t = Array.from(e.getClientRects()).filter(Pr).map((e) => Nr(e.left, e.top, e.width, e.height));
1218
1219
  if (t.length > 0) return t;
1219
1220
  if (typeof e.getBoundingClientRect != "function") return null;
1220
1221
  let n = e.getBoundingClientRect();
1221
- return Mr(n) ? [jr(n.left, n.top, n.width, n.height)] : null;
1222
+ return Pr(n) ? [Nr(n.left, n.top, n.width, n.height)] : null;
1222
1223
  }
1223
- function Ir(e, t) {
1224
+ function Rr(e, t) {
1224
1225
  if (t.rangeCount === 0) return null;
1225
1226
  let n = t.getRangeAt(0);
1226
1227
  try {
@@ -1233,8 +1234,8 @@ function Ir(e, t) {
1233
1234
  return null;
1234
1235
  }
1235
1236
  }
1236
- function Lr(e, t) {
1237
- let n = Ir(e, t);
1237
+ function zr(e, t) {
1238
+ let n = Rr(e, t);
1238
1239
  if (!n) return !1;
1239
1240
  let { selection: r } = e.state, i = {
1240
1241
  from: Math.min(r.from, r.to),
@@ -1242,51 +1243,51 @@ function Lr(e, t) {
1242
1243
  };
1243
1244
  return n.from === i.from && n.to === i.to;
1244
1245
  }
1245
- function Rr(e) {
1246
+ function Br(e) {
1246
1247
  let t = e.view.dom.ownerDocument.getSelection();
1247
- return !t || t.rangeCount === 0 || t.isCollapsed || !Pr(e, t) || !Lr(e, t) ? null : Fr(t.getRangeAt(0));
1248
+ return !t || t.rangeCount === 0 || t.isCollapsed || !Ir(e, t) || !zr(e, t) ? null : Lr(t.getRangeAt(0));
1248
1249
  }
1249
- function zr(e) {
1250
+ function Vr(e) {
1250
1251
  let { selection: t } = e.state;
1251
1252
  if (t.empty) return null;
1252
1253
  let n = Math.min(t.from, t.to), r = Math.max(t.from, t.to);
1253
1254
  try {
1254
1255
  let t = e.view.domAtPos(n), i = e.view.domAtPos(r), a = e.view.dom.ownerDocument.createRange();
1255
- return a.setStart(t.node, t.offset), a.setEnd(i.node, i.offset), Fr(a);
1256
+ return a.setStart(t.node, t.offset), a.setEnd(i.node, i.offset), Lr(a);
1256
1257
  } catch {
1257
1258
  return null;
1258
1259
  }
1259
1260
  }
1260
- function Br(e) {
1261
+ function Hr(e) {
1261
1262
  let { selection: t } = e.state;
1262
1263
  if (t.empty) return null;
1263
- let n = Math.min(t.from, t.to), r = Math.max(t.from, t.to), i = e.view.coordsAtPos(n), a = e.view.coordsAtPos(r, -1), o = Math.min(i.top, a.top), s = Math.max(i.bottom, a.bottom), c = Math.min(i.left, a.left), l = jr(c, o, Math.max(i.right, a.right) - c, s - o);
1264
- return Mr(l) ? [l] : null;
1264
+ 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 = Nr(c, o, Math.max(i.right, a.right) - c, s - o);
1265
+ return Pr(l) ? [l] : null;
1265
1266
  }
1266
- function Vr(e) {
1267
- return Rr(e) ?? zr(e) ?? Br(e);
1267
+ function Ur(e) {
1268
+ return Br(e) ?? Vr(e) ?? Hr(e);
1268
1269
  }
1269
- function Hr(e) {
1270
- let t = Vr(e);
1271
- return t && t.length > 0 ? Nr(t) : null;
1270
+ function Wr(e) {
1271
+ let t = Ur(e);
1272
+ return t && t.length > 0 ? Fr(t) : null;
1272
1273
  }
1273
- function Ur(e) {
1274
+ function Gr(e) {
1274
1275
  return {
1275
- getBoundingClientRect: () => Hr(e) ?? jr(0, 0, 0, 0),
1276
- getClientRects: () => Vr(e) ?? []
1276
+ getBoundingClientRect: () => Wr(e) ?? Nr(0, 0, 0, 0),
1277
+ getClientRects: () => Ur(e) ?? []
1277
1278
  };
1278
1279
  }
1279
- function Wr(e) {
1280
+ function Kr(e) {
1280
1281
  return e === "block-type" || e === "link" || e === "color" || e === "more";
1281
1282
  }
1282
- function Gr(e, t, n) {
1283
- n?.(gn(e, t)), e.commands.focus();
1283
+ function qr(e, t, n) {
1284
+ n?.(_n(e, t)), e.commands.focus();
1284
1285
  }
1285
- function Kr({ editor: e, messages: t = Er, selectionSnapshot: n, onRewriteSelection: r }) {
1286
- let i = U(() => xn(t), [t]), a = et(n, { editable: e.isEditable }), [o, s] = G(a), [c, l] = G(null), [u, d] = G(null), [f, p] = G(null), [m, h] = G(""), [g, _] = G(""), [v, y] = G(null), [b, x] = G(0), [S, ee] = G(a.boundaryPadding), [C, w] = G("bottom"), T = W(0), E = W(null), D = W(null), O = W(null), k = W(null), A = _n(e, o.variant, t), j = Cn(A.find((e) => e.id === c) ?? null), M = Pn(m), N = V(() => {
1287
- let t = E.current, n = e.view.dom.closest(".markweave-editor-frame");
1286
+ function Jr({ editor: e, messages: t = Or, selectionSnapshot: n, onRewriteSelection: r }) {
1287
+ let i = H(() => Sn(t), [t]), a = et(n, { editable: e.isEditable }), [o, s] = W(a), [c, l] = W(null), [u, d] = W(null), [f, p] = W(null), [m, h] = W(""), [g, _] = W(""), [v, y] = W(null), [b, x] = W(0), [S, C] = W(a.boundaryPadding), [w, T] = W("bottom"), E = U(0), D = U(null), O = U(null), ee = U(null), k = U(null), A = vn(e, o.variant, t), j = wn(A.find((e) => e.id === c) ?? null), te = Fn(m), M = B(() => {
1288
+ let t = D.current, n = e.view.dom.closest(".markweave-editor-frame");
1288
1289
  if (!t || !(n instanceof HTMLElement)) return;
1289
- let r = t.getBoundingClientRect(), i = n.getBoundingClientRect(), a = kr(t, D.current), s = T.current, c = Ye({
1290
+ let r = t.getBoundingClientRect(), i = n.getBoundingClientRect(), a = jr(t, O.current), s = E.current, c = Ye({
1290
1291
  toolbarRect: {
1291
1292
  left: r.left - s,
1292
1293
  top: r.top,
@@ -1314,19 +1315,19 @@ function Kr({ editor: e, messages: t = Er, selectionSnapshot: n, onRewriteSelect
1314
1315
  offset: o.offset,
1315
1316
  boundaryPadding: o.boundaryPadding
1316
1317
  });
1317
- t.style.marginLeft = c === 0 ? "" : `${c}px`, t.style.visibility = "visible", t.style.opacity = "1", T.current = c, x((e) => e === c ? e : c), ee((e) => e === l ? e : l);
1318
+ t.style.marginLeft = c === 0 ? "" : `${c}px`, t.style.visibility = "visible", t.style.opacity = "1", E.current = c, x((e) => e === c ? e : c), C((e) => e === l ? e : l);
1318
1319
  }, [
1319
1320
  e.view.dom,
1320
1321
  o.boundaryPadding,
1321
1322
  o.offset
1322
- ]), P = V(() => {
1323
- E.current && (E.current.style.visibility = "hidden", E.current.style.opacity = "0");
1324
- }, []), F = V(() => {
1325
- N();
1326
- }, [N]), te = V(() => Ur(e), [e]), I = V((e) => {
1327
- O.current = e;
1328
- }, []), L = V(() => {
1329
- let t = E.current, n = O.current, r = e.view.dom.closest(".markweave-editor-frame");
1323
+ ]), N = B(() => {
1324
+ D.current && (D.current.style.visibility = "hidden", D.current.style.opacity = "0");
1325
+ }, []), ne = B(() => {
1326
+ M();
1327
+ }, [M]), P = B(() => Gr(e), [e]), F = B((e) => {
1328
+ ee.current = e;
1329
+ }, []), I = B(() => {
1330
+ let t = D.current, n = ee.current, r = e.view.dom.closest(".markweave-editor-frame");
1330
1331
  if (!f || !t || !n) return;
1331
1332
  let i = t.getBoundingClientRect(), a = n.getBoundingClientRect(), s = r?.getBoundingClientRect() ?? null, c = Xe({
1332
1333
  toolbarRect: i,
@@ -1339,23 +1340,23 @@ function Kr({ editor: e, messages: t = Er, selectionSnapshot: n, onRewriteSelect
1339
1340
  gap: f === "more" ? 8 : 6,
1340
1341
  boundaryPadding: o.boundaryPadding
1341
1342
  });
1342
- w((e) => e === c.placement ? e : c.placement);
1343
+ T((e) => e === c.placement ? e : c.placement);
1343
1344
  }, [
1344
1345
  e.view.dom,
1345
1346
  f,
1346
1347
  o.boundaryPadding
1347
- ]), ne = U(() => ({
1348
+ ]), re = H(() => ({
1348
1349
  ...$e(o, { topBoundaryPadding: S }),
1349
- onShow: P,
1350
- onUpdate: F
1350
+ onShow: N,
1351
+ onUpdate: ne
1351
1352
  }), [
1352
- P,
1353
- F,
1353
+ N,
1354
+ ne,
1354
1355
  o,
1355
1356
  S
1356
1357
  ]);
1357
- H(() => {
1358
- let e = Dr();
1358
+ V(() => {
1359
+ let e = kr();
1359
1360
  s((t) => rt(t, a, e));
1360
1361
  }, [
1361
1362
  a.hiddenReason,
@@ -1368,10 +1369,10 @@ function Kr({ editor: e, messages: t = Er, selectionSnapshot: n, onRewriteSelect
1368
1369
  a.updateDelayMs,
1369
1370
  a.variant,
1370
1371
  a.visibility
1371
- ]), H(() => {
1372
+ ]), V(() => {
1372
1373
  if (o.motionStartedAtMs === null || o.motionDurationMs <= 0) return;
1373
- let e = Math.max(0, o.motionStartedAtMs + o.motionDurationMs - Dr()), t = window.setTimeout(() => {
1374
- s((e) => qe(e, Dr()));
1374
+ let e = Math.max(0, o.motionStartedAtMs + o.motionDurationMs - kr()), t = window.setTimeout(() => {
1375
+ s((e) => qe(e, kr()));
1375
1376
  }, e);
1376
1377
  return () => {
1377
1378
  window.clearTimeout(t);
@@ -1380,17 +1381,17 @@ function Kr({ editor: e, messages: t = Er, selectionSnapshot: n, onRewriteSelect
1380
1381
  o.motionDurationMs,
1381
1382
  o.motionPhase,
1382
1383
  o.motionStartedAtMs
1383
- ]), me(() => {
1384
+ ]), he(() => {
1384
1385
  if (o.visibility !== "visible") {
1385
- T.current = 0, E.current && (E.current.style.marginLeft = "", E.current.style.visibility = "hidden", E.current.style.opacity = "0"), x(0), ee(o.boundaryPadding);
1386
+ E.current = 0, D.current && (D.current.style.marginLeft = "", D.current.style.visibility = "hidden", D.current.style.opacity = "0"), x(0), C(o.boundaryPadding);
1386
1387
  return;
1387
1388
  }
1388
- let e = mn(N);
1389
+ let e = hn(M);
1389
1390
  return e.schedule(), window.addEventListener("resize", e.schedule), window.addEventListener("scroll", e.schedule, !0), () => {
1390
1391
  e.cancel(), window.removeEventListener("resize", e.schedule), window.removeEventListener("scroll", e.schedule, !0);
1391
1392
  };
1392
1393
  }, [
1393
- N,
1394
+ M,
1394
1395
  e.view.dom,
1395
1396
  f,
1396
1397
  n?.from,
@@ -1398,41 +1399,41 @@ function Kr({ editor: e, messages: t = Er, selectionSnapshot: n, onRewriteSelect
1398
1399
  o.variant,
1399
1400
  o.visibility,
1400
1401
  A.length
1401
- ]), me(() => {
1402
+ ]), he(() => {
1402
1403
  if (!f) return;
1403
- let e = mn(L);
1404
+ let e = hn(I);
1404
1405
  return e.schedule(), window.addEventListener("resize", e.schedule), window.addEventListener("scroll", e.schedule, !0), () => {
1405
1406
  e.cancel(), window.removeEventListener("resize", e.schedule), window.removeEventListener("scroll", e.schedule, !0);
1406
1407
  };
1407
- }, [f, L]), H(() => {
1408
+ }, [f, I]), V(() => {
1408
1409
  f === "more" && i.some((e) => e.id === c) || A.some((e) => e.id === c) || (l(null), d(null));
1409
1410
  }, [
1410
1411
  i,
1411
1412
  f,
1412
1413
  c,
1413
1414
  A
1414
- ]), H(() => {
1415
+ ]), V(() => {
1415
1416
  if (!f) return;
1416
1417
  let t = (e) => {
1417
- D.current?.contains(e.target) || p(null);
1418
+ O.current?.contains(e.target) || p(null);
1418
1419
  }, n = (t) => {
1419
1420
  t.key === "Escape" && (t.preventDefault(), p(null), e.commands.focus());
1420
1421
  };
1421
1422
  return document.addEventListener("pointerdown", t, !0), document.addEventListener("keydown", n, !0), () => {
1422
1423
  document.removeEventListener("pointerdown", t, !0), document.removeEventListener("keydown", n, !0);
1423
1424
  };
1424
- }, [e, f]), H(() => {
1425
+ }, [e, f]), V(() => {
1425
1426
  if (f !== "link") return;
1426
1427
  let e = window.requestAnimationFrame(() => {
1427
1428
  k.current?.focus(), k.current?.select();
1428
1429
  });
1429
1430
  return () => window.cancelAnimationFrame(e);
1430
1431
  }, [f]);
1431
- let R = (t) => {
1432
- if (Wr(t.id)) {
1432
+ let L = (t) => {
1433
+ if (Kr(t.id)) {
1433
1434
  let n = t.id;
1434
1435
  if (n === "link") {
1435
- let t = yn(e);
1436
+ let t = bn(e);
1436
1437
  h(t), _(t), y({
1437
1438
  from: Math.min(e.state.selection.from, e.state.selection.to),
1438
1439
  to: Math.max(e.state.selection.from, e.state.selection.to)
@@ -1442,88 +1443,88 @@ function Kr({ editor: e, messages: t = Er, selectionSnapshot: n, onRewriteSelect
1442
1443
  return;
1443
1444
  }
1444
1445
  if (p(null), t.id === "improve") {
1445
- Gr(e, "rewrite-selection", r);
1446
+ qr(e, "rewrite-selection", r);
1446
1447
  return;
1447
1448
  }
1448
1449
  t.run(), e.commands.focus();
1449
- }, z = () => {
1450
+ }, R = () => {
1450
1451
  p(null), e.commands.focus();
1451
- }, re = () => {
1452
- v && e.commands.setTextSelection(v);
1453
1452
  }, ie = () => {
1454
- re(), hn(e, m) && z();
1453
+ v && e.commands.setTextSelection(v);
1455
1454
  }, ae = () => {
1456
- if (re(), kn(e)) {
1457
- h(""), _(""), z();
1455
+ ie(), gn(e, m) && R();
1456
+ }, oe = () => {
1457
+ if (ie(), An(e)) {
1458
+ h(""), _(""), R();
1458
1459
  return;
1459
1460
  }
1460
1461
  m.trim() && h("");
1461
- }, oe = (e, t) => {
1462
- if (l(e), !e || !t || !D.current) {
1462
+ }, z = (e, t) => {
1463
+ if (l(e), !e || !t || !O.current) {
1463
1464
  d(null);
1464
1465
  return;
1465
1466
  }
1466
- let n = t.getBoundingClientRect(), r = D.current.getBoundingClientRect();
1467
+ let n = t.getBoundingClientRect(), r = O.current.getBoundingClientRect();
1467
1468
  d(n.left + n.width / 2 - r.left);
1468
1469
  };
1469
- return /* @__PURE__ */ Z(pn, {
1470
- ref: E,
1470
+ return /* @__PURE__ */ Z(mn, {
1471
+ ref: D,
1471
1472
  editor: e,
1472
1473
  className: `markweave-floating-toolbar markweave-floating-toolbar--${o.variant} markweave-floating-toolbar--motion-${o.motionPhase}`,
1473
1474
  "data-motion": o.motionPhase,
1474
- "data-position-strategy": ne.strategy,
1475
+ "data-position-strategy": re.strategy,
1475
1476
  "data-boundary-padding": o.boundaryPadding,
1476
- "data-popover-placement": f ? C : void 0,
1477
+ "data-popover-placement": f ? w : void 0,
1477
1478
  "data-testid": "markweave-floating-toolbar",
1478
- style: Or(o, b),
1479
+ style: Ar(o, b),
1479
1480
  updateDelay: 0,
1480
- getReferencedVirtualElement: te,
1481
- options: ne,
1481
+ getReferencedVirtualElement: P,
1482
+ options: re,
1482
1483
  shouldShow: ({ editor: e }) => e.isEditable && nt(Qe(e)),
1483
1484
  children: /* @__PURE__ */ Q("div", {
1484
- ref: D,
1485
+ ref: O,
1485
1486
  className: "markweave-floating-toolbar-content",
1486
1487
  "data-menu": f ?? "none",
1487
1488
  children: [
1488
- A.map((e, t) => /* @__PURE__ */ Z(Jr, {
1489
+ A.map((e, t) => /* @__PURE__ */ Z(Xr, {
1489
1490
  button: e,
1490
1491
  expanded: f === e.id,
1491
1492
  showDivider: t > 0 && A[t - 1].group !== e.group,
1492
1493
  tooltipActive: c === e.id,
1493
- onPointerDown: On,
1494
- onTooltipChange: oe,
1495
- onRun: R
1494
+ onPointerDown: kn,
1495
+ onTooltipChange: z,
1496
+ onRun: L
1496
1497
  }, e.id)),
1497
- f === "block-type" ? /* @__PURE__ */ Z(Xr, {
1498
+ f === "block-type" ? /* @__PURE__ */ Z(Qr, {
1498
1499
  editor: e,
1499
1500
  messages: t,
1500
- onPopoverRef: I,
1501
+ onPopoverRef: F,
1501
1502
  onClose: () => p(null)
1502
1503
  }) : null,
1503
- f === "link" ? /* @__PURE__ */ Z(qr, {
1504
+ f === "link" ? /* @__PURE__ */ Z(Yr, {
1504
1505
  inputRef: k,
1505
1506
  messages: t,
1506
1507
  value: m,
1507
- canApply: !!M,
1508
- canOpen: !!M,
1508
+ canApply: !!te,
1509
+ canOpen: !!te,
1509
1510
  canRemove: !!(g || m.trim()),
1510
1511
  onValueChange: h,
1511
- onApply: ie,
1512
- onOpen: () => Dn(m),
1513
- onRemove: ae,
1514
- onPopoverRef: I
1512
+ onApply: ae,
1513
+ onOpen: () => On(m),
1514
+ onRemove: oe,
1515
+ onPopoverRef: F
1515
1516
  }) : null,
1516
- f === "color" ? /* @__PURE__ */ Z(Qr, {
1517
+ f === "color" ? /* @__PURE__ */ Z(ei, {
1517
1518
  editor: e,
1518
1519
  messages: t,
1519
- onPopoverRef: I,
1520
+ onPopoverRef: F,
1520
1521
  onClose: () => p(null)
1521
1522
  }) : null,
1522
- f === "more" ? /* @__PURE__ */ Z(ei, {
1523
+ f === "more" ? /* @__PURE__ */ Z(ni, {
1523
1524
  editor: e,
1524
1525
  messages: t,
1525
1526
  activeTooltipId: c,
1526
- onPopoverRef: I,
1527
+ onPopoverRef: F,
1527
1528
  onTooltipChange: l,
1528
1529
  onClose: () => p(null)
1529
1530
  }) : null,
@@ -1533,15 +1534,15 @@ function Kr({ editor: e, messages: t = Er, selectionSnapshot: n, onRewriteSelect
1533
1534
  "data-testid": "markweave-floating-toolbar-tooltip",
1534
1535
  "data-button-id": j.buttonId,
1535
1536
  "data-active": j.active,
1536
- style: Ar(u),
1537
+ style: Mr(u),
1537
1538
  children: j.label
1538
1539
  }) : null
1539
1540
  ]
1540
1541
  })
1541
1542
  });
1542
1543
  }
1543
- function qr({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRemove: a, onValueChange: o, onApply: s, onOpen: c, onRemove: l, onPopoverRef: u }) {
1544
- let d = bn(t);
1544
+ function Yr({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRemove: a, onValueChange: o, onApply: s, onOpen: c, onRemove: l, onPopoverRef: u }) {
1545
+ let d = xn(t);
1545
1546
  return /* @__PURE__ */ Q("form", {
1546
1547
  ref: u,
1547
1548
  className: "markweave-floating-toolbar-popover markweave-floating-toolbar-link-popover",
@@ -1564,7 +1565,7 @@ function qr({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRe
1564
1565
  "aria-label": d.applyLink,
1565
1566
  "data-testid": "markweave-floating-toolbar-link-apply",
1566
1567
  disabled: !r,
1567
- onMouseDown: On,
1568
+ onMouseDown: kn,
1568
1569
  children: /* @__PURE__ */ Z($, { name: "corner-down-left" })
1569
1570
  }),
1570
1571
  /* @__PURE__ */ Z("span", {
@@ -1576,7 +1577,7 @@ function qr({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRe
1576
1577
  "aria-label": d.openLink,
1577
1578
  "data-testid": "markweave-floating-toolbar-link-open",
1578
1579
  disabled: !i,
1579
- onMouseDown: On,
1580
+ onMouseDown: kn,
1580
1581
  onClick: c,
1581
1582
  children: /* @__PURE__ */ Z($, { name: "external-link" })
1582
1583
  }),
@@ -1585,7 +1586,7 @@ function qr({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRe
1585
1586
  "aria-label": d.removeLink,
1586
1587
  "data-testid": "markweave-floating-toolbar-link-remove",
1587
1588
  disabled: !a,
1588
- onMouseDown: On,
1589
+ onMouseDown: kn,
1589
1590
  onClick: l,
1590
1591
  children: /* @__PURE__ */ Z($, { name: "trash" })
1591
1592
  })
@@ -1593,7 +1594,7 @@ function qr({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRe
1593
1594
  })]
1594
1595
  });
1595
1596
  }
1596
- function Jr({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointerDown: i, onTooltipChange: a, onRun: o }) {
1597
+ function Xr({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointerDown: i, onTooltipChange: a, onRun: o }) {
1597
1598
  return /* @__PURE__ */ Q(X, { children: [n ? /* @__PURE__ */ Z("span", {
1598
1599
  className: "markweave-floating-toolbar-divider",
1599
1600
  "aria-hidden": "true"
@@ -1601,7 +1602,7 @@ function Jr({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointe
1601
1602
  type: "button",
1602
1603
  className: `markweave-floating-toolbar-button markweave-floating-toolbar-button--${e.id}`,
1603
1604
  "aria-label": e.label,
1604
- "aria-expanded": Wr(e.id) ? t : void 0,
1605
+ "aria-expanded": Kr(e.id) ? t : void 0,
1605
1606
  "data-active": e.active || t,
1606
1607
  "data-tooltip-active": r ? "true" : "false",
1607
1608
  "data-testid": `markweave-floating-toolbar-button-${e.id}`,
@@ -1611,13 +1612,13 @@ function Jr({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointe
1611
1612
  onMouseEnter: (t) => a(e.id, t.currentTarget),
1612
1613
  onMouseLeave: () => a(null),
1613
1614
  onClick: () => o(e),
1614
- children: /* @__PURE__ */ Z(Yr, {
1615
+ children: /* @__PURE__ */ Z(Zr, {
1615
1616
  button: e,
1616
1617
  expanded: t
1617
1618
  })
1618
1619
  })] });
1619
1620
  }
1620
- function Yr({ button: e, expanded: t }) {
1621
+ function Zr({ button: e, expanded: t }) {
1621
1622
  return e.id === "improve" ? /* @__PURE__ */ Q("span", {
1622
1623
  className: "markweave-floating-toolbar-button-inner",
1623
1624
  children: [/* @__PURE__ */ Z($, { name: "sparkles" }), /* @__PURE__ */ Z("span", { children: e.glyph })]
@@ -1635,8 +1636,8 @@ function Yr({ button: e, expanded: t }) {
1635
1636
  }), /* @__PURE__ */ Z($, { name: t ? "chevron-up" : "chevron-down" })]
1636
1637
  }) : /* @__PURE__ */ Z($, { name: "more" });
1637
1638
  }
1638
- function Xr({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
1639
- let i = bn(t), a = wn(t);
1639
+ function Qr({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
1640
+ let i = xn(t), a = Tn(t);
1640
1641
  return /* @__PURE__ */ Q("div", {
1641
1642
  ref: n,
1642
1643
  className: "markweave-floating-toolbar-popover markweave-floating-toolbar-turn-menu",
@@ -1646,48 +1647,48 @@ function Xr({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
1646
1647
  children: i.turnIntoTitle
1647
1648
  }), a.map((t) => /* @__PURE__ */ Q("button", {
1648
1649
  type: "button",
1649
- "data-active": En(e, t.id),
1650
+ "data-active": Dn(e, t.id),
1650
1651
  "data-testid": `markweave-floating-toolbar-turn-${t.id}`,
1651
- onMouseDown: On,
1652
+ onMouseDown: kn,
1652
1653
  onClick: () => {
1653
- Nn(e, t.id), r();
1654
+ Pn(e, t.id), r();
1654
1655
  },
1655
1656
  children: [/* @__PURE__ */ Z("span", {
1656
1657
  className: "markweave-floating-toolbar-menu-icon",
1657
- children: /* @__PURE__ */ Z(Zr, { option: t })
1658
+ children: /* @__PURE__ */ Z($r, { option: t })
1658
1659
  }), /* @__PURE__ */ Z("span", { children: t.label })]
1659
1660
  }, t.id))]
1660
1661
  });
1661
1662
  }
1662
- function Zr({ option: e }) {
1663
+ function $r({ option: e }) {
1663
1664
  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 });
1664
1665
  }
1665
- function Qr({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
1666
- let i = bn(t), a = e.getAttributes("textStyle").color, o = e.getAttributes("highlight").color;
1666
+ function ei({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
1667
+ let i = xn(t), a = e.getAttributes("textStyle").color, o = e.getAttributes("highlight").color;
1667
1668
  return /* @__PURE__ */ Q("div", {
1668
1669
  ref: n,
1669
1670
  className: "markweave-floating-toolbar-popover markweave-floating-toolbar-color-popover",
1670
1671
  "data-testid": "markweave-floating-toolbar-color-menu",
1671
- children: [/* @__PURE__ */ Z($r, {
1672
+ children: [/* @__PURE__ */ Z(ti, {
1672
1673
  title: i.textColorTitle,
1673
1674
  mode: "text",
1674
1675
  activeColor: a ?? null,
1675
- options: Sn(t),
1676
+ options: Cn(t),
1676
1677
  onSelect: (t) => {
1677
- Mn(e, t), r();
1678
+ Nn(e, t), r();
1678
1679
  }
1679
- }), /* @__PURE__ */ Z($r, {
1680
+ }), /* @__PURE__ */ Z(ti, {
1680
1681
  title: i.highlightColorTitle,
1681
1682
  mode: "highlight",
1682
1683
  activeColor: o ?? null,
1683
- options: vn(t),
1684
+ options: yn(t),
1684
1685
  onSelect: (t) => {
1685
- jn(e, t), r();
1686
+ Mn(e, t), r();
1686
1687
  }
1687
1688
  })]
1688
1689
  });
1689
1690
  }
1690
- function $r({ title: e, mode: t, activeColor: n, options: r, onSelect: i }) {
1691
+ function ti({ title: e, mode: t, activeColor: n, options: r, onSelect: i }) {
1691
1692
  return /* @__PURE__ */ Q("section", {
1692
1693
  className: "markweave-floating-toolbar-color-section",
1693
1694
  "aria-label": e,
@@ -1701,7 +1702,7 @@ function $r({ title: e, mode: t, activeColor: n, options: r, onSelect: i }) {
1701
1702
  "aria-label": e.label,
1702
1703
  "data-active": e.value === n || e.value === null && !n,
1703
1704
  "data-testid": `markweave-floating-toolbar-${t}-${e.id}`,
1704
- onMouseDown: On,
1705
+ onMouseDown: kn,
1705
1706
  onClick: () => i(e.value),
1706
1707
  children: t === "text" ? /* @__PURE__ */ Z("span", {
1707
1708
  className: "markweave-floating-toolbar-text-swatch",
@@ -1716,25 +1717,25 @@ function $r({ title: e, mode: t, activeColor: n, options: r, onSelect: i }) {
1716
1717
  })]
1717
1718
  });
1718
1719
  }
1719
- function ei({ editor: e, messages: t, activeTooltipId: n, onPopoverRef: r, onTooltipChange: i, onClose: a }) {
1720
- let o = xn(t);
1720
+ function ni({ editor: e, messages: t, activeTooltipId: n, onPopoverRef: r, onTooltipChange: i, onClose: a }) {
1721
+ let o = Sn(t);
1721
1722
  return /* @__PURE__ */ Z("div", {
1722
1723
  ref: r,
1723
1724
  className: "markweave-floating-toolbar-popover markweave-floating-toolbar-more-menu",
1724
1725
  "data-testid": "markweave-floating-toolbar-more-menu",
1725
- children: o.map((t, r) => /* @__PURE__ */ Z(ti, {
1726
+ children: o.map((t, r) => /* @__PURE__ */ Z(ri, {
1726
1727
  action: t,
1727
- active: Tn(e, t.id),
1728
+ active: En(e, t.id),
1728
1729
  tooltipActive: n === t.id,
1729
1730
  showDivider: r > 0 && o[r - 1].group !== t.group,
1730
1731
  onTooltipChange: i,
1731
1732
  onRun: () => {
1732
- An(e, t.id), a();
1733
+ jn(e, t.id), a();
1733
1734
  }
1734
1735
  }, t.id))
1735
1736
  });
1736
1737
  }
1737
- function ti({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipChange: i, onRun: a }) {
1738
+ function ri({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipChange: i, onRun: a }) {
1738
1739
  return /* @__PURE__ */ Q(X, { children: [r ? /* @__PURE__ */ Z("span", {
1739
1740
  className: "markweave-floating-toolbar-divider",
1740
1741
  "aria-hidden": "true"
@@ -1746,11 +1747,11 @@ function ti({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipC
1746
1747
  "data-active": t,
1747
1748
  "data-tooltip-active": n ? "true" : "false",
1748
1749
  "data-testid": `markweave-floating-toolbar-more-${e.id}`,
1749
- onMouseDown: On,
1750
+ onMouseDown: kn,
1750
1751
  onMouseEnter: () => i(e.id),
1751
1752
  onMouseLeave: () => i(null),
1752
1753
  onClick: a,
1753
- children: /* @__PURE__ */ Z(ni, { id: e.id })
1754
+ children: /* @__PURE__ */ Z(ii, { id: e.id })
1754
1755
  }), n ? /* @__PURE__ */ Z("div", {
1755
1756
  className: "markweave-floating-toolbar-tooltip markweave-floating-toolbar-tooltip--more",
1756
1757
  role: "tooltip",
@@ -1758,11 +1759,11 @@ function ti({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipC
1758
1759
  }) : null]
1759
1760
  })] });
1760
1761
  }
1761
- function ni({ id: e }) {
1762
+ function ii({ id: e }) {
1762
1763
  return e === "superscript" ? /* @__PURE__ */ Z($, { name: "superscript" }) : e === "subscript" ? /* @__PURE__ */ Z($, { name: "subscript" }) : e === "inline-math" ? /* @__PURE__ */ Z($, { name: "math" }) : Z($, { name: e });
1763
1764
  }
1764
- var ri = {
1765
- sparkles: ie,
1765
+ var ai = {
1766
+ sparkles: ae,
1766
1767
  "chevron-down": h,
1767
1768
  "chevron-up": g,
1768
1769
  "corner-down-left": y,
@@ -1770,29 +1771,29 @@ var ri = {
1770
1771
  bold: u,
1771
1772
  italic: A,
1772
1773
  underline: fe,
1773
- strike: ae,
1774
+ strike: oe,
1774
1775
  "inline-code": v,
1775
- link: M,
1776
- more: I,
1776
+ link: te,
1777
+ more: F,
1777
1778
  text: de,
1778
- "bullet-list": N,
1779
- "numbered-list": F,
1780
- "todo-list": P,
1781
- quote: ne,
1779
+ "bullet-list": M,
1780
+ "numbered-list": ne,
1781
+ "todo-list": N,
1782
+ quote: re,
1782
1783
  "code-block": d,
1783
1784
  superscript: se,
1784
- subscript: oe,
1785
- math: z,
1785
+ subscript: z,
1786
+ math: R,
1786
1787
  "align-left": c,
1787
1788
  "align-center": o,
1788
1789
  "align-right": l,
1789
1790
  "align-justify": s,
1790
- "decrease-indent": D,
1791
- "increase-indent": O,
1791
+ "decrease-indent": O,
1792
+ "increase-indent": ee,
1792
1793
  trash: ue
1793
1794
  };
1794
1795
  function $({ name: e }) {
1795
- let t = ri[e];
1796
+ let t = ai[e];
1796
1797
  return /* @__PURE__ */ Z(t, {
1797
1798
  "aria-hidden": "true",
1798
1799
  absoluteStrokeWidth: !0,
@@ -1802,24 +1803,24 @@ function $({ name: e }) {
1802
1803
  }
1803
1804
  //#endregion
1804
1805
  //#region src/ui/math/MathEditorPopover.tsx
1805
- function ii({ editor: e, messages: t, onClose: n, target: r }) {
1806
- let i = W(null), a = W(null), [o, s] = G(r.latex), [c, l] = G(null), u = t.math, d = U(() => yt(e, r) ?? 1, [e, r]), f = U(() => bt(e, r), [e, r]), m = U(() => o === r.latex && f ? {
1806
+ function oi({ editor: e, messages: t, onClose: n, target: r }) {
1807
+ let i = U(null), a = U(null), [o, s] = W(r.latex), [c, l] = W(null), u = t.math, d = H(() => bt(e, r) ?? 1, [e, r]), f = H(() => xt(e, r), [e, r]), m = H(() => o === r.latex && f ? {
1807
1808
  html: f,
1808
1809
  error: !1
1809
- } : wt(o, r.kind, e), [
1810
+ } : Tt(o, r.kind, e), [
1810
1811
  e,
1811
1812
  f,
1812
1813
  r.kind,
1813
1814
  r.latex,
1814
1815
  o
1815
- ]), h = o.trim().length > 0, g = V(() => {
1816
+ ]), h = o.trim().length > 0, g = B(() => {
1816
1817
  if (typeof window > "u") return;
1817
- let t = vt(e, r), i = e.view.dom.closest(".markweave-editor-frame")?.getBoundingClientRect();
1818
+ let t = yt(e, r), i = e.view.dom.closest(".markweave-editor-frame")?.getBoundingClientRect();
1818
1819
  if (!t || !i) {
1819
1820
  n();
1820
1821
  return;
1821
1822
  }
1822
- l(_t({
1823
+ l(vt({
1823
1824
  anchorRect: t,
1824
1825
  frameRect: i,
1825
1826
  kind: r.kind,
@@ -1833,30 +1834,30 @@ function ii({ editor: e, messages: t, onClose: n, target: r }) {
1833
1834
  r,
1834
1835
  o
1835
1836
  ]);
1836
- H(() => {
1837
+ V(() => {
1837
1838
  s(r.latex);
1838
- }, [r.latex, r.pos]), H(() => {
1839
- Tt(e, r, !0), g();
1839
+ }, [r.latex, r.pos]), V(() => {
1840
+ Et(e, r, !0), g();
1840
1841
  let t = window.requestAnimationFrame(() => {
1841
1842
  a.current?.focus({ preventScroll: !0 }), a.current?.select(), g();
1842
1843
  });
1843
1844
  return window.addEventListener("resize", g), window.addEventListener("scroll", g, !0), () => {
1844
- window.cancelAnimationFrame(t), window.removeEventListener("resize", g), window.removeEventListener("scroll", g, !0), Tt(e, r, !1);
1845
+ window.cancelAnimationFrame(t), window.removeEventListener("resize", g), window.removeEventListener("scroll", g, !0), Et(e, r, !1);
1845
1846
  };
1846
1847
  }, [
1847
1848
  e,
1848
1849
  n,
1849
1850
  r,
1850
1851
  g
1851
- ]), H(() => {
1852
+ ]), V(() => {
1852
1853
  let e = (e) => {
1853
1854
  let t = e.target;
1854
1855
  t instanceof Node && (i.current?.contains(t) || t instanceof Element && t.closest(".tiptap-mathematics-render") || n());
1855
1856
  };
1856
1857
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
1857
1858
  }, [n]);
1858
- let _ = V(() => {
1859
- h && gt(e, r, o) && n();
1859
+ let _ = B(() => {
1860
+ h && _t(e, r, o) && n();
1860
1861
  }, [
1861
1862
  h,
1862
1863
  e,
@@ -1987,31 +1988,31 @@ function ii({ editor: e, messages: t, onClose: n, target: r }) {
1987
1988
  }
1988
1989
  //#endregion
1989
1990
  //#region src/ui/slash-command/SlashCommandMenu.tsx
1990
- var ai = Ae("zh"), oi = {
1991
+ var si = je("zh"), ci = {
1991
1992
  type: le,
1992
- "heading-1": ee,
1993
- "heading-2": C,
1994
- "heading-3": w,
1995
- "bullet-list": N,
1996
- "ordered-list": F,
1997
- "task-list": P,
1998
- blockquote: ne,
1993
+ "heading-1": C,
1994
+ "heading-2": w,
1995
+ "heading-3": T,
1996
+ "bullet-list": M,
1997
+ "ordered-list": ne,
1998
+ "task-list": N,
1999
+ blockquote: re,
1999
2000
  "code-block": d,
2000
2001
  info: k,
2001
2002
  tip: j,
2002
2003
  warning: a,
2003
2004
  error: _,
2004
2005
  success: m,
2005
- emoji: re,
2006
- math: z,
2006
+ emoji: ie,
2007
+ math: R,
2007
2008
  table: ce,
2008
- separator: te,
2009
- image: T,
2010
- video: B,
2011
- attachment: L
2009
+ separator: P,
2010
+ image: E,
2011
+ video: me,
2012
+ attachment: I
2012
2013
  };
2013
- function si({ name: e }) {
2014
- let t = oi[e];
2014
+ function li({ name: e }) {
2015
+ let t = ci[e];
2015
2016
  return /* @__PURE__ */ Z(t, {
2016
2017
  "aria-hidden": "true",
2017
2018
  absoluteStrokeWidth: !0,
@@ -2019,8 +2020,8 @@ function si({ name: e }) {
2019
2020
  strokeWidth: 1.6
2020
2021
  });
2021
2022
  }
2022
- function ci(e, t, n) {
2023
- return !jt(e) || !n ? {
2023
+ function ui(e, t, n) {
2024
+ return !Mt(e) || !n ? {
2024
2025
  visible: !1,
2025
2026
  empty: !1,
2026
2027
  activeIndex: -1
@@ -2034,17 +2035,17 @@ function ci(e, t, n) {
2034
2035
  activeIndex: Math.min(t.length - 1, Math.max(0, e.activeIndex))
2035
2036
  };
2036
2037
  }
2037
- function li(e, t) {
2038
+ function di(e, t) {
2038
2039
  return Object.values(t.slash.groups).map((t) => ({
2039
2040
  group: t,
2040
2041
  commands: e.filter((e) => e.group === t)
2041
2042
  })).filter((e) => e.commands.length > 0);
2042
2043
  }
2043
- function ui(e, t) {
2044
+ function fi(e, t) {
2044
2045
  return t.slash.uploadKindLabels[e] ?? t.slash.uploadKindLabels.upload;
2045
2046
  }
2046
- function di({ command: e, messages: t, onBack: n, onSelect: r }) {
2047
- let [i, a] = G(""), [o, s] = G(0), c = U(() => {
2047
+ function pi({ command: e, messages: t, onBack: n, onSelect: r }) {
2048
+ let [i, a] = W(""), [o, s] = W(0), c = H(() => {
2048
2049
  let e = i.trim().toLowerCase();
2049
2050
  return (e ? t.slash.emojiItems.filter((t) => [
2050
2051
  t.emoji,
@@ -2110,9 +2111,9 @@ function di({ command: e, messages: t, onBack: n, onSelect: r }) {
2110
2111
  ]
2111
2112
  });
2112
2113
  }
2113
- function fi({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
2114
- let a = e.uploadKind ?? "attachment", [o, s] = G(""), [c, l] = G(null), [u, d] = G(null), [f, p] = G(!1), m = async (t) => {
2115
- r(e, { uploadResult: await ve({
2114
+ function mi({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
2115
+ let a = e.uploadKind ?? "attachment", [o, s] = W(""), [c, l] = W(null), [u, d] = W(null), [f, p] = W(!1), m = async (t) => {
2116
+ r(e, { uploadResult: await G({
2116
2117
  kind: a,
2117
2118
  source: t,
2118
2119
  trigger: "slash-command"
@@ -2132,7 +2133,7 @@ function fi({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
2132
2133
  d(t.slash.uploadRequiredError);
2133
2134
  return;
2134
2135
  }
2135
- await m(ge(o));
2136
+ await m(_e(o));
2136
2137
  } catch (e) {
2137
2138
  d(e instanceof Error ? e.message : t.slash.uploadFailedError);
2138
2139
  } finally {
@@ -2150,7 +2151,7 @@ function fi({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
2150
2151
  onMouseDown: (e) => e.preventDefault(),
2151
2152
  onClick: n,
2152
2153
  children: t.common.back
2153
- }), /* @__PURE__ */ Z("span", { children: ui(a, t) })]
2154
+ }), /* @__PURE__ */ Z("span", { children: fi(a, t) })]
2154
2155
  }),
2155
2156
  /* @__PURE__ */ Q("label", {
2156
2157
  className: "markweave-slash-upload-field",
@@ -2198,10 +2199,10 @@ function fi({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
2198
2199
  ]
2199
2200
  });
2200
2201
  }
2201
- function pi({ commands: e, messages: t = ai, state: n, position: r, inputCommand: i, onActiveIndexChange: a, onInputCommandChange: o, onSelect: s, onUpload: c }) {
2202
- let l = ci(n, e, r);
2202
+ function hi({ commands: e, messages: t = si, state: n, position: r, inputCommand: i, onActiveIndexChange: a, onInputCommandChange: o, onSelect: s, onUpload: c }) {
2203
+ let l = ui(n, e, r);
2203
2204
  if (!l.visible || !r) return null;
2204
- let u = li(e, t), d = {
2205
+ let u = di(e, t), d = {
2205
2206
  left: r.left,
2206
2207
  top: r.top,
2207
2208
  maxHeight: r.maxHeight,
@@ -2223,12 +2224,12 @@ function pi({ commands: e, messages: t = ai, state: n, position: r, inputCommand
2223
2224
  "aria-label": t.slash.ariaLabel,
2224
2225
  "data-placement": r.placement,
2225
2226
  "data-testid": "markweave-slash-menu",
2226
- children: i?.inputKind === "emoji" ? /* @__PURE__ */ Z(di, {
2227
+ children: i?.inputKind === "emoji" ? /* @__PURE__ */ Z(pi, {
2227
2228
  command: i,
2228
2229
  messages: t,
2229
2230
  onBack: m,
2230
2231
  onSelect: s
2231
- }) : i?.inputKind === "upload" ? /* @__PURE__ */ Z(fi, {
2232
+ }) : i?.inputKind === "upload" ? /* @__PURE__ */ Z(mi, {
2232
2233
  command: i,
2233
2234
  messages: t,
2234
2235
  onBack: m,
@@ -2248,7 +2249,7 @@ function pi({ commands: e, messages: t = ai, state: n, position: r, inputCommand
2248
2249
  className: "markweave-slash-group-title",
2249
2250
  children: t.group
2250
2251
  }), t.commands.map((t) => {
2251
- let n = e.indexOf(t), r = n === l.activeIndex, i = kt(t), o = !!t.disabled;
2252
+ let n = e.indexOf(t), r = n === l.activeIndex, i = At(t), o = !!t.disabled;
2252
2253
  return /* @__PURE__ */ Q("button", {
2253
2254
  type: "button",
2254
2255
  role: "option",
@@ -2272,7 +2273,7 @@ function pi({ commands: e, messages: t = ai, state: n, position: r, inputCommand
2272
2273
  }
2273
2274
  },
2274
2275
  children: [
2275
- /* @__PURE__ */ Z(si, { name: t.icon }),
2276
+ /* @__PURE__ */ Z(li, { name: t.icon }),
2276
2277
  /* @__PURE__ */ Z("span", { children: t.label }),
2277
2278
  o && t.disabledReason ? /* @__PURE__ */ Z("small", { children: t.disabledReason }) : null
2278
2279
  ]
@@ -2284,38 +2285,38 @@ function pi({ commands: e, messages: t = ai, state: n, position: r, inputCommand
2284
2285
  }
2285
2286
  //#endregion
2286
2287
  //#region src/ui/table/TableControls.tsx
2287
- var mi = Ae("zh");
2288
- function hi({ active: e, editor: t, interactionState: n = Ht, messages: r = mi, onCopyPayload: i, onCommandResult: a, onEditWithAi: o }) {
2289
- let [s, c] = G(null), [l, u] = G("row-edge"), [d, f] = G(null), [p, m] = G(null), [h, g] = G(null), [_, v] = G(null), [y, b] = G(null), x = W(null), S = W(null), ee = W(null), C = W(null), w = W(null), T = e ? Bt(t.state) : null;
2290
- if (H(() => {
2288
+ var gi = je("zh");
2289
+ function _i({ active: e, editor: t, interactionState: n = Ut, messages: r = gi, onCopyPayload: i, onCommandResult: a, onEditWithAi: o }) {
2290
+ let [s, c] = W(null), [l, u] = W("row-edge"), [d, f] = W(null), [p, m] = W(null), [h, g] = W(null), [_, v] = W(null), [y, b] = W(null), x = U(null), S = U(null), C = U(null), w = U(null), T = U(null), E = e ? Vt(t.state) : null;
2291
+ if (V(() => {
2291
2292
  if (!y) return;
2292
2293
  let e = window.setTimeout(() => {
2293
2294
  b(null);
2294
- }, Qn);
2295
+ }, $n);
2295
2296
  return () => {
2296
2297
  window.clearTimeout(e);
2297
2298
  };
2298
- }, [y]), me(() => {
2299
+ }, [y]), he(() => {
2299
2300
  if (!e) {
2300
2301
  m(null), g(null), v(null), b(null);
2301
2302
  return;
2302
2303
  }
2303
2304
  let r = () => {
2304
- let e = t.view.dom.closest(".markweave-editor-frame") ?? t.view.dom.parentElement, r = Wn(t, n, "row", T?.activeCellPos ?? null), i = Wn(t, n, "column", T?.activeCellPos ?? null), a = r ? Un(t, r) : null, o = i ? Un(t, i) : null, c = Hn(t).length > 0 ? Yn(t) : null;
2305
+ let e = t.view.dom.closest(".markweave-editor-frame") ?? t.view.dom.parentElement, r = Gn(t, n, "row", E?.activeCellPos ?? null), i = Gn(t, n, "column", E?.activeCellPos ?? null), a = r ? Wn(t, r) : null, o = i ? Wn(t, i) : null, c = Un(t).length > 0 ? Xn(t) : null;
2305
2306
  if (!e) {
2306
2307
  m(null), g(null), v(null);
2307
2308
  return;
2308
2309
  }
2309
2310
  let u = e.getBoundingClientRect();
2310
- a ? m(Ln({
2311
+ a ? m(Rn({
2311
2312
  targetRect: a,
2312
2313
  frameRect: u,
2313
2314
  kind: "row"
2314
- })) : s === "row" && l === "row-edge" || m(null), o ? g(Ln({
2315
+ })) : s === "row" && l === "row-edge" || m(null), o ? g(Rn({
2315
2316
  targetRect: o,
2316
2317
  frameRect: u,
2317
2318
  kind: "column"
2318
- })) : s === "column" && l === "column-edge" || g(null), c ? v(Ln({
2319
+ })) : s === "column" && l === "column-edge" || g(null), c ? v(Rn({
2319
2320
  targetRect: c,
2320
2321
  frameRect: u,
2321
2322
  kind: "selection"
@@ -2327,31 +2328,31 @@ function hi({ active: e, editor: t, interactionState: n = Ht, messages: r = mi,
2327
2328
  }, [
2328
2329
  e,
2329
2330
  t,
2330
- T?.activeCellPos,
2331
- T?.selectionFrom,
2332
- T?.selectionTo,
2331
+ E?.activeCellPos,
2332
+ E?.selectionFrom,
2333
+ E?.selectionTo,
2333
2334
  n.hoverCellPos,
2334
2335
  n.hoverVisualColumnIndex,
2335
2336
  n.hoverVisualRowIndex,
2336
2337
  l,
2337
2338
  s
2338
- ]), me(() => {
2339
+ ]), he(() => {
2339
2340
  if (!e || !s) {
2340
2341
  f(null);
2341
2342
  return;
2342
2343
  }
2343
2344
  let n = () => {
2344
- let e = t.view.dom.closest(".markweave-editor-frame") ?? t.view.dom.parentElement, n = l === "row-edge" ? ee.current : l === "column-edge" ? C.current : w.current, r = S.current;
2345
+ let e = t.view.dom.closest(".markweave-editor-frame") ?? t.view.dom.parentElement, n = l === "row-edge" ? C.current : l === "column-edge" ? w.current : T.current, r = S.current;
2345
2346
  if (!e || !n || !r) {
2346
2347
  f(null);
2347
2348
  return;
2348
2349
  }
2349
- let i = n.getBoundingClientRect(), a = s === "row" ? Vn(t)?.getBoundingClientRect() : null, o = a ? {
2350
+ let i = n.getBoundingClientRect(), a = s === "row" ? Hn(t)?.getBoundingClientRect() : null, o = a ? {
2350
2351
  left: i.left,
2351
2352
  top: a.top,
2352
2353
  width: i.width,
2353
2354
  height: i.height
2354
- } : i, c = e.getBoundingClientRect(), u = r.getBoundingClientRect(), d = In({
2355
+ } : i, c = e.getBoundingClientRect(), u = r.getBoundingClientRect(), d = Ln({
2355
2356
  anchorRect: o,
2356
2357
  frameRect: c,
2357
2358
  menuSize: {
@@ -2373,7 +2374,7 @@ function hi({ active: e, editor: t, interactionState: n = Ht, messages: r = mi,
2373
2374
  p,
2374
2375
  h,
2375
2376
  _
2376
- ]), H(() => {
2377
+ ]), V(() => {
2377
2378
  if (!e || !s) return;
2378
2379
  let n = (e) => {
2379
2380
  e.key === "Escape" && (c(null), t.view.focus());
@@ -2388,26 +2389,26 @@ function hi({ active: e, editor: t, interactionState: n = Ht, messages: r = mi,
2388
2389
  t,
2389
2390
  s
2390
2391
  ]), !e) return null;
2391
- let E = (e, t) => {
2392
+ let D = (e, t) => {
2392
2393
  let n = s === e && l === t;
2393
2394
  u(t), c(n ? null : e);
2394
- }, D = () => {
2395
- t.view.dispatch(Fn(t.state.tr, null));
2396
- }, O = (e, r) => {
2397
- let i = n.hoverCellPos ?? T?.activeCellPos ?? null, a = n.hoverCellPos === null ? null : e === "row" ? n.hoverVisualRowIndex : n.hoverVisualColumnIndex;
2398
- i !== null && Zn(t, i, e, { visualIndex: a }), E(e, r);
2395
+ }, O = () => {
2396
+ t.view.dispatch(In(t.state.tr, null));
2397
+ }, ee = (e, r) => {
2398
+ let i = n.hoverCellPos ?? E?.activeCellPos ?? null, a = n.hoverCellPos === null ? null : e === "row" ? n.hoverVisualRowIndex : n.hoverVisualColumnIndex;
2399
+ i !== null && Qn(t, i, e, { visualIndex: a }), D(e, r);
2399
2400
  }, k = () => {
2400
- D(), E("selection", "selection-edge");
2401
- }, A = Wn(t, n, "row", T?.activeCellPos ?? null), j = Wn(t, n, "column", T?.activeCellPos ?? null), M = Hn(t).length > 0, N = s ? Jn(t, s) : [], P = async (e, n) => {
2402
- let o = await zn({
2401
+ O(), D("selection", "selection-edge");
2402
+ }, A = Gn(t, n, "row", E?.activeCellPos ?? null), j = Gn(t, n, "column", E?.activeCellPos ?? null), te = Un(t).length > 0, M = s ? Yn(t, s) : [], N = async (e, n) => {
2403
+ let o = await Bn({
2403
2404
  editor: t,
2404
2405
  commandId: e,
2405
2406
  menu: n ?? s ?? "selection",
2406
2407
  messages: r
2407
2408
  });
2408
2409
  return o.copyFeedback ? (b(o.copyFeedback), o.copyPayload && i?.(o.copyPayload)) : b(null), a?.(o.commandResult), o.success;
2409
- }, F = (e) => {
2410
- let n = Gn(t, e);
2410
+ }, ne = (e) => {
2411
+ let n = Kn(t, e);
2411
2412
  n && o?.(n), c(null), t.view.focus();
2412
2413
  };
2413
2414
  return /* @__PURE__ */ Q("div", {
@@ -2426,11 +2427,11 @@ function hi({ active: e, editor: t, interactionState: n = Ht, messages: r = mi,
2426
2427
  "data-copy-kind": y.kind,
2427
2428
  "data-text-length": y.textLength,
2428
2429
  "data-html-length": y.htmlLength,
2429
- children: Bn(y)
2430
+ children: Vn(y)
2430
2431
  }) : null,
2431
2432
  p ? /* @__PURE__ */ Z("button", {
2432
2433
  type: "button",
2433
- ref: ee,
2434
+ ref: C,
2434
2435
  className: "markweave-table-edge-handle markweave-table-edge-handle--row",
2435
2436
  "aria-label": r.table.activeRowActions,
2436
2437
  "aria-expanded": s === "row" && l === "row-edge",
@@ -2447,7 +2448,7 @@ function hi({ active: e, editor: t, interactionState: n = Ht, messages: r = mi,
2447
2448
  },
2448
2449
  onMouseDown: (e) => e.preventDefault(),
2449
2450
  onClick: () => {
2450
- O("row", "row-edge");
2451
+ ee("row", "row-edge");
2451
2452
  },
2452
2453
  children: /* @__PURE__ */ Z("span", {
2453
2454
  "aria-hidden": "true",
@@ -2456,7 +2457,7 @@ function hi({ active: e, editor: t, interactionState: n = Ht, messages: r = mi,
2456
2457
  }) : null,
2457
2458
  h ? /* @__PURE__ */ Z("button", {
2458
2459
  type: "button",
2459
- ref: C,
2460
+ ref: w,
2460
2461
  className: "markweave-table-edge-handle markweave-table-edge-handle--column",
2461
2462
  "aria-label": r.table.activeColumnActions,
2462
2463
  "aria-expanded": s === "column" && l === "column-edge",
@@ -2473,16 +2474,16 @@ function hi({ active: e, editor: t, interactionState: n = Ht, messages: r = mi,
2473
2474
  },
2474
2475
  onMouseDown: (e) => e.preventDefault(),
2475
2476
  onClick: () => {
2476
- O("column", "column-edge");
2477
+ ee("column", "column-edge");
2477
2478
  },
2478
2479
  children: /* @__PURE__ */ Z("span", {
2479
2480
  "aria-hidden": "true",
2480
2481
  children: "..."
2481
2482
  })
2482
2483
  }) : null,
2483
- M && _ ? /* @__PURE__ */ Z("button", {
2484
+ te && _ ? /* @__PURE__ */ Z("button", {
2484
2485
  type: "button",
2485
- ref: w,
2486
+ ref: T,
2486
2487
  className: "markweave-table-edge-handle markweave-table-edge-handle--selection",
2487
2488
  "aria-label": r.table.selectionActions,
2488
2489
  "aria-expanded": s === "selection" && l === "selection-edge",
@@ -2504,15 +2505,15 @@ function hi({ active: e, editor: t, interactionState: n = Ht, messages: r = mi,
2504
2505
  ref: S,
2505
2506
  className: "markweave-table-menu",
2506
2507
  role: "menu",
2507
- "aria-label": $n(s, r),
2508
+ "aria-label": er(s, r),
2508
2509
  "data-testid": "markweave-table-menu",
2509
2510
  "data-positioned": d ? "true" : "false",
2510
2511
  style: d ? {
2511
2512
  left: d.left,
2512
2513
  top: d.top
2513
2514
  } : void 0,
2514
- children: N.map((e, n) => {
2515
- let i = Kn(e), a = n === 0 ? i : Kn(N[n - 1]), l = n > 0 && a !== i, u = e.commandId === null ? !!o : Rn(t, e.commandId), d = qn(e, r);
2515
+ children: M.map((e, n) => {
2516
+ let i = qn(e), a = n === 0 ? i : qn(M[n - 1]), l = n > 0 && a !== i, u = e.commandId === null ? !!o : zn(t, e.commandId), d = Jn(e, r);
2516
2517
  return /* @__PURE__ */ Z("button", {
2517
2518
  type: "button",
2518
2519
  role: "menuitem",
@@ -2527,10 +2528,10 @@ function hi({ active: e, editor: t, interactionState: n = Ht, messages: r = mi,
2527
2528
  onClick: () => {
2528
2529
  if (u) {
2529
2530
  if (e.commandId === null) {
2530
- F(s === "row" || s === "column" ? s : "selection");
2531
+ ne(s === "row" || s === "column" ? s : "selection");
2531
2532
  return;
2532
2533
  }
2533
- P(e.commandId).finally(() => c(null));
2534
+ N(e.commandId).finally(() => c(null));
2534
2535
  }
2535
2536
  },
2536
2537
  children: d
@@ -2542,15 +2543,15 @@ function hi({ active: e, editor: t, interactionState: n = Ht, messages: r = mi,
2542
2543
  }
2543
2544
  //#endregion
2544
2545
  //#region src/ui/table/TableSelectionOverlay.tsx
2545
- function gi({ editor: e, focusState: t }) {
2546
- let [n, r] = G(null);
2547
- return me(() => {
2546
+ function vi({ editor: e, focusState: t }) {
2547
+ let [n, r] = W(null);
2548
+ return he(() => {
2548
2549
  if (t.mode !== "cell-selection") {
2549
2550
  r(null);
2550
2551
  return;
2551
2552
  }
2552
2553
  let n = () => {
2553
- r(Xn(e, Vt(e.state)));
2554
+ r(Zn(e, Ht(e.state)));
2554
2555
  };
2555
2556
  return n(), window.addEventListener("resize", n), window.addEventListener("scroll", n, !0), () => {
2556
2557
  window.removeEventListener("resize", n), window.removeEventListener("scroll", n, !0);
@@ -2585,16 +2586,16 @@ function gi({ editor: e, focusState: t }) {
2585
2586
  }
2586
2587
  //#endregion
2587
2588
  //#region src/ui/toc/MarkweaveInnerToc.tsx
2588
- function _i(e, t) {
2589
+ function yi(e, t) {
2589
2590
  return `${e.toc.itemAriaLabel}: ${t.text}`;
2590
2591
  }
2591
- function vi({ editor: e, state: t, messages: n, editable: r, placement: i }) {
2592
- let a = W(null);
2593
- if (H(() => {
2594
- if (!(i !== "container" || !a.current)) return or(a.current);
2592
+ function bi({ editor: e, state: t, messages: n, editable: r, placement: i }) {
2593
+ let a = U(null);
2594
+ if (V(() => {
2595
+ if (!(i !== "container" || !a.current)) return sr(a.current);
2595
2596
  }, [i]), !t.items.length) return null;
2596
2597
  let o = (t) => {
2597
- sr(e, t, {
2598
+ cr(e, t, {
2598
2599
  behavior: "smooth",
2599
2600
  focus: r
2600
2601
  });
@@ -2621,7 +2622,7 @@ function vi({ editor: e, state: t, messages: n, editable: r, placement: i }) {
2621
2622
  "data-level": e.level,
2622
2623
  "data-active": e.active ? "true" : "false",
2623
2624
  "aria-current": e.active ? "location" : void 0,
2624
- "aria-label": _i(n, e),
2625
+ "aria-label": yi(n, e),
2625
2626
  title: e.text,
2626
2627
  onClick: () => o(e),
2627
2628
  children: e.text
@@ -2632,7 +2633,7 @@ function vi({ editor: e, state: t, messages: n, editable: r, placement: i }) {
2632
2633
  }
2633
2634
  //#endregion
2634
2635
  //#region src/MarkweaveEditor.tsx
2635
- var yi = {
2636
+ var xi = {
2636
2637
  active: !1,
2637
2638
  mode: "outside",
2638
2639
  activeCellPos: null,
@@ -2640,21 +2641,21 @@ var yi = {
2640
2641
  selectedCellCount: 0,
2641
2642
  selectionFrom: 0,
2642
2643
  selectionTo: 0
2643
- }, bi = {
2644
+ }, Si = {
2644
2645
  active: !1,
2645
2646
  language: ct.defaultLanguage,
2646
2647
  mermaidPreviewMode: "code",
2647
2648
  pos: null,
2648
2649
  text: ""
2649
- }, xi = ht({
2650
+ }, Ci = gt({
2650
2651
  active: !1,
2651
2652
  mode: "code",
2652
2653
  source: ""
2653
2654
  });
2654
- function Si(e) {
2655
- return Ut.getState(e.state) ?? Ht;
2655
+ function wi(e) {
2656
+ return Wt.getState(e.state) ?? Ut;
2656
2657
  }
2657
- function Ci(e) {
2658
+ function Ti(e) {
2658
2659
  if (!e || typeof window > "u") return null;
2659
2660
  let t = e.parentElement;
2660
2661
  for (; t;) {
@@ -2664,88 +2665,88 @@ function Ci(e) {
2664
2665
  }
2665
2666
  return null;
2666
2667
  }
2667
- function wi(e) {
2668
+ function Ei(e) {
2668
2669
  return typeof window > "u" || typeof window.requestAnimationFrame != "function" ? globalThis.setTimeout(() => e(0), 0) : window.requestAnimationFrame(e);
2669
2670
  }
2670
- function Ti(e) {
2671
+ function Di(e) {
2671
2672
  if (typeof window < "u" && typeof window.cancelAnimationFrame == "function") {
2672
2673
  window.cancelAnimationFrame(e);
2673
2674
  return;
2674
2675
  }
2675
2676
  globalThis.clearTimeout(e);
2676
2677
  }
2677
- function Ei({ ariaLabel: e, autoFocusFirstTableBodyCell: t = !1, autofocus: n = !1, content: r, contentFormat: a, defaultContent: o = "", defaultContentFormat: s, editable: c = !0, innerToc: l = !0, innerTocPlacement: u, lang: d, mode: f = "live", onEditWithAi: p, onExtractToNote: m, onRewriteSelection: h, onRuntimeStateChange: g, onSlashCommandUpload: _, onTableCommandResult: v, onTableCopyPayload: y, onTocChange: b, onUpdate: x } = {}) {
2678
- let S = Pe(f), ee = ar(u), C = S === "live" && c !== !1, w = We(r === void 0 ? s : a), T = W({
2679
- editorMode: S,
2680
- effectiveEditable: C
2678
+ function Oi({ ariaLabel: e, autoFocusFirstTableBodyCell: t = !1, autofocus: n = !1, content: r, contentFormat: a, defaultContent: o = "", defaultContentFormat: s, editable: c = !0, innerToc: l = !0, innerTocPlacement: u, lang: d, mode: f = "live", theme: p, onEditWithAi: m, onExtractToNote: h, onRewriteSelection: g, onRuntimeStateChange: _, onSlashCommandUpload: v, onTableCommandResult: y, onTableCopyPayload: b, onTocChange: x, onUpdate: S } = {}) {
2679
+ let C = Pe(f), w = lr(p), T = or(u), E = C === "live" && c !== !1, D = We(r === void 0 ? s : a), O = U({
2680
+ editorMode: C,
2681
+ effectiveEditable: E
2681
2682
  });
2682
- T.current = {
2683
- editorMode: S,
2684
- effectiveEditable: C
2683
+ O.current = {
2684
+ editorMode: C,
2685
+ effectiveEditable: E
2685
2686
  };
2686
- let E = W(null);
2687
- E.current === null && (E.current = je(d));
2688
- let D = E.current, O = U(() => Ae(D), [D]), k = U(() => ke(D), [D]), A = W(_);
2689
- A.current = _;
2690
- let j = U(() => Sr({
2691
- lang: D,
2687
+ let ee = U(null);
2688
+ ee.current === null && (ee.current = Me(d));
2689
+ let k = ee.current, A = H(() => je(k), [k]), j = H(() => Ae(k), [k]), te = U(v);
2690
+ te.current = v;
2691
+ let M = H(() => wr({
2692
+ lang: k,
2692
2693
  onImageUpload: (e) => {
2693
- if (A.current) return A.current(e);
2694
- let t = _e(e);
2694
+ if (te.current) return te.current(e);
2695
+ let t = ve(e);
2695
2696
  if (!t) throw Error("File upload requires an upload handler.");
2696
2697
  return t;
2697
2698
  },
2698
2699
  onVideoUpload: (e) => {
2699
- if (A.current) return A.current(e);
2700
- let t = _e(e);
2700
+ if (te.current) return te.current(e);
2701
+ let t = ve(e);
2701
2702
  if (!t) throw Error("File upload requires an upload handler.");
2702
2703
  return t;
2703
2704
  }
2704
- }), [D]), [M, N] = G(null), [P, F] = G(It), [te, I] = G(null), [L, ne] = G(null), [R, z] = G("code"), [re, ie] = G(null), [ae, oe] = G(Ht), [se, ce] = G(null), [le, ue] = G(0), de = W(!1), fe = W({
2705
+ }), [k]), [N, ne] = W(null), [P, F] = W(Lt), [I, re] = W(null), [L, R] = W(null), [ie, ae] = W("code"), [oe, z] = W(null), [se, ce] = W(Ut), [le, ue] = W(null), [de, fe] = W(0), pe = U(!1), me = U({
2705
2706
  content: r,
2706
- format: w
2707
- }), pe = W(null), B = W(null), me = W({ onUpdate: x }), he = U(() => Ot(P.query, k), [k, P.query]);
2708
- me.current = { onUpdate: x }, fe.current = {
2707
+ format: D
2708
+ }), he = U(null), ge = U(null), _e = U({ onUpdate: S }), G = H(() => kt(P.query, j), [j, P.query]);
2709
+ _e.current = { onUpdate: S }, me.current = {
2709
2710
  content: r,
2710
- format: w
2711
+ format: D
2711
2712
  };
2712
- let ge = V(() => {
2713
- B.current !== null && (window.clearTimeout(B.current), B.current = null), ue((e) => e + 1);
2714
- }, []), ve = V(() => {
2715
- B.current !== null && window.clearTimeout(B.current), B.current = window.setTimeout(() => {
2716
- B.current = null, ue((e) => e + 1);
2713
+ let ye = B(() => {
2714
+ ge.current !== null && (window.clearTimeout(ge.current), ge.current = null), fe((e) => e + 1);
2715
+ }, []), be = B(() => {
2716
+ ge.current !== null && window.clearTimeout(ge.current), ge.current = window.setTimeout(() => {
2717
+ ge.current = null, fe((e) => e + 1);
2717
2718
  }, tt);
2718
2719
  }, []);
2719
- H(() => () => {
2720
- B.current !== null && window.clearTimeout(B.current);
2720
+ V(() => () => {
2721
+ ge.current !== null && window.clearTimeout(ge.current);
2721
2722
  }, []);
2722
- let K = V(() => {
2723
- I(null), ne(null), F(It);
2724
- }, []), ye = V((e) => {
2725
- let t = Ft(e.state);
2723
+ let K = B(() => {
2724
+ re(null), R(null), F(Lt);
2725
+ }, []), xe = B((e) => {
2726
+ let t = It(e.state);
2726
2727
  if (!t) {
2727
- F((e) => e.name === "idle" ? e : It), I(null), ne(null);
2728
+ F((e) => e.name === "idle" ? e : Lt), re(null), R(null);
2728
2729
  return;
2729
2730
  }
2730
2731
  let n = e.coordsAtPos(t.cursor), r = e.coordsAtPos(t.triggerFrom), i = e.dom.closest(".markweave-editor-frame")?.getBoundingClientRect();
2731
- I(Pt(n, {
2732
+ re(Ft(n, {
2732
2733
  frameRect: i,
2733
2734
  triggerRect: r
2734
- })), F((e) => Nt(e, t));
2735
- }, []), be = V((e) => ye(e.view), [ye]), xe = V((e) => {
2735
+ })), F((e) => Pt(e, t));
2736
+ }, []), Se = B((e) => xe(e.view), [xe]), Ce = B((e) => {
2736
2737
  let t = Qe(e);
2737
- N((e) => Je(e, t) ? e : t);
2738
- let n = Ct(e);
2739
- n && (Tt(e, n, !0), ie(n));
2738
+ ne((e) => Je(e, t) ? e : t);
2739
+ let n = wt(e);
2740
+ n && (Et(e, n, !0), z(n));
2740
2741
  let r = ot(e);
2741
- r.active && r.language === "mermaid" && z(r.mermaidPreviewMode);
2742
- }, []), Se = V((e) => {
2743
- oe(Si(e));
2742
+ r.active && r.language === "mermaid" && ae(r.mermaidPreviewMode);
2743
+ }, []), we = B((e) => {
2744
+ ce(wi(e));
2744
2745
  }, []), q = i({
2745
- extensions: j,
2746
+ extensions: M,
2746
2747
  content: r ?? o,
2747
- contentType: Ve(w),
2748
- editable: C,
2748
+ contentType: Ve(D),
2749
+ editable: E,
2749
2750
  autofocus: n,
2750
2751
  editorProps: {
2751
2752
  attributes: {
@@ -2756,36 +2757,36 @@ function Ei({ ariaLabel: e, autoFocusFirstTableBodyCell: t = !1, autofocus: n =
2756
2757
  spellcheck: "false",
2757
2758
  translate: "no"
2758
2759
  },
2759
- handleClick: (e, t, n) => T.current.effectiveEditable ? !1 : Ge(n),
2760
+ handleClick: (e, t, n) => O.current.effectiveEditable ? !1 : Ge(n),
2760
2761
  handleDOMEvents: {
2761
- compositionstart: () => T.current.effectiveEditable ? (F((e) => Lt(e, { type: "composition-start" })), I(null), !1) : !1,
2762
- compositionend: (e) => (T.current.effectiveEditable && window.setTimeout(() => ye(e), 0), !1),
2762
+ compositionstart: () => O.current.effectiveEditable ? (F((e) => Rt(e, { type: "composition-start" })), re(null), !1) : !1,
2763
+ compositionend: (e) => (O.current.effectiveEditable && window.setTimeout(() => xe(e), 0), !1),
2763
2764
  click: (e, t) => {
2764
- if (T.current.effectiveEditable) {
2765
- let n = St(e, t);
2766
- return n ? (t.preventDefault(), t.stopPropagation(), K(), Et(e, n, !0), Dt(e, n), ie(n), !0) : (ie(null), !1);
2765
+ if (O.current.effectiveEditable) {
2766
+ let n = Ct(e, t);
2767
+ return n ? (t.preventDefault(), t.stopPropagation(), K(), Dt(e, n, !0), Ot(e, n), z(n), !0) : (z(null), !1);
2767
2768
  }
2768
2769
  return Ge(t);
2769
2770
  }
2770
2771
  }
2771
2772
  },
2772
2773
  onSelectionUpdate: ({ editor: e }) => {
2773
- xe(e);
2774
+ Ce(e);
2774
2775
  },
2775
2776
  onCreate: ({ editor: e }) => {
2776
- t && T.current.effectiveEditable && zt(e), Se(e), xe(e), ge();
2777
+ t && O.current.effectiveEditable && Bt(e), we(e), Ce(e), ye();
2777
2778
  },
2778
2779
  onTransaction: ({ editor: e, transaction: t }) => {
2779
- Se(e), (t.docChanged || ft(t)) && ve(), t.docChanged && ie((t) => {
2780
+ we(e), (t.docChanged || ft(t)) && be(), t.docChanged && z((t) => {
2780
2781
  if (!t) return null;
2781
- let n = xt(e, t.pos);
2782
+ let n = St(e, t.pos);
2782
2783
  return n?.kind === t.kind ? n : null;
2783
2784
  });
2784
2785
  },
2785
2786
  onUpdate: ({ editor: e }) => {
2786
- xe(e), T.current.effectiveEditable && be(e), de.current || me.current.onUpdate?.(Be(e, { onContentRead: (t, n) => {
2787
- let r = fe.current;
2788
- r.content !== void 0 && t === r.format && (pe.current = {
2787
+ Ce(e), O.current.effectiveEditable && Se(e), pe.current || _e.current.onUpdate?.(Be(e, { onContentRead: (t, n) => {
2788
+ let r = me.current;
2789
+ r.content !== void 0 && t === r.format && (he.current = {
2789
2790
  content: n,
2790
2791
  format: t,
2791
2792
  doc: e.state.doc
@@ -2793,308 +2794,312 @@ function Ei({ ariaLabel: e, autoFocusFirstTableBodyCell: t = !1, autofocus: n =
2793
2794
  } }));
2794
2795
  }
2795
2796
  });
2796
- H(() => {
2797
- q && (q.setEditable(C), Fe(q, {
2798
- mode: S,
2799
- editable: C
2800
- }), pt(q, C ? "live" : "view"), ge(), C || K());
2797
+ V(() => {
2798
+ q && (q.setEditable(E), Fe(q, {
2799
+ mode: C,
2800
+ editable: E
2801
+ }), mt(q, E ? "live" : "view"), ye(), E || K());
2801
2802
  }, [
2802
2803
  K,
2803
2804
  q,
2804
- S,
2805
2805
  C,
2806
- ge
2807
- ]), H(() => {
2806
+ E,
2807
+ ye
2808
+ ]), V(() => {
2809
+ q && pt(q, w);
2810
+ }, [q, w]), V(() => {
2808
2811
  let e = We(a);
2809
2812
  if (!(!q || r === void 0)) {
2810
- if (Ue(q, pe.current, r, e)) {
2811
- pe.current = null;
2813
+ if (Ue(q, he.current, r, e)) {
2814
+ he.current = null;
2812
2815
  return;
2813
2816
  }
2814
- pe.current = null, !He(q, r, e) && (de.current = !0, q.commands.setContent(r, {
2817
+ he.current = null, !He(q, r, e) && (pe.current = !0, q.commands.setContent(r, {
2815
2818
  contentType: Ve(e),
2816
2819
  emitUpdate: !1
2817
- }), de.current = !1, xe(q), C && be(q), Se(q), ge());
2820
+ }), pe.current = !1, Ce(q), E && Se(q), we(q), ye());
2818
2821
  }
2819
2822
  }, [
2820
2823
  r,
2821
2824
  a,
2822
- C,
2825
+ E,
2823
2826
  q,
2824
- ge,
2825
- xe,
2826
- be,
2827
- Se
2828
- ]), H(() => {
2829
- if (!te) return;
2827
+ ye,
2828
+ Ce,
2829
+ Se,
2830
+ we
2831
+ ]), V(() => {
2832
+ if (!I) return;
2830
2833
  let e = (e) => {
2831
2834
  let t = e.target;
2832
2835
  t instanceof Element && (t.closest(".markweave-slash-menu") || t.closest(".markweave-slash-trigger") || K());
2833
2836
  };
2834
2837
  return document.addEventListener("pointerdown", e, !0), () => document.removeEventListener("pointerdown", e, !0);
2835
- }, [K, te]);
2836
- let Ce = U(() => q ? ot(q) : bi, [
2838
+ }, [K, I]);
2839
+ let Te = H(() => q ? ot(q) : Si, [
2837
2840
  q,
2838
- le,
2839
- M
2840
- ]), we = U(() => q ? Bt(q.state) : yi, [
2841
+ de,
2842
+ N
2843
+ ]), Ee = H(() => q ? Vt(q.state) : xi, [
2841
2844
  q,
2842
- le,
2843
- M,
2844
- ae
2845
- ]), Te = M?.currentNode === "codeBlock", Ee = Te && Ce.language === "mermaid", De = U(() => q ? ht({
2846
- active: Ee,
2847
- mode: R,
2848
- source: Ce.text
2849
- }) : xi, [
2850
- Ce.text,
2845
+ de,
2846
+ N,
2847
+ se
2848
+ ]), De = N?.currentNode === "codeBlock", Oe = De && Te.language === "mermaid", ke = H(() => q ? gt({
2849
+ active: Oe,
2850
+ mode: ie,
2851
+ source: Te.text
2852
+ }) : Ci, [
2853
+ Te.text,
2851
2854
  q,
2852
- Ee,
2853
- R
2854
- ]), Oe = U(() => q ? Rt(q.state) : null, [q, le]), J = U(() => q ? rr(q.state.doc) : tr.items, [q, le]), Y = U(() => ir(J, se), [se, J]), Me = U(() => er(J, Y), [Y, J]), Ne = V(() => {
2855
- if (!q || !J.length) {
2856
- ce(null);
2855
+ Oe,
2856
+ ie
2857
+ ]), J = H(() => q ? zt(q.state) : null, [q, de]), Y = H(() => q ? ir(q.state.doc) : nr.items, [q, de]), Ne = H(() => ar(Y, le), [le, Y]), Ie = H(() => tr(Y, Ne), [Ne, Y]), Le = B(() => {
2858
+ if (!q || !Y.length) {
2859
+ ue(null);
2857
2860
  return;
2858
2861
  }
2859
- let e = nr(q, J);
2860
- ce((t) => t === e ? t : e);
2861
- }, [q, J]);
2862
- H(() => {
2863
- ce((e) => {
2864
- let t = ir(J, e);
2862
+ let e = rr(q, Y);
2863
+ ue((t) => t === e ? t : e);
2864
+ }, [q, Y]);
2865
+ V(() => {
2866
+ ue((e) => {
2867
+ let t = ar(Y, e);
2865
2868
  return e === t ? e : t;
2866
2869
  });
2867
- }, [J]), H(() => {
2868
- if (!q || !J.length || typeof window > "u") return;
2870
+ }, [Y]), V(() => {
2871
+ if (!q || !Y.length || typeof window > "u") return;
2869
2872
  let e = null, t = () => {
2870
- e !== null && Ti(e), e = wi(() => {
2871
- e = null, Ne();
2873
+ e !== null && Di(e), e = Ei(() => {
2874
+ e = null, Le();
2872
2875
  });
2873
- }, n = Ci(q.view.dom);
2876
+ }, n = Ti(q.view.dom);
2874
2877
  return window.addEventListener("scroll", t, { passive: !0 }), window.addEventListener("resize", t), n?.addEventListener("scroll", t, { passive: !0 }), t(), () => {
2875
- window.removeEventListener("scroll", t), window.removeEventListener("resize", t), n?.removeEventListener("scroll", t), e !== null && Ti(e);
2878
+ window.removeEventListener("scroll", t), window.removeEventListener("resize", t), n?.removeEventListener("scroll", t), e !== null && Di(e);
2876
2879
  };
2877
2880
  }, [
2878
2881
  q,
2879
- J.length,
2880
- Ne
2882
+ Y.length,
2883
+ Le
2881
2884
  ]);
2882
- let Ie = U(() => Ke({
2883
- revision: le,
2884
- mode: S,
2885
- editable: C,
2886
- toc: Me,
2887
- selection: M,
2885
+ let X = H(() => Ke({
2886
+ revision: de,
2887
+ mode: C,
2888
+ editable: E,
2889
+ toc: Ie,
2890
+ selection: N,
2888
2891
  slash: P,
2889
- table: we,
2890
- tableInteraction: ae,
2891
- codeBlock: Ce,
2892
- mermaid: De,
2893
- tableDebugSnapshot: Oe
2892
+ table: Ee,
2893
+ tableInteraction: se,
2894
+ codeBlock: Te,
2895
+ mermaid: ke,
2896
+ tableDebugSnapshot: J
2894
2897
  }), [
2895
- Ce,
2896
- S,
2898
+ Te,
2897
2899
  C,
2898
- De,
2899
- le,
2900
- M,
2900
+ E,
2901
+ ke,
2902
+ de,
2903
+ N,
2901
2904
  P,
2902
- Oe,
2903
- we,
2904
- ae,
2905
- Me
2905
+ J,
2906
+ Ee,
2907
+ se,
2908
+ Ie
2906
2909
  ]);
2907
- H(() => {
2908
- g?.(Ie);
2909
- }, [g, Ie]), H(() => {
2910
- b?.(Me);
2911
- }, [b, Me]);
2912
- let Le = V((e, t) => {
2913
- if (!(!q || !C) && kt(e)) {
2910
+ V(() => {
2911
+ _?.(X);
2912
+ }, [_, X]), V(() => {
2913
+ x?.(Ie);
2914
+ }, [x, Ie]);
2915
+ let Z = B((e, t) => {
2916
+ if (!(!q || !E) && At(e)) {
2914
2917
  if (e.inputKind && !t?.emoji && !t?.uploadResult) {
2915
- ne(e);
2918
+ R(e);
2916
2919
  return;
2917
2920
  }
2918
- Mt(q, P, e, t), F((e) => Lt(e, { type: "execute" })), K();
2921
+ Nt(q, P, e, t), F((e) => Rt(e, { type: "execute" })), K();
2919
2922
  }
2920
2923
  }, [
2921
2924
  K,
2922
- C,
2925
+ E,
2923
2926
  q,
2924
2927
  P
2925
- ]), X = V((e) => {
2926
- F((t) => Lt(t, {
2928
+ ]), Q = B((e) => {
2929
+ F((t) => Rt(t, {
2927
2930
  type: "set-active",
2928
2931
  index: e,
2929
- optionCount: he.length
2932
+ optionCount: G.length
2930
2933
  }));
2931
- }, [he.length]), Z = V((e) => {
2932
- if (!q || L || !C) return;
2933
- let t = At(P, he, e.key, { isComposing: e.nativeEvent.isComposing || ze(q.state) });
2934
+ }, [G.length]), Re = B((e) => {
2935
+ if (!q || L || !E) return;
2936
+ let t = jt(P, G, e.key, { isComposing: e.nativeEvent.isComposing || ze(q.state) });
2934
2937
  if (t.type !== "ignore") {
2935
2938
  if (t.type === "close") {
2936
- e.preventDefault(), F((e) => Lt(e, { type: "escape" })), K();
2939
+ e.preventDefault(), F((e) => Rt(e, { type: "escape" })), K();
2937
2940
  return;
2938
2941
  }
2939
2942
  if (t.type === "move-active") {
2940
- e.preventDefault(), F((e) => Lt(e, {
2943
+ e.preventDefault(), F((e) => Rt(e, {
2941
2944
  type: "move-active",
2942
2945
  delta: t.delta,
2943
2946
  optionCount: t.optionCount
2944
2947
  }));
2945
2948
  return;
2946
2949
  }
2947
- t.type === "execute-active" && (e.preventDefault(), Le(t.command));
2950
+ t.type === "execute-active" && (e.preventDefault(), Z(t.command));
2948
2951
  }
2949
2952
  }, [
2950
2953
  K,
2951
- C,
2954
+ E,
2952
2955
  q,
2953
- he,
2954
- Le,
2956
+ G,
2957
+ Z,
2955
2958
  L,
2956
2959
  P
2957
- ]), Q = U(() => ({
2960
+ ]), qe = H(() => ({
2958
2961
  closeSlashMenu: K,
2959
- focusFirstTableBodyCell: () => q ? zt(q) : !1,
2962
+ focusFirstTableBodyCell: () => q ? Bt(q) : !1,
2960
2963
  setContent: (e, t = {}) => {
2961
2964
  if (!q) return !1;
2962
2965
  let n = We(t.format);
2963
2966
  return q.commands.setContent(e, {
2964
2967
  contentType: Ve(n),
2965
2968
  emitUpdate: t.emitUpdate ?? !1
2966
- }), t.focusFirstTableBodyCell && zt(q), xe(q), C && be(q), Se(q), ge(), !0;
2969
+ }), t.focusFirstTableBodyCell && Bt(q), Ce(q), E && Se(q), we(q), ye(), !0;
2967
2970
  }
2968
2971
  }), [
2969
2972
  K,
2970
- C,
2973
+ E,
2971
2974
  q,
2972
- ge,
2973
- xe,
2974
- be,
2975
- Se
2975
+ ye,
2976
+ Ce,
2977
+ Se,
2978
+ we
2976
2979
  ]);
2977
2980
  return {
2978
2981
  editor: q,
2979
- frameProps: U(() => ({
2982
+ frameProps: H(() => ({
2980
2983
  className: "markweave-editor-frame",
2981
- "aria-label": e ?? O.common.editorAriaLabel,
2984
+ "aria-label": e ?? A.common.editorAriaLabel,
2982
2985
  "data-testid": "markweave-editor-frame",
2983
- "data-markweave-mode": S,
2986
+ "data-markweave-mode": C,
2987
+ "data-markweave-theme": w,
2984
2988
  "data-markweave-inner-toc": l ? "true" : "false",
2985
- "data-markweave-inner-toc-placement": ee,
2986
- "data-mermaid-mode": De.mode,
2987
- "data-table-focus-mode": we.mode,
2988
- onKeyDownCapture: Z
2989
+ "data-markweave-inner-toc-placement": T,
2990
+ "data-mermaid-mode": ke.mode,
2991
+ "data-table-focus-mode": Ee.mode,
2992
+ onKeyDownCapture: Re
2989
2993
  }), [
2990
2994
  e,
2991
- S,
2992
- Z,
2995
+ C,
2996
+ Re,
2993
2997
  l,
2994
- De.mode,
2995
- O.common.editorAriaLabel,
2996
- ee,
2997
- we.mode
2998
+ ke.mode,
2999
+ A.common.editorAriaLabel,
3000
+ T,
3001
+ w,
3002
+ Ee.mode
2998
3003
  ]),
2999
- overlayProps: U(() => ({
3000
- floatingToolbar: q && C ? {
3004
+ overlayProps: H(() => ({
3005
+ floatingToolbar: q && E ? {
3001
3006
  editor: q,
3002
- messages: O,
3003
- selectionSnapshot: M,
3004
- onRewriteSelection: h,
3005
- onExtractToNote: m
3007
+ messages: A,
3008
+ selectionSnapshot: N,
3009
+ onRewriteSelection: g,
3010
+ onExtractToNote: h
3006
3011
  } : null,
3007
- slashCommandMenu: q && C ? {
3008
- commands: he,
3012
+ slashCommandMenu: q && E ? {
3013
+ commands: G,
3009
3014
  state: P,
3010
- position: te,
3015
+ position: I,
3011
3016
  inputCommand: L,
3012
- messages: O,
3013
- onActiveIndexChange: X,
3014
- onInputCommandChange: ne,
3015
- onSelect: Le,
3016
- onUpload: _
3017
+ messages: A,
3018
+ onActiveIndexChange: Q,
3019
+ onInputCommandChange: R,
3020
+ onSelect: Z,
3021
+ onUpload: v
3017
3022
  } : null,
3018
- tableControls: q && C ? {
3023
+ tableControls: q && E ? {
3019
3024
  editor: q,
3020
- active: we.active,
3021
- interactionState: ae,
3022
- messages: O,
3023
- onCopyPayload: y,
3024
- onCommandResult: v,
3025
- onEditWithAi: p
3025
+ active: Ee.active,
3026
+ interactionState: se,
3027
+ messages: A,
3028
+ onCopyPayload: b,
3029
+ onCommandResult: y,
3030
+ onEditWithAi: m
3026
3031
  } : null,
3027
- tableSelectionOverlay: q && C ? {
3032
+ tableSelectionOverlay: q && E ? {
3028
3033
  editor: q,
3029
- focusState: we
3034
+ focusState: Ee
3030
3035
  } : null,
3031
3036
  codeBlockControls: q ? {
3032
3037
  editor: q,
3033
- active: C && Te,
3034
- mermaidMode: R,
3035
- onMermaidModeChange: z,
3036
- readOnly: !C
3038
+ active: E && De,
3039
+ mermaidMode: ie,
3040
+ onMermaidModeChange: ae,
3041
+ readOnly: !E
3037
3042
  } : null,
3038
- innerToc: q && l && Me.items.length ? {
3043
+ innerToc: q && l && Ie.items.length ? {
3039
3044
  editor: q,
3040
- editable: C,
3041
- messages: O,
3042
- placement: ee,
3043
- state: Me
3045
+ editable: E,
3046
+ messages: A,
3047
+ placement: T,
3048
+ state: Ie
3044
3049
  } : null,
3045
- mathEditorPopover: q && C && re ? {
3050
+ mathEditorPopover: q && E && oe ? {
3046
3051
  editor: q,
3047
- messages: O,
3048
- target: re,
3049
- onClose: () => ie(null)
3052
+ messages: A,
3053
+ target: oe,
3054
+ onClose: () => z(null)
3050
3055
  } : null
3051
3056
  }), [
3052
- C,
3057
+ E,
3053
3058
  q,
3054
- he,
3059
+ G,
3055
3060
  l,
3056
- Te,
3057
- R,
3058
- O,
3059
- re,
3060
- p,
3061
+ De,
3062
+ ie,
3063
+ A,
3064
+ oe,
3061
3065
  m,
3062
3066
  h,
3063
- _,
3067
+ g,
3064
3068
  v,
3065
3069
  y,
3066
- Le,
3067
- M,
3068
- X,
3070
+ b,
3071
+ Z,
3072
+ N,
3073
+ Q,
3069
3074
  L,
3070
- te,
3075
+ I,
3071
3076
  P,
3072
- we,
3073
- ae,
3074
- Me
3077
+ Ee,
3078
+ se,
3079
+ Ie
3075
3080
  ]),
3076
- runtimeSnapshot: Ie,
3077
- actions: Q
3081
+ runtimeSnapshot: X,
3082
+ actions: qe
3078
3083
  };
3079
3084
  }
3080
- function Di({ className: e, ...n }) {
3081
- let r = Ei(n);
3085
+ function ki({ className: e, ...n }) {
3086
+ let r = Oi(n);
3082
3087
  if (!r.editor) return null;
3083
3088
  let i = [r.frameProps.className, e].filter(Boolean).join(" ");
3084
3089
  return /* @__PURE__ */ Q("section", {
3085
3090
  ...r.frameProps,
3086
3091
  className: i,
3087
3092
  children: [
3088
- r.overlayProps.floatingToolbar ? /* @__PURE__ */ Z(Kr, { ...r.overlayProps.floatingToolbar }) : null,
3089
- r.overlayProps.slashCommandMenu ? /* @__PURE__ */ Z(pi, { ...r.overlayProps.slashCommandMenu }) : null,
3090
- r.overlayProps.tableControls ? /* @__PURE__ */ Z(hi, { ...r.overlayProps.tableControls }) : null,
3091
- r.overlayProps.tableSelectionOverlay ? /* @__PURE__ */ Z(gi, { ...r.overlayProps.tableSelectionOverlay }) : null,
3092
- r.overlayProps.codeBlockControls ? /* @__PURE__ */ Z(Tr, { ...r.overlayProps.codeBlockControls }) : null,
3093
- r.overlayProps.innerToc ? /* @__PURE__ */ Z(vi, { ...r.overlayProps.innerToc }) : null,
3094
- r.overlayProps.mathEditorPopover ? /* @__PURE__ */ Z(ii, { ...r.overlayProps.mathEditorPopover }) : null,
3093
+ r.overlayProps.floatingToolbar ? /* @__PURE__ */ Z(Jr, { ...r.overlayProps.floatingToolbar }) : null,
3094
+ r.overlayProps.slashCommandMenu ? /* @__PURE__ */ Z(hi, { ...r.overlayProps.slashCommandMenu }) : null,
3095
+ r.overlayProps.tableControls ? /* @__PURE__ */ Z(_i, { ...r.overlayProps.tableControls }) : null,
3096
+ r.overlayProps.tableSelectionOverlay ? /* @__PURE__ */ Z(vi, { ...r.overlayProps.tableSelectionOverlay }) : null,
3097
+ r.overlayProps.codeBlockControls ? /* @__PURE__ */ Z(Dr, { ...r.overlayProps.codeBlockControls }) : null,
3098
+ r.overlayProps.innerToc ? /* @__PURE__ */ Z(bi, { ...r.overlayProps.innerToc }) : null,
3099
+ r.overlayProps.mathEditorPopover ? /* @__PURE__ */ Z(oi, { ...r.overlayProps.mathEditorPopover }) : null,
3095
3100
  /* @__PURE__ */ Z(t, { editor: r.editor })
3096
3101
  ]
3097
3102
  });
3098
3103
  }
3099
3104
  //#endregion
3100
- export { Di as MarkweaveEditor, Sr as createMarkweaveEditorExtensions, Sr as createMarkweaveReactEditorExtensions, Ei as useMarkweaveEditorController };
3105
+ export { ki as MarkweaveEditor, wr as createMarkweaveEditorExtensions, wr as createMarkweaveReactEditorExtensions, Oi as useMarkweaveEditorController };