Remove suggestedFlow actions and hardcode key handling

This commit is contained in:
Nick O'Leary
2025-06-25 13:43:13 +01:00
parent 412d47b303
commit 1717e0f39b
2 changed files with 20 additions and 23 deletions

View File

@@ -91,8 +91,7 @@
"alt-shift-w": "core:show-last-hidden-flow",
"ctrl-+": "core:zoom-in",
"ctrl--": "core:zoom-out",
"ctrl-0": "core:zoom-reset",
"tab": "core:apply-suggested-flow"
"ctrl-0": "core:zoom-reset"
},
"red-ui-editor-stack": {
"ctrl-enter": "core:confirm-edit-tray",

View File

@@ -876,19 +876,6 @@ RED.view = (function() {
}
})
RED.actions.add("core:apply-suggested-flow", function() {
// TypeSeach will handle this if it is visible; don't want to cause conflicts
if (!RED.typeSearch.isVisible()) {
RED.view.applySuggestedFlow();
}
})
RED.actions.add("core:clear-suggested-flow", function() {
// TypeSeach will handle this if it is visible; don't want to cause conflicts
if (!RED.typeSearch.isVisible()) {
RED.view.setSuggestedFlow(null);
}
})
RED.view.annotations.init();
RED.view.navigator.init();
RED.view.tools.init();
@@ -6526,6 +6513,7 @@ RED.view = (function() {
* @param {Object} suggestion - The suggestion object
*/
function setSuggestedFlow (suggestion) {
$(window).off('keydown.suggestedFlow')
if (!currentSuggestion && !suggestion) {
// Avoid unnecessary redraws
return
@@ -6650,7 +6638,22 @@ RED.view = (function() {
__ghost: true
})
}
$(window).on('keyup',disableSuggestedFlowEventHandler);
if (!RED.typeSearch.isVisible()) {
$(window).on('keydown.suggestedFlow', function (evt) {
console.log('kd')
if (evt.keyCode === 9) { // tab
applySuggestedFlow();
} else {
clearSuggestedFlow();
RED.view.redraw(true);
}
});
}
if (suggestion.clickToApply) {
$(window).on('mousedown.suggestedFlow', function (evnt) {
clearSuggestedFlow();
})
}
}
if (ghostNode) {
if (suggestedNodes.length > 0) {
@@ -6663,7 +6666,8 @@ RED.view = (function() {
}
function clearSuggestedFlow () {
$(window).off('keyup', disableSuggestedFlowEventHandler)
$(window).off('mousedown.suggestedFlow');
$(window).off('keydown.suggestedFlow')
currentSuggestion = null
suggestedNodes = []
suggestedLinks = []
@@ -6709,12 +6713,6 @@ RED.view = (function() {
}
}
function disableSuggestedFlowEventHandler(evt) {
if (evt.keyCode === 27) { // ESCAPE
RED.actions.invoke("core:clear-suggested-flow")
}
}
return {
init: init,
state:function(state) {