fix(editor): 复制粘贴时添加的到的父组件应当是当前父组件

fix #448
This commit is contained in:
roymondchen 2022-12-05 20:35:17 +08:00
parent 45eaea6f68
commit 828681e960

View File

@ -352,6 +352,9 @@ class Editor extends BaseService {
const newNodes = await Promise.all(
addNodes.map((node) => {
if (isPage(node)) {
return this.doAdd(node, this.get('root'));
}
const parentNode = parent && typeof parent !== 'function' ? parent : getAddParent(node);
if (!parentNode) throw new Error('未找到父元素');
return this.doAdd(node, parentNode);
@ -579,7 +582,7 @@ class Editor extends BaseService {
const pasteConfigs = await this.doPaste(config, position);
return this.add(pasteConfigs);
return this.add(pasteConfigs, this.get('parent'));
}
public async doPaste(config: MNode[], position: PastePosition = {}): Promise<MNode[]> {