You can implement an “ExternalObjectsDropped” DiagramEvent listener on the Diagram.
The collection of Parts that are dropped is available as the Diagram.selection collection, which is the same as the value of DiagramEvent.subject.
If you find that the new parts are not acceptable, you can just delete them all by calling e.diagram.commandHandler.deleteSelection(). Or you can modify the individual new parts.
I wanted to before adding the nodes to judge, whether have the same type of node,
If the diagram has “start” are not allowed, but it seems that the following code is invalid
Would it not be clearer and simpler to either remove the “start” node from the palette or change its appearance and make it not Part.copyable? http://gojs.net/latest/intro/permissions.html
If you still want to handle the drop, I think this would be clearer and work better: