edu360-web-ui 1.0.93 → 1.0.95

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.
@@ -2,7 +2,7 @@ var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
4
  var _a2;
5
- import { ref, defineComponent, provide, markRaw, reactive, h as h$2, render as render$1, getCurrentInstance, watchEffect, nextTick, unref, onBeforeUnmount, customRef, shallowRef, onMounted, watch, onUnmounted, createBlock, openBlock, normalizeClass, withCtx, createElementVNode, createCommentVNode, createVNode, createTextVNode, toDisplayString, createElementBlock, Fragment as Fragment$1, renderList, resolveComponent, resolveDirective, normalizeStyle, withDirectives, vShow, withModifiers, Teleport, isRef, createApp, renderSlot, computed } from "vue";
5
+ import { ref, defineComponent, provide, markRaw, reactive, h as h$2, render as render$1, getCurrentInstance, watchEffect, nextTick, unref, onBeforeUnmount, customRef, shallowRef, onMounted, watch, onUnmounted, createBlock, openBlock, normalizeClass, withCtx, createElementVNode, createCommentVNode, createVNode, createTextVNode, toDisplayString, createElementBlock, Fragment as Fragment$1, renderList, resolveComponent, resolveDirective, normalizeStyle, withDirectives, vShow, withModifiers, Teleport, computed, isRef, createApp, renderSlot } from "vue";
6
6
  import { ElDropdown, ElDropdownMenu, ElDropdownItem, ElMessage, ElInput, ElButton, ElCard, ElForm, ElFormItem, ElTooltip, ElUpload, ElPopover, ElDrawer, ElTable, ElTableColumn, ElColorPicker, ElButtonGroup, ElLoading, ElDialog } from "element-plus";
