@mario9/tiptap-editor 0.1.3 → 0.1.5

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