@mario9/tiptap-editor 0.1.1 → 0.1.3
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/README.md +33 -3
- package/dist/tiptap-editor.css +1 -1
- package/dist/tiptap-editor.js +579 -490
- package/dist/tiptap-editor.umd.cjs +1 -1
- package/package.json +48 -16
package/dist/tiptap-editor.js
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import
|
|
3
|
-
import { nodeViewProps as
|
|
4
|
-
import { TaskList as
|
|
5
|
-
import { TextAlign as
|
|
6
|
-
import { Placeholder as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import
|
|
15
|
-
|
|
1
|
+
import { defineComponent as c, computed as D, ref as M, openBlock as Z, createBlock as te, unref as w, withCtx as _, createElementBlock as R, normalizeClass as le, createElementVNode as y, createTextVNode as B, toDisplayString as P, Fragment as we, renderList as ke, normalizeStyle as be, createCommentVNode as xe, withModifiers as G, createVNode as e, mergeProps as b, inject as I, watch as N, nextTick as j, watchEffect as ne, provide as J } from "vue";
|
|
2
|
+
import He from "@tiptap/starter-kit";
|
|
3
|
+
import { nodeViewProps as Be, NodeViewWrapper as Me, VueNodeViewRenderer as Ae, useEditor as ye, EditorContent as Le } from "@tiptap/vue-3";
|
|
4
|
+
import { TaskList as Ie, TaskItem as Ee } from "@tiptap/extension-list";
|
|
5
|
+
import { TextAlign as Ve } from "@tiptap/extension-text-align";
|
|
6
|
+
import { Placeholder as Te } from "@tiptap/extension-placeholder";
|
|
7
|
+
import { CodeBlockLowlight as Ze } from "@tiptap/extension-code-block-lowlight";
|
|
8
|
+
import { createLowlight as Fe, common as _e } from "lowlight";
|
|
9
|
+
import { Image as Re } from "@tiptap/extension-image";
|
|
10
|
+
import { Plugin as De, NodeSelection as Se } from "@tiptap/pm/state";
|
|
11
|
+
import { Decoration as Ue, DecorationSet as $e } from "@tiptap/pm/view";
|
|
12
|
+
import { TableRow as ze, TableHeader as Pe, TableCell as Oe, Table as Ne } from "@tiptap/extension-table";
|
|
13
|
+
import { Mathematics as je } from "@tiptap/extension-mathematics";
|
|
14
|
+
import { Node as We, mergeAttributes as Ke } from "@tiptap/core";
|
|
15
|
+
import { ElTooltip as U, ElButton as S, ElPopover as oe, ElInput as ie, ElDropdown as X, ElDropdownMenu as Q, ElDropdownItem as T, ElDialog as qe, ElRadioGroup as Ge, ElRadioButton as Y } from "element-plus";
|
|
16
|
+
import Je from "katex";
|
|
17
|
+
import { BubbleMenu as Xe } from "@tiptap/vue-3/menus";
|
|
18
|
+
const Qe = Re.extend({
|
|
16
19
|
addAttributes() {
|
|
17
20
|
return {
|
|
18
21
|
...this.parent?.(),
|
|
@@ -26,130 +29,130 @@ const Ne = Ie.extend({
|
|
|
26
29
|
addProseMirrorPlugins() {
|
|
27
30
|
const t = this.name;
|
|
28
31
|
return [
|
|
29
|
-
new
|
|
32
|
+
new De({
|
|
30
33
|
props: {
|
|
31
34
|
decorations(l) {
|
|
32
|
-
const
|
|
33
|
-
return l.doc.descendants((
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
"data-align":
|
|
35
|
+
const n = [];
|
|
36
|
+
return l.doc.descendants((i, a) => {
|
|
37
|
+
i.type.name === t && i.attrs.align && n.push(
|
|
38
|
+
Ue.node(a, a + i.nodeSize, {
|
|
39
|
+
"data-align": i.attrs.align
|
|
37
40
|
})
|
|
38
41
|
);
|
|
39
|
-
}),
|
|
42
|
+
}), $e.create(l.doc, n);
|
|
40
43
|
}
|
|
41
44
|
}
|
|
42
45
|
})
|
|
43
46
|
];
|
|
44
47
|
}
|
|
45
|
-
}),
|
|
48
|
+
}), Ye = { class: "tiptap-image-upload-content" }, e1 = { class: "tiptap-image-upload-subtext" }, t1 = {
|
|
46
49
|
key: 1,
|
|
47
50
|
class: "tiptap-image-upload-previews"
|
|
48
|
-
},
|
|
51
|
+
}, l1 = { class: "tiptap-image-upload-preview-content" }, n1 = { class: "tiptap-image-upload-text" }, o1 = { class: "tiptap-image-upload-subtext" }, i1 = ["onClick"], r1 = ["accept", "multiple"], u1 = /* @__PURE__ */ c({
|
|
49
52
|
__name: "ImageUploadView",
|
|
50
|
-
props:
|
|
53
|
+
props: Be,
|
|
51
54
|
setup(t) {
|
|
52
|
-
const l = t,
|
|
53
|
-
if (a.value > 0 &&
|
|
55
|
+
const l = t, n = D(() => l.node.attrs.accept), i = D(() => l.node.attrs.limit), a = D(() => l.node.attrs.maxSize), u = M([]), h = M(), m = M(!1), f = async (d) => {
|
|
56
|
+
if (a.value > 0 && d.size > a.value)
|
|
54
57
|
return l.extension.options.onError?.(
|
|
55
58
|
new Error(`文件大小超出限制 ${a.value / 1024 / 1024}MB`)
|
|
56
59
|
), null;
|
|
57
|
-
const
|
|
58
|
-
u.value.push({ id:
|
|
60
|
+
const p = crypto.randomUUID();
|
|
61
|
+
u.value.push({ id: p, file: d, progress: 0, status: "uploading" });
|
|
59
62
|
try {
|
|
60
63
|
const v = l.extension.options.upload;
|
|
61
64
|
if (!v) throw new Error("未配置 upload 函数");
|
|
62
|
-
const
|
|
63
|
-
if (!
|
|
64
|
-
const
|
|
65
|
-
return
|
|
65
|
+
const A = await v(d);
|
|
66
|
+
if (!A) throw new Error("上传失败:未返回 URL");
|
|
67
|
+
const H = u.value.find((E) => E.id === p);
|
|
68
|
+
return H && (H.status = "success", H.progress = 100), l.extension.options.onSuccess?.(A), A;
|
|
66
69
|
} catch (v) {
|
|
67
|
-
const
|
|
68
|
-
return
|
|
70
|
+
const A = u.value.find((H) => H.id === p);
|
|
71
|
+
return A && (A.status = "error", A.progress = 0), l.extension.options.onError?.(v instanceof Error ? v : new Error("上传失败")), null;
|
|
69
72
|
}
|
|
70
|
-
},
|
|
71
|
-
if (!
|
|
72
|
-
if (
|
|
73
|
-
l.extension.options.onError?.(new Error(`最多上传 ${
|
|
73
|
+
}, C = async (d) => {
|
|
74
|
+
if (!d.length) return;
|
|
75
|
+
if (d.length > i.value) {
|
|
76
|
+
l.extension.options.onError?.(new Error(`最多上传 ${i.value} 个文件`));
|
|
74
77
|
return;
|
|
75
78
|
}
|
|
76
|
-
const
|
|
77
|
-
if (
|
|
79
|
+
const p = (await Promise.all(d.map(f))).filter((v) => !!v);
|
|
80
|
+
if (p.length > 0) {
|
|
78
81
|
const v = l.getPos();
|
|
79
82
|
if (typeof v != "number") return;
|
|
80
|
-
const
|
|
81
|
-
l.editor.chain().focus().deleteRange({ from: v, to: v + l.node.nodeSize }).insertContentAt(v,
|
|
83
|
+
const A = p.map((H) => ({ type: "image", attrs: { src: H } }));
|
|
84
|
+
l.editor.chain().focus().deleteRange({ from: v, to: v + l.node.nodeSize }).insertContentAt(v, A).run();
|
|
82
85
|
}
|
|
83
|
-
},
|
|
86
|
+
}, o = () => {
|
|
84
87
|
u.value.length === 0 && h.value && (h.value.value = "", h.value.click());
|
|
85
|
-
},
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
},
|
|
89
|
-
|
|
90
|
-
},
|
|
91
|
-
|
|
92
|
-
}, L = (
|
|
93
|
-
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
}, g = (
|
|
97
|
-
u.value = u.value.filter((
|
|
88
|
+
}, r = (d) => {
|
|
89
|
+
const p = d.target.files;
|
|
90
|
+
p && C(Array.from(p));
|
|
91
|
+
}, s = (d) => {
|
|
92
|
+
d.preventDefault(), m.value = !0;
|
|
93
|
+
}, x = (d) => {
|
|
94
|
+
d.currentTarget.contains(d.relatedTarget) || (m.value = !1);
|
|
95
|
+
}, L = (d) => {
|
|
96
|
+
d.preventDefault(), m.value = !1;
|
|
97
|
+
const p = Array.from(d.dataTransfer?.files ?? []);
|
|
98
|
+
p.length && C(p);
|
|
99
|
+
}, g = (d) => {
|
|
100
|
+
u.value = u.value.filter((p) => p.id !== d);
|
|
98
101
|
};
|
|
99
|
-
return (
|
|
102
|
+
return (d, p) => (Z(), te(w(Me), {
|
|
100
103
|
class: "tiptap-image-upload",
|
|
101
|
-
onClick:
|
|
104
|
+
onClick: o
|
|
102
105
|
}, {
|
|
103
|
-
default:
|
|
104
|
-
u.value.length ? (Z(),
|
|
105
|
-
(Z(!0),
|
|
106
|
+
default: _(() => [
|
|
107
|
+
u.value.length ? (Z(), R("div", t1, [
|
|
108
|
+
(Z(!0), R(we, null, ke(u.value, (v) => (Z(), R("div", {
|
|
106
109
|
key: v.id,
|
|
107
110
|
class: "tiptap-image-upload-preview"
|
|
108
111
|
}, [
|
|
109
|
-
v.status === "uploading" ? (Z(),
|
|
112
|
+
v.status === "uploading" ? (Z(), R("div", {
|
|
110
113
|
key: 0,
|
|
111
114
|
class: "tiptap-image-upload-progress",
|
|
112
|
-
style:
|
|
113
|
-
}, null, 4)) :
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
115
|
+
style: be({ width: `${v.progress}%` })
|
|
116
|
+
}, null, 4)) : xe("", !0),
|
|
117
|
+
y("div", l1, [
|
|
118
|
+
y("span", n1, P(v.file.name), 1),
|
|
119
|
+
y("span", o1, P(v.status === "uploading" ? `${v.progress}%` : v.status === "error" ? "上传失败" : "上传成功"), 1),
|
|
120
|
+
y("button", {
|
|
118
121
|
class: "tiptap-image-upload-remove",
|
|
119
|
-
onClick: G((
|
|
120
|
-
}, "×", 8,
|
|
122
|
+
onClick: G((A) => g(v.id), ["stop"])
|
|
123
|
+
}, "×", 8, i1)
|
|
121
124
|
])
|
|
122
125
|
]))), 128))
|
|
123
|
-
])) : (Z(),
|
|
126
|
+
])) : (Z(), R("div", {
|
|
124
127
|
key: 0,
|
|
125
128
|
class: le(["tiptap-image-upload-drag-area", { "drag-active": m.value }]),
|
|
126
|
-
onDragover:
|
|
127
|
-
onDragleave:
|
|
129
|
+
onDragover: s,
|
|
130
|
+
onDragleave: x,
|
|
128
131
|
onDrop: L
|
|
129
132
|
}, [
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
133
|
+
y("div", Ye, [
|
|
134
|
+
p[1] || (p[1] = y("span", { class: "tiptap-image-upload-text" }, [
|
|
135
|
+
y("em", null, "点击上传"),
|
|
136
|
+
B(" 或拖拽图片到此处")
|
|
134
137
|
], -1)),
|
|
135
|
-
|
|
138
|
+
y("span", e1, " 最多 " + P(i.value) + " 个文件" + P(a.value ? `,每个不超过 ${a.value / 1024 / 1024}MB` : ""), 1)
|
|
136
139
|
])
|
|
137
140
|
], 34)),
|
|
138
|
-
|
|
141
|
+
y("input", {
|
|
139
142
|
ref_key: "inputRef",
|
|
140
143
|
ref: h,
|
|
141
144
|
type: "file",
|
|
142
|
-
accept:
|
|
143
|
-
multiple:
|
|
144
|
-
onChange:
|
|
145
|
-
onClick:
|
|
145
|
+
accept: n.value,
|
|
146
|
+
multiple: i.value > 1,
|
|
147
|
+
onChange: r,
|
|
148
|
+
onClick: p[0] || (p[0] = G(() => {
|
|
146
149
|
}, ["stop"]))
|
|
147
|
-
}, null, 40,
|
|
150
|
+
}, null, 40, r1)
|
|
148
151
|
]),
|
|
149
152
|
_: 1
|
|
150
153
|
}));
|
|
151
154
|
}
|
|
152
|
-
}),
|
|
155
|
+
}), a1 = We.create({
|
|
153
156
|
name: "imageUpload",
|
|
154
157
|
group: "block",
|
|
155
158
|
draggable: !0,
|
|
@@ -162,8 +165,8 @@ const Ne = Ie.extend({
|
|
|
162
165
|
limit: 1,
|
|
163
166
|
maxSize: 0,
|
|
164
167
|
upload: (t) => new Promise((l) => {
|
|
165
|
-
const
|
|
166
|
-
|
|
168
|
+
const n = new FileReader();
|
|
169
|
+
n.onloadend = () => l(n.result), n.readAsDataURL(t);
|
|
167
170
|
}),
|
|
168
171
|
onError: void 0,
|
|
169
172
|
onSuccess: void 0,
|
|
@@ -191,12 +194,12 @@ const Ne = Ie.extend({
|
|
|
191
194
|
renderHTML({
|
|
192
195
|
HTMLAttributes: t
|
|
193
196
|
}) {
|
|
194
|
-
return ["div",
|
|
197
|
+
return ["div", Ke({
|
|
195
198
|
"data-type": "image-upload"
|
|
196
199
|
}, t)];
|
|
197
200
|
},
|
|
198
201
|
addNodeView() {
|
|
199
|
-
return
|
|
202
|
+
return Ae(u1);
|
|
200
203
|
},
|
|
201
204
|
addCommands() {
|
|
202
205
|
return {
|
|
@@ -215,12 +218,12 @@ const Ne = Ie.extend({
|
|
|
215
218
|
const {
|
|
216
219
|
selection: l
|
|
217
220
|
} = t.state, {
|
|
218
|
-
nodeAfter:
|
|
221
|
+
nodeAfter: n
|
|
219
222
|
} = l.$from;
|
|
220
|
-
if (
|
|
221
|
-
const
|
|
222
|
-
if (
|
|
223
|
-
const a =
|
|
223
|
+
if (n?.type.name === "imageUpload" && t.isActive("imageUpload")) {
|
|
224
|
+
const i = t.view.nodeDOM(l.$from.pos);
|
|
225
|
+
if (i instanceof HTMLElement) {
|
|
226
|
+
const a = i.firstChild;
|
|
224
227
|
if (a instanceof HTMLElement)
|
|
225
228
|
return a.click(), !0;
|
|
226
229
|
}
|
|
@@ -229,7 +232,7 @@ const Ne = Ie.extend({
|
|
|
229
232
|
}
|
|
230
233
|
};
|
|
231
234
|
}
|
|
232
|
-
}),
|
|
235
|
+
}), s1 = {
|
|
233
236
|
icon: {
|
|
234
237
|
type: Object,
|
|
235
238
|
required: !0
|
|
@@ -248,9 +251,9 @@ const Ne = Ie.extend({
|
|
|
248
251
|
onClick: {
|
|
249
252
|
type: Function
|
|
250
253
|
}
|
|
251
|
-
},
|
|
254
|
+
}, k = /* @__PURE__ */ c({
|
|
252
255
|
name: "IconButton",
|
|
253
|
-
props:
|
|
256
|
+
props: s1,
|
|
254
257
|
setup(t) {
|
|
255
258
|
return () => e(U, {
|
|
256
259
|
showArrow: !1,
|
|
@@ -268,12 +271,12 @@ const Ne = Ie.extend({
|
|
|
268
271
|
}, null)]
|
|
269
272
|
});
|
|
270
273
|
}
|
|
271
|
-
}),
|
|
274
|
+
}), c1 = /* @__PURE__ */ c({
|
|
272
275
|
name: "UndoIcon",
|
|
273
276
|
setup(t, {
|
|
274
277
|
attrs: l
|
|
275
278
|
}) {
|
|
276
|
-
return () => e("svg",
|
|
279
|
+
return () => e("svg", b({
|
|
277
280
|
width: "24",
|
|
278
281
|
height: "24",
|
|
279
282
|
viewBox: "0 0 24 24",
|
|
@@ -286,12 +289,12 @@ const Ne = Ie.extend({
|
|
|
286
289
|
fill: "currentColor"
|
|
287
290
|
}, null)]);
|
|
288
291
|
}
|
|
289
|
-
}),
|
|
292
|
+
}), d1 = /* @__PURE__ */ c({
|
|
290
293
|
name: "RedoIcon",
|
|
291
294
|
setup(t, {
|
|
292
295
|
attrs: l
|
|
293
296
|
}) {
|
|
294
|
-
return () => e("svg",
|
|
297
|
+
return () => e("svg", b({
|
|
295
298
|
width: "24",
|
|
296
299
|
height: "24",
|
|
297
300
|
viewBox: "0 0 24 24",
|
|
@@ -304,28 +307,28 @@ const Ne = Ie.extend({
|
|
|
304
307
|
fill: "currentColor"
|
|
305
308
|
}, null)]);
|
|
306
309
|
}
|
|
307
|
-
}),
|
|
310
|
+
}), p1 = /* @__PURE__ */ c({
|
|
308
311
|
name: "UndoRedoButton",
|
|
309
312
|
setup() {
|
|
310
|
-
const t =
|
|
311
|
-
return () => e("div", null, [e(
|
|
312
|
-
icon:
|
|
313
|
+
const t = I("editor"), l = D(() => t?.value?.can().undo() ?? !1), n = D(() => t?.value?.can().redo() ?? !1);
|
|
314
|
+
return () => e("div", null, [e(k, {
|
|
315
|
+
icon: c1,
|
|
313
316
|
tooltip: "撤销",
|
|
314
317
|
disabled: !l.value,
|
|
315
318
|
onClick: () => t?.value?.chain().focus().undo().run()
|
|
316
|
-
}, null), e(
|
|
317
|
-
icon:
|
|
319
|
+
}, null), e(k, {
|
|
320
|
+
icon: d1,
|
|
318
321
|
tooltip: "重做",
|
|
319
|
-
disabled: !
|
|
322
|
+
disabled: !n.value,
|
|
320
323
|
onClick: () => t?.value?.chain().focus().redo().run()
|
|
321
324
|
}, null)]);
|
|
322
325
|
}
|
|
323
|
-
}),
|
|
326
|
+
}), C1 = /* @__PURE__ */ c({
|
|
324
327
|
name: "LinkIcon",
|
|
325
328
|
setup(t, {
|
|
326
329
|
attrs: l
|
|
327
330
|
}) {
|
|
328
|
-
return () => e("svg",
|
|
331
|
+
return () => e("svg", b({
|
|
329
332
|
width: "24",
|
|
330
333
|
height: "24",
|
|
331
334
|
viewBox: "0 0 24 24",
|
|
@@ -339,12 +342,12 @@ const Ne = Ie.extend({
|
|
|
339
342
|
fill: "currentColor"
|
|
340
343
|
}, null)]);
|
|
341
344
|
}
|
|
342
|
-
}),
|
|
345
|
+
}), v1 = /* @__PURE__ */ c({
|
|
343
346
|
name: "CornerDownLeftIcon",
|
|
344
347
|
setup(t, {
|
|
345
348
|
attrs: l
|
|
346
349
|
}) {
|
|
347
|
-
return () => e("svg",
|
|
350
|
+
return () => e("svg", b({
|
|
348
351
|
width: "24",
|
|
349
352
|
height: "24",
|
|
350
353
|
viewBox: "0 0 24 24",
|
|
@@ -360,12 +363,12 @@ const Ne = Ie.extend({
|
|
|
360
363
|
d: "M20 4v7a4 4 0 0 1-4 4H4"
|
|
361
364
|
}, null)]);
|
|
362
365
|
}
|
|
363
|
-
}),
|
|
366
|
+
}), f1 = /* @__PURE__ */ c({
|
|
364
367
|
name: "ExternalLinkIcon",
|
|
365
368
|
setup(t, {
|
|
366
369
|
attrs: l
|
|
367
370
|
}) {
|
|
368
|
-
return () => e("svg",
|
|
371
|
+
return () => e("svg", b({
|
|
369
372
|
width: "24",
|
|
370
373
|
height: "24",
|
|
371
374
|
viewBox: "0 0 24 24",
|
|
@@ -386,12 +389,12 @@ const Ne = Ie.extend({
|
|
|
386
389
|
y2: "3"
|
|
387
390
|
}, null)]);
|
|
388
391
|
}
|
|
389
|
-
}),
|
|
392
|
+
}), h1 = /* @__PURE__ */ c({
|
|
390
393
|
name: "TrashIcon",
|
|
391
394
|
setup(t, {
|
|
392
395
|
attrs: l
|
|
393
396
|
}) {
|
|
394
|
-
return () => e("svg",
|
|
397
|
+
return () => e("svg", b({
|
|
395
398
|
width: "24",
|
|
396
399
|
height: "24",
|
|
397
400
|
viewBox: "0 0 24 24",
|
|
@@ -407,52 +410,52 @@ const Ne = Ie.extend({
|
|
|
407
410
|
d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"
|
|
408
411
|
}, null)]);
|
|
409
412
|
}
|
|
410
|
-
}),
|
|
413
|
+
}), m1 = /* @__PURE__ */ c({
|
|
411
414
|
name: "LinkPopover",
|
|
412
415
|
setup() {
|
|
413
|
-
const t =
|
|
414
|
-
let
|
|
415
|
-
N(() => t?.value?.isActive("link"), (
|
|
416
|
-
|
|
416
|
+
const t = I("editor"), l = M(!1), n = M("");
|
|
417
|
+
let i = !1;
|
|
418
|
+
N(() => t?.value?.isActive("link"), (o) => {
|
|
419
|
+
i || o && (n.value = t?.value?.getAttributes("link").href ?? "", j(() => {
|
|
417
420
|
l.value = !0;
|
|
418
421
|
}));
|
|
419
422
|
});
|
|
420
423
|
const a = () => {
|
|
421
|
-
const
|
|
422
|
-
if (!
|
|
423
|
-
|
|
424
|
+
const o = t?.value;
|
|
425
|
+
if (!o || !n.value) return;
|
|
426
|
+
i = !0;
|
|
424
427
|
const {
|
|
425
|
-
empty:
|
|
426
|
-
} =
|
|
427
|
-
let
|
|
428
|
-
href:
|
|
428
|
+
empty: r
|
|
429
|
+
} = o.state.selection;
|
|
430
|
+
let s = o.chain().focus().extendMarkRange("link").setLink({
|
|
431
|
+
href: n.value
|
|
429
432
|
});
|
|
430
|
-
|
|
433
|
+
r && (s = s.insertContent({
|
|
431
434
|
type: "text",
|
|
432
|
-
text:
|
|
433
|
-
})),
|
|
434
|
-
|
|
435
|
+
text: n.value
|
|
436
|
+
})), s.run(), l.value = !1, j(() => {
|
|
437
|
+
i = !1;
|
|
435
438
|
});
|
|
436
439
|
}, u = () => {
|
|
437
|
-
const
|
|
438
|
-
|
|
439
|
-
|
|
440
|
+
const o = t?.value;
|
|
441
|
+
o && (i = !0, o.chain().focus().extendMarkRange("link").unsetLink().run(), n.value = "", l.value = !1, j(() => {
|
|
442
|
+
i = !1;
|
|
440
443
|
}));
|
|
441
444
|
}, h = () => {
|
|
442
|
-
const
|
|
443
|
-
|
|
444
|
-
}, m = (
|
|
445
|
-
|
|
446
|
-
},
|
|
447
|
-
|
|
448
|
-
},
|
|
449
|
-
|
|
445
|
+
const o = t?.value?.getAttributes("link").href;
|
|
446
|
+
o && window.open(o, "_blank", "noopener,noreferrer");
|
|
447
|
+
}, m = (o) => {
|
|
448
|
+
o.key === "Enter" && (o.preventDefault(), a());
|
|
449
|
+
}, f = (o) => {
|
|
450
|
+
o && (n.value = t?.value?.getAttributes("link").href ?? ""), l.value = o;
|
|
451
|
+
}, C = (o) => {
|
|
452
|
+
n.value = o;
|
|
450
453
|
};
|
|
451
454
|
return () => {
|
|
452
|
-
const
|
|
455
|
+
const o = t?.value?.isActive("link") ?? !1;
|
|
453
456
|
return e(oe, {
|
|
454
457
|
visible: l.value,
|
|
455
|
-
"onUpdate:visible":
|
|
458
|
+
"onUpdate:visible": f,
|
|
456
459
|
placement: "bottom",
|
|
457
460
|
width: 300,
|
|
458
461
|
trigger: "click",
|
|
@@ -460,18 +463,18 @@ const Ne = Ie.extend({
|
|
|
460
463
|
popperClass: "link-popover-popper",
|
|
461
464
|
offset: 6
|
|
462
465
|
}, {
|
|
463
|
-
reference: () => e("span", null, [e(
|
|
466
|
+
reference: () => e("span", null, [e(k, {
|
|
464
467
|
tooltip: "链接",
|
|
465
|
-
icon:
|
|
468
|
+
icon: C1,
|
|
466
469
|
class: ["tiptap-button", {
|
|
467
|
-
"is-active":
|
|
470
|
+
"is-active": o
|
|
468
471
|
}]
|
|
469
472
|
}, null)]),
|
|
470
473
|
default: () => e("div", {
|
|
471
474
|
class: "link-popover-inner"
|
|
472
475
|
}, [e(ie, {
|
|
473
|
-
modelValue:
|
|
474
|
-
"onUpdate:modelValue":
|
|
476
|
+
modelValue: n.value,
|
|
477
|
+
"onUpdate:modelValue": C,
|
|
475
478
|
type: "url",
|
|
476
479
|
placeholder: "请输入链接...",
|
|
477
480
|
size: "small",
|
|
@@ -486,8 +489,8 @@ const Ne = Ie.extend({
|
|
|
486
489
|
}, {
|
|
487
490
|
default: () => [e(S, {
|
|
488
491
|
text: !0,
|
|
489
|
-
icon:
|
|
490
|
-
disabled: !
|
|
492
|
+
icon: v1,
|
|
493
|
+
disabled: !n.value,
|
|
491
494
|
onClick: a
|
|
492
495
|
}, null)]
|
|
493
496
|
}), e(U, {
|
|
@@ -497,8 +500,8 @@ const Ne = Ie.extend({
|
|
|
497
500
|
}, {
|
|
498
501
|
default: () => [e(S, {
|
|
499
502
|
text: !0,
|
|
500
|
-
icon:
|
|
501
|
-
disabled: !
|
|
503
|
+
icon: f1,
|
|
504
|
+
disabled: !n.value && !o,
|
|
502
505
|
onClick: h
|
|
503
506
|
}, null)]
|
|
504
507
|
}), e(U, {
|
|
@@ -508,20 +511,20 @@ const Ne = Ie.extend({
|
|
|
508
511
|
}, {
|
|
509
512
|
default: () => [e(S, {
|
|
510
513
|
text: !0,
|
|
511
|
-
icon:
|
|
512
|
-
disabled: !
|
|
514
|
+
icon: h1,
|
|
515
|
+
disabled: !o,
|
|
513
516
|
onClick: u
|
|
514
517
|
}, null)]
|
|
515
518
|
})])])
|
|
516
519
|
});
|
|
517
520
|
};
|
|
518
521
|
}
|
|
519
|
-
}),
|
|
522
|
+
}), re = /* @__PURE__ */ c({
|
|
520
523
|
name: "BoldIcon",
|
|
521
524
|
setup(t, {
|
|
522
525
|
attrs: l
|
|
523
526
|
}) {
|
|
524
|
-
return () => e("svg",
|
|
527
|
+
return () => e("svg", b({
|
|
525
528
|
width: "24",
|
|
526
529
|
height: "24",
|
|
527
530
|
viewBox: "0 0 24 24",
|
|
@@ -534,12 +537,12 @@ const Ne = Ie.extend({
|
|
|
534
537
|
fill: "currentColor"
|
|
535
538
|
}, null)]);
|
|
536
539
|
}
|
|
537
|
-
}),
|
|
540
|
+
}), ue = /* @__PURE__ */ c({
|
|
538
541
|
name: "ItalicIcon",
|
|
539
542
|
setup(t, {
|
|
540
543
|
attrs: l
|
|
541
544
|
}) {
|
|
542
|
-
return () => e("svg",
|
|
545
|
+
return () => e("svg", b({
|
|
543
546
|
width: "24",
|
|
544
547
|
height: "24",
|
|
545
548
|
viewBox: "0 0 24 24",
|
|
@@ -550,12 +553,12 @@ const Ne = Ie.extend({
|
|
|
550
553
|
fill: "currentColor"
|
|
551
554
|
}, null)]);
|
|
552
555
|
}
|
|
553
|
-
}),
|
|
556
|
+
}), ae = /* @__PURE__ */ c({
|
|
554
557
|
name: "StrikeIcon",
|
|
555
558
|
setup(t, {
|
|
556
559
|
attrs: l
|
|
557
560
|
}) {
|
|
558
|
-
return () => e("svg",
|
|
561
|
+
return () => e("svg", b({
|
|
559
562
|
width: "24",
|
|
560
563
|
height: "24",
|
|
561
564
|
viewBox: "0 0 24 24",
|
|
@@ -569,12 +572,12 @@ const Ne = Ie.extend({
|
|
|
569
572
|
fill: "currentColor"
|
|
570
573
|
}, null)]);
|
|
571
574
|
}
|
|
572
|
-
}),
|
|
575
|
+
}), se = /* @__PURE__ */ c({
|
|
573
576
|
name: "UnderlineIcon",
|
|
574
577
|
setup(t, {
|
|
575
578
|
attrs: l
|
|
576
579
|
}) {
|
|
577
|
-
return () => e("svg",
|
|
580
|
+
return () => e("svg", b({
|
|
578
581
|
width: "24",
|
|
579
582
|
height: "24",
|
|
580
583
|
viewBox: "0 0 24 24",
|
|
@@ -587,38 +590,38 @@ const Ne = Ie.extend({
|
|
|
587
590
|
fill: "currentColor"
|
|
588
591
|
}, null)]);
|
|
589
592
|
}
|
|
590
|
-
}),
|
|
593
|
+
}), g1 = /* @__PURE__ */ c({
|
|
591
594
|
name: "TextStyleButton",
|
|
592
595
|
setup() {
|
|
593
|
-
const t =
|
|
594
|
-
return () => e("div", null, [e(
|
|
595
|
-
icon:
|
|
596
|
+
const t = I("editor");
|
|
597
|
+
return () => e("div", null, [e(k, {
|
|
598
|
+
icon: re,
|
|
596
599
|
tooltip: "粗体",
|
|
597
600
|
isActive: t?.value?.isActive("bold"),
|
|
598
601
|
onClick: () => t?.value?.chain().focus().toggleBold().run()
|
|
599
|
-
}, null), e(
|
|
600
|
-
icon:
|
|
602
|
+
}, null), e(k, {
|
|
603
|
+
icon: ue,
|
|
601
604
|
tooltip: "斜体",
|
|
602
605
|
isActive: t?.value?.isActive("italic"),
|
|
603
606
|
onClick: () => t?.value?.chain().focus().toggleItalic().run()
|
|
604
|
-
}, null), e(
|
|
605
|
-
icon:
|
|
607
|
+
}, null), e(k, {
|
|
608
|
+
icon: ae,
|
|
606
609
|
tooltip: "删除线",
|
|
607
610
|
isActive: t?.value?.isActive("strike"),
|
|
608
611
|
onClick: () => t?.value?.chain().focus().toggleStrike().run()
|
|
609
|
-
}, null), e(
|
|
610
|
-
icon:
|
|
612
|
+
}, null), e(k, {
|
|
613
|
+
icon: se,
|
|
611
614
|
tooltip: "下划线",
|
|
612
615
|
isActive: t?.value?.isActive("underline"),
|
|
613
616
|
onClick: () => t?.value?.chain().focus().toggleUnderline().run()
|
|
614
|
-
}, null), e(
|
|
617
|
+
}, null), e(m1, null, null)]);
|
|
615
618
|
}
|
|
616
|
-
}),
|
|
619
|
+
}), ce = /* @__PURE__ */ c({
|
|
617
620
|
name: "AlignLeftIcon",
|
|
618
621
|
setup(t, {
|
|
619
622
|
attrs: l
|
|
620
623
|
}) {
|
|
621
|
-
return () => e("svg",
|
|
624
|
+
return () => e("svg", b({
|
|
622
625
|
width: "24",
|
|
623
626
|
height: "24",
|
|
624
627
|
viewBox: "0 0 24 24",
|
|
@@ -641,12 +644,12 @@ const Ne = Ie.extend({
|
|
|
641
644
|
fill: "currentColor"
|
|
642
645
|
}, null)]);
|
|
643
646
|
}
|
|
644
|
-
}),
|
|
647
|
+
}), de = /* @__PURE__ */ c({
|
|
645
648
|
name: "AlignCenterIcon",
|
|
646
649
|
setup(t, {
|
|
647
650
|
attrs: l
|
|
648
651
|
}) {
|
|
649
|
-
return () => e("svg",
|
|
652
|
+
return () => e("svg", b({
|
|
650
653
|
width: "24",
|
|
651
654
|
height: "24",
|
|
652
655
|
viewBox: "0 0 24 24",
|
|
@@ -669,12 +672,12 @@ const Ne = Ie.extend({
|
|
|
669
672
|
fill: "currentColor"
|
|
670
673
|
}, null)]);
|
|
671
674
|
}
|
|
672
|
-
}),
|
|
675
|
+
}), pe = /* @__PURE__ */ c({
|
|
673
676
|
name: "AlignRightIcon",
|
|
674
677
|
setup(t, {
|
|
675
678
|
attrs: l
|
|
676
679
|
}) {
|
|
677
|
-
return () => e("svg",
|
|
680
|
+
return () => e("svg", b({
|
|
678
681
|
width: "24",
|
|
679
682
|
height: "24",
|
|
680
683
|
viewBox: "0 0 24 24",
|
|
@@ -697,12 +700,12 @@ const Ne = Ie.extend({
|
|
|
697
700
|
fill: "currentColor"
|
|
698
701
|
}, null)]);
|
|
699
702
|
}
|
|
700
|
-
}),
|
|
703
|
+
}), w1 = /* @__PURE__ */ c({
|
|
701
704
|
name: "AlignJustifyIcon",
|
|
702
705
|
setup(t, {
|
|
703
706
|
attrs: l
|
|
704
707
|
}) {
|
|
705
|
-
return () => e("svg",
|
|
708
|
+
return () => e("svg", b({
|
|
706
709
|
width: "24",
|
|
707
710
|
height: "24",
|
|
708
711
|
viewBox: "0 0 24 24",
|
|
@@ -725,33 +728,33 @@ const Ne = Ie.extend({
|
|
|
725
728
|
fill: "currentColor"
|
|
726
729
|
}, null)]);
|
|
727
730
|
}
|
|
728
|
-
}),
|
|
731
|
+
}), k1 = /* @__PURE__ */ c({
|
|
729
732
|
name: "TextAlignButton",
|
|
730
733
|
setup() {
|
|
731
|
-
const t =
|
|
732
|
-
return () => e("div", null, [e(
|
|
733
|
-
icon:
|
|
734
|
+
const t = I("editor");
|
|
735
|
+
return () => e("div", null, [e(k, {
|
|
736
|
+
icon: ce,
|
|
734
737
|
tooltip: "左边对齐",
|
|
735
738
|
isActive: t?.value?.isActive({
|
|
736
739
|
textAlign: "left"
|
|
737
740
|
}),
|
|
738
741
|
onClick: () => t?.value?.chain().focus().setTextAlign("left").run()
|
|
739
|
-
}, null), e(
|
|
740
|
-
icon:
|
|
742
|
+
}, null), e(k, {
|
|
743
|
+
icon: de,
|
|
741
744
|
tooltip: "中间对齐",
|
|
742
745
|
isActive: t?.value?.isActive({
|
|
743
746
|
textAlign: "center"
|
|
744
747
|
}),
|
|
745
748
|
onClick: () => t?.value?.chain().focus().setTextAlign("center").run()
|
|
746
|
-
}, null), e(
|
|
747
|
-
icon:
|
|
749
|
+
}, null), e(k, {
|
|
750
|
+
icon: pe,
|
|
748
751
|
tooltip: "右边对齐",
|
|
749
752
|
isActive: t?.value?.isActive({
|
|
750
753
|
textAlign: "right"
|
|
751
754
|
}),
|
|
752
755
|
onClick: () => t?.value?.chain().focus().setTextAlign("right").run()
|
|
753
|
-
}, null), e(
|
|
754
|
-
icon:
|
|
756
|
+
}, null), e(k, {
|
|
757
|
+
icon: w1,
|
|
755
758
|
tooltip: "两端对齐",
|
|
756
759
|
isActive: t?.value?.isActive({
|
|
757
760
|
textAlign: "justify"
|
|
@@ -759,12 +762,12 @@ const Ne = Ie.extend({
|
|
|
759
762
|
onClick: () => t?.value?.chain().focus().setTextAlign("justify").run()
|
|
760
763
|
}, null)]);
|
|
761
764
|
}
|
|
762
|
-
}),
|
|
765
|
+
}), b1 = /* @__PURE__ */ c({
|
|
763
766
|
name: "ListIcon",
|
|
764
767
|
setup(t, {
|
|
765
768
|
attrs: l
|
|
766
769
|
}) {
|
|
767
|
-
return () => e("svg",
|
|
770
|
+
return () => e("svg", b({
|
|
768
771
|
width: "24",
|
|
769
772
|
height: "24",
|
|
770
773
|
viewBox: "0 0 24 24",
|
|
@@ -802,12 +805,12 @@ const Ne = Ie.extend({
|
|
|
802
805
|
fill: "currentColor"
|
|
803
806
|
}, null)]);
|
|
804
807
|
}
|
|
805
|
-
}),
|
|
808
|
+
}), x1 = /* @__PURE__ */ c({
|
|
806
809
|
name: "ListOrderedIcon",
|
|
807
810
|
setup(t, {
|
|
808
811
|
attrs: l
|
|
809
812
|
}) {
|
|
810
|
-
return () => e("svg",
|
|
813
|
+
return () => e("svg", b({
|
|
811
814
|
width: "24",
|
|
812
815
|
height: "24",
|
|
813
816
|
viewBox: "0 0 24 24",
|
|
@@ -845,12 +848,12 @@ const Ne = Ie.extend({
|
|
|
845
848
|
fill: "currentColor"
|
|
846
849
|
}, null)]);
|
|
847
850
|
}
|
|
848
|
-
}),
|
|
851
|
+
}), H1 = /* @__PURE__ */ c({
|
|
849
852
|
name: "ListTodoIcon",
|
|
850
853
|
setup(t, {
|
|
851
854
|
attrs: l
|
|
852
855
|
}) {
|
|
853
|
-
return () => e("svg",
|
|
856
|
+
return () => e("svg", b({
|
|
854
857
|
width: "24",
|
|
855
858
|
height: "24",
|
|
856
859
|
viewBox: "0 0 24 24",
|
|
@@ -883,33 +886,33 @@ const Ne = Ie.extend({
|
|
|
883
886
|
fill: "currentColor"
|
|
884
887
|
}, null)]);
|
|
885
888
|
}
|
|
886
|
-
}),
|
|
889
|
+
}), B1 = /* @__PURE__ */ c({
|
|
887
890
|
name: "ListButton",
|
|
888
891
|
setup() {
|
|
889
|
-
const t =
|
|
890
|
-
return () => e("div", null, [e(
|
|
891
|
-
icon:
|
|
892
|
+
const t = I("editor");
|
|
893
|
+
return () => e("div", null, [e(k, {
|
|
894
|
+
icon: b1,
|
|
892
895
|
tooltip: "无序列表",
|
|
893
896
|
isActive: t?.value?.isActive("bulletList"),
|
|
894
897
|
onClick: () => t?.value?.chain().focus().toggleBulletList().run()
|
|
895
|
-
}, null), e(
|
|
896
|
-
icon:
|
|
898
|
+
}, null), e(k, {
|
|
899
|
+
icon: x1,
|
|
897
900
|
tooltip: "有序列表",
|
|
898
901
|
isActive: t?.value?.isActive("orderedList"),
|
|
899
902
|
onClick: () => t?.value?.chain().focus().toggleOrderedList().run()
|
|
900
|
-
}, null), e(
|
|
901
|
-
icon:
|
|
903
|
+
}, null), e(k, {
|
|
904
|
+
icon: H1,
|
|
902
905
|
tooltip: "任务列表",
|
|
903
906
|
isActive: t?.value?.isActive("taskList"),
|
|
904
907
|
onClick: () => t?.value?.chain().focus().toggleTaskList().run()
|
|
905
908
|
}, null)]);
|
|
906
909
|
}
|
|
907
|
-
}),
|
|
910
|
+
}), M1 = /* @__PURE__ */ c({
|
|
908
911
|
name: "ImagePlusIcon",
|
|
909
912
|
setup(t, {
|
|
910
913
|
attrs: l
|
|
911
914
|
}) {
|
|
912
|
-
return () => e("svg",
|
|
915
|
+
return () => e("svg", b({
|
|
913
916
|
width: "24",
|
|
914
917
|
height: "24",
|
|
915
918
|
viewBox: "0 0 24 24",
|
|
@@ -922,22 +925,22 @@ const Ne = Ie.extend({
|
|
|
922
925
|
fill: "currentColor"
|
|
923
926
|
}, null)]);
|
|
924
927
|
}
|
|
925
|
-
}),
|
|
928
|
+
}), A1 = /* @__PURE__ */ c({
|
|
926
929
|
name: "ImageButton",
|
|
927
930
|
setup() {
|
|
928
|
-
const t =
|
|
929
|
-
return () => e("div", null, [e(
|
|
930
|
-
icon:
|
|
931
|
+
const t = I("editor");
|
|
932
|
+
return () => e("div", null, [e(k, {
|
|
933
|
+
icon: M1,
|
|
931
934
|
tooltip: "图片",
|
|
932
935
|
onClick: () => t?.value?.commands.setImageUploadNode()
|
|
933
936
|
}, null)]);
|
|
934
937
|
}
|
|
935
|
-
}),
|
|
938
|
+
}), y1 = /* @__PURE__ */ c({
|
|
936
939
|
name: "TableIcon",
|
|
937
940
|
setup(t, {
|
|
938
941
|
attrs: l
|
|
939
942
|
}) {
|
|
940
|
-
return () => e("svg",
|
|
943
|
+
return () => e("svg", b({
|
|
941
944
|
width: "24",
|
|
942
945
|
height: "24",
|
|
943
946
|
viewBox: "0 0 24 24",
|
|
@@ -950,16 +953,16 @@ const Ne = Ie.extend({
|
|
|
950
953
|
fill: "currentColor"
|
|
951
954
|
}, null)]);
|
|
952
955
|
}
|
|
953
|
-
}),
|
|
956
|
+
}), L1 = 8, I1 = 8, E1 = /* @__PURE__ */ c({
|
|
954
957
|
name: "TableButton",
|
|
955
958
|
setup() {
|
|
956
|
-
const t =
|
|
957
|
-
|
|
959
|
+
const t = I("editor"), l = M(!1), n = M(0), i = M(0), a = (m, f) => {
|
|
960
|
+
n.value = m, i.value = f;
|
|
958
961
|
}, u = () => {
|
|
959
|
-
|
|
960
|
-
}, h = (m,
|
|
962
|
+
n.value = 0, i.value = 0;
|
|
963
|
+
}, h = (m, f) => {
|
|
961
964
|
t?.value?.chain().focus().insertTable({
|
|
962
|
-
rows:
|
|
965
|
+
rows: f,
|
|
963
966
|
cols: m,
|
|
964
967
|
withHeaderRow: !0
|
|
965
968
|
}).run(), l.value = !1;
|
|
@@ -985,7 +988,7 @@ const Ne = Ie.extend({
|
|
|
985
988
|
"is-active": l.value
|
|
986
989
|
}]
|
|
987
990
|
}, {
|
|
988
|
-
default: () => [e(
|
|
991
|
+
default: () => [e(y1, {
|
|
989
992
|
class: "tiptap-button-icon"
|
|
990
993
|
}, null)]
|
|
991
994
|
})]
|
|
@@ -996,32 +999,32 @@ const Ne = Ie.extend({
|
|
|
996
999
|
class: "table-picker-grid",
|
|
997
1000
|
onMouseleave: u
|
|
998
1001
|
}, [Array.from({
|
|
999
|
-
length:
|
|
1000
|
-
}, (m,
|
|
1001
|
-
key:
|
|
1002
|
+
length: I1
|
|
1003
|
+
}, (m, f) => e("div", {
|
|
1004
|
+
key: f,
|
|
1002
1005
|
class: "table-picker-row"
|
|
1003
1006
|
}, [Array.from({
|
|
1004
|
-
length:
|
|
1005
|
-
}, (
|
|
1006
|
-
key:
|
|
1007
|
+
length: L1
|
|
1008
|
+
}, (C, o) => e("div", {
|
|
1009
|
+
key: o,
|
|
1007
1010
|
class: ["table-picker-cell", {
|
|
1008
|
-
"is-active":
|
|
1011
|
+
"is-active": o < n.value && f < i.value
|
|
1009
1012
|
}],
|
|
1010
|
-
onMouseenter: () => a(
|
|
1011
|
-
onClick: () => h(
|
|
1013
|
+
onMouseenter: () => a(o + 1, f + 1),
|
|
1014
|
+
onClick: () => h(o + 1, f + 1)
|
|
1012
1015
|
}, null))]))]), e("div", {
|
|
1013
1016
|
class: "table-picker-footer"
|
|
1014
1017
|
}, [e("div", {
|
|
1015
1018
|
class: "table-picker-counter"
|
|
1016
|
-
}, [e("span", null, [
|
|
1019
|
+
}, [e("span", null, [B("列")]), e("span", null, [n.value || 1])]), e("span", {
|
|
1017
1020
|
class: "table-picker-x"
|
|
1018
|
-
}, [
|
|
1021
|
+
}, [B("x")]), e("div", {
|
|
1019
1022
|
class: "table-picker-counter"
|
|
1020
|
-
}, [e("span", null, [
|
|
1023
|
+
}, [e("span", null, [B("行")]), e("span", null, [i.value || 1])])])])
|
|
1021
1024
|
});
|
|
1022
1025
|
}
|
|
1023
1026
|
});
|
|
1024
|
-
function
|
|
1027
|
+
function V1(t) {
|
|
1025
1028
|
let l = t.nodeType === Node.TEXT_NODE ? t.parentElement : t;
|
|
1026
1029
|
for (; l && l instanceof HTMLElement; ) {
|
|
1027
1030
|
if (l.tagName === "TD" || l.tagName === "TH") return l;
|
|
@@ -1029,104 +1032,104 @@ function B1(t) {
|
|
|
1029
1032
|
}
|
|
1030
1033
|
return null;
|
|
1031
1034
|
}
|
|
1032
|
-
function
|
|
1035
|
+
function T1(t) {
|
|
1033
1036
|
if (!t.isActive("tableCell") && !t.isActive("tableHeader")) return null;
|
|
1034
1037
|
const {
|
|
1035
1038
|
node: l
|
|
1036
|
-
} = t.view.domAtPos(t.state.selection.from),
|
|
1037
|
-
if (!
|
|
1038
|
-
const
|
|
1039
|
+
} = t.view.domAtPos(t.state.selection.from), n = V1(l);
|
|
1040
|
+
if (!n) return null;
|
|
1041
|
+
const i = n.parentElement, a = i.parentElement, u = n.closest("table");
|
|
1039
1042
|
if (!u) return null;
|
|
1040
|
-
const h = Array.from(
|
|
1043
|
+
const h = Array.from(i.children).indexOf(n), m = Array.from(a.children).indexOf(i), f = i.children.length, C = a.children.length, o = n.getBoundingClientRect(), r = u.getBoundingClientRect(), s = t.view.dom.closest(".tiptap-editor").getBoundingClientRect();
|
|
1041
1044
|
return {
|
|
1042
|
-
cell:
|
|
1045
|
+
cell: n,
|
|
1043
1046
|
colIndex: h,
|
|
1044
1047
|
rowIndex: m,
|
|
1045
|
-
totalCols:
|
|
1046
|
-
totalRows:
|
|
1047
|
-
cellRect:
|
|
1048
|
-
tableRect:
|
|
1049
|
-
editorRect:
|
|
1048
|
+
totalCols: f,
|
|
1049
|
+
totalRows: C,
|
|
1050
|
+
cellRect: o,
|
|
1051
|
+
tableRect: r,
|
|
1052
|
+
editorRect: s
|
|
1050
1053
|
};
|
|
1051
1054
|
}
|
|
1052
1055
|
function ee(t) {
|
|
1053
1056
|
const {
|
|
1054
1057
|
state: l
|
|
1055
|
-
} = t,
|
|
1056
|
-
let
|
|
1058
|
+
} = t, n = l.selection.from;
|
|
1059
|
+
let i = null;
|
|
1057
1060
|
return l.doc.nodesBetween(0, l.doc.content.size, (a, u) => {
|
|
1058
|
-
if (a.type.name === "table" && u <=
|
|
1059
|
-
return
|
|
1061
|
+
if (a.type.name === "table" && u <= n && n <= u + a.nodeSize)
|
|
1062
|
+
return i = {
|
|
1060
1063
|
node: a,
|
|
1061
1064
|
pos: u
|
|
1062
1065
|
}, !1;
|
|
1063
|
-
}),
|
|
1066
|
+
}), i;
|
|
1064
1067
|
}
|
|
1065
|
-
const
|
|
1068
|
+
const Z1 = /* @__PURE__ */ c({
|
|
1066
1069
|
name: "TableControls",
|
|
1067
1070
|
setup() {
|
|
1068
|
-
const t =
|
|
1069
|
-
function
|
|
1070
|
-
const
|
|
1071
|
-
if (
|
|
1071
|
+
const t = I("editor"), l = M(null), n = M(null);
|
|
1072
|
+
function i() {
|
|
1073
|
+
const C = t?.value;
|
|
1074
|
+
if (n.value && (n.value.classList.remove("tcc-cell-focused"), n.value = null), !C) {
|
|
1072
1075
|
l.value = null;
|
|
1073
1076
|
return;
|
|
1074
1077
|
}
|
|
1075
|
-
const
|
|
1076
|
-
l.value =
|
|
1078
|
+
const o = T1(C);
|
|
1079
|
+
l.value = o, o && (o.cell.classList.add("tcc-cell-focused"), n.value = o.cell);
|
|
1077
1080
|
}
|
|
1078
|
-
ne((
|
|
1079
|
-
const
|
|
1080
|
-
|
|
1081
|
-
|
|
1081
|
+
ne((C) => {
|
|
1082
|
+
const o = t?.value;
|
|
1083
|
+
o && (o.on("selectionUpdate", i), o.on("transaction", i), C(() => {
|
|
1084
|
+
o.off("selectionUpdate", i), o.off("transaction", i), n.value && (n.value.classList.remove("tcc-cell-focused"), n.value = null);
|
|
1082
1085
|
}));
|
|
1083
1086
|
});
|
|
1084
|
-
function a(
|
|
1085
|
-
const
|
|
1086
|
-
if (!
|
|
1087
|
+
function a(C) {
|
|
1088
|
+
const o = t?.value;
|
|
1089
|
+
if (!o || !l.value) return;
|
|
1087
1090
|
const {
|
|
1088
|
-
colIndex:
|
|
1089
|
-
totalCols:
|
|
1090
|
-
} = l.value,
|
|
1091
|
-
if (
|
|
1092
|
-
const L = ee(
|
|
1091
|
+
colIndex: r,
|
|
1092
|
+
totalCols: s
|
|
1093
|
+
} = l.value, x = C === "left" ? r - 1 : r + 1;
|
|
1094
|
+
if (x < 0 || x >= s) return;
|
|
1095
|
+
const L = ee(o);
|
|
1093
1096
|
if (!L) return;
|
|
1094
1097
|
const {
|
|
1095
1098
|
node: g,
|
|
1096
|
-
pos:
|
|
1097
|
-
} = L,
|
|
1098
|
-
g.forEach((
|
|
1099
|
-
if (
|
|
1100
|
-
|
|
1099
|
+
pos: d
|
|
1100
|
+
} = L, p = [];
|
|
1101
|
+
g.forEach((H) => {
|
|
1102
|
+
if (H.type.name !== "tableRow") {
|
|
1103
|
+
p.push(H);
|
|
1101
1104
|
return;
|
|
1102
1105
|
}
|
|
1103
|
-
const
|
|
1104
|
-
|
|
1105
|
-
const $ =
|
|
1106
|
-
|
|
1106
|
+
const E = [];
|
|
1107
|
+
H.forEach((z) => E.push(z));
|
|
1108
|
+
const $ = E[r];
|
|
1109
|
+
E[r] = E[x], E[x] = $, p.push(H.type.create(H.attrs, E, H.marks));
|
|
1107
1110
|
});
|
|
1108
|
-
const v = g.type.create(g.attrs,
|
|
1109
|
-
|
|
1111
|
+
const v = g.type.create(g.attrs, p, g.marks), A = o.state.tr.replaceWith(d, d + g.nodeSize, v);
|
|
1112
|
+
o.view.dispatch(A);
|
|
1110
1113
|
}
|
|
1111
|
-
function u(
|
|
1112
|
-
const
|
|
1113
|
-
if (!
|
|
1114
|
+
function u(C) {
|
|
1115
|
+
const o = t?.value;
|
|
1116
|
+
if (!o || !l.value) return;
|
|
1114
1117
|
const {
|
|
1115
|
-
rowIndex:
|
|
1116
|
-
totalRows:
|
|
1117
|
-
} = l.value,
|
|
1118
|
-
if (
|
|
1119
|
-
const L = ee(
|
|
1118
|
+
rowIndex: r,
|
|
1119
|
+
totalRows: s
|
|
1120
|
+
} = l.value, x = C === "up" ? r - 1 : r + 1;
|
|
1121
|
+
if (x < 0 || x >= s) return;
|
|
1122
|
+
const L = ee(o);
|
|
1120
1123
|
if (!L) return;
|
|
1121
1124
|
const {
|
|
1122
1125
|
node: g,
|
|
1123
|
-
pos:
|
|
1124
|
-
} = L,
|
|
1125
|
-
g.forEach((
|
|
1126
|
-
const v =
|
|
1127
|
-
|
|
1128
|
-
const
|
|
1129
|
-
|
|
1126
|
+
pos: d
|
|
1127
|
+
} = L, p = [];
|
|
1128
|
+
g.forEach((E) => p.push(E));
|
|
1129
|
+
const v = p[r];
|
|
1130
|
+
p[r] = p[x], p[x] = v;
|
|
1131
|
+
const A = g.type.create(g.attrs, p, g.marks), H = o.state.tr.replaceWith(d, d + g.nodeSize, A);
|
|
1132
|
+
o.view.dispatch(H);
|
|
1130
1133
|
}
|
|
1131
1134
|
const h = () => e("svg", {
|
|
1132
1135
|
width: "16",
|
|
@@ -1162,7 +1165,7 @@ const I1 = /* @__PURE__ */ d({
|
|
|
1162
1165
|
cx: "2",
|
|
1163
1166
|
cy: "14",
|
|
1164
1167
|
r: "1.5"
|
|
1165
|
-
}, null)]),
|
|
1168
|
+
}, null)]), f = () => e("svg", {
|
|
1166
1169
|
width: "10",
|
|
1167
1170
|
height: "10",
|
|
1168
1171
|
viewBox: "0 0 10 10",
|
|
@@ -1174,41 +1177,41 @@ const I1 = /* @__PURE__ */ d({
|
|
|
1174
1177
|
d: "M5 1v8M1 5h8"
|
|
1175
1178
|
}, null)]);
|
|
1176
1179
|
return () => {
|
|
1177
|
-
const
|
|
1178
|
-
if (!
|
|
1180
|
+
const C = l.value;
|
|
1181
|
+
if (!C) return null;
|
|
1179
1182
|
const {
|
|
1180
|
-
colIndex:
|
|
1181
|
-
rowIndex:
|
|
1182
|
-
totalCols:
|
|
1183
|
-
totalRows:
|
|
1183
|
+
colIndex: o,
|
|
1184
|
+
rowIndex: r,
|
|
1185
|
+
totalCols: s,
|
|
1186
|
+
totalRows: x,
|
|
1184
1187
|
cellRect: L,
|
|
1185
1188
|
tableRect: g,
|
|
1186
|
-
editorRect:
|
|
1187
|
-
} =
|
|
1189
|
+
editorRect: d
|
|
1190
|
+
} = C, p = g.top - d.top, v = g.left - d.left, A = g.right - d.left, H = g.bottom - d.top, E = L.left - d.left, $ = L.top - d.top, z = L.width, W = L.height, Ce = {
|
|
1188
1191
|
position: "absolute",
|
|
1189
|
-
top: `${
|
|
1190
|
-
left: `${
|
|
1191
|
-
},
|
|
1192
|
+
top: `${p - 20}px`,
|
|
1193
|
+
left: `${E + z / 2 - 18}px`
|
|
1194
|
+
}, ve = {
|
|
1192
1195
|
position: "absolute",
|
|
1193
1196
|
top: `${$ + W / 2 - 18}px`,
|
|
1194
1197
|
left: `${v - 20}px`
|
|
1195
|
-
},
|
|
1198
|
+
}, fe = {
|
|
1196
1199
|
position: "absolute",
|
|
1197
1200
|
top: `${$ + W / 2 - 12}px`,
|
|
1198
|
-
left: `${
|
|
1199
|
-
},
|
|
1201
|
+
left: `${A + 6}px`
|
|
1202
|
+
}, he = {
|
|
1200
1203
|
position: "absolute",
|
|
1201
|
-
top: `${
|
|
1202
|
-
left: `${
|
|
1203
|
-
},
|
|
1204
|
+
top: `${H + 6}px`,
|
|
1205
|
+
left: `${E + z / 2 - 12}px`
|
|
1206
|
+
}, me = o === 0, K = o === s - 1, ge = r === 0, q = r === x - 1, F = t?.value;
|
|
1204
1207
|
return e("div", {
|
|
1205
1208
|
class: "table-cell-controls"
|
|
1206
1209
|
}, [e(X, {
|
|
1207
1210
|
trigger: "click",
|
|
1208
1211
|
placement: "bottom",
|
|
1209
|
-
style:
|
|
1212
|
+
style: Ce,
|
|
1210
1213
|
onCommand: (V) => {
|
|
1211
|
-
V === "move-left" ? a("left") : V === "move-right" ? a("right") : V === "insert-left" ?
|
|
1214
|
+
V === "move-left" ? a("left") : V === "move-right" ? a("right") : V === "insert-left" ? F?.chain().focus().addColumnBefore().run() : V === "insert-right" ? F?.chain().focus().addColumnAfter().run() : V === "delete" && F?.chain().focus().deleteColumn().run();
|
|
1212
1215
|
}
|
|
1213
1216
|
}, {
|
|
1214
1217
|
default: () => [e("button", {
|
|
@@ -1217,35 +1220,35 @@ const I1 = /* @__PURE__ */ d({
|
|
|
1217
1220
|
dropdown: () => e(Q, null, {
|
|
1218
1221
|
default: () => [e(T, {
|
|
1219
1222
|
command: "move-left",
|
|
1220
|
-
disabled:
|
|
1223
|
+
disabled: me
|
|
1221
1224
|
}, {
|
|
1222
|
-
default: () => [
|
|
1225
|
+
default: () => [B("移动列到左侧")]
|
|
1223
1226
|
}), e(T, {
|
|
1224
1227
|
command: "move-right",
|
|
1225
1228
|
disabled: K
|
|
1226
1229
|
}, {
|
|
1227
|
-
default: () => [
|
|
1230
|
+
default: () => [B("移动列到右侧")]
|
|
1228
1231
|
}), e(T, {
|
|
1229
1232
|
command: "insert-left"
|
|
1230
1233
|
}, {
|
|
1231
|
-
default: () => [
|
|
1234
|
+
default: () => [B("在左侧插入一列")]
|
|
1232
1235
|
}), e(T, {
|
|
1233
1236
|
command: "insert-right"
|
|
1234
1237
|
}, {
|
|
1235
|
-
default: () => [
|
|
1238
|
+
default: () => [B("在右侧插入一列")]
|
|
1236
1239
|
}), e(T, {
|
|
1237
1240
|
command: "delete",
|
|
1238
1241
|
divided: !0
|
|
1239
1242
|
}, {
|
|
1240
|
-
default: () => [
|
|
1243
|
+
default: () => [B("删除列")]
|
|
1241
1244
|
})]
|
|
1242
1245
|
})
|
|
1243
1246
|
}), e(X, {
|
|
1244
1247
|
trigger: "click",
|
|
1245
1248
|
placement: "right",
|
|
1246
|
-
style:
|
|
1249
|
+
style: ve,
|
|
1247
1250
|
onCommand: (V) => {
|
|
1248
|
-
V === "move-up" ? u("up") : V === "move-down" ? u("down") : V === "insert-above" ?
|
|
1251
|
+
V === "move-up" ? u("up") : V === "move-down" ? u("down") : V === "insert-above" ? F?.chain().focus().addRowBefore().run() : V === "insert-below" ? F?.chain().focus().addRowAfter().run() : V === "delete" && F?.chain().focus().deleteRow().run();
|
|
1249
1252
|
}
|
|
1250
1253
|
}, {
|
|
1251
1254
|
default: () => [e("button", {
|
|
@@ -1254,46 +1257,46 @@ const I1 = /* @__PURE__ */ d({
|
|
|
1254
1257
|
dropdown: () => e(Q, null, {
|
|
1255
1258
|
default: () => [e(T, {
|
|
1256
1259
|
command: "move-up",
|
|
1257
|
-
disabled:
|
|
1260
|
+
disabled: ge
|
|
1258
1261
|
}, {
|
|
1259
|
-
default: () => [
|
|
1262
|
+
default: () => [B("上移")]
|
|
1260
1263
|
}), e(T, {
|
|
1261
1264
|
command: "move-down",
|
|
1262
1265
|
disabled: q
|
|
1263
1266
|
}, {
|
|
1264
|
-
default: () => [
|
|
1267
|
+
default: () => [B("下移")]
|
|
1265
1268
|
}), e(T, {
|
|
1266
1269
|
command: "insert-above"
|
|
1267
1270
|
}, {
|
|
1268
|
-
default: () => [
|
|
1271
|
+
default: () => [B("在上方插入一行")]
|
|
1269
1272
|
}), e(T, {
|
|
1270
1273
|
command: "insert-below"
|
|
1271
1274
|
}, {
|
|
1272
|
-
default: () => [
|
|
1275
|
+
default: () => [B("在下方插入一行")]
|
|
1273
1276
|
}), e(T, {
|
|
1274
1277
|
command: "delete",
|
|
1275
1278
|
divided: !0
|
|
1276
1279
|
}, {
|
|
1277
|
-
default: () => [
|
|
1280
|
+
default: () => [B("删除行")]
|
|
1278
1281
|
})]
|
|
1279
1282
|
})
|
|
1280
1283
|
}), K && e("button", {
|
|
1281
1284
|
class: "tcc-btn tcc-btn--add",
|
|
1282
|
-
style:
|
|
1283
|
-
onClick: () =>
|
|
1284
|
-
}, [e(
|
|
1285
|
+
style: fe,
|
|
1286
|
+
onClick: () => F?.chain().focus().addColumnAfter().run()
|
|
1287
|
+
}, [e(f, null, null)]), q && e("button", {
|
|
1285
1288
|
class: "tcc-btn tcc-btn--add",
|
|
1286
|
-
style:
|
|
1287
|
-
onClick: () =>
|
|
1288
|
-
}, [e(
|
|
1289
|
+
style: he,
|
|
1290
|
+
onClick: () => F?.chain().focus().addRowAfter().run()
|
|
1291
|
+
}, [e(f, null, null)])]);
|
|
1289
1292
|
};
|
|
1290
1293
|
}
|
|
1291
|
-
}),
|
|
1294
|
+
}), F1 = /* @__PURE__ */ c({
|
|
1292
1295
|
name: "MathIcon",
|
|
1293
1296
|
setup(t, {
|
|
1294
1297
|
attrs: l
|
|
1295
1298
|
}) {
|
|
1296
|
-
return () => e("svg",
|
|
1299
|
+
return () => e("svg", b({
|
|
1297
1300
|
width: "24",
|
|
1298
1301
|
height: "24",
|
|
1299
1302
|
viewBox: "0 0 24 24",
|
|
@@ -1306,21 +1309,21 @@ const I1 = /* @__PURE__ */ d({
|
|
|
1306
1309
|
fill: "currentColor"
|
|
1307
1310
|
}, null)]);
|
|
1308
1311
|
}
|
|
1309
|
-
}),
|
|
1312
|
+
}), _1 = /* @__PURE__ */ c({
|
|
1310
1313
|
name: "MathButton",
|
|
1311
1314
|
setup() {
|
|
1312
|
-
const t =
|
|
1313
|
-
return () => e(
|
|
1314
|
-
icon:
|
|
1315
|
+
const t = I("editor"), l = I("openMathDialog");
|
|
1316
|
+
return () => e(k, {
|
|
1317
|
+
icon: F1,
|
|
1315
1318
|
tooltip: "数学公式",
|
|
1316
1319
|
isActive: t?.value?.isActive("inlineMath") || t?.value?.isActive("blockMath"),
|
|
1317
1320
|
onClick: () => l?.()
|
|
1318
1321
|
}, null);
|
|
1319
1322
|
}
|
|
1320
|
-
}),
|
|
1323
|
+
}), R1 = { class: "math-dialog" }, D1 = {
|
|
1321
1324
|
key: 0,
|
|
1322
1325
|
class: "math-preview__placeholder"
|
|
1323
|
-
},
|
|
1326
|
+
}, S1 = ["innerHTML"], U1 = /* @__PURE__ */ c({
|
|
1324
1327
|
__name: "MathEditDialog",
|
|
1325
1328
|
props: {
|
|
1326
1329
|
visible: { type: Boolean },
|
|
@@ -1330,134 +1333,134 @@ const I1 = /* @__PURE__ */ d({
|
|
|
1330
1333
|
},
|
|
1331
1334
|
emits: ["update:visible"],
|
|
1332
1335
|
setup(t, { emit: l }) {
|
|
1333
|
-
const
|
|
1334
|
-
N(() =>
|
|
1335
|
-
u.value =
|
|
1336
|
-
}, { immediate: !0 }), N(() =>
|
|
1337
|
-
h.value =
|
|
1336
|
+
const n = t, i = l, a = I("editor"), u = M(""), h = M("inline");
|
|
1337
|
+
N(() => n.latex, (o) => {
|
|
1338
|
+
u.value = o;
|
|
1339
|
+
}, { immediate: !0 }), N(() => n.type, (o) => {
|
|
1340
|
+
h.value = o;
|
|
1338
1341
|
}, { immediate: !0 });
|
|
1339
|
-
const m = D(() =>
|
|
1342
|
+
const m = D(() => n.pos === null), f = D(() => u.value.trim() ? Je.renderToString(u.value, {
|
|
1340
1343
|
displayMode: h.value === "block",
|
|
1341
1344
|
throwOnError: !1
|
|
1342
|
-
}) : ""),
|
|
1343
|
-
const
|
|
1344
|
-
if (!(!
|
|
1345
|
+
}) : ""), C = () => {
|
|
1346
|
+
const o = a?.value;
|
|
1347
|
+
if (!(!o || !u.value.trim())) {
|
|
1345
1348
|
if (m.value)
|
|
1346
|
-
h.value === "inline" ?
|
|
1347
|
-
else if (h.value ===
|
|
1348
|
-
|
|
1349
|
+
h.value === "inline" ? o.chain().focus().insertInlineMath({ latex: u.value }).run() : o.chain().focus().insertBlockMath({ latex: u.value }).run();
|
|
1350
|
+
else if (h.value === n.type)
|
|
1351
|
+
n.type === "inline" ? o.commands.updateInlineMath({ latex: u.value, pos: n.pos }) : o.commands.updateBlockMath({ latex: u.value, pos: n.pos });
|
|
1349
1352
|
else {
|
|
1350
|
-
const
|
|
1351
|
-
|
|
1353
|
+
const r = n.pos;
|
|
1354
|
+
n.type === "inline" ? o.chain().focus().deleteInlineMath({ pos: r }).insertBlockMath({ latex: u.value }).run() : o.chain().focus().deleteBlockMath({ pos: r }).insertInlineMath({ latex: u.value }).run();
|
|
1352
1355
|
}
|
|
1353
|
-
|
|
1356
|
+
i("update:visible", !1);
|
|
1354
1357
|
}
|
|
1355
1358
|
};
|
|
1356
|
-
return (
|
|
1359
|
+
return (o, r) => (Z(), te(w(qe), {
|
|
1357
1360
|
"model-value": t.visible,
|
|
1358
1361
|
title: m.value ? "插入数学公式" : "编辑数学公式",
|
|
1359
1362
|
width: "520px",
|
|
1360
|
-
"onUpdate:modelValue":
|
|
1363
|
+
"onUpdate:modelValue": r[3] || (r[3] = (s) => i("update:visible", s))
|
|
1361
1364
|
}, {
|
|
1362
|
-
footer:
|
|
1363
|
-
e(
|
|
1364
|
-
onClick:
|
|
1365
|
+
footer: _(() => [
|
|
1366
|
+
e(w(S), {
|
|
1367
|
+
onClick: r[2] || (r[2] = (s) => i("update:visible", !1))
|
|
1365
1368
|
}, {
|
|
1366
|
-
default:
|
|
1367
|
-
|
|
1369
|
+
default: _(() => [...r[6] || (r[6] = [
|
|
1370
|
+
B("取消", -1)
|
|
1368
1371
|
])]),
|
|
1369
1372
|
_: 1
|
|
1370
1373
|
}),
|
|
1371
|
-
e(
|
|
1374
|
+
e(w(S), {
|
|
1372
1375
|
type: "primary",
|
|
1373
1376
|
disabled: !u.value.trim(),
|
|
1374
|
-
onClick:
|
|
1377
|
+
onClick: C
|
|
1375
1378
|
}, {
|
|
1376
|
-
default:
|
|
1377
|
-
|
|
1379
|
+
default: _(() => [...r[7] || (r[7] = [
|
|
1380
|
+
B("确认", -1)
|
|
1378
1381
|
])]),
|
|
1379
1382
|
_: 1
|
|
1380
1383
|
}, 8, ["disabled"])
|
|
1381
1384
|
]),
|
|
1382
|
-
default:
|
|
1383
|
-
|
|
1384
|
-
e(
|
|
1385
|
+
default: _(() => [
|
|
1386
|
+
y("div", R1, [
|
|
1387
|
+
e(w(Ge), {
|
|
1385
1388
|
modelValue: h.value,
|
|
1386
|
-
"onUpdate:modelValue":
|
|
1389
|
+
"onUpdate:modelValue": r[0] || (r[0] = (s) => h.value = s)
|
|
1387
1390
|
}, {
|
|
1388
|
-
default:
|
|
1389
|
-
e(
|
|
1390
|
-
default:
|
|
1391
|
-
|
|
1391
|
+
default: _(() => [
|
|
1392
|
+
e(w(Y), { value: "inline" }, {
|
|
1393
|
+
default: _(() => [...r[4] || (r[4] = [
|
|
1394
|
+
B("行内公式", -1)
|
|
1392
1395
|
])]),
|
|
1393
1396
|
_: 1
|
|
1394
1397
|
}),
|
|
1395
|
-
e(
|
|
1396
|
-
default:
|
|
1397
|
-
|
|
1398
|
+
e(w(Y), { value: "block" }, {
|
|
1399
|
+
default: _(() => [...r[5] || (r[5] = [
|
|
1400
|
+
B("块级公式", -1)
|
|
1398
1401
|
])]),
|
|
1399
1402
|
_: 1
|
|
1400
1403
|
})
|
|
1401
1404
|
]),
|
|
1402
1405
|
_: 1
|
|
1403
1406
|
}, 8, ["modelValue"]),
|
|
1404
|
-
e(
|
|
1407
|
+
e(w(ie), {
|
|
1405
1408
|
modelValue: u.value,
|
|
1406
|
-
"onUpdate:modelValue":
|
|
1409
|
+
"onUpdate:modelValue": r[1] || (r[1] = (s) => u.value = s),
|
|
1407
1410
|
type: "textarea",
|
|
1408
1411
|
rows: 3,
|
|
1409
1412
|
placeholder: "请输入 LaTeX 公式,例如:E=mc^2"
|
|
1410
1413
|
}, null, 8, ["modelValue"]),
|
|
1411
|
-
|
|
1412
|
-
class: le(["math-preview", { "math-preview--empty": !
|
|
1414
|
+
y("div", {
|
|
1415
|
+
class: le(["math-preview", { "math-preview--empty": !f.value }])
|
|
1413
1416
|
}, [
|
|
1414
|
-
|
|
1417
|
+
f.value ? (Z(), R("div", {
|
|
1415
1418
|
key: 1,
|
|
1416
|
-
innerHTML:
|
|
1417
|
-
}, null, 8,
|
|
1419
|
+
innerHTML: f.value
|
|
1420
|
+
}, null, 8, S1)) : (Z(), R("span", D1, "预览将在此处显示"))
|
|
1418
1421
|
], 2)
|
|
1419
1422
|
])
|
|
1420
1423
|
]),
|
|
1421
1424
|
_: 1
|
|
1422
1425
|
}, 8, ["model-value", "title"]));
|
|
1423
1426
|
}
|
|
1424
|
-
}),
|
|
1425
|
-
const
|
|
1426
|
-
for (const [
|
|
1427
|
-
|
|
1428
|
-
return
|
|
1429
|
-
},
|
|
1427
|
+
}), $1 = (t, l) => {
|
|
1428
|
+
const n = t.__vccOpts || t;
|
|
1429
|
+
for (const [i, a] of l)
|
|
1430
|
+
n[i] = a;
|
|
1431
|
+
return n;
|
|
1432
|
+
}, z1 = /* @__PURE__ */ $1(U1, [["__scopeId", "data-v-995dc22f"]]), P1 = [{
|
|
1430
1433
|
value: "left",
|
|
1431
1434
|
title: "居左",
|
|
1432
|
-
Icon:
|
|
1435
|
+
Icon: ce
|
|
1433
1436
|
}, {
|
|
1434
1437
|
value: "center",
|
|
1435
1438
|
title: "居中",
|
|
1436
|
-
Icon:
|
|
1439
|
+
Icon: de
|
|
1437
1440
|
}, {
|
|
1438
1441
|
value: "right",
|
|
1439
1442
|
title: "居右",
|
|
1440
|
-
Icon:
|
|
1443
|
+
Icon: pe
|
|
1441
1444
|
}], O = (t) => t.preventDefault();
|
|
1442
|
-
function
|
|
1445
|
+
function O1(t) {
|
|
1443
1446
|
if (!t.isActive("image")) return null;
|
|
1444
1447
|
const {
|
|
1445
1448
|
selection: l
|
|
1446
1449
|
} = t.state;
|
|
1447
|
-
if (!(l instanceof
|
|
1448
|
-
const
|
|
1450
|
+
if (!(l instanceof Se) || l.node.type.name !== "image") return null;
|
|
1451
|
+
const n = l.node;
|
|
1449
1452
|
return {
|
|
1450
1453
|
pos: l.from,
|
|
1451
|
-
nodeSize:
|
|
1452
|
-
src:
|
|
1453
|
-
align:
|
|
1454
|
+
nodeSize: n.nodeSize,
|
|
1455
|
+
src: n.attrs.src,
|
|
1456
|
+
align: n.attrs.align ?? "left"
|
|
1454
1457
|
};
|
|
1455
1458
|
}
|
|
1456
|
-
function
|
|
1457
|
-
const l = t.startsWith("data:") ? "image.png" : t.split("/").pop()?.split("?")[0] || "image.png",
|
|
1458
|
-
|
|
1459
|
+
function N1(t) {
|
|
1460
|
+
const l = t.startsWith("data:") ? "image.png" : t.split("/").pop()?.split("?")[0] || "image.png", n = document.createElement("a");
|
|
1461
|
+
n.href = t, n.download = l, document.body.appendChild(n), n.click(), document.body.removeChild(n);
|
|
1459
1462
|
}
|
|
1460
|
-
const
|
|
1463
|
+
const j1 = () => e("svg", {
|
|
1461
1464
|
width: "16",
|
|
1462
1465
|
height: "16",
|
|
1463
1466
|
viewBox: "0 0 24 24",
|
|
@@ -1475,7 +1478,7 @@ const z1 = () => e("svg", {
|
|
|
1475
1478
|
y1: "15",
|
|
1476
1479
|
x2: "12",
|
|
1477
1480
|
y2: "3"
|
|
1478
|
-
}, null)]),
|
|
1481
|
+
}, null)]), W1 = () => e("svg", {
|
|
1479
1482
|
width: "16",
|
|
1480
1483
|
height: "16",
|
|
1481
1484
|
viewBox: "0 0 24 24",
|
|
@@ -1488,7 +1491,7 @@ const z1 = () => e("svg", {
|
|
|
1488
1491
|
points: "1 4 1 10 7 10"
|
|
1489
1492
|
}, null), e("path", {
|
|
1490
1493
|
d: "M3.51 15a9 9 0 1 0 .49-4.1L1 10"
|
|
1491
|
-
}, null)]),
|
|
1494
|
+
}, null)]), K1 = () => e("svg", {
|
|
1492
1495
|
width: "16",
|
|
1493
1496
|
height: "16",
|
|
1494
1497
|
viewBox: "0 0 24 24",
|
|
@@ -1505,67 +1508,67 @@ const z1 = () => e("svg", {
|
|
|
1505
1508
|
d: "M10 11v6M14 11v6"
|
|
1506
1509
|
}, null), e("path", {
|
|
1507
1510
|
d: "M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"
|
|
1508
|
-
}, null)]),
|
|
1511
|
+
}, null)]), q1 = /* @__PURE__ */ c({
|
|
1509
1512
|
name: "ImageControls",
|
|
1510
1513
|
setup() {
|
|
1511
|
-
const t =
|
|
1512
|
-
function
|
|
1513
|
-
const
|
|
1514
|
-
if (!
|
|
1514
|
+
const t = I("editor"), l = M(null);
|
|
1515
|
+
function n() {
|
|
1516
|
+
const i = t?.value;
|
|
1517
|
+
if (!i) {
|
|
1515
1518
|
l.value = null;
|
|
1516
1519
|
return;
|
|
1517
1520
|
}
|
|
1518
|
-
l.value =
|
|
1521
|
+
l.value = O1(i);
|
|
1519
1522
|
}
|
|
1520
|
-
return ne((
|
|
1523
|
+
return ne((i) => {
|
|
1521
1524
|
const a = t?.value;
|
|
1522
|
-
a && (a.on("transaction",
|
|
1523
|
-
a.off("transaction",
|
|
1525
|
+
a && (a.on("transaction", n), i(() => {
|
|
1526
|
+
a.off("transaction", n);
|
|
1524
1527
|
}));
|
|
1525
1528
|
}), () => {
|
|
1526
|
-
const
|
|
1527
|
-
if (!
|
|
1529
|
+
const i = l.value;
|
|
1530
|
+
if (!i) return null;
|
|
1528
1531
|
const a = t?.value;
|
|
1529
1532
|
if (!a) return null;
|
|
1530
1533
|
const {
|
|
1531
1534
|
pos: u,
|
|
1532
1535
|
nodeSize: h,
|
|
1533
1536
|
src: m,
|
|
1534
|
-
align:
|
|
1535
|
-
} =
|
|
1536
|
-
if (!
|
|
1537
|
-
const
|
|
1538
|
-
if (!
|
|
1539
|
-
const
|
|
1537
|
+
align: f
|
|
1538
|
+
} = i, C = a.view.nodeDOM(u);
|
|
1539
|
+
if (!C || !(C instanceof HTMLElement)) return null;
|
|
1540
|
+
const o = C.querySelector("[data-resize-wrapper]") ?? C, r = a.view.dom.closest(".tiptap-editor");
|
|
1541
|
+
if (!r) return null;
|
|
1542
|
+
const s = o.getBoundingClientRect(), x = r.getBoundingClientRect(), L = {
|
|
1540
1543
|
position: "absolute",
|
|
1541
|
-
top: `${
|
|
1542
|
-
left: `${
|
|
1544
|
+
top: `${s.top - x.top}px`,
|
|
1545
|
+
left: `${s.left - x.left + s.width / 2}px`,
|
|
1543
1546
|
transform: "translate(-50%, calc(-100% - 8px))",
|
|
1544
1547
|
zIndex: 20
|
|
1545
1548
|
};
|
|
1546
1549
|
return e("div", {
|
|
1547
1550
|
class: "image-controls",
|
|
1548
1551
|
style: L
|
|
1549
|
-
}, [
|
|
1552
|
+
}, [P1.map(({
|
|
1550
1553
|
value: g,
|
|
1551
|
-
title:
|
|
1552
|
-
Icon:
|
|
1554
|
+
title: d,
|
|
1555
|
+
Icon: p
|
|
1553
1556
|
}) => e("button", {
|
|
1554
1557
|
key: g,
|
|
1555
|
-
class: ["image-controls-btn",
|
|
1556
|
-
title:
|
|
1558
|
+
class: ["image-controls-btn", f === g && "is-active"],
|
|
1559
|
+
title: d,
|
|
1557
1560
|
onMousedown: O,
|
|
1558
1561
|
onClick: () => a.chain().focus().updateAttributes("image", {
|
|
1559
1562
|
align: g
|
|
1560
1563
|
}).run()
|
|
1561
|
-
}, [e(
|
|
1564
|
+
}, [e(p, null, null)])), e("span", {
|
|
1562
1565
|
class: "image-controls-separator"
|
|
1563
1566
|
}, null), e("button", {
|
|
1564
1567
|
class: "image-controls-btn",
|
|
1565
1568
|
title: "下载",
|
|
1566
1569
|
onMousedown: O,
|
|
1567
|
-
onClick: () =>
|
|
1568
|
-
}, [e(
|
|
1570
|
+
onClick: () => N1(m)
|
|
1571
|
+
}, [e(j1, null, null)]), e("button", {
|
|
1569
1572
|
class: "image-controls-btn",
|
|
1570
1573
|
title: "重新上传",
|
|
1571
1574
|
onMousedown: O,
|
|
@@ -1575,7 +1578,7 @@ const z1 = () => e("svg", {
|
|
|
1575
1578
|
}).insertContentAt(u, {
|
|
1576
1579
|
type: "imageUpload"
|
|
1577
1580
|
}).run()
|
|
1578
|
-
}, [e(
|
|
1581
|
+
}, [e(W1, null, null)]), e("button", {
|
|
1579
1582
|
class: "image-controls-btn",
|
|
1580
1583
|
title: "删除",
|
|
1581
1584
|
onMousedown: O,
|
|
@@ -1583,10 +1586,89 @@ const z1 = () => e("svg", {
|
|
|
1583
1586
|
from: u,
|
|
1584
1587
|
to: u + h
|
|
1585
1588
|
}).run()
|
|
1586
|
-
}, [e(
|
|
1589
|
+
}, [e(K1, null, null)])]);
|
|
1587
1590
|
};
|
|
1588
1591
|
}
|
|
1589
|
-
}),
|
|
1592
|
+
}), G1 = /* @__PURE__ */ c({
|
|
1593
|
+
name: "CodeBlockIcon",
|
|
1594
|
+
setup(t, {
|
|
1595
|
+
attrs: l
|
|
1596
|
+
}) {
|
|
1597
|
+
return () => e("svg", b({
|
|
1598
|
+
width: "24",
|
|
1599
|
+
height: "24",
|
|
1600
|
+
viewBox: "0 0 24 24",
|
|
1601
|
+
fill: "none",
|
|
1602
|
+
stroke: "currentColor",
|
|
1603
|
+
"stroke-width": "2",
|
|
1604
|
+
"stroke-linecap": "round",
|
|
1605
|
+
"stroke-linejoin": "round",
|
|
1606
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
1607
|
+
}, l), [e("polyline", {
|
|
1608
|
+
points: "16 18 22 12 16 6"
|
|
1609
|
+
}, null), e("polyline", {
|
|
1610
|
+
points: "8 6 2 12 8 18"
|
|
1611
|
+
}, null)]);
|
|
1612
|
+
}
|
|
1613
|
+
}), J1 = /* @__PURE__ */ c({
|
|
1614
|
+
name: "CodeBlockButton",
|
|
1615
|
+
setup() {
|
|
1616
|
+
const t = I("editor");
|
|
1617
|
+
return () => e(k, {
|
|
1618
|
+
icon: G1,
|
|
1619
|
+
tooltip: "代码块",
|
|
1620
|
+
isActive: t?.value?.isActive("codeBlock"),
|
|
1621
|
+
onClick: () => t?.value?.chain().focus().toggleCodeBlock().run()
|
|
1622
|
+
}, null);
|
|
1623
|
+
}
|
|
1624
|
+
}), X1 = /* @__PURE__ */ c({
|
|
1625
|
+
name: "BubbleMenuBar",
|
|
1626
|
+
setup() {
|
|
1627
|
+
const t = I("editor");
|
|
1628
|
+
return () => t?.value ? e(Xe, {
|
|
1629
|
+
editor: t.value,
|
|
1630
|
+
class: "bubble-menu",
|
|
1631
|
+
options: {
|
|
1632
|
+
placement: "top",
|
|
1633
|
+
offset: {
|
|
1634
|
+
mainAxis: 8
|
|
1635
|
+
}
|
|
1636
|
+
},
|
|
1637
|
+
shouldShow: (l) => {
|
|
1638
|
+
const {
|
|
1639
|
+
editor: n,
|
|
1640
|
+
from: i,
|
|
1641
|
+
to: a
|
|
1642
|
+
} = l;
|
|
1643
|
+
return !(i === a || n.isActive("image") || n.isActive("table"));
|
|
1644
|
+
}
|
|
1645
|
+
}, {
|
|
1646
|
+
default: () => [e("div", {
|
|
1647
|
+
class: "bubble-menu-content"
|
|
1648
|
+
}, [e(k, {
|
|
1649
|
+
icon: re,
|
|
1650
|
+
tooltip: "粗体",
|
|
1651
|
+
isActive: t.value.isActive("bold"),
|
|
1652
|
+
onClick: () => t.value?.chain().focus().toggleBold().run()
|
|
1653
|
+
}, null), e(k, {
|
|
1654
|
+
icon: ue,
|
|
1655
|
+
tooltip: "斜体",
|
|
1656
|
+
isActive: t.value.isActive("italic"),
|
|
1657
|
+
onClick: () => t.value?.chain().focus().toggleItalic().run()
|
|
1658
|
+
}, null), e(k, {
|
|
1659
|
+
icon: ae,
|
|
1660
|
+
tooltip: "删除线",
|
|
1661
|
+
isActive: t.value.isActive("strike"),
|
|
1662
|
+
onClick: () => t.value?.chain().focus().toggleStrike().run()
|
|
1663
|
+
}, null), e(k, {
|
|
1664
|
+
icon: se,
|
|
1665
|
+
tooltip: "下划线",
|
|
1666
|
+
isActive: t.value.isActive("underline"),
|
|
1667
|
+
onClick: () => t.value?.chain().focus().toggleUnderline().run()
|
|
1668
|
+
}, null)])]
|
|
1669
|
+
}) : null;
|
|
1670
|
+
}
|
|
1671
|
+
}), Q1 = { class: "tiptap-editor" }, Y1 = { class: "tiptap-toolbar" }, mt = /* @__PURE__ */ c({
|
|
1590
1672
|
__name: "TiptapEditor",
|
|
1591
1673
|
props: {
|
|
1592
1674
|
modelValue: { default: "" },
|
|
@@ -1595,26 +1677,31 @@ const z1 = () => e("svg", {
|
|
|
1595
1677
|
},
|
|
1596
1678
|
emits: ["update:modelValue"],
|
|
1597
1679
|
setup(t, { emit: l }) {
|
|
1598
|
-
const
|
|
1599
|
-
|
|
1680
|
+
const n = Fe(_e), i = t, a = l, u = M(!1), h = M(""), m = M(null), f = M("inline"), C = (r = {}) => {
|
|
1681
|
+
h.value = r.latex ?? "", m.value = r.pos ?? null, f.value = r.type ?? "inline", u.value = !0;
|
|
1600
1682
|
};
|
|
1601
1683
|
J("openMathDialog", C);
|
|
1602
|
-
const
|
|
1603
|
-
content:
|
|
1684
|
+
const o = ye({
|
|
1685
|
+
content: i.modelValue,
|
|
1604
1686
|
extensions: [
|
|
1605
|
-
|
|
1687
|
+
He.configure({
|
|
1688
|
+
codeBlock: !1,
|
|
1606
1689
|
link: {
|
|
1607
1690
|
openOnClick: !1,
|
|
1608
1691
|
enableClickSelection: !0
|
|
1609
1692
|
}
|
|
1610
1693
|
}),
|
|
1611
|
-
|
|
1612
|
-
placeholder:
|
|
1694
|
+
Te.configure({
|
|
1695
|
+
placeholder: i.placeholder
|
|
1696
|
+
}),
|
|
1697
|
+
Ze.configure({
|
|
1698
|
+
lowlight: n,
|
|
1699
|
+
defaultLanguage: "plaintext"
|
|
1613
1700
|
}),
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1701
|
+
Ve.configure({ types: ["heading", "paragraph"] }),
|
|
1702
|
+
Ie,
|
|
1703
|
+
Ee.configure({ nested: !0 }),
|
|
1704
|
+
Qe.configure({
|
|
1618
1705
|
allowBase64: !0,
|
|
1619
1706
|
resize: {
|
|
1620
1707
|
enabled: !0,
|
|
@@ -1633,60 +1720,62 @@ const z1 = () => e("svg", {
|
|
|
1633
1720
|
alwaysPreserveAspectRatio: !1
|
|
1634
1721
|
}
|
|
1635
1722
|
}),
|
|
1636
|
-
|
|
1637
|
-
...
|
|
1723
|
+
a1.configure({
|
|
1724
|
+
...i.upload ? { upload: i.upload } : {}
|
|
1638
1725
|
}),
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1726
|
+
Ne.configure({ resizable: !0 }),
|
|
1727
|
+
ze,
|
|
1728
|
+
Pe,
|
|
1729
|
+
Oe,
|
|
1730
|
+
je.configure({
|
|
1644
1731
|
inlineOptions: {
|
|
1645
|
-
onClick: (
|
|
1732
|
+
onClick: (r, s) => C({ latex: r.attrs.latex, pos: s, type: "inline" })
|
|
1646
1733
|
},
|
|
1647
1734
|
blockOptions: {
|
|
1648
|
-
onClick: (
|
|
1735
|
+
onClick: (r, s) => C({ latex: r.attrs.latex, pos: s, type: "block" })
|
|
1649
1736
|
}
|
|
1650
1737
|
})
|
|
1651
1738
|
],
|
|
1652
|
-
onUpdate: ({ editor:
|
|
1653
|
-
|
|
1739
|
+
onUpdate: ({ editor: r }) => {
|
|
1740
|
+
a("update:modelValue", r.getHTML());
|
|
1654
1741
|
}
|
|
1655
1742
|
});
|
|
1656
|
-
return J("editor",
|
|
1657
|
-
|
|
1658
|
-
}), (
|
|
1659
|
-
|
|
1660
|
-
e(
|
|
1661
|
-
|
|
1662
|
-
e(
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
e(
|
|
1670
|
-
e(
|
|
1743
|
+
return J("editor", o), N(() => i.modelValue, (r) => {
|
|
1744
|
+
o.value && r !== o.value.getHTML() && o.value.commands.setContent(r, { emitUpdate: !1 });
|
|
1745
|
+
}), (r, s) => (Z(), R("div", Q1, [
|
|
1746
|
+
y("div", Y1, [
|
|
1747
|
+
e(w(p1)),
|
|
1748
|
+
s[1] || (s[1] = y("div", { class: "tiptap-separator" }, null, -1)),
|
|
1749
|
+
e(w(g1)),
|
|
1750
|
+
e(w(J1)),
|
|
1751
|
+
s[2] || (s[2] = y("div", { class: "tiptap-separator" }, null, -1)),
|
|
1752
|
+
e(w(B1)),
|
|
1753
|
+
s[3] || (s[3] = y("div", { class: "tiptap-separator" }, null, -1)),
|
|
1754
|
+
e(w(k1)),
|
|
1755
|
+
s[4] || (s[4] = y("div", { class: "tiptap-separator" }, null, -1)),
|
|
1756
|
+
e(w(A1)),
|
|
1757
|
+
e(w(E1)),
|
|
1758
|
+
e(w(_1))
|
|
1671
1759
|
]),
|
|
1672
|
-
e(
|
|
1760
|
+
e(w(Le), {
|
|
1673
1761
|
class: "tiptap-content",
|
|
1674
|
-
editor:
|
|
1762
|
+
editor: w(o)
|
|
1675
1763
|
}, null, 8, ["editor"]),
|
|
1676
|
-
e(
|
|
1677
|
-
e(
|
|
1678
|
-
e(
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1764
|
+
e(w(X1)),
|
|
1765
|
+
e(w(Z1)),
|
|
1766
|
+
e(w(q1)),
|
|
1767
|
+
e(z1, {
|
|
1768
|
+
visible: u.value,
|
|
1769
|
+
"onUpdate:visible": s[0] || (s[0] = (x) => u.value = x),
|
|
1770
|
+
latex: h.value,
|
|
1771
|
+
pos: m.value,
|
|
1772
|
+
type: f.value
|
|
1684
1773
|
}, null, 8, ["visible", "latex", "pos", "type"])
|
|
1685
1774
|
]));
|
|
1686
1775
|
}
|
|
1687
1776
|
});
|
|
1688
1777
|
export {
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1778
|
+
k as IconButton,
|
|
1779
|
+
Qe as ImageWithAlign,
|
|
1780
|
+
mt as TiptapEditor
|
|
1692
1781
|
};
|