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