mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-30 02:48:55 +08:00
容器组件不直接替换 & 添加右键清空操作
This commit is contained in:
parent
34280372c5
commit
8d55b21847
@ -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; // 父级节点
|
||||
|
||||
|
@ -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: '替换组件',
|
||||
|
Loading…
Reference in New Issue
Block a user