@markweave/react 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +19 -19
- package/dist/index.js +785 -712
- package/dist/types/MarkweaveEditor.d.ts.map +1 -1
- package/dist/types/media/video-node.d.ts.map +1 -1
- package/dist/types/ui/floating-toolbar/FloatingToolbar.d.ts.map +1 -1
- package/dist/types/ui/floating-toolbar/behavior-contract.d.ts +1 -1
- package/dist/types/ui/floating-toolbar/behavior-contract.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,54 +1,55 @@
|
|
|
1
1
|
import { createMarkweaveEditorExtensions as e } from "markweave/internal/editor-core/create-editor-extensions";
|
|
2
2
|
import { EditorContent as t, NodeViewWrapper as n, ReactNodeViewRenderer as r, useEditor as i } from "@tiptap/react";
|
|
3
|
-
import { AlertTriangle as a, AlignCenter as o, AlignJustify as s, AlignLeft as c, AlignRight as l, Bold as u, Braces as d, Captions as f, Check as p, CheckCircle2 as m, ChevronDown as h, ChevronUp as g, CircleX as _, Code2 as v, CornerDownLeft as y, Download as b, ExternalLink as x, Eye as S, Heading1 as
|
|
3
|
+
import { AlertTriangle as a, AlignCenter as o, AlignJustify as s, AlignLeft as c, AlignRight as l, Bold as u, Braces as d, Captions as f, Check as p, CheckCircle2 as m, ChevronDown as h, ChevronUp as g, CircleX as _, Code2 as v, CornerDownLeft as y, Download as b, ExternalLink as x, Eye as S, Heading1 as ee, Heading2 as C, Heading3 as w, Image as T, ImageUp as E, IndentDecrease as D, IndentIncrease as O, Info as k, Italic as A, Lightbulb as j, Link2 as M, List as N, ListChecks as P, ListOrdered as F, Minus as te, MoreVertical as I, Paperclip as L, Quote as ne, Replace as R, Sigma as z, SmilePlus as re, Sparkles as ie, Strikethrough as ae, Subscript as oe, Superscript as se, Table2 as ce, Text as le, Trash2 as ue, Type as de, Underline as fe, Upload as pe, Video as B } from "lucide-react";
|
|
4
4
|
import { useCallback as V, useEffect as H, useLayoutEffect as me, useMemo as U, useRef as W, useState as G, useSyncExternalStore as he } from "react";
|
|
5
|
-
import { detectUploadSource as ge, getDirectUploadResult as _e, resolveMarkweaveUploadResult as
|
|
6
|
-
import { MarkweaveCoreImage as
|
|
5
|
+
import { detectUploadSource as ge, getDirectUploadResult as _e, resolveMarkweaveUploadResult as ve } from "markweave/internal/plugins/slash-command/upload";
|
|
6
|
+
import { MarkweaveCoreImage as K, MarkweaveCoreVideo as ye, attrsFromMarkweaveImageUploadResult as be, attrsFromMarkweaveVideoUploadResult as xe, attrsFromMarkweaveVideoUrl as Se, clampMarkweaveImageWidth as q, createMarkweaveImageUploadRequest as Ce, createMarkweaveVideoUploadRequest as we, downloadMarkweaveImage as Te, markweaveVideoIframeAllow as Ee, normalizeMarkweaveCoreImageAlign as De, normalizeMarkweaveVideoEmbedUrl as Oe, numberAttribute as J, stringAttribute as Y } from "markweave/internal/plugins/media/core-media-nodes";
|
|
7
7
|
import { getLocalizedSlashCommandSpecs as ke, getMarkweaveMessages as Ae, normalizeMarkweaveLang as je } from "markweave/internal/i18n";
|
|
8
8
|
import { getMarkweaveEditorModeState as Me, isMarkweaveEditorLiveEditable as Ne, normalizeMarkweaveEditorMode as Pe, setMarkweaveEditorModeState as Fe, subscribeToMarkweaveEditorMode as Ie } from "markweave/internal/core/editor-mode-state";
|
|
9
9
|
import { openMarkweaveImagePreview as Le } from "markweave/internal/plugins/media/image-preview";
|
|
10
10
|
import { Fragment as X, jsx as Z, jsxs as Q } from "react/jsx-runtime";
|
|
11
11
|
import { createMarkweaveAdapterMediaExtensions as Re } from "markweave/internal/plugins/media/media-extension-factory";
|
|
12
12
|
import { isEditorComposing as ze } from "markweave/internal/editor-core/composition-guard";
|
|
13
|
-
import { createMarkweaveEditorUpdatePayload as Be, getMarkweaveContentType as Ve, isEditorContentCurrent as He,
|
|
14
|
-
import { openMarkweaveReadonlyLinkFromEvent as
|
|
15
|
-
import { createMarkweaveEditorRuntimeSnapshot as
|
|
16
|
-
import { advanceFloatingToolbarMotionState as
|
|
17
|
-
import { codeBlockCollapsePluginKey as
|
|
18
|
-
import { isMermaidInlinePreviewTransaction as
|
|
19
|
-
import { getMermaidPreviewState as
|
|
20
|
-
import { applyMarkweaveMathLatex as
|
|
21
|
-
import { filterSlashCommands as
|
|
22
|
-
import { getSlashCommandKeyboardAction as
|
|
23
|
-
import { executeSlashCommand as
|
|
24
|
-
import { initialSlashCommandState as
|
|
25
|
-
import { getFirstTableDebugSnapshot as
|
|
26
|
-
import { focusFirstTableBodyCell as
|
|
27
|
-
import { getTableFocusState as
|
|
28
|
-
import { getTableSelectionOverlayState as
|
|
29
|
-
import { calculateCodeBlockLanguageMenuPosition as
|
|
30
|
-
import { BubbleMenu as
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
13
|
+
import { createMarkweaveEditorUpdatePayload as Be, getMarkweaveContentType as Ve, isEditorContentCurrent as He, isMarkweaveControlledContentEchoCurrent as Ue, normalizeMarkweaveContentFormat as We } from "markweave/internal/editor-core/editor-content";
|
|
14
|
+
import { openMarkweaveReadonlyLinkFromEvent as Ge } from "markweave/internal/editor-core/readonly-link";
|
|
15
|
+
import { createMarkweaveEditorRuntimeSnapshot as Ke } from "markweave/internal/editor-core/runtime-snapshot";
|
|
16
|
+
import { advanceFloatingToolbarMotionState as qe, areEditorSelectionSnapshotsEquivalent as Je, calculateFloatingToolbarFrameShift as Ye, calculateFloatingToolbarPopoverPlacement as Xe, calculateFloatingToolbarTopBoundary as Ze, createSelectionSnapshot as Qe, getFloatingToolbarFloatingOptions as $e, getFloatingToolbarState as et, markweaveRuntimeProjectionDelayMs as tt, shouldShowFloatingToolbar as nt, transitionFloatingToolbarState as rt } from "markweave/internal/editor-core/selection-state";
|
|
17
|
+
import { codeBlockCollapsePluginKey as it, copyActiveCodeBlock as at, getActiveCodeBlockState as ot, getCodeBlockCopyFeedbackSnapshot as st, markweaveCodeBlockBehavior as ct, setCodeBlockCollapsedAtPosition as lt, setCodeBlockLanguageAtPosition as ut, setCodeBlockMermaidPreviewModeAtPosition as dt } from "markweave/internal/plugins/codeblock/codeblock-behavior";
|
|
18
|
+
import { isMermaidInlinePreviewTransaction as ft, setMermaidInlinePreviewEditorMode as pt, setReadonlyMermaidPreviewMode as mt } from "markweave/internal/plugins/mermaid/mermaid-inline-preview";
|
|
19
|
+
import { getMermaidPreviewState as ht } from "markweave/internal/plugins/mermaid/mermaid-renderer";
|
|
20
|
+
import { applyMarkweaveMathLatex as gt, calculateMarkweaveMathPopoverPosition as _t, getMarkweaveMathAnchorRect as vt, getMarkweaveMathBlockIndex as yt, getMarkweaveMathRenderedHtml as bt, getMarkweaveMathTargetAtPos as xt, getMarkweaveMathTargetFromDomEvent as St, getMarkweaveMathTargetFromSelection as Ct, renderMarkweaveMathPreview as wt, setMarkweaveMathEditingDomState as Tt, setMarkweaveMathEditingDomStateInView as Et, setMarkweaveMathSelectionInView as Dt } from "markweave/internal/plugins/math/math-ui-model";
|
|
21
|
+
import { filterSlashCommands as Ot, isExecutableSlashCommand as kt } from "markweave/internal/plugins/slash-command/command-spec";
|
|
22
|
+
import { getSlashCommandKeyboardAction as At, isSlashCommandMenuState as jt } from "markweave/internal/plugins/slash-command/slash-keyboard";
|
|
23
|
+
import { executeSlashCommand as Mt, getNextSlashCommandState as Nt, getSlashCommandAnchoredMenuPosition as Pt, getSlashCommandContext as Ft } from "markweave/internal/plugins/slash-command/slash-runtime";
|
|
24
|
+
import { initialSlashCommandState as It, reduceSlashCommandState as Lt } from "markweave/internal/plugins/slash-command/slash-state";
|
|
25
|
+
import { getFirstTableDebugSnapshot as Rt } from "markweave/internal/plugins/table/table-debug-snapshot";
|
|
26
|
+
import { focusFirstTableBodyCell as zt } from "markweave/internal/plugins/table/table-focus-position";
|
|
27
|
+
import { getTableFocusState as Bt } from "markweave/internal/plugins/table/table-focus-state";
|
|
28
|
+
import { getTableSelectionOverlayState as Vt, initialTableInteractionState as Ht, tableInteractionPluginKey as Ut } from "markweave/internal/plugins/table/table-interaction-layer";
|
|
29
|
+
import { calculateCodeBlockLanguageMenuPosition as Wt, clampFullscreenScale as Gt, codeBlockCopyFeedbackTimeoutMs as Kt, copyCodeBlockText as qt, createCodeBlockOverlayPosition as Jt, createMermaidFullscreenViewerState as Yt, createMermaidTabPosition as Xt, focusCodeBlockTarget as Zt, formatCodeBlockLanguageLabel as Qt, formatFullscreenZoom as $t, getActiveCodeBlockElement as en, getAnchoredRect as tn, getCodeBlockLanguageItems as nn, getCodeBlockPositionFromEventTarget as rn, getCodeBlockStateAtPosition as an, getFrameElement as on, getMermaidCodeBlockTargets as sn, getMermaidSvgMarkup as cn, isCodeBlockTargetCollapsed as ln, mergeStableMermaidTabPositions as un, mermaidFullscreenZoomStep as dn, moveMermaidFullscreenViewer as fn } from "markweave/internal/plugins/codeblock/codeblock-ui-model";
|
|
30
|
+
import { BubbleMenu as pn } from "@tiptap/react/menus";
|
|
31
|
+
import { createMarkweaveFrameScheduler as mn } from "markweave/internal/editor-core/frame-scheduler";
|
|
32
|
+
import { applyFloatingToolbarLink as hn, createFloatingToolbarAssistantRequest as gn, getFloatingToolbarButtonModels as _n, getFloatingToolbarHighlightColorOptions as vn, getFloatingToolbarLinkHref as yn, getFloatingToolbarMessageSet as bn, getFloatingToolbarMoreActions as xn, getFloatingToolbarTextColorOptions as Sn, getFloatingToolbarTooltipModel as Cn, getFloatingToolbarTurnIntoOptions as wn, isFloatingToolbarMoreActionActive as Tn, isFloatingToolbarTurnIntoActive as En, openFloatingToolbarLinkHref as Dn, preventFloatingToolbarPointerFocusLoss as On, removeFloatingToolbarLink as kn, runFloatingToolbarMoreAction as An, setFloatingToolbarHighlightColor as jn, setFloatingToolbarTextColor as Mn, setFloatingToolbarTurnInto as Nn } from "markweave/internal/editor-core/floating-toolbar-model";
|
|
33
|
+
import { normalizeMarkdownLinkHref as Pn } from "markweave/internal/plugins/markdown/markdown-input";
|
|
34
|
+
import { setMarkweaveTableMenuAxisTarget as Fn } from "markweave/internal/plugins/table/table-clipboard";
|
|
35
|
+
import { calculateAnchoredTableMenuPosition as In, calculateTableEdgeHandlePosition as Ln, canRunTableCommand as Rn, executeTableMenuCommand as zn, formatTableCopyFeedback as Bn, getActiveTableElement as Vn, getAvailableCellMenuCommandSpecs as Hn, getTableAxisTargetRect as Un, getTableControlAxisSelectionModel as Wn, getTableEditWithAiRequest as Gn, getTableMenuItemGroup as Kn, getTableMenuItemLabel as qn, getTableMenuItems as Jn, getTableSelectionTargetRect as Yn, measureTableSelectionOverlay as Xn, selectTableAxisFromCell as Zn, tableCopyFeedbackTimeoutMs as Qn, tableMenuLabel as $n } from "markweave/internal/plugins/table/table-ui-model";
|
|
36
|
+
import { createMarkweaveTocState as er, emptyMarkweaveTocState as tr, getActiveMarkweaveTocId as nr, getMarkweaveTocItems as rr, getValidMarkweaveTocActiveId as ir, normalizeMarkweaveInnerTocPlacement as ar, observeMarkweaveInnerTocContainerPosition as or, scrollToMarkweaveTocItem as sr } from "markweave/internal/core/toc-state";
|
|
36
37
|
//#region src/editor-mode-state.ts
|
|
37
|
-
var
|
|
38
|
+
var cr = {
|
|
38
39
|
mode: "live",
|
|
39
40
|
editable: !0
|
|
40
41
|
};
|
|
41
|
-
function
|
|
42
|
-
return he((t) => Ie(e, t), () => Me(e), () =>
|
|
42
|
+
function lr(e) {
|
|
43
|
+
return he((t) => Ie(e, t), () => Me(e), () => cr);
|
|
43
44
|
}
|
|
44
45
|
//#endregion
|
|
45
46
|
//#region src/media/image-node.tsx
|
|
46
|
-
var
|
|
47
|
-
function
|
|
47
|
+
var ur = De;
|
|
48
|
+
function dr(e) {
|
|
48
49
|
return e instanceof Element && !!e.closest("[data-markweave-image-ui=\"true\"]");
|
|
49
50
|
}
|
|
50
|
-
function
|
|
51
|
-
let { deleteNode: t, editor: r, getPos: i, node: a, selected: o, updateAttributes: s } = e, c = e.extension.options, l = c.messages ?? Ae("zh"), u = l.image, d = Ne(
|
|
51
|
+
function fr(e) {
|
|
52
|
+
let { deleteNode: t, editor: r, getPos: i, node: a, selected: o, updateAttributes: s } = e, c = e.extension.options, l = c.messages ?? Ae("zh"), u = l.image, d = Ne(lr(r)), f = Y(a.attrs.src), p = ur(a.attrs.align), m = J(a.attrs.width), h = Y(a.attrs.caption), g = W(null), _ = W(null), [v, y] = G(!1), [b, x] = G(!1), [ee, C] = G(!1), [w, T] = G(""), [E, D] = G(null), [O, k] = G(!1), [A, j] = G(!!h), [M, N] = G(h ?? ""), P = d && (!f || b), F = () => {
|
|
52
53
|
f && Le({
|
|
53
54
|
src: f,
|
|
54
55
|
alt: Y(a.attrs.alt) ?? "",
|
|
@@ -62,62 +63,62 @@ function sr(e) {
|
|
|
62
63
|
});
|
|
63
64
|
};
|
|
64
65
|
H(() => {
|
|
65
|
-
|
|
66
|
-
}, [h,
|
|
67
|
-
let
|
|
66
|
+
A || N(h ?? "");
|
|
67
|
+
}, [h, A]);
|
|
68
|
+
let te = () => {
|
|
68
69
|
if (!d) return;
|
|
69
70
|
let e = i();
|
|
70
71
|
typeof e == "number" && r.chain().focus().setNodeSelection(e).run();
|
|
71
|
-
},
|
|
72
|
+
}, I = () => {
|
|
72
73
|
if (d) {
|
|
73
|
-
if (
|
|
74
|
+
if (T(""), D(null), C(!1), f) {
|
|
74
75
|
x(!1);
|
|
75
76
|
return;
|
|
76
77
|
}
|
|
77
78
|
t();
|
|
78
79
|
}
|
|
79
|
-
},
|
|
80
|
+
}, L = async (e) => {
|
|
80
81
|
if (d) {
|
|
81
|
-
|
|
82
|
+
D(null), k(!0);
|
|
82
83
|
try {
|
|
83
|
-
let t = await
|
|
84
|
-
s(
|
|
84
|
+
let t = await ve(Ce(e, f && b ? "image-replace" : "image-insert"), c.onUpload);
|
|
85
|
+
s(be(a.attrs, t)), x(!1), T("");
|
|
85
86
|
} catch (e) {
|
|
86
|
-
|
|
87
|
+
D(e instanceof Error ? e.message : u.uploadFailedError);
|
|
87
88
|
} finally {
|
|
88
|
-
|
|
89
|
+
k(!1), C(!1);
|
|
89
90
|
}
|
|
90
91
|
}
|
|
91
|
-
},
|
|
92
|
+
}, ne = () => {
|
|
92
93
|
if (d) {
|
|
93
|
-
if (!
|
|
94
|
-
|
|
94
|
+
if (!w.trim()) {
|
|
95
|
+
D(u.uploadRequiredError);
|
|
95
96
|
return;
|
|
96
97
|
}
|
|
97
|
-
|
|
98
|
+
L(ge(w));
|
|
98
99
|
}
|
|
99
|
-
},
|
|
100
|
-
!d || !e ||
|
|
100
|
+
}, R = (e) => {
|
|
101
|
+
!d || !e || L({
|
|
101
102
|
type: "file",
|
|
102
103
|
file: e,
|
|
103
104
|
mimeType: e.type
|
|
104
105
|
});
|
|
105
|
-
},
|
|
106
|
-
|
|
106
|
+
}, z = (e) => {
|
|
107
|
+
R(e.currentTarget.files?.[0] ?? null), e.currentTarget.value = "";
|
|
107
108
|
}, re = (e) => {
|
|
108
|
-
e.preventDefault(), e.stopPropagation(), d &&
|
|
109
|
+
e.preventDefault(), e.stopPropagation(), d && R(e.dataTransfer.files?.[0] ?? null);
|
|
109
110
|
}, ie = () => {
|
|
110
|
-
d && (
|
|
111
|
+
d && (j((e) => !e), A || N(h ?? ""));
|
|
111
112
|
}, ae = (e) => {
|
|
112
|
-
d && (
|
|
113
|
+
d && (N(e), s({ caption: e.trim() ? e : null }));
|
|
113
114
|
}, oe = (e, t) => {
|
|
114
115
|
if (t.preventDefault(), t.stopPropagation(), !d) return;
|
|
115
|
-
|
|
116
|
+
te();
|
|
116
117
|
let n = g.current;
|
|
117
118
|
if (!n) return;
|
|
118
119
|
let r = t.clientX, i = n.getBoundingClientRect().width || m || 320, a = n.closest(".markweave-editor-surface")?.getBoundingClientRect().width ?? n.parentElement?.getBoundingClientRect().width ?? i, o = (t) => {
|
|
119
120
|
let n = e === "right" ? t.clientX - r : r - t.clientX;
|
|
120
|
-
s({ width:
|
|
121
|
+
s({ width: q(i + n, a) });
|
|
121
122
|
}, c = () => {
|
|
122
123
|
window.removeEventListener("pointermove", o), window.removeEventListener("pointerup", c);
|
|
123
124
|
};
|
|
@@ -130,39 +131,39 @@ function sr(e) {
|
|
|
130
131
|
"data-align": p,
|
|
131
132
|
"data-selected": d && o ? "true" : "false",
|
|
132
133
|
"data-hovered": v ? "true" : "false",
|
|
133
|
-
"data-empty":
|
|
134
|
+
"data-empty": P ? "true" : "false",
|
|
134
135
|
onPointerEnter: () => y(!0),
|
|
135
136
|
onPointerLeave: () => y(!1),
|
|
136
137
|
onMouseDown: (e) => {
|
|
137
|
-
d && !
|
|
138
|
+
d && !dr(e.target) && te();
|
|
138
139
|
},
|
|
139
|
-
children:
|
|
140
|
-
dragActive:
|
|
141
|
-
error:
|
|
142
|
-
inputValue:
|
|
143
|
-
isSubmitting:
|
|
140
|
+
children: P ? /* @__PURE__ */ Z(pr, {
|
|
141
|
+
dragActive: ee,
|
|
142
|
+
error: E,
|
|
143
|
+
inputValue: w,
|
|
144
|
+
isSubmitting: O,
|
|
144
145
|
fileInputRef: _,
|
|
145
146
|
messages: l,
|
|
146
|
-
onCancel:
|
|
147
|
+
onCancel: I,
|
|
147
148
|
onDrop: re,
|
|
148
|
-
onDragActiveChange:
|
|
149
|
-
onFileChange:
|
|
150
|
-
onInputChange:
|
|
151
|
-
onSubmit:
|
|
149
|
+
onDragActiveChange: C,
|
|
150
|
+
onFileChange: z,
|
|
151
|
+
onInputChange: T,
|
|
152
|
+
onSubmit: ne
|
|
152
153
|
}) : /* @__PURE__ */ Q(X, { children: [
|
|
153
|
-
d ? /* @__PURE__ */ Z(
|
|
154
|
+
d ? /* @__PURE__ */ Z(mr, {
|
|
154
155
|
align: p,
|
|
155
|
-
captionActive:
|
|
156
|
+
captionActive: A || !!h,
|
|
156
157
|
messages: l,
|
|
157
158
|
onAlign: (e) => s({ align: e }),
|
|
158
159
|
onCaption: ie,
|
|
159
160
|
onDelete: t,
|
|
160
161
|
onDownload: () => {
|
|
161
|
-
f &&
|
|
162
|
+
f && Te(f);
|
|
162
163
|
},
|
|
163
|
-
onPreview:
|
|
164
|
+
onPreview: F,
|
|
164
165
|
onReplace: () => {
|
|
165
|
-
|
|
166
|
+
T(""), D(null), x(!0);
|
|
166
167
|
}
|
|
167
168
|
}) : null,
|
|
168
169
|
/* @__PURE__ */ Q("div", {
|
|
@@ -189,7 +190,7 @@ function sr(e) {
|
|
|
189
190
|
"aria-label": u.preview,
|
|
190
191
|
title: u.preview,
|
|
191
192
|
onMouseDown: (e) => e.preventDefault(),
|
|
192
|
-
onClick:
|
|
193
|
+
onClick: F,
|
|
193
194
|
children: [/* @__PURE__ */ Z(S, {
|
|
194
195
|
size: 16,
|
|
195
196
|
strokeWidth: 1.8
|
|
@@ -199,28 +200,28 @@ function sr(e) {
|
|
|
199
200
|
children: u.preview
|
|
200
201
|
})]
|
|
201
202
|
}) : null,
|
|
202
|
-
d ? /* @__PURE__ */ Z(
|
|
203
|
+
d ? /* @__PURE__ */ Z(gr, {
|
|
203
204
|
side: "left",
|
|
204
205
|
messages: l,
|
|
205
206
|
onPointerDown: oe
|
|
206
207
|
}) : null,
|
|
207
|
-
d ? /* @__PURE__ */ Z(
|
|
208
|
+
d ? /* @__PURE__ */ Z(gr, {
|
|
208
209
|
side: "right",
|
|
209
210
|
messages: l,
|
|
210
211
|
onPointerDown: oe
|
|
211
212
|
}) : null
|
|
212
213
|
]
|
|
213
214
|
}),
|
|
214
|
-
d && (
|
|
215
|
+
d && (A || h) ? /* @__PURE__ */ Z("input", {
|
|
215
216
|
className: "markweave-image-caption-input",
|
|
216
217
|
"data-markweave-image-ui": "true",
|
|
217
218
|
"data-testid": "markweave-image-caption-input",
|
|
218
|
-
value:
|
|
219
|
+
value: M,
|
|
219
220
|
placeholder: u.captionPlaceholder,
|
|
220
221
|
"aria-label": u.captionAriaLabel,
|
|
221
222
|
onChange: (e) => ae(e.currentTarget.value),
|
|
222
223
|
onKeyDown: (e) => {
|
|
223
|
-
e.key === "Escape" && (e.preventDefault(),
|
|
224
|
+
e.key === "Escape" && (e.preventDefault(), j(!1));
|
|
224
225
|
}
|
|
225
226
|
}) : h ? /* @__PURE__ */ Z("figcaption", {
|
|
226
227
|
className: "markweave-image-caption",
|
|
@@ -230,7 +231,7 @@ function sr(e) {
|
|
|
230
231
|
] })
|
|
231
232
|
});
|
|
232
233
|
}
|
|
233
|
-
function
|
|
234
|
+
function pr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitting: i, messages: a, onCancel: o, onDragActiveChange: s, onDrop: c, onFileChange: l, onInputChange: u, onSubmit: d }) {
|
|
234
235
|
let f = a.image;
|
|
235
236
|
return /* @__PURE__ */ Q("section", {
|
|
236
237
|
className: "markweave-image-upload-placeholder",
|
|
@@ -257,7 +258,7 @@ function cr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
|
|
|
257
258
|
/* @__PURE__ */ Z("div", {
|
|
258
259
|
className: "markweave-image-upload-icon",
|
|
259
260
|
"aria-hidden": "true",
|
|
260
|
-
children: /* @__PURE__ */ Z(
|
|
261
|
+
children: /* @__PURE__ */ Z(E, {
|
|
261
262
|
size: 46,
|
|
262
263
|
strokeWidth: 1.6
|
|
263
264
|
})
|
|
@@ -292,7 +293,7 @@ function cr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
|
|
|
292
293
|
"data-testid": "markweave-image-upload-submit",
|
|
293
294
|
disabled: i || !r.trim(),
|
|
294
295
|
onClick: d,
|
|
295
|
-
children: [/* @__PURE__ */ Z(
|
|
296
|
+
children: [/* @__PURE__ */ Z(E, {
|
|
296
297
|
size: 16,
|
|
297
298
|
strokeWidth: 1.8
|
|
298
299
|
}), a.common.insert]
|
|
@@ -312,7 +313,7 @@ function cr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
|
|
|
312
313
|
]
|
|
313
314
|
});
|
|
314
315
|
}
|
|
315
|
-
function
|
|
316
|
+
function mr({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i, onDelete: a, onDownload: s, onPreview: u, onReplace: d }) {
|
|
316
317
|
let p = n.image;
|
|
317
318
|
return /* @__PURE__ */ Q("div", {
|
|
318
319
|
className: "markweave-image-toolbar",
|
|
@@ -320,21 +321,21 @@ function lr({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i,
|
|
|
320
321
|
"data-markweave-image-ui": "true",
|
|
321
322
|
"aria-label": p.toolsAriaLabel,
|
|
322
323
|
children: [
|
|
323
|
-
/* @__PURE__ */ Z(
|
|
324
|
+
/* @__PURE__ */ Z(hr, {
|
|
324
325
|
testId: "markweave-image-align-left",
|
|
325
326
|
label: p.alignLeft,
|
|
326
327
|
icon: c,
|
|
327
328
|
active: e === "left",
|
|
328
329
|
onClick: () => r("left")
|
|
329
330
|
}),
|
|
330
|
-
/* @__PURE__ */ Z(
|
|
331
|
+
/* @__PURE__ */ Z(hr, {
|
|
331
332
|
testId: "markweave-image-align-center",
|
|
332
333
|
label: p.alignCenter,
|
|
333
334
|
icon: o,
|
|
334
335
|
active: e === "center",
|
|
335
336
|
onClick: () => r("center")
|
|
336
337
|
}),
|
|
337
|
-
/* @__PURE__ */ Z(
|
|
338
|
+
/* @__PURE__ */ Z(hr, {
|
|
338
339
|
testId: "markweave-image-align-right",
|
|
339
340
|
label: p.alignRight,
|
|
340
341
|
icon: l,
|
|
@@ -345,36 +346,36 @@ function lr({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i,
|
|
|
345
346
|
className: "markweave-image-toolbar-divider",
|
|
346
347
|
"aria-hidden": "true"
|
|
347
348
|
}),
|
|
348
|
-
/* @__PURE__ */ Z(
|
|
349
|
+
/* @__PURE__ */ Z(hr, {
|
|
349
350
|
testId: "markweave-image-caption",
|
|
350
351
|
label: p.caption,
|
|
351
352
|
icon: f,
|
|
352
353
|
active: t,
|
|
353
354
|
onClick: i
|
|
354
355
|
}),
|
|
355
|
-
/* @__PURE__ */ Z(
|
|
356
|
+
/* @__PURE__ */ Z(hr, {
|
|
356
357
|
testId: "markweave-image-preview",
|
|
357
358
|
label: p.preview,
|
|
358
359
|
icon: S,
|
|
359
360
|
onClick: u
|
|
360
361
|
}),
|
|
361
|
-
/* @__PURE__ */ Z(
|
|
362
|
+
/* @__PURE__ */ Z(hr, {
|
|
362
363
|
testId: "markweave-image-download",
|
|
363
364
|
label: p.download,
|
|
364
365
|
icon: b,
|
|
365
366
|
onClick: s
|
|
366
367
|
}),
|
|
367
|
-
/* @__PURE__ */ Z(
|
|
368
|
+
/* @__PURE__ */ Z(hr, {
|
|
368
369
|
testId: "markweave-image-replace",
|
|
369
370
|
label: p.replace,
|
|
370
|
-
icon:
|
|
371
|
+
icon: R,
|
|
371
372
|
onClick: d
|
|
372
373
|
}),
|
|
373
374
|
/* @__PURE__ */ Z("span", {
|
|
374
375
|
className: "markweave-image-toolbar-divider",
|
|
375
376
|
"aria-hidden": "true"
|
|
376
377
|
}),
|
|
377
|
-
/* @__PURE__ */ Z(
|
|
378
|
+
/* @__PURE__ */ Z(hr, {
|
|
378
379
|
testId: "markweave-image-delete",
|
|
379
380
|
label: p.delete,
|
|
380
381
|
icon: ue,
|
|
@@ -383,7 +384,7 @@ function lr({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i,
|
|
|
383
384
|
]
|
|
384
385
|
});
|
|
385
386
|
}
|
|
386
|
-
function
|
|
387
|
+
function hr({ active: e = !1, icon: t, label: n, onClick: r, testId: i }) {
|
|
387
388
|
return /* @__PURE__ */ Q("button", {
|
|
388
389
|
type: "button",
|
|
389
390
|
"aria-label": n,
|
|
@@ -402,7 +403,7 @@ function ur({ active: e = !1, icon: t, label: n, onClick: r, testId: i }) {
|
|
|
402
403
|
})]
|
|
403
404
|
});
|
|
404
405
|
}
|
|
405
|
-
function
|
|
406
|
+
function gr({ messages: e, onPointerDown: t, side: n }) {
|
|
406
407
|
return /* @__PURE__ */ Z("button", {
|
|
407
408
|
type: "button",
|
|
408
409
|
className: "markweave-image-resize-handle",
|
|
@@ -413,7 +414,7 @@ function dr({ messages: e, onPointerDown: t, side: n }) {
|
|
|
413
414
|
onPointerDown: (e) => t(n, e)
|
|
414
415
|
});
|
|
415
416
|
}
|
|
416
|
-
var
|
|
417
|
+
var _r = K.extend({
|
|
417
418
|
addOptions() {
|
|
418
419
|
return {
|
|
419
420
|
...this.parent?.(),
|
|
@@ -422,70 +423,70 @@ var fr = q.extend({
|
|
|
422
423
|
};
|
|
423
424
|
},
|
|
424
425
|
addNodeView() {
|
|
425
|
-
return typeof document > "u" ? null : r(
|
|
426
|
+
return typeof document > "u" ? null : r(fr, { stopEvent: ({ event: e }) => dr(e.target) });
|
|
426
427
|
}
|
|
427
428
|
});
|
|
428
429
|
//#endregion
|
|
429
430
|
//#region src/media/video-node.tsx
|
|
430
|
-
function
|
|
431
|
+
function vr(e) {
|
|
431
432
|
return e instanceof Element && !!e.closest("[data-markweave-video-ui=\"true\"], iframe[data-markweave-video-embed], video[data-markweave-video]");
|
|
432
433
|
}
|
|
433
|
-
function
|
|
434
|
-
let { deleteNode: t, editor: r, getPos: i, node: a, selected: o, updateAttributes: s } = e, c = e.extension.options, l = c.messages ?? Ae("zh"), u = l.video, d = Ne(
|
|
434
|
+
function yr(e) {
|
|
435
|
+
let { deleteNode: t, editor: r, getPos: i, node: a, selected: o, updateAttributes: s } = e, c = e.extension.options, l = c.messages ?? Ae("zh"), u = l.video, d = Ne(lr(r)), f = Y(a.attrs.src), p = Y(a.attrs.embedUrl), m = Y(a.attrs.provider), h = p ? Oe(p, m) : null, g = Y(a.attrs.mimeType), _ = Y(a.attrs.title), v = W(null), [y, b] = G(!1), [x, S] = G(""), [ee, C] = G(null), [w, T] = G(!1), E = d && !f, D = () => {
|
|
435
436
|
if (!d) return;
|
|
436
437
|
let e = i();
|
|
437
438
|
typeof e == "number" && r.chain().focus().setNodeSelection(e).run();
|
|
439
|
+
}, O = (e) => {
|
|
440
|
+
d && (vr(e.target) || (e.preventDefault(), D()));
|
|
438
441
|
}, k = (e) => {
|
|
439
|
-
d && (pr(e.target) || (e.preventDefault(), O()));
|
|
440
|
-
}, A = (e) => {
|
|
441
442
|
d && (e.key === "Delete" || e.key === "Backspace") && o && (e.preventDefault(), t());
|
|
442
|
-
},
|
|
443
|
+
}, A = async (e) => {
|
|
443
444
|
if (!(!d || !e)) {
|
|
444
|
-
|
|
445
|
+
C(null), T(!0);
|
|
445
446
|
try {
|
|
446
|
-
let t = await
|
|
447
|
+
let t = await ve(we({
|
|
447
448
|
type: "file",
|
|
448
449
|
file: e,
|
|
449
450
|
mimeType: e.type
|
|
450
451
|
}), c.onUpload);
|
|
451
|
-
s(
|
|
452
|
+
s(xe(t)), S("");
|
|
452
453
|
} catch (e) {
|
|
453
|
-
|
|
454
|
+
C(e instanceof Error ? e.message : u.uploadFailedError);
|
|
454
455
|
} finally {
|
|
455
|
-
|
|
456
|
+
T(!1), b(!1);
|
|
456
457
|
}
|
|
457
458
|
}
|
|
458
459
|
};
|
|
459
|
-
return
|
|
460
|
+
return E ? /* @__PURE__ */ Z(n, {
|
|
460
461
|
as: "figure",
|
|
461
462
|
className: "markweave-video-node",
|
|
462
463
|
"data-testid": "markweave-video-node",
|
|
463
464
|
"data-empty": "true",
|
|
464
465
|
"data-selected": "false",
|
|
465
|
-
children: /* @__PURE__ */ Z(
|
|
466
|
+
children: /* @__PURE__ */ Z(br, {
|
|
466
467
|
dragActive: y,
|
|
467
|
-
error:
|
|
468
|
+
error: ee,
|
|
468
469
|
fileInputRef: v,
|
|
469
470
|
inputValue: x,
|
|
470
|
-
isSubmitting:
|
|
471
|
+
isSubmitting: w,
|
|
471
472
|
messages: l,
|
|
472
473
|
onCancel: t,
|
|
473
474
|
onDragActiveChange: b,
|
|
474
475
|
onDrop: (e) => {
|
|
475
|
-
e.preventDefault(), e.stopPropagation(), d &&
|
|
476
|
+
e.preventDefault(), e.stopPropagation(), d && A(e.dataTransfer.files?.[0] ?? null);
|
|
476
477
|
},
|
|
477
478
|
onFileChange: (e) => {
|
|
478
|
-
|
|
479
|
+
A(e.currentTarget.files?.[0] ?? null), e.currentTarget.value = "";
|
|
479
480
|
},
|
|
480
481
|
onInputChange: S,
|
|
481
482
|
onSubmit: () => {
|
|
482
483
|
if (!d) return;
|
|
483
|
-
let e =
|
|
484
|
+
let e = Se(x);
|
|
484
485
|
if (!e) {
|
|
485
|
-
|
|
486
|
+
C(u.unsupportedUrlError);
|
|
486
487
|
return;
|
|
487
488
|
}
|
|
488
|
-
|
|
489
|
+
C(null), s(e), S("");
|
|
489
490
|
}
|
|
490
491
|
})
|
|
491
492
|
}) : /* @__PURE__ */ Z(n, {
|
|
@@ -497,9 +498,9 @@ function mr(e) {
|
|
|
497
498
|
"data-selected": d && o ? "true" : "false",
|
|
498
499
|
tabIndex: d ? 0 : void 0,
|
|
499
500
|
"aria-label": u.nodeAriaLabel,
|
|
500
|
-
onFocus:
|
|
501
|
-
onKeyDown:
|
|
502
|
-
onMouseDown:
|
|
501
|
+
onFocus: D,
|
|
502
|
+
onKeyDown: k,
|
|
503
|
+
onMouseDown: O,
|
|
503
504
|
children: h ? /* @__PURE__ */ Q("div", {
|
|
504
505
|
className: "markweave-video-embed",
|
|
505
506
|
children: [/* @__PURE__ */ Z("iframe", {
|
|
@@ -509,7 +510,8 @@ function mr(e) {
|
|
|
509
510
|
"data-markweave-video-embed": "true",
|
|
510
511
|
"data-markweave-video-provider": m ?? void 0,
|
|
511
512
|
"data-markweave-video-src": f ?? void 0,
|
|
512
|
-
allow:
|
|
513
|
+
allow: Ee,
|
|
514
|
+
loading: "lazy",
|
|
513
515
|
allowFullScreen: !0
|
|
514
516
|
}), d ? /* @__PURE__ */ Z("button", {
|
|
515
517
|
type: "button",
|
|
@@ -526,6 +528,7 @@ function mr(e) {
|
|
|
526
528
|
title: _ ?? void 0,
|
|
527
529
|
"data-markweave-video": "true",
|
|
528
530
|
"data-markweave-mime-type": g ?? void 0,
|
|
531
|
+
preload: "metadata",
|
|
529
532
|
controls: !0
|
|
530
533
|
}), d ? /* @__PURE__ */ Z("button", {
|
|
531
534
|
type: "button",
|
|
@@ -541,7 +544,7 @@ function mr(e) {
|
|
|
541
544
|
})
|
|
542
545
|
});
|
|
543
546
|
}
|
|
544
|
-
function
|
|
547
|
+
function br({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitting: i, messages: a, onCancel: o, onDragActiveChange: s, onDrop: c, onFileChange: l, onInputChange: u, onSubmit: d }) {
|
|
545
548
|
let f = a.video;
|
|
546
549
|
return /* @__PURE__ */ Q("section", {
|
|
547
550
|
className: "markweave-video-upload-placeholder",
|
|
@@ -623,7 +626,7 @@ function hr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
|
|
|
623
626
|
]
|
|
624
627
|
});
|
|
625
628
|
}
|
|
626
|
-
var
|
|
629
|
+
var xr = ye.extend({
|
|
627
630
|
addOptions() {
|
|
628
631
|
return {
|
|
629
632
|
...this.parent?.(),
|
|
@@ -632,17 +635,17 @@ var gr = ve.extend({
|
|
|
632
635
|
};
|
|
633
636
|
},
|
|
634
637
|
addNodeView() {
|
|
635
|
-
return typeof document > "u" ? null : r(
|
|
638
|
+
return typeof document > "u" ? null : r(yr, { stopEvent: ({ event: e }) => vr(e.target) });
|
|
636
639
|
}
|
|
637
640
|
});
|
|
638
641
|
//#endregion
|
|
639
642
|
//#region src/create-editor-extensions.ts
|
|
640
|
-
function
|
|
643
|
+
function Sr(t = {}) {
|
|
641
644
|
return e({
|
|
642
645
|
lang: t.lang,
|
|
643
646
|
mediaExtensions: Re({
|
|
644
|
-
image:
|
|
645
|
-
video:
|
|
647
|
+
image: _r,
|
|
648
|
+
video: xr,
|
|
646
649
|
lang: t.lang,
|
|
647
650
|
onImageUpload: t.onImageUpload,
|
|
648
651
|
onVideoUpload: t.onVideoUpload
|
|
@@ -651,7 +654,7 @@ function _r(t = {}) {
|
|
|
651
654
|
}
|
|
652
655
|
//#endregion
|
|
653
656
|
//#region src/ui/codeblock/CodeBlockControls.tsx
|
|
654
|
-
function
|
|
657
|
+
function Cr(e) {
|
|
655
658
|
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", {
|
|
656
659
|
cx: "10",
|
|
657
660
|
cy: "10",
|
|
@@ -688,7 +691,7 @@ function vr(e) {
|
|
|
688
691
|
/* @__PURE__ */ Z("path", { d: "m14 14 4 4" })
|
|
689
692
|
] }) : 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" });
|
|
690
693
|
}
|
|
691
|
-
function
|
|
694
|
+
function wr({ icon: e }) {
|
|
692
695
|
return /* @__PURE__ */ Z("svg", {
|
|
693
696
|
viewBox: "0 0 24 24",
|
|
694
697
|
"aria-hidden": "true",
|
|
@@ -699,40 +702,40 @@ function yr({ icon: e }) {
|
|
|
699
702
|
strokeLinecap: "round",
|
|
700
703
|
strokeLinejoin: "round",
|
|
701
704
|
strokeWidth: "1.8",
|
|
702
|
-
children:
|
|
705
|
+
children: Cr(e)
|
|
703
706
|
})
|
|
704
707
|
});
|
|
705
708
|
}
|
|
706
|
-
function
|
|
709
|
+
function Tr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, readOnly: i = !1 }) {
|
|
707
710
|
let a = W(null), o = W(null), s = W(null), c = W({
|
|
708
711
|
active: !1,
|
|
709
712
|
lastX: 0,
|
|
710
713
|
lastY: 0
|
|
711
|
-
}), [l, u] = G(null), [d, f] = G(null), [p, m] = G([]), [h, g] = G(null), [_, v] = G(!1), [y, b] = G(""), [x, S] = G(null), [
|
|
712
|
-
...
|
|
713
|
-
pos:
|
|
714
|
+
}), [l, u] = G(null), [d, f] = G(null), [p, m] = G([]), [h, g] = G(null), [_, v] = G(!1), [y, b] = G(""), [x, S] = G(null), [ee, C] = G(!1), [w, T] = G(null), [E, D] = G(null), [O, k] = G(!1), [A, j] = G(0), [M, N] = G(0), P = ot(t), F = an(t, l), te = !i && e && P.active && P.pos !== null ? {
|
|
715
|
+
...P,
|
|
716
|
+
pos: P.pos,
|
|
714
717
|
active: !0
|
|
715
|
-
} : null,
|
|
718
|
+
} : null, I = F ?? te, L = I !== null, ne = I?.language === "mermaid", R = ln(t, I), z = L && I !== null && !R, re = !i, ie = Qt(I ? I.language : "text"), ae = x?.status ?? "idle", oe = I?.mermaidPreviewMode ?? n, se = ne && oe === "preview", ce = sn(t), le = `${M}|${ce.map((e) => `${e.pos}:${e.mermaidPreviewMode}:${e.text.length}`).join("|")}`, ue = U(() => nn(y.trim().toLowerCase()), [y]);
|
|
716
719
|
if (H(() => {
|
|
717
720
|
i && (v(!1), b(""));
|
|
718
721
|
}, [i]), H(() => {
|
|
719
722
|
if (!x) return;
|
|
720
723
|
let e = window.setTimeout(() => {
|
|
721
724
|
S(null);
|
|
722
|
-
},
|
|
725
|
+
}, Kt);
|
|
723
726
|
return () => {
|
|
724
727
|
window.clearTimeout(e);
|
|
725
728
|
};
|
|
726
729
|
}, [x]), H(() => {
|
|
727
|
-
S(null), v(!1), b(""),
|
|
730
|
+
S(null), v(!1), b(""), T(null), D(null), k(!1);
|
|
728
731
|
}, [
|
|
729
732
|
e,
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
+
I?.language,
|
|
734
|
+
I?.pos,
|
|
735
|
+
I?.text
|
|
733
736
|
]), H(() => {
|
|
734
737
|
let e = ({ transaction: e }) => {
|
|
735
|
-
e.getMeta(
|
|
738
|
+
e.getMeta(it) && j((e) => e + 1);
|
|
736
739
|
};
|
|
737
740
|
return t.on("transaction", e), () => {
|
|
738
741
|
t.off("transaction", e);
|
|
@@ -742,7 +745,7 @@ function br({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
742
745
|
if (!e) return;
|
|
743
746
|
let n = (e) => {
|
|
744
747
|
if (e.target instanceof Node && a.current?.contains(e.target) || _) return;
|
|
745
|
-
let n =
|
|
748
|
+
let n = an(t, rn(t, e.target)), r = n && !ln(t, n) ? n.pos : null;
|
|
746
749
|
u((e) => e === r ? e : r);
|
|
747
750
|
}, r = () => {
|
|
748
751
|
_ || u(null);
|
|
@@ -753,9 +756,9 @@ function br({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
753
756
|
}, [t, _]), H(() => {
|
|
754
757
|
_ && s.current?.focus({ preventScroll: !0 });
|
|
755
758
|
}, [_]), H(() => {
|
|
756
|
-
if (!
|
|
759
|
+
if (!w) return;
|
|
757
760
|
let e = (e) => {
|
|
758
|
-
e.key === "Escape" && (
|
|
761
|
+
e.key === "Escape" && (T(null), D(null), k(!1), c.current = {
|
|
759
762
|
active: !1,
|
|
760
763
|
lastX: 0,
|
|
761
764
|
lastY: 0
|
|
@@ -764,8 +767,8 @@ function br({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
764
767
|
return document.addEventListener("keydown", e), () => {
|
|
765
768
|
document.removeEventListener("keydown", e);
|
|
766
769
|
};
|
|
767
|
-
}, [t,
|
|
768
|
-
if (!
|
|
770
|
+
}, [t, w]), H(() => {
|
|
771
|
+
if (!L || !_) return;
|
|
769
772
|
let e = (e) => {
|
|
770
773
|
e.key === "Escape" && (v(!1), t.view.focus());
|
|
771
774
|
}, n = (e) => {
|
|
@@ -775,22 +778,22 @@ function br({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
775
778
|
document.removeEventListener("keydown", e), document.removeEventListener("mousedown", n);
|
|
776
779
|
};
|
|
777
780
|
}, [
|
|
778
|
-
|
|
781
|
+
L,
|
|
779
782
|
t,
|
|
780
783
|
_
|
|
781
784
|
]), me(() => {
|
|
782
785
|
let e = () => {
|
|
783
786
|
let e = a.current;
|
|
784
787
|
if (!e) return;
|
|
785
|
-
if (!
|
|
788
|
+
if (!on(e) || ce.length === 0) {
|
|
786
789
|
m([]);
|
|
787
790
|
return;
|
|
788
791
|
}
|
|
789
792
|
let n = e.getBoundingClientRect(), r = ce.flatMap((e) => {
|
|
790
|
-
let r =
|
|
791
|
-
return r ? [
|
|
793
|
+
let r = tn(en(t, e.pos, e.mermaidPreviewMode), n);
|
|
794
|
+
return r ? [Xt(e, r, n)] : [];
|
|
792
795
|
});
|
|
793
|
-
m((e) =>
|
|
796
|
+
m((e) => un(e, r, ce.map((e) => e.pos)));
|
|
794
797
|
};
|
|
795
798
|
e();
|
|
796
799
|
let n = window.requestAnimationFrame(e);
|
|
@@ -798,26 +801,26 @@ function br({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
798
801
|
window.cancelAnimationFrame(n), window.removeEventListener("resize", e), window.removeEventListener("scroll", e, !0);
|
|
799
802
|
};
|
|
800
803
|
}, [
|
|
801
|
-
|
|
804
|
+
A,
|
|
802
805
|
t,
|
|
803
806
|
le
|
|
804
807
|
]), me(() => {
|
|
805
|
-
if (!
|
|
808
|
+
if (!z || !I) {
|
|
806
809
|
f(null), g(null);
|
|
807
810
|
return;
|
|
808
811
|
}
|
|
809
812
|
let e = () => {
|
|
810
813
|
let e = a.current;
|
|
811
814
|
if (!e) return;
|
|
812
|
-
let n =
|
|
815
|
+
let n = en(t, I.pos, oe), r = e.getBoundingClientRect(), i = tn(n, r);
|
|
813
816
|
if (!i) {
|
|
814
|
-
f((e) => e?.pos ===
|
|
817
|
+
f((e) => e?.pos === I.pos ? e : null), g((e) => _ ? e : null);
|
|
815
818
|
return;
|
|
816
819
|
}
|
|
817
|
-
let s =
|
|
820
|
+
let s = Jt(I.pos, i, r);
|
|
818
821
|
if (f(s), _ && o.current) {
|
|
819
822
|
let e = o.current.getBoundingClientRect();
|
|
820
|
-
g(
|
|
823
|
+
g(Wt({
|
|
821
824
|
overlayRect: r,
|
|
822
825
|
buttonRect: e,
|
|
823
826
|
windowWidth: window.innerWidth,
|
|
@@ -829,79 +832,79 @@ function br({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
829
832
|
window.removeEventListener("resize", e), window.removeEventListener("scroll", e, !0);
|
|
830
833
|
};
|
|
831
834
|
}, [
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
+
z,
|
|
836
|
+
A,
|
|
837
|
+
I?.pos,
|
|
835
838
|
t,
|
|
836
839
|
_,
|
|
837
840
|
oe
|
|
838
|
-
]), !
|
|
841
|
+
]), !z && ce.length === 0 && !w) return null;
|
|
839
842
|
let de = d ? {
|
|
840
843
|
top: d.top,
|
|
841
844
|
right: d.right
|
|
842
845
|
} : void 0, fe = async () => {
|
|
843
846
|
if (i) {
|
|
844
|
-
if (!
|
|
845
|
-
let e = await
|
|
846
|
-
S(
|
|
847
|
+
if (!I) return;
|
|
848
|
+
let e = await qt(I.text);
|
|
849
|
+
S(st(I, e ? "copied" : "failed"));
|
|
847
850
|
return;
|
|
848
851
|
}
|
|
849
|
-
if (!
|
|
850
|
-
let e = await
|
|
851
|
-
S(
|
|
852
|
+
if (!Zt(t, I)) return;
|
|
853
|
+
let e = await at(t);
|
|
854
|
+
S(st(ot(t), e ? "copied" : "failed")), t.view.focus();
|
|
852
855
|
}, pe = (e, n) => {
|
|
853
856
|
if (i) {
|
|
854
|
-
|
|
857
|
+
mt(t, e.pos, n) && N((e) => e + 1);
|
|
855
858
|
return;
|
|
856
859
|
}
|
|
857
|
-
let a =
|
|
858
|
-
|
|
860
|
+
let a = P.active && P.pos === e.pos;
|
|
861
|
+
dt(t, e.pos, n) && (r(n), N((e) => e + 1), a && t.view.focus());
|
|
859
862
|
}, B = (e) => {
|
|
860
|
-
if (i || !
|
|
861
|
-
let n =
|
|
862
|
-
|
|
863
|
+
if (i || !I) return;
|
|
864
|
+
let n = P.active && P.pos === I.pos;
|
|
865
|
+
ut(t, I.pos, e) && (e === "mermaid" && dt(t, I.pos, "preview") && r("preview"), v(!1), b(""), N((e) => e + 1), n && t.view.focus());
|
|
863
866
|
}, V = () => {
|
|
864
|
-
i || !
|
|
867
|
+
i || !I || lt(t, I.pos, !R) && (j((e) => e + 1), u(null));
|
|
865
868
|
}, he = () => {
|
|
866
|
-
if (!
|
|
867
|
-
let e =
|
|
869
|
+
if (!I) return;
|
|
870
|
+
let e = cn(t, I.pos);
|
|
868
871
|
if (!e) return;
|
|
869
872
|
let n = new Blob([e], { type: "image/svg+xml" }), r = URL.createObjectURL(n), i = document.createElement("a");
|
|
870
873
|
i.href = r, i.download = "markweave-mermaid.svg", i.click(), URL.revokeObjectURL(r), t.view.focus();
|
|
871
874
|
}, ge = () => {
|
|
872
|
-
if (!
|
|
873
|
-
let e =
|
|
874
|
-
e && (
|
|
875
|
+
if (!I) return;
|
|
876
|
+
let e = cn(t, I.pos);
|
|
877
|
+
e && (T(Yt(e)), D(null), k(!1), c.current = {
|
|
875
878
|
active: !1,
|
|
876
879
|
lastX: 0,
|
|
877
880
|
lastY: 0
|
|
878
881
|
});
|
|
879
882
|
}, _e = () => {
|
|
880
|
-
|
|
883
|
+
T(null), D(null), k(!1), c.current = {
|
|
881
884
|
active: !1,
|
|
882
885
|
lastX: 0,
|
|
883
886
|
lastY: 0
|
|
884
887
|
}, t.view.focus();
|
|
885
|
-
},
|
|
886
|
-
|
|
888
|
+
}, ve = (e) => {
|
|
889
|
+
T((t) => t && {
|
|
887
890
|
...t,
|
|
888
|
-
scale:
|
|
891
|
+
scale: Gt(t.scale + e)
|
|
889
892
|
});
|
|
890
|
-
},
|
|
891
|
-
|
|
893
|
+
}, K = () => {
|
|
894
|
+
T((e) => e && Yt(e.svg)), c.current = {
|
|
892
895
|
active: !1,
|
|
893
896
|
lastX: 0,
|
|
894
897
|
lastY: 0
|
|
895
|
-
},
|
|
896
|
-
}, ve = (e) => {
|
|
897
|
-
e.preventDefault(), K(e.deltaY < 0 ? sn : -sn);
|
|
898
|
+
}, k(!1);
|
|
898
899
|
}, ye = (e) => {
|
|
900
|
+
e.preventDefault(), ve(e.deltaY < 0 ? dn : -dn);
|
|
901
|
+
}, be = (e) => {
|
|
899
902
|
e.button === 0 && (e.preventDefault(), c.current = {
|
|
900
903
|
active: !0,
|
|
901
904
|
lastX: e.clientX,
|
|
902
905
|
lastY: e.clientY
|
|
903
|
-
},
|
|
904
|
-
},
|
|
906
|
+
}, k(!0));
|
|
907
|
+
}, xe = (e) => {
|
|
905
908
|
let t = c.current;
|
|
906
909
|
if (!t.active) return;
|
|
907
910
|
let n = e.clientX - t.lastX, r = e.clientY - t.lastY;
|
|
@@ -909,13 +912,13 @@ function br({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
909
912
|
active: !0,
|
|
910
913
|
lastX: e.clientX,
|
|
911
914
|
lastY: e.clientY
|
|
912
|
-
},
|
|
913
|
-
},
|
|
915
|
+
}, T((e) => fn(e, n, r));
|
|
916
|
+
}, Se = () => {
|
|
914
917
|
c.current = {
|
|
915
918
|
active: !1,
|
|
916
919
|
lastX: 0,
|
|
917
920
|
lastY: 0
|
|
918
|
-
},
|
|
921
|
+
}, k(!1);
|
|
919
922
|
};
|
|
920
923
|
return /* @__PURE__ */ Q("div", {
|
|
921
924
|
ref: a,
|
|
@@ -944,11 +947,11 @@ function br({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
944
947
|
}, t))
|
|
945
948
|
}, e.pos);
|
|
946
949
|
}),
|
|
947
|
-
|
|
950
|
+
z ? /* @__PURE__ */ Q("div", {
|
|
948
951
|
className: "markweave-codeblock-controls",
|
|
949
952
|
"data-testid": "markweave-codeblock-controls",
|
|
950
953
|
"data-positioned": d ? "true" : "false",
|
|
951
|
-
"data-collapsed":
|
|
954
|
+
"data-collapsed": R ? "true" : "false",
|
|
952
955
|
"data-read-only": i ? "true" : "false",
|
|
953
956
|
"aria-label": "Code block controls",
|
|
954
957
|
style: de,
|
|
@@ -968,18 +971,18 @@ function br({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
968
971
|
"data-testid": "markweave-codeblock-language",
|
|
969
972
|
onMouseDown: (e) => e.preventDefault(),
|
|
970
973
|
onClick: () => v((e) => !e),
|
|
971
|
-
children: [/* @__PURE__ */ Z("span", { children: ie }), /* @__PURE__ */ Z(
|
|
974
|
+
children: [/* @__PURE__ */ Z("span", { children: ie }), /* @__PURE__ */ Z(wr, { icon: "chevron" })]
|
|
972
975
|
}),
|
|
973
976
|
re ? /* @__PURE__ */ Z("button", {
|
|
974
977
|
type: "button",
|
|
975
978
|
className: "markweave-codeblock-icon-button markweave-codeblock-collapse-button",
|
|
976
|
-
"aria-label":
|
|
977
|
-
title:
|
|
979
|
+
"aria-label": R ? "Expand code block" : "Collapse code block",
|
|
980
|
+
title: R ? "Expand code block" : "Collapse code block",
|
|
978
981
|
"data-testid": "markweave-codeblock-collapse",
|
|
979
|
-
"data-collapsed":
|
|
982
|
+
"data-collapsed": R ? "true" : "false",
|
|
980
983
|
onMouseDown: (e) => e.preventDefault(),
|
|
981
984
|
onClick: V,
|
|
982
|
-
children: /* @__PURE__ */ Z(
|
|
985
|
+
children: /* @__PURE__ */ Z(wr, { icon: "chevron" })
|
|
983
986
|
}) : null,
|
|
984
987
|
/* @__PURE__ */ Q("span", {
|
|
985
988
|
className: "markweave-codeblock-copy-wrap",
|
|
@@ -990,20 +993,20 @@ function br({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
990
993
|
"data-testid": "markweave-codeblock-copy",
|
|
991
994
|
"data-copy-state": ae,
|
|
992
995
|
onMouseDown: (e) => e.preventDefault(),
|
|
993
|
-
onMouseEnter: () =>
|
|
994
|
-
onMouseLeave: () =>
|
|
995
|
-
onFocus: () =>
|
|
996
|
-
onBlur: () =>
|
|
996
|
+
onMouseEnter: () => C(!0),
|
|
997
|
+
onMouseLeave: () => C(!1),
|
|
998
|
+
onFocus: () => C(!0),
|
|
999
|
+
onBlur: () => C(!1),
|
|
997
1000
|
onClick: fe,
|
|
998
|
-
children: /* @__PURE__ */ Z(
|
|
999
|
-
}),
|
|
1001
|
+
children: /* @__PURE__ */ Z(wr, { icon: ae === "copied" ? "check" : "clipboard" })
|
|
1002
|
+
}), ee ? /* @__PURE__ */ Z("span", {
|
|
1000
1003
|
className: "markweave-codeblock-tooltip",
|
|
1001
1004
|
role: "tooltip",
|
|
1002
1005
|
"data-testid": "markweave-codeblock-copy-tooltip",
|
|
1003
1006
|
children: "Copy to clipboard"
|
|
1004
1007
|
}) : null]
|
|
1005
1008
|
}),
|
|
1006
|
-
|
|
1009
|
+
ne && oe === "preview" ? /* @__PURE__ */ Q("div", {
|
|
1007
1010
|
className: "markweave-mermaid-preview-actions",
|
|
1008
1011
|
"data-testid": "markweave-mermaid-preview-actions",
|
|
1009
1012
|
children: [/* @__PURE__ */ Z("button", {
|
|
@@ -1014,7 +1017,7 @@ function br({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1014
1017
|
disabled: !se,
|
|
1015
1018
|
onMouseDown: (e) => e.preventDefault(),
|
|
1016
1019
|
onClick: ge,
|
|
1017
|
-
children: /* @__PURE__ */ Z(
|
|
1020
|
+
children: /* @__PURE__ */ Z(wr, { icon: "expand" })
|
|
1018
1021
|
}), /* @__PURE__ */ Z("button", {
|
|
1019
1022
|
type: "button",
|
|
1020
1023
|
className: "markweave-codeblock-icon-button",
|
|
@@ -1023,12 +1026,12 @@ function br({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1023
1026
|
disabled: !se,
|
|
1024
1027
|
onMouseDown: (e) => e.preventDefault(),
|
|
1025
1028
|
onClick: he,
|
|
1026
|
-
children: /* @__PURE__ */ Z(
|
|
1029
|
+
children: /* @__PURE__ */ Z(wr, { icon: "download" })
|
|
1027
1030
|
})]
|
|
1028
1031
|
}) : null
|
|
1029
1032
|
]
|
|
1030
1033
|
}) : null,
|
|
1031
|
-
re &&
|
|
1034
|
+
re && z && _ ? /* @__PURE__ */ Q("div", {
|
|
1032
1035
|
className: "markweave-codeblock-language-menu",
|
|
1033
1036
|
role: "listbox",
|
|
1034
1037
|
"aria-label": "Code block languages",
|
|
@@ -1049,11 +1052,11 @@ function br({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1049
1052
|
onKeyDown: (e) => {
|
|
1050
1053
|
e.key === "Escape" && (e.preventDefault(), v(!1), t.view.focus());
|
|
1051
1054
|
}
|
|
1052
|
-
}), /* @__PURE__ */ Z(
|
|
1055
|
+
}), /* @__PURE__ */ Z(wr, { icon: "search" })]
|
|
1053
1056
|
}), /* @__PURE__ */ Z("div", {
|
|
1054
1057
|
className: "markweave-codeblock-language-list",
|
|
1055
1058
|
children: ue.map((e) => {
|
|
1056
|
-
let t = e.language ===
|
|
1059
|
+
let t = e.language === I.language;
|
|
1057
1060
|
return /* @__PURE__ */ Q("button", {
|
|
1058
1061
|
type: "button",
|
|
1059
1062
|
role: "option",
|
|
@@ -1062,12 +1065,12 @@ function br({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1062
1065
|
"data-active": t ? "true" : "false",
|
|
1063
1066
|
onMouseDown: (e) => e.preventDefault(),
|
|
1064
1067
|
onClick: () => B(e.language),
|
|
1065
|
-
children: [/* @__PURE__ */ Z("span", { children: e.label }), t ? /* @__PURE__ */ Z(
|
|
1068
|
+
children: [/* @__PURE__ */ Z("span", { children: e.label }), t ? /* @__PURE__ */ Z(wr, { icon: "check" }) : null]
|
|
1066
1069
|
}, e.language);
|
|
1067
1070
|
})
|
|
1068
1071
|
})]
|
|
1069
1072
|
}) : null,
|
|
1070
|
-
|
|
1073
|
+
w ? /* @__PURE__ */ Q("div", {
|
|
1071
1074
|
className: "markweave-mermaid-fullscreen-layer",
|
|
1072
1075
|
role: "dialog",
|
|
1073
1076
|
"aria-modal": "true",
|
|
@@ -1083,47 +1086,47 @@ function br({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1083
1086
|
className: "markweave-mermaid-fullscreen-control",
|
|
1084
1087
|
"aria-label": "Zoom out",
|
|
1085
1088
|
"data-testid": "markweave-mermaid-fullscreen-zoom-out",
|
|
1086
|
-
onMouseEnter: () =>
|
|
1087
|
-
onMouseLeave: () =>
|
|
1088
|
-
onFocus: () =>
|
|
1089
|
-
onBlur: () =>
|
|
1090
|
-
onClick: () =>
|
|
1091
|
-
children: /* @__PURE__ */ Z(
|
|
1089
|
+
onMouseEnter: () => D("zoom-out"),
|
|
1090
|
+
onMouseLeave: () => D(null),
|
|
1091
|
+
onFocus: () => D("zoom-out"),
|
|
1092
|
+
onBlur: () => D(null),
|
|
1093
|
+
onClick: () => ve(-dn),
|
|
1094
|
+
children: /* @__PURE__ */ Z(wr, { icon: "zoomOut" })
|
|
1092
1095
|
}),
|
|
1093
1096
|
/* @__PURE__ */ Z("span", {
|
|
1094
1097
|
className: "markweave-mermaid-fullscreen-zoom-label",
|
|
1095
1098
|
"data-testid": "markweave-mermaid-fullscreen-zoom-label",
|
|
1096
|
-
children:
|
|
1099
|
+
children: $t(w.scale)
|
|
1097
1100
|
}),
|
|
1098
1101
|
/* @__PURE__ */ Z("button", {
|
|
1099
1102
|
type: "button",
|
|
1100
1103
|
className: "markweave-mermaid-fullscreen-control",
|
|
1101
1104
|
"aria-label": "Zoom in",
|
|
1102
1105
|
"data-testid": "markweave-mermaid-fullscreen-zoom-in",
|
|
1103
|
-
onMouseEnter: () =>
|
|
1104
|
-
onMouseLeave: () =>
|
|
1105
|
-
onFocus: () =>
|
|
1106
|
-
onBlur: () =>
|
|
1107
|
-
onClick: () =>
|
|
1108
|
-
children: /* @__PURE__ */ Z(
|
|
1106
|
+
onMouseEnter: () => D("zoom-in"),
|
|
1107
|
+
onMouseLeave: () => D(null),
|
|
1108
|
+
onFocus: () => D("zoom-in"),
|
|
1109
|
+
onBlur: () => D(null),
|
|
1110
|
+
onClick: () => ve(dn),
|
|
1111
|
+
children: /* @__PURE__ */ Z(wr, { icon: "zoomIn" })
|
|
1109
1112
|
}),
|
|
1110
1113
|
/* @__PURE__ */ Z("button", {
|
|
1111
1114
|
type: "button",
|
|
1112
1115
|
className: "markweave-mermaid-fullscreen-control",
|
|
1113
1116
|
"aria-label": "Reset zoom",
|
|
1114
1117
|
"data-testid": "markweave-mermaid-fullscreen-reset",
|
|
1115
|
-
onMouseEnter: () =>
|
|
1116
|
-
onMouseLeave: () =>
|
|
1117
|
-
onFocus: () =>
|
|
1118
|
-
onBlur: () =>
|
|
1119
|
-
onClick:
|
|
1120
|
-
children: /* @__PURE__ */ Z(
|
|
1118
|
+
onMouseEnter: () => D("reset"),
|
|
1119
|
+
onMouseLeave: () => D(null),
|
|
1120
|
+
onFocus: () => D("reset"),
|
|
1121
|
+
onBlur: () => D(null),
|
|
1122
|
+
onClick: K,
|
|
1123
|
+
children: /* @__PURE__ */ Z(wr, { icon: "reset" })
|
|
1121
1124
|
}),
|
|
1122
|
-
|
|
1125
|
+
E ? /* @__PURE__ */ Z("span", {
|
|
1123
1126
|
className: "markweave-mermaid-fullscreen-tooltip",
|
|
1124
1127
|
role: "tooltip",
|
|
1125
1128
|
"data-testid": "markweave-mermaid-fullscreen-tooltip",
|
|
1126
|
-
children:
|
|
1129
|
+
children: E === "zoom-out" ? "Zoom out" : E === "zoom-in" ? "Zoom in" : "Reset"
|
|
1127
1130
|
}) : null
|
|
1128
1131
|
]
|
|
1129
1132
|
}),
|
|
@@ -1133,28 +1136,28 @@ function br({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1133
1136
|
"aria-label": "Close fullscreen Mermaid preview",
|
|
1134
1137
|
"data-testid": "markweave-mermaid-fullscreen-close",
|
|
1135
1138
|
onClick: _e,
|
|
1136
|
-
children: /* @__PURE__ */ Z(
|
|
1139
|
+
children: /* @__PURE__ */ Z(wr, { icon: "close" })
|
|
1137
1140
|
}),
|
|
1138
1141
|
/* @__PURE__ */ Z("div", {
|
|
1139
1142
|
className: "markweave-mermaid-fullscreen-viewport",
|
|
1140
1143
|
"data-testid": "markweave-mermaid-fullscreen-viewport",
|
|
1141
|
-
"data-dragging":
|
|
1142
|
-
onWheel:
|
|
1143
|
-
onMouseDown:
|
|
1144
|
-
onMouseMove:
|
|
1145
|
-
onMouseUp:
|
|
1146
|
-
onMouseLeave:
|
|
1144
|
+
"data-dragging": O ? "true" : "false",
|
|
1145
|
+
onWheel: ye,
|
|
1146
|
+
onMouseDown: be,
|
|
1147
|
+
onMouseMove: xe,
|
|
1148
|
+
onMouseUp: Se,
|
|
1149
|
+
onMouseLeave: Se,
|
|
1147
1150
|
children: /* @__PURE__ */ Z("div", {
|
|
1148
1151
|
className: "markweave-mermaid-fullscreen-content",
|
|
1149
1152
|
"data-testid": "markweave-mermaid-fullscreen-content",
|
|
1150
|
-
"data-scale-percent": Math.round(
|
|
1151
|
-
"data-translate": `${Math.round(
|
|
1153
|
+
"data-scale-percent": Math.round(w.scale * 100),
|
|
1154
|
+
"data-translate": `${Math.round(w.translateX)},${Math.round(w.translateY)}`,
|
|
1152
1155
|
style: {
|
|
1153
|
-
width: `${
|
|
1154
|
-
height: `${
|
|
1155
|
-
transform: `translate(${
|
|
1156
|
+
width: `${w.width}px`,
|
|
1157
|
+
height: `${w.height}px`,
|
|
1158
|
+
transform: `translate(${w.translateX}px, ${w.translateY}px) scale(${w.scale})`
|
|
1156
1159
|
},
|
|
1157
|
-
dangerouslySetInnerHTML: { __html:
|
|
1160
|
+
dangerouslySetInnerHTML: { __html: w.svg }
|
|
1158
1161
|
})
|
|
1159
1162
|
})
|
|
1160
1163
|
]
|
|
@@ -1164,25 +1167,25 @@ function br({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1164
1167
|
}
|
|
1165
1168
|
//#endregion
|
|
1166
1169
|
//#region src/ui/floating-toolbar/FloatingToolbar.tsx
|
|
1167
|
-
var
|
|
1168
|
-
function
|
|
1170
|
+
var Er = Ae("zh");
|
|
1171
|
+
function Dr() {
|
|
1169
1172
|
return typeof performance > "u" ? Date.now() : performance.now();
|
|
1170
1173
|
}
|
|
1171
|
-
function
|
|
1174
|
+
function Or(e, t) {
|
|
1172
1175
|
return {
|
|
1173
1176
|
"--markweave-toolbar-motion-duration": `${e.motionDurationMs}ms`,
|
|
1174
1177
|
"--markweave-toolbar-motion-easing": e.motionEasing,
|
|
1175
1178
|
marginLeft: t === 0 ? void 0 : `${t}px`
|
|
1176
1179
|
};
|
|
1177
1180
|
}
|
|
1178
|
-
function
|
|
1181
|
+
function kr(e, t) {
|
|
1179
1182
|
let n = e?.getBoundingClientRect().height ?? 0, r = t?.getBoundingClientRect().height ?? 0;
|
|
1180
1183
|
return Math.max(n, r, 44);
|
|
1181
1184
|
}
|
|
1182
|
-
function
|
|
1185
|
+
function Ar(e) {
|
|
1183
1186
|
if (e !== null) return { "--markweave-floating-toolbar-tooltip-left": `${e}px` };
|
|
1184
1187
|
}
|
|
1185
|
-
function
|
|
1188
|
+
function jr(e, t, n, r) {
|
|
1186
1189
|
let i = {
|
|
1187
1190
|
bottom: t + r,
|
|
1188
1191
|
height: r,
|
|
@@ -1198,26 +1201,26 @@ function Er(e, t, n, r) {
|
|
|
1198
1201
|
toJSON: () => i
|
|
1199
1202
|
};
|
|
1200
1203
|
}
|
|
1201
|
-
function
|
|
1204
|
+
function Mr(e) {
|
|
1202
1205
|
return e.width > 0 && e.height > 0;
|
|
1203
1206
|
}
|
|
1204
|
-
function
|
|
1207
|
+
function Nr(e) {
|
|
1205
1208
|
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));
|
|
1206
|
-
return
|
|
1209
|
+
return jr(t, n, r - t, i - n);
|
|
1207
1210
|
}
|
|
1208
|
-
function
|
|
1211
|
+
function Pr(e, t) {
|
|
1209
1212
|
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;
|
|
1210
1213
|
return r(t.anchorNode) && r(t.focusNode);
|
|
1211
1214
|
}
|
|
1212
|
-
function
|
|
1215
|
+
function Fr(e) {
|
|
1213
1216
|
if (typeof e.getClientRects != "function") return null;
|
|
1214
|
-
let t = Array.from(e.getClientRects()).filter(
|
|
1217
|
+
let t = Array.from(e.getClientRects()).filter(Mr).map((e) => jr(e.left, e.top, e.width, e.height));
|
|
1215
1218
|
if (t.length > 0) return t;
|
|
1216
1219
|
if (typeof e.getBoundingClientRect != "function") return null;
|
|
1217
1220
|
let n = e.getBoundingClientRect();
|
|
1218
|
-
return
|
|
1221
|
+
return Mr(n) ? [jr(n.left, n.top, n.width, n.height)] : null;
|
|
1219
1222
|
}
|
|
1220
|
-
function
|
|
1223
|
+
function Ir(e, t) {
|
|
1221
1224
|
if (t.rangeCount === 0) return null;
|
|
1222
1225
|
let n = t.getRangeAt(0);
|
|
1223
1226
|
try {
|
|
@@ -1230,8 +1233,8 @@ function jr(e, t) {
|
|
|
1230
1233
|
return null;
|
|
1231
1234
|
}
|
|
1232
1235
|
}
|
|
1233
|
-
function
|
|
1234
|
-
let n =
|
|
1236
|
+
function Lr(e, t) {
|
|
1237
|
+
let n = Ir(e, t);
|
|
1235
1238
|
if (!n) return !1;
|
|
1236
1239
|
let { selection: r } = e.state, i = {
|
|
1237
1240
|
from: Math.min(r.from, r.to),
|
|
@@ -1239,51 +1242,51 @@ function Mr(e, t) {
|
|
|
1239
1242
|
};
|
|
1240
1243
|
return n.from === i.from && n.to === i.to;
|
|
1241
1244
|
}
|
|
1242
|
-
function
|
|
1245
|
+
function Rr(e) {
|
|
1243
1246
|
let t = e.view.dom.ownerDocument.getSelection();
|
|
1244
|
-
return !t || t.rangeCount === 0 || t.isCollapsed || !
|
|
1247
|
+
return !t || t.rangeCount === 0 || t.isCollapsed || !Pr(e, t) || !Lr(e, t) ? null : Fr(t.getRangeAt(0));
|
|
1245
1248
|
}
|
|
1246
|
-
function
|
|
1249
|
+
function zr(e) {
|
|
1247
1250
|
let { selection: t } = e.state;
|
|
1248
1251
|
if (t.empty) return null;
|
|
1249
1252
|
let n = Math.min(t.from, t.to), r = Math.max(t.from, t.to);
|
|
1250
1253
|
try {
|
|
1251
1254
|
let t = e.view.domAtPos(n), i = e.view.domAtPos(r), a = e.view.dom.ownerDocument.createRange();
|
|
1252
|
-
return a.setStart(t.node, t.offset), a.setEnd(i.node, i.offset),
|
|
1255
|
+
return a.setStart(t.node, t.offset), a.setEnd(i.node, i.offset), Fr(a);
|
|
1253
1256
|
} catch {
|
|
1254
1257
|
return null;
|
|
1255
1258
|
}
|
|
1256
1259
|
}
|
|
1257
|
-
function
|
|
1260
|
+
function Br(e) {
|
|
1258
1261
|
let { selection: t } = e.state;
|
|
1259
1262
|
if (t.empty) return null;
|
|
1260
|
-
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 =
|
|
1261
|
-
return
|
|
1263
|
+
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 = jr(c, o, Math.max(i.right, a.right) - c, s - o);
|
|
1264
|
+
return Mr(l) ? [l] : null;
|
|
1262
1265
|
}
|
|
1263
|
-
function
|
|
1264
|
-
return
|
|
1266
|
+
function Vr(e) {
|
|
1267
|
+
return Rr(e) ?? zr(e) ?? Br(e);
|
|
1265
1268
|
}
|
|
1266
|
-
function
|
|
1267
|
-
let t =
|
|
1268
|
-
return t && t.length > 0 ?
|
|
1269
|
+
function Hr(e) {
|
|
1270
|
+
let t = Vr(e);
|
|
1271
|
+
return t && t.length > 0 ? Nr(t) : null;
|
|
1269
1272
|
}
|
|
1270
|
-
function
|
|
1273
|
+
function Ur(e) {
|
|
1271
1274
|
return {
|
|
1272
|
-
getBoundingClientRect: () =>
|
|
1273
|
-
getClientRects: () =>
|
|
1275
|
+
getBoundingClientRect: () => Hr(e) ?? jr(0, 0, 0, 0),
|
|
1276
|
+
getClientRects: () => Vr(e) ?? []
|
|
1274
1277
|
};
|
|
1275
1278
|
}
|
|
1276
|
-
function
|
|
1279
|
+
function Wr(e) {
|
|
1277
1280
|
return e === "block-type" || e === "link" || e === "color" || e === "more";
|
|
1278
1281
|
}
|
|
1279
|
-
function
|
|
1280
|
-
n?.(
|
|
1282
|
+
function Gr(e, t, n) {
|
|
1283
|
+
n?.(gn(e, t)), e.commands.focus();
|
|
1281
1284
|
}
|
|
1282
|
-
function
|
|
1283
|
-
let i = U(() =>
|
|
1284
|
-
let t =
|
|
1285
|
+
function Kr({ editor: e, messages: t = Er, selectionSnapshot: n, onRewriteSelection: r }) {
|
|
1286
|
+
let i = U(() => xn(t), [t]), a = et(n, { editable: e.isEditable }), [o, s] = G(a), [c, l] = G(null), [u, d] = G(null), [f, p] = G(null), [m, h] = G(""), [g, _] = G(""), [v, y] = G(null), [b, x] = G(0), [S, ee] = G(a.boundaryPadding), [C, w] = G("bottom"), T = W(0), E = W(null), D = W(null), O = W(null), k = W(null), A = _n(e, o.variant, t), j = Cn(A.find((e) => e.id === c) ?? null), M = Pn(m), N = V(() => {
|
|
1287
|
+
let t = E.current, n = e.view.dom.closest(".markweave-editor-frame");
|
|
1285
1288
|
if (!t || !(n instanceof HTMLElement)) return;
|
|
1286
|
-
let r = t.getBoundingClientRect(), i = n.getBoundingClientRect(), a =
|
|
1289
|
+
let r = t.getBoundingClientRect(), i = n.getBoundingClientRect(), a = kr(t, D.current), s = T.current, c = Ye({
|
|
1287
1290
|
toolbarRect: {
|
|
1288
1291
|
left: r.left - s,
|
|
1289
1292
|
top: r.top,
|
|
@@ -1297,7 +1300,7 @@ function Vr({ editor: e, messages: t = xr, selectionSnapshot: n, onRewriteSelect
|
|
|
1297
1300
|
height: i.height
|
|
1298
1301
|
},
|
|
1299
1302
|
boundaryPadding: o.boundaryPadding
|
|
1300
|
-
}), l =
|
|
1303
|
+
}), l = Ze({
|
|
1301
1304
|
frameRect: {
|
|
1302
1305
|
left: i.left,
|
|
1303
1306
|
top: i.top,
|
|
@@ -1311,28 +1314,49 @@ function Vr({ editor: e, messages: t = xr, selectionSnapshot: n, onRewriteSelect
|
|
|
1311
1314
|
offset: o.offset,
|
|
1312
1315
|
boundaryPadding: o.boundaryPadding
|
|
1313
1316
|
});
|
|
1314
|
-
t.style.marginLeft = c === 0 ? "" : `${c}px`, t.style.visibility = "visible", t.style.opacity = "1",
|
|
1317
|
+
t.style.marginLeft = c === 0 ? "" : `${c}px`, t.style.visibility = "visible", t.style.opacity = "1", T.current = c, x((e) => e === c ? e : c), ee((e) => e === l ? e : l);
|
|
1315
1318
|
}, [
|
|
1316
1319
|
e.view.dom,
|
|
1317
1320
|
o.boundaryPadding,
|
|
1318
1321
|
o.offset
|
|
1319
|
-
]),
|
|
1320
|
-
|
|
1321
|
-
}, []),
|
|
1322
|
-
|
|
1323
|
-
}, [
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1322
|
+
]), P = V(() => {
|
|
1323
|
+
E.current && (E.current.style.visibility = "hidden", E.current.style.opacity = "0");
|
|
1324
|
+
}, []), F = V(() => {
|
|
1325
|
+
N();
|
|
1326
|
+
}, [N]), te = V(() => Ur(e), [e]), I = V((e) => {
|
|
1327
|
+
O.current = e;
|
|
1328
|
+
}, []), L = V(() => {
|
|
1329
|
+
let t = E.current, n = O.current, r = e.view.dom.closest(".markweave-editor-frame");
|
|
1330
|
+
if (!f || !t || !n) return;
|
|
1331
|
+
let i = t.getBoundingClientRect(), a = n.getBoundingClientRect(), s = r?.getBoundingClientRect() ?? null, c = Xe({
|
|
1332
|
+
toolbarRect: i,
|
|
1333
|
+
popoverSize: a,
|
|
1334
|
+
viewport: {
|
|
1335
|
+
width: window.innerWidth,
|
|
1336
|
+
height: window.innerHeight
|
|
1337
|
+
},
|
|
1338
|
+
frameRect: s,
|
|
1339
|
+
gap: f === "more" ? 8 : 6,
|
|
1340
|
+
boundaryPadding: o.boundaryPadding
|
|
1341
|
+
});
|
|
1342
|
+
w((e) => e === c.placement ? e : c.placement);
|
|
1343
|
+
}, [
|
|
1344
|
+
e.view.dom,
|
|
1345
|
+
f,
|
|
1346
|
+
o.boundaryPadding
|
|
1347
|
+
]), ne = U(() => ({
|
|
1348
|
+
...$e(o, { topBoundaryPadding: S }),
|
|
1349
|
+
onShow: P,
|
|
1350
|
+
onUpdate: F
|
|
1327
1351
|
}), [
|
|
1328
|
-
|
|
1329
|
-
|
|
1352
|
+
P,
|
|
1353
|
+
F,
|
|
1330
1354
|
o,
|
|
1331
1355
|
S
|
|
1332
1356
|
]);
|
|
1333
1357
|
H(() => {
|
|
1334
|
-
let e =
|
|
1335
|
-
s((t) =>
|
|
1358
|
+
let e = Dr();
|
|
1359
|
+
s((t) => rt(t, a, e));
|
|
1336
1360
|
}, [
|
|
1337
1361
|
a.hiddenReason,
|
|
1338
1362
|
a.motionDurationMs,
|
|
@@ -1346,8 +1370,8 @@ function Vr({ editor: e, messages: t = xr, selectionSnapshot: n, onRewriteSelect
|
|
|
1346
1370
|
a.visibility
|
|
1347
1371
|
]), H(() => {
|
|
1348
1372
|
if (o.motionStartedAtMs === null || o.motionDurationMs <= 0) return;
|
|
1349
|
-
let e = Math.max(0, o.motionStartedAtMs + o.motionDurationMs -
|
|
1350
|
-
s((e) =>
|
|
1373
|
+
let e = Math.max(0, o.motionStartedAtMs + o.motionDurationMs - Dr()), t = window.setTimeout(() => {
|
|
1374
|
+
s((e) => qe(e, Dr()));
|
|
1351
1375
|
}, e);
|
|
1352
1376
|
return () => {
|
|
1353
1377
|
window.clearTimeout(t);
|
|
@@ -1358,33 +1382,39 @@ function Vr({ editor: e, messages: t = xr, selectionSnapshot: n, onRewriteSelect
|
|
|
1358
1382
|
o.motionStartedAtMs
|
|
1359
1383
|
]), me(() => {
|
|
1360
1384
|
if (o.visibility !== "visible") {
|
|
1361
|
-
|
|
1385
|
+
T.current = 0, E.current && (E.current.style.marginLeft = "", E.current.style.visibility = "hidden", E.current.style.opacity = "0"), x(0), ee(o.boundaryPadding);
|
|
1362
1386
|
return;
|
|
1363
1387
|
}
|
|
1364
|
-
let e =
|
|
1365
|
-
return e
|
|
1366
|
-
|
|
1388
|
+
let e = mn(N);
|
|
1389
|
+
return e.schedule(), window.addEventListener("resize", e.schedule), window.addEventListener("scroll", e.schedule, !0), () => {
|
|
1390
|
+
e.cancel(), window.removeEventListener("resize", e.schedule), window.removeEventListener("scroll", e.schedule, !0);
|
|
1367
1391
|
};
|
|
1368
1392
|
}, [
|
|
1369
|
-
|
|
1393
|
+
N,
|
|
1370
1394
|
e.view.dom,
|
|
1371
1395
|
f,
|
|
1372
1396
|
n?.from,
|
|
1373
1397
|
n?.to,
|
|
1374
1398
|
o.variant,
|
|
1375
1399
|
o.visibility,
|
|
1376
|
-
|
|
1377
|
-
]),
|
|
1378
|
-
|
|
1400
|
+
A.length
|
|
1401
|
+
]), me(() => {
|
|
1402
|
+
if (!f) return;
|
|
1403
|
+
let e = mn(L);
|
|
1404
|
+
return e.schedule(), window.addEventListener("resize", e.schedule), window.addEventListener("scroll", e.schedule, !0), () => {
|
|
1405
|
+
e.cancel(), window.removeEventListener("resize", e.schedule), window.removeEventListener("scroll", e.schedule, !0);
|
|
1406
|
+
};
|
|
1407
|
+
}, [f, L]), H(() => {
|
|
1408
|
+
f === "more" && i.some((e) => e.id === c) || A.some((e) => e.id === c) || (l(null), d(null));
|
|
1379
1409
|
}, [
|
|
1380
1410
|
i,
|
|
1381
1411
|
f,
|
|
1382
1412
|
c,
|
|
1383
|
-
|
|
1413
|
+
A
|
|
1384
1414
|
]), H(() => {
|
|
1385
1415
|
if (!f) return;
|
|
1386
1416
|
let t = (e) => {
|
|
1387
|
-
|
|
1417
|
+
D.current?.contains(e.target) || p(null);
|
|
1388
1418
|
}, n = (t) => {
|
|
1389
1419
|
t.key === "Escape" && (t.preventDefault(), p(null), e.commands.focus());
|
|
1390
1420
|
};
|
|
@@ -1394,15 +1424,15 @@ function Vr({ editor: e, messages: t = xr, selectionSnapshot: n, onRewriteSelect
|
|
|
1394
1424
|
}, [e, f]), H(() => {
|
|
1395
1425
|
if (f !== "link") return;
|
|
1396
1426
|
let e = window.requestAnimationFrame(() => {
|
|
1397
|
-
|
|
1427
|
+
k.current?.focus(), k.current?.select();
|
|
1398
1428
|
});
|
|
1399
1429
|
return () => window.cancelAnimationFrame(e);
|
|
1400
1430
|
}, [f]);
|
|
1401
|
-
let
|
|
1402
|
-
if (
|
|
1431
|
+
let R = (t) => {
|
|
1432
|
+
if (Wr(t.id)) {
|
|
1403
1433
|
let n = t.id;
|
|
1404
1434
|
if (n === "link") {
|
|
1405
|
-
let t =
|
|
1435
|
+
let t = yn(e);
|
|
1406
1436
|
h(t), _(t), y({
|
|
1407
1437
|
from: Math.min(e.state.selection.from, e.state.selection.to),
|
|
1408
1438
|
to: Math.max(e.state.selection.from, e.state.selection.to)
|
|
@@ -1412,102 +1442,108 @@ function Vr({ editor: e, messages: t = xr, selectionSnapshot: n, onRewriteSelect
|
|
|
1412
1442
|
return;
|
|
1413
1443
|
}
|
|
1414
1444
|
if (p(null), t.id === "improve") {
|
|
1415
|
-
|
|
1445
|
+
Gr(e, "rewrite-selection", r);
|
|
1416
1446
|
return;
|
|
1417
1447
|
}
|
|
1418
1448
|
t.run(), e.commands.focus();
|
|
1419
|
-
},
|
|
1449
|
+
}, z = () => {
|
|
1420
1450
|
p(null), e.commands.focus();
|
|
1421
|
-
},
|
|
1451
|
+
}, re = () => {
|
|
1422
1452
|
v && e.commands.setTextSelection(v);
|
|
1423
|
-
},
|
|
1424
|
-
|
|
1425
|
-
},
|
|
1426
|
-
if (
|
|
1427
|
-
h(""), _(""),
|
|
1453
|
+
}, ie = () => {
|
|
1454
|
+
re(), hn(e, m) && z();
|
|
1455
|
+
}, ae = () => {
|
|
1456
|
+
if (re(), kn(e)) {
|
|
1457
|
+
h(""), _(""), z();
|
|
1428
1458
|
return;
|
|
1429
1459
|
}
|
|
1430
1460
|
m.trim() && h("");
|
|
1431
|
-
},
|
|
1432
|
-
if (l(e), !e || !t || !
|
|
1461
|
+
}, oe = (e, t) => {
|
|
1462
|
+
if (l(e), !e || !t || !D.current) {
|
|
1433
1463
|
d(null);
|
|
1434
1464
|
return;
|
|
1435
1465
|
}
|
|
1436
|
-
let n = t.getBoundingClientRect(), r =
|
|
1466
|
+
let n = t.getBoundingClientRect(), r = D.current.getBoundingClientRect();
|
|
1437
1467
|
d(n.left + n.width / 2 - r.left);
|
|
1438
1468
|
};
|
|
1439
|
-
return /* @__PURE__ */ Z(
|
|
1440
|
-
ref:
|
|
1469
|
+
return /* @__PURE__ */ Z(pn, {
|
|
1470
|
+
ref: E,
|
|
1441
1471
|
editor: e,
|
|
1442
1472
|
className: `markweave-floating-toolbar markweave-floating-toolbar--${o.variant} markweave-floating-toolbar--motion-${o.motionPhase}`,
|
|
1443
1473
|
"data-motion": o.motionPhase,
|
|
1444
|
-
"data-position-strategy":
|
|
1474
|
+
"data-position-strategy": ne.strategy,
|
|
1445
1475
|
"data-boundary-padding": o.boundaryPadding,
|
|
1476
|
+
"data-popover-placement": f ? C : void 0,
|
|
1446
1477
|
"data-testid": "markweave-floating-toolbar",
|
|
1447
|
-
style:
|
|
1478
|
+
style: Or(o, b),
|
|
1448
1479
|
updateDelay: 0,
|
|
1449
|
-
getReferencedVirtualElement:
|
|
1450
|
-
options:
|
|
1451
|
-
shouldShow: ({ editor: e }) => e.isEditable && Qe(
|
|
1480
|
+
getReferencedVirtualElement: te,
|
|
1481
|
+
options: ne,
|
|
1482
|
+
shouldShow: ({ editor: e }) => e.isEditable && nt(Qe(e)),
|
|
1452
1483
|
children: /* @__PURE__ */ Q("div", {
|
|
1453
|
-
ref:
|
|
1484
|
+
ref: D,
|
|
1454
1485
|
className: "markweave-floating-toolbar-content",
|
|
1455
1486
|
"data-menu": f ?? "none",
|
|
1456
1487
|
children: [
|
|
1457
|
-
|
|
1488
|
+
A.map((e, t) => /* @__PURE__ */ Z(Jr, {
|
|
1458
1489
|
button: e,
|
|
1459
1490
|
expanded: f === e.id,
|
|
1460
|
-
showDivider: t > 0 &&
|
|
1491
|
+
showDivider: t > 0 && A[t - 1].group !== e.group,
|
|
1461
1492
|
tooltipActive: c === e.id,
|
|
1462
|
-
onPointerDown:
|
|
1463
|
-
onTooltipChange:
|
|
1464
|
-
onRun:
|
|
1493
|
+
onPointerDown: On,
|
|
1494
|
+
onTooltipChange: oe,
|
|
1495
|
+
onRun: R
|
|
1465
1496
|
}, e.id)),
|
|
1466
|
-
f === "block-type" ? /* @__PURE__ */ Z(
|
|
1497
|
+
f === "block-type" ? /* @__PURE__ */ Z(Xr, {
|
|
1467
1498
|
editor: e,
|
|
1468
1499
|
messages: t,
|
|
1500
|
+
onPopoverRef: I,
|
|
1469
1501
|
onClose: () => p(null)
|
|
1470
1502
|
}) : null,
|
|
1471
|
-
f === "link" ? /* @__PURE__ */ Z(
|
|
1472
|
-
inputRef:
|
|
1503
|
+
f === "link" ? /* @__PURE__ */ Z(qr, {
|
|
1504
|
+
inputRef: k,
|
|
1473
1505
|
messages: t,
|
|
1474
1506
|
value: m,
|
|
1475
|
-
canApply: !!
|
|
1476
|
-
canOpen: !!
|
|
1507
|
+
canApply: !!M,
|
|
1508
|
+
canOpen: !!M,
|
|
1477
1509
|
canRemove: !!(g || m.trim()),
|
|
1478
1510
|
onValueChange: h,
|
|
1479
|
-
onApply:
|
|
1480
|
-
onOpen: () =>
|
|
1481
|
-
onRemove:
|
|
1511
|
+
onApply: ie,
|
|
1512
|
+
onOpen: () => Dn(m),
|
|
1513
|
+
onRemove: ae,
|
|
1514
|
+
onPopoverRef: I
|
|
1482
1515
|
}) : null,
|
|
1483
|
-
f === "color" ? /* @__PURE__ */ Z(
|
|
1516
|
+
f === "color" ? /* @__PURE__ */ Z(Qr, {
|
|
1484
1517
|
editor: e,
|
|
1485
1518
|
messages: t,
|
|
1519
|
+
onPopoverRef: I,
|
|
1486
1520
|
onClose: () => p(null)
|
|
1487
1521
|
}) : null,
|
|
1488
|
-
f === "more" ? /* @__PURE__ */ Z(
|
|
1522
|
+
f === "more" ? /* @__PURE__ */ Z(ei, {
|
|
1489
1523
|
editor: e,
|
|
1490
1524
|
messages: t,
|
|
1491
1525
|
activeTooltipId: c,
|
|
1526
|
+
onPopoverRef: I,
|
|
1492
1527
|
onTooltipChange: l,
|
|
1493
1528
|
onClose: () => p(null)
|
|
1494
1529
|
}) : null,
|
|
1495
|
-
|
|
1530
|
+
j && f === null ? /* @__PURE__ */ Z("div", {
|
|
1496
1531
|
className: "markweave-floating-toolbar-tooltip",
|
|
1497
1532
|
role: "tooltip",
|
|
1498
1533
|
"data-testid": "markweave-floating-toolbar-tooltip",
|
|
1499
|
-
"data-button-id":
|
|
1500
|
-
"data-active":
|
|
1501
|
-
style:
|
|
1502
|
-
children:
|
|
1534
|
+
"data-button-id": j.buttonId,
|
|
1535
|
+
"data-active": j.active,
|
|
1536
|
+
style: Ar(u),
|
|
1537
|
+
children: j.label
|
|
1503
1538
|
}) : null
|
|
1504
1539
|
]
|
|
1505
1540
|
})
|
|
1506
1541
|
});
|
|
1507
1542
|
}
|
|
1508
|
-
function
|
|
1509
|
-
let
|
|
1543
|
+
function qr({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRemove: a, onValueChange: o, onApply: s, onOpen: c, onRemove: l, onPopoverRef: u }) {
|
|
1544
|
+
let d = bn(t);
|
|
1510
1545
|
return /* @__PURE__ */ Q("form", {
|
|
1546
|
+
ref: u,
|
|
1511
1547
|
className: "markweave-floating-toolbar-popover markweave-floating-toolbar-link-popover",
|
|
1512
1548
|
"data-testid": "markweave-floating-toolbar-link-popover",
|
|
1513
1549
|
onSubmit: (e) => {
|
|
@@ -1515,9 +1551,9 @@ function Hr({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRe
|
|
|
1515
1551
|
},
|
|
1516
1552
|
children: [/* @__PURE__ */ Z("input", {
|
|
1517
1553
|
ref: e,
|
|
1518
|
-
"aria-label":
|
|
1554
|
+
"aria-label": d.linkUrlLabel,
|
|
1519
1555
|
"data-testid": "markweave-floating-toolbar-link-input",
|
|
1520
|
-
placeholder:
|
|
1556
|
+
placeholder: d.linkPlaceholder,
|
|
1521
1557
|
value: n,
|
|
1522
1558
|
onChange: (e) => o(e.currentTarget.value)
|
|
1523
1559
|
}), /* @__PURE__ */ Q("span", {
|
|
@@ -1525,10 +1561,10 @@ function Hr({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRe
|
|
|
1525
1561
|
children: [
|
|
1526
1562
|
/* @__PURE__ */ Z("button", {
|
|
1527
1563
|
type: "submit",
|
|
1528
|
-
"aria-label":
|
|
1564
|
+
"aria-label": d.applyLink,
|
|
1529
1565
|
"data-testid": "markweave-floating-toolbar-link-apply",
|
|
1530
1566
|
disabled: !r,
|
|
1531
|
-
onMouseDown:
|
|
1567
|
+
onMouseDown: On,
|
|
1532
1568
|
children: /* @__PURE__ */ Z($, { name: "corner-down-left" })
|
|
1533
1569
|
}),
|
|
1534
1570
|
/* @__PURE__ */ Z("span", {
|
|
@@ -1537,19 +1573,19 @@ function Hr({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRe
|
|
|
1537
1573
|
}),
|
|
1538
1574
|
/* @__PURE__ */ Z("button", {
|
|
1539
1575
|
type: "button",
|
|
1540
|
-
"aria-label":
|
|
1576
|
+
"aria-label": d.openLink,
|
|
1541
1577
|
"data-testid": "markweave-floating-toolbar-link-open",
|
|
1542
1578
|
disabled: !i,
|
|
1543
|
-
onMouseDown:
|
|
1579
|
+
onMouseDown: On,
|
|
1544
1580
|
onClick: c,
|
|
1545
1581
|
children: /* @__PURE__ */ Z($, { name: "external-link" })
|
|
1546
1582
|
}),
|
|
1547
1583
|
/* @__PURE__ */ Z("button", {
|
|
1548
1584
|
type: "button",
|
|
1549
|
-
"aria-label":
|
|
1585
|
+
"aria-label": d.removeLink,
|
|
1550
1586
|
"data-testid": "markweave-floating-toolbar-link-remove",
|
|
1551
1587
|
disabled: !a,
|
|
1552
|
-
onMouseDown:
|
|
1588
|
+
onMouseDown: On,
|
|
1553
1589
|
onClick: l,
|
|
1554
1590
|
children: /* @__PURE__ */ Z($, { name: "trash" })
|
|
1555
1591
|
})
|
|
@@ -1557,7 +1593,7 @@ function Hr({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRe
|
|
|
1557
1593
|
})]
|
|
1558
1594
|
});
|
|
1559
1595
|
}
|
|
1560
|
-
function
|
|
1596
|
+
function Jr({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointerDown: i, onTooltipChange: a, onRun: o }) {
|
|
1561
1597
|
return /* @__PURE__ */ Q(X, { children: [n ? /* @__PURE__ */ Z("span", {
|
|
1562
1598
|
className: "markweave-floating-toolbar-divider",
|
|
1563
1599
|
"aria-hidden": "true"
|
|
@@ -1565,7 +1601,7 @@ function Ur({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointe
|
|
|
1565
1601
|
type: "button",
|
|
1566
1602
|
className: `markweave-floating-toolbar-button markweave-floating-toolbar-button--${e.id}`,
|
|
1567
1603
|
"aria-label": e.label,
|
|
1568
|
-
"aria-expanded":
|
|
1604
|
+
"aria-expanded": Wr(e.id) ? t : void 0,
|
|
1569
1605
|
"data-active": e.active || t,
|
|
1570
1606
|
"data-tooltip-active": r ? "true" : "false",
|
|
1571
1607
|
"data-testid": `markweave-floating-toolbar-button-${e.id}`,
|
|
@@ -1575,13 +1611,13 @@ function Ur({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointe
|
|
|
1575
1611
|
onMouseEnter: (t) => a(e.id, t.currentTarget),
|
|
1576
1612
|
onMouseLeave: () => a(null),
|
|
1577
1613
|
onClick: () => o(e),
|
|
1578
|
-
children: /* @__PURE__ */ Z(
|
|
1614
|
+
children: /* @__PURE__ */ Z(Yr, {
|
|
1579
1615
|
button: e,
|
|
1580
1616
|
expanded: t
|
|
1581
1617
|
})
|
|
1582
1618
|
})] });
|
|
1583
1619
|
}
|
|
1584
|
-
function
|
|
1620
|
+
function Yr({ button: e, expanded: t }) {
|
|
1585
1621
|
return e.id === "improve" ? /* @__PURE__ */ Q("span", {
|
|
1586
1622
|
className: "markweave-floating-toolbar-button-inner",
|
|
1587
1623
|
children: [/* @__PURE__ */ Z($, { name: "sparkles" }), /* @__PURE__ */ Z("span", { children: e.glyph })]
|
|
@@ -1599,57 +1635,59 @@ function Wr({ button: e, expanded: t }) {
|
|
|
1599
1635
|
}), /* @__PURE__ */ Z($, { name: t ? "chevron-up" : "chevron-down" })]
|
|
1600
1636
|
}) : /* @__PURE__ */ Z($, { name: "more" });
|
|
1601
1637
|
}
|
|
1602
|
-
function
|
|
1603
|
-
let
|
|
1638
|
+
function Xr({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
|
|
1639
|
+
let i = bn(t), a = wn(t);
|
|
1604
1640
|
return /* @__PURE__ */ Q("div", {
|
|
1641
|
+
ref: n,
|
|
1605
1642
|
className: "markweave-floating-toolbar-popover markweave-floating-toolbar-turn-menu",
|
|
1606
1643
|
"data-testid": "markweave-floating-toolbar-turn-menu",
|
|
1607
1644
|
children: [/* @__PURE__ */ Z("div", {
|
|
1608
1645
|
className: "markweave-floating-toolbar-menu-title",
|
|
1609
|
-
children:
|
|
1610
|
-
}),
|
|
1646
|
+
children: i.turnIntoTitle
|
|
1647
|
+
}), a.map((t) => /* @__PURE__ */ Q("button", {
|
|
1611
1648
|
type: "button",
|
|
1612
|
-
"data-active":
|
|
1649
|
+
"data-active": En(e, t.id),
|
|
1613
1650
|
"data-testid": `markweave-floating-toolbar-turn-${t.id}`,
|
|
1614
|
-
onMouseDown:
|
|
1651
|
+
onMouseDown: On,
|
|
1615
1652
|
onClick: () => {
|
|
1616
|
-
|
|
1653
|
+
Nn(e, t.id), r();
|
|
1617
1654
|
},
|
|
1618
1655
|
children: [/* @__PURE__ */ Z("span", {
|
|
1619
1656
|
className: "markweave-floating-toolbar-menu-icon",
|
|
1620
|
-
children: /* @__PURE__ */ Z(
|
|
1657
|
+
children: /* @__PURE__ */ Z(Zr, { option: t })
|
|
1621
1658
|
}), /* @__PURE__ */ Z("span", { children: t.label })]
|
|
1622
1659
|
}, t.id))]
|
|
1623
1660
|
});
|
|
1624
1661
|
}
|
|
1625
|
-
function
|
|
1662
|
+
function Zr({ option: e }) {
|
|
1626
1663
|
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 });
|
|
1627
1664
|
}
|
|
1628
|
-
function
|
|
1629
|
-
let
|
|
1665
|
+
function Qr({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
|
|
1666
|
+
let i = bn(t), a = e.getAttributes("textStyle").color, o = e.getAttributes("highlight").color;
|
|
1630
1667
|
return /* @__PURE__ */ Q("div", {
|
|
1668
|
+
ref: n,
|
|
1631
1669
|
className: "markweave-floating-toolbar-popover markweave-floating-toolbar-color-popover",
|
|
1632
1670
|
"data-testid": "markweave-floating-toolbar-color-menu",
|
|
1633
|
-
children: [/* @__PURE__ */ Z(
|
|
1634
|
-
title:
|
|
1671
|
+
children: [/* @__PURE__ */ Z($r, {
|
|
1672
|
+
title: i.textColorTitle,
|
|
1635
1673
|
mode: "text",
|
|
1636
|
-
activeColor:
|
|
1637
|
-
options:
|
|
1674
|
+
activeColor: a ?? null,
|
|
1675
|
+
options: Sn(t),
|
|
1638
1676
|
onSelect: (t) => {
|
|
1639
|
-
|
|
1677
|
+
Mn(e, t), r();
|
|
1640
1678
|
}
|
|
1641
|
-
}), /* @__PURE__ */ Z(
|
|
1642
|
-
title:
|
|
1679
|
+
}), /* @__PURE__ */ Z($r, {
|
|
1680
|
+
title: i.highlightColorTitle,
|
|
1643
1681
|
mode: "highlight",
|
|
1644
|
-
activeColor:
|
|
1645
|
-
options:
|
|
1682
|
+
activeColor: o ?? null,
|
|
1683
|
+
options: vn(t),
|
|
1646
1684
|
onSelect: (t) => {
|
|
1647
|
-
|
|
1685
|
+
jn(e, t), r();
|
|
1648
1686
|
}
|
|
1649
1687
|
})]
|
|
1650
1688
|
});
|
|
1651
1689
|
}
|
|
1652
|
-
function
|
|
1690
|
+
function $r({ title: e, mode: t, activeColor: n, options: r, onSelect: i }) {
|
|
1653
1691
|
return /* @__PURE__ */ Q("section", {
|
|
1654
1692
|
className: "markweave-floating-toolbar-color-section",
|
|
1655
1693
|
"aria-label": e,
|
|
@@ -1663,7 +1701,7 @@ function Jr({ title: e, mode: t, activeColor: n, options: r, onSelect: i }) {
|
|
|
1663
1701
|
"aria-label": e.label,
|
|
1664
1702
|
"data-active": e.value === n || e.value === null && !n,
|
|
1665
1703
|
"data-testid": `markweave-floating-toolbar-${t}-${e.id}`,
|
|
1666
|
-
onMouseDown:
|
|
1704
|
+
onMouseDown: On,
|
|
1667
1705
|
onClick: () => i(e.value),
|
|
1668
1706
|
children: t === "text" ? /* @__PURE__ */ Z("span", {
|
|
1669
1707
|
className: "markweave-floating-toolbar-text-swatch",
|
|
@@ -1678,24 +1716,25 @@ function Jr({ title: e, mode: t, activeColor: n, options: r, onSelect: i }) {
|
|
|
1678
1716
|
})]
|
|
1679
1717
|
});
|
|
1680
1718
|
}
|
|
1681
|
-
function
|
|
1682
|
-
let
|
|
1719
|
+
function ei({ editor: e, messages: t, activeTooltipId: n, onPopoverRef: r, onTooltipChange: i, onClose: a }) {
|
|
1720
|
+
let o = xn(t);
|
|
1683
1721
|
return /* @__PURE__ */ Z("div", {
|
|
1722
|
+
ref: r,
|
|
1684
1723
|
className: "markweave-floating-toolbar-popover markweave-floating-toolbar-more-menu",
|
|
1685
1724
|
"data-testid": "markweave-floating-toolbar-more-menu",
|
|
1686
|
-
children:
|
|
1725
|
+
children: o.map((t, r) => /* @__PURE__ */ Z(ti, {
|
|
1687
1726
|
action: t,
|
|
1688
|
-
active:
|
|
1727
|
+
active: Tn(e, t.id),
|
|
1689
1728
|
tooltipActive: n === t.id,
|
|
1690
|
-
showDivider:
|
|
1691
|
-
onTooltipChange:
|
|
1729
|
+
showDivider: r > 0 && o[r - 1].group !== t.group,
|
|
1730
|
+
onTooltipChange: i,
|
|
1692
1731
|
onRun: () => {
|
|
1693
|
-
|
|
1732
|
+
An(e, t.id), a();
|
|
1694
1733
|
}
|
|
1695
1734
|
}, t.id))
|
|
1696
1735
|
});
|
|
1697
1736
|
}
|
|
1698
|
-
function
|
|
1737
|
+
function ti({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipChange: i, onRun: a }) {
|
|
1699
1738
|
return /* @__PURE__ */ Q(X, { children: [r ? /* @__PURE__ */ Z("span", {
|
|
1700
1739
|
className: "markweave-floating-toolbar-divider",
|
|
1701
1740
|
"aria-hidden": "true"
|
|
@@ -1707,11 +1746,11 @@ function Xr({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipC
|
|
|
1707
1746
|
"data-active": t,
|
|
1708
1747
|
"data-tooltip-active": n ? "true" : "false",
|
|
1709
1748
|
"data-testid": `markweave-floating-toolbar-more-${e.id}`,
|
|
1710
|
-
onMouseDown:
|
|
1749
|
+
onMouseDown: On,
|
|
1711
1750
|
onMouseEnter: () => i(e.id),
|
|
1712
1751
|
onMouseLeave: () => i(null),
|
|
1713
1752
|
onClick: a,
|
|
1714
|
-
children: /* @__PURE__ */ Z(
|
|
1753
|
+
children: /* @__PURE__ */ Z(ni, { id: e.id })
|
|
1715
1754
|
}), n ? /* @__PURE__ */ Z("div", {
|
|
1716
1755
|
className: "markweave-floating-toolbar-tooltip markweave-floating-toolbar-tooltip--more",
|
|
1717
1756
|
role: "tooltip",
|
|
@@ -1719,41 +1758,41 @@ function Xr({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipC
|
|
|
1719
1758
|
}) : null]
|
|
1720
1759
|
})] });
|
|
1721
1760
|
}
|
|
1722
|
-
function
|
|
1761
|
+
function ni({ id: e }) {
|
|
1723
1762
|
return e === "superscript" ? /* @__PURE__ */ Z($, { name: "superscript" }) : e === "subscript" ? /* @__PURE__ */ Z($, { name: "subscript" }) : e === "inline-math" ? /* @__PURE__ */ Z($, { name: "math" }) : Z($, { name: e });
|
|
1724
1763
|
}
|
|
1725
|
-
var
|
|
1764
|
+
var ri = {
|
|
1726
1765
|
sparkles: ie,
|
|
1727
1766
|
"chevron-down": h,
|
|
1728
1767
|
"chevron-up": g,
|
|
1729
1768
|
"corner-down-left": y,
|
|
1730
1769
|
"external-link": x,
|
|
1731
1770
|
bold: u,
|
|
1732
|
-
italic:
|
|
1771
|
+
italic: A,
|
|
1733
1772
|
underline: fe,
|
|
1734
1773
|
strike: ae,
|
|
1735
1774
|
"inline-code": v,
|
|
1736
|
-
link:
|
|
1737
|
-
more:
|
|
1775
|
+
link: M,
|
|
1776
|
+
more: I,
|
|
1738
1777
|
text: de,
|
|
1739
|
-
"bullet-list":
|
|
1740
|
-
"numbered-list":
|
|
1741
|
-
"todo-list":
|
|
1742
|
-
quote:
|
|
1778
|
+
"bullet-list": N,
|
|
1779
|
+
"numbered-list": F,
|
|
1780
|
+
"todo-list": P,
|
|
1781
|
+
quote: ne,
|
|
1743
1782
|
"code-block": d,
|
|
1744
1783
|
superscript: se,
|
|
1745
1784
|
subscript: oe,
|
|
1746
|
-
math:
|
|
1785
|
+
math: z,
|
|
1747
1786
|
"align-left": c,
|
|
1748
1787
|
"align-center": o,
|
|
1749
1788
|
"align-right": l,
|
|
1750
1789
|
"align-justify": s,
|
|
1751
|
-
"decrease-indent":
|
|
1752
|
-
"increase-indent":
|
|
1790
|
+
"decrease-indent": D,
|
|
1791
|
+
"increase-indent": O,
|
|
1753
1792
|
trash: ue
|
|
1754
1793
|
};
|
|
1755
1794
|
function $({ name: e }) {
|
|
1756
|
-
let t =
|
|
1795
|
+
let t = ri[e];
|
|
1757
1796
|
return /* @__PURE__ */ Z(t, {
|
|
1758
1797
|
"aria-hidden": "true",
|
|
1759
1798
|
absoluteStrokeWidth: !0,
|
|
@@ -1763,11 +1802,11 @@ function $({ name: e }) {
|
|
|
1763
1802
|
}
|
|
1764
1803
|
//#endregion
|
|
1765
1804
|
//#region src/ui/math/MathEditorPopover.tsx
|
|
1766
|
-
function
|
|
1767
|
-
let i = W(null), a = W(null), [o, s] = G(r.latex), [c, l] = G(null), u = t.math, d = U(() =>
|
|
1805
|
+
function ii({ editor: e, messages: t, onClose: n, target: r }) {
|
|
1806
|
+
let i = W(null), a = W(null), [o, s] = G(r.latex), [c, l] = G(null), u = t.math, d = U(() => yt(e, r) ?? 1, [e, r]), f = U(() => bt(e, r), [e, r]), m = U(() => o === r.latex && f ? {
|
|
1768
1807
|
html: f,
|
|
1769
1808
|
error: !1
|
|
1770
|
-
} :
|
|
1809
|
+
} : wt(o, r.kind, e), [
|
|
1771
1810
|
e,
|
|
1772
1811
|
f,
|
|
1773
1812
|
r.kind,
|
|
@@ -1775,12 +1814,12 @@ function $r({ editor: e, messages: t, onClose: n, target: r }) {
|
|
|
1775
1814
|
o
|
|
1776
1815
|
]), h = o.trim().length > 0, g = V(() => {
|
|
1777
1816
|
if (typeof window > "u") return;
|
|
1778
|
-
let t =
|
|
1817
|
+
let t = vt(e, r), i = e.view.dom.closest(".markweave-editor-frame")?.getBoundingClientRect();
|
|
1779
1818
|
if (!t || !i) {
|
|
1780
1819
|
n();
|
|
1781
1820
|
return;
|
|
1782
1821
|
}
|
|
1783
|
-
l(
|
|
1822
|
+
l(_t({
|
|
1784
1823
|
anchorRect: t,
|
|
1785
1824
|
frameRect: i,
|
|
1786
1825
|
kind: r.kind,
|
|
@@ -1797,12 +1836,12 @@ function $r({ editor: e, messages: t, onClose: n, target: r }) {
|
|
|
1797
1836
|
H(() => {
|
|
1798
1837
|
s(r.latex);
|
|
1799
1838
|
}, [r.latex, r.pos]), H(() => {
|
|
1800
|
-
|
|
1839
|
+
Tt(e, r, !0), g();
|
|
1801
1840
|
let t = window.requestAnimationFrame(() => {
|
|
1802
1841
|
a.current?.focus({ preventScroll: !0 }), a.current?.select(), g();
|
|
1803
1842
|
});
|
|
1804
1843
|
return window.addEventListener("resize", g), window.addEventListener("scroll", g, !0), () => {
|
|
1805
|
-
window.cancelAnimationFrame(t), window.removeEventListener("resize", g), window.removeEventListener("scroll", g, !0),
|
|
1844
|
+
window.cancelAnimationFrame(t), window.removeEventListener("resize", g), window.removeEventListener("scroll", g, !0), Tt(e, r, !1);
|
|
1806
1845
|
};
|
|
1807
1846
|
}, [
|
|
1808
1847
|
e,
|
|
@@ -1817,7 +1856,7 @@ function $r({ editor: e, messages: t, onClose: n, target: r }) {
|
|
|
1817
1856
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
1818
1857
|
}, [n]);
|
|
1819
1858
|
let _ = V(() => {
|
|
1820
|
-
h &&
|
|
1859
|
+
h && gt(e, r, o) && n();
|
|
1821
1860
|
}, [
|
|
1822
1861
|
h,
|
|
1823
1862
|
e,
|
|
@@ -1948,31 +1987,31 @@ function $r({ editor: e, messages: t, onClose: n, target: r }) {
|
|
|
1948
1987
|
}
|
|
1949
1988
|
//#endregion
|
|
1950
1989
|
//#region src/ui/slash-command/SlashCommandMenu.tsx
|
|
1951
|
-
var
|
|
1990
|
+
var ai = Ae("zh"), oi = {
|
|
1952
1991
|
type: le,
|
|
1953
|
-
"heading-1":
|
|
1954
|
-
"heading-2":
|
|
1955
|
-
"heading-3":
|
|
1956
|
-
"bullet-list":
|
|
1957
|
-
"ordered-list":
|
|
1958
|
-
"task-list":
|
|
1959
|
-
blockquote:
|
|
1992
|
+
"heading-1": ee,
|
|
1993
|
+
"heading-2": C,
|
|
1994
|
+
"heading-3": w,
|
|
1995
|
+
"bullet-list": N,
|
|
1996
|
+
"ordered-list": F,
|
|
1997
|
+
"task-list": P,
|
|
1998
|
+
blockquote: ne,
|
|
1960
1999
|
"code-block": d,
|
|
1961
|
-
info:
|
|
1962
|
-
tip:
|
|
2000
|
+
info: k,
|
|
2001
|
+
tip: j,
|
|
1963
2002
|
warning: a,
|
|
1964
2003
|
error: _,
|
|
1965
2004
|
success: m,
|
|
1966
2005
|
emoji: re,
|
|
1967
|
-
math:
|
|
2006
|
+
math: z,
|
|
1968
2007
|
table: ce,
|
|
1969
|
-
separator:
|
|
1970
|
-
image:
|
|
2008
|
+
separator: te,
|
|
2009
|
+
image: T,
|
|
1971
2010
|
video: B,
|
|
1972
|
-
attachment:
|
|
2011
|
+
attachment: L
|
|
1973
2012
|
};
|
|
1974
|
-
function
|
|
1975
|
-
let t =
|
|
2013
|
+
function si({ name: e }) {
|
|
2014
|
+
let t = oi[e];
|
|
1976
2015
|
return /* @__PURE__ */ Z(t, {
|
|
1977
2016
|
"aria-hidden": "true",
|
|
1978
2017
|
absoluteStrokeWidth: !0,
|
|
@@ -1980,8 +2019,8 @@ function ni({ name: e }) {
|
|
|
1980
2019
|
strokeWidth: 1.6
|
|
1981
2020
|
});
|
|
1982
2021
|
}
|
|
1983
|
-
function
|
|
1984
|
-
return !
|
|
2022
|
+
function ci(e, t, n) {
|
|
2023
|
+
return !jt(e) || !n ? {
|
|
1985
2024
|
visible: !1,
|
|
1986
2025
|
empty: !1,
|
|
1987
2026
|
activeIndex: -1
|
|
@@ -1995,16 +2034,16 @@ function ri(e, t, n) {
|
|
|
1995
2034
|
activeIndex: Math.min(t.length - 1, Math.max(0, e.activeIndex))
|
|
1996
2035
|
};
|
|
1997
2036
|
}
|
|
1998
|
-
function
|
|
2037
|
+
function li(e, t) {
|
|
1999
2038
|
return Object.values(t.slash.groups).map((t) => ({
|
|
2000
2039
|
group: t,
|
|
2001
2040
|
commands: e.filter((e) => e.group === t)
|
|
2002
2041
|
})).filter((e) => e.commands.length > 0);
|
|
2003
2042
|
}
|
|
2004
|
-
function
|
|
2043
|
+
function ui(e, t) {
|
|
2005
2044
|
return t.slash.uploadKindLabels[e] ?? t.slash.uploadKindLabels.upload;
|
|
2006
2045
|
}
|
|
2007
|
-
function
|
|
2046
|
+
function di({ command: e, messages: t, onBack: n, onSelect: r }) {
|
|
2008
2047
|
let [i, a] = G(""), [o, s] = G(0), c = U(() => {
|
|
2009
2048
|
let e = i.trim().toLowerCase();
|
|
2010
2049
|
return (e ? t.slash.emojiItems.filter((t) => [
|
|
@@ -2071,9 +2110,9 @@ function oi({ command: e, messages: t, onBack: n, onSelect: r }) {
|
|
|
2071
2110
|
]
|
|
2072
2111
|
});
|
|
2073
2112
|
}
|
|
2074
|
-
function
|
|
2113
|
+
function fi({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
|
|
2075
2114
|
let a = e.uploadKind ?? "attachment", [o, s] = G(""), [c, l] = G(null), [u, d] = G(null), [f, p] = G(!1), m = async (t) => {
|
|
2076
|
-
r(e, { uploadResult: await
|
|
2115
|
+
r(e, { uploadResult: await ve({
|
|
2077
2116
|
kind: a,
|
|
2078
2117
|
source: t,
|
|
2079
2118
|
trigger: "slash-command"
|
|
@@ -2111,7 +2150,7 @@ function si({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
|
|
|
2111
2150
|
onMouseDown: (e) => e.preventDefault(),
|
|
2112
2151
|
onClick: n,
|
|
2113
2152
|
children: t.common.back
|
|
2114
|
-
}), /* @__PURE__ */ Z("span", { children:
|
|
2153
|
+
}), /* @__PURE__ */ Z("span", { children: ui(a, t) })]
|
|
2115
2154
|
}),
|
|
2116
2155
|
/* @__PURE__ */ Q("label", {
|
|
2117
2156
|
className: "markweave-slash-upload-field",
|
|
@@ -2159,10 +2198,10 @@ function si({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
|
|
|
2159
2198
|
]
|
|
2160
2199
|
});
|
|
2161
2200
|
}
|
|
2162
|
-
function
|
|
2163
|
-
let l =
|
|
2201
|
+
function pi({ commands: e, messages: t = ai, state: n, position: r, inputCommand: i, onActiveIndexChange: a, onInputCommandChange: o, onSelect: s, onUpload: c }) {
|
|
2202
|
+
let l = ci(n, e, r);
|
|
2164
2203
|
if (!l.visible || !r) return null;
|
|
2165
|
-
let u =
|
|
2204
|
+
let u = li(e, t), d = {
|
|
2166
2205
|
left: r.left,
|
|
2167
2206
|
top: r.top,
|
|
2168
2207
|
maxHeight: r.maxHeight,
|
|
@@ -2184,12 +2223,12 @@ function ci({ commands: e, messages: t = ei, state: n, position: r, inputCommand
|
|
|
2184
2223
|
"aria-label": t.slash.ariaLabel,
|
|
2185
2224
|
"data-placement": r.placement,
|
|
2186
2225
|
"data-testid": "markweave-slash-menu",
|
|
2187
|
-
children: i?.inputKind === "emoji" ? /* @__PURE__ */ Z(
|
|
2226
|
+
children: i?.inputKind === "emoji" ? /* @__PURE__ */ Z(di, {
|
|
2188
2227
|
command: i,
|
|
2189
2228
|
messages: t,
|
|
2190
2229
|
onBack: m,
|
|
2191
2230
|
onSelect: s
|
|
2192
|
-
}) : i?.inputKind === "upload" ? /* @__PURE__ */ Z(
|
|
2231
|
+
}) : i?.inputKind === "upload" ? /* @__PURE__ */ Z(fi, {
|
|
2193
2232
|
command: i,
|
|
2194
2233
|
messages: t,
|
|
2195
2234
|
onBack: m,
|
|
@@ -2209,7 +2248,7 @@ function ci({ commands: e, messages: t = ei, state: n, position: r, inputCommand
|
|
|
2209
2248
|
className: "markweave-slash-group-title",
|
|
2210
2249
|
children: t.group
|
|
2211
2250
|
}), t.commands.map((t) => {
|
|
2212
|
-
let n = e.indexOf(t), r = n === l.activeIndex, i =
|
|
2251
|
+
let n = e.indexOf(t), r = n === l.activeIndex, i = kt(t), o = !!t.disabled;
|
|
2213
2252
|
return /* @__PURE__ */ Q("button", {
|
|
2214
2253
|
type: "button",
|
|
2215
2254
|
role: "option",
|
|
@@ -2233,7 +2272,7 @@ function ci({ commands: e, messages: t = ei, state: n, position: r, inputCommand
|
|
|
2233
2272
|
}
|
|
2234
2273
|
},
|
|
2235
2274
|
children: [
|
|
2236
|
-
/* @__PURE__ */ Z(
|
|
2275
|
+
/* @__PURE__ */ Z(si, { name: t.icon }),
|
|
2237
2276
|
/* @__PURE__ */ Z("span", { children: t.label }),
|
|
2238
2277
|
o && t.disabledReason ? /* @__PURE__ */ Z("small", { children: t.disabledReason }) : null
|
|
2239
2278
|
]
|
|
@@ -2245,14 +2284,14 @@ function ci({ commands: e, messages: t = ei, state: n, position: r, inputCommand
|
|
|
2245
2284
|
}
|
|
2246
2285
|
//#endregion
|
|
2247
2286
|
//#region src/ui/table/TableControls.tsx
|
|
2248
|
-
var
|
|
2249
|
-
function
|
|
2250
|
-
let [s, c] = G(null), [l, u] = G("row-edge"), [d, f] = G(null), [p, m] = G(null), [h, g] = G(null), [_, v] = G(null), [y, b] = G(null), x = W(null), S = W(null),
|
|
2287
|
+
var mi = Ae("zh");
|
|
2288
|
+
function hi({ active: e, editor: t, interactionState: n = Ht, messages: r = mi, onCopyPayload: i, onCommandResult: a, onEditWithAi: o }) {
|
|
2289
|
+
let [s, c] = G(null), [l, u] = G("row-edge"), [d, f] = G(null), [p, m] = G(null), [h, g] = G(null), [_, v] = G(null), [y, b] = G(null), x = W(null), S = W(null), ee = W(null), C = W(null), w = W(null), T = e ? Bt(t.state) : null;
|
|
2251
2290
|
if (H(() => {
|
|
2252
2291
|
if (!y) return;
|
|
2253
2292
|
let e = window.setTimeout(() => {
|
|
2254
2293
|
b(null);
|
|
2255
|
-
},
|
|
2294
|
+
}, Qn);
|
|
2256
2295
|
return () => {
|
|
2257
2296
|
window.clearTimeout(e);
|
|
2258
2297
|
};
|
|
@@ -2262,21 +2301,21 @@ function ui({ active: e, editor: t, interactionState: n = Rt, messages: r = li,
|
|
|
2262
2301
|
return;
|
|
2263
2302
|
}
|
|
2264
2303
|
let r = () => {
|
|
2265
|
-
let e = t.view.dom.closest(".markweave-editor-frame") ?? t.view.dom.parentElement, r =
|
|
2304
|
+
let e = t.view.dom.closest(".markweave-editor-frame") ?? t.view.dom.parentElement, r = Wn(t, n, "row", T?.activeCellPos ?? null), i = Wn(t, n, "column", T?.activeCellPos ?? null), a = r ? Un(t, r) : null, o = i ? Un(t, i) : null, c = Hn(t).length > 0 ? Yn(t) : null;
|
|
2266
2305
|
if (!e) {
|
|
2267
2306
|
m(null), g(null), v(null);
|
|
2268
2307
|
return;
|
|
2269
2308
|
}
|
|
2270
2309
|
let u = e.getBoundingClientRect();
|
|
2271
|
-
a ? m(
|
|
2310
|
+
a ? m(Ln({
|
|
2272
2311
|
targetRect: a,
|
|
2273
2312
|
frameRect: u,
|
|
2274
2313
|
kind: "row"
|
|
2275
|
-
})) : s === "row" && l === "row-edge" || m(null), o ? g(
|
|
2314
|
+
})) : s === "row" && l === "row-edge" || m(null), o ? g(Ln({
|
|
2276
2315
|
targetRect: o,
|
|
2277
2316
|
frameRect: u,
|
|
2278
2317
|
kind: "column"
|
|
2279
|
-
})) : s === "column" && l === "column-edge" || g(null), c ? v(
|
|
2318
|
+
})) : s === "column" && l === "column-edge" || g(null), c ? v(Ln({
|
|
2280
2319
|
targetRect: c,
|
|
2281
2320
|
frameRect: u,
|
|
2282
2321
|
kind: "selection"
|
|
@@ -2288,9 +2327,9 @@ function ui({ active: e, editor: t, interactionState: n = Rt, messages: r = li,
|
|
|
2288
2327
|
}, [
|
|
2289
2328
|
e,
|
|
2290
2329
|
t,
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2330
|
+
T?.activeCellPos,
|
|
2331
|
+
T?.selectionFrom,
|
|
2332
|
+
T?.selectionTo,
|
|
2294
2333
|
n.hoverCellPos,
|
|
2295
2334
|
n.hoverVisualColumnIndex,
|
|
2296
2335
|
n.hoverVisualRowIndex,
|
|
@@ -2302,17 +2341,17 @@ function ui({ active: e, editor: t, interactionState: n = Rt, messages: r = li,
|
|
|
2302
2341
|
return;
|
|
2303
2342
|
}
|
|
2304
2343
|
let n = () => {
|
|
2305
|
-
let e = t.view.dom.closest(".markweave-editor-frame") ?? t.view.dom.parentElement, n = l === "row-edge" ?
|
|
2344
|
+
let e = t.view.dom.closest(".markweave-editor-frame") ?? t.view.dom.parentElement, n = l === "row-edge" ? ee.current : l === "column-edge" ? C.current : w.current, r = S.current;
|
|
2306
2345
|
if (!e || !n || !r) {
|
|
2307
2346
|
f(null);
|
|
2308
2347
|
return;
|
|
2309
2348
|
}
|
|
2310
|
-
let i = n.getBoundingClientRect(), a = s === "row" ?
|
|
2349
|
+
let i = n.getBoundingClientRect(), a = s === "row" ? Vn(t)?.getBoundingClientRect() : null, o = a ? {
|
|
2311
2350
|
left: i.left,
|
|
2312
2351
|
top: a.top,
|
|
2313
2352
|
width: i.width,
|
|
2314
2353
|
height: i.height
|
|
2315
|
-
} : i, c = e.getBoundingClientRect(), u = r.getBoundingClientRect(), d =
|
|
2354
|
+
} : i, c = e.getBoundingClientRect(), u = r.getBoundingClientRect(), d = In({
|
|
2316
2355
|
anchorRect: o,
|
|
2317
2356
|
frameRect: c,
|
|
2318
2357
|
menuSize: {
|
|
@@ -2349,26 +2388,26 @@ function ui({ active: e, editor: t, interactionState: n = Rt, messages: r = li,
|
|
|
2349
2388
|
t,
|
|
2350
2389
|
s
|
|
2351
2390
|
]), !e) return null;
|
|
2352
|
-
let
|
|
2391
|
+
let E = (e, t) => {
|
|
2353
2392
|
let n = s === e && l === t;
|
|
2354
2393
|
u(t), c(n ? null : e);
|
|
2355
|
-
},
|
|
2356
|
-
t.view.dispatch(
|
|
2357
|
-
},
|
|
2358
|
-
let i = n.hoverCellPos ??
|
|
2359
|
-
i !== null &&
|
|
2360
|
-
},
|
|
2361
|
-
|
|
2362
|
-
},
|
|
2363
|
-
let o = await
|
|
2394
|
+
}, D = () => {
|
|
2395
|
+
t.view.dispatch(Fn(t.state.tr, null));
|
|
2396
|
+
}, O = (e, r) => {
|
|
2397
|
+
let i = n.hoverCellPos ?? T?.activeCellPos ?? null, a = n.hoverCellPos === null ? null : e === "row" ? n.hoverVisualRowIndex : n.hoverVisualColumnIndex;
|
|
2398
|
+
i !== null && Zn(t, i, e, { visualIndex: a }), E(e, r);
|
|
2399
|
+
}, k = () => {
|
|
2400
|
+
D(), E("selection", "selection-edge");
|
|
2401
|
+
}, A = Wn(t, n, "row", T?.activeCellPos ?? null), j = Wn(t, n, "column", T?.activeCellPos ?? null), M = Hn(t).length > 0, N = s ? Jn(t, s) : [], P = async (e, n) => {
|
|
2402
|
+
let o = await zn({
|
|
2364
2403
|
editor: t,
|
|
2365
2404
|
commandId: e,
|
|
2366
2405
|
menu: n ?? s ?? "selection",
|
|
2367
2406
|
messages: r
|
|
2368
2407
|
});
|
|
2369
2408
|
return o.copyFeedback ? (b(o.copyFeedback), o.copyPayload && i?.(o.copyPayload)) : b(null), a?.(o.commandResult), o.success;
|
|
2370
|
-
},
|
|
2371
|
-
let n =
|
|
2409
|
+
}, F = (e) => {
|
|
2410
|
+
let n = Gn(t, e);
|
|
2372
2411
|
n && o?.(n), c(null), t.view.focus();
|
|
2373
2412
|
};
|
|
2374
2413
|
return /* @__PURE__ */ Q("div", {
|
|
@@ -2387,28 +2426,28 @@ function ui({ active: e, editor: t, interactionState: n = Rt, messages: r = li,
|
|
|
2387
2426
|
"data-copy-kind": y.kind,
|
|
2388
2427
|
"data-text-length": y.textLength,
|
|
2389
2428
|
"data-html-length": y.htmlLength,
|
|
2390
|
-
children:
|
|
2429
|
+
children: Bn(y)
|
|
2391
2430
|
}) : null,
|
|
2392
2431
|
p ? /* @__PURE__ */ Z("button", {
|
|
2393
2432
|
type: "button",
|
|
2394
|
-
ref:
|
|
2433
|
+
ref: ee,
|
|
2395
2434
|
className: "markweave-table-edge-handle markweave-table-edge-handle--row",
|
|
2396
2435
|
"aria-label": r.table.activeRowActions,
|
|
2397
2436
|
"aria-expanded": s === "row" && l === "row-edge",
|
|
2398
2437
|
"aria-haspopup": "menu",
|
|
2399
2438
|
title: r.table.rowActions,
|
|
2400
2439
|
"data-testid": "markweave-table-hover-row-handle",
|
|
2401
|
-
"data-axis-index":
|
|
2402
|
-
"data-axis-selected-cells":
|
|
2403
|
-
"data-axis-visual-cells":
|
|
2404
|
-
"data-axis-visual-size":
|
|
2440
|
+
"data-axis-index": A?.index ?? "",
|
|
2441
|
+
"data-axis-selected-cells": A?.selectedCellCount ?? "",
|
|
2442
|
+
"data-axis-visual-cells": A?.visualCellCount ?? "",
|
|
2443
|
+
"data-axis-visual-size": A?.visualHeight ?? "",
|
|
2405
2444
|
style: {
|
|
2406
2445
|
left: p.left,
|
|
2407
2446
|
top: p.top
|
|
2408
2447
|
},
|
|
2409
2448
|
onMouseDown: (e) => e.preventDefault(),
|
|
2410
2449
|
onClick: () => {
|
|
2411
|
-
|
|
2450
|
+
O("row", "row-edge");
|
|
2412
2451
|
},
|
|
2413
2452
|
children: /* @__PURE__ */ Z("span", {
|
|
2414
2453
|
"aria-hidden": "true",
|
|
@@ -2417,33 +2456,33 @@ function ui({ active: e, editor: t, interactionState: n = Rt, messages: r = li,
|
|
|
2417
2456
|
}) : null,
|
|
2418
2457
|
h ? /* @__PURE__ */ Z("button", {
|
|
2419
2458
|
type: "button",
|
|
2420
|
-
ref:
|
|
2459
|
+
ref: C,
|
|
2421
2460
|
className: "markweave-table-edge-handle markweave-table-edge-handle--column",
|
|
2422
2461
|
"aria-label": r.table.activeColumnActions,
|
|
2423
2462
|
"aria-expanded": s === "column" && l === "column-edge",
|
|
2424
2463
|
"aria-haspopup": "menu",
|
|
2425
2464
|
title: r.table.columnActions,
|
|
2426
2465
|
"data-testid": "markweave-table-hover-column-handle",
|
|
2427
|
-
"data-axis-index":
|
|
2428
|
-
"data-axis-selected-cells":
|
|
2429
|
-
"data-axis-visual-cells":
|
|
2430
|
-
"data-axis-visual-size":
|
|
2466
|
+
"data-axis-index": j?.index ?? "",
|
|
2467
|
+
"data-axis-selected-cells": j?.selectedCellCount ?? "",
|
|
2468
|
+
"data-axis-visual-cells": j?.visualCellCount ?? "",
|
|
2469
|
+
"data-axis-visual-size": j?.visualWidth ?? "",
|
|
2431
2470
|
style: {
|
|
2432
2471
|
left: h.left,
|
|
2433
2472
|
top: h.top
|
|
2434
2473
|
},
|
|
2435
2474
|
onMouseDown: (e) => e.preventDefault(),
|
|
2436
2475
|
onClick: () => {
|
|
2437
|
-
|
|
2476
|
+
O("column", "column-edge");
|
|
2438
2477
|
},
|
|
2439
2478
|
children: /* @__PURE__ */ Z("span", {
|
|
2440
2479
|
"aria-hidden": "true",
|
|
2441
2480
|
children: "..."
|
|
2442
2481
|
})
|
|
2443
2482
|
}) : null,
|
|
2444
|
-
|
|
2483
|
+
M && _ ? /* @__PURE__ */ Z("button", {
|
|
2445
2484
|
type: "button",
|
|
2446
|
-
ref:
|
|
2485
|
+
ref: w,
|
|
2447
2486
|
className: "markweave-table-edge-handle markweave-table-edge-handle--selection",
|
|
2448
2487
|
"aria-label": r.table.selectionActions,
|
|
2449
2488
|
"aria-expanded": s === "selection" && l === "selection-edge",
|
|
@@ -2455,7 +2494,7 @@ function ui({ active: e, editor: t, interactionState: n = Rt, messages: r = li,
|
|
|
2455
2494
|
top: _.top
|
|
2456
2495
|
},
|
|
2457
2496
|
onMouseDown: (e) => e.preventDefault(),
|
|
2458
|
-
onClick:
|
|
2497
|
+
onClick: k,
|
|
2459
2498
|
children: /* @__PURE__ */ Z("span", {
|
|
2460
2499
|
"aria-hidden": "true",
|
|
2461
2500
|
children: "..."
|
|
@@ -2465,15 +2504,15 @@ function ui({ active: e, editor: t, interactionState: n = Rt, messages: r = li,
|
|
|
2465
2504
|
ref: S,
|
|
2466
2505
|
className: "markweave-table-menu",
|
|
2467
2506
|
role: "menu",
|
|
2468
|
-
"aria-label":
|
|
2507
|
+
"aria-label": $n(s, r),
|
|
2469
2508
|
"data-testid": "markweave-table-menu",
|
|
2470
2509
|
"data-positioned": d ? "true" : "false",
|
|
2471
2510
|
style: d ? {
|
|
2472
2511
|
left: d.left,
|
|
2473
2512
|
top: d.top
|
|
2474
2513
|
} : void 0,
|
|
2475
|
-
children:
|
|
2476
|
-
let i =
|
|
2514
|
+
children: N.map((e, n) => {
|
|
2515
|
+
let i = Kn(e), a = n === 0 ? i : Kn(N[n - 1]), l = n > 0 && a !== i, u = e.commandId === null ? !!o : Rn(t, e.commandId), d = qn(e, r);
|
|
2477
2516
|
return /* @__PURE__ */ Z("button", {
|
|
2478
2517
|
type: "button",
|
|
2479
2518
|
role: "menuitem",
|
|
@@ -2488,10 +2527,10 @@ function ui({ active: e, editor: t, interactionState: n = Rt, messages: r = li,
|
|
|
2488
2527
|
onClick: () => {
|
|
2489
2528
|
if (u) {
|
|
2490
2529
|
if (e.commandId === null) {
|
|
2491
|
-
|
|
2530
|
+
F(s === "row" || s === "column" ? s : "selection");
|
|
2492
2531
|
return;
|
|
2493
2532
|
}
|
|
2494
|
-
|
|
2533
|
+
P(e.commandId).finally(() => c(null));
|
|
2495
2534
|
}
|
|
2496
2535
|
},
|
|
2497
2536
|
children: d
|
|
@@ -2503,7 +2542,7 @@ function ui({ active: e, editor: t, interactionState: n = Rt, messages: r = li,
|
|
|
2503
2542
|
}
|
|
2504
2543
|
//#endregion
|
|
2505
2544
|
//#region src/ui/table/TableSelectionOverlay.tsx
|
|
2506
|
-
function
|
|
2545
|
+
function gi({ editor: e, focusState: t }) {
|
|
2507
2546
|
let [n, r] = G(null);
|
|
2508
2547
|
return me(() => {
|
|
2509
2548
|
if (t.mode !== "cell-selection") {
|
|
@@ -2511,7 +2550,7 @@ function di({ editor: e, focusState: t }) {
|
|
|
2511
2550
|
return;
|
|
2512
2551
|
}
|
|
2513
2552
|
let n = () => {
|
|
2514
|
-
r(
|
|
2553
|
+
r(Xn(e, Vt(e.state)));
|
|
2515
2554
|
};
|
|
2516
2555
|
return n(), window.addEventListener("resize", n), window.addEventListener("scroll", n, !0), () => {
|
|
2517
2556
|
window.removeEventListener("resize", n), window.removeEventListener("scroll", n, !0);
|
|
@@ -2546,16 +2585,16 @@ function di({ editor: e, focusState: t }) {
|
|
|
2546
2585
|
}
|
|
2547
2586
|
//#endregion
|
|
2548
2587
|
//#region src/ui/toc/MarkweaveInnerToc.tsx
|
|
2549
|
-
function
|
|
2588
|
+
function _i(e, t) {
|
|
2550
2589
|
return `${e.toc.itemAriaLabel}: ${t.text}`;
|
|
2551
2590
|
}
|
|
2552
|
-
function
|
|
2591
|
+
function vi({ editor: e, state: t, messages: n, editable: r, placement: i }) {
|
|
2553
2592
|
let a = W(null);
|
|
2554
2593
|
if (H(() => {
|
|
2555
|
-
if (!(i !== "container" || !a.current)) return
|
|
2594
|
+
if (!(i !== "container" || !a.current)) return or(a.current);
|
|
2556
2595
|
}, [i]), !t.items.length) return null;
|
|
2557
2596
|
let o = (t) => {
|
|
2558
|
-
|
|
2597
|
+
sr(e, t, {
|
|
2559
2598
|
behavior: "smooth",
|
|
2560
2599
|
focus: r
|
|
2561
2600
|
});
|
|
@@ -2582,7 +2621,7 @@ function pi({ editor: e, state: t, messages: n, editable: r, placement: i }) {
|
|
|
2582
2621
|
"data-level": e.level,
|
|
2583
2622
|
"data-active": e.active ? "true" : "false",
|
|
2584
2623
|
"aria-current": e.active ? "location" : void 0,
|
|
2585
|
-
"aria-label":
|
|
2624
|
+
"aria-label": _i(n, e),
|
|
2586
2625
|
title: e.text,
|
|
2587
2626
|
onClick: () => o(e),
|
|
2588
2627
|
children: e.text
|
|
@@ -2593,7 +2632,7 @@ function pi({ editor: e, state: t, messages: n, editable: r, placement: i }) {
|
|
|
2593
2632
|
}
|
|
2594
2633
|
//#endregion
|
|
2595
2634
|
//#region src/MarkweaveEditor.tsx
|
|
2596
|
-
var
|
|
2635
|
+
var yi = {
|
|
2597
2636
|
active: !1,
|
|
2598
2637
|
mode: "outside",
|
|
2599
2638
|
activeCellPos: null,
|
|
@@ -2601,21 +2640,21 @@ var mi = {
|
|
|
2601
2640
|
selectedCellCount: 0,
|
|
2602
2641
|
selectionFrom: 0,
|
|
2603
2642
|
selectionTo: 0
|
|
2604
|
-
},
|
|
2643
|
+
}, bi = {
|
|
2605
2644
|
active: !1,
|
|
2606
|
-
language:
|
|
2645
|
+
language: ct.defaultLanguage,
|
|
2607
2646
|
mermaidPreviewMode: "code",
|
|
2608
2647
|
pos: null,
|
|
2609
2648
|
text: ""
|
|
2610
|
-
},
|
|
2649
|
+
}, xi = ht({
|
|
2611
2650
|
active: !1,
|
|
2612
2651
|
mode: "code",
|
|
2613
2652
|
source: ""
|
|
2614
2653
|
});
|
|
2615
|
-
function
|
|
2616
|
-
return
|
|
2654
|
+
function Si(e) {
|
|
2655
|
+
return Ut.getState(e.state) ?? Ht;
|
|
2617
2656
|
}
|
|
2618
|
-
function
|
|
2657
|
+
function Ci(e) {
|
|
2619
2658
|
if (!e || typeof window > "u") return null;
|
|
2620
2659
|
let t = e.parentElement;
|
|
2621
2660
|
for (; t;) {
|
|
@@ -2625,71 +2664,88 @@ function vi(e) {
|
|
|
2625
2664
|
}
|
|
2626
2665
|
return null;
|
|
2627
2666
|
}
|
|
2628
|
-
function
|
|
2667
|
+
function wi(e) {
|
|
2629
2668
|
return typeof window > "u" || typeof window.requestAnimationFrame != "function" ? globalThis.setTimeout(() => e(0), 0) : window.requestAnimationFrame(e);
|
|
2630
2669
|
}
|
|
2631
|
-
function
|
|
2670
|
+
function Ti(e) {
|
|
2632
2671
|
if (typeof window < "u" && typeof window.cancelAnimationFrame == "function") {
|
|
2633
2672
|
window.cancelAnimationFrame(e);
|
|
2634
2673
|
return;
|
|
2635
2674
|
}
|
|
2636
2675
|
globalThis.clearTimeout(e);
|
|
2637
2676
|
}
|
|
2638
|
-
function
|
|
2639
|
-
let S = Pe(f),
|
|
2677
|
+
function Ei({ ariaLabel: e, autoFocusFirstTableBodyCell: t = !1, autofocus: n = !1, content: r, contentFormat: a, defaultContent: o = "", defaultContentFormat: s, editable: c = !0, innerToc: l = !0, innerTocPlacement: u, lang: d, mode: f = "live", onEditWithAi: p, onExtractToNote: m, onRewriteSelection: h, onRuntimeStateChange: g, onSlashCommandUpload: _, onTableCommandResult: v, onTableCopyPayload: y, onTocChange: b, onUpdate: x } = {}) {
|
|
2678
|
+
let S = Pe(f), ee = ar(u), C = S === "live" && c !== !1, w = We(r === void 0 ? s : a), T = W({
|
|
2640
2679
|
editorMode: S,
|
|
2641
|
-
effectiveEditable:
|
|
2680
|
+
effectiveEditable: C
|
|
2642
2681
|
});
|
|
2643
|
-
|
|
2682
|
+
T.current = {
|
|
2644
2683
|
editorMode: S,
|
|
2645
|
-
effectiveEditable:
|
|
2684
|
+
effectiveEditable: C
|
|
2646
2685
|
};
|
|
2647
|
-
let
|
|
2648
|
-
|
|
2649
|
-
let
|
|
2650
|
-
|
|
2651
|
-
let
|
|
2652
|
-
lang:
|
|
2686
|
+
let E = W(null);
|
|
2687
|
+
E.current === null && (E.current = je(d));
|
|
2688
|
+
let D = E.current, O = U(() => Ae(D), [D]), k = U(() => ke(D), [D]), A = W(_);
|
|
2689
|
+
A.current = _;
|
|
2690
|
+
let j = U(() => Sr({
|
|
2691
|
+
lang: D,
|
|
2653
2692
|
onImageUpload: (e) => {
|
|
2654
|
-
if (
|
|
2693
|
+
if (A.current) return A.current(e);
|
|
2655
2694
|
let t = _e(e);
|
|
2656
2695
|
if (!t) throw Error("File upload requires an upload handler.");
|
|
2657
2696
|
return t;
|
|
2658
2697
|
},
|
|
2659
2698
|
onVideoUpload: (e) => {
|
|
2660
|
-
if (
|
|
2699
|
+
if (A.current) return A.current(e);
|
|
2661
2700
|
let t = _e(e);
|
|
2662
2701
|
if (!t) throw Error("File upload requires an upload handler.");
|
|
2663
2702
|
return t;
|
|
2664
2703
|
}
|
|
2665
|
-
}), [
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
},
|
|
2670
|
-
|
|
2704
|
+
}), [D]), [M, N] = G(null), [P, F] = G(It), [te, I] = G(null), [L, ne] = G(null), [R, z] = G("code"), [re, ie] = G(null), [ae, oe] = G(Ht), [se, ce] = G(null), [le, ue] = G(0), de = W(!1), fe = W({
|
|
2705
|
+
content: r,
|
|
2706
|
+
format: w
|
|
2707
|
+
}), pe = W(null), B = W(null), me = W({ onUpdate: x }), he = U(() => Ot(P.query, k), [k, P.query]);
|
|
2708
|
+
me.current = { onUpdate: x }, fe.current = {
|
|
2709
|
+
content: r,
|
|
2710
|
+
format: w
|
|
2711
|
+
};
|
|
2712
|
+
let ge = V(() => {
|
|
2713
|
+
B.current !== null && (window.clearTimeout(B.current), B.current = null), ue((e) => e + 1);
|
|
2714
|
+
}, []), ve = V(() => {
|
|
2715
|
+
B.current !== null && window.clearTimeout(B.current), B.current = window.setTimeout(() => {
|
|
2716
|
+
B.current = null, ue((e) => e + 1);
|
|
2717
|
+
}, tt);
|
|
2718
|
+
}, []);
|
|
2719
|
+
H(() => () => {
|
|
2720
|
+
B.current !== null && window.clearTimeout(B.current);
|
|
2721
|
+
}, []);
|
|
2722
|
+
let K = V(() => {
|
|
2723
|
+
I(null), ne(null), F(It);
|
|
2724
|
+
}, []), ye = V((e) => {
|
|
2725
|
+
let t = Ft(e.state);
|
|
2671
2726
|
if (!t) {
|
|
2672
|
-
|
|
2727
|
+
F((e) => e.name === "idle" ? e : It), I(null), ne(null);
|
|
2673
2728
|
return;
|
|
2674
2729
|
}
|
|
2675
2730
|
let n = e.coordsAtPos(t.cursor), r = e.coordsAtPos(t.triggerFrom), i = e.dom.closest(".markweave-editor-frame")?.getBoundingClientRect();
|
|
2676
|
-
|
|
2731
|
+
I(Pt(n, {
|
|
2677
2732
|
frameRect: i,
|
|
2678
2733
|
triggerRect: r
|
|
2679
|
-
})),
|
|
2680
|
-
}, []),
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2734
|
+
})), F((e) => Nt(e, t));
|
|
2735
|
+
}, []), be = V((e) => ye(e.view), [ye]), xe = V((e) => {
|
|
2736
|
+
let t = Qe(e);
|
|
2737
|
+
N((e) => Je(e, t) ? e : t);
|
|
2738
|
+
let n = Ct(e);
|
|
2739
|
+
n && (Tt(e, n, !0), ie(n));
|
|
2740
|
+
let r = ot(e);
|
|
2741
|
+
r.active && r.language === "mermaid" && z(r.mermaidPreviewMode);
|
|
2742
|
+
}, []), Se = V((e) => {
|
|
2743
|
+
oe(Si(e));
|
|
2688
2744
|
}, []), q = i({
|
|
2689
|
-
extensions:
|
|
2745
|
+
extensions: j,
|
|
2690
2746
|
content: r ?? o,
|
|
2691
|
-
contentType: Ve(
|
|
2692
|
-
editable:
|
|
2747
|
+
contentType: Ve(w),
|
|
2748
|
+
editable: C,
|
|
2693
2749
|
autofocus: n,
|
|
2694
2750
|
editorProps: {
|
|
2695
2751
|
attributes: {
|
|
@@ -2700,289 +2756,306 @@ function xi({ ariaLabel: e, autoFocusFirstTableBodyCell: t = !1, autofocus: n =
|
|
|
2700
2756
|
spellcheck: "false",
|
|
2701
2757
|
translate: "no"
|
|
2702
2758
|
},
|
|
2703
|
-
handleClick: (e, t, n) =>
|
|
2759
|
+
handleClick: (e, t, n) => T.current.effectiveEditable ? !1 : Ge(n),
|
|
2704
2760
|
handleDOMEvents: {
|
|
2705
|
-
compositionstart: () =>
|
|
2706
|
-
compositionend: (e) => (
|
|
2761
|
+
compositionstart: () => T.current.effectiveEditable ? (F((e) => Lt(e, { type: "composition-start" })), I(null), !1) : !1,
|
|
2762
|
+
compositionend: (e) => (T.current.effectiveEditable && window.setTimeout(() => ye(e), 0), !1),
|
|
2707
2763
|
click: (e, t) => {
|
|
2708
|
-
if (
|
|
2709
|
-
let n =
|
|
2710
|
-
return n ? (t.preventDefault(), t.stopPropagation(),
|
|
2764
|
+
if (T.current.effectiveEditable) {
|
|
2765
|
+
let n = St(e, t);
|
|
2766
|
+
return n ? (t.preventDefault(), t.stopPropagation(), K(), Et(e, n, !0), Dt(e, n), ie(n), !0) : (ie(null), !1);
|
|
2711
2767
|
}
|
|
2712
|
-
return
|
|
2768
|
+
return Ge(t);
|
|
2713
2769
|
}
|
|
2714
2770
|
}
|
|
2715
2771
|
},
|
|
2716
2772
|
onSelectionUpdate: ({ editor: e }) => {
|
|
2717
|
-
|
|
2773
|
+
xe(e);
|
|
2718
2774
|
},
|
|
2719
2775
|
onCreate: ({ editor: e }) => {
|
|
2720
|
-
t &&
|
|
2776
|
+
t && T.current.effectiveEditable && zt(e), Se(e), xe(e), ge();
|
|
2721
2777
|
},
|
|
2722
2778
|
onTransaction: ({ editor: e, transaction: t }) => {
|
|
2723
|
-
|
|
2779
|
+
Se(e), (t.docChanged || ft(t)) && ve(), t.docChanged && ie((t) => {
|
|
2724
2780
|
if (!t) return null;
|
|
2725
|
-
let n =
|
|
2781
|
+
let n = xt(e, t.pos);
|
|
2726
2782
|
return n?.kind === t.kind ? n : null;
|
|
2727
2783
|
});
|
|
2728
2784
|
},
|
|
2729
2785
|
onUpdate: ({ editor: e }) => {
|
|
2730
|
-
|
|
2786
|
+
xe(e), T.current.effectiveEditable && be(e), de.current || me.current.onUpdate?.(Be(e, { onContentRead: (t, n) => {
|
|
2787
|
+
let r = fe.current;
|
|
2788
|
+
r.content !== void 0 && t === r.format && (pe.current = {
|
|
2789
|
+
content: n,
|
|
2790
|
+
format: t,
|
|
2791
|
+
doc: e.state.doc
|
|
2792
|
+
});
|
|
2793
|
+
} }));
|
|
2731
2794
|
}
|
|
2732
2795
|
});
|
|
2733
2796
|
H(() => {
|
|
2734
|
-
q && (q.setEditable(
|
|
2797
|
+
q && (q.setEditable(C), Fe(q, {
|
|
2735
2798
|
mode: S,
|
|
2736
|
-
editable:
|
|
2737
|
-
}),
|
|
2799
|
+
editable: C
|
|
2800
|
+
}), pt(q, C ? "live" : "view"), ge(), C || K());
|
|
2738
2801
|
}, [
|
|
2739
|
-
|
|
2802
|
+
K,
|
|
2740
2803
|
q,
|
|
2741
2804
|
S,
|
|
2742
|
-
|
|
2805
|
+
C,
|
|
2806
|
+
ge
|
|
2743
2807
|
]), H(() => {
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2808
|
+
let e = We(a);
|
|
2809
|
+
if (!(!q || r === void 0)) {
|
|
2810
|
+
if (Ue(q, pe.current, r, e)) {
|
|
2811
|
+
pe.current = null;
|
|
2812
|
+
return;
|
|
2813
|
+
}
|
|
2814
|
+
pe.current = null, !He(q, r, e) && (de.current = !0, q.commands.setContent(r, {
|
|
2815
|
+
contentType: Ve(e),
|
|
2816
|
+
emitUpdate: !1
|
|
2817
|
+
}), de.current = !1, xe(q), C && be(q), Se(q), ge());
|
|
2818
|
+
}
|
|
2748
2819
|
}, [
|
|
2749
2820
|
r,
|
|
2750
2821
|
a,
|
|
2751
|
-
|
|
2822
|
+
C,
|
|
2752
2823
|
q,
|
|
2753
2824
|
ge,
|
|
2754
|
-
|
|
2755
|
-
|
|
2825
|
+
xe,
|
|
2826
|
+
be,
|
|
2827
|
+
Se
|
|
2756
2828
|
]), H(() => {
|
|
2757
|
-
if (!
|
|
2829
|
+
if (!te) return;
|
|
2758
2830
|
let e = (e) => {
|
|
2759
2831
|
let t = e.target;
|
|
2760
|
-
t instanceof Element && (t.closest(".markweave-slash-menu") || t.closest(".markweave-slash-trigger") ||
|
|
2832
|
+
t instanceof Element && (t.closest(".markweave-slash-menu") || t.closest(".markweave-slash-trigger") || K());
|
|
2761
2833
|
};
|
|
2762
2834
|
return document.addEventListener("pointerdown", e, !0), () => document.removeEventListener("pointerdown", e, !0);
|
|
2763
|
-
}, [
|
|
2764
|
-
let
|
|
2835
|
+
}, [K, te]);
|
|
2836
|
+
let Ce = U(() => q ? ot(q) : bi, [
|
|
2765
2837
|
q,
|
|
2766
2838
|
le,
|
|
2767
|
-
|
|
2768
|
-
]),
|
|
2839
|
+
M
|
|
2840
|
+
]), we = U(() => q ? Bt(q.state) : yi, [
|
|
2769
2841
|
q,
|
|
2770
2842
|
le,
|
|
2771
|
-
|
|
2843
|
+
M,
|
|
2772
2844
|
ae
|
|
2773
|
-
]),
|
|
2774
|
-
active:
|
|
2775
|
-
mode:
|
|
2776
|
-
source:
|
|
2777
|
-
}) :
|
|
2778
|
-
|
|
2845
|
+
]), Te = M?.currentNode === "codeBlock", Ee = Te && Ce.language === "mermaid", De = U(() => q ? ht({
|
|
2846
|
+
active: Ee,
|
|
2847
|
+
mode: R,
|
|
2848
|
+
source: Ce.text
|
|
2849
|
+
}) : xi, [
|
|
2850
|
+
Ce.text,
|
|
2779
2851
|
q,
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
]),
|
|
2852
|
+
Ee,
|
|
2853
|
+
R
|
|
2854
|
+
]), Oe = U(() => q ? Rt(q.state) : null, [q, le]), J = U(() => q ? rr(q.state.doc) : tr.items, [q, le]), Y = U(() => ir(J, se), [se, J]), Me = U(() => er(J, Y), [Y, J]), Ne = V(() => {
|
|
2783
2855
|
if (!q || !J.length) {
|
|
2784
2856
|
ce(null);
|
|
2785
2857
|
return;
|
|
2786
2858
|
}
|
|
2787
|
-
let e =
|
|
2859
|
+
let e = nr(q, J);
|
|
2788
2860
|
ce((t) => t === e ? t : e);
|
|
2789
2861
|
}, [q, J]);
|
|
2790
2862
|
H(() => {
|
|
2791
2863
|
ce((e) => {
|
|
2792
|
-
let t =
|
|
2864
|
+
let t = ir(J, e);
|
|
2793
2865
|
return e === t ? e : t;
|
|
2794
2866
|
});
|
|
2795
2867
|
}, [J]), H(() => {
|
|
2796
2868
|
if (!q || !J.length || typeof window > "u") return;
|
|
2797
2869
|
let e = null, t = () => {
|
|
2798
|
-
e !== null &&
|
|
2799
|
-
e = null,
|
|
2870
|
+
e !== null && Ti(e), e = wi(() => {
|
|
2871
|
+
e = null, Ne();
|
|
2800
2872
|
});
|
|
2801
|
-
}, n =
|
|
2873
|
+
}, n = Ci(q.view.dom);
|
|
2802
2874
|
return window.addEventListener("scroll", t, { passive: !0 }), window.addEventListener("resize", t), n?.addEventListener("scroll", t, { passive: !0 }), t(), () => {
|
|
2803
|
-
window.removeEventListener("scroll", t), window.removeEventListener("resize", t), n?.removeEventListener("scroll", t), e !== null &&
|
|
2875
|
+
window.removeEventListener("scroll", t), window.removeEventListener("resize", t), n?.removeEventListener("scroll", t), e !== null && Ti(e);
|
|
2804
2876
|
};
|
|
2805
2877
|
}, [
|
|
2806
2878
|
q,
|
|
2807
2879
|
J.length,
|
|
2808
|
-
|
|
2880
|
+
Ne
|
|
2809
2881
|
]);
|
|
2810
|
-
let
|
|
2882
|
+
let Ie = U(() => Ke({
|
|
2811
2883
|
revision: le,
|
|
2812
2884
|
mode: S,
|
|
2813
|
-
editable:
|
|
2814
|
-
toc:
|
|
2815
|
-
selection:
|
|
2816
|
-
slash:
|
|
2817
|
-
table:
|
|
2885
|
+
editable: C,
|
|
2886
|
+
toc: Me,
|
|
2887
|
+
selection: M,
|
|
2888
|
+
slash: P,
|
|
2889
|
+
table: we,
|
|
2818
2890
|
tableInteraction: ae,
|
|
2819
|
-
codeBlock:
|
|
2820
|
-
mermaid:
|
|
2821
|
-
tableDebugSnapshot:
|
|
2891
|
+
codeBlock: Ce,
|
|
2892
|
+
mermaid: De,
|
|
2893
|
+
tableDebugSnapshot: Oe
|
|
2822
2894
|
}), [
|
|
2823
|
-
|
|
2895
|
+
Ce,
|
|
2824
2896
|
S,
|
|
2825
|
-
|
|
2826
|
-
|
|
2897
|
+
C,
|
|
2898
|
+
De,
|
|
2827
2899
|
le,
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2900
|
+
M,
|
|
2901
|
+
P,
|
|
2902
|
+
Oe,
|
|
2903
|
+
we,
|
|
2832
2904
|
ae,
|
|
2833
|
-
|
|
2905
|
+
Me
|
|
2834
2906
|
]);
|
|
2835
2907
|
H(() => {
|
|
2836
|
-
g?.(
|
|
2837
|
-
}, [g,
|
|
2838
|
-
b?.(
|
|
2839
|
-
}, [b,
|
|
2840
|
-
let
|
|
2841
|
-
if (!(!q || !
|
|
2908
|
+
g?.(Ie);
|
|
2909
|
+
}, [g, Ie]), H(() => {
|
|
2910
|
+
b?.(Me);
|
|
2911
|
+
}, [b, Me]);
|
|
2912
|
+
let Le = V((e, t) => {
|
|
2913
|
+
if (!(!q || !C) && kt(e)) {
|
|
2842
2914
|
if (e.inputKind && !t?.emoji && !t?.uploadResult) {
|
|
2843
|
-
|
|
2915
|
+
ne(e);
|
|
2844
2916
|
return;
|
|
2845
2917
|
}
|
|
2846
|
-
|
|
2918
|
+
Mt(q, P, e, t), F((e) => Lt(e, { type: "execute" })), K();
|
|
2847
2919
|
}
|
|
2848
2920
|
}, [
|
|
2849
|
-
|
|
2850
|
-
|
|
2921
|
+
K,
|
|
2922
|
+
C,
|
|
2851
2923
|
q,
|
|
2852
|
-
|
|
2853
|
-
]),
|
|
2854
|
-
|
|
2924
|
+
P
|
|
2925
|
+
]), X = V((e) => {
|
|
2926
|
+
F((t) => Lt(t, {
|
|
2855
2927
|
type: "set-active",
|
|
2856
2928
|
index: e,
|
|
2857
|
-
optionCount:
|
|
2929
|
+
optionCount: he.length
|
|
2858
2930
|
}));
|
|
2859
|
-
}, [
|
|
2860
|
-
if (!q ||
|
|
2861
|
-
let t =
|
|
2931
|
+
}, [he.length]), Z = V((e) => {
|
|
2932
|
+
if (!q || L || !C) return;
|
|
2933
|
+
let t = At(P, he, e.key, { isComposing: e.nativeEvent.isComposing || ze(q.state) });
|
|
2862
2934
|
if (t.type !== "ignore") {
|
|
2863
2935
|
if (t.type === "close") {
|
|
2864
|
-
e.preventDefault(),
|
|
2936
|
+
e.preventDefault(), F((e) => Lt(e, { type: "escape" })), K();
|
|
2865
2937
|
return;
|
|
2866
2938
|
}
|
|
2867
2939
|
if (t.type === "move-active") {
|
|
2868
|
-
e.preventDefault(),
|
|
2940
|
+
e.preventDefault(), F((e) => Lt(e, {
|
|
2869
2941
|
type: "move-active",
|
|
2870
2942
|
delta: t.delta,
|
|
2871
2943
|
optionCount: t.optionCount
|
|
2872
2944
|
}));
|
|
2873
2945
|
return;
|
|
2874
2946
|
}
|
|
2875
|
-
t.type === "execute-active" && (e.preventDefault(),
|
|
2947
|
+
t.type === "execute-active" && (e.preventDefault(), Le(t.command));
|
|
2876
2948
|
}
|
|
2877
2949
|
}, [
|
|
2878
|
-
|
|
2879
|
-
|
|
2950
|
+
K,
|
|
2951
|
+
C,
|
|
2880
2952
|
q,
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
]),
|
|
2886
|
-
closeSlashMenu:
|
|
2887
|
-
focusFirstTableBodyCell: () => q ?
|
|
2953
|
+
he,
|
|
2954
|
+
Le,
|
|
2955
|
+
L,
|
|
2956
|
+
P
|
|
2957
|
+
]), Q = U(() => ({
|
|
2958
|
+
closeSlashMenu: K,
|
|
2959
|
+
focusFirstTableBodyCell: () => q ? zt(q) : !1,
|
|
2888
2960
|
setContent: (e, t = {}) => {
|
|
2889
2961
|
if (!q) return !1;
|
|
2890
|
-
let n =
|
|
2962
|
+
let n = We(t.format);
|
|
2891
2963
|
return q.commands.setContent(e, {
|
|
2892
2964
|
contentType: Ve(n),
|
|
2893
2965
|
emitUpdate: t.emitUpdate ?? !1
|
|
2894
|
-
}), t.focusFirstTableBodyCell &&
|
|
2966
|
+
}), t.focusFirstTableBodyCell && zt(q), xe(q), C && be(q), Se(q), ge(), !0;
|
|
2895
2967
|
}
|
|
2896
2968
|
}), [
|
|
2897
|
-
|
|
2898
|
-
|
|
2969
|
+
K,
|
|
2970
|
+
C,
|
|
2899
2971
|
q,
|
|
2900
2972
|
ge,
|
|
2901
|
-
|
|
2902
|
-
|
|
2973
|
+
xe,
|
|
2974
|
+
be,
|
|
2975
|
+
Se
|
|
2903
2976
|
]);
|
|
2904
2977
|
return {
|
|
2905
2978
|
editor: q,
|
|
2906
2979
|
frameProps: U(() => ({
|
|
2907
2980
|
className: "markweave-editor-frame",
|
|
2908
|
-
"aria-label": e ??
|
|
2981
|
+
"aria-label": e ?? O.common.editorAriaLabel,
|
|
2909
2982
|
"data-testid": "markweave-editor-frame",
|
|
2910
2983
|
"data-markweave-mode": S,
|
|
2911
2984
|
"data-markweave-inner-toc": l ? "true" : "false",
|
|
2912
|
-
"data-markweave-inner-toc-placement":
|
|
2913
|
-
"data-mermaid-mode":
|
|
2914
|
-
"data-table-focus-mode":
|
|
2915
|
-
onKeyDownCapture:
|
|
2985
|
+
"data-markweave-inner-toc-placement": ee,
|
|
2986
|
+
"data-mermaid-mode": De.mode,
|
|
2987
|
+
"data-table-focus-mode": we.mode,
|
|
2988
|
+
onKeyDownCapture: Z
|
|
2916
2989
|
}), [
|
|
2917
2990
|
e,
|
|
2918
2991
|
S,
|
|
2919
|
-
|
|
2992
|
+
Z,
|
|
2920
2993
|
l,
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2994
|
+
De.mode,
|
|
2995
|
+
O.common.editorAriaLabel,
|
|
2996
|
+
ee,
|
|
2997
|
+
we.mode
|
|
2925
2998
|
]),
|
|
2926
2999
|
overlayProps: U(() => ({
|
|
2927
|
-
floatingToolbar: q &&
|
|
3000
|
+
floatingToolbar: q && C ? {
|
|
2928
3001
|
editor: q,
|
|
2929
|
-
messages:
|
|
2930
|
-
selectionSnapshot:
|
|
3002
|
+
messages: O,
|
|
3003
|
+
selectionSnapshot: M,
|
|
2931
3004
|
onRewriteSelection: h,
|
|
2932
3005
|
onExtractToNote: m
|
|
2933
3006
|
} : null,
|
|
2934
|
-
slashCommandMenu: q &&
|
|
2935
|
-
commands:
|
|
2936
|
-
state:
|
|
2937
|
-
position:
|
|
2938
|
-
inputCommand:
|
|
2939
|
-
messages:
|
|
2940
|
-
onActiveIndexChange:
|
|
2941
|
-
onInputCommandChange:
|
|
2942
|
-
onSelect:
|
|
3007
|
+
slashCommandMenu: q && C ? {
|
|
3008
|
+
commands: he,
|
|
3009
|
+
state: P,
|
|
3010
|
+
position: te,
|
|
3011
|
+
inputCommand: L,
|
|
3012
|
+
messages: O,
|
|
3013
|
+
onActiveIndexChange: X,
|
|
3014
|
+
onInputCommandChange: ne,
|
|
3015
|
+
onSelect: Le,
|
|
2943
3016
|
onUpload: _
|
|
2944
3017
|
} : null,
|
|
2945
|
-
tableControls: q &&
|
|
3018
|
+
tableControls: q && C ? {
|
|
2946
3019
|
editor: q,
|
|
2947
|
-
active:
|
|
3020
|
+
active: we.active,
|
|
2948
3021
|
interactionState: ae,
|
|
2949
|
-
messages:
|
|
3022
|
+
messages: O,
|
|
2950
3023
|
onCopyPayload: y,
|
|
2951
3024
|
onCommandResult: v,
|
|
2952
3025
|
onEditWithAi: p
|
|
2953
3026
|
} : null,
|
|
2954
|
-
tableSelectionOverlay: q &&
|
|
3027
|
+
tableSelectionOverlay: q && C ? {
|
|
2955
3028
|
editor: q,
|
|
2956
|
-
focusState:
|
|
3029
|
+
focusState: we
|
|
2957
3030
|
} : null,
|
|
2958
3031
|
codeBlockControls: q ? {
|
|
2959
3032
|
editor: q,
|
|
2960
|
-
active:
|
|
2961
|
-
mermaidMode:
|
|
2962
|
-
onMermaidModeChange:
|
|
2963
|
-
readOnly: !
|
|
3033
|
+
active: C && Te,
|
|
3034
|
+
mermaidMode: R,
|
|
3035
|
+
onMermaidModeChange: z,
|
|
3036
|
+
readOnly: !C
|
|
2964
3037
|
} : null,
|
|
2965
|
-
innerToc: q && l &&
|
|
3038
|
+
innerToc: q && l && Me.items.length ? {
|
|
2966
3039
|
editor: q,
|
|
2967
|
-
editable:
|
|
2968
|
-
messages:
|
|
2969
|
-
placement:
|
|
2970
|
-
state:
|
|
3040
|
+
editable: C,
|
|
3041
|
+
messages: O,
|
|
3042
|
+
placement: ee,
|
|
3043
|
+
state: Me
|
|
2971
3044
|
} : null,
|
|
2972
|
-
mathEditorPopover: q &&
|
|
3045
|
+
mathEditorPopover: q && C && re ? {
|
|
2973
3046
|
editor: q,
|
|
2974
|
-
messages:
|
|
3047
|
+
messages: O,
|
|
2975
3048
|
target: re,
|
|
2976
3049
|
onClose: () => ie(null)
|
|
2977
3050
|
} : null
|
|
2978
3051
|
}), [
|
|
2979
|
-
|
|
3052
|
+
C,
|
|
2980
3053
|
q,
|
|
2981
|
-
|
|
3054
|
+
he,
|
|
2982
3055
|
l,
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
3056
|
+
Te,
|
|
3057
|
+
R,
|
|
3058
|
+
O,
|
|
2986
3059
|
re,
|
|
2987
3060
|
p,
|
|
2988
3061
|
m,
|
|
@@ -2990,38 +3063,38 @@ function xi({ ariaLabel: e, autoFocusFirstTableBodyCell: t = !1, autofocus: n =
|
|
|
2990
3063
|
_,
|
|
2991
3064
|
v,
|
|
2992
3065
|
y,
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3066
|
+
Le,
|
|
3067
|
+
M,
|
|
3068
|
+
X,
|
|
3069
|
+
L,
|
|
3070
|
+
te,
|
|
3071
|
+
P,
|
|
3072
|
+
we,
|
|
3000
3073
|
ae,
|
|
3001
|
-
|
|
3074
|
+
Me
|
|
3002
3075
|
]),
|
|
3003
|
-
runtimeSnapshot:
|
|
3004
|
-
actions:
|
|
3076
|
+
runtimeSnapshot: Ie,
|
|
3077
|
+
actions: Q
|
|
3005
3078
|
};
|
|
3006
3079
|
}
|
|
3007
|
-
function
|
|
3008
|
-
let r =
|
|
3080
|
+
function Di({ className: e, ...n }) {
|
|
3081
|
+
let r = Ei(n);
|
|
3009
3082
|
if (!r.editor) return null;
|
|
3010
3083
|
let i = [r.frameProps.className, e].filter(Boolean).join(" ");
|
|
3011
3084
|
return /* @__PURE__ */ Q("section", {
|
|
3012
3085
|
...r.frameProps,
|
|
3013
3086
|
className: i,
|
|
3014
3087
|
children: [
|
|
3015
|
-
r.overlayProps.floatingToolbar ? /* @__PURE__ */ Z(
|
|
3016
|
-
r.overlayProps.slashCommandMenu ? /* @__PURE__ */ Z(
|
|
3017
|
-
r.overlayProps.tableControls ? /* @__PURE__ */ Z(
|
|
3018
|
-
r.overlayProps.tableSelectionOverlay ? /* @__PURE__ */ Z(
|
|
3019
|
-
r.overlayProps.codeBlockControls ? /* @__PURE__ */ Z(
|
|
3020
|
-
r.overlayProps.innerToc ? /* @__PURE__ */ Z(
|
|
3021
|
-
r.overlayProps.mathEditorPopover ? /* @__PURE__ */ Z(
|
|
3088
|
+
r.overlayProps.floatingToolbar ? /* @__PURE__ */ Z(Kr, { ...r.overlayProps.floatingToolbar }) : null,
|
|
3089
|
+
r.overlayProps.slashCommandMenu ? /* @__PURE__ */ Z(pi, { ...r.overlayProps.slashCommandMenu }) : null,
|
|
3090
|
+
r.overlayProps.tableControls ? /* @__PURE__ */ Z(hi, { ...r.overlayProps.tableControls }) : null,
|
|
3091
|
+
r.overlayProps.tableSelectionOverlay ? /* @__PURE__ */ Z(gi, { ...r.overlayProps.tableSelectionOverlay }) : null,
|
|
3092
|
+
r.overlayProps.codeBlockControls ? /* @__PURE__ */ Z(Tr, { ...r.overlayProps.codeBlockControls }) : null,
|
|
3093
|
+
r.overlayProps.innerToc ? /* @__PURE__ */ Z(vi, { ...r.overlayProps.innerToc }) : null,
|
|
3094
|
+
r.overlayProps.mathEditorPopover ? /* @__PURE__ */ Z(ii, { ...r.overlayProps.mathEditorPopover }) : null,
|
|
3022
3095
|
/* @__PURE__ */ Z(t, { editor: r.editor })
|
|
3023
3096
|
]
|
|
3024
3097
|
});
|
|
3025
3098
|
}
|
|
3026
3099
|
//#endregion
|
|
3027
|
-
export {
|
|
3100
|
+
export { Di as MarkweaveEditor, Sr as createMarkweaveEditorExtensions, Sr as createMarkweaveReactEditorExtensions, Ei as useMarkweaveEditorController };
|