Add select-connected action

This commit is contained in:
Nick O'Leary 2021-02-16 21:16:21 +00:00
parent d5314d2a85
commit 35f788693d
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
2 changed files with 18 additions and 0 deletions

View File

@ -46,6 +46,8 @@
"ctrl-a": "core:select-all-nodes",
"alt-s u": "core:select-upstream-nodes",
"alt-s d": "core:select-downstream-nodes",
"alt-s c": "core:select-connected-nodes",
"alt-s d": "core:select-downstream-nodes",
"shift-?": "core:show-help",
"w": "core:scroll-view-up",
"d": "core:scroll-view-right",

View File

@ -16,6 +16,21 @@
RED.view.tools = (function() {
function selectAllConnected() {
console.log(args);
var selection = RED.view.selection();
var visited = new Set();
if (selection.nodes && selection.nodes.length > 0) {
selection.nodes.forEach(function(n) {
if (!visited.has(n)) {
var connected = RED.nodes.getAllFlowNodes(n);
connected.forEach(function(nn) { visited.add(nn) })
}
});
RED.view.select({nodes:Array.from(visited)});
}
}
function selectDownstream() {
selectStream('source','target')
@ -241,6 +256,7 @@ RED.view.tools = (function() {
RED.actions.add("core:step-selection-down", function() { moveSelection(0,RED.view.gridSize());});
RED.actions.add("core:step-selection-left", function() { moveSelection(-RED.view.gridSize(),0);});
RED.actions.add("core:select-connected-nodes", selectAllConnected);
RED.actions.add("core:select-downstream-nodes", selectDownstream);
RED.actions.add("core:select-upstream-nodes", selectUpstream);
},