mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Eliminate snake_case and use camelCase, and change assignment of keyboard shortcut
This commit is contained in:
parent
c4e8756210
commit
b749a27f86
@ -14,8 +14,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
**/
|
**/
|
||||||
RED.history = (function() {
|
RED.history = (function() {
|
||||||
var undo_history = [];
|
var undoHistory = [];
|
||||||
var redo_history = [];
|
var redoHistory = [];
|
||||||
|
|
||||||
function undoEvent(ev) {
|
function undoEvent(ev) {
|
||||||
var i;
|
var i;
|
||||||
@ -23,20 +23,20 @@ RED.history = (function() {
|
|||||||
var node;
|
var node;
|
||||||
var subflow;
|
var subflow;
|
||||||
var modifiedTabs = {};
|
var modifiedTabs = {};
|
||||||
var inv_ev;
|
var inverseEv;
|
||||||
if (ev) {
|
if (ev) {
|
||||||
if (ev.t == 'multi') {
|
if (ev.t == 'multi') {
|
||||||
inv_ev = {
|
inverseEv = {
|
||||||
t: 'multi',
|
t: 'multi',
|
||||||
events: []
|
events: []
|
||||||
};
|
};
|
||||||
len = ev.events.length;
|
len = ev.events.length;
|
||||||
for (i=len-1;i>=0;i--) {
|
for (i=len-1;i>=0;i--) {
|
||||||
var r = undoEvent(ev.events[i]);
|
var r = undoEvent(ev.events[i]);
|
||||||
inv_ev.events.push(r);
|
inverseEv.events.push(r);
|
||||||
}
|
}
|
||||||
} else if (ev.t == 'replace') {
|
} else if (ev.t == 'replace') {
|
||||||
inv_ev = {
|
inverseEv = {
|
||||||
t: 'replace',
|
t: 'replace',
|
||||||
config: RED.nodes.createCompleteNodeSet(),
|
config: RED.nodes.createCompleteNodeSet(),
|
||||||
changed: [],
|
changed: [],
|
||||||
@ -47,57 +47,57 @@ RED.history = (function() {
|
|||||||
imported[0].forEach(function(n) {
|
imported[0].forEach(function(n) {
|
||||||
if (ev.changed[n.id]) {
|
if (ev.changed[n.id]) {
|
||||||
n.changed = true;
|
n.changed = true;
|
||||||
inv_ev.changed[n.id] = true;
|
inverseEv.changed[n.id] = true;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
RED.nodes.version(ev.rev);
|
RED.nodes.version(ev.rev);
|
||||||
} else if (ev.t == 'add') {
|
} else if (ev.t == 'add') {
|
||||||
inv_ev = {
|
inverseEv = {
|
||||||
t: "delete",
|
t: "delete",
|
||||||
};
|
};
|
||||||
if (ev.nodes) {
|
if (ev.nodes) {
|
||||||
inv_ev.nodes = [];
|
inverseEv.nodes = [];
|
||||||
for (i=0;i<ev.nodes.length;i++) {
|
for (i=0;i<ev.nodes.length;i++) {
|
||||||
node = RED.nodes.node(ev.nodes[i]);
|
node = RED.nodes.node(ev.nodes[i]);
|
||||||
if (node.z) {
|
if (node.z) {
|
||||||
modifiedTabs[node.z] = true;
|
modifiedTabs[node.z] = true;
|
||||||
}
|
}
|
||||||
inv_ev.nodes.push(node);
|
inverseEv.nodes.push(node);
|
||||||
RED.nodes.remove(ev.nodes[i]);
|
RED.nodes.remove(ev.nodes[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ev.links) {
|
if (ev.links) {
|
||||||
inv_ev.links = [];
|
inverseEv.links = [];
|
||||||
for (i=0;i<ev.links.length;i++) {
|
for (i=0;i<ev.links.length;i++) {
|
||||||
inv_ev.links.push(ev.links[i]);
|
inverseEv.links.push(ev.links[i]);
|
||||||
RED.nodes.removeLink(ev.links[i]);
|
RED.nodes.removeLink(ev.links[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ev.workspaces) {
|
if (ev.workspaces) {
|
||||||
inv_ev.workspaces = [];
|
inverseEv.workspaces = [];
|
||||||
for (i=0;i<ev.workspaces.length;i++) {
|
for (i=0;i<ev.workspaces.length;i++) {
|
||||||
var workspaceOrder = RED.nodes.getWorkspaceOrder();
|
var workspaceOrder = RED.nodes.getWorkspaceOrder();
|
||||||
ev.workspaces[i]._index = workspaceOrder.indexOf(ev.workspaces[i].id);
|
ev.workspaces[i]._index = workspaceOrder.indexOf(ev.workspaces[i].id);
|
||||||
inv_ev.workspaces.push(ev.workspaces[i]);
|
inverseEv.workspaces.push(ev.workspaces[i]);
|
||||||
RED.nodes.removeWorkspace(ev.workspaces[i].id);
|
RED.nodes.removeWorkspace(ev.workspaces[i].id);
|
||||||
RED.workspaces.remove(ev.workspaces[i]);
|
RED.workspaces.remove(ev.workspaces[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ev.subflows) {
|
if (ev.subflows) {
|
||||||
inv_ev.subflows = [];
|
inverseEv.subflows = [];
|
||||||
for (i=0;i<ev.subflows.length;i++) {
|
for (i=0;i<ev.subflows.length;i++) {
|
||||||
inv_ev.subflows.push(ev.subflows[i]);
|
inverseEv.subflows.push(ev.subflows[i]);
|
||||||
RED.nodes.removeSubflow(ev.subflows[i]);
|
RED.nodes.removeSubflow(ev.subflows[i]);
|
||||||
RED.workspaces.remove(ev.subflows[i]);
|
RED.workspaces.remove(ev.subflows[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ev.subflow) {
|
if (ev.subflow) {
|
||||||
inv_ev.subflow = {};
|
inverseEv.subflow = {};
|
||||||
if (ev.subflow.instances) {
|
if (ev.subflow.instances) {
|
||||||
inv_ev.subflow.instances = [];
|
inverseEv.subflow.instances = [];
|
||||||
ev.subflow.instances.forEach(function(n) {
|
ev.subflow.instances.forEach(function(n) {
|
||||||
inv_ev.subflow.instances.push(n);
|
inverseEv.subflow.instances.push(n);
|
||||||
var node = RED.nodes.node(n.id);
|
var node = RED.nodes.node(n.id);
|
||||||
if (node) {
|
if (node) {
|
||||||
node.changed = n.changed;
|
node.changed = n.changed;
|
||||||
@ -113,30 +113,30 @@ RED.history = (function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ev.removedLinks) {
|
if (ev.removedLinks) {
|
||||||
inv_ev.createdLinks = [];
|
inverseEv.createdLinks = [];
|
||||||
for (i=0;i<ev.removedLinks.length;i++) {
|
for (i=0;i<ev.removedLinks.length;i++) {
|
||||||
inv_ev.createdLinks.push(ev.removedLinks[i]);
|
inverseEv.createdLinks.push(ev.removedLinks[i]);
|
||||||
RED.nodes.addLink(ev.removedLinks[i]);
|
RED.nodes.addLink(ev.removedLinks[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (ev.t == "delete") {
|
} else if (ev.t == "delete") {
|
||||||
inv_ev = {
|
inverseEv = {
|
||||||
t: "add"
|
t: "add"
|
||||||
};
|
};
|
||||||
if (ev.workspaces) {
|
if (ev.workspaces) {
|
||||||
inv_ev.workspaces = [];
|
inverseEv.workspaces = [];
|
||||||
for (i=0;i<ev.workspaces.length;i++) {
|
for (i=0;i<ev.workspaces.length;i++) {
|
||||||
inv_ev.workspaces.push(ev.workspaces[i]);
|
inverseEv.workspaces.push(ev.workspaces[i]);
|
||||||
RED.nodes.addWorkspace(ev.workspaces[i],ev.workspaces[i]._index);
|
RED.nodes.addWorkspace(ev.workspaces[i],ev.workspaces[i]._index);
|
||||||
RED.workspaces.add(ev.workspaces[i],undefined,ev.workspaces[i]._index);
|
RED.workspaces.add(ev.workspaces[i],undefined,ev.workspaces[i]._index);
|
||||||
delete ev.workspaces[i]._index;
|
delete ev.workspaces[i]._index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ev.subflows) {
|
if (ev.subflows) {
|
||||||
inv_ev.subflows = [];
|
inverseEv.subflows = [];
|
||||||
for (i=0;i<ev.subflows.length;i++) {
|
for (i=0;i<ev.subflows.length;i++) {
|
||||||
inv_ev.subflows.push(ev.subflows[i]);
|
inverseEv.subflows.push(ev.subflows[i]);
|
||||||
RED.nodes.addSubflow(ev.subflows[i]);
|
RED.nodes.addSubflow(ev.subflows[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -165,11 +165,11 @@ RED.history = (function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ev.subflow) {
|
if (ev.subflow) {
|
||||||
inv_ev.subflow = {};
|
inverseEv.subflow = {};
|
||||||
if (ev.subflow.hasOwnProperty('instances')) {
|
if (ev.subflow.hasOwnProperty('instances')) {
|
||||||
inv_ev.subflow.instances = [];
|
inverseEv.subflow.instances = [];
|
||||||
ev.subflow.instances.forEach(function(n) {
|
ev.subflow.instances.forEach(function(n) {
|
||||||
inv_ev.subflow.instances.push(n);
|
inverseEv.subflow.instances.push(n);
|
||||||
var node = RED.nodes.node(n.id);
|
var node = RED.nodes.node(n.id);
|
||||||
if (node) {
|
if (node) {
|
||||||
node.changed = n.changed;
|
node.changed = n.changed;
|
||||||
@ -194,24 +194,24 @@ RED.history = (function() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (ev.nodes) {
|
if (ev.nodes) {
|
||||||
inv_ev.nodes = [];
|
inverseEv.nodes = [];
|
||||||
for (i=0;i<ev.nodes.length;i++) {
|
for (i=0;i<ev.nodes.length;i++) {
|
||||||
RED.nodes.add(ev.nodes[i]);
|
RED.nodes.add(ev.nodes[i]);
|
||||||
modifiedTabs[ev.nodes[i].z] = true;
|
modifiedTabs[ev.nodes[i].z] = true;
|
||||||
inv_ev.nodes.push(ev.nodes[i].id);
|
inverseEv.nodes.push(ev.nodes[i].id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ev.links) {
|
if (ev.links) {
|
||||||
inv_ev.links = [];
|
inverseEv.links = [];
|
||||||
for (i=0;i<ev.links.length;i++) {
|
for (i=0;i<ev.links.length;i++) {
|
||||||
RED.nodes.addLink(ev.links[i]);
|
RED.nodes.addLink(ev.links[i]);
|
||||||
inv_ev.links.push(ev.links[i]);
|
inverseEv.links.push(ev.links[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ev.createdLinks) {
|
if (ev.createdLinks) {
|
||||||
inv_ev.removedLinks = [];
|
inverseEv.removedLinks = [];
|
||||||
for (i=0;i<ev.createdLinks.length;i++) {
|
for (i=0;i<ev.createdLinks.length;i++) {
|
||||||
inv_ev.removedLinks.push(ev.createdLinks[i]);
|
inverseEv.removedLinks.push(ev.createdLinks[i]);
|
||||||
RED.nodes.removeLink(ev.createdLinks[i]);
|
RED.nodes.removeLink(ev.createdLinks[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -232,14 +232,14 @@ RED.history = (function() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
} else if (ev.t == "move") {
|
} else if (ev.t == "move") {
|
||||||
inv_ev = {
|
inverseEv = {
|
||||||
t: 'move',
|
t: 'move',
|
||||||
nodes: []
|
nodes: []
|
||||||
};
|
};
|
||||||
for (i=0;i<ev.nodes.length;i++) {
|
for (i=0;i<ev.nodes.length;i++) {
|
||||||
var n = ev.nodes[i];
|
var n = ev.nodes[i];
|
||||||
var rn = {n: n.n, ox: n.n.x, oy: n.n.y, dirty: true, moved: n.moved};
|
var rn = {n: n.n, ox: n.n.x, oy: n.n.y, dirty: true, moved: n.moved};
|
||||||
inv_ev.nodes.push(rn);
|
inverseEv.nodes.push(rn);
|
||||||
n.n.x = n.ox;
|
n.n.x = n.ox;
|
||||||
n.n.y = n.oy;
|
n.n.y = n.oy;
|
||||||
n.n.dirty = true;
|
n.n.dirty = true;
|
||||||
@ -247,28 +247,28 @@ RED.history = (function() {
|
|||||||
}
|
}
|
||||||
// A move could have caused a link splice
|
// A move could have caused a link splice
|
||||||
if (ev.links) {
|
if (ev.links) {
|
||||||
inv_ev.removedLinks = [];
|
inverseEv.removedLinks = [];
|
||||||
for (i=0;i<ev.links.length;i++) {
|
for (i=0;i<ev.links.length;i++) {
|
||||||
inv_ev.removedLinks.push(ev.links[i]);
|
inverseEv.removedLinks.push(ev.links[i]);
|
||||||
RED.nodes.removeLink(ev.links[i]);
|
RED.nodes.removeLink(ev.links[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ev.removedLinks) {
|
if (ev.removedLinks) {
|
||||||
inv_ev.links = [];
|
inverseEv.links = [];
|
||||||
for (i=0;i<ev.removedLinks.length;i++) {
|
for (i=0;i<ev.removedLinks.length;i++) {
|
||||||
inv_ev.links.push(ev.removedLinks[i]);
|
inverseEv.links.push(ev.removedLinks[i]);
|
||||||
RED.nodes.addLink(ev.removedLinks[i]);
|
RED.nodes.addLink(ev.removedLinks[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (ev.t == "edit") {
|
} else if (ev.t == "edit") {
|
||||||
inv_ev = {
|
inverseEv = {
|
||||||
t: "edit",
|
t: "edit",
|
||||||
changes: {}
|
changes: {}
|
||||||
};
|
};
|
||||||
inv_ev.node = ev.node;
|
inverseEv.node = ev.node;
|
||||||
for (i in ev.changes) {
|
for (i in ev.changes) {
|
||||||
if (ev.changes.hasOwnProperty(i)) {
|
if (ev.changes.hasOwnProperty(i)) {
|
||||||
inv_ev.changes[i] = ev.node[i];
|
inverseEv.changes[i] = ev.node[i];
|
||||||
if (ev.node._def.defaults && ev.node._def.defaults[i] && ev.node._def.defaults[i].type) {
|
if (ev.node._def.defaults && ev.node._def.defaults[i] && ev.node._def.defaults[i].type) {
|
||||||
// This is a config node property
|
// This is a config node property
|
||||||
var currentConfigNode = RED.nodes.node(ev.node[i]);
|
var currentConfigNode = RED.nodes.node(ev.node[i]);
|
||||||
@ -288,29 +288,29 @@ RED.history = (function() {
|
|||||||
$("#red-ui-workspace").toggleClass("red-ui-workspace-disabled",!!ev.node.disabled);
|
$("#red-ui-workspace").toggleClass("red-ui-workspace-disabled",!!ev.node.disabled);
|
||||||
}
|
}
|
||||||
if (ev.subflow) {
|
if (ev.subflow) {
|
||||||
inv_ev.subflow = {};
|
inverseEv.subflow = {};
|
||||||
if (ev.subflow.hasOwnProperty('inputCount')) {
|
if (ev.subflow.hasOwnProperty('inputCount')) {
|
||||||
inv_ev.subflow.inputCount = ev.node.in.length;
|
inverseEv.subflow.inputCount = ev.node.in.length;
|
||||||
if (ev.node.in.length > ev.subflow.inputCount) {
|
if (ev.node.in.length > ev.subflow.inputCount) {
|
||||||
inv_ev.subflow.inputs = ev.node.in.slice(ev.subflow.inputCount);
|
inverseEv.subflow.inputs = ev.node.in.slice(ev.subflow.inputCount);
|
||||||
ev.node.in.splice(ev.subflow.inputCount);
|
ev.node.in.splice(ev.subflow.inputCount);
|
||||||
} else if (ev.subflow.inputs.length > 0) {
|
} else if (ev.subflow.inputs.length > 0) {
|
||||||
ev.node.in = ev.node.in.concat(ev.subflow.inputs);
|
ev.node.in = ev.node.in.concat(ev.subflow.inputs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ev.subflow.hasOwnProperty('outputCount')) {
|
if (ev.subflow.hasOwnProperty('outputCount')) {
|
||||||
inv_ev.subflow.outputCount = ev.node.out.length;
|
inverseEv.subflow.outputCount = ev.node.out.length;
|
||||||
if (ev.node.out.length > ev.subflow.outputCount) {
|
if (ev.node.out.length > ev.subflow.outputCount) {
|
||||||
inv_ev.subflow.outputs = ev.node.out.slice(ev.subflow.outputCount);
|
inverseEv.subflow.outputs = ev.node.out.slice(ev.subflow.outputCount);
|
||||||
ev.node.out.splice(ev.subflow.outputCount);
|
ev.node.out.splice(ev.subflow.outputCount);
|
||||||
} else if (ev.subflow.outputs.length > 0) {
|
} else if (ev.subflow.outputs.length > 0) {
|
||||||
ev.node.out = ev.node.out.concat(ev.subflow.outputs);
|
ev.node.out = ev.node.out.concat(ev.subflow.outputs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ev.subflow.hasOwnProperty('instances')) {
|
if (ev.subflow.hasOwnProperty('instances')) {
|
||||||
inv_ev.subflow.instances = [];
|
inverseEv.subflow.instances = [];
|
||||||
ev.subflow.instances.forEach(function(n) {
|
ev.subflow.instances.forEach(function(n) {
|
||||||
inv_ev.subflow.instances.push(n);
|
inverseEv.subflow.instances.push(n);
|
||||||
var node = RED.nodes.node(n.id);
|
var node = RED.nodes.node(n.id);
|
||||||
if (node) {
|
if (node) {
|
||||||
node.changed = n.changed;
|
node.changed = n.changed;
|
||||||
@ -334,11 +334,11 @@ RED.history = (function() {
|
|||||||
var outputMap;
|
var outputMap;
|
||||||
if (ev.outputMap) {
|
if (ev.outputMap) {
|
||||||
outputMap = {};
|
outputMap = {};
|
||||||
inv_ev.outputMap = {};
|
inverseEv.outputMap = {};
|
||||||
for (var port in ev.outputMap) {
|
for (var port in ev.outputMap) {
|
||||||
if (ev.outputMap.hasOwnProperty(port) && ev.outputMap[port] !== "-1") {
|
if (ev.outputMap.hasOwnProperty(port) && ev.outputMap[port] !== "-1") {
|
||||||
outputMap[ev.outputMap[port]] = port;
|
outputMap[ev.outputMap[port]] = port;
|
||||||
inv_ev.outputMap[ev.outputMap[port]] = port;
|
inverseEv.outputMap[ev.outputMap[port]] = port;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -346,84 +346,78 @@ RED.history = (function() {
|
|||||||
RED.editor.validateNode(ev.node);
|
RED.editor.validateNode(ev.node);
|
||||||
}
|
}
|
||||||
if (ev.links) {
|
if (ev.links) {
|
||||||
inv_ev.createdLinks = [];
|
inverseEv.createdLinks = [];
|
||||||
for (i=0;i<ev.links.length;i++) {
|
for (i=0;i<ev.links.length;i++) {
|
||||||
RED.nodes.addLink(ev.links[i]);
|
RED.nodes.addLink(ev.links[i]);
|
||||||
inv_ev.createdLinks.push(ev.links[i]);
|
inverseEv.createdLinks.push(ev.links[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ev.createdLinks) {
|
if (ev.createdLinks) {
|
||||||
inv_ev.links = [];
|
inverseEv.links = [];
|
||||||
for (i=0;i<ev.createdLinks.length;i++) {
|
for (i=0;i<ev.createdLinks.length;i++) {
|
||||||
RED.nodes.removeLink(ev.createdLinks[i]);
|
RED.nodes.removeLink(ev.createdLinks[i]);
|
||||||
inv_ev.links.push(ev.createdLinks[i]);
|
inverseEv.links.push(ev.createdLinks[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ev.node.dirty = true;
|
ev.node.dirty = true;
|
||||||
ev.node.changed = ev.changed;
|
ev.node.changed = ev.changed;
|
||||||
} else if (ev.t == "createSubflow") {
|
} else if (ev.t == "createSubflow") {
|
||||||
inv_ev = {
|
inverseEv = {
|
||||||
t: "deleteSubflow",
|
t: "deleteSubflow",
|
||||||
activeWorkspace: ev.activeWorkspace,
|
activeWorkspace: ev.activeWorkspace,
|
||||||
dirty: RED.nodes.dirty()
|
dirty: RED.nodes.dirty()
|
||||||
};
|
};
|
||||||
if (ev.nodes) {
|
if (ev.nodes) {
|
||||||
<<<<<<< HEAD
|
inverseEv.movedNodes = [];
|
||||||
inv_ev.movedNodes = [];
|
|
||||||
=======
|
|
||||||
var z = ev.activeWorkspace;
|
var z = ev.activeWorkspace;
|
||||||
>>>>>>> upstream/dev
|
|
||||||
RED.nodes.filterNodes({z:ev.subflow.subflow.id}).forEach(function(n) {
|
RED.nodes.filterNodes({z:ev.subflow.subflow.id}).forEach(function(n) {
|
||||||
n.x += ev.subflow.offsetX;
|
n.x += ev.subflow.offsetX;
|
||||||
n.y += ev.subflow.offsetY;
|
n.y += ev.subflow.offsetY;
|
||||||
n.z = ev.activeWorkspace;
|
n.z = ev.activeWorkspace;
|
||||||
n.dirty = true;
|
n.dirty = true;
|
||||||
<<<<<<< HEAD
|
inverseEv.movedNodes.push(n.id);
|
||||||
inv_ev.movedNodes.push(n.id);
|
|
||||||
=======
|
|
||||||
RED.nodes.moveNodeToTab(n, z);
|
RED.nodes.moveNodeToTab(n, z);
|
||||||
>>>>>>> upstream/dev
|
|
||||||
});
|
});
|
||||||
inv_ev.subflows = [];
|
inverseEv.subflows = [];
|
||||||
for (i=0;i<ev.nodes.length;i++) {
|
for (i=0;i<ev.nodes.length;i++) {
|
||||||
inv_ev.subflows.push(RED.nodes.node(ev.nodes[i]));
|
inverseEv.subflows.push(RED.nodes.node(ev.nodes[i]));
|
||||||
RED.nodes.remove(ev.nodes[i]);
|
RED.nodes.remove(ev.nodes[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ev.links) {
|
if (ev.links) {
|
||||||
inv_ev.links = [];
|
inverseEv.links = [];
|
||||||
for (i=0;i<ev.links.length;i++) {
|
for (i=0;i<ev.links.length;i++) {
|
||||||
inv_ev.links.push(ev.links[i]);
|
inverseEv.links.push(ev.links[i]);
|
||||||
RED.nodes.removeLink(ev.links[i]);
|
RED.nodes.removeLink(ev.links[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inv_ev.subflow = ev.subflow;
|
inverseEv.subflow = ev.subflow;
|
||||||
RED.nodes.removeSubflow(ev.subflow.subflow);
|
RED.nodes.removeSubflow(ev.subflow.subflow);
|
||||||
RED.workspaces.remove(ev.subflow.subflow);
|
RED.workspaces.remove(ev.subflow.subflow);
|
||||||
|
|
||||||
if (ev.removedLinks) {
|
if (ev.removedLinks) {
|
||||||
inv_ev.createdLinks = [];
|
inverseEv.createdLinks = [];
|
||||||
for (i=0;i<ev.removedLinks.length;i++) {
|
for (i=0;i<ev.removedLinks.length;i++) {
|
||||||
inv_ev.createdLinks.push(ev.removedLinks[i]);
|
inverseEv.createdLinks.push(ev.removedLinks[i]);
|
||||||
RED.nodes.addLink(ev.removedLinks[i]);
|
RED.nodes.addLink(ev.removedLinks[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (ev.t == "deleteSubflow") {
|
} else if (ev.t == "deleteSubflow") {
|
||||||
inv_ev = {
|
inverseEv = {
|
||||||
t: "createSubflow",
|
t: "createSubflow",
|
||||||
activeWorkspace: ev.activeWorkspace,
|
activeWorkspace: ev.activeWorkspace,
|
||||||
ditry: RED.nodes.dirty(),
|
ditry: RED.nodes.dirty(),
|
||||||
};
|
};
|
||||||
if (ev.subflow) {
|
if (ev.subflow) {
|
||||||
RED.nodes.addSubflow(ev.subflow.subflow);
|
RED.nodes.addSubflow(ev.subflow.subflow);
|
||||||
inv_ev.subflow = ev.subflow;
|
inverseEv.subflow = ev.subflow;
|
||||||
}
|
}
|
||||||
if (ev.subflows) {
|
if (ev.subflows) {
|
||||||
inv_ev.nodes = [];
|
inverseEv.nodes = [];
|
||||||
for (i=0;i<ev.subflows.length;i++) {
|
for (i=0;i<ev.subflows.length;i++) {
|
||||||
RED.nodes.add(ev.subflows[i]);
|
RED.nodes.add(ev.subflows[i]);
|
||||||
inv_ev.nodes.push(ev.subflows[i].id);
|
inverseEv.nodes.push(ev.subflows[i].id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ev.movedNodes) {
|
if (ev.movedNodes) {
|
||||||
@ -436,21 +430,21 @@ RED.history = (function() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (ev.links) {
|
if (ev.links) {
|
||||||
inv_ev.links = [];
|
inverseEv.links = [];
|
||||||
for (i=0;i<ev.links.length;i++) {
|
for (i=0;i<ev.links.length;i++) {
|
||||||
inv_ev.links.push(ev.links[i]);
|
inverseEv.links.push(ev.links[i]);
|
||||||
RED.nodes.addLink(ev.links[i]);
|
RED.nodes.addLink(ev.links[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ev.createdLinks) {
|
if (ev.createdLinks) {
|
||||||
inv_ev.removedLinks = [];
|
inverseEv.removedLinks = [];
|
||||||
for (i=0;i<ev.createdLinks.length;i++) {
|
for (i=0;i<ev.createdLinks.length;i++) {
|
||||||
inv_ev.removedLinks.push(ev.createdLinks[i]);
|
inverseEv.removedLinks.push(ev.createdLinks[i]);
|
||||||
RED.nodes.removeLink(ev.createdLinks[i]);
|
RED.nodes.removeLink(ev.createdLinks[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (ev.t == "reorder") {
|
} else if (ev.t == "reorder") {
|
||||||
inv_ev = {
|
inverseEv = {
|
||||||
t: 'reorder',
|
t: 'reorder',
|
||||||
order: RED.nodes.getWorkspaceOrder()
|
order: RED.nodes.getWorkspaceOrder()
|
||||||
};
|
};
|
||||||
@ -474,7 +468,7 @@ RED.history = (function() {
|
|||||||
RED.sidebar.config.refresh();
|
RED.sidebar.config.refresh();
|
||||||
RED.subflow.refresh();
|
RED.subflow.refresh();
|
||||||
|
|
||||||
return inv_ev;
|
return inverseEv;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -482,40 +476,40 @@ RED.history = (function() {
|
|||||||
return {
|
return {
|
||||||
//TODO: this function is a placeholder until there is a 'save' event that can be listened to
|
//TODO: this function is a placeholder until there is a 'save' event that can be listened to
|
||||||
markAllDirty: function() {
|
markAllDirty: function() {
|
||||||
for (var i=0;i<undo_history.length;i++) {
|
for (var i=0;i<undoHistory.length;i++) {
|
||||||
undo_history[i].dirty = true;
|
undoHistory[i].dirty = true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
list: function() {
|
list: function() {
|
||||||
return undo_history;
|
return undoHistory;
|
||||||
},
|
},
|
||||||
depth: function() {
|
depth: function() {
|
||||||
return undo_history.length;
|
return undoHistory.length;
|
||||||
},
|
},
|
||||||
push: function(ev) {
|
push: function(ev) {
|
||||||
undo_history.push(ev);
|
undoHistory.push(ev);
|
||||||
redo_history = [];
|
redoHistory = [];
|
||||||
},
|
},
|
||||||
pop: function() {
|
pop: function() {
|
||||||
var ev = undo_history.pop();
|
var ev = undoHistory.pop();
|
||||||
var rev = undoEvent(ev);
|
var rev = undoEvent(ev);
|
||||||
if (rev) {
|
if (rev) {
|
||||||
redo_history.push(rev);
|
redoHistory.push(rev);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
peek: function() {
|
peek: function() {
|
||||||
return undo_history[undo_history.length-1];
|
return undoHistory[undoHistory.length-1];
|
||||||
},
|
},
|
||||||
clear: function() {
|
clear: function() {
|
||||||
undo_history = [];
|
undoHistory = [];
|
||||||
redo_history = [];
|
redoHistory = [];
|
||||||
},
|
},
|
||||||
redo: function() {
|
redo: function() {
|
||||||
var ev = redo_history.pop();
|
var ev = redoHistory.pop();
|
||||||
if (ev) {
|
if (ev) {
|
||||||
var uev = undoEvent(ev);
|
var uev = undoEvent(ev);
|
||||||
if (uev) {
|
if (uev) {
|
||||||
undo_history.push(uev);
|
undoHistory.push(uev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
"delete": "core:delete-config-selection",
|
"delete": "core:delete-config-selection",
|
||||||
"ctrl-a": "core:select-all-config-nodes",
|
"ctrl-a": "core:select-all-config-nodes",
|
||||||
"ctrl-z": "core:undo",
|
"ctrl-z": "core:undo",
|
||||||
"ctrl-shift-z": "core:redo"
|
"ctrl-y": "core:redo"
|
||||||
},
|
},
|
||||||
"red-ui-workspace": {
|
"red-ui-workspace": {
|
||||||
"backspace": "core:delete-selection",
|
"backspace": "core:delete-selection",
|
||||||
@ -41,6 +41,7 @@
|
|||||||
"ctrl-x": "core:cut-selection-to-internal-clipboard",
|
"ctrl-x": "core:cut-selection-to-internal-clipboard",
|
||||||
"ctrl-v": "core:paste-from-internal-clipboard",
|
"ctrl-v": "core:paste-from-internal-clipboard",
|
||||||
"ctrl-z": "core:undo",
|
"ctrl-z": "core:undo",
|
||||||
|
"ctrl-y": "core:redo",
|
||||||
"ctrl-a": "core:select-all-nodes",
|
"ctrl-a": "core:select-all-nodes",
|
||||||
"shift-?": "core:show-help",
|
"shift-?": "core:show-help",
|
||||||
"up": "core:move-selection-up",
|
"up": "core:move-selection-up",
|
||||||
@ -52,7 +53,6 @@
|
|||||||
"shift-down": "core:step-selection-down",
|
"shift-down": "core:step-selection-down",
|
||||||
"shift-left": "core:step-selection-left",
|
"shift-left": "core:step-selection-left",
|
||||||
"ctrl-shift-j": "core:show-previous-tab",
|
"ctrl-shift-j": "core:show-previous-tab",
|
||||||
"ctrl-shift-k": "core:show-next-tab",
|
"ctrl-shift-k": "core:show-next-tab"
|
||||||
"ctrl-shift-z": "core:redo"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user