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