@markweave/react 0.5.3 → 0.6.0

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,124 +1,126 @@
1
1
  import { createMarkweaveEditorExtensions as e } from "markweave/internal/editor-core/create-editor-extensions";
2
- import { getLocalizedSlashCommandSpecs as t, getMarkweaveMessages as n, normalizeMarkweaveLang as r } from "markweave/internal/i18n";
3
- import { createMarkweaveAdapterMediaExtensions as i } from "markweave/internal/plugins/media/media-extension-factory";
4
- import { EditorContent as a, NodeViewWrapper as o, ReactNodeViewRenderer as s, useEditor as c } from "@tiptap/react";
5
- import { AlertTriangle as l, AlignCenter as u, AlignJustify as d, AlignLeft as f, AlignRight as p, AlignVerticalJustifyCenter as m, AlignVerticalJustifyEnd as h, AlignVerticalJustifyStart as g, ArrowDown as _, ArrowDownAZ as v, ArrowLeft as y, ArrowRight as b, ArrowUp as x, ArrowUpZA as S, BetweenHorizontalEnd as C, BetweenHorizontalStart as w, BetweenVerticalEnd as T, BetweenVerticalStart as E, Bold as D, Braces as O, Captions as k, Check as A, CheckCircle2 as j, ChevronDown as ee, ChevronRight as M, ChevronUp as te, CircleX as N, Code2 as ne, Copy as P, CornerDownLeft as re, Download as F, ExternalLink as I, Eye as ie, Heading1 as ae, Heading2 as L, Heading3 as oe, Image as R, ImageUp as z, IndentDecrease as B, IndentIncrease as se, Info as ce, Italic as V, Lightbulb as le, Link2 as ue, List as H, ListChecks as de, ListOrdered as U, Minus as fe, MoreVertical as pe, PaintBucket as me, Paperclip as W, Pencil as he, Plus as ge, Quote as _e, Replace as ve, RotateCcw as ye, Sigma as be, SmilePlus as xe, Sparkles as Se, Square as Ce, SquareX as we, Strikethrough as Te, Subscript as Ee, Superscript as De, Table2 as Oe, TableCellsMerge as ke, TableCellsSplit as Ae, Text as je, Trash2 as Me, Type as Ne, Underline as Pe, Upload as Fe, Video as Ie, X as Le } from "lucide-react";
6
- import { useCallback as G, useEffect as K, useLayoutEffect as Re, useMemo as q, useRef as J, useState as Y, useSyncExternalStore as ze } from "react";
7
- import { getMarkweaveEditorModeState as Be, isMarkweaveEditorLiveEditable as Ve, normalizeMarkweaveEditorMode as He, setMarkweaveEditorModeState as Ue, subscribeToMarkweaveEditorMode as X } from "markweave/internal/core/editor-mode-state";
8
- import { activateMarkweaveAttachmentDownload as We, attrsFromMarkweaveAttachmentUploadResult as Ge, createMarkweaveAttachmentRefFromAttrs as Ke, createMarkweaveAttachmentUploadRequest as qe, formatMarkweaveAttachmentSize as Je } from "markweave/internal/plugins/media/attachment-download";
9
- import { MarkweaveCoreImage as Ye, MarkweaveCoreVideo as Xe, attrsFromMarkweaveImageUploadResult as Ze, attrsFromMarkweaveVideoUploadResult as Qe, attrsFromMarkweaveVideoUrl as $e, clampMarkweaveImageWidth as et, createMarkweaveImageUploadRequest as tt, createMarkweaveVideoUploadRequest as nt, downloadMarkweaveImage as rt, markweaveVideoIframeAllow as it, normalizeMarkweaveCoreImageAlign as at, normalizeMarkweaveVideoEmbedUrl as ot, numberAttribute as st, stringAttribute as ct } from "markweave/internal/plugins/media/core-media-nodes";
2
+ import { getMarkweaveMessages as t, normalizeMarkweaveLang as n } from "markweave/internal/i18n";
3
+ import { createMarkweaveAdapterMediaExtensions as r } from "markweave/internal/plugins/media/media-extension-factory";
4
+ import { EditorContent as i, NodeViewWrapper as a, ReactNodeViewRenderer as o, useEditor as s } from "@tiptap/react";
5
+ import { AlertTriangle as c, AlignCenter as l, AlignJustify as u, AlignLeft as d, AlignRight as f, AlignVerticalJustifyCenter as p, AlignVerticalJustifyEnd as m, AlignVerticalJustifyStart as h, ArrowDown as g, ArrowDownAZ as _, ArrowLeft as v, ArrowRight as y, ArrowUp as b, ArrowUpZA as x, BetweenHorizontalEnd as S, BetweenHorizontalStart as C, BetweenVerticalEnd as w, BetweenVerticalStart as T, Bold as E, Braces as D, Captions as ee, Check as O, CheckCircle2 as k, ChevronDown as A, ChevronRight as te, ChevronUp as j, CircleX as ne, Code2 as re, Copy as ie, CornerDownLeft as ae, Download as M, ExternalLink as N, Eye as P, Heading1 as oe, Heading2 as F, Heading3 as I, Image as se, ImageUp as L, IndentDecrease as R, IndentIncrease as z, Info as ce, Italic as le, Lightbulb as B, Link2 as ue, List as V, ListChecks as H, ListOrdered as de, Minus as fe, MoreVertical as pe, PaintBucket as me, Paperclip as he, Pencil as ge, Plus as _e, Quote as ve, Replace as ye, RotateCcw as be, Sigma as xe, SmilePlus as Se, Sparkles as U, Square as Ce, SquareX as we, Strikethrough as Te, Subscript as Ee, Superscript as De, Table2 as Oe, TableCellsMerge as ke, TableCellsSplit as Ae, Text as je, Trash2 as Me, Type as Ne, Underline as Pe, Upload as Fe, Video as Ie, X as Le } from "lucide-react";
6
+ import { useCallback as W, useEffect as G, useLayoutEffect as Re, useMemo as K, useRef as q, useState as J, useSyncExternalStore as ze } from "react";
7
+ import { getMarkweaveEditorModeState as Be, isMarkweaveEditorLiveEditable as Ve, normalizeMarkweaveEditorMode as He, setMarkweaveEditorModeState as Ue, subscribeToMarkweaveEditorMode as We } from "markweave/internal/core/editor-mode-state";
8
+ import { activateMarkweaveAttachmentDownload as Ge, attrsFromMarkweaveAttachmentUploadResult as Ke, createMarkweaveAttachmentRefFromAttrs as qe, createMarkweaveAttachmentUploadRequest as Je, formatMarkweaveAttachmentSize as Ye } from "markweave/internal/plugins/media/attachment-download";
9
+ import { MarkweaveCoreImage as Xe, MarkweaveCoreVideo as Ze, attrsFromMarkweaveImageUploadResult as Qe, attrsFromMarkweaveVideoUploadResult as $e, attrsFromMarkweaveVideoUrl as et, clampMarkweaveImageWidth as tt, createMarkweaveImageUploadRequest as nt, createMarkweaveVideoUploadRequest as Y, downloadMarkweaveImage as rt, markweaveVideoIframeAllow as it, normalizeMarkweaveCoreImageAlign as at, normalizeMarkweaveVideoEmbedUrl as ot, numberAttribute as st, stringAttribute as ct } from "markweave/internal/plugins/media/core-media-nodes";
10
10
  import { MarkweaveAttachment as lt } from "markweave/internal/plugins/media/media-nodes";
11
11
  import { detectUploadSource as ut, getDirectUploadResult as dt, resolveMarkweaveUploadResult as ft } from "markweave/internal/plugins/slash-command/upload";
12
- import { Fragment as pt, jsx as Z, jsxs as Q } from "react/jsx-runtime";
13
- import { openMarkweaveImagePreview as mt } from "markweave/internal/plugins/media/image-preview";
14
- import { createMarkweaveLightweightImageNodeViewRenderer as ht } from "markweave/internal/plugins/media/lightweight-image-node-view";
15
- import { resolveMarkweaveMediaSource as gt } from "markweave/internal/plugins/media/media-source";
16
- import { normalizeMarkweaveLinkCardAttrs as _t, normalizeMarkweaveLinkCardHref as vt, replaceMarkweaveLinkCardWithLink as yt } from "markweave/internal/plugins/link-card/link-card";
17
- import { openMarkweaveLinkCardComposer as bt } from "markweave/internal/plugins/link-card/link-card-composer";
18
- import { MarkweaveLinkCard as xt } from "markweave/internal/plugins/link-card/link-card-node";
19
- import { createMarkweaveAiEditController as St } from "markweave";
20
- import { isEditorComposing as Ct } from "markweave/internal/editor-core/composition-guard";
21
- import { createMarkweaveFrameScheduler as wt } from "markweave/internal/editor-core/frame-scheduler";
22
- import { createMarkweaveEditorUpdatePayload as Tt, getMarkweaveContentType as Et, isEditorContentCurrent as Dt, isMarkweaveControlledContentEchoCurrent as Ot, normalizeMarkweaveContentFormat as kt } from "markweave/internal/editor-core/editor-content";
23
- import { openMarkweaveReadonlyLinkFromEvent as At } from "markweave/internal/editor-core/readonly-link";
24
- import { createMarkweaveEditorRuntimeSnapshot as jt } from "markweave/internal/editor-core/runtime-snapshot";
25
- import { advanceFloatingToolbarMotionState as Mt, areEditorSelectionSnapshotsEquivalent as Nt, calculateFloatingToolbarFrameShift as Pt, calculateFloatingToolbarPopoverPlacement as Ft, calculateFloatingToolbarTopBoundary as It, createSelectionSnapshot as Lt, getFloatingToolbarFloatingOptions as Rt, getFloatingToolbarState as zt, markweaveRuntimeProjectionDelayMs as Bt, shouldShowFloatingToolbarForAiState as Vt, transitionFloatingToolbarState as Ht } from "markweave/internal/editor-core/selection-state";
26
- import { codeBlockCollapsePluginKey as Ut, copyActiveCodeBlock as Wt, getActiveCodeBlockState as Gt, getCodeBlockCopyFeedbackSnapshot as Kt, markweaveCodeBlockBehavior as qt, setCodeBlockCollapsedAtPosition as Jt, setCodeBlockLanguageAtPosition as Yt, setCodeBlockMermaidPreviewModeAtPosition as Xt } from "markweave/internal/plugins/codeblock/codeblock-behavior";
27
- import { isMermaidInlinePreviewTransaction as Zt, setMarkweaveMermaidTheme as Qt, setMermaidInlinePreviewEditorMode as $t, setReadonlyMermaidPreviewMode as en } from "markweave/internal/plugins/mermaid/mermaid-inline-preview";
28
- import { getMermaidPreviewState as tn } from "markweave/internal/plugins/mermaid/mermaid-renderer";
29
- import { applyMarkweaveMathLatex as nn, calculateMarkweaveMathPopoverPosition as rn, getMarkweaveMathAnchorRect as an, getMarkweaveMathBlockIndex as on, getMarkweaveMathRenderedHtml as sn, getMarkweaveMathTargetAtPos as cn, getMarkweaveMathTargetFromDomEvent as ln, getMarkweaveMathTargetFromSelection as un, renderMarkweaveMathPreview as dn, setMarkweaveMathEditingDomState as fn, setMarkweaveMathEditingDomStateInView as pn, setMarkweaveMathSelectionInView as mn } from "markweave/internal/plugins/math/math-ui-model";
30
- import { filterSlashCommands as hn, isExecutableSlashCommand as gn } from "markweave/internal/plugins/slash-command/command-spec";
12
+ import { Fragment as X, jsx as Z, jsxs as Q } from "react/jsx-runtime";
13
+ import { openMarkweaveImagePreview as pt } from "markweave/internal/plugins/media/image-preview";
14
+ import { createMarkweaveLightweightImageNodeViewRenderer as mt } from "markweave/internal/plugins/media/lightweight-image-node-view";
15
+ import { resolveMarkweaveMediaSource as ht } from "markweave/internal/plugins/media/media-source";
16
+ import { normalizeMarkweaveLinkCardAttrs as gt, normalizeMarkweaveLinkCardHref as _t, replaceMarkweaveLinkCardWithLink as vt } from "markweave/internal/plugins/link-card/link-card";
17
+ import { openMarkweaveLinkCardComposer as yt } from "markweave/internal/plugins/link-card/link-card-composer";
18
+ import { MarkweaveLinkCard as bt } from "markweave/internal/plugins/link-card/link-card-node";
19
+ import { createMarkweaveAiEditController as xt } from "markweave";
20
+ import { isEditorComposing as St } from "markweave/internal/editor-core/composition-guard";
21
+ import { createMarkweaveFrameScheduler as Ct } from "markweave/internal/editor-core/frame-scheduler";
22
+ import { createMarkweaveEditorUpdatePayload as wt, getMarkweaveContentType as Tt, isEditorContentCurrent as Et, isMarkweaveControlledContentEchoCurrent as Dt, normalizeMarkweaveContentFormat as Ot } from "markweave/internal/editor-core/editor-content";
23
+ import { openMarkweaveReadonlyLinkFromEvent as kt } from "markweave/internal/editor-core/readonly-link";
24
+ import { createMarkweaveEditorRuntimeSnapshot as At } from "markweave/internal/editor-core/runtime-snapshot";
25
+ import { advanceFloatingToolbarMotionState as jt, areEditorSelectionSnapshotsEquivalent as Mt, calculateFloatingToolbarFrameShift as Nt, calculateFloatingToolbarPopoverPlacement as Pt, calculateFloatingToolbarTopBoundary as Ft, createSelectionSnapshot as It, getFloatingToolbarFloatingOptions as Lt, getFloatingToolbarState as Rt, markweaveRuntimeProjectionDelayMs as zt, shouldShowFloatingToolbarForAiState as Bt, transitionFloatingToolbarState as Vt } from "markweave/internal/editor-core/selection-state";
26
+ import { codeBlockCollapsePluginKey as Ht, copyActiveCodeBlock as Ut, getActiveCodeBlockState as Wt, getCodeBlockCopyFeedbackSnapshot as Gt, markweaveCodeBlockBehavior as Kt, setCodeBlockCollapsedAtPosition as qt, setCodeBlockLanguageAtPosition as Jt, setCodeBlockMermaidPreviewModeAtPosition as Yt } from "markweave/internal/plugins/codeblock/codeblock-behavior";
27
+ import { isMermaidInlinePreviewTransaction as Xt, setMarkweaveMermaidTheme as Zt, setMermaidInlinePreviewEditorMode as Qt, setReadonlyMermaidPreviewMode as $t } from "markweave/internal/plugins/mermaid/mermaid-inline-preview";
28
+ import { getMermaidPreviewState as en } from "markweave/internal/plugins/mermaid/mermaid-renderer";
29
+ import { applyMarkweaveMathLatex as tn, calculateMarkweaveMathPopoverPosition as nn, getMarkweaveMathAnchorRect as rn, getMarkweaveMathBlockIndex as an, getMarkweaveMathRenderedHtml as on, getMarkweaveMathTargetAtPos as sn, getMarkweaveMathTargetFromDomEvent as cn, getMarkweaveMathTargetFromSelection as ln, renderMarkweaveMathPreview as un, setMarkweaveMathEditingDomState as dn, setMarkweaveMathEditingDomStateInView as fn, setMarkweaveMathSelectionInView as pn } from "markweave/internal/plugins/math/math-ui-model";
30
+ import { createResolvedSlashCommandSpecs as mn, filterSlashCommands as hn, isExecutableSlashCommand as gn } from "markweave/internal/plugins/slash-command/command-spec";
31
31
  import { getSlashCommandKeyboardAction as _n, isSlashCommandMenuState as vn } from "markweave/internal/plugins/slash-command/slash-keyboard";
32
- import { areSlashCommandMenuPositionsEquivalent as yn, executeSlashCommand as bn, getNextSlashCommandState as xn, getSlashCommandAnchoredMenuPosition as Sn, getSlashCommandContext as Cn, isMarkweaveSlashMenuScrollTarget as wn, isSlashCommandAnchorVisible as Tn } from "markweave/internal/plugins/slash-command/slash-runtime";
33
- import { initialSlashCommandState as En, reduceSlashCommandState as Dn } from "markweave/internal/plugins/slash-command/slash-state";
34
- import { getFirstTableDebugSnapshot as On } from "markweave/internal/plugins/table/table-debug-snapshot";
35
- import { focusFirstTableBodyCell as kn } from "markweave/internal/plugins/table/table-focus-position";
36
- import { getTableFocusState as An } from "markweave/internal/plugins/table/table-focus-state";
37
- import { getTableSelectionOverlayState as jn, initialTableInteractionState as Mn, tableInteractionPluginKey as Nn } from "markweave/internal/plugins/table/table-interaction-layer";
38
- import { saveMarkweaveBrowserFile as Pn } from "markweave/internal/core/browser-file-save";
39
- import { calculateCodeBlockLanguageMenuPosition as Fn, clampFullscreenScale as In, codeBlockCopyFeedbackTimeoutMs as Ln, copyCodeBlockText as Rn, createCodeBlockLanguageMenuDomId as zn, createCodeBlockOverlayPosition as Bn, createMermaidFullscreenViewerState as Vn, createMermaidTabPosition as Hn, focusCodeBlockTarget as Un, formatCodeBlockLanguageLabel as Wn, formatFullscreenZoom as Gn, getActiveCodeBlockElement as Kn, getAnchoredRect as qn, getCodeBlockLanguageItems as Jn, getCodeBlockLanguageOptionDomId as Yn, getCodeBlockPositionFromEventTarget as Xn, getCodeBlockStateAtPosition as Zn, getFrameElement as Qn, getInitialCodeBlockLanguageItemIndex as $n, getMermaidCodeBlockTargets as er, getMermaidSvgMarkup as tr, isCodeBlockTargetCollapsed as nr, mergeStableMermaidTabPositions as rr, mermaidFullscreenZoomStep as ir, moveCodeBlockLanguageItemIndex as ar, moveMermaidFullscreenViewer as or, scrollCodeBlockLanguageItemIntoView as sr } from "markweave/internal/plugins/codeblock/codeblock-ui-model";
40
- import { BubbleMenu as cr } from "@tiptap/react/menus";
41
- import { applyFloatingToolbarLink as lr, createFloatingToolbarAssistantRequest as ur, getFloatingToolbarButtonModels as dr, getFloatingToolbarHighlightColorOptions as fr, getFloatingToolbarLinkHref as pr, getFloatingToolbarMessageSet as mr, getFloatingToolbarMoreActions as hr, getFloatingToolbarTextColorOptions as gr, getFloatingToolbarTooltipModel as _r, getFloatingToolbarTurnIntoOptions as vr, isFloatingToolbarMoreActionActive as yr, isFloatingToolbarTurnIntoActive as br, openFloatingToolbarLinkHref as xr, preventFloatingToolbarPointerFocusLoss as Sr, removeFloatingToolbarLink as Cr, runFloatingToolbarMoreAction as wr, setFloatingToolbarHighlightColor as Tr, setFloatingToolbarTextColor as Er, setFloatingToolbarTurnInto as Dr } from "markweave/internal/editor-core/floating-toolbar-model";
42
- import { MarkweaveAskAiError as Or, acceptMarkweaveAskAiResult as kr, calculateMarkweaveAskAiPanelPosition as Ar, canStartMarkweaveAskAiTableTarget as jr, clearMarkweaveAskAiPreview as Mr, clearMarkweaveAskAiTarget as Nr, createMarkweaveAskAiRequest as Pr, getMappedMarkweaveAskAiSelection as Fr, getMarkweaveAskAiSurfaceRect as Ir, getMarkweaveAskAiTarget as Lr, getMarkweaveAskAiTargetRect as Rr, hasMarkweaveAskAiPreview as zr, restoreMarkweaveAskAiTargetSelection as Br, runMarkweaveAskAiHandler as Vr, setMarkweaveAskAiPreview as Hr, startMarkweaveAskAiTableTarget as Ur, startMarkweaveAskAiTarget as Wr } from "markweave/internal/plugins/ask-ai/ask-ai-session";
43
- import { normalizeMarkdownLinkHref as Gr } from "markweave/internal/plugins/markdown/markdown-input";
44
- import { scrollSlashCommandItemIntoView as Kr } from "markweave/internal/plugins/slash-command/slash-menu-scroll";
45
- import { setMarkweaveTableMenuAxisTarget as qr } from "markweave/internal/plugins/table/table-clipboard";
46
- import { applyTableAxisAlignment as Jr, applyTableAxisBackgroundColor as Yr, applyTableAxisTextColor as Xr, calculateAnchoredTableMenuPosition as Zr, calculateAnchoredTableSubmenuPosition as Qr, calculateTableAxisHandleLayout as $r, calculateTableExtendButtonLayout as ei, canRunTableCommand as ti, executeTableMenuCommand as ni, formatTableCopyFeedback as ri, getActiveTableElement as ii, getTableAxisDropIndexAtPoint as ai, getTableAxisFormattingState as oi, getTableAxisTargetRect as si, getTableControlAxisSelectionModel as ci, getTableMenuBoundaryRect as li, getTableMenuItemGroup as ui, getTableMenuItemLabel as di, getTableMenuItems as fi, getTableSelectionTargetRect as pi, measureTableSelectionOverlay as mi, moveTargetedTableAxis as hi, selectTableAxisFromCell as gi, tableColorOptions as _i, tableCopyFeedbackTimeoutMs as vi, tableHorizontalAlignmentOptions as yi, tableMenuLabel as bi, tableVerticalAlignmentOptions as xi, targetTableAxisFromCell as Si } from "markweave/internal/plugins/table/table-ui-model";
47
- import { createMarkweaveTocState as Ci, emptyMarkweaveTocState as wi, getActiveMarkweaveTocId as Ti, getMarkweaveInnerTocRailHeight as Ei, getMarkweaveTocItemsFromState as Di, getValidMarkweaveTocActiveId as Oi, normalizeMarkweaveInnerTocPlacement as ki, observeMarkweaveInnerTocContainerPosition as Ai, observeMarkweaveInnerTocRailOverflow as ji, scrollToMarkweaveTocItem as Mi } from "markweave/internal/core/toc-state";
48
- import { normalizeMarkweaveCanvasColor as Ni, normalizeMarkweaveTheme as Pi } from "markweave/internal/core/theme";
49
- import { splitMarkweaveLargeMarkdown as Fi } from "markweave/internal/core/large-document";
50
- import { createMarkweaveSearchController as Ii } from "markweave/internal/plugins/search/search-controller";
51
- import { createMarkweaveAiEditController as Li } from "markweave/internal/plugins/ai-edit/ai-edit-controller";
32
+ import { areSlashCommandMenuPositionsEquivalent as yn, getNextSlashCommandState as bn, getSlashCommandAnchoredMenuPosition as xn, getSlashCommandContext as Sn, isMarkweaveSlashMenuScrollTarget as Cn, isSlashCommandAnchorVisible as wn } from "markweave/internal/plugins/slash-command/slash-runtime";
33
+ import { createMarkweaveCommandController as Tn, executeMarkweaveSlashCommand as En, setMarkweaveCommandContentFormat as Dn, setMarkweaveCommandRegistry as On } from "markweave/internal/commands/command-runtime";
34
+ import { createMarkweaveCommandRegistry as kn } from "markweave/internal/commands/command-registry";
35
+ import { initialSlashCommandState as An, reduceSlashCommandState as jn } from "markweave/internal/plugins/slash-command/slash-state";
36
+ import { getFirstTableDebugSnapshot as Mn } from "markweave/internal/plugins/table/table-debug-snapshot";
37
+ import { focusFirstTableBodyCell as Nn } from "markweave/internal/plugins/table/table-focus-position";
38
+ import { getTableFocusState as Pn } from "markweave/internal/plugins/table/table-focus-state";
39
+ import { getTableSelectionOverlayState as Fn, initialTableInteractionState as In, tableInteractionPluginKey as Ln } from "markweave/internal/plugins/table/table-interaction-layer";
40
+ import { saveMarkweaveBrowserFile as Rn } from "markweave/internal/core/browser-file-save";
41
+ import { calculateCodeBlockLanguageMenuPosition as zn, clampFullscreenScale as Bn, codeBlockCopyFeedbackTimeoutMs as Vn, copyCodeBlockText as Hn, createCodeBlockLanguageMenuDomId as Un, createCodeBlockOverlayPosition as Wn, createMermaidFullscreenViewerState as Gn, createMermaidTabPosition as Kn, focusCodeBlockTarget as qn, formatCodeBlockLanguageLabel as Jn, formatFullscreenZoom as Yn, getActiveCodeBlockElement as Xn, getAnchoredRect as Zn, getCodeBlockLanguageItems as Qn, getCodeBlockLanguageOptionDomId as $n, getCodeBlockPositionFromEventTarget as er, getCodeBlockStateAtPosition as tr, getFrameElement as nr, getInitialCodeBlockLanguageItemIndex as rr, getMermaidCodeBlockTargets as ir, getMermaidSvgMarkup as ar, isCodeBlockTargetCollapsed as or, mergeStableMermaidTabPositions as sr, mermaidFullscreenZoomStep as cr, moveCodeBlockLanguageItemIndex as lr, moveMermaidFullscreenViewer as ur, scrollCodeBlockLanguageItemIntoView as dr } from "markweave/internal/plugins/codeblock/codeblock-ui-model";
42
+ import { BubbleMenu as fr } from "@tiptap/react/menus";
43
+ import { applyFloatingToolbarLink as pr, createFloatingToolbarAssistantRequest as mr, getFloatingToolbarButtonModels as hr, getFloatingToolbarHighlightColorOptions as gr, getFloatingToolbarLinkHref as _r, getFloatingToolbarMessageSet as vr, getFloatingToolbarMoreActions as yr, getFloatingToolbarTextColorOptions as br, getFloatingToolbarTooltipModel as xr, getFloatingToolbarTurnIntoOptions as Sr, isFloatingToolbarMoreActionActive as Cr, isFloatingToolbarTurnIntoActive as wr, openFloatingToolbarLinkHref as Tr, preventFloatingToolbarPointerFocusLoss as Er, removeFloatingToolbarLink as Dr, runFloatingToolbarMoreAction as Or, setFloatingToolbarHighlightColor as kr, setFloatingToolbarTextColor as Ar, setFloatingToolbarTurnInto as jr } from "markweave/internal/editor-core/floating-toolbar-model";
44
+ import { MarkweaveAskAiError as Mr, acceptMarkweaveAskAiResult as Nr, calculateMarkweaveAskAiPanelPosition as Pr, canStartMarkweaveAskAiTableTarget as Fr, clearMarkweaveAskAiPreview as Ir, clearMarkweaveAskAiTarget as Lr, createMarkweaveAskAiRequest as Rr, getMappedMarkweaveAskAiSelection as zr, getMarkweaveAskAiSurfaceRect as Br, getMarkweaveAskAiTarget as Vr, getMarkweaveAskAiTargetRect as Hr, hasMarkweaveAskAiPreview as Ur, restoreMarkweaveAskAiTargetSelection as Wr, runMarkweaveAskAiHandler as Gr, setMarkweaveAskAiPreview as Kr, startMarkweaveAskAiTableTarget as qr, startMarkweaveAskAiTarget as Jr } from "markweave/internal/plugins/ask-ai/ask-ai-session";
45
+ import { normalizeMarkdownLinkHref as Yr } from "markweave/internal/plugins/markdown/markdown-input";
46
+ import { scrollSlashCommandItemIntoView as Xr } from "markweave/internal/plugins/slash-command/slash-menu-scroll";
47
+ import { setMarkweaveTableMenuAxisTarget as Zr } from "markweave/internal/plugins/table/table-clipboard";
48
+ import { applyTableAxisAlignment as Qr, applyTableAxisBackgroundColor as $r, applyTableAxisTextColor as ei, calculateAnchoredTableMenuPosition as ti, calculateAnchoredTableSubmenuPosition as ni, calculateTableAxisHandleLayout as ri, calculateTableExtendButtonLayout as ii, canRunTableCommand as ai, executeTableMenuCommand as oi, formatTableCopyFeedback as si, getActiveTableElement as ci, getTableAxisDropIndexAtPoint as li, getTableAxisFormattingState as ui, getTableAxisTargetRect as di, getTableControlAxisSelectionModel as fi, getTableMenuBoundaryRect as pi, getTableMenuItemGroup as mi, getTableMenuItemLabel as hi, getTableMenuItems as gi, getTableSelectionTargetRect as _i, measureTableSelectionOverlay as vi, moveTargetedTableAxis as yi, selectTableAxisFromCell as bi, tableColorOptions as xi, tableCopyFeedbackTimeoutMs as Si, tableHorizontalAlignmentOptions as Ci, tableMenuLabel as wi, tableVerticalAlignmentOptions as Ti, targetTableAxisFromCell as Ei } from "markweave/internal/plugins/table/table-ui-model";
49
+ import { createMarkweaveTocState as Di, emptyMarkweaveTocState as Oi, getActiveMarkweaveTocId as ki, getMarkweaveInnerTocRailHeight as Ai, getMarkweaveTocItemsFromState as ji, getValidMarkweaveTocActiveId as Mi, normalizeMarkweaveInnerTocPlacement as Ni, observeMarkweaveInnerTocContainerPosition as Pi, observeMarkweaveInnerTocRailOverflow as Fi, scrollToMarkweaveTocItem as Ii } from "markweave/internal/core/toc-state";
50
+ import { normalizeMarkweaveCanvasColor as Li, normalizeMarkweaveTheme as Ri } from "markweave/internal/core/theme";
51
+ import { splitMarkweaveLargeMarkdown as zi } from "markweave/internal/core/large-document";
52
+ import { createMarkweaveSearchController as Bi } from "markweave/internal/plugins/search/search-controller";
53
+ import { createMarkweaveAiEditController as Vi } from "markweave/internal/plugins/ai-edit/ai-edit-controller";
52
54
  //#region src/editor-mode-state.ts
