@mario9/tiptap-editor 1.0.0 → 1.0.2
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 +13 -12
- package/dist/tiptap-editor.css +1 -1
- package/dist/tiptap-editor.js +594 -607
- package/dist/tiptap-editor.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/tiptap-editor.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { defineComponent as
|
|
1
|
+
import { defineComponent as s, createVNode as e, mergeProps as b, inject as y, ref as H, computed as T, provide as P, watch as _, createTextVNode as g, watchEffect as K, Fragment as de, h as pe } from "vue";
|
|
2
2
|
import Ce from "@tiptap/starter-kit";
|
|
3
3
|
import { useEditor as ve, EditorContent as fe, nodeViewProps as he, NodeViewWrapper as me, VueNodeViewRenderer as ge } from "@tiptap/vue-3";
|
|
4
4
|
import { TaskList as we, TaskItem as be } from "@tiptap/extension-list";
|
|
5
5
|
import { TextAlign as xe } from "@tiptap/extension-text-align";
|
|
6
6
|
import { Placeholder as ke } from "@tiptap/extension-placeholder";
|
|
7
7
|
import { BubbleMenu as He } from "@tiptap/vue-3/menus";
|
|
8
|
-
import { ElTooltip as D, ElButton as Z, ElPopover as
|
|
8
|
+
import { ElTooltip as D, ElButton as Z, ElPopover as G, ElInput as J, ElDropdown as N, ElDropdownMenu as j, ElDropdownItem as L, ElDialog as ye, ElRadioGroup as Be, ElRadioButton as W } from "element-plus";
|
|
9
9
|
import { Image as Ae } from "@tiptap/extension-image";
|
|
10
10
|
import { Plugin as Me, NodeSelection as Ie } from "@tiptap/pm/state";
|
|
11
|
-
import { Decoration as
|
|
11
|
+
import { Decoration as Ee, DecorationSet as Le } from "@tiptap/pm/view";
|
|
12
12
|
import { CodeBlockLowlight as Fe } from "@tiptap/extension-code-block-lowlight";
|
|
13
13
|
import { createLowlight as Te, common as Ve } from "lowlight";
|
|
14
14
|
import { TableRow as Ze, TableHeader as De, TableCell as Re, Table as Se } from "@tiptap/extension-table";
|
|
@@ -34,7 +34,7 @@ const Oe = {
|
|
|
34
34
|
onClick: {
|
|
35
35
|
type: Function
|
|
36
36
|
}
|
|
37
|
-
}, w = /* @__PURE__ */
|
|
37
|
+
}, w = /* @__PURE__ */ s({
|
|
38
38
|
name: "IconButton",
|
|
39
39
|
props: Oe,
|
|
40
40
|
setup(t) {
|
|
@@ -54,7 +54,7 @@ const Oe = {
|
|
|
54
54
|
}, null)]
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
|
-
}),
|
|
57
|
+
}), X = /* @__PURE__ */ s({
|
|
58
58
|
name: "BoldIcon",
|
|
59
59
|
setup(t, {
|
|
60
60
|
attrs: l
|
|
@@ -72,7 +72,7 @@ const Oe = {
|
|
|
72
72
|
fill: "currentColor"
|
|
73
73
|
}, null)]);
|
|
74
74
|
}
|
|
75
|
-
}),
|
|
75
|
+
}), Q = /* @__PURE__ */ s({
|
|
76
76
|
name: "ItalicIcon",
|
|
77
77
|
setup(t, {
|
|
78
78
|
attrs: l
|
|
@@ -88,7 +88,7 @@ const Oe = {
|
|
|
88
88
|
fill: "currentColor"
|
|
89
89
|
}, null)]);
|
|
90
90
|
}
|
|
91
|
-
}),
|
|
91
|
+
}), Y = /* @__PURE__ */ s({
|
|
92
92
|
name: "StrikeIcon",
|
|
93
93
|
setup(t, {
|
|
94
94
|
attrs: l
|
|
@@ -107,7 +107,7 @@ const Oe = {
|
|
|
107
107
|
fill: "currentColor"
|
|
108
108
|
}, null)]);
|
|
109
109
|
}
|
|
110
|
-
}),
|
|
110
|
+
}), ee = /* @__PURE__ */ s({
|
|
111
111
|
name: "UnderlineIcon",
|
|
112
112
|
setup(t, {
|
|
113
113
|
attrs: l
|
|
@@ -125,10 +125,192 @@ const Oe = {
|
|
|
125
125
|
fill: "currentColor"
|
|
126
126
|
}, null)]);
|
|
127
127
|
}
|
|
128
|
-
}), $e = /* @__PURE__ */
|
|
128
|
+
}), $e = /* @__PURE__ */ s({
|
|
129
|
+
name: "LinkIcon",
|
|
130
|
+
setup(t, {
|
|
131
|
+
attrs: l
|
|
132
|
+
}) {
|
|
133
|
+
return () => e("svg", b({
|
|
134
|
+
width: "24",
|
|
135
|
+
height: "24",
|
|
136
|
+
viewBox: "0 0 24 24",
|
|
137
|
+
fill: "currentColor",
|
|
138
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
139
|
+
}, l), [e("path", {
|
|
140
|
+
d: "M16.9958 1.06669C15.4226 1.05302 13.907 1.65779 12.7753 2.75074L12.765 2.76086L11.045 4.47086C10.6534 4.86024 10.6515 5.49341 11.0409 5.88507C11.4303 6.27673 12.0634 6.27858 12.4551 5.88919L14.1697 4.18456C14.9236 3.45893 15.9319 3.05752 16.9784 3.06662C18.0272 3.07573 19.0304 3.49641 19.772 4.23804C20.5137 4.97967 20.9344 5.98292 20.9435 7.03171C20.9526 8.07776 20.5515 9.08563 19.8265 9.83941L16.833 12.8329C16.4274 13.2386 15.9393 13.5524 15.4019 13.7529C14.8645 13.9533 14.2903 14.0359 13.7181 13.9949C13.146 13.9539 12.5894 13.7904 12.0861 13.5154C11.5827 13.2404 11.1444 12.8604 10.8008 12.401C10.47 11.9588 9.84333 11.8685 9.40108 12.1993C8.95883 12.5301 8.86849 13.1568 9.1993 13.599C9.71464 14.288 10.3721 14.858 11.1272 15.2705C11.8822 15.683 12.7171 15.9283 13.5753 15.9898C14.4334 16.0513 15.2948 15.9274 16.1009 15.6267C16.907 15.326 17.639 14.8555 18.2473 14.247L21.2472 11.2471L21.2593 11.2347C22.3523 10.1031 22.9571 8.58751 22.9434 7.01433C22.9297 5.44115 22.2987 3.93628 21.1863 2.82383C20.0738 1.71138 18.5689 1.08036 16.9958 1.06669Z",
|
|
141
|
+
fill: "currentColor"
|
|
142
|
+
}, null), e("path", {
|
|
143
|
+
d: "M10.4247 8.0102C9.56657 7.94874 8.70522 8.07256 7.89911 8.37326C7.09305 8.67395 6.36096 9.14458 5.75272 9.753L2.75285 12.7529L2.74067 12.7653C1.64772 13.8969 1.04295 15.4125 1.05662 16.9857C1.07029 18.5589 1.70131 20.0637 2.81376 21.1762C3.9262 22.2886 5.43108 22.9196 7.00426 22.9333C8.57744 22.947 10.0931 22.3422 11.2247 21.2493L11.2371 21.2371L12.9471 19.5271C13.3376 19.1366 13.3376 18.5034 12.9471 18.1129C12.5565 17.7223 11.9234 17.7223 11.5328 18.1129L9.82932 19.8164C9.07555 20.5414 8.06768 20.9425 7.02164 20.9334C5.97285 20.9243 4.9696 20.5036 4.22797 19.762C3.48634 19.0203 3.06566 18.0171 3.05655 16.9683C3.04746 15.9222 3.44851 14.9144 4.17355 14.1606L7.16719 11.167C7.5727 10.7613 8.06071 10.4476 8.59811 10.2471C9.13552 10.0467 9.70976 9.96412 10.2819 10.0051C10.854 10.0461 11.4106 10.2096 11.9139 10.4846C12.4173 10.7596 12.8556 11.1397 13.1992 11.599C13.53 12.0412 14.1567 12.1316 14.5989 11.8007C15.0412 11.4699 15.1315 10.8433 14.8007 10.401C14.2854 9.71205 13.6279 9.14198 12.8729 8.72948C12.1178 8.31697 11.2829 8.07166 10.4247 8.0102Z",
|
|
144
|
+
fill: "currentColor"
|
|
145
|
+
}, null)]);
|
|
146
|
+
}
|
|
147
|
+
}), Ne = /* @__PURE__ */ s({
|
|
148
|
+
name: "CornerDownLeftIcon",
|
|
149
|
+
setup(t, {
|
|
150
|
+
attrs: l
|
|
151
|
+
}) {
|
|
152
|
+
return () => e("svg", b({
|
|
153
|
+
width: "24",
|
|
154
|
+
height: "24",
|
|
155
|
+
viewBox: "0 0 24 24",
|
|
156
|
+
fill: "none",
|
|
157
|
+
stroke: "currentColor",
|
|
158
|
+
"stroke-width": "2",
|
|
159
|
+
"stroke-linecap": "round",
|
|
160
|
+
"stroke-linejoin": "round",
|
|
161
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
162
|
+
}, l), [e("polyline", {
|
|
163
|
+
points: "9 10 4 15 9 20"
|
|
164
|
+
}, null), e("path", {
|
|
165
|
+
d: "M20 4v7a4 4 0 0 1-4 4H4"
|
|
166
|
+
}, null)]);
|
|
167
|
+
}
|
|
168
|
+
}), je = /* @__PURE__ */ s({
|
|
169
|
+
name: "ExternalLinkIcon",
|
|
170
|
+
setup(t, {
|
|
171
|
+
attrs: l
|
|
172
|
+
}) {
|
|
173
|
+
return () => e("svg", b({
|
|
174
|
+
width: "24",
|
|
175
|
+
height: "24",
|
|
176
|
+
viewBox: "0 0 24 24",
|
|
177
|
+
fill: "none",
|
|
178
|
+
stroke: "currentColor",
|
|
179
|
+
"stroke-width": "2",
|
|
180
|
+
"stroke-linecap": "round",
|
|
181
|
+
"stroke-linejoin": "round",
|
|
182
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
183
|
+
}, l), [e("path", {
|
|
184
|
+
d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"
|
|
185
|
+
}, null), e("polyline", {
|
|
186
|
+
points: "15 3 21 3 21 9"
|
|
187
|
+
}, null), e("line", {
|
|
188
|
+
x1: "10",
|
|
189
|
+
y1: "14",
|
|
190
|
+
x2: "21",
|
|
191
|
+
y2: "3"
|
|
192
|
+
}, null)]);
|
|
193
|
+
}
|
|
194
|
+
}), We = /* @__PURE__ */ s({
|
|
195
|
+
name: "TrashIcon",
|
|
196
|
+
setup(t, {
|
|
197
|
+
attrs: l
|
|
198
|
+
}) {
|
|
199
|
+
return () => e("svg", b({
|
|
200
|
+
width: "24",
|
|
201
|
+
height: "24",
|
|
202
|
+
viewBox: "0 0 24 24",
|
|
203
|
+
fill: "none",
|
|
204
|
+
stroke: "currentColor",
|
|
205
|
+
"stroke-width": "2",
|
|
206
|
+
"stroke-linecap": "round",
|
|
207
|
+
"stroke-linejoin": "round",
|
|
208
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
209
|
+
}, l), [e("polyline", {
|
|
210
|
+
points: "3 6 5 6 21 6"
|
|
211
|
+
}, null), e("path", {
|
|
212
|
+
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"
|
|
213
|
+
}, null)]);
|
|
214
|
+
}
|
|
215
|
+
}), te = /* @__PURE__ */ s({
|
|
216
|
+
name: "LinkPopover",
|
|
217
|
+
setup() {
|
|
218
|
+
const t = y("editor"), l = H(!1), n = H(""), o = () => {
|
|
219
|
+
const C = t?.value;
|
|
220
|
+
if (!C || !n.value) return;
|
|
221
|
+
const {
|
|
222
|
+
empty: h
|
|
223
|
+
} = C.state.selection;
|
|
224
|
+
let c = C.chain().focus().extendMarkRange("link").setLink({
|
|
225
|
+
href: n.value
|
|
226
|
+
});
|
|
227
|
+
h && (c = c.insertContent({
|
|
228
|
+
type: "text",
|
|
229
|
+
text: n.value
|
|
230
|
+
})), c.run(), l.value = !1;
|
|
231
|
+
}, i = () => {
|
|
232
|
+
const C = t?.value;
|
|
233
|
+
C && (C.chain().focus().extendMarkRange("link").unsetLink().run(), n.value = "", l.value = !1);
|
|
234
|
+
}, u = () => {
|
|
235
|
+
const C = t?.value?.getAttributes("link").href;
|
|
236
|
+
C && window.open(C, "_blank", "noopener,noreferrer");
|
|
237
|
+
}, v = (C) => {
|
|
238
|
+
C.key === "Enter" && (C.preventDefault(), o());
|
|
239
|
+
}, p = (C) => {
|
|
240
|
+
C && (n.value = t?.value?.getAttributes("link").href ?? ""), l.value = C;
|
|
241
|
+
}, a = (C) => {
|
|
242
|
+
n.value = C;
|
|
243
|
+
};
|
|
244
|
+
return () => {
|
|
245
|
+
const C = t?.value?.isActive("link") ?? !1;
|
|
246
|
+
return e(G, {
|
|
247
|
+
visible: l.value,
|
|
248
|
+
"onUpdate:visible": p,
|
|
249
|
+
placement: "bottom",
|
|
250
|
+
width: 300,
|
|
251
|
+
trigger: "click",
|
|
252
|
+
showArrow: !1,
|
|
253
|
+
popperClass: "tiptap-link-popover-popper",
|
|
254
|
+
offset: 6
|
|
255
|
+
}, {
|
|
256
|
+
reference: () => e("span", null, [e(w, {
|
|
257
|
+
tooltip: "链接",
|
|
258
|
+
icon: $e,
|
|
259
|
+
isActive: C
|
|
260
|
+
}, null)]),
|
|
261
|
+
default: () => e("div", {
|
|
262
|
+
class: "tiptap-link-popover-inner"
|
|
263
|
+
}, [e(J, {
|
|
264
|
+
modelValue: n.value,
|
|
265
|
+
"onUpdate:modelValue": a,
|
|
266
|
+
type: "url",
|
|
267
|
+
placeholder: "请输入链接...",
|
|
268
|
+
size: "small",
|
|
269
|
+
autofocus: !0,
|
|
270
|
+
onKeydown: v
|
|
271
|
+
}, null), e("div", {
|
|
272
|
+
class: "tiptap-link-popover-actions"
|
|
273
|
+
}, [e(D, {
|
|
274
|
+
content: "确认",
|
|
275
|
+
showArrow: !1,
|
|
276
|
+
offset: 4
|
|
277
|
+
}, {
|
|
278
|
+
default: () => [e(Z, {
|
|
279
|
+
text: !0,
|
|
280
|
+
icon: Ne,
|
|
281
|
+
disabled: !n.value,
|
|
282
|
+
onClick: o
|
|
283
|
+
}, null)]
|
|
284
|
+
}), e(D, {
|
|
285
|
+
content: "在新标签页打开",
|
|
286
|
+
showArrow: !1,
|
|
287
|
+
offset: 4
|
|
288
|
+
}, {
|
|
289
|
+
default: () => [e(Z, {
|
|
290
|
+
text: !0,
|
|
291
|
+
icon: je,
|
|
292
|
+
disabled: !n.value && !C,
|
|
293
|
+
onClick: u
|
|
294
|
+
}, null)]
|
|
295
|
+
}), e(D, {
|
|
296
|
+
content: "移除链接",
|
|
297
|
+
showArrow: !1,
|
|
298
|
+
offset: 4
|
|
299
|
+
}, {
|
|
300
|
+
default: () => [e(Z, {
|
|
301
|
+
text: !0,
|
|
302
|
+
icon: We,
|
|
303
|
+
disabled: !C,
|
|
304
|
+
onClick: i
|
|
305
|
+
}, null)]
|
|
306
|
+
})])])
|
|
307
|
+
});
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
}), qe = /* @__PURE__ */ s({
|
|
129
311
|
name: "BubbleMenuBar",
|
|
130
312
|
setup() {
|
|
131
|
-
const t =
|
|
313
|
+
const t = y("editor"), l = y("readonly");
|
|
132
314
|
return () => t?.value ? e(He, {
|
|
133
315
|
editor: t.value,
|
|
134
316
|
class: "bubble-menu",
|
|
@@ -143,37 +325,37 @@ const Oe = {
|
|
|
143
325
|
const {
|
|
144
326
|
editor: o,
|
|
145
327
|
from: i,
|
|
146
|
-
to:
|
|
328
|
+
to: u
|
|
147
329
|
} = n;
|
|
148
|
-
return !(i ===
|
|
330
|
+
return !(i === u || o.isActive("image") || o.isActive("table"));
|
|
149
331
|
}
|
|
150
332
|
}, {
|
|
151
333
|
default: () => [e("div", {
|
|
152
|
-
class: "bubble-menu
|
|
334
|
+
class: "tiptap-bubble-menu"
|
|
153
335
|
}, [e(w, {
|
|
154
|
-
icon:
|
|
336
|
+
icon: X,
|
|
155
337
|
tooltip: "粗体",
|
|
156
338
|
isActive: t.value.isActive("bold"),
|
|
157
339
|
onClick: () => t.value?.chain().focus().toggleBold().run()
|
|
158
340
|
}, null), e(w, {
|
|
159
|
-
icon:
|
|
341
|
+
icon: Q,
|
|
160
342
|
tooltip: "斜体",
|
|
161
343
|
isActive: t.value.isActive("italic"),
|
|
162
344
|
onClick: () => t.value?.chain().focus().toggleItalic().run()
|
|
163
345
|
}, null), e(w, {
|
|
164
|
-
icon:
|
|
346
|
+
icon: Y,
|
|
165
347
|
tooltip: "删除线",
|
|
166
348
|
isActive: t.value.isActive("strike"),
|
|
167
349
|
onClick: () => t.value?.chain().focus().toggleStrike().run()
|
|
168
350
|
}, null), e(w, {
|
|
169
|
-
icon:
|
|
351
|
+
icon: ee,
|
|
170
352
|
tooltip: "下划线",
|
|
171
353
|
isActive: t.value.isActive("underline"),
|
|
172
354
|
onClick: () => t.value?.chain().focus().toggleUnderline().run()
|
|
173
|
-
}, null)])]
|
|
355
|
+
}, null), e(te, null, null)])]
|
|
174
356
|
}) : null;
|
|
175
357
|
}
|
|
176
|
-
}),
|
|
358
|
+
}), Wt = /* @__PURE__ */ s({
|
|
177
359
|
name: "TiptapEditor",
|
|
178
360
|
props: {
|
|
179
361
|
modelValue: {
|
|
@@ -188,6 +370,10 @@ const Oe = {
|
|
|
188
370
|
type: Boolean,
|
|
189
371
|
default: !1
|
|
190
372
|
},
|
|
373
|
+
upload: {
|
|
374
|
+
type: Function,
|
|
375
|
+
default: void 0
|
|
376
|
+
},
|
|
191
377
|
features: {
|
|
192
378
|
type: Array,
|
|
193
379
|
default: () => []
|
|
@@ -199,11 +385,12 @@ const Oe = {
|
|
|
199
385
|
}) {
|
|
200
386
|
const n = T(() => t.readonly ?? !1);
|
|
201
387
|
P("readonly", n);
|
|
202
|
-
const o = t.features.map((
|
|
203
|
-
plugin:
|
|
204
|
-
result:
|
|
388
|
+
const o = t.features.map((u) => ({
|
|
389
|
+
plugin: u,
|
|
390
|
+
result: u.install({
|
|
205
391
|
readonly: n,
|
|
206
|
-
provide: (v, p) => P(v, p)
|
|
392
|
+
provide: (v, p) => P(v, p),
|
|
393
|
+
upload: t.upload
|
|
207
394
|
})
|
|
208
395
|
})), i = ve({
|
|
209
396
|
content: t.modelValue,
|
|
@@ -221,45 +408,45 @@ const Oe = {
|
|
|
221
408
|
}), we, be.configure({
|
|
222
409
|
nested: !0
|
|
223
410
|
}), ...o.flatMap(({
|
|
224
|
-
result:
|
|
225
|
-
}) =>
|
|
411
|
+
result: u
|
|
412
|
+
}) => u.extensions)],
|
|
226
413
|
onUpdate: ({
|
|
227
|
-
editor:
|
|
414
|
+
editor: u
|
|
228
415
|
}) => {
|
|
229
|
-
l("update:modelValue",
|
|
416
|
+
l("update:modelValue", u.getHTML());
|
|
230
417
|
}
|
|
231
418
|
});
|
|
232
|
-
return P("editor", i),
|
|
233
|
-
i.value &&
|
|
419
|
+
return P("editor", i), _(() => t.modelValue, (u) => {
|
|
420
|
+
i.value && u !== i.value.getHTML() && i.value.commands.setContent(u, {
|
|
234
421
|
emitUpdate: !1
|
|
235
422
|
});
|
|
236
|
-
}),
|
|
237
|
-
i.value?.setEditable(!
|
|
423
|
+
}), _(() => t.readonly, (u) => {
|
|
424
|
+
i.value?.setEditable(!u);
|
|
238
425
|
}), () => e("div", {
|
|
239
426
|
class: "tiptap-editor"
|
|
240
427
|
}, [!t.readonly && e("div", {
|
|
241
428
|
class: "tiptap-toolbar"
|
|
242
429
|
}, [o.map(({
|
|
243
|
-
plugin:
|
|
430
|
+
plugin: u
|
|
244
431
|
}) => {
|
|
245
|
-
const v =
|
|
432
|
+
const v = u.toolbarComponent;
|
|
246
433
|
return v ? e(v, {
|
|
247
|
-
key:
|
|
434
|
+
key: u.name
|
|
248
435
|
}, null) : null;
|
|
249
436
|
})]), e(fe, {
|
|
250
437
|
class: "tiptap-content",
|
|
251
438
|
editor: i.value
|
|
252
|
-
}, null), e(
|
|
253
|
-
plugin:
|
|
439
|
+
}, null), e(qe, null, null), o.map(({
|
|
440
|
+
plugin: u,
|
|
254
441
|
result: v
|
|
255
442
|
}) => {
|
|
256
443
|
const p = v.controlComponent;
|
|
257
444
|
return p ? e(p, {
|
|
258
|
-
key: `${
|
|
445
|
+
key: `${u.name}-control`
|
|
259
446
|
}, null) : null;
|
|
260
447
|
})]);
|
|
261
448
|
}
|
|
262
|
-
}),
|
|
449
|
+
}), Ke = Ae.extend({
|
|
263
450
|
addAttributes() {
|
|
264
451
|
return {
|
|
265
452
|
...this.parent?.(),
|
|
@@ -279,17 +466,17 @@ const Oe = {
|
|
|
279
466
|
const n = [];
|
|
280
467
|
return l.doc.descendants((o, i) => {
|
|
281
468
|
o.type.name === t && o.attrs.align && n.push(
|
|
282
|
-
|
|
469
|
+
Ee.node(i, i + o.nodeSize, {
|
|
283
470
|
"data-align": o.attrs.align
|
|
284
471
|
})
|
|
285
472
|
);
|
|
286
|
-
}),
|
|
473
|
+
}), Le.create(l.doc, n);
|
|
287
474
|
}
|
|
288
475
|
}
|
|
289
476
|
})
|
|
290
477
|
];
|
|
291
478
|
}
|
|
292
|
-
}),
|
|
479
|
+
}), Ge = /* @__PURE__ */ s({
|
|
293
480
|
name: "UndoIcon",
|
|
294
481
|
setup(t, {
|
|
295
482
|
attrs: l
|
|
@@ -307,7 +494,7 @@ const Oe = {
|
|
|
307
494
|
fill: "currentColor"
|
|
308
495
|
}, null)]);
|
|
309
496
|
}
|
|
310
|
-
}),
|
|
497
|
+
}), Je = /* @__PURE__ */ s({
|
|
311
498
|
name: "RedoIcon",
|
|
312
499
|
setup(t, {
|
|
313
500
|
attrs: l
|
|
@@ -325,253 +512,57 @@ const Oe = {
|
|
|
325
512
|
fill: "currentColor"
|
|
326
513
|
}, null)]);
|
|
327
514
|
}
|
|
328
|
-
}),
|
|
515
|
+
}), Xe = /* @__PURE__ */ s({
|
|
329
516
|
name: "UndoRedoButton",
|
|
330
517
|
setup() {
|
|
331
|
-
const t =
|
|
518
|
+
const t = y("editor"), l = T(() => t?.value?.can().undo() ?? !1), n = T(() => t?.value?.can().redo() ?? !1);
|
|
332
519
|
return () => e("div", null, [e(w, {
|
|
333
|
-
icon:
|
|
520
|
+
icon: Ge,
|
|
334
521
|
tooltip: "撤销",
|
|
335
522
|
disabled: !l.value,
|
|
336
523
|
onClick: () => t?.value?.chain().focus().undo().run()
|
|
337
524
|
}, null), e(w, {
|
|
338
|
-
icon:
|
|
525
|
+
icon: Je,
|
|
339
526
|
tooltip: "重做",
|
|
340
527
|
disabled: !n.value,
|
|
341
528
|
onClick: () => t?.value?.chain().focus().redo().run()
|
|
342
529
|
}, null)]);
|
|
343
530
|
}
|
|
344
|
-
}),
|
|
531
|
+
}), qt = {
|
|
345
532
|
name: "undo-redo",
|
|
346
533
|
install: () => ({ extensions: [] }),
|
|
347
|
-
toolbarComponent:
|
|
348
|
-
},
|
|
349
|
-
name: "LinkIcon",
|
|
350
|
-
setup(t, {
|
|
351
|
-
attrs: l
|
|
352
|
-
}) {
|
|
353
|
-
return () => e("svg", b({
|
|
354
|
-
width: "24",
|
|
355
|
-
height: "24",
|
|
356
|
-
viewBox: "0 0 24 24",
|
|
357
|
-
fill: "currentColor",
|
|
358
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
359
|
-
}, l), [e("path", {
|
|
360
|
-
d: "M16.9958 1.06669C15.4226 1.05302 13.907 1.65779 12.7753 2.75074L12.765 2.76086L11.045 4.47086C10.6534 4.86024 10.6515 5.49341 11.0409 5.88507C11.4303 6.27673 12.0634 6.27858 12.4551 5.88919L14.1697 4.18456C14.9236 3.45893 15.9319 3.05752 16.9784 3.06662C18.0272 3.07573 19.0304 3.49641 19.772 4.23804C20.5137 4.97967 20.9344 5.98292 20.9435 7.03171C20.9526 8.07776 20.5515 9.08563 19.8265 9.83941L16.833 12.8329C16.4274 13.2386 15.9393 13.5524 15.4019 13.7529C14.8645 13.9533 14.2903 14.0359 13.7181 13.9949C13.146 13.9539 12.5894 13.7904 12.0861 13.5154C11.5827 13.2404 11.1444 12.8604 10.8008 12.401C10.47 11.9588 9.84333 11.8685 9.40108 12.1993C8.95883 12.5301 8.86849 13.1568 9.1993 13.599C9.71464 14.288 10.3721 14.858 11.1272 15.2705C11.8822 15.683 12.7171 15.9283 13.5753 15.9898C14.4334 16.0513 15.2948 15.9274 16.1009 15.6267C16.907 15.326 17.639 14.8555 18.2473 14.247L21.2472 11.2471L21.2593 11.2347C22.3523 10.1031 22.9571 8.58751 22.9434 7.01433C22.9297 5.44115 22.2987 3.93628 21.1863 2.82383C20.0738 1.71138 18.5689 1.08036 16.9958 1.06669Z",
|
|
361
|
-
fill: "currentColor"
|
|
362
|
-
}, null), e("path", {
|
|
363
|
-
d: "M10.4247 8.0102C9.56657 7.94874 8.70522 8.07256 7.89911 8.37326C7.09305 8.67395 6.36096 9.14458 5.75272 9.753L2.75285 12.7529L2.74067 12.7653C1.64772 13.8969 1.04295 15.4125 1.05662 16.9857C1.07029 18.5589 1.70131 20.0637 2.81376 21.1762C3.9262 22.2886 5.43108 22.9196 7.00426 22.9333C8.57744 22.947 10.0931 22.3422 11.2247 21.2493L11.2371 21.2371L12.9471 19.5271C13.3376 19.1366 13.3376 18.5034 12.9471 18.1129C12.5565 17.7223 11.9234 17.7223 11.5328 18.1129L9.82932 19.8164C9.07555 20.5414 8.06768 20.9425 7.02164 20.9334C5.97285 20.9243 4.9696 20.5036 4.22797 19.762C3.48634 19.0203 3.06566 18.0171 3.05655 16.9683C3.04746 15.9222 3.44851 14.9144 4.17355 14.1606L7.16719 11.167C7.5727 10.7613 8.06071 10.4476 8.59811 10.2471C9.13552 10.0467 9.70976 9.96412 10.2819 10.0051C10.854 10.0461 11.4106 10.2096 11.9139 10.4846C12.4173 10.7596 12.8556 11.1397 13.1992 11.599C13.53 12.0412 14.1567 12.1316 14.5989 11.8007C15.0412 11.4699 15.1315 10.8433 14.8007 10.401C14.2854 9.71205 13.6279 9.14198 12.8729 8.72948C12.1178 8.31697 11.2829 8.07166 10.4247 8.0102Z",
|
|
364
|
-
fill: "currentColor"
|
|
365
|
-
}, null)]);
|
|
366
|
-
}
|
|
367
|
-
}), Ge = /* @__PURE__ */ c({
|
|
368
|
-
name: "CornerDownLeftIcon",
|
|
369
|
-
setup(t, {
|
|
370
|
-
attrs: l
|
|
371
|
-
}) {
|
|
372
|
-
return () => e("svg", b({
|
|
373
|
-
width: "24",
|
|
374
|
-
height: "24",
|
|
375
|
-
viewBox: "0 0 24 24",
|
|
376
|
-
fill: "none",
|
|
377
|
-
stroke: "currentColor",
|
|
378
|
-
"stroke-width": "2",
|
|
379
|
-
"stroke-linecap": "round",
|
|
380
|
-
"stroke-linejoin": "round",
|
|
381
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
382
|
-
}, l), [e("polyline", {
|
|
383
|
-
points: "9 10 4 15 9 20"
|
|
384
|
-
}, null), e("path", {
|
|
385
|
-
d: "M20 4v7a4 4 0 0 1-4 4H4"
|
|
386
|
-
}, null)]);
|
|
387
|
-
}
|
|
388
|
-
}), Je = /* @__PURE__ */ c({
|
|
389
|
-
name: "ExternalLinkIcon",
|
|
390
|
-
setup(t, {
|
|
391
|
-
attrs: l
|
|
392
|
-
}) {
|
|
393
|
-
return () => e("svg", b({
|
|
394
|
-
width: "24",
|
|
395
|
-
height: "24",
|
|
396
|
-
viewBox: "0 0 24 24",
|
|
397
|
-
fill: "none",
|
|
398
|
-
stroke: "currentColor",
|
|
399
|
-
"stroke-width": "2",
|
|
400
|
-
"stroke-linecap": "round",
|
|
401
|
-
"stroke-linejoin": "round",
|
|
402
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
403
|
-
}, l), [e("path", {
|
|
404
|
-
d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"
|
|
405
|
-
}, null), e("polyline", {
|
|
406
|
-
points: "15 3 21 3 21 9"
|
|
407
|
-
}, null), e("line", {
|
|
408
|
-
x1: "10",
|
|
409
|
-
y1: "14",
|
|
410
|
-
x2: "21",
|
|
411
|
-
y2: "3"
|
|
412
|
-
}, null)]);
|
|
413
|
-
}
|
|
414
|
-
}), Xe = /* @__PURE__ */ c({
|
|
415
|
-
name: "TrashIcon",
|
|
416
|
-
setup(t, {
|
|
417
|
-
attrs: l
|
|
418
|
-
}) {
|
|
419
|
-
return () => e("svg", b({
|
|
420
|
-
width: "24",
|
|
421
|
-
height: "24",
|
|
422
|
-
viewBox: "0 0 24 24",
|
|
423
|
-
fill: "none",
|
|
424
|
-
stroke: "currentColor",
|
|
425
|
-
"stroke-width": "2",
|
|
426
|
-
"stroke-linecap": "round",
|
|
427
|
-
"stroke-linejoin": "round",
|
|
428
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
429
|
-
}, l), [e("polyline", {
|
|
430
|
-
points: "3 6 5 6 21 6"
|
|
431
|
-
}, null), e("path", {
|
|
432
|
-
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"
|
|
433
|
-
}, null)]);
|
|
434
|
-
}
|
|
435
|
-
}), Qe = /* @__PURE__ */ c({
|
|
436
|
-
name: "LinkPopover",
|
|
437
|
-
setup() {
|
|
438
|
-
const t = H("editor"), l = k(!1), n = k("");
|
|
439
|
-
let o = !1;
|
|
440
|
-
R(() => t?.value?.isActive("link"), (u) => {
|
|
441
|
-
o || u && (n.value = t?.value?.getAttributes("link").href ?? "", z(() => {
|
|
442
|
-
l.value = !0;
|
|
443
|
-
}));
|
|
444
|
-
});
|
|
445
|
-
const i = () => {
|
|
446
|
-
const u = t?.value;
|
|
447
|
-
if (!u || !n.value) return;
|
|
448
|
-
o = !0;
|
|
449
|
-
const {
|
|
450
|
-
empty: C
|
|
451
|
-
} = u.state.selection;
|
|
452
|
-
let g = u.chain().focus().extendMarkRange("link").setLink({
|
|
453
|
-
href: n.value
|
|
454
|
-
});
|
|
455
|
-
C && (g = g.insertContent({
|
|
456
|
-
type: "text",
|
|
457
|
-
text: n.value
|
|
458
|
-
})), g.run(), l.value = !1, z(() => {
|
|
459
|
-
o = !1;
|
|
460
|
-
});
|
|
461
|
-
}, r = () => {
|
|
462
|
-
const u = t?.value;
|
|
463
|
-
u && (o = !0, u.chain().focus().extendMarkRange("link").unsetLink().run(), n.value = "", l.value = !1, z(() => {
|
|
464
|
-
o = !1;
|
|
465
|
-
}));
|
|
466
|
-
}, v = () => {
|
|
467
|
-
const u = t?.value?.getAttributes("link").href;
|
|
468
|
-
u && window.open(u, "_blank", "noopener,noreferrer");
|
|
469
|
-
}, p = (u) => {
|
|
470
|
-
u.key === "Enter" && (u.preventDefault(), i());
|
|
471
|
-
}, s = (u) => {
|
|
472
|
-
u && (n.value = t?.value?.getAttributes("link").href ?? ""), l.value = u;
|
|
473
|
-
}, y = (u) => {
|
|
474
|
-
n.value = u;
|
|
475
|
-
};
|
|
476
|
-
return () => {
|
|
477
|
-
const u = t?.value?.isActive("link") ?? !1;
|
|
478
|
-
return e(J, {
|
|
479
|
-
visible: l.value,
|
|
480
|
-
"onUpdate:visible": s,
|
|
481
|
-
placement: "bottom",
|
|
482
|
-
width: 300,
|
|
483
|
-
trigger: "click",
|
|
484
|
-
showArrow: !1,
|
|
485
|
-
popperClass: "link-popover-popper",
|
|
486
|
-
offset: 6
|
|
487
|
-
}, {
|
|
488
|
-
reference: () => e("span", null, [e(w, {
|
|
489
|
-
tooltip: "链接",
|
|
490
|
-
icon: Ke,
|
|
491
|
-
class: ["tiptap-button", {
|
|
492
|
-
"is-active": u
|
|
493
|
-
}]
|
|
494
|
-
}, null)]),
|
|
495
|
-
default: () => e("div", {
|
|
496
|
-
class: "link-popover-inner"
|
|
497
|
-
}, [e(X, {
|
|
498
|
-
modelValue: n.value,
|
|
499
|
-
"onUpdate:modelValue": y,
|
|
500
|
-
type: "url",
|
|
501
|
-
placeholder: "请输入链接...",
|
|
502
|
-
size: "small",
|
|
503
|
-
autofocus: !0,
|
|
504
|
-
onKeydown: p
|
|
505
|
-
}, null), e("div", {
|
|
506
|
-
class: "link-popover-actions"
|
|
507
|
-
}, [e(D, {
|
|
508
|
-
content: "确认",
|
|
509
|
-
showArrow: !1,
|
|
510
|
-
offset: 4
|
|
511
|
-
}, {
|
|
512
|
-
default: () => [e(Z, {
|
|
513
|
-
text: !0,
|
|
514
|
-
icon: Ge,
|
|
515
|
-
disabled: !n.value,
|
|
516
|
-
onClick: i
|
|
517
|
-
}, null)]
|
|
518
|
-
}), e(D, {
|
|
519
|
-
content: "在新标签页打开",
|
|
520
|
-
showArrow: !1,
|
|
521
|
-
offset: 4
|
|
522
|
-
}, {
|
|
523
|
-
default: () => [e(Z, {
|
|
524
|
-
text: !0,
|
|
525
|
-
icon: Je,
|
|
526
|
-
disabled: !n.value && !u,
|
|
527
|
-
onClick: v
|
|
528
|
-
}, null)]
|
|
529
|
-
}), e(D, {
|
|
530
|
-
content: "移除链接",
|
|
531
|
-
showArrow: !1,
|
|
532
|
-
offset: 4
|
|
533
|
-
}, {
|
|
534
|
-
default: () => [e(Z, {
|
|
535
|
-
text: !0,
|
|
536
|
-
icon: Xe,
|
|
537
|
-
disabled: !u,
|
|
538
|
-
onClick: r
|
|
539
|
-
}, null)]
|
|
540
|
-
})])])
|
|
541
|
-
});
|
|
542
|
-
};
|
|
543
|
-
}
|
|
544
|
-
}), Ye = /* @__PURE__ */ c({
|
|
534
|
+
toolbarComponent: Xe
|
|
535
|
+
}, Qe = /* @__PURE__ */ s({
|
|
545
536
|
name: "TextStyleButton",
|
|
546
537
|
setup() {
|
|
547
|
-
const t =
|
|
538
|
+
const t = y("editor");
|
|
548
539
|
return () => e("div", null, [e(w, {
|
|
549
|
-
icon:
|
|
540
|
+
icon: X,
|
|
550
541
|
tooltip: "粗体",
|
|
551
542
|
isActive: t?.value?.isActive("bold"),
|
|
552
543
|
onClick: () => t?.value?.chain().focus().toggleBold().run()
|
|
553
544
|
}, null), e(w, {
|
|
554
|
-
icon:
|
|
545
|
+
icon: Q,
|
|
555
546
|
tooltip: "斜体",
|
|
556
547
|
isActive: t?.value?.isActive("italic"),
|
|
557
548
|
onClick: () => t?.value?.chain().focus().toggleItalic().run()
|
|
558
549
|
}, null), e(w, {
|
|
559
|
-
icon:
|
|
550
|
+
icon: Y,
|
|
560
551
|
tooltip: "删除线",
|
|
561
552
|
isActive: t?.value?.isActive("strike"),
|
|
562
553
|
onClick: () => t?.value?.chain().focus().toggleStrike().run()
|
|
563
554
|
}, null), e(w, {
|
|
564
|
-
icon:
|
|
555
|
+
icon: ee,
|
|
565
556
|
tooltip: "下划线",
|
|
566
557
|
isActive: t?.value?.isActive("underline"),
|
|
567
558
|
onClick: () => t?.value?.chain().focus().toggleUnderline().run()
|
|
568
|
-
}, null), e(
|
|
559
|
+
}, null), e(te, null, null)]);
|
|
569
560
|
}
|
|
570
|
-
}),
|
|
561
|
+
}), Kt = {
|
|
571
562
|
name: "text-style",
|
|
572
563
|
install: () => ({ extensions: [] }),
|
|
573
|
-
toolbarComponent:
|
|
574
|
-
}, le = /* @__PURE__ */
|
|
564
|
+
toolbarComponent: Qe
|
|
565
|
+
}, le = /* @__PURE__ */ s({
|
|
575
566
|
name: "AlignLeftIcon",
|
|
576
567
|
setup(t, {
|
|
577
568
|
attrs: l
|
|
@@ -599,7 +590,7 @@ const Oe = {
|
|
|
599
590
|
fill: "currentColor"
|
|
600
591
|
}, null)]);
|
|
601
592
|
}
|
|
602
|
-
}), ne = /* @__PURE__ */
|
|
593
|
+
}), ne = /* @__PURE__ */ s({
|
|
603
594
|
name: "AlignCenterIcon",
|
|
604
595
|
setup(t, {
|
|
605
596
|
attrs: l
|
|
@@ -627,7 +618,7 @@ const Oe = {
|
|
|
627
618
|
fill: "currentColor"
|
|
628
619
|
}, null)]);
|
|
629
620
|
}
|
|
630
|
-
}), oe = /* @__PURE__ */
|
|
621
|
+
}), oe = /* @__PURE__ */ s({
|
|
631
622
|
name: "AlignRightIcon",
|
|
632
623
|
setup(t, {
|
|
633
624
|
attrs: l
|
|
@@ -655,7 +646,7 @@ const Oe = {
|
|
|
655
646
|
fill: "currentColor"
|
|
656
647
|
}, null)]);
|
|
657
648
|
}
|
|
658
|
-
}),
|
|
649
|
+
}), Ye = /* @__PURE__ */ s({
|
|
659
650
|
name: "AlignJustifyIcon",
|
|
660
651
|
setup(t, {
|
|
661
652
|
attrs: l
|
|
@@ -683,10 +674,10 @@ const Oe = {
|
|
|
683
674
|
fill: "currentColor"
|
|
684
675
|
}, null)]);
|
|
685
676
|
}
|
|
686
|
-
}),
|
|
677
|
+
}), et = /* @__PURE__ */ s({
|
|
687
678
|
name: "TextAlignButton",
|
|
688
679
|
setup() {
|
|
689
|
-
const t =
|
|
680
|
+
const t = y("editor");
|
|
690
681
|
return () => e("div", null, [e(w, {
|
|
691
682
|
icon: le,
|
|
692
683
|
tooltip: "左边对齐",
|
|
@@ -709,7 +700,7 @@ const Oe = {
|
|
|
709
700
|
}),
|
|
710
701
|
onClick: () => t?.value?.chain().focus().setTextAlign("right").run()
|
|
711
702
|
}, null), e(w, {
|
|
712
|
-
icon:
|
|
703
|
+
icon: Ye,
|
|
713
704
|
tooltip: "两端对齐",
|
|
714
705
|
isActive: t?.value?.isActive({
|
|
715
706
|
textAlign: "justify"
|
|
@@ -717,11 +708,11 @@ const Oe = {
|
|
|
717
708
|
onClick: () => t?.value?.chain().focus().setTextAlign("justify").run()
|
|
718
709
|
}, null)]);
|
|
719
710
|
}
|
|
720
|
-
}),
|
|
711
|
+
}), Gt = {
|
|
721
712
|
name: "text-align",
|
|
722
713
|
install: () => ({ extensions: [] }),
|
|
723
|
-
toolbarComponent:
|
|
724
|
-
},
|
|
714
|
+
toolbarComponent: et
|
|
715
|
+
}, tt = /* @__PURE__ */ s({
|
|
725
716
|
name: "ListIcon",
|
|
726
717
|
setup(t, {
|
|
727
718
|
attrs: l
|
|
@@ -764,7 +755,7 @@ const Oe = {
|
|
|
764
755
|
fill: "currentColor"
|
|
765
756
|
}, null)]);
|
|
766
757
|
}
|
|
767
|
-
}),
|
|
758
|
+
}), lt = /* @__PURE__ */ s({
|
|
768
759
|
name: "ListOrderedIcon",
|
|
769
760
|
setup(t, {
|
|
770
761
|
attrs: l
|
|
@@ -807,7 +798,7 @@ const Oe = {
|
|
|
807
798
|
fill: "currentColor"
|
|
808
799
|
}, null)]);
|
|
809
800
|
}
|
|
810
|
-
}),
|
|
801
|
+
}), nt = /* @__PURE__ */ s({
|
|
811
802
|
name: "ListTodoIcon",
|
|
812
803
|
setup(t, {
|
|
813
804
|
attrs: l
|
|
@@ -845,32 +836,32 @@ const Oe = {
|
|
|
845
836
|
fill: "currentColor"
|
|
846
837
|
}, null)]);
|
|
847
838
|
}
|
|
848
|
-
}),
|
|
839
|
+
}), ot = /* @__PURE__ */ s({
|
|
849
840
|
name: "ListButton",
|
|
850
841
|
setup() {
|
|
851
|
-
const t =
|
|
842
|
+
const t = y("editor");
|
|
852
843
|
return () => e("div", null, [e(w, {
|
|
853
|
-
icon:
|
|
844
|
+
icon: tt,
|
|
854
845
|
tooltip: "无序列表",
|
|
855
846
|
isActive: t?.value?.isActive("bulletList"),
|
|
856
847
|
onClick: () => t?.value?.chain().focus().toggleBulletList().run()
|
|
857
848
|
}, null), e(w, {
|
|
858
|
-
icon:
|
|
849
|
+
icon: lt,
|
|
859
850
|
tooltip: "有序列表",
|
|
860
851
|
isActive: t?.value?.isActive("orderedList"),
|
|
861
852
|
onClick: () => t?.value?.chain().focus().toggleOrderedList().run()
|
|
862
853
|
}, null), e(w, {
|
|
863
|
-
icon:
|
|
854
|
+
icon: nt,
|
|
864
855
|
tooltip: "任务列表",
|
|
865
856
|
isActive: t?.value?.isActive("taskList"),
|
|
866
857
|
onClick: () => t?.value?.chain().focus().toggleTaskList().run()
|
|
867
858
|
}, null)]);
|
|
868
859
|
}
|
|
869
|
-
}),
|
|
860
|
+
}), Jt = {
|
|
870
861
|
name: "list",
|
|
871
862
|
install: () => ({ extensions: [] }),
|
|
872
|
-
toolbarComponent:
|
|
873
|
-
},
|
|
863
|
+
toolbarComponent: ot
|
|
864
|
+
}, it = /* @__PURE__ */ s({
|
|
874
865
|
name: "CodeBlockIcon",
|
|
875
866
|
setup(t, {
|
|
876
867
|
attrs: l
|
|
@@ -891,24 +882,24 @@ const Oe = {
|
|
|
891
882
|
points: "8 6 2 12 8 18"
|
|
892
883
|
}, null)]);
|
|
893
884
|
}
|
|
894
|
-
}), ut = /* @__PURE__ */
|
|
885
|
+
}), ut = /* @__PURE__ */ s({
|
|
895
886
|
name: "CodeBlockButton",
|
|
896
887
|
setup() {
|
|
897
|
-
const t =
|
|
888
|
+
const t = y("editor");
|
|
898
889
|
return () => e(w, {
|
|
899
|
-
icon:
|
|
890
|
+
icon: it,
|
|
900
891
|
tooltip: "代码块",
|
|
901
892
|
isActive: t?.value?.isActive("codeBlock"),
|
|
902
893
|
onClick: () => t?.value?.chain().focus().toggleCodeBlock().run()
|
|
903
894
|
}, null);
|
|
904
895
|
}
|
|
905
|
-
}),
|
|
896
|
+
}), rt = Te(Ve), Xt = {
|
|
906
897
|
name: "code-block",
|
|
907
898
|
install: () => ({
|
|
908
|
-
extensions: [Fe.configure({ lowlight:
|
|
899
|
+
extensions: [Fe.configure({ lowlight: rt, defaultLanguage: "plaintext" })]
|
|
909
900
|
}),
|
|
910
901
|
toolbarComponent: ut
|
|
911
|
-
},
|
|
902
|
+
}, at = /* @__PURE__ */ s({
|
|
912
903
|
name: "TableIcon",
|
|
913
904
|
setup(t, {
|
|
914
905
|
attrs: l
|
|
@@ -926,26 +917,26 @@ const Oe = {
|
|
|
926
917
|
fill: "currentColor"
|
|
927
918
|
}, null)]);
|
|
928
919
|
}
|
|
929
|
-
}),
|
|
920
|
+
}), st = 8, ct = 8, dt = /* @__PURE__ */ s({
|
|
930
921
|
name: "TableButton",
|
|
931
922
|
setup() {
|
|
932
|
-
const t =
|
|
933
|
-
n.value = p, o.value =
|
|
934
|
-
},
|
|
923
|
+
const t = y("editor"), l = H(!1), n = H(0), o = H(0), i = (p, a) => {
|
|
924
|
+
n.value = p, o.value = a;
|
|
925
|
+
}, u = () => {
|
|
935
926
|
n.value = 0, o.value = 0;
|
|
936
|
-
}, v = (p,
|
|
927
|
+
}, v = (p, a) => {
|
|
937
928
|
t?.value?.chain().focus().insertTable({
|
|
938
|
-
rows:
|
|
929
|
+
rows: a,
|
|
939
930
|
cols: p,
|
|
940
931
|
withHeaderRow: !0
|
|
941
932
|
}).run(), l.value = !1;
|
|
942
933
|
};
|
|
943
|
-
return () => e(
|
|
934
|
+
return () => e(G, {
|
|
944
935
|
visible: l.value,
|
|
945
936
|
"onUpdate:visible": (p) => l.value = p,
|
|
946
937
|
trigger: "click",
|
|
947
938
|
placement: "bottom-start",
|
|
948
|
-
popperClass: "table-picker-popper",
|
|
939
|
+
popperClass: "tiptap-table-picker-popper",
|
|
949
940
|
width: "auto",
|
|
950
941
|
showArrow: !1
|
|
951
942
|
}, {
|
|
@@ -961,43 +952,43 @@ const Oe = {
|
|
|
961
952
|
"is-active": l.value
|
|
962
953
|
}]
|
|
963
954
|
}, {
|
|
964
|
-
default: () => [e(
|
|
955
|
+
default: () => [e(at, {
|
|
965
956
|
class: "tiptap-button-icon"
|
|
966
957
|
}, null)]
|
|
967
958
|
})]
|
|
968
959
|
})]),
|
|
969
960
|
default: () => e("div", {
|
|
970
|
-
class: "table-picker"
|
|
961
|
+
class: "tiptap-table-picker"
|
|
971
962
|
}, [e("div", {
|
|
972
|
-
class: "table-picker-grid",
|
|
973
|
-
onMouseleave:
|
|
974
|
-
}, [Array.from({
|
|
975
|
-
length: dt
|
|
976
|
-
}, (p, s) => e("div", {
|
|
977
|
-
key: s,
|
|
978
|
-
class: "table-picker-row"
|
|
963
|
+
class: "tiptap-table-picker-grid",
|
|
964
|
+
onMouseleave: u
|
|
979
965
|
}, [Array.from({
|
|
980
966
|
length: ct
|
|
981
|
-
}, (
|
|
982
|
-
key:
|
|
983
|
-
class:
|
|
984
|
-
|
|
967
|
+
}, (p, a) => e("div", {
|
|
968
|
+
key: a,
|
|
969
|
+
class: "tiptap-table-picker-row"
|
|
970
|
+
}, [Array.from({
|
|
971
|
+
length: st
|
|
972
|
+
}, (C, h) => e("div", {
|
|
973
|
+
key: h,
|
|
974
|
+
class: ["tiptap-table-picker-cell", {
|
|
975
|
+
"is-active": h < n.value && a < o.value
|
|
985
976
|
}],
|
|
986
|
-
onMouseenter: () => i(
|
|
987
|
-
onClick: () => v(
|
|
977
|
+
onMouseenter: () => i(h + 1, a + 1),
|
|
978
|
+
onClick: () => v(h + 1, a + 1)
|
|
988
979
|
}, null))]))]), e("div", {
|
|
989
|
-
class: "table-picker-footer"
|
|
980
|
+
class: "tiptap-table-picker-footer"
|
|
990
981
|
}, [e("div", {
|
|
991
|
-
class: "table-picker-counter"
|
|
992
|
-
}, [e("span", null, [
|
|
993
|
-
class: "table-picker-x"
|
|
994
|
-
}, [
|
|
995
|
-
class: "table-picker-counter"
|
|
996
|
-
}, [e("span", null, [
|
|
982
|
+
class: "tiptap-table-picker-counter"
|
|
983
|
+
}, [e("span", null, [g("列")]), e("span", null, [n.value || 1])]), e("span", {
|
|
984
|
+
class: "tiptap-table-picker-x"
|
|
985
|
+
}, [g("x")]), e("div", {
|
|
986
|
+
class: "tiptap-table-picker-counter"
|
|
987
|
+
}, [e("span", null, [g("行")]), e("span", null, [o.value || 1])])])])
|
|
997
988
|
});
|
|
998
989
|
}
|
|
999
990
|
});
|
|
1000
|
-
function
|
|
991
|
+
function pt(t) {
|
|
1001
992
|
let l = t.nodeType === Node.TEXT_NODE ? t.parentElement : t;
|
|
1002
993
|
for (; l && l instanceof HTMLElement; ) {
|
|
1003
994
|
if (l.tagName === "TD" || l.tagName === "TH") return l;
|
|
@@ -1005,104 +996,104 @@ function Ct(t) {
|
|
|
1005
996
|
}
|
|
1006
997
|
return null;
|
|
1007
998
|
}
|
|
1008
|
-
function
|
|
999
|
+
function Ct(t) {
|
|
1009
1000
|
if (!t.isActive("tableCell") && !t.isActive("tableHeader")) return null;
|
|
1010
1001
|
const {
|
|
1011
1002
|
node: l
|
|
1012
|
-
} = t.view.domAtPos(t.state.selection.from), n =
|
|
1003
|
+
} = t.view.domAtPos(t.state.selection.from), n = pt(l);
|
|
1013
1004
|
if (!n) return null;
|
|
1014
|
-
const o = n.parentElement, i = o.parentElement,
|
|
1015
|
-
if (!
|
|
1016
|
-
const v = Array.from(o.children).indexOf(n), p = Array.from(i.children).indexOf(o),
|
|
1005
|
+
const o = n.parentElement, i = o.parentElement, u = n.closest("table");
|
|
1006
|
+
if (!u) return null;
|
|
1007
|
+
const v = Array.from(o.children).indexOf(n), p = Array.from(i.children).indexOf(o), a = o.children.length, C = i.children.length, h = n.getBoundingClientRect(), c = u.getBoundingClientRect(), x = t.view.dom.closest(".tiptap-editor").getBoundingClientRect();
|
|
1017
1008
|
return {
|
|
1018
1009
|
cell: n,
|
|
1019
1010
|
colIndex: v,
|
|
1020
1011
|
rowIndex: p,
|
|
1021
|
-
totalCols:
|
|
1022
|
-
totalRows:
|
|
1023
|
-
cellRect:
|
|
1024
|
-
tableRect:
|
|
1025
|
-
editorRect:
|
|
1012
|
+
totalCols: a,
|
|
1013
|
+
totalRows: C,
|
|
1014
|
+
cellRect: h,
|
|
1015
|
+
tableRect: c,
|
|
1016
|
+
editorRect: x
|
|
1026
1017
|
};
|
|
1027
1018
|
}
|
|
1028
|
-
function
|
|
1019
|
+
function q(t) {
|
|
1029
1020
|
const {
|
|
1030
1021
|
state: l
|
|
1031
1022
|
} = t, n = l.selection.from;
|
|
1032
1023
|
let o = null;
|
|
1033
|
-
return l.doc.nodesBetween(0, l.doc.content.size, (i,
|
|
1034
|
-
if (i.type.name === "table" &&
|
|
1024
|
+
return l.doc.nodesBetween(0, l.doc.content.size, (i, u) => {
|
|
1025
|
+
if (i.type.name === "table" && u <= n && n <= u + i.nodeSize)
|
|
1035
1026
|
return o = {
|
|
1036
1027
|
node: i,
|
|
1037
|
-
pos:
|
|
1028
|
+
pos: u
|
|
1038
1029
|
}, !1;
|
|
1039
1030
|
}), o;
|
|
1040
1031
|
}
|
|
1041
|
-
const
|
|
1032
|
+
const vt = /* @__PURE__ */ s({
|
|
1042
1033
|
name: "TableControls",
|
|
1043
1034
|
setup() {
|
|
1044
|
-
const t =
|
|
1035
|
+
const t = y("editor"), l = y("readonly"), n = H(null), o = H(null);
|
|
1045
1036
|
function i() {
|
|
1046
|
-
const
|
|
1047
|
-
if (o.value && (o.value.classList.remove("
|
|
1037
|
+
const h = t?.value;
|
|
1038
|
+
if (o.value && (o.value.classList.remove("tiptap-cell-focused"), o.value = null), !h) {
|
|
1048
1039
|
n.value = null;
|
|
1049
1040
|
return;
|
|
1050
1041
|
}
|
|
1051
|
-
const
|
|
1052
|
-
n.value =
|
|
1042
|
+
const c = Ct(h);
|
|
1043
|
+
n.value = c, c && (c.cell.classList.add("tiptap-cell-focused"), o.value = c.cell);
|
|
1053
1044
|
}
|
|
1054
|
-
|
|
1055
|
-
const
|
|
1056
|
-
|
|
1057
|
-
|
|
1045
|
+
K((h) => {
|
|
1046
|
+
const c = t?.value;
|
|
1047
|
+
c && (c.on("selectionUpdate", i), c.on("transaction", i), h(() => {
|
|
1048
|
+
c.off("selectionUpdate", i), c.off("transaction", i), o.value && (o.value.classList.remove("tiptap-cell-focused"), o.value = null);
|
|
1058
1049
|
}));
|
|
1059
1050
|
});
|
|
1060
|
-
function
|
|
1061
|
-
const
|
|
1062
|
-
if (!
|
|
1051
|
+
function u(h) {
|
|
1052
|
+
const c = t?.value;
|
|
1053
|
+
if (!c || !n.value) return;
|
|
1063
1054
|
const {
|
|
1064
|
-
colIndex:
|
|
1055
|
+
colIndex: x,
|
|
1065
1056
|
totalCols: I
|
|
1066
|
-
} = n.value,
|
|
1067
|
-
if (
|
|
1068
|
-
const
|
|
1069
|
-
if (!
|
|
1057
|
+
} = n.value, k = h === "left" ? x - 1 : x + 1;
|
|
1058
|
+
if (k < 0 || k >= I) return;
|
|
1059
|
+
const r = q(c);
|
|
1060
|
+
if (!r) return;
|
|
1070
1061
|
const {
|
|
1071
1062
|
node: d,
|
|
1072
1063
|
pos: f
|
|
1073
|
-
} =
|
|
1074
|
-
d.forEach((
|
|
1075
|
-
if (
|
|
1076
|
-
|
|
1064
|
+
} = r, m = [];
|
|
1065
|
+
d.forEach((E) => {
|
|
1066
|
+
if (E.type.name !== "tableRow") {
|
|
1067
|
+
m.push(E);
|
|
1077
1068
|
return;
|
|
1078
1069
|
}
|
|
1079
1070
|
const A = [];
|
|
1080
|
-
|
|
1081
|
-
const
|
|
1082
|
-
A[
|
|
1071
|
+
E.forEach((S) => A.push(S));
|
|
1072
|
+
const R = A[x];
|
|
1073
|
+
A[x] = A[k], A[k] = R, m.push(E.type.create(E.attrs, A, E.marks));
|
|
1083
1074
|
});
|
|
1084
|
-
const B = d.type.create(d.attrs,
|
|
1085
|
-
|
|
1075
|
+
const B = d.type.create(d.attrs, m, d.marks), V = c.state.tr.replaceWith(f, f + d.nodeSize, B);
|
|
1076
|
+
c.view.dispatch(V);
|
|
1086
1077
|
}
|
|
1087
|
-
function v(
|
|
1088
|
-
const
|
|
1089
|
-
if (!
|
|
1078
|
+
function v(h) {
|
|
1079
|
+
const c = t?.value;
|
|
1080
|
+
if (!c || !n.value) return;
|
|
1090
1081
|
const {
|
|
1091
|
-
rowIndex:
|
|
1082
|
+
rowIndex: x,
|
|
1092
1083
|
totalRows: I
|
|
1093
|
-
} = n.value,
|
|
1094
|
-
if (
|
|
1095
|
-
const
|
|
1096
|
-
if (!
|
|
1084
|
+
} = n.value, k = h === "up" ? x - 1 : x + 1;
|
|
1085
|
+
if (k < 0 || k >= I) return;
|
|
1086
|
+
const r = q(c);
|
|
1087
|
+
if (!r) return;
|
|
1097
1088
|
const {
|
|
1098
1089
|
node: d,
|
|
1099
1090
|
pos: f
|
|
1100
|
-
} =
|
|
1101
|
-
d.forEach((A) =>
|
|
1102
|
-
const B =
|
|
1103
|
-
|
|
1104
|
-
const V = d.type.create(d.attrs,
|
|
1105
|
-
|
|
1091
|
+
} = r, m = [];
|
|
1092
|
+
d.forEach((A) => m.push(A));
|
|
1093
|
+
const B = m[x];
|
|
1094
|
+
m[x] = m[k], m[k] = B;
|
|
1095
|
+
const V = d.type.create(d.attrs, m, d.marks), E = c.state.tr.replaceWith(f, f + d.nodeSize, V);
|
|
1096
|
+
c.view.dispatch(E);
|
|
1106
1097
|
}
|
|
1107
1098
|
const p = () => e("svg", {
|
|
1108
1099
|
width: "16",
|
|
@@ -1121,7 +1112,7 @@ const ft = /* @__PURE__ */ c({
|
|
|
1121
1112
|
cx: "14",
|
|
1122
1113
|
cy: "2",
|
|
1123
1114
|
r: "1.5"
|
|
1124
|
-
}, null)]),
|
|
1115
|
+
}, null)]), a = () => e("svg", {
|
|
1125
1116
|
width: "4",
|
|
1126
1117
|
height: "16",
|
|
1127
1118
|
viewBox: "0 0 4 16",
|
|
@@ -1138,7 +1129,7 @@ const ft = /* @__PURE__ */ c({
|
|
|
1138
1129
|
cx: "2",
|
|
1139
1130
|
cy: "14",
|
|
1140
1131
|
r: "1.5"
|
|
1141
|
-
}, null)]),
|
|
1132
|
+
}, null)]), C = () => e("svg", {
|
|
1142
1133
|
width: "10",
|
|
1143
1134
|
height: "10",
|
|
1144
1135
|
viewBox: "0 0 10 10",
|
|
@@ -1151,128 +1142,128 @@ const ft = /* @__PURE__ */ c({
|
|
|
1151
1142
|
}, null)]);
|
|
1152
1143
|
return () => {
|
|
1153
1144
|
if (l?.value) return null;
|
|
1154
|
-
const
|
|
1155
|
-
if (!
|
|
1145
|
+
const h = n.value;
|
|
1146
|
+
if (!h) return null;
|
|
1156
1147
|
const {
|
|
1157
|
-
colIndex:
|
|
1158
|
-
rowIndex:
|
|
1148
|
+
colIndex: c,
|
|
1149
|
+
rowIndex: x,
|
|
1159
1150
|
totalCols: I,
|
|
1160
|
-
totalRows:
|
|
1161
|
-
cellRect:
|
|
1151
|
+
totalRows: k,
|
|
1152
|
+
cellRect: r,
|
|
1162
1153
|
tableRect: d,
|
|
1163
1154
|
editorRect: f
|
|
1164
|
-
} =
|
|
1155
|
+
} = h, m = d.top - f.top, B = d.left - f.left, V = d.right - f.left, E = d.bottom - f.top, A = r.left - f.left, R = r.top - f.top, S = r.width, z = r.height, ie = {
|
|
1165
1156
|
position: "absolute",
|
|
1166
|
-
top: `${
|
|
1167
|
-
left: `${A +
|
|
1168
|
-
},
|
|
1157
|
+
top: `${m - 20}px`,
|
|
1158
|
+
left: `${A + S / 2 - 18}px`
|
|
1159
|
+
}, ue = {
|
|
1169
1160
|
position: "absolute",
|
|
1170
|
-
top: `${
|
|
1161
|
+
top: `${R + z / 2 - 18}px`,
|
|
1171
1162
|
left: `${B - 20}px`
|
|
1172
|
-
},
|
|
1163
|
+
}, re = {
|
|
1173
1164
|
position: "absolute",
|
|
1174
|
-
top: `${
|
|
1165
|
+
top: `${R + z / 2 - 12}px`,
|
|
1175
1166
|
left: `${V + 6}px`
|
|
1176
1167
|
}, ae = {
|
|
1177
1168
|
position: "absolute",
|
|
1178
|
-
top: `${
|
|
1179
|
-
left: `${A +
|
|
1180
|
-
}, se =
|
|
1169
|
+
top: `${E + 6}px`,
|
|
1170
|
+
left: `${A + S / 2 - 12}px`
|
|
1171
|
+
}, se = c === 0, O = c === I - 1, ce = x === 0, $ = x === k - 1, F = t?.value;
|
|
1181
1172
|
return e("div", {
|
|
1182
|
-
class: "table-
|
|
1183
|
-
}, [e(
|
|
1173
|
+
class: "tiptap-table-controls"
|
|
1174
|
+
}, [e(N, {
|
|
1184
1175
|
trigger: "click",
|
|
1185
1176
|
placement: "bottom",
|
|
1186
1177
|
style: ie,
|
|
1187
1178
|
onCommand: (M) => {
|
|
1188
|
-
M === "move-left" ?
|
|
1179
|
+
M === "move-left" ? u("left") : M === "move-right" ? u("right") : M === "insert-left" ? F?.chain().focus().addColumnBefore().run() : M === "insert-right" ? F?.chain().focus().addColumnAfter().run() : M === "delete" && F?.chain().focus().deleteColumn().run();
|
|
1189
1180
|
}
|
|
1190
1181
|
}, {
|
|
1191
1182
|
default: () => [e("button", {
|
|
1192
|
-
class: "
|
|
1183
|
+
class: "tiptap-table-btn tiptap-table-btn--col"
|
|
1193
1184
|
}, [e(p, null, null)])],
|
|
1194
|
-
dropdown: () => e(
|
|
1195
|
-
default: () => [e(
|
|
1185
|
+
dropdown: () => e(j, null, {
|
|
1186
|
+
default: () => [e(L, {
|
|
1196
1187
|
command: "move-left",
|
|
1197
1188
|
disabled: se
|
|
1198
1189
|
}, {
|
|
1199
|
-
default: () => [
|
|
1200
|
-
}), e(
|
|
1190
|
+
default: () => [g("移动列到左侧")]
|
|
1191
|
+
}), e(L, {
|
|
1201
1192
|
command: "move-right",
|
|
1202
|
-
disabled:
|
|
1193
|
+
disabled: O
|
|
1203
1194
|
}, {
|
|
1204
|
-
default: () => [
|
|
1205
|
-
}), e(
|
|
1195
|
+
default: () => [g("移动列到右侧")]
|
|
1196
|
+
}), e(L, {
|
|
1206
1197
|
command: "insert-left"
|
|
1207
1198
|
}, {
|
|
1208
|
-
default: () => [
|
|
1209
|
-
}), e(
|
|
1199
|
+
default: () => [g("在左侧插入一列")]
|
|
1200
|
+
}), e(L, {
|
|
1210
1201
|
command: "insert-right"
|
|
1211
1202
|
}, {
|
|
1212
|
-
default: () => [
|
|
1213
|
-
}), e(
|
|
1203
|
+
default: () => [g("在右侧插入一列")]
|
|
1204
|
+
}), e(L, {
|
|
1214
1205
|
command: "delete",
|
|
1215
1206
|
divided: !0
|
|
1216
1207
|
}, {
|
|
1217
|
-
default: () => [
|
|
1208
|
+
default: () => [g("删除列")]
|
|
1218
1209
|
})]
|
|
1219
1210
|
})
|
|
1220
|
-
}), e(
|
|
1211
|
+
}), e(N, {
|
|
1221
1212
|
trigger: "click",
|
|
1222
1213
|
placement: "right",
|
|
1223
|
-
style:
|
|
1214
|
+
style: ue,
|
|
1224
1215
|
onCommand: (M) => {
|
|
1225
1216
|
M === "move-up" ? v("up") : M === "move-down" ? v("down") : M === "insert-above" ? F?.chain().focus().addRowBefore().run() : M === "insert-below" ? F?.chain().focus().addRowAfter().run() : M === "delete" && F?.chain().focus().deleteRow().run();
|
|
1226
1217
|
}
|
|
1227
1218
|
}, {
|
|
1228
1219
|
default: () => [e("button", {
|
|
1229
|
-
class: "
|
|
1230
|
-
}, [e(
|
|
1231
|
-
dropdown: () => e(
|
|
1232
|
-
default: () => [e(
|
|
1220
|
+
class: "tiptap-table-btn tiptap-table-btn--row"
|
|
1221
|
+
}, [e(a, null, null)])],
|
|
1222
|
+
dropdown: () => e(j, null, {
|
|
1223
|
+
default: () => [e(L, {
|
|
1233
1224
|
command: "move-up",
|
|
1234
1225
|
disabled: ce
|
|
1235
1226
|
}, {
|
|
1236
|
-
default: () => [
|
|
1237
|
-
}), e(
|
|
1227
|
+
default: () => [g("上移")]
|
|
1228
|
+
}), e(L, {
|
|
1238
1229
|
command: "move-down",
|
|
1239
|
-
disabled:
|
|
1230
|
+
disabled: $
|
|
1240
1231
|
}, {
|
|
1241
|
-
default: () => [
|
|
1242
|
-
}), e(
|
|
1232
|
+
default: () => [g("下移")]
|
|
1233
|
+
}), e(L, {
|
|
1243
1234
|
command: "insert-above"
|
|
1244
1235
|
}, {
|
|
1245
|
-
default: () => [
|
|
1246
|
-
}), e(
|
|
1236
|
+
default: () => [g("在上方插入一行")]
|
|
1237
|
+
}), e(L, {
|
|
1247
1238
|
command: "insert-below"
|
|
1248
1239
|
}, {
|
|
1249
|
-
default: () => [
|
|
1250
|
-
}), e(
|
|
1240
|
+
default: () => [g("在下方插入一行")]
|
|
1241
|
+
}), e(L, {
|
|
1251
1242
|
command: "delete",
|
|
1252
1243
|
divided: !0
|
|
1253
1244
|
}, {
|
|
1254
|
-
default: () => [
|
|
1245
|
+
default: () => [g("删除行")]
|
|
1255
1246
|
})]
|
|
1256
1247
|
})
|
|
1257
|
-
}),
|
|
1258
|
-
class: "
|
|
1259
|
-
style:
|
|
1248
|
+
}), O && e("button", {
|
|
1249
|
+
class: "tiptap-table-btn tiptap-table-btn--add",
|
|
1250
|
+
style: re,
|
|
1260
1251
|
onClick: () => F?.chain().focus().addColumnAfter().run()
|
|
1261
|
-
}, [e(
|
|
1262
|
-
class: "
|
|
1252
|
+
}, [e(C, null, null)]), $ && e("button", {
|
|
1253
|
+
class: "tiptap-table-btn tiptap-table-btn--add",
|
|
1263
1254
|
style: ae,
|
|
1264
1255
|
onClick: () => F?.chain().focus().addRowAfter().run()
|
|
1265
|
-
}, [e(
|
|
1256
|
+
}, [e(C, null, null)])]);
|
|
1266
1257
|
};
|
|
1267
1258
|
}
|
|
1268
|
-
}),
|
|
1259
|
+
}), Qt = {
|
|
1269
1260
|
name: "table",
|
|
1270
1261
|
install: () => ({
|
|
1271
1262
|
extensions: [Se.configure({ resizable: !0 }), Ze, De, Re],
|
|
1272
|
-
controlComponent:
|
|
1263
|
+
controlComponent: vt
|
|
1273
1264
|
}),
|
|
1274
|
-
toolbarComponent:
|
|
1275
|
-
},
|
|
1265
|
+
toolbarComponent: dt
|
|
1266
|
+
}, ft = /* @__PURE__ */ s({
|
|
1276
1267
|
name: "MathIcon",
|
|
1277
1268
|
setup(t, {
|
|
1278
1269
|
attrs: l
|
|
@@ -1290,18 +1281,18 @@ const ft = /* @__PURE__ */ c({
|
|
|
1290
1281
|
fill: "currentColor"
|
|
1291
1282
|
}, null)]);
|
|
1292
1283
|
}
|
|
1293
|
-
}),
|
|
1284
|
+
}), ht = /* @__PURE__ */ s({
|
|
1294
1285
|
name: "MathButton",
|
|
1295
1286
|
setup() {
|
|
1296
|
-
const t =
|
|
1287
|
+
const t = y("editor"), l = y("openMathDialog");
|
|
1297
1288
|
return () => e(w, {
|
|
1298
|
-
icon:
|
|
1289
|
+
icon: ft,
|
|
1299
1290
|
tooltip: "数学公式",
|
|
1300
1291
|
isActive: t?.value?.isActive("inlineMath") || t?.value?.isActive("blockMath"),
|
|
1301
1292
|
onClick: () => l?.()
|
|
1302
1293
|
}, null);
|
|
1303
1294
|
}
|
|
1304
|
-
}),
|
|
1295
|
+
}), mt = /* @__PURE__ */ s({
|
|
1305
1296
|
name: "MathEditDialog",
|
|
1306
1297
|
props: {
|
|
1307
1298
|
visible: {
|
|
@@ -1325,44 +1316,44 @@ const ft = /* @__PURE__ */ c({
|
|
|
1325
1316
|
setup(t, {
|
|
1326
1317
|
emit: l
|
|
1327
1318
|
}) {
|
|
1328
|
-
const n =
|
|
1329
|
-
|
|
1330
|
-
o.value =
|
|
1319
|
+
const n = y("editor"), o = H(""), i = H("inline");
|
|
1320
|
+
_(() => t.latex, (a) => {
|
|
1321
|
+
o.value = a;
|
|
1331
1322
|
}, {
|
|
1332
1323
|
immediate: !0
|
|
1333
|
-
}),
|
|
1334
|
-
i.value =
|
|
1324
|
+
}), _(() => t.type, (a) => {
|
|
1325
|
+
i.value = a;
|
|
1335
1326
|
}, {
|
|
1336
1327
|
immediate: !0
|
|
1337
1328
|
});
|
|
1338
|
-
const
|
|
1329
|
+
const u = T(() => t.pos === null), v = T(() => o.value.trim() ? _e.renderToString(o.value, {
|
|
1339
1330
|
displayMode: i.value === "block",
|
|
1340
1331
|
throwOnError: !1
|
|
1341
1332
|
}) : ""), p = () => {
|
|
1342
|
-
const
|
|
1343
|
-
if (!(!
|
|
1344
|
-
if (
|
|
1345
|
-
i.value === "inline" ?
|
|
1333
|
+
const a = n?.value;
|
|
1334
|
+
if (!(!a || !o.value.trim())) {
|
|
1335
|
+
if (u.value)
|
|
1336
|
+
i.value === "inline" ? a.chain().focus().insertInlineMath({
|
|
1346
1337
|
latex: o.value
|
|
1347
|
-
}).run() :
|
|
1338
|
+
}).run() : a.chain().focus().insertBlockMath({
|
|
1348
1339
|
latex: o.value
|
|
1349
1340
|
}).run();
|
|
1350
1341
|
else if (i.value === t.type)
|
|
1351
|
-
t.type === "inline" ?
|
|
1342
|
+
t.type === "inline" ? a.commands.updateInlineMath({
|
|
1352
1343
|
latex: o.value,
|
|
1353
1344
|
pos: t.pos
|
|
1354
|
-
}) :
|
|
1345
|
+
}) : a.commands.updateBlockMath({
|
|
1355
1346
|
latex: o.value,
|
|
1356
1347
|
pos: t.pos
|
|
1357
1348
|
});
|
|
1358
1349
|
else {
|
|
1359
|
-
const
|
|
1360
|
-
t.type === "inline" ?
|
|
1361
|
-
pos:
|
|
1350
|
+
const C = t.pos;
|
|
1351
|
+
t.type === "inline" ? a.chain().focus().deleteInlineMath({
|
|
1352
|
+
pos: C
|
|
1362
1353
|
}).insertBlockMath({
|
|
1363
1354
|
latex: o.value
|
|
1364
|
-
}).run() :
|
|
1365
|
-
pos:
|
|
1355
|
+
}).run() : a.chain().focus().deleteBlockMath({
|
|
1356
|
+
pos: C
|
|
1366
1357
|
}).insertInlineMath({
|
|
1367
1358
|
latex: o.value
|
|
1368
1359
|
}).run();
|
|
@@ -1370,70 +1361,70 @@ const ft = /* @__PURE__ */ c({
|
|
|
1370
1361
|
l("update:visible", !1);
|
|
1371
1362
|
}
|
|
1372
1363
|
};
|
|
1373
|
-
return () => e(
|
|
1364
|
+
return () => e(ye, {
|
|
1374
1365
|
modelValue: t.visible,
|
|
1375
|
-
title:
|
|
1366
|
+
title: u.value ? "插入数学公式" : "编辑数学公式",
|
|
1376
1367
|
width: "520px",
|
|
1377
|
-
"onUpdate:modelValue": (
|
|
1368
|
+
"onUpdate:modelValue": (a) => l("update:visible", a)
|
|
1378
1369
|
}, {
|
|
1379
1370
|
default: () => [e("div", {
|
|
1380
|
-
class: "math-dialog"
|
|
1381
|
-
}, [e(
|
|
1371
|
+
class: "tiptap-math-dialog"
|
|
1372
|
+
}, [e(Be, {
|
|
1382
1373
|
modelValue: i.value,
|
|
1383
|
-
"onUpdate:modelValue": (
|
|
1384
|
-
i.value =
|
|
1374
|
+
"onUpdate:modelValue": (a) => {
|
|
1375
|
+
i.value = a;
|
|
1385
1376
|
}
|
|
1386
1377
|
}, {
|
|
1387
|
-
default: () => [e(
|
|
1378
|
+
default: () => [e(W, {
|
|
1388
1379
|
value: "inline"
|
|
1389
1380
|
}, {
|
|
1390
|
-
default: () => [
|
|
1391
|
-
}), e(
|
|
1381
|
+
default: () => [g("行内公式")]
|
|
1382
|
+
}), e(W, {
|
|
1392
1383
|
value: "block"
|
|
1393
1384
|
}, {
|
|
1394
|
-
default: () => [
|
|
1385
|
+
default: () => [g("块级公式")]
|
|
1395
1386
|
})]
|
|
1396
|
-
}), e(
|
|
1387
|
+
}), e(J, {
|
|
1397
1388
|
modelValue: o.value,
|
|
1398
1389
|
type: "textarea",
|
|
1399
1390
|
rows: 3,
|
|
1400
1391
|
placeholder: "请输入 LaTeX 公式,例如:E=mc^2",
|
|
1401
|
-
"onUpdate:modelValue": (
|
|
1402
|
-
o.value =
|
|
1392
|
+
"onUpdate:modelValue": (a) => {
|
|
1393
|
+
o.value = a;
|
|
1403
1394
|
}
|
|
1404
1395
|
}, null), e("div", {
|
|
1405
|
-
class: ["math-preview", {
|
|
1406
|
-
"math-preview--empty": !v.value
|
|
1396
|
+
class: ["tiptap-math-preview", {
|
|
1397
|
+
"tiptap-math-preview--empty": !v.value
|
|
1407
1398
|
}]
|
|
1408
1399
|
}, [v.value ? e("div", {
|
|
1409
1400
|
innerHTML: v.value
|
|
1410
1401
|
}, null) : e("span", {
|
|
1411
|
-
class: "math-preview__placeholder"
|
|
1412
|
-
}, [
|
|
1402
|
+
class: "tiptap-math-preview__placeholder"
|
|
1403
|
+
}, [g("预览将在此处显示")])])])],
|
|
1413
1404
|
footer: () => e(de, null, [e(Z, {
|
|
1414
1405
|
onClick: () => l("update:visible", !1)
|
|
1415
1406
|
}, {
|
|
1416
|
-
default: () => [
|
|
1407
|
+
default: () => [g("取消")]
|
|
1417
1408
|
}), e(Z, {
|
|
1418
1409
|
type: "primary",
|
|
1419
1410
|
disabled: !o.value.trim(),
|
|
1420
1411
|
onClick: p
|
|
1421
1412
|
}, {
|
|
1422
|
-
default: () => [
|
|
1413
|
+
default: () => [g("确认")]
|
|
1423
1414
|
})])
|
|
1424
1415
|
});
|
|
1425
1416
|
}
|
|
1426
|
-
}),
|
|
1417
|
+
}), Yt = {
|
|
1427
1418
|
name: "math",
|
|
1428
|
-
toolbarComponent:
|
|
1419
|
+
toolbarComponent: ht,
|
|
1429
1420
|
install(t) {
|
|
1430
|
-
const l =
|
|
1421
|
+
const l = H(!1), n = H(""), o = H(null), i = H("inline"), u = (p = {}) => {
|
|
1431
1422
|
t.readonly.value || (n.value = p.latex ?? "", o.value = p.pos ?? null, i.value = p.type ?? "inline", l.value = !0);
|
|
1432
1423
|
};
|
|
1433
|
-
t.provide("openMathDialog",
|
|
1434
|
-
const v =
|
|
1424
|
+
t.provide("openMathDialog", u);
|
|
1425
|
+
const v = s({
|
|
1435
1426
|
name: "MathEditDialogWrapper",
|
|
1436
|
-
setup: () => () => pe(
|
|
1427
|
+
setup: () => () => pe(mt, {
|
|
1437
1428
|
visible: l.value,
|
|
1438
1429
|
latex: n.value,
|
|
1439
1430
|
pos: o.value,
|
|
@@ -1447,52 +1438,52 @@ const ft = /* @__PURE__ */ c({
|
|
|
1447
1438
|
extensions: [
|
|
1448
1439
|
Ue.configure({
|
|
1449
1440
|
inlineOptions: {
|
|
1450
|
-
onClick: (p,
|
|
1441
|
+
onClick: (p, a) => u({ latex: p.attrs.latex, pos: a, type: "inline" })
|
|
1451
1442
|
},
|
|
1452
1443
|
blockOptions: {
|
|
1453
|
-
onClick: (p,
|
|
1444
|
+
onClick: (p, a) => u({ latex: p.attrs.latex, pos: a, type: "block" })
|
|
1454
1445
|
}
|
|
1455
1446
|
})
|
|
1456
1447
|
],
|
|
1457
1448
|
controlComponent: v
|
|
1458
1449
|
};
|
|
1459
1450
|
}
|
|
1460
|
-
},
|
|
1451
|
+
}, gt = /* @__PURE__ */ s({
|
|
1461
1452
|
name: "ImageUploadView",
|
|
1462
1453
|
props: he,
|
|
1463
1454
|
setup(t) {
|
|
1464
|
-
const l = T(() => t.node.attrs.accept), n = T(() => t.node.attrs.limit), o = T(() => t.node.attrs.maxSize), i =
|
|
1465
|
-
if (o.value > 0 &&
|
|
1455
|
+
const l = T(() => t.node.attrs.accept), n = T(() => t.node.attrs.limit), o = T(() => t.node.attrs.maxSize), i = H([]), u = H(), v = H(!1), p = async (r) => {
|
|
1456
|
+
if (o.value > 0 && r.size > o.value)
|
|
1466
1457
|
return t.extension.options.onError?.(new Error(`文件大小超出限制 ${o.value / 1024 / 1024}MB`)), null;
|
|
1467
1458
|
const d = crypto.randomUUID();
|
|
1468
1459
|
i.value.push({
|
|
1469
1460
|
id: d,
|
|
1470
|
-
file:
|
|
1461
|
+
file: r,
|
|
1471
1462
|
progress: 0,
|
|
1472
1463
|
status: "uploading"
|
|
1473
1464
|
});
|
|
1474
1465
|
try {
|
|
1475
1466
|
const f = t.extension.options.upload;
|
|
1476
1467
|
if (!f) throw new Error("未配置 upload 函数");
|
|
1477
|
-
const
|
|
1478
|
-
if (!
|
|
1468
|
+
const m = await f(r);
|
|
1469
|
+
if (!m) throw new Error("上传失败:未返回 URL");
|
|
1479
1470
|
const B = i.value.find((V) => V.id === d);
|
|
1480
|
-
return B && (B.status = "success", B.progress = 100), t.extension.options.onSuccess?.(
|
|
1471
|
+
return B && (B.status = "success", B.progress = 100), t.extension.options.onSuccess?.(m), m;
|
|
1481
1472
|
} catch (f) {
|
|
1482
|
-
const
|
|
1483
|
-
return
|
|
1473
|
+
const m = i.value.find((B) => B.id === d);
|
|
1474
|
+
return m && (m.status = "error", m.progress = 0), t.extension.options.onError?.(f instanceof Error ? f : new Error("上传失败")), null;
|
|
1484
1475
|
}
|
|
1485
|
-
},
|
|
1486
|
-
if (!
|
|
1487
|
-
if (
|
|
1476
|
+
}, a = async (r) => {
|
|
1477
|
+
if (!r.length) return;
|
|
1478
|
+
if (r.length > n.value) {
|
|
1488
1479
|
t.extension.options.onError?.(new Error(`最多上传 ${n.value} 个文件`));
|
|
1489
1480
|
return;
|
|
1490
1481
|
}
|
|
1491
|
-
const d = (await Promise.all(
|
|
1482
|
+
const d = (await Promise.all(r.map(p))).filter((f) => !!f);
|
|
1492
1483
|
if (d.length > 0) {
|
|
1493
1484
|
const f = t.getPos();
|
|
1494
1485
|
if (typeof f != "number") return;
|
|
1495
|
-
const
|
|
1486
|
+
const m = d.map((B) => ({
|
|
1496
1487
|
type: "image",
|
|
1497
1488
|
attrs: {
|
|
1498
1489
|
src: B
|
|
@@ -1501,74 +1492,74 @@ const ft = /* @__PURE__ */ c({
|
|
|
1501
1492
|
t.editor.chain().focus().deleteRange({
|
|
1502
1493
|
from: f,
|
|
1503
1494
|
to: f + t.node.nodeSize
|
|
1504
|
-
}).insertContentAt(f,
|
|
1495
|
+
}).insertContentAt(f, m).run();
|
|
1505
1496
|
}
|
|
1506
|
-
},
|
|
1507
|
-
i.value.length === 0 &&
|
|
1508
|
-
},
|
|
1509
|
-
const d =
|
|
1510
|
-
d &&
|
|
1511
|
-
},
|
|
1512
|
-
|
|
1513
|
-
},
|
|
1514
|
-
|
|
1515
|
-
}, I = (
|
|
1516
|
-
|
|
1517
|
-
const d = Array.from(
|
|
1518
|
-
d.length &&
|
|
1519
|
-
},
|
|
1520
|
-
i.value = i.value.filter((d) => d.id !==
|
|
1497
|
+
}, C = () => {
|
|
1498
|
+
i.value.length === 0 && u.value && (u.value.value = "", u.value.click());
|
|
1499
|
+
}, h = (r) => {
|
|
1500
|
+
const d = r.target.files;
|
|
1501
|
+
d && a(Array.from(d));
|
|
1502
|
+
}, c = (r) => {
|
|
1503
|
+
r.preventDefault(), v.value = !0;
|
|
1504
|
+
}, x = (r) => {
|
|
1505
|
+
r.currentTarget.contains(r.relatedTarget) || (v.value = !1);
|
|
1506
|
+
}, I = (r) => {
|
|
1507
|
+
r.preventDefault(), v.value = !1;
|
|
1508
|
+
const d = Array.from(r.dataTransfer?.files ?? []);
|
|
1509
|
+
d.length && a(d);
|
|
1510
|
+
}, k = (r) => {
|
|
1511
|
+
i.value = i.value.filter((d) => d.id !== r);
|
|
1521
1512
|
};
|
|
1522
1513
|
return () => e(me, {
|
|
1523
1514
|
class: "tiptap-image-upload"
|
|
1524
1515
|
}, {
|
|
1525
1516
|
default: () => [e("div", {
|
|
1526
|
-
onClick:
|
|
1517
|
+
onClick: C
|
|
1527
1518
|
}, [i.value.length ? e("div", {
|
|
1528
1519
|
class: "tiptap-image-upload-previews"
|
|
1529
|
-
}, [i.value.map((
|
|
1530
|
-
key:
|
|
1520
|
+
}, [i.value.map((r) => e("div", {
|
|
1521
|
+
key: r.id,
|
|
1531
1522
|
class: "tiptap-image-upload-preview"
|
|
1532
|
-
}, [
|
|
1523
|
+
}, [r.status === "uploading" && e("div", {
|
|
1533
1524
|
class: "tiptap-image-upload-progress",
|
|
1534
1525
|
style: {
|
|
1535
|
-
width: `${
|
|
1526
|
+
width: `${r.progress}%`
|
|
1536
1527
|
}
|
|
1537
1528
|
}, null), e("div", {
|
|
1538
1529
|
class: "tiptap-image-upload-preview-content"
|
|
1539
1530
|
}, [e("span", {
|
|
1540
1531
|
class: "tiptap-image-upload-text"
|
|
1541
|
-
}, [
|
|
1532
|
+
}, [r.file.name]), e("span", {
|
|
1542
1533
|
class: "tiptap-image-upload-subtext"
|
|
1543
|
-
}, [
|
|
1534
|
+
}, [r.status === "uploading" ? `${r.progress}%` : r.status === "error" ? "上传失败" : "上传成功"]), e("button", {
|
|
1544
1535
|
class: "tiptap-image-upload-remove",
|
|
1545
1536
|
onClick: (d) => {
|
|
1546
|
-
d.stopPropagation(),
|
|
1537
|
+
d.stopPropagation(), k(r.id);
|
|
1547
1538
|
}
|
|
1548
|
-
}, [
|
|
1539
|
+
}, [g("×")])])]))]) : e("div", {
|
|
1549
1540
|
class: ["tiptap-image-upload-drag-area", {
|
|
1550
1541
|
"drag-active": v.value
|
|
1551
1542
|
}],
|
|
1552
|
-
onDragover:
|
|
1553
|
-
onDragleave:
|
|
1543
|
+
onDragover: c,
|
|
1544
|
+
onDragleave: x,
|
|
1554
1545
|
onDrop: I
|
|
1555
1546
|
}, [e("div", {
|
|
1556
1547
|
class: "tiptap-image-upload-content"
|
|
1557
1548
|
}, [e("span", {
|
|
1558
1549
|
class: "tiptap-image-upload-text"
|
|
1559
|
-
}, [e("em", null, [
|
|
1550
|
+
}, [e("em", null, [g("点击上传")]), g(" 或拖拽图片到此处")]), e("span", {
|
|
1560
1551
|
class: "tiptap-image-upload-subtext"
|
|
1561
|
-
}, [
|
|
1562
|
-
ref:
|
|
1552
|
+
}, [g("最多 "), n.value, g(" 个文件"), o.value ? `,每个不超过 ${o.value / 1024 / 1024}MB` : ""])])]), e("input", {
|
|
1553
|
+
ref: u,
|
|
1563
1554
|
type: "file",
|
|
1564
1555
|
accept: l.value,
|
|
1565
1556
|
multiple: n.value > 1,
|
|
1566
|
-
onChange:
|
|
1567
|
-
onClick: (
|
|
1557
|
+
onChange: h,
|
|
1558
|
+
onClick: (r) => r.stopPropagation()
|
|
1568
1559
|
}, null)])]
|
|
1569
1560
|
});
|
|
1570
1561
|
}
|
|
1571
|
-
}),
|
|
1562
|
+
}), wt = Pe.create({
|
|
1572
1563
|
name: "imageUpload",
|
|
1573
1564
|
group: "block",
|
|
1574
1565
|
draggable: !0,
|
|
@@ -1615,7 +1606,7 @@ const ft = /* @__PURE__ */ c({
|
|
|
1615
1606
|
}, t)];
|
|
1616
1607
|
},
|
|
1617
1608
|
addNodeView() {
|
|
1618
|
-
return ge(
|
|
1609
|
+
return ge(gt);
|
|
1619
1610
|
},
|
|
1620
1611
|
addCommands() {
|
|
1621
1612
|
return {
|
|
@@ -1648,7 +1639,7 @@ const ft = /* @__PURE__ */ c({
|
|
|
1648
1639
|
}
|
|
1649
1640
|
};
|
|
1650
1641
|
}
|
|
1651
|
-
}),
|
|
1642
|
+
}), bt = /* @__PURE__ */ s({
|
|
1652
1643
|
name: "ImagePlusIcon",
|
|
1653
1644
|
setup(t, {
|
|
1654
1645
|
attrs: l
|
|
@@ -1666,17 +1657,17 @@ const ft = /* @__PURE__ */ c({
|
|
|
1666
1657
|
fill: "currentColor"
|
|
1667
1658
|
}, null)]);
|
|
1668
1659
|
}
|
|
1669
|
-
}),
|
|
1660
|
+
}), xt = /* @__PURE__ */ s({
|
|
1670
1661
|
name: "ImageButton",
|
|
1671
1662
|
setup() {
|
|
1672
|
-
const t =
|
|
1663
|
+
const t = y("editor");
|
|
1673
1664
|
return () => e("div", null, [e(w, {
|
|
1674
|
-
icon:
|
|
1665
|
+
icon: bt,
|
|
1675
1666
|
tooltip: "图片",
|
|
1676
1667
|
onClick: () => t?.value?.commands.setImageUploadNode()
|
|
1677
1668
|
}, null)]);
|
|
1678
1669
|
}
|
|
1679
|
-
}),
|
|
1670
|
+
}), kt = [{
|
|
1680
1671
|
value: "left",
|
|
1681
1672
|
title: "居左",
|
|
1682
1673
|
Icon: le
|
|
@@ -1688,8 +1679,8 @@ const ft = /* @__PURE__ */ c({
|
|
|
1688
1679
|
value: "right",
|
|
1689
1680
|
title: "居右",
|
|
1690
1681
|
Icon: oe
|
|
1691
|
-
}],
|
|
1692
|
-
function
|
|
1682
|
+
}], U = (t) => t.preventDefault();
|
|
1683
|
+
function Ht(t) {
|
|
1693
1684
|
if (!t.isActive("image")) return null;
|
|
1694
1685
|
const {
|
|
1695
1686
|
selection: l
|
|
@@ -1707,7 +1698,7 @@ function yt(t) {
|
|
|
1707
1698
|
const l = t.startsWith("data:") ? "image.png" : t.split("/").pop()?.split("?")[0] || "image.png", n = document.createElement("a");
|
|
1708
1699
|
n.href = t, n.download = l, document.body.appendChild(n), n.click(), document.body.removeChild(n);
|
|
1709
1700
|
}
|
|
1710
|
-
const
|
|
1701
|
+
const Bt = () => e("svg", {
|
|
1711
1702
|
width: "16",
|
|
1712
1703
|
height: "16",
|
|
1713
1704
|
viewBox: "0 0 24 24",
|
|
@@ -1725,7 +1716,7 @@ const At = () => e("svg", {
|
|
|
1725
1716
|
y1: "15",
|
|
1726
1717
|
x2: "12",
|
|
1727
1718
|
y2: "3"
|
|
1728
|
-
}, null)]),
|
|
1719
|
+
}, null)]), At = () => e("svg", {
|
|
1729
1720
|
width: "16",
|
|
1730
1721
|
height: "16",
|
|
1731
1722
|
viewBox: "0 0 24 24",
|
|
@@ -1738,7 +1729,7 @@ const At = () => e("svg", {
|
|
|
1738
1729
|
points: "1 4 1 10 7 10"
|
|
1739
1730
|
}, null), e("path", {
|
|
1740
1731
|
d: "M3.51 15a9 9 0 1 0 .49-4.1L1 10"
|
|
1741
|
-
}, null)]),
|
|
1732
|
+
}, null)]), Mt = () => e("svg", {
|
|
1742
1733
|
width: "16",
|
|
1743
1734
|
height: "16",
|
|
1744
1735
|
viewBox: "0 0 24 24",
|
|
@@ -1755,116 +1746,112 @@ const At = () => e("svg", {
|
|
|
1755
1746
|
d: "M10 11v6M14 11v6"
|
|
1756
1747
|
}, null), e("path", {
|
|
1757
1748
|
d: "M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"
|
|
1758
|
-
}, null)]),
|
|
1749
|
+
}, null)]), It = /* @__PURE__ */ s({
|
|
1759
1750
|
name: "ImageControls",
|
|
1760
1751
|
setup() {
|
|
1761
|
-
const t =
|
|
1752
|
+
const t = y("editor"), l = y("readonly"), n = H(null);
|
|
1762
1753
|
function o() {
|
|
1763
1754
|
const i = t?.value;
|
|
1764
1755
|
if (!i) {
|
|
1765
1756
|
n.value = null;
|
|
1766
1757
|
return;
|
|
1767
1758
|
}
|
|
1768
|
-
n.value =
|
|
1759
|
+
n.value = Ht(i);
|
|
1769
1760
|
}
|
|
1770
|
-
return
|
|
1771
|
-
const
|
|
1772
|
-
|
|
1773
|
-
|
|
1761
|
+
return K((i) => {
|
|
1762
|
+
const u = t?.value;
|
|
1763
|
+
u && (u.on("transaction", o), i(() => {
|
|
1764
|
+
u.off("transaction", o);
|
|
1774
1765
|
}));
|
|
1775
1766
|
}), () => {
|
|
1776
1767
|
const i = n.value;
|
|
1777
1768
|
if (!i) return null;
|
|
1778
|
-
const
|
|
1779
|
-
if (!
|
|
1769
|
+
const u = t?.value;
|
|
1770
|
+
if (!u) return null;
|
|
1780
1771
|
const {
|
|
1781
1772
|
pos: v,
|
|
1782
1773
|
nodeSize: p,
|
|
1783
|
-
src:
|
|
1784
|
-
align:
|
|
1785
|
-
} = i,
|
|
1786
|
-
if (!
|
|
1787
|
-
const
|
|
1774
|
+
src: a,
|
|
1775
|
+
align: C
|
|
1776
|
+
} = i, h = l?.value ?? !1, c = u.view.nodeDOM(v);
|
|
1777
|
+
if (!c || !(c instanceof HTMLElement)) return null;
|
|
1778
|
+
const x = c.querySelector("[data-resize-wrapper]") ?? c, I = u.view.dom.closest(".tiptap-editor");
|
|
1788
1779
|
if (!I) return null;
|
|
1789
|
-
const
|
|
1780
|
+
const k = x.getBoundingClientRect(), r = I.getBoundingClientRect(), d = {
|
|
1790
1781
|
position: "absolute",
|
|
1791
|
-
top: `${
|
|
1792
|
-
left: `${
|
|
1782
|
+
top: `${k.top - r.top}px`,
|
|
1783
|
+
left: `${k.left - r.left + k.width / 2}px`,
|
|
1793
1784
|
transform: "translate(-50%, calc(-100% - 8px))",
|
|
1794
1785
|
zIndex: 20
|
|
1795
1786
|
};
|
|
1796
1787
|
return e("div", {
|
|
1797
|
-
class: "image-controls",
|
|
1788
|
+
class: "tiptap-image-controls",
|
|
1798
1789
|
style: d
|
|
1799
|
-
}, [!
|
|
1790
|
+
}, [!h && kt.map(({
|
|
1800
1791
|
value: f,
|
|
1801
|
-
title:
|
|
1792
|
+
title: m,
|
|
1802
1793
|
Icon: B
|
|
1803
1794
|
}) => e("button", {
|
|
1804
1795
|
key: f,
|
|
1805
|
-
class: ["image-controls-btn",
|
|
1806
|
-
title:
|
|
1807
|
-
onMousedown:
|
|
1808
|
-
onClick: () =>
|
|
1796
|
+
class: ["tiptap-image-controls-btn", C === f && "is-active"],
|
|
1797
|
+
title: m,
|
|
1798
|
+
onMousedown: U,
|
|
1799
|
+
onClick: () => u.chain().focus().updateAttributes("image", {
|
|
1809
1800
|
align: f
|
|
1810
1801
|
}).run()
|
|
1811
|
-
}, [e(B, null, null)])), !
|
|
1812
|
-
class: "image-controls-separator"
|
|
1802
|
+
}, [e(B, null, null)])), !h && e("span", {
|
|
1803
|
+
class: "tiptap-image-controls-separator"
|
|
1813
1804
|
}, null), e("button", {
|
|
1814
|
-
class: "image-controls-btn",
|
|
1805
|
+
class: "tiptap-image-controls-btn",
|
|
1815
1806
|
title: "下载",
|
|
1816
|
-
onMousedown:
|
|
1817
|
-
onClick: () => yt(
|
|
1818
|
-
}, [e(
|
|
1819
|
-
class: "image-controls-btn",
|
|
1807
|
+
onMousedown: U,
|
|
1808
|
+
onClick: () => yt(a)
|
|
1809
|
+
}, [e(Bt, null, null)]), !h && e("button", {
|
|
1810
|
+
class: "tiptap-image-controls-btn",
|
|
1820
1811
|
title: "重新上传",
|
|
1821
|
-
onMousedown:
|
|
1822
|
-
onClick: () =>
|
|
1812
|
+
onMousedown: U,
|
|
1813
|
+
onClick: () => u.chain().focus().deleteRange({
|
|
1823
1814
|
from: v,
|
|
1824
1815
|
to: v + p
|
|
1825
1816
|
}).insertContentAt(v, {
|
|
1826
1817
|
type: "imageUpload"
|
|
1827
1818
|
}).run()
|
|
1828
|
-
}, [e(
|
|
1829
|
-
class: "image-controls-btn",
|
|
1819
|
+
}, [e(At, null, null)]), !h && e("button", {
|
|
1820
|
+
class: "tiptap-image-controls-btn",
|
|
1830
1821
|
title: "删除",
|
|
1831
|
-
onMousedown:
|
|
1832
|
-
onClick: () =>
|
|
1822
|
+
onMousedown: U,
|
|
1823
|
+
onClick: () => u.chain().focus().deleteRange({
|
|
1833
1824
|
from: v,
|
|
1834
1825
|
to: v + p
|
|
1835
1826
|
}).run()
|
|
1836
|
-
}, [e(
|
|
1827
|
+
}, [e(Mt, null, null)])]);
|
|
1837
1828
|
};
|
|
1838
1829
|
}
|
|
1839
|
-
})
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
toolbarComponent: kt
|
|
1860
|
-
};
|
|
1861
|
-
}
|
|
1862
|
-
const l1 = {
|
|
1830
|
+
}), e1 = {
|
|
1831
|
+
name: "image",
|
|
1832
|
+
install: (t) => ({
|
|
1833
|
+
extensions: [
|
|
1834
|
+
Ke.configure({
|
|
1835
|
+
allowBase64: !0,
|
|
1836
|
+
resize: {
|
|
1837
|
+
enabled: !0,
|
|
1838
|
+
directions: ["top", "right", "bottom", "left", "top-right", "top-left", "bottom-right", "bottom-left"],
|
|
1839
|
+
minWidth: 50,
|
|
1840
|
+
minHeight: 50,
|
|
1841
|
+
alwaysPreserveAspectRatio: !1
|
|
1842
|
+
}
|
|
1843
|
+
}),
|
|
1844
|
+
wt.configure({ ...t.upload ? { upload: t.upload } : {} })
|
|
1845
|
+
],
|
|
1846
|
+
controlComponent: It
|
|
1847
|
+
}),
|
|
1848
|
+
toolbarComponent: xt
|
|
1849
|
+
}, t1 = {
|
|
1863
1850
|
name: "separator",
|
|
1864
1851
|
install: () => ({
|
|
1865
1852
|
extensions: []
|
|
1866
1853
|
}),
|
|
1867
|
-
toolbarComponent: /* @__PURE__ */
|
|
1854
|
+
toolbarComponent: /* @__PURE__ */ s({
|
|
1868
1855
|
name: "ToolbarSeparator",
|
|
1869
1856
|
setup: () => () => e("div", {
|
|
1870
1857
|
class: "tiptap-separator"
|
|
@@ -1872,16 +1859,16 @@ const l1 = {
|
|
|
1872
1859
|
})
|
|
1873
1860
|
};
|
|
1874
1861
|
export {
|
|
1875
|
-
|
|
1862
|
+
Xt as CodeBlockFeature,
|
|
1876
1863
|
w as IconButton,
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1864
|
+
e1 as ImageFeature,
|
|
1865
|
+
Ke as ImageWithAlign,
|
|
1866
|
+
Jt as ListFeature,
|
|
1867
|
+
Yt as MathFeature,
|
|
1868
|
+
t1 as SeparatorFeature,
|
|
1869
|
+
Qt as TableFeature,
|
|
1870
|
+
Gt as TextAlignFeature,
|
|
1871
|
+
Kt as TextStyleFeature,
|
|
1872
|
+
Wt as TiptapEditor,
|
|
1873
|
+
qt as UndoRedoFeature
|
|
1887
1874
|
};
|