@markweave/react 0.2.6 → 0.3.1

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