Copy/Paste events propagating out of canvas

I want to manage copy and paste events outside of the goJS diagram in my application. I have requirements to be able to copy and paste between browsers and from outside applications. I have a solution for how to do this in other parts of the application, but as soon as I’m focused on the canvas, none of the native copy/paste event listeners are being fired. I’m adding event listeners to the document for copy and paste, and I especially need the paste event to be fired so that I have access to the os’s clipboard data at that time.

I know goJS doesn’t use the os’s clipboard and there are solutions provided to use local storage instead of the in-memory global variable, but local storage won’t work for my needs. Is there a way to allow the native browser events for copy and paste to bubble up from the canvas?

I’m not sure about that. It’s too late now – but I can look into it tomorrow.

1 Like

Try overriding the ToolManager.doKeyDown method:

    myDiagram.toolManager.doKeyDown = function() {
      var e = this.diagram.lastInput;
      if ((e.control || e.meta) && e.key === "V") {
        e.bubbles = true;
      } else {;

I’m assuming you don’t want the Diagram’s CommandHandler the usual control-V behavior to do a CommandHandler.pasteSelection command. And you might want to do something about control-C and control-X too, but those are separate decisions.

That’s exactly what I needed. Thanks Walter!