@markweave/react 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -1,110 +1,123 @@
|
|
|
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,
|
|
4
|
-
import { useCallback as
|
|
5
|
-
import { detectUploadSource as
|
|
6
|
-
import { MarkweaveCoreImage as
|
|
7
|
-
import { getLocalizedSlashCommandSpecs as
|
|
8
|
-
import { getMarkweaveEditorModeState 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 C, Heading2 as w, Heading3 as T, Image as E, ImageUp as D, IndentDecrease as O, IndentIncrease as k, Info as A, Italic as j, Lightbulb as M, Link2 as N, List as P, ListChecks as F, ListOrdered as I, Minus as ee, MoreVertical as L, Paperclip as R, Quote as te, Replace as z, Sigma as ne, 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
|
+
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 K } from "markweave/internal/plugins/slash-command/upload";
|
|
6
|
+
import { MarkweaveCoreImage as q, MarkweaveCoreVideo as ve, attrsFromMarkweaveImageUploadResult as ye, attrsFromMarkweaveVideoUploadResult as be, attrsFromMarkweaveVideoUrl as xe, clampMarkweaveImageWidth as Se, createMarkweaveImageUploadRequest as Ce, createMarkweaveVideoUploadRequest as J, downloadMarkweaveImage as we, markweaveVideoIframeAllow as Te, normalizeMarkweaveCoreImageAlign as Ee, normalizeMarkweaveVideoEmbedUrl as De, numberAttribute as Oe, stringAttribute as Y } from "markweave/internal/plugins/media/core-media-nodes";
|
|
7
|
+
import { getLocalizedSlashCommandSpecs as ke, getMarkweaveMessages as Ae, normalizeMarkweaveLang as je } from "markweave/internal/i18n";
|
|
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
|
+
import { openMarkweaveImagePreview as Le } from "markweave/internal/plugins/media/image-preview";
|
|
9
10
|
import { Fragment as X, jsx as Z, jsxs as Q } from "react/jsx-runtime";
|
|
10
|
-
import { createMarkweaveAdapterMediaExtensions as
|
|
11
|
-
import { isEditorComposing as
|
|
12
|
-
import { createMarkweaveEditorUpdatePayload as
|
|
13
|
-
import { openMarkweaveReadonlyLinkFromEvent as
|
|
14
|
-
import { createMarkweaveEditorRuntimeSnapshot as
|
|
15
|
-
import { advanceFloatingToolbarMotionState as
|
|
16
|
-
import { codeBlockCollapsePluginKey as
|
|
17
|
-
import { isMermaidInlinePreviewTransaction as
|
|
18
|
-
import { getMermaidPreviewState as
|
|
19
|
-
import { applyMarkweaveMathLatex as
|
|
20
|
-
import { filterSlashCommands as
|
|
21
|
-
import { getSlashCommandKeyboardAction as
|
|
22
|
-
import { executeSlashCommand as
|
|
23
|
-
import { initialSlashCommandState as
|
|
24
|
-
import { getFirstTableDebugSnapshot as
|
|
25
|
-
import { focusFirstTableBodyCell as
|
|
26
|
-
import { getTableFocusState as
|
|
27
|
-
import { getTableSelectionOverlayState as
|
|
28
|
-
import { calculateCodeBlockLanguageMenuPosition as
|
|
29
|
-
import { BubbleMenu as
|
|
30
|
-
import { applyFloatingToolbarLink as
|
|
31
|
-
import { normalizeMarkdownLinkHref as
|
|
32
|
-
import { setMarkweaveTableMenuAxisTarget as
|
|
33
|
-
import { calculateAnchoredTableMenuPosition as
|
|
34
|
-
import { createMarkweaveTocState as
|
|
11
|
+
import { createMarkweaveAdapterMediaExtensions as Re } from "markweave/internal/plugins/media/media-extension-factory";
|
|
12
|
+
import { isEditorComposing as ze } from "markweave/internal/editor-core/composition-guard";
|
|
13
|
+
import { createMarkweaveEditorUpdatePayload as Be, getMarkweaveContentType as Ve, isEditorContentCurrent as He, normalizeMarkweaveContentFormat as Ue } from "markweave/internal/editor-core/editor-content";
|
|
14
|
+
import { openMarkweaveReadonlyLinkFromEvent as We } from "markweave/internal/editor-core/readonly-link";
|
|
15
|
+
import { createMarkweaveEditorRuntimeSnapshot as Ge } from "markweave/internal/editor-core/runtime-snapshot";
|
|
16
|
+
import { advanceFloatingToolbarMotionState as Ke, calculateFloatingToolbarFrameShift as qe, calculateFloatingToolbarTopBoundary as Je, createSelectionSnapshot as Ye, getFloatingToolbarFloatingOptions as Xe, getFloatingToolbarState as Ze, shouldShowFloatingToolbar as Qe, transitionFloatingToolbarState as $e } from "markweave/internal/editor-core/selection-state";
|
|
17
|
+
import { codeBlockCollapsePluginKey as et, copyActiveCodeBlock as tt, getActiveCodeBlockState as nt, getCodeBlockCopyFeedbackSnapshot as rt, markweaveCodeBlockBehavior as it, setCodeBlockCollapsedAtPosition as at, setCodeBlockLanguageAtPosition as ot, setCodeBlockMermaidPreviewModeAtPosition as st } from "markweave/internal/plugins/codeblock/codeblock-behavior";
|
|
18
|
+
import { isMermaidInlinePreviewTransaction as ct, setMermaidInlinePreviewEditorMode as lt, setReadonlyMermaidPreviewMode as ut } from "markweave/internal/plugins/mermaid/mermaid-inline-preview";
|
|
19
|
+
import { getMermaidPreviewState as dt } from "markweave/internal/plugins/mermaid/mermaid-renderer";
|
|
20
|
+
import { applyMarkweaveMathLatex as ft, calculateMarkweaveMathPopoverPosition as pt, getMarkweaveMathAnchorRect as mt, getMarkweaveMathBlockIndex as ht, getMarkweaveMathRenderedHtml as gt, getMarkweaveMathTargetAtPos as _t, getMarkweaveMathTargetFromDomEvent as vt, getMarkweaveMathTargetFromSelection as yt, renderMarkweaveMathPreview as bt, setMarkweaveMathEditingDomState as xt, setMarkweaveMathEditingDomStateInView as St, setMarkweaveMathSelectionInView as Ct } from "markweave/internal/plugins/math/math-ui-model";
|
|
21
|
+
import { filterSlashCommands as wt, isExecutableSlashCommand as Tt } from "markweave/internal/plugins/slash-command/command-spec";
|
|
22
|
+
import { getSlashCommandKeyboardAction as Et, isSlashCommandMenuState as Dt } from "markweave/internal/plugins/slash-command/slash-keyboard";
|
|
23
|
+
import { executeSlashCommand as Ot, getNextSlashCommandState as kt, getSlashCommandAnchoredMenuPosition as At, getSlashCommandContext as jt } from "markweave/internal/plugins/slash-command/slash-runtime";
|
|
24
|
+
import { initialSlashCommandState as Mt, reduceSlashCommandState as Nt } from "markweave/internal/plugins/slash-command/slash-state";
|
|
25
|
+
import { getFirstTableDebugSnapshot as Pt } from "markweave/internal/plugins/table/table-debug-snapshot";
|
|
26
|
+
import { focusFirstTableBodyCell as Ft } from "markweave/internal/plugins/table/table-focus-position";
|
|
27
|
+
import { getTableFocusState as It } from "markweave/internal/plugins/table/table-focus-state";
|
|
28
|
+
import { getTableSelectionOverlayState as Lt, initialTableInteractionState as Rt, tableInteractionPluginKey as zt } from "markweave/internal/plugins/table/table-interaction-layer";
|
|
29
|
+
import { calculateCodeBlockLanguageMenuPosition as Bt, clampFullscreenScale as Vt, codeBlockCopyFeedbackTimeoutMs as Ht, copyCodeBlockText as Ut, createCodeBlockOverlayPosition as Wt, createMermaidFullscreenViewerState as Gt, createMermaidTabPosition as Kt, focusCodeBlockTarget as qt, formatCodeBlockLanguageLabel as Jt, formatFullscreenZoom as Yt, getActiveCodeBlockElement as Xt, getAnchoredRect as Zt, getCodeBlockLanguageItems as Qt, getCodeBlockPositionFromEventTarget as $t, getCodeBlockStateAtPosition as en, getFrameElement as tn, getMermaidCodeBlockTargets as nn, getMermaidSvgMarkup as rn, isCodeBlockTargetCollapsed as an, mergeStableMermaidTabPositions as on, mermaidFullscreenZoomStep as sn, moveMermaidFullscreenViewer as cn } from "markweave/internal/plugins/codeblock/codeblock-ui-model";
|
|
30
|
+
import { BubbleMenu as ln } from "@tiptap/react/menus";
|
|
31
|
+
import { applyFloatingToolbarLink as un, createFloatingToolbarAssistantRequest as dn, getFloatingToolbarButtonModels as fn, getFloatingToolbarHighlightColorOptions as pn, getFloatingToolbarLinkHref as mn, getFloatingToolbarMessageSet as hn, getFloatingToolbarMoreActions as gn, getFloatingToolbarTextColorOptions as _n, getFloatingToolbarTooltipModel as vn, getFloatingToolbarTurnIntoOptions as yn, isFloatingToolbarMoreActionActive as bn, isFloatingToolbarTurnIntoActive as xn, openFloatingToolbarLinkHref as Sn, preventFloatingToolbarPointerFocusLoss as Cn, removeFloatingToolbarLink as wn, runFloatingToolbarMoreAction as Tn, setFloatingToolbarHighlightColor as En, setFloatingToolbarTextColor as Dn, setFloatingToolbarTurnInto as On } from "markweave/internal/editor-core/floating-toolbar-model";
|
|
32
|
+
import { normalizeMarkdownLinkHref as kn } from "markweave/internal/plugins/markdown/markdown-input";
|
|
33
|
+
import { setMarkweaveTableMenuAxisTarget as An } from "markweave/internal/plugins/table/table-clipboard";
|
|
34
|
+
import { calculateAnchoredTableMenuPosition as jn, calculateTableEdgeHandlePosition as Mn, canRunTableCommand as Nn, executeTableMenuCommand as Pn, formatTableCopyFeedback as Fn, getActiveTableElement as In, getAvailableCellMenuCommandSpecs as Ln, getTableAxisTargetRect as Rn, getTableControlAxisSelectionModel as zn, getTableEditWithAiRequest as Bn, getTableMenuItemGroup as Vn, getTableMenuItemLabel as Hn, getTableMenuItems as Un, getTableSelectionTargetRect as Wn, measureTableSelectionOverlay as Gn, selectTableAxisFromCell as Kn, tableCopyFeedbackTimeoutMs as qn, tableMenuLabel as Jn } from "markweave/internal/plugins/table/table-ui-model";
|
|
35
|
+
import { createMarkweaveTocState as Yn, emptyMarkweaveTocState as Xn, getActiveMarkweaveTocId as Zn, getMarkweaveTocItems as Qn, getValidMarkweaveTocActiveId as $n, normalizeMarkweaveInnerTocPlacement as er, observeMarkweaveInnerTocContainerPosition as tr, scrollToMarkweaveTocItem as nr } from "markweave/internal/core/toc-state";
|
|
35
36
|
//#region src/editor-mode-state.ts
|
|
36
|
-
var
|
|
37
|
+
var rr = {
|
|
37
38
|
mode: "live",
|
|
38
39
|
editable: !0
|
|
39
40
|
};
|
|
40
|
-
function
|
|
41
|
-
return
|
|
41
|
+
function ir(e) {
|
|
42
|
+
return he((t) => Ie(e, t), () => Me(e), () => rr);
|
|
42
43
|
}
|
|
43
44
|
//#endregion
|
|
44
45
|
//#region src/media/image-node.tsx
|
|
45
|
-
var
|
|
46
|
-
function
|
|
46
|
+
var ar = Ee;
|
|
47
|
+
function or(e) {
|
|
47
48
|
return e instanceof Element && !!e.closest("[data-markweave-image-ui=\"true\"]");
|
|
48
49
|
}
|
|
49
|
-
function
|
|
50
|
-
let { deleteNode: t, editor: r, getPos: i, node: a, selected: o, updateAttributes: s } = e, c = e.extension.options, l = c.messages ??
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
function sr(e) {
|
|
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(ir(r)), f = Y(a.attrs.src), p = ar(a.attrs.align), m = Oe(a.attrs.width), h = Y(a.attrs.caption), g = W(null), _ = W(null), [v, y] = G(!1), [b, x] = G(!1), [C, w] = G(!1), [T, E] = G(""), [D, O] = G(null), [k, A] = G(!1), [j, M] = G(!!h), [N, P] = G(h ?? ""), F = d && (!f || b), I = () => {
|
|
52
|
+
f && Le({
|
|
53
|
+
src: f,
|
|
54
|
+
alt: Y(a.attrs.alt) ?? "",
|
|
55
|
+
messages: {
|
|
56
|
+
dialogAriaLabel: u.previewDialogAriaLabel,
|
|
57
|
+
zoomOut: u.previewZoomOut,
|
|
58
|
+
zoomIn: u.previewZoomIn,
|
|
59
|
+
reset: u.previewReset,
|
|
60
|
+
close: u.previewClose
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
H(() => {
|
|
65
|
+
j || P(h ?? "");
|
|
66
|
+
}, [h, j]);
|
|
67
|
+
let ee = () => {
|
|
55
68
|
if (!d) return;
|
|
56
69
|
let e = i();
|
|
57
70
|
typeof e == "number" && r.chain().focus().setNodeSelection(e).run();
|
|
58
|
-
},
|
|
71
|
+
}, L = () => {
|
|
59
72
|
if (d) {
|
|
60
|
-
if (
|
|
73
|
+
if (E(""), O(null), w(!1), f) {
|
|
61
74
|
x(!1);
|
|
62
75
|
return;
|
|
63
76
|
}
|
|
64
77
|
t();
|
|
65
78
|
}
|
|
66
|
-
},
|
|
79
|
+
}, R = async (e) => {
|
|
67
80
|
if (d) {
|
|
68
|
-
|
|
81
|
+
O(null), A(!0);
|
|
69
82
|
try {
|
|
70
|
-
let t = await K(
|
|
71
|
-
s(
|
|
83
|
+
let t = await K(Ce(e, f && b ? "image-replace" : "image-insert"), c.onUpload);
|
|
84
|
+
s(ye(a.attrs, t)), x(!1), E("");
|
|
72
85
|
} catch (e) {
|
|
73
|
-
|
|
86
|
+
O(e instanceof Error ? e.message : u.uploadFailedError);
|
|
74
87
|
} finally {
|
|
75
|
-
|
|
88
|
+
A(!1), w(!1);
|
|
76
89
|
}
|
|
77
90
|
}
|
|
78
|
-
},
|
|
91
|
+
}, te = () => {
|
|
79
92
|
if (d) {
|
|
80
|
-
if (!
|
|
81
|
-
|
|
93
|
+
if (!T.trim()) {
|
|
94
|
+
O(u.uploadRequiredError);
|
|
82
95
|
return;
|
|
83
96
|
}
|
|
84
|
-
|
|
97
|
+
R(ge(T));
|
|
85
98
|
}
|
|
86
|
-
},
|
|
87
|
-
!d || !e ||
|
|
99
|
+
}, z = (e) => {
|
|
100
|
+
!d || !e || R({
|
|
88
101
|
type: "file",
|
|
89
102
|
file: e,
|
|
90
103
|
mimeType: e.type
|
|
91
104
|
});
|
|
92
|
-
},
|
|
93
|
-
|
|
94
|
-
}, z = (e) => {
|
|
95
|
-
e.preventDefault(), e.stopPropagation(), d && R(e.dataTransfer.files?.[0] ?? null);
|
|
96
|
-
}, ne = () => {
|
|
97
|
-
d && (j((e) => !e), A || N(h ?? ""));
|
|
105
|
+
}, ne = (e) => {
|
|
106
|
+
z(e.currentTarget.files?.[0] ?? null), e.currentTarget.value = "";
|
|
98
107
|
}, re = (e) => {
|
|
99
|
-
|
|
100
|
-
}, ie = (
|
|
108
|
+
e.preventDefault(), e.stopPropagation(), d && z(e.dataTransfer.files?.[0] ?? null);
|
|
109
|
+
}, ie = () => {
|
|
110
|
+
d && (M((e) => !e), j || P(h ?? ""));
|
|
111
|
+
}, ae = (e) => {
|
|
112
|
+
d && (P(e), s({ caption: e.trim() ? e : null }));
|
|
113
|
+
}, oe = (e, t) => {
|
|
101
114
|
if (t.preventDefault(), t.stopPropagation(), !d) return;
|
|
102
|
-
|
|
115
|
+
ee();
|
|
103
116
|
let n = g.current;
|
|
104
117
|
if (!n) return;
|
|
105
118
|
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) => {
|
|
106
119
|
let n = e === "right" ? t.clientX - r : r - t.clientX;
|
|
107
|
-
s({ width:
|
|
120
|
+
s({ width: Se(i + n, a) });
|
|
108
121
|
}, c = () => {
|
|
109
122
|
window.removeEventListener("pointermove", o), window.removeEventListener("pointerup", c);
|
|
110
123
|
};
|
|
@@ -116,39 +129,40 @@ function ar(e) {
|
|
|
116
129
|
"data-testid": "markweave-image-node",
|
|
117
130
|
"data-align": p,
|
|
118
131
|
"data-selected": d && o ? "true" : "false",
|
|
119
|
-
"data-hovered":
|
|
120
|
-
"data-empty":
|
|
132
|
+
"data-hovered": v ? "true" : "false",
|
|
133
|
+
"data-empty": F ? "true" : "false",
|
|
121
134
|
onPointerEnter: () => y(!0),
|
|
122
135
|
onPointerLeave: () => y(!1),
|
|
123
136
|
onMouseDown: (e) => {
|
|
124
|
-
d && !
|
|
137
|
+
d && !or(e.target) && ee();
|
|
125
138
|
},
|
|
126
|
-
children:
|
|
127
|
-
dragActive:
|
|
128
|
-
error:
|
|
129
|
-
inputValue:
|
|
130
|
-
isSubmitting:
|
|
139
|
+
children: F ? /* @__PURE__ */ Z(cr, {
|
|
140
|
+
dragActive: C,
|
|
141
|
+
error: D,
|
|
142
|
+
inputValue: T,
|
|
143
|
+
isSubmitting: k,
|
|
131
144
|
fileInputRef: _,
|
|
132
145
|
messages: l,
|
|
133
|
-
onCancel:
|
|
134
|
-
onDrop:
|
|
135
|
-
onDragActiveChange:
|
|
136
|
-
onFileChange:
|
|
137
|
-
onInputChange:
|
|
138
|
-
onSubmit:
|
|
146
|
+
onCancel: L,
|
|
147
|
+
onDrop: re,
|
|
148
|
+
onDragActiveChange: w,
|
|
149
|
+
onFileChange: ne,
|
|
150
|
+
onInputChange: E,
|
|
151
|
+
onSubmit: te
|
|
139
152
|
}) : /* @__PURE__ */ Q(X, { children: [
|
|
140
|
-
d ? /* @__PURE__ */ Z(
|
|
153
|
+
d ? /* @__PURE__ */ Z(lr, {
|
|
141
154
|
align: p,
|
|
142
|
-
captionActive:
|
|
155
|
+
captionActive: j || !!h,
|
|
143
156
|
messages: l,
|
|
144
157
|
onAlign: (e) => s({ align: e }),
|
|
145
|
-
onCaption:
|
|
158
|
+
onCaption: ie,
|
|
146
159
|
onDelete: t,
|
|
147
160
|
onDownload: () => {
|
|
148
|
-
f &&
|
|
161
|
+
f && we(f);
|
|
149
162
|
},
|
|
163
|
+
onPreview: I,
|
|
150
164
|
onReplace: () => {
|
|
151
|
-
|
|
165
|
+
E(""), O(null), x(!0);
|
|
152
166
|
}
|
|
153
167
|
}) : null,
|
|
154
168
|
/* @__PURE__ */ Q("div", {
|
|
@@ -167,28 +181,46 @@ function ar(e) {
|
|
|
167
181
|
"data-testid": "markweave-image-readonly-empty",
|
|
168
182
|
"aria-hidden": "true"
|
|
169
183
|
}),
|
|
170
|
-
d ? /* @__PURE__ */
|
|
184
|
+
!d && f ? /* @__PURE__ */ Q("button", {
|
|
185
|
+
type: "button",
|
|
186
|
+
className: "markweave-image-preview-trigger",
|
|
187
|
+
"data-testid": "markweave-image-preview",
|
|
188
|
+
"data-markweave-image-ui": "true",
|
|
189
|
+
"aria-label": u.preview,
|
|
190
|
+
title: u.preview,
|
|
191
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
192
|
+
onClick: I,
|
|
193
|
+
children: [/* @__PURE__ */ Z(S, {
|
|
194
|
+
size: 16,
|
|
195
|
+
strokeWidth: 1.8
|
|
196
|
+
}), /* @__PURE__ */ Z("span", {
|
|
197
|
+
className: "markweave-image-tooltip",
|
|
198
|
+
role: "tooltip",
|
|
199
|
+
children: u.preview
|
|
200
|
+
})]
|
|
201
|
+
}) : null,
|
|
202
|
+
d ? /* @__PURE__ */ Z(dr, {
|
|
171
203
|
side: "left",
|
|
172
204
|
messages: l,
|
|
173
|
-
onPointerDown:
|
|
205
|
+
onPointerDown: oe
|
|
174
206
|
}) : null,
|
|
175
|
-
d ? /* @__PURE__ */ Z(
|
|
207
|
+
d ? /* @__PURE__ */ Z(dr, {
|
|
176
208
|
side: "right",
|
|
177
209
|
messages: l,
|
|
178
|
-
onPointerDown:
|
|
210
|
+
onPointerDown: oe
|
|
179
211
|
}) : null
|
|
180
212
|
]
|
|
181
213
|
}),
|
|
182
|
-
d && (
|
|
214
|
+
d && (j || h) ? /* @__PURE__ */ Z("input", {
|
|
183
215
|
className: "markweave-image-caption-input",
|
|
184
216
|
"data-markweave-image-ui": "true",
|
|
185
217
|
"data-testid": "markweave-image-caption-input",
|
|
186
|
-
value:
|
|
218
|
+
value: N,
|
|
187
219
|
placeholder: u.captionPlaceholder,
|
|
188
220
|
"aria-label": u.captionAriaLabel,
|
|
189
|
-
onChange: (e) =>
|
|
221
|
+
onChange: (e) => ae(e.currentTarget.value),
|
|
190
222
|
onKeyDown: (e) => {
|
|
191
|
-
e.key === "Escape" && (e.preventDefault(),
|
|
223
|
+
e.key === "Escape" && (e.preventDefault(), M(!1));
|
|
192
224
|
}
|
|
193
225
|
}) : h ? /* @__PURE__ */ Z("figcaption", {
|
|
194
226
|
className: "markweave-image-caption",
|
|
@@ -198,7 +230,7 @@ function ar(e) {
|
|
|
198
230
|
] })
|
|
199
231
|
});
|
|
200
232
|
}
|
|
201
|
-
function
|
|
233
|
+
function cr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitting: i, messages: a, onCancel: o, onDragActiveChange: s, onDrop: c, onFileChange: l, onInputChange: u, onSubmit: d }) {
|
|
202
234
|
let f = a.image;
|
|
203
235
|
return /* @__PURE__ */ Q("section", {
|
|
204
236
|
className: "markweave-image-upload-placeholder",
|
|
@@ -225,7 +257,7 @@ function or({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
|
|
|
225
257
|
/* @__PURE__ */ Z("div", {
|
|
226
258
|
className: "markweave-image-upload-icon",
|
|
227
259
|
"aria-hidden": "true",
|
|
228
|
-
children: /* @__PURE__ */ Z(
|
|
260
|
+
children: /* @__PURE__ */ Z(D, {
|
|
229
261
|
size: 46,
|
|
230
262
|
strokeWidth: 1.6
|
|
231
263
|
})
|
|
@@ -260,7 +292,7 @@ function or({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
|
|
|
260
292
|
"data-testid": "markweave-image-upload-submit",
|
|
261
293
|
disabled: i || !r.trim(),
|
|
262
294
|
onClick: d,
|
|
263
|
-
children: [/* @__PURE__ */ Z(
|
|
295
|
+
children: [/* @__PURE__ */ Z(D, {
|
|
264
296
|
size: 16,
|
|
265
297
|
strokeWidth: 1.8
|
|
266
298
|
}), a.common.insert]
|
|
@@ -280,31 +312,31 @@ function or({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
|
|
|
280
312
|
]
|
|
281
313
|
});
|
|
282
314
|
}
|
|
283
|
-
function
|
|
284
|
-
let
|
|
315
|
+
function lr({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i, onDelete: a, onDownload: s, onPreview: u, onReplace: d }) {
|
|
316
|
+
let p = n.image;
|
|
285
317
|
return /* @__PURE__ */ Q("div", {
|
|
286
318
|
className: "markweave-image-toolbar",
|
|
287
319
|
"data-testid": "markweave-image-toolbar",
|
|
288
320
|
"data-markweave-image-ui": "true",
|
|
289
|
-
"aria-label":
|
|
321
|
+
"aria-label": p.toolsAriaLabel,
|
|
290
322
|
children: [
|
|
291
|
-
/* @__PURE__ */ Z(
|
|
323
|
+
/* @__PURE__ */ Z(ur, {
|
|
292
324
|
testId: "markweave-image-align-left",
|
|
293
|
-
label:
|
|
325
|
+
label: p.alignLeft,
|
|
294
326
|
icon: c,
|
|
295
327
|
active: e === "left",
|
|
296
328
|
onClick: () => r("left")
|
|
297
329
|
}),
|
|
298
|
-
/* @__PURE__ */ Z(
|
|
330
|
+
/* @__PURE__ */ Z(ur, {
|
|
299
331
|
testId: "markweave-image-align-center",
|
|
300
|
-
label:
|
|
332
|
+
label: p.alignCenter,
|
|
301
333
|
icon: o,
|
|
302
334
|
active: e === "center",
|
|
303
335
|
onClick: () => r("center")
|
|
304
336
|
}),
|
|
305
|
-
/* @__PURE__ */ Z(
|
|
337
|
+
/* @__PURE__ */ Z(ur, {
|
|
306
338
|
testId: "markweave-image-align-right",
|
|
307
|
-
label:
|
|
339
|
+
label: p.alignRight,
|
|
308
340
|
icon: l,
|
|
309
341
|
active: e === "right",
|
|
310
342
|
onClick: () => r("right")
|
|
@@ -313,39 +345,45 @@ function sr({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i,
|
|
|
313
345
|
className: "markweave-image-toolbar-divider",
|
|
314
346
|
"aria-hidden": "true"
|
|
315
347
|
}),
|
|
316
|
-
/* @__PURE__ */ Z(
|
|
348
|
+
/* @__PURE__ */ Z(ur, {
|
|
317
349
|
testId: "markweave-image-caption",
|
|
318
|
-
label:
|
|
350
|
+
label: p.caption,
|
|
319
351
|
icon: f,
|
|
320
352
|
active: t,
|
|
321
353
|
onClick: i
|
|
322
354
|
}),
|
|
323
|
-
/* @__PURE__ */ Z(
|
|
355
|
+
/* @__PURE__ */ Z(ur, {
|
|
356
|
+
testId: "markweave-image-preview",
|
|
357
|
+
label: p.preview,
|
|
358
|
+
icon: S,
|
|
359
|
+
onClick: u
|
|
360
|
+
}),
|
|
361
|
+
/* @__PURE__ */ Z(ur, {
|
|
324
362
|
testId: "markweave-image-download",
|
|
325
|
-
label:
|
|
363
|
+
label: p.download,
|
|
326
364
|
icon: b,
|
|
327
365
|
onClick: s
|
|
328
366
|
}),
|
|
329
|
-
/* @__PURE__ */ Z(
|
|
367
|
+
/* @__PURE__ */ Z(ur, {
|
|
330
368
|
testId: "markweave-image-replace",
|
|
331
|
-
label:
|
|
332
|
-
icon:
|
|
333
|
-
onClick:
|
|
369
|
+
label: p.replace,
|
|
370
|
+
icon: z,
|
|
371
|
+
onClick: d
|
|
334
372
|
}),
|
|
335
373
|
/* @__PURE__ */ Z("span", {
|
|
336
374
|
className: "markweave-image-toolbar-divider",
|
|
337
375
|
"aria-hidden": "true"
|
|
338
376
|
}),
|
|
339
|
-
/* @__PURE__ */ Z(
|
|
377
|
+
/* @__PURE__ */ Z(ur, {
|
|
340
378
|
testId: "markweave-image-delete",
|
|
341
|
-
label:
|
|
342
|
-
icon:
|
|
379
|
+
label: p.delete,
|
|
380
|
+
icon: ue,
|
|
343
381
|
onClick: a
|
|
344
382
|
})
|
|
345
383
|
]
|
|
346
384
|
});
|
|
347
385
|
}
|
|
348
|
-
function
|
|
386
|
+
function ur({ active: e = !1, icon: t, label: n, onClick: r, testId: i }) {
|
|
349
387
|
return /* @__PURE__ */ Q("button", {
|
|
350
388
|
type: "button",
|
|
351
389
|
"aria-label": n,
|
|
@@ -364,7 +402,7 @@ function cr({ active: e = !1, icon: t, label: n, onClick: r, testId: i }) {
|
|
|
364
402
|
})]
|
|
365
403
|
});
|
|
366
404
|
}
|
|
367
|
-
function
|
|
405
|
+
function dr({ messages: e, onPointerDown: t, side: n }) {
|
|
368
406
|
return /* @__PURE__ */ Z("button", {
|
|
369
407
|
type: "button",
|
|
370
408
|
className: "markweave-image-resize-handle",
|
|
@@ -375,42 +413,42 @@ function lr({ messages: e, onPointerDown: t, side: n }) {
|
|
|
375
413
|
onPointerDown: (e) => t(n, e)
|
|
376
414
|
});
|
|
377
415
|
}
|
|
378
|
-
var
|
|
416
|
+
var fr = q.extend({
|
|
379
417
|
addOptions() {
|
|
380
418
|
return {
|
|
381
419
|
...this.parent?.(),
|
|
382
|
-
messages:
|
|
420
|
+
messages: Ae("zh"),
|
|
383
421
|
onUpload: void 0
|
|
384
422
|
};
|
|
385
423
|
},
|
|
386
424
|
addNodeView() {
|
|
387
|
-
return typeof document > "u" ? null : r(
|
|
425
|
+
return typeof document > "u" ? null : r(sr, { stopEvent: ({ event: e }) => or(e.target) });
|
|
388
426
|
}
|
|
389
427
|
});
|
|
390
428
|
//#endregion
|
|
391
429
|
//#region src/media/video-node.tsx
|
|
392
|
-
function
|
|
430
|
+
function pr(e) {
|
|
393
431
|
return e instanceof Element && !!e.closest("[data-markweave-video-ui=\"true\"], iframe[data-markweave-video-embed], video[data-markweave-video]");
|
|
394
432
|
}
|
|
395
|
-
function
|
|
396
|
-
let { deleteNode: t, editor: r, getPos: i, node: a, selected: o, updateAttributes: s } = e, c = e.extension.options, l = c.messages ??
|
|
433
|
+
function mr(e) {
|
|
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(ir(r)), f = Y(a.attrs.src), p = Y(a.attrs.embedUrl), m = Y(a.attrs.provider), h = p ? De(p, m) : null, g = Y(a.attrs.mimeType), _ = Y(a.attrs.title), v = W(null), [y, b] = G(!1), [x, S] = G(""), [C, w] = G(null), [T, E] = G(!1), D = d && !f, O = () => {
|
|
397
435
|
if (!d) return;
|
|
398
436
|
let e = i();
|
|
399
437
|
typeof e == "number" && r.chain().focus().setNodeSelection(e).run();
|
|
400
438
|
}, k = (e) => {
|
|
401
|
-
d && (
|
|
439
|
+
d && (pr(e.target) || (e.preventDefault(), O()));
|
|
402
440
|
}, A = (e) => {
|
|
403
441
|
d && (e.key === "Delete" || e.key === "Backspace") && o && (e.preventDefault(), t());
|
|
404
442
|
}, j = async (e) => {
|
|
405
443
|
if (!(!d || !e)) {
|
|
406
444
|
w(null), E(!0);
|
|
407
445
|
try {
|
|
408
|
-
let t = await K(
|
|
446
|
+
let t = await K(J({
|
|
409
447
|
type: "file",
|
|
410
448
|
file: e,
|
|
411
449
|
mimeType: e.type
|
|
412
450
|
}), c.onUpload);
|
|
413
|
-
s(
|
|
451
|
+
s(be(t)), S("");
|
|
414
452
|
} catch (e) {
|
|
415
453
|
w(e instanceof Error ? e.message : u.uploadFailedError);
|
|
416
454
|
} finally {
|
|
@@ -424,7 +462,7 @@ function fr(e) {
|
|
|
424
462
|
"data-testid": "markweave-video-node",
|
|
425
463
|
"data-empty": "true",
|
|
426
464
|
"data-selected": "false",
|
|
427
|
-
children: /* @__PURE__ */ Z(
|
|
465
|
+
children: /* @__PURE__ */ Z(hr, {
|
|
428
466
|
dragActive: y,
|
|
429
467
|
error: C,
|
|
430
468
|
fileInputRef: v,
|
|
@@ -442,7 +480,7 @@ function fr(e) {
|
|
|
442
480
|
onInputChange: S,
|
|
443
481
|
onSubmit: () => {
|
|
444
482
|
if (!d) return;
|
|
445
|
-
let e =
|
|
483
|
+
let e = xe(x);
|
|
446
484
|
if (!e) {
|
|
447
485
|
w(u.unsupportedUrlError);
|
|
448
486
|
return;
|
|
@@ -471,7 +509,7 @@ function fr(e) {
|
|
|
471
509
|
"data-markweave-video-embed": "true",
|
|
472
510
|
"data-markweave-video-provider": m ?? void 0,
|
|
473
511
|
"data-markweave-video-src": f ?? void 0,
|
|
474
|
-
allow:
|
|
512
|
+
allow: Te,
|
|
475
513
|
allowFullScreen: !0
|
|
476
514
|
}), d ? /* @__PURE__ */ Z("button", {
|
|
477
515
|
type: "button",
|
|
@@ -503,7 +541,7 @@ function fr(e) {
|
|
|
503
541
|
})
|
|
504
542
|
});
|
|
505
543
|
}
|
|
506
|
-
function
|
|
544
|
+
function hr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitting: i, messages: a, onCancel: o, onDragActiveChange: s, onDrop: c, onFileChange: l, onInputChange: u, onSubmit: d }) {
|
|
507
545
|
let f = a.video;
|
|
508
546
|
return /* @__PURE__ */ Q("section", {
|
|
509
547
|
className: "markweave-video-upload-placeholder",
|
|
@@ -530,7 +568,7 @@ function pr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
|
|
|
530
568
|
/* @__PURE__ */ Z("div", {
|
|
531
569
|
className: "markweave-video-upload-icon",
|
|
532
570
|
"aria-hidden": "true",
|
|
533
|
-
children: /* @__PURE__ */ Z(
|
|
571
|
+
children: /* @__PURE__ */ Z(B, {
|
|
534
572
|
size: 46,
|
|
535
573
|
strokeWidth: 1.6
|
|
536
574
|
})
|
|
@@ -565,7 +603,7 @@ function pr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
|
|
|
565
603
|
"data-testid": "markweave-video-upload-submit",
|
|
566
604
|
disabled: i || !r.trim(),
|
|
567
605
|
onClick: d,
|
|
568
|
-
children: [/* @__PURE__ */ Z(
|
|
606
|
+
children: [/* @__PURE__ */ Z(pe, {
|
|
569
607
|
size: 16,
|
|
570
608
|
strokeWidth: 1.8
|
|
571
609
|
}), a.common.insert]
|
|
@@ -585,26 +623,26 @@ function pr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
|
|
|
585
623
|
]
|
|
586
624
|
});
|
|
587
625
|
}
|
|
588
|
-
var
|
|
626
|
+
var gr = ve.extend({
|
|
589
627
|
addOptions() {
|
|
590
628
|
return {
|
|
591
629
|
...this.parent?.(),
|
|
592
|
-
messages:
|
|
630
|
+
messages: Ae("zh"),
|
|
593
631
|
onUpload: void 0
|
|
594
632
|
};
|
|
595
633
|
},
|
|
596
634
|
addNodeView() {
|
|
597
|
-
return typeof document > "u" ? null : r(
|
|
635
|
+
return typeof document > "u" ? null : r(mr, { stopEvent: ({ event: e }) => pr(e.target) });
|
|
598
636
|
}
|
|
599
637
|
});
|
|
600
638
|
//#endregion
|
|
601
639
|
//#region src/create-editor-extensions.ts
|
|
602
|
-
function
|
|
640
|
+
function _r(t = {}) {
|
|
603
641
|
return e({
|
|
604
642
|
lang: t.lang,
|
|
605
|
-
mediaExtensions:
|
|
606
|
-
image:
|
|
607
|
-
video:
|
|
643
|
+
mediaExtensions: Re({
|
|
644
|
+
image: fr,
|
|
645
|
+
video: gr,
|
|
608
646
|
lang: t.lang,
|
|
609
647
|
onImageUpload: t.onImageUpload,
|
|
610
648
|
onVideoUpload: t.onVideoUpload
|
|
@@ -613,7 +651,7 @@ function hr(t = {}) {
|
|
|
613
651
|
}
|
|
614
652
|
//#endregion
|
|
615
653
|
//#region src/ui/codeblock/CodeBlockControls.tsx
|
|
616
|
-
function
|
|
654
|
+
function vr(e) {
|
|
617
655
|
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", {
|
|
618
656
|
cx: "10",
|
|
619
657
|
cy: "10",
|
|
@@ -650,7 +688,7 @@ function gr(e) {
|
|
|
650
688
|
/* @__PURE__ */ Z("path", { d: "m14 14 4 4" })
|
|
651
689
|
] }) : 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" });
|
|
652
690
|
}
|
|
653
|
-
function
|
|
691
|
+
function yr({ icon: e }) {
|
|
654
692
|
return /* @__PURE__ */ Z("svg", {
|
|
655
693
|
viewBox: "0 0 24 24",
|
|
656
694
|
"aria-hidden": "true",
|
|
@@ -661,50 +699,50 @@ function _r({ icon: e }) {
|
|
|
661
699
|
strokeLinecap: "round",
|
|
662
700
|
strokeLinejoin: "round",
|
|
663
701
|
strokeWidth: "1.8",
|
|
664
|
-
children:
|
|
702
|
+
children: vr(e)
|
|
665
703
|
})
|
|
666
704
|
});
|
|
667
705
|
}
|
|
668
|
-
function
|
|
706
|
+
function br({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, readOnly: i = !1 }) {
|
|
669
707
|
let a = W(null), o = W(null), s = W(null), c = W({
|
|
670
708
|
active: !1,
|
|
671
709
|
lastX: 0,
|
|
672
710
|
lastY: 0
|
|
673
|
-
}), [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), [C, w] = G(!1), [T, E] = G(null), [D, O] = G(null), [k, A] = G(!1), [j, M] = G(0), [N, P] = G(0), F =
|
|
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), [C, w] = G(!1), [T, E] = G(null), [D, O] = G(null), [k, A] = G(!1), [j, M] = G(0), [N, P] = G(0), F = nt(t), I = en(t, l), ee = !i && e && F.active && F.pos !== null ? {
|
|
674
712
|
...F,
|
|
675
713
|
pos: F.pos,
|
|
676
714
|
active: !0
|
|
677
|
-
} : null, L = I ?? ee, R = L !== null, te = L?.language === "mermaid", z =
|
|
678
|
-
if (
|
|
715
|
+
} : null, L = I ?? ee, R = L !== null, te = L?.language === "mermaid", z = an(t, L), ne = R && L !== null && !z, re = !i, ie = Jt(L ? L.language : "text"), ae = x?.status ?? "idle", oe = L?.mermaidPreviewMode ?? n, se = te && oe === "preview", ce = nn(t), le = `${N}|${ce.map((e) => `${e.pos}:${e.mermaidPreviewMode}:${e.text.length}`).join("|")}`, ue = U(() => Qt(y.trim().toLowerCase()), [y]);
|
|
716
|
+
if (H(() => {
|
|
679
717
|
i && (v(!1), b(""));
|
|
680
|
-
}, [i]),
|
|
718
|
+
}, [i]), H(() => {
|
|
681
719
|
if (!x) return;
|
|
682
720
|
let e = window.setTimeout(() => {
|
|
683
721
|
S(null);
|
|
684
|
-
},
|
|
722
|
+
}, Ht);
|
|
685
723
|
return () => {
|
|
686
724
|
window.clearTimeout(e);
|
|
687
725
|
};
|
|
688
|
-
}, [x]),
|
|
726
|
+
}, [x]), H(() => {
|
|
689
727
|
S(null), v(!1), b(""), E(null), O(null), A(!1);
|
|
690
728
|
}, [
|
|
691
729
|
e,
|
|
692
730
|
L?.language,
|
|
693
731
|
L?.pos,
|
|
694
732
|
L?.text
|
|
695
|
-
]),
|
|
733
|
+
]), H(() => {
|
|
696
734
|
let e = ({ transaction: e }) => {
|
|
697
|
-
e.getMeta(
|
|
735
|
+
e.getMeta(et) && M((e) => e + 1);
|
|
698
736
|
};
|
|
699
737
|
return t.on("transaction", e), () => {
|
|
700
738
|
t.off("transaction", e);
|
|
701
739
|
};
|
|
702
|
-
}, [t]),
|
|
740
|
+
}, [t]), H(() => {
|
|
703
741
|
let e = t.view.dom.closest(".markweave-editor-frame");
|
|
704
742
|
if (!e) return;
|
|
705
743
|
let n = (e) => {
|
|
706
744
|
if (e.target instanceof Node && a.current?.contains(e.target) || _) return;
|
|
707
|
-
let n =
|
|
745
|
+
let n = en(t, $t(t, e.target)), r = n && !an(t, n) ? n.pos : null;
|
|
708
746
|
u((e) => e === r ? e : r);
|
|
709
747
|
}, r = () => {
|
|
710
748
|
_ || u(null);
|
|
@@ -712,9 +750,9 @@ function vr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
712
750
|
return e.addEventListener("mousemove", n), e.addEventListener("mouseleave", r), () => {
|
|
713
751
|
e.removeEventListener("mousemove", n), e.removeEventListener("mouseleave", r);
|
|
714
752
|
};
|
|
715
|
-
}, [t, _]),
|
|
753
|
+
}, [t, _]), H(() => {
|
|
716
754
|
_ && s.current?.focus({ preventScroll: !0 });
|
|
717
|
-
}, [_]),
|
|
755
|
+
}, [_]), H(() => {
|
|
718
756
|
if (!T) return;
|
|
719
757
|
let e = (e) => {
|
|
720
758
|
e.key === "Escape" && (E(null), O(null), A(!1), c.current = {
|
|
@@ -726,7 +764,7 @@ function vr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
726
764
|
return document.addEventListener("keydown", e), () => {
|
|
727
765
|
document.removeEventListener("keydown", e);
|
|
728
766
|
};
|
|
729
|
-
}, [t, T]),
|
|
767
|
+
}, [t, T]), H(() => {
|
|
730
768
|
if (!R || !_) return;
|
|
731
769
|
let e = (e) => {
|
|
732
770
|
e.key === "Escape" && (v(!1), t.view.focus());
|
|
@@ -740,19 +778,19 @@ function vr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
740
778
|
R,
|
|
741
779
|
t,
|
|
742
780
|
_
|
|
743
|
-
]),
|
|
781
|
+
]), me(() => {
|
|
744
782
|
let e = () => {
|
|
745
783
|
let e = a.current;
|
|
746
784
|
if (!e) return;
|
|
747
|
-
if (
|
|
785
|
+
if (!tn(e) || ce.length === 0) {
|
|
748
786
|
m([]);
|
|
749
787
|
return;
|
|
750
788
|
}
|
|
751
789
|
let n = e.getBoundingClientRect(), r = ce.flatMap((e) => {
|
|
752
|
-
let r =
|
|
753
|
-
return r ? [
|
|
790
|
+
let r = Zt(Xt(t, e.pos, e.mermaidPreviewMode), n);
|
|
791
|
+
return r ? [Kt(e, r, n)] : [];
|
|
754
792
|
});
|
|
755
|
-
m((e) =>
|
|
793
|
+
m((e) => on(e, r, ce.map((e) => e.pos)));
|
|
756
794
|
};
|
|
757
795
|
e();
|
|
758
796
|
let n = window.requestAnimationFrame(e);
|
|
@@ -763,7 +801,7 @@ function vr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
763
801
|
j,
|
|
764
802
|
t,
|
|
765
803
|
le
|
|
766
|
-
]),
|
|
804
|
+
]), me(() => {
|
|
767
805
|
if (!ne || !L) {
|
|
768
806
|
f(null), g(null);
|
|
769
807
|
return;
|
|
@@ -771,15 +809,15 @@ function vr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
771
809
|
let e = () => {
|
|
772
810
|
let e = a.current;
|
|
773
811
|
if (!e) return;
|
|
774
|
-
let n =
|
|
812
|
+
let n = Xt(t, L.pos, oe), r = e.getBoundingClientRect(), i = Zt(n, r);
|
|
775
813
|
if (!i) {
|
|
776
814
|
f((e) => e?.pos === L.pos ? e : null), g((e) => _ ? e : null);
|
|
777
815
|
return;
|
|
778
816
|
}
|
|
779
|
-
let s =
|
|
817
|
+
let s = Wt(L.pos, i, r);
|
|
780
818
|
if (f(s), _ && o.current) {
|
|
781
819
|
let e = o.current.getBoundingClientRect();
|
|
782
|
-
g(
|
|
820
|
+
g(Bt({
|
|
783
821
|
overlayRect: r,
|
|
784
822
|
buttonRect: e,
|
|
785
823
|
windowWidth: window.innerWidth,
|
|
@@ -804,59 +842,59 @@ function vr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
804
842
|
} : void 0, fe = async () => {
|
|
805
843
|
if (i) {
|
|
806
844
|
if (!L) return;
|
|
807
|
-
let e = await
|
|
808
|
-
S(
|
|
845
|
+
let e = await Ut(L.text);
|
|
846
|
+
S(rt(L, e ? "copied" : "failed"));
|
|
809
847
|
return;
|
|
810
848
|
}
|
|
811
|
-
if (!
|
|
812
|
-
let e = await
|
|
813
|
-
S(
|
|
849
|
+
if (!qt(t, L)) return;
|
|
850
|
+
let e = await tt(t);
|
|
851
|
+
S(rt(nt(t), e ? "copied" : "failed")), t.view.focus();
|
|
814
852
|
}, pe = (e, n) => {
|
|
815
853
|
if (i) {
|
|
816
|
-
|
|
854
|
+
ut(t, e.pos, n) && P((e) => e + 1);
|
|
817
855
|
return;
|
|
818
856
|
}
|
|
819
857
|
let a = F.active && F.pos === e.pos;
|
|
820
|
-
|
|
858
|
+
st(t, e.pos, n) && (r(n), P((e) => e + 1), a && t.view.focus());
|
|
821
859
|
}, B = (e) => {
|
|
822
860
|
if (i || !L) return;
|
|
823
861
|
let n = F.active && F.pos === L.pos;
|
|
824
|
-
|
|
825
|
-
},
|
|
826
|
-
i || !L ||
|
|
862
|
+
ot(t, L.pos, e) && (e === "mermaid" && st(t, L.pos, "preview") && r("preview"), v(!1), b(""), P((e) => e + 1), n && t.view.focus());
|
|
863
|
+
}, V = () => {
|
|
864
|
+
i || !L || at(t, L.pos, !z) && (M((e) => e + 1), u(null));
|
|
827
865
|
}, he = () => {
|
|
828
866
|
if (!L) return;
|
|
829
|
-
let e =
|
|
867
|
+
let e = rn(t, L.pos);
|
|
830
868
|
if (!e) return;
|
|
831
869
|
let n = new Blob([e], { type: "image/svg+xml" }), r = URL.createObjectURL(n), i = document.createElement("a");
|
|
832
870
|
i.href = r, i.download = "markweave-mermaid.svg", i.click(), URL.revokeObjectURL(r), t.view.focus();
|
|
833
871
|
}, ge = () => {
|
|
834
872
|
if (!L) return;
|
|
835
|
-
let e =
|
|
836
|
-
e && (E(
|
|
873
|
+
let e = rn(t, L.pos);
|
|
874
|
+
e && (E(Gt(e)), O(null), A(!1), c.current = {
|
|
837
875
|
active: !1,
|
|
838
876
|
lastX: 0,
|
|
839
877
|
lastY: 0
|
|
840
878
|
});
|
|
841
|
-
},
|
|
879
|
+
}, _e = () => {
|
|
842
880
|
E(null), O(null), A(!1), c.current = {
|
|
843
881
|
active: !1,
|
|
844
882
|
lastX: 0,
|
|
845
883
|
lastY: 0
|
|
846
884
|
}, t.view.focus();
|
|
847
|
-
},
|
|
885
|
+
}, K = (e) => {
|
|
848
886
|
E((t) => t && {
|
|
849
887
|
...t,
|
|
850
|
-
scale:
|
|
888
|
+
scale: Vt(t.scale + e)
|
|
851
889
|
});
|
|
852
890
|
}, q = () => {
|
|
853
|
-
E((e) => e &&
|
|
891
|
+
E((e) => e && Gt(e.svg)), c.current = {
|
|
854
892
|
active: !1,
|
|
855
893
|
lastX: 0,
|
|
856
894
|
lastY: 0
|
|
857
895
|
}, A(!1);
|
|
858
896
|
}, ve = (e) => {
|
|
859
|
-
e.preventDefault(),
|
|
897
|
+
e.preventDefault(), K(e.deltaY < 0 ? sn : -sn);
|
|
860
898
|
}, ye = (e) => {
|
|
861
899
|
e.button === 0 && (e.preventDefault(), c.current = {
|
|
862
900
|
active: !0,
|
|
@@ -871,7 +909,7 @@ function vr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
871
909
|
active: !0,
|
|
872
910
|
lastX: e.clientX,
|
|
873
911
|
lastY: e.clientY
|
|
874
|
-
}, E((e) =>
|
|
912
|
+
}, E((e) => cn(e, n, r));
|
|
875
913
|
}, xe = () => {
|
|
876
914
|
c.current = {
|
|
877
915
|
active: !1,
|
|
@@ -930,7 +968,7 @@ function vr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
930
968
|
"data-testid": "markweave-codeblock-language",
|
|
931
969
|
onMouseDown: (e) => e.preventDefault(),
|
|
932
970
|
onClick: () => v((e) => !e),
|
|
933
|
-
children: [/* @__PURE__ */ Z("span", { children: ie }), /* @__PURE__ */ Z(
|
|
971
|
+
children: [/* @__PURE__ */ Z("span", { children: ie }), /* @__PURE__ */ Z(yr, { icon: "chevron" })]
|
|
934
972
|
}),
|
|
935
973
|
re ? /* @__PURE__ */ Z("button", {
|
|
936
974
|
type: "button",
|
|
@@ -940,8 +978,8 @@ function vr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
940
978
|
"data-testid": "markweave-codeblock-collapse",
|
|
941
979
|
"data-collapsed": z ? "true" : "false",
|
|
942
980
|
onMouseDown: (e) => e.preventDefault(),
|
|
943
|
-
onClick:
|
|
944
|
-
children: /* @__PURE__ */ Z(
|
|
981
|
+
onClick: V,
|
|
982
|
+
children: /* @__PURE__ */ Z(yr, { icon: "chevron" })
|
|
945
983
|
}) : null,
|
|
946
984
|
/* @__PURE__ */ Q("span", {
|
|
947
985
|
className: "markweave-codeblock-copy-wrap",
|
|
@@ -957,7 +995,7 @@ function vr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
957
995
|
onFocus: () => w(!0),
|
|
958
996
|
onBlur: () => w(!1),
|
|
959
997
|
onClick: fe,
|
|
960
|
-
children: /* @__PURE__ */ Z(
|
|
998
|
+
children: /* @__PURE__ */ Z(yr, { icon: ae === "copied" ? "check" : "clipboard" })
|
|
961
999
|
}), C ? /* @__PURE__ */ Z("span", {
|
|
962
1000
|
className: "markweave-codeblock-tooltip",
|
|
963
1001
|
role: "tooltip",
|
|
@@ -976,7 +1014,7 @@ function vr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
976
1014
|
disabled: !se,
|
|
977
1015
|
onMouseDown: (e) => e.preventDefault(),
|
|
978
1016
|
onClick: ge,
|
|
979
|
-
children: /* @__PURE__ */ Z(
|
|
1017
|
+
children: /* @__PURE__ */ Z(yr, { icon: "expand" })
|
|
980
1018
|
}), /* @__PURE__ */ Z("button", {
|
|
981
1019
|
type: "button",
|
|
982
1020
|
className: "markweave-codeblock-icon-button",
|
|
@@ -985,7 +1023,7 @@ function vr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
985
1023
|
disabled: !se,
|
|
986
1024
|
onMouseDown: (e) => e.preventDefault(),
|
|
987
1025
|
onClick: he,
|
|
988
|
-
children: /* @__PURE__ */ Z(
|
|
1026
|
+
children: /* @__PURE__ */ Z(yr, { icon: "download" })
|
|
989
1027
|
})]
|
|
990
1028
|
}) : null
|
|
991
1029
|
]
|
|
@@ -1011,7 +1049,7 @@ function vr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1011
1049
|
onKeyDown: (e) => {
|
|
1012
1050
|
e.key === "Escape" && (e.preventDefault(), v(!1), t.view.focus());
|
|
1013
1051
|
}
|
|
1014
|
-
}), /* @__PURE__ */ Z(
|
|
1052
|
+
}), /* @__PURE__ */ Z(yr, { icon: "search" })]
|
|
1015
1053
|
}), /* @__PURE__ */ Z("div", {
|
|
1016
1054
|
className: "markweave-codeblock-language-list",
|
|
1017
1055
|
children: ue.map((e) => {
|
|
@@ -1024,7 +1062,7 @@ function vr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1024
1062
|
"data-active": t ? "true" : "false",
|
|
1025
1063
|
onMouseDown: (e) => e.preventDefault(),
|
|
1026
1064
|
onClick: () => B(e.language),
|
|
1027
|
-
children: [/* @__PURE__ */ Z("span", { children: e.label }), t ? /* @__PURE__ */ Z(
|
|
1065
|
+
children: [/* @__PURE__ */ Z("span", { children: e.label }), t ? /* @__PURE__ */ Z(yr, { icon: "check" }) : null]
|
|
1028
1066
|
}, e.language);
|
|
1029
1067
|
})
|
|
1030
1068
|
})]
|
|
@@ -1049,13 +1087,13 @@ function vr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1049
1087
|
onMouseLeave: () => O(null),
|
|
1050
1088
|
onFocus: () => O("zoom-out"),
|
|
1051
1089
|
onBlur: () => O(null),
|
|
1052
|
-
onClick: () =>
|
|
1053
|
-
children: /* @__PURE__ */ Z(
|
|
1090
|
+
onClick: () => K(-sn),
|
|
1091
|
+
children: /* @__PURE__ */ Z(yr, { icon: "zoomOut" })
|
|
1054
1092
|
}),
|
|
1055
1093
|
/* @__PURE__ */ Z("span", {
|
|
1056
1094
|
className: "markweave-mermaid-fullscreen-zoom-label",
|
|
1057
1095
|
"data-testid": "markweave-mermaid-fullscreen-zoom-label",
|
|
1058
|
-
children:
|
|
1096
|
+
children: Yt(T.scale)
|
|
1059
1097
|
}),
|
|
1060
1098
|
/* @__PURE__ */ Z("button", {
|
|
1061
1099
|
type: "button",
|
|
@@ -1066,8 +1104,8 @@ function vr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1066
1104
|
onMouseLeave: () => O(null),
|
|
1067
1105
|
onFocus: () => O("zoom-in"),
|
|
1068
1106
|
onBlur: () => O(null),
|
|
1069
|
-
onClick: () =>
|
|
1070
|
-
children: /* @__PURE__ */ Z(
|
|
1107
|
+
onClick: () => K(sn),
|
|
1108
|
+
children: /* @__PURE__ */ Z(yr, { icon: "zoomIn" })
|
|
1071
1109
|
}),
|
|
1072
1110
|
/* @__PURE__ */ Z("button", {
|
|
1073
1111
|
type: "button",
|
|
@@ -1079,7 +1117,7 @@ function vr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1079
1117
|
onFocus: () => O("reset"),
|
|
1080
1118
|
onBlur: () => O(null),
|
|
1081
1119
|
onClick: q,
|
|
1082
|
-
children: /* @__PURE__ */ Z(
|
|
1120
|
+
children: /* @__PURE__ */ Z(yr, { icon: "reset" })
|
|
1083
1121
|
}),
|
|
1084
1122
|
D ? /* @__PURE__ */ Z("span", {
|
|
1085
1123
|
className: "markweave-mermaid-fullscreen-tooltip",
|
|
@@ -1094,8 +1132,8 @@ function vr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1094
1132
|
className: "markweave-mermaid-fullscreen-close",
|
|
1095
1133
|
"aria-label": "Close fullscreen Mermaid preview",
|
|
1096
1134
|
"data-testid": "markweave-mermaid-fullscreen-close",
|
|
1097
|
-
onClick:
|
|
1098
|
-
children: /* @__PURE__ */ Z(
|
|
1135
|
+
onClick: _e,
|
|
1136
|
+
children: /* @__PURE__ */ Z(yr, { icon: "close" })
|
|
1099
1137
|
}),
|
|
1100
1138
|
/* @__PURE__ */ Z("div", {
|
|
1101
1139
|
className: "markweave-mermaid-fullscreen-viewport",
|
|
@@ -1126,25 +1164,25 @@ function vr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1126
1164
|
}
|
|
1127
1165
|
//#endregion
|
|
1128
1166
|
//#region src/ui/floating-toolbar/FloatingToolbar.tsx
|
|
1129
|
-
var
|
|
1130
|
-
function
|
|
1167
|
+
var xr = Ae("zh");
|
|
1168
|
+
function Sr() {
|
|
1131
1169
|
return typeof performance > "u" ? Date.now() : performance.now();
|
|
1132
1170
|
}
|
|
1133
|
-
function
|
|
1171
|
+
function Cr(e, t) {
|
|
1134
1172
|
return {
|
|
1135
1173
|
"--markweave-toolbar-motion-duration": `${e.motionDurationMs}ms`,
|
|
1136
1174
|
"--markweave-toolbar-motion-easing": e.motionEasing,
|
|
1137
1175
|
marginLeft: t === 0 ? void 0 : `${t}px`
|
|
1138
1176
|
};
|
|
1139
1177
|
}
|
|
1140
|
-
function
|
|
1178
|
+
function wr(e, t) {
|
|
1141
1179
|
let n = e?.getBoundingClientRect().height ?? 0, r = t?.getBoundingClientRect().height ?? 0;
|
|
1142
1180
|
return Math.max(n, r, 44);
|
|
1143
1181
|
}
|
|
1144
|
-
function
|
|
1182
|
+
function Tr(e) {
|
|
1145
1183
|
if (e !== null) return { "--markweave-floating-toolbar-tooltip-left": `${e}px` };
|
|
1146
1184
|
}
|
|
1147
|
-
function
|
|
1185
|
+
function Er(e, t, n, r) {
|
|
1148
1186
|
let i = {
|
|
1149
1187
|
bottom: t + r,
|
|
1150
1188
|
height: r,
|
|
@@ -1160,26 +1198,26 @@ function wr(e, t, n, r) {
|
|
|
1160
1198
|
toJSON: () => i
|
|
1161
1199
|
};
|
|
1162
1200
|
}
|
|
1163
|
-
function
|
|
1201
|
+
function Dr(e) {
|
|
1164
1202
|
return e.width > 0 && e.height > 0;
|
|
1165
1203
|
}
|
|
1166
|
-
function
|
|
1204
|
+
function Or(e) {
|
|
1167
1205
|
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));
|
|
1168
|
-
return
|
|
1206
|
+
return Er(t, n, r - t, i - n);
|
|
1169
1207
|
}
|
|
1170
|
-
function
|
|
1208
|
+
function kr(e, t) {
|
|
1171
1209
|
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;
|
|
1172
1210
|
return r(t.anchorNode) && r(t.focusNode);
|
|
1173
1211
|
}
|
|
1174
|
-
function
|
|
1212
|
+
function Ar(e) {
|
|
1175
1213
|
if (typeof e.getClientRects != "function") return null;
|
|
1176
|
-
let t = Array.from(e.getClientRects()).filter(
|
|
1214
|
+
let t = Array.from(e.getClientRects()).filter(Dr).map((e) => Er(e.left, e.top, e.width, e.height));
|
|
1177
1215
|
if (t.length > 0) return t;
|
|
1178
1216
|
if (typeof e.getBoundingClientRect != "function") return null;
|
|
1179
1217
|
let n = e.getBoundingClientRect();
|
|
1180
|
-
return
|
|
1218
|
+
return Dr(n) ? [Er(n.left, n.top, n.width, n.height)] : null;
|
|
1181
1219
|
}
|
|
1182
|
-
function
|
|
1220
|
+
function jr(e, t) {
|
|
1183
1221
|
if (t.rangeCount === 0) return null;
|
|
1184
1222
|
let n = t.getRangeAt(0);
|
|
1185
1223
|
try {
|
|
@@ -1192,8 +1230,8 @@ function kr(e, t) {
|
|
|
1192
1230
|
return null;
|
|
1193
1231
|
}
|
|
1194
1232
|
}
|
|
1195
|
-
function
|
|
1196
|
-
let n =
|
|
1233
|
+
function Mr(e, t) {
|
|
1234
|
+
let n = jr(e, t);
|
|
1197
1235
|
if (!n) return !1;
|
|
1198
1236
|
let { selection: r } = e.state, i = {
|
|
1199
1237
|
from: Math.min(r.from, r.to),
|
|
@@ -1201,51 +1239,51 @@ function Ar(e, t) {
|
|
|
1201
1239
|
};
|
|
1202
1240
|
return n.from === i.from && n.to === i.to;
|
|
1203
1241
|
}
|
|
1204
|
-
function
|
|
1242
|
+
function Nr(e) {
|
|
1205
1243
|
let t = e.view.dom.ownerDocument.getSelection();
|
|
1206
|
-
return !t || t.rangeCount === 0 || t.isCollapsed || !
|
|
1244
|
+
return !t || t.rangeCount === 0 || t.isCollapsed || !kr(e, t) || !Mr(e, t) ? null : Ar(t.getRangeAt(0));
|
|
1207
1245
|
}
|
|
1208
|
-
function
|
|
1246
|
+
function Pr(e) {
|
|
1209
1247
|
let { selection: t } = e.state;
|
|
1210
1248
|
if (t.empty) return null;
|
|
1211
1249
|
let n = Math.min(t.from, t.to), r = Math.max(t.from, t.to);
|
|
1212
1250
|
try {
|
|
1213
1251
|
let t = e.view.domAtPos(n), i = e.view.domAtPos(r), a = e.view.dom.ownerDocument.createRange();
|
|
1214
|
-
return a.setStart(t.node, t.offset), a.setEnd(i.node, i.offset),
|
|
1252
|
+
return a.setStart(t.node, t.offset), a.setEnd(i.node, i.offset), Ar(a);
|
|
1215
1253
|
} catch {
|
|
1216
1254
|
return null;
|
|
1217
1255
|
}
|
|
1218
1256
|
}
|
|
1219
|
-
function
|
|
1257
|
+
function Fr(e) {
|
|
1220
1258
|
let { selection: t } = e.state;
|
|
1221
1259
|
if (t.empty) return null;
|
|
1222
|
-
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 =
|
|
1223
|
-
return
|
|
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 = Er(c, o, Math.max(i.right, a.right) - c, s - o);
|
|
1261
|
+
return Dr(l) ? [l] : null;
|
|
1224
1262
|
}
|
|
1225
|
-
function
|
|
1226
|
-
return
|
|
1263
|
+
function Ir(e) {
|
|
1264
|
+
return Nr(e) ?? Pr(e) ?? Fr(e);
|
|
1227
1265
|
}
|
|
1228
|
-
function
|
|
1229
|
-
let t =
|
|
1230
|
-
return t && t.length > 0 ?
|
|
1266
|
+
function Lr(e) {
|
|
1267
|
+
let t = Ir(e);
|
|
1268
|
+
return t && t.length > 0 ? Or(t) : null;
|
|
1231
1269
|
}
|
|
1232
|
-
function
|
|
1270
|
+
function Rr(e) {
|
|
1233
1271
|
return {
|
|
1234
|
-
getBoundingClientRect: () =>
|
|
1235
|
-
getClientRects: () =>
|
|
1272
|
+
getBoundingClientRect: () => Lr(e) ?? Er(0, 0, 0, 0),
|
|
1273
|
+
getClientRects: () => Ir(e) ?? []
|
|
1236
1274
|
};
|
|
1237
1275
|
}
|
|
1238
|
-
function
|
|
1276
|
+
function zr(e) {
|
|
1239
1277
|
return e === "block-type" || e === "link" || e === "color" || e === "more";
|
|
1240
1278
|
}
|
|
1241
|
-
function
|
|
1242
|
-
n?.(
|
|
1279
|
+
function Br(e, t, n) {
|
|
1280
|
+
n?.(dn(e, t)), e.commands.focus();
|
|
1243
1281
|
}
|
|
1244
|
-
function
|
|
1245
|
-
let i = U(() =>
|
|
1282
|
+
function Vr({ editor: e, messages: t = xr, selectionSnapshot: n, onRewriteSelection: r }) {
|
|
1283
|
+
let i = U(() => gn(t), [t]), a = Ze(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, C] = G(a.boundaryPadding), w = W(0), T = W(null), E = W(null), D = W(null), O = fn(e, o.variant, t), k = vn(O.find((e) => e.id === c) ?? null), A = kn(m), j = V(() => {
|
|
1246
1284
|
let t = T.current, n = e.view.dom.closest(".markweave-editor-frame");
|
|
1247
1285
|
if (!t || !(n instanceof HTMLElement)) return;
|
|
1248
|
-
let r = t.getBoundingClientRect(), i = n.getBoundingClientRect(), a =
|
|
1286
|
+
let r = t.getBoundingClientRect(), i = n.getBoundingClientRect(), a = wr(t, E.current), s = w.current, c = qe({
|
|
1249
1287
|
toolbarRect: {
|
|
1250
1288
|
left: r.left - s,
|
|
1251
1289
|
top: r.top,
|
|
@@ -1259,7 +1297,7 @@ function zr({ editor: e, messages: t = yr, selectionSnapshot: n, onRewriteSelect
|
|
|
1259
1297
|
height: i.height
|
|
1260
1298
|
},
|
|
1261
1299
|
boundaryPadding: o.boundaryPadding
|
|
1262
|
-
}), l =
|
|
1300
|
+
}), l = Je({
|
|
1263
1301
|
frameRect: {
|
|
1264
1302
|
left: i.left,
|
|
1265
1303
|
top: i.top,
|
|
@@ -1278,12 +1316,12 @@ function zr({ editor: e, messages: t = yr, selectionSnapshot: n, onRewriteSelect
|
|
|
1278
1316
|
e.view.dom,
|
|
1279
1317
|
o.boundaryPadding,
|
|
1280
1318
|
o.offset
|
|
1281
|
-
]), M =
|
|
1319
|
+
]), M = V(() => {
|
|
1282
1320
|
T.current && (T.current.style.visibility = "hidden", T.current.style.opacity = "0");
|
|
1283
|
-
}, []), N =
|
|
1321
|
+
}, []), N = V(() => {
|
|
1284
1322
|
j();
|
|
1285
|
-
}, [j]), P =
|
|
1286
|
-
...
|
|
1323
|
+
}, [j]), P = V(() => Rr(e), [e]), F = U(() => ({
|
|
1324
|
+
...Xe(o, { topBoundaryPadding: S }),
|
|
1287
1325
|
onShow: M,
|
|
1288
1326
|
onUpdate: N
|
|
1289
1327
|
}), [
|
|
@@ -1292,9 +1330,9 @@ function zr({ editor: e, messages: t = yr, selectionSnapshot: n, onRewriteSelect
|
|
|
1292
1330
|
o,
|
|
1293
1331
|
S
|
|
1294
1332
|
]);
|
|
1295
|
-
|
|
1296
|
-
let e =
|
|
1297
|
-
s((t) =>
|
|
1333
|
+
H(() => {
|
|
1334
|
+
let e = Sr();
|
|
1335
|
+
s((t) => $e(t, a, e));
|
|
1298
1336
|
}, [
|
|
1299
1337
|
a.hiddenReason,
|
|
1300
1338
|
a.motionDurationMs,
|
|
@@ -1306,10 +1344,10 @@ function zr({ editor: e, messages: t = yr, selectionSnapshot: n, onRewriteSelect
|
|
|
1306
1344
|
a.updateDelayMs,
|
|
1307
1345
|
a.variant,
|
|
1308
1346
|
a.visibility
|
|
1309
|
-
]),
|
|
1347
|
+
]), H(() => {
|
|
1310
1348
|
if (o.motionStartedAtMs === null || o.motionDurationMs <= 0) return;
|
|
1311
|
-
let e = Math.max(0, o.motionStartedAtMs + o.motionDurationMs -
|
|
1312
|
-
s((e) =>
|
|
1349
|
+
let e = Math.max(0, o.motionStartedAtMs + o.motionDurationMs - Sr()), t = window.setTimeout(() => {
|
|
1350
|
+
s((e) => Ke(e, Sr()));
|
|
1313
1351
|
}, e);
|
|
1314
1352
|
return () => {
|
|
1315
1353
|
window.clearTimeout(t);
|
|
@@ -1318,7 +1356,7 @@ function zr({ editor: e, messages: t = yr, selectionSnapshot: n, onRewriteSelect
|
|
|
1318
1356
|
o.motionDurationMs,
|
|
1319
1357
|
o.motionPhase,
|
|
1320
1358
|
o.motionStartedAtMs
|
|
1321
|
-
]),
|
|
1359
|
+
]), me(() => {
|
|
1322
1360
|
if (o.visibility !== "visible") {
|
|
1323
1361
|
w.current = 0, T.current && (T.current.style.marginLeft = "", T.current.style.visibility = "hidden", T.current.style.opacity = "0"), x(0), C(o.boundaryPadding);
|
|
1324
1362
|
return;
|
|
@@ -1336,14 +1374,14 @@ function zr({ editor: e, messages: t = yr, selectionSnapshot: n, onRewriteSelect
|
|
|
1336
1374
|
o.variant,
|
|
1337
1375
|
o.visibility,
|
|
1338
1376
|
O.length
|
|
1339
|
-
]),
|
|
1377
|
+
]), H(() => {
|
|
1340
1378
|
f === "more" && i.some((e) => e.id === c) || O.some((e) => e.id === c) || (l(null), d(null));
|
|
1341
1379
|
}, [
|
|
1342
1380
|
i,
|
|
1343
1381
|
f,
|
|
1344
1382
|
c,
|
|
1345
1383
|
O
|
|
1346
|
-
]),
|
|
1384
|
+
]), H(() => {
|
|
1347
1385
|
if (!f) return;
|
|
1348
1386
|
let t = (e) => {
|
|
1349
1387
|
E.current?.contains(e.target) || p(null);
|
|
@@ -1353,7 +1391,7 @@ function zr({ editor: e, messages: t = yr, selectionSnapshot: n, onRewriteSelect
|
|
|
1353
1391
|
return document.addEventListener("pointerdown", t, !0), document.addEventListener("keydown", n, !0), () => {
|
|
1354
1392
|
document.removeEventListener("pointerdown", t, !0), document.removeEventListener("keydown", n, !0);
|
|
1355
1393
|
};
|
|
1356
|
-
}, [e, f]),
|
|
1394
|
+
}, [e, f]), H(() => {
|
|
1357
1395
|
if (f !== "link") return;
|
|
1358
1396
|
let e = window.requestAnimationFrame(() => {
|
|
1359
1397
|
D.current?.focus(), D.current?.select();
|
|
@@ -1361,10 +1399,10 @@ function zr({ editor: e, messages: t = yr, selectionSnapshot: n, onRewriteSelect
|
|
|
1361
1399
|
return () => window.cancelAnimationFrame(e);
|
|
1362
1400
|
}, [f]);
|
|
1363
1401
|
let I = (t) => {
|
|
1364
|
-
if (
|
|
1402
|
+
if (zr(t.id)) {
|
|
1365
1403
|
let n = t.id;
|
|
1366
1404
|
if (n === "link") {
|
|
1367
|
-
let t =
|
|
1405
|
+
let t = mn(e);
|
|
1368
1406
|
h(t), _(t), y({
|
|
1369
1407
|
from: Math.min(e.state.selection.from, e.state.selection.to),
|
|
1370
1408
|
to: Math.max(e.state.selection.from, e.state.selection.to)
|
|
@@ -1374,7 +1412,7 @@ function zr({ editor: e, messages: t = yr, selectionSnapshot: n, onRewriteSelect
|
|
|
1374
1412
|
return;
|
|
1375
1413
|
}
|
|
1376
1414
|
if (p(null), t.id === "improve") {
|
|
1377
|
-
|
|
1415
|
+
Br(e, "rewrite-selection", r);
|
|
1378
1416
|
return;
|
|
1379
1417
|
}
|
|
1380
1418
|
t.run(), e.commands.focus();
|
|
@@ -1383,9 +1421,9 @@ function zr({ editor: e, messages: t = yr, selectionSnapshot: n, onRewriteSelect
|
|
|
1383
1421
|
}, L = () => {
|
|
1384
1422
|
v && e.commands.setTextSelection(v);
|
|
1385
1423
|
}, R = () => {
|
|
1386
|
-
L(),
|
|
1424
|
+
L(), un(e, m) && ee();
|
|
1387
1425
|
}, te = () => {
|
|
1388
|
-
if (L(),
|
|
1426
|
+
if (L(), wn(e)) {
|
|
1389
1427
|
h(""), _(""), ee();
|
|
1390
1428
|
return;
|
|
1391
1429
|
}
|
|
@@ -1398,7 +1436,7 @@ function zr({ editor: e, messages: t = yr, selectionSnapshot: n, onRewriteSelect
|
|
|
1398
1436
|
let n = t.getBoundingClientRect(), r = E.current.getBoundingClientRect();
|
|
1399
1437
|
d(n.left + n.width / 2 - r.left);
|
|
1400
1438
|
};
|
|
1401
|
-
return /* @__PURE__ */ Z(
|
|
1439
|
+
return /* @__PURE__ */ Z(ln, {
|
|
1402
1440
|
ref: T,
|
|
1403
1441
|
editor: e,
|
|
1404
1442
|
className: `markweave-floating-toolbar markweave-floating-toolbar--${o.variant} markweave-floating-toolbar--motion-${o.motionPhase}`,
|
|
@@ -1406,31 +1444,31 @@ function zr({ editor: e, messages: t = yr, selectionSnapshot: n, onRewriteSelect
|
|
|
1406
1444
|
"data-position-strategy": F.strategy,
|
|
1407
1445
|
"data-boundary-padding": o.boundaryPadding,
|
|
1408
1446
|
"data-testid": "markweave-floating-toolbar",
|
|
1409
|
-
style:
|
|
1447
|
+
style: Cr(o, b),
|
|
1410
1448
|
updateDelay: 0,
|
|
1411
1449
|
getReferencedVirtualElement: P,
|
|
1412
1450
|
options: F,
|
|
1413
|
-
shouldShow: ({ editor: e }) => e.isEditable &&
|
|
1451
|
+
shouldShow: ({ editor: e }) => e.isEditable && Qe(Ye(e)),
|
|
1414
1452
|
children: /* @__PURE__ */ Q("div", {
|
|
1415
1453
|
ref: E,
|
|
1416
1454
|
className: "markweave-floating-toolbar-content",
|
|
1417
1455
|
"data-menu": f ?? "none",
|
|
1418
1456
|
children: [
|
|
1419
|
-
O.map((e, t) => /* @__PURE__ */ Z(
|
|
1457
|
+
O.map((e, t) => /* @__PURE__ */ Z(Ur, {
|
|
1420
1458
|
button: e,
|
|
1421
1459
|
expanded: f === e.id,
|
|
1422
1460
|
showDivider: t > 0 && O[t - 1].group !== e.group,
|
|
1423
1461
|
tooltipActive: c === e.id,
|
|
1424
|
-
onPointerDown:
|
|
1462
|
+
onPointerDown: Cn,
|
|
1425
1463
|
onTooltipChange: z,
|
|
1426
1464
|
onRun: I
|
|
1427
1465
|
}, e.id)),
|
|
1428
|
-
f === "block-type" ? /* @__PURE__ */ Z(
|
|
1466
|
+
f === "block-type" ? /* @__PURE__ */ Z(Gr, {
|
|
1429
1467
|
editor: e,
|
|
1430
1468
|
messages: t,
|
|
1431
1469
|
onClose: () => p(null)
|
|
1432
1470
|
}) : null,
|
|
1433
|
-
f === "link" ? /* @__PURE__ */ Z(
|
|
1471
|
+
f === "link" ? /* @__PURE__ */ Z(Hr, {
|
|
1434
1472
|
inputRef: D,
|
|
1435
1473
|
messages: t,
|
|
1436
1474
|
value: m,
|
|
@@ -1439,15 +1477,15 @@ function zr({ editor: e, messages: t = yr, selectionSnapshot: n, onRewriteSelect
|
|
|
1439
1477
|
canRemove: !!(g || m.trim()),
|
|
1440
1478
|
onValueChange: h,
|
|
1441
1479
|
onApply: R,
|
|
1442
|
-
onOpen: () =>
|
|
1480
|
+
onOpen: () => Sn(m),
|
|
1443
1481
|
onRemove: te
|
|
1444
1482
|
}) : null,
|
|
1445
|
-
f === "color" ? /* @__PURE__ */ Z(
|
|
1483
|
+
f === "color" ? /* @__PURE__ */ Z(qr, {
|
|
1446
1484
|
editor: e,
|
|
1447
1485
|
messages: t,
|
|
1448
1486
|
onClose: () => p(null)
|
|
1449
1487
|
}) : null,
|
|
1450
|
-
f === "more" ? /* @__PURE__ */ Z(
|
|
1488
|
+
f === "more" ? /* @__PURE__ */ Z(Yr, {
|
|
1451
1489
|
editor: e,
|
|
1452
1490
|
messages: t,
|
|
1453
1491
|
activeTooltipId: c,
|
|
@@ -1460,15 +1498,15 @@ function zr({ editor: e, messages: t = yr, selectionSnapshot: n, onRewriteSelect
|
|
|
1460
1498
|
"data-testid": "markweave-floating-toolbar-tooltip",
|
|
1461
1499
|
"data-button-id": k.buttonId,
|
|
1462
1500
|
"data-active": k.active,
|
|
1463
|
-
style:
|
|
1501
|
+
style: Tr(u),
|
|
1464
1502
|
children: k.label
|
|
1465
1503
|
}) : null
|
|
1466
1504
|
]
|
|
1467
1505
|
})
|
|
1468
1506
|
});
|
|
1469
1507
|
}
|
|
1470
|
-
function
|
|
1471
|
-
let u =
|
|
1508
|
+
function Hr({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRemove: a, onValueChange: o, onApply: s, onOpen: c, onRemove: l }) {
|
|
1509
|
+
let u = hn(t);
|
|
1472
1510
|
return /* @__PURE__ */ Q("form", {
|
|
1473
1511
|
className: "markweave-floating-toolbar-popover markweave-floating-toolbar-link-popover",
|
|
1474
1512
|
"data-testid": "markweave-floating-toolbar-link-popover",
|
|
@@ -1490,7 +1528,7 @@ function Br({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRe
|
|
|
1490
1528
|
"aria-label": u.applyLink,
|
|
1491
1529
|
"data-testid": "markweave-floating-toolbar-link-apply",
|
|
1492
1530
|
disabled: !r,
|
|
1493
|
-
onMouseDown:
|
|
1531
|
+
onMouseDown: Cn,
|
|
1494
1532
|
children: /* @__PURE__ */ Z($, { name: "corner-down-left" })
|
|
1495
1533
|
}),
|
|
1496
1534
|
/* @__PURE__ */ Z("span", {
|
|
@@ -1502,7 +1540,7 @@ function Br({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRe
|
|
|
1502
1540
|
"aria-label": u.openLink,
|
|
1503
1541
|
"data-testid": "markweave-floating-toolbar-link-open",
|
|
1504
1542
|
disabled: !i,
|
|
1505
|
-
onMouseDown:
|
|
1543
|
+
onMouseDown: Cn,
|
|
1506
1544
|
onClick: c,
|
|
1507
1545
|
children: /* @__PURE__ */ Z($, { name: "external-link" })
|
|
1508
1546
|
}),
|
|
@@ -1511,7 +1549,7 @@ function Br({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRe
|
|
|
1511
1549
|
"aria-label": u.removeLink,
|
|
1512
1550
|
"data-testid": "markweave-floating-toolbar-link-remove",
|
|
1513
1551
|
disabled: !a,
|
|
1514
|
-
onMouseDown:
|
|
1552
|
+
onMouseDown: Cn,
|
|
1515
1553
|
onClick: l,
|
|
1516
1554
|
children: /* @__PURE__ */ Z($, { name: "trash" })
|
|
1517
1555
|
})
|
|
@@ -1519,7 +1557,7 @@ function Br({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRe
|
|
|
1519
1557
|
})]
|
|
1520
1558
|
});
|
|
1521
1559
|
}
|
|
1522
|
-
function
|
|
1560
|
+
function Ur({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointerDown: i, onTooltipChange: a, onRun: o }) {
|
|
1523
1561
|
return /* @__PURE__ */ Q(X, { children: [n ? /* @__PURE__ */ Z("span", {
|
|
1524
1562
|
className: "markweave-floating-toolbar-divider",
|
|
1525
1563
|
"aria-hidden": "true"
|
|
@@ -1527,7 +1565,7 @@ function Vr({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointe
|
|
|
1527
1565
|
type: "button",
|
|
1528
1566
|
className: `markweave-floating-toolbar-button markweave-floating-toolbar-button--${e.id}`,
|
|
1529
1567
|
"aria-label": e.label,
|
|
1530
|
-
"aria-expanded":
|
|
1568
|
+
"aria-expanded": zr(e.id) ? t : void 0,
|
|
1531
1569
|
"data-active": e.active || t,
|
|
1532
1570
|
"data-tooltip-active": r ? "true" : "false",
|
|
1533
1571
|
"data-testid": `markweave-floating-toolbar-button-${e.id}`,
|
|
@@ -1537,13 +1575,13 @@ function Vr({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointe
|
|
|
1537
1575
|
onMouseEnter: (t) => a(e.id, t.currentTarget),
|
|
1538
1576
|
onMouseLeave: () => a(null),
|
|
1539
1577
|
onClick: () => o(e),
|
|
1540
|
-
children: /* @__PURE__ */ Z(
|
|
1578
|
+
children: /* @__PURE__ */ Z(Wr, {
|
|
1541
1579
|
button: e,
|
|
1542
1580
|
expanded: t
|
|
1543
1581
|
})
|
|
1544
1582
|
})] });
|
|
1545
1583
|
}
|
|
1546
|
-
function
|
|
1584
|
+
function Wr({ button: e, expanded: t }) {
|
|
1547
1585
|
return e.id === "improve" ? /* @__PURE__ */ Q("span", {
|
|
1548
1586
|
className: "markweave-floating-toolbar-button-inner",
|
|
1549
1587
|
children: [/* @__PURE__ */ Z($, { name: "sparkles" }), /* @__PURE__ */ Z("span", { children: e.glyph })]
|
|
@@ -1561,8 +1599,8 @@ function Hr({ button: e, expanded: t }) {
|
|
|
1561
1599
|
}), /* @__PURE__ */ Z($, { name: t ? "chevron-up" : "chevron-down" })]
|
|
1562
1600
|
}) : /* @__PURE__ */ Z($, { name: "more" });
|
|
1563
1601
|
}
|
|
1564
|
-
function
|
|
1565
|
-
let r =
|
|
1602
|
+
function Gr({ editor: e, messages: t, onClose: n }) {
|
|
1603
|
+
let r = hn(t), i = yn(t);
|
|
1566
1604
|
return /* @__PURE__ */ Q("div", {
|
|
1567
1605
|
className: "markweave-floating-toolbar-popover markweave-floating-toolbar-turn-menu",
|
|
1568
1606
|
"data-testid": "markweave-floating-toolbar-turn-menu",
|
|
@@ -1571,47 +1609,47 @@ function Ur({ editor: e, messages: t, onClose: n }) {
|
|
|
1571
1609
|
children: r.turnIntoTitle
|
|
1572
1610
|
}), i.map((t) => /* @__PURE__ */ Q("button", {
|
|
1573
1611
|
type: "button",
|
|
1574
|
-
"data-active":
|
|
1612
|
+
"data-active": xn(e, t.id),
|
|
1575
1613
|
"data-testid": `markweave-floating-toolbar-turn-${t.id}`,
|
|
1576
|
-
onMouseDown:
|
|
1614
|
+
onMouseDown: Cn,
|
|
1577
1615
|
onClick: () => {
|
|
1578
|
-
|
|
1616
|
+
On(e, t.id), n();
|
|
1579
1617
|
},
|
|
1580
1618
|
children: [/* @__PURE__ */ Z("span", {
|
|
1581
1619
|
className: "markweave-floating-toolbar-menu-icon",
|
|
1582
|
-
children: /* @__PURE__ */ Z(
|
|
1620
|
+
children: /* @__PURE__ */ Z(Kr, { option: t })
|
|
1583
1621
|
}), /* @__PURE__ */ Z("span", { children: t.label })]
|
|
1584
1622
|
}, t.id))]
|
|
1585
1623
|
});
|
|
1586
1624
|
}
|
|
1587
|
-
function
|
|
1625
|
+
function Kr({ option: e }) {
|
|
1588
1626
|
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 });
|
|
1589
1627
|
}
|
|
1590
|
-
function
|
|
1591
|
-
let r =
|
|
1628
|
+
function qr({ editor: e, messages: t, onClose: n }) {
|
|
1629
|
+
let r = hn(t), i = e.getAttributes("textStyle").color, a = e.getAttributes("highlight").color;
|
|
1592
1630
|
return /* @__PURE__ */ Q("div", {
|
|
1593
1631
|
className: "markweave-floating-toolbar-popover markweave-floating-toolbar-color-popover",
|
|
1594
1632
|
"data-testid": "markweave-floating-toolbar-color-menu",
|
|
1595
|
-
children: [/* @__PURE__ */ Z(
|
|
1633
|
+
children: [/* @__PURE__ */ Z(Jr, {
|
|
1596
1634
|
title: r.textColorTitle,
|
|
1597
1635
|
mode: "text",
|
|
1598
1636
|
activeColor: i ?? null,
|
|
1599
|
-
options:
|
|
1637
|
+
options: _n(t),
|
|
1600
1638
|
onSelect: (t) => {
|
|
1601
|
-
|
|
1639
|
+
Dn(e, t), n();
|
|
1602
1640
|
}
|
|
1603
|
-
}), /* @__PURE__ */ Z(
|
|
1641
|
+
}), /* @__PURE__ */ Z(Jr, {
|
|
1604
1642
|
title: r.highlightColorTitle,
|
|
1605
1643
|
mode: "highlight",
|
|
1606
1644
|
activeColor: a ?? null,
|
|
1607
|
-
options:
|
|
1645
|
+
options: pn(t),
|
|
1608
1646
|
onSelect: (t) => {
|
|
1609
|
-
|
|
1647
|
+
En(e, t), n();
|
|
1610
1648
|
}
|
|
1611
1649
|
})]
|
|
1612
1650
|
});
|
|
1613
1651
|
}
|
|
1614
|
-
function
|
|
1652
|
+
function Jr({ title: e, mode: t, activeColor: n, options: r, onSelect: i }) {
|
|
1615
1653
|
return /* @__PURE__ */ Q("section", {
|
|
1616
1654
|
className: "markweave-floating-toolbar-color-section",
|
|
1617
1655
|
"aria-label": e,
|
|
@@ -1625,7 +1663,7 @@ function Kr({ title: e, mode: t, activeColor: n, options: r, onSelect: i }) {
|
|
|
1625
1663
|
"aria-label": e.label,
|
|
1626
1664
|
"data-active": e.value === n || e.value === null && !n,
|
|
1627
1665
|
"data-testid": `markweave-floating-toolbar-${t}-${e.id}`,
|
|
1628
|
-
onMouseDown:
|
|
1666
|
+
onMouseDown: Cn,
|
|
1629
1667
|
onClick: () => i(e.value),
|
|
1630
1668
|
children: t === "text" ? /* @__PURE__ */ Z("span", {
|
|
1631
1669
|
className: "markweave-floating-toolbar-text-swatch",
|
|
@@ -1640,24 +1678,24 @@ function Kr({ title: e, mode: t, activeColor: n, options: r, onSelect: i }) {
|
|
|
1640
1678
|
})]
|
|
1641
1679
|
});
|
|
1642
1680
|
}
|
|
1643
|
-
function
|
|
1644
|
-
let a =
|
|
1681
|
+
function Yr({ editor: e, messages: t, activeTooltipId: n, onTooltipChange: r, onClose: i }) {
|
|
1682
|
+
let a = gn(t);
|
|
1645
1683
|
return /* @__PURE__ */ Z("div", {
|
|
1646
1684
|
className: "markweave-floating-toolbar-popover markweave-floating-toolbar-more-menu",
|
|
1647
1685
|
"data-testid": "markweave-floating-toolbar-more-menu",
|
|
1648
|
-
children: a.map((t, o) => /* @__PURE__ */ Z(
|
|
1686
|
+
children: a.map((t, o) => /* @__PURE__ */ Z(Xr, {
|
|
1649
1687
|
action: t,
|
|
1650
|
-
active:
|
|
1688
|
+
active: bn(e, t.id),
|
|
1651
1689
|
tooltipActive: n === t.id,
|
|
1652
1690
|
showDivider: o > 0 && a[o - 1].group !== t.group,
|
|
1653
1691
|
onTooltipChange: r,
|
|
1654
1692
|
onRun: () => {
|
|
1655
|
-
|
|
1693
|
+
Tn(e, t.id), i();
|
|
1656
1694
|
}
|
|
1657
1695
|
}, t.id))
|
|
1658
1696
|
});
|
|
1659
1697
|
}
|
|
1660
|
-
function
|
|
1698
|
+
function Xr({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipChange: i, onRun: a }) {
|
|
1661
1699
|
return /* @__PURE__ */ Q(X, { children: [r ? /* @__PURE__ */ Z("span", {
|
|
1662
1700
|
className: "markweave-floating-toolbar-divider",
|
|
1663
1701
|
"aria-hidden": "true"
|
|
@@ -1669,11 +1707,11 @@ function Jr({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipC
|
|
|
1669
1707
|
"data-active": t,
|
|
1670
1708
|
"data-tooltip-active": n ? "true" : "false",
|
|
1671
1709
|
"data-testid": `markweave-floating-toolbar-more-${e.id}`,
|
|
1672
|
-
onMouseDown:
|
|
1710
|
+
onMouseDown: Cn,
|
|
1673
1711
|
onMouseEnter: () => i(e.id),
|
|
1674
1712
|
onMouseLeave: () => i(null),
|
|
1675
1713
|
onClick: a,
|
|
1676
|
-
children: /* @__PURE__ */ Z(
|
|
1714
|
+
children: /* @__PURE__ */ Z(Zr, { id: e.id })
|
|
1677
1715
|
}), n ? /* @__PURE__ */ Z("div", {
|
|
1678
1716
|
className: "markweave-floating-toolbar-tooltip markweave-floating-toolbar-tooltip--more",
|
|
1679
1717
|
role: "tooltip",
|
|
@@ -1681,41 +1719,41 @@ function Jr({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipC
|
|
|
1681
1719
|
}) : null]
|
|
1682
1720
|
})] });
|
|
1683
1721
|
}
|
|
1684
|
-
function
|
|
1722
|
+
function Zr({ id: e }) {
|
|
1685
1723
|
return e === "superscript" ? /* @__PURE__ */ Z($, { name: "superscript" }) : e === "subscript" ? /* @__PURE__ */ Z($, { name: "subscript" }) : e === "inline-math" ? /* @__PURE__ */ Z($, { name: "math" }) : Z($, { name: e });
|
|
1686
1724
|
}
|
|
1687
|
-
var
|
|
1688
|
-
sparkles:
|
|
1725
|
+
var Qr = {
|
|
1726
|
+
sparkles: ie,
|
|
1689
1727
|
"chevron-down": h,
|
|
1690
1728
|
"chevron-up": g,
|
|
1691
1729
|
"corner-down-left": y,
|
|
1692
1730
|
"external-link": x,
|
|
1693
1731
|
bold: u,
|
|
1694
|
-
italic:
|
|
1695
|
-
underline:
|
|
1696
|
-
strike:
|
|
1732
|
+
italic: j,
|
|
1733
|
+
underline: fe,
|
|
1734
|
+
strike: ae,
|
|
1697
1735
|
"inline-code": v,
|
|
1698
|
-
link:
|
|
1699
|
-
more:
|
|
1700
|
-
text:
|
|
1701
|
-
"bullet-list":
|
|
1702
|
-
"numbered-list":
|
|
1703
|
-
"todo-list":
|
|
1704
|
-
quote:
|
|
1736
|
+
link: N,
|
|
1737
|
+
more: L,
|
|
1738
|
+
text: de,
|
|
1739
|
+
"bullet-list": P,
|
|
1740
|
+
"numbered-list": I,
|
|
1741
|
+
"todo-list": F,
|
|
1742
|
+
quote: te,
|
|
1705
1743
|
"code-block": d,
|
|
1706
|
-
superscript:
|
|
1707
|
-
subscript:
|
|
1708
|
-
math:
|
|
1744
|
+
superscript: se,
|
|
1745
|
+
subscript: oe,
|
|
1746
|
+
math: ne,
|
|
1709
1747
|
"align-left": c,
|
|
1710
1748
|
"align-center": o,
|
|
1711
1749
|
"align-right": l,
|
|
1712
1750
|
"align-justify": s,
|
|
1713
|
-
"decrease-indent":
|
|
1714
|
-
"increase-indent":
|
|
1715
|
-
trash:
|
|
1751
|
+
"decrease-indent": O,
|
|
1752
|
+
"increase-indent": k,
|
|
1753
|
+
trash: ue
|
|
1716
1754
|
};
|
|
1717
1755
|
function $({ name: e }) {
|
|
1718
|
-
let t =
|
|
1756
|
+
let t = Qr[e];
|
|
1719
1757
|
return /* @__PURE__ */ Z(t, {
|
|
1720
1758
|
"aria-hidden": "true",
|
|
1721
1759
|
absoluteStrokeWidth: !0,
|
|
@@ -1725,24 +1763,24 @@ function $({ name: e }) {
|
|
|
1725
1763
|
}
|
|
1726
1764
|
//#endregion
|
|
1727
1765
|
//#region src/ui/math/MathEditorPopover.tsx
|
|
1728
|
-
function
|
|
1729
|
-
let i = W(null), a = W(null), [o, s] = G(r.latex), [c, l] = G(null), u = t.math, d = U(() =>
|
|
1766
|
+
function $r({ editor: e, messages: t, onClose: n, target: r }) {
|
|
1767
|
+
let i = W(null), a = W(null), [o, s] = G(r.latex), [c, l] = G(null), u = t.math, d = U(() => ht(e, r) ?? 1, [e, r]), f = U(() => gt(e, r), [e, r]), m = U(() => o === r.latex && f ? {
|
|
1730
1768
|
html: f,
|
|
1731
1769
|
error: !1
|
|
1732
|
-
} :
|
|
1770
|
+
} : bt(o, r.kind, e), [
|
|
1733
1771
|
e,
|
|
1734
1772
|
f,
|
|
1735
1773
|
r.kind,
|
|
1736
1774
|
r.latex,
|
|
1737
1775
|
o
|
|
1738
|
-
]), h = o.trim().length > 0, g =
|
|
1776
|
+
]), h = o.trim().length > 0, g = V(() => {
|
|
1739
1777
|
if (typeof window > "u") return;
|
|
1740
|
-
let t =
|
|
1778
|
+
let t = mt(e, r), i = e.view.dom.closest(".markweave-editor-frame")?.getBoundingClientRect();
|
|
1741
1779
|
if (!t || !i) {
|
|
1742
1780
|
n();
|
|
1743
1781
|
return;
|
|
1744
1782
|
}
|
|
1745
|
-
l(
|
|
1783
|
+
l(pt({
|
|
1746
1784
|
anchorRect: t,
|
|
1747
1785
|
frameRect: i,
|
|
1748
1786
|
kind: r.kind,
|
|
@@ -1756,30 +1794,30 @@ function Zr({ editor: e, messages: t, onClose: n, target: r }) {
|
|
|
1756
1794
|
r,
|
|
1757
1795
|
o
|
|
1758
1796
|
]);
|
|
1759
|
-
|
|
1797
|
+
H(() => {
|
|
1760
1798
|
s(r.latex);
|
|
1761
|
-
}, [r.latex, r.pos]),
|
|
1762
|
-
|
|
1799
|
+
}, [r.latex, r.pos]), H(() => {
|
|
1800
|
+
xt(e, r, !0), g();
|
|
1763
1801
|
let t = window.requestAnimationFrame(() => {
|
|
1764
1802
|
a.current?.focus({ preventScroll: !0 }), a.current?.select(), g();
|
|
1765
1803
|
});
|
|
1766
1804
|
return window.addEventListener("resize", g), window.addEventListener("scroll", g, !0), () => {
|
|
1767
|
-
window.cancelAnimationFrame(t), window.removeEventListener("resize", g), window.removeEventListener("scroll", g, !0),
|
|
1805
|
+
window.cancelAnimationFrame(t), window.removeEventListener("resize", g), window.removeEventListener("scroll", g, !0), xt(e, r, !1);
|
|
1768
1806
|
};
|
|
1769
1807
|
}, [
|
|
1770
1808
|
e,
|
|
1771
1809
|
n,
|
|
1772
1810
|
r,
|
|
1773
1811
|
g
|
|
1774
|
-
]),
|
|
1812
|
+
]), H(() => {
|
|
1775
1813
|
let e = (e) => {
|
|
1776
1814
|
let t = e.target;
|
|
1777
1815
|
t instanceof Node && (i.current?.contains(t) || t instanceof Element && t.closest(".tiptap-mathematics-render") || n());
|
|
1778
1816
|
};
|
|
1779
1817
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
1780
1818
|
}, [n]);
|
|
1781
|
-
let _ =
|
|
1782
|
-
h &&
|
|
1819
|
+
let _ = V(() => {
|
|
1820
|
+
h && ft(e, r, o) && n();
|
|
1783
1821
|
}, [
|
|
1784
1822
|
h,
|
|
1785
1823
|
e,
|
|
@@ -1910,31 +1948,31 @@ function Zr({ editor: e, messages: t, onClose: n, target: r }) {
|
|
|
1910
1948
|
}
|
|
1911
1949
|
//#endregion
|
|
1912
1950
|
//#region src/ui/slash-command/SlashCommandMenu.tsx
|
|
1913
|
-
var
|
|
1914
|
-
type:
|
|
1915
|
-
"heading-1":
|
|
1916
|
-
"heading-2":
|
|
1917
|
-
"heading-3":
|
|
1918
|
-
"bullet-list":
|
|
1919
|
-
"ordered-list":
|
|
1920
|
-
"task-list":
|
|
1921
|
-
blockquote:
|
|
1951
|
+
var ei = Ae("zh"), ti = {
|
|
1952
|
+
type: le,
|
|
1953
|
+
"heading-1": C,
|
|
1954
|
+
"heading-2": w,
|
|
1955
|
+
"heading-3": T,
|
|
1956
|
+
"bullet-list": P,
|
|
1957
|
+
"ordered-list": I,
|
|
1958
|
+
"task-list": F,
|
|
1959
|
+
blockquote: te,
|
|
1922
1960
|
"code-block": d,
|
|
1923
|
-
info:
|
|
1924
|
-
tip:
|
|
1961
|
+
info: A,
|
|
1962
|
+
tip: M,
|
|
1925
1963
|
warning: a,
|
|
1926
1964
|
error: _,
|
|
1927
1965
|
success: m,
|
|
1928
|
-
emoji:
|
|
1929
|
-
math:
|
|
1930
|
-
table:
|
|
1931
|
-
separator:
|
|
1932
|
-
image:
|
|
1933
|
-
video:
|
|
1934
|
-
attachment:
|
|
1966
|
+
emoji: re,
|
|
1967
|
+
math: ne,
|
|
1968
|
+
table: ce,
|
|
1969
|
+
separator: ee,
|
|
1970
|
+
image: E,
|
|
1971
|
+
video: B,
|
|
1972
|
+
attachment: R
|
|
1935
1973
|
};
|
|
1936
|
-
function
|
|
1937
|
-
let t =
|
|
1974
|
+
function ni({ name: e }) {
|
|
1975
|
+
let t = ti[e];
|
|
1938
1976
|
return /* @__PURE__ */ Z(t, {
|
|
1939
1977
|
"aria-hidden": "true",
|
|
1940
1978
|
absoluteStrokeWidth: !0,
|
|
@@ -1942,8 +1980,8 @@ function ei({ name: e }) {
|
|
|
1942
1980
|
strokeWidth: 1.6
|
|
1943
1981
|
});
|
|
1944
1982
|
}
|
|
1945
|
-
function
|
|
1946
|
-
return !
|
|
1983
|
+
function ri(e, t, n) {
|
|
1984
|
+
return !Dt(e) || !n ? {
|
|
1947
1985
|
visible: !1,
|
|
1948
1986
|
empty: !1,
|
|
1949
1987
|
activeIndex: -1
|
|
@@ -1957,16 +1995,16 @@ function ti(e, t, n) {
|
|
|
1957
1995
|
activeIndex: Math.min(t.length - 1, Math.max(0, e.activeIndex))
|
|
1958
1996
|
};
|
|
1959
1997
|
}
|
|
1960
|
-
function
|
|
1998
|
+
function ii(e, t) {
|
|
1961
1999
|
return Object.values(t.slash.groups).map((t) => ({
|
|
1962
2000
|
group: t,
|
|
1963
2001
|
commands: e.filter((e) => e.group === t)
|
|
1964
2002
|
})).filter((e) => e.commands.length > 0);
|
|
1965
2003
|
}
|
|
1966
|
-
function
|
|
2004
|
+
function ai(e, t) {
|
|
1967
2005
|
return t.slash.uploadKindLabels[e] ?? t.slash.uploadKindLabels.upload;
|
|
1968
2006
|
}
|
|
1969
|
-
function
|
|
2007
|
+
function oi({ command: e, messages: t, onBack: n, onSelect: r }) {
|
|
1970
2008
|
let [i, a] = G(""), [o, s] = G(0), c = U(() => {
|
|
1971
2009
|
let e = i.trim().toLowerCase();
|
|
1972
2010
|
return (e ? t.slash.emojiItems.filter((t) => [
|
|
@@ -2033,7 +2071,7 @@ function ii({ command: e, messages: t, onBack: n, onSelect: r }) {
|
|
|
2033
2071
|
]
|
|
2034
2072
|
});
|
|
2035
2073
|
}
|
|
2036
|
-
function
|
|
2074
|
+
function si({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
|
|
2037
2075
|
let a = e.uploadKind ?? "attachment", [o, s] = G(""), [c, l] = G(null), [u, d] = G(null), [f, p] = G(!1), m = async (t) => {
|
|
2038
2076
|
r(e, { uploadResult: await K({
|
|
2039
2077
|
kind: a,
|
|
@@ -2055,7 +2093,7 @@ function ai({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
|
|
|
2055
2093
|
d(t.slash.uploadRequiredError);
|
|
2056
2094
|
return;
|
|
2057
2095
|
}
|
|
2058
|
-
await m(
|
|
2096
|
+
await m(ge(o));
|
|
2059
2097
|
} catch (e) {
|
|
2060
2098
|
d(e instanceof Error ? e.message : t.slash.uploadFailedError);
|
|
2061
2099
|
} finally {
|
|
@@ -2073,7 +2111,7 @@ function ai({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
|
|
|
2073
2111
|
onMouseDown: (e) => e.preventDefault(),
|
|
2074
2112
|
onClick: n,
|
|
2075
2113
|
children: t.common.back
|
|
2076
|
-
}), /* @__PURE__ */ Z("span", { children:
|
|
2114
|
+
}), /* @__PURE__ */ Z("span", { children: ai(a, t) })]
|
|
2077
2115
|
}),
|
|
2078
2116
|
/* @__PURE__ */ Q("label", {
|
|
2079
2117
|
className: "markweave-slash-upload-field",
|
|
@@ -2121,10 +2159,10 @@ function ai({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
|
|
|
2121
2159
|
]
|
|
2122
2160
|
});
|
|
2123
2161
|
}
|
|
2124
|
-
function
|
|
2125
|
-
let l =
|
|
2162
|
+
function ci({ commands: e, messages: t = ei, state: n, position: r, inputCommand: i, onActiveIndexChange: a, onInputCommandChange: o, onSelect: s, onUpload: c }) {
|
|
2163
|
+
let l = ri(n, e, r);
|
|
2126
2164
|
if (!l.visible || !r) return null;
|
|
2127
|
-
let u =
|
|
2165
|
+
let u = ii(e, t), d = {
|
|
2128
2166
|
left: r.left,
|
|
2129
2167
|
top: r.top,
|
|
2130
2168
|
maxHeight: r.maxHeight,
|
|
@@ -2146,12 +2184,12 @@ function oi({ commands: e, messages: t = Qr, state: n, position: r, inputCommand
|
|
|
2146
2184
|
"aria-label": t.slash.ariaLabel,
|
|
2147
2185
|
"data-placement": r.placement,
|
|
2148
2186
|
"data-testid": "markweave-slash-menu",
|
|
2149
|
-
children: i?.inputKind === "emoji" ? /* @__PURE__ */ Z(
|
|
2187
|
+
children: i?.inputKind === "emoji" ? /* @__PURE__ */ Z(oi, {
|
|
2150
2188
|
command: i,
|
|
2151
2189
|
messages: t,
|
|
2152
2190
|
onBack: m,
|
|
2153
2191
|
onSelect: s
|
|
2154
|
-
}) : i?.inputKind === "upload" ? /* @__PURE__ */ Z(
|
|
2192
|
+
}) : i?.inputKind === "upload" ? /* @__PURE__ */ Z(si, {
|
|
2155
2193
|
command: i,
|
|
2156
2194
|
messages: t,
|
|
2157
2195
|
onBack: m,
|
|
@@ -2171,7 +2209,7 @@ function oi({ commands: e, messages: t = Qr, state: n, position: r, inputCommand
|
|
|
2171
2209
|
className: "markweave-slash-group-title",
|
|
2172
2210
|
children: t.group
|
|
2173
2211
|
}), t.commands.map((t) => {
|
|
2174
|
-
let n = e.indexOf(t), r = n === l.activeIndex, i =
|
|
2212
|
+
let n = e.indexOf(t), r = n === l.activeIndex, i = Tt(t), o = !!t.disabled;
|
|
2175
2213
|
return /* @__PURE__ */ Q("button", {
|
|
2176
2214
|
type: "button",
|
|
2177
2215
|
role: "option",
|
|
@@ -2195,7 +2233,7 @@ function oi({ commands: e, messages: t = Qr, state: n, position: r, inputCommand
|
|
|
2195
2233
|
}
|
|
2196
2234
|
},
|
|
2197
2235
|
children: [
|
|
2198
|
-
/* @__PURE__ */ Z(
|
|
2236
|
+
/* @__PURE__ */ Z(ni, { name: t.icon }),
|
|
2199
2237
|
/* @__PURE__ */ Z("span", { children: t.label }),
|
|
2200
2238
|
o && t.disabledReason ? /* @__PURE__ */ Z("small", { children: t.disabledReason }) : null
|
|
2201
2239
|
]
|
|
@@ -2207,38 +2245,38 @@ function oi({ commands: e, messages: t = Qr, state: n, position: r, inputCommand
|
|
|
2207
2245
|
}
|
|
2208
2246
|
//#endregion
|
|
2209
2247
|
//#region src/ui/table/TableControls.tsx
|
|
2210
|
-
var
|
|
2211
|
-
function
|
|
2212
|
-
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), C = W(null), w = W(null), T = W(null), E = e ?
|
|
2213
|
-
if (
|
|
2248
|
+
var li = Ae("zh");
|
|
2249
|
+
function ui({ active: e, editor: t, interactionState: n = Rt, messages: r = li, onCopyPayload: i, onCommandResult: a, onEditWithAi: o }) {
|
|
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), C = W(null), w = W(null), T = W(null), E = e ? It(t.state) : null;
|
|
2251
|
+
if (H(() => {
|
|
2214
2252
|
if (!y) return;
|
|
2215
2253
|
let e = window.setTimeout(() => {
|
|
2216
2254
|
b(null);
|
|
2217
|
-
},
|
|
2255
|
+
}, qn);
|
|
2218
2256
|
return () => {
|
|
2219
2257
|
window.clearTimeout(e);
|
|
2220
2258
|
};
|
|
2221
|
-
}, [y]),
|
|
2259
|
+
}, [y]), me(() => {
|
|
2222
2260
|
if (!e) {
|
|
2223
2261
|
m(null), g(null), v(null), b(null);
|
|
2224
2262
|
return;
|
|
2225
2263
|
}
|
|
2226
2264
|
let r = () => {
|
|
2227
|
-
let e = t.view.dom.closest(".markweave-editor-frame") ?? t.view.dom.parentElement, r =
|
|
2265
|
+
let e = t.view.dom.closest(".markweave-editor-frame") ?? t.view.dom.parentElement, r = zn(t, n, "row", E?.activeCellPos ?? null), i = zn(t, n, "column", E?.activeCellPos ?? null), a = r ? Rn(t, r) : null, o = i ? Rn(t, i) : null, c = Ln(t).length > 0 ? Wn(t) : null;
|
|
2228
2266
|
if (!e) {
|
|
2229
2267
|
m(null), g(null), v(null);
|
|
2230
2268
|
return;
|
|
2231
2269
|
}
|
|
2232
2270
|
let u = e.getBoundingClientRect();
|
|
2233
|
-
a ? m(
|
|
2271
|
+
a ? m(Mn({
|
|
2234
2272
|
targetRect: a,
|
|
2235
2273
|
frameRect: u,
|
|
2236
2274
|
kind: "row"
|
|
2237
|
-
})) : s === "row" && l === "row-edge" || m(null), o ? g(
|
|
2275
|
+
})) : s === "row" && l === "row-edge" || m(null), o ? g(Mn({
|
|
2238
2276
|
targetRect: o,
|
|
2239
2277
|
frameRect: u,
|
|
2240
2278
|
kind: "column"
|
|
2241
|
-
})) : s === "column" && l === "column-edge" || g(null), c ? v(
|
|
2279
|
+
})) : s === "column" && l === "column-edge" || g(null), c ? v(Mn({
|
|
2242
2280
|
targetRect: c,
|
|
2243
2281
|
frameRect: u,
|
|
2244
2282
|
kind: "selection"
|
|
@@ -2258,7 +2296,7 @@ function ci({ active: e, editor: t, interactionState: n = It, messages: r = si,
|
|
|
2258
2296
|
n.hoverVisualRowIndex,
|
|
2259
2297
|
l,
|
|
2260
2298
|
s
|
|
2261
|
-
]),
|
|
2299
|
+
]), me(() => {
|
|
2262
2300
|
if (!e || !s) {
|
|
2263
2301
|
f(null);
|
|
2264
2302
|
return;
|
|
@@ -2269,12 +2307,12 @@ function ci({ active: e, editor: t, interactionState: n = It, messages: r = si,
|
|
|
2269
2307
|
f(null);
|
|
2270
2308
|
return;
|
|
2271
2309
|
}
|
|
2272
|
-
let i = n.getBoundingClientRect(), a = s === "row" ?
|
|
2310
|
+
let i = n.getBoundingClientRect(), a = s === "row" ? In(t)?.getBoundingClientRect() : null, o = a ? {
|
|
2273
2311
|
left: i.left,
|
|
2274
2312
|
top: a.top,
|
|
2275
2313
|
width: i.width,
|
|
2276
2314
|
height: i.height
|
|
2277
|
-
} : i, c = e.getBoundingClientRect(), u = r.getBoundingClientRect(), d =
|
|
2315
|
+
} : i, c = e.getBoundingClientRect(), u = r.getBoundingClientRect(), d = jn({
|
|
2278
2316
|
anchorRect: o,
|
|
2279
2317
|
frameRect: c,
|
|
2280
2318
|
menuSize: {
|
|
@@ -2296,7 +2334,7 @@ function ci({ active: e, editor: t, interactionState: n = It, messages: r = si,
|
|
|
2296
2334
|
p,
|
|
2297
2335
|
h,
|
|
2298
2336
|
_
|
|
2299
|
-
]),
|
|
2337
|
+
]), H(() => {
|
|
2300
2338
|
if (!e || !s) return;
|
|
2301
2339
|
let n = (e) => {
|
|
2302
2340
|
e.key === "Escape" && (c(null), t.view.focus());
|
|
@@ -2315,14 +2353,14 @@ function ci({ active: e, editor: t, interactionState: n = It, messages: r = si,
|
|
|
2315
2353
|
let n = s === e && l === t;
|
|
2316
2354
|
u(t), c(n ? null : e);
|
|
2317
2355
|
}, O = () => {
|
|
2318
|
-
t.view.dispatch(
|
|
2356
|
+
t.view.dispatch(An(t.state.tr, null));
|
|
2319
2357
|
}, k = (e, r) => {
|
|
2320
2358
|
let i = n.hoverCellPos ?? E?.activeCellPos ?? null, a = n.hoverCellPos === null ? null : e === "row" ? n.hoverVisualRowIndex : n.hoverVisualColumnIndex;
|
|
2321
|
-
i !== null &&
|
|
2359
|
+
i !== null && Kn(t, i, e, { visualIndex: a }), D(e, r);
|
|
2322
2360
|
}, A = () => {
|
|
2323
2361
|
O(), D("selection", "selection-edge");
|
|
2324
|
-
}, j =
|
|
2325
|
-
let o = await
|
|
2362
|
+
}, j = zn(t, n, "row", E?.activeCellPos ?? null), M = zn(t, n, "column", E?.activeCellPos ?? null), N = Ln(t).length > 0, P = s ? Un(t, s) : [], F = async (e, n) => {
|
|
2363
|
+
let o = await Pn({
|
|
2326
2364
|
editor: t,
|
|
2327
2365
|
commandId: e,
|
|
2328
2366
|
menu: n ?? s ?? "selection",
|
|
@@ -2330,7 +2368,7 @@ function ci({ active: e, editor: t, interactionState: n = It, messages: r = si,
|
|
|
2330
2368
|
});
|
|
2331
2369
|
return o.copyFeedback ? (b(o.copyFeedback), o.copyPayload && i?.(o.copyPayload)) : b(null), a?.(o.commandResult), o.success;
|
|
2332
2370
|
}, I = (e) => {
|
|
2333
|
-
let n =
|
|
2371
|
+
let n = Bn(t, e);
|
|
2334
2372
|
n && o?.(n), c(null), t.view.focus();
|
|
2335
2373
|
};
|
|
2336
2374
|
return /* @__PURE__ */ Q("div", {
|
|
@@ -2349,7 +2387,7 @@ function ci({ active: e, editor: t, interactionState: n = It, messages: r = si,
|
|
|
2349
2387
|
"data-copy-kind": y.kind,
|
|
2350
2388
|
"data-text-length": y.textLength,
|
|
2351
2389
|
"data-html-length": y.htmlLength,
|
|
2352
|
-
children:
|
|
2390
|
+
children: Fn(y)
|
|
2353
2391
|
}) : null,
|
|
2354
2392
|
p ? /* @__PURE__ */ Z("button", {
|
|
2355
2393
|
type: "button",
|
|
@@ -2427,7 +2465,7 @@ function ci({ active: e, editor: t, interactionState: n = It, messages: r = si,
|
|
|
2427
2465
|
ref: S,
|
|
2428
2466
|
className: "markweave-table-menu",
|
|
2429
2467
|
role: "menu",
|
|
2430
|
-
"aria-label":
|
|
2468
|
+
"aria-label": Jn(s, r),
|
|
2431
2469
|
"data-testid": "markweave-table-menu",
|
|
2432
2470
|
"data-positioned": d ? "true" : "false",
|
|
2433
2471
|
style: d ? {
|
|
@@ -2435,7 +2473,7 @@ function ci({ active: e, editor: t, interactionState: n = It, messages: r = si,
|
|
|
2435
2473
|
top: d.top
|
|
2436
2474
|
} : void 0,
|
|
2437
2475
|
children: P.map((e, n) => {
|
|
2438
|
-
let i =
|
|
2476
|
+
let i = Vn(e), a = n === 0 ? i : Vn(P[n - 1]), l = n > 0 && a !== i, u = e.commandId === null ? !!o : Nn(t, e.commandId), d = Hn(e, r);
|
|
2439
2477
|
return /* @__PURE__ */ Z("button", {
|
|
2440
2478
|
type: "button",
|
|
2441
2479
|
role: "menuitem",
|
|
@@ -2465,15 +2503,15 @@ function ci({ active: e, editor: t, interactionState: n = It, messages: r = si,
|
|
|
2465
2503
|
}
|
|
2466
2504
|
//#endregion
|
|
2467
2505
|
//#region src/ui/table/TableSelectionOverlay.tsx
|
|
2468
|
-
function
|
|
2506
|
+
function di({ editor: e, focusState: t }) {
|
|
2469
2507
|
let [n, r] = G(null);
|
|
2470
|
-
return
|
|
2508
|
+
return me(() => {
|
|
2471
2509
|
if (t.mode !== "cell-selection") {
|
|
2472
2510
|
r(null);
|
|
2473
2511
|
return;
|
|
2474
2512
|
}
|
|
2475
2513
|
let n = () => {
|
|
2476
|
-
r(
|
|
2514
|
+
r(Gn(e, Lt(e.state)));
|
|
2477
2515
|
};
|
|
2478
2516
|
return n(), window.addEventListener("resize", n), window.addEventListener("scroll", n, !0), () => {
|
|
2479
2517
|
window.removeEventListener("resize", n), window.removeEventListener("scroll", n, !0);
|
|
@@ -2508,16 +2546,16 @@ function li({ editor: e, focusState: t }) {
|
|
|
2508
2546
|
}
|
|
2509
2547
|
//#endregion
|
|
2510
2548
|
//#region src/ui/toc/MarkweaveInnerToc.tsx
|
|
2511
|
-
function
|
|
2549
|
+
function fi(e, t) {
|
|
2512
2550
|
return `${e.toc.itemAriaLabel}: ${t.text}`;
|
|
2513
2551
|
}
|
|
2514
|
-
function
|
|
2552
|
+
function pi({ editor: e, state: t, messages: n, editable: r, placement: i }) {
|
|
2515
2553
|
let a = W(null);
|
|
2516
|
-
if (
|
|
2517
|
-
if (!(i !== "container" || !a.current)) return
|
|
2554
|
+
if (H(() => {
|
|
2555
|
+
if (!(i !== "container" || !a.current)) return tr(a.current);
|
|
2518
2556
|
}, [i]), !t.items.length) return null;
|
|
2519
2557
|
let o = (t) => {
|
|
2520
|
-
|
|
2558
|
+
nr(e, t, {
|
|
2521
2559
|
behavior: "smooth",
|
|
2522
2560
|
focus: r
|
|
2523
2561
|
});
|
|
@@ -2544,7 +2582,7 @@ function di({ editor: e, state: t, messages: n, editable: r, placement: i }) {
|
|
|
2544
2582
|
"data-level": e.level,
|
|
2545
2583
|
"data-active": e.active ? "true" : "false",
|
|
2546
2584
|
"aria-current": e.active ? "location" : void 0,
|
|
2547
|
-
"aria-label":
|
|
2585
|
+
"aria-label": fi(n, e),
|
|
2548
2586
|
title: e.text,
|
|
2549
2587
|
onClick: () => o(e),
|
|
2550
2588
|
children: e.text
|
|
@@ -2555,7 +2593,7 @@ function di({ editor: e, state: t, messages: n, editable: r, placement: i }) {
|
|
|
2555
2593
|
}
|
|
2556
2594
|
//#endregion
|
|
2557
2595
|
//#region src/MarkweaveEditor.tsx
|
|
2558
|
-
var
|
|
2596
|
+
var mi = {
|
|
2559
2597
|
active: !1,
|
|
2560
2598
|
mode: "outside",
|
|
2561
2599
|
activeCellPos: null,
|
|
@@ -2563,21 +2601,21 @@ var fi = {
|
|
|
2563
2601
|
selectedCellCount: 0,
|
|
2564
2602
|
selectionFrom: 0,
|
|
2565
2603
|
selectionTo: 0
|
|
2566
|
-
},
|
|
2604
|
+
}, hi = {
|
|
2567
2605
|
active: !1,
|
|
2568
|
-
language:
|
|
2606
|
+
language: it.defaultLanguage,
|
|
2569
2607
|
mermaidPreviewMode: "code",
|
|
2570
2608
|
pos: null,
|
|
2571
2609
|
text: ""
|
|
2572
|
-
},
|
|
2610
|
+
}, gi = dt({
|
|
2573
2611
|
active: !1,
|
|
2574
2612
|
mode: "code",
|
|
2575
2613
|
source: ""
|
|
2576
2614
|
});
|
|
2577
|
-
function
|
|
2578
|
-
return
|
|
2615
|
+
function _i(e) {
|
|
2616
|
+
return zt.getState(e.state) ?? Rt;
|
|
2579
2617
|
}
|
|
2580
|
-
function
|
|
2618
|
+
function vi(e) {
|
|
2581
2619
|
if (!e || typeof window > "u") return null;
|
|
2582
2620
|
let t = e.parentElement;
|
|
2583
2621
|
for (; t;) {
|
|
@@ -2587,18 +2625,18 @@ function gi(e) {
|
|
|
2587
2625
|
}
|
|
2588
2626
|
return null;
|
|
2589
2627
|
}
|
|
2590
|
-
function
|
|
2628
|
+
function yi(e) {
|
|
2591
2629
|
return typeof window > "u" || typeof window.requestAnimationFrame != "function" ? globalThis.setTimeout(() => e(0), 0) : window.requestAnimationFrame(e);
|
|
2592
2630
|
}
|
|
2593
|
-
function
|
|
2631
|
+
function bi(e) {
|
|
2594
2632
|
if (typeof window < "u" && typeof window.cancelAnimationFrame == "function") {
|
|
2595
2633
|
window.cancelAnimationFrame(e);
|
|
2596
2634
|
return;
|
|
2597
2635
|
}
|
|
2598
2636
|
globalThis.clearTimeout(e);
|
|
2599
2637
|
}
|
|
2600
|
-
function
|
|
2601
|
-
let S =
|
|
2638
|
+
function xi({ 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 } = {}) {
|
|
2639
|
+
let S = Pe(f), C = er(u), w = S === "live" && c !== !1, T = Ue(r === void 0 ? s : a), E = W({
|
|
2602
2640
|
editorMode: S,
|
|
2603
2641
|
effectiveEditable: w
|
|
2604
2642
|
});
|
|
@@ -2607,50 +2645,50 @@ function yi({ ariaLabel: e, autoFocusFirstTableBodyCell: t = !1, autofocus: n =
|
|
|
2607
2645
|
effectiveEditable: w
|
|
2608
2646
|
};
|
|
2609
2647
|
let D = W(null);
|
|
2610
|
-
D.current === null && (D.current =
|
|
2611
|
-
let O = D.current, k = U(() =>
|
|
2648
|
+
D.current === null && (D.current = je(d));
|
|
2649
|
+
let O = D.current, k = U(() => Ae(O), [O]), A = U(() => ke(O), [O]), j = W(_);
|
|
2612
2650
|
j.current = _;
|
|
2613
|
-
let M = U(() =>
|
|
2651
|
+
let M = U(() => _r({
|
|
2614
2652
|
lang: O,
|
|
2615
2653
|
onImageUpload: (e) => {
|
|
2616
2654
|
if (j.current) return j.current(e);
|
|
2617
|
-
let t =
|
|
2655
|
+
let t = _e(e);
|
|
2618
2656
|
if (!t) throw Error("File upload requires an upload handler.");
|
|
2619
2657
|
return t;
|
|
2620
2658
|
},
|
|
2621
2659
|
onVideoUpload: (e) => {
|
|
2622
2660
|
if (j.current) return j.current(e);
|
|
2623
|
-
let t =
|
|
2661
|
+
let t = _e(e);
|
|
2624
2662
|
if (!t) throw Error("File upload requires an upload handler.");
|
|
2625
2663
|
return t;
|
|
2626
2664
|
}
|
|
2627
|
-
}), [O]), [N, P] = G(null), [F, I] = G(
|
|
2665
|
+
}), [O]), [N, P] = G(null), [F, I] = G(Mt), [ee, L] = G(null), [R, te] = G(null), [z, ne] = G("code"), [re, ie] = G(null), [ae, oe] = G(Rt), [se, ce] = G(null), [le, ue] = G(0), de = W(!1), fe = W({ onUpdate: x }), pe = U(() => wt(F.query, A), [A, F.query]);
|
|
2628
2666
|
fe.current = { onUpdate: x };
|
|
2629
|
-
let
|
|
2630
|
-
L(null), te(null), I(
|
|
2631
|
-
}, []), me =
|
|
2632
|
-
let t =
|
|
2667
|
+
let B = V(() => {
|
|
2668
|
+
L(null), te(null), I(Mt);
|
|
2669
|
+
}, []), me = V((e) => {
|
|
2670
|
+
let t = jt(e.state);
|
|
2633
2671
|
if (!t) {
|
|
2634
|
-
I((e) => e.name === "idle" ? e :
|
|
2672
|
+
I((e) => e.name === "idle" ? e : Mt), L(null), te(null);
|
|
2635
2673
|
return;
|
|
2636
2674
|
}
|
|
2637
2675
|
let n = e.coordsAtPos(t.cursor), r = e.coordsAtPos(t.triggerFrom), i = e.dom.closest(".markweave-editor-frame")?.getBoundingClientRect();
|
|
2638
|
-
L(
|
|
2676
|
+
L(At(n, {
|
|
2639
2677
|
frameRect: i,
|
|
2640
2678
|
triggerRect: r
|
|
2641
|
-
})), I((e) =>
|
|
2642
|
-
}, []), he =
|
|
2643
|
-
P(
|
|
2644
|
-
let t =
|
|
2645
|
-
t && (
|
|
2646
|
-
let n =
|
|
2679
|
+
})), I((e) => kt(e, t));
|
|
2680
|
+
}, []), he = V((e) => me(e.view), [me]), ge = V((e) => {
|
|
2681
|
+
P(Ye(e));
|
|
2682
|
+
let t = yt(e);
|
|
2683
|
+
t && (xt(e, t, !0), ie(t));
|
|
2684
|
+
let n = nt(e);
|
|
2647
2685
|
n.active && n.language === "mermaid" && ne(n.mermaidPreviewMode);
|
|
2648
|
-
}, []),
|
|
2649
|
-
oe(
|
|
2686
|
+
}, []), K = V((e) => {
|
|
2687
|
+
oe(_i(e));
|
|
2650
2688
|
}, []), q = i({
|
|
2651
2689
|
extensions: M,
|
|
2652
2690
|
content: r ?? o,
|
|
2653
|
-
contentType:
|
|
2691
|
+
contentType: Ve(T),
|
|
2654
2692
|
editable: w,
|
|
2655
2693
|
autofocus: n,
|
|
2656
2694
|
editorProps: {
|
|
@@ -2662,114 +2700,114 @@ function yi({ ariaLabel: e, autoFocusFirstTableBodyCell: t = !1, autofocus: n =
|
|
|
2662
2700
|
spellcheck: "false",
|
|
2663
2701
|
translate: "no"
|
|
2664
2702
|
},
|
|
2665
|
-
handleClick: (e, t, n) => E.current.effectiveEditable ? !1 :
|
|
2703
|
+
handleClick: (e, t, n) => E.current.effectiveEditable ? !1 : We(n),
|
|
2666
2704
|
handleDOMEvents: {
|
|
2667
|
-
compositionstart: () => E.current.effectiveEditable ? (I((e) =>
|
|
2705
|
+
compositionstart: () => E.current.effectiveEditable ? (I((e) => Nt(e, { type: "composition-start" })), L(null), !1) : !1,
|
|
2668
2706
|
compositionend: (e) => (E.current.effectiveEditable && window.setTimeout(() => me(e), 0), !1),
|
|
2669
2707
|
click: (e, t) => {
|
|
2670
2708
|
if (E.current.effectiveEditable) {
|
|
2671
|
-
let n =
|
|
2672
|
-
return n ? (t.preventDefault(), t.stopPropagation(),
|
|
2709
|
+
let n = vt(e, t);
|
|
2710
|
+
return n ? (t.preventDefault(), t.stopPropagation(), B(), St(e, n, !0), Ct(e, n), ie(n), !0) : (ie(null), !1);
|
|
2673
2711
|
}
|
|
2674
|
-
return
|
|
2712
|
+
return We(t);
|
|
2675
2713
|
}
|
|
2676
2714
|
}
|
|
2677
2715
|
},
|
|
2678
2716
|
onSelectionUpdate: ({ editor: e }) => {
|
|
2679
|
-
|
|
2717
|
+
ge(e);
|
|
2680
2718
|
},
|
|
2681
2719
|
onCreate: ({ editor: e }) => {
|
|
2682
|
-
t && E.current.effectiveEditable &&
|
|
2720
|
+
t && E.current.effectiveEditable && Ft(e), K(e), ge(e), ue((e) => e + 1);
|
|
2683
2721
|
},
|
|
2684
2722
|
onTransaction: ({ editor: e, transaction: t }) => {
|
|
2685
|
-
|
|
2723
|
+
K(e), (t.docChanged || ct(t)) && ue((e) => e + 1), t.docChanged && ie((t) => {
|
|
2686
2724
|
if (!t) return null;
|
|
2687
|
-
let n =
|
|
2725
|
+
let n = _t(e, t.pos);
|
|
2688
2726
|
return n?.kind === t.kind ? n : null;
|
|
2689
2727
|
});
|
|
2690
2728
|
},
|
|
2691
2729
|
onUpdate: ({ editor: e }) => {
|
|
2692
|
-
|
|
2730
|
+
ge(e), E.current.effectiveEditable && he(e), de.current || fe.current.onUpdate?.(Be(e));
|
|
2693
2731
|
}
|
|
2694
2732
|
});
|
|
2695
|
-
|
|
2696
|
-
q && (q.setEditable(w),
|
|
2733
|
+
H(() => {
|
|
2734
|
+
q && (q.setEditable(w), Fe(q, {
|
|
2697
2735
|
mode: S,
|
|
2698
2736
|
editable: w
|
|
2699
|
-
}),
|
|
2737
|
+
}), lt(q, w ? "live" : "view"), w || B());
|
|
2700
2738
|
}, [
|
|
2701
|
-
|
|
2739
|
+
B,
|
|
2702
2740
|
q,
|
|
2703
2741
|
S,
|
|
2704
2742
|
w
|
|
2705
|
-
]),
|
|
2706
|
-
!q || r === void 0 ||
|
|
2707
|
-
contentType:
|
|
2743
|
+
]), H(() => {
|
|
2744
|
+
!q || r === void 0 || He(q, r, Ue(a)) || (de.current = !0, q.commands.setContent(r, {
|
|
2745
|
+
contentType: Ve(Ue(a)),
|
|
2708
2746
|
emitUpdate: !1
|
|
2709
|
-
}), de.current = !1,
|
|
2747
|
+
}), de.current = !1, ge(q), w && he(q), K(q), ue((e) => e + 1));
|
|
2710
2748
|
}, [
|
|
2711
2749
|
r,
|
|
2712
2750
|
a,
|
|
2713
2751
|
w,
|
|
2714
2752
|
q,
|
|
2715
|
-
|
|
2753
|
+
ge,
|
|
2716
2754
|
he,
|
|
2717
|
-
|
|
2718
|
-
]),
|
|
2755
|
+
K
|
|
2756
|
+
]), H(() => {
|
|
2719
2757
|
if (!ee) return;
|
|
2720
2758
|
let e = (e) => {
|
|
2721
2759
|
let t = e.target;
|
|
2722
|
-
t instanceof Element && (t.closest(".markweave-slash-menu") || t.closest(".markweave-slash-trigger") ||
|
|
2760
|
+
t instanceof Element && (t.closest(".markweave-slash-menu") || t.closest(".markweave-slash-trigger") || B());
|
|
2723
2761
|
};
|
|
2724
2762
|
return document.addEventListener("pointerdown", e, !0), () => document.removeEventListener("pointerdown", e, !0);
|
|
2725
|
-
}, [
|
|
2726
|
-
let ve = U(() => q ?
|
|
2763
|
+
}, [B, ee]);
|
|
2764
|
+
let ve = U(() => q ? nt(q) : hi, [
|
|
2727
2765
|
q,
|
|
2728
2766
|
le,
|
|
2729
2767
|
N
|
|
2730
|
-
]), ye = U(() => q ?
|
|
2768
|
+
]), ye = U(() => q ? It(q.state) : mi, [
|
|
2731
2769
|
q,
|
|
2732
2770
|
le,
|
|
2733
2771
|
N,
|
|
2734
2772
|
ae
|
|
2735
|
-
]), be = N?.currentNode === "codeBlock", xe = be && ve.language === "mermaid", Se = U(() => q ?
|
|
2773
|
+
]), be = N?.currentNode === "codeBlock", xe = be && ve.language === "mermaid", Se = U(() => q ? dt({
|
|
2736
2774
|
active: xe,
|
|
2737
2775
|
mode: z,
|
|
2738
2776
|
source: ve.text
|
|
2739
|
-
}) :
|
|
2777
|
+
}) : gi, [
|
|
2740
2778
|
ve.text,
|
|
2741
2779
|
q,
|
|
2742
2780
|
xe,
|
|
2743
2781
|
z
|
|
2744
|
-
]), Ce = U(() => q ?
|
|
2782
|
+
]), Ce = U(() => q ? Pt(q.state) : null, [q, le]), J = U(() => q ? Qn(q.state.doc) : Xn.items, [q, le]), we = U(() => $n(J, se), [se, J]), Te = U(() => Yn(J, we), [we, J]), Ee = V(() => {
|
|
2745
2783
|
if (!q || !J.length) {
|
|
2746
2784
|
ce(null);
|
|
2747
2785
|
return;
|
|
2748
2786
|
}
|
|
2749
|
-
let e =
|
|
2787
|
+
let e = Zn(q, J);
|
|
2750
2788
|
ce((t) => t === e ? t : e);
|
|
2751
2789
|
}, [q, J]);
|
|
2752
|
-
|
|
2790
|
+
H(() => {
|
|
2753
2791
|
ce((e) => {
|
|
2754
|
-
let t =
|
|
2792
|
+
let t = $n(J, e);
|
|
2755
2793
|
return e === t ? e : t;
|
|
2756
2794
|
});
|
|
2757
|
-
}, [J]),
|
|
2795
|
+
}, [J]), H(() => {
|
|
2758
2796
|
if (!q || !J.length || typeof window > "u") return;
|
|
2759
2797
|
let e = null, t = () => {
|
|
2760
|
-
e !== null &&
|
|
2798
|
+
e !== null && bi(e), e = yi(() => {
|
|
2761
2799
|
e = null, Ee();
|
|
2762
2800
|
});
|
|
2763
|
-
}, n =
|
|
2801
|
+
}, n = vi(q.view.dom);
|
|
2764
2802
|
return window.addEventListener("scroll", t, { passive: !0 }), window.addEventListener("resize", t), n?.addEventListener("scroll", t, { passive: !0 }), t(), () => {
|
|
2765
|
-
window.removeEventListener("scroll", t), window.removeEventListener("resize", t), n?.removeEventListener("scroll", t), e !== null &&
|
|
2803
|
+
window.removeEventListener("scroll", t), window.removeEventListener("resize", t), n?.removeEventListener("scroll", t), e !== null && bi(e);
|
|
2766
2804
|
};
|
|
2767
2805
|
}, [
|
|
2768
2806
|
q,
|
|
2769
2807
|
J.length,
|
|
2770
2808
|
Ee
|
|
2771
2809
|
]);
|
|
2772
|
-
let De = U(() =>
|
|
2810
|
+
let De = U(() => Ge({
|
|
2773
2811
|
revision: le,
|
|
2774
2812
|
mode: S,
|
|
2775
2813
|
editable: w,
|
|
@@ -2794,74 +2832,74 @@ function yi({ ariaLabel: e, autoFocusFirstTableBodyCell: t = !1, autofocus: n =
|
|
|
2794
2832
|
ae,
|
|
2795
2833
|
Te
|
|
2796
2834
|
]);
|
|
2797
|
-
|
|
2835
|
+
H(() => {
|
|
2798
2836
|
g?.(De);
|
|
2799
|
-
}, [g, De]),
|
|
2837
|
+
}, [g, De]), H(() => {
|
|
2800
2838
|
b?.(Te);
|
|
2801
2839
|
}, [b, Te]);
|
|
2802
|
-
let
|
|
2803
|
-
if (!(!q || !w) &&
|
|
2840
|
+
let Oe = V((e, t) => {
|
|
2841
|
+
if (!(!q || !w) && Tt(e)) {
|
|
2804
2842
|
if (e.inputKind && !t?.emoji && !t?.uploadResult) {
|
|
2805
2843
|
te(e);
|
|
2806
2844
|
return;
|
|
2807
2845
|
}
|
|
2808
|
-
|
|
2846
|
+
Ot(q, F, e, t), I((e) => Nt(e, { type: "execute" })), B();
|
|
2809
2847
|
}
|
|
2810
2848
|
}, [
|
|
2811
|
-
|
|
2849
|
+
B,
|
|
2812
2850
|
w,
|
|
2813
2851
|
q,
|
|
2814
2852
|
F
|
|
2815
|
-
]),
|
|
2816
|
-
I((t) =>
|
|
2853
|
+
]), Y = V((e) => {
|
|
2854
|
+
I((t) => Nt(t, {
|
|
2817
2855
|
type: "set-active",
|
|
2818
2856
|
index: e,
|
|
2819
2857
|
optionCount: pe.length
|
|
2820
2858
|
}));
|
|
2821
|
-
}, [pe.length]), Me =
|
|
2859
|
+
}, [pe.length]), Me = V((e) => {
|
|
2822
2860
|
if (!q || R || !w) return;
|
|
2823
|
-
let t =
|
|
2861
|
+
let t = Et(F, pe, e.key, { isComposing: e.nativeEvent.isComposing || ze(q.state) });
|
|
2824
2862
|
if (t.type !== "ignore") {
|
|
2825
2863
|
if (t.type === "close") {
|
|
2826
|
-
e.preventDefault(), I((e) =>
|
|
2864
|
+
e.preventDefault(), I((e) => Nt(e, { type: "escape" })), B();
|
|
2827
2865
|
return;
|
|
2828
2866
|
}
|
|
2829
2867
|
if (t.type === "move-active") {
|
|
2830
|
-
e.preventDefault(), I((e) =>
|
|
2868
|
+
e.preventDefault(), I((e) => Nt(e, {
|
|
2831
2869
|
type: "move-active",
|
|
2832
2870
|
delta: t.delta,
|
|
2833
2871
|
optionCount: t.optionCount
|
|
2834
2872
|
}));
|
|
2835
2873
|
return;
|
|
2836
2874
|
}
|
|
2837
|
-
t.type === "execute-active" && (e.preventDefault(),
|
|
2875
|
+
t.type === "execute-active" && (e.preventDefault(), Oe(t.command));
|
|
2838
2876
|
}
|
|
2839
2877
|
}, [
|
|
2840
|
-
|
|
2878
|
+
B,
|
|
2841
2879
|
w,
|
|
2842
2880
|
q,
|
|
2843
2881
|
pe,
|
|
2844
|
-
|
|
2882
|
+
Oe,
|
|
2845
2883
|
R,
|
|
2846
2884
|
F
|
|
2847
|
-
]),
|
|
2848
|
-
closeSlashMenu:
|
|
2849
|
-
focusFirstTableBodyCell: () => q ?
|
|
2885
|
+
]), Ne = U(() => ({
|
|
2886
|
+
closeSlashMenu: B,
|
|
2887
|
+
focusFirstTableBodyCell: () => q ? Ft(q) : !1,
|
|
2850
2888
|
setContent: (e, t = {}) => {
|
|
2851
2889
|
if (!q) return !1;
|
|
2852
|
-
let n =
|
|
2890
|
+
let n = Ue(t.format);
|
|
2853
2891
|
return q.commands.setContent(e, {
|
|
2854
|
-
contentType:
|
|
2892
|
+
contentType: Ve(n),
|
|
2855
2893
|
emitUpdate: t.emitUpdate ?? !1
|
|
2856
|
-
}), t.focusFirstTableBodyCell &&
|
|
2894
|
+
}), t.focusFirstTableBodyCell && Ft(q), ge(q), w && he(q), K(q), ue((e) => e + 1), !0;
|
|
2857
2895
|
}
|
|
2858
2896
|
}), [
|
|
2859
|
-
|
|
2897
|
+
B,
|
|
2860
2898
|
w,
|
|
2861
2899
|
q,
|
|
2862
|
-
|
|
2900
|
+
ge,
|
|
2863
2901
|
he,
|
|
2864
|
-
|
|
2902
|
+
K
|
|
2865
2903
|
]);
|
|
2866
2904
|
return {
|
|
2867
2905
|
editor: q,
|
|
@@ -2899,9 +2937,9 @@ function yi({ ariaLabel: e, autoFocusFirstTableBodyCell: t = !1, autofocus: n =
|
|
|
2899
2937
|
position: ee,
|
|
2900
2938
|
inputCommand: R,
|
|
2901
2939
|
messages: k,
|
|
2902
|
-
onActiveIndexChange:
|
|
2940
|
+
onActiveIndexChange: Y,
|
|
2903
2941
|
onInputCommandChange: te,
|
|
2904
|
-
onSelect:
|
|
2942
|
+
onSelect: Oe,
|
|
2905
2943
|
onUpload: _
|
|
2906
2944
|
} : null,
|
|
2907
2945
|
tableControls: q && w ? {
|
|
@@ -2952,9 +2990,9 @@ function yi({ ariaLabel: e, autoFocusFirstTableBodyCell: t = !1, autofocus: n =
|
|
|
2952
2990
|
_,
|
|
2953
2991
|
v,
|
|
2954
2992
|
y,
|
|
2955
|
-
|
|
2993
|
+
Oe,
|
|
2956
2994
|
N,
|
|
2957
|
-
|
|
2995
|
+
Y,
|
|
2958
2996
|
R,
|
|
2959
2997
|
ee,
|
|
2960
2998
|
F,
|
|
@@ -2963,27 +3001,27 @@ function yi({ ariaLabel: e, autoFocusFirstTableBodyCell: t = !1, autofocus: n =
|
|
|
2963
3001
|
Te
|
|
2964
3002
|
]),
|
|
2965
3003
|
runtimeSnapshot: De,
|
|
2966
|
-
actions:
|
|
3004
|
+
actions: Ne
|
|
2967
3005
|
};
|
|
2968
3006
|
}
|
|
2969
|
-
function
|
|
2970
|
-
let r =
|
|
3007
|
+
function Si({ className: e, ...n }) {
|
|
3008
|
+
let r = xi(n);
|
|
2971
3009
|
if (!r.editor) return null;
|
|
2972
3010
|
let i = [r.frameProps.className, e].filter(Boolean).join(" ");
|
|
2973
3011
|
return /* @__PURE__ */ Q("section", {
|
|
2974
3012
|
...r.frameProps,
|
|
2975
3013
|
className: i,
|
|
2976
3014
|
children: [
|
|
2977
|
-
r.overlayProps.floatingToolbar ? /* @__PURE__ */ Z(
|
|
2978
|
-
r.overlayProps.slashCommandMenu ? /* @__PURE__ */ Z(
|
|
2979
|
-
r.overlayProps.tableControls ? /* @__PURE__ */ Z(
|
|
2980
|
-
r.overlayProps.tableSelectionOverlay ? /* @__PURE__ */ Z(
|
|
2981
|
-
r.overlayProps.codeBlockControls ? /* @__PURE__ */ Z(
|
|
2982
|
-
r.overlayProps.innerToc ? /* @__PURE__ */ Z(
|
|
2983
|
-
r.overlayProps.mathEditorPopover ? /* @__PURE__ */ Z(
|
|
3015
|
+
r.overlayProps.floatingToolbar ? /* @__PURE__ */ Z(Vr, { ...r.overlayProps.floatingToolbar }) : null,
|
|
3016
|
+
r.overlayProps.slashCommandMenu ? /* @__PURE__ */ Z(ci, { ...r.overlayProps.slashCommandMenu }) : null,
|
|
3017
|
+
r.overlayProps.tableControls ? /* @__PURE__ */ Z(ui, { ...r.overlayProps.tableControls }) : null,
|
|
3018
|
+
r.overlayProps.tableSelectionOverlay ? /* @__PURE__ */ Z(di, { ...r.overlayProps.tableSelectionOverlay }) : null,
|
|
3019
|
+
r.overlayProps.codeBlockControls ? /* @__PURE__ */ Z(br, { ...r.overlayProps.codeBlockControls }) : null,
|
|
3020
|
+
r.overlayProps.innerToc ? /* @__PURE__ */ Z(pi, { ...r.overlayProps.innerToc }) : null,
|
|
3021
|
+
r.overlayProps.mathEditorPopover ? /* @__PURE__ */ Z($r, { ...r.overlayProps.mathEditorPopover }) : null,
|
|
2984
3022
|
/* @__PURE__ */ Z(t, { editor: r.editor })
|
|
2985
3023
|
]
|
|
2986
3024
|
});
|
|
2987
3025
|
}
|
|
2988
3026
|
//#endregion
|
|
2989
|
-
export {
|
|
3027
|
+
export { Si as MarkweaveEditor, _r as createMarkweaveEditorExtensions, _r as createMarkweaveReactEditorExtensions, xi as useMarkweaveEditorController };
|