Socket
Socket
Sign inDemoInstall

cytoscape-clipboard

Package Overview
Dependencies
2
Maintainers
6
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.1.1 to 2.2.0

65

cytoscape-clipboard.js

@@ -16,2 +16,11 @@ ;(function () {

//Global variables to hold x and y coordinates in case of pasting
var mouseX, mouseY;
cy.on('mousemove', function onmousemove (e) {
var pos = e.position || e.cyPosition;
mouseX = pos.x;
mouseY = pos.y;
});
var options = {

@@ -64,3 +73,3 @@ clipboardSize: 0,

function changeIds(jsons) {
function changeIds(jsons, pasteAtMouseLoc) {
jsons = $.extend(true, [], jsons);

@@ -74,2 +83,38 @@ for (var i = 0; i < jsons.length; i++) {

//Paste the elements centered at the mouse location
var topLeftX, topLeftY;
var bottomRightX, bottomRightY;
var centerX, centerY;
var diffX, diffY;
//Checks only for nodes
if (jsons[0] !== undefined && jsons[0].position.x)
{
topLeftX = jsons[0].position.x;
topLeftY = jsons[0].position.y;
bottomRightX = jsons[0].position.x;
bottomRightY = jsons[0].position.y;
for (var k = 1; k < jsons.length; k++) {
var ele = jsons[k];
if (ele.position.x < topLeftX) {
topLeftX = ele.position.x;
}
if (ele.position.y < topLeftY) {
topLeftY = ele.position.y;
}
if (ele.position.x > bottomRightX) {
bottomRightX = ele.position.x;
}
if (ele.position.y > bottomRightY) {
bottomRightY = ele.position.y;
}
}
centerX = (topLeftX+bottomRightX)/2;
centerY = (topLeftY+bottomRightY)/2;
diffX = mouseX -centerX;
diffY = mouseY - centerY;
}
for (var j = 0; j < jsons.length; j++) {

@@ -83,7 +128,13 @@ var json = jsons[j];

}
if (json.position.x) {
json.position.x += 50;
json.position.y += 50;
if (pasteAtMouseLoc == false) {
json.position.x += 50;
json.position.y += 50;
}
else {
json.position.x += diffX;
json.position.y += diffY;
}
}

@@ -118,3 +169,3 @@ }

},
paste: function (_id) {
paste: function (_id, pasteAtMouseLoc) {
var id = _id ? _id : getItemId(true);

@@ -126,3 +177,3 @@ var res = cy.collection();

if (clipboard[id]) {
var nodes = changeIds(clipboard[id].nodes);
var nodes = changeIds(clipboard[id].nodes, pasteAtMouseLoc);
var edges = changeIds(clipboard[id].edges);

@@ -146,3 +197,3 @@ oldIdToNewId = {};

ur.action("paste", function (eles) {
return eles.firstTime ? scratchPad.instance.paste(eles.id) : eles.restore();
return eles.firstTime ? scratchPad.instance.paste(eles.id, eles.pasteAtMouseLoc) : eles.restore();
}, function (eles) {

@@ -149,0 +200,0 @@ return eles.remove();

2

package.json
{
"name": "cytoscape-clipboard",
"version": "2.1.1",
"version": "2.2.0",
"description": "Adds copy-paste utilities to cytoscape.",

@@ -5,0 +5,0 @@ "main": "cytoscape-clipboard.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc