@tmagic/editor 1.2.0-beta.1 → 1.2.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/tmagic-editor.mjs +769 -768
  2. package/dist/tmagic-editor.mjs.map +1 -1
  3. package/dist/tmagic-editor.umd.js +773 -771
  4. package/dist/tmagic-editor.umd.js.map +1 -1
  5. package/package.json +9 -9
  6. package/src/Editor.vue +2 -2
  7. package/src/components/ContentMenu.vue +2 -2
  8. package/src/components/Icon.vue +6 -4
  9. package/src/components/ToolButton.vue +29 -14
  10. package/src/fields/Code.vue +4 -1
  11. package/src/fields/CodeLink.vue +19 -11
  12. package/src/fields/CodeSelect.vue +6 -6
  13. package/src/fields/UISelect.vue +8 -7
  14. package/src/index.ts +2 -1
  15. package/src/layouts/AddPageBox.vue +13 -20
  16. package/src/layouts/CodeEditor.vue +106 -120
  17. package/src/layouts/Framework.vue +3 -2
  18. package/src/layouts/PropsPanel.vue +3 -8
  19. package/src/layouts/sidebar/ComponentListPanel.vue +13 -11
  20. package/src/layouts/sidebar/LayerMenu.vue +86 -91
  21. package/src/layouts/sidebar/LayerPanel.vue +252 -162
  22. package/src/layouts/sidebar/Sidebar.vue +24 -28
  23. package/src/layouts/sidebar/TabPane.vue +43 -51
  24. package/src/layouts/sidebar/code-block/CodeBlockEditor.vue +22 -18
  25. package/src/layouts/sidebar/code-block/CodeBlockList.vue +21 -21
  26. package/src/layouts/workspace/PageBar.vue +11 -10
  27. package/src/services/codeBlock.ts +16 -10
  28. package/src/services/editor.ts +4 -4
  29. package/src/theme/index.scss +1 -15
  30. package/src/theme/theme.scss +15 -0
  31. package/src/type.ts +1 -1
  32. package/types/Editor.vue.d.ts +2 -2
  33. package/types/fields/Code.vue.d.ts +8 -0
  34. package/types/fields/CodeLink.vue.d.ts +4 -0
  35. package/types/index.d.ts +1 -0
  36. package/types/layouts/AddPageBox.vue.d.ts +45 -3
  37. package/types/layouts/CodeEditor.vue.d.ts +160 -45
  38. package/types/layouts/sidebar/LayerMenu.vue.d.ts +16 -64
  39. package/types/layouts/sidebar/LayerPanel.vue.d.ts +16 -1071
  40. package/types/layouts/sidebar/Sidebar.vue.d.ts +114 -17
  41. package/types/layouts/sidebar/TabPane.vue.d.ts +80 -12
  42. package/types/layouts/sidebar/code-block/CodeBlockList.vue.d.ts +1 -0
  43. package/types/services/codeBlock.d.ts +1 -1
  44. package/types/services/editor.d.ts +2 -2
  45. package/types/type.d.ts +1 -1
@@ -1,8 +1,8 @@
1
- import { defineComponent, computed, resolveComponent, openBlock, createBlock, normalizeStyle, unref, reactive, watch, inject, ref, watchEffect, createElementBlock, createVNode, withCtx, createElementVNode, withModifiers, createCommentVNode, createTextVNode, toDisplayString, onMounted, onUnmounted, toRaw, renderSlot, Fragment, normalizeClass, createSlots, resolveDynamicComponent, renderList, normalizeProps, mergeProps, markRaw, getCurrentInstance, isRef, Teleport, nextTick, toHandlers, provide } from 'vue';
1
+ import { defineComponent, computed, resolveComponent, openBlock, createBlock, normalizeStyle, unref, reactive, watch, inject, ref, watchEffect, createElementBlock, createVNode, withCtx, createElementVNode, withModifiers, createCommentVNode, createTextVNode, toDisplayString, onMounted, onUnmounted, normalizeClass, resolveDynamicComponent, toRaw, renderSlot, Fragment, createSlots, renderList, normalizeProps, mergeProps, markRaw, getCurrentInstance, isRef, Teleport, nextTick, toHandlers, provide } from 'vue';
2
2
  import serialize from 'serialize-javascript';
3
- import { ElMessage } from 'element-plus';
4
3
  import { cloneDeep, map, xor, throttle, pick, isEmpty, forIn, omit, keys, mergeWith, uniq } from 'lodash-es';
5
- import { Delete, Close, Plus, Edit, ArrowDown, Grid, Memo, FullScreen, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, View, Link, Files, DocumentCopy, EditPen, Coin, ArrowLeftBold, ArrowRightBold, CaretBottom, Top, Bottom } from '@element-plus/icons-vue';
4
+ import { TMagicCard, TMagicTooltip, tMagicMessage, TMagicButton, TMagicIcon, TMagicScrollbar, TMagicDivider, TMagicDropdown, TMagicDropdownMenu, TMagicDropdownItem, TMagicDialog, TMagicInput, TMagicTree, TMagicCollapse, TMagicCollapseItem, TMagicTabPane, TMagicTabs, TMagicPopover } from '@tmagic/design';
5
+ import { Delete, Close, Edit, Plus, ArrowDown, Grid, Memo, FullScreen, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, View, Link, Files, DocumentCopy, EditPen, Coin, ArrowLeftBold, ArrowRightBold, CaretBottom, Top, Bottom } from '@element-plus/icons-vue';
6
6
  import * as monaco from 'monaco-editor';
7
7
  import StageCore, { GuidesType, getOffset, calcValueByFontsize, CONTAINER_HIGHLIGHT_CLASS, ContainerHighlightType } from '@tmagic/stage';
8
8
  import { NodeType } from '@tmagic/schema';
@@ -24,7 +24,7 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
24
24
  setup(__props, { emit }) {
25
25
  const props = __props;
26
26
  const language = computed(() => props.config.language || "javascript");
27
- const height = computed(() => `${document.body.clientHeight - 168}px`);
27
+ const height = computed(() => props.config.height || `${document.body.clientHeight - 168}px`);
28
28
  const save = (v) => {
29
29
  props.model[props.name] = v;
30
30
  emit("change", v);
@@ -35,8 +35,9 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
35
35
  style: normalizeStyle(`height: ${unref(height)}`),
36
36
  "init-values": __props.model[__props.name],
37
37
  language: unref(language),
38
+ options: __props.config.options,
38
39
  onSave: save
39
- }, null, 8, ["style", "init-values", "language"]);
40
+ }, null, 8, ["style", "init-values", "language", "options"]);
40
41
  };
41
42
  }
42
43
  });
@@ -52,17 +53,24 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
52
53
  emits: ["change"],
53
54
  setup(__props, { emit }) {
54
55
  const props = __props;
55
- const formConfig = computed(() => ({
56
- ...props.config,
57
- text: "",
58
- type: "link",
59
- form: [
60
- {
61
- name: props.name,
62
- type: "vs-code"
63
- }
64
- ]
65
- }));
56
+ const formConfig = computed(() => {
57
+ const { codeOptions, ...config } = props.config;
58
+ return {
59
+ ...config,
60
+ text: "",
61
+ type: "link",
62
+ form: [
63
+ {
64
+ name: props.name,
65
+ type: "vs-code",
66
+ options: {
67
+ tabSize: 2,
68
+ ...codeOptions || {}
69
+ }
70
+ }
71
+ ]
72
+ };
73
+ });
66
74
  const modelValue = reactive({
67
75
  form: {
68
76
  [props.name]: ""
@@ -145,13 +153,13 @@ var CodeSelectOp = /* @__PURE__ */ ((CodeSelectOp2) => {
145
153
  return CodeSelectOp2;
146
154
  })(CodeSelectOp || {});
147
155
 
148
- const _hoisted_1$e = { class: "tool-bar" };
149
- const _hoisted_2$6 = /* @__PURE__ */ createElementVNode("path", {
156
+ const _hoisted_1$d = { class: "tool-bar" };
157
+ const _hoisted_2$5 = /* @__PURE__ */ createElementVNode("path", {
150
158
  fill: "currentColor",
151
159
  d: "m23 12l-7.071 7.071l-1.414-1.414L20.172 12l-5.657-5.657l1.414-1.414L23 12zM3.828 12l5.657 5.657l-1.414 1.414L1 12l7.071-7.071l1.414 1.414L3.828 12z"
152
160
  }, null, -1);
153
161
  const _hoisted_3$3 = [
154
- _hoisted_2$6
162
+ _hoisted_2$5
155
163
  ];
156
164
  const _sfc_main$q = /* @__PURE__ */ defineComponent({
157
165
  __name: "CodeSelect",
@@ -227,7 +235,7 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
227
235
  };
228
236
  const viewHandler = async () => {
229
237
  if (props.model[props.name].length === 0) {
230
- ElMessage.error("\u8BF7\u5148\u7ED1\u5B9A\u4EE3\u7801\u5757");
238
+ tMagicMessage.error("\u8BF7\u5148\u7ED1\u5B9A\u4EE3\u7801\u5757");
231
239
  return;
232
240
  }
233
241
  await setCombineIds(props.model[props.name]);
@@ -236,13 +244,11 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
236
244
  };
237
245
  return (_ctx, _cache) => {
238
246
  const _component_m_fields_select = resolveComponent("m-fields-select");
239
- const _component_el_tooltip = resolveComponent("el-tooltip");
240
- const _component_el_card = resolveComponent("el-card");
241
247
  return openBlock(), createElementBlock("div", {
242
248
  class: "m-fields-code-select",
243
249
  key: fieldKey.value
244
250
  }, [
245
- createVNode(_component_el_card, { shadow: "never" }, {
251
+ createVNode(unref(TMagicCard), { shadow: "never" }, {
246
252
  header: withCtx(() => [
247
253
  createVNode(_component_m_fields_select, {
248
254
  config: unref(selectConfig),
@@ -254,8 +260,8 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
254
260
  }, null, 8, ["config", "model", "prop", "name", "size"])
255
261
  ]),
256
262
  default: withCtx(() => [
257
- createElementVNode("div", _hoisted_1$e, [
258
- createVNode(_component_el_tooltip, {
263
+ createElementVNode("div", _hoisted_1$d, [
264
+ createVNode(unref(TMagicTooltip), {
259
265
  class: "tool-item",
260
266
  effect: "dark",
261
267
  content: "\u67E5\u770B\u4EE3\u7801\u5757",
@@ -282,7 +288,7 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
282
288
  }
283
289
  });
284
290
 
285
- const _hoisted_1$d = /* @__PURE__ */ createTextVNode("\u53D6\u6D88");
291
+ const _hoisted_1$c = /* @__PURE__ */ createTextVNode("\u53D6\u6D88");
286
292
  const _sfc_main$p = /* @__PURE__ */ defineComponent({
287
293
  __name: "UISelect",
288
294
  props: {
@@ -334,21 +340,19 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
334
340
  }
335
341
  };
336
342
  return (_ctx, _cache) => {
337
- const _component_el_button = resolveComponent("el-button");
338
- const _component_el_tooltip = resolveComponent("el-tooltip");
339
343
  return uiSelectMode.value ? (openBlock(), createElementBlock("div", {
340
344
  key: 0,
341
345
  class: "m-fields-ui-select",
342
346
  onClick: cancelHandler
343
347
  }, [
344
- createVNode(_component_el_button, {
348
+ createVNode(unref(TMagicButton), {
345
349
  type: "danger",
346
350
  icon: unref(Delete),
347
351
  text: "",
348
352
  style: { "padding": "0" }
349
353
  }, {
350
354
  default: withCtx(() => [
351
- _hoisted_1$d
355
+ _hoisted_1$c
352
356
  ]),
353
357
  _: 1
354
358
  }, 8, ["icon"])
@@ -358,12 +362,12 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
358
362
  onClick: startSelect,
359
363
  style: { "display": "flex" }
360
364
  }, [
361
- unref(val) ? (openBlock(), createBlock(_component_el_tooltip, {
365
+ unref(val) ? (openBlock(), createBlock(unref(TMagicTooltip), {
362
366
  key: 0,
363
367
  content: "\u6E05\u9664"
364
368
  }, {
365
369
  default: withCtx(() => [
366
- createVNode(_component_el_button, {
370
+ createVNode(unref(TMagicButton), {
367
371
  style: { "padding": "0" },
368
372
  type: "danger",
369
373
  icon: unref(Close),
@@ -373,11 +377,11 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
373
377
  ]),
374
378
  _: 1
375
379
  })) : createCommentVNode("", true),
376
- createVNode(_component_el_tooltip, {
380
+ createVNode(unref(TMagicTooltip), {
377
381
  content: unref(val) ? unref(toName) + "_" + unref(val) : "\u70B9\u51FB\u6B64\u5904\u9009\u62E9"
378
382
  }, {
379
383
  default: withCtx(() => [
380
- createVNode(_component_el_button, {
384
+ createVNode(unref(TMagicButton), {
381
385
  text: "",
382
386
  style: { "padding": "0", "margin": "0" }
383
387
  }, {
@@ -396,45 +400,36 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
396
400
 
397
401
  const UISelect_vue_vue_type_style_index_0_lang = '';
398
402
 
399
- const toString = (v, language) => {
400
- let value = "";
401
- if (typeof v !== "string") {
402
- value = serialize(v, {
403
- space: 2,
404
- unsafe: true
405
- }).replace(/"(\w+)":\s/g, "$1: ");
406
- } else {
407
- value = v;
408
- }
409
- if (language === "javascript" && value.startsWith("{") && value.endsWith("}")) {
410
- value = `(${value})`;
411
- }
412
- return value;
413
- };
414
- const _sfc_main$o = defineComponent({
415
- name: "magic-code-editor",
403
+ const _sfc_main$o = /* @__PURE__ */ defineComponent({
404
+ __name: "CodeEditor",
416
405
  props: {
417
- initValues: {
418
- type: [String, Object]
419
- },
420
- modifiedValues: {
421
- type: [String, Object]
422
- },
423
- type: {
424
- type: String,
425
- default: () => ""
426
- },
427
- language: {
428
- type: String,
429
- default: () => "javascript"
430
- },
431
- options: {
432
- type: Object,
433
- default: () => ({})
434
- }
406
+ initValues: null,
407
+ modifiedValues: null,
408
+ type: { default: "" },
409
+ language: { default: "javascript" },
410
+ options: { default: () => ({
411
+ tabSize: 2
412
+ }) },
413
+ autoSave: { type: Boolean, default: true }
435
414
  },
436
415
  emits: ["initd", "save"],
437
- setup(props, { emit }) {
416
+ setup(__props, { expose, emit }) {
417
+ const props = __props;
418
+ const toString = (v, language) => {
419
+ let value = "";
420
+ if (typeof v !== "string") {
421
+ value = serialize(v, {
422
+ space: 2,
423
+ unsafe: true
424
+ }).replace(/"(\w+)":\s/g, "$1: ");
425
+ } else {
426
+ value = v;
427
+ }
428
+ if (language === "javascript" && value.startsWith("{") && value.endsWith("}")) {
429
+ value = `(${value})`;
430
+ }
431
+ return value;
432
+ };
438
433
  let vsEditor = null;
439
434
  let vsDiffEditor = null;
440
435
  const values = ref("");
@@ -483,7 +478,7 @@ const _sfc_main$o = defineComponent({
483
478
  emit("save", getEditorValue());
484
479
  }
485
480
  });
486
- if (props.type !== "diff") {
481
+ if (props.type !== "diff" && props.autoSave) {
487
482
  vsEditor?.onDidBlurEditorWidget(() => {
488
483
  emit("save", getEditorValue());
489
484
  });
@@ -509,10 +504,7 @@ const _sfc_main$o = defineComponent({
509
504
  onUnmounted(() => {
510
505
  resizeObserver.disconnect();
511
506
  });
512
- return {
513
- values,
514
- loading,
515
- codeEditor,
507
+ expose({
516
508
  getEditor() {
517
509
  return vsEditor || vsDiffEditor;
518
510
  },
@@ -521,33 +513,63 @@ const _sfc_main$o = defineComponent({
521
513
  vsEditor?.focus();
522
514
  vsDiffEditor?.focus();
523
515
  }
516
+ });
517
+ return (_ctx, _cache) => {
518
+ return openBlock(), createElementBlock("div", {
519
+ ref_key: "codeEditor",
520
+ ref: codeEditor,
521
+ class: "magic-code-editor"
522
+ }, null, 512);
524
523
  };
525
524
  }
526
525
  });
527
526
 
528
- const _export_sfc = (sfc, props) => {
529
- const target = sfc.__vccOpts || sfc;
530
- for (const [key, val] of props) {
531
- target[key] = val;
532
- }
533
- return target;
534
- };
535
-
536
- const _hoisted_1$c = {
537
- ref: "codeEditor",
538
- class: "magic-code-editor"
539
- };
540
- function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
541
- return openBlock(), createElementBlock("div", _hoisted_1$c, null, 512);
542
- }
543
- const CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$o, [["render", _sfc_render$6]]);
544
-
545
527
  let $TMAGIC_EDITOR = {};
546
528
  const setConfig = (option) => {
547
529
  $TMAGIC_EDITOR = option;
548
530
  };
549
531
  const getConfig = (key) => $TMAGIC_EDITOR[key];
550
532
 
533
+ const _hoisted_1$b = ["src"];
534
+ const _sfc_main$n = /* @__PURE__ */ defineComponent({
535
+ __name: "Icon",
536
+ props: {
537
+ icon: null
538
+ },
539
+ setup(__props) {
540
+ return (_ctx, _cache) => {
541
+ return !__props.icon ? (openBlock(), createBlock(unref(TMagicIcon), {
542
+ key: 0,
543
+ class: "magic-editor-icon"
544
+ }, {
545
+ default: withCtx(() => [
546
+ createVNode(unref(Edit))
547
+ ]),
548
+ _: 1
549
+ })) : typeof __props.icon === "string" && __props.icon.startsWith("http") ? (openBlock(), createBlock(unref(TMagicIcon), {
550
+ key: 1,
551
+ class: "magic-editor-icon"
552
+ }, {
553
+ default: withCtx(() => [
554
+ createElementVNode("img", { src: __props.icon }, null, 8, _hoisted_1$b)
555
+ ]),
556
+ _: 1
557
+ })) : typeof __props.icon === "string" ? (openBlock(), createElementBlock("i", {
558
+ key: 2,
559
+ class: normalizeClass(["magic-editor-icon", __props.icon])
560
+ }, null, 2)) : (openBlock(), createBlock(unref(TMagicIcon), {
561
+ key: 3,
562
+ class: "magic-editor-icon"
563
+ }, {
564
+ default: withCtx(() => [
565
+ (openBlock(), createBlock(resolveDynamicComponent(toRaw(__props.icon))))
566
+ ]),
567
+ _: 1
568
+ }));
569
+ };
570
+ }
571
+ });
572
+
551
573
  const log = (...args) => {
552
574
  if (process.env.NODE_ENV === "development") {
553
575
  console.log("magic editor: ", ...args);
@@ -736,16 +758,20 @@ class CodeBlock extends BaseService {
736
758
  }
737
759
  async setCodeDslById(id, codeConfig) {
738
760
  let codeDsl = await this.getCodeDsl();
739
- if (!codeDsl)
740
- return;
741
- const existContent = codeDsl[id] || {};
742
- codeDsl = {
743
- ...codeDsl,
744
- [id]: {
745
- ...existContent,
746
- ...codeConfig
747
- }
748
- };
761
+ if (!codeDsl) {
762
+ codeDsl = {
763
+ [id]: codeConfig
764
+ };
765
+ } else {
766
+ const existContent = codeDsl[id] || {};
767
+ codeDsl = {
768
+ ...codeDsl,
769
+ [id]: {
770
+ ...existContent,
771
+ ...codeConfig
772
+ }
773
+ };
774
+ }
749
775
  await this.setCodeDsl(codeDsl);
750
776
  }
751
777
  async getCodeDslByIds(ids) {
@@ -1929,12 +1955,12 @@ class Editor$1 extends BaseService {
1929
1955
  const root = this.get("root");
1930
1956
  if (!root)
1931
1957
  return null;
1932
- return root.codeBlock || null;
1958
+ return root.codeBlocks || null;
1933
1959
  }
1934
1960
  async setCodeDsl(codeDsl) {
1935
1961
  if (!this.state.root)
1936
1962
  return;
1937
- this.state.root.codeBlock = codeDsl;
1963
+ this.state.root.codeBlocks = codeDsl;
1938
1964
  }
1939
1965
  addModifiedNodeId(id) {
1940
1966
  if (!this.isHistoryStateChange) {
@@ -2400,52 +2426,41 @@ const useStage = (stageOptions) => {
2400
2426
  return stage;
2401
2427
  };
2402
2428
 
2403
- const _sfc_main$n = defineComponent({
2404
- components: { Plus },
2405
- setup() {
2429
+ const _hoisted_1$a = { class: "m-editor-empty-panel" };
2430
+ const _hoisted_2$4 = { class: "m-editor-empty-content" };
2431
+ const _hoisted_3$2 = /* @__PURE__ */ createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
2432
+ const _sfc_main$m = /* @__PURE__ */ defineComponent({
2433
+ __name: "AddPageBox",
2434
+ setup(__props) {
2406
2435
  const services = inject("services");
2407
- return {
2408
- clickHandler() {
2409
- const { editorService } = services || {};
2410
- if (!editorService)
2411
- return;
2412
- editorService.add({
2413
- type: NodeType.PAGE,
2414
- name: generatePageNameByApp(toRaw(editorService.get("root")))
2415
- });
2416
- }
2436
+ const clickHandler = () => {
2437
+ const { editorService } = services || {};
2438
+ if (!editorService)
2439
+ return;
2440
+ editorService.add({
2441
+ type: NodeType.PAGE,
2442
+ name: generatePageNameByApp(toRaw(editorService.get("root")))
2443
+ });
2444
+ };
2445
+ return (_ctx, _cache) => {
2446
+ return openBlock(), createElementBlock("div", _hoisted_1$a, [
2447
+ createElementVNode("div", _hoisted_2$4, [
2448
+ createElementVNode("div", {
2449
+ class: "m-editor-empty-button",
2450
+ onClick: clickHandler
2451
+ }, [
2452
+ createElementVNode("div", null, [
2453
+ createVNode(_sfc_main$n, { icon: unref(Plus) }, null, 8, ["icon"])
2454
+ ]),
2455
+ _hoisted_3$2
2456
+ ])
2457
+ ])
2458
+ ]);
2417
2459
  };
2418
2460
  }
2419
2461
  });
2420
2462
 
2421
- const _hoisted_1$b = { class: "m-editor-empty-panel" };
2422
- const _hoisted_2$5 = { class: "m-editor-empty-content" };
2423
- const _hoisted_3$2 = /* @__PURE__ */ createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
2424
- function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
2425
- const _component_plus = resolveComponent("plus");
2426
- const _component_el_icon = resolveComponent("el-icon");
2427
- return openBlock(), createElementBlock("div", _hoisted_1$b, [
2428
- createElementVNode("div", _hoisted_2$5, [
2429
- createElementVNode("div", {
2430
- class: "m-editor-empty-button",
2431
- onClick: _cache[0] || (_cache[0] = (...args) => _ctx.clickHandler && _ctx.clickHandler(...args))
2432
- }, [
2433
- createElementVNode("div", null, [
2434
- createVNode(_component_el_icon, null, {
2435
- default: withCtx(() => [
2436
- createVNode(_component_plus)
2437
- ]),
2438
- _: 1
2439
- })
2440
- ]),
2441
- _hoisted_3$2
2442
- ])
2443
- ])
2444
- ]);
2445
- }
2446
- const AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$n, [["render", _sfc_render$5]]);
2447
-
2448
- const _sfc_main$m = /* @__PURE__ */ defineComponent({
2463
+ const _sfc_main$l = /* @__PURE__ */ defineComponent({
2449
2464
  __name: "Resizer",
2450
2465
  emits: ["change"],
2451
2466
  setup(__props, { emit }) {
@@ -2478,7 +2493,7 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
2478
2493
  }
2479
2494
  });
2480
2495
 
2481
- const _sfc_main$l = /* @__PURE__ */ defineComponent({
2496
+ const _sfc_main$k = /* @__PURE__ */ defineComponent({
2482
2497
  __name: "Layout",
2483
2498
  props: {
2484
2499
  left: null,
@@ -2551,7 +2566,7 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
2551
2566
  }, [
2552
2567
  renderSlot(_ctx.$slots, "left")
2553
2568
  ], 6),
2554
- createVNode(_sfc_main$m, { onChange: changeLeft })
2569
+ createVNode(_sfc_main$l, { onChange: changeLeft })
2555
2570
  ], 64)) : createCommentVNode("", true),
2556
2571
  createElementVNode("div", {
2557
2572
  class: normalizeClass(["m-editor-layout-center", __props.centerClass]),
@@ -2560,7 +2575,7 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
2560
2575
  renderSlot(_ctx.$slots, "center")
2561
2576
  ], 6),
2562
2577
  typeof props.right !== "undefined" ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
2563
- createVNode(_sfc_main$m, { onChange: changeRight }),
2578
+ createVNode(_sfc_main$l, { onChange: changeRight }),
2564
2579
  createElementVNode("div", {
2565
2580
  class: normalizeClass(["m-editor-layout-right", __props.rightClass]),
2566
2581
  style: normalizeStyle(`width: ${__props.right}px`)
@@ -2573,8 +2588,8 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
2573
2588
  }
2574
2589
  });
2575
2590
 
2576
- const _hoisted_1$a = { class: "m-editor" };
2577
- const _sfc_main$k = /* @__PURE__ */ defineComponent({
2591
+ const _hoisted_1$9 = { class: "m-editor" };
2592
+ const _sfc_main$j = /* @__PURE__ */ defineComponent({
2578
2593
  __name: "Framework",
2579
2594
  props: {
2580
2595
  codeOptions: { default: () => ({}) }
@@ -2624,8 +2639,7 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
2624
2639
  };
2625
2640
  return (_ctx, _cache) => {
2626
2641
  const _component_magic_code_editor = resolveComponent("magic-code-editor");
2627
- const _component_el_scrollbar = resolveComponent("el-scrollbar");
2628
- return openBlock(), createElementBlock("div", _hoisted_1$a, [
2642
+ return openBlock(), createElementBlock("div", _hoisted_1$9, [
2629
2643
  renderSlot(_ctx.$slots, "nav", { class: "m-editor-nav-menu" }),
2630
2644
  unref(showSrc) ? (openBlock(), createBlock(_component_magic_code_editor, {
2631
2645
  key: 0,
@@ -2633,7 +2647,7 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
2633
2647
  "init-values": unref(root),
2634
2648
  options: __props.codeOptions,
2635
2649
  onSave: saveCode
2636
- }, null, 8, ["init-values", "options"])) : (openBlock(), createBlock(_sfc_main$l, {
2650
+ }, null, 8, ["init-values", "options"])) : (openBlock(), createBlock(_sfc_main$k, {
2637
2651
  key: 1,
2638
2652
  class: "m-editor-content",
2639
2653
  "left-class": "m-editor-framework-left",
@@ -2652,7 +2666,7 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
2652
2666
  ]),
2653
2667
  center: withCtx(() => [
2654
2668
  unref(pageLength) > 0 ? renderSlot(_ctx.$slots, "workspace", { key: 0 }) : renderSlot(_ctx.$slots, "empty", { key: 1 }, () => [
2655
- createVNode(AddPageBox)
2669
+ createVNode(_sfc_main$m)
2656
2670
  ])
2657
2671
  ]),
2658
2672
  _: 2
@@ -2660,7 +2674,7 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
2660
2674
  unref(pageLength) > 0 ? {
2661
2675
  name: "right",
2662
2676
  fn: withCtx(() => [
2663
- createVNode(_component_el_scrollbar, null, {
2677
+ createVNode(unref(TMagicScrollbar), null, {
2664
2678
  default: withCtx(() => [
2665
2679
  renderSlot(_ctx.$slots, "props-panel")
2666
2680
  ]),
@@ -2674,52 +2688,11 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
2674
2688
  }
2675
2689
  });
2676
2690
 
2677
- const _hoisted_1$9 = ["src"];
2678
- const _sfc_main$j = /* @__PURE__ */ defineComponent({
2679
- __name: "Icon",
2680
- props: {
2681
- icon: null
2682
- },
2683
- setup(__props) {
2684
- return (_ctx, _cache) => {
2685
- const _component_el_icon = resolveComponent("el-icon");
2686
- return !__props.icon ? (openBlock(), createBlock(_component_el_icon, {
2687
- key: 0,
2688
- class: "magic-editor-icon"
2689
- }, {
2690
- default: withCtx(() => [
2691
- createVNode(unref(Edit))
2692
- ]),
2693
- _: 1
2694
- })) : typeof __props.icon === "string" && __props.icon.startsWith("http") ? (openBlock(), createBlock(_component_el_icon, {
2695
- key: 1,
2696
- class: "magic-editor-icon"
2697
- }, {
2698
- default: withCtx(() => [
2699
- createElementVNode("img", { src: __props.icon }, null, 8, _hoisted_1$9)
2700
- ]),
2701
- _: 1
2702
- })) : typeof __props.icon === "string" ? (openBlock(), createElementBlock("i", {
2703
- key: 2,
2704
- class: normalizeClass(["magic-editor-icon", __props.icon])
2705
- }, null, 2)) : (openBlock(), createBlock(_component_el_icon, {
2706
- key: 3,
2707
- class: "magic-editor-icon"
2708
- }, {
2709
- default: withCtx(() => [
2710
- (openBlock(), createBlock(resolveDynamicComponent(toRaw(__props.icon))))
2711
- ]),
2712
- _: 1
2713
- }));
2714
- };
2715
- }
2716
- });
2717
-
2718
2691
  const _hoisted_1$8 = {
2719
2692
  key: 1,
2720
2693
  class: "menu-item-text"
2721
2694
  };
2722
- const _hoisted_2$4 = { class: "el-dropdown-link menubar-menu-button" };
2695
+ const _hoisted_2$3 = { class: "el-dropdown-link menubar-menu-button" };
2723
2696
  const _sfc_main$i = /* @__PURE__ */ defineComponent({
2724
2697
  __name: "ToolButton",
2725
2698
  props: {
@@ -2786,13 +2759,6 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
2786
2759
  }
2787
2760
  };
2788
2761
  return (_ctx, _cache) => {
2789
- const _component_el_divider = resolveComponent("el-divider");
2790
- const _component_el_button = resolveComponent("el-button");
2791
- const _component_el_tooltip = resolveComponent("el-tooltip");
2792
- const _component_el_icon = resolveComponent("el-icon");
2793
- const _component_el_dropdown_item = resolveComponent("el-dropdown-item");
2794
- const _component_el_dropdown_menu = resolveComponent("el-dropdown-menu");
2795
- const _component_el_dropdown = resolveComponent("el-dropdown");
2796
2762
  return unref(display) ? (openBlock(), createElementBlock("div", {
2797
2763
  key: 0,
2798
2764
  class: normalizeClass(["menu-item", `${__props.data.type} ${__props.data.className || ""}`]),
@@ -2800,24 +2766,24 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
2800
2766
  onMousedown: _cache[1] || (_cache[1] = ($event) => mousedownHandler(__props.data, $event)),
2801
2767
  onMouseup: _cache[2] || (_cache[2] = ($event) => mouseupHandler(__props.data, $event))
2802
2768
  }, [
2803
- __props.data.type === "divider" ? (openBlock(), createBlock(_component_el_divider, {
2769
+ __props.data.type === "divider" ? (openBlock(), createBlock(unref(TMagicDivider), {
2804
2770
  key: 0,
2805
2771
  direction: __props.data.direction || "vertical"
2806
2772
  }, null, 8, ["direction"])) : __props.data.type === "text" ? (openBlock(), createElementBlock("div", _hoisted_1$8, toDisplayString(__props.data.text), 1)) : __props.data.type === "button" ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
2807
- __props.data.tooltip ? (openBlock(), createBlock(_component_el_tooltip, {
2773
+ __props.data.tooltip ? (openBlock(), createBlock(unref(TMagicTooltip), {
2808
2774
  key: 0,
2809
2775
  effect: "dark",
2810
2776
  placement: "bottom-start",
2811
2777
  content: __props.data.tooltip
2812
2778
  }, {
2813
2779
  default: withCtx(() => [
2814
- createVNode(_component_el_button, {
2780
+ createVNode(unref(TMagicButton), {
2815
2781
  size: "small",
2816
2782
  text: "",
2817
2783
  disabled: unref(disabled)
2818
2784
  }, {
2819
2785
  default: withCtx(() => [
2820
- __props.data.icon ? (openBlock(), createBlock(_sfc_main$j, {
2786
+ __props.data.icon ? (openBlock(), createBlock(_sfc_main$n, {
2821
2787
  key: 0,
2822
2788
  icon: __props.data.icon
2823
2789
  }, null, 8, ["icon"])) : createCommentVNode("", true),
@@ -2827,14 +2793,14 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
2827
2793
  }, 8, ["disabled"])
2828
2794
  ]),
2829
2795
  _: 1
2830
- }, 8, ["content"])) : (openBlock(), createBlock(_component_el_button, {
2796
+ }, 8, ["content"])) : (openBlock(), createBlock(unref(TMagicButton), {
2831
2797
  key: 1,
2832
2798
  size: "small",
2833
2799
  text: "",
2834
2800
  disabled: unref(disabled)
2835
2801
  }, {
2836
2802
  default: withCtx(() => [
2837
- __props.data.icon ? (openBlock(), createBlock(_sfc_main$j, {
2803
+ __props.data.icon ? (openBlock(), createBlock(_sfc_main$n, {
2838
2804
  key: 0,
2839
2805
  icon: __props.data.icon
2840
2806
  }, null, 8, ["icon"])) : createCommentVNode("", true),
@@ -2842,17 +2808,17 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
2842
2808
  ]),
2843
2809
  _: 1
2844
2810
  }, 8, ["disabled"]))
2845
- ], 64)) : __props.data.type === "dropdown" ? (openBlock(), createBlock(_component_el_dropdown, {
2811
+ ], 64)) : __props.data.type === "dropdown" ? (openBlock(), createBlock(unref(TMagicDropdown), {
2846
2812
  key: 3,
2847
2813
  trigger: "click",
2848
2814
  disabled: unref(disabled),
2849
2815
  onCommand: dropdownHandler
2850
2816
  }, {
2851
2817
  dropdown: withCtx(() => [
2852
- __props.data.items && __props.data.items.length ? (openBlock(), createBlock(_component_el_dropdown_menu, { key: 0 }, {
2818
+ __props.data.items && __props.data.items.length ? (openBlock(), createBlock(unref(TMagicDropdownMenu), { key: 0 }, {
2853
2819
  default: withCtx(() => [
2854
2820
  (openBlock(true), createElementBlock(Fragment, null, renderList(__props.data.items, (subItem, index) => {
2855
- return openBlock(), createBlock(_component_el_dropdown_item, {
2821
+ return openBlock(), createBlock(unref(TMagicDropdownItem), {
2856
2822
  key: index,
2857
2823
  command: { data: __props.data, subItem }
2858
2824
  }, {
@@ -2867,9 +2833,9 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
2867
2833
  })) : createCommentVNode("", true)
2868
2834
  ]),
2869
2835
  default: withCtx(() => [
2870
- createElementVNode("span", _hoisted_2$4, [
2836
+ createElementVNode("span", _hoisted_2$3, [
2871
2837
  createTextVNode(toDisplayString(__props.data.text), 1),
2872
- createVNode(_component_el_icon, { class: "el-icon--right" }, {
2838
+ createVNode(unref(TMagicIcon), { class: "el-icon--right" }, {
2873
2839
  default: withCtx(() => [
2874
2840
  createVNode(unref(ArrowDown))
2875
2841
  ]),
@@ -3090,13 +3056,8 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
3090
3056
  services?.editorService.update(values2);
3091
3057
  } catch (e) {
3092
3058
  console.error(e);
3093
- ElMessage.closeAll();
3094
- ElMessage.error({
3095
- duration: 1e4,
3096
- showClose: true,
3097
- message: e.message,
3098
- dangerouslyUseHTMLString: true
3099
- });
3059
+ tMagicMessage.closeAll();
3060
+ tMagicMessage.error(e.message);
3100
3061
  }
3101
3062
  };
3102
3063
  expose({ submit });
@@ -3120,7 +3081,7 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
3120
3081
  });
3121
3082
 
3122
3083
  const _hoisted_1$6 = ["id"];
3123
- const _hoisted_2$3 = { class: "list-item" };
3084
+ const _hoisted_2$2 = { class: "list-item" };
3124
3085
  const _hoisted_3$1 = { class: "code-name" };
3125
3086
  const _hoisted_4$1 = { class: "code-name-wrapper" };
3126
3087
  const _hoisted_5$1 = /* @__PURE__ */ createElementVNode("div", { class: "code-name-label" }, "\u4EE3\u7801\u5757\u540D\u79F0", -1);
@@ -3165,8 +3126,7 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
3165
3126
  forIn(codeDsl, (value, key) => {
3166
3127
  state.codeList.push({
3167
3128
  id: key,
3168
- name: value.name,
3169
- content: value.content
3129
+ name: value.name
3170
3130
  });
3171
3131
  });
3172
3132
  currentTitle.value = state.codeList[0]?.name || "";
@@ -3178,14 +3138,14 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
3178
3138
  const codeContent = codeEditor.value.getEditor()?.getValue();
3179
3139
  codeConfig.value.content = eval(codeContent);
3180
3140
  } catch (e) {
3181
- ElMessage.error(e.stack);
3141
+ tMagicMessage.error(e.stack);
3182
3142
  return false;
3183
3143
  }
3184
3144
  await services?.codeBlockService.setCodeDslById(id.value, {
3185
3145
  name: codeConfig.value.name,
3186
3146
  content: codeConfig.value.content
3187
3147
  });
3188
- ElMessage.success("\u4EE3\u7801\u4FDD\u5B58\u6210\u529F");
3148
+ tMagicMessage.success("\u4EE3\u7801\u4FDD\u5B58\u6210\u529F");
3189
3149
  return true;
3190
3150
  };
3191
3151
  const saveAndClose = async () => {
@@ -3199,22 +3159,17 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
3199
3159
  currentTitle.value = data.name;
3200
3160
  };
3201
3161
  return (_ctx, _cache) => {
3202
- const _component_el_tree = resolveComponent("el-tree");
3203
- const _component_el_input = resolveComponent("el-input");
3204
- const _component_el_button = resolveComponent("el-button");
3205
- const _component_el_card = resolveComponent("el-card");
3206
- const _component_el_dialog = resolveComponent("el-dialog");
3207
- return openBlock(), createBlock(_component_el_dialog, {
3162
+ return openBlock(), createBlock(unref(TMagicDialog), {
3208
3163
  modelValue: unref(isShowCodeBlockEditor),
3209
3164
  "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => isRef(isShowCodeBlockEditor) ? isShowCodeBlockEditor.value = $event : null),
3165
+ class: "code-editor-dialog",
3210
3166
  title: currentTitle.value,
3211
3167
  fullscreen: true,
3212
3168
  "before-close": saveAndClose,
3213
- "append-to-body": true,
3214
- "custom-class": "code-editor-dialog"
3169
+ "append-to-body": true
3215
3170
  }, {
3216
3171
  default: withCtx(() => [
3217
- createVNode(_sfc_main$l, {
3172
+ createVNode(_sfc_main$k, {
3218
3173
  left: left.value,
3219
3174
  "onUpdate:left": _cache[1] || (_cache[1] = ($event) => left.value = $event),
3220
3175
  "min-left": 45,
@@ -3228,11 +3183,11 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
3228
3183
  ])
3229
3184
  }, [
3230
3185
  renderSlot(_ctx.$slots, "code-block-edit-panel-header", { id: unref(id) }),
3231
- createVNode(_component_el_card, { shadow: "never" }, {
3186
+ createVNode(unref(TMagicCard), { shadow: "never" }, {
3232
3187
  header: withCtx(() => [
3233
3188
  createElementVNode("div", _hoisted_4$1, [
3234
3189
  _hoisted_5$1,
3235
- codeConfig.value ? (openBlock(), createBlock(_component_el_input, {
3190
+ codeConfig.value ? (openBlock(), createBlock(unref(TMagicInput), {
3236
3191
  key: 0,
3237
3192
  class: "code-name-input",
3238
3193
  modelValue: codeConfig.value.name,
@@ -3243,7 +3198,7 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
3243
3198
  ]),
3244
3199
  default: withCtx(() => [
3245
3200
  createElementVNode("div", _hoisted_6$1, [
3246
- codeConfig.value ? (openBlock(), createBlock(CodeEditor, {
3201
+ codeConfig.value ? (openBlock(), createBlock(_sfc_main$o, {
3247
3202
  key: 0,
3248
3203
  ref_key: "codeEditor",
3249
3204
  ref: codeEditor,
@@ -3258,7 +3213,7 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
3258
3213
  }
3259
3214
  }, null, 8, ["init-values", "options"])) : createCommentVNode("", true),
3260
3215
  unref(editable) ? (openBlock(), createElementBlock("div", _hoisted_7$1, [
3261
- createVNode(_component_el_button, {
3216
+ createVNode(unref(TMagicButton), {
3262
3217
  type: "primary",
3263
3218
  class: "button",
3264
3219
  onClick: saveCode
@@ -3268,7 +3223,7 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
3268
3223
  ]),
3269
3224
  _: 1
3270
3225
  }),
3271
- createVNode(_component_el_button, {
3226
+ createVNode(unref(TMagicButton), {
3272
3227
  type: "primary",
3273
3228
  class: "button",
3274
3229
  onClick: saveAndClose
@@ -3279,7 +3234,7 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
3279
3234
  _: 1
3280
3235
  })
3281
3236
  ])) : (openBlock(), createElementBlock("div", _hoisted_10, [
3282
- createVNode(_component_el_button, {
3237
+ createVNode(unref(TMagicButton), {
3283
3238
  type: "primary",
3284
3239
  class: "button",
3285
3240
  onClick: saveAndClose
@@ -3301,23 +3256,22 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
3301
3256
  unref(mode) === unref(CodeEditorMode).LIST ? {
3302
3257
  name: "left",
3303
3258
  fn: withCtx(() => [
3304
- !unref(isEmpty)(state.codeList) ? (openBlock(), createBlock(_component_el_tree, {
3259
+ !unref(isEmpty)(state.codeList) ? (openBlock(), createBlock(unref(TMagicTree), {
3305
3260
  key: 0,
3306
- ref: "tree",
3261
+ class: "side-tree",
3307
3262
  "node-key": "id",
3308
3263
  "empty-text": "\u6682\u65E0\u4EE3\u7801\u5757",
3309
3264
  data: state.codeList,
3310
3265
  "highlight-current": true,
3311
- onNodeClick: selectHandler,
3312
3266
  "current-node-key": state.codeList[0].id,
3313
- class: "side-tree"
3267
+ onNodeClick: selectHandler
3314
3268
  }, {
3315
3269
  default: withCtx(({ data }) => [
3316
3270
  createElementVNode("div", {
3317
3271
  id: data.id,
3318
3272
  class: "list-container"
3319
3273
  }, [
3320
- createElementVNode("div", _hoisted_2$3, [
3274
+ createElementVNode("div", _hoisted_2$2, [
3321
3275
  createElementVNode("div", _hoisted_3$1, toDisplayString(data.name) + "\uFF08" + toDisplayString(data.id) + "\uFF09", 1)
3322
3276
  ])
3323
3277
  ], 8, _hoisted_1$6)
@@ -3335,7 +3289,7 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
3335
3289
  });
3336
3290
 
3337
3291
  const _hoisted_1$5 = { class: "m-editor-code-block-list" };
3338
- const _hoisted_2$2 = { class: "code-header-wrapper" };
3292
+ const _hoisted_2$1 = { class: "code-header-wrapper" };
3339
3293
  const _hoisted_3 = /* @__PURE__ */ createTextVNode("\u65B0\u589E");
3340
3294
  const _hoisted_4 = ["id"];
3341
3295
  const _hoisted_5 = { class: "list-item" };
@@ -3393,7 +3347,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
3393
3347
  state.codeList.push({
3394
3348
  id: codeId,
3395
3349
  name: value.name,
3396
- content: value.content,
3350
+ codeBlockContent: value,
3397
3351
  showRelation: true
3398
3352
  });
3399
3353
  });
@@ -3425,7 +3379,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
3425
3379
  const createCodeBlock = async () => {
3426
3380
  const { codeBlockService } = services || {};
3427
3381
  if (!codeBlockService) {
3428
- ElMessage.error("\u65B0\u589E\u4EE3\u7801\u5757\u5931\u8D25");
3382
+ tMagicMessage.error("\u65B0\u589E\u4EE3\u7801\u5757\u5931\u8D25");
3429
3383
  return;
3430
3384
  }
3431
3385
  const codeConfig = {
@@ -3452,7 +3406,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
3452
3406
  if (typeof props.customError === "function") {
3453
3407
  props.customError(key, existBinds ? CodeDeleteErrorType.BIND : CodeDeleteErrorType.UNDELETEABLE);
3454
3408
  } else {
3455
- ElMessage.error("\u4EE3\u7801\u5757\u5220\u9664\u5931\u8D25");
3409
+ tMagicMessage.error("\u4EE3\u7801\u5757\u5220\u9664\u5931\u8D25");
3456
3410
  }
3457
3411
  }
3458
3412
  };
@@ -3484,14 +3438,10 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
3484
3438
  stage?.select(compId);
3485
3439
  };
3486
3440
  return (_ctx, _cache) => {
3487
- const _component_el_input = resolveComponent("el-input");
3488
- const _component_el_button = resolveComponent("el-button");
3489
- const _component_el_tooltip = resolveComponent("el-tooltip");
3490
- const _component_el_tree = resolveComponent("el-tree");
3491
3441
  return openBlock(), createElementBlock("div", _hoisted_1$5, [
3492
3442
  renderSlot(_ctx.$slots, "code-block-panel-header", {}, () => [
3493
- createElementVNode("div", _hoisted_2$2, [
3494
- createVNode(_component_el_input, {
3443
+ createElementVNode("div", _hoisted_2$1, [
3444
+ createVNode(unref(TMagicInput), {
3495
3445
  class: normalizeClass([unref(editable) ? "code-filter-input" : "code-filter-input-no-btn"]),
3496
3446
  size: "small",
3497
3447
  placeholder: "\u8F93\u5165\u5173\u952E\u5B57\u8FDB\u884C\u8FC7\u6EE4",
@@ -3500,7 +3450,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
3500
3450
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => filterText.value = $event),
3501
3451
  onInput: filterTextChangeHandler
3502
3452
  }, null, 8, ["class", "modelValue"]),
3503
- unref(editable) ? (openBlock(), createBlock(_component_el_button, {
3453
+ unref(editable) ? (openBlock(), createBlock(unref(TMagicButton), {
3504
3454
  key: 0,
3505
3455
  class: "create-code-button",
3506
3456
  type: "primary",
@@ -3514,7 +3464,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
3514
3464
  })) : createCommentVNode("", true)
3515
3465
  ])
3516
3466
  ]),
3517
- !unref(isEmpty)(state.codeList) ? (openBlock(), createBlock(_component_el_tree, {
3467
+ !unref(isEmpty)(state.codeList) ? (openBlock(), createBlock(unref(TMagicTree), {
3518
3468
  key: 0,
3519
3469
  ref_key: "tree",
3520
3470
  ref: tree,
@@ -3533,13 +3483,13 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
3533
3483
  createElementVNode("div", _hoisted_5, [
3534
3484
  createElementVNode("div", _hoisted_6, toDisplayString(data.name) + "\uFF08" + toDisplayString(data.id) + "\uFF09", 1),
3535
3485
  createElementVNode("div", _hoisted_7, [
3536
- createVNode(_component_el_tooltip, {
3486
+ createVNode(unref(TMagicTooltip), {
3537
3487
  effect: "dark",
3538
3488
  content: unref(editable) ? "\u7F16\u8F91" : "\u67E5\u770B",
3539
3489
  placement: "bottom"
3540
3490
  }, {
3541
3491
  default: withCtx(() => [
3542
- createVNode(_sfc_main$j, {
3492
+ createVNode(_sfc_main$n, {
3543
3493
  icon: unref(editable) ? unref(Edit) : unref(View),
3544
3494
  class: "edit-icon",
3545
3495
  onClick: withModifiers(($event) => editCode(`${data.id}`), ["stop"])
@@ -3547,14 +3497,14 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
3547
3497
  ]),
3548
3498
  _: 2
3549
3499
  }, 1032, ["content"]),
3550
- state.bindComps[data.id] && state.bindComps[data.id].length > 0 ? (openBlock(), createBlock(_component_el_tooltip, {
3500
+ state.bindComps[data.id] && state.bindComps[data.id].length > 0 ? (openBlock(), createBlock(unref(TMagicTooltip), {
3551
3501
  key: 0,
3552
3502
  effect: "dark",
3553
3503
  content: "\u67E5\u770B\u7ED1\u5B9A\u5173\u7CFB",
3554
3504
  placement: "bottom"
3555
3505
  }, {
3556
3506
  default: withCtx(() => [
3557
- createVNode(_sfc_main$j, {
3507
+ createVNode(_sfc_main$n, {
3558
3508
  icon: unref(Link),
3559
3509
  class: "edit-icon",
3560
3510
  onClick: withModifiers(($event) => toggleCombineRelation(data), ["stop"])
@@ -3562,14 +3512,14 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
3562
3512
  ]),
3563
3513
  _: 2
3564
3514
  }, 1024)) : createCommentVNode("", true),
3565
- unref(editable) ? (openBlock(), createBlock(_component_el_tooltip, {
3515
+ unref(editable) ? (openBlock(), createBlock(unref(TMagicTooltip), {
3566
3516
  key: 1,
3567
3517
  effect: "dark",
3568
3518
  content: "\u5220\u9664",
3569
3519
  placement: "bottom"
3570
3520
  }, {
3571
3521
  default: withCtx(() => [
3572
- createVNode(_sfc_main$j, {
3522
+ createVNode(_sfc_main$n, {
3573
3523
  icon: unref(Close),
3574
3524
  class: "edit-icon",
3575
3525
  onClick: withModifiers(($event) => deleteCode(`${data.id}`), ["stop"])
@@ -3578,14 +3528,15 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
3578
3528
  _: 2
3579
3529
  }, 1024)) : createCommentVNode("", true),
3580
3530
  renderSlot(_ctx.$slots, "code-block-panel-tool", {
3581
- id: data.id
3531
+ id: data.id,
3532
+ data: data.codeBlockContent
3582
3533
  })
3583
3534
  ])
3584
3535
  ]),
3585
3536
  data.showRelation && state.bindComps[data.id] && state.bindComps[data.id].length > 0 ? (openBlock(), createElementBlock("div", _hoisted_8, [
3586
3537
  _hoisted_9,
3587
3538
  (openBlock(true), createElementBlock(Fragment, null, renderList(state.bindComps[data.id], (comp, index) => {
3588
- return openBlock(), createBlock(_component_el_button, {
3539
+ return openBlock(), createBlock(unref(TMagicButton), {
3589
3540
  key: index,
3590
3541
  class: "code-comp",
3591
3542
  size: "small",
@@ -3614,8 +3565,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
3614
3565
  }
3615
3566
  });
3616
3567
 
3617
- const _hoisted_1$4 = /* @__PURE__ */ createElementVNode("i", { class: "el-icon-s-grid" }, null, -1);
3618
- const _hoisted_2$1 = ["onClick", "onDragstart"];
3568
+ const _hoisted_1$4 = ["onClick", "onDragstart"];
3619
3569
  const _sfc_main$d = /* @__PURE__ */ defineComponent({
3620
3570
  __name: "ComponentListPanel",
3621
3571
  setup(__props) {
@@ -3630,7 +3580,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
3630
3580
  }))
3631
3581
  );
3632
3582
  const collapseValue = computed(
3633
- () => Array(list.value?.length).fill(1).map((x, i) => i)
3583
+ () => Array(list.value?.length).fill(1).map((x, i) => `${i}`)
3634
3584
  );
3635
3585
  let timeout;
3636
3586
  let clientX;
@@ -3682,20 +3632,15 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
3682
3632
  timeout = stage.value.getAddContainerHighlightClassNameTimeout(e);
3683
3633
  };
3684
3634
  return (_ctx, _cache) => {
3685
- const _component_el_input = resolveComponent("el-input");
3686
- const _component_el_tooltip = resolveComponent("el-tooltip");
3687
- const _component_el_collapse_item = resolveComponent("el-collapse-item");
3688
- const _component_el_collapse = resolveComponent("el-collapse");
3689
- const _component_el_scrollbar = resolveComponent("el-scrollbar");
3690
- return openBlock(), createBlock(_component_el_scrollbar, null, {
3635
+ return openBlock(), createBlock(unref(TMagicScrollbar), null, {
3691
3636
  default: withCtx(() => [
3692
3637
  renderSlot(_ctx.$slots, "component-list-panel-header"),
3693
- createVNode(_component_el_collapse, {
3638
+ createVNode(unref(TMagicCollapse), {
3694
3639
  class: "ui-component-panel",
3695
3640
  "model-value": unref(collapseValue)
3696
3641
  }, {
3697
3642
  default: withCtx(() => [
3698
- createVNode(_component_el_input, {
3643
+ createVNode(unref(TMagicInput), {
3699
3644
  "prefix-icon": "el-icon-search",
3700
3645
  placeholder: "\u8F93\u5165\u5173\u952E\u5B57\u8FDB\u884C\u8FC7\u6EE4",
3701
3646
  class: "search-input",
@@ -3706,12 +3651,12 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
3706
3651
  }, null, 8, ["modelValue"]),
3707
3652
  (openBlock(true), createElementBlock(Fragment, null, renderList(unref(list), (group, index) => {
3708
3653
  return openBlock(), createElementBlock(Fragment, null, [
3709
- group.items && group.items.length ? (openBlock(), createBlock(_component_el_collapse_item, {
3654
+ group.items && group.items.length ? (openBlock(), createBlock(unref(TMagicCollapseItem), {
3710
3655
  key: index,
3711
- name: index
3656
+ name: `${index}`
3712
3657
  }, {
3713
3658
  title: withCtx(() => [
3714
- _hoisted_1$4,
3659
+ createVNode(_sfc_main$n, { icon: unref(Grid) }, null, 8, ["icon"]),
3715
3660
  createTextVNode(toDisplayString(group.title), 1)
3716
3661
  ]),
3717
3662
  default: withCtx(() => [
@@ -3726,10 +3671,10 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
3726
3671
  onDrag: dragHandler
3727
3672
  }, [
3728
3673
  renderSlot(_ctx.$slots, "component-list-item", { component: item }, () => [
3729
- createVNode(_sfc_main$j, {
3674
+ createVNode(_sfc_main$n, {
3730
3675
  icon: item.icon
3731
3676
  }, null, 8, ["icon"]),
3732
- createVNode(_component_el_tooltip, {
3677
+ createVNode(unref(TMagicTooltip), {
3733
3678
  effect: "dark",
3734
3679
  placement: "bottom",
3735
3680
  content: item.text
@@ -3740,7 +3685,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
3740
3685
  _: 2
3741
3686
  }, 1032, ["content"])
3742
3687
  ])
3743
- ], 40, _hoisted_2$1);
3688
+ ], 40, _hoisted_1$4);
3744
3689
  }), 128))
3745
3690
  ]),
3746
3691
  _: 2
@@ -3870,9 +3815,9 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
3870
3815
  }
3871
3816
  });
3872
3817
 
3873
- const _sfc_main$b = defineComponent({
3874
- components: { ContentMenu: _sfc_main$c },
3875
- setup() {
3818
+ const _sfc_main$b = /* @__PURE__ */ defineComponent({
3819
+ __name: "LayerMenu",
3820
+ setup(__props, { expose }) {
3876
3821
  const services = inject("services");
3877
3822
  const menu = ref();
3878
3823
  const node = computed(() => services?.editorService.get("node"));
@@ -3923,337 +3868,349 @@ const _sfc_main$b = defineComponent({
3923
3868
  }
3924
3869
  return [];
3925
3870
  });
3926
- return {
3927
- menu,
3928
- menuData: computed(() => [
3929
- {
3930
- type: "button",
3931
- text: "\u65B0\u589E",
3932
- icon: markRaw(Plus),
3933
- display: () => node.value?.items,
3934
- items: getSubMenuData.value
3935
- },
3936
- {
3937
- type: "button",
3938
- text: "\u590D\u5236",
3939
- icon: markRaw(DocumentCopy),
3940
- display: () => !isRoot.value,
3941
- handler: () => {
3942
- node.value && services?.editorService.copy(node.value);
3943
- }
3944
- },
3945
- {
3946
- type: "button",
3947
- text: "\u5220\u9664",
3948
- icon: markRaw(Delete),
3949
- display: () => !isRoot.value && !isPage.value,
3950
- handler: () => {
3951
- node.value && services?.editorService.remove(node.value);
3952
- }
3953
- },
3954
- ...layerContentMenu
3955
- ]),
3956
- show(e) {
3957
- menu.value?.show(e);
3958
- }
3871
+ const menuData = computed(() => [
3872
+ {
3873
+ type: "button",
3874
+ text: "\u65B0\u589E",
3875
+ icon: markRaw(Plus),
3876
+ display: () => node.value?.items,
3877
+ items: getSubMenuData.value
3878
+ },
3879
+ {
3880
+ type: "button",
3881
+ text: "\u590D\u5236",
3882
+ icon: markRaw(DocumentCopy),
3883
+ display: () => !isRoot.value,
3884
+ handler: () => {
3885
+ node.value && services?.editorService.copy(node.value);
3886
+ }
3887
+ },
3888
+ {
3889
+ type: "button",
3890
+ text: "\u5220\u9664",
3891
+ icon: markRaw(Delete),
3892
+ display: () => !isRoot.value && !isPage.value,
3893
+ handler: () => {
3894
+ node.value && services?.editorService.remove(node.value);
3895
+ }
3896
+ },
3897
+ ...layerContentMenu
3898
+ ]);
3899
+ const show = (e) => {
3900
+ menu.value?.show(e);
3901
+ };
3902
+ expose({
3903
+ show
3904
+ });
3905
+ return (_ctx, _cache) => {
3906
+ return openBlock(), createBlock(_sfc_main$c, {
3907
+ "menu-data": unref(menuData),
3908
+ ref_key: "menu",
3909
+ ref: menu,
3910
+ style: { "overflow": "initial" }
3911
+ }, null, 8, ["menu-data"]);
3959
3912
  };
3960
3913
  }
3961
3914
  });
3962
3915
 
3963
- function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
3964
- const _component_content_menu = resolveComponent("content-menu");
3965
- return openBlock(), createBlock(_component_content_menu, {
3966
- "menu-data": _ctx.menuData,
3967
- ref: "menu",
3968
- style: { "overflow": "initial" }
3969
- }, null, 8, ["menu-data"]);
3970
- }
3971
- const LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["render", _sfc_render$4]]);
3972
-
3973
- const throttleTime = 150;
3974
- const select = async (data, editorService) => {
3975
- if (!data.id) {
3976
- throw new Error("\u6CA1\u6709id");
3977
- }
3978
- await editorService?.select(data);
3979
- editorService?.get("stage")?.select(data.id);
3980
- };
3981
- const highlight = (data, editorService) => {
3982
- if (!data?.id) {
3983
- throw new Error("\u6CA1\u6709id");
3984
- }
3985
- editorService?.highlight(data);
3986
- editorService?.get("stage")?.highlight(data.id);
3987
- };
3988
- const useDrop = (tree, editorService) => ({
3989
- allowDrop: (draggingNode, dropNode, type) => {
3990
- const { data } = dropNode || {};
3991
- const { data: ingData } = draggingNode;
3992
- const { type: ingType } = ingData;
3993
- if (ingType !== NodeType.PAGE && data.type === NodeType.PAGE)
3994
- return false;
3995
- if (ingType === NodeType.PAGE && data.type !== NodeType.PAGE)
3996
- return false;
3997
- if (!data || !data.type)
3916
+ const _hoisted_1$3 = ["id", "onMouseenter"];
3917
+ const _sfc_main$a = /* @__PURE__ */ defineComponent({
3918
+ __name: "LayerPanel",
3919
+ setup(__props) {
3920
+ const throttleTime = 150;
3921
+ const services = inject("services");
3922
+ const tree = ref();
3923
+ const menu = ref();
3924
+ const editorService = services?.editorService;
3925
+ const page = computed(() => editorService?.get("page"));
3926
+ const values = computed(() => page.value ? [page.value] : []);
3927
+ const selectedNodes = ref([]);
3928
+ const selectedIds = computed(() => selectedNodes.value.map((node) => node.id));
3929
+ const isMultiSelectStatus = ref(false);
3930
+ const spliceNodeKey = ref();
3931
+ const filterText = ref("");
3932
+ const defaultExpandedKeys = computed(() => selectedIds.value.length > 0 ? selectedIds.value : []);
3933
+ editorService?.on("remove", () => {
3934
+ setTimeout(() => {
3935
+ tree.value?.getNode(editorService.get("node").id)?.updateChildren();
3936
+ }, 0);
3937
+ });
3938
+ const select = async (data) => {
3939
+ if (!data.id) {
3940
+ throw new Error("\u6CA1\u6709id");
3941
+ }
3942
+ await editorService?.select(data);
3943
+ editorService?.get("stage")?.select(data.id);
3944
+ };
3945
+ const multiSelect = async (data) => {
3946
+ await editorService?.multiSelect(data);
3947
+ editorService?.get("stage")?.multiSelect(data);
3948
+ };
3949
+ const highlight = (data) => {
3950
+ if (!data?.id) {
3951
+ throw new Error("\u6CA1\u6709id");
3952
+ }
3953
+ editorService?.highlight(data);
3954
+ editorService?.get("stage")?.highlight(data.id);
3955
+ };
3956
+ const expandedKeys = /* @__PURE__ */ new Map();
3957
+ const allowDrop = (draggingNode, dropNode, type) => {
3958
+ const { data } = dropNode || {};
3959
+ const { data: ingData } = draggingNode;
3960
+ const { type: ingType } = ingData;
3961
+ if (ingType !== NodeType.PAGE && data.type === NodeType.PAGE)
3962
+ return false;
3963
+ if (ingType === NodeType.PAGE && data.type !== NodeType.PAGE)
3964
+ return false;
3965
+ if (!data || !data.type)
3966
+ return false;
3967
+ if (["prev", "next"].includes(type))
3968
+ return true;
3969
+ if (data.items || data.type === "container")
3970
+ return true;
3998
3971
  return false;
3999
- if (["prev", "next"].includes(type))
4000
- return true;
4001
- if (data.items || data.type === "container")
4002
- return true;
4003
- return false;
4004
- },
4005
- async handleDragEnd(e) {
4006
- if (!tree.value)
4007
- return;
4008
- const { data: node } = e;
4009
- const parent = editorService?.getParentById(node.id, false);
4010
- const layout = await editorService?.getLayout(parent);
4011
- node.style.position = layout;
4012
- if (layout === Layout.RELATIVE) {
4013
- node.style.top = 0;
4014
- node.style.left = 0;
4015
- }
4016
- const { data } = tree.value;
4017
- const [page] = data;
4018
- editorService?.update(page);
4019
- }
4020
- });
4021
- const useStatus = (tree, editorService) => {
4022
- const node = ref();
4023
- const page = computed(() => editorService?.get("page"));
4024
- const expandedKeys = /* @__PURE__ */ new Map();
4025
- const expandNodes = () => {
4026
- expandedKeys.forEach((key) => {
3972
+ };
3973
+ const handleDragEnd = async (e) => {
4027
3974
  if (!tree.value)
4028
3975
  return;
4029
- tree.value.getNode(key)?.expand();
4030
- });
4031
- };
4032
- watchEffect(() => {
4033
- if (!tree.value)
4034
- return;
4035
- if (!editorService)
4036
- return;
4037
- node.value = editorService.get("node");
4038
- if (!node.value)
4039
- return;
4040
- tree.value.setCurrentKey(node.value.id, true);
4041
- const parent = editorService.get("parent");
4042
- if (!parent?.id)
4043
- return;
4044
- const treeNode = tree.value.getNode(parent.id);
4045
- treeNode?.updateChildren();
4046
- setTimeout(() => {
4047
- tree.value && Object.entries(tree.value.store.nodesMap).forEach(([id, node2]) => {
4048
- if (node2.expanded && node2.data.items) {
4049
- expandedKeys.set(id, id);
4050
- }
4051
- });
4052
- expandNodes();
4053
- });
4054
- });
4055
- return {
4056
- values: computed(() => page.value ? [page.value] : []),
4057
- loadItems: (node2, resolve) => {
4058
- if (Array.isArray(node2.data)) {
4059
- return resolve(node2.data);
3976
+ const { data: node } = e;
3977
+ const parent = editorService?.getParentById(node.id, false);
3978
+ const layout = await editorService?.getLayout(parent);
3979
+ node.style.position = layout;
3980
+ if (layout === Layout.RELATIVE) {
3981
+ node.style.top = 0;
3982
+ node.style.left = 0;
3983
+ }
3984
+ const data = tree.value.getData();
3985
+ const [page2] = data;
3986
+ editorService?.update(page2);
3987
+ };
3988
+ const loadItems = (node, resolve) => {
3989
+ if (Array.isArray(node.data)) {
3990
+ return resolve(node.data);
4060
3991
  }
4061
- if (Array.isArray(node2.data?.items)) {
4062
- return resolve(node2.data?.items);
3992
+ if (Array.isArray(node.data?.items)) {
3993
+ return resolve(node.data?.items);
4063
3994
  }
4064
3995
  resolve([]);
4065
- },
4066
- highlightNode: computed(() => editorService?.get("highlightNode")),
4067
- clickNode: node,
4068
- expandedKeys: computed(() => node.value ? [node.value.id] : []),
4069
- handleCollapse: (data) => {
3996
+ };
3997
+ const handleCollapse = (data) => {
4070
3998
  expandedKeys.delete(data.id);
4071
- },
4072
- handleExpand: (data) => {
3999
+ };
4000
+ const handleExpand = (data) => {
4073
4001
  const parent = editorService?.getParentById(data.id);
4074
4002
  if (!parent?.id)
4075
4003
  return;
4076
4004
  expandedKeys.set(parent.id, parent.id);
4077
- }
4078
- };
4079
- };
4080
- const useFilter = (tree) => ({
4081
- filterText: ref(""),
4082
- filterNode: (value, data) => {
4083
- if (!value) {
4084
- return true;
4085
- }
4086
- let name = "";
4087
- if (data.name) {
4088
- name = data.name;
4089
- } else if (data.items) {
4090
- name = "container";
4091
- }
4092
- return `${data.id}${name}${data.type}`.indexOf(value) !== -1;
4093
- },
4094
- filterTextChangeHandler(val) {
4095
- tree.value?.filter(val);
4096
- }
4097
- });
4098
- const _sfc_main$a = defineComponent({
4099
- name: "magic-editor-layer-panel",
4100
- components: { LayerMenu },
4101
- setup() {
4102
- const services = inject("services");
4103
- const tree = ref();
4104
- const menu = ref();
4005
+ };
4006
+ const filterNode = (value, data) => {
4007
+ if (!value) {
4008
+ return true;
4009
+ }
4010
+ let name = "";
4011
+ if (data.name) {
4012
+ name = data.name;
4013
+ } else if (data.items) {
4014
+ name = "container";
4015
+ }
4016
+ return `${data.id}${name}${data.type}`.indexOf(value) !== -1;
4017
+ };
4018
+ const filterTextChangeHandler = (val) => {
4019
+ tree.value?.filter(val);
4020
+ };
4021
+ const expandNodes = () => {
4022
+ expandedKeys.forEach((key) => {
4023
+ if (!tree.value)
4024
+ return;
4025
+ tree.value.getNode(key)?.expand();
4026
+ });
4027
+ };
4028
+ watch(
4029
+ () => editorService?.get("nodes"),
4030
+ (nodes) => {
4031
+ if (!tree.value)
4032
+ return;
4033
+ if (!editorService)
4034
+ return;
4035
+ if (!nodes)
4036
+ return;
4037
+ selectedNodes.value = nodes;
4038
+ const parent = editorService.get("parent");
4039
+ if (!parent?.id)
4040
+ return;
4041
+ const treeNode = tree.value.getNode(parent.id);
4042
+ treeNode?.updateChildren();
4043
+ setTimeout(() => {
4044
+ tree.value && Object.entries(tree.value.getStore().nodesMap).forEach(([id, node]) => {
4045
+ if (node.expanded && node.data.items) {
4046
+ expandedKeys.set(id, id);
4047
+ }
4048
+ });
4049
+ expandNodes();
4050
+ });
4051
+ }
4052
+ );
4053
+ const setTreeKeyStatus = () => {
4054
+ if (!tree.value)
4055
+ return;
4056
+ if (selectedIds.value.length === 0) {
4057
+ tree.value.setCheckedKeys([]);
4058
+ tree.value.setCurrentKey();
4059
+ } else if (selectedIds.value.length === 1 && !isMultiSelectStatus.value) {
4060
+ tree.value.setCurrentKey(selectedIds.value[0], true);
4061
+ tree.value.setCheckedKeys([]);
4062
+ } else {
4063
+ tree.value.setCheckedKeys(selectedIds.value);
4064
+ tree.value.setCurrentKey();
4065
+ }
4066
+ };
4067
+ watch(selectedIds, () => {
4068
+ setTreeKeyStatus();
4069
+ });
4070
+ const keycon = ref();
4071
+ const addSelectModeListener = () => {
4072
+ const isMac = /mac os x/.test(navigator.userAgent.toLowerCase());
4073
+ const ctrl = isMac ? "meta" : "ctrl";
4074
+ keycon.value = new KeyController();
4075
+ keycon.value.keydown(ctrl, (e) => {
4076
+ e.inputEvent.preventDefault();
4077
+ isMultiSelectStatus.value = true;
4078
+ });
4079
+ keycon.value.on("blur", () => {
4080
+ isMultiSelectStatus.value = false;
4081
+ });
4082
+ keycon.value.keyup(ctrl, (e) => {
4083
+ e.inputEvent.preventDefault();
4084
+ isMultiSelectStatus.value = false;
4085
+ });
4086
+ };
4087
+ const removeSelectModeListener = () => {
4088
+ keycon.value?.destroy();
4089
+ if (selectedIds.value.length === 1)
4090
+ isMultiSelectStatus.value = false;
4091
+ };
4105
4092
  const clicked = ref(false);
4106
- const editorService = services?.editorService;
4093
+ const highlightNode = computed(() => editorService?.get("highlightNode"));
4107
4094
  const highlightHandler = throttle((data) => {
4108
- highlight(data, editorService);
4095
+ highlight(data);
4109
4096
  }, throttleTime);
4110
4097
  const toggleClickFlag = () => {
4111
4098
  clicked.value = !clicked.value;
4112
4099
  };
4113
- const statusData = useStatus(tree, editorService);
4114
- const canHighlight = computed(
4115
- () => statusData.highlightNode.value?.id !== statusData.clickNode.value?.id && !clicked.value
4116
- );
4117
- editorService?.on("remove", () => {
4118
- setTimeout(() => {
4119
- tree.value?.getNode(editorService.get("node").id)?.updateChildren();
4120
- }, 0);
4100
+ const canHighlight = (data) => {
4101
+ if (clicked.value)
4102
+ return false;
4103
+ return data.id === highlightNode?.value?.id && !selectedIds.value.includes(data.id) && spliceNodeKey.value !== data.id;
4104
+ };
4105
+ watch(isMultiSelectStatus, () => {
4106
+ if (isMultiSelectStatus.value && selectedNodes.value.length === 1 && selectedNodes.value[0].type === NodeType.PAGE) {
4107
+ selectedNodes.value = [];
4108
+ }
4121
4109
  });
4122
- return {
4123
- tree,
4124
- menu,
4125
- ...statusData,
4126
- ...useDrop(tree, editorService),
4127
- ...useFilter(tree),
4128
- highlightHandler,
4129
- toggleClickFlag,
4130
- canHighlight,
4131
- clickHandler(data) {
4110
+ const multiClickHandler = (data) => {
4111
+ if (!data?.id) {
4112
+ throw new Error("\u6CA1\u6709id");
4113
+ }
4114
+ if (data.type === NodeType.PAGE) {
4115
+ tree.value?.setCheckedKeys([]);
4116
+ return;
4117
+ }
4118
+ const index = selectedNodes.value.findIndex((node) => node.id === data.id);
4119
+ if (index !== -1) {
4120
+ selectedNodes.value.splice(index, 1);
4121
+ spliceNodeKey.value = data.id;
4122
+ } else {
4123
+ selectedNodes.value = [...selectedNodes.value, data];
4124
+ }
4125
+ tree.value?.setCheckedKeys(selectedIds.value);
4126
+ multiSelect(selectedIds.value);
4127
+ };
4128
+ const clickHandler = (data) => {
4129
+ if (!isMultiSelectStatus.value) {
4132
4130
  if (services?.uiService.get("uiSelectMode")) {
4133
4131
  document.dispatchEvent(new CustomEvent("ui-select", { detail: data }));
4134
4132
  return;
4135
4133
  }
4136
4134
  tree.value?.setCurrentKey(data.id);
4137
- select(data, editorService);
4138
- },
4139
- async contextmenu(event, data) {
4140
- event.preventDefault();
4141
- await select(data, editorService);
4142
- menu.value?.show(event);
4135
+ select(data);
4136
+ } else {
4137
+ multiClickHandler(data);
4143
4138
  }
4144
4139
  };
4145
- }
4146
- });
4147
-
4148
- const _hoisted_1$3 = ["id", "onMouseenter"];
4149
- function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
4150
- const _component_el_input = resolveComponent("el-input");
4151
- const _component_el_tree = resolveComponent("el-tree");
4152
- const _component_layer_menu = resolveComponent("layer-menu");
4153
- const _component_el_scrollbar = resolveComponent("el-scrollbar");
4154
- return openBlock(), createBlock(_component_el_scrollbar, { class: "magic-editor-layer-panel" }, {
4155
- default: withCtx(() => [
4156
- renderSlot(_ctx.$slots, "layer-panel-header"),
4157
- createVNode(_component_el_input, {
4158
- class: "filterInput",
4159
- size: "small",
4160
- placeholder: "\u8F93\u5165\u5173\u952E\u5B57\u8FDB\u884C\u8FC7\u6EE4",
4161
- clearable: "",
4162
- modelValue: _ctx.filterText,
4163
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.filterText = $event),
4164
- onChange: _ctx.filterTextChangeHandler
4165
- }, null, 8, ["modelValue", "onChange"]),
4166
- _ctx.values.length ? (openBlock(), createBlock(_component_el_tree, {
4167
- key: 0,
4168
- ref: "tree",
4169
- "node-key": "id",
4170
- "empty-text": "\u9875\u9762\u7A7A\u8361\u8361\u7684",
4171
- draggable: "",
4172
- "default-expanded-keys": _ctx.expandedKeys,
4173
- load: _ctx.loadItems,
4174
- data: _ctx.values,
4175
- "expand-on-click-node": false,
4176
- "highlight-current": true,
4177
- props: {
4178
- children: "items"
4179
- },
4180
- "filter-node-method": _ctx.filterNode,
4181
- "allow-drop": _ctx.allowDrop,
4182
- onNodeClick: _ctx.clickHandler,
4183
- onNodeContextmenu: _ctx.contextmenu,
4184
- onNodeDragEnd: _ctx.handleDragEnd,
4185
- onNodeCollapse: _ctx.handleCollapse,
4186
- onNodeExpand: _ctx.handleExpand
4140
+ const contextmenu = async (event, data) => {
4141
+ event.preventDefault();
4142
+ await select(data);
4143
+ menu.value?.show(event);
4144
+ };
4145
+ return (_ctx, _cache) => {
4146
+ return openBlock(), createBlock(unref(TMagicScrollbar), {
4147
+ class: "magic-editor-layer-panel",
4148
+ onMouseenter: addSelectModeListener,
4149
+ onMouseleave: removeSelectModeListener
4187
4150
  }, {
4188
- default: withCtx(({ node, data }) => [
4189
- createElementVNode("div", {
4190
- id: data.id,
4191
- class: normalizeClass(["cus-tree-node", { "cus-tree-node-hover": _ctx.canHighlight && data.id === _ctx.highlightNode?.id }]),
4192
- onMousedown: _cache[1] || (_cache[1] = (...args) => _ctx.toggleClickFlag && _ctx.toggleClickFlag(...args)),
4193
- onMouseup: _cache[2] || (_cache[2] = (...args) => _ctx.toggleClickFlag && _ctx.toggleClickFlag(...args)),
4194
- onMouseenter: ($event) => _ctx.highlightHandler(data)
4195
- }, [
4196
- renderSlot(_ctx.$slots, "layer-node-content", {
4197
- node,
4198
- data
4199
- }, () => [
4200
- createElementVNode("span", null, toDisplayString(`${data.name} (${data.id})`), 1)
4201
- ])
4202
- ], 42, _hoisted_1$3)
4151
+ default: withCtx(() => [
4152
+ renderSlot(_ctx.$slots, "layer-panel-header"),
4153
+ createVNode(unref(TMagicInput), {
4154
+ class: "filterInput",
4155
+ size: "small",
4156
+ placeholder: "\u8F93\u5165\u5173\u952E\u5B57\u8FDB\u884C\u8FC7\u6EE4",
4157
+ clearable: "",
4158
+ modelValue: filterText.value,
4159
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => filterText.value = $event),
4160
+ onChange: filterTextChangeHandler
4161
+ }, null, 8, ["modelValue"]),
4162
+ unref(values).length ? (openBlock(), createBlock(unref(TMagicTree), {
4163
+ key: 0,
4164
+ ref_key: "tree",
4165
+ ref: tree,
4166
+ "node-key": "id",
4167
+ "empty-text": "\u9875\u9762\u7A7A\u8361\u8361\u7684",
4168
+ draggable: "",
4169
+ "default-expanded-keys": unref(defaultExpandedKeys),
4170
+ load: loadItems,
4171
+ data: unref(values),
4172
+ "expand-on-click-node": false,
4173
+ "highlight-current": true,
4174
+ props: {
4175
+ children: "items"
4176
+ },
4177
+ "filter-node-method": filterNode,
4178
+ "allow-drop": allowDrop,
4179
+ "show-checkbox": isMultiSelectStatus.value || unref(selectedIds).length > 1,
4180
+ onNodeClick: clickHandler,
4181
+ onNodeContextmenu: contextmenu,
4182
+ onNodeDragEnd: handleDragEnd,
4183
+ onNodeCollapse: handleCollapse,
4184
+ onNodeExpand: handleExpand,
4185
+ onCheck: multiClickHandler,
4186
+ onMousedown: toggleClickFlag,
4187
+ onMouseup: toggleClickFlag
4188
+ }, {
4189
+ default: withCtx(({ node, data }) => [
4190
+ createElementVNode("div", {
4191
+ id: data.id,
4192
+ class: normalizeClass(["cus-tree-node", { "cus-tree-node-hover": canHighlight(data) }]),
4193
+ onMouseenter: ($event) => unref(highlightHandler)(data)
4194
+ }, [
4195
+ renderSlot(_ctx.$slots, "layer-node-content", {
4196
+ node,
4197
+ data
4198
+ }, () => [
4199
+ createElementVNode("span", null, toDisplayString(`${data.name} (${data.id})`), 1)
4200
+ ])
4201
+ ], 42, _hoisted_1$3)
4202
+ ]),
4203
+ _: 3
4204
+ }, 8, ["default-expanded-keys", "data", "show-checkbox"])) : createCommentVNode("", true),
4205
+ (openBlock(), createBlock(Teleport, { to: "body" }, [
4206
+ createVNode(_sfc_main$b, {
4207
+ ref_key: "menu",
4208
+ ref: menu
4209
+ }, null, 512)
4210
+ ]))
4203
4211
  ]),
4204
4212
  _: 3
4205
- }, 8, ["default-expanded-keys", "load", "data", "filter-node-method", "allow-drop", "onNodeClick", "onNodeContextmenu", "onNodeDragEnd", "onNodeCollapse", "onNodeExpand"])) : createCommentVNode("", true),
4206
- (openBlock(), createBlock(Teleport, { to: "body" }, [
4207
- createVNode(_component_layer_menu, { ref: "menu" }, null, 512)
4208
- ]))
4209
- ]),
4210
- _: 3
4211
- });
4212
- }
4213
- const LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$3]]);
4214
-
4215
- const _sfc_main$9 = defineComponent({
4216
- components: { MIcon: _sfc_main$j },
4217
- props: {
4218
- data: {
4219
- type: [Object, String]
4220
- }
4221
- },
4222
- setup(props) {
4223
- return {
4224
- config: computed(() => {
4225
- if (typeof props.data !== "string") {
4226
- return props.data;
4227
- }
4228
- switch (props.data) {
4229
- case "component-list":
4230
- return {
4231
- type: "component",
4232
- icon: Coin,
4233
- text: "\u7EC4\u4EF6",
4234
- component: _sfc_main$d,
4235
- slots: {}
4236
- };
4237
- case "layer":
4238
- return {
4239
- type: "component",
4240
- icon: Files,
4241
- text: "\u5DF2\u9009\u7EC4\u4EF6",
4242
- component: LayerPanel,
4243
- slots: {}
4244
- };
4245
- case "code-block":
4246
- return {
4247
- type: "component",
4248
- icon: EditPen,
4249
- text: "\u4EE3\u7801\u7F16\u8F91",
4250
- component: _sfc_main$e,
4251
- slots: {}
4252
- };
4253
- default:
4254
- return void 0;
4255
- }
4256
- })
4213
+ });
4257
4214
  };
4258
4215
  }
4259
4216
  });
@@ -4262,188 +4219,224 @@ const _hoisted_1$2 = {
4262
4219
  key: 1,
4263
4220
  class: "magic-editor-tab-panel-title"
4264
4221
  };
4265
- function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
4266
- const _component_m_icon = resolveComponent("m-icon");
4267
- const _component_el_tab_pane = resolveComponent("el-tab-pane");
4268
- return _ctx.config ? (openBlock(), createBlock(_component_el_tab_pane, {
4269
- key: 0,
4270
- name: _ctx.config.text
4271
- }, {
4272
- label: withCtx(() => [
4273
- (openBlock(), createElementBlock("div", {
4274
- key: _ctx.config.text
4275
- }, [
4276
- _ctx.config.icon ? (openBlock(), createBlock(_component_m_icon, {
4277
- key: 0,
4278
- icon: _ctx.config.icon
4279
- }, null, 8, ["icon"])) : createCommentVNode("", true),
4280
- _ctx.config.text ? (openBlock(), createElementBlock("div", _hoisted_1$2, toDisplayString(_ctx.config.text), 1)) : createCommentVNode("", true)
4281
- ]))
4282
- ]),
4283
- default: withCtx(() => [
4284
- (openBlock(), createBlock(resolveDynamicComponent(_ctx.config.component), mergeProps(_ctx.config.props || {}, toHandlers(_ctx.config?.listeners || {})), createSlots({ _: 2 }, [
4285
- _ctx.data === "component-list" || _ctx.config.slots?.componentListPanelHeader ? {
4286
- name: "component-list-panel-header",
4287
- fn: withCtx(() => [
4288
- _ctx.data === "component-list" ? renderSlot(_ctx.$slots, "component-list-panel-header", { key: 0 }) : _ctx.config.slots?.componentListPanelHeader ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.config.slots.componentListPanelHeader), { key: 1 })) : createCommentVNode("", true)
4289
- ])
4290
- } : void 0,
4291
- _ctx.data === "component-list" || _ctx.config.slots?.componentListItem ? {
4292
- name: "component-list-item",
4293
- fn: withCtx(({ component }) => [
4294
- _ctx.data === "component-list" ? renderSlot(_ctx.$slots, "component-list-item", {
4295
- key: 0,
4296
- component
4297
- }) : _ctx.config.slots?.componentListItem ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.config.slots.componentListItem), {
4298
- key: 1,
4299
- component
4300
- }, null, 8, ["component"])) : createCommentVNode("", true)
4301
- ])
4302
- } : void 0,
4303
- _ctx.data === "layer" || _ctx.config.slots?.layerPanelHeader ? {
4304
- name: "layer-panel-header",
4305
- fn: withCtx(() => [
4306
- _ctx.data === "layer" ? renderSlot(_ctx.$slots, "layer-panel-header", { key: 0 }) : _ctx.config.slots?.layerPanelHeader ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.config.slots.layerPanelHeader), { key: 1 })) : createCommentVNode("", true)
4307
- ])
4308
- } : void 0,
4309
- _ctx.data === "code-block" || _ctx.config.slots?.codeBlockPanelHeader ? {
4310
- name: "code-block-panel-header",
4311
- fn: withCtx(() => [
4312
- _ctx.data === "code-block" ? renderSlot(_ctx.$slots, "code-block-panel-header", { key: 0 }) : _ctx.config.slots?.codeBlockPanelHeader ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.config.slots.codeBlockPanelHeader), { key: 1 })) : createCommentVNode("", true)
4313
- ])
4314
- } : void 0,
4315
- _ctx.data === "code-block" || _ctx.config.slots?.codeBlockPanelTool ? {
4316
- name: "code-block-panel-tool",
4317
- fn: withCtx(({ id }) => [
4318
- _ctx.data === "code-block" ? renderSlot(_ctx.$slots, "code-block-panel-tool", {
4319
- key: 0,
4320
- id
4321
- }) : _ctx.config.slots?.codeBlockPanelTool ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.config.slots.codeBlockPanelTool), { key: 1 })) : createCommentVNode("", true)
4322
- ])
4323
- } : void 0,
4324
- _ctx.data === "code-block" || _ctx.config.slots?.codeBlockEditPanelHeader ? {
4325
- name: "code-block-edit-panel-header",
4326
- fn: withCtx(({ id }) => [
4327
- _ctx.data === "code-block" ? renderSlot(_ctx.$slots, "code-block-edit-panel-header", {
4328
- key: 0,
4329
- id
4330
- }) : _ctx.config.slots?.codeBlockEditPanelHeader ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.config.slots.codeBlockEditPanelHeader), { key: 1 })) : createCommentVNode("", true)
4331
- ])
4332
- } : void 0,
4333
- _ctx.data === "layer" || _ctx.config.slots?.layerNodeContent ? {
4334
- name: "layer-node-content",
4335
- fn: withCtx(({ data: nodeData, node }) => [
4336
- _ctx.data === "layer" ? renderSlot(_ctx.$slots, "layer-node-content", {
4222
+ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
4223
+ __name: "TabPane",
4224
+ props: {
4225
+ data: null
4226
+ },
4227
+ setup(__props) {
4228
+ const props = __props;
4229
+ const config = computed(() => {
4230
+ if (typeof props.data !== "string") {
4231
+ return props.data;
4232
+ }
4233
+ switch (props.data) {
4234
+ case "component-list":
4235
+ return {
4236
+ type: "component",
4237
+ icon: Coin,
4238
+ text: "\u7EC4\u4EF6",
4239
+ component: _sfc_main$d,
4240
+ slots: {}
4241
+ };
4242
+ case "layer":
4243
+ return {
4244
+ type: "component",
4245
+ icon: Files,
4246
+ text: "\u5DF2\u9009\u7EC4\u4EF6",
4247
+ component: _sfc_main$a,
4248
+ slots: {}
4249
+ };
4250
+ case "code-block":
4251
+ return {
4252
+ type: "component",
4253
+ icon: EditPen,
4254
+ text: "\u4EE3\u7801\u7F16\u8F91",
4255
+ component: _sfc_main$e,
4256
+ slots: {}
4257
+ };
4258
+ default:
4259
+ return void 0;
4260
+ }
4261
+ });
4262
+ return (_ctx, _cache) => {
4263
+ return unref(config) ? (openBlock(), createBlock(unref(TMagicTabPane), {
4264
+ key: 0,
4265
+ name: unref(config).text
4266
+ }, {
4267
+ label: withCtx(() => [
4268
+ (openBlock(), createElementBlock("div", {
4269
+ key: unref(config).text
4270
+ }, [
4271
+ unref(config).icon ? (openBlock(), createBlock(_sfc_main$n, {
4337
4272
  key: 0,
4338
- data: nodeData,
4339
- node
4340
- }) : _ctx.config.slots?.layerNodeContent ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.config.slots.layerNodeContent), {
4341
- key: 1,
4342
- data: nodeData,
4343
- node
4344
- }, null, 8, ["data", "node"])) : createCommentVNode("", true)
4345
- ])
4346
- } : void 0
4347
- ]), 1040))
4348
- ]),
4349
- _: 3
4350
- }, 8, ["name"])) : createCommentVNode("", true);
4351
- }
4352
- const TabPane = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$2]]);
4273
+ icon: unref(config).icon
4274
+ }, null, 8, ["icon"])) : createCommentVNode("", true),
4275
+ unref(config).text ? (openBlock(), createElementBlock("div", _hoisted_1$2, toDisplayString(unref(config).text), 1)) : createCommentVNode("", true)
4276
+ ]))
4277
+ ]),
4278
+ default: withCtx(() => [
4279
+ (openBlock(), createBlock(resolveDynamicComponent(unref(config).component), mergeProps(unref(config).props || {}, toHandlers(unref(config)?.listeners || {})), createSlots({ _: 2 }, [
4280
+ __props.data === "component-list" || unref(config).slots?.componentListPanelHeader ? {
4281
+ name: "component-list-panel-header",
4282
+ fn: withCtx(() => [
4283
+ __props.data === "component-list" ? renderSlot(_ctx.$slots, "component-list-panel-header", { key: 0 }) : unref(config).slots?.componentListPanelHeader ? (openBlock(), createBlock(resolveDynamicComponent(unref(config).slots.componentListPanelHeader), { key: 1 })) : createCommentVNode("", true)
4284
+ ])
4285
+ } : void 0,
4286
+ __props.data === "component-list" || unref(config).slots?.componentListItem ? {
4287
+ name: "component-list-item",
4288
+ fn: withCtx(({ component }) => [
4289
+ __props.data === "component-list" ? renderSlot(_ctx.$slots, "component-list-item", {
4290
+ key: 0,
4291
+ component
4292
+ }) : unref(config).slots?.componentListItem ? (openBlock(), createBlock(resolveDynamicComponent(unref(config).slots.componentListItem), {
4293
+ key: 1,
4294
+ component
4295
+ }, null, 8, ["component"])) : createCommentVNode("", true)
4296
+ ])
4297
+ } : void 0,
4298
+ __props.data === "layer" || unref(config).slots?.layerPanelHeader ? {
4299
+ name: "layer-panel-header",
4300
+ fn: withCtx(() => [
4301
+ __props.data === "layer" ? renderSlot(_ctx.$slots, "layer-panel-header", { key: 0 }) : unref(config).slots?.layerPanelHeader ? (openBlock(), createBlock(resolveDynamicComponent(unref(config).slots.layerPanelHeader), { key: 1 })) : createCommentVNode("", true)
4302
+ ])
4303
+ } : void 0,
4304
+ __props.data === "code-block" || unref(config).slots?.codeBlockPanelHeader ? {
4305
+ name: "code-block-panel-header",
4306
+ fn: withCtx(() => [
4307
+ __props.data === "code-block" ? renderSlot(_ctx.$slots, "code-block-panel-header", { key: 0 }) : unref(config).slots?.codeBlockPanelHeader ? (openBlock(), createBlock(resolveDynamicComponent(unref(config).slots.codeBlockPanelHeader), { key: 1 })) : createCommentVNode("", true)
4308
+ ])
4309
+ } : void 0,
4310
+ __props.data === "code-block" || unref(config).slots?.codeBlockPanelTool ? {
4311
+ name: "code-block-panel-tool",
4312
+ fn: withCtx(({ id, data }) => [
4313
+ data === "code-block" ? renderSlot(_ctx.$slots, "code-block-panel-tool", {
4314
+ key: 0,
4315
+ id,
4316
+ data
4317
+ }) : unref(config).slots?.codeBlockPanelTool ? (openBlock(), createBlock(resolveDynamicComponent(unref(config).slots.codeBlockPanelTool), { key: 1 })) : createCommentVNode("", true)
4318
+ ])
4319
+ } : void 0,
4320
+ __props.data === "code-block" || unref(config).slots?.codeBlockEditPanelHeader ? {
4321
+ name: "code-block-edit-panel-header",
4322
+ fn: withCtx(({ id }) => [
4323
+ __props.data === "code-block" ? renderSlot(_ctx.$slots, "code-block-edit-panel-header", {
4324
+ key: 0,
4325
+ id
4326
+ }) : unref(config).slots?.codeBlockEditPanelHeader ? (openBlock(), createBlock(resolveDynamicComponent(unref(config).slots.codeBlockEditPanelHeader), { key: 1 })) : createCommentVNode("", true)
4327
+ ])
4328
+ } : void 0,
4329
+ __props.data === "layer" || unref(config).slots?.layerNodeContent ? {
4330
+ name: "layer-node-content",
4331
+ fn: withCtx(({ data: nodeData, node }) => [
4332
+ __props.data === "layer" ? renderSlot(_ctx.$slots, "layer-node-content", {
4333
+ key: 0,
4334
+ data: nodeData,
4335
+ node
4336
+ }) : unref(config).slots?.layerNodeContent ? (openBlock(), createBlock(resolveDynamicComponent(unref(config).slots.layerNodeContent), {
4337
+ key: 1,
4338
+ data: nodeData,
4339
+ node
4340
+ }, null, 8, ["data", "node"])) : createCommentVNode("", true)
4341
+ ])
4342
+ } : void 0
4343
+ ]), 1040))
4344
+ ]),
4345
+ _: 3
4346
+ }, 8, ["name"])) : createCommentVNode("", true);
4347
+ };
4348
+ }
4349
+ });
4353
4350
 
4354
- const _sfc_main$8 = defineComponent({
4355
- components: { TabPane },
4356
- name: "m-sidebar",
4351
+ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
4352
+ __name: "Sidebar",
4357
4353
  props: {
4358
- data: {
4359
- type: Object,
4360
- default: () => ({ type: "tabs", status: "\u7EC4\u4EF6", items: ["component-list", "layer", "code-block"] })
4361
- }
4354
+ data: { default: () => ({ type: "tabs", status: "\u7EC4\u4EF6", items: ["component-list", "layer", "code-block"] }) }
4362
4355
  },
4363
- setup(props) {
4356
+ setup(__props, { expose }) {
4357
+ const props = __props;
4364
4358
  const activeTabName = ref(props.data?.status);
4365
4359
  watch(
4366
- () => props.data?.status,
4360
+ () => props.data.status,
4367
4361
  (status) => {
4368
4362
  activeTabName.value = status || "0";
4369
4363
  }
4370
4364
  );
4371
- return {
4365
+ expose({
4372
4366
  activeTabName
4367
+ });
4368
+ return (_ctx, _cache) => {
4369
+ return __props.data.type === "tabs" && __props.data.items.length ? (openBlock(), createBlock(unref(TMagicTabs), {
4370
+ key: 0,
4371
+ class: "m-editor-sidebar",
4372
+ modelValue: activeTabName.value,
4373
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => activeTabName.value = $event),
4374
+ type: "card",
4375
+ "tab-position": "left"
4376
+ }, {
4377
+ default: withCtx(() => [
4378
+ (openBlock(true), createElementBlock(Fragment, null, renderList(__props.data.items, (item, index) => {
4379
+ return openBlock(), createBlock(_sfc_main$9, {
4380
+ key: index,
4381
+ data: item
4382
+ }, createSlots({ _: 2 }, [
4383
+ item === "layer" ? {
4384
+ name: "layer-panel-header",
4385
+ fn: withCtx(() => [
4386
+ renderSlot(_ctx.$slots, "layer-panel-header")
4387
+ ])
4388
+ } : void 0,
4389
+ item === "layer" ? {
4390
+ name: "layer-node-content",
4391
+ fn: withCtx(({ node, data }) => [
4392
+ renderSlot(_ctx.$slots, "layer-node-content", {
4393
+ data,
4394
+ node
4395
+ })
4396
+ ])
4397
+ } : void 0,
4398
+ item === "component-list" ? {
4399
+ name: "component-list-panel-header",
4400
+ fn: withCtx(() => [
4401
+ renderSlot(_ctx.$slots, "component-list-panel-header")
4402
+ ])
4403
+ } : void 0,
4404
+ item === "component-list" ? {
4405
+ name: "component-list-item",
4406
+ fn: withCtx(({ component }) => [
4407
+ renderSlot(_ctx.$slots, "component-list-item", { component })
4408
+ ])
4409
+ } : void 0,
4410
+ item === "code-block" ? {
4411
+ name: "code-block-panel-header",
4412
+ fn: withCtx(() => [
4413
+ renderSlot(_ctx.$slots, "code-block-panel-header")
4414
+ ])
4415
+ } : void 0,
4416
+ item === "code-block" ? {
4417
+ name: "code-block-panel-tool",
4418
+ fn: withCtx(({ id, data }) => [
4419
+ renderSlot(_ctx.$slots, "code-block-panel-tool", {
4420
+ id,
4421
+ data
4422
+ })
4423
+ ])
4424
+ } : void 0,
4425
+ item === "code-block" ? {
4426
+ name: "code-block-edit-panel-header",
4427
+ fn: withCtx(({ id }) => [
4428
+ renderSlot(_ctx.$slots, "code-block-edit-panel-header", { id })
4429
+ ])
4430
+ } : void 0
4431
+ ]), 1032, ["data"]);
4432
+ }), 128))
4433
+ ]),
4434
+ _: 3
4435
+ }, 8, ["modelValue"])) : createCommentVNode("", true);
4373
4436
  };
4374
4437
  }
4375
4438
  });
4376
4439
 
4377
- function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
4378
- const _component_tab_pane = resolveComponent("tab-pane");
4379
- const _component_el_tabs = resolveComponent("el-tabs");
4380
- return _ctx.data.type === "tabs" && _ctx.data.items.length ? (openBlock(), createBlock(_component_el_tabs, {
4381
- key: 0,
4382
- class: "m-editor-sidebar",
4383
- modelValue: _ctx.activeTabName,
4384
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.activeTabName = $event),
4385
- type: "card",
4386
- "tab-position": "left"
4387
- }, {
4388
- default: withCtx(() => [
4389
- (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.data.items, (item, index) => {
4390
- return openBlock(), createBlock(_component_tab_pane, {
4391
- key: index,
4392
- data: item
4393
- }, createSlots({ _: 2 }, [
4394
- item === "layer" ? {
4395
- name: "layer-panel-header",
4396
- fn: withCtx(() => [
4397
- renderSlot(_ctx.$slots, "layer-panel-header")
4398
- ])
4399
- } : void 0,
4400
- item === "layer" ? {
4401
- name: "layer-node-content",
4402
- fn: withCtx(({ node, data }) => [
4403
- renderSlot(_ctx.$slots, "layer-node-content", {
4404
- data,
4405
- node
4406
- })
4407
- ])
4408
- } : void 0,
4409
- item === "component-list" ? {
4410
- name: "component-list-panel-header",
4411
- fn: withCtx(() => [
4412
- renderSlot(_ctx.$slots, "component-list-panel-header")
4413
- ])
4414
- } : void 0,
4415
- item === "component-list" ? {
4416
- name: "component-list-item",
4417
- fn: withCtx(({ component }) => [
4418
- renderSlot(_ctx.$slots, "component-list-item", { component })
4419
- ])
4420
- } : void 0,
4421
- item === "code-block" ? {
4422
- name: "code-block-panel-header",
4423
- fn: withCtx(() => [
4424
- renderSlot(_ctx.$slots, "code-block-panel-header")
4425
- ])
4426
- } : void 0,
4427
- item === "code-block" ? {
4428
- name: "code-block-panel-tool",
4429
- fn: withCtx(({ id }) => [
4430
- renderSlot(_ctx.$slots, "code-block-panel-tool", { id })
4431
- ])
4432
- } : void 0,
4433
- item === "code-block" ? {
4434
- name: "code-block-edit-panel-header",
4435
- fn: withCtx(({ id }) => [
4436
- renderSlot(_ctx.$slots, "code-block-edit-panel-header", { id })
4437
- ])
4438
- } : void 0
4439
- ]), 1032, ["data"]);
4440
- }), 128))
4441
- ]),
4442
- _: 3
4443
- }, 8, ["modelValue"])) : createCommentVNode("", true);
4444
- }
4445
- const Sidebar = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$1]]);
4446
-
4447
4440
  const _hoisted_1$1 = {
4448
4441
  key: 1,
4449
4442
  style: { "width": "21px" }
@@ -4530,14 +4523,14 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
4530
4523
  class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
4531
4524
  onClick: addPage
4532
4525
  }, [
4533
- createVNode(_sfc_main$j, { icon: unref(Plus) }, null, 8, ["icon"])
4526
+ createVNode(_sfc_main$n, { icon: unref(Plus) }, null, 8, ["icon"])
4534
4527
  ])) : (openBlock(), createElementBlock("div", _hoisted_1$1)),
4535
4528
  canScroll.value ? (openBlock(), createElementBlock("div", {
4536
4529
  key: 2,
4537
4530
  class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
4538
4531
  onClick: _cache[0] || (_cache[0] = ($event) => scroll("left"))
4539
4532
  }, [
4540
- createVNode(_sfc_main$j, { icon: unref(ArrowLeftBold) }, null, 8, ["icon"])
4533
+ createVNode(_sfc_main$n, { icon: unref(ArrowLeftBold) }, null, 8, ["icon"])
4541
4534
  ])) : createCommentVNode("", true),
4542
4535
  unref(pageLength) ? (openBlock(), createElementBlock("div", {
4543
4536
  key: 3,
@@ -4553,7 +4546,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
4553
4546
  class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
4554
4547
  onClick: _cache[1] || (_cache[1] = ($event) => scroll("right"))
4555
4548
  }, [
4556
- createVNode(_sfc_main$j, { icon: unref(ArrowRightBold) }, null, 8, ["icon"])
4549
+ createVNode(_sfc_main$n, { icon: unref(ArrowRightBold) }, null, 8, ["icon"])
4557
4550
  ])) : createCommentVNode("", true)
4558
4551
  ], 512);
4559
4552
  };
@@ -4583,9 +4576,6 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
4583
4576
  editorService?.remove(node);
4584
4577
  };
4585
4578
  return (_ctx, _cache) => {
4586
- const _component_el_tooltip = resolveComponent("el-tooltip");
4587
- const _component_el_icon = resolveComponent("el-icon");
4588
- const _component_el_popover = resolveComponent("el-popover");
4589
4579
  return openBlock(), createBlock(_sfc_main$7, null, {
4590
4580
  default: withCtx(() => [
4591
4581
  (openBlock(true), createElementBlock(Fragment, null, renderList(unref(root) && unref(root).items || [], (item) => {
@@ -4596,7 +4586,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
4596
4586
  }, [
4597
4587
  createElementVNode("div", _hoisted_2, [
4598
4588
  renderSlot(_ctx.$slots, "page-bar-title", { page: item }, () => [
4599
- createVNode(_component_el_tooltip, {
4589
+ createVNode(unref(TMagicTooltip), {
4600
4590
  effect: "dark",
4601
4591
  placement: "top-start",
4602
4592
  content: item.name
@@ -4608,14 +4598,14 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
4608
4598
  }, 1032, ["content"])
4609
4599
  ])
4610
4600
  ]),
4611
- createVNode(_component_el_popover, {
4601
+ createVNode(unref(TMagicPopover), {
4612
4602
  "popper-class": "page-bar-popover",
4613
4603
  placement: "top",
4614
4604
  width: 160,
4615
4605
  trigger: "hover"
4616
4606
  }, {
4617
4607
  reference: withCtx(() => [
4618
- createVNode(_component_el_icon, { class: "m-editor-page-bar-menu-icon" }, {
4608
+ createVNode(unref(TMagicIcon), { class: "m-editor-page-bar-menu-icon" }, {
4619
4609
  default: withCtx(() => [
4620
4610
  createVNode(unref(CaretBottom))
4621
4611
  ]),
@@ -5408,10 +5398,10 @@ const _sfc_main = defineComponent({
5408
5398
  name: "m-editor",
5409
5399
  components: {
5410
5400
  NavMenu: _sfc_main$h,
5411
- Sidebar,
5401
+ Sidebar: _sfc_main$8,
5412
5402
  Workspace: _sfc_main$1,
5413
5403
  PropsPanel: _sfc_main$g,
5414
- Framework: _sfc_main$k
5404
+ Framework: _sfc_main$j
5415
5405
  },
5416
5406
  props: {
5417
5407
  modelValue: {
@@ -5605,6 +5595,14 @@ const _sfc_main = defineComponent({
5605
5595
  }
5606
5596
  });
5607
5597
 
5598
+ const _export_sfc = (sfc, props) => {
5599
+ const target = sfc.__vccOpts || sfc;
5600
+ for (const [key, val] of props) {
5601
+ target[key] = val;
5602
+ }
5603
+ return target;
5604
+ };
5605
+
5608
5606
  function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
5609
5607
  const _component_nav_menu = resolveComponent("nav-menu");
5610
5608
  const _component_sidebar = resolveComponent("sidebar");
@@ -5638,8 +5636,11 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
5638
5636
  "code-block-panel-header": withCtx(() => [
5639
5637
  renderSlot(_ctx.$slots, "code-block-panel-header")
5640
5638
  ]),
5641
- "code-block-panel-tool": withCtx(({ id }) => [
5642
- renderSlot(_ctx.$slots, "code-block-panel-tool", { id })
5639
+ "code-block-panel-tool": withCtx(({ id, data }) => [
5640
+ renderSlot(_ctx.$slots, "code-block-panel-tool", {
5641
+ id,
5642
+ data
5643
+ })
5643
5644
  ]),
5644
5645
  "code-block-edit-panel-header": withCtx(({ id }) => [
5645
5646
  renderSlot(_ctx.$slots, "code-block-edit-panel-header", { id })
@@ -5699,10 +5700,10 @@ const index = {
5699
5700
  app.component("m-fields-ui-select", _sfc_main$p);
5700
5701
  app.component("m-fields-code-link", _sfc_main$r);
5701
5702
  app.component("m-fields-vs-code", _sfc_main$s);
5702
- app.component(CodeEditor.name, CodeEditor);
5703
+ app.component("magic-code-editor", _sfc_main$o);
5703
5704
  app.component("m-fields-code-select", _sfc_main$q);
5704
5705
  }
5705
5706
  };
5706
5707
 
5707
- export { COPY_STORAGE_KEY, _sfc_main$e as CodeBlockList, CodeDeleteErrorType, CodeEditorMode, CodeSelectOp, ColumnLayout, _sfc_main$d as ComponentListPanel, _sfc_main$c as ContentMenu, Fixed2Other, H_GUIDE_LINE_STORAGE_KEY, _sfc_main$j as Icon, Keys, LayerOffset, LayerPanel, Layout, _sfc_main$g as PropsPanel, CodeEditor as TMagicCodeEditor, Editor as TMagicEditor, _sfc_main$i as ToolButton, V_GUIDE_LINE_STORAGE_KEY, change2Fixed, codeBlockService, debug, index as default, editorService, error, eventsService, fillConfig, fixNodeLeft, fixNodePosition, generatePageName, generatePageNameByApp, getConfig, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageList, getPageNameList, getRelativeStyle, historyService, info, isFixed, log, propsService, setConfig, setLayout, storageService, uiService, useStage, warn };
5708
+ export { COPY_STORAGE_KEY, _sfc_main$e as CodeBlockList, CodeDeleteErrorType, CodeEditorMode, _sfc_main$q as CodeSelect, CodeSelectOp, ColumnLayout, _sfc_main$d as ComponentListPanel, _sfc_main$c as ContentMenu, Fixed2Other, H_GUIDE_LINE_STORAGE_KEY, _sfc_main$n as Icon, Keys, LayerOffset, _sfc_main$a as LayerPanel, Layout, _sfc_main$g as PropsPanel, _sfc_main$o as TMagicCodeEditor, Editor as TMagicEditor, _sfc_main$i as ToolButton, V_GUIDE_LINE_STORAGE_KEY, change2Fixed, codeBlockService, debug, index as default, editorService, error, eventsService, fillConfig, fixNodeLeft, fixNodePosition, generatePageName, generatePageNameByApp, getConfig, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageList, getPageNameList, getRelativeStyle, historyService, info, isFixed, log, propsService, setConfig, setLayout, storageService, uiService, useStage, warn };
5708
5709
  //# sourceMappingURL=tmagic-editor.mjs.map