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