Add escape to clear suggested flow

This commit is contained in:
Nick O'Leary
2025-06-23 10:08:27 +01:00
parent 4967de8e5b
commit 63b4615e78
2 changed files with 24 additions and 2 deletions

View File

@@ -539,9 +539,10 @@ RED.typeSearch = (function() {
}
return {
show: show,
show,
refresh: refreshTypeList,
hide: hide
hide,
isVisible: () => visible
};
})();

View File

@@ -876,6 +876,19 @@ 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();
@@ -6613,6 +6626,7 @@ RED.view = (function() {
__ghost: true
})
}
$(window).on('keyup',disableSuggestedFlowEventHandler);
}
if (ghostNode) {
if (suggestedNodes.length > 0) {
@@ -6625,6 +6639,7 @@ RED.view = (function() {
}
function clearSuggestedFlow () {
$(window).off('keyup', disableSuggestedFlowEventHandler)
currentSuggestion = null
suggestedNodes = []
suggestedLinks = []
@@ -6670,6 +6685,12 @@ RED.view = (function() {
}
}
function disableSuggestedFlowEventHandler(evt) {
if (evt.keyCode === 27) { // ESCAPE
RED.actions.invoke("core:clear-suggested-flow")
}
}
return {
init: init,
state:function(state) {