@tmagic/editor 1.1.4 → 1.1.6

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.
@@ -30,112 +30,100 @@
30
30
  const Gesto__default = /*#__PURE__*/_interopDefaultLegacy(Gesto);
31
31
  const KeyController__default = /*#__PURE__*/_interopDefaultLegacy(KeyController);
32
32
 
33
- const _sfc_main$o = vue.defineComponent({
34
- name: "m-fields-vs-code",
35
- props: ["model", "name", "config", "prop"],
33
+ const _sfc_main$p = /* @__PURE__ */ vue.defineComponent({
34
+ __name: "Code",
35
+ props: {
36
+ model: null,
37
+ name: null,
38
+ config: null,
39
+ prop: null
40
+ },
36
41
  emits: ["change"],
37
- setup(props, { emit }) {
42
+ setup(__props, { emit }) {
43
+ const props = __props;
38
44
  const language = vue.computed(() => props.config.language || "javascript");
39
45
  const height = vue.computed(() => `${document.body.clientHeight - 168}px`);
40
- return {
41
- height,
42
- language,
43
- save(v) {
44
- props.model[props.name] = v;
45
- emit("change", v);
46
- }
46
+ const save = (v) => {
47
+ props.model[props.name] = v;
48
+ emit("change", v);
49
+ };
50
+ return (_ctx, _cache) => {
51
+ const _component_magic_code_editor = vue.resolveComponent("magic-code-editor");
52
+ return vue.openBlock(), vue.createBlock(_component_magic_code_editor, {
53
+ style: vue.normalizeStyle(`height: ${vue.unref(height)}`),
54
+ "init-values": __props.model[__props.name],
55
+ language: vue.unref(language),
56
+ onSave: save
57
+ }, null, 8, ["style", "init-values", "language"]);
47
58
  };
48
59
  }
49
60
  });
50
61
 
51
- const _export_sfc = (sfc, props) => {
52
- const target = sfc.__vccOpts || sfc;
53
- for (const [key, val] of props) {
54
- target[key] = val;
55
- }
56
- return target;
57
- };
58
-
59
- function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
60
- const _component_magic_code_editor = vue.resolveComponent("magic-code-editor");
61
- return vue.openBlock(), vue.createBlock(_component_magic_code_editor, {
62
- style: vue.normalizeStyle(`height: ${_ctx.height}`),
63
- "init-values": _ctx.model[_ctx.name],
64
- language: _ctx.language,
65
- onSave: _ctx.save
66
- }, null, 8, ["style", "init-values", "language", "onSave"]);
67
- }
68
- const Code = /* @__PURE__ */ _export_sfc(_sfc_main$o, [["render", _sfc_render$a]]);
69
-
70
- const _sfc_main$n = vue.defineComponent({
71
- name: "m-fields-code-link",
62
+ const _sfc_main$o = /* @__PURE__ */ vue.defineComponent({
63
+ __name: "CodeLink",
72
64
  props: {
73
- config: {
74
- type: Object
75
- },
76
- model: {
77
- type: Object
78
- },
79
- name: {
80
- type: String
81
- },
82
- prop: {
83
- type: String
84
- }
65
+ config: null,
66
+ model: null,
67
+ name: null,
68
+ prop: null
85
69
  },
86
70
  emits: ["change"],
87
- setup(props, { emit }) {
88
- const modelValue = vue.ref({
89
- form: {}
71
+ setup(__props, { emit }) {
72
+ const props = __props;
73
+ const formConfig = vue.computed(() => ({
74
+ ...props.config,
75
+ text: "",
76
+ type: "link",
77
+ form: [
78
+ {
79
+ name: props.name,
80
+ type: "vs-code"
81
+ }
82
+ ]
83
+ }));
84
+ const modelValue = vue.reactive({
85
+ form: {
86
+ [props.name]: ""
87
+ }
90
88
  });
91
- vue.watchEffect(() => {
92
- if (!props.model || !props.name)
89
+ vue.watch(
90
+ () => props.model[props.name],
91
+ (value) => {
92
+ modelValue.form = {
93
+ [props.name]: serialize__default.default(value, {
94
+ space: 2,
95
+ unsafe: true
96
+ }).replace(/"(\w+)":\s/g, "$1: ")
97
+ };
98
+ },
99
+ {
100
+ immediate: true
101
+ }
102
+ );
103
+ const changeHandler = (v) => {
104
+ if (!props.name || !props.model)
93
105
  return;
94
- modelValue.value.form[props.name] = serialize__default.default(props.model[props.name], {
95
- space: 2,
96
- unsafe: true
97
- }).replace(/"(\w+)":\s/g, "$1: ");
98
- });
99
- return {
100
- modelValue,
101
- formConfig: vue.computed(() => ({
102
- ...props.config,
103
- text: "",
104
- type: "link",
105
- form: [
106
- {
107
- name: props.name,
108
- type: "vs-code"
109
- }
110
- ]
111
- })),
112
- changeHandler(v) {
113
- if (!props.name || !props.model)
114
- return;
115
- try {
116
- props.model[props.name] = eval(`${v[props.name]}`);
117
- emit("change", props.model[props.name]);
118
- } catch (e) {
119
- console.error(e);
120
- }
106
+ try {
107
+ props.model[props.name] = eval(`(${v[props.name]})`);
108
+ emit("change", props.model[props.name]);
109
+ } catch (e) {
110
+ console.error(e);
121
111
  }
122
112
  };
113
+ return (_ctx, _cache) => {
114
+ const _component_m_fields_link = vue.resolveComponent("m-fields-link");
115
+ return vue.openBlock(), vue.createBlock(_component_m_fields_link, {
116
+ config: vue.unref(formConfig),
117
+ model: modelValue,
118
+ name: "form",
119
+ onChange: changeHandler
120
+ }, null, 8, ["config", "model"]);
121
+ };
123
122
  }
124
123
  });
125
124
 
126
- function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
127
- const _component_m_fields_link = vue.resolveComponent("m-fields-link");
128
- return vue.openBlock(), vue.createBlock(_component_m_fields_link, {
129
- config: _ctx.formConfig,
130
- model: _ctx.modelValue,
131
- name: "form",
132
- onChange: _ctx.changeHandler
133
- }, null, 8, ["config", "model", "onChange"]);
134
- }
135
- const CodeLink = /* @__PURE__ */ _export_sfc(_sfc_main$n, [["render", _sfc_render$9]]);
136
-
137
- const _hoisted_1$c = /* @__PURE__ */ vue.createTextVNode("\u53D6\u6D88");
138
- const _sfc_main$m = /* @__PURE__ */ vue.defineComponent({
125
+ const _hoisted_1$b = /* @__PURE__ */ vue.createTextVNode("\u53D6\u6D88");
126
+ const _sfc_main$n = /* @__PURE__ */ vue.defineComponent({
139
127
  __name: "UISelect",
140
128
  props: {
141
129
  config: null,
@@ -200,7 +188,7 @@
200
188
  style: { "padding": "0" }
201
189
  }, {
202
190
  default: vue.withCtx(() => [
203
- _hoisted_1$c
191
+ _hoisted_1$b
204
192
  ]),
205
193
  _: 1
206
194
  }, 8, ["icon"])
@@ -263,7 +251,7 @@
263
251
  }
264
252
  return value;
265
253
  };
266
- const _sfc_main$l = vue.defineComponent({
254
+ const _sfc_main$m = vue.defineComponent({
267
255
  name: "magic-code-editor",
268
256
  props: {
269
257
  initValues: {
@@ -292,10 +280,12 @@
292
280
  const values = vue.ref("");
293
281
  const loading = vue.ref(false);
294
282
  const codeEditor = vue.ref();
295
- const resizeObserver = new globalThis.ResizeObserver(lodashEs.throttle(() => {
296
- vsEditor?.layout();
297
- vsDiffEditor?.layout();
298
- }, 300));
283
+ const resizeObserver = new globalThis.ResizeObserver(
284
+ lodashEs.throttle(() => {
285
+ vsEditor?.layout();
286
+ vsDiffEditor?.layout();
287
+ }, 300)
288
+ );
299
289
  const setEditorValue = (v, m) => {
300
290
  values.value = toString(v, props.language);
301
291
  if (props.type === "diff") {
@@ -340,14 +330,18 @@
340
330
  }
341
331
  resizeObserver.observe(codeEditor.value);
342
332
  };
343
- vue.watch(() => props.initValues, (v, preV) => {
344
- if (v !== preV) {
345
- setEditorValue(props.initValues, props.modifiedValues);
333
+ vue.watch(
334
+ () => props.initValues,
335
+ (v, preV) => {
336
+ if (v !== preV) {
337
+ setEditorValue(props.initValues, props.modifiedValues);
338
+ }
339
+ },
340
+ {
341
+ deep: true,
342
+ immediate: true
346
343
  }
347
- }, {
348
- deep: true,
349
- immediate: true
350
- });
344
+ );
351
345
  vue.onMounted(async () => {
352
346
  loading.value = true;
353
347
  init();
@@ -371,14 +365,22 @@
371
365
  }
372
366
  });
373
367
 
374
- const _hoisted_1$b = {
368
+ const _export_sfc = (sfc, props) => {
369
+ const target = sfc.__vccOpts || sfc;
370
+ for (const [key, val] of props) {
371
+ target[key] = val;
372
+ }
373
+ return target;
374
+ };
375
+
376
+ const _hoisted_1$a = {
375
377
  ref: "codeEditor",
376
378
  class: "magic-code-editor"
377
379
  };
378
- function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
379
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$b, null, 512);
380
+ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
381
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$a, null, 512);
380
382
  }
381
- const CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$l, [["render", _sfc_render$8]]);
383
+ const CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$m, [["render", _sfc_render$6]]);
382
384
 
383
385
  let $TMAGIC_EDITOR = {};
384
386
  const setConfig = (option) => {
@@ -651,7 +653,9 @@
651
653
  }
652
654
  async getItem(key, options = {}) {
653
655
  const [storage, namespace] = await Promise.all([this.getStorage(), this.getNamespace()]);
654
- const { protocol = options.protocol, item } = this.getValueAndProtocol(storage.getItem(`${options.namespace || namespace}:${key}`));
656
+ const { protocol = options.protocol, item } = this.getValueAndProtocol(
657
+ storage.getItem(`${options.namespace || namespace}:${key}`)
658
+ );
655
659
  if (item === null)
656
660
  return null;
657
661
  switch (protocol) {
@@ -942,10 +946,12 @@
942
946
  const [id, defaultPropsValue, data] = await Promise.all([
943
947
  this.createId(type),
944
948
  this.getDefaultPropsValue(type),
945
- this.setNewItemId(lodashEs.cloneDeep({
946
- type,
947
- ...defaultValue
948
- }))
949
+ this.setNewItemId(
950
+ lodashEs.cloneDeep({
951
+ type,
952
+ ...defaultValue
953
+ })
954
+ )
949
955
  ]);
950
956
  return {
951
957
  id,
@@ -998,37 +1004,39 @@
998
1004
  return config;
999
1005
  const curNode = editorService.get("node");
1000
1006
  const { left: referenceLeft, top: referenceTop } = config[0].style;
1001
- const pasteConfigs = await Promise.all(config.map(async (configItem) => {
1002
- const { offsetX = 0, offsetY = 0, ...positionClone } = position;
1003
- let pastePosition = positionClone;
1004
- if (!lodashEs.isEmpty(pastePosition) && curNode.items) {
1005
- pastePosition = getPositionInContainer(pastePosition, curNode.id);
1006
- }
1007
- if (pastePosition.left && configItem.style?.left) {
1008
- pastePosition.left = configItem.style.left - referenceLeft + pastePosition.left;
1009
- }
1010
- if (pastePosition.top && configItem.style?.top) {
1011
- pastePosition.top = configItem.style?.top - referenceTop + pastePosition.top;
1012
- }
1013
- const pasteConfig = await propsService.setNewItemId(configItem);
1014
- if (pasteConfig.style) {
1015
- const { left, top } = pasteConfig.style;
1016
- if (typeof left === "number" || !!left && !isNaN(Number(left))) {
1017
- pasteConfig.style.left = Number(left) + offsetX;
1007
+ const pasteConfigs = await Promise.all(
1008
+ config.map(async (configItem) => {
1009
+ const { offsetX = 0, offsetY = 0, ...positionClone } = position;
1010
+ let pastePosition = positionClone;
1011
+ if (!lodashEs.isEmpty(pastePosition) && curNode.items) {
1012
+ pastePosition = getPositionInContainer(pastePosition, curNode.id);
1018
1013
  }
1019
- if (typeof top === "number" || !!top && !isNaN(Number(top))) {
1020
- pasteConfig.style.top = Number(top) + offsetY;
1014
+ if (pastePosition.left && configItem.style?.left) {
1015
+ pastePosition.left = configItem.style.left - referenceLeft + pastePosition.left;
1021
1016
  }
1022
- pasteConfig.style = {
1023
- ...pasteConfig.style,
1024
- ...pastePosition
1025
- };
1026
- }
1027
- if (utils.isPage(pasteConfig)) {
1028
- pasteConfig.name = generatePageNameByApp(editorService.get("root"));
1029
- }
1030
- return pasteConfig;
1031
- }));
1017
+ if (pastePosition.top && configItem.style?.top) {
1018
+ pastePosition.top = configItem.style?.top - referenceTop + pastePosition.top;
1019
+ }
1020
+ const pasteConfig = await propsService.setNewItemId(configItem);
1021
+ if (pasteConfig.style) {
1022
+ const { left, top } = pasteConfig.style;
1023
+ if (typeof left === "number" || !!left && !isNaN(Number(left))) {
1024
+ pasteConfig.style.left = Number(left) + offsetX;
1025
+ }
1026
+ if (typeof top === "number" || !!top && !isNaN(Number(top))) {
1027
+ pasteConfig.style.top = Number(top) + offsetY;
1028
+ }
1029
+ pasteConfig.style = {
1030
+ ...pasteConfig.style,
1031
+ ...pastePosition
1032
+ };
1033
+ }
1034
+ if (utils.isPage(pasteConfig)) {
1035
+ pasteConfig.name = generatePageNameByApp(editorService.get("root"));
1036
+ }
1037
+ return pasteConfig;
1038
+ })
1039
+ );
1032
1040
  return pasteConfigs;
1033
1041
  };
1034
1042
  const getPositionInContainer = (position = {}, id) => {
@@ -1069,28 +1077,31 @@
1069
1077
  });
1070
1078
  isHistoryStateChange = false;
1071
1079
  constructor() {
1072
- super([
1073
- "getLayout",
1074
- "select",
1075
- "doAdd",
1076
- "add",
1077
- "doRemove",
1078
- "remove",
1079
- "doUpdate",
1080
- "update",
1081
- "sort",
1082
- "copy",
1083
- "paste",
1084
- "doPaste",
1085
- "duAlignCenter",
1086
- "alignCenter",
1087
- "moveLayer",
1088
- "moveToContainer",
1089
- "move",
1090
- "undo",
1091
- "redo",
1092
- "highlight"
1093
- ], ["select", "update", "moveLayer"]);
1080
+ super(
1081
+ [
1082
+ "getLayout",
1083
+ "select",
1084
+ "doAdd",
1085
+ "add",
1086
+ "doRemove",
1087
+ "remove",
1088
+ "doUpdate",
1089
+ "update",
1090
+ "sort",
1091
+ "copy",
1092
+ "paste",
1093
+ "doPaste",
1094
+ "duAlignCenter",
1095
+ "alignCenter",
1096
+ "moveLayer",
1097
+ "moveToContainer",
1098
+ "move",
1099
+ "undo",
1100
+ "redo",
1101
+ "highlight"
1102
+ ],
1103
+ ["select", "update", "moveLayer"]
1104
+ );
1094
1105
  }
1095
1106
  set(name, value) {
1096
1107
  this.state[name] = value;
@@ -1162,11 +1173,15 @@
1162
1173
  historyService.empty();
1163
1174
  }
1164
1175
  if (node?.id) {
1165
- this.get("stage")?.renderer.runtime?.getApp?.()?.emit("editor:select", {
1166
- node,
1167
- page,
1168
- parent
1169
- }, utils.getNodePath(node.id, this.get("root").items));
1176
+ this.get("stage")?.renderer.runtime?.getApp?.()?.emit(
1177
+ "editor:select",
1178
+ {
1179
+ node,
1180
+ page,
1181
+ parent
1182
+ },
1183
+ utils.getNodePath(node.id, this.get("root").items)
1184
+ );
1170
1185
  }
1171
1186
  this.emit("select", node);
1172
1187
  return node;
@@ -1232,8 +1247,11 @@
1232
1247
  parentId: parent.id,
1233
1248
  root: lodashEs.cloneDeep(root)
1234
1249
  });
1235
- node.style = fixNodePosition(node, parent, stage);
1236
- await stage?.update({ config: lodashEs.cloneDeep(node), parentId: parent.id, root: lodashEs.cloneDeep(root) });
1250
+ const newStyle = fixNodePosition(node, parent, stage);
1251
+ if (newStyle && (newStyle.top !== node.style.top || newStyle.left !== node.style.left)) {
1252
+ node.style = newStyle;
1253
+ await stage?.update({ config: lodashEs.cloneDeep(node), parentId: parent.id, root: lodashEs.cloneDeep(root) });
1254
+ }
1237
1255
  this.addModifiedNodeId(node.id);
1238
1256
  return node;
1239
1257
  }
@@ -1248,12 +1266,14 @@
1248
1266
  } else {
1249
1267
  addNodes.push(...addNode);
1250
1268
  }
1251
- const newNodes = await Promise.all(addNodes.map((node) => {
1252
- const parentNode = parent && typeof parent !== "function" ? parent : getAddParent(node);
1253
- if (!parentNode)
1254
- throw new Error("\u672A\u627E\u5230\u7236\u5143\u7D20");
1255
- return this.doAdd(node, parentNode);
1256
- }));
1269
+ const newNodes = await Promise.all(
1270
+ addNodes.map((node) => {
1271
+ const parentNode = parent && typeof parent !== "function" ? parent : getAddParent(node);
1272
+ if (!parentNode)
1273
+ throw new Error("\u672A\u627E\u5230\u7236\u5143\u7D20");
1274
+ return this.doAdd(node, parentNode);
1275
+ })
1276
+ );
1257
1277
  if (newNodes.length > 1) {
1258
1278
  const newNodeIds = newNodes.map((node) => node.id);
1259
1279
  stage?.multiSelect(newNodeIds);
@@ -1872,16 +1892,6 @@
1872
1892
  }
1873
1893
  };
1874
1894
 
1875
- const DEFAULT_LEFT_COLUMN_WIDTH = 310;
1876
- const MIN_LEFT_COLUMN_WIDTH = 45;
1877
- const DEFAULT_RIGHT_COLUMN_WIDTH = 480;
1878
- const MIN_RIGHT_COLUMN_WIDTH = 1;
1879
- const COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorColumnWidthData";
1880
- const defaultColumnWidth = {
1881
- left: DEFAULT_LEFT_COLUMN_WIDTH,
1882
- center: globalThis.document.body.clientWidth - DEFAULT_LEFT_COLUMN_WIDTH - DEFAULT_RIGHT_COLUMN_WIDTH,
1883
- right: DEFAULT_RIGHT_COLUMN_WIDTH
1884
- };
1885
1895
  const state = vue.reactive({
1886
1896
  uiSelectMode: false,
1887
1897
  showSrc: false,
@@ -1894,7 +1904,11 @@
1894
1904
  width: 375,
1895
1905
  height: 817
1896
1906
  },
1897
- columnWidth: defaultColumnWidth,
1907
+ columnWidth: {
1908
+ left: 0,
1909
+ right: 0,
1910
+ center: 0
1911
+ },
1898
1912
  showGuides: true,
1899
1913
  showRule: true,
1900
1914
  propsPanelSize: "small",
@@ -1902,19 +1916,10 @@
1902
1916
  });
1903
1917
  class Ui extends BaseService {
1904
1918
  constructor() {
1905
- super(["initColumnWidth", "zoom", "calcZoom"]);
1906
- globalThis.addEventListener("resize", () => {
1907
- this.setColumnWidth({
1908
- center: "auto"
1909
- });
1910
- });
1919
+ super(["zoom", "calcZoom"]);
1911
1920
  }
1912
1921
  set(name, value) {
1913
1922
  const mask = editorService.get("stage")?.mask;
1914
- if (name === "columnWidth") {
1915
- this.setColumnWidth(value);
1916
- return;
1917
- }
1918
1923
  if (name === "stageRect") {
1919
1924
  this.setStageRect(value);
1920
1925
  return;
@@ -1930,17 +1935,6 @@
1930
1935
  get(name) {
1931
1936
  return state[name];
1932
1937
  }
1933
- async initColumnWidth() {
1934
- const columnWidthCacheData = globalThis.localStorage.getItem(COLUMN_WIDTH_STORAGE_KEY);
1935
- if (columnWidthCacheData) {
1936
- try {
1937
- const columnWidthCache = JSON.parse(columnWidthCacheData);
1938
- this.setColumnWidth(columnWidthCache);
1939
- } catch (e) {
1940
- console.error(e);
1941
- }
1942
- }
1943
- }
1944
1938
  async zoom(zoom) {
1945
1939
  this.set("zoom", (this.get("zoom") * 100 + zoom * 100) / 100);
1946
1940
  if (this.get("zoom") < 0.1)
@@ -1961,30 +1955,6 @@
1961
1955
  destroy() {
1962
1956
  this.removeAllListeners();
1963
1957
  }
1964
- setColumnWidth({ left, center, right }) {
1965
- const columnWidth = {
1966
- ...vue.toRaw(this.get("columnWidth"))
1967
- };
1968
- if (left) {
1969
- columnWidth.left = Math.max(left, MIN_LEFT_COLUMN_WIDTH);
1970
- }
1971
- if (right) {
1972
- columnWidth.right = Math.max(right, MIN_RIGHT_COLUMN_WIDTH);
1973
- }
1974
- if (!center || center === "auto") {
1975
- const bodyWidth = globalThis.document.body.clientWidth;
1976
- columnWidth.center = bodyWidth - (columnWidth?.left || 0) - (columnWidth?.right || 0);
1977
- if (columnWidth.center <= 0) {
1978
- columnWidth.left = defaultColumnWidth.left;
1979
- columnWidth.center = defaultColumnWidth.center;
1980
- columnWidth.right = defaultColumnWidth.right;
1981
- }
1982
- } else {
1983
- columnWidth.center = center;
1984
- }
1985
- globalThis.localStorage.setItem(COLUMN_WIDTH_STORAGE_KEY, JSON.stringify(columnWidth));
1986
- state.columnWidth = columnWidth;
1987
- }
1988
1958
  async setStageRect(value) {
1989
1959
  state.stageRect = {
1990
1960
  ...state.stageRect,
@@ -2050,7 +2020,9 @@
2050
2020
  uiService.set("showGuides", true);
2051
2021
  if (!root.value || !page.value)
2052
2022
  return;
2053
- const storageKey = getGuideLineKey(e.type === StageCore.GuidesType.HORIZONTAL ? H_GUIDE_LINE_STORAGE_KEY : V_GUIDE_LINE_STORAGE_KEY);
2023
+ const storageKey = getGuideLineKey(
2024
+ e.type === StageCore.GuidesType.HORIZONTAL ? H_GUIDE_LINE_STORAGE_KEY : V_GUIDE_LINE_STORAGE_KEY
2025
+ );
2054
2026
  if (e.guides.length) {
2055
2027
  globalThis.localStorage.setItem(storageKey, JSON.stringify(e.guides));
2056
2028
  } else {
@@ -2060,7 +2032,7 @@
2060
2032
  return stage;
2061
2033
  };
2062
2034
 
2063
- const _sfc_main$k = vue.defineComponent({
2035
+ const _sfc_main$l = vue.defineComponent({
2064
2036
  components: { Plus: iconsVue.Plus },
2065
2037
  setup() {
2066
2038
  const services = vue.inject("services");
@@ -2078,14 +2050,14 @@
2078
2050
  }
2079
2051
  });
2080
2052
 
2081
- const _hoisted_1$a = { class: "m-editor-empty-panel" };
2082
- const _hoisted_2$4 = { class: "m-editor-empty-content" };
2053
+ const _hoisted_1$9 = { class: "m-editor-empty-panel" };
2054
+ const _hoisted_2$3 = { class: "m-editor-empty-content" };
2083
2055
  const _hoisted_3 = /* @__PURE__ */ vue.createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
2084
- function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
2056
+ function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
2085
2057
  const _component_plus = vue.resolveComponent("plus");
2086
2058
  const _component_el_icon = vue.resolveComponent("el-icon");
2087
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$a, [
2088
- vue.createElementVNode("div", _hoisted_2$4, [
2059
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$9, [
2060
+ vue.createElementVNode("div", _hoisted_2$3, [
2089
2061
  vue.createElementVNode("div", {
2090
2062
  class: "m-editor-empty-button",
2091
2063
  onClick: _cache[0] || (_cache[0] = (...args) => _ctx.clickHandler && _ctx.clickHandler(...args))
@@ -2103,17 +2075,12 @@
2103
2075
  ])
2104
2076
  ]);
2105
2077
  }
2106
- const AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["render", _sfc_render$7]]);
2078
+ const AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$l, [["render", _sfc_render$5]]);
2107
2079
 
2108
- const _sfc_main$j = vue.defineComponent({
2109
- name: "m-editor-resize",
2110
- props: {
2111
- type: {
2112
- type: String
2113
- }
2114
- },
2115
- setup(props) {
2116
- const services = vue.inject("services");
2080
+ const _sfc_main$k = /* @__PURE__ */ vue.defineComponent({
2081
+ __name: "Resizer",
2082
+ emits: ["change"],
2083
+ setup(__props, { emit }) {
2117
2084
  const target = vue.ref();
2118
2085
  let getso;
2119
2086
  vue.onMounted(() => {
@@ -2123,124 +2090,220 @@
2123
2090
  container: window,
2124
2091
  pinchOutside: true
2125
2092
  }).on("drag", (e) => {
2126
- if (!target.value || !services)
2093
+ if (!target.value)
2127
2094
  return;
2128
- let { left, right } = {
2129
- ...vue.toRaw(services.uiService.get("columnWidth"))
2130
- };
2131
- if (props.type === "left") {
2132
- left += e.deltaX;
2133
- } else if (props.type === "right") {
2134
- right -= e.deltaX;
2135
- }
2136
- services.uiService.set("columnWidth", {
2137
- left,
2138
- right
2139
- });
2095
+ emit("change", e.deltaX);
2140
2096
  });
2141
2097
  });
2142
2098
  vue.onUnmounted(() => {
2143
2099
  getso?.unset();
2144
2100
  });
2145
- return {
2146
- target
2101
+ return (_ctx, _cache) => {
2102
+ return vue.openBlock(), vue.createElementBlock("span", {
2103
+ ref_key: "target",
2104
+ ref: target,
2105
+ class: "m-editor-resizer"
2106
+ }, [
2107
+ vue.renderSlot(_ctx.$slots, "default")
2108
+ ], 512);
2147
2109
  };
2148
2110
  }
2149
2111
  });
2150
2112
 
2151
- const _hoisted_1$9 = {
2152
- ref: "target",
2153
- class: "m-editor-resizer"
2154
- };
2155
- function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
2156
- return vue.openBlock(), vue.createElementBlock("span", _hoisted_1$9, [
2157
- vue.renderSlot(_ctx.$slots, "default")
2158
- ], 512);
2159
- }
2160
- const Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["render", _sfc_render$6]]);
2161
-
2162
- const _sfc_main$i = vue.defineComponent({
2163
- components: {
2164
- AddPageBox,
2165
- Resizer
2166
- },
2113
+ const _sfc_main$j = /* @__PURE__ */ vue.defineComponent({
2114
+ __name: "Layout",
2167
2115
  props: {
2168
- codeOptions: {
2169
- type: Object,
2170
- default: () => ({})
2171
- }
2116
+ left: null,
2117
+ right: null,
2118
+ minLeft: { default: 1 },
2119
+ minRight: { default: 1 },
2120
+ leftClass: null,
2121
+ rightClass: null,
2122
+ centerClass: null
2172
2123
  },
2173
- setup() {
2174
- const { editorService, uiService } = vue.inject("services") || {};
2175
- const root = vue.computed(() => editorService?.get("root"));
2176
- return {
2177
- root,
2178
- pageLength: vue.computed(() => editorService?.get("pageLength") || 0),
2179
- showSrc: vue.computed(() => uiService?.get("showSrc")),
2180
- columnWidth: vue.computed(() => uiService?.get("columnWidth")),
2181
- saveCode(value) {
2182
- try {
2183
- editorService?.set("root", eval(value));
2184
- } catch (e) {
2185
- console.error(e);
2186
- }
2124
+ emits: ["update:left", "change", "update:right"],
2125
+ setup(__props, { emit }) {
2126
+ const props = __props;
2127
+ const el = vue.ref();
2128
+ let clientWidth = 0;
2129
+ const resizerObserver = new ResizeObserver((entries) => {
2130
+ for (const { contentRect } of entries) {
2131
+ clientWidth = contentRect.width;
2132
+ center.value = clientWidth - (props.left || 0) - (props.right || 0);
2133
+ emit("change", {
2134
+ left: props.left,
2135
+ center: center.value,
2136
+ right: props.right
2137
+ });
2187
2138
  }
2139
+ });
2140
+ vue.onMounted(() => {
2141
+ if (el.value) {
2142
+ resizerObserver.observe(el.value);
2143
+ }
2144
+ });
2145
+ vue.onUnmounted(() => {
2146
+ resizerObserver.disconnect();
2147
+ });
2148
+ const center = vue.ref(0);
2149
+ const changeLeft = (deltaX) => {
2150
+ if (typeof props.left === "undefined")
2151
+ return;
2152
+ const left = Math.max(props.left + deltaX, props.minLeft) || 0;
2153
+ emit("update:left", left);
2154
+ center.value = clientWidth - left - (props.right || 0);
2155
+ emit("change", {
2156
+ left,
2157
+ center: center.value,
2158
+ right: props.right
2159
+ });
2160
+ };
2161
+ const changeRight = (deltaX) => {
2162
+ if (typeof props.right === "undefined")
2163
+ return;
2164
+ const right = Math.max(props.right - deltaX, props.minRight) || 0;
2165
+ emit("update:right", right);
2166
+ center.value = clientWidth - (props.left || 0) - right;
2167
+ emit("change", {
2168
+ left: props.left,
2169
+ center: center.value,
2170
+ right
2171
+ });
2172
+ };
2173
+ return (_ctx, _cache) => {
2174
+ return vue.openBlock(), vue.createElementBlock("div", {
2175
+ ref_key: "el",
2176
+ ref: el
2177
+ }, [
2178
+ typeof props.left !== "undefined" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [
2179
+ vue.createElementVNode("div", {
2180
+ class: vue.normalizeClass(["m-editor-layout-left", __props.leftClass]),
2181
+ style: vue.normalizeStyle(`width: ${__props.left}px`)
2182
+ }, [
2183
+ vue.renderSlot(_ctx.$slots, "left")
2184
+ ], 6),
2185
+ vue.createVNode(_sfc_main$k, { onChange: changeLeft })
2186
+ ], 64)) : vue.createCommentVNode("", true),
2187
+ vue.createElementVNode("div", {
2188
+ class: vue.normalizeClass(["m-editor-layout-center", __props.centerClass]),
2189
+ style: vue.normalizeStyle(`width: ${center.value}px`)
2190
+ }, [
2191
+ vue.renderSlot(_ctx.$slots, "center")
2192
+ ], 6),
2193
+ typeof props.right !== "undefined" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 1 }, [
2194
+ vue.createVNode(_sfc_main$k, { onChange: changeRight }),
2195
+ vue.createElementVNode("div", {
2196
+ class: vue.normalizeClass(["m-editor-layout-right", __props.rightClass]),
2197
+ style: vue.normalizeStyle(`width: ${__props.right}px`)
2198
+ }, [
2199
+ vue.renderSlot(_ctx.$slots, "right")
2200
+ ], 6)
2201
+ ], 64)) : vue.createCommentVNode("", true)
2202
+ ], 512);
2188
2203
  };
2189
2204
  }
2190
2205
  });
2191
2206
 
2192
2207
  const _hoisted_1$8 = { class: "m-editor" };
2193
- const _hoisted_2$3 = {
2194
- key: 1,
2195
- class: "m-editor-content"
2196
- };
2197
- function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
2198
- const _component_magic_code_editor = vue.resolveComponent("magic-code-editor");
2199
- const _component_resizer = vue.resolveComponent("resizer");
2200
- const _component_el_scrollbar = vue.resolveComponent("el-scrollbar");
2201
- const _component_add_page_box = vue.resolveComponent("add-page-box");
2202
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$8, [
2203
- vue.renderSlot(_ctx.$slots, "nav", { class: "m-editor-nav-menu" }),
2204
- _ctx.showSrc ? (vue.openBlock(), vue.createBlock(_component_magic_code_editor, {
2205
- key: 0,
2206
- class: "m-editor-content",
2207
- "init-values": _ctx.root,
2208
- options: _ctx.codeOptions,
2209
- onSave: _ctx.saveCode
2210
- }, null, 8, ["init-values", "options", "onSave"])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_2$3, [
2211
- vue.createElementVNode("div", {
2212
- class: "m-editor-framework-left",
2213
- style: vue.normalizeStyle(`width: ${_ctx.columnWidth?.left}px`)
2214
- }, [
2215
- vue.renderSlot(_ctx.$slots, "sidebar")
2216
- ], 4),
2217
- vue.createVNode(_component_resizer, { type: "left" }),
2218
- _ctx.pageLength > 0 ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [
2219
- vue.createElementVNode("div", {
2220
- class: "m-editor-framework-center",
2221
- style: vue.normalizeStyle(`width: ${_ctx.columnWidth?.center}px`)
2222
- }, [
2223
- vue.renderSlot(_ctx.$slots, "workspace")
2224
- ], 4),
2225
- vue.createVNode(_component_resizer, { type: "right" }),
2226
- vue.createElementVNode("div", {
2227
- class: "m-editor-framework-right",
2228
- style: vue.normalizeStyle(`width: ${_ctx.columnWidth?.right}px`)
2208
+ const _sfc_main$i = /* @__PURE__ */ vue.defineComponent({
2209
+ __name: "Framework",
2210
+ props: {
2211
+ codeOptions: { default: () => ({}) }
2212
+ },
2213
+ setup(__props) {
2214
+ const DEFAULT_LEFT_COLUMN_WIDTH = 310;
2215
+ const DEFAULT_RIGHT_COLUMN_WIDTH = 480;
2216
+ const { editorService, uiService } = vue.inject("services") || {};
2217
+ const root = vue.computed(() => editorService?.get("root"));
2218
+ const pageLength = vue.computed(() => editorService?.get("pageLength") || 0);
2219
+ const showSrc = vue.computed(() => uiService?.get("showSrc"));
2220
+ const columnWidth = vue.ref({
2221
+ left: DEFAULT_LEFT_COLUMN_WIDTH,
2222
+ center: 0,
2223
+ right: 0
2224
+ });
2225
+ uiService?.set("columnWidth", columnWidth.value);
2226
+ vue.watchEffect(() => {
2227
+ if (pageLength.value <= 0) {
2228
+ columnWidth.value.right = void 0;
2229
+ columnWidth.value.center = globalThis.document.body.clientWidth - DEFAULT_LEFT_COLUMN_WIDTH;
2230
+ } else {
2231
+ columnWidth.value.right = columnWidth.value.right || DEFAULT_RIGHT_COLUMN_WIDTH;
2232
+ columnWidth.value.center = globalThis.document.body.clientWidth - DEFAULT_LEFT_COLUMN_WIDTH - DEFAULT_RIGHT_COLUMN_WIDTH;
2233
+ }
2234
+ });
2235
+ const saveCode = (value) => {
2236
+ try {
2237
+ editorService?.set("root", eval(value));
2238
+ } catch (e) {
2239
+ console.error(e);
2240
+ }
2241
+ };
2242
+ const COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorColumnWidthData";
2243
+ const columnWidthCacheData = globalThis.localStorage.getItem(COLUMN_WIDTH_STORAGE_KEY);
2244
+ if (columnWidthCacheData) {
2245
+ try {
2246
+ const columnWidthCache = JSON.parse(columnWidthCacheData);
2247
+ columnWidth.value = columnWidthCache;
2248
+ } catch (e) {
2249
+ console.error(e);
2250
+ }
2251
+ }
2252
+ const columnWidthChange = (columnWidth2) => {
2253
+ uiService?.set("columnWidth", columnWidth2);
2254
+ globalThis.localStorage.setItem(COLUMN_WIDTH_STORAGE_KEY, JSON.stringify(columnWidth2));
2255
+ };
2256
+ return (_ctx, _cache) => {
2257
+ const _component_magic_code_editor = vue.resolveComponent("magic-code-editor");
2258
+ const _component_el_scrollbar = vue.resolveComponent("el-scrollbar");
2259
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$8, [
2260
+ vue.renderSlot(_ctx.$slots, "nav", { class: "m-editor-nav-menu" }),
2261
+ vue.unref(showSrc) ? (vue.openBlock(), vue.createBlock(_component_magic_code_editor, {
2262
+ key: 0,
2263
+ class: "m-editor-content",
2264
+ "init-values": vue.unref(root),
2265
+ options: __props.codeOptions,
2266
+ onSave: saveCode
2267
+ }, null, 8, ["init-values", "options"])) : (vue.openBlock(), vue.createBlock(_sfc_main$j, {
2268
+ key: 1,
2269
+ class: "m-editor-content",
2270
+ "left-class": "m-editor-framework-left",
2271
+ "center-class": "m-editor-framework-center",
2272
+ "right-class": "m-editor-framework-right",
2273
+ left: columnWidth.value.left,
2274
+ "onUpdate:left": _cache[0] || (_cache[0] = ($event) => columnWidth.value.left = $event),
2275
+ right: columnWidth.value.right,
2276
+ "onUpdate:right": _cache[1] || (_cache[1] = ($event) => columnWidth.value.right = $event),
2277
+ "min-left": 45,
2278
+ "min-right": 1,
2279
+ onChange: columnWidthChange
2280
+ }, vue.createSlots({
2281
+ left: vue.withCtx(() => [
2282
+ vue.renderSlot(_ctx.$slots, "sidebar")
2283
+ ]),
2284
+ center: vue.withCtx(() => [
2285
+ vue.unref(pageLength) > 0 ? vue.renderSlot(_ctx.$slots, "workspace", { key: 0 }) : vue.renderSlot(_ctx.$slots, "empty", { key: 1 }, () => [
2286
+ vue.createVNode(AddPageBox)
2287
+ ])
2288
+ ]),
2289
+ _: 2
2229
2290
  }, [
2230
- vue.createVNode(_component_el_scrollbar, null, {
2231
- default: vue.withCtx(() => [
2232
- vue.renderSlot(_ctx.$slots, "props-panel")
2233
- ]),
2234
- _: 3
2235
- })
2236
- ], 4)
2237
- ], 64)) : vue.renderSlot(_ctx.$slots, "empty", { key: 1 }, () => [
2238
- vue.createVNode(_component_add_page_box)
2239
- ])
2240
- ]))
2241
- ]);
2242
- }
2243
- const Framework = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["render", _sfc_render$5]]);
2291
+ vue.unref(pageLength) > 0 ? {
2292
+ name: "right",
2293
+ fn: vue.withCtx(() => [
2294
+ vue.createVNode(_component_el_scrollbar, null, {
2295
+ default: vue.withCtx(() => [
2296
+ vue.renderSlot(_ctx.$slots, "props-panel")
2297
+ ]),
2298
+ _: 3
2299
+ })
2300
+ ])
2301
+ } : void 0
2302
+ ]), 1032, ["left", "right"]))
2303
+ ]);
2304
+ };
2305
+ }
2306
+ });
2244
2307
 
2245
2308
  const _hoisted_1$7 = ["src"];
2246
2309
  const _sfc_main$h = /* @__PURE__ */ vue.defineComponent({
@@ -2482,7 +2545,13 @@
2482
2545
  });
2483
2546
  break;
2484
2547
  case "zoom":
2485
- config.push(...getConfig("zoom-out"), ...getConfig(`${parseInt(`${zoom.value * 100}`, 10)}%`), ...getConfig("zoom-in"), ...getConfig("scale-to-original"), ...getConfig("scale-to-fit"));
2548
+ config.push(
2549
+ ...getConfig("zoom-out"),
2550
+ ...getConfig(`${parseInt(`${zoom.value * 100}`, 10)}%`),
2551
+ ...getConfig("zoom-in"),
2552
+ ...getConfig("scale-to-original"),
2553
+ ...getConfig("scale-to-fit")
2554
+ );
2486
2555
  break;
2487
2556
  case "delete":
2488
2557
  config.push({
@@ -2690,11 +2759,15 @@
2690
2759
  const services = vue.inject("services");
2691
2760
  const stageOptions = vue.inject("stageOptions");
2692
2761
  const stage = vue.computed(() => services?.editorService.get("stage"));
2693
- const list = vue.computed(() => services?.componentListService.getList().map((group) => ({
2694
- ...group,
2695
- items: group.items.filter((item) => item.text.includes(searchText.value))
2696
- })));
2697
- const collapseValue = vue.computed(() => Array(list.value?.length).fill(1).map((x, i) => i));
2762
+ const list = vue.computed(
2763
+ () => services?.componentListService.getList().map((group) => ({
2764
+ ...group,
2765
+ items: group.items.filter((item) => item.text.includes(searchText.value))
2766
+ }))
2767
+ );
2768
+ const collapseValue = vue.computed(
2769
+ () => Array(list.value?.length).fill(1).map((x, i) => i)
2770
+ );
2698
2771
  let timeout;
2699
2772
  let clientX;
2700
2773
  let clientY;
@@ -2708,11 +2781,14 @@
2708
2781
  const dragstartHandler = ({ text, type, data = {} }, e) => {
2709
2782
  if (e.dataTransfer) {
2710
2783
  e.dataTransfer.effectAllowed = "move";
2711
- e.dataTransfer.setData("data", serialize__default.default({
2712
- name: text,
2713
- type,
2714
- ...data
2715
- }).replace(/"(\w+)":\s/g, "$1: "));
2784
+ e.dataTransfer.setData(
2785
+ "data",
2786
+ serialize__default.default({
2787
+ name: text,
2788
+ type,
2789
+ ...data
2790
+ }).replace(/"(\w+)":\s/g, "$1: ")
2791
+ );
2716
2792
  }
2717
2793
  };
2718
2794
  const dragendHandler = () => {
@@ -2968,12 +3044,18 @@
2968
3044
  ];
2969
3045
  }
2970
3046
  if (node.value?.items) {
2971
- return componentList.value.reduce((subMenuData, group, index) => subMenuData.concat(createMenuItems(group), index < componentList.value.length - 1 ? [
2972
- {
2973
- type: "divider",
2974
- direction: "horizontal"
2975
- }
2976
- ] : []), []) || [];
3047
+ return componentList.value.reduce(
3048
+ (subMenuData, group, index) => subMenuData.concat(
3049
+ createMenuItems(group),
3050
+ index < componentList.value.length - 1 ? [
3051
+ {
3052
+ type: "divider",
3053
+ direction: "horizontal"
3054
+ }
3055
+ ] : []
3056
+ ),
3057
+ []
3058
+ ) || [];
2977
3059
  }
2978
3060
  return [];
2979
3061
  });
@@ -3165,7 +3247,9 @@
3165
3247
  clicked.value = !clicked.value;
3166
3248
  };
3167
3249
  const statusData = useStatus(tree, editorService);
3168
- const canHighlight = vue.computed(() => statusData.highlightNode.value?.id !== statusData.clickNode.value?.id && !clicked.value);
3250
+ const canHighlight = vue.computed(
3251
+ () => statusData.highlightNode.value?.id !== statusData.clickNode.value?.id && !clicked.value
3252
+ );
3169
3253
  editorService?.on("remove", () => {
3170
3254
  setTimeout(() => {
3171
3255
  tree.value?.getNode(editorService.get("node").id)?.updateChildren();
@@ -3350,13 +3434,18 @@
3350
3434
  _ctx.data === "layer" ? vue.renderSlot(_ctx.$slots, "layer-panel-header", { key: 0 }) : _ctx.config.slots?.layerPanelHeader ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.config.slots.layerPanelHeader), { key: 1 })) : vue.createCommentVNode("", true)
3351
3435
  ])
3352
3436
  } : void 0,
3353
- _ctx.config.slots?.layerNodeContent ? {
3437
+ _ctx.data === "layer" || _ctx.config.slots?.layerNodeContent ? {
3354
3438
  name: "layer-node-content",
3355
- fn: vue.withCtx(({ data, node }) => [
3356
- (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.config.slots?.layerNodeContent), {
3357
- data,
3439
+ fn: vue.withCtx(({ data: nodeData, node }) => [
3440
+ _ctx.data === "layer" ? vue.renderSlot(_ctx.$slots, "layer-node-content", {
3441
+ key: 0,
3442
+ data: nodeData,
3358
3443
  node
3359
- }, null, 8, ["data", "node"]))
3444
+ }) : _ctx.config.slots?.layerNodeContent ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.config.slots.layerNodeContent), {
3445
+ key: 1,
3446
+ data: nodeData,
3447
+ node
3448
+ }, null, 8, ["data", "node"])) : vue.createCommentVNode("", true)
3360
3449
  ])
3361
3450
  } : void 0
3362
3451
  ]), 1040))
