mohamed yahia
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with
4 additions and
4 deletions
-
packages/core/src/utils/sorter/CanvasNewComponentNode.ts
|
|
|
@ -1,3 +1,4 @@ |
|
|
|
import { isFunction } from 'underscore'; |
|
|
|
import CanvasComponentNode from './CanvasComponentNode'; |
|
|
|
|
|
|
|
export default class CanvasNewComponentNode extends CanvasComponentNode { |
|
|
|
@ -8,14 +9,13 @@ export default class CanvasNewComponentNode extends CanvasComponentNode { |
|
|
|
*/ |
|
|
|
addChildAt(node: CanvasNewComponentNode, index: number): CanvasNewComponentNode { |
|
|
|
const insertingTextableIntoText = this.isTextNode() && node.isTextable(); |
|
|
|
const content = isFunction(node._content) ? node._content() : node._content; |
|
|
|
let model; |
|
|
|
if (insertingTextableIntoText) { |
|
|
|
// @ts-ignore
|
|
|
|
model = this.model?.getView?.()?.insertComponent?.(node._content, { action: 'add-component' }); |
|
|
|
model = this.model?.getView?.()?.insertComponent?.(content, { action: 'add-component' }); |
|
|
|
} else { |
|
|
|
model = this.model |
|
|
|
.components() |
|
|
|
.add(node._content, { at: this.getRealIndex(index || -1), action: 'add-component' }); |
|
|
|
model = this.model.components().add(content, { at: this.getRealIndex(index || -1), action: 'add-component' }); |
|
|
|
} |
|
|
|
|
|
|
|
return new (this.constructor as any)(model); |
|
|
|
|