@tmagic/editor 1.0.0-beta.4 → 1.0.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/style.css CHANGED
@@ -28,11 +28,11 @@
28
28
  z-index: 1;
29
29
  align-items: center;
30
30
  }
31
- .m-editor-nav-menu .menu-left {
32
- padding-left: 16px;
31
+ .m-editor-nav-menu .menu-center {
32
+ justify-content: center;
33
33
  }
34
34
  .m-editor-nav-menu .menu-right {
35
- padding-right: 16px;
35
+ justify-content: flex-end;
36
36
  }
37
37
  .m-editor-nav-menu .menu-item {
38
38
  flex-direction: row;
@@ -493,6 +493,7 @@
493
493
  position: relative;
494
494
  border: 1px solid #d9dbdd;
495
495
  transition: transform 0.3s;
496
+ box-sizing: content-box;
496
497
  }
497
498
  .m-editor-stage-container::-webkit-scrollbar {
498
499
  width: 0 !important;
@@ -2,7 +2,7 @@ import { defineComponent, computed, resolveComponent, openBlock, createBlock, no
2
2
  import serialize from 'serialize-javascript';
3
3
  import * as monaco from 'monaco-editor';
4
4
  import { Plus, Edit, ArrowDown, Grid, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, Delete, Files, Coin, CaretBottom } from '@element-plus/icons';
5
- import { cloneDeep, random } from 'lodash-es';
5
+ import { cloneDeep, random, mergeWith } from 'lodash-es';
6
6
  import { toLine, isPop, getNodePath } from '@tmagic/utils';
7
7
  import { EventEmitter as EventEmitter$2 } from 'events';
8
8
  import { DEFAULT_EVENTS, DEFAULT_METHODS } from '@tmagic/core';
@@ -742,22 +742,6 @@ const Fixed2Other = async (node, root, getLayout) => {
742
742
  }
743
743
  return toRelative(node);
744
744
  };
745
- const defaults = (object, source) => {
746
- let o = source;
747
- if (Array.isArray(object)) {
748
- o = object;
749
- }
750
- Object.entries(o).forEach(([key, value]) => {
751
- if (typeof object[key] === "undefined") {
752
- object[key] = value;
753
- return;
754
- }
755
- if (value && typeof value !== "string" && Object.keys(value).length) {
756
- object[key] = defaults(cloneDeep(object[key]), value);
757
- }
758
- });
759
- return object;
760
- };
761
745
 
762
746
  const log = (...args) => {
763
747
  };
@@ -926,7 +910,11 @@ class Editor$1 extends BaseService {
926
910
  throw new Error(`\u83B7\u53D6\u4E0D\u5230id\u4E3A${config2.id}\u7684\u8282\u70B9`);
927
911
  const node = cloneDeep(toRaw(info.node));
928
912
  let newConfig = await this.toggleFixedPosition(toRaw(config2), node, this.get("root"));
929
- defaults(newConfig, node);
913
+ newConfig = mergeWith(node, newConfig, (objValue, srcValue) => {
914
+ if (Array.isArray(srcValue)) {
915
+ return srcValue;
916
+ }
917
+ });
930
918
  if (!newConfig.type)
931
919
  throw new Error("\u914D\u7F6E\u7F3A\u5C11type\u503C");
932
920
  if (newConfig.type === "app") {
@@ -2929,8 +2917,10 @@ const _sfc_main$b = defineComponent({
2929
2917
  }
2930
2918
  },
2931
2919
  setup(props) {
2920
+ const services = inject("services");
2932
2921
  return {
2933
- keys: computed(() => Object.keys(props.data))
2922
+ keys: computed(() => Object.keys(props.data)),
2923
+ columnWidth: computed(() => services?.uiService.get("columnWidth"))
2934
2924
  };
2935
2925
  }
2936
2926
  });
@@ -2943,7 +2933,8 @@ function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
2943
2933
  (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.keys, (key) => {
2944
2934
  return openBlock(), createElementBlock("div", {
2945
2935
  class: normalizeClass(`menu-${key}`),
2946
- key
2936
+ key,
2937
+ style: normalizeStyle(`width: ${_ctx.columnWidth?.[key]}px`)
2947
2938
  }, [
2948
2939
  (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.data[key], (item, index) => {
2949
2940
  return openBlock(), createBlock(_component_tool_button, {
@@ -2951,7 +2942,7 @@ function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
2951
2942
  key: index
2952
2943
  }, null, 8, ["data"]);
2953
2944
  }), 128))
2954
- ], 2);
2945
+ ], 6);
2955
2946
  }), 128))
