@markweave/vue2 0.5.0 → 0.5.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 +39 -39
- package/dist/index.js +1190 -933
- package/dist/types/MarkweaveEditor.d.ts +2 -0
- package/dist/types/MarkweaveEditor.d.ts.map +1 -1
- package/dist/types/create-editor-extensions.d.ts +4 -1
- 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-nodeviews.d.ts +8 -0
- package/dist/types/media-nodeviews.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -10,55 +10,58 @@ import { normalizeMarkweaveLinkCardAttrs as _, normalizeMarkweaveLinkCardHref as
|
|
|
10
10
|
import { openMarkweaveImagePreview as b } from "markweave/internal/plugins/media/image-preview";
|
|
11
11
|
import { createMarkweaveLightweightImageNodeViewRenderer as x } from "markweave/internal/plugins/media/lightweight-image-node-view";
|
|
12
12
|
import { resolveMarkweaveMediaSource as S } from "markweave/internal/plugins/media/media-source";
|
|
13
|
-
import { MarkweaveCoreImage as C, MarkweaveCoreVideo as w, attrsFromMarkweaveImageUploadResult as T, attrsFromMarkweaveVideoUploadResult as E, attrsFromMarkweaveVideoUrl as D, clampMarkweaveImageWidth as O, createMarkweaveImageUploadRequest as k, createMarkweaveVideoUploadRequest as A, downloadMarkweaveImage as j, markweaveVideoIframeAllow as
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
41
|
-
import {
|
|
42
|
-
import {
|
|
43
|
-
import {
|
|
44
|
-
import {
|
|
13
|
+
import { MarkweaveCoreImage as C, MarkweaveCoreVideo as w, attrsFromMarkweaveImageUploadResult as T, attrsFromMarkweaveVideoUploadResult as E, attrsFromMarkweaveVideoUrl as D, clampMarkweaveImageWidth as O, createMarkweaveImageUploadRequest as k, createMarkweaveVideoUploadRequest as A, downloadMarkweaveImage as j, markweaveVideoIframeAllow as ee, normalizeMarkweaveCoreImageAlign as te, normalizeMarkweaveVideoEmbedUrl as M, numberAttribute as N, stringAttribute as P } from "markweave/internal/plugins/media/core-media-nodes";
|
|
14
|
+
import { activateMarkweaveAttachmentDownload as F, attrsFromMarkweaveAttachmentUploadResult as I, createMarkweaveAttachmentRefFromAttrs as L, createMarkweaveAttachmentUploadRequest as R, formatMarkweaveAttachmentSize as z } from "markweave/internal/plugins/media/attachment-download";
|
|
15
|
+
import { MarkweaveAttachment as B } from "markweave/internal/plugins/media/media-nodes";
|
|
16
|
+
import { detectUploadSource as V, getDirectUploadResult as H, resolveMarkweaveUploadResult as ne } from "markweave/internal/plugins/slash-command/upload";
|
|
17
|
+
import { createMarkweaveAiEditController as re } from "markweave";
|
|
18
|
+
import { BubbleMenu as ie } from "@tiptap/vue-2/menus";
|
|
19
|
+
import { isEditorComposing as ae } from "markweave/internal/editor-core/composition-guard";
|
|
20
|
+
import { saveMarkweaveBrowserFile as oe } from "markweave/internal/core/browser-file-save";
|
|
21
|
+
import { createMarkweaveFrameScheduler as se } from "markweave/internal/editor-core/frame-scheduler";
|
|
22
|
+
import { createMarkweaveEditorUpdatePayload as ce, getMarkweaveContentType as le, isEditorContentCurrent as ue, isMarkweaveControlledContentEchoCurrent as de, normalizeMarkweaveContentFormat as fe } from "markweave/internal/editor-core/editor-content";
|
|
23
|
+
import { getCurrentFloatingToolbarBlockType as pe, getFloatingToolbarHighlightColorOptions as me, getFloatingToolbarMoreActions as he, getFloatingToolbarTextColorOptions as ge, getFloatingToolbarTurnIntoOptions as _e, runFloatingToolbarMoreAction as ve, setFloatingToolbarTurnInto as ye } from "markweave/internal/editor-core/floating-toolbar-model";
|
|
24
|
+
import { openMarkweaveReadonlyLinkFromEvent as be } from "markweave/internal/editor-core/readonly-link";
|
|
25
|
+
import { createMarkweaveEditorRuntimeSnapshot as xe } from "markweave/internal/editor-core/runtime-snapshot";
|
|
26
|
+
import { areEditorSelectionSnapshotsEquivalent as Se, calculateFloatingToolbarPopoverPlacement as Ce, createSelectionSnapshot as we, markweaveRuntimeProjectionDelayMs as Te, shouldShowFloatingToolbarForAiState as Ee } from "markweave/internal/editor-core/selection-state";
|
|
27
|
+
import { normalizeMarkweaveCanvasColor as De, normalizeMarkweaveTheme as Oe } from "markweave/internal/core/theme";
|
|
28
|
+
import { createMarkweaveAiEditController as ke } from "markweave/internal/plugins/ai-edit/ai-edit-controller";
|
|
29
|
+
import { MarkweaveAskAiError as Ae, acceptMarkweaveAskAiResult as je, calculateMarkweaveAskAiPanelPosition as Me, canStartMarkweaveAskAiTableTarget as Ne, clearMarkweaveAskAiPreview as Pe, clearMarkweaveAskAiTarget as Fe, createMarkweaveAskAiRequest as Ie, getMappedMarkweaveAskAiSelection as Le, getMarkweaveAskAiSurfaceRect as Re, getMarkweaveAskAiTarget as ze, getMarkweaveAskAiTargetRect as Be, hasMarkweaveAskAiPreview as Ve, isMarkweaveAskAiSelectionEligible as He, restoreMarkweaveAskAiTargetSelection as Ue, runMarkweaveAskAiHandler as We, setMarkweaveAskAiPreview as Ge, startMarkweaveAskAiTableTarget as Ke, startMarkweaveAskAiTarget as qe } from "markweave/internal/plugins/ask-ai/ask-ai-session";
|
|
30
|
+
import { createMarkweaveTocState as Je, emptyMarkweaveTocState as Ye, getActiveMarkweaveTocId as Xe, getMarkweaveInnerTocRailHeight as Ze, getMarkweaveTocItemsFromState as Qe, getValidMarkweaveTocActiveId as $e, normalizeMarkweaveInnerTocPlacement as et, observeMarkweaveInnerTocContainerPosition as tt, observeMarkweaveInnerTocRailOverflow as nt, scrollToMarkweaveTocItem as rt } from "markweave/internal/core/toc-state";
|
|
31
|
+
import { codeBlockCollapsePluginKey as it, copyActiveCodeBlock as at, getActiveCodeBlockState as ot, getCodeBlockCopyFeedbackSnapshot as st, markweaveCodeBlockBehavior as ct, setCodeBlockCollapsedAtPosition as lt, setCodeBlockLanguageAtPosition as ut, setCodeBlockMermaidPreviewModeAtPosition as dt } from "markweave/internal/plugins/codeblock/codeblock-behavior";
|
|
32
|
+
import { calculateCodeBlockLanguageMenuPosition as ft, clampFullscreenScale as pt, codeBlockCopyFeedbackTimeoutMs as mt, copyCodeBlockText as ht, createCodeBlockLanguageMenuDomId as gt, createCodeBlockOverlayPosition as _t, createMermaidFullscreenViewerState as vt, createMermaidTabPosition as yt, focusCodeBlockTarget as bt, formatCodeBlockLanguageLabel as xt, formatFullscreenZoom as St, getActiveCodeBlockElement as Ct, getAnchoredRect as wt, getCodeBlockLanguageItems as Tt, getCodeBlockLanguageOptionDomId as Et, getCodeBlockPositionFromEventTarget as Dt, getCodeBlockStateAtPosition as Ot, getFrameElement as kt, getInitialCodeBlockLanguageItemIndex as At, getMermaidCodeBlockTargets as jt, getMermaidSvgMarkup as Mt, isCodeBlockTargetCollapsed as Nt, mergeStableMermaidTabPositions as Pt, mermaidFullscreenZoomStep as Ft, moveCodeBlockLanguageItemIndex as It, moveMermaidFullscreenViewer as Lt, scrollCodeBlockLanguageItemIntoView as Rt } from "markweave/internal/plugins/codeblock/codeblock-ui-model";
|
|
33
|
+
import { normalizeMarkdownLinkHref as zt } from "markweave/internal/plugins/markdown/markdown-input";
|
|
34
|
+
import { applyMarkweaveMathLatex as Bt, calculateMarkweaveMathPopoverPosition as Vt, getMarkweaveMathAnchorRect as Ht, getMarkweaveMathBlockIndex as Ut, getMarkweaveMathRenderedHtml as Wt, getMarkweaveMathTargetAtPos as Gt, getMarkweaveMathTargetFromDomEvent as Kt, getMarkweaveMathTargetFromSelection as qt, renderMarkweaveMathPreview as Jt, setMarkweaveMathEditingDomState as Yt, setMarkweaveMathEditingDomStateInView as Xt, setMarkweaveMathSelectionInView as Zt } from "markweave/internal/plugins/math/math-ui-model";
|
|
35
|
+
import { isMermaidInlinePreviewTransaction as Qt, setMarkweaveMermaidTheme as $t, setMermaidInlinePreviewEditorMode as en, setReadonlyMermaidPreviewMode as tn } from "markweave/internal/plugins/mermaid/mermaid-inline-preview";
|
|
36
|
+
import { getMermaidPreviewState as nn } from "markweave/internal/plugins/mermaid/mermaid-renderer";
|
|
37
|
+
import { filterSlashCommands as rn, isExecutableSlashCommand as an } from "markweave/internal/plugins/slash-command/command-spec";
|
|
38
|
+
import { getSlashCommandKeyboardAction as on } from "markweave/internal/plugins/slash-command/slash-keyboard";
|
|
39
|
+
import { scrollSlashCommandItemIntoView as sn } from "markweave/internal/plugins/slash-command/slash-menu-scroll";
|
|
40
|
+
import { areSlashCommandMenuPositionsEquivalent as cn, executeSlashCommand as ln, getNextSlashCommandState as un, getSlashCommandAnchoredMenuPosition as dn, getSlashCommandContext as fn, isMarkweaveSlashMenuScrollTarget as pn, isSlashCommandAnchorVisible as mn } from "markweave/internal/plugins/slash-command/slash-runtime";
|
|
41
|
+
import { initialSlashCommandState as hn, reduceSlashCommandState as gn } from "markweave/internal/plugins/slash-command/slash-state";
|
|
42
|
+
import { setMarkweaveTableMenuAxisTarget as _n } from "markweave/internal/plugins/table/table-clipboard";
|
|
43
|
+
import { getFirstTableDebugSnapshot as vn } from "markweave/internal/plugins/table/table-debug-snapshot";
|
|
44
|
+
import { focusFirstTableBodyCell as yn } from "markweave/internal/plugins/table/table-focus-position";
|
|
45
|
+
import { getTableFocusState as bn } from "markweave/internal/plugins/table/table-focus-state";
|
|
46
|
+
import { getTableSelectionOverlayState as xn, initialTableInteractionState as Sn, tableInteractionPluginKey as Cn } from "markweave/internal/plugins/table/table-interaction-layer";
|
|
47
|
+
import { applyTableAxisAlignment as wn, applyTableAxisBackgroundColor as Tn, applyTableAxisTextColor as En, calculateAnchoredTableMenuPosition as Dn, calculateAnchoredTableSubmenuPosition as On, calculateTableAxisHandleLayout as kn, calculateTableExtendButtonLayout as An, canRunTableCommand as jn, executeTableMenuCommand as Mn, formatTableCopyFeedback as Nn, getActiveTableElement as Pn, getAvailableCellMenuCommandSpecs as Fn, getTableAxisDropIndexAtPoint as In, getTableAxisFormattingState as Ln, getTableAxisTargetRect as Rn, getTableControlAxisSelectionModel as zn, getTableMenuBoundaryRect as Bn, getTableMenuItemGroup as Vn, getTableMenuItemLabel as Hn, getTableMenuItems as Un, getTableSelectionTargetRect as Wn, measureTableSelectionOverlay as Gn, moveTargetedTableAxis as Kn, selectTableAxisFromCell as qn, tableColorOptions as Jn, tableCopyFeedbackTimeoutMs as Yn, tableHorizontalAlignmentOptions as Xn, tableMenuLabel as Zn, tableVerticalAlignmentOptions as Qn, targetTableAxisFromCell as $n } from "markweave/internal/plugins/table/table-ui-model";
|
|
45
48
|
//#region src/vue2-compat.ts
|
|
46
|
-
var
|
|
47
|
-
function
|
|
49
|
+
var er = l.default ?? l, tr = null, nr = null, rr = null;
|
|
50
|
+
function ir(e) {
|
|
48
51
|
return !!(e && typeof e == "object" && "value" in e);
|
|
49
52
|
}
|
|
50
|
-
function
|
|
53
|
+
function ar(e) {
|
|
51
54
|
let t = e.slice(2);
|
|
52
55
|
return t.endsWith("Capture") ? `!${t.slice(0, -7).replace(/^[A-Z]/, (e) => e.toLowerCase())}` : t.replace(/^[A-Z]/, (e) => e.toLowerCase());
|
|
53
56
|
}
|
|
54
|
-
function
|
|
57
|
+
function or(e) {
|
|
55
58
|
let t = {}, n = {}, r = {}, i = {}, a = {};
|
|
56
59
|
for (let [o, s] of Object.entries(e)) if (s !== void 0) {
|
|
57
60
|
if (o === "class" || o === "style" || o === "key") {
|
|
58
61
|
t[o] = s;
|
|
59
62
|
continue;
|
|
60
63
|
}
|
|
61
|
-
if (o === "ref" &&
|
|
64
|
+
if (o === "ref" && ir(s)) {
|
|
62
65
|
a.insert = (e) => {
|
|
63
66
|
s.value = e.elm;
|
|
64
67
|
}, a.destroy = () => {
|
|
@@ -67,7 +70,7 @@ function Yn(e) {
|
|
|
67
70
|
continue;
|
|
68
71
|
}
|
|
69
72
|
if (/^on[A-Z]/.test(o)) {
|
|
70
|
-
i[
|
|
73
|
+
i[ar(o)] = s;
|
|
71
74
|
continue;
|
|
72
75
|
}
|
|
73
76
|
if (o === "value" || o === "checked" || o === "innerHTML" || o === "textContent") {
|
|
@@ -78,14 +81,14 @@ function Yn(e) {
|
|
|
78
81
|
}
|
|
79
82
|
return Object.keys(n).length && (t.attrs = n), Object.keys(r).length && (t.domProps = r), Object.keys(i).length && (t.on = i), Object.keys(a).length && (t.hook = a), t;
|
|
80
83
|
}
|
|
81
|
-
function
|
|
84
|
+
function sr(e) {
|
|
82
85
|
let t = {}, n = {}, r = {}, i = {};
|
|
83
86
|
for (let [a, o] of Object.entries(e)) if (o !== void 0) {
|
|
84
87
|
if (a === "class" || a === "style" || a === "key") {
|
|
85
88
|
t[a] = o;
|
|
86
89
|
continue;
|
|
87
90
|
}
|
|
88
|
-
if (a === "ref" &&
|
|
91
|
+
if (a === "ref" && ir(o)) {
|
|
89
92
|
i.insert = (e) => {
|
|
90
93
|
o.value = e.componentInstance ?? e.elm;
|
|
91
94
|
}, i.destroy = () => {
|
|
@@ -101,47 +104,47 @@ function Xn(e) {
|
|
|
101
104
|
}
|
|
102
105
|
return Object.keys(n).length && (t.props = n), Object.keys(r).length && (t.attrs = r), Object.keys(i).length && (t.hook = i), t;
|
|
103
106
|
}
|
|
104
|
-
function
|
|
107
|
+
function cr(e) {
|
|
105
108
|
return !!(e && typeof e == "object" && "default" in e && typeof e.default == "function");
|
|
106
109
|
}
|
|
107
|
-
function
|
|
110
|
+
function lr(e) {
|
|
108
111
|
return !!(e && typeof e == "object" && ("tag" in e || "text" in e || "elm" in e || "componentOptions" in e || "componentInstance" in e));
|
|
109
112
|
}
|
|
110
|
-
function
|
|
113
|
+
function ur(e) {
|
|
111
114
|
return e == null || Array.isArray(e) ? e : [e];
|
|
112
115
|
}
|
|
113
|
-
function
|
|
114
|
-
return typeof e == "function" ?
|
|
116
|
+
function dr(e) {
|
|
117
|
+
return typeof e == "function" ? ur(e()) : cr(e) ? ur(e.default()) : lr(e) ? [e] : e;
|
|
115
118
|
}
|
|
116
|
-
function
|
|
117
|
-
if (!
|
|
118
|
-
let r = t && typeof t == "object" && !Array.isArray(t) ? t : {}, i = typeof e == "string" ?
|
|
119
|
-
return
|
|
119
|
+
function U(e, t, n) {
|
|
120
|
+
if (!rr) throw Error("Vue 2 render context is not available.");
|
|
121
|
+
let r = t && typeof t == "object" && !Array.isArray(t) ? t : {}, i = typeof e == "string" ? or(r) : sr(r), a = arguments.length === 2 && (Array.isArray(t) || typeof t == "string") ? t : dr(n);
|
|
122
|
+
return rr(e, i, a);
|
|
120
123
|
}
|
|
121
|
-
function
|
|
122
|
-
return
|
|
124
|
+
function W(e) {
|
|
125
|
+
return er.observable({ value: e });
|
|
123
126
|
}
|
|
124
|
-
var
|
|
125
|
-
function
|
|
127
|
+
var G = W;
|
|
128
|
+
function K(e) {
|
|
126
129
|
return { get value() {
|
|
127
130
|
return e();
|
|
128
131
|
} };
|
|
129
132
|
}
|
|
130
|
-
function
|
|
133
|
+
function q(e, t, n) {
|
|
131
134
|
let r = typeof e == "function" ? e : () => e.value;
|
|
132
|
-
return
|
|
135
|
+
return tr?.$watch ? tr.$watch(r, t, n) : () => void 0;
|
|
133
136
|
}
|
|
134
|
-
function
|
|
135
|
-
|
|
137
|
+
function fr(e) {
|
|
138
|
+
nr?.mounted.push(e);
|
|
136
139
|
}
|
|
137
|
-
function
|
|
138
|
-
|
|
140
|
+
function J(e) {
|
|
141
|
+
nr?.beforeUnmount.push(e);
|
|
139
142
|
}
|
|
140
143
|
function Y(e) {
|
|
141
|
-
return
|
|
144
|
+
return er.nextTick(e);
|
|
142
145
|
}
|
|
143
146
|
function X(e) {
|
|
144
|
-
return
|
|
147
|
+
return er.extend({
|
|
145
148
|
name: e.name,
|
|
146
149
|
props: e.props,
|
|
147
150
|
created() {
|
|
@@ -149,12 +152,12 @@ function X(e) {
|
|
|
149
152
|
mounted: [],
|
|
150
153
|
beforeUnmount: []
|
|
151
154
|
};
|
|
152
|
-
|
|
155
|
+
tr = this, nr = t;
|
|
153
156
|
try {
|
|
154
157
|
let n = e.setup?.(this.$props ?? this) ?? null;
|
|
155
158
|
this.__markweaveVue2Render = typeof n == "function" ? n : null, this.__markweaveVue2Lifecycle = t;
|
|
156
159
|
} finally {
|
|
157
|
-
|
|
160
|
+
tr = null, nr = null;
|
|
158
161
|
}
|
|
159
162
|
},
|
|
160
163
|
mounted() {
|
|
@@ -164,19 +167,19 @@ function X(e) {
|
|
|
164
167
|
this.__markweaveVue2Lifecycle?.beforeUnmount.forEach((e) => e());
|
|
165
168
|
},
|
|
166
169
|
render(t) {
|
|
167
|
-
|
|
170
|
+
rr = t;
|
|
168
171
|
try {
|
|
169
172
|
let n = this.__markweaveVue2Render;
|
|
170
173
|
return n ? n() : e.render?.(t) ?? null;
|
|
171
174
|
} finally {
|
|
172
|
-
|
|
175
|
+
rr = null;
|
|
173
176
|
}
|
|
174
177
|
}
|
|
175
178
|
});
|
|
176
179
|
}
|
|
177
180
|
//#endregion
|
|
178
181
|
//#region src/vue2-icons.ts
|
|
179
|
-
var
|
|
182
|
+
var pr = {
|
|
180
183
|
AlignVerticalJustifyCenter: {
|
|
181
184
|
iconName: "align-vertical-justify-center",
|
|
182
185
|
node: [
|
|
@@ -1498,8 +1501,8 @@ var ir = {
|
|
|
1498
1501
|
}]]
|
|
1499
1502
|
}
|
|
1500
1503
|
};
|
|
1501
|
-
function
|
|
1502
|
-
return e.map(([e, t]) =>
|
|
1504
|
+
function mr(e) {
|
|
1505
|
+
return e.map(([e, t]) => U(e, t));
|
|
1503
1506
|
}
|
|
1504
1507
|
function Z(e) {
|
|
1505
1508
|
return X({
|
|
@@ -1519,8 +1522,8 @@ function Z(e) {
|
|
|
1519
1522
|
}
|
|
1520
1523
|
},
|
|
1521
1524
|
setup(t) {
|
|
1522
|
-
let n =
|
|
1523
|
-
return () =>
|
|
1525
|
+
let n = pr[e];
|
|
1526
|
+
return () => U("svg", {
|
|
1524
1527
|
class: `lucide lucide-${n.iconName}`,
|
|
1525
1528
|
viewBox: "0 0 24 24",
|
|
1526
1529
|
width: t.size,
|
|
@@ -1532,12 +1535,12 @@ function Z(e) {
|
|
|
1532
1535
|
"stroke-width": t.absoluteStrokeWidth && t.size ? Number(t.strokeWidth) * 24 / Number(t.size) : t.strokeWidth,
|
|
1533
1536
|
"aria-hidden": "true",
|
|
1534
1537
|
focusable: "false"
|
|
1535
|
-
},
|
|
1538
|
+
}, mr(n.node));
|
|
1536
1539
|
}
|
|
1537
1540
|
});
|
|
1538
1541
|
}
|
|
1539
|
-
var
|
|
1540
|
-
function
|
|
1542
|
+
var hr = Z("AlignCenter"), gr = Z("AlignJustify"), _r = Z("AlignLeft"), vr = Z("AlignRight"), yr = Z("AlignVerticalJustifyCenter"), br = Z("AlignVerticalJustifyEnd"), xr = Z("AlignVerticalJustifyStart"), Sr = Z("AlertTriangle"), Cr = Z("ArrowDown"), wr = Z("ArrowDownAZ"), Tr = Z("ArrowLeft"), Er = Z("ArrowRight"), Dr = Z("ArrowUp"), Or = Z("ArrowUpZA"), kr = Z("BetweenHorizontalEnd"), Ar = Z("BetweenHorizontalStart"), jr = Z("BetweenVerticalEnd"), Mr = Z("BetweenVerticalStart"), Nr = Z("Bold"), Pr = Z("Braces"), Fr = Z("Captions"), Ir = Z("Check"), Lr = Z("CheckCircle2"), Rr = Z("ChevronDown"), zr = Z("ChevronRight"), Br = Z("ChevronUp"), Vr = Z("CircleX"), Hr = Z("Code2"), Ur = Z("CornerDownLeft"), Wr = Z("Copy"), Gr = Z("Download"), Kr = Z("Eye"), qr = Z("ExternalLink"), Jr = Z("Heading1"), Yr = Z("Heading2"), Xr = Z("Heading3"), Zr = Z("Image"), Qr = Z("ImageUp"), $r = Z("IndentDecrease"), ei = Z("IndentIncrease"), ti = Z("Info"), ni = Z("Italic"), ri = Z("Lightbulb"), ii = Z("Link2"), ai = Z("List"), oi = Z("ListChecks"), si = Z("ListOrdered"), ci = Z("Minus"), li = Z("MoreVertical"), ui = Z("PaintBucket"), di = Z("Paperclip"), fi = Z("PencilLine"), pi = Z("Plus"), mi = Z("Quote"), hi = Z("Replace"), gi = Z("RotateCcw"), _i = Z("Sigma"), vi = Z("SmilePlus"), yi = Z("Sparkles"), bi = Z("Square"), xi = Z("SquareX"), Si = Z("Strikethrough"), Ci = Z("Subscript"), wi = Z("Superscript"), Ti = Z("Table2"), Ei = Z("TableCellsMerge"), Di = Z("TableCellsSplit"), Oi = Z("Text"), ki = Z("Trash2"), Ai = Z("Type"), ji = Z("Underline"), Mi = Z("Upload"), Ni = Z("Video"), Pi = Z("X"), Fi = te;
|
|
1543
|
+
function Ii(e) {
|
|
1541
1544
|
let t = e.view.dom.closest(".markweave-editor-frame"), n = () => {
|
|
1542
1545
|
let n = t?.getAttribute("data-markweave-mode");
|
|
1543
1546
|
return n === "view" ? {
|
|
@@ -1547,7 +1550,7 @@ function Di(e) {
|
|
|
1547
1550
|
mode: "live",
|
|
1548
1551
|
editable: e.isEditable
|
|
1549
1552
|
} : u(e);
|
|
1550
|
-
}, r =
|
|
1553
|
+
}, r = W(n()), i = m(e, () => {
|
|
1551
1554
|
r.value = n();
|
|
1552
1555
|
}), a = typeof MutationObserver > "u" || !t ? null : new MutationObserver(() => {
|
|
1553
1556
|
r.value = n();
|
|
@@ -1555,28 +1558,28 @@ function Di(e) {
|
|
|
1555
1558
|
return a && t && a.observe(t, {
|
|
1556
1559
|
attributes: !0,
|
|
1557
1560
|
attributeFilter: ["data-markweave-mode"]
|
|
1558
|
-
}),
|
|
1561
|
+
}), J(() => {
|
|
1559
1562
|
i(), a?.disconnect();
|
|
1560
1563
|
}), r;
|
|
1561
1564
|
}
|
|
1562
|
-
function
|
|
1565
|
+
function Li(e) {
|
|
1563
1566
|
return e instanceof Element && !!e.closest("[data-markweave-image-ui=\"true\"]");
|
|
1564
1567
|
}
|
|
1565
|
-
function
|
|
1568
|
+
function Ri(e) {
|
|
1566
1569
|
return e instanceof Element && !!e.closest("[data-markweave-video-ui=\"true\"], iframe[data-markweave-video-embed], video[data-markweave-video]");
|
|
1567
1570
|
}
|
|
1568
|
-
function
|
|
1571
|
+
function zi(e) {
|
|
1569
1572
|
return e instanceof Element && !!e.closest("[data-markweave-link-card-ui=\"true\"]");
|
|
1570
1573
|
}
|
|
1571
|
-
function
|
|
1572
|
-
return
|
|
1574
|
+
function Bi(e, t) {
|
|
1575
|
+
return U(e, {
|
|
1573
1576
|
size: 18,
|
|
1574
1577
|
strokeWidth: 1.8,
|
|
1575
1578
|
"aria-hidden": "true"
|
|
1576
1579
|
}, { default: () => t });
|
|
1577
1580
|
}
|
|
1578
|
-
function
|
|
1579
|
-
return
|
|
1581
|
+
function Vi(e) {
|
|
1582
|
+
return U("button", {
|
|
1580
1583
|
type: "button",
|
|
1581
1584
|
"aria-label": e.label,
|
|
1582
1585
|
title: e.label,
|
|
@@ -1584,14 +1587,14 @@ function Mi(e) {
|
|
|
1584
1587
|
"data-active": e.active ? "true" : "false",
|
|
1585
1588
|
onMousedown: (e) => e.preventDefault(),
|
|
1586
1589
|
onClick: e.onClick
|
|
1587
|
-
}, [
|
|
1590
|
+
}, [Bi(e.icon, e.label), U("span", {
|
|
1588
1591
|
class: "markweave-image-tooltip",
|
|
1589
1592
|
role: "tooltip"
|
|
1590
1593
|
}, e.label)]);
|
|
1591
1594
|
}
|
|
1592
|
-
function
|
|
1593
|
-
let t =
|
|
1594
|
-
return
|
|
1595
|
+
function Hi(e) {
|
|
1596
|
+
let t = W(null), n = e.messages.image;
|
|
1597
|
+
return U("section", {
|
|
1595
1598
|
class: "markweave-image-upload-placeholder",
|
|
1596
1599
|
"data-testid": "markweave-image-upload-placeholder",
|
|
1597
1600
|
"data-drag-active": e.dragActive ? "true" : "false",
|
|
@@ -1609,7 +1612,7 @@ function Ni(e) {
|
|
|
1609
1612
|
n && e.onFile(n);
|
|
1610
1613
|
}
|
|
1611
1614
|
}, [
|
|
1612
|
-
|
|
1615
|
+
U("input", {
|
|
1613
1616
|
ref: t,
|
|
1614
1617
|
"data-testid": "markweave-image-file-input",
|
|
1615
1618
|
type: "file",
|
|
@@ -1620,20 +1623,29 @@ function Ni(e) {
|
|
|
1620
1623
|
r && e.onFile(r), n.value = "";
|
|
1621
1624
|
}
|
|
1622
1625
|
}),
|
|
1623
|
-
|
|
1624
|
-
class: "markweave-image-upload-icon",
|
|
1625
|
-
"aria-hidden": "true"
|
|
1626
|
-
}, [G(Ur, {
|
|
1627
|
-
size: 46,
|
|
1628
|
-
strokeWidth: 1.6
|
|
1629
|
-
})]),
|
|
1630
|
-
G("div", { class: "markweave-image-upload-copy" }, [G("button", {
|
|
1626
|
+
U("button", {
|
|
1631
1627
|
type: "button",
|
|
1628
|
+
class: "markweave-image-upload-trigger",
|
|
1629
|
+
"data-testid": "markweave-image-upload-trigger",
|
|
1630
|
+
"aria-label": n.uploadLabel,
|
|
1631
|
+
onMousedown: (e) => e.preventDefault(),
|
|
1632
1632
|
onClick: () => t.value?.click()
|
|
1633
|
-
},
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1633
|
+
}, [
|
|
1634
|
+
U("span", {
|
|
1635
|
+
class: "markweave-image-upload-icon",
|
|
1636
|
+
"aria-hidden": "true"
|
|
1637
|
+
}, [U(Qr, {
|
|
1638
|
+
size: 16,
|
|
1639
|
+
strokeWidth: 1.8
|
|
1640
|
+
})]),
|
|
1641
|
+
U("span", { class: "markweave-image-upload-label" }, n.uploadLabel),
|
|
1642
|
+
U("span", {
|
|
1643
|
+
class: "markweave-image-upload-tooltip",
|
|
1644
|
+
role: "tooltip"
|
|
1645
|
+
}, `${n.clickToUpload}${n.dragAndDrop}. ${n.uploadNote}`)
|
|
1646
|
+
]),
|
|
1647
|
+
U("div", { class: "markweave-image-upload-row" }, [
|
|
1648
|
+
U("input", {
|
|
1637
1649
|
"data-testid": "markweave-image-url-input",
|
|
1638
1650
|
value: e.inputValue,
|
|
1639
1651
|
placeholder: n.uploadInputPlaceholder,
|
|
@@ -1643,30 +1655,30 @@ function Ni(e) {
|
|
|
1643
1655
|
t.key === "Enter" && (t.preventDefault(), e.onSubmit());
|
|
1644
1656
|
}
|
|
1645
1657
|
}),
|
|
1646
|
-
|
|
1658
|
+
U("button", {
|
|
1647
1659
|
type: "button",
|
|
1648
1660
|
"data-testid": "markweave-image-upload-submit",
|
|
1649
1661
|
disabled: e.isSubmitting || !e.inputValue.trim(),
|
|
1650
1662
|
onClick: e.onSubmit
|
|
1651
|
-
}, [
|
|
1663
|
+
}, [U(Qr, {
|
|
1652
1664
|
size: 16,
|
|
1653
1665
|
strokeWidth: 1.8
|
|
1654
1666
|
}), e.messages.common.insert]),
|
|
1655
|
-
|
|
1667
|
+
U("button", {
|
|
1656
1668
|
type: "button",
|
|
1657
1669
|
"data-testid": "markweave-image-upload-cancel",
|
|
1658
1670
|
onClick: e.onCancel
|
|
1659
1671
|
}, e.messages.common.cancel)
|
|
1660
1672
|
]),
|
|
1661
|
-
e.error ?
|
|
1673
|
+
e.error ? U("div", {
|
|
1662
1674
|
class: "markweave-image-upload-error",
|
|
1663
1675
|
role: "alert"
|
|
1664
1676
|
}, e.error) : null
|
|
1665
1677
|
]);
|
|
1666
1678
|
}
|
|
1667
|
-
function
|
|
1668
|
-
let t =
|
|
1669
|
-
return
|
|
1679
|
+
function Ui(e) {
|
|
1680
|
+
let t = W(null), n = e.messages.video;
|
|
1681
|
+
return U("section", {
|
|
1670
1682
|
class: "markweave-video-upload-placeholder",
|
|
1671
1683
|
"data-testid": "markweave-video-upload-placeholder",
|
|
1672
1684
|
"data-drag-active": e.dragActive ? "true" : "false",
|
|
@@ -1684,7 +1696,7 @@ function Pi(e) {
|
|
|
1684
1696
|
n && e.onFile(n);
|
|
1685
1697
|
}
|
|
1686
1698
|
}, [
|
|
1687
|
-
|
|
1699
|
+
U("input", {
|
|
1688
1700
|
ref: t,
|
|
1689
1701
|
"data-testid": "markweave-video-file-input",
|
|
1690
1702
|
type: "file",
|
|
@@ -1695,20 +1707,29 @@ function Pi(e) {
|
|
|
1695
1707
|
r && e.onFile(r), n.value = "";
|
|
1696
1708
|
}
|
|
1697
1709
|
}),
|
|
1698
|
-
|
|
1699
|
-
class: "markweave-video-upload-icon",
|
|
1700
|
-
"aria-hidden": "true"
|
|
1701
|
-
}, [G(wi, {
|
|
1702
|
-
size: 46,
|
|
1703
|
-
strokeWidth: 1.6
|
|
1704
|
-
})]),
|
|
1705
|
-
G("div", { class: "markweave-video-upload-copy" }, [G("button", {
|
|
1710
|
+
U("button", {
|
|
1706
1711
|
type: "button",
|
|
1712
|
+
class: "markweave-video-upload-trigger",
|
|
1713
|
+
"data-testid": "markweave-video-upload-trigger",
|
|
1714
|
+
"aria-label": n.uploadLabel,
|
|
1715
|
+
onMousedown: (e) => e.preventDefault(),
|
|
1707
1716
|
onClick: () => t.value?.click()
|
|
1708
|
-
},
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1717
|
+
}, [
|
|
1718
|
+
U("span", {
|
|
1719
|
+
class: "markweave-video-upload-icon",
|
|
1720
|
+
"aria-hidden": "true"
|
|
1721
|
+
}, [U(Ni, {
|
|
1722
|
+
size: 16,
|
|
1723
|
+
strokeWidth: 1.8
|
|
1724
|
+
})]),
|
|
1725
|
+
U("span", { class: "markweave-video-upload-label" }, n.uploadLabel),
|
|
1726
|
+
U("span", {
|
|
1727
|
+
class: "markweave-video-upload-tooltip",
|
|
1728
|
+
role: "tooltip"
|
|
1729
|
+
}, `${n.clickToUpload}${n.dragAndDrop}. ${n.uploadNote}`)
|
|
1730
|
+
]),
|
|
1731
|
+
U("div", { class: "markweave-video-upload-row" }, [
|
|
1732
|
+
U("input", {
|
|
1712
1733
|
"data-testid": "markweave-video-url-input",
|
|
1713
1734
|
value: e.inputValue,
|
|
1714
1735
|
placeholder: n.uploadInputPlaceholder,
|
|
@@ -1718,28 +1739,28 @@ function Pi(e) {
|
|
|
1718
1739
|
t.key === "Enter" && (t.preventDefault(), e.onSubmit());
|
|
1719
1740
|
}
|
|
1720
1741
|
}),
|
|
1721
|
-
|
|
1742
|
+
U("button", {
|
|
1722
1743
|
type: "button",
|
|
1723
1744
|
"data-testid": "markweave-video-upload-submit",
|
|
1724
1745
|
disabled: e.isSubmitting || !e.inputValue.trim(),
|
|
1725
1746
|
onClick: e.onSubmit
|
|
1726
|
-
}, [
|
|
1747
|
+
}, [U(Mi, {
|
|
1727
1748
|
size: 16,
|
|
1728
1749
|
strokeWidth: 1.8
|
|
1729
1750
|
}), e.messages.common.insert]),
|
|
1730
|
-
|
|
1751
|
+
U("button", {
|
|
1731
1752
|
type: "button",
|
|
1732
1753
|
"data-testid": "markweave-video-upload-cancel",
|
|
1733
1754
|
onClick: e.onCancel
|
|
1734
1755
|
}, e.messages.common.cancel)
|
|
1735
1756
|
]),
|
|
1736
|
-
e.error ?
|
|
1757
|
+
e.error ? U("div", {
|
|
1737
1758
|
class: "markweave-video-upload-error",
|
|
1738
1759
|
role: "alert"
|
|
1739
1760
|
}, e.error) : null
|
|
1740
1761
|
]);
|
|
1741
1762
|
}
|
|
1742
|
-
var
|
|
1763
|
+
var Wi = X({
|
|
1743
1764
|
name: "MarkweaveVueImageNodeView",
|
|
1744
1765
|
props: {
|
|
1745
1766
|
editor: {
|
|
@@ -1772,8 +1793,8 @@ var Fi = X({
|
|
|
1772
1793
|
}
|
|
1773
1794
|
},
|
|
1774
1795
|
setup(e) {
|
|
1775
|
-
let t =
|
|
1776
|
-
|
|
1796
|
+
let t = W(null), r = W(!1), i = W(!1), a = W(!1), o = W(""), c = W(null), l = W(!1), u = K(() => e.node.attrs), f = W(!!P(u.value.caption)), p = W(P(u.value.caption) ?? ""), m = Ii(e.editor), h = K(() => d(m.value)), g = K(() => e.extension.options?.messages ?? n("zh")), _ = K(() => g.value.image), v = K(() => P(u.value.src)), y = K(() => e.extension.options?.resolveMediaSource), x = W(null), C = null;
|
|
1797
|
+
q(v, (t) => {
|
|
1777
1798
|
if (C?.abort(), C = null, !t) {
|
|
1778
1799
|
x.value = null;
|
|
1779
1800
|
return;
|
|
@@ -1792,11 +1813,11 @@ var Fi = X({
|
|
|
1792
1813
|
}).then((e) => {
|
|
1793
1814
|
r.signal.aborted || (x.value = e);
|
|
1794
1815
|
});
|
|
1795
|
-
}, { immediate: !0 }),
|
|
1796
|
-
let w =
|
|
1816
|
+
}, { immediate: !0 }), J(() => C?.abort());
|
|
1817
|
+
let w = K(() => x.value?.src ?? (y.value ? null : v.value)), E = K(() => Fi(u.value.align)), D = K(() => N(u.value.width)), A = K(() => P(u.value.caption)), ee = K(() => h.value && (!v.value || i.value)), te = () => {
|
|
1797
1818
|
w.value && b({
|
|
1798
1819
|
src: w.value,
|
|
1799
|
-
alt:
|
|
1820
|
+
alt: P(u.value.alt) ?? "",
|
|
1800
1821
|
messages: {
|
|
1801
1822
|
dialogAriaLabel: _.value.previewDialogAriaLabel,
|
|
1802
1823
|
zoomOut: _.value.previewZoomOut,
|
|
@@ -1806,48 +1827,48 @@ var Fi = X({
|
|
|
1806
1827
|
}
|
|
1807
1828
|
});
|
|
1808
1829
|
};
|
|
1809
|
-
|
|
1830
|
+
q(A, (e) => {
|
|
1810
1831
|
f.value || (p.value = e ?? "");
|
|
1811
1832
|
});
|
|
1812
|
-
let
|
|
1833
|
+
let M = () => {
|
|
1813
1834
|
if (!h.value) return;
|
|
1814
1835
|
let t = e.getPos();
|
|
1815
1836
|
typeof t == "number" && e.editor.chain().focus().setNodeSelection(t).run();
|
|
1816
|
-
},
|
|
1837
|
+
}, F = () => {
|
|
1817
1838
|
if (o.value = "", c.value = null, a.value = !1, v.value) {
|
|
1818
1839
|
i.value = !1;
|
|
1819
1840
|
return;
|
|
1820
1841
|
}
|
|
1821
1842
|
e.deleteNode();
|
|
1822
|
-
},
|
|
1843
|
+
}, I = async (t) => {
|
|
1823
1844
|
if (!h.value) return;
|
|
1824
1845
|
let n = e.extension.options;
|
|
1825
1846
|
l.value = !0, c.value = null;
|
|
1826
1847
|
try {
|
|
1827
|
-
let r = await
|
|
1848
|
+
let r = await ne(k(t, v.value && i.value ? "image-replace" : "image-insert"), n?.onUpload);
|
|
1828
1849
|
e.updateAttributes(T(u.value, r)), o.value = "", i.value = !1;
|
|
1829
1850
|
} catch (e) {
|
|
1830
1851
|
c.value = e instanceof Error ? e.message : _.value.uploadFailedError;
|
|
1831
1852
|
} finally {
|
|
1832
1853
|
l.value = !1, a.value = !1;
|
|
1833
1854
|
}
|
|
1834
|
-
},
|
|
1855
|
+
}, L = () => {
|
|
1835
1856
|
if (!o.value.trim()) {
|
|
1836
1857
|
c.value = _.value.uploadRequiredError;
|
|
1837
1858
|
return;
|
|
1838
1859
|
}
|
|
1839
|
-
|
|
1840
|
-
},
|
|
1841
|
-
|
|
1860
|
+
I(V(o.value));
|
|
1861
|
+
}, R = (e) => {
|
|
1862
|
+
I({
|
|
1842
1863
|
type: "file",
|
|
1843
1864
|
file: e,
|
|
1844
1865
|
mimeType: e.type || "image/*"
|
|
1845
1866
|
});
|
|
1846
|
-
},
|
|
1867
|
+
}, z = () => {
|
|
1847
1868
|
f.value = !f.value, f.value && (p.value = A.value ?? "");
|
|
1848
|
-
},
|
|
1869
|
+
}, B = (n, r) => {
|
|
1849
1870
|
if (!h.value || !v.value) return;
|
|
1850
|
-
r.preventDefault(), r.stopPropagation(),
|
|
1871
|
+
r.preventDefault(), r.stopPropagation(), M();
|
|
1851
1872
|
let i = t.value;
|
|
1852
1873
|
if (!i) return;
|
|
1853
1874
|
let a = r.clientX, o = i.getBoundingClientRect().width || D.value || 320, s = i.closest(".markweave-editor-surface")?.getBoundingClientRect().width ?? i.parentElement?.getBoundingClientRect().width ?? o, c = (t) => {
|
|
@@ -1858,7 +1879,7 @@ var Fi = X({
|
|
|
1858
1879
|
};
|
|
1859
1880
|
window.addEventListener("pointermove", c), window.addEventListener("pointerup", l, { once: !0 });
|
|
1860
1881
|
};
|
|
1861
|
-
return () =>
|
|
1882
|
+
return () => ee.value ? U(s, {
|
|
1862
1883
|
as: "figure",
|
|
1863
1884
|
class: "markweave-image-node",
|
|
1864
1885
|
"data-testid": "markweave-image-node",
|
|
@@ -1866,7 +1887,7 @@ var Fi = X({
|
|
|
1866
1887
|
"data-selected": "false",
|
|
1867
1888
|
"data-hovered": "false",
|
|
1868
1889
|
"data-empty": "true"
|
|
1869
|
-
}, () =>
|
|
1890
|
+
}, () => Hi({
|
|
1870
1891
|
messages: g.value,
|
|
1871
1892
|
inputValue: o.value,
|
|
1872
1893
|
error: c.value,
|
|
@@ -1875,13 +1896,13 @@ var Fi = X({
|
|
|
1875
1896
|
onInputValue: (e) => {
|
|
1876
1897
|
o.value = e;
|
|
1877
1898
|
},
|
|
1878
|
-
onFile:
|
|
1879
|
-
onSubmit:
|
|
1880
|
-
onCancel:
|
|
1899
|
+
onFile: R,
|
|
1900
|
+
onSubmit: L,
|
|
1901
|
+
onCancel: F,
|
|
1881
1902
|
onDragActive: (e) => {
|
|
1882
1903
|
a.value = e;
|
|
1883
1904
|
}
|
|
1884
|
-
})) :
|
|
1905
|
+
})) : U(s, {
|
|
1885
1906
|
as: "figure",
|
|
1886
1907
|
class: "markweave-image-node",
|
|
1887
1908
|
"data-testid": "markweave-image-node",
|
|
@@ -1896,81 +1917,81 @@ var Fi = X({
|
|
|
1896
1917
|
r.value = !1;
|
|
1897
1918
|
},
|
|
1898
1919
|
onMousedown: (e) => {
|
|
1899
|
-
h.value && !
|
|
1920
|
+
h.value && !Li(e.target) && M();
|
|
1900
1921
|
}
|
|
1901
1922
|
}, () => [
|
|
1902
|
-
h.value ?
|
|
1923
|
+
h.value ? U("div", {
|
|
1903
1924
|
class: "markweave-image-toolbar",
|
|
1904
1925
|
"data-testid": "markweave-image-toolbar",
|
|
1905
1926
|
"data-markweave-image-ui": "true",
|
|
1906
1927
|
"aria-label": _.value.toolsAriaLabel
|
|
1907
1928
|
}, [
|
|
1908
|
-
|
|
1929
|
+
Vi({
|
|
1909
1930
|
testId: "markweave-image-align-left",
|
|
1910
1931
|
label: _.value.alignLeft,
|
|
1911
|
-
icon:
|
|
1932
|
+
icon: _r,
|
|
1912
1933
|
active: E.value === "left",
|
|
1913
1934
|
onClick: () => e.updateAttributes({ align: "left" })
|
|
1914
1935
|
}),
|
|
1915
|
-
|
|
1936
|
+
Vi({
|
|
1916
1937
|
testId: "markweave-image-align-center",
|
|
1917
1938
|
label: _.value.alignCenter,
|
|
1918
|
-
icon:
|
|
1939
|
+
icon: hr,
|
|
1919
1940
|
active: E.value === "center",
|
|
1920
1941
|
onClick: () => e.updateAttributes({ align: "center" })
|
|
1921
1942
|
}),
|
|
1922
|
-
|
|
1943
|
+
Vi({
|
|
1923
1944
|
testId: "markweave-image-align-right",
|
|
1924
1945
|
label: _.value.alignRight,
|
|
1925
|
-
icon:
|
|
1946
|
+
icon: vr,
|
|
1926
1947
|
active: E.value === "right",
|
|
1927
1948
|
onClick: () => e.updateAttributes({ align: "right" })
|
|
1928
1949
|
}),
|
|
1929
|
-
|
|
1950
|
+
U("span", {
|
|
1930
1951
|
class: "markweave-image-toolbar-divider",
|
|
1931
1952
|
"aria-hidden": "true"
|
|
1932
1953
|
}),
|
|
1933
|
-
|
|
1954
|
+
Vi({
|
|
1934
1955
|
testId: "markweave-image-caption",
|
|
1935
1956
|
label: _.value.caption,
|
|
1936
|
-
icon:
|
|
1957
|
+
icon: Fr,
|
|
1937
1958
|
active: f.value || !!A.value,
|
|
1938
|
-
onClick:
|
|
1959
|
+
onClick: z
|
|
1939
1960
|
}),
|
|
1940
|
-
|
|
1961
|
+
Vi({
|
|
1941
1962
|
testId: "markweave-image-preview",
|
|
1942
1963
|
label: _.value.preview,
|
|
1943
|
-
icon:
|
|
1944
|
-
onClick:
|
|
1964
|
+
icon: Kr,
|
|
1965
|
+
onClick: te
|
|
1945
1966
|
}),
|
|
1946
|
-
|
|
1967
|
+
Vi({
|
|
1947
1968
|
testId: "markweave-image-download",
|
|
1948
1969
|
label: _.value.download,
|
|
1949
|
-
icon:
|
|
1970
|
+
icon: Gr,
|
|
1950
1971
|
onClick: () => {
|
|
1951
1972
|
w.value && j(w.value);
|
|
1952
1973
|
}
|
|
1953
1974
|
}),
|
|
1954
|
-
|
|
1975
|
+
Vi({
|
|
1955
1976
|
testId: "markweave-image-replace",
|
|
1956
1977
|
label: _.value.replace,
|
|
1957
|
-
icon:
|
|
1978
|
+
icon: hi,
|
|
1958
1979
|
onClick: () => {
|
|
1959
1980
|
o.value = "", c.value = null, i.value = !0;
|
|
1960
1981
|
}
|
|
1961
1982
|
}),
|
|
1962
|
-
|
|
1983
|
+
U("span", {
|
|
1963
1984
|
class: "markweave-image-toolbar-divider",
|
|
1964
1985
|
"aria-hidden": "true"
|
|
1965
1986
|
}),
|
|
1966
|
-
|
|
1987
|
+
Vi({
|
|
1967
1988
|
testId: "markweave-image-delete",
|
|
1968
1989
|
label: _.value.delete,
|
|
1969
|
-
icon:
|
|
1990
|
+
icon: ki,
|
|
1970
1991
|
onClick: () => e.deleteNode()
|
|
1971
1992
|
})
|
|
1972
1993
|
]) : null,
|
|
1973
|
-
|
|
1994
|
+
U("div", {
|
|
1974
1995
|
ref: t,
|
|
1975
1996
|
class: "markweave-image-box",
|
|
1976
1997
|
style: {
|
|
@@ -1978,22 +1999,22 @@ var Fi = X({
|
|
|
1978
1999
|
...x.value?.width && x.value.height ? { aspectRatio: `${x.value.width} / ${x.value.height}` } : {}
|
|
1979
2000
|
}
|
|
1980
2001
|
}, [
|
|
1981
|
-
w.value ?
|
|
2002
|
+
w.value ? U("img", {
|
|
1982
2003
|
class: "markweave-image",
|
|
1983
2004
|
src: w.value,
|
|
1984
|
-
alt:
|
|
1985
|
-
title:
|
|
2005
|
+
alt: P(u.value.alt) ?? "",
|
|
2006
|
+
title: P(u.value.title) ?? void 0,
|
|
1986
2007
|
draggable: !1,
|
|
1987
2008
|
loading: "lazy",
|
|
1988
2009
|
decoding: "async",
|
|
1989
2010
|
width: x.value?.width,
|
|
1990
2011
|
height: x.value?.height
|
|
1991
|
-
}) :
|
|
2012
|
+
}) : U("div", {
|
|
1992
2013
|
class: "markweave-image-readonly-empty",
|
|
1993
2014
|
"data-testid": "markweave-image-readonly-empty",
|
|
1994
2015
|
"aria-hidden": "true"
|
|
1995
2016
|
}),
|
|
1996
|
-
!h.value && w.value ?
|
|
2017
|
+
!h.value && w.value ? U("button", {
|
|
1997
2018
|
type: "button",
|
|
1998
2019
|
class: "markweave-image-preview-trigger",
|
|
1999
2020
|
"data-testid": "markweave-image-preview",
|
|
@@ -2001,34 +2022,34 @@ var Fi = X({
|
|
|
2001
2022
|
"aria-label": _.value.preview,
|
|
2002
2023
|
title: _.value.preview,
|
|
2003
2024
|
onMousedown: (e) => e.preventDefault(),
|
|
2004
|
-
onClick:
|
|
2005
|
-
}, [
|
|
2025
|
+
onClick: te
|
|
2026
|
+
}, [U(Kr, {
|
|
2006
2027
|
size: 16,
|
|
2007
2028
|
strokeWidth: 1.8
|
|
2008
|
-
}),
|
|
2029
|
+
}), U("span", {
|
|
2009
2030
|
class: "markweave-image-tooltip",
|
|
2010
2031
|
role: "tooltip"
|
|
2011
2032
|
}, _.value.preview)]) : null,
|
|
2012
|
-
h.value ?
|
|
2033
|
+
h.value ? U("button", {
|
|
2013
2034
|
type: "button",
|
|
2014
2035
|
class: "markweave-image-resize-handle",
|
|
2015
2036
|
"data-testid": "markweave-image-resize-left",
|
|
2016
2037
|
"data-side": "left",
|
|
2017
2038
|
"aria-label": _.value.resizeLeft,
|
|
2018
2039
|
"data-markweave-image-ui": "true",
|
|
2019
|
-
onPointerdown: (e) =>
|
|
2040
|
+
onPointerdown: (e) => B("left", e)
|
|
2020
2041
|
}) : null,
|
|
2021
|
-
h.value ?
|
|
2042
|
+
h.value ? U("button", {
|
|
2022
2043
|
type: "button",
|
|
2023
2044
|
class: "markweave-image-resize-handle",
|
|
2024
2045
|
"data-testid": "markweave-image-resize-right",
|
|
2025
2046
|
"data-side": "right",
|
|
2026
2047
|
"aria-label": _.value.resizeRight,
|
|
2027
2048
|
"data-markweave-image-ui": "true",
|
|
2028
|
-
onPointerdown: (e) =>
|
|
2049
|
+
onPointerdown: (e) => B("right", e)
|
|
2029
2050
|
}) : null
|
|
2030
2051
|
]),
|
|
2031
|
-
h.value && (f.value || A.value) ?
|
|
2052
|
+
h.value && (f.value || A.value) ? U("input", {
|
|
2032
2053
|
class: "markweave-image-caption-input",
|
|
2033
2054
|
"data-testid": "markweave-image-caption-input",
|
|
2034
2055
|
"data-markweave-image-ui": "true",
|
|
@@ -2041,13 +2062,13 @@ var Fi = X({
|
|
|
2041
2062
|
onKeydown: (e) => {
|
|
2042
2063
|
e.key === "Escape" && (e.preventDefault(), f.value = !1);
|
|
2043
2064
|
}
|
|
2044
|
-
}) : A.value ?
|
|
2065
|
+
}) : A.value ? U("figcaption", {
|
|
2045
2066
|
class: "markweave-image-caption",
|
|
2046
2067
|
"data-testid": "markweave-image-caption"
|
|
2047
2068
|
}, A.value) : null
|
|
2048
2069
|
]);
|
|
2049
2070
|
}
|
|
2050
|
-
}),
|
|
2071
|
+
}), Gi = X({
|
|
2051
2072
|
name: "MarkweaveVueVideoNodeView",
|
|
2052
2073
|
props: {
|
|
2053
2074
|
editor: {
|
|
@@ -2080,14 +2101,14 @@ var Fi = X({
|
|
|
2080
2101
|
}
|
|
2081
2102
|
},
|
|
2082
2103
|
setup(e) {
|
|
2083
|
-
let t =
|
|
2104
|
+
let t = W(!1), r = W(""), i = W(null), a = W(!1), o = Ii(e.editor), c = K(() => d(o.value)), l = K(() => e.extension.options?.messages ?? n("zh")), u = K(() => l.value.video), f = K(() => e.node.attrs), p = K(() => P(f.value.src)), m = K(() => P(f.value.embedUrl)), h = K(() => P(f.value.provider)), g = K(() => m.value ? M(m.value, h.value) : null), _ = K(() => P(f.value.mimeType)), v = K(() => P(f.value.title)), y = () => {
|
|
2084
2105
|
p.value || e.deleteNode(), r.value = "", i.value = null, t.value = !1;
|
|
2085
2106
|
}, b = async (n) => {
|
|
2086
2107
|
if (!c.value) return;
|
|
2087
2108
|
let o = e.extension.options;
|
|
2088
2109
|
a.value = !0, i.value = null;
|
|
2089
2110
|
try {
|
|
2090
|
-
let t = await
|
|
2111
|
+
let t = await ne(A(n), o?.onUpload);
|
|
2091
2112
|
e.updateAttributes(E(t)), r.value = "";
|
|
2092
2113
|
} catch (e) {
|
|
2093
2114
|
i.value = e instanceof Error ? e.message : u.value.uploadFailedError;
|
|
@@ -2115,13 +2136,13 @@ var Fi = X({
|
|
|
2115
2136
|
}, w = (t) => {
|
|
2116
2137
|
c.value && e.selected && (t.key === "Backspace" || t.key === "Delete") && (t.preventDefault(), e.deleteNode());
|
|
2117
2138
|
};
|
|
2118
|
-
return () => c.value && !p.value ?
|
|
2139
|
+
return () => c.value && !p.value ? U(s, {
|
|
2119
2140
|
as: "figure",
|
|
2120
2141
|
class: "markweave-video-node",
|
|
2121
2142
|
"data-testid": "markweave-video-node",
|
|
2122
2143
|
"data-empty": "true",
|
|
2123
2144
|
"data-selected": "false"
|
|
2124
|
-
}, () =>
|
|
2145
|
+
}, () => Ui({
|
|
2125
2146
|
messages: l.value,
|
|
2126
2147
|
inputValue: r.value,
|
|
2127
2148
|
error: i.value,
|
|
@@ -2136,7 +2157,7 @@ var Fi = X({
|
|
|
2136
2157
|
onDragActive: (e) => {
|
|
2137
2158
|
t.value = e;
|
|
2138
2159
|
}
|
|
2139
|
-
})) :
|
|
2160
|
+
})) : U(s, {
|
|
2140
2161
|
as: "figure",
|
|
2141
2162
|
class: "markweave-video-node",
|
|
2142
2163
|
"data-testid": "markweave-video-node",
|
|
@@ -2148,25 +2169,25 @@ var Fi = X({
|
|
|
2148
2169
|
onFocus: C,
|
|
2149
2170
|
onKeydown: w,
|
|
2150
2171
|
onMousedown: (e) => {
|
|
2151
|
-
c.value && !
|
|
2172
|
+
c.value && !Ri(e.target) && (e.preventDefault(), C());
|
|
2152
2173
|
}
|
|
2153
|
-
}, () => [g.value ?
|
|
2174
|
+
}, () => [g.value ? U("div", { class: "markweave-video-embed" }, [U("iframe", {
|
|
2154
2175
|
class: "markweave-video-iframe",
|
|
2155
2176
|
src: g.value,
|
|
2156
2177
|
title: v.value ?? `${h.value ?? "Video"} embed`,
|
|
2157
2178
|
"data-markweave-video-embed": "true",
|
|
2158
2179
|
"data-markweave-video-provider": h.value ?? void 0,
|
|
2159
2180
|
"data-markweave-video-src": p.value ?? void 0,
|
|
2160
|
-
allow:
|
|
2181
|
+
allow: ee,
|
|
2161
2182
|
loading: "lazy",
|
|
2162
2183
|
allowfullscreen: "true"
|
|
2163
|
-
}), c.value ?
|
|
2184
|
+
}), c.value ? U("button", {
|
|
2164
2185
|
type: "button",
|
|
2165
2186
|
class: "markweave-video-selection-layer",
|
|
2166
2187
|
"data-testid": "markweave-video-selection-layer",
|
|
2167
2188
|
tabindex: -1,
|
|
2168
2189
|
"aria-label": u.value.selectAriaLabel
|
|
2169
|
-
}) : null]) : p.value ?
|
|
2190
|
+
}) : null]) : p.value ? U("div", { class: "markweave-video-box" }, [U("video", {
|
|
2170
2191
|
class: "markweave-video",
|
|
2171
2192
|
src: p.value,
|
|
2172
2193
|
title: v.value ?? void 0,
|
|
@@ -2174,19 +2195,19 @@ var Fi = X({
|
|
|
2174
2195
|
controls: !0,
|
|
2175
2196
|
"data-markweave-video": "true",
|
|
2176
2197
|
"data-markweave-mime-type": _.value ?? void 0
|
|
2177
|
-
}), c.value ?
|
|
2198
|
+
}), c.value ? U("button", {
|
|
2178
2199
|
type: "button",
|
|
2179
2200
|
class: "markweave-video-selection-layer",
|
|
2180
2201
|
"data-testid": "markweave-video-selection-layer",
|
|
2181
2202
|
tabindex: -1,
|
|
2182
2203
|
"aria-label": u.value.selectAriaLabel
|
|
2183
|
-
}) : null]) :
|
|
2204
|
+
}) : null]) : U("div", {
|
|
2184
2205
|
class: "markweave-video-readonly-empty",
|
|
2185
2206
|
"data-testid": "markweave-video-readonly-empty",
|
|
2186
2207
|
"aria-hidden": "true"
|
|
2187
2208
|
})]);
|
|
2188
2209
|
}
|
|
2189
|
-
}),
|
|
2210
|
+
}), Ki = C.extend({
|
|
2190
2211
|
addOptions() {
|
|
2191
2212
|
return {
|
|
2192
2213
|
...this.parent?.(),
|
|
@@ -2197,16 +2218,16 @@ var Fi = X({
|
|
|
2197
2218
|
},
|
|
2198
2219
|
addNodeView() {
|
|
2199
2220
|
if (typeof document > "u") return null;
|
|
2200
|
-
let e = c(
|
|
2221
|
+
let e = c(Wi, { stopEvent: ({ event: e }) => Li(e.target) }), t = this.options.resolveMediaSource;
|
|
2201
2222
|
if (!t) return e;
|
|
2202
2223
|
let r = x({
|
|
2203
2224
|
messages: this.options.messages ?? n("zh"),
|
|
2204
2225
|
onUpload: this.options.onUpload,
|
|
2205
2226
|
resolveMediaSource: t
|
|
2206
2227
|
});
|
|
2207
|
-
return (t) =>
|
|
2228
|
+
return (t) => P(t.node.attrs.src) ? r(t) : e(t);
|
|
2208
2229
|
}
|
|
2209
|
-
}),
|
|
2230
|
+
}), qi = w.extend({
|
|
2210
2231
|
addOptions() {
|
|
2211
2232
|
return {
|
|
2212
2233
|
...this.parent?.(),
|
|
@@ -2216,9 +2237,215 @@ var Fi = X({
|
|
|
2216
2237
|
};
|
|
2217
2238
|
},
|
|
2218
2239
|
addNodeView() {
|
|
2219
|
-
return typeof document > "u" ? null : c(
|
|
2240
|
+
return typeof document > "u" ? null : c(Gi, { stopEvent: ({ event: e }) => Ri(e.target) });
|
|
2220
2241
|
}
|
|
2221
|
-
})
|
|
2242
|
+
});
|
|
2243
|
+
function Ji(e) {
|
|
2244
|
+
return e instanceof Element && !!e.closest("[data-markweave-attachment-ui=\"true\"], .markweave-attachment-upload-placeholder, .markweave-attachment-uploading");
|
|
2245
|
+
}
|
|
2246
|
+
function Yi(e, t) {
|
|
2247
|
+
return typeof t != "number" || !Number.isFinite(t) || t <= 0 ? null : Math.max(0, Math.min(100, Math.round(e / t * 100)));
|
|
2248
|
+
}
|
|
2249
|
+
var Xi = X({
|
|
2250
|
+
name: "MarkweaveVueAttachmentNodeView",
|
|
2251
|
+
props: {
|
|
2252
|
+
editor: {
|
|
2253
|
+
type: Object,
|
|
2254
|
+
required: !0
|
|
2255
|
+
},
|
|
2256
|
+
extension: {
|
|
2257
|
+
type: Object,
|
|
2258
|
+
required: !0
|
|
2259
|
+
},
|
|
2260
|
+
node: {
|
|
2261
|
+
type: Object,
|
|
2262
|
+
required: !0
|
|
2263
|
+
},
|
|
2264
|
+
getPos: {
|
|
2265
|
+
type: Function,
|
|
2266
|
+
required: !0
|
|
2267
|
+
},
|
|
2268
|
+
deleteNode: {
|
|
2269
|
+
type: Function,
|
|
2270
|
+
required: !0
|
|
2271
|
+
},
|
|
2272
|
+
updateAttributes: {
|
|
2273
|
+
type: Function,
|
|
2274
|
+
required: !0
|
|
2275
|
+
},
|
|
2276
|
+
selected: {
|
|
2277
|
+
type: Boolean,
|
|
2278
|
+
required: !0
|
|
2279
|
+
}
|
|
2280
|
+
},
|
|
2281
|
+
setup(e) {
|
|
2282
|
+
let t = K(() => e.extension.options), r = K(() => t.value?.messages ?? n("zh")), i = Ii(e.editor), a = K(() => d(i.value)), o = K(() => L(e.node.attrs ?? {})), c = K(() => o.value?.name ?? P(e.node.attrs?.src) ?? r.value.attachment.missingSrc), l = K(() => [P(e.node.attrs?.mimeType), z(typeof e.node.attrs?.size == "number" ? e.node.attrs.size : null)].filter(Boolean).join(" · ")), f = W(null), p = W(!1), m = W(!1), h = W(null), g = W(null), _ = W(null), v = W(null), y = () => {
|
|
2283
|
+
if (!a.value) return;
|
|
2284
|
+
let t = e.getPos();
|
|
2285
|
+
typeof t == "number" && e.editor.chain().focus().setNodeSelection(t).run();
|
|
2286
|
+
}, b = () => {
|
|
2287
|
+
!a.value || m.value || f.value?.click();
|
|
2288
|
+
}, x = async (n) => {
|
|
2289
|
+
if (!(!a.value || !n || m.value)) {
|
|
2290
|
+
h.value = null, m.value = !0, g.value = n.name, _.value = n.size, v.value = null;
|
|
2291
|
+
try {
|
|
2292
|
+
let r = await ne({
|
|
2293
|
+
...R({
|
|
2294
|
+
type: "file",
|
|
2295
|
+
file: n,
|
|
2296
|
+
mimeType: n.type || void 0
|
|
2297
|
+
}),
|
|
2298
|
+
onProgress: (e) => {
|
|
2299
|
+
v.value = Yi(e.loaded, e.total);
|
|
2300
|
+
}
|
|
2301
|
+
}, t.value?.onUpload);
|
|
2302
|
+
e.updateAttributes(I(r));
|
|
2303
|
+
} catch (e) {
|
|
2304
|
+
h.value = e instanceof Error ? e.message : r.value.attachment.uploadFailedError;
|
|
2305
|
+
} finally {
|
|
2306
|
+
m.value = !1, g.value = null, _.value = null, v.value = null, f.value && (f.value.value = "");
|
|
2307
|
+
}
|
|
2308
|
+
}
|
|
2309
|
+
}, S = (n) => {
|
|
2310
|
+
n.preventDefault(), n.stopPropagation(), o.value && F(o.value, {
|
|
2311
|
+
mode: u(e.editor).mode,
|
|
2312
|
+
event: n
|
|
2313
|
+
}, t.value?.onDownload);
|
|
2314
|
+
}, C = (e) => {
|
|
2315
|
+
Ji(e.target) || (e.preventDefault(), e.stopPropagation(), o.value && S(e));
|
|
2316
|
+
};
|
|
2317
|
+
return () => {
|
|
2318
|
+
let t = r.value.attachment, n = a.value && !o.value && !m.value, i = m.value, u = !!o.value && (p.value || e.selected), d = [z(_.value), v.value === null ? null : `${v.value}%`].filter(Boolean).join(" · ");
|
|
2319
|
+
return n ? U(s, {
|
|
2320
|
+
as: "div",
|
|
2321
|
+
class: "markweave-attachment markweave-attachment-upload-placeholder",
|
|
2322
|
+
"data-markweave-attachment": "true",
|
|
2323
|
+
"data-markweave-attachment-nodeview": "true",
|
|
2324
|
+
"data-empty": "true",
|
|
2325
|
+
"data-testid": "markweave-attachment-node",
|
|
2326
|
+
"data-selected": e.selected ? "true" : "false",
|
|
2327
|
+
"aria-label": t.uploadLabel,
|
|
2328
|
+
onKeydown: (t) => {
|
|
2329
|
+
a.value && e.selected && (t.key === "Delete" || t.key === "Backspace") && (t.preventDefault(), e.deleteNode());
|
|
2330
|
+
}
|
|
2331
|
+
}, [U("input", {
|
|
2332
|
+
ref: f,
|
|
2333
|
+
type: "file",
|
|
2334
|
+
hidden: !0,
|
|
2335
|
+
"data-testid": "markweave-attachment-file-input",
|
|
2336
|
+
onChange: (e) => {
|
|
2337
|
+
x(e.target.files?.[0] ?? null);
|
|
2338
|
+
}
|
|
2339
|
+
}), U("button", {
|
|
2340
|
+
type: "button",
|
|
2341
|
+
class: "markweave-attachment-upload-trigger",
|
|
2342
|
+
"data-markweave-attachment-ui": "true",
|
|
2343
|
+
"data-testid": "markweave-attachment-upload-trigger",
|
|
2344
|
+
"aria-label": t.uploadLabel,
|
|
2345
|
+
onMousedown: (e) => e.preventDefault(),
|
|
2346
|
+
onClick: () => b()
|
|
2347
|
+
}, [
|
|
2348
|
+
U("span", {
|
|
2349
|
+
class: "markweave-attachment-icon",
|
|
2350
|
+
"aria-hidden": "true"
|
|
2351
|
+
}, [Bi(Mi, t.uploadLabel)]),
|
|
2352
|
+
U("span", { class: "markweave-attachment-upload-label" }, t.uploadLabel),
|
|
2353
|
+
h.value ? U("span", { class: "markweave-attachment-upload-error" }, h.value) : null
|
|
2354
|
+
])]) : i ? U(s, {
|
|
2355
|
+
as: "div",
|
|
2356
|
+
class: "markweave-attachment markweave-attachment-uploading",
|
|
2357
|
+
"data-markweave-attachment": "true",
|
|
2358
|
+
"data-markweave-attachment-nodeview": "true",
|
|
2359
|
+
"data-markweave-attachment-ui": "true",
|
|
2360
|
+
"data-uploading": "true",
|
|
2361
|
+
"data-testid": "markweave-attachment-node",
|
|
2362
|
+
"data-selected": e.selected ? "true" : "false",
|
|
2363
|
+
"aria-label": t.uploading,
|
|
2364
|
+
onMousedown: (e) => {
|
|
2365
|
+
e.preventDefault(), e.stopPropagation();
|
|
2366
|
+
},
|
|
2367
|
+
onKeydown: (t) => {
|
|
2368
|
+
a.value && e.selected && (t.key === "Delete" || t.key === "Backspace") && (t.preventDefault(), e.deleteNode());
|
|
2369
|
+
}
|
|
2370
|
+
}, [U("span", {
|
|
2371
|
+
class: "markweave-attachment-icon",
|
|
2372
|
+
"aria-hidden": "true"
|
|
2373
|
+
}, [Bi(Mi, t.uploading)]), U("span", { class: "markweave-attachment-body" }, [U("span", { class: "markweave-attachment-name" }, g.value ?? t.uploading), U("span", { class: "markweave-attachment-meta" }, [U("span", {
|
|
2374
|
+
class: "markweave-attachment-spinner",
|
|
2375
|
+
"aria-hidden": "true"
|
|
2376
|
+
}), d || t.uploading])])]) : U(s, {
|
|
2377
|
+
as: "div",
|
|
2378
|
+
class: "markweave-attachment",
|
|
2379
|
+
"data-markweave-attachment": "true",
|
|
2380
|
+
"data-markweave-attachment-nodeview": "true",
|
|
2381
|
+
"data-testid": "markweave-attachment-node",
|
|
2382
|
+
"data-selected": e.selected ? "true" : "false",
|
|
2383
|
+
"data-hovered": p.value ? "true" : "false",
|
|
2384
|
+
"aria-label": t.nodeAriaLabel,
|
|
2385
|
+
onMouseenter: () => {
|
|
2386
|
+
p.value = !0;
|
|
2387
|
+
},
|
|
2388
|
+
onMouseleave: () => {
|
|
2389
|
+
p.value = !1;
|
|
2390
|
+
},
|
|
2391
|
+
onMousedown: (e) => {
|
|
2392
|
+
!a.value || Ji(e.target) || (e.preventDefault(), y());
|
|
2393
|
+
},
|
|
2394
|
+
onKeydown: (t) => {
|
|
2395
|
+
a.value && e.selected && (t.key === "Delete" || t.key === "Backspace") && (t.preventDefault(), e.deleteNode());
|
|
2396
|
+
},
|
|
2397
|
+
onClick: C
|
|
2398
|
+
}, [
|
|
2399
|
+
U("span", {
|
|
2400
|
+
class: "markweave-attachment-icon",
|
|
2401
|
+
"aria-hidden": "true"
|
|
2402
|
+
}, [Bi(di, t.nodeAriaLabel)]),
|
|
2403
|
+
U("span", { class: "markweave-attachment-body" }, [U("span", { class: "markweave-attachment-name" }, c.value), l.value ? U("span", { class: "markweave-attachment-meta" }, l.value) : null]),
|
|
2404
|
+
u ? U("span", {
|
|
2405
|
+
class: "markweave-attachment-actions",
|
|
2406
|
+
"data-markweave-attachment-ui": "true"
|
|
2407
|
+
}, [U("button", {
|
|
2408
|
+
type: "button",
|
|
2409
|
+
class: "markweave-attachment-download",
|
|
2410
|
+
"data-markweave-attachment-ui": "true",
|
|
2411
|
+
"data-testid": "markweave-attachment-download",
|
|
2412
|
+
"aria-label": t.downloadAriaLabel,
|
|
2413
|
+
onMousedown: (e) => e.preventDefault(),
|
|
2414
|
+
onClick: S
|
|
2415
|
+
}, [Bi(Gr, t.download), U("span", {
|
|
2416
|
+
class: "markweave-attachment-tooltip",
|
|
2417
|
+
role: "tooltip"
|
|
2418
|
+
}, t.download)]), a.value ? U("button", {
|
|
2419
|
+
type: "button",
|
|
2420
|
+
class: "markweave-attachment-delete",
|
|
2421
|
+
"data-markweave-attachment-ui": "true",
|
|
2422
|
+
"data-testid": "markweave-attachment-delete",
|
|
2423
|
+
"aria-label": t.deleteAriaLabel,
|
|
2424
|
+
onMousedown: (e) => e.preventDefault(),
|
|
2425
|
+
onClick: (t) => {
|
|
2426
|
+
t.preventDefault(), t.stopPropagation(), e.deleteNode();
|
|
2427
|
+
}
|
|
2428
|
+
}, [Bi(ki, t.delete), U("span", {
|
|
2429
|
+
class: "markweave-attachment-tooltip",
|
|
2430
|
+
role: "tooltip"
|
|
2431
|
+
}, t.delete)]) : null]) : null
|
|
2432
|
+
]);
|
|
2433
|
+
};
|
|
2434
|
+
}
|
|
2435
|
+
}), Zi = B.extend({
|
|
2436
|
+
addOptions() {
|
|
2437
|
+
return {
|
|
2438
|
+
...this.parent?.(),
|
|
2439
|
+
messages: n("zh"),
|
|
2440
|
+
onUpload: void 0,
|
|
2441
|
+
onDownload: void 0,
|
|
2442
|
+
HTMLAttributes: { class: "markweave-attachment" }
|
|
2443
|
+
};
|
|
2444
|
+
},
|
|
2445
|
+
addNodeView() {
|
|
2446
|
+
return typeof document > "u" ? null : c(Xi, { stopEvent: ({ event: e }) => Ji(e.target) });
|
|
2447
|
+
}
|
|
2448
|
+
}), Qi = X({
|
|
2222
2449
|
name: "MarkweaveVueLinkCardNodeView",
|
|
2223
2450
|
props: {
|
|
2224
2451
|
editor: {
|
|
@@ -2251,11 +2478,11 @@ var Fi = X({
|
|
|
2251
2478
|
}
|
|
2252
2479
|
},
|
|
2253
2480
|
setup(e) {
|
|
2254
|
-
let t = e.extension.options, r = t.messages ?? n("zh"), i =
|
|
2255
|
-
|
|
2481
|
+
let t = e.extension.options, r = t.messages ?? n("zh"), i = Ii(e.editor), a = W(!1), o = W(!1), c = W(!1), l = K(() => _(e.node.attrs ?? {})), u = W(l.value?.title ?? ""), f = W(l.value?.href ?? "");
|
|
2482
|
+
q(l, (e) => {
|
|
2256
2483
|
u.value = e?.title ?? "", f.value = e?.href ?? "", c.value = !1;
|
|
2257
2484
|
});
|
|
2258
|
-
let p =
|
|
2485
|
+
let p = K(() => d(i.value)), m = K(() => {
|
|
2259
2486
|
try {
|
|
2260
2487
|
return new URL(l.value?.href ?? "").host;
|
|
2261
2488
|
} catch {
|
|
@@ -2279,18 +2506,18 @@ var Fi = X({
|
|
|
2279
2506
|
...r,
|
|
2280
2507
|
...i
|
|
2281
2508
|
}) ?? r);
|
|
2282
|
-
}, C = (e, t, n, r) =>
|
|
2509
|
+
}, C = (e, t, n, r) => U("button", {
|
|
2283
2510
|
type: "button",
|
|
2284
2511
|
title: e,
|
|
2285
2512
|
"aria-label": e,
|
|
2286
2513
|
"data-testid": n,
|
|
2287
2514
|
onMousedown: h,
|
|
2288
2515
|
onClick: r
|
|
2289
|
-
}, [
|
|
2516
|
+
}, [Bi(t, e), U("span", { role: "tooltip" }, e)]);
|
|
2290
2517
|
return () => {
|
|
2291
2518
|
let n = l.value;
|
|
2292
2519
|
if (!n) return null;
|
|
2293
|
-
let i = !c.value && n.imageUrl ?
|
|
2520
|
+
let i = !c.value && n.imageUrl ? U("img", {
|
|
2294
2521
|
src: n.imageUrl,
|
|
2295
2522
|
alt: "",
|
|
2296
2523
|
loading: "lazy",
|
|
@@ -2298,7 +2525,7 @@ var Fi = X({
|
|
|
2298
2525
|
onError: () => {
|
|
2299
2526
|
c.value = !0;
|
|
2300
2527
|
}
|
|
2301
|
-
}) : !c.value && n.faviconUrl ?
|
|
2528
|
+
}) : !c.value && n.faviconUrl ? U("img", {
|
|
2302
2529
|
class: "markweave-link-card-favicon",
|
|
2303
2530
|
src: n.faviconUrl,
|
|
2304
2531
|
alt: "",
|
|
@@ -2307,8 +2534,8 @@ var Fi = X({
|
|
|
2307
2534
|
onError: () => {
|
|
2308
2535
|
c.value = !0;
|
|
2309
2536
|
}
|
|
2310
|
-
}) :
|
|
2311
|
-
return
|
|
2537
|
+
}) : U("b", null, m.value.slice(0, 1).toUpperCase());
|
|
2538
|
+
return U(s, {
|
|
2312
2539
|
as: "article",
|
|
2313
2540
|
class: "markweave-link-card",
|
|
2314
2541
|
"data-testid": "markweave-link-card",
|
|
@@ -2322,32 +2549,32 @@ var Fi = X({
|
|
|
2322
2549
|
a.value = !1;
|
|
2323
2550
|
},
|
|
2324
2551
|
onMousedown: (e) => {
|
|
2325
|
-
|
|
2552
|
+
zi(e.target) || e.preventDefault();
|
|
2326
2553
|
},
|
|
2327
2554
|
onClick: (e) => {
|
|
2328
|
-
|
|
2555
|
+
zi(e.target) || (e.preventDefault(), n.href && window.open(n.href, "_blank", "noopener,noreferrer"));
|
|
2329
2556
|
}
|
|
2330
2557
|
}, () => [
|
|
2331
|
-
|
|
2558
|
+
U("a", {
|
|
2332
2559
|
class: "markweave-link-card-main",
|
|
2333
2560
|
href: n.href,
|
|
2334
2561
|
"aria-label": r.linkCard.open
|
|
2335
|
-
}, [
|
|
2336
|
-
|
|
2337
|
-
n.description ?
|
|
2338
|
-
|
|
2339
|
-
]),
|
|
2562
|
+
}, [U("span", { class: "markweave-link-card-copy" }, [
|
|
2563
|
+
U("strong", null, n.title),
|
|
2564
|
+
n.description ? U("span", null, n.description) : null,
|
|
2565
|
+
U("small", null, n.siteName ?? m.value)
|
|
2566
|
+
]), U("span", {
|
|
2340
2567
|
class: "markweave-link-card-media",
|
|
2341
2568
|
"aria-hidden": "true"
|
|
2342
2569
|
}, [i])]),
|
|
2343
|
-
p.value
|
|
2570
|
+
p.value ? U("div", {
|
|
2344
2571
|
class: "markweave-link-card-tools",
|
|
2345
2572
|
"data-markweave-link-card-ui": "true",
|
|
2346
2573
|
"aria-label": r.linkCard.toolsAriaLabel
|
|
2347
2574
|
}, [
|
|
2348
|
-
C(r.linkCard.convertToLink,
|
|
2349
|
-
C(r.linkCard.copyAddress,
|
|
2350
|
-
C(r.linkCard.edit,
|
|
2575
|
+
C(r.linkCard.convertToLink, ii, "markweave-link-card-convert", x),
|
|
2576
|
+
C(r.linkCard.copyAddress, Gr, "markweave-link-card-copy", () => b(n.href)),
|
|
2577
|
+
C(r.linkCard.edit, fi, "markweave-link-card-edit", (i) => g({
|
|
2351
2578
|
anchor: i.currentTarget,
|
|
2352
2579
|
editor: e.editor,
|
|
2353
2580
|
messages: r,
|
|
@@ -2357,15 +2584,15 @@ var Fi = X({
|
|
|
2357
2584
|
attrs: n
|
|
2358
2585
|
}
|
|
2359
2586
|
})),
|
|
2360
|
-
C(r.linkCard.delete,
|
|
2587
|
+
C(r.linkCard.delete, ki, "markweave-link-card-delete", () => e.deleteNode())
|
|
2361
2588
|
]) : null,
|
|
2362
|
-
p.value && o.value ?
|
|
2589
|
+
p.value && o.value ? U("form", {
|
|
2363
2590
|
class: "markweave-link-card-editor",
|
|
2364
2591
|
"data-markweave-link-card-ui": "true",
|
|
2365
2592
|
"data-testid": "markweave-link-card-editor",
|
|
2366
2593
|
onSubmit: S
|
|
2367
2594
|
}, [
|
|
2368
|
-
|
|
2595
|
+
U("label", null, [U("span", null, r.linkCard.titleLabel), U("input", {
|
|
2369
2596
|
value: u.value,
|
|
2370
2597
|
placeholder: r.linkCard.titlePlaceholder,
|
|
2371
2598
|
"aria-label": r.linkCard.titleLabel,
|
|
@@ -2373,7 +2600,7 @@ var Fi = X({
|
|
|
2373
2600
|
u.value = e.target.value;
|
|
2374
2601
|
}
|
|
2375
2602
|
})]),
|
|
2376
|
-
|
|
2603
|
+
U("label", null, [U("span", null, r.linkCard.addressLabel), U("input", {
|
|
2377
2604
|
value: f.value,
|
|
2378
2605
|
placeholder: r.linkCard.addressPlaceholder,
|
|
2379
2606
|
"aria-label": r.linkCard.addressLabel,
|
|
@@ -2381,16 +2608,16 @@ var Fi = X({
|
|
|
2381
2608
|
f.value = e.target.value;
|
|
2382
2609
|
}
|
|
2383
2610
|
})]),
|
|
2384
|
-
|
|
2611
|
+
U("button", {
|
|
2385
2612
|
type: "submit",
|
|
2386
2613
|
disabled: !v(f.value),
|
|
2387
2614
|
"aria-label": r.linkCard.edit
|
|
2388
|
-
}, [
|
|
2615
|
+
}, [Bi(ii, r.linkCard.edit)])
|
|
2389
2616
|
]) : null
|
|
2390
2617
|
]);
|
|
2391
2618
|
};
|
|
2392
2619
|
}
|
|
2393
|
-
}),
|
|
2620
|
+
}), $i = h.extend({
|
|
2394
2621
|
addOptions() {
|
|
2395
2622
|
return {
|
|
2396
2623
|
...this.parent?.(),
|
|
@@ -2399,33 +2626,36 @@ var Fi = X({
|
|
|
2399
2626
|
};
|
|
2400
2627
|
},
|
|
2401
2628
|
addNodeView() {
|
|
2402
|
-
return typeof document > "u" ? null : c(
|
|
2629
|
+
return typeof document > "u" ? null : c(Qi, { stopEvent: ({ event: e }) => zi(e.target) });
|
|
2403
2630
|
}
|
|
2404
2631
|
});
|
|
2405
2632
|
//#endregion
|
|
2406
2633
|
//#region src/create-editor-extensions.ts
|
|
2407
|
-
function
|
|
2634
|
+
function ea(t = {}) {
|
|
2408
2635
|
return e({
|
|
2409
2636
|
lang: t.lang,
|
|
2410
2637
|
onImageUpload: t.onImageUpload,
|
|
2411
|
-
linkCardExtension:
|
|
2638
|
+
linkCardExtension: $i.configure({
|
|
2412
2639
|
lang: t.lang,
|
|
2413
2640
|
messages: n(t.lang),
|
|
2414
2641
|
resolver: t.linkCardResolver
|
|
2415
2642
|
}),
|
|
2416
2643
|
mediaExtensions: i({
|
|
2417
|
-
image:
|
|
2418
|
-
video:
|
|
2644
|
+
image: Ki,
|
|
2645
|
+
video: qi,
|
|
2646
|
+
attachment: Zi,
|
|
2419
2647
|
lang: t.lang,
|
|
2420
2648
|
onImageUpload: t.onImageUpload,
|
|
2421
2649
|
onVideoUpload: t.onVideoUpload,
|
|
2650
|
+
onAttachmentUpload: t.onAttachmentUpload,
|
|
2651
|
+
onAttachmentDownload: t.onAttachmentDownload,
|
|
2422
2652
|
resolveMediaSource: t.resolveMediaSource
|
|
2423
2653
|
})
|
|
2424
2654
|
});
|
|
2425
2655
|
}
|
|
2426
2656
|
//#endregion
|
|
2427
2657
|
//#region src/MarkweaveEditor.ts
|
|
2428
|
-
var
|
|
2658
|
+
var ta = {
|
|
2429
2659
|
active: !1,
|
|
2430
2660
|
mode: "outside",
|
|
2431
2661
|
activeCellPos: null,
|
|
@@ -2433,17 +2663,17 @@ var Hi = {
|
|
|
2433
2663
|
selectedCellCount: 0,
|
|
2434
2664
|
selectionFrom: 0,
|
|
2435
2665
|
selectionTo: 0
|
|
2436
|
-
},
|
|
2666
|
+
}, na = {
|
|
2437
2667
|
active: !1,
|
|
2438
|
-
language:
|
|
2668
|
+
language: ct.defaultLanguage,
|
|
2439
2669
|
mermaidPreviewMode: "code",
|
|
2440
2670
|
pos: null,
|
|
2441
2671
|
text: ""
|
|
2442
2672
|
};
|
|
2443
|
-
function
|
|
2444
|
-
return
|
|
2673
|
+
function ra(e) {
|
|
2674
|
+
return Cn.getState(e.state) ?? Sn;
|
|
2445
2675
|
}
|
|
2446
|
-
function
|
|
2676
|
+
function ia(e) {
|
|
2447
2677
|
if (!e || typeof window > "u") return null;
|
|
2448
2678
|
let t = e.parentElement;
|
|
2449
2679
|
for (; t;) {
|
|
@@ -2454,133 +2684,133 @@ function Gi(e) {
|
|
|
2454
2684
|
return null;
|
|
2455
2685
|
}
|
|
2456
2686
|
function Q(e, t, n = 18, r = 1.8) {
|
|
2457
|
-
return
|
|
2687
|
+
return U(e, {
|
|
2458
2688
|
size: n,
|
|
2459
2689
|
strokeWidth: r,
|
|
2460
2690
|
"aria-hidden": "true"
|
|
2461
2691
|
}, { default: () => t });
|
|
2462
2692
|
}
|
|
2463
|
-
function
|
|
2464
|
-
return e === "clipboard" ? [
|
|
2693
|
+
function aa(e) {
|
|
2694
|
+
return e === "clipboard" ? [U("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" }), U("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" ? [U("circle", {
|
|
2465
2695
|
cx: "10",
|
|
2466
2696
|
cy: "10",
|
|
2467
2697
|
r: "5.5"
|
|
2468
|
-
}),
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2698
|
+
}), U("path", { d: "m14 14 4 4" })] : e === "check" ? [U("path", { d: "m5 11 4 4 8-9" })] : e === "expand" ? [
|
|
2699
|
+
U("path", { d: "M8 4H4v4" }),
|
|
2700
|
+
U("path", { d: "M4 4l5 5" }),
|
|
2701
|
+
U("path", { d: "M16 4h4v4" }),
|
|
2702
|
+
U("path", { d: "m20 4-5 5" }),
|
|
2703
|
+
U("path", { d: "M8 20H4v-4" }),
|
|
2704
|
+
U("path", { d: "m4 20 5-5" }),
|
|
2705
|
+
U("path", { d: "M16 20h4v-4" }),
|
|
2706
|
+
U("path", { d: "m20 20-5-5" })
|
|
2477
2707
|
] : e === "download" ? [
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
] : e === "close" ? [
|
|
2482
|
-
|
|
2708
|
+
U("path", { d: "M12 4v10" }),
|
|
2709
|
+
U("path", { d: "m8 10 4 4 4-4" }),
|
|
2710
|
+
U("path", { d: "M5 19h14" })
|
|
2711
|
+
] : e === "close" ? [U("path", { d: "M6 6l12 12" }), U("path", { d: "M18 6 6 18" })] : e === "zoomOut" ? [
|
|
2712
|
+
U("circle", {
|
|
2483
2713
|
cx: "10",
|
|
2484
2714
|
cy: "10",
|
|
2485
2715
|
r: "5.25"
|
|
2486
2716
|
}),
|
|
2487
|
-
|
|
2488
|
-
|
|
2717
|
+
U("path", { d: "M7.5 10h5" }),
|
|
2718
|
+
U("path", { d: "m14 14 4 4" })
|
|
2489
2719
|
] : e === "zoomIn" ? [
|
|
2490
|
-
|
|
2720
|
+
U("circle", {
|
|
2491
2721
|
cx: "10",
|
|
2492
2722
|
cy: "10",
|
|
2493
2723
|
r: "5.25"
|
|
2494
2724
|
}),
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
] : e === "reset" ? [
|
|
2725
|
+
U("path", { d: "M7.5 10h5" }),
|
|
2726
|
+
U("path", { d: "M10 7.5v5" }),
|
|
2727
|
+
U("path", { d: "m14 14 4 4" })
|
|
2728
|
+
] : e === "reset" ? [U("path", { d: "M6.5 8.5A6 6 0 1 1 6 15" }), U("path", { d: "M6.5 8.5H3.5v-3" })] : [U("path", { d: "m6 9 6 6 6-6" })];
|
|
2499
2729
|
}
|
|
2500
|
-
function
|
|
2501
|
-
return
|
|
2730
|
+
function oa(e) {
|
|
2731
|
+
return U("svg", {
|
|
2502
2732
|
viewBox: "0 0 24 24",
|
|
2503
2733
|
"aria-hidden": "true",
|
|
2504
2734
|
focusable: "false"
|
|
2505
|
-
},
|
|
2735
|
+
}, U("g", {
|
|
2506
2736
|
fill: "none",
|
|
2507
2737
|
stroke: "currentColor",
|
|
2508
2738
|
"stroke-linecap": "round",
|
|
2509
2739
|
"stroke-linejoin": "round",
|
|
2510
2740
|
"stroke-width": "1.8"
|
|
2511
|
-
},
|
|
2741
|
+
}, aa(e)));
|
|
2512
2742
|
}
|
|
2513
2743
|
function $(e) {
|
|
2514
2744
|
e.preventDefault();
|
|
2515
2745
|
}
|
|
2516
|
-
function
|
|
2517
|
-
let t =
|
|
2746
|
+
function sa(e) {
|
|
2747
|
+
let t = zt(e);
|
|
2518
2748
|
return !t || typeof window > "u" || typeof window.open != "function" ? !1 : (window.open(t, "_blank", "noopener,noreferrer"), !0);
|
|
2519
2749
|
}
|
|
2520
|
-
var
|
|
2521
|
-
bold:
|
|
2522
|
-
italic:
|
|
2523
|
-
underline:
|
|
2524
|
-
strike:
|
|
2525
|
-
"inline-code":
|
|
2526
|
-
link:
|
|
2527
|
-
more:
|
|
2528
|
-
superscript:
|
|
2529
|
-
subscript:
|
|
2530
|
-
"inline-math":
|
|
2531
|
-
"align-left":
|
|
2532
|
-
"align-center":
|
|
2533
|
-
"align-right":
|
|
2534
|
-
"align-justify":
|
|
2535
|
-
"decrease-indent":
|
|
2536
|
-
"increase-indent":
|
|
2537
|
-
},
|
|
2538
|
-
type:
|
|
2539
|
-
"heading-1":
|
|
2540
|
-
"heading-2":
|
|
2541
|
-
"heading-3":
|
|
2542
|
-
"bullet-list":
|
|
2543
|
-
"ordered-list":
|
|
2544
|
-
"task-list":
|
|
2545
|
-
blockquote:
|
|
2546
|
-
"code-block":
|
|
2547
|
-
info:
|
|
2548
|
-
tip:
|
|
2549
|
-
warning:
|
|
2550
|
-
error:
|
|
2551
|
-
success:
|
|
2552
|
-
emoji:
|
|
2553
|
-
math:
|
|
2554
|
-
table:
|
|
2555
|
-
separator:
|
|
2556
|
-
image:
|
|
2557
|
-
video:
|
|
2558
|
-
attachment:
|
|
2750
|
+
var ca = {
|
|
2751
|
+
bold: Nr,
|
|
2752
|
+
italic: ni,
|
|
2753
|
+
underline: ji,
|
|
2754
|
+
strike: Si,
|
|
2755
|
+
"inline-code": Hr,
|
|
2756
|
+
link: ii,
|
|
2757
|
+
more: li,
|
|
2758
|
+
superscript: wi,
|
|
2759
|
+
subscript: Ci,
|
|
2760
|
+
"inline-math": _i,
|
|
2761
|
+
"align-left": _r,
|
|
2762
|
+
"align-center": hr,
|
|
2763
|
+
"align-right": vr,
|
|
2764
|
+
"align-justify": gr,
|
|
2765
|
+
"decrease-indent": $r,
|
|
2766
|
+
"increase-indent": ei
|
|
2767
|
+
}, la = {
|
|
2768
|
+
type: Oi,
|
|
2769
|
+
"heading-1": Jr,
|
|
2770
|
+
"heading-2": Yr,
|
|
2771
|
+
"heading-3": Xr,
|
|
2772
|
+
"bullet-list": ai,
|
|
2773
|
+
"ordered-list": si,
|
|
2774
|
+
"task-list": oi,
|
|
2775
|
+
blockquote: mi,
|
|
2776
|
+
"code-block": Pr,
|
|
2777
|
+
info: ti,
|
|
2778
|
+
tip: ri,
|
|
2779
|
+
warning: Sr,
|
|
2780
|
+
error: Vr,
|
|
2781
|
+
success: Lr,
|
|
2782
|
+
emoji: vi,
|
|
2783
|
+
math: _i,
|
|
2784
|
+
table: Ti,
|
|
2785
|
+
separator: ci,
|
|
2786
|
+
image: Zr,
|
|
2787
|
+
video: Ni,
|
|
2788
|
+
attachment: di
|
|
2559
2789
|
};
|
|
2560
|
-
function
|
|
2561
|
-
let t =
|
|
2562
|
-
return
|
|
2790
|
+
function ua(e) {
|
|
2791
|
+
let t = la[e];
|
|
2792
|
+
return U(t, {
|
|
2563
2793
|
size: 18,
|
|
2564
2794
|
strokeWidth: 1.6,
|
|
2565
2795
|
absoluteStrokeWidth: !0,
|
|
2566
2796
|
"aria-hidden": "true"
|
|
2567
2797
|
});
|
|
2568
2798
|
}
|
|
2569
|
-
var
|
|
2570
|
-
paragraph:
|
|
2571
|
-
"heading-1":
|
|
2572
|
-
"heading-2":
|
|
2573
|
-
"heading-3":
|
|
2574
|
-
"bullet-list":
|
|
2575
|
-
"numbered-list":
|
|
2576
|
-
"todo-list":
|
|
2577
|
-
quote:
|
|
2578
|
-
"code-block":
|
|
2799
|
+
var da = {
|
|
2800
|
+
paragraph: Ai,
|
|
2801
|
+
"heading-1": Jr,
|
|
2802
|
+
"heading-2": Yr,
|
|
2803
|
+
"heading-3": Xr,
|
|
2804
|
+
"bullet-list": ai,
|
|
2805
|
+
"numbered-list": si,
|
|
2806
|
+
"todo-list": oi,
|
|
2807
|
+
quote: mi,
|
|
2808
|
+
"code-block": Pr
|
|
2579
2809
|
};
|
|
2580
|
-
function
|
|
2581
|
-
return
|
|
2810
|
+
function fa(e, t) {
|
|
2811
|
+
return pe(e, t).label;
|
|
2582
2812
|
}
|
|
2583
|
-
var
|
|
2813
|
+
var pa = X({
|
|
2584
2814
|
name: "MarkweaveVueFloatingToolbar",
|
|
2585
2815
|
props: {
|
|
2586
2816
|
editor: {
|
|
@@ -2605,73 +2835,73 @@ var ea = X({
|
|
|
2605
2835
|
}
|
|
2606
2836
|
},
|
|
2607
2837
|
setup(e) {
|
|
2608
|
-
let t =
|
|
2838
|
+
let t = W(null), n = W("input"), r = W(""), i = W(""), a = W(""), o = W(""), s = G(null), c = G(null), l = W(null), u = W(null), d = "", f = K(() => e.askAi?.enabled === !0 && typeof e.askAi.handler == "function"), p = W(""), m = W(null), h = W(null), g = W("bottom"), _ = W(null), v = W(null), y = W(null), b = K(() => zt(p.value.trim())), x = K(() => e.messages.floatingToolbar), S = K(() => _e(e.messages).map((e) => [
|
|
2609
2839
|
e.id,
|
|
2610
2840
|
e.label,
|
|
2611
|
-
|
|
2612
|
-
])), C =
|
|
2841
|
+
da[e.id]
|
|
2842
|
+
])), C = K(() => ge(e.messages).map((e) => [
|
|
2613
2843
|
e.id,
|
|
2614
2844
|
e.value,
|
|
2615
2845
|
e.label
|
|
2616
|
-
])), w =
|
|
2846
|
+
])), w = K(() => me(e.messages).map((e) => [
|
|
2617
2847
|
e.id,
|
|
2618
2848
|
e.value,
|
|
2619
2849
|
e.label
|
|
2620
|
-
])), T =
|
|
2850
|
+
])), T = K(() => he(e.messages).map((e) => e.id)), E = () => {
|
|
2621
2851
|
b.value && (e.editor.chain().focus().extendMarkRange("link").setLink({ href: b.value }).run(), t.value = null);
|
|
2622
2852
|
}, D = () => {
|
|
2623
2853
|
e.editor.isActive("link") && e.editor.chain().focus().extendMarkRange("link").unsetLink().run(), p.value = "", t.value = null;
|
|
2624
2854
|
}, O = (n) => {
|
|
2625
2855
|
t.value = t.value === n ? null : n, n === "link" && (p.value = e.editor.getAttributes("link").href ?? "");
|
|
2626
|
-
}, k =
|
|
2627
|
-
|
|
2856
|
+
}, k = se(() => {
|
|
2857
|
+
Ge(e.editor, d), a.value = d;
|
|
2628
2858
|
}), A = (n = !0) => {
|
|
2629
|
-
c.value?.abort(), k.cancel(), d = "", c.value = null, l.value = null, n &&
|
|
2859
|
+
c.value?.abort(), k.cancel(), d = "", c.value = null, l.value = null, n && Ue(e.editor), Fe(e.editor), t.value = null, n && e.editor.commands.focus();
|
|
2630
2860
|
}, j = () => {
|
|
2631
2861
|
if (!f.value) return;
|
|
2632
|
-
let r =
|
|
2862
|
+
let r = qe(e.editor);
|
|
2633
2863
|
r && (s.value = r, n.value = "input", a.value = "", o.value = "", i.value = "", t.value = "ask-ai", Y(() => u.value?.focus()));
|
|
2634
|
-
},
|
|
2864
|
+
}, ee = async (t) => {
|
|
2635
2865
|
if (!f.value || e.askAi?.enabled !== !0 || !s.value) return;
|
|
2636
2866
|
let u = (t ?? r.value).trim();
|
|
2637
2867
|
if (!u) {
|
|
2638
2868
|
o.value = e.messages.askAi.emptyPrompt, n.value = "error";
|
|
2639
2869
|
return;
|
|
2640
2870
|
}
|
|
2641
|
-
let p =
|
|
2871
|
+
let p = Le(e.editor, s.value);
|
|
2642
2872
|
if (!p) {
|
|
2643
2873
|
n.value = "conflict";
|
|
2644
2874
|
return;
|
|
2645
2875
|
}
|
|
2646
|
-
s.value = p, c.value?.abort(),
|
|
2647
|
-
let m = new AbortController(), h =
|
|
2876
|
+
s.value = p, c.value?.abort(), Pe(e.editor);
|
|
2877
|
+
let m = new AbortController(), h = Ie(p, u, e.lang, m.signal, void 0, ze(e.editor)?.target);
|
|
2648
2878
|
c.value = m, l.value = h.id, i.value = u, k.cancel(), d = "", a.value = "", o.value = "", n.value = "generating";
|
|
2649
2879
|
try {
|
|
2650
|
-
let t = await
|
|
2880
|
+
let t = await We(e.askAi.handler, h, (e) => {
|
|
2651
2881
|
l.value === h.id && !m.signal.aborted && (d = e, k.schedule());
|
|
2652
2882
|
});
|
|
2653
2883
|
if (l.value !== h.id || m.signal.aborted) return;
|
|
2654
|
-
if (k.cancel(), d = t, !
|
|
2655
|
-
a.value = t, r.value = "", n.value =
|
|
2884
|
+
if (k.cancel(), d = t, !Ge(e.editor, t)) throw new Ae("invalid-output", "Ask AI output is incompatible with the selected content.");
|
|
2885
|
+
a.value = t, r.value = "", n.value = ze(e.editor)?.status === "target" ? "result" : "conflict";
|
|
2656
2886
|
} catch (t) {
|
|
2657
2887
|
if (l.value !== h.id) return;
|
|
2658
2888
|
if (k.cancel(), m.signal.aborted) {
|
|
2659
|
-
|
|
2889
|
+
Pe(e.editor), n.value = ze(e.editor)?.status === "conflict" ? "conflict" : "input";
|
|
2660
2890
|
return;
|
|
2661
2891
|
}
|
|
2662
|
-
|
|
2892
|
+
Pe(e.editor), o.value = t instanceof Ae ? t.code === "empty-result" ? e.messages.askAi.emptyResult : e.messages.askAi.errorFallback : t instanceof Error && t.message ? t.message : e.messages.askAi.errorFallback, n.value = "error";
|
|
2663
2893
|
}
|
|
2664
|
-
},
|
|
2665
|
-
if (!
|
|
2666
|
-
n.value =
|
|
2894
|
+
}, te = () => {
|
|
2895
|
+
if (!je(e.editor, a.value)) {
|
|
2896
|
+
n.value = ze(e.editor)?.status === "conflict" ? "conflict" : "error", o.value = e.messages.askAi.errorFallback;
|
|
2667
2897
|
return;
|
|
2668
2898
|
}
|
|
2669
|
-
t.value = null, window.setTimeout(() =>
|
|
2670
|
-
},
|
|
2899
|
+
t.value = null, window.setTimeout(() => Fe(e.editor), 560), e.editor.commands.focus();
|
|
2900
|
+
}, M = se(() => {
|
|
2671
2901
|
let n = _.value, r = y.value, i = e.editor.view.dom.closest(".markweave-editor-frame");
|
|
2672
2902
|
if (!t.value || !n || !r) return;
|
|
2673
2903
|
if (t.value === "ask-ai") {
|
|
2674
|
-
let t =
|
|
2904
|
+
let t = Be(e.editor), n = v.value?.getBoundingClientRect();
|
|
2675
2905
|
if (!t || !n) return;
|
|
2676
2906
|
let a = {
|
|
2677
2907
|
anchorRect: n,
|
|
@@ -2681,18 +2911,18 @@ var ea = X({
|
|
|
2681
2911
|
height: window.innerHeight
|
|
2682
2912
|
},
|
|
2683
2913
|
frameRect: i?.getBoundingClientRect() ?? null,
|
|
2684
|
-
surfaceRect:
|
|
2685
|
-
}, o =
|
|
2914
|
+
surfaceRect: Re(e.editor.view.dom)
|
|
2915
|
+
}, o = Me({
|
|
2686
2916
|
...a,
|
|
2687
2917
|
panelSize: r.getBoundingClientRect()
|
|
2688
2918
|
}), s = `${o.width}px`;
|
|
2689
|
-
r.style.width !== s && (r.style.width = s, o =
|
|
2919
|
+
r.style.width !== s && (r.style.width = s, o = Me({
|
|
2690
2920
|
...a,
|
|
2691
2921
|
panelSize: r.getBoundingClientRect()
|
|
2692
2922
|
})), r.style.left = `${o.left}px`, r.style.top = `${o.top}px`, r.style.bottom = "auto", r.style.maxWidth = `${o.maxWidth}px`, r.style.maxHeight = `${Math.max(0, o.maxHeight)}px`, r.dataset.positioned = "true", g.value = o.placement;
|
|
2693
2923
|
return;
|
|
2694
2924
|
}
|
|
2695
|
-
let a =
|
|
2925
|
+
let a = Ce({
|
|
2696
2926
|
toolbarRect: n.getBoundingClientRect(),
|
|
2697
2927
|
popoverSize: r.getBoundingClientRect(),
|
|
2698
2928
|
viewport: {
|
|
@@ -2703,16 +2933,16 @@ var ea = X({
|
|
|
2703
2933
|
gap: t.value === "more" ? 8 : 6
|
|
2704
2934
|
});
|
|
2705
2935
|
g.value = a.placement;
|
|
2706
|
-
}),
|
|
2707
|
-
let l =
|
|
2936
|
+
}), N = () => {
|
|
2937
|
+
let l = ze(e.editor);
|
|
2708
2938
|
if (l?.target.kind === "table" && l.status === "target" && t.value !== "ask-ai") {
|
|
2709
2939
|
s.value = l.selection, n.value = "input", r.value = "", a.value = "", o.value = "", i.value = "", t.value = "ask-ai", Y(() => u.value?.focus());
|
|
2710
2940
|
return;
|
|
2711
2941
|
}
|
|
2712
2942
|
t.value === "ask-ai" && l?.status === "conflict" && (c.value?.abort(), k.cancel(), n.value = "conflict");
|
|
2713
|
-
},
|
|
2943
|
+
}, P = (e) => {
|
|
2714
2944
|
e.key !== "Escape" || t.value !== "ask-ai" || (e.preventDefault(), n.value === "generating" ? (c.value?.abort(), k.cancel(), n.value = "input") : A(!0));
|
|
2715
|
-
},
|
|
2945
|
+
}, F = (e) => {
|
|
2716
2946
|
if (!(!t.value || v.value?.contains(e.target))) {
|
|
2717
2947
|
if (t.value === "ask-ai") {
|
|
2718
2948
|
A(!0);
|
|
@@ -2721,38 +2951,38 @@ var ea = X({
|
|
|
2721
2951
|
t.value = null;
|
|
2722
2952
|
}
|
|
2723
2953
|
};
|
|
2724
|
-
|
|
2954
|
+
q(() => [
|
|
2725
2955
|
t.value,
|
|
2726
2956
|
n.value,
|
|
2727
2957
|
a.value,
|
|
2728
2958
|
o.value
|
|
2729
2959
|
], ([e]) => {
|
|
2730
|
-
e && Y(
|
|
2731
|
-
}),
|
|
2732
|
-
window.addEventListener("resize",
|
|
2733
|
-
}),
|
|
2734
|
-
|
|
2960
|
+
e && Y(M.schedule);
|
|
2961
|
+
}), fr(() => {
|
|
2962
|
+
window.addEventListener("resize", M.schedule), window.addEventListener("scroll", M.schedule, !0), e.editor.on("transaction", N), document.addEventListener("pointerdown", F, !0), document.addEventListener("keydown", P, !0);
|
|
2963
|
+
}), J(() => {
|
|
2964
|
+
M.cancel(), k.cancel(), window.removeEventListener("resize", M.schedule), window.removeEventListener("scroll", M.schedule, !0), e.editor.off("transaction", N), document.removeEventListener("pointerdown", F, !0), document.removeEventListener("keydown", P, !0), c.value?.abort(), Fe(e.editor);
|
|
2735
2965
|
});
|
|
2736
|
-
let
|
|
2966
|
+
let I = (n) => n === "block-type" || n === "color" || n === "more" ? t.value === n : n === "bold" ? e.editor.isActive("bold") : n === "italic" ? e.editor.isActive("italic") : n === "underline" ? e.editor.isActive("underline") : n === "strike" ? e.editor.isActive("strike") : n === "inline-code" ? e.editor.isActive("code") : n === "link" ? e.editor.isActive("link") : !1, L = (e, t) => {
|
|
2737
2967
|
if (m.value = e, !e || !(t instanceof HTMLElement) || !v.value) {
|
|
2738
2968
|
h.value = null;
|
|
2739
2969
|
return;
|
|
2740
2970
|
}
|
|
2741
2971
|
let n = t.getBoundingClientRect(), r = v.value.getBoundingClientRect();
|
|
2742
2972
|
h.value = n.left + n.width / 2 - r.left;
|
|
2743
|
-
},
|
|
2973
|
+
}, R = () => {
|
|
2744
2974
|
let e = m.value;
|
|
2745
2975
|
if (!e || t.value !== null) return null;
|
|
2746
2976
|
let n = x.value.buttons[e];
|
|
2747
|
-
return n ?
|
|
2977
|
+
return n ? U("div", {
|
|
2748
2978
|
class: "markweave-floating-toolbar-tooltip",
|
|
2749
2979
|
role: "tooltip",
|
|
2750
2980
|
"data-testid": "markweave-floating-toolbar-tooltip",
|
|
2751
2981
|
"data-button-id": e,
|
|
2752
|
-
"data-active":
|
|
2982
|
+
"data-active": I(e),
|
|
2753
2983
|
style: h.value === null ? void 0 : { "--markweave-floating-toolbar-tooltip-left": `${h.value}px` }
|
|
2754
2984
|
}, n) : null;
|
|
2755
|
-
},
|
|
2985
|
+
}, z = (n, r, i, a, o = !1, s) => U("button", {
|
|
2756
2986
|
type: "button",
|
|
2757
2987
|
class: `markweave-floating-toolbar-button markweave-floating-toolbar-button--${n}`,
|
|
2758
2988
|
"aria-label": r,
|
|
@@ -2766,19 +2996,19 @@ var ea = X({
|
|
|
2766
2996
|
"data-active": o || t.value === n,
|
|
2767
2997
|
"data-tooltip-active": m.value === n ? "true" : "false",
|
|
2768
2998
|
"data-testid": `markweave-floating-toolbar-button-${n}`,
|
|
2769
|
-
onBlur: () =>
|
|
2770
|
-
onFocus: (e) =>
|
|
2999
|
+
onBlur: () => L(null),
|
|
3000
|
+
onFocus: (e) => L(n, e.currentTarget),
|
|
2771
3001
|
onMousedown: $,
|
|
2772
|
-
onMouseenter: (e) =>
|
|
2773
|
-
onMouseleave: () =>
|
|
3002
|
+
onMouseenter: (e) => L(n, e.currentTarget),
|
|
3003
|
+
onMouseleave: () => L(null),
|
|
2774
3004
|
onClick: a
|
|
2775
|
-
}, n === "ask-ai" ? [
|
|
3005
|
+
}, n === "ask-ai" ? [U("span", { class: "markweave-floating-toolbar-button-inner" }, [Q(i, r), U("span", null, s ?? r)])] : n === "block-type" ? [U("span", { class: "markweave-floating-toolbar-button-inner" }, [U("span", { class: "markweave-floating-toolbar-block-label" }, fa(e.editor, e.messages)), Q(t.value === "block-type" ? Br : Rr, r)])] : n === "color" ? [U("span", { class: "markweave-floating-toolbar-button-inner markweave-floating-toolbar-button-inner--color" }, [U("span", { class: "markweave-floating-toolbar-color-trigger" }, "A"), Q(t.value === "color" ? Br : Rr, r)])] : [Q(i, r)]), B = () => U("span", {
|
|
2776
3006
|
class: "markweave-floating-toolbar-divider",
|
|
2777
3007
|
"aria-hidden": "true"
|
|
2778
|
-
}),
|
|
3008
|
+
}), V = (n, r, i) => U("section", {
|
|
2779
3009
|
class: "markweave-floating-toolbar-color-section",
|
|
2780
3010
|
"aria-label": n
|
|
2781
|
-
}, [
|
|
3011
|
+
}, [U("div", { class: "markweave-floating-toolbar-menu-title" }, n), U("div", { class: "markweave-floating-toolbar-swatch-grid" }, i.map(([n, i, a]) => U("button", {
|
|
2782
3012
|
key: `${r}-${n}`,
|
|
2783
3013
|
type: "button",
|
|
2784
3014
|
"aria-label": a,
|
|
@@ -2787,24 +3017,24 @@ var ea = X({
|
|
|
2787
3017
|
onClick: () => {
|
|
2788
3018
|
r === "text" ? i ? e.editor.chain().focus().setColor(i).run() : e.editor.chain().focus().unsetColor().run() : i ? e.editor.chain().focus().toggleHighlight({ color: i }).run() : e.editor.chain().focus().unsetHighlight().run(), t.value = null;
|
|
2789
3019
|
}
|
|
2790
|
-
}, r === "text" ? [
|
|
3020
|
+
}, r === "text" ? [U("span", {
|
|
2791
3021
|
class: "markweave-floating-toolbar-text-swatch",
|
|
2792
3022
|
style: { color: i ?? "#646970" }
|
|
2793
|
-
}, "A")] : [
|
|
3023
|
+
}, "A")] : [U("span", {
|
|
2794
3024
|
class: "markweave-floating-toolbar-highlight-swatch",
|
|
2795
3025
|
style: { backgroundColor: i ?? "#ffffff" },
|
|
2796
3026
|
"aria-hidden": "true"
|
|
2797
|
-
})])))]),
|
|
3027
|
+
})])))]), H = () => {
|
|
2798
3028
|
if (t.value === "ask-ai") {
|
|
2799
|
-
let t = (e, t, n, r) =>
|
|
3029
|
+
let t = (e, t, n, r) => U("button", {
|
|
2800
3030
|
type: "button",
|
|
2801
3031
|
class: n,
|
|
2802
3032
|
onMousedown: $,
|
|
2803
3033
|
onClick: t
|
|
2804
|
-
}, r ? [Q(r, e),
|
|
3034
|
+
}, r ? [Q(r, e), U("span", null, e)] : e), s = n.value === "input" || n.value === "result" || n.value === "error" ? U("div", {
|
|
2805
3035
|
class: "markweave-ask-ai-composer",
|
|
2806
3036
|
"data-variant": n.value === "result" ? "follow-up" : "prompt"
|
|
2807
|
-
}, [
|
|
3037
|
+
}, [U("textarea", {
|
|
2808
3038
|
ref: u,
|
|
2809
3039
|
class: "markweave-ask-ai-input",
|
|
2810
3040
|
rows: 2,
|
|
@@ -2815,19 +3045,19 @@ var ea = X({
|
|
|
2815
3045
|
r.value = e.target.value;
|
|
2816
3046
|
},
|
|
2817
3047
|
onKeydown: (e) => {
|
|
2818
|
-
e.key === "Enter" && !e.shiftKey && !e.isComposing && (e.preventDefault(),
|
|
3048
|
+
e.key === "Enter" && !e.shiftKey && !e.isComposing && (e.preventDefault(), ee());
|
|
2819
3049
|
}
|
|
2820
|
-
}),
|
|
3050
|
+
}), U("button", {
|
|
2821
3051
|
type: "button",
|
|
2822
3052
|
class: "markweave-ask-ai-send",
|
|
2823
3053
|
"aria-label": e.messages.askAi.send,
|
|
2824
3054
|
disabled: !r.value.trim(),
|
|
2825
3055
|
onMousedown: $,
|
|
2826
3056
|
onClick: () => {
|
|
2827
|
-
|
|
3057
|
+
ee();
|
|
2828
3058
|
}
|
|
2829
|
-
}, [Q(
|
|
2830
|
-
return
|
|
3059
|
+
}, [Q(Dr, e.messages.askAi.send)])]) : null;
|
|
3060
|
+
return U("section", {
|
|
2831
3061
|
ref: y,
|
|
2832
3062
|
class: "markweave-floating-toolbar-popover markweave-ask-ai-popover",
|
|
2833
3063
|
"aria-label": e.messages.askAi.ariaLabel,
|
|
@@ -2835,65 +3065,65 @@ var ea = X({
|
|
|
2835
3065
|
"data-testid": "markweave-ask-ai-popover"
|
|
2836
3066
|
}, [
|
|
2837
3067
|
s,
|
|
2838
|
-
n.value === "generating" ?
|
|
3068
|
+
n.value === "generating" ? U("div", {
|
|
2839
3069
|
class: "markweave-ask-ai-progress markweave-ask-ai-generating",
|
|
2840
3070
|
role: "status"
|
|
2841
3071
|
}, [
|
|
2842
|
-
|
|
3072
|
+
U("span", {
|
|
2843
3073
|
class: "markweave-ask-ai-sparkles",
|
|
2844
3074
|
"aria-hidden": "true"
|
|
2845
|
-
}, [Q(
|
|
2846
|
-
|
|
2847
|
-
|
|
3075
|
+
}, [Q(yi, "")]),
|
|
3076
|
+
U("span", { class: "markweave-ask-ai-progress-label" }, a.value ? e.messages.askAi.streaming : e.messages.askAi.generating),
|
|
3077
|
+
U("button", {
|
|
2848
3078
|
type: "button",
|
|
2849
3079
|
class: "markweave-ask-ai-stop",
|
|
2850
3080
|
"aria-label": e.messages.askAi.stop,
|
|
2851
3081
|
onMousedown: $,
|
|
2852
3082
|
onClick: () => {
|
|
2853
|
-
c.value?.abort(), k.cancel(),
|
|
3083
|
+
c.value?.abort(), k.cancel(), Pe(e.editor), n.value = "input";
|
|
2854
3084
|
}
|
|
2855
|
-
}, [Q(
|
|
3085
|
+
}, [Q(bi, e.messages.askAi.stop)])
|
|
2856
3086
|
]) : null,
|
|
2857
|
-
n.value === "result" ?
|
|
3087
|
+
n.value === "result" ? U("div", { class: "markweave-ask-ai-action-bar" }, [
|
|
2858
3088
|
t(e.messages.askAi.retry, () => {
|
|
2859
|
-
|
|
2860
|
-
}, "markweave-ask-ai-retry",
|
|
2861
|
-
|
|
2862
|
-
t(e.messages.askAi.discard, () => A(!0), "markweave-ask-ai-discard",
|
|
2863
|
-
t(e.messages.askAi.accept,
|
|
3089
|
+
ee(i.value);
|
|
3090
|
+
}, "markweave-ask-ai-retry", gi),
|
|
3091
|
+
U("span", { class: "markweave-ask-ai-action-spacer" }),
|
|
3092
|
+
t(e.messages.askAi.discard, () => A(!0), "markweave-ask-ai-discard", Pi),
|
|
3093
|
+
t(e.messages.askAi.accept, te, "markweave-ask-ai-accept", Ir)
|
|
2864
3094
|
]) : null,
|
|
2865
|
-
n.value === "error" || n.value === "conflict" ?
|
|
3095
|
+
n.value === "error" || n.value === "conflict" ? U("div", {
|
|
2866
3096
|
class: "markweave-ask-ai-error",
|
|
2867
3097
|
role: "alert"
|
|
2868
|
-
}, [n.value === "conflict" ? e.messages.askAi.conflict : o.value || e.messages.askAi.errorFallback,
|
|
3098
|
+
}, [n.value === "conflict" ? e.messages.askAi.conflict : o.value || e.messages.askAi.errorFallback, U("div", { class: "markweave-ask-ai-action-bar" }, [
|
|
2869
3099
|
n.value === "error" ? t(e.messages.askAi.retry, () => {
|
|
2870
|
-
|
|
2871
|
-
}, "markweave-ask-ai-retry",
|
|
2872
|
-
|
|
2873
|
-
t(e.messages.askAi.discard, () => A(!0), "markweave-ask-ai-discard",
|
|
3100
|
+
ee(i.value);
|
|
3101
|
+
}, "markweave-ask-ai-retry", gi) : null,
|
|
3102
|
+
U("span", { class: "markweave-ask-ai-action-spacer" }),
|
|
3103
|
+
t(e.messages.askAi.discard, () => A(!0), "markweave-ask-ai-discard", Pi)
|
|
2874
3104
|
])]) : null
|
|
2875
3105
|
]);
|
|
2876
3106
|
}
|
|
2877
|
-
return t.value === "block-type" ?
|
|
3107
|
+
return t.value === "block-type" ? U("div", {
|
|
2878
3108
|
ref: y,
|
|
2879
3109
|
class: "markweave-floating-toolbar-popover markweave-floating-toolbar-turn-menu",
|
|
2880
3110
|
"data-testid": "markweave-floating-toolbar-turn-menu"
|
|
2881
|
-
}, [
|
|
3111
|
+
}, [U("div", { class: "markweave-floating-toolbar-menu-title" }, x.value.turnIntoTitle), ...S.value.map(([n, r, i]) => U("button", {
|
|
2882
3112
|
key: n,
|
|
2883
3113
|
type: "button",
|
|
2884
3114
|
"data-testid": `markweave-floating-toolbar-turn-${n}`,
|
|
2885
3115
|
onMousedown: $,
|
|
2886
3116
|
onClick: () => {
|
|
2887
|
-
|
|
3117
|
+
ye(e.editor, n), t.value = null;
|
|
2888
3118
|
}
|
|
2889
|
-
}, [
|
|
3119
|
+
}, [U("span", { class: "markweave-floating-toolbar-menu-icon" }, [Q(i, r)]), U("span", null, r)]))]) : t.value === "link" ? U("form", {
|
|
2890
3120
|
class: "markweave-floating-toolbar-popover markweave-floating-toolbar-link-popover",
|
|
2891
3121
|
ref: y,
|
|
2892
3122
|
"data-testid": "markweave-floating-toolbar-link-popover",
|
|
2893
3123
|
onSubmit: (e) => {
|
|
2894
3124
|
e.preventDefault(), E();
|
|
2895
3125
|
}
|
|
2896
|
-
}, [
|
|
3126
|
+
}, [U("input", {
|
|
2897
3127
|
value: p.value,
|
|
2898
3128
|
placeholder: x.value.linkPlaceholder,
|
|
2899
3129
|
"aria-label": x.value.linkUrlLabel,
|
|
@@ -2901,45 +3131,45 @@ var ea = X({
|
|
|
2901
3131
|
onInput: (e) => {
|
|
2902
3132
|
p.value = e.target.value;
|
|
2903
3133
|
}
|
|
2904
|
-
}),
|
|
2905
|
-
|
|
3134
|
+
}), U("span", { class: "markweave-floating-toolbar-link-actions" }, [
|
|
3135
|
+
U("button", {
|
|
2906
3136
|
type: "submit",
|
|
2907
3137
|
disabled: !b.value,
|
|
2908
3138
|
"aria-label": x.value.applyLink,
|
|
2909
3139
|
"data-testid": "markweave-floating-toolbar-link-apply",
|
|
2910
3140
|
onMousedown: $
|
|
2911
|
-
}, [Q(
|
|
2912
|
-
|
|
3141
|
+
}, [Q(Ur, x.value.applyLink)]),
|
|
3142
|
+
U("span", {
|
|
2913
3143
|
class: "markweave-floating-toolbar-link-divider",
|
|
2914
3144
|
"aria-hidden": "true"
|
|
2915
3145
|
}),
|
|
2916
|
-
|
|
3146
|
+
U("button", {
|
|
2917
3147
|
type: "button",
|
|
2918
3148
|
disabled: !b.value,
|
|
2919
3149
|
"aria-label": x.value.openLink,
|
|
2920
3150
|
"data-testid": "markweave-floating-toolbar-link-open",
|
|
2921
3151
|
onMousedown: $,
|
|
2922
|
-
onClick: () =>
|
|
2923
|
-
}, [Q(
|
|
2924
|
-
|
|
3152
|
+
onClick: () => sa(p.value)
|
|
3153
|
+
}, [Q(qr, x.value.openLink)]),
|
|
3154
|
+
U("button", {
|
|
2925
3155
|
type: "button",
|
|
2926
3156
|
"aria-label": x.value.removeLink,
|
|
2927
3157
|
"data-testid": "markweave-floating-toolbar-link-remove",
|
|
2928
3158
|
onMousedown: $,
|
|
2929
3159
|
onClick: D
|
|
2930
|
-
}, [Q(
|
|
2931
|
-
])]) : t.value === "color" ?
|
|
3160
|
+
}, [Q(ki, x.value.removeLink)])
|
|
3161
|
+
])]) : t.value === "color" ? U("div", {
|
|
2932
3162
|
ref: y,
|
|
2933
3163
|
class: "markweave-floating-toolbar-popover markweave-floating-toolbar-color-popover",
|
|
2934
3164
|
"data-testid": "markweave-floating-toolbar-color-menu"
|
|
2935
|
-
}, [
|
|
3165
|
+
}, [V(x.value.textColorTitle, "text", C.value), V(x.value.highlightColorTitle, "highlight", w.value)]) : t.value === "more" ? U("div", {
|
|
2936
3166
|
ref: y,
|
|
2937
3167
|
class: "markweave-floating-toolbar-popover markweave-floating-toolbar-more-menu",
|
|
2938
3168
|
"data-testid": "markweave-floating-toolbar-more-menu"
|
|
2939
|
-
}, T.value.map((n) =>
|
|
3169
|
+
}, T.value.map((n) => U("span", {
|
|
2940
3170
|
key: n,
|
|
2941
3171
|
class: "markweave-floating-toolbar-more-item"
|
|
2942
|
-
}, [
|
|
3172
|
+
}, [U("button", {
|
|
2943
3173
|
type: "button",
|
|
2944
3174
|
"aria-label": x.value.moreActions[n],
|
|
2945
3175
|
"data-testid": `markweave-floating-toolbar-more-${n}`,
|
|
@@ -2952,61 +3182,61 @@ var ea = X({
|
|
|
2952
3182
|
m.value = null;
|
|
2953
3183
|
},
|
|
2954
3184
|
onClick: () => {
|
|
2955
|
-
|
|
3185
|
+
ve(e.editor, n), t.value = null;
|
|
2956
3186
|
}
|
|
2957
|
-
}, [Q(
|
|
3187
|
+
}, [Q(ca[n], x.value.moreActions[n])]), m.value === n ? U("div", {
|
|
2958
3188
|
class: "markweave-floating-toolbar-tooltip markweave-floating-toolbar-tooltip--more",
|
|
2959
3189
|
role: "tooltip"
|
|
2960
3190
|
}, x.value.moreActions[n]) : null]))) : null;
|
|
2961
3191
|
};
|
|
2962
|
-
return () =>
|
|
3192
|
+
return () => U(ie, {
|
|
2963
3193
|
editor: e.editor,
|
|
2964
3194
|
shouldShow: ({ editor: e }) => {
|
|
2965
|
-
let t =
|
|
2966
|
-
return
|
|
3195
|
+
let t = ze(e);
|
|
3196
|
+
return Ee(we(e), {
|
|
2967
3197
|
editable: e.isEditable,
|
|
2968
|
-
hasAskAiPreview:
|
|
3198
|
+
hasAskAiPreview: Ve(e.state),
|
|
2969
3199
|
hasActiveAskAiTableTarget: t?.target.kind === "table" && t.status === "target"
|
|
2970
3200
|
});
|
|
2971
3201
|
},
|
|
2972
3202
|
getReferencedVirtualElement: () => {
|
|
2973
|
-
let t =
|
|
3203
|
+
let t = ze(e.editor)?.target.kind === "table" ? Be(e.editor) : null;
|
|
2974
3204
|
return t ? {
|
|
2975
3205
|
getBoundingClientRect: () => new DOMRect(t.left, t.top, t.width, t.height),
|
|
2976
3206
|
getClientRects: () => [new DOMRect(t.left, t.top, t.width, t.height)]
|
|
2977
3207
|
} : null;
|
|
2978
3208
|
},
|
|
2979
3209
|
options: { placement: "top" }
|
|
2980
|
-
}, { default: () =>
|
|
3210
|
+
}, { default: () => U("div", {
|
|
2981
3211
|
ref: _,
|
|
2982
3212
|
class: "markweave-floating-toolbar markweave-floating-toolbar--default markweave-floating-toolbar--motion-entered",
|
|
2983
3213
|
"data-popover-placement": t.value ? g.value : void 0,
|
|
2984
3214
|
"data-ask-ai-session": t.value === "ask-ai" ? "open" : "closed",
|
|
2985
3215
|
"data-testid": "markweave-floating-toolbar"
|
|
2986
|
-
}, [
|
|
3216
|
+
}, [U("div", {
|
|
2987
3217
|
ref: v,
|
|
2988
3218
|
class: "markweave-floating-toolbar-content",
|
|
2989
3219
|
"data-menu": t.value ?? "none"
|
|
2990
3220
|
}, [
|
|
2991
|
-
f.value &&
|
|
2992
|
-
f.value &&
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3221
|
+
f.value && He(e.editor) ? z("ask-ai", x.value.buttons["ask-ai"], yi, j, t.value === "ask-ai", x.value.buttons["ask-ai"]) : null,
|
|
3222
|
+
f.value && He(e.editor) ? B() : null,
|
|
3223
|
+
z("block-type", x.value.buttons["block-type"], Ai, () => O("block-type"), t.value === "block-type"),
|
|
3224
|
+
B(),
|
|
3225
|
+
z("bold", x.value.buttons.bold, Nr, () => e.editor.chain().focus().toggleBold().run(), e.editor.isActive("bold")),
|
|
3226
|
+
z("italic", x.value.buttons.italic, ni, () => e.editor.chain().focus().toggleItalic().run(), e.editor.isActive("italic")),
|
|
3227
|
+
z("underline", x.value.buttons.underline, ji, () => e.editor.chain().focus().toggleUnderline().run(), e.editor.isActive("underline")),
|
|
3228
|
+
z("strike", x.value.buttons.strike, Si, () => e.editor.chain().focus().toggleStrike().run(), e.editor.isActive("strike")),
|
|
3229
|
+
z("inline-code", x.value.buttons["inline-code"], Hr, () => e.editor.chain().focus().toggleCode().run(), e.editor.isActive("code")),
|
|
3230
|
+
B(),
|
|
3231
|
+
z("link", x.value.buttons.link, ii, () => O("link"), e.editor.isActive("link")),
|
|
3232
|
+
z("color", x.value.buttons.color, Ai, () => O("color"), t.value === "color"),
|
|
3233
|
+
B(),
|
|
3234
|
+
z("more", x.value.buttons.more, li, () => O("more"), t.value === "more"),
|
|
3235
|
+
H(),
|
|
3236
|
+
R()
|
|
3007
3237
|
])]) });
|
|
3008
3238
|
}
|
|
3009
|
-
}),
|
|
3239
|
+
}), ma = X({
|
|
3010
3240
|
name: "MarkweaveVueMathEditorPopover",
|
|
3011
3241
|
props: {
|
|
3012
3242
|
editor: {
|
|
@@ -3027,17 +3257,17 @@ var ea = X({
|
|
|
3027
3257
|
}
|
|
3028
3258
|
},
|
|
3029
3259
|
setup(e) {
|
|
3030
|
-
let t =
|
|
3260
|
+
let t = W(e.target.latex), n = G(null), r = W(null), i = W(null), a = G(Wt(e.editor, e.target)), o = K(() => t.value === e.target.latex && a.value ? {
|
|
3031
3261
|
html: a.value,
|
|
3032
3262
|
error: !1
|
|
3033
|
-
} :
|
|
3263
|
+
} : Jt(t.value, e.target.kind, e.editor)), s = K(() => t.value.trim().length > 0), c = K(() => e.messages.math), l = K(() => Ut(e.editor, e.target) ?? 1), u = () => {
|
|
3034
3264
|
if (typeof window > "u") return;
|
|
3035
|
-
let r =
|
|
3265
|
+
let r = Ht(e.editor, e.target), i = e.editor.view.dom.closest(".markweave-editor-frame")?.getBoundingClientRect();
|
|
3036
3266
|
if (!r || !i) {
|
|
3037
3267
|
e.onClose();
|
|
3038
3268
|
return;
|
|
3039
3269
|
}
|
|
3040
|
-
n.value =
|
|
3270
|
+
n.value = Vt({
|
|
3041
3271
|
anchorRect: r,
|
|
3042
3272
|
frameRect: i,
|
|
3043
3273
|
kind: e.target.kind,
|
|
@@ -3046,7 +3276,7 @@ var ea = X({
|
|
|
3046
3276
|
viewportWidth: window.innerWidth
|
|
3047
3277
|
});
|
|
3048
3278
|
}, d = () => {
|
|
3049
|
-
s.value &&
|
|
3279
|
+
s.value && Bt(e.editor, e.target, t.value) && e.onClose();
|
|
3050
3280
|
}, f = (t) => {
|
|
3051
3281
|
if (t.key === "Escape") {
|
|
3052
3282
|
t.preventDefault(), e.onClose(), e.editor.commands.focus();
|
|
@@ -3057,14 +3287,14 @@ var ea = X({
|
|
|
3057
3287
|
let n = t.target;
|
|
3058
3288
|
n instanceof Node && (r.value?.contains(n) || n instanceof Element && n.closest(".tiptap-mathematics-render") || e.onClose());
|
|
3059
3289
|
};
|
|
3060
|
-
return
|
|
3061
|
-
t.value = e.target.latex, a.value =
|
|
3062
|
-
}),
|
|
3063
|
-
|
|
3290
|
+
return q(() => [e.target.pos, e.target.latex], () => {
|
|
3291
|
+
t.value = e.target.latex, a.value = Wt(e.editor, e.target), Y(u);
|
|
3292
|
+
}), fr(() => {
|
|
3293
|
+
Yt(e.editor, e.target, !0), u(), Y(() => {
|
|
3064
3294
|
i.value?.focus({ preventScroll: !0 }), i.value?.select(), u();
|
|
3065
3295
|
}), window.addEventListener("resize", u), window.addEventListener("scroll", u, !0), document.addEventListener("mousedown", p);
|
|
3066
|
-
}),
|
|
3067
|
-
|
|
3296
|
+
}), J(() => {
|
|
3297
|
+
Yt(e.editor, e.target, !1), window.removeEventListener("resize", u), window.removeEventListener("scroll", u, !0), document.removeEventListener("mousedown", p);
|
|
3068
3298
|
}), () => {
|
|
3069
3299
|
let a = e.target.kind === "block" ? c.value.blockTitle : c.value.inlineTitle, u = {
|
|
3070
3300
|
ref: i,
|
|
@@ -3077,7 +3307,7 @@ var ea = X({
|
|
|
3077
3307
|
},
|
|
3078
3308
|
onKeydown: f
|
|
3079
3309
|
};
|
|
3080
|
-
return e.target.kind === "inline" ?
|
|
3310
|
+
return e.target.kind === "inline" ? U("form", {
|
|
3081
3311
|
ref: r,
|
|
3082
3312
|
class: "markweave-math-editor-popover markweave-math-editor-popover--inline",
|
|
3083
3313
|
"aria-label": a,
|
|
@@ -3092,22 +3322,22 @@ var ea = X({
|
|
|
3092
3322
|
onSubmit: (e) => {
|
|
3093
3323
|
e.preventDefault(), d();
|
|
3094
3324
|
}
|
|
3095
|
-
}, [
|
|
3325
|
+
}, [U("label", {
|
|
3096
3326
|
class: "markweave-math-inline-source",
|
|
3097
3327
|
"data-testid": "markweave-math-inline-source"
|
|
3098
3328
|
}, [
|
|
3099
|
-
|
|
3100
|
-
|
|
3329
|
+
U("span", { attrs: { "aria-hidden": "true" } }, "$"),
|
|
3330
|
+
U("input", {
|
|
3101
3331
|
...u,
|
|
3102
3332
|
"aria-label": c.value.latexLabel,
|
|
3103
3333
|
size: Math.max(t.value.length, 1)
|
|
3104
3334
|
}),
|
|
3105
|
-
|
|
3106
|
-
]),
|
|
3335
|
+
U("span", { attrs: { "aria-hidden": "true" } }, "$")
|
|
3336
|
+
]), U("div", {
|
|
3107
3337
|
class: "markweave-math-inline-preview",
|
|
3108
3338
|
"data-error": o.value.error ? "true" : "false",
|
|
3109
3339
|
"data-testid": "markweave-math-editor-preview"
|
|
3110
|
-
}, [
|
|
3340
|
+
}, [U("div", { innerHTML: o.value.html || " " }), o.value.error ? U("small", null, c.value.invalidPreview) : null])]) : U("form", {
|
|
3111
3341
|
ref: r,
|
|
3112
3342
|
class: "markweave-math-editor-popover markweave-math-editor-popover--block",
|
|
3113
3343
|
"aria-label": a,
|
|
@@ -3123,39 +3353,39 @@ var ea = X({
|
|
|
3123
3353
|
e.preventDefault(), d();
|
|
3124
3354
|
}
|
|
3125
3355
|
}, [
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
Q(
|
|
3129
|
-
|
|
3356
|
+
U("div", { class: "markweave-math-block-toolbar" }, [
|
|
3357
|
+
U("span", null, c.value.label),
|
|
3358
|
+
Q(Hr, c.value.label, 15, 1.75),
|
|
3359
|
+
U("button", {
|
|
3130
3360
|
type: "submit",
|
|
3131
3361
|
title: c.value.apply,
|
|
3132
3362
|
"aria-label": c.value.apply,
|
|
3133
3363
|
disabled: !s.value,
|
|
3134
3364
|
"data-testid": "markweave-math-editor-apply"
|
|
3135
|
-
}, [Q(
|
|
3365
|
+
}, [Q(Lr, c.value.apply, 16, 2)])
|
|
3136
3366
|
]),
|
|
3137
|
-
|
|
3367
|
+
U("label", {
|
|
3138
3368
|
class: "markweave-math-block-source",
|
|
3139
3369
|
"data-testid": "markweave-math-block-source"
|
|
3140
3370
|
}, [
|
|
3141
|
-
|
|
3142
|
-
|
|
3371
|
+
U("span", { attrs: { "aria-hidden": "true" } }, "$$"),
|
|
3372
|
+
U("textarea", {
|
|
3143
3373
|
...u,
|
|
3144
3374
|
"aria-label": c.value.latexLabel,
|
|
3145
3375
|
rows: 3
|
|
3146
3376
|
}),
|
|
3147
|
-
|
|
3377
|
+
U("span", { attrs: { "aria-hidden": "true" } }, "$$")
|
|
3148
3378
|
]),
|
|
3149
|
-
|
|
3379
|
+
U("div", {
|
|
3150
3380
|
class: "markweave-math-block-preview",
|
|
3151
3381
|
"data-error": o.value.error ? "true" : "false",
|
|
3152
3382
|
"data-math-number": String(l.value),
|
|
3153
3383
|
"data-testid": "markweave-math-editor-preview"
|
|
3154
|
-
}, [
|
|
3384
|
+
}, [U("div", { innerHTML: o.value.html || " " }), o.value.error ? U("small", null, c.value.invalidPreview) : null])
|
|
3155
3385
|
]);
|
|
3156
3386
|
};
|
|
3157
3387
|
}
|
|
3158
|
-
}),
|
|
3388
|
+
}), ha = X({
|
|
3159
3389
|
name: "MarkweaveVueSlashCommandMenu",
|
|
3160
3390
|
props: {
|
|
3161
3391
|
commands: {
|
|
@@ -3192,87 +3422,99 @@ var ea = X({
|
|
|
3192
3422
|
}
|
|
3193
3423
|
},
|
|
3194
3424
|
setup(e) {
|
|
3195
|
-
let t =
|
|
3425
|
+
let t = W(""), n = W(null), r = W(null), i = W(!1), a = W(""), o = W(0), s = W(null), c = K(() => {
|
|
3196
3426
|
let t = a.value.trim().toLowerCase();
|
|
3197
3427
|
return (t ? e.messages.slash.emojiItems.filter((e) => [
|
|
3198
3428
|
e.emoji,
|
|
3199
3429
|
e.label,
|
|
3200
3430
|
...e.terms
|
|
3201
3431
|
].join(" ").toLowerCase().includes(t)) : e.messages.slash.emojiItems).slice(0, 12);
|
|
3202
|
-
})
|
|
3432
|
+
});
|
|
3433
|
+
q(() => [
|
|
3434
|
+
e.state.name,
|
|
3435
|
+
e.state.activeIndex,
|
|
3436
|
+
e.commands.length,
|
|
3437
|
+
e.inputCommand?.id ?? null
|
|
3438
|
+
], async () => {
|
|
3439
|
+
if (e.state.name !== "keyboard-selecting" || e.inputCommand || !e.commands.length) return;
|
|
3440
|
+
await Y();
|
|
3441
|
+
let t = s.value, n = t?.querySelector("[data-active=\"true\"]");
|
|
3442
|
+
t && n && sn(t, n);
|
|
3443
|
+
}, { flush: "post" });
|
|
3444
|
+
let l = async () => {
|
|
3203
3445
|
if (e.inputCommand) {
|
|
3204
3446
|
r.value = null, i.value = !0;
|
|
3205
3447
|
try {
|
|
3206
|
-
let i = n.value ? {
|
|
3207
|
-
kind:
|
|
3208
|
-
trigger: "slash-command",
|
|
3448
|
+
let i = e.inputCommand.uploadKind ?? "attachment", a = n.value ? {
|
|
3449
|
+
kind: i,
|
|
3450
|
+
trigger: i === "attachment" ? "attachment-insert" : "slash-command",
|
|
3209
3451
|
source: {
|
|
3210
3452
|
type: "file",
|
|
3211
3453
|
file: n.value,
|
|
3212
3454
|
mimeType: n.value.type
|
|
3213
3455
|
}
|
|
3214
3456
|
} : {
|
|
3215
|
-
kind:
|
|
3216
|
-
trigger: "slash-command",
|
|
3217
|
-
source:
|
|
3457
|
+
kind: i,
|
|
3458
|
+
trigger: i === "attachment" ? "attachment-insert" : "slash-command",
|
|
3459
|
+
source: V(t.value)
|
|
3218
3460
|
};
|
|
3219
3461
|
if (!n.value && !t.value.trim()) {
|
|
3220
3462
|
r.value = e.messages.slash.uploadRequiredError;
|
|
3221
3463
|
return;
|
|
3222
3464
|
}
|
|
3223
|
-
let
|
|
3224
|
-
e.onSelect(e.inputCommand, { uploadResult:
|
|
3465
|
+
let o = await ne(a, e.onUpload);
|
|
3466
|
+
e.onSelect(e.inputCommand, { uploadResult: o }), e.onInputCommandChange(null), t.value = "", n.value = null;
|
|
3225
3467
|
} catch (t) {
|
|
3226
3468
|
r.value = t instanceof Error ? t.message : e.messages.slash.uploadFailedError;
|
|
3227
3469
|
} finally {
|
|
3228
3470
|
i.value = !1;
|
|
3229
3471
|
}
|
|
3230
3472
|
}
|
|
3231
|
-
},
|
|
3473
|
+
}, u = (t) => {
|
|
3232
3474
|
if (!e.inputCommand) return;
|
|
3233
|
-
let n =
|
|
3475
|
+
let n = c.value[Math.min(c.value.length - 1, Math.max(0, t))];
|
|
3234
3476
|
n && (e.onSelect(e.inputCommand, { emoji: n.emoji }), e.onInputCommandChange(null));
|
|
3235
3477
|
};
|
|
3236
3478
|
return () => {
|
|
3237
3479
|
if (!e.position) return null;
|
|
3238
|
-
let
|
|
3480
|
+
let d = {
|
|
3239
3481
|
left: `${e.position.left}px`,
|
|
3240
3482
|
top: `${e.position.top}px`,
|
|
3241
3483
|
maxHeight: `${e.position.maxHeight}px`,
|
|
3242
3484
|
"--markweave-slash-menu-max-height": `${e.position.maxHeight}px`
|
|
3243
|
-
},
|
|
3485
|
+
}, f = {
|
|
3244
3486
|
left: `${e.position.triggerLeft}px`,
|
|
3245
3487
|
top: `${e.position.triggerTop}px`
|
|
3246
|
-
},
|
|
3488
|
+
}, p = Object.values(e.messages.slash.groups).map((t) => ({
|
|
3247
3489
|
group: t,
|
|
3248
3490
|
commands: e.commands.filter((e) => e.group === t)
|
|
3249
3491
|
})).filter((e) => e.commands.length);
|
|
3250
|
-
return
|
|
3492
|
+
return U("div", {
|
|
3251
3493
|
class: "markweave-slash-layer",
|
|
3252
3494
|
style: { display: "contents" },
|
|
3253
3495
|
"data-testid": "markweave-slash-layer"
|
|
3254
|
-
}, [
|
|
3496
|
+
}, [U("div", {
|
|
3255
3497
|
class: "markweave-slash-trigger",
|
|
3256
|
-
style:
|
|
3498
|
+
style: f,
|
|
3257
3499
|
"aria-hidden": "true",
|
|
3258
3500
|
"data-testid": "markweave-slash-trigger"
|
|
3259
|
-
}, [
|
|
3501
|
+
}, [U("span", null, "/"), U("em", null, e.state.query || e.messages.slash.filterPlaceholder)]), U("div", {
|
|
3260
3502
|
class: "markweave-slash-menu",
|
|
3261
|
-
style:
|
|
3503
|
+
style: d,
|
|
3262
3504
|
role: "listbox",
|
|
3263
3505
|
"aria-label": e.messages.slash.ariaLabel,
|
|
3264
3506
|
"data-placement": e.position.placement,
|
|
3265
3507
|
"data-testid": "markweave-slash-menu"
|
|
3266
|
-
}, [e.inputCommand?.inputKind === "emoji" ?
|
|
3508
|
+
}, [e.inputCommand?.inputKind === "emoji" ? U("div", {
|
|
3267
3509
|
class: "markweave-slash-subpanel",
|
|
3268
3510
|
"data-testid": "markweave-slash-emoji-picker"
|
|
3269
3511
|
}, [
|
|
3270
|
-
|
|
3512
|
+
U("div", { class: "markweave-slash-subpanel-header" }, [U("button", {
|
|
3271
3513
|
type: "button",
|
|
3272
3514
|
onMousedown: $,
|
|
3273
3515
|
onClick: () => e.onInputCommandChange(null)
|
|
3274
|
-
}, e.messages.common.back),
|
|
3275
|
-
|
|
3516
|
+
}, e.messages.common.back), U("span", null, e.messages.slash.emojiTitle)]),
|
|
3517
|
+
U("label", { class: "markweave-slash-input" }, [U("span", null, "/"), U("input", {
|
|
3276
3518
|
autofocus: !0,
|
|
3277
3519
|
value: a.value,
|
|
3278
3520
|
placeholder: e.messages.slash.emojiSearchPlaceholder,
|
|
@@ -3280,14 +3522,14 @@ var ea = X({
|
|
|
3280
3522
|
a.value = e.target.value, o.value = 0;
|
|
3281
3523
|
},
|
|
3282
3524
|
onKeydown: (t) => {
|
|
3283
|
-
t.key === "Escape" ? (t.preventDefault(), e.onInputCommandChange(null)) : t.key === "ArrowDown" ? (t.preventDefault(), o.value =
|
|
3525
|
+
t.key === "Escape" ? (t.preventDefault(), e.onInputCommandChange(null)) : t.key === "ArrowDown" ? (t.preventDefault(), o.value = c.value.length ? (o.value + 1) % c.value.length : 0) : t.key === "ArrowUp" ? (t.preventDefault(), o.value = c.value.length ? (o.value - 1 + c.value.length) % c.value.length : 0) : (t.key === "Enter" || t.key === "Tab") && (t.preventDefault(), u(o.value));
|
|
3284
3526
|
}
|
|
3285
3527
|
})]),
|
|
3286
|
-
|
|
3528
|
+
U("div", {
|
|
3287
3529
|
class: "markweave-slash-emoji-grid",
|
|
3288
3530
|
role: "listbox",
|
|
3289
3531
|
"aria-label": e.messages.slash.emojiTitle
|
|
3290
|
-
},
|
|
3532
|
+
}, c.value.map((e, t) => U("button", {
|
|
3291
3533
|
key: `${e.emoji}-${e.label}`,
|
|
3292
3534
|
type: "button",
|
|
3293
3535
|
role: "option",
|
|
@@ -3295,18 +3537,18 @@ var ea = X({
|
|
|
3295
3537
|
"data-active": t === o.value,
|
|
3296
3538
|
onMouseenter: () => o.value = t,
|
|
3297
3539
|
onMousedown: $,
|
|
3298
|
-
onClick: () =>
|
|
3299
|
-
}, [
|
|
3300
|
-
]) : e.inputCommand?.inputKind === "upload" ?
|
|
3540
|
+
onClick: () => u(t)
|
|
3541
|
+
}, [U("span", null, e.emoji), U("small", null, e.label)])))
|
|
3542
|
+
]) : e.inputCommand?.inputKind === "upload" ? U("div", {
|
|
3301
3543
|
class: "markweave-slash-subpanel",
|
|
3302
3544
|
"data-testid": "markweave-slash-upload-panel"
|
|
3303
3545
|
}, [
|
|
3304
|
-
|
|
3546
|
+
U("div", { class: "markweave-slash-upload-header" }, [U("button", {
|
|
3305
3547
|
type: "button",
|
|
3306
3548
|
onMousedown: $,
|
|
3307
3549
|
onClick: () => e.onInputCommandChange(null)
|
|
3308
|
-
}, e.messages.common.back),
|
|
3309
|
-
|
|
3550
|
+
}, e.messages.common.back), U("strong", null, e.inputCommand ? e.messages.slash.uploadKindLabels[e.inputCommand.uploadKind ?? "upload"] : e.messages.slash.uploadKindLabels.upload)]),
|
|
3551
|
+
U("label", { class: "markweave-slash-upload-field" }, [U("span", null, e.messages.slash.uploadValueLabel), U("input", {
|
|
3310
3552
|
autofocus: !0,
|
|
3311
3553
|
value: t.value,
|
|
3312
3554
|
placeholder: e.messages.slash.uploadValuePlaceholder,
|
|
@@ -3314,35 +3556,38 @@ var ea = X({
|
|
|
3314
3556
|
t.value = e.target.value;
|
|
3315
3557
|
},
|
|
3316
3558
|
onKeydown: (e) => {
|
|
3317
|
-
e.key === "Enter" && (e.preventDefault(),
|
|
3559
|
+
e.key === "Enter" && (e.preventDefault(), l());
|
|
3318
3560
|
}
|
|
3319
3561
|
})]),
|
|
3320
|
-
|
|
3562
|
+
U("label", { class: "markweave-slash-upload-field" }, [U("span", null, e.messages.common.file), U("input", {
|
|
3321
3563
|
type: "file",
|
|
3322
3564
|
onChange: (e) => n.value = e.target.files?.[0] ?? null
|
|
3323
3565
|
})]),
|
|
3324
|
-
r.value ?
|
|
3566
|
+
r.value ? U("div", {
|
|
3325
3567
|
class: "markweave-slash-upload-error",
|
|
3326
3568
|
role: "alert"
|
|
3327
3569
|
}, r.value) : null,
|
|
3328
|
-
|
|
3570
|
+
U("div", { class: "markweave-slash-upload-actions" }, [U("button", {
|
|
3329
3571
|
type: "button",
|
|
3330
3572
|
onMousedown: $,
|
|
3331
3573
|
onClick: () => e.onInputCommandChange(null)
|
|
3332
|
-
}, e.messages.common.cancel),
|
|
3574
|
+
}, e.messages.common.cancel), U("button", {
|
|
3333
3575
|
type: "button",
|
|
3334
3576
|
"data-primary": "true",
|
|
3335
3577
|
disabled: i.value,
|
|
3336
3578
|
onMousedown: $,
|
|
3337
|
-
onClick:
|
|
3579
|
+
onClick: l
|
|
3338
3580
|
}, e.messages.common.insert)])
|
|
3339
|
-
]) : e.commands.length ?
|
|
3581
|
+
]) : e.commands.length ? U("div", {
|
|
3582
|
+
ref: s,
|
|
3583
|
+
class: "markweave-slash-command-list"
|
|
3584
|
+
}, p.map((t) => U("section", {
|
|
3340
3585
|
key: t.group,
|
|
3341
3586
|
class: "markweave-slash-group",
|
|
3342
3587
|
"aria-label": t.group
|
|
3343
|
-
}, [
|
|
3344
|
-
let n = e.commands.indexOf(t) === e.state.activeIndex, r =
|
|
3345
|
-
return
|
|
3588
|
+
}, [U("div", { class: "markweave-slash-group-title" }, t.group), ...t.commands.map((t) => {
|
|
3589
|
+
let n = e.commands.indexOf(t) === e.state.activeIndex, r = an(t);
|
|
3590
|
+
return U("button", {
|
|
3346
3591
|
key: t.id,
|
|
3347
3592
|
type: "button",
|
|
3348
3593
|
role: "option",
|
|
@@ -3364,45 +3609,45 @@ var ea = X({
|
|
|
3364
3609
|
}
|
|
3365
3610
|
}
|
|
3366
3611
|
}, [
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
t.disabledReason ?
|
|
3612
|
+
ua(t.icon),
|
|
3613
|
+
U("span", null, t.label),
|
|
3614
|
+
t.disabledReason ? U("small", null, t.disabledReason) : null
|
|
3370
3615
|
]);
|
|
3371
|
-
})]))) :
|
|
3616
|
+
})]))) : U("div", {
|
|
3372
3617
|
class: "markweave-slash-menu__empty",
|
|
3373
3618
|
role: "option",
|
|
3374
3619
|
"aria-disabled": "true"
|
|
3375
3620
|
}, e.messages.slash.noResults)])]);
|
|
3376
3621
|
};
|
|
3377
3622
|
}
|
|
3378
|
-
}),
|
|
3379
|
-
"ask-ai":
|
|
3380
|
-
"move-left":
|
|
3381
|
-
"move-right":
|
|
3382
|
-
"move-up":
|
|
3383
|
-
"move-down":
|
|
3384
|
-
"insert-left":
|
|
3385
|
-
"insert-right":
|
|
3386
|
-
"insert-above":
|
|
3387
|
-
"insert-below":
|
|
3388
|
-
"sort-asc":
|
|
3389
|
-
"sort-desc":
|
|
3390
|
-
color:
|
|
3391
|
-
alignment:
|
|
3392
|
-
clear:
|
|
3393
|
-
duplicate:
|
|
3394
|
-
copy:
|
|
3395
|
-
merge:
|
|
3396
|
-
split:
|
|
3397
|
-
delete:
|
|
3398
|
-
},
|
|
3399
|
-
left:
|
|
3400
|
-
center:
|
|
3401
|
-
right:
|
|
3402
|
-
top:
|
|
3403
|
-
middle:
|
|
3404
|
-
bottom:
|
|
3405
|
-
},
|
|
3623
|
+
}), ga = {
|
|
3624
|
+
"ask-ai": yi,
|
|
3625
|
+
"move-left": Tr,
|
|
3626
|
+
"move-right": Er,
|
|
3627
|
+
"move-up": Dr,
|
|
3628
|
+
"move-down": Cr,
|
|
3629
|
+
"insert-left": Mr,
|
|
3630
|
+
"insert-right": jr,
|
|
3631
|
+
"insert-above": Ar,
|
|
3632
|
+
"insert-below": kr,
|
|
3633
|
+
"sort-asc": wr,
|
|
3634
|
+
"sort-desc": Or,
|
|
3635
|
+
color: ui,
|
|
3636
|
+
alignment: _r,
|
|
3637
|
+
clear: xi,
|
|
3638
|
+
duplicate: Wr,
|
|
3639
|
+
copy: Wr,
|
|
3640
|
+
merge: Ei,
|
|
3641
|
+
split: Di,
|
|
3642
|
+
delete: ki
|
|
3643
|
+
}, _a = {
|
|
3644
|
+
left: _r,
|
|
3645
|
+
center: hr,
|
|
3646
|
+
right: vr,
|
|
3647
|
+
top: xr,
|
|
3648
|
+
middle: yr,
|
|
3649
|
+
bottom: br
|
|
3650
|
+
}, va = X({
|
|
3406
3651
|
name: "MarkweaveVueTableControls",
|
|
3407
3652
|
props: {
|
|
3408
3653
|
editor: {
|
|
@@ -3439,13 +3684,13 @@ var ea = X({
|
|
|
3439
3684
|
}
|
|
3440
3685
|
},
|
|
3441
3686
|
setup(e) {
|
|
3442
|
-
let t =
|
|
3687
|
+
let t = W(null), n = W(null), r = W("row-edge"), i = W(null), a = W(null), o = W(null), s = W(null), c = W(null), l = W(null), u = W(null), d = W(null), f = W(0), p = W(null), m = W(null), h = W(null), g = W(null), _ = W(null), v = W(null), y = W(null), b = null, x = null, S = null, C = K(() => e.askAi?.enabled === !0 && typeof e.askAi.handler == "function"), w = K(() => e.active ? bn(e.editor.state) : ta), T = K(() => zn(e.editor, e.interactionState, "row", w.value.activeCellPos)), E = K(() => zn(e.editor, e.interactionState, "column", w.value.activeCellPos)), D = K(() => Fn(e.editor)), O = K(() => (D.value, w.value.active && Un(e.editor, "selection", { askAiEnabled: C.value }).length > 0)), k = K(() => t.value ? Un(e.editor, t.value, { askAiEnabled: C.value }) : []), A = () => {
|
|
3443
3688
|
b === null || typeof window > "u" || (window.clearTimeout(b), b = null);
|
|
3444
3689
|
}, j = (e) => {
|
|
3445
3690
|
A(), d.value = e, !(!e || typeof window > "u") && (b = window.setTimeout(() => {
|
|
3446
3691
|
d.value = null, b = null;
|
|
3447
|
-
},
|
|
3448
|
-
},
|
|
3692
|
+
}, Yn));
|
|
3693
|
+
}, ee = () => {
|
|
3449
3694
|
if (!e.active) {
|
|
3450
3695
|
i.value = null, a.value = null, o.value = null, s.value = null, c.value = null, j(null);
|
|
3451
3696
|
return;
|
|
@@ -3455,31 +3700,31 @@ var ea = X({
|
|
|
3455
3700
|
i.value = null, a.value = null, o.value = null, s.value = null, c.value = null;
|
|
3456
3701
|
return;
|
|
3457
3702
|
}
|
|
3458
|
-
let l = n.getBoundingClientRect(), u = T.value ?
|
|
3459
|
-
u ? i.value =
|
|
3703
|
+
let l = n.getBoundingClientRect(), u = T.value ? Rn(e.editor, T.value) : null, d = E.value ? Rn(e.editor, E.value) : null, f = O.value ? Wn(e.editor) : null, p = Pn(e.editor)?.getBoundingClientRect() ?? null;
|
|
3704
|
+
u ? i.value = kn({
|
|
3460
3705
|
targetRect: u,
|
|
3461
3706
|
frameRect: l,
|
|
3462
3707
|
kind: "row"
|
|
3463
|
-
}) : t.value === "row" && r.value === "row-edge" || (i.value = null), d ? a.value =
|
|
3708
|
+
}) : t.value === "row" && r.value === "row-edge" || (i.value = null), d ? a.value = kn({
|
|
3464
3709
|
targetRect: d,
|
|
3465
3710
|
frameRect: l,
|
|
3466
3711
|
kind: "column"
|
|
3467
|
-
}) : t.value === "column" && r.value === "column-edge" || (a.value = null), f ? o.value =
|
|
3712
|
+
}) : t.value === "column" && r.value === "column-edge" || (a.value = null), f ? o.value = kn({
|
|
3468
3713
|
targetRect: f,
|
|
3469
3714
|
frameRect: l,
|
|
3470
3715
|
kind: "selection"
|
|
3471
3716
|
}) : t.value === "selection" && r.value === "selection-edge" || (o.value = null);
|
|
3472
3717
|
let m = e.interactionState.hoverCellPos !== null && !!(T.value && T.value.index === T.value.visualHeight - 1), h = e.interactionState.hoverCellPos !== null && !!(E.value && E.value.index === E.value.visualWidth - 1);
|
|
3473
|
-
s.value = p && m ?
|
|
3718
|
+
s.value = p && m ? An({
|
|
3474
3719
|
tableRect: p,
|
|
3475
3720
|
frameRect: l,
|
|
3476
3721
|
kind: "row"
|
|
3477
|
-
}) : null, c.value = p && h ?
|
|
3722
|
+
}) : null, c.value = p && h ? An({
|
|
3478
3723
|
tableRect: p,
|
|
3479
3724
|
frameRect: l,
|
|
3480
3725
|
kind: "column"
|
|
3481
3726
|
}) : null;
|
|
3482
|
-
},
|
|
3727
|
+
}, te = () => {
|
|
3483
3728
|
if (!e.active || !t.value) {
|
|
3484
3729
|
l.value = null;
|
|
3485
3730
|
return;
|
|
@@ -3489,23 +3734,23 @@ var ea = X({
|
|
|
3489
3734
|
l.value = null;
|
|
3490
3735
|
return;
|
|
3491
3736
|
}
|
|
3492
|
-
let a = i.getBoundingClientRect(), o = t.value === "row" ?
|
|
3737
|
+
let a = i.getBoundingClientRect(), o = t.value === "row" ? Pn(e.editor)?.getBoundingClientRect() : null, s = o ? {
|
|
3493
3738
|
left: a.left,
|
|
3494
3739
|
top: o.top,
|
|
3495
3740
|
width: a.width,
|
|
3496
3741
|
height: a.height
|
|
3497
3742
|
} : a, c = n.getBoundingClientRect(), u = _.value.getBoundingClientRect(), d = v.value?.scrollHeight ?? 0, f = d > 0 ? d + 12 : 0;
|
|
3498
|
-
l.value =
|
|
3743
|
+
l.value = Dn({
|
|
3499
3744
|
anchorRect: s,
|
|
3500
3745
|
frameRect: c,
|
|
3501
|
-
boundaryRect:
|
|
3746
|
+
boundaryRect: Bn(n),
|
|
3502
3747
|
menuSize: {
|
|
3503
3748
|
width: u.width || 254,
|
|
3504
3749
|
height: f || u.height || 410
|
|
3505
3750
|
},
|
|
3506
3751
|
kind: t.value
|
|
3507
3752
|
});
|
|
3508
|
-
},
|
|
3753
|
+
}, M = () => {
|
|
3509
3754
|
if (!e.active || !t.value || !n.value || !l.value) {
|
|
3510
3755
|
u.value = null;
|
|
3511
3756
|
return;
|
|
@@ -3516,33 +3761,33 @@ var ea = X({
|
|
|
3516
3761
|
return;
|
|
3517
3762
|
}
|
|
3518
3763
|
let a = y.value.getBoundingClientRect(), o = Math.max(y.value.scrollHeight + 2, a.height);
|
|
3519
|
-
u.value =
|
|
3764
|
+
u.value = On({
|
|
3520
3765
|
triggerRect: i.getBoundingClientRect(),
|
|
3521
3766
|
parentMenuRect: _.value.getBoundingClientRect(),
|
|
3522
|
-
boundaryRect:
|
|
3767
|
+
boundaryRect: Bn(r),
|
|
3523
3768
|
submenuSize: {
|
|
3524
3769
|
width: a.width || 238,
|
|
3525
3770
|
height: o || 410
|
|
3526
3771
|
}
|
|
3527
3772
|
});
|
|
3773
|
+
}, N = () => {
|
|
3774
|
+
ee(), te(), M();
|
|
3528
3775
|
}, P = () => {
|
|
3529
|
-
|
|
3530
|
-
}, F = () => {
|
|
3531
|
-
Y(P);
|
|
3532
|
-
}, I = (e, i) => {
|
|
3776
|
+
Y(N);
|
|
3777
|
+
}, F = (e, i) => {
|
|
3533
3778
|
let a = t.value === e && r.value === i;
|
|
3534
|
-
r.value = i, t.value = a ? null : e, n.value = null, u.value = null,
|
|
3535
|
-
},
|
|
3536
|
-
e.editor.view.dispatch(
|
|
3537
|
-
},
|
|
3779
|
+
r.value = i, t.value = a ? null : e, n.value = null, u.value = null, P();
|
|
3780
|
+
}, I = () => {
|
|
3781
|
+
e.editor.view.dispatch(_n(e.editor.state.tr, null));
|
|
3782
|
+
}, L = (t, n) => {
|
|
3538
3783
|
let r = e.interactionState.hoverCellPos ?? w.value.activeCellPos, i = e.interactionState.hoverCellPos === null ? null : t === "row" ? e.interactionState.hoverVisualRowIndex : e.interactionState.hoverVisualColumnIndex;
|
|
3539
|
-
r !== null &&
|
|
3540
|
-
},
|
|
3541
|
-
|
|
3784
|
+
r !== null && qn(e.editor, r, t, { visualIndex: i }), F(t, n);
|
|
3785
|
+
}, R = () => {
|
|
3786
|
+
I(), F("selection", "selection-edge");
|
|
3542
3787
|
}, z = (r = !1) => {
|
|
3543
3788
|
t.value = null, n.value = null, l.value = null, u.value = null, r && e.editor.view.focus();
|
|
3544
3789
|
}, B = async (n, r) => {
|
|
3545
|
-
let i = await
|
|
3790
|
+
let i = await Mn({
|
|
3546
3791
|
editor: e.editor,
|
|
3547
3792
|
commandId: n,
|
|
3548
3793
|
menu: r ?? t.value ?? "selection",
|
|
@@ -3550,27 +3795,27 @@ var ea = X({
|
|
|
3550
3795
|
});
|
|
3551
3796
|
return i.copyFeedback ? (j(i.copyFeedback), i.copyPayload && e.onCopyPayload?.(i.copyPayload)) : j(null), e.onCommandResult?.(i.commandResult), i.success;
|
|
3552
3797
|
}, V = (t) => {
|
|
3553
|
-
C.value && (
|
|
3798
|
+
C.value && (Ke(e.editor, t), z(!1));
|
|
3554
3799
|
}, H = (e) => {
|
|
3555
|
-
t.value !== "row" && t.value !== "column" || e(t.value) && (f.value += 1,
|
|
3556
|
-
},
|
|
3800
|
+
t.value !== "row" && t.value !== "column" || e(t.value) && (f.value += 1, P());
|
|
3801
|
+
}, ne = (t) => {
|
|
3557
3802
|
let n = t === "row" ? T.value : E.value, r = e.interactionState.hoverCellPos ?? w.value.activeCellPos;
|
|
3558
|
-
!n || r === null ||
|
|
3559
|
-
},
|
|
3803
|
+
!n || r === null || $n(e.editor, r, t, { visualIndex: n.index }) && B(t === "row" ? "add-row-after" : "add-column-after", t);
|
|
3804
|
+
}, re = (e, t, n) => {
|
|
3560
3805
|
x = {
|
|
3561
3806
|
axis: e,
|
|
3562
3807
|
index: t
|
|
3563
3808
|
}, S = t, n.dataTransfer?.setData("application/x-markweave-table-axis", `${e}:${t}`), n.dataTransfer && (n.dataTransfer.effectAllowed = "move");
|
|
3564
|
-
},
|
|
3809
|
+
}, ie = (t) => {
|
|
3565
3810
|
if (!x) return;
|
|
3566
|
-
let n =
|
|
3811
|
+
let n = In(e.editor, x.axis, t.clientX, t.clientY);
|
|
3567
3812
|
n !== null && (t.preventDefault(), S = n, t.dataTransfer && (t.dataTransfer.dropEffect = "move"));
|
|
3568
|
-
},
|
|
3813
|
+
}, ae = (t) => {
|
|
3569
3814
|
let n = x;
|
|
3570
3815
|
if (!n) return;
|
|
3571
|
-
let r =
|
|
3572
|
-
t.preventDefault(), x = null, S = null, r !== null &&
|
|
3573
|
-
},
|
|
3816
|
+
let r = In(e.editor, n.axis, t.clientX, t.clientY) ?? S;
|
|
3817
|
+
t.preventDefault(), x = null, S = null, r !== null && Kn(e.editor, n.axis, n.index, r);
|
|
3818
|
+
}, oe = K(() => (f.value, t.value === "row" || t.value === "column" ? Ln(e.editor, t.value) : null)), se = (e) => {
|
|
3574
3819
|
if (!(!t.value || e.key !== "Escape")) {
|
|
3575
3820
|
if (n.value) {
|
|
3576
3821
|
n.value = null;
|
|
@@ -3578,20 +3823,20 @@ var ea = X({
|
|
|
3578
3823
|
}
|
|
3579
3824
|
z(!0);
|
|
3580
3825
|
}
|
|
3581
|
-
},
|
|
3826
|
+
}, ce = (e) => {
|
|
3582
3827
|
if (e.key !== "ArrowDown" && e.key !== "ArrowUp") return;
|
|
3583
3828
|
let t = e.currentTarget;
|
|
3584
3829
|
if (!(t instanceof HTMLElement)) return;
|
|
3585
3830
|
let n = t.classList.contains("markweave-table-menu") ? t.querySelector(":scope > .markweave-table-menu-scroll") ?? t : t, r = Array.from(n.querySelectorAll(":scope > button[role=\"menuitem\"]:not(:disabled), :scope > button[role=\"menuitemradio\"]:not(:disabled)")), i = r.indexOf(document.activeElement), a = e.key === "ArrowDown" ? 1 : -1, o = i < 0 ? 0 : Math.min(r.length - 1, Math.max(0, i + a));
|
|
3586
3831
|
e.preventDefault(), e.stopPropagation(), r[o]?.focus();
|
|
3587
|
-
},
|
|
3832
|
+
}, le = (e) => {
|
|
3588
3833
|
t.value && (e.target instanceof Node && p.value?.contains(e.target) || z());
|
|
3589
3834
|
};
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
}),
|
|
3593
|
-
A(), window.removeEventListener("resize",
|
|
3594
|
-
}),
|
|
3835
|
+
fr(() => {
|
|
3836
|
+
N(), window.addEventListener("resize", N), window.addEventListener("scroll", N, !0), document.addEventListener("keydown", se), document.addEventListener("mousedown", le), document.addEventListener("dragover", ie), document.addEventListener("drop", ae);
|
|
3837
|
+
}), J(() => {
|
|
3838
|
+
A(), window.removeEventListener("resize", N), window.removeEventListener("scroll", N, !0), document.removeEventListener("keydown", se), document.removeEventListener("mousedown", le), document.removeEventListener("dragover", ie), document.removeEventListener("drop", ae);
|
|
3839
|
+
}), q(() => [
|
|
3595
3840
|
e.active,
|
|
3596
3841
|
w.value.activeCellPos,
|
|
3597
3842
|
w.value.selectionFrom,
|
|
@@ -3602,12 +3847,12 @@ var ea = X({
|
|
|
3602
3847
|
t.value,
|
|
3603
3848
|
n.value,
|
|
3604
3849
|
r.value
|
|
3605
|
-
],
|
|
3606
|
-
let
|
|
3850
|
+
], P, { flush: "post" });
|
|
3851
|
+
let ue = () => {
|
|
3607
3852
|
if (!t.value) return null;
|
|
3608
3853
|
let r = k.value.map((r, i) => {
|
|
3609
|
-
let a =
|
|
3610
|
-
return
|
|
3854
|
+
let a = Vn(r), o = i === 0 ? a : Vn(k.value[i - 1]), s = i > 0 && o !== a, c = t.value === "row" || t.value === "column" ? t.value : "selection", l = r.submenuId ? !0 : r.commandId === null ? C.value && Ne(e.editor, c) : jn(e.editor, r.commandId), u = Hn(r, e.messages), d = ga[r.icon];
|
|
3855
|
+
return U("button", {
|
|
3611
3856
|
key: `${r.id}-${i}`,
|
|
3612
3857
|
type: "button",
|
|
3613
3858
|
role: "menuitem",
|
|
@@ -3642,26 +3887,26 @@ var ea = X({
|
|
|
3642
3887
|
}
|
|
3643
3888
|
}
|
|
3644
3889
|
}, [
|
|
3645
|
-
|
|
3890
|
+
U("span", {
|
|
3646
3891
|
class: "markweave-table-menu-item-icon",
|
|
3647
3892
|
"aria-hidden": "true"
|
|
3648
|
-
}, [
|
|
3893
|
+
}, [U(d, {
|
|
3649
3894
|
size: 18,
|
|
3650
3895
|
strokeWidth: 1.8
|
|
3651
3896
|
})]),
|
|
3652
|
-
|
|
3653
|
-
r.submenuId ?
|
|
3897
|
+
U("span", { class: "markweave-table-menu-item-label" }, u),
|
|
3898
|
+
r.submenuId ? U(zr, {
|
|
3654
3899
|
class: "markweave-table-menu-chevron",
|
|
3655
3900
|
size: 16,
|
|
3656
3901
|
"aria-hidden": "true"
|
|
3657
3902
|
}) : null
|
|
3658
3903
|
]);
|
|
3659
|
-
}), i = [
|
|
3904
|
+
}), i = [U("div", {
|
|
3660
3905
|
ref: v,
|
|
3661
3906
|
class: "markweave-table-menu-scroll",
|
|
3662
3907
|
style: l.value ? { maxHeight: `${Math.max(1, l.value.maxHeight - 12)}px` } : void 0
|
|
3663
3908
|
}, r)];
|
|
3664
|
-
if (n.value === "color" && (t.value === "row" || t.value === "column") && i.push(
|
|
3909
|
+
if (n.value === "color" && (t.value === "row" || t.value === "column") && i.push(U("div", {
|
|
3665
3910
|
ref: y,
|
|
3666
3911
|
class: "markweave-table-submenu markweave-table-color-menu",
|
|
3667
3912
|
role: "menu",
|
|
@@ -3674,43 +3919,43 @@ var ea = X({
|
|
|
3674
3919
|
top: `${u.value.top}px`,
|
|
3675
3920
|
maxHeight: `${u.value.maxHeight}px`
|
|
3676
3921
|
} : void 0,
|
|
3677
|
-
onKeydown:
|
|
3922
|
+
onKeydown: ce
|
|
3678
3923
|
}, [
|
|
3679
|
-
|
|
3680
|
-
...
|
|
3924
|
+
U("div", { class: "markweave-table-submenu-title" }, e.messages.table.submenus.textColor),
|
|
3925
|
+
...Jn.map((t) => U("button", {
|
|
3681
3926
|
key: `text-${t.id}`,
|
|
3682
3927
|
type: "button",
|
|
3683
3928
|
role: "menuitemradio",
|
|
3684
|
-
"aria-checked":
|
|
3685
|
-
"data-active":
|
|
3929
|
+
"aria-checked": oe.value?.textColorId === t.id,
|
|
3930
|
+
"data-active": oe.value?.textColorId === t.id ? "true" : "false",
|
|
3686
3931
|
"data-testid": `markweave-table-text-color-${t.id}`,
|
|
3687
3932
|
onMousedown: $,
|
|
3688
|
-
onClick: () => H((n) =>
|
|
3689
|
-
}, [
|
|
3933
|
+
onClick: () => H((n) => En(e.editor, n, t.id))
|
|
3934
|
+
}, [U("span", {
|
|
3690
3935
|
class: "markweave-table-color-swatch markweave-table-text-color-swatch",
|
|
3691
3936
|
"aria-hidden": "true",
|
|
3692
3937
|
style: { backgroundColor: t.textColor ?? "var(--markweave-text)" }
|
|
3693
|
-
}),
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
...
|
|
3938
|
+
}), U("span", null, e.messages.table.colors[t.id].text)])),
|
|
3939
|
+
U("div", { class: "markweave-table-submenu-separator" }),
|
|
3940
|
+
U("div", { class: "markweave-table-submenu-title" }, e.messages.table.submenus.backgroundColor),
|
|
3941
|
+
...Jn.map((t) => U("button", {
|
|
3697
3942
|
key: `background-${t.id}`,
|
|
3698
3943
|
type: "button",
|
|
3699
3944
|
role: "menuitemradio",
|
|
3700
|
-
"aria-checked":
|
|
3701
|
-
"data-active":
|
|
3945
|
+
"aria-checked": oe.value?.backgroundColorId === t.id,
|
|
3946
|
+
"data-active": oe.value?.backgroundColorId === t.id ? "true" : "false",
|
|
3702
3947
|
"data-testid": `markweave-table-background-color-${t.id}`,
|
|
3703
3948
|
onMousedown: $,
|
|
3704
|
-
onClick: () => H((n) =>
|
|
3705
|
-
}, [
|
|
3949
|
+
onClick: () => H((n) => Tn(e.editor, n, t.id))
|
|
3950
|
+
}, [U("span", {
|
|
3706
3951
|
class: "markweave-table-color-swatch",
|
|
3707
3952
|
"aria-hidden": "true",
|
|
3708
3953
|
style: { backgroundColor: t.backgroundColor }
|
|
3709
|
-
}),
|
|
3954
|
+
}), U("span", null, e.messages.table.colors[t.id].background)]))
|
|
3710
3955
|
])), n.value === "alignment" && (t.value === "row" || t.value === "column")) {
|
|
3711
3956
|
let t = (t, n) => {
|
|
3712
|
-
let r =
|
|
3713
|
-
return
|
|
3957
|
+
let r = _a[t];
|
|
3958
|
+
return U("button", {
|
|
3714
3959
|
key: t,
|
|
3715
3960
|
type: "button",
|
|
3716
3961
|
role: "menuitemradio",
|
|
@@ -3718,14 +3963,14 @@ var ea = X({
|
|
|
3718
3963
|
"data-active": n ? "true" : "false",
|
|
3719
3964
|
"data-testid": `markweave-table-alignment-${t}`,
|
|
3720
3965
|
onMousedown: $,
|
|
3721
|
-
onClick: () => H((n) =>
|
|
3722
|
-
}, [
|
|
3966
|
+
onClick: () => H((n) => wn(e.editor, n, t))
|
|
3967
|
+
}, [U(r, {
|
|
3723
3968
|
size: 18,
|
|
3724
3969
|
strokeWidth: 1.8,
|
|
3725
3970
|
"aria-hidden": "true"
|
|
3726
|
-
}),
|
|
3971
|
+
}), U("span", null, e.messages.table.alignments[t])]);
|
|
3727
3972
|
};
|
|
3728
|
-
i.push(
|
|
3973
|
+
i.push(U("div", {
|
|
3729
3974
|
ref: y,
|
|
3730
3975
|
class: "markweave-table-submenu markweave-table-alignment-menu",
|
|
3731
3976
|
role: "menu",
|
|
@@ -3738,18 +3983,18 @@ var ea = X({
|
|
|
3738
3983
|
top: `${u.value.top}px`,
|
|
3739
3984
|
maxHeight: `${u.value.maxHeight}px`
|
|
3740
3985
|
} : void 0,
|
|
3741
|
-
onKeydown:
|
|
3986
|
+
onKeydown: ce
|
|
3742
3987
|
}, [
|
|
3743
|
-
...
|
|
3744
|
-
|
|
3745
|
-
...
|
|
3988
|
+
...Xn.map((e) => t(e, oe.value?.textAlign === e)),
|
|
3989
|
+
U("div", { class: "markweave-table-submenu-separator" }),
|
|
3990
|
+
...Qn.map((e) => t(e, oe.value?.verticalAlign === e))
|
|
3746
3991
|
]));
|
|
3747
3992
|
}
|
|
3748
|
-
return
|
|
3993
|
+
return U("div", {
|
|
3749
3994
|
ref: _,
|
|
3750
3995
|
class: "markweave-table-menu",
|
|
3751
3996
|
role: "menu",
|
|
3752
|
-
"aria-label":
|
|
3997
|
+
"aria-label": Zn(t.value, e.messages),
|
|
3753
3998
|
"data-testid": "markweave-table-menu",
|
|
3754
3999
|
"data-positioned": l.value ? "true" : "false",
|
|
3755
4000
|
"data-placement": l.value?.placement,
|
|
@@ -3758,19 +4003,19 @@ var ea = X({
|
|
|
3758
4003
|
left: `${l.value.left}px`,
|
|
3759
4004
|
top: `${l.value.top}px`
|
|
3760
4005
|
} : void 0,
|
|
3761
|
-
onKeydown:
|
|
4006
|
+
onKeydown: ce
|
|
3762
4007
|
}, i);
|
|
3763
4008
|
};
|
|
3764
|
-
return () => e.active ?
|
|
4009
|
+
return () => e.active ? U("div", {
|
|
3765
4010
|
ref: p,
|
|
3766
4011
|
class: "markweave-table-controls",
|
|
3767
4012
|
"data-testid": "markweave-table-controls",
|
|
3768
4013
|
"aria-label": e.messages.table.controlsAriaLabel,
|
|
3769
4014
|
"data-open-menu": t.value ?? "none",
|
|
3770
4015
|
"data-positioned": i.value || a.value || o.value ? "true" : "false",
|
|
3771
|
-
onMouseleave: () => e.editor.view.dispatch(e.editor.state.tr.setMeta(
|
|
4016
|
+
onMouseleave: () => e.editor.view.dispatch(e.editor.state.tr.setMeta(Cn, { type: "clear-hover" }))
|
|
3772
4017
|
}, [
|
|
3773
|
-
d.value ?
|
|
4018
|
+
d.value ? U("div", {
|
|
3774
4019
|
class: "markweave-table-copy-feedback",
|
|
3775
4020
|
role: "status",
|
|
3776
4021
|
"aria-live": "polite",
|
|
@@ -3778,8 +4023,8 @@ var ea = X({
|
|
|
3778
4023
|
"data-copy-kind": d.value.kind,
|
|
3779
4024
|
"data-text-length": d.value.textLength,
|
|
3780
4025
|
"data-html-length": d.value.htmlLength
|
|
3781
|
-
},
|
|
3782
|
-
i.value ?
|
|
4026
|
+
}, Nn(d.value)) : null,
|
|
4027
|
+
i.value ? U("button", {
|
|
3783
4028
|
ref: m,
|
|
3784
4029
|
type: "button",
|
|
3785
4030
|
draggable: !0,
|
|
@@ -3800,16 +4045,16 @@ var ea = X({
|
|
|
3800
4045
|
height: `${i.value.height}px`
|
|
3801
4046
|
},
|
|
3802
4047
|
onMousedown: $,
|
|
3803
|
-
onClick: () =>
|
|
3804
|
-
onDragstart: (e) =>
|
|
4048
|
+
onClick: () => L("row", "row-edge"),
|
|
4049
|
+
onDragstart: (e) => re("row", T.value?.index ?? 0, e),
|
|
3805
4050
|
onDragend: () => {
|
|
3806
4051
|
x = null, S = null;
|
|
3807
4052
|
}
|
|
3808
|
-
}, [
|
|
4053
|
+
}, [U(li, {
|
|
3809
4054
|
size: 14,
|
|
3810
4055
|
"aria-hidden": "true"
|
|
3811
4056
|
})]) : null,
|
|
3812
|
-
a.value ?
|
|
4057
|
+
a.value ? U("button", {
|
|
3813
4058
|
ref: h,
|
|
3814
4059
|
type: "button",
|
|
3815
4060
|
draggable: !0,
|
|
@@ -3830,16 +4075,16 @@ var ea = X({
|
|
|
3830
4075
|
height: `${a.value.height}px`
|
|
3831
4076
|
},
|
|
3832
4077
|
onMousedown: $,
|
|
3833
|
-
onClick: () =>
|
|
3834
|
-
onDragstart: (e) =>
|
|
4078
|
+
onClick: () => L("column", "column-edge"),
|
|
4079
|
+
onDragstart: (e) => re("column", E.value?.index ?? 0, e),
|
|
3835
4080
|
onDragend: () => {
|
|
3836
4081
|
x = null, S = null;
|
|
3837
4082
|
}
|
|
3838
|
-
}, [
|
|
4083
|
+
}, [U(li, {
|
|
3839
4084
|
size: 14,
|
|
3840
4085
|
"aria-hidden": "true"
|
|
3841
4086
|
})]) : null,
|
|
3842
|
-
O.value && o.value ?
|
|
4087
|
+
O.value && o.value ? U("button", {
|
|
3843
4088
|
ref: g,
|
|
3844
4089
|
type: "button",
|
|
3845
4090
|
class: "markweave-table-edge-handle markweave-table-edge-handle--selection",
|
|
@@ -3855,12 +4100,12 @@ var ea = X({
|
|
|
3855
4100
|
height: `${o.value.height}px`
|
|
3856
4101
|
},
|
|
3857
4102
|
onMousedown: $,
|
|
3858
|
-
onClick:
|
|
3859
|
-
}, [
|
|
4103
|
+
onClick: R
|
|
4104
|
+
}, [U(li, {
|
|
3860
4105
|
size: 14,
|
|
3861
4106
|
"aria-hidden": "true"
|
|
3862
4107
|
})]) : null,
|
|
3863
|
-
s.value ?
|
|
4108
|
+
s.value ? U("button", {
|
|
3864
4109
|
type: "button",
|
|
3865
4110
|
class: "markweave-table-extend-button markweave-table-extend-button--row",
|
|
3866
4111
|
"aria-label": e.messages.table.addRow,
|
|
@@ -3873,12 +4118,12 @@ var ea = X({
|
|
|
3873
4118
|
height: `${s.value.height}px`
|
|
3874
4119
|
},
|
|
3875
4120
|
onMousedown: $,
|
|
3876
|
-
onClick: () =>
|
|
3877
|
-
}, [
|
|
4121
|
+
onClick: () => ne("row")
|
|
4122
|
+
}, [U(pi, {
|
|
3878
4123
|
size: 14,
|
|
3879
4124
|
"aria-hidden": "true"
|
|
3880
4125
|
})]) : null,
|
|
3881
|
-
c.value ?
|
|
4126
|
+
c.value ? U("button", {
|
|
3882
4127
|
type: "button",
|
|
3883
4128
|
class: "markweave-table-extend-button markweave-table-extend-button--column",
|
|
3884
4129
|
"aria-label": e.messages.table.addColumn,
|
|
@@ -3891,15 +4136,15 @@ var ea = X({
|
|
|
3891
4136
|
height: `${c.value.height}px`
|
|
3892
4137
|
},
|
|
3893
4138
|
onMousedown: $,
|
|
3894
|
-
onClick: () =>
|
|
3895
|
-
}, [
|
|
4139
|
+
onClick: () => ne("column")
|
|
4140
|
+
}, [U(pi, {
|
|
3896
4141
|
size: 14,
|
|
3897
4142
|
"aria-hidden": "true"
|
|
3898
4143
|
})]) : null,
|
|
3899
|
-
|
|
4144
|
+
ue()
|
|
3900
4145
|
]) : null;
|
|
3901
4146
|
}
|
|
3902
|
-
}),
|
|
4147
|
+
}), ya = X({
|
|
3903
4148
|
name: "MarkweaveVueTableSelectionOverlay",
|
|
3904
4149
|
props: {
|
|
3905
4150
|
editor: {
|
|
@@ -3912,18 +4157,18 @@ var ea = X({
|
|
|
3912
4157
|
}
|
|
3913
4158
|
},
|
|
3914
4159
|
setup(e) {
|
|
3915
|
-
let t =
|
|
4160
|
+
let t = W(null), n = () => {
|
|
3916
4161
|
if (e.focusState.mode !== "cell-selection") {
|
|
3917
4162
|
t.value = null;
|
|
3918
4163
|
return;
|
|
3919
4164
|
}
|
|
3920
|
-
t.value =
|
|
4165
|
+
t.value = Gn(e.editor, xn(e.editor.state));
|
|
3921
4166
|
};
|
|
3922
|
-
return
|
|
4167
|
+
return fr(() => {
|
|
3923
4168
|
n(), window.addEventListener("resize", n), window.addEventListener("scroll", n, !0);
|
|
3924
|
-
}),
|
|
4169
|
+
}), J(() => {
|
|
3925
4170
|
window.removeEventListener("resize", n), window.removeEventListener("scroll", n, !0);
|
|
3926
|
-
}),
|
|
4171
|
+
}), q(() => [
|
|
3927
4172
|
e.focusState.activeCellPos,
|
|
3928
4173
|
e.focusState.anchorCellPos,
|
|
3929
4174
|
e.focusState.mode,
|
|
@@ -3934,7 +4179,7 @@ var ea = X({
|
|
|
3934
4179
|
Y(n);
|
|
3935
4180
|
}, { flush: "post" }), () => {
|
|
3936
4181
|
let e = t.value;
|
|
3937
|
-
return e ?
|
|
4182
|
+
return e ? U("div", {
|
|
3938
4183
|
"aria-hidden": "true",
|
|
3939
4184
|
class: "markweave-table-selection-overlay",
|
|
3940
4185
|
"data-axis-target": e.axisTarget ?? "none",
|
|
@@ -3956,7 +4201,7 @@ var ea = X({
|
|
|
3956
4201
|
}) : null;
|
|
3957
4202
|
};
|
|
3958
4203
|
}
|
|
3959
|
-
}),
|
|
4204
|
+
}), ba = X({
|
|
3960
4205
|
name: "MarkweaveVueCodeBlockControls",
|
|
3961
4206
|
props: {
|
|
3962
4207
|
editor: {
|
|
@@ -3985,53 +4230,53 @@ var ea = X({
|
|
|
3985
4230
|
}
|
|
3986
4231
|
},
|
|
3987
4232
|
setup(e) {
|
|
3988
|
-
let t =
|
|
4233
|
+
let t = W(null), n = W(null), r = W(null), i = W(null), a = W(null), o = W(null), s = W(null), c = W(null), l = W([]), u = W(null), d = W(!1), f = W(""), p = W(-1), m = W(null), h = W(!1), g = W(null), _ = W(null), v = W(!1), y = W({
|
|
3989
4234
|
active: !1,
|
|
3990
4235
|
lastX: 0,
|
|
3991
4236
|
lastY: 0
|
|
3992
|
-
}), b =
|
|
4237
|
+
}), b = W(0), x = W(0), S = W(0), C = null, w = K(() => (S.value, Ot(e.editor, s.value))), T = K(() => !e.readOnly && e.active && e.state.active && e.state.pos !== null ? {
|
|
3993
4238
|
...e.state,
|
|
3994
4239
|
pos: e.state.pos,
|
|
3995
4240
|
active: !0
|
|
3996
|
-
} : null), E =
|
|
4241
|
+
} : null), E = K(() => w.value ?? T.value), D = K(() => E.value !== null), O = K(() => E.value?.language === "mermaid"), k = K(() => Nt(e.editor, E.value)), A = K(() => D.value && E.value !== null && !k.value), j = K(() => !e.readOnly), ee = K(() => E.value ? xt(E.value.language) : xt("text")), te = K(() => m.value?.status ?? "idle"), M = K(() => E.value?.mermaidPreviewMode ?? e.mermaidMode), N = K(() => O.value && M.value === "preview"), P = K(() => (S.value, b.value, x.value, jt(e.editor))), F = K(() => `${x.value}|${P.value.map((e) => `${e.pos}:${e.mermaidPreviewMode}:${e.text.length}`).join("|")}`), I = K(() => Tt(f.value)), L = K(() => E.value ? `${E.value.pos}:${E.value.language}:${E.value.text}` : "none"), R = () => {
|
|
3997
4242
|
C !== null && (window.clearTimeout(C), C = null);
|
|
3998
4243
|
}, z = (e) => {
|
|
3999
|
-
|
|
4244
|
+
R(), m.value = e, e && (C = window.setTimeout(() => {
|
|
4000
4245
|
m.value = null, C = null;
|
|
4001
|
-
},
|
|
4246
|
+
}, mt));
|
|
4002
4247
|
}, B = () => {
|
|
4003
4248
|
g.value = null, _.value = null, v.value = !1, y.value = {
|
|
4004
4249
|
active: !1,
|
|
4005
4250
|
lastX: 0,
|
|
4006
4251
|
lastY: 0
|
|
4007
4252
|
}, e.editor.view.focus();
|
|
4008
|
-
},
|
|
4253
|
+
}, V = () => {
|
|
4009
4254
|
let n = t.value;
|
|
4010
4255
|
if (!n) return;
|
|
4011
|
-
if (!
|
|
4256
|
+
if (!kt(n) || P.value.length === 0) {
|
|
4012
4257
|
l.value = [];
|
|
4013
4258
|
return;
|
|
4014
4259
|
}
|
|
4015
|
-
let r = n.getBoundingClientRect(), i =
|
|
4016
|
-
let n =
|
|
4017
|
-
return n ? [
|
|
4260
|
+
let r = n.getBoundingClientRect(), i = P.value.flatMap((t) => {
|
|
4261
|
+
let n = wt(Ct(e.editor, t.pos, t.mermaidPreviewMode), r);
|
|
4262
|
+
return n ? [yt(t, n, r)] : [];
|
|
4018
4263
|
});
|
|
4019
|
-
l.value =
|
|
4020
|
-
},
|
|
4264
|
+
l.value = Pt(l.value, i, P.value.map((e) => e.pos));
|
|
4265
|
+
}, H = () => {
|
|
4021
4266
|
if (!A.value || !E.value) {
|
|
4022
4267
|
c.value = null, u.value = null;
|
|
4023
4268
|
return;
|
|
4024
4269
|
}
|
|
4025
4270
|
let i = t.value;
|
|
4026
4271
|
if (!i) return;
|
|
4027
|
-
let a =
|
|
4272
|
+
let a = Ct(e.editor, E.value.pos, M.value), o = i.getBoundingClientRect(), s = wt(a, o);
|
|
4028
4273
|
if (!s) {
|
|
4029
4274
|
c.value = c.value?.pos === E.value.pos ? c.value : null, u.value = d.value ? u.value : null;
|
|
4030
4275
|
return;
|
|
4031
4276
|
}
|
|
4032
|
-
if (c.value =
|
|
4277
|
+
if (c.value = _t(E.value.pos, s, o), d.value && n.value) {
|
|
4033
4278
|
let e = n.value.getBoundingClientRect(), t = r.value?.getBoundingClientRect().height;
|
|
4034
|
-
u.value =
|
|
4279
|
+
u.value = ft({
|
|
4035
4280
|
overlayRect: o,
|
|
4036
4281
|
buttonRect: e,
|
|
4037
4282
|
menuHeight: t,
|
|
@@ -4042,81 +4287,81 @@ var ea = X({
|
|
|
4042
4287
|
}, ne = async () => {
|
|
4043
4288
|
if (e.readOnly) {
|
|
4044
4289
|
if (!E.value) return;
|
|
4045
|
-
let e = await
|
|
4046
|
-
z(
|
|
4290
|
+
let e = await ht(E.value.text);
|
|
4291
|
+
z(st(E.value, e ? "copied" : "failed"));
|
|
4047
4292
|
return;
|
|
4048
4293
|
}
|
|
4049
|
-
if (!
|
|
4050
|
-
let t = await
|
|
4051
|
-
z(
|
|
4294
|
+
if (!bt(e.editor, E.value)) return;
|
|
4295
|
+
let t = await at(e.editor);
|
|
4296
|
+
z(st(ot(e.editor), t ? "copied" : "failed")), e.editor.view.focus();
|
|
4052
4297
|
}, re = (t, n) => {
|
|
4053
4298
|
if (e.readOnly) {
|
|
4054
|
-
|
|
4299
|
+
tn(e.editor, t.pos, n) && (x.value += 1, S.value += 1);
|
|
4055
4300
|
return;
|
|
4056
4301
|
}
|
|
4057
4302
|
let r = e.state.active && e.state.pos === t.pos;
|
|
4058
|
-
|
|
4303
|
+
dt(e.editor, t.pos, n) && (e.onMermaidModeChange(n), S.value += 1, r && e.editor.view.focus());
|
|
4059
4304
|
}, ie = (t) => {
|
|
4060
4305
|
if (e.readOnly || !E.value) return;
|
|
4061
4306
|
let n = e.state.active && e.state.pos === E.value.pos;
|
|
4062
|
-
|
|
4063
|
-
},
|
|
4064
|
-
d.value = !d.value, d.value && o.value === null && (o.value =
|
|
4065
|
-
},
|
|
4066
|
-
let t =
|
|
4067
|
-
f.value = e, p.value =
|
|
4068
|
-
},
|
|
4307
|
+
ut(e.editor, E.value.pos, t) && (t === "mermaid" && dt(e.editor, E.value.pos, "preview") && e.onMermaidModeChange("preview"), d.value = !1, f.value = "", p.value = -1, S.value += 1, n && e.editor.view.focus());
|
|
4308
|
+
}, ae = () => {
|
|
4309
|
+
d.value = !d.value, d.value && o.value === null && (o.value = gt()), p.value = d.value ? At(I.value, E.value?.language ?? null) : -1;
|
|
4310
|
+
}, se = (e) => {
|
|
4311
|
+
let t = Tt(e);
|
|
4312
|
+
f.value = e, p.value = At(t, e.trim() ? null : E.value?.language ?? null);
|
|
4313
|
+
}, ce = (t) => {
|
|
4069
4314
|
if (!t.isComposing) {
|
|
4070
4315
|
if (t.key === "ArrowDown" || t.key === "ArrowUp") {
|
|
4071
|
-
t.preventDefault(), p.value =
|
|
4316
|
+
t.preventDefault(), p.value = It(p.value, I.value.length, t.key === "ArrowUp" ? "previous" : "next");
|
|
4072
4317
|
return;
|
|
4073
4318
|
}
|
|
4074
4319
|
if (t.key === "Enter") {
|
|
4075
|
-
let e =
|
|
4320
|
+
let e = I.value[p.value];
|
|
4076
4321
|
e && (t.preventDefault(), ie(e.language));
|
|
4077
4322
|
return;
|
|
4078
4323
|
}
|
|
4079
4324
|
t.key === "Escape" && (t.preventDefault(), d.value = !1, p.value = -1, e.editor.view.focus());
|
|
4080
4325
|
}
|
|
4081
|
-
},
|
|
4082
|
-
e.readOnly || !E.value ||
|
|
4083
|
-
},
|
|
4326
|
+
}, le = () => {
|
|
4327
|
+
e.readOnly || !E.value || lt(e.editor, E.value.pos, !k.value) && (b.value += 1, S.value += 1, s.value = null);
|
|
4328
|
+
}, ue = () => {
|
|
4084
4329
|
if (!E.value) return;
|
|
4085
|
-
let t =
|
|
4086
|
-
t &&
|
|
4330
|
+
let t = Mt(e.editor, E.value.pos);
|
|
4331
|
+
t && oe({
|
|
4087
4332
|
data: new Blob([t], { type: "image/svg+xml" }),
|
|
4088
4333
|
fileName: "markweave-mermaid.svg",
|
|
4089
4334
|
onSettled: () => e.editor.view.focus(),
|
|
4090
4335
|
ownerDocument: document
|
|
4091
4336
|
});
|
|
4092
|
-
},
|
|
4337
|
+
}, de = () => {
|
|
4093
4338
|
if (!E.value) return;
|
|
4094
|
-
let t =
|
|
4095
|
-
t && (g.value =
|
|
4339
|
+
let t = Mt(e.editor, E.value.pos);
|
|
4340
|
+
t && (g.value = vt(t), _.value = null, v.value = !1, y.value = {
|
|
4096
4341
|
active: !1,
|
|
4097
4342
|
lastX: 0,
|
|
4098
4343
|
lastY: 0
|
|
4099
4344
|
});
|
|
4100
|
-
},
|
|
4345
|
+
}, fe = (e) => {
|
|
4101
4346
|
g.value = g.value ? {
|
|
4102
4347
|
...g.value,
|
|
4103
|
-
scale:
|
|
4348
|
+
scale: pt(g.value.scale + e)
|
|
4104
4349
|
} : null;
|
|
4105
|
-
},
|
|
4106
|
-
g.value = g.value ?
|
|
4350
|
+
}, pe = () => {
|
|
4351
|
+
g.value = g.value ? vt(g.value.svg) : null, y.value = {
|
|
4107
4352
|
active: !1,
|
|
4108
4353
|
lastX: 0,
|
|
4109
4354
|
lastY: 0
|
|
4110
4355
|
}, v.value = !1;
|
|
4111
|
-
},
|
|
4112
|
-
e.preventDefault(),
|
|
4113
|
-
},
|
|
4356
|
+
}, me = (e) => {
|
|
4357
|
+
e.preventDefault(), fe(e.deltaY < 0 ? Ft : -Ft);
|
|
4358
|
+
}, he = (e) => {
|
|
4114
4359
|
e.button === 0 && (e.preventDefault(), y.value = {
|
|
4115
4360
|
active: !0,
|
|
4116
4361
|
lastX: e.clientX,
|
|
4117
4362
|
lastY: e.clientY
|
|
4118
4363
|
}, v.value = !0);
|
|
4119
|
-
},
|
|
4364
|
+
}, ge = (e) => {
|
|
4120
4365
|
let t = y.value;
|
|
4121
4366
|
if (!t.active) return;
|
|
4122
4367
|
let n = e.clientX - t.lastX, r = e.clientY - t.lastY;
|
|
@@ -4124,25 +4369,25 @@ var ea = X({
|
|
|
4124
4369
|
active: !0,
|
|
4125
4370
|
lastX: e.clientX,
|
|
4126
4371
|
lastY: e.clientY
|
|
4127
|
-
}, g.value =
|
|
4128
|
-
},
|
|
4372
|
+
}, g.value = Lt(g.value, n, r);
|
|
4373
|
+
}, _e = () => {
|
|
4129
4374
|
y.value = {
|
|
4130
4375
|
active: !1,
|
|
4131
4376
|
lastX: 0,
|
|
4132
4377
|
lastY: 0
|
|
4133
4378
|
}, v.value = !1;
|
|
4134
4379
|
};
|
|
4135
|
-
|
|
4380
|
+
q(() => e.readOnly, (e) => {
|
|
4136
4381
|
e && (d.value = !1, f.value = "");
|
|
4137
|
-
}),
|
|
4382
|
+
}), q(L, () => {
|
|
4138
4383
|
z(null), d.value = !1, f.value = "", p.value = -1, g.value = null, _.value = null, v.value = !1;
|
|
4139
|
-
}),
|
|
4384
|
+
}), q(d, async (e) => {
|
|
4140
4385
|
if (!e) {
|
|
4141
4386
|
p.value = -1;
|
|
4142
4387
|
return;
|
|
4143
4388
|
}
|
|
4144
|
-
await Y(),
|
|
4145
|
-
}),
|
|
4389
|
+
await Y(), H(), i.value?.focus({ preventScroll: !0 });
|
|
4390
|
+
}), q(() => [
|
|
4146
4391
|
d.value,
|
|
4147
4392
|
f.value,
|
|
4148
4393
|
p.value
|
|
@@ -4150,31 +4395,31 @@ var ea = X({
|
|
|
4150
4395
|
if (!d.value || p.value < 0) return;
|
|
4151
4396
|
await Y();
|
|
4152
4397
|
let e = a.value, t = e?.querySelector(`[data-language-index="${p.value}"]`);
|
|
4153
|
-
e && t &&
|
|
4154
|
-
}, { flush: "post" }),
|
|
4398
|
+
e && t && Rt(e, t);
|
|
4399
|
+
}, { flush: "post" }), q(() => [
|
|
4155
4400
|
A.value,
|
|
4156
4401
|
b.value,
|
|
4157
4402
|
E.value?.pos ?? null,
|
|
4158
|
-
|
|
4403
|
+
I.value.length,
|
|
4159
4404
|
d.value,
|
|
4160
|
-
|
|
4405
|
+
M.value
|
|
4161
4406
|
], async () => {
|
|
4162
|
-
await Y(),
|
|
4407
|
+
await Y(), H();
|
|
4163
4408
|
}, {
|
|
4164
4409
|
flush: "post",
|
|
4165
4410
|
immediate: !0
|
|
4166
|
-
}),
|
|
4167
|
-
await Y(),
|
|
4411
|
+
}), q(F, async () => {
|
|
4412
|
+
await Y(), V(), window.requestAnimationFrame(V);
|
|
4168
4413
|
}, {
|
|
4169
4414
|
flush: "post",
|
|
4170
4415
|
immediate: !0
|
|
4171
4416
|
});
|
|
4172
|
-
let
|
|
4173
|
-
return
|
|
4417
|
+
let ve = null;
|
|
4418
|
+
return fr(() => {
|
|
4174
4419
|
Y(() => {
|
|
4175
4420
|
let n = e.editor.view.dom.closest(".markweave-editor-frame"), r = (n) => {
|
|
4176
4421
|
if (n.target instanceof Node && t.value?.contains(n.target) || d.value) return;
|
|
4177
|
-
let r =
|
|
4422
|
+
let r = Dt(e.editor, n.target), i = Ot(e.editor, r), a = i && !Nt(e.editor, i) ? i.pos : null;
|
|
4178
4423
|
s.value = s.value === a ? s.value : a;
|
|
4179
4424
|
}, i = () => {
|
|
4180
4425
|
d.value || (s.value = null);
|
|
@@ -4189,16 +4434,16 @@ var ea = X({
|
|
|
4189
4434
|
}, o = (e) => {
|
|
4190
4435
|
d.value && (e.target instanceof Node && t.value?.contains(e.target) || (d.value = !1, p.value = -1));
|
|
4191
4436
|
}, c = ({ transaction: e }) => {
|
|
4192
|
-
e.getMeta(
|
|
4437
|
+
e.getMeta(it) && (b.value += 1), (e.docChanged || e.selectionSet || e.getMeta(it) || Qt(e)) && (S.value += 1);
|
|
4193
4438
|
};
|
|
4194
|
-
n?.addEventListener("mousemove", r), n?.addEventListener("mouseleave", i), window.addEventListener("resize",
|
|
4195
|
-
n?.removeEventListener("mousemove", r), n?.removeEventListener("mouseleave", i), window.removeEventListener("resize",
|
|
4439
|
+
n?.addEventListener("mousemove", r), n?.addEventListener("mouseleave", i), window.addEventListener("resize", H), window.addEventListener("scroll", H, !0), window.addEventListener("resize", V), window.addEventListener("scroll", V, !0), document.addEventListener("keydown", a), document.addEventListener("mousedown", o), e.editor.on("transaction", c), ve = () => {
|
|
4440
|
+
n?.removeEventListener("mousemove", r), n?.removeEventListener("mouseleave", i), window.removeEventListener("resize", H), window.removeEventListener("scroll", H, !0), window.removeEventListener("resize", V), window.removeEventListener("scroll", V, !0), document.removeEventListener("keydown", a), document.removeEventListener("mousedown", o), e.editor.off("transaction", c), R();
|
|
4196
4441
|
};
|
|
4197
4442
|
});
|
|
4198
|
-
}),
|
|
4199
|
-
|
|
4443
|
+
}), J(() => {
|
|
4444
|
+
ve?.(), ve = null, R();
|
|
4200
4445
|
}), () => {
|
|
4201
|
-
if (!A.value &&
|
|
4446
|
+
if (!A.value && P.value.length === 0 && !g.value) return null;
|
|
4202
4447
|
let s = c.value ? {
|
|
4203
4448
|
top: `${c.value.top}px`,
|
|
4204
4449
|
right: `${c.value.right}px`
|
|
@@ -4206,15 +4451,15 @@ var ea = X({
|
|
|
4206
4451
|
left: `${u.value.left}px`,
|
|
4207
4452
|
top: `${u.value.top}px`
|
|
4208
4453
|
} : void 0;
|
|
4209
|
-
return
|
|
4454
|
+
return U("div", {
|
|
4210
4455
|
ref: t,
|
|
4211
4456
|
class: "markweave-codeblock-overlay",
|
|
4212
4457
|
"data-testid": "markweave-codeblock-overlay",
|
|
4213
4458
|
"data-read-only": e.readOnly ? "true" : "false"
|
|
4214
4459
|
}, [
|
|
4215
|
-
...
|
|
4460
|
+
...P.value.map((e) => {
|
|
4216
4461
|
let t = l.value.find((t) => t.pos === e.pos);
|
|
4217
|
-
return
|
|
4462
|
+
return U("div", {
|
|
4218
4463
|
key: e.pos,
|
|
4219
4464
|
class: "markweave-mermaid-tabs",
|
|
4220
4465
|
"data-testid": "markweave-mermaid-tabs",
|
|
@@ -4224,7 +4469,7 @@ var ea = X({
|
|
|
4224
4469
|
top: `${t.top}px`,
|
|
4225
4470
|
left: `${t.left}px`
|
|
4226
4471
|
} : void 0
|
|
4227
|
-
}, ["code", "preview"].map((t) =>
|
|
4472
|
+
}, ["code", "preview"].map((t) => U("button", {
|
|
4228
4473
|
key: t,
|
|
4229
4474
|
type: "button",
|
|
4230
4475
|
"data-testid": `markweave-mermaid-mode-${t}`,
|
|
@@ -4233,7 +4478,7 @@ var ea = X({
|
|
|
4233
4478
|
onClick: () => re(e, t)
|
|
4234
4479
|
}, t === "code" ? "Code" : "Preview")));
|
|
4235
4480
|
}),
|
|
4236
|
-
A.value && E.value ?
|
|
4481
|
+
A.value && E.value ? U("div", {
|
|
4237
4482
|
class: "markweave-codeblock-controls",
|
|
4238
4483
|
"data-testid": "markweave-codeblock-controls",
|
|
4239
4484
|
"data-positioned": c.value ? "true" : "false",
|
|
@@ -4242,11 +4487,11 @@ var ea = X({
|
|
|
4242
4487
|
"aria-label": "Code block controls",
|
|
4243
4488
|
style: s
|
|
4244
4489
|
}, [
|
|
4245
|
-
e.readOnly ?
|
|
4490
|
+
e.readOnly ? U("span", {
|
|
4246
4491
|
class: "markweave-codeblock-language-button markweave-codeblock-language-label",
|
|
4247
4492
|
"aria-label": "Code block language",
|
|
4248
4493
|
"data-testid": "markweave-codeblock-language"
|
|
4249
|
-
}, [
|
|
4494
|
+
}, [U("span", null, ee.value)]) : U("button", {
|
|
4250
4495
|
ref: n,
|
|
4251
4496
|
type: "button",
|
|
4252
4497
|
class: "markweave-codeblock-language-button",
|
|
@@ -4255,9 +4500,9 @@ var ea = X({
|
|
|
4255
4500
|
"aria-haspopup": "listbox",
|
|
4256
4501
|
"data-testid": "markweave-codeblock-language",
|
|
4257
4502
|
onMousedown: $,
|
|
4258
|
-
onClick:
|
|
4259
|
-
}, [
|
|
4260
|
-
j.value ?
|
|
4503
|
+
onClick: ae
|
|
4504
|
+
}, [U("span", null, ee.value), oa("chevron")]),
|
|
4505
|
+
j.value ? U("button", {
|
|
4261
4506
|
type: "button",
|
|
4262
4507
|
class: "markweave-codeblock-icon-button markweave-codeblock-collapse-button",
|
|
4263
4508
|
"aria-label": k.value ? "Expand code block" : "Collapse code block",
|
|
@@ -4265,14 +4510,14 @@ var ea = X({
|
|
|
4265
4510
|
"data-testid": "markweave-codeblock-collapse",
|
|
4266
4511
|
"data-collapsed": k.value ? "true" : "false",
|
|
4267
4512
|
onMousedown: $,
|
|
4268
|
-
onClick:
|
|
4269
|
-
}, [
|
|
4270
|
-
|
|
4513
|
+
onClick: le
|
|
4514
|
+
}, [oa("chevron")]) : null,
|
|
4515
|
+
U("span", { class: "markweave-codeblock-copy-wrap" }, [U("button", {
|
|
4271
4516
|
type: "button",
|
|
4272
4517
|
class: "markweave-codeblock-icon-button",
|
|
4273
4518
|
"aria-label": "Copy to clipboard",
|
|
4274
4519
|
"data-testid": "markweave-codeblock-copy",
|
|
4275
|
-
"data-copy-state":
|
|
4520
|
+
"data-copy-state": te.value,
|
|
4276
4521
|
onMousedown: $,
|
|
4277
4522
|
onMouseenter: () => {
|
|
4278
4523
|
h.value = !0;
|
|
@@ -4289,64 +4534,64 @@ var ea = X({
|
|
|
4289
4534
|
onClick: () => {
|
|
4290
4535
|
ne();
|
|
4291
4536
|
}
|
|
4292
|
-
}, [
|
|
4537
|
+
}, [oa(te.value === "copied" ? "check" : "clipboard")]), h.value ? U("span", {
|
|
4293
4538
|
class: "markweave-codeblock-tooltip",
|
|
4294
4539
|
role: "tooltip",
|
|
4295
4540
|
"data-testid": "markweave-codeblock-copy-tooltip"
|
|
4296
4541
|
}, "Copy to clipboard") : null]),
|
|
4297
|
-
O.value &&
|
|
4542
|
+
O.value && M.value === "preview" ? U("div", {
|
|
4298
4543
|
class: "markweave-mermaid-preview-actions",
|
|
4299
4544
|
"data-testid": "markweave-mermaid-preview-actions"
|
|
4300
|
-
}, [
|
|
4545
|
+
}, [U("button", {
|
|
4301
4546
|
type: "button",
|
|
4302
4547
|
class: "markweave-codeblock-icon-button",
|
|
4303
4548
|
"aria-label": "Fullscreen Mermaid preview",
|
|
4304
4549
|
"data-testid": "markweave-mermaid-fullscreen",
|
|
4305
|
-
disabled: !
|
|
4550
|
+
disabled: !N.value,
|
|
4306
4551
|
onMousedown: $,
|
|
4307
|
-
onClick:
|
|
4308
|
-
}, [
|
|
4552
|
+
onClick: de
|
|
4553
|
+
}, [oa("expand")]), U("button", {
|
|
4309
4554
|
type: "button",
|
|
4310
4555
|
class: "markweave-codeblock-icon-button",
|
|
4311
4556
|
"aria-label": "Download Mermaid SVG",
|
|
4312
4557
|
"data-testid": "markweave-mermaid-download",
|
|
4313
|
-
disabled: !
|
|
4558
|
+
disabled: !N.value,
|
|
4314
4559
|
onMousedown: $,
|
|
4315
|
-
onClick:
|
|
4316
|
-
}, [
|
|
4560
|
+
onClick: ue
|
|
4561
|
+
}, [oa("download")])]) : null
|
|
4317
4562
|
]) : null,
|
|
4318
|
-
j.value && A.value && d.value && E.value ?
|
|
4563
|
+
j.value && A.value && d.value && E.value ? U("div", {
|
|
4319
4564
|
ref: r,
|
|
4320
4565
|
class: "markweave-codeblock-language-menu",
|
|
4321
4566
|
"data-testid": "markweave-codeblock-language-menu",
|
|
4322
4567
|
"data-positioned": u.value ? "true" : "false",
|
|
4323
4568
|
style: m
|
|
4324
|
-
}, [
|
|
4569
|
+
}, [U("label", { class: "markweave-codeblock-language-search" }, [U("input", {
|
|
4325
4570
|
ref: i,
|
|
4326
4571
|
role: "combobox",
|
|
4327
4572
|
"aria-autocomplete": "list",
|
|
4328
4573
|
"aria-controls": o.value ?? void 0,
|
|
4329
4574
|
"aria-expanded": "true",
|
|
4330
|
-
"aria-activedescendant": o.value &&
|
|
4575
|
+
"aria-activedescendant": o.value && I.value[p.value] ? Et(o.value, I.value[p.value].language) : void 0,
|
|
4331
4576
|
"aria-label": "Search code block languages",
|
|
4332
4577
|
value: f.value,
|
|
4333
4578
|
placeholder: "Search...",
|
|
4334
4579
|
"data-testid": "markweave-codeblock-language-search",
|
|
4335
4580
|
onInput: (e) => {
|
|
4336
|
-
|
|
4581
|
+
se(e.target.value);
|
|
4337
4582
|
},
|
|
4338
|
-
onKeydown:
|
|
4339
|
-
}),
|
|
4583
|
+
onKeydown: ce
|
|
4584
|
+
}), oa("search")]), U("div", {
|
|
4340
4585
|
ref: a,
|
|
4341
4586
|
id: o.value ?? void 0,
|
|
4342
4587
|
class: "markweave-codeblock-language-list",
|
|
4343
4588
|
role: "listbox",
|
|
4344
4589
|
"aria-label": "Code block languages"
|
|
4345
|
-
},
|
|
4590
|
+
}, I.value.map((e, t) => {
|
|
4346
4591
|
let n = E.value?.language === e.language, r = t === p.value;
|
|
4347
|
-
return
|
|
4592
|
+
return U("button", {
|
|
4348
4593
|
key: e.language,
|
|
4349
|
-
id: o.value ?
|
|
4594
|
+
id: o.value ? Et(o.value, e.language) : void 0,
|
|
4350
4595
|
type: "button",
|
|
4351
4596
|
role: "option",
|
|
4352
4597
|
"aria-selected": n ? "true" : "false",
|
|
@@ -4359,20 +4604,20 @@ var ea = X({
|
|
|
4359
4604
|
p.value = t;
|
|
4360
4605
|
},
|
|
4361
4606
|
onClick: () => ie(e.language)
|
|
4362
|
-
}, [
|
|
4607
|
+
}, [U("span", null, e.label), n ? oa("check") : null]);
|
|
4363
4608
|
}))]) : null,
|
|
4364
|
-
g.value ?
|
|
4609
|
+
g.value ? U("div", {
|
|
4365
4610
|
class: "markweave-mermaid-fullscreen-layer",
|
|
4366
4611
|
role: "dialog",
|
|
4367
4612
|
"aria-modal": "true",
|
|
4368
4613
|
"aria-label": "Mermaid preview",
|
|
4369
4614
|
"data-testid": "markweave-mermaid-fullscreen-layer"
|
|
4370
4615
|
}, [
|
|
4371
|
-
|
|
4616
|
+
U("div", {
|
|
4372
4617
|
class: "markweave-mermaid-fullscreen-toolbar",
|
|
4373
4618
|
"data-testid": "markweave-mermaid-fullscreen-toolbar"
|
|
4374
4619
|
}, [
|
|
4375
|
-
|
|
4620
|
+
U("button", {
|
|
4376
4621
|
type: "button",
|
|
4377
4622
|
class: "markweave-mermaid-fullscreen-control",
|
|
4378
4623
|
"aria-label": "Zoom out",
|
|
@@ -4389,13 +4634,13 @@ var ea = X({
|
|
|
4389
4634
|
onBlur: () => {
|
|
4390
4635
|
_.value = null;
|
|
4391
4636
|
},
|
|
4392
|
-
onClick: () =>
|
|
4393
|
-
}, [
|
|
4394
|
-
|
|
4637
|
+
onClick: () => fe(-Ft)
|
|
4638
|
+
}, [oa("zoomOut")]),
|
|
4639
|
+
U("span", {
|
|
4395
4640
|
class: "markweave-mermaid-fullscreen-zoom-label",
|
|
4396
4641
|
"data-testid": "markweave-mermaid-fullscreen-zoom-label"
|
|
4397
|
-
},
|
|
4398
|
-
|
|
4642
|
+
}, St(g.value.scale)),
|
|
4643
|
+
U("button", {
|
|
4399
4644
|
type: "button",
|
|
4400
4645
|
class: "markweave-mermaid-fullscreen-control",
|
|
4401
4646
|
"aria-label": "Zoom in",
|
|
@@ -4412,9 +4657,9 @@ var ea = X({
|
|
|
4412
4657
|
onBlur: () => {
|
|
4413
4658
|
_.value = null;
|
|
4414
4659
|
},
|
|
4415
|
-
onClick: () =>
|
|
4416
|
-
}, [
|
|
4417
|
-
|
|
4660
|
+
onClick: () => fe(Ft)
|
|
4661
|
+
}, [oa("zoomIn")]),
|
|
4662
|
+
U("button", {
|
|
4418
4663
|
type: "button",
|
|
4419
4664
|
class: "markweave-mermaid-fullscreen-control",
|
|
4420
4665
|
"aria-label": "Reset zoom",
|
|
@@ -4431,31 +4676,31 @@ var ea = X({
|
|
|
4431
4676
|
onBlur: () => {
|
|
4432
4677
|
_.value = null;
|
|
4433
4678
|
},
|
|
4434
|
-
onClick:
|
|
4435
|
-
}, [
|
|
4436
|
-
_.value ?
|
|
4679
|
+
onClick: pe
|
|
4680
|
+
}, [oa("reset")]),
|
|
4681
|
+
_.value ? U("span", {
|
|
4437
4682
|
class: "markweave-mermaid-fullscreen-tooltip",
|
|
4438
4683
|
role: "tooltip",
|
|
4439
4684
|
"data-testid": "markweave-mermaid-fullscreen-tooltip"
|
|
4440
4685
|
}, _.value === "zoom-out" ? "Zoom out" : _.value === "zoom-in" ? "Zoom in" : "Reset") : null
|
|
4441
4686
|
]),
|
|
4442
|
-
|
|
4687
|
+
U("button", {
|
|
4443
4688
|
type: "button",
|
|
4444
4689
|
class: "markweave-mermaid-fullscreen-close",
|
|
4445
4690
|
"aria-label": "Close fullscreen Mermaid preview",
|
|
4446
4691
|
"data-testid": "markweave-mermaid-fullscreen-close",
|
|
4447
4692
|
onClick: B
|
|
4448
|
-
}, [
|
|
4449
|
-
|
|
4693
|
+
}, [oa("close")]),
|
|
4694
|
+
U("div", {
|
|
4450
4695
|
class: "markweave-mermaid-fullscreen-viewport",
|
|
4451
4696
|
"data-testid": "markweave-mermaid-fullscreen-viewport",
|
|
4452
4697
|
"data-dragging": v.value ? "true" : "false",
|
|
4453
|
-
onWheel:
|
|
4454
|
-
onMousedown:
|
|
4455
|
-
onMousemove:
|
|
4456
|
-
onMouseup:
|
|
4457
|
-
onMouseleave:
|
|
4458
|
-
}, [
|
|
4698
|
+
onWheel: me,
|
|
4699
|
+
onMousedown: he,
|
|
4700
|
+
onMousemove: ge,
|
|
4701
|
+
onMouseup: _e,
|
|
4702
|
+
onMouseleave: _e
|
|
4703
|
+
}, [U("div", {
|
|
4459
4704
|
class: "markweave-mermaid-fullscreen-content",
|
|
4460
4705
|
"data-testid": "markweave-mermaid-fullscreen-content",
|
|
4461
4706
|
"data-scale-percent": Math.round(g.value.scale * 100),
|
|
@@ -4471,7 +4716,7 @@ var ea = X({
|
|
|
4471
4716
|
]);
|
|
4472
4717
|
};
|
|
4473
4718
|
}
|
|
4474
|
-
}),
|
|
4719
|
+
}), xa = X({
|
|
4475
4720
|
name: "MarkweaveVueInnerToc",
|
|
4476
4721
|
props: {
|
|
4477
4722
|
editor: {
|
|
@@ -4496,23 +4741,29 @@ var ea = X({
|
|
|
4496
4741
|
}
|
|
4497
4742
|
},
|
|
4498
4743
|
setup(e) {
|
|
4499
|
-
let t =
|
|
4500
|
-
n?.(), n = e.placement === "container" && t.value ?
|
|
4744
|
+
let t = W(null), n, r, i = () => {
|
|
4745
|
+
n?.(), n = e.placement === "container" && t.value ? tt(t.value) : void 0;
|
|
4746
|
+
}, a = () => {
|
|
4747
|
+
r?.(), r = t.value && e.state.items.length ? nt(t.value, e.state.items.length) : void 0;
|
|
4501
4748
|
};
|
|
4502
|
-
return
|
|
4749
|
+
return fr(() => {
|
|
4750
|
+
i(), a();
|
|
4751
|
+
}), J(() => {
|
|
4752
|
+
n?.(), r?.();
|
|
4753
|
+
}), q(() => e.placement, i), q(() => e.state.items.length, a, { flush: "post" }), () => e.state.items.length ? U("nav", {
|
|
4503
4754
|
ref: t,
|
|
4504
4755
|
class: "markweave-inner-toc",
|
|
4505
4756
|
"data-testid": "markweave-inner-toc",
|
|
4506
4757
|
"aria-label": e.messages.toc.ariaLabel,
|
|
4507
|
-
style: { "--markweave-inner-toc-rail-height":
|
|
4508
|
-
}, [
|
|
4758
|
+
style: { "--markweave-inner-toc-rail-height": Ze(e.state.items.length) }
|
|
4759
|
+
}, [U("div", {
|
|
4509
4760
|
class: "markweave-inner-toc-rail",
|
|
4510
4761
|
"aria-hidden": "true"
|
|
4511
|
-
}, e.state.items.map((e) =>
|
|
4762
|
+
}, e.state.items.map((e) => U("span", {
|
|
4512
4763
|
key: e.id,
|
|
4513
4764
|
"data-level": e.level,
|
|
4514
4765
|
"data-active": e.active ? "true" : "false"
|
|
4515
|
-
}))),
|
|
4766
|
+
}))), U("div", { class: "markweave-inner-toc-panel" }, [U("div", { class: "markweave-inner-toc-list" }, e.state.items.map((t) => U("button", {
|
|
4516
4767
|
key: t.id,
|
|
4517
4768
|
type: "button",
|
|
4518
4769
|
class: "markweave-inner-toc-item",
|
|
@@ -4521,34 +4772,36 @@ var ea = X({
|
|
|
4521
4772
|
"aria-current": t.active ? "location" : void 0,
|
|
4522
4773
|
"aria-label": `${e.messages.toc.itemAriaLabel}: ${t.text}`,
|
|
4523
4774
|
title: t.text,
|
|
4524
|
-
onClick: () =>
|
|
4775
|
+
onClick: () => rt(e.editor, t, {
|
|
4525
4776
|
behavior: "smooth",
|
|
4526
4777
|
focus: e.editable
|
|
4527
4778
|
})
|
|
4528
4779
|
}, t.text)))])]) : null;
|
|
4529
4780
|
}
|
|
4530
4781
|
});
|
|
4531
|
-
function
|
|
4532
|
-
let i = r(e.lang), o = n(i), s = t(i), c =
|
|
4782
|
+
function Sa(e = {}) {
|
|
4783
|
+
let i = r(e.lang), o = n(i), s = t(i), c = W(f(e.mode)), l = K(() => Oe(e.theme)), u = K(() => c.value === "live" && e.editable !== !1), d = W(0), m = G(null), h = W(hn), g = G(null), _ = G(null), v = W("code"), y = G(null), b = G(Sn), x = W(null), S = W(!1), C = G(null), w = fe(e.content === void 0 ? e.defaultContentFormat : e.contentFormat), T = e.content ?? e.defaultContent ?? "", E = typeof T == "string" && T.length >= 2e5, D = null;
|
|
4533
4784
|
function O() {
|
|
4534
4785
|
D !== null && (window.clearTimeout(D), D = null), d.value += 1;
|
|
4535
4786
|
}
|
|
4536
4787
|
function k() {
|
|
4537
4788
|
D !== null && window.clearTimeout(D), D = window.setTimeout(() => {
|
|
4538
4789
|
D = null, d.value += 1;
|
|
4539
|
-
},
|
|
4790
|
+
}, Te);
|
|
4540
4791
|
}
|
|
4541
|
-
let A = e.onSlashCommandUpload, j =
|
|
4792
|
+
let A = e.onSlashCommandUpload, j = G(null);
|
|
4542
4793
|
j.value = new a({
|
|
4543
|
-
extensions:
|
|
4794
|
+
extensions: ea({
|
|
4544
4795
|
lang: i,
|
|
4545
4796
|
linkCardResolver: e.linkCardResolver,
|
|
4546
|
-
onImageUpload: (e) => A?.(e) ??
|
|
4547
|
-
onVideoUpload: (e) => A?.(e) ??
|
|
4797
|
+
onImageUpload: (e) => A?.(e) ?? H(e) ?? Promise.reject(/* @__PURE__ */ Error("File upload requires an upload handler.")),
|
|
4798
|
+
onVideoUpload: (e) => A?.(e) ?? H(e) ?? Promise.reject(/* @__PURE__ */ Error("File upload requires an upload handler.")),
|
|
4799
|
+
onAttachmentUpload: (t) => e.onSlashCommandUpload?.(t) ?? H(t) ?? Promise.reject(/* @__PURE__ */ Error("File upload requires an upload handler.")),
|
|
4800
|
+
onAttachmentDownload: (t, n) => e.onAttachmentDownload?.(t, n),
|
|
4548
4801
|
resolveMediaSource: e.resolveMediaSource
|
|
4549
4802
|
}),
|
|
4550
4803
|
content: T,
|
|
4551
|
-
contentType:
|
|
4804
|
+
contentType: le(w),
|
|
4552
4805
|
editable: u.value,
|
|
4553
4806
|
autofocus: e.autofocus,
|
|
4554
4807
|
editorProps: {
|
|
@@ -4562,36 +4815,36 @@ function la(e = {}) {
|
|
|
4562
4815
|
translate: "no"
|
|
4563
4816
|
},
|
|
4564
4817
|
handleClick: (e, t, n) => {
|
|
4565
|
-
if (!u.value) return
|
|
4566
|
-
let r =
|
|
4567
|
-
return r ? (n.preventDefault(), n.stopPropagation(),
|
|
4818
|
+
if (!u.value) return be(n);
|
|
4819
|
+
let r = Kt(e, n);
|
|
4820
|
+
return r ? (n.preventDefault(), n.stopPropagation(), F(), Xt(e, r, !0), Zt(e, r), y.value = r, !0) : (y.value = null, !1);
|
|
4568
4821
|
},
|
|
4569
4822
|
handleDOMEvents: {
|
|
4570
|
-
compositionstart: () => u.value ? (h.value =
|
|
4571
|
-
compositionend: (e) => (u.value && window.setTimeout(() =>
|
|
4823
|
+
compositionstart: () => u.value ? (h.value = gn(h.value, { type: "composition-start" }), g.value = null, !1) : !1,
|
|
4824
|
+
compositionend: (e) => (u.value && window.setTimeout(() => I(e), 0), !1),
|
|
4572
4825
|
click: (e, t) => {
|
|
4573
|
-
if (!u.value) return
|
|
4574
|
-
let n =
|
|
4575
|
-
return n ? (t.preventDefault(), t.stopPropagation(),
|
|
4826
|
+
if (!u.value) return be(t);
|
|
4827
|
+
let n = Kt(e, t);
|
|
4828
|
+
return n ? (t.preventDefault(), t.stopPropagation(), F(), Xt(e, n, !0), Zt(e, n), y.value = n, !0) : (y.value = null, !1);
|
|
4576
4829
|
}
|
|
4577
4830
|
}
|
|
4578
4831
|
},
|
|
4579
|
-
onSelectionUpdate: ({ editor: e }) =>
|
|
4832
|
+
onSelectionUpdate: ({ editor: e }) => R(e),
|
|
4580
4833
|
onCreate: ({ editor: t }) => {
|
|
4581
4834
|
p(t, {
|
|
4582
4835
|
mode: c.value,
|
|
4583
4836
|
editable: u.value
|
|
4584
|
-
}),
|
|
4837
|
+
}), $t(t, l.value), en(t, u.value ? "live" : "view"), e.autoFocusFirstTableBodyCell && u.value && yn(t), z(t), R(t), O();
|
|
4585
4838
|
},
|
|
4586
4839
|
onTransaction: ({ editor: e, transaction: t }) => {
|
|
4587
|
-
if (
|
|
4588
|
-
let t =
|
|
4840
|
+
if (z(e), (t.docChanged || Qt(t)) && k(), t.docChanged && y.value) {
|
|
4841
|
+
let t = Gt(e, y.value.pos);
|
|
4589
4842
|
y.value = t?.kind === y.value.kind ? t : null;
|
|
4590
4843
|
}
|
|
4591
4844
|
},
|
|
4592
4845
|
onUpdate: ({ editor: t }) => {
|
|
4593
|
-
|
|
4594
|
-
let i =
|
|
4846
|
+
R(t), u.value && L(t), S.value || e.onUpdate?.(ce(t, { onContentRead: (n, r) => {
|
|
4847
|
+
let i = fe(e.contentFormat);
|
|
4595
4848
|
e.content !== void 0 && n === i && (C.value = {
|
|
4596
4849
|
content: r,
|
|
4597
4850
|
format: n,
|
|
@@ -4600,194 +4853,194 @@ function la(e = {}) {
|
|
|
4600
4853
|
} }));
|
|
4601
4854
|
}
|
|
4602
4855
|
});
|
|
4603
|
-
let
|
|
4856
|
+
let ee = j.value, te = ke(ee), M = !1, N = !1;
|
|
4604
4857
|
Y(() => {
|
|
4605
|
-
|
|
4858
|
+
M || j.value !== ee || (N = !0, e.onAiEditControllerChange?.(te));
|
|
4606
4859
|
});
|
|
4607
|
-
let
|
|
4608
|
-
function
|
|
4609
|
-
g.value = null, _.value = null, h.value =
|
|
4860
|
+
let P = K(() => j.value ?? null);
|
|
4861
|
+
function F() {
|
|
4862
|
+
g.value = null, _.value = null, h.value = hn;
|
|
4610
4863
|
}
|
|
4611
|
-
function
|
|
4612
|
-
let t =
|
|
4864
|
+
function I(e) {
|
|
4865
|
+
let t = fn(e.state);
|
|
4613
4866
|
if (!t) {
|
|
4614
|
-
h.value = h.value.name === "idle" ? h.value :
|
|
4867
|
+
h.value = h.value.name === "idle" ? h.value : hn, g.value = null, _.value = null;
|
|
4615
4868
|
return;
|
|
4616
4869
|
}
|
|
4617
4870
|
let n = e.coordsAtPos(t.cursor), r = e.coordsAtPos(t.triggerFrom), i = e.dom.closest(".markweave-editor-frame")?.getBoundingClientRect();
|
|
4618
|
-
if (!
|
|
4619
|
-
|
|
4871
|
+
if (!mn(r, { frameRect: i })) {
|
|
4872
|
+
F();
|
|
4620
4873
|
return;
|
|
4621
4874
|
}
|
|
4622
|
-
let a =
|
|
4875
|
+
let a = dn(n, {
|
|
4623
4876
|
frameRect: i,
|
|
4624
4877
|
triggerRect: r
|
|
4625
4878
|
});
|
|
4626
|
-
|
|
4879
|
+
cn(g.value, a) || (g.value = a), h.value = un(h.value, t);
|
|
4627
4880
|
}
|
|
4628
|
-
function
|
|
4629
|
-
|
|
4881
|
+
function L(e) {
|
|
4882
|
+
I(e.view);
|
|
4630
4883
|
}
|
|
4631
|
-
function
|
|
4632
|
-
let t =
|
|
4633
|
-
|
|
4634
|
-
let n =
|
|
4635
|
-
n && (
|
|
4636
|
-
let r =
|
|
4884
|
+
function R(e) {
|
|
4885
|
+
let t = we(e);
|
|
4886
|
+
Se(m.value, t) || (m.value = t);
|
|
4887
|
+
let n = qt(e);
|
|
4888
|
+
n && (Yt(e, n, !0), y.value = n);
|
|
4889
|
+
let r = ot(e);
|
|
4637
4890
|
r.active && r.language === "mermaid" && (v.value = r.mermaidPreviewMode);
|
|
4638
4891
|
}
|
|
4639
|
-
function
|
|
4640
|
-
b.value =
|
|
4892
|
+
function z(e) {
|
|
4893
|
+
b.value = ra(e);
|
|
4641
4894
|
}
|
|
4642
|
-
let
|
|
4643
|
-
active:
|
|
4895
|
+
let B = K(() => P.value ? ot(P.value) : na), V = K(() => P.value ? bn(P.value.state) : ta), ne = K(() => m.value?.currentNode === "codeBlock"), re = K(() => ne.value && B.value.language === "mermaid"), ie = K(() => P.value ? nn({
|
|
4896
|
+
active: re.value,
|
|
4644
4897
|
mode: v.value,
|
|
4645
|
-
source:
|
|
4646
|
-
}) :
|
|
4898
|
+
source: B.value.text
|
|
4899
|
+
}) : nn({
|
|
4647
4900
|
active: !1,
|
|
4648
4901
|
mode: "code",
|
|
4649
4902
|
source: ""
|
|
4650
|
-
})),
|
|
4903
|
+
})), oe = K(() => P.value && e.onRuntimeStateChange ? vn(P.value.state) : null), pe = K(() => P.value ? Qe(P.value.state) : Ye.items), me = K(() => $e(pe.value, x.value)), he = K(() => Je(pe.value, me.value)), ge = K(() => rn(h.value.query, s)), _e = K(() => xe({
|
|
4651
4904
|
revision: d.value,
|
|
4652
4905
|
mode: c.value,
|
|
4653
4906
|
editable: u.value,
|
|
4654
|
-
toc:
|
|
4907
|
+
toc: he.value,
|
|
4655
4908
|
selection: m.value,
|
|
4656
4909
|
slash: h.value,
|
|
4657
|
-
table:
|
|
4910
|
+
table: V.value,
|
|
4658
4911
|
tableInteraction: b.value,
|
|
4659
|
-
codeBlock:
|
|
4660
|
-
mermaid:
|
|
4661
|
-
tableDebugSnapshot:
|
|
4662
|
-
})),
|
|
4663
|
-
closeSlashMenu:
|
|
4664
|
-
focusFirstTableBodyCell: () =>
|
|
4912
|
+
codeBlock: B.value,
|
|
4913
|
+
mermaid: ie.value,
|
|
4914
|
+
tableDebugSnapshot: oe.value
|
|
4915
|
+
})), ve = {
|
|
4916
|
+
closeSlashMenu: F,
|
|
4917
|
+
focusFirstTableBodyCell: () => P.value ? yn(P.value) : !1,
|
|
4665
4918
|
setContent: (e, t = {}) => {
|
|
4666
|
-
if (!
|
|
4667
|
-
let n =
|
|
4668
|
-
return
|
|
4669
|
-
contentType:
|
|
4919
|
+
if (!P.value) return !1;
|
|
4920
|
+
let n = fe(t.format);
|
|
4921
|
+
return P.value.commands.setContent(e, {
|
|
4922
|
+
contentType: le(n),
|
|
4670
4923
|
emitUpdate: t.emitUpdate ?? !1
|
|
4671
|
-
}), t.focusFirstTableBodyCell &&
|
|
4924
|
+
}), t.focusFirstTableBodyCell && yn(P.value), R(P.value), u.value && L(P.value), z(P.value), O(), !0;
|
|
4672
4925
|
}
|
|
4673
4926
|
};
|
|
4674
|
-
function
|
|
4675
|
-
if (!(!
|
|
4927
|
+
function ye(e, t) {
|
|
4928
|
+
if (!(!P.value || !u.value || !an(e))) {
|
|
4676
4929
|
if (e.inputKind && !t?.emoji && !t?.uploadResult) {
|
|
4677
4930
|
_.value = e;
|
|
4678
4931
|
return;
|
|
4679
4932
|
}
|
|
4680
|
-
|
|
4933
|
+
ln(P.value, h.value, e, t), h.value = gn(h.value, { type: "execute" }), F();
|
|
4681
4934
|
}
|
|
4682
4935
|
}
|
|
4683
|
-
function
|
|
4684
|
-
if (!
|
|
4685
|
-
let t =
|
|
4936
|
+
function Ce(e) {
|
|
4937
|
+
if (!P.value || _.value || !u.value) return;
|
|
4938
|
+
let t = on(h.value, ge.value, e.key, { isComposing: e.isComposing || ae(P.value.state) });
|
|
4686
4939
|
if (t.type !== "ignore") {
|
|
4687
4940
|
if (e.preventDefault(), t.type === "close") {
|
|
4688
|
-
h.value =
|
|
4941
|
+
h.value = gn(h.value, { type: "escape" }), F();
|
|
4689
4942
|
return;
|
|
4690
4943
|
}
|
|
4691
4944
|
if (t.type === "move-active") {
|
|
4692
|
-
h.value =
|
|
4945
|
+
h.value = gn(h.value, {
|
|
4693
4946
|
type: "move-active",
|
|
4694
4947
|
delta: t.delta,
|
|
4695
4948
|
optionCount: t.optionCount
|
|
4696
4949
|
});
|
|
4697
4950
|
return;
|
|
4698
4951
|
}
|
|
4699
|
-
|
|
4952
|
+
ye(t.command);
|
|
4700
4953
|
}
|
|
4701
4954
|
}
|
|
4702
|
-
|
|
4703
|
-
c.value = f(e.mode),
|
|
4955
|
+
q(() => [e.mode, e.editable], () => {
|
|
4956
|
+
c.value = f(e.mode), P.value && (P.value.setEditable(u.value), p(P.value, {
|
|
4704
4957
|
mode: c.value,
|
|
4705
4958
|
editable: u.value
|
|
4706
|
-
}),
|
|
4707
|
-
}, { immediate: !0 }),
|
|
4708
|
-
|
|
4709
|
-
}, { immediate: !0 }),
|
|
4710
|
-
let n =
|
|
4711
|
-
if (!(!
|
|
4712
|
-
if (
|
|
4959
|
+
}), en(P.value, u.value ? "live" : "view"), O(), u.value || F());
|
|
4960
|
+
}, { immediate: !0 }), q(() => e.theme, () => {
|
|
4961
|
+
P.value && $t(P.value, l.value);
|
|
4962
|
+
}, { immediate: !0 }), q(() => e.content, (t) => {
|
|
4963
|
+
let n = fe(e.contentFormat);
|
|
4964
|
+
if (!(!P.value || t === void 0)) {
|
|
4965
|
+
if (de(P.value, C.value, t, n)) {
|
|
4713
4966
|
C.value = null;
|
|
4714
4967
|
return;
|
|
4715
4968
|
}
|
|
4716
|
-
C.value = null, !
|
|
4717
|
-
contentType:
|
|
4969
|
+
C.value = null, !ue(P.value, t, n) && (S.value = !0, P.value.commands.setContent(t, {
|
|
4970
|
+
contentType: le(n),
|
|
4718
4971
|
emitUpdate: !1
|
|
4719
|
-
}), S.value = !1,
|
|
4972
|
+
}), S.value = !1, R(P.value), u.value && L(P.value), z(P.value), O());
|
|
4720
4973
|
}
|
|
4721
|
-
}),
|
|
4722
|
-
let t =
|
|
4974
|
+
}), q(_e, (t) => e.onRuntimeStateChange?.(t), { immediate: !0 }), q(he, (t) => e.onTocChange?.(t), { immediate: !0 }), q(pe, (e) => {
|
|
4975
|
+
let t = $e(e, x.value);
|
|
4723
4976
|
x.value !== t && (x.value = t);
|
|
4724
4977
|
});
|
|
4725
|
-
let Ee =
|
|
4726
|
-
|
|
4727
|
-
}), De = () => {
|
|
4728
|
-
g.value && Ee.schedule();
|
|
4978
|
+
let Ee = se(() => {
|
|
4979
|
+
P.value && g.value && I(P.value.view);
|
|
4980
|
+
}), De = (e) => {
|
|
4981
|
+
e?.type === "scroll" && pn(e.target) || g.value && Ee.schedule();
|
|
4729
4982
|
};
|
|
4730
|
-
|
|
4983
|
+
q(g, (e) => {
|
|
4731
4984
|
e ? De() : Ee.cancel();
|
|
4732
|
-
}),
|
|
4985
|
+
}), fr(() => {
|
|
4733
4986
|
window.addEventListener("resize", De), window.addEventListener("scroll", De, !0);
|
|
4734
|
-
}),
|
|
4987
|
+
}), J(() => {
|
|
4735
4988
|
Ee.cancel(), window.removeEventListener("resize", De), window.removeEventListener("scroll", De, !0);
|
|
4736
4989
|
});
|
|
4737
|
-
let
|
|
4738
|
-
return
|
|
4990
|
+
let Ae = null;
|
|
4991
|
+
return J(() => {
|
|
4739
4992
|
D !== null && window.clearTimeout(D);
|
|
4740
|
-
}),
|
|
4993
|
+
}), fr(() => {
|
|
4741
4994
|
let e = () => {
|
|
4742
|
-
if (!
|
|
4995
|
+
if (!P.value || !pe.value.length) {
|
|
4743
4996
|
x.value = null;
|
|
4744
4997
|
return;
|
|
4745
4998
|
}
|
|
4746
4999
|
let e = null;
|
|
4747
5000
|
try {
|
|
4748
|
-
e =
|
|
5001
|
+
e = Xe(P.value, pe.value);
|
|
4749
5002
|
} catch {
|
|
4750
5003
|
return;
|
|
4751
5004
|
}
|
|
4752
5005
|
x.value !== e && (x.value = e);
|
|
4753
|
-
}, t = () => window.requestAnimationFrame(e), n =
|
|
4754
|
-
window.addEventListener("scroll", t, { passive: !0 }), window.addEventListener("resize", t), n?.addEventListener("scroll", t, { passive: !0 }), t(),
|
|
5006
|
+
}, t = () => window.requestAnimationFrame(e), n = ia(P.value?.view.dom ?? null);
|
|
5007
|
+
window.addEventListener("scroll", t, { passive: !0 }), window.addEventListener("resize", t), n?.addEventListener("scroll", t, { passive: !0 }), t(), Ae = () => {
|
|
4755
5008
|
window.removeEventListener("scroll", t), window.removeEventListener("resize", t), n?.removeEventListener("scroll", t);
|
|
4756
5009
|
};
|
|
4757
|
-
}),
|
|
4758
|
-
|
|
5010
|
+
}), J(() => {
|
|
5011
|
+
Ae?.(), M = !0, N && e.onAiEditControllerChange?.(null);
|
|
4759
5012
|
let t = j.value;
|
|
4760
5013
|
j.value = null, Y(() => t?.destroy());
|
|
4761
5014
|
}), {
|
|
4762
|
-
editor:
|
|
4763
|
-
runtimeSnapshot:
|
|
4764
|
-
actions:
|
|
5015
|
+
editor: P,
|
|
5016
|
+
runtimeSnapshot: _e,
|
|
5017
|
+
actions: ve,
|
|
4765
5018
|
__render: {
|
|
4766
5019
|
messages: o,
|
|
4767
5020
|
effectiveEditable: u,
|
|
4768
|
-
tableFocusState:
|
|
5021
|
+
tableFocusState: V,
|
|
4769
5022
|
tableInteractionState: b,
|
|
4770
|
-
codeBlockState:
|
|
4771
|
-
isCodeBlockActive:
|
|
5023
|
+
codeBlockState: B,
|
|
5024
|
+
isCodeBlockActive: ne,
|
|
4772
5025
|
mermaidMode: v,
|
|
4773
5026
|
mathTarget: y,
|
|
4774
5027
|
setMermaidMode: (e) => {
|
|
4775
5028
|
v.value = e;
|
|
4776
5029
|
},
|
|
4777
|
-
tocState:
|
|
4778
|
-
filteredSlashCommands:
|
|
5030
|
+
tocState: he,
|
|
5031
|
+
filteredSlashCommands: ge,
|
|
4779
5032
|
slashState: h,
|
|
4780
5033
|
slashMenuPosition: g,
|
|
4781
5034
|
slashInputCommand: _,
|
|
4782
|
-
runSlashCommand:
|
|
4783
|
-
handleEditorKeyDown:
|
|
5035
|
+
runSlashCommand: ye,
|
|
5036
|
+
handleEditorKeyDown: Ce,
|
|
4784
5037
|
setSlashInputCommand: (e) => {
|
|
4785
5038
|
_.value = e;
|
|
4786
5039
|
}
|
|
4787
5040
|
}
|
|
4788
5041
|
};
|
|
4789
5042
|
}
|
|
4790
|
-
var
|
|
5043
|
+
var Ca = X({
|
|
4791
5044
|
name: "MarkweaveEditor",
|
|
4792
5045
|
props: {
|
|
4793
5046
|
defaultContent: {
|
|
@@ -4882,6 +5135,10 @@ var ua = X({
|
|
|
4882
5135
|
type: Function,
|
|
4883
5136
|
default: void 0
|
|
4884
5137
|
},
|
|
5138
|
+
onAttachmentDownload: {
|
|
5139
|
+
type: Function,
|
|
5140
|
+
default: void 0
|
|
5141
|
+
},
|
|
4885
5142
|
onTableCopyPayload: {
|
|
4886
5143
|
type: Function,
|
|
4887
5144
|
default: void 0
|
|
@@ -4904,31 +5161,31 @@ var ua = X({
|
|
|
4904
5161
|
}
|
|
4905
5162
|
},
|
|
4906
5163
|
setup(e) {
|
|
4907
|
-
let t =
|
|
5164
|
+
let t = Sa(e);
|
|
4908
5165
|
return () => {
|
|
4909
5166
|
let n = t.editor.value;
|
|
4910
5167
|
if (!n) return null;
|
|
4911
|
-
let i = t.__render, a = ["markweave-editor-frame", e.className].filter(Boolean).join(" "), s =
|
|
4912
|
-
return
|
|
5168
|
+
let i = t.__render, a = ["markweave-editor-frame", e.className].filter(Boolean).join(" "), s = De(e.canvasColor);
|
|
5169
|
+
return U("section", {
|
|
4913
5170
|
class: a,
|
|
4914
5171
|
"aria-label": e.ariaLabel ?? i.messages.common.editorAriaLabel,
|
|
4915
5172
|
"data-testid": "markweave-editor-frame",
|
|
4916
5173
|
"data-markweave-mode": t.runtimeSnapshot.value.mode,
|
|
4917
|
-
"data-markweave-theme":
|
|
5174
|
+
"data-markweave-theme": Oe(e.theme),
|
|
4918
5175
|
style: s ? { "--markweave-canvas": s } : void 0,
|
|
4919
5176
|
"data-markweave-inner-toc": e.innerToc ? "true" : "false",
|
|
4920
|
-
"data-markweave-inner-toc-placement":
|
|
5177
|
+
"data-markweave-inner-toc-placement": et(e.innerTocPlacement),
|
|
4921
5178
|
"data-mermaid-mode": t.runtimeSnapshot.value.mermaid.mode,
|
|
4922
5179
|
"data-table-focus-mode": i.tableFocusState.value.mode,
|
|
4923
5180
|
onKeydownCapture: i.handleEditorKeyDown
|
|
4924
5181
|
}, [
|
|
4925
|
-
i.effectiveEditable.value ?
|
|
5182
|
+
i.effectiveEditable.value ? U(pa, {
|
|
4926
5183
|
editor: n,
|
|
4927
5184
|
lang: r(e.lang),
|
|
4928
5185
|
messages: i.messages,
|
|
4929
5186
|
askAi: e.askAi
|
|
4930
5187
|
}) : null,
|
|
4931
|
-
i.effectiveEditable.value ?
|
|
5188
|
+
i.effectiveEditable.value ? U(ha, {
|
|
4932
5189
|
commands: i.filteredSlashCommands.value,
|
|
4933
5190
|
state: i.slashState.value,
|
|
4934
5191
|
position: i.slashMenuPosition.value,
|
|
@@ -4938,7 +5195,7 @@ var ua = X({
|
|
|
4938
5195
|
onInputCommandChange: i.setSlashInputCommand,
|
|
4939
5196
|
onUpload: e.onSlashCommandUpload
|
|
4940
5197
|
}) : null,
|
|
4941
|
-
i.effectiveEditable.value ?
|
|
5198
|
+
i.effectiveEditable.value ? U(va, {
|
|
4942
5199
|
editor: n,
|
|
4943
5200
|
active: i.tableFocusState.value.active,
|
|
4944
5201
|
interactionState: i.tableInteractionState.value,
|
|
@@ -4948,11 +5205,11 @@ var ua = X({
|
|
|
4948
5205
|
onCommandResult: e.onTableCommandResult,
|
|
4949
5206
|
onEditWithAi: e.onEditWithAi
|
|
4950
5207
|
}) : null,
|
|
4951
|
-
i.effectiveEditable.value ?
|
|
5208
|
+
i.effectiveEditable.value ? U(ya, {
|
|
4952
5209
|
editor: n,
|
|
4953
5210
|
focusState: i.tableFocusState.value
|
|
4954
5211
|
}) : null,
|
|
4955
|
-
|
|
5212
|
+
U(ba, {
|
|
4956
5213
|
editor: n,
|
|
4957
5214
|
state: i.codeBlockState.value,
|
|
4958
5215
|
active: i.effectiveEditable.value && i.isCodeBlockActive.value,
|
|
@@ -4960,23 +5217,23 @@ var ua = X({
|
|
|
4960
5217
|
onMermaidModeChange: i.setMermaidMode,
|
|
4961
5218
|
readOnly: !i.effectiveEditable.value
|
|
4962
5219
|
}),
|
|
4963
|
-
e.innerToc && i.tocState.value.items.length ?
|
|
5220
|
+
e.innerToc && i.tocState.value.items.length ? U(xa, {
|
|
4964
5221
|
editor: n,
|
|
4965
5222
|
state: i.tocState.value,
|
|
4966
5223
|
messages: i.messages,
|
|
4967
5224
|
editable: i.effectiveEditable.value,
|
|
4968
|
-
placement:
|
|
5225
|
+
placement: et(e.innerTocPlacement)
|
|
4969
5226
|
}) : null,
|
|
4970
|
-
i.effectiveEditable.value && i.mathTarget.value ?
|
|
5227
|
+
i.effectiveEditable.value && i.mathTarget.value ? U(ma, {
|
|
4971
5228
|
editor: n,
|
|
4972
5229
|
messages: i.messages,
|
|
4973
5230
|
target: i.mathTarget.value,
|
|
4974
5231
|
onClose: () => i.mathTarget.value = null
|
|
4975
5232
|
}) : null,
|
|
4976
|
-
|
|
5233
|
+
U(o, { editor: n })
|
|
4977
5234
|
]);
|
|
4978
5235
|
};
|
|
4979
5236
|
}
|
|
4980
5237
|
});
|
|
4981
5238
|
//#endregion
|
|
4982
|
-
export {
|
|
5239
|
+
export { Ca as MarkweaveEditor, re as createMarkweaveAiEditController, ea as createMarkweaveEditorExtensions, ea as createMarkweaveVue2EditorExtensions, Sa as useMarkweaveEditorController };
|