1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Merge pull request #3653 from node-red-hitachi/fix-undo-junction-to-subflow

Fix undoing junction to subflow
This commit is contained in:
Nick O'Leary 2022-06-13 21:09:20 +01:00 committed by GitHub
commit 6c49d1aa3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -22,6 +22,14 @@ RED.history = (function() {
var undoHistory = []; var undoHistory = [];
var redoHistory = []; var redoHistory = [];
function nodeOrJunction(id) {
var node = RED.nodes.node(id);
if (node) {
return node;
}
return RED.nodes.junction(id);
}
function undoEvent(ev) { function undoEvent(ev) {
var i; var i;
var len; var len;
@ -514,6 +522,7 @@ RED.history = (function() {
var z = ev.activeWorkspace; var z = ev.activeWorkspace;
var fullNodeList = RED.nodes.filterNodes({z:ev.subflow.subflow.id}); var fullNodeList = RED.nodes.filterNodes({z:ev.subflow.subflow.id});
fullNodeList = fullNodeList.concat(RED.nodes.groups(ev.subflow.subflow.id)) fullNodeList = fullNodeList.concat(RED.nodes.groups(ev.subflow.subflow.id))
fullNodeList = fullNodeList.concat(RED.nodes.junctions(ev.subflow.subflow.id))
fullNodeList.forEach(function(n) { fullNodeList.forEach(function(n) {
n.x += ev.subflow.offsetX; n.x += ev.subflow.offsetX;
n.y += ev.subflow.offsetY; n.y += ev.subflow.offsetY;
@ -523,7 +532,7 @@ RED.history = (function() {
}); });
inverseEv.subflows = []; inverseEv.subflows = [];
for (i=0;i<ev.nodes.length;i++) { for (i=0;i<ev.nodes.length;i++) {
inverseEv.subflows.push(RED.nodes.node(ev.nodes[i])); inverseEv.subflows.push(nodeOrJunction(ev.nodes[i]));
RED.nodes.remove(ev.nodes[i]); RED.nodes.remove(ev.nodes[i]);
} }
} }