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