@markweave/react 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +19 -19
- package/dist/index.js +853 -1005
- package/dist/types/MarkweaveEditor.d.ts +1 -3
- package/dist/types/MarkweaveEditor.d.ts.map +1 -1
- package/dist/types/create-editor-extensions.d.ts +1 -6
- 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/media/image-node.d.ts +0 -2
- package/dist/types/media/image-node.d.ts.map +1 -1
- package/dist/types/media/video-node.d.ts +0 -2
- package/dist/types/media/video-node.d.ts.map +1 -1
- package/dist/types/ui/codeblock/CodeBlockControls.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,67 +1,63 @@
|
|
|
1
1
|
import { createMarkweaveEditorExtensions as e } from "markweave/internal/editor-core/create-editor-extensions";
|
|
2
2
|
import { getLocalizedSlashCommandSpecs as t, getMarkweaveMessages as n, normalizeMarkweaveLang as r } from "markweave/internal/i18n";
|
|
3
3
|
import { EditorContent as i, NodeViewWrapper as a, ReactNodeViewRenderer as o, useEditor as s } from "@tiptap/react";
|
|
4
|
-
import { AlertTriangle as c, AlignCenter as l, AlignJustify as u, AlignLeft as d, AlignRight as f, 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
|
|
5
|
-
import { useCallback as H, useEffect as U, useLayoutEffect as
|
|
6
|
-
import { detectUploadSource as
|
|
7
|
-
import { MarkweaveCoreImage as
|
|
8
|
-
import { getMarkweaveEditorModeState as
|
|
9
|
-
import { openMarkweaveImagePreview as
|
|
10
|
-
import { createMarkweaveLightweightImageNodeViewRenderer as Y } from "markweave/internal/plugins/media/lightweight-image-node-view";
|
|
11
|
-
import { resolveMarkweaveMediaSource as Ve } from "markweave/internal/plugins/media/media-source";
|
|
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 N, Info as P, Italic as F, Lightbulb as ee, Link2 as I, List as L, ListChecks as te, ListOrdered as R, Minus as z, MoreVertical as ne, Paperclip as re, Pencil as ie, Quote as ae, Replace as B, Sigma as V, SmilePlus as oe, Sparkles as se, Strikethrough as ce, Subscript as le, Superscript as ue, Table2 as de, Text as fe, Trash2 as pe, Type as me, Underline as he, Upload as ge, Video as _e } from "lucide-react";
|
|
5
|
+
import { useCallback as H, useEffect as U, useLayoutEffect as W, useMemo as G, useRef as K, useState as q, useSyncExternalStore as ve } from "react";
|
|
6
|
+
import { detectUploadSource as ye, getDirectUploadResult as be, resolveMarkweaveUploadResult as xe } from "markweave/internal/plugins/slash-command/upload";
|
|
7
|
+
import { MarkweaveCoreImage as Se, MarkweaveCoreVideo as Ce, attrsFromMarkweaveImageUploadResult as we, attrsFromMarkweaveVideoUploadResult as Te, attrsFromMarkweaveVideoUrl as Ee, clampMarkweaveImageWidth as De, createMarkweaveImageUploadRequest as Oe, createMarkweaveVideoUploadRequest as ke, downloadMarkweaveImage as Ae, markweaveVideoIframeAllow as je, normalizeMarkweaveCoreImageAlign as Me, normalizeMarkweaveVideoEmbedUrl as J, numberAttribute as Ne, stringAttribute as Y } from "markweave/internal/plugins/media/core-media-nodes";
|
|
8
|
+
import { getMarkweaveEditorModeState as Pe, 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";
|
|
12
10
|
import { Fragment as X, jsx as Z, jsxs as Q } from "react/jsx-runtime";
|
|
13
|
-
import { createMarkweaveAdapterMediaExtensions as
|
|
14
|
-
import { normalizeMarkweaveLinkCardAttrs as
|
|
15
|
-
import { openMarkweaveLinkCardComposer as
|
|
16
|
-
import { MarkweaveLinkCard as
|
|
17
|
-
import { isEditorComposing as
|
|
18
|
-
import { createMarkweaveEditorUpdatePayload as
|
|
19
|
-
import { openMarkweaveReadonlyLinkFromEvent as
|
|
20
|
-
import { createMarkweaveEditorRuntimeSnapshot as
|
|
21
|
-
import { advanceFloatingToolbarMotionState as
|
|
22
|
-
import { codeBlockCollapsePluginKey as
|
|
23
|
-
import { isMermaidInlinePreviewTransaction as
|
|
24
|
-
import { getMermaidPreviewState as
|
|
25
|
-
import { applyMarkweaveMathLatex as
|
|
26
|
-
import { filterSlashCommands as
|
|
27
|
-
import { getSlashCommandKeyboardAction as
|
|
28
|
-
import { executeSlashCommand as
|
|
29
|
-
import { initialSlashCommandState as
|
|
30
|
-
import { getFirstTableDebugSnapshot as
|
|
31
|
-
import { focusFirstTableBodyCell as
|
|
32
|
-
import { getTableFocusState as
|
|
33
|
-
import { getTableSelectionOverlayState as
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
41
|
-
import {
|
|
42
|
-
import {
|
|
43
|
-
import {
|
|
44
|
-
import { splitMarkweaveLargeMarkdown as Er } from "markweave/internal/core/large-document";
|
|
45
|
-
import { createMarkweaveSearchController as Dr } from "markweave/internal/plugins/search/search-controller";
|
|
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 { normalizeMarkweaveCanvasColor as gr, normalizeMarkweaveTheme as _r } from "markweave/internal/core/theme";
|
|
41
|
+
import { createMarkweaveSearchController as vr } from "markweave/internal/plugins/search/search-controller";
|
|
46
42
|
//#region src/editor-mode-state.ts
|
|
47
|
-
var
|
|
43
|
+
var yr = {
|
|
48
44
|
mode: "live",
|
|
49
45
|
editable: !0
|
|
50
46
|
};
|
|
51
|
-
function
|
|
52
|
-
return
|
|
47
|
+
function br(e) {
|
|
48
|
+
return ve((t) => Re(e, t), () => Pe(e), () => yr);
|
|
53
49
|
}
|
|
54
50
|
//#endregion
|
|
55
51
|
//#region src/media/image-node.tsx
|
|
56
|
-
var
|
|
57
|
-
function
|
|
52
|
+
var xr = Me;
|
|
53
|
+
function Sr(e) {
|
|
58
54
|
return e instanceof Element && !!e.closest("[data-markweave-image-ui=\"true\"]");
|
|
59
55
|
}
|
|
60
|
-
function
|
|
61
|
-
let { deleteNode: t, editor: r, getPos: i, node: o, selected: s, updateAttributes: c } = e, l = e.extension.options, u = l.messages ?? n("zh"), d = u.image, f =
|
|
62
|
-
|
|
63
|
-
src:
|
|
64
|
-
alt:
|
|
56
|
+
function Cr(e) {
|
|
57
|
+
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(br(r)), p = Y(o.attrs.src), m = xr(o.attrs.align), h = Ne(o.attrs.width), g = Y(o.attrs.caption), _ = K(null), v = K(null), [y, b] = q(!1), [x, S] = q(!1), [C, w] = q(!1), [T, D] = q(""), [O, k] = q(null), [A, j] = q(!1), [M, N] = q(!!g), [P, F] = q(g ?? ""), ee = f && (!p || x), I = () => {
|
|
58
|
+
p && ze({
|
|
59
|
+
src: p,
|
|
60
|
+
alt: Y(o.attrs.alt) ?? "",
|
|
65
61
|
messages: {
|
|
66
62
|
dialogAriaLabel: d.previewDialogAriaLabel,
|
|
67
63
|
zoomOut: d.previewZoomOut,
|
|
@@ -72,62 +68,62 @@ function Mr(e) {
|
|
|
72
68
|
});
|
|
73
69
|
};
|
|
74
70
|
U(() => {
|
|
75
|
-
|
|
76
|
-
}, [g,
|
|
77
|
-
let
|
|
71
|
+
M || F(g ?? "");
|
|
72
|
+
}, [g, M]);
|
|
73
|
+
let L = () => {
|
|
78
74
|
if (!f) return;
|
|
79
75
|
let e = i();
|
|
80
76
|
typeof e == "number" && r.chain().focus().setNodeSelection(e).run();
|
|
81
|
-
},
|
|
77
|
+
}, te = () => {
|
|
82
78
|
if (f) {
|
|
83
|
-
if (
|
|
84
|
-
|
|
79
|
+
if (D(""), k(null), w(!1), p) {
|
|
80
|
+
S(!1);
|
|
85
81
|
return;
|
|
86
82
|
}
|
|
87
83
|
t();
|
|
88
84
|
}
|
|
89
85
|
}, R = async (e) => {
|
|
90
86
|
if (f) {
|
|
91
|
-
|
|
87
|
+
k(null), j(!0);
|
|
92
88
|
try {
|
|
93
|
-
let t = await
|
|
94
|
-
c(
|
|
89
|
+
let t = await xe(Oe(e, p && x ? "image-replace" : "image-insert"), l.onUpload);
|
|
90
|
+
c(we(o.attrs, t)), S(!1), D("");
|
|
95
91
|
} catch (e) {
|
|
96
|
-
|
|
92
|
+
k(e instanceof Error ? e.message : d.uploadFailedError);
|
|
97
93
|
} finally {
|
|
98
|
-
|
|
94
|
+
j(!1), w(!1);
|
|
99
95
|
}
|
|
100
96
|
}
|
|
101
|
-
},
|
|
97
|
+
}, z = () => {
|
|
102
98
|
if (f) {
|
|
103
|
-
if (!
|
|
104
|
-
|
|
99
|
+
if (!T.trim()) {
|
|
100
|
+
k(d.uploadRequiredError);
|
|
105
101
|
return;
|
|
106
102
|
}
|
|
107
|
-
R(
|
|
103
|
+
R(ye(T));
|
|
108
104
|
}
|
|
109
|
-
},
|
|
105
|
+
}, ne = (e) => {
|
|
110
106
|
!f || !e || R({
|
|
111
107
|
type: "file",
|
|
112
108
|
file: e,
|
|
113
109
|
mimeType: e.type
|
|
114
110
|
});
|
|
115
|
-
},
|
|
116
|
-
|
|
117
|
-
},
|
|
118
|
-
e.preventDefault(), e.stopPropagation(), f &&
|
|
119
|
-
},
|
|
120
|
-
f && (
|
|
121
|
-
},
|
|
122
|
-
f && (
|
|
123
|
-
},
|
|
111
|
+
}, re = (e) => {
|
|
112
|
+
ne(e.currentTarget.files?.[0] ?? null), e.currentTarget.value = "";
|
|
113
|
+
}, ie = (e) => {
|
|
114
|
+
e.preventDefault(), e.stopPropagation(), f && ne(e.dataTransfer.files?.[0] ?? null);
|
|
115
|
+
}, ae = () => {
|
|
116
|
+
f && (N((e) => !e), M || F(g ?? ""));
|
|
117
|
+
}, B = (e) => {
|
|
118
|
+
f && (F(e), c({ caption: e.trim() ? e : null }));
|
|
119
|
+
}, V = (e, t) => {
|
|
124
120
|
if (t.preventDefault(), t.stopPropagation(), !f) return;
|
|
125
|
-
|
|
121
|
+
L();
|
|
126
122
|
let n = _.current;
|
|
127
123
|
if (!n) return;
|
|
128
124
|
let r = t.clientX, i = n.getBoundingClientRect().width || h || 320, a = n.closest(".markweave-editor-surface")?.getBoundingClientRect().width ?? n.parentElement?.getBoundingClientRect().width ?? i, o = (t) => {
|
|
129
125
|
let n = e === "right" ? t.clientX - r : r - t.clientX;
|
|
130
|
-
c({ width:
|
|
126
|
+
c({ width: De(i + n, a) });
|
|
131
127
|
}, s = () => {
|
|
132
128
|
window.removeEventListener("pointermove", o), window.removeEventListener("pointerup", s);
|
|
133
129
|
};
|
|
@@ -139,66 +135,59 @@ function Mr(e) {
|
|
|
139
135
|
"data-testid": "markweave-image-node",
|
|
140
136
|
"data-align": m,
|
|
141
137
|
"data-selected": f && s ? "true" : "false",
|
|
142
|
-
"data-hovered":
|
|
143
|
-
"data-empty":
|
|
144
|
-
onPointerEnter: () =>
|
|
145
|
-
onPointerLeave: () =>
|
|
138
|
+
"data-hovered": y ? "true" : "false",
|
|
139
|
+
"data-empty": ee ? "true" : "false",
|
|
140
|
+
onPointerEnter: () => b(!0),
|
|
141
|
+
onPointerLeave: () => b(!1),
|
|
146
142
|
onMouseDown: (e) => {
|
|
147
|
-
f && !
|
|
143
|
+
f && !Sr(e.target) && L();
|
|
148
144
|
},
|
|
149
|
-
children:
|
|
150
|
-
dragActive:
|
|
151
|
-
error:
|
|
152
|
-
inputValue:
|
|
153
|
-
isSubmitting:
|
|
154
|
-
fileInputRef:
|
|
145
|
+
children: ee ? /* @__PURE__ */ Z(wr, {
|
|
146
|
+
dragActive: C,
|
|
147
|
+
error: O,
|
|
148
|
+
inputValue: T,
|
|
149
|
+
isSubmitting: A,
|
|
150
|
+
fileInputRef: v,
|
|
155
151
|
messages: u,
|
|
156
|
-
onCancel:
|
|
157
|
-
onDrop:
|
|
158
|
-
onDragActiveChange:
|
|
159
|
-
onFileChange:
|
|
160
|
-
onInputChange:
|
|
161
|
-
onSubmit:
|
|
152
|
+
onCancel: te,
|
|
153
|
+
onDrop: ie,
|
|
154
|
+
onDragActiveChange: w,
|
|
155
|
+
onFileChange: re,
|
|
156
|
+
onInputChange: D,
|
|
157
|
+
onSubmit: z
|
|
162
158
|
}) : /* @__PURE__ */ Q(X, { children: [
|
|
163
|
-
f ? /* @__PURE__ */ Z(
|
|
159
|
+
f ? /* @__PURE__ */ Z(Tr, {
|
|
164
160
|
align: m,
|
|
165
|
-
captionActive:
|
|
161
|
+
captionActive: M || !!g,
|
|
166
162
|
messages: u,
|
|
167
163
|
onAlign: (e) => c({ align: e }),
|
|
168
|
-
onCaption:
|
|
164
|
+
onCaption: ae,
|
|
169
165
|
onDelete: t,
|
|
170
166
|
onDownload: () => {
|
|
171
|
-
|
|
167
|
+
p && Ae(p);
|
|
172
168
|
},
|
|
173
|
-
onPreview:
|
|
169
|
+
onPreview: I,
|
|
174
170
|
onReplace: () => {
|
|
175
|
-
|
|
171
|
+
D(""), k(null), S(!0);
|
|
176
172
|
}
|
|
177
173
|
}) : null,
|
|
178
174
|
/* @__PURE__ */ Q("div", {
|
|
179
175
|
className: "markweave-image-box",
|
|
180
176
|
ref: _,
|
|
181
|
-
style: {
|
|
182
|
-
...h ? { width: `${h}px` } : null,
|
|
183
|
-
...v?.width && v.height ? { aspectRatio: `${v.width} / ${v.height}` } : null
|
|
184
|
-
},
|
|
177
|
+
style: h ? { width: `${h}px` } : void 0,
|
|
185
178
|
children: [
|
|
186
|
-
|
|
179
|
+
p ? /* @__PURE__ */ Z("img", {
|
|
187
180
|
className: "markweave-image",
|
|
188
|
-
src:
|
|
189
|
-
alt:
|
|
190
|
-
title:
|
|
191
|
-
draggable: !1
|
|
192
|
-
loading: "lazy",
|
|
193
|
-
decoding: "async",
|
|
194
|
-
width: v?.width,
|
|
195
|
-
height: v?.height
|
|
181
|
+
src: p,
|
|
182
|
+
alt: Y(o.attrs.alt) ?? "",
|
|
183
|
+
title: Y(o.attrs.title) ?? void 0,
|
|
184
|
+
draggable: !1
|
|
196
185
|
}) : /* @__PURE__ */ Z("div", {
|
|
197
186
|
className: "markweave-image-readonly-empty",
|
|
198
187
|
"data-testid": "markweave-image-readonly-empty",
|
|
199
188
|
"aria-hidden": "true"
|
|
200
189
|
}),
|
|
201
|
-
!f &&
|
|
190
|
+
!f && p ? /* @__PURE__ */ Q("button", {
|
|
202
191
|
type: "button",
|
|
203
192
|
className: "markweave-image-preview-trigger",
|
|
204
193
|
"data-testid": "markweave-image-preview",
|
|
@@ -206,7 +195,7 @@ function Mr(e) {
|
|
|
206
195
|
"aria-label": d.preview,
|
|
207
196
|
title: d.preview,
|
|
208
197
|
onMouseDown: (e) => e.preventDefault(),
|
|
209
|
-
onClick:
|
|
198
|
+
onClick: I,
|
|
210
199
|
children: [/* @__PURE__ */ Z(E, {
|
|
211
200
|
size: 16,
|
|
212
201
|
strokeWidth: 1.8
|
|
@@ -216,28 +205,28 @@ function Mr(e) {
|
|
|
216
205
|
children: d.preview
|
|
217
206
|
})]
|
|
218
207
|
}) : null,
|
|
219
|
-
f ? /* @__PURE__ */ Z(
|
|
208
|
+
f ? /* @__PURE__ */ Z(Dr, {
|
|
220
209
|
side: "left",
|
|
221
210
|
messages: u,
|
|
222
|
-
onPointerDown:
|
|
211
|
+
onPointerDown: V
|
|
223
212
|
}) : null,
|
|
224
|
-
f ? /* @__PURE__ */ Z(
|
|
213
|
+
f ? /* @__PURE__ */ Z(Dr, {
|
|
225
214
|
side: "right",
|
|
226
215
|
messages: u,
|
|
227
|
-
onPointerDown:
|
|
216
|
+
onPointerDown: V
|
|
228
217
|
}) : null
|
|
229
218
|
]
|
|
230
219
|
}),
|
|
231
|
-
f && (
|
|
220
|
+
f && (M || g) ? /* @__PURE__ */ Z("input", {
|
|
232
221
|
className: "markweave-image-caption-input",
|
|
233
222
|
"data-markweave-image-ui": "true",
|
|
234
223
|
"data-testid": "markweave-image-caption-input",
|
|
235
|
-
value:
|
|
224
|
+
value: P,
|
|
236
225
|
placeholder: d.captionPlaceholder,
|
|
237
226
|
"aria-label": d.captionAriaLabel,
|
|
238
|
-
onChange: (e) =>
|
|
227
|
+
onChange: (e) => B(e.currentTarget.value),
|
|
239
228
|
onKeyDown: (e) => {
|
|
240
|
-
e.key === "Escape" && (e.preventDefault(),
|
|
229
|
+
e.key === "Escape" && (e.preventDefault(), N(!1));
|
|
241
230
|
}
|
|
242
231
|
}) : g ? /* @__PURE__ */ Z("figcaption", {
|
|
243
232
|
className: "markweave-image-caption",
|
|
@@ -247,7 +236,7 @@ function Mr(e) {
|
|
|
247
236
|
] })
|
|
248
237
|
});
|
|
249
238
|
}
|
|
250
|
-
function
|
|
239
|
+
function wr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitting: i, messages: a, onCancel: o, onDragActiveChange: s, onDrop: c, onFileChange: l, onInputChange: u, onSubmit: d }) {
|
|
251
240
|
let f = a.image;
|
|
252
241
|
return /* @__PURE__ */ Q("section", {
|
|
253
242
|
className: "markweave-image-upload-placeholder",
|
|
@@ -329,7 +318,7 @@ function Nr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
|
|
|
329
318
|
]
|
|
330
319
|
});
|
|
331
320
|
}
|
|
332
|
-
function
|
|
321
|
+
function Tr({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i, onDelete: a, onDownload: o, onPreview: s, onReplace: c }) {
|
|
333
322
|
let u = n.image;
|
|
334
323
|
return /* @__PURE__ */ Q("div", {
|
|
335
324
|
className: "markweave-image-toolbar",
|
|
@@ -337,21 +326,21 @@ function Pr({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i,
|
|
|
337
326
|
"data-markweave-image-ui": "true",
|
|
338
327
|
"aria-label": u.toolsAriaLabel,
|
|
339
328
|
children: [
|
|
340
|
-
/* @__PURE__ */ Z(
|
|
329
|
+
/* @__PURE__ */ Z(Er, {
|
|
341
330
|
testId: "markweave-image-align-left",
|
|
342
331
|
label: u.alignLeft,
|
|
343
332
|
icon: d,
|
|
344
333
|
active: e === "left",
|
|
345
334
|
onClick: () => r("left")
|
|
346
335
|
}),
|
|
347
|
-
/* @__PURE__ */ Z(
|
|
336
|
+
/* @__PURE__ */ Z(Er, {
|
|
348
337
|
testId: "markweave-image-align-center",
|
|
349
338
|
label: u.alignCenter,
|
|
350
339
|
icon: l,
|
|
351
340
|
active: e === "center",
|
|
352
341
|
onClick: () => r("center")
|
|
353
342
|
}),
|
|
354
|
-
/* @__PURE__ */ Z(
|
|
343
|
+
/* @__PURE__ */ Z(Er, {
|
|
355
344
|
testId: "markweave-image-align-right",
|
|
356
345
|
label: u.alignRight,
|
|
357
346
|
icon: f,
|
|
@@ -362,36 +351,36 @@ function Pr({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i,
|
|
|
362
351
|
className: "markweave-image-toolbar-divider",
|
|
363
352
|
"aria-hidden": "true"
|
|
364
353
|
}),
|
|
365
|
-
/* @__PURE__ */ Z(
|
|
354
|
+
/* @__PURE__ */ Z(Er, {
|
|
366
355
|
testId: "markweave-image-caption",
|
|
367
356
|
label: u.caption,
|
|
368
357
|
icon: h,
|
|
369
358
|
active: t,
|
|
370
359
|
onClick: i
|
|
371
360
|
}),
|
|
372
|
-
/* @__PURE__ */ Z(
|
|
361
|
+
/* @__PURE__ */ Z(Er, {
|
|
373
362
|
testId: "markweave-image-preview",
|
|
374
363
|
label: u.preview,
|
|
375
364
|
icon: E,
|
|
376
365
|
onClick: s
|
|
377
366
|
}),
|
|
378
|
-
/* @__PURE__ */ Z(
|
|
367
|
+
/* @__PURE__ */ Z(Er, {
|
|
379
368
|
testId: "markweave-image-download",
|
|
380
369
|
label: u.download,
|
|
381
370
|
icon: w,
|
|
382
371
|
onClick: o
|
|
383
372
|
}),
|
|
384
|
-
/* @__PURE__ */ Z(
|
|
373
|
+
/* @__PURE__ */ Z(Er, {
|
|
385
374
|
testId: "markweave-image-replace",
|
|
386
375
|
label: u.replace,
|
|
387
|
-
icon:
|
|
376
|
+
icon: B,
|
|
388
377
|
onClick: c
|
|
389
378
|
}),
|
|
390
379
|
/* @__PURE__ */ Z("span", {
|
|
391
380
|
className: "markweave-image-toolbar-divider",
|
|
392
381
|
"aria-hidden": "true"
|
|
393
382
|
}),
|
|
394
|
-
/* @__PURE__ */ Z(
|
|
383
|
+
/* @__PURE__ */ Z(Er, {
|
|
395
384
|
testId: "markweave-image-delete",
|
|
396
385
|
label: u.delete,
|
|
397
386
|
icon: pe,
|
|
@@ -400,7 +389,7 @@ function Pr({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i,
|
|
|
400
389
|
]
|
|
401
390
|
});
|
|
402
391
|
}
|
|
403
|
-
function
|
|
392
|
+
function Er({ active: e = !1, icon: t, label: n, onClick: r, testId: i }) {
|
|
404
393
|
return /* @__PURE__ */ Q("button", {
|
|
405
394
|
type: "button",
|
|
406
395
|
"aria-label": n,
|
|
@@ -419,7 +408,7 @@ function Fr({ active: e = !1, icon: t, label: n, onClick: r, testId: i }) {
|
|
|
419
408
|
})]
|
|
420
409
|
});
|
|
421
410
|
}
|
|
422
|
-
function
|
|
411
|
+
function Dr({ messages: e, onPointerDown: t, side: n }) {
|
|
423
412
|
return /* @__PURE__ */ Z("button", {
|
|
424
413
|
type: "button",
|
|
425
414
|
className: "markweave-image-resize-handle",
|
|
@@ -430,95 +419,42 @@ function Ir({ messages: e, onPointerDown: t, side: n }) {
|
|
|
430
419
|
onPointerDown: (e) => t(n, e)
|
|
431
420
|
});
|
|
432
421
|
}
|
|
433
|
-
var
|
|
422
|
+
var Or = Se.extend({
|
|
434
423
|
addOptions() {
|
|
435
424
|
return {
|
|
436
425
|
...this.parent?.(),
|
|
437
426
|
messages: n("zh"),
|
|
438
|
-
onUpload: void 0
|
|
439
|
-
resolveMediaSource: void 0
|
|
427
|
+
onUpload: void 0
|
|
440
428
|
};
|
|
441
429
|
},
|
|
442
430
|
addNodeView() {
|
|
443
|
-
|
|
444
|
-
let e = o(Mr, { stopEvent: ({ event: e }) => jr(e.target) }), t = this.options.resolveMediaSource;
|
|
445
|
-
if (!t) return e;
|
|
446
|
-
let r = Y({
|
|
447
|
-
messages: this.options.messages ?? n("zh"),
|
|
448
|
-
onUpload: this.options.onUpload,
|
|
449
|
-
resolveMediaSource: t
|
|
450
|
-
});
|
|
451
|
-
return (t) => J(t.node.attrs.src) ? r(t) : e(t);
|
|
431
|
+
return typeof document > "u" ? null : o(Cr, { stopEvent: ({ event: e }) => Sr(e.target) });
|
|
452
432
|
}
|
|
453
433
|
});
|
|
454
|
-
function Rr(e, t, n, r) {
|
|
455
|
-
let [i, a] = K(t ? "background" : "visible"), [o, s] = K(() => !t && e ? { src: e } : null);
|
|
456
|
-
return U(() => {
|
|
457
|
-
s(!t && e ? { src: e } : null), a(t ? "background" : "visible");
|
|
458
|
-
}, [t, e]), U(() => {
|
|
459
|
-
if (!t || !e) return;
|
|
460
|
-
if (r) {
|
|
461
|
-
a("visible");
|
|
462
|
-
return;
|
|
463
|
-
}
|
|
464
|
-
let i = n.current;
|
|
465
|
-
if (!i || typeof IntersectionObserver > "u") {
|
|
466
|
-
a("visible");
|
|
467
|
-
return;
|
|
468
|
-
}
|
|
469
|
-
let o = new IntersectionObserver((e) => {
|
|
470
|
-
let t = e[0];
|
|
471
|
-
if (!t?.isIntersecting) return;
|
|
472
|
-
let n = t.boundingClientRect, r = n.bottom >= 0 && n.top <= window.innerHeight;
|
|
473
|
-
a(r ? "visible" : "nearby");
|
|
474
|
-
}, { rootMargin: "300% 0px" });
|
|
475
|
-
return o.observe(i), () => o.disconnect();
|
|
476
|
-
}, [
|
|
477
|
-
n,
|
|
478
|
-
t,
|
|
479
|
-
r,
|
|
480
|
-
e
|
|
481
|
-
]), U(() => {
|
|
482
|
-
if (!t || !e || i === "background") return;
|
|
483
|
-
let n = new AbortController();
|
|
484
|
-
return Ve(t, {
|
|
485
|
-
kind: "image",
|
|
486
|
-
priority: i,
|
|
487
|
-
signal: n.signal,
|
|
488
|
-
src: e
|
|
489
|
-
}).then((e) => {
|
|
490
|
-
n.signal.aborted || s(e);
|
|
491
|
-
}), () => n.abort();
|
|
492
|
-
}, [
|
|
493
|
-
i,
|
|
494
|
-
t,
|
|
495
|
-
e
|
|
496
|
-
]), o;
|
|
497
|
-
}
|
|
498
434
|
//#endregion
|
|
499
435
|
//#region src/media/video-node.tsx
|
|
500
|
-
function
|
|
436
|
+
function kr(e) {
|
|
501
437
|
return e instanceof Element && !!e.closest("[data-markweave-video-ui=\"true\"], iframe[data-markweave-video-embed], video[data-markweave-video]");
|
|
502
438
|
}
|
|
503
|
-
function
|
|
504
|
-
let { deleteNode: t, editor: r, getPos: i, node: o, selected: s, updateAttributes: c } = e, l = e.extension.options, u = l.messages ?? n("zh"), d = u.video, f =
|
|
439
|
+
function Ar(e) {
|
|
440
|
+
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(br(r)), p = Y(o.attrs.src), m = Y(o.attrs.embedUrl), h = Y(o.attrs.provider), g = m ? J(m, h) : null, _ = Y(o.attrs.mimeType), v = Y(o.attrs.title), y = K(null), [b, x] = q(!1), [S, C] = q(""), [w, T] = q(null), [E, D] = q(!1), O = f && !p, k = () => {
|
|
505
441
|
if (!f) return;
|
|
506
442
|
let e = i();
|
|
507
443
|
typeof e == "number" && r.chain().focus().setNodeSelection(e).run();
|
|
508
444
|
}, A = (e) => {
|
|
509
|
-
f && (
|
|
445
|
+
f && (kr(e.target) || (e.preventDefault(), k()));
|
|
510
446
|
}, j = (e) => {
|
|
511
447
|
f && (e.key === "Delete" || e.key === "Backspace") && s && (e.preventDefault(), t());
|
|
512
448
|
}, M = async (e) => {
|
|
513
449
|
if (!(!f || !e)) {
|
|
514
450
|
T(null), D(!0);
|
|
515
451
|
try {
|
|
516
|
-
let t = await
|
|
452
|
+
let t = await xe(ke({
|
|
517
453
|
type: "file",
|
|
518
454
|
file: e,
|
|
519
455
|
mimeType: e.type
|
|
520
456
|
}), l.onUpload);
|
|
521
|
-
c(
|
|
457
|
+
c(Te(t)), C("");
|
|
522
458
|
} catch (e) {
|
|
523
459
|
T(e instanceof Error ? e.message : d.uploadFailedError);
|
|
524
460
|
} finally {
|
|
@@ -532,7 +468,7 @@ function Br(e) {
|
|
|
532
468
|
"data-testid": "markweave-video-node",
|
|
533
469
|
"data-empty": "true",
|
|
534
470
|
"data-selected": "false",
|
|
535
|
-
children: /* @__PURE__ */ Z(
|
|
471
|
+
children: /* @__PURE__ */ Z(jr, {
|
|
536
472
|
dragActive: b,
|
|
537
473
|
error: w,
|
|
538
474
|
fileInputRef: y,
|
|
@@ -550,7 +486,7 @@ function Br(e) {
|
|
|
550
486
|
onInputChange: C,
|
|
551
487
|
onSubmit: () => {
|
|
552
488
|
if (!f) return;
|
|
553
|
-
let e =
|
|
489
|
+
let e = Ee(S);
|
|
554
490
|
if (!e) {
|
|
555
491
|
T(d.unsupportedUrlError);
|
|
556
492
|
return;
|
|
@@ -613,7 +549,7 @@ function Br(e) {
|
|
|
613
549
|
})
|
|
614
550
|
});
|
|
615
551
|
}
|
|
616
|
-
function
|
|
552
|
+
function jr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitting: i, messages: a, onCancel: o, onDragActiveChange: s, onDrop: c, onFileChange: l, onInputChange: u, onSubmit: d }) {
|
|
617
553
|
let f = a.video;
|
|
618
554
|
return /* @__PURE__ */ Q("section", {
|
|
619
555
|
className: "markweave-video-upload-placeholder",
|
|
@@ -695,45 +631,44 @@ function Vr({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
|
|
|
695
631
|
]
|
|
696
632
|
});
|
|
697
633
|
}
|
|
698
|
-
var
|
|
634
|
+
var Mr = Ce.extend({
|
|
699
635
|
addOptions() {
|
|
700
636
|
return {
|
|
701
637
|
...this.parent?.(),
|
|
702
638
|
messages: n("zh"),
|
|
703
|
-
onUpload: void 0
|
|
704
|
-
resolveMediaSource: void 0
|
|
639
|
+
onUpload: void 0
|
|
705
640
|
};
|
|
706
641
|
},
|
|
707
642
|
addNodeView() {
|
|
708
|
-
return typeof document > "u" ? null : o(
|
|
643
|
+
return typeof document > "u" ? null : o(Ar, { stopEvent: ({ event: e }) => kr(e.target) });
|
|
709
644
|
}
|
|
710
645
|
});
|
|
711
646
|
//#endregion
|
|
712
647
|
//#region src/link-card-node.tsx
|
|
713
|
-
function
|
|
648
|
+
function Nr(e) {
|
|
714
649
|
return e instanceof Element && !!e.closest("[data-markweave-link-card-ui=\"true\"]");
|
|
715
650
|
}
|
|
716
|
-
function
|
|
651
|
+
function Pr(e) {
|
|
717
652
|
return typeof navigator < "u" && navigator.clipboard?.writeText ? navigator.clipboard.writeText(e).catch(() => void 0) : Promise.resolve();
|
|
718
653
|
}
|
|
719
|
-
function
|
|
654
|
+
function Fr(e) {
|
|
720
655
|
!e || typeof window > "u" || window.open(e, "_blank", "noopener,noreferrer");
|
|
721
656
|
}
|
|
722
|
-
function
|
|
657
|
+
function Ir(e) {
|
|
723
658
|
try {
|
|
724
659
|
return new URL(e).host;
|
|
725
660
|
} catch {
|
|
726
661
|
return e;
|
|
727
662
|
}
|
|
728
663
|
}
|
|
729
|
-
function
|
|
730
|
-
let { deleteNode: t, editor: r, getPos: i, node: o, updateAttributes: s } = e, c = e.extension.options, l = c.messages ?? n("zh"), u = l.linkCard, d =
|
|
664
|
+
function Lr(e) {
|
|
665
|
+
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(br(r)), f = Ve(o.attrs), [p, m] = q(!1), [h, g] = q(!1), [_, v] = q(!1), [y, b] = q(f?.title ?? ""), [x, C] = q(f?.href ?? ""), w = K(null);
|
|
731
666
|
if (U(() => () => w.current?.abort(), []), U(() => {
|
|
732
667
|
b(f?.title ?? ""), C(f?.href ?? ""), v(!1);
|
|
733
668
|
}, [f?.href, f?.title]), !f) return null;
|
|
734
669
|
let T = async (e) => {
|
|
735
670
|
e.preventDefault();
|
|
736
|
-
let t =
|
|
671
|
+
let t = Ve({
|
|
737
672
|
...f,
|
|
738
673
|
href: x,
|
|
739
674
|
title: y
|
|
@@ -748,15 +683,15 @@ function qr(e) {
|
|
|
748
683
|
title: t.title,
|
|
749
684
|
signal: n.signal
|
|
750
685
|
});
|
|
751
|
-
!n.signal.aborted && e && s(
|
|
686
|
+
!n.signal.aborted && e && s(Ve({
|
|
752
687
|
...t,
|
|
753
688
|
...e
|
|
754
689
|
}) ?? t);
|
|
755
690
|
} catch {}
|
|
756
691
|
}, E = () => {
|
|
757
692
|
let e = i();
|
|
758
|
-
typeof e == "number" &&
|
|
759
|
-
}, D = _ ? null : f.imageUrl, O =
|
|
693
|
+
typeof e == "number" && Ue(r, e);
|
|
694
|
+
}, D = _ ? null : f.imageUrl, O = Ir(f.href);
|
|
760
695
|
return /* @__PURE__ */ Q(a, {
|
|
761
696
|
as: "article",
|
|
762
697
|
className: "markweave-link-card",
|
|
@@ -767,10 +702,10 @@ function qr(e) {
|
|
|
767
702
|
onMouseEnter: () => m(!0),
|
|
768
703
|
onMouseLeave: () => m(!1),
|
|
769
704
|
onMouseDown: (e) => {
|
|
770
|
-
|
|
705
|
+
Nr(e.target) || e.preventDefault();
|
|
771
706
|
},
|
|
772
707
|
onClick: (e) => {
|
|
773
|
-
|
|
708
|
+
Nr(e.target) || (e.preventDefault(), Fr(f.href));
|
|
774
709
|
},
|
|
775
710
|
children: [
|
|
776
711
|
/* @__PURE__ */ Q("a", {
|
|
@@ -808,24 +743,24 @@ function qr(e) {
|
|
|
808
743
|
"data-markweave-link-card-ui": "true",
|
|
809
744
|
"aria-label": u.toolsAriaLabel,
|
|
810
745
|
children: [
|
|
811
|
-
/* @__PURE__ */ Z(
|
|
746
|
+
/* @__PURE__ */ Z(Rr, {
|
|
812
747
|
label: u.convertToLink,
|
|
813
|
-
icon:
|
|
748
|
+
icon: I,
|
|
814
749
|
onClick: E,
|
|
815
750
|
testId: "markweave-link-card-convert"
|
|
816
751
|
}),
|
|
817
|
-
/* @__PURE__ */ Z(
|
|
752
|
+
/* @__PURE__ */ Z(Rr, {
|
|
818
753
|
label: u.copyAddress,
|
|
819
754
|
icon: S,
|
|
820
|
-
onClick: () => void
|
|
755
|
+
onClick: () => void Pr(f.href),
|
|
821
756
|
testId: "markweave-link-card-copy"
|
|
822
757
|
}),
|
|
823
|
-
/* @__PURE__ */ Z(
|
|
758
|
+
/* @__PURE__ */ Z(Rr, {
|
|
824
759
|
label: u.edit,
|
|
825
|
-
icon:
|
|
760
|
+
icon: ie,
|
|
826
761
|
onClick: (e) => {
|
|
827
762
|
let t = i();
|
|
828
|
-
typeof t == "number" &&
|
|
763
|
+
typeof t == "number" && We({
|
|
829
764
|
anchor: e.currentTarget,
|
|
830
765
|
editor: r,
|
|
831
766
|
messages: l,
|
|
@@ -838,7 +773,7 @@ function qr(e) {
|
|
|
838
773
|
},
|
|
839
774
|
testId: "markweave-link-card-edit"
|
|
840
775
|
}),
|
|
841
|
-
/* @__PURE__ */ Z(
|
|
776
|
+
/* @__PURE__ */ Z(Rr, {
|
|
842
777
|
label: u.delete,
|
|
843
778
|
icon: pe,
|
|
844
779
|
onClick: t,
|
|
@@ -867,15 +802,15 @@ function qr(e) {
|
|
|
867
802
|
/* @__PURE__ */ Z("button", {
|
|
868
803
|
type: "submit",
|
|
869
804
|
"aria-label": u.edit,
|
|
870
|
-
disabled: !
|
|
871
|
-
children: /* @__PURE__ */ Z(
|
|
805
|
+
disabled: !He(x),
|
|
806
|
+
children: /* @__PURE__ */ Z(I, { size: 16 })
|
|
872
807
|
})
|
|
873
808
|
]
|
|
874
809
|
}) : null
|
|
875
810
|
]
|
|
876
811
|
});
|
|
877
812
|
}
|
|
878
|
-
function
|
|
813
|
+
function Rr({ icon: e, label: t, onClick: n, testId: r }) {
|
|
879
814
|
return /* @__PURE__ */ Q("button", {
|
|
880
815
|
type: "button",
|
|
881
816
|
"aria-label": t,
|
|
@@ -892,7 +827,7 @@ function Jr({ icon: e, label: t, onClick: n, testId: r }) {
|
|
|
892
827
|
})]
|
|
893
828
|
});
|
|
894
829
|
}
|
|
895
|
-
var
|
|
830
|
+
var zr = Ge.extend({
|
|
896
831
|
addOptions() {
|
|
897
832
|
return {
|
|
898
833
|
...this.parent?.(),
|
|
@@ -901,33 +836,32 @@ var Yr = qe.extend({
|
|
|
901
836
|
};
|
|
902
837
|
},
|
|
903
838
|
addNodeView() {
|
|
904
|
-
return typeof document > "u" ? null : o(
|
|
839
|
+
return typeof document > "u" ? null : o(Lr, { stopEvent: ({ event: e }) => Nr(e.target) });
|
|
905
840
|
}
|
|
906
841
|
});
|
|
907
842
|
//#endregion
|
|
908
843
|
//#region src/create-editor-extensions.ts
|
|
909
|
-
function
|
|
844
|
+
function Br(t = {}) {
|
|
910
845
|
return e({
|
|
911
846
|
lang: t.lang,
|
|
912
847
|
onImageUpload: t.onImageUpload,
|
|
913
|
-
linkCardExtension:
|
|
848
|
+
linkCardExtension: zr.configure({
|
|
914
849
|
lang: t.lang,
|
|
915
850
|
messages: n(t.lang),
|
|
916
851
|
resolver: t.linkCardResolver
|
|
917
852
|
}),
|
|
918
|
-
mediaExtensions:
|
|
919
|
-
image:
|
|
920
|
-
video:
|
|
853
|
+
mediaExtensions: Be({
|
|
854
|
+
image: Or,
|
|
855
|
+
video: Mr,
|
|
921
856
|
lang: t.lang,
|
|
922
857
|
onImageUpload: t.onImageUpload,
|
|
923
|
-
onVideoUpload: t.onVideoUpload
|
|
924
|
-
resolveMediaSource: t.resolveMediaSource
|
|
858
|
+
onVideoUpload: t.onVideoUpload
|
|
925
859
|
})
|
|
926
860
|
});
|
|
927
861
|
}
|
|
928
862
|
//#endregion
|
|
929
863
|
//#region src/ui/codeblock/CodeBlockControls.tsx
|
|
930
|
-
function
|
|
864
|
+
function Vr(e) {
|
|
931
865
|
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", {
|
|
932
866
|
cx: "10",
|
|
933
867
|
cy: "10",
|
|
@@ -964,7 +898,7 @@ function Zr(e) {
|
|
|
964
898
|
/* @__PURE__ */ Z("path", { d: "m14 14 4 4" })
|
|
965
899
|
] }) : 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" });
|
|
966
900
|
}
|
|
967
|
-
function
|
|
901
|
+
function Hr({ icon: e }) {
|
|
968
902
|
return /* @__PURE__ */ Z("svg", {
|
|
969
903
|
viewBox: "0 0 24 24",
|
|
970
904
|
"aria-hidden": "true",
|
|
@@ -975,40 +909,40 @@ function Qr({ icon: e }) {
|
|
|
975
909
|
strokeLinecap: "round",
|
|
976
910
|
strokeLinejoin: "round",
|
|
977
911
|
strokeWidth: "1.8",
|
|
978
|
-
children:
|
|
912
|
+
children: Vr(e)
|
|
979
913
|
})
|
|
980
914
|
});
|
|
981
915
|
}
|
|
982
|
-
function
|
|
983
|
-
let a =
|
|
916
|
+
function Ur({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, readOnly: i = !1 }) {
|
|
917
|
+
let a = K(null), o = K(null), s = K(null), c = K({
|
|
984
918
|
active: !1,
|
|
985
919
|
lastX: 0,
|
|
986
920
|
lastY: 0
|
|
987
|
-
}), [
|
|
988
|
-
...
|
|
989
|
-
pos:
|
|
921
|
+
}), [l, u] = q(null), [d, f] = q(null), [p, m] = q([]), [h, g] = q(null), [_, v] = q(!1), [y, b] = q(""), [x, S] = q(null), [C, w] = q(!1), [T, E] = q(null), [D, O] = q(null), [k, A] = q(!1), [j, M] = q(0), [N, P] = q(0), F = pt(t), ee = pn(t, l), I = !i && e && F.active && F.pos !== null ? {
|
|
922
|
+
...F,
|
|
923
|
+
pos: F.pos,
|
|
990
924
|
active: !0
|
|
991
|
-
} : null,
|
|
925
|
+
} : null, L = ee ?? I, te = L !== null, R = L?.language === "mermaid", z = _n(t, L), ne = te && L !== null && !z, re = !i, ie = sn(L ? L.language : "text"), ae = x?.status ?? "idle", B = L?.mermaidPreviewMode ?? n, V = R && B === "preview", oe = hn(t), se = `${N}|${oe.map((e) => `${e.pos}:${e.mermaidPreviewMode}:${e.text.length}`).join("|")}`, ce = G(() => dn(y.trim().toLowerCase()), [y]);
|
|
992
926
|
if (U(() => {
|
|
993
|
-
i && (
|
|
927
|
+
i && (v(!1), b(""));
|
|
994
928
|
}, [i]), U(() => {
|
|
995
|
-
if (!
|
|
929
|
+
if (!x) return;
|
|
996
930
|
let e = window.setTimeout(() => {
|
|
997
|
-
|
|
998
|
-
},
|
|
931
|
+
S(null);
|
|
932
|
+
}, en);
|
|
999
933
|
return () => {
|
|
1000
934
|
window.clearTimeout(e);
|
|
1001
935
|
};
|
|
1002
|
-
}, [
|
|
1003
|
-
|
|
936
|
+
}, [x]), U(() => {
|
|
937
|
+
S(null), v(!1), b(""), E(null), O(null), A(!1);
|
|
1004
938
|
}, [
|
|
1005
939
|
e,
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
940
|
+
L?.language,
|
|
941
|
+
L?.pos,
|
|
942
|
+
L?.text
|
|
1009
943
|
]), U(() => {
|
|
1010
944
|
let e = ({ transaction: e }) => {
|
|
1011
|
-
e.getMeta(
|
|
945
|
+
e.getMeta(dt) && M((e) => e + 1);
|
|
1012
946
|
};
|
|
1013
947
|
return t.on("transaction", e), () => {
|
|
1014
948
|
t.off("transaction", e);
|
|
@@ -1017,29 +951,21 @@ function $r({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1017
951
|
let e = t.view.dom.closest(".markweave-editor-frame");
|
|
1018
952
|
if (!e) return;
|
|
1019
953
|
let n = (e) => {
|
|
1020
|
-
if (e.target instanceof Node && a.current?.contains(e.target) ||
|
|
1021
|
-
let n =
|
|
1022
|
-
|
|
954
|
+
if (e.target instanceof Node && a.current?.contains(e.target) || _) return;
|
|
955
|
+
let n = pn(t, fn(t, e.target)), r = n && !_n(t, n) ? n.pos : null;
|
|
956
|
+
u((e) => e === r ? e : r);
|
|
1023
957
|
}, r = () => {
|
|
1024
|
-
|
|
958
|
+
_ || u(null);
|
|
1025
959
|
};
|
|
1026
960
|
return e.addEventListener("mousemove", n), e.addEventListener("mouseleave", r), () => {
|
|
1027
961
|
e.removeEventListener("mousemove", n), e.removeEventListener("mouseleave", r);
|
|
1028
962
|
};
|
|
1029
|
-
}, [t,
|
|
1030
|
-
|
|
1031
|
-
}, [
|
|
1032
|
-
if (!
|
|
1033
|
-
let e = c.current, t = e?.querySelector(`[data-language-index="${C}"]`);
|
|
1034
|
-
e && t && On(e, t);
|
|
1035
|
-
}, [
|
|
1036
|
-
C,
|
|
1037
|
-
V,
|
|
1038
|
-
y
|
|
1039
|
-
]), U(() => {
|
|
1040
|
-
if (!k) return;
|
|
963
|
+
}, [t, _]), U(() => {
|
|
964
|
+
_ && s.current?.focus({ preventScroll: !0 });
|
|
965
|
+
}, [_]), U(() => {
|
|
966
|
+
if (!T) return;
|
|
1041
967
|
let e = (e) => {
|
|
1042
|
-
e.key === "Escape" && (
|
|
968
|
+
e.key === "Escape" && (E(null), O(null), A(!1), c.current = {
|
|
1043
969
|
active: !1,
|
|
1044
970
|
lastX: 0,
|
|
1045
971
|
lastY: 0
|
|
@@ -1048,33 +974,33 @@ function $r({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1048
974
|
return document.addEventListener("keydown", e), () => {
|
|
1049
975
|
document.removeEventListener("keydown", e);
|
|
1050
976
|
};
|
|
1051
|
-
}, [t,
|
|
1052
|
-
if (!
|
|
977
|
+
}, [t, T]), U(() => {
|
|
978
|
+
if (!te || !_) return;
|
|
1053
979
|
let e = (e) => {
|
|
1054
|
-
e.key === "Escape" && (
|
|
980
|
+
e.key === "Escape" && (v(!1), t.view.focus());
|
|
1055
981
|
}, n = (e) => {
|
|
1056
|
-
e.target instanceof Node && a.current?.contains(e.target) || (
|
|
982
|
+
e.target instanceof Node && a.current?.contains(e.target) || v(!1);
|
|
1057
983
|
};
|
|
1058
984
|
return document.addEventListener("keydown", e), document.addEventListener("mousedown", n), () => {
|
|
1059
985
|
document.removeEventListener("keydown", e), document.removeEventListener("mousedown", n);
|
|
1060
986
|
};
|
|
1061
987
|
}, [
|
|
1062
|
-
|
|
988
|
+
te,
|
|
1063
989
|
t,
|
|
1064
|
-
|
|
1065
|
-
]),
|
|
990
|
+
_
|
|
991
|
+
]), W(() => {
|
|
1066
992
|
let e = () => {
|
|
1067
993
|
let e = a.current;
|
|
1068
994
|
if (!e) return;
|
|
1069
|
-
if (!
|
|
1070
|
-
|
|
995
|
+
if (!mn(e) || oe.length === 0) {
|
|
996
|
+
m([]);
|
|
1071
997
|
return;
|
|
1072
998
|
}
|
|
1073
|
-
let n = e.getBoundingClientRect(), r =
|
|
1074
|
-
let r =
|
|
1075
|
-
return r ? [
|
|
999
|
+
let n = e.getBoundingClientRect(), r = oe.flatMap((e) => {
|
|
1000
|
+
let r = un(ln(t, e.pos, e.mermaidPreviewMode), n);
|
|
1001
|
+
return r ? [an(e, r, n)] : [];
|
|
1076
1002
|
});
|
|
1077
|
-
|
|
1003
|
+
m((e) => vn(e, r, oe.map((e) => e.pos)));
|
|
1078
1004
|
};
|
|
1079
1005
|
e();
|
|
1080
1006
|
let n = window.requestAnimationFrame(e);
|
|
@@ -1082,26 +1008,26 @@ function $r({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1082
1008
|
window.cancelAnimationFrame(n), window.removeEventListener("resize", e), window.removeEventListener("scroll", e, !0);
|
|
1083
1009
|
};
|
|
1084
1010
|
}, [
|
|
1085
|
-
|
|
1011
|
+
j,
|
|
1086
1012
|
t,
|
|
1087
|
-
|
|
1088
|
-
]),
|
|
1089
|
-
if (!
|
|
1090
|
-
|
|
1013
|
+
se
|
|
1014
|
+
]), W(() => {
|
|
1015
|
+
if (!ne || !L) {
|
|
1016
|
+
f(null), g(null);
|
|
1091
1017
|
return;
|
|
1092
1018
|
}
|
|
1093
1019
|
let e = () => {
|
|
1094
1020
|
let e = a.current;
|
|
1095
1021
|
if (!e) return;
|
|
1096
|
-
let n =
|
|
1022
|
+
let n = ln(t, L.pos, B), r = e.getBoundingClientRect(), i = un(n, r);
|
|
1097
1023
|
if (!i) {
|
|
1098
|
-
|
|
1024
|
+
f((e) => e?.pos === L.pos ? e : null), g((e) => _ ? e : null);
|
|
1099
1025
|
return;
|
|
1100
1026
|
}
|
|
1101
|
-
let s =
|
|
1102
|
-
if (
|
|
1027
|
+
let s = nn(L.pos, i, r);
|
|
1028
|
+
if (f(s), _ && o.current) {
|
|
1103
1029
|
let e = o.current.getBoundingClientRect();
|
|
1104
|
-
|
|
1030
|
+
g(Qt({
|
|
1105
1031
|
overlayRect: r,
|
|
1106
1032
|
buttonRect: e,
|
|
1107
1033
|
windowWidth: window.innerWidth,
|
|
@@ -1113,115 +1039,93 @@ function $r({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1113
1039
|
window.removeEventListener("resize", e), window.removeEventListener("scroll", e, !0);
|
|
1114
1040
|
};
|
|
1115
1041
|
}, [
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1042
|
+
ne,
|
|
1043
|
+
j,
|
|
1044
|
+
L?.pos,
|
|
1119
1045
|
t,
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
]), !
|
|
1123
|
-
let
|
|
1124
|
-
top:
|
|
1125
|
-
right:
|
|
1126
|
-
} : void 0,
|
|
1046
|
+
_,
|
|
1047
|
+
B
|
|
1048
|
+
]), !ne && oe.length === 0 && !T) return null;
|
|
1049
|
+
let le = d ? {
|
|
1050
|
+
top: d.top,
|
|
1051
|
+
right: d.right
|
|
1052
|
+
} : void 0, ue = async () => {
|
|
1127
1053
|
if (i) {
|
|
1128
|
-
if (!
|
|
1129
|
-
let e = await
|
|
1130
|
-
|
|
1054
|
+
if (!L) return;
|
|
1055
|
+
let e = await tn(L.text);
|
|
1056
|
+
S(mt(L, e ? "copied" : "failed"));
|
|
1131
1057
|
return;
|
|
1132
1058
|
}
|
|
1133
|
-
if (!
|
|
1134
|
-
let e = await
|
|
1135
|
-
|
|
1136
|
-
},
|
|
1059
|
+
if (!on(t, L)) return;
|
|
1060
|
+
let e = await ft(t);
|
|
1061
|
+
S(mt(pt(t), e ? "copied" : "failed")), t.view.focus();
|
|
1062
|
+
}, de = (e, n) => {
|
|
1137
1063
|
if (i) {
|
|
1138
|
-
|
|
1064
|
+
St(t, e.pos, n) && P((e) => e + 1);
|
|
1139
1065
|
return;
|
|
1140
1066
|
}
|
|
1141
|
-
let a =
|
|
1142
|
-
|
|
1143
|
-
},
|
|
1144
|
-
if (i || !
|
|
1145
|
-
let n =
|
|
1146
|
-
|
|
1147
|
-
},
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
let
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
if (e.key === "Enter") {
|
|
1160
|
-
let t = V[C];
|
|
1161
|
-
t && (e.preventDefault(), ge(t.language));
|
|
1162
|
-
return;
|
|
1163
|
-
}
|
|
1164
|
-
e.key === "Escape" && (e.preventDefault(), b(!1), w(-1), t.view.focus());
|
|
1165
|
-
}
|
|
1166
|
-
}, be = V[C], xe = l.current && be ? gn(l.current, be.language) : void 0, Se = () => {
|
|
1167
|
-
i || !R || vt(t, R.pos, !z) && (F((e) => e + 1), f(null));
|
|
1168
|
-
}, Ce = () => {
|
|
1169
|
-
if (!R) return;
|
|
1170
|
-
let e = Sn(t, R.pos);
|
|
1171
|
-
e && en({
|
|
1172
|
-
data: new Blob([e], { type: "image/svg+xml" }),
|
|
1173
|
-
fileName: "markweave-mermaid.svg",
|
|
1174
|
-
onSettled: () => t.view.focus(),
|
|
1175
|
-
ownerDocument: document
|
|
1176
|
-
});
|
|
1177
|
-
}, we = () => {
|
|
1178
|
-
if (!R) return;
|
|
1179
|
-
let e = Sn(t, R.pos);
|
|
1180
|
-
e && (A(cn(e)), M(null), N(!1), u.current = {
|
|
1067
|
+
let a = F.active && F.pos === e.pos;
|
|
1068
|
+
vt(t, e.pos, n) && (r(n), P((e) => e + 1), a && t.view.focus());
|
|
1069
|
+
}, fe = (e) => {
|
|
1070
|
+
if (i || !L) return;
|
|
1071
|
+
let n = F.active && F.pos === L.pos;
|
|
1072
|
+
_t(t, L.pos, e) && (e === "mermaid" && vt(t, L.pos, "preview") && r("preview"), v(!1), b(""), P((e) => e + 1), n && t.view.focus());
|
|
1073
|
+
}, pe = () => {
|
|
1074
|
+
i || !L || gt(t, L.pos, !z) && (M((e) => e + 1), u(null));
|
|
1075
|
+
}, me = () => {
|
|
1076
|
+
if (!L) return;
|
|
1077
|
+
let e = gn(t, L.pos);
|
|
1078
|
+
if (!e) return;
|
|
1079
|
+
let n = new Blob([e], { type: "image/svg+xml" }), r = URL.createObjectURL(n), i = document.createElement("a");
|
|
1080
|
+
i.href = r, i.download = "markweave-mermaid.svg", i.click(), URL.revokeObjectURL(r), t.view.focus();
|
|
1081
|
+
}, he = () => {
|
|
1082
|
+
if (!L) return;
|
|
1083
|
+
let e = gn(t, L.pos);
|
|
1084
|
+
e && (E(rn(e)), O(null), A(!1), c.current = {
|
|
1181
1085
|
active: !1,
|
|
1182
1086
|
lastX: 0,
|
|
1183
1087
|
lastY: 0
|
|
1184
1088
|
});
|
|
1185
|
-
},
|
|
1186
|
-
|
|
1089
|
+
}, ge = () => {
|
|
1090
|
+
E(null), O(null), A(!1), c.current = {
|
|
1187
1091
|
active: !1,
|
|
1188
1092
|
lastX: 0,
|
|
1189
1093
|
lastY: 0
|
|
1190
1094
|
}, t.view.focus();
|
|
1191
|
-
},
|
|
1192
|
-
|
|
1095
|
+
}, _e = (e) => {
|
|
1096
|
+
E((t) => t && {
|
|
1193
1097
|
...t,
|
|
1194
|
-
scale:
|
|
1098
|
+
scale: $t(t.scale + e)
|
|
1195
1099
|
});
|
|
1196
|
-
},
|
|
1197
|
-
|
|
1100
|
+
}, H = () => {
|
|
1101
|
+
E((e) => e && rn(e.svg)), c.current = {
|
|
1198
1102
|
active: !1,
|
|
1199
1103
|
lastX: 0,
|
|
1200
1104
|
lastY: 0
|
|
1201
|
-
},
|
|
1202
|
-
},
|
|
1203
|
-
e.preventDefault(),
|
|
1204
|
-
},
|
|
1205
|
-
e.button === 0 && (e.preventDefault(),
|
|
1105
|
+
}, A(!1);
|
|
1106
|
+
}, ve = (e) => {
|
|
1107
|
+
e.preventDefault(), _e(e.deltaY < 0 ? yn : -yn);
|
|
1108
|
+
}, ye = (e) => {
|
|
1109
|
+
e.button === 0 && (e.preventDefault(), c.current = {
|
|
1206
1110
|
active: !0,
|
|
1207
1111
|
lastX: e.clientX,
|
|
1208
1112
|
lastY: e.clientY
|
|
1209
|
-
},
|
|
1210
|
-
},
|
|
1211
|
-
let t =
|
|
1113
|
+
}, A(!0));
|
|
1114
|
+
}, be = (e) => {
|
|
1115
|
+
let t = c.current;
|
|
1212
1116
|
if (!t.active) return;
|
|
1213
1117
|
let n = e.clientX - t.lastX, r = e.clientY - t.lastY;
|
|
1214
|
-
|
|
1118
|
+
c.current = {
|
|
1215
1119
|
active: !0,
|
|
1216
1120
|
lastX: e.clientX,
|
|
1217
1121
|
lastY: e.clientY
|
|
1218
|
-
},
|
|
1219
|
-
},
|
|
1220
|
-
|
|
1122
|
+
}, E((e) => bn(e, n, r));
|
|
1123
|
+
}, xe = () => {
|
|
1124
|
+
c.current = {
|
|
1221
1125
|
active: !1,
|
|
1222
1126
|
lastX: 0,
|
|
1223
1127
|
lastY: 0
|
|
1224
|
-
},
|
|
1128
|
+
}, A(!1);
|
|
1225
1129
|
};
|
|
1226
1130
|
return /* @__PURE__ */ Q("div", {
|
|
1227
1131
|
ref: a,
|
|
@@ -1229,8 +1133,8 @@ function $r({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1229
1133
|
"data-testid": "markweave-codeblock-overlay",
|
|
1230
1134
|
"data-read-only": i ? "true" : "false",
|
|
1231
1135
|
children: [
|
|
1232
|
-
|
|
1233
|
-
let t =
|
|
1136
|
+
oe.map((e) => {
|
|
1137
|
+
let t = p.find((t) => t.pos === e.pos);
|
|
1234
1138
|
return /* @__PURE__ */ Z("div", {
|
|
1235
1139
|
className: "markweave-mermaid-tabs",
|
|
1236
1140
|
"data-testid": "markweave-mermaid-tabs",
|
|
@@ -1245,38 +1149,38 @@ function $r({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1245
1149
|
"data-testid": `markweave-mermaid-mode-${t}`,
|
|
1246
1150
|
"data-active": e.mermaidPreviewMode === t,
|
|
1247
1151
|
onMouseDown: (e) => e.preventDefault(),
|
|
1248
|
-
onClick: () =>
|
|
1152
|
+
onClick: () => de(e, t),
|
|
1249
1153
|
children: t === "code" ? "Code" : "Preview"
|
|
1250
1154
|
}, t))
|
|
1251
1155
|
}, e.pos);
|
|
1252
1156
|
}),
|
|
1253
|
-
|
|
1157
|
+
ne ? /* @__PURE__ */ Q("div", {
|
|
1254
1158
|
className: "markweave-codeblock-controls",
|
|
1255
1159
|
"data-testid": "markweave-codeblock-controls",
|
|
1256
|
-
"data-positioned":
|
|
1160
|
+
"data-positioned": d ? "true" : "false",
|
|
1257
1161
|
"data-collapsed": z ? "true" : "false",
|
|
1258
1162
|
"data-read-only": i ? "true" : "false",
|
|
1259
1163
|
"aria-label": "Code block controls",
|
|
1260
|
-
style:
|
|
1164
|
+
style: le,
|
|
1261
1165
|
children: [
|
|
1262
1166
|
i ? /* @__PURE__ */ Z("span", {
|
|
1263
1167
|
className: "markweave-codeblock-language-button markweave-codeblock-language-label",
|
|
1264
1168
|
"aria-label": "Code block language",
|
|
1265
1169
|
"data-testid": "markweave-codeblock-language",
|
|
1266
|
-
children: /* @__PURE__ */ Z("span", { children:
|
|
1170
|
+
children: /* @__PURE__ */ Z("span", { children: ie })
|
|
1267
1171
|
}) : /* @__PURE__ */ Q("button", {
|
|
1268
1172
|
ref: o,
|
|
1269
1173
|
type: "button",
|
|
1270
1174
|
className: "markweave-codeblock-language-button",
|
|
1271
1175
|
"aria-label": "Code block language",
|
|
1272
|
-
"aria-expanded":
|
|
1176
|
+
"aria-expanded": _,
|
|
1273
1177
|
"aria-haspopup": "listbox",
|
|
1274
1178
|
"data-testid": "markweave-codeblock-language",
|
|
1275
1179
|
onMouseDown: (e) => e.preventDefault(),
|
|
1276
|
-
onClick:
|
|
1277
|
-
children: [/* @__PURE__ */ Z("span", { children:
|
|
1180
|
+
onClick: () => v((e) => !e),
|
|
1181
|
+
children: [/* @__PURE__ */ Z("span", { children: ie }), /* @__PURE__ */ Z(Hr, { icon: "chevron" })]
|
|
1278
1182
|
}),
|
|
1279
|
-
|
|
1183
|
+
re ? /* @__PURE__ */ Z("button", {
|
|
1280
1184
|
type: "button",
|
|
1281
1185
|
className: "markweave-codeblock-icon-button markweave-codeblock-collapse-button",
|
|
1282
1186
|
"aria-label": z ? "Expand code block" : "Collapse code block",
|
|
@@ -1284,8 +1188,8 @@ function $r({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1284
1188
|
"data-testid": "markweave-codeblock-collapse",
|
|
1285
1189
|
"data-collapsed": z ? "true" : "false",
|
|
1286
1190
|
onMouseDown: (e) => e.preventDefault(),
|
|
1287
|
-
onClick:
|
|
1288
|
-
children: /* @__PURE__ */ Z(
|
|
1191
|
+
onClick: pe,
|
|
1192
|
+
children: /* @__PURE__ */ Z(Hr, { icon: "chevron" })
|
|
1289
1193
|
}) : null,
|
|
1290
1194
|
/* @__PURE__ */ Q("span", {
|
|
1291
1195
|
className: "markweave-codeblock-copy-wrap",
|
|
@@ -1294,22 +1198,22 @@ function $r({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1294
1198
|
className: "markweave-codeblock-icon-button",
|
|
1295
1199
|
"aria-label": "Copy to clipboard",
|
|
1296
1200
|
"data-testid": "markweave-codeblock-copy",
|
|
1297
|
-
"data-copy-state":
|
|
1201
|
+
"data-copy-state": ae,
|
|
1298
1202
|
onMouseDown: (e) => e.preventDefault(),
|
|
1299
|
-
onMouseEnter: () =>
|
|
1300
|
-
onMouseLeave: () =>
|
|
1301
|
-
onFocus: () =>
|
|
1302
|
-
onBlur: () =>
|
|
1303
|
-
onClick:
|
|
1304
|
-
children: /* @__PURE__ */ Z(
|
|
1305
|
-
}),
|
|
1203
|
+
onMouseEnter: () => w(!0),
|
|
1204
|
+
onMouseLeave: () => w(!1),
|
|
1205
|
+
onFocus: () => w(!0),
|
|
1206
|
+
onBlur: () => w(!1),
|
|
1207
|
+
onClick: ue,
|
|
1208
|
+
children: /* @__PURE__ */ Z(Hr, { icon: ae === "copied" ? "check" : "clipboard" })
|
|
1209
|
+
}), C ? /* @__PURE__ */ Z("span", {
|
|
1306
1210
|
className: "markweave-codeblock-tooltip",
|
|
1307
1211
|
role: "tooltip",
|
|
1308
1212
|
"data-testid": "markweave-codeblock-copy-tooltip",
|
|
1309
1213
|
children: "Copy to clipboard"
|
|
1310
1214
|
}) : null]
|
|
1311
1215
|
}),
|
|
1312
|
-
|
|
1216
|
+
R && B === "preview" ? /* @__PURE__ */ Q("div", {
|
|
1313
1217
|
className: "markweave-mermaid-preview-actions",
|
|
1314
1218
|
"data-testid": "markweave-mermaid-preview-actions",
|
|
1315
1219
|
children: [/* @__PURE__ */ Z("button", {
|
|
@@ -1317,73 +1221,63 @@ function $r({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1317
1221
|
className: "markweave-codeblock-icon-button",
|
|
1318
1222
|
"aria-label": "Fullscreen Mermaid preview",
|
|
1319
1223
|
"data-testid": "markweave-mermaid-fullscreen",
|
|
1320
|
-
disabled: !
|
|
1224
|
+
disabled: !V,
|
|
1321
1225
|
onMouseDown: (e) => e.preventDefault(),
|
|
1322
|
-
onClick:
|
|
1323
|
-
children: /* @__PURE__ */ Z(
|
|
1226
|
+
onClick: he,
|
|
1227
|
+
children: /* @__PURE__ */ Z(Hr, { icon: "expand" })
|
|
1324
1228
|
}), /* @__PURE__ */ Z("button", {
|
|
1325
1229
|
type: "button",
|
|
1326
1230
|
className: "markweave-codeblock-icon-button",
|
|
1327
1231
|
"aria-label": "Download Mermaid SVG",
|
|
1328
1232
|
"data-testid": "markweave-mermaid-download",
|
|
1329
|
-
disabled: !
|
|
1233
|
+
disabled: !V,
|
|
1330
1234
|
onMouseDown: (e) => e.preventDefault(),
|
|
1331
|
-
onClick:
|
|
1332
|
-
children: /* @__PURE__ */ Z(
|
|
1235
|
+
onClick: me,
|
|
1236
|
+
children: /* @__PURE__ */ Z(Hr, { icon: "download" })
|
|
1333
1237
|
})]
|
|
1334
1238
|
}) : null
|
|
1335
1239
|
]
|
|
1336
1240
|
}) : null,
|
|
1337
|
-
|
|
1241
|
+
re && ne && _ ? /* @__PURE__ */ Q("div", {
|
|
1338
1242
|
className: "markweave-codeblock-language-menu",
|
|
1243
|
+
role: "listbox",
|
|
1244
|
+
"aria-label": "Code block languages",
|
|
1339
1245
|
"data-testid": "markweave-codeblock-language-menu",
|
|
1340
|
-
"data-positioned":
|
|
1341
|
-
style:
|
|
1342
|
-
left:
|
|
1343
|
-
top:
|
|
1246
|
+
"data-positioned": h ? "true" : "false",
|
|
1247
|
+
style: h ? {
|
|
1248
|
+
left: h.left,
|
|
1249
|
+
top: h.top
|
|
1344
1250
|
} : void 0,
|
|
1345
1251
|
children: [/* @__PURE__ */ Q("label", {
|
|
1346
1252
|
className: "markweave-codeblock-language-search",
|
|
1347
1253
|
children: [/* @__PURE__ */ Z("input", {
|
|
1348
1254
|
ref: s,
|
|
1349
|
-
|
|
1350
|
-
"aria-autocomplete": "list",
|
|
1351
|
-
"aria-controls": l.current ?? void 0,
|
|
1352
|
-
"aria-expanded": "true",
|
|
1353
|
-
"aria-activedescendant": xe,
|
|
1354
|
-
"aria-label": "Search code block languages",
|
|
1355
|
-
value: x,
|
|
1255
|
+
value: y,
|
|
1356
1256
|
placeholder: "Search...",
|
|
1357
1257
|
"data-testid": "markweave-codeblock-language-search",
|
|
1358
|
-
onChange: (e) =>
|
|
1359
|
-
onKeyDown:
|
|
1360
|
-
|
|
1258
|
+
onChange: (e) => b(e.target.value),
|
|
1259
|
+
onKeyDown: (e) => {
|
|
1260
|
+
e.key === "Escape" && (e.preventDefault(), v(!1), t.view.focus());
|
|
1261
|
+
}
|
|
1262
|
+
}), /* @__PURE__ */ Z(Hr, { icon: "search" })]
|
|
1361
1263
|
}), /* @__PURE__ */ Z("div", {
|
|
1362
|
-
ref: c,
|
|
1363
|
-
id: l.current ?? void 0,
|
|
1364
1264
|
className: "markweave-codeblock-language-list",
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
children: V.map((e, t) => {
|
|
1368
|
-
let n = e.language === R.language, r = t === C;
|
|
1265
|
+
children: ce.map((e) => {
|
|
1266
|
+
let t = e.language === L.language;
|
|
1369
1267
|
return /* @__PURE__ */ Q("button", {
|
|
1370
|
-
id: l.current ? gn(l.current, e.language) : void 0,
|
|
1371
1268
|
type: "button",
|
|
1372
1269
|
role: "option",
|
|
1373
|
-
"aria-selected":
|
|
1270
|
+
"aria-selected": t,
|
|
1374
1271
|
"data-testid": `markweave-codeblock-language-option-${e.language}`,
|
|
1375
|
-
"data-active":
|
|
1376
|
-
"data-highlighted": r ? "true" : "false",
|
|
1377
|
-
"data-language-index": t,
|
|
1272
|
+
"data-active": t ? "true" : "false",
|
|
1378
1273
|
onMouseDown: (e) => e.preventDefault(),
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
children: [/* @__PURE__ */ Z("span", { children: e.label }), n ? /* @__PURE__ */ Z(Qr, { icon: "check" }) : null]
|
|
1274
|
+
onClick: () => fe(e.language),
|
|
1275
|
+
children: [/* @__PURE__ */ Z("span", { children: e.label }), t ? /* @__PURE__ */ Z(Hr, { icon: "check" }) : null]
|
|
1382
1276
|
}, e.language);
|
|
1383
1277
|
})
|
|
1384
1278
|
})]
|
|
1385
1279
|
}) : null,
|
|
1386
|
-
|
|
1280
|
+
T ? /* @__PURE__ */ Q("div", {
|
|
1387
1281
|
className: "markweave-mermaid-fullscreen-layer",
|
|
1388
1282
|
role: "dialog",
|
|
1389
1283
|
"aria-modal": "true",
|
|
@@ -1399,47 +1293,47 @@ function $r({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1399
1293
|
className: "markweave-mermaid-fullscreen-control",
|
|
1400
1294
|
"aria-label": "Zoom out",
|
|
1401
1295
|
"data-testid": "markweave-mermaid-fullscreen-zoom-out",
|
|
1402
|
-
onMouseEnter: () =>
|
|
1403
|
-
onMouseLeave: () =>
|
|
1404
|
-
onFocus: () =>
|
|
1405
|
-
onBlur: () =>
|
|
1406
|
-
onClick: () =>
|
|
1407
|
-
children: /* @__PURE__ */ Z(
|
|
1296
|
+
onMouseEnter: () => O("zoom-out"),
|
|
1297
|
+
onMouseLeave: () => O(null),
|
|
1298
|
+
onFocus: () => O("zoom-out"),
|
|
1299
|
+
onBlur: () => O(null),
|
|
1300
|
+
onClick: () => _e(-yn),
|
|
1301
|
+
children: /* @__PURE__ */ Z(Hr, { icon: "zoomOut" })
|
|
1408
1302
|
}),
|
|
1409
1303
|
/* @__PURE__ */ Z("span", {
|
|
1410
1304
|
className: "markweave-mermaid-fullscreen-zoom-label",
|
|
1411
1305
|
"data-testid": "markweave-mermaid-fullscreen-zoom-label",
|
|
1412
|
-
children:
|
|
1306
|
+
children: cn(T.scale)
|
|
1413
1307
|
}),
|
|
1414
1308
|
/* @__PURE__ */ Z("button", {
|
|
1415
1309
|
type: "button",
|
|
1416
1310
|
className: "markweave-mermaid-fullscreen-control",
|
|
1417
1311
|
"aria-label": "Zoom in",
|
|
1418
1312
|
"data-testid": "markweave-mermaid-fullscreen-zoom-in",
|
|
1419
|
-
onMouseEnter: () =>
|
|
1420
|
-
onMouseLeave: () =>
|
|
1421
|
-
onFocus: () =>
|
|
1422
|
-
onBlur: () =>
|
|
1423
|
-
onClick: () =>
|
|
1424
|
-
children: /* @__PURE__ */ Z(
|
|
1313
|
+
onMouseEnter: () => O("zoom-in"),
|
|
1314
|
+
onMouseLeave: () => O(null),
|
|
1315
|
+
onFocus: () => O("zoom-in"),
|
|
1316
|
+
onBlur: () => O(null),
|
|
1317
|
+
onClick: () => _e(yn),
|
|
1318
|
+
children: /* @__PURE__ */ Z(Hr, { icon: "zoomIn" })
|
|
1425
1319
|
}),
|
|
1426
1320
|
/* @__PURE__ */ Z("button", {
|
|
1427
1321
|
type: "button",
|
|
1428
1322
|
className: "markweave-mermaid-fullscreen-control",
|
|
1429
1323
|
"aria-label": "Reset zoom",
|
|
1430
1324
|
"data-testid": "markweave-mermaid-fullscreen-reset",
|
|
1431
|
-
onMouseEnter: () =>
|
|
1432
|
-
onMouseLeave: () =>
|
|
1433
|
-
onFocus: () =>
|
|
1434
|
-
onBlur: () =>
|
|
1435
|
-
onClick:
|
|
1436
|
-
children: /* @__PURE__ */ Z(
|
|
1325
|
+
onMouseEnter: () => O("reset"),
|
|
1326
|
+
onMouseLeave: () => O(null),
|
|
1327
|
+
onFocus: () => O("reset"),
|
|
1328
|
+
onBlur: () => O(null),
|
|
1329
|
+
onClick: H,
|
|
1330
|
+
children: /* @__PURE__ */ Z(Hr, { icon: "reset" })
|
|
1437
1331
|
}),
|
|
1438
|
-
|
|
1332
|
+
D ? /* @__PURE__ */ Z("span", {
|
|
1439
1333
|
className: "markweave-mermaid-fullscreen-tooltip",
|
|
1440
1334
|
role: "tooltip",
|
|
1441
1335
|
"data-testid": "markweave-mermaid-fullscreen-tooltip",
|
|
1442
|
-
children:
|
|
1336
|
+
children: D === "zoom-out" ? "Zoom out" : D === "zoom-in" ? "Zoom in" : "Reset"
|
|
1443
1337
|
}) : null
|
|
1444
1338
|
]
|
|
1445
1339
|
}),
|
|
@@ -1448,29 +1342,29 @@ function $r({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1448
1342
|
className: "markweave-mermaid-fullscreen-close",
|
|
1449
1343
|
"aria-label": "Close fullscreen Mermaid preview",
|
|
1450
1344
|
"data-testid": "markweave-mermaid-fullscreen-close",
|
|
1451
|
-
onClick:
|
|
1452
|
-
children: /* @__PURE__ */ Z(
|
|
1345
|
+
onClick: ge,
|
|
1346
|
+
children: /* @__PURE__ */ Z(Hr, { icon: "close" })
|
|
1453
1347
|
}),
|
|
1454
1348
|
/* @__PURE__ */ Z("div", {
|
|
1455
1349
|
className: "markweave-mermaid-fullscreen-viewport",
|
|
1456
1350
|
"data-testid": "markweave-mermaid-fullscreen-viewport",
|
|
1457
|
-
"data-dragging":
|
|
1458
|
-
onWheel:
|
|
1459
|
-
onMouseDown:
|
|
1460
|
-
onMouseMove:
|
|
1461
|
-
onMouseUp:
|
|
1462
|
-
onMouseLeave:
|
|
1351
|
+
"data-dragging": k ? "true" : "false",
|
|
1352
|
+
onWheel: ve,
|
|
1353
|
+
onMouseDown: ye,
|
|
1354
|
+
onMouseMove: be,
|
|
1355
|
+
onMouseUp: xe,
|
|
1356
|
+
onMouseLeave: xe,
|
|
1463
1357
|
children: /* @__PURE__ */ Z("div", {
|
|
1464
1358
|
className: "markweave-mermaid-fullscreen-content",
|
|
1465
1359
|
"data-testid": "markweave-mermaid-fullscreen-content",
|
|
1466
|
-
"data-scale-percent": Math.round(
|
|
1467
|
-
"data-translate": `${Math.round(
|
|
1360
|
+
"data-scale-percent": Math.round(T.scale * 100),
|
|
1361
|
+
"data-translate": `${Math.round(T.translateX)},${Math.round(T.translateY)}`,
|
|
1468
1362
|
style: {
|
|
1469
|
-
width: `${
|
|
1470
|
-
height: `${
|
|
1471
|
-
transform: `translate(${
|
|
1363
|
+
width: `${T.width}px`,
|
|
1364
|
+
height: `${T.height}px`,
|
|
1365
|
+
transform: `translate(${T.translateX}px, ${T.translateY}px) scale(${T.scale})`
|
|
1472
1366
|
},
|
|
1473
|
-
dangerouslySetInnerHTML: { __html:
|
|
1367
|
+
dangerouslySetInnerHTML: { __html: T.svg }
|
|
1474
1368
|
})
|
|
1475
1369
|
})
|
|
1476
1370
|
]
|
|
@@ -1480,25 +1374,25 @@ function $r({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
|
|
|
1480
1374
|
}
|
|
1481
1375
|
//#endregion
|
|
1482
1376
|
//#region src/ui/floating-toolbar/FloatingToolbar.tsx
|
|
1483
|
-
var
|
|
1484
|
-
function
|
|
1377
|
+
var Wr = n("zh");
|
|
1378
|
+
function Gr() {
|
|
1485
1379
|
return typeof performance > "u" ? Date.now() : performance.now();
|
|
1486
1380
|
}
|
|
1487
|
-
function
|
|
1381
|
+
function Kr(e, t) {
|
|
1488
1382
|
return {
|
|
1489
1383
|
"--markweave-toolbar-motion-duration": `${e.motionDurationMs}ms`,
|
|
1490
1384
|
"--markweave-toolbar-motion-easing": e.motionEasing,
|
|
1491
1385
|
marginLeft: t === 0 ? void 0 : `${t}px`
|
|
1492
1386
|
};
|
|
1493
1387
|
}
|
|
1494
|
-
function
|
|
1388
|
+
function qr(e, t) {
|
|
1495
1389
|
let n = e?.getBoundingClientRect().height ?? 0, r = t?.getBoundingClientRect().height ?? 0;
|
|
1496
1390
|
return Math.max(n, r, 44);
|
|
1497
1391
|
}
|
|
1498
|
-
function
|
|
1392
|
+
function Jr(e) {
|
|
1499
1393
|
if (e !== null) return { "--markweave-floating-toolbar-tooltip-left": `${e}px` };
|
|
1500
1394
|
}
|
|
1501
|
-
function
|
|
1395
|
+
function Yr(e, t, n, r) {
|
|
1502
1396
|
let i = {
|
|
1503
1397
|
bottom: t + r,
|
|
1504
1398
|
height: r,
|
|
@@ -1514,26 +1408,26 @@ function ai(e, t, n, r) {
|
|
|
1514
1408
|
toJSON: () => i
|
|
1515
1409
|
};
|
|
1516
1410
|
}
|
|
1517
|
-
function
|
|
1411
|
+
function Xr(e) {
|
|
1518
1412
|
return e.width > 0 && e.height > 0;
|
|
1519
1413
|
}
|
|
1520
|
-
function
|
|
1414
|
+
function Zr(e) {
|
|
1521
1415
|
let t = Math.min(...e.map((e) => e.left)), n = Math.min(...e.map((e) => e.top)), r = Math.max(...e.map((e) => e.right)), i = Math.max(...e.map((e) => e.bottom));
|
|
1522
|
-
return
|
|
1416
|
+
return Yr(t, n, r - t, i - n);
|
|
1523
1417
|
}
|
|
1524
|
-
function
|
|
1418
|
+
function Qr(e, t) {
|
|
1525
1419
|
let n = e.view.dom.ownerDocument.defaultView?.Node.ELEMENT_NODE ?? 1, r = (t) => t ? e.view.dom.contains(t.nodeType === n ? t : t.parentNode) : !1;
|
|
1526
1420
|
return r(t.anchorNode) && r(t.focusNode);
|
|
1527
1421
|
}
|
|
1528
|
-
function
|
|
1422
|
+
function $r(e) {
|
|
1529
1423
|
if (typeof e.getClientRects != "function") return null;
|
|
1530
|
-
let t = Array.from(e.getClientRects()).filter(
|
|
1424
|
+
let t = Array.from(e.getClientRects()).filter(Xr).map((e) => Yr(e.left, e.top, e.width, e.height));
|
|
1531
1425
|
if (t.length > 0) return t;
|
|
1532
1426
|
if (typeof e.getBoundingClientRect != "function") return null;
|
|
1533
1427
|
let n = e.getBoundingClientRect();
|
|
1534
|
-
return
|
|
1428
|
+
return Xr(n) ? [Yr(n.left, n.top, n.width, n.height)] : null;
|
|
1535
1429
|
}
|
|
1536
|
-
function
|
|
1430
|
+
function ei(e, t) {
|
|
1537
1431
|
if (t.rangeCount === 0) return null;
|
|
1538
1432
|
let n = t.getRangeAt(0);
|
|
1539
1433
|
try {
|
|
@@ -1546,8 +1440,8 @@ function ui(e, t) {
|
|
|
1546
1440
|
return null;
|
|
1547
1441
|
}
|
|
1548
1442
|
}
|
|
1549
|
-
function
|
|
1550
|
-
let n =
|
|
1443
|
+
function ti(e, t) {
|
|
1444
|
+
let n = ei(e, t);
|
|
1551
1445
|
if (!n) return !1;
|
|
1552
1446
|
let { selection: r } = e.state, i = {
|
|
1553
1447
|
from: Math.min(r.from, r.to),
|
|
@@ -1555,51 +1449,51 @@ function di(e, t) {
|
|
|
1555
1449
|
};
|
|
1556
1450
|
return n.from === i.from && n.to === i.to;
|
|
1557
1451
|
}
|
|
1558
|
-
function
|
|
1452
|
+
function ni(e) {
|
|
1559
1453
|
let t = e.view.dom.ownerDocument.getSelection();
|
|
1560
|
-
return !t || t.rangeCount === 0 || t.isCollapsed || !
|
|
1454
|
+
return !t || t.rangeCount === 0 || t.isCollapsed || !Qr(e, t) || !ti(e, t) ? null : $r(t.getRangeAt(0));
|
|
1561
1455
|
}
|
|
1562
|
-
function
|
|
1456
|
+
function ri(e) {
|
|
1563
1457
|
let { selection: t } = e.state;
|
|
1564
1458
|
if (t.empty) return null;
|
|
1565
1459
|
let n = Math.min(t.from, t.to), r = Math.max(t.from, t.to);
|
|
1566
1460
|
try {
|
|
1567
1461
|
let t = e.view.domAtPos(n), i = e.view.domAtPos(r), a = e.view.dom.ownerDocument.createRange();
|
|
1568
|
-
return a.setStart(t.node, t.offset), a.setEnd(i.node, i.offset),
|
|
1462
|
+
return a.setStart(t.node, t.offset), a.setEnd(i.node, i.offset), $r(a);
|
|
1569
1463
|
} catch {
|
|
1570
1464
|
return null;
|
|
1571
1465
|
}
|
|
1572
1466
|
}
|
|
1573
|
-
function
|
|
1467
|
+
function ii(e) {
|
|
1574
1468
|
let { selection: t } = e.state;
|
|
1575
1469
|
if (t.empty) return null;
|
|
1576
|
-
let n = Math.min(t.from, t.to), r = Math.max(t.from, t.to), i = e.view.coordsAtPos(n), a = e.view.coordsAtPos(r, -1), o = Math.min(i.top, a.top), s = Math.max(i.bottom, a.bottom), c = Math.min(i.left, a.left), l =
|
|
1577
|
-
return
|
|
1470
|
+
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 = Yr(c, o, Math.max(i.right, a.right) - c, s - o);
|
|
1471
|
+
return Xr(l) ? [l] : null;
|
|
1578
1472
|
}
|
|
1579
|
-
function
|
|
1580
|
-
return
|
|
1473
|
+
function ai(e) {
|
|
1474
|
+
return ni(e) ?? ri(e) ?? ii(e);
|
|
1581
1475
|
}
|
|
1582
|
-
function
|
|
1583
|
-
let t =
|
|
1584
|
-
return t && t.length > 0 ?
|
|
1476
|
+
function oi(e) {
|
|
1477
|
+
let t = ai(e);
|
|
1478
|
+
return t && t.length > 0 ? Zr(t) : null;
|
|
1585
1479
|
}
|
|
1586
|
-
function
|
|
1480
|
+
function si(e) {
|
|
1587
1481
|
return {
|
|
1588
|
-
getBoundingClientRect: () =>
|
|
1589
|
-
getClientRects: () =>
|
|
1482
|
+
getBoundingClientRect: () => oi(e) ?? Yr(0, 0, 0, 0),
|
|
1483
|
+
getClientRects: () => ai(e) ?? []
|
|
1590
1484
|
};
|
|
1591
1485
|
}
|
|
1592
|
-
function
|
|
1486
|
+
function ci(e) {
|
|
1593
1487
|
return e === "block-type" || e === "link" || e === "color" || e === "more";
|
|
1594
1488
|
}
|
|
1595
|
-
function
|
|
1596
|
-
n?.(
|
|
1489
|
+
function li(e, t, n) {
|
|
1490
|
+
n?.(wn(e, t)), e.commands.focus();
|
|
1597
1491
|
}
|
|
1598
|
-
function
|
|
1599
|
-
let i =
|
|
1492
|
+
function ui({ editor: e, messages: t = Wr, selectionSnapshot: n, onRewriteSelection: r }) {
|
|
1493
|
+
let i = G(() => kn(t), [t]), a = st(n, { editable: e.isEditable }), [o, s] = q(a), [c, l] = q(null), [u, d] = q(null), [f, p] = q(null), [m, h] = q(""), [g, _] = q(""), [v, y] = q(null), [b, x] = q(0), [S, C] = q(a.boundaryPadding), [w, T] = q("bottom"), E = K(0), D = K(null), O = K(null), k = K(null), A = K(null), j = Tn(e, o.variant, t), M = jn(j.find((e) => e.id === c) ?? null), N = Hn(m), P = H(() => {
|
|
1600
1494
|
let t = D.current, n = e.view.dom.closest(".markweave-editor-frame");
|
|
1601
1495
|
if (!t || !(n instanceof HTMLElement)) return;
|
|
1602
|
-
let r = t.getBoundingClientRect(), i = n.getBoundingClientRect(), a =
|
|
1496
|
+
let r = t.getBoundingClientRect(), i = n.getBoundingClientRect(), a = qr(t, O.current), s = E.current, c = nt({
|
|
1603
1497
|
toolbarRect: {
|
|
1604
1498
|
left: r.left - s,
|
|
1605
1499
|
top: r.top,
|
|
@@ -1613,7 +1507,7 @@ function bi({ editor: e, messages: t = ei, selectionSnapshot: n, onRewriteSelect
|
|
|
1613
1507
|
height: i.height
|
|
1614
1508
|
},
|
|
1615
1509
|
boundaryPadding: o.boundaryPadding
|
|
1616
|
-
}), l =
|
|
1510
|
+
}), l = it({
|
|
1617
1511
|
frameRect: {
|
|
1618
1512
|
left: i.left,
|
|
1619
1513
|
top: i.top,
|
|
@@ -1632,16 +1526,16 @@ function bi({ editor: e, messages: t = ei, selectionSnapshot: n, onRewriteSelect
|
|
|
1632
1526
|
e.view.dom,
|
|
1633
1527
|
o.boundaryPadding,
|
|
1634
1528
|
o.offset
|
|
1635
|
-
]),
|
|
1529
|
+
]), F = H(() => {
|
|
1636
1530
|
D.current && (D.current.style.visibility = "hidden", D.current.style.opacity = "0");
|
|
1637
|
-
}, []),
|
|
1638
|
-
|
|
1639
|
-
}, [
|
|
1531
|
+
}, []), ee = H(() => {
|
|
1532
|
+
P();
|
|
1533
|
+
}, [P]), I = H(() => si(e), [e]), L = H((e) => {
|
|
1640
1534
|
k.current = e;
|
|
1641
|
-
}, []),
|
|
1535
|
+
}, []), te = H(() => {
|
|
1642
1536
|
let t = D.current, n = k.current, r = e.view.dom.closest(".markweave-editor-frame");
|
|
1643
1537
|
if (!f || !t || !n) return;
|
|
1644
|
-
let i = t.getBoundingClientRect(), a = n.getBoundingClientRect(), s = r?.getBoundingClientRect() ?? null, c =
|
|
1538
|
+
let i = t.getBoundingClientRect(), a = n.getBoundingClientRect(), s = r?.getBoundingClientRect() ?? null, c = rt({
|
|
1645
1539
|
toolbarRect: i,
|
|
1646
1540
|
popoverSize: a,
|
|
1647
1541
|
viewport: {
|
|
@@ -1657,19 +1551,19 @@ function bi({ editor: e, messages: t = ei, selectionSnapshot: n, onRewriteSelect
|
|
|
1657
1551
|
e.view.dom,
|
|
1658
1552
|
f,
|
|
1659
1553
|
o.boundaryPadding
|
|
1660
|
-
]),
|
|
1661
|
-
...
|
|
1662
|
-
onShow:
|
|
1663
|
-
onUpdate:
|
|
1554
|
+
]), R = G(() => ({
|
|
1555
|
+
...ot(o, { topBoundaryPadding: S }),
|
|
1556
|
+
onShow: F,
|
|
1557
|
+
onUpdate: ee
|
|
1664
1558
|
}), [
|
|
1665
|
-
P,
|
|
1666
1559
|
F,
|
|
1560
|
+
ee,
|
|
1667
1561
|
o,
|
|
1668
1562
|
S
|
|
1669
1563
|
]);
|
|
1670
1564
|
U(() => {
|
|
1671
|
-
let e =
|
|
1672
|
-
s((t) =>
|
|
1565
|
+
let e = Gr();
|
|
1566
|
+
s((t) => ut(t, a, e));
|
|
1673
1567
|
}, [
|
|
1674
1568
|
a.hiddenReason,
|
|
1675
1569
|
a.motionDurationMs,
|
|
@@ -1683,8 +1577,8 @@ function bi({ editor: e, messages: t = ei, selectionSnapshot: n, onRewriteSelect
|
|
|
1683
1577
|
a.visibility
|
|
1684
1578
|
]), U(() => {
|
|
1685
1579
|
if (o.motionStartedAtMs === null || o.motionDurationMs <= 0) return;
|
|
1686
|
-
let e = Math.max(0, o.motionStartedAtMs + o.motionDurationMs -
|
|
1687
|
-
s((e) =>
|
|
1580
|
+
let e = Math.max(0, o.motionStartedAtMs + o.motionDurationMs - Gr()), t = window.setTimeout(() => {
|
|
1581
|
+
s((e) => et(e, Gr()));
|
|
1688
1582
|
}, e);
|
|
1689
1583
|
return () => {
|
|
1690
1584
|
window.clearTimeout(t);
|
|
@@ -1693,17 +1587,17 @@ function bi({ editor: e, messages: t = ei, selectionSnapshot: n, onRewriteSelect
|
|
|
1693
1587
|
o.motionDurationMs,
|
|
1694
1588
|
o.motionPhase,
|
|
1695
1589
|
o.motionStartedAtMs
|
|
1696
|
-
]),
|
|
1590
|
+
]), W(() => {
|
|
1697
1591
|
if (o.visibility !== "visible") {
|
|
1698
1592
|
E.current = 0, D.current && (D.current.style.marginLeft = "", D.current.style.visibility = "hidden", D.current.style.opacity = "0"), x(0), C(o.boundaryPadding);
|
|
1699
1593
|
return;
|
|
1700
1594
|
}
|
|
1701
|
-
let e =
|
|
1595
|
+
let e = Sn(P);
|
|
1702
1596
|
return e.schedule(), window.addEventListener("resize", e.schedule), window.addEventListener("scroll", e.schedule, !0), () => {
|
|
1703
1597
|
e.cancel(), window.removeEventListener("resize", e.schedule), window.removeEventListener("scroll", e.schedule, !0);
|
|
1704
1598
|
};
|
|
1705
1599
|
}, [
|
|
1706
|
-
|
|
1600
|
+
P,
|
|
1707
1601
|
e.view.dom,
|
|
1708
1602
|
f,
|
|
1709
1603
|
n?.from,
|
|
@@ -1711,13 +1605,13 @@ function bi({ editor: e, messages: t = ei, selectionSnapshot: n, onRewriteSelect
|
|
|
1711
1605
|
o.variant,
|
|
1712
1606
|
o.visibility,
|
|
1713
1607
|
j.length
|
|
1714
|
-
]),
|
|
1608
|
+
]), W(() => {
|
|
1715
1609
|
if (!f) return;
|
|
1716
|
-
let e =
|
|
1610
|
+
let e = Sn(te);
|
|
1717
1611
|
return e.schedule(), window.addEventListener("resize", e.schedule), window.addEventListener("scroll", e.schedule, !0), () => {
|
|
1718
1612
|
e.cancel(), window.removeEventListener("resize", e.schedule), window.removeEventListener("scroll", e.schedule, !0);
|
|
1719
1613
|
};
|
|
1720
|
-
}, [f,
|
|
1614
|
+
}, [f, te]), U(() => {
|
|
1721
1615
|
f === "more" && i.some((e) => e.id === c) || j.some((e) => e.id === c) || (l(null), d(null));
|
|
1722
1616
|
}, [
|
|
1723
1617
|
i,
|
|
@@ -1741,11 +1635,11 @@ function bi({ editor: e, messages: t = ei, selectionSnapshot: n, onRewriteSelect
|
|
|
1741
1635
|
});
|
|
1742
1636
|
return () => window.cancelAnimationFrame(e);
|
|
1743
1637
|
}, [f]);
|
|
1744
|
-
let
|
|
1745
|
-
if (
|
|
1638
|
+
let z = (t) => {
|
|
1639
|
+
if (ci(t.id)) {
|
|
1746
1640
|
let n = t.id;
|
|
1747
1641
|
if (n === "link") {
|
|
1748
|
-
let t =
|
|
1642
|
+
let t = Dn(e);
|
|
1749
1643
|
h(t), _(t), y({
|
|
1750
1644
|
from: Math.min(e.state.selection.from, e.state.selection.to),
|
|
1751
1645
|
to: Math.max(e.state.selection.from, e.state.selection.to)
|
|
@@ -1755,23 +1649,23 @@ function bi({ editor: e, messages: t = ei, selectionSnapshot: n, onRewriteSelect
|
|
|
1755
1649
|
return;
|
|
1756
1650
|
}
|
|
1757
1651
|
if (p(null), t.id === "improve") {
|
|
1758
|
-
|
|
1652
|
+
li(e, "rewrite-selection", r);
|
|
1759
1653
|
return;
|
|
1760
1654
|
}
|
|
1761
1655
|
t.run(), e.commands.focus();
|
|
1762
|
-
},
|
|
1656
|
+
}, ne = () => {
|
|
1763
1657
|
p(null), e.commands.focus();
|
|
1764
|
-
},
|
|
1658
|
+
}, re = () => {
|
|
1765
1659
|
v && e.commands.setTextSelection(v);
|
|
1660
|
+
}, ie = () => {
|
|
1661
|
+
re(), Cn(e, m) && ne();
|
|
1766
1662
|
}, ae = () => {
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
if (ie(), Gn(e)) {
|
|
1770
|
-
h(""), _(""), R();
|
|
1663
|
+
if (re(), Ln(e)) {
|
|
1664
|
+
h(""), _(""), ne();
|
|
1771
1665
|
return;
|
|
1772
1666
|
}
|
|
1773
1667
|
m.trim() && h("");
|
|
1774
|
-
},
|
|
1668
|
+
}, B = (e, t) => {
|
|
1775
1669
|
if (l(e), !e || !t || !O.current) {
|
|
1776
1670
|
d(null);
|
|
1777
1671
|
return;
|
|
@@ -1779,64 +1673,64 @@ function bi({ editor: e, messages: t = ei, selectionSnapshot: n, onRewriteSelect
|
|
|
1779
1673
|
let n = t.getBoundingClientRect(), r = O.current.getBoundingClientRect();
|
|
1780
1674
|
d(n.left + n.width / 2 - r.left);
|
|
1781
1675
|
};
|
|
1782
|
-
return /* @__PURE__ */ Z(
|
|
1676
|
+
return /* @__PURE__ */ Z(xn, {
|
|
1783
1677
|
ref: D,
|
|
1784
1678
|
editor: e,
|
|
1785
1679
|
className: `markweave-floating-toolbar markweave-floating-toolbar--${o.variant} markweave-floating-toolbar--motion-${o.motionPhase}`,
|
|
1786
1680
|
"data-motion": o.motionPhase,
|
|
1787
|
-
"data-position-strategy":
|
|
1681
|
+
"data-position-strategy": R.strategy,
|
|
1788
1682
|
"data-boundary-padding": o.boundaryPadding,
|
|
1789
1683
|
"data-popover-placement": f ? w : void 0,
|
|
1790
1684
|
"data-testid": "markweave-floating-toolbar",
|
|
1791
|
-
style:
|
|
1685
|
+
style: Kr(o, b),
|
|
1792
1686
|
updateDelay: 0,
|
|
1793
|
-
getReferencedVirtualElement:
|
|
1794
|
-
options:
|
|
1795
|
-
shouldShow: ({ editor: e }) => e.isEditable &&
|
|
1687
|
+
getReferencedVirtualElement: I,
|
|
1688
|
+
options: R,
|
|
1689
|
+
shouldShow: ({ editor: e }) => e.isEditable && lt(at(e)),
|
|
1796
1690
|
children: /* @__PURE__ */ Q("div", {
|
|
1797
1691
|
ref: O,
|
|
1798
1692
|
className: "markweave-floating-toolbar-content",
|
|
1799
1693
|
"data-menu": f ?? "none",
|
|
1800
1694
|
children: [
|
|
1801
|
-
j.map((e, t) => /* @__PURE__ */ Z(
|
|
1695
|
+
j.map((e, t) => /* @__PURE__ */ Z(fi, {
|
|
1802
1696
|
button: e,
|
|
1803
1697
|
expanded: f === e.id,
|
|
1804
1698
|
showDivider: t > 0 && j[t - 1].group !== e.group,
|
|
1805
1699
|
tooltipActive: c === e.id,
|
|
1806
|
-
onPointerDown:
|
|
1807
|
-
onTooltipChange:
|
|
1808
|
-
onRun:
|
|
1700
|
+
onPointerDown: In,
|
|
1701
|
+
onTooltipChange: B,
|
|
1702
|
+
onRun: z
|
|
1809
1703
|
}, e.id)),
|
|
1810
|
-
f === "block-type" ? /* @__PURE__ */ Z(
|
|
1704
|
+
f === "block-type" ? /* @__PURE__ */ Z(mi, {
|
|
1811
1705
|
editor: e,
|
|
1812
1706
|
messages: t,
|
|
1813
|
-
onPopoverRef:
|
|
1707
|
+
onPopoverRef: L,
|
|
1814
1708
|
onClose: () => p(null)
|
|
1815
1709
|
}) : null,
|
|
1816
|
-
f === "link" ? /* @__PURE__ */ Z(
|
|
1710
|
+
f === "link" ? /* @__PURE__ */ Z(di, {
|
|
1817
1711
|
inputRef: A,
|
|
1818
1712
|
messages: t,
|
|
1819
1713
|
value: m,
|
|
1820
|
-
canApply: !!
|
|
1821
|
-
canOpen: !!
|
|
1714
|
+
canApply: !!N,
|
|
1715
|
+
canOpen: !!N,
|
|
1822
1716
|
canRemove: !!(g || m.trim()),
|
|
1823
1717
|
onValueChange: h,
|
|
1824
|
-
onApply:
|
|
1825
|
-
onOpen: () =>
|
|
1826
|
-
onRemove:
|
|
1827
|
-
onPopoverRef:
|
|
1718
|
+
onApply: ie,
|
|
1719
|
+
onOpen: () => Fn(m),
|
|
1720
|
+
onRemove: ae,
|
|
1721
|
+
onPopoverRef: L
|
|
1828
1722
|
}) : null,
|
|
1829
|
-
f === "color" ? /* @__PURE__ */ Z(
|
|
1723
|
+
f === "color" ? /* @__PURE__ */ Z(gi, {
|
|
1830
1724
|
editor: e,
|
|
1831
1725
|
messages: t,
|
|
1832
|
-
onPopoverRef:
|
|
1726
|
+
onPopoverRef: L,
|
|
1833
1727
|
onClose: () => p(null)
|
|
1834
1728
|
}) : null,
|
|
1835
|
-
f === "more" ? /* @__PURE__ */ Z(
|
|
1729
|
+
f === "more" ? /* @__PURE__ */ Z(vi, {
|
|
1836
1730
|
editor: e,
|
|
1837
1731
|
messages: t,
|
|
1838
1732
|
activeTooltipId: c,
|
|
1839
|
-
onPopoverRef:
|
|
1733
|
+
onPopoverRef: L,
|
|
1840
1734
|
onTooltipChange: l,
|
|
1841
1735
|
onClose: () => p(null)
|
|
1842
1736
|
}) : null,
|
|
@@ -1846,15 +1740,15 @@ function bi({ editor: e, messages: t = ei, selectionSnapshot: n, onRewriteSelect
|
|
|
1846
1740
|
"data-testid": "markweave-floating-toolbar-tooltip",
|
|
1847
1741
|
"data-button-id": M.buttonId,
|
|
1848
1742
|
"data-active": M.active,
|
|
1849
|
-
style:
|
|
1743
|
+
style: Jr(u),
|
|
1850
1744
|
children: M.label
|
|
1851
1745
|
}) : null
|
|
1852
1746
|
]
|
|
1853
1747
|
})
|
|
1854
1748
|
});
|
|
1855
1749
|
}
|
|
1856
|
-
function
|
|
1857
|
-
let d =
|
|
1750
|
+
function di({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRemove: a, onValueChange: o, onApply: s, onOpen: c, onRemove: l, onPopoverRef: u }) {
|
|
1751
|
+
let d = On(t);
|
|
1858
1752
|
return /* @__PURE__ */ Q("form", {
|
|
1859
1753
|
ref: u,
|
|
1860
1754
|
className: "markweave-floating-toolbar-popover markweave-floating-toolbar-link-popover",
|
|
@@ -1877,7 +1771,7 @@ function xi({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRe
|
|
|
1877
1771
|
"aria-label": d.applyLink,
|
|
1878
1772
|
"data-testid": "markweave-floating-toolbar-link-apply",
|
|
1879
1773
|
disabled: !r,
|
|
1880
|
-
onMouseDown:
|
|
1774
|
+
onMouseDown: In,
|
|
1881
1775
|
children: /* @__PURE__ */ Z($, { name: "corner-down-left" })
|
|
1882
1776
|
}),
|
|
1883
1777
|
/* @__PURE__ */ Z("span", {
|
|
@@ -1889,7 +1783,7 @@ function xi({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRe
|
|
|
1889
1783
|
"aria-label": d.openLink,
|
|
1890
1784
|
"data-testid": "markweave-floating-toolbar-link-open",
|
|
1891
1785
|
disabled: !i,
|
|
1892
|
-
onMouseDown:
|
|
1786
|
+
onMouseDown: In,
|
|
1893
1787
|
onClick: c,
|
|
1894
1788
|
children: /* @__PURE__ */ Z($, { name: "external-link" })
|
|
1895
1789
|
}),
|
|
@@ -1898,7 +1792,7 @@ function xi({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRe
|
|
|
1898
1792
|
"aria-label": d.removeLink,
|
|
1899
1793
|
"data-testid": "markweave-floating-toolbar-link-remove",
|
|
1900
1794
|
disabled: !a,
|
|
1901
|
-
onMouseDown:
|
|
1795
|
+
onMouseDown: In,
|
|
1902
1796
|
onClick: l,
|
|
1903
1797
|
children: /* @__PURE__ */ Z($, { name: "trash" })
|
|
1904
1798
|
})
|
|
@@ -1906,7 +1800,7 @@ function xi({ inputRef: e, messages: t, value: n, canApply: r, canOpen: i, canRe
|
|
|
1906
1800
|
})]
|
|
1907
1801
|
});
|
|
1908
1802
|
}
|
|
1909
|
-
function
|
|
1803
|
+
function fi({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointerDown: i, onTooltipChange: a, onRun: o }) {
|
|
1910
1804
|
return /* @__PURE__ */ Q(X, { children: [n ? /* @__PURE__ */ Z("span", {
|
|
1911
1805
|
className: "markweave-floating-toolbar-divider",
|
|
1912
1806
|
"aria-hidden": "true"
|
|
@@ -1914,7 +1808,7 @@ function Si({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointe
|
|
|
1914
1808
|
type: "button",
|
|
1915
1809
|
className: `markweave-floating-toolbar-button markweave-floating-toolbar-button--${e.id}`,
|
|
1916
1810
|
"aria-label": e.label,
|
|
1917
|
-
"aria-expanded":
|
|
1811
|
+
"aria-expanded": ci(e.id) ? t : void 0,
|
|
1918
1812
|
"data-active": e.active || t,
|
|
1919
1813
|
"data-tooltip-active": r ? "true" : "false",
|
|
1920
1814
|
"data-testid": `markweave-floating-toolbar-button-${e.id}`,
|
|
@@ -1924,13 +1818,13 @@ function Si({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointe
|
|
|
1924
1818
|
onMouseEnter: (t) => a(e.id, t.currentTarget),
|
|
1925
1819
|
onMouseLeave: () => a(null),
|
|
1926
1820
|
onClick: () => o(e),
|
|
1927
|
-
children: /* @__PURE__ */ Z(
|
|
1821
|
+
children: /* @__PURE__ */ Z(pi, {
|
|
1928
1822
|
button: e,
|
|
1929
1823
|
expanded: t
|
|
1930
1824
|
})
|
|
1931
1825
|
})] });
|
|
1932
1826
|
}
|
|
1933
|
-
function
|
|
1827
|
+
function pi({ button: e, expanded: t }) {
|
|
1934
1828
|
return e.id === "improve" ? /* @__PURE__ */ Q("span", {
|
|
1935
1829
|
className: "markweave-floating-toolbar-button-inner",
|
|
1936
1830
|
children: [/* @__PURE__ */ Z($, { name: "sparkles" }), /* @__PURE__ */ Z("span", { children: e.glyph })]
|
|
@@ -1948,8 +1842,8 @@ function Ci({ button: e, expanded: t }) {
|
|
|
1948
1842
|
}), /* @__PURE__ */ Z($, { name: t ? "chevron-up" : "chevron-down" })]
|
|
1949
1843
|
}) : /* @__PURE__ */ Z($, { name: "more" });
|
|
1950
1844
|
}
|
|
1951
|
-
function
|
|
1952
|
-
let i =
|
|
1845
|
+
function mi({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
|
|
1846
|
+
let i = On(t), a = Mn(t);
|
|
1953
1847
|
return /* @__PURE__ */ Q("div", {
|
|
1954
1848
|
ref: n,
|
|
1955
1849
|
className: "markweave-floating-toolbar-popover markweave-floating-toolbar-turn-menu",
|
|
@@ -1959,48 +1853,48 @@ function wi({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
|
|
|
1959
1853
|
children: i.turnIntoTitle
|
|
1960
1854
|
}), a.map((t) => /* @__PURE__ */ Q("button", {
|
|
1961
1855
|
type: "button",
|
|
1962
|
-
"data-active":
|
|
1856
|
+
"data-active": Pn(e, t.id),
|
|
1963
1857
|
"data-testid": `markweave-floating-toolbar-turn-${t.id}`,
|
|
1964
|
-
onMouseDown:
|
|
1858
|
+
onMouseDown: In,
|
|
1965
1859
|
onClick: () => {
|
|
1966
|
-
|
|
1860
|
+
Vn(e, t.id), r();
|
|
1967
1861
|
},
|
|
1968
1862
|
children: [/* @__PURE__ */ Z("span", {
|
|
1969
1863
|
className: "markweave-floating-toolbar-menu-icon",
|
|
1970
|
-
children: /* @__PURE__ */ Z(
|
|
1864
|
+
children: /* @__PURE__ */ Z(hi, { option: t })
|
|
1971
1865
|
}), /* @__PURE__ */ Z("span", { children: t.label })]
|
|
1972
1866
|
}, t.id))]
|
|
1973
1867
|
});
|
|
1974
1868
|
}
|
|
1975
|
-
function
|
|
1869
|
+
function hi({ option: e }) {
|
|
1976
1870
|
return e.id === "paragraph" ? /* @__PURE__ */ Z($, { name: "text" }) : e.glyph === "bullet-list" || e.glyph === "numbered-list" || e.glyph === "todo-list" || e.glyph === "quote" || e.glyph === "code-block" ? /* @__PURE__ */ Z($, { name: e.glyph }) : /* @__PURE__ */ Z("span", { children: e.glyph });
|
|
1977
1871
|
}
|
|
1978
|
-
function
|
|
1979
|
-
let i =
|
|
1872
|
+
function gi({ editor: e, messages: t, onPopoverRef: n, onClose: r }) {
|
|
1873
|
+
let i = On(t), a = e.getAttributes("textStyle").color, o = e.getAttributes("highlight").color;
|
|
1980
1874
|
return /* @__PURE__ */ Q("div", {
|
|
1981
1875
|
ref: n,
|
|
1982
1876
|
className: "markweave-floating-toolbar-popover markweave-floating-toolbar-color-popover",
|
|
1983
1877
|
"data-testid": "markweave-floating-toolbar-color-menu",
|
|
1984
|
-
children: [/* @__PURE__ */ Z(
|
|
1878
|
+
children: [/* @__PURE__ */ Z(_i, {
|
|
1985
1879
|
title: i.textColorTitle,
|
|
1986
1880
|
mode: "text",
|
|
1987
1881
|
activeColor: a ?? null,
|
|
1988
|
-
options:
|
|
1882
|
+
options: An(t),
|
|
1989
1883
|
onSelect: (t) => {
|
|
1990
|
-
|
|
1884
|
+
Bn(e, t), r();
|
|
1991
1885
|
}
|
|
1992
|
-
}), /* @__PURE__ */ Z(
|
|
1886
|
+
}), /* @__PURE__ */ Z(_i, {
|
|
1993
1887
|
title: i.highlightColorTitle,
|
|
1994
1888
|
mode: "highlight",
|
|
1995
1889
|
activeColor: o ?? null,
|
|
1996
|
-
options:
|
|
1890
|
+
options: En(t),
|
|
1997
1891
|
onSelect: (t) => {
|
|
1998
|
-
|
|
1892
|
+
zn(e, t), r();
|
|
1999
1893
|
}
|
|
2000
1894
|
})]
|
|
2001
1895
|
});
|
|
2002
1896
|
}
|
|
2003
|
-
function
|
|
1897
|
+
function _i({ title: e, mode: t, activeColor: n, options: r, onSelect: i }) {
|
|
2004
1898
|
return /* @__PURE__ */ Q("section", {
|
|
2005
1899
|
className: "markweave-floating-toolbar-color-section",
|
|
2006
1900
|
"aria-label": e,
|
|
@@ -2014,7 +1908,7 @@ function Di({ title: e, mode: t, activeColor: n, options: r, onSelect: i }) {
|
|
|
2014
1908
|
"aria-label": e.label,
|
|
2015
1909
|
"data-active": e.value === n || e.value === null && !n,
|
|
2016
1910
|
"data-testid": `markweave-floating-toolbar-${t}-${e.id}`,
|
|
2017
|
-
onMouseDown:
|
|
1911
|
+
onMouseDown: In,
|
|
2018
1912
|
onClick: () => i(e.value),
|
|
2019
1913
|
children: t === "text" ? /* @__PURE__ */ Z("span", {
|
|
2020
1914
|
className: "markweave-floating-toolbar-text-swatch",
|
|
@@ -2029,25 +1923,25 @@ function Di({ title: e, mode: t, activeColor: n, options: r, onSelect: i }) {
|
|
|
2029
1923
|
})]
|
|
2030
1924
|
});
|
|
2031
1925
|
}
|
|
2032
|
-
function
|
|
2033
|
-
let o =
|
|
1926
|
+
function vi({ editor: e, messages: t, activeTooltipId: n, onPopoverRef: r, onTooltipChange: i, onClose: a }) {
|
|
1927
|
+
let o = kn(t);
|
|
2034
1928
|
return /* @__PURE__ */ Z("div", {
|
|
2035
1929
|
ref: r,
|
|
2036
1930
|
className: "markweave-floating-toolbar-popover markweave-floating-toolbar-more-menu",
|
|
2037
1931
|
"data-testid": "markweave-floating-toolbar-more-menu",
|
|
2038
|
-
children: o.map((t, r) => /* @__PURE__ */ Z(
|
|
1932
|
+
children: o.map((t, r) => /* @__PURE__ */ Z(yi, {
|
|
2039
1933
|
action: t,
|
|
2040
|
-
active:
|
|
1934
|
+
active: Nn(e, t.id),
|
|
2041
1935
|
tooltipActive: n === t.id,
|
|
2042
1936
|
showDivider: r > 0 && o[r - 1].group !== t.group,
|
|
2043
1937
|
onTooltipChange: i,
|
|
2044
1938
|
onRun: () => {
|
|
2045
|
-
|
|
1939
|
+
Rn(e, t.id), a();
|
|
2046
1940
|
}
|
|
2047
1941
|
}, t.id))
|
|
2048
1942
|
});
|
|
2049
1943
|
}
|
|
2050
|
-
function
|
|
1944
|
+
function yi({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipChange: i, onRun: a }) {
|
|
2051
1945
|
return /* @__PURE__ */ Q(X, { children: [r ? /* @__PURE__ */ Z("span", {
|
|
2052
1946
|
className: "markweave-floating-toolbar-divider",
|
|
2053
1947
|
"aria-hidden": "true"
|
|
@@ -2059,11 +1953,11 @@ function ki({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipC
|
|
|
2059
1953
|
"data-active": t,
|
|
2060
1954
|
"data-tooltip-active": n ? "true" : "false",
|
|
2061
1955
|
"data-testid": `markweave-floating-toolbar-more-${e.id}`,
|
|
2062
|
-
onMouseDown:
|
|
1956
|
+
onMouseDown: In,
|
|
2063
1957
|
onMouseEnter: () => i(e.id),
|
|
2064
1958
|
onMouseLeave: () => i(null),
|
|
2065
1959
|
onClick: a,
|
|
2066
|
-
children: /* @__PURE__ */ Z(
|
|
1960
|
+
children: /* @__PURE__ */ Z(bi, { id: e.id })
|
|
2067
1961
|
}), n ? /* @__PURE__ */ Z("div", {
|
|
2068
1962
|
className: "markweave-floating-toolbar-tooltip markweave-floating-toolbar-tooltip--more",
|
|
2069
1963
|
role: "tooltip",
|
|
@@ -2071,41 +1965,41 @@ function ki({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipC
|
|
|
2071
1965
|
}) : null]
|
|
2072
1966
|
})] });
|
|
2073
1967
|
}
|
|
2074
|
-
function
|
|
1968
|
+
function bi({ id: e }) {
|
|
2075
1969
|
return e === "superscript" ? /* @__PURE__ */ Z($, { name: "superscript" }) : e === "subscript" ? /* @__PURE__ */ Z($, { name: "subscript" }) : e === "inline-math" ? /* @__PURE__ */ Z($, { name: "math" }) : Z($, { name: e });
|
|
2076
1970
|
}
|
|
2077
|
-
var
|
|
2078
|
-
sparkles:
|
|
1971
|
+
var xi = {
|
|
1972
|
+
sparkles: se,
|
|
2079
1973
|
"chevron-down": v,
|
|
2080
1974
|
"chevron-up": y,
|
|
2081
1975
|
"corner-down-left": C,
|
|
2082
1976
|
"external-link": T,
|
|
2083
1977
|
bold: p,
|
|
2084
|
-
italic:
|
|
1978
|
+
italic: F,
|
|
2085
1979
|
underline: he,
|
|
2086
|
-
strike:
|
|
1980
|
+
strike: ce,
|
|
2087
1981
|
"inline-code": x,
|
|
2088
|
-
link:
|
|
2089
|
-
more:
|
|
1982
|
+
link: I,
|
|
1983
|
+
more: ne,
|
|
2090
1984
|
text: me,
|
|
2091
|
-
"bullet-list":
|
|
2092
|
-
"numbered-list":
|
|
2093
|
-
"todo-list":
|
|
2094
|
-
quote:
|
|
1985
|
+
"bullet-list": L,
|
|
1986
|
+
"numbered-list": R,
|
|
1987
|
+
"todo-list": te,
|
|
1988
|
+
quote: ae,
|
|
2095
1989
|
"code-block": m,
|
|
2096
|
-
superscript:
|
|
2097
|
-
subscript:
|
|
2098
|
-
math:
|
|
1990
|
+
superscript: ue,
|
|
1991
|
+
subscript: le,
|
|
1992
|
+
math: V,
|
|
2099
1993
|
"align-left": d,
|
|
2100
1994
|
"align-center": l,
|
|
2101
1995
|
"align-right": f,
|
|
2102
1996
|
"align-justify": u,
|
|
2103
1997
|
"decrease-indent": M,
|
|
2104
|
-
"increase-indent":
|
|
1998
|
+
"increase-indent": N,
|
|
2105
1999
|
trash: pe
|
|
2106
2000
|
};
|
|
2107
2001
|
function $({ name: e }) {
|
|
2108
|
-
let t =
|
|
2002
|
+
let t = xi[e];
|
|
2109
2003
|
return /* @__PURE__ */ Z(t, {
|
|
2110
2004
|
"aria-hidden": "true",
|
|
2111
2005
|
absoluteStrokeWidth: !0,
|
|
@@ -2115,11 +2009,11 @@ function $({ name: e }) {
|
|
|
2115
2009
|
}
|
|
2116
2010
|
//#endregion
|
|
2117
2011
|
//#region src/ui/math/MathEditorPopover.tsx
|
|
2118
|
-
function
|
|
2119
|
-
let i =
|
|
2012
|
+
function Si({ editor: e, messages: t, onClose: n, target: r }) {
|
|
2013
|
+
let i = K(null), a = K(null), [o, s] = q(r.latex), [c, l] = q(null), u = t.math, d = G(() => Dt(e, r) ?? 1, [e, r]), f = G(() => Ot(e, r), [e, r]), p = G(() => o === r.latex && f ? {
|
|
2120
2014
|
html: f,
|
|
2121
2015
|
error: !1
|
|
2122
|
-
} :
|
|
2016
|
+
} : Mt(o, r.kind, e), [
|
|
2123
2017
|
e,
|
|
2124
2018
|
f,
|
|
2125
2019
|
r.kind,
|
|
@@ -2127,12 +2021,12 @@ function Mi({ editor: e, messages: t, onClose: n, target: r }) {
|
|
|
2127
2021
|
o
|
|
2128
2022
|
]), m = o.trim().length > 0, h = H(() => {
|
|
2129
2023
|
if (typeof window > "u") return;
|
|
2130
|
-
let t =
|
|
2024
|
+
let t = Et(e, r), i = e.view.dom.closest(".markweave-editor-frame")?.getBoundingClientRect();
|
|
2131
2025
|
if (!t || !i) {
|
|
2132
2026
|
n();
|
|
2133
2027
|
return;
|
|
2134
2028
|
}
|
|
2135
|
-
l(
|
|
2029
|
+
l(Tt({
|
|
2136
2030
|
anchorRect: t,
|
|
2137
2031
|
frameRect: i,
|
|
2138
2032
|
kind: r.kind,
|
|
@@ -2149,12 +2043,12 @@ function Mi({ editor: e, messages: t, onClose: n, target: r }) {
|
|
|
2149
2043
|
U(() => {
|
|
2150
2044
|
s(r.latex);
|
|
2151
2045
|
}, [r.latex, r.pos]), U(() => {
|
|
2152
|
-
|
|
2046
|
+
Nt(e, r, !0), h();
|
|
2153
2047
|
let t = window.requestAnimationFrame(() => {
|
|
2154
2048
|
a.current?.focus({ preventScroll: !0 }), a.current?.select(), h();
|
|
2155
2049
|
});
|
|
2156
2050
|
return window.addEventListener("resize", h), window.addEventListener("scroll", h, !0), () => {
|
|
2157
|
-
window.cancelAnimationFrame(t), window.removeEventListener("resize", h), window.removeEventListener("scroll", h, !0),
|
|
2051
|
+
window.cancelAnimationFrame(t), window.removeEventListener("resize", h), window.removeEventListener("scroll", h, !0), Nt(e, r, !1);
|
|
2158
2052
|
};
|
|
2159
2053
|
}, [
|
|
2160
2054
|
e,
|
|
@@ -2169,7 +2063,7 @@ function Mi({ editor: e, messages: t, onClose: n, target: r }) {
|
|
|
2169
2063
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
2170
2064
|
}, [n]);
|
|
2171
2065
|
let _ = H(() => {
|
|
2172
|
-
m &&
|
|
2066
|
+
m && wt(e, r, o) && n();
|
|
2173
2067
|
}, [
|
|
2174
2068
|
m,
|
|
2175
2069
|
e,
|
|
@@ -2300,31 +2194,31 @@ function Mi({ editor: e, messages: t, onClose: n, target: r }) {
|
|
|
2300
2194
|
}
|
|
2301
2195
|
//#endregion
|
|
2302
2196
|
//#region src/ui/slash-command/SlashCommandMenu.tsx
|
|
2303
|
-
var
|
|
2304
|
-
type:
|
|
2197
|
+
var Ci = n("zh"), wi = {
|
|
2198
|
+
type: fe,
|
|
2305
2199
|
"heading-1": D,
|
|
2306
2200
|
"heading-2": O,
|
|
2307
2201
|
"heading-3": k,
|
|
2308
|
-
"bullet-list":
|
|
2309
|
-
"ordered-list":
|
|
2310
|
-
"task-list":
|
|
2311
|
-
blockquote:
|
|
2202
|
+
"bullet-list": L,
|
|
2203
|
+
"ordered-list": R,
|
|
2204
|
+
"task-list": te,
|
|
2205
|
+
blockquote: ae,
|
|
2312
2206
|
"code-block": m,
|
|
2313
|
-
info:
|
|
2314
|
-
tip:
|
|
2207
|
+
info: P,
|
|
2208
|
+
tip: ee,
|
|
2315
2209
|
warning: c,
|
|
2316
2210
|
error: b,
|
|
2317
2211
|
success: _,
|
|
2318
|
-
emoji:
|
|
2319
|
-
math:
|
|
2320
|
-
table:
|
|
2321
|
-
separator:
|
|
2212
|
+
emoji: oe,
|
|
2213
|
+
math: V,
|
|
2214
|
+
table: de,
|
|
2215
|
+
separator: z,
|
|
2322
2216
|
image: A,
|
|
2323
2217
|
video: _e,
|
|
2324
|
-
attachment:
|
|
2218
|
+
attachment: re
|
|
2325
2219
|
};
|
|
2326
|
-
function
|
|
2327
|
-
let t =
|
|
2220
|
+
function Ti({ name: e }) {
|
|
2221
|
+
let t = wi[e];
|
|
2328
2222
|
return /* @__PURE__ */ Z(t, {
|
|
2329
2223
|
"aria-hidden": "true",
|
|
2330
2224
|
absoluteStrokeWidth: !0,
|
|
@@ -2332,8 +2226,8 @@ function Fi({ name: e }) {
|
|
|
2332
2226
|
strokeWidth: 1.6
|
|
2333
2227
|
});
|
|
2334
2228
|
}
|
|
2335
|
-
function
|
|
2336
|
-
return !
|
|
2229
|
+
function Ei(e, t, n) {
|
|
2230
|
+
return !zt(e) || !n ? {
|
|
2337
2231
|
visible: !1,
|
|
2338
2232
|
empty: !1,
|
|
2339
2233
|
activeIndex: -1
|
|
@@ -2347,17 +2241,17 @@ function Ii(e, t, n) {
|
|
|
2347
2241
|
activeIndex: Math.min(t.length - 1, Math.max(0, e.activeIndex))
|
|
2348
2242
|
};
|
|
2349
2243
|
}
|
|
2350
|
-
function
|
|
2244
|
+
function Di(e, t) {
|
|
2351
2245
|
return Object.values(t.slash.groups).map((t) => ({
|
|
2352
2246
|
group: t,
|
|
2353
2247
|
commands: e.filter((e) => e.group === t)
|
|
2354
2248
|
})).filter((e) => e.commands.length > 0);
|
|
2355
2249
|
}
|
|
2356
|
-
function
|
|
2250
|
+
function Oi(e, t) {
|
|
2357
2251
|
return t.slash.uploadKindLabels[e] ?? t.slash.uploadKindLabels.upload;
|
|
2358
2252
|
}
|
|
2359
|
-
function
|
|
2360
|
-
let [i, a] =
|
|
2253
|
+
function ki({ command: e, messages: t, onBack: n, onSelect: r }) {
|
|
2254
|
+
let [i, a] = q(""), [o, s] = q(0), c = G(() => {
|
|
2361
2255
|
let e = i.trim().toLowerCase();
|
|
2362
2256
|
return (e ? t.slash.emojiItems.filter((t) => [
|
|
2363
2257
|
t.emoji,
|
|
@@ -2423,9 +2317,9 @@ function zi({ command: e, messages: t, onBack: n, onSelect: r }) {
|
|
|
2423
2317
|
]
|
|
2424
2318
|
});
|
|
2425
2319
|
}
|
|
2426
|
-
function
|
|
2427
|
-
let a = e.uploadKind ?? "attachment", [o, s] =
|
|
2428
|
-
r(e, { uploadResult: await
|
|
2320
|
+
function Ai({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
|
|
2321
|
+
let a = e.uploadKind ?? "attachment", [o, s] = q(""), [c, l] = q(null), [u, d] = q(null), [f, p] = q(!1), m = async (t) => {
|
|
2322
|
+
r(e, { uploadResult: await xe({
|
|
2429
2323
|
kind: a,
|
|
2430
2324
|
source: t,
|
|
2431
2325
|
trigger: "slash-command"
|
|
@@ -2445,7 +2339,7 @@ function Bi({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
|
|
|
2445
2339
|
d(t.slash.uploadRequiredError);
|
|
2446
2340
|
return;
|
|
2447
2341
|
}
|
|
2448
|
-
await m(
|
|
2342
|
+
await m(ye(o));
|
|
2449
2343
|
} catch (e) {
|
|
2450
2344
|
d(e instanceof Error ? e.message : t.slash.uploadFailedError);
|
|
2451
2345
|
} finally {
|
|
@@ -2463,7 +2357,7 @@ function Bi({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
|
|
|
2463
2357
|
onMouseDown: (e) => e.preventDefault(),
|
|
2464
2358
|
onClick: n,
|
|
2465
2359
|
children: t.common.back
|
|
2466
|
-
}), /* @__PURE__ */ Z("span", { children:
|
|
2360
|
+
}), /* @__PURE__ */ Z("span", { children: Oi(a, t) })]
|
|
2467
2361
|
}),
|
|
2468
2362
|
/* @__PURE__ */ Q("label", {
|
|
2469
2363
|
className: "markweave-slash-upload-field",
|
|
@@ -2511,10 +2405,10 @@ function Bi({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
|
|
|
2511
2405
|
]
|
|
2512
2406
|
});
|
|
2513
2407
|
}
|
|
2514
|
-
function
|
|
2515
|
-
let l =
|
|
2408
|
+
function ji({ commands: e, messages: t = Ci, state: n, position: r, inputCommand: i, onActiveIndexChange: a, onInputCommandChange: o, onSelect: s, onUpload: c }) {
|
|
2409
|
+
let l = Ei(n, e, r);
|
|
2516
2410
|
if (!l.visible || !r) return null;
|
|
2517
|
-
let u =
|
|
2411
|
+
let u = Di(e, t), d = {
|
|
2518
2412
|
left: r.left,
|
|
2519
2413
|
top: r.top,
|
|
2520
2414
|
maxHeight: r.maxHeight,
|
|
@@ -2536,12 +2430,12 @@ function Vi({ commands: e, messages: t = Ni, state: n, position: r, inputCommand
|
|
|
2536
2430
|
"aria-label": t.slash.ariaLabel,
|
|
2537
2431
|
"data-placement": r.placement,
|
|
2538
2432
|
"data-testid": "markweave-slash-menu",
|
|
2539
|
-
children: i?.inputKind === "emoji" ? /* @__PURE__ */ Z(
|
|
2433
|
+
children: i?.inputKind === "emoji" ? /* @__PURE__ */ Z(ki, {
|
|
2540
2434
|
command: i,
|
|
2541
2435
|
messages: t,
|
|
2542
2436
|
onBack: m,
|
|
2543
2437
|
onSelect: s
|
|
2544
|
-
}) : i?.inputKind === "upload" ? /* @__PURE__ */ Z(
|
|
2438
|
+
}) : i?.inputKind === "upload" ? /* @__PURE__ */ Z(Ai, {
|
|
2545
2439
|
command: i,
|
|
2546
2440
|
messages: t,
|
|
2547
2441
|
onBack: m,
|
|
@@ -2561,7 +2455,7 @@ function Vi({ commands: e, messages: t = Ni, state: n, position: r, inputCommand
|
|
|
2561
2455
|
className: "markweave-slash-group-title",
|
|
2562
2456
|
children: t.group
|
|
2563
2457
|
}), t.commands.map((t) => {
|
|
2564
|
-
let n = e.indexOf(t), r = n === l.activeIndex, i =
|
|
2458
|
+
let n = e.indexOf(t), r = n === l.activeIndex, i = Lt(t), o = !!t.disabled;
|
|
2565
2459
|
return /* @__PURE__ */ Q("button", {
|
|
2566
2460
|
type: "button",
|
|
2567
2461
|
role: "option",
|
|
@@ -2585,7 +2479,7 @@ function Vi({ commands: e, messages: t = Ni, state: n, position: r, inputCommand
|
|
|
2585
2479
|
}
|
|
2586
2480
|
},
|
|
2587
2481
|
children: [
|
|
2588
|
-
/* @__PURE__ */ Z(
|
|
2482
|
+
/* @__PURE__ */ Z(Ti, { name: t.icon }),
|
|
2589
2483
|
/* @__PURE__ */ Z("span", { children: t.label }),
|
|
2590
2484
|
o && t.disabledReason ? /* @__PURE__ */ Z("small", { children: t.disabledReason }) : null
|
|
2591
2485
|
]
|
|
@@ -2597,38 +2491,38 @@ function Vi({ commands: e, messages: t = Ni, state: n, position: r, inputCommand
|
|
|
2597
2491
|
}
|
|
2598
2492
|
//#endregion
|
|
2599
2493
|
//#region src/ui/table/TableControls.tsx
|
|
2600
|
-
var
|
|
2601
|
-
function
|
|
2602
|
-
let [s, c] =
|
|
2494
|
+
var Mi = n("zh");
|
|
2495
|
+
function Ni({ active: e, editor: t, interactionState: n = Xt, messages: r = Mi, onCopyPayload: i, onCommandResult: a, onEditWithAi: o }) {
|
|
2496
|
+
let [s, c] = q(null), [l, u] = q("row-edge"), [d, f] = q(null), [p, m] = q(null), [h, g] = q(null), [_, v] = q(null), [y, b] = q(null), x = K(null), S = K(null), C = K(null), w = K(null), T = K(null), E = e ? Jt(t.state) : null;
|
|
2603
2497
|
if (U(() => {
|
|
2604
2498
|
if (!y) return;
|
|
2605
2499
|
let e = window.setTimeout(() => {
|
|
2606
2500
|
b(null);
|
|
2607
|
-
},
|
|
2501
|
+
}, or);
|
|
2608
2502
|
return () => {
|
|
2609
2503
|
window.clearTimeout(e);
|
|
2610
2504
|
};
|
|
2611
|
-
}, [y]),
|
|
2505
|
+
}, [y]), W(() => {
|
|
2612
2506
|
if (!e) {
|
|
2613
2507
|
m(null), g(null), v(null), b(null);
|
|
2614
2508
|
return;
|
|
2615
2509
|
}
|
|
2616
2510
|
let r = () => {
|
|
2617
|
-
let e = t.view.dom.closest(".markweave-editor-frame") ?? t.view.dom.parentElement, r =
|
|
2511
|
+
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;
|
|
2618
2512
|
if (!e) {
|
|
2619
2513
|
m(null), g(null), v(null);
|
|
2620
2514
|
return;
|
|
2621
2515
|
}
|
|
2622
2516
|
let u = e.getBoundingClientRect();
|
|
2623
|
-
a ? m(
|
|
2517
|
+
a ? m(Gn({
|
|
2624
2518
|
targetRect: a,
|
|
2625
2519
|
frameRect: u,
|
|
2626
2520
|
kind: "row"
|
|
2627
|
-
})) : s === "row" && l === "row-edge" || m(null), o ? g(
|
|
2521
|
+
})) : s === "row" && l === "row-edge" || m(null), o ? g(Gn({
|
|
2628
2522
|
targetRect: o,
|
|
2629
2523
|
frameRect: u,
|
|
2630
2524
|
kind: "column"
|
|
2631
|
-
})) : s === "column" && l === "column-edge" || g(null), c ? v(
|
|
2525
|
+
})) : s === "column" && l === "column-edge" || g(null), c ? v(Gn({
|
|
2632
2526
|
targetRect: c,
|
|
2633
2527
|
frameRect: u,
|
|
2634
2528
|
kind: "selection"
|
|
@@ -2648,7 +2542,7 @@ function Ui({ active: e, editor: t, interactionState: n = Qt, messages: r = Hi,
|
|
|
2648
2542
|
n.hoverVisualRowIndex,
|
|
2649
2543
|
l,
|
|
2650
2544
|
s
|
|
2651
|
-
]),
|
|
2545
|
+
]), W(() => {
|
|
2652
2546
|
if (!e || !s) {
|
|
2653
2547
|
f(null);
|
|
2654
2548
|
return;
|
|
@@ -2659,12 +2553,12 @@ function Ui({ active: e, editor: t, interactionState: n = Qt, messages: r = Hi,
|
|
|
2659
2553
|
f(null);
|
|
2660
2554
|
return;
|
|
2661
2555
|
}
|
|
2662
|
-
let i = n.getBoundingClientRect(), a = s === "row" ?
|
|
2556
|
+
let i = n.getBoundingClientRect(), a = s === "row" ? Yn(t)?.getBoundingClientRect() : null, o = a ? {
|
|
2663
2557
|
left: i.left,
|
|
2664
2558
|
top: a.top,
|
|
2665
2559
|
width: i.width,
|
|
2666
2560
|
height: i.height
|
|
2667
|
-
} : i, c = e.getBoundingClientRect(), u = r.getBoundingClientRect(), d =
|
|
2561
|
+
} : i, c = e.getBoundingClientRect(), u = r.getBoundingClientRect(), d = Wn({
|
|
2668
2562
|
anchorRect: o,
|
|
2669
2563
|
frameRect: c,
|
|
2670
2564
|
menuSize: {
|
|
@@ -2705,22 +2599,22 @@ function Ui({ active: e, editor: t, interactionState: n = Qt, messages: r = Hi,
|
|
|
2705
2599
|
let n = s === e && l === t;
|
|
2706
2600
|
u(t), c(n ? null : e);
|
|
2707
2601
|
}, O = () => {
|
|
2708
|
-
t.view.dispatch(
|
|
2602
|
+
t.view.dispatch(Un(t.state.tr, null));
|
|
2709
2603
|
}, k = (e, r) => {
|
|
2710
2604
|
let i = n.hoverCellPos ?? E?.activeCellPos ?? null, a = n.hoverCellPos === null ? null : e === "row" ? n.hoverVisualRowIndex : n.hoverVisualColumnIndex;
|
|
2711
|
-
i !== null &&
|
|
2605
|
+
i !== null && ar(t, i, e, { visualIndex: a }), D(e, r);
|
|
2712
2606
|
}, A = () => {
|
|
2713
2607
|
O(), D("selection", "selection-edge");
|
|
2714
|
-
}, j =
|
|
2715
|
-
let o = await
|
|
2608
|
+
}, j = Qn(t, n, "row", E?.activeCellPos ?? null), M = Qn(t, n, "column", E?.activeCellPos ?? null), N = Xn(t).length > 0, P = s ? nr(t, s) : [], F = async (e, n) => {
|
|
2609
|
+
let o = await qn({
|
|
2716
2610
|
editor: t,
|
|
2717
2611
|
commandId: e,
|
|
2718
2612
|
menu: n ?? s ?? "selection",
|
|
2719
2613
|
messages: r
|
|
2720
2614
|
});
|
|
2721
2615
|
return o.copyFeedback ? (b(o.copyFeedback), o.copyPayload && i?.(o.copyPayload)) : b(null), a?.(o.commandResult), o.success;
|
|
2722
|
-
},
|
|
2723
|
-
let n =
|
|
2616
|
+
}, ee = (e) => {
|
|
2617
|
+
let n = $n(t, e);
|
|
2724
2618
|
n && o?.(n), c(null), t.view.focus();
|
|
2725
2619
|
};
|
|
2726
2620
|
return /* @__PURE__ */ Q("div", {
|
|
@@ -2739,7 +2633,7 @@ function Ui({ active: e, editor: t, interactionState: n = Qt, messages: r = Hi,
|
|
|
2739
2633
|
"data-copy-kind": y.kind,
|
|
2740
2634
|
"data-text-length": y.textLength,
|
|
2741
2635
|
"data-html-length": y.htmlLength,
|
|
2742
|
-
children:
|
|
2636
|
+
children: Jn(y)
|
|
2743
2637
|
}) : null,
|
|
2744
2638
|
p ? /* @__PURE__ */ Z("button", {
|
|
2745
2639
|
type: "button",
|
|
@@ -2793,7 +2687,7 @@ function Ui({ active: e, editor: t, interactionState: n = Qt, messages: r = Hi,
|
|
|
2793
2687
|
children: "..."
|
|
2794
2688
|
})
|
|
2795
2689
|
}) : null,
|
|
2796
|
-
|
|
2690
|
+
N && _ ? /* @__PURE__ */ Z("button", {
|
|
2797
2691
|
type: "button",
|
|
2798
2692
|
ref: T,
|
|
2799
2693
|
className: "markweave-table-edge-handle markweave-table-edge-handle--selection",
|
|
@@ -2817,15 +2711,15 @@ function Ui({ active: e, editor: t, interactionState: n = Qt, messages: r = Hi,
|
|
|
2817
2711
|
ref: S,
|
|
2818
2712
|
className: "markweave-table-menu",
|
|
2819
2713
|
role: "menu",
|
|
2820
|
-
"aria-label":
|
|
2714
|
+
"aria-label": sr(s, r),
|
|
2821
2715
|
"data-testid": "markweave-table-menu",
|
|
2822
2716
|
"data-positioned": d ? "true" : "false",
|
|
2823
2717
|
style: d ? {
|
|
2824
2718
|
left: d.left,
|
|
2825
2719
|
top: d.top
|
|
2826
2720
|
} : void 0,
|
|
2827
|
-
children:
|
|
2828
|
-
let i =
|
|
2721
|
+
children: P.map((e, n) => {
|
|
2722
|
+
let i = er(e), a = n === 0 ? i : er(P[n - 1]), l = n > 0 && a !== i, u = e.commandId === null ? !!o : Kn(t, e.commandId), d = tr(e, r);
|
|
2829
2723
|
return /* @__PURE__ */ Z("button", {
|
|
2830
2724
|
type: "button",
|
|
2831
2725
|
role: "menuitem",
|
|
@@ -2840,10 +2734,10 @@ function Ui({ active: e, editor: t, interactionState: n = Qt, messages: r = Hi,
|
|
|
2840
2734
|
onClick: () => {
|
|
2841
2735
|
if (u) {
|
|
2842
2736
|
if (e.commandId === null) {
|
|
2843
|
-
|
|
2737
|
+
ee(s === "row" || s === "column" ? s : "selection");
|
|
2844
2738
|
return;
|
|
2845
2739
|
}
|
|
2846
|
-
|
|
2740
|
+
F(e.commandId).finally(() => c(null));
|
|
2847
2741
|
}
|
|
2848
2742
|
},
|
|
2849
2743
|
children: d
|
|
@@ -2855,15 +2749,15 @@ function Ui({ active: e, editor: t, interactionState: n = Qt, messages: r = Hi,
|
|
|
2855
2749
|
}
|
|
2856
2750
|
//#endregion
|
|
2857
2751
|
//#region src/ui/table/TableSelectionOverlay.tsx
|
|
2858
|
-
function
|
|
2859
|
-
let [n, r] =
|
|
2860
|
-
return
|
|
2752
|
+
function Pi({ editor: e, focusState: t }) {
|
|
2753
|
+
let [n, r] = q(null);
|
|
2754
|
+
return W(() => {
|
|
2861
2755
|
if (t.mode !== "cell-selection") {
|
|
2862
2756
|
r(null);
|
|
2863
2757
|
return;
|
|
2864
2758
|
}
|
|
2865
2759
|
let n = () => {
|
|
2866
|
-
r(
|
|
2760
|
+
r(ir(e, Yt(e.state)));
|
|
2867
2761
|
};
|
|
2868
2762
|
return n(), window.addEventListener("resize", n), window.addEventListener("scroll", n, !0), () => {
|
|
2869
2763
|
window.removeEventListener("resize", n), window.removeEventListener("scroll", n, !0);
|
|
@@ -2898,16 +2792,16 @@ function Wi({ editor: e, focusState: t }) {
|
|
|
2898
2792
|
}
|
|
2899
2793
|
//#endregion
|
|
2900
2794
|
//#region src/ui/toc/MarkweaveInnerToc.tsx
|
|
2901
|
-
function
|
|
2795
|
+
function Fi(e, t) {
|
|
2902
2796
|
return `${e.toc.itemAriaLabel}: ${t.text}`;
|
|
2903
2797
|
}
|
|
2904
|
-
function
|
|
2905
|
-
let a =
|
|
2798
|
+
function Ii({ editor: e, state: t, messages: n, editable: r, placement: i }) {
|
|
2799
|
+
let a = K(null);
|
|
2906
2800
|
if (U(() => {
|
|
2907
|
-
if (!(i !== "container" || !a.current)) return
|
|
2801
|
+
if (!(i !== "container" || !a.current)) return mr(a.current);
|
|
2908
2802
|
}, [i]), !t.items.length) return null;
|
|
2909
2803
|
let o = (t) => {
|
|
2910
|
-
|
|
2804
|
+
hr(e, t, {
|
|
2911
2805
|
behavior: "smooth",
|
|
2912
2806
|
focus: r
|
|
2913
2807
|
});
|
|
@@ -2934,7 +2828,7 @@ function Ki({ editor: e, state: t, messages: n, editable: r, placement: i }) {
|
|
|
2934
2828
|
"data-level": e.level,
|
|
2935
2829
|
"data-active": e.active ? "true" : "false",
|
|
2936
2830
|
"aria-current": e.active ? "location" : void 0,
|
|
2937
|
-
"aria-label":
|
|
2831
|
+
"aria-label": Fi(n, e),
|
|
2938
2832
|
title: e.text,
|
|
2939
2833
|
onClick: () => o(e),
|
|
2940
2834
|
children: e.text
|
|
@@ -2945,7 +2839,7 @@ function Ki({ editor: e, state: t, messages: n, editable: r, placement: i }) {
|
|
|
2945
2839
|
}
|
|
2946
2840
|
//#endregion
|
|
2947
2841
|
//#region src/MarkweaveEditor.tsx
|
|
2948
|
-
var
|
|
2842
|
+
var Li = {
|
|
2949
2843
|
active: !1,
|
|
2950
2844
|
mode: "outside",
|
|
2951
2845
|
activeCellPos: null,
|
|
@@ -2953,21 +2847,21 @@ var qi = {
|
|
|
2953
2847
|
selectedCellCount: 0,
|
|
2954
2848
|
selectionFrom: 0,
|
|
2955
2849
|
selectionTo: 0
|
|
2956
|
-
},
|
|
2850
|
+
}, Ri = {
|
|
2957
2851
|
active: !1,
|
|
2958
|
-
language:
|
|
2852
|
+
language: ht.defaultLanguage,
|
|
2959
2853
|
mermaidPreviewMode: "code",
|
|
2960
2854
|
pos: null,
|
|
2961
2855
|
text: ""
|
|
2962
|
-
},
|
|
2856
|
+
}, zi = Ct({
|
|
2963
2857
|
active: !1,
|
|
2964
2858
|
mode: "code",
|
|
2965
2859
|
source: ""
|
|
2966
2860
|
});
|
|
2967
|
-
function
|
|
2968
|
-
return
|
|
2861
|
+
function Bi(e) {
|
|
2862
|
+
return Zt.getState(e.state) ?? Xt;
|
|
2969
2863
|
}
|
|
2970
|
-
function
|
|
2864
|
+
function Vi(e) {
|
|
2971
2865
|
if (!e || typeof window > "u") return null;
|
|
2972
2866
|
let t = e.parentElement;
|
|
2973
2867
|
for (; t;) {
|
|
@@ -2977,136 +2871,133 @@ function Zi(e) {
|
|
|
2977
2871
|
}
|
|
2978
2872
|
return null;
|
|
2979
2873
|
}
|
|
2980
|
-
function
|
|
2874
|
+
function Hi(e) {
|
|
2981
2875
|
return typeof window > "u" || typeof window.requestAnimationFrame != "function" ? globalThis.setTimeout(() => e(0), 0) : window.requestAnimationFrame(e);
|
|
2982
2876
|
}
|
|
2983
|
-
function
|
|
2877
|
+
function Ui(e) {
|
|
2984
2878
|
if (typeof window < "u" && typeof window.cancelAnimationFrame == "function") {
|
|
2985
2879
|
window.cancelAnimationFrame(e);
|
|
2986
2880
|
return;
|
|
2987
2881
|
}
|
|
2988
2882
|
globalThis.clearTimeout(e);
|
|
2989
2883
|
}
|
|
2990
|
-
function
|
|
2991
|
-
let
|
|
2992
|
-
editorMode:
|
|
2884
|
+
function Wi({ ariaLabel: e, autoFocusFirstTableBodyCell: i = !1, autofocus: a = !1, content: o, contentFormat: c, defaultContent: l = "", defaultContentFormat: u, editable: d = !0, innerToc: f = !0, innerTocPlacement: p, lang: m, mode: h = "live", theme: g, canvasColor: _, onEditWithAi: v, onExtractToNote: y, onRewriteSelection: b, onRuntimeStateChange: x, onSearchControllerChange: S, onSlashCommandUpload: C, onTableCommandResult: w, onTableCopyPayload: T, onTocChange: E, onUpdate: D, linkCardResolver: O } = {}) {
|
|
2885
|
+
let k = Ie(h), A = _r(g), j = gr(_), M = pr(p), N = k === "live" && d !== !1, P = Ze(o === void 0 ? u : c), F = K({
|
|
2886
|
+
editorMode: k,
|
|
2993
2887
|
effectiveEditable: N
|
|
2994
2888
|
});
|
|
2995
|
-
|
|
2996
|
-
editorMode:
|
|
2889
|
+
F.current = {
|
|
2890
|
+
editorMode: k,
|
|
2997
2891
|
effectiveEditable: N
|
|
2998
2892
|
};
|
|
2999
|
-
let
|
|
3000
|
-
|
|
3001
|
-
let
|
|
3002
|
-
|
|
3003
|
-
let
|
|
3004
|
-
|
|
3005
|
-
let
|
|
3006
|
-
|
|
3007
|
-
let
|
|
3008
|
-
lang:
|
|
2893
|
+
let ee = K(null);
|
|
2894
|
+
ee.current === null && (ee.current = r(m));
|
|
2895
|
+
let I = ee.current, L = G(() => n(I), [I]), te = G(() => t(I), [I]), R = K(C);
|
|
2896
|
+
R.current = C;
|
|
2897
|
+
let z = K(S);
|
|
2898
|
+
z.current = S;
|
|
2899
|
+
let ne = K(O);
|
|
2900
|
+
ne.current = O;
|
|
2901
|
+
let re = G(() => Br({
|
|
2902
|
+
lang: I,
|
|
3009
2903
|
onImageUpload: (e) => {
|
|
3010
|
-
if (
|
|
3011
|
-
let t =
|
|
2904
|
+
if (R.current) return R.current(e);
|
|
2905
|
+
let t = be(e);
|
|
3012
2906
|
if (!t) throw Error("File upload requires an upload handler.");
|
|
3013
2907
|
return t;
|
|
3014
2908
|
},
|
|
3015
2909
|
onVideoUpload: (e) => {
|
|
3016
|
-
if (
|
|
3017
|
-
let t =
|
|
2910
|
+
if (R.current) return R.current(e);
|
|
2911
|
+
let t = be(e);
|
|
3018
2912
|
if (!t) throw Error("File upload requires an upload handler.");
|
|
3019
2913
|
return t;
|
|
3020
2914
|
},
|
|
3021
|
-
linkCardResolver: (e) =>
|
|
3022
|
-
|
|
3023
|
-
}), [k, ae]), [de, fe] = K(null), [B, V] = K(Kt), [pe, me] = K(null), [he, ge] = K(null), [_e, ve] = K("code"), [ye, be] = K(null), [Se, Ce] = K(Qt), [we, Te] = K(null), [Ee, De] = K(0), Oe = G(!1), ke = G({
|
|
2915
|
+
linkCardResolver: (e) => ne.current?.(e) ?? Promise.resolve(null)
|
|
2916
|
+
}), [I]), [ie, ae] = q(null), [B, V] = q(Wt), [oe, se] = q(null), [ce, le] = q(null), [ue, de] = q("code"), [fe, pe] = q(null), [me, he] = q(Xt), [ge, _e] = q(null), [W, ve] = q(0), ye = K(!1), xe = K({
|
|
3024
2917
|
content: o,
|
|
3025
2918
|
format: P
|
|
3026
|
-
}),
|
|
3027
|
-
|
|
2919
|
+
}), Se = K(null), Ce = K(null), we = K({ onUpdate: D }), Te = G(() => It(B.query, te), [te, B.query]);
|
|
2920
|
+
we.current = { onUpdate: D }, xe.current = {
|
|
3028
2921
|
content: o,
|
|
3029
2922
|
format: P
|
|
3030
2923
|
};
|
|
3031
|
-
let
|
|
3032
|
-
|
|
3033
|
-
}, []),
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
},
|
|
2924
|
+
let Ee = H(() => {
|
|
2925
|
+
Ce.current !== null && (window.clearTimeout(Ce.current), Ce.current = null), ve((e) => e + 1);
|
|
2926
|
+
}, []), De = H(() => {
|
|
2927
|
+
Ce.current !== null && window.clearTimeout(Ce.current), Ce.current = window.setTimeout(() => {
|
|
2928
|
+
Ce.current = null, ve((e) => e + 1);
|
|
2929
|
+
}, ct);
|
|
3037
2930
|
}, []);
|
|
3038
2931
|
U(() => () => {
|
|
3039
|
-
|
|
2932
|
+
Ce.current !== null && window.clearTimeout(Ce.current);
|
|
3040
2933
|
}, []);
|
|
3041
|
-
let
|
|
3042
|
-
|
|
3043
|
-
}, []),
|
|
3044
|
-
let t =
|
|
2934
|
+
let Oe = H(() => {
|
|
2935
|
+
se(null), le(null), V(Wt);
|
|
2936
|
+
}, []), ke = H((e) => {
|
|
2937
|
+
let t = Ut(e.state);
|
|
3045
2938
|
if (!t) {
|
|
3046
|
-
V((e) => e.name === "idle" ? e :
|
|
2939
|
+
V((e) => e.name === "idle" ? e : Wt), se(null), le(null);
|
|
3047
2940
|
return;
|
|
3048
2941
|
}
|
|
3049
2942
|
let n = e.coordsAtPos(t.cursor), r = e.coordsAtPos(t.triggerFrom), i = e.dom.closest(".markweave-editor-frame")?.getBoundingClientRect();
|
|
3050
|
-
|
|
2943
|
+
se(Ht(n, {
|
|
3051
2944
|
frameRect: i,
|
|
3052
2945
|
triggerRect: r
|
|
3053
|
-
})), V((e) =>
|
|
3054
|
-
}, []),
|
|
3055
|
-
let t =
|
|
3056
|
-
|
|
3057
|
-
let n =
|
|
3058
|
-
n && (
|
|
3059
|
-
let r =
|
|
3060
|
-
r.active && r.language === "mermaid" &&
|
|
3061
|
-
}, []),
|
|
3062
|
-
|
|
3063
|
-
}, []),
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
contentType: Xe(P),
|
|
2946
|
+
})), V((e) => Vt(e, t));
|
|
2947
|
+
}, []), Ae = H((e) => ke(e.view), [ke]), je = H((e) => {
|
|
2948
|
+
let t = at(e);
|
|
2949
|
+
ae((e) => tt(e, t) ? e : t);
|
|
2950
|
+
let n = jt(e);
|
|
2951
|
+
n && (Nt(e, n, !0), pe(n));
|
|
2952
|
+
let r = pt(e);
|
|
2953
|
+
r.active && r.language === "mermaid" && de(r.mermaidPreviewMode);
|
|
2954
|
+
}, []), Me = H((e) => {
|
|
2955
|
+
he(Bi(e));
|
|
2956
|
+
}, []), J = s({
|
|
2957
|
+
extensions: re,
|
|
2958
|
+
content: o ?? l,
|
|
2959
|
+
contentType: Je(P),
|
|
3068
2960
|
editable: N,
|
|
3069
2961
|
autofocus: a,
|
|
3070
2962
|
editorProps: {
|
|
3071
2963
|
attributes: {
|
|
3072
2964
|
class: "markweave-editor-surface",
|
|
3073
2965
|
"data-testid": "markweave-editor-surface",
|
|
3074
|
-
"data-markweave-large-document": te ? "true" : "false",
|
|
3075
2966
|
autocapitalize: "off",
|
|
3076
2967
|
autocorrect: "off",
|
|
3077
2968
|
spellcheck: "false",
|
|
3078
2969
|
translate: "no"
|
|
3079
2970
|
},
|
|
3080
|
-
handleClick: (e, t, n) =>
|
|
2971
|
+
handleClick: (e, t, n) => F.current.effectiveEditable ? !1 : Qe(n),
|
|
3081
2972
|
handleDOMEvents: {
|
|
3082
|
-
compositionstart: () =>
|
|
3083
|
-
compositionend: (e) => (
|
|
2973
|
+
compositionstart: () => F.current.effectiveEditable ? (V((e) => Gt(e, { type: "composition-start" })), se(null), !1) : !1,
|
|
2974
|
+
compositionend: (e) => (F.current.effectiveEditable && window.setTimeout(() => ke(e), 0), !1),
|
|
3084
2975
|
click: (e, t) => {
|
|
3085
|
-
if (
|
|
3086
|
-
let n =
|
|
3087
|
-
return n ? (t.preventDefault(), t.stopPropagation(),
|
|
2976
|
+
if (F.current.effectiveEditable) {
|
|
2977
|
+
let n = At(e, t);
|
|
2978
|
+
return n ? (t.preventDefault(), t.stopPropagation(), Oe(), Pt(e, n, !0), Ft(e, n), pe(n), !0) : (pe(null), !1);
|
|
3088
2979
|
}
|
|
3089
|
-
return
|
|
2980
|
+
return Qe(t);
|
|
3090
2981
|
}
|
|
3091
2982
|
}
|
|
3092
2983
|
},
|
|
3093
2984
|
onSelectionUpdate: ({ editor: e }) => {
|
|
3094
|
-
|
|
2985
|
+
je(e);
|
|
3095
2986
|
},
|
|
3096
2987
|
onCreate: ({ editor: e }) => {
|
|
3097
|
-
i &&
|
|
2988
|
+
i && F.current.effectiveEditable && qt(e), Me(e), je(e), Ee();
|
|
3098
2989
|
},
|
|
3099
2990
|
onTransaction: ({ editor: e, transaction: t }) => {
|
|
3100
|
-
|
|
2991
|
+
Me(e), (t.docChanged || yt(t)) && De(), t.docChanged && pe((t) => {
|
|
3101
2992
|
if (!t) return null;
|
|
3102
|
-
let n =
|
|
2993
|
+
let n = kt(e, t.pos);
|
|
3103
2994
|
return n?.kind === t.kind ? n : null;
|
|
3104
2995
|
});
|
|
3105
2996
|
},
|
|
3106
2997
|
onUpdate: ({ editor: e }) => {
|
|
3107
|
-
|
|
3108
|
-
let r =
|
|
3109
|
-
r.content !== void 0 && t === r.format && (
|
|
2998
|
+
je(e), F.current.effectiveEditable && Ae(e), ye.current || we.current.onUpdate?.(qe(e, { onContentRead: (t, n) => {
|
|
2999
|
+
let r = xe.current;
|
|
3000
|
+
r.content !== void 0 && t === r.format && (Se.current = {
|
|
3110
3001
|
content: n,
|
|
3111
3002
|
format: t,
|
|
3112
3003
|
doc: e.state.doc
|
|
@@ -3115,360 +3006,317 @@ function ea({ ariaLabel: e, autoFocusFirstTableBodyCell: i = !1, autofocus: a =
|
|
|
3115
3006
|
}
|
|
3116
3007
|
});
|
|
3117
3008
|
U(() => {
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
let t = !1;
|
|
3121
|
-
return (async () => {
|
|
3122
|
-
Oe.current = !0;
|
|
3123
|
-
try {
|
|
3124
|
-
let n = !0;
|
|
3125
|
-
for (let r of Er(e)) {
|
|
3126
|
-
if (await new Promise((e) => window.setTimeout(e, 0)), t) return;
|
|
3127
|
-
let e = Y.markdown?.parse(r);
|
|
3128
|
-
if (!e) throw Error("Markdown parser is unavailable.");
|
|
3129
|
-
let i = Y.schema.nodeFromJSON(e).content, a = n ? Y.state.tr.replaceWith(0, Y.state.doc.content.size, i) : Y.state.tr.insert(Y.state.doc.content.size, i);
|
|
3130
|
-
Y.view.dispatch(a.setMeta("addToHistory", !1)), n = !1;
|
|
3131
|
-
}
|
|
3132
|
-
if (t) return;
|
|
3133
|
-
ze(Y), Be(Y), Ne(), L.current = null, re(!1);
|
|
3134
|
-
} finally {
|
|
3135
|
-
Oe.current = !1;
|
|
3136
|
-
}
|
|
3137
|
-
})().catch(() => {
|
|
3138
|
-
t || (Y.commands.setContent(e, {
|
|
3139
|
-
contentType: "markdown",
|
|
3140
|
-
emitUpdate: !1
|
|
3141
|
-
}), L.current = null, re(!1));
|
|
3142
|
-
}), () => {
|
|
3143
|
-
t = !0;
|
|
3009
|
+
if (J) return z.current?.(vr(J)), () => {
|
|
3010
|
+
z.current?.(null);
|
|
3144
3011
|
};
|
|
3012
|
+
}, [J]), U(() => {
|
|
3013
|
+
J && (J.setEditable(N), Le(J, {
|
|
3014
|
+
mode: k,
|
|
3015
|
+
editable: N
|
|
3016
|
+
}), xt(J, N ? "live" : "view"), Ee(), N || Oe());
|
|
3145
3017
|
}, [
|
|
3146
|
-
|
|
3147
|
-
Ne,
|
|
3148
|
-
ze,
|
|
3149
|
-
Be
|
|
3150
|
-
]), U(() => {
|
|
3151
|
-
if (Y) return ce.current?.(Dr(Y)), () => {
|
|
3152
|
-
ce.current?.(null);
|
|
3153
|
-
};
|
|
3154
|
-
}, [Y]), U(() => {
|
|
3155
|
-
if (!Y) return;
|
|
3156
|
-
let e = N && !ne;
|
|
3157
|
-
Y.setEditable(e), Re(Y, {
|
|
3158
|
-
mode: A,
|
|
3159
|
-
editable: e
|
|
3160
|
-
}), Ct(Y, e ? "live" : "view"), Ne(), N || J();
|
|
3161
|
-
}, [
|
|
3018
|
+
Oe,
|
|
3162
3019
|
J,
|
|
3163
|
-
|
|
3164
|
-
A,
|
|
3020
|
+
k,
|
|
3165
3021
|
N,
|
|
3166
|
-
|
|
3167
|
-
ne
|
|
3022
|
+
Ee
|
|
3168
3023
|
]), U(() => {
|
|
3169
|
-
|
|
3170
|
-
}, [
|
|
3171
|
-
let e =
|
|
3172
|
-
if (!(!
|
|
3173
|
-
if (
|
|
3174
|
-
|
|
3024
|
+
J && bt(J, A);
|
|
3025
|
+
}, [J, A]), U(() => {
|
|
3026
|
+
let e = Ze(c);
|
|
3027
|
+
if (!(!J || o === void 0)) {
|
|
3028
|
+
if (Xe(J, Se.current, o, e)) {
|
|
3029
|
+
Se.current = null;
|
|
3175
3030
|
return;
|
|
3176
3031
|
}
|
|
3177
|
-
|
|
3178
|
-
contentType:
|
|
3032
|
+
Se.current = null, !Ye(J, o, e) && (ye.current = !0, J.commands.setContent(o, {
|
|
3033
|
+
contentType: Je(e),
|
|
3179
3034
|
emitUpdate: !1
|
|
3180
|
-
}),
|
|
3035
|
+
}), ye.current = !1, je(J), N && Ae(J), Me(J), Ee());
|
|
3181
3036
|
}
|
|
3182
3037
|
}, [
|
|
3183
3038
|
o,
|
|
3184
3039
|
c,
|
|
3185
3040
|
N,
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3041
|
+
J,
|
|
3042
|
+
Ee,
|
|
3043
|
+
je,
|
|
3044
|
+
Ae,
|
|
3045
|
+
Me
|
|
3191
3046
|
]), U(() => {
|
|
3192
|
-
if (!
|
|
3047
|
+
if (!oe) return;
|
|
3193
3048
|
let e = (e) => {
|
|
3194
3049
|
let t = e.target;
|
|
3195
|
-
t instanceof Element && (t.closest(".markweave-slash-menu") || t.closest(".markweave-slash-trigger") ||
|
|
3050
|
+
t instanceof Element && (t.closest(".markweave-slash-menu") || t.closest(".markweave-slash-trigger") || Oe());
|
|
3196
3051
|
};
|
|
3197
3052
|
return document.addEventListener("pointerdown", e, !0), () => document.removeEventListener("pointerdown", e, !0);
|
|
3198
|
-
}, [
|
|
3199
|
-
let
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
]),
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
]),
|
|
3209
|
-
active:
|
|
3210
|
-
mode:
|
|
3211
|
-
source:
|
|
3212
|
-
}) :
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
]),
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
Ee
|
|
3221
|
-
]), We = W(() => Y ? yr(Y.state) : _r.items, [Y, Ee]), Ge = W(() => br(We, we), [we, We]), Ke = W(() => gr(We, Ge), [Ge, We]), qe = H(() => {
|
|
3222
|
-
if (!Y || !We.length) {
|
|
3223
|
-
Te(null);
|
|
3053
|
+
}, [Oe, oe]);
|
|
3054
|
+
let Ne = G(() => J ? pt(J) : Ri, [
|
|
3055
|
+
J,
|
|
3056
|
+
W,
|
|
3057
|
+
ie
|
|
3058
|
+
]), Y = G(() => J ? Jt(J.state) : Li, [
|
|
3059
|
+
J,
|
|
3060
|
+
W,
|
|
3061
|
+
ie,
|
|
3062
|
+
me
|
|
3063
|
+
]), Pe = ie?.currentNode === "codeBlock", Fe = Pe && Ne.language === "mermaid", Re = G(() => J ? Ct({
|
|
3064
|
+
active: Fe,
|
|
3065
|
+
mode: ue,
|
|
3066
|
+
source: Ne.text
|
|
3067
|
+
}) : zi, [
|
|
3068
|
+
Ne.text,
|
|
3069
|
+
J,
|
|
3070
|
+
Fe,
|
|
3071
|
+
ue
|
|
3072
|
+
]), ze = G(() => J ? Kt(J.state) : null, [J, W]), X = G(() => J ? dr(J.state.doc) : lr.items, [J, W]), Z = G(() => fr(X, ge), [ge, X]), Q = G(() => cr(X, Z), [Z, X]), Be = H(() => {
|
|
3073
|
+
if (!J || !X.length) {
|
|
3074
|
+
_e(null);
|
|
3224
3075
|
return;
|
|
3225
3076
|
}
|
|
3226
|
-
let e =
|
|
3227
|
-
|
|
3228
|
-
}, [
|
|
3077
|
+
let e = ur(J, X);
|
|
3078
|
+
_e((t) => t === e ? t : e);
|
|
3079
|
+
}, [J, X]);
|
|
3229
3080
|
U(() => {
|
|
3230
|
-
|
|
3231
|
-
let t =
|
|
3081
|
+
_e((e) => {
|
|
3082
|
+
let t = fr(X, e);
|
|
3232
3083
|
return e === t ? e : t;
|
|
3233
3084
|
});
|
|
3234
|
-
}, [
|
|
3235
|
-
if (!
|
|
3085
|
+
}, [X]), U(() => {
|
|
3086
|
+
if (!J || !X.length || typeof window > "u") return;
|
|
3236
3087
|
let e = null, t = () => {
|
|
3237
|
-
e !== null &&
|
|
3238
|
-
e = null,
|
|
3088
|
+
e !== null && Ui(e), e = Hi(() => {
|
|
3089
|
+
e = null, Be();
|
|
3239
3090
|
});
|
|
3240
|
-
}, n =
|
|
3091
|
+
}, n = Vi(J.view.dom);
|
|
3241
3092
|
return window.addEventListener("scroll", t, { passive: !0 }), window.addEventListener("resize", t), n?.addEventListener("scroll", t, { passive: !0 }), t(), () => {
|
|
3242
|
-
window.removeEventListener("scroll", t), window.removeEventListener("resize", t), n?.removeEventListener("scroll", t), e !== null &&
|
|
3093
|
+
window.removeEventListener("scroll", t), window.removeEventListener("resize", t), n?.removeEventListener("scroll", t), e !== null && Ui(e);
|
|
3243
3094
|
};
|
|
3244
3095
|
}, [
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3096
|
+
J,
|
|
3097
|
+
X.length,
|
|
3098
|
+
Be
|
|
3248
3099
|
]);
|
|
3249
|
-
let
|
|
3250
|
-
revision:
|
|
3251
|
-
mode:
|
|
3100
|
+
let Ve = G(() => $e({
|
|
3101
|
+
revision: W,
|
|
3102
|
+
mode: k,
|
|
3252
3103
|
editable: N,
|
|
3253
|
-
toc:
|
|
3254
|
-
selection:
|
|
3104
|
+
toc: Q,
|
|
3105
|
+
selection: ie,
|
|
3255
3106
|
slash: B,
|
|
3256
|
-
table:
|
|
3257
|
-
tableInteraction:
|
|
3258
|
-
codeBlock:
|
|
3259
|
-
mermaid:
|
|
3260
|
-
tableDebugSnapshot:
|
|
3107
|
+
table: Y,
|
|
3108
|
+
tableInteraction: me,
|
|
3109
|
+
codeBlock: Ne,
|
|
3110
|
+
mermaid: Re,
|
|
3111
|
+
tableDebugSnapshot: ze
|
|
3261
3112
|
}), [
|
|
3262
|
-
|
|
3263
|
-
|
|
3113
|
+
Ne,
|
|
3114
|
+
k,
|
|
3264
3115
|
N,
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3116
|
+
Re,
|
|
3117
|
+
W,
|
|
3118
|
+
ie,
|
|
3268
3119
|
B,
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3120
|
+
ze,
|
|
3121
|
+
Y,
|
|
3122
|
+
me,
|
|
3123
|
+
Q
|
|
3273
3124
|
]);
|
|
3274
3125
|
U(() => {
|
|
3275
|
-
x?.(
|
|
3276
|
-
}, [x,
|
|
3277
|
-
E?.(
|
|
3278
|
-
}, [E,
|
|
3279
|
-
let
|
|
3280
|
-
if (!(!
|
|
3126
|
+
x?.(Ve);
|
|
3127
|
+
}, [x, Ve]), U(() => {
|
|
3128
|
+
E?.(Q);
|
|
3129
|
+
}, [E, Q]);
|
|
3130
|
+
let He = H((e, t) => {
|
|
3131
|
+
if (!(!J || !N) && Lt(e)) {
|
|
3281
3132
|
if (e.inputKind && !t?.emoji && !t?.uploadResult) {
|
|
3282
|
-
|
|
3133
|
+
le(e);
|
|
3283
3134
|
return;
|
|
3284
3135
|
}
|
|
3285
|
-
|
|
3136
|
+
Bt(J, B, e, t), V((e) => Gt(e, { type: "execute" })), Oe();
|
|
3286
3137
|
}
|
|
3287
3138
|
}, [
|
|
3288
|
-
|
|
3139
|
+
Oe,
|
|
3289
3140
|
N,
|
|
3290
|
-
|
|
3141
|
+
J,
|
|
3291
3142
|
B
|
|
3292
|
-
]),
|
|
3293
|
-
V((t) =>
|
|
3143
|
+
]), Ue = H((e) => {
|
|
3144
|
+
V((t) => Gt(t, {
|
|
3294
3145
|
type: "set-active",
|
|
3295
3146
|
index: e,
|
|
3296
|
-
optionCount:
|
|
3147
|
+
optionCount: Te.length
|
|
3297
3148
|
}));
|
|
3298
|
-
}, [
|
|
3299
|
-
if (!
|
|
3300
|
-
let t =
|
|
3149
|
+
}, [Te.length]), We = H((e) => {
|
|
3150
|
+
if (!J || ce || !N) return;
|
|
3151
|
+
let t = Rt(B, Te, e.key, { isComposing: e.nativeEvent.isComposing || Ke(J.state) });
|
|
3301
3152
|
if (t.type !== "ignore") {
|
|
3302
3153
|
if (t.type === "close") {
|
|
3303
|
-
e.preventDefault(), V((e) =>
|
|
3154
|
+
e.preventDefault(), V((e) => Gt(e, { type: "escape" })), Oe();
|
|
3304
3155
|
return;
|
|
3305
3156
|
}
|
|
3306
3157
|
if (t.type === "move-active") {
|
|
3307
|
-
e.preventDefault(), V((e) =>
|
|
3158
|
+
e.preventDefault(), V((e) => Gt(e, {
|
|
3308
3159
|
type: "move-active",
|
|
3309
3160
|
delta: t.delta,
|
|
3310
3161
|
optionCount: t.optionCount
|
|
3311
3162
|
}));
|
|
3312
3163
|
return;
|
|
3313
3164
|
}
|
|
3314
|
-
t.type === "execute-active" && (e.preventDefault(),
|
|
3165
|
+
t.type === "execute-active" && (e.preventDefault(), He(t.command));
|
|
3315
3166
|
}
|
|
3316
3167
|
}, [
|
|
3317
|
-
|
|
3168
|
+
Oe,
|
|
3318
3169
|
N,
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3170
|
+
J,
|
|
3171
|
+
Te,
|
|
3172
|
+
He,
|
|
3173
|
+
ce,
|
|
3323
3174
|
B
|
|
3324
|
-
]),
|
|
3325
|
-
closeSlashMenu:
|
|
3326
|
-
focusFirstTableBodyCell: () =>
|
|
3175
|
+
]), Ge = G(() => ({
|
|
3176
|
+
closeSlashMenu: Oe,
|
|
3177
|
+
focusFirstTableBodyCell: () => J ? qt(J) : !1,
|
|
3327
3178
|
setContent: (e, t = {}) => {
|
|
3328
|
-
if (!
|
|
3329
|
-
let n =
|
|
3330
|
-
return
|
|
3331
|
-
contentType:
|
|
3179
|
+
if (!J) return !1;
|
|
3180
|
+
let n = Ze(t.format);
|
|
3181
|
+
return J.commands.setContent(e, {
|
|
3182
|
+
contentType: Je(n),
|
|
3332
3183
|
emitUpdate: t.emitUpdate ?? !1
|
|
3333
|
-
}), t.focusFirstTableBodyCell &&
|
|
3184
|
+
}), t.focusFirstTableBodyCell && qt(J), je(J), N && Ae(J), Me(J), Ee(), !0;
|
|
3334
3185
|
}
|
|
3335
3186
|
}), [
|
|
3336
|
-
|
|
3187
|
+
Oe,
|
|
3337
3188
|
N,
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3189
|
+
J,
|
|
3190
|
+
Ee,
|
|
3191
|
+
je,
|
|
3192
|
+
Ae,
|
|
3193
|
+
Me
|
|
3343
3194
|
]);
|
|
3344
3195
|
return {
|
|
3345
|
-
editor:
|
|
3346
|
-
frameProps:
|
|
3196
|
+
editor: J,
|
|
3197
|
+
frameProps: G(() => ({
|
|
3347
3198
|
className: "markweave-editor-frame",
|
|
3348
|
-
"aria-label": e ??
|
|
3199
|
+
"aria-label": e ?? L.common.editorAriaLabel,
|
|
3349
3200
|
"data-testid": "markweave-editor-frame",
|
|
3350
|
-
"data-markweave-mode":
|
|
3351
|
-
"
|
|
3352
|
-
"
|
|
3353
|
-
"data-markweave-theme": j,
|
|
3354
|
-
style: M ? { "--markweave-canvas": M } : void 0,
|
|
3201
|
+
"data-markweave-mode": k,
|
|
3202
|
+
"data-markweave-theme": A,
|
|
3203
|
+
style: j ? { "--markweave-canvas": j } : void 0,
|
|
3355
3204
|
"data-markweave-inner-toc": f ? "true" : "false",
|
|
3356
|
-
"data-markweave-inner-toc-placement":
|
|
3357
|
-
"data-mermaid-mode":
|
|
3358
|
-
"data-table-focus-mode":
|
|
3359
|
-
onKeyDownCapture:
|
|
3205
|
+
"data-markweave-inner-toc-placement": M,
|
|
3206
|
+
"data-mermaid-mode": Re.mode,
|
|
3207
|
+
"data-table-focus-mode": Y.mode,
|
|
3208
|
+
onKeyDownCapture: We
|
|
3360
3209
|
}), [
|
|
3361
3210
|
e,
|
|
3362
|
-
|
|
3363
|
-
|
|
3211
|
+
k,
|
|
3212
|
+
We,
|
|
3364
3213
|
f,
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
z.common.editorAriaLabel,
|
|
3368
|
-
M,
|
|
3369
|
-
ee,
|
|
3214
|
+
Re.mode,
|
|
3215
|
+
L.common.editorAriaLabel,
|
|
3370
3216
|
j,
|
|
3371
|
-
|
|
3217
|
+
M,
|
|
3218
|
+
A,
|
|
3219
|
+
Y.mode
|
|
3372
3220
|
]),
|
|
3373
|
-
overlayProps:
|
|
3374
|
-
floatingToolbar:
|
|
3375
|
-
editor:
|
|
3376
|
-
messages:
|
|
3377
|
-
selectionSnapshot:
|
|
3221
|
+
overlayProps: G(() => ({
|
|
3222
|
+
floatingToolbar: J && N ? {
|
|
3223
|
+
editor: J,
|
|
3224
|
+
messages: L,
|
|
3225
|
+
selectionSnapshot: ie,
|
|
3378
3226
|
onRewriteSelection: b,
|
|
3379
3227
|
onExtractToNote: y
|
|
3380
3228
|
} : null,
|
|
3381
|
-
slashCommandMenu:
|
|
3382
|
-
commands:
|
|
3229
|
+
slashCommandMenu: J && N ? {
|
|
3230
|
+
commands: Te,
|
|
3383
3231
|
state: B,
|
|
3384
|
-
position:
|
|
3385
|
-
inputCommand:
|
|
3386
|
-
messages:
|
|
3387
|
-
onActiveIndexChange:
|
|
3388
|
-
onInputCommandChange:
|
|
3389
|
-
onSelect:
|
|
3232
|
+
position: oe,
|
|
3233
|
+
inputCommand: ce,
|
|
3234
|
+
messages: L,
|
|
3235
|
+
onActiveIndexChange: Ue,
|
|
3236
|
+
onInputCommandChange: le,
|
|
3237
|
+
onSelect: He,
|
|
3390
3238
|
onUpload: C
|
|
3391
3239
|
} : null,
|
|
3392
|
-
tableControls:
|
|
3393
|
-
editor:
|
|
3394
|
-
active:
|
|
3395
|
-
interactionState:
|
|
3396
|
-
messages:
|
|
3240
|
+
tableControls: J && N ? {
|
|
3241
|
+
editor: J,
|
|
3242
|
+
active: Y.active,
|
|
3243
|
+
interactionState: me,
|
|
3244
|
+
messages: L,
|
|
3397
3245
|
onCopyPayload: T,
|
|
3398
3246
|
onCommandResult: w,
|
|
3399
3247
|
onEditWithAi: v
|
|
3400
3248
|
} : null,
|
|
3401
|
-
tableSelectionOverlay:
|
|
3402
|
-
editor:
|
|
3403
|
-
focusState:
|
|
3249
|
+
tableSelectionOverlay: J && N ? {
|
|
3250
|
+
editor: J,
|
|
3251
|
+
focusState: Y
|
|
3404
3252
|
} : null,
|
|
3405
|
-
codeBlockControls:
|
|
3406
|
-
editor:
|
|
3407
|
-
active: N &&
|
|
3408
|
-
mermaidMode:
|
|
3409
|
-
onMermaidModeChange:
|
|
3253
|
+
codeBlockControls: J ? {
|
|
3254
|
+
editor: J,
|
|
3255
|
+
active: N && Pe,
|
|
3256
|
+
mermaidMode: ue,
|
|
3257
|
+
onMermaidModeChange: de,
|
|
3410
3258
|
readOnly: !N
|
|
3411
3259
|
} : null,
|
|
3412
|
-
innerToc:
|
|
3413
|
-
editor:
|
|
3260
|
+
innerToc: J && f && Q.items.length ? {
|
|
3261
|
+
editor: J,
|
|
3414
3262
|
editable: N,
|
|
3415
|
-
messages:
|
|
3416
|
-
placement:
|
|
3417
|
-
state:
|
|
3263
|
+
messages: L,
|
|
3264
|
+
placement: M,
|
|
3265
|
+
state: Q
|
|
3418
3266
|
} : null,
|
|
3419
|
-
mathEditorPopover:
|
|
3420
|
-
editor:
|
|
3421
|
-
messages:
|
|
3422
|
-
target:
|
|
3423
|
-
onClose: () =>
|
|
3267
|
+
mathEditorPopover: J && N && fe ? {
|
|
3268
|
+
editor: J,
|
|
3269
|
+
messages: L,
|
|
3270
|
+
target: fe,
|
|
3271
|
+
onClose: () => pe(null)
|
|
3424
3272
|
} : null
|
|
3425
3273
|
}), [
|
|
3426
3274
|
N,
|
|
3427
|
-
|
|
3428
|
-
|
|
3275
|
+
J,
|
|
3276
|
+
Te,
|
|
3429
3277
|
f,
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3278
|
+
Pe,
|
|
3279
|
+
ue,
|
|
3280
|
+
L,
|
|
3281
|
+
fe,
|
|
3434
3282
|
v,
|
|
3435
3283
|
y,
|
|
3436
3284
|
b,
|
|
3437
3285
|
C,
|
|
3438
3286
|
w,
|
|
3439
3287
|
T,
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3288
|
+
He,
|
|
3289
|
+
ie,
|
|
3290
|
+
Ue,
|
|
3291
|
+
ce,
|
|
3292
|
+
oe,
|
|
3445
3293
|
B,
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3294
|
+
Y,
|
|
3295
|
+
me,
|
|
3296
|
+
Q
|
|
3449
3297
|
]),
|
|
3450
|
-
runtimeSnapshot:
|
|
3451
|
-
actions:
|
|
3298
|
+
runtimeSnapshot: Ve,
|
|
3299
|
+
actions: Ge
|
|
3452
3300
|
};
|
|
3453
3301
|
}
|
|
3454
|
-
function
|
|
3455
|
-
let n =
|
|
3302
|
+
function Gi({ className: e, ...t }) {
|
|
3303
|
+
let n = Wi(t);
|
|
3456
3304
|
if (!n.editor) return null;
|
|
3457
3305
|
let r = [n.frameProps.className, e].filter(Boolean).join(" ");
|
|
3458
3306
|
return /* @__PURE__ */ Q("section", {
|
|
3459
3307
|
...n.frameProps,
|
|
3460
3308
|
className: r,
|
|
3461
3309
|
children: [
|
|
3462
|
-
n.overlayProps.floatingToolbar ? /* @__PURE__ */ Z(
|
|
3463
|
-
n.overlayProps.slashCommandMenu ? /* @__PURE__ */ Z(
|
|
3464
|
-
n.overlayProps.tableControls ? /* @__PURE__ */ Z(
|
|
3465
|
-
n.overlayProps.tableSelectionOverlay ? /* @__PURE__ */ Z(
|
|
3466
|
-
n.overlayProps.codeBlockControls ? /* @__PURE__ */ Z(
|
|
3467
|
-
n.overlayProps.innerToc ? /* @__PURE__ */ Z(
|
|
3468
|
-
n.overlayProps.mathEditorPopover ? /* @__PURE__ */ Z(
|
|
3310
|
+
n.overlayProps.floatingToolbar ? /* @__PURE__ */ Z(ui, { ...n.overlayProps.floatingToolbar }) : null,
|
|
3311
|
+
n.overlayProps.slashCommandMenu ? /* @__PURE__ */ Z(ji, { ...n.overlayProps.slashCommandMenu }) : null,
|
|
3312
|
+
n.overlayProps.tableControls ? /* @__PURE__ */ Z(Ni, { ...n.overlayProps.tableControls }) : null,
|
|
3313
|
+
n.overlayProps.tableSelectionOverlay ? /* @__PURE__ */ Z(Pi, { ...n.overlayProps.tableSelectionOverlay }) : null,
|
|
3314
|
+
n.overlayProps.codeBlockControls ? /* @__PURE__ */ Z(Ur, { ...n.overlayProps.codeBlockControls }) : null,
|
|
3315
|
+
n.overlayProps.innerToc ? /* @__PURE__ */ Z(Ii, { ...n.overlayProps.innerToc }) : null,
|
|
3316
|
+
n.overlayProps.mathEditorPopover ? /* @__PURE__ */ Z(Si, { ...n.overlayProps.mathEditorPopover }) : null,
|
|
3469
3317
|
/* @__PURE__ */ Z(i, { editor: n.editor })
|
|
3470
3318
|
]
|
|
3471
3319
|
});
|
|
3472
3320
|
}
|
|
3473
3321
|
//#endregion
|
|
3474
|
-
export {
|
|
3322
|
+
export { Gi as MarkweaveEditor, Br as createMarkweaveEditorExtensions, Br as createMarkweaveReactEditorExtensions, Wi as useMarkweaveEditorController };
|