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