@@ -3377,9 +3466,12 @@
3377
3466
  },
3378
3467
  setup(props) {
3379
3468
  const activeTabName = vue.ref(props.data?.status);
3380
- vue.watch(() => props.data?.status, (status) => {
3381
- activeTabName.value = status || "0";
3382
- });
3469
+ vue.watch(
3470
+ () => props.data?.status,
3471
+ (status) => {
3472
+ activeTabName.value = status || "0";
3473
+ }
3474
+ );
3383
3475
  return {
3384
3476
  activeTabName
3385
3477
  };
@@ -3409,6 +3501,15 @@
3409
3501
  vue.renderSlot(_ctx.$slots, "layer-panel-header")
3410
3502
  ])
3411
3503
  } : void 0,
3504
+ item === "layer" ? {
3505
+ name: "layer-node-content",
3506
+ fn: vue.withCtx(({ node, data }) => [
3507
+ vue.renderSlot(_ctx.$slots, "layer-node-content", {
3508
+ data,
3509
+ node
3510
+ })
3511
+ ])
3512
+ } : void 0,
3412
3513
  item === "component-list" ? {
3413
3514
  name: "component-list-panel-header",
3414
3515
  fn: vue.withCtx(() => [
@@ -3857,12 +3958,14 @@
3857
3958
  const props = __props;
3858
3959
  const container = vue.ref();
3859
3960
  const el = vue.ref();
3860
- const style = vue.computed(() => `
3961
+ const style = vue.computed(
3962
+ () => `
3861
3963
  width: ${props.width}px;
3862
3964
  height: ${props.height}px;
3863
3965
  position: absolute;
3864
3966
  margin-top: 30px;
3865
- `);
3967
+ `
3968
+ );
3866
3969
  const scrollWidth = vue.ref(0);
3867
3970
  const scrollHeight = vue.ref(0);
3868
3971
  let scrollViewer;
@@ -3884,9 +3987,12 @@
3884
3987
  vue.onUnmounted(() => {
3885
3988
  scrollViewer.destroy();
3886
3989
  });
3887
- vue.watch(() => props.zoom, () => {
3888
- scrollViewer.setZoom(props.zoom);
3889
- });
3990
+ vue.watch(
3991
+ () => props.zoom,
3992
+ () => {
3993
+ scrollViewer.setZoom(props.zoom);
3994
+ }
3995
+ );
3890
3996
  const vOffset = vue.ref(0);
3891
3997
  const vScrollHandler = (delta) => {
3892
3998
  vOffset.value += delta;
@@ -4058,14 +4164,20 @@
4058
4164
  },
4059
4165
  ...stageContentMenu
4060
4166
  ]);
4061
- vue.watch(parent, async () => {
4062
- if (!parent.value || !editorService)
4063
- return canCenter.value = false;
4064
- const layout = await editorService.getLayout(parent.value);
4065
- const isLayoutConform = [Layout.ABSOLUTE, Layout.FIXED].includes(layout);
4066
- const isTypeConform = nodes.value?.every((selectedNode) => ![schema.NodeType.ROOT, schema.NodeType.PAGE, "pop"].includes(`${selectedNode?.type}`));
4067
- canCenter.value = isLayoutConform && !!isTypeConform;
4068
- }, { immediate: true });
4167
+ vue.watch(
4168
+ parent,
4169
+ async () => {
4170
+ if (!parent.value || !editorService)
4171
+ return canCenter.value = false;
4172
+ const layout = await editorService.getLayout(parent.value);
4173
+ const isLayoutConform = [Layout.ABSOLUTE, Layout.FIXED].includes(layout);
4174
+ const isTypeConform = nodes.value?.every(
4175
+ (selectedNode) => ![schema.NodeType.ROOT, schema.NodeType.PAGE, "pop"].includes(`${selectedNode?.type}`)
4176
+ );
4177
+ canCenter.value = isLayoutConform && !!isTypeConform;
4178
+ },
4179
+ { immediate: true }
4180
+ );
4069
4181
  const show = async (e) => {
4070
4182
  menu.value?.show(e);
4071
4183
  const data = await storageService.getItem(COPY_STORAGE_KEY);
@@ -4385,7 +4497,7 @@
4385
4497
  Sidebar,
4386
4498
  Workspace: _sfc_main$1,
4387
4499
  PropsPanel: _sfc_main$e,
4388
- Framework
4500
+ Framework: _sfc_main$i
4389
4501
  },
4390
4502
  props: {
4391
4503
  modelValue: {
@@ -4478,37 +4590,64 @@
4478
4590
  }
4479
4591
  emit("update:modelValue", vue.toRaw(editorService.get("root")));
4480
4592
  });
