@markweave/react 0.1.7 → 0.1.8
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 +1086 -879
- package/dist/types/MarkweaveEditor.d.ts +3 -1
- package/dist/types/MarkweaveEditor.d.ts.map +1 -1
- package/dist/types/create-editor-extensions.d.ts +4 -2
- package/dist/types/create-editor-extensions.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/link-card-node.d.ts +9 -0
- package/dist/types/link-card-node.d.ts.map +1 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,238 +1,241 @@
|
|
|
1
1
|
import { createMarkweaveEditorExtensions as e } from "markweave/internal/editor-core/create-editor-extensions";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { getMarkweaveEditorModeState as Y, isMarkweaveEditorLiveEditable as
|
|
9
|
-
import { openMarkweaveImagePreview as
|
|
2
|
+
import { getLocalizedSlashCommandSpecs as t, getMarkweaveMessages as n, normalizeMarkweaveLang as r } from "markweave/internal/i18n";
|
|
3
|
+
import { EditorContent as i, NodeViewWrapper as a, ReactNodeViewRenderer as o, useEditor as s } from "@tiptap/react";
|
|
4
|
+
import { AlertTriangle as c, AlignCenter as l, AlignJustify as u, AlignLeft as d, AlignRight as f, Bold as p, Braces as m, Captions as h, Check as g, CheckCircle2 as _, ChevronDown as v, ChevronUp as y, CircleX as b, Code2 as x, Copy as S, CornerDownLeft as C, Download as w, ExternalLink as T, Eye as E, Heading1 as D, Heading2 as O, Heading3 as k, Image as A, ImageUp as j, IndentDecrease as M, IndentIncrease as ee, Info as N, Italic as P, Lightbulb as te, Link2 as F, List as I, ListChecks as ne, ListOrdered as L, Minus as re, MoreVertical as R, Paperclip as z, Pencil as ie, Quote as ae, Replace as oe, Sigma as se, SmilePlus as ce, Sparkles as le, Strikethrough as ue, Subscript as de, Superscript as fe, Table2 as pe, Text as me, Trash2 as he, Type as ge, Underline as _e, Upload as ve, Video as ye } from "lucide-react";
|
|
5
|
+
import { useCallback as B, useEffect as V, useLayoutEffect as be, useMemo as H, useRef as U, useState as W, useSyncExternalStore as G } from "react";
|
|
6
|
+
import { detectUploadSource as xe, getDirectUploadResult as Se, resolveMarkweaveUploadResult as Ce } from "markweave/internal/plugins/slash-command/upload";
|
|
7
|
+
import { MarkweaveCoreImage as we, MarkweaveCoreVideo as Te, attrsFromMarkweaveImageUploadResult as K, attrsFromMarkweaveVideoUploadResult as Ee, attrsFromMarkweaveVideoUrl as De, clampMarkweaveImageWidth as Oe, createMarkweaveImageUploadRequest as ke, createMarkweaveVideoUploadRequest as q, downloadMarkweaveImage as Ae, markweaveVideoIframeAllow as je, normalizeMarkweaveCoreImageAlign as Me, normalizeMarkweaveVideoEmbedUrl as Ne, numberAttribute as Pe, stringAttribute as J } from "markweave/internal/plugins/media/core-media-nodes";
|
|
8
|
+
import { getMarkweaveEditorModeState as Y, isMarkweaveEditorLiveEditable as Fe, normalizeMarkweaveEditorMode as Ie, setMarkweaveEditorModeState as Le, subscribeToMarkweaveEditorMode as Re } from "markweave/internal/core/editor-mode-state";
|
|
9
|
+
import { openMarkweaveImagePreview as ze } from "markweave/internal/plugins/media/image-preview";
|
|
10
10
|
import { Fragment as X, jsx as Z, jsxs as Q } from "react/jsx-runtime";
|
|
11
|
-
import { createMarkweaveAdapterMediaExtensions as
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
11
|
+
import { createMarkweaveAdapterMediaExtensions as Be } from "markweave/internal/plugins/media/media-extension-factory";
|
|
12
|
+
import { normalizeMarkweaveLinkCardAttrs as Ve, normalizeMarkweaveLinkCardHref as He, replaceMarkweaveLinkCardWithLink as Ue } from "markweave/internal/plugins/link-card/link-card";
|
|
13
|
+
import { openMarkweaveLinkCardComposer as We } from "markweave/internal/plugins/link-card/link-card-composer";
|
|
14
|
+
import { MarkweaveLinkCard as Ge } from "markweave/internal/plugins/link-card/link-card-node";
|
|
15
|
+
import { isEditorComposing as Ke } from "markweave/internal/editor-core/composition-guard";
|
|
16
|
+
import { createMarkweaveEditorUpdatePayload as qe, getMarkweaveContentType as Je, isEditorContentCurrent as Ye, isMarkweaveControlledContentEchoCurrent as Xe, normalizeMarkweaveContentFormat as Ze } from "markweave/internal/editor-core/editor-content";
|
|
17
|
+
import { openMarkweaveReadonlyLinkFromEvent as Qe } from "markweave/internal/editor-core/readonly-link";
|
|
18
|
+
import { createMarkweaveEditorRuntimeSnapshot as $e } from "markweave/internal/editor-core/runtime-snapshot";
|
|
19
|
+
import { advanceFloatingToolbarMotionState as et, areEditorSelectionSnapshotsEquivalent as tt, calculateFloatingToolbarFrameShift as nt, calculateFloatingToolbarPopoverPlacement as rt, calculateFloatingToolbarTopBoundary as it, createSelectionSnapshot as at, getFloatingToolbarFloatingOptions as ot, getFloatingToolbarState as st, markweaveRuntimeProjectionDelayMs as ct, shouldShowFloatingToolbar as lt, transitionFloatingToolbarState as ut } from "markweave/internal/editor-core/selection-state";
|
|
20
|
+
import { codeBlockCollapsePluginKey as dt, copyActiveCodeBlock as ft, getActiveCodeBlockState as pt, getCodeBlockCopyFeedbackSnapshot as mt, markweaveCodeBlockBehavior as ht, setCodeBlockCollapsedAtPosition as gt, setCodeBlockLanguageAtPosition as _t, setCodeBlockMermaidPreviewModeAtPosition as vt } from "markweave/internal/plugins/codeblock/codeblock-behavior";
|
|
21
|
+
import { isMermaidInlinePreviewTransaction as yt, setMarkweaveMermaidTheme as bt, setMermaidInlinePreviewEditorMode as xt, setReadonlyMermaidPreviewMode as St } from "markweave/internal/plugins/mermaid/mermaid-inline-preview";
|
|
22
|
+
import { getMermaidPreviewState as Ct } from "markweave/internal/plugins/mermaid/mermaid-renderer";
|
|
23
|
+
import { applyMarkweaveMathLatex as wt, calculateMarkweaveMathPopoverPosition as Tt, getMarkweaveMathAnchorRect as Et, getMarkweaveMathBlockIndex as Dt, getMarkweaveMathRenderedHtml as Ot, getMarkweaveMathTargetAtPos as kt, getMarkweaveMathTargetFromDomEvent as At, getMarkweaveMathTargetFromSelection as jt, renderMarkweaveMathPreview as Mt, setMarkweaveMathEditingDomState as Nt, setMarkweaveMathEditingDomStateInView as Pt, setMarkweaveMathSelectionInView as Ft } from "markweave/internal/plugins/math/math-ui-model";
|
|
24
|
+
import { filterSlashCommands as It, isExecutableSlashCommand as Lt } from "markweave/internal/plugins/slash-command/command-spec";
|
|
25
|
+
import { getSlashCommandKeyboardAction as Rt, isSlashCommandMenuState as zt } from "markweave/internal/plugins/slash-command/slash-keyboard";
|
|
26
|
+
import { executeSlashCommand as Bt, getNextSlashCommandState as Vt, getSlashCommandAnchoredMenuPosition as Ht, getSlashCommandContext as Ut } from "markweave/internal/plugins/slash-command/slash-runtime";
|
|
27
|
+
import { initialSlashCommandState as Wt, reduceSlashCommandState as Gt } from "markweave/internal/plugins/slash-command/slash-state";
|
|
28
|
+
import { getFirstTableDebugSnapshot as Kt } from "markweave/internal/plugins/table/table-debug-snapshot";
|
|
29
|
+
import { focusFirstTableBodyCell as qt } from "markweave/internal/plugins/table/table-focus-position";
|
|
30
|
+
import { getTableFocusState as Jt } from "markweave/internal/plugins/table/table-focus-state";
|
|
31
|
+
import { getTableSelectionOverlayState as Yt, initialTableInteractionState as Xt, tableInteractionPluginKey as Zt } from "markweave/internal/plugins/table/table-interaction-layer";
|
|
32
|
+
import { calculateCodeBlockLanguageMenuPosition as Qt, clampFullscreenScale as $t, codeBlockCopyFeedbackTimeoutMs as en, copyCodeBlockText as tn, createCodeBlockOverlayPosition as nn, createMermaidFullscreenViewerState as rn, createMermaidTabPosition as an, focusCodeBlockTarget as on, formatCodeBlockLanguageLabel as sn, formatFullscreenZoom as cn, getActiveCodeBlockElement as ln, getAnchoredRect as un, getCodeBlockLanguageItems as dn, getCodeBlockPositionFromEventTarget as fn, getCodeBlockStateAtPosition as pn, getFrameElement as mn, getMermaidCodeBlockTargets as hn, getMermaidSvgMarkup as gn, isCodeBlockTargetCollapsed as _n, mergeStableMermaidTabPositions as vn, mermaidFullscreenZoomStep as yn, moveMermaidFullscreenViewer as bn } from "markweave/internal/plugins/codeblock/codeblock-ui-model";
|
|
33
|
+
import { BubbleMenu as xn } from "@tiptap/react/menus";
|
|
34
|
+
import { createMarkweaveFrameScheduler as Sn } from "markweave/internal/editor-core/frame-scheduler";
|
|
35
|
+
import { applyFloatingToolbarLink as Cn, createFloatingToolbarAssistantRequest as wn, getFloatingToolbarButtonModels as Tn, getFloatingToolbarHighlightColorOptions as En, getFloatingToolbarLinkHref as Dn, getFloatingToolbarMessageSet as On, getFloatingToolbarMoreActions as kn, getFloatingToolbarTextColorOptions as An, getFloatingToolbarTooltipModel as jn, getFloatingToolbarTurnIntoOptions as Mn, isFloatingToolbarMoreActionActive as Nn, isFloatingToolbarTurnIntoActive as Pn, openFloatingToolbarLinkHref as Fn, preventFloatingToolbarPointerFocusLoss as In, removeFloatingToolbarLink as Ln, runFloatingToolbarMoreAction as Rn, setFloatingToolbarHighlightColor as zn, setFloatingToolbarTextColor as Bn, setFloatingToolbarTurnInto as Vn } from "markweave/internal/editor-core/floating-toolbar-model";
|
|
36
|
+
import { normalizeMarkdownLinkHref as Hn } from "markweave/internal/plugins/markdown/markdown-input";
|
|
37
|
+
import { setMarkweaveTableMenuAxisTarget as Un } from "markweave/internal/plugins/table/table-clipboard";
|
|
38
|
+
import { calculateAnchoredTableMenuPosition as Wn, calculateTableEdgeHandlePosition as Gn, canRunTableCommand as Kn, executeTableMenuCommand as qn, formatTableCopyFeedback as Jn, getActiveTableElement as Yn, getAvailableCellMenuCommandSpecs as Xn, getTableAxisTargetRect as Zn, getTableControlAxisSelectionModel as Qn, getTableEditWithAiRequest as $n, getTableMenuItemGroup as er, getTableMenuItemLabel as tr, getTableMenuItems as nr, getTableSelectionTargetRect as rr, measureTableSelectionOverlay as ir, selectTableAxisFromCell as ar, tableCopyFeedbackTimeoutMs as or, tableMenuLabel as sr } from "markweave/internal/plugins/table/table-ui-model";
|
|
39
|
+
import { createMarkweaveTocState as cr, emptyMarkweaveTocState as lr, getActiveMarkweaveTocId as ur, getMarkweaveTocItems as dr, getValidMarkweaveTocActiveId as fr, normalizeMarkweaveInnerTocPlacement as pr, observeMarkweaveInnerTocContainerPosition as mr, scrollToMarkweaveTocItem as hr } from "markweave/internal/core/toc-state";
|
|
40
|
+
import { normalizeMarkweaveTheme as gr } from "markweave/internal/core/theme";
|
|
38
41
|
//#region src/editor-mode-state.ts
|
|
39
|
-
var
|
|
42
|
+
var _r = {
|
|
40
43
|
mode: "live",
|
|
41
44
|
editable: !0
|
|
42
45
|
};
|
|
43
|
-
function
|
|
44
|
-
return
|
|
46
|
+
function vr(e) {
|
|
47
|
+
return G((t) => Re(e, t), () => Y(e), () => _r);
|
|
45
48
|
}
|
|
46
49
|
//#endregion
|
|
47
50
|
//#region src/media/image-node.tsx
|
|
48
|
-
var
|
|
49
|
-
function
|
|
51
|
+
var yr = Me;
|
|
52
|
+
function br(e) {
|
|
50
53
|
return e instanceof Element && !!e.closest("[data-markweave-image-ui=\"true\"]");
|
|
51
54
|
}
|
|
52
|
-
function
|
|
53
|
-
let { deleteNode: t, editor: r, getPos: i, node:
|
|
54
|
-
|
|
55
|
-
src:
|
|
56
|
-
alt: J(
|
|
55
|
+
function xr(e) {
|
|
56
|
+
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 = Fe(vr(r)), p = J(o.attrs.src), m = yr(o.attrs.align), h = Pe(o.attrs.width), g = J(o.attrs.caption), _ = U(null), v = U(null), [y, b] = W(!1), [x, S] = W(!1), [C, w] = W(!1), [T, D] = W(""), [O, k] = W(null), [A, j] = W(!1), [M, ee] = W(!!g), [N, P] = W(g ?? ""), te = f && (!p || x), F = () => {
|
|
57
|
+
p && ze({
|
|
58
|
+
src: p,
|
|
59
|
+
alt: J(o.attrs.alt) ?? "",
|
|
57
60
|
messages: {
|
|
58
|
-
dialogAriaLabel:
|
|
59
|
-
zoomOut:
|
|
60
|
-
zoomIn:
|
|
61
|
-
reset:
|
|
62
|
-
close:
|
|
61
|
+
dialogAriaLabel: d.previewDialogAriaLabel,
|
|
62
|
+
zoomOut: d.previewZoomOut,
|
|
63
|
+
zoomIn: d.previewZoomIn,
|
|
64
|
+
reset: d.previewReset,
|
|
65
|
+
close: d.previewClose
|
|
63
66
|
}
|
|
64
67
|
});
|
|
65
68
|
};
|
|
66
69
|
V(() => {
|
|
67
|
-
|
|
68
|
-
}, [
|
|
69
|
-
let
|
|
70
|
-
if (!
|
|
70
|
+
M || P(g ?? "");
|
|
71
|
+
}, [g, M]);
|
|
72
|
+
let I = () => {
|
|
73
|
+
if (!f) return;
|
|
71
74
|
let e = i();
|
|
72
75
|
typeof e == "number" && r.chain().focus().setNodeSelection(e).run();
|
|
73
|
-
},
|
|
74
|
-
if (
|
|
75
|
-
if (
|
|
76
|
-
|
|
76
|
+
}, ne = () => {
|
|
77
|
+
if (f) {
|
|
78
|
+
if (D(""), k(null), w(!1), p) {
|
|
79
|
+
S(!1);
|
|
77
80
|
return;
|
|
78
81
|
}
|
|
79
82
|
t();
|
|
80
83
|
}
|
|
81
|
-
},
|
|
82
|
-
if (
|
|
83
|
-
|
|
84
|
+
}, L = async (e) => {
|
|
85
|
+
if (f) {
|
|
86
|
+
k(null), j(!0);
|
|
84
87
|
try {
|
|
85
|
-
let t = await
|
|
86
|
-
|
|
88
|
+
let t = await Ce(ke(e, p && x ? "image-replace" : "image-insert"), l.onUpload);
|
|
89
|
+
c(K(o.attrs, t)), S(!1), D("");
|
|
87
90
|
} catch (e) {
|
|
88
|
-
|
|
91
|
+
k(e instanceof Error ? e.message : d.uploadFailedError);
|
|
89
92
|
} finally {
|
|
90
|
-
|
|
93
|
+
j(!1), w(!1);
|
|
91
94
|
}
|
|
92
95
|
}
|
|
93
96
|
}, re = () => {
|
|
94
|
-
if (
|
|
97
|
+
if (f) {
|
|
95
98
|
if (!T.trim()) {
|
|
96
|
-
|
|
99
|
+
k(d.uploadRequiredError);
|
|
97
100
|
return;
|
|
98
101
|
}
|
|
99
|
-
|
|
102
|
+
L(xe(T));
|
|
100
103
|
}
|
|
101
|
-
},
|
|
102
|
-
!
|
|
104
|
+
}, R = (e) => {
|
|
105
|
+
!f || !e || L({
|
|
103
106
|
type: "file",
|
|
104
107
|
file: e,
|
|
105
108
|
mimeType: e.type
|
|
106
109
|
});
|
|
107
|
-
},
|
|
108
|
-
|
|
110
|
+
}, z = (e) => {
|
|
111
|
+
R(e.currentTarget.files?.[0] ?? null), e.currentTarget.value = "";
|
|
109
112
|
}, ie = (e) => {
|
|
110
|
-
e.preventDefault(), e.stopPropagation(),
|
|
113
|
+
e.preventDefault(), e.stopPropagation(), f && R(e.dataTransfer.files?.[0] ?? null);
|
|
111
114
|
}, ae = () => {
|
|
112
|
-
|
|
115
|
+
f && (ee((e) => !e), M || P(g ?? ""));
|
|
113
116
|
}, oe = (e) => {
|
|
114
|
-
|
|
115
|
-
},
|
|
116
|
-
if (t.preventDefault(), t.stopPropagation(), !
|
|
117
|
-
|
|
118
|
-
let n =
|
|
117
|
+
f && (P(e), c({ caption: e.trim() ? e : null }));
|
|
118
|
+
}, se = (e, t) => {
|
|
119
|
+
if (t.preventDefault(), t.stopPropagation(), !f) return;
|
|
120
|
+
I();
|
|
121
|
+
let n = _.current;
|
|
119
122
|
if (!n) return;
|
|
120
|
-
let r = t.clientX, i = n.getBoundingClientRect().width ||
|
|
123
|
+
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) => {
|
|
121
124
|
let n = e === "right" ? t.clientX - r : r - t.clientX;
|
|
122
|
-
|
|
123
|
-
},
|
|
124
|
-
window.removeEventListener("pointermove", o), window.removeEventListener("pointerup",
|
|
125
|
+
c({ width: Oe(i + n, a) });
|
|
126
|
+
}, s = () => {
|
|
127
|
+
window.removeEventListener("pointermove", o), window.removeEventListener("pointerup", s);
|
|
125
128
|
};
|
|
126
|
-
window.addEventListener("pointermove", o), window.addEventListener("pointerup",
|
|
129
|
+
window.addEventListener("pointermove", o), window.addEventListener("pointerup", s, { once: !0 });
|
|
127
130
|
};
|
|
128
|
-
return /* @__PURE__ */ Z(
|
|
131
|
+
return /* @__PURE__ */ Z(a, {
|
|
129
132
|
as: "figure",
|
|
130
133
|
className: "markweave-image-node",
|
|
131
134
|
"data-testid": "markweave-image-node",
|
|
132
|
-
"data-align":
|
|
133
|
-
"data-selected":
|
|
134
|
-
"data-hovered":
|
|
135
|
-
"data-empty":
|
|
136
|
-
onPointerEnter: () =>
|
|
137
|
-
onPointerLeave: () =>
|
|
135
|
+
"data-align": m,
|
|
136
|
+
"data-selected": f && s ? "true" : "false",
|
|
137
|
+
"data-hovered": y ? "true" : "false",
|
|
138
|
+
"data-empty": te ? "true" : "false",
|
|
139
|
+
onPointerEnter: () => b(!0),
|
|
140
|
+
onPointerLeave: () => b(!1),
|
|
138
141
|
onMouseDown: (e) => {
|
|
139
|
-
|
|
142
|
+
f && !br(e.target) && I();
|
|
140
143
|
},
|
|
141
|
-
children:
|
|
144
|
+
children: te ? /* @__PURE__ */ Z(Sr, {
|
|
142
145
|
dragActive: C,
|
|
143
|
-
error:
|
|
146
|
+
error: O,
|
|
144
147
|
inputValue: T,
|
|
145
|
-
isSubmitting:
|
|
146
|
-
fileInputRef:
|
|
147
|
-
messages:
|
|
148
|
-
onCancel:
|
|
148
|
+
isSubmitting: A,
|
|
149
|
+
fileInputRef: v,
|
|
150
|
+
messages: u,
|
|
151
|
+
onCancel: ne,
|
|
149
152
|
onDrop: ie,
|
|
150
153
|
onDragActiveChange: w,
|
|
151
|
-
onFileChange:
|
|
152
|
-
onInputChange:
|
|
154
|
+
onFileChange: z,
|
|
155
|
+
onInputChange: D,
|
|
153
156
|
onSubmit: re
|
|
154
157
|
}) : /* @__PURE__ */ Q(X, { children: [
|
|
155
|
-
|
|
156
|
-
align:
|
|
157
|
-
captionActive:
|
|
158
|
-
messages:
|
|
159
|
-
onAlign: (e) =>
|
|
158
|
+
f ? /* @__PURE__ */ Z(Cr, {
|
|
159
|
+
align: m,
|
|
160
|
+
captionActive: M || !!g,
|
|
161
|
+
messages: u,
|
|
162
|
+
onAlign: (e) => c({ align: e }),
|
|
160
163
|
onCaption: ae,
|
|
161
164
|
onDelete: t,
|
|
162
165
|
onDownload: () => {
|
|
163
|
-
|
|
166
|
+
p && Ae(p);
|
|
164
167
|
},
|
|
165
|
-
onPreview:
|
|
168
|
+
onPreview: F,
|
|
166
169
|
onReplace: () => {
|
|
167
|
-
|
|
170
|
+
D(""), k(null), S(!0);
|
|
168
171
|
}
|
|
169
172
|
}) : null,
|
|
170
173
|
/* @__PURE__ */ Q("div", {
|
|
171
174
|
className: "markweave-image-box",
|
|
172
|
-
ref:
|
|
173
|
-
style:
|
|
175
|
+
ref: _,
|
|
176
|
+
style: h ? { width: `${h}px` } : void 0,
|
|
174
177
|
children: [
|
|
175
|
-
|
|
178
|
+
p ? /* @__PURE__ */ Z("img", {
|
|
176
179
|
className: "markweave-image",
|
|
177
|
-
src:
|
|
178
|
-
alt: J(
|
|
179
|
-
title: J(
|
|
180
|
+
src: p,
|
|
181
|
+
alt: J(o.attrs.alt) ?? "",
|
|
182
|
+
title: J(o.attrs.title) ?? void 0,
|
|
180
183
|
draggable: !1
|
|
181
184
|
}) : /* @__PURE__ */ Z("div", {
|
|
182
185
|
className: "markweave-image-readonly-empty",
|
|
183
186
|
"data-testid": "markweave-image-readonly-empty",
|
|
184
187
|
"aria-hidden": "true"
|
|
185
188
|
}),
|
|
186
|
-
!
|
|
189
|
+
!f && p ? /* @__PURE__ */ Q("button", {
|
|
187
190
|
type: "button",
|
|
188
191
|
className: "markweave-image-preview-trigger",
|
|
189
192
|
"data-testid": "markweave-image-preview",
|
|
190
193
|
"data-markweave-image-ui": "true",
|
|
191
|
-
"aria-label":
|
|
192
|
-
title:
|
|
194
|
+
"aria-label": d.preview,
|
|
195
|
+
title: d.preview,
|
|
193
196
|
onMouseDown: (e) => e.preventDefault(),
|
|
194
|
-
onClick:
|
|
195
|
-
children: [/* @__PURE__ */ Z(
|
|
197
|
+
onClick: F,
|
|
198
|
+
children: [/* @__PURE__ */ Z(E, {
|
|
196
199
|
size: 16,
|
|
197
200
|
strokeWidth: 1.8
|
|
198
201
|
}), /* @__PURE__ */ Z("span", {
|
|
199
202
|
className: "markweave-image-tooltip",
|
|
200
203
|
role: "tooltip",
|
|
201
|
-
children:
|
|
204
|
+
children: d.preview
|
|
202
205
|
})]
|
|
203
206
|
}) : null,
|
|
204
|
-
|
|
207
|
+
f ? /* @__PURE__ */ Z(Tr, {
|
|
205
208
|
side: "left",
|
|
206
|
-
messages:
|
|
207
|
-
onPointerDown:
|
|
209
|
+
messages: u,
|
|
210
|
+
onPointerDown: se
|
|
208
211
|
}) : null,
|
|
209
|
-
|
|
212
|
+
f ? /* @__PURE__ */ Z(Tr, {
|
|
210
213
|
side: "right",
|
|
211
|
-
messages:
|
|
212
|
-
onPointerDown:
|
|
214
|
+
messages: u,
|
|
215
|
+
onPointerDown: se
|
|
213
216
|
}) : null
|
|
214
217
|
]
|
|
215
218
|
}),
|
|
216
|
-
|
|
219
|
+
f && (M || g) ? /* @__PURE__ */ Z("input", {
|
|
217
220
|
className: "markweave-image-caption-input",
|
|
218
221
|
"data-markweave-image-ui": "true",
|
|
219
222
|
"data-testid": "markweave-image-caption-input",
|
|
220
|
-
value:
|
|
221
|
-
placeholder:
|
|
222
|
-
"aria-label":
|
|
223
|
+
value: N,
|
|
224
|
+
placeholder: d.captionPlaceholder,
|
|
225
|
+
"aria-label": d.captionAriaLabel,
|
|
223
226
|
onChange: (e) => oe(e.currentTarget.value),
|
|
224
227
|
onKeyDown: (e) => {
|
|
225
|
-
e.key === "Escape" && (e.preventDefault(),
|
|
228
|
+
e.key === "Escape" && (e.preventDefault(), ee(!1));
|
|
226
229
|
}
|
|
227
|
-
}) :
|
|
230
|
+
}) : g ? /* @__PURE__ */ Z("figcaption", {
|
|
228
231
|
className: "markweave-image-caption",
|
|
229
232
|
"data-testid": "markweave-image-caption",
|
|
230
|
-
children:
|
|
233
|
+
children: g
|
|
231
234
|
}) : null
|
|
232
235
|
] })
|
|
233
236
|
});
|
|
234
237
|
}
|
|
235
|
-
function
|
|
238
|
+
function Sr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitting: i, messages: a, onCancel: o, onDragActiveChange: s, onDrop: c, onFileChange: l, onInputChange: u, onSubmit: d }) {
|
|
236
239
|
let f = a.image;
|
|
237
240
|
return /* @__PURE__ */ Q("section", {
|
|
238
241
|
className: "markweave-image-upload-placeholder",
|
|
@@ -259,7 +262,7 @@ function hr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
|
|
|
259
262
|
/* @__PURE__ */ Z("div", {
|
|
260
263
|
className: "markweave-image-upload-icon",
|
|
261
264
|
"aria-hidden": "true",
|
|
262
|
-
children: /* @__PURE__ */ Z(
|
|
265
|
+
children: /* @__PURE__ */ Z(j, {
|
|
263
266
|
size: 46,
|
|
264
267
|
strokeWidth: 1.6
|
|
265
268
|
})
|
|
@@ -294,7 +297,7 @@ function hr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
|
|
|
294
297
|
"data-testid": "markweave-image-upload-submit",
|
|
295
298
|
disabled: i || !r.trim(),
|
|
296
299
|
onClick: d,
|
|
297
|
-
children: [/* @__PURE__ */ Z(
|
|
300
|
+
children: [/* @__PURE__ */ Z(j, {
|
|
298
301
|
size: 16,
|
|
299
302
|
strokeWidth: 1.8
|
|
300
303
|
}), a.common.insert]
|
|
@@ -314,32 +317,32 @@ function hr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
|
|
|
314
317
|
]
|
|
315
318
|
});
|
|
316
319
|
}
|
|
317
|
-
function
|
|
318
|
-
let
|
|
320
|
+
function Cr({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i, onDelete: a, onDownload: o, onPreview: s, onReplace: c }) {
|
|
321
|
+
let u = n.image;
|
|
319
322
|
return /* @__PURE__ */ Q("div", {
|
|
320
323
|
className: "markweave-image-toolbar",
|
|
321
324
|
"data-testid": "markweave-image-toolbar",
|
|
322
325
|
"data-markweave-image-ui": "true",
|
|
323
|
-
"aria-label":
|
|
326
|
+
"aria-label": u.toolsAriaLabel,
|
|
324
327
|
children: [
|
|
325
|
-
/* @__PURE__ */ Z(
|
|
328
|
+
/* @__PURE__ */ Z(wr, {
|
|
326
329
|
testId: "markweave-image-align-left",
|
|
327
|
-
label:
|
|
328
|
-
icon:
|
|
330
|
+
label: u.alignLeft,
|
|
331
|
+
icon: d,
|
|
329
332
|
active: e === "left",
|
|
330
333
|
onClick: () => r("left")
|
|
331
334
|
}),
|
|
332
|
-
/* @__PURE__ */ Z(
|
|
335
|
+
/* @__PURE__ */ Z(wr, {
|
|
333
336
|
testId: "markweave-image-align-center",
|
|
334
|
-
label:
|
|
335
|
-
icon:
|
|
337
|
+
label: u.alignCenter,
|
|
338
|
+
icon: l,
|
|
336
339
|
active: e === "center",
|
|
337
340
|
onClick: () => r("center")
|
|
338
341
|
}),
|
|
339
|
-
/* @__PURE__ */ Z(
|
|
342
|
+
/* @__PURE__ */ Z(wr, {
|
|
340
343
|
testId: "markweave-image-align-right",
|
|
341
|
-
label:
|
|
342
|
-
icon:
|
|
344
|
+
label: u.alignRight,
|
|
345
|
+
icon: f,
|
|
343
346
|
active: e === "right",
|
|
344
347
|
onClick: () => r("right")
|
|
345
348
|
}),
|
|
@@ -347,45 +350,45 @@ function gr({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i,
|
|
|
347
350
|
className: "markweave-image-toolbar-divider",
|
|
348
351
|
"aria-hidden": "true"
|
|
349
352
|
}),
|
|
350
|
-
/* @__PURE__ */ Z(
|
|
353
|
+
/* @__PURE__ */ Z(wr, {
|
|
351
354
|
testId: "markweave-image-caption",
|
|
352
|
-
label:
|
|
353
|
-
icon:
|
|
355
|
+
label: u.caption,
|
|
356
|
+
icon: h,
|
|
354
357
|
active: t,
|
|
355
358
|
onClick: i
|
|
356
359
|
}),
|
|
357
|
-
/* @__PURE__ */ Z(
|
|
360
|
+
/* @__PURE__ */ Z(wr, {
|
|
358
361
|
testId: "markweave-image-preview",
|
|
359
|
-
label:
|
|
360
|
-
icon:
|
|
361
|
-
onClick:
|
|
362
|
+
label: u.preview,
|
|
363
|
+
icon: E,
|
|
364
|
+
onClick: s
|
|
362
365
|
}),
|
|
363
|
-
/* @__PURE__ */ Z(
|
|
366
|
+
/* @__PURE__ */ Z(wr, {
|
|
364
367
|
testId: "markweave-image-download",
|
|
365
|
-
label:
|
|
366
|
-
icon:
|
|
367
|
-
onClick:
|
|
368
|
+
label: u.download,
|
|
369
|
+
icon: w,
|
|
370
|
+
onClick: o
|
|
368
371
|
}),
|
|
369
|
-
/* @__PURE__ */ Z(
|
|
372
|
+
/* @__PURE__ */ Z(wr, {
|
|
370
373
|
testId: "markweave-image-replace",
|
|
371
|
-
label:
|
|
372
|
-
icon:
|
|
373
|
-
onClick:
|
|
374
|
+
label: u.replace,
|
|
375
|
+
icon: oe,
|
|
376
|
+
onClick: c
|
|
374
377
|
}),
|
|
375
378
|
/* @__PURE__ */ Z("span", {
|
|
376
379
|
className: "markweave-image-toolbar-divider",
|
|
377
380
|
"aria-hidden": "true"
|
|
378
381
|
}),
|
|
379
|
-
/* @__PURE__ */ Z(
|
|
382
|
+
/* @__PURE__ */ Z(wr, {
|
|
380
383
|
testId: "markweave-image-delete",
|
|
381
|
-
label:
|
|
382
|
-
icon:
|
|
384
|
+
label: u.delete,
|
|
385
|
+
icon: he,
|
|
383
386
|
onClick: a
|
|
384
387
|
})
|
|
385
388
|
]
|
|
386
389
|
});
|
|
387
390
|
}
|
|
388
|
-
function
|
|
391
|
+
function wr({ active: e = !1, icon: t, label: n, onClick: r, testId: i }) {
|
|
389
392
|
return /* @__PURE__ */ Q("button", {
|
|
390
393
|
type: "button",
|
|
391
394
|
"aria-label": n,
|
|
@@ -404,7 +407,7 @@ function _r({ active: e = !1, icon: t, label: n, onClick: r, testId: i }) {
|
|
|
404
407
|
})]
|
|
405
408
|
});
|
|
406
409
|
}
|
|
407
|
-
function
|
|
410
|
+
function Tr({ messages: e, onPointerDown: t, side: n }) {
|
|
408
411
|
return /* @__PURE__ */ Z("button", {
|
|
409
412
|
type: "button",
|
|
410
413
|
className: "markweave-image-resize-handle",
|
|
@@ -415,128 +418,128 @@ function vr({ messages: e, onPointerDown: t, side: n }) {
|
|
|
415
418
|
onPointerDown: (e) => t(n, e)
|
|
416
419
|
});
|
|
417
420
|
}
|
|
418
|
-
var
|
|
421
|
+
var Er = we.extend({
|
|
419
422
|
addOptions() {
|
|
420
423
|
return {
|
|
421
424
|
...this.parent?.(),
|
|
422
|
-
messages:
|
|
425
|
+
messages: n("zh"),
|
|
423
426
|
onUpload: void 0
|
|
424
427
|
};
|
|
425
428
|
},
|
|
426
429
|
addNodeView() {
|
|
427
|
-
return typeof document > "u" ? null :
|
|
430
|
+
return typeof document > "u" ? null : o(xr, { stopEvent: ({ event: e }) => br(e.target) });
|
|
428
431
|
}
|
|
429
432
|
});
|
|
430
433
|
//#endregion
|
|
431
434
|
//#region src/media/video-node.tsx
|
|
432
|
-
function
|
|
435
|
+
function Dr(e) {
|
|
433
436
|
return e instanceof Element && !!e.closest("[data-markweave-video-ui=\"true\"], iframe[data-markweave-video-embed], video[data-markweave-video]");
|
|
434
437
|
}
|
|
435
|
-
function
|
|
436
|
-
let { deleteNode: t, editor: r, getPos: i, node:
|
|
437
|
-
if (!
|
|
438
|
+
function Or(e) {
|
|
439
|
+
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 = Fe(vr(r)), p = J(o.attrs.src), m = J(o.attrs.embedUrl), h = J(o.attrs.provider), g = m ? Ne(m, h) : null, _ = J(o.attrs.mimeType), v = J(o.attrs.title), y = U(null), [b, x] = W(!1), [S, C] = W(""), [w, T] = W(null), [E, D] = W(!1), O = f && !p, k = () => {
|
|
440
|
+
if (!f) return;
|
|
438
441
|
let e = i();
|
|
439
442
|
typeof e == "number" && r.chain().focus().setNodeSelection(e).run();
|
|
440
|
-
},
|
|
441
|
-
|
|
442
|
-
},
|
|
443
|
-
|
|
444
|
-
},
|
|
445
|
-
if (!(!
|
|
446
|
-
|
|
443
|
+
}, A = (e) => {
|
|
444
|
+
f && (Dr(e.target) || (e.preventDefault(), k()));
|
|
445
|
+
}, j = (e) => {
|
|
446
|
+
f && (e.key === "Delete" || e.key === "Backspace") && s && (e.preventDefault(), t());
|
|
447
|
+
}, M = async (e) => {
|
|
448
|
+
if (!(!f || !e)) {
|
|
449
|
+
T(null), D(!0);
|
|
447
450
|
try {
|
|
448
|
-
let t = await
|
|
451
|
+
let t = await Ce(q({
|
|
449
452
|
type: "file",
|
|
450
453
|
file: e,
|
|
451
454
|
mimeType: e.type
|
|
452
|
-
}),
|
|
453
|
-
|
|
455
|
+
}), l.onUpload);
|
|
456
|
+
c(Ee(t)), C("");
|
|
454
457
|
} catch (e) {
|
|
455
|
-
|
|
458
|
+
T(e instanceof Error ? e.message : d.uploadFailedError);
|
|
456
459
|
} finally {
|
|
457
|
-
|
|
460
|
+
D(!1), x(!1);
|
|
458
461
|
}
|
|
459
462
|
}
|
|
460
463
|
};
|
|
461
|
-
return
|
|
464
|
+
return O ? /* @__PURE__ */ Z(a, {
|
|
462
465
|
as: "figure",
|
|
463
466
|
className: "markweave-video-node",
|
|
464
467
|
"data-testid": "markweave-video-node",
|
|
465
468
|
"data-empty": "true",
|
|
466
469
|
"data-selected": "false",
|
|
467
|
-
children: /* @__PURE__ */ Z(
|
|
468
|
-
dragActive:
|
|
469
|
-
error:
|
|
470
|
-
fileInputRef:
|
|
471
|
-
inputValue:
|
|
472
|
-
isSubmitting:
|
|
473
|
-
messages:
|
|
470
|
+
children: /* @__PURE__ */ Z(kr, {
|
|
471
|
+
dragActive: b,
|
|
472
|
+
error: w,
|
|
473
|
+
fileInputRef: y,
|
|
474
|
+
inputValue: S,
|
|
475
|
+
isSubmitting: E,
|
|
476
|
+
messages: u,
|
|
474
477
|
onCancel: t,
|
|
475
|
-
onDragActiveChange:
|
|
478
|
+
onDragActiveChange: x,
|
|
476
479
|
onDrop: (e) => {
|
|
477
|
-
e.preventDefault(), e.stopPropagation(),
|
|
480
|
+
e.preventDefault(), e.stopPropagation(), f && M(e.dataTransfer.files?.[0] ?? null);
|
|
478
481
|
},
|
|
479
482
|
onFileChange: (e) => {
|
|
480
|
-
|
|
483
|
+
M(e.currentTarget.files?.[0] ?? null), e.currentTarget.value = "";
|
|
481
484
|
},
|
|
482
|
-
onInputChange:
|
|
485
|
+
onInputChange: C,
|
|
483
486
|
onSubmit: () => {
|
|
484
|
-
if (!
|
|
485
|
-
let e =
|
|
487
|
+
if (!f) return;
|
|
488
|
+
let e = De(S);
|
|
486
489
|
if (!e) {
|
|
487
|
-
|
|
490
|
+
T(d.unsupportedUrlError);
|
|
488
491
|
return;
|
|
489
492
|
}
|
|
490
|
-
|
|
493
|
+
T(null), c(e), C("");
|
|
491
494
|
}
|
|
492
495
|
})
|
|
493
|
-
}) : /* @__PURE__ */ Z(
|
|
496
|
+
}) : /* @__PURE__ */ Z(a, {
|
|
494
497
|
as: "figure",
|
|
495
498
|
className: "markweave-video-node",
|
|
496
499
|
"data-testid": "markweave-video-node",
|
|
497
|
-
"data-provider":
|
|
498
|
-
"data-empty":
|
|
499
|
-
"data-selected":
|
|
500
|
-
tabIndex:
|
|
501
|
-
"aria-label":
|
|
502
|
-
onFocus:
|
|
503
|
-
onKeyDown:
|
|
504
|
-
onMouseDown:
|
|
505
|
-
children:
|
|
500
|
+
"data-provider": h ?? "file",
|
|
501
|
+
"data-empty": p ? "false" : "true",
|
|
502
|
+
"data-selected": f && s ? "true" : "false",
|
|
503
|
+
tabIndex: f ? 0 : void 0,
|
|
504
|
+
"aria-label": d.nodeAriaLabel,
|
|
505
|
+
onFocus: k,
|
|
506
|
+
onKeyDown: j,
|
|
507
|
+
onMouseDown: A,
|
|
508
|
+
children: g ? /* @__PURE__ */ Q("div", {
|
|
506
509
|
className: "markweave-video-embed",
|
|
507
510
|
children: [/* @__PURE__ */ Z("iframe", {
|
|
508
511
|
className: "markweave-video-iframe",
|
|
509
|
-
src:
|
|
510
|
-
title:
|
|
512
|
+
src: g,
|
|
513
|
+
title: v ?? `${h ?? "Video"} embed`,
|
|
511
514
|
"data-markweave-video-embed": "true",
|
|
512
|
-
"data-markweave-video-provider":
|
|
513
|
-
"data-markweave-video-src":
|
|
514
|
-
allow:
|
|
515
|
+
"data-markweave-video-provider": h ?? void 0,
|
|
516
|
+
"data-markweave-video-src": p ?? void 0,
|
|
517
|
+
allow: je,
|
|
515
518
|
loading: "lazy",
|
|
516
519
|
allowFullScreen: !0
|
|
517
|
-
}),
|
|
520
|
+
}), f ? /* @__PURE__ */ Z("button", {
|
|
518
521
|
type: "button",
|
|
519
522
|
className: "markweave-video-selection-layer",
|
|
520
523
|
"data-testid": "markweave-video-selection-layer",
|
|
521
524
|
tabIndex: -1,
|
|
522
|
-
"aria-label":
|
|
525
|
+
"aria-label": d.selectAriaLabel
|
|
523
526
|
}) : null]
|
|
524
|
-
}) :
|
|
527
|
+
}) : p ? /* @__PURE__ */ Q("div", {
|
|
525
528
|
className: "markweave-video-box",
|
|
526
529
|
children: [/* @__PURE__ */ Z("video", {
|
|
527
530
|
className: "markweave-video",
|
|
528
|
-
src:
|
|
529
|
-
title:
|
|
531
|
+
src: p,
|
|
532
|
+
title: v ?? void 0,
|
|
530
533
|
"data-markweave-video": "true",
|
|
531
|
-
"data-markweave-mime-type":
|
|
534
|
+
"data-markweave-mime-type": _ ?? void 0,
|
|
532
535
|
preload: "metadata",
|
|
533
536
|
controls: !0
|
|
534
|
-
}),
|
|
537
|
+
}), f ? /* @__PURE__ */ Z("button", {
|
|
535
538
|
type: "button",
|
|
536
539
|
className: "markweave-video-selection-layer",
|
|
537
540
|
"data-testid": "markweave-video-selection-layer",
|
|
538
541
|
tabIndex: -1,
|
|
539
|
-
"aria-label":
|
|
542
|
+
"aria-label": d.selectAriaLabel
|
|
540
543
|
}) : null]
|
|
541
544
|
}) : /* @__PURE__ */ Z("div", {
|
|
542
545
|
className: "markweave-video-readonly-empty",
|
|
@@ -545,7 +548,7 @@ function xr(e) {
|
|
|
545
548
|
})
|
|
546
549
|
});
|
|
547
550
|
}
|
|
548
|
-
function
|
|
551
|
+
function kr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitting: i, messages: a, onCancel: o, onDragActiveChange: s, onDrop: c, onFileChange: l, onInputChange: u, onSubmit: d }) {
|
|
549
552
|
let f = a.video;
|
|
550
553
|
return /* @__PURE__ */ Q("section", {
|
|
551
554
|
className: "markweave-video-upload-placeholder",
|
|
@@ -572,7 +575,7 @@ function Sr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
|
|
|
572
575
|
/* @__PURE__ */ Z("div", {
|
|
573
576
|
className: "markweave-video-upload-icon",
|
|
574
577
|
"aria-hidden": "true",
|
|
575
|
-
children: /* @__PURE__ */ Z(
|
|
578
|
+
children: /* @__PURE__ */ Z(ye, {
|
|
576
579
|
size: 46,
|
|
577
580
|
strokeWidth: 1.6
|
|
578
581
|
})
|
|
@@ -607,7 +610,7 @@ function Sr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
|
|
|
607
610
|
"data-testid": "markweave-video-upload-submit",
|
|
608
611
|
disabled: i || !r.trim(),
|
|
609
612
|
onClick: d,
|
|
610
|
-
children: [/* @__PURE__ */ Z(
|
|
613
|
+
children: [/* @__PURE__ */ Z(ve, {
|
|
611
614
|
size: 16,
|
|
612
615
|
strokeWidth: 1.8
|
|
613
616
|
}), a.common.insert]
|
|
@@ -627,26 +630,227 @@ function Sr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
|
|
|
627
630
|
]
|
|
628
631
|
});
|
|
629
632
|
}
|
|
630
|
-
var
|
|
633
|
+
var Ar = Te.extend({
|
|
631
634
|
addOptions() {
|
|
632
635
|
return {
|
|
633
636
|
...this.parent?.(),
|
|
634
|
-
messages:
|
|
637
|
+
messages: n("zh"),
|
|
635
638
|
onUpload: void 0
|
|
636
639
|
};
|
|
637
640
|
},
|
|
638
641
|
addNodeView() {
|
|
639
|
-
return typeof document > "u" ? null :
|
|
642
|
+
return typeof document > "u" ? null : o(Or, { stopEvent: ({ event: e }) => Dr(e.target) });
|
|
643
|
+
}
|
|
644
|
+
});
|
|
645
|
+
//#endregion
|
|
646
|
+
//#region src/link-card-node.tsx
|
|
647
|
+
function jr(e) {
|
|
648
|
+
return e instanceof Element && !!e.closest("[data-markweave-link-card-ui=\"true\"]");
|
|
649
|
+
}
|
|
650
|
+
function Mr(e) {
|
|
651
|
+
return typeof navigator < "u" && navigator.clipboard?.writeText ? navigator.clipboard.writeText(e).catch(() => void 0) : Promise.resolve();
|
|
652
|
+
}
|
|
653
|
+
function Nr(e) {
|
|
654
|
+
!e || typeof window > "u" || window.open(e, "_blank", "noopener,noreferrer");
|
|
655
|
+
}
|
|
656
|
+
function Pr(e) {
|
|
657
|
+
try {
|
|
658
|
+
return new URL(e).host;
|
|
659
|
+
} catch {
|
|
660
|
+
return e;
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
function Fr(e) {
|
|
664
|
+
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 = Fe(vr(r)), f = Ve(o.attrs), [p, m] = W(!1), [h, g] = W(!1), [_, v] = W(!1), [y, b] = W(f?.title ?? ""), [x, C] = W(f?.href ?? ""), w = U(null);
|
|
665
|
+
if (V(() => () => w.current?.abort(), []), V(() => {
|
|
666
|
+
b(f?.title ?? ""), C(f?.href ?? ""), v(!1);
|
|
667
|
+
}, [f?.href, f?.title]), !f) return null;
|
|
668
|
+
let T = async (e) => {
|
|
669
|
+
e.preventDefault();
|
|
670
|
+
let t = Ve({
|
|
671
|
+
...f,
|
|
672
|
+
href: x,
|
|
673
|
+
title: y
|
|
674
|
+
});
|
|
675
|
+
if (!t) return;
|
|
676
|
+
s(t), g(!1), w.current?.abort();
|
|
677
|
+
let n = new AbortController();
|
|
678
|
+
w.current = n;
|
|
679
|
+
try {
|
|
680
|
+
let e = await c.resolver?.({
|
|
681
|
+
href: t.href,
|
|
682
|
+
title: t.title,
|
|
683
|
+
signal: n.signal
|
|
684
|
+
});
|
|
685
|
+
!n.signal.aborted && e && s(Ve({
|
|
686
|
+
...t,
|
|
687
|
+
...e
|
|
688
|
+
}) ?? t);
|
|
689
|
+
} catch {}
|
|
690
|
+
}, E = () => {
|
|
691
|
+
let e = i();
|
|
692
|
+
typeof e == "number" && Ue(r, e);
|
|
693
|
+
}, D = _ ? null : f.imageUrl, O = Pr(f.href);
|
|
694
|
+
return /* @__PURE__ */ Q(a, {
|
|
695
|
+
as: "article",
|
|
696
|
+
className: "markweave-link-card",
|
|
697
|
+
"data-testid": "markweave-link-card",
|
|
698
|
+
"data-markweave-link-card": "true",
|
|
699
|
+
"data-hovered": p ? "true" : "false",
|
|
700
|
+
"data-selected": e.selected ? "true" : "false",
|
|
701
|
+
onMouseEnter: () => m(!0),
|
|
702
|
+
onMouseLeave: () => m(!1),
|
|
703
|
+
onMouseDown: (e) => {
|
|
704
|
+
jr(e.target) || e.preventDefault();
|
|
705
|
+
},
|
|
706
|
+
onClick: (e) => {
|
|
707
|
+
jr(e.target) || (e.preventDefault(), Nr(f.href));
|
|
708
|
+
},
|
|
709
|
+
children: [
|
|
710
|
+
/* @__PURE__ */ Q("a", {
|
|
711
|
+
className: "markweave-link-card-main",
|
|
712
|
+
href: f.href,
|
|
713
|
+
"aria-label": u.open,
|
|
714
|
+
children: [/* @__PURE__ */ Q("span", {
|
|
715
|
+
className: "markweave-link-card-copy",
|
|
716
|
+
children: [
|
|
717
|
+
/* @__PURE__ */ Z("strong", { children: f.title }),
|
|
718
|
+
f.description ? /* @__PURE__ */ Z("span", { children: f.description }) : null,
|
|
719
|
+
/* @__PURE__ */ Z("small", { children: f.siteName ?? O })
|
|
720
|
+
]
|
|
721
|
+
}), /* @__PURE__ */ Z("span", {
|
|
722
|
+
className: "markweave-link-card-media",
|
|
723
|
+
"aria-hidden": "true",
|
|
724
|
+
children: D ? /* @__PURE__ */ Z("img", {
|
|
725
|
+
src: D,
|
|
726
|
+
alt: "",
|
|
727
|
+
loading: "lazy",
|
|
728
|
+
referrerPolicy: "no-referrer",
|
|
729
|
+
onError: () => v(!0)
|
|
730
|
+
}) : !_ && f.faviconUrl ? /* @__PURE__ */ Z("img", {
|
|
731
|
+
className: "markweave-link-card-favicon",
|
|
732
|
+
src: f.faviconUrl,
|
|
733
|
+
alt: "",
|
|
734
|
+
loading: "lazy",
|
|
735
|
+
referrerPolicy: "no-referrer",
|
|
736
|
+
onError: () => v(!0)
|
|
737
|
+
}) : /* @__PURE__ */ Z("b", { children: O.slice(0, 1).toUpperCase() })
|
|
738
|
+
})]
|
|
739
|
+
}),
|
|
740
|
+
d && p ? /* @__PURE__ */ Q("div", {
|
|
741
|
+
className: "markweave-link-card-tools",
|
|
742
|
+
"data-markweave-link-card-ui": "true",
|
|
743
|
+
"aria-label": u.toolsAriaLabel,
|
|
744
|
+
children: [
|
|
745
|
+
/* @__PURE__ */ Z(Ir, {
|
|
746
|
+
label: u.convertToLink,
|
|
747
|
+
icon: F,
|
|
748
|
+
onClick: E,
|
|
749
|
+
testId: "markweave-link-card-convert"
|
|
750
|
+
}),
|
|
751
|
+
/* @__PURE__ */ Z(Ir, {
|
|
752
|
+
label: u.copyAddress,
|
|
753
|
+
icon: S,
|
|
754
|
+
onClick: () => void Mr(f.href),
|
|
755
|
+
testId: "markweave-link-card-copy"
|
|
756
|
+
}),
|
|
757
|
+
/* @__PURE__ */ Z(Ir, {
|
|
758
|
+
label: u.edit,
|
|
759
|
+
icon: ie,
|
|
760
|
+
onClick: (e) => {
|
|
761
|
+
let t = i();
|
|
762
|
+
typeof t == "number" && We({
|
|
763
|
+
anchor: e.currentTarget,
|
|
764
|
+
editor: r,
|
|
765
|
+
messages: l,
|
|
766
|
+
resolver: c.resolver,
|
|
767
|
+
card: {
|
|
768
|
+
pos: t,
|
|
769
|
+
attrs: f
|
|
770
|
+
}
|
|
771
|
+
});
|
|
772
|
+
},
|
|
773
|
+
testId: "markweave-link-card-edit"
|
|
774
|
+
}),
|
|
775
|
+
/* @__PURE__ */ Z(Ir, {
|
|
776
|
+
label: u.delete,
|
|
777
|
+
icon: he,
|
|
778
|
+
onClick: t,
|
|
779
|
+
testId: "markweave-link-card-delete"
|
|
780
|
+
})
|
|
781
|
+
]
|
|
782
|
+
}) : null,
|
|
783
|
+
d && h ? /* @__PURE__ */ Q("form", {
|
|
784
|
+
className: "markweave-link-card-editor",
|
|
785
|
+
"data-markweave-link-card-ui": "true",
|
|
786
|
+
"data-testid": "markweave-link-card-editor",
|
|
787
|
+
onSubmit: T,
|
|
788
|
+
children: [
|
|
789
|
+
/* @__PURE__ */ Q("label", { children: [/* @__PURE__ */ Z("span", { children: u.titleLabel }), /* @__PURE__ */ Z("input", {
|
|
790
|
+
"aria-label": u.titleLabel,
|
|
791
|
+
placeholder: u.titlePlaceholder,
|
|
792
|
+
value: y,
|
|
793
|
+
onChange: (e) => b(e.currentTarget.value)
|
|
794
|
+
})] }),
|
|
795
|
+
/* @__PURE__ */ Q("label", { children: [/* @__PURE__ */ Z("span", { children: u.addressLabel }), /* @__PURE__ */ Z("input", {
|
|
796
|
+
"aria-label": u.addressLabel,
|
|
797
|
+
placeholder: u.addressPlaceholder,
|
|
798
|
+
value: x,
|
|
799
|
+
onChange: (e) => C(e.currentTarget.value)
|
|
800
|
+
})] }),
|
|
801
|
+
/* @__PURE__ */ Z("button", {
|
|
802
|
+
type: "submit",
|
|
803
|
+
"aria-label": u.edit,
|
|
804
|
+
disabled: !He(x),
|
|
805
|
+
children: /* @__PURE__ */ Z(F, { size: 16 })
|
|
806
|
+
})
|
|
807
|
+
]
|
|
808
|
+
}) : null
|
|
809
|
+
]
|
|
810
|
+
});
|
|
811
|
+
}
|
|
812
|
+
function Ir({ icon: e, label: t, onClick: n, testId: r }) {
|
|
813
|
+
return /* @__PURE__ */ Q("button", {
|
|
814
|
+
type: "button",
|
|
815
|
+
"aria-label": t,
|
|
816
|
+
title: t,
|
|
817
|
+
"data-testid": r,
|
|
818
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
819
|
+
onClick: n,
|
|
820
|
+
children: [/* @__PURE__ */ Z(e, {
|
|
821
|
+
size: 16,
|
|
822
|
+
strokeWidth: 1.8
|
|
823
|
+
}), /* @__PURE__ */ Z("span", {
|
|
824
|
+
role: "tooltip",
|
|
825
|
+
children: t
|
|
826
|
+
})]
|
|
827
|
+
});
|
|
828
|
+
}
|
|
829
|
+
var Lr = Ge.extend({
|
|
830
|
+
addOptions() {
|
|
831
|
+
return {
|
|
832
|
+
...this.parent?.(),
|
|
833
|
+
messages: n("zh"),
|
|
834
|
+
resolver: void 0
|
|
835
|
+
};
|
|
836
|
+
},
|
|
837
|
+
addNodeView() {
|
|
838
|
+
return typeof document > "u" ? null : o(Fr, { stopEvent: ({ event: e }) => jr(e.target) });
|
|
640
839
|
}
|
|
641
840
|
});
|
|
642
841
|
//#endregion
|
|
643
842
|
//#region src/create-editor-extensions.ts
|
|
644
|
-
function
|
|
843
|
+
function Rr(t = {}) {
|
|
645
844
|
return e({
|
|
646
845
|
lang: t.lang,
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
846
|
+
linkCardExtension: Lr.configure({
|
|
847
|
+
lang: t.lang,
|
|
848
|
+
messages: n(t.lang),
|
|
849
|
+
resolver: t.linkCardResolver
|
|
850
|
+
}),
|
|
851
|
+
mediaExtensions: Be({
|
|
852
|
+
image: Er,
|
|
853
|
+
video: Ar,
|
|
650
854
|
lang: t.lang,
|
|
651
855
|
onImageUpload: t.onImageUpload,
|
|
652
856
|
onVideoUpload: t.onVideoUpload
|
|
@@ -655,7 +859,7 @@ function wr(t = {}) {
|
|
|
655
859
|
}
|
|
656
860
|
//#endregion
|
|
657
861
|
//#region src/ui/codeblock/CodeBlockControls.tsx
|
|
658
|
-
function
|
|
862
|
+
function zr(e) {
|
|
659
863
|
return e === "clipboard" ? /* @__PURE__ */ Q(X, { children: [/* @__PURE__ */ Z("path", { d: "M9 4.5h6a1.5 1.5 0 0 1 1.5 1.5v11A1.5 1.5 0 0 1 15 18.5H7A1.5 1.5 0 0 1 5.5 17V6A1.5 1.5 0 0 1 7 4.5h2" }), /* @__PURE__ */ Z("path", { d: "M8.5 5.5v-1A1.5 1.5 0 0 1 10 3h2a1.5 1.5 0 0 1 1.5 1.5v1h-5Z" })] }) : e === "search" ? /* @__PURE__ */ Q(X, { children: [/* @__PURE__ */ Z("circle", {
|
|
660
864
|
cx: "10",
|
|
661
865
|
cy: "10",
|
|
@@ -692,7 +896,7 @@ function Tr(e) {
|
|
|
692
896
|
/* @__PURE__ */ Z("path", { d: "m14 14 4 4" })
|
|
693
897
|
] }) : e === "reset" ? /* @__PURE__ */ Q(X, { children: [/* @__PURE__ */ Z("path", { d: "M6.5 8.5A6 6 0 1 1 6 15" }), /* @__PURE__ */ Z("path", { d: "M6.5 8.5H3.5v-3" })] }) : /* @__PURE__ */ Z("path", { d: "m6 9 6 6 6-6" });
|
|
694
898
|
}
|
|
695
|
-
function
|
|
899
|
+
function Br({ icon: e }) {
|
|
696
900
|
return /* @__PURE__ */ Z("svg", {
|
|
697
901
|
viewBox: "0 0 24 24",
|
|
698
902
|
"aria-hidden": "true",
|
|
@@ -703,40 +907,40 @@ function Er({ icon: e }) {
|
|
|
703
907
|
strokeLinecap: "round",
|
|
704
908
|
strokeLinejoin: "round",
|
|
705
909
|
strokeWidth: "1.8",
|
|
706
|
-
children:
|
|
910
|
+
children: zr(e)
|
|
707
911
|
})
|
|
708
912
|
});
|
|
709
913
|
}
|
|
710
|
-
function
|
|
914
|
+
function Vr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, readOnly: i = !1 }) {
|
|
711
915
|
let a = U(null), o = U(null), s = U(null), c = U({
|
|
712
916
|
active: !1,
|
|
713
917
|
lastX: 0,
|
|
714
918
|
lastY: 0
|
|
715
|
-
}), [l, u] = W(null), [d, f] = W(null), [p, m] = W([]), [h, g] = W(null), [_, v] = W(!1), [y, b] = W(""), [x, S] = W(null), [C, w] = W(!1), [T, E] = W(null), [D, O] = W(null), [
|
|
716
|
-
...
|
|
717
|
-
pos:
|
|
919
|
+
}), [l, u] = W(null), [d, f] = W(null), [p, m] = W([]), [h, g] = W(null), [_, v] = W(!1), [y, b] = W(""), [x, S] = W(null), [C, w] = W(!1), [T, E] = W(null), [D, O] = W(null), [k, A] = W(!1), [j, M] = W(0), [ee, N] = W(0), P = pt(t), te = pn(t, l), F = !i && e && P.active && P.pos !== null ? {
|
|
920
|
+
...P,
|
|
921
|
+
pos: P.pos,
|
|
718
922
|
active: !0
|
|
719
|
-
} : null,
|
|
923
|
+
} : null, I = te ?? F, ne = I !== null, L = I?.language === "mermaid", re = _n(t, I), R = ne && I !== null && !re, z = !i, ie = sn(I ? I.language : "text"), ae = x?.status ?? "idle", oe = I?.mermaidPreviewMode ?? n, se = L && oe === "preview", ce = hn(t), le = `${ee}|${ce.map((e) => `${e.pos}:${e.mermaidPreviewMode}:${e.text.length}`).join("|")}`, ue = H(() => dn(y.trim().toLowerCase()), [y]);
|
|
720
924
|
if (V(() => {
|
|
721
925
|
i && (v(!1), b(""));
|
|
722
926
|
}, [i]), V(() => {
|
|
723
927
|
if (!x) return;
|
|
724
928
|
let e = window.setTimeout(() => {
|
|
725
929
|
S(null);
|
|
726
|
-
},
|
|
930
|
+
}, en);
|
|
727
931
|
return () => {
|
|
728
932
|
window.clearTimeout(e);
|
|
729
933
|
};
|
|
730
934
|
}, [x]), V(() => {
|
|
731
|
-
S(null), v(!1), b(""), E(null), O(null),
|
|
935
|
+
S(null), v(!1), b(""), E(null), O(null), A(!1);
|
|
732
936
|
}, [
|
|
733
937
|
e,
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
938
|
+
I?.language,
|
|
939
|
+
I?.pos,
|
|
940
|
+
I?.text
|
|
737
941
|
]), V(() => {
|
|
738
942
|
let e = ({ transaction: e }) => {
|
|
739
|
-
e.getMeta(
|
|
943
|
+
e.getMeta(dt) && M((e) => e + 1);
|
|
740
944
|
};
|
|
741
945
|
return t.on("transaction", e), () => {
|
|
742
946
|
t.off("transaction", e);
|
|
@@ -746,7 +950,7 @@ function Dr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
746
950
|
if (!e) return;
|
|
747
951
|
let n = (e) => {
|
|
748
952
|
if (e.target instanceof Node && a.current?.contains(e.target) || _) return;
|
|
749
|
-
let n =
|
|
953
|
+
let n = pn(t, fn(t, e.target)), r = n && !_n(t, n) ? n.pos : null;
|
|
750
954
|
u((e) => e === r ? e : r);
|
|
751
955
|
}, r = () => {
|
|
752
956
|
_ || u(null);
|
|
@@ -759,7 +963,7 @@ function Dr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
759
963
|
}, [_]), V(() => {
|
|
760
964
|
if (!T) return;
|
|
761
965
|
let e = (e) => {
|
|
762
|
-
e.key === "Escape" && (E(null), O(null),
|
|
966
|
+
e.key === "Escape" && (E(null), O(null), A(!1), c.current = {
|
|
763
967
|
active: !1,
|
|
764
968
|
lastX: 0,
|
|
765
969
|
lastY: 0
|
|
@@ -769,7 +973,7 @@ function Dr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
769
973
|
document.removeEventListener("keydown", e);
|
|
770
974
|
};
|
|
771
975
|
}, [t, T]), V(() => {
|
|
772
|
-
if (!
|
|
976
|
+
if (!ne || !_) return;
|
|
773
977
|
let e = (e) => {
|
|
774
978
|
e.key === "Escape" && (v(!1), t.view.focus());
|
|
775
979
|
}, n = (e) => {
|
|
@@ -779,22 +983,22 @@ function Dr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
779
983
|
document.removeEventListener("keydown", e), document.removeEventListener("mousedown", n);
|
|
780
984
|
};
|
|
781
985
|
}, [
|
|
782
|
-
|
|
986
|
+
ne,
|
|
783
987
|
t,
|
|
784
988
|
_
|
|
785
|
-
]),
|
|
989
|
+
]), be(() => {
|
|
786
990
|
let e = () => {
|
|
787
991
|
let e = a.current;
|
|
788
992
|
if (!e) return;
|
|
789
|
-
if (!
|
|
993
|
+
if (!mn(e) || ce.length === 0) {
|
|
790
994
|
m([]);
|
|
791
995
|
return;
|
|
792
996
|
}
|
|
793
997
|
let n = e.getBoundingClientRect(), r = ce.flatMap((e) => {
|
|
794
|
-
let r =
|
|
795
|
-
return r ? [
|
|
998
|
+
let r = un(ln(t, e.pos, e.mermaidPreviewMode), n);
|
|
999
|
+
return r ? [an(e, r, n)] : [];
|
|
796
1000
|
});
|
|
797
|
-
m((e) =>
|
|
1001
|
+
m((e) => vn(e, r, ce.map((e) => e.pos)));
|
|
798
1002
|
};
|
|
799
1003
|
e();
|
|
800
1004
|
let n = window.requestAnimationFrame(e);
|
|
@@ -802,26 +1006,26 @@ function Dr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
802
1006
|
window.cancelAnimationFrame(n), window.removeEventListener("resize", e), window.removeEventListener("scroll", e, !0);
|
|
803
1007
|
};
|
|
804
1008
|
}, [
|
|
805
|
-
|
|
1009
|
+
j,
|
|
806
1010
|
t,
|
|
807
1011
|
le
|
|
808
|
-
]),
|
|
809
|
-
if (!R || !
|
|
1012
|
+
]), be(() => {
|
|
1013
|
+
if (!R || !I) {
|
|
810
1014
|
f(null), g(null);
|
|
811
1015
|
return;
|
|
812
1016
|
}
|
|
813
1017
|
let e = () => {
|
|
814
1018
|
let e = a.current;
|
|
815
1019
|
if (!e) return;
|
|
816
|
-
let n =
|
|
1020
|
+
let n = ln(t, I.pos, oe), r = e.getBoundingClientRect(), i = un(n, r);
|
|
817
1021
|
if (!i) {
|
|
818
|
-
f((e) => e?.pos ===
|
|
1022
|
+
f((e) => e?.pos === I.pos ? e : null), g((e) => _ ? e : null);
|
|
819
1023
|
return;
|
|
820
1024
|
}
|
|
821
|
-
let s =
|
|
1025
|
+
let s = nn(I.pos, i, r);
|
|
822
1026
|
if (f(s), _ && o.current) {
|
|
823
1027
|
let e = o.current.getBoundingClientRect();
|
|
824
|
-
g(
|
|
1028
|
+
g(Qt({
|
|
825
1029
|
overlayRect: r,
|
|
826
1030
|
buttonRect: e,
|
|
827
1031
|
windowWidth: window.innerWidth,
|
|
@@ -834,78 +1038,78 @@ function Dr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
834
1038
|
};
|
|
835
1039
|
}, [
|
|
836
1040
|
R,
|
|
837
|
-
|
|
838
|
-
|
|
1041
|
+
j,
|
|
1042
|
+
I?.pos,
|
|
839
1043
|
t,
|
|
840
1044
|
_,
|
|
841
|
-
|
|
1045
|
+
oe
|
|
842
1046
|
]), !R && ce.length === 0 && !T) return null;
|
|
843
1047
|
let de = d ? {
|
|
844
1048
|
top: d.top,
|
|
845
1049
|
right: d.right
|
|
846
1050
|
} : void 0, fe = async () => {
|
|
847
1051
|
if (i) {
|
|
848
|
-
if (!
|
|
849
|
-
let e = await
|
|
850
|
-
S(
|
|
1052
|
+
if (!I) return;
|
|
1053
|
+
let e = await tn(I.text);
|
|
1054
|
+
S(mt(I, e ? "copied" : "failed"));
|
|
851
1055
|
return;
|
|
852
1056
|
}
|
|
853
|
-
if (!
|
|
854
|
-
let e = await
|
|
855
|
-
S(
|
|
1057
|
+
if (!on(t, I)) return;
|
|
1058
|
+
let e = await ft(t);
|
|
1059
|
+
S(mt(pt(t), e ? "copied" : "failed")), t.view.focus();
|
|
856
1060
|
}, pe = (e, n) => {
|
|
857
1061
|
if (i) {
|
|
858
|
-
|
|
1062
|
+
St(t, e.pos, n) && N((e) => e + 1);
|
|
859
1063
|
return;
|
|
860
1064
|
}
|
|
861
|
-
let a =
|
|
862
|
-
|
|
1065
|
+
let a = P.active && P.pos === e.pos;
|
|
1066
|
+
vt(t, e.pos, n) && (r(n), N((e) => e + 1), a && t.view.focus());
|
|
863
1067
|
}, me = (e) => {
|
|
864
|
-
if (i || !
|
|
865
|
-
let n =
|
|
866
|
-
|
|
867
|
-
},
|
|
868
|
-
i || !
|
|
1068
|
+
if (i || !I) return;
|
|
1069
|
+
let n = P.active && P.pos === I.pos;
|
|
1070
|
+
_t(t, I.pos, e) && (e === "mermaid" && vt(t, I.pos, "preview") && r("preview"), v(!1), b(""), N((e) => e + 1), n && t.view.focus());
|
|
1071
|
+
}, he = () => {
|
|
1072
|
+
i || !I || gt(t, I.pos, !re) && (M((e) => e + 1), u(null));
|
|
869
1073
|
}, ge = () => {
|
|
870
|
-
if (!
|
|
871
|
-
let e =
|
|
1074
|
+
if (!I) return;
|
|
1075
|
+
let e = gn(t, I.pos);
|
|
872
1076
|
if (!e) return;
|
|
873
1077
|
let n = new Blob([e], { type: "image/svg+xml" }), r = URL.createObjectURL(n), i = document.createElement("a");
|
|
874
1078
|
i.href = r, i.download = "markweave-mermaid.svg", i.click(), URL.revokeObjectURL(r), t.view.focus();
|
|
875
1079
|
}, _e = () => {
|
|
876
|
-
if (!
|
|
877
|
-
let e =
|
|
878
|
-
e && (E(
|
|
1080
|
+
if (!I) return;
|
|
1081
|
+
let e = gn(t, I.pos);
|
|
1082
|
+
e && (E(rn(e)), O(null), A(!1), c.current = {
|
|
879
1083
|
active: !1,
|
|
880
1084
|
lastX: 0,
|
|
881
1085
|
lastY: 0
|
|
882
1086
|
});
|
|
883
1087
|
}, ve = () => {
|
|
884
|
-
E(null), O(null),
|
|
1088
|
+
E(null), O(null), A(!1), c.current = {
|
|
885
1089
|
active: !1,
|
|
886
1090
|
lastX: 0,
|
|
887
1091
|
lastY: 0
|
|
888
1092
|
}, t.view.focus();
|
|
889
|
-
},
|
|
1093
|
+
}, ye = (e) => {
|
|
890
1094
|
E((t) => t && {
|
|
891
1095
|
...t,
|
|
892
|
-
scale:
|
|
1096
|
+
scale: $t(t.scale + e)
|
|
893
1097
|
});
|
|
894
|
-
},
|
|
895
|
-
E((e) => e &&
|
|
1098
|
+
}, B = () => {
|
|
1099
|
+
E((e) => e && rn(e.svg)), c.current = {
|
|
896
1100
|
active: !1,
|
|
897
1101
|
lastX: 0,
|
|
898
1102
|
lastY: 0
|
|
899
|
-
},
|
|
900
|
-
},
|
|
901
|
-
e.preventDefault(),
|
|
902
|
-
},
|
|
1103
|
+
}, A(!1);
|
|
1104
|
+
}, G = (e) => {
|
|
1105
|
+
e.preventDefault(), ye(e.deltaY < 0 ? yn : -yn);
|
|
1106
|
+
}, xe = (e) => {
|
|
903
1107
|
e.button === 0 && (e.preventDefault(), c.current = {
|
|
904
1108
|
active: !0,
|
|
905
1109
|
lastX: e.clientX,
|
|
906
1110
|
lastY: e.clientY
|
|
907
|
-
},
|
|
908
|
-
},
|
|
1111
|
+
}, A(!0));
|
|
1112
|
+
}, Se = (e) => {
|
|
909
1113
|
let t = c.current;
|
|
910
1114
|
if (!t.active) return;
|
|
911
1115
|
let n = e.clientX - t.lastX, r = e.clientY - t.lastY;
|
|
@@ -913,13 +1117,13 @@ function Dr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
913
1117
|
active: !0,
|
|
914
1118
|
lastX: e.clientX,
|
|
915
1119
|
lastY: e.clientY
|
|
916
|
-
}, E((e) =>
|
|
917
|
-
},
|
|
1120
|
+
}, E((e) => bn(e, n, r));
|
|
1121
|
+
}, Ce = () => {
|
|
918
1122
|
c.current = {
|
|
919
1123
|
active: !1,
|
|
920
1124
|
lastX: 0,
|
|
921
1125
|
lastY: 0
|
|
922
|
-
},
|
|
1126
|
+
}, A(!1);
|
|
923
1127
|
};
|
|
924
1128
|
return /* @__PURE__ */ Q("div", {
|
|
925
1129
|
ref: a,
|
|
@@ -952,7 +1156,7 @@ function Dr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
952
1156
|
className: "markweave-codeblock-controls",
|
|
953
1157
|
"data-testid": "markweave-codeblock-controls",
|
|
954
1158
|
"data-positioned": d ? "true" : "false",
|
|
955
|
-
"data-collapsed":
|
|
1159
|
+
"data-collapsed": re ? "true" : "false",
|
|
956
1160
|
"data-read-only": i ? "true" : "false",
|
|
957
1161
|
"aria-label": "Code block controls",
|
|
958
1162
|
style: de,
|
|
@@ -961,7 +1165,7 @@ function Dr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
961
1165
|
className: "markweave-codeblock-language-button markweave-codeblock-language-label",
|
|
962
1166
|
"aria-label": "Code block language",
|
|
963
1167
|
"data-testid": "markweave-codeblock-language",
|
|
964
|
-
children: /* @__PURE__ */ Z("span", { children:
|
|
1168
|
+
children: /* @__PURE__ */ Z("span", { children: ie })
|
|
965
1169
|
}) : /* @__PURE__ */ Q("button", {
|
|
966
1170
|
ref: o,
|
|
967
1171
|
type: "button",
|
|
@@ -972,18 +1176,18 @@ function Dr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
972
1176
|
"data-testid": "markweave-codeblock-language",
|
|
973
1177
|
onMouseDown: (e) => e.preventDefault(),
|
|
974
1178
|
onClick: () => v((e) => !e),
|
|
975
|
-
children: [/* @__PURE__ */ Z("span", { children:
|
|
1179
|
+
children: [/* @__PURE__ */ Z("span", { children: ie }), /* @__PURE__ */ Z(Br, { icon: "chevron" })]
|
|
976
1180
|
}),
|
|
977
|
-
|
|
1181
|
+
z ? /* @__PURE__ */ Z("button", {
|
|
978
1182
|
type: "button",
|
|
979
1183
|
className: "markweave-codeblock-icon-button markweave-codeblock-collapse-button",
|
|
980
|
-
"aria-label":
|
|
981
|
-
title:
|
|
1184
|
+
"aria-label": re ? "Expand code block" : "Collapse code block",
|
|
1185
|
+
title: re ? "Expand code block" : "Collapse code block",
|
|
982
1186
|
"data-testid": "markweave-codeblock-collapse",
|
|
983
|
-
"data-collapsed":
|
|
1187
|
+
"data-collapsed": re ? "true" : "false",
|
|
984
1188
|
onMouseDown: (e) => e.preventDefault(),
|
|
985
|
-
onClick:
|
|
986
|
-
children: /* @__PURE__ */ Z(
|
|
1189
|
+
onClick: he,
|
|
1190
|
+
children: /* @__PURE__ */ Z(Br, { icon: "chevron" })
|
|
987
1191
|
}) : null,
|
|
988
1192
|
/* @__PURE__ */ Q("span", {
|
|
989
1193
|
className: "markweave-codeblock-copy-wrap",
|
|
@@ -992,14 +1196,14 @@ function Dr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
992
1196
|
className: "markweave-codeblock-icon-button",
|
|
993
1197
|
"aria-label": "Copy to clipboard",
|
|
994
1198
|
"data-testid": "markweave-codeblock-copy",
|
|
995
|
-
"data-copy-state":
|
|
1199
|
+
"data-copy-state": ae,
|
|
996
1200
|
onMouseDown: (e) => e.preventDefault(),
|
|
997
1201
|
onMouseEnter: () => w(!0),
|
|
998
1202
|
onMouseLeave: () => w(!1),
|
|
999
1203
|
onFocus: () => w(!0),
|
|
1000
1204
|
onBlur: () => w(!1),
|
|
1001
1205
|
onClick: fe,
|
|
1002
|
-
children: /* @__PURE__ */ Z(
|
|
1206
|
+
children: /* @__PURE__ */ Z(Br, { icon: ae === "copied" ? "check" : "clipboard" })
|
|
1003
1207
|
}), C ? /* @__PURE__ */ Z("span", {
|
|
1004
1208
|
className: "markweave-codeblock-tooltip",
|
|
1005
1209
|
role: "tooltip",
|
|
@@ -1007,7 +1211,7 @@ function Dr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1007
1211
|
children: "Copy to clipboard"
|
|
1008
1212
|
}) : null]
|
|
1009
1213
|
}),
|
|
1010
|
-
|
|
1214
|
+
L && oe === "preview" ? /* @__PURE__ */ Q("div", {
|
|
1011
1215
|
className: "markweave-mermaid-preview-actions",
|
|
1012
1216
|
"data-testid": "markweave-mermaid-preview-actions",
|
|
1013
1217
|
children: [/* @__PURE__ */ Z("button", {
|
|
@@ -1018,7 +1222,7 @@ function Dr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1018
1222
|
disabled: !se,
|
|
1019
1223
|
onMouseDown: (e) => e.preventDefault(),
|
|
1020
1224
|
onClick: _e,
|
|
1021
|
-
children: /* @__PURE__ */ Z(
|
|
1225
|
+
children: /* @__PURE__ */ Z(Br, { icon: "expand" })
|
|
1022
1226
|
}), /* @__PURE__ */ Z("button", {
|
|
1023
1227
|
type: "button",
|
|
1024
1228
|
className: "markweave-codeblock-icon-button",
|
|
@@ -1027,12 +1231,12 @@ function Dr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1027
1231
|
disabled: !se,
|
|
1028
1232
|
onMouseDown: (e) => e.preventDefault(),
|
|
1029
1233
|
onClick: ge,
|
|
1030
|
-
children: /* @__PURE__ */ Z(
|
|
1234
|
+
children: /* @__PURE__ */ Z(Br, { icon: "download" })
|
|
1031
1235
|
})]
|
|
1032
1236
|
}) : null
|
|
1033
1237
|
]
|
|
1034
1238
|
}) : null,
|
|
1035
|
-
|
|
1239
|
+
z && R && _ ? /* @__PURE__ */ Q("div", {
|
|
1036
1240
|
className: "markweave-codeblock-language-menu",
|
|
1037
1241
|
role: "listbox",
|
|
1038
1242
|
"aria-label": "Code block languages",
|
|
@@ -1053,11 +1257,11 @@ function Dr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1053
1257
|
onKeyDown: (e) => {
|
|
1054
1258
|
e.key === "Escape" && (e.preventDefault(), v(!1), t.view.focus());
|
|
1055
1259
|
}
|
|
1056
|
-
}), /* @__PURE__ */ Z(
|
|
1260
|
+
}), /* @__PURE__ */ Z(Br, { icon: "search" })]
|
|
1057
1261
|
}), /* @__PURE__ */ Z("div", {
|
|
1058
1262
|
className: "markweave-codeblock-language-list",
|
|
1059
1263
|
children: ue.map((e) => {
|
|
1060
|
-
let t = e.language ===
|
|
1264
|
+
let t = e.language === I.language;
|
|
1061
1265
|
return /* @__PURE__ */ Q("button", {
|
|
1062
1266
|
type: "button",
|
|
1063
1267
|
role: "option",
|
|
@@ -1066,7 +1270,7 @@ function Dr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1066
1270
|
"data-active": t ? "true" : "false",
|
|
1067
1271
|
onMouseDown: (e) => e.preventDefault(),
|
|
1068
1272
|
onClick: () => me(e.language),
|
|
1069
|
-
children: [/* @__PURE__ */ Z("span", { children: e.label }), t ? /* @__PURE__ */ Z(
|
|
1273
|
+
children: [/* @__PURE__ */ Z("span", { children: e.label }), t ? /* @__PURE__ */ Z(Br, { icon: "check" }) : null]
|
|
1070
1274
|
}, e.language);
|
|
1071
1275
|
})
|
|
1072
1276
|
})]
|
|
@@ -1091,13 +1295,13 @@ function Dr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1091
1295
|
onMouseLeave: () => O(null),
|
|
1092
1296
|
onFocus: () => O("zoom-out"),
|
|
1093
1297
|
onBlur: () => O(null),
|
|
1094
|
-
onClick: () =>
|
|
1095
|
-
children: /* @__PURE__ */ Z(
|
|
1298
|
+
onClick: () => ye(-yn),
|
|
1299
|
+
children: /* @__PURE__ */ Z(Br, { icon: "zoomOut" })
|
|
1096
1300
|
}),
|
|
1097
1301
|
/* @__PURE__ */ Z("span", {
|
|
1098
1302
|
className: "markweave-mermaid-fullscreen-zoom-label",
|
|
1099
1303
|
"data-testid": "markweave-mermaid-fullscreen-zoom-label",
|
|
1100
|
-
children:
|
|
1304
|
+
children: cn(T.scale)
|
|
1101
1305
|
}),
|
|
1102
1306
|
/* @__PURE__ */ Z("button", {
|
|
1103
1307
|
type: "button",
|
|
@@ -1108,8 +1312,8 @@ function Dr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1108
1312
|
onMouseLeave: () => O(null),
|
|
1109
1313
|
onFocus: () => O("zoom-in"),
|
|
1110
1314
|
onBlur: () => O(null),
|
|
1111
|
-
onClick: () =>
|
|
1112
|
-
children: /* @__PURE__ */ Z(
|
|
1315
|
+
onClick: () => ye(yn),
|
|
1316
|
+
children: /* @__PURE__ */ Z(Br, { icon: "zoomIn" })
|
|
1113
1317
|
}),
|
|
1114
1318
|
/* @__PURE__ */ Z("button", {
|
|
1115
1319
|
type: "button",
|
|
@@ -1120,8 +1324,8 @@ function Dr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1120
1324
|
onMouseLeave: () => O(null),
|
|
1121
1325
|
onFocus: () => O("reset"),
|
|
1122
1326
|
onBlur: () => O(null),
|
|
1123
|
-
onClick:
|
|
1124
|
-
children: /* @__PURE__ */ Z(
|
|
1327
|
+
onClick: B,
|
|
1328
|
+
children: /* @__PURE__ */ Z(Br, { icon: "reset" })
|
|
1125
1329
|
}),
|
|
1126
1330
|
D ? /* @__PURE__ */ Z("span", {
|
|
1127
1331
|
className: "markweave-mermaid-fullscreen-tooltip",
|
|
@@ -1137,17 +1341,17 @@ function Dr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1137
1341
|
"aria-label": "Close fullscreen Mermaid preview",
|
|
1138
1342
|
"data-testid": "markweave-mermaid-fullscreen-close",
|
|
1139
1343
|
onClick: ve,
|
|
1140
|
-
children: /* @__PURE__ */ Z(
|
|
1344
|
+
children: /* @__PURE__ */ Z(Br, { icon: "close" })
|
|
1141
1345
|
}),
|
|
1142
1346
|
/* @__PURE__ */ Z("div", {
|
|
1143
1347
|
className: "markweave-mermaid-fullscreen-viewport",
|
|
1144
1348
|
"data-testid": "markweave-mermaid-fullscreen-viewport",
|
|
1145
|
-
"data-dragging":
|
|
1146
|
-
onWheel:
|
|
1147
|
-
onMouseDown:
|
|
1148
|
-
onMouseMove:
|
|
1149
|
-
onMouseUp:
|
|
1150
|
-
onMouseLeave:
|
|
1349
|
+
"data-dragging": k ? "true" : "false",
|
|
1350
|
+
onWheel: G,
|
|
1351
|
+
onMouseDown: xe,
|
|
1352
|
+
onMouseMove: Se,
|
|
1353
|
+
onMouseUp: Ce,
|
|
1354
|
+
onMouseLeave: Ce,
|
|
1151
1355
|
children: /* @__PURE__ */ Z("div", {
|
|
1152
1356
|
className: "markweave-mermaid-fullscreen-content",
|
|
1153
1357
|
"data-testid": "markweave-mermaid-fullscreen-content",
|
|
@@ -1168,25 +1372,25 @@ function Dr({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1168
1372
|
}
|
|
1169
1373
|
//#endregion
|
|
1170
1374
|
//#region src/ui/floating-toolbar/FloatingToolbar.tsx
|
|
1171
|
-
var
|
|
1172
|
-
function
|
|
1375
|
+
var Hr = n("zh");
|
|
1376
|
+
function Ur() {
|
|
1173
1377
|
return typeof performance > "u" ? Date.now() : performance.now();
|
|
1174
1378
|
}
|
|
1175
|
-
function
|
|
1379
|
+
function Wr(e, t) {
|
|
1176
1380
|
return {
|
|
1177
1381
|
"--markweave-toolbar-motion-duration": `${e.motionDurationMs}ms`,
|
|
1178
1382
|
"--markweave-toolbar-motion-easing": e.motionEasing,
|
|
1179
1383
|
marginLeft: t === 0 ? void 0 : `${t}px`
|
|
1180
1384
|
};
|
|
1181
1385
|
}
|
|
1182
|
-
function
|
|
1386
|
+
function Gr(e, t) {
|
|
1183
1387
|
let n = e?.getBoundingClientRect().height ?? 0, r = t?.getBoundingClientRect().height ?? 0;
|
|
1184
1388
|
return Math.max(n, r, 44);
|
|
1185
1389
|
}
|
|
1186
|
-
function
|
|
1390
|
+
function Kr(e) {
|
|
1187
1391
|
if (e !== null) return { "--markweave-floating-toolbar-tooltip-left": `${e}px` };
|
|
1188
1392
|
}
|
|
1189
|
-
function
|
|
1393
|
+
function qr(e, t, n, r) {
|
|
1190
1394
|
let i = {
|
|
1191
1395
|
bottom: t + r,
|
|
1192
1396
|
height: r,
|
|
@@ -1202,26 +1406,26 @@ function Nr(e, t, n, r) {
|
|
|
1202
1406
|
toJSON: () => i
|
|
1203
1407
|
};
|
|
1204
1408
|
}
|
|
1205
|
-
function
|
|
1409
|
+
function Jr(e) {
|
|
1206
1410
|
return e.width > 0 && e.height > 0;
|
|
1207
1411
|
}
|
|
1208
|
-
function
|
|
1412
|
+
function Yr(e) {
|
|
1209
1413
|
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));
|
|
1210
|
-
return
|
|
1414
|
+
return qr(t, n, r - t, i - n);
|
|
1211
1415
|
}
|
|
1212
|
-
function
|
|
1416
|
+
function Xr(e, t) {
|
|
1213
1417
|
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;
|
|
1214
1418
|
return r(t.anchorNode) && r(t.focusNode);
|
|
1215
1419
|
}
|
|
1216
|
-
function
|
|
1420
|
+
function Zr(e) {
|
|
1217
1421
|
if (typeof e.getClientRects != "function") return null;
|
|
1218
|
-
let t = Array.from(e.getClientRects()).filter(
|
|
1422
|
+
let t = Array.from(e.getClientRects()).filter(Jr).map((e) => qr(e.left, e.top, e.width, e.height));
|
|
1219
1423
|
if (t.length > 0) return t;
|
|
1220
1424
|
if (typeof e.getBoundingClientRect != "function") return null;
|
|
1221
1425
|
let n = e.getBoundingClientRect();
|
|
1222
|
-
return
|
|
1426
|
+
return Jr(n) ? [qr(n.left, n.top, n.width, n.height)] : null;
|
|
1223
1427
|
}
|
|
1224
|
-
function
|
|
1428
|
+
function Qr(e, t) {
|
|
1225
1429
|
if (t.rangeCount === 0) return null;
|
|
1226
1430
|
let n = t.getRangeAt(0);
|
|
1227
1431
|
try {
|
|
@@ -1234,8 +1438,8 @@ function Rr(e, t) {
|
|
|
1234
1438
|
return null;
|
|
1235
1439
|
}
|
|
1236
1440
|
}
|
|
1237
|
-
function
|
|
1238
|
-
let n =
|
|
1441
|
+
function $r(e, t) {
|
|
1442
|
+
let n = Qr(e, t);
|
|
1239
1443
|
if (!n) return !1;
|
|
1240
1444
|
let { selection: r } = e.state, i = {
|
|
1241
1445
|
from: Math.min(r.from, r.to),
|
|
@@ -1243,51 +1447,51 @@ function zr(e, t) {
|
|
|
1243
1447
|
};
|
|
1244
1448
|
return n.from === i.from && n.to === i.to;
|
|
1245
1449
|
}
|
|
1246
|
-
function
|
|
1450
|
+
function ei(e) {
|
|
1247
1451
|
let t = e.view.dom.ownerDocument.getSelection();
|
|
1248
|
-
return !t || t.rangeCount === 0 || t.isCollapsed || !
|
|
1452
|
+
return !t || t.rangeCount === 0 || t.isCollapsed || !Xr(e, t) || !$r(e, t) ? null : Zr(t.getRangeAt(0));
|
|
1249
1453
|
}
|
|
1250
|
-
function
|
|
1454
|
+
function ti(e) {
|
|
1251
1455
|
let { selection: t } = e.state;
|
|
1252
1456
|
if (t.empty) return null;
|
|
1253
1457
|
let n = Math.min(t.from, t.to), r = Math.max(t.from, t.to);
|
|
1254
1458
|
try {
|
|
1255
1459
|
let t = e.view.domAtPos(n), i = e.view.domAtPos(r), a = e.view.dom.ownerDocument.createRange();
|
|
1256
|
-
return a.setStart(t.node, t.offset), a.setEnd(i.node, i.offset),
|
|
1460
|
+
return a.setStart(t.node, t.offset), a.setEnd(i.node, i.offset), Zr(a);
|
|
1257
1461
|
} catch {
|
|
1258
1462
|
return null;
|
|
1259
1463
|
}
|
|
1260
1464
|
}
|
|
1261
|
-
function
|
|
1465
|
+
function ni(e) {
|
|
1262
1466
|
let { selection: t } = e.state;
|
|
1263
1467
|
if (t.empty) return null;
|
|
1264
|
-
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 =
|
|
1265
|
-
return
|
|
1468
|
+
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 = qr(c, o, Math.max(i.right, a.right) - c, s - o);
|
|
1469
|
+
return Jr(l) ? [l] : null;
|
|
1266
1470
|
}
|
|
1267
|
-
function
|
|
1268
|
-
return
|
|
1471
|
+
function ri(e) {
|
|
1472
|
+
return ei(e) ?? ti(e) ?? ni(e);
|
|
1269
1473
|
}
|
|
1270
|
-
function
|
|
1271
|
-
let t =
|
|
1272
|
-
return t && t.length > 0 ?
|
|
1474
|
+
function ii(e) {
|
|
1475
|
+
let t = ri(e);
|
|
1476
|
+
return t && t.length > 0 ? Yr(t) : null;
|
|
1273
1477
|
}
|
|
1274
|
-
function
|
|
1478
|
+
function ai(e) {
|
|
1275
1479
|
return {
|
|
1276
|
-
getBoundingClientRect: () =>
|
|
1277
|
-
getClientRects: () =>
|
|
1480
|
+
getBoundingClientRect: () => ii(e) ?? qr(0, 0, 0, 0),
|
|
1481
|
+
getClientRects: () => ri(e) ?? []
|
|
1278
1482
|
};
|
|
1279
1483
|
}
|
|
1280
|
-
function
|
|
1484
|
+
function oi(e) {
|
|
1281
1485
|
return e === "block-type" || e === "link" || e === "color" || e === "more";
|
|
1282
1486
|
}
|
|
1283
|
-
function
|
|
1284
|
-
n?.(
|
|
1487
|
+
function si(e, t, n) {
|
|
1488
|
+
n?.(wn(e, t)), e.commands.focus();
|
|
1285
1489
|
}
|
|
1286
|
-
function
|
|
1287
|
-
let i = H(() =>
|
|
1490
|
+
function ci({ editor: e, messages: t = Hr, selectionSnapshot: n, onRewriteSelection: r }) {
|
|
1491
|
+
let i = H(() => kn(t), [t]), a = st(n, { editable: e.isEditable }), [o, s] = W(a), [c, l] = W(null), [u, d] = W(null), [f, p] = W(null), [m, h] = W(""), [g, _] = W(""), [v, y] = W(null), [b, x] = W(0), [S, C] = W(a.boundaryPadding), [w, T] = W("bottom"), E = U(0), D = U(null), O = U(null), k = U(null), A = U(null), j = Tn(e, o.variant, t), M = jn(j.find((e) => e.id === c) ?? null), ee = Hn(m), N = B(() => {
|
|
1288
1492
|
let t = D.current, n = e.view.dom.closest(".markweave-editor-frame");
|
|
1289
1493
|
if (!t || !(n instanceof HTMLElement)) return;
|
|
1290
|
-
let r = t.getBoundingClientRect(), i = n.getBoundingClientRect(), a =
|
|
1494
|
+
let r = t.getBoundingClientRect(), i = n.getBoundingClientRect(), a = Gr(t, O.current), s = E.current, c = nt({
|
|
1291
1495
|
toolbarRect: {
|
|
1292
1496
|
left: r.left - s,
|
|
1293
1497
|
top: r.top,
|
|
@@ -1301,7 +1505,7 @@ function Jr({ editor: e, messages: t = Or, selectionSnapshot: n, onRewriteSelect
|
|
|
1301
1505
|
height: i.height
|
|
1302
1506
|
},
|
|
1303
1507
|
boundaryPadding: o.boundaryPadding
|
|
1304
|
-
}), l =
|
|
1508
|
+
}), l = it({
|
|
1305
1509
|
frameRect: {
|
|
1306
1510
|
left: i.left,
|
|
1307
1511
|
top: i.top,
|
|
@@ -1320,16 +1524,16 @@ function Jr({ editor: e, messages: t = Or, selectionSnapshot: n, onRewriteSelect
|
|
|
1320
1524
|
e.view.dom,
|
|
1321
1525
|
o.boundaryPadding,
|
|
1322
1526
|
o.offset
|
|
1323
|
-
]),
|
|
1527
|
+
]), P = B(() => {
|
|
1324
1528
|
D.current && (D.current.style.visibility = "hidden", D.current.style.opacity = "0");
|
|
1529
|
+
}, []), te = B(() => {
|
|
1530
|
+
N();
|
|
1531
|
+
}, [N]), F = B(() => ai(e), [e]), I = B((e) => {
|
|
1532
|
+
k.current = e;
|
|
1325
1533
|
}, []), ne = B(() => {
|
|
1326
|
-
|
|
1327
|
-
}, [M]), P = B(() => Gr(e), [e]), F = B((e) => {
|
|
1328
|
-
ee.current = e;
|
|
1329
|
-
}, []), I = B(() => {
|
|
1330
|
-
let t = D.current, n = ee.current, r = e.view.dom.closest(".markweave-editor-frame");
|
|
1534
|
+
let t = D.current, n = k.current, r = e.view.dom.closest(".markweave-editor-frame");
|
|
1331
1535
|
if (!f || !t || !n) return;
|
|
1332
|
-
let i = t.getBoundingClientRect(), a = n.getBoundingClientRect(), s = r?.getBoundingClientRect() ?? null, c =
|
|
1536
|
+
let i = t.getBoundingClientRect(), a = n.getBoundingClientRect(), s = r?.getBoundingClientRect() ?? null, c = rt({
|
|
1333
1537
|
toolbarRect: i,
|
|
1334
1538
|
popoverSize: a,
|
|
1335
1539
|
viewport: {
|
|
@@ -1345,19 +1549,19 @@ function Jr({ editor: e, messages: t = Or, selectionSnapshot: n, onRewriteSelect
|
|
|
1345
1549
|
e.view.dom,
|
|
1346
1550
|
f,
|
|
1347
1551
|
o.boundaryPadding
|
|
1348
|
-
]),
|
|
1349
|
-
|
|
1350
|
-
onShow:
|
|
1351
|
-
onUpdate:
|
|
1552
|
+
]), L = H(() => ({
|
|
1553
|
+
...ot(o, { topBoundaryPadding: S }),
|
|
1554
|
+
onShow: P,
|
|
1555
|
+
onUpdate: te
|
|
1352
1556
|
}), [
|
|
1353
|
-
|
|
1354
|
-
|
|
1557
|
+
P,
|
|
1558
|
+
te,
|
|
1355
1559
|
o,
|
|
1356
1560
|
S
|
|
1357
1561
|
]);
|
|
1358
1562
|
V(() => {
|
|
1359
|
-
let e =
|
|
1360
|
-
s((t) =>
|
|
1563
|
+
let e = Ur();
|
|
1564
|
+
s((t) => ut(t, a, e));
|
|
1361
1565
|
}, [
|
|
1362
1566
|
a.hiddenReason,
|
|
1363
1567
|
a.motionDurationMs,
|
|
@@ -1371,8 +1575,8 @@ function Jr({ editor: e, messages: t = Or, selectionSnapshot: n, onRewriteSelect
|
|
|
1371
1575
|
a.visibility
|
|
1372
1576
|
]), V(() => {
|
|
1373
1577
|
if (o.motionStartedAtMs === null || o.motionDurationMs <= 0) return;
|
|
1374
|
-
let e = Math.max(0, o.motionStartedAtMs + o.motionDurationMs -
|
|
1375
|
-
s((e) =>
|
|
1578
|
+
let e = Math.max(0, o.motionStartedAtMs + o.motionDurationMs - Ur()), t = window.setTimeout(() => {
|
|
1579
|
+
s((e) => et(e, Ur()));
|
|
1376
1580
|
}, e);
|
|
1377
1581
|
return () => {
|
|
1378
1582
|
window.clearTimeout(t);
|
|
@@ -1381,37 +1585,37 @@ function Jr({ editor: e, messages: t = Or, selectionSnapshot: n, onRewriteSelect
|
|
|
1381
1585
|
o.motionDurationMs,
|
|
1382
1586
|
o.motionPhase,
|
|
1383
1587
|
o.motionStartedAtMs
|
|
1384
|
-
]),
|
|
1588
|
+
]), be(() => {
|
|
1385
1589
|
if (o.visibility !== "visible") {
|
|
1386
1590
|
E.current = 0, D.current && (D.current.style.marginLeft = "", D.current.style.visibility = "hidden", D.current.style.opacity = "0"), x(0), C(o.boundaryPadding);
|
|
1387
1591
|
return;
|
|
1388
1592
|
}
|
|
1389
|
-
let e =
|
|
1593
|
+
let e = Sn(N);
|
|
1390
1594
|
return e.schedule(), window.addEventListener("resize", e.schedule), window.addEventListener("scroll", e.schedule, !0), () => {
|
|
1391
1595
|
e.cancel(), window.removeEventListener("resize", e.schedule), window.removeEventListener("scroll", e.schedule, !0);
|
|
1392
1596
|
};
|
|
1393
1597
|
}, [
|
|
1394
|
-
|
|
1598
|
+
N,
|
|
1395
1599
|
e.view.dom,
|
|
1396
1600
|
f,
|
|
1397
1601
|
n?.from,
|
|
1398
1602
|
n?.to,
|
|
1399
1603
|
o.variant,
|
|
1400
1604
|
o.visibility,
|
|
1401
|
-
|
|
1402
|
-
]),
|
|
1605
|
+
j.length
|
|
1606
|
+
]), be(() => {
|
|
1403
1607
|
if (!f) return;
|
|
1404
|
-
let e =
|
|
1608
|
+
let e = Sn(ne);
|
|
1405
1609
|
return e.schedule(), window.addEventListener("resize", e.schedule), window.addEventListener("scroll", e.schedule, !0), () => {
|
|
1406
1610
|
e.cancel(), window.removeEventListener("resize", e.schedule), window.removeEventListener("scroll", e.schedule, !0);
|
|
1407
1611
|
};
|
|
1408
|
-
}, [f,
|
|
1409
|
-
f === "more" && i.some((e) => e.id === c) ||
|
|
1612
|
+
}, [f, ne]), V(() => {
|
|
1613
|
+
f === "more" && i.some((e) => e.id === c) || j.some((e) => e.id === c) || (l(null), d(null));
|
|
1410
1614
|
}, [
|
|
1411
1615
|
i,
|
|
1412
1616
|
f,
|
|
1413
1617
|
c,
|
|
1414
|
-
|
|
1618
|
+
j
|
|
1415
1619
|
]), V(() => {
|
|
1416
1620
|
if (!f) return;
|
|
1417
1621
|
let t = (e) => {
|
|
@@ -1425,15 +1629,15 @@ function Jr({ editor: e, messages: t = Or, selectionSnapshot: n, onRewriteSelect
|
|
|
1425
1629
|
}, [e, f]), V(() => {
|
|
1426
1630
|
if (f !== "link") return;
|
|
1427
1631
|
let e = window.requestAnimationFrame(() => {
|
|
1428
|
-
|
|
1632
|
+
A.current?.focus(), A.current?.select();
|
|
1429
1633
|
});
|
|
1430
1634
|
return () => window.cancelAnimationFrame(e);
|
|
1431
1635
|
}, [f]);
|
|
1432
|
-
let
|
|
1433
|
-
if (
|
|
1636
|
+
let re = (t) => {
|
|
1637
|
+
if (oi(t.id)) {
|
|
1434
1638
|
let n = t.id;
|
|
1435
1639
|
if (n === "link") {
|
|
1436
|
-
let t =
|
|
1640
|
+
let t = Dn(e);
|
|
1437
1641
|
h(t), _(t), y({
|
|
1438
1642
|
from: Math.min(e.state.selection.from, e.state.selection.to),
|
|
1439
1643
|
to: Math.max(e.state.selection.from, e.state.selection.to)
|
|
@@ -1443,23 +1647,23 @@ function Jr({ editor: e, messages: t = Or, selectionSnapshot: n, onRewriteSelect
|
|
|
1443
1647
|
return;
|
|
1444
1648
|
}
|
|
1445
1649
|
if (p(null), t.id === "improve") {
|
|
1446
|
-
|
|
1650
|
+
si(e, "rewrite-selection", r);
|
|
1447
1651
|
return;
|
|
1448
1652
|
}
|
|
1449
1653
|
t.run(), e.commands.focus();
|
|
1450
1654
|
}, R = () => {
|
|
1451
1655
|
p(null), e.commands.focus();
|
|
1452
|
-
},
|
|
1656
|
+
}, z = () => {
|
|
1453
1657
|
v && e.commands.setTextSelection(v);
|
|
1658
|
+
}, ie = () => {
|
|
1659
|
+
z(), Cn(e, m) && R();
|
|
1454
1660
|
}, ae = () => {
|
|
1455
|
-
|
|
1456
|
-
}, oe = () => {
|
|
1457
|
-
if (ie(), An(e)) {
|
|
1661
|
+
if (z(), Ln(e)) {
|
|
1458
1662
|
h(""), _(""), R();
|
|
1459
1663
|
return;
|
|
1460
1664
|
}
|
|
1461
1665
|
m.trim() && h("");
|
|
1462
|
-
},
|
|
1666
|
+
}, oe = (e, t) => {
|
|
1463
1667
|
if (l(e), !e || !t || !O.current) {
|
|
1464
1668
|
d(null);
|
|
1465
1669
|
return;
|
|
@@ -1467,82 +1671,82 @@ function Jr({ editor: e, messages: t = Or, selectionSnapshot: n, onRewriteSelect
|
|
|
1467
1671
|
let n = t.getBoundingClientRect(), r = O.current.getBoundingClientRect();
|
|
1468
1672
|
d(n.left + n.width / 2 - r.left);
|
|
1469
1673
|
};
|
|
1470
|
-
return /* @__PURE__ */ Z(
|
|
1674
|
+
return /* @__PURE__ */ Z(xn, {
|
|
1471
1675
|
ref: D,
|
|
1472
1676
|
editor: e,
|
|
1473
1677
|
className: `markweave-floating-toolbar markweave-floating-toolbar--${o.variant} markweave-floating-toolbar--motion-${o.motionPhase}`,
|
|
1474
1678
|
"data-motion": o.motionPhase,
|
|
1475
|
-
"data-position-strategy":
|
|
1679
|
+
"data-position-strategy": L.strategy,
|
|
1476
1680
|
"data-boundary-padding": o.boundaryPadding,
|
|
1477
1681
|
"data-popover-placement": f ? w : void 0,
|
|
1478
1682
|
"data-testid": "markweave-floating-toolbar",
|
|
1479
|
-
style:
|
|
1683
|
+
style: Wr(o, b),
|
|
1480
1684
|
updateDelay: 0,
|
|
1481
|
-
getReferencedVirtualElement:
|
|
1482
|
-
options:
|
|
1483
|
-
shouldShow: ({ editor: e }) => e.isEditable &&
|
|
1685
|
+
getReferencedVirtualElement: F,
|
|
1686
|
+
options: L,
|
|
1687
|
+
shouldShow: ({ editor: e }) => e.isEditable && lt(at(e)),
|
|
1484
1688
|
children: /* @__PURE__ */ Q("div", {
|
|
1485
1689
|
ref: O,
|
|
1486
1690
|
className: "markweave-floating-toolbar-content",
|
|
1487
1691
|
"data-menu": f ?? "none",
|
|
1488
1692
|
children: [
|
|
1489
|
-
|
|
1693
|
+
j.map((e, t) => /* @__PURE__ */ Z(ui, {
|
|
1490
1694
|
button: e,
|
|
1491
1695
|
expanded: f === e.id,
|
|
1492
|
-
showDivider: t > 0 &&
|
|
1696
|
+
showDivider: t > 0 && j[t - 1].group !== e.group,
|
|
1493
1697
|
tooltipActive: c === e.id,
|
|
1494
|
-
onPointerDown:
|
|
1495
|
-
onTooltipChange:
|
|
1496
|
-
onRun:
|
|
1698
|
+
onPointerDown: In,
|
|
1699
|
+
onTooltipChange: oe,
|
|
1700
|
+
onRun: re
|
|
1497
1701
|
}, e.id)),
|
|
1498
|
-
f === "block-type" ? /* @__PURE__ */ Z(
|
|
1702
|
+
f === "block-type" ? /* @__PURE__ */ Z(fi, {
|
|
1499
1703
|
editor: e,
|
|
1500
1704
|
messages: t,
|
|
1501
|
-
onPopoverRef:
|
|
1705
|
+
onPopoverRef: I,
|
|
1502
1706
|
onClose: () => p(null)
|
|
1503
1707
|
}) : null,
|
|
1504
|
-
f === "link" ? /* @__PURE__ */ Z(
|
|
1505
|
-
inputRef:
|
|
1708
|
+
f === "link" ? /* @__PURE__ */ Z(li, {
|
|
1709
|
+
inputRef: A,
|
|
1506
1710
|
messages: t,
|
|
1507
1711
|
value: m,
|
|
1508
|
-
canApply: !!
|
|
1509
|
-
canOpen: !!
|
|
1712
|
+
canApply: !!ee,
|
|
1713
|
+
canOpen: !!ee,
|
|
1510
1714
|
canRemove: !!(g || m.trim()),
|
|
1511
1715
|
onValueChange: h,
|
|
1512
|
-
onApply:
|
|
1513
|
-
onOpen: () =>
|
|
1514
|
-
onRemove:
|
|
1515
|
-
onPopoverRef:
|
|
1716
|
+
onApply: ie,
|
|
1717
|
+
onOpen: () => Fn(m),
|
|
1718
|
+
onRemove: ae,
|
|
1719
|
+
onPopoverRef: I
|
|
1516
1720
|
}) : null,
|
|
1517
|
-
f === "color" ? /* @__PURE__ */ Z(
|
|
1721
|
+
f === "color" ? /* @__PURE__ */ Z(mi, {
|
|
1518
1722
|
editor: e,
|
|
1519
1723
|
messages: t,
|
|
1520
|
-
onPopoverRef:
|
|
1724
|
+
onPopoverRef: I,
|
|
1521
1725
|
onClose: () => p(null)
|
|
1522
1726
|
}) : null,
|
|
1523
|
-
f === "more" ? /* @__PURE__ */ Z(
|
|
1727
|
+
f === "more" ? /* @__PURE__ */ Z(gi, {
|
|
1524
1728
|
editor: e,
|
|
1525
1729
|
messages: t,
|
|
1526
1730
|
activeTooltipId: c,
|
|
1527
|
-
onPopoverRef:
|
|
1731
|
+
onPopoverRef: I,
|
|
1528
1732
|
onTooltipChange: l,
|
|
1529
1733
|
onClose: () => p(null)
|
|
1530
1734
|
}) : null,
|
|
1531
|
-
|
|
1735
|
+
M && f === null ? /* @__PURE__ */ Z("div", {
|
|
1532
1736
|
className: "markweave-floating-toolbar-tooltip",
|
|
1533
1737
|
role: "tooltip",
|
|
1534
1738
|
"data-testid": "markweave-floating-toolbar-tooltip",
|
|
1535
|
-
"data-button-id":
|
|
1536
|
-
"data-active":
|
|
1537
|
-
style:
|
|
1538
|
-
children:
|
|
1739
|
+
"data-button-id": M.buttonId,
|
|
1740
|
+
"data-active": M.active,
|
|
1741
|
+
style: Kr(u),
|
|
1742
|
+
children: M.label
|
|
1539
1743
|
}) : null
|
|
1540
1744
|
]
|
|
1541
1745
|
})
|
|
1542
1746
|
});
|
|
1543
1747
|
}
|
|
1544
|
-
function
|
|
1545
|
-
let d =
|
|
1748
|
+
function li({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRemove: a, onValueChange: o, onApply: s, onOpen: c, onRemove: l, onPopoverRef: u }) {
|
|
1749
|
+
let d = On(t);
|
|
1546
1750
|
return /* @__PURE__ */ Q("form", {
|
|
1547
1751
|
ref: u,
|
|
1548
1752
|
className: "markweave-floating-toolbar-popover markweave-floating-toolbar-link-popover",
|
|
@@ -1565,7 +1769,7 @@ function Yr({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRe
|
|
|
1565
1769
|
"aria-label": d.applyLink,
|
|
1566
1770
|
"data-testid": "markweave-floating-toolbar-link-apply",
|
|
1567
1771
|
disabled: !r,
|
|
1568
|
-
onMouseDown:
|
|
1772
|
+
onMouseDown: In,
|
|
1569
1773
|
children: /* @__PURE__ */ Z($, { name: "corner-down-left" })
|
|
1570
1774
|
}),
|
|
1571
1775
|
/* @__PURE__ */ Z("span", {
|
|
@@ -1577,7 +1781,7 @@ function Yr({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRe
|
|
|
1577
1781
|
"aria-label": d.openLink,
|
|
1578
1782
|
"data-testid": "markweave-floating-toolbar-link-open",
|
|
1579
1783
|
disabled: !i,
|
|
1580
|
-
onMouseDown:
|
|
1784
|
+
onMouseDown: In,
|
|
1581
1785
|
onClick: c,
|
|
1582
1786
|
children: /* @__PURE__ */ Z($, { name: "external-link" })
|
|
1583
1787
|
}),
|
|
@@ -1586,7 +1790,7 @@ function Yr({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRe
|
|
|
1586
1790
|
"aria-label": d.removeLink,
|
|
1587
1791
|
"data-testid": "markweave-floating-toolbar-link-remove",
|
|
1588
1792
|
disabled: !a,
|
|
1589
|
-
onMouseDown:
|
|
1793
|
+
onMouseDown: In,
|
|
1590
1794
|
onClick: l,
|
|
1591
1795
|
children: /* @__PURE__ */ Z($, { name: "trash" })
|
|
1592
1796
|
})
|
|
@@ -1594,7 +1798,7 @@ function Yr({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRe
|
|
|
1594
1798
|
})]
|
|
1595
1799
|
});
|
|
1596
1800
|
}
|
|
1597
|
-
function
|
|
1801
|
+
function ui({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointerDown: i, onTooltipChange: a, onRun: o }) {
|
|
1598
1802
|
return /* @__PURE__ */ Q(X, { children: [n ? /* @__PURE__ */ Z("span", {
|
|
1599
1803
|
className: "markweave-floating-toolbar-divider",
|
|
1600
1804
|
"aria-hidden": "true"
|
|
@@ -1602,7 +1806,7 @@ function Xr({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointe
|
|
|
1602
1806
|
type: "button",
|
|
1603
1807
|
className: `markweave-floating-toolbar-button markweave-floating-toolbar-button--${e.id}`,
|
|
1604
1808
|
"aria-label": e.label,
|
|
1605
|
-
"aria-expanded":
|
|
1809
|
+
"aria-expanded": oi(e.id) ? t : void 0,
|
|
1606
1810
|
"data-active": e.active || t,
|
|
1607
1811
|
"data-tooltip-active": r ? "true" : "false",
|
|
1608
1812
|
"data-testid": `markweave-floating-toolbar-button-${e.id}`,
|
|
@@ -1612,13 +1816,13 @@ function Xr({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointe
|
|
|
1612
1816
|
onMouseEnter: (t) => a(e.id, t.currentTarget),
|
|
1613
1817
|
onMouseLeave: () => a(null),
|
|
1614
1818
|
onClick: () => o(e),
|
|
1615
|
-
children: /* @__PURE__ */ Z(
|
|
1819
|
+
children: /* @__PURE__ */ Z(di, {
|
|
1616
1820
|
button: e,
|
|
1617
1821
|
expanded: t
|
|
1618
1822
|
})
|
|
1619
1823
|
})] });
|
|
1620
1824
|
}
|
|
1621
|
-
function
|
|
1825
|
+
function di({ button: e, expanded: t }) {
|
|
1622
1826
|
return e.id === "improve" ? /* @__PURE__ */ Q("span", {
|
|
1623
1827
|
className: "markweave-floating-toolbar-button-inner",
|
|
1624
1828
|
children: [/* @__PURE__ */ Z($, { name: "sparkles" }), /* @__PURE__ */ Z("span", { children: e.glyph })]
|
|
@@ -1636,8 +1840,8 @@ function Zr({ button: e, expanded: t }) {
|
|
|
1636
1840
|
}), /* @__PURE__ */ Z($, { name: t ? "chevron-up" : "chevron-down" })]
|
|
1637
1841
|
}) : /* @__PURE__ */ Z($, { name: "more" });
|
|
1638
1842
|
}
|
|
1639
|
-
function
|
|
1640
|
-
let i =
|
|
1843
|
+
function fi({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
|
|
1844
|
+
let i = On(t), a = Mn(t);
|
|
1641
1845
|
return /* @__PURE__ */ Q("div", {
|
|
1642
1846
|
ref: n,
|
|
1643
1847
|
className: "markweave-floating-toolbar-popover markweave-floating-toolbar-turn-menu",
|
|
@@ -1647,48 +1851,48 @@ function Qr({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
|
|
|
1647
1851
|
children: i.turnIntoTitle
|
|
1648
1852
|
}), a.map((t) => /* @__PURE__ */ Q("button", {
|
|
1649
1853
|
type: "button",
|
|
1650
|
-
"data-active":
|
|
1854
|
+
"data-active": Pn(e, t.id),
|
|
1651
1855
|
"data-testid": `markweave-floating-toolbar-turn-${t.id}`,
|
|
1652
|
-
onMouseDown:
|
|
1856
|
+
onMouseDown: In,
|
|
1653
1857
|
onClick: () => {
|
|
1654
|
-
|
|
1858
|
+
Vn(e, t.id), r();
|
|
1655
1859
|
},
|
|
1656
1860
|
children: [/* @__PURE__ */ Z("span", {
|
|
1657
1861
|
className: "markweave-floating-toolbar-menu-icon",
|
|
1658
|
-
children: /* @__PURE__ */ Z(
|
|
1862
|
+
children: /* @__PURE__ */ Z(pi, { option: t })
|
|
1659
1863
|
}), /* @__PURE__ */ Z("span", { children: t.label })]
|
|
1660
1864
|
}, t.id))]
|
|
1661
1865
|
});
|
|
1662
1866
|
}
|
|
1663
|
-
function
|
|
1867
|
+
function pi({ option: e }) {
|
|
1664
1868
|
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 });
|
|
1665
1869
|
}
|
|
1666
|
-
function
|
|
1667
|
-
let i =
|
|
1870
|
+
function mi({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
|
|
1871
|
+
let i = On(t), a = e.getAttributes("textStyle").color, o = e.getAttributes("highlight").color;
|
|
1668
1872
|
return /* @__PURE__ */ Q("div", {
|
|
1669
1873
|
ref: n,
|
|
1670
1874
|
className: "markweave-floating-toolbar-popover markweave-floating-toolbar-color-popover",
|
|
1671
1875
|
"data-testid": "markweave-floating-toolbar-color-menu",
|
|
1672
|
-
children: [/* @__PURE__ */ Z(
|
|
1876
|
+
children: [/* @__PURE__ */ Z(hi, {
|
|
1673
1877
|
title: i.textColorTitle,
|
|
1674
1878
|
mode: "text",
|
|
1675
1879
|
activeColor: a ?? null,
|
|
1676
|
-
options:
|
|
1880
|
+
options: An(t),
|
|
1677
1881
|
onSelect: (t) => {
|
|
1678
|
-
|
|
1882
|
+
Bn(e, t), r();
|
|
1679
1883
|
}
|
|
1680
|
-
}), /* @__PURE__ */ Z(
|
|
1884
|
+
}), /* @__PURE__ */ Z(hi, {
|
|
1681
1885
|
title: i.highlightColorTitle,
|
|
1682
1886
|
mode: "highlight",
|
|
1683
1887
|
activeColor: o ?? null,
|
|
1684
|
-
options:
|
|
1888
|
+
options: En(t),
|
|
1685
1889
|
onSelect: (t) => {
|
|
1686
|
-
|
|
1890
|
+
zn(e, t), r();
|
|
1687
1891
|
}
|
|
1688
1892
|
})]
|
|
1689
1893
|
});
|
|
1690
1894
|
}
|
|
1691
|
-
function
|
|
1895
|
+
function hi({ title: e, mode: t, activeColor: n, options: r, onSelect: i }) {
|
|
1692
1896
|
return /* @__PURE__ */ Q("section", {
|
|
1693
1897
|
className: "markweave-floating-toolbar-color-section",
|
|
1694
1898
|
"aria-label": e,
|
|
@@ -1702,7 +1906,7 @@ function ti({ title: e, mode: t, activeColor: n, options: r, onSelect: i }) {
|
|
|
1702
1906
|
"aria-label": e.label,
|
|
1703
1907
|
"data-active": e.value === n || e.value === null && !n,
|
|
1704
1908
|
"data-testid": `markweave-floating-toolbar-${t}-${e.id}`,
|
|
1705
|
-
onMouseDown:
|
|
1909
|
+
onMouseDown: In,
|
|
1706
1910
|
onClick: () => i(e.value),
|
|
1707
1911
|
children: t === "text" ? /* @__PURE__ */ Z("span", {
|
|
1708
1912
|
className: "markweave-floating-toolbar-text-swatch",
|
|
@@ -1717,25 +1921,25 @@ function ti({ title: e, mode: t, activeColor: n, options: r, onSelect: i }) {
|
|
|
1717
1921
|
})]
|
|
1718
1922
|
});
|
|
1719
1923
|
}
|
|
1720
|
-
function
|
|
1721
|
-
let o =
|
|
1924
|
+
function gi({ editor: e, messages: t, activeTooltipId: n, onPopoverRef: r, onTooltipChange: i, onClose: a }) {
|
|
1925
|
+
let o = kn(t);
|
|
1722
1926
|
return /* @__PURE__ */ Z("div", {
|
|
1723
1927
|
ref: r,
|
|
1724
1928
|
className: "markweave-floating-toolbar-popover markweave-floating-toolbar-more-menu",
|
|
1725
1929
|
"data-testid": "markweave-floating-toolbar-more-menu",
|
|
1726
|
-
children: o.map((t, r) => /* @__PURE__ */ Z(
|
|
1930
|
+
children: o.map((t, r) => /* @__PURE__ */ Z(_i, {
|
|
1727
1931
|
action: t,
|
|
1728
|
-
active:
|
|
1932
|
+
active: Nn(e, t.id),
|
|
1729
1933
|
tooltipActive: n === t.id,
|
|
1730
1934
|
showDivider: r > 0 && o[r - 1].group !== t.group,
|
|
1731
1935
|
onTooltipChange: i,
|
|
1732
1936
|
onRun: () => {
|
|
1733
|
-
|
|
1937
|
+
Rn(e, t.id), a();
|
|
1734
1938
|
}
|
|
1735
1939
|
}, t.id))
|
|
1736
1940
|
});
|
|
1737
1941
|
}
|
|
1738
|
-
function
|
|
1942
|
+
function _i({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipChange: i, onRun: a }) {
|
|
1739
1943
|
return /* @__PURE__ */ Q(X, { children: [r ? /* @__PURE__ */ Z("span", {
|
|
1740
1944
|
className: "markweave-floating-toolbar-divider",
|
|
1741
1945
|
"aria-hidden": "true"
|
|
@@ -1747,11 +1951,11 @@ function ri({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipC
|
|
|
1747
1951
|
"data-active": t,
|
|
1748
1952
|
"data-tooltip-active": n ? "true" : "false",
|
|
1749
1953
|
"data-testid": `markweave-floating-toolbar-more-${e.id}`,
|
|
1750
|
-
onMouseDown:
|
|
1954
|
+
onMouseDown: In,
|
|
1751
1955
|
onMouseEnter: () => i(e.id),
|
|
1752
1956
|
onMouseLeave: () => i(null),
|
|
1753
1957
|
onClick: a,
|
|
1754
|
-
children: /* @__PURE__ */ Z(
|
|
1958
|
+
children: /* @__PURE__ */ Z(vi, { id: e.id })
|
|
1755
1959
|
}), n ? /* @__PURE__ */ Z("div", {
|
|
1756
1960
|
className: "markweave-floating-toolbar-tooltip markweave-floating-toolbar-tooltip--more",
|
|
1757
1961
|
role: "tooltip",
|
|
@@ -1759,41 +1963,41 @@ function ri({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipC
|
|
|
1759
1963
|
}) : null]
|
|
1760
1964
|
})] });
|
|
1761
1965
|
}
|
|
1762
|
-
function
|
|
1966
|
+
function vi({ id: e }) {
|
|
1763
1967
|
return e === "superscript" ? /* @__PURE__ */ Z($, { name: "superscript" }) : e === "subscript" ? /* @__PURE__ */ Z($, { name: "subscript" }) : e === "inline-math" ? /* @__PURE__ */ Z($, { name: "math" }) : Z($, { name: e });
|
|
1764
1968
|
}
|
|
1765
|
-
var
|
|
1766
|
-
sparkles:
|
|
1767
|
-
"chevron-down":
|
|
1768
|
-
"chevron-up":
|
|
1769
|
-
"corner-down-left":
|
|
1770
|
-
"external-link":
|
|
1771
|
-
bold:
|
|
1772
|
-
italic:
|
|
1773
|
-
underline:
|
|
1774
|
-
strike:
|
|
1775
|
-
"inline-code":
|
|
1776
|
-
link:
|
|
1777
|
-
more:
|
|
1778
|
-
text:
|
|
1779
|
-
"bullet-list":
|
|
1780
|
-
"numbered-list":
|
|
1781
|
-
"todo-list":
|
|
1782
|
-
quote:
|
|
1783
|
-
"code-block":
|
|
1784
|
-
superscript:
|
|
1785
|
-
subscript:
|
|
1786
|
-
math:
|
|
1787
|
-
"align-left":
|
|
1788
|
-
"align-center":
|
|
1789
|
-
"align-right":
|
|
1790
|
-
"align-justify":
|
|
1791
|
-
"decrease-indent":
|
|
1969
|
+
var yi = {
|
|
1970
|
+
sparkles: le,
|
|
1971
|
+
"chevron-down": v,
|
|
1972
|
+
"chevron-up": y,
|
|
1973
|
+
"corner-down-left": C,
|
|
1974
|
+
"external-link": T,
|
|
1975
|
+
bold: p,
|
|
1976
|
+
italic: P,
|
|
1977
|
+
underline: _e,
|
|
1978
|
+
strike: ue,
|
|
1979
|
+
"inline-code": x,
|
|
1980
|
+
link: F,
|
|
1981
|
+
more: R,
|
|
1982
|
+
text: ge,
|
|
1983
|
+
"bullet-list": I,
|
|
1984
|
+
"numbered-list": L,
|
|
1985
|
+
"todo-list": ne,
|
|
1986
|
+
quote: ae,
|
|
1987
|
+
"code-block": m,
|
|
1988
|
+
superscript: fe,
|
|
1989
|
+
subscript: de,
|
|
1990
|
+
math: se,
|
|
1991
|
+
"align-left": d,
|
|
1992
|
+
"align-center": l,
|
|
1993
|
+
"align-right": f,
|
|
1994
|
+
"align-justify": u,
|
|
1995
|
+
"decrease-indent": M,
|
|
1792
1996
|
"increase-indent": ee,
|
|
1793
|
-
trash:
|
|
1997
|
+
trash: he
|
|
1794
1998
|
};
|
|
1795
1999
|
function $({ name: e }) {
|
|
1796
|
-
let t =
|
|
2000
|
+
let t = yi[e];
|
|
1797
2001
|
return /* @__PURE__ */ Z(t, {
|
|
1798
2002
|
"aria-hidden": "true",
|
|
1799
2003
|
absoluteStrokeWidth: !0,
|
|
@@ -1803,24 +2007,24 @@ function $({ name: e }) {
|
|
|
1803
2007
|
}
|
|
1804
2008
|
//#endregion
|
|
1805
2009
|
//#region src/ui/math/MathEditorPopover.tsx
|
|
1806
|
-
function
|
|
1807
|
-
let i = U(null), a = U(null), [o, s] = W(r.latex), [c, l] = W(null), u = t.math, d = H(() =>
|
|
2010
|
+
function bi({ editor: e, messages: t, onClose: n, target: r }) {
|
|
2011
|
+
let i = U(null), a = U(null), [o, s] = W(r.latex), [c, l] = W(null), u = t.math, d = H(() => Dt(e, r) ?? 1, [e, r]), f = H(() => Ot(e, r), [e, r]), p = H(() => o === r.latex && f ? {
|
|
1808
2012
|
html: f,
|
|
1809
2013
|
error: !1
|
|
1810
|
-
} :
|
|
2014
|
+
} : Mt(o, r.kind, e), [
|
|
1811
2015
|
e,
|
|
1812
2016
|
f,
|
|
1813
2017
|
r.kind,
|
|
1814
2018
|
r.latex,
|
|
1815
2019
|
o
|
|
1816
|
-
]),
|
|
2020
|
+
]), m = o.trim().length > 0, h = B(() => {
|
|
1817
2021
|
if (typeof window > "u") return;
|
|
1818
|
-
let t =
|
|
2022
|
+
let t = Et(e, r), i = e.view.dom.closest(".markweave-editor-frame")?.getBoundingClientRect();
|
|
1819
2023
|
if (!t || !i) {
|
|
1820
2024
|
n();
|
|
1821
2025
|
return;
|
|
1822
2026
|
}
|
|
1823
|
-
l(
|
|
2027
|
+
l(Tt({
|
|
1824
2028
|
anchorRect: t,
|
|
1825
2029
|
frameRect: i,
|
|
1826
2030
|
kind: r.kind,
|
|
@@ -1837,18 +2041,18 @@ function oi({ editor: e, messages: t, onClose: n, target: r }) {
|
|
|
1837
2041
|
V(() => {
|
|
1838
2042
|
s(r.latex);
|
|
1839
2043
|
}, [r.latex, r.pos]), V(() => {
|
|
1840
|
-
|
|
2044
|
+
Nt(e, r, !0), h();
|
|
1841
2045
|
let t = window.requestAnimationFrame(() => {
|
|
1842
|
-
a.current?.focus({ preventScroll: !0 }), a.current?.select(),
|
|
2046
|
+
a.current?.focus({ preventScroll: !0 }), a.current?.select(), h();
|
|
1843
2047
|
});
|
|
1844
|
-
return window.addEventListener("resize",
|
|
1845
|
-
window.cancelAnimationFrame(t), window.removeEventListener("resize",
|
|
2048
|
+
return window.addEventListener("resize", h), window.addEventListener("scroll", h, !0), () => {
|
|
2049
|
+
window.cancelAnimationFrame(t), window.removeEventListener("resize", h), window.removeEventListener("scroll", h, !0), Nt(e, r, !1);
|
|
1846
2050
|
};
|
|
1847
2051
|
}, [
|
|
1848
2052
|
e,
|
|
1849
2053
|
n,
|
|
1850
2054
|
r,
|
|
1851
|
-
|
|
2055
|
+
h
|
|
1852
2056
|
]), V(() => {
|
|
1853
2057
|
let e = (e) => {
|
|
1854
2058
|
let t = e.target;
|
|
@@ -1857,27 +2061,27 @@ function oi({ editor: e, messages: t, onClose: n, target: r }) {
|
|
|
1857
2061
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
1858
2062
|
}, [n]);
|
|
1859
2063
|
let _ = B(() => {
|
|
1860
|
-
|
|
2064
|
+
m && wt(e, r, o) && n();
|
|
1861
2065
|
}, [
|
|
1862
|
-
|
|
2066
|
+
m,
|
|
1863
2067
|
e,
|
|
1864
2068
|
n,
|
|
1865
2069
|
r,
|
|
1866
2070
|
o
|
|
1867
|
-
]),
|
|
2071
|
+
]), v = (t) => {
|
|
1868
2072
|
if (t.key === "Escape") {
|
|
1869
2073
|
t.preventDefault(), n(), e.commands.focus();
|
|
1870
2074
|
return;
|
|
1871
2075
|
}
|
|
1872
2076
|
t.key === "Enter" && (r.kind === "inline" || t.metaKey || t.ctrlKey) && (t.preventDefault(), _());
|
|
1873
|
-
},
|
|
2077
|
+
}, y = c ? {
|
|
1874
2078
|
left: c.left,
|
|
1875
2079
|
top: c.top,
|
|
1876
2080
|
width: c.width
|
|
1877
|
-
} : void 0,
|
|
2081
|
+
} : void 0, b = r.kind === "block" ? u.blockTitle : u.inlineTitle;
|
|
1878
2082
|
return r.kind === "inline" ? /* @__PURE__ */ Q("form", {
|
|
1879
2083
|
ref: i,
|
|
1880
|
-
"aria-label":
|
|
2084
|
+
"aria-label": b,
|
|
1881
2085
|
className: "markweave-math-editor-popover markweave-math-editor-popover--inline",
|
|
1882
2086
|
"data-kind": "inline",
|
|
1883
2087
|
"data-placement": c?.placement ?? "bottom",
|
|
@@ -1885,7 +2089,7 @@ function oi({ editor: e, messages: t, onClose: n, target: r }) {
|
|
|
1885
2089
|
onSubmit: (e) => {
|
|
1886
2090
|
e.preventDefault(), _();
|
|
1887
2091
|
},
|
|
1888
|
-
style:
|
|
2092
|
+
style: y,
|
|
1889
2093
|
children: [/* @__PURE__ */ Q("label", {
|
|
1890
2094
|
className: "markweave-math-inline-source",
|
|
1891
2095
|
"data-testid": "markweave-math-inline-source",
|
|
@@ -1899,7 +2103,7 @@ function oi({ editor: e, messages: t, onClose: n, target: r }) {
|
|
|
1899
2103
|
"aria-label": u.latexLabel,
|
|
1900
2104
|
"data-testid": "markweave-math-editor-input",
|
|
1901
2105
|
onChange: (e) => s(e.currentTarget.value),
|
|
1902
|
-
onKeyDown:
|
|
2106
|
+
onKeyDown: v,
|
|
1903
2107
|
placeholder: u.latexPlaceholder,
|
|
1904
2108
|
size: Math.max(o.length, 1),
|
|
1905
2109
|
spellCheck: !1,
|
|
@@ -1912,13 +2116,13 @@ function oi({ editor: e, messages: t, onClose: n, target: r }) {
|
|
|
1912
2116
|
]
|
|
1913
2117
|
}), /* @__PURE__ */ Q("div", {
|
|
1914
2118
|
className: "markweave-math-inline-preview",
|
|
1915
|
-
"data-error":
|
|
2119
|
+
"data-error": p.error ? "true" : "false",
|
|
1916
2120
|
"data-testid": "markweave-math-editor-preview",
|
|
1917
|
-
children: [/* @__PURE__ */ Z("div", { dangerouslySetInnerHTML: { __html:
|
|
2121
|
+
children: [/* @__PURE__ */ Z("div", { dangerouslySetInnerHTML: { __html: p.html || " " } }), p.error ? /* @__PURE__ */ Z("small", { children: u.invalidPreview }) : null]
|
|
1918
2122
|
})]
|
|
1919
2123
|
}) : /* @__PURE__ */ Q("form", {
|
|
1920
2124
|
ref: i,
|
|
1921
|
-
"aria-label":
|
|
2125
|
+
"aria-label": b,
|
|
1922
2126
|
className: "markweave-math-editor-popover markweave-math-editor-popover--block",
|
|
1923
2127
|
"data-kind": r.kind,
|
|
1924
2128
|
"data-placement": c?.placement ?? "bottom",
|
|
@@ -1926,13 +2130,13 @@ function oi({ editor: e, messages: t, onClose: n, target: r }) {
|
|
|
1926
2130
|
onSubmit: (e) => {
|
|
1927
2131
|
e.preventDefault(), _();
|
|
1928
2132
|
},
|
|
1929
|
-
style:
|
|
2133
|
+
style: y,
|
|
1930
2134
|
children: [
|
|
1931
2135
|
/* @__PURE__ */ Q("div", {
|
|
1932
2136
|
className: "markweave-math-block-toolbar",
|
|
1933
2137
|
children: [
|
|
1934
2138
|
/* @__PURE__ */ Z("span", { children: u.label }),
|
|
1935
|
-
/* @__PURE__ */ Z(
|
|
2139
|
+
/* @__PURE__ */ Z(x, {
|
|
1936
2140
|
"aria-hidden": "true",
|
|
1937
2141
|
size: 15,
|
|
1938
2142
|
strokeWidth: 1.75
|
|
@@ -1940,10 +2144,10 @@ function oi({ editor: e, messages: t, onClose: n, target: r }) {
|
|
|
1940
2144
|
/* @__PURE__ */ Z("button", {
|
|
1941
2145
|
"aria-label": u.apply,
|
|
1942
2146
|
"data-testid": "markweave-math-editor-apply",
|
|
1943
|
-
disabled: !
|
|
2147
|
+
disabled: !m,
|
|
1944
2148
|
title: u.apply,
|
|
1945
2149
|
type: "submit",
|
|
1946
|
-
children: /* @__PURE__ */ Z(
|
|
2150
|
+
children: /* @__PURE__ */ Z(g, {
|
|
1947
2151
|
"aria-hidden": "true",
|
|
1948
2152
|
size: 16,
|
|
1949
2153
|
strokeWidth: 2
|
|
@@ -1964,7 +2168,7 @@ function oi({ editor: e, messages: t, onClose: n, target: r }) {
|
|
|
1964
2168
|
"aria-label": u.latexLabel,
|
|
1965
2169
|
"data-testid": "markweave-math-editor-input",
|
|
1966
2170
|
onChange: (e) => s(e.currentTarget.value),
|
|
1967
|
-
onKeyDown:
|
|
2171
|
+
onKeyDown: v,
|
|
1968
2172
|
placeholder: u.latexPlaceholder,
|
|
1969
2173
|
rows: 3,
|
|
1970
2174
|
spellCheck: !1,
|
|
@@ -1978,41 +2182,41 @@ function oi({ editor: e, messages: t, onClose: n, target: r }) {
|
|
|
1978
2182
|
}),
|
|
1979
2183
|
/* @__PURE__ */ Q("div", {
|
|
1980
2184
|
className: "markweave-math-block-preview",
|
|
1981
|
-
"data-error":
|
|
2185
|
+
"data-error": p.error ? "true" : "false",
|
|
1982
2186
|
"data-math-number": String(d),
|
|
1983
2187
|
"data-testid": "markweave-math-editor-preview",
|
|
1984
|
-
children: [/* @__PURE__ */ Z("div", { dangerouslySetInnerHTML: { __html:
|
|
2188
|
+
children: [/* @__PURE__ */ Z("div", { dangerouslySetInnerHTML: { __html: p.html || " " } }), p.error ? /* @__PURE__ */ Z("small", { children: u.invalidPreview }) : null]
|
|
1985
2189
|
})
|
|
1986
2190
|
]
|
|
1987
2191
|
});
|
|
1988
2192
|
}
|
|
1989
2193
|
//#endregion
|
|
1990
2194
|
//#region src/ui/slash-command/SlashCommandMenu.tsx
|
|
1991
|
-
var
|
|
1992
|
-
type:
|
|
1993
|
-
"heading-1":
|
|
1994
|
-
"heading-2":
|
|
1995
|
-
"heading-3":
|
|
1996
|
-
"bullet-list":
|
|
1997
|
-
"ordered-list":
|
|
1998
|
-
"task-list":
|
|
1999
|
-
blockquote:
|
|
2000
|
-
"code-block":
|
|
2001
|
-
info:
|
|
2002
|
-
tip:
|
|
2003
|
-
warning:
|
|
2004
|
-
error:
|
|
2005
|
-
success:
|
|
2006
|
-
emoji:
|
|
2007
|
-
math:
|
|
2008
|
-
table:
|
|
2009
|
-
separator:
|
|
2010
|
-
image:
|
|
2011
|
-
video:
|
|
2012
|
-
attachment:
|
|
2195
|
+
var xi = n("zh"), Si = {
|
|
2196
|
+
type: me,
|
|
2197
|
+
"heading-1": D,
|
|
2198
|
+
"heading-2": O,
|
|
2199
|
+
"heading-3": k,
|
|
2200
|
+
"bullet-list": I,
|
|
2201
|
+
"ordered-list": L,
|
|
2202
|
+
"task-list": ne,
|
|
2203
|
+
blockquote: ae,
|
|
2204
|
+
"code-block": m,
|
|
2205
|
+
info: N,
|
|
2206
|
+
tip: te,
|
|
2207
|
+
warning: c,
|
|
2208
|
+
error: b,
|
|
2209
|
+
success: _,
|
|
2210
|
+
emoji: ce,
|
|
2211
|
+
math: se,
|
|
2212
|
+
table: pe,
|
|
2213
|
+
separator: re,
|
|
2214
|
+
image: A,
|
|
2215
|
+
video: ye,
|
|
2216
|
+
attachment: z
|
|
2013
2217
|
};
|
|
2014
|
-
function
|
|
2015
|
-
let t =
|
|
2218
|
+
function Ci({ name: e }) {
|
|
2219
|
+
let t = Si[e];
|
|
2016
2220
|
return /* @__PURE__ */ Z(t, {
|
|
2017
2221
|
"aria-hidden": "true",
|
|
2018
2222
|
absoluteStrokeWidth: !0,
|
|
@@ -2020,8 +2224,8 @@ function li({ name: e }) {
|
|
|
2020
2224
|
strokeWidth: 1.6
|
|
2021
2225
|
});
|
|
2022
2226
|
}
|
|
2023
|
-
function
|
|
2024
|
-
return !
|
|
2227
|
+
function wi(e, t, n) {
|
|
2228
|
+
return !zt(e) || !n ? {
|
|
2025
2229
|
visible: !1,
|
|
2026
2230
|
empty: !1,
|
|
2027
2231
|
activeIndex: -1
|
|
@@ -2035,16 +2239,16 @@ function ui(e, t, n) {
|
|
|
2035
2239
|
activeIndex: Math.min(t.length - 1, Math.max(0, e.activeIndex))
|
|
2036
2240
|
};
|
|
2037
2241
|
}
|
|
2038
|
-
function
|
|
2242
|
+
function Ti(e, t) {
|
|
2039
2243
|
return Object.values(t.slash.groups).map((t) => ({
|
|
2040
2244
|
group: t,
|
|
2041
2245
|
commands: e.filter((e) => e.group === t)
|
|
2042
2246
|
})).filter((e) => e.commands.length > 0);
|
|
2043
2247
|
}
|
|
2044
|
-
function
|
|
2248
|
+
function Ei(e, t) {
|
|
2045
2249
|
return t.slash.uploadKindLabels[e] ?? t.slash.uploadKindLabels.upload;
|
|
2046
2250
|
}
|
|
2047
|
-
function
|
|
2251
|
+
function Di({ command: e, messages: t, onBack: n, onSelect: r }) {
|
|
2048
2252
|
let [i, a] = W(""), [o, s] = W(0), c = H(() => {
|
|
2049
2253
|
let e = i.trim().toLowerCase();
|
|
2050
2254
|
return (e ? t.slash.emojiItems.filter((t) => [
|
|
@@ -2111,9 +2315,9 @@ function pi({ command: e, messages: t, onBack: n, onSelect: r }) {
|
|
|
2111
2315
|
]
|
|
2112
2316
|
});
|
|
2113
2317
|
}
|
|
2114
|
-
function
|
|
2318
|
+
function Oi({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
|
|
2115
2319
|
let a = e.uploadKind ?? "attachment", [o, s] = W(""), [c, l] = W(null), [u, d] = W(null), [f, p] = W(!1), m = async (t) => {
|
|
2116
|
-
r(e, { uploadResult: await
|
|
2320
|
+
r(e, { uploadResult: await Ce({
|
|
2117
2321
|
kind: a,
|
|
2118
2322
|
source: t,
|
|
2119
2323
|
trigger: "slash-command"
|
|
@@ -2133,7 +2337,7 @@ function mi({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
|
|
|
2133
2337
|
d(t.slash.uploadRequiredError);
|
|
2134
2338
|
return;
|
|
2135
2339
|
}
|
|
2136
|
-
await m(
|
|
2340
|
+
await m(xe(o));
|
|
2137
2341
|
} catch (e) {
|
|
2138
2342
|
d(e instanceof Error ? e.message : t.slash.uploadFailedError);
|
|
2139
2343
|
} finally {
|
|
@@ -2151,7 +2355,7 @@ function mi({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
|
|
|
2151
2355
|
onMouseDown: (e) => e.preventDefault(),
|
|
2152
2356
|
onClick: n,
|
|
2153
2357
|
children: t.common.back
|
|
2154
|
-
}), /* @__PURE__ */ Z("span", { children:
|
|
2358
|
+
}), /* @__PURE__ */ Z("span", { children: Ei(a, t) })]
|
|
2155
2359
|
}),
|
|
2156
2360
|
/* @__PURE__ */ Q("label", {
|
|
2157
2361
|
className: "markweave-slash-upload-field",
|
|
@@ -2199,10 +2403,10 @@ function mi({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
|
|
|
2199
2403
|
]
|
|
2200
2404
|
});
|
|
2201
2405
|
}
|
|
2202
|
-
function
|
|
2203
|
-
let l =
|
|
2406
|
+
function ki({ commands: e, messages: t = xi, state: n, position: r, inputCommand: i, onActiveIndexChange: a, onInputCommandChange: o, onSelect: s, onUpload: c }) {
|
|
2407
|
+
let l = wi(n, e, r);
|
|
2204
2408
|
if (!l.visible || !r) return null;
|
|
2205
|
-
let u =
|
|
2409
|
+
let u = Ti(e, t), d = {
|
|
2206
2410
|
left: r.left,
|
|
2207
2411
|
top: r.top,
|
|
2208
2412
|
maxHeight: r.maxHeight,
|
|
@@ -2224,12 +2428,12 @@ function hi({ commands: e, messages: t = si, state: n, position: r, inputCommand
|
|
|
2224
2428
|
"aria-label": t.slash.ariaLabel,
|
|
2225
2429
|
"data-placement": r.placement,
|
|
2226
2430
|
"data-testid": "markweave-slash-menu",
|
|
2227
|
-
children: i?.inputKind === "emoji" ? /* @__PURE__ */ Z(
|
|
2431
|
+
children: i?.inputKind === "emoji" ? /* @__PURE__ */ Z(Di, {
|
|
2228
2432
|
command: i,
|
|
2229
2433
|
messages: t,
|
|
2230
2434
|
onBack: m,
|
|
2231
2435
|
onSelect: s
|
|
2232
|
-
}) : i?.inputKind === "upload" ? /* @__PURE__ */ Z(
|
|
2436
|
+
}) : i?.inputKind === "upload" ? /* @__PURE__ */ Z(Oi, {
|
|
2233
2437
|
command: i,
|
|
2234
2438
|
messages: t,
|
|
2235
2439
|
onBack: m,
|
|
@@ -2249,7 +2453,7 @@ function hi({ commands: e, messages: t = si, state: n, position: r, inputCommand
|
|
|
2249
2453
|
className: "markweave-slash-group-title",
|
|
2250
2454
|
children: t.group
|
|
2251
2455
|
}), t.commands.map((t) => {
|
|
2252
|
-
let n = e.indexOf(t), r = n === l.activeIndex, i =
|
|
2456
|
+
let n = e.indexOf(t), r = n === l.activeIndex, i = Lt(t), o = !!t.disabled;
|
|
2253
2457
|
return /* @__PURE__ */ Q("button", {
|
|
2254
2458
|
type: "button",
|
|
2255
2459
|
role: "option",
|
|
@@ -2273,7 +2477,7 @@ function hi({ commands: e, messages: t = si, state: n, position: r, inputCommand
|
|
|
2273
2477
|
}
|
|
2274
2478
|
},
|
|
2275
2479
|
children: [
|
|
2276
|
-
/* @__PURE__ */ Z(
|
|
2480
|
+
/* @__PURE__ */ Z(Ci, { name: t.icon }),
|
|
2277
2481
|
/* @__PURE__ */ Z("span", { children: t.label }),
|
|
2278
2482
|
o && t.disabledReason ? /* @__PURE__ */ Z("small", { children: t.disabledReason }) : null
|
|
2279
2483
|
]
|
|
@@ -2285,38 +2489,38 @@ function hi({ commands: e, messages: t = si, state: n, position: r, inputCommand
|
|
|
2285
2489
|
}
|
|
2286
2490
|
//#endregion
|
|
2287
2491
|
//#region src/ui/table/TableControls.tsx
|
|
2288
|
-
var
|
|
2289
|
-
function
|
|
2290
|
-
let [s, c] = W(null), [l, u] = W("row-edge"), [d, f] = W(null), [p, m] = W(null), [h, g] = W(null), [_, v] = W(null), [y, b] = W(null), x = U(null), S = U(null), C = U(null), w = U(null), T = U(null), E = e ?
|
|
2492
|
+
var Ai = n("zh");
|
|
2493
|
+
function ji({ active: e, editor: t, interactionState: n = Xt, messages: r = Ai, onCopyPayload: i, onCommandResult: a, onEditWithAi: o }) {
|
|
2494
|
+
let [s, c] = W(null), [l, u] = W("row-edge"), [d, f] = W(null), [p, m] = W(null), [h, g] = W(null), [_, v] = W(null), [y, b] = W(null), x = U(null), S = U(null), C = U(null), w = U(null), T = U(null), E = e ? Jt(t.state) : null;
|
|
2291
2495
|
if (V(() => {
|
|
2292
2496
|
if (!y) return;
|
|
2293
2497
|
let e = window.setTimeout(() => {
|
|
2294
2498
|
b(null);
|
|
2295
|
-
},
|
|
2499
|
+
}, or);
|
|
2296
2500
|
return () => {
|
|
2297
2501
|
window.clearTimeout(e);
|
|
2298
2502
|
};
|
|
2299
|
-
}, [y]),
|
|
2503
|
+
}, [y]), be(() => {
|
|
2300
2504
|
if (!e) {
|
|
2301
2505
|
m(null), g(null), v(null), b(null);
|
|
2302
2506
|
return;
|
|
2303
2507
|
}
|
|
2304
2508
|
let r = () => {
|
|
2305
|
-
let e = t.view.dom.closest(".markweave-editor-frame") ?? t.view.dom.parentElement, r =
|
|
2509
|
+
let e = t.view.dom.closest(".markweave-editor-frame") ?? t.view.dom.parentElement, r = Qn(t, n, "row", E?.activeCellPos ?? null), i = Qn(t, n, "column", E?.activeCellPos ?? null), a = r ? Zn(t, r) : null, o = i ? Zn(t, i) : null, c = Xn(t).length > 0 ? rr(t) : null;
|
|
2306
2510
|
if (!e) {
|
|
2307
2511
|
m(null), g(null), v(null);
|
|
2308
2512
|
return;
|
|
2309
2513
|
}
|
|
2310
2514
|
let u = e.getBoundingClientRect();
|
|
2311
|
-
a ? m(
|
|
2515
|
+
a ? m(Gn({
|
|
2312
2516
|
targetRect: a,
|
|
2313
2517
|
frameRect: u,
|
|
2314
2518
|
kind: "row"
|
|
2315
|
-
})) : s === "row" && l === "row-edge" || m(null), o ? g(
|
|
2519
|
+
})) : s === "row" && l === "row-edge" || m(null), o ? g(Gn({
|
|
2316
2520
|
targetRect: o,
|
|
2317
2521
|
frameRect: u,
|
|
2318
2522
|
kind: "column"
|
|
2319
|
-
})) : s === "column" && l === "column-edge" || g(null), c ? v(
|
|
2523
|
+
})) : s === "column" && l === "column-edge" || g(null), c ? v(Gn({
|
|
2320
2524
|
targetRect: c,
|
|
2321
2525
|
frameRect: u,
|
|
2322
2526
|
kind: "selection"
|
|
@@ -2336,7 +2540,7 @@ function _i({ active: e, editor: t, interactionState: n = Ut, messages: r = gi,
|
|
|
2336
2540
|
n.hoverVisualRowIndex,
|
|
2337
2541
|
l,
|
|
2338
2542
|
s
|
|
2339
|
-
]),
|
|
2543
|
+
]), be(() => {
|
|
2340
2544
|
if (!e || !s) {
|
|
2341
2545
|
f(null);
|
|
2342
2546
|
return;
|
|
@@ -2347,12 +2551,12 @@ function _i({ active: e, editor: t, interactionState: n = Ut, messages: r = gi,
|
|
|
2347
2551
|
f(null);
|
|
2348
2552
|
return;
|
|
2349
2553
|
}
|
|
2350
|
-
let i = n.getBoundingClientRect(), a = s === "row" ?
|
|
2554
|
+
let i = n.getBoundingClientRect(), a = s === "row" ? Yn(t)?.getBoundingClientRect() : null, o = a ? {
|
|
2351
2555
|
left: i.left,
|
|
2352
2556
|
top: a.top,
|
|
2353
2557
|
width: i.width,
|
|
2354
2558
|
height: i.height
|
|
2355
|
-
} : i, c = e.getBoundingClientRect(), u = r.getBoundingClientRect(), d =
|
|
2559
|
+
} : i, c = e.getBoundingClientRect(), u = r.getBoundingClientRect(), d = Wn({
|
|
2356
2560
|
anchorRect: o,
|
|
2357
2561
|
frameRect: c,
|
|
2358
2562
|
menuSize: {
|
|
@@ -2393,22 +2597,22 @@ function _i({ active: e, editor: t, interactionState: n = Ut, messages: r = gi,
|
|
|
2393
2597
|
let n = s === e && l === t;
|
|
2394
2598
|
u(t), c(n ? null : e);
|
|
2395
2599
|
}, O = () => {
|
|
2396
|
-
t.view.dispatch(
|
|
2397
|
-
},
|
|
2600
|
+
t.view.dispatch(Un(t.state.tr, null));
|
|
2601
|
+
}, k = (e, r) => {
|
|
2398
2602
|
let i = n.hoverCellPos ?? E?.activeCellPos ?? null, a = n.hoverCellPos === null ? null : e === "row" ? n.hoverVisualRowIndex : n.hoverVisualColumnIndex;
|
|
2399
|
-
i !== null &&
|
|
2400
|
-
},
|
|
2603
|
+
i !== null && ar(t, i, e, { visualIndex: a }), D(e, r);
|
|
2604
|
+
}, A = () => {
|
|
2401
2605
|
O(), D("selection", "selection-edge");
|
|
2402
|
-
},
|
|
2403
|
-
let o = await
|
|
2606
|
+
}, j = Qn(t, n, "row", E?.activeCellPos ?? null), M = Qn(t, n, "column", E?.activeCellPos ?? null), ee = Xn(t).length > 0, N = s ? nr(t, s) : [], P = async (e, n) => {
|
|
2607
|
+
let o = await qn({
|
|
2404
2608
|
editor: t,
|
|
2405
2609
|
commandId: e,
|
|
2406
2610
|
menu: n ?? s ?? "selection",
|
|
2407
2611
|
messages: r
|
|
2408
2612
|
});
|
|
2409
2613
|
return o.copyFeedback ? (b(o.copyFeedback), o.copyPayload && i?.(o.copyPayload)) : b(null), a?.(o.commandResult), o.success;
|
|
2410
|
-
},
|
|
2411
|
-
let n =
|
|
2614
|
+
}, te = (e) => {
|
|
2615
|
+
let n = $n(t, e);
|
|
2412
2616
|
n && o?.(n), c(null), t.view.focus();
|
|
2413
2617
|
};
|
|
2414
2618
|
return /* @__PURE__ */ Q("div", {
|
|
@@ -2427,7 +2631,7 @@ function _i({ active: e, editor: t, interactionState: n = Ut, messages: r = gi,
|
|
|
2427
2631
|
"data-copy-kind": y.kind,
|
|
2428
2632
|
"data-text-length": y.textLength,
|
|
2429
2633
|
"data-html-length": y.htmlLength,
|
|
2430
|
-
children:
|
|
2634
|
+
children: Jn(y)
|
|
2431
2635
|
}) : null,
|
|
2432
2636
|
p ? /* @__PURE__ */ Z("button", {
|
|
2433
2637
|
type: "button",
|
|
@@ -2438,17 +2642,17 @@ function _i({ active: e, editor: t, interactionState: n = Ut, messages: r = gi,
|
|
|
2438
2642
|
"aria-haspopup": "menu",
|
|
2439
2643
|
title: r.table.rowActions,
|
|
2440
2644
|
"data-testid": "markweave-table-hover-row-handle",
|
|
2441
|
-
"data-axis-index":
|
|
2442
|
-
"data-axis-selected-cells":
|
|
2443
|
-
"data-axis-visual-cells":
|
|
2444
|
-
"data-axis-visual-size":
|
|
2645
|
+
"data-axis-index": j?.index ?? "",
|
|
2646
|
+
"data-axis-selected-cells": j?.selectedCellCount ?? "",
|
|
2647
|
+
"data-axis-visual-cells": j?.visualCellCount ?? "",
|
|
2648
|
+
"data-axis-visual-size": j?.visualHeight ?? "",
|
|
2445
2649
|
style: {
|
|
2446
2650
|
left: p.left,
|
|
2447
2651
|
top: p.top
|
|
2448
2652
|
},
|
|
2449
2653
|
onMouseDown: (e) => e.preventDefault(),
|
|
2450
2654
|
onClick: () => {
|
|
2451
|
-
|
|
2655
|
+
k("row", "row-edge");
|
|
2452
2656
|
},
|
|
2453
2657
|
children: /* @__PURE__ */ Z("span", {
|
|
2454
2658
|
"aria-hidden": "true",
|
|
@@ -2464,24 +2668,24 @@ function _i({ active: e, editor: t, interactionState: n = Ut, messages: r = gi,
|
|
|
2464
2668
|
"aria-haspopup": "menu",
|
|
2465
2669
|
title: r.table.columnActions,
|
|
2466
2670
|
"data-testid": "markweave-table-hover-column-handle",
|
|
2467
|
-
"data-axis-index":
|
|
2468
|
-
"data-axis-selected-cells":
|
|
2469
|
-
"data-axis-visual-cells":
|
|
2470
|
-
"data-axis-visual-size":
|
|
2671
|
+
"data-axis-index": M?.index ?? "",
|
|
2672
|
+
"data-axis-selected-cells": M?.selectedCellCount ?? "",
|
|
2673
|
+
"data-axis-visual-cells": M?.visualCellCount ?? "",
|
|
2674
|
+
"data-axis-visual-size": M?.visualWidth ?? "",
|
|
2471
2675
|
style: {
|
|
2472
2676
|
left: h.left,
|
|
2473
2677
|
top: h.top
|
|
2474
2678
|
},
|
|
2475
2679
|
onMouseDown: (e) => e.preventDefault(),
|
|
2476
2680
|
onClick: () => {
|
|
2477
|
-
|
|
2681
|
+
k("column", "column-edge");
|
|
2478
2682
|
},
|
|
2479
2683
|
children: /* @__PURE__ */ Z("span", {
|
|
2480
2684
|
"aria-hidden": "true",
|
|
2481
2685
|
children: "..."
|
|
2482
2686
|
})
|
|
2483
2687
|
}) : null,
|
|
2484
|
-
|
|
2688
|
+
ee && _ ? /* @__PURE__ */ Z("button", {
|
|
2485
2689
|
type: "button",
|
|
2486
2690
|
ref: T,
|
|
2487
2691
|
className: "markweave-table-edge-handle markweave-table-edge-handle--selection",
|
|
@@ -2495,7 +2699,7 @@ function _i({ active: e, editor: t, interactionState: n = Ut, messages: r = gi,
|
|
|
2495
2699
|
top: _.top
|
|
2496
2700
|
},
|
|
2497
2701
|
onMouseDown: (e) => e.preventDefault(),
|
|
2498
|
-
onClick:
|
|
2702
|
+
onClick: A,
|
|
2499
2703
|
children: /* @__PURE__ */ Z("span", {
|
|
2500
2704
|
"aria-hidden": "true",
|
|
2501
2705
|
children: "..."
|
|
@@ -2505,15 +2709,15 @@ function _i({ active: e, editor: t, interactionState: n = Ut, messages: r = gi,
|
|
|
2505
2709
|
ref: S,
|
|
2506
2710
|
className: "markweave-table-menu",
|
|
2507
2711
|
role: "menu",
|
|
2508
|
-
"aria-label":
|
|
2712
|
+
"aria-label": sr(s, r),
|
|
2509
2713
|
"data-testid": "markweave-table-menu",
|
|
2510
2714
|
"data-positioned": d ? "true" : "false",
|
|
2511
2715
|
style: d ? {
|
|
2512
2716
|
left: d.left,
|
|
2513
2717
|
top: d.top
|
|
2514
2718
|
} : void 0,
|
|
2515
|
-
children:
|
|
2516
|
-
let i =
|
|
2719
|
+
children: N.map((e, n) => {
|
|
2720
|
+
let i = er(e), a = n === 0 ? i : er(N[n - 1]), l = n > 0 && a !== i, u = e.commandId === null ? !!o : Kn(t, e.commandId), d = tr(e, r);
|
|
2517
2721
|
return /* @__PURE__ */ Z("button", {
|
|
2518
2722
|
type: "button",
|
|
2519
2723
|
role: "menuitem",
|
|
@@ -2528,10 +2732,10 @@ function _i({ active: e, editor: t, interactionState: n = Ut, messages: r = gi,
|
|
|
2528
2732
|
onClick: () => {
|
|
2529
2733
|
if (u) {
|
|
2530
2734
|
if (e.commandId === null) {
|
|
2531
|
-
|
|
2735
|
+
te(s === "row" || s === "column" ? s : "selection");
|
|
2532
2736
|
return;
|
|
2533
2737
|
}
|
|
2534
|
-
|
|
2738
|
+
P(e.commandId).finally(() => c(null));
|
|
2535
2739
|
}
|
|
2536
2740
|
},
|
|
2537
2741
|
children: d
|
|
@@ -2543,15 +2747,15 @@ function _i({ active: e, editor: t, interactionState: n = Ut, messages: r = gi,
|
|
|
2543
2747
|
}
|
|
2544
2748
|
//#endregion
|
|
2545
2749
|
//#region src/ui/table/TableSelectionOverlay.tsx
|
|
2546
|
-
function
|
|
2750
|
+
function Mi({ editor: e, focusState: t }) {
|
|
2547
2751
|
let [n, r] = W(null);
|
|
2548
|
-
return
|
|
2752
|
+
return be(() => {
|
|
2549
2753
|
if (t.mode !== "cell-selection") {
|
|
2550
2754
|
r(null);
|
|
2551
2755
|
return;
|
|
2552
2756
|
}
|
|
2553
2757
|
let n = () => {
|
|
2554
|
-
r(
|
|
2758
|
+
r(ir(e, Yt(e.state)));
|
|
2555
2759
|
};
|
|
2556
2760
|
return n(), window.addEventListener("resize", n), window.addEventListener("scroll", n, !0), () => {
|
|
2557
2761
|
window.removeEventListener("resize", n), window.removeEventListener("scroll", n, !0);
|
|
@@ -2586,16 +2790,16 @@ function vi({ editor: e, focusState: t }) {
|
|
|
2586
2790
|
}
|
|
2587
2791
|
//#endregion
|
|
2588
2792
|
//#region src/ui/toc/MarkweaveInnerToc.tsx
|
|
2589
|
-
function
|
|
2793
|
+
function Ni(e, t) {
|
|
2590
2794
|
return `${e.toc.itemAriaLabel}: ${t.text}`;
|
|
2591
2795
|
}
|
|
2592
|
-
function
|
|
2796
|
+
function Pi({ editor: e, state: t, messages: n, editable: r, placement: i }) {
|
|
2593
2797
|
let a = U(null);
|
|
2594
2798
|
if (V(() => {
|
|
2595
|
-
if (!(i !== "container" || !a.current)) return
|
|
2799
|
+
if (!(i !== "container" || !a.current)) return mr(a.current);
|
|
2596
2800
|
}, [i]), !t.items.length) return null;
|
|
2597
2801
|
let o = (t) => {
|
|
2598
|
-
|
|
2802
|
+
hr(e, t, {
|
|
2599
2803
|
behavior: "smooth",
|
|
2600
2804
|
focus: r
|
|
2601
2805
|
});
|
|
@@ -2622,7 +2826,7 @@ function bi({ editor: e, state: t, messages: n, editable: r, placement: i }) {
|
|
|
2622
2826
|
"data-level": e.level,
|
|
2623
2827
|
"data-active": e.active ? "true" : "false",
|
|
2624
2828
|
"aria-current": e.active ? "location" : void 0,
|
|
2625
|
-
"aria-label":
|
|
2829
|
+
"aria-label": Ni(n, e),
|
|
2626
2830
|
title: e.text,
|
|
2627
2831
|
onClick: () => o(e),
|
|
2628
2832
|
children: e.text
|
|
@@ -2633,7 +2837,7 @@ function bi({ editor: e, state: t, messages: n, editable: r, placement: i }) {
|
|
|
2633
2837
|
}
|
|
2634
2838
|
//#endregion
|
|
2635
2839
|
//#region src/MarkweaveEditor.tsx
|
|
2636
|
-
var
|
|
2840
|
+
var Fi = {
|
|
2637
2841
|
active: !1,
|
|
2638
2842
|
mode: "outside",
|
|
2639
2843
|
activeCellPos: null,
|
|
@@ -2641,21 +2845,21 @@ var xi = {
|
|
|
2641
2845
|
selectedCellCount: 0,
|
|
2642
2846
|
selectionFrom: 0,
|
|
2643
2847
|
selectionTo: 0
|
|
2644
|
-
},
|
|
2848
|
+
}, Ii = {
|
|
2645
2849
|
active: !1,
|
|
2646
|
-
language:
|
|
2850
|
+
language: ht.defaultLanguage,
|
|
2647
2851
|
mermaidPreviewMode: "code",
|
|
2648
2852
|
pos: null,
|
|
2649
2853
|
text: ""
|
|
2650
|
-
},
|
|
2854
|
+
}, Li = Ct({
|
|
2651
2855
|
active: !1,
|
|
2652
2856
|
mode: "code",
|
|
2653
2857
|
source: ""
|
|
2654
2858
|
});
|
|
2655
|
-
function
|
|
2656
|
-
return
|
|
2859
|
+
function Ri(e) {
|
|
2860
|
+
return Zt.getState(e.state) ?? Xt;
|
|
2657
2861
|
}
|
|
2658
|
-
function
|
|
2862
|
+
function zi(e) {
|
|
2659
2863
|
if (!e || typeof window > "u") return null;
|
|
2660
2864
|
let t = e.parentElement;
|
|
2661
2865
|
for (; t;) {
|
|
@@ -2665,89 +2869,92 @@ function Ti(e) {
|
|
|
2665
2869
|
}
|
|
2666
2870
|
return null;
|
|
2667
2871
|
}
|
|
2668
|
-
function
|
|
2872
|
+
function Bi(e) {
|
|
2669
2873
|
return typeof window > "u" || typeof window.requestAnimationFrame != "function" ? globalThis.setTimeout(() => e(0), 0) : window.requestAnimationFrame(e);
|
|
2670
2874
|
}
|
|
2671
|
-
function
|
|
2875
|
+
function Vi(e) {
|
|
2672
2876
|
if (typeof window < "u" && typeof window.cancelAnimationFrame == "function") {
|
|
2673
2877
|
window.cancelAnimationFrame(e);
|
|
2674
2878
|
return;
|
|
2675
2879
|
}
|
|
2676
2880
|
globalThis.clearTimeout(e);
|
|
2677
2881
|
}
|
|
2678
|
-
function
|
|
2679
|
-
let
|
|
2680
|
-
editorMode:
|
|
2681
|
-
effectiveEditable:
|
|
2882
|
+
function Hi({ ariaLabel: e, autoFocusFirstTableBodyCell: i = !1, autofocus: a = !1, content: o, contentFormat: c, defaultContent: l = "", defaultContentFormat: u, editable: d = !0, innerToc: f = !0, innerTocPlacement: p, lang: m, mode: h = "live", theme: g, onEditWithAi: _, onExtractToNote: v, onRewriteSelection: y, onRuntimeStateChange: b, onSlashCommandUpload: x, onTableCommandResult: S, onTableCopyPayload: C, onTocChange: w, onUpdate: T, linkCardResolver: E } = {}) {
|
|
2883
|
+
let D = Ie(h), O = gr(g), k = pr(p), A = D === "live" && d !== !1, j = Ze(o === void 0 ? u : c), M = U({
|
|
2884
|
+
editorMode: D,
|
|
2885
|
+
effectiveEditable: A
|
|
2682
2886
|
});
|
|
2683
|
-
|
|
2684
|
-
editorMode:
|
|
2685
|
-
effectiveEditable:
|
|
2887
|
+
M.current = {
|
|
2888
|
+
editorMode: D,
|
|
2889
|
+
effectiveEditable: A
|
|
2686
2890
|
};
|
|
2687
2891
|
let ee = U(null);
|
|
2688
|
-
ee.current === null && (ee.current =
|
|
2689
|
-
let
|
|
2690
|
-
|
|
2691
|
-
let
|
|
2692
|
-
|
|
2892
|
+
ee.current === null && (ee.current = r(m));
|
|
2893
|
+
let N = ee.current, P = H(() => n(N), [N]), te = H(() => t(N), [N]), F = U(x);
|
|
2894
|
+
F.current = x;
|
|
2895
|
+
let I = U(E);
|
|
2896
|
+
I.current = E;
|
|
2897
|
+
let ne = H(() => Rr({
|
|
2898
|
+
lang: N,
|
|
2693
2899
|
onImageUpload: (e) => {
|
|
2694
|
-
if (
|
|
2695
|
-
let t =
|
|
2900
|
+
if (F.current) return F.current(e);
|
|
2901
|
+
let t = Se(e);
|
|
2696
2902
|
if (!t) throw Error("File upload requires an upload handler.");
|
|
2697
2903
|
return t;
|
|
2698
2904
|
},
|
|
2699
2905
|
onVideoUpload: (e) => {
|
|
2700
|
-
if (
|
|
2701
|
-
let t =
|
|
2906
|
+
if (F.current) return F.current(e);
|
|
2907
|
+
let t = Se(e);
|
|
2702
2908
|
if (!t) throw Error("File upload requires an upload handler.");
|
|
2703
2909
|
return t;
|
|
2704
|
-
}
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2910
|
+
},
|
|
2911
|
+
linkCardResolver: (e) => I.current?.(e) ?? Promise.resolve(null)
|
|
2912
|
+
}), [N]), [L, re] = W(null), [R, z] = W(Wt), [ie, ae] = W(null), [oe, se] = W(null), [ce, le] = W("code"), [ue, de] = W(null), [fe, pe] = W(Xt), [me, he] = W(null), [ge, _e] = W(0), ve = U(!1), ye = U({
|
|
2913
|
+
content: o,
|
|
2914
|
+
format: j
|
|
2915
|
+
}), be = U(null), G = U(null), xe = U({ onUpdate: T }), Ce = H(() => It(R.query, te), [te, R.query]);
|
|
2916
|
+
xe.current = { onUpdate: T }, ye.current = {
|
|
2917
|
+
content: o,
|
|
2918
|
+
format: j
|
|
2712
2919
|
};
|
|
2713
|
-
let
|
|
2714
|
-
|
|
2715
|
-
}, []),
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
},
|
|
2920
|
+
let we = B(() => {
|
|
2921
|
+
G.current !== null && (window.clearTimeout(G.current), G.current = null), _e((e) => e + 1);
|
|
2922
|
+
}, []), Te = B(() => {
|
|
2923
|
+
G.current !== null && window.clearTimeout(G.current), G.current = window.setTimeout(() => {
|
|
2924
|
+
G.current = null, _e((e) => e + 1);
|
|
2925
|
+
}, ct);
|
|
2719
2926
|
}, []);
|
|
2720
2927
|
V(() => () => {
|
|
2721
|
-
|
|
2928
|
+
G.current !== null && window.clearTimeout(G.current);
|
|
2722
2929
|
}, []);
|
|
2723
2930
|
let K = B(() => {
|
|
2724
|
-
|
|
2725
|
-
}, []),
|
|
2726
|
-
let t =
|
|
2931
|
+
ae(null), se(null), z(Wt);
|
|
2932
|
+
}, []), Ee = B((e) => {
|
|
2933
|
+
let t = Ut(e.state);
|
|
2727
2934
|
if (!t) {
|
|
2728
|
-
|
|
2935
|
+
z((e) => e.name === "idle" ? e : Wt), ae(null), se(null);
|
|
2729
2936
|
return;
|
|
2730
2937
|
}
|
|
2731
2938
|
let n = e.coordsAtPos(t.cursor), r = e.coordsAtPos(t.triggerFrom), i = e.dom.closest(".markweave-editor-frame")?.getBoundingClientRect();
|
|
2732
|
-
|
|
2939
|
+
ae(Ht(n, {
|
|
2733
2940
|
frameRect: i,
|
|
2734
2941
|
triggerRect: r
|
|
2735
|
-
})),
|
|
2736
|
-
}, []),
|
|
2737
|
-
let t =
|
|
2738
|
-
|
|
2739
|
-
let n =
|
|
2740
|
-
n && (
|
|
2741
|
-
let r =
|
|
2742
|
-
r.active && r.language === "mermaid" &&
|
|
2743
|
-
}, []),
|
|
2744
|
-
|
|
2745
|
-
}, []), q =
|
|
2746
|
-
extensions:
|
|
2747
|
-
content:
|
|
2748
|
-
contentType:
|
|
2749
|
-
editable:
|
|
2750
|
-
autofocus:
|
|
2942
|
+
})), z((e) => Vt(e, t));
|
|
2943
|
+
}, []), De = B((e) => Ee(e.view), [Ee]), Oe = B((e) => {
|
|
2944
|
+
let t = at(e);
|
|
2945
|
+
re((e) => tt(e, t) ? e : t);
|
|
2946
|
+
let n = jt(e);
|
|
2947
|
+
n && (Nt(e, n, !0), de(n));
|
|
2948
|
+
let r = pt(e);
|
|
2949
|
+
r.active && r.language === "mermaid" && le(r.mermaidPreviewMode);
|
|
2950
|
+
}, []), ke = B((e) => {
|
|
2951
|
+
pe(Ri(e));
|
|
2952
|
+
}, []), q = s({
|
|
2953
|
+
extensions: ne,
|
|
2954
|
+
content: o ?? l,
|
|
2955
|
+
contentType: Je(j),
|
|
2956
|
+
editable: A,
|
|
2957
|
+
autofocus: a,
|
|
2751
2958
|
editorProps: {
|
|
2752
2959
|
attributes: {
|
|
2753
2960
|
class: "markweave-editor-surface",
|
|
@@ -2757,36 +2964,36 @@ function Oi({ ariaLabel: e, autoFocusFirstTableBodyCell: t = !1, autofocus: n =
|
|
|
2757
2964
|
spellcheck: "false",
|
|
2758
2965
|
translate: "no"
|
|
2759
2966
|
},
|
|
2760
|
-
handleClick: (e, t, n) =>
|
|
2967
|
+
handleClick: (e, t, n) => M.current.effectiveEditable ? !1 : Qe(n),
|
|
2761
2968
|
handleDOMEvents: {
|
|
2762
|
-
compositionstart: () =>
|
|
2763
|
-
compositionend: (e) => (
|
|
2969
|
+
compositionstart: () => M.current.effectiveEditable ? (z((e) => Gt(e, { type: "composition-start" })), ae(null), !1) : !1,
|
|
2970
|
+
compositionend: (e) => (M.current.effectiveEditable && window.setTimeout(() => Ee(e), 0), !1),
|
|
2764
2971
|
click: (e, t) => {
|
|
2765
|
-
if (
|
|
2766
|
-
let n =
|
|
2767
|
-
return n ? (t.preventDefault(), t.stopPropagation(), K(),
|
|
2972
|
+
if (M.current.effectiveEditable) {
|
|
2973
|
+
let n = At(e, t);
|
|
2974
|
+
return n ? (t.preventDefault(), t.stopPropagation(), K(), Pt(e, n, !0), Ft(e, n), de(n), !0) : (de(null), !1);
|
|
2768
2975
|
}
|
|
2769
|
-
return
|
|
2976
|
+
return Qe(t);
|
|
2770
2977
|
}
|
|
2771
2978
|
}
|
|
2772
2979
|
},
|
|
2773
2980
|
onSelectionUpdate: ({ editor: e }) => {
|
|
2774
|
-
|
|
2981
|
+
Oe(e);
|
|
2775
2982
|
},
|
|
2776
2983
|
onCreate: ({ editor: e }) => {
|
|
2777
|
-
|
|
2984
|
+
i && M.current.effectiveEditable && qt(e), ke(e), Oe(e), we();
|
|
2778
2985
|
},
|
|
2779
2986
|
onTransaction: ({ editor: e, transaction: t }) => {
|
|
2780
|
-
|
|
2987
|
+
ke(e), (t.docChanged || yt(t)) && Te(), t.docChanged && de((t) => {
|
|
2781
2988
|
if (!t) return null;
|
|
2782
|
-
let n =
|
|
2989
|
+
let n = kt(e, t.pos);
|
|
2783
2990
|
return n?.kind === t.kind ? n : null;
|
|
2784
2991
|
});
|
|
2785
2992
|
},
|
|
2786
2993
|
onUpdate: ({ editor: e }) => {
|
|
2787
|
-
|
|
2788
|
-
let r =
|
|
2789
|
-
r.content !== void 0 && t === r.format && (
|
|
2994
|
+
Oe(e), M.current.effectiveEditable && De(e), ve.current || xe.current.onUpdate?.(qe(e, { onContentRead: (t, n) => {
|
|
2995
|
+
let r = ye.current;
|
|
2996
|
+
r.content !== void 0 && t === r.format && (be.current = {
|
|
2790
2997
|
content: n,
|
|
2791
2998
|
format: t,
|
|
2792
2999
|
doc: e.state.doc
|
|
@@ -2795,152 +3002,152 @@ function Oi({ ariaLabel: e, autoFocusFirstTableBodyCell: t = !1, autofocus: n =
|
|
|
2795
3002
|
}
|
|
2796
3003
|
});
|
|
2797
3004
|
V(() => {
|
|
2798
|
-
q && (q.setEditable(
|
|
2799
|
-
mode:
|
|
2800
|
-
editable:
|
|
2801
|
-
}),
|
|
3005
|
+
q && (q.setEditable(A), Le(q, {
|
|
3006
|
+
mode: D,
|
|
3007
|
+
editable: A
|
|
3008
|
+
}), xt(q, A ? "live" : "view"), we(), A || K());
|
|
2802
3009
|
}, [
|
|
2803
3010
|
K,
|
|
2804
3011
|
q,
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
3012
|
+
D,
|
|
3013
|
+
A,
|
|
3014
|
+
we
|
|
2808
3015
|
]), V(() => {
|
|
2809
|
-
q &&
|
|
2810
|
-
}, [q,
|
|
2811
|
-
let e =
|
|
2812
|
-
if (!(!q ||
|
|
2813
|
-
if (
|
|
2814
|
-
|
|
3016
|
+
q && bt(q, O);
|
|
3017
|
+
}, [q, O]), V(() => {
|
|
3018
|
+
let e = Ze(c);
|
|
3019
|
+
if (!(!q || o === void 0)) {
|
|
3020
|
+
if (Xe(q, be.current, o, e)) {
|
|
3021
|
+
be.current = null;
|
|
2815
3022
|
return;
|
|
2816
3023
|
}
|
|
2817
|
-
|
|
2818
|
-
contentType:
|
|
3024
|
+
be.current = null, !Ye(q, o, e) && (ve.current = !0, q.commands.setContent(o, {
|
|
3025
|
+
contentType: Je(e),
|
|
2819
3026
|
emitUpdate: !1
|
|
2820
|
-
}),
|
|
3027
|
+
}), ve.current = !1, Oe(q), A && De(q), ke(q), we());
|
|
2821
3028
|
}
|
|
2822
3029
|
}, [
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
3030
|
+
o,
|
|
3031
|
+
c,
|
|
3032
|
+
A,
|
|
2826
3033
|
q,
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
3034
|
+
we,
|
|
3035
|
+
Oe,
|
|
3036
|
+
De,
|
|
3037
|
+
ke
|
|
2831
3038
|
]), V(() => {
|
|
2832
|
-
if (!
|
|
3039
|
+
if (!ie) return;
|
|
2833
3040
|
let e = (e) => {
|
|
2834
3041
|
let t = e.target;
|
|
2835
3042
|
t instanceof Element && (t.closest(".markweave-slash-menu") || t.closest(".markweave-slash-trigger") || K());
|
|
2836
3043
|
};
|
|
2837
3044
|
return document.addEventListener("pointerdown", e, !0), () => document.removeEventListener("pointerdown", e, !0);
|
|
2838
|
-
}, [K,
|
|
2839
|
-
let
|
|
3045
|
+
}, [K, ie]);
|
|
3046
|
+
let Ae = H(() => q ? pt(q) : Ii, [
|
|
2840
3047
|
q,
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
]),
|
|
3048
|
+
ge,
|
|
3049
|
+
L
|
|
3050
|
+
]), je = H(() => q ? Jt(q.state) : Fi, [
|
|
2844
3051
|
q,
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
]),
|
|
2849
|
-
active:
|
|
2850
|
-
mode:
|
|
2851
|
-
source:
|
|
2852
|
-
}) :
|
|
2853
|
-
|
|
3052
|
+
ge,
|
|
3053
|
+
L,
|
|
3054
|
+
fe
|
|
3055
|
+
]), Me = L?.currentNode === "codeBlock", Ne = Me && Ae.language === "mermaid", Pe = H(() => q ? Ct({
|
|
3056
|
+
active: Ne,
|
|
3057
|
+
mode: ce,
|
|
3058
|
+
source: Ae.text
|
|
3059
|
+
}) : Li, [
|
|
3060
|
+
Ae.text,
|
|
2854
3061
|
q,
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
]), J = H(() => q ?
|
|
3062
|
+
Ne,
|
|
3063
|
+
ce
|
|
3064
|
+
]), J = H(() => q ? Kt(q.state) : null, [q, ge]), Y = H(() => q ? dr(q.state.doc) : lr.items, [q, ge]), Fe = H(() => fr(Y, me), [me, Y]), Re = H(() => cr(Y, Fe), [Fe, Y]), ze = B(() => {
|
|
2858
3065
|
if (!q || !Y.length) {
|
|
2859
|
-
|
|
3066
|
+
he(null);
|
|
2860
3067
|
return;
|
|
2861
3068
|
}
|
|
2862
|
-
let e =
|
|
2863
|
-
|
|
3069
|
+
let e = ur(q, Y);
|
|
3070
|
+
he((t) => t === e ? t : e);
|
|
2864
3071
|
}, [q, Y]);
|
|
2865
3072
|
V(() => {
|
|
2866
|
-
|
|
2867
|
-
let t =
|
|
3073
|
+
he((e) => {
|
|
3074
|
+
let t = fr(Y, e);
|
|
2868
3075
|
return e === t ? e : t;
|
|
2869
3076
|
});
|
|
2870
3077
|
}, [Y]), V(() => {
|
|
2871
3078
|
if (!q || !Y.length || typeof window > "u") return;
|
|
2872
3079
|
let e = null, t = () => {
|
|
2873
|
-
e !== null &&
|
|
2874
|
-
e = null,
|
|
3080
|
+
e !== null && Vi(e), e = Bi(() => {
|
|
3081
|
+
e = null, ze();
|
|
2875
3082
|
});
|
|
2876
|
-
}, n =
|
|
3083
|
+
}, n = zi(q.view.dom);
|
|
2877
3084
|
return window.addEventListener("scroll", t, { passive: !0 }), window.addEventListener("resize", t), n?.addEventListener("scroll", t, { passive: !0 }), t(), () => {
|
|
2878
|
-
window.removeEventListener("scroll", t), window.removeEventListener("resize", t), n?.removeEventListener("scroll", t), e !== null &&
|
|
3085
|
+
window.removeEventListener("scroll", t), window.removeEventListener("resize", t), n?.removeEventListener("scroll", t), e !== null && Vi(e);
|
|
2879
3086
|
};
|
|
2880
3087
|
}, [
|
|
2881
3088
|
q,
|
|
2882
3089
|
Y.length,
|
|
2883
|
-
|
|
3090
|
+
ze
|
|
2884
3091
|
]);
|
|
2885
|
-
let X = H(() =>
|
|
2886
|
-
revision:
|
|
2887
|
-
mode:
|
|
2888
|
-
editable:
|
|
2889
|
-
toc:
|
|
2890
|
-
selection:
|
|
2891
|
-
slash:
|
|
2892
|
-
table:
|
|
2893
|
-
tableInteraction:
|
|
2894
|
-
codeBlock:
|
|
2895
|
-
mermaid:
|
|
3092
|
+
let X = H(() => $e({
|
|
3093
|
+
revision: ge,
|
|
3094
|
+
mode: D,
|
|
3095
|
+
editable: A,
|
|
3096
|
+
toc: Re,
|
|
3097
|
+
selection: L,
|
|
3098
|
+
slash: R,
|
|
3099
|
+
table: je,
|
|
3100
|
+
tableInteraction: fe,
|
|
3101
|
+
codeBlock: Ae,
|
|
3102
|
+
mermaid: Pe,
|
|
2896
3103
|
tableDebugSnapshot: J
|
|
2897
3104
|
}), [
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
3105
|
+
Ae,
|
|
3106
|
+
D,
|
|
3107
|
+
A,
|
|
3108
|
+
Pe,
|
|
3109
|
+
ge,
|
|
3110
|
+
L,
|
|
3111
|
+
R,
|
|
2905
3112
|
J,
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
3113
|
+
je,
|
|
3114
|
+
fe,
|
|
3115
|
+
Re
|
|
2909
3116
|
]);
|
|
2910
3117
|
V(() => {
|
|
2911
|
-
|
|
2912
|
-
}, [
|
|
2913
|
-
|
|
2914
|
-
}, [
|
|
3118
|
+
b?.(X);
|
|
3119
|
+
}, [b, X]), V(() => {
|
|
3120
|
+
w?.(Re);
|
|
3121
|
+
}, [w, Re]);
|
|
2915
3122
|
let Z = B((e, t) => {
|
|
2916
|
-
if (!(!q || !
|
|
3123
|
+
if (!(!q || !A) && Lt(e)) {
|
|
2917
3124
|
if (e.inputKind && !t?.emoji && !t?.uploadResult) {
|
|
2918
|
-
|
|
3125
|
+
se(e);
|
|
2919
3126
|
return;
|
|
2920
3127
|
}
|
|
2921
|
-
|
|
3128
|
+
Bt(q, R, e, t), z((e) => Gt(e, { type: "execute" })), K();
|
|
2922
3129
|
}
|
|
2923
3130
|
}, [
|
|
2924
3131
|
K,
|
|
2925
|
-
|
|
3132
|
+
A,
|
|
2926
3133
|
q,
|
|
2927
|
-
|
|
3134
|
+
R
|
|
2928
3135
|
]), Q = B((e) => {
|
|
2929
|
-
|
|
3136
|
+
z((t) => Gt(t, {
|
|
2930
3137
|
type: "set-active",
|
|
2931
3138
|
index: e,
|
|
2932
|
-
optionCount:
|
|
3139
|
+
optionCount: Ce.length
|
|
2933
3140
|
}));
|
|
2934
|
-
}, [
|
|
2935
|
-
if (!q ||
|
|
2936
|
-
let t =
|
|
3141
|
+
}, [Ce.length]), Be = B((e) => {
|
|
3142
|
+
if (!q || oe || !A) return;
|
|
3143
|
+
let t = Rt(R, Ce, e.key, { isComposing: e.nativeEvent.isComposing || Ke(q.state) });
|
|
2937
3144
|
if (t.type !== "ignore") {
|
|
2938
3145
|
if (t.type === "close") {
|
|
2939
|
-
e.preventDefault(),
|
|
3146
|
+
e.preventDefault(), z((e) => Gt(e, { type: "escape" })), K();
|
|
2940
3147
|
return;
|
|
2941
3148
|
}
|
|
2942
3149
|
if (t.type === "move-active") {
|
|
2943
|
-
e.preventDefault(),
|
|
3150
|
+
e.preventDefault(), z((e) => Gt(e, {
|
|
2944
3151
|
type: "move-active",
|
|
2945
3152
|
delta: t.delta,
|
|
2946
3153
|
optionCount: t.optionCount
|
|
@@ -2951,155 +3158,155 @@ function Oi({ ariaLabel: e, autoFocusFirstTableBodyCell: t = !1, autofocus: n =
|
|
|
2951
3158
|
}
|
|
2952
3159
|
}, [
|
|
2953
3160
|
K,
|
|
2954
|
-
|
|
3161
|
+
A,
|
|
2955
3162
|
q,
|
|
2956
|
-
|
|
3163
|
+
Ce,
|
|
2957
3164
|
Z,
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
]),
|
|
3165
|
+
oe,
|
|
3166
|
+
R
|
|
3167
|
+
]), Ve = H(() => ({
|
|
2961
3168
|
closeSlashMenu: K,
|
|
2962
|
-
focusFirstTableBodyCell: () => q ?
|
|
3169
|
+
focusFirstTableBodyCell: () => q ? qt(q) : !1,
|
|
2963
3170
|
setContent: (e, t = {}) => {
|
|
2964
3171
|
if (!q) return !1;
|
|
2965
|
-
let n =
|
|
3172
|
+
let n = Ze(t.format);
|
|
2966
3173
|
return q.commands.setContent(e, {
|
|
2967
|
-
contentType:
|
|
3174
|
+
contentType: Je(n),
|
|
2968
3175
|
emitUpdate: t.emitUpdate ?? !1
|
|
2969
|
-
}), t.focusFirstTableBodyCell &&
|
|
3176
|
+
}), t.focusFirstTableBodyCell && qt(q), Oe(q), A && De(q), ke(q), we(), !0;
|
|
2970
3177
|
}
|
|
2971
3178
|
}), [
|
|
2972
3179
|
K,
|
|
2973
|
-
|
|
3180
|
+
A,
|
|
2974
3181
|
q,
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
3182
|
+
we,
|
|
3183
|
+
Oe,
|
|
3184
|
+
De,
|
|
3185
|
+
ke
|
|
2979
3186
|
]);
|
|
2980
3187
|
return {
|
|
2981
3188
|
editor: q,
|
|
2982
3189
|
frameProps: H(() => ({
|
|
2983
3190
|
className: "markweave-editor-frame",
|
|
2984
|
-
"aria-label": e ??
|
|
3191
|
+
"aria-label": e ?? P.common.editorAriaLabel,
|
|
2985
3192
|
"data-testid": "markweave-editor-frame",
|
|
2986
|
-
"data-markweave-mode":
|
|
2987
|
-
"data-markweave-theme":
|
|
2988
|
-
"data-markweave-inner-toc":
|
|
2989
|
-
"data-markweave-inner-toc-placement":
|
|
2990
|
-
"data-mermaid-mode":
|
|
2991
|
-
"data-table-focus-mode":
|
|
2992
|
-
onKeyDownCapture:
|
|
3193
|
+
"data-markweave-mode": D,
|
|
3194
|
+
"data-markweave-theme": O,
|
|
3195
|
+
"data-markweave-inner-toc": f ? "true" : "false",
|
|
3196
|
+
"data-markweave-inner-toc-placement": k,
|
|
3197
|
+
"data-mermaid-mode": Pe.mode,
|
|
3198
|
+
"data-table-focus-mode": je.mode,
|
|
3199
|
+
onKeyDownCapture: Be
|
|
2993
3200
|
}), [
|
|
2994
3201
|
e,
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3202
|
+
D,
|
|
3203
|
+
Be,
|
|
3204
|
+
f,
|
|
3205
|
+
Pe.mode,
|
|
3206
|
+
P.common.editorAriaLabel,
|
|
3207
|
+
k,
|
|
3208
|
+
O,
|
|
3209
|
+
je.mode
|
|
3003
3210
|
]),
|
|
3004
3211
|
overlayProps: H(() => ({
|
|
3005
|
-
floatingToolbar: q &&
|
|
3212
|
+
floatingToolbar: q && A ? {
|
|
3006
3213
|
editor: q,
|
|
3007
|
-
messages:
|
|
3008
|
-
selectionSnapshot:
|
|
3009
|
-
onRewriteSelection:
|
|
3010
|
-
onExtractToNote:
|
|
3214
|
+
messages: P,
|
|
3215
|
+
selectionSnapshot: L,
|
|
3216
|
+
onRewriteSelection: y,
|
|
3217
|
+
onExtractToNote: v
|
|
3011
3218
|
} : null,
|
|
3012
|
-
slashCommandMenu: q &&
|
|
3013
|
-
commands:
|
|
3014
|
-
state:
|
|
3015
|
-
position:
|
|
3016
|
-
inputCommand:
|
|
3017
|
-
messages:
|
|
3219
|
+
slashCommandMenu: q && A ? {
|
|
3220
|
+
commands: Ce,
|
|
3221
|
+
state: R,
|
|
3222
|
+
position: ie,
|
|
3223
|
+
inputCommand: oe,
|
|
3224
|
+
messages: P,
|
|
3018
3225
|
onActiveIndexChange: Q,
|
|
3019
|
-
onInputCommandChange:
|
|
3226
|
+
onInputCommandChange: se,
|
|
3020
3227
|
onSelect: Z,
|
|
3021
|
-
onUpload:
|
|
3228
|
+
onUpload: x
|
|
3022
3229
|
} : null,
|
|
3023
|
-
tableControls: q &&
|
|
3230
|
+
tableControls: q && A ? {
|
|
3024
3231
|
editor: q,
|
|
3025
|
-
active:
|
|
3026
|
-
interactionState:
|
|
3027
|
-
messages:
|
|
3028
|
-
onCopyPayload:
|
|
3029
|
-
onCommandResult:
|
|
3030
|
-
onEditWithAi:
|
|
3232
|
+
active: je.active,
|
|
3233
|
+
interactionState: fe,
|
|
3234
|
+
messages: P,
|
|
3235
|
+
onCopyPayload: C,
|
|
3236
|
+
onCommandResult: S,
|
|
3237
|
+
onEditWithAi: _
|
|
3031
3238
|
} : null,
|
|
3032
|
-
tableSelectionOverlay: q &&
|
|
3239
|
+
tableSelectionOverlay: q && A ? {
|
|
3033
3240
|
editor: q,
|
|
3034
|
-
focusState:
|
|
3241
|
+
focusState: je
|
|
3035
3242
|
} : null,
|
|
3036
3243
|
codeBlockControls: q ? {
|
|
3037
3244
|
editor: q,
|
|
3038
|
-
active:
|
|
3039
|
-
mermaidMode:
|
|
3040
|
-
onMermaidModeChange:
|
|
3041
|
-
readOnly: !
|
|
3245
|
+
active: A && Me,
|
|
3246
|
+
mermaidMode: ce,
|
|
3247
|
+
onMermaidModeChange: le,
|
|
3248
|
+
readOnly: !A
|
|
3042
3249
|
} : null,
|
|
3043
|
-
innerToc: q &&
|
|
3250
|
+
innerToc: q && f && Re.items.length ? {
|
|
3044
3251
|
editor: q,
|
|
3045
|
-
editable:
|
|
3046
|
-
messages:
|
|
3047
|
-
placement:
|
|
3048
|
-
state:
|
|
3252
|
+
editable: A,
|
|
3253
|
+
messages: P,
|
|
3254
|
+
placement: k,
|
|
3255
|
+
state: Re
|
|
3049
3256
|
} : null,
|
|
3050
|
-
mathEditorPopover: q &&
|
|
3257
|
+
mathEditorPopover: q && A && ue ? {
|
|
3051
3258
|
editor: q,
|
|
3052
|
-
messages:
|
|
3053
|
-
target:
|
|
3054
|
-
onClose: () =>
|
|
3259
|
+
messages: P,
|
|
3260
|
+
target: ue,
|
|
3261
|
+
onClose: () => de(null)
|
|
3055
3262
|
} : null
|
|
3056
3263
|
}), [
|
|
3057
|
-
E,
|
|
3058
|
-
q,
|
|
3059
|
-
G,
|
|
3060
|
-
l,
|
|
3061
|
-
De,
|
|
3062
|
-
ie,
|
|
3063
3264
|
A,
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3265
|
+
q,
|
|
3266
|
+
Ce,
|
|
3267
|
+
f,
|
|
3268
|
+
Me,
|
|
3269
|
+
ce,
|
|
3270
|
+
P,
|
|
3271
|
+
ue,
|
|
3272
|
+
_,
|
|
3068
3273
|
v,
|
|
3069
3274
|
y,
|
|
3070
|
-
|
|
3275
|
+
x,
|
|
3276
|
+
S,
|
|
3277
|
+
C,
|
|
3071
3278
|
Z,
|
|
3072
|
-
N,
|
|
3073
|
-
Q,
|
|
3074
3279
|
L,
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3280
|
+
Q,
|
|
3281
|
+
oe,
|
|
3282
|
+
ie,
|
|
3283
|
+
R,
|
|
3284
|
+
je,
|
|
3285
|
+
fe,
|
|
3286
|
+
Re
|
|
3080
3287
|
]),
|
|
3081
3288
|
runtimeSnapshot: X,
|
|
3082
|
-
actions:
|
|
3289
|
+
actions: Ve
|
|
3083
3290
|
};
|
|
3084
3291
|
}
|
|
3085
|
-
function
|
|
3086
|
-
let
|
|
3087
|
-
if (!
|
|
3088
|
-
let
|
|
3292
|
+
function Ui({ className: e, ...t }) {
|
|
3293
|
+
let n = Hi(t);
|
|
3294
|
+
if (!n.editor) return null;
|
|
3295
|
+
let r = [n.frameProps.className, e].filter(Boolean).join(" ");
|
|
3089
3296
|
return /* @__PURE__ */ Q("section", {
|
|
3090
|
-
...
|
|
3091
|
-
className:
|
|
3297
|
+
...n.frameProps,
|
|
3298
|
+
className: r,
|
|
3092
3299
|
children: [
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
/* @__PURE__ */ Z(
|
|
3300
|
+
n.overlayProps.floatingToolbar ? /* @__PURE__ */ Z(ci, { ...n.overlayProps.floatingToolbar }) : null,
|
|
3301
|
+
n.overlayProps.slashCommandMenu ? /* @__PURE__ */ Z(ki, { ...n.overlayProps.slashCommandMenu }) : null,
|
|
3302
|
+
n.overlayProps.tableControls ? /* @__PURE__ */ Z(ji, { ...n.overlayProps.tableControls }) : null,
|
|
3303
|
+
n.overlayProps.tableSelectionOverlay ? /* @__PURE__ */ Z(Mi, { ...n.overlayProps.tableSelectionOverlay }) : null,
|
|
3304
|
+
n.overlayProps.codeBlockControls ? /* @__PURE__ */ Z(Vr, { ...n.overlayProps.codeBlockControls }) : null,
|
|
3305
|
+
n.overlayProps.innerToc ? /* @__PURE__ */ Z(Pi, { ...n.overlayProps.innerToc }) : null,
|
|
3306
|
+
n.overlayProps.mathEditorPopover ? /* @__PURE__ */ Z(bi, { ...n.overlayProps.mathEditorPopover }) : null,
|
|
3307
|
+
/* @__PURE__ */ Z(i, { editor: n.editor })
|
|
3101
3308
|
]
|
|
3102
3309
|
});
|
|
3103
3310
|
}
|
|
3104
3311
|
//#endregion
|
|
3105
|
-
export {
|
|
3312
|
+
export { Ui as MarkweaveEditor, Rr as createMarkweaveEditorExtensions, Rr as createMarkweaveReactEditorExtensions, Hi as useMarkweaveEditorController };
|