@mario9/tiptap-editor 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -51,7 +51,7 @@ const content = ref('')
51
51
  SeparatorFeature,
52
52
  TableFeature,
53
53
  MathFeature,
54
- ImageFeature(),
54
+ ImageFeature,
55
55
  ]"
56
56
  />
57
57
  </template>
@@ -63,7 +63,7 @@ const content = ref('')
63
63
  |------|------|--------|------|
64
64
  | `modelValue` | `string` | `''` | 编辑器内容(HTML 格式),支持 `v-model` 双向绑定 |
65
65
  | `placeholder` | `string` | `'请输入内容...'` | 编辑器占位符文本 |
66
- | `readonly` | `boolean` | `false` | 只读模式:隐藏工具栏,禁止编辑 |
66
+ | `upload` | `(file: File) => Promise<string>` | `undefined` | 图片上传函数,传给 `ImageFeature` 使用,不传则默认转为 Base64 |
67
67
  | `features` | `FeaturePlugin[]` | `[]` | 功能插件列表,决定工具栏内容和注册的扩展 |
68
68
 
69
69
  ## Feature Plugins
@@ -77,28 +77,29 @@ const content = ref('')
77
77
  | `CodeBlockFeature` | 代码块(含语法高亮) | `CodeBlockFeature` |
78
78
  | `TableFeature` | 表格(含行列增删、移动) | `TableFeature` |
79
79
  | `MathFeature` | 数学公式(内联 / 块级,基于 KaTeX) | `MathFeature` |
80
- | `ImageFeature` | 图片插入(支持自定义上传,默认 Base64) | `ImageFeature(uploadFn?)` |
80
+ | `ImageFeature` | 图片插入(支持自定义上传,默认 Base64) | `ImageFeature` |
81
81
  | `SeparatorFeature` | 工具栏分隔符 | `SeparatorFeature` |
82
82
 
83
- `ImageFeature` 是工厂函数,接受可选的 `upload` 参数:
83
+ `upload` 通过 `TiptapEditor` 的 `upload` prop 传入,`ImageFeature` 会自动从 context 中读取:
84
+
85
+ ```vue
86
+ <TiptapEditor v-model="content" :upload="myUpload" :features="[..., ImageFeature]" />
87
+ ```
84
88
 
85
89
  ```typescript
86
- import { ImageFeature, type UploadFn } from '@mario9/tiptap-editor'
90
+ import { type UploadFn } from '@mario9/tiptap-editor'
87
91
 
88
- const upload: UploadFn = async (file) => {
92
+ const myUpload: UploadFn = async (file) => {
89
93
  const formData = new FormData()
90
94
  formData.append('file', file)
91
95
  const res = await fetch('/api/upload', { method: 'POST', body: formData })
92
96
  const data = await res.json()
93
97
  return data.url
94
98
  }
95
-
96
- // 不传则默认转为 Base64
97
- ImageFeature()
98
- // 传入自定义上传函数
99
- ImageFeature(upload)
100
99
  ```
101
100
 
101
+ 不传 `upload` 时图片默认转为 Base64。
102
+
102
103
  ## 自定义 Feature Plugin
103
104
 
104
105
  实现 `FeaturePlugin` 接口即可创建自定义功能插件:
@@ -117,7 +118,7 @@ export const MyFeature: FeaturePlugin = {
117
118
  }
