@markweave/react 0.3.9 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -20,7 +20,7 @@ import { createMarkweaveFrameScheduler as vt } from "markweave/internal/editor-c
|
|
|
20
20
|
import { createMarkweaveEditorUpdatePayload as yt, getMarkweaveContentType as bt, isEditorContentCurrent as xt, isMarkweaveControlledContentEchoCurrent as St, normalizeMarkweaveContentFormat as Ct } from "markweave/internal/editor-core/editor-content";
|
|
21
21
|
import { openMarkweaveReadonlyLinkFromEvent as wt } from "markweave/internal/editor-core/readonly-link";
|
|
22
22
|
import { createMarkweaveEditorRuntimeSnapshot as Tt } from "markweave/internal/editor-core/runtime-snapshot";
|
|
23
|
-
import { advanceFloatingToolbarMotionState as Et, areEditorSelectionSnapshotsEquivalent as Dt, calculateFloatingToolbarFrameShift as Ot, calculateFloatingToolbarPopoverPlacement as kt, calculateFloatingToolbarTopBoundary as At, createSelectionSnapshot as jt, getFloatingToolbarFloatingOptions as Mt, getFloatingToolbarState as Nt, markweaveRuntimeProjectionDelayMs as Pt,
|
|
23
|
+
import { advanceFloatingToolbarMotionState as Et, areEditorSelectionSnapshotsEquivalent as Dt, calculateFloatingToolbarFrameShift as Ot, calculateFloatingToolbarPopoverPlacement as kt, calculateFloatingToolbarTopBoundary as At, createSelectionSnapshot as jt, getFloatingToolbarFloatingOptions as Mt, getFloatingToolbarState as Nt, markweaveRuntimeProjectionDelayMs as Pt, shouldShowFloatingToolbarForAiState as Ft, transitionFloatingToolbarState as It } from "markweave/internal/editor-core/selection-state";
|
|
24
24
|
import { codeBlockCollapsePluginKey as Lt, copyActiveCodeBlock as Rt, getActiveCodeBlockState as zt, getCodeBlockCopyFeedbackSnapshot as Bt, markweaveCodeBlockBehavior as Vt, setCodeBlockCollapsedAtPosition as Ht, setCodeBlockLanguageAtPosition as Ut, setCodeBlockMermaidPreviewModeAtPosition as Wt } from "markweave/internal/plugins/codeblock/codeblock-behavior";
|
|
25
25
|
import { isMermaidInlinePreviewTransaction as Gt, setMarkweaveMermaidTheme as Kt, setMermaidInlinePreviewEditorMode as qt, setReadonlyMermaidPreviewMode as Jt } from "markweave/internal/plugins/mermaid/mermaid-inline-preview";
|
|
26
26
|
import { getMermaidPreviewState as Yt } from "markweave/internal/plugins/mermaid/mermaid-renderer";
|
|
@@ -37,31 +37,31 @@ import { saveMarkweaveBrowserFile as Dn } from "markweave/internal/core/browser-
|
|
|
37
37
|
import { calculateCodeBlockLanguageMenuPosition as On, clampFullscreenScale as kn, codeBlockCopyFeedbackTimeoutMs as An, copyCodeBlockText as jn, createCodeBlockLanguageMenuDomId as Mn, createCodeBlockOverlayPosition as Nn, createMermaidFullscreenViewerState as Pn, createMermaidTabPosition as Fn, focusCodeBlockTarget as In, formatCodeBlockLanguageLabel as Ln, formatFullscreenZoom as Rn, getActiveCodeBlockElement as zn, getAnchoredRect as Bn, getCodeBlockLanguageItems as Vn, getCodeBlockLanguageOptionDomId as Hn, getCodeBlockPositionFromEventTarget as Un, getCodeBlockStateAtPosition as Wn, getFrameElement as Gn, getInitialCodeBlockLanguageItemIndex as Kn, getMermaidCodeBlockTargets as qn, getMermaidSvgMarkup as Jn, isCodeBlockTargetCollapsed as Yn, mergeStableMermaidTabPositions as Xn, mermaidFullscreenZoomStep as Zn, moveCodeBlockLanguageItemIndex as Qn, moveMermaidFullscreenViewer as $n, scrollCodeBlockLanguageItemIntoView as er } from "markweave/internal/plugins/codeblock/codeblock-ui-model";
|
|
38
38
|
import { BubbleMenu as tr } from "@tiptap/react/menus";
|
|
39
39
|
import { applyFloatingToolbarLink as nr, createFloatingToolbarAssistantRequest as rr, getFloatingToolbarButtonModels as ir, getFloatingToolbarHighlightColorOptions as ar, getFloatingToolbarLinkHref as or, getFloatingToolbarMessageSet as sr, getFloatingToolbarMoreActions as cr, getFloatingToolbarTextColorOptions as lr, getFloatingToolbarTooltipModel as ur, getFloatingToolbarTurnIntoOptions as dr, isFloatingToolbarMoreActionActive as fr, isFloatingToolbarTurnIntoActive as pr, openFloatingToolbarLinkHref as mr, preventFloatingToolbarPointerFocusLoss as hr, removeFloatingToolbarLink as gr, runFloatingToolbarMoreAction as _r, setFloatingToolbarHighlightColor as vr, setFloatingToolbarTextColor as yr, setFloatingToolbarTurnInto as br } from "markweave/internal/editor-core/floating-toolbar-model";
|
|
40
|
-
import { MarkweaveAskAiError as xr, acceptMarkweaveAskAiResult as Sr, calculateMarkweaveAskAiPanelPosition as Cr, canStartMarkweaveAskAiTableTarget as wr, clearMarkweaveAskAiPreview as Tr, clearMarkweaveAskAiTarget as Er, createMarkweaveAskAiRequest as Dr, getMappedMarkweaveAskAiSelection as Or, getMarkweaveAskAiSurfaceRect as kr, getMarkweaveAskAiTarget as Ar, getMarkweaveAskAiTargetRect as jr,
|
|
41
|
-
import { normalizeMarkdownLinkHref as
|
|
42
|
-
import { setMarkweaveTableMenuAxisTarget as
|
|
43
|
-
import { applyTableAxisAlignment as
|
|
44
|
-
import { createMarkweaveTocState as
|
|
45
|
-
import { normalizeMarkweaveCanvasColor as
|
|
46
|
-
import { splitMarkweaveLargeMarkdown as
|
|
47
|
-
import { createMarkweaveSearchController as
|
|
48
|
-
import { createMarkweaveAiEditController as
|
|
40
|
+
import { MarkweaveAskAiError as xr, acceptMarkweaveAskAiResult as Sr, calculateMarkweaveAskAiPanelPosition as Cr, canStartMarkweaveAskAiTableTarget as wr, clearMarkweaveAskAiPreview as Tr, clearMarkweaveAskAiTarget as Er, createMarkweaveAskAiRequest as Dr, getMappedMarkweaveAskAiSelection as Or, getMarkweaveAskAiSurfaceRect as kr, getMarkweaveAskAiTarget as Ar, getMarkweaveAskAiTargetRect as jr, hasMarkweaveAskAiPreview as Mr, restoreMarkweaveAskAiTargetSelection as Nr, runMarkweaveAskAiHandler as Pr, setMarkweaveAskAiPreview as Fr, startMarkweaveAskAiTableTarget as Ir, startMarkweaveAskAiTarget as Lr } from "markweave/internal/plugins/ask-ai/ask-ai-session";
|
|
41
|
+
import { normalizeMarkdownLinkHref as Rr } from "markweave/internal/plugins/markdown/markdown-input";
|
|
42
|
+
import { setMarkweaveTableMenuAxisTarget as zr } from "markweave/internal/plugins/table/table-clipboard";
|
|
43
|
+
import { applyTableAxisAlignment as Br, applyTableAxisBackgroundColor as Vr, applyTableAxisTextColor as Hr, calculateAnchoredTableMenuPosition as Ur, calculateAnchoredTableSubmenuPosition as Wr, calculateTableAxisHandleLayout as Gr, calculateTableExtendButtonLayout as Kr, canRunTableCommand as qr, executeTableMenuCommand as Jr, formatTableCopyFeedback as Yr, getActiveTableElement as Xr, getTableAxisDropIndexAtPoint as Zr, getTableAxisFormattingState as Qr, getTableAxisTargetRect as $r, getTableControlAxisSelectionModel as ei, getTableMenuBoundaryRect as ti, getTableMenuItemGroup as ni, getTableMenuItemLabel as ri, getTableMenuItems as ii, getTableSelectionTargetRect as ai, measureTableSelectionOverlay as oi, moveTargetedTableAxis as si, selectTableAxisFromCell as ci, tableColorOptions as li, tableCopyFeedbackTimeoutMs as ui, tableHorizontalAlignmentOptions as di, tableMenuLabel as fi, tableVerticalAlignmentOptions as pi, targetTableAxisFromCell as mi } from "markweave/internal/plugins/table/table-ui-model";
|
|
44
|
+
import { createMarkweaveTocState as hi, emptyMarkweaveTocState as gi, getActiveMarkweaveTocId as _i, getMarkweaveTocItemsFromState as vi, getValidMarkweaveTocActiveId as yi, normalizeMarkweaveInnerTocPlacement as bi, observeMarkweaveInnerTocContainerPosition as xi, scrollToMarkweaveTocItem as Si } from "markweave/internal/core/toc-state";
|
|
45
|
+
import { normalizeMarkweaveCanvasColor as Ci, normalizeMarkweaveTheme as wi } from "markweave/internal/core/theme";
|
|
46
|
+
import { splitMarkweaveLargeMarkdown as Ti } from "markweave/internal/core/large-document";
|
|
47
|
+
import { createMarkweaveSearchController as Ei } from "markweave/internal/plugins/search/search-controller";
|
|
48
|
+
import { createMarkweaveAiEditController as Di } from "markweave/internal/plugins/ai-edit/ai-edit-controller";
|
|
49
49
|
//#region src/editor-mode-state.ts
|
|
50
|
-
var
|
|
50
|
+
var Oi = {
|
|
51
51
|
mode: "live",
|
|
52
52
|
editable: !0
|
|
53
53
|
};
|
|
54
|
-
function
|
|
55
|
-
return Re((t) => at(e, t), () => tt(e), () =>
|
|
54
|
+
function ki(e) {
|
|
55
|
+
return Re((t) => at(e, t), () => tt(e), () => Oi);
|
|
56
56
|
}
|
|
57
57
|
//#endregion
|
|
58
58
|
//#region src/media/image-node.tsx
|
|
59
|
-
var
|
|
60
|
-
function
|
|
59
|
+
var Ai = Ze;
|
|
60
|
+
function ji(e) {
|
|
61
61
|
return e instanceof Element && !!e.closest("[data-markweave-image-ui=\"true\"]");
|
|
62
62
|
}
|
|
63
|
-
function
|
|
64
|
-
let { deleteNode: t, editor: r, getPos: i, node: o, selected: s, updateAttributes: c } = e, l = e.extension.options, u = l.messages ?? n("zh"), d = u.image, f = nt(
|
|
63
|
+
function Mi(e) {
|
|
64
|
+
let { deleteNode: t, editor: r, getPos: i, node: o, selected: s, updateAttributes: c } = e, l = e.extension.options, u = l.messages ?? n("zh"), d = u.image, f = nt(ki(r)), p = et(o.attrs.src), m = Ai(o.attrs.align), h = $e(o.attrs.width), g = et(o.attrs.caption), _ = J(null), v = Ri(p, l.resolveMediaSource, _, s), y = v?.src ?? (l.resolveMediaSource ? null : p), b = J(null), [x, S] = Y(!1), [C, w] = Y(!1), [T, E] = Y(!1), [D, ee] = Y(""), [O, k] = Y(null), [A, j] = Y(!1), [M, te] = Y(!!g), [N, P] = Y(g ?? ""), ne = f && (!p || C), re = () => {
|
|
65
65
|
y && ot({
|
|
66
66
|
src: y,
|
|
67
67
|
alt: et(o.attrs.alt) ?? "",
|
|
@@ -147,9 +147,9 @@ function ji(e) {
|
|
|
147
147
|
onPointerEnter: () => S(!0),
|
|
148
148
|
onPointerLeave: () => S(!1),
|
|
149
149
|
onMouseDown: (e) => {
|
|
150
|
-
f && !
|
|
150
|
+
f && !ji(e.target) && F();
|
|
151
151
|
},
|
|
152
|
-
children: ne ? /* @__PURE__ */ Z(
|
|
152
|
+
children: ne ? /* @__PURE__ */ Z(Ni, {
|
|
153
153
|
dragActive: T,
|
|
154
154
|
error: O,
|
|
155
155
|
inputValue: D,
|
|
@@ -163,7 +163,7 @@ function ji(e) {
|
|
|
163
163
|
onInputChange: ee,
|
|
164
164
|
onSubmit: L
|
|
165
165
|
}) : /* @__PURE__ */ Q(lt, { children: [
|
|
166
|
-
f ? /* @__PURE__ */ Z(
|
|
166
|
+
f ? /* @__PURE__ */ Z(Pi, {
|
|
167
167
|
align: m,
|
|
168
168
|
captionActive: M || !!g,
|
|
169
169
|
messages: u,
|
|
@@ -219,12 +219,12 @@ function ji(e) {
|
|
|
219
219
|
children: d.preview
|
|
220
220
|
})]
|
|
221
221
|
}) : null,
|
|
222
|
-
f ? /* @__PURE__ */ Z(
|
|
222
|
+
f ? /* @__PURE__ */ Z(Ii, {
|
|
223
223
|
side: "left",
|
|
224
224
|
messages: u,
|
|
225
225
|
onPointerDown: se
|
|
226
226
|
}) : null,
|
|
227
|
-
f ? /* @__PURE__ */ Z(
|
|
227
|
+
f ? /* @__PURE__ */ Z(Ii, {
|
|
228
228
|
side: "right",
|
|
229
229
|
messages: u,
|
|
230
230
|
onPointerDown: se
|
|
@@ -250,7 +250,7 @@ function ji(e) {
|
|
|
250
250
|
] })
|
|
251
251
|
});
|
|
252
252
|
}
|
|
253
|
-
function
|
|
253
|
+
function Ni({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitting: i, messages: a, onCancel: o, onDragActiveChange: s, onDrop: c, onFileChange: l, onInputChange: u, onSubmit: d }) {
|
|
254
254
|
let f = a.image;
|
|
255
255
|
return /* @__PURE__ */ Q("section", {
|
|
256
256
|
className: "markweave-image-upload-placeholder",
|
|
@@ -332,7 +332,7 @@ function Mi({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
|
|
|
332
332
|
]
|
|
333
333
|
});
|
|
334
334
|
}
|
|
335
|
-
function
|
|
335
|
+
function Pi({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i, onDelete: a, onDownload: o, onPreview: s, onReplace: c }) {
|
|
336
336
|
let u = n.image;
|
|
337
337
|
return /* @__PURE__ */ Q("div", {
|
|
338
338
|
className: "markweave-image-toolbar",
|
|
@@ -340,21 +340,21 @@ function Ni({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i,
|
|
|
340
340
|
"data-markweave-image-ui": "true",
|
|
341
341
|
"aria-label": u.toolsAriaLabel,
|
|
342
342
|
children: [
|
|
343
|
-
/* @__PURE__ */ Z(
|
|
343
|
+
/* @__PURE__ */ Z(Fi, {
|
|
344
344
|
testId: "markweave-image-align-left",
|
|
345
345
|
label: u.alignLeft,
|
|
346
346
|
icon: d,
|
|
347
347
|
active: e === "left",
|
|
348
348
|
onClick: () => r("left")
|
|
349
349
|
}),
|
|
350
|
-
/* @__PURE__ */ Z(
|
|
350
|
+
/* @__PURE__ */ Z(Fi, {
|
|
351
351
|
testId: "markweave-image-align-center",
|
|
352
352
|
label: u.alignCenter,
|
|
353
353
|
icon: l,
|
|
354
354
|
active: e === "center",
|
|
355
355
|
onClick: () => r("center")
|
|
356
356
|
}),
|
|
357
|
-
/* @__PURE__ */ Z(
|
|
357
|
+
/* @__PURE__ */ Z(Fi, {
|
|
358
358
|
testId: "markweave-image-align-right",
|
|
359
359
|
label: u.alignRight,
|
|
360
360
|
icon: f,
|
|
@@ -365,26 +365,26 @@ function Ni({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i,
|
|
|
365
365
|
className: "markweave-image-toolbar-divider",
|
|
366
366
|
"aria-hidden": "true"
|
|
367
367
|
}),
|
|
368
|
-
/* @__PURE__ */ Z(
|
|
368
|
+
/* @__PURE__ */ Z(Fi, {
|
|
369
369
|
testId: "markweave-image-caption",
|
|
370
370
|
label: u.caption,
|
|
371
371
|
icon: ee,
|
|
372
372
|
active: t,
|
|
373
373
|
onClick: i
|
|
374
374
|
}),
|
|
375
|
-
/* @__PURE__ */ Z(
|
|
375
|
+
/* @__PURE__ */ Z(Fi, {
|
|
376
376
|
testId: "markweave-image-preview",
|
|
377
377
|
label: u.preview,
|
|
378
378
|
icon: I,
|
|
379
379
|
onClick: s
|
|
380
380
|
}),
|
|
381
|
-
/* @__PURE__ */ Z(
|
|
381
|
+
/* @__PURE__ */ Z(Fi, {
|
|
382
382
|
testId: "markweave-image-download",
|
|
383
383
|
label: u.download,
|
|
384
384
|
icon: re,
|
|
385
385
|
onClick: o
|
|
386
386
|
}),
|
|
387
|
-
/* @__PURE__ */ Z(
|
|
387
|
+
/* @__PURE__ */ Z(Fi, {
|
|
388
388
|
testId: "markweave-image-replace",
|
|
389
389
|
label: u.replace,
|
|
390
390
|
icon: _e,
|
|
@@ -394,7 +394,7 @@ function Ni({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i,
|
|
|
394
394
|
className: "markweave-image-toolbar-divider",
|
|
395
395
|
"aria-hidden": "true"
|
|
396
396
|
}),
|
|
397
|
-
/* @__PURE__ */ Z(
|
|
397
|
+
/* @__PURE__ */ Z(Fi, {
|
|
398
398
|
testId: "markweave-image-delete",
|
|
399
399
|
label: u.delete,
|
|
400
400
|
icon: je,
|
|
@@ -403,7 +403,7 @@ function Ni({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i,
|
|
|
403
403
|
]
|
|
404
404
|
});
|
|
405
405
|
}
|
|
406
|
-
function
|
|
406
|
+
function Fi({ active: e = !1, icon: t, label: n, onClick: r, testId: i }) {
|
|
407
407
|
return /* @__PURE__ */ Q("button", {
|
|
408
408
|
type: "button",
|
|
409
409
|
"aria-label": n,
|
|
@@ -422,7 +422,7 @@ function Pi({ active: e = !1, icon: t, label: n, onClick: r, testId: i }) {
|
|
|
422
422
|
})]
|
|
423
423
|
});
|
|
424
424
|
}
|
|
425
|
-
function
|
|
425
|
+
function Ii({ messages: e, onPointerDown: t, side: n }) {
|
|
426
426
|
return /* @__PURE__ */ Z("button", {
|
|
427
427
|
type: "button",
|
|
428
428
|
className: "markweave-image-resize-handle",
|
|
@@ -433,7 +433,7 @@ function Fi({ messages: e, onPointerDown: t, side: n }) {
|
|
|
433
433
|
onPointerDown: (e) => t(n, e)
|
|
434
434
|
});
|
|
435
435
|
}
|
|
436
|
-
var
|
|
436
|
+
var Li = Ve.extend({
|
|
437
437
|
addOptions() {
|
|
438
438
|
return {
|
|
439
439
|
...this.parent?.(),
|
|
@@ -444,7 +444,7 @@ var Ii = Ve.extend({
|
|
|
444
444
|
},
|
|
445
445
|
addNodeView() {
|
|
446
446
|
if (typeof document > "u") return null;
|
|
447
|
-
let e = o(
|
|
447
|
+
let e = o(Mi, { stopEvent: ({ event: e }) => ji(e.target) }), t = this.options.resolveMediaSource;
|
|
448
448
|
if (!t) return e;
|
|
449
449
|
let r = st({
|
|
450
450
|
messages: this.options.messages ?? n("zh"),
|
|
@@ -454,7 +454,7 @@ var Ii = Ve.extend({
|
|
|
454
454
|
return (t) => et(t.node.attrs.src) ? r(t) : e(t);
|
|
455
455
|
}
|
|
456
456
|
});
|
|
457
|
-
function
|
|
457
|
+
function Ri(e, t, n, r) {
|
|
458
458
|
let [i, a] = Y(t ? "background" : "visible"), [o, s] = Y(() => !t && e ? { src: e } : null);
|
|
459
459
|
return K(() => {
|
|
460
460
|
s(!t && e ? { src: e } : null), a(t ? "background" : "visible");
|
|
@@ -500,16 +500,16 @@ function Li(e, t, n, r) {
|
|
|
500
500
|
}
|
|
501
501
|
//#endregion
|
|
502
502
|
//#region src/media/video-node.tsx
|
|
503
|
-
function
|
|
503
|
+
function zi(e) {
|
|
504
504
|
return e instanceof Element && !!e.closest("[data-markweave-video-ui=\"true\"], iframe[data-markweave-video-embed], video[data-markweave-video]");
|
|
505
505
|
}
|
|
506
|
-
function
|
|
507
|
-
let { deleteNode: t, editor: r, getPos: i, node: o, selected: s, updateAttributes: c } = e, l = e.extension.options, u = l.messages ?? n("zh"), d = u.video, f = nt(
|
|
506
|
+
function Bi(e) {
|
|
507
|
+
let { deleteNode: t, editor: r, getPos: i, node: o, selected: s, updateAttributes: c } = e, l = e.extension.options, u = l.messages ?? n("zh"), d = u.video, f = nt(ki(r)), p = et(o.attrs.src), m = et(o.attrs.embedUrl), h = et(o.attrs.provider), g = m ? Qe(m, h) : null, _ = et(o.attrs.mimeType), v = et(o.attrs.title), y = J(null), [b, x] = Y(!1), [S, C] = Y(""), [w, T] = Y(null), [E, D] = Y(!1), ee = f && !p, O = () => {
|
|
508
508
|
if (!f) return;
|
|
509
509
|
let e = i();
|
|
510
510
|
typeof e == "number" && r.chain().focus().setNodeSelection(e).run();
|
|
511
511
|
}, k = (e) => {
|
|
512
|
-
f && (
|
|
512
|
+
f && (zi(e.target) || (e.preventDefault(), O()));
|
|
513
513
|
}, A = (e) => {
|
|
514
514
|
f && (e.key === "Delete" || e.key === "Backspace") && s && (e.preventDefault(), t());
|
|
515
515
|
}, j = async (e) => {
|
|
@@ -535,7 +535,7 @@ function zi(e) {
|
|
|
535
535
|
"data-testid": "markweave-video-node",
|
|
536
536
|
"data-empty": "true",
|
|
537
537
|
"data-selected": "false",
|
|
538
|
-
children: /* @__PURE__ */ Z(
|
|
538
|
+
children: /* @__PURE__ */ Z(Vi, {
|
|
539
539
|
dragActive: b,
|
|
540
540
|
error: w,
|
|
541
541
|
fileInputRef: y,
|
|
@@ -616,7 +616,7 @@ function zi(e) {
|
|
|
616
616
|
})
|
|
617
617
|
});
|
|
618
618
|
}
|
|
619
|
-
function
|
|
619
|
+
function Vi({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitting: i, messages: a, onCancel: o, onDragActiveChange: s, onDrop: c, onFileChange: l, onInputChange: u, onSubmit: d }) {
|
|
620
620
|
let f = a.video;
|
|
621
621
|
return /* @__PURE__ */ Q("section", {
|
|
622
622
|
className: "markweave-video-upload-placeholder",
|
|
@@ -698,7 +698,7 @@ function Bi({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
|
|
|
698
698
|
]
|
|
699
699
|
});
|
|
700
700
|
}
|
|
701
|
-
var
|
|
701
|
+
var Hi = He.extend({
|
|
702
702
|
addOptions() {
|
|
703
703
|
return {
|
|
704
704
|
...this.parent?.(),
|
|
@@ -708,29 +708,29 @@ var Vi = He.extend({
|
|
|
708
708
|
};
|
|
709
709
|
},
|
|
710
710
|
addNodeView() {
|
|
711
|
-
return typeof document > "u" ? null : o(
|
|
711
|
+
return typeof document > "u" ? null : o(Bi, { stopEvent: ({ event: e }) => zi(e.target) });
|
|
712
712
|
}
|
|
713
713
|
});
|
|
714
714
|
//#endregion
|
|
715
715
|
//#region src/link-card-node.tsx
|
|
716
|
-
function
|
|
716
|
+
function Ui(e) {
|
|
717
717
|
return e instanceof Element && !!e.closest("[data-markweave-link-card-ui=\"true\"]");
|
|
718
718
|
}
|
|
719
|
-
function
|
|
719
|
+
function Wi(e) {
|
|
720
720
|
return typeof navigator < "u" && navigator.clipboard?.writeText ? navigator.clipboard.writeText(e).catch(() => void 0) : Promise.resolve();
|
|
721
721
|
}
|
|
722
|
-
function
|
|
722
|
+
function Gi(e) {
|
|
723
723
|
!e || typeof window > "u" || window.open(e, "_blank", "noopener,noreferrer");
|
|
724
724
|
}
|
|
725
|
-
function
|
|
725
|
+
function Ki(e) {
|
|
726
726
|
try {
|
|
727
727
|
return new URL(e).host;
|
|
728
728
|
} catch {
|
|
729
729
|
return e;
|
|
730
730
|
}
|
|
731
731
|
}
|
|
732
|
-
function
|
|
733
|
-
let { deleteNode: t, editor: r, getPos: i, node: o, updateAttributes: s } = e, c = e.extension.options, l = c.messages ?? n("zh"), u = l.linkCard, d = nt(
|
|
732
|
+
function qi(e) {
|
|
733
|
+
let { deleteNode: t, editor: r, getPos: i, node: o, updateAttributes: s } = e, c = e.extension.options, l = c.messages ?? n("zh"), u = l.linkCard, d = nt(ki(r)), f = dt(o.attrs), [p, m] = Y(!1), [h, g] = Y(!1), [_, v] = Y(!1), [y, b] = Y(f?.title ?? ""), [x, S] = Y(f?.href ?? ""), C = J(null);
|
|
734
734
|
if (K(() => () => C.current?.abort(), []), K(() => {
|
|
735
735
|
b(f?.title ?? ""), S(f?.href ?? ""), v(!1);
|
|
736
736
|
}, [f?.href, f?.title]), !f) return null;
|
|
@@ -759,7 +759,7 @@ function Ki(e) {
|
|
|
759
759
|
}, T = () => {
|
|
760
760
|
let e = i();
|
|
761
761
|
typeof e == "number" && pt(r, e);
|
|
762
|
-
}, E = _ ? null : f.imageUrl, D =
|
|
762
|
+
}, E = _ ? null : f.imageUrl, D = Ki(f.href);
|
|
763
763
|
return /* @__PURE__ */ Q(a, {
|
|
764
764
|
as: "article",
|
|
765
765
|
className: "markweave-link-card",
|
|
@@ -770,10 +770,10 @@ function Ki(e) {
|
|
|
770
770
|
onMouseEnter: () => m(!0),
|
|
771
771
|
onMouseLeave: () => m(!1),
|
|
772
772
|
onMouseDown: (e) => {
|
|
773
|
-
|
|
773
|
+
Ui(e.target) || e.preventDefault();
|
|
774
774
|
},
|
|
775
775
|
onClick: (e) => {
|
|
776
|
-
|
|
776
|
+
Ui(e.target) || (e.preventDefault(), Gi(f.href));
|
|
777
777
|
},
|
|
778
778
|
children: [
|
|
779
779
|
/* @__PURE__ */ Q("a", {
|
|
@@ -811,19 +811,19 @@ function Ki(e) {
|
|
|
811
811
|
"data-markweave-link-card-ui": "true",
|
|
812
812
|
"aria-label": u.toolsAriaLabel,
|
|
813
813
|
children: [
|
|
814
|
-
/* @__PURE__ */ Z(
|
|
814
|
+
/* @__PURE__ */ Z(Ji, {
|
|
815
815
|
label: u.convertToLink,
|
|
816
816
|
icon: le,
|
|
817
817
|
onClick: T,
|
|
818
818
|
testId: "markweave-link-card-convert"
|
|
819
819
|
}),
|
|
820
|
-
/* @__PURE__ */ Z(
|
|
820
|
+
/* @__PURE__ */ Z(Ji, {
|
|
821
821
|
label: u.copyAddress,
|
|
822
822
|
icon: P,
|
|
823
|
-
onClick: () => void
|
|
823
|
+
onClick: () => void Wi(f.href),
|
|
824
824
|
testId: "markweave-link-card-copy"
|
|
825
825
|
}),
|
|
826
|
-
/* @__PURE__ */ Z(
|
|
826
|
+
/* @__PURE__ */ Z(Ji, {
|
|
827
827
|
label: u.edit,
|
|
828
828
|
icon: me,
|
|
829
829
|
onClick: (e) => {
|
|
@@ -841,7 +841,7 @@ function Ki(e) {
|
|
|
841
841
|
},
|
|
842
842
|
testId: "markweave-link-card-edit"
|
|
843
843
|
}),
|
|
844
|
-
/* @__PURE__ */ Z(
|
|
844
|
+
/* @__PURE__ */ Z(Ji, {
|
|
845
845
|
label: u.delete,
|
|
846
846
|
icon: je,
|
|
847
847
|
onClick: t,
|
|
@@ -878,7 +878,7 @@ function Ki(e) {
|
|
|
878
878
|
]
|
|
879
879
|
});
|
|
880
880
|
}
|
|
881
|
-
function
|
|
881
|
+
function Ji({ icon: e, label: t, onClick: n, testId: r }) {
|
|
882
882
|
return /* @__PURE__ */ Q("button", {
|
|
883
883
|
type: "button",
|
|
884
884
|
"aria-label": t,
|
|
@@ -895,7 +895,7 @@ function qi({ icon: e, label: t, onClick: n, testId: r }) {
|
|
|
895
895
|
})]
|
|
896
896
|
});
|
|
897
897
|
}
|
|
898
|
-
var
|
|
898
|
+
var Yi = ht.extend({
|
|
899
899
|
addOptions() {
|
|
900
900
|
return {
|
|
901
901
|
...this.parent?.(),
|
|
@@ -904,23 +904,23 @@ var Ji = ht.extend({
|
|
|
904
904
|
};
|
|
905
905
|
},
|
|
906
906
|
addNodeView() {
|
|
907
|
-
return typeof document > "u" ? null : o(
|
|
907
|
+
return typeof document > "u" ? null : o(qi, { stopEvent: ({ event: e }) => Ui(e.target) });
|
|
908
908
|
}
|
|
909
909
|
});
|
|
910
910
|
//#endregion
|
|
911
911
|
//#region src/create-editor-extensions.ts
|
|
912
|
-
function
|
|
912
|
+
function Xi(t = {}) {
|
|
913
913
|
return e({
|
|
914
914
|
lang: t.lang,
|
|
915
915
|
onImageUpload: t.onImageUpload,
|
|
916
|
-
linkCardExtension:
|
|
916
|
+
linkCardExtension: Yi.configure({
|
|
917
917
|
lang: t.lang,
|
|
918
918
|
messages: n(t.lang),
|
|
919
919
|
resolver: t.linkCardResolver
|
|
920
920
|
}),
|
|
921
921
|
mediaExtensions: ut({
|
|
922
|
-
image:
|
|
923
|
-
video:
|
|
922
|
+
image: Li,
|
|
923
|
+
video: Hi,
|
|
924
924
|
lang: t.lang,
|
|
925
925
|
onImageUpload: t.onImageUpload,
|
|
926
926
|
onVideoUpload: t.onVideoUpload,
|
|
@@ -930,7 +930,7 @@ function Yi(t = {}) {
|
|
|
930
930
|
}
|
|
931
931
|
//#endregion
|
|
932
932
|
//#region src/ui/codeblock/CodeBlockControls.tsx
|
|
933
|
-
function
|
|
933
|
+
function Zi(e) {
|
|
934
934
|
return e === "clipboard" ? /* @__PURE__ */ Q(lt, { 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(lt, { children: [/* @__PURE__ */ Z("circle", {
|
|
935
935
|
cx: "10",
|
|
936
936
|
cy: "10",
|
|
@@ -967,7 +967,7 @@ function Xi(e) {
|
|
|
967
967
|
/* @__PURE__ */ Z("path", { d: "m14 14 4 4" })
|
|
968
968
|
] }) : e === "reset" ? /* @__PURE__ */ Q(lt, { 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" });
|
|
969
969
|
}
|
|
970
|
-
function
|
|
970
|
+
function Qi({ icon: e }) {
|
|
971
971
|
return /* @__PURE__ */ Z("svg", {
|
|
972
972
|
viewBox: "0 0 24 24",
|
|
973
973
|
"aria-hidden": "true",
|
|
@@ -978,11 +978,11 @@ function Zi({ icon: e }) {
|
|
|
978
978
|
strokeLinecap: "round",
|
|
979
979
|
strokeLinejoin: "round",
|
|
980
980
|
strokeWidth: "1.8",
|
|
981
|
-
children:
|
|
981
|
+
children: Zi(e)
|
|
982
982
|
})
|
|
983
983
|
});
|
|
984
984
|
}
|
|
985
|
-
function
|
|
985
|
+
function $i({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, readOnly: i = !1 }) {
|
|
986
986
|
let a = J(null), o = J(null), s = J(null), c = J(null), l = J(null), u = J(null), d = J({
|
|
987
987
|
active: !1,
|
|
988
988
|
lastX: 0,
|
|
@@ -1279,7 +1279,7 @@ function Qi({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1279
1279
|
"data-testid": "markweave-codeblock-language",
|
|
1280
1280
|
onMouseDown: (e) => e.preventDefault(),
|
|
1281
1281
|
onClick: he,
|
|
1282
|
-
children: [/* @__PURE__ */ Z("span", { children: se }), /* @__PURE__ */ Z(
|
|
1282
|
+
children: [/* @__PURE__ */ Z("span", { children: se }), /* @__PURE__ */ Z(Qi, { icon: "chevron" })]
|
|
1283
1283
|
}),
|
|
1284
1284
|
oe ? /* @__PURE__ */ Z("button", {
|
|
1285
1285
|
type: "button",
|
|
@@ -1290,7 +1290,7 @@ function Qi({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1290
1290
|
"data-collapsed": B ? "true" : "false",
|
|
1291
1291
|
onMouseDown: (e) => e.preventDefault(),
|
|
1292
1292
|
onClick: be,
|
|
1293
|
-
children: /* @__PURE__ */ Z(
|
|
1293
|
+
children: /* @__PURE__ */ Z(Qi, { icon: "chevron" })
|
|
1294
1294
|
}) : null,
|
|
1295
1295
|
/* @__PURE__ */ Q("span", {
|
|
1296
1296
|
className: "markweave-codeblock-copy-wrap",
|
|
@@ -1306,7 +1306,7 @@ function Qi({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1306
1306
|
onFocus: () => O(!0),
|
|
1307
1307
|
onBlur: () => O(!1),
|
|
1308
1308
|
onClick: W,
|
|
1309
|
-
children: /* @__PURE__ */ Z(
|
|
1309
|
+
children: /* @__PURE__ */ Z(Qi, { icon: ce === "copied" ? "check" : "clipboard" })
|
|
1310
1310
|
}), ee ? /* @__PURE__ */ Z("span", {
|
|
1311
1311
|
className: "markweave-codeblock-tooltip",
|
|
1312
1312
|
role: "tooltip",
|
|
@@ -1325,7 +1325,7 @@ function Qi({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1325
1325
|
disabled: !ue,
|
|
1326
1326
|
onMouseDown: (e) => e.preventDefault(),
|
|
1327
1327
|
onClick: Se,
|
|
1328
|
-
children: /* @__PURE__ */ Z(
|
|
1328
|
+
children: /* @__PURE__ */ Z(Qi, { icon: "expand" })
|
|
1329
1329
|
}), /* @__PURE__ */ Z("button", {
|
|
1330
1330
|
type: "button",
|
|
1331
1331
|
className: "markweave-codeblock-icon-button",
|
|
@@ -1334,7 +1334,7 @@ function Qi({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1334
1334
|
disabled: !ue,
|
|
1335
1335
|
onMouseDown: (e) => e.preventDefault(),
|
|
1336
1336
|
onClick: xe,
|
|
1337
|
-
children: /* @__PURE__ */ Z(
|
|
1337
|
+
children: /* @__PURE__ */ Z(Qi, { icon: "download" })
|
|
1338
1338
|
})]
|
|
1339
1339
|
}) : null
|
|
1340
1340
|
]
|
|
@@ -1363,7 +1363,7 @@ function Qi({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1363
1363
|
"data-testid": "markweave-codeblock-language-search",
|
|
1364
1364
|
onChange: (e) => ge(e.target.value),
|
|
1365
1365
|
onKeyDown: _e
|
|
1366
|
-
}), /* @__PURE__ */ Z(
|
|
1366
|
+
}), /* @__PURE__ */ Z(Qi, { icon: "search" })]
|
|
1367
1367
|
}), /* @__PURE__ */ Z("div", {
|
|
1368
1368
|
ref: l,
|
|
1369
1369
|
id: u.current ?? void 0,
|
|
@@ -1384,7 +1384,7 @@ function Qi({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1384
1384
|
onMouseDown: (e) => e.preventDefault(),
|
|
1385
1385
|
onMouseEnter: () => T(t),
|
|
1386
1386
|
onClick: () => me(e.language),
|
|
1387
|
-
children: [/* @__PURE__ */ Z("span", { children: e.label }), n ? /* @__PURE__ */ Z(
|
|
1387
|
+
children: [/* @__PURE__ */ Z("span", { children: e.label }), n ? /* @__PURE__ */ Z(Qi, { icon: "check" }) : null]
|
|
1388
1388
|
}, e.language);
|
|
1389
1389
|
})
|
|
1390
1390
|
})]
|
|
@@ -1410,7 +1410,7 @@ function Qi({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1410
1410
|
onFocus: () => M("zoom-out"),
|
|
1411
1411
|
onBlur: () => M(null),
|
|
1412
1412
|
onClick: () => we(-Zn),
|
|
1413
|
-
children: /* @__PURE__ */ Z(
|
|
1413
|
+
children: /* @__PURE__ */ Z(Qi, { icon: "zoomOut" })
|
|
1414
1414
|
}),
|
|
1415
1415
|
/* @__PURE__ */ Z("span", {
|
|
1416
1416
|
className: "markweave-mermaid-fullscreen-zoom-label",
|
|
@@ -1427,7 +1427,7 @@ function Qi({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1427
1427
|
onFocus: () => M("zoom-in"),
|
|
1428
1428
|
onBlur: () => M(null),
|
|
1429
1429
|
onClick: () => we(Zn),
|
|
1430
|
-
children: /* @__PURE__ */ Z(
|
|
1430
|
+
children: /* @__PURE__ */ Z(Qi, { icon: "zoomIn" })
|
|
1431
1431
|
}),
|
|
1432
1432
|
/* @__PURE__ */ Z("button", {
|
|
1433
1433
|
type: "button",
|
|
@@ -1439,7 +1439,7 @@ function Qi({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1439
1439
|
onFocus: () => M("reset"),
|
|
1440
1440
|
onBlur: () => M(null),
|
|
1441
1441
|
onClick: Te,
|
|
1442
|
-
children: /* @__PURE__ */ Z(
|
|
1442
|
+
children: /* @__PURE__ */ Z(Qi, { icon: "reset" })
|
|
1443
1443
|
}),
|
|
1444
1444
|
j ? /* @__PURE__ */ Z("span", {
|
|
1445
1445
|
className: "markweave-mermaid-fullscreen-tooltip",
|
|
@@ -1455,7 +1455,7 @@ function Qi({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1455
1455
|
"aria-label": "Close fullscreen Mermaid preview",
|
|
1456
1456
|
"data-testid": "markweave-mermaid-fullscreen-close",
|
|
1457
1457
|
onClick: Ce,
|
|
1458
|
-
children: /* @__PURE__ */ Z(
|
|
1458
|
+
children: /* @__PURE__ */ Z(Qi, { icon: "close" })
|
|
1459
1459
|
}),
|
|
1460
1460
|
/* @__PURE__ */ Z("div", {
|
|
1461
1461
|
className: "markweave-mermaid-fullscreen-viewport",
|
|
@@ -1486,25 +1486,25 @@ function Qi({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1486
1486
|
}
|
|
1487
1487
|
//#endregion
|
|
1488
1488
|
//#region src/ui/floating-toolbar/FloatingToolbar.tsx
|
|
1489
|
-
var
|
|
1490
|
-
function
|
|
1489
|
+
var ea = n("zh");
|
|
1490
|
+
function ta() {
|
|
1491
1491
|
return typeof performance > "u" ? Date.now() : performance.now();
|
|
1492
1492
|
}
|
|
1493
|
-
function
|
|
1493
|
+
function na(e, t) {
|
|
1494
1494
|
return {
|
|
1495
1495
|
"--markweave-toolbar-motion-duration": `${e.motionDurationMs}ms`,
|
|
1496
1496
|
"--markweave-toolbar-motion-easing": e.motionEasing,
|
|
1497
1497
|
marginLeft: t === 0 ? void 0 : `${t}px`
|
|
1498
1498
|
};
|
|
1499
1499
|
}
|
|
1500
|
-
function
|
|
1500
|
+
function ra(e, t) {
|
|
1501
1501
|
let n = e?.getBoundingClientRect().height ?? 0, r = t?.getBoundingClientRect().height ?? 0;
|
|
1502
1502
|
return Math.max(n, r, 44);
|
|
1503
1503
|
}
|
|
1504
|
-
function
|
|
1504
|
+
function ia(e) {
|
|
1505
1505
|
if (e !== null) return { "--markweave-floating-toolbar-tooltip-left": `${e}px` };
|
|
1506
1506
|
}
|
|
1507
|
-
function
|
|
1507
|
+
function aa(e, t, n, r) {
|
|
1508
1508
|
let i = {
|
|
1509
1509
|
bottom: t + r,
|
|
1510
1510
|
height: r,
|
|
@@ -1520,26 +1520,26 @@ function ia(e, t, n, r) {
|
|
|
1520
1520
|
toJSON: () => i
|
|
1521
1521
|
};
|
|
1522
1522
|
}
|
|
1523
|
-
function
|
|
1523
|
+
function oa(e) {
|
|
1524
1524
|
return e.width > 0 && e.height > 0;
|
|
1525
1525
|
}
|
|
1526
|
-
function
|
|
1526
|
+
function sa(e) {
|
|
1527
1527
|
let t = Math.min(...e.map((e) => e.left)), n = Math.min(...e.map((e) => e.top)), r = Math.max(...e.map((e) => e.right)), i = Math.max(...e.map((e) => e.bottom));
|
|
1528
|
-
return
|
|
1528
|
+
return aa(t, n, r - t, i - n);
|
|
1529
1529
|
}
|
|
1530
|
-
function
|
|
1530
|
+
function ca(e, t) {
|
|
1531
1531
|
let n = e.view.dom.ownerDocument.defaultView?.Node.ELEMENT_NODE ?? 1, r = (t) => t ? e.view.dom.contains(t.nodeType === n ? t : t.parentNode) : !1;
|
|
1532
1532
|
return r(t.anchorNode) && r(t.focusNode);
|
|
1533
1533
|
}
|
|
1534
|
-
function
|
|
1534
|
+
function la(e) {
|
|
1535
1535
|
if (typeof e.getClientRects != "function") return null;
|
|
1536
|
-
let t = Array.from(e.getClientRects()).filter(
|
|
1536
|
+
let t = Array.from(e.getClientRects()).filter(oa).map((e) => aa(e.left, e.top, e.width, e.height));
|
|
1537
1537
|
if (t.length > 0) return t;
|
|
1538
1538
|
if (typeof e.getBoundingClientRect != "function") return null;
|
|
1539
1539
|
let n = e.getBoundingClientRect();
|
|
1540
|
-
return
|
|
1540
|
+
return oa(n) ? [aa(n.left, n.top, n.width, n.height)] : null;
|
|
1541
1541
|
}
|
|
1542
|
-
function
|
|
1542
|
+
function ua(e, t) {
|
|
1543
1543
|
if (t.rangeCount === 0) return null;
|
|
1544
1544
|
let n = t.getRangeAt(0);
|
|
1545
1545
|
try {
|
|
@@ -1552,8 +1552,8 @@ function la(e, t) {
|
|
|
1552
1552
|
return null;
|
|
1553
1553
|
}
|
|
1554
1554
|
}
|
|
1555
|
-
function
|
|
1556
|
-
let n =
|
|
1555
|
+
function da(e, t) {
|
|
1556
|
+
let n = ua(e, t);
|
|
1557
1557
|
if (!n) return !1;
|
|
1558
1558
|
let { selection: r } = e.state, i = {
|
|
1559
1559
|
from: Math.min(r.from, r.to),
|
|
@@ -1561,56 +1561,56 @@ function ua(e, t) {
|
|
|
1561
1561
|
};
|
|
1562
1562
|
return n.from === i.from && n.to === i.to;
|
|
1563
1563
|
}
|
|
1564
|
-
function
|
|
1564
|
+
function fa(e) {
|
|
1565
1565
|
let t = e.view.dom.ownerDocument.getSelection();
|
|
1566
|
-
return !t || t.rangeCount === 0 || t.isCollapsed || !
|
|
1566
|
+
return !t || t.rangeCount === 0 || t.isCollapsed || !ca(e, t) || !da(e, t) ? null : la(t.getRangeAt(0));
|
|
1567
1567
|
}
|
|
1568
|
-
function
|
|
1568
|
+
function pa(e) {
|
|
1569
1569
|
let { selection: t } = e.state;
|
|
1570
1570
|
if (t.empty) return null;
|
|
1571
1571
|
let n = Math.min(t.from, t.to), r = Math.max(t.from, t.to);
|
|
1572
1572
|
try {
|
|
1573
1573
|
let t = e.view.domAtPos(n), i = e.view.domAtPos(r), a = e.view.dom.ownerDocument.createRange();
|
|
1574
|
-
return a.setStart(t.node, t.offset), a.setEnd(i.node, i.offset),
|
|
1574
|
+
return a.setStart(t.node, t.offset), a.setEnd(i.node, i.offset), la(a);
|
|
1575
1575
|
} catch {
|
|
1576
1576
|
return null;
|
|
1577
1577
|
}
|
|
1578
1578
|
}
|
|
1579
|
-
function
|
|
1579
|
+
function ma(e) {
|
|
1580
1580
|
let { selection: t } = e.state;
|
|
1581
1581
|
if (t.empty) return null;
|
|
1582
|
-
let n = Math.min(t.from, t.to), r = Math.max(t.from, t.to), i = e.view.coordsAtPos(n), a = e.view.coordsAtPos(r, -1), o = Math.min(i.top, a.top), s = Math.max(i.bottom, a.bottom), c = Math.min(i.left, a.left), l =
|
|
1583
|
-
return
|
|
1584
|
-
}
|
|
1585
|
-
function ma(e) {
|
|
1586
|
-
return da(e) ?? fa(e) ?? pa(e);
|
|
1582
|
+
let n = Math.min(t.from, t.to), r = Math.max(t.from, t.to), i = e.view.coordsAtPos(n), a = e.view.coordsAtPos(r, -1), o = Math.min(i.top, a.top), s = Math.max(i.bottom, a.bottom), c = Math.min(i.left, a.left), l = aa(c, o, Math.max(i.right, a.right) - c, s - o);
|
|
1583
|
+
return oa(l) ? [l] : null;
|
|
1587
1584
|
}
|
|
1588
1585
|
function ha(e) {
|
|
1589
|
-
|
|
1590
|
-
return t && t.length > 0 ? oa(t) : null;
|
|
1586
|
+
return fa(e) ?? pa(e) ?? ma(e);
|
|
1591
1587
|
}
|
|
1592
1588
|
function ga(e) {
|
|
1589
|
+
let t = ha(e);
|
|
1590
|
+
return t && t.length > 0 ? sa(t) : null;
|
|
1591
|
+
}
|
|
1592
|
+
function _a(e) {
|
|
1593
1593
|
return {
|
|
1594
|
-
getBoundingClientRect: () =>
|
|
1595
|
-
getClientRects: () =>
|
|
1594
|
+
getBoundingClientRect: () => ga(e) ?? aa(0, 0, 0, 0),
|
|
1595
|
+
getClientRects: () => ha(e) ?? []
|
|
1596
1596
|
};
|
|
1597
1597
|
}
|
|
1598
|
-
function
|
|
1598
|
+
function va(e) {
|
|
1599
1599
|
return e === "ask-ai" || e === "block-type" || e === "link" || e === "color" || e === "more";
|
|
1600
1600
|
}
|
|
1601
|
-
function
|
|
1601
|
+
function ya(e, t, n) {
|
|
1602
1602
|
n?.(rr(e, t)), e.commands.focus();
|
|
1603
1603
|
}
|
|
1604
|
-
var
|
|
1605
|
-
function
|
|
1606
|
-
let o = q(() => cr(n), [n]), s = Nt(r, { editable: e.isEditable }), [c, l] = Y(s), [u, d] = Y(null), [f, p] = Y(null), [m, h] = Y(null), [g, _] = Y("input"), [v, y] = Y(""), [b, x] = Y(""), [S, C] = Y(""), [w, T] = Y(""), [E, D] = Y(""), [ee, O] = Y(""), [k, A] = Y(null), [j, M] = Y(0), [te, N] = Y(s.boundaryPadding), [P, ne] = Y("bottom"), re = J(0), F = J(null), I = J(null), ie = J(null), ae = J(null), L = J(null), R = J(null), z = J(null), B = J(null), V = J(null), oe = J(""), se = i?.enabled === !0 && typeof i.handler == "function", ce = ir(e, c.variant, n, { askAiEnabled: se }), le = ur(ce.find((e) => e.id === u) ?? null), ue =
|
|
1604
|
+
var ba = "markweave-floating-toolbar";
|
|
1605
|
+
function xa({ editor: e, lang: t = "zh", messages: n = ea, selectionSnapshot: r, askAi: i, onRewriteSelection: a }) {
|
|
1606
|
+
let o = q(() => cr(n), [n]), s = Nt(r, { editable: e.isEditable }), [c, l] = Y(s), [u, d] = Y(null), [f, p] = Y(null), [m, h] = Y(null), [g, _] = Y("input"), [v, y] = Y(""), [b, x] = Y(""), [S, C] = Y(""), [w, T] = Y(""), [E, D] = Y(""), [ee, O] = Y(""), [k, A] = Y(null), [j, M] = Y(0), [te, N] = Y(s.boundaryPadding), [P, ne] = Y("bottom"), re = J(0), F = J(null), I = J(null), ie = J(null), ae = J(null), L = J(null), R = J(null), z = J(null), B = J(null), V = J(null), oe = J(""), se = i?.enabled === !0 && typeof i.handler == "function", ce = ir(e, c.variant, n, { askAiEnabled: se }), le = ur(ce.find((e) => e.id === u) ?? null), ue = Rr(E), H = G(() => {
|
|
1607
1607
|
V.current !== null && (window.cancelAnimationFrame(V.current), V.current = null);
|
|
1608
1608
|
}, []), U = G((t = !0) => {
|
|
1609
|
-
z.current?.abort(), z.current = null, B.current = null, H(), t &&
|
|
1609
|
+
z.current?.abort(), z.current = null, B.current = null, H(), t && Nr(e), Er(e), h(null);
|
|
1610
1610
|
}, [H, e]), de = G(() => {
|
|
1611
1611
|
let t = F.current, n = e.view.dom.closest(".markweave-editor-frame");
|
|
1612
1612
|
if (!t || !(n instanceof HTMLElement)) return;
|
|
1613
|
-
let r = t.getBoundingClientRect(), i = n.getBoundingClientRect(), a =
|
|
1613
|
+
let r = t.getBoundingClientRect(), i = n.getBoundingClientRect(), a = ra(t, I.current), o = re.current, s = Ot({
|
|
1614
1614
|
toolbarRect: {
|
|
1615
1615
|
left: r.left - o,
|
|
1616
1616
|
top: r.top,
|
|
@@ -1650,13 +1650,13 @@ function ba({ editor: e, lang: t = "zh", messages: n = $i, selectionSnapshot: r,
|
|
|
1650
1650
|
}, [de]), pe = G(() => Ar(e)?.target.kind === "table" ? {
|
|
1651
1651
|
getBoundingClientRect: () => {
|
|
1652
1652
|
let t = jr(e);
|
|
1653
|
-
return t ?
|
|
1653
|
+
return t ? aa(t.left, t.top, t.width, t.height) : aa(0, 0, 0, 0);
|
|
1654
1654
|
},
|
|
1655
1655
|
getClientRects: () => {
|
|
1656
1656
|
let t = jr(e);
|
|
1657
|
-
return t ? [
|
|
1657
|
+
return t ? [aa(t.left, t.top, t.width, t.height)] : [];
|
|
1658
1658
|
}
|
|
1659
|
-
} :
|
|
1659
|
+
} : _a(e), [e]), me = G((e) => {
|
|
1660
1660
|
ie.current = e, e?.classList.contains("markweave-ask-ai-popover") && (e.dataset.positioned = "false");
|
|
1661
1661
|
}, []), he = G(() => {
|
|
1662
1662
|
let t = F.current, n = ie.current, r = e.view.dom.closest(".markweave-editor-frame");
|
|
@@ -1712,7 +1712,7 @@ function ba({ editor: e, lang: t = "zh", messages: n = $i, selectionSnapshot: r,
|
|
|
1712
1712
|
te
|
|
1713
1713
|
]);
|
|
1714
1714
|
K(() => {
|
|
1715
|
-
let e =
|
|
1715
|
+
let e = ta();
|
|
1716
1716
|
l((t) => It(t, s, e));
|
|
1717
1717
|
}, [
|
|
1718
1718
|
s.hiddenReason,
|
|
@@ -1727,8 +1727,8 @@ function ba({ editor: e, lang: t = "zh", messages: n = $i, selectionSnapshot: r,
|
|
|
1727
1727
|
s.visibility
|
|
1728
1728
|
]), K(() => {
|
|
1729
1729
|
if (c.motionStartedAtMs === null || c.motionDurationMs <= 0) return;
|
|
1730
|
-
let e = Math.max(0, c.motionStartedAtMs + c.motionDurationMs -
|
|
1731
|
-
l((e) => Et(e,
|
|
1730
|
+
let e = Math.max(0, c.motionStartedAtMs + c.motionDurationMs - ta()), t = window.setTimeout(() => {
|
|
1731
|
+
l((e) => Et(e, ta()));
|
|
1732
1732
|
}, e);
|
|
1733
1733
|
return () => {
|
|
1734
1734
|
window.clearTimeout(t);
|
|
@@ -1822,10 +1822,10 @@ function ba({ editor: e, lang: t = "zh", messages: n = $i, selectionSnapshot: r,
|
|
|
1822
1822
|
});
|
|
1823
1823
|
return () => window.cancelAnimationFrame(e);
|
|
1824
1824
|
}, [m]), K(() => {
|
|
1825
|
-
m !== "ask-ai" || e.isDestroyed || e.view.dispatch(e.state.tr.setMeta(
|
|
1825
|
+
m !== "ask-ai" || e.isDestroyed || e.view.dispatch(e.state.tr.setMeta(ba, "show").setMeta("addToHistory", !1));
|
|
1826
1826
|
}, [e, m]);
|
|
1827
1827
|
let _e = (t) => {
|
|
1828
|
-
if (
|
|
1828
|
+
if (va(t.id)) {
|
|
1829
1829
|
let n = t.id;
|
|
1830
1830
|
if (m === n) {
|
|
1831
1831
|
n === "ask-ai" ? U(!0) : h(null);
|
|
@@ -1833,7 +1833,7 @@ function ba({ editor: e, lang: t = "zh", messages: n = $i, selectionSnapshot: r,
|
|
|
1833
1833
|
}
|
|
1834
1834
|
if (m === "ask-ai" && U(!1), n === "ask-ai") {
|
|
1835
1835
|
if (!se) return;
|
|
1836
|
-
let t =
|
|
1836
|
+
let t = Lr(e);
|
|
1837
1837
|
if (!t) return;
|
|
1838
1838
|
R.current = t, _("input"), C(""), T(""), x("");
|
|
1839
1839
|
}
|
|
@@ -1848,7 +1848,7 @@ function ba({ editor: e, lang: t = "zh", messages: n = $i, selectionSnapshot: r,
|
|
|
1848
1848
|
return;
|
|
1849
1849
|
}
|
|
1850
1850
|
if (h(null), t.id === "improve") {
|
|
1851
|
-
|
|
1851
|
+
ya(e, "rewrite-selection", a);
|
|
1852
1852
|
return;
|
|
1853
1853
|
}
|
|
1854
1854
|
t.run(), e.commands.focus();
|
|
@@ -1868,13 +1868,13 @@ function ba({ editor: e, lang: t = "zh", messages: n = $i, selectionSnapshot: r,
|
|
|
1868
1868
|
let s = new AbortController(), c = Dr(o, a, t, s.signal, void 0, Ar(e)?.target);
|
|
1869
1869
|
z.current = s, B.current = c.id, x(a), T(""), C(""), _("generating");
|
|
1870
1870
|
try {
|
|
1871
|
-
let t = await
|
|
1871
|
+
let t = await Pr(i.handler, c, (t) => {
|
|
1872
1872
|
B.current !== c.id || s.signal.aborted || (oe.current = t, V.current === null && (V.current = window.requestAnimationFrame(() => {
|
|
1873
|
-
V.current = null,
|
|
1873
|
+
V.current = null, Fr(e, oe.current), C(oe.current);
|
|
1874
1874
|
})));
|
|
1875
1875
|
});
|
|
1876
1876
|
if (B.current !== c.id || s.signal.aborted) return;
|
|
1877
|
-
if (!
|
|
1877
|
+
if (!Fr(e, t)) throw new xr("invalid-output", "Ask AI output is incompatible with the selected content.");
|
|
1878
1878
|
H(), C(t), y(""), _(Ar(e)?.status === "target" ? "result" : "conflict");
|
|
1879
1879
|
} catch (t) {
|
|
1880
1880
|
if (B.current !== c.id) return;
|
|
@@ -1925,7 +1925,7 @@ function ba({ editor: e, lang: t = "zh", messages: n = $i, selectionSnapshot: r,
|
|
|
1925
1925
|
return /* @__PURE__ */ Z(tr, {
|
|
1926
1926
|
ref: F,
|
|
1927
1927
|
editor: e,
|
|
1928
|
-
pluginKey:
|
|
1928
|
+
pluginKey: ba,
|
|
1929
1929
|
className: `markweave-floating-toolbar markweave-floating-toolbar--${c.variant} markweave-floating-toolbar--motion-${c.motionPhase}`,
|
|
1930
1930
|
"data-motion": c.motionPhase,
|
|
1931
1931
|
"data-position-strategy": ge.strategy,
|
|
@@ -1933,20 +1933,24 @@ function ba({ editor: e, lang: t = "zh", messages: n = $i, selectionSnapshot: r,
|
|
|
1933
1933
|
"data-popover-placement": m ? P : void 0,
|
|
1934
1934
|
"data-ask-ai-session": m === "ask-ai" ? "open" : "closed",
|
|
1935
1935
|
"data-testid": "markweave-floating-toolbar",
|
|
1936
|
-
style:
|
|
1936
|
+
style: na(c, j),
|
|
1937
1937
|
updateDelay: 0,
|
|
1938
1938
|
getReferencedVirtualElement: pe,
|
|
1939
1939
|
options: ge,
|
|
1940
1940
|
shouldShow: ({ editor: e }) => {
|
|
1941
1941
|
let t = Ar(e);
|
|
1942
|
-
return
|
|
1942
|
+
return Ft(jt(e), {
|
|
1943
|
+
editable: e.isEditable,
|
|
1944
|
+
hasAskAiPreview: Mr(e.state),
|
|
1945
|
+
hasActiveAskAiTableTarget: t?.target.kind === "table" && t.status === "target"
|
|
1946
|
+
});
|
|
1943
1947
|
},
|
|
1944
1948
|
children: /* @__PURE__ */ Q("div", {
|
|
1945
1949
|
ref: I,
|
|
1946
1950
|
className: "markweave-floating-toolbar-content",
|
|
1947
1951
|
"data-menu": m ?? "none",
|
|
1948
1952
|
children: [
|
|
1949
|
-
ce.map((e, t) => /* @__PURE__ */ Z(
|
|
1953
|
+
ce.map((e, t) => /* @__PURE__ */ Z(wa, {
|
|
1950
1954
|
button: e,
|
|
1951
1955
|
expanded: m === e.id,
|
|
1952
1956
|
showDivider: t > 0 && ce[t - 1].group !== e.group,
|
|
@@ -1955,13 +1959,13 @@ function ba({ editor: e, lang: t = "zh", messages: n = $i, selectionSnapshot: r,
|
|
|
1955
1959
|
onTooltipChange: we,
|
|
1956
1960
|
onRun: _e
|
|
1957
1961
|
}, e.id)),
|
|
1958
|
-
m === "block-type" ? /* @__PURE__ */ Z(
|
|
1962
|
+
m === "block-type" ? /* @__PURE__ */ Z(Ea, {
|
|
1959
1963
|
editor: e,
|
|
1960
1964
|
messages: n,
|
|
1961
1965
|
onPopoverRef: me,
|
|
1962
1966
|
onClose: () => h(null)
|
|
1963
1967
|
}) : null,
|
|
1964
|
-
m === "ask-ai" ? /* @__PURE__ */ Z(
|
|
1968
|
+
m === "ask-ai" ? /* @__PURE__ */ Z(Ca, {
|
|
1965
1969
|
inputRef: L,
|
|
1966
1970
|
messages: n,
|
|
1967
1971
|
phase: g,
|
|
@@ -1978,7 +1982,7 @@ function ba({ editor: e, lang: t = "zh", messages: n = $i, selectionSnapshot: r,
|
|
|
1978
1982
|
onDiscard: () => U(!0),
|
|
1979
1983
|
onPopoverRef: me
|
|
1980
1984
|
}) : null,
|
|
1981
|
-
m === "link" ? /* @__PURE__ */ Z(
|
|
1985
|
+
m === "link" ? /* @__PURE__ */ Z(Sa, {
|
|
1982
1986
|
inputRef: ae,
|
|
1983
1987
|
messages: n,
|
|
1984
1988
|
value: E,
|
|
@@ -1991,13 +1995,13 @@ function ba({ editor: e, lang: t = "zh", messages: n = $i, selectionSnapshot: r,
|
|
|
1991
1995
|
onRemove: Ce,
|
|
1992
1996
|
onPopoverRef: me
|
|
1993
1997
|
}) : null,
|
|
1994
|
-
m === "color" ? /* @__PURE__ */ Z(
|
|
1998
|
+
m === "color" ? /* @__PURE__ */ Z(Oa, {
|
|
1995
1999
|
editor: e,
|
|
1996
2000
|
messages: n,
|
|
1997
2001
|
onPopoverRef: me,
|
|
1998
2002
|
onClose: () => h(null)
|
|
1999
2003
|
}) : null,
|
|
2000
|
-
m === "more" ? /* @__PURE__ */ Z(
|
|
2004
|
+
m === "more" ? /* @__PURE__ */ Z(Aa, {
|
|
2001
2005
|
editor: e,
|
|
2002
2006
|
messages: n,
|
|
2003
2007
|
activeTooltipId: u,
|
|
@@ -2011,14 +2015,14 @@ function ba({ editor: e, lang: t = "zh", messages: n = $i, selectionSnapshot: r,
|
|
|
2011
2015
|
"data-testid": "markweave-floating-toolbar-tooltip",
|
|
2012
2016
|
"data-button-id": le.buttonId,
|
|
2013
2017
|
"data-active": le.active,
|
|
2014
|
-
style:
|
|
2018
|
+
style: ia(f),
|
|
2015
2019
|
children: le.label
|
|
2016
2020
|
}) : null
|
|
2017
2021
|
]
|
|
2018
2022
|
})
|
|
2019
2023
|
});
|
|
2020
2024
|
}
|
|
2021
|
-
function
|
|
2025
|
+
function Sa({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRemove: a, onValueChange: o, onApply: s, onOpen: c, onRemove: l, onPopoverRef: u }) {
|
|
2022
2026
|
let d = sr(t);
|
|
2023
2027
|
return /* @__PURE__ */ Q("form", {
|
|
2024
2028
|
ref: u,
|
|
@@ -2071,7 +2075,7 @@ function xa({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRe
|
|
|
2071
2075
|
})]
|
|
2072
2076
|
});
|
|
2073
2077
|
}
|
|
2074
|
-
function
|
|
2078
|
+
function Ca({ inputRef: e, messages: t, phase: n, prompt: r, hasStreamedContent: i, error: a, onPromptChange: o, onSubmit: s, onStop: c, onAccept: l, onRetry: u, onDiscard: d, onPopoverRef: f }) {
|
|
2075
2079
|
let p = n === "input" || n === "result" || n === "error";
|
|
2076
2080
|
return /* @__PURE__ */ Q("section", {
|
|
2077
2081
|
ref: f,
|
|
@@ -2181,7 +2185,7 @@ function Sa({ inputRef: e, messages: t, phase: n, prompt: r, hasStreamedContent:
|
|
|
2181
2185
|
]
|
|
2182
2186
|
});
|
|
2183
2187
|
}
|
|
2184
|
-
function
|
|
2188
|
+
function wa({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointerDown: i, onTooltipChange: a, onRun: o }) {
|
|
2185
2189
|
return /* @__PURE__ */ Q(lt, { children: [n ? /* @__PURE__ */ Z("span", {
|
|
2186
2190
|
className: "markweave-floating-toolbar-divider",
|
|
2187
2191
|
"aria-hidden": "true"
|
|
@@ -2189,7 +2193,7 @@ function Ca({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointe
|
|
|
2189
2193
|
type: "button",
|
|
2190
2194
|
className: `markweave-floating-toolbar-button markweave-floating-toolbar-button--${e.id}`,
|
|
2191
2195
|
"aria-label": e.label,
|
|
2192
|
-
"aria-expanded":
|
|
2196
|
+
"aria-expanded": va(e.id) ? t : void 0,
|
|
2193
2197
|
"data-active": e.active || t,
|
|
2194
2198
|
"data-tooltip-active": r ? "true" : "false",
|
|
2195
2199
|
"data-testid": `markweave-floating-toolbar-button-${e.id}`,
|
|
@@ -2199,13 +2203,13 @@ function Ca({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointe
|
|
|
2199
2203
|
onMouseEnter: (t) => a(e.id, t.currentTarget),
|
|
2200
2204
|
onMouseLeave: () => a(null),
|
|
2201
2205
|
onClick: () => o(e),
|
|
2202
|
-
children: /* @__PURE__ */ Z(
|
|
2206
|
+
children: /* @__PURE__ */ Z(Ta, {
|
|
2203
2207
|
button: e,
|
|
2204
2208
|
expanded: t
|
|
2205
2209
|
})
|
|
2206
2210
|
})] });
|
|
2207
2211
|
}
|
|
2208
|
-
function
|
|
2212
|
+
function Ta({ button: e, expanded: t }) {
|
|
2209
2213
|
return e.id === "improve" || e.id === "ask-ai" ? /* @__PURE__ */ Q("span", {
|
|
2210
2214
|
className: "markweave-floating-toolbar-button-inner",
|
|
2211
2215
|
children: [/* @__PURE__ */ Z($, { name: "sparkles" }), /* @__PURE__ */ Z("span", { children: e.glyph })]
|
|
@@ -2223,7 +2227,7 @@ function wa({ button: e, expanded: t }) {
|
|
|
2223
2227
|
}), /* @__PURE__ */ Z($, { name: t ? "chevron-up" : "chevron-down" })]
|
|
2224
2228
|
}) : /* @__PURE__ */ Z($, { name: "more" });
|
|
2225
2229
|
}
|
|
2226
|
-
function
|
|
2230
|
+
function Ea({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
|
|
2227
2231
|
let i = sr(t), a = dr(t);
|
|
2228
2232
|
return /* @__PURE__ */ Q("div", {
|
|
2229
2233
|
ref: n,
|
|
@@ -2242,21 +2246,21 @@ function Ta({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
|
|
|
2242
2246
|
},
|
|
2243
2247
|
children: [/* @__PURE__ */ Z("span", {
|
|
2244
2248
|
className: "markweave-floating-toolbar-menu-icon",
|
|
2245
|
-
children: /* @__PURE__ */ Z(
|
|
2249
|
+
children: /* @__PURE__ */ Z(Da, { option: t })
|
|
2246
2250
|
}), /* @__PURE__ */ Z("span", { children: t.label })]
|
|
2247
2251
|
}, t.id))]
|
|
2248
2252
|
});
|
|
2249
2253
|
}
|
|
2250
|
-
function
|
|
2254
|
+
function Da({ option: e }) {
|
|
2251
2255
|
return e.id === "paragraph" ? /* @__PURE__ */ Z($, { name: "text" }) : e.glyph === "bullet-list" || e.glyph === "numbered-list" || e.glyph === "todo-list" || e.glyph === "quote" || e.glyph === "code-block" ? /* @__PURE__ */ Z($, { name: e.glyph }) : /* @__PURE__ */ Z("span", { children: e.glyph });
|
|
2252
2256
|
}
|
|
2253
|
-
function
|
|
2257
|
+
function Oa({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
|
|
2254
2258
|
let i = sr(t), a = e.getAttributes("textStyle").color, o = e.getAttributes("highlight").color;
|
|
2255
2259
|
return /* @__PURE__ */ Q("div", {
|
|
2256
2260
|
ref: n,
|
|
2257
2261
|
className: "markweave-floating-toolbar-popover markweave-floating-toolbar-color-popover",
|
|
2258
2262
|
"data-testid": "markweave-floating-toolbar-color-menu",
|
|
2259
|
-
children: [/* @__PURE__ */ Z(
|
|
2263
|
+
children: [/* @__PURE__ */ Z(ka, {
|
|
2260
2264
|
title: i.textColorTitle,
|
|
2261
2265
|
mode: "text",
|
|
2262
2266
|
activeColor: a ?? null,
|
|
@@ -2264,7 +2268,7 @@ function Da({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
|
|
|
2264
2268
|
onSelect: (t) => {
|
|
2265
2269
|
yr(e, t), r();
|
|
2266
2270
|
}
|
|
2267
|
-
}), /* @__PURE__ */ Z(
|
|
2271
|
+
}), /* @__PURE__ */ Z(ka, {
|
|
2268
2272
|
title: i.highlightColorTitle,
|
|
2269
2273
|
mode: "highlight",
|
|
2270
2274
|
activeColor: o ?? null,
|
|
@@ -2275,7 +2279,7 @@ function Da({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
|
|
|
2275
2279
|
})]
|
|
2276
2280
|
});
|
|
2277
2281
|
}
|
|
2278
|
-
function
|
|
2282
|
+
function ka({ title: e, mode: t, activeColor: n, options: r, onSelect: i }) {
|
|
2279
2283
|
return /* @__PURE__ */ Q("section", {
|
|
2280
2284
|
className: "markweave-floating-toolbar-color-section",
|
|
2281
2285
|
"aria-label": e,
|
|
@@ -2304,13 +2308,13 @@ function Oa({ title: e, mode: t, activeColor: n, options: r, onSelect: i }) {
|
|
|
2304
2308
|
})]
|
|
2305
2309
|
});
|
|
2306
2310
|
}
|
|
2307
|
-
function
|
|
2311
|
+
function Aa({ editor: e, messages: t, activeTooltipId: n, onPopoverRef: r, onTooltipChange: i, onClose: a }) {
|
|
2308
2312
|
let o = cr(t);
|
|
2309
2313
|
return /* @__PURE__ */ Z("div", {
|
|
2310
2314
|
ref: r,
|
|
2311
2315
|
className: "markweave-floating-toolbar-popover markweave-floating-toolbar-more-menu",
|
|
2312
2316
|
"data-testid": "markweave-floating-toolbar-more-menu",
|
|
2313
|
-
children: o.map((t, r) => /* @__PURE__ */ Z(
|
|
2317
|
+
children: o.map((t, r) => /* @__PURE__ */ Z(ja, {
|
|
2314
2318
|
action: t,
|
|
2315
2319
|
active: fr(e, t.id),
|
|
2316
2320
|
tooltipActive: n === t.id,
|
|
@@ -2322,7 +2326,7 @@ function ka({ editor: e, messages: t, activeTooltipId: n, onPopoverRef: r, onToo
|
|
|
2322
2326
|
}, t.id))
|
|
2323
2327
|
});
|
|
2324
2328
|
}
|
|
2325
|
-
function
|
|
2329
|
+
function ja({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipChange: i, onRun: a }) {
|
|
2326
2330
|
return /* @__PURE__ */ Q(lt, { children: [r ? /* @__PURE__ */ Z("span", {
|
|
2327
2331
|
className: "markweave-floating-toolbar-divider",
|
|
2328
2332
|
"aria-hidden": "true"
|
|
@@ -2338,7 +2342,7 @@ function Aa({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipC
|
|
|
2338
2342
|
onMouseEnter: () => i(e.id),
|
|
2339
2343
|
onMouseLeave: () => i(null),
|
|
2340
2344
|
onClick: a,
|
|
2341
|
-
children: /* @__PURE__ */ Z(
|
|
2345
|
+
children: /* @__PURE__ */ Z(Ma, { id: e.id })
|
|
2342
2346
|
}), n ? /* @__PURE__ */ Z("div", {
|
|
2343
2347
|
className: "markweave-floating-toolbar-tooltip markweave-floating-toolbar-tooltip--more",
|
|
2344
2348
|
role: "tooltip",
|
|
@@ -2346,10 +2350,10 @@ function Aa({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipC
|
|
|
2346
2350
|
}) : null]
|
|
2347
2351
|
})] });
|
|
2348
2352
|
}
|
|
2349
|
-
function
|
|
2353
|
+
function Ma({ id: e }) {
|
|
2350
2354
|
return e === "superscript" ? /* @__PURE__ */ Z($, { name: "superscript" }) : e === "subscript" ? /* @__PURE__ */ Z($, { name: "subscript" }) : e === "inline-math" ? /* @__PURE__ */ Z($, { name: "math" }) : Z($, { name: e });
|
|
2351
2355
|
}
|
|
2352
|
-
var
|
|
2356
|
+
var Na = {
|
|
2353
2357
|
sparkles: xe,
|
|
2354
2358
|
"arrow-up": b,
|
|
2355
2359
|
check: O,
|
|
@@ -2385,7 +2389,7 @@ var Ma = {
|
|
|
2385
2389
|
x: Ie
|
|
2386
2390
|
};
|
|
2387
2391
|
function $({ name: e }) {
|
|
2388
|
-
let t =
|
|
2392
|
+
let t = Na[e];
|
|
2389
2393
|
return /* @__PURE__ */ Z(t, {
|
|
2390
2394
|
"aria-hidden": "true",
|
|
2391
2395
|
absoluteStrokeWidth: !0,
|
|
@@ -2395,7 +2399,7 @@ function $({ name: e }) {
|
|
|
2395
2399
|
}
|
|
2396
2400
|
//#endregion
|
|
2397
2401
|
//#region src/ui/math/MathEditorPopover.tsx
|
|
2398
|
-
function
|
|
2402
|
+
function Pa({ editor: e, messages: t, onClose: n, target: r }) {
|
|
2399
2403
|
let i = J(null), a = J(null), [o, s] = Y(r.latex), [c, l] = Y(null), u = t.math, d = q(() => $t(e, r) ?? 1, [e, r]), f = q(() => en(e, r), [e, r]), p = q(() => o === r.latex && f ? {
|
|
2400
2404
|
html: f,
|
|
2401
2405
|
error: !1
|
|
@@ -2580,7 +2584,7 @@ function Na({ editor: e, messages: t, onClose: n, target: r }) {
|
|
|
2580
2584
|
}
|
|
2581
2585
|
//#endregion
|
|
2582
2586
|
//#region src/ui/slash-command/SlashCommandMenu.tsx
|
|
2583
|
-
var
|
|
2587
|
+
var Fa = n("zh"), Ia = {
|
|
2584
2588
|
type: Ae,
|
|
2585
2589
|
"heading-1": ie,
|
|
2586
2590
|
"heading-2": ae,
|
|
@@ -2603,8 +2607,8 @@ var Pa = n("zh"), Fa = {
|
|
|
2603
2607
|
video: Fe,
|
|
2604
2608
|
attachment: pe
|
|
2605
2609
|
};
|
|
2606
|
-
function
|
|
2607
|
-
let t =
|
|
2610
|
+
function La({ name: e }) {
|
|
2611
|
+
let t = Ia[e];
|
|
2608
2612
|
return /* @__PURE__ */ Z(t, {
|
|
2609
2613
|
"aria-hidden": "true",
|
|
2610
2614
|
absoluteStrokeWidth: !0,
|
|
@@ -2612,7 +2616,7 @@ function Ia({ name: e }) {
|
|
|
2612
2616
|
strokeWidth: 1.6
|
|
2613
2617
|
});
|
|
2614
2618
|
}
|
|
2615
|
-
function
|
|
2619
|
+
function Ra(e, t, n) {
|
|
2616
2620
|
return !fn(e) || !n ? {
|
|
2617
2621
|
visible: !1,
|
|
2618
2622
|
empty: !1,
|
|
@@ -2627,16 +2631,16 @@ function La(e, t, n) {
|
|
|
2627
2631
|
activeIndex: Math.min(t.length - 1, Math.max(0, e.activeIndex))
|
|
2628
2632
|
};
|
|
2629
2633
|
}
|
|
2630
|
-
function
|
|
2634
|
+
function za(e, t) {
|
|
2631
2635
|
return Object.values(t.slash.groups).map((t) => ({
|
|
2632
2636
|
group: t,
|
|
2633
2637
|
commands: e.filter((e) => e.group === t)
|
|
2634
2638
|
})).filter((e) => e.commands.length > 0);
|
|
2635
2639
|
}
|
|
2636
|
-
function
|
|
2640
|
+
function Ba(e, t) {
|
|
2637
2641
|
return t.slash.uploadKindLabels[e] ?? t.slash.uploadKindLabels.upload;
|
|
2638
2642
|
}
|
|
2639
|
-
function
|
|
2643
|
+
function Va({ command: e, messages: t, onBack: n, onSelect: r }) {
|
|
2640
2644
|
let [i, a] = Y(""), [o, s] = Y(0), c = q(() => {
|
|
2641
2645
|
let e = i.trim().toLowerCase();
|
|
2642
2646
|
return (e ? t.slash.emojiItems.filter((t) => [
|
|
@@ -2703,7 +2707,7 @@ function Ba({ command: e, messages: t, onBack: n, onSelect: r }) {
|
|
|
2703
2707
|
]
|
|
2704
2708
|
});
|
|
2705
2709
|
}
|
|
2706
|
-
function
|
|
2710
|
+
function Ha({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
|
|
2707
2711
|
let a = e.uploadKind ?? "attachment", [o, s] = Y(""), [c, l] = Y(null), [u, d] = Y(null), [f, p] = Y(!1), m = async (t) => {
|
|
2708
2712
|
r(e, { uploadResult: await X({
|
|
2709
2713
|
kind: a,
|
|
@@ -2743,7 +2747,7 @@ function Va({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
|
|
|
2743
2747
|
onMouseDown: (e) => e.preventDefault(),
|
|
2744
2748
|
onClick: n,
|
|
2745
2749
|
children: t.common.back
|
|
2746
|
-
}), /* @__PURE__ */ Z("span", { children:
|
|
2750
|
+
}), /* @__PURE__ */ Z("span", { children: Ba(a, t) })]
|
|
2747
2751
|
}),
|
|
2748
2752
|
/* @__PURE__ */ Q("label", {
|
|
2749
2753
|
className: "markweave-slash-upload-field",
|
|
@@ -2791,10 +2795,10 @@ function Va({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
|
|
|
2791
2795
|
]
|
|
2792
2796
|
});
|
|
2793
2797
|
}
|
|
2794
|
-
function
|
|
2795
|
-
let l =
|
|
2798
|
+
function Ua({ commands: e, messages: t = Fa, state: n, position: r, inputCommand: i, onActiveIndexChange: a, onInputCommandChange: o, onSelect: s, onUpload: c }) {
|
|
2799
|
+
let l = Ra(n, e, r);
|
|
2796
2800
|
if (!l.visible || !r) return null;
|
|
2797
|
-
let u =
|
|
2801
|
+
let u = za(e, t), d = {
|
|
2798
2802
|
left: r.left,
|
|
2799
2803
|
top: r.top,
|
|
2800
2804
|
maxHeight: r.maxHeight,
|
|
@@ -2816,12 +2820,12 @@ function Ha({ commands: e, messages: t = Pa, state: n, position: r, inputCommand
|
|
|
2816
2820
|
"aria-label": t.slash.ariaLabel,
|
|
2817
2821
|
"data-placement": r.placement,
|
|
2818
2822
|
"data-testid": "markweave-slash-menu",
|
|
2819
|
-
children: i?.inputKind === "emoji" ? /* @__PURE__ */ Z(
|
|
2823
|
+
children: i?.inputKind === "emoji" ? /* @__PURE__ */ Z(Va, {
|
|
2820
2824
|
command: i,
|
|
2821
2825
|
messages: t,
|
|
2822
2826
|
onBack: m,
|
|
2823
2827
|
onSelect: s
|
|
2824
|
-
}) : i?.inputKind === "upload" ? /* @__PURE__ */ Z(
|
|
2828
|
+
}) : i?.inputKind === "upload" ? /* @__PURE__ */ Z(Ha, {
|
|
2825
2829
|
command: i,
|
|
2826
2830
|
messages: t,
|
|
2827
2831
|
onBack: m,
|
|
@@ -2865,7 +2869,7 @@ function Ha({ commands: e, messages: t = Pa, state: n, position: r, inputCommand
|
|
|
2865
2869
|
}
|
|
2866
2870
|
},
|
|
2867
2871
|
children: [
|
|
2868
|
-
/* @__PURE__ */ Z(
|
|
2872
|
+
/* @__PURE__ */ Z(La, { name: t.icon }),
|
|
2869
2873
|
/* @__PURE__ */ Z("span", { children: t.label }),
|
|
2870
2874
|
o && t.disabledReason ? /* @__PURE__ */ Z("small", { children: t.disabledReason }) : null
|
|
2871
2875
|
]
|
|
@@ -2877,7 +2881,7 @@ function Ha({ commands: e, messages: t = Pa, state: n, position: r, inputCommand
|
|
|
2877
2881
|
}
|
|
2878
2882
|
//#endregion
|
|
2879
2883
|
//#region src/ui/table/TableControls.tsx
|
|
2880
|
-
var
|
|
2884
|
+
var Wa = n("zh"), Ga = {
|
|
2881
2885
|
"move-left": v,
|
|
2882
2886
|
"move-right": y,
|
|
2883
2887
|
"move-up": b,
|
|
@@ -2897,7 +2901,7 @@ var Ua = n("zh"), Wa = {
|
|
|
2897
2901
|
split: ke,
|
|
2898
2902
|
"ask-ai": xe,
|
|
2899
2903
|
delete: je
|
|
2900
|
-
},
|
|
2904
|
+
}, Ka = {
|
|
2901
2905
|
left: d,
|
|
2902
2906
|
center: l,
|
|
2903
2907
|
right: f,
|
|
@@ -2905,13 +2909,13 @@ var Ua = n("zh"), Wa = {
|
|
|
2905
2909
|
middle: p,
|
|
2906
2910
|
bottom: m
|
|
2907
2911
|
};
|
|
2908
|
-
function
|
|
2912
|
+
function qa({ active: e, editor: t, interactionState: n = Tn, messages: r = Wa, onCopyPayload: i, onCommandResult: a, askAi: o }) {
|
|
2909
2913
|
let [s, c] = Y(null), [l, u] = Y(null), [d, f] = Y("row-edge"), [p, m] = Y(null), [h, g] = Y(null), [_, v] = Y(null), [y, b] = Y(null), [x, S] = Y(null), [C, w] = Y(null), [T, E] = Y(null), [, D] = Y(0), ee = J(null), O = J(null), [k, A] = Y(null), M = J(null), te = J(null), N = J(null), P = J(null), ne = J(null), re = J(null), F = J(null), I = e ? Cn(t.state) : null;
|
|
2910
2914
|
if (K(() => {
|
|
2911
2915
|
if (!k) return;
|
|
2912
2916
|
let e = window.setTimeout(() => {
|
|
2913
2917
|
A(null);
|
|
2914
|
-
},
|
|
2918
|
+
}, ui);
|
|
2915
2919
|
return () => {
|
|
2916
2920
|
window.clearTimeout(e);
|
|
2917
2921
|
};
|
|
@@ -2919,13 +2923,13 @@ function Ka({ active: e, editor: t, interactionState: n = Tn, messages: r = Ua,
|
|
|
2919
2923
|
let e = (e) => {
|
|
2920
2924
|
let n = ee.current;
|
|
2921
2925
|
if (!n) return;
|
|
2922
|
-
let r =
|
|
2926
|
+
let r = Zr(t, n.axis, e.clientX, e.clientY);
|
|
2923
2927
|
r !== null && (e.preventDefault(), O.current = r, e.dataTransfer && (e.dataTransfer.dropEffect = "move"));
|
|
2924
2928
|
}, n = (e) => {
|
|
2925
2929
|
let n = ee.current;
|
|
2926
2930
|
if (!n) return;
|
|
2927
|
-
let r =
|
|
2928
|
-
e.preventDefault(), ee.current = null, O.current = null, r !== null &&
|
|
2931
|
+
let r = Zr(t, n.axis, e.clientX, e.clientY) ?? O.current;
|
|
2932
|
+
e.preventDefault(), ee.current = null, O.current = null, r !== null && si(t, n.axis, n.index, r);
|
|
2929
2933
|
};
|
|
2930
2934
|
return document.addEventListener("dragover", e), document.addEventListener("drop", n), () => {
|
|
2931
2935
|
document.removeEventListener("dragover", e), document.removeEventListener("drop", n);
|
|
@@ -2936,31 +2940,31 @@ function Ka({ active: e, editor: t, interactionState: n = Tn, messages: r = Ua,
|
|
|
2936
2940
|
return;
|
|
2937
2941
|
}
|
|
2938
2942
|
let r = () => {
|
|
2939
|
-
let e = t.view.dom.closest(".markweave-editor-frame") ?? t.view.dom.parentElement, r =
|
|
2943
|
+
let e = t.view.dom.closest(".markweave-editor-frame") ?? t.view.dom.parentElement, r = ei(t, n, "row", I?.activeCellPos ?? null), i = ei(t, n, "column", I?.activeCellPos ?? null), a = r ? $r(t, r) : null, o = i ? $r(t, i) : null, c = ii(t, "selection").length > 0 ? ai(t) : null, l = Xr(t)?.getBoundingClientRect() ?? null;
|
|
2940
2944
|
if (!e) {
|
|
2941
2945
|
v(null), b(null), S(null), w(null), E(null);
|
|
2942
2946
|
return;
|
|
2943
2947
|
}
|
|
2944
2948
|
let u = e.getBoundingClientRect();
|
|
2945
|
-
a ? v(
|
|
2949
|
+
a ? v(Gr({
|
|
2946
2950
|
targetRect: a,
|
|
2947
2951
|
frameRect: u,
|
|
2948
2952
|
kind: "row"
|
|
2949
|
-
})) : s === "row" && d === "row-edge" || v(null), o ? b(
|
|
2953
|
+
})) : s === "row" && d === "row-edge" || v(null), o ? b(Gr({
|
|
2950
2954
|
targetRect: o,
|
|
2951
2955
|
frameRect: u,
|
|
2952
2956
|
kind: "column"
|
|
2953
|
-
})) : s === "column" && d === "column-edge" || b(null), c ? S(
|
|
2957
|
+
})) : s === "column" && d === "column-edge" || b(null), c ? S(Gr({
|
|
2954
2958
|
targetRect: c,
|
|
2955
2959
|
frameRect: u,
|
|
2956
2960
|
kind: "selection"
|
|
2957
2961
|
})) : s === "selection" && d === "selection-edge" || S(null);
|
|
2958
2962
|
let f = n.hoverCellPos !== null && !!(r && r.index === r.visualHeight - 1), p = n.hoverCellPos !== null && !!(i && i.index === i.visualWidth - 1);
|
|
2959
|
-
w(l && f ?
|
|
2963
|
+
w(l && f ? Kr({
|
|
2960
2964
|
tableRect: l,
|
|
2961
2965
|
frameRect: u,
|
|
2962
2966
|
kind: "row"
|
|
2963
|
-
}) : null), E(l && p ?
|
|
2967
|
+
}) : null), E(l && p ? Kr({
|
|
2964
2968
|
tableRect: l,
|
|
2965
2969
|
frameRect: u,
|
|
2966
2970
|
kind: "column"
|
|
@@ -2991,15 +2995,15 @@ function Ka({ active: e, editor: t, interactionState: n = Tn, messages: r = Ua,
|
|
|
2991
2995
|
m(null);
|
|
2992
2996
|
return;
|
|
2993
2997
|
}
|
|
2994
|
-
let i = n.getBoundingClientRect(), a = s === "row" ?
|
|
2998
|
+
let i = n.getBoundingClientRect(), a = s === "row" ? Xr(t)?.getBoundingClientRect() : null, o = a ? {
|
|
2995
2999
|
left: i.left,
|
|
2996
3000
|
top: a.top,
|
|
2997
3001
|
width: i.width,
|
|
2998
3002
|
height: i.height
|
|
2999
|
-
} : i, c = e.getBoundingClientRect(), l = r.getBoundingClientRect(), u = N.current?.scrollHeight ?? 0, f = u > 0 ? u + 12 : 0, p =
|
|
3003
|
+
} : i, c = e.getBoundingClientRect(), l = r.getBoundingClientRect(), u = N.current?.scrollHeight ?? 0, f = u > 0 ? u + 12 : 0, p = Ur({
|
|
3000
3004
|
anchorRect: o,
|
|
3001
3005
|
frameRect: c,
|
|
3002
|
-
boundaryRect:
|
|
3006
|
+
boundaryRect: ti(e),
|
|
3003
3007
|
menuSize: {
|
|
3004
3008
|
width: l.width || 254,
|
|
3005
3009
|
height: f || l.height || 410
|
|
@@ -3031,10 +3035,10 @@ function Ka({ active: e, editor: t, interactionState: n = Tn, messages: r = Ua,
|
|
|
3031
3035
|
return;
|
|
3032
3036
|
}
|
|
3033
3037
|
let a = r.getBoundingClientRect(), o = Math.max(r.scrollHeight + 2, a.height);
|
|
3034
|
-
g(
|
|
3038
|
+
g(Wr({
|
|
3035
3039
|
triggerRect: i.getBoundingClientRect(),
|
|
3036
3040
|
parentMenuRect: n.getBoundingClientRect(),
|
|
3037
|
-
boundaryRect:
|
|
3041
|
+
boundaryRect: ti(e),
|
|
3038
3042
|
submenuSize: {
|
|
3039
3043
|
width: a.width || 238,
|
|
3040
3044
|
height: o || 410
|
|
@@ -3078,14 +3082,14 @@ function Ka({ active: e, editor: t, interactionState: n = Tn, messages: r = Ua,
|
|
|
3078
3082
|
let n = s === e && d === t;
|
|
3079
3083
|
f(t), c(n ? null : e), u(null);
|
|
3080
3084
|
}, ae = () => {
|
|
3081
|
-
t.view.dispatch(
|
|
3085
|
+
t.view.dispatch(zr(t.state.tr, null));
|
|
3082
3086
|
}, L = (e, r) => {
|
|
3083
3087
|
let i = n.hoverCellPos ?? I?.activeCellPos ?? null, a = n.hoverCellPos === null ? null : e === "row" ? n.hoverVisualRowIndex : n.hoverVisualColumnIndex;
|
|
3084
|
-
i !== null &&
|
|
3088
|
+
i !== null && ci(t, i, e, { visualIndex: a }), ie(e, r);
|
|
3085
3089
|
}, R = () => {
|
|
3086
3090
|
ae(), ie("selection", "selection-edge");
|
|
3087
|
-
}, z =
|
|
3088
|
-
let o = await
|
|
3091
|
+
}, z = ei(t, n, "row", I?.activeCellPos ?? null), B = ei(t, n, "column", I?.activeCellPos ?? null), V = o?.enabled === !0 && typeof o.handler == "function", oe = ii(t, "selection", { askAiEnabled: V }).length > 0, se = s ? ii(t, s, { askAiEnabled: V }) : [], ce = async (e, n) => {
|
|
3092
|
+
let o = await Jr({
|
|
3089
3093
|
editor: t,
|
|
3090
3094
|
commandId: e,
|
|
3091
3095
|
menu: n ?? s ?? "selection",
|
|
@@ -3093,12 +3097,12 @@ function Ka({ active: e, editor: t, interactionState: n = Tn, messages: r = Ua,
|
|
|
3093
3097
|
});
|
|
3094
3098
|
return o.copyFeedback ? (A(o.copyFeedback), o.copyPayload && i?.(o.copyPayload)) : A(null), a?.(o.commandResult), o.success;
|
|
3095
3099
|
}, le = (e) => {
|
|
3096
|
-
!V || !
|
|
3100
|
+
!V || !Ir(t, e) || (c(null), u(null));
|
|
3097
3101
|
}, ue = (e) => {
|
|
3098
3102
|
s !== "row" && s !== "column" || e(s) && D((e) => e + 1);
|
|
3099
3103
|
}, H = (e) => {
|
|
3100
3104
|
let r = e === "row" ? z : B, i = n.hoverCellPos ?? I?.activeCellPos ?? null;
|
|
3101
|
-
!r || i === null ||
|
|
3105
|
+
!r || i === null || mi(t, i, e, { visualIndex: r.index }) && ce(e === "row" ? "add-row-after" : "add-column-after", e);
|
|
3102
3106
|
}, U = (e, t, n) => {
|
|
3103
3107
|
ee.current = {
|
|
3104
3108
|
axis: e,
|
|
@@ -3111,7 +3115,7 @@ function Ka({ active: e, editor: t, interactionState: n = Tn, messages: r = Ua,
|
|
|
3111
3115
|
let t = e.key === "ArrowDown" ? 1 : -1;
|
|
3112
3116
|
r[i < 0 ? 0 : Math.min(r.length - 1, Math.max(0, i + t))]?.focus();
|
|
3113
3117
|
}
|
|
3114
|
-
}, W = s === "row" || s === "column" ?
|
|
3118
|
+
}, W = s === "row" || s === "column" ? Qr(t, s) : null;
|
|
3115
3119
|
return /* @__PURE__ */ Q("div", {
|
|
3116
3120
|
ref: M,
|
|
3117
3121
|
className: "markweave-table-controls",
|
|
@@ -3131,7 +3135,7 @@ function Ka({ active: e, editor: t, interactionState: n = Tn, messages: r = Ua,
|
|
|
3131
3135
|
"data-copy-kind": k.kind,
|
|
3132
3136
|
"data-text-length": k.textLength,
|
|
3133
3137
|
"data-html-length": k.htmlLength,
|
|
3134
|
-
children:
|
|
3138
|
+
children: Yr(k)
|
|
3135
3139
|
}) : null,
|
|
3136
3140
|
_ ? /* @__PURE__ */ Z("button", {
|
|
3137
3141
|
type: "button",
|
|
@@ -3261,7 +3265,7 @@ function Ka({ active: e, editor: t, interactionState: n = Tn, messages: r = Ua,
|
|
|
3261
3265
|
ref: te,
|
|
3262
3266
|
className: "markweave-table-menu",
|
|
3263
3267
|
role: "menu",
|
|
3264
|
-
"aria-label":
|
|
3268
|
+
"aria-label": fi(s, r),
|
|
3265
3269
|
"data-testid": "markweave-table-menu",
|
|
3266
3270
|
"data-positioned": p ? "true" : "false",
|
|
3267
3271
|
"data-placement": p?.placement,
|
|
@@ -3277,7 +3281,7 @@ function Ka({ active: e, editor: t, interactionState: n = Tn, messages: r = Ua,
|
|
|
3277
3281
|
className: "markweave-table-menu-scroll",
|
|
3278
3282
|
style: p ? { maxHeight: Math.max(1, p.maxHeight - 12) } : void 0,
|
|
3279
3283
|
children: se.map((e, n) => {
|
|
3280
|
-
let i =
|
|
3284
|
+
let i = ni(e), a = n === 0 ? i : ni(se[n - 1]), o = n > 0 && a !== i, d = s === "row" || s === "column" ? s : "selection", f = e.submenuId ? !0 : e.id === "edit-with-ai" ? V && wr(t, d) : e.commandId === null ? !1 : qr(t, e.commandId), p = ri(e, r), m = Ga[e.icon];
|
|
3281
3285
|
return /* @__PURE__ */ Q("button", {
|
|
3282
3286
|
type: "button",
|
|
3283
3287
|
role: "menuitem",
|
|
@@ -3352,14 +3356,14 @@ function Ka({ active: e, editor: t, interactionState: n = Tn, messages: r = Ua,
|
|
|
3352
3356
|
className: "markweave-table-submenu-title",
|
|
3353
3357
|
children: r.table.submenus.textColor
|
|
3354
3358
|
}),
|
|
3355
|
-
|
|
3359
|
+
li.map((e) => /* @__PURE__ */ Q("button", {
|
|
3356
3360
|
type: "button",
|
|
3357
3361
|
role: "menuitemradio",
|
|
3358
3362
|
"aria-checked": W?.textColorId === e.id,
|
|
3359
3363
|
"data-active": W?.textColorId === e.id ? "true" : "false",
|
|
3360
3364
|
"data-testid": `markweave-table-text-color-${e.id}`,
|
|
3361
3365
|
onMouseDown: (e) => e.preventDefault(),
|
|
3362
|
-
onClick: () => ue((n) =>
|
|
3366
|
+
onClick: () => ue((n) => Hr(t, n, e.id)),
|
|
3363
3367
|
children: [/* @__PURE__ */ Z("span", {
|
|
3364
3368
|
className: "markweave-table-color-swatch markweave-table-text-color-swatch",
|
|
3365
3369
|
"aria-hidden": "true",
|
|
@@ -3371,14 +3375,14 @@ function Ka({ active: e, editor: t, interactionState: n = Tn, messages: r = Ua,
|
|
|
3371
3375
|
className: "markweave-table-submenu-title",
|
|
3372
3376
|
children: r.table.submenus.backgroundColor
|
|
3373
3377
|
}),
|
|
3374
|
-
|
|
3378
|
+
li.map((e) => /* @__PURE__ */ Q("button", {
|
|
3375
3379
|
type: "button",
|
|
3376
3380
|
role: "menuitemradio",
|
|
3377
3381
|
"aria-checked": W?.backgroundColorId === e.id,
|
|
3378
3382
|
"data-active": W?.backgroundColorId === e.id ? "true" : "false",
|
|
3379
3383
|
"data-testid": `markweave-table-background-color-${e.id}`,
|
|
3380
3384
|
onMouseDown: (e) => e.preventDefault(),
|
|
3381
|
-
onClick: () => ue((n) =>
|
|
3385
|
+
onClick: () => ue((n) => Vr(t, n, e.id)),
|
|
3382
3386
|
children: [/* @__PURE__ */ Z("span", {
|
|
3383
3387
|
className: "markweave-table-color-swatch",
|
|
3384
3388
|
"aria-hidden": "true",
|
|
@@ -3402,8 +3406,8 @@ function Ka({ active: e, editor: t, interactionState: n = Tn, messages: r = Ua,
|
|
|
3402
3406
|
} : void 0,
|
|
3403
3407
|
onKeyDown: de,
|
|
3404
3408
|
children: [
|
|
3405
|
-
|
|
3406
|
-
let n =
|
|
3409
|
+
di.map((e) => {
|
|
3410
|
+
let n = Ka[e], i = W?.textAlign === e;
|
|
3407
3411
|
return /* @__PURE__ */ Q("button", {
|
|
3408
3412
|
type: "button",
|
|
3409
3413
|
role: "menuitemradio",
|
|
@@ -3411,7 +3415,7 @@ function Ka({ active: e, editor: t, interactionState: n = Tn, messages: r = Ua,
|
|
|
3411
3415
|
"data-active": i ? "true" : "false",
|
|
3412
3416
|
"data-testid": `markweave-table-alignment-${e}`,
|
|
3413
3417
|
onMouseDown: (e) => e.preventDefault(),
|
|
3414
|
-
onClick: () => ue((n) =>
|
|
3418
|
+
onClick: () => ue((n) => Br(t, n, e)),
|
|
3415
3419
|
children: [/* @__PURE__ */ Z(n, {
|
|
3416
3420
|
"aria-hidden": "true",
|
|
3417
3421
|
size: 18,
|
|
@@ -3420,8 +3424,8 @@ function Ka({ active: e, editor: t, interactionState: n = Tn, messages: r = Ua,
|
|
|
3420
3424
|
}, e);
|
|
3421
3425
|
}),
|
|
3422
3426
|
/* @__PURE__ */ Z("div", { className: "markweave-table-submenu-separator" }),
|
|
3423
|
-
|
|
3424
|
-
let n =
|
|
3427
|
+
pi.map((e) => {
|
|
3428
|
+
let n = Ka[e], i = W?.verticalAlign === e;
|
|
3425
3429
|
return /* @__PURE__ */ Q("button", {
|
|
3426
3430
|
type: "button",
|
|
3427
3431
|
role: "menuitemradio",
|
|
@@ -3429,7 +3433,7 @@ function Ka({ active: e, editor: t, interactionState: n = Tn, messages: r = Ua,
|
|
|
3429
3433
|
"data-active": i ? "true" : "false",
|
|
3430
3434
|
"data-testid": `markweave-table-alignment-${e}`,
|
|
3431
3435
|
onMouseDown: (e) => e.preventDefault(),
|
|
3432
|
-
onClick: () => ue((n) =>
|
|
3436
|
+
onClick: () => ue((n) => Br(t, n, e)),
|
|
3433
3437
|
children: [/* @__PURE__ */ Z(n, {
|
|
3434
3438
|
"aria-hidden": "true",
|
|
3435
3439
|
size: 18,
|
|
@@ -3446,7 +3450,7 @@ function Ka({ active: e, editor: t, interactionState: n = Tn, messages: r = Ua,
|
|
|
3446
3450
|
}
|
|
3447
3451
|
//#endregion
|
|
3448
3452
|
//#region src/ui/table/TableSelectionOverlay.tsx
|
|
3449
|
-
function
|
|
3453
|
+
function Ja({ editor: e, focusState: t }) {
|
|
3450
3454
|
let [n, r] = Y(null);
|
|
3451
3455
|
return Le(() => {
|
|
3452
3456
|
if (t.mode !== "cell-selection") {
|
|
@@ -3454,7 +3458,7 @@ function qa({ editor: e, focusState: t }) {
|
|
|
3454
3458
|
return;
|
|
3455
3459
|
}
|
|
3456
3460
|
let n = () => {
|
|
3457
|
-
r(
|
|
3461
|
+
r(oi(e, wn(e.state)));
|
|
3458
3462
|
};
|
|
3459
3463
|
return n(), window.addEventListener("resize", n), window.addEventListener("scroll", n, !0), () => {
|
|
3460
3464
|
window.removeEventListener("resize", n), window.removeEventListener("scroll", n, !0);
|
|
@@ -3490,16 +3494,16 @@ function qa({ editor: e, focusState: t }) {
|
|
|
3490
3494
|
}
|
|
3491
3495
|
//#endregion
|
|
3492
3496
|
//#region src/ui/toc/MarkweaveInnerToc.tsx
|
|
3493
|
-
function
|
|
3497
|
+
function Ya(e, t) {
|
|
3494
3498
|
return `${e.toc.itemAriaLabel}: ${t.text}`;
|
|
3495
3499
|
}
|
|
3496
|
-
function
|
|
3500
|
+
function Xa({ editor: e, state: t, messages: n, editable: r, placement: i }) {
|
|
3497
3501
|
let a = J(null);
|
|
3498
3502
|
if (K(() => {
|
|
3499
|
-
if (!(i !== "container" || !a.current)) return
|
|
3503
|
+
if (!(i !== "container" || !a.current)) return xi(a.current);
|
|
3500
3504
|
}, [i]), !t.items.length) return null;
|
|
3501
3505
|
let o = (t) => {
|
|
3502
|
-
|
|
3506
|
+
Si(e, t, {
|
|
3503
3507
|
behavior: "smooth",
|
|
3504
3508
|
focus: r
|
|
3505
3509
|
});
|
|
@@ -3526,7 +3530,7 @@ function Ya({ editor: e, state: t, messages: n, editable: r, placement: i }) {
|
|
|
3526
3530
|
"data-level": e.level,
|
|
3527
3531
|
"data-active": e.active ? "true" : "false",
|
|
3528
3532
|
"aria-current": e.active ? "location" : void 0,
|
|
3529
|
-
"aria-label":
|
|
3533
|
+
"aria-label": Ya(n, e),
|
|
3530
3534
|
title: e.text,
|
|
3531
3535
|
onClick: () => o(e),
|
|
3532
3536
|
children: e.text
|
|
@@ -3537,7 +3541,7 @@ function Ya({ editor: e, state: t, messages: n, editable: r, placement: i }) {
|
|
|
3537
3541
|
}
|
|
3538
3542
|
//#endregion
|
|
3539
3543
|
//#region src/MarkweaveEditor.tsx
|
|
3540
|
-
var
|
|
3544
|
+
var Za = {
|
|
3541
3545
|
active: !1,
|
|
3542
3546
|
mode: "outside",
|
|
3543
3547
|
activeCellPos: null,
|
|
@@ -3545,21 +3549,21 @@ var Xa = {
|
|
|
3545
3549
|
selectedCellCount: 0,
|
|
3546
3550
|
selectionFrom: 0,
|
|
3547
3551
|
selectionTo: 0
|
|
3548
|
-
},
|
|
3552
|
+
}, Qa = {
|
|
3549
3553
|
active: !1,
|
|
3550
3554
|
language: Vt.defaultLanguage,
|
|
3551
3555
|
mermaidPreviewMode: "code",
|
|
3552
3556
|
pos: null,
|
|
3553
3557
|
text: ""
|
|
3554
|
-
},
|
|
3558
|
+
}, $a = Yt({
|
|
3555
3559
|
active: !1,
|
|
3556
3560
|
mode: "code",
|
|
3557
3561
|
source: ""
|
|
3558
3562
|
});
|
|
3559
|
-
function
|
|
3563
|
+
function eo(e) {
|
|
3560
3564
|
return En.getState(e.state) ?? Tn;
|
|
3561
3565
|
}
|
|
3562
|
-
function
|
|
3566
|
+
function to(e) {
|
|
3563
3567
|
if (!e || typeof window > "u") return null;
|
|
3564
3568
|
let t = e.parentElement;
|
|
3565
3569
|
for (; t;) {
|
|
@@ -3569,18 +3573,18 @@ function eo(e) {
|
|
|
3569
3573
|
}
|
|
3570
3574
|
return null;
|
|
3571
3575
|
}
|
|
3572
|
-
function
|
|
3576
|
+
function no(e) {
|
|
3573
3577
|
return typeof window > "u" || typeof window.requestAnimationFrame != "function" ? globalThis.setTimeout(() => e(0), 0) : window.requestAnimationFrame(e);
|
|
3574
3578
|
}
|
|
3575
|
-
function
|
|
3579
|
+
function ro(e) {
|
|
3576
3580
|
if (typeof window < "u" && typeof window.cancelAnimationFrame == "function") {
|
|
3577
3581
|
window.cancelAnimationFrame(e);
|
|
3578
3582
|
return;
|
|
3579
3583
|
}
|
|
3580
3584
|
globalThis.clearTimeout(e);
|
|
3581
3585
|
}
|
|
3582
|
-
function
|
|
3583
|
-
let j = rt(g), M =
|
|
3586
|
+
function io({ askAi: e, ariaLabel: i, autoFocusFirstTableBodyCell: a = !1, autofocus: o = !1, content: c, contentFormat: l, defaultContent: u = "", defaultContentFormat: d, editable: f = !0, innerToc: p = !0, innerTocPlacement: m, lang: h, mode: g = "live", theme: _, canvasColor: v, onEditWithAi: y, onExtractToNote: b, onRewriteSelection: x, onAiEditControllerChange: S, onRuntimeStateChange: C, onSearchControllerChange: w, onSlashCommandUpload: T, onTableCommandResult: E, onTableCopyPayload: D, onTocChange: ee, onUpdate: O, linkCardResolver: k, resolveMediaSource: A } = {}) {
|
|
3587
|
+
let j = rt(g), M = wi(_), te = Ci(v), N = bi(m), P = j === "live" && f !== !1, ne = Ct(c === void 0 ? d : l), re = c ?? u, F = typeof re == "string" && re.length >= 2e5, I = c === void 0 && ne === "markdown" && F && typeof re == "string", ie = J(I ? re : null), [ae, L] = Y(I), R = J({
|
|
3584
3588
|
editorMode: j,
|
|
3585
3589
|
effectiveEditable: P
|
|
3586
3590
|
});
|
|
@@ -3598,7 +3602,7 @@ function ro({ askAi: e, ariaLabel: i, autoFocusFirstTableBodyCell: a = !1, autof
|
|
|
3598
3602
|
le.current = S;
|
|
3599
3603
|
let ue = J(k);
|
|
3600
3604
|
ue.current = k;
|
|
3601
|
-
let H = q(() =>
|
|
3605
|
+
let H = q(() => Xi({
|
|
3602
3606
|
lang: B,
|
|
3603
3607
|
onImageUpload: (e) => {
|
|
3604
3608
|
if (se.current) return se.current(e);
|
|
@@ -3658,7 +3662,7 @@ function ro({ askAi: e, ariaLabel: i, autoFocusFirstTableBodyCell: a = !1, autof
|
|
|
3658
3662
|
let r = zt(e);
|
|
3659
3663
|
r.active && r.language === "mermaid" && ve(r.mermaidPreviewMode);
|
|
3660
3664
|
}, []), ze = G((e) => {
|
|
3661
|
-
Se(
|
|
3665
|
+
Se(eo(e));
|
|
3662
3666
|
}, []), X = s({
|
|
3663
3667
|
shouldRerenderOnTransaction: !1,
|
|
3664
3668
|
extensions: H,
|
|
@@ -3721,7 +3725,7 @@ function ro({ askAi: e, ariaLabel: i, autoFocusFirstTableBodyCell: a = !1, autof
|
|
|
3721
3725
|
De.current = !0;
|
|
3722
3726
|
try {
|
|
3723
3727
|
let n = !0;
|
|
3724
|
-
for (let r of
|
|
3728
|
+
for (let r of Ti(e)) {
|
|
3725
3729
|
if (await new Promise((e) => window.setTimeout(e, 0)), t) return;
|
|
3726
3730
|
let e = X.markdown?.parse(r);
|
|
3727
3731
|
if (!e) throw Error("Markdown parser is unavailable.");
|
|
@@ -3747,11 +3751,11 @@ function ro({ askAi: e, ariaLabel: i, autoFocusFirstTableBodyCell: a = !1, autof
|
|
|
3747
3751
|
Re,
|
|
3748
3752
|
ze
|
|
3749
3753
|
]), K(() => {
|
|
3750
|
-
if (X) return ce.current?.(
|
|
3754
|
+
if (X) return ce.current?.(Ei(X)), () => {
|
|
3751
3755
|
ce.current?.(null);
|
|
3752
3756
|
};
|
|
3753
3757
|
}, [X]), K(() => {
|
|
3754
|
-
if (X) return le.current?.(
|
|
3758
|
+
if (X) return le.current?.(Di(X)), () => {
|
|
3755
3759
|
le.current?.(null);
|
|
3756
3760
|
};
|
|
3757
3761
|
}, [X]), K(() => {
|
|
@@ -3813,11 +3817,11 @@ function ro({ askAi: e, ariaLabel: i, autoFocusFirstTableBodyCell: a = !1, autof
|
|
|
3813
3817
|
Ve,
|
|
3814
3818
|
Ie
|
|
3815
3819
|
]);
|
|
3816
|
-
let He = q(() => X ? zt(X) :
|
|
3820
|
+
let He = q(() => X ? zt(X) : Qa, [
|
|
3817
3821
|
X,
|
|
3818
3822
|
Te,
|
|
3819
3823
|
U
|
|
3820
|
-
]), Ue = q(() => X ? Cn(X.state) :
|
|
3824
|
+
]), Ue = q(() => X ? Cn(X.state) : Za, [
|
|
3821
3825
|
X,
|
|
3822
3826
|
Te,
|
|
3823
3827
|
U,
|
|
@@ -3826,7 +3830,7 @@ function ro({ askAi: e, ariaLabel: i, autoFocusFirstTableBodyCell: a = !1, autof
|
|
|
3826
3830
|
active: Ge,
|
|
3827
3831
|
mode: _e,
|
|
3828
3832
|
source: He.text
|
|
3829
|
-
}) :
|
|
3833
|
+
}) : $a, [
|
|
3830
3834
|
He.text,
|
|
3831
3835
|
X,
|
|
3832
3836
|
Ge,
|
|
@@ -3835,28 +3839,28 @@ function ro({ askAi: e, ariaLabel: i, autoFocusFirstTableBodyCell: a = !1, autof
|
|
|
3835
3839
|
X,
|
|
3836
3840
|
C,
|
|
3837
3841
|
Te
|
|
3838
|
-
]), Je = q(() => X ?
|
|
3842
|
+
]), Je = q(() => X ? vi(X.state) : gi.items, [X, Te]), Ye = q(() => yi(Je, Ce), [Ce, Je]), Xe = q(() => hi(Je, Ye), [Ye, Je]), Ze = G(() => {
|
|
3839
3843
|
if (!X || !Je.length) {
|
|
3840
3844
|
we(null);
|
|
3841
3845
|
return;
|
|
3842
3846
|
}
|
|
3843
|
-
let e =
|
|
3847
|
+
let e = _i(X, Je);
|
|
3844
3848
|
we((t) => t === e ? t : e);
|
|
3845
3849
|
}, [X, Je]);
|
|
3846
3850
|
K(() => {
|
|
3847
3851
|
we((e) => {
|
|
3848
|
-
let t =
|
|
3852
|
+
let t = yi(Je, e);
|
|
3849
3853
|
return e === t ? e : t;
|
|
3850
3854
|
});
|
|
3851
3855
|
}, [Je]), K(() => {
|
|
3852
3856
|
if (!X || !Je.length || typeof window > "u") return;
|
|
3853
3857
|
let e = null, t = () => {
|
|
3854
|
-
e !== null &&
|
|
3858
|
+
e !== null && ro(e), e = no(() => {
|
|
3855
3859
|
e = null, Ze();
|
|
3856
3860
|
});
|
|
3857
|
-
}, n =
|
|
3861
|
+
}, n = to(X.view.dom);
|
|
3858
3862
|
return window.addEventListener("scroll", t, { passive: !0 }), window.addEventListener("resize", t), n?.addEventListener("scroll", t, { passive: !0 }), t(), () => {
|
|
3859
|
-
window.removeEventListener("scroll", t), window.removeEventListener("resize", t), n?.removeEventListener("scroll", t), e !== null &&
|
|
3863
|
+
window.removeEventListener("scroll", t), window.removeEventListener("resize", t), n?.removeEventListener("scroll", t), e !== null && ro(e);
|
|
3860
3864
|
};
|
|
3861
3865
|
}, [
|
|
3862
3866
|
X,
|
|
@@ -4072,24 +4076,24 @@ function ro({ askAi: e, ariaLabel: i, autoFocusFirstTableBodyCell: a = !1, autof
|
|
|
4072
4076
|
actions: nt
|
|
4073
4077
|
};
|
|
4074
4078
|
}
|
|
4075
|
-
function
|
|
4076
|
-
let n =
|
|
4079
|
+
function ao({ className: e, ...t }) {
|
|
4080
|
+
let n = io(t);
|
|
4077
4081
|
if (!n.editor) return null;
|
|
4078
4082
|
let r = [n.frameProps.className, e].filter(Boolean).join(" ");
|
|
4079
4083
|
return /* @__PURE__ */ Q("section", {
|
|
4080
4084
|
...n.frameProps,
|
|
4081
4085
|
className: r,
|
|
4082
4086
|
children: [
|
|
4083
|
-
n.overlayProps.floatingToolbar ? /* @__PURE__ */ Z(
|
|
4084
|
-
n.overlayProps.slashCommandMenu ? /* @__PURE__ */ Z(
|
|
4085
|
-
n.overlayProps.tableControls ? /* @__PURE__ */ Z(
|
|
4086
|
-
n.overlayProps.tableSelectionOverlay ? /* @__PURE__ */ Z(
|
|
4087
|
-
n.overlayProps.codeBlockControls ? /* @__PURE__ */ Z(
|
|
4088
|
-
n.overlayProps.innerToc ? /* @__PURE__ */ Z(
|
|
4089
|
-
n.overlayProps.mathEditorPopover ? /* @__PURE__ */ Z(
|
|
4087
|
+
n.overlayProps.floatingToolbar ? /* @__PURE__ */ Z(xa, { ...n.overlayProps.floatingToolbar }) : null,
|
|
4088
|
+
n.overlayProps.slashCommandMenu ? /* @__PURE__ */ Z(Ua, { ...n.overlayProps.slashCommandMenu }) : null,
|
|
4089
|
+
n.overlayProps.tableControls ? /* @__PURE__ */ Z(qa, { ...n.overlayProps.tableControls }) : null,
|
|
4090
|
+
n.overlayProps.tableSelectionOverlay ? /* @__PURE__ */ Z(Ja, { ...n.overlayProps.tableSelectionOverlay }) : null,
|
|
4091
|
+
n.overlayProps.codeBlockControls ? /* @__PURE__ */ Z($i, { ...n.overlayProps.codeBlockControls }) : null,
|
|
4092
|
+
n.overlayProps.innerToc ? /* @__PURE__ */ Z(Xa, { ...n.overlayProps.innerToc }) : null,
|
|
4093
|
+
n.overlayProps.mathEditorPopover ? /* @__PURE__ */ Z(Pa, { ...n.overlayProps.mathEditorPopover }) : null,
|
|
4090
4094
|
/* @__PURE__ */ Z(i, { editor: n.editor })
|
|
4091
4095
|
]
|
|
4092
4096
|
});
|
|
4093
4097
|
}
|
|
4094
4098
|
//#endregion
|
|
4095
|
-
export {
|
|
4099
|
+
export { ao as MarkweaveEditor, gt as createMarkweaveAiEditController, Xi as createMarkweaveEditorExtensions, Xi as createMarkweaveReactEditorExtensions, io as useMarkweaveEditorController };
|