53
- var Ri = {
55
+ var Hi = {
54
56
  mode: "live",
55
57
  editable: !0
56
58
  };
57
- function zi(e) {
58
- return ze((t) => X(e, t), () => Be(e), () => Ri);
59
+ function Ui(e) {
60
+ return ze((t) => We(e, t), () => Be(e), () => Hi);
59
61
  }
60
62
  //#endregion
61
63
  //#region src/media/attachment-node.tsx
62
- function Bi(e) {
64
+ function Wi(e) {
63
65
  return e instanceof Element && !!e.closest("[data-markweave-attachment-ui=\"true\"], .markweave-attachment-upload-placeholder, .markweave-attachment-uploading");
64
66
  }
65
- function Vi(e, t) {
67
+ function Gi(e, t) {
66
68
  return typeof t != "number" || !Number.isFinite(t) || t <= 0 ? null : Math.max(0, Math.min(100, Math.round(e / t * 100)));
67
69
  }
68
- function Hi(e) {
69
- let { deleteNode: t, editor: r, getPos: i, node: a, selected: s, updateAttributes: c } = e, l = e.extension.options, u = (l.messages ?? n("zh")).attachment, d = Ve(zi(r)), f = Ke(a.attrs), p = J(null), [m, h] = Y(!1), [g, _] = Y(!1), [v, y] = Y(null), [b, x] = Y(null), [S, C] = Y(null), [w, T] = Y(null), E = d && !f && !g, D = g, O = !!f && (m || s), k = () => {
70
+ function Ki(e) {
71
+ let { deleteNode: n, editor: r, getPos: i, node: o, selected: s, updateAttributes: c } = e, l = e.extension.options, u = (l.messages ?? t("zh")).attachment, d = Ve(Ui(r)), f = qe(o.attrs), p = q(null), [m, h] = J(!1), [g, _] = J(!1), [v, y] = J(null), [b, x] = J(null), [S, C] = J(null), [w, T] = J(null), E = d && !f && !g, D = g, ee = !!f && (m || s), O = () => {
70
72
  if (!d) return;
71
73
  let e = i();
72
74
  typeof e == "number" && r.chain().focus().setNodeSelection(e).run();
75
+ }, k = (e) => {
76
+ !d || Wi(e.target) || (e.preventDefault(), O());
73
77
  }, A = (e) => {
74
- !d || Bi(e.target) || (e.preventDefault(), k());
75
- }, j = (e) => {
76
- d && s && (e.key === "Delete" || e.key === "Backspace") && (e.preventDefault(), t());
77
- }, ee = () => {
78
+ d && s && (e.key === "Delete" || e.key === "Backspace") && (e.preventDefault(), n());
79
+ }, te = () => {
78
80
  !d || g || p.current?.click();
79
- }, M = async (e) => {
81
+ }, j = async (e) => {
80
82
  if (!(!d || !e || g)) {
81
83
  y(null), _(!0), x(e.name), C(e.size), T(null);
82
84
  try {
83
85
  let t = await ft({
84
- ...qe({
86
+ ...Je({
85
87
  type: "file",
86
88
  file: e,
87
89
  mimeType: e.type || void 0
88
90
  }),
89
91
  onProgress: (e) => {
90
- T(Vi(e.loaded, e.total));
92
+ T(Gi(e.loaded, e.total));
91
93
  }
92
94
  }, l.onUpload);
93
- c(Ge(t));
95
+ c(Ke(t));
94
96
  } catch (e) {
95
97
  y(e instanceof Error ? e.message : u.uploadFailedError);
96
98
  } finally {
97
99
  _(!1), x(null), C(null), T(null), p.current && (p.current.value = "");
98
100
  }
99
101
  }
100
- }, te = (e) => {
101
- M(e.currentTarget.files?.[0] ?? null);
102
- }, N = (e) => {
103
- if (!Bi(e.target)) {
102
+ }, ne = (e) => {
103
+ j(e.currentTarget.files?.[0] ?? null);
104
+ }, re = (e) => {
105
+ if (!Wi(e.target)) {
104
106
  if (e.preventDefault(), e.stopPropagation(), E) {
105
- ee();
107
+ te();
106
108
  return;
107
109
  }
108
- f && We(f, {
110
+ f && Ge(f, {
109
111
  mode: Be(r).mode,
110
112
  event: e.nativeEvent
111
113
  }, l.onDownload);
112
114
  }
113
- }, ne = (e) => {
114
- e.preventDefault(), e.stopPropagation(), f && We(f, {
115
+ }, ie = (e) => {
116
+ e.preventDefault(), e.stopPropagation(), f && Ge(f, {
115
117
  mode: Be(r).mode,
116
118
  event: e.nativeEvent
117
119
  }, l.onDownload);
118
- }, P = (e) => {
119
- e.preventDefault(), e.stopPropagation(), t();
120
- }, re = f?.name ?? ct(a.attrs.src) ?? u.missingSrc, I = [ct(a.attrs.mimeType), Je(typeof a.attrs.size == "number" ? a.attrs.size : null)].filter(Boolean), ie = [Je(S), w === null ? null : `${w}%`].filter(Boolean).join(" · ");
121
- return E ? /* @__PURE__ */ Q(o, {
120
+ }, ae = (e) => {
121
+ e.preventDefault(), e.stopPropagation(), n();
122
+ }, N = f?.name ?? ct(o.attrs.src) ?? u.missingSrc, P = [ct(o.attrs.mimeType), Ye(typeof o.attrs.size == "number" ? o.attrs.size : null)].filter(Boolean), oe = [Ye(S), w === null ? null : `${w}%`].filter(Boolean).join(" · ");
123
+ return E ? /* @__PURE__ */ Q(a, {
122
124
  as: "div",
123
125
  className: "markweave-attachment markweave-attachment-upload-placeholder",
124
126
  "data-markweave-attachment": "true",
@@ -127,13 +129,13 @@ function Hi(e) {
127
129
  "data-testid": "markweave-attachment-node",
128
130
  "data-selected": s ? "true" : "false",
129
131
  "aria-label": u.uploadLabel,
130
- onKeyDown: j,
132
+ onKeyDown: A,
131
133
  children: [/* @__PURE__ */ Z("input", {
132
134
  ref: p,
133
135
  "data-testid": "markweave-attachment-file-input",
134
136
  type: "file",
135
137
  hidden: !0,
136
- onChange: te
138
+ onChange: ne
137
139
  }), /* @__PURE__ */ Q("button", {
138
140
  type: "button",
139
141
  className: "markweave-attachment-upload-trigger",
@@ -141,7 +143,7 @@ function Hi(e) {
141
143
  "data-testid": "markweave-attachment-upload-trigger",
142
144
  "aria-label": u.uploadLabel,
143
145
  onMouseDown: (e) => e.preventDefault(),
144
- onClick: ee,
146
+ onClick: te,
145
147
  children: [
146
148
  /* @__PURE__ */ Z("span", {
147
149
  className: "markweave-attachment-icon",
@@ -161,7 +163,7 @@ function Hi(e) {
161
163
  }) : null
162
164
  ]
163
165
  })]
164
- }) : D ? /* @__PURE__ */ Q(o, {
166
+ }) : D ? /* @__PURE__ */ Q(a, {
165
167
  as: "div",
166
168
  className: "markweave-attachment markweave-attachment-uploading",
167
169
  "data-markweave-attachment": "true",
@@ -174,7 +176,7 @@ function Hi(e) {
174
176
  onMouseDown: (e) => {
175
177
  e.preventDefault(), e.stopPropagation();
176
178
  },
177
- onKeyDown: j,
179
+ onKeyDown: A,
178
180
  children: [/* @__PURE__ */ Z("span", {
179
181
  className: "markweave-attachment-icon",
180
182
  "aria-hidden": "true",
@@ -192,10 +194,10 @@ function Hi(e) {
192
194
  children: [/* @__PURE__ */ Z("span", {
193
195
  className: "markweave-attachment-spinner",
194
196
  "aria-hidden": "true"
195
- }), ie || u.uploading]
197
+ }), oe || u.uploading]
196
198
  })]
197
199
  })]
198
- }) : /* @__PURE__ */ Q(o, {
200
+ }) : /* @__PURE__ */ Q(a, {
199
201
  as: "div",
200
202
  className: "markweave-attachment",
201
203
  "data-markweave-attachment": "true",
@@ -206,14 +208,14 @@ function Hi(e) {
206
208
  "aria-label": u.nodeAriaLabel,
207
209
  onMouseEnter: () => h(!0),
208
210
  onMouseLeave: () => h(!1),
209
- onMouseDown: A,
210
- onKeyDown: j,
211
- onClick: N,
211
+ onMouseDown: k,
212
+ onKeyDown: A,
213
+ onClick: re,
212
214
  children: [
213
215
  /* @__PURE__ */ Z("span", {
214
216
  className: "markweave-attachment-icon",
215
217
  "aria-hidden": "true",
216
- children: /* @__PURE__ */ Z(W, {
218
+ children: /* @__PURE__ */ Z(he, {
217
219
  size: 16,
218
220
  strokeWidth: 1.8
219
221
  })
@@ -222,13 +224,13 @@ function Hi(e) {
222
224
  className: "markweave-attachment-body",
223
225
  children: [/* @__PURE__ */ Z("span", {
224
226
  className: "markweave-attachment-name",
225
- children: re
226
- }), I.length > 0 ? /* @__PURE__ */ Z("span", {
227
+ children: N
228
+ }), P.length > 0 ? /* @__PURE__ */ Z("span", {
227
229
  className: "markweave-attachment-meta",
228
- children: I.join(" · ")
230
+ children: P.join(" · ")
229
231
  }) : null]
230
232
  }),
231
- O ? /* @__PURE__ */ Q("span", {
233
+ ee ? /* @__PURE__ */ Q("span", {
232
234
  className: "markweave-attachment-actions",
233
235
  "data-markweave-attachment-ui": "true",
234
236
  children: [/* @__PURE__ */ Q("button", {
@@ -238,8 +240,8 @@ function Hi(e) {
238
240
  "data-testid": "markweave-attachment-download",
239
241
  "aria-label": u.downloadAriaLabel,
240
242
  onMouseDown: (e) => e.preventDefault(),
241
- onClick: ne,
242
- children: [/* @__PURE__ */ Z(F, {
243
+ onClick: ie,
244
+ children: [/* @__PURE__ */ Z(M, {
243
245
  size: 16,
244
246
  strokeWidth: 1.8
245
247
  }), /* @__PURE__ */ Z("span", {
@@ -254,7 +256,7 @@ function Hi(e) {
254
256
  "data-testid": "markweave-attachment-delete",
255
257
  "aria-label": u.deleteAriaLabel,
256
258
  onMouseDown: (e) => e.preventDefault(),
257
- onClick: P,
259
+ onClick: ae,
258
260
  children: [/* @__PURE__ */ Z(Me, {
259
261
  size: 16,
260
262
  strokeWidth: 1.8
@@ -268,28 +270,28 @@ function Hi(e) {
268
270
  ]
269
271
  });
270
272
  }
271
- var Ui = lt.extend({
273
+ var qi = lt.extend({
272
274
  addOptions() {
273
275
  return {
274
276
  ...this.parent?.(),
275
- messages: n("zh"),
277
+ messages: t("zh"),
276
278
  onUpload: void 0,
277
279
  onDownload: void 0,
278
280
  HTMLAttributes: { class: "markweave-attachment" }
279
281
  };
280
282
  },
281
283
  addNodeView() {
282
- return typeof document > "u" ? null : s(Hi, { stopEvent: ({ event: e }) => Bi(e.target) });
284
+ return typeof document > "u" ? null : o(Ki, { stopEvent: ({ event: e }) => Wi(e.target) });
283
285
  }
284
- }), Wi = at;
285
- function Gi(e) {
286
+ }), Ji = at;
287
+ function Yi(e) {
286
288
  return e instanceof Element && !!e.closest("[data-markweave-image-ui=\"true\"]");
287
289
  }
288
- function Ki(e) {
289
- let { deleteNode: t, editor: r, getPos: i, node: a, selected: s, updateAttributes: c } = e, l = e.extension.options, u = l.messages ?? n("zh"), d = u.image, f = Ve(zi(r)), p = ct(a.attrs.src), m = Wi(a.attrs.align), h = st(a.attrs.width), g = ct(a.attrs.caption), _ = J(null), v = Qi(p, l.resolveMediaSource, _, s), y = v?.src ?? (l.resolveMediaSource ? null : p), b = J(null), [x, S] = Y(!1), [C, w] = Y(!1), [T, E] = Y(!1), [D, O] = Y(""), [k, A] = Y(null), [j, ee] = Y(!1), [M, te] = Y(!!g), [N, ne] = Y(g ?? ""), P = f && (!p || C), re = () => {
290
- y && mt({
290
+ function Xi(e) {
291
+ let { deleteNode: n, editor: r, getPos: i, node: o, selected: s, updateAttributes: c } = e, l = e.extension.options, u = l.messages ?? t("zh"), d = u.image, f = Ve(Ui(r)), p = ct(o.attrs.src), m = Ji(o.attrs.align), h = st(o.attrs.width), g = ct(o.attrs.caption), _ = q(null), v = na(p, l.resolveMediaSource, _, s), y = v?.src ?? (l.resolveMediaSource ? null : p), b = q(null), [x, S] = J(!1), [C, w] = J(!1), [T, E] = J(!1), [D, ee] = J(""), [O, k] = J(null), [A, te] = J(!1), [j, ne] = J(!!g), [re, ie] = J(g ?? ""), ae = f && (!p || C), M = () => {
292
+ y && pt({
291
293
  src: y,
292
- alt: ct(a.attrs.alt) ?? "",
294
+ alt: ct(o.attrs.alt) ?? "",
293
295
  messages: {
294
296
  dialogAriaLabel: d.previewDialogAriaLabel,
295
297
  zoomOut: d.previewZoomOut,
@@ -299,108 +301,108 @@ function Ki(e) {
299
301
  }
300
302
  });
301
303
  };
302
- K(() => {
303
- M || ne(g ?? "");
304
- }, [g, M]);
305
- let F = () => {
304
+ G(() => {
305
+ j || ie(g ?? "");
306
+ }, [g, j]);
307
+ let N = () => {
306
308
  if (!f) return;
307
309
  let e = i();
308
310
  typeof e == "number" && r.chain().focus().setNodeSelection(e).run();
309
- }, I = () => {
311
+ }, oe = () => {
310
312
  if (f) {
311
- if (O(""), A(null), E(!1), p) {
313
+ if (ee(""), k(null), E(!1), p) {
312
314
  w(!1);
313
315
  return;
314
316
  }
315
- t();
317
+ n();
316
318
  }
317
- }, ae = async (e) => {
319
+ }, F = async (e) => {
318
320
  if (f) {
319
- A(null), ee(!0);
321
+ k(null), te(!0);
320
322
  try {
321
- let t = await ft(tt(e, p && C ? "image-replace" : "image-insert"), l.onUpload);
322
- c(Ze(a.attrs, t)), w(!1), O("");
323
+ let t = await ft(nt(e, p && C ? "image-replace" : "image-insert"), l.onUpload);
324
+ c(Qe(o.attrs, t)), w(!1), ee("");
323
325
  } catch (e) {
324
- A(e instanceof Error ? e.message : d.uploadFailedError);
326
+ k(e instanceof Error ? e.message : d.uploadFailedError);
325
327
  } finally {
326
- ee(!1), E(!1);
328
+ te(!1), E(!1);
327
329
  }
328
330
  }
329
- }, L = () => {
331
+ }, I = () => {
330
332
  if (f) {
331
333
  if (!D.trim()) {
332
- A(d.uploadRequiredError);
334
+ k(d.uploadRequiredError);
333
335
  return;
334
336
  }
335
- ae(ut(D));
337
+ F(ut(D));
336
338
  }
337
- }, oe = (e) => {
338
- !f || !e || ae({
339
+ }, se = (e) => {
340
+ !f || !e || F({
339
341
  type: "file",
340
342
  file: e,
341
343
  mimeType: e.type
342
344
  });
345
+ }, L = (e) => {
346
+ se(e.currentTarget.files?.[0] ?? null), e.currentTarget.value = "";
343
347
  }, R = (e) => {
344
- oe(e.currentTarget.files?.[0] ?? null), e.currentTarget.value = "";
345
- }, z = (e) => {
346
- e.preventDefault(), e.stopPropagation(), f && oe(e.dataTransfer.files?.[0] ?? null);
347
- }, B = () => {
348
- f && (te((e) => !e), M || ne(g ?? ""));
349
- }, se = (e) => {
350
- f && (ne(e), c({ caption: e.trim() ? e : null }));
351
- }, ce = (e, t) => {
348
+ e.preventDefault(), e.stopPropagation(), f && se(e.dataTransfer.files?.[0] ?? null);
349
+ }, z = () => {
350
+ f && (ne((e) => !e), j || ie(g ?? ""));
351
+ }, ce = (e) => {
352
+ f && (ie(e), c({ caption: e.trim() ? e : null }));
353
+ }, le = (e, t) => {
352
354
  if (t.preventDefault(), t.stopPropagation(), !f) return;
353
- F();
355
+ N();
354
356
  let n = _.current;
355
357
  if (!n) return;
356
358
  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) => {
357
359
  let n = e === "right" ? t.clientX - r : r - t.clientX;
358
- c({ width: et(i + n, a) });
360
+ c({ width: tt(i + n, a) });
359
361
  }, s = () => {
360
362
  window.removeEventListener("pointermove", o), window.removeEventListener("pointerup", s);
361
363
  };
362
364
  window.addEventListener("pointermove", o), window.addEventListener("pointerup", s, { once: !0 });
363
365
  };
364
- return /* @__PURE__ */ Z(o, {
366
+ return /* @__PURE__ */ Z(a, {
365
367
  as: "figure",
366
368
  className: "markweave-image-node",
367
369
  "data-testid": "markweave-image-node",
368
370
  "data-align": m,
369
371
  "data-selected": f && s ? "true" : "false",
370
372
  "data-hovered": x ? "true" : "false",
371
- "data-empty": P ? "true" : "false",
373
+ "data-empty": ae ? "true" : "false",
372
374
  onPointerEnter: () => S(!0),
373
375
  onPointerLeave: () => S(!1),
374
376
  onMouseDown: (e) => {
375
- f && !Gi(e.target) && F();
377
+ f && !Yi(e.target) && N();
376
378
  },
377
- children: P ? /* @__PURE__ */ Z(qi, {
379
+ children: ae ? /* @__PURE__ */ Z(Zi, {
378
380
  dragActive: T,
379
- error: k,
381
+ error: O,
380
382
  inputValue: D,
381
- isSubmitting: j,
383
+ isSubmitting: A,
382
384
  fileInputRef: b,
383
385
  messages: u,
384
- onCancel: I,
385
- onDrop: z,
386
+ onCancel: oe,
387
+ onDrop: R,
386
388
  onDragActiveChange: E,
387
- onFileChange: R,
388
- onInputChange: O,
389
- onSubmit: L
390
- }) : /* @__PURE__ */ Q(pt, { children: [
391
- f ? /* @__PURE__ */ Z(Ji, {
389
+ onFileChange: L,
390
+ onInputChange: ee,
391
+ onSubmit: I
392
+ }) : /* @__PURE__ */ Q(X, { children: [
393
+ f ? /* @__PURE__ */ Z(Qi, {
392
394
  align: m,
393
- captionActive: M || !!g,
395
+ captionActive: j || !!g,
394
396
  messages: u,
395
397
  onAlign: (e) => c({ align: e }),
396
- onCaption: B,
397
- onDelete: t,
398
+ onCaption: z,
399
+ onDelete: n,
398
400
  onDownload: () => {
399
401
  y && rt(y);
400
402
  },
401
- onPreview: re,
403
+ onPreview: M,
402
404
  onReplace: () => {
403
- O(""), A(null), w(!0);
405
+ ee(""), k(null), w(!0);
404
406
  }
405
407
  }) : null,
406
408
  /* @__PURE__ */ Q("div", {
@@ -414,8 +416,8 @@ function Ki(e) {
414
416
  y ? /* @__PURE__ */ Z("img", {
415
417
  className: "markweave-image",
416
418
  src: y,
417
- alt: ct(a.attrs.alt) ?? "",
418
- title: ct(a.attrs.title) ?? void 0,
419
+ alt: ct(o.attrs.alt) ?? "",
420
+ title: ct(o.attrs.title) ?? void 0,
419
421
  draggable: !1,
420
422
  loading: "lazy",
421
423
  decoding: "async",
@@ -434,8 +436,8 @@ function Ki(e) {
434
436
  "aria-label": d.preview,
435
437
  title: d.preview,
436
438
  onMouseDown: (e) => e.preventDefault(),
437
- onClick: re,
438
- children: [/* @__PURE__ */ Z(ie, {
439
+ onClick: M,
440
+ children: [/* @__PURE__ */ Z(P, {
439
441
  size: 16,
440
442
  strokeWidth: 1.8
441
443
  }), /* @__PURE__ */ Z("span", {
@@ -444,28 +446,28 @@ function Ki(e) {
444
446
  children: d.preview
445
447
  })]
446
448
  }) : null,
447
- f ? /* @__PURE__ */ Z(Xi, {
449
+ f ? /* @__PURE__ */ Z(ea, {
448
450
  side: "left",
449
451
  messages: u,
450
- onPointerDown: ce
452
+ onPointerDown: le
451
453
  }) : null,
452
- f ? /* @__PURE__ */ Z(Xi, {
454
+ f ? /* @__PURE__ */ Z(ea, {
453
455
  side: "right",
454
456
  messages: u,
455
- onPointerDown: ce
457
+ onPointerDown: le
456
458
  }) : null
457
459
  ]
458
460
  }),
459
- f && (M || g) ? /* @__PURE__ */ Z("input", {
461
+ f && (j || g) ? /* @__PURE__ */ Z("input", {
460
462
  className: "markweave-image-caption-input",
461
463
  "data-markweave-image-ui": "true",
462
464
  "data-testid": "markweave-image-caption-input",
463
- value: N,
465
+ value: re,
464
466
  placeholder: d.captionPlaceholder,
465
467
  "aria-label": d.captionAriaLabel,
466
- onChange: (e) => se(e.currentTarget.value),
468
+ onChange: (e) => ce(e.currentTarget.value),
467
469
  onKeyDown: (e) => {
468
- e.key === "Escape" && (e.preventDefault(), te(!1));
470
+ e.key === "Escape" && (e.preventDefault(), ne(!1));
469
471
  }
470
472
  }) : g ? /* @__PURE__ */ Z("figcaption", {
471
473
  className: "markweave-image-caption",
@@ -475,7 +477,7 @@ function Ki(e) {
475
477
  ] })
476
478
  });
477
479
  }
478
- function qi({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitting: i, messages: a, onCancel: o, onDragActiveChange: s, onDrop: c, onFileChange: l, onInputChange: u, onSubmit: d }) {
480
+ function Zi({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitting: i, messages: a, onCancel: o, onDragActiveChange: s, onDrop: c, onFileChange: l, onInputChange: u, onSubmit: d }) {
479
481
  let f = a.image;
480
482
  return /* @__PURE__ */ Q("section", {
481
483
  className: "markweave-image-upload-placeholder",
@@ -510,7 +512,7 @@ function qi({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
510
512
  /* @__PURE__ */ Z("span", {
511
513
  className: "markweave-image-upload-icon",
512
514
  "aria-hidden": "true",
513
- children: /* @__PURE__ */ Z(z, {
515
+ children: /* @__PURE__ */ Z(L, {
514
516
  size: 16,
515
517
  strokeWidth: 1.8
516
518
  })
@@ -544,7 +546,7 @@ function qi({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
544
546
  "data-testid": "markweave-image-upload-submit",
545
547
  disabled: i || !r.trim(),
546
548
  onClick: d,
547
- children: [/* @__PURE__ */ Z(z, {
549
+ children: [/* @__PURE__ */ Z(L, {
548
550
  size: 16,
549
551
  strokeWidth: 1.8
550
552
  }), a.common.insert]
@@ -564,32 +566,32 @@ function qi({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
564
566
  ]
565
567
  });
566
568
  }
567
- function Ji({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i, onDelete: a, onDownload: o, onPreview: s, onReplace: c }) {
568
- let l = n.image;
569
+ function Qi({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i, onDelete: a, onDownload: o, onPreview: s, onReplace: c }) {
570
+ let u = n.image;
569
571
  return /* @__PURE__ */ Q("div", {
570
572
  className: "markweave-image-toolbar",
571
573
  "data-testid": "markweave-image-toolbar",
572
574
  "data-markweave-image-ui": "true",
573
- "aria-label": l.toolsAriaLabel,
575
+ "aria-label": u.toolsAriaLabel,
574
576
  children: [
575
- /* @__PURE__ */ Z(Yi, {
577
+ /* @__PURE__ */ Z($i, {
576
578
  testId: "markweave-image-align-left",
577
- label: l.alignLeft,
578
- icon: f,
579
+ label: u.alignLeft,
580
+ icon: d,
579
581
  active: e === "left",
580
582
  onClick: () => r("left")
581
583
  }),
582
- /* @__PURE__ */ Z(Yi, {
584
+ /* @__PURE__ */ Z($i, {
583
585
  testId: "markweave-image-align-center",
584
- label: l.alignCenter,
585
- icon: u,
586
+ label: u.alignCenter,
587
+ icon: l,
586
588
  active: e === "center",
587
589
  onClick: () => r("center")
588
590
  }),
589
- /* @__PURE__ */ Z(Yi, {
591
+ /* @__PURE__ */ Z($i, {
590
592
  testId: "markweave-image-align-right",
591
- label: l.alignRight,
592
- icon: p,
593
+ label: u.alignRight,
594
+ icon: f,
593
595
  active: e === "right",
594
596
  onClick: () => r("right")
595
597
  }),
@@ -597,45 +599,45 @@ function Ji({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i,
597
599
  className: "markweave-image-toolbar-divider",
598
600
  "aria-hidden": "true"
599
601
  }),
600
- /* @__PURE__ */ Z(Yi, {
602
+ /* @__PURE__ */ Z($i, {
601
603
  testId: "markweave-image-caption",
602
- label: l.caption,
603
- icon: k,
604
+ label: u.caption,
605
+ icon: ee,
604
606
  active: t,
605
607
  onClick: i
606
608
  }),
607
- /* @__PURE__ */ Z(Yi, {
609
+ /* @__PURE__ */ Z($i, {
608
610
  testId: "markweave-image-preview",
609
- label: l.preview,
610
- icon: ie,
611
+ label: u.preview,
612
+ icon: P,
611
613
  onClick: s
612
614
  }),
613
- /* @__PURE__ */ Z(Yi, {
615
+ /* @__PURE__ */ Z($i, {
614
616
  testId: "markweave-image-download",
615
- label: l.download,
616
- icon: F,
617
+ label: u.download,
618
+ icon: M,
617
619
  onClick: o
618
620
  }),
619
- /* @__PURE__ */ Z(Yi, {
621
+ /* @__PURE__ */ Z($i, {
620
622
  testId: "markweave-image-replace",
621
- label: l.replace,
622
- icon: ve,
623
+ label: u.replace,
624
+ icon: ye,
623
625
  onClick: c
624
626
  }),
625
627
  /* @__PURE__ */ Z("span", {
626
628
  className: "markweave-image-toolbar-divider",
627
629
  "aria-hidden": "true"
628
630
  }),
629
- /* @__PURE__ */ Z(Yi, {
631
+ /* @__PURE__ */ Z($i, {
630
632
  testId: "markweave-image-delete",
631
- label: l.delete,
633
+ label: u.delete,
632
634
  icon: Me,
633
635
  onClick: a
634
636
  })
635
637
  ]
636
638
  });
637
639
  }
638
- function Yi({ active: e = !1, icon: t, label: n, onClick: r, testId: i }) {
640
+ function $i({ active: e = !1, icon: t, label: n, onClick: r, testId: i }) {
639
641
  return /* @__PURE__ */ Q("button", {
640
642
  type: "button",
641
643
  "aria-label": n,
@@ -654,7 +656,7 @@ function Yi({ active: e = !1, icon: t, label: n, onClick: r, testId: i }) {
654
656
  })]
655
657
  });
656
658
  }
657
- function Xi({ messages: e, onPointerDown: t, side: n }) {
659
+ function ea({ messages: e, onPointerDown: t, side: n }) {
658
660
  return /* @__PURE__ */ Z("button", {
659
661
  type: "button",
660
662
  className: "markweave-image-resize-handle",
@@ -665,32 +667,32 @@ function Xi({ messages: e, onPointerDown: t, side: n }) {
665
667
  onPointerDown: (e) => t(n, e)
666
668
  });
667
669
  }
668
- var Zi = Ye.extend({
670
+ var ta = Xe.extend({
669
671
  addOptions() {
670
672
  return {
671
673
  ...this.parent?.(),
672
- messages: n("zh"),
674
+ messages: t("zh"),
673
675
  onUpload: void 0,
674
676
  resolveMediaSource: void 0
675
677
  };
676
678
  },
677
679
  addNodeView() {
678
680
  if (typeof document > "u") return null;
679
- let e = s(Ki, { stopEvent: ({ event: e }) => Gi(e.target) }), t = this.options.resolveMediaSource;
680
- if (!t) return e;
681
- let r = ht({
682
- messages: this.options.messages ?? n("zh"),
681
+ let e = o(Xi, { stopEvent: ({ event: e }) => Yi(e.target) }), n = this.options.resolveMediaSource;
682
+ if (!n) return e;
683
+ let r = mt({
684
+ messages: this.options.messages ?? t("zh"),
683
685
  onUpload: this.options.onUpload,
684
- resolveMediaSource: t
686
+ resolveMediaSource: n
685
687
  });
686
688
  return (t) => ct(t.node.attrs.src) ? r(t) : e(t);
687
689
  }
688
690
  });
689
- function Qi(e, t, n, r) {
690
- let [i, a] = Y(t ? "background" : "visible"), [o, s] = Y(() => !t && e ? { src: e } : null);
691
- return K(() => {
691
+ function na(e, t, n, r) {
692
+ let [i, a] = J(t ? "background" : "visible"), [o, s] = J(() => !t && e ? { src: e } : null);
693
+ return G(() => {
692
694
  s(!t && e ? { src: e } : null), a(t ? "background" : "visible");
693
- }, [t, e]), K(() => {
695
+ }, [t, e]), G(() => {
694
696
  if (!t || !e) return;
695
697
  if (r) {
696
698
  a("visible");
@@ -713,10 +715,10 @@ function Qi(e, t, n, r) {
713
715
  t,
714
716
  r,
715
717
  e
716
- ]), K(() => {
718
+ ]), G(() => {
717
719
  if (!t || !e || i === "background") return;
718
720
  let n = new AbortController();
719
- return gt(t, {
721
+ return ht(t, {
720
722
  kind: "image",
721
723
  priority: i,
722
724
  signal: n.signal,
@@ -732,28 +734,28 @@ function Qi(e, t, n, r) {
732
734
  }
733
735
  //#endregion
734
736
  //#region src/media/video-node.tsx
735
- function $i(e) {
737
+ function ra(e) {
736
738
  return e instanceof Element && !!e.closest("[data-markweave-video-ui=\"true\"], iframe[data-markweave-video-embed], video[data-markweave-video]");
737
739
  }
738
- function ea(e) {
739
- let { deleteNode: t, editor: r, getPos: i, node: a, selected: s, updateAttributes: c } = e, l = e.extension.options, u = l.messages ?? n("zh"), d = u.video, f = Ve(zi(r)), p = ct(a.attrs.src), m = ct(a.attrs.embedUrl), h = ct(a.attrs.provider), g = m ? ot(m, h) : null, _ = ct(a.attrs.mimeType), v = ct(a.attrs.title), y = J(null), [b, x] = Y(!1), [S, C] = Y(""), [w, T] = Y(null), [E, D] = Y(!1), O = f && !p, k = () => {
740
+ function ia(e) {
741
+ let { deleteNode: n, editor: r, getPos: i, node: o, selected: s, updateAttributes: c } = e, l = e.extension.options, u = l.messages ?? t("zh"), d = u.video, f = Ve(Ui(r)), p = ct(o.attrs.src), m = ct(o.attrs.embedUrl), h = ct(o.attrs.provider), g = m ? ot(m, h) : null, _ = ct(o.attrs.mimeType), v = ct(o.attrs.title), y = q(null), [b, x] = J(!1), [S, C] = J(""), [w, T] = J(null), [E, D] = J(!1), ee = f && !p, O = () => {
740
742
  if (!f) return;
741
743
  let e = i();
742
744
  typeof e == "number" && r.chain().focus().setNodeSelection(e).run();
745
+ }, k = (e) => {
746
+ f && (ra(e.target) || (e.preventDefault(), O()));
743
747
  }, A = (e) => {
744
- f && ($i(e.target) || (e.preventDefault(), k()));
745
- }, j = (e) => {
746
- f && (e.key === "Delete" || e.key === "Backspace") && s && (e.preventDefault(), t());
747
- }, ee = async (e) => {
748
+ f && (e.key === "Delete" || e.key === "Backspace") && s && (e.preventDefault(), n());
749
+ }, te = async (e) => {
748
750
  if (!(!f || !e)) {
749
751
  T(null), D(!0);
750
752
  try {
751
- let t = await ft(nt({
753
+ let t = await ft(Y({
752
754
  type: "file",
753
755
  file: e,
754
756
  mimeType: e.type
755
757
  }), l.onUpload);
756
- c(Qe(t)), C("");
758
+ c($e(t)), C("");
757
759
  } catch (e) {
758
760
  T(e instanceof Error ? e.message : d.uploadFailedError);
759
761
  } finally {
@@ -761,31 +763,31 @@ function ea(e) {
761
763
  }
762
764
  }
763
765
  };
764
- return O ? /* @__PURE__ */ Z(o, {
766
+ return ee ? /* @__PURE__ */ Z(a, {
765
767
  as: "figure",
766
768
  className: "markweave-video-node",
767
769
  "data-testid": "markweave-video-node",
768
770
  "data-empty": "true",
769
771
  "data-selected": "false",
770
- children: /* @__PURE__ */ Z(ta, {
772
+ children: /* @__PURE__ */ Z(aa, {
771
773
  dragActive: b,
772
774
  error: w,
773
775
  fileInputRef: y,
774
776
  inputValue: S,
775
777
  isSubmitting: E,
776
778
  messages: u,
777
- onCancel: t,
779
+ onCancel: n,
778
780
  onDragActiveChange: x,
779
781
  onDrop: (e) => {
780
- e.preventDefault(), e.stopPropagation(), f && ee(e.dataTransfer.files?.[0] ?? null);
782
+ e.preventDefault(), e.stopPropagation(), f && te(e.dataTransfer.files?.[0] ?? null);
781
783
  },
782
784
  onFileChange: (e) => {
783
- ee(e.currentTarget.files?.[0] ?? null), e.currentTarget.value = "";
785
+ te(e.currentTarget.files?.[0] ?? null), e.currentTarget.value = "";
784
786
  },
785
787
  onInputChange: C,
786
788
  onSubmit: () => {
787
789
  if (!f) return;
788
- let e = $e(S);
790
+ let e = et(S);
789
791
  if (!e) {
790
792
  T(d.unsupportedUrlError);
791
793
  return;
@@ -793,7 +795,7 @@ function ea(e) {
793
795
  T(null), c(e), C("");
794
796
  }
795
797
  })
796
- }) : /* @__PURE__ */ Z(o, {
798
+ }) : /* @__PURE__ */ Z(a, {
797
799
  as: "figure",
798
800
  className: "markweave-video-node",
799
801
  "data-testid": "markweave-video-node",
@@ -802,9 +804,9 @@ function ea(e) {
802
804
  "data-selected": f && s ? "true" : "false",
803
805
  tabIndex: f ? 0 : void 0,
804
806
  "aria-label": d.nodeAriaLabel,
805
- onFocus: k,
806
- onKeyDown: j,
807
- onMouseDown: A,
807
+ onFocus: O,
808
+ onKeyDown: A,
809
+ onMouseDown: k,
808
810
  children: g ? /* @__PURE__ */ Q("div", {
809
811
  className: "markweave-video-embed",
810
812
  children: [/* @__PURE__ */ Z("iframe", {
@@ -848,7 +850,7 @@ function ea(e) {
848
850
  })
849
851
  });
850
852
  }
851
- function ta({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitting: i, messages: a, onCancel: o, onDragActiveChange: s, onDrop: c, onFileChange: l, onInputChange: u, onSubmit: d }) {
853
+ function aa({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitting: i, messages: a, onCancel: o, onDragActiveChange: s, onDrop: c, onFileChange: l, onInputChange: u, onSubmit: d }) {
852
854
  let f = a.video;
853
855
  return /* @__PURE__ */ Q("section", {
854
856
  className: "markweave-video-upload-placeholder",
@@ -937,45 +939,45 @@ function ta({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
937
939
  ]
938
940
  });
939
941
  }
940
- var na = Xe.extend({
942
+ var oa = Ze.extend({
941
943
  addOptions() {
942
944
  return {
943
945
  ...this.parent?.(),
944
- messages: n("zh"),
946
+ messages: t("zh"),
945
947
  onUpload: void 0,
946
948
  resolveMediaSource: void 0
947
949
  };
948
950
  },
949
951
  addNodeView() {
950
- return typeof document > "u" ? null : s(ea, { stopEvent: ({ event: e }) => $i(e.target) });
952
+ return typeof document > "u" ? null : o(ia, { stopEvent: ({ event: e }) => ra(e.target) });
951
953
  }
952
954
  });
953
955
  //#endregion
954
956
  //#region src/link-card-node.tsx
955
- function ra(e) {
957
+ function sa(e) {
956
958
  return e instanceof Element && !!e.closest("[data-markweave-link-card-ui=\"true\"]");
957
959
  }
958
- function ia(e) {
960
+ function ca(e) {
959
961
  return typeof navigator < "u" && navigator.clipboard?.writeText ? navigator.clipboard.writeText(e).catch(() => void 0) : Promise.resolve();
960
962
  }
961
- function aa(e) {
963
+ function la(e) {
962
964
  !e || typeof window > "u" || window.open(e, "_blank", "noopener,noreferrer");
963
965
  }
964
- function oa(e) {
966
+ function ua(e) {
965
967
  try {
966
968
  return new URL(e).host;
967
969
  } catch {
968
970
  return e;
969
971
  }
970
972
  }
971
- function sa(e) {
972
- let { deleteNode: t, editor: r, getPos: i, node: a, updateAttributes: s } = e, c = e.extension.options, l = c.messages ?? n("zh"), u = l.linkCard, d = Ve(zi(r)), f = _t(a.attrs), [p, m] = Y(!1), [h, g] = Y(!1), [_, v] = Y(!1), [y, b] = Y(f?.title ?? ""), [x, S] = Y(f?.href ?? ""), C = J(null);
973
- if (K(() => () => C.current?.abort(), []), K(() => {
973
+ function da(e) {
974
+ let { deleteNode: n, editor: r, getPos: i, node: o, updateAttributes: s } = e, c = e.extension.options, l = c.messages ?? t("zh"), u = l.linkCard, d = Ve(Ui(r)), f = gt(o.attrs), [p, m] = J(!1), [h, g] = J(!1), [_, v] = J(!1), [y, b] = J(f?.title ?? ""), [x, S] = J(f?.href ?? ""), C = q(null);
975
+ if (G(() => () => C.current?.abort(), []), G(() => {
974
976
  b(f?.title ?? ""), S(f?.href ?? ""), v(!1);
975
977
  }, [f?.href, f?.title]), !f) return null;
976
978
  let w = async (e) => {
977
979
  e.preventDefault();
978
- let t = _t({
980
+ let t = gt({
979
981
  ...f,
980
982
  href: x,
981
983
  title: y
@@ -990,16 +992,16 @@ function sa(e) {
990
992
  title: t.title,
991
993
  signal: n.signal
992
994
  });
993
- !n.signal.aborted && e && s(_t({
995
+ !n.signal.aborted && e && s(gt({
994
996
  ...t,
995
997
  ...e
996
998
  }) ?? t);
997
999
  } catch {}
998
1000
  }, T = () => {
999
1001
  let e = i();
1000
- typeof e == "number" && yt(r, e);
1001
- }, E = _ ? null : f.imageUrl, D = oa(f.href);
1002
- return /* @__PURE__ */ Q(o, {
1002
+ typeof e == "number" && vt(r, e);
1003
+ }, E = _ ? null : f.imageUrl, D = ua(f.href);
1004
+ return /* @__PURE__ */ Q(a, {
1003
1005
  as: "article",
1004
1006
  className: "markweave-link-card",
1005
1007
  "data-testid": "markweave-link-card",
@@ -1009,10 +1011,10 @@ function sa(e) {
1009
1011
  onMouseEnter: () => m(!0),
1010
1012
  onMouseLeave: () => m(!1),
1011
1013
  onMouseDown: (e) => {
1012
- ra(e.target) || e.preventDefault();
1014
+ sa(e.target) || e.preventDefault();
1013
1015
  },
1014
1016
  onClick: (e) => {
1015
- ra(e.target) || (e.preventDefault(), aa(f.href));
1017
+ sa(e.target) || (e.preventDefault(), la(f.href));
1016
1018
  },
1017
1019
  children: [
1018
1020
  /* @__PURE__ */ Q("a", {
@@ -1050,24 +1052,24 @@ function sa(e) {
1050
1052
  "data-markweave-link-card-ui": "true",
1051
1053
  "aria-label": u.toolsAriaLabel,
1052
1054
  children: [
1053
- /* @__PURE__ */ Z(ca, {
1055
+ /* @__PURE__ */ Z(fa, {
1054
1056
  label: u.convertToLink,
1055
1057
  icon: ue,
1056
1058
  onClick: T,
1057
1059
  testId: "markweave-link-card-convert"
1058
1060
  }),
1059
- /* @__PURE__ */ Z(ca, {
1061
+ /* @__PURE__ */ Z(fa, {
1060
1062
  label: u.copyAddress,
1061
- icon: P,
1062
- onClick: () => void ia(f.href),
1063
+ icon: ie,
1064
+ onClick: () => void ca(f.href),
1063
1065
  testId: "markweave-link-card-copy"
1064
1066
  }),
1065
- /* @__PURE__ */ Z(ca, {
1067
+ /* @__PURE__ */ Z(fa, {
1066
1068
  label: u.edit,
1067
- icon: he,
1069
+ icon: ge,
1068
1070
  onClick: (e) => {
1069
1071
  let t = i();
1070
- typeof t == "number" && bt({
1072
+ typeof t == "number" && yt({
1071
1073
  anchor: e.currentTarget,
1072
1074
  editor: r,
1073
1075
  messages: l,
@@ -1080,10 +1082,10 @@ function sa(e) {
1080
1082
  },
1081
1083
  testId: "markweave-link-card-edit"
1082
1084
  }),
1083
- /* @__PURE__ */ Z(ca, {
1085
+ /* @__PURE__ */ Z(fa, {
1084
1086
  label: u.delete,
1085
1087
  icon: Me,
1086
- onClick: t,
1088
+ onClick: n,
1087
1089
  testId: "markweave-link-card-delete"
1088
1090
  })
1089
1091
  ]
@@ -1109,7 +1111,7 @@ function sa(e) {
1109
1111
  /* @__PURE__ */ Z("button", {
1110
1112
  type: "submit",
1111
1113
  "aria-label": u.edit,
1112
- disabled: !vt(x),
1114
+ disabled: !_t(x),
1113
1115
  children: /* @__PURE__ */ Z(ue, { size: 16 })
1114
1116
  })
1115
1117
  ]
@@ -1117,7 +1119,7 @@ function sa(e) {
1117
1119
  ]
1118
1120
  });
1119
1121
  }
1120
- function ca({ icon: e, label: t, onClick: n, testId: r }) {
1122
+ function fa({ icon: e, label: t, onClick: n, testId: r }) {
1121
1123
  return /* @__PURE__ */ Q("button", {
1122
1124
  type: "button",
1123
1125
  "aria-label": t,
@@ -1134,50 +1136,51 @@ function ca({ icon: e, label: t, onClick: n, testId: r }) {
1134
1136
  })]
1135
1137
  });
1136
1138
  }
1137
- var la = xt.extend({
1139
+ var pa = bt.extend({
1138
1140
  addOptions() {
1139
1141
  return {
1140
1142
  ...this.parent?.(),
1141
- messages: n("zh"),
1143
+ messages: t("zh"),
1142
1144
  resolver: void 0
1143
1145
  };
1144
1146
  },
1145
1147
  addNodeView() {
1146
- return typeof document > "u" ? null : s(sa, { stopEvent: ({ event: e }) => ra(e.target) });
1148
+ return typeof document > "u" ? null : o(da, { stopEvent: ({ event: e }) => sa(e.target) });
1147
1149
  }
1148
1150
  });
1149
1151
  //#endregion
1150
1152
  //#region src/create-editor-extensions.ts
1151
- function ua(t = {}) {
1153
+ function ma(n = {}) {
1152
1154
  return e({
1153
- lang: t.lang,
1154
- onImageUpload: t.onImageUpload,
1155
- linkCardExtension: la.configure({
1156
- lang: t.lang,
1157
- messages: n(t.lang),
1158
- resolver: t.linkCardResolver
1155
+ lang: n.lang,
1156
+ onImageUpload: n.onImageUpload,
1157
+ linkCardExtension: pa.configure({
1158
+ lang: n.lang,
1159
+ messages: t(n.lang),
1160
+ resolver: n.linkCardResolver
1159
1161
  }),
1160
- mediaExtensions: i({
1161
- image: Zi,
1162
- video: na,
1163
- attachment: Ui,
1164
- lang: t.lang,
1165
- onImageUpload: t.onImageUpload,
1166
- onVideoUpload: t.onVideoUpload,
1167
- onAttachmentUpload: t.onAttachmentUpload,
1168
- onAttachmentDownload: t.onAttachmentDownload,
1169
- resolveMediaSource: t.resolveMediaSource
1170
- })
1162
+ mediaExtensions: r({
1163
+ image: ta,
1164
+ video: oa,
1165
+ attachment: qi,
1166
+ lang: n.lang,
1167
+ onImageUpload: n.onImageUpload,
1168
+ onVideoUpload: n.onVideoUpload,
1169
+ onAttachmentUpload: n.onAttachmentUpload,
1170
+ onAttachmentDownload: n.onAttachmentDownload,
1171
+ resolveMediaSource: n.resolveMediaSource
1172
+ }),
1173
+ editorExtensions: n.editorExtensions
1171
1174
  });
1172
1175
  }
1173
1176
  //#endregion
1174
1177
  //#region src/ui/codeblock/CodeBlockControls.tsx
1175
- function da(e) {
1176
- return e === "clipboard" ? /* @__PURE__ */ Q(pt, { 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(pt, { children: [/* @__PURE__ */ Z("circle", {
1178
+ function ha(e) {
1179
+ 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", {
1177
1180
  cx: "10",
1178
1181
  cy: "10",
1179
1182
  r: "5.5"
1180
- }), /* @__PURE__ */ Z("path", { d: "m14 14 4 4" })] }) : e === "check" ? /* @__PURE__ */ Z("path", { d: "m5 11 4 4 8-9" }) : e === "expand" ? /* @__PURE__ */ Q(pt, { children: [
1183
+ }), /* @__PURE__ */ Z("path", { d: "m14 14 4 4" })] }) : e === "check" ? /* @__PURE__ */ Z("path", { d: "m5 11 4 4 8-9" }) : e === "expand" ? /* @__PURE__ */ Q(X, { children: [
1181
1184
  /* @__PURE__ */ Z("path", { d: "M8 4H4v4" }),
1182
1185
  /* @__PURE__ */ Z("path", { d: "M4 4l5 5" }),
1183
1186
  /* @__PURE__ */ Z("path", { d: "M16 4h4v4" }),
@@ -1186,11 +1189,11 @@ function da(e) {
1186
1189
  /* @__PURE__ */ Z("path", { d: "m4 20 5-5" }),
1187
1190
  /* @__PURE__ */ Z("path", { d: "M16 20h4v-4" }),
1188
1191
  /* @__PURE__ */ Z("path", { d: "m20 20-5-5" })
1189
- ] }) : e === "download" ? /* @__PURE__ */ Q(pt, { children: [
1192
+ ] }) : e === "download" ? /* @__PURE__ */ Q(X, { children: [
1190
1193
  /* @__PURE__ */ Z("path", { d: "M12 4v10" }),
1191
1194
  /* @__PURE__ */ Z("path", { d: "m8 10 4 4 4-4" }),
1192
1195
  /* @__PURE__ */ Z("path", { d: "M5 19h14" })
1193
- ] }) : e === "close" ? /* @__PURE__ */ Q(pt, { children: [/* @__PURE__ */ Z("path", { d: "M6 6l12 12" }), /* @__PURE__ */ Z("path", { d: "M18 6 6 18" })] }) : e === "zoomOut" ? /* @__PURE__ */ Q(pt, { children: [
1196
+ ] }) : e === "close" ? /* @__PURE__ */ Q(X, { children: [/* @__PURE__ */ Z("path", { d: "M6 6l12 12" }), /* @__PURE__ */ Z("path", { d: "M18 6 6 18" })] }) : e === "zoomOut" ? /* @__PURE__ */ Q(X, { children: [
1194
1197
  /* @__PURE__ */ Z("circle", {
1195
1198
  cx: "10",
1196
1199
  cy: "10",
@@ -1198,7 +1201,7 @@ function da(e) {
1198
1201
  }),
1199
1202
  /* @__PURE__ */ Z("path", { d: "M7.5 10h5" }),
1200
1203
  /* @__PURE__ */ Z("path", { d: "m14 14 4 4" })
1201
- ] }) : e === "zoomIn" ? /* @__PURE__ */ Q(pt, { children: [
1204
+ ] }) : e === "zoomIn" ? /* @__PURE__ */ Q(X, { children: [
1202
1205
  /* @__PURE__ */ Z("circle", {
1203
1206
  cx: "10",
1204
1207
  cy: "10",
@@ -1207,9 +1210,9 @@ function da(e) {
1207
1210
  /* @__PURE__ */ Z("path", { d: "M7.5 10h5" }),
1208
1211
  /* @__PURE__ */ Z("path", { d: "M10 7.5v5" }),
1209
1212
  /* @__PURE__ */ Z("path", { d: "m14 14 4 4" })
1210
- ] }) : e === "reset" ? /* @__PURE__ */ Q(pt, { 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" });
1213
+ ] }) : 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" });
1211
1214
  }
1212
- function fa({ icon: e }) {
1215
+ function ga({ icon: e }) {
1213
1216
  return /* @__PURE__ */ Z("svg", {
1214
1217
  viewBox: "0 0 24 24",
1215
1218
  "aria-hidden": "true",
@@ -1220,50 +1223,50 @@ function fa({ icon: e }) {
1220
1223
  strokeLinecap: "round",
1221
1224
  strokeLinejoin: "round",
1222
1225
  strokeWidth: "1.8",
1223
- children: da(e)
1226
+ children: ha(e)
1224
1227
  })
1225
1228
  });
1226
1229
  }
1227
- function pa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, readOnly: i = !1 }) {
1228
- let a = J(null), o = J(null), s = J(null), c = J(null), l = J(null), u = J(null), d = J({
1230
+ function _a({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, readOnly: i = !1 }) {
1231
+ let a = q(null), o = q(null), s = q(null), c = q(null), l = q(null), u = q(null), d = q({
1229
1232
  active: !1,
1230
1233
  lastX: 0,
1231
1234
  lastY: 0
1232
- }), [f, p] = Y(null), [m, h] = Y(null), [g, _] = Y([]), [v, y] = Y(null), [b, x] = Y(!1), [S, C] = Y(""), [w, T] = Y(-1), [E, D] = Y(null), [O, k] = Y(!1), [A, j] = Y(null), [ee, M] = Y(null), [te, N] = Y(!1), [ne, P] = Y(0), [re, F] = Y(0), I = Gt(t), ie = Zn(t, f), ae = !i && e && I.active && I.pos !== null ? {
1233
- ...I,
1234
- pos: I.pos,
1235
+ }), [f, p] = J(null), [m, h] = J(null), [g, _] = J([]), [v, y] = J(null), [b, x] = J(!1), [S, C] = J(""), [w, T] = J(-1), [E, D] = J(null), [ee, O] = J(!1), [k, A] = J(null), [te, j] = J(null), [ne, re] = J(!1), [ie, ae] = J(0), [M, N] = J(0), P = Wt(t), oe = tr(t, f), F = !i && e && P.active && P.pos !== null ? {
1236
+ ...P,
1237
+ pos: P.pos,
1235
1238
  active: !0
1236
- } : null, L = ie ?? ae, oe = L !== null, R = L?.language === "mermaid", z = nr(t, L), B = oe && L !== null && !z, se = !i, ce = Wn(L ? L.language : "text"), V = E?.status ?? "idle", le = L?.mermaidPreviewMode ?? n, ue = R && le === "preview", H = er(t), de = `${re}|${H.map((e) => `${e.pos}:${e.mermaidPreviewMode}:${e.text.length}`).join("|")}`, U = q(() => Jn(S.trim().toLowerCase()), [S]);
1237
- if (K(() => {
1239
+ } : null, I = oe ?? F, se = I !== null, L = I?.language === "mermaid", R = or(t, I), z = se && I !== null && !R, ce = !i, le = Jn(I ? I.language : "text"), B = E?.status ?? "idle", ue = I?.mermaidPreviewMode ?? n, V = L && ue === "preview", H = ir(t), de = `${M}|${H.map((e) => `${e.pos}:${e.mermaidPreviewMode}:${e.text.length}`).join("|")}`, fe = K(() => Qn(S.trim().toLowerCase()), [S]);
1240
+ if (G(() => {
1238
1241
  i && (x(!1), C(""), T(-1));
1239
- }, [i]), K(() => {
1242
+ }, [i]), G(() => {
1240
1243
  if (!E) return;
1241
1244
  let e = window.setTimeout(() => {
1242
1245
  D(null);
1243
- }, Ln);
1246
+ }, Vn);
1244
1247
  return () => {
1245
1248
  window.clearTimeout(e);
1246
1249
  };
1247
- }, [E]), K(() => {
1248
- D(null), x(!1), C(""), T(-1), j(null), M(null), N(!1);
1250
+ }, [E]), G(() => {
1251
+ D(null), x(!1), C(""), T(-1), A(null), j(null), re(!1);
1249
1252
  }, [
1250
1253
  e,
1251
- L?.language,
1252
- L?.pos,
1253
- L?.text
1254
- ]), K(() => {
1254
+ I?.language,
1255
+ I?.pos,
1256
+ I?.text
1257
+ ]), G(() => {
1255
1258
  let e = ({ transaction: e }) => {
1256
- e.getMeta(Ut) && P((e) => e + 1);
1259
+ e.getMeta(Ht) && ae((e) => e + 1);
1257
1260
  };
1258
1261
  return t.on("transaction", e), () => {
1259
1262
  t.off("transaction", e);
1260
1263
  };
1261
- }, [t]), K(() => {
1264
+ }, [t]), G(() => {
1262
1265
  let e = t.view.dom.closest(".markweave-editor-frame");
1263
1266
  if (!e) return;
1264
1267
  let n = (e) => {
1265
1268
  if (e.target instanceof Node && a.current?.contains(e.target) || b) return;
1266
- let n = Zn(t, Xn(t, e.target)), r = n && !nr(t, n) ? n.pos : null;
1269
+ let n = tr(t, er(t, e.target)), r = n && !or(t, n) ? n.pos : null;
1267
1270
  p((e) => e === r ? e : r);
1268
1271
  }, r = () => {
1269
1272
  b || p(null);
@@ -1271,20 +1274,20 @@ function pa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1271
1274
  return e.addEventListener("mousemove", n), e.addEventListener("mouseleave", r), () => {
1272
1275
  e.removeEventListener("mousemove", n), e.removeEventListener("mouseleave", r);
1273
1276
  };
1274
- }, [t, b]), K(() => {
1277
+ }, [t, b]), G(() => {
1275
1278
  b && c.current?.focus({ preventScroll: !0 });
1276
1279
  }, [b]), Re(() => {
1277
1280
  if (!b || w < 0) return;
1278
1281
  let e = l.current, t = e?.querySelector(`[data-language-index="${w}"]`);
1279
- e && t && sr(e, t);
1282
+ e && t && dr(e, t);
1280
1283
  }, [
1281
1284
  w,
1282
- U,
1285
+ fe,
1283
1286
  b
1284
- ]), K(() => {
1285
- if (!A) return;
1287
+ ]), G(() => {
1288
+ if (!k) return;
1286
1289
  let e = (e) => {
1287
- e.key === "Escape" && (j(null), M(null), N(!1), d.current = {
1290
+ e.key === "Escape" && (A(null), j(null), re(!1), d.current = {
1288
1291
  active: !1,
1289
1292
  lastX: 0,
1290
1293
  lastY: 0
@@ -1293,8 +1296,8 @@ function pa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1293
1296
  return document.addEventListener("keydown", e), () => {
1294
1297
  document.removeEventListener("keydown", e);
1295
1298
  };
1296
- }, [t, A]), K(() => {
1297
- if (!oe || !b) return;
1299
+ }, [t, k]), G(() => {
1300
+ if (!se || !b) return;
1298
1301
  let e = (e) => {
1299
1302
  e.key === "Escape" && (x(!1), T(-1), t.view.focus());
1300
1303
  }, n = (e) => {
@@ -1304,22 +1307,22 @@ function pa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1304
1307
  document.removeEventListener("keydown", e), document.removeEventListener("mousedown", n);
1305
1308
  };
1306
1309
  }, [
1307
- oe,
1310
+ se,
1308
1311
  t,
1309
1312
  b
1310
1313
  ]), Re(() => {
1311
1314
  let e = () => {
1312
1315
  let e = a.current;
1313
1316
  if (!e) return;
1314
- if (!Qn(e) || H.length === 0) {
1317
+ if (!nr(e) || H.length === 0) {
1315
1318
  _([]);
1316
1319
  return;
1317
1320
  }
1318
1321
  let n = e.getBoundingClientRect(), r = H.flatMap((e) => {
1319
- let r = qn(Kn(t, e.pos, e.mermaidPreviewMode), n);
1320
- return r ? [Hn(e, r, n)] : [];
1322
+ let r = Zn(Xn(t, e.pos, e.mermaidPreviewMode), n);
1323
+ return r ? [Kn(e, r, n)] : [];
1321
1324
  });
1322
- _((e) => rr(e, r, H.map((e) => e.pos)));
1325
+ _((e) => sr(e, r, H.map((e) => e.pos)));
1323
1326
  };
1324
1327
  e();
1325
1328
  let n = window.requestAnimationFrame(e);
@@ -1327,26 +1330,26 @@ function pa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1327
1330
  window.cancelAnimationFrame(n), window.removeEventListener("resize", e), window.removeEventListener("scroll", e, !0);
1328
1331
  };
1329
1332
  }, [
1330
- ne,
1333
+ ie,
1331
1334
  t,
1332
1335
  de
1333
1336
  ]), Re(() => {
1334
- if (!B || !L) {
1337
+ if (!z || !I) {
1335
1338
  h(null), y(null);
1336
1339
  return;
1337
1340
  }
1338
1341
  let e = () => {
1339
1342
  let e = a.current;
1340
1343
  if (!e) return;
1341
- let n = Kn(t, L.pos, le), r = e.getBoundingClientRect(), i = qn(n, r);
1344
+ let n = Xn(t, I.pos, ue), r = e.getBoundingClientRect(), i = Zn(n, r);
1342
1345
  if (!i) {
1343
- h((e) => e?.pos === L.pos ? e : null), y((e) => b ? e : null);
1346
+ h((e) => e?.pos === I.pos ? e : null), y((e) => b ? e : null);
1344
1347
  return;
1345
1348
  }
1346
- let c = Bn(L.pos, i, r);
1349
+ let c = Wn(I.pos, i, r);
1347
1350
  if (h(c), b && o.current) {
1348
1351
  let e = o.current.getBoundingClientRect(), t = s.current?.getBoundingClientRect().height;
1349
- y(Fn({
1352
+ y(zn({
1350
1353
  overlayRect: r,
1351
1354
  buttonRect: e,
1352
1355
  menuHeight: t,
@@ -1359,102 +1362,102 @@ function pa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1359
1362
  window.removeEventListener("resize", e), window.removeEventListener("scroll", e, !0);
1360
1363
  };
1361
1364
  }, [
1362
- B,
1363
- ne,
1364
- L?.pos,
1365
+ z,
1366
+ ie,
1367
+ I?.pos,
1365
1368
  t,
1366
- U.length,
1369
+ fe.length,
1367
1370
  b,
1368
- le
1369
- ]), !B && H.length === 0 && !A) return null;
1370
- let fe = m ? {
1371
+ ue
1372
+ ]), !z && H.length === 0 && !k) return null;
1373
+ let pe = m ? {
1371
1374
  top: m.top,
1372
1375
  right: m.right
1373
- } : void 0, pe = async () => {
1376
+ } : void 0, me = async () => {
1374
1377
  if (i) {
1375
- if (!L) return;
1376
- let e = await Rn(L.text);
1377
- D(Kt(L, e ? "copied" : "failed"));
1378
+ if (!I) return;
1379
+ let e = await Hn(I.text);
1380
+ D(Gt(I, e ? "copied" : "failed"));
1378
1381
  return;
1379
1382
  }
1380
- if (!Un(t, L)) return;
1381
- let e = await Wt(t);
1382
- D(Kt(Gt(t), e ? "copied" : "failed")), t.view.focus();
1383
- }, me = (e, n) => {
1383
+ if (!qn(t, I)) return;
1384
+ let e = await Ut(t);
1385
+ D(Gt(Wt(t), e ? "copied" : "failed")), t.view.focus();
1386
+ }, he = (e, n) => {
1384
1387
  if (i) {
1385
- en(t, e.pos, n) && F((e) => e + 1);
1388
+ $t(t, e.pos, n) && N((e) => e + 1);
1386
1389
  return;
1387
1390
  }
1388
- let a = I.active && I.pos === e.pos;
1389
- Xt(t, e.pos, n) && (r(n), F((e) => e + 1), a && t.view.focus());
1390
- }, W = (e) => {
1391
- if (i || !L) return;
1392
- let n = I.active && I.pos === L.pos;
1393
- Yt(t, L.pos, e) && (e === "mermaid" && Xt(t, L.pos, "preview") && r("preview"), x(!1), C(""), T(-1), F((e) => e + 1), n && t.view.focus());
1394
- }, he = () => {
1395
- let e = !b;
1396
- e && u.current === null && (u.current = zn()), T(e ? $n(U, L?.language ?? null) : -1), x(e);
1391
+ let a = P.active && P.pos === e.pos;
1392
+ Yt(t, e.pos, n) && (r(n), N((e) => e + 1), a && t.view.focus());
1397
1393
  }, ge = (e) => {
1398
- let t = Jn(e);
1399
- C(e), T($n(t, e.trim() ? null : L?.language ?? null));
1400
- }, _e = (e) => {
1394
+ if (i || !I) return;
1395
+ let n = P.active && P.pos === I.pos;
1396
+ Jt(t, I.pos, e) && (e === "mermaid" && Yt(t, I.pos, "preview") && r("preview"), x(!1), C(""), T(-1), N((e) => e + 1), n && t.view.focus());
1397
+ }, _e = () => {
1398
+ let e = !b;
1399
+ e && u.current === null && (u.current = Un()), T(e ? rr(fe, I?.language ?? null) : -1), x(e);
1400
+ }, ve = (e) => {
1401
+ let t = Qn(e);
1402
+ C(e), T(rr(t, e.trim() ? null : I?.language ?? null));
1403
+ }, ye = (e) => {
1401
1404
  if (!e.nativeEvent.isComposing) {
1402
1405
  if (e.key === "ArrowDown" || e.key === "ArrowUp") {
1403
- e.preventDefault(), T((t) => ar(t, U.length, e.key === "ArrowUp" ? "previous" : "next"));
1406
+ e.preventDefault(), T((t) => lr(t, fe.length, e.key === "ArrowUp" ? "previous" : "next"));
1404
1407
  return;
1405
1408
  }
1406
1409
  if (e.key === "Enter") {
1407
- let t = U[w];
1408
- t && (e.preventDefault(), W(t.language));
1410
+ let t = fe[w];
1411
+ t && (e.preventDefault(), ge(t.language));
1409
1412
  return;
1410
1413
  }
1411
1414
  e.key === "Escape" && (e.preventDefault(), x(!1), T(-1), t.view.focus());
1412
1415
  }
1413
- }, ve = U[w], ye = u.current && ve ? Yn(u.current, ve.language) : void 0, be = () => {
1414
- i || !L || Jt(t, L.pos, !z) && (P((e) => e + 1), p(null));
1415
- }, xe = () => {
1416
- if (!L) return;
1417
- let e = tr(t, L.pos);
1418
- e && Pn({
1416
+ }, be = fe[w], xe = u.current && be ? $n(u.current, be.language) : void 0, Se = () => {
1417
+ i || !I || qt(t, I.pos, !R) && (ae((e) => e + 1), p(null));
1418
+ }, U = () => {
1419
+ if (!I) return;
1420
+ let e = ar(t, I.pos);
1421
+ e && Rn({
1419
1422
  data: new Blob([e], { type: "image/svg+xml" }),
1420
1423
  fileName: "markweave-mermaid.svg",
1421
1424
  onSettled: () => t.view.focus(),
1422
1425
  ownerDocument: document
1423
1426
  });
1424
- }, Se = () => {
1425
- if (!L) return;
1426
- let e = tr(t, L.pos);
1427
- e && (j(Vn(e)), M(null), N(!1), d.current = {
1427
+ }, Ce = () => {
1428
+ if (!I) return;
1429
+ let e = ar(t, I.pos);
1430
+ e && (A(Gn(e)), j(null), re(!1), d.current = {
1428
1431
  active: !1,
1429
1432
  lastX: 0,
1430
1433
  lastY: 0
1431
1434
  });
1432
- }, Ce = () => {
1433
- j(null), M(null), N(!1), d.current = {
1435
+ }, we = () => {
1436
+ A(null), j(null), re(!1), d.current = {
1434
1437
  active: !1,
1435
1438
  lastX: 0,
1436
1439
  lastY: 0
1437
1440
  }, t.view.focus();
1438
- }, we = (e) => {
1439
- j((t) => t && {
1441
+ }, Te = (e) => {
1442
+ A((t) => t && {
1440
1443
  ...t,
1441
- scale: In(t.scale + e)
1444
+ scale: Bn(t.scale + e)
1442
1445
  });
1443
- }, Te = () => {
1444
- j((e) => e && Vn(e.svg)), d.current = {
1446
+ }, Ee = () => {
1447
+ A((e) => e && Gn(e.svg)), d.current = {
1445
1448
  active: !1,
1446
1449
  lastX: 0,
1447
1450
  lastY: 0
1448
- }, N(!1);
1449
- }, Ee = (e) => {
1450
- e.preventDefault(), we(e.deltaY < 0 ? ir : -ir);
1451
+ }, re(!1);
1451
1452
  }, De = (e) => {
1453
+ e.preventDefault(), Te(e.deltaY < 0 ? cr : -cr);
1454
+ }, Oe = (e) => {
1452
1455
  e.button === 0 && (e.preventDefault(), d.current = {
1453
1456
  active: !0,
1454
1457
  lastX: e.clientX,
1455
1458
  lastY: e.clientY
1456
- }, N(!0));
1457
- }, Oe = (e) => {
1459
+ }, re(!0));
1460
+ }, ke = (e) => {
1458
1461
  let t = d.current;
1459
1462
  if (!t.active) return;
1460
1463
  let n = e.clientX - t.lastX, r = e.clientY - t.lastY;
@@ -1462,13 +1465,13 @@ function pa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1462
1465
  active: !0,
1463
1466
  lastX: e.clientX,
1464
1467
  lastY: e.clientY
1465
- }, j((e) => or(e, n, r));
1466
- }, ke = () => {
1468
+ }, A((e) => ur(e, n, r));
1469
+ }, Ae = () => {
1467
1470
  d.current = {
1468
1471
  active: !1,
1469
1472
  lastX: 0,
1470
1473
  lastY: 0
1471
- }, N(!1);
1474
+ }, re(!1);
1472
1475
  };
1473
1476
  return /* @__PURE__ */ Q("div", {
1474
1477
  ref: a,
@@ -1492,25 +1495,25 @@ function pa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1492
1495
  "data-testid": `markweave-mermaid-mode-${t}`,
1493
1496
  "data-active": e.mermaidPreviewMode === t,
1494
1497
  onMouseDown: (e) => e.preventDefault(),
1495
- onClick: () => me(e, t),
1498
+ onClick: () => he(e, t),
1496
1499
  children: t === "code" ? "Code" : "Preview"
1497
1500
  }, t))
1498
1501
  }, e.pos);
1499
1502
  }),
1500
- B ? /* @__PURE__ */ Q("div", {
1503
+ z ? /* @__PURE__ */ Q("div", {
1501
1504
  className: "markweave-codeblock-controls",
1502
1505
  "data-testid": "markweave-codeblock-controls",
1503
1506
  "data-positioned": m ? "true" : "false",
1504
- "data-collapsed": z ? "true" : "false",
1507
+ "data-collapsed": R ? "true" : "false",
1505
1508
  "data-read-only": i ? "true" : "false",
1506
1509
  "aria-label": "Code block controls",
1507
- style: fe,
1510
+ style: pe,
1508
1511
  children: [
1509
1512
  i ? /* @__PURE__ */ Z("span", {
1510
1513
  className: "markweave-codeblock-language-button markweave-codeblock-language-label",
1511
1514
  "aria-label": "Code block language",
1512
1515
  "data-testid": "markweave-codeblock-language",
1513
- children: /* @__PURE__ */ Z("span", { children: ce })
1516
+ children: /* @__PURE__ */ Z("span", { children: le })
1514
1517
  }) : /* @__PURE__ */ Q("button", {
1515
1518
  ref: o,
1516
1519
  type: "button",
@@ -1520,19 +1523,19 @@ function pa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1520
1523
  "aria-haspopup": "listbox",
1521
1524
  "data-testid": "markweave-codeblock-language",
1522
1525
  onMouseDown: (e) => e.preventDefault(),
1523
- onClick: he,
1524
- children: [/* @__PURE__ */ Z("span", { children: ce }), /* @__PURE__ */ Z(fa, { icon: "chevron" })]
1526
+ onClick: _e,
1527
+ children: [/* @__PURE__ */ Z("span", { children: le }), /* @__PURE__ */ Z(ga, { icon: "chevron" })]
1525
1528
  }),
1526
- se ? /* @__PURE__ */ Z("button", {
1529
+ ce ? /* @__PURE__ */ Z("button", {
1527
1530
  type: "button",
1528
1531
  className: "markweave-codeblock-icon-button markweave-codeblock-collapse-button",
1529
- "aria-label": z ? "Expand code block" : "Collapse code block",
1530
- title: z ? "Expand code block" : "Collapse code block",
1532
+ "aria-label": R ? "Expand code block" : "Collapse code block",
1533
+ title: R ? "Expand code block" : "Collapse code block",
1531
1534
  "data-testid": "markweave-codeblock-collapse",
1532
- "data-collapsed": z ? "true" : "false",
1535
+ "data-collapsed": R ? "true" : "false",
1533
1536
  onMouseDown: (e) => e.preventDefault(),
1534
- onClick: be,
1535
- children: /* @__PURE__ */ Z(fa, { icon: "chevron" })
1537
+ onClick: Se,
1538
+ children: /* @__PURE__ */ Z(ga, { icon: "chevron" })
1536
1539
  }) : null,
1537
1540
  /* @__PURE__ */ Q("span", {
1538
1541
  className: "markweave-codeblock-copy-wrap",
@@ -1541,22 +1544,22 @@ function pa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1541
1544
  className: "markweave-codeblock-icon-button",
1542
1545
  "aria-label": "Copy to clipboard",
1543
1546
  "data-testid": "markweave-codeblock-copy",
1544
- "data-copy-state": V,
1547
+ "data-copy-state": B,
1545
1548
  onMouseDown: (e) => e.preventDefault(),
1546
- onMouseEnter: () => k(!0),
1547
- onMouseLeave: () => k(!1),
1548
- onFocus: () => k(!0),
1549
- onBlur: () => k(!1),
1550
- onClick: pe,
1551
- children: /* @__PURE__ */ Z(fa, { icon: V === "copied" ? "check" : "clipboard" })
1552
- }), O ? /* @__PURE__ */ Z("span", {
1549
+ onMouseEnter: () => O(!0),
1550
+ onMouseLeave: () => O(!1),
1551
+ onFocus: () => O(!0),
1552
+ onBlur: () => O(!1),
1553
+ onClick: me,
1554
+ children: /* @__PURE__ */ Z(ga, { icon: B === "copied" ? "check" : "clipboard" })
1555
+ }), ee ? /* @__PURE__ */ Z("span", {
1553
1556
  className: "markweave-codeblock-tooltip",
1554
1557
  role: "tooltip",
1555
1558
  "data-testid": "markweave-codeblock-copy-tooltip",
1556
1559
  children: "Copy to clipboard"
1557
1560
  }) : null]
1558
1561
  }),
1559
- R && le === "preview" ? /* @__PURE__ */ Q("div", {
1562
+ L && ue === "preview" ? /* @__PURE__ */ Q("div", {
1560
1563
  className: "markweave-mermaid-preview-actions",
1561
1564
  "data-testid": "markweave-mermaid-preview-actions",
1562
1565
  children: [/* @__PURE__ */ Z("button", {
@@ -1564,24 +1567,24 @@ function pa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1564
1567
  className: "markweave-codeblock-icon-button",
1565
1568
  "aria-label": "Fullscreen Mermaid preview",
1566
1569
  "data-testid": "markweave-mermaid-fullscreen",
1567
- disabled: !ue,
1570
+ disabled: !V,
1568
1571
  onMouseDown: (e) => e.preventDefault(),
1569
- onClick: Se,
1570
- children: /* @__PURE__ */ Z(fa, { icon: "expand" })
1572
+ onClick: Ce,
1573
+ children: /* @__PURE__ */ Z(ga, { icon: "expand" })
1571
1574
  }), /* @__PURE__ */ Z("button", {
1572
1575
  type: "button",
1573
1576
  className: "markweave-codeblock-icon-button",
1574
1577
  "aria-label": "Download Mermaid SVG",
1575
1578
  "data-testid": "markweave-mermaid-download",
1576
- disabled: !ue,
1579
+ disabled: !V,
1577
1580
  onMouseDown: (e) => e.preventDefault(),
1578
- onClick: xe,
1579
- children: /* @__PURE__ */ Z(fa, { icon: "download" })
1581
+ onClick: U,
1582
+ children: /* @__PURE__ */ Z(ga, { icon: "download" })
1580
1583
  })]
1581
1584
  }) : null
1582
1585
  ]
1583
1586
  }) : null,
1584
- se && B && b ? /* @__PURE__ */ Q("div", {
1587
+ ce && z && b ? /* @__PURE__ */ Q("div", {
1585
1588
  ref: s,
1586
1589
  className: "markweave-codeblock-language-menu",
1587
1590
  "data-testid": "markweave-codeblock-language-menu",
@@ -1598,24 +1601,24 @@ function pa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1598
1601
  "aria-autocomplete": "list",
1599
1602
  "aria-controls": u.current ?? void 0,
1600
1603
  "aria-expanded": "true",
1601
- "aria-activedescendant": ye,
1604
+ "aria-activedescendant": xe,
1602
1605
  "aria-label": "Search code block languages",
1603
1606
  value: S,
1604
1607
  placeholder: "Search...",
1605
1608
  "data-testid": "markweave-codeblock-language-search",
1606
- onChange: (e) => ge(e.target.value),
1607
- onKeyDown: _e
1608
- }), /* @__PURE__ */ Z(fa, { icon: "search" })]
1609
+ onChange: (e) => ve(e.target.value),
1610
+ onKeyDown: ye
1611
+ }), /* @__PURE__ */ Z(ga, { icon: "search" })]
1609
1612
  }), /* @__PURE__ */ Z("div", {
1610
1613
  ref: l,
1611
1614
  id: u.current ?? void 0,
1612
1615
  className: "markweave-codeblock-language-list",
1613
1616
  role: "listbox",
1614
1617
  "aria-label": "Code block languages",
1615
- children: U.map((e, t) => {
1616
- let n = e.language === L.language, r = t === w;
1618
+ children: fe.map((e, t) => {
1619
+ let n = e.language === I.language, r = t === w;
1617
1620
  return /* @__PURE__ */ Q("button", {
1618
- id: u.current ? Yn(u.current, e.language) : void 0,
1621
+ id: u.current ? $n(u.current, e.language) : void 0,
1619
1622
  type: "button",
1620
1623
  role: "option",
1621
1624
  "aria-selected": n,
@@ -1625,13 +1628,13 @@ function pa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1625
1628
  "data-language-index": t,
1626
1629
  onMouseDown: (e) => e.preventDefault(),
1627
1630
  onMouseEnter: () => T(t),
1628
- onClick: () => W(e.language),
1629
- children: [/* @__PURE__ */ Z("span", { children: e.label }), n ? /* @__PURE__ */ Z(fa, { icon: "check" }) : null]
1631
+ onClick: () => ge(e.language),
1632
+ children: [/* @__PURE__ */ Z("span", { children: e.label }), n ? /* @__PURE__ */ Z(ga, { icon: "check" }) : null]
1630
1633
  }, e.language);
1631
1634
  })
1632
1635
  })]
1633
1636
  }) : null,
1634
- A ? /* @__PURE__ */ Q("div", {
1637
+ k ? /* @__PURE__ */ Q("div", {
1635
1638
  className: "markweave-mermaid-fullscreen-layer",
1636
1639
  role: "dialog",
1637
1640
  "aria-modal": "true",
@@ -1647,47 +1650,47 @@ function pa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1647
1650
  className: "markweave-mermaid-fullscreen-control",
1648
1651
  "aria-label": "Zoom out",
1649
1652
  "data-testid": "markweave-mermaid-fullscreen-zoom-out",
1650
- onMouseEnter: () => M("zoom-out"),
1651
- onMouseLeave: () => M(null),
1652
- onFocus: () => M("zoom-out"),
1653
- onBlur: () => M(null),
1654
- onClick: () => we(-ir),
1655
- children: /* @__PURE__ */ Z(fa, { icon: "zoomOut" })
1653
+ onMouseEnter: () => j("zoom-out"),
1654
+ onMouseLeave: () => j(null),
1655
+ onFocus: () => j("zoom-out"),
1656
+ onBlur: () => j(null),
1657
+ onClick: () => Te(-cr),
1658
+ children: /* @__PURE__ */ Z(ga, { icon: "zoomOut" })
1656
1659
  }),
1657
1660
  /* @__PURE__ */ Z("span", {
1658
1661
  className: "markweave-mermaid-fullscreen-zoom-label",
1659
1662
  "data-testid": "markweave-mermaid-fullscreen-zoom-label",
1660
- children: Gn(A.scale)
1663
+ children: Yn(k.scale)
1661
1664
  }),
1662
1665
  /* @__PURE__ */ Z("button", {
1663
1666
  type: "button",
1664
1667
  className: "markweave-mermaid-fullscreen-control",
1665
1668
  "aria-label": "Zoom in",
1666
1669
  "data-testid": "markweave-mermaid-fullscreen-zoom-in",
1667
- onMouseEnter: () => M("zoom-in"),
1668
- onMouseLeave: () => M(null),
1669
- onFocus: () => M("zoom-in"),
1670
- onBlur: () => M(null),
1671
- onClick: () => we(ir),
1672
- children: /* @__PURE__ */ Z(fa, { icon: "zoomIn" })
1670
+ onMouseEnter: () => j("zoom-in"),
1671
+ onMouseLeave: () => j(null),
1672
+ onFocus: () => j("zoom-in"),
1673
+ onBlur: () => j(null),
1674
+ onClick: () => Te(cr),
1675
+ children: /* @__PURE__ */ Z(ga, { icon: "zoomIn" })
1673
1676
  }),
1674
1677
  /* @__PURE__ */ Z("button", {
1675
1678
  type: "button",
1676
1679
  className: "markweave-mermaid-fullscreen-control",
1677
1680
  "aria-label": "Reset zoom",
1678
1681
  "data-testid": "markweave-mermaid-fullscreen-reset",
1679
- onMouseEnter: () => M("reset"),
1680
- onMouseLeave: () => M(null),
1681
- onFocus: () => M("reset"),
1682
- onBlur: () => M(null),
1683
- onClick: Te,
1684
- children: /* @__PURE__ */ Z(fa, { icon: "reset" })
1682
+ onMouseEnter: () => j("reset"),
1683
+ onMouseLeave: () => j(null),
1684
+ onFocus: () => j("reset"),
1685
+ onBlur: () => j(null),
1686
+ onClick: Ee,
1687
+ children: /* @__PURE__ */ Z(ga, { icon: "reset" })
1685
1688
  }),
1686
- ee ? /* @__PURE__ */ Z("span", {
1689
+ te ? /* @__PURE__ */ Z("span", {
1687
1690
  className: "markweave-mermaid-fullscreen-tooltip",
1688
1691
  role: "tooltip",
1689
1692
  "data-testid": "markweave-mermaid-fullscreen-tooltip",
1690
- children: ee === "zoom-out" ? "Zoom out" : ee === "zoom-in" ? "Zoom in" : "Reset"
1693
+ children: te === "zoom-out" ? "Zoom out" : te === "zoom-in" ? "Zoom in" : "Reset"
1691
1694
  }) : null
1692
1695
  ]
1693
1696
  }),
@@ -1696,29 +1699,29 @@ function pa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1696
1699
  className: "markweave-mermaid-fullscreen-close",
1697
1700
  "aria-label": "Close fullscreen Mermaid preview",
1698
1701
  "data-testid": "markweave-mermaid-fullscreen-close",
1699
- onClick: Ce,
1700
- children: /* @__PURE__ */ Z(fa, { icon: "close" })
1702
+ onClick: we,
1703
+ children: /* @__PURE__ */ Z(ga, { icon: "close" })
1701
1704
  }),
1702
1705
  /* @__PURE__ */ Z("div", {
1703
1706
  className: "markweave-mermaid-fullscreen-viewport",
1704
1707
  "data-testid": "markweave-mermaid-fullscreen-viewport",
1705
- "data-dragging": te ? "true" : "false",
1706
- onWheel: Ee,
1707
- onMouseDown: De,
1708
- onMouseMove: Oe,
1709
- onMouseUp: ke,
1710
- onMouseLeave: ke,
1708
+ "data-dragging": ne ? "true" : "false",
1709
+ onWheel: De,
1710
+ onMouseDown: Oe,
1711
+ onMouseMove: ke,
1712
+ onMouseUp: Ae,
1713
+ onMouseLeave: Ae,
1711
1714
  children: /* @__PURE__ */ Z("div", {
1712
1715
  className: "markweave-mermaid-fullscreen-content",
1713
1716
  "data-testid": "markweave-mermaid-fullscreen-content",
1714
- "data-scale-percent": Math.round(A.scale * 100),
1715
- "data-translate": `${Math.round(A.translateX)},${Math.round(A.translateY)}`,
1717
+ "data-scale-percent": Math.round(k.scale * 100),
1718
+ "data-translate": `${Math.round(k.translateX)},${Math.round(k.translateY)}`,
1716
1719
  style: {
1717
- width: `${A.width}px`,
1718
- height: `${A.height}px`,
1719
- transform: `translate(${A.translateX}px, ${A.translateY}px) scale(${A.scale})`
1720
+ width: `${k.width}px`,
1721
+ height: `${k.height}px`,
1722
+ transform: `translate(${k.translateX}px, ${k.translateY}px) scale(${k.scale})`
1720
1723
  },
1721
- dangerouslySetInnerHTML: { __html: A.svg }
1724
+ dangerouslySetInnerHTML: { __html: k.svg }
1722
1725
  })
1723
1726
  })
1724
1727
  ]
@@ -1728,25 +1731,25 @@ function pa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1728
1731
  }
1729
1732
  //#endregion
1730
1733
  //#region src/ui/floating-toolbar/FloatingToolbar.tsx
1731
- var ma = n("zh");
1732
- function ha() {
1734
+ var va = t("zh");
1735
+ function ya() {
1733
1736
  return typeof performance > "u" ? Date.now() : performance.now();
1734
1737
  }
1735
- function ga(e, t) {
1738
+ function ba(e, t) {
1736
1739
  return {
1737
1740
  "--markweave-toolbar-motion-duration": `${e.motionDurationMs}ms`,
1738
1741
  "--markweave-toolbar-motion-easing": e.motionEasing,
1739
1742
  marginLeft: t === 0 ? void 0 : `${t}px`
1740
1743
  };
1741
1744
  }
1742
- function _a(e, t) {
1745
+ function xa(e, t) {
1743
1746
  let n = e?.getBoundingClientRect().height ?? 0, r = t?.getBoundingClientRect().height ?? 0;
1744
1747
  return Math.max(n, r, 44);
1745
1748
  }
1746
- function va(e) {
1749
+ function Sa(e) {
1747
1750
  if (e !== null) return { "--markweave-floating-toolbar-tooltip-left": `${e}px` };
1748
1751
  }
1749
- function ya(e, t, n, r) {
1752
+ function Ca(e, t, n, r) {
1750
1753
  let i = {
1751
1754
  bottom: t + r,
1752
1755
  height: r,
@@ -1762,26 +1765,26 @@ function ya(e, t, n, r) {
1762
1765
  toJSON: () => i
1763
1766
  };
1764
1767
  }
1765
- function ba(e) {
1768
+ function wa(e) {
1766
1769
  return e.width > 0 && e.height > 0;
1767
1770
  }
1768
- function xa(e) {
1771
+ function Ta(e) {
1769
1772
  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));
1770
- return ya(t, n, r - t, i - n);
1773
+ return Ca(t, n, r - t, i - n);
1771
1774
  }
1772
- function Sa(e, t) {
1775
+ function Ea(e, t) {
1773
1776
  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;
1774
1777
  return r(t.anchorNode) && r(t.focusNode);
1775
1778
  }
1776
- function Ca(e) {
1779
+ function Da(e) {
1777
1780
  if (typeof e.getClientRects != "function") return null;
1778
- let t = Array.from(e.getClientRects()).filter(ba).map((e) => ya(e.left, e.top, e.width, e.height));
1781
+ let t = Array.from(e.getClientRects()).filter(wa).map((e) => Ca(e.left, e.top, e.width, e.height));
1779
1782
  if (t.length > 0) return t;
1780
1783
  if (typeof e.getBoundingClientRect != "function") return null;
1781
1784
  let n = e.getBoundingClientRect();
1782
- return ba(n) ? [ya(n.left, n.top, n.width, n.height)] : null;
1785
+ return wa(n) ? [Ca(n.left, n.top, n.width, n.height)] : null;
1783
1786
  }
1784
- function wa(e, t) {
1787
+ function Oa(e, t) {
1785
1788
  if (t.rangeCount === 0) return null;
1786
1789
  let n = t.getRangeAt(0);
1787
1790
  try {
@@ -1794,8 +1797,8 @@ function wa(e, t) {
1794
1797
  return null;
1795
1798
  }
1796
1799
  }
1797
- function Ta(e, t) {
1798
- let n = wa(e, t);
1800
+ function ka(e, t) {
1801
+ let n = Oa(e, t);
1799
1802
  if (!n) return !1;
1800
1803
  let { selection: r } = e.state, i = {
1801
1804
  from: Math.min(r.from, r.to),
@@ -1803,56 +1806,56 @@ function Ta(e, t) {
1803
1806
  };
1804
1807
  return n.from === i.from && n.to === i.to;
1805
1808
  }
1806
- function Ea(e) {
1809
+ function Aa(e) {
1807
1810
  let t = e.view.dom.ownerDocument.getSelection();
1808
- return !t || t.rangeCount === 0 || t.isCollapsed || !Sa(e, t) || !Ta(e, t) ? null : Ca(t.getRangeAt(0));
1811
+ return !t || t.rangeCount === 0 || t.isCollapsed || !Ea(e, t) || !ka(e, t) ? null : Da(t.getRangeAt(0));
1809
1812
  }
1810
- function Da(e) {
1813
+ function ja(e) {
1811
1814
  let { selection: t } = e.state;
1812
1815
  if (t.empty) return null;
1813
1816
  let n = Math.min(t.from, t.to), r = Math.max(t.from, t.to);
1814
1817
  try {
1815
1818
  let t = e.view.domAtPos(n), i = e.view.domAtPos(r), a = e.view.dom.ownerDocument.createRange();
1816
- return a.setStart(t.node, t.offset), a.setEnd(i.node, i.offset), Ca(a);
1819
+ return a.setStart(t.node, t.offset), a.setEnd(i.node, i.offset), Da(a);
1817
1820
  } catch {
1818
1821
  return null;
1819
1822
  }
1820
1823
  }
1821
- function Oa(e) {
1824
+ function Ma(e) {
1822
1825
  let { selection: t } = e.state;
1823
1826
  if (t.empty) return null;
1824
- 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 = ya(c, o, Math.max(i.right, a.right) - c, s - o);
1825
- return ba(l) ? [l] : null;
1827
+ 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 = Ca(c, o, Math.max(i.right, a.right) - c, s - o);
1828
+ return wa(l) ? [l] : null;
1826
1829
  }
1827
- function ka(e) {
1828
- return Ea(e) ?? Da(e) ?? Oa(e);
1830
+ function Na(e) {
1831
+ return Aa(e) ?? ja(e) ?? Ma(e);
1829
1832
  }
1830
- function Aa(e) {
1831
- let t = ka(e);
1832
- return t && t.length > 0 ? xa(t) : null;
1833
+ function Pa(e) {
1834
+ let t = Na(e);
1835
+ return t && t.length > 0 ? Ta(t) : null;
1833
1836
  }
1834
- function ja(e) {
1837
+ function Fa(e) {
1835
1838
  return {
1836
- getBoundingClientRect: () => Aa(e) ?? ya(0, 0, 0, 0),
1837
- getClientRects: () => ka(e) ?? []
1839
+ getBoundingClientRect: () => Pa(e) ?? Ca(0, 0, 0, 0),
1840
+ getClientRects: () => Na(e) ?? []
1838
1841
  };
1839
1842
  }
1840
- function Ma(e) {
1843
+ function Ia(e) {
1841
1844
  return e === "ask-ai" || e === "block-type" || e === "link" || e === "color" || e === "more";
1842
1845
  }
1843
- function Na(e, t, n) {
1844
- n?.(ur(e, t)), e.commands.focus();
1846
+ function La(e, t, n) {
1847
+ n?.(mr(e, t)), e.commands.focus();
1845
1848
  }
1846
- var Pa = "markweave-floating-toolbar";
1847
- function Fa({ editor: e, lang: t = "zh", messages: n = ma, selectionSnapshot: r, askAi: i, onRewriteSelection: a }) {
1848
- let o = q(() => hr(n), [n]), s = zt(r, { editable: e.isEditable }), [c, l] = Y(s), [u, d] = Y(null), [f, p] = Y(null), [m, h] = Y(null), [g, _] = Y("input"), [v, y] = Y(""), [b, x] = Y(""), [S, C] = Y(""), [w, T] = Y(""), [E, D] = Y(""), [O, k] = Y(""), [A, j] = Y(null), [ee, M] = Y(0), [te, N] = Y(s.boundaryPadding), [ne, P] = Y("bottom"), re = J(0), F = J(null), I = J(null), ie = J(null), ae = J(null), L = J(null), oe = J(null), R = J(null), z = J(null), B = J(null), se = J(""), ce = i?.enabled === !0 && typeof i.handler == "function", V = dr(e, c.variant, n, { askAiEnabled: ce }), le = _r(V.find((e) => e.id === u) ?? null), ue = Gr(E), H = G(() => {
1849
- B.current !== null && (window.cancelAnimationFrame(B.current), B.current = null);
1850
- }, []), de = G((t = !0) => {
1851
- R.current?.abort(), R.current = null, z.current = null, H(), t && Br(e), Nr(e), h(null);
1852
- }, [H, e]), U = G(() => {
1853
- let t = F.current, n = e.view.dom.closest(".markweave-editor-frame");
1849
+ var Ra = "markweave-floating-toolbar";
1850
+ function za({ editor: e, lang: t = "zh", messages: n = va, selectionSnapshot: r, askAi: i, onRewriteSelection: a }) {
1851
+ let o = K(() => yr(n), [n]), s = Rt(r, { editable: e.isEditable }), [c, l] = J(s), [u, d] = J(null), [f, p] = J(null), [m, h] = J(null), [g, _] = J("input"), [v, y] = J(""), [b, x] = J(""), [S, C] = J(""), [w, T] = J(""), [E, D] = J(""), [ee, O] = J(""), [k, A] = J(null), [te, j] = J(0), [ne, re] = J(s.boundaryPadding), [ie, ae] = J("bottom"), M = q(0), N = q(null), P = q(null), oe = q(null), F = q(null), I = q(null), se = q(null), L = q(null), R = q(null), z = q(null), ce = q(""), le = i?.enabled === !0 && typeof i.handler == "function", B = hr(e, c.variant, n, { askAiEnabled: le }), ue = xr(B.find((e) => e.id === u) ?? null), V = Yr(E), H = W(() => {
1852
+ z.current !== null && (window.cancelAnimationFrame(z.current), z.current = null);
1853
+ }, []), de = W((t = !0) => {
1854
+ L.current?.abort(), L.current = null, R.current = null, H(), t && Wr(e), Lr(e), h(null);
1855
+ }, [H, e]), fe = W(() => {
1856
+ let t = N.current, n = e.view.dom.closest(".markweave-editor-frame");
1854
1857
  if (!t || !(n instanceof HTMLElement)) return;
1855
- let r = t.getBoundingClientRect(), i = n.getBoundingClientRect(), a = _a(t, I.current), o = re.current, s = Pt({
1858
+ let r = t.getBoundingClientRect(), i = n.getBoundingClientRect(), a = xa(t, P.current), o = M.current, s = Nt({
1856
1859
  toolbarRect: {
1857
1860
  left: r.left - o,
1858
1861
  top: r.top,
@@ -1866,7 +1869,7 @@ function Fa({ editor: e, lang: t = "zh", messages: n = ma, selectionSnapshot: r,
1866
1869
  height: i.height
1867
1870
  },
1868
1871
  boundaryPadding: c.boundaryPadding
1869
- }), l = It({
1872
+ }), l = Ft({
1870
1873
  frameRect: {
1871
1874
  left: i.left,
1872
1875
  top: i.top,
@@ -1880,32 +1883,32 @@ function Fa({ editor: e, lang: t = "zh", messages: n = ma, selectionSnapshot: r,
1880
1883
  offset: c.offset,
1881
1884
  boundaryPadding: c.boundaryPadding
1882
1885
  });
1883
- t.style.marginLeft = s === 0 ? "" : `${s}px`, t.style.visibility = "visible", t.style.opacity = "1", re.current = s, M((e) => e === s ? e : s), N((e) => e === l ? e : l);
1886
+ t.style.marginLeft = s === 0 ? "" : `${s}px`, t.style.visibility = "visible", t.style.opacity = "1", M.current = s, j((e) => e === s ? e : s), re((e) => e === l ? e : l);
1884
1887
  }, [
1885
1888
  e.view.dom,
1886
1889
  c.boundaryPadding,
1887
1890
  c.offset
1888
- ]), fe = G(() => {
1889
- F.current && (F.current.style.visibility = "hidden", F.current.style.opacity = "0");
1890
- }, []), pe = G(() => {
1891
- U();
1892
- }, [U]), me = G(() => Lr(e)?.target.kind === "table" ? {
1891
+ ]), pe = W(() => {
1892
+ N.current && (N.current.style.visibility = "hidden", N.current.style.opacity = "0");
1893
+ }, []), me = W(() => {
1894
+ fe();
1895
+ }, [fe]), he = W(() => Vr(e)?.target.kind === "table" ? {
1893
1896
  getBoundingClientRect: () => {
1894
- let t = Rr(e);
1895
- return t ? ya(t.left, t.top, t.width, t.height) : ya(0, 0, 0, 0);
1897
+ let t = Hr(e);
1898
+ return t ? Ca(t.left, t.top, t.width, t.height) : Ca(0, 0, 0, 0);
1896
1899
  },
1897
1900
  getClientRects: () => {
1898
- let t = Rr(e);
1899
- return t ? [ya(t.left, t.top, t.width, t.height)] : [];
1901
+ let t = Hr(e);
1902
+ return t ? [Ca(t.left, t.top, t.width, t.height)] : [];
1900
1903
  }
1901
- } : ja(e), [e]), W = G((e) => {
1902
- ie.current = e, e?.classList.contains("markweave-ask-ai-popover") && (e.dataset.positioned = "false");
1903
- }, []), he = G(() => {
1904
- let t = F.current, n = ie.current, r = e.view.dom.closest(".markweave-editor-frame");
1904
+ } : Fa(e), [e]), ge = W((e) => {
1905
+ oe.current = e, e?.classList.contains("markweave-ask-ai-popover") && (e.dataset.positioned = "false");
1906
+ }, []), _e = W(() => {
1907
+ let t = N.current, n = oe.current, r = e.view.dom.closest(".markweave-editor-frame");
1905
1908
  if (!m || !t || !n) return;
1906
1909
  let i = t.getBoundingClientRect(), a = n.getBoundingClientRect(), o = r?.getBoundingClientRect() ?? null;
1907
1910
  if (m === "ask-ai") {
1908
- let t = Rr(e), r = I.current?.getBoundingClientRect();
1911
+ let t = Hr(e), r = P.current?.getBoundingClientRect();
1909
1912
  if (!t || !r) return;
1910
1913
  let i = {
1911
1914
  anchorRect: r,
@@ -1915,19 +1918,19 @@ function Fa({ editor: e, lang: t = "zh", messages: n = ma, selectionSnapshot: r,
1915
1918
  height: window.innerHeight
1916
1919
  },
1917
1920
  frameRect: o,
1918
- surfaceRect: Ir(e.view.dom),
1921
+ surfaceRect: Br(e.view.dom),
1919
1922
  boundaryPadding: c.boundaryPadding
1920
- }, s = Ar({
1923
+ }, s = Pr({
1921
1924
  ...i,
1922
1925
  panelSize: a
1923
1926
  }), l = `${s.width}px`;
1924
- n.style.width !== l && (n.style.width = l, s = Ar({
1927
+ n.style.width !== l && (n.style.width = l, s = Pr({
1925
1928
  ...i,
1926
1929
  panelSize: n.getBoundingClientRect()
1927
- })), n.style.left = `${s.left}px`, n.style.top = `${s.top}px`, n.style.bottom = "auto", n.style.maxWidth = `${s.maxWidth}px`, n.style.maxHeight = `${Math.max(0, s.maxHeight)}px`, n.dataset.positioned = "true", P((e) => e === s.placement ? e : s.placement);
1930
+ })), n.style.left = `${s.left}px`, n.style.top = `${s.top}px`, n.style.bottom = "auto", n.style.maxWidth = `${s.maxWidth}px`, n.style.maxHeight = `${Math.max(0, s.maxHeight)}px`, n.dataset.positioned = "true", ae((e) => e === s.placement ? e : s.placement);
1928
1931
  return;
1929
1932
  }
1930
- let s = Ft({
1933
+ let s = Pt({
1931
1934
  toolbarRect: i,
1932
1935
  popoverSize: a,
1933
1936
  viewport: {
@@ -1938,24 +1941,24 @@ function Fa({ editor: e, lang: t = "zh", messages: n = ma, selectionSnapshot: r,
1938
1941
  gap: m === "more" ? 8 : 6,
1939
1942
  boundaryPadding: c.boundaryPadding
1940
1943
  });
1941
- P((e) => e === s.placement ? e : s.placement);
1944
+ ae((e) => e === s.placement ? e : s.placement);
1942
1945
  }, [
1943
1946
  e,
1944
1947
  m,
1945
1948
  c.boundaryPadding
1946
- ]), ge = q(() => ({
1947
- ...Rt(c, { topBoundaryPadding: te }),
1948
- onShow: fe,
1949
- onUpdate: pe
1949
+ ]), ve = K(() => ({
1950
+ ...Lt(c, { topBoundaryPadding: ne }),
1951
+ onShow: pe,
1952
+ onUpdate: me
1950
1953
  }), [
1951
- fe,
1952
1954
  pe,
1955
+ me,
1953
1956
  c,
1954
- te
1957
+ ne
1955
1958
  ]);
1956
- K(() => {
1957
- let e = ha();
1958
- l((t) => Ht(t, s, e));
1959
+ G(() => {
1960
+ let e = ya();
1961
+ l((t) => Vt(t, s, e));
1959
1962
  }, [
1960
1963
  s.hiddenReason,
1961
1964
  s.motionDurationMs,
@@ -1967,10 +1970,10 @@ function Fa({ editor: e, lang: t = "zh", messages: n = ma, selectionSnapshot: r,
1967
1970
  s.updateDelayMs,
1968
1971
  s.variant,
1969
1972
  s.visibility
1970
- ]), K(() => {
1973
+ ]), G(() => {
1971
1974
  if (c.motionStartedAtMs === null || c.motionDurationMs <= 0) return;
1972
- let e = Math.max(0, c.motionStartedAtMs + c.motionDurationMs - ha()), t = window.setTimeout(() => {
1973
- l((e) => Mt(e, ha()));
1975
+ let e = Math.max(0, c.motionStartedAtMs + c.motionDurationMs - ya()), t = window.setTimeout(() => {
1976
+ l((e) => jt(e, ya()));
1974
1977
  }, e);
1975
1978
  return () => {
1976
1979
  window.clearTimeout(t);
@@ -1981,25 +1984,25 @@ function Fa({ editor: e, lang: t = "zh", messages: n = ma, selectionSnapshot: r,
1981
1984
  c.motionStartedAtMs
1982
1985
  ]), Re(() => {
1983
1986
  if (c.visibility !== "visible") {
1984
- re.current = 0, F.current && (F.current.style.marginLeft = "", F.current.style.visibility = "hidden", F.current.style.opacity = "0"), M(0), N(c.boundaryPadding);
1987
+ M.current = 0, N.current && (N.current.style.marginLeft = "", N.current.style.visibility = "hidden", N.current.style.opacity = "0"), j(0), re(c.boundaryPadding);
1985
1988
  return;
1986
1989
  }
1987
- let e = wt(U);
1990
+ let e = Ct(fe);
1988
1991
  return e.schedule(), window.addEventListener("resize", e.schedule), window.addEventListener("scroll", e.schedule, !0), () => {
1989
1992
  e.cancel(), window.removeEventListener("resize", e.schedule), window.removeEventListener("scroll", e.schedule, !0);
1990
1993
  };
1991
1994
  }, [
1992
- U,
1995
+ fe,
1993
1996
  e.view.dom,
1994
1997
  m,
1995
1998
  r?.from,
1996
1999
  r?.to,
1997
2000
  c.variant,
1998
2001
  c.visibility,
1999
- V.length
2002
+ B.length
2000
2003
  ]), Re(() => {
2001
2004
  if (!m) return;
2002
- let e = wt(he);
2005
+ let e = Ct(_e);
2003
2006
  return e.schedule(), window.addEventListener("resize", e.schedule), window.addEventListener("scroll", e.schedule, !0), () => {
2004
2007
  e.cancel(), window.removeEventListener("resize", e.schedule), window.removeEventListener("scroll", e.schedule, !0);
2005
2008
  };
@@ -2008,20 +2011,20 @@ function Fa({ editor: e, lang: t = "zh", messages: n = ma, selectionSnapshot: r,
2008
2011
  S,
2009
2012
  g,
2010
2013
  m,
2011
- he
2012
- ]), K(() => {
2013
- m === "more" && o.some((e) => e.id === u) || V.some((e) => e.id === u) || (d(null), p(null));
2014
+ _e
2015
+ ]), G(() => {
2016
+ m === "more" && o.some((e) => e.id === u) || B.some((e) => e.id === u) || (d(null), p(null));
2014
2017
  }, [
2015
2018
  o,
2016
2019
  m,
2017
2020
  u,
2018
- V
2019
- ]), K(() => {
2021
+ B
2022
+ ]), G(() => {
2020
2023
  if (!m) return;
2021
2024
  let t = (e) => {
2022
- I.current?.contains(e.target) || (m === "ask-ai" ? de(!0) : h(null));
2025
+ P.current?.contains(e.target) || (m === "ask-ai" ? de(!0) : h(null));
2023
2026
  }, n = (t) => {
2024
- t.key === "Escape" && (t.preventDefault(), m === "ask-ai" ? g === "generating" ? (R.current?.abort(), H(), _("input")) : de(!0) : (h(null), e.commands.focus()));
2027
+ t.key === "Escape" && (t.preventDefault(), m === "ask-ai" ? g === "generating" ? (L.current?.abort(), H(), _("input")) : de(!0) : (h(null), e.commands.focus()));
2025
2028
  };
2026
2029
  return document.addEventListener("pointerdown", t, !0), document.addEventListener("keydown", n, !0), () => {
2027
2030
  document.removeEventListener("pointerdown", t, !0), document.removeEventListener("keydown", n, !0);
@@ -2032,11 +2035,11 @@ function Fa({ editor: e, lang: t = "zh", messages: n = ma, selectionSnapshot: r,
2032
2035
  de,
2033
2036
  e,
2034
2037
  m
2035
- ]), K(() => {
2038
+ ]), G(() => {
2036
2039
  let t = () => {
2037
- let t = Lr(e);
2040
+ let t = Vr(e);
2038
2041
  if (t?.target.kind === "table" && t.status === "target" && m !== "ask-ai") {
2039
- oe.current = t.selection, _("input"), y(""), C(""), T(""), x(""), l((e) => ({
2042
+ se.current = t.selection, _("input"), y(""), C(""), T(""), x(""), l((e) => ({
2040
2043
  ...e,
2041
2044
  visibility: "visible",
2042
2045
  variant: "default",
@@ -2046,7 +2049,7 @@ function Fa({ editor: e, lang: t = "zh", messages: n = ma, selectionSnapshot: r,
2046
2049
  })), h("ask-ai");
2047
2050
  return;
2048
2051
  }
2049
- m === "ask-ai" && t?.status === "conflict" && (R.current?.abort(), H(), _("conflict"));
2052
+ m === "ask-ai" && t?.status === "conflict" && (L.current?.abort(), H(), _("conflict"));
2050
2053
  };
2051
2054
  return e.on("transaction", t), () => {
2052
2055
  e.off("transaction", t);
@@ -2055,33 +2058,33 @@ function Fa({ editor: e, lang: t = "zh", messages: n = ma, selectionSnapshot: r,
2055
2058
  H,
2056
2059
  e,
2057
2060
  m
2058
- ]), K(() => () => {
2059
- R.current?.abort(), H(), Nr(e);
2060
- }, [H, e]), K(() => {
2061
+ ]), G(() => () => {
2062
+ L.current?.abort(), H(), Lr(e);
2063
+ }, [H, e]), G(() => {
2061
2064
  if (m !== "link" && m !== "ask-ai") return;
2062
2065
  let e = window.requestAnimationFrame(() => {
2063
- m === "ask-ai" ? L.current?.focus() : (ae.current?.focus(), ae.current?.select());
2066
+ m === "ask-ai" ? I.current?.focus() : (F.current?.focus(), F.current?.select());
2064
2067
  });
2065
2068
  return () => window.cancelAnimationFrame(e);
2066
- }, [m]), K(() => {
2067
- m !== "ask-ai" || e.isDestroyed || e.view.dispatch(e.state.tr.setMeta(Pa, "show").setMeta("addToHistory", !1));
2069
+ }, [m]), G(() => {
2070
+ m !== "ask-ai" || e.isDestroyed || e.view.dispatch(e.state.tr.setMeta(Ra, "show").setMeta("addToHistory", !1));
2068
2071
  }, [e, m]);
2069
- let _e = (t) => {
2070
- if (Ma(t.id)) {
2072
+ let ye = (t) => {
2073
+ if (Ia(t.id)) {
2071
2074
  let n = t.id;
2072
2075
  if (m === n) {
2073
2076
  n === "ask-ai" ? de(!0) : h(null);
2074
2077
  return;
2075
2078
  }
2076
2079
  if (m === "ask-ai" && de(!1), n === "ask-ai") {
2077
- if (!ce) return;
2078
- let t = Wr(e);
2080
+ if (!le) return;
2081
+ let t = Jr(e);
2079
2082
  if (!t) return;
2080
- oe.current = t, _("input"), C(""), T(""), x("");
2083
+ se.current = t, _("input"), C(""), T(""), x("");
2081
2084
  }
2082
2085
  if (n === "link") {
2083
- let t = pr(e);
2084
- D(t), k(t), j({
2086
+ let t = _r(e);
2087
+ D(t), O(t), A({
2085
2088
  from: Math.min(e.state.selection.from, e.state.selection.to),
2086
2089
  to: Math.max(e.state.selection.from, e.state.selection.to)
2087
2090
  });
@@ -2090,182 +2093,182 @@ function Fa({ editor: e, lang: t = "zh", messages: n = ma, selectionSnapshot: r,
2090
2093
  return;
2091
2094
  }
2092
2095
  if (h(null), t.id === "improve") {
2093
- Na(e, "rewrite-selection", a);
2096
+ La(e, "rewrite-selection", a);
2094
2097
  return;
2095
2098
  }
2096
2099
  t.run(), e.commands.focus();
2097
- }, ve = G(async (r) => {
2098
- if (!ce || i?.enabled !== !0 || !oe.current) return;
2100
+ }, be = W(async (r) => {
2101
+ if (!le || i?.enabled !== !0 || !se.current) return;
2099
2102
  let a = (r ?? v).trim();
2100
2103
  if (!a) {
2101
2104
  T(n.askAi.emptyPrompt), _("error");
2102
2105
  return;
2103
2106
  }
2104
- let o = Fr(e, oe.current);
2107
+ let o = zr(e, se.current);
2105
2108
  if (!o) {
2106
2109
  _("conflict");
2107
2110
  return;
2108
2111
  }
2109
- oe.current = o, R.current?.abort(), H(), Mr(e);
2110
- let s = new AbortController(), c = Pr(o, a, t, s.signal, void 0, Lr(e)?.target);
2111
- R.current = s, z.current = c.id, x(a), T(""), C(""), _("generating");
2112
+ se.current = o, L.current?.abort(), H(), Ir(e);
2113
+ let s = new AbortController(), c = Rr(o, a, t, s.signal, void 0, Vr(e)?.target);
2114
+ L.current = s, R.current = c.id, x(a), T(""), C(""), _("generating");
2112
2115
  try {
2113
- let t = await Vr(i.handler, c, (t) => {
2114
- z.current !== c.id || s.signal.aborted || (se.current = t, B.current === null && (B.current = window.requestAnimationFrame(() => {
2115
- B.current = null, Hr(e, se.current), C(se.current);
2116
+ let t = await Gr(i.handler, c, (t) => {
2117
+ R.current !== c.id || s.signal.aborted || (ce.current = t, z.current === null && (z.current = window.requestAnimationFrame(() => {
2118
+ z.current = null, Kr(e, ce.current), C(ce.current);
2116
2119
  })));
2117
2120
  });
2118
- if (z.current !== c.id || s.signal.aborted) return;
2119
- if (!Hr(e, t)) throw new Or("invalid-output", "Ask AI output is incompatible with the selected content.");
2120
- H(), C(t), y(""), _(Lr(e)?.status === "target" ? "result" : "conflict");
2121
+ if (R.current !== c.id || s.signal.aborted) return;
2122
+ if (!Kr(e, t)) throw new Mr("invalid-output", "Ask AI output is incompatible with the selected content.");
2123
+ H(), C(t), y(""), _(Vr(e)?.status === "target" ? "result" : "conflict");
2121
2124
  } catch (t) {
2122
- if (z.current !== c.id) return;
2125
+ if (R.current !== c.id) return;
2123
2126
  if (H(), s.signal.aborted) {
2124
- Mr(e), _(Lr(e)?.status === "conflict" ? "conflict" : "input");
2127
+ Ir(e), _(Vr(e)?.status === "conflict" ? "conflict" : "input");
2125
2128
  return;
2126
2129
  }
2127
- Mr(e), T(t instanceof Or ? t.code === "empty-result" ? n.askAi.emptyResult : n.askAi.errorFallback : t instanceof Error && t.message ? t.message : n.askAi.errorFallback), _("error");
2130
+ Ir(e), T(t instanceof Mr ? t.code === "empty-result" ? n.askAi.emptyResult : n.askAi.errorFallback : t instanceof Error && t.message ? t.message : n.askAi.errorFallback), _("error");
2128
2131
  }
2129
2132
  }, [
2130
2133
  i,
2131
- ce,
2134
+ le,
2132
2135
  v,
2133
2136
  H,
2134
2137
  e,
2135
2138
  t,
2136
2139
  n
2137
- ]), ye = G(() => {
2138
- if (!kr(e, S)) {
2139
- _(Lr(e)?.status === "conflict" ? "conflict" : "error"), T(n.askAi.errorFallback);
2140
+ ]), xe = W(() => {
2141
+ if (!Nr(e, S)) {
2142
+ _(Vr(e)?.status === "conflict" ? "conflict" : "error"), T(n.askAi.errorFallback);
2140
2143
  return;
2141
2144
  }
2142
- h(null), z.current = null, window.setTimeout(() => Nr(e), 560), e.commands.focus();
2145
+ h(null), R.current = null, window.setTimeout(() => Lr(e), 560), e.commands.focus();
2143
2146
  }, [
2144
2147
  S,
2145
2148
  e,
2146
2149
  n.askAi.errorFallback
2147
- ]), be = () => {
2150
+ ]), Se = () => {
2148
2151
  h(null), e.commands.focus();
2149
- }, xe = () => {
2150
- A && e.commands.setTextSelection(A);
2151
- }, Se = () => {
2152
- xe(), lr(e, E) && be();
2152
+ }, U = () => {
2153
+ k && e.commands.setTextSelection(k);
2153
2154
  }, Ce = () => {
2154
- if (xe(), Cr(e)) {
2155
- D(""), k(""), be();
2155
+ U(), pr(e, E) && Se();
2156
+ }, we = () => {
2157
+ if (U(), Dr(e)) {
2158
+ D(""), O(""), Se();
2156
2159
  return;
2157
2160
  }
2158
2161
  E.trim() && D("");
2159
- }, we = (e, t) => {
2160
- if (d(e), !e || !t || !I.current) {
2162
+ }, Te = (e, t) => {
2163
+ if (d(e), !e || !t || !P.current) {
2161
2164
  p(null);
2162
2165
  return;
2163
2166
  }
2164
- let n = t.getBoundingClientRect(), r = I.current.getBoundingClientRect();
2167
+ let n = t.getBoundingClientRect(), r = P.current.getBoundingClientRect();
2165
2168
  p(n.left + n.width / 2 - r.left);
2166
2169
  };
2167
- return /* @__PURE__ */ Z(cr, {
2168
- ref: F,
2170
+ return /* @__PURE__ */ Z(fr, {
2171
+ ref: N,
2169
2172
  editor: e,
2170
- pluginKey: Pa,
2173
+ pluginKey: Ra,
2171
2174
  className: `markweave-floating-toolbar markweave-floating-toolbar--${c.variant} markweave-floating-toolbar--motion-${c.motionPhase}`,
2172
2175
  "data-motion": c.motionPhase,
2173
- "data-position-strategy": ge.strategy,
2176
+ "data-position-strategy": ve.strategy,
2174
2177
  "data-boundary-padding": c.boundaryPadding,
2175
- "data-popover-placement": m ? ne : void 0,
2178
+ "data-popover-placement": m ? ie : void 0,
2176
2179
  "data-ask-ai-session": m === "ask-ai" ? "open" : "closed",
2177
2180
  "data-testid": "markweave-floating-toolbar",
2178
- style: ga(c, ee),
2181
+ style: ba(c, te),
2179
2182
  updateDelay: 0,
2180
- getReferencedVirtualElement: me,
2181
- options: ge,
2183
+ getReferencedVirtualElement: he,
2184
+ options: ve,
2182
2185
  shouldShow: ({ editor: e }) => {
2183
- let t = Lr(e);
2184
- return Vt(Lt(e), {
2186
+ let t = Vr(e);
2187
+ return Bt(It(e), {
2185
2188
  editable: e.isEditable,
2186
- hasAskAiPreview: zr(e.state),
2189
+ hasAskAiPreview: Ur(e.state),
2187
2190
  hasActiveAskAiTableTarget: t?.target.kind === "table" && t.status === "target"
2188
2191
  });
2189
2192
  },
2190
2193
  children: /* @__PURE__ */ Q("div", {
2191
- ref: I,
2194
+ ref: P,
2192
2195
  className: "markweave-floating-toolbar-content",
2193
2196
  "data-menu": m ?? "none",
2194
2197
  children: [
2195
- V.map((e, t) => /* @__PURE__ */ Z(Ra, {
2198
+ B.map((e, t) => /* @__PURE__ */ Z(Ha, {
2196
2199
  button: e,
2197
2200
  expanded: m === e.id,
2198
- showDivider: t > 0 && V[t - 1].group !== e.group,
2201
+ showDivider: t > 0 && B[t - 1].group !== e.group,
2199
2202
  tooltipActive: u === e.id,
2200
- onPointerDown: Sr,
2201
- onTooltipChange: we,
2202
- onRun: _e
2203
+ onPointerDown: Er,
2204
+ onTooltipChange: Te,
2205
+ onRun: ye
2203
2206
  }, e.id)),
2204
- m === "block-type" ? /* @__PURE__ */ Z(Ba, {
2207
+ m === "block-type" ? /* @__PURE__ */ Z(Wa, {
2205
2208
  editor: e,
2206
2209
  messages: n,
2207
- onPopoverRef: W,
2210
+ onPopoverRef: ge,
2208
2211
  onClose: () => h(null)
2209
2212
  }) : null,
2210
- m === "ask-ai" ? /* @__PURE__ */ Z(La, {
2211
- inputRef: L,
2213
+ m === "ask-ai" ? /* @__PURE__ */ Z(Va, {
2214
+ inputRef: I,
2212
2215
  messages: n,
2213
2216
  phase: g,
2214
2217
  prompt: v,
2215
2218
  hasStreamedContent: !!S,
2216
2219
  error: w,
2217
2220
  onPromptChange: y,
2218
- onSubmit: ve,
2221
+ onSubmit: be,
2219
2222
  onStop: () => {
2220
- R.current?.abort(), H(), Mr(e), _("input");
2223
+ L.current?.abort(), H(), Ir(e), _("input");
2221
2224
  },
2222
- onAccept: ye,
2223
- onRetry: () => ve(b),
2225
+ onAccept: xe,
2226
+ onRetry: () => be(b),
2224
2227
  onDiscard: () => de(!0),
2225
- onPopoverRef: W
2228
+ onPopoverRef: ge
2226
2229
  }) : null,
2227
- m === "link" ? /* @__PURE__ */ Z(Ia, {
2228
- inputRef: ae,
2230
+ m === "link" ? /* @__PURE__ */ Z(Ba, {
2231
+ inputRef: F,
2229
2232
  messages: n,
2230
2233
  value: E,
2231
- canApply: !!ue,
2232
- canOpen: !!ue,
2233
- canRemove: !!(O || E.trim()),
2234
+ canApply: !!V,
2235
+ canOpen: !!V,
2236
+ canRemove: !!(ee || E.trim()),
2234
2237
  onValueChange: D,
2235
- onApply: Se,
2236
- onOpen: () => xr(E),
2237
- onRemove: Ce,
2238
- onPopoverRef: W
2238
+ onApply: Ce,
2239
+ onOpen: () => Tr(E),
2240
+ onRemove: we,
2241
+ onPopoverRef: ge
2239
2242
  }) : null,
2240
- m === "color" ? /* @__PURE__ */ Z(Ha, {
2243
+ m === "color" ? /* @__PURE__ */ Z(Ka, {
2241
2244
  editor: e,
2242
2245
  messages: n,
2243
- onPopoverRef: W,
2246
+ onPopoverRef: ge,
2244
2247
  onClose: () => h(null)
2245
2248
  }) : null,
2246
- m === "more" ? /* @__PURE__ */ Z(Wa, {
2249
+ m === "more" ? /* @__PURE__ */ Z(Ja, {
2247
2250
  editor: e,
2248
2251
  messages: n,
2249
2252
  activeTooltipId: u,
2250
- onPopoverRef: W,
2253
+ onPopoverRef: ge,
2251
2254
  onTooltipChange: d,
2252
2255
  onClose: () => h(null)
2253
2256
  }) : null,
2254
- le && m === null ? /* @__PURE__ */ Z("div", {
2257
+ ue && m === null ? /* @__PURE__ */ Z("div", {
2255
2258
  className: "markweave-floating-toolbar-tooltip",
2256
2259
  role: "tooltip",
2257
2260
  "data-testid": "markweave-floating-toolbar-tooltip",
2258
- "data-button-id": le.buttonId,
2259
- "data-active": le.active,
2260
- style: va(f),
2261
- children: le.label
2261
+ "data-button-id": ue.buttonId,
2262
+ "data-active": ue.active,
2263
+ style: Sa(f),
2264
+ children: ue.label
2262
2265
  }) : null
2263
2266
  ]
2264
2267
  })
2265
2268
  });
2266
2269
  }
2267
- function Ia({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRemove: a, onValueChange: o, onApply: s, onOpen: c, onRemove: l, onPopoverRef: u }) {
2268
- let d = mr(t);
2270
+ function Ba({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRemove: a, onValueChange: o, onApply: s, onOpen: c, onRemove: l, onPopoverRef: u }) {
2271
+ let d = vr(t);
2269
2272
  return /* @__PURE__ */ Q("form", {
2270
2273
  ref: u,
2271
2274
  className: "markweave-floating-toolbar-popover markweave-floating-toolbar-link-popover",
@@ -2288,7 +2291,7 @@ function Ia({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRe
2288
2291
  "aria-label": d.applyLink,
2289
2292
  "data-testid": "markweave-floating-toolbar-link-apply",
2290
2293
  disabled: !r,
2291
- onMouseDown: Sr,
2294
+ onMouseDown: Er,
2292
2295
  children: /* @__PURE__ */ Z($, { name: "corner-down-left" })
2293
2296
  }),
2294
2297
  /* @__PURE__ */ Z("span", {
@@ -2300,7 +2303,7 @@ function Ia({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRe
2300
2303
  "aria-label": d.openLink,
2301
2304
  "data-testid": "markweave-floating-toolbar-link-open",
2302
2305
  disabled: !i,
2303
- onMouseDown: Sr,
2306
+ onMouseDown: Er,
2304
2307
  onClick: c,
2305
2308
  children: /* @__PURE__ */ Z($, { name: "external-link" })
2306
2309
  }),
@@ -2309,7 +2312,7 @@ function Ia({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRe
2309
2312
  "aria-label": d.removeLink,
2310
2313
  "data-testid": "markweave-floating-toolbar-link-remove",
2311
2314
  disabled: !a,
2312
- onMouseDown: Sr,
2315
+ onMouseDown: Er,
2313
2316
  onClick: l,
2314
2317
  children: /* @__PURE__ */ Z($, { name: "trash" })
2315
2318
  })
@@ -2317,7 +2320,7 @@ function Ia({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRe
2317
2320
  })]
2318
2321
  });
2319
2322
  }
2320
- function La({ inputRef: e, messages: t, phase: n, prompt: r, hasStreamedContent: i, error: a, onPromptChange: o, onSubmit: s, onStop: c, onAccept: l, onRetry: u, onDiscard: d, onPopoverRef: f }) {
2323
+ function Va({ inputRef: e, messages: t, phase: n, prompt: r, hasStreamedContent: i, error: a, onPromptChange: o, onSubmit: s, onStop: c, onAccept: l, onRetry: u, onDiscard: d, onPopoverRef: f }) {
2321
2324
  let p = n === "input" || n === "result" || n === "error";
2322
2325
  return /* @__PURE__ */ Q("section", {
2323
2326
  ref: f,
@@ -2345,7 +2348,7 @@ function La({ inputRef: e, messages: t, phase: n, prompt: r, hasStreamedContent:
2345
2348
  className: "markweave-ask-ai-send",
2346
2349
  "aria-label": t.askAi.send,
2347
2350
  disabled: !r.trim(),
2348
- onMouseDown: Sr,
2351
+ onMouseDown: Er,
2349
2352
  onClick: () => s(),
2350
2353
  children: /* @__PURE__ */ Z($, { name: "arrow-up" })
2351
2354
  })]
@@ -2367,7 +2370,7 @@ function La({ inputRef: e, messages: t, phase: n, prompt: r, hasStreamedContent:
2367
2370
  type: "button",
2368
2371
  className: "markweave-ask-ai-stop",
2369
2372
  "aria-label": t.askAi.stop,
2370
- onMouseDown: Sr,
2373
+ onMouseDown: Er,
2371
2374
  onClick: c,
2372
2375
  children: /* @__PURE__ */ Z($, { name: "square" })
2373
2376
  })
@@ -2379,7 +2382,7 @@ function La({ inputRef: e, messages: t, phase: n, prompt: r, hasStreamedContent:
2379
2382
  /* @__PURE__ */ Q("button", {
2380
2383
  type: "button",
2381
2384
  className: "markweave-ask-ai-retry",
2382
- onMouseDown: Sr,
2385
+ onMouseDown: Er,
2383
2386
  onClick: u,
2384
2387
  children: [/* @__PURE__ */ Z($, { name: "rotate-ccw" }), t.askAi.retry]
2385
2388
  }),
@@ -2387,14 +2390,14 @@ function La({ inputRef: e, messages: t, phase: n, prompt: r, hasStreamedContent:
2387
2390
  /* @__PURE__ */ Q("button", {
2388
2391
  type: "button",
2389
2392
  className: "markweave-ask-ai-discard",
2390
- onMouseDown: Sr,
2393
+ onMouseDown: Er,
2391
2394
  onClick: d,
2392
2395
  children: [/* @__PURE__ */ Z($, { name: "x" }), t.askAi.discard]
2393
2396
  }),
2394
2397
  /* @__PURE__ */ Q("button", {
2395
2398
  type: "button",
2396
2399
  className: "markweave-ask-ai-accept",
2397
- onMouseDown: Sr,
2400
+ onMouseDown: Er,
2398
2401
  onClick: l,
2399
2402
  children: [/* @__PURE__ */ Z($, { name: "check" }), t.askAi.accept]
2400
2403
  })
@@ -2409,7 +2412,7 @@ function La({ inputRef: e, messages: t, phase: n, prompt: r, hasStreamedContent:
2409
2412
  n === "error" ? /* @__PURE__ */ Q("button", {
2410
2413
  type: "button",
2411
2414
  className: "markweave-ask-ai-retry",
2412
- onMouseDown: Sr,
2415
+ onMouseDown: Er,
2413
2416
  onClick: u,
2414
2417
  children: [/* @__PURE__ */ Z($, { name: "rotate-ccw" }), t.askAi.retry]
2415
2418
  }) : null,
@@ -2417,7 +2420,7 @@ function La({ inputRef: e, messages: t, phase: n, prompt: r, hasStreamedContent:
2417
2420
  /* @__PURE__ */ Q("button", {
2418
2421
  type: "button",
2419
2422
  className: "markweave-ask-ai-discard",
2420
- onMouseDown: Sr,
2423
+ onMouseDown: Er,
2421
2424
  onClick: d,
2422
2425
  children: [/* @__PURE__ */ Z($, { name: "x" }), t.askAi.discard]
2423
2426
  })
@@ -2427,15 +2430,15 @@ function La({ inputRef: e, messages: t, phase: n, prompt: r, hasStreamedContent:
2427
2430
  ]
2428
2431
  });
2429
2432
  }
2430
- function Ra({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointerDown: i, onTooltipChange: a, onRun: o }) {
2431
- return /* @__PURE__ */ Q(pt, { children: [n ? /* @__PURE__ */ Z("span", {
2433
+ function Ha({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointerDown: i, onTooltipChange: a, onRun: o }) {
2434
+ return /* @__PURE__ */ Q(X, { children: [n ? /* @__PURE__ */ Z("span", {
2432
2435
  className: "markweave-floating-toolbar-divider",
2433
2436
  "aria-hidden": "true"
2434
2437
  }) : null, /* @__PURE__ */ Z("button", {
2435
2438
  type: "button",
2436
2439
  className: `markweave-floating-toolbar-button markweave-floating-toolbar-button--${e.id}`,
2437
2440
  "aria-label": e.label,
2438
- "aria-expanded": Ma(e.id) ? t : void 0,
2441
+ "aria-expanded": Ia(e.id) ? t : void 0,
2439
2442
  "data-active": e.active || t,
2440
2443
  "data-tooltip-active": r ? "true" : "false",
2441
2444
  "data-testid": `markweave-floating-toolbar-button-${e.id}`,
@@ -2445,13 +2448,13 @@ function Ra({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointe
2445
2448
  onMouseEnter: (t) => a(e.id, t.currentTarget),
2446
2449
  onMouseLeave: () => a(null),
2447
2450
  onClick: () => o(e),
2448
- children: /* @__PURE__ */ Z(za, {
2451
+ children: /* @__PURE__ */ Z(Ua, {
2449
2452
  button: e,
2450
2453
  expanded: t
2451
2454
  })
2452
2455
  })] });
2453
2456
  }
2454
- function za({ button: e, expanded: t }) {
2457
+ function Ua({ button: e, expanded: t }) {
2455
2458
  return e.id === "improve" || e.id === "ask-ai" ? /* @__PURE__ */ Q("span", {
2456
2459
  className: "markweave-floating-toolbar-button-inner",
2457
2460
  children: [/* @__PURE__ */ Z($, { name: "sparkles" }), /* @__PURE__ */ Z("span", { children: e.glyph })]
@@ -2469,8 +2472,8 @@ function za({ button: e, expanded: t }) {
2469
2472
  }), /* @__PURE__ */ Z($, { name: t ? "chevron-up" : "chevron-down" })]
2470
2473
  }) : /* @__PURE__ */ Z($, { name: "more" });
2471
2474
  }
2472
- function Ba({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
2473
- let i = mr(t), a = vr(t);
2475
+ function Wa({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
2476
+ let i = vr(t), a = Sr(t);
2474
2477
  return /* @__PURE__ */ Q("div", {
2475
2478
  ref: n,
2476
2479
  className: "markweave-floating-toolbar-popover markweave-floating-toolbar-turn-menu",
@@ -2480,48 +2483,48 @@ function Ba({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
2480
2483
  children: i.turnIntoTitle
2481
2484
  }), a.map((t) => /* @__PURE__ */ Q("button", {
2482
2485
  type: "button",
2483
- "data-active": br(e, t.id),
2486
+ "data-active": wr(e, t.id),
2484
2487
  "data-testid": `markweave-floating-toolbar-turn-${t.id}`,
2485
- onMouseDown: Sr,
2488
+ onMouseDown: Er,
2486
2489
  onClick: () => {
2487
- Dr(e, t.id), r();
2490
+ jr(e, t.id), r();
2488
2491
  },
2489
2492
  children: [/* @__PURE__ */ Z("span", {
2490
2493
  className: "markweave-floating-toolbar-menu-icon",
2491
- children: /* @__PURE__ */ Z(Va, { option: t })
2494
+ children: /* @__PURE__ */ Z(Ga, { option: t })
2492
2495
  }), /* @__PURE__ */ Z("span", { children: t.label })]
2493
2496
  }, t.id))]
2494
2497
  });
2495
2498
  }
2496
- function Va({ option: e }) {
2499
+ function Ga({ option: e }) {
2497
2500
  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 });
2498
2501
  }
2499
- function Ha({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
2500
- let i = mr(t), a = e.getAttributes("textStyle").color, o = e.getAttributes("highlight").color;
2502
+ function Ka({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
2503
+ let i = vr(t), a = e.getAttributes("textStyle").color, o = e.getAttributes("highlight").color;
2501
2504
  return /* @__PURE__ */ Q("div", {
2502
2505
  ref: n,
2503
2506
  className: "markweave-floating-toolbar-popover markweave-floating-toolbar-color-popover",
2504
2507
  "data-testid": "markweave-floating-toolbar-color-menu",
2505
- children: [/* @__PURE__ */ Z(Ua, {
2508
+ children: [/* @__PURE__ */ Z(qa, {
2506
2509
  title: i.textColorTitle,
2507
2510
  mode: "text",
2508
2511
  activeColor: a ?? null,
2509
- options: gr(t),
2512
+ options: br(t),
2510
2513
  onSelect: (t) => {
2511
- Er(e, t), r();
2514
+ Ar(e, t), r();
2512
2515
  }
2513
- }), /* @__PURE__ */ Z(Ua, {
2516
+ }), /* @__PURE__ */ Z(qa, {
2514
2517
  title: i.highlightColorTitle,
2515
2518
  mode: "highlight",
2516
2519
  activeColor: o ?? null,
2517
- options: fr(t),
2520
+ options: gr(t),
2518
2521
  onSelect: (t) => {
2519
- Tr(e, t), r();
2522
+ kr(e, t), r();
2520
2523
  }
2521
2524
  })]
2522
2525
  });
2523
2526
  }
2524
- function Ua({ title: e, mode: t, activeColor: n, options: r, onSelect: i }) {
2527
+ function qa({ title: e, mode: t, activeColor: n, options: r, onSelect: i }) {
2525
2528
  return /* @__PURE__ */ Q("section", {
2526
2529
  className: "markweave-floating-toolbar-color-section",
2527
2530
  "aria-label": e,
@@ -2535,7 +2538,7 @@ function Ua({ title: e, mode: t, activeColor: n, options: r, onSelect: i }) {
2535
2538
  "aria-label": e.label,
2536
2539
  "data-active": e.value === n || e.value === null && !n,
2537
2540
  "data-testid": `markweave-floating-toolbar-${t}-${e.id}`,
2538
- onMouseDown: Sr,
2541
+ onMouseDown: Er,
2539
2542
  onClick: () => i(e.value),
2540
2543
  children: t === "text" ? /* @__PURE__ */ Z("span", {
2541
2544
  className: "markweave-floating-toolbar-text-swatch",
@@ -2550,26 +2553,26 @@ function Ua({ title: e, mode: t, activeColor: n, options: r, onSelect: i }) {
2550
2553
  })]
2551
2554
  });
2552
2555
  }
2553
- function Wa({ editor: e, messages: t, activeTooltipId: n, onPopoverRef: r, onTooltipChange: i, onClose: a }) {
2554
- let o = hr(t);
2556
+ function Ja({ editor: e, messages: t, activeTooltipId: n, onPopoverRef: r, onTooltipChange: i, onClose: a }) {
2557
+ let o = yr(t);
2555
2558
  return /* @__PURE__ */ Z("div", {
2556
2559
  ref: r,
2557
2560
  className: "markweave-floating-toolbar-popover markweave-floating-toolbar-more-menu",
2558
2561
  "data-testid": "markweave-floating-toolbar-more-menu",
2559
- children: o.map((t, r) => /* @__PURE__ */ Z(Ga, {
2562
+ children: o.map((t, r) => /* @__PURE__ */ Z(Ya, {
2560
2563
  action: t,
2561
- active: yr(e, t.id),
2564
+ active: Cr(e, t.id),
2562
2565
  tooltipActive: n === t.id,
2563
2566
  showDivider: r > 0 && o[r - 1].group !== t.group,
2564
2567
  onTooltipChange: i,
2565
2568
  onRun: () => {
2566
- wr(e, t.id), a();
2569
+ Or(e, t.id), a();
2567
2570
  }
2568
2571
  }, t.id))
2569
2572
  });
2570
2573
  }
2571
- function Ga({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipChange: i, onRun: a }) {
2572
- return /* @__PURE__ */ Q(pt, { children: [r ? /* @__PURE__ */ Z("span", {
2574
+ function Ya({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipChange: i, onRun: a }) {
2575
+ return /* @__PURE__ */ Q(X, { children: [r ? /* @__PURE__ */ Z("span", {
2573
2576
  className: "markweave-floating-toolbar-divider",
2574
2577
  "aria-hidden": "true"
2575
2578
  }) : null, /* @__PURE__ */ Q("span", {
@@ -2580,11 +2583,11 @@ function Ga({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipC
2580
2583
  "data-active": t,
2581
2584
  "data-tooltip-active": n ? "true" : "false",
2582
2585
  "data-testid": `markweave-floating-toolbar-more-${e.id}`,
2583
- onMouseDown: Sr,
2586
+ onMouseDown: Er,
2584
2587
  onMouseEnter: () => i(e.id),
2585
2588
  onMouseLeave: () => i(null),
2586
2589
  onClick: a,
2587
- children: /* @__PURE__ */ Z(Ka, { id: e.id })
2590
+ children: /* @__PURE__ */ Z(Xa, { id: e.id })
2588
2591
  }), n ? /* @__PURE__ */ Z("div", {
2589
2592
  className: "markweave-floating-toolbar-tooltip markweave-floating-toolbar-tooltip--more",
2590
2593
  role: "tooltip",
@@ -2592,46 +2595,46 @@ function Ga({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipC
2592
2595
  }) : null]
2593
2596
  })] });
2594
2597
  }
2595
- function Ka({ id: e }) {
2598
+ function Xa({ id: e }) {
2596
2599
  return e === "superscript" ? /* @__PURE__ */ Z($, { name: "superscript" }) : e === "subscript" ? /* @__PURE__ */ Z($, { name: "subscript" }) : e === "inline-math" ? /* @__PURE__ */ Z($, { name: "math" }) : Z($, { name: e });
2597
2600
  }
2598
- var qa = {
2599
- sparkles: Se,
2600
- "arrow-up": x,
2601
- check: A,
2602
- "chevron-down": ee,
2603
- "chevron-up": te,
2604
- "corner-down-left": re,
2605
- "external-link": I,
2606
- bold: D,
2607
- italic: V,
2601
+ var Za = {
2602
+ sparkles: U,
2603
+ "arrow-up": b,
2604
+ check: O,
2605
+ "chevron-down": A,
2606
+ "chevron-up": j,
2607
+ "corner-down-left": ae,
2608
+ "external-link": N,
2609
+ bold: E,
2610
+ italic: le,
2608
2611
  underline: Pe,
2609
2612
  strike: Te,
2610
- "inline-code": ne,
2613
+ "inline-code": re,
2611
2614
  link: ue,
2612
2615
  more: pe,
2613
2616
  text: Ne,
2614
- "bullet-list": H,
2615
- "numbered-list": U,
2616
- "todo-list": de,
2617
- quote: _e,
2618
- "code-block": O,
2617
+ "bullet-list": V,
2618
+ "numbered-list": de,
2619
+ "todo-list": H,
2620
+ quote: ve,
2621
+ "code-block": D,
2619
2622
  superscript: De,
2620
2623
  subscript: Ee,
2621
- math: be,
2622
- "align-left": f,
2623
- "align-center": u,
2624
- "align-right": p,
2625
- "align-justify": d,
2626
- "decrease-indent": B,
2627
- "increase-indent": se,
2624
+ math: xe,
2625
+ "align-left": d,
2626
+ "align-center": l,
2627
+ "align-right": f,
2628
+ "align-justify": u,
2629
+ "decrease-indent": R,
2630
+ "increase-indent": z,
2628
2631
  trash: Me,
2629
- "rotate-ccw": ye,
2632
+ "rotate-ccw": be,
2630
2633
  square: Ce,
2631
2634
  x: Le
2632
2635
  };
2633
2636
  function $({ name: e }) {
2634
- let t = qa[e];
2637
+ let t = Za[e];
2635
2638
  return /* @__PURE__ */ Z(t, {
2636
2639
  "aria-hidden": "true",
2637
2640
  absoluteStrokeWidth: !0,
@@ -2641,24 +2644,24 @@ function $({ name: e }) {
2641
2644
  }
2642
2645
  //#endregion
2643
2646
  //#region src/ui/math/MathEditorPopover.tsx
2644
- function Ja({ editor: e, messages: t, onClose: n, target: r }) {
2645
- let i = J(null), a = J(null), [o, s] = Y(r.latex), [c, l] = Y(null), u = t.math, d = q(() => on(e, r) ?? 1, [e, r]), f = q(() => sn(e, r), [e, r]), p = q(() => o === r.latex && f ? {
2647
+ function Qa({ editor: e, messages: t, onClose: n, target: r }) {
2648
+ let i = q(null), a = q(null), [o, s] = J(r.latex), [c, l] = J(null), u = t.math, d = K(() => an(e, r) ?? 1, [e, r]), f = K(() => on(e, r), [e, r]), p = K(() => o === r.latex && f ? {
2646
2649
  html: f,
2647
2650
  error: !1
2648
- } : dn(o, r.kind, e), [
2651
+ } : un(o, r.kind, e), [
2649
2652
  e,
2650
2653
  f,
2651
2654
  r.kind,
2652
2655
  r.latex,
2653
2656
  o
2654
- ]), m = o.trim().length > 0, h = G(() => {
2657
+ ]), m = o.trim().length > 0, h = W(() => {
2655
2658
  if (typeof window > "u") return;
2656
- let t = an(e, r), i = e.view.dom.closest(".markweave-editor-frame")?.getBoundingClientRect();
2659
+ let t = rn(e, r), i = e.view.dom.closest(".markweave-editor-frame")?.getBoundingClientRect();
2657
2660
  if (!t || !i) {
2658
2661
  n();
2659
2662
  return;
2660
2663
  }
2661
- l(rn({
2664
+ l(nn({
2662
2665
  anchorRect: t,
2663
2666
  frameRect: i,
2664
2667
  kind: r.kind,
@@ -2672,30 +2675,30 @@ function Ja({ editor: e, messages: t, onClose: n, target: r }) {
2672
2675
  r,
2673
2676
  o
2674
2677
  ]);
2675
- K(() => {
2678
+ G(() => {
2676
2679
  s(r.latex);
2677
- }, [r.latex, r.pos]), K(() => {
2678
- fn(e, r, !0), h();
2680
+ }, [r.latex, r.pos]), G(() => {
2681
+ dn(e, r, !0), h();
2679
2682
  let t = window.requestAnimationFrame(() => {
2680
2683
  a.current?.focus({ preventScroll: !0 }), a.current?.select(), h();
2681
2684
  });
2682
2685
  return window.addEventListener("resize", h), window.addEventListener("scroll", h, !0), () => {
2683
- window.cancelAnimationFrame(t), window.removeEventListener("resize", h), window.removeEventListener("scroll", h, !0), fn(e, r, !1);
2686
+ window.cancelAnimationFrame(t), window.removeEventListener("resize", h), window.removeEventListener("scroll", h, !0), dn(e, r, !1);
2684
2687
  };
2685
2688
  }, [
2686
2689
  e,
2687
2690
  n,
2688
2691
  r,
2689
2692
  h
2690
- ]), K(() => {
2693
+ ]), G(() => {
2691
2694
  let e = (e) => {
2692
2695
  let t = e.target;
2693
2696
  t instanceof Node && (i.current?.contains(t) || t instanceof Element && t.closest(".tiptap-mathematics-render") || n());
2694
2697
  };
2695
2698
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
2696
2699
  }, [n]);
2697
- let g = G(() => {
2698
- m && nn(e, r, o) && n();
2700
+ let g = W(() => {
2701
+ m && tn(e, r, o) && n();
2699
2702
  }, [
2700
2703
  m,
2701
2704
  e,
@@ -2770,7 +2773,7 @@ function Ja({ editor: e, messages: t, onClose: n, target: r }) {
2770
2773
  className: "markweave-math-block-toolbar",
2771
2774
  children: [
2772
2775
  /* @__PURE__ */ Z("span", { children: u.label }),
2773
- /* @__PURE__ */ Z(ne, {
2776
+ /* @__PURE__ */ Z(re, {
2774
2777
  "aria-hidden": "true",
2775
2778
  size: 15,
2776
2779
  strokeWidth: 1.75
@@ -2781,7 +2784,7 @@ function Ja({ editor: e, messages: t, onClose: n, target: r }) {
2781
2784
  disabled: !m,
2782
2785
  title: u.apply,
2783
2786
  type: "submit",
2784
- children: /* @__PURE__ */ Z(A, {
2787
+ children: /* @__PURE__ */ Z(O, {
2785
2788
  "aria-hidden": "true",
2786
2789
  size: 16,
2787
2790
  strokeWidth: 2
@@ -2826,31 +2829,39 @@ function Ja({ editor: e, messages: t, onClose: n, target: r }) {
2826
2829
  }
2827
2830
  //#endregion
2828
2831
  //#region src/ui/slash-command/SlashCommandMenu.tsx
2829
- var Ya = n("zh"), Xa = {
2832
+ var $a = t("zh"), eo = {
2830
2833
  type: je,
2831
- "heading-1": ae,
2832
- "heading-2": L,
2833
- "heading-3": oe,
2834
- "bullet-list": H,
2835
- "ordered-list": U,
2836
- "task-list": de,
2837
- blockquote: _e,
2838
- "code-block": O,
2834
+ "heading-1": oe,
2835
+ "heading-2": F,
2836
+ "heading-3": I,
2837
+ "bullet-list": V,
2838
+ "ordered-list": de,
2839
+ "task-list": H,
2840
+ blockquote: ve,
2841
+ "code-block": D,
2839
2842
  info: ce,
2840
- tip: le,
2841
- warning: l,
2842
- error: N,
2843
- success: j,
2844
- emoji: xe,
2845
- math: be,
2843
+ tip: B,
2844
+ warning: c,
2845
+ error: ne,
2846
+ success: k,
2847
+ emoji: Se,
2848
+ math: xe,
2846
2849
  table: Oe,
2847
2850
  separator: fe,
2848
- image: R,
2851
+ image: se,
2849
2852
  video: Ie,
2850
- attachment: W
2853
+ attachment: he
2851
2854
  };
2852
- function Za({ name: e }) {
2853
- let t = Xa[e];
2855
+ function to({ name: e }) {
2856
+ if (typeof e != "string") {
2857
+ if (e.kind === "text") return /* @__PURE__ */ Z("span", {
2858
+ className: "markweave-slash-command-text-icon",
2859
+ "aria-hidden": "true",
2860
+ children: e.text
2861
+ });
2862
+ e = e.name;
2863
+ }
2864
+ let t = eo[e];
2854
2865
  return /* @__PURE__ */ Z(t, {
2855
2866
  "aria-hidden": "true",
2856
2867
  absoluteStrokeWidth: !0,
@@ -2858,7 +2869,7 @@ function Za({ name: e }) {
2858
2869
  strokeWidth: 1.6
2859
2870
  });
2860
2871
  }
2861
- function Qa(e, t, n) {
2872
+ function no(e, t, n) {
2862
2873
  return !vn(e) || !n ? {
2863
2874
  visible: !1,
2864
2875
  empty: !1,
@@ -2873,17 +2884,22 @@ function Qa(e, t, n) {
2873
2884
  activeIndex: Math.min(t.length - 1, Math.max(0, e.activeIndex))
2874
2885
  };
2875
2886
  }
2876
- function $a(e, t) {
2877
- return Object.values(t.slash.groups).map((t) => ({
2878
- group: t,
2879
- commands: e.filter((e) => e.group === t)
2880
- })).filter((e) => e.commands.length > 0);
2887
+ function ro(e, t) {
2888
+ let n = /* @__PURE__ */ new Map();
2889
+ for (let t of e) {
2890
+ let e = n.get(t.group) ?? [];
2891
+ e.push(t), n.set(t.group, e);
2892
+ }
2893
+ return [...n].map(([e, t]) => ({
2894
+ group: e,
2895
+ commands: t
2896
+ }));
2881
2897
  }
2882
- function eo(e, t) {
2898
+ function io(e, t) {
2883
2899
  return t.slash.uploadKindLabels[e] ?? t.slash.uploadKindLabels.upload;
2884
2900
  }
2885
- function to({ command: e, messages: t, onBack: n, onSelect: r }) {
2886
- let [i, a] = Y(""), [o, s] = Y(0), c = q(() => {
2901
+ function ao({ command: e, messages: t, onBack: n, onSelect: r }) {
2902
+ let [i, a] = J(""), [o, s] = J(0), c = K(() => {
2887
2903
  let e = i.trim().toLowerCase();
2888
2904
  return (e ? t.slash.emojiItems.filter((t) => [
2889
2905
  t.emoji,
@@ -2949,8 +2965,8 @@ function to({ command: e, messages: t, onBack: n, onSelect: r }) {
2949
2965
  ]
2950
2966
  });
2951
2967
  }
2952
- function no({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
2953
- let a = e.uploadKind ?? "attachment", [o, s] = Y(""), [c, l] = Y(null), [u, d] = Y(null), [f, p] = Y(!1), m = async (t) => {
2968
+ function oo({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
2969
+ let a = e.uploadKind ?? "attachment", [o, s] = J(""), [c, l] = J(null), [u, d] = J(null), [f, p] = J(!1), m = async (t) => {
2954
2970
  r(e, { uploadResult: await ft({
2955
2971
  kind: a,
2956
2972
  source: t,
@@ -2989,7 +3005,7 @@ function no({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
2989
3005
  onMouseDown: (e) => e.preventDefault(),
2990
3006
  onClick: n,
2991
3007
  children: t.common.back
2992
- }), /* @__PURE__ */ Z("span", { children: eo(a, t) })]
3008
+ }), /* @__PURE__ */ Z("span", { children: io(a, t) })]
2993
3009
  }),
2994
3010
  /* @__PURE__ */ Q("label", {
2995
3011
  className: "markweave-slash-upload-field",
@@ -3037,187 +3053,200 @@ function no({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
3037
3053
  ]
3038
3054
  });
3039
3055
  }
3040
- function ro({ commands: e, messages: t = Ya, state: n, position: r, inputCommand: i, onActiveIndexChange: a, onInputCommandChange: o, onSelect: s, onUpload: c }) {
3041
- let l = Qa(n, e, r), u = J(null);
3056
+ function so({ commands: e, messages: t = $a, state: n, position: r, inputCommand: i, onActiveIndexChange: a, onInputCommandChange: o, onSelect: s, onUpload: c, busy: l = !1, error: u = null }) {
3057
+ let d = no(n, e, r), f = q(null);
3042
3058
  if (Re(() => {
3043
- if (!l.visible || l.empty || n.name !== "keyboard-selecting") return;
3044
- let e = u.current, t = e?.querySelector("[data-active=\"true\"]");
3045
- e && t && Kr(e, t);
3059
+ if (!d.visible || d.empty || n.name !== "keyboard-selecting") return;
3060
+ let e = f.current, t = e?.querySelector("[data-active=\"true\"]");
3061
+ e && t && Xr(e, t);
3046
3062
  }, [
3047
3063
  e,
3048
- l.activeIndex,
3049
- l.empty,
3050
- l.visible,
3064
+ d.activeIndex,
3065
+ d.empty,
3066
+ d.visible,
3051
3067
  n.name
3052
- ]), !l.visible || !r) return null;
3053
- let d = $a(e, t), f = {
3068
+ ]), !d.visible || !r) return null;
3069
+ let p = ro(e, t), m = {
3054
3070
  left: r.left,
3055
3071
  top: r.top,
3056
3072
  maxHeight: r.maxHeight,
3057
3073
  "--markweave-slash-menu-max-height": `${r.maxHeight}px`
3058
- }, p = {
3074
+ }, h = {
3059
3075
  left: r.triggerLeft,
3060
3076
  top: r.triggerTop
3061
- }, m = (e) => o?.(e), h = () => o?.(null);
3062
- return /* @__PURE__ */ Q(pt, { children: [/* @__PURE__ */ Q("div", {
3063
- className: "markweave-slash-trigger",
3064
- style: p,
3065
- "aria-hidden": "true",
3066
- "data-testid": "markweave-slash-trigger",
3067
- children: [/* @__PURE__ */ Z("span", { children: "/" }), /* @__PURE__ */ Z("em", { children: n.query ? n.query : t.slash.filterPlaceholder })]
3068
- }), /* @__PURE__ */ Z("div", {
3069
- className: "markweave-slash-menu",
3070
- style: f,
3071
- role: "listbox",
3072
- "aria-label": t.slash.ariaLabel,
3073
- "data-placement": r.placement,
3074
- "data-testid": "markweave-slash-menu",
3075
- children: i?.inputKind === "emoji" ? /* @__PURE__ */ Z(to, {
3076
- command: i,
3077
- messages: t,
3078
- onBack: h,
3079
- onSelect: s
3080
- }) : i?.inputKind === "upload" ? /* @__PURE__ */ Z(no, {
3081
- command: i,
3082
- messages: t,
3083
- onBack: h,
3084
- onSelect: s,
3085
- onUpload: c
3086
- }) : l.empty ? /* @__PURE__ */ Z("div", {
3087
- className: "markweave-slash-menu__empty",
3088
- role: "option",
3089
- "aria-disabled": "true",
3090
- children: t.slash.noResults
3091
- }) : /* @__PURE__ */ Z("div", {
3092
- className: "markweave-slash-command-list",
3093
- ref: u,
3094
- children: d.map((t) => /* @__PURE__ */ Q("section", {
3095
- className: "markweave-slash-group",
3096
- "aria-label": t.group,
3097
- children: [/* @__PURE__ */ Z("div", {
3098
- className: "markweave-slash-group-title",
3099
- children: t.group
3100
- }), t.commands.map((t) => {
3101
- let n = e.indexOf(t), r = n === l.activeIndex, i = gn(t), o = !!t.disabled;
3102
- return /* @__PURE__ */ Q("button", {
3103
- type: "button",
3104
- role: "option",
3105
- "aria-selected": r,
3106
- "aria-disabled": !i || o,
3107
- "data-active": r,
3108
- "data-disabled": o ? "true" : "false",
3109
- "data-execution-kind": t.executionKind,
3110
- "data-testid": `markweave-slash-command-${t.id}`,
3111
- title: o ? t.disabledReason : void 0,
3112
- onFocus: () => a?.(n),
3113
- onMouseEnter: () => a?.(n),
3114
- onMouseDown: (e) => e.preventDefault(),
3115
- onClick: () => {
3116
- if (!(!i || o)) {
3117
- if (t.inputKind) {
3118
- m(t);
3119
- return;
3077
+ }, g = (e) => o?.(e), _ = () => o?.(null);
3078
+ return /* @__PURE__ */ Q(X, { children: [
3079
+ /* @__PURE__ */ Q("div", {
3080
+ className: "markweave-slash-trigger",
3081
+ style: h,
3082
+ "aria-hidden": "true",
3083
+ "data-testid": "markweave-slash-trigger",
3084
+ children: [/* @__PURE__ */ Z("span", { children: "/" }), /* @__PURE__ */ Z("em", { children: n.query ? n.query : t.slash.filterPlaceholder })]
3085
+ }),
3086
+ /* @__PURE__ */ Z("div", {
3087
+ id: "markweave-slash-command-listbox",
3088
+ className: "markweave-slash-menu",
3089
+ style: m,
3090
+ role: "listbox",
3091
+ "aria-label": t.slash.ariaLabel,
3092
+ "aria-busy": l,
3093
+ "data-placement": r.placement,
3094
+ "data-testid": "markweave-slash-menu",
3095
+ children: i?.inputKind === "emoji" ? /* @__PURE__ */ Z(ao, {
3096
+ command: i,
3097
+ messages: t,
3098
+ onBack: _,
3099
+ onSelect: s
3100
+ }) : i?.inputKind === "upload" ? /* @__PURE__ */ Z(oo, {
3101
+ command: i,
3102
+ messages: t,
3103
+ onBack: _,
3104
+ onSelect: s,
3105
+ onUpload: c
3106
+ }) : d.empty ? /* @__PURE__ */ Z("div", {
3107
+ className: "markweave-slash-menu__empty",
3108
+ role: "option",
3109
+ "aria-disabled": "true",
3110
+ children: t.slash.noResults
3111
+ }) : /* @__PURE__ */ Z("div", {
3112
+ className: "markweave-slash-command-list",
3113
+ ref: f,
3114
+ children: p.map((t) => /* @__PURE__ */ Q("section", {
3115
+ className: "markweave-slash-group",
3116
+ "aria-label": t.group,
3117
+ children: [/* @__PURE__ */ Z("div", {
3118
+ className: "markweave-slash-group-title",
3119
+ children: t.group
3120
+ }), t.commands.map((t) => {
3121
+ let n = e.indexOf(t), r = n === d.activeIndex, i = gn(t), o = !!t.disabled;
3122
+ return /* @__PURE__ */ Q("button", {
3123
+ id: `markweave-slash-command-option-${n}`,
3124
+ type: "button",
3125
+ role: "option",
3126
+ "aria-selected": r,
3127
+ "aria-disabled": !i || o,
3128
+ "data-active": r,
3129
+ "data-disabled": o ? "true" : "false",
3130
+ "data-execution-kind": t.executionKind,
3131
+ "data-testid": `markweave-slash-command-${t.id}`,
3132
+ title: o ? t.disabledReason : void 0,
3133
+ onFocus: () => a?.(n),
3134
+ onMouseEnter: () => a?.(n),
3135
+ onMouseDown: (e) => e.preventDefault(),
3136
+ onClick: () => {
3137
+ if (!(!i || o)) {
3138
+ if (t.inputKind) {
3139
+ g(t);
3140
+ return;
3141
+ }
3142
+ s(t);
3120
3143
  }
3121
- s(t);
3122
- }
3123
- },
3124
- children: [
3125
- /* @__PURE__ */ Z(Za, { name: t.icon }),
3126
- /* @__PURE__ */ Z("span", { children: t.label }),
3127
- o && t.disabledReason ? /* @__PURE__ */ Z("small", { children: t.disabledReason }) : null
3128
- ]
3129
- }, t.id);
3130
- })]
3131
- }, t.group))
3144
+ },
3145
+ children: [
3146
+ /* @__PURE__ */ Z(to, { name: t.icon }),
3147
+ /* @__PURE__ */ Z("span", { children: t.label }),
3148
+ o && t.disabledReason ? /* @__PURE__ */ Z("small", { children: t.disabledReason }) : null
3149
+ ]
3150
+ }, t.id);
3151
+ })]
3152
+ }, t.group))
3153
+ })
3154
+ }),
3155
+ /* @__PURE__ */ Z("div", {
3156
+ className: "markweave-slash-command-live-region",
3157
+ role: "status",
3158
+ "aria-live": "polite",
3159
+ "aria-atomic": "true",
3160
+ children: u ?? ""
3132
3161
  })
3133
- })] });
3162
+ ] });
3134
3163
  }
3135
3164
  //#endregion
3136
3165
  //#region src/ui/table/TableControls.tsx
3137
- var io = n("zh"), ao = {
3138
- "move-left": y,
3139
- "move-right": b,
3140
- "move-up": x,
3141
- "move-down": _,
3142
- "insert-left": E,
3143
- "insert-right": T,
3144
- "insert-above": w,
3145
- "insert-below": C,
3146
- "sort-asc": v,
3147
- "sort-desc": S,
3166
+ var co = t("zh"), lo = {
3167
+ "move-left": v,
3168
+ "move-right": y,
3169
+ "move-up": b,
3170
+ "move-down": g,
3171
+ "insert-left": T,
3172
+ "insert-right": w,
3173
+ "insert-above": C,
3174
+ "insert-below": S,
3175
+ "sort-asc": _,
3176
+ "sort-desc": x,
3148
3177
  color: me,
3149
- alignment: f,
3178
+ alignment: d,
3150
3179
  clear: we,
3151
- duplicate: P,
3152
- copy: P,
3180
+ duplicate: ie,
3181
+ copy: ie,
3153
3182
  merge: ke,
3154
3183
  split: Ae,
3155
- "ask-ai": Se,
3184
+ "ask-ai": U,
3156
3185
  delete: Me
3157
- }, oo = {
3158
- left: f,
3159
- center: u,
3160
- right: p,
3161
- top: g,
3162
- middle: m,
3163
- bottom: h
3186
+ }, uo = {
3187
+ left: d,
3188
+ center: l,
3189
+ right: f,
3190
+ top: h,
3191
+ middle: p,
3192
+ bottom: m
3164
3193
  };
3165
- function so({ active: e, editor: t, interactionState: n = Mn, messages: r = io, onCopyPayload: i, onCommandResult: a, askAi: o }) {
3166
- let [s, c] = Y(null), [l, u] = Y(null), [d, f] = Y("row-edge"), [p, m] = Y(null), [h, g] = Y(null), [_, v] = Y(null), [y, b] = Y(null), [x, S] = Y(null), [C, w] = Y(null), [T, E] = Y(null), [, D] = Y(0), O = J(null), k = J(null), [A, j] = Y(null), ee = J(null), te = J(null), N = J(null), ne = J(null), P = J(null), re = J(null), F = J(null), I = e ? An(t.state) : null;
3167
- if (K(() => {
3168
- if (!A) return;
3194
+ function fo({ active: e, editor: t, interactionState: n = In, messages: r = co, onCopyPayload: i, onCommandResult: a, askAi: o }) {
3195
+ let [s, c] = J(null), [l, u] = J(null), [d, f] = J("row-edge"), [p, m] = J(null), [h, g] = J(null), [_, v] = J(null), [y, b] = J(null), [x, S] = J(null), [C, w] = J(null), [T, E] = J(null), [, D] = J(0), ee = q(null), O = q(null), [k, A] = J(null), j = q(null), ne = q(null), re = q(null), ie = q(null), ae = q(null), M = q(null), N = q(null), P = e ? Pn(t.state) : null;
3196
+ if (G(() => {
3197
+ if (!k) return;
3169
3198
  let e = window.setTimeout(() => {
3170
- j(null);
3171
- }, vi);
3199
+ A(null);
3200
+ }, Si);
3172
3201
  return () => {
3173
3202
  window.clearTimeout(e);
3174
3203
  };
3175
- }, [A]), K(() => {
3204
+ }, [k]), G(() => {
3176
3205
  let e = (e) => {
3177
- let n = O.current;
3206
+ let n = ee.current;
3178
3207
  if (!n) return;
3179
- let r = ai(t, n.axis, e.clientX, e.clientY);
3180
- r !== null && (e.preventDefault(), k.current = r, e.dataTransfer && (e.dataTransfer.dropEffect = "move"));
3208
+ let r = li(t, n.axis, e.clientX, e.clientY);
3209
+ r !== null && (e.preventDefault(), O.current = r, e.dataTransfer && (e.dataTransfer.dropEffect = "move"));
3181
3210
  }, n = (e) => {
3182
- let n = O.current;
3211
+ let n = ee.current;
3183
3212
  if (!n) return;
3184
- let r = ai(t, n.axis, e.clientX, e.clientY) ?? k.current;
3185
- e.preventDefault(), O.current = null, k.current = null, r !== null && hi(t, n.axis, n.index, r);
3213
+ let r = li(t, n.axis, e.clientX, e.clientY) ?? O.current;
3214
+ e.preventDefault(), ee.current = null, O.current = null, r !== null && yi(t, n.axis, n.index, r);
3186
3215
  };
3187
3216
  return document.addEventListener("dragover", e), document.addEventListener("drop", n), () => {
3188
3217
  document.removeEventListener("dragover", e), document.removeEventListener("drop", n);
3189
3218
  };
3190
3219
  }, [t]), Re(() => {
3191
3220
  if (!e) {
3192
- v(null), b(null), S(null), w(null), E(null), j(null);
3221
+ v(null), b(null), S(null), w(null), E(null), A(null);
3193
3222
  return;
3194
3223
  }
3195
3224
  let r = () => {
3196
- let e = t.view.dom.closest(".markweave-editor-frame") ?? t.view.dom.parentElement, r = ci(t, n, "row", I?.activeCellPos ?? null), i = ci(t, n, "column", I?.activeCellPos ?? null), a = r ? si(t, r) : null, o = i ? si(t, i) : null, c = fi(t, "selection").length > 0 ? pi(t) : null, l = ii(t)?.getBoundingClientRect() ?? null;
3225
+ let e = t.view.dom.closest(".markweave-editor-frame") ?? t.view.dom.parentElement, r = fi(t, n, "row", P?.activeCellPos ?? null), i = fi(t, n, "column", P?.activeCellPos ?? null), a = r ? di(t, r) : null, o = i ? di(t, i) : null, c = gi(t, "selection").length > 0 ? _i(t) : null, l = ci(t)?.getBoundingClientRect() ?? null;
3197
3226
  if (!e) {
3198
3227
  v(null), b(null), S(null), w(null), E(null);
3199
3228
  return;
3200
3229
  }
3201
3230
  let u = e.getBoundingClientRect();
3202
- a ? v($r({
3231
+ a ? v(ri({
3203
3232
  targetRect: a,
3204
3233
  frameRect: u,
3205
3234
  kind: "row"
3206
- })) : s === "row" && d === "row-edge" || v(null), o ? b($r({
3235
+ })) : s === "row" && d === "row-edge" || v(null), o ? b(ri({
3207
3236
  targetRect: o,
3208
3237
  frameRect: u,
3209
3238
  kind: "column"
3210
- })) : s === "column" && d === "column-edge" || b(null), c ? S($r({
3239
+ })) : s === "column" && d === "column-edge" || b(null), c ? S(ri({
3211
3240
  targetRect: c,
3212
3241
  frameRect: u,
3213
3242
  kind: "selection"
3214
3243
  })) : s === "selection" && d === "selection-edge" || S(null);
3215
3244
  let f = n.hoverCellPos !== null && !!(r && r.index === r.visualHeight - 1), p = n.hoverCellPos !== null && !!(i && i.index === i.visualWidth - 1);
3216
- w(l && f ? ei({
3245
+ w(l && f ? ii({
3217
3246
  tableRect: l,
3218
3247
  frameRect: u,
3219
3248
  kind: "row"
3220
- }) : null), E(l && p ? ei({
3249
+ }) : null), E(l && p ? ii({
3221
3250
  tableRect: l,
3222
3251
  frameRect: u,
3223
3252
  kind: "column"
@@ -3229,9 +3258,9 @@ function so({ active: e, editor: t, interactionState: n = Mn, messages: r = io,
3229
3258
  }, [
3230
3259
  e,
3231
3260
  t,
3232
- I?.activeCellPos,
3233
- I?.selectionFrom,
3234
- I?.selectionTo,
3261
+ P?.activeCellPos,
3262
+ P?.selectionFrom,
3263
+ P?.selectionTo,
3235
3264
  n.hoverCellPos,
3236
3265
  n.hoverVisualColumnIndex,
3237
3266
  n.hoverVisualRowIndex,
@@ -3243,20 +3272,20 @@ function so({ active: e, editor: t, interactionState: n = Mn, messages: r = io,
3243
3272
  return;
3244
3273
  }
3245
3274
  let n = () => {
3246
- let e = t.view.dom.closest(".markweave-editor-frame") ?? t.view.dom.parentElement, n = d === "row-edge" ? P.current : d === "column-edge" ? re.current : F.current, r = te.current;
3275
+ let e = t.view.dom.closest(".markweave-editor-frame") ?? t.view.dom.parentElement, n = d === "row-edge" ? ae.current : d === "column-edge" ? M.current : N.current, r = ne.current;
3247
3276
  if (!e || !n || !r) {
3248
3277
  m(null);
3249
3278
  return;
3250
3279
  }
3251
- let i = n.getBoundingClientRect(), a = s === "row" ? ii(t)?.getBoundingClientRect() : null, o = a ? {
3280
+ let i = n.getBoundingClientRect(), a = s === "row" ? ci(t)?.getBoundingClientRect() : null, o = a ? {
3252
3281
  left: i.left,
3253
3282
  top: a.top,
3254
3283
  width: i.width,
3255
3284
  height: i.height
3256
- } : i, c = e.getBoundingClientRect(), l = r.getBoundingClientRect(), u = N.current?.scrollHeight ?? 0, f = u > 0 ? u + 12 : 0, p = Zr({
3285
+ } : i, c = e.getBoundingClientRect(), l = r.getBoundingClientRect(), u = re.current?.scrollHeight ?? 0, f = u > 0 ? u + 12 : 0, p = ti({
3257
3286
  anchorRect: o,
3258
3287
  frameRect: c,
3259
- boundaryRect: li(e),
3288
+ boundaryRect: pi(e),
3260
3289
  menuSize: {
3261
3290
  width: l.width || 254,
3262
3291
  height: f || l.height || 410
@@ -3282,16 +3311,16 @@ function so({ active: e, editor: t, interactionState: n = Mn, messages: r = io,
3282
3311
  return;
3283
3312
  }
3284
3313
  let n = () => {
3285
- let e = t.view.dom.closest(".markweave-editor-frame") ?? t.view.dom.parentElement, n = te.current, r = ne.current, i = n?.querySelector(`[data-submenu-trigger="${l}"]`);
3314
+ let e = t.view.dom.closest(".markweave-editor-frame") ?? t.view.dom.parentElement, n = ne.current, r = ie.current, i = n?.querySelector(`[data-submenu-trigger="${l}"]`);
3286
3315
  if (!e || !n || !r || !i) {
3287
3316
  g(null);
3288
3317
  return;
3289
3318
  }
3290
3319
  let a = r.getBoundingClientRect(), o = Math.max(r.scrollHeight + 2, a.height);
3291
- g(Qr({
3320
+ g(ni({
3292
3321
  triggerRect: i.getBoundingClientRect(),
3293
3322
  parentMenuRect: n.getBoundingClientRect(),
3294
- boundaryRect: li(e),
3323
+ boundaryRect: pi(e),
3295
3324
  submenuSize: {
3296
3325
  width: a.width || 238,
3297
3326
  height: o || 410
@@ -3299,7 +3328,7 @@ function so({ active: e, editor: t, interactionState: n = Mn, messages: r = io,
3299
3328
  }));
3300
3329
  };
3301
3330
  n();
3302
- let r = N.current;
3331
+ let r = re.current;
3303
3332
  return r?.addEventListener("scroll", n), window.addEventListener("resize", n), window.addEventListener("scroll", n, !0), () => {
3304
3333
  r?.removeEventListener("scroll", n), window.removeEventListener("resize", n), window.removeEventListener("scroll", n, !0);
3305
3334
  };
@@ -3309,7 +3338,7 @@ function so({ active: e, editor: t, interactionState: n = Mn, messages: r = io,
3309
3338
  p,
3310
3339
  s,
3311
3340
  l
3312
- ]), K(() => {
3341
+ ]), G(() => {
3313
3342
  if (!e || !s) return;
3314
3343
  let n = (e) => {
3315
3344
  if (e.key === "Escape") {
@@ -3320,7 +3349,7 @@ function so({ active: e, editor: t, interactionState: n = Mn, messages: r = io,
3320
3349
  c(null), u(null), t.view.focus();
3321
3350
  }
3322
3351
  }, r = (e) => {
3323
- e.target instanceof Node && ee.current?.contains(e.target) || (c(null), u(null));
3352
+ e.target instanceof Node && j.current?.contains(e.target) || (c(null), u(null));
3324
3353
  };
3325
3354
  return document.addEventListener("keydown", n), document.addEventListener("mousedown", r), () => {
3326
3355
  document.removeEventListener("keydown", n), document.removeEventListener("mousedown", r);
@@ -3331,78 +3360,78 @@ function so({ active: e, editor: t, interactionState: n = Mn, messages: r = io,
3331
3360
  s,
3332
3361
  l
3333
3362
  ]), !e) return null;
3334
- let ie = (e, t) => {
3363
+ let oe = (e, t) => {
3335
3364
  let n = s === e && d === t;
3336
3365
  f(t), c(n ? null : e), u(null);
3337
- }, ae = () => {
3338
- t.view.dispatch(qr(t.state.tr, null));
3339
- }, L = (e, r) => {
3340
- let i = n.hoverCellPos ?? I?.activeCellPos ?? null, a = n.hoverCellPos === null ? null : e === "row" ? n.hoverVisualRowIndex : n.hoverVisualColumnIndex;
3341
- i !== null && gi(t, i, e, { visualIndex: a }), ie(e, r);
3342
- }, oe = () => {
3343
- ae(), ie("selection", "selection-edge");
3344
- }, R = ci(t, n, "row", I?.activeCellPos ?? null), z = ci(t, n, "column", I?.activeCellPos ?? null), B = o?.enabled === !0 && typeof o.handler == "function", se = fi(t, "selection", { askAiEnabled: B }).length > 0, ce = s ? fi(t, s, { askAiEnabled: B }) : [], V = async (e, n) => {
3345
- let o = await ni({
3366
+ }, F = () => {
3367
+ t.view.dispatch(Zr(t.state.tr, null));
3368
+ }, I = (e, r) => {
3369
+ let i = n.hoverCellPos ?? P?.activeCellPos ?? null, a = n.hoverCellPos === null ? null : e === "row" ? n.hoverVisualRowIndex : n.hoverVisualColumnIndex;
3370
+ i !== null && bi(t, i, e, { visualIndex: a }), oe(e, r);
3371
+ }, se = () => {
3372
+ F(), oe("selection", "selection-edge");
3373
+ }, L = fi(t, n, "row", P?.activeCellPos ?? null), R = fi(t, n, "column", P?.activeCellPos ?? null), z = o?.enabled === !0 && typeof o.handler == "function", ce = gi(t, "selection", { askAiEnabled: z }).length > 0, le = s ? gi(t, s, { askAiEnabled: z }) : [], B = async (e, n) => {
3374
+ let o = await oi({
3346
3375
  editor: t,
3347
3376
  commandId: e,
3348
3377
  menu: n ?? s ?? "selection",
3349
3378
  messages: r
3350
3379
  });
3351
- return o.copyFeedback ? (j(o.copyFeedback), o.copyPayload && i?.(o.copyPayload)) : j(null), a?.(o.commandResult), o.success;
3352
- }, le = (e) => {
3353
- !B || !Ur(t, e) || (c(null), u(null));
3380
+ return o.copyFeedback ? (A(o.copyFeedback), o.copyPayload && i?.(o.copyPayload)) : A(null), a?.(o.commandResult), o.success;
3354
3381
  }, ue = (e) => {
3382
+ !z || !qr(t, e) || (c(null), u(null));
3383
+ }, V = (e) => {
3355
3384
  s !== "row" && s !== "column" || e(s) && D((e) => e + 1);
3356
3385
  }, H = (e) => {
3357
- let r = e === "row" ? R : z, i = n.hoverCellPos ?? I?.activeCellPos ?? null;
3358
- !r || i === null || Si(t, i, e, { visualIndex: r.index }) && V(e === "row" ? "add-row-after" : "add-column-after", e);
3386
+ let r = e === "row" ? L : R, i = n.hoverCellPos ?? P?.activeCellPos ?? null;
3387
+ !r || i === null || Ei(t, i, e, { visualIndex: r.index }) && B(e === "row" ? "add-row-after" : "add-column-after", e);
3359
3388
  }, de = (e, t, n) => {
3360
- O.current = {
3389
+ ee.current = {
3361
3390
  axis: e,
3362
3391
  index: t
3363
- }, k.current = t, n.dataTransfer.effectAllowed = "move", n.dataTransfer.setData("application/x-markweave-table-axis", `${e}:${t}`);
3364
- }, U = (e) => {
3392
+ }, O.current = t, n.dataTransfer.effectAllowed = "move", n.dataTransfer.setData("application/x-markweave-table-axis", `${e}:${t}`);
3393
+ }, fe = (e) => {
3365
3394
  let t = e.currentTarget, n = t.classList.contains("markweave-table-menu") ? t.querySelector(":scope > .markweave-table-menu-scroll") ?? t : t, r = Array.from(n.querySelectorAll(":scope > button[role=\"menuitem\"]:not(:disabled), :scope > button[role=\"menuitemradio\"]:not(:disabled)")), i = r.indexOf(document.activeElement);
3366
3395
  if (e.key === "ArrowDown" || e.key === "ArrowUp") {
3367
3396
  e.preventDefault(), e.stopPropagation();
3368
3397
  let t = e.key === "ArrowDown" ? 1 : -1;
3369
3398
  r[i < 0 ? 0 : Math.min(r.length - 1, Math.max(0, i + t))]?.focus();
3370
3399
  }
3371
- }, fe = s === "row" || s === "column" ? oi(t, s) : null;
3400
+ }, me = s === "row" || s === "column" ? ui(t, s) : null;
3372
3401
  return /* @__PURE__ */ Q("div", {
3373
- ref: ee,
3402
+ ref: j,
3374
3403
  className: "markweave-table-controls",
3375
3404
  "data-testid": "markweave-table-controls",
3376
3405
  "aria-label": r.table.controlsAriaLabel,
3377
3406
  "data-open-menu": s ?? "none",
3378
3407
  "data-positioned": _ || y || x ? "true" : "false",
3379
3408
  onMouseLeave: () => {
3380
- t.view.dispatch(t.state.tr.setMeta(Nn, { type: "clear-hover" }));
3409
+ t.view.dispatch(t.state.tr.setMeta(Ln, { type: "clear-hover" }));
3381
3410
  },
3382
3411
  children: [
3383
- A ? /* @__PURE__ */ Z("div", {
3412
+ k ? /* @__PURE__ */ Z("div", {
3384
3413
  className: "markweave-table-copy-feedback",
3385
3414
  role: "status",
3386
3415
  "aria-live": "polite",
3387
3416
  "data-testid": "markweave-table-copy-feedback",
3388
- "data-copy-kind": A.kind,
3389
- "data-text-length": A.textLength,
3390
- "data-html-length": A.htmlLength,
3391
- children: ri(A)
3417
+ "data-copy-kind": k.kind,
3418
+ "data-text-length": k.textLength,
3419
+ "data-html-length": k.htmlLength,
3420
+ children: si(k)
3392
3421
  }) : null,
3393
3422
  _ ? /* @__PURE__ */ Z("button", {
3394
3423
  type: "button",
3395
- ref: P,
3424
+ ref: ae,
3396
3425
  className: "markweave-table-edge-handle markweave-table-edge-handle--row",
3397
3426
  "aria-label": r.table.activeRowActions,
3398
3427
  "aria-expanded": s === "row" && d === "row-edge",
3399
3428
  "aria-haspopup": "menu",
3400
3429
  title: r.table.rowActions,
3401
3430
  "data-testid": "markweave-table-hover-row-handle",
3402
- "data-axis-index": R?.index ?? "",
3403
- "data-axis-selected-cells": R?.selectedCellCount ?? "",
3404
- "data-axis-visual-cells": R?.visualCellCount ?? "",
3405
- "data-axis-visual-size": R?.visualHeight ?? "",
3431
+ "data-axis-index": L?.index ?? "",
3432
+ "data-axis-selected-cells": L?.selectedCellCount ?? "",
3433
+ "data-axis-visual-cells": L?.visualCellCount ?? "",
3434
+ "data-axis-visual-size": L?.visualHeight ?? "",
3406
3435
  style: {
3407
3436
  left: _.left,
3408
3437
  top: _.top,
@@ -3410,12 +3439,12 @@ function so({ active: e, editor: t, interactionState: n = Mn, messages: r = io,
3410
3439
  height: _.height
3411
3440
  },
3412
3441
  draggable: !0,
3413
- onDragStart: (e) => de("row", R?.index ?? 0, e),
3442
+ onDragStart: (e) => de("row", L?.index ?? 0, e),
3414
3443
  onDragEnd: () => {
3415
- O.current = null, k.current = null;
3444
+ ee.current = null, O.current = null;
3416
3445
  },
3417
3446
  onClick: () => {
3418
- L("row", "row-edge");
3447
+ I("row", "row-edge");
3419
3448
  },
3420
3449
  children: /* @__PURE__ */ Z(pe, {
3421
3450
  "aria-hidden": "true",
@@ -3424,17 +3453,17 @@ function so({ active: e, editor: t, interactionState: n = Mn, messages: r = io,
3424
3453
  }) : null,
3425
3454
  y ? /* @__PURE__ */ Z("button", {
3426
3455
  type: "button",
3427
- ref: re,
3456
+ ref: M,
3428
3457
  className: "markweave-table-edge-handle markweave-table-edge-handle--column",
3429
3458
  "aria-label": r.table.activeColumnActions,
3430
3459
  "aria-expanded": s === "column" && d === "column-edge",
3431
3460
  "aria-haspopup": "menu",
3432
3461
  title: r.table.columnActions,
3433
3462
  "data-testid": "markweave-table-hover-column-handle",
3434
- "data-axis-index": z?.index ?? "",
3435
- "data-axis-selected-cells": z?.selectedCellCount ?? "",
3436
- "data-axis-visual-cells": z?.visualCellCount ?? "",
3437
- "data-axis-visual-size": z?.visualWidth ?? "",
3463
+ "data-axis-index": R?.index ?? "",
3464
+ "data-axis-selected-cells": R?.selectedCellCount ?? "",
3465
+ "data-axis-visual-cells": R?.visualCellCount ?? "",
3466
+ "data-axis-visual-size": R?.visualWidth ?? "",
3438
3467
  style: {
3439
3468
  left: y.left,
3440
3469
  top: y.top,
@@ -3442,12 +3471,12 @@ function so({ active: e, editor: t, interactionState: n = Mn, messages: r = io,
3442
3471
  height: y.height
3443
3472
  },
3444
3473
  draggable: !0,
3445
- onDragStart: (e) => de("column", z?.index ?? 0, e),
3474
+ onDragStart: (e) => de("column", R?.index ?? 0, e),
3446
3475
  onDragEnd: () => {
3447
- O.current = null, k.current = null;
3476
+ ee.current = null, O.current = null;
3448
3477
  },
3449
3478
  onClick: () => {
3450
- L("column", "column-edge");
3479
+ I("column", "column-edge");
3451
3480
  },
3452
3481
  children: /* @__PURE__ */ Z(pe, {
3453
3482
  "aria-hidden": "true",
@@ -3468,7 +3497,7 @@ function so({ active: e, editor: t, interactionState: n = Mn, messages: r = io,
3468
3497
  },
3469
3498
  onMouseDown: (e) => e.preventDefault(),
3470
3499
  onClick: () => H("row"),
3471
- children: /* @__PURE__ */ Z(ge, {
3500
+ children: /* @__PURE__ */ Z(_e, {
3472
3501
  "aria-hidden": "true",
3473
3502
  size: 16
3474
3503
  })
@@ -3487,14 +3516,14 @@ function so({ active: e, editor: t, interactionState: n = Mn, messages: r = io,
3487
3516
  },
3488
3517
  onMouseDown: (e) => e.preventDefault(),
3489
3518
  onClick: () => H("column"),
3490
- children: /* @__PURE__ */ Z(ge, {
3519
+ children: /* @__PURE__ */ Z(_e, {
3491
3520
  "aria-hidden": "true",
3492
3521
  size: 16
3493
3522
  })
3494
3523
  }) : null,
3495
- se && x ? /* @__PURE__ */ Z("button", {
3524
+ ce && x ? /* @__PURE__ */ Z("button", {
3496
3525
  type: "button",
3497
- ref: F,
3526
+ ref: N,
3498
3527
  className: "markweave-table-edge-handle markweave-table-edge-handle--selection",
3499
3528
  "aria-label": r.table.selectionActions,
3500
3529
  "aria-expanded": s === "selection" && d === "selection-edge",
@@ -3508,17 +3537,17 @@ function so({ active: e, editor: t, interactionState: n = Mn, messages: r = io,
3508
3537
  height: x.height
3509
3538
  },
3510
3539
  onMouseDown: (e) => e.preventDefault(),
3511
- onClick: oe,
3540
+ onClick: se,
3512
3541
  children: /* @__PURE__ */ Z(pe, {
3513
3542
  "aria-hidden": "true",
3514
3543
  size: 14
3515
3544
  })
3516
3545
  }) : null,
3517
3546
  s ? /* @__PURE__ */ Q("div", {
3518
- ref: te,
3547
+ ref: ne,
3519
3548
  className: "markweave-table-menu",
3520
3549
  role: "menu",
3521
- "aria-label": bi(s, r),
3550
+ "aria-label": wi(s, r),
3522
3551
  "data-testid": "markweave-table-menu",
3523
3552
  "data-positioned": p ? "true" : "false",
3524
3553
  "data-placement": p?.placement,
@@ -3527,14 +3556,14 @@ function so({ active: e, editor: t, interactionState: n = Mn, messages: r = io,
3527
3556
  left: p.left,
3528
3557
  top: p.top
3529
3558
  } : void 0,
3530
- onKeyDown: U,
3559
+ onKeyDown: fe,
3531
3560
  children: [
3532
3561
  /* @__PURE__ */ Z("div", {
3533
- ref: N,
3562
+ ref: re,
3534
3563
  className: "markweave-table-menu-scroll",
3535
3564
  style: p ? { maxHeight: Math.max(1, p.maxHeight - 12) } : void 0,
3536
- children: ce.map((e, n) => {
3537
- let i = ui(e), a = n === 0 ? i : ui(ce[n - 1]), o = n > 0 && a !== i, d = s === "row" || s === "column" ? s : "selection", f = e.submenuId ? !0 : e.id === "edit-with-ai" ? B && jr(t, d) : e.commandId === null ? !1 : ti(t, e.commandId), p = di(e, r), m = ao[e.icon];
3565
+ children: le.map((e, n) => {
3566
+ let i = mi(e), a = n === 0 ? i : mi(le[n - 1]), o = n > 0 && a !== i, d = s === "row" || s === "column" ? s : "selection", f = e.submenuId ? !0 : e.id === "edit-with-ai" ? z && Fr(t, d) : e.commandId === null ? !1 : ai(t, e.commandId), p = hi(e, r), m = lo[e.icon];
3538
3567
  return /* @__PURE__ */ Q("button", {
3539
3568
  type: "button",
3540
3569
  role: "menuitem",
@@ -3543,14 +3572,14 @@ function so({ active: e, editor: t, interactionState: n = Mn, messages: r = io,
3543
3572
  "aria-haspopup": e.submenuId ? "menu" : void 0,
3544
3573
  "aria-expanded": e.submenuId ? l === e.submenuId : void 0,
3545
3574
  disabled: !f,
3546
- title: e.id === "edit-with-ai" && B && !f ? r.askAi.tableMergedUnsupported : void 0,
3575
+ title: e.id === "edit-with-ai" && z && !f ? r.askAi.tableMergedUnsupported : void 0,
3547
3576
  "data-menu-group": i,
3548
3577
  "data-starts-group": o ? "true" : "false",
3549
3578
  "data-command-enabled": f ? "true" : "false",
3550
3579
  "data-submenu-trigger": e.submenuId ?? void 0,
3551
3580
  "data-testid": e.commandId ? `markweave-table-menu-command-${e.commandId}` : e.submenuId ? `markweave-table-menu-submenu-${e.submenuId}` : "markweave-table-menu-command-edit-with-ai",
3552
3581
  onMouseDown: (t) => {
3553
- t.preventDefault(), f && e.id === "edit-with-ai" && le(d);
3582
+ t.preventDefault(), f && e.id === "edit-with-ai" && ue(d);
3554
3583
  },
3555
3584
  onMouseEnter: () => u(e.submenuId),
3556
3585
  onClick: (t) => {
@@ -3560,10 +3589,10 @@ function so({ active: e, editor: t, interactionState: n = Mn, messages: r = io,
3560
3589
  return;
3561
3590
  }
3562
3591
  if (e.commandId === null) {
3563
- t.detail === 0 && le(d);
3592
+ t.detail === 0 && ue(d);
3564
3593
  return;
3565
3594
  }
3566
- V(e.commandId).finally(() => {
3595
+ B(e.commandId).finally(() => {
3567
3596
  c(null), u(null);
3568
3597
  });
3569
3598
  }
@@ -3581,7 +3610,7 @@ function so({ active: e, editor: t, interactionState: n = Mn, messages: r = io,
3581
3610
  className: "markweave-table-menu-item-label",
3582
3611
  children: p
3583
3612
  }),
3584
- e.submenuId ? /* @__PURE__ */ Z(M, {
3613
+ e.submenuId ? /* @__PURE__ */ Z(te, {
3585
3614
  className: "markweave-table-menu-chevron",
3586
3615
  "aria-hidden": "true",
3587
3616
  size: 16
@@ -3591,7 +3620,7 @@ function so({ active: e, editor: t, interactionState: n = Mn, messages: r = io,
3591
3620
  })
3592
3621
  }),
3593
3622
  l === "color" && (s === "row" || s === "column") ? /* @__PURE__ */ Q("div", {
3594
- ref: ne,
3623
+ ref: ie,
3595
3624
  className: "markweave-table-submenu markweave-table-color-menu",
3596
3625
  role: "menu",
3597
3626
  "aria-label": r.table.submenus.color,
@@ -3603,20 +3632,20 @@ function so({ active: e, editor: t, interactionState: n = Mn, messages: r = io,
3603
3632
  top: h.top,
3604
3633
  maxHeight: h.maxHeight
3605
3634
  } : void 0,
3606
- onKeyDown: U,
3635
+ onKeyDown: fe,
3607
3636
  children: [
3608
3637
  /* @__PURE__ */ Z("div", {
3609
3638
  className: "markweave-table-submenu-title",
3610
3639
  children: r.table.submenus.textColor
3611
3640
  }),
3612
- _i.map((e) => /* @__PURE__ */ Q("button", {
3641
+ xi.map((e) => /* @__PURE__ */ Q("button", {
3613
3642
  type: "button",
3614
3643
  role: "menuitemradio",
3615
- "aria-checked": fe?.textColorId === e.id,
3616
- "data-active": fe?.textColorId === e.id ? "true" : "false",
3644
+ "aria-checked": me?.textColorId === e.id,
3645
+ "data-active": me?.textColorId === e.id ? "true" : "false",
3617
3646
  "data-testid": `markweave-table-text-color-${e.id}`,
3618
3647
  onMouseDown: (e) => e.preventDefault(),
3619
- onClick: () => ue((n) => Xr(t, n, e.id)),
3648
+ onClick: () => V((n) => ei(t, n, e.id)),
3620
3649
  children: [/* @__PURE__ */ Z("span", {
3621
3650
  className: "markweave-table-color-swatch markweave-table-text-color-swatch",
3622
3651
  "aria-hidden": "true",
@@ -3628,14 +3657,14 @@ function so({ active: e, editor: t, interactionState: n = Mn, messages: r = io,
3628
3657
  className: "markweave-table-submenu-title",
3629
3658
  children: r.table.submenus.backgroundColor
3630
3659
  }),
3631
- _i.map((e) => /* @__PURE__ */ Q("button", {
3660
+ xi.map((e) => /* @__PURE__ */ Q("button", {
3632
3661
  type: "button",
3633
3662
  role: "menuitemradio",
3634
- "aria-checked": fe?.backgroundColorId === e.id,
3635
- "data-active": fe?.backgroundColorId === e.id ? "true" : "false",
3663
+ "aria-checked": me?.backgroundColorId === e.id,
3664
+ "data-active": me?.backgroundColorId === e.id ? "true" : "false",
3636
3665
  "data-testid": `markweave-table-background-color-${e.id}`,
3637
3666
  onMouseDown: (e) => e.preventDefault(),
3638
- onClick: () => ue((n) => Yr(t, n, e.id)),
3667
+ onClick: () => V((n) => $r(t, n, e.id)),
3639
3668
  children: [/* @__PURE__ */ Z("span", {
3640
3669
  className: "markweave-table-color-swatch",
3641
3670
  "aria-hidden": "true",
@@ -3645,7 +3674,7 @@ function so({ active: e, editor: t, interactionState: n = Mn, messages: r = io,
3645
3674
  ]
3646
3675
  }) : null,
3647
3676
  l === "alignment" && (s === "row" || s === "column") ? /* @__PURE__ */ Q("div", {
3648
- ref: ne,
3677
+ ref: ie,
3649
3678
  className: "markweave-table-submenu markweave-table-alignment-menu",
3650
3679
  role: "menu",
3651
3680
  "aria-label": r.table.submenus.alignment,
@@ -3657,10 +3686,10 @@ function so({ active: e, editor: t, interactionState: n = Mn, messages: r = io,
3657
3686
  top: h.top,
3658
3687
  maxHeight: h.maxHeight
3659
3688
  } : void 0,
3660
- onKeyDown: U,
3689
+ onKeyDown: fe,
3661
3690
  children: [
3662
- yi.map((e) => {
3663
- let n = oo[e], i = fe?.textAlign === e;
3691
+ Ci.map((e) => {
3692
+ let n = uo[e], i = me?.textAlign === e;
3664
3693
  return /* @__PURE__ */ Q("button", {
3665
3694
  type: "button",
3666
3695
  role: "menuitemradio",
@@ -3668,7 +3697,7 @@ function so({ active: e, editor: t, interactionState: n = Mn, messages: r = io,
3668
3697
  "data-active": i ? "true" : "false",
3669
3698
  "data-testid": `markweave-table-alignment-${e}`,
3670
3699
  onMouseDown: (e) => e.preventDefault(),
3671
- onClick: () => ue((n) => Jr(t, n, e)),
3700
+ onClick: () => V((n) => Qr(t, n, e)),
3672
3701
  children: [/* @__PURE__ */ Z(n, {
3673
3702
  "aria-hidden": "true",
3674
3703
  size: 18,
@@ -3677,8 +3706,8 @@ function so({ active: e, editor: t, interactionState: n = Mn, messages: r = io,
3677
3706
  }, e);
3678
3707
  }),
3679
3708
  /* @__PURE__ */ Z("div", { className: "markweave-table-submenu-separator" }),
3680
- xi.map((e) => {
3681
- let n = oo[e], i = fe?.verticalAlign === e;
3709
+ Ti.map((e) => {
3710
+ let n = uo[e], i = me?.verticalAlign === e;
3682
3711
  return /* @__PURE__ */ Q("button", {
3683
3712
  type: "button",
3684
3713
  role: "menuitemradio",
@@ -3686,7 +3715,7 @@ function so({ active: e, editor: t, interactionState: n = Mn, messages: r = io,
3686
3715
  "data-active": i ? "true" : "false",
3687
3716
  "data-testid": `markweave-table-alignment-${e}`,
3688
3717
  onMouseDown: (e) => e.preventDefault(),
3689
- onClick: () => ue((n) => Jr(t, n, e)),
3718
+ onClick: () => V((n) => Qr(t, n, e)),
3690
3719
  children: [/* @__PURE__ */ Z(n, {
3691
3720
  "aria-hidden": "true",
3692
3721
  size: 18,
@@ -3703,15 +3732,15 @@ function so({ active: e, editor: t, interactionState: n = Mn, messages: r = io,
3703
3732
  }
3704
3733
  //#endregion
3705
3734
  //#region src/ui/table/TableSelectionOverlay.tsx
3706
- function co({ editor: e, focusState: t }) {
3707
- let [n, r] = Y(null);
3735
+ function po({ editor: e, focusState: t }) {
3736
+ let [n, r] = J(null);
3708
3737
  return Re(() => {
3709
3738
  if (t.mode !== "cell-selection") {
3710
3739
  r(null);
3711
3740
  return;
3712
3741
  }
3713
3742
  let n = () => {
3714
- r(mi(e, jn(e.state)));
3743
+ r(vi(e, Fn(e.state)));
3715
3744
  };
3716
3745
  return n(), window.addEventListener("resize", n), window.addEventListener("scroll", n, !0), () => {
3717
3746
  window.removeEventListener("resize", n), window.removeEventListener("scroll", n, !0);
@@ -3747,18 +3776,18 @@ function co({ editor: e, focusState: t }) {
3747
3776
  }
3748
3777
  //#endregion
3749
3778
  //#region src/ui/toc/MarkweaveInnerToc.tsx
3750
- function lo(e, t) {
3779
+ function mo(e, t) {
3751
3780
  return `${e.toc.itemAriaLabel}: ${t.text}`;
3752
3781
  }
3753
- function uo({ editor: e, state: t, messages: n, editable: r, placement: i }) {
3754
- let a = J(null);
3755
- if (K(() => {
3756
- if (!(i !== "container" || !a.current)) return Ai(a.current);
3757
- }, [i]), K(() => {
3758
- if (!(!a.current || !t.items.length)) return ji(a.current, t.items.length);
3782
+ function ho({ editor: e, state: t, messages: n, editable: r, placement: i }) {
3783
+ let a = q(null);
3784
+ if (G(() => {
3785
+ if (!(i !== "container" || !a.current)) return Pi(a.current);
3786
+ }, [i]), G(() => {
3787
+ if (!(!a.current || !t.items.length)) return Fi(a.current, t.items.length);
3759
3788
  }, [t.items.length]), !t.items.length) return null;
3760
3789
  let o = (t) => {
3761
- Mi(e, t, {
3790
+ Ii(e, t, {
3762
3791
  behavior: "smooth",
3763
3792
  focus: r
3764
3793
  });
@@ -3768,7 +3797,7 @@ function uo({ editor: e, state: t, messages: n, editable: r, placement: i }) {
3768
3797
  className: "markweave-inner-toc",
3769
3798
  "data-testid": "markweave-inner-toc",
3770
3799
  "aria-label": n.toc.ariaLabel,
3771
- style: { "--markweave-inner-toc-rail-height": Ei(t.items.length) },
3800
+ style: { "--markweave-inner-toc-rail-height": Ai(t.items.length) },
3772
3801
  children: [/* @__PURE__ */ Z("div", {
3773
3802
  className: "markweave-inner-toc-rail",
3774
3803
  "aria-hidden": "true",
@@ -3786,7 +3815,7 @@ function uo({ editor: e, state: t, messages: n, editable: r, placement: i }) {
3786
3815
  "data-level": e.level,
3787
3816
  "data-active": e.active ? "true" : "false",
3788
3817
  "aria-current": e.active ? "location" : void 0,
3789
- "aria-label": lo(n, e),
3818
+ "aria-label": mo(n, e),
3790
3819
  title: e.text,
3791
3820
  onClick: () => o(e),
3792
3821
  children: e.text
@@ -3797,7 +3826,7 @@ function uo({ editor: e, state: t, messages: n, editable: r, placement: i }) {
3797
3826
  }
3798
3827
  //#endregion
3799
3828
  //#region src/MarkweaveEditor.tsx
3800
- var fo = {
3829
+ var go = {
3801
3830
  active: !1,
3802
3831
  mode: "outside",
3803
3832
  activeCellPos: null,
@@ -3805,21 +3834,21 @@ var fo = {
3805
3834
  selectedCellCount: 0,
3806
3835
  selectionFrom: 0,
3807
3836
  selectionTo: 0
3808
- }, po = {
3837
+ }, _o = {
3809
3838
  active: !1,
3810
- language: qt.defaultLanguage,
3839
+ language: Kt.defaultLanguage,
3811
3840
  mermaidPreviewMode: "code",
3812
3841
  pos: null,
3813
3842
  text: ""
3814
- }, mo = tn({
3843
+ }, vo = en({
3815
3844
  active: !1,
3816
3845
  mode: "code",
3817
3846
  source: ""
3818
3847
  });
3819
- function ho(e) {
3820
- return Nn.getState(e.state) ?? Mn;
3848
+ function yo(e) {
3849
+ return Ln.getState(e.state) ?? In;
3821
3850
  }
3822
- function go(e) {
3851
+ function bo(e) {
3823
3852
  if (!e || typeof window > "u") return null;
3824
3853
  let t = e.parentElement;
3825
3854
  for (; t;) {
@@ -3829,152 +3858,173 @@ function go(e) {
3829
3858
  }
3830
3859
  return null;
3831
3860
  }
3832
- function _o(e) {
3861
+ function xo(e) {
3833
3862
  return typeof window > "u" || typeof window.requestAnimationFrame != "function" ? globalThis.setTimeout(() => e(0), 0) : window.requestAnimationFrame(e);
3834
3863
  }
3835
- function vo(e) {
3864
+ function So(e) {
3836
3865
  if (typeof window < "u" && typeof window.cancelAnimationFrame == "function") {
3837
3866
  window.cancelAnimationFrame(e);
3838
3867
  return;
3839
3868
  }
3840
3869
  globalThis.clearTimeout(e);
3841
3870
  }
3842
- function yo({ askAi: e, ariaLabel: i, autoFocusFirstTableBodyCell: a = !1, autofocus: o = !1, content: s, contentFormat: l, defaultContent: u = "", defaultContentFormat: d, editable: f = !0, innerToc: p = !0, innerTocPlacement: m, lang: h, mode: g = "live", theme: _, canvasColor: v, onEditWithAi: y, onExtractToNote: b, onRewriteSelection: x, onAiEditControllerChange: S, onRuntimeStateChange: C, onSearchControllerChange: w, onSlashCommandUpload: T, onAttachmentDownload: E, onTableCommandResult: D, onTableCopyPayload: O, onTocChange: k, onUpdate: A, linkCardResolver: j, resolveMediaSource: ee } = {}) {
3843
- let M = He(g), te = Pi(_), N = Ni(v), ne = ki(m), P = M === "live" && f !== !1, re = kt(s === void 0 ? d : l), F = s ?? u, I = typeof F == "string" && F.length >= 2e5, ie = s === void 0 && re === "markdown" && I && typeof F == "string", ae = J(ie ? F : null), [L, oe] = Y(ie), R = J({
3871
+ function Co(e, t) {
3872
+ return e.length === t.length && e.every((e, n) => {
3873
+ let r = t[n];
3874
+ return r && e.id === r.id && e.label === r.label && e.description === r.description && e.group === r.group && e.disabled === r.disabled && e.disabledReason === r.disabledReason && JSON.stringify(e.icon) === JSON.stringify(r.icon);
3875
+ });
3876
+ }
3877
+ function wo({ askAi: e, ariaLabel: r, autoFocusFirstTableBodyCell: i = !1, autofocus: a = !1, content: o, contentFormat: c, defaultContent: l = "", defaultContentFormat: u, editable: d = !0, innerToc: f = !0, innerTocPlacement: p, lang: m, mode: h = "live", theme: g, canvasColor: _, onEditWithAi: v, onExtractToNote: y, onRewriteSelection: b, onAiEditControllerChange: x, onRuntimeStateChange: S, onSearchControllerChange: C, commandGroups: w, commands: T, builtinCommands: E, editorExtensions: D, onCommandControllerChange: ee, onCommandError: O, onSlashCommandUpload: k, onAttachmentDownload: A, onTableCommandResult: te, onTableCopyPayload: j, onTocChange: ne, onUpdate: re, linkCardResolver: ie, resolveMediaSource: ae } = {}) {
3878
+ let M = He(h), N = Ri(g), P = Li(_), oe = Ni(p), F = M === "live" && d !== !1, I = Ot(o === void 0 ? u : c), se = o ?? l, L = typeof se == "string" && se.length >= 2e5, R = o === void 0 && I === "markdown" && L && typeof se == "string", z = q(R ? se : null), [ce, le] = J(R), B = q({
3844
3879
  editorMode: M,
3845
- effectiveEditable: P
3880
+ effectiveEditable: F
3846
3881
  });
3847
- R.current = {
3882
+ B.current = {
3848
3883
  editorMode: M,
3849
- effectiveEditable: P
3884
+ effectiveEditable: F
3850
3885
  };
3851
- let z = J(null);
3852
- z.current === null && (z.current = r(h));
3853
- let B = z.current, se = q(() => n(B), [B]), ce = q(() => t(B), [B]), V = J(T);
3854
- V.current = T;
3855
- let le = J(E);
3856
- le.current = E;
3857
- let ue = J(w);
3858
- ue.current = w;
3859
- let H = J(S);
3860
- H.current = S;
3861
- let de = J(j);
3862
- de.current = j;
3863
- let U = q(() => ua({
3864
- lang: B,
3886
+ let ue = q(null);
3887
+ ue.current === null && (ue.current = n(m));
3888
+ let V = ue.current, H = K(() => t(V), [V]), de = K(() => kn({
3889
+ lang: V,
3890
+ commandGroups: w,
3891
+ commands: T,
3892
+ builtinCommands: E
3893
+ }), [
3894
+ E,
3895
+ w,
3896
+ T,
3897
+ V
3898
+ ]), fe = q(D), pe = q(k);
3899
+ pe.current = k;
3900
+ let me = q(A);
3901
+ me.current = A;
3902
+ let he = q(C);
3903
+ he.current = C;
3904
+ let ge = q(x);
3905
+ ge.current = x;
3906
+ let _e = q(ee);
3907
+ _e.current = ee;
3908
+ let ve = q(O);
3909
+ ve.current = O;
3910
+ let ye = q(ie);
3911
+ ye.current = ie;
3912
+ let be = K(() => ma({
3913
+ lang: V,
3865
3914
  onImageUpload: (e) => {
3866
- if (V.current) return V.current(e);
3915
+ if (pe.current) return pe.current(e);
3867
3916
  let t = dt(e);
3868
3917
  if (!t) throw Error("File upload requires an upload handler.");
3869
3918
  return t;
3870
3919
  },
3871
3920
  onVideoUpload: (e) => {
3872
- if (V.current) return V.current(e);
3921
+ if (pe.current) return pe.current(e);
3873
3922
  let t = dt(e);
3874
3923
  if (!t) throw Error("File upload requires an upload handler.");
3875
3924
  return t;
3876
3925
  },
3877
3926
  onAttachmentUpload: (e) => {
3878
- if (V.current) return V.current(e);
3927
+ if (pe.current) return pe.current(e);
3879
3928
  let t = dt(e);
3880
3929
  if (!t) throw Error("File upload requires an upload handler.");
3881
3930
  return t;
3882
3931
  },
3883
- onAttachmentDownload: (e, t) => le.current?.(e, t),
3884
- linkCardResolver: (e) => de.current?.(e) ?? Promise.resolve(null),
3885
- resolveMediaSource: ee
3886
- }), [ee, B]), [fe, pe] = Y(null), [me, W] = Y(En), [he, ge] = Y(null), [_e, ve] = Y(null), [ye, be] = Y("code"), [xe, Se] = Y(null), [Ce, we] = Y(Mn), [Te, Ee] = Y(null), [De, Oe] = Y(0), ke = J(!1), Ae = J({
3887
- content: s,
3888
- format: re
3889
- }), je = J(null), Me = J(null), Ne = J({ onUpdate: A }), Pe = q(() => hn(me.query, ce), [ce, me.query]);
3890
- Ne.current = { onUpdate: A }, Ae.current = {
3891
- content: s,
3892
- format: re
3932
+ onAttachmentDownload: (e, t) => me.current?.(e, t),
3933
+ linkCardResolver: (e) => ye.current?.(e) ?? Promise.resolve(null),
3934
+ resolveMediaSource: ae,
3935
+ editorExtensions: fe.current
3936
+ }), [ae, V]), [xe, Se] = J(null), [U, Ce] = J(An), [we, Te] = J(null), [Ee, De] = J(null), [Oe, ke] = J(() => mn(de.commands, V)), [Ae, je] = J(null), [Me, Ne] = J("code"), [Pe, Fe] = J(null), [Ie, Le] = J(In), [Re, ze] = J(null), [Be, Ve] = J(0), We = q(!1), Ge = q({
3937
+ content: o,
3938
+ format: I
3939
+ }), Ke = q(null), qe = q(null), Je = q({ onUpdate: re }), Ye = K(() => hn(U.query, Oe), [Oe, U.query]);
3940
+ Je.current = { onUpdate: re }, Ge.current = {
3941
+ content: o,
3942
+ format: I
3893
3943
  };
3894
- let Fe = G(() => {
3895
- Me.current !== null && (window.clearTimeout(Me.current), Me.current = null), Oe((e) => e + 1);
3896
- }, []), Ie = G(() => {
3897
- Me.current !== null && window.clearTimeout(Me.current), Me.current = window.setTimeout(() => {
3898
- Me.current = null, Oe((e) => e + 1);
3899
- }, Bt);
3944
+ let Xe = W(() => {
3945
+ qe.current !== null && (window.clearTimeout(qe.current), qe.current = null), Ve((e) => e + 1);
3946
+ }, []), Ze = W(() => {
3947
+ qe.current !== null && window.clearTimeout(qe.current), qe.current = window.setTimeout(() => {
3948
+ qe.current = null, Ve((e) => e + 1);
3949
+ }, zt);
3900
3950
  }, []);
3901
- K(() => () => {
3902
- Me.current !== null && window.clearTimeout(Me.current);
3951
+ G(() => () => {
3952
+ qe.current !== null && window.clearTimeout(qe.current);
3903
3953
  }, []);
3904
- let Le = G(() => {
3905
- ge(null), ve(null), W(En);
3906
- }, []), Re = G((e) => {
3907
- let t = Cn(e.state);
3954
+ let Qe = W(() => {
3955
+ Te(null), De(null), Ce(An);
3956
+ }, []), $e = W((e) => {
3957
+ let t = Sn(e.state);
3908
3958
  if (!t) {
3909
- W((e) => e.name === "idle" ? e : En), ge(null), ve(null);
3959
+ Ce((e) => e.name === "idle" ? e : An), Te(null), De(null);
3910
3960
  return;
3911
3961
  }
3912
3962
  let n = e.coordsAtPos(t.cursor), r = e.coordsAtPos(t.triggerFrom), i = e.dom.closest(".markweave-editor-frame")?.getBoundingClientRect();
3913
- if (!Tn(r, { frameRect: i })) {
3914
- ge(null), ve(null), W(En);
3963
+ if (!wn(r, { frameRect: i })) {
3964
+ Te(null), De(null), Ce(An);
3915
3965
  return;
3916
3966
  }
3917
- let a = Sn(n, {
3967
+ let a = xn(n, {
3918
3968
  frameRect: i,
3919
3969
  triggerRect: r
3920
3970
  });
3921
- ge((e) => yn(e, a) ? e : a), W((e) => xn(e, t));
3922
- }, []), ze = G((e) => Re(e.view), [Re]), Be = G((e) => {
3923
- let t = Lt(e);
3924
- pe((e) => Nt(e, t) ? e : t);
3925
- let n = un(e);
3926
- n && (fn(e, n, !0), Se(n));
3927
- let r = Gt(e);
3928
- r.active && r.language === "mermaid" && be(r.mermaidPreviewMode);
3929
- }, []), Ve = G((e) => {
3930
- we(ho(e));
3931
- }, []), X = c({
3971
+ Te((e) => yn(e, a) ? e : a), Ce((e) => bn(e, t));
3972
+ }, []), et = W((e) => $e(e.view), [$e]), tt = W((e) => {
3973
+ let t = It(e);
3974
+ Se((e) => Mt(e, t) ? e : t);
3975
+ let n = ln(e);
3976
+ n && (dn(e, n, !0), Fe(n));
3977
+ let r = Wt(e);
3978
+ r.active && r.language === "mermaid" && Ne(r.mermaidPreviewMode);
3979
+ }, []), nt = W((e) => {
3980
+ Le(yo(e));
3981
+ }, []), Y = s({
3932
3982
  shouldRerenderOnTransaction: !1,
3933
- extensions: U,
3934
- content: ie ? "" : F,
3935
- contentType: Et(re),
3936
- editable: P,
3937
- autofocus: o,
3983
+ extensions: be,
3984
+ content: R ? "" : se,
3985
+ contentType: Tt(I),
3986
+ editable: F,
3987
+ autofocus: a,
3938
3988
  editorProps: {
3939
3989
  attributes: {
3940
3990
  class: "markweave-editor-surface",
3941
3991
  "data-testid": "markweave-editor-surface",
3942
- "data-markweave-large-document": I ? "true" : "false",
3992
+ "data-markweave-large-document": L ? "true" : "false",
3943
3993
  autocapitalize: "off",
3944
3994
  autocorrect: "off",
3945
3995
  spellcheck: "false",
3946
3996
  translate: "no"
3947
3997
  },
3948
- handleClick: (e, t, n) => R.current.effectiveEditable ? !1 : At(n),
3998
+ handleClick: (e, t, n) => B.current.effectiveEditable ? !1 : kt(n),
3949
3999
  handleDOMEvents: {
3950
- compositionstart: () => R.current.effectiveEditable ? (W((e) => Dn(e, { type: "composition-start" })), ge(null), !1) : !1,
3951
- compositionend: (e) => (R.current.effectiveEditable && window.setTimeout(() => Re(e), 0), !1),
4000
+ compositionstart: () => B.current.effectiveEditable ? (Ce((e) => jn(e, { type: "composition-start" })), Te(null), !1) : !1,
4001
+ compositionend: (e) => (B.current.effectiveEditable && window.setTimeout(() => $e(e), 0), !1),
3952
4002
  click: (e, t) => {
3953
- if (R.current.effectiveEditable) {
3954
- let n = ln(e, t);
3955
- return n ? (t.preventDefault(), t.stopPropagation(), Le(), pn(e, n, !0), mn(e, n), Se(n), !0) : (Se(null), !1);
4003
+ if (B.current.effectiveEditable) {
4004
+ let n = cn(e, t);
4005
+ return n ? (t.preventDefault(), t.stopPropagation(), Qe(), fn(e, n, !0), pn(e, n), Fe(n), !0) : (Fe(null), !1);
3956
4006
  }
3957
- return At(t);
4007
+ return kt(t);
3958
4008
  }
3959
4009
  }
3960
4010
  },
3961
4011
  onSelectionUpdate: ({ editor: e }) => {
3962
- Be(e);
4012
+ tt(e);
3963
4013
  },
3964
4014
  onCreate: ({ editor: e }) => {
3965
- a && R.current.effectiveEditable && kn(e), Ve(e), Be(e), Fe();
4015
+ i && B.current.effectiveEditable && Nn(e), nt(e), tt(e), Xe();
3966
4016
  },
3967
4017
  onTransaction: ({ editor: e, transaction: t }) => {
3968
- Ve(e), (t.docChanged || Zt(t)) && Ie(), t.docChanged && Se((t) => {
4018
+ nt(e), (t.docChanged || Xt(t)) && Ze(), t.docChanged && Fe((t) => {
3969
4019
  if (!t) return null;
3970
- let n = cn(e, t.pos);
4020
+ let n = sn(e, t.pos);
3971
4021
  return n?.kind === t.kind ? n : null;
3972
4022
  });
3973
4023
  },
3974
4024
  onUpdate: ({ editor: e }) => {
3975
- Be(e), R.current.effectiveEditable && ze(e), ke.current || Ne.current.onUpdate?.(Tt(e, { onContentRead: (t, n) => {
3976
- let r = Ae.current;
3977
- r.content !== void 0 && t === r.format && (je.current = {
4025
+ tt(e), B.current.effectiveEditable && et(e), We.current || Je.current.onUpdate?.(wt(e, { onContentRead: (t, n) => {
4026
+ let r = Ge.current;
4027
+ r.content !== void 0 && t === r.format && (Ke.current = {
3978
4028
  content: n,
3979
4029
  format: t,
3980
4030
  doc: e.state.doc
@@ -3982,385 +4032,441 @@ function yo({ askAi: e, ariaLabel: i, autoFocusFirstTableBodyCell: a = !1, autof
3982
4032
  } }));
3983
4033
  }
3984
4034
  });
3985
- K(() => {
3986
- let e = ae.current;
3987
- if (!X || !e) return;
4035
+ G(() => {
4036
+ let e = z.current;
4037
+ if (!Y || !e) return;
3988
4038
  let t = !1;
3989
4039
  return (async () => {
3990
- ke.current = !0;
4040
+ We.current = !0;
3991
4041
  try {
3992
4042
  let n = !0;
3993
- for (let r of Fi(e)) {
4043
+ for (let r of zi(e)) {
3994
4044
  if (await new Promise((e) => window.setTimeout(e, 0)), t) return;
3995
- let e = X.markdown?.parse(r);
4045
+ let e = Y.markdown?.parse(r);
3996
4046
  if (!e) throw Error("Markdown parser is unavailable.");
3997
- let i = X.schema.nodeFromJSON(e).content, a = n ? X.state.tr.replaceWith(0, X.state.doc.content.size, i) : X.state.tr.insert(X.state.doc.content.size, i);
3998
- X.view.dispatch(a.setMeta("addToHistory", !1)), n = !1;
4047
+ let i = Y.schema.nodeFromJSON(e).content, a = n ? Y.state.tr.replaceWith(0, Y.state.doc.content.size, i) : Y.state.tr.insert(Y.state.doc.content.size, i);
4048
+ Y.view.dispatch(a.setMeta("addToHistory", !1)), n = !1;
3999
4049
  }
4000
4050
  if (t) return;
4001
- Be(X), Ve(X), Fe(), ae.current = null, oe(!1);
4051
+ tt(Y), nt(Y), Xe(), z.current = null, le(!1);
4002
4052
  } finally {
4003
- ke.current = !1;
4053
+ We.current = !1;
4004
4054
  }
4005
4055
  })().catch(() => {
4006
- t || (X.commands.setContent(e, {
4056
+ t || (Y.commands.setContent(e, {
4007
4057
  contentType: "markdown",
4008
4058
  emitUpdate: !1
4009
- }), ae.current = null, oe(!1));
4059
+ }), z.current = null, le(!1));
4010
4060
  }), () => {
4011
4061
  t = !0;
4012
4062
  };
4013
4063
  }, [
4014
- X,
4015
- Fe,
4016
- Be,
4017
- Ve
4018
- ]), K(() => {
4019
- if (X) return ue.current?.(Ii(X)), () => {
4020
- ue.current?.(null);
4064
+ Y,
4065
+ Xe,
4066
+ tt,
4067
+ nt
4068
+ ]), G(() => {
4069
+ if (Y) return he.current?.(Bi(Y)), () => {
4070
+ he.current?.(null);
4021
4071
  };
4022
- }, [X]), K(() => {
4023
- if (X) return H.current?.(Li(X)), () => {
4024
- H.current?.(null);
4072
+ }, [Y]), G(() => {
4073
+ if (Y) return _e.current?.(Tn(Y)), () => _e.current?.(null);
4074
+ }, [Y]), G(() => {
4075
+ if (!Y) {
4076
+ let e = mn(de.commands, V);
4077
+ ke((t) => Co(t, e) ? t : e);
4078
+ return;
4079
+ }
4080
+ On(Y, de, (e) => {
4081
+ je(e.message), ve.current?.(e);
4082
+ }), Dn(Y, I);
4083
+ }, [
4084
+ I,
4085
+ de,
4086
+ Y,
4087
+ V
4088
+ ]), G(() => {
4089
+ if (!Y) return;
4090
+ let e = mn(Tn(Y).getCommands({
4091
+ surface: "slash",
4092
+ query: U.query
4093
+ }), V);
4094
+ ke((t) => Co(t, e) ? t : e);
4095
+ }, [
4096
+ de,
4097
+ Y,
4098
+ F,
4099
+ V,
4100
+ Be,
4101
+ xe,
4102
+ U.query
4103
+ ]), G(() => {
4104
+ if (Y) return ge.current?.(Vi(Y)), () => {
4105
+ ge.current?.(null);
4025
4106
  };
4026
- }, [X]), K(() => {
4027
- if (!X) return;
4028
- let e = P && !L;
4029
- X.setEditable(e), Ue(X, {
4107
+ }, [Y]), G(() => {
4108
+ if (!Y) return;
4109
+ let e = F && !ce;
4110
+ Y.setEditable(e), Ue(Y, {
4030
4111
  mode: M,
4031
4112
  editable: e
4032
- }), $t(X, e ? "live" : "view"), Fe(), P || Le();
4113
+ }), Qt(Y, e ? "live" : "view"), Xe(), F || Qe();
4033
4114
  }, [
4034
- Le,
4035
- X,
4115
+ Qe,
4116
+ Y,
4036
4117
  M,
4037
- P,
4038
- Fe,
4039
- L
4040
- ]), K(() => {
4041
- X && Qt(X, te);
4042
- }, [X, te]), K(() => {
4043
- let e = kt(l);
4044
- if (!(!X || s === void 0)) {
4045
- if (Ot(X, je.current, s, e)) {
4046
- je.current = null;
4118
+ F,
4119
+ Xe,
4120
+ ce
4121
+ ]), G(() => {
4122
+ Y && Zt(Y, N);
4123
+ }, [Y, N]), G(() => {
4124
+ let e = Ot(c);
4125
+ if (!(!Y || o === void 0)) {
4126
+ if (Dt(Y, Ke.current, o, e)) {
4127
+ Ke.current = null;
4047
4128
  return;
4048
4129
  }
4049
- je.current = null, !Dt(X, s, e) && (ke.current = !0, X.commands.setContent(s, {
4050
- contentType: Et(e),
4130
+ Ke.current = null, !Et(Y, o, e) && (We.current = !0, Y.commands.setContent(o, {
4131
+ contentType: Tt(e),
4051
4132
  emitUpdate: !1
4052
- }), ke.current = !1, Be(X), P && ze(X), Ve(X), Fe());
4133
+ }), We.current = !1, tt(Y), F && et(Y), nt(Y), Xe());
4053
4134
  }
4054
4135
  }, [
4055
- s,
4056
- l,
4057
- P,
4058
- X,
4059
- Fe,
4060
- Be,
4061
- ze,
4062
- Ve
4063
- ]), K(() => {
4064
- if (!he) return;
4136
+ o,
4137
+ c,
4138
+ F,
4139
+ Y,
4140
+ Xe,
4141
+ tt,
4142
+ et,
4143
+ nt
4144
+ ]), G(() => {
4145
+ if (!we) return;
4065
4146
  let e = (e) => {
4066
4147
  let t = e.target;
4067
- t instanceof Element && (t.closest(".markweave-slash-menu") || t.closest(".markweave-slash-trigger") || Le());
4148
+ t instanceof Element && (t.closest(".markweave-slash-menu") || t.closest(".markweave-slash-trigger") || Qe());
4068
4149
  };
4069
4150
  return document.addEventListener("pointerdown", e, !0), () => document.removeEventListener("pointerdown", e, !0);
4070
- }, [Le, he]);
4071
- let We = he !== null;
4072
- K(() => {
4073
- if (!X || !We) return;
4074
- let e = wt(() => {
4075
- X.isDestroyed || Re(X.view);
4151
+ }, [Qe, we]);
4152
+ let rt = we !== null;
4153
+ G(() => {
4154
+ if (!Y || !rt) return;
4155
+ let e = Ct(() => {
4156
+ Y.isDestroyed || $e(Y.view);
4076
4157
  }), t = (t) => {
4077
- t?.type === "scroll" && wn(t.target) || e.schedule();
4158
+ t?.type === "scroll" && Cn(t.target) || e.schedule();
4078
4159
  };
4079
4160
  return window.addEventListener("resize", t), window.addEventListener("scroll", t, !0), t(), () => {
4080
4161
  e.cancel(), window.removeEventListener("resize", t), window.removeEventListener("scroll", t, !0);
4081
4162
  };
4082
4163
  }, [
4083
- X,
4084
- We,
4085
- Re
4164
+ Y,
4165
+ rt,
4166
+ $e
4086
4167
  ]);
4087
- let Ge = q(() => X ? Gt(X) : po, [
4088
- X,
4089
- De,
4090
- fe
4091
- ]), Ke = q(() => X ? An(X.state) : fo, [
4092
- X,
4093
- De,
4094
- fe,
4095
- Ce
4096
- ]), qe = fe?.currentNode === "codeBlock", Je = qe && Ge.language === "mermaid", Ye = q(() => X ? tn({
4097
- active: Je,
4098
- mode: ye,
4099
- source: Ge.text
4100
- }) : mo, [
4101
- Ge.text,
4102
- X,
4103
- Je,
4104
- ye
4105
- ]), Xe = q(() => X && C ? On(X.state) : null, [
4106
- X,
4107
- C,
4108
- De
4109
- ]), Ze = q(() => X ? Di(X.state) : wi.items, [X, De]), Qe = q(() => Oi(Ze, Te), [Te, Ze]), $e = q(() => Ci(Ze, Qe), [Qe, Ze]), et = G(() => {
4110
- if (!X || !Ze.length) {
4111
- Ee(null);
4168
+ let it = K(() => Y ? Wt(Y) : _o, [
4169
+ Y,
4170
+ Be,
4171
+ xe
4172
+ ]), at = K(() => Y ? Pn(Y.state) : go, [
4173
+ Y,
4174
+ Be,
4175
+ xe,
4176
+ Ie
4177
+ ]), ot = xe?.currentNode === "codeBlock", st = ot && it.language === "mermaid", ct = K(() => Y ? en({
4178
+ active: st,
4179
+ mode: Me,
4180
+ source: it.text
4181
+ }) : vo, [
4182
+ it.text,
4183
+ Y,
4184
+ st,
4185
+ Me
4186
+ ]), lt = K(() => Y && S ? Mn(Y.state) : null, [
4187
+ Y,
4188
+ S,
4189
+ Be
4190
+ ]), ut = K(() => Y ? ji(Y.state) : Oi.items, [Y, Be]), ft = K(() => Mi(ut, Re), [Re, ut]), X = K(() => Di(ut, ft), [ft, ut]), Z = W(() => {
4191
+ if (!Y || !ut.length) {
4192
+ ze(null);
4112
4193
  return;
4113
4194
  }
4114
- let e = Ti(X, Ze);
4115
- Ee((t) => t === e ? t : e);
4116
- }, [X, Ze]);
4117
- K(() => {
4118
- Ee((e) => {
4119
- let t = Oi(Ze, e);
4195
+ let e = ki(Y, ut);
4196
+ ze((t) => t === e ? t : e);
4197
+ }, [Y, ut]);
4198
+ G(() => {
4199
+ ze((e) => {
4200
+ let t = Mi(ut, e);
4120
4201
  return e === t ? e : t;
4121
4202
  });
4122
- }, [Ze]), K(() => {
4123
- if (!X || !Ze.length || typeof window > "u") return;
4203
+ }, [ut]), G(() => {
4204
+ if (!Y || !ut.length || typeof window > "u") return;
4124
4205
  let e = null, t = () => {
4125
- e !== null && vo(e), e = _o(() => {
4126
- e = null, et();
4206
+ e !== null && So(e), e = xo(() => {
4207
+ e = null, Z();
4127
4208
  });
4128
- }, n = go(X.view.dom);
4209
+ }, n = bo(Y.view.dom);
4129
4210
  return window.addEventListener("scroll", t, { passive: !0 }), window.addEventListener("resize", t), n?.addEventListener("scroll", t, { passive: !0 }), t(), () => {
4130
- window.removeEventListener("scroll", t), window.removeEventListener("resize", t), n?.removeEventListener("scroll", t), e !== null && vo(e);
4211
+ window.removeEventListener("scroll", t), window.removeEventListener("resize", t), n?.removeEventListener("scroll", t), e !== null && So(e);
4131
4212
  };
4132
4213
  }, [
4133
- X,
4134
- Ze.length,
4135
- et
4214
+ Y,
4215
+ ut.length,
4216
+ Z
4136
4217
  ]);
4137
- let tt = q(() => jt({
4138
- revision: De,
4218
+ let Q = K(() => At({
4219
+ revision: Be,
4139
4220
  mode: M,
4140
- editable: P,
4141
- toc: $e,
4142
- selection: fe,
4143
- slash: me,
4144
- table: Ke,
4145
- tableInteraction: Ce,
4146
- codeBlock: Ge,
4147
- mermaid: Ye,
4148
- tableDebugSnapshot: Xe
4221
+ editable: F,
4222
+ toc: X,
4223
+ selection: xe,
4224
+ slash: U,
4225
+ table: at,
4226
+ tableInteraction: Ie,
4227
+ codeBlock: it,
4228
+ mermaid: ct,
4229
+ tableDebugSnapshot: lt
4149
4230
  }), [
4150
- Ge,
4231
+ it,
4151
4232
  M,
4152
- P,
4153
- Ye,
4154
- De,
4155
- fe,
4156
- me,
4157
- Xe,
4158
- Ke,
4159
- Ce,
4160
- $e
4233
+ F,
4234
+ ct,
4235
+ Be,
4236
+ xe,
4237
+ U,
4238
+ lt,
4239
+ at,
4240
+ Ie,
4241
+ X
4161
4242
  ]);
4162
- K(() => {
4163
- C?.(tt);
4164
- }, [C, tt]), K(() => {
4165
- k?.($e);
4166
- }, [k, $e]);
4167
- let nt = G((e, t) => {
4168
- if (!(!X || !P) && gn(e)) {
4169
- if (e.inputKind && !t?.emoji && !t?.uploadResult) {
4170
- ve(e);
4243
+ G(() => {
4244
+ S?.(Q);
4245
+ }, [S, Q]), G(() => {
4246
+ ne?.(X);
4247
+ }, [ne, X]);
4248
+ let pt = W((e, t) => {
4249
+ if (!Y || !F || !gn(e)) return;
4250
+ if (e.inputKind && !t?.emoji && !t?.uploadResult) {
4251
+ De(e);
4252
+ return;
4253
+ }
4254
+ let n = Sn(Y.state);
4255
+ n && (je(null), Ce((e) => jn(e, { type: "execute" })), De(null), En(Y, e.id, n, t).then((e) => {
4256
+ if (e.ok && e.outcome === "applied") {
4257
+ Qe();
4171
4258
  return;
4172
4259
  }
4173
- bn(X, me, e, t), W((e) => Dn(e, { type: "execute" })), Le();
4174
- }
4260
+ e.ok || je(e.message), et(Y), Y.commands.focus();
4261
+ }));
4175
4262
  }, [
4176
- Le,
4177
- P,
4178
- X,
4179
- me
4180
- ]), rt = G((e) => {
4181
- W((t) => Dn(t, {
4263
+ Qe,
4264
+ F,
4265
+ Y,
4266
+ et
4267
+ ]), mt = W((e) => {
4268
+ Ce((t) => jn(t, {
4182
4269
  type: "set-active",
4183
4270
  index: e,
4184
- optionCount: Pe.length
4271
+ optionCount: Ye.length
4185
4272
  }));
4186
- }, [Pe.length]), it = G((e) => {
4187
- if (!X || _e || !P) return;
4188
- let t = _n(me, Pe, e.key, { isComposing: e.nativeEvent.isComposing || Ct(X.state) });
4273
+ }, [Ye.length]), ht = W((e) => {
4274
+ if (!Y || Ee || !F) return;
4275
+ if (U.name === "executing" && e.key === "Escape") {
4276
+ e.preventDefault(), Tn(Y).cancel(), Qe();
4277
+ return;
4278
+ }
4279
+ let t = _n(U, Ye, e.key, { isComposing: e.nativeEvent.isComposing || St(Y.state) });
4189
4280
  if (t.type !== "ignore") {
4190
4281
  if (t.type === "close") {
4191
- e.preventDefault(), W((e) => Dn(e, { type: "escape" })), Le();
4282
+ e.preventDefault(), Tn(Y).cancel(), Ce((e) => jn(e, { type: "escape" })), Qe();
4192
4283
  return;
4193
4284
  }
4194
4285
  if (t.type === "move-active") {
4195
- e.preventDefault(), W((e) => Dn(e, {
4286
+ e.preventDefault(), Ce((e) => jn(e, {
4196
4287
  type: "move-active",
4197
4288
  delta: t.delta,
4198
4289
  optionCount: t.optionCount
4199
4290
  }));
4200
4291
  return;
4201
4292
  }
4202
- t.type === "execute-active" && (e.preventDefault(), nt(t.command));
4293
+ if (t.type === "set-active") {
4294
+ e.preventDefault(), Ce((e) => jn(e, t));
4295
+ return;
4296
+ }
4297
+ t.type === "execute-active" && (e.preventDefault(), pt(t.command));
4203
4298
  }
4204
4299
  }, [
4205
- Le,
4206
- P,
4207
- X,
4208
- Pe,
4209
- nt,
4210
- _e,
4211
- me
4212
- ]), at = q(() => ({
4213
- closeSlashMenu: Le,
4214
- focusFirstTableBodyCell: () => X ? kn(X) : !1,
4300
+ Qe,
4301
+ F,
4302
+ Y,
4303
+ Ye,
4304
+ pt,
4305
+ Ee,
4306
+ U
4307
+ ]), gt = K(() => ({
4308
+ closeSlashMenu: Qe,
4309
+ focusFirstTableBodyCell: () => Y ? Nn(Y) : !1,
4215
4310
  setContent: (e, t = {}) => {
4216
- if (!X) return !1;
4217
- let n = kt(t.format);
4218
- return X.commands.setContent(e, {
4219
- contentType: Et(n),
4311
+ if (!Y) return !1;
4312
+ let n = Ot(t.format);
4313
+ return Y.commands.setContent(e, {
4314
+ contentType: Tt(n),
4220
4315
  emitUpdate: t.emitUpdate ?? !1
4221
- }), t.focusFirstTableBodyCell && kn(X), Be(X), P && ze(X), Ve(X), Fe(), !0;
4316
+ }), t.focusFirstTableBodyCell && Nn(Y), tt(Y), F && et(Y), nt(Y), Xe(), !0;
4222
4317
  }
4223
4318
  }), [
4224
- Le,
4225
- P,
4226
- X,
4227
- Fe,
4228
- Be,
4229
- ze,
4230
- Ve
4319
+ Qe,
4320
+ F,
4321
+ Y,
4322
+ Xe,
4323
+ tt,
4324
+ et,
4325
+ nt
4231
4326
  ]);
4232
4327
  return {
4233
- editor: X,
4234
- frameProps: q(() => ({
4328
+ editor: Y,
4329
+ frameProps: K(() => ({
4235
4330
  className: "markweave-editor-frame",
4236
- "aria-label": i ?? se.common.editorAriaLabel,
4331
+ role: "combobox",
4332
+ "aria-label": r ?? H.common.editorAriaLabel,
4333
+ "aria-expanded": we !== null && U.name !== "executing",
4334
+ "aria-controls": "markweave-slash-command-listbox",
4335
+ "aria-activedescendant": Ye.length && U.name !== "executing" ? `markweave-slash-command-option-${Math.min(Ye.length - 1, Math.max(0, U.activeIndex))}` : void 0,
4237
4336
  "data-testid": "markweave-editor-frame",
4238
4337
  "data-markweave-mode": M,
4239
- "aria-busy": L,
4240
- "data-markweave-large-document-loading": L ? "true" : "false",
4241
- "data-markweave-theme": te,
4242
- style: N ? { "--markweave-canvas": N } : void 0,
4243
- "data-markweave-inner-toc": p ? "true" : "false",
4244
- "data-markweave-inner-toc-placement": ne,
4245
- "data-mermaid-mode": Ye.mode,
4246
- "data-table-focus-mode": Ke.mode,
4247
- onKeyDownCapture: it
4338
+ "aria-busy": ce || U.name === "executing",
4339
+ "data-markweave-large-document-loading": ce ? "true" : "false",
4340
+ "data-markweave-theme": N,
4341
+ style: P ? { "--markweave-canvas": P } : void 0,
4342
+ "data-markweave-inner-toc": f ? "true" : "false",
4343
+ "data-markweave-inner-toc-placement": oe,
4344
+ "data-mermaid-mode": ct.mode,
4345
+ "data-table-focus-mode": at.mode,
4346
+ onKeyDownCapture: ht
4248
4347
  }), [
4249
- i,
4348
+ r,
4250
4349
  M,
4251
- it,
4252
- p,
4253
- L,
4254
- Ye.mode,
4255
- se.common.editorAriaLabel,
4350
+ Ye.length,
4351
+ ht,
4352
+ f,
4353
+ ce,
4354
+ ct.mode,
4355
+ H.common.editorAriaLabel,
4356
+ P,
4357
+ oe,
4256
4358
  N,
4257
- ne,
4258
- te,
4259
- Ke.mode
4359
+ we,
4360
+ U.activeIndex,
4361
+ U.name,
4362
+ at.mode
4260
4363
  ]),
4261
- overlayProps: q(() => ({
4262
- floatingToolbar: X && P ? {
4263
- editor: X,
4264
- lang: B,
4265
- messages: se,
4266
- selectionSnapshot: fe,
4364
+ overlayProps: K(() => ({
4365
+ floatingToolbar: Y && F ? {
4366
+ editor: Y,
4367
+ lang: V,
4368
+ messages: H,
4369
+ selectionSnapshot: xe,
4267
4370
  askAi: e,
4268
- onRewriteSelection: x,
4269
- onExtractToNote: b
4371
+ onRewriteSelection: b,
4372
+ onExtractToNote: y
4270
4373
  } : null,
4271
- slashCommandMenu: X && P ? {
4272
- commands: Pe,
4273
- state: me,
4274
- position: he,
4275
- inputCommand: _e,
4276
- messages: se,
4277
- onActiveIndexChange: rt,
4278
- onInputCommandChange: ve,
4279
- onSelect: nt,
4280
- onUpload: T
4374
+ slashCommandMenu: Y && F ? {
4375
+ commands: Ye,
4376
+ state: U,
4377
+ position: we,
4378
+ inputCommand: Ee,
4379
+ busy: U.name === "executing",
4380
+ error: Ae,
4381
+ messages: H,
4382
+ onActiveIndexChange: mt,
4383
+ onInputCommandChange: De,
4384
+ onSelect: pt,
4385
+ onUpload: k
4281
4386
  } : null,
4282
- tableControls: X && P ? {
4283
- editor: X,
4284
- active: Ke.active,
4285
- interactionState: Ce,
4286
- messages: se,
4287
- onCopyPayload: O,
4288
- onCommandResult: D,
4289
- onEditWithAi: y,
4387
+ tableControls: Y && F ? {
4388
+ editor: Y,
4389
+ active: at.active,
4390
+ interactionState: Ie,
4391
+ messages: H,
4392
+ onCopyPayload: j,
4393
+ onCommandResult: te,
4394
+ onEditWithAi: v,
4290
4395
  askAi: e
4291
4396
  } : null,
4292
- tableSelectionOverlay: X && P ? {
4293
- editor: X,
4294
- focusState: Ke
4397
+ tableSelectionOverlay: Y && F ? {
4398
+ editor: Y,
4399
+ focusState: at
4295
4400
  } : null,
4296
- codeBlockControls: X ? {
4297
- editor: X,
4298
- active: P && qe,
4299
- mermaidMode: ye,
4300
- onMermaidModeChange: be,
4301
- readOnly: !P
4401
+ codeBlockControls: Y ? {
4402
+ editor: Y,
4403
+ active: F && ot,
4404
+ mermaidMode: Me,
4405
+ onMermaidModeChange: Ne,
4406
+ readOnly: !F
4302
4407
  } : null,
4303
- innerToc: X && p && $e.items.length ? {
4304
- editor: X,
4305
- editable: P,
4306
- messages: se,
4307
- placement: ne,
4308
- state: $e
4408
+ innerToc: Y && f && X.items.length ? {
4409
+ editor: Y,
4410
+ editable: F,
4411
+ messages: H,
4412
+ placement: oe,
4413
+ state: X
4309
4414
  } : null,
4310
- mathEditorPopover: X && P && xe ? {
4311
- editor: X,
4312
- messages: se,
4313
- target: xe,
4314
- onClose: () => Se(null)
4415
+ mathEditorPopover: Y && F && Pe ? {
4416
+ editor: Y,
4417
+ messages: H,
4418
+ target: Pe,
4419
+ onClose: () => Fe(null)
4315
4420
  } : null
4316
4421
  }), [
4317
- P,
4422
+ F,
4318
4423
  e,
4319
- X,
4424
+ Y,
4425
+ Ye,
4426
+ f,
4427
+ ot,
4428
+ Me,
4429
+ H,
4320
4430
  Pe,
4321
- p,
4322
- qe,
4323
- ye,
4324
- se,
4325
- xe,
4431
+ v,
4326
4432
  y,
4327
4433
  b,
4328
- x,
4329
- T,
4330
- D,
4331
- O,
4332
- nt,
4333
- fe,
4334
- rt,
4335
- _e,
4336
- he,
4337
- me,
4338
- Ke,
4339
- Ce,
4340
- $e
4434
+ k,
4435
+ te,
4436
+ j,
4437
+ pt,
4438
+ xe,
4439
+ mt,
4440
+ Ee,
4441
+ Ae,
4442
+ we,
4443
+ U,
4444
+ at,
4445
+ Ie,
4446
+ X
4341
4447
  ]),
4342
- runtimeSnapshot: tt,
4343
- actions: at
4448
+ runtimeSnapshot: Q,
4449
+ actions: gt
4344
4450
  };
4345
4451
  }
4346
- function bo({ className: e, ...t }) {
4347
- let n = yo(t);
4452
+ function To({ className: e, ...t }) {
4453
+ let n = wo(t);
4348
4454
  if (!n.editor) return null;
4349
4455
  let r = [n.frameProps.className, e].filter(Boolean).join(" ");
4350
4456
  return /* @__PURE__ */ Q("section", {
4351
4457
  ...n.frameProps,
4352
4458
  className: r,
4353
4459
  children: [
4354
- n.overlayProps.floatingToolbar ? /* @__PURE__ */ Z(Fa, { ...n.overlayProps.floatingToolbar }) : null,
4355
- n.overlayProps.slashCommandMenu ? /* @__PURE__ */ Z(ro, { ...n.overlayProps.slashCommandMenu }) : null,
4356
- n.overlayProps.tableControls ? /* @__PURE__ */ Z(so, { ...n.overlayProps.tableControls }) : null,
4357
- n.overlayProps.tableSelectionOverlay ? /* @__PURE__ */ Z(co, { ...n.overlayProps.tableSelectionOverlay }) : null,
4358
- n.overlayProps.codeBlockControls ? /* @__PURE__ */ Z(pa, { ...n.overlayProps.codeBlockControls }) : null,
4359
- n.overlayProps.innerToc ? /* @__PURE__ */ Z(uo, { ...n.overlayProps.innerToc }) : null,
4360
- n.overlayProps.mathEditorPopover ? /* @__PURE__ */ Z(Ja, { ...n.overlayProps.mathEditorPopover }) : null,
4361
- /* @__PURE__ */ Z(a, { editor: n.editor })
4460
+ n.overlayProps.floatingToolbar ? /* @__PURE__ */ Z(za, { ...n.overlayProps.floatingToolbar }) : null,
4461
+ n.overlayProps.slashCommandMenu ? /* @__PURE__ */ Z(so, { ...n.overlayProps.slashCommandMenu }) : null,
4462
+ n.overlayProps.tableControls ? /* @__PURE__ */ Z(fo, { ...n.overlayProps.tableControls }) : null,
4463
+ n.overlayProps.tableSelectionOverlay ? /* @__PURE__ */ Z(po, { ...n.overlayProps.tableSelectionOverlay }) : null,
4464
+ n.overlayProps.codeBlockControls ? /* @__PURE__ */ Z(_a, { ...n.overlayProps.codeBlockControls }) : null,
4465
+ n.overlayProps.innerToc ? /* @__PURE__ */ Z(ho, { ...n.overlayProps.innerToc }) : null,
4466
+ n.overlayProps.mathEditorPopover ? /* @__PURE__ */ Z(Qa, { ...n.overlayProps.mathEditorPopover }) : null,
4467
+ /* @__PURE__ */ Z(i, { editor: n.editor })
4362
4468
  ]
4363
4469
  });
4364
4470
  }
4365
4471
  //#endregion
4366
- export { bo as MarkweaveEditor, St as createMarkweaveAiEditController, ua as createMarkweaveEditorExtensions, ua as createMarkweaveReactEditorExtensions, yo as useMarkweaveEditorController };
4472
+ export { To as MarkweaveEditor, xt as createMarkweaveAiEditController, ma as createMarkweaveEditorExtensions, ma as createMarkweaveReactEditorExtensions, wo as useMarkweaveEditorController };