4481
- vue.watch(() => props.modelValue, (modelValue) => editorService.set("root", modelValue), {
4482
- immediate: true
4483
- });
4484
- vue.watch(() => props.componentGroupList, (componentGroupList) => componentListService.setList(componentGroupList), {
4485
- immediate: true
4486
- });
4487
- vue.watch(() => props.propsConfigs, (configs) => propsService.setPropsConfigs(configs), {
4488
- immediate: true
4489
- });
4490
- vue.watch(() => props.propsValues, (values) => propsService.setPropsValues(values), {
4491
- immediate: true
4492
- });
4493
- vue.watch(() => props.eventMethodList, (eventMethodList) => {
4494
- const eventsList = {};
4495
- const methodsList = {};
4496
- Object.keys(eventMethodList).forEach((type) => {
4497
- eventsList[type] = eventMethodList[type].events;
4498
- methodsList[type] = eventMethodList[type].methods;
4499
- });
4500
- eventsService.setEvents(eventsList);
4501
- eventsService.setMethods(methodsList);
4502
- }, {
4503
- immediate: true
4504
- });
4505
- vue.watch(() => props.defaultSelected, (defaultSelected) => defaultSelected && editorService.select(defaultSelected), {
4506
- immediate: true
4507
- });
4508
- vue.watch(() => props.stageRect, (stageRect) => stageRect && uiService.set("stageRect", stageRect), {
4509
- immediate: true
4510
- });
4511
- uiService.initColumnWidth();
4593
+ vue.watch(
4594
+ () => props.modelValue,
4595
+ (modelValue) => editorService.set("root", modelValue),
4596
+ {
4597
+ immediate: true
4598
+ }
4599
+ );
4600
+ vue.watch(
4601
+ () => props.componentGroupList,
4602
+ (componentGroupList) => componentListService.setList(componentGroupList),
4603
+ {
4604
+ immediate: true
4605
+ }
4606
+ );
4607
+ vue.watch(
4608
+ () => props.propsConfigs,
4609
+ (configs) => propsService.setPropsConfigs(configs),
4610
+ {
4611
+ immediate: true
4612
+ }
4613
+ );
4614
+ vue.watch(
4615
+ () => props.propsValues,
4616
+ (values) => propsService.setPropsValues(values),
4617
+ {
4618
+ immediate: true
4619
+ }
4620
+ );
4621
+ vue.watch(
4622
+ () => props.eventMethodList,
4623
+ (eventMethodList) => {
4624
+ const eventsList = {};
4625
+ const methodsList = {};
4626
+ Object.keys(eventMethodList).forEach((type) => {
4627
+ eventsList[type] = eventMethodList[type].events;
4628
+ methodsList[type] = eventMethodList[type].methods;
4629
+ });
4630
+ eventsService.setEvents(eventsList);
4631
+ eventsService.setMethods(methodsList);
4632
+ },
4633
+ {
4634
+ immediate: true
4635
+ }
4636
+ );
4637
+ vue.watch(
4638
+ () => props.defaultSelected,
4639
+ (defaultSelected) => defaultSelected && editorService.select(defaultSelected),
4640
+ {
4641
+ immediate: true
4642
+ }
4643
+ );
4644
+ vue.watch(
4645
+ () => props.stageRect,
4646
+ (stageRect) => stageRect && uiService.set("stageRect", stageRect),
4647
+ {
4648
+ immediate: true
4649
+ }
4650
+ );
4512
4651
  vue.onUnmounted(() => {
4513
4652
  editorService.destroy();
4514
4653
  historyService.destroy();
@@ -4529,18 +4668,21 @@
4529
4668
  vue.provide("services", services);
4530
4669
  vue.provide("layerContentMenu", props.layerContentMenu);
4531
4670
  vue.provide("stageContentMenu", props.stageContentMenu);
4532
- vue.provide("stageOptions", vue.reactive({
4533
- runtimeUrl: props.runtimeUrl,
4534
- autoScrollIntoView: props.autoScrollIntoView,
4535
- render: props.render,
4536
- moveableOptions: props.moveableOptions,
4537
- canSelect: props.canSelect,
4538
- updateDragEl: props.updateDragEl,
4539
- isContainer: props.isContainer,
4540
- containerHighlightClassName: props.containerHighlightClassName,
4541
- containerHighlightDuration: props.containerHighlightDuration,
4542
- containerHighlightType: props.containerHighlightType
4543
- }));
4671
+ vue.provide(
4672
+ "stageOptions",
4673
+ vue.reactive({
4674
+ runtimeUrl: props.runtimeUrl,
4675
+ autoScrollIntoView: props.autoScrollIntoView,
4676
+ render: props.render,
4677
+ moveableOptions: props.moveableOptions,
4678
+ canSelect: props.canSelect,
4679
+ updateDragEl: props.updateDragEl,
4680
+ isContainer: props.isContainer,
4681
+ containerHighlightClassName: props.containerHighlightClassName,
4682
+ containerHighlightDuration: props.containerHighlightDuration,
4683
+ containerHighlightType: props.containerHighlightType
4684
+ })
4685
+ );
4544
4686
  return services;
4545
4687
  }
4546
4688
  });
