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

Add go-to-previous/next-location actions

This commit is contained in:
Nick O'Leary 2021-03-06 23:20:53 +00:00
parent 99a9e3a91b
commit 5181890433
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
3 changed files with 35 additions and 3 deletions

View File

@ -66,6 +66,8 @@
"shift-left": "core:step-selection-left",
"ctrl-shift-j": "core:show-previous-tab",
"ctrl-shift-k": "core:show-next-tab",
"ctrl-shift-left": "core:go-to-previous-location",
"ctrl-shift-right": "core:go-to-next-location",
"ctrl-shift-g": "core:group-selection",
"ctrl-shift-u": "core:ungroup-selection",
"ctrl-shift-c": "core:copy-group-style",

View File

@ -249,7 +249,7 @@ var RED = (function() {
RED.nodes.dirty(false);
RED.view.redraw(true);
if (/^#flow\/.+$/.test(currentHash)) {
RED.workspaces.show(currentHash.substring(6));
RED.workspaces.show(currentHash.substring(6),true);
}
} catch(err) {
console.warn(err);

View File

@ -20,6 +20,9 @@ RED.workspaces = (function() {
var activeWorkspace = 0;
var workspaceIndex = 0;
var viewStack = [];
var viewStackPos = 0;
function addWorkspace(ws,skipHistoryEntry,targetIndex) {
if (ws) {
workspace_tabs.addTab(ws,targetIndex);
@ -245,6 +248,11 @@ RED.workspaces = (function() {
RED.view.focus();
},
onclick: function(tab) {
if (viewStackPos !== viewStack.length) {
viewStack.splice(viewStackPos);
}
viewStack.push(activeWorkspace);
viewStackPos = viewStack.length;
RED.view.focus();
},
ondblclick: function(tab) {
@ -349,6 +357,21 @@ RED.workspaces = (function() {
RED.actions.invoke("core:search","type:tab ");
})
RED.actions.add("core:go-to-previous-location", function() {
if (viewStackPos > 0) {
if (viewStackPos === viewStack.length) {
viewStack.push(activeWorkspace);
}
RED.workspaces.show(viewStack[--viewStackPos],true);
}
})
RED.actions.add("core:go-to-next-location", function() {
if (viewStackPos < viewStack.length - 1) {
RED.workspaces.show(viewStack[++viewStackPos],true);
}
})
hideWorkspace();
}
@ -444,7 +467,7 @@ RED.workspaces = (function() {
selection: function() {
return workspace_tabs.selection();
},
show: function(id) {
show: function(id,skipStack) {
if (!workspace_tabs.contains(id)) {
var sf = RED.nodes.subflow(id);
if (sf) {
@ -453,6 +476,13 @@ RED.workspaces = (function() {
return;
}
}
if (!skipStack) {
if (viewStackPos !== viewStack.length) {
viewStack.splice(viewStackPos);
}
viewStack.push(activeWorkspace);
viewStackPos = viewStack.length;
}
workspace_tabs.activateTab(id);
},
refresh: function() {