@mario9/tiptap-editor 0.1.1 → 0.1.3

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