From cd4b9826988369a67552183941d530346fdcf2a2 Mon Sep 17 00:00:00 2001 From: mrsfy Date: Mon, 25 Jul 2016 16:50:27 +0300 Subject: [PATCH] Removed keyboard listening from ext. --- cytoscape-clipboard.js | 28 ++-------------------------- demo.html | 11 +++++++++++ 2 files changed, 13 insertions(+), 26 deletions(-) diff --git a/cytoscape-clipboard.js b/cytoscape-clipboard.js index 7c1a776..85f955a 100644 --- a/cytoscape-clipboard.js +++ b/cytoscape-clipboard.js @@ -15,11 +15,7 @@ var cy = this; var options = { - clipboardSize: 0, - shortcuts: { - enabled: true, - undoable: true - } + clipboardSize: 0 }; $.extend(true, options, opts); @@ -82,27 +78,7 @@ if (!initialized) { initialized = true; var ur; - var clipboard = {}; - if (options.shortcuts.enabled) { - var undoable = options.shortcuts.undoable && (cy.undoRedo ? true : false); - if (undoable) - ur = cy.undoRedo({}, true); - - document.addEventListener("keydown", function (e) { - if (e.ctrlKey && e.target.nodeName === 'BODY') - if (e.which == 67) // CTRL + C - _instance.copy(cy.$(":selected")); - else if (e.which == 86) // CTRL + V - if (undoable) - ur.do("paste"); - else - _instance.paste(); - else if (e.which == 65) { - cy.elements().select(); - e.preventDefault(); - } - }); - } + var clipboard = {}; _instance = { copy: function (eles, _id) { diff --git a/demo.html b/demo.html index ee6dfe9..8002d9d 100644 --- a/demo.html +++ b/demo.html @@ -86,6 +86,17 @@ }); var cb = cy.clipboard(); + document.addEventListener("keydown", function (e) { + if (e.ctrlKey && e.target.nodeName === 'BODY') + if (e.which == 67) // CTRL + C + cy.clipboard().copy(cy.$(":selected")); + else if (e.which == 86) // CTRL + V + ur.do("paste"); + else if (e.which == 65) { + cy.elements().select(); + e.preventDefault(); + } + }); });