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