@markweave/react 0.3.3 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +19 -19
- package/dist/index.js +922 -865
- package/dist/types/ui/table/TableControls.d.ts.map +1 -1
- package/dist/types/ui/table/TableSelectionOverlay.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createMarkweaveEditorExtensions as e } from "markweave/internal/editor-core/create-editor-extensions";
|
|
2
2
|
import { getLocalizedSlashCommandSpecs as t, getMarkweaveMessages as n, normalizeMarkweaveLang as r } from "markweave/internal/i18n";
|
|
3
3
|
import { EditorContent as i, NodeViewWrapper as a, ReactNodeViewRenderer as o, useEditor as s } from "@tiptap/react";
|
|
4
|
-
import { AlertTriangle as c, AlignCenter as l, AlignJustify as u, AlignLeft as d, AlignRight as f, AlignVerticalJustifyCenter as p, AlignVerticalJustifyEnd as m, AlignVerticalJustifyStart as h, ArrowDown as g, ArrowDownAZ as _, ArrowLeft as v, ArrowRight as y, ArrowUp as b, ArrowUpZA as x, BetweenHorizontalEnd as S, BetweenHorizontalStart as C, BetweenVerticalEnd as w, BetweenVerticalStart as T, Bold as E, Braces as D, Captions as O, Check as k, CheckCircle2 as A, ChevronDown as j, ChevronRight as M, ChevronUp as
|
|
5
|
-
import { useCallback as
|
|
6
|
-
import { detectUploadSource as
|
|
7
|
-
import { MarkweaveCoreImage as
|
|
4
|
+
import { AlertTriangle as c, AlignCenter as l, AlignJustify as u, AlignLeft as d, AlignRight as f, AlignVerticalJustifyCenter as p, AlignVerticalJustifyEnd as m, AlignVerticalJustifyStart as h, ArrowDown as g, ArrowDownAZ as _, ArrowLeft as v, ArrowRight as y, ArrowUp as b, ArrowUpZA as x, BetweenHorizontalEnd as S, BetweenHorizontalStart as C, BetweenVerticalEnd as w, BetweenVerticalStart as T, Bold as E, Braces as D, Captions as O, Check as k, CheckCircle2 as A, ChevronDown as j, ChevronRight as M, ChevronUp as ee, CircleX as N, Code2 as te, Copy as P, CornerDownLeft as ne, Download as F, ExternalLink as I, Eye as L, Heading1 as re, Heading2 as R, Heading3 as ie, Image as ae, ImageUp as z, IndentDecrease as B, IndentIncrease as oe, Info as se, Italic as ce, Lightbulb as le, Link2 as V, List as ue, ListChecks as H, ListOrdered as U, Minus as de, MoreVertical as fe, PaintBucket as pe, Paperclip as me, Pencil as he, Plus as ge, Quote as _e, Replace as ve, Sigma as ye, SmilePlus as be, Sparkles as xe, SquareX as Se, Strikethrough as Ce, Subscript as we, Superscript as Te, Table2 as Ee, TableCellsMerge as De, TableCellsSplit as Oe, Text as ke, Trash2 as Ae, Type as je, Underline as Me, Upload as Ne, Video as Pe } from "lucide-react";
|
|
5
|
+
import { useCallback as W, useEffect as G, useLayoutEffect as K, useMemo as q, useRef as J, useState as Y, useSyncExternalStore as Fe } from "react";
|
|
6
|
+
import { detectUploadSource as Ie, getDirectUploadResult as Le, resolveMarkweaveUploadResult as X } from "markweave/internal/plugins/slash-command/upload";
|
|
7
|
+
import { MarkweaveCoreImage as Re, MarkweaveCoreVideo as ze, attrsFromMarkweaveImageUploadResult as Be, attrsFromMarkweaveVideoUploadResult as Ve, attrsFromMarkweaveVideoUrl as He, clampMarkweaveImageWidth as Ue, createMarkweaveImageUploadRequest as We, createMarkweaveVideoUploadRequest as Ge, downloadMarkweaveImage as Ke, markweaveVideoIframeAllow as qe, normalizeMarkweaveCoreImageAlign as Je, normalizeMarkweaveVideoEmbedUrl as Ye, numberAttribute as Xe, stringAttribute as Ze } from "markweave/internal/plugins/media/core-media-nodes";
|
|
8
8
|
import { getMarkweaveEditorModeState as Qe, isMarkweaveEditorLiveEditable as $e, normalizeMarkweaveEditorMode as et, setMarkweaveEditorModeState as tt, subscribeToMarkweaveEditorMode as nt } from "markweave/internal/core/editor-mode-state";
|
|
9
9
|
import { openMarkweaveImagePreview as rt } from "markweave/internal/plugins/media/image-preview";
|
|
10
10
|
import { createMarkweaveLightweightImageNodeViewRenderer as it } from "markweave/internal/plugins/media/lightweight-image-node-view";
|
|
@@ -38,30 +38,30 @@ import { BubbleMenu as Zn } from "@tiptap/react/menus";
|
|
|
38
38
|
import { applyFloatingToolbarLink as Qn, createFloatingToolbarAssistantRequest as $n, getFloatingToolbarButtonModels as er, getFloatingToolbarHighlightColorOptions as tr, getFloatingToolbarLinkHref as nr, getFloatingToolbarMessageSet as rr, getFloatingToolbarMoreActions as ir, getFloatingToolbarTextColorOptions as ar, getFloatingToolbarTooltipModel as or, getFloatingToolbarTurnIntoOptions as sr, isFloatingToolbarMoreActionActive as cr, isFloatingToolbarTurnIntoActive as lr, openFloatingToolbarLinkHref as ur, preventFloatingToolbarPointerFocusLoss as dr, removeFloatingToolbarLink as fr, runFloatingToolbarMoreAction as pr, setFloatingToolbarHighlightColor as mr, setFloatingToolbarTextColor as hr, setFloatingToolbarTurnInto as gr } from "markweave/internal/editor-core/floating-toolbar-model";
|
|
39
39
|
import { normalizeMarkdownLinkHref as _r } from "markweave/internal/plugins/markdown/markdown-input";
|
|
40
40
|
import { setMarkweaveTableMenuAxisTarget as vr } from "markweave/internal/plugins/table/table-clipboard";
|
|
41
|
-
import { applyTableAxisAlignment as yr, applyTableAxisBackgroundColor as br, applyTableAxisTextColor as xr, calculateAnchoredTableMenuPosition as Sr,
|
|
42
|
-
import { createMarkweaveTocState as
|
|
43
|
-
import { normalizeMarkweaveCanvasColor as
|
|
44
|
-
import { splitMarkweaveLargeMarkdown as
|
|
45
|
-
import { createMarkweaveSearchController as
|
|
41
|
+
import { applyTableAxisAlignment as yr, applyTableAxisBackgroundColor as br, applyTableAxisTextColor as xr, calculateAnchoredTableMenuPosition as Sr, calculateAnchoredTableSubmenuPosition as Cr, calculateTableAxisHandleLayout as wr, calculateTableExtendButtonLayout as Tr, canRunTableCommand as Er, executeTableMenuCommand as Dr, formatTableCopyFeedback as Or, getActiveTableElement as kr, getTableAxisDropIndexAtPoint as Ar, getTableAxisFormattingState as jr, getTableAxisTargetRect as Mr, getTableControlAxisSelectionModel as Nr, getTableEditWithAiRequest as Pr, getTableMenuBoundaryRect as Fr, getTableMenuItemGroup as Ir, getTableMenuItemLabel as Lr, getTableMenuItems as Rr, getTableSelectionTargetRect as zr, measureTableSelectionOverlay as Br, moveTargetedTableAxis as Vr, selectTableAxisFromCell as Hr, tableColorOptions as Ur, tableCopyFeedbackTimeoutMs as Wr, tableHorizontalAlignmentOptions as Gr, tableMenuLabel as Kr, tableVerticalAlignmentOptions as qr, targetTableAxisFromCell as Jr } from "markweave/internal/plugins/table/table-ui-model";
|
|
42
|
+
import { createMarkweaveTocState as Yr, emptyMarkweaveTocState as Xr, getActiveMarkweaveTocId as Zr, getMarkweaveTocItemsFromState as Qr, getValidMarkweaveTocActiveId as $r, normalizeMarkweaveInnerTocPlacement as ei, observeMarkweaveInnerTocContainerPosition as ti, scrollToMarkweaveTocItem as ni } from "markweave/internal/core/toc-state";
|
|
43
|
+
import { normalizeMarkweaveCanvasColor as ri, normalizeMarkweaveTheme as ii } from "markweave/internal/core/theme";
|
|
44
|
+
import { splitMarkweaveLargeMarkdown as ai } from "markweave/internal/core/large-document";
|
|
45
|
+
import { createMarkweaveSearchController as oi } from "markweave/internal/plugins/search/search-controller";
|
|
46
46
|
//#region src/editor-mode-state.ts
|
|
47
|
-
var
|
|
47
|
+
var si = {
|
|
48
48
|
mode: "live",
|
|
49
49
|
editable: !0
|
|
50
50
|
};
|
|
51
|
-
function
|
|
52
|
-
return
|
|
51
|
+
function ci(e) {
|
|
52
|
+
return Fe((t) => nt(e, t), () => Qe(e), () => si);
|
|
53
53
|
}
|
|
54
54
|
//#endregion
|
|
55
55
|
//#region src/media/image-node.tsx
|
|
56
|
-
var
|
|
57
|
-
function
|
|
56
|
+
var li = Je;
|
|
57
|
+
function ui(e) {
|
|
58
58
|
return e instanceof Element && !!e.closest("[data-markweave-image-ui=\"true\"]");
|
|
59
59
|
}
|
|
60
|
-
function
|
|
61
|
-
let { deleteNode: t, editor: r, getPos: i, node: o, selected: s, updateAttributes: c } = e, l = e.extension.options, u = l.messages ?? n("zh"), d = u.image, f = $e(
|
|
60
|
+
function di(e) {
|
|
61
|
+
let { deleteNode: t, editor: r, getPos: i, node: o, selected: s, updateAttributes: c } = e, l = e.extension.options, u = l.messages ?? n("zh"), d = u.image, f = $e(ci(r)), p = Ze(o.attrs.src), m = li(o.attrs.align), h = Xe(o.attrs.width), g = Ze(o.attrs.caption), _ = J(null), v = _i(p, l.resolveMediaSource, _, s), y = v?.src ?? (l.resolveMediaSource ? null : p), b = J(null), [x, S] = Y(!1), [C, w] = Y(!1), [T, E] = Y(!1), [D, O] = Y(""), [k, A] = Y(null), [j, M] = Y(!1), [ee, N] = Y(!!g), [te, P] = Y(g ?? ""), ne = f && (!p || C), F = () => {
|
|
62
62
|
y && rt({
|
|
63
63
|
src: y,
|
|
64
|
-
alt:
|
|
64
|
+
alt: Ze(o.attrs.alt) ?? "",
|
|
65
65
|
messages: {
|
|
66
66
|
dialogAriaLabel: d.previewDialogAriaLabel,
|
|
67
67
|
zoomOut: d.previewZoomOut,
|
|
@@ -71,10 +71,10 @@ function li(e) {
|
|
|
71
71
|
}
|
|
72
72
|
});
|
|
73
73
|
};
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}, [g,
|
|
77
|
-
let
|
|
74
|
+
G(() => {
|
|
75
|
+
ee || P(g ?? "");
|
|
76
|
+
}, [g, ee]);
|
|
77
|
+
let I = () => {
|
|
78
78
|
if (!f) return;
|
|
79
79
|
let e = i();
|
|
80
80
|
typeof e == "number" && r.chain().focus().setNodeSelection(e).run();
|
|
@@ -90,8 +90,8 @@ function li(e) {
|
|
|
90
90
|
if (f) {
|
|
91
91
|
A(null), M(!0);
|
|
92
92
|
try {
|
|
93
|
-
let t = await
|
|
94
|
-
c(
|
|
93
|
+
let t = await X(We(e, p && C ? "image-replace" : "image-insert"), l.onUpload);
|
|
94
|
+
c(Be(o.attrs, t)), w(!1), O("");
|
|
95
95
|
} catch (e) {
|
|
96
96
|
A(e instanceof Error ? e.message : d.uploadFailedError);
|
|
97
97
|
} finally {
|
|
@@ -104,30 +104,30 @@ function li(e) {
|
|
|
104
104
|
A(d.uploadRequiredError);
|
|
105
105
|
return;
|
|
106
106
|
}
|
|
107
|
-
R(
|
|
107
|
+
R(Ie(D));
|
|
108
108
|
}
|
|
109
|
-
},
|
|
109
|
+
}, ae = (e) => {
|
|
110
110
|
!f || !e || R({
|
|
111
111
|
type: "file",
|
|
112
112
|
file: e,
|
|
113
113
|
mimeType: e.type
|
|
114
114
|
});
|
|
115
|
+
}, z = (e) => {
|
|
116
|
+
ae(e.currentTarget.files?.[0] ?? null), e.currentTarget.value = "";
|
|
115
117
|
}, B = (e) => {
|
|
116
|
-
|
|
117
|
-
}, ae = (e) => {
|
|
118
|
-
e.preventDefault(), e.stopPropagation(), f && z(e.dataTransfer.files?.[0] ?? null);
|
|
118
|
+
e.preventDefault(), e.stopPropagation(), f && ae(e.dataTransfer.files?.[0] ?? null);
|
|
119
119
|
}, oe = () => {
|
|
120
|
-
f && (
|
|
120
|
+
f && (N((e) => !e), ee || P(g ?? ""));
|
|
121
121
|
}, se = (e) => {
|
|
122
|
-
f && (
|
|
122
|
+
f && (P(e), c({ caption: e.trim() ? e : null }));
|
|
123
123
|
}, ce = (e, t) => {
|
|
124
124
|
if (t.preventDefault(), t.stopPropagation(), !f) return;
|
|
125
|
-
|
|
125
|
+
I();
|
|
126
126
|
let n = _.current;
|
|
127
127
|
if (!n) return;
|
|
128
128
|
let r = t.clientX, i = n.getBoundingClientRect().width || h || 320, a = n.closest(".markweave-editor-surface")?.getBoundingClientRect().width ?? n.parentElement?.getBoundingClientRect().width ?? i, o = (t) => {
|
|
129
129
|
let n = e === "right" ? t.clientX - r : r - t.clientX;
|
|
130
|
-
c({ width:
|
|
130
|
+
c({ width: Ue(i + n, a) });
|
|
131
131
|
}, s = () => {
|
|
132
132
|
window.removeEventListener("pointermove", o), window.removeEventListener("pointerup", s);
|
|
133
133
|
};
|
|
@@ -140,13 +140,13 @@ function li(e) {
|
|
|
140
140
|
"data-align": m,
|
|
141
141
|
"data-selected": f && s ? "true" : "false",
|
|
142
142
|
"data-hovered": x ? "true" : "false",
|
|
143
|
-
"data-empty":
|
|
143
|
+
"data-empty": ne ? "true" : "false",
|
|
144
144
|
onPointerEnter: () => S(!0),
|
|
145
145
|
onPointerLeave: () => S(!1),
|
|
146
146
|
onMouseDown: (e) => {
|
|
147
|
-
f && !
|
|
147
|
+
f && !ui(e.target) && I();
|
|
148
148
|
},
|
|
149
|
-
children:
|
|
149
|
+
children: ne ? /* @__PURE__ */ Z(fi, {
|
|
150
150
|
dragActive: T,
|
|
151
151
|
error: k,
|
|
152
152
|
inputValue: D,
|
|
@@ -154,23 +154,23 @@ function li(e) {
|
|
|
154
154
|
fileInputRef: b,
|
|
155
155
|
messages: u,
|
|
156
156
|
onCancel: re,
|
|
157
|
-
onDrop:
|
|
157
|
+
onDrop: B,
|
|
158
158
|
onDragActiveChange: E,
|
|
159
|
-
onFileChange:
|
|
159
|
+
onFileChange: z,
|
|
160
160
|
onInputChange: O,
|
|
161
161
|
onSubmit: ie
|
|
162
162
|
}) : /* @__PURE__ */ Q(ot, { children: [
|
|
163
|
-
f ? /* @__PURE__ */ Z(
|
|
163
|
+
f ? /* @__PURE__ */ Z(pi, {
|
|
164
164
|
align: m,
|
|
165
|
-
captionActive:
|
|
165
|
+
captionActive: ee || !!g,
|
|
166
166
|
messages: u,
|
|
167
167
|
onAlign: (e) => c({ align: e }),
|
|
168
168
|
onCaption: oe,
|
|
169
169
|
onDelete: t,
|
|
170
170
|
onDownload: () => {
|
|
171
|
-
y &&
|
|
171
|
+
y && Ke(y);
|
|
172
172
|
},
|
|
173
|
-
onPreview:
|
|
173
|
+
onPreview: F,
|
|
174
174
|
onReplace: () => {
|
|
175
175
|
O(""), A(null), w(!0);
|
|
176
176
|
}
|
|
@@ -186,8 +186,8 @@ function li(e) {
|
|
|
186
186
|
y ? /* @__PURE__ */ Z("img", {
|
|
187
187
|
className: "markweave-image",
|
|
188
188
|
src: y,
|
|
189
|
-
alt:
|
|
190
|
-
title:
|
|
189
|
+
alt: Ze(o.attrs.alt) ?? "",
|
|
190
|
+
title: Ze(o.attrs.title) ?? void 0,
|
|
191
191
|
draggable: !1,
|
|
192
192
|
loading: "lazy",
|
|
193
193
|
decoding: "async",
|
|
@@ -206,8 +206,8 @@ function li(e) {
|
|
|
206
206
|
"aria-label": d.preview,
|
|
207
207
|
title: d.preview,
|
|
208
208
|
onMouseDown: (e) => e.preventDefault(),
|
|
209
|
-
onClick:
|
|
210
|
-
children: [/* @__PURE__ */ Z(
|
|
209
|
+
onClick: F,
|
|
210
|
+
children: [/* @__PURE__ */ Z(L, {
|
|
211
211
|
size: 16,
|
|
212
212
|
strokeWidth: 1.8
|
|
213
213
|
}), /* @__PURE__ */ Z("span", {
|
|
@@ -216,28 +216,28 @@ function li(e) {
|
|
|
216
216
|
children: d.preview
|
|
217
217
|
})]
|
|
218
218
|
}) : null,
|
|
219
|
-
f ? /* @__PURE__ */ Z(
|
|
219
|
+
f ? /* @__PURE__ */ Z(hi, {
|
|
220
220
|
side: "left",
|
|
221
221
|
messages: u,
|
|
222
222
|
onPointerDown: ce
|
|
223
223
|
}) : null,
|
|
224
|
-
f ? /* @__PURE__ */ Z(
|
|
224
|
+
f ? /* @__PURE__ */ Z(hi, {
|
|
225
225
|
side: "right",
|
|
226
226
|
messages: u,
|
|
227
227
|
onPointerDown: ce
|
|
228
228
|
}) : null
|
|
229
229
|
]
|
|
230
230
|
}),
|
|
231
|
-
f && (
|
|
231
|
+
f && (ee || g) ? /* @__PURE__ */ Z("input", {
|
|
232
232
|
className: "markweave-image-caption-input",
|
|
233
233
|
"data-markweave-image-ui": "true",
|
|
234
234
|
"data-testid": "markweave-image-caption-input",
|
|
235
|
-
value:
|
|
235
|
+
value: te,
|
|
236
236
|
placeholder: d.captionPlaceholder,
|
|
237
237
|
"aria-label": d.captionAriaLabel,
|
|
238
238
|
onChange: (e) => se(e.currentTarget.value),
|
|
239
239
|
onKeyDown: (e) => {
|
|
240
|
-
e.key === "Escape" && (e.preventDefault(),
|
|
240
|
+
e.key === "Escape" && (e.preventDefault(), N(!1));
|
|
241
241
|
}
|
|
242
242
|
}) : g ? /* @__PURE__ */ Z("figcaption", {
|
|
243
243
|
className: "markweave-image-caption",
|
|
@@ -247,7 +247,7 @@ function li(e) {
|
|
|
247
247
|
] })
|
|
248
248
|
});
|
|
249
249
|
}
|
|
250
|
-
function
|
|
250
|
+
function fi({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitting: i, messages: a, onCancel: o, onDragActiveChange: s, onDrop: c, onFileChange: l, onInputChange: u, onSubmit: d }) {
|
|
251
251
|
let f = a.image;
|
|
252
252
|
return /* @__PURE__ */ Q("section", {
|
|
253
253
|
className: "markweave-image-upload-placeholder",
|
|
@@ -274,7 +274,7 @@ function ui({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
|
|
|
274
274
|
/* @__PURE__ */ Z("div", {
|
|
275
275
|
className: "markweave-image-upload-icon",
|
|
276
276
|
"aria-hidden": "true",
|
|
277
|
-
children: /* @__PURE__ */ Z(
|
|
277
|
+
children: /* @__PURE__ */ Z(z, {
|
|
278
278
|
size: 46,
|
|
279
279
|
strokeWidth: 1.6
|
|
280
280
|
})
|
|
@@ -309,7 +309,7 @@ function ui({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
|
|
|
309
309
|
"data-testid": "markweave-image-upload-submit",
|
|
310
310
|
disabled: i || !r.trim(),
|
|
311
311
|
onClick: d,
|
|
312
|
-
children: [/* @__PURE__ */ Z(
|
|
312
|
+
children: [/* @__PURE__ */ Z(z, {
|
|
313
313
|
size: 16,
|
|
314
314
|
strokeWidth: 1.8
|
|
315
315
|
}), a.common.insert]
|
|
@@ -329,7 +329,7 @@ function ui({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
|
|
|
329
329
|
]
|
|
330
330
|
});
|
|
331
331
|
}
|
|
332
|
-
function
|
|
332
|
+
function pi({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i, onDelete: a, onDownload: o, onPreview: s, onReplace: c }) {
|
|
333
333
|
let u = n.image;
|
|
334
334
|
return /* @__PURE__ */ Q("div", {
|
|
335
335
|
className: "markweave-image-toolbar",
|
|
@@ -337,21 +337,21 @@ function di({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i,
|
|
|
337
337
|
"data-markweave-image-ui": "true",
|
|
338
338
|
"aria-label": u.toolsAriaLabel,
|
|
339
339
|
children: [
|
|
340
|
-
/* @__PURE__ */ Z(
|
|
340
|
+
/* @__PURE__ */ Z(mi, {
|
|
341
341
|
testId: "markweave-image-align-left",
|
|
342
342
|
label: u.alignLeft,
|
|
343
343
|
icon: d,
|
|
344
344
|
active: e === "left",
|
|
345
345
|
onClick: () => r("left")
|
|
346
346
|
}),
|
|
347
|
-
/* @__PURE__ */ Z(
|
|
347
|
+
/* @__PURE__ */ Z(mi, {
|
|
348
348
|
testId: "markweave-image-align-center",
|
|
349
349
|
label: u.alignCenter,
|
|
350
350
|
icon: l,
|
|
351
351
|
active: e === "center",
|
|
352
352
|
onClick: () => r("center")
|
|
353
353
|
}),
|
|
354
|
-
/* @__PURE__ */ Z(
|
|
354
|
+
/* @__PURE__ */ Z(mi, {
|
|
355
355
|
testId: "markweave-image-align-right",
|
|
356
356
|
label: u.alignRight,
|
|
357
357
|
icon: f,
|
|
@@ -362,45 +362,45 @@ function di({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i,
|
|
|
362
362
|
className: "markweave-image-toolbar-divider",
|
|
363
363
|
"aria-hidden": "true"
|
|
364
364
|
}),
|
|
365
|
-
/* @__PURE__ */ Z(
|
|
365
|
+
/* @__PURE__ */ Z(mi, {
|
|
366
366
|
testId: "markweave-image-caption",
|
|
367
367
|
label: u.caption,
|
|
368
368
|
icon: O,
|
|
369
369
|
active: t,
|
|
370
370
|
onClick: i
|
|
371
371
|
}),
|
|
372
|
-
/* @__PURE__ */ Z(
|
|
372
|
+
/* @__PURE__ */ Z(mi, {
|
|
373
373
|
testId: "markweave-image-preview",
|
|
374
374
|
label: u.preview,
|
|
375
|
-
icon:
|
|
375
|
+
icon: L,
|
|
376
376
|
onClick: s
|
|
377
377
|
}),
|
|
378
|
-
/* @__PURE__ */ Z(
|
|
378
|
+
/* @__PURE__ */ Z(mi, {
|
|
379
379
|
testId: "markweave-image-download",
|
|
380
380
|
label: u.download,
|
|
381
|
-
icon:
|
|
381
|
+
icon: F,
|
|
382
382
|
onClick: o
|
|
383
383
|
}),
|
|
384
|
-
/* @__PURE__ */ Z(
|
|
384
|
+
/* @__PURE__ */ Z(mi, {
|
|
385
385
|
testId: "markweave-image-replace",
|
|
386
386
|
label: u.replace,
|
|
387
|
-
icon:
|
|
387
|
+
icon: ve,
|
|
388
388
|
onClick: c
|
|
389
389
|
}),
|
|
390
390
|
/* @__PURE__ */ Z("span", {
|
|
391
391
|
className: "markweave-image-toolbar-divider",
|
|
392
392
|
"aria-hidden": "true"
|
|
393
393
|
}),
|
|
394
|
-
/* @__PURE__ */ Z(
|
|
394
|
+
/* @__PURE__ */ Z(mi, {
|
|
395
395
|
testId: "markweave-image-delete",
|
|
396
396
|
label: u.delete,
|
|
397
|
-
icon:
|
|
397
|
+
icon: Ae,
|
|
398
398
|
onClick: a
|
|
399
399
|
})
|
|
400
400
|
]
|
|
401
401
|
});
|
|
402
402
|
}
|
|
403
|
-
function
|
|
403
|
+
function mi({ active: e = !1, icon: t, label: n, onClick: r, testId: i }) {
|
|
404
404
|
return /* @__PURE__ */ Q("button", {
|
|
405
405
|
type: "button",
|
|
406
406
|
"aria-label": n,
|
|
@@ -419,7 +419,7 @@ function fi({ active: e = !1, icon: t, label: n, onClick: r, testId: i }) {
|
|
|
419
419
|
})]
|
|
420
420
|
});
|
|
421
421
|
}
|
|
422
|
-
function
|
|
422
|
+
function hi({ messages: e, onPointerDown: t, side: n }) {
|
|
423
423
|
return /* @__PURE__ */ Z("button", {
|
|
424
424
|
type: "button",
|
|
425
425
|
className: "markweave-image-resize-handle",
|
|
@@ -430,7 +430,7 @@ function pi({ messages: e, onPointerDown: t, side: n }) {
|
|
|
430
430
|
onPointerDown: (e) => t(n, e)
|
|
431
431
|
});
|
|
432
432
|
}
|
|
433
|
-
var
|
|
433
|
+
var gi = Re.extend({
|
|
434
434
|
addOptions() {
|
|
435
435
|
return {
|
|
436
436
|
...this.parent?.(),
|
|
@@ -441,21 +441,21 @@ var mi = ze.extend({
|
|
|
441
441
|
},
|
|
442
442
|
addNodeView() {
|
|
443
443
|
if (typeof document > "u") return null;
|
|
444
|
-
let e = o(
|
|
444
|
+
let e = o(di, { stopEvent: ({ event: e }) => ui(e.target) }), t = this.options.resolveMediaSource;
|
|
445
445
|
if (!t) return e;
|
|
446
446
|
let r = it({
|
|
447
447
|
messages: this.options.messages ?? n("zh"),
|
|
448
448
|
onUpload: this.options.onUpload,
|
|
449
449
|
resolveMediaSource: t
|
|
450
450
|
});
|
|
451
|
-
return (t) =>
|
|
451
|
+
return (t) => Ze(t.node.attrs.src) ? r(t) : e(t);
|
|
452
452
|
}
|
|
453
453
|
});
|
|
454
|
-
function
|
|
455
|
-
let [i, a] =
|
|
456
|
-
return
|
|
454
|
+
function _i(e, t, n, r) {
|
|
455
|
+
let [i, a] = Y(t ? "background" : "visible"), [o, s] = Y(() => !t && e ? { src: e } : null);
|
|
456
|
+
return G(() => {
|
|
457
457
|
s(!t && e ? { src: e } : null), a(t ? "background" : "visible");
|
|
458
|
-
}, [t, e]),
|
|
458
|
+
}, [t, e]), G(() => {
|
|
459
459
|
if (!t || !e) return;
|
|
460
460
|
if (r) {
|
|
461
461
|
a("visible");
|
|
@@ -478,7 +478,7 @@ function hi(e, t, n, r) {
|
|
|
478
478
|
t,
|
|
479
479
|
r,
|
|
480
480
|
e
|
|
481
|
-
]),
|
|
481
|
+
]), G(() => {
|
|
482
482
|
if (!t || !e || i === "background") return;
|
|
483
483
|
let n = new AbortController();
|
|
484
484
|
return at(t, {
|
|
@@ -497,28 +497,28 @@ function hi(e, t, n, r) {
|
|
|
497
497
|
}
|
|
498
498
|
//#endregion
|
|
499
499
|
//#region src/media/video-node.tsx
|
|
500
|
-
function
|
|
500
|
+
function vi(e) {
|
|
501
501
|
return e instanceof Element && !!e.closest("[data-markweave-video-ui=\"true\"], iframe[data-markweave-video-embed], video[data-markweave-video]");
|
|
502
502
|
}
|
|
503
|
-
function
|
|
504
|
-
let { deleteNode: t, editor: r, getPos: i, node: o, selected: s, updateAttributes: c } = e, l = e.extension.options, u = l.messages ?? n("zh"), d = u.video, f = $e(
|
|
503
|
+
function yi(e) {
|
|
504
|
+
let { deleteNode: t, editor: r, getPos: i, node: o, selected: s, updateAttributes: c } = e, l = e.extension.options, u = l.messages ?? n("zh"), d = u.video, f = $e(ci(r)), p = Ze(o.attrs.src), m = Ze(o.attrs.embedUrl), h = Ze(o.attrs.provider), g = m ? Ye(m, h) : null, _ = Ze(o.attrs.mimeType), v = Ze(o.attrs.title), y = J(null), [b, x] = Y(!1), [S, C] = Y(""), [w, T] = Y(null), [E, D] = Y(!1), O = f && !p, k = () => {
|
|
505
505
|
if (!f) return;
|
|
506
506
|
let e = i();
|
|
507
507
|
typeof e == "number" && r.chain().focus().setNodeSelection(e).run();
|
|
508
508
|
}, A = (e) => {
|
|
509
|
-
f && (
|
|
509
|
+
f && (vi(e.target) || (e.preventDefault(), k()));
|
|
510
510
|
}, j = (e) => {
|
|
511
511
|
f && (e.key === "Delete" || e.key === "Backspace") && s && (e.preventDefault(), t());
|
|
512
512
|
}, M = async (e) => {
|
|
513
513
|
if (!(!f || !e)) {
|
|
514
514
|
T(null), D(!0);
|
|
515
515
|
try {
|
|
516
|
-
let t = await
|
|
516
|
+
let t = await X(Ge({
|
|
517
517
|
type: "file",
|
|
518
518
|
file: e,
|
|
519
519
|
mimeType: e.type
|
|
520
520
|
}), l.onUpload);
|
|
521
|
-
c(
|
|
521
|
+
c(Ve(t)), C("");
|
|
522
522
|
} catch (e) {
|
|
523
523
|
T(e instanceof Error ? e.message : d.uploadFailedError);
|
|
524
524
|
} finally {
|
|
@@ -532,7 +532,7 @@ function _i(e) {
|
|
|
532
532
|
"data-testid": "markweave-video-node",
|
|
533
533
|
"data-empty": "true",
|
|
534
534
|
"data-selected": "false",
|
|
535
|
-
children: /* @__PURE__ */ Z(
|
|
535
|
+
children: /* @__PURE__ */ Z(bi, {
|
|
536
536
|
dragActive: b,
|
|
537
537
|
error: w,
|
|
538
538
|
fileInputRef: y,
|
|
@@ -550,7 +550,7 @@ function _i(e) {
|
|
|
550
550
|
onInputChange: C,
|
|
551
551
|
onSubmit: () => {
|
|
552
552
|
if (!f) return;
|
|
553
|
-
let e =
|
|
553
|
+
let e = He(S);
|
|
554
554
|
if (!e) {
|
|
555
555
|
T(d.unsupportedUrlError);
|
|
556
556
|
return;
|
|
@@ -579,7 +579,7 @@ function _i(e) {
|
|
|
579
579
|
"data-markweave-video-embed": "true",
|
|
580
580
|
"data-markweave-video-provider": h ?? void 0,
|
|
581
581
|
"data-markweave-video-src": p ?? void 0,
|
|
582
|
-
allow:
|
|
582
|
+
allow: qe,
|
|
583
583
|
loading: "lazy",
|
|
584
584
|
allowFullScreen: !0
|
|
585
585
|
}), f ? /* @__PURE__ */ Z("button", {
|
|
@@ -613,7 +613,7 @@ function _i(e) {
|
|
|
613
613
|
})
|
|
614
614
|
});
|
|
615
615
|
}
|
|
616
|
-
function
|
|
616
|
+
function bi({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitting: i, messages: a, onCancel: o, onDragActiveChange: s, onDrop: c, onFileChange: l, onInputChange: u, onSubmit: d }) {
|
|
617
617
|
let f = a.video;
|
|
618
618
|
return /* @__PURE__ */ Q("section", {
|
|
619
619
|
className: "markweave-video-upload-placeholder",
|
|
@@ -640,7 +640,7 @@ function vi({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
|
|
|
640
640
|
/* @__PURE__ */ Z("div", {
|
|
641
641
|
className: "markweave-video-upload-icon",
|
|
642
642
|
"aria-hidden": "true",
|
|
643
|
-
children: /* @__PURE__ */ Z(
|
|
643
|
+
children: /* @__PURE__ */ Z(Pe, {
|
|
644
644
|
size: 46,
|
|
645
645
|
strokeWidth: 1.6
|
|
646
646
|
})
|
|
@@ -675,7 +675,7 @@ function vi({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
|
|
|
675
675
|
"data-testid": "markweave-video-upload-submit",
|
|
676
676
|
disabled: i || !r.trim(),
|
|
677
677
|
onClick: d,
|
|
678
|
-
children: [/* @__PURE__ */ Z(
|
|
678
|
+
children: [/* @__PURE__ */ Z(Ne, {
|
|
679
679
|
size: 16,
|
|
680
680
|
strokeWidth: 1.8
|
|
681
681
|
}), a.common.insert]
|
|
@@ -695,7 +695,7 @@ function vi({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
|
|
|
695
695
|
]
|
|
696
696
|
});
|
|
697
697
|
}
|
|
698
|
-
var
|
|
698
|
+
var xi = ze.extend({
|
|
699
699
|
addOptions() {
|
|
700
700
|
return {
|
|
701
701
|
...this.parent?.(),
|
|
@@ -705,30 +705,30 @@ var yi = Be.extend({
|
|
|
705
705
|
};
|
|
706
706
|
},
|
|
707
707
|
addNodeView() {
|
|
708
|
-
return typeof document > "u" ? null : o(
|
|
708
|
+
return typeof document > "u" ? null : o(yi, { stopEvent: ({ event: e }) => vi(e.target) });
|
|
709
709
|
}
|
|
710
710
|
});
|
|
711
711
|
//#endregion
|
|
712
712
|
//#region src/link-card-node.tsx
|
|
713
|
-
function
|
|
713
|
+
function Si(e) {
|
|
714
714
|
return e instanceof Element && !!e.closest("[data-markweave-link-card-ui=\"true\"]");
|
|
715
715
|
}
|
|
716
|
-
function
|
|
716
|
+
function Ci(e) {
|
|
717
717
|
return typeof navigator < "u" && navigator.clipboard?.writeText ? navigator.clipboard.writeText(e).catch(() => void 0) : Promise.resolve();
|
|
718
718
|
}
|
|
719
|
-
function
|
|
719
|
+
function wi(e) {
|
|
720
720
|
!e || typeof window > "u" || window.open(e, "_blank", "noopener,noreferrer");
|
|
721
721
|
}
|
|
722
|
-
function
|
|
722
|
+
function Ti(e) {
|
|
723
723
|
try {
|
|
724
724
|
return new URL(e).host;
|
|
725
725
|
} catch {
|
|
726
726
|
return e;
|
|
727
727
|
}
|
|
728
728
|
}
|
|
729
|
-
function
|
|
730
|
-
let { deleteNode: t, editor: r, getPos: i, node: o, updateAttributes: s } = e, c = e.extension.options, l = c.messages ?? n("zh"), u = l.linkCard, d = $e(
|
|
731
|
-
if (
|
|
729
|
+
function Ei(e) {
|
|
730
|
+
let { deleteNode: t, editor: r, getPos: i, node: o, updateAttributes: s } = e, c = e.extension.options, l = c.messages ?? n("zh"), u = l.linkCard, d = $e(ci(r)), f = ct(o.attrs), [p, m] = Y(!1), [h, g] = Y(!1), [_, v] = Y(!1), [y, b] = Y(f?.title ?? ""), [x, S] = Y(f?.href ?? ""), C = J(null);
|
|
731
|
+
if (G(() => () => C.current?.abort(), []), G(() => {
|
|
732
732
|
b(f?.title ?? ""), S(f?.href ?? ""), v(!1);
|
|
733
733
|
}, [f?.href, f?.title]), !f) return null;
|
|
734
734
|
let w = async (e) => {
|
|
@@ -756,7 +756,7 @@ function wi(e) {
|
|
|
756
756
|
}, T = () => {
|
|
757
757
|
let e = i();
|
|
758
758
|
typeof e == "number" && ut(r, e);
|
|
759
|
-
}, E = _ ? null : f.imageUrl, D =
|
|
759
|
+
}, E = _ ? null : f.imageUrl, D = Ti(f.href);
|
|
760
760
|
return /* @__PURE__ */ Q(a, {
|
|
761
761
|
as: "article",
|
|
762
762
|
className: "markweave-link-card",
|
|
@@ -767,10 +767,10 @@ function wi(e) {
|
|
|
767
767
|
onMouseEnter: () => m(!0),
|
|
768
768
|
onMouseLeave: () => m(!1),
|
|
769
769
|
onMouseDown: (e) => {
|
|
770
|
-
|
|
770
|
+
Si(e.target) || e.preventDefault();
|
|
771
771
|
},
|
|
772
772
|
onClick: (e) => {
|
|
773
|
-
|
|
773
|
+
Si(e.target) || (e.preventDefault(), wi(f.href));
|
|
774
774
|
},
|
|
775
775
|
children: [
|
|
776
776
|
/* @__PURE__ */ Q("a", {
|
|
@@ -808,21 +808,21 @@ function wi(e) {
|
|
|
808
808
|
"data-markweave-link-card-ui": "true",
|
|
809
809
|
"aria-label": u.toolsAriaLabel,
|
|
810
810
|
children: [
|
|
811
|
-
/* @__PURE__ */ Z(
|
|
811
|
+
/* @__PURE__ */ Z(Di, {
|
|
812
812
|
label: u.convertToLink,
|
|
813
813
|
icon: V,
|
|
814
814
|
onClick: T,
|
|
815
815
|
testId: "markweave-link-card-convert"
|
|
816
816
|
}),
|
|
817
|
-
/* @__PURE__ */ Z(
|
|
817
|
+
/* @__PURE__ */ Z(Di, {
|
|
818
818
|
label: u.copyAddress,
|
|
819
|
-
icon:
|
|
820
|
-
onClick: () => void
|
|
819
|
+
icon: P,
|
|
820
|
+
onClick: () => void Ci(f.href),
|
|
821
821
|
testId: "markweave-link-card-copy"
|
|
822
822
|
}),
|
|
823
|
-
/* @__PURE__ */ Z(
|
|
823
|
+
/* @__PURE__ */ Z(Di, {
|
|
824
824
|
label: u.edit,
|
|
825
|
-
icon:
|
|
825
|
+
icon: he,
|
|
826
826
|
onClick: (e) => {
|
|
827
827
|
let t = i();
|
|
828
828
|
typeof t == "number" && dt({
|
|
@@ -838,9 +838,9 @@ function wi(e) {
|
|
|
838
838
|
},
|
|
839
839
|
testId: "markweave-link-card-edit"
|
|
840
840
|
}),
|
|
841
|
-
/* @__PURE__ */ Z(
|
|
841
|
+
/* @__PURE__ */ Z(Di, {
|
|
842
842
|
label: u.delete,
|
|
843
|
-
icon:
|
|
843
|
+
icon: Ae,
|
|
844
844
|
onClick: t,
|
|
845
845
|
testId: "markweave-link-card-delete"
|
|
846
846
|
})
|
|
@@ -875,7 +875,7 @@ function wi(e) {
|
|
|
875
875
|
]
|
|
876
876
|
});
|
|
877
877
|
}
|
|
878
|
-
function
|
|
878
|
+
function Di({ icon: e, label: t, onClick: n, testId: r }) {
|
|
879
879
|
return /* @__PURE__ */ Q("button", {
|
|
880
880
|
type: "button",
|
|
881
881
|
"aria-label": t,
|
|
@@ -892,7 +892,7 @@ function Ti({ icon: e, label: t, onClick: n, testId: r }) {
|
|
|
892
892
|
})]
|
|
893
893
|
});
|
|
894
894
|
}
|
|
895
|
-
var
|
|
895
|
+
var Oi = ft.extend({
|
|
896
896
|
addOptions() {
|
|
897
897
|
return {
|
|
898
898
|
...this.parent?.(),
|
|
@@ -901,23 +901,23 @@ var Ei = ft.extend({
|
|
|
901
901
|
};
|
|
902
902
|
},
|
|
903
903
|
addNodeView() {
|
|
904
|
-
return typeof document > "u" ? null : o(
|
|
904
|
+
return typeof document > "u" ? null : o(Ei, { stopEvent: ({ event: e }) => Si(e.target) });
|
|
905
905
|
}
|
|
906
906
|
});
|
|
907
907
|
//#endregion
|
|
908
908
|
//#region src/create-editor-extensions.ts
|
|
909
|
-
function
|
|
909
|
+
function ki(t = {}) {
|
|
910
910
|
return e({
|
|
911
911
|
lang: t.lang,
|
|
912
912
|
onImageUpload: t.onImageUpload,
|
|
913
|
-
linkCardExtension:
|
|
913
|
+
linkCardExtension: Oi.configure({
|
|
914
914
|
lang: t.lang,
|
|
915
915
|
messages: n(t.lang),
|
|
916
916
|
resolver: t.linkCardResolver
|
|
917
917
|
}),
|
|
918
918
|
mediaExtensions: st({
|
|
919
|
-
image:
|
|
920
|
-
video:
|
|
919
|
+
image: gi,
|
|
920
|
+
video: xi,
|
|
921
921
|
lang: t.lang,
|
|
922
922
|
onImageUpload: t.onImageUpload,
|
|
923
923
|
onVideoUpload: t.onVideoUpload,
|
|
@@ -927,7 +927,7 @@ function Di(t = {}) {
|
|
|
927
927
|
}
|
|
928
928
|
//#endregion
|
|
929
929
|
//#region src/ui/codeblock/CodeBlockControls.tsx
|
|
930
|
-
function
|
|
930
|
+
function Ai(e) {
|
|
931
931
|
return e === "clipboard" ? /* @__PURE__ */ Q(ot, { 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(ot, { children: [/* @__PURE__ */ Z("circle", {
|
|
932
932
|
cx: "10",
|
|
933
933
|
cy: "10",
|
|
@@ -964,7 +964,7 @@ function Oi(e) {
|
|
|
964
964
|
/* @__PURE__ */ Z("path", { d: "m14 14 4 4" })
|
|
965
965
|
] }) : e === "reset" ? /* @__PURE__ */ Q(ot, { 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" });
|
|
966
966
|
}
|
|
967
|
-
function
|
|
967
|
+
function ji({ icon: e }) {
|
|
968
968
|
return /* @__PURE__ */ Z("svg", {
|
|
969
969
|
viewBox: "0 0 24 24",
|
|
970
970
|
"aria-hidden": "true",
|
|
@@ -975,23 +975,23 @@ function ki({ icon: e }) {
|
|
|
975
975
|
strokeLinecap: "round",
|
|
976
976
|
strokeLinejoin: "round",
|
|
977
977
|
strokeWidth: "1.8",
|
|
978
|
-
children:
|
|
978
|
+
children: Ai(e)
|
|
979
979
|
})
|
|
980
980
|
});
|
|
981
981
|
}
|
|
982
|
-
function
|
|
983
|
-
let a =
|
|
982
|
+
function Mi({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, readOnly: i = !1 }) {
|
|
983
|
+
let a = J(null), o = J(null), s = J(null), c = J(null), l = J(null), u = J({
|
|
984
984
|
active: !1,
|
|
985
985
|
lastX: 0,
|
|
986
986
|
lastY: 0
|
|
987
|
-
}), [d, f] =
|
|
988
|
-
...
|
|
989
|
-
pos:
|
|
987
|
+
}), [d, f] = Y(null), [p, m] = Y(null), [h, g] = Y([]), [_, v] = Y(null), [y, b] = Y(!1), [x, S] = Y(""), [C, w] = Y(-1), [T, E] = Y(null), [D, O] = Y(!1), [k, A] = Y(null), [j, M] = Y(null), [ee, N] = Y(!1), [te, P] = Y(0), [ne, F] = Y(0), I = Ft(t), L = Bn(t, d), re = !i && e && I.active && I.pos !== null ? {
|
|
988
|
+
...I,
|
|
989
|
+
pos: I.pos,
|
|
990
990
|
active: !0
|
|
991
|
-
} : null, R =
|
|
992
|
-
if (
|
|
991
|
+
} : null, R = L ?? re, ie = R !== null, ae = R?.language === "mermaid", z = Gn(t, R), B = ie && R !== null && !z, oe = !i, se = Nn(R ? R.language : "text"), ce = T?.status ?? "idle", le = R?.mermaidPreviewMode ?? n, V = ae && le === "preview", ue = Un(t), H = `${ne}|${ue.map((e) => `${e.pos}:${e.mermaidPreviewMode}:${e.text.length}`).join("|")}`, U = q(() => Ln(x.trim().toLowerCase()), [x]);
|
|
992
|
+
if (G(() => {
|
|
993
993
|
i && (b(!1), S(""), w(-1));
|
|
994
|
-
}, [i]),
|
|
994
|
+
}, [i]), G(() => {
|
|
995
995
|
if (!T) return;
|
|
996
996
|
let e = window.setTimeout(() => {
|
|
997
997
|
E(null);
|
|
@@ -999,21 +999,21 @@ function Ai({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
999
999
|
return () => {
|
|
1000
1000
|
window.clearTimeout(e);
|
|
1001
1001
|
};
|
|
1002
|
-
}, [T]),
|
|
1003
|
-
E(null), b(!1), S(""), w(-1), A(null), M(null),
|
|
1002
|
+
}, [T]), G(() => {
|
|
1003
|
+
E(null), b(!1), S(""), w(-1), A(null), M(null), N(!1);
|
|
1004
1004
|
}, [
|
|
1005
1005
|
e,
|
|
1006
1006
|
R?.language,
|
|
1007
1007
|
R?.pos,
|
|
1008
1008
|
R?.text
|
|
1009
|
-
]),
|
|
1009
|
+
]), G(() => {
|
|
1010
1010
|
let e = ({ transaction: e }) => {
|
|
1011
|
-
e.getMeta(Nt) &&
|
|
1011
|
+
e.getMeta(Nt) && P((e) => e + 1);
|
|
1012
1012
|
};
|
|
1013
1013
|
return t.on("transaction", e), () => {
|
|
1014
1014
|
t.off("transaction", e);
|
|
1015
1015
|
};
|
|
1016
|
-
}, [t]),
|
|
1016
|
+
}, [t]), G(() => {
|
|
1017
1017
|
let e = t.view.dom.closest(".markweave-editor-frame");
|
|
1018
1018
|
if (!e) return;
|
|
1019
1019
|
let n = (e) => {
|
|
@@ -1026,20 +1026,20 @@ function Ai({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1026
1026
|
return e.addEventListener("mousemove", n), e.addEventListener("mouseleave", r), () => {
|
|
1027
1027
|
e.removeEventListener("mousemove", n), e.removeEventListener("mouseleave", r);
|
|
1028
1028
|
};
|
|
1029
|
-
}, [t, y]),
|
|
1029
|
+
}, [t, y]), G(() => {
|
|
1030
1030
|
y && s.current?.focus({ preventScroll: !0 });
|
|
1031
|
-
}, [y]),
|
|
1031
|
+
}, [y]), K(() => {
|
|
1032
1032
|
if (!y || C < 0) return;
|
|
1033
1033
|
let e = c.current, t = e?.querySelector(`[data-language-index="${C}"]`);
|
|
1034
1034
|
e && t && Xn(e, t);
|
|
1035
1035
|
}, [
|
|
1036
1036
|
C,
|
|
1037
|
-
|
|
1037
|
+
U,
|
|
1038
1038
|
y
|
|
1039
|
-
]),
|
|
1039
|
+
]), G(() => {
|
|
1040
1040
|
if (!k) return;
|
|
1041
1041
|
let e = (e) => {
|
|
1042
|
-
e.key === "Escape" && (A(null), M(null),
|
|
1042
|
+
e.key === "Escape" && (A(null), M(null), N(!1), u.current = {
|
|
1043
1043
|
active: !1,
|
|
1044
1044
|
lastX: 0,
|
|
1045
1045
|
lastY: 0
|
|
@@ -1048,7 +1048,7 @@ function Ai({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1048
1048
|
return document.addEventListener("keydown", e), () => {
|
|
1049
1049
|
document.removeEventListener("keydown", e);
|
|
1050
1050
|
};
|
|
1051
|
-
}, [t, k]),
|
|
1051
|
+
}, [t, k]), G(() => {
|
|
1052
1052
|
if (!ie || !y) return;
|
|
1053
1053
|
let e = (e) => {
|
|
1054
1054
|
e.key === "Escape" && (b(!1), w(-1), t.view.focus());
|
|
@@ -1062,7 +1062,7 @@ function Ai({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1062
1062
|
ie,
|
|
1063
1063
|
t,
|
|
1064
1064
|
y
|
|
1065
|
-
]),
|
|
1065
|
+
]), K(() => {
|
|
1066
1066
|
let e = () => {
|
|
1067
1067
|
let e = a.current;
|
|
1068
1068
|
if (!e) return;
|
|
@@ -1082,11 +1082,11 @@ function Ai({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1082
1082
|
window.cancelAnimationFrame(n), window.removeEventListener("resize", e), window.removeEventListener("scroll", e, !0);
|
|
1083
1083
|
};
|
|
1084
1084
|
}, [
|
|
1085
|
-
|
|
1085
|
+
te,
|
|
1086
1086
|
t,
|
|
1087
|
-
|
|
1088
|
-
]),
|
|
1089
|
-
if (!
|
|
1087
|
+
H
|
|
1088
|
+
]), K(() => {
|
|
1089
|
+
if (!B || !R) {
|
|
1090
1090
|
m(null), v(null);
|
|
1091
1091
|
return;
|
|
1092
1092
|
}
|
|
@@ -1113,17 +1113,17 @@ function Ai({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1113
1113
|
window.removeEventListener("resize", e), window.removeEventListener("scroll", e, !0);
|
|
1114
1114
|
};
|
|
1115
1115
|
}, [
|
|
1116
|
-
|
|
1117
|
-
|
|
1116
|
+
B,
|
|
1117
|
+
te,
|
|
1118
1118
|
R?.pos,
|
|
1119
1119
|
t,
|
|
1120
1120
|
y,
|
|
1121
1121
|
le
|
|
1122
|
-
]), !
|
|
1123
|
-
let
|
|
1122
|
+
]), !B && ue.length === 0 && !k) return null;
|
|
1123
|
+
let de = p ? {
|
|
1124
1124
|
top: p.top,
|
|
1125
1125
|
right: p.right
|
|
1126
|
-
} : void 0,
|
|
1126
|
+
} : void 0, fe = async () => {
|
|
1127
1127
|
if (i) {
|
|
1128
1128
|
if (!R) return;
|
|
1129
1129
|
let e = await Dn(R.text);
|
|
@@ -1133,39 +1133,39 @@ function Ai({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1133
1133
|
if (!Mn(t, R)) return;
|
|
1134
1134
|
let e = await Pt(t);
|
|
1135
1135
|
E(It(Ft(t), e ? "copied" : "failed")), t.view.focus();
|
|
1136
|
-
},
|
|
1136
|
+
}, pe = (e, n) => {
|
|
1137
1137
|
if (i) {
|
|
1138
|
-
Wt(t, e.pos, n) &&
|
|
1138
|
+
Wt(t, e.pos, n) && F((e) => e + 1);
|
|
1139
1139
|
return;
|
|
1140
1140
|
}
|
|
1141
|
-
let a =
|
|
1142
|
-
Bt(t, e.pos, n) && (r(n),
|
|
1143
|
-
},
|
|
1141
|
+
let a = I.active && I.pos === e.pos;
|
|
1142
|
+
Bt(t, e.pos, n) && (r(n), F((e) => e + 1), a && t.view.focus());
|
|
1143
|
+
}, me = (e) => {
|
|
1144
1144
|
if (i || !R) return;
|
|
1145
|
-
let n =
|
|
1146
|
-
zt(t, R.pos, e) && (e === "mermaid" && Bt(t, R.pos, "preview") && r("preview"), b(!1), S(""), w(-1),
|
|
1147
|
-
},
|
|
1145
|
+
let n = I.active && I.pos === R.pos;
|
|
1146
|
+
zt(t, R.pos, e) && (e === "mermaid" && Bt(t, R.pos, "preview") && r("preview"), b(!1), S(""), w(-1), F((e) => e + 1), n && t.view.focus());
|
|
1147
|
+
}, he = () => {
|
|
1148
1148
|
let e = !y;
|
|
1149
|
-
e && l.current === null && (l.current = On()), w(e ? Hn(
|
|
1150
|
-
},
|
|
1149
|
+
e && l.current === null && (l.current = On()), w(e ? Hn(U, R?.language ?? null) : -1), b(e);
|
|
1150
|
+
}, ge = (e) => {
|
|
1151
1151
|
let t = Ln(e);
|
|
1152
1152
|
S(e), w(Hn(t, e.trim() ? null : R?.language ?? null));
|
|
1153
|
-
},
|
|
1153
|
+
}, _e = (e) => {
|
|
1154
1154
|
if (!e.nativeEvent.isComposing) {
|
|
1155
1155
|
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
1156
|
-
e.preventDefault(), w((t) => Jn(t,
|
|
1156
|
+
e.preventDefault(), w((t) => Jn(t, U.length, e.key === "ArrowUp" ? "previous" : "next"));
|
|
1157
1157
|
return;
|
|
1158
1158
|
}
|
|
1159
1159
|
if (e.key === "Enter") {
|
|
1160
|
-
let t =
|
|
1161
|
-
t && (e.preventDefault(),
|
|
1160
|
+
let t = U[C];
|
|
1161
|
+
t && (e.preventDefault(), me(t.language));
|
|
1162
1162
|
return;
|
|
1163
1163
|
}
|
|
1164
1164
|
e.key === "Escape" && (e.preventDefault(), b(!1), w(-1), t.view.focus());
|
|
1165
1165
|
}
|
|
1166
|
-
},
|
|
1167
|
-
i || !R || Rt(t, R.pos, !
|
|
1168
|
-
},
|
|
1166
|
+
}, ve = U[C], ye = l.current && ve ? Rn(l.current, ve.language) : void 0, be = () => {
|
|
1167
|
+
i || !R || Rt(t, R.pos, !z) && (P((e) => e + 1), f(null));
|
|
1168
|
+
}, xe = () => {
|
|
1169
1169
|
if (!R) return;
|
|
1170
1170
|
let e = Wn(t, R.pos);
|
|
1171
1171
|
e && Cn({
|
|
@@ -1174,40 +1174,40 @@ function Ai({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1174
1174
|
onSettled: () => t.view.focus(),
|
|
1175
1175
|
ownerDocument: document
|
|
1176
1176
|
});
|
|
1177
|
-
},
|
|
1177
|
+
}, Se = () => {
|
|
1178
1178
|
if (!R) return;
|
|
1179
1179
|
let e = Wn(t, R.pos);
|
|
1180
|
-
e && (A(An(e)), M(null),
|
|
1180
|
+
e && (A(An(e)), M(null), N(!1), u.current = {
|
|
1181
1181
|
active: !1,
|
|
1182
1182
|
lastX: 0,
|
|
1183
1183
|
lastY: 0
|
|
1184
1184
|
});
|
|
1185
|
-
},
|
|
1186
|
-
A(null), M(null),
|
|
1185
|
+
}, Ce = () => {
|
|
1186
|
+
A(null), M(null), N(!1), u.current = {
|
|
1187
1187
|
active: !1,
|
|
1188
1188
|
lastX: 0,
|
|
1189
1189
|
lastY: 0
|
|
1190
1190
|
}, t.view.focus();
|
|
1191
|
-
},
|
|
1191
|
+
}, we = (e) => {
|
|
1192
1192
|
A((t) => t && {
|
|
1193
1193
|
...t,
|
|
1194
1194
|
scale: Tn(t.scale + e)
|
|
1195
1195
|
});
|
|
1196
|
-
},
|
|
1196
|
+
}, Te = () => {
|
|
1197
1197
|
A((e) => e && An(e.svg)), u.current = {
|
|
1198
1198
|
active: !1,
|
|
1199
1199
|
lastX: 0,
|
|
1200
1200
|
lastY: 0
|
|
1201
|
-
},
|
|
1201
|
+
}, N(!1);
|
|
1202
|
+
}, Ee = (e) => {
|
|
1203
|
+
e.preventDefault(), we(e.deltaY < 0 ? qn : -qn);
|
|
1202
1204
|
}, De = (e) => {
|
|
1203
|
-
e.preventDefault(), Te(e.deltaY < 0 ? qn : -qn);
|
|
1204
|
-
}, Oe = (e) => {
|
|
1205
1205
|
e.button === 0 && (e.preventDefault(), u.current = {
|
|
1206
1206
|
active: !0,
|
|
1207
1207
|
lastX: e.clientX,
|
|
1208
1208
|
lastY: e.clientY
|
|
1209
|
-
},
|
|
1210
|
-
},
|
|
1209
|
+
}, N(!0));
|
|
1210
|
+
}, Oe = (e) => {
|
|
1211
1211
|
let t = u.current;
|
|
1212
1212
|
if (!t.active) return;
|
|
1213
1213
|
let n = e.clientX - t.lastX, r = e.clientY - t.lastY;
|
|
@@ -1216,12 +1216,12 @@ function Ai({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1216
1216
|
lastX: e.clientX,
|
|
1217
1217
|
lastY: e.clientY
|
|
1218
1218
|
}, A((e) => Yn(e, n, r));
|
|
1219
|
-
},
|
|
1219
|
+
}, ke = () => {
|
|
1220
1220
|
u.current = {
|
|
1221
1221
|
active: !1,
|
|
1222
1222
|
lastX: 0,
|
|
1223
1223
|
lastY: 0
|
|
1224
|
-
},
|
|
1224
|
+
}, N(!1);
|
|
1225
1225
|
};
|
|
1226
1226
|
return /* @__PURE__ */ Q("div", {
|
|
1227
1227
|
ref: a,
|
|
@@ -1245,19 +1245,19 @@ function Ai({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1245
1245
|
"data-testid": `markweave-mermaid-mode-${t}`,
|
|
1246
1246
|
"data-active": e.mermaidPreviewMode === t,
|
|
1247
1247
|
onMouseDown: (e) => e.preventDefault(),
|
|
1248
|
-
onClick: () =>
|
|
1248
|
+
onClick: () => pe(e, t),
|
|
1249
1249
|
children: t === "code" ? "Code" : "Preview"
|
|
1250
1250
|
}, t))
|
|
1251
1251
|
}, e.pos);
|
|
1252
1252
|
}),
|
|
1253
|
-
|
|
1253
|
+
B ? /* @__PURE__ */ Q("div", {
|
|
1254
1254
|
className: "markweave-codeblock-controls",
|
|
1255
1255
|
"data-testid": "markweave-codeblock-controls",
|
|
1256
1256
|
"data-positioned": p ? "true" : "false",
|
|
1257
|
-
"data-collapsed":
|
|
1257
|
+
"data-collapsed": z ? "true" : "false",
|
|
1258
1258
|
"data-read-only": i ? "true" : "false",
|
|
1259
1259
|
"aria-label": "Code block controls",
|
|
1260
|
-
style:
|
|
1260
|
+
style: de,
|
|
1261
1261
|
children: [
|
|
1262
1262
|
i ? /* @__PURE__ */ Z("span", {
|
|
1263
1263
|
className: "markweave-codeblock-language-button markweave-codeblock-language-label",
|
|
@@ -1273,19 +1273,19 @@ function Ai({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1273
1273
|
"aria-haspopup": "listbox",
|
|
1274
1274
|
"data-testid": "markweave-codeblock-language",
|
|
1275
1275
|
onMouseDown: (e) => e.preventDefault(),
|
|
1276
|
-
onClick:
|
|
1277
|
-
children: [/* @__PURE__ */ Z("span", { children: se }), /* @__PURE__ */ Z(
|
|
1276
|
+
onClick: he,
|
|
1277
|
+
children: [/* @__PURE__ */ Z("span", { children: se }), /* @__PURE__ */ Z(ji, { icon: "chevron" })]
|
|
1278
1278
|
}),
|
|
1279
1279
|
oe ? /* @__PURE__ */ Z("button", {
|
|
1280
1280
|
type: "button",
|
|
1281
1281
|
className: "markweave-codeblock-icon-button markweave-codeblock-collapse-button",
|
|
1282
|
-
"aria-label":
|
|
1283
|
-
title:
|
|
1282
|
+
"aria-label": z ? "Expand code block" : "Collapse code block",
|
|
1283
|
+
title: z ? "Expand code block" : "Collapse code block",
|
|
1284
1284
|
"data-testid": "markweave-codeblock-collapse",
|
|
1285
|
-
"data-collapsed":
|
|
1285
|
+
"data-collapsed": z ? "true" : "false",
|
|
1286
1286
|
onMouseDown: (e) => e.preventDefault(),
|
|
1287
|
-
onClick:
|
|
1288
|
-
children: /* @__PURE__ */ Z(
|
|
1287
|
+
onClick: be,
|
|
1288
|
+
children: /* @__PURE__ */ Z(ji, { icon: "chevron" })
|
|
1289
1289
|
}) : null,
|
|
1290
1290
|
/* @__PURE__ */ Q("span", {
|
|
1291
1291
|
className: "markweave-codeblock-copy-wrap",
|
|
@@ -1300,8 +1300,8 @@ function Ai({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1300
1300
|
onMouseLeave: () => O(!1),
|
|
1301
1301
|
onFocus: () => O(!0),
|
|
1302
1302
|
onBlur: () => O(!1),
|
|
1303
|
-
onClick:
|
|
1304
|
-
children: /* @__PURE__ */ Z(
|
|
1303
|
+
onClick: fe,
|
|
1304
|
+
children: /* @__PURE__ */ Z(ji, { icon: ce === "copied" ? "check" : "clipboard" })
|
|
1305
1305
|
}), D ? /* @__PURE__ */ Z("span", {
|
|
1306
1306
|
className: "markweave-codeblock-tooltip",
|
|
1307
1307
|
role: "tooltip",
|
|
@@ -1309,7 +1309,7 @@ function Ai({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1309
1309
|
children: "Copy to clipboard"
|
|
1310
1310
|
}) : null]
|
|
1311
1311
|
}),
|
|
1312
|
-
|
|
1312
|
+
ae && le === "preview" ? /* @__PURE__ */ Q("div", {
|
|
1313
1313
|
className: "markweave-mermaid-preview-actions",
|
|
1314
1314
|
"data-testid": "markweave-mermaid-preview-actions",
|
|
1315
1315
|
children: [/* @__PURE__ */ Z("button", {
|
|
@@ -1319,8 +1319,8 @@ function Ai({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1319
1319
|
"data-testid": "markweave-mermaid-fullscreen",
|
|
1320
1320
|
disabled: !V,
|
|
1321
1321
|
onMouseDown: (e) => e.preventDefault(),
|
|
1322
|
-
onClick:
|
|
1323
|
-
children: /* @__PURE__ */ Z(
|
|
1322
|
+
onClick: Se,
|
|
1323
|
+
children: /* @__PURE__ */ Z(ji, { icon: "expand" })
|
|
1324
1324
|
}), /* @__PURE__ */ Z("button", {
|
|
1325
1325
|
type: "button",
|
|
1326
1326
|
className: "markweave-codeblock-icon-button",
|
|
@@ -1328,13 +1328,13 @@ function Ai({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1328
1328
|
"data-testid": "markweave-mermaid-download",
|
|
1329
1329
|
disabled: !V,
|
|
1330
1330
|
onMouseDown: (e) => e.preventDefault(),
|
|
1331
|
-
onClick:
|
|
1332
|
-
children: /* @__PURE__ */ Z(
|
|
1331
|
+
onClick: xe,
|
|
1332
|
+
children: /* @__PURE__ */ Z(ji, { icon: "download" })
|
|
1333
1333
|
})]
|
|
1334
1334
|
}) : null
|
|
1335
1335
|
]
|
|
1336
1336
|
}) : null,
|
|
1337
|
-
oe &&
|
|
1337
|
+
oe && B && y ? /* @__PURE__ */ Q("div", {
|
|
1338
1338
|
className: "markweave-codeblock-language-menu",
|
|
1339
1339
|
"data-testid": "markweave-codeblock-language-menu",
|
|
1340
1340
|
"data-positioned": _ ? "true" : "false",
|
|
@@ -1350,21 +1350,21 @@ function Ai({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1350
1350
|
"aria-autocomplete": "list",
|
|
1351
1351
|
"aria-controls": l.current ?? void 0,
|
|
1352
1352
|
"aria-expanded": "true",
|
|
1353
|
-
"aria-activedescendant":
|
|
1353
|
+
"aria-activedescendant": ye,
|
|
1354
1354
|
"aria-label": "Search code block languages",
|
|
1355
1355
|
value: x,
|
|
1356
1356
|
placeholder: "Search...",
|
|
1357
1357
|
"data-testid": "markweave-codeblock-language-search",
|
|
1358
|
-
onChange: (e) =>
|
|
1359
|
-
onKeyDown:
|
|
1360
|
-
}), /* @__PURE__ */ Z(
|
|
1358
|
+
onChange: (e) => ge(e.target.value),
|
|
1359
|
+
onKeyDown: _e
|
|
1360
|
+
}), /* @__PURE__ */ Z(ji, { icon: "search" })]
|
|
1361
1361
|
}), /* @__PURE__ */ Z("div", {
|
|
1362
1362
|
ref: c,
|
|
1363
1363
|
id: l.current ?? void 0,
|
|
1364
1364
|
className: "markweave-codeblock-language-list",
|
|
1365
1365
|
role: "listbox",
|
|
1366
1366
|
"aria-label": "Code block languages",
|
|
1367
|
-
children:
|
|
1367
|
+
children: U.map((e, t) => {
|
|
1368
1368
|
let n = e.language === R.language, r = t === C;
|
|
1369
1369
|
return /* @__PURE__ */ Q("button", {
|
|
1370
1370
|
id: l.current ? Rn(l.current, e.language) : void 0,
|
|
@@ -1377,8 +1377,8 @@ function Ai({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1377
1377
|
"data-language-index": t,
|
|
1378
1378
|
onMouseDown: (e) => e.preventDefault(),
|
|
1379
1379
|
onMouseEnter: () => w(t),
|
|
1380
|
-
onClick: () =>
|
|
1381
|
-
children: [/* @__PURE__ */ Z("span", { children: e.label }), n ? /* @__PURE__ */ Z(
|
|
1380
|
+
onClick: () => me(e.language),
|
|
1381
|
+
children: [/* @__PURE__ */ Z("span", { children: e.label }), n ? /* @__PURE__ */ Z(ji, { icon: "check" }) : null]
|
|
1382
1382
|
}, e.language);
|
|
1383
1383
|
})
|
|
1384
1384
|
})]
|
|
@@ -1403,8 +1403,8 @@ function Ai({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1403
1403
|
onMouseLeave: () => M(null),
|
|
1404
1404
|
onFocus: () => M("zoom-out"),
|
|
1405
1405
|
onBlur: () => M(null),
|
|
1406
|
-
onClick: () =>
|
|
1407
|
-
children: /* @__PURE__ */ Z(
|
|
1406
|
+
onClick: () => we(-qn),
|
|
1407
|
+
children: /* @__PURE__ */ Z(ji, { icon: "zoomOut" })
|
|
1408
1408
|
}),
|
|
1409
1409
|
/* @__PURE__ */ Z("span", {
|
|
1410
1410
|
className: "markweave-mermaid-fullscreen-zoom-label",
|
|
@@ -1420,8 +1420,8 @@ function Ai({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1420
1420
|
onMouseLeave: () => M(null),
|
|
1421
1421
|
onFocus: () => M("zoom-in"),
|
|
1422
1422
|
onBlur: () => M(null),
|
|
1423
|
-
onClick: () =>
|
|
1424
|
-
children: /* @__PURE__ */ Z(
|
|
1423
|
+
onClick: () => we(qn),
|
|
1424
|
+
children: /* @__PURE__ */ Z(ji, { icon: "zoomIn" })
|
|
1425
1425
|
}),
|
|
1426
1426
|
/* @__PURE__ */ Z("button", {
|
|
1427
1427
|
type: "button",
|
|
@@ -1432,8 +1432,8 @@ function Ai({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1432
1432
|
onMouseLeave: () => M(null),
|
|
1433
1433
|
onFocus: () => M("reset"),
|
|
1434
1434
|
onBlur: () => M(null),
|
|
1435
|
-
onClick:
|
|
1436
|
-
children: /* @__PURE__ */ Z(
|
|
1435
|
+
onClick: Te,
|
|
1436
|
+
children: /* @__PURE__ */ Z(ji, { icon: "reset" })
|
|
1437
1437
|
}),
|
|
1438
1438
|
j ? /* @__PURE__ */ Z("span", {
|
|
1439
1439
|
className: "markweave-mermaid-fullscreen-tooltip",
|
|
@@ -1448,18 +1448,18 @@ function Ai({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1448
1448
|
className: "markweave-mermaid-fullscreen-close",
|
|
1449
1449
|
"aria-label": "Close fullscreen Mermaid preview",
|
|
1450
1450
|
"data-testid": "markweave-mermaid-fullscreen-close",
|
|
1451
|
-
onClick:
|
|
1452
|
-
children: /* @__PURE__ */ Z(
|
|
1451
|
+
onClick: Ce,
|
|
1452
|
+
children: /* @__PURE__ */ Z(ji, { icon: "close" })
|
|
1453
1453
|
}),
|
|
1454
1454
|
/* @__PURE__ */ Z("div", {
|
|
1455
1455
|
className: "markweave-mermaid-fullscreen-viewport",
|
|
1456
1456
|
"data-testid": "markweave-mermaid-fullscreen-viewport",
|
|
1457
|
-
"data-dragging":
|
|
1458
|
-
onWheel:
|
|
1459
|
-
onMouseDown:
|
|
1460
|
-
onMouseMove:
|
|
1461
|
-
onMouseUp:
|
|
1462
|
-
onMouseLeave:
|
|
1457
|
+
"data-dragging": ee ? "true" : "false",
|
|
1458
|
+
onWheel: Ee,
|
|
1459
|
+
onMouseDown: De,
|
|
1460
|
+
onMouseMove: Oe,
|
|
1461
|
+
onMouseUp: ke,
|
|
1462
|
+
onMouseLeave: ke,
|
|
1463
1463
|
children: /* @__PURE__ */ Z("div", {
|
|
1464
1464
|
className: "markweave-mermaid-fullscreen-content",
|
|
1465
1465
|
"data-testid": "markweave-mermaid-fullscreen-content",
|
|
@@ -1480,25 +1480,25 @@ function Ai({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1480
1480
|
}
|
|
1481
1481
|
//#endregion
|
|
1482
1482
|
//#region src/ui/floating-toolbar/FloatingToolbar.tsx
|
|
1483
|
-
var
|
|
1484
|
-
function
|
|
1483
|
+
var Ni = n("zh");
|
|
1484
|
+
function Pi() {
|
|
1485
1485
|
return typeof performance > "u" ? Date.now() : performance.now();
|
|
1486
1486
|
}
|
|
1487
|
-
function
|
|
1487
|
+
function Fi(e, t) {
|
|
1488
1488
|
return {
|
|
1489
1489
|
"--markweave-toolbar-motion-duration": `${e.motionDurationMs}ms`,
|
|
1490
1490
|
"--markweave-toolbar-motion-easing": e.motionEasing,
|
|
1491
1491
|
marginLeft: t === 0 ? void 0 : `${t}px`
|
|
1492
1492
|
};
|
|
1493
1493
|
}
|
|
1494
|
-
function
|
|
1494
|
+
function Ii(e, t) {
|
|
1495
1495
|
let n = e?.getBoundingClientRect().height ?? 0, r = t?.getBoundingClientRect().height ?? 0;
|
|
1496
1496
|
return Math.max(n, r, 44);
|
|
1497
1497
|
}
|
|
1498
|
-
function
|
|
1498
|
+
function Li(e) {
|
|
1499
1499
|
if (e !== null) return { "--markweave-floating-toolbar-tooltip-left": `${e}px` };
|
|
1500
1500
|
}
|
|
1501
|
-
function
|
|
1501
|
+
function Ri(e, t, n, r) {
|
|
1502
1502
|
let i = {
|
|
1503
1503
|
bottom: t + r,
|
|
1504
1504
|
height: r,
|
|
@@ -1514,26 +1514,26 @@ function Ii(e, t, n, r) {
|
|
|
1514
1514
|
toJSON: () => i
|
|
1515
1515
|
};
|
|
1516
1516
|
}
|
|
1517
|
-
function
|
|
1517
|
+
function zi(e) {
|
|
1518
1518
|
return e.width > 0 && e.height > 0;
|
|
1519
1519
|
}
|
|
1520
|
-
function
|
|
1520
|
+
function Bi(e) {
|
|
1521
1521
|
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));
|
|
1522
|
-
return
|
|
1522
|
+
return Ri(t, n, r - t, i - n);
|
|
1523
1523
|
}
|
|
1524
|
-
function
|
|
1524
|
+
function Vi(e, t) {
|
|
1525
1525
|
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;
|
|
1526
1526
|
return r(t.anchorNode) && r(t.focusNode);
|
|
1527
1527
|
}
|
|
1528
|
-
function
|
|
1528
|
+
function Hi(e) {
|
|
1529
1529
|
if (typeof e.getClientRects != "function") return null;
|
|
1530
|
-
let t = Array.from(e.getClientRects()).filter(
|
|
1530
|
+
let t = Array.from(e.getClientRects()).filter(zi).map((e) => Ri(e.left, e.top, e.width, e.height));
|
|
1531
1531
|
if (t.length > 0) return t;
|
|
1532
1532
|
if (typeof e.getBoundingClientRect != "function") return null;
|
|
1533
1533
|
let n = e.getBoundingClientRect();
|
|
1534
|
-
return
|
|
1534
|
+
return zi(n) ? [Ri(n.left, n.top, n.width, n.height)] : null;
|
|
1535
1535
|
}
|
|
1536
|
-
function
|
|
1536
|
+
function Ui(e, t) {
|
|
1537
1537
|
if (t.rangeCount === 0) return null;
|
|
1538
1538
|
let n = t.getRangeAt(0);
|
|
1539
1539
|
try {
|
|
@@ -1546,8 +1546,8 @@ function Vi(e, t) {
|
|
|
1546
1546
|
return null;
|
|
1547
1547
|
}
|
|
1548
1548
|
}
|
|
1549
|
-
function
|
|
1550
|
-
let n =
|
|
1549
|
+
function Wi(e, t) {
|
|
1550
|
+
let n = Ui(e, t);
|
|
1551
1551
|
if (!n) return !1;
|
|
1552
1552
|
let { selection: r } = e.state, i = {
|
|
1553
1553
|
from: Math.min(r.from, r.to),
|
|
@@ -1555,51 +1555,51 @@ function Hi(e, t) {
|
|
|
1555
1555
|
};
|
|
1556
1556
|
return n.from === i.from && n.to === i.to;
|
|
1557
1557
|
}
|
|
1558
|
-
function
|
|
1558
|
+
function Gi(e) {
|
|
1559
1559
|
let t = e.view.dom.ownerDocument.getSelection();
|
|
1560
|
-
return !t || t.rangeCount === 0 || t.isCollapsed || !
|
|
1560
|
+
return !t || t.rangeCount === 0 || t.isCollapsed || !Vi(e, t) || !Wi(e, t) ? null : Hi(t.getRangeAt(0));
|
|
1561
1561
|
}
|
|
1562
|
-
function
|
|
1562
|
+
function Ki(e) {
|
|
1563
1563
|
let { selection: t } = e.state;
|
|
1564
1564
|
if (t.empty) return null;
|
|
1565
1565
|
let n = Math.min(t.from, t.to), r = Math.max(t.from, t.to);
|
|
1566
1566
|
try {
|
|
1567
1567
|
let t = e.view.domAtPos(n), i = e.view.domAtPos(r), a = e.view.dom.ownerDocument.createRange();
|
|
1568
|
-
return a.setStart(t.node, t.offset), a.setEnd(i.node, i.offset),
|
|
1568
|
+
return a.setStart(t.node, t.offset), a.setEnd(i.node, i.offset), Hi(a);
|
|
1569
1569
|
} catch {
|
|
1570
1570
|
return null;
|
|
1571
1571
|
}
|
|
1572
1572
|
}
|
|
1573
|
-
function
|
|
1573
|
+
function qi(e) {
|
|
1574
1574
|
let { selection: t } = e.state;
|
|
1575
1575
|
if (t.empty) return null;
|
|
1576
|
-
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 =
|
|
1577
|
-
return
|
|
1576
|
+
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 = Ri(c, o, Math.max(i.right, a.right) - c, s - o);
|
|
1577
|
+
return zi(l) ? [l] : null;
|
|
1578
1578
|
}
|
|
1579
|
-
function
|
|
1580
|
-
return
|
|
1579
|
+
function Ji(e) {
|
|
1580
|
+
return Gi(e) ?? Ki(e) ?? qi(e);
|
|
1581
1581
|
}
|
|
1582
|
-
function
|
|
1583
|
-
let t =
|
|
1584
|
-
return t && t.length > 0 ?
|
|
1582
|
+
function Yi(e) {
|
|
1583
|
+
let t = Ji(e);
|
|
1584
|
+
return t && t.length > 0 ? Bi(t) : null;
|
|
1585
1585
|
}
|
|
1586
|
-
function
|
|
1586
|
+
function Xi(e) {
|
|
1587
1587
|
return {
|
|
1588
|
-
getBoundingClientRect: () =>
|
|
1589
|
-
getClientRects: () =>
|
|
1588
|
+
getBoundingClientRect: () => Yi(e) ?? Ri(0, 0, 0, 0),
|
|
1589
|
+
getClientRects: () => Ji(e) ?? []
|
|
1590
1590
|
};
|
|
1591
1591
|
}
|
|
1592
|
-
function
|
|
1592
|
+
function Zi(e) {
|
|
1593
1593
|
return e === "block-type" || e === "link" || e === "color" || e === "more";
|
|
1594
1594
|
}
|
|
1595
|
-
function
|
|
1595
|
+
function Qi(e, t, n) {
|
|
1596
1596
|
n?.($n(e, t)), e.commands.focus();
|
|
1597
1597
|
}
|
|
1598
|
-
function
|
|
1599
|
-
let i =
|
|
1598
|
+
function $i({ editor: e, messages: t = Ni, selectionSnapshot: n, onRewriteSelection: r }) {
|
|
1599
|
+
let i = q(() => ir(t), [t]), a = kt(n, { editable: e.isEditable }), [o, s] = Y(a), [c, l] = Y(null), [u, d] = Y(null), [f, p] = Y(null), [m, h] = Y(""), [g, _] = Y(""), [v, y] = Y(null), [b, x] = Y(0), [S, C] = Y(a.boundaryPadding), [w, T] = Y("bottom"), E = J(0), D = J(null), O = J(null), k = J(null), A = J(null), j = er(e, o.variant, t), M = or(j.find((e) => e.id === c) ?? null), ee = _r(m), N = W(() => {
|
|
1600
1600
|
let t = D.current, n = e.view.dom.closest(".markweave-editor-frame");
|
|
1601
1601
|
if (!t || !(n instanceof HTMLElement)) return;
|
|
1602
|
-
let r = t.getBoundingClientRect(), i = n.getBoundingClientRect(), a =
|
|
1602
|
+
let r = t.getBoundingClientRect(), i = n.getBoundingClientRect(), a = Ii(t, O.current), s = E.current, c = wt({
|
|
1603
1603
|
toolbarRect: {
|
|
1604
1604
|
left: r.left - s,
|
|
1605
1605
|
top: r.top,
|
|
@@ -1632,13 +1632,13 @@ function Zi({ editor: e, messages: t = ji, selectionSnapshot: n, onRewriteSelect
|
|
|
1632
1632
|
e.view.dom,
|
|
1633
1633
|
o.boundaryPadding,
|
|
1634
1634
|
o.offset
|
|
1635
|
-
]),
|
|
1635
|
+
]), te = W(() => {
|
|
1636
1636
|
D.current && (D.current.style.visibility = "hidden", D.current.style.opacity = "0");
|
|
1637
|
-
}, []),
|
|
1638
|
-
|
|
1639
|
-
}, [
|
|
1637
|
+
}, []), P = W(() => {
|
|
1638
|
+
N();
|
|
1639
|
+
}, [N]), ne = W(() => Xi(e), [e]), F = W((e) => {
|
|
1640
1640
|
k.current = e;
|
|
1641
|
-
}, []),
|
|
1641
|
+
}, []), I = W(() => {
|
|
1642
1642
|
let t = D.current, n = k.current, r = e.view.dom.closest(".markweave-editor-frame");
|
|
1643
1643
|
if (!f || !t || !n) return;
|
|
1644
1644
|
let i = t.getBoundingClientRect(), a = n.getBoundingClientRect(), s = r?.getBoundingClientRect() ?? null, c = Tt({
|
|
@@ -1657,18 +1657,18 @@ function Zi({ editor: e, messages: t = ji, selectionSnapshot: n, onRewriteSelect
|
|
|
1657
1657
|
e.view.dom,
|
|
1658
1658
|
f,
|
|
1659
1659
|
o.boundaryPadding
|
|
1660
|
-
]),
|
|
1660
|
+
]), L = q(() => ({
|
|
1661
1661
|
...Ot(o, { topBoundaryPadding: S }),
|
|
1662
|
-
onShow:
|
|
1663
|
-
onUpdate:
|
|
1662
|
+
onShow: te,
|
|
1663
|
+
onUpdate: P
|
|
1664
1664
|
}), [
|
|
1665
|
-
|
|
1666
|
-
|
|
1665
|
+
te,
|
|
1666
|
+
P,
|
|
1667
1667
|
o,
|
|
1668
1668
|
S
|
|
1669
1669
|
]);
|
|
1670
|
-
|
|
1671
|
-
let e =
|
|
1670
|
+
G(() => {
|
|
1671
|
+
let e = Pi();
|
|
1672
1672
|
s((t) => Mt(t, a, e));
|
|
1673
1673
|
}, [
|
|
1674
1674
|
a.hiddenReason,
|
|
@@ -1681,10 +1681,10 @@ function Zi({ editor: e, messages: t = ji, selectionSnapshot: n, onRewriteSelect
|
|
|
1681
1681
|
a.updateDelayMs,
|
|
1682
1682
|
a.variant,
|
|
1683
1683
|
a.visibility
|
|
1684
|
-
]),
|
|
1684
|
+
]), G(() => {
|
|
1685
1685
|
if (o.motionStartedAtMs === null || o.motionDurationMs <= 0) return;
|
|
1686
|
-
let e = Math.max(0, o.motionStartedAtMs + o.motionDurationMs -
|
|
1687
|
-
s((e) => St(e,
|
|
1686
|
+
let e = Math.max(0, o.motionStartedAtMs + o.motionDurationMs - Pi()), t = window.setTimeout(() => {
|
|
1687
|
+
s((e) => St(e, Pi()));
|
|
1688
1688
|
}, e);
|
|
1689
1689
|
return () => {
|
|
1690
1690
|
window.clearTimeout(t);
|
|
@@ -1693,17 +1693,17 @@ function Zi({ editor: e, messages: t = ji, selectionSnapshot: n, onRewriteSelect
|
|
|
1693
1693
|
o.motionDurationMs,
|
|
1694
1694
|
o.motionPhase,
|
|
1695
1695
|
o.motionStartedAtMs
|
|
1696
|
-
]),
|
|
1696
|
+
]), K(() => {
|
|
1697
1697
|
if (o.visibility !== "visible") {
|
|
1698
1698
|
E.current = 0, D.current && (D.current.style.marginLeft = "", D.current.style.visibility = "hidden", D.current.style.opacity = "0"), x(0), C(o.boundaryPadding);
|
|
1699
1699
|
return;
|
|
1700
1700
|
}
|
|
1701
|
-
let e = mt(
|
|
1701
|
+
let e = mt(N);
|
|
1702
1702
|
return e.schedule(), window.addEventListener("resize", e.schedule), window.addEventListener("scroll", e.schedule, !0), () => {
|
|
1703
1703
|
e.cancel(), window.removeEventListener("resize", e.schedule), window.removeEventListener("scroll", e.schedule, !0);
|
|
1704
1704
|
};
|
|
1705
1705
|
}, [
|
|
1706
|
-
|
|
1706
|
+
N,
|
|
1707
1707
|
e.view.dom,
|
|
1708
1708
|
f,
|
|
1709
1709
|
n?.from,
|
|
@@ -1711,20 +1711,20 @@ function Zi({ editor: e, messages: t = ji, selectionSnapshot: n, onRewriteSelect
|
|
|
1711
1711
|
o.variant,
|
|
1712
1712
|
o.visibility,
|
|
1713
1713
|
j.length
|
|
1714
|
-
]),
|
|
1714
|
+
]), K(() => {
|
|
1715
1715
|
if (!f) return;
|
|
1716
|
-
let e = mt(
|
|
1716
|
+
let e = mt(I);
|
|
1717
1717
|
return e.schedule(), window.addEventListener("resize", e.schedule), window.addEventListener("scroll", e.schedule, !0), () => {
|
|
1718
1718
|
e.cancel(), window.removeEventListener("resize", e.schedule), window.removeEventListener("scroll", e.schedule, !0);
|
|
1719
1719
|
};
|
|
1720
|
-
}, [f,
|
|
1720
|
+
}, [f, I]), G(() => {
|
|
1721
1721
|
f === "more" && i.some((e) => e.id === c) || j.some((e) => e.id === c) || (l(null), d(null));
|
|
1722
1722
|
}, [
|
|
1723
1723
|
i,
|
|
1724
1724
|
f,
|
|
1725
1725
|
c,
|
|
1726
1726
|
j
|
|
1727
|
-
]),
|
|
1727
|
+
]), G(() => {
|
|
1728
1728
|
if (!f) return;
|
|
1729
1729
|
let t = (e) => {
|
|
1730
1730
|
O.current?.contains(e.target) || p(null);
|
|
@@ -1734,7 +1734,7 @@ function Zi({ editor: e, messages: t = ji, selectionSnapshot: n, onRewriteSelect
|
|
|
1734
1734
|
return document.addEventListener("pointerdown", t, !0), document.addEventListener("keydown", n, !0), () => {
|
|
1735
1735
|
document.removeEventListener("pointerdown", t, !0), document.removeEventListener("keydown", n, !0);
|
|
1736
1736
|
};
|
|
1737
|
-
}, [e, f]),
|
|
1737
|
+
}, [e, f]), G(() => {
|
|
1738
1738
|
if (f !== "link") return;
|
|
1739
1739
|
let e = window.requestAnimationFrame(() => {
|
|
1740
1740
|
A.current?.focus(), A.current?.select();
|
|
@@ -1742,7 +1742,7 @@ function Zi({ editor: e, messages: t = ji, selectionSnapshot: n, onRewriteSelect
|
|
|
1742
1742
|
return () => window.cancelAnimationFrame(e);
|
|
1743
1743
|
}, [f]);
|
|
1744
1744
|
let re = (t) => {
|
|
1745
|
-
if (
|
|
1745
|
+
if (Zi(t.id)) {
|
|
1746
1746
|
let n = t.id;
|
|
1747
1747
|
if (n === "link") {
|
|
1748
1748
|
let t = nr(e);
|
|
@@ -1755,7 +1755,7 @@ function Zi({ editor: e, messages: t = ji, selectionSnapshot: n, onRewriteSelect
|
|
|
1755
1755
|
return;
|
|
1756
1756
|
}
|
|
1757
1757
|
if (p(null), t.id === "improve") {
|
|
1758
|
-
|
|
1758
|
+
Qi(e, "rewrite-selection", r);
|
|
1759
1759
|
return;
|
|
1760
1760
|
}
|
|
1761
1761
|
t.run(), e.commands.focus();
|
|
@@ -1763,15 +1763,15 @@ function Zi({ editor: e, messages: t = ji, selectionSnapshot: n, onRewriteSelect
|
|
|
1763
1763
|
p(null), e.commands.focus();
|
|
1764
1764
|
}, ie = () => {
|
|
1765
1765
|
v && e.commands.setTextSelection(v);
|
|
1766
|
-
},
|
|
1766
|
+
}, ae = () => {
|
|
1767
1767
|
ie(), Qn(e, m) && R();
|
|
1768
|
-
},
|
|
1768
|
+
}, z = () => {
|
|
1769
1769
|
if (ie(), fr(e)) {
|
|
1770
1770
|
h(""), _(""), R();
|
|
1771
1771
|
return;
|
|
1772
1772
|
}
|
|
1773
1773
|
m.trim() && h("");
|
|
1774
|
-
},
|
|
1774
|
+
}, B = (e, t) => {
|
|
1775
1775
|
if (l(e), !e || !t || !O.current) {
|
|
1776
1776
|
d(null);
|
|
1777
1777
|
return;
|
|
@@ -1784,59 +1784,59 @@ function Zi({ editor: e, messages: t = ji, selectionSnapshot: n, onRewriteSelect
|
|
|
1784
1784
|
editor: e,
|
|
1785
1785
|
className: `markweave-floating-toolbar markweave-floating-toolbar--${o.variant} markweave-floating-toolbar--motion-${o.motionPhase}`,
|
|
1786
1786
|
"data-motion": o.motionPhase,
|
|
1787
|
-
"data-position-strategy":
|
|
1787
|
+
"data-position-strategy": L.strategy,
|
|
1788
1788
|
"data-boundary-padding": o.boundaryPadding,
|
|
1789
1789
|
"data-popover-placement": f ? w : void 0,
|
|
1790
1790
|
"data-testid": "markweave-floating-toolbar",
|
|
1791
|
-
style:
|
|
1791
|
+
style: Fi(o, b),
|
|
1792
1792
|
updateDelay: 0,
|
|
1793
|
-
getReferencedVirtualElement:
|
|
1794
|
-
options:
|
|
1793
|
+
getReferencedVirtualElement: ne,
|
|
1794
|
+
options: L,
|
|
1795
1795
|
shouldShow: ({ editor: e }) => e.isEditable && jt(Dt(e)),
|
|
1796
1796
|
children: /* @__PURE__ */ Q("div", {
|
|
1797
1797
|
ref: O,
|
|
1798
1798
|
className: "markweave-floating-toolbar-content",
|
|
1799
1799
|
"data-menu": f ?? "none",
|
|
1800
1800
|
children: [
|
|
1801
|
-
j.map((e, t) => /* @__PURE__ */ Z(
|
|
1801
|
+
j.map((e, t) => /* @__PURE__ */ Z(ta, {
|
|
1802
1802
|
button: e,
|
|
1803
1803
|
expanded: f === e.id,
|
|
1804
1804
|
showDivider: t > 0 && j[t - 1].group !== e.group,
|
|
1805
1805
|
tooltipActive: c === e.id,
|
|
1806
1806
|
onPointerDown: dr,
|
|
1807
|
-
onTooltipChange:
|
|
1807
|
+
onTooltipChange: B,
|
|
1808
1808
|
onRun: re
|
|
1809
1809
|
}, e.id)),
|
|
1810
|
-
f === "block-type" ? /* @__PURE__ */ Z(
|
|
1810
|
+
f === "block-type" ? /* @__PURE__ */ Z(ra, {
|
|
1811
1811
|
editor: e,
|
|
1812
1812
|
messages: t,
|
|
1813
|
-
onPopoverRef:
|
|
1813
|
+
onPopoverRef: F,
|
|
1814
1814
|
onClose: () => p(null)
|
|
1815
1815
|
}) : null,
|
|
1816
|
-
f === "link" ? /* @__PURE__ */ Z(
|
|
1816
|
+
f === "link" ? /* @__PURE__ */ Z(ea, {
|
|
1817
1817
|
inputRef: A,
|
|
1818
1818
|
messages: t,
|
|
1819
1819
|
value: m,
|
|
1820
|
-
canApply: !!
|
|
1821
|
-
canOpen: !!
|
|
1820
|
+
canApply: !!ee,
|
|
1821
|
+
canOpen: !!ee,
|
|
1822
1822
|
canRemove: !!(g || m.trim()),
|
|
1823
1823
|
onValueChange: h,
|
|
1824
|
-
onApply:
|
|
1824
|
+
onApply: ae,
|
|
1825
1825
|
onOpen: () => ur(m),
|
|
1826
|
-
onRemove:
|
|
1827
|
-
onPopoverRef:
|
|
1826
|
+
onRemove: z,
|
|
1827
|
+
onPopoverRef: F
|
|
1828
1828
|
}) : null,
|
|
1829
|
-
f === "color" ? /* @__PURE__ */ Z(
|
|
1829
|
+
f === "color" ? /* @__PURE__ */ Z(aa, {
|
|
1830
1830
|
editor: e,
|
|
1831
1831
|
messages: t,
|
|
1832
|
-
onPopoverRef:
|
|
1832
|
+
onPopoverRef: F,
|
|
1833
1833
|
onClose: () => p(null)
|
|
1834
1834
|
}) : null,
|
|
1835
|
-
f === "more" ? /* @__PURE__ */ Z(
|
|
1835
|
+
f === "more" ? /* @__PURE__ */ Z(sa, {
|
|
1836
1836
|
editor: e,
|
|
1837
1837
|
messages: t,
|
|
1838
1838
|
activeTooltipId: c,
|
|
1839
|
-
onPopoverRef:
|
|
1839
|
+
onPopoverRef: F,
|
|
1840
1840
|
onTooltipChange: l,
|
|
1841
1841
|
onClose: () => p(null)
|
|
1842
1842
|
}) : null,
|
|
@@ -1846,14 +1846,14 @@ function Zi({ editor: e, messages: t = ji, selectionSnapshot: n, onRewriteSelect
|
|
|
1846
1846
|
"data-testid": "markweave-floating-toolbar-tooltip",
|
|
1847
1847
|
"data-button-id": M.buttonId,
|
|
1848
1848
|
"data-active": M.active,
|
|
1849
|
-
style:
|
|
1849
|
+
style: Li(u),
|
|
1850
1850
|
children: M.label
|
|
1851
1851
|
}) : null
|
|
1852
1852
|
]
|
|
1853
1853
|
})
|
|
1854
1854
|
});
|
|
1855
1855
|
}
|
|
1856
|
-
function
|
|
1856
|
+
function ea({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRemove: a, onValueChange: o, onApply: s, onOpen: c, onRemove: l, onPopoverRef: u }) {
|
|
1857
1857
|
let d = rr(t);
|
|
1858
1858
|
return /* @__PURE__ */ Q("form", {
|
|
1859
1859
|
ref: u,
|
|
@@ -1906,7 +1906,7 @@ function Qi({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRe
|
|
|
1906
1906
|
})]
|
|
1907
1907
|
});
|
|
1908
1908
|
}
|
|
1909
|
-
function
|
|
1909
|
+
function ta({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointerDown: i, onTooltipChange: a, onRun: o }) {
|
|
1910
1910
|
return /* @__PURE__ */ Q(ot, { children: [n ? /* @__PURE__ */ Z("span", {
|
|
1911
1911
|
className: "markweave-floating-toolbar-divider",
|
|
1912
1912
|
"aria-hidden": "true"
|
|
@@ -1914,7 +1914,7 @@ function $i({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointe
|
|
|
1914
1914
|
type: "button",
|
|
1915
1915
|
className: `markweave-floating-toolbar-button markweave-floating-toolbar-button--${e.id}`,
|
|
1916
1916
|
"aria-label": e.label,
|
|
1917
|
-
"aria-expanded":
|
|
1917
|
+
"aria-expanded": Zi(e.id) ? t : void 0,
|
|
1918
1918
|
"data-active": e.active || t,
|
|
1919
1919
|
"data-tooltip-active": r ? "true" : "false",
|
|
1920
1920
|
"data-testid": `markweave-floating-toolbar-button-${e.id}`,
|
|
@@ -1924,13 +1924,13 @@ function $i({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointe
|
|
|
1924
1924
|
onMouseEnter: (t) => a(e.id, t.currentTarget),
|
|
1925
1925
|
onMouseLeave: () => a(null),
|
|
1926
1926
|
onClick: () => o(e),
|
|
1927
|
-
children: /* @__PURE__ */ Z(
|
|
1927
|
+
children: /* @__PURE__ */ Z(na, {
|
|
1928
1928
|
button: e,
|
|
1929
1929
|
expanded: t
|
|
1930
1930
|
})
|
|
1931
1931
|
})] });
|
|
1932
1932
|
}
|
|
1933
|
-
function
|
|
1933
|
+
function na({ button: e, expanded: t }) {
|
|
1934
1934
|
return e.id === "improve" ? /* @__PURE__ */ Q("span", {
|
|
1935
1935
|
className: "markweave-floating-toolbar-button-inner",
|
|
1936
1936
|
children: [/* @__PURE__ */ Z($, { name: "sparkles" }), /* @__PURE__ */ Z("span", { children: e.glyph })]
|
|
@@ -1948,7 +1948,7 @@ function ea({ button: e, expanded: t }) {
|
|
|
1948
1948
|
}), /* @__PURE__ */ Z($, { name: t ? "chevron-up" : "chevron-down" })]
|
|
1949
1949
|
}) : /* @__PURE__ */ Z($, { name: "more" });
|
|
1950
1950
|
}
|
|
1951
|
-
function
|
|
1951
|
+
function ra({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
|
|
1952
1952
|
let i = rr(t), a = sr(t);
|
|
1953
1953
|
return /* @__PURE__ */ Q("div", {
|
|
1954
1954
|
ref: n,
|
|
@@ -1967,21 +1967,21 @@ function ta({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
|
|
|
1967
1967
|
},
|
|
1968
1968
|
children: [/* @__PURE__ */ Z("span", {
|
|
1969
1969
|
className: "markweave-floating-toolbar-menu-icon",
|
|
1970
|
-
children: /* @__PURE__ */ Z(
|
|
1970
|
+
children: /* @__PURE__ */ Z(ia, { option: t })
|
|
1971
1971
|
}), /* @__PURE__ */ Z("span", { children: t.label })]
|
|
1972
1972
|
}, t.id))]
|
|
1973
1973
|
});
|
|
1974
1974
|
}
|
|
1975
|
-
function
|
|
1975
|
+
function ia({ option: e }) {
|
|
1976
1976
|
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 });
|
|
1977
1977
|
}
|
|
1978
|
-
function
|
|
1978
|
+
function aa({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
|
|
1979
1979
|
let i = rr(t), a = e.getAttributes("textStyle").color, o = e.getAttributes("highlight").color;
|
|
1980
1980
|
return /* @__PURE__ */ Q("div", {
|
|
1981
1981
|
ref: n,
|
|
1982
1982
|
className: "markweave-floating-toolbar-popover markweave-floating-toolbar-color-popover",
|
|
1983
1983
|
"data-testid": "markweave-floating-toolbar-color-menu",
|
|
1984
|
-
children: [/* @__PURE__ */ Z(
|
|
1984
|
+
children: [/* @__PURE__ */ Z(oa, {
|
|
1985
1985
|
title: i.textColorTitle,
|
|
1986
1986
|
mode: "text",
|
|
1987
1987
|
activeColor: a ?? null,
|
|
@@ -1989,7 +1989,7 @@ function ra({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
|
|
|
1989
1989
|
onSelect: (t) => {
|
|
1990
1990
|
hr(e, t), r();
|
|
1991
1991
|
}
|
|
1992
|
-
}), /* @__PURE__ */ Z(
|
|
1992
|
+
}), /* @__PURE__ */ Z(oa, {
|
|
1993
1993
|
title: i.highlightColorTitle,
|
|
1994
1994
|
mode: "highlight",
|
|
1995
1995
|
activeColor: o ?? null,
|
|
@@ -2000,7 +2000,7 @@ function ra({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
|
|
|
2000
2000
|
})]
|
|
2001
2001
|
});
|
|
2002
2002
|
}
|
|
2003
|
-
function
|
|
2003
|
+
function oa({ title: e, mode: t, activeColor: n, options: r, onSelect: i }) {
|
|
2004
2004
|
return /* @__PURE__ */ Q("section", {
|
|
2005
2005
|
className: "markweave-floating-toolbar-color-section",
|
|
2006
2006
|
"aria-label": e,
|
|
@@ -2029,13 +2029,13 @@ function ia({ title: e, mode: t, activeColor: n, options: r, onSelect: i }) {
|
|
|
2029
2029
|
})]
|
|
2030
2030
|
});
|
|
2031
2031
|
}
|
|
2032
|
-
function
|
|
2032
|
+
function sa({ editor: e, messages: t, activeTooltipId: n, onPopoverRef: r, onTooltipChange: i, onClose: a }) {
|
|
2033
2033
|
let o = ir(t);
|
|
2034
2034
|
return /* @__PURE__ */ Z("div", {
|
|
2035
2035
|
ref: r,
|
|
2036
2036
|
className: "markweave-floating-toolbar-popover markweave-floating-toolbar-more-menu",
|
|
2037
2037
|
"data-testid": "markweave-floating-toolbar-more-menu",
|
|
2038
|
-
children: o.map((t, r) => /* @__PURE__ */ Z(
|
|
2038
|
+
children: o.map((t, r) => /* @__PURE__ */ Z(ca, {
|
|
2039
2039
|
action: t,
|
|
2040
2040
|
active: cr(e, t.id),
|
|
2041
2041
|
tooltipActive: n === t.id,
|
|
@@ -2047,7 +2047,7 @@ function aa({ editor: e, messages: t, activeTooltipId: n, onPopoverRef: r, onToo
|
|
|
2047
2047
|
}, t.id))
|
|
2048
2048
|
});
|
|
2049
2049
|
}
|
|
2050
|
-
function
|
|
2050
|
+
function ca({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipChange: i, onRun: a }) {
|
|
2051
2051
|
return /* @__PURE__ */ Q(ot, { children: [r ? /* @__PURE__ */ Z("span", {
|
|
2052
2052
|
className: "markweave-floating-toolbar-divider",
|
|
2053
2053
|
"aria-hidden": "true"
|
|
@@ -2063,7 +2063,7 @@ function oa({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipC
|
|
|
2063
2063
|
onMouseEnter: () => i(e.id),
|
|
2064
2064
|
onMouseLeave: () => i(null),
|
|
2065
2065
|
onClick: a,
|
|
2066
|
-
children: /* @__PURE__ */ Z(
|
|
2066
|
+
children: /* @__PURE__ */ Z(la, { id: e.id })
|
|
2067
2067
|
}), n ? /* @__PURE__ */ Z("div", {
|
|
2068
2068
|
className: "markweave-floating-toolbar-tooltip markweave-floating-toolbar-tooltip--more",
|
|
2069
2069
|
role: "tooltip",
|
|
@@ -2071,41 +2071,41 @@ function oa({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipC
|
|
|
2071
2071
|
}) : null]
|
|
2072
2072
|
})] });
|
|
2073
2073
|
}
|
|
2074
|
-
function
|
|
2074
|
+
function la({ id: e }) {
|
|
2075
2075
|
return e === "superscript" ? /* @__PURE__ */ Z($, { name: "superscript" }) : e === "subscript" ? /* @__PURE__ */ Z($, { name: "subscript" }) : e === "inline-math" ? /* @__PURE__ */ Z($, { name: "math" }) : Z($, { name: e });
|
|
2076
2076
|
}
|
|
2077
|
-
var
|
|
2078
|
-
sparkles:
|
|
2077
|
+
var ua = {
|
|
2078
|
+
sparkles: xe,
|
|
2079
2079
|
"chevron-down": j,
|
|
2080
|
-
"chevron-up":
|
|
2081
|
-
"corner-down-left":
|
|
2082
|
-
"external-link":
|
|
2080
|
+
"chevron-up": ee,
|
|
2081
|
+
"corner-down-left": ne,
|
|
2082
|
+
"external-link": I,
|
|
2083
2083
|
bold: E,
|
|
2084
2084
|
italic: ce,
|
|
2085
|
-
underline:
|
|
2086
|
-
strike:
|
|
2087
|
-
"inline-code":
|
|
2085
|
+
underline: Me,
|
|
2086
|
+
strike: Ce,
|
|
2087
|
+
"inline-code": te,
|
|
2088
2088
|
link: V,
|
|
2089
|
-
more:
|
|
2090
|
-
text:
|
|
2089
|
+
more: fe,
|
|
2090
|
+
text: je,
|
|
2091
2091
|
"bullet-list": ue,
|
|
2092
|
-
"numbered-list":
|
|
2093
|
-
"todo-list":
|
|
2094
|
-
quote:
|
|
2092
|
+
"numbered-list": U,
|
|
2093
|
+
"todo-list": H,
|
|
2094
|
+
quote: _e,
|
|
2095
2095
|
"code-block": D,
|
|
2096
|
-
superscript:
|
|
2097
|
-
subscript:
|
|
2098
|
-
math:
|
|
2096
|
+
superscript: Te,
|
|
2097
|
+
subscript: we,
|
|
2098
|
+
math: ye,
|
|
2099
2099
|
"align-left": d,
|
|
2100
2100
|
"align-center": l,
|
|
2101
2101
|
"align-right": f,
|
|
2102
2102
|
"align-justify": u,
|
|
2103
|
-
"decrease-indent":
|
|
2103
|
+
"decrease-indent": B,
|
|
2104
2104
|
"increase-indent": oe,
|
|
2105
|
-
trash:
|
|
2105
|
+
trash: Ae
|
|
2106
2106
|
};
|
|
2107
2107
|
function $({ name: e }) {
|
|
2108
|
-
let t =
|
|
2108
|
+
let t = ua[e];
|
|
2109
2109
|
return /* @__PURE__ */ Z(t, {
|
|
2110
2110
|
"aria-hidden": "true",
|
|
2111
2111
|
absoluteStrokeWidth: !0,
|
|
@@ -2115,8 +2115,8 @@ function $({ name: e }) {
|
|
|
2115
2115
|
}
|
|
2116
2116
|
//#endregion
|
|
2117
2117
|
//#region src/ui/math/MathEditorPopover.tsx
|
|
2118
|
-
function
|
|
2119
|
-
let i =
|
|
2118
|
+
function da({ editor: e, messages: t, onClose: n, target: r }) {
|
|
2119
|
+
let i = J(null), a = J(null), [o, s] = Y(r.latex), [c, l] = Y(null), u = t.math, d = q(() => Yt(e, r) ?? 1, [e, r]), f = q(() => Xt(e, r), [e, r]), p = q(() => o === r.latex && f ? {
|
|
2120
2120
|
html: f,
|
|
2121
2121
|
error: !1
|
|
2122
2122
|
} : en(o, r.kind, e), [
|
|
@@ -2125,7 +2125,7 @@ function la({ editor: e, messages: t, onClose: n, target: r }) {
|
|
|
2125
2125
|
r.kind,
|
|
2126
2126
|
r.latex,
|
|
2127
2127
|
o
|
|
2128
|
-
]), m = o.trim().length > 0, h =
|
|
2128
|
+
]), m = o.trim().length > 0, h = W(() => {
|
|
2129
2129
|
if (typeof window > "u") return;
|
|
2130
2130
|
let t = Jt(e, r), i = e.view.dom.closest(".markweave-editor-frame")?.getBoundingClientRect();
|
|
2131
2131
|
if (!t || !i) {
|
|
@@ -2146,9 +2146,9 @@ function la({ editor: e, messages: t, onClose: n, target: r }) {
|
|
|
2146
2146
|
r,
|
|
2147
2147
|
o
|
|
2148
2148
|
]);
|
|
2149
|
-
|
|
2149
|
+
G(() => {
|
|
2150
2150
|
s(r.latex);
|
|
2151
|
-
}, [r.latex, r.pos]),
|
|
2151
|
+
}, [r.latex, r.pos]), G(() => {
|
|
2152
2152
|
tn(e, r, !0), h();
|
|
2153
2153
|
let t = window.requestAnimationFrame(() => {
|
|
2154
2154
|
a.current?.focus({ preventScroll: !0 }), a.current?.select(), h();
|
|
@@ -2161,14 +2161,14 @@ function la({ editor: e, messages: t, onClose: n, target: r }) {
|
|
|
2161
2161
|
n,
|
|
2162
2162
|
r,
|
|
2163
2163
|
h
|
|
2164
|
-
]),
|
|
2164
|
+
]), G(() => {
|
|
2165
2165
|
let e = (e) => {
|
|
2166
2166
|
let t = e.target;
|
|
2167
2167
|
t instanceof Node && (i.current?.contains(t) || t instanceof Element && t.closest(".tiptap-mathematics-render") || n());
|
|
2168
2168
|
};
|
|
2169
2169
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
2170
2170
|
}, [n]);
|
|
2171
|
-
let g =
|
|
2171
|
+
let g = W(() => {
|
|
2172
2172
|
m && Kt(e, r, o) && n();
|
|
2173
2173
|
}, [
|
|
2174
2174
|
m,
|
|
@@ -2244,7 +2244,7 @@ function la({ editor: e, messages: t, onClose: n, target: r }) {
|
|
|
2244
2244
|
className: "markweave-math-block-toolbar",
|
|
2245
2245
|
children: [
|
|
2246
2246
|
/* @__PURE__ */ Z("span", { children: u.label }),
|
|
2247
|
-
/* @__PURE__ */ Z(
|
|
2247
|
+
/* @__PURE__ */ Z(te, {
|
|
2248
2248
|
"aria-hidden": "true",
|
|
2249
2249
|
size: 15,
|
|
2250
2250
|
strokeWidth: 1.75
|
|
@@ -2300,31 +2300,31 @@ function la({ editor: e, messages: t, onClose: n, target: r }) {
|
|
|
2300
2300
|
}
|
|
2301
2301
|
//#endregion
|
|
2302
2302
|
//#region src/ui/slash-command/SlashCommandMenu.tsx
|
|
2303
|
-
var
|
|
2304
|
-
type:
|
|
2303
|
+
var fa = n("zh"), pa = {
|
|
2304
|
+
type: ke,
|
|
2305
2305
|
"heading-1": re,
|
|
2306
2306
|
"heading-2": R,
|
|
2307
2307
|
"heading-3": ie,
|
|
2308
2308
|
"bullet-list": ue,
|
|
2309
|
-
"ordered-list":
|
|
2310
|
-
"task-list":
|
|
2311
|
-
blockquote:
|
|
2309
|
+
"ordered-list": U,
|
|
2310
|
+
"task-list": H,
|
|
2311
|
+
blockquote: _e,
|
|
2312
2312
|
"code-block": D,
|
|
2313
2313
|
info: se,
|
|
2314
2314
|
tip: le,
|
|
2315
2315
|
warning: c,
|
|
2316
|
-
error:
|
|
2316
|
+
error: N,
|
|
2317
2317
|
success: A,
|
|
2318
|
-
emoji:
|
|
2319
|
-
math:
|
|
2320
|
-
table:
|
|
2321
|
-
separator:
|
|
2322
|
-
image:
|
|
2323
|
-
video:
|
|
2324
|
-
attachment:
|
|
2318
|
+
emoji: be,
|
|
2319
|
+
math: ye,
|
|
2320
|
+
table: Ee,
|
|
2321
|
+
separator: de,
|
|
2322
|
+
image: ae,
|
|
2323
|
+
video: Pe,
|
|
2324
|
+
attachment: me
|
|
2325
2325
|
};
|
|
2326
|
-
function
|
|
2327
|
-
let t =
|
|
2326
|
+
function ma({ name: e }) {
|
|
2327
|
+
let t = pa[e];
|
|
2328
2328
|
return /* @__PURE__ */ Z(t, {
|
|
2329
2329
|
"aria-hidden": "true",
|
|
2330
2330
|
absoluteStrokeWidth: !0,
|
|
@@ -2332,7 +2332,7 @@ function fa({ name: e }) {
|
|
|
2332
2332
|
strokeWidth: 1.6
|
|
2333
2333
|
});
|
|
2334
2334
|
}
|
|
2335
|
-
function
|
|
2335
|
+
function ha(e, t, n) {
|
|
2336
2336
|
return !cn(e) || !n ? {
|
|
2337
2337
|
visible: !1,
|
|
2338
2338
|
empty: !1,
|
|
@@ -2347,17 +2347,17 @@ function pa(e, t, n) {
|
|
|
2347
2347
|
activeIndex: Math.min(t.length - 1, Math.max(0, e.activeIndex))
|
|
2348
2348
|
};
|
|
2349
2349
|
}
|
|
2350
|
-
function
|
|
2350
|
+
function ga(e, t) {
|
|
2351
2351
|
return Object.values(t.slash.groups).map((t) => ({
|
|
2352
2352
|
group: t,
|
|
2353
2353
|
commands: e.filter((e) => e.group === t)
|
|
2354
2354
|
})).filter((e) => e.commands.length > 0);
|
|
2355
2355
|
}
|
|
2356
|
-
function
|
|
2356
|
+
function _a(e, t) {
|
|
2357
2357
|
return t.slash.uploadKindLabels[e] ?? t.slash.uploadKindLabels.upload;
|
|
2358
2358
|
}
|
|
2359
|
-
function
|
|
2360
|
-
let [i, a] =
|
|
2359
|
+
function va({ command: e, messages: t, onBack: n, onSelect: r }) {
|
|
2360
|
+
let [i, a] = Y(""), [o, s] = Y(0), c = q(() => {
|
|
2361
2361
|
let e = i.trim().toLowerCase();
|
|
2362
2362
|
return (e ? t.slash.emojiItems.filter((t) => [
|
|
2363
2363
|
t.emoji,
|
|
@@ -2423,9 +2423,9 @@ function ga({ command: e, messages: t, onBack: n, onSelect: r }) {
|
|
|
2423
2423
|
]
|
|
2424
2424
|
});
|
|
2425
2425
|
}
|
|
2426
|
-
function
|
|
2427
|
-
let a = e.uploadKind ?? "attachment", [o, s] =
|
|
2428
|
-
r(e, { uploadResult: await
|
|
2426
|
+
function ya({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
|
|
2427
|
+
let a = e.uploadKind ?? "attachment", [o, s] = Y(""), [c, l] = Y(null), [u, d] = Y(null), [f, p] = Y(!1), m = async (t) => {
|
|
2428
|
+
r(e, { uploadResult: await X({
|
|
2429
2429
|
kind: a,
|
|
2430
2430
|
source: t,
|
|
2431
2431
|
trigger: "slash-command"
|
|
@@ -2445,7 +2445,7 @@ function _a({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
|
|
|
2445
2445
|
d(t.slash.uploadRequiredError);
|
|
2446
2446
|
return;
|
|
2447
2447
|
}
|
|
2448
|
-
await m(
|
|
2448
|
+
await m(Ie(o));
|
|
2449
2449
|
} catch (e) {
|
|
2450
2450
|
d(e instanceof Error ? e.message : t.slash.uploadFailedError);
|
|
2451
2451
|
} finally {
|
|
@@ -2463,7 +2463,7 @@ function _a({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
|
|
|
2463
2463
|
onMouseDown: (e) => e.preventDefault(),
|
|
2464
2464
|
onClick: n,
|
|
2465
2465
|
children: t.common.back
|
|
2466
|
-
}), /* @__PURE__ */ Z("span", { children:
|
|
2466
|
+
}), /* @__PURE__ */ Z("span", { children: _a(a, t) })]
|
|
2467
2467
|
}),
|
|
2468
2468
|
/* @__PURE__ */ Q("label", {
|
|
2469
2469
|
className: "markweave-slash-upload-field",
|
|
@@ -2511,10 +2511,10 @@ function _a({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
|
|
|
2511
2511
|
]
|
|
2512
2512
|
});
|
|
2513
2513
|
}
|
|
2514
|
-
function
|
|
2515
|
-
let l =
|
|
2514
|
+
function ba({ commands: e, messages: t = fa, state: n, position: r, inputCommand: i, onActiveIndexChange: a, onInputCommandChange: o, onSelect: s, onUpload: c }) {
|
|
2515
|
+
let l = ha(n, e, r);
|
|
2516
2516
|
if (!l.visible || !r) return null;
|
|
2517
|
-
let u =
|
|
2517
|
+
let u = ga(e, t), d = {
|
|
2518
2518
|
left: r.left,
|
|
2519
2519
|
top: r.top,
|
|
2520
2520
|
maxHeight: r.maxHeight,
|
|
@@ -2536,12 +2536,12 @@ function va({ commands: e, messages: t = ua, state: n, position: r, inputCommand
|
|
|
2536
2536
|
"aria-label": t.slash.ariaLabel,
|
|
2537
2537
|
"data-placement": r.placement,
|
|
2538
2538
|
"data-testid": "markweave-slash-menu",
|
|
2539
|
-
children: i?.inputKind === "emoji" ? /* @__PURE__ */ Z(
|
|
2539
|
+
children: i?.inputKind === "emoji" ? /* @__PURE__ */ Z(va, {
|
|
2540
2540
|
command: i,
|
|
2541
2541
|
messages: t,
|
|
2542
2542
|
onBack: m,
|
|
2543
2543
|
onSelect: s
|
|
2544
|
-
}) : i?.inputKind === "upload" ? /* @__PURE__ */ Z(
|
|
2544
|
+
}) : i?.inputKind === "upload" ? /* @__PURE__ */ Z(ya, {
|
|
2545
2545
|
command: i,
|
|
2546
2546
|
messages: t,
|
|
2547
2547
|
onBack: m,
|
|
@@ -2585,7 +2585,7 @@ function va({ commands: e, messages: t = ua, state: n, position: r, inputCommand
|
|
|
2585
2585
|
}
|
|
2586
2586
|
},
|
|
2587
2587
|
children: [
|
|
2588
|
-
/* @__PURE__ */ Z(
|
|
2588
|
+
/* @__PURE__ */ Z(ma, { name: t.icon }),
|
|
2589
2589
|
/* @__PURE__ */ Z("span", { children: t.label }),
|
|
2590
2590
|
o && t.disabledReason ? /* @__PURE__ */ Z("small", { children: t.disabledReason }) : null
|
|
2591
2591
|
]
|
|
@@ -2597,7 +2597,7 @@ function va({ commands: e, messages: t = ua, state: n, position: r, inputCommand
|
|
|
2597
2597
|
}
|
|
2598
2598
|
//#endregion
|
|
2599
2599
|
//#region src/ui/table/TableControls.tsx
|
|
2600
|
-
var
|
|
2600
|
+
var xa = n("zh"), Sa = {
|
|
2601
2601
|
"move-left": v,
|
|
2602
2602
|
"move-right": y,
|
|
2603
2603
|
"move-up": b,
|
|
@@ -2608,15 +2608,15 @@ var ya = n("zh"), ba = {
|
|
|
2608
2608
|
"insert-below": S,
|
|
2609
2609
|
"sort-asc": _,
|
|
2610
2610
|
"sort-desc": x,
|
|
2611
|
-
color:
|
|
2611
|
+
color: pe,
|
|
2612
2612
|
alignment: d,
|
|
2613
|
-
clear:
|
|
2614
|
-
duplicate:
|
|
2615
|
-
copy:
|
|
2616
|
-
merge:
|
|
2617
|
-
split:
|
|
2618
|
-
delete:
|
|
2619
|
-
},
|
|
2613
|
+
clear: Se,
|
|
2614
|
+
duplicate: P,
|
|
2615
|
+
copy: P,
|
|
2616
|
+
merge: De,
|
|
2617
|
+
split: Oe,
|
|
2618
|
+
delete: Ae
|
|
2619
|
+
}, Ca = {
|
|
2620
2620
|
left: d,
|
|
2621
2621
|
center: l,
|
|
2622
2622
|
right: f,
|
|
@@ -2624,62 +2624,62 @@ var ya = n("zh"), ba = {
|
|
|
2624
2624
|
middle: p,
|
|
2625
2625
|
bottom: m
|
|
2626
2626
|
};
|
|
2627
|
-
function
|
|
2628
|
-
let [s, c] =
|
|
2629
|
-
if (
|
|
2630
|
-
if (!
|
|
2627
|
+
function wa({ active: e, editor: t, interactionState: n = xn, messages: r = xa, onCopyPayload: i, onCommandResult: a, onEditWithAi: o }) {
|
|
2628
|
+
let [s, c] = Y(null), [l, u] = Y(null), [d, f] = Y("row-edge"), [p, m] = Y(null), [h, g] = Y(null), [_, v] = Y(null), [y, b] = Y(null), [x, S] = Y(null), [C, w] = Y(null), [T, E] = Y(null), [, D] = Y(0), O = J(null), k = J(null), [A, j] = Y(null), ee = J(null), N = J(null), te = J(null), P = J(null), ne = J(null), F = J(null), I = J(null), L = e ? yn(t.state) : null;
|
|
2629
|
+
if (G(() => {
|
|
2630
|
+
if (!A) return;
|
|
2631
2631
|
let e = window.setTimeout(() => {
|
|
2632
|
-
|
|
2633
|
-
},
|
|
2632
|
+
j(null);
|
|
2633
|
+
}, Wr);
|
|
2634
2634
|
return () => {
|
|
2635
2635
|
window.clearTimeout(e);
|
|
2636
2636
|
};
|
|
2637
|
-
}, [
|
|
2637
|
+
}, [A]), G(() => {
|
|
2638
2638
|
let e = (e) => {
|
|
2639
|
-
let n =
|
|
2639
|
+
let n = O.current;
|
|
2640
2640
|
if (!n) return;
|
|
2641
|
-
let r =
|
|
2642
|
-
r !== null && (e.preventDefault(),
|
|
2641
|
+
let r = Ar(t, n.axis, e.clientX, e.clientY);
|
|
2642
|
+
r !== null && (e.preventDefault(), k.current = r, e.dataTransfer && (e.dataTransfer.dropEffect = "move"));
|
|
2643
2643
|
}, n = (e) => {
|
|
2644
|
-
let n =
|
|
2644
|
+
let n = O.current;
|
|
2645
2645
|
if (!n) return;
|
|
2646
|
-
let r =
|
|
2647
|
-
e.preventDefault(),
|
|
2646
|
+
let r = Ar(t, n.axis, e.clientX, e.clientY) ?? k.current;
|
|
2647
|
+
e.preventDefault(), O.current = null, k.current = null, r !== null && Vr(t, n.axis, n.index, r);
|
|
2648
2648
|
};
|
|
2649
2649
|
return document.addEventListener("dragover", e), document.addEventListener("drop", n), () => {
|
|
2650
2650
|
document.removeEventListener("dragover", e), document.removeEventListener("drop", n);
|
|
2651
2651
|
};
|
|
2652
|
-
}, [t]),
|
|
2652
|
+
}, [t]), K(() => {
|
|
2653
2653
|
if (!e) {
|
|
2654
|
-
|
|
2654
|
+
v(null), b(null), S(null), w(null), E(null), j(null);
|
|
2655
2655
|
return;
|
|
2656
2656
|
}
|
|
2657
2657
|
let r = () => {
|
|
2658
|
-
let e = t.view.dom.closest(".markweave-editor-frame") ?? t.view.dom.parentElement, r =
|
|
2658
|
+
let e = t.view.dom.closest(".markweave-editor-frame") ?? t.view.dom.parentElement, r = Nr(t, n, "row", L?.activeCellPos ?? null), i = Nr(t, n, "column", L?.activeCellPos ?? null), a = r ? Mr(t, r) : null, o = i ? Mr(t, i) : null, c = Rr(t, "selection").length > 0 ? zr(t) : null, l = kr(t)?.getBoundingClientRect() ?? null;
|
|
2659
2659
|
if (!e) {
|
|
2660
|
-
|
|
2660
|
+
v(null), b(null), S(null), w(null), E(null);
|
|
2661
2661
|
return;
|
|
2662
2662
|
}
|
|
2663
2663
|
let u = e.getBoundingClientRect();
|
|
2664
|
-
a ?
|
|
2664
|
+
a ? v(wr({
|
|
2665
2665
|
targetRect: a,
|
|
2666
2666
|
frameRect: u,
|
|
2667
2667
|
kind: "row"
|
|
2668
|
-
})) : s === "row" && d === "row-edge" ||
|
|
2668
|
+
})) : s === "row" && d === "row-edge" || v(null), o ? b(wr({
|
|
2669
2669
|
targetRect: o,
|
|
2670
2670
|
frameRect: u,
|
|
2671
2671
|
kind: "column"
|
|
2672
|
-
})) : s === "column" && d === "column-edge" ||
|
|
2672
|
+
})) : s === "column" && d === "column-edge" || b(null), c ? S(wr({
|
|
2673
2673
|
targetRect: c,
|
|
2674
2674
|
frameRect: u,
|
|
2675
2675
|
kind: "selection"
|
|
2676
|
-
})) : s === "selection" && d === "selection-edge" ||
|
|
2676
|
+
})) : s === "selection" && d === "selection-edge" || S(null);
|
|
2677
2677
|
let f = n.hoverCellPos !== null && !!(r && r.index === r.visualHeight - 1), p = n.hoverCellPos !== null && !!(i && i.index === i.visualWidth - 1);
|
|
2678
|
-
|
|
2678
|
+
w(l && f ? Tr({
|
|
2679
2679
|
tableRect: l,
|
|
2680
2680
|
frameRect: u,
|
|
2681
2681
|
kind: "row"
|
|
2682
|
-
}) : null),
|
|
2682
|
+
}) : null), E(l && p ? Tr({
|
|
2683
2683
|
tableRect: l,
|
|
2684
2684
|
frameRect: u,
|
|
2685
2685
|
kind: "column"
|
|
@@ -2691,40 +2691,41 @@ function Sa({ active: e, editor: t, interactionState: n = xn, messages: r = ya,
|
|
|
2691
2691
|
}, [
|
|
2692
2692
|
e,
|
|
2693
2693
|
t,
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2694
|
+
L?.activeCellPos,
|
|
2695
|
+
L?.selectionFrom,
|
|
2696
|
+
L?.selectionTo,
|
|
2697
2697
|
n.hoverCellPos,
|
|
2698
2698
|
n.hoverVisualColumnIndex,
|
|
2699
2699
|
n.hoverVisualRowIndex,
|
|
2700
2700
|
d,
|
|
2701
2701
|
s
|
|
2702
|
-
]),
|
|
2702
|
+
]), K(() => {
|
|
2703
2703
|
if (!e || !s) {
|
|
2704
2704
|
m(null);
|
|
2705
2705
|
return;
|
|
2706
2706
|
}
|
|
2707
2707
|
let n = () => {
|
|
2708
|
-
let e = t.view.dom.closest(".markweave-editor-frame") ?? t.view.dom.parentElement, n = d === "row-edge" ?
|
|
2708
|
+
let e = t.view.dom.closest(".markweave-editor-frame") ?? t.view.dom.parentElement, n = d === "row-edge" ? ne.current : d === "column-edge" ? F.current : I.current, r = N.current;
|
|
2709
2709
|
if (!e || !n || !r) {
|
|
2710
2710
|
m(null);
|
|
2711
2711
|
return;
|
|
2712
2712
|
}
|
|
2713
|
-
let i = n.getBoundingClientRect(), a = s === "row" ?
|
|
2713
|
+
let i = n.getBoundingClientRect(), a = s === "row" ? kr(t)?.getBoundingClientRect() : null, o = a ? {
|
|
2714
2714
|
left: i.left,
|
|
2715
2715
|
top: a.top,
|
|
2716
2716
|
width: i.width,
|
|
2717
2717
|
height: i.height
|
|
2718
|
-
} : i, c = e.getBoundingClientRect(), l = r.getBoundingClientRect(), u = Sr({
|
|
2718
|
+
} : i, c = e.getBoundingClientRect(), l = r.getBoundingClientRect(), u = te.current?.scrollHeight ?? 0, f = u > 0 ? u + 12 : 0, p = Sr({
|
|
2719
2719
|
anchorRect: o,
|
|
2720
2720
|
frameRect: c,
|
|
2721
|
+
boundaryRect: Fr(e),
|
|
2721
2722
|
menuSize: {
|
|
2722
2723
|
width: l.width || 254,
|
|
2723
|
-
height: l.height || 410
|
|
2724
|
+
height: f || l.height || 410
|
|
2724
2725
|
},
|
|
2725
2726
|
kind: s
|
|
2726
2727
|
});
|
|
2727
|
-
m(
|
|
2728
|
+
m(p);
|
|
2728
2729
|
};
|
|
2729
2730
|
return n(), window.addEventListener("resize", n), window.addEventListener("scroll", n, !0), () => {
|
|
2730
2731
|
window.removeEventListener("resize", n), window.removeEventListener("scroll", n, !0);
|
|
@@ -2734,10 +2735,43 @@ function Sa({ active: e, editor: t, interactionState: n = xn, messages: r = ya,
|
|
|
2734
2735
|
t,
|
|
2735
2736
|
d,
|
|
2736
2737
|
s,
|
|
2737
|
-
h,
|
|
2738
2738
|
_,
|
|
2739
|
-
y
|
|
2740
|
-
|
|
2739
|
+
y,
|
|
2740
|
+
x
|
|
2741
|
+
]), K(() => {
|
|
2742
|
+
if (!e || !s || !l || !p) {
|
|
2743
|
+
g(null);
|
|
2744
|
+
return;
|
|
2745
|
+
}
|
|
2746
|
+
let n = () => {
|
|
2747
|
+
let e = t.view.dom.closest(".markweave-editor-frame") ?? t.view.dom.parentElement, n = N.current, r = P.current, i = n?.querySelector(`[data-submenu-trigger="${l}"]`);
|
|
2748
|
+
if (!e || !n || !r || !i) {
|
|
2749
|
+
g(null);
|
|
2750
|
+
return;
|
|
2751
|
+
}
|
|
2752
|
+
let a = r.getBoundingClientRect(), o = Math.max(r.scrollHeight + 2, a.height);
|
|
2753
|
+
g(Cr({
|
|
2754
|
+
triggerRect: i.getBoundingClientRect(),
|
|
2755
|
+
parentMenuRect: n.getBoundingClientRect(),
|
|
2756
|
+
boundaryRect: Fr(e),
|
|
2757
|
+
submenuSize: {
|
|
2758
|
+
width: a.width || 238,
|
|
2759
|
+
height: o || 410
|
|
2760
|
+
}
|
|
2761
|
+
}));
|
|
2762
|
+
};
|
|
2763
|
+
n();
|
|
2764
|
+
let r = te.current;
|
|
2765
|
+
return r?.addEventListener("scroll", n), window.addEventListener("resize", n), window.addEventListener("scroll", n, !0), () => {
|
|
2766
|
+
r?.removeEventListener("scroll", n), window.removeEventListener("resize", n), window.removeEventListener("scroll", n, !0);
|
|
2767
|
+
};
|
|
2768
|
+
}, [
|
|
2769
|
+
e,
|
|
2770
|
+
t,
|
|
2771
|
+
p,
|
|
2772
|
+
s,
|
|
2773
|
+
l
|
|
2774
|
+
]), G(() => {
|
|
2741
2775
|
if (!e || !s) return;
|
|
2742
2776
|
let n = (e) => {
|
|
2743
2777
|
if (e.key === "Escape") {
|
|
@@ -2748,7 +2782,7 @@ function Sa({ active: e, editor: t, interactionState: n = xn, messages: r = ya,
|
|
|
2748
2782
|
c(null), u(null), t.view.focus();
|
|
2749
2783
|
}
|
|
2750
2784
|
}, r = (e) => {
|
|
2751
|
-
e.target instanceof Node &&
|
|
2785
|
+
e.target instanceof Node && ee.current?.contains(e.target) || (c(null), u(null));
|
|
2752
2786
|
};
|
|
2753
2787
|
return document.addEventListener("keydown", n), document.addEventListener("mousedown", r), () => {
|
|
2754
2788
|
document.removeEventListener("keydown", n), document.removeEventListener("mousedown", r);
|
|
@@ -2759,171 +2793,171 @@ function Sa({ active: e, editor: t, interactionState: n = xn, messages: r = ya,
|
|
|
2759
2793
|
s,
|
|
2760
2794
|
l
|
|
2761
2795
|
]), !e) return null;
|
|
2762
|
-
let
|
|
2796
|
+
let re = (e, t) => {
|
|
2763
2797
|
let n = s === e && d === t;
|
|
2764
2798
|
f(t), c(n ? null : e), u(null);
|
|
2765
|
-
},
|
|
2799
|
+
}, R = () => {
|
|
2766
2800
|
t.view.dispatch(vr(t.state.tr, null));
|
|
2767
|
-
},
|
|
2768
|
-
let i = n.hoverCellPos ??
|
|
2769
|
-
i !== null &&
|
|
2770
|
-
},
|
|
2771
|
-
|
|
2772
|
-
},
|
|
2773
|
-
let o = await
|
|
2801
|
+
}, ie = (e, r) => {
|
|
2802
|
+
let i = n.hoverCellPos ?? L?.activeCellPos ?? null, a = n.hoverCellPos === null ? null : e === "row" ? n.hoverVisualRowIndex : n.hoverVisualColumnIndex;
|
|
2803
|
+
i !== null && Hr(t, i, e, { visualIndex: a }), re(e, r);
|
|
2804
|
+
}, ae = () => {
|
|
2805
|
+
R(), re("selection", "selection-edge");
|
|
2806
|
+
}, z = Nr(t, n, "row", L?.activeCellPos ?? null), B = Nr(t, n, "column", L?.activeCellPos ?? null), oe = Rr(t, "selection").length > 0, se = s ? Rr(t, s) : [], ce = async (e, n) => {
|
|
2807
|
+
let o = await Dr({
|
|
2774
2808
|
editor: t,
|
|
2775
2809
|
commandId: e,
|
|
2776
2810
|
menu: n ?? s ?? "selection",
|
|
2777
2811
|
messages: r
|
|
2778
2812
|
});
|
|
2779
|
-
return o.copyFeedback ? (
|
|
2780
|
-
},
|
|
2781
|
-
let n =
|
|
2813
|
+
return o.copyFeedback ? (j(o.copyFeedback), o.copyPayload && i?.(o.copyPayload)) : j(null), a?.(o.commandResult), o.success;
|
|
2814
|
+
}, le = (e) => {
|
|
2815
|
+
let n = Pr(t, e);
|
|
2782
2816
|
n && o?.(n), c(null), u(null), t.view.focus();
|
|
2783
|
-
},
|
|
2784
|
-
s !== "row" && s !== "column" || e(s) &&
|
|
2785
|
-
},
|
|
2786
|
-
let r = e === "row" ?
|
|
2787
|
-
!r || i === null ||
|
|
2788
|
-
},
|
|
2789
|
-
|
|
2817
|
+
}, V = (e) => {
|
|
2818
|
+
s !== "row" && s !== "column" || e(s) && D((e) => e + 1);
|
|
2819
|
+
}, ue = (e) => {
|
|
2820
|
+
let r = e === "row" ? z : B, i = n.hoverCellPos ?? L?.activeCellPos ?? null;
|
|
2821
|
+
!r || i === null || Jr(t, i, e, { visualIndex: r.index }) && ce(e === "row" ? "add-row-after" : "add-column-after", e);
|
|
2822
|
+
}, H = (e, t, n) => {
|
|
2823
|
+
O.current = {
|
|
2790
2824
|
axis: e,
|
|
2791
2825
|
index: t
|
|
2792
|
-
},
|
|
2793
|
-
},
|
|
2794
|
-
let t = e.currentTarget, n = Array.from(
|
|
2826
|
+
}, k.current = t, n.dataTransfer.effectAllowed = "move", n.dataTransfer.setData("application/x-markweave-table-axis", `${e}:${t}`);
|
|
2827
|
+
}, U = (e) => {
|
|
2828
|
+
let t = e.currentTarget, n = t.classList.contains("markweave-table-menu") ? t.querySelector(":scope > .markweave-table-menu-scroll") ?? t : t, r = Array.from(n.querySelectorAll(":scope > button[role=\"menuitem\"]:not(:disabled), :scope > button[role=\"menuitemradio\"]:not(:disabled)")), i = r.indexOf(document.activeElement);
|
|
2795
2829
|
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
2796
2830
|
e.preventDefault(), e.stopPropagation();
|
|
2797
2831
|
let t = e.key === "ArrowDown" ? 1 : -1;
|
|
2798
|
-
|
|
2832
|
+
r[i < 0 ? 0 : Math.min(r.length - 1, Math.max(0, i + t))]?.focus();
|
|
2799
2833
|
}
|
|
2800
|
-
},
|
|
2834
|
+
}, de = s === "row" || s === "column" ? jr(t, s) : null;
|
|
2801
2835
|
return /* @__PURE__ */ Q("div", {
|
|
2802
|
-
ref:
|
|
2836
|
+
ref: ee,
|
|
2803
2837
|
className: "markweave-table-controls",
|
|
2804
2838
|
"data-testid": "markweave-table-controls",
|
|
2805
2839
|
"aria-label": r.table.controlsAriaLabel,
|
|
2806
2840
|
"data-open-menu": s ?? "none",
|
|
2807
|
-
"data-positioned":
|
|
2841
|
+
"data-positioned": _ || y || x ? "true" : "false",
|
|
2808
2842
|
onMouseLeave: () => {
|
|
2809
2843
|
t.view.dispatch(t.state.tr.setMeta(Sn, { type: "clear-hover" }));
|
|
2810
2844
|
},
|
|
2811
2845
|
children: [
|
|
2812
|
-
|
|
2846
|
+
A ? /* @__PURE__ */ Z("div", {
|
|
2813
2847
|
className: "markweave-table-copy-feedback",
|
|
2814
2848
|
role: "status",
|
|
2815
2849
|
"aria-live": "polite",
|
|
2816
2850
|
"data-testid": "markweave-table-copy-feedback",
|
|
2817
|
-
"data-copy-kind":
|
|
2818
|
-
"data-text-length":
|
|
2819
|
-
"data-html-length":
|
|
2820
|
-
children:
|
|
2851
|
+
"data-copy-kind": A.kind,
|
|
2852
|
+
"data-text-length": A.textLength,
|
|
2853
|
+
"data-html-length": A.htmlLength,
|
|
2854
|
+
children: Or(A)
|
|
2821
2855
|
}) : null,
|
|
2822
|
-
|
|
2856
|
+
_ ? /* @__PURE__ */ Z("button", {
|
|
2823
2857
|
type: "button",
|
|
2824
|
-
ref:
|
|
2858
|
+
ref: ne,
|
|
2825
2859
|
className: "markweave-table-edge-handle markweave-table-edge-handle--row",
|
|
2826
2860
|
"aria-label": r.table.activeRowActions,
|
|
2827
2861
|
"aria-expanded": s === "row" && d === "row-edge",
|
|
2828
2862
|
"aria-haspopup": "menu",
|
|
2829
2863
|
title: r.table.rowActions,
|
|
2830
2864
|
"data-testid": "markweave-table-hover-row-handle",
|
|
2831
|
-
"data-axis-index":
|
|
2832
|
-
"data-axis-selected-cells":
|
|
2833
|
-
"data-axis-visual-cells":
|
|
2834
|
-
"data-axis-visual-size":
|
|
2865
|
+
"data-axis-index": z?.index ?? "",
|
|
2866
|
+
"data-axis-selected-cells": z?.selectedCellCount ?? "",
|
|
2867
|
+
"data-axis-visual-cells": z?.visualCellCount ?? "",
|
|
2868
|
+
"data-axis-visual-size": z?.visualHeight ?? "",
|
|
2835
2869
|
style: {
|
|
2836
|
-
left:
|
|
2837
|
-
top:
|
|
2838
|
-
width:
|
|
2839
|
-
height:
|
|
2870
|
+
left: _.left,
|
|
2871
|
+
top: _.top,
|
|
2872
|
+
width: _.width,
|
|
2873
|
+
height: _.height
|
|
2840
2874
|
},
|
|
2841
2875
|
draggable: !0,
|
|
2842
|
-
onDragStart: (e) =>
|
|
2876
|
+
onDragStart: (e) => H("row", z?.index ?? 0, e),
|
|
2843
2877
|
onDragEnd: () => {
|
|
2844
|
-
|
|
2878
|
+
O.current = null, k.current = null;
|
|
2845
2879
|
},
|
|
2846
2880
|
onClick: () => {
|
|
2847
|
-
|
|
2881
|
+
ie("row", "row-edge");
|
|
2848
2882
|
},
|
|
2849
|
-
children: /* @__PURE__ */ Z(
|
|
2883
|
+
children: /* @__PURE__ */ Z(fe, {
|
|
2850
2884
|
"aria-hidden": "true",
|
|
2851
2885
|
size: 14
|
|
2852
2886
|
})
|
|
2853
2887
|
}) : null,
|
|
2854
|
-
|
|
2888
|
+
y ? /* @__PURE__ */ Z("button", {
|
|
2855
2889
|
type: "button",
|
|
2856
|
-
ref:
|
|
2890
|
+
ref: F,
|
|
2857
2891
|
className: "markweave-table-edge-handle markweave-table-edge-handle--column",
|
|
2858
2892
|
"aria-label": r.table.activeColumnActions,
|
|
2859
2893
|
"aria-expanded": s === "column" && d === "column-edge",
|
|
2860
2894
|
"aria-haspopup": "menu",
|
|
2861
2895
|
title: r.table.columnActions,
|
|
2862
2896
|
"data-testid": "markweave-table-hover-column-handle",
|
|
2863
|
-
"data-axis-index":
|
|
2864
|
-
"data-axis-selected-cells":
|
|
2865
|
-
"data-axis-visual-cells":
|
|
2866
|
-
"data-axis-visual-size":
|
|
2897
|
+
"data-axis-index": B?.index ?? "",
|
|
2898
|
+
"data-axis-selected-cells": B?.selectedCellCount ?? "",
|
|
2899
|
+
"data-axis-visual-cells": B?.visualCellCount ?? "",
|
|
2900
|
+
"data-axis-visual-size": B?.visualWidth ?? "",
|
|
2867
2901
|
style: {
|
|
2868
|
-
left:
|
|
2869
|
-
top:
|
|
2870
|
-
width:
|
|
2871
|
-
height:
|
|
2902
|
+
left: y.left,
|
|
2903
|
+
top: y.top,
|
|
2904
|
+
width: y.width,
|
|
2905
|
+
height: y.height
|
|
2872
2906
|
},
|
|
2873
2907
|
draggable: !0,
|
|
2874
|
-
onDragStart: (e) =>
|
|
2908
|
+
onDragStart: (e) => H("column", B?.index ?? 0, e),
|
|
2875
2909
|
onDragEnd: () => {
|
|
2876
|
-
|
|
2910
|
+
O.current = null, k.current = null;
|
|
2877
2911
|
},
|
|
2878
2912
|
onClick: () => {
|
|
2879
|
-
|
|
2913
|
+
ie("column", "column-edge");
|
|
2880
2914
|
},
|
|
2881
|
-
children: /* @__PURE__ */ Z(
|
|
2915
|
+
children: /* @__PURE__ */ Z(fe, {
|
|
2882
2916
|
"aria-hidden": "true",
|
|
2883
2917
|
size: 14
|
|
2884
2918
|
})
|
|
2885
2919
|
}) : null,
|
|
2886
|
-
|
|
2920
|
+
C ? /* @__PURE__ */ Z("button", {
|
|
2887
2921
|
type: "button",
|
|
2888
2922
|
className: "markweave-table-extend-button markweave-table-extend-button--row",
|
|
2889
2923
|
"aria-label": r.table.addRow,
|
|
2890
2924
|
title: r.table.addRow,
|
|
2891
2925
|
"data-testid": "markweave-table-add-row",
|
|
2892
2926
|
style: {
|
|
2893
|
-
left:
|
|
2894
|
-
top:
|
|
2895
|
-
width:
|
|
2896
|
-
height:
|
|
2927
|
+
left: C.left,
|
|
2928
|
+
top: C.top,
|
|
2929
|
+
width: C.width,
|
|
2930
|
+
height: C.height
|
|
2897
2931
|
},
|
|
2898
2932
|
onMouseDown: (e) => e.preventDefault(),
|
|
2899
|
-
onClick: () =>
|
|
2900
|
-
children: /* @__PURE__ */ Z(
|
|
2933
|
+
onClick: () => ue("row"),
|
|
2934
|
+
children: /* @__PURE__ */ Z(ge, {
|
|
2901
2935
|
"aria-hidden": "true",
|
|
2902
2936
|
size: 16
|
|
2903
2937
|
})
|
|
2904
2938
|
}) : null,
|
|
2905
|
-
|
|
2939
|
+
T ? /* @__PURE__ */ Z("button", {
|
|
2906
2940
|
type: "button",
|
|
2907
2941
|
className: "markweave-table-extend-button markweave-table-extend-button--column",
|
|
2908
2942
|
"aria-label": r.table.addColumn,
|
|
2909
2943
|
title: r.table.addColumn,
|
|
2910
2944
|
"data-testid": "markweave-table-add-column",
|
|
2911
2945
|
style: {
|
|
2912
|
-
left:
|
|
2913
|
-
top:
|
|
2914
|
-
width:
|
|
2915
|
-
height:
|
|
2946
|
+
left: T.left,
|
|
2947
|
+
top: T.top,
|
|
2948
|
+
width: T.width,
|
|
2949
|
+
height: T.height
|
|
2916
2950
|
},
|
|
2917
2951
|
onMouseDown: (e) => e.preventDefault(),
|
|
2918
|
-
onClick: () =>
|
|
2919
|
-
children: /* @__PURE__ */ Z(
|
|
2952
|
+
onClick: () => ue("column"),
|
|
2953
|
+
children: /* @__PURE__ */ Z(ge, {
|
|
2920
2954
|
"aria-hidden": "true",
|
|
2921
2955
|
size: 16
|
|
2922
2956
|
})
|
|
2923
2957
|
}) : null,
|
|
2924
|
-
|
|
2958
|
+
oe && x ? /* @__PURE__ */ Z("button", {
|
|
2925
2959
|
type: "button",
|
|
2926
|
-
ref:
|
|
2960
|
+
ref: I,
|
|
2927
2961
|
className: "markweave-table-edge-handle markweave-table-edge-handle--selection",
|
|
2928
2962
|
"aria-label": r.table.selectionActions,
|
|
2929
2963
|
"aria-expanded": s === "selection" && d === "selection-edge",
|
|
@@ -2931,104 +2965,118 @@ function Sa({ active: e, editor: t, interactionState: n = xn, messages: r = ya,
|
|
|
2931
2965
|
title: r.table.selectionActions,
|
|
2932
2966
|
"data-testid": "markweave-table-cell-handle",
|
|
2933
2967
|
style: {
|
|
2934
|
-
left:
|
|
2935
|
-
top:
|
|
2936
|
-
width:
|
|
2937
|
-
height:
|
|
2968
|
+
left: x.left,
|
|
2969
|
+
top: x.top,
|
|
2970
|
+
width: x.width,
|
|
2971
|
+
height: x.height
|
|
2938
2972
|
},
|
|
2939
2973
|
onMouseDown: (e) => e.preventDefault(),
|
|
2940
|
-
onClick:
|
|
2941
|
-
children: /* @__PURE__ */ Z(
|
|
2974
|
+
onClick: ae,
|
|
2975
|
+
children: /* @__PURE__ */ Z(fe, {
|
|
2942
2976
|
"aria-hidden": "true",
|
|
2943
2977
|
size: 14
|
|
2944
2978
|
})
|
|
2945
2979
|
}) : null,
|
|
2946
2980
|
s ? /* @__PURE__ */ Q("div", {
|
|
2947
|
-
ref:
|
|
2981
|
+
ref: N,
|
|
2948
2982
|
className: "markweave-table-menu",
|
|
2949
2983
|
role: "menu",
|
|
2950
|
-
"aria-label":
|
|
2984
|
+
"aria-label": Kr(s, r),
|
|
2951
2985
|
"data-testid": "markweave-table-menu",
|
|
2952
2986
|
"data-positioned": p ? "true" : "false",
|
|
2987
|
+
"data-placement": p?.placement,
|
|
2953
2988
|
"data-submenu": l ?? "none",
|
|
2954
2989
|
style: p ? {
|
|
2955
2990
|
left: p.left,
|
|
2956
2991
|
top: p.top
|
|
2957
2992
|
} : void 0,
|
|
2958
|
-
onKeyDown:
|
|
2993
|
+
onKeyDown: U,
|
|
2959
2994
|
children: [
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
"
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2995
|
+
/* @__PURE__ */ Z("div", {
|
|
2996
|
+
ref: te,
|
|
2997
|
+
className: "markweave-table-menu-scroll",
|
|
2998
|
+
style: p ? { maxHeight: Math.max(1, p.maxHeight - 12) } : void 0,
|
|
2999
|
+
children: se.map((e, n) => {
|
|
3000
|
+
let i = Ir(e), a = n === 0 ? i : Ir(se[n - 1]), d = n > 0 && a !== i, f = e.submenuId ? !0 : e.commandId === null ? !!o : Er(t, e.commandId), p = Lr(e, r), m = Sa[e.icon];
|
|
3001
|
+
return /* @__PURE__ */ Q("button", {
|
|
3002
|
+
type: "button",
|
|
3003
|
+
role: "menuitem",
|
|
3004
|
+
"aria-label": p,
|
|
3005
|
+
"aria-disabled": !f,
|
|
3006
|
+
"aria-haspopup": e.submenuId ? "menu" : void 0,
|
|
3007
|
+
"aria-expanded": e.submenuId ? l === e.submenuId : void 0,
|
|
3008
|
+
disabled: !f,
|
|
3009
|
+
"data-menu-group": i,
|
|
3010
|
+
"data-starts-group": d ? "true" : "false",
|
|
3011
|
+
"data-command-enabled": f ? "true" : "false",
|
|
3012
|
+
"data-submenu-trigger": e.submenuId ?? void 0,
|
|
3013
|
+
"data-testid": e.commandId ? `markweave-table-menu-command-${e.commandId}` : e.submenuId ? `markweave-table-menu-submenu-${e.submenuId}` : "markweave-table-menu-command-edit-with-ai",
|
|
3014
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
3015
|
+
onMouseEnter: () => u(e.submenuId),
|
|
3016
|
+
onClick: () => {
|
|
3017
|
+
if (f) {
|
|
3018
|
+
if (e.submenuId) {
|
|
3019
|
+
u(e.submenuId);
|
|
3020
|
+
return;
|
|
3021
|
+
}
|
|
3022
|
+
if (e.commandId === null) {
|
|
3023
|
+
le(s === "row" || s === "column" ? s : "selection");
|
|
3024
|
+
return;
|
|
3025
|
+
}
|
|
3026
|
+
ce(e.commandId).finally(() => {
|
|
3027
|
+
c(null), u(null);
|
|
3028
|
+
});
|
|
2986
3029
|
}
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
}) : null
|
|
3010
|
-
]
|
|
3011
|
-
}, `${e.id}-${n}`);
|
|
3030
|
+
},
|
|
3031
|
+
children: [
|
|
3032
|
+
/* @__PURE__ */ Z("span", {
|
|
3033
|
+
className: "markweave-table-menu-item-icon",
|
|
3034
|
+
"aria-hidden": "true",
|
|
3035
|
+
children: /* @__PURE__ */ Z(m, {
|
|
3036
|
+
size: 18,
|
|
3037
|
+
strokeWidth: 1.8
|
|
3038
|
+
})
|
|
3039
|
+
}),
|
|
3040
|
+
/* @__PURE__ */ Z("span", {
|
|
3041
|
+
className: "markweave-table-menu-item-label",
|
|
3042
|
+
children: p
|
|
3043
|
+
}),
|
|
3044
|
+
e.submenuId ? /* @__PURE__ */ Z(M, {
|
|
3045
|
+
className: "markweave-table-menu-chevron",
|
|
3046
|
+
"aria-hidden": "true",
|
|
3047
|
+
size: 16
|
|
3048
|
+
}) : null
|
|
3049
|
+
]
|
|
3050
|
+
}, `${e.id}-${n}`);
|
|
3051
|
+
})
|
|
3012
3052
|
}),
|
|
3013
3053
|
l === "color" && (s === "row" || s === "column") ? /* @__PURE__ */ Q("div", {
|
|
3054
|
+
ref: P,
|
|
3014
3055
|
className: "markweave-table-submenu markweave-table-color-menu",
|
|
3015
3056
|
role: "menu",
|
|
3016
3057
|
"aria-label": r.table.submenus.color,
|
|
3017
3058
|
"data-testid": "markweave-table-color-menu",
|
|
3018
|
-
|
|
3059
|
+
"data-positioned": h ? "true" : "false",
|
|
3060
|
+
"data-placement": h?.placement,
|
|
3061
|
+
style: h ? {
|
|
3062
|
+
left: h.left,
|
|
3063
|
+
top: h.top,
|
|
3064
|
+
maxHeight: h.maxHeight
|
|
3065
|
+
} : void 0,
|
|
3066
|
+
onKeyDown: U,
|
|
3019
3067
|
children: [
|
|
3020
3068
|
/* @__PURE__ */ Z("div", {
|
|
3021
3069
|
className: "markweave-table-submenu-title",
|
|
3022
3070
|
children: r.table.submenus.textColor
|
|
3023
3071
|
}),
|
|
3024
|
-
|
|
3072
|
+
Ur.map((e) => /* @__PURE__ */ Q("button", {
|
|
3025
3073
|
type: "button",
|
|
3026
3074
|
role: "menuitemradio",
|
|
3027
|
-
"aria-checked":
|
|
3028
|
-
"data-active":
|
|
3075
|
+
"aria-checked": de?.textColorId === e.id,
|
|
3076
|
+
"data-active": de?.textColorId === e.id ? "true" : "false",
|
|
3029
3077
|
"data-testid": `markweave-table-text-color-${e.id}`,
|
|
3030
3078
|
onMouseDown: (e) => e.preventDefault(),
|
|
3031
|
-
onClick: () =>
|
|
3079
|
+
onClick: () => V((n) => xr(t, n, e.id)),
|
|
3032
3080
|
children: [/* @__PURE__ */ Z("span", {
|
|
3033
3081
|
className: "markweave-table-color-swatch markweave-table-text-color-swatch",
|
|
3034
3082
|
"aria-hidden": "true",
|
|
@@ -3040,14 +3088,14 @@ function Sa({ active: e, editor: t, interactionState: n = xn, messages: r = ya,
|
|
|
3040
3088
|
className: "markweave-table-submenu-title",
|
|
3041
3089
|
children: r.table.submenus.backgroundColor
|
|
3042
3090
|
}),
|
|
3043
|
-
|
|
3091
|
+
Ur.map((e) => /* @__PURE__ */ Q("button", {
|
|
3044
3092
|
type: "button",
|
|
3045
3093
|
role: "menuitemradio",
|
|
3046
|
-
"aria-checked":
|
|
3047
|
-
"data-active":
|
|
3094
|
+
"aria-checked": de?.backgroundColorId === e.id,
|
|
3095
|
+
"data-active": de?.backgroundColorId === e.id ? "true" : "false",
|
|
3048
3096
|
"data-testid": `markweave-table-background-color-${e.id}`,
|
|
3049
3097
|
onMouseDown: (e) => e.preventDefault(),
|
|
3050
|
-
onClick: () =>
|
|
3098
|
+
onClick: () => V((n) => br(t, n, e.id)),
|
|
3051
3099
|
children: [/* @__PURE__ */ Z("span", {
|
|
3052
3100
|
className: "markweave-table-color-swatch",
|
|
3053
3101
|
"aria-hidden": "true",
|
|
@@ -3057,14 +3105,22 @@ function Sa({ active: e, editor: t, interactionState: n = xn, messages: r = ya,
|
|
|
3057
3105
|
]
|
|
3058
3106
|
}) : null,
|
|
3059
3107
|
l === "alignment" && (s === "row" || s === "column") ? /* @__PURE__ */ Q("div", {
|
|
3108
|
+
ref: P,
|
|
3060
3109
|
className: "markweave-table-submenu markweave-table-alignment-menu",
|
|
3061
3110
|
role: "menu",
|
|
3062
3111
|
"aria-label": r.table.submenus.alignment,
|
|
3063
3112
|
"data-testid": "markweave-table-alignment-menu",
|
|
3064
|
-
|
|
3113
|
+
"data-positioned": h ? "true" : "false",
|
|
3114
|
+
"data-placement": h?.placement,
|
|
3115
|
+
style: h ? {
|
|
3116
|
+
left: h.left,
|
|
3117
|
+
top: h.top,
|
|
3118
|
+
maxHeight: h.maxHeight
|
|
3119
|
+
} : void 0,
|
|
3120
|
+
onKeyDown: U,
|
|
3065
3121
|
children: [
|
|
3066
|
-
|
|
3067
|
-
let n =
|
|
3122
|
+
Gr.map((e) => {
|
|
3123
|
+
let n = Ca[e], i = de?.textAlign === e;
|
|
3068
3124
|
return /* @__PURE__ */ Q("button", {
|
|
3069
3125
|
type: "button",
|
|
3070
3126
|
role: "menuitemradio",
|
|
@@ -3072,7 +3128,7 @@ function Sa({ active: e, editor: t, interactionState: n = xn, messages: r = ya,
|
|
|
3072
3128
|
"data-active": i ? "true" : "false",
|
|
3073
3129
|
"data-testid": `markweave-table-alignment-${e}`,
|
|
3074
3130
|
onMouseDown: (e) => e.preventDefault(),
|
|
3075
|
-
onClick: () =>
|
|
3131
|
+
onClick: () => V((n) => yr(t, n, e)),
|
|
3076
3132
|
children: [/* @__PURE__ */ Z(n, {
|
|
3077
3133
|
"aria-hidden": "true",
|
|
3078
3134
|
size: 18,
|
|
@@ -3081,8 +3137,8 @@ function Sa({ active: e, editor: t, interactionState: n = xn, messages: r = ya,
|
|
|
3081
3137
|
}, e);
|
|
3082
3138
|
}),
|
|
3083
3139
|
/* @__PURE__ */ Z("div", { className: "markweave-table-submenu-separator" }),
|
|
3084
|
-
|
|
3085
|
-
let n =
|
|
3140
|
+
qr.map((e) => {
|
|
3141
|
+
let n = Ca[e], i = de?.verticalAlign === e;
|
|
3086
3142
|
return /* @__PURE__ */ Q("button", {
|
|
3087
3143
|
type: "button",
|
|
3088
3144
|
role: "menuitemradio",
|
|
@@ -3090,7 +3146,7 @@ function Sa({ active: e, editor: t, interactionState: n = xn, messages: r = ya,
|
|
|
3090
3146
|
"data-active": i ? "true" : "false",
|
|
3091
3147
|
"data-testid": `markweave-table-alignment-${e}`,
|
|
3092
3148
|
onMouseDown: (e) => e.preventDefault(),
|
|
3093
|
-
onClick: () =>
|
|
3149
|
+
onClick: () => V((n) => yr(t, n, e)),
|
|
3094
3150
|
children: [/* @__PURE__ */ Z(n, {
|
|
3095
3151
|
"aria-hidden": "true",
|
|
3096
3152
|
size: 18,
|
|
@@ -3107,15 +3163,15 @@ function Sa({ active: e, editor: t, interactionState: n = xn, messages: r = ya,
|
|
|
3107
3163
|
}
|
|
3108
3164
|
//#endregion
|
|
3109
3165
|
//#region src/ui/table/TableSelectionOverlay.tsx
|
|
3110
|
-
function
|
|
3111
|
-
let [n, r] =
|
|
3112
|
-
return
|
|
3166
|
+
function Ta({ editor: e, focusState: t }) {
|
|
3167
|
+
let [n, r] = Y(null);
|
|
3168
|
+
return K(() => {
|
|
3113
3169
|
if (t.mode !== "cell-selection") {
|
|
3114
3170
|
r(null);
|
|
3115
3171
|
return;
|
|
3116
3172
|
}
|
|
3117
3173
|
let n = () => {
|
|
3118
|
-
r(
|
|
3174
|
+
r(Br(e, bn(e.state)));
|
|
3119
3175
|
};
|
|
3120
3176
|
return n(), window.addEventListener("resize", n), window.addEventListener("scroll", n, !0), () => {
|
|
3121
3177
|
window.removeEventListener("resize", n), window.removeEventListener("scroll", n, !0);
|
|
@@ -3131,6 +3187,7 @@ function Ca({ editor: e, focusState: t }) {
|
|
|
3131
3187
|
]), n ? /* @__PURE__ */ Z("div", {
|
|
3132
3188
|
"aria-hidden": "true",
|
|
3133
3189
|
className: "markweave-table-selection-overlay",
|
|
3190
|
+
"data-axis-target": n.axisTarget ?? "none",
|
|
3134
3191
|
"data-anchor-cell-pos": n.anchorCellPos ?? "",
|
|
3135
3192
|
"data-head-cell-pos": n.headCellPos ?? "",
|
|
3136
3193
|
"data-selected-cells": n.selectedCellCount,
|
|
@@ -3150,16 +3207,16 @@ function Ca({ editor: e, focusState: t }) {
|
|
|
3150
3207
|
}
|
|
3151
3208
|
//#endregion
|
|
3152
3209
|
//#region src/ui/toc/MarkweaveInnerToc.tsx
|
|
3153
|
-
function
|
|
3210
|
+
function Ea(e, t) {
|
|
3154
3211
|
return `${e.toc.itemAriaLabel}: ${t.text}`;
|
|
3155
3212
|
}
|
|
3156
|
-
function
|
|
3157
|
-
let a =
|
|
3158
|
-
if (
|
|
3159
|
-
if (!(i !== "container" || !a.current)) return
|
|
3213
|
+
function Da({ editor: e, state: t, messages: n, editable: r, placement: i }) {
|
|
3214
|
+
let a = J(null);
|
|
3215
|
+
if (G(() => {
|
|
3216
|
+
if (!(i !== "container" || !a.current)) return ti(a.current);
|
|
3160
3217
|
}, [i]), !t.items.length) return null;
|
|
3161
3218
|
let o = (t) => {
|
|
3162
|
-
|
|
3219
|
+
ni(e, t, {
|
|
3163
3220
|
behavior: "smooth",
|
|
3164
3221
|
focus: r
|
|
3165
3222
|
});
|
|
@@ -3186,7 +3243,7 @@ function Ta({ editor: e, state: t, messages: n, editable: r, placement: i }) {
|
|
|
3186
3243
|
"data-level": e.level,
|
|
3187
3244
|
"data-active": e.active ? "true" : "false",
|
|
3188
3245
|
"aria-current": e.active ? "location" : void 0,
|
|
3189
|
-
"aria-label":
|
|
3246
|
+
"aria-label": Ea(n, e),
|
|
3190
3247
|
title: e.text,
|
|
3191
3248
|
onClick: () => o(e),
|
|
3192
3249
|
children: e.text
|
|
@@ -3197,7 +3254,7 @@ function Ta({ editor: e, state: t, messages: n, editable: r, placement: i }) {
|
|
|
3197
3254
|
}
|
|
3198
3255
|
//#endregion
|
|
3199
3256
|
//#region src/MarkweaveEditor.tsx
|
|
3200
|
-
var
|
|
3257
|
+
var Oa = {
|
|
3201
3258
|
active: !1,
|
|
3202
3259
|
mode: "outside",
|
|
3203
3260
|
activeCellPos: null,
|
|
@@ -3205,21 +3262,21 @@ var Ea = {
|
|
|
3205
3262
|
selectedCellCount: 0,
|
|
3206
3263
|
selectionFrom: 0,
|
|
3207
3264
|
selectionTo: 0
|
|
3208
|
-
},
|
|
3265
|
+
}, ka = {
|
|
3209
3266
|
active: !1,
|
|
3210
3267
|
language: Lt.defaultLanguage,
|
|
3211
3268
|
mermaidPreviewMode: "code",
|
|
3212
3269
|
pos: null,
|
|
3213
3270
|
text: ""
|
|
3214
|
-
},
|
|
3271
|
+
}, Aa = Gt({
|
|
3215
3272
|
active: !1,
|
|
3216
3273
|
mode: "code",
|
|
3217
3274
|
source: ""
|
|
3218
3275
|
});
|
|
3219
|
-
function
|
|
3276
|
+
function ja(e) {
|
|
3220
3277
|
return Sn.getState(e.state) ?? xn;
|
|
3221
3278
|
}
|
|
3222
|
-
function
|
|
3279
|
+
function Ma(e) {
|
|
3223
3280
|
if (!e || typeof window > "u") return null;
|
|
3224
3281
|
let t = e.parentElement;
|
|
3225
3282
|
for (; t;) {
|
|
@@ -3229,106 +3286,106 @@ function Aa(e) {
|
|
|
3229
3286
|
}
|
|
3230
3287
|
return null;
|
|
3231
3288
|
}
|
|
3232
|
-
function
|
|
3289
|
+
function Na(e) {
|
|
3233
3290
|
return typeof window > "u" || typeof window.requestAnimationFrame != "function" ? globalThis.setTimeout(() => e(0), 0) : window.requestAnimationFrame(e);
|
|
3234
3291
|
}
|
|
3235
|
-
function
|
|
3292
|
+
function Pa(e) {
|
|
3236
3293
|
if (typeof window < "u" && typeof window.cancelAnimationFrame == "function") {
|
|
3237
3294
|
window.cancelAnimationFrame(e);
|
|
3238
3295
|
return;
|
|
3239
3296
|
}
|
|
3240
3297
|
globalThis.clearTimeout(e);
|
|
3241
3298
|
}
|
|
3242
|
-
function
|
|
3243
|
-
let A = et(h), j =
|
|
3299
|
+
function Fa({ ariaLabel: e, autoFocusFirstTableBodyCell: i = !1, autofocus: a = !1, content: o, contentFormat: c, defaultContent: l = "", defaultContentFormat: u, editable: d = !0, innerToc: f = !0, innerTocPlacement: p, lang: m, mode: h = "live", theme: g, canvasColor: _, onEditWithAi: v, onExtractToNote: y, onRewriteSelection: b, onRuntimeStateChange: x, onSearchControllerChange: S, onSlashCommandUpload: C, onTableCommandResult: w, onTableCopyPayload: T, onTocChange: E, onUpdate: D, linkCardResolver: O, resolveMediaSource: k } = {}) {
|
|
3300
|
+
let A = et(h), j = ii(g), M = ri(_), ee = ei(p), N = A === "live" && d !== !1, te = yt(o === void 0 ? u : c), P = o ?? l, ne = typeof P == "string" && P.length >= 2e5, F = o === void 0 && te === "markdown" && ne && typeof P == "string", I = J(F ? P : null), [L, re] = Y(F), R = J({
|
|
3244
3301
|
editorMode: A,
|
|
3245
|
-
effectiveEditable:
|
|
3302
|
+
effectiveEditable: N
|
|
3246
3303
|
});
|
|
3247
3304
|
R.current = {
|
|
3248
3305
|
editorMode: A,
|
|
3249
|
-
effectiveEditable:
|
|
3306
|
+
effectiveEditable: N
|
|
3250
3307
|
};
|
|
3251
|
-
let ie =
|
|
3308
|
+
let ie = J(null);
|
|
3252
3309
|
ie.current === null && (ie.current = r(m));
|
|
3253
|
-
let
|
|
3310
|
+
let ae = ie.current, z = q(() => n(ae), [ae]), B = q(() => t(ae), [ae]), oe = J(C);
|
|
3254
3311
|
oe.current = C;
|
|
3255
|
-
let se =
|
|
3312
|
+
let se = J(S);
|
|
3256
3313
|
se.current = S;
|
|
3257
|
-
let ce =
|
|
3314
|
+
let ce = J(O);
|
|
3258
3315
|
ce.current = O;
|
|
3259
|
-
let le =
|
|
3260
|
-
lang:
|
|
3316
|
+
let le = q(() => ki({
|
|
3317
|
+
lang: ae,
|
|
3261
3318
|
onImageUpload: (e) => {
|
|
3262
3319
|
if (oe.current) return oe.current(e);
|
|
3263
|
-
let t =
|
|
3320
|
+
let t = Le(e);
|
|
3264
3321
|
if (!t) throw Error("File upload requires an upload handler.");
|
|
3265
3322
|
return t;
|
|
3266
3323
|
},
|
|
3267
3324
|
onVideoUpload: (e) => {
|
|
3268
3325
|
if (oe.current) return oe.current(e);
|
|
3269
|
-
let t =
|
|
3326
|
+
let t = Le(e);
|
|
3270
3327
|
if (!t) throw Error("File upload requires an upload handler.");
|
|
3271
3328
|
return t;
|
|
3272
3329
|
},
|
|
3273
3330
|
linkCardResolver: (e) => ce.current?.(e) ?? Promise.resolve(null),
|
|
3274
3331
|
resolveMediaSource: k
|
|
3275
|
-
}), [k,
|
|
3332
|
+
}), [k, ae]), [V, ue] = Y(null), [H, U] = Y(hn), [de, fe] = Y(null), [pe, me] = Y(null), [he, ge] = Y("code"), [_e, ve] = Y(null), [ye, be] = Y(xn), [xe, Se] = Y(null), [Ce, we] = Y(0), Te = J(!1), Ee = J({
|
|
3276
3333
|
content: o,
|
|
3277
|
-
format:
|
|
3278
|
-
}),
|
|
3279
|
-
|
|
3334
|
+
format: te
|
|
3335
|
+
}), De = J(null), Oe = J(null), ke = J({ onUpdate: D }), Ae = q(() => an(H.query, B), [B, H.query]);
|
|
3336
|
+
ke.current = { onUpdate: D }, Ee.current = {
|
|
3280
3337
|
content: o,
|
|
3281
|
-
format:
|
|
3338
|
+
format: te
|
|
3282
3339
|
};
|
|
3283
|
-
let
|
|
3284
|
-
|
|
3285
|
-
}, []),
|
|
3286
|
-
|
|
3287
|
-
|
|
3340
|
+
let je = W(() => {
|
|
3341
|
+
Oe.current !== null && (window.clearTimeout(Oe.current), Oe.current = null), we((e) => e + 1);
|
|
3342
|
+
}, []), Me = W(() => {
|
|
3343
|
+
Oe.current !== null && window.clearTimeout(Oe.current), Oe.current = window.setTimeout(() => {
|
|
3344
|
+
Oe.current = null, we((e) => e + 1);
|
|
3288
3345
|
}, At);
|
|
3289
3346
|
}, []);
|
|
3290
|
-
|
|
3291
|
-
|
|
3347
|
+
G(() => () => {
|
|
3348
|
+
Oe.current !== null && window.clearTimeout(Oe.current);
|
|
3292
3349
|
}, []);
|
|
3293
|
-
let
|
|
3294
|
-
|
|
3295
|
-
}, []),
|
|
3350
|
+
let Ne = W(() => {
|
|
3351
|
+
fe(null), me(null), U(hn);
|
|
3352
|
+
}, []), Pe = W((e) => {
|
|
3296
3353
|
let t = pn(e.state);
|
|
3297
3354
|
if (!t) {
|
|
3298
|
-
|
|
3355
|
+
U((e) => e.name === "idle" ? e : hn), fe(null), me(null);
|
|
3299
3356
|
return;
|
|
3300
3357
|
}
|
|
3301
3358
|
let n = e.coordsAtPos(t.cursor), r = e.coordsAtPos(t.triggerFrom), i = e.dom.closest(".markweave-editor-frame")?.getBoundingClientRect();
|
|
3302
3359
|
if (!mn(r, { frameRect: i })) {
|
|
3303
|
-
|
|
3360
|
+
fe(null), me(null), U(hn);
|
|
3304
3361
|
return;
|
|
3305
3362
|
}
|
|
3306
3363
|
let a = fn(n, {
|
|
3307
3364
|
frameRect: i,
|
|
3308
3365
|
triggerRect: r
|
|
3309
3366
|
});
|
|
3310
|
-
|
|
3311
|
-
}, []),
|
|
3367
|
+
fe((e) => ln(e, a) ? e : a), U((e) => dn(e, t));
|
|
3368
|
+
}, []), K = W((e) => Pe(e.view), [Pe]), Fe = W((e) => {
|
|
3312
3369
|
let t = Dt(e);
|
|
3313
3370
|
ue((e) => Ct(e, t) ? e : t);
|
|
3314
3371
|
let n = $t(e);
|
|
3315
|
-
n && (tn(e, n, !0),
|
|
3372
|
+
n && (tn(e, n, !0), ve(n));
|
|
3316
3373
|
let r = Ft(e);
|
|
3317
|
-
r.active && r.language === "mermaid" &&
|
|
3318
|
-
}, []),
|
|
3319
|
-
|
|
3320
|
-
}, []),
|
|
3374
|
+
r.active && r.language === "mermaid" && ge(r.mermaidPreviewMode);
|
|
3375
|
+
}, []), Ie = W((e) => {
|
|
3376
|
+
be(ja(e));
|
|
3377
|
+
}, []), X = s({
|
|
3321
3378
|
shouldRerenderOnTransaction: !1,
|
|
3322
3379
|
extensions: le,
|
|
3323
|
-
content:
|
|
3324
|
-
contentType: gt(
|
|
3325
|
-
editable:
|
|
3380
|
+
content: F ? "" : P,
|
|
3381
|
+
contentType: gt(te),
|
|
3382
|
+
editable: N,
|
|
3326
3383
|
autofocus: a,
|
|
3327
3384
|
editorProps: {
|
|
3328
3385
|
attributes: {
|
|
3329
3386
|
class: "markweave-editor-surface",
|
|
3330
3387
|
"data-testid": "markweave-editor-surface",
|
|
3331
|
-
"data-markweave-large-document":
|
|
3388
|
+
"data-markweave-large-document": ne ? "true" : "false",
|
|
3332
3389
|
autocapitalize: "off",
|
|
3333
3390
|
autocorrect: "off",
|
|
3334
3391
|
spellcheck: "false",
|
|
@@ -3336,34 +3393,34 @@ function Na({ ariaLabel: e, autoFocusFirstTableBodyCell: i = !1, autofocus: a =
|
|
|
3336
3393
|
},
|
|
3337
3394
|
handleClick: (e, t, n) => R.current.effectiveEditable ? !1 : bt(n),
|
|
3338
3395
|
handleDOMEvents: {
|
|
3339
|
-
compositionstart: () => R.current.effectiveEditable ? (
|
|
3340
|
-
compositionend: (e) => (R.current.effectiveEditable && window.setTimeout(() =>
|
|
3396
|
+
compositionstart: () => R.current.effectiveEditable ? (U((e) => gn(e, { type: "composition-start" })), fe(null), !1) : !1,
|
|
3397
|
+
compositionend: (e) => (R.current.effectiveEditable && window.setTimeout(() => Pe(e), 0), !1),
|
|
3341
3398
|
click: (e, t) => {
|
|
3342
3399
|
if (R.current.effectiveEditable) {
|
|
3343
3400
|
let n = Qt(e, t);
|
|
3344
|
-
return n ? (t.preventDefault(), t.stopPropagation(),
|
|
3401
|
+
return n ? (t.preventDefault(), t.stopPropagation(), Ne(), nn(e, n, !0), rn(e, n), ve(n), !0) : (ve(null), !1);
|
|
3345
3402
|
}
|
|
3346
3403
|
return bt(t);
|
|
3347
3404
|
}
|
|
3348
3405
|
}
|
|
3349
3406
|
},
|
|
3350
3407
|
onSelectionUpdate: ({ editor: e }) => {
|
|
3351
|
-
|
|
3408
|
+
Fe(e);
|
|
3352
3409
|
},
|
|
3353
3410
|
onCreate: ({ editor: e }) => {
|
|
3354
|
-
i && R.current.effectiveEditable && vn(e),
|
|
3411
|
+
i && R.current.effectiveEditable && vn(e), Ie(e), Fe(e), je();
|
|
3355
3412
|
},
|
|
3356
3413
|
onTransaction: ({ editor: e, transaction: t }) => {
|
|
3357
|
-
|
|
3414
|
+
Ie(e), (t.docChanged || Vt(t)) && Me(), t.docChanged && ve((t) => {
|
|
3358
3415
|
if (!t) return null;
|
|
3359
3416
|
let n = Zt(e, t.pos);
|
|
3360
3417
|
return n?.kind === t.kind ? n : null;
|
|
3361
3418
|
});
|
|
3362
3419
|
},
|
|
3363
3420
|
onUpdate: ({ editor: e }) => {
|
|
3364
|
-
|
|
3365
|
-
let r =
|
|
3366
|
-
r.content !== void 0 && t === r.format && (
|
|
3421
|
+
Fe(e), R.current.effectiveEditable && K(e), Te.current || ke.current.onUpdate?.(ht(e, { onContentRead: (t, n) => {
|
|
3422
|
+
let r = Ee.current;
|
|
3423
|
+
r.content !== void 0 && t === r.format && (De.current = {
|
|
3367
3424
|
content: n,
|
|
3368
3425
|
format: t,
|
|
3369
3426
|
doc: e.state.doc
|
|
@@ -3371,375 +3428,375 @@ function Na({ ariaLabel: e, autoFocusFirstTableBodyCell: i = !1, autofocus: a =
|
|
|
3371
3428
|
} }));
|
|
3372
3429
|
}
|
|
3373
3430
|
});
|
|
3374
|
-
|
|
3375
|
-
let e =
|
|
3376
|
-
if (!
|
|
3431
|
+
G(() => {
|
|
3432
|
+
let e = I.current;
|
|
3433
|
+
if (!X || !e) return;
|
|
3377
3434
|
let t = !1;
|
|
3378
3435
|
return (async () => {
|
|
3379
|
-
|
|
3436
|
+
Te.current = !0;
|
|
3380
3437
|
try {
|
|
3381
3438
|
let n = !0;
|
|
3382
|
-
for (let r of
|
|
3439
|
+
for (let r of ai(e)) {
|
|
3383
3440
|
if (await new Promise((e) => window.setTimeout(e, 0)), t) return;
|
|
3384
|
-
let e =
|
|
3441
|
+
let e = X.markdown?.parse(r);
|
|
3385
3442
|
if (!e) throw Error("Markdown parser is unavailable.");
|
|
3386
|
-
let i =
|
|
3387
|
-
|
|
3443
|
+
let i = X.schema.nodeFromJSON(e).content, a = n ? X.state.tr.replaceWith(0, X.state.doc.content.size, i) : X.state.tr.insert(X.state.doc.content.size, i);
|
|
3444
|
+
X.view.dispatch(a.setMeta("addToHistory", !1)), n = !1;
|
|
3388
3445
|
}
|
|
3389
3446
|
if (t) return;
|
|
3390
|
-
|
|
3447
|
+
Fe(X), Ie(X), je(), I.current = null, re(!1);
|
|
3391
3448
|
} finally {
|
|
3392
|
-
|
|
3449
|
+
Te.current = !1;
|
|
3393
3450
|
}
|
|
3394
3451
|
})().catch(() => {
|
|
3395
|
-
t || (
|
|
3452
|
+
t || (X.commands.setContent(e, {
|
|
3396
3453
|
contentType: "markdown",
|
|
3397
3454
|
emitUpdate: !1
|
|
3398
|
-
}),
|
|
3455
|
+
}), I.current = null, re(!1));
|
|
3399
3456
|
}), () => {
|
|
3400
3457
|
t = !0;
|
|
3401
3458
|
};
|
|
3402
3459
|
}, [
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
]),
|
|
3408
|
-
if (
|
|
3460
|
+
X,
|
|
3461
|
+
je,
|
|
3462
|
+
Fe,
|
|
3463
|
+
Ie
|
|
3464
|
+
]), G(() => {
|
|
3465
|
+
if (X) return se.current?.(oi(X)), () => {
|
|
3409
3466
|
se.current?.(null);
|
|
3410
3467
|
};
|
|
3411
|
-
}, [
|
|
3412
|
-
if (!
|
|
3413
|
-
let e =
|
|
3414
|
-
|
|
3468
|
+
}, [X]), G(() => {
|
|
3469
|
+
if (!X) return;
|
|
3470
|
+
let e = N && !L;
|
|
3471
|
+
X.setEditable(e), tt(X, {
|
|
3415
3472
|
mode: A,
|
|
3416
3473
|
editable: e
|
|
3417
|
-
}), Ut(
|
|
3474
|
+
}), Ut(X, e ? "live" : "view"), je(), N || Ne();
|
|
3418
3475
|
}, [
|
|
3419
|
-
|
|
3420
|
-
|
|
3476
|
+
Ne,
|
|
3477
|
+
X,
|
|
3421
3478
|
A,
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
]),
|
|
3426
|
-
|
|
3427
|
-
}, [
|
|
3479
|
+
N,
|
|
3480
|
+
je,
|
|
3481
|
+
L
|
|
3482
|
+
]), G(() => {
|
|
3483
|
+
X && Ht(X, j);
|
|
3484
|
+
}, [X, j]), G(() => {
|
|
3428
3485
|
let e = yt(c);
|
|
3429
|
-
if (!(!
|
|
3430
|
-
if (vt(
|
|
3431
|
-
|
|
3486
|
+
if (!(!X || o === void 0)) {
|
|
3487
|
+
if (vt(X, De.current, o, e)) {
|
|
3488
|
+
De.current = null;
|
|
3432
3489
|
return;
|
|
3433
3490
|
}
|
|
3434
|
-
|
|
3491
|
+
De.current = null, !_t(X, o, e) && (Te.current = !0, X.commands.setContent(o, {
|
|
3435
3492
|
contentType: gt(e),
|
|
3436
3493
|
emitUpdate: !1
|
|
3437
|
-
}),
|
|
3494
|
+
}), Te.current = !1, Fe(X), N && K(X), Ie(X), je());
|
|
3438
3495
|
}
|
|
3439
3496
|
}, [
|
|
3440
3497
|
o,
|
|
3441
3498
|
c,
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
]),
|
|
3449
|
-
if (!
|
|
3499
|
+
N,
|
|
3500
|
+
X,
|
|
3501
|
+
je,
|
|
3502
|
+
Fe,
|
|
3503
|
+
K,
|
|
3504
|
+
Ie
|
|
3505
|
+
]), G(() => {
|
|
3506
|
+
if (!de) return;
|
|
3450
3507
|
let e = (e) => {
|
|
3451
3508
|
let t = e.target;
|
|
3452
|
-
t instanceof Element && (t.closest(".markweave-slash-menu") || t.closest(".markweave-slash-trigger") ||
|
|
3509
|
+
t instanceof Element && (t.closest(".markweave-slash-menu") || t.closest(".markweave-slash-trigger") || Ne());
|
|
3453
3510
|
};
|
|
3454
3511
|
return document.addEventListener("pointerdown", e, !0), () => document.removeEventListener("pointerdown", e, !0);
|
|
3455
|
-
}, [
|
|
3456
|
-
let
|
|
3457
|
-
|
|
3458
|
-
if (!
|
|
3512
|
+
}, [Ne, de]);
|
|
3513
|
+
let Re = de !== null;
|
|
3514
|
+
G(() => {
|
|
3515
|
+
if (!X || !Re) return;
|
|
3459
3516
|
let e = mt(() => {
|
|
3460
|
-
|
|
3517
|
+
X.isDestroyed || Pe(X.view);
|
|
3461
3518
|
}), t = () => e.schedule();
|
|
3462
3519
|
return window.addEventListener("resize", t), window.addEventListener("scroll", t, !0), t(), () => {
|
|
3463
3520
|
e.cancel(), window.removeEventListener("resize", t), window.removeEventListener("scroll", t, !0);
|
|
3464
3521
|
};
|
|
3465
3522
|
}, [
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3523
|
+
X,
|
|
3524
|
+
Re,
|
|
3525
|
+
Pe
|
|
3469
3526
|
]);
|
|
3470
|
-
let
|
|
3471
|
-
|
|
3472
|
-
|
|
3527
|
+
let ze = q(() => X ? Ft(X) : ka, [
|
|
3528
|
+
X,
|
|
3529
|
+
Ce,
|
|
3473
3530
|
V
|
|
3474
|
-
]),
|
|
3475
|
-
|
|
3476
|
-
|
|
3531
|
+
]), Be = q(() => X ? yn(X.state) : Oa, [
|
|
3532
|
+
X,
|
|
3533
|
+
Ce,
|
|
3477
3534
|
V,
|
|
3478
|
-
|
|
3479
|
-
]),
|
|
3480
|
-
active:
|
|
3481
|
-
mode:
|
|
3482
|
-
source:
|
|
3483
|
-
}) :
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
]),
|
|
3489
|
-
|
|
3535
|
+
ye
|
|
3536
|
+
]), Ve = V?.currentNode === "codeBlock", He = Ve && ze.language === "mermaid", Ue = q(() => X ? Gt({
|
|
3537
|
+
active: He,
|
|
3538
|
+
mode: he,
|
|
3539
|
+
source: ze.text
|
|
3540
|
+
}) : Aa, [
|
|
3541
|
+
ze.text,
|
|
3542
|
+
X,
|
|
3543
|
+
He,
|
|
3544
|
+
he
|
|
3545
|
+
]), We = q(() => X && x ? _n(X.state) : null, [
|
|
3546
|
+
X,
|
|
3490
3547
|
x,
|
|
3491
|
-
|
|
3492
|
-
]),
|
|
3493
|
-
if (!
|
|
3494
|
-
|
|
3548
|
+
Ce
|
|
3549
|
+
]), Ge = q(() => X ? Qr(X.state) : Xr.items, [X, Ce]), Ke = q(() => $r(Ge, xe), [xe, Ge]), qe = q(() => Yr(Ge, Ke), [Ke, Ge]), Je = W(() => {
|
|
3550
|
+
if (!X || !Ge.length) {
|
|
3551
|
+
Se(null);
|
|
3495
3552
|
return;
|
|
3496
3553
|
}
|
|
3497
|
-
let e =
|
|
3498
|
-
|
|
3499
|
-
}, [
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
let t =
|
|
3554
|
+
let e = Zr(X, Ge);
|
|
3555
|
+
Se((t) => t === e ? t : e);
|
|
3556
|
+
}, [X, Ge]);
|
|
3557
|
+
G(() => {
|
|
3558
|
+
Se((e) => {
|
|
3559
|
+
let t = $r(Ge, e);
|
|
3503
3560
|
return e === t ? e : t;
|
|
3504
3561
|
});
|
|
3505
|
-
}, [
|
|
3506
|
-
if (!
|
|
3562
|
+
}, [Ge]), G(() => {
|
|
3563
|
+
if (!X || !Ge.length || typeof window > "u") return;
|
|
3507
3564
|
let e = null, t = () => {
|
|
3508
|
-
e !== null &&
|
|
3509
|
-
e = null,
|
|
3565
|
+
e !== null && Pa(e), e = Na(() => {
|
|
3566
|
+
e = null, Je();
|
|
3510
3567
|
});
|
|
3511
|
-
}, n =
|
|
3568
|
+
}, n = Ma(X.view.dom);
|
|
3512
3569
|
return window.addEventListener("scroll", t, { passive: !0 }), window.addEventListener("resize", t), n?.addEventListener("scroll", t, { passive: !0 }), t(), () => {
|
|
3513
|
-
window.removeEventListener("scroll", t), window.removeEventListener("resize", t), n?.removeEventListener("scroll", t), e !== null &&
|
|
3570
|
+
window.removeEventListener("scroll", t), window.removeEventListener("resize", t), n?.removeEventListener("scroll", t), e !== null && Pa(e);
|
|
3514
3571
|
};
|
|
3515
3572
|
}, [
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3573
|
+
X,
|
|
3574
|
+
Ge.length,
|
|
3575
|
+
Je
|
|
3519
3576
|
]);
|
|
3520
|
-
let
|
|
3521
|
-
revision:
|
|
3577
|
+
let Ye = q(() => xt({
|
|
3578
|
+
revision: Ce,
|
|
3522
3579
|
mode: A,
|
|
3523
|
-
editable:
|
|
3524
|
-
toc:
|
|
3580
|
+
editable: N,
|
|
3581
|
+
toc: qe,
|
|
3525
3582
|
selection: V,
|
|
3526
|
-
slash:
|
|
3527
|
-
table:
|
|
3528
|
-
tableInteraction:
|
|
3529
|
-
codeBlock:
|
|
3530
|
-
mermaid:
|
|
3531
|
-
tableDebugSnapshot:
|
|
3583
|
+
slash: H,
|
|
3584
|
+
table: Be,
|
|
3585
|
+
tableInteraction: ye,
|
|
3586
|
+
codeBlock: ze,
|
|
3587
|
+
mermaid: Ue,
|
|
3588
|
+
tableDebugSnapshot: We
|
|
3532
3589
|
}), [
|
|
3533
|
-
|
|
3590
|
+
ze,
|
|
3534
3591
|
A,
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3592
|
+
N,
|
|
3593
|
+
Ue,
|
|
3594
|
+
Ce,
|
|
3538
3595
|
V,
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3596
|
+
H,
|
|
3597
|
+
We,
|
|
3598
|
+
Be,
|
|
3599
|
+
ye,
|
|
3600
|
+
qe
|
|
3544
3601
|
]);
|
|
3545
|
-
|
|
3546
|
-
x?.(
|
|
3547
|
-
}, [x,
|
|
3548
|
-
E?.(
|
|
3549
|
-
}, [E,
|
|
3550
|
-
let
|
|
3551
|
-
if (!(!
|
|
3602
|
+
G(() => {
|
|
3603
|
+
x?.(Ye);
|
|
3604
|
+
}, [x, Ye]), G(() => {
|
|
3605
|
+
E?.(qe);
|
|
3606
|
+
}, [E, qe]);
|
|
3607
|
+
let Xe = W((e, t) => {
|
|
3608
|
+
if (!(!X || !N) && on(e)) {
|
|
3552
3609
|
if (e.inputKind && !t?.emoji && !t?.uploadResult) {
|
|
3553
|
-
|
|
3610
|
+
me(e);
|
|
3554
3611
|
return;
|
|
3555
3612
|
}
|
|
3556
|
-
un(
|
|
3613
|
+
un(X, H, e, t), U((e) => gn(e, { type: "execute" })), Ne();
|
|
3557
3614
|
}
|
|
3558
3615
|
}, [
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
]),
|
|
3564
|
-
|
|
3616
|
+
Ne,
|
|
3617
|
+
N,
|
|
3618
|
+
X,
|
|
3619
|
+
H
|
|
3620
|
+
]), Ze = W((e) => {
|
|
3621
|
+
U((t) => gn(t, {
|
|
3565
3622
|
type: "set-active",
|
|
3566
3623
|
index: e,
|
|
3567
|
-
optionCount:
|
|
3624
|
+
optionCount: Ae.length
|
|
3568
3625
|
}));
|
|
3569
|
-
}, [
|
|
3570
|
-
if (!
|
|
3571
|
-
let t = sn(
|
|
3626
|
+
}, [Ae.length]), Qe = W((e) => {
|
|
3627
|
+
if (!X || pe || !N) return;
|
|
3628
|
+
let t = sn(H, Ae, e.key, { isComposing: e.nativeEvent.isComposing || pt(X.state) });
|
|
3572
3629
|
if (t.type !== "ignore") {
|
|
3573
3630
|
if (t.type === "close") {
|
|
3574
|
-
e.preventDefault(),
|
|
3631
|
+
e.preventDefault(), U((e) => gn(e, { type: "escape" })), Ne();
|
|
3575
3632
|
return;
|
|
3576
3633
|
}
|
|
3577
3634
|
if (t.type === "move-active") {
|
|
3578
|
-
e.preventDefault(),
|
|
3635
|
+
e.preventDefault(), U((e) => gn(e, {
|
|
3579
3636
|
type: "move-active",
|
|
3580
3637
|
delta: t.delta,
|
|
3581
3638
|
optionCount: t.optionCount
|
|
3582
3639
|
}));
|
|
3583
3640
|
return;
|
|
3584
3641
|
}
|
|
3585
|
-
t.type === "execute-active" && (e.preventDefault(),
|
|
3642
|
+
t.type === "execute-active" && (e.preventDefault(), Xe(t.command));
|
|
3586
3643
|
}
|
|
3587
3644
|
}, [
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
]), $e =
|
|
3596
|
-
closeSlashMenu:
|
|
3597
|
-
focusFirstTableBodyCell: () =>
|
|
3645
|
+
Ne,
|
|
3646
|
+
N,
|
|
3647
|
+
X,
|
|
3648
|
+
Ae,
|
|
3649
|
+
Xe,
|
|
3650
|
+
pe,
|
|
3651
|
+
H
|
|
3652
|
+
]), $e = q(() => ({
|
|
3653
|
+
closeSlashMenu: Ne,
|
|
3654
|
+
focusFirstTableBodyCell: () => X ? vn(X) : !1,
|
|
3598
3655
|
setContent: (e, t = {}) => {
|
|
3599
|
-
if (!
|
|
3656
|
+
if (!X) return !1;
|
|
3600
3657
|
let n = yt(t.format);
|
|
3601
|
-
return
|
|
3658
|
+
return X.commands.setContent(e, {
|
|
3602
3659
|
contentType: gt(n),
|
|
3603
3660
|
emitUpdate: t.emitUpdate ?? !1
|
|
3604
|
-
}), t.focusFirstTableBodyCell && vn(
|
|
3661
|
+
}), t.focusFirstTableBodyCell && vn(X), Fe(X), N && K(X), Ie(X), je(), !0;
|
|
3605
3662
|
}
|
|
3606
3663
|
}), [
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3664
|
+
Ne,
|
|
3665
|
+
N,
|
|
3666
|
+
X,
|
|
3667
|
+
je,
|
|
3668
|
+
Fe,
|
|
3669
|
+
K,
|
|
3670
|
+
Ie
|
|
3614
3671
|
]);
|
|
3615
3672
|
return {
|
|
3616
|
-
editor:
|
|
3617
|
-
frameProps:
|
|
3673
|
+
editor: X,
|
|
3674
|
+
frameProps: q(() => ({
|
|
3618
3675
|
className: "markweave-editor-frame",
|
|
3619
|
-
"aria-label": e ??
|
|
3676
|
+
"aria-label": e ?? z.common.editorAriaLabel,
|
|
3620
3677
|
"data-testid": "markweave-editor-frame",
|
|
3621
3678
|
"data-markweave-mode": A,
|
|
3622
|
-
"aria-busy":
|
|
3623
|
-
"data-markweave-large-document-loading":
|
|
3679
|
+
"aria-busy": L,
|
|
3680
|
+
"data-markweave-large-document-loading": L ? "true" : "false",
|
|
3624
3681
|
"data-markweave-theme": j,
|
|
3625
3682
|
style: M ? { "--markweave-canvas": M } : void 0,
|
|
3626
3683
|
"data-markweave-inner-toc": f ? "true" : "false",
|
|
3627
|
-
"data-markweave-inner-toc-placement":
|
|
3628
|
-
"data-mermaid-mode":
|
|
3629
|
-
"data-table-focus-mode":
|
|
3684
|
+
"data-markweave-inner-toc-placement": ee,
|
|
3685
|
+
"data-mermaid-mode": Ue.mode,
|
|
3686
|
+
"data-table-focus-mode": Be.mode,
|
|
3630
3687
|
onKeyDownCapture: Qe
|
|
3631
3688
|
}), [
|
|
3632
3689
|
e,
|
|
3633
3690
|
A,
|
|
3634
3691
|
Qe,
|
|
3635
3692
|
f,
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3693
|
+
L,
|
|
3694
|
+
Ue.mode,
|
|
3695
|
+
z.common.editorAriaLabel,
|
|
3639
3696
|
M,
|
|
3640
|
-
|
|
3697
|
+
ee,
|
|
3641
3698
|
j,
|
|
3642
|
-
|
|
3699
|
+
Be.mode
|
|
3643
3700
|
]),
|
|
3644
|
-
overlayProps:
|
|
3645
|
-
floatingToolbar:
|
|
3646
|
-
editor:
|
|
3647
|
-
messages:
|
|
3701
|
+
overlayProps: q(() => ({
|
|
3702
|
+
floatingToolbar: X && N ? {
|
|
3703
|
+
editor: X,
|
|
3704
|
+
messages: z,
|
|
3648
3705
|
selectionSnapshot: V,
|
|
3649
3706
|
onRewriteSelection: b,
|
|
3650
3707
|
onExtractToNote: y
|
|
3651
3708
|
} : null,
|
|
3652
|
-
slashCommandMenu:
|
|
3653
|
-
commands:
|
|
3654
|
-
state:
|
|
3655
|
-
position:
|
|
3656
|
-
inputCommand:
|
|
3657
|
-
messages:
|
|
3658
|
-
onActiveIndexChange:
|
|
3659
|
-
onInputCommandChange:
|
|
3660
|
-
onSelect:
|
|
3709
|
+
slashCommandMenu: X && N ? {
|
|
3710
|
+
commands: Ae,
|
|
3711
|
+
state: H,
|
|
3712
|
+
position: de,
|
|
3713
|
+
inputCommand: pe,
|
|
3714
|
+
messages: z,
|
|
3715
|
+
onActiveIndexChange: Ze,
|
|
3716
|
+
onInputCommandChange: me,
|
|
3717
|
+
onSelect: Xe,
|
|
3661
3718
|
onUpload: C
|
|
3662
3719
|
} : null,
|
|
3663
|
-
tableControls:
|
|
3664
|
-
editor:
|
|
3665
|
-
active:
|
|
3666
|
-
interactionState:
|
|
3667
|
-
messages:
|
|
3720
|
+
tableControls: X && N ? {
|
|
3721
|
+
editor: X,
|
|
3722
|
+
active: Be.active,
|
|
3723
|
+
interactionState: ye,
|
|
3724
|
+
messages: z,
|
|
3668
3725
|
onCopyPayload: T,
|
|
3669
3726
|
onCommandResult: w,
|
|
3670
3727
|
onEditWithAi: v
|
|
3671
3728
|
} : null,
|
|
3672
|
-
tableSelectionOverlay:
|
|
3673
|
-
editor:
|
|
3674
|
-
focusState:
|
|
3729
|
+
tableSelectionOverlay: X && N ? {
|
|
3730
|
+
editor: X,
|
|
3731
|
+
focusState: Be
|
|
3675
3732
|
} : null,
|
|
3676
|
-
codeBlockControls:
|
|
3677
|
-
editor:
|
|
3678
|
-
active:
|
|
3679
|
-
mermaidMode:
|
|
3680
|
-
onMermaidModeChange:
|
|
3681
|
-
readOnly: !
|
|
3733
|
+
codeBlockControls: X ? {
|
|
3734
|
+
editor: X,
|
|
3735
|
+
active: N && Ve,
|
|
3736
|
+
mermaidMode: he,
|
|
3737
|
+
onMermaidModeChange: ge,
|
|
3738
|
+
readOnly: !N
|
|
3682
3739
|
} : null,
|
|
3683
|
-
innerToc:
|
|
3684
|
-
editor:
|
|
3685
|
-
editable:
|
|
3686
|
-
messages:
|
|
3687
|
-
placement:
|
|
3688
|
-
state:
|
|
3740
|
+
innerToc: X && f && qe.items.length ? {
|
|
3741
|
+
editor: X,
|
|
3742
|
+
editable: N,
|
|
3743
|
+
messages: z,
|
|
3744
|
+
placement: ee,
|
|
3745
|
+
state: qe
|
|
3689
3746
|
} : null,
|
|
3690
|
-
mathEditorPopover:
|
|
3691
|
-
editor:
|
|
3692
|
-
messages:
|
|
3693
|
-
target:
|
|
3694
|
-
onClose: () =>
|
|
3747
|
+
mathEditorPopover: X && N && _e ? {
|
|
3748
|
+
editor: X,
|
|
3749
|
+
messages: z,
|
|
3750
|
+
target: _e,
|
|
3751
|
+
onClose: () => ve(null)
|
|
3695
3752
|
} : null
|
|
3696
3753
|
}), [
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3754
|
+
N,
|
|
3755
|
+
X,
|
|
3756
|
+
Ae,
|
|
3700
3757
|
f,
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3758
|
+
Ve,
|
|
3759
|
+
he,
|
|
3760
|
+
z,
|
|
3761
|
+
_e,
|
|
3705
3762
|
v,
|
|
3706
3763
|
y,
|
|
3707
3764
|
b,
|
|
3708
3765
|
C,
|
|
3709
3766
|
w,
|
|
3710
3767
|
T,
|
|
3711
|
-
|
|
3768
|
+
Xe,
|
|
3712
3769
|
V,
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
fe,
|
|
3770
|
+
Ze,
|
|
3771
|
+
pe,
|
|
3716
3772
|
de,
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3773
|
+
H,
|
|
3774
|
+
Be,
|
|
3775
|
+
ye,
|
|
3776
|
+
qe
|
|
3720
3777
|
]),
|
|
3721
|
-
runtimeSnapshot:
|
|
3778
|
+
runtimeSnapshot: Ye,
|
|
3722
3779
|
actions: $e
|
|
3723
3780
|
};
|
|
3724
3781
|
}
|
|
3725
|
-
function
|
|
3726
|
-
let n =
|
|
3782
|
+
function Ia({ className: e, ...t }) {
|
|
3783
|
+
let n = Fa(t);
|
|
3727
3784
|
if (!n.editor) return null;
|
|
3728
3785
|
let r = [n.frameProps.className, e].filter(Boolean).join(" ");
|
|
3729
3786
|
return /* @__PURE__ */ Q("section", {
|
|
3730
3787
|
...n.frameProps,
|
|
3731
3788
|
className: r,
|
|
3732
3789
|
children: [
|
|
3733
|
-
n.overlayProps.floatingToolbar ? /* @__PURE__ */ Z(
|
|
3734
|
-
n.overlayProps.slashCommandMenu ? /* @__PURE__ */ Z(
|
|
3735
|
-
n.overlayProps.tableControls ? /* @__PURE__ */ Z(
|
|
3736
|
-
n.overlayProps.tableSelectionOverlay ? /* @__PURE__ */ Z(
|
|
3737
|
-
n.overlayProps.codeBlockControls ? /* @__PURE__ */ Z(
|
|
3738
|
-
n.overlayProps.innerToc ? /* @__PURE__ */ Z(
|
|
3739
|
-
n.overlayProps.mathEditorPopover ? /* @__PURE__ */ Z(
|
|
3790
|
+
n.overlayProps.floatingToolbar ? /* @__PURE__ */ Z($i, { ...n.overlayProps.floatingToolbar }) : null,
|
|
3791
|
+
n.overlayProps.slashCommandMenu ? /* @__PURE__ */ Z(ba, { ...n.overlayProps.slashCommandMenu }) : null,
|
|
3792
|
+
n.overlayProps.tableControls ? /* @__PURE__ */ Z(wa, { ...n.overlayProps.tableControls }) : null,
|
|
3793
|
+
n.overlayProps.tableSelectionOverlay ? /* @__PURE__ */ Z(Ta, { ...n.overlayProps.tableSelectionOverlay }) : null,
|
|
3794
|
+
n.overlayProps.codeBlockControls ? /* @__PURE__ */ Z(Mi, { ...n.overlayProps.codeBlockControls }) : null,
|
|
3795
|
+
n.overlayProps.innerToc ? /* @__PURE__ */ Z(Da, { ...n.overlayProps.innerToc }) : null,
|
|
3796
|
+
n.overlayProps.mathEditorPopover ? /* @__PURE__ */ Z(da, { ...n.overlayProps.mathEditorPopover }) : null,
|
|
3740
3797
|
/* @__PURE__ */ Z(i, { editor: n.editor })
|
|
3741
3798
|
]
|
|
3742
3799
|
});
|
|
3743
3800
|
}
|
|
3744
3801
|
//#endregion
|
|
3745
|
-
export {
|
|
3802
|
+
export { Ia as MarkweaveEditor, ki as createMarkweaveEditorExtensions, ki as createMarkweaveReactEditorExtensions, Fa as useMarkweaveEditorController };
|