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