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