118
119
  ```
119
120
 
120
- `install()` 接收 `PluginInstallContext`(含 `readonly` 和 `provide`),返回 `{ extensions, controlComponent? }`。
121
+ `install()` 接收 `PluginInstallContext`(含 `readonly`、`provide`、`upload`),返回 `{ extensions, controlComponent? }`。
121
122
 
122
123
  ## 内置功能(始终启用)
123
124
 
@@ -1,11 +1,11 @@
1
- import { defineComponent as c, createVNode as e, mergeProps as b, inject as H, computed as T, provide as P, watch as R, ref as k, nextTick as z, createTextVNode as m, watchEffect as G, Fragment as de, h as pe } from "vue";
1
+ import { defineComponent as c, createVNode as e, mergeProps as b, inject as H, computed as T, provide as P, watch as R, ref as x, nextTick as z, createTextVNode as m, watchEffect as G, Fragment as de, h as pe } from "vue";
2
2
  import Ce from "@tiptap/starter-kit";
3
3
  import { useEditor as ve, EditorContent as fe, nodeViewProps as he, NodeViewWrapper as me, VueNodeViewRenderer as ge } from "@tiptap/vue-3";
4
4
  import { TaskList as we, TaskItem as be } from "@tiptap/extension-list";
5
- import { TextAlign as xe } from "@tiptap/extension-text-align";
6
- import { Placeholder as ke } from "@tiptap/extension-placeholder";
5
+ import { TextAlign as ke } from "@tiptap/extension-text-align";
6
+ import { Placeholder as xe } from "@tiptap/extension-placeholder";
7
7
  import { BubbleMenu as He } from "@tiptap/vue-3/menus";
8
- import { ElTooltip as D, ElButton as Z, ElPopover as J, ElInput as X, ElDropdown as j, ElDropdownMenu as W, ElDropdownItem as E, ElDialog as Be, ElRadioGroup as ye, ElRadioButton as q } from "element-plus";
8
+ import { ElTooltip as D, ElButton as Z, ElPopover as J, ElInput as X, ElDropdown as j, ElDropdownMenu as W, ElDropdownItem as E, ElDialog as ye, ElRadioGroup as Be, ElRadioButton as q } from "element-plus";
9
9
  import { Image as Ae } from "@tiptap/extension-image";
10
10
  import { Plugin as Me, NodeSelection as Ie } from "@tiptap/pm/state";
11
11
  import { Decoration as Le, DecorationSet as Ee } from "@tiptap/pm/view";
@@ -143,9 +143,9 @@ const Oe = {
143
143
  const {
144
144
  editor: o,
145
145
  from: i,
146
- to: r
146
+ to: u
147
147
  } = n;
148
- return !(i === r || o.isActive("image") || o.isActive("table"));
148
+ return !(i === u || o.isActive("image") || o.isActive("table"));
149
149
  }
150
150
  }, {
151
151
  default: () => [e("div", {
@@ -188,6 +188,10 @@ const Oe = {
188
188
  type: Boolean,
189
189
  default: !1
190
190
  },
191
+ upload: {
192
+ type: Function,
193
+ default: void 0
194
+ },
191
195
  features: {
192
196
  type: Array,
193
197
  default: () => []
@@ -199,11 +203,12 @@ const Oe = {
199
203
  }) {
200
204
  const n = T(() => t.readonly ?? !1);
201
205
  P("readonly", n);
202
- const o = t.features.map((r) => ({
203
- plugin: r,
204
- result: r.install({
206
+ const o = t.features.map((u) => ({
207
+ plugin: u,
208
+ result: u.install({
205
209
  readonly: n,
206
- provide: (v, p) => P(v, p)
210
+ provide: (v, p) => P(v, p),
211
+ upload: t.upload
207
212
  })
208
213
  })), i = ve({
209
214
  content: t.modelValue,
@@ -214,48 +219,48 @@ const Oe = {
214
219
  openOnClick: !1,
215
220
  enableClickSelection: !0
216
221
  }
217
- }), ke.configure({
218
- placeholder: t.placeholder
219
222
  }), xe.configure({
223
+ placeholder: t.placeholder
224
+ }), ke.configure({
220
225
  types: ["heading", "paragraph"]
221
226
  }), we, be.configure({
222
227
  nested: !0
223
228
  }), ...o.flatMap(({
224
- result: r
225
- }) => r.extensions)],
229
+ result: u
230
+ }) => u.extensions)],
226
231
  onUpdate: ({
227
- editor: r
232
+ editor: u
228
233
  }) => {
229
- l("update:modelValue", r.getHTML());
234
+ l("update:modelValue", u.getHTML());
230
235
  }
231
236
  });
232
- return P("editor", i), R(() => t.modelValue, (r) => {
233
- i.value && r !== i.value.getHTML() && i.value.commands.setContent(r, {
237
+ return P("editor", i), R(() => t.modelValue, (u) => {
238
+ i.value && u !== i.value.getHTML() && i.value.commands.setContent(u, {
234
239
  emitUpdate: !1
235
240
  });
236
- }), R(() => t.readonly, (r) => {
237
- i.value?.setEditable(!r);
241
+ }), R(() => t.readonly, (u) => {
242
+ i.value?.setEditable(!u);
238
243
  }), () => e("div", {
239
244
  class: "tiptap-editor"
240
245
  }, [!t.readonly && e("div", {
241
246
  class: "tiptap-toolbar"
242
247
  }, [o.map(({
243
- plugin: r
248
+ plugin: u
244
249
  }) => {
245
- const v = r.toolbarComponent;
250
+ const v = u.toolbarComponent;
246
251
  return v ? e(v, {
247
- key: r.name
252
+ key: u.name
248
253
  }, null) : null;
249
254
  })]), e(fe, {
250
255
  class: "tiptap-content",
251
256
  editor: i.value
252
257
  }, null), e($e, null, null), o.map(({
253
- plugin: r,
258
+ plugin: u,
254
259
  result: v
255
260
  }) => {
256
261
  const p = v.controlComponent;
257
262
  return p ? e(p, {
258
- key: `${r.name}-control`
263
+ key: `${u.name}-control`
259
264
  }, null) : null;
260
265
  })]);
261
266
  }
@@ -435,21 +440,21 @@ const Oe = {
435
440
  }), Qe = /* @__PURE__ */ c({
436
441
  name: "LinkPopover",
437
442
  setup() {
438
- const t = H("editor"), l = k(!1), n = k("");
443
+ const t = H("editor"), l = x(!1), n = x("");
439
444
  let o = !1;
440
- R(() => t?.value?.isActive("link"), (u) => {
441
- o || u && (n.value = t?.value?.getAttributes("link").href ?? "", z(() => {
445
+ R(() => t?.value?.isActive("link"), (r) => {
446
+ o || r && (n.value = t?.value?.getAttributes("link").href ?? "", z(() => {
442
447
  l.value = !0;
443
448
  }));
444
449
  });
445
450
  const i = () => {
446
- const u = t?.value;
447
- if (!u || !n.value) return;
451
+ const r = t?.value;
452
+ if (!r || !n.value) return;
448
453
  o = !0;
449
454
  const {
450
455
  empty: C
451
- } = u.state.selection;
452
- let g = u.chain().focus().extendMarkRange("link").setLink({
456
+ } = r.state.selection;
457
+ let g = r.chain().focus().extendMarkRange("link").setLink({
453
458
  href: n.value
454
459
  });
455
460
  C && (g = g.insertContent({
@@ -458,23 +463,23 @@ const Oe = {
458
463
  })), g.run(), l.value = !1, z(() => {
459
464
  o = !1;
460
465
  });
461
- }, r = () => {
462
- const u = t?.value;
463
- u && (o = !0, u.chain().focus().extendMarkRange("link").unsetLink().run(), n.value = "", l.value = !1, z(() => {
466
+ }, u = () => {
467
+ const r = t?.value;
468
+ r && (o = !0, r.chain().focus().extendMarkRange("link").unsetLink().run(), n.value = "", l.value = !1, z(() => {
464
469
  o = !1;
465
470
  }));
466
471
  }, v = () => {
467
- const u = t?.value?.getAttributes("link").href;
468
- u && window.open(u, "_blank", "noopener,noreferrer");
469
- }, p = (u) => {
470
- u.key === "Enter" && (u.preventDefault(), i());
471
- }, s = (u) => {
472
- u && (n.value = t?.value?.getAttributes("link").href ?? ""), l.value = u;
473
- }, y = (u) => {
474
- n.value = u;
472
+ const r = t?.value?.getAttributes("link").href;
473
+ r && window.open(r, "_blank", "noopener,noreferrer");
474
+ }, p = (r) => {
475
+ r.key === "Enter" && (r.preventDefault(), i());
476
+ }, s = (r) => {
477
+ r && (n.value = t?.value?.getAttributes("link").href ?? ""), l.value = r;
478
+ }, B = (r) => {
479
+ n.value = r;
475
480
  };
476
481
  return () => {
477
- const u = t?.value?.isActive("link") ?? !1;
482
+ const r = t?.value?.isActive("link") ?? !1;
478
483
  return e(J, {
479
484
  visible: l.value,
480
485
  "onUpdate:visible": s,
@@ -489,14 +494,14 @@ const Oe = {
489
494
  tooltip: "链接",
490
495
  icon: Ke,
491
496
  class: ["tiptap-button", {
492
- "is-active": u
497
+ "is-active": r
493
498
  }]
494
499
  }, null)]),
495
500
  default: () => e("div", {
496
501
  class: "link-popover-inner"
497
502
  }, [e(X, {
498
503
  modelValue: n.value,
499
- "onUpdate:modelValue": y,
504
+ "onUpdate:modelValue": B,
500
505
  type: "url",
501
506
  placeholder: "请输入链接...",
502
507
  size: "small",
@@ -523,7 +528,7 @@ const Oe = {
523
528
  default: () => [e(Z, {
524
529
  text: !0,
525
530
  icon: Je,
526
- disabled: !n.value && !u,
531
+ disabled: !n.value && !r,
527
532
  onClick: v
528
533
  }, null)]
529
534
  }), e(D, {
@@ -534,8 +539,8 @@ const Oe = {
534
539
  default: () => [e(Z, {
535
540
  text: !0,
536
541
  icon: Xe,
537
- disabled: !u,
538
- onClick: r
542
+ disabled: !r,
543
+ onClick: u
539
544
  }, null)]
540
545
  })])])
541
546
  });
@@ -870,7 +875,7 @@ const Oe = {
870
875
  name: "list",
871
876
  install: () => ({ extensions: [] }),
872
877
  toolbarComponent: it
873
- }, rt = /* @__PURE__ */ c({
878
+ }, ut = /* @__PURE__ */ c({
874
879
  name: "CodeBlockIcon",
875
880
  setup(t, {
876
881
  attrs: l
@@ -891,12 +896,12 @@ const Oe = {
891
896
  points: "8 6 2 12 8 18"
892
897
  }, null)]);
893
898
  }
894
- }), ut = /* @__PURE__ */ c({
899
+ }), rt = /* @__PURE__ */ c({
895
900
  name: "CodeBlockButton",
896
901
  setup() {
897
902
  const t = H("editor");
898
903
  return () => e(w, {
899
- icon: rt,
904
+ icon: ut,
900
905
  tooltip: "代码块",
901
906
  isActive: t?.value?.isActive("codeBlock"),
902
907
  onClick: () => t?.value?.chain().focus().toggleCodeBlock().run()
@@ -907,7 +912,7 @@ const Oe = {
907
912
  install: () => ({
908
913
  extensions: [Fe.configure({ lowlight: at, defaultLanguage: "plaintext" })]
909
914
  }),
910
- toolbarComponent: ut
915
+ toolbarComponent: rt
911
916
  }, st = /* @__PURE__ */ c({
912
917
  name: "TableIcon",
913
918
  setup(t, {
@@ -929,9 +934,9 @@ const Oe = {
929
934
  }), ct = 8, dt = 8, pt = /* @__PURE__ */ c({
930
935
  name: "TableButton",
931
936
  setup() {
932
- const t = H("editor"), l = k(!1), n = k(0), o = k(0), i = (p, s) => {
937
+ const t = H("editor"), l = x(!1), n = x(0), o = x(0), i = (p, s) => {
933
938
  n.value = p, o.value = s;
934
- }, r = () => {
939
+ }, u = () => {
935
940
  n.value = 0, o.value = 0;
936
941
  }, v = (p, s) => {
937
942
  t?.value?.chain().focus().insertTable({
@@ -970,7 +975,7 @@ const Oe = {
970
975
  class: "table-picker"
971
976
  }, [e("div", {
972
977
  class: "table-picker-grid",
973
- onMouseleave: r
978
+ onMouseleave: u
974
979
  }, [Array.from({
975
980
  length: dt
976
981
  }, (p, s) => e("div", {
@@ -978,13 +983,13 @@ const Oe = {
978
983
  class: "table-picker-row"
979
984
  }, [Array.from({
980
985
  length: ct
981
- }, (y, u) => e("div", {
982
- key: u,
986
+ }, (B, r) => e("div", {
987
+ key: r,
983
988
  class: ["table-picker-cell", {
984
- "is-active": u < n.value && s < o.value
989
+ "is-active": r < n.value && s < o.value
985
990
  }],
986
- onMouseenter: () => i(u + 1, s + 1),
987
- onClick: () => v(u + 1, s + 1)
991
+ onMouseenter: () => i(r + 1, s + 1),
992
+ onClick: () => v(r + 1, s + 1)
988
993
  }, null))]))]), e("div", {
989
994
  class: "table-picker-footer"
990
995
  }, [e("div", {
@@ -1011,16 +1016,16 @@ function vt(t) {
1011
1016
  node: l
1012
1017
  } = t.view.domAtPos(t.state.selection.from), n = Ct(l);
1013
1018
  if (!n) return null;
1014
- const o = n.parentElement, i = o.parentElement, r = n.closest("table");
1015
- if (!r) return null;
1016
- const v = Array.from(o.children).indexOf(n), p = Array.from(i.children).indexOf(o), s = o.children.length, y = i.children.length, u = n.getBoundingClientRect(), C = r.getBoundingClientRect(), g = t.view.dom.closest(".tiptap-editor").getBoundingClientRect();
1019
+ const o = n.parentElement, i = o.parentElement, u = n.closest("table");
1020
+ if (!u) return null;
1021
+ const v = Array.from(o.children).indexOf(n), p = Array.from(i.children).indexOf(o), s = o.children.length, B = i.children.length, r = n.getBoundingClientRect(), C = u.getBoundingClientRect(), g = t.view.dom.closest(".tiptap-editor").getBoundingClientRect();
1017
1022
  return {
1018
1023
  cell: n,
1019
1024
  colIndex: v,
1020
1025
  rowIndex: p,
1021
1026
  totalCols: s,
1022
- totalRows: y,
1023
- cellRect: u,
1027
+ totalRows: B,
1028
+ cellRect: r,
1024
1029
  tableRect: C,
1025
1030
  editorRect: g
1026
1031
  };
@@ -1030,41 +1035,41 @@ function K(t) {
1030
1035
  state: l
1031
1036
  } = t, n = l.selection.from;
1032
1037
  let o = null;
1033
- return l.doc.nodesBetween(0, l.doc.content.size, (i, r) => {
1034
- if (i.type.name === "table" && r <= n && n <= r + i.nodeSize)
1038
+ return l.doc.nodesBetween(0, l.doc.content.size, (i, u) => {
1039
+ if (i.type.name === "table" && u <= n && n <= u + i.nodeSize)
1035
1040
  return o = {
1036
1041
  node: i,
1037
- pos: r
1042
+ pos: u
1038
1043
  }, !1;
1039
1044
  }), o;
1040
1045
  }
1041
1046
  const ft = /* @__PURE__ */ c({
1042
1047
  name: "TableControls",
1043
1048
  setup() {
1044
- const t = H("editor"), l = H("readonly"), n = k(null), o = k(null);
1049
+ const t = H("editor"), l = H("readonly"), n = x(null), o = x(null);
1045
1050
  function i() {
1046
- const u = t?.value;
1047
- if (o.value && (o.value.classList.remove("tcc-cell-focused"), o.value = null), !u) {
1051
+ const r = t?.value;
1052
+ if (o.value && (o.value.classList.remove("tcc-cell-focused"), o.value = null), !r) {
1048
1053
  n.value = null;
1049
1054
  return;
1050
1055
  }
1051
- const C = vt(u);
1056
+ const C = vt(r);
1052
1057
  n.value = C, C && (C.cell.classList.add("tcc-cell-focused"), o.value = C.cell);
1053
1058
  }
1054
- G((u) => {
1059
+ G((r) => {
1055
1060
  const C = t?.value;
1056
- C && (C.on("selectionUpdate", i), C.on("transaction", i), u(() => {
1061
+ C && (C.on("selectionUpdate", i), C.on("transaction", i), r(() => {
1057
1062
  C.off("selectionUpdate", i), C.off("transaction", i), o.value && (o.value.classList.remove("tcc-cell-focused"), o.value = null);
1058
1063
  }));
1059
1064
  });
1060
- function r(u) {
1065
+ function u(r) {
1061
1066
  const C = t?.value;
1062
1067
  if (!C || !n.value) return;
1063
1068
  const {
1064
1069
  colIndex: g,
1065
1070
  totalCols: I
1066
- } = n.value, x = u === "left" ? g - 1 : g + 1;
1067
- if (x < 0 || x >= I) return;
1071
+ } = n.value, k = r === "left" ? g - 1 : g + 1;
1072
+ if (k < 0 || k >= I) return;
1068
1073
  const a = K(C);
1069
1074
  if (!a) return;
1070
1075
  const {
@@ -1079,19 +1084,19 @@ const ft = /* @__PURE__ */ c({
1079
1084
  const A = [];
1080
1085
  L.forEach((U) => A.push(U));
1081
1086
  const S = A[g];
1082
- A[g] = A[x], A[x] = S, h.push(L.type.create(L.attrs, A, L.marks));
1087
+ A[g] = A[k], A[k] = S, h.push(L.type.create(L.attrs, A, L.marks));
1083
1088
  });
1084
- const B = d.type.create(d.attrs, h, d.marks), V = C.state.tr.replaceWith(f, f + d.nodeSize, B);
1089
+ const y = d.type.create(d.attrs, h, d.marks), V = C.state.tr.replaceWith(f, f + d.nodeSize, y);
1085
1090
  C.view.dispatch(V);
1086
1091
  }
1087
- function v(u) {
1092
+ function v(r) {
1088
1093
  const C = t?.value;
1089
1094
  if (!C || !n.value) return;
1090
1095
  const {
1091
1096
  rowIndex: g,
1092
1097
  totalRows: I
1093
- } = n.value, x = u === "up" ? g - 1 : g + 1;
1094
- if (x < 0 || x >= I) return;
1098
+ } = n.value, k = r === "up" ? g - 1 : g + 1;
1099
+ if (k < 0 || k >= I) return;
1095
1100
  const a = K(C);
1096
1101
  if (!a) return;
1097
1102
  const {
@@ -1099,8 +1104,8 @@ const ft = /* @__PURE__ */ c({
1099
1104
  pos: f
1100
1105
  } = a, h = [];
1101
1106
  d.forEach((A) => h.push(A));
1102
- const B = h[g];
1103
- h[g] = h[x], h[x] = B;
1107
+ const y = h[g];
1108
+ h[g] = h[k], h[k] = y;
1104
1109
  const V = d.type.create(d.attrs, h, d.marks), L = C.state.tr.replaceWith(f, f + d.nodeSize, V);
1105
1110
  C.view.dispatch(L);
1106
1111
  }
@@ -1138,7 +1143,7 @@ const ft = /* @__PURE__ */ c({
1138
1143
  cx: "2",
1139
1144
  cy: "14",
1140
1145
  r: "1.5"
1141
- }, null)]), y = () => e("svg", {
1146
+ }, null)]), B = () => e("svg", {
1142
1147
  width: "10",
1143
1148
  height: "10",
1144
1149
  viewBox: "0 0 10 10",
@@ -1151,25 +1156,25 @@ const ft = /* @__PURE__ */ c({
1151
1156
  }, null)]);
1152
1157
  return () => {
1153
1158
  if (l?.value) return null;
1154
- const u = n.value;
1155
- if (!u) return null;
1159
+ const r = n.value;
1160
+ if (!r) return null;
1156
1161
  const {
1157
1162
  colIndex: C,
1158
1163
  rowIndex: g,
1159
1164
  totalCols: I,
1160
- totalRows: x,
1165
+ totalRows: k,
1161
1166
  cellRect: a,
1162
1167
  tableRect: d,
1163
1168
  editorRect: f
1164
- } = u, h = d.top - f.top, B = d.left - f.left, V = d.right - f.left, L = d.bottom - f.top, A = a.left - f.left, S = a.top - f.top, U = a.width, O = a.height, ie = {
1169
+ } = r, h = d.top - f.top, y = d.left - f.left, V = d.right - f.left, L = d.bottom - f.top, A = a.left - f.left, S = a.top - f.top, U = a.width, O = a.height, ie = {
1165
1170
  position: "absolute",
1166
1171
  top: `${h - 20}px`,
1167
1172
  left: `${A + U / 2 - 18}px`
1168
- }, re = {
1173
+ }, ue = {
1169
1174
  position: "absolute",
1170
1175
  top: `${S + O / 2 - 18}px`,
1171
- left: `${B - 20}px`
1172
- }, ue = {
1176
+ left: `${y - 20}px`
1177
+ }, re = {
1173
1178
  position: "absolute",
1174
1179
  top: `${S + O / 2 - 12}px`,
1175
1180
  left: `${V + 6}px`
@@ -1177,7 +1182,7 @@ const ft = /* @__PURE__ */ c({
1177
1182
  position: "absolute",
1178
1183
  top: `${L + 6}px`,
1179
1184
  left: `${A + U / 2 - 12}px`
1180
- }, se = C === 0, $ = C === I - 1, ce = g === 0, N = g === x - 1, F = t?.value;
1185
+ }, se = C === 0, $ = C === I - 1, ce = g === 0, N = g === k - 1, F = t?.value;
1181
1186
  return e("div", {
1182
1187
  class: "table-cell-controls"
1183
1188
  }, [e(j, {
@@ -1185,7 +1190,7 @@ const ft = /* @__PURE__ */ c({
1185
1190
  placement: "bottom",
1186
1191
  style: ie,
1187
1192
  onCommand: (M) => {
1188
- M === "move-left" ? r("left") : M === "move-right" ? r("right") : M === "insert-left" ? F?.chain().focus().addColumnBefore().run() : M === "insert-right" ? F?.chain().focus().addColumnAfter().run() : M === "delete" && F?.chain().focus().deleteColumn().run();
1193
+ M === "move-left" ? u("left") : M === "move-right" ? u("right") : M === "insert-left" ? F?.chain().focus().addColumnBefore().run() : M === "insert-right" ? F?.chain().focus().addColumnAfter().run() : M === "delete" && F?.chain().focus().deleteColumn().run();
1189
1194
  }
1190
1195
  }, {
1191
1196
  default: () => [e("button", {
@@ -1220,7 +1225,7 @@ const ft = /* @__PURE__ */ c({
1220
1225
  }), e(j, {
1221
1226
  trigger: "click",
1222
1227
  placement: "right",
1223
- style: re,
1228
+ style: ue,
1224
1229
  onCommand: (M) => {
1225
1230
  M === "move-up" ? v("up") : M === "move-down" ? v("down") : M === "insert-above" ? F?.chain().focus().addRowBefore().run() : M === "insert-below" ? F?.chain().focus().addRowAfter().run() : M === "delete" && F?.chain().focus().deleteRow().run();
1226
1231
  }
@@ -1256,13 +1261,13 @@ const ft = /* @__PURE__ */ c({
1256
1261
  })
1257
1262
  }), $ && e("button", {
1258
1263
  class: "tcc-btn tcc-btn--add",
1259
- style: ue,
1264
+ style: re,
1260
1265
  onClick: () => F?.chain().focus().addColumnAfter().run()
1261
- }, [e(y, null, null)]), N && e("button", {
1266
+ }, [e(B, null, null)]), N && e("button", {
1262
1267
  class: "tcc-btn tcc-btn--add",
1263
1268
  style: ae,
1264
1269
  onClick: () => F?.chain().focus().addRowAfter().run()
1265
- }, [e(y, null, null)])]);
1270
+ }, [e(B, null, null)])]);
1266
1271
  };
1267
1272
  }
1268
1273
  }), Yt = {
@@ -1325,7 +1330,7 @@ const ft = /* @__PURE__ */ c({
1325
1330
  setup(t, {
1326
1331
  emit: l
1327
1332
  }) {
1328
- const n = H("editor"), o = k(""), i = k("inline");
1333
+ const n = H("editor"), o = x(""), i = x("inline");
1329
1334
  R(() => t.latex, (s) => {
1330
1335
  o.value = s;
1331
1336
  }, {
@@ -1335,13 +1340,13 @@ const ft = /* @__PURE__ */ c({
1335
1340
  }, {
1336
1341
  immediate: !0
1337
1342
  });
1338
- const r = T(() => t.pos === null), v = T(() => o.value.trim() ? _e.renderToString(o.value, {
1343
+ const u = T(() => t.pos === null), v = T(() => o.value.trim() ? _e.renderToString(o.value, {
1339
1344
  displayMode: i.value === "block",
1340
1345
  throwOnError: !1
1341
1346
  }) : ""), p = () => {
1342
1347
  const s = n?.value;
1343
1348
  if (!(!s || !o.value.trim())) {
1344
- if (r.value)
1349
+ if (u.value)
1345
1350
  i.value === "inline" ? s.chain().focus().insertInlineMath({
1346
1351
  latex: o.value
1347
1352
  }).run() : s.chain().focus().insertBlockMath({
@@ -1356,13 +1361,13 @@ const ft = /* @__PURE__ */ c({
1356
1361
  pos: t.pos
1357
1362
  });
1358
1363
  else {
1359
- const y = t.pos;
1364
+ const B = t.pos;
1360
1365
  t.type === "inline" ? s.chain().focus().deleteInlineMath({
1361
- pos: y
1366
+ pos: B
1362
1367
  }).insertBlockMath({
1363
1368
  latex: o.value
1364
1369
  }).run() : s.chain().focus().deleteBlockMath({
1365
- pos: y
1370
+ pos: B
1366
1371
  }).insertInlineMath({
1367
1372
  latex: o.value
1368
1373
  }).run();
@@ -1370,15 +1375,15 @@ const ft = /* @__PURE__ */ c({
1370
1375
  l("update:visible", !1);
1371
1376
  }
1372
1377
  };
1373
- return () => e(Be, {
1378
+ return () => e(ye, {
1374
1379
  modelValue: t.visible,
1375
- title: r.value ? "插入数学公式" : "编辑数学公式",
1380
+ title: u.value ? "插入数学公式" : "编辑数学公式",
1376
1381
  width: "520px",
1377
1382
  "onUpdate:modelValue": (s) => l("update:visible", s)
1378
1383
  }, {
1379
1384
  default: () => [e("div", {
1380
1385
  class: "math-dialog"
1381
- }, [e(ye, {
1386
+ }, [e(Be, {
1382
1387
  modelValue: i.value,
1383
1388
  "onUpdate:modelValue": (s) => {
1384
1389
  i.value = s;
@@ -1427,10 +1432,10 @@ const ft = /* @__PURE__ */ c({
1427
1432
  name: "math",
1428
1433
  toolbarComponent: mt,
1429
1434
  install(t) {
1430
- const l = k(!1), n = k(""), o = k(null), i = k("inline"), r = (p = {}) => {
1435
+ const l = x(!1), n = x(""), o = x(null), i = x("inline"), u = (p = {}) => {
1431
1436
  t.readonly.value || (n.value = p.latex ?? "", o.value = p.pos ?? null, i.value = p.type ?? "inline", l.value = !0);
1432
1437
  };
1433
- t.provide("openMathDialog", r);
1438
+ t.provide("openMathDialog", u);
1434
1439
  const v = c({
1435
1440
  name: "MathEditDialogWrapper",
1436
1441
  setup: () => () => pe(gt, {
@@ -1447,10 +1452,10 @@ const ft = /* @__PURE__ */ c({
1447
1452
  extensions: [
1448
1453
  Ue.configure({
1449
1454
  inlineOptions: {
1450
- onClick: (p, s) => r({ latex: p.attrs.latex, pos: s, type: "inline" })
1455
+ onClick: (p, s) => u({ latex: p.attrs.latex, pos: s, type: "inline" })
1451
1456
  },
1452
1457
  blockOptions: {
1453
- onClick: (p, s) => r({ latex: p.attrs.latex, pos: s, type: "block" })
1458
+ onClick: (p, s) => u({ latex: p.attrs.latex, pos: s, type: "block" })
1454
1459
  }
1455
1460
  })
1456
1461
  ],
@@ -1461,7 +1466,7 @@ const ft = /* @__PURE__ */ c({
1461
1466
  name: "ImageUploadView",
1462
1467
  props: he,
1463
1468
  setup(t) {
1464
- const l = T(() => t.node.attrs.accept), n = T(() => t.node.attrs.limit), o = T(() => t.node.attrs.maxSize), i = k([]), r = k(), v = k(!1), p = async (a) => {
1469
+ const l = T(() => t.node.attrs.accept), n = T(() => t.node.attrs.limit), o = T(() => t.node.attrs.maxSize), i = x([]), u = x(), v = x(!1), p = async (a) => {
1465
1470
  if (o.value > 0 && a.size > o.value)
1466
1471
  return t.extension.options.onError?.(new Error(`文件大小超出限制 ${o.value / 1024 / 1024}MB`)), null;
1467
1472
  const d = crypto.randomUUID();
@@ -1476,10 +1481,10 @@ const ft = /* @__PURE__ */ c({
1476
1481
  if (!f) throw new Error("未配置 upload 函数");
1477
1482
  const h = await f(a);
1478
1483
  if (!h) throw new Error("上传失败:未返回 URL");
1479
- const B = i.value.find((V) => V.id === d);
1480
- return B && (B.status = "success", B.progress = 100), t.extension.options.onSuccess?.(h), h;
1484
+ const y = i.value.find((V) => V.id === d);
1485
+ return y && (y.status = "success", y.progress = 100), t.extension.options.onSuccess?.(h), h;
1481
1486
  } catch (f) {
1482
- const h = i.value.find((B) => B.id === d);
1487
+ const h = i.value.find((y) => y.id === d);
1483
1488
  return h && (h.status = "error", h.progress = 0), t.extension.options.onError?.(f instanceof Error ? f : new Error("上传失败")), null;
1484
1489
  }
1485
1490
  }, s = async (a) => {
@@ -1492,10 +1497,10 @@ const ft = /* @__PURE__ */ c({
1492
1497
  if (d.length > 0) {
1493
1498
  const f = t.getPos();
1494
1499
  if (typeof f != "number") return;
1495
- const h = d.map((B) => ({
1500
+ const h = d.map((y) => ({
1496
1501
  type: "image",
1497
1502
  attrs: {
1498
- src: B
1503
+ src: y
1499
1504
  }
1500
1505
  }));
1501
1506
  t.editor.chain().focus().deleteRange({
@@ -1503,9 +1508,9 @@ const ft = /* @__PURE__ */ c({
1503
1508
  to: f + t.node.nodeSize
1504
1509
  }).insertContentAt(f, h).run();
1505
1510
  }
1506
- }, y = () => {
1507
- i.value.length === 0 && r.value && (r.value.value = "", r.value.click());
1508
- }, u = (a) => {
1511
+ }, B = () => {
1512
+ i.value.length === 0 && u.value && (u.value.value = "", u.value.click());
1513
+ }, r = (a) => {
1509
1514
  const d = a.target.files;
1510
1515
  d && s(Array.from(d));
1511
1516
  }, C = (a) => {
@@ -1516,14 +1521,14 @@ const ft = /* @__PURE__ */ c({
1516
1521
  a.preventDefault(), v.value = !1;
1517
1522
  const d = Array.from(a.dataTransfer?.files ?? []);
1518
1523
  d.length && s(d);
1519
- }, x = (a) => {
1524
+ }, k = (a) => {
1520
1525
  i.value = i.value.filter((d) => d.id !== a);
1521
1526
  };
1522
1527
  return () => e(me, {
1523
1528
  class: "tiptap-image-upload"
1524
1529
  }, {
1525
1530
  default: () => [e("div", {
1526
- onClick: y
1531
+ onClick: B
1527
1532
  }, [i.value.length ? e("div", {
1528
1533
  class: "tiptap-image-upload-previews"
1529
1534
  }, [i.value.map((a) => e("div", {
@@ -1543,7 +1548,7 @@ const ft = /* @__PURE__ */ c({
1543
1548
  }, [a.status === "uploading" ? `${a.progress}%` : a.status === "error" ? "上传失败" : "上传成功"]), e("button", {
1544
1549
  class: "tiptap-image-upload-remove",
1545
1550
  onClick: (d) => {
1546
- d.stopPropagation(), x(a.id);
1551
+ d.stopPropagation(), k(a.id);
1547
1552
  }
1548
1553
  }, [m("×")])])]))]) : e("div", {
1549
1554
  class: ["tiptap-image-upload-drag-area", {
@@ -1559,11 +1564,11 @@ const ft = /* @__PURE__ */ c({
1559
1564
  }, [e("em", null, [m("点击上传")]), m(" 或拖拽图片到此处")]), e("span", {
1560
1565
  class: "tiptap-image-upload-subtext"
1561
1566
  }, [m("最多 "), n.value, m(" 个文件"), o.value ? `,每个不超过 ${o.value / 1024 / 1024}MB` : ""])])]), e("input", {
1562
- ref: r,
1567
+ ref: u,
1563
1568
  type: "file",
1564
1569
  accept: l.value,
1565
1570
  multiple: n.value > 1,
1566
- onChange: u,
1571
+ onChange: r,
1567
1572
  onClick: (a) => a.stopPropagation()
1568
1573
  }, null)])]
1569
1574
  });
@@ -1648,7 +1653,7 @@ const ft = /* @__PURE__ */ c({
1648
1653
  }
1649
1654
  };
1650
1655
  }
1651
- }), xt = /* @__PURE__ */ c({
1656
+ }), kt = /* @__PURE__ */ c({
1652
1657
  name: "ImagePlusIcon",
1653
1658
  setup(t, {
1654
1659
  attrs: l
@@ -1666,12 +1671,12 @@ const ft = /* @__PURE__ */ c({
1666
1671
  fill: "currentColor"
1667
1672
  }, null)]);
1668
1673
  }
1669
- }), kt = /* @__PURE__ */ c({
1674
+ }), xt = /* @__PURE__ */ c({
1670
1675
  name: "ImageButton",
1671
1676
  setup() {
1672
1677
  const t = H("editor");
1673
1678
  return () => e("div", null, [e(w, {
1674
- icon: xt,
1679
+ icon: kt,
1675
1680
  tooltip: "图片",
1676
1681
  onClick: () => t?.value?.commands.setImageUploadNode()
1677
1682
  }, null)]);
@@ -1689,7 +1694,7 @@ const ft = /* @__PURE__ */ c({
1689
1694
  title: "居右",
1690
1695
  Icon: oe
1691
1696
  }], _ = (t) => t.preventDefault();
1692
- function Bt(t) {
1697
+ function yt(t) {
1693
1698
  if (!t.isActive("image")) return null;
1694
1699
  const {
1695
1700
  selection: l
@@ -1703,7 +1708,7 @@ function Bt(t) {
1703
1708
  align: n.attrs.align ?? "left"
1704
1709
  };
1705
1710
  }
1706
- function yt(t) {
1711
+ function Bt(t) {
1707
1712
  const l = t.startsWith("data:") ? "image.png" : t.split("/").pop()?.split("?")[0] || "image.png", n = document.createElement("a");
1708
1713
  n.href = t, n.download = l, document.body.appendChild(n), n.click(), document.body.removeChild(n);
1709
1714
  }
@@ -1758,108 +1763,104 @@ const At = () => e("svg", {
1758
1763
  }, null)]), Lt = /* @__PURE__ */ c({
1759
1764
  name: "ImageControls",
1760
1765
  setup() {
1761
- const t = H("editor"), l = H("readonly"), n = k(null);
1766
+ const t = H("editor"), l = H("readonly"), n = x(null);
1762
1767
  function o() {
1763
1768
  const i = t?.value;
1764
1769
  if (!i) {
1765
1770
  n.value = null;
1766
1771
  return;
1767
1772
  }
1768
- n.value = Bt(i);
1773
+ n.value = yt(i);
1769
1774
  }
1770
1775
  return G((i) => {
1771
- const r = t?.value;
1772
- r && (r.on("transaction", o), i(() => {
1773
- r.off("transaction", o);
1776
+ const u = t?.value;
1777
+ u && (u.on("transaction", o), i(() => {
1778
+ u.off("transaction", o);
1774
1779
  }));
1775
1780
  }), () => {
1776
1781
  const i = n.value;
1777
1782
  if (!i) return null;
1778
- const r = t?.value;
1779
- if (!r) return null;
1783
+ const u = t?.value;
1784
+ if (!u) return null;
1780
1785
  const {
1781
1786
  pos: v,
1782
1787
  nodeSize: p,
1783
1788
  src: s,
1784
- align: y
1785
- } = i, u = l?.value ?? !1, C = r.view.nodeDOM(v);
1789
+ align: B
1790
+ } = i, r = l?.value ?? !1, C = u.view.nodeDOM(v);
1786
1791
  if (!C || !(C instanceof HTMLElement)) return null;
1787
- const g = C.querySelector("[data-resize-wrapper]") ?? C, I = r.view.dom.closest(".tiptap-editor");
1792
+ const g = C.querySelector("[data-resize-wrapper]") ?? C, I = u.view.dom.closest(".tiptap-editor");
1788
1793
  if (!I) return null;
1789
- const x = g.getBoundingClientRect(), a = I.getBoundingClientRect(), d = {
1794
+ const k = g.getBoundingClientRect(), a = I.getBoundingClientRect(), d = {
1790
1795
  position: "absolute",
1791
- top: `${x.top - a.top}px`,
1792
- left: `${x.left - a.left + x.width / 2}px`,
1796
+ top: `${k.top - a.top}px`,
1797
+ left: `${k.left - a.left + k.width / 2}px`,
1793
1798
  transform: "translate(-50%, calc(-100% - 8px))",
1794
1799
  zIndex: 20
1795
1800
  };
1796
1801
  return e("div", {
1797
1802
  class: "image-controls",
1798
1803
  style: d
1799
- }, [!u && Ht.map(({
1804
+ }, [!r && Ht.map(({
1800
1805
  value: f,
1801
1806
  title: h,
1802
- Icon: B
1807
+ Icon: y
1803
1808
  }) => e("button", {
1804
1809
  key: f,
1805
- class: ["image-controls-btn", y === f && "is-active"],
1810
+ class: ["image-controls-btn", B === f && "is-active"],
1806
1811
  title: h,
1807
1812
  onMousedown: _,
1808
- onClick: () => r.chain().focus().updateAttributes("image", {
1813
+ onClick: () => u.chain().focus().updateAttributes("image", {
1809
1814
  align: f
1810
1815
  }).run()
1811
- }, [e(B, null, null)])), !u && e("span", {
1816
+ }, [e(y, null, null)])), !r && e("span", {
1812
1817
  class: "image-controls-separator"
1813
1818
  }, null), e("button", {
1814
1819
  class: "image-controls-btn",
1815
1820
  title: "下载",
1816
1821
  onMousedown: _,
1817
- onClick: () => yt(s)
1818
- }, [e(At, null, null)]), !u && e("button", {
1822
+ onClick: () => Bt(s)
1823
+ }, [e(At, null, null)]), !r && e("button", {
1819
1824
  class: "image-controls-btn",
1820
1825
  title: "重新上传",
1821
1826
  onMousedown: _,
1822
- onClick: () => r.chain().focus().deleteRange({
1827
+ onClick: () => u.chain().focus().deleteRange({
1823
1828
  from: v,
1824
1829
  to: v + p
1825
1830
  }).insertContentAt(v, {
1826
1831
  type: "imageUpload"
1827
1832
  }).run()
1828
- }, [e(Mt, null, null)]), !u && e("button", {
1833
+ }, [e(Mt, null, null)]), !r && e("button", {
1829
1834
  class: "image-controls-btn",
1830
1835
  title: "删除",
1831
1836
  onMousedown: _,
1832
- onClick: () => r.chain().focus().deleteRange({
1837
+ onClick: () => u.chain().focus().deleteRange({
1833
1838
  from: v,
1834
1839
  to: v + p
1835
1840
  }).run()
1836
1841
  }, [e(It, null, null)])]);
1837
1842
  };
1838
1843
  }
1839
- });
1840
- function t1(t) {
1841
- return {
1842
- name: "image",
1843
- install: () => ({
1844
- extensions: [
1845
- Ne.configure({
1846
- allowBase64: !0,
1847
- resize: {
1848
- enabled: !0,
1849
- directions: ["top", "right", "bottom", "left", "top-right", "top-left", "bottom-right", "bottom-left"],
1850
- minWidth: 50,
1851
- minHeight: 50,
1852
- alwaysPreserveAspectRatio: !1
1853
- }
1854
- }),
1855
- bt.configure({ ...t ? { upload: t } : {} })
1856
- ],
1857
- controlComponent: Lt
1858
- }),
1859
- toolbarComponent: kt
1860
- };
1861
- }
1862
- const l1 = {
1844
+ }), t1 = {
1845
+ name: "image",
1846
+ install: (t) => ({
1847
+ extensions: [
1848
+ Ne.configure({
1849
+ allowBase64: !0,
1850
+ resize: {
1851
+ enabled: !0,
1852
+ directions: ["top", "right", "bottom", "left", "top-right", "top-left", "bottom-right", "bottom-left"],
1853
+ minWidth: 50,
1854
+ minHeight: 50,
1855
+ alwaysPreserveAspectRatio: !1
1856
+ }
1857
+ }),
1858
+ bt.configure({ ...t.upload ? { upload: t.upload } : {} })
1859
+ ],
1860
+ controlComponent: Lt
1861
+ }),
1862
+ toolbarComponent: xt
1863
+ }, l1 = {
1863
1864
  name: "separator",
1864
1865
  install: () => ({
1865
1866
  extensions: []
@@ -1 +1 @@
1
- (function(u,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("@tiptap/starter-kit"),require("@tiptap/vue-3"),require("@tiptap/extension-list"),require("@tiptap/extension-text-align"),require("@tiptap/extension-placeholder"),require("@tiptap/vue-3/menus"),require("element-plus"),require("@tiptap/extension-image"),require("@tiptap/pm/state"),require("@tiptap/pm/view"),require("@tiptap/extension-code-block-lowlight"),require("lowlight"),require("@tiptap/extension-table"),require("@tiptap/extension-mathematics"),require("katex"),require("@tiptap/core")):typeof define=="function"&&define.amd?define(["exports","vue","@tiptap/starter-kit","@tiptap/vue-3","@tiptap/extension-list","@tiptap/extension-text-align","@tiptap/extension-placeholder","@tiptap/vue-3/menus","element-plus","@tiptap/extension-image","@tiptap/pm/state","@tiptap/pm/view","@tiptap/extension-code-block-lowlight","lowlight","@tiptap/extension-table","@tiptap/extension-mathematics","katex","@tiptap/core"],e):(u=typeof globalThis<"u"?globalThis:u||self,e(u.TiptapEditor={},u.Vue,u.StarterKit,u.vue3,u.extensionList,u.extensionTextAlign,u.extensionPlaceholder,u.menus,u.ElementPlus,u.extensionImage,u.state,u.view,u.extensionCodeBlockLowlight,u.lowlight$1,u.extensionTable,u.extensionMathematics,u.katex,u.core))})(this,(function(u,e,X,E,F,Q,Y,ee,p,te,D,R,oe,Z,M,ne,le,S){"use strict";const re={icon:{type:Object,required:!0},tooltip:{type:String,required:!0},isActive:{type:Boolean},disabled:{type:Boolean,default:!1},onClick:{type:Function}},V=e.defineComponent({name:"IconButton",props:re,setup(t){return()=>e.createVNode(p.ElTooltip,{showArrow:!1,offset:6,content:t.tooltip},{default:()=>[e.createVNode(p.ElButton,{text:!0,icon:t.icon,class:["tiptap-button",{"is-active":t.isActive}],disabled:t.disabled,onClick:t.onClick},null)]})}}),U=e.defineComponent({name:"BoldIcon",setup(t,{attrs:o}){return()=>e.createVNode("svg",e.mergeProps({width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},o),[e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M6 2.5C5.17157 2.5 4.5 3.17157 4.5 4V20C4.5 20.8284 5.17157 21.5 6 21.5H15C16.4587 21.5 17.8576 20.9205 18.8891 19.8891C19.9205 18.8576 20.5 17.4587 20.5 16C20.5 14.5413 19.9205 13.1424 18.8891 12.1109C18.6781 11.9 18.4518 11.7079 18.2128 11.5359C19.041 10.5492 19.5 9.29829 19.5 8C19.5 6.54131 18.9205 5.14236 17.8891 4.11091C16.8576 3.07946 15.4587 2.5 14 2.5H6ZM14 10.5C14.663 10.5 15.2989 10.2366 15.7678 9.76777C16.2366 9.29893 16.5 8.66304 16.5 8C16.5 7.33696 16.2366 6.70107 15.7678 6.23223C15.2989 5.76339 14.663 5.5 14 5.5H7.5V10.5H14ZM7.5 18.5V13.5H15C15.663 13.5 16.2989 13.7634 16.7678 14.2322C17.2366 14.7011 17.5 15.337 17.5 16C17.5 16.663 17.2366 17.2989 16.7678 17.7678C16.2989 18.2366 15.663 18.5 15 18.5H7.5Z",fill:"currentColor"},null)])}}),j=e.defineComponent({name:"ItalicIcon",setup(t,{attrs:o}){return()=>e.createVNode("svg",e.mergeProps({width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},o),[e.createVNode("path",{d:"M15.0222 3H19C19.5523 3 20 3.44772 20 4C20 4.55228 19.5523 5 19 5H15.693L10.443 19H14C14.5523 19 15 19.4477 15 20C15 20.5523 14.5523 21 14 21H9.02418C9.00802 21.0004 8.99181 21.0004 8.97557 21H5C4.44772 21 4 20.5523 4 20C4 19.4477 4.44772 19 5 19H8.30704L13.557 5H10C9.44772 5 9 4.55228 9 4C9 3.44772 9.44772 3 10 3H14.9782C14.9928 2.99968 15.0075 2.99967 15.0222 3Z",fill:"currentColor"},null)])}}),_=e.defineComponent({name:"StrikeIcon",setup(t,{attrs:o}){return()=>e.createVNode("svg",e.mergeProps({width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},o),[e.createVNode("path",{d:"M9.00039 3H16.0001C16.5524 3 17.0001 3.44772 17.0001 4C17.0001 4.55229 16.5524 5 16.0001 5H9.00011C8.68006 4.99983 8.36412 5.07648 8.07983 5.22349C7.79555 5.37051 7.55069 5.5836 7.36585 5.84487C7.181 6.10614 7.06155 6.40796 7.01754 6.72497C6.97352 7.04198 7.00623 7.36492 7.11292 7.66667C7.29701 8.18737 7.02414 8.75872 6.50344 8.94281C5.98274 9.1269 5.4114 8.85403 5.2273 8.33333C5.01393 7.72984 4.94851 7.08396 5.03654 6.44994C5.12456 5.81592 5.36346 5.21229 5.73316 4.68974C6.10285 4.1672 6.59256 3.74101 7.16113 3.44698C7.72955 3.15303 8.36047 2.99975 9.00039 3Z",fill:"currentColor"},null),e.createVNode("path",{d:"M18 13H20C20.5523 13 21 12.5523 21 12C21 11.4477 20.5523 11 20 11H4C3.44772 11 3 11.4477 3 12C3 12.5523 3.44772 13 4 13H14C14.7956 13 15.5587 13.3161 16.1213 13.8787C16.6839 14.4413 17 15.2044 17 16C17 16.7956 16.6839 17.5587 16.1213 18.1213C15.5587 18.6839 14.7956 19 14 19H6C5.44772 19 5 19.4477 5 20C5 20.5523 5.44772 21 6 21H14C15.3261 21 16.5979 20.4732 17.5355 19.5355C18.4732 18.5979 19 17.3261 19 16C19 14.9119 18.6453 13.8604 18 13Z",fill:"currentColor"},null)])}}),q=e.defineComponent({name:"UnderlineIcon",setup(t,{attrs:o}){return()=>e.createVNode("svg",e.mergeProps({width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},o),[e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M7 4C7 3.44772 6.55228 3 6 3C5.44772 3 5 3.44772 5 4V10C5 11.8565 5.7375 13.637 7.05025 14.9497C8.36301 16.2625 10.1435 17 12 17C13.8565 17 15.637 16.2625 16.9497 14.9497C18.2625 13.637 19 11.8565 19 10V4C19 3.44772 18.5523 3 18 3C17.4477 3 17 3.44772 17 4V10C17 11.3261 16.4732 12.5979 15.5355 13.5355C14.5979 14.4732 13.3261 15 12 15C10.6739 15 9.40215 14.4732 8.46447 13.5355C7.52678 12.5979 7 11.3261 7 10V4ZM4 19C3.44772 19 3 19.4477 3 20C3 20.5523 3.44772 21 4 21H20C20.5523 21 21 20.5523 21 20C21 19.4477 20.5523 19 20 19H4Z",fill:"currentColor"},null)])}}),ae=e.defineComponent({name:"BubbleMenuBar",setup(){const t=e.inject("editor"),o=e.inject("readonly");return()=>t?.value?e.createVNode(ee.BubbleMenu,{editor:t.value,class:"bubble-menu",options:{placement:"top",offset:{mainAxis:8}},shouldShow:n=>{if(o?.value)return!1;const{editor:l,from:r,to:a}=n;return!(r===a||l.isActive("image")||l.isActive("table"))}},{default:()=>[e.createVNode("div",{class:"bubble-menu-content"},[e.createVNode(V,{icon:U,tooltip:"粗体",isActive:t.value.isActive("bold"),onClick:()=>t.value?.chain().focus().toggleBold().run()},null),e.createVNode(V,{icon:j,tooltip:"斜体",isActive:t.value.isActive("italic"),onClick:()=>t.value?.chain().focus().toggleItalic().run()},null),e.createVNode(V,{icon:_,tooltip:"删除线",isActive:t.value.isActive("strike"),onClick:()=>t.value?.chain().focus().toggleStrike().run()},null),e.createVNode(V,{icon:q,tooltip:"下划线",isActive:t.value.isActive("underline"),onClick:()=>t.value?.chain().focus().toggleUnderline().run()},null)])]}):null}}),ie=e.defineComponent({name:"TiptapEditor",props:{modelValue:{type:String,default:""},placeholder:{type:String,default:"请输入内容..."},readonly:{type:Boolean,default:!1},features:{type:Array,default:()=>[]}},emits:["update:modelValue"],setup(t,{emit:o}){const n=e.computed(()=>t.readonly??!1);e.provide("readonly",n);const l=t.features.map(a=>({plugin:a,result:a.install({readonly:n,provide:(m,C)=>e.provide(m,C)})})),r=E.useEditor({content:t.modelValue,editable:!t.readonly,extensions:[X.configure({codeBlock:!1,link:{openOnClick:!1,enableClickSelection:!0}}),Y.Placeholder.configure({placeholder:t.placeholder}),Q.TextAlign.configure({types:["heading","paragraph"]}),F.TaskList,F.TaskItem.configure({nested:!0}),...l.flatMap(({result:a})=>a.extensions)],onUpdate:({editor:a})=>{o("update:modelValue",a.getHTML())}});return e.provide("editor",r),e.watch(()=>t.modelValue,a=>{r.value&&a!==r.value.getHTML()&&r.value.commands.setContent(a,{emitUpdate:!1})}),e.watch(()=>t.readonly,a=>{r.value?.setEditable(!a)}),()=>e.createVNode("div",{class:"tiptap-editor"},[!t.readonly&&e.createVNode("div",{class:"tiptap-toolbar"},[l.map(({plugin:a})=>{const m=a.toolbarComponent;return m?e.createVNode(m,{key:a.name},null):null})]),e.createVNode(E.EditorContent,{class:"tiptap-content",editor:r.value},null),e.createVNode(ae,null,null),l.map(({plugin:a,result:m})=>{const C=m.controlComponent;return C?e.createVNode(C,{key:`${a.name}-control`},null):null})])}}),O=te.Image.extend({addAttributes(){return{...this.parent?.(),align:{default:"left",parseHTML:t=>t.getAttribute("data-align")??"left",renderHTML:t=>({"data-align":t.align})}}},addProseMirrorPlugins(){const t=this.name;return[new D.Plugin({props:{decorations(o){const n=[];return o.doc.descendants((l,r)=>{l.type.name===t&&l.attrs.align&&n.push(R.Decoration.node(r,r+l.nodeSize,{"data-align":l.attrs.align}))}),R.DecorationSet.create(o.doc,n)}}})]}}),ce=e.defineComponent({name:"UndoIcon",setup(t,{attrs:o}){return()=>e.createVNode("svg",e.mergeProps({width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},o),[e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M9.70711 3.70711C10.0976 3.31658 10.0976 2.68342 9.70711 2.29289C9.31658 1.90237 8.68342 1.90237 8.29289 2.29289L3.29289 7.29289C2.90237 7.68342 2.90237 8.31658 3.29289 8.70711L8.29289 13.7071C8.68342 14.0976 9.31658 14.0976 9.70711 13.7071C10.0976 13.3166 10.0976 12.6834 9.70711 12.2929L6.41421 9H14.5C15.0909 9 15.6761 9.1164 16.2221 9.34254C16.768 9.56869 17.2641 9.90016 17.682 10.318C18.0998 10.7359 18.4313 11.232 18.6575 11.7779C18.8836 12.3239 19 12.9091 19 13.5C19 14.0909 18.8836 14.6761 18.6575 15.2221C18.4313 15.768 18.0998 16.2641 17.682 16.682C17.2641 17.0998 16.768 17.4313 16.2221 17.6575C15.6761 17.8836 15.0909 18 14.5 18H11C10.4477 18 10 18.4477 10 19C10 19.5523 10.4477 20 11 20H14.5C15.3536 20 16.1988 19.8319 16.9874 19.5052C17.7761 19.1786 18.4926 18.6998 19.0962 18.0962C19.6998 17.4926 20.1786 16.7761 20.5052 15.9874C20.8319 15.1988 21 14.3536 21 13.5C21 12.6464 20.8319 11.8012 20.5052 11.0126C20.1786 10.2239 19.6998 9.50739 19.0962 8.90381C18.4926 8.30022 17.7761 7.82144 16.9874 7.49478C16.1988 7.16813 15.3536 7 14.5 7H6.41421L9.70711 3.70711Z",fill:"currentColor"},null)])}}),de=e.defineComponent({name:"RedoIcon",setup(t,{attrs:o}){return()=>e.createVNode("svg",e.mergeProps({width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},o),[e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M15.7071 2.29289C15.3166 1.90237 14.6834 1.90237 14.2929 2.29289C13.9024 2.68342 13.9024 3.31658 14.2929 3.70711L17.5858 7H9.5C7.77609 7 6.12279 7.68482 4.90381 8.90381C3.68482 10.1228 3 11.7761 3 13.5C3 14.3536 3.16813 15.1988 3.49478 15.9874C3.82144 16.7761 4.30023 17.4926 4.90381 18.0962C6.12279 19.3152 7.77609 20 9.5 20H13C13.5523 20 14 19.5523 14 19C14 18.4477 13.5523 18 13 18H9.5C8.30653 18 7.16193 17.5259 6.31802 16.682C5.90016 16.2641 5.56869 15.768 5.34254 15.2221C5.1164 14.6761 5 14.0909 5 13.5C5 12.3065 5.47411 11.1619 6.31802 10.318C7.16193 9.47411 8.30653 9 9.5 9H17.5858L14.2929 12.2929C13.9024 12.6834 13.9024 13.3166 14.2929 13.7071C14.6834 14.0976 15.3166 14.0976 15.7071 13.7071L20.7071 8.70711C21.0976 8.31658 21.0976 7.68342 20.7071 7.29289L15.7071 2.29289Z",fill:"currentColor"},null)])}}),se={name:"undo-redo",install:()=>({extensions:[]}),toolbarComponent:e.defineComponent({name:"UndoRedoButton",setup(){const t=e.inject("editor"),o=e.computed(()=>t?.value?.can().undo()??!1),n=e.computed(()=>t?.value?.can().redo()??!1);return()=>e.createVNode("div",null,[e.createVNode(V,{icon:ce,tooltip:"撤销",disabled:!o.value,onClick:()=>t?.value?.chain().focus().undo().run()},null),e.createVNode(V,{icon:de,tooltip:"重做",disabled:!n.value,onClick:()=>t?.value?.chain().focus().redo().run()},null)])}})},ue=e.defineComponent({name:"LinkIcon",setup(t,{attrs:o}){return()=>e.createVNode("svg",e.mergeProps({width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},o),[e.createVNode("path",{d:"M16.9958 1.06669C15.4226 1.05302 13.907 1.65779 12.7753 2.75074L12.765 2.76086L11.045 4.47086C10.6534 4.86024 10.6515 5.49341 11.0409 5.88507C11.4303 6.27673 12.0634 6.27858 12.4551 5.88919L14.1697 4.18456C14.9236 3.45893 15.9319 3.05752 16.9784 3.06662C18.0272 3.07573 19.0304 3.49641 19.772 4.23804C20.5137 4.97967 20.9344 5.98292 20.9435 7.03171C20.9526 8.07776 20.5515 9.08563 19.8265 9.83941L16.833 12.8329C16.4274 13.2386 15.9393 13.5524 15.4019 13.7529C14.8645 13.9533 14.2903 14.0359 13.7181 13.9949C13.146 13.9539 12.5894 13.7904 12.0861 13.5154C11.5827 13.2404 11.1444 12.8604 10.8008 12.401C10.47 11.9588 9.84333 11.8685 9.40108 12.1993C8.95883 12.5301 8.86849 13.1568 9.1993 13.599C9.71464 14.288 10.3721 14.858 11.1272 15.2705C11.8822 15.683 12.7171 15.9283 13.5753 15.9898C14.4334 16.0513 15.2948 15.9274 16.1009 15.6267C16.907 15.326 17.639 14.8555 18.2473 14.247L21.2472 11.2471L21.2593 11.2347C22.3523 10.1031 22.9571 8.58751 22.9434 7.01433C22.9297 5.44115 22.2987 3.93628 21.1863 2.82383C20.0738 1.71138 18.5689 1.08036 16.9958 1.06669Z",fill:"currentColor"},null),e.createVNode("path",{d:"M10.4247 8.0102C9.56657 7.94874 8.70522 8.07256 7.89911 8.37326C7.09305 8.67395 6.36096 9.14458 5.75272 9.753L2.75285 12.7529L2.74067 12.7653C1.64772 13.8969 1.04295 15.4125 1.05662 16.9857C1.07029 18.5589 1.70131 20.0637 2.81376 21.1762C3.9262 22.2886 5.43108 22.9196 7.00426 22.9333C8.57744 22.947 10.0931 22.3422 11.2247 21.2493L11.2371 21.2371L12.9471 19.5271C13.3376 19.1366 13.3376 18.5034 12.9471 18.1129C12.5565 17.7223 11.9234 17.7223 11.5328 18.1129L9.82932 19.8164C9.07555 20.5414 8.06768 20.9425 7.02164 20.9334C5.97285 20.9243 4.9696 20.5036 4.22797 19.762C3.48634 19.0203 3.06566 18.0171 3.05655 16.9683C3.04746 15.9222 3.44851 14.9144 4.17355 14.1606L7.16719 11.167C7.5727 10.7613 8.06071 10.4476 8.59811 10.2471C9.13552 10.0467 9.70976 9.96412 10.2819 10.0051C10.854 10.0461 11.4106 10.2096 11.9139 10.4846C12.4173 10.7596 12.8556 11.1397 13.1992 11.599C13.53 12.0412 14.1567 12.1316 14.5989 11.8007C15.0412 11.4699 15.1315 10.8433 14.8007 10.401C14.2854 9.71205 13.6279 9.14198 12.8729 8.72948C12.1178 8.31697 11.2829 8.07166 10.4247 8.0102Z",fill:"currentColor"},null)])}}),pe=e.defineComponent({name:"CornerDownLeftIcon",setup(t,{attrs:o}){return()=>e.createVNode("svg",e.mergeProps({width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",xmlns:"http://www.w3.org/2000/svg"},o),[e.createVNode("polyline",{points:"9 10 4 15 9 20"},null),e.createVNode("path",{d:"M20 4v7a4 4 0 0 1-4 4H4"},null)])}}),Ce=e.defineComponent({name:"ExternalLinkIcon",setup(t,{attrs:o}){return()=>e.createVNode("svg",e.mergeProps({width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",xmlns:"http://www.w3.org/2000/svg"},o),[e.createVNode("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"},null),e.createVNode("polyline",{points:"15 3 21 3 21 9"},null),e.createVNode("line",{x1:"10",y1:"14",x2:"21",y2:"3"},null)])}}),fe=e.defineComponent({name:"TrashIcon",setup(t,{attrs:o}){return()=>e.createVNode("svg",e.mergeProps({width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",xmlns:"http://www.w3.org/2000/svg"},o),[e.createVNode("polyline",{points:"3 6 5 6 21 6"},null),e.createVNode("path",{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"},null)])}}),me=e.defineComponent({name:"LinkPopover",setup(){const t=e.inject("editor"),o=e.ref(!1),n=e.ref("");let l=!1;e.watch(()=>t?.value?.isActive("link"),i=>{l||i&&(n.value=t?.value?.getAttributes("link").href??"",e.nextTick(()=>{o.value=!0}))});const r=()=>{const i=t?.value;if(!i||!n.value)return;l=!0;const{empty:f}=i.state.selection;let w=i.chain().focus().extendMarkRange("link").setLink({href:n.value});f&&(w=w.insertContent({type:"text",text:n.value})),w.run(),o.value=!1,e.nextTick(()=>{l=!1})},a=()=>{const i=t?.value;i&&(l=!0,i.chain().focus().extendMarkRange("link").unsetLink().run(),n.value="",o.value=!1,e.nextTick(()=>{l=!1}))},m=()=>{const i=t?.value?.getAttributes("link").href;i&&window.open(i,"_blank","noopener,noreferrer")},C=i=>{i.key==="Enter"&&(i.preventDefault(),r())},d=i=>{i&&(n.value=t?.value?.getAttributes("link").href??""),o.value=i},k=i=>{n.value=i};return()=>{const i=t?.value?.isActive("link")??!1;return e.createVNode(p.ElPopover,{visible:o.value,"onUpdate:visible":d,placement:"bottom",width:300,trigger:"click",showArrow:!1,popperClass:"link-popover-popper",offset:6},{reference:()=>e.createVNode("span",null,[e.createVNode(V,{tooltip:"链接",icon:ue,class:["tiptap-button",{"is-active":i}]},null)]),default:()=>e.createVNode("div",{class:"link-popover-inner"},[e.createVNode(p.ElInput,{modelValue:n.value,"onUpdate:modelValue":k,type:"url",placeholder:"请输入链接...",size:"small",autofocus:!0,onKeydown:C},null),e.createVNode("div",{class:"link-popover-actions"},[e.createVNode(p.ElTooltip,{content:"确认",showArrow:!1,offset:4},{default:()=>[e.createVNode(p.ElButton,{text:!0,icon:pe,disabled:!n.value,onClick:r},null)]}),e.createVNode(p.ElTooltip,{content:"在新标签页打开",showArrow:!1,offset:4},{default:()=>[e.createVNode(p.ElButton,{text:!0,icon:Ce,disabled:!n.value&&!i,onClick:m},null)]}),e.createVNode(p.ElTooltip,{content:"移除链接",showArrow:!1,offset:4},{default:()=>[e.createVNode(p.ElButton,{text:!0,icon:fe,disabled:!i,onClick:a},null)]})])])})}}}),he={name:"text-style",install:()=>({extensions:[]}),toolbarComponent:e.defineComponent({name:"TextStyleButton",setup(){const t=e.inject("editor");return()=>e.createVNode("div",null,[e.createVNode(V,{icon:U,tooltip:"粗体",isActive:t?.value?.isActive("bold"),onClick:()=>t?.value?.chain().focus().toggleBold().run()},null),e.createVNode(V,{icon:j,tooltip:"斜体",isActive:t?.value?.isActive("italic"),onClick:()=>t?.value?.chain().focus().toggleItalic().run()},null),e.createVNode(V,{icon:_,tooltip:"删除线",isActive:t?.value?.isActive("strike"),onClick:()=>t?.value?.chain().focus().toggleStrike().run()},null),e.createVNode(V,{icon:q,tooltip:"下划线",isActive:t?.value?.isActive("underline"),onClick:()=>t?.value?.chain().focus().toggleUnderline().run()},null),e.createVNode(me,null,null)])}})},z=e.defineComponent({name:"AlignLeftIcon",setup(t,{attrs:o}){return()=>e.createVNode("svg",e.mergeProps({width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},o),[e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"},null),e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M2 12C2 11.4477 2.44772 11 3 11H15C15.5523 11 16 11.4477 16 12C16 12.5523 15.5523 13 15 13H3C2.44772 13 2 12.5523 2 12Z",fill:"currentColor"},null),e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M2 18C2 17.4477 2.44772 17 3 17H17C17.5523 17 18 17.4477 18 18C18 18.5523 17.5523 19 17 19H3C2.44772 19 2 18.5523 2 18Z",fill:"currentColor"},null)])}}),$=e.defineComponent({name:"AlignCenterIcon",setup(t,{attrs:o}){return()=>e.createVNode("svg",e.mergeProps({width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},o),[e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"},null),e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M6 12C6 11.4477 6.44772 11 7 11H17C17.5523 11 18 11.4477 18 12C18 12.5523 17.5523 13 17 13H7C6.44772 13 6 12.5523 6 12Z",fill:"currentColor"},null),e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M4 18C4 17.4477 4.44772 17 5 17H19C19.5523 17 20 17.4477 20 18C20 18.5523 19.5523 19 19 19H5C4.44772 19 4 18.5523 4 18Z",fill:"currentColor"},null)])}}),P=e.defineComponent({name:"AlignRightIcon",setup(t,{attrs:o}){return()=>e.createVNode("svg",e.mergeProps({width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},o),[e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"},null),e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M8 12C8 11.4477 8.44772 11 9 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H9C8.44772 13 8 12.5523 8 12Z",fill:"currentColor"},null),e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M6 18C6 17.4477 6.44772 17 7 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H7C6.44772 19 6 18.5523 6 18Z",fill:"currentColor"},null)])}}),ge=e.defineComponent({name:"AlignJustifyIcon",setup(t,{attrs:o}){return()=>e.createVNode("svg",e.mergeProps({width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},o),[e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"},null),e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M2 12C2 11.4477 2.44772 11 3 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H3C2.44772 13 2 12.5523 2 12Z",fill:"currentColor"},null),e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M2 18C2 17.4477 2.44772 17 3 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H3C2.44772 19 2 18.5523 2 18Z",fill:"currentColor"},null)])}}),Ve={name:"text-align",install:()=>({extensions:[]}),toolbarComponent:e.defineComponent({name:"TextAlignButton",setup(){const t=e.inject("editor");return()=>e.createVNode("div",null,[e.createVNode(V,{icon:z,tooltip:"左边对齐",isActive:t?.value?.isActive({textAlign:"left"}),onClick:()=>t?.value?.chain().focus().setTextAlign("left").run()},null),e.createVNode(V,{icon:$,tooltip:"中间对齐",isActive:t?.value?.isActive({textAlign:"center"}),onClick:()=>t?.value?.chain().focus().setTextAlign("center").run()},null),e.createVNode(V,{icon:P,tooltip:"右边对齐",isActive:t?.value?.isActive({textAlign:"right"}),onClick:()=>t?.value?.chain().focus().setTextAlign("right").run()},null),e.createVNode(V,{icon:ge,tooltip:"两端对齐",isActive:t?.value?.isActive({textAlign:"justify"}),onClick:()=>t?.value?.chain().focus().setTextAlign("justify").run()},null)])}})},we=e.defineComponent({name:"ListIcon",setup(t,{attrs:o}){return()=>e.createVNode("svg",e.mergeProps({width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},o),[e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M7 6C7 5.44772 7.44772 5 8 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H8C7.44772 7 7 6.55228 7 6Z",fill:"currentColor"},null),e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M7 12C7 11.4477 7.44772 11 8 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H8C7.44772 13 7 12.5523 7 12Z",fill:"currentColor"},null),e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M7 18C7 17.4477 7.44772 17 8 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H8C7.44772 19 7 18.5523 7 18Z",fill:"currentColor"},null),e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H3.01C3.56228 5 4.01 5.44772 4.01 6C4.01 6.55228 3.56228 7 3.01 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"},null),e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M2 12C2 11.4477 2.44772 11 3 11H3.01C3.56228 11 4.01 11.4477 4.01 12C4.01 12.5523 3.56228 13 3.01 13H3C2.44772 13 2 12.5523 2 12Z",fill:"currentColor"},null),e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M2 18C2 17.4477 2.44772 17 3 17H3.01C3.56228 17 4.01 17.4477 4.01 18C4.01 18.5523 3.56228 19 3.01 19H3C2.44772 19 2 18.5523 2 18Z",fill:"currentColor"},null)])}}),Ne=e.defineComponent({name:"ListOrderedIcon",setup(t,{attrs:o}){return()=>e.createVNode("svg",e.mergeProps({width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},o),[e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M9 6C9 5.44772 9.44772 5 10 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H10C9.44772 7 9 6.55228 9 6Z",fill:"currentColor"},null),e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M9 12C9 11.4477 9.44772 11 10 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H10C9.44772 13 9 12.5523 9 12Z",fill:"currentColor"},null),e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M9 18C9 17.4477 9.44772 17 10 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H10C9.44772 19 9 18.5523 9 18Z",fill:"currentColor"},null),e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M3 6C3 5.44772 3.44772 5 4 5H5C5.55228 5 6 5.44772 6 6V10C6 10.5523 5.55228 11 5 11C4.44772 11 4 10.5523 4 10V7C3.44772 7 3 6.55228 3 6Z",fill:"currentColor"},null),e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M3 10C3 9.44772 3.44772 9 4 9H6C6.55228 9 7 9.44772 7 10C7 10.5523 6.55228 11 6 11H4C3.44772 11 3 10.5523 3 10Z",fill:"currentColor"},null),e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M5.82219 13.0431C6.54543 13.4047 6.99997 14.1319 6.99997 15C6.99997 15.5763 6.71806 16.0426 6.48747 16.35C6.31395 16.5814 6.1052 16.8044 5.91309 17H5.99997C6.55226 17 6.99997 17.4477 6.99997 18C6.99997 18.5523 6.55226 19 5.99997 19H3.99997C3.44769 19 2.99997 18.5523 2.99997 18C2.99997 17.4237 3.28189 16.9575 3.51247 16.65C3.74323 16.3424 4.03626 16.0494 4.26965 15.8161C4.27745 15.8083 4.2852 15.8006 4.29287 15.7929C4.55594 15.5298 4.75095 15.3321 4.88748 15.15C4.96287 15.0495 4.99021 14.9922 4.99911 14.9714C4.99535 14.9112 4.9803 14.882 4.9739 14.8715C4.96613 14.8588 4.95382 14.845 4.92776 14.8319C4.87723 14.8067 4.71156 14.7623 4.44719 14.8944C3.95321 15.1414 3.35254 14.9412 3.10555 14.4472C2.85856 13.9533 3.05878 13.3526 3.55276 13.1056C4.28839 12.7378 5.12272 12.6934 5.82219 13.0431Z",fill:"currentColor"},null)])}}),xe=e.defineComponent({name:"ListTodoIcon",setup(t,{attrs:o}){return()=>e.createVNode("svg",e.mergeProps({width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},o),[e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M2 6C2 4.89543 2.89543 4 4 4H8C9.10457 4 10 4.89543 10 6V10C10 11.1046 9.10457 12 8 12H4C2.89543 12 2 11.1046 2 10V6ZM8 6H4V10H8V6Z",fill:"currentColor"},null),e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M9.70711 14.2929C10.0976 14.6834 10.0976 15.3166 9.70711 15.7071L5.70711 19.7071C5.31658 20.0976 4.68342 20.0976 4.29289 19.7071L2.29289 17.7071C1.90237 17.3166 1.90237 16.6834 2.29289 16.2929C2.68342 15.9024 3.31658 15.9024 3.70711 16.2929L5 17.5858L8.29289 14.2929C8.68342 13.9024 9.31658 13.9024 9.70711 14.2929Z",fill:"currentColor"},null),e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M12 6C12 5.44772 12.4477 5 13 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H13C12.4477 7 12 6.55228 12 6Z",fill:"currentColor"},null),e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M12 12C12 11.4477 12.4477 11 13 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H13C12.4477 13 12 12.5523 12 12Z",fill:"currentColor"},null),e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M12 18C12 17.4477 12.4477 17 13 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H13C12.4477 19 12 18.5523 12 18Z",fill:"currentColor"},null)])}}),ke={name:"list",install:()=>({extensions:[]}),toolbarComponent:e.defineComponent({name:"ListButton",setup(){const t=e.inject("editor");return()=>e.createVNode("div",null,[e.createVNode(V,{icon:we,tooltip:"无序列表",isActive:t?.value?.isActive("bulletList"),onClick:()=>t?.value?.chain().focus().toggleBulletList().run()},null),e.createVNode(V,{icon:Ne,tooltip:"有序列表",isActive:t?.value?.isActive("orderedList"),onClick:()=>t?.value?.chain().focus().toggleOrderedList().run()},null),e.createVNode(V,{icon:xe,tooltip:"任务列表",isActive:t?.value?.isActive("taskList"),onClick:()=>t?.value?.chain().focus().toggleTaskList().run()},null)])}})},be=e.defineComponent({name:"CodeBlockIcon",setup(t,{attrs:o}){return()=>e.createVNode("svg",e.mergeProps({width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",xmlns:"http://www.w3.org/2000/svg"},o),[e.createVNode("polyline",{points:"16 18 22 12 16 6"},null),e.createVNode("polyline",{points:"8 6 2 12 8 18"},null)])}}),Be=e.defineComponent({name:"CodeBlockButton",setup(){const t=e.inject("editor");return()=>e.createVNode(V,{icon:be,tooltip:"代码块",isActive:t?.value?.isActive("codeBlock"),onClick:()=>t?.value?.chain().focus().toggleCodeBlock().run()},null)}}),ve=Z.createLowlight(Z.common),He={name:"code-block",install:()=>({extensions:[oe.CodeBlockLowlight.configure({lowlight:ve,defaultLanguage:"plaintext"})]}),toolbarComponent:Be},ye=e.defineComponent({name:"TableIcon",setup(t,{attrs:o}){return()=>e.createVNode("svg",e.mergeProps({width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},o),[e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M2 5C2 3.34315 3.34315 2 5 2H19C20.6569 2 22 3.34315 22 5V19C22 20.6569 20.6569 22 19 22H5C3.34315 22 2 20.6569 2 19V5ZM4 5C4 4.44772 4.44772 4 5 4H11V8H4V5ZM4 10H11V14H4V10ZM20 14V10H13V14H20ZM13 16H20V19C20 19.5523 19.5523 20 19 20H13V16ZM11 16V20H5C4.44772 20 4 19.5523 4 19V16H11ZM13 8H20V5C20 4.44772 19.5523 4 19 4H13V8Z",fill:"currentColor"},null)])}}),Ae=8,Ee=8,Me=e.defineComponent({name:"TableButton",setup(){const t=e.inject("editor"),o=e.ref(!1),n=e.ref(0),l=e.ref(0),r=(C,d)=>{n.value=C,l.value=d},a=()=>{n.value=0,l.value=0},m=(C,d)=>{t?.value?.chain().focus().insertTable({rows:d,cols:C,withHeaderRow:!0}).run(),o.value=!1};return()=>e.createVNode(p.ElPopover,{visible:o.value,"onUpdate:visible":C=>o.value=C,trigger:"click",placement:"bottom-start",popperClass:"table-picker-popper",width:"auto",showArrow:!1},{reference:()=>e.createVNode("span",null,[e.createVNode(p.ElTooltip,{content:"表格",showArrow:!1,offset:6,disabled:o.value},{default:()=>[e.createVNode(p.ElButton,{text:!0,class:["tiptap-button",{"is-active":o.value}]},{default:()=>[e.createVNode(ye,{class:"tiptap-button-icon"},null)]})]})]),default:()=>e.createVNode("div",{class:"table-picker"},[e.createVNode("div",{class:"table-picker-grid",onMouseleave:a},[Array.from({length:Ee},(C,d)=>e.createVNode("div",{key:d,class:"table-picker-row"},[Array.from({length:Ae},(k,i)=>e.createVNode("div",{key:i,class:["table-picker-cell",{"is-active":i<n.value&&d<l.value}],onMouseenter:()=>r(i+1,d+1),onClick:()=>m(i+1,d+1)},null))]))]),e.createVNode("div",{class:"table-picker-footer"},[e.createVNode("div",{class:"table-picker-counter"},[e.createVNode("span",null,[e.createTextVNode("列")]),e.createVNode("span",null,[n.value||1])]),e.createVNode("span",{class:"table-picker-x"},[e.createTextVNode("x")]),e.createVNode("div",{class:"table-picker-counter"},[e.createVNode("span",null,[e.createTextVNode("行")]),e.createVNode("span",null,[l.value||1])])])])})}});function Ie(t){let o=t.nodeType===Node.TEXT_NODE?t.parentElement:t;for(;o&&o instanceof HTMLElement;){if(o.tagName==="TD"||o.tagName==="TH")return o;o=o.parentElement}return null}function Te(t){if(!t.isActive("tableCell")&&!t.isActive("tableHeader"))return null;const{node:o}=t.view.domAtPos(t.state.selection.from),n=Ie(o);if(!n)return null;const l=n.parentElement,r=l.parentElement,a=n.closest("table");if(!a)return null;const m=Array.from(l.children).indexOf(n),C=Array.from(r.children).indexOf(l),d=l.children.length,k=r.children.length,i=n.getBoundingClientRect(),f=a.getBoundingClientRect(),w=t.view.dom.closest(".tiptap-editor").getBoundingClientRect();return{cell:n,colIndex:m,rowIndex:C,totalCols:d,totalRows:k,cellRect:i,tableRect:f,editorRect:w}}function W(t){const{state:o}=t,n=o.selection.from;let l=null;return o.doc.nodesBetween(0,o.doc.content.size,(r,a)=>{if(r.type.name==="table"&&a<=n&&n<=a+r.nodeSize)return l={node:r,pos:a},!1}),l}const Le=e.defineComponent({name:"TableControls",setup(){const t=e.inject("editor"),o=e.inject("readonly"),n=e.ref(null),l=e.ref(null);function r(){const i=t?.value;if(l.value&&(l.value.classList.remove("tcc-cell-focused"),l.value=null),!i){n.value=null;return}const f=Te(i);n.value=f,f&&(f.cell.classList.add("tcc-cell-focused"),l.value=f.cell)}e.watchEffect(i=>{const f=t?.value;f&&(f.on("selectionUpdate",r),f.on("transaction",r),i(()=>{f.off("selectionUpdate",r),f.off("transaction",r),l.value&&(l.value.classList.remove("tcc-cell-focused"),l.value=null)}))});function a(i){const f=t?.value;if(!f||!n.value)return;const{colIndex:w,totalCols:v}=n.value,N=i==="left"?w-1:w+1;if(N<0||N>=v)return;const c=W(f);if(!c)return;const{node:s,pos:h}=c,g=[];s.forEach(H=>{if(H.type.name!=="tableRow"){g.push(H);return}const b=[];H.forEach(L=>b.push(L));const T=b[w];b[w]=b[N],b[N]=T,g.push(H.type.create(H.attrs,b,H.marks))});const x=s.type.create(s.attrs,g,s.marks),A=f.state.tr.replaceWith(h,h+s.nodeSize,x);f.view.dispatch(A)}function m(i){const f=t?.value;if(!f||!n.value)return;const{rowIndex:w,totalRows:v}=n.value,N=i==="up"?w-1:w+1;if(N<0||N>=v)return;const c=W(f);if(!c)return;const{node:s,pos:h}=c,g=[];s.forEach(b=>g.push(b));const x=g[w];g[w]=g[N],g[N]=x;const A=s.type.create(s.attrs,g,s.marks),H=f.state.tr.replaceWith(h,h+s.nodeSize,A);f.view.dispatch(H)}const C=()=>e.createVNode("svg",{width:"16",height:"4",viewBox:"0 0 16 4",fill:"currentColor"},[e.createVNode("circle",{cx:"2",cy:"2",r:"1.5"},null),e.createVNode("circle",{cx:"8",cy:"2",r:"1.5"},null),e.createVNode("circle",{cx:"14",cy:"2",r:"1.5"},null)]),d=()=>e.createVNode("svg",{width:"4",height:"16",viewBox:"0 0 4 16",fill:"currentColor"},[e.createVNode("circle",{cx:"2",cy:"2",r:"1.5"},null),e.createVNode("circle",{cx:"2",cy:"8",r:"1.5"},null),e.createVNode("circle",{cx:"2",cy:"14",r:"1.5"},null)]),k=()=>e.createVNode("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round"},[e.createVNode("path",{d:"M5 1v8M1 5h8"},null)]);return()=>{if(o?.value)return null;const i=n.value;if(!i)return null;const{colIndex:f,rowIndex:w,totalCols:v,totalRows:N,cellRect:c,tableRect:s,editorRect:h}=i,g=s.top-h.top,x=s.left-h.left,A=s.right-h.left,H=s.bottom-h.top,b=c.left-h.left,T=c.top-h.top,L=c.width,K=c.height,Qe={position:"absolute",top:`${g-20}px`,left:`${b+L/2-18}px`},Ye={position:"absolute",top:`${T+K/2-18}px`,left:`${x-20}px`},et={position:"absolute",top:`${T+K/2-12}px`,left:`${A+6}px`},tt={position:"absolute",top:`${H+6}px`,left:`${b+L/2-12}px`},ot=f===0,G=f===v-1,nt=w===0,J=w===N-1,y=t?.value;return e.createVNode("div",{class:"table-cell-controls"},[e.createVNode(p.ElDropdown,{trigger:"click",placement:"bottom",style:Qe,onCommand:B=>{B==="move-left"?a("left"):B==="move-right"?a("right"):B==="insert-left"?y?.chain().focus().addColumnBefore().run():B==="insert-right"?y?.chain().focus().addColumnAfter().run():B==="delete"&&y?.chain().focus().deleteColumn().run()}},{default:()=>[e.createVNode("button",{class:"tcc-btn tcc-btn--col"},[e.createVNode(C,null,null)])],dropdown:()=>e.createVNode(p.ElDropdownMenu,null,{default:()=>[e.createVNode(p.ElDropdownItem,{command:"move-left",disabled:ot},{default:()=>[e.createTextVNode("移动列到左侧")]}),e.createVNode(p.ElDropdownItem,{command:"move-right",disabled:G},{default:()=>[e.createTextVNode("移动列到右侧")]}),e.createVNode(p.ElDropdownItem,{command:"insert-left"},{default:()=>[e.createTextVNode("在左侧插入一列")]}),e.createVNode(p.ElDropdownItem,{command:"insert-right"},{default:()=>[e.createTextVNode("在右侧插入一列")]}),e.createVNode(p.ElDropdownItem,{command:"delete",divided:!0},{default:()=>[e.createTextVNode("删除列")]})]})}),e.createVNode(p.ElDropdown,{trigger:"click",placement:"right",style:Ye,onCommand:B=>{B==="move-up"?m("up"):B==="move-down"?m("down"):B==="insert-above"?y?.chain().focus().addRowBefore().run():B==="insert-below"?y?.chain().focus().addRowAfter().run():B==="delete"&&y?.chain().focus().deleteRow().run()}},{default:()=>[e.createVNode("button",{class:"tcc-btn tcc-btn--row"},[e.createVNode(d,null,null)])],dropdown:()=>e.createVNode(p.ElDropdownMenu,null,{default:()=>[e.createVNode(p.ElDropdownItem,{command:"move-up",disabled:nt},{default:()=>[e.createTextVNode("上移")]}),e.createVNode(p.ElDropdownItem,{command:"move-down",disabled:J},{default:()=>[e.createTextVNode("下移")]}),e.createVNode(p.ElDropdownItem,{command:"insert-above"},{default:()=>[e.createTextVNode("在上方插入一行")]}),e.createVNode(p.ElDropdownItem,{command:"insert-below"},{default:()=>[e.createTextVNode("在下方插入一行")]}),e.createVNode(p.ElDropdownItem,{command:"delete",divided:!0},{default:()=>[e.createTextVNode("删除行")]})]})}),G&&e.createVNode("button",{class:"tcc-btn tcc-btn--add",style:et,onClick:()=>y?.chain().focus().addColumnAfter().run()},[e.createVNode(k,null,null)]),J&&e.createVNode("button",{class:"tcc-btn tcc-btn--add",style:tt,onClick:()=>y?.chain().focus().addRowAfter().run()},[e.createVNode(k,null,null)])])}}}),Fe={name:"table",install:()=>({extensions:[M.Table.configure({resizable:!0}),M.TableRow,M.TableHeader,M.TableCell],controlComponent:Le}),toolbarComponent:Me},De=e.defineComponent({name:"MathIcon",setup(t,{attrs:o}){return()=>e.createVNode("svg",e.mergeProps({width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},o),[e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M9 4.8c.1-.5.5-.8 1-.8h10a1 1 0 1 1 0 2h-9.2L8.3 19.2a1 1 0 0 1-1.7.4l-3.4-4.2a1 1 0 0 1 1.6-1.2l2 2.5L9 4.8Zm9.7 5.5c.4.4.4 1 0 1.4L17 13.5l1.8 1.8a1 1 0 1 1-1.4 1.4L15.5 15l-1.8 1.8a1 1 0 0 1-1.4-1.4l1.8-1.8-1.8-1.8a1 1 0 0 1 1.4-1.4l1.8 1.8 1.8-1.8a1 1 0 0 1 1.4 0Z",fill:"currentColor"},null)])}}),Re=e.defineComponent({name:"MathButton",setup(){const t=e.inject("editor"),o=e.inject("openMathDialog");return()=>e.createVNode(V,{icon:De,tooltip:"数学公式",isActive:t?.value?.isActive("inlineMath")||t?.value?.isActive("blockMath"),onClick:()=>o?.()},null)}}),Ze=e.defineComponent({name:"MathEditDialog",props:{visible:{type:Boolean,required:!0},latex:{type:String,required:!0},pos:{type:Number,default:null},type:{type:String,required:!0}},emits:["update:visible"],setup(t,{emit:o}){const n=e.inject("editor"),l=e.ref(""),r=e.ref("inline");e.watch(()=>t.latex,d=>{l.value=d},{immediate:!0}),e.watch(()=>t.type,d=>{r.value=d},{immediate:!0});const a=e.computed(()=>t.pos===null),m=e.computed(()=>l.value.trim()?le.renderToString(l.value,{displayMode:r.value==="block",throwOnError:!1}):""),C=()=>{const d=n?.value;if(!(!d||!l.value.trim())){if(a.value)r.value==="inline"?d.chain().focus().insertInlineMath({latex:l.value}).run():d.chain().focus().insertBlockMath({latex:l.value}).run();else if(r.value===t.type)t.type==="inline"?d.commands.updateInlineMath({latex:l.value,pos:t.pos}):d.commands.updateBlockMath({latex:l.value,pos:t.pos});else{const k=t.pos;t.type==="inline"?d.chain().focus().deleteInlineMath({pos:k}).insertBlockMath({latex:l.value}).run():d.chain().focus().deleteBlockMath({pos:k}).insertInlineMath({latex:l.value}).run()}o("update:visible",!1)}};return()=>e.createVNode(p.ElDialog,{modelValue:t.visible,title:a.value?"插入数学公式":"编辑数学公式",width:"520px","onUpdate:modelValue":d=>o("update:visible",d)},{default:()=>[e.createVNode("div",{class:"math-dialog"},[e.createVNode(p.ElRadioGroup,{modelValue:r.value,"onUpdate:modelValue":d=>{r.value=d}},{default:()=>[e.createVNode(p.ElRadioButton,{value:"inline"},{default:()=>[e.createTextVNode("行内公式")]}),e.createVNode(p.ElRadioButton,{value:"block"},{default:()=>[e.createTextVNode("块级公式")]})]}),e.createVNode(p.ElInput,{modelValue:l.value,type:"textarea",rows:3,placeholder:"请输入 LaTeX 公式,例如:E=mc^2","onUpdate:modelValue":d=>{l.value=d}},null),e.createVNode("div",{class:["math-preview",{"math-preview--empty":!m.value}]},[m.value?e.createVNode("div",{innerHTML:m.value},null):e.createVNode("span",{class:"math-preview__placeholder"},[e.createTextVNode("预览将在此处显示")])])])],footer:()=>e.createVNode(e.Fragment,null,[e.createVNode(p.ElButton,{onClick:()=>o("update:visible",!1)},{default:()=>[e.createTextVNode("取消")]}),e.createVNode(p.ElButton,{type:"primary",disabled:!l.value.trim(),onClick:C},{default:()=>[e.createTextVNode("确认")]})])})}}),Se={name:"math",toolbarComponent:Re,install(t){const o=e.ref(!1),n=e.ref(""),l=e.ref(null),r=e.ref("inline"),a=(C={})=>{t.readonly.value||(n.value=C.latex??"",l.value=C.pos??null,r.value=C.type??"inline",o.value=!0)};t.provide("openMathDialog",a);const m=e.defineComponent({name:"MathEditDialogWrapper",setup:()=>()=>e.h(Ze,{visible:o.value,latex:n.value,pos:l.value,type:r.value,"onUpdate:visible":C=>{o.value=C}})});return{extensions:[ne.Mathematics.configure({inlineOptions:{onClick:(C,d)=>a({latex:C.attrs.latex,pos:d,type:"inline"})},blockOptions:{onClick:(C,d)=>a({latex:C.attrs.latex,pos:d,type:"block"})}})],controlComponent:m}}},Ue=e.defineComponent({name:"ImageUploadView",props:E.nodeViewProps,setup(t){const o=e.computed(()=>t.node.attrs.accept),n=e.computed(()=>t.node.attrs.limit),l=e.computed(()=>t.node.attrs.maxSize),r=e.ref([]),a=e.ref(),m=e.ref(!1),C=async c=>{if(l.value>0&&c.size>l.value)return t.extension.options.onError?.(new Error(`文件大小超出限制 ${l.value/1024/1024}MB`)),null;const s=crypto.randomUUID();r.value.push({id:s,file:c,progress:0,status:"uploading"});try{const h=t.extension.options.upload;if(!h)throw new Error("未配置 upload 函数");const g=await h(c);if(!g)throw new Error("上传失败:未返回 URL");const x=r.value.find(A=>A.id===s);return x&&(x.status="success",x.progress=100),t.extension.options.onSuccess?.(g),g}catch(h){const g=r.value.find(x=>x.id===s);return g&&(g.status="error",g.progress=0),t.extension.options.onError?.(h instanceof Error?h:new Error("上传失败")),null}},d=async c=>{if(!c.length)return;if(c.length>n.value){t.extension.options.onError?.(new Error(`最多上传 ${n.value} 个文件`));return}const s=(await Promise.all(c.map(C))).filter(h=>!!h);if(s.length>0){const h=t.getPos();if(typeof h!="number")return;const g=s.map(x=>({type:"image",attrs:{src:x}}));t.editor.chain().focus().deleteRange({from:h,to:h+t.node.nodeSize}).insertContentAt(h,g).run()}},k=()=>{r.value.length===0&&a.value&&(a.value.value="",a.value.click())},i=c=>{const s=c.target.files;s&&d(Array.from(s))},f=c=>{c.preventDefault(),m.value=!0},w=c=>{c.currentTarget.contains(c.relatedTarget)||(m.value=!1)},v=c=>{c.preventDefault(),m.value=!1;const s=Array.from(c.dataTransfer?.files??[]);s.length&&d(s)},N=c=>{r.value=r.value.filter(s=>s.id!==c)};return()=>e.createVNode(E.NodeViewWrapper,{class:"tiptap-image-upload"},{default:()=>[e.createVNode("div",{onClick:k},[r.value.length?e.createVNode("div",{class:"tiptap-image-upload-previews"},[r.value.map(c=>e.createVNode("div",{key:c.id,class:"tiptap-image-upload-preview"},[c.status==="uploading"&&e.createVNode("div",{class:"tiptap-image-upload-progress",style:{width:`${c.progress}%`}},null),e.createVNode("div",{class:"tiptap-image-upload-preview-content"},[e.createVNode("span",{class:"tiptap-image-upload-text"},[c.file.name]),e.createVNode("span",{class:"tiptap-image-upload-subtext"},[c.status==="uploading"?`${c.progress}%`:c.status==="error"?"上传失败":"上传成功"]),e.createVNode("button",{class:"tiptap-image-upload-remove",onClick:s=>{s.stopPropagation(),N(c.id)}},[e.createTextVNode("×")])])]))]):e.createVNode("div",{class:["tiptap-image-upload-drag-area",{"drag-active":m.value}],onDragover:f,onDragleave:w,onDrop:v},[e.createVNode("div",{class:"tiptap-image-upload-content"},[e.createVNode("span",{class:"tiptap-image-upload-text"},[e.createVNode("em",null,[e.createTextVNode("点击上传")]),e.createTextVNode(" 或拖拽图片到此处")]),e.createVNode("span",{class:"tiptap-image-upload-subtext"},[e.createTextVNode("最多 "),n.value,e.createTextVNode(" 个文件"),l.value?`,每个不超过 ${l.value/1024/1024}MB`:""])])]),e.createVNode("input",{ref:a,type:"file",accept:o.value,multiple:n.value>1,onChange:i,onClick:c=>c.stopPropagation()},null)])]})}}),je=S.Node.create({name:"imageUpload",group:"block",draggable:!0,selectable:!0,atom:!0,addOptions(){return{type:"image",accept:"image/*",limit:1,maxSize:0,upload:t=>new Promise(o=>{const n=new FileReader;n.onloadend=()=>o(n.result),n.readAsDataURL(t)}),onError:void 0,onSuccess:void 0,HTMLAttributes:{}}},addAttributes(){return{accept:{default:this.options.accept},limit:{default:this.options.limit},maxSize:{default:this.options.maxSize}}},parseHTML(){return[{tag:'div[data-type="image-upload"]'}]},renderHTML({HTMLAttributes:t}){return["div",S.mergeAttributes({"data-type":"image-upload"},t)]},addNodeView(){return E.VueNodeViewRenderer(Ue)},addCommands(){return{setImageUploadNode:()=>({commands:t})=>t.insertContent({type:this.name})}},addKeyboardShortcuts(){return{Enter:({editor:t})=>{const{selection:o}=t.state,{nodeAfter:n}=o.$from;if(n?.type.name==="imageUpload"&&t.isActive("imageUpload")){const l=t.view.nodeDOM(o.$from.pos);if(l instanceof HTMLElement){const r=l.firstChild;if(r instanceof HTMLElement)return r.click(),!0}}return!1}}}}),_e=e.defineComponent({name:"ImagePlusIcon",setup(t,{attrs:o}){return()=>e.createVNode("svg",e.mergeProps({width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},o),[e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M20 2C20 1.44772 19.5523 1 19 1C18.4477 1 18 1.44772 18 2V4H16C15.4477 4 15 4.44772 15 5C15 5.55228 15.4477 6 16 6H18V8C18 8.55228 18.4477 9 19 9C19.5523 9 20 8.55228 20 8V6H22C22.5523 6 23 5.55228 23 5C23 4.44772 22.5523 4 22 4H20V2ZM5 4C4.73478 4 4.48043 4.10536 4.29289 4.29289C4.10536 4.48043 4 4.73478 4 5V19C4 19.2652 4.10536 19.5196 4.29289 19.7071C4.48043 19.8946 4.73478 20 5 20H5.58579L14.379 11.2068C14.9416 10.6444 15.7045 10.3284 16.5 10.3284C17.2955 10.3284 18.0584 10.6444 18.621 11.2068L20 12.5858V12C20 11.4477 20.4477 11 21 11C21.5523 11 22 11.4477 22 12V14.998C22 14.9994 22 15.0007 22 15.002V19C22 19.7957 21.6839 20.5587 21.1213 21.1213C20.5587 21.6839 19.7957 22 19 22H6.00219C6.00073 22 5.99927 22 5.99781 22H5C4.20435 22 3.44129 21.6839 2.87868 21.1213C2.31607 20.5587 2 19.7957 2 19V5C2 4.20435 2.31607 3.44129 2.87868 2.87868C3.44129 2.31607 4.20435 2 5 2H12C12.5523 2 13 2.44772 13 3C13 3.55228 12.5523 4 12 4H5ZM8.41422 20H19C19.2652 20 19.5196 19.8946 19.7071 19.7071C19.8946 19.5196 20 19.2652 20 19V15.4142L17.207 12.6212C17.0195 12.4338 16.7651 12.3284 16.5 12.3284C16.2349 12.3284 15.9806 12.4337 15.7931 12.6211L8.41422 20ZM6.87868 6.87868C7.44129 6.31607 8.20435 6 9 6C9.79565 6 10.5587 6.31607 11.1213 6.87868C11.6839 7.44129 12 8.20435 12 9C12 9.79565 11.6839 10.5587 11.1213 11.1213C10.5587 11.6839 9.79565 12 9 12C8.20435 12 7.44129 11.6839 6.87868 11.1213C6.31607 10.5587 6 9.79565 6 9C6 8.20435 6.31607 7.44129 6.87868 6.87868ZM9 8C8.73478 8 8.48043 8.10536 8.29289 8.29289C8.10536 8.48043 8 8.73478 8 9C8 9.26522 8.10536 9.51957 8.29289 9.70711C8.48043 9.89464 8.73478 10 9 10C9.26522 10 9.51957 9.89464 9.70711 9.70711C9.89464 9.51957 10 9.26522 10 9C10 8.73478 9.89464 8.48043 9.70711 8.29289C9.51957 8.10536 9.26522 8 9 8Z",fill:"currentColor"},null)])}}),qe=e.defineComponent({name:"ImageButton",setup(){const t=e.inject("editor");return()=>e.createVNode("div",null,[e.createVNode(V,{icon:_e,tooltip:"图片",onClick:()=>t?.value?.commands.setImageUploadNode()},null)])}}),Oe=[{value:"left",title:"居左",Icon:z},{value:"center",title:"居中",Icon:$},{value:"right",title:"居右",Icon:P}],I=t=>t.preventDefault();function ze(t){if(!t.isActive("image"))return null;const{selection:o}=t.state;if(!(o instanceof D.NodeSelection)||o.node.type.name!=="image")return null;const n=o.node;return{pos:o.from,nodeSize:n.nodeSize,src:n.attrs.src,align:n.attrs.align??"left"}}function $e(t){const o=t.startsWith("data:")?"image.png":t.split("/").pop()?.split("?")[0]||"image.png",n=document.createElement("a");n.href=t,n.download=o,document.body.appendChild(n),n.click(),document.body.removeChild(n)}const Pe=()=>e.createVNode("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e.createVNode("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"},null),e.createVNode("polyline",{points:"7 10 12 15 17 10"},null),e.createVNode("line",{x1:"12",y1:"15",x2:"12",y2:"3"},null)]),We=()=>e.createVNode("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e.createVNode("polyline",{points:"1 4 1 10 7 10"},null),e.createVNode("path",{d:"M3.51 15a9 9 0 1 0 .49-4.1L1 10"},null)]),Ke=()=>e.createVNode("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e.createVNode("polyline",{points:"3 6 5 6 21 6"},null),e.createVNode("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"},null),e.createVNode("path",{d:"M10 11v6M14 11v6"},null),e.createVNode("path",{d:"M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"},null)]),Ge=e.defineComponent({name:"ImageControls",setup(){const t=e.inject("editor"),o=e.inject("readonly"),n=e.ref(null);function l(){const r=t?.value;if(!r){n.value=null;return}n.value=ze(r)}return e.watchEffect(r=>{const a=t?.value;a&&(a.on("transaction",l),r(()=>{a.off("transaction",l)}))}),()=>{const r=n.value;if(!r)return null;const a=t?.value;if(!a)return null;const{pos:m,nodeSize:C,src:d,align:k}=r,i=o?.value??!1,f=a.view.nodeDOM(m);if(!f||!(f instanceof HTMLElement))return null;const w=f.querySelector("[data-resize-wrapper]")??f,v=a.view.dom.closest(".tiptap-editor");if(!v)return null;const N=w.getBoundingClientRect(),c=v.getBoundingClientRect(),s={position:"absolute",top:`${N.top-c.top}px`,left:`${N.left-c.left+N.width/2}px`,transform:"translate(-50%, calc(-100% - 8px))",zIndex:20};return e.createVNode("div",{class:"image-controls",style:s},[!i&&Oe.map(({value:h,title:g,Icon:x})=>e.createVNode("button",{key:h,class:["image-controls-btn",k===h&&"is-active"],title:g,onMousedown:I,onClick:()=>a.chain().focus().updateAttributes("image",{align:h}).run()},[e.createVNode(x,null,null)])),!i&&e.createVNode("span",{class:"image-controls-separator"},null),e.createVNode("button",{class:"image-controls-btn",title:"下载",onMousedown:I,onClick:()=>$e(d)},[e.createVNode(Pe,null,null)]),!i&&e.createVNode("button",{class:"image-controls-btn",title:"重新上传",onMousedown:I,onClick:()=>a.chain().focus().deleteRange({from:m,to:m+C}).insertContentAt(m,{type:"imageUpload"}).run()},[e.createVNode(We,null,null)]),!i&&e.createVNode("button",{class:"image-controls-btn",title:"删除",onMousedown:I,onClick:()=>a.chain().focus().deleteRange({from:m,to:m+C}).run()},[e.createVNode(Ke,null,null)])])}}});function Je(t){return{name:"image",install:()=>({extensions:[O.configure({allowBase64:!0,resize:{enabled:!0,directions:["top","right","bottom","left","top-right","top-left","bottom-right","bottom-left"],minWidth:50,minHeight:50,alwaysPreserveAspectRatio:!1}}),je.configure({...t?{upload:t}:{}})],controlComponent:Ge}),toolbarComponent:qe}}const Xe={name:"separator",install:()=>({extensions:[]}),toolbarComponent:e.defineComponent({name:"ToolbarSeparator",setup:()=>()=>e.createVNode("div",{class:"tiptap-separator"},null)})};u.CodeBlockFeature=He,u.IconButton=V,u.ImageFeature=Je,u.ImageWithAlign=O,u.ListFeature=ke,u.MathFeature=Se,u.SeparatorFeature=Xe,u.TableFeature=Fe,u.TextAlignFeature=Ve,u.TextStyleFeature=he,u.TiptapEditor=ie,u.UndoRedoFeature=se,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(u,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("@tiptap/starter-kit"),require("@tiptap/vue-3"),require("@tiptap/extension-list"),require("@tiptap/extension-text-align"),require("@tiptap/extension-placeholder"),require("@tiptap/vue-3/menus"),require("element-plus"),require("@tiptap/extension-image"),require("@tiptap/pm/state"),require("@tiptap/pm/view"),require("@tiptap/extension-code-block-lowlight"),require("lowlight"),require("@tiptap/extension-table"),require("@tiptap/extension-mathematics"),require("katex"),require("@tiptap/core")):typeof define=="function"&&define.amd?define(["exports","vue","@tiptap/starter-kit","@tiptap/vue-3","@tiptap/extension-list","@tiptap/extension-text-align","@tiptap/extension-placeholder","@tiptap/vue-3/menus","element-plus","@tiptap/extension-image","@tiptap/pm/state","@tiptap/pm/view","@tiptap/extension-code-block-lowlight","lowlight","@tiptap/extension-table","@tiptap/extension-mathematics","katex","@tiptap/core"],e):(u=typeof globalThis<"u"?globalThis:u||self,e(u.TiptapEditor={},u.Vue,u.StarterKit,u.vue3,u.extensionList,u.extensionTextAlign,u.extensionPlaceholder,u.menus,u.ElementPlus,u.extensionImage,u.state,u.view,u.extensionCodeBlockLowlight,u.lowlight$1,u.extensionTable,u.extensionMathematics,u.katex,u.core))})(this,(function(u,e,X,E,F,Q,Y,ee,p,te,D,R,oe,Z,M,ne,le,S){"use strict";const re={icon:{type:Object,required:!0},tooltip:{type:String,required:!0},isActive:{type:Boolean},disabled:{type:Boolean,default:!1},onClick:{type:Function}},V=e.defineComponent({name:"IconButton",props:re,setup(t){return()=>e.createVNode(p.ElTooltip,{showArrow:!1,offset:6,content:t.tooltip},{default:()=>[e.createVNode(p.ElButton,{text:!0,icon:t.icon,class:["tiptap-button",{"is-active":t.isActive}],disabled:t.disabled,onClick:t.onClick},null)]})}}),U=e.defineComponent({name:"BoldIcon",setup(t,{attrs:o}){return()=>e.createVNode("svg",e.mergeProps({width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},o),[e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M6 2.5C5.17157 2.5 4.5 3.17157 4.5 4V20C4.5 20.8284 5.17157 21.5 6 21.5H15C16.4587 21.5 17.8576 20.9205 18.8891 19.8891C19.9205 18.8576 20.5 17.4587 20.5 16C20.5 14.5413 19.9205 13.1424 18.8891 12.1109C18.6781 11.9 18.4518 11.7079 18.2128 11.5359C19.041 10.5492 19.5 9.29829 19.5 8C19.5 6.54131 18.9205 5.14236 17.8891 4.11091C16.8576 3.07946 15.4587 2.5 14 2.5H6ZM14 10.5C14.663 10.5 15.2989 10.2366 15.7678 9.76777C16.2366 9.29893 16.5 8.66304 16.5 8C16.5 7.33696 16.2366 6.70107 15.7678 6.23223C15.2989 5.76339 14.663 5.5 14 5.5H7.5V10.5H14ZM7.5 18.5V13.5H15C15.663 13.5 16.2989 13.7634 16.7678 14.2322C17.2366 14.7011 17.5 15.337 17.5 16C17.5 16.663 17.2366 17.2989 16.7678 17.7678C16.2989 18.2366 15.663 18.5 15 18.5H7.5Z",fill:"currentColor"},null)])}}),j=e.defineComponent({name:"ItalicIcon",setup(t,{attrs:o}){return()=>e.createVNode("svg",e.mergeProps({width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},o),[e.createVNode("path",{d:"M15.0222 3H19C19.5523 3 20 3.44772 20 4C20 4.55228 19.5523 5 19 5H15.693L10.443 19H14C14.5523 19 15 19.4477 15 20C15 20.5523 14.5523 21 14 21H9.02418C9.00802 21.0004 8.99181 21.0004 8.97557 21H5C4.44772 21 4 20.5523 4 20C4 19.4477 4.44772 19 5 19H8.30704L13.557 5H10C9.44772 5 9 4.55228 9 4C9 3.44772 9.44772 3 10 3H14.9782C14.9928 2.99968 15.0075 2.99967 15.0222 3Z",fill:"currentColor"},null)])}}),_=e.defineComponent({name:"StrikeIcon",setup(t,{attrs:o}){return()=>e.createVNode("svg",e.mergeProps({width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},o),[e.createVNode("path",{d:"M9.00039 3H16.0001C16.5524 3 17.0001 3.44772 17.0001 4C17.0001 4.55229 16.5524 5 16.0001 5H9.00011C8.68006 4.99983 8.36412 5.07648 8.07983 5.22349C7.79555 5.37051 7.55069 5.5836 7.36585 5.84487C7.181 6.10614 7.06155 6.40796 7.01754 6.72497C6.97352 7.04198 7.00623 7.36492 7.11292 7.66667C7.29701 8.18737 7.02414 8.75872 6.50344 8.94281C5.98274 9.1269 5.4114 8.85403 5.2273 8.33333C5.01393 7.72984 4.94851 7.08396 5.03654 6.44994C5.12456 5.81592 5.36346 5.21229 5.73316 4.68974C6.10285 4.1672 6.59256 3.74101 7.16113 3.44698C7.72955 3.15303 8.36047 2.99975 9.00039 3Z",fill:"currentColor"},null),e.createVNode("path",{d:"M18 13H20C20.5523 13 21 12.5523 21 12C21 11.4477 20.5523 11 20 11H4C3.44772 11 3 11.4477 3 12C3 12.5523 3.44772 13 4 13H14C14.7956 13 15.5587 13.3161 16.1213 13.8787C16.6839 14.4413 17 15.2044 17 16C17 16.7956 16.6839 17.5587 16.1213 18.1213C15.5587 18.6839 14.7956 19 14 19H6C5.44772 19 5 19.4477 5 20C5 20.5523 5.44772 21 6 21H14C15.3261 21 16.5979 20.4732 17.5355 19.5355C18.4732 18.5979 19 17.3261 19 16C19 14.9119 18.6453 13.8604 18 13Z",fill:"currentColor"},null)])}}),q=e.defineComponent({name:"UnderlineIcon",setup(t,{attrs:o}){return()=>e.createVNode("svg",e.mergeProps({width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},o),[e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M7 4C7 3.44772 6.55228 3 6 3C5.44772 3 5 3.44772 5 4V10C5 11.8565 5.7375 13.637 7.05025 14.9497C8.36301 16.2625 10.1435 17 12 17C13.8565 17 15.637 16.2625 16.9497 14.9497C18.2625 13.637 19 11.8565 19 10V4C19 3.44772 18.5523 3 18 3C17.4477 3 17 3.44772 17 4V10C17 11.3261 16.4732 12.5979 15.5355 13.5355C14.5979 14.4732 13.3261 15 12 15C10.6739 15 9.40215 14.4732 8.46447 13.5355C7.52678 12.5979 7 11.3261 7 10V4ZM4 19C3.44772 19 3 19.4477 3 20C3 20.5523 3.44772 21 4 21H20C20.5523 21 21 20.5523 21 20C21 19.4477 20.5523 19 20 19H4Z",fill:"currentColor"},null)])}}),ae=e.defineComponent({name:"BubbleMenuBar",setup(){const t=e.inject("editor"),o=e.inject("readonly");return()=>t?.value?e.createVNode(ee.BubbleMenu,{editor:t.value,class:"bubble-menu",options:{placement:"top",offset:{mainAxis:8}},shouldShow:n=>{if(o?.value)return!1;const{editor:l,from:r,to:a}=n;return!(r===a||l.isActive("image")||l.isActive("table"))}},{default:()=>[e.createVNode("div",{class:"bubble-menu-content"},[e.createVNode(V,{icon:U,tooltip:"粗体",isActive:t.value.isActive("bold"),onClick:()=>t.value?.chain().focus().toggleBold().run()},null),e.createVNode(V,{icon:j,tooltip:"斜体",isActive:t.value.isActive("italic"),onClick:()=>t.value?.chain().focus().toggleItalic().run()},null),e.createVNode(V,{icon:_,tooltip:"删除线",isActive:t.value.isActive("strike"),onClick:()=>t.value?.chain().focus().toggleStrike().run()},null),e.createVNode(V,{icon:q,tooltip:"下划线",isActive:t.value.isActive("underline"),onClick:()=>t.value?.chain().focus().toggleUnderline().run()},null)])]}):null}}),ie=e.defineComponent({name:"TiptapEditor",props:{modelValue:{type:String,default:""},placeholder:{type:String,default:"请输入内容..."},readonly:{type:Boolean,default:!1},upload:{type:Function,default:void 0},features:{type:Array,default:()=>[]}},emits:["update:modelValue"],setup(t,{emit:o}){const n=e.computed(()=>t.readonly??!1);e.provide("readonly",n);const l=t.features.map(a=>({plugin:a,result:a.install({readonly:n,provide:(m,C)=>e.provide(m,C),upload:t.upload})})),r=E.useEditor({content:t.modelValue,editable:!t.readonly,extensions:[X.configure({codeBlock:!1,link:{openOnClick:!1,enableClickSelection:!0}}),Y.Placeholder.configure({placeholder:t.placeholder}),Q.TextAlign.configure({types:["heading","paragraph"]}),F.TaskList,F.TaskItem.configure({nested:!0}),...l.flatMap(({result:a})=>a.extensions)],onUpdate:({editor:a})=>{o("update:modelValue",a.getHTML())}});return e.provide("editor",r),e.watch(()=>t.modelValue,a=>{r.value&&a!==r.value.getHTML()&&r.value.commands.setContent(a,{emitUpdate:!1})}),e.watch(()=>t.readonly,a=>{r.value?.setEditable(!a)}),()=>e.createVNode("div",{class:"tiptap-editor"},[!t.readonly&&e.createVNode("div",{class:"tiptap-toolbar"},[l.map(({plugin:a})=>{const m=a.toolbarComponent;return m?e.createVNode(m,{key:a.name},null):null})]),e.createVNode(E.EditorContent,{class:"tiptap-content",editor:r.value},null),e.createVNode(ae,null,null),l.map(({plugin:a,result:m})=>{const C=m.controlComponent;return C?e.createVNode(C,{key:`${a.name}-control`},null):null})])}}),O=te.Image.extend({addAttributes(){return{...this.parent?.(),align:{default:"left",parseHTML:t=>t.getAttribute("data-align")??"left",renderHTML:t=>({"data-align":t.align})}}},addProseMirrorPlugins(){const t=this.name;return[new D.Plugin({props:{decorations(o){const n=[];return o.doc.descendants((l,r)=>{l.type.name===t&&l.attrs.align&&n.push(R.Decoration.node(r,r+l.nodeSize,{"data-align":l.attrs.align}))}),R.DecorationSet.create(o.doc,n)}}})]}}),ce=e.defineComponent({name:"UndoIcon",setup(t,{attrs:o}){return()=>e.createVNode("svg",e.mergeProps({width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},o),[e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M9.70711 3.70711C10.0976 3.31658 10.0976 2.68342 9.70711 2.29289C9.31658 1.90237 8.68342 1.90237 8.29289 2.29289L3.29289 7.29289C2.90237 7.68342 2.90237 8.31658 3.29289 8.70711L8.29289 13.7071C8.68342 14.0976 9.31658 14.0976 9.70711 13.7071C10.0976 13.3166 10.0976 12.6834 9.70711 12.2929L6.41421 9H14.5C15.0909 9 15.6761 9.1164 16.2221 9.34254C16.768 9.56869 17.2641 9.90016 17.682 10.318C18.0998 10.7359 18.4313 11.232 18.6575 11.7779C18.8836 12.3239 19 12.9091 19 13.5C19 14.0909 18.8836 14.6761 18.6575 15.2221C18.4313 15.768 18.0998 16.2641 17.682 16.682C17.2641 17.0998 16.768 17.4313 16.2221 17.6575C15.6761 17.8836 15.0909 18 14.5 18H11C10.4477 18 10 18.4477 10 19C10 19.5523 10.4477 20 11 20H14.5C15.3536 20 16.1988 19.8319 16.9874 19.5052C17.7761 19.1786 18.4926 18.6998 19.0962 18.0962C19.6998 17.4926 20.1786 16.7761 20.5052 15.9874C20.8319 15.1988 21 14.3536 21 13.5C21 12.6464 20.8319 11.8012 20.5052 11.0126C20.1786 10.2239 19.6998 9.50739 19.0962 8.90381C18.4926 8.30022 17.7761 7.82144 16.9874 7.49478C16.1988 7.16813 15.3536 7 14.5 7H6.41421L9.70711 3.70711Z",fill:"currentColor"},null)])}}),de=e.defineComponent({name:"RedoIcon",setup(t,{attrs:o}){return()=>e.createVNode("svg",e.mergeProps({width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},o),[e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M15.7071 2.29289C15.3166 1.90237 14.6834 1.90237 14.2929 2.29289C13.9024 2.68342 13.9024 3.31658 14.2929 3.70711L17.5858 7H9.5C7.77609 7 6.12279 7.68482 4.90381 8.90381C3.68482 10.1228 3 11.7761 3 13.5C3 14.3536 3.16813 15.1988 3.49478 15.9874C3.82144 16.7761 4.30023 17.4926 4.90381 18.0962C6.12279 19.3152 7.77609 20 9.5 20H13C13.5523 20 14 19.5523 14 19C14 18.4477 13.5523 18 13 18H9.5C8.30653 18 7.16193 17.5259 6.31802 16.682C5.90016 16.2641 5.56869 15.768 5.34254 15.2221C5.1164 14.6761 5 14.0909 5 13.5C5 12.3065 5.47411 11.1619 6.31802 10.318C7.16193 9.47411 8.30653 9 9.5 9H17.5858L14.2929 12.2929C13.9024 12.6834 13.9024 13.3166 14.2929 13.7071C14.6834 14.0976 15.3166 14.0976 15.7071 13.7071L20.7071 8.70711C21.0976 8.31658 21.0976 7.68342 20.7071 7.29289L15.7071 2.29289Z",fill:"currentColor"},null)])}}),se={name:"undo-redo",install:()=>({extensions:[]}),toolbarComponent:e.defineComponent({name:"UndoRedoButton",setup(){const t=e.inject("editor"),o=e.computed(()=>t?.value?.can().undo()??!1),n=e.computed(()=>t?.value?.can().redo()??!1);return()=>e.createVNode("div",null,[e.createVNode(V,{icon:ce,tooltip:"撤销",disabled:!o.value,onClick:()=>t?.value?.chain().focus().undo().run()},null),e.createVNode(V,{icon:de,tooltip:"重做",disabled:!n.value,onClick:()=>t?.value?.chain().focus().redo().run()},null)])}})},ue=e.defineComponent({name:"LinkIcon",setup(t,{attrs:o}){return()=>e.createVNode("svg",e.mergeProps({width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},o),[e.createVNode("path",{d:"M16.9958 1.06669C15.4226 1.05302 13.907 1.65779 12.7753 2.75074L12.765 2.76086L11.045 4.47086C10.6534 4.86024 10.6515 5.49341 11.0409 5.88507C11.4303 6.27673 12.0634 6.27858 12.4551 5.88919L14.1697 4.18456C14.9236 3.45893 15.9319 3.05752 16.9784 3.06662C18.0272 3.07573 19.0304 3.49641 19.772 4.23804C20.5137 4.97967 20.9344 5.98292 20.9435 7.03171C20.9526 8.07776 20.5515 9.08563 19.8265 9.83941L16.833 12.8329C16.4274 13.2386 15.9393 13.5524 15.4019 13.7529C14.8645 13.9533 14.2903 14.0359 13.7181 13.9949C13.146 13.9539 12.5894 13.7904 12.0861 13.5154C11.5827 13.2404 11.1444 12.8604 10.8008 12.401C10.47 11.9588 9.84333 11.8685 9.40108 12.1993C8.95883 12.5301 8.86849 13.1568 9.1993 13.599C9.71464 14.288 10.3721 14.858 11.1272 15.2705C11.8822 15.683 12.7171 15.9283 13.5753 15.9898C14.4334 16.0513 15.2948 15.9274 16.1009 15.6267C16.907 15.326 17.639 14.8555 18.2473 14.247L21.2472 11.2471L21.2593 11.2347C22.3523 10.1031 22.9571 8.58751 22.9434 7.01433C22.9297 5.44115 22.2987 3.93628 21.1863 2.82383C20.0738 1.71138 18.5689 1.08036 16.9958 1.06669Z",fill:"currentColor"},null),e.createVNode("path",{d:"M10.4247 8.0102C9.56657 7.94874 8.70522 8.07256 7.89911 8.37326C7.09305 8.67395 6.36096 9.14458 5.75272 9.753L2.75285 12.7529L2.74067 12.7653C1.64772 13.8969 1.04295 15.4125 1.05662 16.9857C1.07029 18.5589 1.70131 20.0637 2.81376 21.1762C3.9262 22.2886 5.43108 22.9196 7.00426 22.9333C8.57744 22.947 10.0931 22.3422 11.2247 21.2493L11.2371 21.2371L12.9471 19.5271C13.3376 19.1366 13.3376 18.5034 12.9471 18.1129C12.5565 17.7223 11.9234 17.7223 11.5328 18.1129L9.82932 19.8164C9.07555 20.5414 8.06768 20.9425 7.02164 20.9334C5.97285 20.9243 4.9696 20.5036 4.22797 19.762C3.48634 19.0203 3.06566 18.0171 3.05655 16.9683C3.04746 15.9222 3.44851 14.9144 4.17355 14.1606L7.16719 11.167C7.5727 10.7613 8.06071 10.4476 8.59811 10.2471C9.13552 10.0467 9.70976 9.96412 10.2819 10.0051C10.854 10.0461 11.4106 10.2096 11.9139 10.4846C12.4173 10.7596 12.8556 11.1397 13.1992 11.599C13.53 12.0412 14.1567 12.1316 14.5989 11.8007C15.0412 11.4699 15.1315 10.8433 14.8007 10.401C14.2854 9.71205 13.6279 9.14198 12.8729 8.72948C12.1178 8.31697 11.2829 8.07166 10.4247 8.0102Z",fill:"currentColor"},null)])}}),pe=e.defineComponent({name:"CornerDownLeftIcon",setup(t,{attrs:o}){return()=>e.createVNode("svg",e.mergeProps({width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",xmlns:"http://www.w3.org/2000/svg"},o),[e.createVNode("polyline",{points:"9 10 4 15 9 20"},null),e.createVNode("path",{d:"M20 4v7a4 4 0 0 1-4 4H4"},null)])}}),Ce=e.defineComponent({name:"ExternalLinkIcon",setup(t,{attrs:o}){return()=>e.createVNode("svg",e.mergeProps({width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",xmlns:"http://www.w3.org/2000/svg"},o),[e.createVNode("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"},null),e.createVNode("polyline",{points:"15 3 21 3 21 9"},null),e.createVNode("line",{x1:"10",y1:"14",x2:"21",y2:"3"},null)])}}),fe=e.defineComponent({name:"TrashIcon",setup(t,{attrs:o}){return()=>e.createVNode("svg",e.mergeProps({width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",xmlns:"http://www.w3.org/2000/svg"},o),[e.createVNode("polyline",{points:"3 6 5 6 21 6"},null),e.createVNode("path",{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"},null)])}}),me=e.defineComponent({name:"LinkPopover",setup(){const t=e.inject("editor"),o=e.ref(!1),n=e.ref("");let l=!1;e.watch(()=>t?.value?.isActive("link"),i=>{l||i&&(n.value=t?.value?.getAttributes("link").href??"",e.nextTick(()=>{o.value=!0}))});const r=()=>{const i=t?.value;if(!i||!n.value)return;l=!0;const{empty:f}=i.state.selection;let w=i.chain().focus().extendMarkRange("link").setLink({href:n.value});f&&(w=w.insertContent({type:"text",text:n.value})),w.run(),o.value=!1,e.nextTick(()=>{l=!1})},a=()=>{const i=t?.value;i&&(l=!0,i.chain().focus().extendMarkRange("link").unsetLink().run(),n.value="",o.value=!1,e.nextTick(()=>{l=!1}))},m=()=>{const i=t?.value?.getAttributes("link").href;i&&window.open(i,"_blank","noopener,noreferrer")},C=i=>{i.key==="Enter"&&(i.preventDefault(),r())},d=i=>{i&&(n.value=t?.value?.getAttributes("link").href??""),o.value=i},k=i=>{n.value=i};return()=>{const i=t?.value?.isActive("link")??!1;return e.createVNode(p.ElPopover,{visible:o.value,"onUpdate:visible":d,placement:"bottom",width:300,trigger:"click",showArrow:!1,popperClass:"link-popover-popper",offset:6},{reference:()=>e.createVNode("span",null,[e.createVNode(V,{tooltip:"链接",icon:ue,class:["tiptap-button",{"is-active":i}]},null)]),default:()=>e.createVNode("div",{class:"link-popover-inner"},[e.createVNode(p.ElInput,{modelValue:n.value,"onUpdate:modelValue":k,type:"url",placeholder:"请输入链接...",size:"small",autofocus:!0,onKeydown:C},null),e.createVNode("div",{class:"link-popover-actions"},[e.createVNode(p.ElTooltip,{content:"确认",showArrow:!1,offset:4},{default:()=>[e.createVNode(p.ElButton,{text:!0,icon:pe,disabled:!n.value,onClick:r},null)]}),e.createVNode(p.ElTooltip,{content:"在新标签页打开",showArrow:!1,offset:4},{default:()=>[e.createVNode(p.ElButton,{text:!0,icon:Ce,disabled:!n.value&&!i,onClick:m},null)]}),e.createVNode(p.ElTooltip,{content:"移除链接",showArrow:!1,offset:4},{default:()=>[e.createVNode(p.ElButton,{text:!0,icon:fe,disabled:!i,onClick:a},null)]})])])})}}}),he={name:"text-style",install:()=>({extensions:[]}),toolbarComponent:e.defineComponent({name:"TextStyleButton",setup(){const t=e.inject("editor");return()=>e.createVNode("div",null,[e.createVNode(V,{icon:U,tooltip:"粗体",isActive:t?.value?.isActive("bold"),onClick:()=>t?.value?.chain().focus().toggleBold().run()},null),e.createVNode(V,{icon:j,tooltip:"斜体",isActive:t?.value?.isActive("italic"),onClick:()=>t?.value?.chain().focus().toggleItalic().run()},null),e.createVNode(V,{icon:_,tooltip:"删除线",isActive:t?.value?.isActive("strike"),onClick:()=>t?.value?.chain().focus().toggleStrike().run()},null),e.createVNode(V,{icon:q,tooltip:"下划线",isActive:t?.value?.isActive("underline"),onClick:()=>t?.value?.chain().focus().toggleUnderline().run()},null),e.createVNode(me,null,null)])}})},z=e.defineComponent({name:"AlignLeftIcon",setup(t,{attrs:o}){return()=>e.createVNode("svg",e.mergeProps({width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},o),[e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"},null),e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M2 12C2 11.4477 2.44772 11 3 11H15C15.5523 11 16 11.4477 16 12C16 12.5523 15.5523 13 15 13H3C2.44772 13 2 12.5523 2 12Z",fill:"currentColor"},null),e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M2 18C2 17.4477 2.44772 17 3 17H17C17.5523 17 18 17.4477 18 18C18 18.5523 17.5523 19 17 19H3C2.44772 19 2 18.5523 2 18Z",fill:"currentColor"},null)])}}),$=e.defineComponent({name:"AlignCenterIcon",setup(t,{attrs:o}){return()=>e.createVNode("svg",e.mergeProps({width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},o),[e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"},null),e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M6 12C6 11.4477 6.44772 11 7 11H17C17.5523 11 18 11.4477 18 12C18 12.5523 17.5523 13 17 13H7C6.44772 13 6 12.5523 6 12Z",fill:"currentColor"},null),e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M4 18C4 17.4477 4.44772 17 5 17H19C19.5523 17 20 17.4477 20 18C20 18.5523 19.5523 19 19 19H5C4.44772 19 4 18.5523 4 18Z",fill:"currentColor"},null)])}}),P=e.defineComponent({name:"AlignRightIcon",setup(t,{attrs:o}){return()=>e.createVNode("svg",e.mergeProps({width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},o),[e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"},null),e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M8 12C8 11.4477 8.44772 11 9 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H9C8.44772 13 8 12.5523 8 12Z",fill:"currentColor"},null),e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M6 18C6 17.4477 6.44772 17 7 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H7C6.44772 19 6 18.5523 6 18Z",fill:"currentColor"},null)])}}),ge=e.defineComponent({name:"AlignJustifyIcon",setup(t,{attrs:o}){return()=>e.createVNode("svg",e.mergeProps({width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},o),[e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"},null),e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M2 12C2 11.4477 2.44772 11 3 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H3C2.44772 13 2 12.5523 2 12Z",fill:"currentColor"},null),e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M2 18C2 17.4477 2.44772 17 3 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H3C2.44772 19 2 18.5523 2 18Z",fill:"currentColor"},null)])}}),Ve={name:"text-align",install:()=>({extensions:[]}),toolbarComponent:e.defineComponent({name:"TextAlignButton",setup(){const t=e.inject("editor");return()=>e.createVNode("div",null,[e.createVNode(V,{icon:z,tooltip:"左边对齐",isActive:t?.value?.isActive({textAlign:"left"}),onClick:()=>t?.value?.chain().focus().setTextAlign("left").run()},null),e.createVNode(V,{icon:$,tooltip:"中间对齐",isActive:t?.value?.isActive({textAlign:"center"}),onClick:()=>t?.value?.chain().focus().setTextAlign("center").run()},null),e.createVNode(V,{icon:P,tooltip:"右边对齐",isActive:t?.value?.isActive({textAlign:"right"}),onClick:()=>t?.value?.chain().focus().setTextAlign("right").run()},null),e.createVNode(V,{icon:ge,tooltip:"两端对齐",isActive:t?.value?.isActive({textAlign:"justify"}),onClick:()=>t?.value?.chain().focus().setTextAlign("justify").run()},null)])}})},we=e.defineComponent({name:"ListIcon",setup(t,{attrs:o}){return()=>e.createVNode("svg",e.mergeProps({width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},o),[e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M7 6C7 5.44772 7.44772 5 8 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H8C7.44772 7 7 6.55228 7 6Z",fill:"currentColor"},null),e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M7 12C7 11.4477 7.44772 11 8 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H8C7.44772 13 7 12.5523 7 12Z",fill:"currentColor"},null),e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M7 18C7 17.4477 7.44772 17 8 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H8C7.44772 19 7 18.5523 7 18Z",fill:"currentColor"},null),e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H3.01C3.56228 5 4.01 5.44772 4.01 6C4.01 6.55228 3.56228 7 3.01 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"},null),e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M2 12C2 11.4477 2.44772 11 3 11H3.01C3.56228 11 4.01 11.4477 4.01 12C4.01 12.5523 3.56228 13 3.01 13H3C2.44772 13 2 12.5523 2 12Z",fill:"currentColor"},null),e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M2 18C2 17.4477 2.44772 17 3 17H3.01C3.56228 17 4.01 17.4477 4.01 18C4.01 18.5523 3.56228 19 3.01 19H3C2.44772 19 2 18.5523 2 18Z",fill:"currentColor"},null)])}}),Ne=e.defineComponent({name:"ListOrderedIcon",setup(t,{attrs:o}){return()=>e.createVNode("svg",e.mergeProps({width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},o),[e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M9 6C9 5.44772 9.44772 5 10 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H10C9.44772 7 9 6.55228 9 6Z",fill:"currentColor"},null),e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M9 12C9 11.4477 9.44772 11 10 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H10C9.44772 13 9 12.5523 9 12Z",fill:"currentColor"},null),e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M9 18C9 17.4477 9.44772 17 10 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H10C9.44772 19 9 18.5523 9 18Z",fill:"currentColor"},null),e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M3 6C3 5.44772 3.44772 5 4 5H5C5.55228 5 6 5.44772 6 6V10C6 10.5523 5.55228 11 5 11C4.44772 11 4 10.5523 4 10V7C3.44772 7 3 6.55228 3 6Z",fill:"currentColor"},null),e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M3 10C3 9.44772 3.44772 9 4 9H6C6.55228 9 7 9.44772 7 10C7 10.5523 6.55228 11 6 11H4C3.44772 11 3 10.5523 3 10Z",fill:"currentColor"},null),e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M5.82219 13.0431C6.54543 13.4047 6.99997 14.1319 6.99997 15C6.99997 15.5763 6.71806 16.0426 6.48747 16.35C6.31395 16.5814 6.1052 16.8044 5.91309 17H5.99997C6.55226 17 6.99997 17.4477 6.99997 18C6.99997 18.5523 6.55226 19 5.99997 19H3.99997C3.44769 19 2.99997 18.5523 2.99997 18C2.99997 17.4237 3.28189 16.9575 3.51247 16.65C3.74323 16.3424 4.03626 16.0494 4.26965 15.8161C4.27745 15.8083 4.2852 15.8006 4.29287 15.7929C4.55594 15.5298 4.75095 15.3321 4.88748 15.15C4.96287 15.0495 4.99021 14.9922 4.99911 14.9714C4.99535 14.9112 4.9803 14.882 4.9739 14.8715C4.96613 14.8588 4.95382 14.845 4.92776 14.8319C4.87723 14.8067 4.71156 14.7623 4.44719 14.8944C3.95321 15.1414 3.35254 14.9412 3.10555 14.4472C2.85856 13.9533 3.05878 13.3526 3.55276 13.1056C4.28839 12.7378 5.12272 12.6934 5.82219 13.0431Z",fill:"currentColor"},null)])}}),xe=e.defineComponent({name:"ListTodoIcon",setup(t,{attrs:o}){return()=>e.createVNode("svg",e.mergeProps({width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},o),[e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M2 6C2 4.89543 2.89543 4 4 4H8C9.10457 4 10 4.89543 10 6V10C10 11.1046 9.10457 12 8 12H4C2.89543 12 2 11.1046 2 10V6ZM8 6H4V10H8V6Z",fill:"currentColor"},null),e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M9.70711 14.2929C10.0976 14.6834 10.0976 15.3166 9.70711 15.7071L5.70711 19.7071C5.31658 20.0976 4.68342 20.0976 4.29289 19.7071L2.29289 17.7071C1.90237 17.3166 1.90237 16.6834 2.29289 16.2929C2.68342 15.9024 3.31658 15.9024 3.70711 16.2929L5 17.5858L8.29289 14.2929C8.68342 13.9024 9.31658 13.9024 9.70711 14.2929Z",fill:"currentColor"},null),e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M12 6C12 5.44772 12.4477 5 13 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H13C12.4477 7 12 6.55228 12 6Z",fill:"currentColor"},null),e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M12 12C12 11.4477 12.4477 11 13 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H13C12.4477 13 12 12.5523 12 12Z",fill:"currentColor"},null),e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M12 18C12 17.4477 12.4477 17 13 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H13C12.4477 19 12 18.5523 12 18Z",fill:"currentColor"},null)])}}),ke={name:"list",install:()=>({extensions:[]}),toolbarComponent:e.defineComponent({name:"ListButton",setup(){const t=e.inject("editor");return()=>e.createVNode("div",null,[e.createVNode(V,{icon:we,tooltip:"无序列表",isActive:t?.value?.isActive("bulletList"),onClick:()=>t?.value?.chain().focus().toggleBulletList().run()},null),e.createVNode(V,{icon:Ne,tooltip:"有序列表",isActive:t?.value?.isActive("orderedList"),onClick:()=>t?.value?.chain().focus().toggleOrderedList().run()},null),e.createVNode(V,{icon:xe,tooltip:"任务列表",isActive:t?.value?.isActive("taskList"),onClick:()=>t?.value?.chain().focus().toggleTaskList().run()},null)])}})},be=e.defineComponent({name:"CodeBlockIcon",setup(t,{attrs:o}){return()=>e.createVNode("svg",e.mergeProps({width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",xmlns:"http://www.w3.org/2000/svg"},o),[e.createVNode("polyline",{points:"16 18 22 12 16 6"},null),e.createVNode("polyline",{points:"8 6 2 12 8 18"},null)])}}),Be=e.defineComponent({name:"CodeBlockButton",setup(){const t=e.inject("editor");return()=>e.createVNode(V,{icon:be,tooltip:"代码块",isActive:t?.value?.isActive("codeBlock"),onClick:()=>t?.value?.chain().focus().toggleCodeBlock().run()},null)}}),ve=Z.createLowlight(Z.common),He={name:"code-block",install:()=>({extensions:[oe.CodeBlockLowlight.configure({lowlight:ve,defaultLanguage:"plaintext"})]}),toolbarComponent:Be},ye=e.defineComponent({name:"TableIcon",setup(t,{attrs:o}){return()=>e.createVNode("svg",e.mergeProps({width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},o),[e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M2 5C2 3.34315 3.34315 2 5 2H19C20.6569 2 22 3.34315 22 5V19C22 20.6569 20.6569 22 19 22H5C3.34315 22 2 20.6569 2 19V5ZM4 5C4 4.44772 4.44772 4 5 4H11V8H4V5ZM4 10H11V14H4V10ZM20 14V10H13V14H20ZM13 16H20V19C20 19.5523 19.5523 20 19 20H13V16ZM11 16V20H5C4.44772 20 4 19.5523 4 19V16H11ZM13 8H20V5C20 4.44772 19.5523 4 19 4H13V8Z",fill:"currentColor"},null)])}}),Ae=8,Ee=8,Me=e.defineComponent({name:"TableButton",setup(){const t=e.inject("editor"),o=e.ref(!1),n=e.ref(0),l=e.ref(0),r=(C,d)=>{n.value=C,l.value=d},a=()=>{n.value=0,l.value=0},m=(C,d)=>{t?.value?.chain().focus().insertTable({rows:d,cols:C,withHeaderRow:!0}).run(),o.value=!1};return()=>e.createVNode(p.ElPopover,{visible:o.value,"onUpdate:visible":C=>o.value=C,trigger:"click",placement:"bottom-start",popperClass:"table-picker-popper",width:"auto",showArrow:!1},{reference:()=>e.createVNode("span",null,[e.createVNode(p.ElTooltip,{content:"表格",showArrow:!1,offset:6,disabled:o.value},{default:()=>[e.createVNode(p.ElButton,{text:!0,class:["tiptap-button",{"is-active":o.value}]},{default:()=>[e.createVNode(ye,{class:"tiptap-button-icon"},null)]})]})]),default:()=>e.createVNode("div",{class:"table-picker"},[e.createVNode("div",{class:"table-picker-grid",onMouseleave:a},[Array.from({length:Ee},(C,d)=>e.createVNode("div",{key:d,class:"table-picker-row"},[Array.from({length:Ae},(k,i)=>e.createVNode("div",{key:i,class:["table-picker-cell",{"is-active":i<n.value&&d<l.value}],onMouseenter:()=>r(i+1,d+1),onClick:()=>m(i+1,d+1)},null))]))]),e.createVNode("div",{class:"table-picker-footer"},[e.createVNode("div",{class:"table-picker-counter"},[e.createVNode("span",null,[e.createTextVNode("列")]),e.createVNode("span",null,[n.value||1])]),e.createVNode("span",{class:"table-picker-x"},[e.createTextVNode("x")]),e.createVNode("div",{class:"table-picker-counter"},[e.createVNode("span",null,[e.createTextVNode("行")]),e.createVNode("span",null,[l.value||1])])])])})}});function Ie(t){let o=t.nodeType===Node.TEXT_NODE?t.parentElement:t;for(;o&&o instanceof HTMLElement;){if(o.tagName==="TD"||o.tagName==="TH")return o;o=o.parentElement}return null}function Te(t){if(!t.isActive("tableCell")&&!t.isActive("tableHeader"))return null;const{node:o}=t.view.domAtPos(t.state.selection.from),n=Ie(o);if(!n)return null;const l=n.parentElement,r=l.parentElement,a=n.closest("table");if(!a)return null;const m=Array.from(l.children).indexOf(n),C=Array.from(r.children).indexOf(l),d=l.children.length,k=r.children.length,i=n.getBoundingClientRect(),f=a.getBoundingClientRect(),w=t.view.dom.closest(".tiptap-editor").getBoundingClientRect();return{cell:n,colIndex:m,rowIndex:C,totalCols:d,totalRows:k,cellRect:i,tableRect:f,editorRect:w}}function W(t){const{state:o}=t,n=o.selection.from;let l=null;return o.doc.nodesBetween(0,o.doc.content.size,(r,a)=>{if(r.type.name==="table"&&a<=n&&n<=a+r.nodeSize)return l={node:r,pos:a},!1}),l}const Le=e.defineComponent({name:"TableControls",setup(){const t=e.inject("editor"),o=e.inject("readonly"),n=e.ref(null),l=e.ref(null);function r(){const i=t?.value;if(l.value&&(l.value.classList.remove("tcc-cell-focused"),l.value=null),!i){n.value=null;return}const f=Te(i);n.value=f,f&&(f.cell.classList.add("tcc-cell-focused"),l.value=f.cell)}e.watchEffect(i=>{const f=t?.value;f&&(f.on("selectionUpdate",r),f.on("transaction",r),i(()=>{f.off("selectionUpdate",r),f.off("transaction",r),l.value&&(l.value.classList.remove("tcc-cell-focused"),l.value=null)}))});function a(i){const f=t?.value;if(!f||!n.value)return;const{colIndex:w,totalCols:v}=n.value,N=i==="left"?w-1:w+1;if(N<0||N>=v)return;const c=W(f);if(!c)return;const{node:s,pos:h}=c,g=[];s.forEach(H=>{if(H.type.name!=="tableRow"){g.push(H);return}const b=[];H.forEach(L=>b.push(L));const T=b[w];b[w]=b[N],b[N]=T,g.push(H.type.create(H.attrs,b,H.marks))});const x=s.type.create(s.attrs,g,s.marks),A=f.state.tr.replaceWith(h,h+s.nodeSize,x);f.view.dispatch(A)}function m(i){const f=t?.value;if(!f||!n.value)return;const{rowIndex:w,totalRows:v}=n.value,N=i==="up"?w-1:w+1;if(N<0||N>=v)return;const c=W(f);if(!c)return;const{node:s,pos:h}=c,g=[];s.forEach(b=>g.push(b));const x=g[w];g[w]=g[N],g[N]=x;const A=s.type.create(s.attrs,g,s.marks),H=f.state.tr.replaceWith(h,h+s.nodeSize,A);f.view.dispatch(H)}const C=()=>e.createVNode("svg",{width:"16",height:"4",viewBox:"0 0 16 4",fill:"currentColor"},[e.createVNode("circle",{cx:"2",cy:"2",r:"1.5"},null),e.createVNode("circle",{cx:"8",cy:"2",r:"1.5"},null),e.createVNode("circle",{cx:"14",cy:"2",r:"1.5"},null)]),d=()=>e.createVNode("svg",{width:"4",height:"16",viewBox:"0 0 4 16",fill:"currentColor"},[e.createVNode("circle",{cx:"2",cy:"2",r:"1.5"},null),e.createVNode("circle",{cx:"2",cy:"8",r:"1.5"},null),e.createVNode("circle",{cx:"2",cy:"14",r:"1.5"},null)]),k=()=>e.createVNode("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round"},[e.createVNode("path",{d:"M5 1v8M1 5h8"},null)]);return()=>{if(o?.value)return null;const i=n.value;if(!i)return null;const{colIndex:f,rowIndex:w,totalCols:v,totalRows:N,cellRect:c,tableRect:s,editorRect:h}=i,g=s.top-h.top,x=s.left-h.left,A=s.right-h.left,H=s.bottom-h.top,b=c.left-h.left,T=c.top-h.top,L=c.width,K=c.height,Qe={position:"absolute",top:`${g-20}px`,left:`${b+L/2-18}px`},Ye={position:"absolute",top:`${T+K/2-18}px`,left:`${x-20}px`},et={position:"absolute",top:`${T+K/2-12}px`,left:`${A+6}px`},tt={position:"absolute",top:`${H+6}px`,left:`${b+L/2-12}px`},ot=f===0,G=f===v-1,nt=w===0,J=w===N-1,y=t?.value;return e.createVNode("div",{class:"table-cell-controls"},[e.createVNode(p.ElDropdown,{trigger:"click",placement:"bottom",style:Qe,onCommand:B=>{B==="move-left"?a("left"):B==="move-right"?a("right"):B==="insert-left"?y?.chain().focus().addColumnBefore().run():B==="insert-right"?y?.chain().focus().addColumnAfter().run():B==="delete"&&y?.chain().focus().deleteColumn().run()}},{default:()=>[e.createVNode("button",{class:"tcc-btn tcc-btn--col"},[e.createVNode(C,null,null)])],dropdown:()=>e.createVNode(p.ElDropdownMenu,null,{default:()=>[e.createVNode(p.ElDropdownItem,{command:"move-left",disabled:ot},{default:()=>[e.createTextVNode("移动列到左侧")]}),e.createVNode(p.ElDropdownItem,{command:"move-right",disabled:G},{default:()=>[e.createTextVNode("移动列到右侧")]}),e.createVNode(p.ElDropdownItem,{command:"insert-left"},{default:()=>[e.createTextVNode("在左侧插入一列")]}),e.createVNode(p.ElDropdownItem,{command:"insert-right"},{default:()=>[e.createTextVNode("在右侧插入一列")]}),e.createVNode(p.ElDropdownItem,{command:"delete",divided:!0},{default:()=>[e.createTextVNode("删除列")]})]})}),e.createVNode(p.ElDropdown,{trigger:"click",placement:"right",style:Ye,onCommand:B=>{B==="move-up"?m("up"):B==="move-down"?m("down"):B==="insert-above"?y?.chain().focus().addRowBefore().run():B==="insert-below"?y?.chain().focus().addRowAfter().run():B==="delete"&&y?.chain().focus().deleteRow().run()}},{default:()=>[e.createVNode("button",{class:"tcc-btn tcc-btn--row"},[e.createVNode(d,null,null)])],dropdown:()=>e.createVNode(p.ElDropdownMenu,null,{default:()=>[e.createVNode(p.ElDropdownItem,{command:"move-up",disabled:nt},{default:()=>[e.createTextVNode("上移")]}),e.createVNode(p.ElDropdownItem,{command:"move-down",disabled:J},{default:()=>[e.createTextVNode("下移")]}),e.createVNode(p.ElDropdownItem,{command:"insert-above"},{default:()=>[e.createTextVNode("在上方插入一行")]}),e.createVNode(p.ElDropdownItem,{command:"insert-below"},{default:()=>[e.createTextVNode("在下方插入一行")]}),e.createVNode(p.ElDropdownItem,{command:"delete",divided:!0},{default:()=>[e.createTextVNode("删除行")]})]})}),G&&e.createVNode("button",{class:"tcc-btn tcc-btn--add",style:et,onClick:()=>y?.chain().focus().addColumnAfter().run()},[e.createVNode(k,null,null)]),J&&e.createVNode("button",{class:"tcc-btn tcc-btn--add",style:tt,onClick:()=>y?.chain().focus().addRowAfter().run()},[e.createVNode(k,null,null)])])}}}),Fe={name:"table",install:()=>({extensions:[M.Table.configure({resizable:!0}),M.TableRow,M.TableHeader,M.TableCell],controlComponent:Le}),toolbarComponent:Me},De=e.defineComponent({name:"MathIcon",setup(t,{attrs:o}){return()=>e.createVNode("svg",e.mergeProps({width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},o),[e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M9 4.8c.1-.5.5-.8 1-.8h10a1 1 0 1 1 0 2h-9.2L8.3 19.2a1 1 0 0 1-1.7.4l-3.4-4.2a1 1 0 0 1 1.6-1.2l2 2.5L9 4.8Zm9.7 5.5c.4.4.4 1 0 1.4L17 13.5l1.8 1.8a1 1 0 1 1-1.4 1.4L15.5 15l-1.8 1.8a1 1 0 0 1-1.4-1.4l1.8-1.8-1.8-1.8a1 1 0 0 1 1.4-1.4l1.8 1.8 1.8-1.8a1 1 0 0 1 1.4 0Z",fill:"currentColor"},null)])}}),Re=e.defineComponent({name:"MathButton",setup(){const t=e.inject("editor"),o=e.inject("openMathDialog");return()=>e.createVNode(V,{icon:De,tooltip:"数学公式",isActive:t?.value?.isActive("inlineMath")||t?.value?.isActive("blockMath"),onClick:()=>o?.()},null)}}),Ze=e.defineComponent({name:"MathEditDialog",props:{visible:{type:Boolean,required:!0},latex:{type:String,required:!0},pos:{type:Number,default:null},type:{type:String,required:!0}},emits:["update:visible"],setup(t,{emit:o}){const n=e.inject("editor"),l=e.ref(""),r=e.ref("inline");e.watch(()=>t.latex,d=>{l.value=d},{immediate:!0}),e.watch(()=>t.type,d=>{r.value=d},{immediate:!0});const a=e.computed(()=>t.pos===null),m=e.computed(()=>l.value.trim()?le.renderToString(l.value,{displayMode:r.value==="block",throwOnError:!1}):""),C=()=>{const d=n?.value;if(!(!d||!l.value.trim())){if(a.value)r.value==="inline"?d.chain().focus().insertInlineMath({latex:l.value}).run():d.chain().focus().insertBlockMath({latex:l.value}).run();else if(r.value===t.type)t.type==="inline"?d.commands.updateInlineMath({latex:l.value,pos:t.pos}):d.commands.updateBlockMath({latex:l.value,pos:t.pos});else{const k=t.pos;t.type==="inline"?d.chain().focus().deleteInlineMath({pos:k}).insertBlockMath({latex:l.value}).run():d.chain().focus().deleteBlockMath({pos:k}).insertInlineMath({latex:l.value}).run()}o("update:visible",!1)}};return()=>e.createVNode(p.ElDialog,{modelValue:t.visible,title:a.value?"插入数学公式":"编辑数学公式",width:"520px","onUpdate:modelValue":d=>o("update:visible",d)},{default:()=>[e.createVNode("div",{class:"math-dialog"},[e.createVNode(p.ElRadioGroup,{modelValue:r.value,"onUpdate:modelValue":d=>{r.value=d}},{default:()=>[e.createVNode(p.ElRadioButton,{value:"inline"},{default:()=>[e.createTextVNode("行内公式")]}),e.createVNode(p.ElRadioButton,{value:"block"},{default:()=>[e.createTextVNode("块级公式")]})]}),e.createVNode(p.ElInput,{modelValue:l.value,type:"textarea",rows:3,placeholder:"请输入 LaTeX 公式,例如:E=mc^2","onUpdate:modelValue":d=>{l.value=d}},null),e.createVNode("div",{class:["math-preview",{"math-preview--empty":!m.value}]},[m.value?e.createVNode("div",{innerHTML:m.value},null):e.createVNode("span",{class:"math-preview__placeholder"},[e.createTextVNode("预览将在此处显示")])])])],footer:()=>e.createVNode(e.Fragment,null,[e.createVNode(p.ElButton,{onClick:()=>o("update:visible",!1)},{default:()=>[e.createTextVNode("取消")]}),e.createVNode(p.ElButton,{type:"primary",disabled:!l.value.trim(),onClick:C},{default:()=>[e.createTextVNode("确认")]})])})}}),Se={name:"math",toolbarComponent:Re,install(t){const o=e.ref(!1),n=e.ref(""),l=e.ref(null),r=e.ref("inline"),a=(C={})=>{t.readonly.value||(n.value=C.latex??"",l.value=C.pos??null,r.value=C.type??"inline",o.value=!0)};t.provide("openMathDialog",a);const m=e.defineComponent({name:"MathEditDialogWrapper",setup:()=>()=>e.h(Ze,{visible:o.value,latex:n.value,pos:l.value,type:r.value,"onUpdate:visible":C=>{o.value=C}})});return{extensions:[ne.Mathematics.configure({inlineOptions:{onClick:(C,d)=>a({latex:C.attrs.latex,pos:d,type:"inline"})},blockOptions:{onClick:(C,d)=>a({latex:C.attrs.latex,pos:d,type:"block"})}})],controlComponent:m}}},Ue=e.defineComponent({name:"ImageUploadView",props:E.nodeViewProps,setup(t){const o=e.computed(()=>t.node.attrs.accept),n=e.computed(()=>t.node.attrs.limit),l=e.computed(()=>t.node.attrs.maxSize),r=e.ref([]),a=e.ref(),m=e.ref(!1),C=async c=>{if(l.value>0&&c.size>l.value)return t.extension.options.onError?.(new Error(`文件大小超出限制 ${l.value/1024/1024}MB`)),null;const s=crypto.randomUUID();r.value.push({id:s,file:c,progress:0,status:"uploading"});try{const h=t.extension.options.upload;if(!h)throw new Error("未配置 upload 函数");const g=await h(c);if(!g)throw new Error("上传失败:未返回 URL");const x=r.value.find(A=>A.id===s);return x&&(x.status="success",x.progress=100),t.extension.options.onSuccess?.(g),g}catch(h){const g=r.value.find(x=>x.id===s);return g&&(g.status="error",g.progress=0),t.extension.options.onError?.(h instanceof Error?h:new Error("上传失败")),null}},d=async c=>{if(!c.length)return;if(c.length>n.value){t.extension.options.onError?.(new Error(`最多上传 ${n.value} 个文件`));return}const s=(await Promise.all(c.map(C))).filter(h=>!!h);if(s.length>0){const h=t.getPos();if(typeof h!="number")return;const g=s.map(x=>({type:"image",attrs:{src:x}}));t.editor.chain().focus().deleteRange({from:h,to:h+t.node.nodeSize}).insertContentAt(h,g).run()}},k=()=>{r.value.length===0&&a.value&&(a.value.value="",a.value.click())},i=c=>{const s=c.target.files;s&&d(Array.from(s))},f=c=>{c.preventDefault(),m.value=!0},w=c=>{c.currentTarget.contains(c.relatedTarget)||(m.value=!1)},v=c=>{c.preventDefault(),m.value=!1;const s=Array.from(c.dataTransfer?.files??[]);s.length&&d(s)},N=c=>{r.value=r.value.filter(s=>s.id!==c)};return()=>e.createVNode(E.NodeViewWrapper,{class:"tiptap-image-upload"},{default:()=>[e.createVNode("div",{onClick:k},[r.value.length?e.createVNode("div",{class:"tiptap-image-upload-previews"},[r.value.map(c=>e.createVNode("div",{key:c.id,class:"tiptap-image-upload-preview"},[c.status==="uploading"&&e.createVNode("div",{class:"tiptap-image-upload-progress",style:{width:`${c.progress}%`}},null),e.createVNode("div",{class:"tiptap-image-upload-preview-content"},[e.createVNode("span",{class:"tiptap-image-upload-text"},[c.file.name]),e.createVNode("span",{class:"tiptap-image-upload-subtext"},[c.status==="uploading"?`${c.progress}%`:c.status==="error"?"上传失败":"上传成功"]),e.createVNode("button",{class:"tiptap-image-upload-remove",onClick:s=>{s.stopPropagation(),N(c.id)}},[e.createTextVNode("×")])])]))]):e.createVNode("div",{class:["tiptap-image-upload-drag-area",{"drag-active":m.value}],onDragover:f,onDragleave:w,onDrop:v},[e.createVNode("div",{class:"tiptap-image-upload-content"},[e.createVNode("span",{class:"tiptap-image-upload-text"},[e.createVNode("em",null,[e.createTextVNode("点击上传")]),e.createTextVNode(" 或拖拽图片到此处")]),e.createVNode("span",{class:"tiptap-image-upload-subtext"},[e.createTextVNode("最多 "),n.value,e.createTextVNode(" 个文件"),l.value?`,每个不超过 ${l.value/1024/1024}MB`:""])])]),e.createVNode("input",{ref:a,type:"file",accept:o.value,multiple:n.value>1,onChange:i,onClick:c=>c.stopPropagation()},null)])]})}}),je=S.Node.create({name:"imageUpload",group:"block",draggable:!0,selectable:!0,atom:!0,addOptions(){return{type:"image",accept:"image/*",limit:1,maxSize:0,upload:t=>new Promise(o=>{const n=new FileReader;n.onloadend=()=>o(n.result),n.readAsDataURL(t)}),onError:void 0,onSuccess:void 0,HTMLAttributes:{}}},addAttributes(){return{accept:{default:this.options.accept},limit:{default:this.options.limit},maxSize:{default:this.options.maxSize}}},parseHTML(){return[{tag:'div[data-type="image-upload"]'}]},renderHTML({HTMLAttributes:t}){return["div",S.mergeAttributes({"data-type":"image-upload"},t)]},addNodeView(){return E.VueNodeViewRenderer(Ue)},addCommands(){return{setImageUploadNode:()=>({commands:t})=>t.insertContent({type:this.name})}},addKeyboardShortcuts(){return{Enter:({editor:t})=>{const{selection:o}=t.state,{nodeAfter:n}=o.$from;if(n?.type.name==="imageUpload"&&t.isActive("imageUpload")){const l=t.view.nodeDOM(o.$from.pos);if(l instanceof HTMLElement){const r=l.firstChild;if(r instanceof HTMLElement)return r.click(),!0}}return!1}}}}),_e=e.defineComponent({name:"ImagePlusIcon",setup(t,{attrs:o}){return()=>e.createVNode("svg",e.mergeProps({width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},o),[e.createVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M20 2C20 1.44772 19.5523 1 19 1C18.4477 1 18 1.44772 18 2V4H16C15.4477 4 15 4.44772 15 5C15 5.55228 15.4477 6 16 6H18V8C18 8.55228 18.4477 9 19 9C19.5523 9 20 8.55228 20 8V6H22C22.5523 6 23 5.55228 23 5C23 4.44772 22.5523 4 22 4H20V2ZM5 4C4.73478 4 4.48043 4.10536 4.29289 4.29289C4.10536 4.48043 4 4.73478 4 5V19C4 19.2652 4.10536 19.5196 4.29289 19.7071C4.48043 19.8946 4.73478 20 5 20H5.58579L14.379 11.2068C14.9416 10.6444 15.7045 10.3284 16.5 10.3284C17.2955 10.3284 18.0584 10.6444 18.621 11.2068L20 12.5858V12C20 11.4477 20.4477 11 21 11C21.5523 11 22 11.4477 22 12V14.998C22 14.9994 22 15.0007 22 15.002V19C22 19.7957 21.6839 20.5587 21.1213 21.1213C20.5587 21.6839 19.7957 22 19 22H6.00219C6.00073 22 5.99927 22 5.99781 22H5C4.20435 22 3.44129 21.6839 2.87868 21.1213C2.31607 20.5587 2 19.7957 2 19V5C2 4.20435 2.31607 3.44129 2.87868 2.87868C3.44129 2.31607 4.20435 2 5 2H12C12.5523 2 13 2.44772 13 3C13 3.55228 12.5523 4 12 4H5ZM8.41422 20H19C19.2652 20 19.5196 19.8946 19.7071 19.7071C19.8946 19.5196 20 19.2652 20 19V15.4142L17.207 12.6212C17.0195 12.4338 16.7651 12.3284 16.5 12.3284C16.2349 12.3284 15.9806 12.4337 15.7931 12.6211L8.41422 20ZM6.87868 6.87868C7.44129 6.31607 8.20435 6 9 6C9.79565 6 10.5587 6.31607 11.1213 6.87868C11.6839 7.44129 12 8.20435 12 9C12 9.79565 11.6839 10.5587 11.1213 11.1213C10.5587 11.6839 9.79565 12 9 12C8.20435 12 7.44129 11.6839 6.87868 11.1213C6.31607 10.5587 6 9.79565 6 9C6 8.20435 6.31607 7.44129 6.87868 6.87868ZM9 8C8.73478 8 8.48043 8.10536 8.29289 8.29289C8.10536 8.48043 8 8.73478 8 9C8 9.26522 8.10536 9.51957 8.29289 9.70711C8.48043 9.89464 8.73478 10 9 10C9.26522 10 9.51957 9.89464 9.70711 9.70711C9.89464 9.51957 10 9.26522 10 9C10 8.73478 9.89464 8.48043 9.70711 8.29289C9.51957 8.10536 9.26522 8 9 8Z",fill:"currentColor"},null)])}}),qe=e.defineComponent({name:"ImageButton",setup(){const t=e.inject("editor");return()=>e.createVNode("div",null,[e.createVNode(V,{icon:_e,tooltip:"图片",onClick:()=>t?.value?.commands.setImageUploadNode()},null)])}}),Oe=[{value:"left",title:"居左",Icon:z},{value:"center",title:"居中",Icon:$},{value:"right",title:"居右",Icon:P}],I=t=>t.preventDefault();function ze(t){if(!t.isActive("image"))return null;const{selection:o}=t.state;if(!(o instanceof D.NodeSelection)||o.node.type.name!=="image")return null;const n=o.node;return{pos:o.from,nodeSize:n.nodeSize,src:n.attrs.src,align:n.attrs.align??"left"}}function $e(t){const o=t.startsWith("data:")?"image.png":t.split("/").pop()?.split("?")[0]||"image.png",n=document.createElement("a");n.href=t,n.download=o,document.body.appendChild(n),n.click(),document.body.removeChild(n)}const Pe=()=>e.createVNode("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e.createVNode("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"},null),e.createVNode("polyline",{points:"7 10 12 15 17 10"},null),e.createVNode("line",{x1:"12",y1:"15",x2:"12",y2:"3"},null)]),We=()=>e.createVNode("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e.createVNode("polyline",{points:"1 4 1 10 7 10"},null),e.createVNode("path",{d:"M3.51 15a9 9 0 1 0 .49-4.1L1 10"},null)]),Ke=()=>e.createVNode("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e.createVNode("polyline",{points:"3 6 5 6 21 6"},null),e.createVNode("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"},null),e.createVNode("path",{d:"M10 11v6M14 11v6"},null),e.createVNode("path",{d:"M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"},null)]),Ge=e.defineComponent({name:"ImageControls",setup(){const t=e.inject("editor"),o=e.inject("readonly"),n=e.ref(null);function l(){const r=t?.value;if(!r){n.value=null;return}n.value=ze(r)}return e.watchEffect(r=>{const a=t?.value;a&&(a.on("transaction",l),r(()=>{a.off("transaction",l)}))}),()=>{const r=n.value;if(!r)return null;const a=t?.value;if(!a)return null;const{pos:m,nodeSize:C,src:d,align:k}=r,i=o?.value??!1,f=a.view.nodeDOM(m);if(!f||!(f instanceof HTMLElement))return null;const w=f.querySelector("[data-resize-wrapper]")??f,v=a.view.dom.closest(".tiptap-editor");if(!v)return null;const N=w.getBoundingClientRect(),c=v.getBoundingClientRect(),s={position:"absolute",top:`${N.top-c.top}px`,left:`${N.left-c.left+N.width/2}px`,transform:"translate(-50%, calc(-100% - 8px))",zIndex:20};return e.createVNode("div",{class:"image-controls",style:s},[!i&&Oe.map(({value:h,title:g,Icon:x})=>e.createVNode("button",{key:h,class:["image-controls-btn",k===h&&"is-active"],title:g,onMousedown:I,onClick:()=>a.chain().focus().updateAttributes("image",{align:h}).run()},[e.createVNode(x,null,null)])),!i&&e.createVNode("span",{class:"image-controls-separator"},null),e.createVNode("button",{class:"image-controls-btn",title:"下载",onMousedown:I,onClick:()=>$e(d)},[e.createVNode(Pe,null,null)]),!i&&e.createVNode("button",{class:"image-controls-btn",title:"重新上传",onMousedown:I,onClick:()=>a.chain().focus().deleteRange({from:m,to:m+C}).insertContentAt(m,{type:"imageUpload"}).run()},[e.createVNode(We,null,null)]),!i&&e.createVNode("button",{class:"image-controls-btn",title:"删除",onMousedown:I,onClick:()=>a.chain().focus().deleteRange({from:m,to:m+C}).run()},[e.createVNode(Ke,null,null)])])}}}),Je={name:"image",install:t=>({extensions:[O.configure({allowBase64:!0,resize:{enabled:!0,directions:["top","right","bottom","left","top-right","top-left","bottom-right","bottom-left"],minWidth:50,minHeight:50,alwaysPreserveAspectRatio:!1}}),je.configure({...t.upload?{upload:t.upload}:{}})],controlComponent:Ge}),toolbarComponent:qe},Xe={name:"separator",install:()=>({extensions:[]}),toolbarComponent:e.defineComponent({name:"ToolbarSeparator",setup:()=>()=>e.createVNode("div",{class:"tiptap-separator"},null)})};u.CodeBlockFeature=He,u.IconButton=V,u.ImageFeature=Je,u.ImageWithAlign=O,u.ListFeature=ke,u.MathFeature=Se,u.SeparatorFeature=Xe,u.TableFeature=Fe,u.TextAlignFeature=Ve,u.TextStyleFeature=he,u.TiptapEditor=ie,u.UndoRedoFeature=se,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mario9/tiptap-editor",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "基于 Tiptap + Vue 3 的富文本编辑器组件。",
5
5
  "type": "module",
6
6
  "main": "./dist/tiptap-editor.umd.cjs",