mirror of
				https://github.com/Tencent/tmagic-editor.git
				synced 2025-11-04 10:49:51 +08:00 
			
		
		
		
	feat(editor): 创建新组件时的顺序 (#316)
* feat(editor): 创建新组件时的顺序 点击面板组件创建新组件时,默认按照当所选组件(非容器)后面的顺序 * feat(editor): 追加vue2 runtime的修改
This commit is contained in:
		
							parent
							
								
									d3342a04c9
								
							
						
					
					
						commit
						6c0b92e808
					
				@ -297,8 +297,13 @@ class Editor extends BaseService {
 | 
			
		||||
      throw new Error('app下不能添加组件');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // 新增节点添加到配置中
 | 
			
		||||
    parent?.items?.push(node);
 | 
			
		||||
    if (parent.id !== curNode.id) {
 | 
			
		||||
      const index = parent.items.indexOf(curNode);
 | 
			
		||||
      parent?.items?.splice(index + 1, 0, node);
 | 
			
		||||
    } else {
 | 
			
		||||
      // 新增节点添加到配置中
 | 
			
		||||
      parent?.items?.push(node);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    const layout = await this.getLayout(toRaw(parent), node as MNode);
 | 
			
		||||
    node.style = getInitPositionStyle(node.style, layout);
 | 
			
		||||
 | 
			
		||||
@ -71,7 +71,13 @@ export default defineComponent({
 | 
			
		||||
        if (!selectedId.value) throw new Error('error');
 | 
			
		||||
        const parent = getNodePath(parentId, [root.value]).pop();
 | 
			
		||||
        if (!parent) throw new Error('未找到父节点');
 | 
			
		||||
        parent.items?.push(config);
 | 
			
		||||
        if (parent.id !== selectedId.value) {
 | 
			
		||||
          const index = parent.items?.findIndex((child: MNode) => child.id === selectedId.value);
 | 
			
		||||
          parent.items?.splice(index + 1, 0, config);
 | 
			
		||||
        } else {
 | 
			
		||||
          // 新增节点添加到配置中
 | 
			
		||||
          parent.items?.push(config);
 | 
			
		||||
        }
 | 
			
		||||
      },
 | 
			
		||||
 | 
			
		||||
      update({ config, parentId }: UpdateData) {
 | 
			
		||||
 | 
			
		||||
@ -71,7 +71,13 @@ export default defineComponent({
 | 
			
		||||
        if (!selectedId.value) throw new Error('error');
 | 
			
		||||
        const parent = getNodePath(parentId, [root.value]).pop();
 | 
			
		||||
        if (!parent) throw new Error('未找到父节点');
 | 
			
		||||
        parent.items?.push(config);
 | 
			
		||||
        if (parent.id !== selectedId.value) {
 | 
			
		||||
          const index = parent.items?.findIndex((child: MNode) => child.id === selectedId.value);
 | 
			
		||||
          parent.items?.splice(index + 1, 0, config);
 | 
			
		||||
        } else {
 | 
			
		||||
          // 新增节点添加到配置中
 | 
			
		||||
          parent.items?.push(config);
 | 
			
		||||
        }
 | 
			
		||||
      },
 | 
			
		||||
 | 
			
		||||
      update({ config, parentId }: UpdateData) {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user