diff --git a/editor/js/history.js b/editor/js/history.js index bb055b206..4b08d007a 100644 --- a/editor/js/history.js +++ b/editor/js/history.js @@ -1,5 +1,5 @@ /** - * Copyright 2013, 2015 IBM Corp. + * Copyright 2013, 2016 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -174,6 +174,17 @@ RED.history = (function() { n.n.y = n.oy; n.n.dirty = true; } + // A move could have caused a link splice + if (ev.links) { + for (i=0;i 3) { mouse_mode = RED.state.MOVING_ACTIVE; clickElapsed = 0; + spliceActive = false; + if (moving_set.length === 1) { + node = moving_set[0]; + spliceActive = node.n._def.inputs > 0 && + node.n._def.outputs > 0 && + RED.nodes.filterLinks({ source: node.n }).length === 0 && + RED.nodes.filterLinks({ target: node.n }).length === 0; + } } } else if (mouse_mode == RED.state.MOVING_ACTIVE || mouse_mode == RED.state.IMPORT_DRAGGING) { mousePos = mouse_position; @@ -630,6 +643,57 @@ RED.view = (function() { } } } + if (mouse_mode == RED.state.MOVING_ACTIVE && moving_set.length === 1) { + node = moving_set[0]; + if (spliceActive) { + if (!spliceTimer) { + spliceTimer = setTimeout(function() { + var nodes = []; + var bestDistance = Infinity; + var bestLink = null; + var mouseX = mousePos[0]; + var mouseY = mousePos[1]; + if (outer[0][0].getIntersectionList) { + var svgRect = outer[0][0].createSVGRect(); + svgRect.x = mouseX; + svgRect.y = mouseY; + svgRect.width = 1; + svgRect.height = 1; + nodes = outer[0][0].getIntersectionList(svgRect, outer[0][0]); + } else { + // Firefox doesn't do getIntersectionList and that + // makes us sad + nodes = RED.view.getLinksAtPoint(mouseX,mouseY); + } + for (var i=0;i