I’m working on selecting a few elements on an artboard and I’m getting an error sometimes.
var selectedItems = [item1, item2];
selection.items = selectItems;
Error: Cannot select node not in the current edit context: [object Object]
at plugins/SelectionWrapper.js:1:918
It seems it may happen if one scene node is owned by another scene node and I’m setting the selection to both.
For example, when I select a text node inside a container and also select the container. Selecting the text node opens a new context on the artboard.
So is there a method to check if a node is contained in another node?
for (var i=0;i<selectedItems.length;i++) {
if (selectedItems[i].isContainer && selectedItems[i].contains(newItem)!=true) {
selectedItems.push(newItem);
}
}
If I assign the selection to a lot of nodes I want to prevent this error.