2956
2947
  ], 4);
2957
2948
  }
@@ -2966,17 +2957,14 @@ const _sfc_main$a = defineComponent({
2966
2957
  const configForm = ref();
2967
2958
  const curFormConfig = ref([]);
2968
2959
  const services = inject("services");
2960
+ const node = computed(() => services?.editorService.get("node"));
2969
2961
  const init = async () => {
2970
- const node = services?.editorService.get("node");
2971
- if (!node) {
2962
+ if (!node.value) {
2972
2963
  curFormConfig.value = [];
2973
2964
  return;
2974
2965
  }
2975
- if (node.devconfig && node.style && !isNaN(+node.style.height) && !isNaN(+node.style.width)) {
2976
- node.devconfig.ratio = node.style.height / node.style.width || 1;
2977
- }
2978
- values.value = node;
2979
- const type = node.type || (node.items ? "container" : "text");
2966
+ values.value = node.value;
2967
+ const type = node.value.type || (node.value.items ? "container" : "text");
2980
2968
  curFormConfig.value = await services?.propsService.getPropsConfig(type) || [];
2981
2969
  };
2982
2970
  watchEffect(init);
@@ -3623,7 +3611,8 @@ class ScrollViewer$1 {
3623
3611
  const { width, height } = contentRect;
3624
3612
  const targetRect = this.target.getBoundingClientRect();
3625
3613
  const targetWidth = targetRect.width * this.zoom;
3626
- const targetHeight = targetRect.height * this.zoom;
3614
+ const targetMarginTop = Number(this.target.style.marginTop) || 0;
3615
+ const targetHeight = (targetRect.height + targetMarginTop) * this.zoom;
3627
3616
  if (targetWidth < width) {
3628
3617
  this.target._left = 0;
3629
3618
  }
@@ -3803,6 +3792,7 @@ const _sfc_main$4 = defineComponent({
3803
3792
  width: ${props.width}px;
3804
3793
  height: ${props.height}px;
3805
3794
  position: absolute;
3795
+ margin-top: 30px;
3806
3796
  `)
3807
3797
  };
3808
3798
  }
@@ -4465,5 +4455,5 @@ var index = {
4465
4455
  }
4466
4456
  };
4467
4457
 
4468
- export { COPY_STORAGE_KEY, ComponentListPanel, DEFAULT_CONFIG, Fixed2Other, Keys, LayerOffset, LayerPanel, Layout, PropsPanel, CodeEditor as TMagicCodeEditor, Editor as TMagicEditor, change2Fixed, debug, index as default, defaults, editorService, error, eventsService, fillConfig, generateId, generatePageName, generatePageNameByApp, getConfig, getDefaultPropsValue, getNodeIndex, getPageList, getPageNameList, historyService, info, initPosition, isFixed, log, propsService, setConfig, setLayout, setNewItemId, toRelative, uiService, warn };
4458
+ export { COPY_STORAGE_KEY, ComponentListPanel, DEFAULT_CONFIG, Fixed2Other, Keys, LayerOffset, LayerPanel, Layout, PropsPanel, CodeEditor as TMagicCodeEditor, Editor as TMagicEditor, change2Fixed, debug, index as default, editorService, error, eventsService, fillConfig, generateId, generatePageName, generatePageNameByApp, getConfig, getDefaultPropsValue, getNodeIndex, getPageList, getPageNameList, historyService, info, initPosition, isFixed, log, propsService, setConfig, setLayout, setNewItemId, toRelative, uiService, warn };
4469
4459
  //# sourceMappingURL=tmagic-editor.es.js.map