@@ -4563,6 +4705,12 @@
4563
4705
  "layer-panel-header": vue.withCtx(() => [
4564
4706
  vue.renderSlot(_ctx.$slots, "layer-panel-header")
4565
4707
  ]),
4708
+ "layer-node-content": vue.withCtx(({ node, data }) => [
4709
+ vue.renderSlot(_ctx.$slots, "layer-node-content", {
4710
+ data,
4711
+ node
4712
+ })
4713
+ ]),
4566
4714
  "component-list-panel-header": vue.withCtx(() => [
4567
4715
  vue.renderSlot(_ctx.$slots, "component-list-panel-header")
4568
4716
  ]),
@@ -4621,9 +4769,9 @@
4621
4769
  app.config.globalProperties.$TMAGIC_EDITOR = option;
4622
4770
  setConfig(option);
4623
4771
  app.component(Editor.name, Editor);
4624
- app.component("m-fields-ui-select", _sfc_main$m);
4625
- app.component(CodeLink.name, CodeLink);
4626
- app.component(Code.name, Code);
4772
+ app.component("m-fields-ui-select", _sfc_main$n);
4773
+ app.component("m-fields-code-link", _sfc_main$o);
4774
+ app.component("m-fields-vs-code", _sfc_main$p);
4627
4775
  app.component(CodeEditor.name, CodeEditor);
4628
4776
  }
4629
4777
  };