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