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