7
7
  function OrderedMap(content) {
8
8
  this.content = content;
@@ -78316,7 +78316,7 @@ const _export_sfc = (sfc, props) => {
78316
78316
  return target;
78317
78317
  };
78318
78318
  const _hoisted_1$9 = { class: "code-block-view-cont" };
78319
- const _hoisted_2$7 = { class: "code-toolbar" };
78319
+ const _hoisted_2$8 = { class: "code-toolbar" };
78320
78320
  const _hoisted_3$6 = { class: "code-toolbar-right" };
78321
78321
  const _hoisted_4$4 = { class: "el-dropdown-link" };
78322
78322
  const _hoisted_5$4 = { style: { "height": "300px" } };
@@ -78381,7 +78381,7 @@ const _sfc_main$b = {
78381
78381
  }, {
78382
78382
  default: withCtx(() => [
78383
78383
  createElementVNode("div", _hoisted_1$9, [
78384
- createElementVNode("div", _hoisted_2$7, [
78384
+ createElementVNode("div", _hoisted_2$8, [
78385
78385
  _cache[0] || (_cache[0] = createElementVNode("div", null, null, -1)),
78386
78386
  createElementVNode("div", _hoisted_3$6, [
78387
78387
  unref(showType) != "ai" ? (openBlock(), createBlock(unref(ElDropdown), {
@@ -88462,13 +88462,23 @@ const commonExtensions = () => [
88462
88462
  // 启用1-6级标题
88463
88463
  bulletList: false,
88464
88464
  orderedList: false,
88465
- listItem: false
88465
+ listItem: false,
88466
+ strike: true,
88467
+ // 确保启用中划线
88468
+ bold: true,
88469
+ // 确保启用粗体
88470
+ italic: true
88471
+ // 确保启用斜体
88466
88472
  }),
88467
88473
  TextStyle,
88468
88474
  // 文本样式扩展
88469
88475
  Color,
88470
88476
  // 颜色选择扩展
88471
- index_default$9,
88477
+ index_default$9.configure({
88478
+ HTMLAttributes: {
88479
+ class: "underline"
88480
+ }
88481
+ }),
88472
88482
  // 下划线功能
88473
88483
  FontSize,
88474
88484
  // 自定义字体大小
@@ -88521,7 +88531,9 @@ const commonExtensions = () => [
88521
88531
  }),
88522
88532
  AutoOrderedOnEnter,
88523
88533
  index_default$2.configure({
88524
- types: ["heading", "paragraph"]
88534
+ types: ["heading", "paragraph"],
88535
+ alignments: ["left", "center", "right", "justify"],
88536
+ defaultAlignment: "left"
88525
88537
  }),
88526
88538
  index_default$b.configure({
88527
88539
  openOnClick: false,
@@ -97319,12 +97331,10 @@ function loadContentInChunks({
97319
97331
  onComplete == null ? void 0 : onComplete();
97320
97332
  return;
97321
97333
  }
97322
- console.log(`准备在位置 ${pos} 插入 ${chunk.length} 个块`);
97323
97334
  editor.chain().insertContentAt(pos, chunk).run();
97324
97335
  index += chunkSize;
97325
97336
  onProgress == null ? void 0 : onProgress(Math.min(index / total, 1));
97326
97337
  const nextPos = editor.state.doc.content.size;
97327
- console.log(`内容插入完成,下一次插入位置是 ${nextPos}`);
97328
97338
  if ("requestIdleCallback" in window) {
97329
97339
  requestIdleCallback(() => insertChunk(nextPos));
97330
97340
  } else {
@@ -98117,7 +98127,7 @@ function htmlToMarkdown(html2) {
98117
98127
  return turndownService.turndown(html2);
98118
98128
  }
98119
98129
  const _hoisted_1$8 = { class: "ai-input" };
98120
- const _hoisted_2$6 = {
98130
+ const _hoisted_2$7 = {
98121
98131
  key: 0,
98122
98132
  class: "ai-btns"
98123
98133
  };
@@ -98135,10 +98145,10 @@ const _hoisted_6$3 = {
98135
98145
  class: "result-image"
98136
98146
  };
98137
98147
  const _hoisted_7$3 = ["onClick"];
98138
- const _hoisted_8$2 = ["src"];
98139
- const _hoisted_9$2 = { class: "result-image-checkbox" };
98148
+ const _hoisted_8$3 = ["src"];
98149
+ const _hoisted_9$3 = { class: "result-image-checkbox" };
98140
98150
  const _hoisted_10$2 = { class: "result-text" };
98141
- const _hoisted_11$1 = { class: "result-actions" };
98151
+ const _hoisted_11 = { class: "result-actions" };
98142
98152
  const _sfc_main$a = {
98143
98153
  __name: "AiComponent",
98144
98154
  props: {
@@ -98393,7 +98403,7 @@ const _sfc_main$a = {
98393
98403
  ], 512), [
98394
98404
  [vShow, !unref(showResult)]
98395
98405
  ]),
98396
- !unref(showResult) ? (openBlock(), createElementBlock("div", _hoisted_2$6, [
98406
+ !unref(showResult) ? (openBlock(), createElementBlock("div", _hoisted_2$7, [
98397
98407
  createElementVNode("div", {
98398
98408
  class: normalizeClass(["ai-btns-send", { "is-disabled": !question.value }]),
98399
98409
  onClick: send2
@@ -98540,8 +98550,8 @@ const _sfc_main$a = {
98540
98550
  src: item.img,
98541
98551
  alt: "",
98542
98552
  width: "100%"
98543
- }, null, 8, _hoisted_8$2),
98544
- createElementVNode("div", _hoisted_9$2, [
98553
+ }, null, 8, _hoisted_8$3),
98554
+ createElementVNode("div", _hoisted_9$3, [
98545
98555
  createVNode(_component_el_checkbox, {
98546
98556
  modelValue: item.checked,
98547
98557
  "onUpdate:modelValue": ($event) => item.checked = $event,
@@ -98557,7 +98567,7 @@ const _sfc_main$a = {
98557
98567
  editor: unref(previewEditor)
98558
98568
  }, null, 8, ["editor"])) : createCommentVNode("", true)
98559
98569
  ]),
98560
- createElementVNode("div", _hoisted_11$1, [
98570
+ createElementVNode("div", _hoisted_11, [
98561
98571
  createVNode(unref(ElButton), {
98562
98572
  disabled: unref(typewriterLoading),
98563
98573
  size: "small",
@@ -101011,7 +101021,8 @@ defineComponent({
101011
101021
  };
101012
101022
  }
101013
101023
  });
101014
- const _hoisted_1$7 = { class: "text-right mt-2" };
101024
+ const _hoisted_1$7 = { class: "flex justify-between items-center mt-2" };
101025
+ const _hoisted_2$6 = { key: 1 };
101015
101026
  const _sfc_main$8 = {
101016
101027
  __name: "LinkToolbar",
101017
101028
  props: {
@@ -101029,6 +101040,9 @@ const _sfc_main$8 = {
101029
101040
  href: ""
101030
101041
  });
101031
101042
  let currentPos = 0;
101043
+ const hasExistingLink = computed(() => {
101044
+ return !!form.href && form.text;
101045
+ });
101032
101046
  const open = () => {
101033
101047
  console.log("22222");
101034
101048
  const { editor } = props;
@@ -101086,6 +101100,11 @@ const _sfc_main$8 = {
101086
101100
  const close2 = () => {
101087
101101
  show.value = false;
101088
101102
  };
101103
+ const removeLink = () => {
101104
+ const { editor } = props;
101105
+ editor.chain().focus().unsetLink().run();
101106
+ close2();
101107
+ };
101089
101108
  onMounted(() => {
101090
101109
  document.addEventListener("mousedown", handleClickOutside);
101091
101110
  });
@@ -101131,25 +101150,58 @@ const _sfc_main$8 = {
101131
101150
  _: 1
101132
101151
  }, 8, ["model"]),
101133
101152
  createElementVNode("div", _hoisted_1$7, [
101134
- createVNode(unref(ElButton), {
101153
+ hasExistingLink.value ? (openBlock(), createBlock(unref(ElButton), {
101154
+ key: 0,
101135
101155
  size: "small",
101136
- onClick: close2
101156
+ onClick: removeLink,
101157
+ class: "unlink-btn"
101137
101158
  }, {
101138
101159
  default: withCtx(() => [..._cache[2] || (_cache[2] = [
101139
- createTextVNode("取消", -1)
101140
- ])]),
101141
- _: 1
101142
- }),
101143
- createVNode(unref(ElButton), {
101144
- size: "small",
101145
- type: "primary",
101146
- onClick: applyLink
101147
- }, {
101148
- default: withCtx(() => [..._cache[3] || (_cache[3] = [
101149
- createTextVNode("确定", -1)
101160
+ createElementVNode("svg", {
101161
+ xmlns: "http://www.w3.org/2000/svg",
101162
+ width: "16",
101163
+ height: "16",
101164
+ viewBox: "0 0 24 24",
101165
+ fill: "none",
101166
+ stroke: "currentColor",
101167
+ "stroke-width": "2",
101168
+ "stroke-linecap": "round",
101169
+ "stroke-linejoin": "round"
101170
+ }, [
101171
+ createElementVNode("path", { d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" }),
101172
+ createElementVNode("path", { d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" }),
101173
+ createElementVNode("line", {
101174
+ x1: "4",
101175
+ y1: "20",
101176
+ x2: "20",
101177
+ y2: "4"
101178
+ })
101179
+ ], -1),
101180
+ createElementVNode("span", { class: "ml-1" }, "取消链接", -1)
101150
101181
  ])]),
101151
101182
  _: 1
101152
- })
101183
+ })) : (openBlock(), createElementBlock("div", _hoisted_2$6)),
101184
+ createElementVNode("div", null, [
101185
+ createVNode(unref(ElButton), {
101186
+ size: "small",
101187
+ onClick: close2
101188
+ }, {
101189
+ default: withCtx(() => [..._cache[3] || (_cache[3] = [
101190
+ createTextVNode("取消", -1)
101191
+ ])]),
101192
+ _: 1
101193
+ }),
101194
+ createVNode(unref(ElButton), {
101195
+ size: "small",
101196
+ type: "primary",
101197
+ onClick: applyLink
101198
+ }, {
101199
+ default: withCtx(() => [..._cache[4] || (_cache[4] = [
101200
+ createTextVNode("确定", -1)
101201
+ ])]),
101202
+ _: 1
101203
+ })
101204
+ ])
101153
101205
  ])
101154
101206
  ]),
101155
101207
  _: 1
@@ -101158,7 +101210,7 @@ const _sfc_main$8 = {
101158
101210
  };
101159
101211
  }
101160
101212
  };
101161
- const LinkToolbar = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["__scopeId", "data-v-1a77d30e"]]);
101213
+ const LinkToolbar = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["__scopeId", "data-v-652c40fc"]]);
101162
101214
  const _hoisted_1$6 = { class: "sudoku-div" };
101163
101215
  const _hoisted_2$5 = ["row", "col", "onMouseover", "onClick"];
101164
101216
  const _sfc_main$7 = {
@@ -107775,8 +107827,8 @@ const _hoisted_4$2 = { class: "floating-menu-common-list" };
107775
107827
  const _hoisted_5$2 = { class: "block-menu-item-icon" };
107776
107828
  const _hoisted_6$2 = { class: "block-menu-item" };
107777
107829
  const _hoisted_7$2 = { class: "block-menu-item-icon" };
107778
- const _hoisted_8$1 = { class: "block-menu-item-icon" };
107779
- const _hoisted_9$1 = { class: "block-menu-item-icon" };
107830
+ const _hoisted_8$2 = { class: "block-menu-item-icon" };
107831
+ const _hoisted_9$2 = { class: "block-menu-item-icon" };
107780
107832
  const _hoisted_10$1 = { class: "block-menu-item-icon" };
107781
107833
  const _sfc_main$6 = {
107782
107834
  __name: "BlockMenu",
@@ -107919,13 +107971,31 @@ const _sfc_main$6 = {
107919
107971
  emit("closemenu", "codeblock");
107920
107972
  };
107921
107973
  let tablePopoverVisible = ref(false);
107974
+ let selectedTableData = ref(null);
107922
107975
  const selectTable = (data) => {
107976
+ selectedTableData.value = data;
107923
107977
  tablePopoverVisible.value = false;
107924
107978
  nextTick(() => {
107925
- emit("closemenu");
107926
- setTimeout(() => {
107927
- props.editor.chain().focus().insertTable({ rows: data.row, cols: data.col, withHeaderRow: true }).run();
107928
- }, 0);
107979
+ emit("closemenu", () => {
107980
+ setTimeout(() => {
107981
+ const { state } = props.editor;
107982
+ const { $from } = state.selection;
107983
+ const currentNode = $from.node();
107984
+ if (currentNode && currentNode.type.name === "paragraph" && currentNode.content.size > 0) {
107985
+ props.editor.chain().focus().insertContent("<p></p>").insertTable({
107986
+ rows: selectedTableData.value.row,
107987
+ cols: selectedTableData.value.col,
107988
+ withHeaderRow: true
107989
+ }).run();
107990
+ } else {
107991
+ props.editor.chain().focus().insertTable({
107992
+ rows: selectedTableData.value.row,
107993
+ cols: selectedTableData.value.col,
107994
+ withHeaderRow: true
107995
+ }).run();
107996
+ }
107997
+ }, 50);
107998
+ });
107929
107999
  });
107930
108000
  };
107931
108001
  return (_ctx, _cache) => {
@@ -108248,7 +108318,7 @@ const _sfc_main$6 = {
108248
108318
  class: normalizeClass(["block-menu-item", { "icon-gray": isActive2("codeBlock") || isActive2("table") || isActive2("bulletList") || isActive2("orderedList") || isActive2("taskList") }]),
108249
108319
  ref: "tableRef"
108250
108320
  }, [
108251
- createElementVNode("div", _hoisted_8$1, [
108321
+ createElementVNode("div", _hoisted_8$2, [
108252
108322
  createVNode(unref(Icon), {
108253
108323
  icon: "material-symbols:table-outline-sharp",
108254
108324
  width: "20"
@@ -108286,7 +108356,7 @@ const _sfc_main$6 = {
108286
108356
  createElementVNode("div", {
108287
108357
  class: normalizeClass(["block-menu-item", { "icon-gray": isActive2("codeBlock") || isActive2("table") || isActive2("bulletList") || isActive2("orderedList") || isActive2("taskList") }])
108288
108358
  }, [
108289
- createElementVNode("div", _hoisted_9$1, [
108359
+ createElementVNode("div", _hoisted_9$2, [
108290
108360
  createVNode(unref(Icon), { icon: "tabler:file-word" })
108291
108361
  ]),
108292
108362
  _cache[27] || (_cache[27] = createElementVNode("div", null, "上传word文件", -1))
@@ -108337,7 +108407,7 @@ const _sfc_main$6 = {
108337
108407
  };
108338
108408
  }
108339
108409
  };
108340
- const BlockMenu = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__scopeId", "data-v-c9b1c163"]]);
108410
+ const BlockMenu = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__scopeId", "data-v-7f8a1002"]]);
108341
108411
  function BlockMenuPlugin(editor, options) {
108342
108412
  const PLUGIN_KEY = new PluginKey("blockMenu");
108343
108413
  let wrapperEl = options.wrapperEl || null;
@@ -108483,6 +108553,34 @@ Extension.create({
108483
108553
  }
108484
108554
  });
108485
108555
  const CustomImage = index_default$6.extend({
108556
+ addAttributes() {
108557
+ var _a3;
108558
+ return {
108559
+ ...(_a3 = this.parent) == null ? void 0 : _a3.call(this),
108560
+ width: {
108561
+ default: null,
108562
+ renderHTML: (attrs) => {
108563
+ if (!attrs.width) return {};
108564
+ return { width: attrs.width + "px" };
108565
+ },
108566
+ parseHTML: (element) => {
108567
+ const w2 = element.getAttribute("width") || element.style.width;
108568
+ return w2 ? parseInt(w2) : null;
108569
+ }
108570
+ },
108571
+ height: {
108572
+ default: null,
108573
+ renderHTML: (attrs) => {
108574
+ if (!attrs.height) return {};
108575
+ return { height: attrs.height + "px" };
108576
+ },
108577
+ parseHTML: (element) => {
108578
+ const h2 = element.getAttribute("height") || element.style.height;
108579
+ return h2 ? parseInt(h2) : null;
108580
+ }
108581
+ }
108582
+ };
108583
+ },
108486
108584
  addProseMirrorPlugins() {
108487
108585
  const PLUGIN_KEY = new PluginKey("customImageClick");
108488
108586
  return [
@@ -108490,18 +108588,272 @@ const CustomImage = index_default$6.extend({
108490
108588
  key: PLUGIN_KEY,
108491
108589
  props: {
108492
108590
  handleDOMEvents: {
108493
- click: (view, event) => {
108494
- const target = event.target;
108495
- if (target.tagName === "IMG") {
108496
- window.dispatchEvent(new CustomEvent("tiptap-image-click", { detail: target.src }));
108497
- return true;
108498
- }
108499
- return false;
108500
- }
108591
+ // 去掉“点击图片放大”行为,仅通过工具条按钮查看原图
108592
+ click: () => false
108501
108593
  }
108502
108594
  }
108503
108595
  })
108504
108596
  ];
108597
+ },
108598
+ addNodeView() {
108599
+ return ({ node, editor, getPos }) => {
108600
+ const wrapper = document.createElement("div");
108601
+ wrapper.style.position = "relative";
108602
+ wrapper.style.display = "inline-block";
108603
+ wrapper.style.lineHeight = "0";
108604
+ const img = document.createElement("img");
108605
+ img.src = node.attrs.src;
108606
+ img.alt = node.attrs.alt || "";
108607
+ img.title = node.attrs.title || "";
108608
+ img.style.display = "block";
108609
+ img.style.borderRadius = "4px";
108610
+ if (node.attrs.width) img.style.width = node.attrs.width + "px";
108611
+ if (node.attrs.height) img.style.height = node.attrs.height + "px";
108612
+ const toolbar = document.createElement("div");
108613
+ toolbar.style.position = "absolute";
108614
+ toolbar.style.top = "8px";
108615
+ toolbar.style.right = "8px";
108616
+ toolbar.style.display = "flex";
108617
+ toolbar.style.gap = "6px";
108618
+ toolbar.style.opacity = "0";
108619
+ toolbar.style.visibility = "hidden";
108620
+ toolbar.style.transition = "all .2s";
108621
+ toolbar.style.zIndex = "2";
108622
+ const getIconSvg = (type) => {
108623
+ if (type === "view") {
108624
+ return `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line><line x1="11" y1="8" x2="11" y2="14"></line><line x1="8" y1="11" x2="14" y2="11"></line></svg>`;
108625
+ }
108626
+ if (type === "reset") {
108627
+ return `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="1 4 1 10 7 10"></polyline><path d="M3.51 15a9 9 0 1 0 2.13-9.36L1 10"></path></svg>`;
108628
+ }
108629
+ if (type === "fit") {
108630
+ return `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="6" width="18" height="12" rx="2" ry="2"></rect><polyline points="8 12 11 9 11 15 8 12"></polyline><polyline points="16 12 13 9 13 15 16 12"></polyline></svg>`;
108631
+ }
108632
+ return "";
108633
+ };
108634
+ const makeBtn = (type, title) => {
108635
+ const btn = document.createElement("button");
108636
+ btn.type = "button";
108637
+ btn.title = title;
108638
+ btn.style.width = "30px";
108639
+ btn.style.height = "30px";
108640
+ btn.style.padding = "0";
108641
+ btn.style.border = "none";
108642
+ btn.style.borderRadius = "6px";
108643
+ btn.style.background = "rgba(0,0,0,.7)";
108644
+ btn.style.color = "#fff";
108645
+ btn.style.cursor = "pointer";
108646
+ btn.style.display = "flex";
108647
+ btn.style.alignItems = "center";
108648
+ btn.style.justifyContent = "center";
108649
+ btn.style.transition = "all .2s";
108650
+ btn.style.boxShadow = "0 2px 8px rgba(0,0,0,.2)";
108651
+ btn.innerHTML = getIconSvg(type);
108652
+ btn.addEventListener("mouseenter", () => {
108653
+ btn.style.background = "rgba(0,0,0,.9)";
108654
+ });
108655
+ btn.addEventListener("mouseleave", () => {
108656
+ btn.style.background = "rgba(0,0,0,.7)";
108657
+ });
108658
+ return btn;
108659
+ };
108660
+ const viewBtn = makeBtn("view", "查看原图");
108661
+ const fitBtn = makeBtn("fit", "适配编辑区宽度");
108662
+ const resetBtn = makeBtn("reset", "重置大小");
108663
+ toolbar.appendChild(viewBtn);
108664
+ toolbar.appendChild(fitBtn);
108665
+ toolbar.appendChild(resetBtn);
108666
+ viewBtn.addEventListener("click", (e) => {
108667
+ e.preventDefault();
108668
+ e.stopPropagation();
108669
+ window.dispatchEvent(new CustomEvent("tiptap-image-click", { detail: img.src }));
108670
+ });
108671
+ resetBtn.addEventListener("click", (e) => {
108672
+ e.preventDefault();
108673
+ e.stopPropagation();
108674
+ if (typeof getPos === "function") {
108675
+ const pos = getPos();
108676
+ const tr2 = editor.view.state.tr.setNodeMarkup(pos, null, {
108677
+ ...node.attrs,
108678
+ width: null,
108679
+ height: null
108680
+ });
108681
+ editor.view.dispatch(tr2);
108682
+ }
108683
+ });
108684
+ fitBtn.addEventListener("click", (e) => {
108685
+ e.preventDefault();
108686
+ e.stopPropagation();
108687
+ const editorDom = editor.view.dom;
108688
+ if (!editorDom) return;
108689
+ const containerWidth = Math.max(50, editorDom.clientWidth - 60);
108690
+ const naturalW = img.naturalWidth || img.offsetWidth || 1;
108691
+ const naturalH = img.naturalHeight || img.offsetHeight || 1;
108692
+ const aspect = naturalW / naturalH;
108693
+ const targetW = Math.round(containerWidth);
108694
+ const targetH = Math.round(targetW / aspect);
108695
+ img.style.width = targetW + "px";
108696
+ img.style.height = targetH + "px";
108697
+ if (typeof getPos === "function") {
108698
+ const pos = getPos();
108699
+ const tr2 = editor.view.state.tr.setNodeMarkup(pos, null, {
108700
+ ...node.attrs,
108701
+ width: targetW,
108702
+ height: targetH
108703
+ });
108704
+ editor.view.dispatch(tr2);
108705
+ }
108706
+ });
108707
+ const handlePositions = ["nw", "ne", "sw", "se"];
108708
+ const handles = {};
108709
+ const createHandle = (pos) => {
108710
+ const h2 = document.createElement("div");
108711
+ h2.dataset.position = pos;
108712
+ h2.style.position = "absolute";
108713
+ h2.style.width = "8px";
108714
+ h2.style.height = "8px";
108715
+ h2.style.background = "#fff";
108716
+ h2.style.border = "2px solid rgb(37,108,251)";
108717
+ h2.style.borderRadius = "50%";
108718
+ h2.style.opacity = "0";
108719
+ h2.style.visibility = "hidden";
108720
+ h2.style.transition = "all .2s";
108721
+ h2.style.zIndex = "1";
108722
+ h2.style.boxShadow = "0 2px 6px rgba(0,0,0,.15)";
108723
+ if (pos === "nw") {
108724
+ h2.style.top = "-4px";
108725
+ h2.style.left = "10px";
108726
+ h2.style.cursor = "nwse-resize";
108727
+ }
108728
+ if (pos === "ne") {
108729
+ h2.style.top = "-4px";
108730
+ h2.style.right = "14px";
108731
+ h2.style.cursor = "nesw-resize";
108732
+ }
108733
+ if (pos === "sw") {
108734
+ h2.style.bottom = "-4px";
108735
+ h2.style.left = "10px";
108736
+ h2.style.cursor = "nesw-resize";
108737
+ }
108738
+ if (pos === "se") {
108739
+ h2.style.bottom = "-4px";
108740
+ h2.style.right = "14px";
108741
+ h2.style.cursor = "nwse-resize";
108742
+ }
108743
+ h2.addEventListener("mouseenter", () => {
108744
+ h2.style.background = "rgb(37,108,251)";
108745
+ h2.style.transform = "scale(1.3)";
108746
+ });
108747
+ h2.addEventListener("mouseleave", () => {
108748
+ h2.style.background = "#fff";
108749
+ h2.style.transform = "scale(1)";
108750
+ });
108751
+ return h2;
108752
+ };
108753
+ handlePositions.forEach((p) => {
108754
+ handles[p] = createHandle(p);
108755
+ });
108756
+ const showUI = () => {
108757
+ toolbar.style.opacity = "1";
108758
+ toolbar.style.visibility = "visible";
108759
+ Object.values(handles).forEach((h2) => {
108760
+ h2.style.opacity = "1";
108761
+ h2.style.visibility = "visible";
108762
+ });
108763
+ };
108764
+ const hideUI = () => {
108765
+ toolbar.style.opacity = "0";
108766
+ toolbar.style.visibility = "hidden";
108767
+ Object.values(handles).forEach((h2) => {
108768
+ h2.style.opacity = "0";
108769
+ h2.style.visibility = "hidden";
108770
+ });
108771
+ };
108772
+ wrapper.addEventListener("mouseenter", showUI);
108773
+ wrapper.addEventListener("mouseleave", hideUI);
108774
+ const startResize = (downEvent, position) => {
108775
+ downEvent.preventDefault();
108776
+ downEvent.stopPropagation();
108777
+ const startX = downEvent.clientX;
108778
+ const startY = downEvent.clientY;
108779
+ const startWidth = img.offsetWidth;
108780
+ const startHeight = img.offsetHeight;
108781
+ const aspect = startWidth / startHeight || 1;
108782
+ const isLeft = position.includes("w");
108783
+ const isTop = position.includes("n");
108784
+ const onMove = (moveEvent) => {
108785
+ let dx = moveEvent.clientX - startX;
108786
+ let dy = moveEvent.clientY - startY;
108787
+ if (isLeft) dx = -dx;
108788
+ if (isTop) dy = -dy;
108789
+ const keepRatio = !moveEvent.shiftKey;
108790
+ let newW, newH;
108791
+ if (keepRatio) {
108792
+ const d2 = Math.max(dx, dy);
108793
+ newW = Math.max(50, startWidth + d2);
108794
+ newH = Math.max(50, newW / aspect);
108795
+ } else {
108796
+ newW = Math.max(50, startWidth + dx);
108797
+ newH = Math.max(50, startHeight + dy);
108798
+ }
108799
+ img.style.width = newW + "px";
108800
+ img.style.height = newH + "px";
108801
+ };
108802
+ const onUp = (upEvent) => {
108803
+ document.removeEventListener("mousemove", onMove);
108804
+ document.removeEventListener("mouseup", onUp);
108805
+ let dx = upEvent.clientX - startX;
108806
+ let dy = upEvent.clientY - startY;
108807
+ if (isLeft) dx = -dx;
108808
+ if (isTop) dy = -dy;
108809
+ const keepRatio = !upEvent.shiftKey;
108810
+ let finalW, finalH;
108811
+ if (keepRatio) {
108812
+ const d2 = Math.max(dx, dy);
108813
+ finalW = Math.max(50, startWidth + d2);
108814
+ finalH = Math.max(50, finalW / aspect);
108815
+ } else {
108816
+ finalW = Math.max(50, startWidth + dx);
108817
+ finalH = Math.max(50, startHeight + dy);
108818
+ }
108819
+ if (typeof getPos === "function") {
108820
+ const pos = getPos();
108821
+ const tr2 = editor.view.state.tr.setNodeMarkup(pos, null, {
108822
+ ...node.attrs,
108823
+ width: Math.round(finalW),
108824
+ height: Math.round(finalH)
108825
+ });
108826
+ editor.view.dispatch(tr2);
108827
+ }
108828
+ };
108829
+ document.addEventListener("mousemove", onMove);
108830
+ document.addEventListener("mouseup", onUp);
108831
+ };
108832
+ handlePositions.forEach((p) => {
108833
+ handles[p].addEventListener("mousedown", (e) => startResize(e, p));
108834
+ });
108835
+ wrapper.appendChild(img);
108836
+ wrapper.appendChild(toolbar);
108837
+ handlePositions.forEach((p) => wrapper.appendChild(handles[p]));
108838
+ return {
108839
+ dom: wrapper,
108840
+ contentDOM: null,
108841
+ update: (updatedNode) => {
108842
+ if (updatedNode.type.name !== "image") return false;
108843
+ img.src = updatedNode.attrs.src;
108844
+ img.alt = updatedNode.attrs.alt || "";
108845
+ img.title = updatedNode.attrs.title || "";
108846
+ if (updatedNode.attrs.width) img.style.width = updatedNode.attrs.width + "px";
108847
+ else img.style.width = "";
108848
+ if (updatedNode.attrs.height) img.style.height = updatedNode.attrs.height + "px";
108849
+ else img.style.height = "";
108850
+ return true;
108851
+ },
108852
+ destroy: () => {
108853
+ wrapper.remove();
108854
+ }
108855
+ };
108856
+ };
108505
108857
  }
108506
108858
  });
108507
108859
  createLowlight();
@@ -108528,7 +108880,13 @@ const createEditor = ({ content = "", info = {}, limit = 50, isInline: isInline2
108528
108880
  // 启用1-6级标题
108529
108881
  bulletList: false,
108530
108882
  orderedList: false,
108531
- listItem: false
108883
+ listItem: false,
108884
+ strike: true,
108885
+ // 确保启用中划线
108886
+ bold: true,
108887
+ // 确保启用粗体
108888
+ italic: true
108889
+ // 确保启用斜体
108532
108890
  }),
108533
108891
  index_default.configure({
108534
108892
  placeholder: ({ node, editor: editor2 }) => {
@@ -108550,7 +108908,11 @@ const createEditor = ({ content = "", info = {}, limit = 50, isInline: isInline2
108550
108908
  // 文本样式扩展
108551
108909
  Color,
108552
108910
  // 颜色选择扩展
108553
- index_default$9,
108911
+ index_default$9.configure({
108912
+ HTMLAttributes: {
108913
+ class: "underline"
108914
+ }
108915
+ }),
108554
108916
  // 下划线功能
108555
108917
  FontSize,
108556
108918
  // 自定义字体大小
@@ -108605,7 +108967,9 @@ const createEditor = ({ content = "", info = {}, limit = 50, isInline: isInline2
108605
108967
  }),
108606
108968
  AutoOrderedOnEnter,
108607
108969
  index_default$2.configure({
108608
- types: ["heading", "paragraph"]
108970
+ types: ["heading", "paragraph"],
108971
+ alignments: ["left", "center", "right", "justify"],
108972
+ defaultAlignment: "left"
108609
108973
  }),
108610
108974
  index_default$b.configure({
108611
108975
  openOnClick: false,
@@ -108645,12 +109009,6 @@ const createEditor = ({ content = "", info = {}, limit = 50, isInline: isInline2
108645
109009
  // --- 修改这里 ---
108646
109010
  handlePaste: (view, event, slice2) => {
108647
109011
  var _a3;
108648
- slice2.content.copy().content.filter((node) => {
108649
- if (node.type.name === "table" || node.type.name === "codeBlock") {
108650
- return false;
108651
- }
108652
- return true;
108653
- });
108654
109012
  const currentSize = getTextLength(view.state.doc);
108655
109013
  const pastedSize = slice2.content.size;
108656
109014
  if (currentSize + pastedSize > limit) {
@@ -108674,7 +109032,6 @@ const createEditor = ({ content = "", info = {}, limit = 50, isInline: isInline2
108674
109032
  apiHost: info.apiHost,
108675
109033
  token: info.token,
108676
109034
  getFileContent: info.uploadUrl
108677
- // 请确认这个 key 是否正确
108678
109035
  }
108679
109036
  };
108680
109037
  uploadImageApi(params, formData).then((res) => {
@@ -108682,9 +109039,11 @@ const createEditor = ({ content = "", info = {}, limit = 50, isInline: isInline2
108682
109039
  editor.chain().focus().setImage({ src: res.data.show_url }).run();
108683
109040
  } else {
108684
109041
  console.error("Image upload failed or response format is incorrect.", res);
109042
+ ElMessage.error("图片上传失败");
108685
109043
  }
108686
109044
  }).catch((error2) => {
108687
109045
  console.error("Error during image upload:", error2);
109046
+ ElMessage.error("图片上传失败");
108688
109047
  });
108689
109048
  return true;
108690
109049
  },
@@ -109025,24 +109384,21 @@ const textLevel = {
109025
109384
  h6: "标题6"
109026
109385
  };
109027
109386
  const _hoisted_1$3 = { class: "toolbar" };
109028
- const _hoisted_2$2 = { class: "el-dropdown-link" };
109029
- const _hoisted_3$2 = { class: "el-dropdown-link" };
109030
- const _hoisted_4$1 = {
109387
+ const _hoisted_2$2 = {
109031
109388
  key: 2,
109032
109389
  class: "flex-center"
109033
109390
  };
109034
- const _hoisted_5$1 = { class: "flex-center" };
109035
- const _hoisted_6$1 = {
109391
+ const _hoisted_3$2 = { class: "flex-center" };
109392
+ const _hoisted_4$1 = {
109036
109393
  key: 3,
109037
109394
  class: "flex-center"
109038
109395
  };
109396
+ const _hoisted_5$1 = { class: "flex-center" };
109397
+ const _hoisted_6$1 = { class: "flex-center" };
109039
109398
  const _hoisted_7$1 = { class: "flex-center" };
109040
- const _hoisted_8 = { class: "el-dropdown-link" };
109041
- const _hoisted_9 = { class: "flex-center" };
109042
- const _hoisted_10 = { class: "flex-center" };
109043
- const _hoisted_11 = { class: "flex-center" };
109044
- const _hoisted_12 = { class: "table-content" };
109045
- const _hoisted_13 = { key: 5 };
109399
+ const _hoisted_8$1 = { class: "flex-center" };
109400
+ const _hoisted_9$1 = { class: "table-content" };
109401
+ const _hoisted_10 = { key: 6 };
109046
109402
  const _sfc_main$4 = {
109047
109403
  __name: "EditorToolbar",
109048
109404
  props: {
@@ -109063,7 +109419,7 @@ const _sfc_main$4 = {
109063
109419
  default: () => []
109064
109420
  }
109065
109421
  },
109066
- emits: ["showAi", "showLink", "toggleLoading"],
109422
+ emits: ["showAi", "showLink", "toggleLoading", "showSource"],
109067
109423
  setup(__props, { emit: __emit }) {
109068
109424
  const { appContext } = getCurrentInstance();
109069
109425
  const props = __props;
@@ -109072,6 +109428,10 @@ const _sfc_main$4 = {
109072
109428
  let curFontColor = ref("#000");
109073
109429
  let curBgColor = ref("");
109074
109430
  const isActive2 = (name, params) => props.editor.isActive(name, params);
109431
+ const isInCodeBlock = computed(() => {
109432
+ if (!props.editor) return false;
109433
+ return props.editor.isActive("codeBlock") || props.editor.isActive("codeBlockCustom");
109434
+ });
109075
109435
  let curText = ref("正文");
109076
109436
  const setHeading = (level) => {
109077
109437
  if (level === "paragraph") {
@@ -109134,6 +109494,9 @@ const _sfc_main$4 = {
109134
109494
  props.editor.setEditable(false);
109135
109495
  }
109136
109496
  };
109497
+ const viewSource = () => {
109498
+ emit("showSource");
109499
+ };
109137
109500
  const commonExpressionVisible = ref(false);
109138
109501
  const showExpression = () => {
109139
109502
  commonExpressionVisible.value = true;
@@ -109294,7 +109657,8 @@ const _sfc_main$4 = {
109294
109657
  createVNode(unref(ElDropdown), {
109295
109658
  onCommand: setHeading,
109296
109659
  trigger: "click",
109297
- "popper-class": "tiptap-drop-down"
109660
+ "popper-class": "tiptap-drop-down",
109661
+ disabled: isInCodeBlock.value
109298
109662
  }, {
109299
109663
  dropdown: withCtx(() => [
109300
109664
  createVNode(unref(ElDropdownMenu), null, {
@@ -109358,16 +109722,18 @@ const _sfc_main$4 = {
109358
109722
  })
109359
109723
  ]),
109360
109724
  default: withCtx(() => [
109361
- createElementVNode("div", _hoisted_2$2, [
109725
+ createElementVNode("div", {
109726
+ class: normalizeClass(["el-dropdown-link", { "disabled": isInCodeBlock.value }])
109727
+ }, [
109362
109728
  createElementVNode("p", null, toDisplayString(unref(curText)), 1),
109363
109729
  createVNode(unref(Icon), {
109364
109730
  icon: "ic:baseline-expand-more",
109365
109731
  width: "16"
109366
109732
  })
109367
- ])
109733
+ ], 2)
109368
109734
  ]),
109369
109735
  _: 1
109370
- })
109736
+ }, 8, ["disabled"])
109371
109737
  ]),
109372
109738
  _: 1
109373
109739
  })) : createCommentVNode("", true),
@@ -109381,7 +109747,8 @@ const _sfc_main$4 = {
109381
109747
  createVNode(unref(ElDropdown), {
109382
109748
  onCommand: setFontSize,
109383
109749
  trigger: "click",
109384
- "popper-class": "tiptap-drop-down"
109750
+ "popper-class": "tiptap-drop-down",
109751
+ disabled: isInCodeBlock.value
109385
109752
  }, {
109386
109753
  dropdown: withCtx(() => [
109387
109754
  createVNode(unref(ElDropdownMenu), null, {
@@ -109404,20 +109771,22 @@ const _sfc_main$4 = {
109404
109771
  })
109405
109772
  ]),
109406
109773
  default: withCtx(() => [
109407
- createElementVNode("div", _hoisted_3$2, [
109774
+ createElementVNode("div", {
109775
+ class: normalizeClass(["el-dropdown-link", { "disabled": isInCodeBlock.value }])
109776
+ }, [
109408
109777
  createElementVNode("p", null, toDisplayString(unref(curFontSize)), 1),
109409
109778
  createVNode(unref(Icon), {
109410
109779
  icon: "ic:baseline-expand-more",
109411
109780
  width: "16"
109412
109781
  })
109413
- ])
109782
+ ], 2)
109414
109783
  ]),
109415
109784
  _: 1
109416
- })
109785
+ }, 8, ["disabled"])
109417
109786
  ]),
109418
109787
  _: 1
109419
109788
  }),
109420
- unref(isShowMenu)("color", __props.showMenu) ? (openBlock(), createElementBlock("div", _hoisted_4$1, [
109789
+ unref(isShowMenu)("color", __props.showMenu) ? (openBlock(), createElementBlock("div", _hoisted_2$2, [
109421
109790
  createVNode(unref(ElTooltip), {
109422
109791
  class: "box-item",
109423
109792
  effect: "dark",
@@ -109425,20 +109794,21 @@ const _sfc_main$4 = {
109425
109794
  placement: "bottom"
109426
109795
  }, {
109427
109796
  default: withCtx(() => [
109428
- createElementVNode("div", _hoisted_5$1, [
109797
+ createElementVNode("div", _hoisted_3$2, [
109429
109798
  createVNode(unref(ElColorPicker), {
109430
109799
  modelValue: unref(curFontColor),
109431
109800
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(curFontColor) ? curFontColor.value = $event : curFontColor = $event),
109432
109801
  onChange: setFontColor,
109433
109802
  size: "small",
109434
- "show-alpha": ""
109435
- }, null, 8, ["modelValue"])
109803
+ "show-alpha": "",
109804
+ disabled: isInCodeBlock.value
109805
+ }, null, 8, ["modelValue", "disabled"])
109436
109806
  ])
109437
109807
  ]),
109438
109808
  _: 1
109439
109809
  })
109440
109810
  ])) : createCommentVNode("", true),
109441
- unref(isShowMenu)("bgColor", __props.showMenu) ? (openBlock(), createElementBlock("div", _hoisted_6$1, [
109811
+ unref(isShowMenu)("bgColor", __props.showMenu) ? (openBlock(), createElementBlock("div", _hoisted_4$1, [
109442
109812
  createVNode(unref(ElTooltip), {
109443
109813
  class: "box-item",
109444
109814
  effect: "dark",
@@ -109446,14 +109816,15 @@ const _sfc_main$4 = {
109446
109816
  placement: "bottom"
109447
109817
  }, {
109448
109818
  default: withCtx(() => [
109449
- createElementVNode("div", _hoisted_7$1, [
109819
+ createElementVNode("div", _hoisted_5$1, [
109450
109820
  createVNode(unref(ElColorPicker), {
109451
109821
  modelValue: unref(curBgColor),
109452
109822
  "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => isRef(curBgColor) ? curBgColor.value = $event : curBgColor = $event),
109453
109823
  onChange: setBgColor,
109454
109824
  size: "small",
109455
- "show-alpha": ""
109456
- }, null, 8, ["modelValue"])
109825
+ "show-alpha": "",
109826
+ disabled: isInCodeBlock.value
109827
+ }, null, 8, ["modelValue", "disabled"])
109457
109828
  ])
109458
109829
  ]),
109459
109830
  _: 1
@@ -109473,16 +109844,18 @@ const _sfc_main$4 = {
109473
109844
  size: "small",
109474
109845
  type: isActive2("bold") ? "primary" : "",
109475
109846
  onClick: _cache[2] || (_cache[2] = ($event) => __props.editor.chain().focus().toggleBold().run()),
109476
- link: ""
109847
+ link: "",
109848
+ disabled: isInCodeBlock.value
109477
109849
  }, {
109478
109850
  default: withCtx(() => [
109479
109851
  createVNode(unref(Icon), {
109480
109852
  icon: "mdi:format-bold",
109481
- width: "20"
109482
- })
109853
+ width: "20",
109854
+ class: normalizeClass({ "icon-gray": isInCodeBlock.value })
109855
+ }, null, 8, ["class"])
109483
109856
  ]),
109484
109857
  _: 1
109485
- }, 8, ["type"])
109858
+ }, 8, ["type", "disabled"])
109486
109859
  ]),
109487
109860
  _: 1
109488
109861
  })) : createCommentVNode("", true),
@@ -109498,16 +109871,18 @@ const _sfc_main$4 = {
109498
109871
  size: "small",
109499
109872
  type: isActive2("italic") ? "primary" : "",
109500
109873
  onClick: _cache[3] || (_cache[3] = ($event) => __props.editor.chain().focus().toggleItalic().run()),
109501
- link: ""
109874
+ link: "",
109875
+ disabled: isInCodeBlock.value
109502
109876
  }, {
109503
109877
  default: withCtx(() => [
109504
109878
  createVNode(unref(Icon), {
109505
109879
  icon: "mdi:format-italic",
109506
- width: "20"
109507
- })
109880
+ width: "20",
109881
+ class: normalizeClass({ "icon-gray": isInCodeBlock.value })
109882
+ }, null, 8, ["class"])
109508
109883
  ]),
109509
109884
  _: 1
109510
- }, 8, ["type"])
109885
+ }, 8, ["type", "disabled"])
109511
109886
  ]),
109512
109887
  _: 1
109513
109888
  })) : createCommentVNode("", true),
@@ -109523,16 +109898,18 @@ const _sfc_main$4 = {
109523
109898
  size: "small",
109524
109899
  type: isActive2("underline") ? "primary" : "",
109525
109900
  onClick: _cache[4] || (_cache[4] = ($event) => __props.editor.chain().focus().toggleUnderline().run()),
109526
- link: ""
109901
+ link: "",
109902
+ disabled: isInCodeBlock.value
109527
109903
  }, {
109528
109904
  default: withCtx(() => [
109529
109905
  createVNode(unref(Icon), {
109530
109906
  icon: "mdi:format-underline",
109531
- width: "20"
109532
- })
109907
+ width: "20",
109908
+ class: normalizeClass({ "icon-gray": isInCodeBlock.value })
109909
+ }, null, 8, ["class"])
109533
109910
  ]),
109534
109911
  _: 1
109535
- }, 8, ["type"])
109912
+ }, 8, ["type", "disabled"])
109536
109913
  ]),
109537
109914
  _: 1
109538
109915
  })) : createCommentVNode("", true),
@@ -109548,16 +109925,18 @@ const _sfc_main$4 = {
109548
109925
  size: "small",
109549
109926
  type: isActive2("strike") ? "primary" : "",
109550
109927
  onClick: _cache[5] || (_cache[5] = ($event) => __props.editor.chain().focus().toggleStrike().run()),
109551
- link: ""
109928
+ link: "",
109929
+ disabled: isInCodeBlock.value
109552
109930
  }, {
109553
109931
  default: withCtx(() => [
109554
109932
  createVNode(unref(Icon), {
109555
109933
  icon: "mdi:format-strikethrough",
109556
- width: "20"
109557
- })
109934
+ width: "20",
109935
+ class: normalizeClass({ "icon-gray": isInCodeBlock.value })
109936
+ }, null, 8, ["class"])
109558
109937
  ]),
109559
109938
  _: 1
109560
- }, 8, ["type"])
109939
+ }, 8, ["type", "disabled"])
109561
109940
  ]),
109562
109941
  _: 1
109563
109942
  })) : createCommentVNode("", true),
@@ -109644,16 +110023,18 @@ const _sfc_main$4 = {
109644
110023
  createVNode(unref(ElButton), {
109645
110024
  onClick: setLink,
109646
110025
  type: isActive2("link") ? "primary" : "",
109647
- link: ""
110026
+ link: "",
110027
+ disabled: isInCodeBlock.value
109648
110028
  }, {
109649
110029
  default: withCtx(() => [
109650
110030
  createVNode(unref(Icon), {
109651
110031
  icon: "mdi:link-variant",
109652
- width: "20"
109653
- })
110032
+ width: "20",
110033
+ class: normalizeClass({ "icon-gray": isInCodeBlock.value })
110034
+ }, null, 8, ["class"])
109654
110035
  ]),
109655
110036
  _: 1
109656
- }, 8, ["type"])
110037
+ }, 8, ["type", "disabled"])
109657
110038
  ]),
109658
110039
  _: 1
109659
110040
  })) : createCommentVNode("", true)
@@ -109670,7 +110051,8 @@ const _sfc_main$4 = {
109670
110051
  createVNode(unref(ElDropdown), {
109671
110052
  onCommand: setAlign,
109672
110053
  trigger: "click",
109673
- teleported: false
110054
+ teleported: false,
110055
+ disabled: isInCodeBlock.value
109674
110056
  }, {
109675
110057
  dropdown: withCtx(() => [
109676
110058
  createVNode(unref(ElDropdownMenu), null, {
@@ -109771,23 +110153,27 @@ const _sfc_main$4 = {
109771
110153
  })
109772
110154
  ]),
109773
110155
  default: withCtx(() => [
109774
- createElementVNode("div", _hoisted_8, [
110156
+ createElementVNode("div", {
110157
+ class: normalizeClass(["el-dropdown-link", { "disabled": isInCodeBlock.value }])
110158
+ }, [
109775
110159
  createVNode(unref(Icon), {
109776
110160
  icon: `mdi:format-align-${unref(alignType)}`,
109777
- width: "20"
109778
- }, null, 8, ["icon"]),
110161
+ width: "20",
110162
+ class: normalizeClass({ "icon-gray": isInCodeBlock.value })
110163
+ }, null, 8, ["icon", "class"]),
109779
110164
  createVNode(unref(Icon), {
109780
110165
  icon: "ic:baseline-expand-more",
109781
- width: "16"
109782
- })
109783
- ])
110166
+ width: "16",
110167
+ class: normalizeClass({ "icon-gray": isInCodeBlock.value })
110168
+ }, null, 8, ["class"])
110169
+ ], 2)
109784
110170
  ]),
109785
110171
  _: 1
109786
- })
110172
+ }, 8, ["disabled"])
109787
110173
  ]),
109788
110174
  _: 1
109789
110175
  }),
109790
- createElementVNode("div", _hoisted_9, [
110176
+ createElementVNode("div", _hoisted_6$1, [
109791
110177
  !__props.isBubble && unref(isShowMenu)("image", __props.showMenu) ? (openBlock(), createBlock(unref(ElTooltip), {
109792
110178
  key: 0,
109793
110179
  class: "box-item",
@@ -109806,6 +110192,7 @@ const _sfc_main$4 = {
109806
110192
  headers: {
109807
110193
  "access-token": __props.info.token
109808
110194
  },
110195
+ accept: ".jpg,.png,.jpeg,.gif",
109809
110196
  "before-upload": handleImageUpload,
109810
110197
  "on-success": uploadFileSuccess
109811
110198
  }, {
@@ -109821,7 +110208,7 @@ const _sfc_main$4 = {
109821
110208
  _: 1
109822
110209
  })) : createCommentVNode("", true)
109823
110210
  ]),
109824
- createElementVNode("div", _hoisted_10, [
110211
+ createElementVNode("div", _hoisted_7$1, [
109825
110212
  !__props.isBubble && unref(isShowMenu)("doc", __props.showMenu) ? (openBlock(), createBlock(unref(ElTooltip), {
109826
110213
  key: 0,
109827
110214
  class: "box-item",
@@ -109848,8 +110235,9 @@ const _sfc_main$4 = {
109848
110235
  default: withCtx(() => [
109849
110236
  createVNode(unref(Icon), {
109850
110237
  icon: "mdi:file-word",
109851
- width: "20"
109852
- })
110238
+ width: "20",
110239
+ class: normalizeClass(isActive2("codeBlock") || isActive2("table") || isActive2("bulletList") || isActive2("orderedList") || isActive2("taskList") ? "icon-gray" : "")
110240
+ }, null, 8, ["class"])
109853
110241
  ]),
109854
110242
  _: 1
109855
110243
  }, 8, ["action", "headers", "disabled"])
@@ -109857,7 +110245,7 @@ const _sfc_main$4 = {
109857
110245
  _: 1
109858
110246
  })) : createCommentVNode("", true)
109859
110247
  ]),
109860
- createElementVNode("div", _hoisted_11, [
110248
+ createElementVNode("div", _hoisted_8$1, [
109861
110249
  !__props.isBubble && unref(isShowMenu)("jupyter", __props.showMenu) ? (openBlock(), createBlock(unref(ElTooltip), {
109862
110250
  key: 0,
109863
110251
  class: "box-item",
@@ -109882,7 +110270,10 @@ const _sfc_main$4 = {
109882
110270
  disabled: isActive2("codeBlock") || isActive2("table") || isActive2("bulletList") || isActive2("orderedList") || isActive2("taskList")
109883
110271
  }, {
109884
110272
  default: withCtx(() => [
109885
- createVNode(unref(Icon), { icon: "logos:jupyter" })
110273
+ createVNode(unref(Icon), {
110274
+ icon: "logos:jupyter",
110275
+ class: normalizeClass(isActive2("codeBlock") || isActive2("table") || isActive2("bulletList") || isActive2("orderedList") || isActive2("taskList") ? "icon-gray" : "")
110276
+ }, null, 8, ["class"])
109886
110277
  ]),
109887
110278
  _: 1
109888
110279
  }, 8, ["action", "headers", "disabled"])
@@ -109925,7 +110316,7 @@ const _sfc_main$4 = {
109925
110316
  placement: "bottom"
109926
110317
  }, {
109927
110318
  default: withCtx(() => [
109928
- createElementVNode("div", _hoisted_12, [
110319
+ createElementVNode("div", _hoisted_9$1, [
109929
110320
  createVNode(unref(ElPopover), {
109930
110321
  placement: "bottom",
109931
110322
  title: "",
@@ -110009,7 +110400,31 @@ const _sfc_main$4 = {
110009
110400
  ]),
110010
110401
  _: 1
110011
110402
  }),
110012
- !__props.isBubble && unref(isShowMenu)("expression", __props.showMenu) ? (openBlock(), createElementBlock("div", _hoisted_13, [
110403
+ !__props.isBubble && unref(isShowMenu)("viewSource", __props.showMenu) ? (openBlock(), createBlock(unref(ElTooltip), {
110404
+ key: 5,
110405
+ class: "box-item",
110406
+ effect: "dark",
110407
+ content: "查看源代码",
110408
+ placement: "bottom"
110409
+ }, {
110410
+ default: withCtx(() => [
110411
+ createVNode(unref(ElButton), {
110412
+ size: "small",
110413
+ onClick: viewSource,
110414
+ link: ""
110415
+ }, {
110416
+ default: withCtx(() => [
110417
+ createVNode(unref(Icon), {
110418
+ icon: "mdi:code-tags",
110419
+ width: "20"
110420
+ })
110421
+ ]),
110422
+ _: 1
110423
+ })
110424
+ ]),
110425
+ _: 1
110426
+ })) : createCommentVNode("", true),
110427
+ !__props.isBubble && unref(isShowMenu)("expression", __props.showMenu) ? (openBlock(), createElementBlock("div", _hoisted_10, [
110013
110428
  createVNode(unref(ElButton), {
110014
110429
  link: "",
110015
110430
  onClick: showExpression
@@ -110032,7 +110447,7 @@ const _sfc_main$4 = {
110032
110447
  };
110033
110448
  }
110034
110449
  };
110035
- const EditorToolbar = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-ad34f900"]]);
110450
+ const EditorToolbar = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-8982114a"]]);
110036
110451
  const _hoisted_1$2 = { class: "bubble-menu" };
110037
110452
  const _sfc_main$3 = {
110038
110453
  __name: "BubbleMenu",
@@ -111517,11 +111932,13 @@ const _hoisted_2 = { key: 1 };
111517
111932
  const _hoisted_3 = { class: "editor-content-container" };
111518
111933
  const _hoisted_4 = { ref: "blockMenuRef" };
111519
111934
  const _hoisted_5 = ["src"];
111520
- const _hoisted_6 = {
111935
+ const _hoisted_6 = { class: "source-dialog-content" };
111936
+ const _hoisted_7 = { class: "dialog-footer" };
111937
+ const _hoisted_8 = {
111521
111938
  key: 2,
111522
111939
  class: "editor-bottom"
111523
111940
  };
111524
- const _hoisted_7 = { class: "editor-bottom-r" };
111941
+ const _hoisted_9 = { class: "editor-bottom-r" };
111525
111942
  const _sfc_main = {
111526
111943
  __name: "index",
111527
111944
  props: {
@@ -111632,8 +112049,11 @@ const _sfc_main = {
111632
112049
  editor.chain().focus().insertContent({
111633
112050
  type: "codeBlock",
111634
112051
  attrs: { language: "javascript" }
111635
- // content: [{ type: "text", text: "// 在这里写代码…" }],
111636
112052
  }).run();
112053
+ } else if (typeof type === "function") {
112054
+ nextTick(() => {
112055
+ type();
112056
+ });
111637
112057
  } else if (type && type != "undele") {
111638
112058
  type();
111639
112059
  }
@@ -111719,6 +112139,34 @@ const _sfc_main = {
111719
112139
  imageSrc.value = e.detail;
111720
112140
  imageDialogVisible.value = true;
111721
112141
  }
112142
+ const sourceDialogVisible = ref(false);
112143
+ const sourceCode = ref("");
112144
+ function openSourceDialog() {
112145
+ sourceCode.value = editor.getHTML();
112146
+ sourceDialogVisible.value = true;
112147
+ }
112148
+ function applySourceCode() {
112149
+ try {
112150
+ isLoading.value = true;
112151
+ loadContentInChunks({
112152
+ editor,
112153
+ content: sourceCode.value,
112154
+ type: "html",
112155
+ extensions: commonExtensions(),
112156
+ chunkSize: 5,
112157
+ onProgress: (p) => {
112158
+ if (p > 0) {
112159
+ isLoading.value = false;
112160
+ }
112161
+ }
112162
+ });
112163
+ sourceDialogVisible.value = false;
112164
+ ElMessage.success("源代码已应用");
112165
+ } catch (error2) {
112166
+ console.error("应用源代码失败:", error2);
112167
+ ElMessage.error("应用源代码失败,请检查代码格式");
112168
+ }
112169
+ }
111722
112170
  const toggleLoading = (data) => {
111723
112171
  isLoading.value = data;
111724
112172
  };
@@ -111747,7 +112195,8 @@ const _sfc_main = {
111747
112195
  showMenu: __props.showMenu,
111748
112196
  onShowLink: _cache[0] || (_cache[0] = ($event) => showLink("top")),
111749
112197
  onToggleLoading: toggleLoading,
111750
- onShowAi: showAi
112198
+ onShowAi: showAi,
112199
+ onShowSource: openSourceDialog
111751
112200
  }, null, 8, ["editor", "info", "limitLength", "showMenu"])
111752
112201
  ])) : createCommentVNode("", true),
111753
112202
  !__props.isInline && !unref(floatAiStatus) ? (openBlock(), createElementBlock("div", _hoisted_2, [
@@ -111821,23 +112270,64 @@ const _sfc_main = {
111821
112270
  }, null, 8, _hoisted_5)
111822
112271
  ]),
111823
112272
  _: 1
112273
+ }, 8, ["modelValue"]),
112274
+ createVNode(unref(ElDialog), {
112275
+ modelValue: sourceDialogVisible.value,
112276
+ "onUpdate:modelValue": _cache[8] || (_cache[8] = ($event) => sourceDialogVisible.value = $event),
112277
+ title: "查看源代码",
112278
+ width: "70%",
112279
+ "close-on-click-modal": false
112280
+ }, {
112281
+ footer: withCtx(() => [
112282
+ createElementVNode("span", _hoisted_7, [
112283
+ createVNode(unref(ElButton), {
112284
+ onClick: _cache[7] || (_cache[7] = ($event) => sourceDialogVisible.value = false)
112285
+ }, {
112286
+ default: withCtx(() => [..._cache[9] || (_cache[9] = [
112287
+ createTextVNode("取消", -1)
112288
+ ])]),
112289
+ _: 1
112290
+ }),
112291
+ createVNode(unref(ElButton), {
112292
+ type: "primary",
112293
+ onClick: applySourceCode
112294
+ }, {
112295
+ default: withCtx(() => [..._cache[10] || (_cache[10] = [
112296
+ createTextVNode("确认", -1)
112297
+ ])]),
112298
+ _: 1
112299
+ })
112300
+ ])
112301
+ ]),
112302
+ default: withCtx(() => [
112303
+ createElementVNode("div", _hoisted_6, [
112304
+ createVNode(unref(ElInput), {
112305
+ modelValue: sourceCode.value,
112306
+ "onUpdate:modelValue": _cache[6] || (_cache[6] = ($event) => sourceCode.value = $event),
112307
+ type: "textarea",
112308
+ rows: 20,
112309
+ placeholder: "HTML源代码"
112310
+ }, null, 8, ["modelValue"])
112311
+ ])
112312
+ ]),
112313
+ _: 1
111824
112314
  }, 8, ["modelValue"])
111825
112315
  ], 2)
111826
112316
  ])), [
111827
112317
  [_directive_loading, unref(isLoading)]
111828
112318
  ]),
111829
- __props.limitLength != Infinity ? (openBlock(), createElementBlock("div", _hoisted_6, [
112319
+ __props.limitLength != Infinity ? (openBlock(), createElementBlock("div", _hoisted_8, [
111830
112320
  createElementVNode("div", null, [
111831
112321
  renderSlot(_ctx.$slots, "default", {}, void 0, true)
111832
112322
  ]),
111833
- createElementVNode("div", _hoisted_7, toDisplayString(unref(getTextLength)(unref(editor).state.doc)) + "/" + toDisplayString(__props.limitLength), 1)
112323
+ createElementVNode("div", _hoisted_9, toDisplayString(unref(getTextLength)(unref(editor).state.doc)) + "/" + toDisplayString(__props.limitLength), 1)
111834
112324
  ])) : createCommentVNode("", true)
111835
112325
  ], 4)
111836
112326
  ], 4);
111837
112327
  };
111838
112328
  }
111839
112329
  };
111840
- const TiptapVue = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-3d89208a"]]);
112330
+ const TiptapVue = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-8ba51e61"]]);
111841
112331
  const components = [
111842
112332
  {
111843
112333
  name: "TiptapVue",