edu360-web-ui 1.0.94 → 1.0.96

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;
@@ -17591,7 +17591,7 @@ var CodeBlock = Node3.create({
17591
17591
  ];
17592
17592
  }
17593
17593
  });
17594
- var index_default$c = CodeBlock;
17594
+ var index_default$d = CodeBlock;
17595
17595
  var Document = Node3.create({
17596
17596
  name: "doc",
17597
17597
  topNode: true,
@@ -19378,7 +19378,7 @@ var Link = Mark2.create({
19378
19378
  return plugins;
19379
19379
  }
19380
19380
  });
19381
- var index_default$b = Link;
19381
+ var index_default$c = Link;
19382
19382
  var __defProp2 = Object.defineProperty;
19383
19383
  var __export = (target, all3) => {
19384
19384
  for (var name in all3)
@@ -20028,7 +20028,7 @@ var Paragraph = Node3.create({
20028
20028
  };
20029
20029
  }
20030
20030
  });
20031
- var index_default$a = Paragraph;
20031
+ var index_default$b = Paragraph;
20032
20032
  var inputRegex$2 = /(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/;
20033
20033
  var pasteRegex$1 = /(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g;
20034
20034
  var Strike = Mark2.create({
@@ -20094,6 +20094,7 @@ var Strike = Mark2.create({
20094
20094
  ];
20095
20095
  }
20096
20096
  });
20097
+ var index_default$a = Strike;
20097
20098
  var Text = Node3.create({
20098
20099
  name: "text",
20099
20100
  group: "inline"
@@ -21821,6 +21822,22 @@ var Highlight = Mark2.create({
21821
21822
  }
21822
21823
  });
21823
21824
  var index_default$7 = Highlight;
21825
+ const CustomUnderline = index_default$9.extend({
21826
+ parseHTML() {
21827
+ return [
21828
+ {
21829
+ tag: "u"
21830
+ },
21831
+ {
21832
+ style: "text-decoration",
21833
+ getAttrs: (value) => value === "underline" && null
21834
+ }
21835
+ ];
21836
+ },
21837
+ renderHTML({ HTMLAttributes }) {
21838
+ return ["u", HTMLAttributes, 0];
21839
+ }
21840
+ });
21824
21841
  var inputRegex = /(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/;
21825
21842
  var Image = Node3.create({
21826
21843
  name: "image",
@@ -24518,6 +24535,49 @@ var TextAlign = Extension.create({
24518
24535
  }
24519
24536
  });
24520
24537
  var index_default$2 = TextAlign;
24538
+ const CustomTextAlign = index_default$2.extend({
24539
+ addGlobalAttributes() {
24540
+ return [
24541
+ {
24542
+ types: this.options.types,
24543
+ attributes: {
24544
+ textAlign: {
24545
+ default: this.options.defaultAlignment,
24546
+ parseHTML: (element) => element.style.textAlign || this.options.defaultAlignment,
24547
+ renderHTML: (attributes) => {
24548
+ if (attributes.textAlign === this.options.defaultAlignment) {
24549
+ return {};
24550
+ }
24551
+ return { style: `text-align: ${attributes.textAlign}` };
24552
+ }
24553
+ }
24554
+ }
24555
+ }
24556
+ ];
24557
+ }
24558
+ });
24559
+ const CustomStrike = index_default$a.extend({
24560
+ parseHTML() {
24561
+ return [
24562
+ {
24563
+ tag: "s"
24564
+ },
24565
+ {
24566
+ tag: "del"
24567
+ },
24568
+ {
24569
+ tag: "strike"
24570
+ },
24571
+ {
24572
+ style: "text-decoration",
24573
+ getAttrs: (value) => value === "line-through" && null
24574
+ }
24575
+ ];
24576
+ },
24577
+ renderHTML({ HTMLAttributes }) {
24578
+ return ["s", HTMLAttributes, 0];
24579
+ }
24580
+ });
24521
24581
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
24522
24582
  function getDefaultExportFromCjs(x) {
24523
24583
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
@@ -26185,7 +26245,7 @@ function LowlightPlugin({
26185
26245
  });
26186
26246
  return lowlightPlugin;
26187
26247
  }
26188
- var CodeBlockLowlight = index_default$c.extend({
26248
+ var CodeBlockLowlight = index_default$d.extend({
26189
26249
  addOptions() {
26190
26250
  var _a3;
26191
26251
  return {
@@ -77512,7 +77572,7 @@ function sendQuery(config2, payload, query, done) {
77512
77572
  } else {
77513
77573
  resources = config2.resources.slice(startIndex).concat(config2.resources.slice(0, startIndex));
77514
77574
  }
77515
- const startTime = Date.now();
77575
+ const startTime2 = Date.now();
77516
77576
  let status = "pending";
77517
77577
  let queriesSent = 0;
77518
77578
  let lastError;
@@ -77550,7 +77610,7 @@ function sendQuery(config2, payload, query, done) {
77550
77610
  }
77551
77611
  function getQueryStatus() {
77552
77612
  return {
77553
- startTime,
77613
+ startTime: startTime2,
77554
77614
  payload,
77555
77615
  status,
77556
77616
  queriesSent,
@@ -78316,7 +78376,7 @@ const _export_sfc = (sfc, props) => {
78316
78376
  return target;
78317
78377
  };
78318
78378
  const _hoisted_1$9 = { class: "code-block-view-cont" };
78319
- const _hoisted_2$7 = { class: "code-toolbar" };
78379
+ const _hoisted_2$8 = { class: "code-toolbar" };
78320
78380
  const _hoisted_3$6 = { class: "code-toolbar-right" };
78321
78381
  const _hoisted_4$4 = { class: "el-dropdown-link" };
78322
78382
  const _hoisted_5$4 = { style: { "height": "300px" } };
@@ -78381,7 +78441,7 @@ const _sfc_main$b = {
78381
78441
  }, {
78382
78442
  default: withCtx(() => [
78383
78443
  createElementVNode("div", _hoisted_1$9, [
78384
- createElementVNode("div", _hoisted_2$7, [
78444
+ createElementVNode("div", _hoisted_2$8, [
78385
78445
  _cache[0] || (_cache[0] = createElementVNode("div", null, null, -1)),
78386
78446
  createElementVNode("div", _hoisted_3$6, [
78387
78447
  unref(showType) != "ai" ? (openBlock(), createBlock(unref(ElDropdown), {
@@ -88462,14 +88522,22 @@ const commonExtensions = () => [
88462
88522
  // 启用1-6级标题
88463
88523
  bulletList: false,
88464
88524
  orderedList: false,
88465
- listItem: false
88525
+ listItem: false,
88526
+ strike: false,
88527
+ // 禁用默认中划线,使用自定义版本
88528
+ bold: true,
88529
+ // 确保启用粗体
88530
+ italic: true
88531
+ // 确保启用斜体
88466
88532
  }),
88467
88533
  TextStyle,
88468
88534
  // 文本样式扩展
88469
88535
  Color,
88470
88536
  // 颜色选择扩展
88471
- index_default$9,
88472
- // 下划线功能
88537
+ CustomUnderline,
88538
+ // 自定义下划线功能
88539
+ CustomStrike,
88540
+ // 自定义中划线功能
88473
88541
  FontSize,
88474
88542
  // 自定义字体大小
88475
88543
  // 图片功能配置
@@ -88520,10 +88588,12 @@ const commonExtensions = () => [
88520
88588
  nested: false
88521
88589
  }),
88522
88590
  AutoOrderedOnEnter,
88523
- index_default$2.configure({
88524
- types: ["heading", "paragraph"]
88591
+ CustomTextAlign.configure({
88592
+ types: ["heading", "paragraph"],
88593
+ alignments: ["left", "center", "right", "justify"],
88594
+ defaultAlignment: "left"
88525
88595
  }),
88526
- index_default$b.configure({
88596
+ index_default$c.configure({
88527
88597
  openOnClick: false,
88528
88598
  defaultProtocol: "https"
88529
88599
  })
@@ -97280,8 +97350,8 @@ function parseContentToJSON(content, type, extensions) {
97280
97350
  return json2.content || [];
97281
97351
  } else if (type === "html") {
97282
97352
  let data = purify.sanitize(content, {
97283
- ALLOWED_TAGS: ["b", "i", "em", "strong", "a", "p", "h1", "h2", "h3", "h5", "h6", "ul", "ol", "li", "img", "pre", "code", "div", "text", "span", "font", "table", "thead", "tbody", "tr", "th", "td", "br"],
97284
- ALLOWED_ATTR: ["href", "src", "alt", "title"]
97353
+ ALLOWED_TAGS: ["b", "i", "em", "strong", "a", "p", "h1", "h2", "h3", "h4", "h5", "h6", "ul", "ol", "li", "img", "pre", "code", "div", "text", "span", "font", "table", "thead", "tbody", "tr", "th", "td", "br", "u", "s", "del", "strike", "mark"],
97354
+ ALLOWED_ATTR: ["href", "src", "alt", "title", "style", "class", "data-type"]
97285
97355
  });
97286
97356
  const json2 = generateJSON(data, extensions);
97287
97357
  return json2.content || [];
@@ -97295,7 +97365,9 @@ function loadContentInChunks({
97295
97365
  extensions,
97296
97366
  chunkSize = 50,
97297
97367
  onProgress,
97298
- onComplete
97368
+ onComplete,
97369
+ isPaste = false
97370
+ // 新增:标识是否为粘贴操作
97299
97371
  }) {
97300
97372
  if (!editor || !content) return;
97301
97373
  let blocks;
@@ -97319,14 +97391,34 @@ function loadContentInChunks({
97319
97391
  onComplete == null ? void 0 : onComplete();
97320
97392
  return;
97321
97393
  }
97322
- editor.chain().insertContentAt(pos, chunk).run();
97323
- index += chunkSize;
97324
- onProgress == null ? void 0 : onProgress(Math.min(index / total, 1));
97325
- const nextPos = editor.state.doc.content.size;
97326
- if ("requestIdleCallback" in window) {
97327
- requestIdleCallback(() => insertChunk(nextPos));
97328
- } else {
97329
- setTimeout(() => insertChunk(nextPos), 16);
97394
+ try {
97395
+ const beforeSize = editor.state.doc.content.size;
97396
+ if (pos < 0 || pos > beforeSize) {
97397
+ pos = beforeSize;
97398
+ }
97399
+ editor.chain().focus().insertContentAt(pos, chunk).run();
97400
+ index += chunkSize;
97401
+ onProgress == null ? void 0 : onProgress(Math.min(index / total, 1));
97402
+ let nextPos;
97403
+ if (isPaste) {
97404
+ const afterSize = editor.state.doc.content.size;
97405
+ const insertedSize = afterSize - beforeSize;
97406
+ if (insertedSize <= 0 || insertedSize > beforeSize * 2) {
97407
+ nextPos = editor.state.doc.content.size;
97408
+ } else {
97409
+ nextPos = pos + insertedSize;
97410
+ }
97411
+ } else {
97412
+ nextPos = editor.state.doc.content.size;
97413
+ }
97414
+ if ("requestIdleCallback" in window) {
97415
+ requestIdleCallback(() => insertChunk(nextPos), { timeout: 50 });
97416
+ } else {
97417
+ setTimeout(() => insertChunk(nextPos), 0);
97418
+ }
97419
+ } catch (error2) {
97420
+ console.error("[分块插入] 插入失败:", error2);
97421
+ onComplete == null ? void 0 : onComplete();
97330
97422
  }
97331
97423
  }
97332
97424
  insertChunk(insertPos);
@@ -98115,7 +98207,7 @@ function htmlToMarkdown(html2) {
98115
98207
  return turndownService.turndown(html2);
98116
98208
  }
98117
98209
  const _hoisted_1$8 = { class: "ai-input" };
98118
- const _hoisted_2$6 = {
98210
+ const _hoisted_2$7 = {
98119
98211
  key: 0,
98120
98212
  class: "ai-btns"
98121
98213
  };
@@ -98133,10 +98225,10 @@ const _hoisted_6$3 = {
98133
98225
  class: "result-image"
98134
98226
  };
98135
98227
  const _hoisted_7$3 = ["onClick"];
98136
- const _hoisted_8$2 = ["src"];
98137
- const _hoisted_9$2 = { class: "result-image-checkbox" };
98228
+ const _hoisted_8$3 = ["src"];
98229
+ const _hoisted_9$3 = { class: "result-image-checkbox" };
98138
98230
  const _hoisted_10$2 = { class: "result-text" };
98139
- const _hoisted_11$1 = { class: "result-actions" };
98231
+ const _hoisted_11 = { class: "result-actions" };
98140
98232
  const _sfc_main$a = {
98141
98233
  __name: "AiComponent",
98142
98234
  props: {
@@ -98391,7 +98483,7 @@ const _sfc_main$a = {
98391
98483
  ], 512), [
98392
98484
  [vShow, !unref(showResult)]
98393
98485
  ]),
98394
- !unref(showResult) ? (openBlock(), createElementBlock("div", _hoisted_2$6, [
98486
+ !unref(showResult) ? (openBlock(), createElementBlock("div", _hoisted_2$7, [
98395
98487
  createElementVNode("div", {
98396
98488
  class: normalizeClass(["ai-btns-send", { "is-disabled": !question.value }]),
98397
98489
  onClick: send2
@@ -98538,8 +98630,8 @@ const _sfc_main$a = {
98538
98630
  src: item.img,
98539
98631
  alt: "",
98540
98632
  width: "100%"
98541
- }, null, 8, _hoisted_8$2),
98542
- createElementVNode("div", _hoisted_9$2, [
98633
+ }, null, 8, _hoisted_8$3),
98634
+ createElementVNode("div", _hoisted_9$3, [
98543
98635
  createVNode(_component_el_checkbox, {
98544
98636
  modelValue: item.checked,
98545
98637
  "onUpdate:modelValue": ($event) => item.checked = $event,
@@ -98555,7 +98647,7 @@ const _sfc_main$a = {
98555
98647
  editor: unref(previewEditor)
98556
98648
  }, null, 8, ["editor"])) : createCommentVNode("", true)
98557
98649
  ]),
98558
- createElementVNode("div", _hoisted_11$1, [
98650
+ createElementVNode("div", _hoisted_11, [
98559
98651
  createVNode(unref(ElButton), {
98560
98652
  disabled: unref(typewriterLoading),
98561
98653
  size: "small",
@@ -101009,7 +101101,8 @@ defineComponent({
101009
101101
  };
101010
101102
  }
101011
101103
  });
101012
- const _hoisted_1$7 = { class: "text-right mt-2" };
101104
+ const _hoisted_1$7 = { class: "flex justify-between items-center mt-2" };
101105
+ const _hoisted_2$6 = { key: 1 };
101013
101106
  const _sfc_main$8 = {
101014
101107
  __name: "LinkToolbar",
101015
101108
  props: {
@@ -101027,6 +101120,9 @@ const _sfc_main$8 = {
101027
101120
  href: ""
101028
101121
  });
101029
101122
  let currentPos = 0;
101123
+ const hasExistingLink = computed(() => {
101124
+ return !!form.href && form.text;
101125
+ });
101030
101126
  const open = () => {
101031
101127
  console.log("22222");
101032
101128
  const { editor } = props;
@@ -101084,6 +101180,11 @@ const _sfc_main$8 = {
101084
101180
  const close2 = () => {
101085
101181
  show.value = false;
101086
101182
  };
101183
+ const removeLink = () => {
101184
+ const { editor } = props;
101185
+ editor.chain().focus().unsetLink().run();
101186
+ close2();
101187
+ };
101087
101188
  onMounted(() => {
101088
101189
  document.addEventListener("mousedown", handleClickOutside);
101089
101190
  });
@@ -101129,25 +101230,58 @@ const _sfc_main$8 = {
101129
101230
  _: 1
101130
101231
  }, 8, ["model"]),
101131
101232
  createElementVNode("div", _hoisted_1$7, [
101132
- createVNode(unref(ElButton), {
101233
+ hasExistingLink.value ? (openBlock(), createBlock(unref(ElButton), {
101234
+ key: 0,
101133
101235
  size: "small",
101134
- onClick: close2
101236
+ onClick: removeLink,
101237
+ class: "unlink-btn"
101135
101238
  }, {
101136
101239
  default: withCtx(() => [..._cache[2] || (_cache[2] = [
101137
- createTextVNode("取消", -1)
101138
- ])]),
101139
- _: 1
101140
- }),
101141
- createVNode(unref(ElButton), {
101142
- size: "small",
101143
- type: "primary",
101144
- onClick: applyLink
101145
- }, {
101146
- default: withCtx(() => [..._cache[3] || (_cache[3] = [
101147
- createTextVNode("确定", -1)
101240
+ createElementVNode("svg", {
101241
+ xmlns: "http://www.w3.org/2000/svg",
101242
+ width: "16",
101243
+ height: "16",
101244
+ viewBox: "0 0 24 24",
101245
+ fill: "none",
101246
+ stroke: "currentColor",
101247
+ "stroke-width": "2",
101248
+ "stroke-linecap": "round",
101249
+ "stroke-linejoin": "round"
101250
+ }, [
101251
+ 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" }),
101252
+ 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" }),
101253
+ createElementVNode("line", {
101254
+ x1: "4",
101255
+ y1: "20",
101256
+ x2: "20",
101257
+ y2: "4"
101258
+ })
101259
+ ], -1),
101260
+ createElementVNode("span", { class: "ml-1" }, "取消链接", -1)
101148
101261
  ])]),
101149
101262
  _: 1
101150
- })
101263
+ })) : (openBlock(), createElementBlock("div", _hoisted_2$6)),
101264
+ createElementVNode("div", null, [
101265
+ createVNode(unref(ElButton), {
101266
+ size: "small",
101267
+ onClick: close2
101268
+ }, {
101269
+ default: withCtx(() => [..._cache[3] || (_cache[3] = [
101270
+ createTextVNode("取消", -1)
101271
+ ])]),
101272
+ _: 1
101273
+ }),
101274
+ createVNode(unref(ElButton), {
101275
+ size: "small",
101276
+ type: "primary",
101277
+ onClick: applyLink
101278
+ }, {
101279
+ default: withCtx(() => [..._cache[4] || (_cache[4] = [
101280
+ createTextVNode("确定", -1)
101281
+ ])]),
101282
+ _: 1
101283
+ })
101284
+ ])
101151
101285
  ])
101152
101286
  ]),
101153
101287
  _: 1
@@ -101156,7 +101290,7 @@ const _sfc_main$8 = {
101156
101290
  };
101157
101291
  }
101158
101292
  };
101159
- const LinkToolbar = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["__scopeId", "data-v-1a77d30e"]]);
101293
+ const LinkToolbar = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["__scopeId", "data-v-652c40fc"]]);
101160
101294
  const _hoisted_1$6 = { class: "sudoku-div" };
101161
101295
  const _hoisted_2$5 = ["row", "col", "onMouseover", "onClick"];
101162
101296
  const _sfc_main$7 = {
@@ -107773,8 +107907,8 @@ const _hoisted_4$2 = { class: "floating-menu-common-list" };
107773
107907
  const _hoisted_5$2 = { class: "block-menu-item-icon" };
107774
107908
  const _hoisted_6$2 = { class: "block-menu-item" };
107775
107909
  const _hoisted_7$2 = { class: "block-menu-item-icon" };
107776
- const _hoisted_8$1 = { class: "block-menu-item-icon" };
107777
- const _hoisted_9$1 = { class: "block-menu-item-icon" };
107910
+ const _hoisted_8$2 = { class: "block-menu-item-icon" };
107911
+ const _hoisted_9$2 = { class: "block-menu-item-icon" };
107778
107912
  const _hoisted_10$1 = { class: "block-menu-item-icon" };
107779
107913
  const _sfc_main$6 = {
107780
107914
  __name: "BlockMenu",
@@ -107844,6 +107978,7 @@ const _sfc_main$6 = {
107844
107978
  };
107845
107979
  const emit = __emit;
107846
107980
  const handleDocUpload = () => {
107981
+ if (isActive2("codeBlock") || isActive2("table") || isActive2("bulletList") || isActive2("orderedList") || isActive2("taskList")) return;
107847
107982
  emit("toggleLoading", true);
107848
107983
  emit("closemenu");
107849
107984
  };
@@ -107875,6 +108010,7 @@ const _sfc_main$6 = {
107875
108010
  });
107876
108011
  };
107877
108012
  const handleJupyterUpload = () => {
108013
+ if (isActive2("codeBlock") || isActive2("table") || isActive2("bulletList") || isActive2("orderedList") || isActive2("taskList")) return;
107878
108014
  emit("toggleLoading", true);
107879
108015
  closePopover();
107880
108016
  emit("closemenu");
@@ -107917,13 +108053,31 @@ const _sfc_main$6 = {
107917
108053
  emit("closemenu", "codeblock");
107918
108054
  };
107919
108055
  let tablePopoverVisible = ref(false);
108056
+ let selectedTableData = ref(null);
107920
108057
  const selectTable = (data) => {
108058
+ selectedTableData.value = data;
107921
108059
  tablePopoverVisible.value = false;
107922
108060
  nextTick(() => {
107923
- emit("closemenu");
107924
- setTimeout(() => {
107925
- props.editor.chain().focus().insertTable({ rows: data.row, cols: data.col, withHeaderRow: true }).run();
107926
- }, 0);
108061
+ emit("closemenu", () => {
108062
+ setTimeout(() => {
108063
+ const { state } = props.editor;
108064
+ const { $from } = state.selection;
108065
+ const currentNode = $from.node();
108066
+ if (currentNode && currentNode.type.name === "paragraph" && currentNode.content.size > 0) {
108067
+ props.editor.chain().focus().insertContent("<p></p>").insertTable({
108068
+ rows: selectedTableData.value.row,
108069
+ cols: selectedTableData.value.col,
108070
+ withHeaderRow: true
108071
+ }).run();
108072
+ } else {
108073
+ props.editor.chain().focus().insertTable({
108074
+ rows: selectedTableData.value.row,
108075
+ cols: selectedTableData.value.col,
108076
+ withHeaderRow: true
108077
+ }).run();
108078
+ }
108079
+ }, 50);
108080
+ });
107927
108081
  });
107928
108082
  };
107929
108083
  return (_ctx, _cache) => {
@@ -108246,7 +108400,7 @@ const _sfc_main$6 = {
108246
108400
  class: normalizeClass(["block-menu-item", { "icon-gray": isActive2("codeBlock") || isActive2("table") || isActive2("bulletList") || isActive2("orderedList") || isActive2("taskList") }]),
108247
108401
  ref: "tableRef"
108248
108402
  }, [
108249
- createElementVNode("div", _hoisted_8$1, [
108403
+ createElementVNode("div", _hoisted_8$2, [
108250
108404
  createVNode(unref(Icon), {
108251
108405
  icon: "material-symbols:table-outline-sharp",
108252
108406
  width: "20"
@@ -108278,13 +108432,13 @@ const _sfc_main$6 = {
108278
108432
  accept: ".doc,.docx",
108279
108433
  "on-success": uploadDocSuccess,
108280
108434
  "before-upload": handleDocUpload,
108281
- disabled: isActive2("codeBlock") || isActive2("table")
108435
+ disabled: isActive2("codeBlock") || isActive2("table") || isActive2("bulletList") || isActive2("orderedList") || isActive2("taskList")
108282
108436
  }, {
108283
108437
  default: withCtx(() => [
108284
108438
  createElementVNode("div", {
108285
108439
  class: normalizeClass(["block-menu-item", { "icon-gray": isActive2("codeBlock") || isActive2("table") || isActive2("bulletList") || isActive2("orderedList") || isActive2("taskList") }])
108286
108440
  }, [
108287
- createElementVNode("div", _hoisted_9$1, [
108441
+ createElementVNode("div", _hoisted_9$2, [
108288
108442
  createVNode(unref(Icon), { icon: "tabler:file-word" })
108289
108443
  ]),
108290
108444
  _cache[27] || (_cache[27] = createElementVNode("div", null, "上传word文件", -1))
@@ -108335,7 +108489,7 @@ const _sfc_main$6 = {
108335
108489
  };
108336
108490
  }
108337
108491
  };
108338
- const BlockMenu = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__scopeId", "data-v-c9b1c163"]]);
108492
+ const BlockMenu = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__scopeId", "data-v-49f2614c"]]);
108339
108493
  function BlockMenuPlugin(editor, options) {
108340
108494
  const PLUGIN_KEY = new PluginKey("blockMenu");
108341
108495
  let wrapperEl = options.wrapperEl || null;
@@ -108481,6 +108635,34 @@ Extension.create({
108481
108635
  }
108482
108636
  });
108483
108637
  const CustomImage = index_default$6.extend({
108638
+ addAttributes() {
108639
+ var _a3;
108640
+ return {
108641
+ ...(_a3 = this.parent) == null ? void 0 : _a3.call(this),
108642
+ width: {
108643
+ default: null,
108644
+ renderHTML: (attrs) => {
108645
+ if (!attrs.width) return {};
108646
+ return { width: attrs.width + "px" };
108647
+ },
108648
+ parseHTML: (element) => {
108649
+ const w2 = element.getAttribute("width") || element.style.width;
108650
+ return w2 ? parseInt(w2) : null;
108651
+ }
108652
+ },
108653
+ height: {
108654
+ default: null,
108655
+ renderHTML: (attrs) => {
108656
+ if (!attrs.height) return {};
108657
+ return { height: attrs.height + "px" };
108658
+ },
108659
+ parseHTML: (element) => {
108660
+ const h2 = element.getAttribute("height") || element.style.height;
108661
+ return h2 ? parseInt(h2) : null;
108662
+ }
108663
+ }
108664
+ };
108665
+ },
108484
108666
  addProseMirrorPlugins() {
108485
108667
  const PLUGIN_KEY = new PluginKey("customImageClick");
108486
108668
  return [
@@ -108488,22 +108670,276 @@ const CustomImage = index_default$6.extend({
108488
108670
  key: PLUGIN_KEY,
108489
108671
  props: {
108490
108672
  handleDOMEvents: {
108491
- click: (view, event) => {
108492
- const target = event.target;
108493
- if (target.tagName === "IMG") {
108494
- window.dispatchEvent(new CustomEvent("tiptap-image-click", { detail: target.src }));
108495
- return true;
108496
- }
108497
- return false;
108498
- }
108673
+ // 去掉“点击图片放大”行为,仅通过工具条按钮查看原图
108674
+ click: () => false
108499
108675
  }
108500
108676
  }
108501
108677
  })
108502
108678
  ];
108679
+ },
108680
+ addNodeView() {
108681
+ return ({ node, editor, getPos }) => {
108682
+ const wrapper = document.createElement("div");
108683
+ wrapper.style.position = "relative";
108684
+ wrapper.style.display = "inline-block";
108685
+ wrapper.style.lineHeight = "0";
108686
+ const img = document.createElement("img");
108687
+ img.src = node.attrs.src;
108688
+ img.alt = node.attrs.alt || "";
108689
+ img.title = node.attrs.title || "";
108690
+ img.style.display = "block";
108691
+ img.style.borderRadius = "4px";
108692
+ if (node.attrs.width) img.style.width = node.attrs.width + "px";
108693
+ if (node.attrs.height) img.style.height = node.attrs.height + "px";
108694
+ const toolbar = document.createElement("div");
108695
+ toolbar.style.position = "absolute";
108696
+ toolbar.style.top = "8px";
108697
+ toolbar.style.right = "8px";
108698
+ toolbar.style.display = "flex";
108699
+ toolbar.style.gap = "6px";
108700
+ toolbar.style.opacity = "0";
108701
+ toolbar.style.visibility = "hidden";
108702
+ toolbar.style.transition = "all .2s";
108703
+ toolbar.style.zIndex = "2";
108704
+ const getIconSvg = (type) => {
108705
+ if (type === "view") {
108706
+ 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>`;
108707
+ }
108708
+ if (type === "reset") {
108709
+ 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>`;
108710
+ }
108711
+ if (type === "fit") {
108712
+ 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>`;
108713
+ }
108714
+ return "";
108715
+ };
108716
+ const makeBtn = (type, title) => {
108717
+ const btn = document.createElement("button");
108718
+ btn.type = "button";
108719
+ btn.title = title;
108720
+ btn.style.width = "30px";
108721
+ btn.style.height = "30px";
108722
+ btn.style.padding = "0";
108723
+ btn.style.border = "none";
108724
+ btn.style.borderRadius = "6px";
108725
+ btn.style.background = "rgba(0,0,0,.7)";
108726
+ btn.style.color = "#fff";
108727
+ btn.style.cursor = "pointer";
108728
+ btn.style.display = "flex";
108729
+ btn.style.alignItems = "center";
108730
+ btn.style.justifyContent = "center";
108731
+ btn.style.transition = "all .2s";
108732
+ btn.style.boxShadow = "0 2px 8px rgba(0,0,0,.2)";
108733
+ btn.innerHTML = getIconSvg(type);
108734
+ btn.addEventListener("mouseenter", () => {
108735
+ btn.style.background = "rgba(0,0,0,.9)";
108736
+ });
108737
+ btn.addEventListener("mouseleave", () => {
108738
+ btn.style.background = "rgba(0,0,0,.7)";
108739
+ });
108740
+ return btn;
108741
+ };
108742
+ const viewBtn = makeBtn("view", "查看原图");
108743
+ const fitBtn = makeBtn("fit", "适配编辑区宽度");
108744
+ const resetBtn = makeBtn("reset", "重置大小");
108745
+ toolbar.appendChild(viewBtn);
108746
+ toolbar.appendChild(fitBtn);
108747
+ toolbar.appendChild(resetBtn);
108748
+ viewBtn.addEventListener("click", (e) => {
108749
+ e.preventDefault();
108750
+ e.stopPropagation();
108751
+ window.dispatchEvent(new CustomEvent("tiptap-image-click", { detail: img.src }));
108752
+ });
108753
+ resetBtn.addEventListener("click", (e) => {
108754
+ e.preventDefault();
108755
+ e.stopPropagation();
108756
+ if (typeof getPos === "function") {
108757
+ const pos = getPos();
108758
+ const tr2 = editor.view.state.tr.setNodeMarkup(pos, null, {
108759
+ ...node.attrs,
108760
+ width: null,
108761
+ height: null
108762
+ });
108763
+ editor.view.dispatch(tr2);
108764
+ }
108765
+ });
108766
+ fitBtn.addEventListener("click", (e) => {
108767
+ e.preventDefault();
108768
+ e.stopPropagation();
108769
+ const editorDom = editor.view.dom;
108770
+ if (!editorDom) return;
108771
+ const containerWidth = Math.max(50, editorDom.clientWidth - 60);
108772
+ const naturalW = img.naturalWidth || img.offsetWidth || 1;
108773
+ const naturalH = img.naturalHeight || img.offsetHeight || 1;
108774
+ const aspect = naturalW / naturalH;
108775
+ const targetW = Math.round(containerWidth);
108776
+ const targetH = Math.round(targetW / aspect);
108777
+ img.style.width = targetW + "px";
108778
+ img.style.height = targetH + "px";
108779
+ if (typeof getPos === "function") {
108780
+ const pos = getPos();
108781
+ const tr2 = editor.view.state.tr.setNodeMarkup(pos, null, {
108782
+ ...node.attrs,
108783
+ width: targetW,
108784
+ height: targetH
108785
+ });
108786
+ editor.view.dispatch(tr2);
108787
+ }
108788
+ });
108789
+ const handlePositions = ["nw", "ne", "sw", "se"];
108790
+ const handles = {};
108791
+ const createHandle = (pos) => {
108792
+ const h2 = document.createElement("div");
108793
+ h2.dataset.position = pos;
108794
+ h2.style.position = "absolute";
108795
+ h2.style.width = "8px";
108796
+ h2.style.height = "8px";
108797
+ h2.style.background = "#fff";
108798
+ h2.style.border = "2px solid rgb(37,108,251)";
108799
+ h2.style.borderRadius = "50%";
108800
+ h2.style.opacity = "0";
108801
+ h2.style.visibility = "hidden";
108802
+ h2.style.transition = "all .2s";
108803
+ h2.style.zIndex = "1";
108804
+ h2.style.boxShadow = "0 2px 6px rgba(0,0,0,.15)";
108805
+ if (pos === "nw") {
108806
+ h2.style.top = "-4px";
108807
+ h2.style.left = "10px";
108808
+ h2.style.cursor = "nwse-resize";
108809
+ }
108810
+ if (pos === "ne") {
108811
+ h2.style.top = "-4px";
108812
+ h2.style.right = "14px";
108813
+ h2.style.cursor = "nesw-resize";
108814
+ }
108815
+ if (pos === "sw") {
108816
+ h2.style.bottom = "-4px";
108817
+ h2.style.left = "10px";
108818
+ h2.style.cursor = "nesw-resize";
108819
+ }
108820
+ if (pos === "se") {
108821
+ h2.style.bottom = "-4px";
108822
+ h2.style.right = "14px";
108823
+ h2.style.cursor = "nwse-resize";
108824
+ }
108825
+ h2.addEventListener("mouseenter", () => {
108826
+ h2.style.background = "rgb(37,108,251)";
108827
+ h2.style.transform = "scale(1.3)";
108828
+ });
108829
+ h2.addEventListener("mouseleave", () => {
108830
+ h2.style.background = "#fff";
108831
+ h2.style.transform = "scale(1)";
108832
+ });
108833
+ return h2;
108834
+ };
108835
+ handlePositions.forEach((p) => {
108836
+ handles[p] = createHandle(p);
108837
+ });
108838
+ const showUI = () => {
108839
+ toolbar.style.opacity = "1";
108840
+ toolbar.style.visibility = "visible";
108841
+ Object.values(handles).forEach((h2) => {
108842
+ h2.style.opacity = "1";
108843
+ h2.style.visibility = "visible";
108844
+ });
108845
+ };
108846
+ const hideUI = () => {
108847
+ toolbar.style.opacity = "0";
108848
+ toolbar.style.visibility = "hidden";
108849
+ Object.values(handles).forEach((h2) => {
108850
+ h2.style.opacity = "0";
108851
+ h2.style.visibility = "hidden";
108852
+ });
108853
+ };
108854
+ wrapper.addEventListener("mouseenter", showUI);
108855
+ wrapper.addEventListener("mouseleave", hideUI);
108856
+ const startResize = (downEvent, position) => {
108857
+ downEvent.preventDefault();
108858
+ downEvent.stopPropagation();
108859
+ const startX = downEvent.clientX;
108860
+ const startY = downEvent.clientY;
108861
+ const startWidth = img.offsetWidth;
108862
+ const startHeight = img.offsetHeight;
108863
+ const aspect = startWidth / startHeight || 1;
108864
+ const isLeft = position.includes("w");
108865
+ const isTop = position.includes("n");
108866
+ const onMove = (moveEvent) => {
108867
+ let dx = moveEvent.clientX - startX;
108868
+ let dy = moveEvent.clientY - startY;
108869
+ if (isLeft) dx = -dx;
108870
+ if (isTop) dy = -dy;
108871
+ const keepRatio = !moveEvent.shiftKey;
108872
+ let newW, newH;
108873
+ if (keepRatio) {
108874
+ const d2 = Math.max(dx, dy);
108875
+ newW = Math.max(50, startWidth + d2);
108876
+ newH = Math.max(50, newW / aspect);
108877
+ } else {
108878
+ newW = Math.max(50, startWidth + dx);
108879
+ newH = Math.max(50, startHeight + dy);
108880
+ }
108881
+ img.style.width = newW + "px";
108882
+ img.style.height = newH + "px";
108883
+ };
108884
+ const onUp = (upEvent) => {
108885
+ document.removeEventListener("mousemove", onMove);
108886
+ document.removeEventListener("mouseup", onUp);
108887
+ let dx = upEvent.clientX - startX;
108888
+ let dy = upEvent.clientY - startY;
108889
+ if (isLeft) dx = -dx;
108890
+ if (isTop) dy = -dy;
108891
+ const keepRatio = !upEvent.shiftKey;
108892
+ let finalW, finalH;
108893
+ if (keepRatio) {
108894
+ const d2 = Math.max(dx, dy);
108895
+ finalW = Math.max(50, startWidth + d2);
108896
+ finalH = Math.max(50, finalW / aspect);
108897
+ } else {
108898
+ finalW = Math.max(50, startWidth + dx);
108899
+ finalH = Math.max(50, startHeight + dy);
108900
+ }
108901
+ if (typeof getPos === "function") {
108902
+ const pos = getPos();
108903
+ const tr2 = editor.view.state.tr.setNodeMarkup(pos, null, {
108904
+ ...node.attrs,
108905
+ width: Math.round(finalW),
108906
+ height: Math.round(finalH)
108907
+ });
108908
+ editor.view.dispatch(tr2);
108909
+ }
108910
+ };
108911
+ document.addEventListener("mousemove", onMove);
108912
+ document.addEventListener("mouseup", onUp);
108913
+ };
108914
+ handlePositions.forEach((p) => {
108915
+ handles[p].addEventListener("mousedown", (e) => startResize(e, p));
108916
+ });
108917
+ wrapper.appendChild(img);
108918
+ wrapper.appendChild(toolbar);
108919
+ handlePositions.forEach((p) => wrapper.appendChild(handles[p]));
108920
+ return {
108921
+ dom: wrapper,
108922
+ contentDOM: null,
108923
+ update: (updatedNode) => {
108924
+ if (updatedNode.type.name !== "image") return false;
108925
+ img.src = updatedNode.attrs.src;
108926
+ img.alt = updatedNode.attrs.alt || "";
108927
+ img.title = updatedNode.attrs.title || "";
108928
+ if (updatedNode.attrs.width) img.style.width = updatedNode.attrs.width + "px";
108929
+ else img.style.width = "";
108930
+ if (updatedNode.attrs.height) img.style.height = updatedNode.attrs.height + "px";
108931
+ else img.style.height = "";
108932
+ return true;
108933
+ },
108934
+ destroy: () => {
108935
+ wrapper.remove();
108936
+ }
108937
+ };
108938
+ };
108503
108939
  }
108504
108940
  });
108505
108941
  createLowlight();
108506
- index_default$a.extend({
108942
+ index_default$b.extend({
108507
108943
  content: "inline*"
108508
108944
  // 只允许 inline node
108509
108945
  });
@@ -108511,6 +108947,117 @@ const CustomTableCell = index_default$4.extend({
108511
108947
  content: "(paragraph | bulletList | orderedList)*"
108512
108948
  // 列表允许嵌套
108513
108949
  });
108950
+ function isMarkdown(text2) {
108951
+ if (!text2 || text2.length < 3) return false;
108952
+ const patterns = [
108953
+ /^#{1,6}\s+/m,
108954
+ // 标题 # ## ###
108955
+ /^\*\*[^*]+\*\*/m,
108956
+ // 粗体 **text**
108957
+ /^__[^_]+__/m,
108958
+ // 粗体 __text__
108959
+ /^\*[^*]+\*/m,
108960
+ // 斜体 *text*
108961
+ /^_[^_]+_/m,
108962
+ // 斜体 _text_
108963
+ /^\[.+\]\(.+\)/m,
108964
+ // 链接 [text](url)
108965
+ /^!\[.*\]\(.+\)/m,
108966
+ // 图片 ![alt](url)
108967
+ /^```/m,
108968
+ // 代码块 ```
108969
+ /^`[^`]+`/m,
108970
+ // 行内代码 `code`
108971
+ /^[-*+]\s+/m,
108972
+ // 无序列表 - * +
108973
+ /^\d+\.\s+/m,
108974
+ // 有序列表 1. 2.
108975
+ /^>\s+/m,
108976
+ // 引用 >
108977
+ /^\|.+\|.+\|/m,
108978
+ // 表格 | col1 | col2 |
108979
+ /^---+$/m,
108980
+ // 分隔线 ---
108981
+ /^___+$/m,
108982
+ // 分隔线 ___
108983
+ /^\*\*\*+$/m
108984
+ // 分隔线 ***
108985
+ ];
108986
+ const matchCount = patterns.filter((pattern) => pattern.test(text2)).length;
108987
+ return matchCount >= 2;
108988
+ }
108989
+ function parseMarkdownTables(text2) {
108990
+ if (!text2.includes("|")) {
108991
+ return text2;
108992
+ }
108993
+ const lines = text2.split("\n");
108994
+ let result = [];
108995
+ let i = 0;
108996
+ const separatorRegex = /^\|[\s:|-]+\|$/;
108997
+ while (i < lines.length) {
108998
+ const line = lines[i];
108999
+ const trimmedLine = line.trim();
109000
+ if (trimmedLine[0] === "|" && trimmedLine[trimmedLine.length - 1] === "|") {
109001
+ const tableRows = [];
109002
+ while (i < lines.length) {
109003
+ const currentLine = lines[i].trim();
109004
+ if (currentLine[0] !== "|" || currentLine[currentLine.length - 1] !== "|") {
109005
+ break;
109006
+ }
109007
+ if (separatorRegex.test(currentLine)) {
109008
+ tableRows.push({ type: "separator", content: currentLine });
109009
+ } else {
109010
+ tableRows.push({ type: "data", content: currentLine });
109011
+ }
109012
+ i++;
109013
+ }
109014
+ if (tableRows.length > 0) {
109015
+ const tableHtml = convertTableToHtml(tableRows);
109016
+ result.push(tableHtml);
109017
+ }
109018
+ } else {
109019
+ result.push(trimmedLine);
109020
+ i++;
109021
+ }
109022
+ }
109023
+ return result.join("\n");
109024
+ }
109025
+ function convertTableToHtml(rows, hasHeaderSeparator) {
109026
+ if (rows.length === 0) return "";
109027
+ const htmlParts = ["<table>"];
109028
+ let hasHeader = false;
109029
+ let headerProcessed = false;
109030
+ for (let i = 0; i < rows.length; i++) {
109031
+ const row = rows[i];
109032
+ if (row.type === "separator") {
109033
+ hasHeader = true;
109034
+ continue;
109035
+ }
109036
+ const content = row.content;
109037
+ const cells = content.substring(1, content.length - 1).split("|");
109038
+ if (hasHeader && !headerProcessed) {
109039
+ htmlParts.push("<thead><tr>");
109040
+ for (let j2 = 0; j2 < cells.length; j2++) {
109041
+ htmlParts.push("<th>", cells[j2].trim(), "</th>");
109042
+ }
109043
+ htmlParts.push("</tr></thead><tbody>");
109044
+ headerProcessed = true;
109045
+ } else {
109046
+ if (!headerProcessed) {
109047
+ htmlParts.push("<tbody>");
109048
+ headerProcessed = true;
109049
+ }
109050
+ htmlParts.push("<tr>");
109051
+ for (let j2 = 0; j2 < cells.length; j2++) {
109052
+ htmlParts.push("<td>", cells[j2].trim(), "</td>");
109053
+ }
109054
+ htmlParts.push("</tr>");
109055
+ }
109056
+ }
109057
+ htmlParts.push("</tbody></table>");
109058
+ return htmlParts.join("");
109059
+ }
109060
+ const PASTE_CHUNK_THRESHOLD = 200;
108514
109061
  const createEditor = ({ content = "", info = {}, limit = 50, isInline: isInline2 = false, showMenu = [], placeholder = "", blockMenuFn, editorWrapper, checkSlashTrigger } = {}) => {
108515
109062
  const editor = new Editor2({
108516
109063
  // 配置编辑器扩展功能
@@ -108526,7 +109073,13 @@ const createEditor = ({ content = "", info = {}, limit = 50, isInline: isInline2
108526
109073
  // 启用1-6级标题
108527
109074
  bulletList: false,
108528
109075
  orderedList: false,
108529
- listItem: false
109076
+ listItem: false,
109077
+ strike: false,
109078
+ // 禁用默认中划线,使用自定义版本
109079
+ bold: true,
109080
+ // 确保启用粗体
109081
+ italic: true
109082
+ // 确保启用斜体
108530
109083
  }),
108531
109084
  index_default.configure({
108532
109085
  placeholder: ({ node, editor: editor2 }) => {
@@ -108548,8 +109101,10 @@ const createEditor = ({ content = "", info = {}, limit = 50, isInline: isInline2
108548
109101
  // 文本样式扩展
108549
109102
  Color,
108550
109103
  // 颜色选择扩展
108551
- index_default$9,
108552
- // 下划线功能
109104
+ CustomUnderline,
109105
+ // 自定义下划线功能
109106
+ CustomStrike,
109107
+ // 自定义中划线功能
108553
109108
  FontSize,
108554
109109
  // 自定义字体大小
108555
109110
  // 图片功能配置
@@ -108602,10 +109157,12 @@ const createEditor = ({ content = "", info = {}, limit = 50, isInline: isInline2
108602
109157
  nested: false
108603
109158
  }),
108604
109159
  AutoOrderedOnEnter,
108605
- index_default$2.configure({
108606
- types: ["heading", "paragraph"]
109160
+ CustomTextAlign.configure({
109161
+ types: ["heading", "paragraph"],
109162
+ alignments: ["left", "center", "right", "justify"],
109163
+ defaultAlignment: "left"
108607
109164
  }),
108608
- index_default$b.configure({
109165
+ index_default$c.configure({
108609
109166
  openOnClick: false,
108610
109167
  defaultProtocol: "https"
108611
109168
  }),
@@ -108642,13 +109199,7 @@ const createEditor = ({ content = "", info = {}, limit = 50, isInline: isInline2
108642
109199
  editorProps: {
108643
109200
  // --- 修改这里 ---
108644
109201
  handlePaste: (view, event, slice2) => {
108645
- var _a3;
108646
- slice2.content.copy().content.filter((node) => {
108647
- if (node.type.name === "table" || node.type.name === "codeBlock") {
108648
- return false;
108649
- }
108650
- return true;
108651
- });
109202
+ var _a3, _b;
108652
109203
  const currentSize = getTextLength(view.state.doc);
108653
109204
  const pastedSize = slice2.content.size;
108654
109205
  if (currentSize + pastedSize > limit) {
@@ -108657,34 +109208,143 @@ const createEditor = ({ content = "", info = {}, limit = 50, isInline: isInline2
108657
109208
  }
108658
109209
  const items = Array.from(((_a3 = event.clipboardData) == null ? void 0 : _a3.items) || []);
108659
109210
  const imageItem = items.find((item) => item.type.startsWith("image/"));
108660
- if (!imageItem) {
108661
- return false;
108662
- }
108663
- event.preventDefault();
108664
- const file = imageItem.getAsFile();
108665
- if (!file) {
108666
- return false;
108667
- }
108668
- const formData = new FormData();
108669
- formData.append("file", file);
108670
- const params = {
108671
- config: {
108672
- apiHost: info.apiHost,
108673
- token: info.token,
108674
- getFileContent: info.uploadUrl
108675
- // 请确认这个 key 是否正确
109211
+ if (imageItem) {
109212
+ event.preventDefault();
109213
+ const file = imageItem.getAsFile();
109214
+ if (!file) {
109215
+ return false;
108676
109216
  }
108677
- };
108678
- uploadImageApi(params, formData).then((res) => {
108679
- if (res && res.data && res.data.show_url) {
108680
- editor.chain().focus().setImage({ src: res.data.show_url }).run();
108681
- } else {
108682
- console.error("Image upload failed or response format is incorrect.", res);
109217
+ const formData = new FormData();
109218
+ formData.append("file", file);
109219
+ const params = {
109220
+ config: {
109221
+ apiHost: info.apiHost,
109222
+ token: info.token,
109223
+ getFileContent: info.uploadUrl
109224
+ }
109225
+ };
109226
+ uploadImageApi(params, formData).then((res) => {
109227
+ if (res && res.data && res.data.show_url) {
109228
+ editor.chain().focus().setImage({ src: res.data.show_url }).run();
109229
+ } else {
109230
+ console.error("Image upload failed or response format is incorrect.", res);
109231
+ ElMessage.error("图片上传失败");
109232
+ }
109233
+ }).catch((error2) => {
109234
+ console.error("Error during image upload:", error2);
109235
+ ElMessage.error("图片上传失败");
109236
+ });
109237
+ return true;
109238
+ }
109239
+ const text2 = (_b = event.clipboardData) == null ? void 0 : _b.getData("text/plain");
109240
+ if (text2 && isMarkdown(text2)) {
109241
+ event.preventDefault();
109242
+ try {
109243
+ let textWithTables;
109244
+ try {
109245
+ textWithTables = parseMarkdownTables(text2);
109246
+ } catch (tableError) {
109247
+ console.error("[粘贴] 表格解析失败:", tableError);
109248
+ textWithTables = text2;
109249
+ }
109250
+ let html2;
109251
+ try {
109252
+ const md = new MarkdownIt({
109253
+ html: true,
109254
+ // 允许 HTML 标签
109255
+ linkify: true,
109256
+ // 自动转换 URL 为链接
109257
+ typographer: false,
109258
+ // 禁用排版,提升性能
109259
+ breaks: false
109260
+ // 不转换单个换行符为 <br>
109261
+ });
109262
+ html2 = md.render(textWithTables);
109263
+ } catch (mdError) {
109264
+ console.error("[粘贴] Markdown-it 渲染失败:", mdError);
109265
+ throw mdError;
109266
+ }
109267
+ let json2;
109268
+ try {
109269
+ json2 = generateJSON(html2, [
109270
+ index_default$8.configure({
109271
+ codeBlock: false,
109272
+ strike: false,
109273
+ bulletList: false,
109274
+ orderedList: false,
109275
+ listItem: false
109276
+ }),
109277
+ CustomUnderline,
109278
+ CustomStrike,
109279
+ TableKit,
109280
+ CustomTextAlign,
109281
+ BulletList,
109282
+ OrderedList,
109283
+ ListItem
109284
+ ]);
109285
+ } catch (jsonError) {
109286
+ console.error("[粘贴] generateJSON 失败:", jsonError);
109287
+ console.error("[粘贴] HTML 内容:", html2);
109288
+ throw jsonError;
109289
+ }
109290
+ if (json2 && json2.content) {
109291
+ const contentLength = json2.content.length;
109292
+ if (contentLength > PASTE_CHUNK_THRESHOLD) {
109293
+ ElMessage.info(`正在插入 ${contentLength} 个内容块...`);
109294
+ if (blockMenuFn) {
109295
+ blockMenuFn(true);
109296
+ }
109297
+ const originalEditable = editor.isEditable;
109298
+ editor.setEditable(false);
109299
+ loadContentInChunks({
109300
+ editor,
109301
+ content: json2.content,
109302
+ type: "json",
109303
+ extensions: [],
109304
+ // 不需要传扩展,因为内容已经是 JSON 格式
109305
+ chunkSize: 100,
109306
+ // 进一步增加到 100 个节点,大幅提升插入速度
109307
+ isPaste: true,
109308
+ // 标识为粘贴操作
109309
+ onProgress: (progress) => {
109310
+ if (progress === 1) {
109311
+ const totalTime = performance.now() - startTime;
109312
+ console.log(`[粘贴] 总耗时: ${totalTime.toFixed(2)}ms`);
109313
+ editor.setEditable(originalEditable);
109314
+ ElMessage.success("内容已插入完成");
109315
+ if (blockMenuFn) {
109316
+ blockMenuFn(false);
109317
+ }
109318
+ }
109319
+ },
109320
+ onComplete: () => {
109321
+ editor.setEditable(originalEditable);
109322
+ if (blockMenuFn) {
109323
+ blockMenuFn(false);
109324
+ }
109325
+ }
109326
+ });
109327
+ } else {
109328
+ editor.chain().focus().insertContent(json2.content).run();
109329
+ setTimeout(() => {
109330
+ editor.view.updateState(editor.state);
109331
+ const { tr: tr2 } = editor.state;
109332
+ editor.view.dispatch(tr2);
109333
+ editor.commands.focus();
109334
+ }, 0);
109335
+ }
109336
+ }
109337
+ } catch (error2) {
109338
+ try {
109339
+ editor.chain().focus().insertContent(text2).run();
109340
+ ElMessage.warning("Markdown 解析失败,已作为纯文本插入");
109341
+ } catch (insertError) {
109342
+ ElMessage.error("内容插入失败,请检查控制台");
109343
+ }
108683
109344
  }
108684
- }).catch((error2) => {
108685
- console.error("Error during image upload:", error2);
108686
- });
108687
- return true;
109345
+ return true;
109346
+ }
109347
+ return false;
108688
109348
  },
108689
109349
  handleDOMEvents: {
108690
109350
  // beforeinput: (view, event) => {
@@ -109023,24 +109683,21 @@ const textLevel = {
109023
109683
  h6: "标题6"
109024
109684
  };
109025
109685
  const _hoisted_1$3 = { class: "toolbar" };
109026
- const _hoisted_2$2 = { class: "el-dropdown-link" };
109027
- const _hoisted_3$2 = { class: "el-dropdown-link" };
109028
- const _hoisted_4$1 = {
109686
+ const _hoisted_2$2 = {
109029
109687
  key: 2,
109030
109688
  class: "flex-center"
109031
109689
  };
109032
- const _hoisted_5$1 = { class: "flex-center" };
109033
- const _hoisted_6$1 = {
109690
+ const _hoisted_3$2 = { class: "flex-center" };
109691
+ const _hoisted_4$1 = {
109034
109692
  key: 3,
109035
109693
  class: "flex-center"
109036
109694
  };
109695
+ const _hoisted_5$1 = { class: "flex-center" };
109696
+ const _hoisted_6$1 = { class: "flex-center" };
109037
109697
  const _hoisted_7$1 = { class: "flex-center" };
109038
- const _hoisted_8 = { class: "el-dropdown-link" };
109039
- const _hoisted_9 = { class: "flex-center" };
109040
- const _hoisted_10 = { class: "flex-center" };
109041
- const _hoisted_11 = { class: "flex-center" };
109042
- const _hoisted_12 = { class: "table-content" };
109043
- const _hoisted_13 = { key: 5 };
109698
+ const _hoisted_8$1 = { class: "flex-center" };
109699
+ const _hoisted_9$1 = { class: "table-content" };
109700
+ const _hoisted_10 = { key: 6 };
109044
109701
  const _sfc_main$4 = {
109045
109702
  __name: "EditorToolbar",
109046
109703
  props: {
@@ -109061,7 +109718,7 @@ const _sfc_main$4 = {
109061
109718
  default: () => []
109062
109719
  }
109063
109720
  },
109064
- emits: ["showAi", "showLink", "toggleLoading"],
109721
+ emits: ["showAi", "showLink", "toggleLoading", "showSource"],
109065
109722
  setup(__props, { emit: __emit }) {
109066
109723
  const { appContext } = getCurrentInstance();
109067
109724
  const props = __props;
@@ -109070,6 +109727,10 @@ const _sfc_main$4 = {
109070
109727
  let curFontColor = ref("#000");
109071
109728
  let curBgColor = ref("");
109072
109729
  const isActive2 = (name, params) => props.editor.isActive(name, params);
109730
+ const isInCodeBlock = computed(() => {
109731
+ if (!props.editor) return false;
109732
+ return props.editor.isActive("codeBlock") || props.editor.isActive("codeBlockCustom");
109733
+ });
109073
109734
  let curText = ref("正文");
109074
109735
  const setHeading = (level) => {
109075
109736
  if (level === "paragraph") {
@@ -109132,6 +109793,9 @@ const _sfc_main$4 = {
109132
109793
  props.editor.setEditable(false);
109133
109794
  }
109134
109795
  };
109796
+ const viewSource = () => {
109797
+ emit("showSource");
109798
+ };
109135
109799
  const commonExpressionVisible = ref(false);
109136
109800
  const showExpression = () => {
109137
109801
  commonExpressionVisible.value = true;
@@ -109292,7 +109956,8 @@ const _sfc_main$4 = {
109292
109956
  createVNode(unref(ElDropdown), {
109293
109957
  onCommand: setHeading,
109294
109958
  trigger: "click",
109295
- "popper-class": "tiptap-drop-down"
109959
+ "popper-class": "tiptap-drop-down",
109960
+ disabled: isInCodeBlock.value
109296
109961
  }, {
109297
109962
  dropdown: withCtx(() => [
109298
109963
  createVNode(unref(ElDropdownMenu), null, {
@@ -109356,16 +110021,18 @@ const _sfc_main$4 = {
109356
110021
  })
109357
110022
  ]),
109358
110023
  default: withCtx(() => [
109359
- createElementVNode("div", _hoisted_2$2, [
110024
+ createElementVNode("div", {
110025
+ class: normalizeClass(["el-dropdown-link", { "disabled": isInCodeBlock.value }])
110026
+ }, [
109360
110027
  createElementVNode("p", null, toDisplayString(unref(curText)), 1),
109361
110028
  createVNode(unref(Icon), {
109362
110029
  icon: "ic:baseline-expand-more",
109363
110030
  width: "16"
109364
110031
  })
109365
- ])
110032
+ ], 2)
109366
110033
  ]),
109367
110034
  _: 1
109368
- })
110035
+ }, 8, ["disabled"])
109369
110036
  ]),
109370
110037
  _: 1
109371
110038
  })) : createCommentVNode("", true),
@@ -109379,7 +110046,8 @@ const _sfc_main$4 = {
109379
110046
  createVNode(unref(ElDropdown), {
109380
110047
  onCommand: setFontSize,
109381
110048
  trigger: "click",
109382
- "popper-class": "tiptap-drop-down"
110049
+ "popper-class": "tiptap-drop-down",
110050
+ disabled: isInCodeBlock.value
109383
110051
  }, {
109384
110052
  dropdown: withCtx(() => [
109385
110053
  createVNode(unref(ElDropdownMenu), null, {
@@ -109402,20 +110070,22 @@ const _sfc_main$4 = {
109402
110070
  })
109403
110071
  ]),
109404
110072
  default: withCtx(() => [
109405
- createElementVNode("div", _hoisted_3$2, [
110073
+ createElementVNode("div", {
110074
+ class: normalizeClass(["el-dropdown-link", { "disabled": isInCodeBlock.value }])
110075
+ }, [
109406
110076
  createElementVNode("p", null, toDisplayString(unref(curFontSize)), 1),
109407
110077
  createVNode(unref(Icon), {
109408
110078
  icon: "ic:baseline-expand-more",
109409
110079
  width: "16"
109410
110080
  })
109411
- ])
110081
+ ], 2)
109412
110082
  ]),
109413
110083
  _: 1
109414
- })
110084
+ }, 8, ["disabled"])
109415
110085
  ]),
109416
110086
  _: 1
109417
110087
  }),
109418
- unref(isShowMenu)("color", __props.showMenu) ? (openBlock(), createElementBlock("div", _hoisted_4$1, [
110088
+ unref(isShowMenu)("color", __props.showMenu) ? (openBlock(), createElementBlock("div", _hoisted_2$2, [
109419
110089
  createVNode(unref(ElTooltip), {
109420
110090
  class: "box-item",
109421
110091
  effect: "dark",
@@ -109423,20 +110093,21 @@ const _sfc_main$4 = {
109423
110093
  placement: "bottom"
109424
110094
  }, {
109425
110095
  default: withCtx(() => [
109426
- createElementVNode("div", _hoisted_5$1, [
110096
+ createElementVNode("div", _hoisted_3$2, [
109427
110097
  createVNode(unref(ElColorPicker), {
109428
110098
  modelValue: unref(curFontColor),
109429
110099
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(curFontColor) ? curFontColor.value = $event : curFontColor = $event),
109430
110100
  onChange: setFontColor,
109431
110101
  size: "small",
109432
- "show-alpha": ""
109433
- }, null, 8, ["modelValue"])
110102
+ "show-alpha": "",
110103
+ disabled: isInCodeBlock.value
110104
+ }, null, 8, ["modelValue", "disabled"])
109434
110105
  ])
109435
110106
  ]),
109436
110107
  _: 1
109437
110108
  })
109438
110109
  ])) : createCommentVNode("", true),
109439
- unref(isShowMenu)("bgColor", __props.showMenu) ? (openBlock(), createElementBlock("div", _hoisted_6$1, [
110110
+ unref(isShowMenu)("bgColor", __props.showMenu) ? (openBlock(), createElementBlock("div", _hoisted_4$1, [
109440
110111
  createVNode(unref(ElTooltip), {
109441
110112
  class: "box-item",
109442
110113
  effect: "dark",
@@ -109444,14 +110115,15 @@ const _sfc_main$4 = {
109444
110115
  placement: "bottom"
109445
110116
  }, {
109446
110117
  default: withCtx(() => [
109447
- createElementVNode("div", _hoisted_7$1, [
110118
+ createElementVNode("div", _hoisted_5$1, [
109448
110119
  createVNode(unref(ElColorPicker), {
109449
110120
  modelValue: unref(curBgColor),
109450
110121
  "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => isRef(curBgColor) ? curBgColor.value = $event : curBgColor = $event),
109451
110122
  onChange: setBgColor,
109452
110123
  size: "small",
109453
- "show-alpha": ""
109454
- }, null, 8, ["modelValue"])
110124
+ "show-alpha": "",
110125
+ disabled: isInCodeBlock.value
110126
+ }, null, 8, ["modelValue", "disabled"])
109455
110127
  ])
109456
110128
  ]),
109457
110129
  _: 1
@@ -109471,16 +110143,18 @@ const _sfc_main$4 = {
109471
110143
  size: "small",
109472
110144
  type: isActive2("bold") ? "primary" : "",
109473
110145
  onClick: _cache[2] || (_cache[2] = ($event) => __props.editor.chain().focus().toggleBold().run()),
109474
- link: ""
110146
+ link: "",
110147
+ disabled: isInCodeBlock.value
109475
110148
  }, {
109476
110149
  default: withCtx(() => [
109477
110150
  createVNode(unref(Icon), {
109478
110151
  icon: "mdi:format-bold",
109479
- width: "20"
109480
- })
110152
+ width: "20",
110153
+ class: normalizeClass({ "icon-gray": isInCodeBlock.value })
110154
+ }, null, 8, ["class"])
109481
110155
  ]),
109482
110156
  _: 1
109483
- }, 8, ["type"])
110157
+ }, 8, ["type", "disabled"])
109484
110158
  ]),
109485
110159
  _: 1
109486
110160
  })) : createCommentVNode("", true),
@@ -109496,16 +110170,18 @@ const _sfc_main$4 = {
109496
110170
  size: "small",
109497
110171
  type: isActive2("italic") ? "primary" : "",
109498
110172
  onClick: _cache[3] || (_cache[3] = ($event) => __props.editor.chain().focus().toggleItalic().run()),
109499
- link: ""
110173
+ link: "",
110174
+ disabled: isInCodeBlock.value
109500
110175
  }, {
109501
110176
  default: withCtx(() => [
109502
110177
  createVNode(unref(Icon), {
109503
110178
  icon: "mdi:format-italic",
109504
- width: "20"
109505
- })
110179
+ width: "20",
110180
+ class: normalizeClass({ "icon-gray": isInCodeBlock.value })
110181
+ }, null, 8, ["class"])
109506
110182
  ]),
109507
110183
  _: 1
109508
- }, 8, ["type"])
110184
+ }, 8, ["type", "disabled"])
109509
110185
  ]),
109510
110186
  _: 1
109511
110187
  })) : createCommentVNode("", true),
@@ -109521,16 +110197,18 @@ const _sfc_main$4 = {
109521
110197
  size: "small",
109522
110198
  type: isActive2("underline") ? "primary" : "",
109523
110199
  onClick: _cache[4] || (_cache[4] = ($event) => __props.editor.chain().focus().toggleUnderline().run()),
109524
- link: ""
110200
+ link: "",
110201
+ disabled: isInCodeBlock.value
109525
110202
  }, {
109526
110203
  default: withCtx(() => [
109527
110204
  createVNode(unref(Icon), {
109528
110205
  icon: "mdi:format-underline",
109529
- width: "20"
109530
- })
110206
+ width: "20",
110207
+ class: normalizeClass({ "icon-gray": isInCodeBlock.value })
110208
+ }, null, 8, ["class"])
109531
110209
  ]),
109532
110210
  _: 1
109533
- }, 8, ["type"])
110211
+ }, 8, ["type", "disabled"])
109534
110212
  ]),
109535
110213
  _: 1
109536
110214
  })) : createCommentVNode("", true),
@@ -109546,16 +110224,18 @@ const _sfc_main$4 = {
109546
110224
  size: "small",
109547
110225
  type: isActive2("strike") ? "primary" : "",
109548
110226
  onClick: _cache[5] || (_cache[5] = ($event) => __props.editor.chain().focus().toggleStrike().run()),
109549
- link: ""
110227
+ link: "",
110228
+ disabled: isInCodeBlock.value
109550
110229
  }, {
109551
110230
  default: withCtx(() => [
109552
110231
  createVNode(unref(Icon), {
109553
110232
  icon: "mdi:format-strikethrough",
109554
- width: "20"
109555
- })
110233
+ width: "20",
110234
+ class: normalizeClass({ "icon-gray": isInCodeBlock.value })
110235
+ }, null, 8, ["class"])
109556
110236
  ]),
109557
110237
  _: 1
109558
- }, 8, ["type"])
110238
+ }, 8, ["type", "disabled"])
109559
110239
  ]),
109560
110240
  _: 1
109561
110241
  })) : createCommentVNode("", true),
@@ -109642,16 +110322,18 @@ const _sfc_main$4 = {
109642
110322
  createVNode(unref(ElButton), {
109643
110323
  onClick: setLink,
109644
110324
  type: isActive2("link") ? "primary" : "",
109645
- link: ""
110325
+ link: "",
110326
+ disabled: isInCodeBlock.value
109646
110327
  }, {
109647
110328
  default: withCtx(() => [
109648
110329
  createVNode(unref(Icon), {
109649
110330
  icon: "mdi:link-variant",
109650
- width: "20"
109651
- })
110331
+ width: "20",
110332
+ class: normalizeClass({ "icon-gray": isInCodeBlock.value })
110333
+ }, null, 8, ["class"])
109652
110334
  ]),
109653
110335
  _: 1
109654
- }, 8, ["type"])
110336
+ }, 8, ["type", "disabled"])
109655
110337
  ]),
109656
110338
  _: 1
109657
110339
  })) : createCommentVNode("", true)
@@ -109668,7 +110350,8 @@ const _sfc_main$4 = {
109668
110350
  createVNode(unref(ElDropdown), {
109669
110351
  onCommand: setAlign,
109670
110352
  trigger: "click",
109671
- teleported: false
110353
+ teleported: false,
110354
+ disabled: isInCodeBlock.value
109672
110355
  }, {
109673
110356
  dropdown: withCtx(() => [
109674
110357
  createVNode(unref(ElDropdownMenu), null, {
@@ -109769,23 +110452,27 @@ const _sfc_main$4 = {
109769
110452
  })
109770
110453
  ]),
109771
110454
  default: withCtx(() => [
109772
- createElementVNode("div", _hoisted_8, [
110455
+ createElementVNode("div", {
110456
+ class: normalizeClass(["el-dropdown-link", { "disabled": isInCodeBlock.value }])
110457
+ }, [
109773
110458
  createVNode(unref(Icon), {
109774
110459
  icon: `mdi:format-align-${unref(alignType)}`,
109775
- width: "20"
109776
- }, null, 8, ["icon"]),
110460
+ width: "20",
110461
+ class: normalizeClass({ "icon-gray": isInCodeBlock.value })
110462
+ }, null, 8, ["icon", "class"]),
109777
110463
  createVNode(unref(Icon), {
109778
110464
  icon: "ic:baseline-expand-more",
109779
- width: "16"
109780
- })
109781
- ])
110465
+ width: "16",
110466
+ class: normalizeClass({ "icon-gray": isInCodeBlock.value })
110467
+ }, null, 8, ["class"])
110468
+ ], 2)
109782
110469
  ]),
109783
110470
  _: 1
109784
- })
110471
+ }, 8, ["disabled"])
109785
110472
  ]),
109786
110473
  _: 1
109787
110474
  }),
109788
- createElementVNode("div", _hoisted_9, [
110475
+ createElementVNode("div", _hoisted_6$1, [
109789
110476
  !__props.isBubble && unref(isShowMenu)("image", __props.showMenu) ? (openBlock(), createBlock(unref(ElTooltip), {
109790
110477
  key: 0,
109791
110478
  class: "box-item",
@@ -109804,6 +110491,7 @@ const _sfc_main$4 = {
109804
110491
  headers: {
109805
110492
  "access-token": __props.info.token
109806
110493
  },
110494
+ accept: ".jpg,.png,.jpeg,.gif",
109807
110495
  "before-upload": handleImageUpload,
109808
110496
  "on-success": uploadFileSuccess
109809
110497
  }, {
@@ -109819,7 +110507,7 @@ const _sfc_main$4 = {
109819
110507
  _: 1
109820
110508
  })) : createCommentVNode("", true)
109821
110509
  ]),
109822
- createElementVNode("div", _hoisted_10, [
110510
+ createElementVNode("div", _hoisted_7$1, [
109823
110511
  !__props.isBubble && unref(isShowMenu)("doc", __props.showMenu) ? (openBlock(), createBlock(unref(ElTooltip), {
109824
110512
  key: 0,
109825
110513
  class: "box-item",
@@ -109846,8 +110534,9 @@ const _sfc_main$4 = {
109846
110534
  default: withCtx(() => [
109847
110535
  createVNode(unref(Icon), {
109848
110536
  icon: "mdi:file-word",
109849
- width: "20"
109850
- })
110537
+ width: "20",
110538
+ class: normalizeClass(isActive2("codeBlock") || isActive2("table") || isActive2("bulletList") || isActive2("orderedList") || isActive2("taskList") ? "icon-gray" : "")
110539
+ }, null, 8, ["class"])
109851
110540
  ]),
109852
110541
  _: 1
109853
110542
  }, 8, ["action", "headers", "disabled"])
@@ -109855,7 +110544,7 @@ const _sfc_main$4 = {
109855
110544
  _: 1
109856
110545
  })) : createCommentVNode("", true)
109857
110546
  ]),
109858
- createElementVNode("div", _hoisted_11, [
110547
+ createElementVNode("div", _hoisted_8$1, [
109859
110548
  !__props.isBubble && unref(isShowMenu)("jupyter", __props.showMenu) ? (openBlock(), createBlock(unref(ElTooltip), {
109860
110549
  key: 0,
109861
110550
  class: "box-item",
@@ -109880,7 +110569,10 @@ const _sfc_main$4 = {
109880
110569
  disabled: isActive2("codeBlock") || isActive2("table") || isActive2("bulletList") || isActive2("orderedList") || isActive2("taskList")
109881
110570
  }, {
109882
110571
  default: withCtx(() => [
109883
- createVNode(unref(Icon), { icon: "logos:jupyter" })
110572
+ createVNode(unref(Icon), {
110573
+ icon: "logos:jupyter",
110574
+ class: normalizeClass(isActive2("codeBlock") || isActive2("table") || isActive2("bulletList") || isActive2("orderedList") || isActive2("taskList") ? "icon-gray" : "")
110575
+ }, null, 8, ["class"])
109884
110576
  ]),
109885
110577
  _: 1
109886
110578
  }, 8, ["action", "headers", "disabled"])
@@ -109923,7 +110615,7 @@ const _sfc_main$4 = {
109923
110615
  placement: "bottom"
109924
110616
  }, {
109925
110617
  default: withCtx(() => [
109926
- createElementVNode("div", _hoisted_12, [
110618
+ createElementVNode("div", _hoisted_9$1, [
109927
110619
  createVNode(unref(ElPopover), {
109928
110620
  placement: "bottom",
109929
110621
  title: "",
@@ -110007,7 +110699,31 @@ const _sfc_main$4 = {
110007
110699
  ]),
110008
110700
  _: 1
110009
110701
  }),
110010
- !__props.isBubble && unref(isShowMenu)("expression", __props.showMenu) ? (openBlock(), createElementBlock("div", _hoisted_13, [
110702
+ !__props.isBubble && unref(isShowMenu)("viewSource", __props.showMenu) ? (openBlock(), createBlock(unref(ElTooltip), {
110703
+ key: 5,
110704
+ class: "box-item",
110705
+ effect: "dark",
110706
+ content: "查看源代码",
110707
+ placement: "bottom"
110708
+ }, {
110709
+ default: withCtx(() => [
110710
+ createVNode(unref(ElButton), {
110711
+ size: "small",
110712
+ onClick: viewSource,
110713
+ link: ""
110714
+ }, {
110715
+ default: withCtx(() => [
110716
+ createVNode(unref(Icon), {
110717
+ icon: "mdi:code-tags",
110718
+ width: "20"
110719
+ })
110720
+ ]),
110721
+ _: 1
110722
+ })
110723
+ ]),
110724
+ _: 1
110725
+ })) : createCommentVNode("", true),
110726
+ !__props.isBubble && unref(isShowMenu)("expression", __props.showMenu) ? (openBlock(), createElementBlock("div", _hoisted_10, [
110011
110727
  createVNode(unref(ElButton), {
110012
110728
  link: "",
110013
110729
  onClick: showExpression
@@ -110030,7 +110746,7 @@ const _sfc_main$4 = {
110030
110746
  };
110031
110747
  }
110032
110748
  };
110033
- const EditorToolbar = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-ad34f900"]]);
110749
+ const EditorToolbar = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-8982114a"]]);
110034
110750
  const _hoisted_1$2 = { class: "bubble-menu" };
110035
110751
  const _sfc_main$3 = {
110036
110752
  __name: "BubbleMenu",
@@ -111515,11 +112231,13 @@ const _hoisted_2 = { key: 1 };
111515
112231
  const _hoisted_3 = { class: "editor-content-container" };
111516
112232
  const _hoisted_4 = { ref: "blockMenuRef" };
111517
112233
  const _hoisted_5 = ["src"];
111518
- const _hoisted_6 = {
112234
+ const _hoisted_6 = { class: "source-dialog-content" };
112235
+ const _hoisted_7 = { class: "dialog-footer" };
112236
+ const _hoisted_8 = {
111519
112237
  key: 2,
111520
112238
  class: "editor-bottom"
111521
112239
  };
111522
- const _hoisted_7 = { class: "editor-bottom-r" };
112240
+ const _hoisted_9 = { class: "editor-bottom-r" };
111523
112241
  const _sfc_main = {
111524
112242
  __name: "index",
111525
112243
  props: {
@@ -111630,8 +112348,11 @@ const _sfc_main = {
111630
112348
  editor.chain().focus().insertContent({
111631
112349
  type: "codeBlock",
111632
112350
  attrs: { language: "javascript" }
111633
- // content: [{ type: "text", text: "// 在这里写代码…" }],
111634
112351
  }).run();
112352
+ } else if (typeof type === "function") {
112353
+ nextTick(() => {
112354
+ type();
112355
+ });
111635
112356
  } else if (type && type != "undele") {
111636
112357
  type();
111637
112358
  }
@@ -111717,6 +112438,35 @@ const _sfc_main = {
111717
112438
  imageSrc.value = e.detail;
111718
112439
  imageDialogVisible.value = true;
111719
112440
  }
112441
+ const sourceDialogVisible = ref(false);
112442
+ const sourceCode = ref("");
112443
+ function openSourceDialog() {
112444
+ sourceCode.value = editor.getHTML();
112445
+ sourceDialogVisible.value = true;
112446
+ }
112447
+ function applySourceCode() {
112448
+ try {
112449
+ isLoading.value = true;
112450
+ editor.commands.clearContent();
112451
+ loadContentInChunks({
112452
+ editor,
112453
+ content: sourceCode.value,
112454
+ type: "html",
112455
+ extensions: commonExtensions(),
112456
+ chunkSize: 5,
112457
+ onProgress: (p) => {
112458
+ if (p > 0) {
112459
+ isLoading.value = false;
112460
+ }
112461
+ }
112462
+ });
112463
+ sourceDialogVisible.value = false;
112464
+ ElMessage.success("源代码已应用");
112465
+ } catch (error2) {
112466
+ console.error("应用源代码失败:", error2);
112467
+ ElMessage.error("应用源代码失败,请检查代码格式");
112468
+ }
112469
+ }
111720
112470
  const toggleLoading = (data) => {
111721
112471
  isLoading.value = data;
111722
112472
  };
@@ -111745,7 +112495,8 @@ const _sfc_main = {
111745
112495
  showMenu: __props.showMenu,
111746
112496
  onShowLink: _cache[0] || (_cache[0] = ($event) => showLink("top")),
111747
112497
  onToggleLoading: toggleLoading,
111748
- onShowAi: showAi
112498
+ onShowAi: showAi,
112499
+ onShowSource: openSourceDialog
111749
112500
  }, null, 8, ["editor", "info", "limitLength", "showMenu"])
111750
112501
  ])) : createCommentVNode("", true),
111751
112502
  !__props.isInline && !unref(floatAiStatus) ? (openBlock(), createElementBlock("div", _hoisted_2, [
@@ -111819,23 +112570,64 @@ const _sfc_main = {
111819
112570
  }, null, 8, _hoisted_5)
111820
112571
  ]),
111821
112572
  _: 1
112573
+ }, 8, ["modelValue"]),
112574
+ createVNode(unref(ElDialog), {
112575
+ modelValue: sourceDialogVisible.value,
112576
+ "onUpdate:modelValue": _cache[8] || (_cache[8] = ($event) => sourceDialogVisible.value = $event),
112577
+ title: "查看源代码",
112578
+ width: "70%",
112579
+ "close-on-click-modal": false
112580
+ }, {
112581
+ footer: withCtx(() => [
112582
+ createElementVNode("span", _hoisted_7, [
112583
+ createVNode(unref(ElButton), {
112584
+ onClick: _cache[7] || (_cache[7] = ($event) => sourceDialogVisible.value = false)
112585
+ }, {
112586
+ default: withCtx(() => [..._cache[9] || (_cache[9] = [
112587
+ createTextVNode("取消", -1)
112588
+ ])]),
112589
+ _: 1
112590
+ }),
112591
+ createVNode(unref(ElButton), {
112592
+ type: "primary",
112593
+ onClick: applySourceCode
112594
+ }, {
112595
+ default: withCtx(() => [..._cache[10] || (_cache[10] = [
112596
+ createTextVNode("确认", -1)
112597
+ ])]),
112598
+ _: 1
112599
+ })
112600
+ ])
112601
+ ]),
112602
+ default: withCtx(() => [
112603
+ createElementVNode("div", _hoisted_6, [
112604
+ createVNode(unref(ElInput), {
112605
+ modelValue: sourceCode.value,
112606
+ "onUpdate:modelValue": _cache[6] || (_cache[6] = ($event) => sourceCode.value = $event),
112607
+ type: "textarea",
112608
+ rows: 20,
112609
+ placeholder: "HTML源代码"
112610
+ }, null, 8, ["modelValue"])
112611
+ ])
112612
+ ]),
112613
+ _: 1
111822
112614
  }, 8, ["modelValue"])
111823
112615
  ], 2)
111824
112616
  ])), [
111825
112617
  [_directive_loading, unref(isLoading)]
111826
112618
  ]),
111827
- __props.limitLength != Infinity ? (openBlock(), createElementBlock("div", _hoisted_6, [
112619
+ __props.limitLength != Infinity ? (openBlock(), createElementBlock("div", _hoisted_8, [
111828
112620
  createElementVNode("div", null, [
111829
112621
  renderSlot(_ctx.$slots, "default", {}, void 0, true)
111830
112622
  ]),
111831
- createElementVNode("div", _hoisted_7, toDisplayString(unref(getTextLength)(unref(editor).state.doc)) + "/" + toDisplayString(__props.limitLength), 1)
112623
+ createElementVNode("div", _hoisted_9, toDisplayString(unref(getTextLength)(unref(editor).state.doc)) + "/" + toDisplayString(__props.limitLength), 1)
111832
112624
  ])) : createCommentVNode("", true)
111833
112625
  ], 4)
111834
112626
  ], 4);
111835
112627
  };
111836
112628
  }
111837
112629
  };
111838
- const TiptapVue = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-3d89208a"]]);
112630
+ const TiptapVue = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-4855cd8e"]]);
111839
112631
  const components = [
111840
112632
  {
111841
112633
  name: "TiptapVue",