How to cancel addnode from palette?

From the palette before dragging a node to the Diagram, how to judge the existing node in the Diagram, if present, is not allowed to add it?
thanks.

i use follow code

myDiagram.addModelChangedListener(function(evt) {
if (!evt.isTransactionFinished) return;
var txn = evt.object; // a Transaction
if (txn === null) return;
txn.changes.each(function(e) {
if (e.change === go.ChangedEvent.Insert && e.modelChange === “nodeDataArray”) {
console.log(" e.modelChange: " + e.modelChange);
if(e.newValue){
//alert(e.newValue.category);
return ;
}
} else if (e.change === go.ChangedEvent.Remove && e.modelChange === “nodeDataArray”) {
console.log(evt.propertyName + " removed link: " + e.oldValue);
}
});
});

but doen’t work.

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

when i draging , the diagram has the node ?

“ExternalObjectsDropped”: function(e) {
var evt = e;
evt.subject.each(function(p) {
if(p.data.category === “Start” && myDiagram.model.findNodeDataForKey(“Start”)){
evt.diagram.commandHandler.deleteSelection();
}
});
}

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:

"ExternalObjectsDropped": function(e) {
    if (e.subject.any(function(p) { return p.data.category === "Start"; })) {
        e.diagram.commandHandler.deleteSelection();
    }
}