@markweave/vue2 0.1.5 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +25 -25
- package/dist/index.js +578 -511
- package/dist/types/MarkweaveEditor.d.ts +2 -0
- package/dist/types/MarkweaveEditor.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/media-nodeviews.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -5,49 +5,51 @@ import * as o from "vue";
|
|
|
5
5
|
import { getMarkweaveEditorModeState as s, isMarkweaveEditorLiveEditable as c, normalizeMarkweaveEditorMode as l, setMarkweaveEditorModeState as u, subscribeToMarkweaveEditorMode as d } from "markweave/internal/core/editor-mode-state";
|
|
6
6
|
import { getLocalizedSlashCommandSpecs as f, getMarkweaveMessages as p, normalizeMarkweaveLang as m } from "markweave/internal/i18n";
|
|
7
7
|
import { openMarkweaveImagePreview as h } from "markweave/internal/plugins/media/image-preview";
|
|
8
|
-
import { MarkweaveCoreImage as g, MarkweaveCoreVideo as _, attrsFromMarkweaveImageUploadResult as v, attrsFromMarkweaveVideoUploadResult as y, attrsFromMarkweaveVideoUrl as b, clampMarkweaveImageWidth as x, createMarkweaveImageUploadRequest as S, createMarkweaveVideoUploadRequest as C, downloadMarkweaveImage as w, markweaveVideoIframeAllow as T, normalizeMarkweaveCoreImageAlign as E, normalizeMarkweaveVideoEmbedUrl as
|
|
9
|
-
import { detectUploadSource as
|
|
10
|
-
import { BubbleMenu as
|
|
11
|
-
import { isEditorComposing as
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
8
|
+
import { MarkweaveCoreImage as g, MarkweaveCoreVideo as _, attrsFromMarkweaveImageUploadResult as v, attrsFromMarkweaveVideoUploadResult as y, attrsFromMarkweaveVideoUrl as b, clampMarkweaveImageWidth as x, createMarkweaveImageUploadRequest as S, createMarkweaveVideoUploadRequest as C, downloadMarkweaveImage as w, markweaveVideoIframeAllow as T, normalizeMarkweaveCoreImageAlign as E, normalizeMarkweaveVideoEmbedUrl as ee, numberAttribute as D, stringAttribute as O } from "markweave/internal/plugins/media/core-media-nodes";
|
|
9
|
+
import { detectUploadSource as k, getDirectUploadResult as A, resolveMarkweaveUploadResult as j } from "markweave/internal/plugins/slash-command/upload";
|
|
10
|
+
import { BubbleMenu as M } from "@tiptap/vue-2/menus";
|
|
11
|
+
import { isEditorComposing as te } from "markweave/internal/editor-core/composition-guard";
|
|
12
|
+
import { createMarkweaveFrameScheduler as N } from "markweave/internal/editor-core/frame-scheduler";
|
|
13
|
+
import { createMarkweaveEditorUpdatePayload as ne, getMarkweaveContentType as P, isEditorContentCurrent as re, isMarkweaveControlledContentEchoCurrent as F, normalizeMarkweaveContentFormat as I } from "markweave/internal/editor-core/editor-content";
|
|
14
|
+
import { getCurrentFloatingToolbarBlockType as L, getFloatingToolbarHighlightColorOptions as R, getFloatingToolbarMoreActions as ie, getFloatingToolbarTextColorOptions as ae, getFloatingToolbarTurnIntoOptions as oe, runFloatingToolbarMoreAction as se, setFloatingToolbarTurnInto as ce } from "markweave/internal/editor-core/floating-toolbar-model";
|
|
15
|
+
import { openMarkweaveReadonlyLinkFromEvent as le } from "markweave/internal/editor-core/readonly-link";
|
|
16
|
+
import { createMarkweaveEditorRuntimeSnapshot as ue } from "markweave/internal/editor-core/runtime-snapshot";
|
|
17
|
+
import { areEditorSelectionSnapshotsEquivalent as de, calculateFloatingToolbarPopoverPlacement as fe, createSelectionSnapshot as pe, markweaveRuntimeProjectionDelayMs as me, shouldShowFloatingToolbar as z } from "markweave/internal/editor-core/selection-state";
|
|
18
|
+
import { normalizeMarkweaveTheme as he } from "markweave/internal/core/theme";
|
|
19
|
+
import { createMarkweaveTocState as ge, emptyMarkweaveTocState as _e, getActiveMarkweaveTocId as ve, getMarkweaveTocItems as ye, getValidMarkweaveTocActiveId as be, normalizeMarkweaveInnerTocPlacement as xe, observeMarkweaveInnerTocContainerPosition as Se, scrollToMarkweaveTocItem as Ce } from "markweave/internal/core/toc-state";
|
|
20
|
+
import { codeBlockCollapsePluginKey as we, copyActiveCodeBlock as Te, getActiveCodeBlockState as Ee, getCodeBlockCopyFeedbackSnapshot as De, markweaveCodeBlockBehavior as Oe, setCodeBlockCollapsedAtPosition as ke, setCodeBlockLanguageAtPosition as Ae, setCodeBlockMermaidPreviewModeAtPosition as je } from "markweave/internal/plugins/codeblock/codeblock-behavior";
|
|
21
|
+
import { calculateCodeBlockLanguageMenuPosition as Me, clampFullscreenScale as Ne, codeBlockCopyFeedbackTimeoutMs as Pe, copyCodeBlockText as Fe, createCodeBlockOverlayPosition as Ie, createMermaidFullscreenViewerState as Le, createMermaidTabPosition as Re, focusCodeBlockTarget as ze, formatCodeBlockLanguageLabel as Be, formatFullscreenZoom as Ve, getActiveCodeBlockElement as He, getAnchoredRect as Ue, getCodeBlockLanguageItems as We, getCodeBlockPositionFromEventTarget as Ge, getCodeBlockStateAtPosition as Ke, getFrameElement as qe, getMermaidCodeBlockTargets as Je, getMermaidSvgMarkup as Ye, isCodeBlockTargetCollapsed as Xe, mergeStableMermaidTabPositions as Ze, mermaidFullscreenZoomStep as Qe, moveMermaidFullscreenViewer as $e } from "markweave/internal/plugins/codeblock/codeblock-ui-model";
|
|
22
|
+
import { normalizeMarkdownLinkHref as et } from "markweave/internal/plugins/markdown/markdown-input";
|
|
23
|
+
import { applyMarkweaveMathLatex as tt, calculateMarkweaveMathPopoverPosition as nt, getMarkweaveMathAnchorRect as rt, getMarkweaveMathBlockIndex as it, getMarkweaveMathRenderedHtml as at, getMarkweaveMathTargetAtPos as ot, getMarkweaveMathTargetFromDomEvent as st, getMarkweaveMathTargetFromSelection as ct, renderMarkweaveMathPreview as lt, setMarkweaveMathEditingDomState as ut, setMarkweaveMathEditingDomStateInView as dt, setMarkweaveMathSelectionInView as ft } from "markweave/internal/plugins/math/math-ui-model";
|
|
24
|
+
import { isMermaidInlinePreviewTransaction as pt, setMarkweaveMermaidTheme as mt, setMermaidInlinePreviewEditorMode as ht, setReadonlyMermaidPreviewMode as gt } from "markweave/internal/plugins/mermaid/mermaid-inline-preview";
|
|
25
|
+
import { getMermaidPreviewState as _t } from "markweave/internal/plugins/mermaid/mermaid-renderer";
|
|
26
|
+
import { filterSlashCommands as vt, isExecutableSlashCommand as yt } from "markweave/internal/plugins/slash-command/command-spec";
|
|
27
|
+
import { getSlashCommandKeyboardAction as bt } from "markweave/internal/plugins/slash-command/slash-keyboard";
|
|
28
|
+
import { executeSlashCommand as xt, getNextSlashCommandState as St, getSlashCommandAnchoredMenuPosition as Ct, getSlashCommandContext as wt } from "markweave/internal/plugins/slash-command/slash-runtime";
|
|
29
|
+
import { initialSlashCommandState as Tt, reduceSlashCommandState as Et } from "markweave/internal/plugins/slash-command/slash-state";
|
|
30
|
+
import { setMarkweaveTableMenuAxisTarget as Dt } from "markweave/internal/plugins/table/table-clipboard";
|
|
31
|
+
import { getFirstTableDebugSnapshot as Ot } from "markweave/internal/plugins/table/table-debug-snapshot";
|
|
32
|
+
import { focusFirstTableBodyCell as kt } from "markweave/internal/plugins/table/table-focus-position";
|
|
33
|
+
import { getTableFocusState as At } from "markweave/internal/plugins/table/table-focus-state";
|
|
34
|
+
import { getTableSelectionOverlayState as jt, initialTableInteractionState as Mt, tableInteractionPluginKey as Nt } from "markweave/internal/plugins/table/table-interaction-layer";
|
|
35
|
+
import { calculateAnchoredTableMenuPosition as Pt, calculateTableEdgeHandlePosition as Ft, canRunTableCommand as It, executeTableMenuCommand as Lt, formatTableCopyFeedback as Rt, getActiveTableElement as zt, getAvailableCellMenuCommandSpecs as Bt, getTableAxisTargetRect as Vt, getTableControlAxisSelectionModel as Ht, getTableEditWithAiRequest as Ut, getTableMenuItemGroup as Wt, getTableMenuItemLabel as Gt, getTableMenuItems as Kt, getTableSelectionTargetRect as qt, measureTableSelectionOverlay as Jt, selectTableAxisFromCell as Yt, tableCopyFeedbackTimeoutMs as Xt, tableMenuLabel as Zt } from "markweave/internal/plugins/table/table-ui-model";
|
|
34
36
|
//#region src/vue2-compat.ts
|
|
35
|
-
var
|
|
36
|
-
function
|
|
37
|
+
var Qt = o.default ?? o, $t = null, en = null, tn = null;
|
|
38
|
+
function nn(e) {
|
|
37
39
|
return !!(e && typeof e == "object" && "value" in e);
|
|
38
40
|
}
|
|
39
|
-
function
|
|
41
|
+
function rn(e) {
|
|
40
42
|
let t = e.slice(2);
|
|
41
43
|
return t.endsWith("Capture") ? `!${t.slice(0, -7).replace(/^[A-Z]/, (e) => e.toLowerCase())}` : t.replace(/^[A-Z]/, (e) => e.toLowerCase());
|
|
42
44
|
}
|
|
43
|
-
function
|
|
45
|
+
function an(e) {
|
|
44
46
|
let t = {}, n = {}, r = {}, i = {}, a = {};
|
|
45
47
|
for (let [o, s] of Object.entries(e)) if (s !== void 0) {
|
|
46
48
|
if (o === "class" || o === "style" || o === "key") {
|
|
47
49
|
t[o] = s;
|
|
48
50
|
continue;
|
|
49
51
|
}
|
|
50
|
-
if (o === "ref" &&
|
|
52
|
+
if (o === "ref" && nn(s)) {
|
|
51
53
|
a.insert = (e) => {
|
|
52
54
|
s.value = e.elm;
|
|
53
55
|
}, a.destroy = () => {
|
|
@@ -56,7 +58,7 @@ function Zt(e) {
|
|
|
56
58
|
continue;
|
|
57
59
|
}
|
|
58
60
|
if (/^on[A-Z]/.test(o)) {
|
|
59
|
-
i[
|
|
61
|
+
i[rn(o)] = s;
|
|
60
62
|
continue;
|
|
61
63
|
}
|
|
62
64
|
if (o === "value" || o === "checked" || o === "innerHTML" || o === "textContent") {
|
|
@@ -67,14 +69,14 @@ function Zt(e) {
|
|
|
67
69
|
}
|
|
68
70
|
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;
|
|
69
71
|
}
|
|
70
|
-
function
|
|
72
|
+
function on(e) {
|
|
71
73
|
let t = {}, n = {}, r = {}, i = {};
|
|
72
74
|
for (let [a, o] of Object.entries(e)) if (o !== void 0) {
|
|
73
75
|
if (a === "class" || a === "style" || a === "key") {
|
|
74
76
|
t[a] = o;
|
|
75
77
|
continue;
|
|
76
78
|
}
|
|
77
|
-
if (a === "ref" &&
|
|
79
|
+
if (a === "ref" && nn(o)) {
|
|
78
80
|
i.insert = (e) => {
|
|
79
81
|
o.value = e.componentInstance ?? e.elm;
|
|
80
82
|
}, i.destroy = () => {
|
|
@@ -90,25 +92,25 @@ function Qt(e) {
|
|
|
90
92
|
}
|
|
91
93
|
return Object.keys(n).length && (t.props = n), Object.keys(r).length && (t.attrs = r), Object.keys(i).length && (t.hook = i), t;
|
|
92
94
|
}
|
|
93
|
-
function
|
|
95
|
+
function sn(e) {
|
|
94
96
|
return !!(e && typeof e == "object" && "default" in e && typeof e.default == "function");
|
|
95
97
|
}
|
|
96
|
-
function
|
|
98
|
+
function cn(e) {
|
|
97
99
|
return !!(e && typeof e == "object" && ("tag" in e || "text" in e || "elm" in e || "componentOptions" in e || "componentInstance" in e));
|
|
98
100
|
}
|
|
99
|
-
function
|
|
101
|
+
function ln(e) {
|
|
100
102
|
return e == null || Array.isArray(e) ? e : [e];
|
|
101
103
|
}
|
|
102
|
-
function
|
|
103
|
-
return typeof e == "function" ?
|
|
104
|
+
function un(e) {
|
|
105
|
+
return typeof e == "function" ? ln(e()) : sn(e) ? ln(e.default()) : cn(e) ? [e] : e;
|
|
104
106
|
}
|
|
105
107
|
function B(e, t, n) {
|
|
106
|
-
if (!
|
|
107
|
-
let r = t && typeof t == "object" && !Array.isArray(t) ? t : {}, i = typeof e == "string" ?
|
|
108
|
-
return
|
|
108
|
+
if (!tn) throw Error("Vue 2 render context is not available.");
|
|
109
|
+
let r = t && typeof t == "object" && !Array.isArray(t) ? t : {}, i = typeof e == "string" ? an(r) : on(r), a = arguments.length === 2 && (Array.isArray(t) || typeof t == "string") ? t : un(n);
|
|
110
|
+
return tn(e, i, a);
|
|
109
111
|
}
|
|
110
112
|
function V(e) {
|
|
111
|
-
return
|
|
113
|
+
return Qt.observable({ value: e });
|
|
112
114
|
}
|
|
113
115
|
var H = V;
|
|
114
116
|
function U(e) {
|
|
@@ -118,19 +120,19 @@ function U(e) {
|
|
|
118
120
|
}
|
|
119
121
|
function W(e, t, n) {
|
|
120
122
|
let r = typeof e == "function" ? e : () => e.value;
|
|
121
|
-
return
|
|
123
|
+
return $t?.$watch ? $t.$watch(r, t, n) : () => void 0;
|
|
122
124
|
}
|
|
123
125
|
function G(e) {
|
|
124
|
-
|
|
126
|
+
en?.mounted.push(e);
|
|
125
127
|
}
|
|
126
128
|
function K(e) {
|
|
127
|
-
|
|
129
|
+
en?.beforeUnmount.push(e);
|
|
128
130
|
}
|
|
129
131
|
function q(e) {
|
|
130
|
-
return
|
|
132
|
+
return Qt.nextTick(e);
|
|
131
133
|
}
|
|
132
134
|
function J(e) {
|
|
133
|
-
return
|
|
135
|
+
return Qt.extend({
|
|
134
136
|
name: e.name,
|
|
135
137
|
props: e.props,
|
|
136
138
|
created() {
|
|
@@ -138,12 +140,12 @@ function J(e) {
|
|
|
138
140
|
mounted: [],
|
|
139
141
|
beforeUnmount: []
|
|
140
142
|
};
|
|
141
|
-
|
|
143
|
+
$t = this, en = t;
|
|
142
144
|
try {
|
|
143
145
|
let n = e.setup?.(this.$props ?? this) ?? null;
|
|
144
146
|
this.__markweaveVue2Render = typeof n == "function" ? n : null, this.__markweaveVue2Lifecycle = t;
|
|
145
147
|
} finally {
|
|
146
|
-
|
|
148
|
+
$t = null, en = null;
|
|
147
149
|
}
|
|
148
150
|
},
|
|
149
151
|
mounted() {
|
|
@@ -153,19 +155,19 @@ function J(e) {
|
|
|
153
155
|
this.__markweaveVue2Lifecycle?.beforeUnmount.forEach((e) => e());
|
|
154
156
|
},
|
|
155
157
|
render(t) {
|
|
156
|
-
|
|
158
|
+
tn = t;
|
|
157
159
|
try {
|
|
158
160
|
let n = this.__markweaveVue2Render;
|
|
159
161
|
return n ? n() : e.render?.(t) ?? null;
|
|
160
162
|
} finally {
|
|
161
|
-
|
|
163
|
+
tn = null;
|
|
162
164
|
}
|
|
163
165
|
}
|
|
164
166
|
});
|
|
165
167
|
}
|
|
166
168
|
//#endregion
|
|
167
169
|
//#region src/vue2-icons.ts
|
|
168
|
-
var
|
|
170
|
+
var dn = {
|
|
169
171
|
AlignCenter: {
|
|
170
172
|
iconName: "text-align-center",
|
|
171
173
|
node: [
|
|
@@ -1030,7 +1032,7 @@ var rn = {
|
|
|
1030
1032
|
}]]
|
|
1031
1033
|
}
|
|
1032
1034
|
};
|
|
1033
|
-
function
|
|
1035
|
+
function fn(e) {
|
|
1034
1036
|
return e.map(([e, t]) => B(e, t));
|
|
1035
1037
|
}
|
|
1036
1038
|
function Y(e) {
|
|
@@ -1051,7 +1053,7 @@ function Y(e) {
|
|
|
1051
1053
|
}
|
|
1052
1054
|
},
|
|
1053
1055
|
setup(t) {
|
|
1054
|
-
let n =
|
|
1056
|
+
let n = dn[e];
|
|
1055
1057
|
return () => B("svg", {
|
|
1056
1058
|
class: `lucide lucide-${n.iconName}`,
|
|
1057
1059
|
viewBox: "0 0 24 24",
|
|
@@ -1064,14 +1066,14 @@ function Y(e) {
|
|
|
1064
1066
|
"stroke-width": t.absoluteStrokeWidth && t.size ? Number(t.strokeWidth) * 24 / Number(t.size) : t.strokeWidth,
|
|
1065
1067
|
"aria-hidden": "true",
|
|
1066
1068
|
focusable: "false"
|
|
1067
|
-
},
|
|
1069
|
+
}, fn(n.node));
|
|
1068
1070
|
}
|
|
1069
1071
|
});
|
|
1070
1072
|
}
|
|
1071
|
-
var
|
|
1073
|
+
var pn = Y("AlignCenter"), mn = Y("AlignJustify"), hn = Y("AlignLeft"), gn = Y("AlignRight"), _n = Y("AlertTriangle"), vn = Y("Bold"), yn = Y("Braces"), bn = Y("Captions"), xn = Y("CheckCircle2"), Sn = Y("ChevronDown"), Cn = Y("ChevronUp"), wn = Y("CircleX"), Tn = Y("Code2"), En = Y("CornerDownLeft"), Dn = Y("Download"), On = Y("Eye"), kn = Y("ExternalLink"), An = Y("Heading1"), jn = Y("Heading2"), Mn = Y("Heading3"), Nn = Y("Image"), Pn = Y("ImageUp"), Fn = Y("IndentDecrease"), In = Y("IndentIncrease"), Ln = Y("Info"), Rn = Y("Italic"), zn = Y("Lightbulb"), Bn = Y("Link2"), Vn = Y("List"), Hn = Y("ListChecks"), Un = Y("ListOrdered"), Wn = Y("Minus"), Gn = Y("MoreVertical"), Kn = Y("Paperclip");
|
|
1072
1074
|
Y("PencilLine");
|
|
1073
|
-
var
|
|
1074
|
-
function
|
|
1075
|
+
var qn = Y("Quote"), Jn = Y("Replace"), Yn = Y("Sigma"), Xn = Y("SmilePlus"), Zn = Y("Strikethrough"), Qn = Y("Subscript"), $n = Y("Superscript"), er = Y("Table2"), tr = Y("Text"), nr = Y("Trash2"), rr = Y("Type"), ir = Y("Underline"), ar = Y("Upload"), or = Y("Video"), sr = E;
|
|
1076
|
+
function cr(e) {
|
|
1075
1077
|
let t = e.view.dom.closest(".markweave-editor-frame"), n = () => {
|
|
1076
1078
|
let n = t?.getAttribute("data-markweave-mode");
|
|
1077
1079
|
return n === "view" ? {
|
|
@@ -1093,13 +1095,13 @@ function tr(e) {
|
|
|
1093
1095
|
i(), a?.disconnect();
|
|
1094
1096
|
}), r;
|
|
1095
1097
|
}
|
|
1096
|
-
function
|
|
1098
|
+
function lr(e) {
|
|
1097
1099
|
return e instanceof Element && !!e.closest("[data-markweave-image-ui=\"true\"]");
|
|
1098
1100
|
}
|
|
1099
|
-
function
|
|
1101
|
+
function ur(e) {
|
|
1100
1102
|
return e instanceof Element && !!e.closest("[data-markweave-video-ui=\"true\"], iframe[data-markweave-video-embed], video[data-markweave-video]");
|
|
1101
1103
|
}
|
|
1102
|
-
function
|
|
1104
|
+
function dr(e, t) {
|
|
1103
1105
|
return B(e, {
|
|
1104
1106
|
size: 18,
|
|
1105
1107
|
strokeWidth: 1.8,
|
|
@@ -1115,12 +1117,12 @@ function X(e) {
|
|
|
1115
1117
|
"data-active": e.active ? "true" : "false",
|
|
1116
1118
|
onMousedown: (e) => e.preventDefault(),
|
|
1117
1119
|
onClick: e.onClick
|
|
1118
|
-
}, [
|
|
1120
|
+
}, [dr(e.icon, e.label), B("span", {
|
|
1119
1121
|
class: "markweave-image-tooltip",
|
|
1120
1122
|
role: "tooltip"
|
|
1121
1123
|
}, e.label)]);
|
|
1122
1124
|
}
|
|
1123
|
-
function
|
|
1125
|
+
function fr(e) {
|
|
1124
1126
|
let t = V(null), n = e.messages.image;
|
|
1125
1127
|
return B("section", {
|
|
1126
1128
|
class: "markweave-image-upload-placeholder",
|
|
@@ -1154,7 +1156,7 @@ function ar(e) {
|
|
|
1154
1156
|
B("div", {
|
|
1155
1157
|
class: "markweave-image-upload-icon",
|
|
1156
1158
|
"aria-hidden": "true"
|
|
1157
|
-
}, [B(
|
|
1159
|
+
}, [B(Pn, {
|
|
1158
1160
|
size: 46,
|
|
1159
1161
|
strokeWidth: 1.6
|
|
1160
1162
|
})]),
|
|
@@ -1179,7 +1181,7 @@ function ar(e) {
|
|
|
1179
1181
|
"data-testid": "markweave-image-upload-submit",
|
|
1180
1182
|
disabled: e.isSubmitting || !e.inputValue.trim(),
|
|
1181
1183
|
onClick: e.onSubmit
|
|
1182
|
-
}, [B(
|
|
1184
|
+
}, [B(Pn, {
|
|
1183
1185
|
size: 16,
|
|
1184
1186
|
strokeWidth: 1.8
|
|
1185
1187
|
}), e.messages.common.insert]),
|
|
@@ -1195,7 +1197,7 @@ function ar(e) {
|
|
|
1195
1197
|
}, e.error) : null
|
|
1196
1198
|
]);
|
|
1197
1199
|
}
|
|
1198
|
-
function
|
|
1200
|
+
function pr(e) {
|
|
1199
1201
|
let t = V(null), n = e.messages.video;
|
|
1200
1202
|
return B("section", {
|
|
1201
1203
|
class: "markweave-video-upload-placeholder",
|
|
@@ -1229,7 +1231,7 @@ function or(e) {
|
|
|
1229
1231
|
B("div", {
|
|
1230
1232
|
class: "markweave-video-upload-icon",
|
|
1231
1233
|
"aria-hidden": "true"
|
|
1232
|
-
}, [B(
|
|
1234
|
+
}, [B(or, {
|
|
1233
1235
|
size: 46,
|
|
1234
1236
|
strokeWidth: 1.6
|
|
1235
1237
|
})]),
|
|
@@ -1254,7 +1256,7 @@ function or(e) {
|
|
|
1254
1256
|
"data-testid": "markweave-video-upload-submit",
|
|
1255
1257
|
disabled: e.isSubmitting || !e.inputValue.trim(),
|
|
1256
1258
|
onClick: e.onSubmit
|
|
1257
|
-
}, [B(
|
|
1259
|
+
}, [B(ar, {
|
|
1258
1260
|
size: 16,
|
|
1259
1261
|
strokeWidth: 1.8
|
|
1260
1262
|
}), e.messages.common.insert]),
|
|
@@ -1270,7 +1272,7 @@ function or(e) {
|
|
|
1270
1272
|
}, e.error) : null
|
|
1271
1273
|
]);
|
|
1272
1274
|
}
|
|
1273
|
-
var
|
|
1275
|
+
var mr = J({
|
|
1274
1276
|
name: "MarkweaveVueImageNodeView",
|
|
1275
1277
|
props: {
|
|
1276
1278
|
editor: {
|
|
@@ -1303,10 +1305,10 @@ var sr = J({
|
|
|
1303
1305
|
}
|
|
1304
1306
|
},
|
|
1305
1307
|
setup(e) {
|
|
1306
|
-
let t = V(null), n = V(!1), r = V(!1), a = V(!1), o = V(""), s = V(null), l = V(!1), u = U(() => e.node.attrs), d = V(!!
|
|
1308
|
+
let t = V(null), n = V(!1), r = V(!1), a = V(!1), o = V(""), s = V(null), l = V(!1), u = U(() => e.node.attrs), d = V(!!O(u.value.caption)), f = V(O(u.value.caption) ?? ""), m = cr(e.editor), g = U(() => c(m.value)), _ = U(() => e.extension.options?.messages ?? p("zh")), y = U(() => _.value.image), b = U(() => O(u.value.src)), C = U(() => sr(u.value.align)), T = U(() => D(u.value.width)), E = U(() => O(u.value.caption)), ee = U(() => g.value && (!b.value || r.value)), A = () => {
|
|
1307
1309
|
b.value && h({
|
|
1308
1310
|
src: b.value,
|
|
1309
|
-
alt:
|
|
1311
|
+
alt: O(u.value.alt) ?? "",
|
|
1310
1312
|
messages: {
|
|
1311
1313
|
dialogAriaLabel: y.value.previewDialogAriaLabel,
|
|
1312
1314
|
zoomOut: y.value.previewZoomOut,
|
|
@@ -1319,45 +1321,45 @@ var sr = J({
|
|
|
1319
1321
|
W(E, (e) => {
|
|
1320
1322
|
d.value || (f.value = e ?? "");
|
|
1321
1323
|
});
|
|
1322
|
-
let
|
|
1324
|
+
let M = () => {
|
|
1323
1325
|
if (!g.value) return;
|
|
1324
1326
|
let t = e.getPos();
|
|
1325
1327
|
typeof t == "number" && e.editor.chain().focus().setNodeSelection(t).run();
|
|
1326
|
-
},
|
|
1328
|
+
}, te = () => {
|
|
1327
1329
|
if (o.value = "", s.value = null, a.value = !1, b.value) {
|
|
1328
1330
|
r.value = !1;
|
|
1329
1331
|
return;
|
|
1330
1332
|
}
|
|
1331
1333
|
e.deleteNode();
|
|
1332
|
-
},
|
|
1334
|
+
}, N = async (t) => {
|
|
1333
1335
|
if (!g.value) return;
|
|
1334
1336
|
let n = e.extension.options;
|
|
1335
1337
|
l.value = !0, s.value = null;
|
|
1336
1338
|
try {
|
|
1337
|
-
let i = await
|
|
1339
|
+
let i = await j(S(t, b.value && r.value ? "image-replace" : "image-insert"), n?.onUpload);
|
|
1338
1340
|
e.updateAttributes(v(u.value, i)), o.value = "", r.value = !1;
|
|
1339
1341
|
} catch (e) {
|
|
1340
1342
|
s.value = e instanceof Error ? e.message : y.value.uploadFailedError;
|
|
1341
1343
|
} finally {
|
|
1342
1344
|
l.value = !1, a.value = !1;
|
|
1343
1345
|
}
|
|
1344
|
-
},
|
|
1346
|
+
}, ne = () => {
|
|
1345
1347
|
if (!o.value.trim()) {
|
|
1346
1348
|
s.value = y.value.uploadRequiredError;
|
|
1347
1349
|
return;
|
|
1348
1350
|
}
|
|
1349
|
-
|
|
1350
|
-
},
|
|
1351
|
-
|
|
1351
|
+
N(k(o.value));
|
|
1352
|
+
}, P = (e) => {
|
|
1353
|
+
N({
|
|
1352
1354
|
type: "file",
|
|
1353
1355
|
file: e,
|
|
1354
1356
|
mimeType: e.type || "image/*"
|
|
1355
1357
|
});
|
|
1356
|
-
},
|
|
1358
|
+
}, re = () => {
|
|
1357
1359
|
d.value = !d.value, d.value && (f.value = E.value ?? "");
|
|
1358
|
-
},
|
|
1360
|
+
}, F = (n, r) => {
|
|
1359
1361
|
if (!g.value || !b.value) return;
|
|
1360
|
-
r.preventDefault(), r.stopPropagation(),
|
|
1362
|
+
r.preventDefault(), r.stopPropagation(), M();
|
|
1361
1363
|
let i = t.value;
|
|
1362
1364
|
if (!i) return;
|
|
1363
1365
|
let a = r.clientX, o = i.getBoundingClientRect().width || T.value || 320, s = i.closest(".markweave-editor-surface")?.getBoundingClientRect().width ?? i.parentElement?.getBoundingClientRect().width ?? o, c = (t) => {
|
|
@@ -1368,7 +1370,7 @@ var sr = J({
|
|
|
1368
1370
|
};
|
|
1369
1371
|
window.addEventListener("pointermove", c), window.addEventListener("pointerup", l, { once: !0 });
|
|
1370
1372
|
};
|
|
1371
|
-
return () =>
|
|
1373
|
+
return () => ee.value ? B(i, {
|
|
1372
1374
|
as: "figure",
|
|
1373
1375
|
class: "markweave-image-node",
|
|
1374
1376
|
"data-testid": "markweave-image-node",
|
|
@@ -1376,7 +1378,7 @@ var sr = J({
|
|
|
1376
1378
|
"data-selected": "false",
|
|
1377
1379
|
"data-hovered": "false",
|
|
1378
1380
|
"data-empty": "true"
|
|
1379
|
-
}, () =>
|
|
1381
|
+
}, () => fr({
|
|
1380
1382
|
messages: _.value,
|
|
1381
1383
|
inputValue: o.value,
|
|
1382
1384
|
error: s.value,
|
|
@@ -1385,9 +1387,9 @@ var sr = J({
|
|
|
1385
1387
|
onInputValue: (e) => {
|
|
1386
1388
|
o.value = e;
|
|
1387
1389
|
},
|
|
1388
|
-
onFile:
|
|
1389
|
-
onSubmit:
|
|
1390
|
-
onCancel:
|
|
1390
|
+
onFile: P,
|
|
1391
|
+
onSubmit: ne,
|
|
1392
|
+
onCancel: te,
|
|
1391
1393
|
onDragActive: (e) => {
|
|
1392
1394
|
a.value = e;
|
|
1393
1395
|
}
|
|
@@ -1406,7 +1408,7 @@ var sr = J({
|
|
|
1406
1408
|
n.value = !1;
|
|
1407
1409
|
},
|
|
1408
1410
|
onMousedown: (e) => {
|
|
1409
|
-
g.value && !
|
|
1411
|
+
g.value && !lr(e.target) && M();
|
|
1410
1412
|
}
|
|
1411
1413
|
}, () => [
|
|
1412
1414
|
g.value ? B("div", {
|
|
@@ -1418,21 +1420,21 @@ var sr = J({
|
|
|
1418
1420
|
X({
|
|
1419
1421
|
testId: "markweave-image-align-left",
|
|
1420
1422
|
label: y.value.alignLeft,
|
|
1421
|
-
icon:
|
|
1423
|
+
icon: hn,
|
|
1422
1424
|
active: C.value === "left",
|
|
1423
1425
|
onClick: () => e.updateAttributes({ align: "left" })
|
|
1424
1426
|
}),
|
|
1425
1427
|
X({
|
|
1426
1428
|
testId: "markweave-image-align-center",
|
|
1427
1429
|
label: y.value.alignCenter,
|
|
1428
|
-
icon:
|
|
1430
|
+
icon: pn,
|
|
1429
1431
|
active: C.value === "center",
|
|
1430
1432
|
onClick: () => e.updateAttributes({ align: "center" })
|
|
1431
1433
|
}),
|
|
1432
1434
|
X({
|
|
1433
1435
|
testId: "markweave-image-align-right",
|
|
1434
1436
|
label: y.value.alignRight,
|
|
1435
|
-
icon:
|
|
1437
|
+
icon: gn,
|
|
1436
1438
|
active: C.value === "right",
|
|
1437
1439
|
onClick: () => e.updateAttributes({ align: "right" })
|
|
1438
1440
|
}),
|
|
@@ -1443,20 +1445,20 @@ var sr = J({
|
|
|
1443
1445
|
X({
|
|
1444
1446
|
testId: "markweave-image-caption",
|
|
1445
1447
|
label: y.value.caption,
|
|
1446
|
-
icon:
|
|
1448
|
+
icon: bn,
|
|
1447
1449
|
active: d.value || !!E.value,
|
|
1448
|
-
onClick:
|
|
1450
|
+
onClick: re
|
|
1449
1451
|
}),
|
|
1450
1452
|
X({
|
|
1451
1453
|
testId: "markweave-image-preview",
|
|
1452
1454
|
label: y.value.preview,
|
|
1453
|
-
icon:
|
|
1454
|
-
onClick:
|
|
1455
|
+
icon: On,
|
|
1456
|
+
onClick: A
|
|
1455
1457
|
}),
|
|
1456
1458
|
X({
|
|
1457
1459
|
testId: "markweave-image-download",
|
|
1458
1460
|
label: y.value.download,
|
|
1459
|
-
icon:
|
|
1461
|
+
icon: Dn,
|
|
1460
1462
|
onClick: () => {
|
|
1461
1463
|
b.value && w(b.value);
|
|
1462
1464
|
}
|
|
@@ -1464,7 +1466,7 @@ var sr = J({
|
|
|
1464
1466
|
X({
|
|
1465
1467
|
testId: "markweave-image-replace",
|
|
1466
1468
|
label: y.value.replace,
|
|
1467
|
-
icon:
|
|
1469
|
+
icon: Jn,
|
|
1468
1470
|
onClick: () => {
|
|
1469
1471
|
o.value = "", s.value = null, r.value = !0;
|
|
1470
1472
|
}
|
|
@@ -1476,7 +1478,7 @@ var sr = J({
|
|
|
1476
1478
|
X({
|
|
1477
1479
|
testId: "markweave-image-delete",
|
|
1478
1480
|
label: y.value.delete,
|
|
1479
|
-
icon:
|
|
1481
|
+
icon: nr,
|
|
1480
1482
|
onClick: () => e.deleteNode()
|
|
1481
1483
|
})
|
|
1482
1484
|
]) : null,
|
|
@@ -1488,8 +1490,8 @@ var sr = J({
|
|
|
1488
1490
|
b.value ? B("img", {
|
|
1489
1491
|
class: "markweave-image",
|
|
1490
1492
|
src: b.value,
|
|
1491
|
-
alt:
|
|
1492
|
-
title:
|
|
1493
|
+
alt: O(u.value.alt) ?? "",
|
|
1494
|
+
title: O(u.value.title) ?? void 0,
|
|
1493
1495
|
draggable: !1
|
|
1494
1496
|
}) : B("div", {
|
|
1495
1497
|
class: "markweave-image-readonly-empty",
|
|
@@ -1504,8 +1506,8 @@ var sr = J({
|
|
|
1504
1506
|
"aria-label": y.value.preview,
|
|
1505
1507
|
title: y.value.preview,
|
|
1506
1508
|
onMousedown: (e) => e.preventDefault(),
|
|
1507
|
-
onClick:
|
|
1508
|
-
}, [B(
|
|
1509
|
+
onClick: A
|
|
1510
|
+
}, [B(On, {
|
|
1509
1511
|
size: 16,
|
|
1510
1512
|
strokeWidth: 1.8
|
|
1511
1513
|
}), B("span", {
|
|
@@ -1519,7 +1521,7 @@ var sr = J({
|
|
|
1519
1521
|
"data-side": "left",
|
|
1520
1522
|
"aria-label": y.value.resizeLeft,
|
|
1521
1523
|
"data-markweave-image-ui": "true",
|
|
1522
|
-
onPointerdown: (e) =>
|
|
1524
|
+
onPointerdown: (e) => F("left", e)
|
|
1523
1525
|
}) : null,
|
|
1524
1526
|
g.value ? B("button", {
|
|
1525
1527
|
type: "button",
|
|
@@ -1528,7 +1530,7 @@ var sr = J({
|
|
|
1528
1530
|
"data-side": "right",
|
|
1529
1531
|
"aria-label": y.value.resizeRight,
|
|
1530
1532
|
"data-markweave-image-ui": "true",
|
|
1531
|
-
onPointerdown: (e) =>
|
|
1533
|
+
onPointerdown: (e) => F("right", e)
|
|
1532
1534
|
}) : null
|
|
1533
1535
|
]),
|
|
1534
1536
|
g.value && (d.value || E.value) ? B("input", {
|
|
@@ -1550,7 +1552,7 @@ var sr = J({
|
|
|
1550
1552
|
}, E.value) : null
|
|
1551
1553
|
]);
|
|
1552
1554
|
}
|
|
1553
|
-
}),
|
|
1555
|
+
}), hr = J({
|
|
1554
1556
|
name: "MarkweaveVueVideoNodeView",
|
|
1555
1557
|
props: {
|
|
1556
1558
|
editor: {
|
|
@@ -1583,14 +1585,14 @@ var sr = J({
|
|
|
1583
1585
|
}
|
|
1584
1586
|
},
|
|
1585
1587
|
setup(e) {
|
|
1586
|
-
let t = V(!1), n = V(""), r = V(null), a = V(!1), o =
|
|
1588
|
+
let t = V(!1), n = V(""), r = V(null), a = V(!1), o = cr(e.editor), s = U(() => c(o.value)), l = U(() => e.extension.options?.messages ?? p("zh")), u = U(() => l.value.video), d = U(() => e.node.attrs), f = U(() => O(d.value.src)), m = U(() => O(d.value.embedUrl)), h = U(() => O(d.value.provider)), g = U(() => m.value ? ee(m.value, h.value) : null), _ = U(() => O(d.value.mimeType)), v = U(() => O(d.value.title)), x = () => {
|
|
1587
1589
|
f.value || e.deleteNode(), n.value = "", r.value = null, t.value = !1;
|
|
1588
1590
|
}, S = async (i) => {
|
|
1589
1591
|
if (!s.value) return;
|
|
1590
1592
|
let o = e.extension.options;
|
|
1591
1593
|
a.value = !0, r.value = null;
|
|
1592
1594
|
try {
|
|
1593
|
-
let t = await
|
|
1595
|
+
let t = await j(C(i), o?.onUpload);
|
|
1594
1596
|
e.updateAttributes(y(t)), n.value = "";
|
|
1595
1597
|
} catch (e) {
|
|
1596
1598
|
r.value = e instanceof Error ? e.message : u.value.uploadFailedError;
|
|
@@ -1611,11 +1613,11 @@ var sr = J({
|
|
|
1611
1613
|
file: e,
|
|
1612
1614
|
mimeType: e.type || "video/*"
|
|
1613
1615
|
});
|
|
1614
|
-
},
|
|
1616
|
+
}, D = () => {
|
|
1615
1617
|
if (!s.value) return;
|
|
1616
1618
|
let t = e.getPos();
|
|
1617
1619
|
typeof t == "number" && e.editor.chain().focus().setNodeSelection(t).run();
|
|
1618
|
-
},
|
|
1620
|
+
}, k = (t) => {
|
|
1619
1621
|
s.value && e.selected && (t.key === "Backspace" || t.key === "Delete") && (t.preventDefault(), e.deleteNode());
|
|
1620
1622
|
};
|
|
1621
1623
|
return () => s.value && !f.value ? B(i, {
|
|
@@ -1624,7 +1626,7 @@ var sr = J({
|
|
|
1624
1626
|
"data-testid": "markweave-video-node",
|
|
1625
1627
|
"data-empty": "true",
|
|
1626
1628
|
"data-selected": "false"
|
|
1627
|
-
}, () =>
|
|
1629
|
+
}, () => pr({
|
|
1628
1630
|
messages: l.value,
|
|
1629
1631
|
inputValue: n.value,
|
|
1630
1632
|
error: r.value,
|
|
@@ -1648,10 +1650,10 @@ var sr = J({
|
|
|
1648
1650
|
"data-selected": s.value && e.selected ? "true" : "false",
|
|
1649
1651
|
"aria-label": u.value.nodeAriaLabel,
|
|
1650
1652
|
tabindex: s.value ? 0 : void 0,
|
|
1651
|
-
onFocus:
|
|
1652
|
-
onKeydown:
|
|
1653
|
+
onFocus: D,
|
|
1654
|
+
onKeydown: k,
|
|
1653
1655
|
onMousedown: (e) => {
|
|
1654
|
-
s.value && !
|
|
1656
|
+
s.value && !ur(e.target) && (e.preventDefault(), D());
|
|
1655
1657
|
}
|
|
1656
1658
|
}, () => [g.value ? B("div", { class: "markweave-video-embed" }, [B("iframe", {
|
|
1657
1659
|
class: "markweave-video-iframe",
|
|
@@ -1661,6 +1663,7 @@ var sr = J({
|
|
|
1661
1663
|
"data-markweave-video-provider": h.value ?? void 0,
|
|
1662
1664
|
"data-markweave-video-src": f.value ?? void 0,
|
|
1663
1665
|
allow: T,
|
|
1666
|
+
loading: "lazy",
|
|
1664
1667
|
allowfullscreen: "true"
|
|
1665
1668
|
}), s.value ? B("button", {
|
|
1666
1669
|
type: "button",
|
|
@@ -1672,6 +1675,7 @@ var sr = J({
|
|
|
1672
1675
|
class: "markweave-video",
|
|
1673
1676
|
src: f.value,
|
|
1674
1677
|
title: v.value ?? void 0,
|
|
1678
|
+
preload: "metadata",
|
|
1675
1679
|
controls: !0,
|
|
1676
1680
|
"data-markweave-video": "true",
|
|
1677
1681
|
"data-markweave-mime-type": _.value ?? void 0
|
|
@@ -1687,7 +1691,7 @@ var sr = J({
|
|
|
1687
1691
|
"aria-hidden": "true"
|
|
1688
1692
|
})]);
|
|
1689
1693
|
}
|
|
1690
|
-
}),
|
|
1694
|
+
}), gr = g.extend({
|
|
1691
1695
|
addOptions() {
|
|
1692
1696
|
return {
|
|
1693
1697
|
...this.parent?.(),
|
|
@@ -1696,9 +1700,9 @@ var sr = J({
|
|
|
1696
1700
|
};
|
|
1697
1701
|
},
|
|
1698
1702
|
addNodeView() {
|
|
1699
|
-
return typeof document > "u" ? null : a(
|
|
1703
|
+
return typeof document > "u" ? null : a(mr, { stopEvent: ({ event: e }) => lr(e.target) });
|
|
1700
1704
|
}
|
|
1701
|
-
}),
|
|
1705
|
+
}), _r = _.extend({
|
|
1702
1706
|
addOptions() {
|
|
1703
1707
|
return {
|
|
1704
1708
|
...this.parent?.(),
|
|
@@ -1707,17 +1711,17 @@ var sr = J({
|
|
|
1707
1711
|
};
|
|
1708
1712
|
},
|
|
1709
1713
|
addNodeView() {
|
|
1710
|
-
return typeof document > "u" ? null : a(
|
|
1714
|
+
return typeof document > "u" ? null : a(hr, { stopEvent: ({ event: e }) => ur(e.target) });
|
|
1711
1715
|
}
|
|
1712
1716
|
});
|
|
1713
1717
|
//#endregion
|
|
1714
1718
|
//#region src/create-editor-extensions.ts
|
|
1715
|
-
function
|
|
1719
|
+
function vr(n = {}) {
|
|
1716
1720
|
return e({
|
|
1717
1721
|
lang: n.lang,
|
|
1718
1722
|
mediaExtensions: t({
|
|
1719
|
-
image:
|
|
1720
|
-
video:
|
|
1723
|
+
image: gr,
|
|
1724
|
+
video: _r,
|
|
1721
1725
|
lang: n.lang,
|
|
1722
1726
|
onImageUpload: n.onImageUpload,
|
|
1723
1727
|
onVideoUpload: n.onVideoUpload
|
|
@@ -1726,7 +1730,7 @@ function dr(n = {}) {
|
|
|
1726
1730
|
}
|
|
1727
1731
|
//#endregion
|
|
1728
1732
|
//#region src/MarkweaveEditor.ts
|
|
1729
|
-
var
|
|
1733
|
+
var yr = {
|
|
1730
1734
|
active: !1,
|
|
1731
1735
|
mode: "outside",
|
|
1732
1736
|
activeCellPos: null,
|
|
@@ -1734,17 +1738,17 @@ var fr = {
|
|
|
1734
1738
|
selectedCellCount: 0,
|
|
1735
1739
|
selectionFrom: 0,
|
|
1736
1740
|
selectionTo: 0
|
|
1737
|
-
},
|
|
1741
|
+
}, br = {
|
|
1738
1742
|
active: !1,
|
|
1739
|
-
language:
|
|
1743
|
+
language: Oe.defaultLanguage,
|
|
1740
1744
|
mermaidPreviewMode: "code",
|
|
1741
1745
|
pos: null,
|
|
1742
1746
|
text: ""
|
|
1743
1747
|
};
|
|
1744
|
-
function
|
|
1745
|
-
return
|
|
1748
|
+
function xr(e) {
|
|
1749
|
+
return Nt.getState(e.state) ?? Mt;
|
|
1746
1750
|
}
|
|
1747
|
-
function
|
|
1751
|
+
function Sr(e) {
|
|
1748
1752
|
if (!e || typeof window > "u") return null;
|
|
1749
1753
|
let t = e.parentElement;
|
|
1750
1754
|
for (; t;) {
|
|
@@ -1761,7 +1765,7 @@ function Z(e, t, n = 18, r = 1.8) {
|
|
|
1761
1765
|
"aria-hidden": "true"
|
|
1762
1766
|
}, { default: () => t });
|
|
1763
1767
|
}
|
|
1764
|
-
function
|
|
1768
|
+
function Cr(e) {
|
|
1765
1769
|
return e === "clipboard" ? [B("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" }), B("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" ? [B("circle", {
|
|
1766
1770
|
cx: "10",
|
|
1767
1771
|
cy: "10",
|
|
@@ -1809,57 +1813,57 @@ function Q(e) {
|
|
|
1809
1813
|
"stroke-linecap": "round",
|
|
1810
1814
|
"stroke-linejoin": "round",
|
|
1811
1815
|
"stroke-width": "1.8"
|
|
1812
|
-
},
|
|
1816
|
+
}, Cr(e)));
|
|
1813
1817
|
}
|
|
1814
1818
|
function $(e) {
|
|
1815
1819
|
e.preventDefault();
|
|
1816
1820
|
}
|
|
1817
|
-
function
|
|
1818
|
-
let t =
|
|
1821
|
+
function wr(e) {
|
|
1822
|
+
let t = et(e);
|
|
1819
1823
|
return !t || typeof window > "u" || typeof window.open != "function" ? !1 : (window.open(t, "_blank", "noopener,noreferrer"), !0);
|
|
1820
1824
|
}
|
|
1821
|
-
var
|
|
1822
|
-
bold:
|
|
1823
|
-
italic:
|
|
1824
|
-
underline:
|
|
1825
|
-
strike:
|
|
1826
|
-
"inline-code":
|
|
1827
|
-
link:
|
|
1828
|
-
more:
|
|
1829
|
-
superscript:
|
|
1830
|
-
subscript:
|
|
1831
|
-
"inline-math":
|
|
1832
|
-
"align-left":
|
|
1833
|
-
"align-center":
|
|
1834
|
-
"align-right":
|
|
1835
|
-
"align-justify":
|
|
1836
|
-
"decrease-indent":
|
|
1837
|
-
"increase-indent":
|
|
1838
|
-
},
|
|
1839
|
-
type:
|
|
1840
|
-
"heading-1":
|
|
1841
|
-
"heading-2":
|
|
1842
|
-
"heading-3":
|
|
1843
|
-
"bullet-list":
|
|
1844
|
-
"ordered-list":
|
|
1845
|
-
"task-list":
|
|
1846
|
-
blockquote:
|
|
1847
|
-
"code-block":
|
|
1848
|
-
info:
|
|
1849
|
-
tip:
|
|
1850
|
-
warning:
|
|
1851
|
-
error:
|
|
1852
|
-
success:
|
|
1853
|
-
emoji:
|
|
1854
|
-
math:
|
|
1855
|
-
table:
|
|
1856
|
-
separator:
|
|
1857
|
-
image:
|
|
1858
|
-
video:
|
|
1859
|
-
attachment:
|
|
1825
|
+
var Tr = {
|
|
1826
|
+
bold: vn,
|
|
1827
|
+
italic: Rn,
|
|
1828
|
+
underline: ir,
|
|
1829
|
+
strike: Zn,
|
|
1830
|
+
"inline-code": Tn,
|
|
1831
|
+
link: Bn,
|
|
1832
|
+
more: Gn,
|
|
1833
|
+
superscript: $n,
|
|
1834
|
+
subscript: Qn,
|
|
1835
|
+
"inline-math": Yn,
|
|
1836
|
+
"align-left": hn,
|
|
1837
|
+
"align-center": pn,
|
|
1838
|
+
"align-right": gn,
|
|
1839
|
+
"align-justify": mn,
|
|
1840
|
+
"decrease-indent": Fn,
|
|
1841
|
+
"increase-indent": In
|
|
1842
|
+
}, Er = {
|
|
1843
|
+
type: tr,
|
|
1844
|
+
"heading-1": An,
|
|
1845
|
+
"heading-2": jn,
|
|
1846
|
+
"heading-3": Mn,
|
|
1847
|
+
"bullet-list": Vn,
|
|
1848
|
+
"ordered-list": Un,
|
|
1849
|
+
"task-list": Hn,
|
|
1850
|
+
blockquote: qn,
|
|
1851
|
+
"code-block": yn,
|
|
1852
|
+
info: Ln,
|
|
1853
|
+
tip: zn,
|
|
1854
|
+
warning: _n,
|
|
1855
|
+
error: wn,
|
|
1856
|
+
success: xn,
|
|
1857
|
+
emoji: Xn,
|
|
1858
|
+
math: Yn,
|
|
1859
|
+
table: er,
|
|
1860
|
+
separator: Wn,
|
|
1861
|
+
image: Nn,
|
|
1862
|
+
video: or,
|
|
1863
|
+
attachment: Kn
|
|
1860
1864
|
};
|
|
1861
|
-
function
|
|
1862
|
-
let t =
|
|
1865
|
+
function Dr(e) {
|
|
1866
|
+
let t = Er[e];
|
|
1863
1867
|
return B(t, {
|
|
1864
1868
|
size: 18,
|
|
1865
1869
|
strokeWidth: 1.6,
|
|
@@ -1867,21 +1871,21 @@ function br(e) {
|
|
|
1867
1871
|
"aria-hidden": "true"
|
|
1868
1872
|
});
|
|
1869
1873
|
}
|
|
1870
|
-
var
|
|
1871
|
-
paragraph:
|
|
1872
|
-
"heading-1":
|
|
1873
|
-
"heading-2":
|
|
1874
|
-
"heading-3":
|
|
1875
|
-
"bullet-list":
|
|
1876
|
-
"numbered-list":
|
|
1877
|
-
"todo-list":
|
|
1878
|
-
quote:
|
|
1879
|
-
"code-block":
|
|
1874
|
+
var Or = {
|
|
1875
|
+
paragraph: rr,
|
|
1876
|
+
"heading-1": An,
|
|
1877
|
+
"heading-2": jn,
|
|
1878
|
+
"heading-3": Mn,
|
|
1879
|
+
"bullet-list": Vn,
|
|
1880
|
+
"numbered-list": Un,
|
|
1881
|
+
"todo-list": Hn,
|
|
1882
|
+
quote: qn,
|
|
1883
|
+
"code-block": yn
|
|
1880
1884
|
};
|
|
1881
|
-
function
|
|
1885
|
+
function kr(e, t) {
|
|
1882
1886
|
return L(e, t).label;
|
|
1883
1887
|
}
|
|
1884
|
-
var
|
|
1888
|
+
var Ar = J({
|
|
1885
1889
|
name: "MarkweaveVueFloatingToolbar",
|
|
1886
1890
|
props: {
|
|
1887
1891
|
editor: {
|
|
@@ -1898,44 +1902,66 @@ var Cr = J({
|
|
|
1898
1902
|
}
|
|
1899
1903
|
},
|
|
1900
1904
|
setup(e) {
|
|
1901
|
-
let t = V(null), n = V(""), r = V(null), i = V(null), a = V(
|
|
1905
|
+
let t = V(null), n = V(""), r = V(null), i = V(null), a = V("bottom"), o = V(null), s = V(null), c = V(null), l = U(() => et(n.value.trim())), u = U(() => e.messages.floatingToolbar), d = U(() => oe(e.messages).map((e) => [
|
|
1902
1906
|
e.id,
|
|
1903
1907
|
e.label,
|
|
1904
|
-
|
|
1905
|
-
])),
|
|
1908
|
+
Or[e.id]
|
|
1909
|
+
])), f = U(() => ae(e.messages).map((e) => [
|
|
1906
1910
|
e.id,
|
|
1907
1911
|
e.value,
|
|
1908
1912
|
e.label
|
|
1909
|
-
])),
|
|
1913
|
+
])), p = U(() => R(e.messages).map((e) => [
|
|
1910
1914
|
e.id,
|
|
1911
1915
|
e.value,
|
|
1912
1916
|
e.label
|
|
1913
|
-
])),
|
|
1914
|
-
|
|
1915
|
-
},
|
|
1917
|
+
])), m = U(() => ie(e.messages).map((e) => e.id)), h = () => {
|
|
1918
|
+
l.value && (e.editor.chain().focus().extendMarkRange("link").setLink({ href: l.value }).run(), t.value = null);
|
|
1919
|
+
}, g = () => {
|
|
1916
1920
|
e.editor.isActive("link") && e.editor.chain().focus().extendMarkRange("link").unsetLink().run(), n.value = "", t.value = null;
|
|
1917
|
-
},
|
|
1921
|
+
}, _ = (r) => {
|
|
1918
1922
|
t.value = t.value === r ? null : r, r === "link" && (n.value = e.editor.getAttributes("link").href ?? "");
|
|
1919
|
-
},
|
|
1920
|
-
|
|
1923
|
+
}, v = N(() => {
|
|
1924
|
+
let n = o.value, r = c.value, i = e.editor.view.dom.closest(".markweave-editor-frame");
|
|
1925
|
+
if (!t.value || !n || !r) return;
|
|
1926
|
+
let s = fe({
|
|
1927
|
+
toolbarRect: n.getBoundingClientRect(),
|
|
1928
|
+
popoverSize: r.getBoundingClientRect(),
|
|
1929
|
+
viewport: {
|
|
1930
|
+
width: window.innerWidth,
|
|
1931
|
+
height: window.innerHeight
|
|
1932
|
+
},
|
|
1933
|
+
frameRect: i?.getBoundingClientRect() ?? null,
|
|
1934
|
+
gap: t.value === "more" ? 8 : 6
|
|
1935
|
+
});
|
|
1936
|
+
a.value = s.placement;
|
|
1937
|
+
});
|
|
1938
|
+
W(t, (e) => {
|
|
1939
|
+
e && q(v.schedule);
|
|
1940
|
+
}), G(() => {
|
|
1941
|
+
window.addEventListener("resize", v.schedule), window.addEventListener("scroll", v.schedule, !0);
|
|
1942
|
+
}), K(() => {
|
|
1943
|
+
v.cancel(), window.removeEventListener("resize", v.schedule), window.removeEventListener("scroll", v.schedule, !0);
|
|
1944
|
+
});
|
|
1945
|
+
let y = (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, b = (e, t) => {
|
|
1946
|
+
if (r.value = e, !e || !(t instanceof HTMLElement) || !s.value) {
|
|
1921
1947
|
i.value = null;
|
|
1922
1948
|
return;
|
|
1923
1949
|
}
|
|
1924
|
-
let n = t.getBoundingClientRect(),
|
|
1925
|
-
i.value = n.left + n.width / 2 -
|
|
1926
|
-
},
|
|
1950
|
+
let n = t.getBoundingClientRect(), a = s.value.getBoundingClientRect();
|
|
1951
|
+
i.value = n.left + n.width / 2 - a.left;
|
|
1952
|
+
}, x = () => {
|
|
1927
1953
|
let e = r.value;
|
|
1928
1954
|
if (!e || t.value !== null) return null;
|
|
1929
|
-
let n =
|
|
1955
|
+
let n = u.value.buttons[e];
|
|
1930
1956
|
return n ? B("div", {
|
|
1931
1957
|
class: "markweave-floating-toolbar-tooltip",
|
|
1932
1958
|
role: "tooltip",
|
|
1933
1959
|
"data-testid": "markweave-floating-toolbar-tooltip",
|
|
1934
1960
|
"data-button-id": e,
|
|
1935
|
-
"data-active":
|
|
1961
|
+
"data-active": y(e),
|
|
1936
1962
|
style: i.value === null ? void 0 : { "--markweave-floating-toolbar-tooltip-left": `${i.value}px` }
|
|
1937
1963
|
}, n) : null;
|
|
1938
|
-
},
|
|
1964
|
+
}, S = (n, i, a, o, s = !1, c) => B("button", {
|
|
1939
1965
|
type: "button",
|
|
1940
1966
|
class: `markweave-floating-toolbar-button markweave-floating-toolbar-button--${n}`,
|
|
1941
1967
|
"aria-label": i,
|
|
@@ -1948,16 +1974,16 @@ var Cr = J({
|
|
|
1948
1974
|
"data-active": s || t.value === n,
|
|
1949
1975
|
"data-tooltip-active": r.value === n ? "true" : "false",
|
|
1950
1976
|
"data-testid": `markweave-floating-toolbar-button-${n}`,
|
|
1951
|
-
onBlur: () =>
|
|
1952
|
-
onFocus: (e) =>
|
|
1977
|
+
onBlur: () => b(null),
|
|
1978
|
+
onFocus: (e) => b(n, e.currentTarget),
|
|
1953
1979
|
onMousedown: $,
|
|
1954
|
-
onMouseenter: (e) =>
|
|
1955
|
-
onMouseleave: () =>
|
|
1980
|
+
onMouseenter: (e) => b(n, e.currentTarget),
|
|
1981
|
+
onMouseleave: () => b(null),
|
|
1956
1982
|
onClick: o
|
|
1957
|
-
}, n === "block-type" ? [B("span", { class: "markweave-floating-toolbar-button-inner" }, [B("span", { class: "markweave-floating-toolbar-block-label" },
|
|
1983
|
+
}, n === "block-type" ? [B("span", { class: "markweave-floating-toolbar-button-inner" }, [B("span", { class: "markweave-floating-toolbar-block-label" }, kr(e.editor, e.messages)), Z(t.value === "block-type" ? Cn : Sn, i)])] : n === "color" ? [B("span", { class: "markweave-floating-toolbar-button-inner markweave-floating-toolbar-button-inner--color" }, [B("span", { class: "markweave-floating-toolbar-color-trigger" }, "A"), Z(t.value === "color" ? Cn : Sn, i)])] : [Z(a, i)]), C = () => B("span", {
|
|
1958
1984
|
class: "markweave-floating-toolbar-divider",
|
|
1959
1985
|
"aria-hidden": "true"
|
|
1960
|
-
}),
|
|
1986
|
+
}), w = (n, r, i) => B("section", {
|
|
1961
1987
|
class: "markweave-floating-toolbar-color-section",
|
|
1962
1988
|
"aria-label": n
|
|
1963
1989
|
}, [B("div", { class: "markweave-floating-toolbar-menu-title" }, n), B("div", { class: "markweave-floating-toolbar-swatch-grid" }, i.map(([n, i, a]) => B("button", {
|
|
@@ -1976,27 +2002,29 @@ var Cr = J({
|
|
|
1976
2002
|
class: "markweave-floating-toolbar-highlight-swatch",
|
|
1977
2003
|
style: { backgroundColor: i ?? "#ffffff" },
|
|
1978
2004
|
"aria-hidden": "true"
|
|
1979
|
-
})])))]),
|
|
2005
|
+
})])))]), T = () => t.value === "block-type" ? B("div", {
|
|
2006
|
+
ref: c,
|
|
1980
2007
|
class: "markweave-floating-toolbar-popover markweave-floating-toolbar-turn-menu",
|
|
1981
2008
|
"data-testid": "markweave-floating-toolbar-turn-menu"
|
|
1982
|
-
}, [B("div", { class: "markweave-floating-toolbar-menu-title" },
|
|
2009
|
+
}, [B("div", { class: "markweave-floating-toolbar-menu-title" }, u.value.turnIntoTitle), ...d.value.map(([n, r, i]) => B("button", {
|
|
1983
2010
|
key: n,
|
|
1984
2011
|
type: "button",
|
|
1985
2012
|
"data-testid": `markweave-floating-toolbar-turn-${n}`,
|
|
1986
2013
|
onMousedown: $,
|
|
1987
2014
|
onClick: () => {
|
|
1988
|
-
|
|
2015
|
+
ce(e.editor, n), t.value = null;
|
|
1989
2016
|
}
|
|
1990
2017
|
}, [B("span", { class: "markweave-floating-toolbar-menu-icon" }, [Z(i, r)]), B("span", null, r)]))]) : t.value === "link" ? B("form", {
|
|
1991
2018
|
class: "markweave-floating-toolbar-popover markweave-floating-toolbar-link-popover",
|
|
2019
|
+
ref: c,
|
|
1992
2020
|
"data-testid": "markweave-floating-toolbar-link-popover",
|
|
1993
2021
|
onSubmit: (e) => {
|
|
1994
|
-
e.preventDefault(),
|
|
2022
|
+
e.preventDefault(), h();
|
|
1995
2023
|
}
|
|
1996
2024
|
}, [B("input", {
|
|
1997
2025
|
value: n.value,
|
|
1998
|
-
placeholder:
|
|
1999
|
-
"aria-label":
|
|
2026
|
+
placeholder: u.value.linkPlaceholder,
|
|
2027
|
+
"aria-label": u.value.linkUrlLabel,
|
|
2000
2028
|
"data-testid": "markweave-floating-toolbar-link-input",
|
|
2001
2029
|
onInput: (e) => {
|
|
2002
2030
|
n.value = e.target.value;
|
|
@@ -2004,42 +2032,44 @@ var Cr = J({
|
|
|
2004
2032
|
}), B("span", { class: "markweave-floating-toolbar-link-actions" }, [
|
|
2005
2033
|
B("button", {
|
|
2006
2034
|
type: "submit",
|
|
2007
|
-
disabled: !
|
|
2008
|
-
"aria-label":
|
|
2035
|
+
disabled: !l.value,
|
|
2036
|
+
"aria-label": u.value.applyLink,
|
|
2009
2037
|
"data-testid": "markweave-floating-toolbar-link-apply",
|
|
2010
2038
|
onMousedown: $
|
|
2011
|
-
}, [Z(
|
|
2039
|
+
}, [Z(En, u.value.applyLink)]),
|
|
2012
2040
|
B("span", {
|
|
2013
2041
|
class: "markweave-floating-toolbar-link-divider",
|
|
2014
2042
|
"aria-hidden": "true"
|
|
2015
2043
|
}),
|
|
2016
2044
|
B("button", {
|
|
2017
2045
|
type: "button",
|
|
2018
|
-
disabled: !
|
|
2019
|
-
"aria-label":
|
|
2046
|
+
disabled: !l.value,
|
|
2047
|
+
"aria-label": u.value.openLink,
|
|
2020
2048
|
"data-testid": "markweave-floating-toolbar-link-open",
|
|
2021
2049
|
onMousedown: $,
|
|
2022
|
-
onClick: () =>
|
|
2023
|
-
}, [Z(
|
|
2050
|
+
onClick: () => wr(n.value)
|
|
2051
|
+
}, [Z(kn, u.value.openLink)]),
|
|
2024
2052
|
B("button", {
|
|
2025
2053
|
type: "button",
|
|
2026
|
-
"aria-label":
|
|
2054
|
+
"aria-label": u.value.removeLink,
|
|
2027
2055
|
"data-testid": "markweave-floating-toolbar-link-remove",
|
|
2028
2056
|
onMousedown: $,
|
|
2029
|
-
onClick:
|
|
2030
|
-
}, [Z(
|
|
2057
|
+
onClick: g
|
|
2058
|
+
}, [Z(nr, u.value.removeLink)])
|
|
2031
2059
|
])]) : t.value === "color" ? B("div", {
|
|
2060
|
+
ref: c,
|
|
2032
2061
|
class: "markweave-floating-toolbar-popover markweave-floating-toolbar-color-popover",
|
|
2033
2062
|
"data-testid": "markweave-floating-toolbar-color-menu"
|
|
2034
|
-
}, [
|
|
2063
|
+
}, [w(u.value.textColorTitle, "text", f.value), w(u.value.highlightColorTitle, "highlight", p.value)]) : t.value === "more" ? B("div", {
|
|
2064
|
+
ref: c,
|
|
2035
2065
|
class: "markweave-floating-toolbar-popover markweave-floating-toolbar-more-menu",
|
|
2036
2066
|
"data-testid": "markweave-floating-toolbar-more-menu"
|
|
2037
|
-
},
|
|
2067
|
+
}, m.value.map((n) => B("span", {
|
|
2038
2068
|
key: n,
|
|
2039
2069
|
class: "markweave-floating-toolbar-more-item"
|
|
2040
2070
|
}, [B("button", {
|
|
2041
2071
|
type: "button",
|
|
2042
|
-
"aria-label":
|
|
2072
|
+
"aria-label": u.value.moreActions[n],
|
|
2043
2073
|
"data-testid": `markweave-floating-toolbar-more-${n}`,
|
|
2044
2074
|
"data-tooltip-active": r.value === n ? "true" : "false",
|
|
2045
2075
|
onMousedown: $,
|
|
@@ -2050,41 +2080,43 @@ var Cr = J({
|
|
|
2050
2080
|
r.value = null;
|
|
2051
2081
|
},
|
|
2052
2082
|
onClick: () => {
|
|
2053
|
-
|
|
2083
|
+
se(e.editor, n), t.value = null;
|
|
2054
2084
|
}
|
|
2055
|
-
}, [Z(
|
|
2085
|
+
}, [Z(Tr[n], u.value.moreActions[n])]), r.value === n ? B("div", {
|
|
2056
2086
|
class: "markweave-floating-toolbar-tooltip markweave-floating-toolbar-tooltip--more",
|
|
2057
2087
|
role: "tooltip"
|
|
2058
|
-
},
|
|
2059
|
-
return () => B(
|
|
2088
|
+
}, u.value.moreActions[n]) : null]))) : null;
|
|
2089
|
+
return () => B(M, {
|
|
2060
2090
|
editor: e.editor,
|
|
2061
|
-
shouldShow: ({ editor: e }) => e.isEditable &&
|
|
2091
|
+
shouldShow: ({ editor: e }) => e.isEditable && z(pe(e)),
|
|
2062
2092
|
options: { placement: "top" }
|
|
2063
2093
|
}, { default: () => B("div", {
|
|
2094
|
+
ref: o,
|
|
2064
2095
|
class: "markweave-floating-toolbar markweave-floating-toolbar--default markweave-floating-toolbar--motion-entered",
|
|
2096
|
+
"data-popover-placement": t.value ? a.value : void 0,
|
|
2065
2097
|
"data-testid": "markweave-floating-toolbar"
|
|
2066
2098
|
}, [B("div", {
|
|
2067
|
-
ref:
|
|
2099
|
+
ref: s,
|
|
2068
2100
|
class: "markweave-floating-toolbar-content",
|
|
2069
2101
|
"data-menu": t.value ?? "none"
|
|
2070
2102
|
}, [
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2103
|
+
S("block-type", u.value.buttons["block-type"], rr, () => _("block-type"), t.value === "block-type"),
|
|
2104
|
+
C(),
|
|
2105
|
+
S("bold", u.value.buttons.bold, vn, () => e.editor.chain().focus().toggleBold().run(), e.editor.isActive("bold")),
|
|
2106
|
+
S("italic", u.value.buttons.italic, Rn, () => e.editor.chain().focus().toggleItalic().run(), e.editor.isActive("italic")),
|
|
2107
|
+
S("underline", u.value.buttons.underline, ir, () => e.editor.chain().focus().toggleUnderline().run(), e.editor.isActive("underline")),
|
|
2108
|
+
S("strike", u.value.buttons.strike, Zn, () => e.editor.chain().focus().toggleStrike().run(), e.editor.isActive("strike")),
|
|
2109
|
+
S("inline-code", u.value.buttons["inline-code"], Tn, () => e.editor.chain().focus().toggleCode().run(), e.editor.isActive("code")),
|
|
2110
|
+
C(),
|
|
2111
|
+
S("link", u.value.buttons.link, Bn, () => _("link"), e.editor.isActive("link")),
|
|
2112
|
+
S("color", u.value.buttons.color, rr, () => _("color"), t.value === "color"),
|
|
2113
|
+
C(),
|
|
2114
|
+
S("more", u.value.buttons.more, Gn, () => _("more"), t.value === "more"),
|
|
2115
|
+
T(),
|
|
2116
|
+
x()
|
|
2085
2117
|
])]) });
|
|
2086
2118
|
}
|
|
2087
|
-
}),
|
|
2119
|
+
}), jr = J({
|
|
2088
2120
|
name: "MarkweaveVueMathEditorPopover",
|
|
2089
2121
|
props: {
|
|
2090
2122
|
editor: {
|
|
@@ -2105,17 +2137,17 @@ var Cr = J({
|
|
|
2105
2137
|
}
|
|
2106
2138
|
},
|
|
2107
2139
|
setup(e) {
|
|
2108
|
-
let t = V(e.target.latex), n = H(null), r = V(null), i = V(null), a = H(
|
|
2140
|
+
let t = V(e.target.latex), n = H(null), r = V(null), i = V(null), a = H(at(e.editor, e.target)), o = U(() => t.value === e.target.latex && a.value ? {
|
|
2109
2141
|
html: a.value,
|
|
2110
2142
|
error: !1
|
|
2111
|
-
} :
|
|
2143
|
+
} : lt(t.value, e.target.kind, e.editor)), s = U(() => t.value.trim().length > 0), c = U(() => e.messages.math), l = U(() => it(e.editor, e.target) ?? 1), u = () => {
|
|
2112
2144
|
if (typeof window > "u") return;
|
|
2113
|
-
let r =
|
|
2145
|
+
let r = rt(e.editor, e.target), i = e.editor.view.dom.closest(".markweave-editor-frame")?.getBoundingClientRect();
|
|
2114
2146
|
if (!r || !i) {
|
|
2115
2147
|
e.onClose();
|
|
2116
2148
|
return;
|
|
2117
2149
|
}
|
|
2118
|
-
n.value =
|
|
2150
|
+
n.value = nt({
|
|
2119
2151
|
anchorRect: r,
|
|
2120
2152
|
frameRect: i,
|
|
2121
2153
|
kind: e.target.kind,
|
|
@@ -2124,7 +2156,7 @@ var Cr = J({
|
|
|
2124
2156
|
viewportWidth: window.innerWidth
|
|
2125
2157
|
});
|
|
2126
2158
|
}, d = () => {
|
|
2127
|
-
s.value &&
|
|
2159
|
+
s.value && tt(e.editor, e.target, t.value) && e.onClose();
|
|
2128
2160
|
}, f = (t) => {
|
|
2129
2161
|
if (t.key === "Escape") {
|
|
2130
2162
|
t.preventDefault(), e.onClose(), e.editor.commands.focus();
|
|
@@ -2136,13 +2168,13 @@ var Cr = J({
|
|
|
2136
2168
|
n instanceof Node && (r.value?.contains(n) || n instanceof Element && n.closest(".tiptap-mathematics-render") || e.onClose());
|
|
2137
2169
|
};
|
|
2138
2170
|
return W(() => [e.target.pos, e.target.latex], () => {
|
|
2139
|
-
t.value = e.target.latex, a.value =
|
|
2171
|
+
t.value = e.target.latex, a.value = at(e.editor, e.target), q(u);
|
|
2140
2172
|
}), G(() => {
|
|
2141
|
-
|
|
2173
|
+
ut(e.editor, e.target, !0), u(), q(() => {
|
|
2142
2174
|
i.value?.focus({ preventScroll: !0 }), i.value?.select(), u();
|
|
2143
2175
|
}), window.addEventListener("resize", u), window.addEventListener("scroll", u, !0), document.addEventListener("mousedown", p);
|
|
2144
2176
|
}), K(() => {
|
|
2145
|
-
|
|
2177
|
+
ut(e.editor, e.target, !1), window.removeEventListener("resize", u), window.removeEventListener("scroll", u, !0), document.removeEventListener("mousedown", p);
|
|
2146
2178
|
}), () => {
|
|
2147
2179
|
let a = e.target.kind === "block" ? c.value.blockTitle : c.value.inlineTitle, u = {
|
|
2148
2180
|
ref: i,
|
|
@@ -2203,14 +2235,14 @@ var Cr = J({
|
|
|
2203
2235
|
}, [
|
|
2204
2236
|
B("div", { class: "markweave-math-block-toolbar" }, [
|
|
2205
2237
|
B("span", null, c.value.label),
|
|
2206
|
-
Z(
|
|
2238
|
+
Z(Tn, c.value.label, 15, 1.75),
|
|
2207
2239
|
B("button", {
|
|
2208
2240
|
type: "submit",
|
|
2209
2241
|
title: c.value.apply,
|
|
2210
2242
|
"aria-label": c.value.apply,
|
|
2211
2243
|
disabled: !s.value,
|
|
2212
2244
|
"data-testid": "markweave-math-editor-apply"
|
|
2213
|
-
}, [Z(
|
|
2245
|
+
}, [Z(xn, c.value.apply, 16, 2)])
|
|
2214
2246
|
]),
|
|
2215
2247
|
B("label", {
|
|
2216
2248
|
class: "markweave-math-block-source",
|
|
@@ -2233,7 +2265,7 @@ var Cr = J({
|
|
|
2233
2265
|
]);
|
|
2234
2266
|
};
|
|
2235
2267
|
}
|
|
2236
|
-
}),
|
|
2268
|
+
}), Mr = J({
|
|
2237
2269
|
name: "MarkweaveVueSlashCommandMenu",
|
|
2238
2270
|
props: {
|
|
2239
2271
|
commands: {
|
|
@@ -2292,13 +2324,13 @@ var Cr = J({
|
|
|
2292
2324
|
} : {
|
|
2293
2325
|
kind: e.inputCommand.uploadKind ?? "attachment",
|
|
2294
2326
|
trigger: "slash-command",
|
|
2295
|
-
source:
|
|
2327
|
+
source: k(t.value)
|
|
2296
2328
|
};
|
|
2297
2329
|
if (!n.value && !t.value.trim()) {
|
|
2298
2330
|
r.value = e.messages.slash.uploadRequiredError;
|
|
2299
2331
|
return;
|
|
2300
2332
|
}
|
|
2301
|
-
let a = await
|
|
2333
|
+
let a = await j(i, e.onUpload);
|
|
2302
2334
|
e.onSelect(e.inputCommand, { uploadResult: a }), e.onInputCommandChange(null), t.value = "", n.value = null;
|
|
2303
2335
|
} catch (t) {
|
|
2304
2336
|
r.value = t instanceof Error ? t.message : e.messages.slash.uploadFailedError;
|
|
@@ -2419,7 +2451,7 @@ var Cr = J({
|
|
|
2419
2451
|
class: "markweave-slash-group",
|
|
2420
2452
|
"aria-label": t.group
|
|
2421
2453
|
}, [B("div", { class: "markweave-slash-group-title" }, t.group), ...t.commands.map((t) => {
|
|
2422
|
-
let n = e.commands.indexOf(t) === e.state.activeIndex, r =
|
|
2454
|
+
let n = e.commands.indexOf(t) === e.state.activeIndex, r = yt(t);
|
|
2423
2455
|
return B("button", {
|
|
2424
2456
|
key: t.id,
|
|
2425
2457
|
type: "button",
|
|
@@ -2442,7 +2474,7 @@ var Cr = J({
|
|
|
2442
2474
|
}
|
|
2443
2475
|
}
|
|
2444
2476
|
}, [
|
|
2445
|
-
|
|
2477
|
+
Dr(t.icon),
|
|
2446
2478
|
B("span", null, t.label),
|
|
2447
2479
|
t.disabledReason ? B("small", null, t.disabledReason) : null
|
|
2448
2480
|
]);
|
|
@@ -2453,7 +2485,7 @@ var Cr = J({
|
|
|
2453
2485
|
}, e.messages.slash.noResults)])]);
|
|
2454
2486
|
};
|
|
2455
2487
|
}
|
|
2456
|
-
}),
|
|
2488
|
+
}), Nr = J({
|
|
2457
2489
|
name: "MarkweaveVueTableControls",
|
|
2458
2490
|
props: {
|
|
2459
2491
|
editor: {
|
|
@@ -2486,12 +2518,12 @@ var Cr = J({
|
|
|
2486
2518
|
}
|
|
2487
2519
|
},
|
|
2488
2520
|
setup(e) {
|
|
2489
|
-
let t = V(null), n = V("row-edge"), r = V(null), i = V(null), a = V(null), o = V(null), s = V(null), c = V(null), l = V(null), u = V(null), d = V(null), f = V(null), p = null, m = U(() => e.active ?
|
|
2521
|
+
let t = V(null), n = V("row-edge"), r = V(null), i = V(null), a = V(null), o = V(null), s = V(null), c = V(null), l = V(null), u = V(null), d = V(null), f = V(null), p = null, m = U(() => e.active ? At(e.editor.state) : yr), h = U(() => Ht(e.editor, e.interactionState, "row", m.value.activeCellPos)), g = U(() => Ht(e.editor, e.interactionState, "column", m.value.activeCellPos)), _ = U(() => Bt(e.editor)), v = U(() => _.value.length > 0), y = U(() => t.value ? Kt(e.editor, t.value) : []), b = () => {
|
|
2490
2522
|
p === null || typeof window > "u" || (window.clearTimeout(p), p = null);
|
|
2491
2523
|
}, x = (e) => {
|
|
2492
2524
|
b(), s.value = e, !(!e || typeof window > "u") && (p = window.setTimeout(() => {
|
|
2493
2525
|
s.value = null, p = null;
|
|
2494
|
-
},
|
|
2526
|
+
}, Xt));
|
|
2495
2527
|
}, S = () => {
|
|
2496
2528
|
if (!e.active) {
|
|
2497
2529
|
r.value = null, i.value = null, a.value = null, x(null);
|
|
@@ -2502,16 +2534,16 @@ var Cr = J({
|
|
|
2502
2534
|
r.value = null, i.value = null, a.value = null;
|
|
2503
2535
|
return;
|
|
2504
2536
|
}
|
|
2505
|
-
let s = o.getBoundingClientRect(), c = h.value ?
|
|
2506
|
-
c ? r.value =
|
|
2537
|
+
let s = o.getBoundingClientRect(), c = h.value ? Vt(e.editor, h.value) : null, l = g.value ? Vt(e.editor, g.value) : null, u = v.value ? qt(e.editor) : null;
|
|
2538
|
+
c ? r.value = Ft({
|
|
2507
2539
|
targetRect: c,
|
|
2508
2540
|
frameRect: s,
|
|
2509
2541
|
kind: "row"
|
|
2510
|
-
}) : t.value === "row" && n.value === "row-edge" || (r.value = null), l ? i.value =
|
|
2542
|
+
}) : t.value === "row" && n.value === "row-edge" || (r.value = null), l ? i.value = Ft({
|
|
2511
2543
|
targetRect: l,
|
|
2512
2544
|
frameRect: s,
|
|
2513
2545
|
kind: "column"
|
|
2514
|
-
}) : t.value === "column" && n.value === "column-edge" || (i.value = null), u ? a.value =
|
|
2546
|
+
}) : t.value === "column" && n.value === "column-edge" || (i.value = null), u ? a.value = Ft({
|
|
2515
2547
|
targetRect: u,
|
|
2516
2548
|
frameRect: s,
|
|
2517
2549
|
kind: "selection"
|
|
@@ -2526,13 +2558,13 @@ var Cr = J({
|
|
|
2526
2558
|
o.value = null;
|
|
2527
2559
|
return;
|
|
2528
2560
|
}
|
|
2529
|
-
let a = i.getBoundingClientRect(), s = t.value === "row" ?
|
|
2561
|
+
let a = i.getBoundingClientRect(), s = t.value === "row" ? zt(e.editor)?.getBoundingClientRect() : null, c = s ? {
|
|
2530
2562
|
left: a.left,
|
|
2531
2563
|
top: s.top,
|
|
2532
2564
|
width: a.width,
|
|
2533
2565
|
height: a.height
|
|
2534
2566
|
} : a, p = r.getBoundingClientRect(), m = f.value.getBoundingClientRect();
|
|
2535
|
-
o.value =
|
|
2567
|
+
o.value = Pt({
|
|
2536
2568
|
anchorRect: c,
|
|
2537
2569
|
frameRect: p,
|
|
2538
2570
|
menuSize: {
|
|
@@ -2548,35 +2580,35 @@ var Cr = J({
|
|
|
2548
2580
|
}, E = (e, r) => {
|
|
2549
2581
|
let i = t.value === e && n.value === r;
|
|
2550
2582
|
n.value = r, t.value = i ? null : e, T();
|
|
2551
|
-
},
|
|
2552
|
-
e.editor.view.dispatch(
|
|
2553
|
-
},
|
|
2583
|
+
}, ee = () => {
|
|
2584
|
+
e.editor.view.dispatch(Dt(e.editor.state.tr, null));
|
|
2585
|
+
}, D = (t, n) => {
|
|
2554
2586
|
let r = e.interactionState.hoverCellPos ?? m.value.activeCellPos, i = e.interactionState.hoverCellPos === null ? null : t === "row" ? e.interactionState.hoverVisualRowIndex : e.interactionState.hoverVisualColumnIndex;
|
|
2555
|
-
r !== null &&
|
|
2556
|
-
},
|
|
2557
|
-
|
|
2558
|
-
},
|
|
2587
|
+
r !== null && Yt(e.editor, r, t, { visualIndex: i }), E(t, n);
|
|
2588
|
+
}, O = () => {
|
|
2589
|
+
ee(), E("selection", "selection-edge");
|
|
2590
|
+
}, k = (n = !1) => {
|
|
2559
2591
|
t.value = null, o.value = null, n && e.editor.view.focus();
|
|
2560
|
-
},
|
|
2561
|
-
let i = await
|
|
2592
|
+
}, A = async (n, r) => {
|
|
2593
|
+
let i = await Lt({
|
|
2562
2594
|
editor: e.editor,
|
|
2563
2595
|
commandId: n,
|
|
2564
2596
|
menu: r ?? t.value ?? "selection",
|
|
2565
2597
|
messages: e.messages
|
|
2566
2598
|
});
|
|
2567
2599
|
return i.copyFeedback ? (x(i.copyFeedback), i.copyPayload && e.onCopyPayload?.(i.copyPayload)) : x(null), e.onCommandResult?.(i.commandResult), i.success;
|
|
2568
|
-
},
|
|
2569
|
-
let n =
|
|
2570
|
-
n && e.onEditWithAi?.(n),
|
|
2571
|
-
},
|
|
2572
|
-
!t.value || e.key !== "Escape" ||
|
|
2573
|
-
},
|
|
2574
|
-
t.value && (e.target instanceof Node && c.value?.contains(e.target) ||
|
|
2600
|
+
}, j = (t) => {
|
|
2601
|
+
let n = Ut(e.editor, t);
|
|
2602
|
+
n && e.onEditWithAi?.(n), k(!0);
|
|
2603
|
+
}, M = (e) => {
|
|
2604
|
+
!t.value || e.key !== "Escape" || k(!0);
|
|
2605
|
+
}, te = (e) => {
|
|
2606
|
+
t.value && (e.target instanceof Node && c.value?.contains(e.target) || k());
|
|
2575
2607
|
};
|
|
2576
2608
|
G(() => {
|
|
2577
|
-
w(), window.addEventListener("resize", w), window.addEventListener("scroll", w, !0), document.addEventListener("keydown",
|
|
2609
|
+
w(), window.addEventListener("resize", w), window.addEventListener("scroll", w, !0), document.addEventListener("keydown", M), document.addEventListener("mousedown", te);
|
|
2578
2610
|
}), K(() => {
|
|
2579
|
-
b(), window.removeEventListener("resize", w), window.removeEventListener("scroll", w, !0), document.removeEventListener("keydown",
|
|
2611
|
+
b(), window.removeEventListener("resize", w), window.removeEventListener("scroll", w, !0), document.removeEventListener("keydown", M), document.removeEventListener("mousedown", te);
|
|
2580
2612
|
}), W(() => [
|
|
2581
2613
|
e.active,
|
|
2582
2614
|
m.value.activeCellPos,
|
|
@@ -2588,11 +2620,11 @@ var Cr = J({
|
|
|
2588
2620
|
t.value,
|
|
2589
2621
|
n.value
|
|
2590
2622
|
], T, { flush: "post" });
|
|
2591
|
-
let
|
|
2623
|
+
let N = () => t.value ? B("div", {
|
|
2592
2624
|
ref: f,
|
|
2593
2625
|
class: "markweave-table-menu",
|
|
2594
2626
|
role: "menu",
|
|
2595
|
-
"aria-label":
|
|
2627
|
+
"aria-label": Zt(t.value, e.messages),
|
|
2596
2628
|
"data-testid": "markweave-table-menu",
|
|
2597
2629
|
"data-positioned": o.value ? "true" : "false",
|
|
2598
2630
|
style: o.value ? {
|
|
@@ -2600,7 +2632,7 @@ var Cr = J({
|
|
|
2600
2632
|
top: `${o.value.top}px`
|
|
2601
2633
|
} : void 0
|
|
2602
2634
|
}, y.value.map((n, r) => {
|
|
2603
|
-
let i =
|
|
2635
|
+
let i = Wt(n), a = r === 0 ? i : Wt(y.value[r - 1]), o = r > 0 && a !== i, s = n.commandId === null ? !!e.onEditWithAi : It(e.editor, n.commandId), c = Gt(n, e.messages);
|
|
2604
2636
|
return B("button", {
|
|
2605
2637
|
key: `${n.id}-${r}`,
|
|
2606
2638
|
type: "button",
|
|
@@ -2616,10 +2648,10 @@ var Cr = J({
|
|
|
2616
2648
|
onClick: () => {
|
|
2617
2649
|
if (s) {
|
|
2618
2650
|
if (n.commandId === null) {
|
|
2619
|
-
|
|
2651
|
+
j(t.value === "row" || t.value === "column" ? t.value : "selection");
|
|
2620
2652
|
return;
|
|
2621
2653
|
}
|
|
2622
|
-
|
|
2654
|
+
A(n.commandId).finally(() => k());
|
|
2623
2655
|
}
|
|
2624
2656
|
}
|
|
2625
2657
|
}, c);
|
|
@@ -2640,7 +2672,7 @@ var Cr = J({
|
|
|
2640
2672
|
"data-copy-kind": s.value.kind,
|
|
2641
2673
|
"data-text-length": s.value.textLength,
|
|
2642
2674
|
"data-html-length": s.value.htmlLength
|
|
2643
|
-
},
|
|
2675
|
+
}, Rt(s.value)) : null,
|
|
2644
2676
|
r.value ? B("button", {
|
|
2645
2677
|
ref: l,
|
|
2646
2678
|
type: "button",
|
|
@@ -2659,7 +2691,7 @@ var Cr = J({
|
|
|
2659
2691
|
top: `${r.value.top}px`
|
|
2660
2692
|
},
|
|
2661
2693
|
onMousedown: $,
|
|
2662
|
-
onClick: () =>
|
|
2694
|
+
onClick: () => D("row", "row-edge")
|
|
2663
2695
|
}, [B("span", { "aria-hidden": "true" }, "...")]) : null,
|
|
2664
2696
|
i.value ? B("button", {
|
|
2665
2697
|
ref: u,
|
|
@@ -2679,7 +2711,7 @@ var Cr = J({
|
|
|
2679
2711
|
top: `${i.value.top}px`
|
|
2680
2712
|
},
|
|
2681
2713
|
onMousedown: $,
|
|
2682
|
-
onClick: () =>
|
|
2714
|
+
onClick: () => D("column", "column-edge")
|
|
2683
2715
|
}, [B("span", { "aria-hidden": "true" }, "...")]) : null,
|
|
2684
2716
|
v.value && a.value ? B("button", {
|
|
2685
2717
|
ref: d,
|
|
@@ -2695,12 +2727,12 @@ var Cr = J({
|
|
|
2695
2727
|
top: `${a.value.top}px`
|
|
2696
2728
|
},
|
|
2697
2729
|
onMousedown: $,
|
|
2698
|
-
onClick:
|
|
2730
|
+
onClick: O
|
|
2699
2731
|
}, [B("span", { "aria-hidden": "true" }, "...")]) : null,
|
|
2700
|
-
|
|
2732
|
+
N()
|
|
2701
2733
|
]) : null;
|
|
2702
2734
|
}
|
|
2703
|
-
}),
|
|
2735
|
+
}), Pr = J({
|
|
2704
2736
|
name: "MarkweaveVueTableSelectionOverlay",
|
|
2705
2737
|
props: {
|
|
2706
2738
|
editor: {
|
|
@@ -2718,7 +2750,7 @@ var Cr = J({
|
|
|
2718
2750
|
t.value = null;
|
|
2719
2751
|
return;
|
|
2720
2752
|
}
|
|
2721
|
-
t.value =
|
|
2753
|
+
t.value = Jt(e.editor, jt(e.editor.state));
|
|
2722
2754
|
};
|
|
2723
2755
|
return G(() => {
|
|
2724
2756
|
n(), window.addEventListener("resize", n), window.addEventListener("scroll", n, !0);
|
|
@@ -2756,7 +2788,7 @@ var Cr = J({
|
|
|
2756
2788
|
}) : null;
|
|
2757
2789
|
};
|
|
2758
2790
|
}
|
|
2759
|
-
}),
|
|
2791
|
+
}), Fr = J({
|
|
2760
2792
|
name: "MarkweaveVueCodeBlockControls",
|
|
2761
2793
|
props: {
|
|
2762
2794
|
editor: {
|
|
@@ -2789,112 +2821,112 @@ var Cr = J({
|
|
|
2789
2821
|
active: !1,
|
|
2790
2822
|
lastX: 0,
|
|
2791
2823
|
lastY: 0
|
|
2792
|
-
}), g = V(0), _ = V(0), v = V(0), y = null, b = U(() => (v.value,
|
|
2824
|
+
}), g = V(0), _ = V(0), v = V(0), y = null, b = U(() => (v.value, Ke(e.editor, i.value))), x = U(() => !e.readOnly && e.active && e.state.active && e.state.pos !== null ? {
|
|
2793
2825
|
...e.state,
|
|
2794
2826
|
pos: e.state.pos,
|
|
2795
2827
|
active: !0
|
|
2796
|
-
} : null), S = U(() => b.value ?? x.value), C = U(() => S.value !== null), w = U(() => S.value?.language === "mermaid"), T = U(() =>
|
|
2828
|
+
} : null), S = U(() => b.value ?? x.value), C = U(() => S.value !== null), w = U(() => S.value?.language === "mermaid"), T = U(() => Xe(e.editor, S.value)), E = U(() => C.value && S.value !== null && !T.value), ee = U(() => !e.readOnly), D = U(() => S.value ? Be(S.value.language) : Be("text")), O = U(() => u.value?.status ?? "idle"), k = U(() => S.value?.mermaidPreviewMode ?? e.mermaidMode), A = U(() => w.value && k.value === "preview"), j = U(() => (v.value, g.value, _.value, Je(e.editor))), M = U(() => `${_.value}|${j.value.map((e) => `${e.pos}:${e.mermaidPreviewMode}:${e.text.length}`).join("|")}`), te = U(() => We(l.value)), N = U(() => S.value ? `${S.value.pos}:${S.value.language}:${S.value.text}` : "none"), ne = () => {
|
|
2797
2829
|
y !== null && (window.clearTimeout(y), y = null);
|
|
2798
|
-
},
|
|
2799
|
-
|
|
2830
|
+
}, P = (e) => {
|
|
2831
|
+
ne(), u.value = e, e && (y = window.setTimeout(() => {
|
|
2800
2832
|
u.value = null, y = null;
|
|
2801
|
-
},
|
|
2802
|
-
},
|
|
2833
|
+
}, Pe));
|
|
2834
|
+
}, re = () => {
|
|
2803
2835
|
f.value = null, p.value = null, m.value = !1, h.value = {
|
|
2804
2836
|
active: !1,
|
|
2805
2837
|
lastX: 0,
|
|
2806
2838
|
lastY: 0
|
|
2807
2839
|
}, e.editor.view.focus();
|
|
2808
|
-
},
|
|
2840
|
+
}, F = () => {
|
|
2809
2841
|
let n = t.value;
|
|
2810
2842
|
if (!n) return;
|
|
2811
|
-
if (!
|
|
2843
|
+
if (!qe(n) || j.value.length === 0) {
|
|
2812
2844
|
o.value = [];
|
|
2813
2845
|
return;
|
|
2814
2846
|
}
|
|
2815
|
-
let r = n.getBoundingClientRect(), i =
|
|
2816
|
-
let n =
|
|
2817
|
-
return n ? [
|
|
2847
|
+
let r = n.getBoundingClientRect(), i = j.value.flatMap((t) => {
|
|
2848
|
+
let n = Ue(He(e.editor, t.pos, t.mermaidPreviewMode), r);
|
|
2849
|
+
return n ? [Re(t, n, r)] : [];
|
|
2818
2850
|
});
|
|
2819
|
-
o.value =
|
|
2820
|
-
},
|
|
2851
|
+
o.value = Ze(o.value, i, j.value.map((e) => e.pos));
|
|
2852
|
+
}, I = () => {
|
|
2821
2853
|
if (!E.value || !S.value) {
|
|
2822
2854
|
a.value = null, s.value = null;
|
|
2823
2855
|
return;
|
|
2824
2856
|
}
|
|
2825
2857
|
let r = t.value;
|
|
2826
2858
|
if (!r) return;
|
|
2827
|
-
let i =
|
|
2859
|
+
let i = He(e.editor, S.value.pos, k.value), o = r.getBoundingClientRect(), l = Ue(i, o);
|
|
2828
2860
|
if (!l) {
|
|
2829
2861
|
a.value = a.value?.pos === S.value.pos ? a.value : null, s.value = c.value ? s.value : null;
|
|
2830
2862
|
return;
|
|
2831
2863
|
}
|
|
2832
|
-
if (a.value =
|
|
2864
|
+
if (a.value = Ie(S.value.pos, l, o), c.value && n.value) {
|
|
2833
2865
|
let e = n.value.getBoundingClientRect();
|
|
2834
|
-
s.value =
|
|
2866
|
+
s.value = Me({
|
|
2835
2867
|
overlayRect: o,
|
|
2836
2868
|
buttonRect: e,
|
|
2837
2869
|
windowWidth: window.innerWidth,
|
|
2838
2870
|
windowHeight: window.innerHeight
|
|
2839
2871
|
});
|
|
2840
2872
|
}
|
|
2841
|
-
},
|
|
2873
|
+
}, L = async () => {
|
|
2842
2874
|
if (e.readOnly) {
|
|
2843
2875
|
if (!S.value) return;
|
|
2844
|
-
let e = await
|
|
2845
|
-
|
|
2876
|
+
let e = await Fe(S.value.text);
|
|
2877
|
+
P(De(S.value, e ? "copied" : "failed"));
|
|
2846
2878
|
return;
|
|
2847
2879
|
}
|
|
2848
|
-
if (!
|
|
2849
|
-
let t = await
|
|
2850
|
-
|
|
2851
|
-
},
|
|
2880
|
+
if (!ze(e.editor, S.value)) return;
|
|
2881
|
+
let t = await Te(e.editor);
|
|
2882
|
+
P(De(Ee(e.editor), t ? "copied" : "failed")), e.editor.view.focus();
|
|
2883
|
+
}, R = (t, n) => {
|
|
2852
2884
|
if (e.readOnly) {
|
|
2853
|
-
|
|
2885
|
+
gt(e.editor, t.pos, n) && (_.value += 1, v.value += 1);
|
|
2854
2886
|
return;
|
|
2855
2887
|
}
|
|
2856
2888
|
let r = e.state.active && e.state.pos === t.pos;
|
|
2857
|
-
|
|
2858
|
-
},
|
|
2889
|
+
je(e.editor, t.pos, n) && (e.onMermaidModeChange(n), v.value += 1, r && e.editor.view.focus());
|
|
2890
|
+
}, ie = (t) => {
|
|
2859
2891
|
if (e.readOnly || !S.value) return;
|
|
2860
2892
|
let n = e.state.active && e.state.pos === S.value.pos;
|
|
2861
|
-
|
|
2862
|
-
}, ie = () => {
|
|
2863
|
-
e.readOnly || !S.value || Ce(e.editor, S.value.pos, !T.value) && (g.value += 1, v.value += 1, i.value = null);
|
|
2893
|
+
Ae(e.editor, S.value.pos, t) && (t === "mermaid" && je(e.editor, S.value.pos, "preview") && e.onMermaidModeChange("preview"), c.value = !1, l.value = "", v.value += 1, n && e.editor.view.focus());
|
|
2864
2894
|
}, ae = () => {
|
|
2895
|
+
e.readOnly || !S.value || ke(e.editor, S.value.pos, !T.value) && (g.value += 1, v.value += 1, i.value = null);
|
|
2896
|
+
}, oe = () => {
|
|
2865
2897
|
if (!S.value) return;
|
|
2866
|
-
let t =
|
|
2898
|
+
let t = Ye(e.editor, S.value.pos);
|
|
2867
2899
|
if (!t) return;
|
|
2868
2900
|
let n = new Blob([t], { type: "image/svg+xml" }), r = URL.createObjectURL(n), i = document.createElement("a");
|
|
2869
2901
|
i.href = r, i.download = "markweave-mermaid.svg", i.click(), URL.revokeObjectURL(r), e.editor.view.focus();
|
|
2870
|
-
},
|
|
2902
|
+
}, se = () => {
|
|
2871
2903
|
if (!S.value) return;
|
|
2872
|
-
let t =
|
|
2873
|
-
t && (f.value =
|
|
2904
|
+
let t = Ye(e.editor, S.value.pos);
|
|
2905
|
+
t && (f.value = Le(t), p.value = null, m.value = !1, h.value = {
|
|
2874
2906
|
active: !1,
|
|
2875
2907
|
lastX: 0,
|
|
2876
2908
|
lastY: 0
|
|
2877
2909
|
});
|
|
2878
|
-
},
|
|
2910
|
+
}, ce = (e) => {
|
|
2879
2911
|
f.value = f.value ? {
|
|
2880
2912
|
...f.value,
|
|
2881
|
-
scale:
|
|
2913
|
+
scale: Ne(f.value.scale + e)
|
|
2882
2914
|
} : null;
|
|
2883
|
-
},
|
|
2884
|
-
f.value = f.value ?
|
|
2915
|
+
}, le = () => {
|
|
2916
|
+
f.value = f.value ? Le(f.value.svg) : null, h.value = {
|
|
2885
2917
|
active: !1,
|
|
2886
2918
|
lastX: 0,
|
|
2887
2919
|
lastY: 0
|
|
2888
2920
|
}, m.value = !1;
|
|
2889
|
-
}, le = (e) => {
|
|
2890
|
-
e.preventDefault(), se(e.deltaY < 0 ? Ke : -Ke);
|
|
2891
2921
|
}, ue = (e) => {
|
|
2922
|
+
e.preventDefault(), ce(e.deltaY < 0 ? Qe : -Qe);
|
|
2923
|
+
}, de = (e) => {
|
|
2892
2924
|
e.button === 0 && (e.preventDefault(), h.value = {
|
|
2893
2925
|
active: !0,
|
|
2894
2926
|
lastX: e.clientX,
|
|
2895
2927
|
lastY: e.clientY
|
|
2896
2928
|
}, m.value = !0);
|
|
2897
|
-
},
|
|
2929
|
+
}, fe = (e) => {
|
|
2898
2930
|
let t = h.value;
|
|
2899
2931
|
if (!t.active) return;
|
|
2900
2932
|
let n = e.clientX - t.lastX, r = e.clientY - t.lastY;
|
|
@@ -2902,8 +2934,8 @@ var Cr = J({
|
|
|
2902
2934
|
active: !0,
|
|
2903
2935
|
lastX: e.clientX,
|
|
2904
2936
|
lastY: e.clientY
|
|
2905
|
-
}, f.value =
|
|
2906
|
-
},
|
|
2937
|
+
}, f.value = $e(f.value, n, r);
|
|
2938
|
+
}, pe = () => {
|
|
2907
2939
|
h.value = {
|
|
2908
2940
|
active: !1,
|
|
2909
2941
|
lastX: 0,
|
|
@@ -2912,40 +2944,40 @@ var Cr = J({
|
|
|
2912
2944
|
};
|
|
2913
2945
|
W(() => e.readOnly, (e) => {
|
|
2914
2946
|
e && (c.value = !1, l.value = "");
|
|
2915
|
-
}), W(
|
|
2916
|
-
|
|
2947
|
+
}), W(N, () => {
|
|
2948
|
+
P(null), c.value = !1, l.value = "", f.value = null, p.value = null, m.value = !1;
|
|
2917
2949
|
}), W(c, async (e) => {
|
|
2918
|
-
e && (await q(),
|
|
2950
|
+
e && (await q(), I(), r.value?.focus({ preventScroll: !0 }));
|
|
2919
2951
|
}), W(() => [
|
|
2920
2952
|
E.value,
|
|
2921
2953
|
g.value,
|
|
2922
2954
|
S.value?.pos ?? null,
|
|
2923
2955
|
c.value,
|
|
2924
|
-
|
|
2956
|
+
k.value
|
|
2925
2957
|
], async () => {
|
|
2926
|
-
await q(),
|
|
2958
|
+
await q(), I();
|
|
2927
2959
|
}, {
|
|
2928
2960
|
flush: "post",
|
|
2929
2961
|
immediate: !0
|
|
2930
|
-
}), W(
|
|
2931
|
-
await q(),
|
|
2962
|
+
}), W(M, async () => {
|
|
2963
|
+
await q(), F(), window.requestAnimationFrame(F);
|
|
2932
2964
|
}, {
|
|
2933
2965
|
flush: "post",
|
|
2934
2966
|
immediate: !0
|
|
2935
2967
|
});
|
|
2936
|
-
let
|
|
2968
|
+
let me = null;
|
|
2937
2969
|
return G(() => {
|
|
2938
2970
|
q(() => {
|
|
2939
2971
|
let n = e.editor.view.dom.closest(".markweave-editor-frame"), r = (n) => {
|
|
2940
2972
|
if (n.target instanceof Node && t.value?.contains(n.target) || c.value) return;
|
|
2941
|
-
let r =
|
|
2973
|
+
let r = Ge(e.editor, n.target), a = Ke(e.editor, r), o = a && !Xe(e.editor, a) ? a.pos : null;
|
|
2942
2974
|
i.value = i.value === o ? i.value : o;
|
|
2943
2975
|
}, a = () => {
|
|
2944
2976
|
c.value || (i.value = null);
|
|
2945
2977
|
}, o = (t) => {
|
|
2946
2978
|
if (t.key === "Escape") {
|
|
2947
2979
|
if (f.value) {
|
|
2948
|
-
|
|
2980
|
+
re();
|
|
2949
2981
|
return;
|
|
2950
2982
|
}
|
|
2951
2983
|
c.value && (c.value = !1, e.editor.view.focus());
|
|
@@ -2953,16 +2985,16 @@ var Cr = J({
|
|
|
2953
2985
|
}, s = (e) => {
|
|
2954
2986
|
c.value && (e.target instanceof Node && t.value?.contains(e.target) || (c.value = !1));
|
|
2955
2987
|
}, l = ({ transaction: e }) => {
|
|
2956
|
-
e.getMeta(
|
|
2988
|
+
e.getMeta(we) && (g.value += 1), (e.docChanged || e.selectionSet || e.getMeta(we) || pt(e)) && (v.value += 1);
|
|
2957
2989
|
};
|
|
2958
|
-
n?.addEventListener("mousemove", r), n?.addEventListener("mouseleave", a), window.addEventListener("resize",
|
|
2959
|
-
n?.removeEventListener("mousemove", r), n?.removeEventListener("mouseleave", a), window.removeEventListener("resize",
|
|
2990
|
+
n?.addEventListener("mousemove", r), n?.addEventListener("mouseleave", a), window.addEventListener("resize", I), window.addEventListener("scroll", I, !0), window.addEventListener("resize", F), window.addEventListener("scroll", F, !0), document.addEventListener("keydown", o), document.addEventListener("mousedown", s), e.editor.on("transaction", l), me = () => {
|
|
2991
|
+
n?.removeEventListener("mousemove", r), n?.removeEventListener("mouseleave", a), window.removeEventListener("resize", I), window.removeEventListener("scroll", I, !0), window.removeEventListener("resize", F), window.removeEventListener("scroll", F, !0), document.removeEventListener("keydown", o), document.removeEventListener("mousedown", s), e.editor.off("transaction", l), ne();
|
|
2960
2992
|
};
|
|
2961
2993
|
});
|
|
2962
2994
|
}), K(() => {
|
|
2963
|
-
|
|
2995
|
+
me?.(), me = null, ne();
|
|
2964
2996
|
}), () => {
|
|
2965
|
-
if (!E.value &&
|
|
2997
|
+
if (!E.value && j.value.length === 0 && !f.value) return null;
|
|
2966
2998
|
let i = a.value ? {
|
|
2967
2999
|
top: `${a.value.top}px`,
|
|
2968
3000
|
right: `${a.value.right}px`
|
|
@@ -2976,7 +3008,7 @@ var Cr = J({
|
|
|
2976
3008
|
"data-testid": "markweave-codeblock-overlay",
|
|
2977
3009
|
"data-read-only": e.readOnly ? "true" : "false"
|
|
2978
3010
|
}, [
|
|
2979
|
-
...
|
|
3011
|
+
...j.value.map((e) => {
|
|
2980
3012
|
let t = o.value.find((t) => t.pos === e.pos);
|
|
2981
3013
|
return B("div", {
|
|
2982
3014
|
key: e.pos,
|
|
@@ -2994,7 +3026,7 @@ var Cr = J({
|
|
|
2994
3026
|
"data-testid": `markweave-mermaid-mode-${t}`,
|
|
2995
3027
|
"data-active": e.mermaidPreviewMode === t ? "true" : "false",
|
|
2996
3028
|
onMousedown: $,
|
|
2997
|
-
onClick: () =>
|
|
3029
|
+
onClick: () => R(e, t)
|
|
2998
3030
|
}, t === "code" ? "Code" : "Preview")));
|
|
2999
3031
|
}),
|
|
3000
3032
|
E.value && S.value ? B("div", {
|
|
@@ -3010,7 +3042,7 @@ var Cr = J({
|
|
|
3010
3042
|
class: "markweave-codeblock-language-button markweave-codeblock-language-label",
|
|
3011
3043
|
"aria-label": "Code block language",
|
|
3012
3044
|
"data-testid": "markweave-codeblock-language"
|
|
3013
|
-
}, [B("span", null,
|
|
3045
|
+
}, [B("span", null, D.value)]) : B("button", {
|
|
3014
3046
|
ref: n,
|
|
3015
3047
|
type: "button",
|
|
3016
3048
|
class: "markweave-codeblock-language-button",
|
|
@@ -3022,8 +3054,8 @@ var Cr = J({
|
|
|
3022
3054
|
onClick: () => {
|
|
3023
3055
|
c.value = !c.value;
|
|
3024
3056
|
}
|
|
3025
|
-
}, [B("span", null,
|
|
3026
|
-
|
|
3057
|
+
}, [B("span", null, D.value), Q("chevron")]),
|
|
3058
|
+
ee.value ? B("button", {
|
|
3027
3059
|
type: "button",
|
|
3028
3060
|
class: "markweave-codeblock-icon-button markweave-codeblock-collapse-button",
|
|
3029
3061
|
"aria-label": T.value ? "Expand code block" : "Collapse code block",
|
|
@@ -3031,14 +3063,14 @@ var Cr = J({
|
|
|
3031
3063
|
"data-testid": "markweave-codeblock-collapse",
|
|
3032
3064
|
"data-collapsed": T.value ? "true" : "false",
|
|
3033
3065
|
onMousedown: $,
|
|
3034
|
-
onClick:
|
|
3066
|
+
onClick: ae
|
|
3035
3067
|
}, [Q("chevron")]) : null,
|
|
3036
3068
|
B("span", { class: "markweave-codeblock-copy-wrap" }, [B("button", {
|
|
3037
3069
|
type: "button",
|
|
3038
3070
|
class: "markweave-codeblock-icon-button",
|
|
3039
3071
|
"aria-label": "Copy to clipboard",
|
|
3040
3072
|
"data-testid": "markweave-codeblock-copy",
|
|
3041
|
-
"data-copy-state":
|
|
3073
|
+
"data-copy-state": O.value,
|
|
3042
3074
|
onMousedown: $,
|
|
3043
3075
|
onMouseenter: () => {
|
|
3044
3076
|
d.value = !0;
|
|
@@ -3053,14 +3085,14 @@ var Cr = J({
|
|
|
3053
3085
|
d.value = !1;
|
|
3054
3086
|
},
|
|
3055
3087
|
onClick: () => {
|
|
3056
|
-
|
|
3088
|
+
L();
|
|
3057
3089
|
}
|
|
3058
|
-
}, [Q(
|
|
3090
|
+
}, [Q(O.value === "copied" ? "check" : "clipboard")]), d.value ? B("span", {
|
|
3059
3091
|
class: "markweave-codeblock-tooltip",
|
|
3060
3092
|
role: "tooltip",
|
|
3061
3093
|
"data-testid": "markweave-codeblock-copy-tooltip"
|
|
3062
3094
|
}, "Copy to clipboard") : null]),
|
|
3063
|
-
w.value &&
|
|
3095
|
+
w.value && k.value === "preview" ? B("div", {
|
|
3064
3096
|
class: "markweave-mermaid-preview-actions",
|
|
3065
3097
|
"data-testid": "markweave-mermaid-preview-actions"
|
|
3066
3098
|
}, [B("button", {
|
|
@@ -3068,20 +3100,20 @@ var Cr = J({
|
|
|
3068
3100
|
class: "markweave-codeblock-icon-button",
|
|
3069
3101
|
"aria-label": "Fullscreen Mermaid preview",
|
|
3070
3102
|
"data-testid": "markweave-mermaid-fullscreen",
|
|
3071
|
-
disabled: !
|
|
3103
|
+
disabled: !A.value,
|
|
3072
3104
|
onMousedown: $,
|
|
3073
|
-
onClick:
|
|
3105
|
+
onClick: se
|
|
3074
3106
|
}, [Q("expand")]), B("button", {
|
|
3075
3107
|
type: "button",
|
|
3076
3108
|
class: "markweave-codeblock-icon-button",
|
|
3077
3109
|
"aria-label": "Download Mermaid SVG",
|
|
3078
3110
|
"data-testid": "markweave-mermaid-download",
|
|
3079
|
-
disabled: !
|
|
3111
|
+
disabled: !A.value,
|
|
3080
3112
|
onMousedown: $,
|
|
3081
|
-
onClick:
|
|
3113
|
+
onClick: oe
|
|
3082
3114
|
}, [Q("download")])]) : null
|
|
3083
3115
|
]) : null,
|
|
3084
|
-
|
|
3116
|
+
ee.value && E.value && c.value && S.value ? B("div", {
|
|
3085
3117
|
class: "markweave-codeblock-language-menu",
|
|
3086
3118
|
role: "listbox",
|
|
3087
3119
|
"aria-label": "Code block languages",
|
|
@@ -3099,7 +3131,7 @@ var Cr = J({
|
|
|
3099
3131
|
onKeydown: (t) => {
|
|
3100
3132
|
t.key === "Escape" && (t.preventDefault(), c.value = !1, e.editor.view.focus());
|
|
3101
3133
|
}
|
|
3102
|
-
}), Q("search")]), B("div", { class: "markweave-codeblock-language-list" },
|
|
3134
|
+
}), Q("search")]), B("div", { class: "markweave-codeblock-language-list" }, te.value.map((e) => {
|
|
3103
3135
|
let t = S.value?.language === e.language;
|
|
3104
3136
|
return B("button", {
|
|
3105
3137
|
key: e.language,
|
|
@@ -3109,7 +3141,7 @@ var Cr = J({
|
|
|
3109
3141
|
"data-testid": `markweave-codeblock-language-option-${e.language}`,
|
|
3110
3142
|
"data-active": t ? "true" : "false",
|
|
3111
3143
|
onMousedown: $,
|
|
3112
|
-
onClick: () =>
|
|
3144
|
+
onClick: () => ie(e.language)
|
|
3113
3145
|
}, [B("span", null, e.label), t ? Q("check") : null]);
|
|
3114
3146
|
}))]) : null,
|
|
3115
3147
|
f.value ? B("div", {
|
|
@@ -3140,12 +3172,12 @@ var Cr = J({
|
|
|
3140
3172
|
onBlur: () => {
|
|
3141
3173
|
p.value = null;
|
|
3142
3174
|
},
|
|
3143
|
-
onClick: () =>
|
|
3175
|
+
onClick: () => ce(-Qe)
|
|
3144
3176
|
}, [Q("zoomOut")]),
|
|
3145
3177
|
B("span", {
|
|
3146
3178
|
class: "markweave-mermaid-fullscreen-zoom-label",
|
|
3147
3179
|
"data-testid": "markweave-mermaid-fullscreen-zoom-label"
|
|
3148
|
-
},
|
|
3180
|
+
}, Ve(f.value.scale)),
|
|
3149
3181
|
B("button", {
|
|
3150
3182
|
type: "button",
|
|
3151
3183
|
class: "markweave-mermaid-fullscreen-control",
|
|
@@ -3163,7 +3195,7 @@ var Cr = J({
|
|
|
3163
3195
|
onBlur: () => {
|
|
3164
3196
|
p.value = null;
|
|
3165
3197
|
},
|
|
3166
|
-
onClick: () =>
|
|
3198
|
+
onClick: () => ce(Qe)
|
|
3167
3199
|
}, [Q("zoomIn")]),
|
|
3168
3200
|
B("button", {
|
|
3169
3201
|
type: "button",
|
|
@@ -3182,7 +3214,7 @@ var Cr = J({
|
|
|
3182
3214
|
onBlur: () => {
|
|
3183
3215
|
p.value = null;
|
|
3184
3216
|
},
|
|
3185
|
-
onClick:
|
|
3217
|
+
onClick: le
|
|
3186
3218
|
}, [Q("reset")]),
|
|
3187
3219
|
p.value ? B("span", {
|
|
3188
3220
|
class: "markweave-mermaid-fullscreen-tooltip",
|
|
@@ -3195,17 +3227,17 @@ var Cr = J({
|
|
|
3195
3227
|
class: "markweave-mermaid-fullscreen-close",
|
|
3196
3228
|
"aria-label": "Close fullscreen Mermaid preview",
|
|
3197
3229
|
"data-testid": "markweave-mermaid-fullscreen-close",
|
|
3198
|
-
onClick:
|
|
3230
|
+
onClick: re
|
|
3199
3231
|
}, [Q("close")]),
|
|
3200
3232
|
B("div", {
|
|
3201
3233
|
class: "markweave-mermaid-fullscreen-viewport",
|
|
3202
3234
|
"data-testid": "markweave-mermaid-fullscreen-viewport",
|
|
3203
3235
|
"data-dragging": m.value ? "true" : "false",
|
|
3204
|
-
onWheel:
|
|
3205
|
-
onMousedown:
|
|
3206
|
-
onMousemove:
|
|
3207
|
-
onMouseup:
|
|
3208
|
-
onMouseleave:
|
|
3236
|
+
onWheel: ue,
|
|
3237
|
+
onMousedown: de,
|
|
3238
|
+
onMousemove: fe,
|
|
3239
|
+
onMouseup: pe,
|
|
3240
|
+
onMouseleave: pe
|
|
3209
3241
|
}, [B("div", {
|
|
3210
3242
|
class: "markweave-mermaid-fullscreen-content",
|
|
3211
3243
|
"data-testid": "markweave-mermaid-fullscreen-content",
|
|
@@ -3222,7 +3254,7 @@ var Cr = J({
|
|
|
3222
3254
|
]);
|
|
3223
3255
|
};
|
|
3224
3256
|
}
|
|
3225
|
-
}),
|
|
3257
|
+
}), Ir = J({
|
|
3226
3258
|
name: "MarkweaveVueInnerToc",
|
|
3227
3259
|
props: {
|
|
3228
3260
|
editor: {
|
|
@@ -3248,7 +3280,7 @@ var Cr = J({
|
|
|
3248
3280
|
},
|
|
3249
3281
|
setup(e) {
|
|
3250
3282
|
let t = V(null), n, r = () => {
|
|
3251
|
-
n?.(), n = e.placement === "container" && t.value ?
|
|
3283
|
+
n?.(), n = e.placement === "container" && t.value ? Se(t.value) : void 0;
|
|
3252
3284
|
};
|
|
3253
3285
|
return G(r), K(() => n?.()), W(() => e.placement, r), () => e.state.items.length ? B("nav", {
|
|
3254
3286
|
ref: t,
|
|
@@ -3271,24 +3303,33 @@ var Cr = J({
|
|
|
3271
3303
|
"aria-current": t.active ? "location" : void 0,
|
|
3272
3304
|
"aria-label": `${e.messages.toc.itemAriaLabel}: ${t.text}`,
|
|
3273
3305
|
title: t.text,
|
|
3274
|
-
onClick: () =>
|
|
3306
|
+
onClick: () => Ce(e.editor, t, {
|
|
3275
3307
|
behavior: "smooth",
|
|
3276
3308
|
focus: e.editable
|
|
3277
3309
|
})
|
|
3278
3310
|
}, t.text)))])]) : null;
|
|
3279
3311
|
}
|
|
3280
3312
|
});
|
|
3281
|
-
function
|
|
3282
|
-
let t = m(e.lang), r = p(t), i = f(t), a = V(l(e.mode)), o = U(() => a.value === "live" && e.editable !== !1),
|
|
3283
|
-
|
|
3284
|
-
|
|
3313
|
+
function Lr(e = {}) {
|
|
3314
|
+
let t = m(e.lang), r = p(t), i = f(t), a = V(l(e.mode)), o = U(() => he(e.theme)), s = U(() => a.value === "live" && e.editable !== !1), c = V(0), d = H(null), h = V(Tt), g = H(null), _ = H(null), v = V("code"), y = H(null), b = H(Mt), x = V(null), S = V(!1), C = H(null), w = I(e.content === void 0 ? e.defaultContentFormat : e.contentFormat), T = null;
|
|
3315
|
+
function E() {
|
|
3316
|
+
T !== null && (window.clearTimeout(T), T = null), c.value += 1;
|
|
3317
|
+
}
|
|
3318
|
+
function ee() {
|
|
3319
|
+
T !== null && window.clearTimeout(T), T = window.setTimeout(() => {
|
|
3320
|
+
T = null, c.value += 1;
|
|
3321
|
+
}, me);
|
|
3322
|
+
}
|
|
3323
|
+
let D = e.onSlashCommandUpload, O = H(null);
|
|
3324
|
+
O.value = new n({
|
|
3325
|
+
extensions: vr({
|
|
3285
3326
|
lang: t,
|
|
3286
|
-
onImageUpload: (e) =>
|
|
3287
|
-
onVideoUpload: (e) =>
|
|
3327
|
+
onImageUpload: (e) => D?.(e) ?? A(e) ?? Promise.reject(/* @__PURE__ */ Error("File upload requires an upload handler.")),
|
|
3328
|
+
onVideoUpload: (e) => D?.(e) ?? A(e) ?? Promise.reject(/* @__PURE__ */ Error("File upload requires an upload handler."))
|
|
3288
3329
|
}),
|
|
3289
3330
|
content: e.content ?? e.defaultContent ?? "",
|
|
3290
|
-
contentType: P(
|
|
3291
|
-
editable:
|
|
3331
|
+
contentType: P(w),
|
|
3332
|
+
editable: s.value,
|
|
3292
3333
|
autofocus: e.autofocus,
|
|
3293
3334
|
editorProps: {
|
|
3294
3335
|
attributes: {
|
|
@@ -3300,190 +3341,211 @@ function Ar(e = {}) {
|
|
|
3300
3341
|
translate: "no"
|
|
3301
3342
|
},
|
|
3302
3343
|
handleClick: (e, t, n) => {
|
|
3303
|
-
if (!
|
|
3304
|
-
let r =
|
|
3305
|
-
return r ? (n.preventDefault(), n.stopPropagation(),
|
|
3344
|
+
if (!s.value) return le(n);
|
|
3345
|
+
let r = st(e, n);
|
|
3346
|
+
return r ? (n.preventDefault(), n.stopPropagation(), j(), dt(e, r, !0), ft(e, r), y.value = r, !0) : (y.value = null, !1);
|
|
3306
3347
|
},
|
|
3307
3348
|
handleDOMEvents: {
|
|
3308
|
-
compositionstart: () =>
|
|
3309
|
-
compositionend: (e) => (
|
|
3349
|
+
compositionstart: () => s.value ? (h.value = Et(h.value, { type: "composition-start" }), g.value = null, !1) : !1,
|
|
3350
|
+
compositionend: (e) => (s.value && window.setTimeout(() => M(e), 0), !1),
|
|
3310
3351
|
click: (e, t) => {
|
|
3311
|
-
if (!
|
|
3312
|
-
let n =
|
|
3313
|
-
return n ? (t.preventDefault(), t.stopPropagation(),
|
|
3352
|
+
if (!s.value) return le(t);
|
|
3353
|
+
let n = st(e, t);
|
|
3354
|
+
return n ? (t.preventDefault(), t.stopPropagation(), j(), dt(e, n, !0), ft(e, n), y.value = n, !0) : (y.value = null, !1);
|
|
3314
3355
|
}
|
|
3315
3356
|
}
|
|
3316
3357
|
},
|
|
3317
|
-
onSelectionUpdate: ({ editor: e }) =>
|
|
3358
|
+
onSelectionUpdate: ({ editor: e }) => L(e),
|
|
3318
3359
|
onCreate: ({ editor: t }) => {
|
|
3319
3360
|
u(t, {
|
|
3320
3361
|
mode: a.value,
|
|
3321
|
-
editable:
|
|
3322
|
-
}),
|
|
3362
|
+
editable: s.value
|
|
3363
|
+
}), mt(t, o.value), ht(t, s.value ? "live" : "view"), e.autoFocusFirstTableBodyCell && s.value && kt(t), R(t), L(t), E();
|
|
3323
3364
|
},
|
|
3324
3365
|
onTransaction: ({ editor: e, transaction: t }) => {
|
|
3325
|
-
if (
|
|
3326
|
-
let t =
|
|
3327
|
-
|
|
3366
|
+
if (R(e), (t.docChanged || pt(t)) && ee(), t.docChanged && y.value) {
|
|
3367
|
+
let t = ot(e, y.value.pos);
|
|
3368
|
+
y.value = t?.kind === y.value.kind ? t : null;
|
|
3328
3369
|
}
|
|
3329
3370
|
},
|
|
3330
3371
|
onUpdate: ({ editor: t }) => {
|
|
3331
|
-
|
|
3372
|
+
L(t), s.value && N(t), S.value || e.onUpdate?.(ne(t, { onContentRead: (n, r) => {
|
|
3373
|
+
let i = I(e.contentFormat);
|
|
3374
|
+
e.content !== void 0 && n === i && (C.value = {
|
|
3375
|
+
content: r,
|
|
3376
|
+
format: n,
|
|
3377
|
+
doc: t.state.doc
|
|
3378
|
+
});
|
|
3379
|
+
} }));
|
|
3332
3380
|
}
|
|
3333
3381
|
});
|
|
3334
|
-
let
|
|
3335
|
-
function
|
|
3336
|
-
|
|
3382
|
+
let k = U(() => O.value ?? null);
|
|
3383
|
+
function j() {
|
|
3384
|
+
g.value = null, _.value = null, h.value = Tt;
|
|
3337
3385
|
}
|
|
3338
|
-
function
|
|
3339
|
-
let t =
|
|
3386
|
+
function M(e) {
|
|
3387
|
+
let t = wt(e.state);
|
|
3340
3388
|
if (!t) {
|
|
3341
|
-
|
|
3389
|
+
h.value = h.value.name === "idle" ? h.value : Tt, g.value = null, _.value = null;
|
|
3342
3390
|
return;
|
|
3343
3391
|
}
|
|
3344
3392
|
let n = e.coordsAtPos(t.cursor), r = e.coordsAtPos(t.triggerFrom), i = e.dom.closest(".markweave-editor-frame")?.getBoundingClientRect();
|
|
3345
|
-
|
|
3393
|
+
g.value = Ct(n, {
|
|
3346
3394
|
frameRect: i,
|
|
3347
3395
|
triggerRect: r
|
|
3348
|
-
}),
|
|
3396
|
+
}), h.value = St(h.value, t);
|
|
3349
3397
|
}
|
|
3350
|
-
function
|
|
3351
|
-
|
|
3398
|
+
function N(e) {
|
|
3399
|
+
M(e.view);
|
|
3352
3400
|
}
|
|
3353
|
-
function
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3401
|
+
function L(e) {
|
|
3402
|
+
let t = pe(e);
|
|
3403
|
+
de(d.value, t) || (d.value = t);
|
|
3404
|
+
let n = ct(e);
|
|
3405
|
+
n && (ut(e, n, !0), y.value = n);
|
|
3406
|
+
let r = Ee(e);
|
|
3407
|
+
r.active && r.language === "mermaid" && (v.value = r.mermaidPreviewMode);
|
|
3359
3408
|
}
|
|
3360
|
-
function
|
|
3361
|
-
|
|
3409
|
+
function R(e) {
|
|
3410
|
+
b.value = xr(e);
|
|
3362
3411
|
}
|
|
3363
|
-
let
|
|
3364
|
-
active:
|
|
3365
|
-
mode:
|
|
3366
|
-
source:
|
|
3367
|
-
}) :
|
|
3412
|
+
let ie = U(() => k.value ? Ee(k.value) : br), ae = U(() => k.value ? At(k.value.state) : yr), oe = U(() => d.value?.currentNode === "codeBlock"), se = U(() => oe.value && ie.value.language === "mermaid"), ce = U(() => k.value ? _t({
|
|
3413
|
+
active: se.value,
|
|
3414
|
+
mode: v.value,
|
|
3415
|
+
source: ie.value.text
|
|
3416
|
+
}) : _t({
|
|
3368
3417
|
active: !1,
|
|
3369
3418
|
mode: "code",
|
|
3370
3419
|
source: ""
|
|
3371
|
-
})),
|
|
3372
|
-
revision:
|
|
3420
|
+
})), fe = U(() => k.value ? Ot(k.value.state) : null), z = U(() => k.value ? ye(k.value.state.doc) : _e.items), xe = U(() => be(z.value, x.value)), Se = U(() => ge(z.value, xe.value)), Ce = U(() => vt(h.value.query, i)), we = U(() => ue({
|
|
3421
|
+
revision: c.value,
|
|
3373
3422
|
mode: a.value,
|
|
3374
|
-
editable:
|
|
3375
|
-
toc:
|
|
3376
|
-
selection:
|
|
3377
|
-
slash:
|
|
3378
|
-
table:
|
|
3379
|
-
tableInteraction:
|
|
3380
|
-
codeBlock:
|
|
3381
|
-
mermaid:
|
|
3382
|
-
tableDebugSnapshot:
|
|
3383
|
-
})),
|
|
3384
|
-
closeSlashMenu:
|
|
3385
|
-
focusFirstTableBodyCell: () =>
|
|
3423
|
+
editable: s.value,
|
|
3424
|
+
toc: Se.value,
|
|
3425
|
+
selection: d.value,
|
|
3426
|
+
slash: h.value,
|
|
3427
|
+
table: ae.value,
|
|
3428
|
+
tableInteraction: b.value,
|
|
3429
|
+
codeBlock: ie.value,
|
|
3430
|
+
mermaid: ce.value,
|
|
3431
|
+
tableDebugSnapshot: fe.value
|
|
3432
|
+
})), Te = {
|
|
3433
|
+
closeSlashMenu: j,
|
|
3434
|
+
focusFirstTableBodyCell: () => k.value ? kt(k.value) : !1,
|
|
3386
3435
|
setContent: (e, t = {}) => {
|
|
3387
|
-
if (!
|
|
3436
|
+
if (!k.value) return !1;
|
|
3388
3437
|
let n = I(t.format);
|
|
3389
|
-
return
|
|
3438
|
+
return k.value.commands.setContent(e, {
|
|
3390
3439
|
contentType: P(n),
|
|
3391
3440
|
emitUpdate: t.emitUpdate ?? !1
|
|
3392
|
-
}), t.focusFirstTableBodyCell &&
|
|
3441
|
+
}), t.focusFirstTableBodyCell && kt(k.value), L(k.value), s.value && N(k.value), R(k.value), E(), !0;
|
|
3393
3442
|
}
|
|
3394
3443
|
};
|
|
3395
|
-
function
|
|
3396
|
-
if (!(!
|
|
3444
|
+
function De(e, t) {
|
|
3445
|
+
if (!(!k.value || !s.value || !yt(e))) {
|
|
3397
3446
|
if (e.inputKind && !t?.emoji && !t?.uploadResult) {
|
|
3398
|
-
|
|
3447
|
+
_.value = e;
|
|
3399
3448
|
return;
|
|
3400
3449
|
}
|
|
3401
|
-
|
|
3450
|
+
xt(k.value, h.value, e, t), h.value = Et(h.value, { type: "execute" }), j();
|
|
3402
3451
|
}
|
|
3403
3452
|
}
|
|
3404
|
-
function
|
|
3405
|
-
if (!
|
|
3406
|
-
let t =
|
|
3453
|
+
function Oe(e) {
|
|
3454
|
+
if (!k.value || _.value || !s.value) return;
|
|
3455
|
+
let t = bt(h.value, Ce.value, e.key, { isComposing: e.isComposing || te(k.value.state) });
|
|
3407
3456
|
if (t.type !== "ignore") {
|
|
3408
3457
|
if (e.preventDefault(), t.type === "close") {
|
|
3409
|
-
|
|
3458
|
+
h.value = Et(h.value, { type: "escape" }), j();
|
|
3410
3459
|
return;
|
|
3411
3460
|
}
|
|
3412
3461
|
if (t.type === "move-active") {
|
|
3413
|
-
|
|
3462
|
+
h.value = Et(h.value, {
|
|
3414
3463
|
type: "move-active",
|
|
3415
3464
|
delta: t.delta,
|
|
3416
3465
|
optionCount: t.optionCount
|
|
3417
3466
|
});
|
|
3418
3467
|
return;
|
|
3419
3468
|
}
|
|
3420
|
-
|
|
3469
|
+
De(t.command);
|
|
3421
3470
|
}
|
|
3422
3471
|
}
|
|
3423
3472
|
W(() => [e.mode, e.editable], () => {
|
|
3424
|
-
a.value = l(e.mode),
|
|
3473
|
+
a.value = l(e.mode), k.value && (k.value.setEditable(s.value), u(k.value, {
|
|
3425
3474
|
mode: a.value,
|
|
3426
|
-
editable:
|
|
3427
|
-
}),
|
|
3475
|
+
editable: s.value
|
|
3476
|
+
}), ht(k.value, s.value ? "live" : "view"), E(), s.value || j());
|
|
3477
|
+
}, { immediate: !0 }), W(() => e.theme, () => {
|
|
3478
|
+
k.value && mt(k.value, o.value);
|
|
3428
3479
|
}, { immediate: !0 }), W(() => e.content, (t) => {
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3480
|
+
let n = I(e.contentFormat);
|
|
3481
|
+
if (!(!k.value || t === void 0)) {
|
|
3482
|
+
if (F(k.value, C.value, t, n)) {
|
|
3483
|
+
C.value = null;
|
|
3484
|
+
return;
|
|
3485
|
+
}
|
|
3486
|
+
C.value = null, !re(k.value, t, n) && (S.value = !0, k.value.commands.setContent(t, {
|
|
3487
|
+
contentType: P(n),
|
|
3488
|
+
emitUpdate: !1
|
|
3489
|
+
}), S.value = !1, L(k.value), s.value && N(k.value), R(k.value), E());
|
|
3490
|
+
}
|
|
3491
|
+
}), W(we, (t) => e.onRuntimeStateChange?.(t), { immediate: !0 }), W(Se, (t) => e.onTocChange?.(t), { immediate: !0 }), W(z, (e) => {
|
|
3492
|
+
let t = be(e, x.value);
|
|
3493
|
+
x.value !== t && (x.value = t);
|
|
3436
3494
|
});
|
|
3437
|
-
let
|
|
3438
|
-
return
|
|
3495
|
+
let ke = null;
|
|
3496
|
+
return K(() => {
|
|
3497
|
+
T !== null && window.clearTimeout(T);
|
|
3498
|
+
}), G(() => {
|
|
3439
3499
|
let e = () => {
|
|
3440
|
-
if (!
|
|
3441
|
-
|
|
3500
|
+
if (!k.value || !z.value.length) {
|
|
3501
|
+
x.value = null;
|
|
3442
3502
|
return;
|
|
3443
3503
|
}
|
|
3444
3504
|
let e = null;
|
|
3445
3505
|
try {
|
|
3446
|
-
e =
|
|
3506
|
+
e = ve(k.value, z.value);
|
|
3447
3507
|
} catch {
|
|
3448
3508
|
return;
|
|
3449
3509
|
}
|
|
3450
|
-
|
|
3451
|
-
}, t = () => window.requestAnimationFrame(e), n =
|
|
3452
|
-
window.addEventListener("scroll", t, { passive: !0 }), window.addEventListener("resize", t), n?.addEventListener("scroll", t, { passive: !0 }), t(),
|
|
3510
|
+
x.value !== e && (x.value = e);
|
|
3511
|
+
}, t = () => window.requestAnimationFrame(e), n = Sr(k.value?.view.dom ?? null);
|
|
3512
|
+
window.addEventListener("scroll", t, { passive: !0 }), window.addEventListener("resize", t), n?.addEventListener("scroll", t, { passive: !0 }), t(), ke = () => {
|
|
3453
3513
|
window.removeEventListener("scroll", t), window.removeEventListener("resize", t), n?.removeEventListener("scroll", t);
|
|
3454
3514
|
};
|
|
3455
3515
|
}), K(() => {
|
|
3456
|
-
|
|
3516
|
+
ke?.();
|
|
3517
|
+
let e = O.value;
|
|
3518
|
+
O.value = null, q(() => e?.destroy());
|
|
3457
3519
|
}), {
|
|
3458
|
-
editor:
|
|
3459
|
-
runtimeSnapshot:
|
|
3460
|
-
actions:
|
|
3520
|
+
editor: k,
|
|
3521
|
+
runtimeSnapshot: we,
|
|
3522
|
+
actions: Te,
|
|
3461
3523
|
__render: {
|
|
3462
3524
|
messages: r,
|
|
3463
|
-
effectiveEditable:
|
|
3464
|
-
tableFocusState:
|
|
3465
|
-
tableInteractionState:
|
|
3466
|
-
codeBlockState:
|
|
3467
|
-
isCodeBlockActive:
|
|
3468
|
-
mermaidMode:
|
|
3469
|
-
mathTarget:
|
|
3525
|
+
effectiveEditable: s,
|
|
3526
|
+
tableFocusState: ae,
|
|
3527
|
+
tableInteractionState: b,
|
|
3528
|
+
codeBlockState: ie,
|
|
3529
|
+
isCodeBlockActive: oe,
|
|
3530
|
+
mermaidMode: v,
|
|
3531
|
+
mathTarget: y,
|
|
3470
3532
|
setMermaidMode: (e) => {
|
|
3471
|
-
|
|
3533
|
+
v.value = e;
|
|
3472
3534
|
},
|
|
3473
|
-
tocState:
|
|
3474
|
-
filteredSlashCommands:
|
|
3475
|
-
slashState:
|
|
3476
|
-
slashMenuPosition:
|
|
3477
|
-
slashInputCommand:
|
|
3478
|
-
runSlashCommand:
|
|
3479
|
-
handleEditorKeyDown:
|
|
3535
|
+
tocState: Se,
|
|
3536
|
+
filteredSlashCommands: Ce,
|
|
3537
|
+
slashState: h,
|
|
3538
|
+
slashMenuPosition: g,
|
|
3539
|
+
slashInputCommand: _,
|
|
3540
|
+
runSlashCommand: De,
|
|
3541
|
+
handleEditorKeyDown: Oe,
|
|
3480
3542
|
setSlashInputCommand: (e) => {
|
|
3481
|
-
|
|
3543
|
+
_.value = e;
|
|
3482
3544
|
}
|
|
3483
3545
|
}
|
|
3484
3546
|
};
|
|
3485
3547
|
}
|
|
3486
|
-
var
|
|
3548
|
+
var Rr = J({
|
|
3487
3549
|
name: "MarkweaveEditor",
|
|
3488
3550
|
props: {
|
|
3489
3551
|
defaultContent: {
|
|
@@ -3510,6 +3572,10 @@ var jr = J({
|
|
|
3510
3572
|
type: String,
|
|
3511
3573
|
default: "live"
|
|
3512
3574
|
},
|
|
3575
|
+
theme: {
|
|
3576
|
+
type: String,
|
|
3577
|
+
default: "light"
|
|
3578
|
+
},
|
|
3513
3579
|
innerToc: {
|
|
3514
3580
|
type: Boolean,
|
|
3515
3581
|
default: !0
|
|
@@ -3576,7 +3642,7 @@ var jr = J({
|
|
|
3576
3642
|
}
|
|
3577
3643
|
},
|
|
3578
3644
|
setup(e) {
|
|
3579
|
-
let t =
|
|
3645
|
+
let t = Lr(e);
|
|
3580
3646
|
return () => {
|
|
3581
3647
|
let n = t.editor.value;
|
|
3582
3648
|
if (!n) return null;
|
|
@@ -3586,17 +3652,18 @@ var jr = J({
|
|
|
3586
3652
|
"aria-label": e.ariaLabel ?? i.messages.common.editorAriaLabel,
|
|
3587
3653
|
"data-testid": "markweave-editor-frame",
|
|
3588
3654
|
"data-markweave-mode": t.runtimeSnapshot.value.mode,
|
|
3655
|
+
"data-markweave-theme": he(e.theme),
|
|
3589
3656
|
"data-markweave-inner-toc": e.innerToc ? "true" : "false",
|
|
3590
|
-
"data-markweave-inner-toc-placement":
|
|
3657
|
+
"data-markweave-inner-toc-placement": xe(e.innerTocPlacement),
|
|
3591
3658
|
"data-mermaid-mode": t.runtimeSnapshot.value.mermaid.mode,
|
|
3592
3659
|
"data-table-focus-mode": i.tableFocusState.value.mode,
|
|
3593
3660
|
onKeydownCapture: i.handleEditorKeyDown
|
|
3594
3661
|
}, [
|
|
3595
|
-
i.effectiveEditable.value ? B(
|
|
3662
|
+
i.effectiveEditable.value ? B(Ar, {
|
|
3596
3663
|
editor: n,
|
|
3597
3664
|
messages: i.messages
|
|
3598
3665
|
}) : null,
|
|
3599
|
-
i.effectiveEditable.value ? B(
|
|
3666
|
+
i.effectiveEditable.value ? B(Mr, {
|
|
3600
3667
|
commands: i.filteredSlashCommands.value,
|
|
3601
3668
|
state: i.slashState.value,
|
|
3602
3669
|
position: i.slashMenuPosition.value,
|
|
@@ -3606,7 +3673,7 @@ var jr = J({
|
|
|
3606
3673
|
onInputCommandChange: i.setSlashInputCommand,
|
|
3607
3674
|
onUpload: e.onSlashCommandUpload
|
|
3608
3675
|
}) : null,
|
|
3609
|
-
i.effectiveEditable.value ? B(
|
|
3676
|
+
i.effectiveEditable.value ? B(Nr, {
|
|
3610
3677
|
editor: n,
|
|
3611
3678
|
active: i.tableFocusState.value.active,
|
|
3612
3679
|
interactionState: i.tableInteractionState.value,
|
|
@@ -3615,11 +3682,11 @@ var jr = J({
|
|
|
3615
3682
|
onCommandResult: e.onTableCommandResult,
|
|
3616
3683
|
onEditWithAi: e.onEditWithAi
|
|
3617
3684
|
}) : null,
|
|
3618
|
-
i.effectiveEditable.value ? B(
|
|
3685
|
+
i.effectiveEditable.value ? B(Pr, {
|
|
3619
3686
|
editor: n,
|
|
3620
3687
|
focusState: i.tableFocusState.value
|
|
3621
3688
|
}) : null,
|
|
3622
|
-
B(
|
|
3689
|
+
B(Fr, {
|
|
3623
3690
|
editor: n,
|
|
3624
3691
|
state: i.codeBlockState.value,
|
|
3625
3692
|
active: i.effectiveEditable.value && i.isCodeBlockActive.value,
|
|
@@ -3627,14 +3694,14 @@ var jr = J({
|
|
|
3627
3694
|
onMermaidModeChange: i.setMermaidMode,
|
|
3628
3695
|
readOnly: !i.effectiveEditable.value
|
|
3629
3696
|
}),
|
|
3630
|
-
e.innerToc && i.tocState.value.items.length ? B(
|
|
3697
|
+
e.innerToc && i.tocState.value.items.length ? B(Ir, {
|
|
3631
3698
|
editor: n,
|
|
3632
3699
|
state: i.tocState.value,
|
|
3633
3700
|
messages: i.messages,
|
|
3634
3701
|
editable: i.effectiveEditable.value,
|
|
3635
|
-
placement:
|
|
3702
|
+
placement: xe(e.innerTocPlacement)
|
|
3636
3703
|
}) : null,
|
|
3637
|
-
i.effectiveEditable.value && i.mathTarget.value ? B(
|
|
3704
|
+
i.effectiveEditable.value && i.mathTarget.value ? B(jr, {
|
|
3638
3705
|
editor: n,
|
|
3639
3706
|
messages: i.messages,
|
|
3640
3707
|
target: i.mathTarget.value,
|
|
@@ -3646,4 +3713,4 @@ var jr = J({
|
|
|
3646
3713
|
}
|
|
3647
3714
|
});
|
|
3648
3715
|
//#endregion
|
|
3649
|
-
export {
|
|
3716
|
+
export { Rr as MarkweaveEditor, vr as createMarkweaveEditorExtensions, vr as createMarkweaveVue2EditorExtensions, Lr as useMarkweaveEditorController };
|