@markweave/react 0.3.2 → 0.3.4

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,63 +1,67 @@
1
1
  import { createMarkweaveEditorExtensions as e } from "markweave/internal/editor-core/create-editor-extensions";
2
2
  import { getLocalizedSlashCommandSpecs as t, getMarkweaveMessages as n, normalizeMarkweaveLang as r } from "markweave/internal/i18n";
3
3
  import { EditorContent as i, NodeViewWrapper as a, ReactNodeViewRenderer as o, useEditor as s } from "@tiptap/react";
4
- import { AlertTriangle as c, AlignCenter as l, AlignJustify as u, AlignLeft as d, AlignRight as f, Bold as p, Braces as m, Captions as h, Check as g, CheckCircle2 as _, ChevronDown as v, ChevronUp as y, CircleX as b, Code2 as x, Copy as S, CornerDownLeft as C, Download as w, ExternalLink as T, Eye as E, Heading1 as D, Heading2 as O, Heading3 as k, Image as A, ImageUp as j, IndentDecrease as M, IndentIncrease as N, Info as P, Italic as F, Lightbulb as ee, Link2 as I, List as L, ListChecks as te, ListOrdered as R, Minus as z, MoreVertical as ne, Paperclip as re, Pencil as ie, Quote as ae, Replace as B, Sigma as V, SmilePlus as oe, Sparkles as se, Strikethrough as ce, Subscript as le, Superscript as ue, Table2 as de, Text as fe, Trash2 as pe, Type as me, Underline as he, Upload as ge, Video as _e } from "lucide-react";
5
- import { useCallback as H, useEffect as U, useLayoutEffect as W, useMemo as G, useRef as K, useState as q, useSyncExternalStore as ve } from "react";
6
- import { detectUploadSource as ye, getDirectUploadResult as be, resolveMarkweaveUploadResult as xe } from "markweave/internal/plugins/slash-command/upload";
7
- import { MarkweaveCoreImage as Se, MarkweaveCoreVideo as Ce, attrsFromMarkweaveImageUploadResult as we, attrsFromMarkweaveVideoUploadResult as Te, attrsFromMarkweaveVideoUrl as Ee, clampMarkweaveImageWidth as De, createMarkweaveImageUploadRequest as Oe, createMarkweaveVideoUploadRequest as ke, downloadMarkweaveImage as Ae, markweaveVideoIframeAllow as je, normalizeMarkweaveCoreImageAlign as Me, normalizeMarkweaveVideoEmbedUrl as J, numberAttribute as Ne, stringAttribute as Y } from "markweave/internal/plugins/media/core-media-nodes";
8
- import { getMarkweaveEditorModeState as Pe, isMarkweaveEditorLiveEditable as Fe, normalizeMarkweaveEditorMode as Ie, setMarkweaveEditorModeState as Le, subscribeToMarkweaveEditorMode as Re } from "markweave/internal/core/editor-mode-state";
9
- import { openMarkweaveImagePreview as ze } from "markweave/internal/plugins/media/image-preview";
10
- import { Fragment as X, jsx as Z, jsxs as Q } from "react/jsx-runtime";
11
- import { createMarkweaveAdapterMediaExtensions as Be } from "markweave/internal/plugins/media/media-extension-factory";
12
- import { normalizeMarkweaveLinkCardAttrs as Ve, normalizeMarkweaveLinkCardHref as He, replaceMarkweaveLinkCardWithLink as Ue } from "markweave/internal/plugins/link-card/link-card";
13
- import { openMarkweaveLinkCardComposer as We } from "markweave/internal/plugins/link-card/link-card-composer";
14
- import { MarkweaveLinkCard as Ge } from "markweave/internal/plugins/link-card/link-card-node";
15
- import { isEditorComposing as Ke } from "markweave/internal/editor-core/composition-guard";
16
- import { createMarkweaveEditorUpdatePayload as qe, getMarkweaveContentType as Je, isEditorContentCurrent as Ye, isMarkweaveControlledContentEchoCurrent as Xe, normalizeMarkweaveContentFormat as Ze } from "markweave/internal/editor-core/editor-content";
17
- import { openMarkweaveReadonlyLinkFromEvent as Qe } from "markweave/internal/editor-core/readonly-link";
18
- import { createMarkweaveEditorRuntimeSnapshot as $e } from "markweave/internal/editor-core/runtime-snapshot";
19
- import { advanceFloatingToolbarMotionState as et, areEditorSelectionSnapshotsEquivalent as tt, calculateFloatingToolbarFrameShift as nt, calculateFloatingToolbarPopoverPlacement as rt, calculateFloatingToolbarTopBoundary as it, createSelectionSnapshot as at, getFloatingToolbarFloatingOptions as ot, getFloatingToolbarState as st, markweaveRuntimeProjectionDelayMs as ct, shouldShowFloatingToolbar as lt, transitionFloatingToolbarState as ut } from "markweave/internal/editor-core/selection-state";
20
- import { codeBlockCollapsePluginKey as dt, copyActiveCodeBlock as ft, getActiveCodeBlockState as pt, getCodeBlockCopyFeedbackSnapshot as mt, markweaveCodeBlockBehavior as ht, setCodeBlockCollapsedAtPosition as gt, setCodeBlockLanguageAtPosition as _t, setCodeBlockMermaidPreviewModeAtPosition as vt } from "markweave/internal/plugins/codeblock/codeblock-behavior";
21
- import { isMermaidInlinePreviewTransaction as yt, setMarkweaveMermaidTheme as bt, setMermaidInlinePreviewEditorMode as xt, setReadonlyMermaidPreviewMode as St } from "markweave/internal/plugins/mermaid/mermaid-inline-preview";
22
- import { getMermaidPreviewState as Ct } from "markweave/internal/plugins/mermaid/mermaid-renderer";
23
- import { applyMarkweaveMathLatex as wt, calculateMarkweaveMathPopoverPosition as Tt, getMarkweaveMathAnchorRect as Et, getMarkweaveMathBlockIndex as Dt, getMarkweaveMathRenderedHtml as Ot, getMarkweaveMathTargetAtPos as kt, getMarkweaveMathTargetFromDomEvent as At, getMarkweaveMathTargetFromSelection as jt, renderMarkweaveMathPreview as Mt, setMarkweaveMathEditingDomState as Nt, setMarkweaveMathEditingDomStateInView as Pt, setMarkweaveMathSelectionInView as Ft } from "markweave/internal/plugins/math/math-ui-model";
24
- import { filterSlashCommands as It, isExecutableSlashCommand as Lt } from "markweave/internal/plugins/slash-command/command-spec";
25
- import { getSlashCommandKeyboardAction as Rt, isSlashCommandMenuState as zt } from "markweave/internal/plugins/slash-command/slash-keyboard";
26
- import { executeSlashCommand as Bt, getNextSlashCommandState as Vt, getSlashCommandAnchoredMenuPosition as Ht, getSlashCommandContext as Ut } from "markweave/internal/plugins/slash-command/slash-runtime";
27
- import { initialSlashCommandState as Wt, reduceSlashCommandState as Gt } from "markweave/internal/plugins/slash-command/slash-state";
28
- import { getFirstTableDebugSnapshot as Kt } from "markweave/internal/plugins/table/table-debug-snapshot";
29
- import { focusFirstTableBodyCell as qt } from "markweave/internal/plugins/table/table-focus-position";
30
- import { getTableFocusState as Jt } from "markweave/internal/plugins/table/table-focus-state";
31
- import { getTableSelectionOverlayState as Yt, initialTableInteractionState as Xt, tableInteractionPluginKey as Zt } from "markweave/internal/plugins/table/table-interaction-layer";
32
- import { calculateCodeBlockLanguageMenuPosition as Qt, clampFullscreenScale as $t, codeBlockCopyFeedbackTimeoutMs as en, copyCodeBlockText as tn, createCodeBlockOverlayPosition as nn, createMermaidFullscreenViewerState as rn, createMermaidTabPosition as an, focusCodeBlockTarget as on, formatCodeBlockLanguageLabel as sn, formatFullscreenZoom as cn, getActiveCodeBlockElement as ln, getAnchoredRect as un, getCodeBlockLanguageItems as dn, getCodeBlockPositionFromEventTarget as fn, getCodeBlockStateAtPosition as pn, getFrameElement as mn, getMermaidCodeBlockTargets as hn, getMermaidSvgMarkup as gn, isCodeBlockTargetCollapsed as _n, mergeStableMermaidTabPositions as vn, mermaidFullscreenZoomStep as yn, moveMermaidFullscreenViewer as bn } from "markweave/internal/plugins/codeblock/codeblock-ui-model";
33
- import { BubbleMenu as xn } from "@tiptap/react/menus";
34
- import { createMarkweaveFrameScheduler as Sn } from "markweave/internal/editor-core/frame-scheduler";
35
- import { applyFloatingToolbarLink as Cn, createFloatingToolbarAssistantRequest as wn, getFloatingToolbarButtonModels as Tn, getFloatingToolbarHighlightColorOptions as En, getFloatingToolbarLinkHref as Dn, getFloatingToolbarMessageSet as On, getFloatingToolbarMoreActions as kn, getFloatingToolbarTextColorOptions as An, getFloatingToolbarTooltipModel as jn, getFloatingToolbarTurnIntoOptions as Mn, isFloatingToolbarMoreActionActive as Nn, isFloatingToolbarTurnIntoActive as Pn, openFloatingToolbarLinkHref as Fn, preventFloatingToolbarPointerFocusLoss as In, removeFloatingToolbarLink as Ln, runFloatingToolbarMoreAction as Rn, setFloatingToolbarHighlightColor as zn, setFloatingToolbarTextColor as Bn, setFloatingToolbarTurnInto as Vn } from "markweave/internal/editor-core/floating-toolbar-model";
36
- import { normalizeMarkdownLinkHref as Hn } from "markweave/internal/plugins/markdown/markdown-input";
37
- import { setMarkweaveTableMenuAxisTarget as Un } from "markweave/internal/plugins/table/table-clipboard";
38
- import { calculateAnchoredTableMenuPosition as Wn, calculateTableEdgeHandlePosition as Gn, canRunTableCommand as Kn, executeTableMenuCommand as qn, formatTableCopyFeedback as Jn, getActiveTableElement as Yn, getAvailableCellMenuCommandSpecs as Xn, getTableAxisTargetRect as Zn, getTableControlAxisSelectionModel as Qn, getTableEditWithAiRequest as $n, getTableMenuItemGroup as er, getTableMenuItemLabel as tr, getTableMenuItems as nr, getTableSelectionTargetRect as rr, measureTableSelectionOverlay as ir, selectTableAxisFromCell as ar, tableCopyFeedbackTimeoutMs as or, tableMenuLabel as sr } from "markweave/internal/plugins/table/table-ui-model";
39
- import { createMarkweaveTocState as cr, emptyMarkweaveTocState as lr, getActiveMarkweaveTocId as ur, getMarkweaveTocItems as dr, getValidMarkweaveTocActiveId as fr, normalizeMarkweaveInnerTocPlacement as pr, observeMarkweaveInnerTocContainerPosition as mr, scrollToMarkweaveTocItem as hr } from "markweave/internal/core/toc-state";
40
- import { normalizeMarkweaveCanvasColor as gr, normalizeMarkweaveTheme as _r } from "markweave/internal/core/theme";
41
- import { createMarkweaveSearchController as vr } from "markweave/internal/plugins/search/search-controller";
4
+ 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 O, Check as k, CheckCircle2 as A, ChevronDown as j, ChevronRight as M, ChevronUp as ee, CircleX as N, Code2 as te, Copy as P, CornerDownLeft as ne, Download as F, ExternalLink as I, Eye as L, Heading1 as re, Heading2 as R, Heading3 as ie, Image as ae, ImageUp as z, IndentDecrease as B, IndentIncrease as oe, Info as se, Italic as ce, Lightbulb as le, Link2 as V, List as ue, ListChecks as H, ListOrdered as U, Minus as de, MoreVertical as fe, PaintBucket as pe, Paperclip as me, Pencil as he, Plus as ge, Quote as _e, Replace as ve, Sigma as ye, SmilePlus as be, Sparkles as xe, SquareX as Se, Strikethrough as Ce, Subscript as we, Superscript as Te, Table2 as Ee, TableCellsMerge as De, TableCellsSplit as Oe, Text as ke, Trash2 as Ae, Type as je, Underline as Me, Upload as Ne, Video as Pe } from "lucide-react";
5
+ import { useCallback as W, useEffect as G, useLayoutEffect as K, useMemo as q, useRef as J, useState as Y, useSyncExternalStore as Fe } from "react";
6
+ import { detectUploadSource as Ie, getDirectUploadResult as Le, resolveMarkweaveUploadResult as X } from "markweave/internal/plugins/slash-command/upload";
7
+ import { MarkweaveCoreImage as Re, MarkweaveCoreVideo as ze, attrsFromMarkweaveImageUploadResult as Be, attrsFromMarkweaveVideoUploadResult as Ve, attrsFromMarkweaveVideoUrl as He, clampMarkweaveImageWidth as Ue, createMarkweaveImageUploadRequest as We, createMarkweaveVideoUploadRequest as Ge, downloadMarkweaveImage as Ke, markweaveVideoIframeAllow as qe, normalizeMarkweaveCoreImageAlign as Je, normalizeMarkweaveVideoEmbedUrl as Ye, numberAttribute as Xe, stringAttribute as Ze } from "markweave/internal/plugins/media/core-media-nodes";
8
+ import { getMarkweaveEditorModeState as Qe, isMarkweaveEditorLiveEditable as $e, normalizeMarkweaveEditorMode as et, setMarkweaveEditorModeState as tt, subscribeToMarkweaveEditorMode as nt } from "markweave/internal/core/editor-mode-state";
9
+ import { openMarkweaveImagePreview as rt } from "markweave/internal/plugins/media/image-preview";
10
+ import { createMarkweaveLightweightImageNodeViewRenderer as it } from "markweave/internal/plugins/media/lightweight-image-node-view";
11
+ import { resolveMarkweaveMediaSource as at } from "markweave/internal/plugins/media/media-source";
12
+ import { Fragment as ot, jsx as Z, jsxs as Q } from "react/jsx-runtime";
13
+ import { createMarkweaveAdapterMediaExtensions as st } from "markweave/internal/plugins/media/media-extension-factory";
14
+ import { normalizeMarkweaveLinkCardAttrs as ct, normalizeMarkweaveLinkCardHref as lt, replaceMarkweaveLinkCardWithLink as ut } from "markweave/internal/plugins/link-card/link-card";
15
+ import { openMarkweaveLinkCardComposer as dt } from "markweave/internal/plugins/link-card/link-card-composer";
16
+ import { MarkweaveLinkCard as ft } from "markweave/internal/plugins/link-card/link-card-node";
17
+ import { isEditorComposing as pt } from "markweave/internal/editor-core/composition-guard";
18
+ import { createMarkweaveFrameScheduler as mt } from "markweave/internal/editor-core/frame-scheduler";
19
+ import { createMarkweaveEditorUpdatePayload as ht, getMarkweaveContentType as gt, isEditorContentCurrent as _t, isMarkweaveControlledContentEchoCurrent as vt, normalizeMarkweaveContentFormat as yt } from "markweave/internal/editor-core/editor-content";
20
+ import { openMarkweaveReadonlyLinkFromEvent as bt } from "markweave/internal/editor-core/readonly-link";
21
+ import { createMarkweaveEditorRuntimeSnapshot as xt } from "markweave/internal/editor-core/runtime-snapshot";
22
+ import { advanceFloatingToolbarMotionState as St, areEditorSelectionSnapshotsEquivalent as Ct, calculateFloatingToolbarFrameShift as wt, calculateFloatingToolbarPopoverPlacement as Tt, calculateFloatingToolbarTopBoundary as Et, createSelectionSnapshot as Dt, getFloatingToolbarFloatingOptions as Ot, getFloatingToolbarState as kt, markweaveRuntimeProjectionDelayMs as At, shouldShowFloatingToolbar as jt, transitionFloatingToolbarState as Mt } from "markweave/internal/editor-core/selection-state";
23
+ import { codeBlockCollapsePluginKey as Nt, copyActiveCodeBlock as Pt, getActiveCodeBlockState as Ft, getCodeBlockCopyFeedbackSnapshot as It, markweaveCodeBlockBehavior as Lt, setCodeBlockCollapsedAtPosition as Rt, setCodeBlockLanguageAtPosition as zt, setCodeBlockMermaidPreviewModeAtPosition as Bt } from "markweave/internal/plugins/codeblock/codeblock-behavior";
24
+ import { isMermaidInlinePreviewTransaction as Vt, setMarkweaveMermaidTheme as Ht, setMermaidInlinePreviewEditorMode as Ut, setReadonlyMermaidPreviewMode as Wt } from "markweave/internal/plugins/mermaid/mermaid-inline-preview";
25
+ import { getMermaidPreviewState as Gt } from "markweave/internal/plugins/mermaid/mermaid-renderer";
26
+ import { applyMarkweaveMathLatex as Kt, calculateMarkweaveMathPopoverPosition as qt, getMarkweaveMathAnchorRect as Jt, getMarkweaveMathBlockIndex as Yt, getMarkweaveMathRenderedHtml as Xt, getMarkweaveMathTargetAtPos as Zt, getMarkweaveMathTargetFromDomEvent as Qt, getMarkweaveMathTargetFromSelection as $t, renderMarkweaveMathPreview as en, setMarkweaveMathEditingDomState as tn, setMarkweaveMathEditingDomStateInView as nn, setMarkweaveMathSelectionInView as rn } from "markweave/internal/plugins/math/math-ui-model";
27
+ import { filterSlashCommands as an, isExecutableSlashCommand as on } from "markweave/internal/plugins/slash-command/command-spec";
28
+ import { getSlashCommandKeyboardAction as sn, isSlashCommandMenuState as cn } from "markweave/internal/plugins/slash-command/slash-keyboard";
29
+ import { areSlashCommandMenuPositionsEquivalent as ln, executeSlashCommand as un, getNextSlashCommandState as dn, getSlashCommandAnchoredMenuPosition as fn, getSlashCommandContext as pn, isSlashCommandAnchorVisible as mn } from "markweave/internal/plugins/slash-command/slash-runtime";
30
+ import { initialSlashCommandState as hn, reduceSlashCommandState as gn } from "markweave/internal/plugins/slash-command/slash-state";
31
+ import { getFirstTableDebugSnapshot as _n } from "markweave/internal/plugins/table/table-debug-snapshot";
32
+ import { focusFirstTableBodyCell as vn } from "markweave/internal/plugins/table/table-focus-position";
33
+ import { getTableFocusState as yn } from "markweave/internal/plugins/table/table-focus-state";
34
+ import { getTableSelectionOverlayState as bn, initialTableInteractionState as xn, tableInteractionPluginKey as Sn } from "markweave/internal/plugins/table/table-interaction-layer";
35
+ import { saveMarkweaveBrowserFile as Cn } from "markweave/internal/core/browser-file-save";
36
+ import { calculateCodeBlockLanguageMenuPosition as wn, clampFullscreenScale as Tn, codeBlockCopyFeedbackTimeoutMs as En, copyCodeBlockText as Dn, createCodeBlockLanguageMenuDomId as On, createCodeBlockOverlayPosition as kn, createMermaidFullscreenViewerState as An, createMermaidTabPosition as jn, focusCodeBlockTarget as Mn, formatCodeBlockLanguageLabel as Nn, formatFullscreenZoom as Pn, getActiveCodeBlockElement as Fn, getAnchoredRect as In, getCodeBlockLanguageItems as Ln, getCodeBlockLanguageOptionDomId as Rn, getCodeBlockPositionFromEventTarget as zn, getCodeBlockStateAtPosition as Bn, getFrameElement as Vn, getInitialCodeBlockLanguageItemIndex as Hn, getMermaidCodeBlockTargets as Un, getMermaidSvgMarkup as Wn, isCodeBlockTargetCollapsed as Gn, mergeStableMermaidTabPositions as Kn, mermaidFullscreenZoomStep as qn, moveCodeBlockLanguageItemIndex as Jn, moveMermaidFullscreenViewer as Yn, scrollCodeBlockLanguageItemIntoView as Xn } from "markweave/internal/plugins/codeblock/codeblock-ui-model";
37
+ import { BubbleMenu as Zn } from "@tiptap/react/menus";
38
+ import { applyFloatingToolbarLink as Qn, createFloatingToolbarAssistantRequest as $n, getFloatingToolbarButtonModels as er, getFloatingToolbarHighlightColorOptions as tr, getFloatingToolbarLinkHref as nr, getFloatingToolbarMessageSet as rr, getFloatingToolbarMoreActions as ir, getFloatingToolbarTextColorOptions as ar, getFloatingToolbarTooltipModel as or, getFloatingToolbarTurnIntoOptions as sr, isFloatingToolbarMoreActionActive as cr, isFloatingToolbarTurnIntoActive as lr, openFloatingToolbarLinkHref as ur, preventFloatingToolbarPointerFocusLoss as dr, removeFloatingToolbarLink as fr, runFloatingToolbarMoreAction as pr, setFloatingToolbarHighlightColor as mr, setFloatingToolbarTextColor as hr, setFloatingToolbarTurnInto as gr } from "markweave/internal/editor-core/floating-toolbar-model";
39
+ import { normalizeMarkdownLinkHref as _r } from "markweave/internal/plugins/markdown/markdown-input";
40
+ import { setMarkweaveTableMenuAxisTarget as vr } from "markweave/internal/plugins/table/table-clipboard";
41
+ import { applyTableAxisAlignment as yr, applyTableAxisBackgroundColor as br, applyTableAxisTextColor as xr, calculateAnchoredTableMenuPosition as Sr, calculateAnchoredTableSubmenuPosition as Cr, calculateTableAxisHandleLayout as wr, calculateTableExtendButtonLayout as Tr, canRunTableCommand as Er, executeTableMenuCommand as Dr, formatTableCopyFeedback as Or, getActiveTableElement as kr, getTableAxisDropIndexAtPoint as Ar, getTableAxisFormattingState as jr, getTableAxisTargetRect as Mr, getTableControlAxisSelectionModel as Nr, getTableEditWithAiRequest as Pr, getTableMenuBoundaryRect as Fr, getTableMenuItemGroup as Ir, getTableMenuItemLabel as Lr, getTableMenuItems as Rr, getTableSelectionTargetRect as zr, measureTableSelectionOverlay as Br, moveTargetedTableAxis as Vr, selectTableAxisFromCell as Hr, tableColorOptions as Ur, tableCopyFeedbackTimeoutMs as Wr, tableHorizontalAlignmentOptions as Gr, tableMenuLabel as Kr, tableVerticalAlignmentOptions as qr, targetTableAxisFromCell as Jr } from "markweave/internal/plugins/table/table-ui-model";
42
+ import { createMarkweaveTocState as Yr, emptyMarkweaveTocState as Xr, getActiveMarkweaveTocId as Zr, getMarkweaveTocItemsFromState as Qr, getValidMarkweaveTocActiveId as $r, normalizeMarkweaveInnerTocPlacement as ei, observeMarkweaveInnerTocContainerPosition as ti, scrollToMarkweaveTocItem as ni } from "markweave/internal/core/toc-state";
43
+ import { normalizeMarkweaveCanvasColor as ri, normalizeMarkweaveTheme as ii } from "markweave/internal/core/theme";
44
+ import { splitMarkweaveLargeMarkdown as ai } from "markweave/internal/core/large-document";
45
+ import { createMarkweaveSearchController as oi } from "markweave/internal/plugins/search/search-controller";
42
46
  //#region src/editor-mode-state.ts
