@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/dist/tmagic-editor.js +25 -17
- package/dist/tmagic-editor.js.map +1 -1
- package/dist/tmagic-editor.umd.cjs +25 -16
- package/dist/tmagic-editor.umd.cjs.map +1 -1
- package/package.json +10 -10
- package/src/layouts/sidebar/data-source/DataSourceList.vue +0 -1
- package/src/services/editor.ts +11 -2
- package/src/utils/editor.ts +18 -13
- package/types/utils/editor.d.ts +2 -1
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.3.
|
|
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.
|
|
51
|
-
"@tmagic/design": "1.3.
|
|
52
|
-
"@tmagic/form": "1.3.
|
|
53
|
-
"@tmagic/schema": "1.3.
|
|
54
|
-
"@tmagic/stage": "1.3.
|
|
55
|
-
"@tmagic/table": "1.3.
|
|
56
|
-
"@tmagic/utils": "1.3.
|
|
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.
|
|
69
|
-
"@tmagic/form": "1.3.
|
|
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
|
},
|
package/src/services/editor.ts
CHANGED
|
@@ -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 =
|
|
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');
|
package/src/utils/editor.ts
CHANGED
|
@@ -129,23 +129,28 @@ export const getInitPositionStyle = (style: Record<string, any> = {}, layout: La
|
|
|
129
129
|
return style;
|
|
130
130
|
};
|
|
131
131
|
|
|
132
|
-
export const
|
|
132
|
+
export const setChilrenLayout = (node: MContainer, layout: Layout) => {
|
|
133
133
|
node.items?.forEach((child: MNode) => {
|
|
134
|
-
|
|
134
|
+
setLayout(child, layout);
|
|
135
|
+
});
|
|
136
|
+
return node;
|
|
137
|
+
};
|
|
135
138
|
|
|
136
|
-
|
|
139
|
+
export const setLayout = (node: MNode, layout: Layout) => {
|
|
140
|
+
if (isPop(node)) return;
|
|
137
141
|
|
|
138
|
-
|
|
139
|
-
if (style.position === 'fixed') return;
|
|
142
|
+
const style = node.style || {};
|
|
140
143
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
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
|
|
package/types/utils/editor.d.ts
CHANGED
|
@@ -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
|
|
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;
|