@markweave/react 0.1.7 → 0.1.8

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,238 +1,241 @@
1
1
  import { createMarkweaveEditorExtensions as e } from "markweave/internal/editor-core/create-editor-extensions";
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 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
- import { openMarkweaveImagePreview as Le } from "markweave/internal/plugins/media/image-preview";
2
+ import { getLocalizedSlashCommandSpecs as t, getMarkweaveMessages as n, normalizeMarkweaveLang as r } from "markweave/internal/i18n";
3
+ import { EditorContent as i, NodeViewWrapper as a, ReactNodeViewRenderer as o, useEditor as s } from "@tiptap/react";
4
+ import { AlertTriangle as c, AlignCenter as l, AlignJustify as u, AlignLeft as d, AlignRight as f, Bold as p, Braces as m, Captions as h, Check as g, CheckCircle2 as _, ChevronDown as v, ChevronUp as y, CircleX as b, Code2 as x, Copy as S, CornerDownLeft as C, Download as w, ExternalLink as T, Eye as E, Heading1 as D, Heading2 as O, Heading3 as k, Image as A, ImageUp as j, IndentDecrease as M, IndentIncrease as ee, Info as N, Italic as P, Lightbulb as te, Link2 as F, List as I, ListChecks as ne, ListOrdered as L, Minus as re, MoreVertical as R, Paperclip as z, Pencil as ie, Quote as ae, Replace as oe, Sigma as se, SmilePlus as ce, Sparkles as le, Strikethrough as ue, Subscript as de, Superscript as fe, Table2 as pe, Text as me, Trash2 as he, Type as ge, Underline as _e, Upload as ve, Video as ye } from "lucide-react";
5
+ import { useCallback as B, useEffect as V, useLayoutEffect as be, useMemo as H, useRef as U, useState as W, useSyncExternalStore as G } from "react";
6
+ import { detectUploadSource as xe, getDirectUploadResult as Se, resolveMarkweaveUploadResult as Ce } from "markweave/internal/plugins/slash-command/upload";
7
+ import { MarkweaveCoreImage as we, MarkweaveCoreVideo as Te, attrsFromMarkweaveImageUploadResult as K, attrsFromMarkweaveVideoUploadResult as Ee, attrsFromMarkweaveVideoUrl as De, clampMarkweaveImageWidth as Oe, createMarkweaveImageUploadRequest as ke, createMarkweaveVideoUploadRequest as q, downloadMarkweaveImage as Ae, markweaveVideoIframeAllow as je, normalizeMarkweaveCoreImageAlign as Me, normalizeMarkweaveVideoEmbedUrl as Ne, numberAttribute as Pe, stringAttribute as J } from "markweave/internal/plugins/media/core-media-nodes";
8
+ import { getMarkweaveEditorModeState as Y, isMarkweaveEditorLiveEditable as Fe, normalizeMarkweaveEditorMode as Ie, setMarkweaveEditorModeState as Le, subscribeToMarkweaveEditorMode as Re } from "markweave/internal/core/editor-mode-state";
9
+ import { openMarkweaveImagePreview as ze } from "markweave/internal/plugins/media/image-preview";
10
10
  import { Fragment as X, jsx as Z, jsxs as Q } from "react/jsx-runtime";
11
- import { createMarkweaveAdapterMediaExtensions as Re } from "markweave/internal/plugins/media/media-extension-factory";
12
- import { isEditorComposing as ze } from "markweave/internal/editor-core/composition-guard";
13
- import { createMarkweaveEditorUpdatePayload as Be, getMarkweaveContentType as Ve, isEditorContentCurrent as He, isMarkweaveControlledContentEchoCurrent as Ue, normalizeMarkweaveContentFormat as We } from "markweave/internal/editor-core/editor-content";
14
- import { openMarkweaveReadonlyLinkFromEvent as Ge } from "markweave/internal/editor-core/readonly-link";
15
- import { createMarkweaveEditorRuntimeSnapshot as Ke } from "markweave/internal/editor-core/runtime-snapshot";
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
- 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, 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";
11
+ import { createMarkweaveAdapterMediaExtensions as Be } from "markweave/internal/plugins/media/media-extension-factory";
12
+ import { normalizeMarkweaveLinkCardAttrs as Ve, normalizeMarkweaveLinkCardHref as He, replaceMarkweaveLinkCardWithLink as Ue } from "markweave/internal/plugins/link-card/link-card";
13
+ import { openMarkweaveLinkCardComposer as We } from "markweave/internal/plugins/link-card/link-card-composer";
14
+ import { MarkweaveLinkCard as Ge } from "markweave/internal/plugins/link-card/link-card-node";
15
+ import { isEditorComposing as Ke } from "markweave/internal/editor-core/composition-guard";
16
+ import { createMarkweaveEditorUpdatePayload as qe, getMarkweaveContentType as Je, isEditorContentCurrent as Ye, isMarkweaveControlledContentEchoCurrent as Xe, normalizeMarkweaveContentFormat as Ze } from "markweave/internal/editor-core/editor-content";
17
+ import { openMarkweaveReadonlyLinkFromEvent as Qe } from "markweave/internal/editor-core/readonly-link";
18
+ import { createMarkweaveEditorRuntimeSnapshot as $e } from "markweave/internal/editor-core/runtime-snapshot";
19
+ import { advanceFloatingToolbarMotionState as et, areEditorSelectionSnapshotsEquivalent as tt, calculateFloatingToolbarFrameShift as nt, calculateFloatingToolbarPopoverPlacement as rt, calculateFloatingToolbarTopBoundary as it, createSelectionSnapshot as at, getFloatingToolbarFloatingOptions as ot, getFloatingToolbarState as st, markweaveRuntimeProjectionDelayMs as ct, shouldShowFloatingToolbar as lt, transitionFloatingToolbarState as ut } from "markweave/internal/editor-core/selection-state";
20
+ import { codeBlockCollapsePluginKey as dt, copyActiveCodeBlock as ft, getActiveCodeBlockState as pt, getCodeBlockCopyFeedbackSnapshot as mt, markweaveCodeBlockBehavior as ht, setCodeBlockCollapsedAtPosition as gt, setCodeBlockLanguageAtPosition as _t, setCodeBlockMermaidPreviewModeAtPosition as vt } from "markweave/internal/plugins/codeblock/codeblock-behavior";
21
+ import { isMermaidInlinePreviewTransaction as yt, setMarkweaveMermaidTheme as bt, setMermaidInlinePreviewEditorMode as xt, setReadonlyMermaidPreviewMode as St } from "markweave/internal/plugins/mermaid/mermaid-inline-preview";
22
+ import { getMermaidPreviewState as Ct } from "markweave/internal/plugins/mermaid/mermaid-renderer";
23
+ import { applyMarkweaveMathLatex as wt, calculateMarkweaveMathPopoverPosition as Tt, getMarkweaveMathAnchorRect as Et, getMarkweaveMathBlockIndex as Dt, getMarkweaveMathRenderedHtml as Ot, getMarkweaveMathTargetAtPos as kt, getMarkweaveMathTargetFromDomEvent as At, getMarkweaveMathTargetFromSelection as jt, renderMarkweaveMathPreview as Mt, setMarkweaveMathEditingDomState as Nt, setMarkweaveMathEditingDomStateInView as Pt, setMarkweaveMathSelectionInView as Ft } from "markweave/internal/plugins/math/math-ui-model";
24
+ import { filterSlashCommands as It, isExecutableSlashCommand as Lt } from "markweave/internal/plugins/slash-command/command-spec";
25
+ import { getSlashCommandKeyboardAction as Rt, isSlashCommandMenuState as zt } from "markweave/internal/plugins/slash-command/slash-keyboard";
26
+ import { executeSlashCommand as Bt, getNextSlashCommandState as Vt, getSlashCommandAnchoredMenuPosition as Ht, getSlashCommandContext as Ut } from "markweave/internal/plugins/slash-command/slash-runtime";
27
+ import { initialSlashCommandState as Wt, reduceSlashCommandState as Gt } from "markweave/internal/plugins/slash-command/slash-state";
28
+ import { getFirstTableDebugSnapshot as Kt } from "markweave/internal/plugins/table/table-debug-snapshot";
29
+ import { focusFirstTableBodyCell as qt } from "markweave/internal/plugins/table/table-focus-position";
30
+ import { getTableFocusState as Jt } from "markweave/internal/plugins/table/table-focus-state";
31
+ import { getTableSelectionOverlayState as Yt, initialTableInteractionState as Xt, tableInteractionPluginKey as Zt } from "markweave/internal/plugins/table/table-interaction-layer";
32
+ import { calculateCodeBlockLanguageMenuPosition as Qt, clampFullscreenScale as $t, codeBlockCopyFeedbackTimeoutMs as en, copyCodeBlockText as tn, createCodeBlockOverlayPosition as nn, createMermaidFullscreenViewerState as rn, createMermaidTabPosition as an, focusCodeBlockTarget as on, formatCodeBlockLanguageLabel as sn, formatFullscreenZoom as cn, getActiveCodeBlockElement as ln, getAnchoredRect as un, getCodeBlockLanguageItems as dn, getCodeBlockPositionFromEventTarget as fn, getCodeBlockStateAtPosition as pn, getFrameElement as mn, getMermaidCodeBlockTargets as hn, getMermaidSvgMarkup as gn, isCodeBlockTargetCollapsed as _n, mergeStableMermaidTabPositions as vn, mermaidFullscreenZoomStep as yn, moveMermaidFullscreenViewer as bn } from "markweave/internal/plugins/codeblock/codeblock-ui-model";
33
+ import { BubbleMenu as xn } from "@tiptap/react/menus";
34
+ import { createMarkweaveFrameScheduler as Sn } from "markweave/internal/editor-core/frame-scheduler";
35
+ import { applyFloatingToolbarLink as Cn, createFloatingToolbarAssistantRequest as wn, getFloatingToolbarButtonModels as Tn, getFloatingToolbarHighlightColorOptions as En, getFloatingToolbarLinkHref as Dn, getFloatingToolbarMessageSet as On, getFloatingToolbarMoreActions as kn, getFloatingToolbarTextColorOptions as An, getFloatingToolbarTooltipModel as jn, getFloatingToolbarTurnIntoOptions as Mn, isFloatingToolbarMoreActionActive as Nn, isFloatingToolbarTurnIntoActive as Pn, openFloatingToolbarLinkHref as Fn, preventFloatingToolbarPointerFocusLoss as In, removeFloatingToolbarLink as Ln, runFloatingToolbarMoreAction as Rn, setFloatingToolbarHighlightColor as zn, setFloatingToolbarTextColor as Bn, setFloatingToolbarTurnInto as Vn } from "markweave/internal/editor-core/floating-toolbar-model";
36
+ import { normalizeMarkdownLinkHref as Hn } from "markweave/internal/plugins/markdown/markdown-input";
37
+ import { setMarkweaveTableMenuAxisTarget as Un } from "markweave/internal/plugins/table/table-clipboard";
38
+ import { calculateAnchoredTableMenuPosition as Wn, calculateTableEdgeHandlePosition as Gn, canRunTableCommand as Kn, executeTableMenuCommand as qn, formatTableCopyFeedback as Jn, getActiveTableElement as Yn, getAvailableCellMenuCommandSpecs as Xn, getTableAxisTargetRect as Zn, getTableControlAxisSelectionModel as Qn, getTableEditWithAiRequest as $n, getTableMenuItemGroup as er, getTableMenuItemLabel as tr, getTableMenuItems as nr, getTableSelectionTargetRect as rr, measureTableSelectionOverlay as ir, selectTableAxisFromCell as ar, tableCopyFeedbackTimeoutMs as or, tableMenuLabel as sr } from "markweave/internal/plugins/table/table-ui-model";
39
+ import { createMarkweaveTocState as cr, emptyMarkweaveTocState as lr, getActiveMarkweaveTocId as ur, getMarkweaveTocItems as dr, getValidMarkweaveTocActiveId as fr, normalizeMarkweaveInnerTocPlacement as pr, observeMarkweaveInnerTocContainerPosition as mr, scrollToMarkweaveTocItem as hr } from "markweave/internal/core/toc-state";
40
+ import { normalizeMarkweaveTheme as gr } from "markweave/internal/core/theme";
38
41
  //#region src/editor-mode-state.ts
39
- var ur = {
42
+ var _r = {
40
43
  mode: "live",
41
44
  editable: !0
42
45
  };
43
- function dr(e) {
44
- return ge((t) => Ie(e, t), () => Y(e), () => ur);
46
+ function vr(e) {
47
+ return G((t) => Re(e, t), () => Y(e), () => _r);
45
48
  }
46
49
  //#endregion
47
50
  //#region src/media/image-node.tsx
48
- var fr = De;
49
- function pr(e) {
51
+ var yr = Me;
52
+ function br(e) {
50
53
  return e instanceof Element && !!e.closest("[data-markweave-image-ui=\"true\"]");
51
54
  }
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 = () => {
54
- f && Le({
55
- src: f,
56
- alt: J(a.attrs.alt) ?? "",
55
+ function xr(e) {
56
+ let { deleteNode: t, editor: r, getPos: i, node: o, selected: s, updateAttributes: c } = e, l = e.extension.options, u = l.messages ?? n("zh"), d = u.image, f = Fe(vr(r)), p = J(o.attrs.src), m = yr(o.attrs.align), h = Pe(o.attrs.width), g = J(o.attrs.caption), _ = U(null), v = U(null), [y, b] = W(!1), [x, S] = W(!1), [C, w] = W(!1), [T, D] = W(""), [O, k] = W(null), [A, j] = W(!1), [M, ee] = W(!!g), [N, P] = W(g ?? ""), te = f && (!p || x), F = () => {
57
+ p && ze({
58
+ src: p,
59
+ alt: J(o.attrs.alt) ?? "",
57
60
  messages: {
58
- dialogAriaLabel: u.previewDialogAriaLabel,
59
- zoomOut: u.previewZoomOut,
60
- zoomIn: u.previewZoomIn,
61
- reset: u.previewReset,
62
- close: u.previewClose
61
+ dialogAriaLabel: d.previewDialogAriaLabel,
62
+ zoomOut: d.previewZoomOut,
63
+ zoomIn: d.previewZoomIn,
64
+ reset: d.previewReset,
65
+ close: d.previewClose
63
66
  }
64
67
  });
65
68
  };
66
69
  V(() => {
67
- A || M(h ?? "");
68
- }, [h, A]);
69
- let P = () => {
70
- if (!d) return;
70
+ M || P(g ?? "");
71
+ }, [g, M]);
72
+ let I = () => {
73
+ if (!f) return;
71
74
  let e = i();
72
75
  typeof e == "number" && r.chain().focus().setNodeSelection(e).run();
73
- }, F = () => {
74
- if (d) {
75
- if (E(""), O(null), w(!1), f) {
76
- x(!1);
76
+ }, ne = () => {
77
+ if (f) {
78
+ if (D(""), k(null), w(!1), p) {
79
+ S(!1);
77
80
  return;
78
81
  }
79
82
  t();
80
83
  }
81
- }, I = async (e) => {
82
- if (d) {
83
- O(null), k(!0);
84
+ }, L = async (e) => {
85
+ if (f) {
86
+ k(null), j(!0);
84
87
  try {
85
- let t = await G(we(e, f && b ? "image-replace" : "image-insert"), c.onUpload);
86
- s(K(a.attrs, t)), x(!1), E("");
88
+ let t = await Ce(ke(e, p && x ? "image-replace" : "image-insert"), l.onUpload);
89
+ c(K(o.attrs, t)), S(!1), D("");
87
90
  } catch (e) {
88
- O(e instanceof Error ? e.message : u.uploadFailedError);
91
+ k(e instanceof Error ? e.message : d.uploadFailedError);
89
92
  } finally {
90
- k(!1), w(!1);
93
+ j(!1), w(!1);
91
94
  }
92
95
  }
93
96
  }, re = () => {
94
- if (d) {
97
+ if (f) {
95
98
  if (!T.trim()) {
96
- O(u.uploadRequiredError);
99
+ k(d.uploadRequiredError);
97
100
  return;
98
101
  }
99
- I(_e(T));
102
+ L(xe(T));
100
103
  }
101
- }, L = (e) => {
102
- !d || !e || I({
104
+ }, R = (e) => {
105
+ !f || !e || L({
103
106
  type: "file",
104
107
  file: e,
105
108
  mimeType: e.type
106
109
  });
107
- }, R = (e) => {
108
- L(e.currentTarget.files?.[0] ?? null), e.currentTarget.value = "";
110
+ }, z = (e) => {
111
+ R(e.currentTarget.files?.[0] ?? null), e.currentTarget.value = "";
109
112
  }, ie = (e) => {
110
- e.preventDefault(), e.stopPropagation(), d && L(e.dataTransfer.files?.[0] ?? null);
113
+ e.preventDefault(), e.stopPropagation(), f && R(e.dataTransfer.files?.[0] ?? null);
111
114
  }, ae = () => {
112
- d && (j((e) => !e), A || M(h ?? ""));
115
+ f && (ee((e) => !e), M || P(g ?? ""));
113
116
  }, oe = (e) => {
114
- d && (M(e), s({ caption: e.trim() ? e : null }));
115
- }, z = (e, t) => {
116
- if (t.preventDefault(), t.stopPropagation(), !d) return;
117
- P();
118
- let n = g.current;
117
+ f && (P(e), c({ caption: e.trim() ? e : null }));
118
+ }, se = (e, t) => {
119
+ if (t.preventDefault(), t.stopPropagation(), !f) return;
120
+ I();
121
+ let n = _.current;
119
122
  if (!n) return;
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) => {
123
+ let r = t.clientX, i = n.getBoundingClientRect().width || h || 320, a = n.closest(".markweave-editor-surface")?.getBoundingClientRect().width ?? n.parentElement?.getBoundingClientRect().width ?? i, o = (t) => {
121
124
  let n = e === "right" ? t.clientX - r : r - t.clientX;
122
- s({ width: Ce(i + n, a) });
123
- }, c = () => {
124
- window.removeEventListener("pointermove", o), window.removeEventListener("pointerup", c);
125
+ c({ width: Oe(i + n, a) });
126
+ }, s = () => {
127
+ window.removeEventListener("pointermove", o), window.removeEventListener("pointerup", s);
125
128
  };
126
- window.addEventListener("pointermove", o), window.addEventListener("pointerup", c, { once: !0 });
129
+ window.addEventListener("pointermove", o), window.addEventListener("pointerup", s, { once: !0 });
127
130
  };
128
- return /* @__PURE__ */ Z(n, {
131
+ return /* @__PURE__ */ Z(a, {
129
132
  as: "figure",
130
133
  className: "markweave-image-node",
131
134
  "data-testid": "markweave-image-node",
132
- "data-align": p,
133
- "data-selected": d && o ? "true" : "false",
134
- "data-hovered": v ? "true" : "false",
135
- "data-empty": N ? "true" : "false",
136
- onPointerEnter: () => y(!0),
137
- onPointerLeave: () => y(!1),
135
+ "data-align": m,
136
+ "data-selected": f && s ? "true" : "false",
137
+ "data-hovered": y ? "true" : "false",
138
+ "data-empty": te ? "true" : "false",
139
+ onPointerEnter: () => b(!0),
140
+ onPointerLeave: () => b(!1),
138
141
  onMouseDown: (e) => {
139
- d && !pr(e.target) && P();
142
+ f && !br(e.target) && I();
140
143
  },
141
- children: N ? /* @__PURE__ */ Z(hr, {
144
+ children: te ? /* @__PURE__ */ Z(Sr, {
142
145
  dragActive: C,
143
- error: D,
146
+ error: O,
144
147
  inputValue: T,
145
- isSubmitting: ee,
146
- fileInputRef: _,
147
- messages: l,
148
- onCancel: F,
148
+ isSubmitting: A,
149
+ fileInputRef: v,
150
+ messages: u,
151
+ onCancel: ne,
149
152
  onDrop: ie,
150
153
  onDragActiveChange: w,
151
- onFileChange: R,
152
- onInputChange: E,
154
+ onFileChange: z,
155
+ onInputChange: D,
153
156
  onSubmit: re
154
157
  }) : /* @__PURE__ */ Q(X, { children: [
155
- d ? /* @__PURE__ */ Z(gr, {
156
- align: p,
157
- captionActive: A || !!h,
158
- messages: l,
159
- onAlign: (e) => s({ align: e }),
158
+ f ? /* @__PURE__ */ Z(Cr, {
159
+ align: m,
160
+ captionActive: M || !!g,
161
+ messages: u,
162
+ onAlign: (e) => c({ align: e }),
160
163
  onCaption: ae,
161
164
  onDelete: t,
162
165
  onDownload: () => {
163
- f && Te(f);
166
+ p && Ae(p);
164
167
  },
165
- onPreview: ne,
168
+ onPreview: F,
166
169
  onReplace: () => {
167
- E(""), O(null), x(!0);
170
+ D(""), k(null), S(!0);
168
171
  }
169
172
  }) : null,
170
173
  /* @__PURE__ */ Q("div", {
171
174
  className: "markweave-image-box",
172
- ref: g,
173
- style: m ? { width: `${m}px` } : void 0,
175
+ ref: _,
176
+ style: h ? { width: `${h}px` } : void 0,
174
177
  children: [
175
- f ? /* @__PURE__ */ Z("img", {
178
+ p ? /* @__PURE__ */ Z("img", {
176
179
  className: "markweave-image",
177
- src: f,
178
- alt: J(a.attrs.alt) ?? "",
179
- title: J(a.attrs.title) ?? void 0,
180
+ src: p,
181
+ alt: J(o.attrs.alt) ?? "",
182
+ title: J(o.attrs.title) ?? void 0,
180
183
  draggable: !1
181
184
  }) : /* @__PURE__ */ Z("div", {
182
185
  className: "markweave-image-readonly-empty",
183
186
  "data-testid": "markweave-image-readonly-empty",
184
187
  "aria-hidden": "true"
185
188
  }),
186
- !d && f ? /* @__PURE__ */ Q("button", {
189
+ !f && p ? /* @__PURE__ */ Q("button", {
187
190
  type: "button",
188
191
  className: "markweave-image-preview-trigger",
189
192
  "data-testid": "markweave-image-preview",
190
193
  "data-markweave-image-ui": "true",
191
- "aria-label": u.preview,
192
- title: u.preview,
194
+ "aria-label": d.preview,
195
+ title: d.preview,
193
196
  onMouseDown: (e) => e.preventDefault(),
194
- onClick: ne,
195
- children: [/* @__PURE__ */ Z(S, {
197
+ onClick: F,
198
+ children: [/* @__PURE__ */ Z(E, {
196
199
  size: 16,
197
200
  strokeWidth: 1.8
198
201
  }), /* @__PURE__ */ Z("span", {
199
202
  className: "markweave-image-tooltip",
200
203
  role: "tooltip",
201
- children: u.preview
204
+ children: d.preview
202
205
  })]
203
206
  }) : null,
204
- d ? /* @__PURE__ */ Z(vr, {
207
+ f ? /* @__PURE__ */ Z(Tr, {
205
208
  side: "left",
206
- messages: l,
207
- onPointerDown: z
209
+ messages: u,
210
+ onPointerDown: se
208
211
  }) : null,
209
- d ? /* @__PURE__ */ Z(vr, {
212
+ f ? /* @__PURE__ */ Z(Tr, {
210
213
  side: "right",
211
- messages: l,
212
- onPointerDown: z
214
+ messages: u,
215
+ onPointerDown: se
213
216
  }) : null
214
217
  ]
215
218
  }),
216
- d && (A || h) ? /* @__PURE__ */ Z("input", {
219
+ f && (M || g) ? /* @__PURE__ */ Z("input", {
217
220
  className: "markweave-image-caption-input",
218
221
  "data-markweave-image-ui": "true",
219
222
  "data-testid": "markweave-image-caption-input",
220
- value: te,
221
- placeholder: u.captionPlaceholder,
222
- "aria-label": u.captionAriaLabel,
223
+ value: N,
224
+ placeholder: d.captionPlaceholder,
225
+ "aria-label": d.captionAriaLabel,
223
226
  onChange: (e) => oe(e.currentTarget.value),
224
227
  onKeyDown: (e) => {
225
- e.key === "Escape" && (e.preventDefault(), j(!1));
228
+ e.key === "Escape" && (e.preventDefault(), ee(!1));
226
229
  }
227
- }) : h ? /* @__PURE__ */ Z("figcaption", {
230
+ }) : g ? /* @__PURE__ */ Z("figcaption", {
228
231
  className: "markweave-image-caption",
229
232
  "data-testid": "markweave-image-caption",
230
- children: h
233
+ children: g
231
234
  }) : null
232
235
  ] })
233
236
  });
234
237
  }
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 }) {
238
+ 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 }) {
236
239
  let f = a.image;
237
240
  return /* @__PURE__ */ Q("section", {
238
241
  className: "markweave-image-upload-placeholder",
@@ -259,7 +262,7 @@ function hr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
259
262
  /* @__PURE__ */ Z("div", {
260
263
  className: "markweave-image-upload-icon",
261
264
  "aria-hidden": "true",
262
- children: /* @__PURE__ */ Z(D, {
265
+ children: /* @__PURE__ */ Z(j, {
263
266
  size: 46,
264
267
  strokeWidth: 1.6
265
268
  })
@@ -294,7 +297,7 @@ function hr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
294
297
  "data-testid": "markweave-image-upload-submit",
295
298
  disabled: i || !r.trim(),
296
299
  onClick: d,
297
- children: [/* @__PURE__ */ Z(D, {
300
+ children: [/* @__PURE__ */ Z(j, {
298
301
  size: 16,
299
302
  strokeWidth: 1.8
300
303
  }), a.common.insert]
@@ -314,32 +317,32 @@ function hr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
314
317
  ]
315
318
  });
316
319
  }
317
- function gr({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i, onDelete: a, onDownload: s, onPreview: u, onReplace: d }) {
318
- let p = n.image;
320
+ function Cr({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i, onDelete: a, onDownload: o, onPreview: s, onReplace: c }) {
321
+ let u = n.image;
319
322
  return /* @__PURE__ */ Q("div", {
320
323
  className: "markweave-image-toolbar",
321
324
  "data-testid": "markweave-image-toolbar",
322
325
  "data-markweave-image-ui": "true",
323
- "aria-label": p.toolsAriaLabel,
326
+ "aria-label": u.toolsAriaLabel,
324
327
  children: [
325
- /* @__PURE__ */ Z(_r, {
328
+ /* @__PURE__ */ Z(wr, {
326
329
  testId: "markweave-image-align-left",
327
- label: p.alignLeft,
328
- icon: c,
330
+ label: u.alignLeft,
331
+ icon: d,
329
332
  active: e === "left",
330
333
  onClick: () => r("left")
331
334
  }),
332
- /* @__PURE__ */ Z(_r, {
335
+ /* @__PURE__ */ Z(wr, {
333
336
  testId: "markweave-image-align-center",
334
- label: p.alignCenter,
335
- icon: o,
337
+ label: u.alignCenter,
338
+ icon: l,
336
339
  active: e === "center",
337
340
  onClick: () => r("center")
338
341
  }),
339
- /* @__PURE__ */ Z(_r, {
342
+ /* @__PURE__ */ Z(wr, {
340
343
  testId: "markweave-image-align-right",
341
- label: p.alignRight,
342
- icon: l,
344
+ label: u.alignRight,
345
+ icon: f,
343
346
  active: e === "right",
344
347
  onClick: () => r("right")
345
348
  }),
@@ -347,45 +350,45 @@ function gr({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i,
347
350
  className: "markweave-image-toolbar-divider",
348
351
  "aria-hidden": "true"
349
352
  }),
350
- /* @__PURE__ */ Z(_r, {
353
+ /* @__PURE__ */ Z(wr, {
351
354
  testId: "markweave-image-caption",
352
- label: p.caption,
353
- icon: f,
355
+ label: u.caption,
356
+ icon: h,
354
357
  active: t,
355
358
  onClick: i
356
359
  }),
357
- /* @__PURE__ */ Z(_r, {
360
+ /* @__PURE__ */ Z(wr, {
358
361
  testId: "markweave-image-preview",
359
- label: p.preview,
360
- icon: S,
361
- onClick: u
362
+ label: u.preview,
363
+ icon: E,
364
+ onClick: s
362
365
  }),
363
- /* @__PURE__ */ Z(_r, {
366
+ /* @__PURE__ */ Z(wr, {
364
367
  testId: "markweave-image-download",
365
- label: p.download,
366
- icon: b,
367
- onClick: s
368
+ label: u.download,
369
+ icon: w,
370
+ onClick: o
368
371
  }),
369
- /* @__PURE__ */ Z(_r, {
372
+ /* @__PURE__ */ Z(wr, {
370
373
  testId: "markweave-image-replace",
371
- label: p.replace,
372
- icon: L,
373
- onClick: d
374
+ label: u.replace,
375
+ icon: oe,
376
+ onClick: c
374
377
  }),
375
378
  /* @__PURE__ */ Z("span", {
376
379
  className: "markweave-image-toolbar-divider",
377
380
  "aria-hidden": "true"
378
381
  }),
379
- /* @__PURE__ */ Z(_r, {
382
+ /* @__PURE__ */ Z(wr, {
380
383
  testId: "markweave-image-delete",
381
- label: p.delete,
382
- icon: ue,
384
+ label: u.delete,
385
+ icon: he,
383
386
  onClick: a
384
387
  })
385
388
  ]
386
389
  });
387
390
  }
388
- function _r({ active: e = !1, icon: t, label: n, onClick: r, testId: i }) {
391
+ function wr({ active: e = !1, icon: t, label: n, onClick: r, testId: i }) {
389
392
  return /* @__PURE__ */ Q("button", {
390
393
  type: "button",
391
394
  "aria-label": n,
@@ -404,7 +407,7 @@ function _r({ active: e = !1, icon: t, label: n, onClick: r, testId: i }) {
404
407
  })]
405
408
  });
406
409
  }
407
- function vr({ messages: e, onPointerDown: t, side: n }) {
410
+ function Tr({ messages: e, onPointerDown: t, side: n }) {
408
411
  return /* @__PURE__ */ Z("button", {
409
412
  type: "button",
410
413
  className: "markweave-image-resize-handle",
@@ -415,128 +418,128 @@ function vr({ messages: e, onPointerDown: t, side: n }) {
415
418
  onPointerDown: (e) => t(n, e)
416
419
  });
417
420
  }
418
- var yr = ye.extend({
421
+ var Er = we.extend({
419
422
  addOptions() {
420
423
  return {
421
424
  ...this.parent?.(),
422
- messages: je("zh"),
425
+ messages: n("zh"),
423
426
  onUpload: void 0
424
427
  };
425
428
  },
426
429
  addNodeView() {
427
- return typeof document > "u" ? null : r(mr, { stopEvent: ({ event: e }) => pr(e.target) });
430
+ return typeof document > "u" ? null : o(xr, { stopEvent: ({ event: e }) => br(e.target) });
428
431
  }
429
432
  });
430
433
  //#endregion
431
434
  //#region src/media/video-node.tsx
432
- function br(e) {
435
+ function Dr(e) {
433
436
  return e instanceof Element && !!e.closest("[data-markweave-video-ui=\"true\"], iframe[data-markweave-video-embed], video[data-markweave-video]");
434
437
  }
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 = () => {
437
- if (!d) return;
438
+ function Or(e) {
439
+ let { deleteNode: t, editor: r, getPos: i, node: o, selected: s, updateAttributes: c } = e, l = e.extension.options, u = l.messages ?? n("zh"), d = u.video, f = Fe(vr(r)), p = J(o.attrs.src), m = J(o.attrs.embedUrl), h = J(o.attrs.provider), g = m ? Ne(m, h) : null, _ = J(o.attrs.mimeType), v = J(o.attrs.title), y = U(null), [b, x] = W(!1), [S, C] = W(""), [w, T] = W(null), [E, D] = W(!1), O = f && !p, k = () => {
440
+ if (!f) return;
438
441
  let e = i();
439
442
  typeof e == "number" && r.chain().focus().setNodeSelection(e).run();
440
- }, ee = (e) => {
441
- d && (br(e.target) || (e.preventDefault(), O()));
442
- }, k = (e) => {
443
- d && (e.key === "Delete" || e.key === "Backspace") && o && (e.preventDefault(), t());
444
- }, A = async (e) => {
445
- if (!(!d || !e)) {
446
- w(null), E(!0);
443
+ }, A = (e) => {
444
+ f && (Dr(e.target) || (e.preventDefault(), k()));
445
+ }, j = (e) => {
446
+ f && (e.key === "Delete" || e.key === "Backspace") && s && (e.preventDefault(), t());
447
+ }, M = async (e) => {
448
+ if (!(!f || !e)) {
449
+ T(null), D(!0);
447
450
  try {
448
- let t = await G(q({
451
+ let t = await Ce(q({
449
452
  type: "file",
450
453
  file: e,
451
454
  mimeType: e.type
452
- }), c.onUpload);
453
- s(xe(t)), S("");
455
+ }), l.onUpload);
456
+ c(Ee(t)), C("");
454
457
  } catch (e) {
455
- w(e instanceof Error ? e.message : u.uploadFailedError);
458
+ T(e instanceof Error ? e.message : d.uploadFailedError);
456
459
  } finally {
457
- E(!1), b(!1);
460
+ D(!1), x(!1);
458
461
  }
459
462
  }
460
463
  };
461
- return D ? /* @__PURE__ */ Z(n, {
464
+ return O ? /* @__PURE__ */ Z(a, {
462
465
  as: "figure",
463
466
  className: "markweave-video-node",
464
467
  "data-testid": "markweave-video-node",
465
468
  "data-empty": "true",
466
469
  "data-selected": "false",
467
- children: /* @__PURE__ */ Z(Sr, {
468
- dragActive: y,
469
- error: C,
470
- fileInputRef: v,
471
- inputValue: x,
472
- isSubmitting: T,
473
- messages: l,
470
+ children: /* @__PURE__ */ Z(kr, {
471
+ dragActive: b,
472
+ error: w,
473
+ fileInputRef: y,
474
+ inputValue: S,
475
+ isSubmitting: E,
476
+ messages: u,
474
477
  onCancel: t,
475
- onDragActiveChange: b,
478
+ onDragActiveChange: x,
476
479
  onDrop: (e) => {
477
- e.preventDefault(), e.stopPropagation(), d && A(e.dataTransfer.files?.[0] ?? null);
480
+ e.preventDefault(), e.stopPropagation(), f && M(e.dataTransfer.files?.[0] ?? null);
478
481
  },
479
482
  onFileChange: (e) => {
480
- A(e.currentTarget.files?.[0] ?? null), e.currentTarget.value = "";
483
+ M(e.currentTarget.files?.[0] ?? null), e.currentTarget.value = "";
481
484
  },
482
- onInputChange: S,
485
+ onInputChange: C,
483
486
  onSubmit: () => {
484
- if (!d) return;
485
- let e = Se(x);
487
+ if (!f) return;
488
+ let e = De(S);
486
489
  if (!e) {
487
- w(u.unsupportedUrlError);
490
+ T(d.unsupportedUrlError);
488
491
  return;
489
492
  }
490
- w(null), s(e), S("");
493
+ T(null), c(e), C("");
491
494
  }
492
495
  })
493
- }) : /* @__PURE__ */ Z(n, {
496
+ }) : /* @__PURE__ */ Z(a, {
494
497
  as: "figure",
495
498
  className: "markweave-video-node",
496
499
  "data-testid": "markweave-video-node",
497
- "data-provider": m ?? "file",
498
- "data-empty": f ? "false" : "true",
499
- "data-selected": d && o ? "true" : "false",
500
- tabIndex: d ? 0 : void 0,
501
- "aria-label": u.nodeAriaLabel,
502
- onFocus: O,
503
- onKeyDown: k,
504
- onMouseDown: ee,
505
- children: h ? /* @__PURE__ */ Q("div", {
500
+ "data-provider": h ?? "file",
501
+ "data-empty": p ? "false" : "true",
502
+ "data-selected": f && s ? "true" : "false",
503
+ tabIndex: f ? 0 : void 0,
504
+ "aria-label": d.nodeAriaLabel,
505
+ onFocus: k,
506
+ onKeyDown: j,
507
+ onMouseDown: A,
508
+ children: g ? /* @__PURE__ */ Q("div", {
506
509
  className: "markweave-video-embed",
507
510
  children: [/* @__PURE__ */ Z("iframe", {
508
511
  className: "markweave-video-iframe",
509
- src: h,
510
- title: _ ?? `${m ?? "Video"} embed`,
512
+ src: g,
513
+ title: v ?? `${h ?? "Video"} embed`,
511
514
  "data-markweave-video-embed": "true",
512
- "data-markweave-video-provider": m ?? void 0,
513
- "data-markweave-video-src": f ?? void 0,
514
- allow: Ee,
515
+ "data-markweave-video-provider": h ?? void 0,
516
+ "data-markweave-video-src": p ?? void 0,
517
+ allow: je,
515
518
  loading: "lazy",
516
519
  allowFullScreen: !0
517
- }), d ? /* @__PURE__ */ Z("button", {
520
+ }), f ? /* @__PURE__ */ Z("button", {
518
521
  type: "button",
519
522
  className: "markweave-video-selection-layer",
520
523
  "data-testid": "markweave-video-selection-layer",
521
524
  tabIndex: -1,
522
- "aria-label": u.selectAriaLabel
525
+ "aria-label": d.selectAriaLabel
523
526
  }) : null]
524
- }) : f ? /* @__PURE__ */ Q("div", {
527
+ }) : p ? /* @__PURE__ */ Q("div", {
525
528
  className: "markweave-video-box",
526
529
  children: [/* @__PURE__ */ Z("video", {
527
530
  className: "markweave-video",
528
- src: f,
529
- title: _ ?? void 0,
531
+ src: p,
532
+ title: v ?? void 0,
530
533
  "data-markweave-video": "true",
531
- "data-markweave-mime-type": g ?? void 0,
534
+ "data-markweave-mime-type": _ ?? void 0,
532
535
  preload: "metadata",
533
536
  controls: !0
534
- }), d ? /* @__PURE__ */ Z("button", {
537
+ }), f ? /* @__PURE__ */ Z("button", {
535
538
  type: "button",
536
539
  className: "markweave-video-selection-layer",
537
540
  "data-testid": "markweave-video-selection-layer",
538
541
  tabIndex: -1,
539
- "aria-label": u.selectAriaLabel
542
+ "aria-label": d.selectAriaLabel
540
543
  }) : null]
541
544
  }) : /* @__PURE__ */ Z("div", {
542
545
  className: "markweave-video-readonly-empty",
@@ -545,7 +548,7 @@ function xr(e) {
545
548
  })
546
549
  });
547
550
  }
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 }) {
551
+ function kr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitting: i, messages: a, onCancel: o, onDragActiveChange: s, onDrop: c, onFileChange: l, onInputChange: u, onSubmit: d }) {
549
552
  let f = a.video;
550
553
  return /* @__PURE__ */ Q("section", {
551
554
  className: "markweave-video-upload-placeholder",
@@ -572,7 +575,7 @@ function Sr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
572
575
  /* @__PURE__ */ Z("div", {
573
576
  className: "markweave-video-upload-icon",
574
577
  "aria-hidden": "true",
575
- children: /* @__PURE__ */ Z(me, {
578
+ children: /* @__PURE__ */ Z(ye, {
576
579
  size: 46,
577
580
  strokeWidth: 1.6
578
581
  })
@@ -607,7 +610,7 @@ function Sr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
607
610
  "data-testid": "markweave-video-upload-submit",
608
611
  disabled: i || !r.trim(),
609
612
  onClick: d,
610
- children: [/* @__PURE__ */ Z(pe, {
613
+ children: [/* @__PURE__ */ Z(ve, {
611
614
  size: 16,
612
615
  strokeWidth: 1.8
613
616
  }), a.common.insert]
@@ -627,26 +630,227 @@ function Sr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
627
630
  ]
628
631
  });
629
632
  }
630
- var Cr = be.extend({
633
+ var Ar = Te.extend({
631
634
  addOptions() {
632
635
  return {
633
636
  ...this.parent?.(),
634
- messages: je("zh"),
637
+ messages: n("zh"),
635
638
  onUpload: void 0
636
639
  };
637
640
  },
638
641
  addNodeView() {
639
- return typeof document > "u" ? null : r(xr, { stopEvent: ({ event: e }) => br(e.target) });
642
+ return typeof document > "u" ? null : o(Or, { stopEvent: ({ event: e }) => Dr(e.target) });
643
+ }
644
+ });
645
+ //#endregion
646
+ //#region src/link-card-node.tsx
647
+ function jr(e) {
648
+ return e instanceof Element && !!e.closest("[data-markweave-link-card-ui=\"true\"]");
649
+ }
650
+ function Mr(e) {
651
+ return typeof navigator < "u" && navigator.clipboard?.writeText ? navigator.clipboard.writeText(e).catch(() => void 0) : Promise.resolve();
652
+ }
653
+ function Nr(e) {
654
+ !e || typeof window > "u" || window.open(e, "_blank", "noopener,noreferrer");
655
+ }
656
+ function Pr(e) {
657
+ try {
658
+ return new URL(e).host;
659
+ } catch {
660
+ return e;
661
+ }
662
+ }
663
+ function Fr(e) {
664
+ let { deleteNode: t, editor: r, getPos: i, node: o, updateAttributes: s } = e, c = e.extension.options, l = c.messages ?? n("zh"), u = l.linkCard, d = Fe(vr(r)), f = Ve(o.attrs), [p, m] = W(!1), [h, g] = W(!1), [_, v] = W(!1), [y, b] = W(f?.title ?? ""), [x, C] = W(f?.href ?? ""), w = U(null);
665
+ if (V(() => () => w.current?.abort(), []), V(() => {
666
+ b(f?.title ?? ""), C(f?.href ?? ""), v(!1);
667
+ }, [f?.href, f?.title]), !f) return null;
668
+ let T = async (e) => {
669
+ e.preventDefault();
670
+ let t = Ve({
671
+ ...f,
672
+ href: x,
673
+ title: y
674
+ });
675
+ if (!t) return;
676
+ s(t), g(!1), w.current?.abort();
677
+ let n = new AbortController();
678
+ w.current = n;
679
+ try {
680
+ let e = await c.resolver?.({
681
+ href: t.href,
682
+ title: t.title,
683
+ signal: n.signal
684
+ });
685
+ !n.signal.aborted && e && s(Ve({
686
+ ...t,
687
+ ...e
688
+ }) ?? t);
689
+ } catch {}
690
+ }, E = () => {
691
+ let e = i();
692
+ typeof e == "number" && Ue(r, e);
693
+ }, D = _ ? null : f.imageUrl, O = Pr(f.href);
694
+ return /* @__PURE__ */ Q(a, {
695
+ as: "article",
696
+ className: "markweave-link-card",
697
+ "data-testid": "markweave-link-card",
698
+ "data-markweave-link-card": "true",
699
+ "data-hovered": p ? "true" : "false",
700
+ "data-selected": e.selected ? "true" : "false",
701
+ onMouseEnter: () => m(!0),
702
+ onMouseLeave: () => m(!1),
703
+ onMouseDown: (e) => {
704
+ jr(e.target) || e.preventDefault();
705
+ },
706
+ onClick: (e) => {
707
+ jr(e.target) || (e.preventDefault(), Nr(f.href));
708
+ },
709
+ children: [
710
+ /* @__PURE__ */ Q("a", {
711
+ className: "markweave-link-card-main",
712
+ href: f.href,
713
+ "aria-label": u.open,
714
+ children: [/* @__PURE__ */ Q("span", {
715
+ className: "markweave-link-card-copy",
716
+ children: [
717
+ /* @__PURE__ */ Z("strong", { children: f.title }),
718
+ f.description ? /* @__PURE__ */ Z("span", { children: f.description }) : null,
719
+ /* @__PURE__ */ Z("small", { children: f.siteName ?? O })
720
+ ]
721
+ }), /* @__PURE__ */ Z("span", {
722
+ className: "markweave-link-card-media",
723
+ "aria-hidden": "true",
724
+ children: D ? /* @__PURE__ */ Z("img", {
725
+ src: D,
726
+ alt: "",
727
+ loading: "lazy",
728
+ referrerPolicy: "no-referrer",
729
+ onError: () => v(!0)
730
+ }) : !_ && f.faviconUrl ? /* @__PURE__ */ Z("img", {
731
+ className: "markweave-link-card-favicon",
732
+ src: f.faviconUrl,
733
+ alt: "",
734
+ loading: "lazy",
735
+ referrerPolicy: "no-referrer",
736
+ onError: () => v(!0)
737
+ }) : /* @__PURE__ */ Z("b", { children: O.slice(0, 1).toUpperCase() })
738
+ })]
739
+ }),
740
+ d && p ? /* @__PURE__ */ Q("div", {
741
+ className: "markweave-link-card-tools",
742
+ "data-markweave-link-card-ui": "true",
743
+ "aria-label": u.toolsAriaLabel,
744
+ children: [
745
+ /* @__PURE__ */ Z(Ir, {
746
+ label: u.convertToLink,
747
+ icon: F,
748
+ onClick: E,
749
+ testId: "markweave-link-card-convert"
750
+ }),
751
+ /* @__PURE__ */ Z(Ir, {
752
+ label: u.copyAddress,
753
+ icon: S,
754
+ onClick: () => void Mr(f.href),
755
+ testId: "markweave-link-card-copy"
756
+ }),
757
+ /* @__PURE__ */ Z(Ir, {
758
+ label: u.edit,
759
+ icon: ie,
760
+ onClick: (e) => {
761
+ let t = i();
762
+ typeof t == "number" && We({
763
+ anchor: e.currentTarget,
764
+ editor: r,
765
+ messages: l,
766
+ resolver: c.resolver,
767
+ card: {
768
+ pos: t,
769
+ attrs: f
770
+ }
771
+ });
772
+ },
773
+ testId: "markweave-link-card-edit"
774
+ }),
775
+ /* @__PURE__ */ Z(Ir, {
776
+ label: u.delete,
777
+ icon: he,
778
+ onClick: t,
779
+ testId: "markweave-link-card-delete"
780
+ })
781
+ ]
782
+ }) : null,
783
+ d && h ? /* @__PURE__ */ Q("form", {
784
+ className: "markweave-link-card-editor",
785
+ "data-markweave-link-card-ui": "true",
786
+ "data-testid": "markweave-link-card-editor",
787
+ onSubmit: T,
788
+ children: [
789
+ /* @__PURE__ */ Q("label", { children: [/* @__PURE__ */ Z("span", { children: u.titleLabel }), /* @__PURE__ */ Z("input", {
790
+ "aria-label": u.titleLabel,
791
+ placeholder: u.titlePlaceholder,
792
+ value: y,
793
+ onChange: (e) => b(e.currentTarget.value)
794
+ })] }),
795
+ /* @__PURE__ */ Q("label", { children: [/* @__PURE__ */ Z("span", { children: u.addressLabel }), /* @__PURE__ */ Z("input", {
796
+ "aria-label": u.addressLabel,
797
+ placeholder: u.addressPlaceholder,
798
+ value: x,
799
+ onChange: (e) => C(e.currentTarget.value)
800
+ })] }),
801
+ /* @__PURE__ */ Z("button", {
802
+ type: "submit",
803
+ "aria-label": u.edit,
804
+ disabled: !He(x),
805
+ children: /* @__PURE__ */ Z(F, { size: 16 })
806
+ })
807
+ ]
808
+ }) : null
809
+ ]
810
+ });
811
+ }
812
+ function Ir({ icon: e, label: t, onClick: n, testId: r }) {
813
+ return /* @__PURE__ */ Q("button", {
814
+ type: "button",
815
+ "aria-label": t,
816
+ title: t,
817
+ "data-testid": r,
818
+ onMouseDown: (e) => e.preventDefault(),
819
+ onClick: n,
820
+ children: [/* @__PURE__ */ Z(e, {
821
+ size: 16,
822
+ strokeWidth: 1.8
823
+ }), /* @__PURE__ */ Z("span", {
824
+ role: "tooltip",
825
+ children: t
826
+ })]
827
+ });
828
+ }
829
+ var Lr = Ge.extend({
830
+ addOptions() {
831
+ return {
832
+ ...this.parent?.(),
833
+ messages: n("zh"),
834
+ resolver: void 0
835
+ };
836
+ },
837
+ addNodeView() {
838
+ return typeof document > "u" ? null : o(Fr, { stopEvent: ({ event: e }) => jr(e.target) });
640
839
  }
641
840
  });
642
841
  //#endregion
643
842
  //#region src/create-editor-extensions.ts
644
- function wr(t = {}) {
843
+ function Rr(t = {}) {
645
844
  return e({
646
845
  lang: t.lang,
647
- mediaExtensions: Re({
648
- image: yr,
649
- video: Cr,
846
+ linkCardExtension: Lr.configure({
847
+ lang: t.lang,
848
+ messages: n(t.lang),
849
+ resolver: t.linkCardResolver
850
+ }),
851
+ mediaExtensions: Be({
852
+ image: Er,
853
+ video: Ar,
650
854
  lang: t.lang,
651
855
  onImageUpload: t.onImageUpload,
652
856
  onVideoUpload: t.onVideoUpload
@@ -655,7 +859,7 @@ function wr(t = {}) {
655
859
  }
656
860
  //#endregion
657
861
  //#region src/ui/codeblock/CodeBlockControls.tsx
658
- function Tr(e) {
862
+ function zr(e) {
659
863
  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", {
660
864
  cx: "10",
661
865
  cy: "10",
@@ -692,7 +896,7 @@ function Tr(e) {
692
896
  /* @__PURE__ */ Z("path", { d: "m14 14 4 4" })
693
897
  ] }) : 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" });
694
898
  }
695
- function Er({ icon: e }) {
899
+ function Br({ icon: e }) {
696
900
  return /* @__PURE__ */ Z("svg", {
697
901
  viewBox: "0 0 24 24",
698
902
  "aria-hidden": "true",
@@ -703,40 +907,40 @@ function Er({ icon: e }) {
703
907
  strokeLinecap: "round",
704
908
  strokeLinejoin: "round",
705
909
  strokeWidth: "1.8",
706
- children: Tr(e)
910
+ children: zr(e)
707
911
  })
708
912
  });
709
913
  }
710
- function Dr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, readOnly: i = !1 }) {
914
+ function Vr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, readOnly: i = !1 }) {
711
915
  let a = U(null), o = U(null), s = U(null), c = U({
712
916
  active: !1,
713
917
  lastX: 0,
714
918
  lastY: 0
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,
919
+ }), [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), [k, A] = W(!1), [j, M] = W(0), [ee, N] = W(0), P = pt(t), te = pn(t, l), F = !i && e && P.active && P.pos !== null ? {
920
+ ...P,
921
+ pos: P.pos,
718
922
  active: !0
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]);
923
+ } : null, I = te ?? F, ne = I !== null, L = I?.language === "mermaid", re = _n(t, I), R = ne && I !== null && !re, z = !i, ie = sn(I ? I.language : "text"), ae = x?.status ?? "idle", oe = I?.mermaidPreviewMode ?? n, se = L && oe === "preview", ce = hn(t), le = `${ee}|${ce.map((e) => `${e.pos}:${e.mermaidPreviewMode}:${e.text.length}`).join("|")}`, ue = H(() => dn(y.trim().toLowerCase()), [y]);
720
924
  if (V(() => {
721
925
  i && (v(!1), b(""));
722
926
  }, [i]), V(() => {
723
927
  if (!x) return;
724
928
  let e = window.setTimeout(() => {
725
929
  S(null);
726
- }, qt);
930
+ }, en);
727
931
  return () => {
728
932
  window.clearTimeout(e);
729
933
  };
730
934
  }, [x]), V(() => {
731
- S(null), v(!1), b(""), E(null), O(null), k(!1);
935
+ S(null), v(!1), b(""), E(null), O(null), A(!1);
732
936
  }, [
733
937
  e,
734
- F?.language,
735
- F?.pos,
736
- F?.text
938
+ I?.language,
939
+ I?.pos,
940
+ I?.text
737
941
  ]), V(() => {
738
942
  let e = ({ transaction: e }) => {
739
- e.getMeta(it) && j((e) => e + 1);
943
+ e.getMeta(dt) && M((e) => e + 1);
740
944
  };
741
945
  return t.on("transaction", e), () => {
742
946
  t.off("transaction", e);
@@ -746,7 +950,7 @@ function Dr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
746
950
  if (!e) return;
747
951
  let n = (e) => {
748
952
  if (e.target instanceof Node && a.current?.contains(e.target) || _) return;
749
- let n = on(t, an(t, e.target)), r = n && !un(t, n) ? n.pos : null;
953
+ let n = pn(t, fn(t, e.target)), r = n && !_n(t, n) ? n.pos : null;
750
954
  u((e) => e === r ? e : r);
751
955
  }, r = () => {
752
956
  _ || u(null);
@@ -759,7 +963,7 @@ function Dr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
759
963
  }, [_]), V(() => {
760
964
  if (!T) return;
761
965
  let e = (e) => {
762
- e.key === "Escape" && (E(null), O(null), k(!1), c.current = {
966
+ e.key === "Escape" && (E(null), O(null), A(!1), c.current = {
763
967
  active: !1,
764
968
  lastX: 0,
765
969
  lastY: 0
@@ -769,7 +973,7 @@ function Dr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
769
973
  document.removeEventListener("keydown", e);
770
974
  };
771
975
  }, [t, T]), V(() => {
772
- if (!I || !_) return;
976
+ if (!ne || !_) return;
773
977
  let e = (e) => {
774
978
  e.key === "Escape" && (v(!1), t.view.focus());
775
979
  }, n = (e) => {
@@ -779,22 +983,22 @@ function Dr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
779
983
  document.removeEventListener("keydown", e), document.removeEventListener("mousedown", n);
780
984
  };
781
985
  }, [
782
- I,
986
+ ne,
783
987
  t,
784
988
  _
785
- ]), he(() => {
989
+ ]), be(() => {
786
990
  let e = () => {
787
991
  let e = a.current;
788
992
  if (!e) return;
789
- if (!sn(e) || ce.length === 0) {
993
+ if (!mn(e) || ce.length === 0) {
790
994
  m([]);
791
995
  return;
792
996
  }
793
997
  let n = e.getBoundingClientRect(), r = ce.flatMap((e) => {
794
- let r = nn(tn(t, e.pos, e.mermaidPreviewMode), n);
795
- return r ? [Zt(e, r, n)] : [];
998
+ let r = un(ln(t, e.pos, e.mermaidPreviewMode), n);
999
+ return r ? [an(e, r, n)] : [];
796
1000
  });
797
- m((e) => dn(e, r, ce.map((e) => e.pos)));
1001
+ m((e) => vn(e, r, ce.map((e) => e.pos)));
798
1002
  };
799
1003
  e();
800
1004
  let n = window.requestAnimationFrame(e);
@@ -802,26 +1006,26 @@ function Dr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
802
1006
  window.cancelAnimationFrame(n), window.removeEventListener("resize", e), window.removeEventListener("scroll", e, !0);
803
1007
  };
804
1008
  }, [
805
- A,
1009
+ j,
806
1010
  t,
807
1011
  le
808
- ]), he(() => {
809
- if (!R || !F) {
1012
+ ]), be(() => {
1013
+ if (!R || !I) {
810
1014
  f(null), g(null);
811
1015
  return;
812
1016
  }
813
1017
  let e = () => {
814
1018
  let e = a.current;
815
1019
  if (!e) return;
816
- let n = tn(t, F.pos, z), r = e.getBoundingClientRect(), i = nn(n, r);
1020
+ let n = ln(t, I.pos, oe), r = e.getBoundingClientRect(), i = un(n, r);
817
1021
  if (!i) {
818
- f((e) => e?.pos === F.pos ? e : null), g((e) => _ ? e : null);
1022
+ f((e) => e?.pos === I.pos ? e : null), g((e) => _ ? e : null);
819
1023
  return;
820
1024
  }
821
- let s = Yt(F.pos, i, r);
1025
+ let s = nn(I.pos, i, r);
822
1026
  if (f(s), _ && o.current) {
823
1027
  let e = o.current.getBoundingClientRect();
824
- g(Gt({
1028
+ g(Qt({
825
1029
  overlayRect: r,
826
1030
  buttonRect: e,
827
1031
  windowWidth: window.innerWidth,
@@ -834,78 +1038,78 @@ function Dr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
834
1038
  };
835
1039
  }, [
836
1040
  R,
837
- A,
838
- F?.pos,
1041
+ j,
1042
+ I?.pos,
839
1043
  t,
840
1044
  _,
841
- z
1045
+ oe
842
1046
  ]), !R && ce.length === 0 && !T) return null;
843
1047
  let de = d ? {
844
1048
  top: d.top,
845
1049
  right: d.right
846
1050
  } : void 0, fe = async () => {
847
1051
  if (i) {
848
- if (!F) return;
849
- let e = await Jt(F.text);
850
- S(st(F, e ? "copied" : "failed"));
1052
+ if (!I) return;
1053
+ let e = await tn(I.text);
1054
+ S(mt(I, e ? "copied" : "failed"));
851
1055
  return;
852
1056
  }
853
- if (!Qt(t, F)) return;
854
- let e = await at(t);
855
- S(st(ot(t), e ? "copied" : "failed")), t.view.focus();
1057
+ if (!on(t, I)) return;
1058
+ let e = await ft(t);
1059
+ S(mt(pt(t), e ? "copied" : "failed")), t.view.focus();
856
1060
  }, pe = (e, n) => {
857
1061
  if (i) {
858
- ht(t, e.pos, n) && M((e) => e + 1);
1062
+ St(t, e.pos, n) && N((e) => e + 1);
859
1063
  return;
860
1064
  }
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());
1065
+ let a = P.active && P.pos === e.pos;
1066
+ vt(t, e.pos, n) && (r(n), N((e) => e + 1), a && t.view.focus());
863
1067
  }, 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));
1068
+ if (i || !I) return;
1069
+ let n = P.active && P.pos === I.pos;
1070
+ _t(t, I.pos, e) && (e === "mermaid" && vt(t, I.pos, "preview") && r("preview"), v(!1), b(""), N((e) => e + 1), n && t.view.focus());
1071
+ }, he = () => {
1072
+ i || !I || gt(t, I.pos, !re) && (M((e) => e + 1), u(null));
869
1073
  }, ge = () => {
870
- if (!F) return;
871
- let e = ln(t, F.pos);
1074
+ if (!I) return;
1075
+ let e = gn(t, I.pos);
872
1076
  if (!e) return;
873
1077
  let n = new Blob([e], { type: "image/svg+xml" }), r = URL.createObjectURL(n), i = document.createElement("a");
874
1078
  i.href = r, i.download = "markweave-mermaid.svg", i.click(), URL.revokeObjectURL(r), t.view.focus();
875
1079
  }, _e = () => {
876
- if (!F) return;
877
- let e = ln(t, F.pos);
878
- e && (E(Xt(e)), O(null), k(!1), c.current = {
1080
+ if (!I) return;
1081
+ let e = gn(t, I.pos);
1082
+ e && (E(rn(e)), O(null), A(!1), c.current = {
879
1083
  active: !1,
880
1084
  lastX: 0,
881
1085
  lastY: 0
882
1086
  });
883
1087
  }, ve = () => {
884
- E(null), O(null), k(!1), c.current = {
1088
+ E(null), O(null), A(!1), c.current = {
885
1089
  active: !1,
886
1090
  lastX: 0,
887
1091
  lastY: 0
888
1092
  }, t.view.focus();
889
- }, G = (e) => {
1093
+ }, ye = (e) => {
890
1094
  E((t) => t && {
891
1095
  ...t,
892
- scale: Kt(t.scale + e)
1096
+ scale: $t(t.scale + e)
893
1097
  });
894
- }, ye = () => {
895
- E((e) => e && Xt(e.svg)), c.current = {
1098
+ }, B = () => {
1099
+ E((e) => e && rn(e.svg)), c.current = {
896
1100
  active: !1,
897
1101
  lastX: 0,
898
1102
  lastY: 0
899
- }, k(!1);
900
- }, be = (e) => {
901
- e.preventDefault(), G(e.deltaY < 0 ? fn : -fn);
902
- }, K = (e) => {
1103
+ }, A(!1);
1104
+ }, G = (e) => {
1105
+ e.preventDefault(), ye(e.deltaY < 0 ? yn : -yn);
1106
+ }, xe = (e) => {
903
1107
  e.button === 0 && (e.preventDefault(), c.current = {
904
1108
  active: !0,
905
1109
  lastX: e.clientX,
906
1110
  lastY: e.clientY
907
- }, k(!0));
908
- }, xe = (e) => {
1111
+ }, A(!0));
1112
+ }, Se = (e) => {
909
1113
  let t = c.current;
910
1114
  if (!t.active) return;
911
1115
  let n = e.clientX - t.lastX, r = e.clientY - t.lastY;
@@ -913,13 +1117,13 @@ function Dr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
913
1117
  active: !0,
914
1118
  lastX: e.clientX,
915
1119
  lastY: e.clientY
916
- }, E((e) => pn(e, n, r));
917
- }, Se = () => {
1120
+ }, E((e) => bn(e, n, r));
1121
+ }, Ce = () => {
918
1122
  c.current = {
919
1123
  active: !1,
920
1124
  lastX: 0,
921
1125
  lastY: 0
922
- }, k(!1);
1126
+ }, A(!1);
923
1127
  };
924
1128
  return /* @__PURE__ */ Q("div", {
925
1129
  ref: a,
@@ -952,7 +1156,7 @@ function Dr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
952
1156
  className: "markweave-codeblock-controls",
953
1157
  "data-testid": "markweave-codeblock-controls",
954
1158
  "data-positioned": d ? "true" : "false",
955
- "data-collapsed": L ? "true" : "false",
1159
+ "data-collapsed": re ? "true" : "false",
956
1160
  "data-read-only": i ? "true" : "false",
957
1161
  "aria-label": "Code block controls",
958
1162
  style: de,
@@ -961,7 +1165,7 @@ function Dr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
961
1165
  className: "markweave-codeblock-language-button markweave-codeblock-language-label",
962
1166
  "aria-label": "Code block language",
963
1167
  "data-testid": "markweave-codeblock-language",
964
- children: /* @__PURE__ */ Z("span", { children: ae })
1168
+ children: /* @__PURE__ */ Z("span", { children: ie })
965
1169
  }) : /* @__PURE__ */ Q("button", {
966
1170
  ref: o,
967
1171
  type: "button",
@@ -972,18 +1176,18 @@ function Dr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
972
1176
  "data-testid": "markweave-codeblock-language",
973
1177
  onMouseDown: (e) => e.preventDefault(),
974
1178
  onClick: () => v((e) => !e),
975
- children: [/* @__PURE__ */ Z("span", { children: ae }), /* @__PURE__ */ Z(Er, { icon: "chevron" })]
1179
+ children: [/* @__PURE__ */ Z("span", { children: ie }), /* @__PURE__ */ Z(Br, { icon: "chevron" })]
976
1180
  }),
977
- ie ? /* @__PURE__ */ Z("button", {
1181
+ z ? /* @__PURE__ */ Z("button", {
978
1182
  type: "button",
979
1183
  className: "markweave-codeblock-icon-button markweave-codeblock-collapse-button",
980
- "aria-label": L ? "Expand code block" : "Collapse code block",
981
- title: L ? "Expand code block" : "Collapse code block",
1184
+ "aria-label": re ? "Expand code block" : "Collapse code block",
1185
+ title: re ? "Expand code block" : "Collapse code block",
982
1186
  "data-testid": "markweave-codeblock-collapse",
983
- "data-collapsed": L ? "true" : "false",
1187
+ "data-collapsed": re ? "true" : "false",
984
1188
  onMouseDown: (e) => e.preventDefault(),
985
- onClick: B,
986
- children: /* @__PURE__ */ Z(Er, { icon: "chevron" })
1189
+ onClick: he,
1190
+ children: /* @__PURE__ */ Z(Br, { icon: "chevron" })
987
1191
  }) : null,
988
1192
  /* @__PURE__ */ Q("span", {
989
1193
  className: "markweave-codeblock-copy-wrap",
@@ -992,14 +1196,14 @@ function Dr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
992
1196
  className: "markweave-codeblock-icon-button",
993
1197
  "aria-label": "Copy to clipboard",
994
1198
  "data-testid": "markweave-codeblock-copy",
995
- "data-copy-state": oe,
1199
+ "data-copy-state": ae,
996
1200
  onMouseDown: (e) => e.preventDefault(),
997
1201
  onMouseEnter: () => w(!0),
998
1202
  onMouseLeave: () => w(!1),
999
1203
  onFocus: () => w(!0),
1000
1204
  onBlur: () => w(!1),
1001
1205
  onClick: fe,
1002
- children: /* @__PURE__ */ Z(Er, { icon: oe === "copied" ? "check" : "clipboard" })
1206
+ children: /* @__PURE__ */ Z(Br, { icon: ae === "copied" ? "check" : "clipboard" })
1003
1207
  }), C ? /* @__PURE__ */ Z("span", {
1004
1208
  className: "markweave-codeblock-tooltip",
1005
1209
  role: "tooltip",
@@ -1007,7 +1211,7 @@ function Dr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1007
1211
  children: "Copy to clipboard"
1008
1212
  }) : null]
1009
1213
  }),
1010
- re && z === "preview" ? /* @__PURE__ */ Q("div", {
1214
+ L && oe === "preview" ? /* @__PURE__ */ Q("div", {
1011
1215
  className: "markweave-mermaid-preview-actions",
1012
1216
  "data-testid": "markweave-mermaid-preview-actions",
1013
1217
  children: [/* @__PURE__ */ Z("button", {
@@ -1018,7 +1222,7 @@ function Dr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1018
1222
  disabled: !se,
1019
1223
  onMouseDown: (e) => e.preventDefault(),
1020
1224
  onClick: _e,
1021
- children: /* @__PURE__ */ Z(Er, { icon: "expand" })
1225
+ children: /* @__PURE__ */ Z(Br, { icon: "expand" })
1022
1226
  }), /* @__PURE__ */ Z("button", {
1023
1227
  type: "button",
1024
1228
  className: "markweave-codeblock-icon-button",
@@ -1027,12 +1231,12 @@ function Dr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1027
1231
  disabled: !se,
1028
1232
  onMouseDown: (e) => e.preventDefault(),
1029
1233
  onClick: ge,
1030
- children: /* @__PURE__ */ Z(Er, { icon: "download" })
1234
+ children: /* @__PURE__ */ Z(Br, { icon: "download" })
1031
1235
  })]
1032
1236
  }) : null
1033
1237
  ]
1034
1238
  }) : null,
1035
- ie && R && _ ? /* @__PURE__ */ Q("div", {
1239
+ z && R && _ ? /* @__PURE__ */ Q("div", {
1036
1240
  className: "markweave-codeblock-language-menu",
1037
1241
  role: "listbox",
1038
1242
  "aria-label": "Code block languages",
@@ -1053,11 +1257,11 @@ function Dr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1053
1257
  onKeyDown: (e) => {
1054
1258
  e.key === "Escape" && (e.preventDefault(), v(!1), t.view.focus());
1055
1259
  }
1056
- }), /* @__PURE__ */ Z(Er, { icon: "search" })]
1260
+ }), /* @__PURE__ */ Z(Br, { icon: "search" })]
1057
1261
  }), /* @__PURE__ */ Z("div", {
1058
1262
  className: "markweave-codeblock-language-list",
1059
1263
  children: ue.map((e) => {
1060
- let t = e.language === F.language;
1264
+ let t = e.language === I.language;
1061
1265
  return /* @__PURE__ */ Q("button", {
1062
1266
  type: "button",
1063
1267
  role: "option",
@@ -1066,7 +1270,7 @@ function Dr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1066
1270
  "data-active": t ? "true" : "false",
1067
1271
  onMouseDown: (e) => e.preventDefault(),
1068
1272
  onClick: () => me(e.language),
1069
- children: [/* @__PURE__ */ Z("span", { children: e.label }), t ? /* @__PURE__ */ Z(Er, { icon: "check" }) : null]
1273
+ children: [/* @__PURE__ */ Z("span", { children: e.label }), t ? /* @__PURE__ */ Z(Br, { icon: "check" }) : null]
1070
1274
  }, e.language);
1071
1275
  })
1072
1276
  })]
@@ -1091,13 +1295,13 @@ function Dr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1091
1295
  onMouseLeave: () => O(null),
1092
1296
  onFocus: () => O("zoom-out"),
1093
1297
  onBlur: () => O(null),
1094
- onClick: () => G(-fn),
1095
- children: /* @__PURE__ */ Z(Er, { icon: "zoomOut" })
1298
+ onClick: () => ye(-yn),
1299
+ children: /* @__PURE__ */ Z(Br, { icon: "zoomOut" })
1096
1300
  }),
1097
1301
  /* @__PURE__ */ Z("span", {
1098
1302
  className: "markweave-mermaid-fullscreen-zoom-label",
1099
1303
  "data-testid": "markweave-mermaid-fullscreen-zoom-label",
1100
- children: en(T.scale)
1304
+ children: cn(T.scale)
1101
1305
  }),
1102
1306
  /* @__PURE__ */ Z("button", {
1103
1307
  type: "button",
@@ -1108,8 +1312,8 @@ function Dr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1108
1312
  onMouseLeave: () => O(null),
1109
1313
  onFocus: () => O("zoom-in"),
1110
1314
  onBlur: () => O(null),
1111
- onClick: () => G(fn),
1112
- children: /* @__PURE__ */ Z(Er, { icon: "zoomIn" })
1315
+ onClick: () => ye(yn),
1316
+ children: /* @__PURE__ */ Z(Br, { icon: "zoomIn" })
1113
1317
  }),
1114
1318
  /* @__PURE__ */ Z("button", {
1115
1319
  type: "button",
@@ -1120,8 +1324,8 @@ function Dr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1120
1324
  onMouseLeave: () => O(null),
1121
1325
  onFocus: () => O("reset"),
1122
1326
  onBlur: () => O(null),
1123
- onClick: ye,
1124
- children: /* @__PURE__ */ Z(Er, { icon: "reset" })
1327
+ onClick: B,
1328
+ children: /* @__PURE__ */ Z(Br, { icon: "reset" })
1125
1329
  }),
1126
1330
  D ? /* @__PURE__ */ Z("span", {
1127
1331
  className: "markweave-mermaid-fullscreen-tooltip",
@@ -1137,17 +1341,17 @@ function Dr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1137
1341
  "aria-label": "Close fullscreen Mermaid preview",
1138
1342
  "data-testid": "markweave-mermaid-fullscreen-close",
1139
1343
  onClick: ve,
1140
- children: /* @__PURE__ */ Z(Er, { icon: "close" })
1344
+ children: /* @__PURE__ */ Z(Br, { icon: "close" })
1141
1345
  }),
1142
1346
  /* @__PURE__ */ Z("div", {
1143
1347
  className: "markweave-mermaid-fullscreen-viewport",
1144
1348
  "data-testid": "markweave-mermaid-fullscreen-viewport",
1145
- "data-dragging": ee ? "true" : "false",
1146
- onWheel: be,
1147
- onMouseDown: K,
1148
- onMouseMove: xe,
1149
- onMouseUp: Se,
1150
- onMouseLeave: Se,
1349
+ "data-dragging": k ? "true" : "false",
1350
+ onWheel: G,
1351
+ onMouseDown: xe,
1352
+ onMouseMove: Se,
1353
+ onMouseUp: Ce,
1354
+ onMouseLeave: Ce,
1151
1355
  children: /* @__PURE__ */ Z("div", {
1152
1356
  className: "markweave-mermaid-fullscreen-content",
1153
1357
  "data-testid": "markweave-mermaid-fullscreen-content",
@@ -1168,25 +1372,25 @@ function Dr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1168
1372
  }
1169
1373
  //#endregion
1170
1374
  //#region src/ui/floating-toolbar/FloatingToolbar.tsx
1171
- var Or = je("zh");
1172
- function kr() {
1375
+ var Hr = n("zh");
1376
+ function Ur() {
1173
1377
  return typeof performance > "u" ? Date.now() : performance.now();
1174
1378
  }
1175
- function Ar(e, t) {
1379
+ function Wr(e, t) {
1176
1380
  return {
1177
1381
  "--markweave-toolbar-motion-duration": `${e.motionDurationMs}ms`,
1178
1382
  "--markweave-toolbar-motion-easing": e.motionEasing,
1179
1383
  marginLeft: t === 0 ? void 0 : `${t}px`
1180
1384
  };
1181
1385
  }
1182
- function jr(e, t) {
1386
+ function Gr(e, t) {
1183
1387
  let n = e?.getBoundingClientRect().height ?? 0, r = t?.getBoundingClientRect().height ?? 0;
1184
1388
  return Math.max(n, r, 44);
1185
1389
  }
1186
- function Mr(e) {
1390
+ function Kr(e) {
1187
1391
  if (e !== null) return { "--markweave-floating-toolbar-tooltip-left": `${e}px` };
1188
1392
  }
1189
- function Nr(e, t, n, r) {
1393
+ function qr(e, t, n, r) {
1190
1394
  let i = {
1191
1395
  bottom: t + r,
1192
1396
  height: r,
@@ -1202,26 +1406,26 @@ function Nr(e, t, n, r) {
1202
1406
  toJSON: () => i
1203
1407
  };
1204
1408
  }
1205
- function Pr(e) {
1409
+ function Jr(e) {
1206
1410
  return e.width > 0 && e.height > 0;
1207
1411
  }
1208
- function Fr(e) {
1412
+ function Yr(e) {
1209
1413
  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));
1210
- return Nr(t, n, r - t, i - n);
1414
+ return qr(t, n, r - t, i - n);
1211
1415
  }
1212
- function Ir(e, t) {
1416
+ function Xr(e, t) {
1213
1417
  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;
1214
1418
  return r(t.anchorNode) && r(t.focusNode);
1215
1419
  }
1216
- function Lr(e) {
1420
+ function Zr(e) {
1217
1421
  if (typeof e.getClientRects != "function") return null;
1218
- let t = Array.from(e.getClientRects()).filter(Pr).map((e) => Nr(e.left, e.top, e.width, e.height));
1422
+ let t = Array.from(e.getClientRects()).filter(Jr).map((e) => qr(e.left, e.top, e.width, e.height));
1219
1423
  if (t.length > 0) return t;
1220
1424
  if (typeof e.getBoundingClientRect != "function") return null;
1221
1425
  let n = e.getBoundingClientRect();
1222
- return Pr(n) ? [Nr(n.left, n.top, n.width, n.height)] : null;
1426
+ return Jr(n) ? [qr(n.left, n.top, n.width, n.height)] : null;
1223
1427
  }
1224
- function Rr(e, t) {
1428
+ function Qr(e, t) {
1225
1429
  if (t.rangeCount === 0) return null;
1226
1430
  let n = t.getRangeAt(0);
1227
1431
  try {
@@ -1234,8 +1438,8 @@ function Rr(e, t) {
1234
1438
  return null;
1235
1439
  }
1236
1440
  }
1237
- function zr(e, t) {
1238
- let n = Rr(e, t);
1441
+ function $r(e, t) {
1442
+ let n = Qr(e, t);
1239
1443
  if (!n) return !1;
1240
1444
  let { selection: r } = e.state, i = {
1241
1445
  from: Math.min(r.from, r.to),
@@ -1243,51 +1447,51 @@ function zr(e, t) {
1243
1447
  };
1244
1448
  return n.from === i.from && n.to === i.to;
1245
1449
  }
1246
- function Br(e) {
1450
+ function ei(e) {
1247
1451
  let t = e.view.dom.ownerDocument.getSelection();
1248
- return !t || t.rangeCount === 0 || t.isCollapsed || !Ir(e, t) || !zr(e, t) ? null : Lr(t.getRangeAt(0));
1452
+ return !t || t.rangeCount === 0 || t.isCollapsed || !Xr(e, t) || !$r(e, t) ? null : Zr(t.getRangeAt(0));
1249
1453
  }
1250
- function Vr(e) {
1454
+ function ti(e) {
1251
1455
  let { selection: t } = e.state;
1252
1456
  if (t.empty) return null;
1253
1457
  let n = Math.min(t.from, t.to), r = Math.max(t.from, t.to);
1254
1458
  try {
1255
1459
  let t = e.view.domAtPos(n), i = e.view.domAtPos(r), a = e.view.dom.ownerDocument.createRange();
1256
- return a.setStart(t.node, t.offset), a.setEnd(i.node, i.offset), Lr(a);
1460
+ return a.setStart(t.node, t.offset), a.setEnd(i.node, i.offset), Zr(a);
1257
1461
  } catch {
1258
1462
  return null;
1259
1463
  }
1260
1464
  }
1261
- function Hr(e) {
1465
+ function ni(e) {
1262
1466
  let { selection: t } = e.state;
1263
1467
  if (t.empty) return 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;
1468
+ 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 = qr(c, o, Math.max(i.right, a.right) - c, s - o);
1469
+ return Jr(l) ? [l] : null;
1266
1470
  }
1267
- function Ur(e) {
1268
- return Br(e) ?? Vr(e) ?? Hr(e);
1471
+ function ri(e) {
1472
+ return ei(e) ?? ti(e) ?? ni(e);
1269
1473
  }
1270
- function Wr(e) {
1271
- let t = Ur(e);
1272
- return t && t.length > 0 ? Fr(t) : null;
1474
+ function ii(e) {
1475
+ let t = ri(e);
1476
+ return t && t.length > 0 ? Yr(t) : null;
1273
1477
  }
1274
- function Gr(e) {
1478
+ function ai(e) {
1275
1479
  return {
1276
- getBoundingClientRect: () => Wr(e) ?? Nr(0, 0, 0, 0),
1277
- getClientRects: () => Ur(e) ?? []
1480
+ getBoundingClientRect: () => ii(e) ?? qr(0, 0, 0, 0),
1481
+ getClientRects: () => ri(e) ?? []
1278
1482
  };
1279
1483
  }
1280
- function Kr(e) {
1484
+ function oi(e) {
1281
1485
  return e === "block-type" || e === "link" || e === "color" || e === "more";
1282
1486
  }
1283
- function qr(e, t, n) {
1284
- n?.(_n(e, t)), e.commands.focus();
1487
+ function si(e, t, n) {
1488
+ n?.(wn(e, t)), e.commands.focus();
1285
1489
  }
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(() => {
1490
+ function ci({ editor: e, messages: t = Hr, selectionSnapshot: n, onRewriteSelection: r }) {
1491
+ let i = H(() => kn(t), [t]), a = st(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), k = U(null), A = U(null), j = Tn(e, o.variant, t), M = jn(j.find((e) => e.id === c) ?? null), ee = Hn(m), N = B(() => {
1288
1492
  let t = D.current, n = e.view.dom.closest(".markweave-editor-frame");
1289
1493
  if (!t || !(n instanceof HTMLElement)) return;
1290
- let r = t.getBoundingClientRect(), i = n.getBoundingClientRect(), a = jr(t, O.current), s = E.current, c = Ye({
1494
+ let r = t.getBoundingClientRect(), i = n.getBoundingClientRect(), a = Gr(t, O.current), s = E.current, c = nt({
1291
1495
  toolbarRect: {
1292
1496
  left: r.left - s,
1293
1497
  top: r.top,
@@ -1301,7 +1505,7 @@ function Jr({ editor: e, messages: t = Or, selectionSnapshot: n, onRewriteSelect
1301
1505
  height: i.height
1302
1506
  },
1303
1507
  boundaryPadding: o.boundaryPadding
1304
- }), l = Ze({
1508
+ }), l = it({
1305
1509
  frameRect: {
1306
1510
  left: i.left,
1307
1511
  top: i.top,
@@ -1320,16 +1524,16 @@ function Jr({ editor: e, messages: t = Or, selectionSnapshot: n, onRewriteSelect
1320
1524
  e.view.dom,
1321
1525
  o.boundaryPadding,
1322
1526
  o.offset
1323
- ]), N = B(() => {
1527
+ ]), P = B(() => {
1324
1528
  D.current && (D.current.style.visibility = "hidden", D.current.style.opacity = "0");
1529
+ }, []), te = B(() => {
1530
+ N();
1531
+ }, [N]), F = B(() => ai(e), [e]), I = B((e) => {
1532
+ k.current = e;
1325
1533
  }, []), 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");
1534
+ let t = D.current, n = k.current, r = e.view.dom.closest(".markweave-editor-frame");
1331
1535
  if (!f || !t || !n) return;
1332
- let i = t.getBoundingClientRect(), a = n.getBoundingClientRect(), s = r?.getBoundingClientRect() ?? null, c = Xe({
1536
+ let i = t.getBoundingClientRect(), a = n.getBoundingClientRect(), s = r?.getBoundingClientRect() ?? null, c = rt({
1333
1537
  toolbarRect: i,
1334
1538
  popoverSize: a,
1335
1539
  viewport: {
@@ -1345,19 +1549,19 @@ function Jr({ editor: e, messages: t = Or, selectionSnapshot: n, onRewriteSelect
1345
1549
  e.view.dom,
1346
1550
  f,
1347
1551
  o.boundaryPadding
1348
- ]), re = H(() => ({
1349
- ...$e(o, { topBoundaryPadding: S }),
1350
- onShow: N,
1351
- onUpdate: ne
1552
+ ]), L = H(() => ({
1553
+ ...ot(o, { topBoundaryPadding: S }),
1554
+ onShow: P,
1555
+ onUpdate: te
1352
1556
  }), [
1353
- N,
1354
- ne,
1557
+ P,
1558
+ te,
1355
1559
  o,
1356
1560
  S
1357
1561
  ]);
1358
1562
  V(() => {
1359
- let e = kr();
1360
- s((t) => rt(t, a, e));
1563
+ let e = Ur();
1564
+ s((t) => ut(t, a, e));
1361
1565
  }, [
1362
1566
  a.hiddenReason,
1363
1567
  a.motionDurationMs,
@@ -1371,8 +1575,8 @@ function Jr({ editor: e, messages: t = Or, selectionSnapshot: n, onRewriteSelect
1371
1575
  a.visibility
1372
1576
  ]), V(() => {
1373
1577
  if (o.motionStartedAtMs === null || o.motionDurationMs <= 0) return;
1374
- let e = Math.max(0, o.motionStartedAtMs + o.motionDurationMs - kr()), t = window.setTimeout(() => {
1375
- s((e) => qe(e, kr()));
1578
+ let e = Math.max(0, o.motionStartedAtMs + o.motionDurationMs - Ur()), t = window.setTimeout(() => {
1579
+ s((e) => et(e, Ur()));
1376
1580
  }, e);
1377
1581
  return () => {
1378
1582
  window.clearTimeout(t);
@@ -1381,37 +1585,37 @@ function Jr({ editor: e, messages: t = Or, selectionSnapshot: n, onRewriteSelect
1381
1585
  o.motionDurationMs,
1382
1586
  o.motionPhase,
1383
1587
  o.motionStartedAtMs
1384
- ]), he(() => {
1588
+ ]), be(() => {
1385
1589
  if (o.visibility !== "visible") {
1386
1590
  E.current = 0, D.current && (D.current.style.marginLeft = "", D.current.style.visibility = "hidden", D.current.style.opacity = "0"), x(0), C(o.boundaryPadding);
1387
1591
  return;
1388
1592
  }
1389
- let e = hn(M);
1593
+ let e = Sn(N);
1390
1594
  return e.schedule(), window.addEventListener("resize", e.schedule), window.addEventListener("scroll", e.schedule, !0), () => {
1391
1595
  e.cancel(), window.removeEventListener("resize", e.schedule), window.removeEventListener("scroll", e.schedule, !0);
1392
1596
  };
1393
1597
  }, [
1394
- M,
1598
+ N,
1395
1599
  e.view.dom,
1396
1600
  f,
1397
1601
  n?.from,
1398
1602
  n?.to,
1399
1603
  o.variant,
1400
1604
  o.visibility,
1401
- A.length
1402
- ]), he(() => {
1605
+ j.length
1606
+ ]), be(() => {
1403
1607
  if (!f) return;
1404
- let e = hn(I);
1608
+ let e = Sn(ne);
1405
1609
  return e.schedule(), window.addEventListener("resize", e.schedule), window.addEventListener("scroll", e.schedule, !0), () => {
1406
1610
  e.cancel(), window.removeEventListener("resize", e.schedule), window.removeEventListener("scroll", e.schedule, !0);
1407
1611
  };
1408
- }, [f, I]), V(() => {
1409
- f === "more" && i.some((e) => e.id === c) || A.some((e) => e.id === c) || (l(null), d(null));
1612
+ }, [f, ne]), V(() => {
1613
+ f === "more" && i.some((e) => e.id === c) || j.some((e) => e.id === c) || (l(null), d(null));
1410
1614
  }, [
1411
1615
  i,
1412
1616
  f,
1413
1617
  c,
1414
- A
1618
+ j
1415
1619
  ]), V(() => {
1416
1620
  if (!f) return;
1417
1621
  let t = (e) => {
@@ -1425,15 +1629,15 @@ function Jr({ editor: e, messages: t = Or, selectionSnapshot: n, onRewriteSelect
1425
1629
  }, [e, f]), V(() => {
1426
1630
  if (f !== "link") return;
1427
1631
  let e = window.requestAnimationFrame(() => {
1428
- k.current?.focus(), k.current?.select();
1632
+ A.current?.focus(), A.current?.select();
1429
1633
  });
1430
1634
  return () => window.cancelAnimationFrame(e);
1431
1635
  }, [f]);
1432
- let L = (t) => {
1433
- if (Kr(t.id)) {
1636
+ let re = (t) => {
1637
+ if (oi(t.id)) {
1434
1638
  let n = t.id;
1435
1639
  if (n === "link") {
1436
- let t = bn(e);
1640
+ let t = Dn(e);
1437
1641
  h(t), _(t), y({
1438
1642
  from: Math.min(e.state.selection.from, e.state.selection.to),
1439
1643
  to: Math.max(e.state.selection.from, e.state.selection.to)
@@ -1443,23 +1647,23 @@ function Jr({ editor: e, messages: t = Or, selectionSnapshot: n, onRewriteSelect
1443
1647
  return;
1444
1648
  }
1445
1649
  if (p(null), t.id === "improve") {
1446
- qr(e, "rewrite-selection", r);
1650
+ si(e, "rewrite-selection", r);
1447
1651
  return;
1448
1652
  }
1449
1653
  t.run(), e.commands.focus();
1450
1654
  }, R = () => {
1451
1655
  p(null), e.commands.focus();
1452
- }, ie = () => {
1656
+ }, z = () => {
1453
1657
  v && e.commands.setTextSelection(v);
1658
+ }, ie = () => {
1659
+ z(), Cn(e, m) && R();
1454
1660
  }, ae = () => {
1455
- ie(), gn(e, m) && R();
1456
- }, oe = () => {
1457
- if (ie(), An(e)) {
1661
+ if (z(), Ln(e)) {
1458
1662
  h(""), _(""), R();
1459
1663
  return;
1460
1664
  }
1461
1665
  m.trim() && h("");
1462
- }, z = (e, t) => {
1666
+ }, oe = (e, t) => {
1463
1667
  if (l(e), !e || !t || !O.current) {
1464
1668
  d(null);
1465
1669
  return;
@@ -1467,82 +1671,82 @@ function Jr({ editor: e, messages: t = Or, selectionSnapshot: n, onRewriteSelect
1467
1671
  let n = t.getBoundingClientRect(), r = O.current.getBoundingClientRect();
1468
1672
  d(n.left + n.width / 2 - r.left);
1469
1673
  };
1470
- return /* @__PURE__ */ Z(mn, {
1674
+ return /* @__PURE__ */ Z(xn, {
1471
1675
  ref: D,
1472
1676
  editor: e,
1473
1677
  className: `markweave-floating-toolbar markweave-floating-toolbar--${o.variant} markweave-floating-toolbar--motion-${o.motionPhase}`,
1474
1678
  "data-motion": o.motionPhase,
1475
- "data-position-strategy": re.strategy,
1679
+ "data-position-strategy": L.strategy,
1476
1680
  "data-boundary-padding": o.boundaryPadding,
1477
1681
  "data-popover-placement": f ? w : void 0,
1478
1682
  "data-testid": "markweave-floating-toolbar",
1479
- style: Ar(o, b),
1683
+ style: Wr(o, b),
1480
1684
  updateDelay: 0,
1481
- getReferencedVirtualElement: P,
1482
- options: re,
1483
- shouldShow: ({ editor: e }) => e.isEditable && nt(Qe(e)),
1685
+ getReferencedVirtualElement: F,
1686
+ options: L,
1687
+ shouldShow: ({ editor: e }) => e.isEditable && lt(at(e)),
1484
1688
  children: /* @__PURE__ */ Q("div", {
1485
1689
  ref: O,
1486
1690
  className: "markweave-floating-toolbar-content",
1487
1691
  "data-menu": f ?? "none",
1488
1692
  children: [
1489
- A.map((e, t) => /* @__PURE__ */ Z(Xr, {
1693
+ j.map((e, t) => /* @__PURE__ */ Z(ui, {
1490
1694
  button: e,
1491
1695
  expanded: f === e.id,
1492
- showDivider: t > 0 && A[t - 1].group !== e.group,
1696
+ showDivider: t > 0 && j[t - 1].group !== e.group,
1493
1697
  tooltipActive: c === e.id,
1494
- onPointerDown: kn,
1495
- onTooltipChange: z,
1496
- onRun: L
1698
+ onPointerDown: In,
1699
+ onTooltipChange: oe,
1700
+ onRun: re
1497
1701
  }, e.id)),
1498
- f === "block-type" ? /* @__PURE__ */ Z(Qr, {
1702
+ f === "block-type" ? /* @__PURE__ */ Z(fi, {
1499
1703
  editor: e,
1500
1704
  messages: t,
1501
- onPopoverRef: F,
1705
+ onPopoverRef: I,
1502
1706
  onClose: () => p(null)
1503
1707
  }) : null,
1504
- f === "link" ? /* @__PURE__ */ Z(Yr, {
1505
- inputRef: k,
1708
+ f === "link" ? /* @__PURE__ */ Z(li, {
1709
+ inputRef: A,
1506
1710
  messages: t,
1507
1711
  value: m,
1508
- canApply: !!te,
1509
- canOpen: !!te,
1712
+ canApply: !!ee,
1713
+ canOpen: !!ee,
1510
1714
  canRemove: !!(g || m.trim()),
1511
1715
  onValueChange: h,
1512
- onApply: ae,
1513
- onOpen: () => On(m),
1514
- onRemove: oe,
1515
- onPopoverRef: F
1716
+ onApply: ie,
1717
+ onOpen: () => Fn(m),
1718
+ onRemove: ae,
1719
+ onPopoverRef: I
1516
1720
  }) : null,
1517
- f === "color" ? /* @__PURE__ */ Z(ei, {
1721
+ f === "color" ? /* @__PURE__ */ Z(mi, {
1518
1722
  editor: e,
1519
1723
  messages: t,
1520
- onPopoverRef: F,
1724
+ onPopoverRef: I,
1521
1725
  onClose: () => p(null)
1522
1726
  }) : null,
1523
- f === "more" ? /* @__PURE__ */ Z(ni, {
1727
+ f === "more" ? /* @__PURE__ */ Z(gi, {
1524
1728
  editor: e,
1525
1729
  messages: t,
1526
1730
  activeTooltipId: c,
1527
- onPopoverRef: F,
1731
+ onPopoverRef: I,
1528
1732
  onTooltipChange: l,
1529
1733
  onClose: () => p(null)
1530
1734
  }) : null,
1531
- j && f === null ? /* @__PURE__ */ Z("div", {
1735
+ M && f === null ? /* @__PURE__ */ Z("div", {
1532
1736
  className: "markweave-floating-toolbar-tooltip",
1533
1737
  role: "tooltip",
1534
1738
  "data-testid": "markweave-floating-toolbar-tooltip",
1535
- "data-button-id": j.buttonId,
1536
- "data-active": j.active,
1537
- style: Mr(u),
1538
- children: j.label
1739
+ "data-button-id": M.buttonId,
1740
+ "data-active": M.active,
1741
+ style: Kr(u),
1742
+ children: M.label
1539
1743
  }) : null
1540
1744
  ]
1541
1745
  })
1542
1746
  });
1543
1747
  }
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);
1748
+ function li({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRemove: a, onValueChange: o, onApply: s, onOpen: c, onRemove: l, onPopoverRef: u }) {
1749
+ let d = On(t);
1546
1750
  return /* @__PURE__ */ Q("form", {
1547
1751
  ref: u,
1548
1752
  className: "markweave-floating-toolbar-popover markweave-floating-toolbar-link-popover",
@@ -1565,7 +1769,7 @@ function Yr({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRe
1565
1769
  "aria-label": d.applyLink,
1566
1770
  "data-testid": "markweave-floating-toolbar-link-apply",
1567
1771
  disabled: !r,
1568
- onMouseDown: kn,
1772
+ onMouseDown: In,
1569
1773
  children: /* @__PURE__ */ Z($, { name: "corner-down-left" })
1570
1774
  }),
1571
1775
  /* @__PURE__ */ Z("span", {
@@ -1577,7 +1781,7 @@ function Yr({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRe
1577
1781
  "aria-label": d.openLink,
1578
1782
  "data-testid": "markweave-floating-toolbar-link-open",
1579
1783
  disabled: !i,
1580
- onMouseDown: kn,
1784
+ onMouseDown: In,
1581
1785
  onClick: c,
1582
1786
  children: /* @__PURE__ */ Z($, { name: "external-link" })
1583
1787
  }),
@@ -1586,7 +1790,7 @@ function Yr({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRe
1586
1790
  "aria-label": d.removeLink,
1587
1791
  "data-testid": "markweave-floating-toolbar-link-remove",
1588
1792
  disabled: !a,
1589
- onMouseDown: kn,
1793
+ onMouseDown: In,
1590
1794
  onClick: l,
1591
1795
  children: /* @__PURE__ */ Z($, { name: "trash" })
1592
1796
  })
@@ -1594,7 +1798,7 @@ function Yr({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRe
1594
1798
  })]
1595
1799
  });
1596
1800
  }
1597
- function Xr({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointerDown: i, onTooltipChange: a, onRun: o }) {
1801
+ function ui({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointerDown: i, onTooltipChange: a, onRun: o }) {
1598
1802
  return /* @__PURE__ */ Q(X, { children: [n ? /* @__PURE__ */ Z("span", {
1599
1803
  className: "markweave-floating-toolbar-divider",
1600
1804
  "aria-hidden": "true"
@@ -1602,7 +1806,7 @@ function Xr({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointe
1602
1806
  type: "button",
1603
1807
  className: `markweave-floating-toolbar-button markweave-floating-toolbar-button--${e.id}`,
1604
1808
  "aria-label": e.label,
1605
- "aria-expanded": Kr(e.id) ? t : void 0,
1809
+ "aria-expanded": oi(e.id) ? t : void 0,
1606
1810
  "data-active": e.active || t,
1607
1811
  "data-tooltip-active": r ? "true" : "false",
1608
1812
  "data-testid": `markweave-floating-toolbar-button-${e.id}`,
@@ -1612,13 +1816,13 @@ function Xr({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointe
1612
1816
  onMouseEnter: (t) => a(e.id, t.currentTarget),
1613
1817
  onMouseLeave: () => a(null),
1614
1818
  onClick: () => o(e),
1615
- children: /* @__PURE__ */ Z(Zr, {
1819
+ children: /* @__PURE__ */ Z(di, {
1616
1820
  button: e,
1617
1821
  expanded: t
1618
1822
  })
1619
1823
  })] });
1620
1824
  }
1621
- function Zr({ button: e, expanded: t }) {
1825
+ function di({ button: e, expanded: t }) {
1622
1826
  return e.id === "improve" ? /* @__PURE__ */ Q("span", {
1623
1827
  className: "markweave-floating-toolbar-button-inner",
1624
1828
  children: [/* @__PURE__ */ Z($, { name: "sparkles" }), /* @__PURE__ */ Z("span", { children: e.glyph })]
@@ -1636,8 +1840,8 @@ function Zr({ button: e, expanded: t }) {
1636
1840
  }), /* @__PURE__ */ Z($, { name: t ? "chevron-up" : "chevron-down" })]
1637
1841
  }) : /* @__PURE__ */ Z($, { name: "more" });
1638
1842
  }
1639
- function Qr({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
1640
- let i = xn(t), a = Tn(t);
1843
+ function fi({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
1844
+ let i = On(t), a = Mn(t);
1641
1845
  return /* @__PURE__ */ Q("div", {
1642
1846
  ref: n,
1643
1847
  className: "markweave-floating-toolbar-popover markweave-floating-toolbar-turn-menu",
@@ -1647,48 +1851,48 @@ function Qr({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
1647
1851
  children: i.turnIntoTitle
1648
1852
  }), a.map((t) => /* @__PURE__ */ Q("button", {
1649
1853
  type: "button",
1650
- "data-active": Dn(e, t.id),
1854
+ "data-active": Pn(e, t.id),
1651
1855
  "data-testid": `markweave-floating-toolbar-turn-${t.id}`,
1652
- onMouseDown: kn,
1856
+ onMouseDown: In,
1653
1857
  onClick: () => {
1654
- Pn(e, t.id), r();
1858
+ Vn(e, t.id), r();
1655
1859
  },
1656
1860
  children: [/* @__PURE__ */ Z("span", {
1657
1861
  className: "markweave-floating-toolbar-menu-icon",
1658
- children: /* @__PURE__ */ Z($r, { option: t })
1862
+ children: /* @__PURE__ */ Z(pi, { option: t })
1659
1863
  }), /* @__PURE__ */ Z("span", { children: t.label })]
1660
1864
  }, t.id))]
1661
1865
  });
1662
1866
  }
1663
- function $r({ option: e }) {
1867
+ function pi({ option: e }) {
1664
1868
  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 });
1665
1869
  }
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;
1870
+ function mi({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
1871
+ let i = On(t), a = e.getAttributes("textStyle").color, o = e.getAttributes("highlight").color;
1668
1872
  return /* @__PURE__ */ Q("div", {
1669
1873
  ref: n,
1670
1874
  className: "markweave-floating-toolbar-popover markweave-floating-toolbar-color-popover",
1671
1875
  "data-testid": "markweave-floating-toolbar-color-menu",
1672
- children: [/* @__PURE__ */ Z(ti, {
1876
+ children: [/* @__PURE__ */ Z(hi, {
1673
1877
  title: i.textColorTitle,
1674
1878
  mode: "text",
1675
1879
  activeColor: a ?? null,
1676
- options: Cn(t),
1880
+ options: An(t),
1677
1881
  onSelect: (t) => {
1678
- Nn(e, t), r();
1882
+ Bn(e, t), r();
1679
1883
  }
1680
- }), /* @__PURE__ */ Z(ti, {
1884
+ }), /* @__PURE__ */ Z(hi, {
1681
1885
  title: i.highlightColorTitle,
1682
1886
  mode: "highlight",
1683
1887
  activeColor: o ?? null,
1684
- options: yn(t),
1888
+ options: En(t),
1685
1889
  onSelect: (t) => {
1686
- Mn(e, t), r();
1890
+ zn(e, t), r();
1687
1891
  }
1688
1892
  })]
1689
1893
  });
1690
1894
  }
1691
- function ti({ title: e, mode: t, activeColor: n, options: r, onSelect: i }) {
1895
+ function hi({ title: e, mode: t, activeColor: n, options: r, onSelect: i }) {
1692
1896
  return /* @__PURE__ */ Q("section", {
1693
1897
  className: "markweave-floating-toolbar-color-section",
1694
1898
  "aria-label": e,
@@ -1702,7 +1906,7 @@ function ti({ title: e, mode: t, activeColor: n, options: r, onSelect: i }) {
1702
1906
  "aria-label": e.label,
1703
1907
  "data-active": e.value === n || e.value === null && !n,
1704
1908
  "data-testid": `markweave-floating-toolbar-${t}-${e.id}`,
1705
- onMouseDown: kn,
1909
+ onMouseDown: In,
1706
1910
  onClick: () => i(e.value),
1707
1911
  children: t === "text" ? /* @__PURE__ */ Z("span", {
1708
1912
  className: "markweave-floating-toolbar-text-swatch",
@@ -1717,25 +1921,25 @@ function ti({ title: e, mode: t, activeColor: n, options: r, onSelect: i }) {
1717
1921
  })]
1718
1922
  });
1719
1923
  }
1720
- function ni({ editor: e, messages: t, activeTooltipId: n, onPopoverRef: r, onTooltipChange: i, onClose: a }) {
1721
- let o = Sn(t);
1924
+ function gi({ editor: e, messages: t, activeTooltipId: n, onPopoverRef: r, onTooltipChange: i, onClose: a }) {
1925
+ let o = kn(t);
1722
1926
  return /* @__PURE__ */ Z("div", {
1723
1927
  ref: r,
1724
1928
  className: "markweave-floating-toolbar-popover markweave-floating-toolbar-more-menu",
1725
1929
  "data-testid": "markweave-floating-toolbar-more-menu",
1726
- children: o.map((t, r) => /* @__PURE__ */ Z(ri, {
1930
+ children: o.map((t, r) => /* @__PURE__ */ Z(_i, {
1727
1931
  action: t,
1728
- active: En(e, t.id),
1932
+ active: Nn(e, t.id),
1729
1933
  tooltipActive: n === t.id,
1730
1934
  showDivider: r > 0 && o[r - 1].group !== t.group,
1731
1935
  onTooltipChange: i,
1732
1936
  onRun: () => {
1733
- jn(e, t.id), a();
1937
+ Rn(e, t.id), a();
1734
1938
  }
1735
1939
  }, t.id))
1736
1940
  });
1737
1941
  }
1738
- function ri({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipChange: i, onRun: a }) {
1942
+ function _i({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipChange: i, onRun: a }) {
1739
1943
  return /* @__PURE__ */ Q(X, { children: [r ? /* @__PURE__ */ Z("span", {
1740
1944
  className: "markweave-floating-toolbar-divider",
1741
1945
  "aria-hidden": "true"
@@ -1747,11 +1951,11 @@ function ri({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipC
1747
1951
  "data-active": t,
1748
1952
  "data-tooltip-active": n ? "true" : "false",
1749
1953
  "data-testid": `markweave-floating-toolbar-more-${e.id}`,
1750
- onMouseDown: kn,
1954
+ onMouseDown: In,
1751
1955
  onMouseEnter: () => i(e.id),
1752
1956
  onMouseLeave: () => i(null),
1753
1957
  onClick: a,
1754
- children: /* @__PURE__ */ Z(ii, { id: e.id })
1958
+ children: /* @__PURE__ */ Z(vi, { id: e.id })
1755
1959
  }), n ? /* @__PURE__ */ Z("div", {
1756
1960
  className: "markweave-floating-toolbar-tooltip markweave-floating-toolbar-tooltip--more",
1757
1961
  role: "tooltip",
@@ -1759,41 +1963,41 @@ function ri({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipC
1759
1963
  }) : null]
1760
1964
  })] });
1761
1965
  }
1762
- function ii({ id: e }) {
1966
+ function vi({ id: e }) {
1763
1967
  return e === "superscript" ? /* @__PURE__ */ Z($, { name: "superscript" }) : e === "subscript" ? /* @__PURE__ */ Z($, { name: "subscript" }) : e === "inline-math" ? /* @__PURE__ */ Z($, { name: "math" }) : Z($, { name: e });
1764
1968
  }
1765
- var ai = {
1766
- sparkles: ae,
1767
- "chevron-down": h,
1768
- "chevron-up": g,
1769
- "corner-down-left": y,
1770
- "external-link": x,
1771
- bold: u,
1772
- italic: A,
1773
- underline: fe,
1774
- strike: oe,
1775
- "inline-code": v,
1776
- link: te,
1777
- more: F,
1778
- text: de,
1779
- "bullet-list": M,
1780
- "numbered-list": ne,
1781
- "todo-list": N,
1782
- quote: re,
1783
- "code-block": d,
1784
- superscript: se,
1785
- subscript: z,
1786
- math: R,
1787
- "align-left": c,
1788
- "align-center": o,
1789
- "align-right": l,
1790
- "align-justify": s,
1791
- "decrease-indent": O,
1969
+ var yi = {
1970
+ sparkles: le,
1971
+ "chevron-down": v,
1972
+ "chevron-up": y,
1973
+ "corner-down-left": C,
1974
+ "external-link": T,
1975
+ bold: p,
1976
+ italic: P,
1977
+ underline: _e,
1978
+ strike: ue,
1979
+ "inline-code": x,
1980
+ link: F,
1981
+ more: R,
1982
+ text: ge,
1983
+ "bullet-list": I,
1984
+ "numbered-list": L,
1985
+ "todo-list": ne,
1986
+ quote: ae,
1987
+ "code-block": m,
1988
+ superscript: fe,
1989
+ subscript: de,
1990
+ math: se,
1991
+ "align-left": d,
1992
+ "align-center": l,
1993
+ "align-right": f,
1994
+ "align-justify": u,
1995
+ "decrease-indent": M,
1792
1996
  "increase-indent": ee,
1793
- trash: ue
1997
+ trash: he
1794
1998
  };
1795
1999
  function $({ name: e }) {
1796
- let t = ai[e];
2000
+ let t = yi[e];
1797
2001
  return /* @__PURE__ */ Z(t, {
1798
2002
  "aria-hidden": "true",
1799
2003
  absoluteStrokeWidth: !0,
@@ -1803,24 +2007,24 @@ function $({ name: e }) {
1803
2007
  }
1804
2008
  //#endregion
1805
2009
  //#region src/ui/math/MathEditorPopover.tsx
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 ? {
2010
+ function bi({ editor: e, messages: t, onClose: n, target: r }) {
2011
+ let i = U(null), a = U(null), [o, s] = W(r.latex), [c, l] = W(null), u = t.math, d = H(() => Dt(e, r) ?? 1, [e, r]), f = H(() => Ot(e, r), [e, r]), p = H(() => o === r.latex && f ? {
1808
2012
  html: f,
1809
2013
  error: !1
1810
- } : Tt(o, r.kind, e), [
2014
+ } : Mt(o, r.kind, e), [
1811
2015
  e,
1812
2016
  f,
1813
2017
  r.kind,
1814
2018
  r.latex,
1815
2019
  o
1816
- ]), h = o.trim().length > 0, g = B(() => {
2020
+ ]), m = o.trim().length > 0, h = B(() => {
1817
2021
  if (typeof window > "u") return;
1818
- let t = yt(e, r), i = e.view.dom.closest(".markweave-editor-frame")?.getBoundingClientRect();
2022
+ let t = Et(e, r), i = e.view.dom.closest(".markweave-editor-frame")?.getBoundingClientRect();
1819
2023
  if (!t || !i) {
1820
2024
  n();
1821
2025
  return;
1822
2026
  }
1823
- l(vt({
2027
+ l(Tt({
1824
2028
  anchorRect: t,
1825
2029
  frameRect: i,
1826
2030
  kind: r.kind,
@@ -1837,18 +2041,18 @@ function oi({ editor: e, messages: t, onClose: n, target: r }) {
1837
2041
  V(() => {
1838
2042
  s(r.latex);
1839
2043
  }, [r.latex, r.pos]), V(() => {
1840
- Et(e, r, !0), g();
2044
+ Nt(e, r, !0), h();
1841
2045
  let t = window.requestAnimationFrame(() => {
1842
- a.current?.focus({ preventScroll: !0 }), a.current?.select(), g();
2046
+ a.current?.focus({ preventScroll: !0 }), a.current?.select(), h();
1843
2047
  });
1844
- return window.addEventListener("resize", g), window.addEventListener("scroll", g, !0), () => {
1845
- window.cancelAnimationFrame(t), window.removeEventListener("resize", g), window.removeEventListener("scroll", g, !0), Et(e, r, !1);
2048
+ return window.addEventListener("resize", h), window.addEventListener("scroll", h, !0), () => {
2049
+ window.cancelAnimationFrame(t), window.removeEventListener("resize", h), window.removeEventListener("scroll", h, !0), Nt(e, r, !1);
1846
2050
  };
1847
2051
  }, [
1848
2052
  e,
1849
2053
  n,
1850
2054
  r,
1851
- g
2055
+ h
1852
2056
  ]), V(() => {
1853
2057
  let e = (e) => {
1854
2058
  let t = e.target;
@@ -1857,27 +2061,27 @@ function oi({ editor: e, messages: t, onClose: n, target: r }) {
1857
2061
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
1858
2062
  }, [n]);
1859
2063
  let _ = B(() => {
1860
- h && _t(e, r, o) && n();
2064
+ m && wt(e, r, o) && n();
1861
2065
  }, [
1862
- h,
2066
+ m,
1863
2067
  e,
1864
2068
  n,
1865
2069
  r,
1866
2070
  o
1867
- ]), y = (t) => {
2071
+ ]), v = (t) => {
1868
2072
  if (t.key === "Escape") {
1869
2073
  t.preventDefault(), n(), e.commands.focus();
1870
2074
  return;
1871
2075
  }
1872
2076
  t.key === "Enter" && (r.kind === "inline" || t.metaKey || t.ctrlKey) && (t.preventDefault(), _());
1873
- }, b = c ? {
2077
+ }, y = c ? {
1874
2078
  left: c.left,
1875
2079
  top: c.top,
1876
2080
  width: c.width
1877
- } : void 0, x = r.kind === "block" ? u.blockTitle : u.inlineTitle;
2081
+ } : void 0, b = r.kind === "block" ? u.blockTitle : u.inlineTitle;
1878
2082
  return r.kind === "inline" ? /* @__PURE__ */ Q("form", {
1879
2083
  ref: i,
1880
- "aria-label": x,
2084
+ "aria-label": b,
1881
2085
  className: "markweave-math-editor-popover markweave-math-editor-popover--inline",
1882
2086
  "data-kind": "inline",
1883
2087
  "data-placement": c?.placement ?? "bottom",
@@ -1885,7 +2089,7 @@ function oi({ editor: e, messages: t, onClose: n, target: r }) {
1885
2089
  onSubmit: (e) => {
1886
2090
  e.preventDefault(), _();
1887
2091
  },
1888
- style: b,
2092
+ style: y,
1889
2093
  children: [/* @__PURE__ */ Q("label", {
1890
2094
  className: "markweave-math-inline-source",
1891
2095
  "data-testid": "markweave-math-inline-source",
@@ -1899,7 +2103,7 @@ function oi({ editor: e, messages: t, onClose: n, target: r }) {
1899
2103
  "aria-label": u.latexLabel,
1900
2104
  "data-testid": "markweave-math-editor-input",
1901
2105
  onChange: (e) => s(e.currentTarget.value),
1902
- onKeyDown: y,
2106
+ onKeyDown: v,
1903
2107
  placeholder: u.latexPlaceholder,
1904
2108
  size: Math.max(o.length, 1),
1905
2109
  spellCheck: !1,
@@ -1912,13 +2116,13 @@ function oi({ editor: e, messages: t, onClose: n, target: r }) {
1912
2116
  ]
1913
2117
  }), /* @__PURE__ */ Q("div", {
1914
2118
  className: "markweave-math-inline-preview",
1915
- "data-error": m.error ? "true" : "false",
2119
+ "data-error": p.error ? "true" : "false",
1916
2120
  "data-testid": "markweave-math-editor-preview",
1917
- children: [/* @__PURE__ */ Z("div", { dangerouslySetInnerHTML: { __html: m.html || "&nbsp;" } }), m.error ? /* @__PURE__ */ Z("small", { children: u.invalidPreview }) : null]
2121
+ children: [/* @__PURE__ */ Z("div", { dangerouslySetInnerHTML: { __html: p.html || "&nbsp;" } }), p.error ? /* @__PURE__ */ Z("small", { children: u.invalidPreview }) : null]
1918
2122
  })]
1919
2123
  }) : /* @__PURE__ */ Q("form", {
1920
2124
  ref: i,
1921
- "aria-label": x,
2125
+ "aria-label": b,
1922
2126
  className: "markweave-math-editor-popover markweave-math-editor-popover--block",
1923
2127
  "data-kind": r.kind,
1924
2128
  "data-placement": c?.placement ?? "bottom",
@@ -1926,13 +2130,13 @@ function oi({ editor: e, messages: t, onClose: n, target: r }) {
1926
2130
  onSubmit: (e) => {
1927
2131
  e.preventDefault(), _();
1928
2132
  },
1929
- style: b,
2133
+ style: y,
1930
2134
  children: [
1931
2135
  /* @__PURE__ */ Q("div", {
1932
2136
  className: "markweave-math-block-toolbar",
1933
2137
  children: [
1934
2138
  /* @__PURE__ */ Z("span", { children: u.label }),
1935
- /* @__PURE__ */ Z(v, {
2139
+ /* @__PURE__ */ Z(x, {
1936
2140
  "aria-hidden": "true",
1937
2141
  size: 15,
1938
2142
  strokeWidth: 1.75
@@ -1940,10 +2144,10 @@ function oi({ editor: e, messages: t, onClose: n, target: r }) {
1940
2144
  /* @__PURE__ */ Z("button", {
1941
2145
  "aria-label": u.apply,
1942
2146
  "data-testid": "markweave-math-editor-apply",
1943
- disabled: !h,
2147
+ disabled: !m,
1944
2148
  title: u.apply,
1945
2149
  type: "submit",
1946
- children: /* @__PURE__ */ Z(p, {
2150
+ children: /* @__PURE__ */ Z(g, {
1947
2151
  "aria-hidden": "true",
1948
2152
  size: 16,
1949
2153
  strokeWidth: 2
@@ -1964,7 +2168,7 @@ function oi({ editor: e, messages: t, onClose: n, target: r }) {
1964
2168
  "aria-label": u.latexLabel,
1965
2169
  "data-testid": "markweave-math-editor-input",
1966
2170
  onChange: (e) => s(e.currentTarget.value),
1967
- onKeyDown: y,
2171
+ onKeyDown: v,
1968
2172
  placeholder: u.latexPlaceholder,
1969
2173
  rows: 3,
1970
2174
  spellCheck: !1,
@@ -1978,41 +2182,41 @@ function oi({ editor: e, messages: t, onClose: n, target: r }) {
1978
2182
  }),
1979
2183
  /* @__PURE__ */ Q("div", {
1980
2184
  className: "markweave-math-block-preview",
1981
- "data-error": m.error ? "true" : "false",
2185
+ "data-error": p.error ? "true" : "false",
1982
2186
  "data-math-number": String(d),
1983
2187
  "data-testid": "markweave-math-editor-preview",
1984
- children: [/* @__PURE__ */ Z("div", { dangerouslySetInnerHTML: { __html: m.html || "&nbsp;" } }), m.error ? /* @__PURE__ */ Z("small", { children: u.invalidPreview }) : null]
2188
+ children: [/* @__PURE__ */ Z("div", { dangerouslySetInnerHTML: { __html: p.html || "&nbsp;" } }), p.error ? /* @__PURE__ */ Z("small", { children: u.invalidPreview }) : null]
1985
2189
  })
1986
2190
  ]
1987
2191
  });
1988
2192
  }
1989
2193
  //#endregion
1990
2194
  //#region src/ui/slash-command/SlashCommandMenu.tsx
1991
- var si = je("zh"), ci = {
1992
- type: le,
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,
2000
- "code-block": d,
2001
- info: k,
2002
- tip: j,
2003
- warning: a,
2004
- error: _,
2005
- success: m,
2006
- emoji: ie,
2007
- math: R,
2008
- table: ce,
2009
- separator: P,
2010
- image: E,
2011
- video: me,
2012
- attachment: I
2195
+ var xi = n("zh"), Si = {
2196
+ type: me,
2197
+ "heading-1": D,
2198
+ "heading-2": O,
2199
+ "heading-3": k,
2200
+ "bullet-list": I,
2201
+ "ordered-list": L,
2202
+ "task-list": ne,
2203
+ blockquote: ae,
2204
+ "code-block": m,
2205
+ info: N,
2206
+ tip: te,
2207
+ warning: c,
2208
+ error: b,
2209
+ success: _,
2210
+ emoji: ce,
2211
+ math: se,
2212
+ table: pe,
2213
+ separator: re,
2214
+ image: A,
2215
+ video: ye,
2216
+ attachment: z
2013
2217
  };
2014
- function li({ name: e }) {
2015
- let t = ci[e];
2218
+ function Ci({ name: e }) {
2219
+ let t = Si[e];
2016
2220
  return /* @__PURE__ */ Z(t, {
2017
2221
  "aria-hidden": "true",
2018
2222
  absoluteStrokeWidth: !0,
@@ -2020,8 +2224,8 @@ function li({ name: e }) {
2020
2224
  strokeWidth: 1.6
2021
2225
  });
2022
2226
  }
2023
- function ui(e, t, n) {
2024
- return !Mt(e) || !n ? {
2227
+ function wi(e, t, n) {
2228
+ return !zt(e) || !n ? {
2025
2229
  visible: !1,
2026
2230
  empty: !1,
2027
2231
  activeIndex: -1
@@ -2035,16 +2239,16 @@ function ui(e, t, n) {
2035
2239
  activeIndex: Math.min(t.length - 1, Math.max(0, e.activeIndex))
2036
2240
  };
2037
2241
  }
2038
- function di(e, t) {
2242
+ function Ti(e, t) {
2039
2243
  return Object.values(t.slash.groups).map((t) => ({
2040
2244
  group: t,
2041
2245
  commands: e.filter((e) => e.group === t)
2042
2246
  })).filter((e) => e.commands.length > 0);
2043
2247
  }
2044
- function fi(e, t) {
2248
+ function Ei(e, t) {
2045
2249
  return t.slash.uploadKindLabels[e] ?? t.slash.uploadKindLabels.upload;
2046
2250
  }
2047
- function pi({ command: e, messages: t, onBack: n, onSelect: r }) {
2251
+ function Di({ command: e, messages: t, onBack: n, onSelect: r }) {
2048
2252
  let [i, a] = W(""), [o, s] = W(0), c = H(() => {
2049
2253
  let e = i.trim().toLowerCase();
2050
2254
  return (e ? t.slash.emojiItems.filter((t) => [
@@ -2111,9 +2315,9 @@ function pi({ command: e, messages: t, onBack: n, onSelect: r }) {
2111
2315
  ]
2112
2316
  });
2113
2317
  }
2114
- function mi({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
2318
+ function Oi({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
2115
2319
  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({
2320
+ r(e, { uploadResult: await Ce({
2117
2321
  kind: a,
2118
2322
  source: t,
2119
2323
  trigger: "slash-command"
@@ -2133,7 +2337,7 @@ function mi({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
2133
2337
  d(t.slash.uploadRequiredError);
2134
2338
  return;
2135
2339
  }
2136
- await m(_e(o));
2340
+ await m(xe(o));
2137
2341
  } catch (e) {
2138
2342
  d(e instanceof Error ? e.message : t.slash.uploadFailedError);
2139
2343
  } finally {
@@ -2151,7 +2355,7 @@ function mi({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
2151
2355
  onMouseDown: (e) => e.preventDefault(),
2152
2356
  onClick: n,
2153
2357
  children: t.common.back
2154
- }), /* @__PURE__ */ Z("span", { children: fi(a, t) })]
2358
+ }), /* @__PURE__ */ Z("span", { children: Ei(a, t) })]
2155
2359
  }),
2156
2360
  /* @__PURE__ */ Q("label", {
2157
2361
  className: "markweave-slash-upload-field",
@@ -2199,10 +2403,10 @@ function mi({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
2199
2403
  ]
2200
2404
  });
2201
2405
  }
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);
2406
+ function ki({ commands: e, messages: t = xi, state: n, position: r, inputCommand: i, onActiveIndexChange: a, onInputCommandChange: o, onSelect: s, onUpload: c }) {
2407
+ let l = wi(n, e, r);
2204
2408
  if (!l.visible || !r) return null;
2205
- let u = di(e, t), d = {
2409
+ let u = Ti(e, t), d = {
2206
2410
  left: r.left,
2207
2411
  top: r.top,
2208
2412
  maxHeight: r.maxHeight,
@@ -2224,12 +2428,12 @@ function hi({ commands: e, messages: t = si, state: n, position: r, inputCommand
2224
2428
  "aria-label": t.slash.ariaLabel,
2225
2429
  "data-placement": r.placement,
2226
2430
  "data-testid": "markweave-slash-menu",
2227
- children: i?.inputKind === "emoji" ? /* @__PURE__ */ Z(pi, {
2431
+ children: i?.inputKind === "emoji" ? /* @__PURE__ */ Z(Di, {
2228
2432
  command: i,
2229
2433
  messages: t,
2230
2434
  onBack: m,
2231
2435
  onSelect: s
2232
- }) : i?.inputKind === "upload" ? /* @__PURE__ */ Z(mi, {
2436
+ }) : i?.inputKind === "upload" ? /* @__PURE__ */ Z(Oi, {
2233
2437
  command: i,
2234
2438
  messages: t,
2235
2439
  onBack: m,
@@ -2249,7 +2453,7 @@ function hi({ commands: e, messages: t = si, state: n, position: r, inputCommand
2249
2453
  className: "markweave-slash-group-title",
2250
2454
  children: t.group
2251
2455
  }), t.commands.map((t) => {
2252
- let n = e.indexOf(t), r = n === l.activeIndex, i = At(t), o = !!t.disabled;
2456
+ let n = e.indexOf(t), r = n === l.activeIndex, i = Lt(t), o = !!t.disabled;
2253
2457
  return /* @__PURE__ */ Q("button", {
2254
2458
  type: "button",
2255
2459
  role: "option",
@@ -2273,7 +2477,7 @@ function hi({ commands: e, messages: t = si, state: n, position: r, inputCommand
2273
2477
  }
2274
2478
  },
2275
2479
  children: [
2276
- /* @__PURE__ */ Z(li, { name: t.icon }),
2480
+ /* @__PURE__ */ Z(Ci, { name: t.icon }),
2277
2481
  /* @__PURE__ */ Z("span", { children: t.label }),
2278
2482
  o && t.disabledReason ? /* @__PURE__ */ Z("small", { children: t.disabledReason }) : null
2279
2483
  ]
@@ -2285,38 +2489,38 @@ function hi({ commands: e, messages: t = si, state: n, position: r, inputCommand
2285
2489
  }
2286
2490
  //#endregion
2287
2491
  //#region src/ui/table/TableControls.tsx
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;
2492
+ var Ai = n("zh");
2493
+ function ji({ active: e, editor: t, interactionState: n = Xt, messages: r = Ai, onCopyPayload: i, onCommandResult: a, onEditWithAi: o }) {
2494
+ 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 ? Jt(t.state) : null;
2291
2495
  if (V(() => {
2292
2496
  if (!y) return;
2293
2497
  let e = window.setTimeout(() => {
2294
2498
  b(null);
2295
- }, $n);
2499
+ }, or);
2296
2500
  return () => {
2297
2501
  window.clearTimeout(e);
2298
2502
  };
2299
- }, [y]), he(() => {
2503
+ }, [y]), be(() => {
2300
2504
  if (!e) {
2301
2505
  m(null), g(null), v(null), b(null);
2302
2506
  return;
2303
2507
  }
2304
2508
  let r = () => {
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;
2509
+ let e = t.view.dom.closest(".markweave-editor-frame") ?? t.view.dom.parentElement, r = Qn(t, n, "row", E?.activeCellPos ?? null), i = Qn(t, n, "column", E?.activeCellPos ?? null), a = r ? Zn(t, r) : null, o = i ? Zn(t, i) : null, c = Xn(t).length > 0 ? rr(t) : null;
2306
2510
  if (!e) {
2307
2511
  m(null), g(null), v(null);
2308
2512
  return;
2309
2513
  }
2310
2514
  let u = e.getBoundingClientRect();
2311
- a ? m(Rn({
2515
+ a ? m(Gn({
2312
2516
  targetRect: a,
2313
2517
  frameRect: u,
2314
2518
  kind: "row"
2315
- })) : s === "row" && l === "row-edge" || m(null), o ? g(Rn({
2519
+ })) : s === "row" && l === "row-edge" || m(null), o ? g(Gn({
2316
2520
  targetRect: o,
2317
2521
  frameRect: u,
2318
2522
  kind: "column"
2319
- })) : s === "column" && l === "column-edge" || g(null), c ? v(Rn({
2523
+ })) : s === "column" && l === "column-edge" || g(null), c ? v(Gn({
2320
2524
  targetRect: c,
2321
2525
  frameRect: u,
2322
2526
  kind: "selection"
@@ -2336,7 +2540,7 @@ function _i({ active: e, editor: t, interactionState: n = Ut, messages: r = gi,
2336
2540
  n.hoverVisualRowIndex,
2337
2541
  l,
2338
2542
  s
2339
- ]), he(() => {
2543
+ ]), be(() => {
2340
2544
  if (!e || !s) {
2341
2545
  f(null);
2342
2546
  return;
@@ -2347,12 +2551,12 @@ function _i({ active: e, editor: t, interactionState: n = Ut, messages: r = gi,
2347
2551
  f(null);
2348
2552
  return;
2349
2553
  }
2350
- let i = n.getBoundingClientRect(), a = s === "row" ? Hn(t)?.getBoundingClientRect() : null, o = a ? {
2554
+ let i = n.getBoundingClientRect(), a = s === "row" ? Yn(t)?.getBoundingClientRect() : null, o = a ? {
2351
2555
  left: i.left,
2352
2556
  top: a.top,
2353
2557
  width: i.width,
2354
2558
  height: i.height
2355
- } : i, c = e.getBoundingClientRect(), u = r.getBoundingClientRect(), d = Ln({
2559
+ } : i, c = e.getBoundingClientRect(), u = r.getBoundingClientRect(), d = Wn({
2356
2560
  anchorRect: o,
2357
2561
  frameRect: c,
2358
2562
  menuSize: {
@@ -2393,22 +2597,22 @@ function _i({ active: e, editor: t, interactionState: n = Ut, messages: r = gi,
2393
2597
  let n = s === e && l === t;
2394
2598
  u(t), c(n ? null : e);
2395
2599
  }, O = () => {
2396
- t.view.dispatch(In(t.state.tr, null));
2397
- }, ee = (e, r) => {
2600
+ t.view.dispatch(Un(t.state.tr, null));
2601
+ }, k = (e, r) => {
2398
2602
  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);
2400
- }, k = () => {
2603
+ i !== null && ar(t, i, e, { visualIndex: a }), D(e, r);
2604
+ }, A = () => {
2401
2605
  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({
2606
+ }, j = Qn(t, n, "row", E?.activeCellPos ?? null), M = Qn(t, n, "column", E?.activeCellPos ?? null), ee = Xn(t).length > 0, N = s ? nr(t, s) : [], P = async (e, n) => {
2607
+ let o = await qn({
2404
2608
  editor: t,
2405
2609
  commandId: e,
2406
2610
  menu: n ?? s ?? "selection",
2407
2611
  messages: r
2408
2612
  });
2409
2613
  return o.copyFeedback ? (b(o.copyFeedback), o.copyPayload && i?.(o.copyPayload)) : b(null), a?.(o.commandResult), o.success;
2410
- }, ne = (e) => {
2411
- let n = Kn(t, e);
2614
+ }, te = (e) => {
2615
+ let n = $n(t, e);
2412
2616
  n && o?.(n), c(null), t.view.focus();
2413
2617
  };
2414
2618
  return /* @__PURE__ */ Q("div", {
@@ -2427,7 +2631,7 @@ function _i({ active: e, editor: t, interactionState: n = Ut, messages: r = gi,
2427
2631
  "data-copy-kind": y.kind,
2428
2632
  "data-text-length": y.textLength,
2429
2633
  "data-html-length": y.htmlLength,
2430
- children: Vn(y)
2634
+ children: Jn(y)
2431
2635
  }) : null,
2432
2636
  p ? /* @__PURE__ */ Z("button", {
2433
2637
  type: "button",
@@ -2438,17 +2642,17 @@ function _i({ active: e, editor: t, interactionState: n = Ut, messages: r = gi,
2438
2642
  "aria-haspopup": "menu",
2439
2643
  title: r.table.rowActions,
2440
2644
  "data-testid": "markweave-table-hover-row-handle",
2441
- "data-axis-index": A?.index ?? "",
2442
- "data-axis-selected-cells": A?.selectedCellCount ?? "",
2443
- "data-axis-visual-cells": A?.visualCellCount ?? "",
2444
- "data-axis-visual-size": A?.visualHeight ?? "",
2645
+ "data-axis-index": j?.index ?? "",
2646
+ "data-axis-selected-cells": j?.selectedCellCount ?? "",
2647
+ "data-axis-visual-cells": j?.visualCellCount ?? "",
2648
+ "data-axis-visual-size": j?.visualHeight ?? "",
2445
2649
  style: {
2446
2650
  left: p.left,
2447
2651
  top: p.top
2448
2652
  },
2449
2653
  onMouseDown: (e) => e.preventDefault(),
2450
2654
  onClick: () => {
2451
- ee("row", "row-edge");
2655
+ k("row", "row-edge");
2452
2656
  },
2453
2657
  children: /* @__PURE__ */ Z("span", {
2454
2658
  "aria-hidden": "true",
@@ -2464,24 +2668,24 @@ function _i({ active: e, editor: t, interactionState: n = Ut, messages: r = gi,
2464
2668
  "aria-haspopup": "menu",
2465
2669
  title: r.table.columnActions,
2466
2670
  "data-testid": "markweave-table-hover-column-handle",
2467
- "data-axis-index": j?.index ?? "",
2468
- "data-axis-selected-cells": j?.selectedCellCount ?? "",
2469
- "data-axis-visual-cells": j?.visualCellCount ?? "",
2470
- "data-axis-visual-size": j?.visualWidth ?? "",
2671
+ "data-axis-index": M?.index ?? "",
2672
+ "data-axis-selected-cells": M?.selectedCellCount ?? "",
2673
+ "data-axis-visual-cells": M?.visualCellCount ?? "",
2674
+ "data-axis-visual-size": M?.visualWidth ?? "",
2471
2675
  style: {
2472
2676
  left: h.left,
2473
2677
  top: h.top
2474
2678
  },
2475
2679
  onMouseDown: (e) => e.preventDefault(),
2476
2680
  onClick: () => {
2477
- ee("column", "column-edge");
2681
+ k("column", "column-edge");
2478
2682
  },
2479
2683
  children: /* @__PURE__ */ Z("span", {
2480
2684
  "aria-hidden": "true",
2481
2685
  children: "..."
2482
2686
  })
2483
2687
  }) : null,
2484
- te && _ ? /* @__PURE__ */ Z("button", {
2688
+ ee && _ ? /* @__PURE__ */ Z("button", {
2485
2689
  type: "button",
2486
2690
  ref: T,
2487
2691
  className: "markweave-table-edge-handle markweave-table-edge-handle--selection",
@@ -2495,7 +2699,7 @@ function _i({ active: e, editor: t, interactionState: n = Ut, messages: r = gi,
2495
2699
  top: _.top
2496
2700
  },
2497
2701
  onMouseDown: (e) => e.preventDefault(),
2498
- onClick: k,
2702
+ onClick: A,
2499
2703
  children: /* @__PURE__ */ Z("span", {
2500
2704
  "aria-hidden": "true",
2501
2705
  children: "..."
@@ -2505,15 +2709,15 @@ function _i({ active: e, editor: t, interactionState: n = Ut, messages: r = gi,
2505
2709
  ref: S,
2506
2710
  className: "markweave-table-menu",
2507
2711
  role: "menu",
2508
- "aria-label": er(s, r),
2712
+ "aria-label": sr(s, r),
2509
2713
  "data-testid": "markweave-table-menu",
2510
2714
  "data-positioned": d ? "true" : "false",
2511
2715
  style: d ? {
2512
2716
  left: d.left,
2513
2717
  top: d.top
2514
2718
  } : void 0,
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);
2719
+ children: N.map((e, n) => {
2720
+ let i = er(e), a = n === 0 ? i : er(N[n - 1]), l = n > 0 && a !== i, u = e.commandId === null ? !!o : Kn(t, e.commandId), d = tr(e, r);
2517
2721
  return /* @__PURE__ */ Z("button", {
2518
2722
  type: "button",
2519
2723
  role: "menuitem",
@@ -2528,10 +2732,10 @@ function _i({ active: e, editor: t, interactionState: n = Ut, messages: r = gi,
2528
2732
  onClick: () => {
2529
2733
  if (u) {
2530
2734
  if (e.commandId === null) {
2531
- ne(s === "row" || s === "column" ? s : "selection");
2735
+ te(s === "row" || s === "column" ? s : "selection");
2532
2736
  return;
2533
2737
  }
2534
- N(e.commandId).finally(() => c(null));
2738
+ P(e.commandId).finally(() => c(null));
2535
2739
  }
2536
2740
  },
2537
2741
  children: d
@@ -2543,15 +2747,15 @@ function _i({ active: e, editor: t, interactionState: n = Ut, messages: r = gi,
2543
2747
  }
2544
2748
  //#endregion
2545
2749
  //#region src/ui/table/TableSelectionOverlay.tsx
2546
- function vi({ editor: e, focusState: t }) {
2750
+ function Mi({ editor: e, focusState: t }) {
2547
2751
  let [n, r] = W(null);
2548
- return he(() => {
2752
+ return be(() => {
2549
2753
  if (t.mode !== "cell-selection") {
2550
2754
  r(null);
2551
2755
  return;
2552
2756
  }
2553
2757
  let n = () => {
2554
- r(Zn(e, Ht(e.state)));
2758
+ r(ir(e, Yt(e.state)));
2555
2759
  };
2556
2760
  return n(), window.addEventListener("resize", n), window.addEventListener("scroll", n, !0), () => {
2557
2761
  window.removeEventListener("resize", n), window.removeEventListener("scroll", n, !0);
@@ -2586,16 +2790,16 @@ function vi({ editor: e, focusState: t }) {
2586
2790
  }
2587
2791
  //#endregion
2588
2792
  //#region src/ui/toc/MarkweaveInnerToc.tsx
2589
- function yi(e, t) {
2793
+ function Ni(e, t) {
2590
2794
  return `${e.toc.itemAriaLabel}: ${t.text}`;
2591
2795
  }
2592
- function bi({ editor: e, state: t, messages: n, editable: r, placement: i }) {
2796
+ function Pi({ editor: e, state: t, messages: n, editable: r, placement: i }) {
2593
2797
  let a = U(null);
2594
2798
  if (V(() => {
2595
- if (!(i !== "container" || !a.current)) return sr(a.current);
2799
+ if (!(i !== "container" || !a.current)) return mr(a.current);
2596
2800
  }, [i]), !t.items.length) return null;
2597
2801
  let o = (t) => {
2598
- cr(e, t, {
2802
+ hr(e, t, {
2599
2803
  behavior: "smooth",
2600
2804
  focus: r
2601
2805
  });
@@ -2622,7 +2826,7 @@ function bi({ editor: e, state: t, messages: n, editable: r, placement: i }) {
2622
2826
  "data-level": e.level,
2623
2827
  "data-active": e.active ? "true" : "false",
2624
2828
  "aria-current": e.active ? "location" : void 0,
2625
- "aria-label": yi(n, e),
2829
+ "aria-label": Ni(n, e),
2626
2830
  title: e.text,
2627
2831
  onClick: () => o(e),
2628
2832
  children: e.text
@@ -2633,7 +2837,7 @@ function bi({ editor: e, state: t, messages: n, editable: r, placement: i }) {
2633
2837
  }
2634
2838
  //#endregion
2635
2839
  //#region src/MarkweaveEditor.tsx
2636
- var xi = {
2840
+ var Fi = {
2637
2841
  active: !1,
2638
2842
  mode: "outside",
2639
2843
  activeCellPos: null,
@@ -2641,21 +2845,21 @@ var xi = {
2641
2845
  selectedCellCount: 0,
2642
2846
  selectionFrom: 0,
2643
2847
  selectionTo: 0
2644
- }, Si = {
2848
+ }, Ii = {
2645
2849
  active: !1,
2646
- language: ct.defaultLanguage,
2850
+ language: ht.defaultLanguage,
2647
2851
  mermaidPreviewMode: "code",
2648
2852
  pos: null,
2649
2853
  text: ""
2650
- }, Ci = gt({
2854
+ }, Li = Ct({
2651
2855
  active: !1,
2652
2856
  mode: "code",
2653
2857
  source: ""
2654
2858
  });
2655
- function wi(e) {
2656
- return Wt.getState(e.state) ?? Ut;
2859
+ function Ri(e) {
2860
+ return Zt.getState(e.state) ?? Xt;
2657
2861
  }
2658
- function Ti(e) {
2862
+ function zi(e) {
2659
2863
  if (!e || typeof window > "u") return null;
2660
2864
  let t = e.parentElement;
2661
2865
  for (; t;) {
@@ -2665,89 +2869,92 @@ function Ti(e) {
2665
2869
  }
2666
2870
  return null;
2667
2871
  }
2668
- function Ei(e) {
2872
+ function Bi(e) {
2669
2873
  return typeof window > "u" || typeof window.requestAnimationFrame != "function" ? globalThis.setTimeout(() => e(0), 0) : window.requestAnimationFrame(e);
2670
2874
  }
2671
- function Di(e) {
2875
+ function Vi(e) {
2672
2876
  if (typeof window < "u" && typeof window.cancelAnimationFrame == "function") {
2673
2877
  window.cancelAnimationFrame(e);
2674
2878
  return;
2675
2879
  }
2676
2880
  globalThis.clearTimeout(e);
2677
2881
  }
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
2882
+ function Hi({ ariaLabel: e, autoFocusFirstTableBodyCell: i = !1, autofocus: a = !1, content: o, contentFormat: c, defaultContent: l = "", defaultContentFormat: u, editable: d = !0, innerToc: f = !0, innerTocPlacement: p, lang: m, mode: h = "live", theme: g, onEditWithAi: _, onExtractToNote: v, onRewriteSelection: y, onRuntimeStateChange: b, onSlashCommandUpload: x, onTableCommandResult: S, onTableCopyPayload: C, onTocChange: w, onUpdate: T, linkCardResolver: E } = {}) {
2883
+ let D = Ie(h), O = gr(g), k = pr(p), A = D === "live" && d !== !1, j = Ze(o === void 0 ? u : c), M = U({
2884
+ editorMode: D,
2885
+ effectiveEditable: A
2682
2886
  });
2683
- O.current = {
2684
- editorMode: C,
2685
- effectiveEditable: E
2887
+ M.current = {
2888
+ editorMode: D,
2889
+ effectiveEditable: A
2686
2890
  };
2687
2891
  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,
2892
+ ee.current === null && (ee.current = r(m));
2893
+ let N = ee.current, P = H(() => n(N), [N]), te = H(() => t(N), [N]), F = U(x);
2894
+ F.current = x;
2895
+ let I = U(E);
2896
+ I.current = E;
2897
+ let ne = H(() => Rr({
2898
+ lang: N,
2693
2899
  onImageUpload: (e) => {
2694
- if (te.current) return te.current(e);
2695
- let t = ve(e);
2900
+ if (F.current) return F.current(e);
2901
+ let t = Se(e);
2696
2902
  if (!t) throw Error("File upload requires an upload handler.");
2697
2903
  return t;
2698
2904
  },
2699
2905
  onVideoUpload: (e) => {
2700
- if (te.current) return te.current(e);
2701
- let t = ve(e);
2906
+ if (F.current) return F.current(e);
2907
+ let t = Se(e);
2702
2908
  if (!t) throw Error("File upload requires an upload handler.");
2703
2909
  return t;
2704
- }
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({
2706
- content: r,
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 = {
2710
- content: r,
2711
- format: D
2910
+ },
2911
+ linkCardResolver: (e) => I.current?.(e) ?? Promise.resolve(null)
2912
+ }), [N]), [L, re] = W(null), [R, z] = W(Wt), [ie, ae] = W(null), [oe, se] = W(null), [ce, le] = W("code"), [ue, de] = W(null), [fe, pe] = W(Xt), [me, he] = W(null), [ge, _e] = W(0), ve = U(!1), ye = U({
2913
+ content: o,
2914
+ format: j
2915
+ }), be = U(null), G = U(null), xe = U({ onUpdate: T }), Ce = H(() => It(R.query, te), [te, R.query]);
2916
+ xe.current = { onUpdate: T }, ye.current = {
2917
+ content: o,
2918
+ format: j
2712
2919
  };
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);
2718
- }, tt);
2920
+ let we = B(() => {
2921
+ G.current !== null && (window.clearTimeout(G.current), G.current = null), _e((e) => e + 1);
2922
+ }, []), Te = B(() => {
2923
+ G.current !== null && window.clearTimeout(G.current), G.current = window.setTimeout(() => {
2924
+ G.current = null, _e((e) => e + 1);
2925
+ }, ct);
2719
2926
  }, []);
2720
2927
  V(() => () => {
2721
- ge.current !== null && window.clearTimeout(ge.current);
2928
+ G.current !== null && window.clearTimeout(G.current);
2722
2929
  }, []);
2723
2930
  let K = B(() => {
2724
- re(null), R(null), F(Lt);
2725
- }, []), xe = B((e) => {
2726
- let t = It(e.state);
2931
+ ae(null), se(null), z(Wt);
2932
+ }, []), Ee = B((e) => {
2933
+ let t = Ut(e.state);
2727
2934
  if (!t) {
2728
- F((e) => e.name === "idle" ? e : Lt), re(null), R(null);
2935
+ z((e) => e.name === "idle" ? e : Wt), ae(null), se(null);
2729
2936
  return;
2730
2937
  }
2731
2938
  let n = e.coordsAtPos(t.cursor), r = e.coordsAtPos(t.triggerFrom), i = e.dom.closest(".markweave-editor-frame")?.getBoundingClientRect();
2732
- re(Ft(n, {
2939
+ ae(Ht(n, {
2733
2940
  frameRect: i,
2734
2941
  triggerRect: r
2735
- })), F((e) => Pt(e, t));
2736
- }, []), Se = B((e) => xe(e.view), [xe]), Ce = B((e) => {
2737
- let t = Qe(e);
2738
- ne((e) => Je(e, t) ? e : t);
2739
- let n = wt(e);
2740
- n && (Et(e, n, !0), z(n));
2741
- let r = ot(e);
2742
- r.active && r.language === "mermaid" && ae(r.mermaidPreviewMode);
2743
- }, []), we = B((e) => {
2744
- ce(wi(e));
2745
- }, []), q = i({
2746
- extensions: M,
2747
- content: r ?? o,
2748
- contentType: Ve(D),
2749
- editable: E,
2750
- autofocus: n,
2942
+ })), z((e) => Vt(e, t));
2943
+ }, []), De = B((e) => Ee(e.view), [Ee]), Oe = B((e) => {
2944
+ let t = at(e);
2945
+ re((e) => tt(e, t) ? e : t);
2946
+ let n = jt(e);
2947
+ n && (Nt(e, n, !0), de(n));
2948
+ let r = pt(e);
2949
+ r.active && r.language === "mermaid" && le(r.mermaidPreviewMode);
2950
+ }, []), ke = B((e) => {
2951
+ pe(Ri(e));
2952
+ }, []), q = s({
2953
+ extensions: ne,
2954
+ content: o ?? l,
2955
+ contentType: Je(j),
2956
+ editable: A,
2957
+ autofocus: a,
2751
2958
  editorProps: {
2752
2959
  attributes: {
2753
2960
  class: "markweave-editor-surface",
@@ -2757,36 +2964,36 @@ function Oi({ ariaLabel: e, autoFocusFirstTableBodyCell: t = !1, autofocus: n =
2757
2964
  spellcheck: "false",
2758
2965
  translate: "no"
2759
2966
  },
2760
- handleClick: (e, t, n) => O.current.effectiveEditable ? !1 : Ge(n),
2967
+ handleClick: (e, t, n) => M.current.effectiveEditable ? !1 : Qe(n),
2761
2968
  handleDOMEvents: {
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),
2969
+ compositionstart: () => M.current.effectiveEditable ? (z((e) => Gt(e, { type: "composition-start" })), ae(null), !1) : !1,
2970
+ compositionend: (e) => (M.current.effectiveEditable && window.setTimeout(() => Ee(e), 0), !1),
2764
2971
  click: (e, t) => {
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);
2972
+ if (M.current.effectiveEditable) {
2973
+ let n = At(e, t);
2974
+ return n ? (t.preventDefault(), t.stopPropagation(), K(), Pt(e, n, !0), Ft(e, n), de(n), !0) : (de(null), !1);
2768
2975
  }
2769
- return Ge(t);
2976
+ return Qe(t);
2770
2977
  }
2771
2978
  }
2772
2979
  },
2773
2980
  onSelectionUpdate: ({ editor: e }) => {
2774
- Ce(e);
2981
+ Oe(e);
2775
2982
  },
2776
2983
  onCreate: ({ editor: e }) => {
2777
- t && O.current.effectiveEditable && Bt(e), we(e), Ce(e), ye();
2984
+ i && M.current.effectiveEditable && qt(e), ke(e), Oe(e), we();
2778
2985
  },
2779
2986
  onTransaction: ({ editor: e, transaction: t }) => {
2780
- we(e), (t.docChanged || ft(t)) && be(), t.docChanged && z((t) => {
2987
+ ke(e), (t.docChanged || yt(t)) && Te(), t.docChanged && de((t) => {
2781
2988
  if (!t) return null;
2782
- let n = St(e, t.pos);
2989
+ let n = kt(e, t.pos);
2783
2990
  return n?.kind === t.kind ? n : null;
2784
2991
  });
2785
2992
  },
2786
2993
  onUpdate: ({ editor: e }) => {
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 = {
2994
+ Oe(e), M.current.effectiveEditable && De(e), ve.current || xe.current.onUpdate?.(qe(e, { onContentRead: (t, n) => {
2995
+ let r = ye.current;
2996
+ r.content !== void 0 && t === r.format && (be.current = {
2790
2997
  content: n,
2791
2998
  format: t,
2792
2999
  doc: e.state.doc
@@ -2795,152 +3002,152 @@ function Oi({ ariaLabel: e, autoFocusFirstTableBodyCell: t = !1, autofocus: n =
2795
3002
  }
2796
3003
  });
2797
3004
  V(() => {
2798
- q && (q.setEditable(E), Fe(q, {
2799
- mode: C,
2800
- editable: E
2801
- }), mt(q, E ? "live" : "view"), ye(), E || K());
3005
+ q && (q.setEditable(A), Le(q, {
3006
+ mode: D,
3007
+ editable: A
3008
+ }), xt(q, A ? "live" : "view"), we(), A || K());
2802
3009
  }, [
2803
3010
  K,
2804
3011
  q,
2805
- C,
2806
- E,
2807
- ye
3012
+ D,
3013
+ A,
3014
+ we
2808
3015
  ]), V(() => {
2809
- q && pt(q, w);
2810
- }, [q, w]), V(() => {
2811
- let e = We(a);
2812
- if (!(!q || r === void 0)) {
2813
- if (Ue(q, he.current, r, e)) {
2814
- he.current = null;
3016
+ q && bt(q, O);
3017
+ }, [q, O]), V(() => {
3018
+ let e = Ze(c);
3019
+ if (!(!q || o === void 0)) {
3020
+ if (Xe(q, be.current, o, e)) {
3021
+ be.current = null;
2815
3022
  return;
2816
3023
  }
2817
- he.current = null, !He(q, r, e) && (pe.current = !0, q.commands.setContent(r, {
2818
- contentType: Ve(e),
3024
+ be.current = null, !Ye(q, o, e) && (ve.current = !0, q.commands.setContent(o, {
3025
+ contentType: Je(e),
2819
3026
  emitUpdate: !1
2820
- }), pe.current = !1, Ce(q), E && Se(q), we(q), ye());
3027
+ }), ve.current = !1, Oe(q), A && De(q), ke(q), we());
2821
3028
  }
2822
3029
  }, [
2823
- r,
2824
- a,
2825
- E,
3030
+ o,
3031
+ c,
3032
+ A,
2826
3033
  q,
2827
- ye,
2828
- Ce,
2829
- Se,
2830
- we
3034
+ we,
3035
+ Oe,
3036
+ De,
3037
+ ke
2831
3038
  ]), V(() => {
2832
- if (!I) return;
3039
+ if (!ie) return;
2833
3040
  let e = (e) => {
2834
3041
  let t = e.target;
2835
3042
  t instanceof Element && (t.closest(".markweave-slash-menu") || t.closest(".markweave-slash-trigger") || K());
2836
3043
  };
2837
3044
  return document.addEventListener("pointerdown", e, !0), () => document.removeEventListener("pointerdown", e, !0);
2838
- }, [K, I]);
2839
- let Te = H(() => q ? ot(q) : Si, [
3045
+ }, [K, ie]);
3046
+ let Ae = H(() => q ? pt(q) : Ii, [
2840
3047
  q,
2841
- de,
2842
- N
2843
- ]), Ee = H(() => q ? Vt(q.state) : xi, [
3048
+ ge,
3049
+ L
3050
+ ]), je = H(() => q ? Jt(q.state) : Fi, [
2844
3051
  q,
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,
3052
+ ge,
3053
+ L,
3054
+ fe
3055
+ ]), Me = L?.currentNode === "codeBlock", Ne = Me && Ae.language === "mermaid", Pe = H(() => q ? Ct({
3056
+ active: Ne,
3057
+ mode: ce,
3058
+ source: Ae.text
3059
+ }) : Li, [
3060
+ Ae.text,
2854
3061
  q,
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(() => {
3062
+ Ne,
3063
+ ce
3064
+ ]), J = H(() => q ? Kt(q.state) : null, [q, ge]), Y = H(() => q ? dr(q.state.doc) : lr.items, [q, ge]), Fe = H(() => fr(Y, me), [me, Y]), Re = H(() => cr(Y, Fe), [Fe, Y]), ze = B(() => {
2858
3065
  if (!q || !Y.length) {
2859
- ue(null);
3066
+ he(null);
2860
3067
  return;
2861
3068
  }
2862
- let e = rr(q, Y);
2863
- ue((t) => t === e ? t : e);
3069
+ let e = ur(q, Y);
3070
+ he((t) => t === e ? t : e);
2864
3071
  }, [q, Y]);
2865
3072
  V(() => {
2866
- ue((e) => {
2867
- let t = ar(Y, e);
3073
+ he((e) => {
3074
+ let t = fr(Y, e);
2868
3075
  return e === t ? e : t;
2869
3076
  });
2870
3077
  }, [Y]), V(() => {
2871
3078
  if (!q || !Y.length || typeof window > "u") return;
2872
3079
  let e = null, t = () => {
2873
- e !== null && Di(e), e = Ei(() => {
2874
- e = null, Le();
3080
+ e !== null && Vi(e), e = Bi(() => {
3081
+ e = null, ze();
2875
3082
  });
2876
- }, n = Ti(q.view.dom);
3083
+ }, n = zi(q.view.dom);
2877
3084
  return window.addEventListener("scroll", t, { passive: !0 }), window.addEventListener("resize", t), n?.addEventListener("scroll", t, { passive: !0 }), t(), () => {
2878
- window.removeEventListener("scroll", t), window.removeEventListener("resize", t), n?.removeEventListener("scroll", t), e !== null && Di(e);
3085
+ window.removeEventListener("scroll", t), window.removeEventListener("resize", t), n?.removeEventListener("scroll", t), e !== null && Vi(e);
2879
3086
  };
2880
3087
  }, [
2881
3088
  q,
2882
3089
  Y.length,
2883
- Le
3090
+ ze
2884
3091
  ]);
2885
- let X = H(() => Ke({
2886
- revision: de,
2887
- mode: C,
2888
- editable: E,
2889
- toc: Ie,
2890
- selection: N,
2891
- slash: P,
2892
- table: Ee,
2893
- tableInteraction: se,
2894
- codeBlock: Te,
2895
- mermaid: ke,
3092
+ let X = H(() => $e({
3093
+ revision: ge,
3094
+ mode: D,
3095
+ editable: A,
3096
+ toc: Re,
3097
+ selection: L,
3098
+ slash: R,
3099
+ table: je,
3100
+ tableInteraction: fe,
3101
+ codeBlock: Ae,
3102
+ mermaid: Pe,
2896
3103
  tableDebugSnapshot: J
2897
3104
  }), [
2898
- Te,
2899
- C,
2900
- E,
2901
- ke,
2902
- de,
2903
- N,
2904
- P,
3105
+ Ae,
3106
+ D,
3107
+ A,
3108
+ Pe,
3109
+ ge,
3110
+ L,
3111
+ R,
2905
3112
  J,
2906
- Ee,
2907
- se,
2908
- Ie
3113
+ je,
3114
+ fe,
3115
+ Re
2909
3116
  ]);
2910
3117
  V(() => {
2911
- _?.(X);
2912
- }, [_, X]), V(() => {
2913
- x?.(Ie);
2914
- }, [x, Ie]);
3118
+ b?.(X);
3119
+ }, [b, X]), V(() => {
3120
+ w?.(Re);
3121
+ }, [w, Re]);
2915
3122
  let Z = B((e, t) => {
2916
- if (!(!q || !E) && At(e)) {
3123
+ if (!(!q || !A) && Lt(e)) {
2917
3124
  if (e.inputKind && !t?.emoji && !t?.uploadResult) {
2918
- R(e);
3125
+ se(e);
2919
3126
  return;
2920
3127
  }
2921
- Nt(q, P, e, t), F((e) => Rt(e, { type: "execute" })), K();
3128
+ Bt(q, R, e, t), z((e) => Gt(e, { type: "execute" })), K();
2922
3129
  }
2923
3130
  }, [
2924
3131
  K,
2925
- E,
3132
+ A,
2926
3133
  q,
2927
- P
3134
+ R
2928
3135
  ]), Q = B((e) => {
2929
- F((t) => Rt(t, {
3136
+ z((t) => Gt(t, {
2930
3137
  type: "set-active",
2931
3138
  index: e,
2932
- optionCount: G.length
3139
+ optionCount: Ce.length
2933
3140
  }));
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) });
3141
+ }, [Ce.length]), Be = B((e) => {
3142
+ if (!q || oe || !A) return;
3143
+ let t = Rt(R, Ce, e.key, { isComposing: e.nativeEvent.isComposing || Ke(q.state) });
2937
3144
  if (t.type !== "ignore") {
2938
3145
  if (t.type === "close") {
2939
- e.preventDefault(), F((e) => Rt(e, { type: "escape" })), K();
3146
+ e.preventDefault(), z((e) => Gt(e, { type: "escape" })), K();
2940
3147
  return;
2941
3148
  }
2942
3149
  if (t.type === "move-active") {
2943
- e.preventDefault(), F((e) => Rt(e, {
3150
+ e.preventDefault(), z((e) => Gt(e, {
2944
3151
  type: "move-active",
2945
3152
  delta: t.delta,
2946
3153
  optionCount: t.optionCount
@@ -2951,155 +3158,155 @@ function Oi({ ariaLabel: e, autoFocusFirstTableBodyCell: t = !1, autofocus: n =
2951
3158
  }
2952
3159
  }, [
2953
3160
  K,
2954
- E,
3161
+ A,
2955
3162
  q,
2956
- G,
3163
+ Ce,
2957
3164
  Z,
2958
- L,
2959
- P
2960
- ]), qe = H(() => ({
3165
+ oe,
3166
+ R
3167
+ ]), Ve = H(() => ({
2961
3168
  closeSlashMenu: K,
2962
- focusFirstTableBodyCell: () => q ? Bt(q) : !1,
3169
+ focusFirstTableBodyCell: () => q ? qt(q) : !1,
2963
3170
  setContent: (e, t = {}) => {
2964
3171
  if (!q) return !1;
2965
- let n = We(t.format);
3172
+ let n = Ze(t.format);
2966
3173
  return q.commands.setContent(e, {
2967
- contentType: Ve(n),
3174
+ contentType: Je(n),
2968
3175
  emitUpdate: t.emitUpdate ?? !1
2969
- }), t.focusFirstTableBodyCell && Bt(q), Ce(q), E && Se(q), we(q), ye(), !0;
3176
+ }), t.focusFirstTableBodyCell && qt(q), Oe(q), A && De(q), ke(q), we(), !0;
2970
3177
  }
2971
3178
  }), [
2972
3179
  K,
2973
- E,
3180
+ A,
2974
3181
  q,
2975
- ye,
2976
- Ce,
2977
- Se,
2978
- we
3182
+ we,
3183
+ Oe,
3184
+ De,
3185
+ ke
2979
3186
  ]);
2980
3187
  return {
2981
3188
  editor: q,
2982
3189
  frameProps: H(() => ({
2983
3190
  className: "markweave-editor-frame",
2984
- "aria-label": e ?? A.common.editorAriaLabel,
3191
+ "aria-label": e ?? P.common.editorAriaLabel,
2985
3192
  "data-testid": "markweave-editor-frame",
2986
- "data-markweave-mode": C,
2987
- "data-markweave-theme": w,
2988
- "data-markweave-inner-toc": l ? "true" : "false",
2989
- "data-markweave-inner-toc-placement": T,
2990
- "data-mermaid-mode": ke.mode,
2991
- "data-table-focus-mode": Ee.mode,
2992
- onKeyDownCapture: Re
3193
+ "data-markweave-mode": D,
3194
+ "data-markweave-theme": O,
3195
+ "data-markweave-inner-toc": f ? "true" : "false",
3196
+ "data-markweave-inner-toc-placement": k,
3197
+ "data-mermaid-mode": Pe.mode,
3198
+ "data-table-focus-mode": je.mode,
3199
+ onKeyDownCapture: Be
2993
3200
  }), [
2994
3201
  e,
2995
- C,
2996
- Re,
2997
- l,
2998
- ke.mode,
2999
- A.common.editorAriaLabel,
3000
- T,
3001
- w,
3002
- Ee.mode
3202
+ D,
3203
+ Be,
3204
+ f,
3205
+ Pe.mode,
3206
+ P.common.editorAriaLabel,
3207
+ k,
3208
+ O,
3209
+ je.mode
3003
3210
  ]),
3004
3211
  overlayProps: H(() => ({
3005
- floatingToolbar: q && E ? {
3212
+ floatingToolbar: q && A ? {
3006
3213
  editor: q,
3007
- messages: A,
3008
- selectionSnapshot: N,
3009
- onRewriteSelection: g,
3010
- onExtractToNote: h
3214
+ messages: P,
3215
+ selectionSnapshot: L,
3216
+ onRewriteSelection: y,
3217
+ onExtractToNote: v
3011
3218
  } : null,
3012
- slashCommandMenu: q && E ? {
3013
- commands: G,
3014
- state: P,
3015
- position: I,
3016
- inputCommand: L,
3017
- messages: A,
3219
+ slashCommandMenu: q && A ? {
3220
+ commands: Ce,
3221
+ state: R,
3222
+ position: ie,
3223
+ inputCommand: oe,
3224
+ messages: P,
3018
3225
  onActiveIndexChange: Q,
3019
- onInputCommandChange: R,
3226
+ onInputCommandChange: se,
3020
3227
  onSelect: Z,
3021
- onUpload: v
3228
+ onUpload: x
3022
3229
  } : null,
3023
- tableControls: q && E ? {
3230
+ tableControls: q && A ? {
3024
3231
  editor: q,
3025
- active: Ee.active,
3026
- interactionState: se,
3027
- messages: A,
3028
- onCopyPayload: b,
3029
- onCommandResult: y,
3030
- onEditWithAi: m
3232
+ active: je.active,
3233
+ interactionState: fe,
3234
+ messages: P,
3235
+ onCopyPayload: C,
3236
+ onCommandResult: S,
3237
+ onEditWithAi: _
3031
3238
  } : null,
3032
- tableSelectionOverlay: q && E ? {
3239
+ tableSelectionOverlay: q && A ? {
3033
3240
  editor: q,
3034
- focusState: Ee
3241
+ focusState: je
3035
3242
  } : null,
3036
3243
  codeBlockControls: q ? {
3037
3244
  editor: q,
3038
- active: E && De,
3039
- mermaidMode: ie,
3040
- onMermaidModeChange: ae,
3041
- readOnly: !E
3245
+ active: A && Me,
3246
+ mermaidMode: ce,
3247
+ onMermaidModeChange: le,
3248
+ readOnly: !A
3042
3249
  } : null,
3043
- innerToc: q && l && Ie.items.length ? {
3250
+ innerToc: q && f && Re.items.length ? {
3044
3251
  editor: q,
3045
- editable: E,
3046
- messages: A,
3047
- placement: T,
3048
- state: Ie
3252
+ editable: A,
3253
+ messages: P,
3254
+ placement: k,
3255
+ state: Re
3049
3256
  } : null,
3050
- mathEditorPopover: q && E && oe ? {
3257
+ mathEditorPopover: q && A && ue ? {
3051
3258
  editor: q,
3052
- messages: A,
3053
- target: oe,
3054
- onClose: () => z(null)
3259
+ messages: P,
3260
+ target: ue,
3261
+ onClose: () => de(null)
3055
3262
  } : null
3056
3263
  }), [
3057
- E,
3058
- q,
3059
- G,
3060
- l,
3061
- De,
3062
- ie,
3063
3264
  A,
3064
- oe,
3065
- m,
3066
- h,
3067
- g,
3265
+ q,
3266
+ Ce,
3267
+ f,
3268
+ Me,
3269
+ ce,
3270
+ P,
3271
+ ue,
3272
+ _,
3068
3273
  v,
3069
3274
  y,
3070
- b,
3275
+ x,
3276
+ S,
3277
+ C,
3071
3278
  Z,
3072
- N,
3073
- Q,
3074
3279
  L,
3075
- I,
3076
- P,
3077
- Ee,
3078
- se,
3079
- Ie
3280
+ Q,
3281
+ oe,
3282
+ ie,
3283
+ R,
3284
+ je,
3285
+ fe,
3286
+ Re
3080
3287
  ]),
3081
3288
  runtimeSnapshot: X,
3082
- actions: qe
3289
+ actions: Ve
3083
3290
  };
3084
3291
  }
3085
- function ki({ className: e, ...n }) {
3086
- let r = Oi(n);
3087
- if (!r.editor) return null;
3088
- let i = [r.frameProps.className, e].filter(Boolean).join(" ");
3292
+ function Ui({ className: e, ...t }) {
3293
+ let n = Hi(t);
3294
+ if (!n.editor) return null;
3295
+ let r = [n.frameProps.className, e].filter(Boolean).join(" ");
3089
3296
  return /* @__PURE__ */ Q("section", {
3090
- ...r.frameProps,
3091
- className: i,
3297
+ ...n.frameProps,
3298
+ className: r,
3092
3299
  children: [
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,
3100
- /* @__PURE__ */ Z(t, { editor: r.editor })
3300
+ n.overlayProps.floatingToolbar ? /* @__PURE__ */ Z(ci, { ...n.overlayProps.floatingToolbar }) : null,
3301
+ n.overlayProps.slashCommandMenu ? /* @__PURE__ */ Z(ki, { ...n.overlayProps.slashCommandMenu }) : null,
3302
+ n.overlayProps.tableControls ? /* @__PURE__ */ Z(ji, { ...n.overlayProps.tableControls }) : null,
3303
+ n.overlayProps.tableSelectionOverlay ? /* @__PURE__ */ Z(Mi, { ...n.overlayProps.tableSelectionOverlay }) : null,
3304
+ n.overlayProps.codeBlockControls ? /* @__PURE__ */ Z(Vr, { ...n.overlayProps.codeBlockControls }) : null,
3305
+ n.overlayProps.innerToc ? /* @__PURE__ */ Z(Pi, { ...n.overlayProps.innerToc }) : null,
3306
+ n.overlayProps.mathEditorPopover ? /* @__PURE__ */ Z(bi, { ...n.overlayProps.mathEditorPopover }) : null,
3307
+ /* @__PURE__ */ Z(i, { editor: n.editor })
3101
3308
  ]
3102
3309
  });
3103
3310
  }
3104
3311
  //#endregion
3105
- export { ki as MarkweaveEditor, wr as createMarkweaveEditorExtensions, wr as createMarkweaveReactEditorExtensions, Oi as useMarkweaveEditorController };
3312
+ export { Ui as MarkweaveEditor, Rr as createMarkweaveEditorExtensions, Rr as createMarkweaveReactEditorExtensions, Hi as useMarkweaveEditorController };