| 67 | if (!toNode) throw new Error(`Component not found at line ${toLine}. If you have unsaved changes in your editor, save your files and try again.`); |
| 68 | |
| 69 | function getMovableNode(nodePath: any): any { |
| 70 | let current = nodePath; |
| 71 | while (current.parent) { |
| 72 | const parentNode = current.parent.node; |
| 73 | if (parentNode.children && parentNode.children.indexOf(current.node) !== -1) { |
| 74 | return current; |
| 75 | } |
| 76 | current = current.parent; |
| 77 | } |
| 78 | return nodePath; |
| 79 | } |
| 80 | |
| 81 | const fromMovable = getMovableNode(fromNode); |
| 82 | const toMovable = getMovableNode(toNode); |