cytoscape-clipboard
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -13,3 +13,2 @@ ;(function () { | ||
var _instance; | ||
var initialized = false; | ||
cytoscape('core', 'clipboard', function (opts) { | ||
@@ -19,7 +18,3 @@ var cy = this; | ||
var options = { | ||
clipboardSize: 0, | ||
shortcuts: { | ||
enabled: true, | ||
undoable: true | ||
} | ||
clipboardSize: 0 | ||
}; | ||
@@ -30,2 +25,10 @@ | ||
function getScratch() { | ||
if (!cy.scratch("_clipboard")) { | ||
cy.scratch("_clipboard", { }); | ||
} | ||
return cy.scratch("_clipboard"); | ||
} | ||
var counter = 0; | ||
@@ -85,27 +88,7 @@ | ||
if (!initialized) { | ||
initialized = true; | ||
if (!getScratch().isInitialized) { | ||
getScratch().isInitialized = 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) | ||
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(); | ||
} | ||
}); | ||
} | ||
_instance = { | ||
@@ -112,0 +95,0 @@ copy: function (eles, _id) { |
{ | ||
"name": "cytoscape-clipboard", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Adds copy-paste utilities to cytoscape.", | ||
@@ -5,0 +5,0 @@ "main": "cytoscape-clipboard.js", |
@@ -33,7 +33,3 @@ cytoscape-clipboard | ||
var options = { | ||
clipboardSize: 0, // Size of clipboard. 0 means unlimited. If size is exceeded, first added item in clipboard will be removed. | ||
shortcuts: { | ||
enabled: true, // Whether keyboard shortcuts are enabled | ||
undoable: true // and if undoRedo extension exists | ||
} | ||
clipboardSize: 0 | ||
}; | ||
@@ -50,3 +46,3 @@ ``` | ||
* Cytoscape.js ^x.y.z | ||
* Cytoscape.js ^2.6.12 | ||
* cytoscape-undo-redo ^1.0.8 (optional) | ||
@@ -53,0 +49,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
78363
601
87