mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-05-06 02:26:06 +08:00
parent
7f6ba9de99
commit
ce0c941bf1
@ -36,6 +36,7 @@ import {
|
|||||||
getInitPositionStyle,
|
getInitPositionStyle,
|
||||||
getNodeIndex,
|
getNodeIndex,
|
||||||
isFixed,
|
isFixed,
|
||||||
|
setChilrenLayout,
|
||||||
setLayout,
|
setLayout,
|
||||||
} from '@editor/utils/editor';
|
} from '@editor/utils/editor';
|
||||||
import { beforePaste, getAddParent } from '@editor/utils/operator';
|
import { beforePaste, getAddParent } from '@editor/utils/operator';
|
||||||
@ -510,8 +511,8 @@ class Editor extends BaseService {
|
|||||||
|
|
||||||
const newLayout = await this.getLayout(newConfig);
|
const newLayout = await this.getLayout(newConfig);
|
||||||
const layout = await this.getLayout(node);
|
const layout = await this.getLayout(node);
|
||||||
if (newLayout !== layout) {
|
if (Array.isArray(newConfig.items) && newLayout !== layout) {
|
||||||
newConfig = setLayout(newConfig, newLayout);
|
newConfig = setChilrenLayout(newConfig as MContainer, newLayout);
|
||||||
}
|
}
|
||||||
|
|
||||||
parentNodeItems[index] = newConfig;
|
parentNodeItems[index] = newConfig;
|
||||||
@ -788,7 +789,15 @@ class Editor extends BaseService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const layout = await this.getLayout(parent);
|
||||||
|
const newLayout = await this.getLayout(targetParent);
|
||||||
|
|
||||||
|
if (newLayout !== layout) {
|
||||||
|
setLayout(config, newLayout);
|
||||||
|
}
|
||||||
|
|
||||||
parent.items?.splice(index, 1);
|
parent.items?.splice(index, 1);
|
||||||
|
|
||||||
targetParent.items?.splice(targetIndex, 0, config);
|
targetParent.items?.splice(targetIndex, 0, config);
|
||||||
|
|
||||||
const page = this.get('page');
|
const page = this.get('page');
|
||||||
|
@ -129,11 +129,17 @@ export const getInitPositionStyle = (style: Record<string, any> = {}, layout: La
|
|||||||
return style;
|
return style;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const setLayout = (node: MNode, layout: Layout) => {
|
export const setChilrenLayout = (node: MContainer, layout: Layout) => {
|
||||||
node.items?.forEach((child: MNode) => {
|
node.items?.forEach((child: MNode) => {
|
||||||
if (isPop(child)) return;
|
setLayout(child, layout);
|
||||||
|
});
|
||||||
|
return node;
|
||||||
|
};
|
||||||
|
|
||||||
const style = child.style || {};
|
export const setLayout = (node: MNode, layout: Layout) => {
|
||||||
|
if (isPop(node)) return;
|
||||||
|
|
||||||
|
const style = node.style || {};
|
||||||
|
|
||||||
// 是 fixed 不做处理
|
// 是 fixed 不做处理
|
||||||
if (style.position === 'fixed') return;
|
if (style.position === 'fixed') return;
|
||||||
@ -141,11 +147,10 @@ export const setLayout = (node: MNode, layout: Layout) => {
|
|||||||
if (layout !== Layout.RELATIVE) {
|
if (layout !== Layout.RELATIVE) {
|
||||||
style.position = 'absolute';
|
style.position = 'absolute';
|
||||||
} else {
|
} else {
|
||||||
child.style = getRelativeStyle(style);
|
node.style = getRelativeStyle(style);
|
||||||
child.style.right = 'auto';
|
node.style.right = 'auto';
|
||||||
child.style.bottom = 'auto';
|
node.style.bottom = 'auto';
|
||||||
}
|
}
|
||||||
});
|
|
||||||
return node;
|
return node;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user