43
- var yr = {
47
+ var si = {
44
48
  mode: "live",
45
49
  editable: !0
46
50
  };
47
- function br(e) {
48
- return ve((t) => Re(e, t), () => Pe(e), () => yr);
51
+ function ci(e) {
52
+ return Fe((t) => nt(e, t), () => Qe(e), () => si);
49
53
  }
50
54
  //#endregion
51
55
  //#region src/media/image-node.tsx
52
- var xr = Me;
53
- function Sr(e) {
56
+ var li = Je;
57
+ function ui(e) {
54
58
  return e instanceof Element && !!e.closest("[data-markweave-image-ui=\"true\"]");
55
59
  }
56
- function Cr(e) {
57
- let { deleteNode: t, editor: r, getPos: i, node: o, selected: s, updateAttributes: c } = e, l = e.extension.options, u = l.messages ?? n("zh"), d = u.image, f = Fe(br(r)), p = Y(o.attrs.src), m = xr(o.attrs.align), h = Ne(o.attrs.width), g = Y(o.attrs.caption), _ = K(null), v = K(null), [y, b] = q(!1), [x, S] = q(!1), [C, w] = q(!1), [T, D] = q(""), [O, k] = q(null), [A, j] = q(!1), [M, N] = q(!!g), [P, F] = q(g ?? ""), ee = f && (!p || x), I = () => {
58
- p && ze({
59
- src: p,
60
- alt: Y(o.attrs.alt) ?? "",
60
+ function di(e) {
61
+ let { deleteNode: t, editor: r, getPos: i, node: o, selected: s, updateAttributes: c } = e, l = e.extension.options, u = l.messages ?? n("zh"), d = u.image, f = $e(ci(r)), p = Ze(o.attrs.src), m = li(o.attrs.align), h = Xe(o.attrs.width), g = Ze(o.attrs.caption), _ = J(null), v = _i(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, M] = Y(!1), [ee, N] = Y(!!g), [te, P] = Y(g ?? ""), ne = f && (!p || C), F = () => {
62
+ y && rt({
63
+ src: y,
64
+ alt: Ze(o.attrs.alt) ?? "",
61
65
  messages: {
62
66
  dialogAriaLabel: d.previewDialogAriaLabel,
63
67
  zoomOut: d.previewZoomOut,
@@ -67,63 +71,63 @@ function Cr(e) {
67
71
  }
68
72
  });
69
73
  };
70
- U(() => {
71
- M || F(g ?? "");
72
- }, [g, M]);
73
- let L = () => {
74
+ G(() => {
75
+ ee || P(g ?? "");
76
+ }, [g, ee]);
77
+ let I = () => {
74
78
  if (!f) return;
75
79
  let e = i();
76
80
  typeof e == "number" && r.chain().focus().setNodeSelection(e).run();
77
- }, te = () => {
81
+ }, re = () => {
78
82
  if (f) {
79
- if (D(""), k(null), w(!1), p) {
80
- S(!1);
83
+ if (O(""), A(null), E(!1), p) {
84
+ w(!1);
81
85
  return;
82
86
  }
83
87
  t();
84
88
  }
85
89
  }, R = async (e) => {
86
90
  if (f) {
87
- k(null), j(!0);
91
+ A(null), M(!0);
88
92
  try {
89
- let t = await xe(Oe(e, p && x ? "image-replace" : "image-insert"), l.onUpload);
90
- c(we(o.attrs, t)), S(!1), D("");
93
+ let t = await X(We(e, p && C ? "image-replace" : "image-insert"), l.onUpload);
94
+ c(Be(o.attrs, t)), w(!1), O("");
91
95
  } catch (e) {
92
- k(e instanceof Error ? e.message : d.uploadFailedError);
96
+ A(e instanceof Error ? e.message : d.uploadFailedError);
93
97
  } finally {
94
- j(!1), w(!1);
98
+ M(!1), E(!1);
95
99
  }
96
100
  }
97
- }, z = () => {
101
+ }, ie = () => {
98
102
  if (f) {
99
- if (!T.trim()) {
100
- k(d.uploadRequiredError);
103
+ if (!D.trim()) {
104
+ A(d.uploadRequiredError);
101
105
  return;
102
106
  }
103
- R(ye(T));
107
+ R(Ie(D));
104
108
  }
105
- }, ne = (e) => {
109
+ }, ae = (e) => {
106
110
  !f || !e || R({
107
111
  type: "file",
108
112
  file: e,
109
113
  mimeType: e.type
110
114
  });
111
- }, re = (e) => {
112
- ne(e.currentTarget.files?.[0] ?? null), e.currentTarget.value = "";
113
- }, ie = (e) => {
114
- e.preventDefault(), e.stopPropagation(), f && ne(e.dataTransfer.files?.[0] ?? null);
115
- }, ae = () => {
116
- f && (N((e) => !e), M || F(g ?? ""));
115
+ }, z = (e) => {
116
+ ae(e.currentTarget.files?.[0] ?? null), e.currentTarget.value = "";
117
117
  }, B = (e) => {
118
- f && (F(e), c({ caption: e.trim() ? e : null }));
119
- }, V = (e, t) => {
118
+ e.preventDefault(), e.stopPropagation(), f && ae(e.dataTransfer.files?.[0] ?? null);
119
+ }, oe = () => {
120
+ f && (N((e) => !e), ee || P(g ?? ""));
121
+ }, se = (e) => {
122
+ f && (P(e), c({ caption: e.trim() ? e : null }));
123
+ }, ce = (e, t) => {
120
124
  if (t.preventDefault(), t.stopPropagation(), !f) return;
121
- L();
125
+ I();
122
126
  let n = _.current;
123
127
  if (!n) return;
124
128
  let r = t.clientX, i = n.getBoundingClientRect().width || h || 320, a = n.closest(".markweave-editor-surface")?.getBoundingClientRect().width ?? n.parentElement?.getBoundingClientRect().width ?? i, o = (t) => {
125
129
  let n = e === "right" ? t.clientX - r : r - t.clientX;
126
- c({ width: De(i + n, a) });
130
+ c({ width: Ue(i + n, a) });
127
131
  }, s = () => {
128
132
  window.removeEventListener("pointermove", o), window.removeEventListener("pointerup", s);
129
133
  };
@@ -135,59 +139,66 @@ function Cr(e) {
135
139
  "data-testid": "markweave-image-node",
136
140
  "data-align": m,
137
141
  "data-selected": f && s ? "true" : "false",
138
- "data-hovered": y ? "true" : "false",
139
- "data-empty": ee ? "true" : "false",
140
- onPointerEnter: () => b(!0),
141
- onPointerLeave: () => b(!1),
142
+ "data-hovered": x ? "true" : "false",
143
+ "data-empty": ne ? "true" : "false",
144
+ onPointerEnter: () => S(!0),
145
+ onPointerLeave: () => S(!1),
142
146
  onMouseDown: (e) => {
143
- f && !Sr(e.target) && L();
147
+ f && !ui(e.target) && I();
144
148
  },
145
- children: ee ? /* @__PURE__ */ Z(wr, {
146
- dragActive: C,
147
- error: O,
148
- inputValue: T,
149
- isSubmitting: A,
150
- fileInputRef: v,
149
+ children: ne ? /* @__PURE__ */ Z(fi, {
150
+ dragActive: T,
151
+ error: k,
152
+ inputValue: D,
153
+ isSubmitting: j,
154
+ fileInputRef: b,
151
155
  messages: u,
152
- onCancel: te,
153
- onDrop: ie,
154
- onDragActiveChange: w,
155
- onFileChange: re,
156
- onInputChange: D,
157
- onSubmit: z
158
- }) : /* @__PURE__ */ Q(X, { children: [
159
- f ? /* @__PURE__ */ Z(Tr, {
156
+ onCancel: re,
157
+ onDrop: B,
158
+ onDragActiveChange: E,
159
+ onFileChange: z,
160
+ onInputChange: O,
161
+ onSubmit: ie
162
+ }) : /* @__PURE__ */ Q(ot, { children: [
163
+ f ? /* @__PURE__ */ Z(pi, {
160
164
  align: m,
161
- captionActive: M || !!g,
165
+ captionActive: ee || !!g,
162
166
  messages: u,
163
167
  onAlign: (e) => c({ align: e }),
164
- onCaption: ae,
168
+ onCaption: oe,
165
169
  onDelete: t,
166
170
  onDownload: () => {
167
- p && Ae(p);
171
+ y && Ke(y);
168
172
  },
169
- onPreview: I,
173
+ onPreview: F,
170
174
  onReplace: () => {
171
- D(""), k(null), S(!0);
175
+ O(""), A(null), w(!0);
172
176
  }
173
177
  }) : null,
174
178
  /* @__PURE__ */ Q("div", {
175
179
  className: "markweave-image-box",
176
180
  ref: _,
177
- style: h ? { width: `${h}px` } : void 0,
181
+ style: {
182
+ ...h ? { width: `${h}px` } : null,
183
+ ...v?.width && v.height ? { aspectRatio: `${v.width} / ${v.height}` } : null
184
+ },
178
185
  children: [
179
- p ? /* @__PURE__ */ Z("img", {
186
+ y ? /* @__PURE__ */ Z("img", {
180
187
  className: "markweave-image",
181
- src: p,
182
- alt: Y(o.attrs.alt) ?? "",
183
- title: Y(o.attrs.title) ?? void 0,
184
- draggable: !1
188
+ src: y,
189
+ alt: Ze(o.attrs.alt) ?? "",
190
+ title: Ze(o.attrs.title) ?? void 0,
191
+ draggable: !1,
192
+ loading: "lazy",
193
+ decoding: "async",
194
+ width: v?.width,
195
+ height: v?.height
185
196
  }) : /* @__PURE__ */ Z("div", {
186
197
  className: "markweave-image-readonly-empty",
187
198
  "data-testid": "markweave-image-readonly-empty",
188
199
  "aria-hidden": "true"
189
200
  }),
190
- !f && p ? /* @__PURE__ */ Q("button", {
201
+ !f && y ? /* @__PURE__ */ Q("button", {
191
202
  type: "button",
192
203
  className: "markweave-image-preview-trigger",
193
204
  "data-testid": "markweave-image-preview",
@@ -195,8 +206,8 @@ function Cr(e) {
195
206
  "aria-label": d.preview,
196
207
  title: d.preview,
197
208
  onMouseDown: (e) => e.preventDefault(),
198
- onClick: I,
199
- children: [/* @__PURE__ */ Z(E, {
209
+ onClick: F,
210
+ children: [/* @__PURE__ */ Z(L, {
200
211
  size: 16,
201
212
  strokeWidth: 1.8
202
213
  }), /* @__PURE__ */ Z("span", {
@@ -205,26 +216,26 @@ function Cr(e) {
205
216
  children: d.preview
206
217
  })]
207
218
  }) : null,
208
- f ? /* @__PURE__ */ Z(Dr, {
219
+ f ? /* @__PURE__ */ Z(hi, {
209
220
  side: "left",
210
221
  messages: u,
211
- onPointerDown: V
222
+ onPointerDown: ce
212
223
  }) : null,
213
- f ? /* @__PURE__ */ Z(Dr, {
224
+ f ? /* @__PURE__ */ Z(hi, {
214
225
  side: "right",
215
226
  messages: u,
216
- onPointerDown: V
227
+ onPointerDown: ce
217
228
  }) : null
218
229
  ]
219
230
  }),
220
- f && (M || g) ? /* @__PURE__ */ Z("input", {
231
+ f && (ee || g) ? /* @__PURE__ */ Z("input", {
221
232
  className: "markweave-image-caption-input",
222
233
  "data-markweave-image-ui": "true",
223
234
  "data-testid": "markweave-image-caption-input",
224
- value: P,
235
+ value: te,
225
236
  placeholder: d.captionPlaceholder,
226
237
  "aria-label": d.captionAriaLabel,
227
- onChange: (e) => B(e.currentTarget.value),
238
+ onChange: (e) => se(e.currentTarget.value),
228
239
  onKeyDown: (e) => {
229
240
  e.key === "Escape" && (e.preventDefault(), N(!1));
230
241
  }
@@ -236,7 +247,7 @@ function Cr(e) {
236
247
  ] })
237
248
  });
238
249
  }
239
- function wr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitting: i, messages: a, onCancel: o, onDragActiveChange: s, onDrop: c, onFileChange: l, onInputChange: u, onSubmit: d }) {
250
+ function fi({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitting: i, messages: a, onCancel: o, onDragActiveChange: s, onDrop: c, onFileChange: l, onInputChange: u, onSubmit: d }) {
240
251
  let f = a.image;
241
252
  return /* @__PURE__ */ Q("section", {
242
253
  className: "markweave-image-upload-placeholder",
@@ -263,7 +274,7 @@ function wr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
263
274
  /* @__PURE__ */ Z("div", {
264
275
  className: "markweave-image-upload-icon",
265
276
  "aria-hidden": "true",
266
- children: /* @__PURE__ */ Z(j, {
277
+ children: /* @__PURE__ */ Z(z, {
267
278
  size: 46,
268
279
  strokeWidth: 1.6
269
280
  })
@@ -298,7 +309,7 @@ function wr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
298
309
  "data-testid": "markweave-image-upload-submit",
299
310
  disabled: i || !r.trim(),
300
311
  onClick: d,
301
- children: [/* @__PURE__ */ Z(j, {
312
+ children: [/* @__PURE__ */ Z(z, {
302
313
  size: 16,
303
314
  strokeWidth: 1.8
304
315
  }), a.common.insert]
@@ -318,7 +329,7 @@ function wr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
318
329
  ]
319
330
  });
320
331
  }
321
- function Tr({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i, onDelete: a, onDownload: o, onPreview: s, onReplace: c }) {
332
+ function pi({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i, onDelete: a, onDownload: o, onPreview: s, onReplace: c }) {
322
333
  let u = n.image;
323
334
  return /* @__PURE__ */ Q("div", {
324
335
  className: "markweave-image-toolbar",
@@ -326,21 +337,21 @@ function Tr({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i,
326
337
  "data-markweave-image-ui": "true",
327
338
  "aria-label": u.toolsAriaLabel,
328
339
  children: [
329
- /* @__PURE__ */ Z(Er, {
340
+ /* @__PURE__ */ Z(mi, {
330
341
  testId: "markweave-image-align-left",
331
342
  label: u.alignLeft,
332
343
  icon: d,
333
344
  active: e === "left",
334
345
  onClick: () => r("left")
335
346
  }),
336
- /* @__PURE__ */ Z(Er, {
347
+ /* @__PURE__ */ Z(mi, {
337
348
  testId: "markweave-image-align-center",
338
349
  label: u.alignCenter,
339
350
  icon: l,
340
351
  active: e === "center",
341
352
  onClick: () => r("center")
342
353
  }),
343
- /* @__PURE__ */ Z(Er, {
354
+ /* @__PURE__ */ Z(mi, {
344
355
  testId: "markweave-image-align-right",
345
356
  label: u.alignRight,
346
357
  icon: f,
@@ -351,45 +362,45 @@ function Tr({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i,
351
362
  className: "markweave-image-toolbar-divider",
352
363
  "aria-hidden": "true"
353
364
  }),
354
- /* @__PURE__ */ Z(Er, {
365
+ /* @__PURE__ */ Z(mi, {
355
366
  testId: "markweave-image-caption",
356
367
  label: u.caption,
357
- icon: h,
368
+ icon: O,
358
369
  active: t,
359
370
  onClick: i
360
371
  }),
361
- /* @__PURE__ */ Z(Er, {
372
+ /* @__PURE__ */ Z(mi, {
362
373
  testId: "markweave-image-preview",
363
374
  label: u.preview,
364
- icon: E,
375
+ icon: L,
365
376
  onClick: s
366
377
  }),
367
- /* @__PURE__ */ Z(Er, {
378
+ /* @__PURE__ */ Z(mi, {
368
379
  testId: "markweave-image-download",
369
380
  label: u.download,
370
- icon: w,
381
+ icon: F,
371
382
  onClick: o
372
383
  }),
373
- /* @__PURE__ */ Z(Er, {
384
+ /* @__PURE__ */ Z(mi, {
374
385
  testId: "markweave-image-replace",
375
386
  label: u.replace,
376
- icon: B,
387
+ icon: ve,
377
388
  onClick: c
378
389
  }),
379
390
  /* @__PURE__ */ Z("span", {
380
391
  className: "markweave-image-toolbar-divider",
381
392
  "aria-hidden": "true"
382
393
  }),
383
- /* @__PURE__ */ Z(Er, {
394
+ /* @__PURE__ */ Z(mi, {
384
395
  testId: "markweave-image-delete",
385
396
  label: u.delete,
386
- icon: pe,
397
+ icon: Ae,
387
398
  onClick: a
388
399
  })
389
400
  ]
390
401
  });
391
402
  }
392
- function Er({ active: e = !1, icon: t, label: n, onClick: r, testId: i }) {
403
+ function mi({ active: e = !1, icon: t, label: n, onClick: r, testId: i }) {
393
404
  return /* @__PURE__ */ Q("button", {
394
405
  type: "button",
395
406
  "aria-label": n,
@@ -408,7 +419,7 @@ function Er({ active: e = !1, icon: t, label: n, onClick: r, testId: i }) {
408
419
  })]
409
420
  });
410
421
  }
411
- function Dr({ messages: e, onPointerDown: t, side: n }) {
422
+ function hi({ messages: e, onPointerDown: t, side: n }) {
412
423
  return /* @__PURE__ */ Z("button", {
413
424
  type: "button",
414
425
  className: "markweave-image-resize-handle",
@@ -419,42 +430,95 @@ function Dr({ messages: e, onPointerDown: t, side: n }) {
419
430
  onPointerDown: (e) => t(n, e)
420
431
  });
421
432
  }
422
- var Or = Se.extend({
433
+ var gi = Re.extend({
423
434
  addOptions() {
424
435
  return {
425
436
  ...this.parent?.(),
426
437
  messages: n("zh"),
427
- onUpload: void 0
438
+ onUpload: void 0,
439
+ resolveMediaSource: void 0
428
440
  };
429
441
  },
430
442
  addNodeView() {
431
- return typeof document > "u" ? null : o(Cr, { stopEvent: ({ event: e }) => Sr(e.target) });
443
+ if (typeof document > "u") return null;
444
+ let e = o(di, { stopEvent: ({ event: e }) => ui(e.target) }), t = this.options.resolveMediaSource;
445
+ if (!t) return e;
446
+ let r = it({
447
+ messages: this.options.messages ?? n("zh"),
448
+ onUpload: this.options.onUpload,
449
+ resolveMediaSource: t
450
+ });
451
+ return (t) => Ze(t.node.attrs.src) ? r(t) : e(t);
432
452
  }
433
453
  });
454
+ function _i(e, t, n, r) {
455
+ let [i, a] = Y(t ? "background" : "visible"), [o, s] = Y(() => !t && e ? { src: e } : null);
456
+ return G(() => {
457
+ s(!t && e ? { src: e } : null), a(t ? "background" : "visible");
458
+ }, [t, e]), G(() => {
459
+ if (!t || !e) return;
460
+ if (r) {
461
+ a("visible");
462
+ return;
463
+ }
464
+ let i = n.current;
465
+ if (!i || typeof IntersectionObserver > "u") {
466
+ a("visible");
467
+ return;
468
+ }
469
+ let o = new IntersectionObserver((e) => {
470
+ let t = e[0];
471
+ if (!t?.isIntersecting) return;
472
+ let n = t.boundingClientRect, r = n.bottom >= 0 && n.top <= window.innerHeight;
473
+ a(r ? "visible" : "nearby");
474
+ }, { rootMargin: "300% 0px" });
475
+ return o.observe(i), () => o.disconnect();
476
+ }, [
477
+ n,
478
+ t,
479
+ r,
480
+ e
481
+ ]), G(() => {
482
+ if (!t || !e || i === "background") return;
483
+ let n = new AbortController();
484
+ return at(t, {
485
+ kind: "image",
486
+ priority: i,
487
+ signal: n.signal,
488
+ src: e
489
+ }).then((e) => {
490
+ n.signal.aborted || s(e);
491
+ }), () => n.abort();
492
+ }, [
493
+ i,
494
+ t,
495
+ e
496
+ ]), o;
497
+ }
434
498
  //#endregion
435
499
  //#region src/media/video-node.tsx
436
- function kr(e) {
500
+ function vi(e) {
437
501
  return e instanceof Element && !!e.closest("[data-markweave-video-ui=\"true\"], iframe[data-markweave-video-embed], video[data-markweave-video]");
438
502
  }
439
- function Ar(e) {
440
- let { deleteNode: t, editor: r, getPos: i, node: o, selected: s, updateAttributes: c } = e, l = e.extension.options, u = l.messages ?? n("zh"), d = u.video, f = Fe(br(r)), p = Y(o.attrs.src), m = Y(o.attrs.embedUrl), h = Y(o.attrs.provider), g = m ? J(m, h) : null, _ = Y(o.attrs.mimeType), v = Y(o.attrs.title), y = K(null), [b, x] = q(!1), [S, C] = q(""), [w, T] = q(null), [E, D] = q(!1), O = f && !p, k = () => {
503
+ function yi(e) {
504
+ let { deleteNode: t, editor: r, getPos: i, node: o, selected: s, updateAttributes: c } = e, l = e.extension.options, u = l.messages ?? n("zh"), d = u.video, f = $e(ci(r)), p = Ze(o.attrs.src), m = Ze(o.attrs.embedUrl), h = Ze(o.attrs.provider), g = m ? Ye(m, h) : null, _ = Ze(o.attrs.mimeType), v = Ze(o.attrs.title), y = J(null), [b, x] = Y(!1), [S, C] = Y(""), [w, T] = Y(null), [E, D] = Y(!1), O = f && !p, k = () => {
441
505
  if (!f) return;
442
506
  let e = i();
443
507
  typeof e == "number" && r.chain().focus().setNodeSelection(e).run();
444
508
  }, A = (e) => {
445
- f && (kr(e.target) || (e.preventDefault(), k()));
509
+ f && (vi(e.target) || (e.preventDefault(), k()));
446
510
  }, j = (e) => {
447
511
  f && (e.key === "Delete" || e.key === "Backspace") && s && (e.preventDefault(), t());
448
512
  }, M = async (e) => {
449
513
  if (!(!f || !e)) {
450
514
  T(null), D(!0);
451
515
  try {
452
- let t = await xe(ke({
516
+ let t = await X(Ge({
453
517
  type: "file",
454
518
  file: e,
455
519
  mimeType: e.type
456
520
  }), l.onUpload);
457
- c(Te(t)), C("");
521
+ c(Ve(t)), C("");
458
522
  } catch (e) {
459
523
  T(e instanceof Error ? e.message : d.uploadFailedError);
460
524
  } finally {
@@ -468,7 +532,7 @@ function Ar(e) {
468
532
  "data-testid": "markweave-video-node",
469
533
  "data-empty": "true",
470
534
  "data-selected": "false",
471
- children: /* @__PURE__ */ Z(jr, {
535
+ children: /* @__PURE__ */ Z(bi, {
472
536
  dragActive: b,
473
537
  error: w,
474
538
  fileInputRef: y,
@@ -486,7 +550,7 @@ function Ar(e) {
486
550
  onInputChange: C,
487
551
  onSubmit: () => {
488
552
  if (!f) return;
489
- let e = Ee(S);
553
+ let e = He(S);
490
554
  if (!e) {
491
555
  T(d.unsupportedUrlError);
492
556
  return;
@@ -515,7 +579,7 @@ function Ar(e) {
515
579
  "data-markweave-video-embed": "true",
516
580
  "data-markweave-video-provider": h ?? void 0,
517
581
  "data-markweave-video-src": p ?? void 0,
518
- allow: je,
582
+ allow: qe,
519
583
  loading: "lazy",
520
584
  allowFullScreen: !0
521
585
  }), f ? /* @__PURE__ */ Z("button", {
@@ -549,7 +613,7 @@ function Ar(e) {
549
613
  })
550
614
  });
551
615
  }
552
- function jr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitting: i, messages: a, onCancel: o, onDragActiveChange: s, onDrop: c, onFileChange: l, onInputChange: u, onSubmit: d }) {
616
+ function bi({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitting: i, messages: a, onCancel: o, onDragActiveChange: s, onDrop: c, onFileChange: l, onInputChange: u, onSubmit: d }) {
553
617
  let f = a.video;
554
618
  return /* @__PURE__ */ Q("section", {
555
619
  className: "markweave-video-upload-placeholder",
@@ -576,7 +640,7 @@ function jr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
576
640
  /* @__PURE__ */ Z("div", {
577
641
  className: "markweave-video-upload-icon",
578
642
  "aria-hidden": "true",
579
- children: /* @__PURE__ */ Z(_e, {
643
+ children: /* @__PURE__ */ Z(Pe, {
580
644
  size: 46,
581
645
  strokeWidth: 1.6
582
646
  })
@@ -611,7 +675,7 @@ function jr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
611
675
  "data-testid": "markweave-video-upload-submit",
612
676
  disabled: i || !r.trim(),
613
677
  onClick: d,
614
- children: [/* @__PURE__ */ Z(ge, {
678
+ children: [/* @__PURE__ */ Z(Ne, {
615
679
  size: 16,
616
680
  strokeWidth: 1.8
617
681
  }), a.common.insert]
@@ -631,67 +695,68 @@ function jr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
631
695
  ]
632
696
  });
633
697
  }
634
- var Mr = Ce.extend({
698
+ var xi = ze.extend({
635
699
  addOptions() {
636
700
  return {
637
701
  ...this.parent?.(),
638
702
  messages: n("zh"),
639
- onUpload: void 0
703
+ onUpload: void 0,
704
+ resolveMediaSource: void 0
640
705
  };
641
706
  },
642
707
  addNodeView() {
643
- return typeof document > "u" ? null : o(Ar, { stopEvent: ({ event: e }) => kr(e.target) });
708
+ return typeof document > "u" ? null : o(yi, { stopEvent: ({ event: e }) => vi(e.target) });
644
709
  }
645
710
  });
646
711
  //#endregion
647
712
  //#region src/link-card-node.tsx
648
- function Nr(e) {
713
+ function Si(e) {
649
714
  return e instanceof Element && !!e.closest("[data-markweave-link-card-ui=\"true\"]");
650
715
  }
651
- function Pr(e) {
716
+ function Ci(e) {
652
717
  return typeof navigator < "u" && navigator.clipboard?.writeText ? navigator.clipboard.writeText(e).catch(() => void 0) : Promise.resolve();
653
718
  }
654
- function Fr(e) {
719
+ function wi(e) {
655
720
  !e || typeof window > "u" || window.open(e, "_blank", "noopener,noreferrer");
656
721
  }
657
- function Ir(e) {
722
+ function Ti(e) {
658
723
  try {
659
724
  return new URL(e).host;
660
725
  } catch {
661
726
  return e;
662
727
  }
663
728
  }
664
- function Lr(e) {
665
- let { deleteNode: t, editor: r, getPos: i, node: o, updateAttributes: s } = e, c = e.extension.options, l = c.messages ?? n("zh"), u = l.linkCard, d = Fe(br(r)), f = Ve(o.attrs), [p, m] = q(!1), [h, g] = q(!1), [_, v] = q(!1), [y, b] = q(f?.title ?? ""), [x, C] = q(f?.href ?? ""), w = K(null);
666
- if (U(() => () => w.current?.abort(), []), U(() => {
667
- b(f?.title ?? ""), C(f?.href ?? ""), v(!1);
729
+ function Ei(e) {
730
+ let { deleteNode: t, editor: r, getPos: i, node: o, updateAttributes: s } = e, c = e.extension.options, l = c.messages ?? n("zh"), u = l.linkCard, d = $e(ci(r)), f = ct(o.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);
731
+ if (G(() => () => C.current?.abort(), []), G(() => {
732
+ b(f?.title ?? ""), S(f?.href ?? ""), v(!1);
668
733
  }, [f?.href, f?.title]), !f) return null;
669
- let T = async (e) => {
734
+ let w = async (e) => {
670
735
  e.preventDefault();
671
- let t = Ve({
736
+ let t = ct({
672
737
  ...f,
673
738
  href: x,
674
739
  title: y
675
740
  });
676
741
  if (!t) return;
677
- s(t), g(!1), w.current?.abort();
742
+ s(t), g(!1), C.current?.abort();
678
743
  let n = new AbortController();
679
- w.current = n;
744
+ C.current = n;
680
745
  try {
681
746
  let e = await c.resolver?.({
682
747
  href: t.href,
683
748
  title: t.title,
684
749
  signal: n.signal
685
750
  });
686
- !n.signal.aborted && e && s(Ve({
751
+ !n.signal.aborted && e && s(ct({
687
752
  ...t,
688
753
  ...e
689
754
  }) ?? t);
690
755
  } catch {}
691
- }, E = () => {
756
+ }, T = () => {
692
757
  let e = i();
693
- typeof e == "number" && Ue(r, e);
694
- }, D = _ ? null : f.imageUrl, O = Ir(f.href);
758
+ typeof e == "number" && ut(r, e);
759
+ }, E = _ ? null : f.imageUrl, D = Ti(f.href);
695
760
  return /* @__PURE__ */ Q(a, {
696
761
  as: "article",
697
762
  className: "markweave-link-card",
@@ -702,10 +767,10 @@ function Lr(e) {
702
767
  onMouseEnter: () => m(!0),
703
768
  onMouseLeave: () => m(!1),
704
769
  onMouseDown: (e) => {
705
- Nr(e.target) || e.preventDefault();
770
+ Si(e.target) || e.preventDefault();
706
771
  },
707
772
  onClick: (e) => {
708
- Nr(e.target) || (e.preventDefault(), Fr(f.href));
773
+ Si(e.target) || (e.preventDefault(), wi(f.href));
709
774
  },
710
775
  children: [
711
776
  /* @__PURE__ */ Q("a", {
@@ -717,13 +782,13 @@ function Lr(e) {
717
782
  children: [
718
783
  /* @__PURE__ */ Z("strong", { children: f.title }),
719
784
  f.description ? /* @__PURE__ */ Z("span", { children: f.description }) : null,
720
- /* @__PURE__ */ Z("small", { children: f.siteName ?? O })
785
+ /* @__PURE__ */ Z("small", { children: f.siteName ?? D })
721
786
  ]
722
787
  }), /* @__PURE__ */ Z("span", {
723
788
  className: "markweave-link-card-media",
724
789
  "aria-hidden": "true",
725
- children: D ? /* @__PURE__ */ Z("img", {
726
- src: D,
790
+ children: E ? /* @__PURE__ */ Z("img", {
791
+ src: E,
727
792
  alt: "",
728
793
  loading: "lazy",
729
794
  referrerPolicy: "no-referrer",
@@ -735,7 +800,7 @@ function Lr(e) {
735
800
  loading: "lazy",
736
801
  referrerPolicy: "no-referrer",
737
802
  onError: () => v(!0)
738
- }) : /* @__PURE__ */ Z("b", { children: O.slice(0, 1).toUpperCase() })
803
+ }) : /* @__PURE__ */ Z("b", { children: D.slice(0, 1).toUpperCase() })
739
804
  })]
740
805
  }),
741
806
  d && p ? /* @__PURE__ */ Q("div", {
@@ -743,24 +808,24 @@ function Lr(e) {
743
808
  "data-markweave-link-card-ui": "true",
744
809
  "aria-label": u.toolsAriaLabel,
745
810
  children: [
746
- /* @__PURE__ */ Z(Rr, {
811
+ /* @__PURE__ */ Z(Di, {
747
812
  label: u.convertToLink,
748
- icon: I,
749
- onClick: E,
813
+ icon: V,
814
+ onClick: T,
750
815
  testId: "markweave-link-card-convert"
751
816
  }),
752
- /* @__PURE__ */ Z(Rr, {
817
+ /* @__PURE__ */ Z(Di, {
753
818
  label: u.copyAddress,
754
- icon: S,
755
- onClick: () => void Pr(f.href),
819
+ icon: P,
820
+ onClick: () => void Ci(f.href),
756
821
  testId: "markweave-link-card-copy"
757
822
  }),
758
- /* @__PURE__ */ Z(Rr, {
823
+ /* @__PURE__ */ Z(Di, {
759
824
  label: u.edit,
760
- icon: ie,
825
+ icon: he,
761
826
  onClick: (e) => {
762
827
  let t = i();
763
- typeof t == "number" && We({
828
+ typeof t == "number" && dt({
764
829
  anchor: e.currentTarget,
765
830
  editor: r,
766
831
  messages: l,
@@ -773,9 +838,9 @@ function Lr(e) {
773
838
  },
774
839
  testId: "markweave-link-card-edit"
775
840
  }),
776
- /* @__PURE__ */ Z(Rr, {
841
+ /* @__PURE__ */ Z(Di, {
777
842
  label: u.delete,
778
- icon: pe,
843
+ icon: Ae,
779
844
  onClick: t,
780
845
  testId: "markweave-link-card-delete"
781
846
  })
@@ -785,7 +850,7 @@ function Lr(e) {
785
850
  className: "markweave-link-card-editor",
786
851
  "data-markweave-link-card-ui": "true",
787
852
  "data-testid": "markweave-link-card-editor",
788
- onSubmit: T,
853
+ onSubmit: w,
789
854
  children: [
790
855
  /* @__PURE__ */ Q("label", { children: [/* @__PURE__ */ Z("span", { children: u.titleLabel }), /* @__PURE__ */ Z("input", {
791
856
  "aria-label": u.titleLabel,
@@ -797,20 +862,20 @@ function Lr(e) {
797
862
  "aria-label": u.addressLabel,
798
863
  placeholder: u.addressPlaceholder,
799
864
  value: x,
800
- onChange: (e) => C(e.currentTarget.value)
865
+ onChange: (e) => S(e.currentTarget.value)
801
866
  })] }),
802
867
  /* @__PURE__ */ Z("button", {
803
868
  type: "submit",
804
869
  "aria-label": u.edit,
805
- disabled: !He(x),
806
- children: /* @__PURE__ */ Z(I, { size: 16 })
870
+ disabled: !lt(x),
871
+ children: /* @__PURE__ */ Z(V, { size: 16 })
807
872
  })
808
873
  ]
809
874
  }) : null
810
875
  ]
811
876
  });
812
877
  }
813
- function Rr({ icon: e, label: t, onClick: n, testId: r }) {
878
+ function Di({ icon: e, label: t, onClick: n, testId: r }) {
814
879
  return /* @__PURE__ */ Q("button", {
815
880
  type: "button",
816
881
  "aria-label": t,
@@ -827,7 +892,7 @@ function Rr({ icon: e, label: t, onClick: n, testId: r }) {
827
892
  })]
828
893
  });
829
894
  }
830
- var zr = Ge.extend({
895
+ var Oi = ft.extend({
831
896
  addOptions() {
832
897
  return {
833
898
  ...this.parent?.(),
@@ -836,37 +901,38 @@ var zr = Ge.extend({
836
901
  };
837
902
  },
838
903
  addNodeView() {
839
- return typeof document > "u" ? null : o(Lr, { stopEvent: ({ event: e }) => Nr(e.target) });
904
+ return typeof document > "u" ? null : o(Ei, { stopEvent: ({ event: e }) => Si(e.target) });
840
905
  }
841
906
  });
842
907
  //#endregion
843
908
  //#region src/create-editor-extensions.ts
844
- function Br(t = {}) {
909
+ function ki(t = {}) {
845
910
  return e({
846
911
  lang: t.lang,
847
912
  onImageUpload: t.onImageUpload,
848
- linkCardExtension: zr.configure({
913
+ linkCardExtension: Oi.configure({
849
914
  lang: t.lang,
850
915
  messages: n(t.lang),
851
916
  resolver: t.linkCardResolver
852
917
  }),
853
- mediaExtensions: Be({
854
- image: Or,
855
- video: Mr,
918
+ mediaExtensions: st({
919
+ image: gi,
920
+ video: xi,
856
921
  lang: t.lang,
857
922
  onImageUpload: t.onImageUpload,
858
- onVideoUpload: t.onVideoUpload
923
+ onVideoUpload: t.onVideoUpload,
924
+ resolveMediaSource: t.resolveMediaSource
859
925
  })
860
926
  });
861
927
  }
862
928
  //#endregion
863
929
  //#region src/ui/codeblock/CodeBlockControls.tsx
864
- function Vr(e) {
865
- 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", {
930
+ function Ai(e) {
931
+ return e === "clipboard" ? /* @__PURE__ */ Q(ot, { 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(ot, { children: [/* @__PURE__ */ Z("circle", {
866
932
  cx: "10",
867
933
  cy: "10",
868
934
  r: "5.5"
869
- }), /* @__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: [
935
+ }), /* @__PURE__ */ Z("path", { d: "m14 14 4 4" })] }) : e === "check" ? /* @__PURE__ */ Z("path", { d: "m5 11 4 4 8-9" }) : e === "expand" ? /* @__PURE__ */ Q(ot, { children: [
870
936
  /* @__PURE__ */ Z("path", { d: "M8 4H4v4" }),
871
937
  /* @__PURE__ */ Z("path", { d: "M4 4l5 5" }),
872
938
  /* @__PURE__ */ Z("path", { d: "M16 4h4v4" }),
@@ -875,11 +941,11 @@ function Vr(e) {
875
941
  /* @__PURE__ */ Z("path", { d: "m4 20 5-5" }),
876
942
  /* @__PURE__ */ Z("path", { d: "M16 20h4v-4" }),
877
943
  /* @__PURE__ */ Z("path", { d: "m20 20-5-5" })
878
- ] }) : e === "download" ? /* @__PURE__ */ Q(X, { children: [
944
+ ] }) : e === "download" ? /* @__PURE__ */ Q(ot, { children: [
879
945
  /* @__PURE__ */ Z("path", { d: "M12 4v10" }),
880
946
  /* @__PURE__ */ Z("path", { d: "m8 10 4 4 4-4" }),
881
947
  /* @__PURE__ */ Z("path", { d: "M5 19h14" })
882
- ] }) : 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: [
948
+ ] }) : e === "close" ? /* @__PURE__ */ Q(ot, { children: [/* @__PURE__ */ Z("path", { d: "M6 6l12 12" }), /* @__PURE__ */ Z("path", { d: "M18 6 6 18" })] }) : e === "zoomOut" ? /* @__PURE__ */ Q(ot, { children: [
883
949
  /* @__PURE__ */ Z("circle", {
884
950
  cx: "10",
885
951
  cy: "10",
@@ -887,7 +953,7 @@ function Vr(e) {
887
953
  }),
888
954
  /* @__PURE__ */ Z("path", { d: "M7.5 10h5" }),
889
955
  /* @__PURE__ */ Z("path", { d: "m14 14 4 4" })
890
- ] }) : e === "zoomIn" ? /* @__PURE__ */ Q(X, { children: [
956
+ ] }) : e === "zoomIn" ? /* @__PURE__ */ Q(ot, { children: [
891
957
  /* @__PURE__ */ Z("circle", {
892
958
  cx: "10",
893
959
  cy: "10",
@@ -896,9 +962,9 @@ function Vr(e) {
896
962
  /* @__PURE__ */ Z("path", { d: "M7.5 10h5" }),
897
963
  /* @__PURE__ */ Z("path", { d: "M10 7.5v5" }),
898
964
  /* @__PURE__ */ Z("path", { d: "m14 14 4 4" })
899
- ] }) : 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" });
965
+ ] }) : e === "reset" ? /* @__PURE__ */ Q(ot, { children: [/* @__PURE__ */ Z("path", { d: "M6.5 8.5A6 6 0 1 1 6 15" }), /* @__PURE__ */ Z("path", { d: "M6.5 8.5H3.5v-3" })] }) : /* @__PURE__ */ Z("path", { d: "m6 9 6 6 6-6" });
900
966
  }
901
- function Hr({ icon: e }) {
967
+ function ji({ icon: e }) {
902
968
  return /* @__PURE__ */ Z("svg", {
903
969
  viewBox: "0 0 24 24",
904
970
  "aria-hidden": "true",
@@ -909,63 +975,71 @@ function Hr({ icon: e }) {
909
975
  strokeLinecap: "round",
910
976
  strokeLinejoin: "round",
911
977
  strokeWidth: "1.8",
912
- children: Vr(e)
978
+ children: Ai(e)
913
979
  })
914
980
  });
915
981
  }
916
- function Ur({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, readOnly: i = !1 }) {
917
- let a = K(null), o = K(null), s = K(null), c = K({
982
+ function Mi({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, readOnly: i = !1 }) {
983
+ let a = J(null), o = J(null), s = J(null), c = J(null), l = J(null), u = J({
918
984
  active: !1,
919
985
  lastX: 0,
920
986
  lastY: 0
921
- }), [l, u] = q(null), [d, f] = q(null), [p, m] = q([]), [h, g] = q(null), [_, v] = q(!1), [y, b] = q(""), [x, S] = q(null), [C, w] = q(!1), [T, E] = q(null), [D, O] = q(null), [k, A] = q(!1), [j, M] = q(0), [N, P] = q(0), F = pt(t), ee = pn(t, l), I = !i && e && F.active && F.pos !== null ? {
922
- ...F,
923
- pos: F.pos,
987
+ }), [d, f] = Y(null), [p, m] = Y(null), [h, g] = Y([]), [_, v] = Y(null), [y, b] = Y(!1), [x, S] = Y(""), [C, w] = Y(-1), [T, E] = Y(null), [D, O] = Y(!1), [k, A] = Y(null), [j, M] = Y(null), [ee, N] = Y(!1), [te, P] = Y(0), [ne, F] = Y(0), I = Ft(t), L = Bn(t, d), re = !i && e && I.active && I.pos !== null ? {
988
+ ...I,
989
+ pos: I.pos,
924
990
  active: !0
925
- } : null, L = ee ?? I, te = L !== null, R = L?.language === "mermaid", z = _n(t, L), ne = te && L !== null && !z, re = !i, ie = sn(L ? L.language : "text"), ae = x?.status ?? "idle", B = L?.mermaidPreviewMode ?? n, V = R && B === "preview", oe = hn(t), se = `${N}|${oe.map((e) => `${e.pos}:${e.mermaidPreviewMode}:${e.text.length}`).join("|")}`, ce = G(() => dn(y.trim().toLowerCase()), [y]);
926
- if (U(() => {
927
- i && (v(!1), b(""));
928
- }, [i]), U(() => {
929
- if (!x) return;
991
+ } : null, R = L ?? re, ie = R !== null, ae = R?.language === "mermaid", z = Gn(t, R), B = ie && R !== null && !z, oe = !i, se = Nn(R ? R.language : "text"), ce = T?.status ?? "idle", le = R?.mermaidPreviewMode ?? n, V = ae && le === "preview", ue = Un(t), H = `${ne}|${ue.map((e) => `${e.pos}:${e.mermaidPreviewMode}:${e.text.length}`).join("|")}`, U = q(() => Ln(x.trim().toLowerCase()), [x]);
992
+ if (G(() => {
993
+ i && (b(!1), S(""), w(-1));
994
+ }, [i]), G(() => {
995
+ if (!T) return;
930
996
  let e = window.setTimeout(() => {
931
- S(null);
932
- }, en);
997
+ E(null);
998
+ }, En);
933
999
  return () => {
934
1000
  window.clearTimeout(e);
935
1001
  };
936
- }, [x]), U(() => {
937
- S(null), v(!1), b(""), E(null), O(null), A(!1);
1002
+ }, [T]), G(() => {
1003
+ E(null), b(!1), S(""), w(-1), A(null), M(null), N(!1);
938
1004
  }, [
939
1005
  e,
940
- L?.language,
941
- L?.pos,
942
- L?.text
943
- ]), U(() => {
1006
+ R?.language,
1007
+ R?.pos,
1008
+ R?.text
1009
+ ]), G(() => {
944
1010
  let e = ({ transaction: e }) => {
945
- e.getMeta(dt) && M((e) => e + 1);
1011
+ e.getMeta(Nt) && P((e) => e + 1);
946
1012
  };
947
1013
  return t.on("transaction", e), () => {
948
1014
  t.off("transaction", e);
949
1015
  };
950
- }, [t]), U(() => {
1016
+ }, [t]), G(() => {
951
1017
  let e = t.view.dom.closest(".markweave-editor-frame");
952
1018
  if (!e) return;
953
1019
  let n = (e) => {
954
- if (e.target instanceof Node && a.current?.contains(e.target) || _) return;
955
- let n = pn(t, fn(t, e.target)), r = n && !_n(t, n) ? n.pos : null;
956
- u((e) => e === r ? e : r);
1020
+ if (e.target instanceof Node && a.current?.contains(e.target) || y) return;
1021
+ let n = Bn(t, zn(t, e.target)), r = n && !Gn(t, n) ? n.pos : null;
1022
+ f((e) => e === r ? e : r);
957
1023
  }, r = () => {
958
- _ || u(null);
1024
+ y || f(null);
959
1025
  };
960
1026
  return e.addEventListener("mousemove", n), e.addEventListener("mouseleave", r), () => {
961
1027
  e.removeEventListener("mousemove", n), e.removeEventListener("mouseleave", r);
962
1028
  };
963
- }, [t, _]), U(() => {
964
- _ && s.current?.focus({ preventScroll: !0 });
965
- }, [_]), U(() => {
966
- if (!T) return;
1029
+ }, [t, y]), G(() => {
1030
+ y && s.current?.focus({ preventScroll: !0 });
1031
+ }, [y]), K(() => {
1032
+ if (!y || C < 0) return;
1033
+ let e = c.current, t = e?.querySelector(`[data-language-index="${C}"]`);
1034
+ e && t && Xn(e, t);
1035
+ }, [
1036
+ C,
1037
+ U,
1038
+ y
1039
+ ]), G(() => {
1040
+ if (!k) return;
967
1041
  let e = (e) => {
968
- e.key === "Escape" && (E(null), O(null), A(!1), c.current = {
1042
+ e.key === "Escape" && (A(null), M(null), N(!1), u.current = {
969
1043
  active: !1,
970
1044
  lastX: 0,
971
1045
  lastY: 0
@@ -974,33 +1048,33 @@ function Ur({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
974
1048
  return document.addEventListener("keydown", e), () => {
975
1049
  document.removeEventListener("keydown", e);
976
1050
  };
977
- }, [t, T]), U(() => {
978
- if (!te || !_) return;
1051
+ }, [t, k]), G(() => {
1052
+ if (!ie || !y) return;
979
1053
  let e = (e) => {
980
- e.key === "Escape" && (v(!1), t.view.focus());
1054
+ e.key === "Escape" && (b(!1), w(-1), t.view.focus());
981
1055
  }, n = (e) => {
982
- e.target instanceof Node && a.current?.contains(e.target) || v(!1);
1056
+ e.target instanceof Node && a.current?.contains(e.target) || (b(!1), w(-1));
983
1057
  };
984
1058
  return document.addEventListener("keydown", e), document.addEventListener("mousedown", n), () => {
985
1059
  document.removeEventListener("keydown", e), document.removeEventListener("mousedown", n);
986
1060
  };
987
1061
  }, [
988
- te,
1062
+ ie,
989
1063
  t,
990
- _
991
- ]), W(() => {
1064
+ y
1065
+ ]), K(() => {
992
1066
  let e = () => {
993
1067
  let e = a.current;
994
1068
  if (!e) return;
995
- if (!mn(e) || oe.length === 0) {
996
- m([]);
1069
+ if (!Vn(e) || ue.length === 0) {
1070
+ g([]);
997
1071
  return;
998
1072
  }
999
- let n = e.getBoundingClientRect(), r = oe.flatMap((e) => {
1000
- let r = un(ln(t, e.pos, e.mermaidPreviewMode), n);
1001
- return r ? [an(e, r, n)] : [];
1073
+ let n = e.getBoundingClientRect(), r = ue.flatMap((e) => {
1074
+ let r = In(Fn(t, e.pos, e.mermaidPreviewMode), n);
1075
+ return r ? [jn(e, r, n)] : [];
1002
1076
  });
1003
- m((e) => vn(e, r, oe.map((e) => e.pos)));
1077
+ g((e) => Kn(e, r, ue.map((e) => e.pos)));
1004
1078
  };
1005
1079
  e();
1006
1080
  let n = window.requestAnimationFrame(e);
@@ -1008,26 +1082,26 @@ function Ur({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1008
1082
  window.cancelAnimationFrame(n), window.removeEventListener("resize", e), window.removeEventListener("scroll", e, !0);
1009
1083
  };
1010
1084
  }, [
1011
- j,
1085
+ te,
1012
1086
  t,
1013
- se
1014
- ]), W(() => {
1015
- if (!ne || !L) {
1016
- f(null), g(null);
1087
+ H
1088
+ ]), K(() => {
1089
+ if (!B || !R) {
1090
+ m(null), v(null);
1017
1091
  return;
1018
1092
  }
1019
1093
  let e = () => {
1020
1094
  let e = a.current;
1021
1095
  if (!e) return;
1022
- let n = ln(t, L.pos, B), r = e.getBoundingClientRect(), i = un(n, r);
1096
+ let n = Fn(t, R.pos, le), r = e.getBoundingClientRect(), i = In(n, r);
1023
1097
  if (!i) {
1024
- f((e) => e?.pos === L.pos ? e : null), g((e) => _ ? e : null);
1098
+ m((e) => e?.pos === R.pos ? e : null), v((e) => y ? e : null);
1025
1099
  return;
1026
1100
  }
1027
- let s = nn(L.pos, i, r);
1028
- if (f(s), _ && o.current) {
1101
+ let s = kn(R.pos, i, r);
1102
+ if (m(s), y && o.current) {
1029
1103
  let e = o.current.getBoundingClientRect();
1030
- g(Qt({
1104
+ v(wn({
1031
1105
  overlayRect: r,
1032
1106
  buttonRect: e,
1033
1107
  windowWidth: window.innerWidth,
@@ -1039,93 +1113,115 @@ function Ur({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1039
1113
  window.removeEventListener("resize", e), window.removeEventListener("scroll", e, !0);
1040
1114
  };
1041
1115
  }, [
1042
- ne,
1043
- j,
1044
- L?.pos,
1116
+ B,
1117
+ te,
1118
+ R?.pos,
1045
1119
  t,
1046
- _,
1047
- B
1048
- ]), !ne && oe.length === 0 && !T) return null;
1049
- let le = d ? {
1050
- top: d.top,
1051
- right: d.right
1052
- } : void 0, ue = async () => {
1120
+ y,
1121
+ le
1122
+ ]), !B && ue.length === 0 && !k) return null;
1123
+ let de = p ? {
1124
+ top: p.top,
1125
+ right: p.right
1126
+ } : void 0, fe = async () => {
1053
1127
  if (i) {
1054
- if (!L) return;
1055
- let e = await tn(L.text);
1056
- S(mt(L, e ? "copied" : "failed"));
1128
+ if (!R) return;
1129
+ let e = await Dn(R.text);
1130
+ E(It(R, e ? "copied" : "failed"));
1057
1131
  return;
1058
1132
  }
1059
- if (!on(t, L)) return;
1060
- let e = await ft(t);
1061
- S(mt(pt(t), e ? "copied" : "failed")), t.view.focus();
1062
- }, de = (e, n) => {
1133
+ if (!Mn(t, R)) return;
1134
+ let e = await Pt(t);
1135
+ E(It(Ft(t), e ? "copied" : "failed")), t.view.focus();
1136
+ }, pe = (e, n) => {
1063
1137
  if (i) {
1064
- St(t, e.pos, n) && P((e) => e + 1);
1138
+ Wt(t, e.pos, n) && F((e) => e + 1);
1065
1139
  return;
1066
1140
  }
1067
- let a = F.active && F.pos === e.pos;
1068
- vt(t, e.pos, n) && (r(n), P((e) => e + 1), a && t.view.focus());
1069
- }, fe = (e) => {
1070
- if (i || !L) return;
1071
- let n = F.active && F.pos === L.pos;
1072
- _t(t, L.pos, e) && (e === "mermaid" && vt(t, L.pos, "preview") && r("preview"), v(!1), b(""), P((e) => e + 1), n && t.view.focus());
1073
- }, pe = () => {
1074
- i || !L || gt(t, L.pos, !z) && (M((e) => e + 1), u(null));
1075
- }, me = () => {
1076
- if (!L) return;
1077
- let e = gn(t, L.pos);
1078
- if (!e) return;
1079
- let n = new Blob([e], { type: "image/svg+xml" }), r = URL.createObjectURL(n), i = document.createElement("a");
1080
- i.href = r, i.download = "markweave-mermaid.svg", i.click(), URL.revokeObjectURL(r), t.view.focus();
1141
+ let a = I.active && I.pos === e.pos;
1142
+ Bt(t, e.pos, n) && (r(n), F((e) => e + 1), a && t.view.focus());
1143
+ }, me = (e) => {
1144
+ if (i || !R) return;
1145
+ let n = I.active && I.pos === R.pos;
1146
+ zt(t, R.pos, e) && (e === "mermaid" && Bt(t, R.pos, "preview") && r("preview"), b(!1), S(""), w(-1), F((e) => e + 1), n && t.view.focus());
1081
1147
  }, he = () => {
1082
- if (!L) return;
1083
- let e = gn(t, L.pos);
1084
- e && (E(rn(e)), O(null), A(!1), c.current = {
1148
+ let e = !y;
1149
+ e && l.current === null && (l.current = On()), w(e ? Hn(U, R?.language ?? null) : -1), b(e);
1150
+ }, ge = (e) => {
1151
+ let t = Ln(e);
1152
+ S(e), w(Hn(t, e.trim() ? null : R?.language ?? null));
1153
+ }, _e = (e) => {
1154
+ if (!e.nativeEvent.isComposing) {
1155
+ if (e.key === "ArrowDown" || e.key === "ArrowUp") {
1156
+ e.preventDefault(), w((t) => Jn(t, U.length, e.key === "ArrowUp" ? "previous" : "next"));
1157
+ return;
1158
+ }
1159
+ if (e.key === "Enter") {
1160
+ let t = U[C];
1161
+ t && (e.preventDefault(), me(t.language));
1162
+ return;
1163
+ }
1164
+ e.key === "Escape" && (e.preventDefault(), b(!1), w(-1), t.view.focus());
1165
+ }
1166
+ }, ve = U[C], ye = l.current && ve ? Rn(l.current, ve.language) : void 0, be = () => {
1167
+ i || !R || Rt(t, R.pos, !z) && (P((e) => e + 1), f(null));
1168
+ }, xe = () => {
1169
+ if (!R) return;
1170
+ let e = Wn(t, R.pos);
1171
+ e && Cn({
1172
+ data: new Blob([e], { type: "image/svg+xml" }),
1173
+ fileName: "markweave-mermaid.svg",
1174
+ onSettled: () => t.view.focus(),
1175
+ ownerDocument: document
1176
+ });
1177
+ }, Se = () => {
1178
+ if (!R) return;
1179
+ let e = Wn(t, R.pos);
1180
+ e && (A(An(e)), M(null), N(!1), u.current = {
1085
1181
  active: !1,
1086
1182
  lastX: 0,
1087
1183
  lastY: 0
1088
1184
  });
1089
- }, ge = () => {
1090
- E(null), O(null), A(!1), c.current = {
1185
+ }, Ce = () => {
1186
+ A(null), M(null), N(!1), u.current = {
1091
1187
  active: !1,
1092
1188
  lastX: 0,
1093
1189
  lastY: 0
1094
1190
  }, t.view.focus();
1095
- }, _e = (e) => {
1096
- E((t) => t && {
1191
+ }, we = (e) => {
1192
+ A((t) => t && {
1097
1193
  ...t,
1098
- scale: $t(t.scale + e)
1194
+ scale: Tn(t.scale + e)
1099
1195
  });
1100
- }, H = () => {
1101
- E((e) => e && rn(e.svg)), c.current = {
1196
+ }, Te = () => {
1197
+ A((e) => e && An(e.svg)), u.current = {
1102
1198
  active: !1,
1103
1199
  lastX: 0,
1104
1200
  lastY: 0
1105
- }, A(!1);
1106
- }, ve = (e) => {
1107
- e.preventDefault(), _e(e.deltaY < 0 ? yn : -yn);
1108
- }, ye = (e) => {
1109
- e.button === 0 && (e.preventDefault(), c.current = {
1201
+ }, N(!1);
1202
+ }, Ee = (e) => {
1203
+ e.preventDefault(), we(e.deltaY < 0 ? qn : -qn);
1204
+ }, De = (e) => {
1205
+ e.button === 0 && (e.preventDefault(), u.current = {
1110
1206
  active: !0,
1111
1207
  lastX: e.clientX,
1112
1208
  lastY: e.clientY
1113
- }, A(!0));
1114
- }, be = (e) => {
1115
- let t = c.current;
1209
+ }, N(!0));
1210
+ }, Oe = (e) => {
1211
+ let t = u.current;
1116
1212
  if (!t.active) return;
1117
1213
  let n = e.clientX - t.lastX, r = e.clientY - t.lastY;
1118
- c.current = {
1214
+ u.current = {
1119
1215
  active: !0,
1120
1216
  lastX: e.clientX,
1121
1217
  lastY: e.clientY
1122
- }, E((e) => bn(e, n, r));
1123
- }, xe = () => {
1124
- c.current = {
1218
+ }, A((e) => Yn(e, n, r));
1219
+ }, ke = () => {
1220
+ u.current = {
1125
1221
  active: !1,
1126
1222
  lastX: 0,
1127
1223
  lastY: 0
1128
- }, A(!1);
1224
+ }, N(!1);
1129
1225
  };
1130
1226
  return /* @__PURE__ */ Q("div", {
1131
1227
  ref: a,
@@ -1133,8 +1229,8 @@ function Ur({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1133
1229
  "data-testid": "markweave-codeblock-overlay",
1134
1230
  "data-read-only": i ? "true" : "false",
1135
1231
  children: [
1136
- oe.map((e) => {
1137
- let t = p.find((t) => t.pos === e.pos);
1232
+ ue.map((e) => {
1233
+ let t = h.find((t) => t.pos === e.pos);
1138
1234
  return /* @__PURE__ */ Z("div", {
1139
1235
  className: "markweave-mermaid-tabs",
1140
1236
  "data-testid": "markweave-mermaid-tabs",
@@ -1149,38 +1245,38 @@ function Ur({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1149
1245
  "data-testid": `markweave-mermaid-mode-${t}`,
1150
1246
  "data-active": e.mermaidPreviewMode === t,
1151
1247
  onMouseDown: (e) => e.preventDefault(),
1152
- onClick: () => de(e, t),
1248
+ onClick: () => pe(e, t),
1153
1249
  children: t === "code" ? "Code" : "Preview"
1154
1250
  }, t))
1155
1251
  }, e.pos);
1156
1252
  }),
1157
- ne ? /* @__PURE__ */ Q("div", {
1253
+ B ? /* @__PURE__ */ Q("div", {
1158
1254
  className: "markweave-codeblock-controls",
1159
1255
  "data-testid": "markweave-codeblock-controls",
1160
- "data-positioned": d ? "true" : "false",
1256
+ "data-positioned": p ? "true" : "false",
1161
1257
  "data-collapsed": z ? "true" : "false",
1162
1258
  "data-read-only": i ? "true" : "false",
1163
1259
  "aria-label": "Code block controls",
1164
- style: le,
1260
+ style: de,
1165
1261
  children: [
1166
1262
  i ? /* @__PURE__ */ Z("span", {
1167
1263
  className: "markweave-codeblock-language-button markweave-codeblock-language-label",
1168
1264
  "aria-label": "Code block language",
1169
1265
  "data-testid": "markweave-codeblock-language",
1170
- children: /* @__PURE__ */ Z("span", { children: ie })
1266
+ children: /* @__PURE__ */ Z("span", { children: se })
1171
1267
  }) : /* @__PURE__ */ Q("button", {
1172
1268
  ref: o,
1173
1269
  type: "button",
1174
1270
  className: "markweave-codeblock-language-button",
1175
1271
  "aria-label": "Code block language",
1176
- "aria-expanded": _,
1272
+ "aria-expanded": y,
1177
1273
  "aria-haspopup": "listbox",
1178
1274
  "data-testid": "markweave-codeblock-language",
1179
1275
  onMouseDown: (e) => e.preventDefault(),
1180
- onClick: () => v((e) => !e),
1181
- children: [/* @__PURE__ */ Z("span", { children: ie }), /* @__PURE__ */ Z(Hr, { icon: "chevron" })]
1276
+ onClick: he,
1277
+ children: [/* @__PURE__ */ Z("span", { children: se }), /* @__PURE__ */ Z(ji, { icon: "chevron" })]
1182
1278
  }),
1183
- re ? /* @__PURE__ */ Z("button", {
1279
+ oe ? /* @__PURE__ */ Z("button", {
1184
1280
  type: "button",
1185
1281
  className: "markweave-codeblock-icon-button markweave-codeblock-collapse-button",
1186
1282
  "aria-label": z ? "Expand code block" : "Collapse code block",
@@ -1188,8 +1284,8 @@ function Ur({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1188
1284
  "data-testid": "markweave-codeblock-collapse",
1189
1285
  "data-collapsed": z ? "true" : "false",
1190
1286
  onMouseDown: (e) => e.preventDefault(),
1191
- onClick: pe,
1192
- children: /* @__PURE__ */ Z(Hr, { icon: "chevron" })
1287
+ onClick: be,
1288
+ children: /* @__PURE__ */ Z(ji, { icon: "chevron" })
1193
1289
  }) : null,
1194
1290
  /* @__PURE__ */ Q("span", {
1195
1291
  className: "markweave-codeblock-copy-wrap",
@@ -1198,22 +1294,22 @@ function Ur({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1198
1294
  className: "markweave-codeblock-icon-button",
1199
1295
  "aria-label": "Copy to clipboard",
1200
1296
  "data-testid": "markweave-codeblock-copy",
1201
- "data-copy-state": ae,
1297
+ "data-copy-state": ce,
1202
1298
  onMouseDown: (e) => e.preventDefault(),
1203
- onMouseEnter: () => w(!0),
1204
- onMouseLeave: () => w(!1),
1205
- onFocus: () => w(!0),
1206
- onBlur: () => w(!1),
1207
- onClick: ue,
1208
- children: /* @__PURE__ */ Z(Hr, { icon: ae === "copied" ? "check" : "clipboard" })
1209
- }), C ? /* @__PURE__ */ Z("span", {
1299
+ onMouseEnter: () => O(!0),
1300
+ onMouseLeave: () => O(!1),
1301
+ onFocus: () => O(!0),
1302
+ onBlur: () => O(!1),
1303
+ onClick: fe,
1304
+ children: /* @__PURE__ */ Z(ji, { icon: ce === "copied" ? "check" : "clipboard" })
1305
+ }), D ? /* @__PURE__ */ Z("span", {
1210
1306
  className: "markweave-codeblock-tooltip",
1211
1307
  role: "tooltip",
1212
1308
  "data-testid": "markweave-codeblock-copy-tooltip",
1213
1309
  children: "Copy to clipboard"
1214
1310
  }) : null]
1215
1311
  }),
1216
- R && B === "preview" ? /* @__PURE__ */ Q("div", {
1312
+ ae && le === "preview" ? /* @__PURE__ */ Q("div", {
1217
1313
  className: "markweave-mermaid-preview-actions",
1218
1314
  "data-testid": "markweave-mermaid-preview-actions",
1219
1315
  children: [/* @__PURE__ */ Z("button", {
@@ -1223,8 +1319,8 @@ function Ur({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1223
1319
  "data-testid": "markweave-mermaid-fullscreen",
1224
1320
  disabled: !V,
1225
1321
  onMouseDown: (e) => e.preventDefault(),
1226
- onClick: he,
1227
- children: /* @__PURE__ */ Z(Hr, { icon: "expand" })
1322
+ onClick: Se,
1323
+ children: /* @__PURE__ */ Z(ji, { icon: "expand" })
1228
1324
  }), /* @__PURE__ */ Z("button", {
1229
1325
  type: "button",
1230
1326
  className: "markweave-codeblock-icon-button",
@@ -1232,52 +1328,62 @@ function Ur({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1232
1328
  "data-testid": "markweave-mermaid-download",
1233
1329
  disabled: !V,
1234
1330
  onMouseDown: (e) => e.preventDefault(),
1235
- onClick: me,
1236
- children: /* @__PURE__ */ Z(Hr, { icon: "download" })
1331
+ onClick: xe,
1332
+ children: /* @__PURE__ */ Z(ji, { icon: "download" })
1237
1333
  })]
1238
1334
  }) : null
1239
1335
  ]
1240
1336
  }) : null,
1241
- re && ne && _ ? /* @__PURE__ */ Q("div", {
1337
+ oe && B && y ? /* @__PURE__ */ Q("div", {
1242
1338
  className: "markweave-codeblock-language-menu",
1243
- role: "listbox",
1244
- "aria-label": "Code block languages",
1245
1339
  "data-testid": "markweave-codeblock-language-menu",
1246
- "data-positioned": h ? "true" : "false",
1247
- style: h ? {
1248
- left: h.left,
1249
- top: h.top
1340
+ "data-positioned": _ ? "true" : "false",
1341
+ style: _ ? {
1342
+ left: _.left,
1343
+ top: _.top
1250
1344
  } : void 0,
1251
1345
  children: [/* @__PURE__ */ Q("label", {
1252
1346
  className: "markweave-codeblock-language-search",
1253
1347
  children: [/* @__PURE__ */ Z("input", {
1254
1348
  ref: s,
1255
- value: y,
1349
+ role: "combobox",
1350
+ "aria-autocomplete": "list",
1351
+ "aria-controls": l.current ?? void 0,
1352
+ "aria-expanded": "true",
1353
+ "aria-activedescendant": ye,
1354
+ "aria-label": "Search code block languages",
1355
+ value: x,
1256
1356
  placeholder: "Search...",
1257
1357
  "data-testid": "markweave-codeblock-language-search",
1258
- onChange: (e) => b(e.target.value),
1259
- onKeyDown: (e) => {
1260
- e.key === "Escape" && (e.preventDefault(), v(!1), t.view.focus());
1261
- }
1262
- }), /* @__PURE__ */ Z(Hr, { icon: "search" })]
1358
+ onChange: (e) => ge(e.target.value),
1359
+ onKeyDown: _e
1360
+ }), /* @__PURE__ */ Z(ji, { icon: "search" })]
1263
1361
  }), /* @__PURE__ */ Z("div", {
1362
+ ref: c,
1363
+ id: l.current ?? void 0,
1264
1364
  className: "markweave-codeblock-language-list",
1265
- children: ce.map((e) => {
1266
- let t = e.language === L.language;
1365
+ role: "listbox",
1366
+ "aria-label": "Code block languages",
1367
+ children: U.map((e, t) => {
1368
+ let n = e.language === R.language, r = t === C;
1267
1369
  return /* @__PURE__ */ Q("button", {
1370
+ id: l.current ? Rn(l.current, e.language) : void 0,
1268
1371
  type: "button",
1269
1372
  role: "option",
1270
- "aria-selected": t,
1373
+ "aria-selected": n,
1271
1374
  "data-testid": `markweave-codeblock-language-option-${e.language}`,
1272
- "data-active": t ? "true" : "false",
1375
+ "data-active": n ? "true" : "false",
1376
+ "data-highlighted": r ? "true" : "false",
1377
+ "data-language-index": t,
1273
1378
  onMouseDown: (e) => e.preventDefault(),
1274
- onClick: () => fe(e.language),
1275
- children: [/* @__PURE__ */ Z("span", { children: e.label }), t ? /* @__PURE__ */ Z(Hr, { icon: "check" }) : null]
1379
+ onMouseEnter: () => w(t),
1380
+ onClick: () => me(e.language),
1381
+ children: [/* @__PURE__ */ Z("span", { children: e.label }), n ? /* @__PURE__ */ Z(ji, { icon: "check" }) : null]
1276
1382
  }, e.language);
1277
1383
  })
1278
1384
  })]
1279
1385
  }) : null,
1280
- T ? /* @__PURE__ */ Q("div", {
1386
+ k ? /* @__PURE__ */ Q("div", {
1281
1387
  className: "markweave-mermaid-fullscreen-layer",
1282
1388
  role: "dialog",
1283
1389
  "aria-modal": "true",
@@ -1293,47 +1399,47 @@ function Ur({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1293
1399
  className: "markweave-mermaid-fullscreen-control",
1294
1400
  "aria-label": "Zoom out",
1295
1401
  "data-testid": "markweave-mermaid-fullscreen-zoom-out",
1296
- onMouseEnter: () => O("zoom-out"),
1297
- onMouseLeave: () => O(null),
1298
- onFocus: () => O("zoom-out"),
1299
- onBlur: () => O(null),
1300
- onClick: () => _e(-yn),
1301
- children: /* @__PURE__ */ Z(Hr, { icon: "zoomOut" })
1402
+ onMouseEnter: () => M("zoom-out"),
1403
+ onMouseLeave: () => M(null),
1404
+ onFocus: () => M("zoom-out"),
1405
+ onBlur: () => M(null),
1406
+ onClick: () => we(-qn),
1407
+ children: /* @__PURE__ */ Z(ji, { icon: "zoomOut" })
1302
1408
  }),
1303
1409
  /* @__PURE__ */ Z("span", {
1304
1410
  className: "markweave-mermaid-fullscreen-zoom-label",
1305
1411
  "data-testid": "markweave-mermaid-fullscreen-zoom-label",
1306
- children: cn(T.scale)
1412
+ children: Pn(k.scale)
1307
1413
  }),
1308
1414
  /* @__PURE__ */ Z("button", {
1309
1415
  type: "button",
1310
1416
  className: "markweave-mermaid-fullscreen-control",
1311
1417
  "aria-label": "Zoom in",
1312
1418
  "data-testid": "markweave-mermaid-fullscreen-zoom-in",
1313
- onMouseEnter: () => O("zoom-in"),
1314
- onMouseLeave: () => O(null),
1315
- onFocus: () => O("zoom-in"),
1316
- onBlur: () => O(null),
1317
- onClick: () => _e(yn),
1318
- children: /* @__PURE__ */ Z(Hr, { icon: "zoomIn" })
1419
+ onMouseEnter: () => M("zoom-in"),
1420
+ onMouseLeave: () => M(null),
1421
+ onFocus: () => M("zoom-in"),
1422
+ onBlur: () => M(null),
1423
+ onClick: () => we(qn),
1424
+ children: /* @__PURE__ */ Z(ji, { icon: "zoomIn" })
1319
1425
  }),
1320
1426
  /* @__PURE__ */ Z("button", {
1321
1427
  type: "button",
1322
1428
  className: "markweave-mermaid-fullscreen-control",
1323
1429
  "aria-label": "Reset zoom",
1324
1430
  "data-testid": "markweave-mermaid-fullscreen-reset",
1325
- onMouseEnter: () => O("reset"),
1326
- onMouseLeave: () => O(null),
1327
- onFocus: () => O("reset"),
1328
- onBlur: () => O(null),
1329
- onClick: H,
1330
- children: /* @__PURE__ */ Z(Hr, { icon: "reset" })
1431
+ onMouseEnter: () => M("reset"),
1432
+ onMouseLeave: () => M(null),
1433
+ onFocus: () => M("reset"),
1434
+ onBlur: () => M(null),
1435
+ onClick: Te,
1436
+ children: /* @__PURE__ */ Z(ji, { icon: "reset" })
1331
1437
  }),
1332
- D ? /* @__PURE__ */ Z("span", {
1438
+ j ? /* @__PURE__ */ Z("span", {
1333
1439
  className: "markweave-mermaid-fullscreen-tooltip",
1334
1440
  role: "tooltip",
1335
1441
  "data-testid": "markweave-mermaid-fullscreen-tooltip",
1336
- children: D === "zoom-out" ? "Zoom out" : D === "zoom-in" ? "Zoom in" : "Reset"
1442
+ children: j === "zoom-out" ? "Zoom out" : j === "zoom-in" ? "Zoom in" : "Reset"
1337
1443
  }) : null
1338
1444
  ]
1339
1445
  }),
@@ -1342,29 +1448,29 @@ function Ur({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1342
1448
  className: "markweave-mermaid-fullscreen-close",
1343
1449
  "aria-label": "Close fullscreen Mermaid preview",
1344
1450
  "data-testid": "markweave-mermaid-fullscreen-close",
1345
- onClick: ge,
1346
- children: /* @__PURE__ */ Z(Hr, { icon: "close" })
1451
+ onClick: Ce,
1452
+ children: /* @__PURE__ */ Z(ji, { icon: "close" })
1347
1453
  }),
1348
1454
  /* @__PURE__ */ Z("div", {
1349
1455
  className: "markweave-mermaid-fullscreen-viewport",
1350
1456
  "data-testid": "markweave-mermaid-fullscreen-viewport",
1351
- "data-dragging": k ? "true" : "false",
1352
- onWheel: ve,
1353
- onMouseDown: ye,
1354
- onMouseMove: be,
1355
- onMouseUp: xe,
1356
- onMouseLeave: xe,
1457
+ "data-dragging": ee ? "true" : "false",
1458
+ onWheel: Ee,
1459
+ onMouseDown: De,
1460
+ onMouseMove: Oe,
1461
+ onMouseUp: ke,
1462
+ onMouseLeave: ke,
1357
1463
  children: /* @__PURE__ */ Z("div", {
1358
1464
  className: "markweave-mermaid-fullscreen-content",
1359
1465
  "data-testid": "markweave-mermaid-fullscreen-content",
1360
- "data-scale-percent": Math.round(T.scale * 100),
1361
- "data-translate": `${Math.round(T.translateX)},${Math.round(T.translateY)}`,
1466
+ "data-scale-percent": Math.round(k.scale * 100),
1467
+ "data-translate": `${Math.round(k.translateX)},${Math.round(k.translateY)}`,
1362
1468
  style: {
1363
- width: `${T.width}px`,
1364
- height: `${T.height}px`,
1365
- transform: `translate(${T.translateX}px, ${T.translateY}px) scale(${T.scale})`
1469
+ width: `${k.width}px`,
1470
+ height: `${k.height}px`,
1471
+ transform: `translate(${k.translateX}px, ${k.translateY}px) scale(${k.scale})`
1366
1472
  },
1367
- dangerouslySetInnerHTML: { __html: T.svg }
1473
+ dangerouslySetInnerHTML: { __html: k.svg }
1368
1474
  })
1369
1475
  })
1370
1476
  ]
@@ -1374,25 +1480,25 @@ function Ur({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1374
1480
  }
1375
1481
  //#endregion
1376
1482
  //#region src/ui/floating-toolbar/FloatingToolbar.tsx
1377
- var Wr = n("zh");
1378
- function Gr() {
1483
+ var Ni = n("zh");
1484
+ function Pi() {
1379
1485
  return typeof performance > "u" ? Date.now() : performance.now();
1380
1486
  }
1381
- function Kr(e, t) {
1487
+ function Fi(e, t) {
1382
1488
  return {
1383
1489
  "--markweave-toolbar-motion-duration": `${e.motionDurationMs}ms`,
1384
1490
  "--markweave-toolbar-motion-easing": e.motionEasing,
1385
1491
  marginLeft: t === 0 ? void 0 : `${t}px`
1386
1492
  };
1387
1493
  }
1388
- function qr(e, t) {
1494
+ function Ii(e, t) {
1389
1495
  let n = e?.getBoundingClientRect().height ?? 0, r = t?.getBoundingClientRect().height ?? 0;
1390
1496
  return Math.max(n, r, 44);
1391
1497
  }
1392
- function Jr(e) {
1498
+ function Li(e) {
1393
1499
  if (e !== null) return { "--markweave-floating-toolbar-tooltip-left": `${e}px` };
1394
1500
  }
1395
- function Yr(e, t, n, r) {
1501
+ function Ri(e, t, n, r) {
1396
1502
  let i = {
1397
1503
  bottom: t + r,
1398
1504
  height: r,
@@ -1408,26 +1514,26 @@ function Yr(e, t, n, r) {
1408
1514
  toJSON: () => i
1409
1515
  };
1410
1516
  }
1411
- function Xr(e) {
1517
+ function zi(e) {
1412
1518
  return e.width > 0 && e.height > 0;
1413
1519
  }
1414
- function Zr(e) {
1520
+ function Bi(e) {
1415
1521
  let t = Math.min(...e.map((e) => e.left)), n = Math.min(...e.map((e) => e.top)), r = Math.max(...e.map((e) => e.right)), i = Math.max(...e.map((e) => e.bottom));
1416
- return Yr(t, n, r - t, i - n);
1522
+ return Ri(t, n, r - t, i - n);
1417
1523
  }
1418
- function Qr(e, t) {
1524
+ function Vi(e, t) {
1419
1525
  let n = e.view.dom.ownerDocument.defaultView?.Node.ELEMENT_NODE ?? 1, r = (t) => t ? e.view.dom.contains(t.nodeType === n ? t : t.parentNode) : !1;
1420
1526
  return r(t.anchorNode) && r(t.focusNode);
1421
1527
  }
1422
- function $r(e) {
1528
+ function Hi(e) {
1423
1529
  if (typeof e.getClientRects != "function") return null;
1424
- let t = Array.from(e.getClientRects()).filter(Xr).map((e) => Yr(e.left, e.top, e.width, e.height));
1530
+ let t = Array.from(e.getClientRects()).filter(zi).map((e) => Ri(e.left, e.top, e.width, e.height));
1425
1531
  if (t.length > 0) return t;
1426
1532
  if (typeof e.getBoundingClientRect != "function") return null;
1427
1533
  let n = e.getBoundingClientRect();
1428
- return Xr(n) ? [Yr(n.left, n.top, n.width, n.height)] : null;
1534
+ return zi(n) ? [Ri(n.left, n.top, n.width, n.height)] : null;
1429
1535
  }
1430
- function ei(e, t) {
1536
+ function Ui(e, t) {
1431
1537
  if (t.rangeCount === 0) return null;
1432
1538
  let n = t.getRangeAt(0);
1433
1539
  try {
@@ -1440,8 +1546,8 @@ function ei(e, t) {
1440
1546
  return null;
1441
1547
  }
1442
1548
  }
1443
- function ti(e, t) {
1444
- let n = ei(e, t);
1549
+ function Wi(e, t) {
1550
+ let n = Ui(e, t);
1445
1551
  if (!n) return !1;
1446
1552
  let { selection: r } = e.state, i = {
1447
1553
  from: Math.min(r.from, r.to),
@@ -1449,51 +1555,51 @@ function ti(e, t) {
1449
1555
  };
1450
1556
  return n.from === i.from && n.to === i.to;
1451
1557
  }
1452
- function ni(e) {
1558
+ function Gi(e) {
1453
1559
  let t = e.view.dom.ownerDocument.getSelection();
1454
- return !t || t.rangeCount === 0 || t.isCollapsed || !Qr(e, t) || !ti(e, t) ? null : $r(t.getRangeAt(0));
1560
+ return !t || t.rangeCount === 0 || t.isCollapsed || !Vi(e, t) || !Wi(e, t) ? null : Hi(t.getRangeAt(0));
1455
1561
  }
1456
- function ri(e) {
1562
+ function Ki(e) {
1457
1563
  let { selection: t } = e.state;
1458
1564
  if (t.empty) return null;
1459
1565
  let n = Math.min(t.from, t.to), r = Math.max(t.from, t.to);
1460
1566
  try {
1461
1567
  let t = e.view.domAtPos(n), i = e.view.domAtPos(r), a = e.view.dom.ownerDocument.createRange();
1462
- return a.setStart(t.node, t.offset), a.setEnd(i.node, i.offset), $r(a);
1568
+ return a.setStart(t.node, t.offset), a.setEnd(i.node, i.offset), Hi(a);
1463
1569
  } catch {
1464
1570
  return null;
1465
1571
  }
1466
1572
  }
1467
- function ii(e) {
1573
+ function qi(e) {
1468
1574
  let { selection: t } = e.state;
1469
1575
  if (t.empty) return null;
1470
- let n = Math.min(t.from, t.to), r = Math.max(t.from, t.to), i = e.view.coordsAtPos(n), a = e.view.coordsAtPos(r, -1), o = Math.min(i.top, a.top), s = Math.max(i.bottom, a.bottom), c = Math.min(i.left, a.left), l = Yr(c, o, Math.max(i.right, a.right) - c, s - o);
1471
- return Xr(l) ? [l] : null;
1576
+ 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 = Ri(c, o, Math.max(i.right, a.right) - c, s - o);
1577
+ return zi(l) ? [l] : null;
1472
1578
  }
1473
- function ai(e) {
1474
- return ni(e) ?? ri(e) ?? ii(e);
1579
+ function Ji(e) {
1580
+ return Gi(e) ?? Ki(e) ?? qi(e);
1475
1581
  }
1476
- function oi(e) {
1477
- let t = ai(e);
1478
- return t && t.length > 0 ? Zr(t) : null;
1582
+ function Yi(e) {
1583
+ let t = Ji(e);
1584
+ return t && t.length > 0 ? Bi(t) : null;
1479
1585
  }
1480
- function si(e) {
1586
+ function Xi(e) {
1481
1587
  return {
1482
- getBoundingClientRect: () => oi(e) ?? Yr(0, 0, 0, 0),
1483
- getClientRects: () => ai(e) ?? []
1588
+ getBoundingClientRect: () => Yi(e) ?? Ri(0, 0, 0, 0),
1589
+ getClientRects: () => Ji(e) ?? []
1484
1590
  };
1485
1591
  }
1486
- function ci(e) {
1592
+ function Zi(e) {
1487
1593
  return e === "block-type" || e === "link" || e === "color" || e === "more";
1488
1594
  }
1489
- function li(e, t, n) {
1490
- n?.(wn(e, t)), e.commands.focus();
1595
+ function Qi(e, t, n) {
1596
+ n?.($n(e, t)), e.commands.focus();
1491
1597
  }
1492
- function ui({ editor: e, messages: t = Wr, selectionSnapshot: n, onRewriteSelection: r }) {
1493
- let i = G(() => kn(t), [t]), a = st(n, { editable: e.isEditable }), [o, s] = q(a), [c, l] = q(null), [u, d] = q(null), [f, p] = q(null), [m, h] = q(""), [g, _] = q(""), [v, y] = q(null), [b, x] = q(0), [S, C] = q(a.boundaryPadding), [w, T] = q("bottom"), E = K(0), D = K(null), O = K(null), k = K(null), A = K(null), j = Tn(e, o.variant, t), M = jn(j.find((e) => e.id === c) ?? null), N = Hn(m), P = H(() => {
1598
+ function $i({ editor: e, messages: t = Ni, selectionSnapshot: n, onRewriteSelection: r }) {
1599
+ let i = q(() => ir(t), [t]), a = kt(n, { editable: e.isEditable }), [o, s] = Y(a), [c, l] = Y(null), [u, d] = Y(null), [f, p] = Y(null), [m, h] = Y(""), [g, _] = Y(""), [v, y] = Y(null), [b, x] = Y(0), [S, C] = Y(a.boundaryPadding), [w, T] = Y("bottom"), E = J(0), D = J(null), O = J(null), k = J(null), A = J(null), j = er(e, o.variant, t), M = or(j.find((e) => e.id === c) ?? null), ee = _r(m), N = W(() => {
1494
1600
  let t = D.current, n = e.view.dom.closest(".markweave-editor-frame");
1495
1601
  if (!t || !(n instanceof HTMLElement)) return;
1496
- let r = t.getBoundingClientRect(), i = n.getBoundingClientRect(), a = qr(t, O.current), s = E.current, c = nt({
1602
+ let r = t.getBoundingClientRect(), i = n.getBoundingClientRect(), a = Ii(t, O.current), s = E.current, c = wt({
1497
1603
  toolbarRect: {
1498
1604
  left: r.left - s,
1499
1605
  top: r.top,
@@ -1507,7 +1613,7 @@ function ui({ editor: e, messages: t = Wr, selectionSnapshot: n, onRewriteSelect
1507
1613
  height: i.height
1508
1614
  },
1509
1615
  boundaryPadding: o.boundaryPadding
1510
- }), l = it({
1616
+ }), l = Et({
1511
1617
  frameRect: {
1512
1618
  left: i.left,
1513
1619
  top: i.top,
@@ -1526,16 +1632,16 @@ function ui({ editor: e, messages: t = Wr, selectionSnapshot: n, onRewriteSelect
1526
1632
  e.view.dom,
1527
1633
  o.boundaryPadding,
1528
1634
  o.offset
1529
- ]), F = H(() => {
1635
+ ]), te = W(() => {
1530
1636
  D.current && (D.current.style.visibility = "hidden", D.current.style.opacity = "0");
1531
- }, []), ee = H(() => {
1532
- P();
1533
- }, [P]), I = H(() => si(e), [e]), L = H((e) => {
1637
+ }, []), P = W(() => {
1638
+ N();
1639
+ }, [N]), ne = W(() => Xi(e), [e]), F = W((e) => {
1534
1640
  k.current = e;
1535
- }, []), te = H(() => {
1641
+ }, []), I = W(() => {
1536
1642
  let t = D.current, n = k.current, r = e.view.dom.closest(".markweave-editor-frame");
1537
1643
  if (!f || !t || !n) return;
1538
- let i = t.getBoundingClientRect(), a = n.getBoundingClientRect(), s = r?.getBoundingClientRect() ?? null, c = rt({
1644
+ let i = t.getBoundingClientRect(), a = n.getBoundingClientRect(), s = r?.getBoundingClientRect() ?? null, c = Tt({
1539
1645
  toolbarRect: i,
1540
1646
  popoverSize: a,
1541
1647
  viewport: {
@@ -1551,19 +1657,19 @@ function ui({ editor: e, messages: t = Wr, selectionSnapshot: n, onRewriteSelect
1551
1657
  e.view.dom,
1552
1658
  f,
1553
1659
  o.boundaryPadding
1554
- ]), R = G(() => ({
1555
- ...ot(o, { topBoundaryPadding: S }),
1556
- onShow: F,
1557
- onUpdate: ee
1660
+ ]), L = q(() => ({
1661
+ ...Ot(o, { topBoundaryPadding: S }),
1662
+ onShow: te,
1663
+ onUpdate: P
1558
1664
  }), [
1559
- F,
1560
- ee,
1665
+ te,
1666
+ P,
1561
1667
  o,
1562
1668
  S
1563
1669
  ]);
1564
- U(() => {
1565
- let e = Gr();
1566
- s((t) => ut(t, a, e));
1670
+ G(() => {
1671
+ let e = Pi();
1672
+ s((t) => Mt(t, a, e));
1567
1673
  }, [
1568
1674
  a.hiddenReason,
1569
1675
  a.motionDurationMs,
@@ -1575,10 +1681,10 @@ function ui({ editor: e, messages: t = Wr, selectionSnapshot: n, onRewriteSelect
1575
1681
  a.updateDelayMs,
1576
1682
  a.variant,
1577
1683
  a.visibility
1578
- ]), U(() => {
1684
+ ]), G(() => {
1579
1685
  if (o.motionStartedAtMs === null || o.motionDurationMs <= 0) return;
1580
- let e = Math.max(0, o.motionStartedAtMs + o.motionDurationMs - Gr()), t = window.setTimeout(() => {
1581
- s((e) => et(e, Gr()));
1686
+ let e = Math.max(0, o.motionStartedAtMs + o.motionDurationMs - Pi()), t = window.setTimeout(() => {
1687
+ s((e) => St(e, Pi()));
1582
1688
  }, e);
1583
1689
  return () => {
1584
1690
  window.clearTimeout(t);
@@ -1587,17 +1693,17 @@ function ui({ editor: e, messages: t = Wr, selectionSnapshot: n, onRewriteSelect
1587
1693
  o.motionDurationMs,
1588
1694
  o.motionPhase,
1589
1695
  o.motionStartedAtMs
1590
- ]), W(() => {
1696
+ ]), K(() => {
1591
1697
  if (o.visibility !== "visible") {
1592
1698
  E.current = 0, D.current && (D.current.style.marginLeft = "", D.current.style.visibility = "hidden", D.current.style.opacity = "0"), x(0), C(o.boundaryPadding);
1593
1699
  return;
1594
1700
  }
1595
- let e = Sn(P);
1701
+ let e = mt(N);
1596
1702
  return e.schedule(), window.addEventListener("resize", e.schedule), window.addEventListener("scroll", e.schedule, !0), () => {
1597
1703
  e.cancel(), window.removeEventListener("resize", e.schedule), window.removeEventListener("scroll", e.schedule, !0);
1598
1704
  };
1599
1705
  }, [
1600
- P,
1706
+ N,
1601
1707
  e.view.dom,
1602
1708
  f,
1603
1709
  n?.from,
@@ -1605,20 +1711,20 @@ function ui({ editor: e, messages: t = Wr, selectionSnapshot: n, onRewriteSelect
1605
1711
  o.variant,
1606
1712
  o.visibility,
1607
1713
  j.length
1608
- ]), W(() => {
1714
+ ]), K(() => {
1609
1715
  if (!f) return;
1610
- let e = Sn(te);
1716
+ let e = mt(I);
1611
1717
  return e.schedule(), window.addEventListener("resize", e.schedule), window.addEventListener("scroll", e.schedule, !0), () => {
1612
1718
  e.cancel(), window.removeEventListener("resize", e.schedule), window.removeEventListener("scroll", e.schedule, !0);
1613
1719
  };
1614
- }, [f, te]), U(() => {
1720
+ }, [f, I]), G(() => {
1615
1721
  f === "more" && i.some((e) => e.id === c) || j.some((e) => e.id === c) || (l(null), d(null));
1616
1722
  }, [
1617
1723
  i,
1618
1724
  f,
1619
1725
  c,
1620
1726
  j
1621
- ]), U(() => {
1727
+ ]), G(() => {
1622
1728
  if (!f) return;
1623
1729
  let t = (e) => {
1624
1730
  O.current?.contains(e.target) || p(null);
@@ -1628,18 +1734,18 @@ function ui({ editor: e, messages: t = Wr, selectionSnapshot: n, onRewriteSelect
1628
1734
  return document.addEventListener("pointerdown", t, !0), document.addEventListener("keydown", n, !0), () => {
1629
1735
  document.removeEventListener("pointerdown", t, !0), document.removeEventListener("keydown", n, !0);
1630
1736
  };
1631
- }, [e, f]), U(() => {
1737
+ }, [e, f]), G(() => {
1632
1738
  if (f !== "link") return;
1633
1739
  let e = window.requestAnimationFrame(() => {
1634
1740
  A.current?.focus(), A.current?.select();
1635
1741
  });
1636
1742
  return () => window.cancelAnimationFrame(e);
1637
1743
  }, [f]);
1638
- let z = (t) => {
1639
- if (ci(t.id)) {
1744
+ let re = (t) => {
1745
+ if (Zi(t.id)) {
1640
1746
  let n = t.id;
1641
1747
  if (n === "link") {
1642
- let t = Dn(e);
1748
+ let t = nr(e);
1643
1749
  h(t), _(t), y({
1644
1750
  from: Math.min(e.state.selection.from, e.state.selection.to),
1645
1751
  to: Math.max(e.state.selection.from, e.state.selection.to)
@@ -1649,19 +1755,19 @@ function ui({ editor: e, messages: t = Wr, selectionSnapshot: n, onRewriteSelect
1649
1755
  return;
1650
1756
  }
1651
1757
  if (p(null), t.id === "improve") {
1652
- li(e, "rewrite-selection", r);
1758
+ Qi(e, "rewrite-selection", r);
1653
1759
  return;
1654
1760
  }
1655
1761
  t.run(), e.commands.focus();
1656
- }, ne = () => {
1762
+ }, R = () => {
1657
1763
  p(null), e.commands.focus();
1658
- }, re = () => {
1659
- v && e.commands.setTextSelection(v);
1660
1764
  }, ie = () => {
1661
- re(), Cn(e, m) && ne();
1765
+ v && e.commands.setTextSelection(v);
1662
1766
  }, ae = () => {
1663
- if (re(), Ln(e)) {
1664
- h(""), _(""), ne();
1767
+ ie(), Qn(e, m) && R();
1768
+ }, z = () => {
1769
+ if (ie(), fr(e)) {
1770
+ h(""), _(""), R();
1665
1771
  return;
1666
1772
  }
1667
1773
  m.trim() && h("");
@@ -1673,64 +1779,64 @@ function ui({ editor: e, messages: t = Wr, selectionSnapshot: n, onRewriteSelect
1673
1779
  let n = t.getBoundingClientRect(), r = O.current.getBoundingClientRect();
1674
1780
  d(n.left + n.width / 2 - r.left);
1675
1781
  };
1676
- return /* @__PURE__ */ Z(xn, {
1782
+ return /* @__PURE__ */ Z(Zn, {
1677
1783
  ref: D,
1678
1784
  editor: e,
1679
1785
  className: `markweave-floating-toolbar markweave-floating-toolbar--${o.variant} markweave-floating-toolbar--motion-${o.motionPhase}`,
1680
1786
  "data-motion": o.motionPhase,
1681
- "data-position-strategy": R.strategy,
1787
+ "data-position-strategy": L.strategy,
1682
1788
  "data-boundary-padding": o.boundaryPadding,
1683
1789
  "data-popover-placement": f ? w : void 0,
1684
1790
  "data-testid": "markweave-floating-toolbar",
1685
- style: Kr(o, b),
1791
+ style: Fi(o, b),
1686
1792
  updateDelay: 0,
1687
- getReferencedVirtualElement: I,
1688
- options: R,
1689
- shouldShow: ({ editor: e }) => e.isEditable && lt(at(e)),
1793
+ getReferencedVirtualElement: ne,
1794
+ options: L,
1795
+ shouldShow: ({ editor: e }) => e.isEditable && jt(Dt(e)),
1690
1796
  children: /* @__PURE__ */ Q("div", {
1691
1797
  ref: O,
1692
1798
  className: "markweave-floating-toolbar-content",
1693
1799
  "data-menu": f ?? "none",
1694
1800
  children: [
1695
- j.map((e, t) => /* @__PURE__ */ Z(fi, {
1801
+ j.map((e, t) => /* @__PURE__ */ Z(ta, {
1696
1802
  button: e,
1697
1803
  expanded: f === e.id,
1698
1804
  showDivider: t > 0 && j[t - 1].group !== e.group,
1699
1805
  tooltipActive: c === e.id,
1700
- onPointerDown: In,
1806
+ onPointerDown: dr,
1701
1807
  onTooltipChange: B,
1702
- onRun: z
1808
+ onRun: re
1703
1809
  }, e.id)),
1704
- f === "block-type" ? /* @__PURE__ */ Z(mi, {
1810
+ f === "block-type" ? /* @__PURE__ */ Z(ra, {
1705
1811
  editor: e,
1706
1812
  messages: t,
1707
- onPopoverRef: L,
1813
+ onPopoverRef: F,
1708
1814
  onClose: () => p(null)
1709
1815
  }) : null,
1710
- f === "link" ? /* @__PURE__ */ Z(di, {
1816
+ f === "link" ? /* @__PURE__ */ Z(ea, {
1711
1817
  inputRef: A,
1712
1818
  messages: t,
1713
1819
  value: m,
1714
- canApply: !!N,
1715
- canOpen: !!N,
1820
+ canApply: !!ee,
1821
+ canOpen: !!ee,
1716
1822
  canRemove: !!(g || m.trim()),
1717
1823
  onValueChange: h,
1718
- onApply: ie,
1719
- onOpen: () => Fn(m),
1720
- onRemove: ae,
1721
- onPopoverRef: L
1824
+ onApply: ae,
1825
+ onOpen: () => ur(m),
1826
+ onRemove: z,
1827
+ onPopoverRef: F
1722
1828
  }) : null,
1723
- f === "color" ? /* @__PURE__ */ Z(gi, {
1829
+ f === "color" ? /* @__PURE__ */ Z(aa, {
1724
1830
  editor: e,
1725
1831
  messages: t,
1726
- onPopoverRef: L,
1832
+ onPopoverRef: F,
1727
1833
  onClose: () => p(null)
1728
1834
  }) : null,
1729
- f === "more" ? /* @__PURE__ */ Z(vi, {
1835
+ f === "more" ? /* @__PURE__ */ Z(sa, {
1730
1836
  editor: e,
1731
1837
  messages: t,
1732
1838
  activeTooltipId: c,
1733
- onPopoverRef: L,
1839
+ onPopoverRef: F,
1734
1840
  onTooltipChange: l,
1735
1841
  onClose: () => p(null)
1736
1842
  }) : null,
@@ -1740,15 +1846,15 @@ function ui({ editor: e, messages: t = Wr, selectionSnapshot: n, onRewriteSelect
1740
1846
  "data-testid": "markweave-floating-toolbar-tooltip",
1741
1847
  "data-button-id": M.buttonId,
1742
1848
  "data-active": M.active,
1743
- style: Jr(u),
1849
+ style: Li(u),
1744
1850
  children: M.label
1745
1851
  }) : null
1746
1852
  ]
1747
1853
  })
1748
1854
  });
1749
1855
  }
1750
- function di({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRemove: a, onValueChange: o, onApply: s, onOpen: c, onRemove: l, onPopoverRef: u }) {
1751
- let d = On(t);
1856
+ function ea({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRemove: a, onValueChange: o, onApply: s, onOpen: c, onRemove: l, onPopoverRef: u }) {
1857
+ let d = rr(t);
1752
1858
  return /* @__PURE__ */ Q("form", {
1753
1859
  ref: u,
1754
1860
  className: "markweave-floating-toolbar-popover markweave-floating-toolbar-link-popover",
@@ -1771,7 +1877,7 @@ function di({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRe
1771
1877
  "aria-label": d.applyLink,
1772
1878
  "data-testid": "markweave-floating-toolbar-link-apply",
1773
1879
  disabled: !r,
1774
- onMouseDown: In,
1880
+ onMouseDown: dr,
1775
1881
  children: /* @__PURE__ */ Z($, { name: "corner-down-left" })
1776
1882
  }),
1777
1883
  /* @__PURE__ */ Z("span", {
@@ -1783,7 +1889,7 @@ function di({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRe
1783
1889
  "aria-label": d.openLink,
1784
1890
  "data-testid": "markweave-floating-toolbar-link-open",
1785
1891
  disabled: !i,
1786
- onMouseDown: In,
1892
+ onMouseDown: dr,
1787
1893
  onClick: c,
1788
1894
  children: /* @__PURE__ */ Z($, { name: "external-link" })
1789
1895
  }),
@@ -1792,7 +1898,7 @@ function di({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRe
1792
1898
  "aria-label": d.removeLink,
1793
1899
  "data-testid": "markweave-floating-toolbar-link-remove",
1794
1900
  disabled: !a,
1795
- onMouseDown: In,
1901
+ onMouseDown: dr,
1796
1902
  onClick: l,
1797
1903
  children: /* @__PURE__ */ Z($, { name: "trash" })
1798
1904
  })
@@ -1800,15 +1906,15 @@ function di({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRe
1800
1906
  })]
1801
1907
  });
1802
1908
  }
1803
- function fi({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointerDown: i, onTooltipChange: a, onRun: o }) {
1804
- return /* @__PURE__ */ Q(X, { children: [n ? /* @__PURE__ */ Z("span", {
1909
+ function ta({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointerDown: i, onTooltipChange: a, onRun: o }) {
1910
+ return /* @__PURE__ */ Q(ot, { children: [n ? /* @__PURE__ */ Z("span", {
1805
1911
  className: "markweave-floating-toolbar-divider",
1806
1912
  "aria-hidden": "true"
1807
1913
  }) : null, /* @__PURE__ */ Z("button", {
1808
1914
  type: "button",
1809
1915
  className: `markweave-floating-toolbar-button markweave-floating-toolbar-button--${e.id}`,
1810
1916
  "aria-label": e.label,
1811
- "aria-expanded": ci(e.id) ? t : void 0,
1917
+ "aria-expanded": Zi(e.id) ? t : void 0,
1812
1918
  "data-active": e.active || t,
1813
1919
  "data-tooltip-active": r ? "true" : "false",
1814
1920
  "data-testid": `markweave-floating-toolbar-button-${e.id}`,
@@ -1818,13 +1924,13 @@ function fi({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointe
1818
1924
  onMouseEnter: (t) => a(e.id, t.currentTarget),
1819
1925
  onMouseLeave: () => a(null),
1820
1926
  onClick: () => o(e),
1821
- children: /* @__PURE__ */ Z(pi, {
1927
+ children: /* @__PURE__ */ Z(na, {
1822
1928
  button: e,
1823
1929
  expanded: t
1824
1930
  })
1825
1931
  })] });
1826
1932
  }
1827
- function pi({ button: e, expanded: t }) {
1933
+ function na({ button: e, expanded: t }) {
1828
1934
  return e.id === "improve" ? /* @__PURE__ */ Q("span", {
1829
1935
  className: "markweave-floating-toolbar-button-inner",
1830
1936
  children: [/* @__PURE__ */ Z($, { name: "sparkles" }), /* @__PURE__ */ Z("span", { children: e.glyph })]
@@ -1842,8 +1948,8 @@ function pi({ button: e, expanded: t }) {
1842
1948
  }), /* @__PURE__ */ Z($, { name: t ? "chevron-up" : "chevron-down" })]
1843
1949
  }) : /* @__PURE__ */ Z($, { name: "more" });
1844
1950
  }
1845
- function mi({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
1846
- let i = On(t), a = Mn(t);
1951
+ function ra({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
1952
+ let i = rr(t), a = sr(t);
1847
1953
  return /* @__PURE__ */ Q("div", {
1848
1954
  ref: n,
1849
1955
  className: "markweave-floating-toolbar-popover markweave-floating-toolbar-turn-menu",
@@ -1853,48 +1959,48 @@ function mi({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
1853
1959
  children: i.turnIntoTitle
1854
1960
  }), a.map((t) => /* @__PURE__ */ Q("button", {
1855
1961
  type: "button",
1856
- "data-active": Pn(e, t.id),
1962
+ "data-active": lr(e, t.id),
1857
1963
  "data-testid": `markweave-floating-toolbar-turn-${t.id}`,
1858
- onMouseDown: In,
1964
+ onMouseDown: dr,
1859
1965
  onClick: () => {
1860
- Vn(e, t.id), r();
1966
+ gr(e, t.id), r();
1861
1967
  },
1862
1968
  children: [/* @__PURE__ */ Z("span", {
1863
1969
  className: "markweave-floating-toolbar-menu-icon",
1864
- children: /* @__PURE__ */ Z(hi, { option: t })
1970
+ children: /* @__PURE__ */ Z(ia, { option: t })
1865
1971
  }), /* @__PURE__ */ Z("span", { children: t.label })]
1866
1972
  }, t.id))]
1867
1973
  });
1868
1974
  }
1869
- function hi({ option: e }) {
1975
+ function ia({ option: e }) {
1870
1976
  return e.id === "paragraph" ? /* @__PURE__ */ Z($, { name: "text" }) : e.glyph === "bullet-list" || e.glyph === "numbered-list" || e.glyph === "todo-list" || e.glyph === "quote" || e.glyph === "code-block" ? /* @__PURE__ */ Z($, { name: e.glyph }) : /* @__PURE__ */ Z("span", { children: e.glyph });
1871
1977
  }
1872
- function gi({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
1873
- let i = On(t), a = e.getAttributes("textStyle").color, o = e.getAttributes("highlight").color;
1978
+ function aa({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
1979
+ let i = rr(t), a = e.getAttributes("textStyle").color, o = e.getAttributes("highlight").color;
1874
1980
  return /* @__PURE__ */ Q("div", {
1875
1981
  ref: n,
1876
1982
  className: "markweave-floating-toolbar-popover markweave-floating-toolbar-color-popover",
1877
1983
  "data-testid": "markweave-floating-toolbar-color-menu",
1878
- children: [/* @__PURE__ */ Z(_i, {
1984
+ children: [/* @__PURE__ */ Z(oa, {
1879
1985
  title: i.textColorTitle,
1880
1986
  mode: "text",
1881
1987
  activeColor: a ?? null,
1882
- options: An(t),
1988
+ options: ar(t),
1883
1989
  onSelect: (t) => {
1884
- Bn(e, t), r();
1990
+ hr(e, t), r();
1885
1991
  }
1886
- }), /* @__PURE__ */ Z(_i, {
1992
+ }), /* @__PURE__ */ Z(oa, {
1887
1993
  title: i.highlightColorTitle,
1888
1994
  mode: "highlight",
1889
1995
  activeColor: o ?? null,
1890
- options: En(t),
1996
+ options: tr(t),
1891
1997
  onSelect: (t) => {
1892
- zn(e, t), r();
1998
+ mr(e, t), r();
1893
1999
  }
1894
2000
  })]
1895
2001
  });
1896
2002
  }
1897
- function _i({ title: e, mode: t, activeColor: n, options: r, onSelect: i }) {
2003
+ function oa({ title: e, mode: t, activeColor: n, options: r, onSelect: i }) {
1898
2004
  return /* @__PURE__ */ Q("section", {
1899
2005
  className: "markweave-floating-toolbar-color-section",
1900
2006
  "aria-label": e,
@@ -1908,7 +2014,7 @@ function _i({ title: e, mode: t, activeColor: n, options: r, onSelect: i }) {
1908
2014
  "aria-label": e.label,
1909
2015
  "data-active": e.value === n || e.value === null && !n,
1910
2016
  "data-testid": `markweave-floating-toolbar-${t}-${e.id}`,
1911
- onMouseDown: In,
2017
+ onMouseDown: dr,
1912
2018
  onClick: () => i(e.value),
1913
2019
  children: t === "text" ? /* @__PURE__ */ Z("span", {
1914
2020
  className: "markweave-floating-toolbar-text-swatch",
@@ -1923,26 +2029,26 @@ function _i({ title: e, mode: t, activeColor: n, options: r, onSelect: i }) {
1923
2029
  })]
1924
2030
  });
1925
2031
  }
1926
- function vi({ editor: e, messages: t, activeTooltipId: n, onPopoverRef: r, onTooltipChange: i, onClose: a }) {
1927
- let o = kn(t);
2032
+ function sa({ editor: e, messages: t, activeTooltipId: n, onPopoverRef: r, onTooltipChange: i, onClose: a }) {
2033
+ let o = ir(t);
1928
2034
  return /* @__PURE__ */ Z("div", {
1929
2035
  ref: r,
1930
2036
  className: "markweave-floating-toolbar-popover markweave-floating-toolbar-more-menu",
1931
2037
  "data-testid": "markweave-floating-toolbar-more-menu",
1932
- children: o.map((t, r) => /* @__PURE__ */ Z(yi, {
2038
+ children: o.map((t, r) => /* @__PURE__ */ Z(ca, {
1933
2039
  action: t,
1934
- active: Nn(e, t.id),
2040
+ active: cr(e, t.id),
1935
2041
  tooltipActive: n === t.id,
1936
2042
  showDivider: r > 0 && o[r - 1].group !== t.group,
1937
2043
  onTooltipChange: i,
1938
2044
  onRun: () => {
1939
- Rn(e, t.id), a();
2045
+ pr(e, t.id), a();
1940
2046
  }
1941
2047
  }, t.id))
1942
2048
  });
1943
2049
  }
1944
- function yi({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipChange: i, onRun: a }) {
1945
- return /* @__PURE__ */ Q(X, { children: [r ? /* @__PURE__ */ Z("span", {
2050
+ function ca({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipChange: i, onRun: a }) {
2051
+ return /* @__PURE__ */ Q(ot, { children: [r ? /* @__PURE__ */ Z("span", {
1946
2052
  className: "markweave-floating-toolbar-divider",
1947
2053
  "aria-hidden": "true"
1948
2054
  }) : null, /* @__PURE__ */ Q("span", {
@@ -1953,11 +2059,11 @@ function yi({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipC
1953
2059
  "data-active": t,
1954
2060
  "data-tooltip-active": n ? "true" : "false",
1955
2061
  "data-testid": `markweave-floating-toolbar-more-${e.id}`,
1956
- onMouseDown: In,
2062
+ onMouseDown: dr,
1957
2063
  onMouseEnter: () => i(e.id),
1958
2064
  onMouseLeave: () => i(null),
1959
2065
  onClick: a,
1960
- children: /* @__PURE__ */ Z(bi, { id: e.id })
2066
+ children: /* @__PURE__ */ Z(la, { id: e.id })
1961
2067
  }), n ? /* @__PURE__ */ Z("div", {
1962
2068
  className: "markweave-floating-toolbar-tooltip markweave-floating-toolbar-tooltip--more",
1963
2069
  role: "tooltip",
@@ -1965,41 +2071,41 @@ function yi({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipC
1965
2071
  }) : null]
1966
2072
  })] });
1967
2073
  }
1968
- function bi({ id: e }) {
2074
+ function la({ id: e }) {
1969
2075
  return e === "superscript" ? /* @__PURE__ */ Z($, { name: "superscript" }) : e === "subscript" ? /* @__PURE__ */ Z($, { name: "subscript" }) : e === "inline-math" ? /* @__PURE__ */ Z($, { name: "math" }) : Z($, { name: e });
1970
2076
  }
1971
- var xi = {
1972
- sparkles: se,
1973
- "chevron-down": v,
1974
- "chevron-up": y,
1975
- "corner-down-left": C,
1976
- "external-link": T,
1977
- bold: p,
1978
- italic: F,
1979
- underline: he,
1980
- strike: ce,
1981
- "inline-code": x,
1982
- link: I,
1983
- more: ne,
1984
- text: me,
1985
- "bullet-list": L,
1986
- "numbered-list": R,
1987
- "todo-list": te,
1988
- quote: ae,
1989
- "code-block": m,
1990
- superscript: ue,
1991
- subscript: le,
1992
- math: V,
2077
+ var ua = {
2078
+ sparkles: xe,
2079
+ "chevron-down": j,
2080
+ "chevron-up": ee,
2081
+ "corner-down-left": ne,
2082
+ "external-link": I,
2083
+ bold: E,
2084
+ italic: ce,
2085
+ underline: Me,
2086
+ strike: Ce,
2087
+ "inline-code": te,
2088
+ link: V,
2089
+ more: fe,
2090
+ text: je,
2091
+ "bullet-list": ue,
2092
+ "numbered-list": U,
2093
+ "todo-list": H,
2094
+ quote: _e,
2095
+ "code-block": D,
2096
+ superscript: Te,
2097
+ subscript: we,
2098
+ math: ye,
1993
2099
  "align-left": d,
1994
2100
  "align-center": l,
1995
2101
  "align-right": f,
1996
2102
  "align-justify": u,
1997
- "decrease-indent": M,
1998
- "increase-indent": N,
1999
- trash: pe
2103
+ "decrease-indent": B,
2104
+ "increase-indent": oe,
2105
+ trash: Ae
2000
2106
  };
2001
2107
  function $({ name: e }) {
2002
- let t = xi[e];
2108
+ let t = ua[e];
2003
2109
  return /* @__PURE__ */ Z(t, {
2004
2110
  "aria-hidden": "true",
2005
2111
  absoluteStrokeWidth: !0,
@@ -2009,24 +2115,24 @@ function $({ name: e }) {
2009
2115
  }
2010
2116
  //#endregion
2011
2117
  //#region src/ui/math/MathEditorPopover.tsx
2012
- function Si({ editor: e, messages: t, onClose: n, target: r }) {
2013
- let i = K(null), a = K(null), [o, s] = q(r.latex), [c, l] = q(null), u = t.math, d = G(() => Dt(e, r) ?? 1, [e, r]), f = G(() => Ot(e, r), [e, r]), p = G(() => o === r.latex && f ? {
2118
+ function da({ editor: e, messages: t, onClose: n, target: r }) {
2119
+ let i = J(null), a = J(null), [o, s] = Y(r.latex), [c, l] = Y(null), u = t.math, d = q(() => Yt(e, r) ?? 1, [e, r]), f = q(() => Xt(e, r), [e, r]), p = q(() => o === r.latex && f ? {
2014
2120
  html: f,
2015
2121
  error: !1
2016
- } : Mt(o, r.kind, e), [
2122
+ } : en(o, r.kind, e), [
2017
2123
  e,
2018
2124
  f,
2019
2125
  r.kind,
2020
2126
  r.latex,
2021
2127
  o
2022
- ]), m = o.trim().length > 0, h = H(() => {
2128
+ ]), m = o.trim().length > 0, h = W(() => {
2023
2129
  if (typeof window > "u") return;
2024
- let t = Et(e, r), i = e.view.dom.closest(".markweave-editor-frame")?.getBoundingClientRect();
2130
+ let t = Jt(e, r), i = e.view.dom.closest(".markweave-editor-frame")?.getBoundingClientRect();
2025
2131
  if (!t || !i) {
2026
2132
  n();
2027
2133
  return;
2028
2134
  }
2029
- l(Tt({
2135
+ l(qt({
2030
2136
  anchorRect: t,
2031
2137
  frameRect: i,
2032
2138
  kind: r.kind,
@@ -2040,58 +2146,58 @@ function Si({ editor: e, messages: t, onClose: n, target: r }) {
2040
2146
  r,
2041
2147
  o
2042
2148
  ]);
2043
- U(() => {
2149
+ G(() => {
2044
2150
  s(r.latex);
2045
- }, [r.latex, r.pos]), U(() => {
2046
- Nt(e, r, !0), h();
2151
+ }, [r.latex, r.pos]), G(() => {
2152
+ tn(e, r, !0), h();
2047
2153
  let t = window.requestAnimationFrame(() => {
2048
2154
  a.current?.focus({ preventScroll: !0 }), a.current?.select(), h();
2049
2155
  });
2050
2156
  return window.addEventListener("resize", h), window.addEventListener("scroll", h, !0), () => {
2051
- window.cancelAnimationFrame(t), window.removeEventListener("resize", h), window.removeEventListener("scroll", h, !0), Nt(e, r, !1);
2157
+ window.cancelAnimationFrame(t), window.removeEventListener("resize", h), window.removeEventListener("scroll", h, !0), tn(e, r, !1);
2052
2158
  };
2053
2159
  }, [
2054
2160
  e,
2055
2161
  n,
2056
2162
  r,
2057
2163
  h
2058
- ]), U(() => {
2164
+ ]), G(() => {
2059
2165
  let e = (e) => {
2060
2166
  let t = e.target;
2061
2167
  t instanceof Node && (i.current?.contains(t) || t instanceof Element && t.closest(".tiptap-mathematics-render") || n());
2062
2168
  };
2063
2169
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
2064
2170
  }, [n]);
2065
- let _ = H(() => {
2066
- m && wt(e, r, o) && n();
2171
+ let g = W(() => {
2172
+ m && Kt(e, r, o) && n();
2067
2173
  }, [
2068
2174
  m,
2069
2175
  e,
2070
2176
  n,
2071
2177
  r,
2072
2178
  o
2073
- ]), v = (t) => {
2179
+ ]), _ = (t) => {
2074
2180
  if (t.key === "Escape") {
2075
2181
  t.preventDefault(), n(), e.commands.focus();
2076
2182
  return;
2077
2183
  }
2078
- t.key === "Enter" && (r.kind === "inline" || t.metaKey || t.ctrlKey) && (t.preventDefault(), _());
2079
- }, y = c ? {
2184
+ t.key === "Enter" && (r.kind === "inline" || t.metaKey || t.ctrlKey) && (t.preventDefault(), g());
2185
+ }, v = c ? {
2080
2186
  left: c.left,
2081
2187
  top: c.top,
2082
2188
  width: c.width
2083
- } : void 0, b = r.kind === "block" ? u.blockTitle : u.inlineTitle;
2189
+ } : void 0, y = r.kind === "block" ? u.blockTitle : u.inlineTitle;
2084
2190
  return r.kind === "inline" ? /* @__PURE__ */ Q("form", {
2085
2191
  ref: i,
2086
- "aria-label": b,
2192
+ "aria-label": y,
2087
2193
  className: "markweave-math-editor-popover markweave-math-editor-popover--inline",
2088
2194
  "data-kind": "inline",
2089
2195
  "data-placement": c?.placement ?? "bottom",
2090
2196
  "data-testid": "markweave-math-editor-popover",
2091
2197
  onSubmit: (e) => {
2092
- e.preventDefault(), _();
2198
+ e.preventDefault(), g();
2093
2199
  },
2094
- style: y,
2200
+ style: v,
2095
2201
  children: [/* @__PURE__ */ Q("label", {
2096
2202
  className: "markweave-math-inline-source",
2097
2203
  "data-testid": "markweave-math-inline-source",
@@ -2105,7 +2211,7 @@ function Si({ editor: e, messages: t, onClose: n, target: r }) {
2105
2211
  "aria-label": u.latexLabel,
2106
2212
  "data-testid": "markweave-math-editor-input",
2107
2213
  onChange: (e) => s(e.currentTarget.value),
2108
- onKeyDown: v,
2214
+ onKeyDown: _,
2109
2215
  placeholder: u.latexPlaceholder,
2110
2216
  size: Math.max(o.length, 1),
2111
2217
  spellCheck: !1,
@@ -2124,21 +2230,21 @@ function Si({ editor: e, messages: t, onClose: n, target: r }) {
2124
2230
  })]
2125
2231
  }) : /* @__PURE__ */ Q("form", {
2126
2232
  ref: i,
2127
- "aria-label": b,
2233
+ "aria-label": y,
2128
2234
  className: "markweave-math-editor-popover markweave-math-editor-popover--block",
2129
2235
  "data-kind": r.kind,
2130
2236
  "data-placement": c?.placement ?? "bottom",
2131
2237
  "data-testid": "markweave-math-editor-popover",
2132
2238
  onSubmit: (e) => {
2133
- e.preventDefault(), _();
2239
+ e.preventDefault(), g();
2134
2240
  },
2135
- style: y,
2241
+ style: v,
2136
2242
  children: [
2137
2243
  /* @__PURE__ */ Q("div", {
2138
2244
  className: "markweave-math-block-toolbar",
2139
2245
  children: [
2140
2246
  /* @__PURE__ */ Z("span", { children: u.label }),
2141
- /* @__PURE__ */ Z(x, {
2247
+ /* @__PURE__ */ Z(te, {
2142
2248
  "aria-hidden": "true",
2143
2249
  size: 15,
2144
2250
  strokeWidth: 1.75
@@ -2149,7 +2255,7 @@ function Si({ editor: e, messages: t, onClose: n, target: r }) {
2149
2255
  disabled: !m,
2150
2256
  title: u.apply,
2151
2257
  type: "submit",
2152
- children: /* @__PURE__ */ Z(g, {
2258
+ children: /* @__PURE__ */ Z(k, {
2153
2259
  "aria-hidden": "true",
2154
2260
  size: 16,
2155
2261
  strokeWidth: 2
@@ -2170,7 +2276,7 @@ function Si({ editor: e, messages: t, onClose: n, target: r }) {
2170
2276
  "aria-label": u.latexLabel,
2171
2277
  "data-testid": "markweave-math-editor-input",
2172
2278
  onChange: (e) => s(e.currentTarget.value),
2173
- onKeyDown: v,
2279
+ onKeyDown: _,
2174
2280
  placeholder: u.latexPlaceholder,
2175
2281
  rows: 3,
2176
2282
  spellCheck: !1,
@@ -2194,31 +2300,31 @@ function Si({ editor: e, messages: t, onClose: n, target: r }) {
2194
2300
  }
2195
2301
  //#endregion
2196
2302
  //#region src/ui/slash-command/SlashCommandMenu.tsx
2197
- var Ci = n("zh"), wi = {
2198
- type: fe,
2199
- "heading-1": D,
2200
- "heading-2": O,
2201
- "heading-3": k,
2202
- "bullet-list": L,
2203
- "ordered-list": R,
2204
- "task-list": te,
2205
- blockquote: ae,
2206
- "code-block": m,
2207
- info: P,
2208
- tip: ee,
2303
+ var fa = n("zh"), pa = {
2304
+ type: ke,
2305
+ "heading-1": re,
2306
+ "heading-2": R,
2307
+ "heading-3": ie,
2308
+ "bullet-list": ue,
2309
+ "ordered-list": U,
2310
+ "task-list": H,
2311
+ blockquote: _e,
2312
+ "code-block": D,
2313
+ info: se,
2314
+ tip: le,
2209
2315
  warning: c,
2210
- error: b,
2211
- success: _,
2212
- emoji: oe,
2213
- math: V,
2214
- table: de,
2215
- separator: z,
2216
- image: A,
2217
- video: _e,
2218
- attachment: re
2316
+ error: N,
2317
+ success: A,
2318
+ emoji: be,
2319
+ math: ye,
2320
+ table: Ee,
2321
+ separator: de,
2322
+ image: ae,
2323
+ video: Pe,
2324
+ attachment: me
2219
2325
  };
2220
- function Ti({ name: e }) {
2221
- let t = wi[e];
2326
+ function ma({ name: e }) {
2327
+ let t = pa[e];
2222
2328
  return /* @__PURE__ */ Z(t, {
2223
2329
  "aria-hidden": "true",
2224
2330
  absoluteStrokeWidth: !0,
@@ -2226,8 +2332,8 @@ function Ti({ name: e }) {
2226
2332
  strokeWidth: 1.6
2227
2333
  });
2228
2334
  }
2229
- function Ei(e, t, n) {
2230
- return !zt(e) || !n ? {
2335
+ function ha(e, t, n) {
2336
+ return !cn(e) || !n ? {
2231
2337
  visible: !1,
2232
2338
  empty: !1,
2233
2339
  activeIndex: -1
@@ -2241,17 +2347,17 @@ function Ei(e, t, n) {
2241
2347
  activeIndex: Math.min(t.length - 1, Math.max(0, e.activeIndex))
2242
2348
  };
2243
2349
  }
2244
- function Di(e, t) {
2350
+ function ga(e, t) {
2245
2351
  return Object.values(t.slash.groups).map((t) => ({
2246
2352
  group: t,
2247
2353
  commands: e.filter((e) => e.group === t)
2248
2354
  })).filter((e) => e.commands.length > 0);
2249
2355
  }
2250
- function Oi(e, t) {
2356
+ function _a(e, t) {
2251
2357
  return t.slash.uploadKindLabels[e] ?? t.slash.uploadKindLabels.upload;
2252
2358
  }
2253
- function ki({ command: e, messages: t, onBack: n, onSelect: r }) {
2254
- let [i, a] = q(""), [o, s] = q(0), c = G(() => {
2359
+ function va({ command: e, messages: t, onBack: n, onSelect: r }) {
2360
+ let [i, a] = Y(""), [o, s] = Y(0), c = q(() => {
2255
2361
  let e = i.trim().toLowerCase();
2256
2362
  return (e ? t.slash.emojiItems.filter((t) => [
2257
2363
  t.emoji,
@@ -2317,9 +2423,9 @@ function ki({ command: e, messages: t, onBack: n, onSelect: r }) {
2317
2423
  ]
2318
2424
  });
2319
2425
  }
2320
- function Ai({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
2321
- let a = e.uploadKind ?? "attachment", [o, s] = q(""), [c, l] = q(null), [u, d] = q(null), [f, p] = q(!1), m = async (t) => {
2322
- r(e, { uploadResult: await xe({
2426
+ function ya({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
2427
+ let a = e.uploadKind ?? "attachment", [o, s] = Y(""), [c, l] = Y(null), [u, d] = Y(null), [f, p] = Y(!1), m = async (t) => {
2428
+ r(e, { uploadResult: await X({
2323
2429
  kind: a,
2324
2430
  source: t,
2325
2431
  trigger: "slash-command"
@@ -2339,7 +2445,7 @@ function Ai({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
2339
2445
  d(t.slash.uploadRequiredError);
2340
2446
  return;
2341
2447
  }
2342
- await m(ye(o));
2448
+ await m(Ie(o));
2343
2449
  } catch (e) {
2344
2450
  d(e instanceof Error ? e.message : t.slash.uploadFailedError);
2345
2451
  } finally {
@@ -2357,7 +2463,7 @@ function Ai({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
2357
2463
  onMouseDown: (e) => e.preventDefault(),
2358
2464
  onClick: n,
2359
2465
  children: t.common.back
2360
- }), /* @__PURE__ */ Z("span", { children: Oi(a, t) })]
2466
+ }), /* @__PURE__ */ Z("span", { children: _a(a, t) })]
2361
2467
  }),
2362
2468
  /* @__PURE__ */ Q("label", {
2363
2469
  className: "markweave-slash-upload-field",
@@ -2405,10 +2511,10 @@ function Ai({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
2405
2511
  ]
2406
2512
  });
2407
2513
  }
2408
- function ji({ commands: e, messages: t = Ci, state: n, position: r, inputCommand: i, onActiveIndexChange: a, onInputCommandChange: o, onSelect: s, onUpload: c }) {
2409
- let l = Ei(n, e, r);
2514
+ function ba({ commands: e, messages: t = fa, state: n, position: r, inputCommand: i, onActiveIndexChange: a, onInputCommandChange: o, onSelect: s, onUpload: c }) {
2515
+ let l = ha(n, e, r);
2410
2516
  if (!l.visible || !r) return null;
2411
- let u = Di(e, t), d = {
2517
+ let u = ga(e, t), d = {
2412
2518
  left: r.left,
2413
2519
  top: r.top,
2414
2520
  maxHeight: r.maxHeight,
@@ -2417,7 +2523,7 @@ function ji({ commands: e, messages: t = Ci, state: n, position: r, inputCommand
2417
2523
  left: r.triggerLeft,
2418
2524
  top: r.triggerTop
2419
2525
  }, p = (e) => o?.(e), m = () => o?.(null);
2420
- return /* @__PURE__ */ Q(X, { children: [/* @__PURE__ */ Q("div", {
2526
+ return /* @__PURE__ */ Q(ot, { children: [/* @__PURE__ */ Q("div", {
2421
2527
  className: "markweave-slash-trigger",
2422
2528
  style: f,
2423
2529
  "aria-hidden": "true",
@@ -2430,12 +2536,12 @@ function ji({ commands: e, messages: t = Ci, state: n, position: r, inputCommand
2430
2536
  "aria-label": t.slash.ariaLabel,
2431
2537
  "data-placement": r.placement,
2432
2538
  "data-testid": "markweave-slash-menu",
2433
- children: i?.inputKind === "emoji" ? /* @__PURE__ */ Z(ki, {
2539
+ children: i?.inputKind === "emoji" ? /* @__PURE__ */ Z(va, {
2434
2540
  command: i,
2435
2541
  messages: t,
2436
2542
  onBack: m,
2437
2543
  onSelect: s
2438
- }) : i?.inputKind === "upload" ? /* @__PURE__ */ Z(Ai, {
2544
+ }) : i?.inputKind === "upload" ? /* @__PURE__ */ Z(ya, {
2439
2545
  command: i,
2440
2546
  messages: t,
2441
2547
  onBack: m,
@@ -2455,7 +2561,7 @@ function ji({ commands: e, messages: t = Ci, state: n, position: r, inputCommand
2455
2561
  className: "markweave-slash-group-title",
2456
2562
  children: t.group
2457
2563
  }), t.commands.map((t) => {
2458
- let n = e.indexOf(t), r = n === l.activeIndex, i = Lt(t), o = !!t.disabled;
2564
+ let n = e.indexOf(t), r = n === l.activeIndex, i = on(t), o = !!t.disabled;
2459
2565
  return /* @__PURE__ */ Q("button", {
2460
2566
  type: "button",
2461
2567
  role: "option",
@@ -2479,7 +2585,7 @@ function ji({ commands: e, messages: t = Ci, state: n, position: r, inputCommand
2479
2585
  }
2480
2586
  },
2481
2587
  children: [
2482
- /* @__PURE__ */ Z(Ti, { name: t.icon }),
2588
+ /* @__PURE__ */ Z(ma, { name: t.icon }),
2483
2589
  /* @__PURE__ */ Z("span", { children: t.label }),
2484
2590
  o && t.disabledReason ? /* @__PURE__ */ Z("small", { children: t.disabledReason }) : null
2485
2591
  ]
@@ -2491,42 +2597,93 @@ function ji({ commands: e, messages: t = Ci, state: n, position: r, inputCommand
2491
2597
  }
2492
2598
  //#endregion
2493
2599
  //#region src/ui/table/TableControls.tsx
2494
- var Mi = n("zh");
2495
- function Ni({ active: e, editor: t, interactionState: n = Xt, messages: r = Mi, onCopyPayload: i, onCommandResult: a, onEditWithAi: o }) {
2496
- let [s, c] = q(null), [l, u] = q("row-edge"), [d, f] = q(null), [p, m] = q(null), [h, g] = q(null), [_, v] = q(null), [y, b] = q(null), x = K(null), S = K(null), C = K(null), w = K(null), T = K(null), E = e ? Jt(t.state) : null;
2497
- if (U(() => {
2498
- if (!y) return;
2600
+ var xa = n("zh"), Sa = {
2601
+ "move-left": v,
2602
+ "move-right": y,
2603
+ "move-up": b,
2604
+ "move-down": g,
2605
+ "insert-left": T,
2606
+ "insert-right": w,
2607
+ "insert-above": C,
2608
+ "insert-below": S,
2609
+ "sort-asc": _,
2610
+ "sort-desc": x,
2611
+ color: pe,
2612
+ alignment: d,
2613
+ clear: Se,
2614
+ duplicate: P,
2615
+ copy: P,
2616
+ merge: De,
2617
+ split: Oe,
2618
+ delete: Ae
2619
+ }, Ca = {
2620
+ left: d,
2621
+ center: l,
2622
+ right: f,
2623
+ top: h,
2624
+ middle: p,
2625
+ bottom: m
2626
+ };
2627
+ function wa({ active: e, editor: t, interactionState: n = xn, messages: r = xa, onCopyPayload: i, onCommandResult: a, onEditWithAi: o }) {
2628
+ 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), N = J(null), te = J(null), P = J(null), ne = J(null), F = J(null), I = J(null), L = e ? yn(t.state) : null;
2629
+ if (G(() => {
2630
+ if (!A) return;
2499
2631
  let e = window.setTimeout(() => {
2500
- b(null);
2501
- }, or);
2632
+ j(null);
2633
+ }, Wr);
2502
2634
  return () => {
2503
2635
  window.clearTimeout(e);
2504
2636
  };
2505
- }, [y]), W(() => {
2637
+ }, [A]), G(() => {
2638
+ let e = (e) => {
2639
+ let n = O.current;
2640
+ if (!n) return;
2641
+ let r = Ar(t, n.axis, e.clientX, e.clientY);
2642
+ r !== null && (e.preventDefault(), k.current = r, e.dataTransfer && (e.dataTransfer.dropEffect = "move"));
2643
+ }, n = (e) => {
2644
+ let n = O.current;
2645
+ if (!n) return;
2646
+ let r = Ar(t, n.axis, e.clientX, e.clientY) ?? k.current;
2647
+ e.preventDefault(), O.current = null, k.current = null, r !== null && Vr(t, n.axis, n.index, r);
2648
+ };
2649
+ return document.addEventListener("dragover", e), document.addEventListener("drop", n), () => {
2650
+ document.removeEventListener("dragover", e), document.removeEventListener("drop", n);
2651
+ };
2652
+ }, [t]), K(() => {
2506
2653
  if (!e) {
2507
- m(null), g(null), v(null), b(null);
2654
+ v(null), b(null), S(null), w(null), E(null), j(null);
2508
2655
  return;
2509
2656
  }
2510
2657
  let r = () => {
2511
- let e = t.view.dom.closest(".markweave-editor-frame") ?? t.view.dom.parentElement, r = Qn(t, n, "row", E?.activeCellPos ?? null), i = Qn(t, n, "column", E?.activeCellPos ?? null), a = r ? Zn(t, r) : null, o = i ? Zn(t, i) : null, c = Xn(t).length > 0 ? rr(t) : null;
2658
+ let e = t.view.dom.closest(".markweave-editor-frame") ?? t.view.dom.parentElement, r = Nr(t, n, "row", L?.activeCellPos ?? null), i = Nr(t, n, "column", L?.activeCellPos ?? null), a = r ? Mr(t, r) : null, o = i ? Mr(t, i) : null, c = Rr(t, "selection").length > 0 ? zr(t) : null, l = kr(t)?.getBoundingClientRect() ?? null;
2512
2659
  if (!e) {
2513
- m(null), g(null), v(null);
2660
+ v(null), b(null), S(null), w(null), E(null);
2514
2661
  return;
2515
2662
  }
2516
2663
  let u = e.getBoundingClientRect();
2517
- a ? m(Gn({
2664
+ a ? v(wr({
2518
2665
  targetRect: a,
2519
2666
  frameRect: u,
2520
2667
  kind: "row"
2521
- })) : s === "row" && l === "row-edge" || m(null), o ? g(Gn({
2668
+ })) : s === "row" && d === "row-edge" || v(null), o ? b(wr({
2522
2669
  targetRect: o,
2523
2670
  frameRect: u,
2524
2671
  kind: "column"
2525
- })) : s === "column" && l === "column-edge" || g(null), c ? v(Gn({
2672
+ })) : s === "column" && d === "column-edge" || b(null), c ? S(wr({
2526
2673
  targetRect: c,
2527
2674
  frameRect: u,
2528
2675
  kind: "selection"
2529
- })) : s === "selection" && l === "selection-edge" || v(null);
2676
+ })) : s === "selection" && d === "selection-edge" || S(null);
2677
+ let f = n.hoverCellPos !== null && !!(r && r.index === r.visualHeight - 1), p = n.hoverCellPos !== null && !!(i && i.index === i.visualWidth - 1);
2678
+ w(l && f ? Tr({
2679
+ tableRect: l,
2680
+ frameRect: u,
2681
+ kind: "row"
2682
+ }) : null), E(l && p ? Tr({
2683
+ tableRect: l,
2684
+ frameRect: u,
2685
+ kind: "column"
2686
+ }) : null);
2530
2687
  };
2531
2688
  return r(), window.addEventListener("resize", r), window.addEventListener("scroll", r, !0), () => {
2532
2689
  window.removeEventListener("resize", r), window.removeEventListener("scroll", r, !0);
@@ -2534,40 +2691,41 @@ function Ni({ active: e, editor: t, interactionState: n = Xt, messages: r = Mi,
2534
2691
  }, [
2535
2692
  e,
2536
2693
  t,
2537
- E?.activeCellPos,
2538
- E?.selectionFrom,
2539
- E?.selectionTo,
2694
+ L?.activeCellPos,
2695
+ L?.selectionFrom,
2696
+ L?.selectionTo,
2540
2697
  n.hoverCellPos,
2541
2698
  n.hoverVisualColumnIndex,
2542
2699
  n.hoverVisualRowIndex,
2543
- l,
2700
+ d,
2544
2701
  s
2545
- ]), W(() => {
2702
+ ]), K(() => {
2546
2703
  if (!e || !s) {
2547
- f(null);
2704
+ m(null);
2548
2705
  return;
2549
2706
  }
2550
2707
  let n = () => {
2551
- let e = t.view.dom.closest(".markweave-editor-frame") ?? t.view.dom.parentElement, n = l === "row-edge" ? C.current : l === "column-edge" ? w.current : T.current, r = S.current;
2708
+ let e = t.view.dom.closest(".markweave-editor-frame") ?? t.view.dom.parentElement, n = d === "row-edge" ? ne.current : d === "column-edge" ? F.current : I.current, r = N.current;
2552
2709
  if (!e || !n || !r) {
2553
- f(null);
2710
+ m(null);
2554
2711
  return;
2555
2712
  }
2556
- let i = n.getBoundingClientRect(), a = s === "row" ? Yn(t)?.getBoundingClientRect() : null, o = a ? {
2713
+ let i = n.getBoundingClientRect(), a = s === "row" ? kr(t)?.getBoundingClientRect() : null, o = a ? {
2557
2714
  left: i.left,
2558
2715
  top: a.top,
2559
2716
  width: i.width,
2560
2717
  height: i.height
2561
- } : i, c = e.getBoundingClientRect(), u = r.getBoundingClientRect(), d = Wn({
2718
+ } : i, c = e.getBoundingClientRect(), l = r.getBoundingClientRect(), u = te.current?.scrollHeight ?? 0, f = u > 0 ? u + 12 : 0, p = Sr({
2562
2719
  anchorRect: o,
2563
2720
  frameRect: c,
2721
+ boundaryRect: Fr(e),
2564
2722
  menuSize: {
2565
- width: u.width || 204,
2566
- height: u.height || 220
2723
+ width: l.width || 254,
2724
+ height: f || l.height || 410
2567
2725
  },
2568
2726
  kind: s
2569
2727
  });
2570
- f(d);
2728
+ m(p);
2571
2729
  };
2572
2730
  return n(), window.addEventListener("resize", n), window.addEventListener("scroll", n, !0), () => {
2573
2731
  window.removeEventListener("resize", n), window.removeEventListener("scroll", n, !0);
@@ -2575,17 +2733,56 @@ function Ni({ active: e, editor: t, interactionState: n = Xt, messages: r = Mi,
2575
2733
  }, [
2576
2734
  e,
2577
2735
  t,
2578
- l,
2736
+ d,
2579
2737
  s,
2738
+ _,
2739
+ y,
2740
+ x
2741
+ ]), K(() => {
2742
+ if (!e || !s || !l || !p) {
2743
+ g(null);
2744
+ return;
2745
+ }
2746
+ let n = () => {
2747
+ let e = t.view.dom.closest(".markweave-editor-frame") ?? t.view.dom.parentElement, n = N.current, r = P.current, i = n?.querySelector(`[data-submenu-trigger="${l}"]`);
2748
+ if (!e || !n || !r || !i) {
2749
+ g(null);
2750
+ return;
2751
+ }
2752
+ let a = r.getBoundingClientRect(), o = Math.max(r.scrollHeight + 2, a.height);
2753
+ g(Cr({
2754
+ triggerRect: i.getBoundingClientRect(),
2755
+ parentMenuRect: n.getBoundingClientRect(),
2756
+ boundaryRect: Fr(e),
2757
+ submenuSize: {
2758
+ width: a.width || 238,
2759
+ height: o || 410
2760
+ }
2761
+ }));
2762
+ };
2763
+ n();
2764
+ let r = te.current;
2765
+ return r?.addEventListener("scroll", n), window.addEventListener("resize", n), window.addEventListener("scroll", n, !0), () => {
2766
+ r?.removeEventListener("scroll", n), window.removeEventListener("resize", n), window.removeEventListener("scroll", n, !0);
2767
+ };
2768
+ }, [
2769
+ e,
2770
+ t,
2580
2771
  p,
2581
- h,
2582
- _
2583
- ]), U(() => {
2772
+ s,
2773
+ l
2774
+ ]), G(() => {
2584
2775
  if (!e || !s) return;
2585
2776
  let n = (e) => {
2586
- e.key === "Escape" && (c(null), t.view.focus());
2777
+ if (e.key === "Escape") {
2778
+ if (l) {
2779
+ u(null);
2780
+ return;
2781
+ }
2782
+ c(null), u(null), t.view.focus();
2783
+ }
2587
2784
  }, r = (e) => {
2588
- e.target instanceof Node && x.current?.contains(e.target) || c(null);
2785
+ e.target instanceof Node && ee.current?.contains(e.target) || (c(null), u(null));
2589
2786
  };
2590
2787
  return document.addEventListener("keydown", n), document.addEventListener("mousedown", r), () => {
2591
2788
  document.removeEventListener("keydown", n), document.removeEventListener("mousedown", r);
@@ -2593,171 +2790,388 @@ function Ni({ active: e, editor: t, interactionState: n = Xt, messages: r = Mi,
2593
2790
  }, [
2594
2791
  e,
2595
2792
  t,
2596
- s
2793
+ s,
2794
+ l
2597
2795
  ]), !e) return null;
2598
- let D = (e, t) => {
2599
- let n = s === e && l === t;
2600
- u(t), c(n ? null : e);
2601
- }, O = () => {
2602
- t.view.dispatch(Un(t.state.tr, null));
2603
- }, k = (e, r) => {
2604
- let i = n.hoverCellPos ?? E?.activeCellPos ?? null, a = n.hoverCellPos === null ? null : e === "row" ? n.hoverVisualRowIndex : n.hoverVisualColumnIndex;
2605
- i !== null && ar(t, i, e, { visualIndex: a }), D(e, r);
2606
- }, A = () => {
2607
- O(), D("selection", "selection-edge");
2608
- }, j = Qn(t, n, "row", E?.activeCellPos ?? null), M = Qn(t, n, "column", E?.activeCellPos ?? null), N = Xn(t).length > 0, P = s ? nr(t, s) : [], F = async (e, n) => {
2609
- let o = await qn({
2796
+ let re = (e, t) => {
2797
+ let n = s === e && d === t;
2798
+ f(t), c(n ? null : e), u(null);
2799
+ }, R = () => {
2800
+ t.view.dispatch(vr(t.state.tr, null));
2801
+ }, ie = (e, r) => {
2802
+ let i = n.hoverCellPos ?? L?.activeCellPos ?? null, a = n.hoverCellPos === null ? null : e === "row" ? n.hoverVisualRowIndex : n.hoverVisualColumnIndex;
2803
+ i !== null && Hr(t, i, e, { visualIndex: a }), re(e, r);
2804
+ }, ae = () => {
2805
+ R(), re("selection", "selection-edge");
2806
+ }, z = Nr(t, n, "row", L?.activeCellPos ?? null), B = Nr(t, n, "column", L?.activeCellPos ?? null), oe = Rr(t, "selection").length > 0, se = s ? Rr(t, s) : [], ce = async (e, n) => {
2807
+ let o = await Dr({
2610
2808
  editor: t,
2611
2809
  commandId: e,
2612
2810
  menu: n ?? s ?? "selection",
2613
2811
  messages: r
2614
2812
  });
2615
- return o.copyFeedback ? (b(o.copyFeedback), o.copyPayload && i?.(o.copyPayload)) : b(null), a?.(o.commandResult), o.success;
2616
- }, ee = (e) => {
2617
- let n = $n(t, e);
2618
- n && o?.(n), c(null), t.view.focus();
2619
- };
2813
+ return o.copyFeedback ? (j(o.copyFeedback), o.copyPayload && i?.(o.copyPayload)) : j(null), a?.(o.commandResult), o.success;
2814
+ }, le = (e) => {
2815
+ let n = Pr(t, e);
2816
+ n && o?.(n), c(null), u(null), t.view.focus();
2817
+ }, V = (e) => {
2818
+ s !== "row" && s !== "column" || e(s) && D((e) => e + 1);
2819
+ }, ue = (e) => {
2820
+ let r = e === "row" ? z : B, i = n.hoverCellPos ?? L?.activeCellPos ?? null;
2821
+ !r || i === null || Jr(t, i, e, { visualIndex: r.index }) && ce(e === "row" ? "add-row-after" : "add-column-after", e);
2822
+ }, H = (e, t, n) => {
2823
+ O.current = {
2824
+ axis: e,
2825
+ index: t
2826
+ }, k.current = t, n.dataTransfer.effectAllowed = "move", n.dataTransfer.setData("application/x-markweave-table-axis", `${e}:${t}`);
2827
+ }, U = (e) => {
2828
+ 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);
2829
+ if (e.key === "ArrowDown" || e.key === "ArrowUp") {
2830
+ e.preventDefault(), e.stopPropagation();
2831
+ let t = e.key === "ArrowDown" ? 1 : -1;
2832
+ r[i < 0 ? 0 : Math.min(r.length - 1, Math.max(0, i + t))]?.focus();
2833
+ }
2834
+ }, de = s === "row" || s === "column" ? jr(t, s) : null;
2620
2835
  return /* @__PURE__ */ Q("div", {
2621
- ref: x,
2836
+ ref: ee,
2622
2837
  className: "markweave-table-controls",
2623
2838
  "data-testid": "markweave-table-controls",
2624
2839
  "aria-label": r.table.controlsAriaLabel,
2625
2840
  "data-open-menu": s ?? "none",
2626
- "data-positioned": p || h || _ ? "true" : "false",
2841
+ "data-positioned": _ || y || x ? "true" : "false",
2842
+ onMouseLeave: () => {
2843
+ t.view.dispatch(t.state.tr.setMeta(Sn, { type: "clear-hover" }));
2844
+ },
2627
2845
  children: [
2628
- y ? /* @__PURE__ */ Z("div", {
2846
+ A ? /* @__PURE__ */ Z("div", {
2629
2847
  className: "markweave-table-copy-feedback",
2630
2848
  role: "status",
2631
2849
  "aria-live": "polite",
2632
2850
  "data-testid": "markweave-table-copy-feedback",
2633
- "data-copy-kind": y.kind,
2634
- "data-text-length": y.textLength,
2635
- "data-html-length": y.htmlLength,
2636
- children: Jn(y)
2851
+ "data-copy-kind": A.kind,
2852
+ "data-text-length": A.textLength,
2853
+ "data-html-length": A.htmlLength,
2854
+ children: Or(A)
2637
2855
  }) : null,
2638
- p ? /* @__PURE__ */ Z("button", {
2856
+ _ ? /* @__PURE__ */ Z("button", {
2639
2857
  type: "button",
2640
- ref: C,
2858
+ ref: ne,
2641
2859
  className: "markweave-table-edge-handle markweave-table-edge-handle--row",
2642
2860
  "aria-label": r.table.activeRowActions,
2643
- "aria-expanded": s === "row" && l === "row-edge",
2861
+ "aria-expanded": s === "row" && d === "row-edge",
2644
2862
  "aria-haspopup": "menu",
2645
2863
  title: r.table.rowActions,
2646
2864
  "data-testid": "markweave-table-hover-row-handle",
2647
- "data-axis-index": j?.index ?? "",
2648
- "data-axis-selected-cells": j?.selectedCellCount ?? "",
2649
- "data-axis-visual-cells": j?.visualCellCount ?? "",
2650
- "data-axis-visual-size": j?.visualHeight ?? "",
2865
+ "data-axis-index": z?.index ?? "",
2866
+ "data-axis-selected-cells": z?.selectedCellCount ?? "",
2867
+ "data-axis-visual-cells": z?.visualCellCount ?? "",
2868
+ "data-axis-visual-size": z?.visualHeight ?? "",
2651
2869
  style: {
2652
- left: p.left,
2653
- top: p.top
2870
+ left: _.left,
2871
+ top: _.top,
2872
+ width: _.width,
2873
+ height: _.height
2874
+ },
2875
+ draggable: !0,
2876
+ onDragStart: (e) => H("row", z?.index ?? 0, e),
2877
+ onDragEnd: () => {
2878
+ O.current = null, k.current = null;
2654
2879
  },
2655
- onMouseDown: (e) => e.preventDefault(),
2656
2880
  onClick: () => {
2657
- k("row", "row-edge");
2881
+ ie("row", "row-edge");
2658
2882
  },
2659
- children: /* @__PURE__ */ Z("span", {
2883
+ children: /* @__PURE__ */ Z(fe, {
2660
2884
  "aria-hidden": "true",
2661
- children: "..."
2885
+ size: 14
2662
2886
  })
2663
2887
  }) : null,
2664
- h ? /* @__PURE__ */ Z("button", {
2888
+ y ? /* @__PURE__ */ Z("button", {
2665
2889
  type: "button",
2666
- ref: w,
2890
+ ref: F,
2667
2891
  className: "markweave-table-edge-handle markweave-table-edge-handle--column",
2668
2892
  "aria-label": r.table.activeColumnActions,
2669
- "aria-expanded": s === "column" && l === "column-edge",
2893
+ "aria-expanded": s === "column" && d === "column-edge",
2670
2894
  "aria-haspopup": "menu",
2671
2895
  title: r.table.columnActions,
2672
2896
  "data-testid": "markweave-table-hover-column-handle",
2673
- "data-axis-index": M?.index ?? "",
2674
- "data-axis-selected-cells": M?.selectedCellCount ?? "",
2675
- "data-axis-visual-cells": M?.visualCellCount ?? "",
2676
- "data-axis-visual-size": M?.visualWidth ?? "",
2897
+ "data-axis-index": B?.index ?? "",
2898
+ "data-axis-selected-cells": B?.selectedCellCount ?? "",
2899
+ "data-axis-visual-cells": B?.visualCellCount ?? "",
2900
+ "data-axis-visual-size": B?.visualWidth ?? "",
2677
2901
  style: {
2678
- left: h.left,
2679
- top: h.top
2902
+ left: y.left,
2903
+ top: y.top,
2904
+ width: y.width,
2905
+ height: y.height
2906
+ },
2907
+ draggable: !0,
2908
+ onDragStart: (e) => H("column", B?.index ?? 0, e),
2909
+ onDragEnd: () => {
2910
+ O.current = null, k.current = null;
2680
2911
  },
2681
- onMouseDown: (e) => e.preventDefault(),
2682
2912
  onClick: () => {
2683
- k("column", "column-edge");
2913
+ ie("column", "column-edge");
2914
+ },
2915
+ children: /* @__PURE__ */ Z(fe, {
2916
+ "aria-hidden": "true",
2917
+ size: 14
2918
+ })
2919
+ }) : null,
2920
+ C ? /* @__PURE__ */ Z("button", {
2921
+ type: "button",
2922
+ className: "markweave-table-extend-button markweave-table-extend-button--row",
2923
+ "aria-label": r.table.addRow,
2924
+ title: r.table.addRow,
2925
+ "data-testid": "markweave-table-add-row",
2926
+ style: {
2927
+ left: C.left,
2928
+ top: C.top,
2929
+ width: C.width,
2930
+ height: C.height
2931
+ },
2932
+ onMouseDown: (e) => e.preventDefault(),
2933
+ onClick: () => ue("row"),
2934
+ children: /* @__PURE__ */ Z(ge, {
2935
+ "aria-hidden": "true",
2936
+ size: 16
2937
+ })
2938
+ }) : null,
2939
+ T ? /* @__PURE__ */ Z("button", {
2940
+ type: "button",
2941
+ className: "markweave-table-extend-button markweave-table-extend-button--column",
2942
+ "aria-label": r.table.addColumn,
2943
+ title: r.table.addColumn,
2944
+ "data-testid": "markweave-table-add-column",
2945
+ style: {
2946
+ left: T.left,
2947
+ top: T.top,
2948
+ width: T.width,
2949
+ height: T.height
2684
2950
  },
2685
- children: /* @__PURE__ */ Z("span", {
2951
+ onMouseDown: (e) => e.preventDefault(),
2952
+ onClick: () => ue("column"),
2953
+ children: /* @__PURE__ */ Z(ge, {
2686
2954
  "aria-hidden": "true",
2687
- children: "..."
2955
+ size: 16
2688
2956
  })
2689
2957
  }) : null,
2690
- N && _ ? /* @__PURE__ */ Z("button", {
2958
+ oe && x ? /* @__PURE__ */ Z("button", {
2691
2959
  type: "button",
2692
- ref: T,
2960
+ ref: I,
2693
2961
  className: "markweave-table-edge-handle markweave-table-edge-handle--selection",
2694
2962
  "aria-label": r.table.selectionActions,
2695
- "aria-expanded": s === "selection" && l === "selection-edge",
2963
+ "aria-expanded": s === "selection" && d === "selection-edge",
2696
2964
  "aria-haspopup": "menu",
2697
2965
  title: r.table.selectionActions,
2698
2966
  "data-testid": "markweave-table-cell-handle",
2699
2967
  style: {
2700
- left: _.left,
2701
- top: _.top
2968
+ left: x.left,
2969
+ top: x.top,
2970
+ width: x.width,
2971
+ height: x.height
2702
2972
  },
2703
2973
  onMouseDown: (e) => e.preventDefault(),
2704
- onClick: A,
2705
- children: /* @__PURE__ */ Z("span", {
2974
+ onClick: ae,
2975
+ children: /* @__PURE__ */ Z(fe, {
2706
2976
  "aria-hidden": "true",
2707
- children: "..."
2977
+ size: 14
2708
2978
  })
2709
2979
  }) : null,
2710
- s ? /* @__PURE__ */ Z("div", {
2711
- ref: S,
2980
+ s ? /* @__PURE__ */ Q("div", {
2981
+ ref: N,
2712
2982
  className: "markweave-table-menu",
2713
2983
  role: "menu",
2714
- "aria-label": sr(s, r),
2984
+ "aria-label": Kr(s, r),
2715
2985
  "data-testid": "markweave-table-menu",
2716
- "data-positioned": d ? "true" : "false",
2717
- style: d ? {
2718
- left: d.left,
2719
- top: d.top
2986
+ "data-positioned": p ? "true" : "false",
2987
+ "data-placement": p?.placement,
2988
+ "data-submenu": l ?? "none",
2989
+ style: p ? {
2990
+ left: p.left,
2991
+ top: p.top
2720
2992
  } : void 0,
2721
- children: P.map((e, n) => {
2722
- let i = er(e), a = n === 0 ? i : er(P[n - 1]), l = n > 0 && a !== i, u = e.commandId === null ? !!o : Kn(t, e.commandId), d = tr(e, r);
2723
- return /* @__PURE__ */ Z("button", {
2724
- type: "button",
2725
- role: "menuitem",
2726
- "aria-label": d,
2727
- "aria-disabled": !u,
2728
- disabled: !u,
2729
- "data-menu-group": i,
2730
- "data-starts-group": l ? "true" : "false",
2731
- "data-command-enabled": u ? "true" : "false",
2732
- "data-testid": e.commandId ? `markweave-table-menu-command-${e.commandId}` : "markweave-table-menu-command-edit-with-ai",
2733
- onMouseDown: (e) => e.preventDefault(),
2734
- onClick: () => {
2735
- if (u) {
2736
- if (e.commandId === null) {
2737
- ee(s === "row" || s === "column" ? s : "selection");
2738
- return;
2739
- }
2740
- F(e.commandId).finally(() => c(null));
2741
- }
2742
- },
2743
- children: d
2744
- }, `${e.id}-${n}`);
2745
- })
2993
+ onKeyDown: U,
2994
+ children: [
2995
+ /* @__PURE__ */ Z("div", {
2996
+ ref: te,
2997
+ className: "markweave-table-menu-scroll",
2998
+ style: p ? { maxHeight: Math.max(1, p.maxHeight - 12) } : void 0,
2999
+ children: se.map((e, n) => {
3000
+ let i = Ir(e), a = n === 0 ? i : Ir(se[n - 1]), d = n > 0 && a !== i, f = e.submenuId ? !0 : e.commandId === null ? !!o : Er(t, e.commandId), p = Lr(e, r), m = Sa[e.icon];
3001
+ return /* @__PURE__ */ Q("button", {
3002
+ type: "button",
3003
+ role: "menuitem",
3004
+ "aria-label": p,
3005
+ "aria-disabled": !f,
3006
+ "aria-haspopup": e.submenuId ? "menu" : void 0,
3007
+ "aria-expanded": e.submenuId ? l === e.submenuId : void 0,
3008
+ disabled: !f,
3009
+ "data-menu-group": i,
3010
+ "data-starts-group": d ? "true" : "false",
3011
+ "data-command-enabled": f ? "true" : "false",
3012
+ "data-submenu-trigger": e.submenuId ?? void 0,
3013
+ "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",
3014
+ onMouseDown: (e) => e.preventDefault(),
3015
+ onMouseEnter: () => u(e.submenuId),
3016
+ onClick: () => {
3017
+ if (f) {
3018
+ if (e.submenuId) {
3019
+ u(e.submenuId);
3020
+ return;
3021
+ }
3022
+ if (e.commandId === null) {
3023
+ le(s === "row" || s === "column" ? s : "selection");
3024
+ return;
3025
+ }
3026
+ ce(e.commandId).finally(() => {
3027
+ c(null), u(null);
3028
+ });
3029
+ }
3030
+ },
3031
+ children: [
3032
+ /* @__PURE__ */ Z("span", {
3033
+ className: "markweave-table-menu-item-icon",
3034
+ "aria-hidden": "true",
3035
+ children: /* @__PURE__ */ Z(m, {
3036
+ size: 18,
3037
+ strokeWidth: 1.8
3038
+ })
3039
+ }),
3040
+ /* @__PURE__ */ Z("span", {
3041
+ className: "markweave-table-menu-item-label",
3042
+ children: p
3043
+ }),
3044
+ e.submenuId ? /* @__PURE__ */ Z(M, {
3045
+ className: "markweave-table-menu-chevron",
3046
+ "aria-hidden": "true",
3047
+ size: 16
3048
+ }) : null
3049
+ ]
3050
+ }, `${e.id}-${n}`);
3051
+ })
3052
+ }),
3053
+ l === "color" && (s === "row" || s === "column") ? /* @__PURE__ */ Q("div", {
3054
+ ref: P,
3055
+ className: "markweave-table-submenu markweave-table-color-menu",
3056
+ role: "menu",
3057
+ "aria-label": r.table.submenus.color,
3058
+ "data-testid": "markweave-table-color-menu",
3059
+ "data-positioned": h ? "true" : "false",
3060
+ "data-placement": h?.placement,
3061
+ style: h ? {
3062
+ left: h.left,
3063
+ top: h.top,
3064
+ maxHeight: h.maxHeight
3065
+ } : void 0,
3066
+ onKeyDown: U,
3067
+ children: [
3068
+ /* @__PURE__ */ Z("div", {
3069
+ className: "markweave-table-submenu-title",
3070
+ children: r.table.submenus.textColor
3071
+ }),
3072
+ Ur.map((e) => /* @__PURE__ */ Q("button", {
3073
+ type: "button",
3074
+ role: "menuitemradio",
3075
+ "aria-checked": de?.textColorId === e.id,
3076
+ "data-active": de?.textColorId === e.id ? "true" : "false",
3077
+ "data-testid": `markweave-table-text-color-${e.id}`,
3078
+ onMouseDown: (e) => e.preventDefault(),
3079
+ onClick: () => V((n) => xr(t, n, e.id)),
3080
+ children: [/* @__PURE__ */ Z("span", {
3081
+ className: "markweave-table-color-swatch markweave-table-text-color-swatch",
3082
+ "aria-hidden": "true",
3083
+ style: { backgroundColor: e.textColor ?? "var(--markweave-text)" }
3084
+ }), /* @__PURE__ */ Z("span", { children: r.table.colors[e.id].text })]
3085
+ }, `text-${e.id}`)),
3086
+ /* @__PURE__ */ Z("div", { className: "markweave-table-submenu-separator" }),
3087
+ /* @__PURE__ */ Z("div", {
3088
+ className: "markweave-table-submenu-title",
3089
+ children: r.table.submenus.backgroundColor
3090
+ }),
3091
+ Ur.map((e) => /* @__PURE__ */ Q("button", {
3092
+ type: "button",
3093
+ role: "menuitemradio",
3094
+ "aria-checked": de?.backgroundColorId === e.id,
3095
+ "data-active": de?.backgroundColorId === e.id ? "true" : "false",
3096
+ "data-testid": `markweave-table-background-color-${e.id}`,
3097
+ onMouseDown: (e) => e.preventDefault(),
3098
+ onClick: () => V((n) => br(t, n, e.id)),
3099
+ children: [/* @__PURE__ */ Z("span", {
3100
+ className: "markweave-table-color-swatch",
3101
+ "aria-hidden": "true",
3102
+ style: { backgroundColor: e.backgroundColor }
3103
+ }), /* @__PURE__ */ Z("span", { children: r.table.colors[e.id].background })]
3104
+ }, `background-${e.id}`))
3105
+ ]
3106
+ }) : null,
3107
+ l === "alignment" && (s === "row" || s === "column") ? /* @__PURE__ */ Q("div", {
3108
+ ref: P,
3109
+ className: "markweave-table-submenu markweave-table-alignment-menu",
3110
+ role: "menu",
3111
+ "aria-label": r.table.submenus.alignment,
3112
+ "data-testid": "markweave-table-alignment-menu",
3113
+ "data-positioned": h ? "true" : "false",
3114
+ "data-placement": h?.placement,
3115
+ style: h ? {
3116
+ left: h.left,
3117
+ top: h.top,
3118
+ maxHeight: h.maxHeight
3119
+ } : void 0,
3120
+ onKeyDown: U,
3121
+ children: [
3122
+ Gr.map((e) => {
3123
+ let n = Ca[e], i = de?.textAlign === e;
3124
+ return /* @__PURE__ */ Q("button", {
3125
+ type: "button",
3126
+ role: "menuitemradio",
3127
+ "aria-checked": i,
3128
+ "data-active": i ? "true" : "false",
3129
+ "data-testid": `markweave-table-alignment-${e}`,
3130
+ onMouseDown: (e) => e.preventDefault(),
3131
+ onClick: () => V((n) => yr(t, n, e)),
3132
+ children: [/* @__PURE__ */ Z(n, {
3133
+ "aria-hidden": "true",
3134
+ size: 18,
3135
+ strokeWidth: 1.8
3136
+ }), /* @__PURE__ */ Z("span", { children: r.table.alignments[e] })]
3137
+ }, e);
3138
+ }),
3139
+ /* @__PURE__ */ Z("div", { className: "markweave-table-submenu-separator" }),
3140
+ qr.map((e) => {
3141
+ let n = Ca[e], i = de?.verticalAlign === e;
3142
+ return /* @__PURE__ */ Q("button", {
3143
+ type: "button",
3144
+ role: "menuitemradio",
3145
+ "aria-checked": i,
3146
+ "data-active": i ? "true" : "false",
3147
+ "data-testid": `markweave-table-alignment-${e}`,
3148
+ onMouseDown: (e) => e.preventDefault(),
3149
+ onClick: () => V((n) => yr(t, n, e)),
3150
+ children: [/* @__PURE__ */ Z(n, {
3151
+ "aria-hidden": "true",
3152
+ size: 18,
3153
+ strokeWidth: 1.8
3154
+ }), /* @__PURE__ */ Z("span", { children: r.table.alignments[e] })]
3155
+ }, e);
3156
+ })
3157
+ ]
3158
+ }) : null
3159
+ ]
2746
3160
  }) : null
2747
3161
  ]
2748
3162
  });
2749
3163
  }
2750
3164
  //#endregion
2751
3165
  //#region src/ui/table/TableSelectionOverlay.tsx
2752
- function Pi({ editor: e, focusState: t }) {
2753
- let [n, r] = q(null);
2754
- return W(() => {
3166
+ function Ta({ editor: e, focusState: t }) {
3167
+ let [n, r] = Y(null);
3168
+ return K(() => {
2755
3169
  if (t.mode !== "cell-selection") {
2756
3170
  r(null);
2757
3171
  return;
2758
3172
  }
2759
3173
  let n = () => {
2760
- r(ir(e, Yt(e.state)));
3174
+ r(Br(e, bn(e.state)));
2761
3175
  };
2762
3176
  return n(), window.addEventListener("resize", n), window.addEventListener("scroll", n, !0), () => {
2763
3177
  window.removeEventListener("resize", n), window.removeEventListener("scroll", n, !0);
@@ -2773,6 +3187,7 @@ function Pi({ editor: e, focusState: t }) {
2773
3187
  ]), n ? /* @__PURE__ */ Z("div", {
2774
3188
  "aria-hidden": "true",
2775
3189
  className: "markweave-table-selection-overlay",
3190
+ "data-axis-target": n.axisTarget ?? "none",
2776
3191
  "data-anchor-cell-pos": n.anchorCellPos ?? "",
2777
3192
  "data-head-cell-pos": n.headCellPos ?? "",
2778
3193
  "data-selected-cells": n.selectedCellCount,
@@ -2792,16 +3207,16 @@ function Pi({ editor: e, focusState: t }) {
2792
3207
  }
2793
3208
  //#endregion
2794
3209
  //#region src/ui/toc/MarkweaveInnerToc.tsx
2795
- function Fi(e, t) {
3210
+ function Ea(e, t) {
2796
3211
  return `${e.toc.itemAriaLabel}: ${t.text}`;
2797
3212
  }
2798
- function Ii({ editor: e, state: t, messages: n, editable: r, placement: i }) {
2799
- let a = K(null);
2800
- if (U(() => {
2801
- if (!(i !== "container" || !a.current)) return mr(a.current);
3213
+ function Da({ editor: e, state: t, messages: n, editable: r, placement: i }) {
3214
+ let a = J(null);
3215
+ if (G(() => {
3216
+ if (!(i !== "container" || !a.current)) return ti(a.current);
2802
3217
  }, [i]), !t.items.length) return null;
2803
3218
  let o = (t) => {
2804
- hr(e, t, {
3219
+ ni(e, t, {
2805
3220
  behavior: "smooth",
2806
3221
  focus: r
2807
3222
  });
@@ -2828,7 +3243,7 @@ function Ii({ editor: e, state: t, messages: n, editable: r, placement: i }) {
2828
3243
  "data-level": e.level,
2829
3244
  "data-active": e.active ? "true" : "false",
2830
3245
  "aria-current": e.active ? "location" : void 0,
2831
- "aria-label": Fi(n, e),
3246
+ "aria-label": Ea(n, e),
2832
3247
  title: e.text,
2833
3248
  onClick: () => o(e),
2834
3249
  children: e.text
@@ -2839,7 +3254,7 @@ function Ii({ editor: e, state: t, messages: n, editable: r, placement: i }) {
2839
3254
  }
2840
3255
  //#endregion
2841
3256
  //#region src/MarkweaveEditor.tsx
2842
- var Li = {
3257
+ var Oa = {
2843
3258
  active: !1,
2844
3259
  mode: "outside",
2845
3260
  activeCellPos: null,
@@ -2847,21 +3262,21 @@ var Li = {
2847
3262
  selectedCellCount: 0,
2848
3263
  selectionFrom: 0,
2849
3264
  selectionTo: 0
2850
- }, Ri = {
3265
+ }, ka = {
2851
3266
  active: !1,
2852
- language: ht.defaultLanguage,
3267
+ language: Lt.defaultLanguage,
2853
3268
  mermaidPreviewMode: "code",
2854
3269
  pos: null,
2855
3270
  text: ""
2856
- }, zi = Ct({
3271
+ }, Aa = Gt({
2857
3272
  active: !1,
2858
3273
  mode: "code",
2859
3274
  source: ""
2860
3275
  });
2861
- function Bi(e) {
2862
- return Zt.getState(e.state) ?? Xt;
3276
+ function ja(e) {
3277
+ return Sn.getState(e.state) ?? xn;
2863
3278
  }
2864
- function Vi(e) {
3279
+ function Ma(e) {
2865
3280
  if (!e || typeof window > "u") return null;
2866
3281
  let t = e.parentElement;
2867
3282
  for (; t;) {
@@ -2871,133 +3286,141 @@ function Vi(e) {
2871
3286
  }
2872
3287
  return null;
2873
3288
  }
2874
- function Hi(e) {
3289
+ function Na(e) {
2875
3290
  return typeof window > "u" || typeof window.requestAnimationFrame != "function" ? globalThis.setTimeout(() => e(0), 0) : window.requestAnimationFrame(e);
2876
3291
  }
2877
- function Ui(e) {
3292
+ function Pa(e) {
2878
3293
  if (typeof window < "u" && typeof window.cancelAnimationFrame == "function") {
2879
3294
  window.cancelAnimationFrame(e);
2880
3295
  return;
2881
3296
  }
2882
3297
  globalThis.clearTimeout(e);
2883
3298
  }
2884
- function Wi({ ariaLabel: e, autoFocusFirstTableBodyCell: i = !1, autofocus: a = !1, content: o, contentFormat: c, defaultContent: l = "", defaultContentFormat: u, editable: d = !0, innerToc: f = !0, innerTocPlacement: p, lang: m, mode: h = "live", theme: g, canvasColor: _, onEditWithAi: v, onExtractToNote: y, onRewriteSelection: b, onRuntimeStateChange: x, onSearchControllerChange: S, onSlashCommandUpload: C, onTableCommandResult: w, onTableCopyPayload: T, onTocChange: E, onUpdate: D, linkCardResolver: O } = {}) {
2885
- let k = Ie(h), A = _r(g), j = gr(_), M = pr(p), N = k === "live" && d !== !1, P = Ze(o === void 0 ? u : c), F = K({
2886
- editorMode: k,
3299
+ function Fa({ ariaLabel: e, autoFocusFirstTableBodyCell: i = !1, autofocus: a = !1, content: o, contentFormat: c, defaultContent: l = "", defaultContentFormat: u, editable: d = !0, innerToc: f = !0, innerTocPlacement: p, lang: m, mode: h = "live", theme: g, canvasColor: _, onEditWithAi: v, onExtractToNote: y, onRewriteSelection: b, onRuntimeStateChange: x, onSearchControllerChange: S, onSlashCommandUpload: C, onTableCommandResult: w, onTableCopyPayload: T, onTocChange: E, onUpdate: D, linkCardResolver: O, resolveMediaSource: k } = {}) {
3300
+ let A = et(h), j = ii(g), M = ri(_), ee = ei(p), N = A === "live" && d !== !1, te = yt(o === void 0 ? u : c), P = o ?? l, ne = typeof P == "string" && P.length >= 2e5, F = o === void 0 && te === "markdown" && ne && typeof P == "string", I = J(F ? P : null), [L, re] = Y(F), R = J({
3301
+ editorMode: A,
2887
3302
  effectiveEditable: N
2888
3303
  });
2889
- F.current = {
2890
- editorMode: k,
3304
+ R.current = {
3305
+ editorMode: A,
2891
3306
  effectiveEditable: N
2892
3307
  };
2893
- let ee = K(null);
2894
- ee.current === null && (ee.current = r(m));
2895
- let I = ee.current, L = G(() => n(I), [I]), te = G(() => t(I), [I]), R = K(C);
2896
- R.current = C;
2897
- let z = K(S);
2898
- z.current = S;
2899
- let ne = K(O);
2900
- ne.current = O;
2901
- let re = G(() => Br({
2902
- lang: I,
3308
+ let ie = J(null);
3309
+ ie.current === null && (ie.current = r(m));
3310
+ let ae = ie.current, z = q(() => n(ae), [ae]), B = q(() => t(ae), [ae]), oe = J(C);
3311
+ oe.current = C;
3312
+ let se = J(S);
3313
+ se.current = S;
3314
+ let ce = J(O);
3315
+ ce.current = O;
3316
+ let le = q(() => ki({
3317
+ lang: ae,
2903
3318
  onImageUpload: (e) => {
2904
- if (R.current) return R.current(e);
2905
- let t = be(e);
3319
+ if (oe.current) return oe.current(e);
3320
+ let t = Le(e);
2906
3321
  if (!t) throw Error("File upload requires an upload handler.");
2907
3322
  return t;
2908
3323
  },
2909
3324
  onVideoUpload: (e) => {
2910
- if (R.current) return R.current(e);
2911
- let t = be(e);
3325
+ if (oe.current) return oe.current(e);
3326
+ let t = Le(e);
2912
3327
  if (!t) throw Error("File upload requires an upload handler.");
2913
3328
  return t;
2914
3329
  },
2915
- linkCardResolver: (e) => ne.current?.(e) ?? Promise.resolve(null)
2916
- }), [I]), [ie, ae] = q(null), [B, V] = q(Wt), [oe, se] = q(null), [ce, le] = q(null), [ue, de] = q("code"), [fe, pe] = q(null), [me, he] = q(Xt), [ge, _e] = q(null), [W, ve] = q(0), ye = K(!1), xe = K({
3330
+ linkCardResolver: (e) => ce.current?.(e) ?? Promise.resolve(null),
3331
+ resolveMediaSource: k
3332
+ }), [k, ae]), [V, ue] = Y(null), [H, U] = Y(hn), [de, fe] = Y(null), [pe, me] = Y(null), [he, ge] = Y("code"), [_e, ve] = Y(null), [ye, be] = Y(xn), [xe, Se] = Y(null), [Ce, we] = Y(0), Te = J(!1), Ee = J({
2917
3333
  content: o,
2918
- format: P
2919
- }), Se = K(null), Ce = K(null), we = K({ onUpdate: D }), Te = G(() => It(B.query, te), [te, B.query]);
2920
- we.current = { onUpdate: D }, xe.current = {
3334
+ format: te
3335
+ }), De = J(null), Oe = J(null), ke = J({ onUpdate: D }), Ae = q(() => an(H.query, B), [B, H.query]);
3336
+ ke.current = { onUpdate: D }, Ee.current = {
2921
3337
  content: o,
2922
- format: P
3338
+ format: te
2923
3339
  };
2924
- let Ee = H(() => {
2925
- Ce.current !== null && (window.clearTimeout(Ce.current), Ce.current = null), ve((e) => e + 1);
2926
- }, []), De = H(() => {
2927
- Ce.current !== null && window.clearTimeout(Ce.current), Ce.current = window.setTimeout(() => {
2928
- Ce.current = null, ve((e) => e + 1);
2929
- }, ct);
3340
+ let je = W(() => {
3341
+ Oe.current !== null && (window.clearTimeout(Oe.current), Oe.current = null), we((e) => e + 1);
3342
+ }, []), Me = W(() => {
3343
+ Oe.current !== null && window.clearTimeout(Oe.current), Oe.current = window.setTimeout(() => {
3344
+ Oe.current = null, we((e) => e + 1);
3345
+ }, At);
2930
3346
  }, []);
2931
- U(() => () => {
2932
- Ce.current !== null && window.clearTimeout(Ce.current);
3347
+ G(() => () => {
3348
+ Oe.current !== null && window.clearTimeout(Oe.current);
2933
3349
  }, []);
2934
- let Oe = H(() => {
2935
- se(null), le(null), V(Wt);
2936
- }, []), ke = H((e) => {
2937
- let t = Ut(e.state);
3350
+ let Ne = W(() => {
3351
+ fe(null), me(null), U(hn);
3352
+ }, []), Pe = W((e) => {
3353
+ let t = pn(e.state);
2938
3354
  if (!t) {
2939
- V((e) => e.name === "idle" ? e : Wt), se(null), le(null);
3355
+ U((e) => e.name === "idle" ? e : hn), fe(null), me(null);
2940
3356
  return;
2941
3357
  }
2942
3358
  let n = e.coordsAtPos(t.cursor), r = e.coordsAtPos(t.triggerFrom), i = e.dom.closest(".markweave-editor-frame")?.getBoundingClientRect();
2943
- se(Ht(n, {
3359
+ if (!mn(r, { frameRect: i })) {
3360
+ fe(null), me(null), U(hn);
3361
+ return;
3362
+ }
3363
+ let a = fn(n, {
2944
3364
  frameRect: i,
2945
3365
  triggerRect: r
2946
- })), V((e) => Vt(e, t));
2947
- }, []), Ae = H((e) => ke(e.view), [ke]), je = H((e) => {
2948
- let t = at(e);
2949
- ae((e) => tt(e, t) ? e : t);
2950
- let n = jt(e);
2951
- n && (Nt(e, n, !0), pe(n));
2952
- let r = pt(e);
2953
- r.active && r.language === "mermaid" && de(r.mermaidPreviewMode);
2954
- }, []), Me = H((e) => {
2955
- he(Bi(e));
2956
- }, []), J = s({
2957
- extensions: re,
2958
- content: o ?? l,
2959
- contentType: Je(P),
3366
+ });
3367
+ fe((e) => ln(e, a) ? e : a), U((e) => dn(e, t));
3368
+ }, []), K = W((e) => Pe(e.view), [Pe]), Fe = W((e) => {
3369
+ let t = Dt(e);
3370
+ ue((e) => Ct(e, t) ? e : t);
3371
+ let n = $t(e);
3372
+ n && (tn(e, n, !0), ve(n));
3373
+ let r = Ft(e);
3374
+ r.active && r.language === "mermaid" && ge(r.mermaidPreviewMode);
3375
+ }, []), Ie = W((e) => {
3376
+ be(ja(e));
3377
+ }, []), X = s({
3378
+ shouldRerenderOnTransaction: !1,
3379
+ extensions: le,
3380
+ content: F ? "" : P,
3381
+ contentType: gt(te),
2960
3382
  editable: N,
2961
3383
  autofocus: a,
2962
3384
  editorProps: {
2963
3385
  attributes: {
2964
3386
  class: "markweave-editor-surface",
2965
3387
  "data-testid": "markweave-editor-surface",
3388
+ "data-markweave-large-document": ne ? "true" : "false",
2966
3389
  autocapitalize: "off",
2967
3390
  autocorrect: "off",
2968
3391
  spellcheck: "false",
2969
3392
  translate: "no"
2970
3393
  },
2971
- handleClick: (e, t, n) => F.current.effectiveEditable ? !1 : Qe(n),
3394
+ handleClick: (e, t, n) => R.current.effectiveEditable ? !1 : bt(n),
2972
3395
  handleDOMEvents: {
2973
- compositionstart: () => F.current.effectiveEditable ? (V((e) => Gt(e, { type: "composition-start" })), se(null), !1) : !1,
2974
- compositionend: (e) => (F.current.effectiveEditable && window.setTimeout(() => ke(e), 0), !1),
3396
+ compositionstart: () => R.current.effectiveEditable ? (U((e) => gn(e, { type: "composition-start" })), fe(null), !1) : !1,
3397
+ compositionend: (e) => (R.current.effectiveEditable && window.setTimeout(() => Pe(e), 0), !1),
2975
3398
  click: (e, t) => {
2976
- if (F.current.effectiveEditable) {
2977
- let n = At(e, t);
2978
- return n ? (t.preventDefault(), t.stopPropagation(), Oe(), Pt(e, n, !0), Ft(e, n), pe(n), !0) : (pe(null), !1);
3399
+ if (R.current.effectiveEditable) {
3400
+ let n = Qt(e, t);
3401
+ return n ? (t.preventDefault(), t.stopPropagation(), Ne(), nn(e, n, !0), rn(e, n), ve(n), !0) : (ve(null), !1);
2979
3402
  }
2980
- return Qe(t);
3403
+ return bt(t);
2981
3404
  }
2982
3405
  }
2983
3406
  },
2984
3407
  onSelectionUpdate: ({ editor: e }) => {
2985
- je(e);
3408
+ Fe(e);
2986
3409
  },
2987
3410
  onCreate: ({ editor: e }) => {
2988
- i && F.current.effectiveEditable && qt(e), Me(e), je(e), Ee();
3411
+ i && R.current.effectiveEditable && vn(e), Ie(e), Fe(e), je();
2989
3412
  },
2990
3413
  onTransaction: ({ editor: e, transaction: t }) => {
2991
- Me(e), (t.docChanged || yt(t)) && De(), t.docChanged && pe((t) => {
3414
+ Ie(e), (t.docChanged || Vt(t)) && Me(), t.docChanged && ve((t) => {
2992
3415
  if (!t) return null;
2993
- let n = kt(e, t.pos);
3416
+ let n = Zt(e, t.pos);
2994
3417
  return n?.kind === t.kind ? n : null;
2995
3418
  });
2996
3419
  },
2997
3420
  onUpdate: ({ editor: e }) => {
2998
- je(e), F.current.effectiveEditable && Ae(e), ye.current || we.current.onUpdate?.(qe(e, { onContentRead: (t, n) => {
2999
- let r = xe.current;
3000
- r.content !== void 0 && t === r.format && (Se.current = {
3421
+ Fe(e), R.current.effectiveEditable && K(e), Te.current || ke.current.onUpdate?.(ht(e, { onContentRead: (t, n) => {
3422
+ let r = Ee.current;
3423
+ r.content !== void 0 && t === r.format && (De.current = {
3001
3424
  content: n,
3002
3425
  format: t,
3003
3426
  doc: e.state.doc
@@ -3005,318 +3428,375 @@ function Wi({ ariaLabel: e, autoFocusFirstTableBodyCell: i = !1, autofocus: a =
3005
3428
  } }));
3006
3429
  }
3007
3430
  });
3008
- U(() => {
3009
- if (J) return z.current?.(vr(J)), () => {
3010
- z.current?.(null);
3431
+ G(() => {
3432
+ let e = I.current;
3433
+ if (!X || !e) return;
3434
+ let t = !1;
3435
+ return (async () => {
3436
+ Te.current = !0;
3437
+ try {
3438
+ let n = !0;
3439
+ for (let r of ai(e)) {
3440
+ if (await new Promise((e) => window.setTimeout(e, 0)), t) return;
3441
+ let e = X.markdown?.parse(r);
3442
+ if (!e) throw Error("Markdown parser is unavailable.");
3443
+ 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);
3444
+ X.view.dispatch(a.setMeta("addToHistory", !1)), n = !1;
3445
+ }
3446
+ if (t) return;
3447
+ Fe(X), Ie(X), je(), I.current = null, re(!1);
3448
+ } finally {
3449
+ Te.current = !1;
3450
+ }
3451
+ })().catch(() => {
3452
+ t || (X.commands.setContent(e, {
3453
+ contentType: "markdown",
3454
+ emitUpdate: !1
3455
+ }), I.current = null, re(!1));
3456
+ }), () => {
3457
+ t = !0;
3011
3458
  };
3012
- }, [J]), U(() => {
3013
- J && (J.setEditable(N), Le(J, {
3014
- mode: k,
3015
- editable: N
3016
- }), xt(J, N ? "live" : "view"), Ee(), N || Oe());
3017
3459
  }, [
3018
- Oe,
3019
- J,
3020
- k,
3460
+ X,
3461
+ je,
3462
+ Fe,
3463
+ Ie
3464
+ ]), G(() => {
3465
+ if (X) return se.current?.(oi(X)), () => {
3466
+ se.current?.(null);
3467
+ };
3468
+ }, [X]), G(() => {
3469
+ if (!X) return;
3470
+ let e = N && !L;
3471
+ X.setEditable(e), tt(X, {
3472
+ mode: A,
3473
+ editable: e
3474
+ }), Ut(X, e ? "live" : "view"), je(), N || Ne();
3475
+ }, [
3476
+ Ne,
3477
+ X,
3478
+ A,
3021
3479
  N,
3022
- Ee
3023
- ]), U(() => {
3024
- J && bt(J, A);
3025
- }, [J, A]), U(() => {
3026
- let e = Ze(c);
3027
- if (!(!J || o === void 0)) {
3028
- if (Xe(J, Se.current, o, e)) {
3029
- Se.current = null;
3480
+ je,
3481
+ L
3482
+ ]), G(() => {
3483
+ X && Ht(X, j);
3484
+ }, [X, j]), G(() => {
3485
+ let e = yt(c);
3486
+ if (!(!X || o === void 0)) {
3487
+ if (vt(X, De.current, o, e)) {
3488
+ De.current = null;
3030
3489
  return;
3031
3490
  }
3032
- Se.current = null, !Ye(J, o, e) && (ye.current = !0, J.commands.setContent(o, {
3033
- contentType: Je(e),
3491
+ De.current = null, !_t(X, o, e) && (Te.current = !0, X.commands.setContent(o, {
3492
+ contentType: gt(e),
3034
3493
  emitUpdate: !1
3035
- }), ye.current = !1, je(J), N && Ae(J), Me(J), Ee());
3494
+ }), Te.current = !1, Fe(X), N && K(X), Ie(X), je());
3036
3495
  }
3037
3496
  }, [
3038
3497
  o,
3039
3498
  c,
3040
3499
  N,
3041
- J,
3042
- Ee,
3500
+ X,
3043
3501
  je,
3044
- Ae,
3045
- Me
3046
- ]), U(() => {
3047
- if (!oe) return;
3502
+ Fe,
3503
+ K,
3504
+ Ie
3505
+ ]), G(() => {
3506
+ if (!de) return;
3048
3507
  let e = (e) => {
3049
3508
  let t = e.target;
3050
- t instanceof Element && (t.closest(".markweave-slash-menu") || t.closest(".markweave-slash-trigger") || Oe());
3509
+ t instanceof Element && (t.closest(".markweave-slash-menu") || t.closest(".markweave-slash-trigger") || Ne());
3051
3510
  };
3052
3511
  return document.addEventListener("pointerdown", e, !0), () => document.removeEventListener("pointerdown", e, !0);
3053
- }, [Oe, oe]);
3054
- let Ne = G(() => J ? pt(J) : Ri, [
3055
- J,
3056
- W,
3057
- ie
3058
- ]), Y = G(() => J ? Jt(J.state) : Li, [
3059
- J,
3060
- W,
3061
- ie,
3062
- me
3063
- ]), Pe = ie?.currentNode === "codeBlock", Fe = Pe && Ne.language === "mermaid", Re = G(() => J ? Ct({
3064
- active: Fe,
3065
- mode: ue,
3066
- source: Ne.text
3067
- }) : zi, [
3068
- Ne.text,
3069
- J,
3070
- Fe,
3071
- ue
3072
- ]), ze = G(() => J ? Kt(J.state) : null, [J, W]), X = G(() => J ? dr(J.state.doc) : lr.items, [J, W]), Z = G(() => fr(X, ge), [ge, X]), Q = G(() => cr(X, Z), [Z, X]), Be = H(() => {
3073
- if (!J || !X.length) {
3074
- _e(null);
3512
+ }, [Ne, de]);
3513
+ let Re = de !== null;
3514
+ G(() => {
3515
+ if (!X || !Re) return;
3516
+ let e = mt(() => {
3517
+ X.isDestroyed || Pe(X.view);
3518
+ }), t = () => e.schedule();
3519
+ return window.addEventListener("resize", t), window.addEventListener("scroll", t, !0), t(), () => {
3520
+ e.cancel(), window.removeEventListener("resize", t), window.removeEventListener("scroll", t, !0);
3521
+ };
3522
+ }, [
3523
+ X,
3524
+ Re,
3525
+ Pe
3526
+ ]);
3527
+ let ze = q(() => X ? Ft(X) : ka, [
3528
+ X,
3529
+ Ce,
3530
+ V
3531
+ ]), Be = q(() => X ? yn(X.state) : Oa, [
3532
+ X,
3533
+ Ce,
3534
+ V,
3535
+ ye
3536
+ ]), Ve = V?.currentNode === "codeBlock", He = Ve && ze.language === "mermaid", Ue = q(() => X ? Gt({
3537
+ active: He,
3538
+ mode: he,
3539
+ source: ze.text
3540
+ }) : Aa, [
3541
+ ze.text,
3542
+ X,
3543
+ He,
3544
+ he
3545
+ ]), We = q(() => X && x ? _n(X.state) : null, [
3546
+ X,
3547
+ x,
3548
+ Ce
3549
+ ]), Ge = q(() => X ? Qr(X.state) : Xr.items, [X, Ce]), Ke = q(() => $r(Ge, xe), [xe, Ge]), qe = q(() => Yr(Ge, Ke), [Ke, Ge]), Je = W(() => {
3550
+ if (!X || !Ge.length) {
3551
+ Se(null);
3075
3552
  return;
3076
3553
  }
3077
- let e = ur(J, X);
3078
- _e((t) => t === e ? t : e);
3079
- }, [J, X]);
3080
- U(() => {
3081
- _e((e) => {
3082
- let t = fr(X, e);
3554
+ let e = Zr(X, Ge);
3555
+ Se((t) => t === e ? t : e);
3556
+ }, [X, Ge]);
3557
+ G(() => {
3558
+ Se((e) => {
3559
+ let t = $r(Ge, e);
3083
3560
  return e === t ? e : t;
3084
3561
  });
3085
- }, [X]), U(() => {
3086
- if (!J || !X.length || typeof window > "u") return;
3562
+ }, [Ge]), G(() => {
3563
+ if (!X || !Ge.length || typeof window > "u") return;
3087
3564
  let e = null, t = () => {
3088
- e !== null && Ui(e), e = Hi(() => {
3089
- e = null, Be();
3565
+ e !== null && Pa(e), e = Na(() => {
3566
+ e = null, Je();
3090
3567
  });
3091
- }, n = Vi(J.view.dom);
3568
+ }, n = Ma(X.view.dom);
3092
3569
  return window.addEventListener("scroll", t, { passive: !0 }), window.addEventListener("resize", t), n?.addEventListener("scroll", t, { passive: !0 }), t(), () => {
3093
- window.removeEventListener("scroll", t), window.removeEventListener("resize", t), n?.removeEventListener("scroll", t), e !== null && Ui(e);
3570
+ window.removeEventListener("scroll", t), window.removeEventListener("resize", t), n?.removeEventListener("scroll", t), e !== null && Pa(e);
3094
3571
  };
3095
3572
  }, [
3096
- J,
3097
- X.length,
3098
- Be
3573
+ X,
3574
+ Ge.length,
3575
+ Je
3099
3576
  ]);
3100
- let Ve = G(() => $e({
3101
- revision: W,
3102
- mode: k,
3577
+ let Ye = q(() => xt({
3578
+ revision: Ce,
3579
+ mode: A,
3103
3580
  editable: N,
3104
- toc: Q,
3105
- selection: ie,
3106
- slash: B,
3107
- table: Y,
3108
- tableInteraction: me,
3109
- codeBlock: Ne,
3110
- mermaid: Re,
3111
- tableDebugSnapshot: ze
3581
+ toc: qe,
3582
+ selection: V,
3583
+ slash: H,
3584
+ table: Be,
3585
+ tableInteraction: ye,
3586
+ codeBlock: ze,
3587
+ mermaid: Ue,
3588
+ tableDebugSnapshot: We
3112
3589
  }), [
3113
- Ne,
3114
- k,
3115
- N,
3116
- Re,
3117
- W,
3118
- ie,
3119
- B,
3120
3590
  ze,
3121
- Y,
3122
- me,
3123
- Q
3591
+ A,
3592
+ N,
3593
+ Ue,
3594
+ Ce,
3595
+ V,
3596
+ H,
3597
+ We,
3598
+ Be,
3599
+ ye,
3600
+ qe
3124
3601
  ]);
3125
- U(() => {
3126
- x?.(Ve);
3127
- }, [x, Ve]), U(() => {
3128
- E?.(Q);
3129
- }, [E, Q]);
3130
- let He = H((e, t) => {
3131
- if (!(!J || !N) && Lt(e)) {
3602
+ G(() => {
3603
+ x?.(Ye);
3604
+ }, [x, Ye]), G(() => {
3605
+ E?.(qe);
3606
+ }, [E, qe]);
3607
+ let Xe = W((e, t) => {
3608
+ if (!(!X || !N) && on(e)) {
3132
3609
  if (e.inputKind && !t?.emoji && !t?.uploadResult) {
3133
- le(e);
3610
+ me(e);
3134
3611
  return;
3135
3612
  }
3136
- Bt(J, B, e, t), V((e) => Gt(e, { type: "execute" })), Oe();
3613
+ un(X, H, e, t), U((e) => gn(e, { type: "execute" })), Ne();
3137
3614
  }
3138
3615
  }, [
3139
- Oe,
3616
+ Ne,
3140
3617
  N,
3141
- J,
3142
- B
3143
- ]), Ue = H((e) => {
3144
- V((t) => Gt(t, {
3618
+ X,
3619
+ H
3620
+ ]), Ze = W((e) => {
3621
+ U((t) => gn(t, {
3145
3622
  type: "set-active",
3146
3623
  index: e,
3147
- optionCount: Te.length
3624
+ optionCount: Ae.length
3148
3625
  }));
3149
- }, [Te.length]), We = H((e) => {
3150
- if (!J || ce || !N) return;
3151
- let t = Rt(B, Te, e.key, { isComposing: e.nativeEvent.isComposing || Ke(J.state) });
3626
+ }, [Ae.length]), Qe = W((e) => {
3627
+ if (!X || pe || !N) return;
3628
+ let t = sn(H, Ae, e.key, { isComposing: e.nativeEvent.isComposing || pt(X.state) });
3152
3629
  if (t.type !== "ignore") {
3153
3630
  if (t.type === "close") {
3154
- e.preventDefault(), V((e) => Gt(e, { type: "escape" })), Oe();
3631
+ e.preventDefault(), U((e) => gn(e, { type: "escape" })), Ne();
3155
3632
  return;
3156
3633
  }
3157
3634
  if (t.type === "move-active") {
3158
- e.preventDefault(), V((e) => Gt(e, {
3635
+ e.preventDefault(), U((e) => gn(e, {
3159
3636
  type: "move-active",
3160
3637
  delta: t.delta,
3161
3638
  optionCount: t.optionCount
3162
3639
  }));
3163
3640
  return;
3164
3641
  }
3165
- t.type === "execute-active" && (e.preventDefault(), He(t.command));
3642
+ t.type === "execute-active" && (e.preventDefault(), Xe(t.command));
3166
3643
  }
3167
3644
  }, [
3168
- Oe,
3645
+ Ne,
3169
3646
  N,
3170
- J,
3171
- Te,
3172
- He,
3173
- ce,
3174
- B
3175
- ]), Ge = G(() => ({
3176
- closeSlashMenu: Oe,
3177
- focusFirstTableBodyCell: () => J ? qt(J) : !1,
3647
+ X,
3648
+ Ae,
3649
+ Xe,
3650
+ pe,
3651
+ H
3652
+ ]), $e = q(() => ({
3653
+ closeSlashMenu: Ne,
3654
+ focusFirstTableBodyCell: () => X ? vn(X) : !1,
3178
3655
  setContent: (e, t = {}) => {
3179
- if (!J) return !1;
3180
- let n = Ze(t.format);
3181
- return J.commands.setContent(e, {
3182
- contentType: Je(n),
3656
+ if (!X) return !1;
3657
+ let n = yt(t.format);
3658
+ return X.commands.setContent(e, {
3659
+ contentType: gt(n),
3183
3660
  emitUpdate: t.emitUpdate ?? !1
3184
- }), t.focusFirstTableBodyCell && qt(J), je(J), N && Ae(J), Me(J), Ee(), !0;
3661
+ }), t.focusFirstTableBodyCell && vn(X), Fe(X), N && K(X), Ie(X), je(), !0;
3185
3662
  }
3186
3663
  }), [
3187
- Oe,
3664
+ Ne,
3188
3665
  N,
3189
- J,
3190
- Ee,
3666
+ X,
3191
3667
  je,
3192
- Ae,
3193
- Me
3668
+ Fe,
3669
+ K,
3670
+ Ie
3194
3671
  ]);
3195
3672
  return {
3196
- editor: J,
3197
- frameProps: G(() => ({
3673
+ editor: X,
3674
+ frameProps: q(() => ({
3198
3675
  className: "markweave-editor-frame",
3199
- "aria-label": e ?? L.common.editorAriaLabel,
3676
+ "aria-label": e ?? z.common.editorAriaLabel,
3200
3677
  "data-testid": "markweave-editor-frame",
3201
- "data-markweave-mode": k,
3202
- "data-markweave-theme": A,
3203
- style: j ? { "--markweave-canvas": j } : void 0,
3678
+ "data-markweave-mode": A,
3679
+ "aria-busy": L,
3680
+ "data-markweave-large-document-loading": L ? "true" : "false",
3681
+ "data-markweave-theme": j,
3682
+ style: M ? { "--markweave-canvas": M } : void 0,
3204
3683
  "data-markweave-inner-toc": f ? "true" : "false",
3205
- "data-markweave-inner-toc-placement": M,
3206
- "data-mermaid-mode": Re.mode,
3207
- "data-table-focus-mode": Y.mode,
3208
- onKeyDownCapture: We
3684
+ "data-markweave-inner-toc-placement": ee,
3685
+ "data-mermaid-mode": Ue.mode,
3686
+ "data-table-focus-mode": Be.mode,
3687
+ onKeyDownCapture: Qe
3209
3688
  }), [
3210
3689
  e,
3211
- k,
3212
- We,
3690
+ A,
3691
+ Qe,
3213
3692
  f,
3214
- Re.mode,
3215
- L.common.editorAriaLabel,
3216
- j,
3693
+ L,
3694
+ Ue.mode,
3695
+ z.common.editorAriaLabel,
3217
3696
  M,
3218
- A,
3219
- Y.mode
3697
+ ee,
3698
+ j,
3699
+ Be.mode
3220
3700
  ]),
3221
- overlayProps: G(() => ({
3222
- floatingToolbar: J && N ? {
3223
- editor: J,
3224
- messages: L,
3225
- selectionSnapshot: ie,
3701
+ overlayProps: q(() => ({
3702
+ floatingToolbar: X && N ? {
3703
+ editor: X,
3704
+ messages: z,
3705
+ selectionSnapshot: V,
3226
3706
  onRewriteSelection: b,
3227
3707
  onExtractToNote: y
3228
3708
  } : null,
3229
- slashCommandMenu: J && N ? {
3230
- commands: Te,
3231
- state: B,
3232
- position: oe,
3233
- inputCommand: ce,
3234
- messages: L,
3235
- onActiveIndexChange: Ue,
3236
- onInputCommandChange: le,
3237
- onSelect: He,
3709
+ slashCommandMenu: X && N ? {
3710
+ commands: Ae,
3711
+ state: H,
3712
+ position: de,
3713
+ inputCommand: pe,
3714
+ messages: z,
3715
+ onActiveIndexChange: Ze,
3716
+ onInputCommandChange: me,
3717
+ onSelect: Xe,
3238
3718
  onUpload: C
3239
3719
  } : null,
3240
- tableControls: J && N ? {
3241
- editor: J,
3242
- active: Y.active,
3243
- interactionState: me,
3244
- messages: L,
3720
+ tableControls: X && N ? {
3721
+ editor: X,
3722
+ active: Be.active,
3723
+ interactionState: ye,
3724
+ messages: z,
3245
3725
  onCopyPayload: T,
3246
3726
  onCommandResult: w,
3247
3727
  onEditWithAi: v
3248
3728
  } : null,
3249
- tableSelectionOverlay: J && N ? {
3250
- editor: J,
3251
- focusState: Y
3729
+ tableSelectionOverlay: X && N ? {
3730
+ editor: X,
3731
+ focusState: Be
3252
3732
  } : null,
3253
- codeBlockControls: J ? {
3254
- editor: J,
3255
- active: N && Pe,
3256
- mermaidMode: ue,
3257
- onMermaidModeChange: de,
3733
+ codeBlockControls: X ? {
3734
+ editor: X,
3735
+ active: N && Ve,
3736
+ mermaidMode: he,
3737
+ onMermaidModeChange: ge,
3258
3738
  readOnly: !N
3259
3739
  } : null,
3260
- innerToc: J && f && Q.items.length ? {
3261
- editor: J,
3740
+ innerToc: X && f && qe.items.length ? {
3741
+ editor: X,
3262
3742
  editable: N,
3263
- messages: L,
3264
- placement: M,
3265
- state: Q
3743
+ messages: z,
3744
+ placement: ee,
3745
+ state: qe
3266
3746
  } : null,
3267
- mathEditorPopover: J && N && fe ? {
3268
- editor: J,
3269
- messages: L,
3270
- target: fe,
3271
- onClose: () => pe(null)
3747
+ mathEditorPopover: X && N && _e ? {
3748
+ editor: X,
3749
+ messages: z,
3750
+ target: _e,
3751
+ onClose: () => ve(null)
3272
3752
  } : null
3273
3753
  }), [
3274
3754
  N,
3275
- J,
3276
- Te,
3755
+ X,
3756
+ Ae,
3277
3757
  f,
3278
- Pe,
3279
- ue,
3280
- L,
3281
- fe,
3758
+ Ve,
3759
+ he,
3760
+ z,
3761
+ _e,
3282
3762
  v,
3283
3763
  y,
3284
3764
  b,
3285
3765
  C,
3286
3766
  w,
3287
3767
  T,
3288
- He,
3289
- ie,
3290
- Ue,
3291
- ce,
3292
- oe,
3293
- B,
3294
- Y,
3295
- me,
3296
- Q
3768
+ Xe,
3769
+ V,
3770
+ Ze,
3771
+ pe,
3772
+ de,
3773
+ H,
3774
+ Be,
3775
+ ye,
3776
+ qe
3297
3777
  ]),
3298
- runtimeSnapshot: Ve,
3299
- actions: Ge
3778
+ runtimeSnapshot: Ye,
3779
+ actions: $e
3300
3780
  };
3301
3781
  }
3302
- function Gi({ className: e, ...t }) {
3303
- let n = Wi(t);
3782
+ function Ia({ className: e, ...t }) {
3783
+ let n = Fa(t);
3304
3784
  if (!n.editor) return null;
3305
3785
  let r = [n.frameProps.className, e].filter(Boolean).join(" ");
3306
3786
  return /* @__PURE__ */ Q("section", {
3307
3787
  ...n.frameProps,
3308
3788
  className: r,
3309
3789
  children: [
3310
- n.overlayProps.floatingToolbar ? /* @__PURE__ */ Z(ui, { ...n.overlayProps.floatingToolbar }) : null,
3311
- n.overlayProps.slashCommandMenu ? /* @__PURE__ */ Z(ji, { ...n.overlayProps.slashCommandMenu }) : null,
3312
- n.overlayProps.tableControls ? /* @__PURE__ */ Z(Ni, { ...n.overlayProps.tableControls }) : null,
3313
- n.overlayProps.tableSelectionOverlay ? /* @__PURE__ */ Z(Pi, { ...n.overlayProps.tableSelectionOverlay }) : null,
3314
- n.overlayProps.codeBlockControls ? /* @__PURE__ */ Z(Ur, { ...n.overlayProps.codeBlockControls }) : null,
3315
- n.overlayProps.innerToc ? /* @__PURE__ */ Z(Ii, { ...n.overlayProps.innerToc }) : null,
3316
- n.overlayProps.mathEditorPopover ? /* @__PURE__ */ Z(Si, { ...n.overlayProps.mathEditorPopover }) : null,
3790
+ n.overlayProps.floatingToolbar ? /* @__PURE__ */ Z($i, { ...n.overlayProps.floatingToolbar }) : null,
3791
+ n.overlayProps.slashCommandMenu ? /* @__PURE__ */ Z(ba, { ...n.overlayProps.slashCommandMenu }) : null,
3792
+ n.overlayProps.tableControls ? /* @__PURE__ */ Z(wa, { ...n.overlayProps.tableControls }) : null,
3793
+ n.overlayProps.tableSelectionOverlay ? /* @__PURE__ */ Z(Ta, { ...n.overlayProps.tableSelectionOverlay }) : null,
3794
+ n.overlayProps.codeBlockControls ? /* @__PURE__ */ Z(Mi, { ...n.overlayProps.codeBlockControls }) : null,
3795
+ n.overlayProps.innerToc ? /* @__PURE__ */ Z(Da, { ...n.overlayProps.innerToc }) : null,
3796
+ n.overlayProps.mathEditorPopover ? /* @__PURE__ */ Z(da, { ...n.overlayProps.mathEditorPopover }) : null,
3317
3797
  /* @__PURE__ */ Z(i, { editor: n.editor })
3318
3798
  ]
3319
3799
  });
3320
3800
  }
3321
3801
  //#endregion
3322
- export { Gi as MarkweaveEditor, Br as createMarkweaveEditorExtensions, Br as createMarkweaveReactEditorExtensions, Wi as useMarkweaveEditorController };
3802
+ export { Ia as MarkweaveEditor, ki as createMarkweaveEditorExtensions, ki as createMarkweaveReactEditorExtensions, Fa as useMarkweaveEditorController };