(childSet: ChildSet, index: number, node: SplootNode)
| 419 | } |
| 420 | |
| 421 | replaceNode(childSet: ChildSet, index: number, node: SplootNode) { |
| 422 | const nodeToReplace = childSet.getChild(index) |
| 423 | if (!isAdaptableToPasteDesintation(node, childSet.nodeCategory)) { |
| 424 | // Would the parent be empty without that node? |
| 425 | // Can we replace the parent instead? |
| 426 | const parentRef = nodeToReplace.parent |
| 427 | if (parentRef.node.childSetOrder.length === 1 && parentRef.getChildSet().getCount() === 1) { |
| 428 | const destCategory = parentRef.node.parent.getChildSet().nodeCategory |
| 429 | if (!isAdaptableToPasteDesintation(node, destCategory)) { |
| 430 | return false |
| 431 | } |
| 432 | childSet = parentRef.node.parent.getChildSet() |
| 433 | index = childSet.getIndexOf(parentRef.node) |
| 434 | } else { |
| 435 | return |
| 436 | } |
| 437 | } |
| 438 | |
| 439 | childSet.removeChild(index) |
| 440 | this.insertNodeByChildSet(childSet, index, node) |
| 441 | } |
| 442 | |
| 443 | insertFragment(fragment: SplootFragment, allowSingle = true) { |
| 444 | if (this.isCursor()) { |
no test coverage detected