mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-02 20:09:08 +08:00
fix(布局能力提升amis-saas-7924): 当wrapper为空插入布局容器时,自动改为置换
Change-Id: Icafb6c50d53ebcb876f82e5f75ca3168ab7989d1
This commit is contained in:
parent
752fcdba34
commit
cef36b0c62
@ -590,6 +590,7 @@
|
||||
&.ae-AppendChild {
|
||||
pointer-events: all;
|
||||
position: absolute;
|
||||
margin: 0;
|
||||
background: $Editor-hlbox-bg;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
@ -640,8 +641,8 @@
|
||||
}
|
||||
|
||||
&.ae-AppendChild {
|
||||
top: 10px;
|
||||
right: 10px;
|
||||
top: 5px;
|
||||
right: 5px;
|
||||
left: auto;
|
||||
bottom: auto;
|
||||
transform: none;
|
||||
@ -1267,13 +1268,9 @@
|
||||
margin: 0 6px;
|
||||
}
|
||||
}
|
||||
// 区域仅有 [内容区],也展示头部标签
|
||||
> div.region-tip.is-only-child-region {
|
||||
top: -19px;
|
||||
border-radius: 3px 3px 0 0;
|
||||
}
|
||||
|
||||
// 兼容方案,避免便签被遮挡
|
||||
|
||||
// 兼容方案,避免便签被遮挡: 区域仅有 [内容区],头部标签放内部展示
|
||||
> div.region-tip.is-only-child-region,
|
||||
&.region-label-within > .region-tip {
|
||||
top: 1px;
|
||||
border-radius: 0 0 3px 3px;
|
||||
|
@ -101,10 +101,11 @@ export class RegionWrapper extends React.Component<RegionWrapperProps> {
|
||||
}
|
||||
|
||||
render() {
|
||||
const isLayoutItem = this.props.rendererName === 'wrapper' || this.props.rendererName === 'container';
|
||||
return (
|
||||
<EditorNodeContext.Provider value={this.editorNode}>
|
||||
{this.props.children}
|
||||
<span className={`ae-Region-placeholder ${this.props.rendererName === 'wrapper' ? 'layout-content' : ''}`}>
|
||||
<span className={`ae-Region-placeholder ${isLayoutItem ? 'layout-content' : ''}`}>
|
||||
{this.props.placeholder || this.props.label}
|
||||
</span>
|
||||
</EditorNodeContext.Provider>
|
||||
|
@ -726,7 +726,7 @@ export class EditorManager {
|
||||
* @param rendererIdOrSchema
|
||||
* 备注:可以根据渲染器ID添加新元素,也可以根据现有schema片段添加新元素
|
||||
*/
|
||||
async addElem(rendererIdOrSchema: string | Object) {
|
||||
async addElem(rendererIdOrSchema: string | any) {
|
||||
if (!rendererIdOrSchema) {
|
||||
return;
|
||||
}
|
||||
@ -758,6 +758,15 @@ export class EditorManager {
|
||||
toast.warning('请先选择一个元素作为插入的位置。');
|
||||
return;
|
||||
}
|
||||
|
||||
if (node.type === 'wrapper'
|
||||
&& node.schema?.body?.length === 0
|
||||
&& (schemaData?.type === 'flex' || subRenderer?.rendererName === 'flex')) {
|
||||
const newSchemaData = schemaData || subRenderer?.scaffold;
|
||||
// 布局能力提升: 点击插入新元素,当wrapper为空插入布局容器时,自动改为置换,避免过多层级
|
||||
this.replaceChild(id, newSchemaData);
|
||||
}
|
||||
|
||||
const parentNode = node.parent as EditorNodeType; // 父级节点
|
||||
|
||||
// 插入新元素需要的字段
|
||||
|
Loading…
Reference in New Issue
Block a user