Issue with copy & paste

When we copy whole diagram & paste it is pasted where we want to paste it & paste it works fine.

When we copy a part of the diagram & paste it is not pasted desire place it is override the previous part.

How to fix this?

Please help.

How are you invoking the paste command? Is it the same way both times?

Yes same way both time.

But how? You did not answer my first question.

myDiagram =
$(go.Diagram, “myDiagramDiv”, {

function ClipboardPasted(e){


Is the user typing Ctrl-V? What does ClipboardPasted do?

When press Ctrl-V the following code is executed.

So where the pasted copied parts go depends on where the mouse last was. Does that answer your question?

What does ClipboardPasted do?

This function change node data name, key, etc .

But that listener does not move the nodes? So that function doesn’t actually matter to your question. OK.

In any case you seem to have answered your question by explaining how CommandHandler.pasteSelection is being called.

Let me explain again.
Let two nodes (Node 1 & Node 2) and one link (Link 1) are there.
When we copy Node 1 Or Node 2 and paste it, it works fine. Pasting where we point the mouse.

But when we copy (Node 1 And Link 1 ) Or (Node 2 And Link 1) and paste it. Pasting is override the copy node.

Can you tell me how to resolve this?
We are copy using Ctrl-C And Ctrl-v.
For Ctrl-C our code is myDiagram.commandHandler.copySelection();
for Ctrl-v our code is myDiagram.commandHandler.pasteSelection(myDiagram.lastInput.documentPoint);

OK, I just tried this, and I did not have any trouble – the custom paste always inserted the node(s) at the current mouse point.

    $(go.Diagram, . . .,
      { . . .,
        "commandHandler.doKeyDown": function() {
          var e = this.diagram.lastInput;
          if (e.control && e.key === "F") {
          } else {

Here I bound the Ctrl-F keyboard command so that I could continue testing Ctrl-V as well.