容器组件不直接替换 & 添加右键清空操作

This commit is contained in:
zhangtao07 2024-01-04 16:56:20 +08:00
parent 34280372c5
commit 8d55b21847
2 changed files with 29 additions and 20 deletions

View File

@ -915,26 +915,28 @@ export class EditorManager {
const curElemSchema = schemaData || subRenderer?.scaffold;
const isSpecialLayout = this.isSpecialLayout(curElemSchema);
if (
(node.type === 'wrapper' || node.type === 'container') &&
node.schema?.body?.length === 0 &&
curElemSchema?.type === 'flex' &&
!node.schema?.isFreeContainer &&
!isSpecialLayout
) {
// 布局能力提升: 点击插入新元素当wrapper为空插入布局容器时自动改为置换避免过多层级
this.replaceChild(
curActiveId,
curElemSchema,
subRenderer,
store.insertRegion,
reGenerateId
);
setTimeout(() => {
this.updateConfigPanel();
}, 0);
return;
}
// 不直接替换容器
// if (
// (node.type === 'wrapper' || node.type === 'container') &&
// node.schema?.body?.length === 0 &&
// curElemSchema?.type === 'flex' &&
// !node.schema?.isFreeContainer &&
// !isSpecialLayout
// ) {
// // 布局能力提升: 点击插入新元素当wrapper为空插入布局容器时自动改为置换避免过多层级
// this.replaceChild(
// curActiveId,
// curElemSchema,
// subRenderer,
// store.insertRegion,
// reGenerateId
// );
// setTimeout(() => {
// this.updateConfigPanel();
// }, 0);
// return;
// }
const parentNode = node.parent as EditorNodeType; // 父级节点

View File

@ -518,6 +518,13 @@ export class BasicToolbarPlugin extends BasePlugin {
});
}
}
if (node.type === 'container') {
menus.push({
label: '清空容器',
disabled: !node.schema.body?.length,
onSelect: () => manager.emptyRegion(id, 'body')
});
}
menus.push({
label: '替换组件',