@markweave/react 0.7.2 → 0.7.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 +37 -37
- package/dist/index.js +792 -784
- package/dist/types/MarkweaveEditor.d.ts +5 -1
- package/dist/types/MarkweaveEditor.d.ts.map +1 -1
- package/dist/types/create-editor-extensions.d.ts +4 -0
- package/dist/types/create-editor-extensions.d.ts.map +1 -1
- package/dist/types/ui/slash-command/SlashCommandMenu.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2,14 +2,14 @@ import { createMarkweaveEditorExtensions as e } from "markweave/internal/editor-
|
|
|
2
2
|
import { getMarkweaveMessages as t, normalizeMarkweaveLang as n } from "markweave/internal/i18n";
|
|
3
3
|
import { createMarkweaveAdapterMediaExtensions as r } from "markweave/internal/plugins/media/media-extension-factory";
|
|
4
4
|
import { EditorContent as i, NodeViewWrapper as a, ReactNodeViewRenderer as o, useCurrentEditor as s, useEditor as c } from "@tiptap/react";
|
|
5
|
-
import { AlertTriangle as l, AlignCenter as u, AlignJustify as d, AlignLeft as f, AlignRight as p, AlignVerticalJustifyCenter as m, AlignVerticalJustifyEnd as h, AlignVerticalJustifyStart as g, ArrowDown as _, ArrowDownAZ as v, ArrowLeft as y, ArrowRight as b, ArrowUp as x, ArrowUpZA as S, BetweenHorizontalEnd as C, BetweenHorizontalStart as w, BetweenVerticalEnd as T, BetweenVerticalStart as E, Bold as D, Braces as O, Captions as k, Check as A, CheckCircle2 as j, ChevronDown as
|
|
5
|
+
import { AlertTriangle as l, AlignCenter as u, AlignJustify as d, AlignLeft as f, AlignRight as p, AlignVerticalJustifyCenter as m, AlignVerticalJustifyEnd as h, AlignVerticalJustifyStart as g, ArrowDown as _, ArrowDownAZ as v, ArrowLeft as y, ArrowRight as b, ArrowUp as x, ArrowUpZA as S, BetweenHorizontalEnd as C, BetweenHorizontalStart as w, BetweenVerticalEnd as T, BetweenVerticalStart as E, Bold as D, Braces as O, Captions as k, Check as A, CheckCircle2 as j, ChevronDown as M, ChevronRight as N, ChevronUp as ee, CircleX as P, Code2 as te, Copy as ne, CornerDownLeft as re, Download as F, ExternalLink as I, Eye as ie, Heading1 as ae, Heading2 as L, Heading3 as oe, Image as R, ImageUp as z, IndentDecrease as B, IndentIncrease as se, Info as ce, Italic as le, Lightbulb as ue, Link2 as de, List as V, ListChecks as fe, ListOrdered as H, Minus as pe, MoreVertical as me, PaintBucket as he, Paperclip as ge, Pencil as _e, Plus as ve, Quote as ye, Replace as be, RotateCcw as xe, Sigma as Se, SmilePlus as Ce, Sparkles as we, Square as Te, SquareX as Ee, Strikethrough as De, Subscript as Oe, Superscript as ke, Table2 as Ae, TableCellsMerge as je, TableCellsSplit as Me, Text as Ne, Trash2 as U, Type as Pe, Underline as Fe, Upload as Ie, Video as Le, X as Re } from "lucide-react";
|
|
6
6
|
import ze, { useCallback as W, useEffect as G, useLayoutEffect as Be, useMemo as K, useRef as q, useState as J, useSyncExternalStore as Ve } from "react";
|
|
7
7
|
import { getMarkweaveEditorModeState as He, isMarkweaveEditorLiveEditable as Ue, normalizeMarkweaveEditorMode as We, setMarkweaveEditorModeState as Ge, subscribeToMarkweaveEditorMode as Ke } from "markweave/internal/core/editor-mode-state";
|
|
8
8
|
import { activateMarkweaveAttachmentDownload as qe, attrsFromMarkweaveAttachmentUploadResult as Je, createMarkweaveAttachmentRefFromAttrs as Ye, createMarkweaveAttachmentUploadRequest as Xe, formatMarkweaveAttachmentSize as Ze } from "markweave/internal/plugins/media/attachment-download";
|
|
9
|
-
import { MarkweaveCoreImage as Qe, MarkweaveCoreVideo as $e, attrsFromMarkweaveImageUploadResult as et, attrsFromMarkweaveVideoUploadResult as tt, attrsFromMarkweaveVideoUrl as nt, clampMarkweaveImageWidth as rt, createMarkweaveImageUploadRequest as it, createMarkweaveVideoUploadRequest as
|
|
9
|
+
import { MarkweaveCoreImage as Qe, MarkweaveCoreVideo as $e, attrsFromMarkweaveImageUploadResult as et, attrsFromMarkweaveVideoUploadResult as tt, attrsFromMarkweaveVideoUrl as nt, clampMarkweaveImageWidth as rt, createMarkweaveImageUploadRequest as it, createMarkweaveVideoUploadRequest as at, downloadMarkweaveImage as ot, markweaveVideoIframeAllow as st, normalizeMarkweaveCoreImageAlign as ct, normalizeMarkweaveVideoEmbedUrl as lt, numberAttribute as ut, stringAttribute as Y } from "markweave/internal/plugins/media/core-media-nodes";
|
|
10
10
|
import { MarkweaveAttachment as dt } from "markweave/internal/plugins/media/media-nodes";
|
|
11
|
-
import { detectUploadSource as ft, getDirectUploadResult as pt, resolveMarkweaveUploadResult as
|
|
12
|
-
import { Fragment as
|
|
11
|
+
import { detectUploadSource as ft, getDirectUploadResult as pt, resolveMarkweaveUploadResult as X } from "markweave/internal/plugins/slash-command/upload";
|
|
12
|
+
import { Fragment as mt, jsx as Z, jsxs as Q } from "react/jsx-runtime";
|
|
13
13
|
import { openMarkweaveImagePreview as ht } from "markweave/internal/plugins/media/image-preview";
|
|
14
14
|
import { createMarkweaveLightweightImageNodeViewRenderer as gt } from "markweave/internal/plugins/media/lightweight-image-node-view";
|
|
15
15
|
import { resolveMarkweaveMediaSource as _t } from "markweave/internal/plugins/media/media-source";
|
|
@@ -80,13 +80,13 @@ function aa(e) {
|
|
|
80
80
|
!d || ra(e.target) || (e.preventDefault(), k());
|
|
81
81
|
}, j = (e) => {
|
|
82
82
|
d && s && (e.key === "Delete" || e.key === "Backspace") && (e.preventDefault(), n());
|
|
83
|
-
},
|
|
83
|
+
}, M = () => {
|
|
84
84
|
!d || g || p.current?.click();
|
|
85
|
-
},
|
|
85
|
+
}, N = async (e) => {
|
|
86
86
|
if (!(!d || !e || g)) {
|
|
87
87
|
y(null), _(!0), x(e.name), C(e.size), T(null);
|
|
88
88
|
try {
|
|
89
|
-
let t = await
|
|
89
|
+
let t = await X({
|
|
90
90
|
...Xe({
|
|
91
91
|
type: "file",
|
|
92
92
|
file: e,
|
|
@@ -103,12 +103,12 @@ function aa(e) {
|
|
|
103
103
|
_(!1), x(null), C(null), T(null), p.current && (p.current.value = "");
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
|
-
},
|
|
107
|
-
|
|
108
|
-
},
|
|
106
|
+
}, ee = (e) => {
|
|
107
|
+
N(e.currentTarget.files?.[0] ?? null);
|
|
108
|
+
}, P = (e) => {
|
|
109
109
|
if (!ra(e.target)) {
|
|
110
110
|
if (e.preventDefault(), e.stopPropagation(), E) {
|
|
111
|
-
|
|
111
|
+
M();
|
|
112
112
|
return;
|
|
113
113
|
}
|
|
114
114
|
f && qe(f, {
|
|
@@ -116,14 +116,14 @@ function aa(e) {
|
|
|
116
116
|
event: e.nativeEvent
|
|
117
117
|
}, l.onDownload);
|
|
118
118
|
}
|
|
119
|
-
},
|
|
119
|
+
}, te = (e) => {
|
|
120
120
|
e.preventDefault(), e.stopPropagation(), f && qe(f, {
|
|
121
121
|
mode: He(r).mode,
|
|
122
122
|
event: e.nativeEvent
|
|
123
123
|
}, l.onDownload);
|
|
124
|
-
},
|
|
124
|
+
}, ne = (e) => {
|
|
125
125
|
e.preventDefault(), e.stopPropagation(), n();
|
|
126
|
-
},
|
|
126
|
+
}, re = f?.name ?? Y(o.attrs.src) ?? u.missingSrc, I = [Y(o.attrs.mimeType), Ze(typeof o.attrs.size == "number" ? o.attrs.size : null)].filter(Boolean), ie = [Ze(S), w === null ? null : `${w}%`].filter(Boolean).join(" · ");
|
|
127
127
|
return E ? /* @__PURE__ */ Q(a, {
|
|
128
128
|
as: "div",
|
|
129
129
|
className: "markweave-attachment markweave-attachment-upload-placeholder",
|
|
@@ -139,7 +139,7 @@ function aa(e) {
|
|
|
139
139
|
"data-testid": "markweave-attachment-file-input",
|
|
140
140
|
type: "file",
|
|
141
141
|
hidden: !0,
|
|
142
|
-
onChange:
|
|
142
|
+
onChange: ee
|
|
143
143
|
}), /* @__PURE__ */ Q("button", {
|
|
144
144
|
type: "button",
|
|
145
145
|
className: "markweave-attachment-upload-trigger",
|
|
@@ -147,7 +147,7 @@ function aa(e) {
|
|
|
147
147
|
"data-testid": "markweave-attachment-upload-trigger",
|
|
148
148
|
"aria-label": u.uploadLabel,
|
|
149
149
|
onMouseDown: (e) => e.preventDefault(),
|
|
150
|
-
onClick:
|
|
150
|
+
onClick: M,
|
|
151
151
|
children: [
|
|
152
152
|
/* @__PURE__ */ Z("span", {
|
|
153
153
|
className: "markweave-attachment-icon",
|
|
@@ -198,7 +198,7 @@ function aa(e) {
|
|
|
198
198
|
children: [/* @__PURE__ */ Z("span", {
|
|
199
199
|
className: "markweave-attachment-spinner",
|
|
200
200
|
"aria-hidden": "true"
|
|
201
|
-
}),
|
|
201
|
+
}), ie || u.uploading]
|
|
202
202
|
})]
|
|
203
203
|
})]
|
|
204
204
|
}) : /* @__PURE__ */ Q(a, {
|
|
@@ -214,7 +214,7 @@ function aa(e) {
|
|
|
214
214
|
onMouseLeave: () => h(!1),
|
|
215
215
|
onMouseDown: A,
|
|
216
216
|
onKeyDown: j,
|
|
217
|
-
onClick:
|
|
217
|
+
onClick: P,
|
|
218
218
|
children: [
|
|
219
219
|
/* @__PURE__ */ Z("span", {
|
|
220
220
|
className: "markweave-attachment-icon",
|
|
@@ -228,10 +228,10 @@ function aa(e) {
|
|
|
228
228
|
className: "markweave-attachment-body",
|
|
229
229
|
children: [/* @__PURE__ */ Z("span", {
|
|
230
230
|
className: "markweave-attachment-name",
|
|
231
|
-
children:
|
|
232
|
-
}),
|
|
231
|
+
children: re
|
|
232
|
+
}), I.length > 0 ? /* @__PURE__ */ Z("span", {
|
|
233
233
|
className: "markweave-attachment-meta",
|
|
234
|
-
children:
|
|
234
|
+
children: I.join(" · ")
|
|
235
235
|
}) : null]
|
|
236
236
|
}),
|
|
237
237
|
O ? /* @__PURE__ */ Q("span", {
|
|
@@ -244,8 +244,8 @@ function aa(e) {
|
|
|
244
244
|
"data-testid": "markweave-attachment-download",
|
|
245
245
|
"aria-label": u.downloadAriaLabel,
|
|
246
246
|
onMouseDown: (e) => e.preventDefault(),
|
|
247
|
-
onClick:
|
|
248
|
-
children: [/* @__PURE__ */ Z(
|
|
247
|
+
onClick: te,
|
|
248
|
+
children: [/* @__PURE__ */ Z(F, {
|
|
249
249
|
size: 16,
|
|
250
250
|
strokeWidth: 1.8
|
|
251
251
|
}), /* @__PURE__ */ Z("span", {
|
|
@@ -260,8 +260,8 @@ function aa(e) {
|
|
|
260
260
|
"data-testid": "markweave-attachment-delete",
|
|
261
261
|
"aria-label": u.deleteAriaLabel,
|
|
262
262
|
onMouseDown: (e) => e.preventDefault(),
|
|
263
|
-
onClick:
|
|
264
|
-
children: [/* @__PURE__ */ Z(
|
|
263
|
+
onClick: ne,
|
|
264
|
+
children: [/* @__PURE__ */ Z(U, {
|
|
265
265
|
size: 16,
|
|
266
266
|
strokeWidth: 1.8
|
|
267
267
|
}), /* @__PURE__ */ Z("span", {
|
|
@@ -287,15 +287,15 @@ var oa = dt.extend({
|
|
|
287
287
|
addNodeView() {
|
|
288
288
|
return typeof document > "u" ? null : o(aa, { stopEvent: ({ event: e }) => ra(e.target) });
|
|
289
289
|
}
|
|
290
|
-
}), sa =
|
|
290
|
+
}), sa = ct;
|
|
291
291
|
function ca(e) {
|
|
292
292
|
return e instanceof Element && !!e.closest("[data-markweave-image-ui=\"true\"]");
|
|
293
293
|
}
|
|
294
294
|
function la(e) {
|
|
295
|
-
let { deleteNode: n, editor: r, getPos: i, node: o, selected: s, updateAttributes: c } = e, l = e.extension.options, u = l.messages ?? t("zh"), d = u.image, f = Ue(na(r)), p =
|
|
295
|
+
let { deleteNode: n, editor: r, getPos: i, node: o, selected: s, updateAttributes: c } = e, l = e.extension.options, u = l.messages ?? t("zh"), d = u.image, f = Ue(na(r)), p = Y(o.attrs.src), m = sa(o.attrs.align), h = ut(o.attrs.width), g = Y(o.attrs.caption), _ = q(null), v = ha(p, l.resolveMediaSource, _, s), y = v?.src ?? (l.resolveMediaSource ? null : p), b = q(null), [x, S] = J(!1), [C, w] = J(!1), [T, E] = J(!1), [D, O] = J(""), [k, A] = J(null), [j, M] = J(!1), [N, ee] = J(!!g), [P, te] = J(g ?? ""), ne = f && (!p || C), re = () => {
|
|
296
296
|
y && ht({
|
|
297
297
|
src: y,
|
|
298
|
-
alt:
|
|
298
|
+
alt: Y(o.attrs.alt) ?? "",
|
|
299
299
|
messages: {
|
|
300
300
|
dialogAriaLabel: d.previewDialogAriaLabel,
|
|
301
301
|
zoomOut: d.previewZoomOut,
|
|
@@ -306,13 +306,13 @@ function la(e) {
|
|
|
306
306
|
});
|
|
307
307
|
};
|
|
308
308
|
G(() => {
|
|
309
|
-
|
|
310
|
-
}, [g,
|
|
311
|
-
let
|
|
309
|
+
N || te(g ?? "");
|
|
310
|
+
}, [g, N]);
|
|
311
|
+
let F = () => {
|
|
312
312
|
if (!f) return;
|
|
313
313
|
let e = i();
|
|
314
314
|
typeof e == "number" && r.chain().focus().setNodeSelection(e).run();
|
|
315
|
-
},
|
|
315
|
+
}, I = () => {
|
|
316
316
|
if (f) {
|
|
317
317
|
if (O(""), A(null), E(!1), p) {
|
|
318
318
|
w(!1);
|
|
@@ -320,43 +320,43 @@ function la(e) {
|
|
|
320
320
|
}
|
|
321
321
|
n();
|
|
322
322
|
}
|
|
323
|
-
},
|
|
323
|
+
}, ae = async (e) => {
|
|
324
324
|
if (f) {
|
|
325
|
-
A(null),
|
|
325
|
+
A(null), M(!0);
|
|
326
326
|
try {
|
|
327
|
-
let t = await
|
|
327
|
+
let t = await X(it(e, p && C ? "image-replace" : "image-insert"), l.onUpload);
|
|
328
328
|
c(et(o.attrs, t)), w(!1), O("");
|
|
329
329
|
} catch (e) {
|
|
330
330
|
A(e instanceof Error ? e.message : d.uploadFailedError);
|
|
331
331
|
} finally {
|
|
332
|
-
|
|
332
|
+
M(!1), E(!1);
|
|
333
333
|
}
|
|
334
334
|
}
|
|
335
|
-
},
|
|
335
|
+
}, L = () => {
|
|
336
336
|
if (f) {
|
|
337
337
|
if (!D.trim()) {
|
|
338
338
|
A(d.uploadRequiredError);
|
|
339
339
|
return;
|
|
340
340
|
}
|
|
341
|
-
|
|
341
|
+
ae(ft(D));
|
|
342
342
|
}
|
|
343
|
-
},
|
|
344
|
-
!f || !e ||
|
|
343
|
+
}, oe = (e) => {
|
|
344
|
+
!f || !e || ae({
|
|
345
345
|
type: "file",
|
|
346
346
|
file: e,
|
|
347
347
|
mimeType: e.type
|
|
348
348
|
});
|
|
349
|
-
}, L = (e) => {
|
|
350
|
-
I(e.currentTarget.files?.[0] ?? null), e.currentTarget.value = "";
|
|
351
349
|
}, R = (e) => {
|
|
352
|
-
|
|
353
|
-
}, z = () => {
|
|
354
|
-
|
|
355
|
-
},
|
|
356
|
-
f && (
|
|
357
|
-
},
|
|
350
|
+
oe(e.currentTarget.files?.[0] ?? null), e.currentTarget.value = "";
|
|
351
|
+
}, z = (e) => {
|
|
352
|
+
e.preventDefault(), e.stopPropagation(), f && oe(e.dataTransfer.files?.[0] ?? null);
|
|
353
|
+
}, B = () => {
|
|
354
|
+
f && (ee((e) => !e), N || te(g ?? ""));
|
|
355
|
+
}, se = (e) => {
|
|
356
|
+
f && (te(e), c({ caption: e.trim() ? e : null }));
|
|
357
|
+
}, ce = (e, t) => {
|
|
358
358
|
if (t.preventDefault(), t.stopPropagation(), !f) return;
|
|
359
|
-
|
|
359
|
+
F();
|
|
360
360
|
let n = _.current;
|
|
361
361
|
if (!n) return;
|
|
362
362
|
let r = t.clientX, i = n.getBoundingClientRect().width || h || 320, a = n.closest(".markweave-editor-surface")?.getBoundingClientRect().width ?? n.parentElement?.getBoundingClientRect().width ?? i, o = (t) => {
|
|
@@ -374,37 +374,37 @@ function la(e) {
|
|
|
374
374
|
"data-align": m,
|
|
375
375
|
"data-selected": f && s ? "true" : "false",
|
|
376
376
|
"data-hovered": x ? "true" : "false",
|
|
377
|
-
"data-empty":
|
|
377
|
+
"data-empty": ne ? "true" : "false",
|
|
378
378
|
onPointerEnter: () => S(!0),
|
|
379
379
|
onPointerLeave: () => S(!1),
|
|
380
380
|
onMouseDown: (e) => {
|
|
381
|
-
f && !ca(e.target) &&
|
|
381
|
+
f && !ca(e.target) && F();
|
|
382
382
|
},
|
|
383
|
-
children:
|
|
383
|
+
children: ne ? /* @__PURE__ */ Z(ua, {
|
|
384
384
|
dragActive: T,
|
|
385
385
|
error: k,
|
|
386
386
|
inputValue: D,
|
|
387
387
|
isSubmitting: j,
|
|
388
388
|
fileInputRef: b,
|
|
389
389
|
messages: u,
|
|
390
|
-
onCancel:
|
|
391
|
-
onDrop:
|
|
390
|
+
onCancel: I,
|
|
391
|
+
onDrop: z,
|
|
392
392
|
onDragActiveChange: E,
|
|
393
|
-
onFileChange:
|
|
393
|
+
onFileChange: R,
|
|
394
394
|
onInputChange: O,
|
|
395
|
-
onSubmit:
|
|
396
|
-
}) : /* @__PURE__ */ Q(
|
|
395
|
+
onSubmit: L
|
|
396
|
+
}) : /* @__PURE__ */ Q(mt, { children: [
|
|
397
397
|
f ? /* @__PURE__ */ Z(da, {
|
|
398
398
|
align: m,
|
|
399
|
-
captionActive:
|
|
399
|
+
captionActive: N || !!g,
|
|
400
400
|
messages: u,
|
|
401
401
|
onAlign: (e) => c({ align: e }),
|
|
402
|
-
onCaption:
|
|
402
|
+
onCaption: B,
|
|
403
403
|
onDelete: n,
|
|
404
404
|
onDownload: () => {
|
|
405
|
-
y &&
|
|
405
|
+
y && ot(y);
|
|
406
406
|
},
|
|
407
|
-
onPreview:
|
|
407
|
+
onPreview: re,
|
|
408
408
|
onReplace: () => {
|
|
409
409
|
O(""), A(null), w(!0);
|
|
410
410
|
}
|
|
@@ -420,8 +420,8 @@ function la(e) {
|
|
|
420
420
|
y ? /* @__PURE__ */ Z("img", {
|
|
421
421
|
className: "markweave-image",
|
|
422
422
|
src: y,
|
|
423
|
-
alt:
|
|
424
|
-
title:
|
|
423
|
+
alt: Y(o.attrs.alt) ?? "",
|
|
424
|
+
title: Y(o.attrs.title) ?? void 0,
|
|
425
425
|
draggable: !1,
|
|
426
426
|
loading: "lazy",
|
|
427
427
|
decoding: "async",
|
|
@@ -440,8 +440,8 @@ function la(e) {
|
|
|
440
440
|
"aria-label": d.preview,
|
|
441
441
|
title: d.preview,
|
|
442
442
|
onMouseDown: (e) => e.preventDefault(),
|
|
443
|
-
onClick:
|
|
444
|
-
children: [/* @__PURE__ */ Z(
|
|
443
|
+
onClick: re,
|
|
444
|
+
children: [/* @__PURE__ */ Z(ie, {
|
|
445
445
|
size: 16,
|
|
446
446
|
strokeWidth: 1.8
|
|
447
447
|
}), /* @__PURE__ */ Z("span", {
|
|
@@ -453,25 +453,25 @@ function la(e) {
|
|
|
453
453
|
f ? /* @__PURE__ */ Z(pa, {
|
|
454
454
|
side: "left",
|
|
455
455
|
messages: u,
|
|
456
|
-
onPointerDown:
|
|
456
|
+
onPointerDown: ce
|
|
457
457
|
}) : null,
|
|
458
458
|
f ? /* @__PURE__ */ Z(pa, {
|
|
459
459
|
side: "right",
|
|
460
460
|
messages: u,
|
|
461
|
-
onPointerDown:
|
|
461
|
+
onPointerDown: ce
|
|
462
462
|
}) : null
|
|
463
463
|
]
|
|
464
464
|
}),
|
|
465
|
-
f && (
|
|
465
|
+
f && (N || g) ? /* @__PURE__ */ Z("input", {
|
|
466
466
|
className: "markweave-image-caption-input",
|
|
467
467
|
"data-markweave-image-ui": "true",
|
|
468
468
|
"data-testid": "markweave-image-caption-input",
|
|
469
|
-
value:
|
|
469
|
+
value: P,
|
|
470
470
|
placeholder: d.captionPlaceholder,
|
|
471
471
|
"aria-label": d.captionAriaLabel,
|
|
472
|
-
onChange: (e) =>
|
|
472
|
+
onChange: (e) => se(e.currentTarget.value),
|
|
473
473
|
onKeyDown: (e) => {
|
|
474
|
-
e.key === "Escape" && (e.preventDefault(),
|
|
474
|
+
e.key === "Escape" && (e.preventDefault(), ee(!1));
|
|
475
475
|
}
|
|
476
476
|
}) : g ? /* @__PURE__ */ Z("figcaption", {
|
|
477
477
|
className: "markweave-image-caption",
|
|
@@ -516,7 +516,7 @@ function ua({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
|
|
|
516
516
|
/* @__PURE__ */ Z("span", {
|
|
517
517
|
className: "markweave-image-upload-icon",
|
|
518
518
|
"aria-hidden": "true",
|
|
519
|
-
children: /* @__PURE__ */ Z(
|
|
519
|
+
children: /* @__PURE__ */ Z(z, {
|
|
520
520
|
size: 16,
|
|
521
521
|
strokeWidth: 1.8
|
|
522
522
|
})
|
|
@@ -550,7 +550,7 @@ function ua({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
|
|
|
550
550
|
"data-testid": "markweave-image-upload-submit",
|
|
551
551
|
disabled: i || !r.trim(),
|
|
552
552
|
onClick: d,
|
|
553
|
-
children: [/* @__PURE__ */ Z(
|
|
553
|
+
children: [/* @__PURE__ */ Z(z, {
|
|
554
554
|
size: 16,
|
|
555
555
|
strokeWidth: 1.8
|
|
556
556
|
}), a.common.insert]
|
|
@@ -613,13 +613,13 @@ function da({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i,
|
|
|
613
613
|
/* @__PURE__ */ Z(fa, {
|
|
614
614
|
testId: "markweave-image-preview",
|
|
615
615
|
label: l.preview,
|
|
616
|
-
icon:
|
|
616
|
+
icon: ie,
|
|
617
617
|
onClick: s
|
|
618
618
|
}),
|
|
619
619
|
/* @__PURE__ */ Z(fa, {
|
|
620
620
|
testId: "markweave-image-download",
|
|
621
621
|
label: l.download,
|
|
622
|
-
icon:
|
|
622
|
+
icon: F,
|
|
623
623
|
onClick: o
|
|
624
624
|
}),
|
|
625
625
|
/* @__PURE__ */ Z(fa, {
|
|
@@ -635,7 +635,7 @@ function da({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i,
|
|
|
635
635
|
/* @__PURE__ */ Z(fa, {
|
|
636
636
|
testId: "markweave-image-delete",
|
|
637
637
|
label: l.delete,
|
|
638
|
-
icon:
|
|
638
|
+
icon: U,
|
|
639
639
|
onClick: a
|
|
640
640
|
})
|
|
641
641
|
]
|
|
@@ -689,7 +689,7 @@ var ma = Qe.extend({
|
|
|
689
689
|
onUpload: this.options.onUpload,
|
|
690
690
|
resolveMediaSource: n
|
|
691
691
|
});
|
|
692
|
-
return (t) =>
|
|
692
|
+
return (t) => Y(t.node.attrs.src) ? r(t) : e(t);
|
|
693
693
|
}
|
|
694
694
|
});
|
|
695
695
|
function ha(e, t, n, r) {
|
|
@@ -742,7 +742,7 @@ function ga(e) {
|
|
|
742
742
|
return e instanceof Element && !!e.closest("[data-markweave-video-ui=\"true\"], iframe[data-markweave-video-embed], video[data-markweave-video]");
|
|
743
743
|
}
|
|
744
744
|
function _a(e) {
|
|
745
|
-
let { deleteNode: n, editor: r, getPos: i, node: o, selected: s, updateAttributes: c } = e, l = e.extension.options, u = l.messages ?? t("zh"), d = u.video, f = Ue(na(r)), p =
|
|
745
|
+
let { deleteNode: n, editor: r, getPos: i, node: o, selected: s, updateAttributes: c } = e, l = e.extension.options, u = l.messages ?? t("zh"), d = u.video, f = Ue(na(r)), p = Y(o.attrs.src), m = Y(o.attrs.embedUrl), h = Y(o.attrs.provider), g = m ? lt(m, h) : null, _ = Y(o.attrs.mimeType), v = Y(o.attrs.title), y = q(null), [b, x] = J(!1), [S, C] = J(""), [w, T] = J(null), [E, D] = J(!1), O = f && !p, k = () => {
|
|
746
746
|
if (!f) return;
|
|
747
747
|
let e = i();
|
|
748
748
|
typeof e == "number" && r.chain().focus().setNodeSelection(e).run();
|
|
@@ -750,11 +750,11 @@ function _a(e) {
|
|
|
750
750
|
f && (ga(e.target) || (e.preventDefault(), k()));
|
|
751
751
|
}, j = (e) => {
|
|
752
752
|
f && (e.key === "Delete" || e.key === "Backspace") && s && (e.preventDefault(), n());
|
|
753
|
-
},
|
|
753
|
+
}, M = async (e) => {
|
|
754
754
|
if (!(!f || !e)) {
|
|
755
755
|
T(null), D(!0);
|
|
756
756
|
try {
|
|
757
|
-
let t = await
|
|
757
|
+
let t = await X(at({
|
|
758
758
|
type: "file",
|
|
759
759
|
file: e,
|
|
760
760
|
mimeType: e.type
|
|
@@ -783,10 +783,10 @@ function _a(e) {
|
|
|
783
783
|
onCancel: n,
|
|
784
784
|
onDragActiveChange: x,
|
|
785
785
|
onDrop: (e) => {
|
|
786
|
-
e.preventDefault(), e.stopPropagation(), f &&
|
|
786
|
+
e.preventDefault(), e.stopPropagation(), f && M(e.dataTransfer.files?.[0] ?? null);
|
|
787
787
|
},
|
|
788
788
|
onFileChange: (e) => {
|
|
789
|
-
|
|
789
|
+
M(e.currentTarget.files?.[0] ?? null), e.currentTarget.value = "";
|
|
790
790
|
},
|
|
791
791
|
onInputChange: C,
|
|
792
792
|
onSubmit: () => {
|
|
@@ -820,7 +820,7 @@ function _a(e) {
|
|
|
820
820
|
"data-markweave-video-embed": "true",
|
|
821
821
|
"data-markweave-video-provider": h ?? void 0,
|
|
822
822
|
"data-markweave-video-src": p ?? void 0,
|
|
823
|
-
allow:
|
|
823
|
+
allow: st,
|
|
824
824
|
loading: "lazy",
|
|
825
825
|
allowFullScreen: !0
|
|
826
826
|
}), f ? /* @__PURE__ */ Z("button", {
|
|
@@ -1058,13 +1058,13 @@ function wa(e) {
|
|
|
1058
1058
|
children: [
|
|
1059
1059
|
/* @__PURE__ */ Z(Ta, {
|
|
1060
1060
|
label: u.convertToLink,
|
|
1061
|
-
icon:
|
|
1061
|
+
icon: de,
|
|
1062
1062
|
onClick: T,
|
|
1063
1063
|
testId: "markweave-link-card-convert"
|
|
1064
1064
|
}),
|
|
1065
1065
|
/* @__PURE__ */ Z(Ta, {
|
|
1066
1066
|
label: u.copyAddress,
|
|
1067
|
-
icon:
|
|
1067
|
+
icon: ne,
|
|
1068
1068
|
onClick: () => void xa(f.href),
|
|
1069
1069
|
testId: "markweave-link-card-copy"
|
|
1070
1070
|
}),
|
|
@@ -1088,7 +1088,7 @@ function wa(e) {
|
|
|
1088
1088
|
}),
|
|
1089
1089
|
/* @__PURE__ */ Z(Ta, {
|
|
1090
1090
|
label: u.delete,
|
|
1091
|
-
icon:
|
|
1091
|
+
icon: U,
|
|
1092
1092
|
onClick: n,
|
|
1093
1093
|
testId: "markweave-link-card-delete"
|
|
1094
1094
|
})
|
|
@@ -1116,7 +1116,7 @@ function wa(e) {
|
|
|
1116
1116
|
type: "submit",
|
|
1117
1117
|
"aria-label": u.edit,
|
|
1118
1118
|
disabled: !yt(x),
|
|
1119
|
-
children: /* @__PURE__ */ Z(
|
|
1119
|
+
children: /* @__PURE__ */ Z(de, { size: 16 })
|
|
1120
1120
|
})
|
|
1121
1121
|
]
|
|
1122
1122
|
}) : null
|
|
@@ -1159,6 +1159,8 @@ function Da(n = {}) {
|
|
|
1159
1159
|
lang: n.lang,
|
|
1160
1160
|
onImageUpload: n.onImageUpload,
|
|
1161
1161
|
tableCapabilities: n.tableCapabilities,
|
|
1162
|
+
referenceSuggestion: n.referenceSuggestion,
|
|
1163
|
+
internalLinkCard: n.internalLinkCard,
|
|
1162
1164
|
linkCardExtension: Ea.configure({
|
|
1163
1165
|
lang: n.lang,
|
|
1164
1166
|
messages: t(n.lang),
|
|
@@ -1181,11 +1183,11 @@ function Da(n = {}) {
|
|
|
1181
1183
|
//#endregion
|
|
1182
1184
|
//#region src/ui/codeblock/CodeBlockControls.tsx
|
|
1183
1185
|
function Oa(e) {
|
|
1184
|
-
return e === "clipboard" ? /* @__PURE__ */ Q(
|
|
1186
|
+
return e === "clipboard" ? /* @__PURE__ */ Q(mt, { 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(mt, { children: [/* @__PURE__ */ Z("circle", {
|
|
1185
1187
|
cx: "10",
|
|
1186
1188
|
cy: "10",
|
|
1187
1189
|
r: "5.5"
|
|
1188
|
-
}), /* @__PURE__ */ Z("path", { d: "m14 14 4 4" })] }) : e === "check" ? /* @__PURE__ */ Z("path", { d: "m5 11 4 4 8-9" }) : e === "expand" ? /* @__PURE__ */ Q(
|
|
1190
|
+
}), /* @__PURE__ */ Z("path", { d: "m14 14 4 4" })] }) : e === "check" ? /* @__PURE__ */ Z("path", { d: "m5 11 4 4 8-9" }) : e === "expand" ? /* @__PURE__ */ Q(mt, { children: [
|
|
1189
1191
|
/* @__PURE__ */ Z("path", { d: "M8 4H4v4" }),
|
|
1190
1192
|
/* @__PURE__ */ Z("path", { d: "M4 4l5 5" }),
|
|
1191
1193
|
/* @__PURE__ */ Z("path", { d: "M16 4h4v4" }),
|
|
@@ -1194,11 +1196,11 @@ function Oa(e) {
|
|
|
1194
1196
|
/* @__PURE__ */ Z("path", { d: "m4 20 5-5" }),
|
|
1195
1197
|
/* @__PURE__ */ Z("path", { d: "M16 20h4v-4" }),
|
|
1196
1198
|
/* @__PURE__ */ Z("path", { d: "m20 20-5-5" })
|
|
1197
|
-
] }) : e === "download" ? /* @__PURE__ */ Q(
|
|
1199
|
+
] }) : e === "download" ? /* @__PURE__ */ Q(mt, { children: [
|
|
1198
1200
|
/* @__PURE__ */ Z("path", { d: "M12 4v10" }),
|
|
1199
1201
|
/* @__PURE__ */ Z("path", { d: "m8 10 4 4 4-4" }),
|
|
1200
1202
|
/* @__PURE__ */ Z("path", { d: "M5 19h14" })
|
|
1201
|
-
] }) : e === "close" ? /* @__PURE__ */ Q(
|
|
1203
|
+
] }) : e === "close" ? /* @__PURE__ */ Q(mt, { children: [/* @__PURE__ */ Z("path", { d: "M6 6l12 12" }), /* @__PURE__ */ Z("path", { d: "M18 6 6 18" })] }) : e === "zoomOut" ? /* @__PURE__ */ Q(mt, { children: [
|
|
1202
1204
|
/* @__PURE__ */ Z("circle", {
|
|
1203
1205
|
cx: "10",
|
|
1204
1206
|
cy: "10",
|
|
@@ -1206,7 +1208,7 @@ function Oa(e) {
|
|
|
1206
1208
|
}),
|
|
1207
1209
|
/* @__PURE__ */ Z("path", { d: "M7.5 10h5" }),
|
|
1208
1210
|
/* @__PURE__ */ Z("path", { d: "m14 14 4 4" })
|
|
1209
|
-
] }) : e === "zoomIn" ? /* @__PURE__ */ Q(
|
|
1211
|
+
] }) : e === "zoomIn" ? /* @__PURE__ */ Q(mt, { children: [
|
|
1210
1212
|
/* @__PURE__ */ Z("circle", {
|
|
1211
1213
|
cx: "10",
|
|
1212
1214
|
cy: "10",
|
|
@@ -1215,7 +1217,7 @@ function Oa(e) {
|
|
|
1215
1217
|
/* @__PURE__ */ Z("path", { d: "M7.5 10h5" }),
|
|
1216
1218
|
/* @__PURE__ */ Z("path", { d: "M10 7.5v5" }),
|
|
1217
1219
|
/* @__PURE__ */ Z("path", { d: "m14 14 4 4" })
|
|
1218
|
-
] }) : e === "reset" ? /* @__PURE__ */ Q(
|
|
1220
|
+
] }) : e === "reset" ? /* @__PURE__ */ Q(mt, { 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" });
|
|
1219
1221
|
}
|
|
1220
1222
|
function ka({ icon: e }) {
|
|
1221
1223
|
return /* @__PURE__ */ Z("svg", {
|
|
@@ -1237,11 +1239,11 @@ function Aa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1237
1239
|
active: !1,
|
|
1238
1240
|
lastX: 0,
|
|
1239
1241
|
lastY: 0
|
|
1240
|
-
}), [f, p] = J(null), [m, h] = J(null), [g, _] = J([]), [v, y] = J(null), [b, x] = J(!1), [S, C] = J(""), [w, T] = J(-1), [E, D] = J(null), [O, k] = J(!1), [A, j] = J(null), [
|
|
1241
|
-
...
|
|
1242
|
-
pos:
|
|
1242
|
+
}), [f, p] = J(null), [m, h] = J(null), [g, _] = J([]), [v, y] = J(null), [b, x] = J(!1), [S, C] = J(""), [w, T] = J(-1), [E, D] = J(null), [O, k] = J(!1), [A, j] = J(null), [M, N] = J(null), [ee, P] = J(!1), [te, ne] = J(0), [re, F] = J(0), I = Kt(t), ie = ir(t, f), ae = !i && e && I.active && I.pos !== null ? {
|
|
1243
|
+
...I,
|
|
1244
|
+
pos: I.pos,
|
|
1243
1245
|
active: !0
|
|
1244
|
-
} : null,
|
|
1246
|
+
} : null, L = ie ?? ae, oe = L !== null, R = L?.language === "mermaid", z = lr(t, L), B = oe && L !== null && !z, se = !i, ce = Zn(L ? L.language : "text"), le = E?.status ?? "idle", ue = L?.mermaidPreviewMode ?? n, de = R && ue === "preview", V = sr(t), fe = `${re}|${V.map((e) => `${e.pos}:${e.mermaidPreviewMode}:${e.text.length}`).join("|")}`, H = K(() => tr(S.trim().toLowerCase()), [S]);
|
|
1245
1247
|
if (G(() => {
|
|
1246
1248
|
i && (x(!1), C(""), T(-1));
|
|
1247
1249
|
}, [i]), G(() => {
|
|
@@ -1253,15 +1255,15 @@ function Aa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1253
1255
|
window.clearTimeout(e);
|
|
1254
1256
|
};
|
|
1255
1257
|
}, [E]), G(() => {
|
|
1256
|
-
D(null), x(!1), C(""), T(-1), j(null),
|
|
1258
|
+
D(null), x(!1), C(""), T(-1), j(null), N(null), P(!1);
|
|
1257
1259
|
}, [
|
|
1258
1260
|
e,
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1261
|
+
L?.language,
|
|
1262
|
+
L?.pos,
|
|
1263
|
+
L?.text
|
|
1262
1264
|
]), G(() => {
|
|
1263
1265
|
let e = ({ transaction: e }) => {
|
|
1264
|
-
e.getMeta(Wt) &&
|
|
1266
|
+
e.getMeta(Wt) && ne((e) => e + 1);
|
|
1265
1267
|
};
|
|
1266
1268
|
return t.on("transaction", e), () => {
|
|
1267
1269
|
t.off("transaction", e);
|
|
@@ -1292,7 +1294,7 @@ function Aa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1292
1294
|
]), G(() => {
|
|
1293
1295
|
if (!A) return;
|
|
1294
1296
|
let e = (e) => {
|
|
1295
|
-
e.key === "Escape" && (j(null),
|
|
1297
|
+
e.key === "Escape" && (j(null), N(null), P(!1), d.current = {
|
|
1296
1298
|
active: !1,
|
|
1297
1299
|
lastX: 0,
|
|
1298
1300
|
lastY: 0
|
|
@@ -1302,7 +1304,7 @@ function Aa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1302
1304
|
document.removeEventListener("keydown", e);
|
|
1303
1305
|
};
|
|
1304
1306
|
}, [t, A]), G(() => {
|
|
1305
|
-
if (!
|
|
1307
|
+
if (!oe || !b) return;
|
|
1306
1308
|
let e = (e) => {
|
|
1307
1309
|
e.key === "Escape" && (x(!1), T(-1), t.view.focus());
|
|
1308
1310
|
}, n = (e) => {
|
|
@@ -1312,22 +1314,22 @@ function Aa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1312
1314
|
document.removeEventListener("keydown", e), document.removeEventListener("mousedown", n);
|
|
1313
1315
|
};
|
|
1314
1316
|
}, [
|
|
1315
|
-
|
|
1317
|
+
oe,
|
|
1316
1318
|
t,
|
|
1317
1319
|
b
|
|
1318
1320
|
]), Be(() => {
|
|
1319
1321
|
let e = () => {
|
|
1320
1322
|
let e = a.current;
|
|
1321
1323
|
if (!e) return;
|
|
1322
|
-
if (!ar(e) ||
|
|
1324
|
+
if (!ar(e) || V.length === 0) {
|
|
1323
1325
|
_([]);
|
|
1324
1326
|
return;
|
|
1325
1327
|
}
|
|
1326
|
-
let n = e.getBoundingClientRect(), r =
|
|
1328
|
+
let n = e.getBoundingClientRect(), r = V.flatMap((e) => {
|
|
1327
1329
|
let r = er($n(t, e.pos, e.mermaidPreviewMode), n);
|
|
1328
1330
|
return r ? [Yn(e, r, n)] : [];
|
|
1329
1331
|
});
|
|
1330
|
-
_((e) => ur(e, r,
|
|
1332
|
+
_((e) => ur(e, r, V.map((e) => e.pos)));
|
|
1331
1333
|
};
|
|
1332
1334
|
e();
|
|
1333
1335
|
let n = window.requestAnimationFrame(e);
|
|
@@ -1335,23 +1337,23 @@ function Aa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1335
1337
|
window.cancelAnimationFrame(n), window.removeEventListener("resize", e), window.removeEventListener("scroll", e, !0);
|
|
1336
1338
|
};
|
|
1337
1339
|
}, [
|
|
1338
|
-
|
|
1340
|
+
te,
|
|
1339
1341
|
t,
|
|
1340
|
-
|
|
1342
|
+
fe
|
|
1341
1343
|
]), Be(() => {
|
|
1342
|
-
if (!
|
|
1344
|
+
if (!B || !L) {
|
|
1343
1345
|
h(null), y(null);
|
|
1344
1346
|
return;
|
|
1345
1347
|
}
|
|
1346
1348
|
let e = () => {
|
|
1347
1349
|
let e = a.current;
|
|
1348
1350
|
if (!e) return;
|
|
1349
|
-
let n = $n(t,
|
|
1351
|
+
let n = $n(t, L.pos, ue), r = e.getBoundingClientRect(), i = er(n, r);
|
|
1350
1352
|
if (!i) {
|
|
1351
|
-
h((e) => e?.pos ===
|
|
1353
|
+
h((e) => e?.pos === L.pos ? e : null), y((e) => b ? e : null);
|
|
1352
1354
|
return;
|
|
1353
1355
|
}
|
|
1354
|
-
let c = qn(
|
|
1356
|
+
let c = qn(L.pos, i, r);
|
|
1355
1357
|
if (h(c), b && o.current) {
|
|
1356
1358
|
let e = o.current.getBoundingClientRect(), t = s.current?.getBoundingClientRect().height;
|
|
1357
1359
|
y(Hn({
|
|
@@ -1367,44 +1369,44 @@ function Aa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1367
1369
|
window.removeEventListener("resize", e), window.removeEventListener("scroll", e, !0);
|
|
1368
1370
|
};
|
|
1369
1371
|
}, [
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1372
|
+
B,
|
|
1373
|
+
te,
|
|
1374
|
+
L?.pos,
|
|
1373
1375
|
t,
|
|
1374
1376
|
H.length,
|
|
1375
1377
|
b,
|
|
1376
|
-
|
|
1377
|
-
]), !
|
|
1378
|
+
ue
|
|
1379
|
+
]), !B && V.length === 0 && !A) return null;
|
|
1378
1380
|
let pe = m ? {
|
|
1379
1381
|
top: m.top,
|
|
1380
1382
|
right: m.right
|
|
1381
1383
|
} : void 0, me = async () => {
|
|
1382
1384
|
if (i) {
|
|
1383
|
-
if (!
|
|
1384
|
-
let e = await Gn(
|
|
1385
|
-
D(qt(
|
|
1385
|
+
if (!L) return;
|
|
1386
|
+
let e = await Gn(L.text);
|
|
1387
|
+
D(qt(L, e ? "copied" : "failed"));
|
|
1386
1388
|
return;
|
|
1387
1389
|
}
|
|
1388
|
-
if (!Xn(t,
|
|
1390
|
+
if (!Xn(t, L)) return;
|
|
1389
1391
|
let e = await Gt(t);
|
|
1390
1392
|
D(qt(Kt(t), e ? "copied" : "failed")), t.view.focus();
|
|
1391
1393
|
}, he = (e, n) => {
|
|
1392
1394
|
if (i) {
|
|
1393
|
-
tn(t, e.pos, n) &&
|
|
1395
|
+
tn(t, e.pos, n) && F((e) => e + 1);
|
|
1394
1396
|
return;
|
|
1395
1397
|
}
|
|
1396
|
-
let a =
|
|
1397
|
-
Zt(t, e.pos, n) && (r(n),
|
|
1398
|
+
let a = I.active && I.pos === e.pos;
|
|
1399
|
+
Zt(t, e.pos, n) && (r(n), F((e) => e + 1), a && t.view.focus());
|
|
1398
1400
|
}, ge = (e) => {
|
|
1399
|
-
if (i || !
|
|
1400
|
-
let n =
|
|
1401
|
-
Xt(t,
|
|
1401
|
+
if (i || !L) return;
|
|
1402
|
+
let n = I.active && I.pos === L.pos;
|
|
1403
|
+
Xt(t, L.pos, e) && (e === "mermaid" && Zt(t, L.pos, "preview") && r("preview"), x(!1), C(""), T(-1), F((e) => e + 1), n && t.view.focus());
|
|
1402
1404
|
}, _e = () => {
|
|
1403
1405
|
let e = !b;
|
|
1404
|
-
e && u.current === null && (u.current = Kn()), T(e ? or(H,
|
|
1406
|
+
e && u.current === null && (u.current = Kn()), T(e ? or(H, L?.language ?? null) : -1), x(e);
|
|
1405
1407
|
}, ve = (e) => {
|
|
1406
1408
|
let t = tr(e);
|
|
1407
|
-
C(e), T(or(t, e.trim() ? null :
|
|
1409
|
+
C(e), T(or(t, e.trim() ? null : L?.language ?? null));
|
|
1408
1410
|
}, ye = (e) => {
|
|
1409
1411
|
if (!e.nativeEvent.isComposing) {
|
|
1410
1412
|
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
@@ -1419,10 +1421,10 @@ function Aa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1419
1421
|
e.key === "Escape" && (e.preventDefault(), x(!1), T(-1), t.view.focus());
|
|
1420
1422
|
}
|
|
1421
1423
|
}, be = H[w], xe = u.current && be ? nr(u.current, be.language) : void 0, Se = () => {
|
|
1422
|
-
i || !
|
|
1424
|
+
i || !L || Yt(t, L.pos, !z) && (ne((e) => e + 1), p(null));
|
|
1423
1425
|
}, Ce = () => {
|
|
1424
|
-
if (!
|
|
1425
|
-
let e = cr(t,
|
|
1426
|
+
if (!L) return;
|
|
1427
|
+
let e = cr(t, L.pos);
|
|
1426
1428
|
e && Vn({
|
|
1427
1429
|
data: new Blob([e], { type: "image/svg+xml" }),
|
|
1428
1430
|
fileName: "markweave-mermaid.svg",
|
|
@@ -1430,39 +1432,39 @@ function Aa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1430
1432
|
ownerDocument: document
|
|
1431
1433
|
});
|
|
1432
1434
|
}, we = () => {
|
|
1433
|
-
if (!
|
|
1434
|
-
let e = cr(t,
|
|
1435
|
-
e && (j(Jn(e)),
|
|
1435
|
+
if (!L) return;
|
|
1436
|
+
let e = cr(t, L.pos);
|
|
1437
|
+
e && (j(Jn(e)), N(null), P(!1), d.current = {
|
|
1436
1438
|
active: !1,
|
|
1437
1439
|
lastX: 0,
|
|
1438
1440
|
lastY: 0
|
|
1439
1441
|
});
|
|
1440
|
-
},
|
|
1441
|
-
j(null),
|
|
1442
|
+
}, Te = () => {
|
|
1443
|
+
j(null), N(null), P(!1), d.current = {
|
|
1442
1444
|
active: !1,
|
|
1443
1445
|
lastX: 0,
|
|
1444
1446
|
lastY: 0
|
|
1445
1447
|
}, t.view.focus();
|
|
1446
|
-
},
|
|
1448
|
+
}, Ee = (e) => {
|
|
1447
1449
|
j((t) => t && {
|
|
1448
1450
|
...t,
|
|
1449
1451
|
scale: Un(t.scale + e)
|
|
1450
1452
|
});
|
|
1451
|
-
},
|
|
1453
|
+
}, De = () => {
|
|
1452
1454
|
j((e) => e && Jn(e.svg)), d.current = {
|
|
1453
1455
|
active: !1,
|
|
1454
1456
|
lastX: 0,
|
|
1455
1457
|
lastY: 0
|
|
1456
|
-
},
|
|
1457
|
-
}, De = (e) => {
|
|
1458
|
-
e.preventDefault(), Te(e.deltaY < 0 ? dr : -dr);
|
|
1458
|
+
}, P(!1);
|
|
1459
1459
|
}, Oe = (e) => {
|
|
1460
|
+
e.preventDefault(), Ee(e.deltaY < 0 ? dr : -dr);
|
|
1461
|
+
}, ke = (e) => {
|
|
1460
1462
|
e.button === 0 && (e.preventDefault(), d.current = {
|
|
1461
1463
|
active: !0,
|
|
1462
1464
|
lastX: e.clientX,
|
|
1463
1465
|
lastY: e.clientY
|
|
1464
|
-
},
|
|
1465
|
-
},
|
|
1466
|
+
}, P(!0));
|
|
1467
|
+
}, Ae = (e) => {
|
|
1466
1468
|
let t = d.current;
|
|
1467
1469
|
if (!t.active) return;
|
|
1468
1470
|
let n = e.clientX - t.lastX, r = e.clientY - t.lastY;
|
|
@@ -1471,12 +1473,12 @@ function Aa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1471
1473
|
lastX: e.clientX,
|
|
1472
1474
|
lastY: e.clientY
|
|
1473
1475
|
}, j((e) => pr(e, n, r));
|
|
1474
|
-
},
|
|
1476
|
+
}, je = () => {
|
|
1475
1477
|
d.current = {
|
|
1476
1478
|
active: !1,
|
|
1477
1479
|
lastX: 0,
|
|
1478
1480
|
lastY: 0
|
|
1479
|
-
},
|
|
1481
|
+
}, P(!1);
|
|
1480
1482
|
};
|
|
1481
1483
|
return /* @__PURE__ */ Q("div", {
|
|
1482
1484
|
ref: a,
|
|
@@ -1484,7 +1486,7 @@ function Aa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1484
1486
|
"data-testid": "markweave-codeblock-overlay",
|
|
1485
1487
|
"data-read-only": i ? "true" : "false",
|
|
1486
1488
|
children: [
|
|
1487
|
-
|
|
1489
|
+
V.map((e) => {
|
|
1488
1490
|
let t = g.find((t) => t.pos === e.pos);
|
|
1489
1491
|
return /* @__PURE__ */ Z("div", {
|
|
1490
1492
|
className: "markweave-mermaid-tabs",
|
|
@@ -1505,11 +1507,11 @@ function Aa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1505
1507
|
}, t))
|
|
1506
1508
|
}, e.pos);
|
|
1507
1509
|
}),
|
|
1508
|
-
|
|
1510
|
+
B ? /* @__PURE__ */ Q("div", {
|
|
1509
1511
|
className: "markweave-codeblock-controls",
|
|
1510
1512
|
"data-testid": "markweave-codeblock-controls",
|
|
1511
1513
|
"data-positioned": m ? "true" : "false",
|
|
1512
|
-
"data-collapsed":
|
|
1514
|
+
"data-collapsed": z ? "true" : "false",
|
|
1513
1515
|
"data-read-only": i ? "true" : "false",
|
|
1514
1516
|
"aria-label": "Code block controls",
|
|
1515
1517
|
style: pe,
|
|
@@ -1518,7 +1520,7 @@ function Aa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1518
1520
|
className: "markweave-codeblock-language-button markweave-codeblock-language-label",
|
|
1519
1521
|
"aria-label": "Code block language",
|
|
1520
1522
|
"data-testid": "markweave-codeblock-language",
|
|
1521
|
-
children: /* @__PURE__ */ Z("span", { children:
|
|
1523
|
+
children: /* @__PURE__ */ Z("span", { children: ce })
|
|
1522
1524
|
}) : /* @__PURE__ */ Q("button", {
|
|
1523
1525
|
ref: o,
|
|
1524
1526
|
type: "button",
|
|
@@ -1529,15 +1531,15 @@ function Aa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1529
1531
|
"data-testid": "markweave-codeblock-language",
|
|
1530
1532
|
onMouseDown: (e) => e.preventDefault(),
|
|
1531
1533
|
onClick: _e,
|
|
1532
|
-
children: [/* @__PURE__ */ Z("span", { children:
|
|
1534
|
+
children: [/* @__PURE__ */ Z("span", { children: ce }), /* @__PURE__ */ Z(ka, { icon: "chevron" })]
|
|
1533
1535
|
}),
|
|
1534
|
-
|
|
1536
|
+
se ? /* @__PURE__ */ Z("button", {
|
|
1535
1537
|
type: "button",
|
|
1536
1538
|
className: "markweave-codeblock-icon-button markweave-codeblock-collapse-button",
|
|
1537
|
-
"aria-label":
|
|
1538
|
-
title:
|
|
1539
|
+
"aria-label": z ? "Expand code block" : "Collapse code block",
|
|
1540
|
+
title: z ? "Expand code block" : "Collapse code block",
|
|
1539
1541
|
"data-testid": "markweave-codeblock-collapse",
|
|
1540
|
-
"data-collapsed":
|
|
1542
|
+
"data-collapsed": z ? "true" : "false",
|
|
1541
1543
|
onMouseDown: (e) => e.preventDefault(),
|
|
1542
1544
|
onClick: Se,
|
|
1543
1545
|
children: /* @__PURE__ */ Z(ka, { icon: "chevron" })
|
|
@@ -1549,14 +1551,14 @@ function Aa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1549
1551
|
className: "markweave-codeblock-icon-button",
|
|
1550
1552
|
"aria-label": "Copy to clipboard",
|
|
1551
1553
|
"data-testid": "markweave-codeblock-copy",
|
|
1552
|
-
"data-copy-state":
|
|
1554
|
+
"data-copy-state": le,
|
|
1553
1555
|
onMouseDown: (e) => e.preventDefault(),
|
|
1554
1556
|
onMouseEnter: () => k(!0),
|
|
1555
1557
|
onMouseLeave: () => k(!1),
|
|
1556
1558
|
onFocus: () => k(!0),
|
|
1557
1559
|
onBlur: () => k(!1),
|
|
1558
1560
|
onClick: me,
|
|
1559
|
-
children: /* @__PURE__ */ Z(ka, { icon:
|
|
1561
|
+
children: /* @__PURE__ */ Z(ka, { icon: le === "copied" ? "check" : "clipboard" })
|
|
1560
1562
|
}), O ? /* @__PURE__ */ Z("span", {
|
|
1561
1563
|
className: "markweave-codeblock-tooltip",
|
|
1562
1564
|
role: "tooltip",
|
|
@@ -1564,7 +1566,7 @@ function Aa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1564
1566
|
children: "Copy to clipboard"
|
|
1565
1567
|
}) : null]
|
|
1566
1568
|
}),
|
|
1567
|
-
|
|
1569
|
+
R && ue === "preview" ? /* @__PURE__ */ Q("div", {
|
|
1568
1570
|
className: "markweave-mermaid-preview-actions",
|
|
1569
1571
|
"data-testid": "markweave-mermaid-preview-actions",
|
|
1570
1572
|
children: [/* @__PURE__ */ Z("button", {
|
|
@@ -1572,7 +1574,7 @@ function Aa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1572
1574
|
className: "markweave-codeblock-icon-button",
|
|
1573
1575
|
"aria-label": "Fullscreen Mermaid preview",
|
|
1574
1576
|
"data-testid": "markweave-mermaid-fullscreen",
|
|
1575
|
-
disabled: !
|
|
1577
|
+
disabled: !de,
|
|
1576
1578
|
onMouseDown: (e) => e.preventDefault(),
|
|
1577
1579
|
onClick: we,
|
|
1578
1580
|
children: /* @__PURE__ */ Z(ka, { icon: "expand" })
|
|
@@ -1581,7 +1583,7 @@ function Aa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1581
1583
|
className: "markweave-codeblock-icon-button",
|
|
1582
1584
|
"aria-label": "Download Mermaid SVG",
|
|
1583
1585
|
"data-testid": "markweave-mermaid-download",
|
|
1584
|
-
disabled: !
|
|
1586
|
+
disabled: !de,
|
|
1585
1587
|
onMouseDown: (e) => e.preventDefault(),
|
|
1586
1588
|
onClick: Ce,
|
|
1587
1589
|
children: /* @__PURE__ */ Z(ka, { icon: "download" })
|
|
@@ -1589,7 +1591,7 @@ function Aa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1589
1591
|
}) : null
|
|
1590
1592
|
]
|
|
1591
1593
|
}) : null,
|
|
1592
|
-
|
|
1594
|
+
se && B && b ? /* @__PURE__ */ Q("div", {
|
|
1593
1595
|
ref: s,
|
|
1594
1596
|
className: "markweave-codeblock-language-menu",
|
|
1595
1597
|
"data-testid": "markweave-codeblock-language-menu",
|
|
@@ -1621,7 +1623,7 @@ function Aa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1621
1623
|
role: "listbox",
|
|
1622
1624
|
"aria-label": "Code block languages",
|
|
1623
1625
|
children: H.map((e, t) => {
|
|
1624
|
-
let n = e.language ===
|
|
1626
|
+
let n = e.language === L.language, r = t === w;
|
|
1625
1627
|
return /* @__PURE__ */ Q("button", {
|
|
1626
1628
|
id: u.current ? nr(u.current, e.language) : void 0,
|
|
1627
1629
|
type: "button",
|
|
@@ -1655,11 +1657,11 @@ function Aa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1655
1657
|
className: "markweave-mermaid-fullscreen-control",
|
|
1656
1658
|
"aria-label": "Zoom out",
|
|
1657
1659
|
"data-testid": "markweave-mermaid-fullscreen-zoom-out",
|
|
1658
|
-
onMouseEnter: () =>
|
|
1659
|
-
onMouseLeave: () =>
|
|
1660
|
-
onFocus: () =>
|
|
1661
|
-
onBlur: () =>
|
|
1662
|
-
onClick: () =>
|
|
1660
|
+
onMouseEnter: () => N("zoom-out"),
|
|
1661
|
+
onMouseLeave: () => N(null),
|
|
1662
|
+
onFocus: () => N("zoom-out"),
|
|
1663
|
+
onBlur: () => N(null),
|
|
1664
|
+
onClick: () => Ee(-dr),
|
|
1663
1665
|
children: /* @__PURE__ */ Z(ka, { icon: "zoomOut" })
|
|
1664
1666
|
}),
|
|
1665
1667
|
/* @__PURE__ */ Z("span", {
|
|
@@ -1672,11 +1674,11 @@ function Aa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1672
1674
|
className: "markweave-mermaid-fullscreen-control",
|
|
1673
1675
|
"aria-label": "Zoom in",
|
|
1674
1676
|
"data-testid": "markweave-mermaid-fullscreen-zoom-in",
|
|
1675
|
-
onMouseEnter: () =>
|
|
1676
|
-
onMouseLeave: () =>
|
|
1677
|
-
onFocus: () =>
|
|
1678
|
-
onBlur: () =>
|
|
1679
|
-
onClick: () =>
|
|
1677
|
+
onMouseEnter: () => N("zoom-in"),
|
|
1678
|
+
onMouseLeave: () => N(null),
|
|
1679
|
+
onFocus: () => N("zoom-in"),
|
|
1680
|
+
onBlur: () => N(null),
|
|
1681
|
+
onClick: () => Ee(dr),
|
|
1680
1682
|
children: /* @__PURE__ */ Z(ka, { icon: "zoomIn" })
|
|
1681
1683
|
}),
|
|
1682
1684
|
/* @__PURE__ */ Z("button", {
|
|
@@ -1684,18 +1686,18 @@ function Aa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1684
1686
|
className: "markweave-mermaid-fullscreen-control",
|
|
1685
1687
|
"aria-label": "Reset zoom",
|
|
1686
1688
|
"data-testid": "markweave-mermaid-fullscreen-reset",
|
|
1687
|
-
onMouseEnter: () =>
|
|
1688
|
-
onMouseLeave: () =>
|
|
1689
|
-
onFocus: () =>
|
|
1690
|
-
onBlur: () =>
|
|
1691
|
-
onClick:
|
|
1689
|
+
onMouseEnter: () => N("reset"),
|
|
1690
|
+
onMouseLeave: () => N(null),
|
|
1691
|
+
onFocus: () => N("reset"),
|
|
1692
|
+
onBlur: () => N(null),
|
|
1693
|
+
onClick: De,
|
|
1692
1694
|
children: /* @__PURE__ */ Z(ka, { icon: "reset" })
|
|
1693
1695
|
}),
|
|
1694
|
-
|
|
1696
|
+
M ? /* @__PURE__ */ Z("span", {
|
|
1695
1697
|
className: "markweave-mermaid-fullscreen-tooltip",
|
|
1696
1698
|
role: "tooltip",
|
|
1697
1699
|
"data-testid": "markweave-mermaid-fullscreen-tooltip",
|
|
1698
|
-
children:
|
|
1700
|
+
children: M === "zoom-out" ? "Zoom out" : M === "zoom-in" ? "Zoom in" : "Reset"
|
|
1699
1701
|
}) : null
|
|
1700
1702
|
]
|
|
1701
1703
|
}),
|
|
@@ -1704,18 +1706,18 @@ function Aa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1704
1706
|
className: "markweave-mermaid-fullscreen-close",
|
|
1705
1707
|
"aria-label": "Close fullscreen Mermaid preview",
|
|
1706
1708
|
"data-testid": "markweave-mermaid-fullscreen-close",
|
|
1707
|
-
onClick:
|
|
1709
|
+
onClick: Te,
|
|
1708
1710
|
children: /* @__PURE__ */ Z(ka, { icon: "close" })
|
|
1709
1711
|
}),
|
|
1710
1712
|
/* @__PURE__ */ Z("div", {
|
|
1711
1713
|
className: "markweave-mermaid-fullscreen-viewport",
|
|
1712
1714
|
"data-testid": "markweave-mermaid-fullscreen-viewport",
|
|
1713
|
-
"data-dragging":
|
|
1714
|
-
onWheel:
|
|
1715
|
-
onMouseDown:
|
|
1716
|
-
onMouseMove:
|
|
1717
|
-
onMouseUp:
|
|
1718
|
-
onMouseLeave:
|
|
1715
|
+
"data-dragging": ee ? "true" : "false",
|
|
1716
|
+
onWheel: Oe,
|
|
1717
|
+
onMouseDown: ke,
|
|
1718
|
+
onMouseMove: Ae,
|
|
1719
|
+
onMouseUp: je,
|
|
1720
|
+
onMouseLeave: je,
|
|
1719
1721
|
children: /* @__PURE__ */ Z("div", {
|
|
1720
1722
|
className: "markweave-mermaid-fullscreen-content",
|
|
1721
1723
|
"data-testid": "markweave-mermaid-fullscreen-content",
|
|
@@ -1964,15 +1966,15 @@ var co = 50, lo = async (e, t, n) => {
|
|
|
1964
1966
|
y: r
|
|
1965
1967
|
}, p = Ka(i), m = Wa(p), h = await o.getDimensions(l), g = p === "y", _ = g ? "top" : "left", v = g ? "bottom" : "right", y = g ? "clientHeight" : "clientWidth", b = a.reference[m] + a.reference[p] - f[p] - a.floating[m], x = f[p] - a.reference[p], S = await (o.getOffsetParent == null ? void 0 : o.getOffsetParent(l)), C = S ? S[y] : 0;
|
|
1966
1968
|
(!C || !await (o.isElement == null ? void 0 : o.isElement(S))) && (C = s.floating[y] || a.floating[m]);
|
|
1967
|
-
let w = b / 2 - x / 2, T = C / 2 - h[m] / 2 - 1, E = Pa(d[_], T), D = Pa(d[v], T), O = E, k = C - h[m] - D, A = C / 2 - h[m] / 2 + w, j = za(O, A, k),
|
|
1969
|
+
let w = b / 2 - x / 2, T = C / 2 - h[m] / 2 - 1, E = Pa(d[_], T), D = Pa(d[v], T), O = E, k = C - h[m] - D, A = C / 2 - h[m] / 2 + w, j = za(O, A, k), M = !c.arrow && Ha(i) != null && A !== j && a.reference[m] / 2 - (A < O ? E : D) - h[m] / 2 < 0, N = M ? A < O ? A - O : A - k : 0;
|
|
1968
1970
|
return {
|
|
1969
|
-
[p]: f[p] +
|
|
1971
|
+
[p]: f[p] + N,
|
|
1970
1972
|
data: {
|
|
1971
1973
|
[p]: j,
|
|
1972
|
-
centerOffset: A - j -
|
|
1973
|
-
...
|
|
1974
|
+
centerOffset: A - j - N,
|
|
1975
|
+
...M && { alignmentOffset: N }
|
|
1974
1976
|
},
|
|
1975
|
-
reset:
|
|
1977
|
+
reset: M
|
|
1976
1978
|
};
|
|
1977
1979
|
}
|
|
1978
1980
|
});
|
|
@@ -2628,7 +2630,7 @@ var Cs = {
|
|
|
2628
2630
|
});
|
|
2629
2631
|
};
|
|
2630
2632
|
//#endregion
|
|
2631
|
-
//#region ../../node_modules/.pnpm/@tiptap+extension-bubble-
|
|
2633
|
+
//#region ../../node_modules/.pnpm/@tiptap+extension-bubble-menu@3.29.2_@tiptap+core@3.29.2_@tiptap+pm@3.29.2__@tiptap+pm@3.29.2/node_modules/@tiptap/extension-bubble-menu/dist/index.js
|
|
2632
2634
|
function Ns(e, t) {
|
|
2633
2635
|
let n = Math.min(e.top, t.top), r = Math.max(e.bottom, t.bottom), i = Math.min(e.left, t.left), a = Math.max(e.right, t.right) - i, o = r - n;
|
|
2634
2636
|
return new DOMRect(i, n, a, o);
|
|
@@ -2814,7 +2816,7 @@ hr.create({
|
|
|
2814
2816
|
}
|
|
2815
2817
|
});
|
|
2816
2818
|
//#endregion
|
|
2817
|
-
//#region ../../node_modules/.pnpm/@tiptap+extension-floating-
|
|
2819
|
+
//#region ../../node_modules/.pnpm/@tiptap+extension-floating-menu@3.29.2_@floating-ui+dom@1.7.6_@tiptap+core@3.29.2_@tiptap+pm@3.29.2__@tiptap+pm@3.29.2/node_modules/@tiptap/extension-floating-menu/dist/index.js
|
|
2818
2820
|
var Is = class {
|
|
2819
2821
|
constructor({ editor: e, element: t, view: n, pluginKey: r = "floatingMenu", updateDelay: i = 250, resizeDelay: a = 60, options: o, appendTo: s, shouldShow: c }) {
|
|
2820
2822
|
this.preventHide = !1, this.isVisible = !1, this.scrollTarget = window, this.shouldShow = ({ view: e, state: t }) => {
|
|
@@ -2958,7 +2960,7 @@ hr.create({
|
|
|
2958
2960
|
}
|
|
2959
2961
|
});
|
|
2960
2962
|
//#endregion
|
|
2961
|
-
//#region ../../node_modules/.pnpm/@tiptap+react@3.29.2_@
|
|
2963
|
+
//#region ../../node_modules/.pnpm/@tiptap+react@3.29.2_@floating-ui+dom@1.7.6_@tiptap+core@3.29.2_@tiptap+pm@3.29.2__@tip_2279cac4bf12e5469a1ae6c590eec77f/node_modules/@tiptap/react/dist/menus/index.js
|
|
2962
2964
|
function Rs(e, t) {
|
|
2963
2965
|
return e ?? new Sr(t);
|
|
2964
2966
|
}
|
|
@@ -3371,14 +3373,14 @@ function kc(e, t, n) {
|
|
|
3371
3373
|
}
|
|
3372
3374
|
var Ac = "markweave-floating-toolbar";
|
|
3373
3375
|
function jc({ editor: e, lang: t = "zh", messages: n = uc, selectionSnapshot: r, askAi: i, onRewriteSelection: a }) {
|
|
3374
|
-
let o = K(() => jr(n), [n]), s = Bt(r, { editable: e.isEditable }), [c, l] = J(s), [u, d] = J(null), [f, p] = J(null), [m, h] = J(null), [g, _] = J("input"), [v, y] = J(""), [b, x] = J(""), [S, C] = J(""), [w, T] = J(""), [E, D] = J(""), [O, k] = J(""), [A, j] = J(null), [
|
|
3375
|
-
|
|
3376
|
-
}, []),
|
|
3377
|
-
|
|
3378
|
-
}, [
|
|
3379
|
-
let t =
|
|
3376
|
+
let o = K(() => jr(n), [n]), s = Bt(r, { editable: e.isEditable }), [c, l] = J(s), [u, d] = J(null), [f, p] = J(null), [m, h] = J(null), [g, _] = J("input"), [v, y] = J(""), [b, x] = J(""), [S, C] = J(""), [w, T] = J(""), [E, D] = J(""), [O, k] = J(""), [A, j] = J(null), [M, N] = J(0), [ee, P] = J(s.boundaryPadding), [te, ne] = J("bottom"), re = q(0), F = q(null), I = q(null), ie = q(null), ae = q(null), L = q(null), oe = q(null), R = q(null), z = q(null), B = q(null), se = q(""), ce = i?.enabled === !0 && typeof i.handler == "function", le = Dr(e, c.variant, n, { askAiEnabled: ce }), ue = Nr(le.find((e) => e.id === u) ?? null), de = si(E), V = W(() => {
|
|
3377
|
+
B.current !== null && (window.cancelAnimationFrame(B.current), B.current = null);
|
|
3378
|
+
}, []), fe = W((t = !0) => {
|
|
3379
|
+
R.current?.abort(), R.current = null, z.current = null, V(), t && ni(e), Yr(e), h(null);
|
|
3380
|
+
}, [V, e]), H = W(() => {
|
|
3381
|
+
let t = F.current, n = e.view.dom.closest(".markweave-editor-frame");
|
|
3380
3382
|
if (!t || !(n instanceof HTMLElement)) return;
|
|
3381
|
-
let r = t.getBoundingClientRect(), i = n.getBoundingClientRect(), a = pc(t,
|
|
3383
|
+
let r = t.getBoundingClientRect(), i = n.getBoundingClientRect(), a = pc(t, I.current), o = re.current, s = Ft({
|
|
3382
3384
|
toolbarRect: {
|
|
3383
3385
|
left: r.left - o,
|
|
3384
3386
|
top: r.top,
|
|
@@ -3406,13 +3408,13 @@ function jc({ editor: e, lang: t = "zh", messages: n = uc, selectionSnapshot: r,
|
|
|
3406
3408
|
offset: c.offset,
|
|
3407
3409
|
boundaryPadding: c.boundaryPadding
|
|
3408
3410
|
});
|
|
3409
|
-
t.style.marginLeft = s === 0 ? "" : `${s}px`, t.style.visibility = "visible", t.style.opacity = "1",
|
|
3411
|
+
t.style.marginLeft = s === 0 ? "" : `${s}px`, t.style.visibility = "visible", t.style.opacity = "1", re.current = s, N((e) => e === s ? e : s), P((e) => e === l ? e : l);
|
|
3410
3412
|
}, [
|
|
3411
3413
|
e.view.dom,
|
|
3412
3414
|
c.boundaryPadding,
|
|
3413
3415
|
c.offset
|
|
3414
3416
|
]), pe = W(() => {
|
|
3415
|
-
|
|
3417
|
+
F.current && (F.current.style.visibility = "hidden", F.current.style.opacity = "0");
|
|
3416
3418
|
}, []), me = W(() => {
|
|
3417
3419
|
H();
|
|
3418
3420
|
}, [H]), he = W(() => $r(e)?.target.kind === "table" ? {
|
|
@@ -3425,13 +3427,13 @@ function jc({ editor: e, lang: t = "zh", messages: n = uc, selectionSnapshot: r,
|
|
|
3425
3427
|
return t ? [hc(t.left, t.top, t.width, t.height)] : [];
|
|
3426
3428
|
}
|
|
3427
3429
|
} : Dc(e), [e]), ge = W((e) => {
|
|
3428
|
-
|
|
3430
|
+
ie.current = e, e?.classList.contains("markweave-ask-ai-popover") && (e.dataset.positioned = "false");
|
|
3429
3431
|
}, []), _e = W(() => {
|
|
3430
|
-
let t =
|
|
3432
|
+
let t = F.current, n = ie.current, r = e.view.dom.closest(".markweave-editor-frame");
|
|
3431
3433
|
if (!m || !t || !n) return;
|
|
3432
3434
|
let i = t.getBoundingClientRect(), a = n.getBoundingClientRect(), o = r?.getBoundingClientRect() ?? null;
|
|
3433
3435
|
if (m === "ask-ai") {
|
|
3434
|
-
let t = ei(e), r =
|
|
3436
|
+
let t = ei(e), r = I.current?.getBoundingClientRect();
|
|
3435
3437
|
if (!t || !r) return;
|
|
3436
3438
|
let i = {
|
|
3437
3439
|
anchorRect: r,
|
|
@@ -3450,7 +3452,7 @@ function jc({ editor: e, lang: t = "zh", messages: n = uc, selectionSnapshot: r,
|
|
|
3450
3452
|
n.style.width !== l && (n.style.width = l, s = Kr({
|
|
3451
3453
|
...i,
|
|
3452
3454
|
panelSize: n.getBoundingClientRect()
|
|
3453
|
-
})), n.style.left = `${s.left}px`, n.style.top = `${s.top}px`, n.style.bottom = "auto", n.style.maxWidth = `${s.maxWidth}px`, n.style.maxHeight = `${Math.max(0, s.maxHeight)}px`, n.dataset.positioned = "true",
|
|
3455
|
+
})), n.style.left = `${s.left}px`, n.style.top = `${s.top}px`, n.style.bottom = "auto", n.style.maxWidth = `${s.maxWidth}px`, n.style.maxHeight = `${Math.max(0, s.maxHeight)}px`, n.dataset.positioned = "true", ne((e) => e === s.placement ? e : s.placement);
|
|
3454
3456
|
return;
|
|
3455
3457
|
}
|
|
3456
3458
|
let s = It({
|
|
@@ -3464,20 +3466,20 @@ function jc({ editor: e, lang: t = "zh", messages: n = uc, selectionSnapshot: r,
|
|
|
3464
3466
|
gap: m === "more" ? 8 : 6,
|
|
3465
3467
|
boundaryPadding: c.boundaryPadding
|
|
3466
3468
|
});
|
|
3467
|
-
|
|
3469
|
+
ne((e) => e === s.placement ? e : s.placement);
|
|
3468
3470
|
}, [
|
|
3469
3471
|
e,
|
|
3470
3472
|
m,
|
|
3471
3473
|
c.boundaryPadding
|
|
3472
3474
|
]), ve = K(() => ({
|
|
3473
|
-
...zt(c, { topBoundaryPadding:
|
|
3475
|
+
...zt(c, { topBoundaryPadding: ee }),
|
|
3474
3476
|
onShow: pe,
|
|
3475
3477
|
onUpdate: me
|
|
3476
3478
|
}), [
|
|
3477
3479
|
pe,
|
|
3478
3480
|
me,
|
|
3479
3481
|
c,
|
|
3480
|
-
|
|
3482
|
+
ee
|
|
3481
3483
|
]);
|
|
3482
3484
|
G(() => {
|
|
3483
3485
|
let e = dc();
|
|
@@ -3507,7 +3509,7 @@ function jc({ editor: e, lang: t = "zh", messages: n = uc, selectionSnapshot: r,
|
|
|
3507
3509
|
c.motionStartedAtMs
|
|
3508
3510
|
]), Be(() => {
|
|
3509
3511
|
if (c.visibility !== "visible") {
|
|
3510
|
-
|
|
3512
|
+
re.current = 0, F.current && (F.current.style.marginLeft = "", F.current.style.visibility = "hidden", F.current.style.opacity = "0"), N(0), P(c.boundaryPadding);
|
|
3511
3513
|
return;
|
|
3512
3514
|
}
|
|
3513
3515
|
let e = Tt(H);
|
|
@@ -3522,7 +3524,7 @@ function jc({ editor: e, lang: t = "zh", messages: n = uc, selectionSnapshot: r,
|
|
|
3522
3524
|
r?.to,
|
|
3523
3525
|
c.variant,
|
|
3524
3526
|
c.visibility,
|
|
3525
|
-
|
|
3527
|
+
le.length
|
|
3526
3528
|
]), Be(() => {
|
|
3527
3529
|
if (!m) return;
|
|
3528
3530
|
let e = Tt(_e);
|
|
@@ -3536,33 +3538,33 @@ function jc({ editor: e, lang: t = "zh", messages: n = uc, selectionSnapshot: r,
|
|
|
3536
3538
|
m,
|
|
3537
3539
|
_e
|
|
3538
3540
|
]), G(() => {
|
|
3539
|
-
m === "more" && o.some((e) => e.id === u) ||
|
|
3541
|
+
m === "more" && o.some((e) => e.id === u) || le.some((e) => e.id === u) || (d(null), p(null));
|
|
3540
3542
|
}, [
|
|
3541
3543
|
o,
|
|
3542
3544
|
m,
|
|
3543
3545
|
u,
|
|
3544
|
-
|
|
3546
|
+
le
|
|
3545
3547
|
]), G(() => {
|
|
3546
3548
|
if (!m) return;
|
|
3547
3549
|
let t = (e) => {
|
|
3548
|
-
|
|
3550
|
+
I.current?.contains(e.target) || (m === "ask-ai" ? fe(!0) : h(null));
|
|
3549
3551
|
}, n = (t) => {
|
|
3550
|
-
t.key === "Escape" && (t.preventDefault(), m === "ask-ai" ? g === "generating" ? (
|
|
3552
|
+
t.key === "Escape" && (t.preventDefault(), m === "ask-ai" ? g === "generating" ? (R.current?.abort(), V(), _("input")) : fe(!0) : (h(null), e.commands.focus()));
|
|
3551
3553
|
};
|
|
3552
3554
|
return document.addEventListener("pointerdown", t, !0), document.addEventListener("keydown", n, !0), () => {
|
|
3553
3555
|
document.removeEventListener("pointerdown", t, !0), document.removeEventListener("keydown", n, !0);
|
|
3554
3556
|
};
|
|
3555
3557
|
}, [
|
|
3556
3558
|
g,
|
|
3557
|
-
B,
|
|
3558
3559
|
V,
|
|
3560
|
+
fe,
|
|
3559
3561
|
e,
|
|
3560
3562
|
m
|
|
3561
3563
|
]), G(() => {
|
|
3562
3564
|
let t = () => {
|
|
3563
3565
|
let t = $r(e);
|
|
3564
3566
|
if (t?.target.kind === "table" && t.status === "target" && m !== "ask-ai") {
|
|
3565
|
-
|
|
3567
|
+
oe.current = t.selection, _("input"), y(""), C(""), T(""), x(""), l((e) => ({
|
|
3566
3568
|
...e,
|
|
3567
3569
|
visibility: "visible",
|
|
3568
3570
|
variant: "default",
|
|
@@ -3572,21 +3574,21 @@ function jc({ editor: e, lang: t = "zh", messages: n = uc, selectionSnapshot: r,
|
|
|
3572
3574
|
})), h("ask-ai");
|
|
3573
3575
|
return;
|
|
3574
3576
|
}
|
|
3575
|
-
m === "ask-ai" && t?.status === "conflict" && (
|
|
3577
|
+
m === "ask-ai" && t?.status === "conflict" && (R.current?.abort(), V(), _("conflict"));
|
|
3576
3578
|
};
|
|
3577
3579
|
return e.on("transaction", t), () => {
|
|
3578
3580
|
e.off("transaction", t);
|
|
3579
3581
|
};
|
|
3580
3582
|
}, [
|
|
3581
|
-
|
|
3583
|
+
V,
|
|
3582
3584
|
e,
|
|
3583
3585
|
m
|
|
3584
3586
|
]), G(() => () => {
|
|
3585
|
-
|
|
3586
|
-
}, [
|
|
3587
|
+
R.current?.abort(), V(), Yr(e);
|
|
3588
|
+
}, [V, e]), G(() => {
|
|
3587
3589
|
if (m !== "link" && m !== "ask-ai") return;
|
|
3588
3590
|
let e = window.requestAnimationFrame(() => {
|
|
3589
|
-
m === "ask-ai" ?
|
|
3591
|
+
m === "ask-ai" ? L.current?.focus() : (ae.current?.focus(), ae.current?.select());
|
|
3590
3592
|
});
|
|
3591
3593
|
return () => window.cancelAnimationFrame(e);
|
|
3592
3594
|
}, [m]), G(() => {
|
|
@@ -3596,14 +3598,14 @@ function jc({ editor: e, lang: t = "zh", messages: n = uc, selectionSnapshot: r,
|
|
|
3596
3598
|
if (Oc(t.id)) {
|
|
3597
3599
|
let n = t.id;
|
|
3598
3600
|
if (m === n) {
|
|
3599
|
-
n === "ask-ai" ?
|
|
3601
|
+
n === "ask-ai" ? fe(!0) : h(null);
|
|
3600
3602
|
return;
|
|
3601
3603
|
}
|
|
3602
|
-
if (m === "ask-ai" &&
|
|
3603
|
-
if (!
|
|
3604
|
+
if (m === "ask-ai" && fe(!1), n === "ask-ai") {
|
|
3605
|
+
if (!ce) return;
|
|
3604
3606
|
let t = oi(e);
|
|
3605
3607
|
if (!t) return;
|
|
3606
|
-
|
|
3608
|
+
oe.current = t, _("input"), C(""), T(""), x("");
|
|
3607
3609
|
}
|
|
3608
3610
|
if (n === "link") {
|
|
3609
3611
|
let t = kr(e);
|
|
@@ -3621,32 +3623,32 @@ function jc({ editor: e, lang: t = "zh", messages: n = uc, selectionSnapshot: r,
|
|
|
3621
3623
|
}
|
|
3622
3624
|
t.run(), e.commands.focus();
|
|
3623
3625
|
}, be = W(async (r) => {
|
|
3624
|
-
if (!
|
|
3626
|
+
if (!ce || i?.enabled !== !0 || !oe.current) return;
|
|
3625
3627
|
let a = (r ?? v).trim();
|
|
3626
3628
|
if (!a) {
|
|
3627
3629
|
T(n.askAi.emptyPrompt), _("error");
|
|
3628
3630
|
return;
|
|
3629
3631
|
}
|
|
3630
|
-
let o = Zr(e,
|
|
3632
|
+
let o = Zr(e, oe.current);
|
|
3631
3633
|
if (!o) {
|
|
3632
3634
|
_("conflict");
|
|
3633
3635
|
return;
|
|
3634
3636
|
}
|
|
3635
|
-
|
|
3637
|
+
oe.current = o, R.current?.abort(), V(), Jr(e);
|
|
3636
3638
|
let s = new AbortController(), c = Xr(o, a, t, s.signal, void 0, $r(e)?.target);
|
|
3637
|
-
|
|
3639
|
+
R.current = s, z.current = c.id, x(a), T(""), C(""), _("generating");
|
|
3638
3640
|
try {
|
|
3639
3641
|
let t = await ri(i.handler, c, (t) => {
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
+
z.current !== c.id || s.signal.aborted || (se.current = t, B.current === null && (B.current = window.requestAnimationFrame(() => {
|
|
3643
|
+
B.current = null, ii(e, se.current), C(se.current);
|
|
3642
3644
|
})));
|
|
3643
3645
|
});
|
|
3644
|
-
if (
|
|
3646
|
+
if (z.current !== c.id || s.signal.aborted) return;
|
|
3645
3647
|
if (!ii(e, t)) throw new Wr("invalid-output", "Ask AI output is incompatible with the selected content.");
|
|
3646
|
-
|
|
3648
|
+
V(), C(t), y(""), _($r(e)?.status === "target" ? "result" : "conflict");
|
|
3647
3649
|
} catch (t) {
|
|
3648
|
-
if (
|
|
3649
|
-
if (
|
|
3650
|
+
if (z.current !== c.id) return;
|
|
3651
|
+
if (V(), s.signal.aborted) {
|
|
3650
3652
|
Jr(e), _($r(e)?.status === "conflict" ? "conflict" : "input");
|
|
3651
3653
|
return;
|
|
3652
3654
|
}
|
|
@@ -3654,9 +3656,9 @@ function jc({ editor: e, lang: t = "zh", messages: n = uc, selectionSnapshot: r,
|
|
|
3654
3656
|
}
|
|
3655
3657
|
}, [
|
|
3656
3658
|
i,
|
|
3657
|
-
|
|
3659
|
+
ce,
|
|
3658
3660
|
v,
|
|
3659
|
-
|
|
3661
|
+
V,
|
|
3660
3662
|
e,
|
|
3661
3663
|
t,
|
|
3662
3664
|
n
|
|
@@ -3665,7 +3667,7 @@ function jc({ editor: e, lang: t = "zh", messages: n = uc, selectionSnapshot: r,
|
|
|
3665
3667
|
_($r(e)?.status === "conflict" ? "conflict" : "error"), T(n.askAi.errorFallback);
|
|
3666
3668
|
return;
|
|
3667
3669
|
}
|
|
3668
|
-
h(null),
|
|
3670
|
+
h(null), z.current = null, window.setTimeout(() => Yr(e), 560), e.commands.focus();
|
|
3669
3671
|
}, [
|
|
3670
3672
|
S,
|
|
3671
3673
|
e,
|
|
@@ -3676,32 +3678,32 @@ function jc({ editor: e, lang: t = "zh", messages: n = uc, selectionSnapshot: r,
|
|
|
3676
3678
|
A && e.commands.setTextSelection(A);
|
|
3677
3679
|
}, we = () => {
|
|
3678
3680
|
Ce(), Tr(e, E) && Se();
|
|
3679
|
-
},
|
|
3681
|
+
}, Te = () => {
|
|
3680
3682
|
if (Ce(), zr(e)) {
|
|
3681
3683
|
D(""), k(""), Se();
|
|
3682
3684
|
return;
|
|
3683
3685
|
}
|
|
3684
3686
|
E.trim() && D("");
|
|
3685
|
-
},
|
|
3686
|
-
if (d(e), !e || !t || !
|
|
3687
|
+
}, Ee = (e, t) => {
|
|
3688
|
+
if (d(e), !e || !t || !I.current) {
|
|
3687
3689
|
p(null);
|
|
3688
3690
|
return;
|
|
3689
3691
|
}
|
|
3690
|
-
let n = t.getBoundingClientRect(), r =
|
|
3692
|
+
let n = t.getBoundingClientRect(), r = I.current.getBoundingClientRect();
|
|
3691
3693
|
p(n.left + n.width / 2 - r.left);
|
|
3692
3694
|
};
|
|
3693
3695
|
return /* @__PURE__ */ Z(lc, {
|
|
3694
|
-
ref:
|
|
3696
|
+
ref: F,
|
|
3695
3697
|
editor: e,
|
|
3696
3698
|
pluginKey: Ac,
|
|
3697
3699
|
className: `markweave-floating-toolbar markweave-floating-toolbar--${c.variant} markweave-floating-toolbar--motion-${c.motionPhase}`,
|
|
3698
3700
|
"data-motion": c.motionPhase,
|
|
3699
3701
|
"data-position-strategy": ve.strategy,
|
|
3700
3702
|
"data-boundary-padding": c.boundaryPadding,
|
|
3701
|
-
"data-popover-placement": m ?
|
|
3703
|
+
"data-popover-placement": m ? te : void 0,
|
|
3702
3704
|
"data-ask-ai-session": m === "ask-ai" ? "open" : "closed",
|
|
3703
3705
|
"data-testid": "markweave-floating-toolbar",
|
|
3704
|
-
style: fc(c,
|
|
3706
|
+
style: fc(c, M),
|
|
3705
3707
|
updateDelay: 0,
|
|
3706
3708
|
getReferencedVirtualElement: he,
|
|
3707
3709
|
options: ve,
|
|
@@ -3714,17 +3716,17 @@ function jc({ editor: e, lang: t = "zh", messages: n = uc, selectionSnapshot: r,
|
|
|
3714
3716
|
});
|
|
3715
3717
|
},
|
|
3716
3718
|
children: /* @__PURE__ */ Q("div", {
|
|
3717
|
-
ref:
|
|
3719
|
+
ref: I,
|
|
3718
3720
|
className: "markweave-floating-toolbar-content",
|
|
3719
3721
|
"data-menu": m ?? "none",
|
|
3720
3722
|
children: [
|
|
3721
|
-
|
|
3723
|
+
le.map((e, t) => /* @__PURE__ */ Z(Pc, {
|
|
3722
3724
|
button: e,
|
|
3723
3725
|
expanded: m === e.id,
|
|
3724
|
-
showDivider: t > 0 &&
|
|
3726
|
+
showDivider: t > 0 && le[t - 1].group !== e.group,
|
|
3725
3727
|
tooltipActive: u === e.id,
|
|
3726
3728
|
onPointerDown: Rr,
|
|
3727
|
-
onTooltipChange:
|
|
3729
|
+
onTooltipChange: Ee,
|
|
3728
3730
|
onRun: ye
|
|
3729
3731
|
}, e.id)),
|
|
3730
3732
|
m === "block-type" ? /* @__PURE__ */ Z(Ic, {
|
|
@@ -3734,7 +3736,7 @@ function jc({ editor: e, lang: t = "zh", messages: n = uc, selectionSnapshot: r,
|
|
|
3734
3736
|
onClose: () => h(null)
|
|
3735
3737
|
}) : null,
|
|
3736
3738
|
m === "ask-ai" ? /* @__PURE__ */ Z(Nc, {
|
|
3737
|
-
inputRef:
|
|
3739
|
+
inputRef: L,
|
|
3738
3740
|
messages: n,
|
|
3739
3741
|
phase: g,
|
|
3740
3742
|
prompt: v,
|
|
@@ -3743,24 +3745,24 @@ function jc({ editor: e, lang: t = "zh", messages: n = uc, selectionSnapshot: r,
|
|
|
3743
3745
|
onPromptChange: y,
|
|
3744
3746
|
onSubmit: be,
|
|
3745
3747
|
onStop: () => {
|
|
3746
|
-
|
|
3748
|
+
R.current?.abort(), V(), Jr(e), _("input");
|
|
3747
3749
|
},
|
|
3748
3750
|
onAccept: xe,
|
|
3749
3751
|
onRetry: () => be(b),
|
|
3750
|
-
onDiscard: () =>
|
|
3752
|
+
onDiscard: () => fe(!0),
|
|
3751
3753
|
onPopoverRef: ge
|
|
3752
3754
|
}) : null,
|
|
3753
3755
|
m === "link" ? /* @__PURE__ */ Z(Mc, {
|
|
3754
|
-
inputRef:
|
|
3756
|
+
inputRef: ae,
|
|
3755
3757
|
messages: n,
|
|
3756
3758
|
value: E,
|
|
3757
|
-
canApply: !!
|
|
3758
|
-
canOpen: !!
|
|
3759
|
+
canApply: !!de,
|
|
3760
|
+
canOpen: !!de,
|
|
3759
3761
|
canRemove: !!(O || E.trim()),
|
|
3760
3762
|
onValueChange: D,
|
|
3761
3763
|
onApply: we,
|
|
3762
3764
|
onOpen: () => Lr(E),
|
|
3763
|
-
onRemove:
|
|
3765
|
+
onRemove: Te,
|
|
3764
3766
|
onPopoverRef: ge
|
|
3765
3767
|
}) : null,
|
|
3766
3768
|
m === "color" ? /* @__PURE__ */ Z(Rc, {
|
|
@@ -3777,14 +3779,14 @@ function jc({ editor: e, lang: t = "zh", messages: n = uc, selectionSnapshot: r,
|
|
|
3777
3779
|
onTooltipChange: d,
|
|
3778
3780
|
onClose: () => h(null)
|
|
3779
3781
|
}) : null,
|
|
3780
|
-
|
|
3782
|
+
ue && m === null ? /* @__PURE__ */ Z("div", {
|
|
3781
3783
|
className: "markweave-floating-toolbar-tooltip",
|
|
3782
3784
|
role: "tooltip",
|
|
3783
3785
|
"data-testid": "markweave-floating-toolbar-tooltip",
|
|
3784
|
-
"data-button-id":
|
|
3785
|
-
"data-active":
|
|
3786
|
+
"data-button-id": ue.buttonId,
|
|
3787
|
+
"data-active": ue.active,
|
|
3786
3788
|
style: mc(f),
|
|
3787
|
-
children:
|
|
3789
|
+
children: ue.label
|
|
3788
3790
|
}) : null
|
|
3789
3791
|
]
|
|
3790
3792
|
})
|
|
@@ -3954,7 +3956,7 @@ function Nc({ inputRef: e, messages: t, phase: n, prompt: r, hasStreamedContent:
|
|
|
3954
3956
|
});
|
|
3955
3957
|
}
|
|
3956
3958
|
function Pc({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointerDown: i, onTooltipChange: a, onRun: o }) {
|
|
3957
|
-
return /* @__PURE__ */ Q(
|
|
3959
|
+
return /* @__PURE__ */ Q(mt, { children: [n ? /* @__PURE__ */ Z("span", {
|
|
3958
3960
|
className: "markweave-floating-toolbar-divider",
|
|
3959
3961
|
"aria-hidden": "true"
|
|
3960
3962
|
}) : null, /* @__PURE__ */ Z("button", {
|
|
@@ -4095,7 +4097,7 @@ function Bc({ editor: e, messages: t, activeTooltipId: n, onPopoverRef: r, onToo
|
|
|
4095
4097
|
});
|
|
4096
4098
|
}
|
|
4097
4099
|
function Vc({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipChange: i, onRun: a }) {
|
|
4098
|
-
return /* @__PURE__ */ Q(
|
|
4100
|
+
return /* @__PURE__ */ Q(mt, { children: [r ? /* @__PURE__ */ Z("span", {
|
|
4099
4101
|
className: "markweave-floating-toolbar-divider",
|
|
4100
4102
|
"aria-hidden": "true"
|
|
4101
4103
|
}) : null, /* @__PURE__ */ Q("span", {
|
|
@@ -4125,35 +4127,35 @@ var Uc = {
|
|
|
4125
4127
|
sparkles: we,
|
|
4126
4128
|
"arrow-up": x,
|
|
4127
4129
|
check: A,
|
|
4128
|
-
"chevron-down":
|
|
4129
|
-
"chevron-up":
|
|
4130
|
-
"corner-down-left":
|
|
4131
|
-
"external-link":
|
|
4130
|
+
"chevron-down": M,
|
|
4131
|
+
"chevron-up": ee,
|
|
4132
|
+
"corner-down-left": re,
|
|
4133
|
+
"external-link": I,
|
|
4132
4134
|
bold: D,
|
|
4133
|
-
italic:
|
|
4135
|
+
italic: le,
|
|
4134
4136
|
underline: Fe,
|
|
4135
|
-
strike:
|
|
4136
|
-
"inline-code":
|
|
4137
|
-
link:
|
|
4137
|
+
strike: De,
|
|
4138
|
+
"inline-code": te,
|
|
4139
|
+
link: de,
|
|
4138
4140
|
more: me,
|
|
4139
4141
|
text: Pe,
|
|
4140
|
-
"bullet-list":
|
|
4142
|
+
"bullet-list": V,
|
|
4141
4143
|
"numbered-list": H,
|
|
4142
|
-
"todo-list":
|
|
4144
|
+
"todo-list": fe,
|
|
4143
4145
|
quote: ye,
|
|
4144
4146
|
"code-block": O,
|
|
4145
|
-
superscript:
|
|
4146
|
-
subscript:
|
|
4147
|
+
superscript: ke,
|
|
4148
|
+
subscript: Oe,
|
|
4147
4149
|
math: Se,
|
|
4148
4150
|
"align-left": f,
|
|
4149
4151
|
"align-center": u,
|
|
4150
4152
|
"align-right": p,
|
|
4151
4153
|
"align-justify": d,
|
|
4152
|
-
"decrease-indent":
|
|
4153
|
-
"increase-indent":
|
|
4154
|
-
trash:
|
|
4154
|
+
"decrease-indent": B,
|
|
4155
|
+
"increase-indent": se,
|
|
4156
|
+
trash: U,
|
|
4155
4157
|
"rotate-ccw": xe,
|
|
4156
|
-
square:
|
|
4158
|
+
square: Te,
|
|
4157
4159
|
x: Re
|
|
4158
4160
|
};
|
|
4159
4161
|
function $({ name: e }) {
|
|
@@ -4296,7 +4298,7 @@ function Wc({ editor: e, messages: t, onClose: n, target: r }) {
|
|
|
4296
4298
|
className: "markweave-math-block-toolbar",
|
|
4297
4299
|
children: [
|
|
4298
4300
|
/* @__PURE__ */ Z("span", { children: u.label }),
|
|
4299
|
-
/* @__PURE__ */ Z(
|
|
4301
|
+
/* @__PURE__ */ Z(te, {
|
|
4300
4302
|
"aria-hidden": "true",
|
|
4301
4303
|
size: 15,
|
|
4302
4304
|
strokeWidth: 1.75
|
|
@@ -4353,25 +4355,25 @@ function Wc({ editor: e, messages: t, onClose: n, target: r }) {
|
|
|
4353
4355
|
//#endregion
|
|
4354
4356
|
//#region src/ui/slash-command/SlashCommandMenu.tsx
|
|
4355
4357
|
var Gc = t("zh"), Kc = {
|
|
4356
|
-
type:
|
|
4357
|
-
"heading-1":
|
|
4358
|
-
"heading-2":
|
|
4359
|
-
"heading-3":
|
|
4360
|
-
"bullet-list":
|
|
4358
|
+
type: Ne,
|
|
4359
|
+
"heading-1": ae,
|
|
4360
|
+
"heading-2": L,
|
|
4361
|
+
"heading-3": oe,
|
|
4362
|
+
"bullet-list": V,
|
|
4361
4363
|
"ordered-list": H,
|
|
4362
|
-
"task-list":
|
|
4364
|
+
"task-list": fe,
|
|
4363
4365
|
blockquote: ye,
|
|
4364
4366
|
"code-block": O,
|
|
4365
|
-
info:
|
|
4366
|
-
tip:
|
|
4367
|
+
info: ce,
|
|
4368
|
+
tip: ue,
|
|
4367
4369
|
warning: l,
|
|
4368
|
-
error:
|
|
4370
|
+
error: P,
|
|
4369
4371
|
success: j,
|
|
4370
4372
|
emoji: Ce,
|
|
4371
4373
|
math: Se,
|
|
4372
|
-
table:
|
|
4374
|
+
table: Ae,
|
|
4373
4375
|
separator: pe,
|
|
4374
|
-
image:
|
|
4376
|
+
image: R,
|
|
4375
4377
|
video: Le,
|
|
4376
4378
|
attachment: ge
|
|
4377
4379
|
};
|
|
@@ -4491,7 +4493,7 @@ function Zc({ command: e, messages: t, onBack: n, onSelect: r }) {
|
|
|
4491
4493
|
}
|
|
4492
4494
|
function Qc({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
|
|
4493
4495
|
let a = e.uploadKind ?? "attachment", [o, s] = J(""), [c, l] = J(null), [u, d] = J(null), [f, p] = J(!1), m = async (t) => {
|
|
4494
|
-
r(e, { uploadResult: await
|
|
4496
|
+
r(e, { uploadResult: await X({
|
|
4495
4497
|
kind: a,
|
|
4496
4498
|
source: t,
|
|
4497
4499
|
trigger: a === "attachment" ? "attachment-insert" : "slash-command"
|
|
@@ -4595,96 +4597,83 @@ function $c({ commands: e, messages: t = Gc, state: n, position: r, inputCommand
|
|
|
4595
4597
|
top: r.top,
|
|
4596
4598
|
maxHeight: r.maxHeight,
|
|
4597
4599
|
"--markweave-slash-menu-max-height": `${r.maxHeight}px`
|
|
4598
|
-
}, h =
|
|
4599
|
-
|
|
4600
|
-
|
|
4601
|
-
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
|
|
4607
|
-
|
|
4608
|
-
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
|
|
4612
|
-
|
|
4613
|
-
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
"data-text-icon-length": vn(t.icon) ?? void 0,
|
|
4656
|
-
"data-testid": `markweave-slash-command-${t.id}`,
|
|
4657
|
-
title: o ? t.disabledReason : void 0,
|
|
4658
|
-
onFocus: () => a?.(n),
|
|
4659
|
-
onMouseEnter: () => a?.(n),
|
|
4660
|
-
onMouseDown: (e) => e.preventDefault(),
|
|
4661
|
-
onClick: () => {
|
|
4662
|
-
if (!(!i || o)) {
|
|
4663
|
-
if (t.inputKind) {
|
|
4664
|
-
g(t);
|
|
4665
|
-
return;
|
|
4666
|
-
}
|
|
4667
|
-
s(t);
|
|
4600
|
+
}, h = (e) => o?.(e), g = () => o?.(null);
|
|
4601
|
+
return /* @__PURE__ */ Q(mt, { children: [/* @__PURE__ */ Z("div", {
|
|
4602
|
+
id: "markweave-slash-command-listbox",
|
|
4603
|
+
className: "markweave-slash-menu",
|
|
4604
|
+
style: m,
|
|
4605
|
+
role: "listbox",
|
|
4606
|
+
"aria-label": t.slash.ariaLabel,
|
|
4607
|
+
"aria-busy": l,
|
|
4608
|
+
"data-placement": r.placement,
|
|
4609
|
+
"data-testid": "markweave-slash-menu",
|
|
4610
|
+
children: i?.inputKind === "emoji" ? /* @__PURE__ */ Z(Zc, {
|
|
4611
|
+
command: i,
|
|
4612
|
+
messages: t,
|
|
4613
|
+
onBack: g,
|
|
4614
|
+
onSelect: s
|
|
4615
|
+
}) : i?.inputKind === "upload" ? /* @__PURE__ */ Z(Qc, {
|
|
4616
|
+
command: i,
|
|
4617
|
+
messages: t,
|
|
4618
|
+
onBack: g,
|
|
4619
|
+
onSelect: s,
|
|
4620
|
+
onUpload: c
|
|
4621
|
+
}) : d.empty ? /* @__PURE__ */ Z("div", {
|
|
4622
|
+
className: "markweave-slash-menu__empty",
|
|
4623
|
+
role: "option",
|
|
4624
|
+
"aria-disabled": "true",
|
|
4625
|
+
children: t.slash.noResults
|
|
4626
|
+
}) : /* @__PURE__ */ Z("div", {
|
|
4627
|
+
className: "markweave-slash-command-list",
|
|
4628
|
+
ref: f,
|
|
4629
|
+
children: p.map((t) => /* @__PURE__ */ Q("section", {
|
|
4630
|
+
className: "markweave-slash-group",
|
|
4631
|
+
"aria-label": t.group,
|
|
4632
|
+
children: [/* @__PURE__ */ Z("div", {
|
|
4633
|
+
className: "markweave-slash-group-title",
|
|
4634
|
+
children: t.group
|
|
4635
|
+
}), t.commands.map((t) => {
|
|
4636
|
+
let n = e.indexOf(t), r = n === d.activeIndex, i = yn(t), o = !!t.disabled;
|
|
4637
|
+
return /* @__PURE__ */ Q("button", {
|
|
4638
|
+
id: `markweave-slash-command-option-${n}`,
|
|
4639
|
+
type: "button",
|
|
4640
|
+
role: "option",
|
|
4641
|
+
"aria-selected": r,
|
|
4642
|
+
"aria-disabled": !i || o,
|
|
4643
|
+
"data-active": r,
|
|
4644
|
+
"data-disabled": o ? "true" : "false",
|
|
4645
|
+
"data-execution-kind": t.executionKind,
|
|
4646
|
+
"data-text-icon-length": vn(t.icon) ?? void 0,
|
|
4647
|
+
"data-testid": `markweave-slash-command-${t.id}`,
|
|
4648
|
+
title: o ? t.disabledReason : void 0,
|
|
4649
|
+
onFocus: () => a?.(n),
|
|
4650
|
+
onMouseEnter: () => a?.(n),
|
|
4651
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
4652
|
+
onClick: () => {
|
|
4653
|
+
if (!(!i || o)) {
|
|
4654
|
+
if (t.inputKind) {
|
|
4655
|
+
h(t);
|
|
4656
|
+
return;
|
|
4668
4657
|
}
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
|
|
4679
|
-
|
|
4680
|
-
/* @__PURE__ */ Z("div", {
|
|
4681
|
-
className: "markweave-slash-command-live-region",
|
|
4682
|
-
role: "status",
|
|
4683
|
-
"aria-live": "polite",
|
|
4684
|
-
"aria-atomic": "true",
|
|
4685
|
-
children: u ?? ""
|
|
4658
|
+
s(t);
|
|
4659
|
+
}
|
|
4660
|
+
},
|
|
4661
|
+
children: [
|
|
4662
|
+
/* @__PURE__ */ Z(qc, { name: t.icon }),
|
|
4663
|
+
/* @__PURE__ */ Z("span", { children: t.label }),
|
|
4664
|
+
o && t.disabledReason ? /* @__PURE__ */ Z("small", { children: t.disabledReason }) : null
|
|
4665
|
+
]
|
|
4666
|
+
}, t.id);
|
|
4667
|
+
})]
|
|
4668
|
+
}, t.group))
|
|
4686
4669
|
})
|
|
4687
|
-
|
|
4670
|
+
}), /* @__PURE__ */ Z("div", {
|
|
4671
|
+
className: "markweave-slash-command-live-region",
|
|
4672
|
+
role: "status",
|
|
4673
|
+
"aria-live": "polite",
|
|
4674
|
+
"aria-atomic": "true",
|
|
4675
|
+
children: u ?? ""
|
|
4676
|
+
})] });
|
|
4688
4677
|
}
|
|
4689
4678
|
//#endregion
|
|
4690
4679
|
//#region src/ui/table/TableControls.tsx
|
|
@@ -4701,13 +4690,13 @@ var el = t("zh"), tl = {
|
|
|
4701
4690
|
"sort-desc": S,
|
|
4702
4691
|
color: he,
|
|
4703
4692
|
alignment: f,
|
|
4704
|
-
clear:
|
|
4705
|
-
duplicate:
|
|
4706
|
-
copy:
|
|
4707
|
-
merge:
|
|
4708
|
-
split:
|
|
4693
|
+
clear: Ee,
|
|
4694
|
+
duplicate: ne,
|
|
4695
|
+
copy: ne,
|
|
4696
|
+
merge: je,
|
|
4697
|
+
split: Me,
|
|
4709
4698
|
"ask-ai": we,
|
|
4710
|
-
delete:
|
|
4699
|
+
delete: U
|
|
4711
4700
|
}, nl = {
|
|
4712
4701
|
left: f,
|
|
4713
4702
|
center: u,
|
|
@@ -4717,7 +4706,7 @@ var el = t("zh"), tl = {
|
|
|
4717
4706
|
bottom: h
|
|
4718
4707
|
};
|
|
4719
4708
|
function rl({ active: e, editor: t, interactionState: n = zn, messages: r = el, onCopyPayload: i, onCommandResult: a, askAi: o }) {
|
|
4720
|
-
let [s, c] = J(null), [l, u] = J(null), [d, f] = J("row-edge"), [p, m] = J(null), [h, g] = J(null), [_, v] = J(null), [y, b] = J(null), [x, S] = J(null), [C, w] = J(null), [T, E] = J(null), [, D] = J(0), O = q(null), k = q(null), [A, j] = J(null),
|
|
4709
|
+
let [s, c] = J(null), [l, u] = J(null), [d, f] = J("row-edge"), [p, m] = J(null), [h, g] = J(null), [_, v] = J(null), [y, b] = J(null), [x, S] = J(null), [C, w] = J(null), [T, E] = J(null), [, D] = J(0), O = q(null), k = q(null), [A, j] = J(null), M = q(null), ee = q(null), P = q(null), te = q(null), ne = q(null), re = q(null), F = q(null), I = e ? Ln(t.state) : null;
|
|
4721
4710
|
if (G(() => {
|
|
4722
4711
|
if (!A) return;
|
|
4723
4712
|
let e = window.setTimeout(() => {
|
|
@@ -4747,7 +4736,7 @@ function rl({ active: e, editor: t, interactionState: n = zn, messages: r = el,
|
|
|
4747
4736
|
return;
|
|
4748
4737
|
}
|
|
4749
4738
|
let r = () => {
|
|
4750
|
-
let e = t.view.dom.closest(".markweave-editor-frame") ?? t.view.dom.parentElement, r = Ti(t, n, "row",
|
|
4739
|
+
let e = t.view.dom.closest(".markweave-editor-frame") ?? t.view.dom.parentElement, r = Ti(t, n, "row", I?.activeCellPos ?? null), i = Ti(t, n, "column", I?.activeCellPos ?? null), a = r ? wi(t, r) : null, o = i ? wi(t, i) : null, c = ki(t, "selection").length > 0 ? Ai(t) : null, l = xi(t)?.getBoundingClientRect() ?? null;
|
|
4751
4740
|
if (!e) {
|
|
4752
4741
|
v(null), b(null), S(null), w(null), E(null);
|
|
4753
4742
|
return;
|
|
@@ -4783,9 +4772,9 @@ function rl({ active: e, editor: t, interactionState: n = zn, messages: r = el,
|
|
|
4783
4772
|
}, [
|
|
4784
4773
|
e,
|
|
4785
4774
|
t,
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4775
|
+
I?.activeCellPos,
|
|
4776
|
+
I?.selectionFrom,
|
|
4777
|
+
I?.selectionTo,
|
|
4789
4778
|
n.hoverCellPos,
|
|
4790
4779
|
n.hoverVisualColumnIndex,
|
|
4791
4780
|
n.hoverVisualRowIndex,
|
|
@@ -4797,7 +4786,7 @@ function rl({ active: e, editor: t, interactionState: n = zn, messages: r = el,
|
|
|
4797
4786
|
return;
|
|
4798
4787
|
}
|
|
4799
4788
|
let n = () => {
|
|
4800
|
-
let e = t.view.dom.closest(".markweave-editor-frame") ?? t.view.dom.parentElement, n = d === "row-edge" ?
|
|
4789
|
+
let e = t.view.dom.closest(".markweave-editor-frame") ?? t.view.dom.parentElement, n = d === "row-edge" ? ne.current : d === "column-edge" ? re.current : F.current, r = ee.current;
|
|
4801
4790
|
if (!e || !n || !r) {
|
|
4802
4791
|
m(null);
|
|
4803
4792
|
return;
|
|
@@ -4807,7 +4796,7 @@ function rl({ active: e, editor: t, interactionState: n = zn, messages: r = el,
|
|
|
4807
4796
|
top: a.top,
|
|
4808
4797
|
width: i.width,
|
|
4809
4798
|
height: i.height
|
|
4810
|
-
} : i, c = e.getBoundingClientRect(), l = r.getBoundingClientRect(), u =
|
|
4799
|
+
} : i, c = e.getBoundingClientRect(), l = r.getBoundingClientRect(), u = P.current?.scrollHeight ?? 0, f = u > 0 ? u + 12 : 0, p = mi({
|
|
4811
4800
|
anchorRect: o,
|
|
4812
4801
|
frameRect: c,
|
|
4813
4802
|
boundaryRect: Ei(e),
|
|
@@ -4836,7 +4825,7 @@ function rl({ active: e, editor: t, interactionState: n = zn, messages: r = el,
|
|
|
4836
4825
|
return;
|
|
4837
4826
|
}
|
|
4838
4827
|
let n = () => {
|
|
4839
|
-
let e = t.view.dom.closest(".markweave-editor-frame") ?? t.view.dom.parentElement, n =
|
|
4828
|
+
let e = t.view.dom.closest(".markweave-editor-frame") ?? t.view.dom.parentElement, n = ee.current, r = te.current, i = n?.querySelector(`[data-submenu-trigger="${l}"]`);
|
|
4840
4829
|
if (!e || !n || !r || !i) {
|
|
4841
4830
|
g(null);
|
|
4842
4831
|
return;
|
|
@@ -4853,7 +4842,7 @@ function rl({ active: e, editor: t, interactionState: n = zn, messages: r = el,
|
|
|
4853
4842
|
}));
|
|
4854
4843
|
};
|
|
4855
4844
|
n();
|
|
4856
|
-
let r =
|
|
4845
|
+
let r = P.current;
|
|
4857
4846
|
return r?.addEventListener("scroll", n), window.addEventListener("resize", n), window.addEventListener("scroll", n, !0), () => {
|
|
4858
4847
|
r?.removeEventListener("scroll", n), window.removeEventListener("resize", n), window.removeEventListener("scroll", n, !0);
|
|
4859
4848
|
};
|
|
@@ -4874,7 +4863,7 @@ function rl({ active: e, editor: t, interactionState: n = zn, messages: r = el,
|
|
|
4874
4863
|
c(null), u(null), t.view.focus();
|
|
4875
4864
|
}
|
|
4876
4865
|
}, r = (e) => {
|
|
4877
|
-
e.target instanceof Node &&
|
|
4866
|
+
e.target instanceof Node && M.current?.contains(e.target) || (c(null), u(null));
|
|
4878
4867
|
};
|
|
4879
4868
|
return document.addEventListener("keydown", n), document.addEventListener("mousedown", r), () => {
|
|
4880
4869
|
document.removeEventListener("keydown", n), document.removeEventListener("mousedown", r);
|
|
@@ -4885,17 +4874,17 @@ function rl({ active: e, editor: t, interactionState: n = zn, messages: r = el,
|
|
|
4885
4874
|
s,
|
|
4886
4875
|
l
|
|
4887
4876
|
]), !e) return null;
|
|
4888
|
-
let
|
|
4877
|
+
let ie = (e, t) => {
|
|
4889
4878
|
let n = s === e && d === t;
|
|
4890
4879
|
f(t), c(n ? null : e), u(null);
|
|
4891
|
-
},
|
|
4880
|
+
}, ae = () => {
|
|
4892
4881
|
t.view.dispatch(li(t.state.tr, null));
|
|
4893
|
-
},
|
|
4894
|
-
let i = n.hoverCellPos ??
|
|
4895
|
-
i !== null && Ni(t, i, e, { visualIndex: a }),
|
|
4896
|
-
},
|
|
4897
|
-
|
|
4898
|
-
},
|
|
4882
|
+
}, L = (e, r) => {
|
|
4883
|
+
let i = n.hoverCellPos ?? I?.activeCellPos ?? null, a = n.hoverCellPos === null ? null : e === "row" ? n.hoverVisualRowIndex : n.hoverVisualColumnIndex;
|
|
4884
|
+
i !== null && Ni(t, i, e, { visualIndex: a }), ie(e, r);
|
|
4885
|
+
}, oe = () => {
|
|
4886
|
+
ae(), ie("selection", "selection-edge");
|
|
4887
|
+
}, R = Ti(t, n, "row", I?.activeCellPos ?? null), z = Ti(t, n, "column", I?.activeCellPos ?? null), B = o?.enabled === !0 && typeof o.handler == "function", se = ui(t.state, "structure"), ce = ki(t, "selection", { askAiEnabled: B }).length > 0, le = s ? ki(t, s, { askAiEnabled: B }) : [], ue = async (e, n) => {
|
|
4899
4888
|
let o = await yi({
|
|
4900
4889
|
editor: t,
|
|
4901
4890
|
commandId: e,
|
|
@@ -4903,15 +4892,15 @@ function rl({ active: e, editor: t, interactionState: n = zn, messages: r = el,
|
|
|
4903
4892
|
messages: r
|
|
4904
4893
|
});
|
|
4905
4894
|
return o.copyFeedback ? (j(o.copyFeedback), o.copyPayload && i?.(o.copyPayload)) : j(null), a?.(o.commandResult), o.success;
|
|
4906
|
-
},
|
|
4907
|
-
!
|
|
4908
|
-
}, B = (e) => {
|
|
4909
|
-
s !== "row" && s !== "column" || e(s) && D((e) => e + 1);
|
|
4895
|
+
}, de = (e) => {
|
|
4896
|
+
!B || !ai(t, e) || (c(null), u(null));
|
|
4910
4897
|
}, V = (e) => {
|
|
4911
|
-
|
|
4912
|
-
|
|
4898
|
+
s !== "row" && s !== "column" || e(s) && D((e) => e + 1);
|
|
4899
|
+
}, fe = (e) => {
|
|
4900
|
+
let r = e === "row" ? R : z, i = n.hoverCellPos ?? I?.activeCellPos ?? null;
|
|
4901
|
+
!r || i === null || zi(t, i, e, { visualIndex: r.index }) && ue(e === "row" ? "add-row-after" : "add-column-after", e);
|
|
4913
4902
|
}, H = (e, t, n) => {
|
|
4914
|
-
if (!
|
|
4903
|
+
if (!se) {
|
|
4915
4904
|
n.preventDefault();
|
|
4916
4905
|
return;
|
|
4917
4906
|
}
|
|
@@ -4928,7 +4917,7 @@ function rl({ active: e, editor: t, interactionState: n = zn, messages: r = el,
|
|
|
4928
4917
|
}
|
|
4929
4918
|
}, he = s === "row" || s === "column" ? Ci(t, s) : null;
|
|
4930
4919
|
return /* @__PURE__ */ Q("div", {
|
|
4931
|
-
ref:
|
|
4920
|
+
ref: M,
|
|
4932
4921
|
className: "markweave-table-controls",
|
|
4933
4922
|
"data-testid": "markweave-table-controls",
|
|
4934
4923
|
"aria-label": r.table.controlsAriaLabel,
|
|
@@ -4950,30 +4939,30 @@ function rl({ active: e, editor: t, interactionState: n = zn, messages: r = el,
|
|
|
4950
4939
|
}) : null,
|
|
4951
4940
|
_ ? /* @__PURE__ */ Z("button", {
|
|
4952
4941
|
type: "button",
|
|
4953
|
-
ref:
|
|
4942
|
+
ref: ne,
|
|
4954
4943
|
className: "markweave-table-edge-handle markweave-table-edge-handle--row",
|
|
4955
4944
|
"aria-label": r.table.activeRowActions,
|
|
4956
4945
|
"aria-expanded": s === "row" && d === "row-edge",
|
|
4957
4946
|
"aria-haspopup": "menu",
|
|
4958
4947
|
title: r.table.rowActions,
|
|
4959
4948
|
"data-testid": "markweave-table-hover-row-handle",
|
|
4960
|
-
"data-axis-index":
|
|
4961
|
-
"data-axis-selected-cells":
|
|
4962
|
-
"data-axis-visual-cells":
|
|
4963
|
-
"data-axis-visual-size":
|
|
4949
|
+
"data-axis-index": R?.index ?? "",
|
|
4950
|
+
"data-axis-selected-cells": R?.selectedCellCount ?? "",
|
|
4951
|
+
"data-axis-visual-cells": R?.visualCellCount ?? "",
|
|
4952
|
+
"data-axis-visual-size": R?.visualHeight ?? "",
|
|
4964
4953
|
style: {
|
|
4965
4954
|
left: _.left,
|
|
4966
4955
|
top: _.top,
|
|
4967
4956
|
width: _.width,
|
|
4968
4957
|
height: _.height
|
|
4969
4958
|
},
|
|
4970
|
-
draggable:
|
|
4971
|
-
onDragStart: (e) => H("row",
|
|
4959
|
+
draggable: se,
|
|
4960
|
+
onDragStart: (e) => H("row", R?.index ?? 0, e),
|
|
4972
4961
|
onDragEnd: () => {
|
|
4973
4962
|
O.current = null, k.current = null;
|
|
4974
4963
|
},
|
|
4975
4964
|
onClick: () => {
|
|
4976
|
-
|
|
4965
|
+
L("row", "row-edge");
|
|
4977
4966
|
},
|
|
4978
4967
|
children: /* @__PURE__ */ Z(me, {
|
|
4979
4968
|
"aria-hidden": "true",
|
|
@@ -4982,37 +4971,37 @@ function rl({ active: e, editor: t, interactionState: n = zn, messages: r = el,
|
|
|
4982
4971
|
}) : null,
|
|
4983
4972
|
y ? /* @__PURE__ */ Z("button", {
|
|
4984
4973
|
type: "button",
|
|
4985
|
-
ref:
|
|
4974
|
+
ref: re,
|
|
4986
4975
|
className: "markweave-table-edge-handle markweave-table-edge-handle--column",
|
|
4987
4976
|
"aria-label": r.table.activeColumnActions,
|
|
4988
4977
|
"aria-expanded": s === "column" && d === "column-edge",
|
|
4989
4978
|
"aria-haspopup": "menu",
|
|
4990
4979
|
title: r.table.columnActions,
|
|
4991
4980
|
"data-testid": "markweave-table-hover-column-handle",
|
|
4992
|
-
"data-axis-index":
|
|
4993
|
-
"data-axis-selected-cells":
|
|
4994
|
-
"data-axis-visual-cells":
|
|
4995
|
-
"data-axis-visual-size":
|
|
4981
|
+
"data-axis-index": z?.index ?? "",
|
|
4982
|
+
"data-axis-selected-cells": z?.selectedCellCount ?? "",
|
|
4983
|
+
"data-axis-visual-cells": z?.visualCellCount ?? "",
|
|
4984
|
+
"data-axis-visual-size": z?.visualWidth ?? "",
|
|
4996
4985
|
style: {
|
|
4997
4986
|
left: y.left,
|
|
4998
4987
|
top: y.top,
|
|
4999
4988
|
width: y.width,
|
|
5000
4989
|
height: y.height
|
|
5001
4990
|
},
|
|
5002
|
-
draggable:
|
|
5003
|
-
onDragStart: (e) => H("column",
|
|
4991
|
+
draggable: se,
|
|
4992
|
+
onDragStart: (e) => H("column", z?.index ?? 0, e),
|
|
5004
4993
|
onDragEnd: () => {
|
|
5005
4994
|
O.current = null, k.current = null;
|
|
5006
4995
|
},
|
|
5007
4996
|
onClick: () => {
|
|
5008
|
-
|
|
4997
|
+
L("column", "column-edge");
|
|
5009
4998
|
},
|
|
5010
4999
|
children: /* @__PURE__ */ Z(me, {
|
|
5011
5000
|
"aria-hidden": "true",
|
|
5012
5001
|
size: 14
|
|
5013
5002
|
})
|
|
5014
5003
|
}) : null,
|
|
5015
|
-
|
|
5004
|
+
se && C ? /* @__PURE__ */ Z("button", {
|
|
5016
5005
|
type: "button",
|
|
5017
5006
|
className: "markweave-table-extend-button markweave-table-extend-button--row",
|
|
5018
5007
|
"aria-label": r.table.addRow,
|
|
@@ -5025,13 +5014,13 @@ function rl({ active: e, editor: t, interactionState: n = zn, messages: r = el,
|
|
|
5025
5014
|
height: C.height
|
|
5026
5015
|
},
|
|
5027
5016
|
onMouseDown: (e) => e.preventDefault(),
|
|
5028
|
-
onClick: () =>
|
|
5017
|
+
onClick: () => fe("row"),
|
|
5029
5018
|
children: /* @__PURE__ */ Z(ve, {
|
|
5030
5019
|
"aria-hidden": "true",
|
|
5031
5020
|
size: 16
|
|
5032
5021
|
})
|
|
5033
5022
|
}) : null,
|
|
5034
|
-
|
|
5023
|
+
se && T ? /* @__PURE__ */ Z("button", {
|
|
5035
5024
|
type: "button",
|
|
5036
5025
|
className: "markweave-table-extend-button markweave-table-extend-button--column",
|
|
5037
5026
|
"aria-label": r.table.addColumn,
|
|
@@ -5044,15 +5033,15 @@ function rl({ active: e, editor: t, interactionState: n = zn, messages: r = el,
|
|
|
5044
5033
|
height: T.height
|
|
5045
5034
|
},
|
|
5046
5035
|
onMouseDown: (e) => e.preventDefault(),
|
|
5047
|
-
onClick: () =>
|
|
5036
|
+
onClick: () => fe("column"),
|
|
5048
5037
|
children: /* @__PURE__ */ Z(ve, {
|
|
5049
5038
|
"aria-hidden": "true",
|
|
5050
5039
|
size: 16
|
|
5051
5040
|
})
|
|
5052
5041
|
}) : null,
|
|
5053
|
-
|
|
5042
|
+
ce && x ? /* @__PURE__ */ Z("button", {
|
|
5054
5043
|
type: "button",
|
|
5055
|
-
ref:
|
|
5044
|
+
ref: F,
|
|
5056
5045
|
className: "markweave-table-edge-handle markweave-table-edge-handle--selection",
|
|
5057
5046
|
"aria-label": r.table.selectionActions,
|
|
5058
5047
|
"aria-expanded": s === "selection" && d === "selection-edge",
|
|
@@ -5066,14 +5055,14 @@ function rl({ active: e, editor: t, interactionState: n = zn, messages: r = el,
|
|
|
5066
5055
|
height: x.height
|
|
5067
5056
|
},
|
|
5068
5057
|
onMouseDown: (e) => e.preventDefault(),
|
|
5069
|
-
onClick:
|
|
5058
|
+
onClick: oe,
|
|
5070
5059
|
children: /* @__PURE__ */ Z(me, {
|
|
5071
5060
|
"aria-hidden": "true",
|
|
5072
5061
|
size: 14
|
|
5073
5062
|
})
|
|
5074
5063
|
}) : null,
|
|
5075
5064
|
s ? /* @__PURE__ */ Q("div", {
|
|
5076
|
-
ref:
|
|
5065
|
+
ref: ee,
|
|
5077
5066
|
className: "markweave-table-menu",
|
|
5078
5067
|
role: "menu",
|
|
5079
5068
|
"aria-label": Li(s, r),
|
|
@@ -5088,11 +5077,11 @@ function rl({ active: e, editor: t, interactionState: n = zn, messages: r = el,
|
|
|
5088
5077
|
onKeyDown: pe,
|
|
5089
5078
|
children: [
|
|
5090
5079
|
/* @__PURE__ */ Z("div", {
|
|
5091
|
-
ref:
|
|
5080
|
+
ref: P,
|
|
5092
5081
|
className: "markweave-table-menu-scroll",
|
|
5093
5082
|
style: p ? { maxHeight: Math.max(1, p.maxHeight - 12) } : void 0,
|
|
5094
|
-
children:
|
|
5095
|
-
let i = Di(e), a = n === 0 ? i : Di(
|
|
5083
|
+
children: le.map((e, n) => {
|
|
5084
|
+
let i = Di(e), a = n === 0 ? i : Di(le[n - 1]), o = n > 0 && a !== i, d = s === "row" || s === "column" ? s : "selection", f = e.submenuId ? !0 : e.id === "edit-with-ai" ? B && qr(t, d) : e.commandId === null ? !1 : vi(t, e.commandId), p = Oi(e, r), m = tl[e.icon];
|
|
5096
5085
|
return /* @__PURE__ */ Q("button", {
|
|
5097
5086
|
type: "button",
|
|
5098
5087
|
role: "menuitem",
|
|
@@ -5101,14 +5090,14 @@ function rl({ active: e, editor: t, interactionState: n = zn, messages: r = el,
|
|
|
5101
5090
|
"aria-haspopup": e.submenuId ? "menu" : void 0,
|
|
5102
5091
|
"aria-expanded": e.submenuId ? l === e.submenuId : void 0,
|
|
5103
5092
|
disabled: !f,
|
|
5104
|
-
title: e.id === "edit-with-ai" &&
|
|
5093
|
+
title: e.id === "edit-with-ai" && B && !f ? r.askAi.tableMergedUnsupported : void 0,
|
|
5105
5094
|
"data-menu-group": i,
|
|
5106
5095
|
"data-starts-group": o ? "true" : "false",
|
|
5107
5096
|
"data-command-enabled": f ? "true" : "false",
|
|
5108
5097
|
"data-submenu-trigger": e.submenuId ?? void 0,
|
|
5109
5098
|
"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",
|
|
5110
5099
|
onMouseDown: (t) => {
|
|
5111
|
-
t.preventDefault(), f && e.id === "edit-with-ai" &&
|
|
5100
|
+
t.preventDefault(), f && e.id === "edit-with-ai" && de(d);
|
|
5112
5101
|
},
|
|
5113
5102
|
onMouseEnter: () => u(e.submenuId),
|
|
5114
5103
|
onClick: (t) => {
|
|
@@ -5118,10 +5107,10 @@ function rl({ active: e, editor: t, interactionState: n = zn, messages: r = el,
|
|
|
5118
5107
|
return;
|
|
5119
5108
|
}
|
|
5120
5109
|
if (e.commandId === null) {
|
|
5121
|
-
t.detail === 0 &&
|
|
5110
|
+
t.detail === 0 && de(d);
|
|
5122
5111
|
return;
|
|
5123
5112
|
}
|
|
5124
|
-
|
|
5113
|
+
ue(e.commandId).finally(() => {
|
|
5125
5114
|
c(null), u(null);
|
|
5126
5115
|
});
|
|
5127
5116
|
}
|
|
@@ -5139,7 +5128,7 @@ function rl({ active: e, editor: t, interactionState: n = zn, messages: r = el,
|
|
|
5139
5128
|
className: "markweave-table-menu-item-label",
|
|
5140
5129
|
children: p
|
|
5141
5130
|
}),
|
|
5142
|
-
e.submenuId ? /* @__PURE__ */ Z(
|
|
5131
|
+
e.submenuId ? /* @__PURE__ */ Z(N, {
|
|
5143
5132
|
className: "markweave-table-menu-chevron",
|
|
5144
5133
|
"aria-hidden": "true",
|
|
5145
5134
|
size: 16
|
|
@@ -5149,7 +5138,7 @@ function rl({ active: e, editor: t, interactionState: n = zn, messages: r = el,
|
|
|
5149
5138
|
})
|
|
5150
5139
|
}),
|
|
5151
5140
|
l === "color" && (s === "row" || s === "column") ? /* @__PURE__ */ Q("div", {
|
|
5152
|
-
ref:
|
|
5141
|
+
ref: te,
|
|
5153
5142
|
className: "markweave-table-submenu markweave-table-color-menu",
|
|
5154
5143
|
role: "menu",
|
|
5155
5144
|
"aria-label": r.table.submenus.color,
|
|
@@ -5174,7 +5163,7 @@ function rl({ active: e, editor: t, interactionState: n = zn, messages: r = el,
|
|
|
5174
5163
|
"data-active": he?.textColorId === e.id ? "true" : "false",
|
|
5175
5164
|
"data-testid": `markweave-table-text-color-${e.id}`,
|
|
5176
5165
|
onMouseDown: (e) => e.preventDefault(),
|
|
5177
|
-
onClick: () =>
|
|
5166
|
+
onClick: () => V((n) => pi(t, n, e.id)),
|
|
5178
5167
|
children: [/* @__PURE__ */ Z("span", {
|
|
5179
5168
|
className: "markweave-table-color-swatch markweave-table-text-color-swatch",
|
|
5180
5169
|
"aria-hidden": "true",
|
|
@@ -5193,7 +5182,7 @@ function rl({ active: e, editor: t, interactionState: n = zn, messages: r = el,
|
|
|
5193
5182
|
"data-active": he?.backgroundColorId === e.id ? "true" : "false",
|
|
5194
5183
|
"data-testid": `markweave-table-background-color-${e.id}`,
|
|
5195
5184
|
onMouseDown: (e) => e.preventDefault(),
|
|
5196
|
-
onClick: () =>
|
|
5185
|
+
onClick: () => V((n) => fi(t, n, e.id)),
|
|
5197
5186
|
children: [/* @__PURE__ */ Z("span", {
|
|
5198
5187
|
className: "markweave-table-color-swatch",
|
|
5199
5188
|
"aria-hidden": "true",
|
|
@@ -5203,7 +5192,7 @@ function rl({ active: e, editor: t, interactionState: n = zn, messages: r = el,
|
|
|
5203
5192
|
]
|
|
5204
5193
|
}) : null,
|
|
5205
5194
|
l === "alignment" && (s === "row" || s === "column") ? /* @__PURE__ */ Q("div", {
|
|
5206
|
-
ref:
|
|
5195
|
+
ref: te,
|
|
5207
5196
|
className: "markweave-table-submenu markweave-table-alignment-menu",
|
|
5208
5197
|
role: "menu",
|
|
5209
5198
|
"aria-label": r.table.submenus.alignment,
|
|
@@ -5226,7 +5215,7 @@ function rl({ active: e, editor: t, interactionState: n = zn, messages: r = el,
|
|
|
5226
5215
|
"data-active": i ? "true" : "false",
|
|
5227
5216
|
"data-testid": `markweave-table-alignment-${e}`,
|
|
5228
5217
|
onMouseDown: (e) => e.preventDefault(),
|
|
5229
|
-
onClick: () =>
|
|
5218
|
+
onClick: () => V((n) => di(t, n, e)),
|
|
5230
5219
|
children: [/* @__PURE__ */ Z(n, {
|
|
5231
5220
|
"aria-hidden": "true",
|
|
5232
5221
|
size: 18,
|
|
@@ -5244,7 +5233,7 @@ function rl({ active: e, editor: t, interactionState: n = zn, messages: r = el,
|
|
|
5244
5233
|
"data-active": i ? "true" : "false",
|
|
5245
5234
|
"data-testid": `markweave-table-alignment-${e}`,
|
|
5246
5235
|
onMouseDown: (e) => e.preventDefault(),
|
|
5247
|
-
onClick: () =>
|
|
5236
|
+
onClick: () => V((n) => di(t, n, e)),
|
|
5248
5237
|
children: [/* @__PURE__ */ Z(n, {
|
|
5249
5238
|
"aria-hidden": "true",
|
|
5250
5239
|
size: 18,
|
|
@@ -5403,19 +5392,19 @@ function ml(e, t) {
|
|
|
5403
5392
|
return r && e.id === r.id && e.label === r.label && e.description === r.description && e.group === r.group && e.disabled === r.disabled && e.disabledReason === r.disabledReason && JSON.stringify(e.icon) === JSON.stringify(r.icon);
|
|
5404
5393
|
});
|
|
5405
5394
|
}
|
|
5406
|
-
function hl({ askAi: e, ariaLabel: r, autoFocusFirstTableBodyCell: i = !1, autofocus: a = !1, content: o, contentFormat: s, defaultContent: l = "", defaultContentFormat: u, editable: d = !0, innerToc: f = !0, innerTocPlacement: p, lang: m, mode: h = "live", theme: g, canvasColor: _, onEditWithAi: v, onExtractToNote: y, onRewriteSelection: b, onAiEditControllerChange: x, onRuntimeStateChange: S, onSearchControllerChange: C, commandGroups: w, commands: T, builtinCommands: E, editorExtensions: D, onCommandControllerChange: O, onCommandError: k, onSlashCommandUpload: A, onAttachmentDownload: j, onTableCommandResult:
|
|
5407
|
-
let
|
|
5408
|
-
editorMode:
|
|
5409
|
-
effectiveEditable:
|
|
5395
|
+
function hl({ askAi: e, ariaLabel: r, autoFocusFirstTableBodyCell: i = !1, autofocus: a = !1, content: o, contentFormat: s, defaultContent: l = "", defaultContentFormat: u, editable: d = !0, innerToc: f = !0, innerTocPlacement: p, lang: m, mode: h = "live", theme: g, canvasColor: _, onEditWithAi: v, onExtractToNote: y, onRewriteSelection: b, onAiEditControllerChange: x, onRuntimeStateChange: S, onSearchControllerChange: C, commandGroups: w, commands: T, builtinCommands: E, editorExtensions: D, onCommandControllerChange: O, onCommandError: k, onSlashCommandUpload: A, onAttachmentDownload: j, onTableCommandResult: M, onTableCopyPayload: N, tableCapabilities: ee, onTocChange: P, onUpdate: te, linkCardResolver: ne, resolveMediaSource: re, referenceSuggestion: F, internalLinkCard: I } = {}) {
|
|
5396
|
+
let ie = We(h), ae = Zi(g), L = Xi(_), oe = Ki(p), R = ie === "live" && d !== !1, z = At(o === void 0 ? u : s), B = o ?? l, se = typeof B == "string" && B.length >= 2e5, ce = o === void 0 && z === "markdown" && se && typeof B == "string", le = q(ce ? B : null), [ue, de] = J(ce), V = q({
|
|
5397
|
+
editorMode: ie,
|
|
5398
|
+
effectiveEditable: R
|
|
5410
5399
|
});
|
|
5411
|
-
|
|
5412
|
-
editorMode:
|
|
5413
|
-
effectiveEditable:
|
|
5400
|
+
V.current = {
|
|
5401
|
+
editorMode: ie,
|
|
5402
|
+
effectiveEditable: R
|
|
5414
5403
|
};
|
|
5415
5404
|
let fe = q(null);
|
|
5416
5405
|
fe.current === null && (fe.current = n(m));
|
|
5417
|
-
let
|
|
5418
|
-
lang:
|
|
5406
|
+
let H = fe.current, pe = K(() => t(H), [H]), me = K(() => Mn({
|
|
5407
|
+
lang: H,
|
|
5419
5408
|
commandGroups: w,
|
|
5420
5409
|
commands: T,
|
|
5421
5410
|
builtinCommands: E
|
|
@@ -5423,140 +5412,159 @@ function hl({ askAi: e, ariaLabel: r, autoFocusFirstTableBodyCell: i = !1, autof
|
|
|
5423
5412
|
E,
|
|
5424
5413
|
w,
|
|
5425
5414
|
T,
|
|
5426
|
-
|
|
5427
|
-
]),
|
|
5428
|
-
|
|
5429
|
-
let
|
|
5430
|
-
|
|
5431
|
-
let
|
|
5432
|
-
|
|
5433
|
-
let
|
|
5434
|
-
|
|
5435
|
-
let
|
|
5436
|
-
|
|
5437
|
-
let
|
|
5438
|
-
|
|
5439
|
-
let
|
|
5440
|
-
|
|
5441
|
-
let
|
|
5442
|
-
|
|
5443
|
-
let
|
|
5444
|
-
|
|
5415
|
+
H
|
|
5416
|
+
]), he = q(D), ge = q(ee);
|
|
5417
|
+
ge.current = ee;
|
|
5418
|
+
let _e = q(A);
|
|
5419
|
+
_e.current = A;
|
|
5420
|
+
let ve = q(j);
|
|
5421
|
+
ve.current = j;
|
|
5422
|
+
let ye = q(C);
|
|
5423
|
+
ye.current = C;
|
|
5424
|
+
let be = q(x);
|
|
5425
|
+
be.current = x;
|
|
5426
|
+
let xe = q(O);
|
|
5427
|
+
xe.current = O;
|
|
5428
|
+
let Se = q(k);
|
|
5429
|
+
Se.current = k;
|
|
5430
|
+
let Ce = q(ne);
|
|
5431
|
+
Ce.current = ne;
|
|
5432
|
+
let we = q(F);
|
|
5433
|
+
we.current = F;
|
|
5434
|
+
let Te = q(!!F), Ee = q(!!F?.render), De = q(!!F?.command), Oe = q(I);
|
|
5435
|
+
Oe.current = I;
|
|
5436
|
+
let ke = q(!!I), Ae = q(!!I?.resolve), je = K(() => Da({
|
|
5437
|
+
lang: H,
|
|
5445
5438
|
onImageUpload: (e) => {
|
|
5446
|
-
if (
|
|
5439
|
+
if (_e.current) return _e.current(e);
|
|
5447
5440
|
let t = pt(e);
|
|
5448
5441
|
if (!t) throw Error("File upload requires an upload handler.");
|
|
5449
5442
|
return t;
|
|
5450
5443
|
},
|
|
5451
5444
|
onVideoUpload: (e) => {
|
|
5452
|
-
if (
|
|
5445
|
+
if (_e.current) return _e.current(e);
|
|
5453
5446
|
let t = pt(e);
|
|
5454
5447
|
if (!t) throw Error("File upload requires an upload handler.");
|
|
5455
5448
|
return t;
|
|
5456
5449
|
},
|
|
5457
5450
|
onAttachmentUpload: (e) => {
|
|
5458
|
-
if (
|
|
5451
|
+
if (_e.current) return _e.current(e);
|
|
5459
5452
|
let t = pt(e);
|
|
5460
5453
|
if (!t) throw Error("File upload requires an upload handler.");
|
|
5461
5454
|
return t;
|
|
5462
5455
|
},
|
|
5463
|
-
onAttachmentDownload: (e, t) =>
|
|
5464
|
-
linkCardResolver: (e) =>
|
|
5465
|
-
resolveMediaSource:
|
|
5466
|
-
tableCapabilities: (e) =>
|
|
5467
|
-
|
|
5468
|
-
|
|
5456
|
+
onAttachmentDownload: (e, t) => ve.current?.(e, t),
|
|
5457
|
+
linkCardResolver: (e) => Ce.current?.(e) ?? Promise.resolve(null),
|
|
5458
|
+
resolveMediaSource: re,
|
|
5459
|
+
tableCapabilities: (e) => ge.current?.(e),
|
|
5460
|
+
referenceSuggestion: Te.current ? {
|
|
5461
|
+
char: we.current?.char,
|
|
5462
|
+
allowSpaces: we.current?.allowSpaces,
|
|
5463
|
+
allowedPrefixes: we.current?.allowedPrefixes,
|
|
5464
|
+
minQueryLength: we.current?.minQueryLength,
|
|
5465
|
+
debounce: we.current?.debounce,
|
|
5466
|
+
items: (e) => we.current?.items(e) ?? [],
|
|
5467
|
+
render: Ee.current ? () => we.current.render() : void 0,
|
|
5468
|
+
command: De.current ? (e) => we.current.command(e) : void 0,
|
|
5469
|
+
onInsert: (e) => we.current?.onInsert?.(e)
|
|
5470
|
+
} : null,
|
|
5471
|
+
internalLinkCard: ke.current ? {
|
|
5472
|
+
isInternalLink: (e) => Oe.current?.isInternalLink(e) ?? !1,
|
|
5473
|
+
resolve: Ae.current ? (e) => Oe.current.resolve(e) : void 0
|
|
5474
|
+
} : null,
|
|
5475
|
+
editorExtensions: he.current
|
|
5476
|
+
}), [re, H]), [Me, Ne] = J(null), [U, Pe] = J(Nn), [Fe, Ie] = J(null), [Le, Re] = J(null), [ze, Be] = J(() => gn(me.commands, H)), [Ve, He] = J(null), [Ue, Ke] = J("code"), [qe, Je] = J(null), [Ye, Xe] = J(zn), [Ze, Qe] = J(null), [$e, et] = J(0), tt = q(!1), nt = q({
|
|
5469
5477
|
content: o,
|
|
5470
|
-
format:
|
|
5471
|
-
}),
|
|
5472
|
-
|
|
5478
|
+
format: z
|
|
5479
|
+
}), rt = q(null), it = q(null), at = q({ onUpdate: te }), ot = K(() => _n(U.query, ze), [ze, U.query]);
|
|
5480
|
+
at.current = { onUpdate: te }, nt.current = {
|
|
5473
5481
|
content: o,
|
|
5474
|
-
format:
|
|
5482
|
+
format: z
|
|
5475
5483
|
};
|
|
5476
|
-
let
|
|
5477
|
-
|
|
5478
|
-
}, []),
|
|
5479
|
-
|
|
5480
|
-
|
|
5484
|
+
let st = W(() => {
|
|
5485
|
+
it.current !== null && (window.clearTimeout(it.current), it.current = null), et((e) => e + 1);
|
|
5486
|
+
}, []), ct = W(() => {
|
|
5487
|
+
it.current !== null && window.clearTimeout(it.current), it.current = window.setTimeout(() => {
|
|
5488
|
+
it.current = null, et((e) => e + 1);
|
|
5481
5489
|
}, Vt);
|
|
5482
5490
|
}, []);
|
|
5483
5491
|
G(() => () => {
|
|
5484
|
-
|
|
5492
|
+
it.current !== null && window.clearTimeout(it.current);
|
|
5485
5493
|
}, []);
|
|
5486
|
-
let
|
|
5487
|
-
|
|
5488
|
-
}, []),
|
|
5494
|
+
let lt = W(() => {
|
|
5495
|
+
Ie(null), Re(null), Pe(Nn);
|
|
5496
|
+
}, []), ut = W((e) => {
|
|
5489
5497
|
let t = Tn(e.state);
|
|
5490
5498
|
if (!t) {
|
|
5491
|
-
|
|
5499
|
+
Pe((e) => e.name === "idle" ? e : Nn), Ie(null), Re(null);
|
|
5492
5500
|
return;
|
|
5493
5501
|
}
|
|
5494
5502
|
let n = e.coordsAtPos(t.cursor), r = e.coordsAtPos(t.triggerFrom), i = e.dom.closest(".markweave-editor-frame")?.getBoundingClientRect();
|
|
5495
5503
|
if (!Dn(r, { frameRect: i })) {
|
|
5496
|
-
|
|
5504
|
+
Ie(null), Re(null), Pe(Nn);
|
|
5497
5505
|
return;
|
|
5498
5506
|
}
|
|
5499
5507
|
let a = wn(n, {
|
|
5500
5508
|
frameRect: i,
|
|
5501
5509
|
triggerRect: r
|
|
5502
5510
|
});
|
|
5503
|
-
|
|
5504
|
-
}, []),
|
|
5511
|
+
Ie((e) => Sn(e, a) ? e : a), Pe((e) => Cn(e, t));
|
|
5512
|
+
}, []), Y = W((e) => ut(e.view), [ut]), dt = W((e) => {
|
|
5505
5513
|
let t = Rt(e);
|
|
5506
|
-
|
|
5514
|
+
Ne((e) => Pt(e, t) ? e : t);
|
|
5507
5515
|
let n = dn(e);
|
|
5508
|
-
n && (pn(e, n, !0),
|
|
5516
|
+
n && (pn(e, n, !0), Je(n));
|
|
5509
5517
|
let r = Kt(e);
|
|
5510
|
-
r.active && r.language === "mermaid" &&
|
|
5511
|
-
}, []),
|
|
5512
|
-
|
|
5513
|
-
}, []),
|
|
5518
|
+
r.active && r.language === "mermaid" && Ke(r.mermaidPreviewMode);
|
|
5519
|
+
}, []), ft = W((e) => {
|
|
5520
|
+
Xe(ul(e));
|
|
5521
|
+
}, []), X = c({
|
|
5514
5522
|
shouldRerenderOnTransaction: !1,
|
|
5515
|
-
extensions:
|
|
5516
|
-
content:
|
|
5517
|
-
contentType: Dt(
|
|
5518
|
-
editable:
|
|
5523
|
+
extensions: je,
|
|
5524
|
+
content: ce ? "" : B,
|
|
5525
|
+
contentType: Dt(z),
|
|
5526
|
+
editable: R,
|
|
5519
5527
|
autofocus: a,
|
|
5520
5528
|
editorProps: {
|
|
5521
5529
|
attributes: {
|
|
5522
5530
|
class: "markweave-editor-surface",
|
|
5523
5531
|
"data-testid": "markweave-editor-surface",
|
|
5524
|
-
"data-markweave-large-document":
|
|
5532
|
+
"data-markweave-large-document": se ? "true" : "false",
|
|
5525
5533
|
autocapitalize: "off",
|
|
5526
5534
|
autocorrect: "off",
|
|
5527
5535
|
spellcheck: "false",
|
|
5528
5536
|
translate: "no"
|
|
5529
5537
|
},
|
|
5530
|
-
handleClick: (e, t, n) =>
|
|
5538
|
+
handleClick: (e, t, n) => V.current.effectiveEditable ? !1 : jt(n),
|
|
5531
5539
|
handleDOMEvents: {
|
|
5532
|
-
compositionstart: () =>
|
|
5533
|
-
compositionend: (e) => (
|
|
5540
|
+
compositionstart: () => V.current.effectiveEditable ? (Pe((e) => Pn(e, { type: "composition-start" })), Ie(null), !1) : !1,
|
|
5541
|
+
compositionend: (e) => (V.current.effectiveEditable && window.setTimeout(() => ut(e), 0), !1),
|
|
5534
5542
|
click: (e, t) => {
|
|
5535
|
-
if (
|
|
5543
|
+
if (V.current.effectiveEditable) {
|
|
5536
5544
|
let n = un(e, t);
|
|
5537
|
-
return n ? (t.preventDefault(), t.stopPropagation(),
|
|
5545
|
+
return n ? (t.preventDefault(), t.stopPropagation(), lt(), mn(e, n, !0), hn(e, n), Je(n), !0) : (Je(null), !1);
|
|
5538
5546
|
}
|
|
5539
5547
|
return jt(t);
|
|
5540
5548
|
}
|
|
5541
5549
|
}
|
|
5542
5550
|
},
|
|
5543
5551
|
onSelectionUpdate: ({ editor: e }) => {
|
|
5544
|
-
|
|
5552
|
+
dt(e);
|
|
5545
5553
|
},
|
|
5546
5554
|
onCreate: ({ editor: e }) => {
|
|
5547
|
-
i &&
|
|
5555
|
+
i && V.current.effectiveEditable && In(e), ft(e), dt(e), st();
|
|
5548
5556
|
},
|
|
5549
5557
|
onTransaction: ({ editor: e, transaction: t }) => {
|
|
5550
|
-
|
|
5558
|
+
ft(e), (t.docChanged || Qt(t)) && ct(), t.docChanged && Je((t) => {
|
|
5551
5559
|
if (!t) return null;
|
|
5552
5560
|
let n = ln(e, t.pos);
|
|
5553
5561
|
return n?.kind === t.kind ? n : null;
|
|
5554
5562
|
});
|
|
5555
5563
|
},
|
|
5556
5564
|
onUpdate: ({ editor: e }) => {
|
|
5557
|
-
|
|
5558
|
-
let r =
|
|
5559
|
-
r.content !== void 0 && t === r.format && (
|
|
5565
|
+
dt(e), V.current.effectiveEditable && Y(e), tt.current || at.current.onUpdate?.(Et(e, { onContentRead: (t, n) => {
|
|
5566
|
+
let r = nt.current;
|
|
5567
|
+
r.content !== void 0 && t === r.format && (rt.current = {
|
|
5560
5568
|
content: n,
|
|
5561
5569
|
format: t,
|
|
5562
5570
|
doc: e.state.doc
|
|
@@ -5565,127 +5573,127 @@ function hl({ askAi: e, ariaLabel: r, autoFocusFirstTableBodyCell: i = !1, autof
|
|
|
5565
5573
|
}
|
|
5566
5574
|
});
|
|
5567
5575
|
G(() => {
|
|
5568
|
-
let e =
|
|
5569
|
-
if (!
|
|
5576
|
+
let e = le.current;
|
|
5577
|
+
if (!X || !e) return;
|
|
5570
5578
|
let t = !1;
|
|
5571
5579
|
return (async () => {
|
|
5572
|
-
|
|
5580
|
+
tt.current = !0;
|
|
5573
5581
|
try {
|
|
5574
5582
|
let n = !0;
|
|
5575
5583
|
for (let r of Qi(e)) {
|
|
5576
5584
|
if (await new Promise((e) => window.setTimeout(e, 0)), t) return;
|
|
5577
|
-
let e =
|
|
5585
|
+
let e = X.markdown?.parse(r);
|
|
5578
5586
|
if (!e) throw Error("Markdown parser is unavailable.");
|
|
5579
|
-
let i =
|
|
5580
|
-
|
|
5587
|
+
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);
|
|
5588
|
+
X.view.dispatch(a.setMeta("addToHistory", !1)), n = !1;
|
|
5581
5589
|
}
|
|
5582
5590
|
if (t) return;
|
|
5583
|
-
|
|
5591
|
+
dt(X), ft(X), st(), le.current = null, de(!1);
|
|
5584
5592
|
} finally {
|
|
5585
|
-
|
|
5593
|
+
tt.current = !1;
|
|
5586
5594
|
}
|
|
5587
5595
|
})().catch(() => {
|
|
5588
|
-
t || (
|
|
5596
|
+
t || (X.commands.setContent(e, {
|
|
5589
5597
|
contentType: "markdown",
|
|
5590
5598
|
emitUpdate: !1
|
|
5591
|
-
}),
|
|
5599
|
+
}), le.current = null, de(!1));
|
|
5592
5600
|
}), () => {
|
|
5593
5601
|
t = !0;
|
|
5594
5602
|
};
|
|
5595
5603
|
}, [
|
|
5596
|
-
|
|
5597
|
-
|
|
5598
|
-
|
|
5599
|
-
|
|
5604
|
+
X,
|
|
5605
|
+
st,
|
|
5606
|
+
dt,
|
|
5607
|
+
ft
|
|
5600
5608
|
]), G(() => {
|
|
5601
|
-
if (
|
|
5602
|
-
|
|
5609
|
+
if (X) return ye.current?.($i(X)), () => {
|
|
5610
|
+
ye.current?.(null);
|
|
5603
5611
|
};
|
|
5604
|
-
}, [
|
|
5605
|
-
if (
|
|
5606
|
-
}, [
|
|
5607
|
-
if (!
|
|
5608
|
-
let e = gn(
|
|
5609
|
-
|
|
5612
|
+
}, [X]), G(() => {
|
|
5613
|
+
if (X) return xe.current?.(On(X)), () => xe.current?.(null);
|
|
5614
|
+
}, [X]), G(() => {
|
|
5615
|
+
if (!X) {
|
|
5616
|
+
let e = gn(me.commands, H);
|
|
5617
|
+
Be((t) => ml(t, e) ? t : e);
|
|
5610
5618
|
return;
|
|
5611
5619
|
}
|
|
5612
|
-
jn(
|
|
5613
|
-
|
|
5614
|
-
}), An(
|
|
5620
|
+
jn(X, me, (e) => {
|
|
5621
|
+
He(e.message), Se.current?.(e);
|
|
5622
|
+
}), An(X, z);
|
|
5615
5623
|
}, [
|
|
5616
|
-
|
|
5617
|
-
|
|
5618
|
-
|
|
5619
|
-
|
|
5624
|
+
z,
|
|
5625
|
+
me,
|
|
5626
|
+
X,
|
|
5627
|
+
H
|
|
5620
5628
|
]), G(() => {
|
|
5621
|
-
if (!
|
|
5622
|
-
let e = gn(On(
|
|
5629
|
+
if (!X) return;
|
|
5630
|
+
let e = gn(On(X).getCommands({
|
|
5623
5631
|
surface: "slash",
|
|
5624
5632
|
query: U.query
|
|
5625
|
-
}),
|
|
5626
|
-
|
|
5633
|
+
}), H);
|
|
5634
|
+
Be((t) => ml(t, e) ? t : e);
|
|
5627
5635
|
}, [
|
|
5636
|
+
me,
|
|
5637
|
+
X,
|
|
5638
|
+
R,
|
|
5628
5639
|
H,
|
|
5629
|
-
|
|
5630
|
-
|
|
5631
|
-
B,
|
|
5632
|
-
He,
|
|
5633
|
-
Ce,
|
|
5640
|
+
$e,
|
|
5641
|
+
Me,
|
|
5634
5642
|
U.query
|
|
5635
5643
|
]), G(() => {
|
|
5636
|
-
if (
|
|
5637
|
-
|
|
5644
|
+
if (X) return be.current?.(ea(X)), () => {
|
|
5645
|
+
be.current?.(null);
|
|
5638
5646
|
};
|
|
5639
|
-
}, [
|
|
5640
|
-
if (!
|
|
5641
|
-
let e =
|
|
5642
|
-
|
|
5643
|
-
mode:
|
|
5647
|
+
}, [X]), G(() => {
|
|
5648
|
+
if (!X) return;
|
|
5649
|
+
let e = R && !ue;
|
|
5650
|
+
X.setEditable(e), Ge(X, {
|
|
5651
|
+
mode: ie,
|
|
5644
5652
|
editable: e
|
|
5645
|
-
}), en(
|
|
5653
|
+
}), en(X, e ? "live" : "view"), st(), R || lt();
|
|
5646
5654
|
}, [
|
|
5647
|
-
|
|
5648
|
-
|
|
5649
|
-
|
|
5650
|
-
|
|
5651
|
-
|
|
5652
|
-
|
|
5655
|
+
lt,
|
|
5656
|
+
X,
|
|
5657
|
+
ie,
|
|
5658
|
+
R,
|
|
5659
|
+
st,
|
|
5660
|
+
ue
|
|
5653
5661
|
]), G(() => {
|
|
5654
|
-
|
|
5655
|
-
}, [
|
|
5662
|
+
X && $t(X, ae);
|
|
5663
|
+
}, [X, ae]), G(() => {
|
|
5656
5664
|
let e = At(s);
|
|
5657
|
-
if (!(!
|
|
5658
|
-
if (kt(
|
|
5659
|
-
|
|
5665
|
+
if (!(!X || o === void 0)) {
|
|
5666
|
+
if (kt(X, rt.current, o, e)) {
|
|
5667
|
+
rt.current = null;
|
|
5660
5668
|
return;
|
|
5661
5669
|
}
|
|
5662
|
-
|
|
5670
|
+
rt.current = null, !Ot(X, o, e) && (tt.current = !0, X.commands.setContent(o, {
|
|
5663
5671
|
contentType: Dt(e),
|
|
5664
5672
|
emitUpdate: !1
|
|
5665
|
-
}),
|
|
5673
|
+
}), tt.current = !1, dt(X), R && Y(X), ft(X), st());
|
|
5666
5674
|
}
|
|
5667
5675
|
}, [
|
|
5668
5676
|
o,
|
|
5669
5677
|
s,
|
|
5670
|
-
|
|
5678
|
+
R,
|
|
5679
|
+
X,
|
|
5680
|
+
st,
|
|
5681
|
+
dt,
|
|
5671
5682
|
Y,
|
|
5672
|
-
|
|
5673
|
-
rt,
|
|
5674
|
-
nt,
|
|
5675
|
-
it
|
|
5683
|
+
ft
|
|
5676
5684
|
]), G(() => {
|
|
5677
|
-
if (!
|
|
5685
|
+
if (!Fe) return;
|
|
5678
5686
|
let e = (e) => {
|
|
5679
5687
|
let t = e.target;
|
|
5680
|
-
t instanceof Element && (t.closest(".markweave-slash-menu") ||
|
|
5688
|
+
t instanceof Element && (t.closest(".markweave-slash-menu") || lt());
|
|
5681
5689
|
};
|
|
5682
5690
|
return document.addEventListener("pointerdown", e, !0), () => document.removeEventListener("pointerdown", e, !0);
|
|
5683
|
-
}, [
|
|
5684
|
-
let
|
|
5691
|
+
}, [lt, Fe]);
|
|
5692
|
+
let mt = Fe !== null;
|
|
5685
5693
|
G(() => {
|
|
5686
|
-
if (!
|
|
5694
|
+
if (!X || !mt) return;
|
|
5687
5695
|
let e = Tt(() => {
|
|
5688
|
-
|
|
5696
|
+
X.isDestroyed || ut(X.view);
|
|
5689
5697
|
}), t = (t) => {
|
|
5690
5698
|
t?.type === "scroll" && En(t.target) || e.schedule();
|
|
5691
5699
|
};
|
|
@@ -5693,129 +5701,129 @@ function hl({ askAi: e, ariaLabel: r, autoFocusFirstTableBodyCell: i = !1, autof
|
|
|
5693
5701
|
e.cancel(), window.removeEventListener("resize", t), window.removeEventListener("scroll", t, !0);
|
|
5694
5702
|
};
|
|
5695
5703
|
}, [
|
|
5696
|
-
|
|
5697
|
-
|
|
5698
|
-
|
|
5704
|
+
X,
|
|
5705
|
+
mt,
|
|
5706
|
+
ut
|
|
5699
5707
|
]);
|
|
5700
|
-
let
|
|
5701
|
-
|
|
5702
|
-
|
|
5703
|
-
|
|
5704
|
-
]),
|
|
5705
|
-
|
|
5706
|
-
|
|
5707
|
-
|
|
5708
|
-
|
|
5709
|
-
]),
|
|
5710
|
-
active:
|
|
5711
|
-
mode:
|
|
5712
|
-
source:
|
|
5708
|
+
let Z = K(() => X ? Kt(X) : cl, [
|
|
5709
|
+
X,
|
|
5710
|
+
$e,
|
|
5711
|
+
Me
|
|
5712
|
+
]), Q = K(() => X ? Ln(X.state) : sl, [
|
|
5713
|
+
X,
|
|
5714
|
+
$e,
|
|
5715
|
+
Me,
|
|
5716
|
+
Ye
|
|
5717
|
+
]), ht = Me?.currentNode === "codeBlock", gt = ht && Z.language === "mermaid", _t = K(() => X ? nn({
|
|
5718
|
+
active: gt,
|
|
5719
|
+
mode: Ue,
|
|
5720
|
+
source: Z.text
|
|
5713
5721
|
}) : ll, [
|
|
5714
|
-
|
|
5715
|
-
|
|
5716
|
-
|
|
5717
|
-
|
|
5718
|
-
]),
|
|
5719
|
-
|
|
5722
|
+
Z.text,
|
|
5723
|
+
X,
|
|
5724
|
+
gt,
|
|
5725
|
+
Ue
|
|
5726
|
+
]), vt = K(() => X && S ? Fn(X.state) : null, [
|
|
5727
|
+
X,
|
|
5720
5728
|
S,
|
|
5721
|
-
|
|
5722
|
-
]),
|
|
5723
|
-
if (!
|
|
5724
|
-
|
|
5729
|
+
$e
|
|
5730
|
+
]), yt = K(() => X ? Wi(X.state) : Vi.items, [X, $e]), bt = K(() => Gi(yt, Ze), [Ze, yt]), xt = K(() => Bi(yt, bt), [bt, yt]), St = W(() => {
|
|
5731
|
+
if (!X || !yt.length) {
|
|
5732
|
+
Qe(null);
|
|
5725
5733
|
return;
|
|
5726
5734
|
}
|
|
5727
|
-
let e = Hi(
|
|
5728
|
-
|
|
5729
|
-
}, [
|
|
5735
|
+
let e = Hi(X, yt);
|
|
5736
|
+
Qe((t) => t === e ? t : e);
|
|
5737
|
+
}, [X, yt]);
|
|
5730
5738
|
G(() => {
|
|
5731
|
-
|
|
5732
|
-
let t = Gi(
|
|
5739
|
+
Qe((e) => {
|
|
5740
|
+
let t = Gi(yt, e);
|
|
5733
5741
|
return e === t ? e : t;
|
|
5734
5742
|
});
|
|
5735
|
-
}, [
|
|
5736
|
-
if (!
|
|
5743
|
+
}, [yt]), G(() => {
|
|
5744
|
+
if (!X || !yt.length || typeof window > "u") return;
|
|
5737
5745
|
let e = null, t = () => {
|
|
5738
5746
|
e !== null && pl(e), e = fl(() => {
|
|
5739
|
-
e = null,
|
|
5747
|
+
e = null, St();
|
|
5740
5748
|
});
|
|
5741
|
-
}, n = dl(
|
|
5749
|
+
}, n = dl(X.view.dom);
|
|
5742
5750
|
return window.addEventListener("scroll", t, { passive: !0 }), window.addEventListener("resize", t), n?.addEventListener("scroll", t, { passive: !0 }), t(), () => {
|
|
5743
5751
|
window.removeEventListener("scroll", t), window.removeEventListener("resize", t), n?.removeEventListener("scroll", t), e !== null && pl(e);
|
|
5744
5752
|
};
|
|
5745
5753
|
}, [
|
|
5746
|
-
|
|
5747
|
-
|
|
5748
|
-
|
|
5754
|
+
X,
|
|
5755
|
+
yt.length,
|
|
5756
|
+
St
|
|
5749
5757
|
]);
|
|
5750
|
-
let
|
|
5751
|
-
revision:
|
|
5752
|
-
mode:
|
|
5753
|
-
editable:
|
|
5754
|
-
toc:
|
|
5755
|
-
selection:
|
|
5758
|
+
let Ct = K(() => Mt({
|
|
5759
|
+
revision: $e,
|
|
5760
|
+
mode: ie,
|
|
5761
|
+
editable: R,
|
|
5762
|
+
toc: xt,
|
|
5763
|
+
selection: Me,
|
|
5756
5764
|
slash: U,
|
|
5757
|
-
table:
|
|
5758
|
-
tableInteraction:
|
|
5759
|
-
codeBlock:
|
|
5760
|
-
mermaid:
|
|
5761
|
-
tableDebugSnapshot:
|
|
5765
|
+
table: Q,
|
|
5766
|
+
tableInteraction: Ye,
|
|
5767
|
+
codeBlock: Z,
|
|
5768
|
+
mermaid: _t,
|
|
5769
|
+
tableDebugSnapshot: vt
|
|
5762
5770
|
}), [
|
|
5763
|
-
|
|
5764
|
-
|
|
5765
|
-
|
|
5766
|
-
|
|
5767
|
-
|
|
5768
|
-
|
|
5771
|
+
Z,
|
|
5772
|
+
ie,
|
|
5773
|
+
R,
|
|
5774
|
+
_t,
|
|
5775
|
+
$e,
|
|
5776
|
+
Me,
|
|
5769
5777
|
U,
|
|
5770
|
-
|
|
5771
|
-
|
|
5772
|
-
|
|
5773
|
-
|
|
5778
|
+
vt,
|
|
5779
|
+
Q,
|
|
5780
|
+
Ye,
|
|
5781
|
+
xt
|
|
5774
5782
|
]);
|
|
5775
5783
|
G(() => {
|
|
5776
|
-
S?.(
|
|
5777
|
-
}, [S,
|
|
5778
|
-
|
|
5779
|
-
}, [
|
|
5780
|
-
let
|
|
5781
|
-
if (!
|
|
5784
|
+
S?.(Ct);
|
|
5785
|
+
}, [S, Ct]), G(() => {
|
|
5786
|
+
P?.(xt);
|
|
5787
|
+
}, [P, xt]);
|
|
5788
|
+
let Nt = W((e, t) => {
|
|
5789
|
+
if (!X || !R || !yn(e)) return;
|
|
5782
5790
|
if (e.inputKind && !t?.emoji && !t?.uploadResult) {
|
|
5783
|
-
|
|
5791
|
+
Re(e);
|
|
5784
5792
|
return;
|
|
5785
5793
|
}
|
|
5786
|
-
let n = Tn(
|
|
5787
|
-
n && (
|
|
5794
|
+
let n = Tn(X.state);
|
|
5795
|
+
n && (He(null), Pe((e) => Pn(e, { type: "execute" })), Re(null), kn(X, e.id, n, t).then((e) => {
|
|
5788
5796
|
if (e.ok && e.outcome === "applied") {
|
|
5789
|
-
|
|
5797
|
+
lt();
|
|
5790
5798
|
return;
|
|
5791
5799
|
}
|
|
5792
|
-
e.ok ||
|
|
5800
|
+
e.ok || He(e.message), Y(X), X.commands.focus();
|
|
5793
5801
|
}));
|
|
5794
5802
|
}, [
|
|
5795
|
-
|
|
5796
|
-
|
|
5797
|
-
|
|
5798
|
-
|
|
5799
|
-
]),
|
|
5800
|
-
|
|
5803
|
+
lt,
|
|
5804
|
+
R,
|
|
5805
|
+
X,
|
|
5806
|
+
Y
|
|
5807
|
+
]), Ft = W((e) => {
|
|
5808
|
+
Pe((t) => Pn(t, {
|
|
5801
5809
|
type: "set-active",
|
|
5802
5810
|
index: e,
|
|
5803
|
-
optionCount:
|
|
5811
|
+
optionCount: ot.length
|
|
5804
5812
|
}));
|
|
5805
|
-
}, [
|
|
5806
|
-
if (!
|
|
5813
|
+
}, [ot.length]), It = W((e) => {
|
|
5814
|
+
if (!X || Le || !R) return;
|
|
5807
5815
|
if (U.name === "executing" && e.key === "Escape") {
|
|
5808
|
-
e.preventDefault(), On(
|
|
5816
|
+
e.preventDefault(), On(X).cancel(), lt();
|
|
5809
5817
|
return;
|
|
5810
5818
|
}
|
|
5811
|
-
let t = bn(U,
|
|
5819
|
+
let t = bn(U, ot, e.key, { isComposing: e.nativeEvent.isComposing || wt(X.state) });
|
|
5812
5820
|
if (t.type !== "ignore") {
|
|
5813
5821
|
if (t.type === "close") {
|
|
5814
|
-
e.preventDefault(), On(
|
|
5822
|
+
e.preventDefault(), On(X).cancel(), Pe((e) => Pn(e, { type: "escape" })), lt();
|
|
5815
5823
|
return;
|
|
5816
5824
|
}
|
|
5817
5825
|
if (t.type === "move-active") {
|
|
5818
|
-
e.preventDefault(),
|
|
5826
|
+
e.preventDefault(), Pe((e) => Pn(e, {
|
|
5819
5827
|
type: "move-active",
|
|
5820
5828
|
delta: t.delta,
|
|
5821
5829
|
optionCount: t.optionCount
|
|
@@ -5823,162 +5831,162 @@ function hl({ askAi: e, ariaLabel: r, autoFocusFirstTableBodyCell: i = !1, autof
|
|
|
5823
5831
|
return;
|
|
5824
5832
|
}
|
|
5825
5833
|
if (t.type === "set-active") {
|
|
5826
|
-
e.preventDefault(),
|
|
5834
|
+
e.preventDefault(), Pe((e) => Pn(e, t));
|
|
5827
5835
|
return;
|
|
5828
5836
|
}
|
|
5829
|
-
t.type === "execute-active" && (e.preventDefault(),
|
|
5837
|
+
t.type === "execute-active" && (e.preventDefault(), Nt(t.command));
|
|
5830
5838
|
}
|
|
5831
5839
|
}, [
|
|
5832
|
-
|
|
5833
|
-
|
|
5834
|
-
|
|
5835
|
-
|
|
5836
|
-
|
|
5837
|
-
|
|
5840
|
+
lt,
|
|
5841
|
+
R,
|
|
5842
|
+
X,
|
|
5843
|
+
ot,
|
|
5844
|
+
Nt,
|
|
5845
|
+
Le,
|
|
5838
5846
|
U
|
|
5839
|
-
]),
|
|
5840
|
-
closeSlashMenu:
|
|
5841
|
-
focusFirstTableBodyCell: () =>
|
|
5847
|
+
]), Lt = K(() => ({
|
|
5848
|
+
closeSlashMenu: lt,
|
|
5849
|
+
focusFirstTableBodyCell: () => X ? In(X) : !1,
|
|
5842
5850
|
setContent: (e, t = {}) => {
|
|
5843
|
-
if (!
|
|
5851
|
+
if (!X) return !1;
|
|
5844
5852
|
let n = At(t.format);
|
|
5845
|
-
return
|
|
5853
|
+
return X.commands.setContent(e, {
|
|
5846
5854
|
contentType: Dt(n),
|
|
5847
5855
|
emitUpdate: t.emitUpdate ?? !1
|
|
5848
|
-
}), t.focusFirstTableBodyCell && In(
|
|
5856
|
+
}), t.focusFirstTableBodyCell && In(X), dt(X), R && Y(X), ft(X), st(), !0;
|
|
5849
5857
|
}
|
|
5850
5858
|
}), [
|
|
5851
|
-
|
|
5852
|
-
|
|
5859
|
+
lt,
|
|
5860
|
+
R,
|
|
5861
|
+
X,
|
|
5862
|
+
st,
|
|
5863
|
+
dt,
|
|
5853
5864
|
Y,
|
|
5854
|
-
|
|
5855
|
-
rt,
|
|
5856
|
-
nt,
|
|
5857
|
-
it
|
|
5865
|
+
ft
|
|
5858
5866
|
]);
|
|
5859
5867
|
return {
|
|
5860
|
-
editor:
|
|
5868
|
+
editor: X,
|
|
5861
5869
|
frameProps: K(() => ({
|
|
5862
5870
|
className: "markweave-editor-frame",
|
|
5863
5871
|
role: "combobox",
|
|
5864
|
-
"aria-label": r ??
|
|
5865
|
-
"aria-expanded":
|
|
5872
|
+
"aria-label": r ?? pe.common.editorAriaLabel,
|
|
5873
|
+
"aria-expanded": Fe !== null && U.name !== "executing",
|
|
5866
5874
|
"aria-controls": "markweave-slash-command-listbox",
|
|
5867
|
-
"aria-activedescendant":
|
|
5875
|
+
"aria-activedescendant": ot.length && U.name !== "executing" ? `markweave-slash-command-option-${Math.min(ot.length - 1, Math.max(0, U.activeIndex))}` : void 0,
|
|
5868
5876
|
"data-testid": "markweave-editor-frame",
|
|
5869
|
-
"data-markweave-mode":
|
|
5870
|
-
"aria-busy":
|
|
5871
|
-
"data-markweave-large-document-loading":
|
|
5872
|
-
"data-markweave-theme":
|
|
5873
|
-
style:
|
|
5877
|
+
"data-markweave-mode": ie,
|
|
5878
|
+
"aria-busy": ue || U.name === "executing",
|
|
5879
|
+
"data-markweave-large-document-loading": ue ? "true" : "false",
|
|
5880
|
+
"data-markweave-theme": ae,
|
|
5881
|
+
style: L ? { "--markweave-canvas": L } : void 0,
|
|
5874
5882
|
"data-markweave-inner-toc": f ? "true" : "false",
|
|
5875
|
-
"data-markweave-inner-toc-placement":
|
|
5876
|
-
"data-mermaid-mode":
|
|
5877
|
-
"data-table-focus-mode":
|
|
5878
|
-
onKeyDownCapture:
|
|
5883
|
+
"data-markweave-inner-toc-placement": oe,
|
|
5884
|
+
"data-mermaid-mode": _t.mode,
|
|
5885
|
+
"data-table-focus-mode": Q.mode,
|
|
5886
|
+
onKeyDownCapture: It
|
|
5879
5887
|
}), [
|
|
5880
5888
|
r,
|
|
5881
|
-
|
|
5882
|
-
|
|
5883
|
-
|
|
5889
|
+
ie,
|
|
5890
|
+
ot.length,
|
|
5891
|
+
It,
|
|
5884
5892
|
f,
|
|
5885
|
-
|
|
5886
|
-
|
|
5887
|
-
|
|
5893
|
+
ue,
|
|
5894
|
+
_t.mode,
|
|
5895
|
+
pe.common.editorAriaLabel,
|
|
5896
|
+
L,
|
|
5888
5897
|
oe,
|
|
5889
|
-
|
|
5890
|
-
|
|
5891
|
-
Ee,
|
|
5898
|
+
ae,
|
|
5899
|
+
Fe,
|
|
5892
5900
|
U.activeIndex,
|
|
5893
5901
|
U.name,
|
|
5894
|
-
|
|
5902
|
+
Q.mode
|
|
5895
5903
|
]),
|
|
5896
5904
|
overlayProps: K(() => ({
|
|
5897
|
-
floatingToolbar:
|
|
5898
|
-
editor:
|
|
5899
|
-
lang:
|
|
5900
|
-
messages:
|
|
5901
|
-
selectionSnapshot:
|
|
5905
|
+
floatingToolbar: X && R ? {
|
|
5906
|
+
editor: X,
|
|
5907
|
+
lang: H,
|
|
5908
|
+
messages: pe,
|
|
5909
|
+
selectionSnapshot: Me,
|
|
5902
5910
|
askAi: e,
|
|
5903
5911
|
onRewriteSelection: b,
|
|
5904
5912
|
onExtractToNote: y
|
|
5905
5913
|
} : null,
|
|
5906
|
-
slashCommandMenu:
|
|
5907
|
-
commands:
|
|
5914
|
+
slashCommandMenu: X && R ? {
|
|
5915
|
+
commands: ot,
|
|
5908
5916
|
state: U,
|
|
5909
|
-
position:
|
|
5910
|
-
inputCommand:
|
|
5917
|
+
position: Fe,
|
|
5918
|
+
inputCommand: Le,
|
|
5911
5919
|
busy: U.name === "executing",
|
|
5912
|
-
error:
|
|
5913
|
-
messages:
|
|
5914
|
-
onActiveIndexChange:
|
|
5915
|
-
onInputCommandChange:
|
|
5916
|
-
onSelect:
|
|
5920
|
+
error: Ve,
|
|
5921
|
+
messages: pe,
|
|
5922
|
+
onActiveIndexChange: Ft,
|
|
5923
|
+
onInputCommandChange: Re,
|
|
5924
|
+
onSelect: Nt,
|
|
5917
5925
|
onUpload: A
|
|
5918
5926
|
} : null,
|
|
5919
|
-
tableControls:
|
|
5920
|
-
editor:
|
|
5921
|
-
active:
|
|
5922
|
-
interactionState:
|
|
5923
|
-
messages:
|
|
5924
|
-
onCopyPayload:
|
|
5925
|
-
onCommandResult:
|
|
5927
|
+
tableControls: X && R ? {
|
|
5928
|
+
editor: X,
|
|
5929
|
+
active: Q.active,
|
|
5930
|
+
interactionState: Ye,
|
|
5931
|
+
messages: pe,
|
|
5932
|
+
onCopyPayload: N,
|
|
5933
|
+
onCommandResult: M,
|
|
5926
5934
|
onEditWithAi: v,
|
|
5927
5935
|
askAi: e
|
|
5928
5936
|
} : null,
|
|
5929
|
-
tableSelectionOverlay:
|
|
5930
|
-
editor:
|
|
5931
|
-
focusState:
|
|
5937
|
+
tableSelectionOverlay: X && R ? {
|
|
5938
|
+
editor: X,
|
|
5939
|
+
focusState: Q
|
|
5932
5940
|
} : null,
|
|
5933
|
-
codeBlockControls:
|
|
5934
|
-
editor:
|
|
5935
|
-
active:
|
|
5936
|
-
mermaidMode:
|
|
5937
|
-
onMermaidModeChange:
|
|
5938
|
-
readOnly: !
|
|
5941
|
+
codeBlockControls: X ? {
|
|
5942
|
+
editor: X,
|
|
5943
|
+
active: R && ht,
|
|
5944
|
+
mermaidMode: Ue,
|
|
5945
|
+
onMermaidModeChange: Ke,
|
|
5946
|
+
readOnly: !R
|
|
5939
5947
|
} : null,
|
|
5940
|
-
innerToc:
|
|
5941
|
-
editor:
|
|
5942
|
-
editable:
|
|
5943
|
-
messages:
|
|
5944
|
-
placement:
|
|
5945
|
-
state:
|
|
5948
|
+
innerToc: X && f && xt.items.length ? {
|
|
5949
|
+
editor: X,
|
|
5950
|
+
editable: R,
|
|
5951
|
+
messages: pe,
|
|
5952
|
+
placement: oe,
|
|
5953
|
+
state: xt
|
|
5946
5954
|
} : null,
|
|
5947
|
-
mathEditorPopover:
|
|
5948
|
-
editor:
|
|
5949
|
-
messages:
|
|
5950
|
-
target:
|
|
5951
|
-
onClose: () =>
|
|
5955
|
+
mathEditorPopover: X && R && qe ? {
|
|
5956
|
+
editor: X,
|
|
5957
|
+
messages: pe,
|
|
5958
|
+
target: qe,
|
|
5959
|
+
onClose: () => Je(null)
|
|
5952
5960
|
} : null
|
|
5953
5961
|
}), [
|
|
5954
|
-
|
|
5962
|
+
R,
|
|
5955
5963
|
e,
|
|
5956
|
-
|
|
5957
|
-
|
|
5964
|
+
X,
|
|
5965
|
+
ot,
|
|
5958
5966
|
f,
|
|
5959
|
-
|
|
5960
|
-
|
|
5961
|
-
|
|
5962
|
-
|
|
5967
|
+
ht,
|
|
5968
|
+
Ue,
|
|
5969
|
+
pe,
|
|
5970
|
+
qe,
|
|
5963
5971
|
v,
|
|
5964
5972
|
y,
|
|
5965
5973
|
b,
|
|
5966
5974
|
A,
|
|
5967
|
-
ee,
|
|
5968
5975
|
M,
|
|
5969
|
-
|
|
5970
|
-
|
|
5971
|
-
gt,
|
|
5972
|
-
Oe,
|
|
5976
|
+
N,
|
|
5977
|
+
Nt,
|
|
5973
5978
|
Me,
|
|
5974
|
-
|
|
5979
|
+
Ft,
|
|
5980
|
+
Le,
|
|
5981
|
+
Ve,
|
|
5982
|
+
Fe,
|
|
5975
5983
|
U,
|
|
5976
|
-
|
|
5977
|
-
|
|
5978
|
-
|
|
5984
|
+
Q,
|
|
5985
|
+
Ye,
|
|
5986
|
+
xt
|
|
5979
5987
|
]),
|
|
5980
|
-
runtimeSnapshot:
|
|
5981
|
-
actions:
|
|
5988
|
+
runtimeSnapshot: Ct,
|
|
5989
|
+
actions: Lt
|
|
5982
5990
|
};
|
|
5983
5991
|
}
|
|
5984
5992
|
function gl({ className: e, ...t }) {
|