@markweave/react 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +21 -17
- package/dist/index.js +729 -684
- package/dist/types/MarkweaveEditor.d.ts +4 -2
- package/dist/types/MarkweaveEditor.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/media/image-node.d.ts.map +1 -1
- package/dist/types/ui/toc/MarkweaveInnerToc.d.ts +3 -2
- package/dist/types/ui/toc/MarkweaveInnerToc.d.ts.map +1 -1
- package/package.json +2 -2
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 V, useEffect as H, useLayoutEffect 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 ??
|
|
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
|
+
};
|
|
51
64
|
H(() => {
|
|
52
|
-
|
|
53
|
-
}, [h,
|
|
54
|
-
let
|
|
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
|
|
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
|
});
|
|
105
|
+
}, ne = (e) => {
|
|
106
|
+
z(e.currentTarget.files?.[0] ?? null), e.currentTarget.value = "";
|
|
92
107
|
}, re = (e) => {
|
|
93
|
-
|
|
94
|
-
},
|
|
95
|
-
e
|
|
96
|
-
},
|
|
97
|
-
d && (
|
|
98
|
-
},
|
|
99
|
-
d && (M(e), s({ caption: e.trim() ? e : null }));
|
|
100
|
-
}, ae = (e, t) => {
|
|
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 rr(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 rr(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 rr(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 ir({ 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 ir({ 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 ir({ 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 ar({ 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 or({ 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 sr({ 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
|
|
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 ur(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 ur(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 ur(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 ur(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 dr({ 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 dr({ 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 dr({ 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 pr(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 mr(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,27 +699,27 @@ function hr({ 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
|
|
669
|
-
let a =
|
|
706
|
+
function br({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, readOnly: i = !1 }) {
|
|
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] =
|
|
674
|
-
...
|
|
675
|
-
pos:
|
|
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 ? {
|
|
712
|
+
...F,
|
|
713
|
+
pos: F.pos,
|
|
676
714
|
active: !0
|
|
677
|
-
} : null,
|
|
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]);
|
|
678
716
|
if (H(() => {
|
|
679
717
|
i && (v(!1), b(""));
|
|
680
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
|
};
|
|
@@ -689,12 +727,12 @@ function gr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
689
727
|
S(null), v(!1), b(""), E(null), O(null), A(!1);
|
|
690
728
|
}, [
|
|
691
729
|
e,
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
730
|
+
L?.language,
|
|
731
|
+
L?.pos,
|
|
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);
|
|
@@ -704,7 +742,7 @@ function gr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
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);
|
|
@@ -727,7 +765,7 @@ function gr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
727
765
|
document.removeEventListener("keydown", e);
|
|
728
766
|
};
|
|
729
767
|
}, [t, T]), H(() => {
|
|
730
|
-
if (!
|
|
768
|
+
if (!R || !_) return;
|
|
731
769
|
let e = (e) => {
|
|
732
770
|
e.key === "Escape" && (v(!1), t.view.focus());
|
|
733
771
|
}, n = (e) => {
|
|
@@ -737,22 +775,22 @@ function gr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
737
775
|
document.removeEventListener("keydown", e), document.removeEventListener("mousedown", n);
|
|
738
776
|
};
|
|
739
777
|
}, [
|
|
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
|
-
let n = e.getBoundingClientRect(), r =
|
|
752
|
-
let r =
|
|
753
|
-
return r ? [
|
|
789
|
+
let n = e.getBoundingClientRect(), r = ce.flatMap((e) => {
|
|
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,23 +801,23 @@ function gr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
763
801
|
j,
|
|
764
802
|
t,
|
|
765
803
|
le
|
|
766
|
-
]),
|
|
767
|
-
if (!
|
|
804
|
+
]), me(() => {
|
|
805
|
+
if (!ne || !L) {
|
|
768
806
|
f(null), g(null);
|
|
769
807
|
return;
|
|
770
808
|
}
|
|
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
|
-
f((e) => e?.pos ===
|
|
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,
|
|
@@ -791,72 +829,72 @@ function gr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
791
829
|
window.removeEventListener("resize", e), window.removeEventListener("scroll", e, !0);
|
|
792
830
|
};
|
|
793
831
|
}, [
|
|
794
|
-
|
|
832
|
+
ne,
|
|
795
833
|
j,
|
|
796
|
-
|
|
834
|
+
L?.pos,
|
|
797
835
|
t,
|
|
798
836
|
_,
|
|
799
|
-
|
|
800
|
-
]), !
|
|
837
|
+
oe
|
|
838
|
+
]), !ne && ce.length === 0 && !T) return null;
|
|
801
839
|
let de = d ? {
|
|
802
840
|
top: d.top,
|
|
803
841
|
right: d.right
|
|
804
|
-
} : void 0,
|
|
842
|
+
} : void 0, fe = async () => {
|
|
805
843
|
if (i) {
|
|
806
|
-
if (!
|
|
807
|
-
let e = await
|
|
808
|
-
S(
|
|
844
|
+
if (!L) return;
|
|
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(
|
|
814
|
-
},
|
|
849
|
+
if (!qt(t, L)) return;
|
|
850
|
+
let e = await tt(t);
|
|
851
|
+
S(rt(nt(t), e ? "copied" : "failed")), t.view.focus();
|
|
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
|
-
let a =
|
|
820
|
-
|
|
821
|
-
},
|
|
822
|
-
if (i || !
|
|
823
|
-
let n =
|
|
824
|
-
|
|
825
|
-
},
|
|
826
|
-
i || !
|
|
827
|
-
},
|
|
828
|
-
if (!
|
|
829
|
-
let e =
|
|
857
|
+
let a = F.active && F.pos === e.pos;
|
|
858
|
+
st(t, e.pos, n) && (r(n), P((e) => e + 1), a && t.view.focus());
|
|
859
|
+
}, B = (e) => {
|
|
860
|
+
if (i || !L) return;
|
|
861
|
+
let n = F.active && F.pos === L.pos;
|
|
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));
|
|
865
|
+
}, he = () => {
|
|
866
|
+
if (!L) return;
|
|
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
|
-
},
|
|
834
|
-
if (!
|
|
835
|
-
let e =
|
|
836
|
-
e && (E(
|
|
871
|
+
}, ge = () => {
|
|
872
|
+
if (!L) return;
|
|
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
|
-
},
|
|
853
|
-
E((e) => e &&
|
|
890
|
+
}, q = () => {
|
|
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 gr({ 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,
|
|
@@ -885,7 +923,7 @@ function gr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
885
923
|
"data-testid": "markweave-codeblock-overlay",
|
|
886
924
|
"data-read-only": i ? "true" : "false",
|
|
887
925
|
children: [
|
|
888
|
-
|
|
926
|
+
ce.map((e) => {
|
|
889
927
|
let t = p.find((t) => t.pos === e.pos);
|
|
890
928
|
return /* @__PURE__ */ Z("div", {
|
|
891
929
|
className: "markweave-mermaid-tabs",
|
|
@@ -901,16 +939,16 @@ function gr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
901
939
|
"data-testid": `markweave-mermaid-mode-${t}`,
|
|
902
940
|
"data-active": e.mermaidPreviewMode === t,
|
|
903
941
|
onMouseDown: (e) => e.preventDefault(),
|
|
904
|
-
onClick: () =>
|
|
942
|
+
onClick: () => pe(e, t),
|
|
905
943
|
children: t === "code" ? "Code" : "Preview"
|
|
906
944
|
}, t))
|
|
907
945
|
}, e.pos);
|
|
908
946
|
}),
|
|
909
|
-
|
|
947
|
+
ne ? /* @__PURE__ */ Q("div", {
|
|
910
948
|
className: "markweave-codeblock-controls",
|
|
911
949
|
"data-testid": "markweave-codeblock-controls",
|
|
912
950
|
"data-positioned": d ? "true" : "false",
|
|
913
|
-
"data-collapsed":
|
|
951
|
+
"data-collapsed": z ? "true" : "false",
|
|
914
952
|
"data-read-only": i ? "true" : "false",
|
|
915
953
|
"aria-label": "Code block controls",
|
|
916
954
|
style: de,
|
|
@@ -919,7 +957,7 @@ function gr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
919
957
|
className: "markweave-codeblock-language-button markweave-codeblock-language-label",
|
|
920
958
|
"aria-label": "Code block language",
|
|
921
959
|
"data-testid": "markweave-codeblock-language",
|
|
922
|
-
children: /* @__PURE__ */ Z("span", { children:
|
|
960
|
+
children: /* @__PURE__ */ Z("span", { children: ie })
|
|
923
961
|
}) : /* @__PURE__ */ Q("button", {
|
|
924
962
|
ref: o,
|
|
925
963
|
type: "button",
|
|
@@ -930,18 +968,18 @@ function gr({ 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:
|
|
971
|
+
children: [/* @__PURE__ */ Z("span", { children: ie }), /* @__PURE__ */ Z(yr, { icon: "chevron" })]
|
|
934
972
|
}),
|
|
935
|
-
|
|
973
|
+
re ? /* @__PURE__ */ Z("button", {
|
|
936
974
|
type: "button",
|
|
937
975
|
className: "markweave-codeblock-icon-button markweave-codeblock-collapse-button",
|
|
938
|
-
"aria-label":
|
|
939
|
-
title:
|
|
976
|
+
"aria-label": z ? "Expand code block" : "Collapse code block",
|
|
977
|
+
title: z ? "Expand code block" : "Collapse code block",
|
|
940
978
|
"data-testid": "markweave-codeblock-collapse",
|
|
941
|
-
"data-collapsed":
|
|
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",
|
|
@@ -950,14 +988,14 @@ function gr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
950
988
|
className: "markweave-codeblock-icon-button",
|
|
951
989
|
"aria-label": "Copy to clipboard",
|
|
952
990
|
"data-testid": "markweave-codeblock-copy",
|
|
953
|
-
"data-copy-state":
|
|
991
|
+
"data-copy-state": ae,
|
|
954
992
|
onMouseDown: (e) => e.preventDefault(),
|
|
955
993
|
onMouseEnter: () => w(!0),
|
|
956
994
|
onMouseLeave: () => w(!1),
|
|
957
995
|
onFocus: () => w(!0),
|
|
958
996
|
onBlur: () => w(!1),
|
|
959
|
-
onClick:
|
|
960
|
-
children: /* @__PURE__ */ Z(
|
|
997
|
+
onClick: fe,
|
|
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",
|
|
@@ -965,7 +1003,7 @@ function gr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
965
1003
|
children: "Copy to clipboard"
|
|
966
1004
|
}) : null]
|
|
967
1005
|
}),
|
|
968
|
-
|
|
1006
|
+
te && oe === "preview" ? /* @__PURE__ */ Q("div", {
|
|
969
1007
|
className: "markweave-mermaid-preview-actions",
|
|
970
1008
|
"data-testid": "markweave-mermaid-preview-actions",
|
|
971
1009
|
children: [/* @__PURE__ */ Z("button", {
|
|
@@ -973,24 +1011,24 @@ function gr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
973
1011
|
className: "markweave-codeblock-icon-button",
|
|
974
1012
|
"aria-label": "Fullscreen Mermaid preview",
|
|
975
1013
|
"data-testid": "markweave-mermaid-fullscreen",
|
|
976
|
-
disabled: !
|
|
1014
|
+
disabled: !se,
|
|
977
1015
|
onMouseDown: (e) => e.preventDefault(),
|
|
978
|
-
onClick:
|
|
979
|
-
children: /* @__PURE__ */ Z(
|
|
1016
|
+
onClick: ge,
|
|
1017
|
+
children: /* @__PURE__ */ Z(yr, { icon: "expand" })
|
|
980
1018
|
}), /* @__PURE__ */ Z("button", {
|
|
981
1019
|
type: "button",
|
|
982
1020
|
className: "markweave-codeblock-icon-button",
|
|
983
1021
|
"aria-label": "Download Mermaid SVG",
|
|
984
1022
|
"data-testid": "markweave-mermaid-download",
|
|
985
|
-
disabled: !
|
|
1023
|
+
disabled: !se,
|
|
986
1024
|
onMouseDown: (e) => e.preventDefault(),
|
|
987
|
-
onClick:
|
|
988
|
-
children: /* @__PURE__ */ Z(
|
|
1025
|
+
onClick: he,
|
|
1026
|
+
children: /* @__PURE__ */ Z(yr, { icon: "download" })
|
|
989
1027
|
})]
|
|
990
1028
|
}) : null
|
|
991
1029
|
]
|
|
992
1030
|
}) : null,
|
|
993
|
-
|
|
1031
|
+
re && ne && _ ? /* @__PURE__ */ Q("div", {
|
|
994
1032
|
className: "markweave-codeblock-language-menu",
|
|
995
1033
|
role: "listbox",
|
|
996
1034
|
"aria-label": "Code block languages",
|
|
@@ -1011,11 +1049,11 @@ function gr({ 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) => {
|
|
1018
|
-
let t = e.language ===
|
|
1056
|
+
let t = e.language === L.language;
|
|
1019
1057
|
return /* @__PURE__ */ Q("button", {
|
|
1020
1058
|
type: "button",
|
|
1021
1059
|
role: "option",
|
|
@@ -1023,8 +1061,8 @@ function gr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1023
1061
|
"data-testid": `markweave-codeblock-language-option-${e.language}`,
|
|
1024
1062
|
"data-active": t ? "true" : "false",
|
|
1025
1063
|
onMouseDown: (e) => e.preventDefault(),
|
|
1026
|
-
onClick: () =>
|
|
1027
|
-
children: [/* @__PURE__ */ Z("span", { children: e.label }), t ? /* @__PURE__ */ Z(
|
|
1064
|
+
onClick: () => B(e.language),
|
|
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 gr({ 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 gr({ 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",
|
|
@@ -1078,8 +1116,8 @@ function gr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1078
1116
|
onMouseLeave: () => O(null),
|
|
1079
1117
|
onFocus: () => O("reset"),
|
|
1080
1118
|
onBlur: () => O(null),
|
|
1081
|
-
onClick:
|
|
1082
|
-
children: /* @__PURE__ */ Z(
|
|
1119
|
+
onClick: q,
|
|
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 gr({ 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 gr({ 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 Sr(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 Dr(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 Or(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 =
|
|
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 Lr({ editor: e, messages: t = _r, 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,23 +1316,23 @@ function Lr({ editor: e, messages: t = _r, selectionSnapshot: n, onRewriteSelect
|
|
|
1278
1316
|
e.view.dom,
|
|
1279
1317
|
o.boundaryPadding,
|
|
1280
1318
|
o.offset
|
|
1281
|
-
]),
|
|
1319
|
+
]), M = V(() => {
|
|
1282
1320
|
T.current && (T.current.style.visibility = "hidden", T.current.style.opacity = "0");
|
|
1283
|
-
}, []),
|
|
1321
|
+
}, []), N = V(() => {
|
|
1284
1322
|
j();
|
|
1285
|
-
}, [j]),
|
|
1286
|
-
...
|
|
1287
|
-
onShow:
|
|
1288
|
-
onUpdate:
|
|
1323
|
+
}, [j]), P = V(() => Rr(e), [e]), F = U(() => ({
|
|
1324
|
+
...Xe(o, { topBoundaryPadding: S }),
|
|
1325
|
+
onShow: M,
|
|
1326
|
+
onUpdate: N
|
|
1289
1327
|
}), [
|
|
1290
|
-
ee,
|
|
1291
1328
|
M,
|
|
1329
|
+
N,
|
|
1292
1330
|
o,
|
|
1293
1331
|
S
|
|
1294
1332
|
]);
|
|
1295
1333
|
H(() => {
|
|
1296
|
-
let e =
|
|
1297
|
-
s((t) =>
|
|
1334
|
+
let e = Sr();
|
|
1335
|
+
s((t) => $e(t, a, e));
|
|
1298
1336
|
}, [
|
|
1299
1337
|
a.hiddenReason,
|
|
1300
1338
|
a.motionDurationMs,
|
|
@@ -1308,8 +1346,8 @@ function Lr({ editor: e, messages: t = _r, selectionSnapshot: n, onRewriteSelect
|
|
|
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 Lr({ editor: e, messages: t = _r, 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;
|
|
@@ -1360,11 +1398,11 @@ function Lr({ editor: e, messages: t = _r, selectionSnapshot: n, onRewriteSelect
|
|
|
1360
1398
|
});
|
|
1361
1399
|
return () => window.cancelAnimationFrame(e);
|
|
1362
1400
|
}, [f]);
|
|
1363
|
-
let
|
|
1364
|
-
if (
|
|
1401
|
+
let I = (t) => {
|
|
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,23 +1412,23 @@ function Lr({ editor: e, messages: t = _r, 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();
|
|
1381
|
-
},
|
|
1419
|
+
}, ee = () => {
|
|
1382
1420
|
p(null), e.commands.focus();
|
|
1383
|
-
},
|
|
1421
|
+
}, L = () => {
|
|
1384
1422
|
v && e.commands.setTextSelection(v);
|
|
1385
|
-
},
|
|
1386
|
-
|
|
1387
|
-
},
|
|
1388
|
-
if (
|
|
1389
|
-
h(""), _(""),
|
|
1423
|
+
}, R = () => {
|
|
1424
|
+
L(), un(e, m) && ee();
|
|
1425
|
+
}, te = () => {
|
|
1426
|
+
if (L(), wn(e)) {
|
|
1427
|
+
h(""), _(""), ee();
|
|
1390
1428
|
return;
|
|
1391
1429
|
}
|
|
1392
1430
|
m.trim() && h("");
|
|
1393
|
-
},
|
|
1431
|
+
}, z = (e, t) => {
|
|
1394
1432
|
if (l(e), !e || !t || !E.current) {
|
|
1395
1433
|
d(null);
|
|
1396
1434
|
return;
|
|
@@ -1398,39 +1436,39 @@ function Lr({ editor: e, messages: t = _r, 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}`,
|
|
1405
1443
|
"data-motion": o.motionPhase,
|
|
1406
|
-
"data-position-strategy":
|
|
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
|
-
getReferencedVirtualElement:
|
|
1412
|
-
options:
|
|
1413
|
-
shouldShow: ({ editor: e }) => e.isEditable &&
|
|
1449
|
+
getReferencedVirtualElement: P,
|
|
1450
|
+
options: F,
|
|
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:
|
|
1425
|
-
onTooltipChange:
|
|
1426
|
-
onRun:
|
|
1462
|
+
onPointerDown: Cn,
|
|
1463
|
+
onTooltipChange: z,
|
|
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,
|
|
@@ -1438,16 +1476,16 @@ function Lr({ editor: e, messages: t = _r, selectionSnapshot: n, onRewriteSelect
|
|
|
1438
1476
|
canOpen: !!A,
|
|
1439
1477
|
canRemove: !!(g || m.trim()),
|
|
1440
1478
|
onValueChange: h,
|
|
1441
|
-
onApply:
|
|
1442
|
-
onOpen: () =>
|
|
1443
|
-
onRemove:
|
|
1479
|
+
onApply: R,
|
|
1480
|
+
onOpen: () => Sn(m),
|
|
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 Lr({ editor: e, messages: t = _r, 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 Rr({ 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 Rr({ 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 Rr({ 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 Rr({ 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 zr({ 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 zr({ 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 Br({ 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 Vr({ 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 Wr({ 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 Wr({ 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 Kr({ 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 Kr({ 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
|
|
1725
|
+
var Qr = {
|
|
1688
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:
|
|
1732
|
+
italic: j,
|
|
1733
|
+
underline: fe,
|
|
1696
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
1744
|
superscript: se,
|
|
1707
1745
|
subscript: oe,
|
|
1708
|
-
math:
|
|
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,11 +1763,11 @@ function $({ name: e }) {
|
|
|
1725
1763
|
}
|
|
1726
1764
|
//#endregion
|
|
1727
1765
|
//#region src/ui/math/MathEditorPopover.tsx
|
|
1728
|
-
function
|
|
1729
|
-
let i =
|
|
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,
|
|
@@ -1737,12 +1775,12 @@ function Yr({ editor: e, messages: t, onClose: n, target: r }) {
|
|
|
1737
1775
|
o
|
|
1738
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,
|
|
@@ -1759,12 +1797,12 @@ function Yr({ editor: e, messages: t, onClose: n, target: r }) {
|
|
|
1759
1797
|
H(() => {
|
|
1760
1798
|
s(r.latex);
|
|
1761
1799
|
}, [r.latex, r.pos]), H(() => {
|
|
1762
|
-
|
|
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,
|
|
@@ -1779,7 +1817,7 @@ function Yr({ editor: e, messages: t, onClose: n, target: r }) {
|
|
|
1779
1817
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
1780
1818
|
}, [n]);
|
|
1781
1819
|
let _ = V(() => {
|
|
1782
|
-
h &&
|
|
1820
|
+
h && ft(e, r, o) && n();
|
|
1783
1821
|
}, [
|
|
1784
1822
|
h,
|
|
1785
1823
|
e,
|
|
@@ -1910,31 +1948,31 @@ function Yr({ 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:
|
|
1966
|
+
emoji: re,
|
|
1967
|
+
math: ne,
|
|
1930
1968
|
table: ce,
|
|
1931
|
-
separator:
|
|
1932
|
-
image:
|
|
1933
|
-
video:
|
|
1934
|
-
attachment:
|
|
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 Qr({ 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,17 +1995,17 @@ function $r(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
|
|
1970
|
-
let [i, a] =
|
|
2007
|
+
function oi({ command: e, messages: t, onBack: n, onSelect: r }) {
|
|
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) => [
|
|
1973
2011
|
t.emoji,
|
|
@@ -2033,9 +2071,9 @@ function ni({ command: e, messages: t, onBack: n, onSelect: r }) {
|
|
|
2033
2071
|
]
|
|
2034
2072
|
});
|
|
2035
2073
|
}
|
|
2036
|
-
function
|
|
2037
|
-
let a = e.uploadKind ?? "attachment", [o, s] =
|
|
2038
|
-
r(e, { uploadResult: await
|
|
2074
|
+
function si({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
|
|
2075
|
+
let a = e.uploadKind ?? "attachment", [o, s] = G(""), [c, l] = G(null), [u, d] = G(null), [f, p] = G(!1), m = async (t) => {
|
|
2076
|
+
r(e, { uploadResult: await K({
|
|
2039
2077
|
kind: a,
|
|
2040
2078
|
source: t,
|
|
2041
2079
|
trigger: "slash-command"
|
|
@@ -2055,7 +2093,7 @@ function ri({ 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 ri({ 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 ri({ 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 ii({ commands: e, messages: t = Xr, 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 ii({ commands: e, messages: t = Xr, 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 ii({ commands: e, messages: t = Xr, 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 ii({ commands: e, messages: t = Xr, 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] =
|
|
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;
|
|
2213
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 oi({ active: e, editor: t, interactionState: n = It, messages: r = ai,
|
|
|
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 oi({ active: e, editor: t, interactionState: n = It, messages: r = ai,
|
|
|
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: {
|
|
@@ -2315,22 +2353,22 @@ function oi({ active: e, editor: t, interactionState: n = It, messages: r = ai,
|
|
|
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",
|
|
2329
2367
|
messages: r
|
|
2330
2368
|
});
|
|
2331
2369
|
return o.copyFeedback ? (b(o.copyFeedback), o.copyPayload && i?.(o.copyPayload)) : b(null), a?.(o.commandResult), o.success;
|
|
2332
|
-
},
|
|
2333
|
-
let n =
|
|
2370
|
+
}, I = (e) => {
|
|
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 oi({ active: e, editor: t, interactionState: n = It, messages: r = ai,
|
|
|
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",
|
|
@@ -2386,10 +2424,10 @@ function oi({ active: e, editor: t, interactionState: n = It, messages: r = ai,
|
|
|
2386
2424
|
"aria-haspopup": "menu",
|
|
2387
2425
|
title: r.table.columnActions,
|
|
2388
2426
|
"data-testid": "markweave-table-hover-column-handle",
|
|
2389
|
-
"data-axis-index":
|
|
2390
|
-
"data-axis-selected-cells":
|
|
2391
|
-
"data-axis-visual-cells":
|
|
2392
|
-
"data-axis-visual-size":
|
|
2427
|
+
"data-axis-index": M?.index ?? "",
|
|
2428
|
+
"data-axis-selected-cells": M?.selectedCellCount ?? "",
|
|
2429
|
+
"data-axis-visual-cells": M?.visualCellCount ?? "",
|
|
2430
|
+
"data-axis-visual-size": M?.visualWidth ?? "",
|
|
2393
2431
|
style: {
|
|
2394
2432
|
left: h.left,
|
|
2395
2433
|
top: h.top
|
|
@@ -2403,7 +2441,7 @@ function oi({ active: e, editor: t, interactionState: n = It, messages: r = ai,
|
|
|
2403
2441
|
children: "..."
|
|
2404
2442
|
})
|
|
2405
2443
|
}) : null,
|
|
2406
|
-
|
|
2444
|
+
N && _ ? /* @__PURE__ */ Z("button", {
|
|
2407
2445
|
type: "button",
|
|
2408
2446
|
ref: T,
|
|
2409
2447
|
className: "markweave-table-edge-handle markweave-table-edge-handle--selection",
|
|
@@ -2427,15 +2465,15 @@ function oi({ active: e, editor: t, interactionState: n = It, messages: r = ai,
|
|
|
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 ? {
|
|
2434
2472
|
left: d.left,
|
|
2435
2473
|
top: d.top
|
|
2436
2474
|
} : void 0,
|
|
2437
|
-
children:
|
|
2438
|
-
let i =
|
|
2475
|
+
children: P.map((e, n) => {
|
|
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",
|
|
@@ -2450,10 +2488,10 @@ function oi({ active: e, editor: t, interactionState: n = It, messages: r = ai,
|
|
|
2450
2488
|
onClick: () => {
|
|
2451
2489
|
if (u) {
|
|
2452
2490
|
if (e.commandId === null) {
|
|
2453
|
-
|
|
2491
|
+
I(s === "row" || s === "column" ? s : "selection");
|
|
2454
2492
|
return;
|
|
2455
2493
|
}
|
|
2456
|
-
|
|
2494
|
+
F(e.commandId).finally(() => c(null));
|
|
2457
2495
|
}
|
|
2458
2496
|
},
|
|
2459
2497
|
children: d
|
|
@@ -2465,15 +2503,15 @@ function oi({ active: e, editor: t, interactionState: n = It, messages: r = ai,
|
|
|
2465
2503
|
}
|
|
2466
2504
|
//#endregion
|
|
2467
2505
|
//#region src/ui/table/TableSelectionOverlay.tsx
|
|
2468
|
-
function
|
|
2469
|
-
let [n, r] =
|
|
2470
|
-
return
|
|
2506
|
+
function di({ editor: e, focusState: t }) {
|
|
2507
|
+
let [n, r] = G(null);
|
|
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,18 +2546,22 @@ function si({ 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
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2552
|
+
function pi({ editor: e, state: t, messages: n, editable: r, placement: i }) {
|
|
2553
|
+
let a = W(null);
|
|
2554
|
+
if (H(() => {
|
|
2555
|
+
if (!(i !== "container" || !a.current)) return tr(a.current);
|
|
2556
|
+
}, [i]), !t.items.length) return null;
|
|
2557
|
+
let o = (t) => {
|
|
2558
|
+
nr(e, t, {
|
|
2518
2559
|
behavior: "smooth",
|
|
2519
2560
|
focus: r
|
|
2520
2561
|
});
|
|
2521
2562
|
};
|
|
2522
2563
|
return /* @__PURE__ */ Q("nav", {
|
|
2564
|
+
ref: a,
|
|
2523
2565
|
className: "markweave-inner-toc",
|
|
2524
2566
|
"data-testid": "markweave-inner-toc",
|
|
2525
2567
|
"aria-label": n.toc.ariaLabel,
|
|
@@ -2540,9 +2582,9 @@ function li({ editor: e, state: t, messages: n, editable: r }) {
|
|
|
2540
2582
|
"data-level": e.level,
|
|
2541
2583
|
"data-active": e.active ? "true" : "false",
|
|
2542
2584
|
"aria-current": e.active ? "location" : void 0,
|
|
2543
|
-
"aria-label":
|
|
2585
|
+
"aria-label": fi(n, e),
|
|
2544
2586
|
title: e.text,
|
|
2545
|
-
onClick: () =>
|
|
2587
|
+
onClick: () => o(e),
|
|
2546
2588
|
children: e.text
|
|
2547
2589
|
}, e.id))
|
|
2548
2590
|
})
|
|
@@ -2551,7 +2593,7 @@ function li({ editor: e, state: t, messages: n, editable: r }) {
|
|
|
2551
2593
|
}
|
|
2552
2594
|
//#endregion
|
|
2553
2595
|
//#region src/MarkweaveEditor.tsx
|
|
2554
|
-
var
|
|
2596
|
+
var mi = {
|
|
2555
2597
|
active: !1,
|
|
2556
2598
|
mode: "outside",
|
|
2557
2599
|
activeCellPos: null,
|
|
@@ -2559,21 +2601,21 @@ var ui = {
|
|
|
2559
2601
|
selectedCellCount: 0,
|
|
2560
2602
|
selectionFrom: 0,
|
|
2561
2603
|
selectionTo: 0
|
|
2562
|
-
},
|
|
2604
|
+
}, hi = {
|
|
2563
2605
|
active: !1,
|
|
2564
|
-
language:
|
|
2606
|
+
language: it.defaultLanguage,
|
|
2565
2607
|
mermaidPreviewMode: "code",
|
|
2566
2608
|
pos: null,
|
|
2567
2609
|
text: ""
|
|
2568
|
-
},
|
|
2610
|
+
}, gi = dt({
|
|
2569
2611
|
active: !1,
|
|
2570
2612
|
mode: "code",
|
|
2571
2613
|
source: ""
|
|
2572
2614
|
});
|
|
2573
|
-
function
|
|
2574
|
-
return
|
|
2615
|
+
function _i(e) {
|
|
2616
|
+
return zt.getState(e.state) ?? Rt;
|
|
2575
2617
|
}
|
|
2576
|
-
function
|
|
2618
|
+
function vi(e) {
|
|
2577
2619
|
if (!e || typeof window > "u") return null;
|
|
2578
2620
|
let t = e.parentElement;
|
|
2579
2621
|
for (; t;) {
|
|
@@ -2583,71 +2625,71 @@ function mi(e) {
|
|
|
2583
2625
|
}
|
|
2584
2626
|
return null;
|
|
2585
2627
|
}
|
|
2586
|
-
function
|
|
2628
|
+
function yi(e) {
|
|
2587
2629
|
return typeof window > "u" || typeof window.requestAnimationFrame != "function" ? globalThis.setTimeout(() => e(0), 0) : window.requestAnimationFrame(e);
|
|
2588
2630
|
}
|
|
2589
|
-
function
|
|
2631
|
+
function bi(e) {
|
|
2590
2632
|
if (typeof window < "u" && typeof window.cancelAnimationFrame == "function") {
|
|
2591
2633
|
window.cancelAnimationFrame(e);
|
|
2592
2634
|
return;
|
|
2593
2635
|
}
|
|
2594
2636
|
globalThis.clearTimeout(e);
|
|
2595
2637
|
}
|
|
2596
|
-
function
|
|
2597
|
-
let
|
|
2598
|
-
editorMode:
|
|
2599
|
-
effectiveEditable:
|
|
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({
|
|
2640
|
+
editorMode: S,
|
|
2641
|
+
effectiveEditable: w
|
|
2600
2642
|
});
|
|
2601
|
-
|
|
2602
|
-
editorMode:
|
|
2603
|
-
effectiveEditable:
|
|
2643
|
+
E.current = {
|
|
2644
|
+
editorMode: S,
|
|
2645
|
+
effectiveEditable: w
|
|
2604
2646
|
};
|
|
2605
|
-
let
|
|
2606
|
-
|
|
2607
|
-
let
|
|
2608
|
-
|
|
2609
|
-
let
|
|
2610
|
-
lang:
|
|
2647
|
+
let D = W(null);
|
|
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(_);
|
|
2650
|
+
j.current = _;
|
|
2651
|
+
let M = U(() => _r({
|
|
2652
|
+
lang: O,
|
|
2611
2653
|
onImageUpload: (e) => {
|
|
2612
|
-
if (
|
|
2613
|
-
let t =
|
|
2654
|
+
if (j.current) return j.current(e);
|
|
2655
|
+
let t = _e(e);
|
|
2614
2656
|
if (!t) throw Error("File upload requires an upload handler.");
|
|
2615
2657
|
return t;
|
|
2616
2658
|
},
|
|
2617
2659
|
onVideoUpload: (e) => {
|
|
2618
|
-
if (
|
|
2619
|
-
let t =
|
|
2660
|
+
if (j.current) return j.current(e);
|
|
2661
|
+
let t = _e(e);
|
|
2620
2662
|
if (!t) throw Error("File upload requires an upload handler.");
|
|
2621
2663
|
return t;
|
|
2622
2664
|
}
|
|
2623
|
-
}), [
|
|
2624
|
-
|
|
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]);
|
|
2666
|
+
fe.current = { onUpdate: x };
|
|
2625
2667
|
let B = V(() => {
|
|
2626
|
-
|
|
2627
|
-
}, []),
|
|
2628
|
-
let t =
|
|
2668
|
+
L(null), te(null), I(Mt);
|
|
2669
|
+
}, []), me = V((e) => {
|
|
2670
|
+
let t = jt(e.state);
|
|
2629
2671
|
if (!t) {
|
|
2630
|
-
|
|
2672
|
+
I((e) => e.name === "idle" ? e : Mt), L(null), te(null);
|
|
2631
2673
|
return;
|
|
2632
2674
|
}
|
|
2633
2675
|
let n = e.coordsAtPos(t.cursor), r = e.coordsAtPos(t.triggerFrom), i = e.dom.closest(".markweave-editor-frame")?.getBoundingClientRect();
|
|
2634
|
-
|
|
2676
|
+
L(At(n, {
|
|
2635
2677
|
frameRect: i,
|
|
2636
2678
|
triggerRect: r
|
|
2637
|
-
})),
|
|
2638
|
-
}, []),
|
|
2639
|
-
|
|
2640
|
-
let t =
|
|
2641
|
-
t && (
|
|
2642
|
-
let n =
|
|
2643
|
-
n.active && n.language === "mermaid" &&
|
|
2644
|
-
}, []),
|
|
2645
|
-
|
|
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);
|
|
2685
|
+
n.active && n.language === "mermaid" && ne(n.mermaidPreviewMode);
|
|
2686
|
+
}, []), K = V((e) => {
|
|
2687
|
+
oe(_i(e));
|
|
2646
2688
|
}, []), q = i({
|
|
2647
|
-
extensions:
|
|
2689
|
+
extensions: M,
|
|
2648
2690
|
content: r ?? o,
|
|
2649
|
-
contentType:
|
|
2650
|
-
editable:
|
|
2691
|
+
contentType: Ve(T),
|
|
2692
|
+
editable: w,
|
|
2651
2693
|
autofocus: n,
|
|
2652
2694
|
editorProps: {
|
|
2653
2695
|
attributes: {
|
|
@@ -2658,325 +2700,328 @@ function _i({ ariaLabel: e, autoFocusFirstTableBodyCell: t = !1, autofocus: n =
|
|
|
2658
2700
|
spellcheck: "false",
|
|
2659
2701
|
translate: "no"
|
|
2660
2702
|
},
|
|
2661
|
-
handleClick: (e, t, n) =>
|
|
2703
|
+
handleClick: (e, t, n) => E.current.effectiveEditable ? !1 : We(n),
|
|
2662
2704
|
handleDOMEvents: {
|
|
2663
|
-
compositionstart: () =>
|
|
2664
|
-
compositionend: (e) => (
|
|
2705
|
+
compositionstart: () => E.current.effectiveEditable ? (I((e) => Nt(e, { type: "composition-start" })), L(null), !1) : !1,
|
|
2706
|
+
compositionend: (e) => (E.current.effectiveEditable && window.setTimeout(() => me(e), 0), !1),
|
|
2665
2707
|
click: (e, t) => {
|
|
2666
|
-
if (
|
|
2667
|
-
let n =
|
|
2668
|
-
return n ? (t.preventDefault(), t.stopPropagation(), B(),
|
|
2708
|
+
if (E.current.effectiveEditable) {
|
|
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);
|
|
2669
2711
|
}
|
|
2670
|
-
return
|
|
2712
|
+
return We(t);
|
|
2671
2713
|
}
|
|
2672
2714
|
}
|
|
2673
2715
|
},
|
|
2674
2716
|
onSelectionUpdate: ({ editor: e }) => {
|
|
2675
|
-
|
|
2717
|
+
ge(e);
|
|
2676
2718
|
},
|
|
2677
2719
|
onCreate: ({ editor: e }) => {
|
|
2678
|
-
t &&
|
|
2720
|
+
t && E.current.effectiveEditable && Ft(e), K(e), ge(e), ue((e) => e + 1);
|
|
2679
2721
|
},
|
|
2680
2722
|
onTransaction: ({ editor: e, transaction: t }) => {
|
|
2681
|
-
|
|
2723
|
+
K(e), (t.docChanged || ct(t)) && ue((e) => e + 1), t.docChanged && ie((t) => {
|
|
2682
2724
|
if (!t) return null;
|
|
2683
|
-
let n =
|
|
2725
|
+
let n = _t(e, t.pos);
|
|
2684
2726
|
return n?.kind === t.kind ? n : null;
|
|
2685
2727
|
});
|
|
2686
2728
|
},
|
|
2687
2729
|
onUpdate: ({ editor: e }) => {
|
|
2688
|
-
|
|
2730
|
+
ge(e), E.current.effectiveEditable && he(e), de.current || fe.current.onUpdate?.(Be(e));
|
|
2689
2731
|
}
|
|
2690
2732
|
});
|
|
2691
2733
|
H(() => {
|
|
2692
|
-
q && (q.setEditable(
|
|
2693
|
-
mode:
|
|
2694
|
-
editable:
|
|
2695
|
-
}),
|
|
2734
|
+
q && (q.setEditable(w), Fe(q, {
|
|
2735
|
+
mode: S,
|
|
2736
|
+
editable: w
|
|
2737
|
+
}), lt(q, w ? "live" : "view"), w || B());
|
|
2696
2738
|
}, [
|
|
2697
2739
|
B,
|
|
2698
2740
|
q,
|
|
2699
|
-
|
|
2700
|
-
|
|
2741
|
+
S,
|
|
2742
|
+
w
|
|
2701
2743
|
]), H(() => {
|
|
2702
|
-
!q || r === void 0 ||
|
|
2703
|
-
contentType:
|
|
2744
|
+
!q || r === void 0 || He(q, r, Ue(a)) || (de.current = !0, q.commands.setContent(r, {
|
|
2745
|
+
contentType: Ve(Ue(a)),
|
|
2704
2746
|
emitUpdate: !1
|
|
2705
|
-
}),
|
|
2747
|
+
}), de.current = !1, ge(q), w && he(q), K(q), ue((e) => e + 1));
|
|
2706
2748
|
}, [
|
|
2707
2749
|
r,
|
|
2708
2750
|
a,
|
|
2709
|
-
|
|
2751
|
+
w,
|
|
2710
2752
|
q,
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2753
|
+
ge,
|
|
2754
|
+
he,
|
|
2755
|
+
K
|
|
2714
2756
|
]), H(() => {
|
|
2715
|
-
if (!
|
|
2757
|
+
if (!ee) return;
|
|
2716
2758
|
let e = (e) => {
|
|
2717
2759
|
let t = e.target;
|
|
2718
2760
|
t instanceof Element && (t.closest(".markweave-slash-menu") || t.closest(".markweave-slash-trigger") || B());
|
|
2719
2761
|
};
|
|
2720
2762
|
return document.addEventListener("pointerdown", e, !0), () => document.removeEventListener("pointerdown", e, !0);
|
|
2721
|
-
}, [B,
|
|
2722
|
-
let
|
|
2763
|
+
}, [B, ee]);
|
|
2764
|
+
let ve = U(() => q ? nt(q) : hi, [
|
|
2723
2765
|
q,
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
]),
|
|
2766
|
+
le,
|
|
2767
|
+
N
|
|
2768
|
+
]), ye = U(() => q ? It(q.state) : mi, [
|
|
2727
2769
|
q,
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
]),
|
|
2732
|
-
active:
|
|
2733
|
-
mode:
|
|
2734
|
-
source:
|
|
2735
|
-
}) :
|
|
2736
|
-
|
|
2770
|
+
le,
|
|
2771
|
+
N,
|
|
2772
|
+
ae
|
|
2773
|
+
]), be = N?.currentNode === "codeBlock", xe = be && ve.language === "mermaid", Se = U(() => q ? dt({
|
|
2774
|
+
active: xe,
|
|
2775
|
+
mode: z,
|
|
2776
|
+
source: ve.text
|
|
2777
|
+
}) : gi, [
|
|
2778
|
+
ve.text,
|
|
2737
2779
|
q,
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
]),
|
|
2780
|
+
xe,
|
|
2781
|
+
z
|
|
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(() => {
|
|
2741
2783
|
if (!q || !J.length) {
|
|
2742
|
-
|
|
2784
|
+
ce(null);
|
|
2743
2785
|
return;
|
|
2744
2786
|
}
|
|
2745
|
-
let e =
|
|
2746
|
-
|
|
2787
|
+
let e = Zn(q, J);
|
|
2788
|
+
ce((t) => t === e ? t : e);
|
|
2747
2789
|
}, [q, J]);
|
|
2748
2790
|
H(() => {
|
|
2749
|
-
|
|
2750
|
-
let t =
|
|
2791
|
+
ce((e) => {
|
|
2792
|
+
let t = $n(J, e);
|
|
2751
2793
|
return e === t ? e : t;
|
|
2752
2794
|
});
|
|
2753
2795
|
}, [J]), H(() => {
|
|
2754
2796
|
if (!q || !J.length || typeof window > "u") return;
|
|
2755
2797
|
let e = null, t = () => {
|
|
2756
|
-
e !== null &&
|
|
2757
|
-
e = null,
|
|
2798
|
+
e !== null && bi(e), e = yi(() => {
|
|
2799
|
+
e = null, Ee();
|
|
2758
2800
|
});
|
|
2759
|
-
}, n =
|
|
2801
|
+
}, n = vi(q.view.dom);
|
|
2760
2802
|
return window.addEventListener("scroll", t, { passive: !0 }), window.addEventListener("resize", t), n?.addEventListener("scroll", t, { passive: !0 }), t(), () => {
|
|
2761
|
-
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);
|
|
2762
2804
|
};
|
|
2763
2805
|
}, [
|
|
2764
2806
|
q,
|
|
2765
2807
|
J.length,
|
|
2766
|
-
|
|
2808
|
+
Ee
|
|
2767
2809
|
]);
|
|
2768
|
-
let
|
|
2769
|
-
revision:
|
|
2770
|
-
mode:
|
|
2771
|
-
editable:
|
|
2772
|
-
toc:
|
|
2773
|
-
selection:
|
|
2774
|
-
slash:
|
|
2775
|
-
table:
|
|
2776
|
-
tableInteraction:
|
|
2777
|
-
codeBlock:
|
|
2778
|
-
mermaid:
|
|
2779
|
-
tableDebugSnapshot:
|
|
2810
|
+
let De = U(() => Ge({
|
|
2811
|
+
revision: le,
|
|
2812
|
+
mode: S,
|
|
2813
|
+
editable: w,
|
|
2814
|
+
toc: Te,
|
|
2815
|
+
selection: N,
|
|
2816
|
+
slash: F,
|
|
2817
|
+
table: ye,
|
|
2818
|
+
tableInteraction: ae,
|
|
2819
|
+
codeBlock: ve,
|
|
2820
|
+
mermaid: Se,
|
|
2821
|
+
tableDebugSnapshot: Ce
|
|
2780
2822
|
}), [
|
|
2781
|
-
|
|
2782
|
-
x,
|
|
2823
|
+
ve,
|
|
2783
2824
|
S,
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2825
|
+
w,
|
|
2826
|
+
Se,
|
|
2827
|
+
le,
|
|
2828
|
+
N,
|
|
2829
|
+
F,
|
|
2830
|
+
Ce,
|
|
2831
|
+
ye,
|
|
2832
|
+
ae,
|
|
2833
|
+
Te
|
|
2792
2834
|
]);
|
|
2793
2835
|
H(() => {
|
|
2794
|
-
|
|
2795
|
-
}, [
|
|
2796
|
-
|
|
2797
|
-
}, [
|
|
2798
|
-
let
|
|
2799
|
-
if (!(!q || !
|
|
2836
|
+
g?.(De);
|
|
2837
|
+
}, [g, De]), H(() => {
|
|
2838
|
+
b?.(Te);
|
|
2839
|
+
}, [b, Te]);
|
|
2840
|
+
let Oe = V((e, t) => {
|
|
2841
|
+
if (!(!q || !w) && Tt(e)) {
|
|
2800
2842
|
if (e.inputKind && !t?.emoji && !t?.uploadResult) {
|
|
2801
|
-
|
|
2843
|
+
te(e);
|
|
2802
2844
|
return;
|
|
2803
2845
|
}
|
|
2804
|
-
|
|
2846
|
+
Ot(q, F, e, t), I((e) => Nt(e, { type: "execute" })), B();
|
|
2805
2847
|
}
|
|
2806
2848
|
}, [
|
|
2807
2849
|
B,
|
|
2808
|
-
|
|
2850
|
+
w,
|
|
2809
2851
|
q,
|
|
2810
|
-
|
|
2811
|
-
]),
|
|
2812
|
-
|
|
2852
|
+
F
|
|
2853
|
+
]), Y = V((e) => {
|
|
2854
|
+
I((t) => Nt(t, {
|
|
2813
2855
|
type: "set-active",
|
|
2814
2856
|
index: e,
|
|
2815
|
-
optionCount:
|
|
2857
|
+
optionCount: pe.length
|
|
2816
2858
|
}));
|
|
2817
|
-
}, [
|
|
2818
|
-
if (!q ||
|
|
2819
|
-
let t =
|
|
2859
|
+
}, [pe.length]), Me = V((e) => {
|
|
2860
|
+
if (!q || R || !w) return;
|
|
2861
|
+
let t = Et(F, pe, e.key, { isComposing: e.nativeEvent.isComposing || ze(q.state) });
|
|
2820
2862
|
if (t.type !== "ignore") {
|
|
2821
2863
|
if (t.type === "close") {
|
|
2822
|
-
e.preventDefault(),
|
|
2864
|
+
e.preventDefault(), I((e) => Nt(e, { type: "escape" })), B();
|
|
2823
2865
|
return;
|
|
2824
2866
|
}
|
|
2825
2867
|
if (t.type === "move-active") {
|
|
2826
|
-
e.preventDefault(),
|
|
2868
|
+
e.preventDefault(), I((e) => Nt(e, {
|
|
2827
2869
|
type: "move-active",
|
|
2828
2870
|
delta: t.delta,
|
|
2829
2871
|
optionCount: t.optionCount
|
|
2830
2872
|
}));
|
|
2831
2873
|
return;
|
|
2832
2874
|
}
|
|
2833
|
-
t.type === "execute-active" && (e.preventDefault(),
|
|
2875
|
+
t.type === "execute-active" && (e.preventDefault(), Oe(t.command));
|
|
2834
2876
|
}
|
|
2835
2877
|
}, [
|
|
2836
2878
|
B,
|
|
2837
|
-
|
|
2879
|
+
w,
|
|
2838
2880
|
q,
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
]),
|
|
2881
|
+
pe,
|
|
2882
|
+
Oe,
|
|
2883
|
+
R,
|
|
2884
|
+
F
|
|
2885
|
+
]), Ne = U(() => ({
|
|
2844
2886
|
closeSlashMenu: B,
|
|
2845
|
-
focusFirstTableBodyCell: () => q ?
|
|
2887
|
+
focusFirstTableBodyCell: () => q ? Ft(q) : !1,
|
|
2846
2888
|
setContent: (e, t = {}) => {
|
|
2847
2889
|
if (!q) return !1;
|
|
2848
|
-
let n =
|
|
2890
|
+
let n = Ue(t.format);
|
|
2849
2891
|
return q.commands.setContent(e, {
|
|
2850
|
-
contentType:
|
|
2892
|
+
contentType: Ve(n),
|
|
2851
2893
|
emitUpdate: t.emitUpdate ?? !1
|
|
2852
|
-
}), t.focusFirstTableBodyCell &&
|
|
2894
|
+
}), t.focusFirstTableBodyCell && Ft(q), ge(q), w && he(q), K(q), ue((e) => e + 1), !0;
|
|
2853
2895
|
}
|
|
2854
2896
|
}), [
|
|
2855
2897
|
B,
|
|
2856
|
-
|
|
2898
|
+
w,
|
|
2857
2899
|
q,
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2900
|
+
ge,
|
|
2901
|
+
he,
|
|
2902
|
+
K
|
|
2861
2903
|
]);
|
|
2862
2904
|
return {
|
|
2863
2905
|
editor: q,
|
|
2864
|
-
frameProps:
|
|
2906
|
+
frameProps: U(() => ({
|
|
2865
2907
|
className: "markweave-editor-frame",
|
|
2866
|
-
"aria-label": e ??
|
|
2908
|
+
"aria-label": e ?? k.common.editorAriaLabel,
|
|
2867
2909
|
"data-testid": "markweave-editor-frame",
|
|
2868
|
-
"data-markweave-mode":
|
|
2910
|
+
"data-markweave-mode": S,
|
|
2869
2911
|
"data-markweave-inner-toc": l ? "true" : "false",
|
|
2870
|
-
"data-
|
|
2871
|
-
"data-
|
|
2872
|
-
|
|
2912
|
+
"data-markweave-inner-toc-placement": C,
|
|
2913
|
+
"data-mermaid-mode": Se.mode,
|
|
2914
|
+
"data-table-focus-mode": ye.mode,
|
|
2915
|
+
onKeyDownCapture: Me
|
|
2873
2916
|
}), [
|
|
2874
2917
|
e,
|
|
2875
|
-
|
|
2876
|
-
|
|
2918
|
+
S,
|
|
2919
|
+
Me,
|
|
2877
2920
|
l,
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2921
|
+
Se.mode,
|
|
2922
|
+
k.common.editorAriaLabel,
|
|
2923
|
+
C,
|
|
2924
|
+
ye.mode
|
|
2881
2925
|
]),
|
|
2882
|
-
overlayProps:
|
|
2883
|
-
floatingToolbar: q &&
|
|
2926
|
+
overlayProps: U(() => ({
|
|
2927
|
+
floatingToolbar: q && w ? {
|
|
2884
2928
|
editor: q,
|
|
2885
|
-
messages:
|
|
2886
|
-
selectionSnapshot:
|
|
2887
|
-
onRewriteSelection:
|
|
2888
|
-
onExtractToNote:
|
|
2929
|
+
messages: k,
|
|
2930
|
+
selectionSnapshot: N,
|
|
2931
|
+
onRewriteSelection: h,
|
|
2932
|
+
onExtractToNote: m
|
|
2889
2933
|
} : null,
|
|
2890
|
-
slashCommandMenu: q &&
|
|
2891
|
-
commands:
|
|
2892
|
-
state:
|
|
2893
|
-
position:
|
|
2894
|
-
inputCommand:
|
|
2895
|
-
messages:
|
|
2896
|
-
onActiveIndexChange:
|
|
2897
|
-
onInputCommandChange:
|
|
2898
|
-
onSelect:
|
|
2899
|
-
onUpload:
|
|
2934
|
+
slashCommandMenu: q && w ? {
|
|
2935
|
+
commands: pe,
|
|
2936
|
+
state: F,
|
|
2937
|
+
position: ee,
|
|
2938
|
+
inputCommand: R,
|
|
2939
|
+
messages: k,
|
|
2940
|
+
onActiveIndexChange: Y,
|
|
2941
|
+
onInputCommandChange: te,
|
|
2942
|
+
onSelect: Oe,
|
|
2943
|
+
onUpload: _
|
|
2900
2944
|
} : null,
|
|
2901
|
-
tableControls: q &&
|
|
2945
|
+
tableControls: q && w ? {
|
|
2902
2946
|
editor: q,
|
|
2903
|
-
active:
|
|
2904
|
-
interactionState:
|
|
2905
|
-
messages:
|
|
2906
|
-
onCopyPayload:
|
|
2907
|
-
onCommandResult:
|
|
2908
|
-
onEditWithAi:
|
|
2947
|
+
active: ye.active,
|
|
2948
|
+
interactionState: ae,
|
|
2949
|
+
messages: k,
|
|
2950
|
+
onCopyPayload: y,
|
|
2951
|
+
onCommandResult: v,
|
|
2952
|
+
onEditWithAi: p
|
|
2909
2953
|
} : null,
|
|
2910
|
-
tableSelectionOverlay: q &&
|
|
2954
|
+
tableSelectionOverlay: q && w ? {
|
|
2911
2955
|
editor: q,
|
|
2912
|
-
focusState:
|
|
2956
|
+
focusState: ye
|
|
2913
2957
|
} : null,
|
|
2914
2958
|
codeBlockControls: q ? {
|
|
2915
2959
|
editor: q,
|
|
2916
|
-
active:
|
|
2917
|
-
mermaidMode:
|
|
2918
|
-
onMermaidModeChange:
|
|
2919
|
-
readOnly: !
|
|
2960
|
+
active: w && be,
|
|
2961
|
+
mermaidMode: z,
|
|
2962
|
+
onMermaidModeChange: ne,
|
|
2963
|
+
readOnly: !w
|
|
2920
2964
|
} : null,
|
|
2921
|
-
innerToc: q && l &&
|
|
2965
|
+
innerToc: q && l && Te.items.length ? {
|
|
2922
2966
|
editor: q,
|
|
2923
|
-
editable:
|
|
2924
|
-
messages:
|
|
2925
|
-
|
|
2967
|
+
editable: w,
|
|
2968
|
+
messages: k,
|
|
2969
|
+
placement: C,
|
|
2970
|
+
state: Te
|
|
2926
2971
|
} : null,
|
|
2927
|
-
mathEditorPopover: q &&
|
|
2972
|
+
mathEditorPopover: q && w && re ? {
|
|
2928
2973
|
editor: q,
|
|
2929
|
-
messages:
|
|
2930
|
-
target:
|
|
2931
|
-
onClose: () =>
|
|
2974
|
+
messages: k,
|
|
2975
|
+
target: re,
|
|
2976
|
+
onClose: () => ie(null)
|
|
2932
2977
|
} : null
|
|
2933
2978
|
}), [
|
|
2934
|
-
|
|
2979
|
+
w,
|
|
2935
2980
|
q,
|
|
2936
|
-
|
|
2981
|
+
pe,
|
|
2937
2982
|
l,
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
f,
|
|
2983
|
+
be,
|
|
2984
|
+
z,
|
|
2985
|
+
k,
|
|
2986
|
+
re,
|
|
2943
2987
|
p,
|
|
2944
2988
|
m,
|
|
2945
|
-
|
|
2989
|
+
h,
|
|
2946
2990
|
_,
|
|
2947
2991
|
v,
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2992
|
+
y,
|
|
2993
|
+
Oe,
|
|
2994
|
+
N,
|
|
2995
|
+
Y,
|
|
2996
|
+
R,
|
|
2997
|
+
ee,
|
|
2998
|
+
F,
|
|
2999
|
+
ye,
|
|
3000
|
+
ae,
|
|
3001
|
+
Te
|
|
2957
3002
|
]),
|
|
2958
|
-
runtimeSnapshot:
|
|
2959
|
-
actions:
|
|
3003
|
+
runtimeSnapshot: De,
|
|
3004
|
+
actions: Ne
|
|
2960
3005
|
};
|
|
2961
3006
|
}
|
|
2962
|
-
function
|
|
2963
|
-
let r =
|
|
3007
|
+
function Si({ className: e, ...n }) {
|
|
3008
|
+
let r = xi(n);
|
|
2964
3009
|
if (!r.editor) return null;
|
|
2965
3010
|
let i = [r.frameProps.className, e].filter(Boolean).join(" ");
|
|
2966
3011
|
return /* @__PURE__ */ Q("section", {
|
|
2967
3012
|
...r.frameProps,
|
|
2968
3013
|
className: i,
|
|
2969
3014
|
children: [
|
|
2970
|
-
r.overlayProps.floatingToolbar ? /* @__PURE__ */ Z(
|
|
2971
|
-
r.overlayProps.slashCommandMenu ? /* @__PURE__ */ Z(
|
|
2972
|
-
r.overlayProps.tableControls ? /* @__PURE__ */ Z(
|
|
2973
|
-
r.overlayProps.tableSelectionOverlay ? /* @__PURE__ */ Z(
|
|
2974
|
-
r.overlayProps.codeBlockControls ? /* @__PURE__ */ Z(
|
|
2975
|
-
r.overlayProps.innerToc ? /* @__PURE__ */ Z(
|
|
2976
|
-
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,
|
|
2977
3022
|
/* @__PURE__ */ Z(t, { editor: r.editor })
|
|
2978
3023
|
]
|
|
2979
3024
|
});
|
|
2980
3025
|
}
|
|
2981
3026
|
//#endregion
|
|
2982
|
-
export {
|
|
3027
|
+
export { Si as MarkweaveEditor, _r as createMarkweaveEditorExtensions, _r as createMarkweaveReactEditorExtensions, xi as useMarkweaveEditorController };
|