@tmagic/editor 1.3.0 → 1.3.1

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/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.3.0",
2
+ "version": "1.3.1",
3
3
  "name": "@tmagic/editor",
4
4
  "type": "module",
5
5
  "sideEffects": [
@@ -47,13 +47,13 @@
47
47
  "dependencies": {
48
48
  "@babel/core": "^7.18.0",
49
49
  "@element-plus/icons-vue": "^2.0.9",
50
- "@tmagic/core": "1.3.0",
51
- "@tmagic/design": "1.3.0",
52
- "@tmagic/form": "1.3.0",
53
- "@tmagic/schema": "1.3.0",
54
- "@tmagic/stage": "1.3.0",
55
- "@tmagic/table": "1.3.0",
56
- "@tmagic/utils": "1.3.0",
50
+ "@tmagic/core": "1.3.1",
51
+ "@tmagic/design": "1.3.1",
52
+ "@tmagic/form": "1.3.1",
53
+ "@tmagic/schema": "1.3.1",
54
+ "@tmagic/stage": "1.3.1",
55
+ "@tmagic/table": "1.3.1",
56
+ "@tmagic/utils": "1.3.1",
57
57
  "buffer": "^6.0.3",
58
58
  "color": "^3.1.3",
59
59
  "events": "^3.3.0",
@@ -65,8 +65,8 @@
65
65
  "vue": "^3.3.4"
66
66
  },
67
67
  "peerDependencies": {
68
- "@tmagic/design": "1.3.0",
69
- "@tmagic/form": "1.3.0",
68
+ "@tmagic/design": "1.3.1",
69
+ "@tmagic/form": "1.3.1",
70
70
  "monaco-editor": "^0.41.0",
71
71
  "vue": "^3.3.4"
72
72
  },
@@ -149,7 +149,6 @@ const tree = ref<InstanceType<typeof TMagicTree>>();
149
149
 
150
150
  defineExpose({
151
151
  filter(val: string) {
152
- debugger;
153
152
  tree.value?.filter(val);
154
153
  },
155
154
  });
@@ -36,6 +36,7 @@ import {
36
36
  getInitPositionStyle,
37
37
  getNodeIndex,
38
38
  isFixed,
39
+ setChilrenLayout,
39
40
  setLayout,
40
41
  } from '@editor/utils/editor';
41
42
  import { beforePaste, getAddParent } from '@editor/utils/operator';
@@ -510,8 +511,8 @@ class Editor extends BaseService {
510
511
 
511
512
  const newLayout = await this.getLayout(newConfig);
512
513
  const layout = await this.getLayout(node);
513
- if (newLayout !== layout) {
514
- newConfig = setLayout(newConfig, newLayout);
514
+ if (Array.isArray(newConfig.items) && newLayout !== layout) {
515
+ newConfig = setChilrenLayout(newConfig as MContainer, newLayout);
515
516
  }
516
517
 
517
518
  parentNodeItems[index] = newConfig;
@@ -788,7 +789,15 @@ class Editor extends BaseService {
788
789
  }
789
790
  }
790
791
 
792
+ const layout = await this.getLayout(parent);
793
+ const newLayout = await this.getLayout(targetParent);
794
+
795
+ if (newLayout !== layout) {
796
+ setLayout(config, newLayout);
797
+ }
798
+
791
799
  parent.items?.splice(index, 1);
800
+
792
801
  targetParent.items?.splice(targetIndex, 0, config);
793
802
 
794
803
  const page = this.get('page');
@@ -129,23 +129,28 @@ export const getInitPositionStyle = (style: Record<string, any> = {}, layout: La
129
129
  return style;
130
130
  };
131
131
 
132
- export const setLayout = (node: MNode, layout: Layout) => {
132
+ export const setChilrenLayout = (node: MContainer, layout: Layout) => {
133
133
  node.items?.forEach((child: MNode) => {
134
- if (isPop(child)) return;
134
+ setLayout(child, layout);
135
+ });
136
+ return node;
137
+ };
135
138
 
136
- const style = child.style || {};
139
+ export const setLayout = (node: MNode, layout: Layout) => {
140
+ if (isPop(node)) return;
137
141
 
138
- // fixed 不做处理
139
- if (style.position === 'fixed') return;
142
+ const style = node.style || {};
140
143
 
141
- if (layout !== Layout.RELATIVE) {
142
- style.position = 'absolute';
143
- } else {
144
- child.style = getRelativeStyle(style);
145
- child.style.right = 'auto';
146
- child.style.bottom = 'auto';
147
- }
148
- });
144
+ // fixed 不做处理
145
+ if (style.position === 'fixed') return;
146
+
147
+ if (layout !== Layout.RELATIVE) {
148
+ style.position = 'absolute';
149
+ } else {
150
+ node.style = getRelativeStyle(style);
151
+ node.style.right = 'auto';
152
+ node.style.bottom = 'auto';
153
+ }
149
154
  return node;
150
155
  };
151
156
 
@@ -34,7 +34,8 @@ export declare const isFixed: (node: MNode) => boolean;
34
34
  export declare const getNodeIndex: (id: Id, parent: MContainer | MApp) => number;
35
35
  export declare const getRelativeStyle: (style?: Record<string, any>) => Record<string, any>;
36
36
  export declare const getInitPositionStyle: (style: Record<string, any> | undefined, layout: Layout) => Record<string, any>;
37
- export declare const setLayout: (node: MNode, layout: Layout) => MNode;
37
+ export declare const setChilrenLayout: (node: MContainer, layout: Layout) => MContainer;
38
+ export declare const setLayout: (node: MNode, layout: Layout) => import("@tmagic/schema").MComponent | undefined;
38
39
  export declare const change2Fixed: (node: MNode, root: MApp) => {
39
40
  left: number;
40
41
  top: number;