Add several click-outside-edit-tray behaviours

pull/5385/head
GogoVega 2025-12-13 14:28:51 +01:00
parent 6a75a084ad
commit 2334b34541
No known key found for this signature in database
GPG Key ID: E1E048B63AC5AC2B
4 changed files with 31 additions and 3 deletions

View File

@ -160,7 +160,13 @@
"moveToBack": "Move to back",
"moveToFront": "Move to front",
"moveBackwards": "Move backwards",
"moveForwards": "Move forwards"
"moveForwards": "Move forwards",
"clickOutsideEditTray": "Click behavior outside the edit tray",
"clickOptions": {
"nothing": "Do nothing",
"discard": "Discard changes and close",
"save": "Save changes and close"
}
}
},
"actions": {

View File

@ -160,7 +160,13 @@
"moveToBack": "Déplacer vers l'arrière",
"moveToFront": "Déplacer vers l'avant",
"moveBackwards": "Reculer",
"moveForwards": "Avancer"
"moveForwards": "Avancer",
"clickOutsideEditTray": "Comportement du clic en dehors de la zone d'édition",
"clickOptions": {
"nothing": "Ne rien faire",
"discard": "Annuler les modifications et fermer",
"save": "Enregistrer les modifications et fermer"
}
}
},
"actions": {

View File

@ -230,6 +230,21 @@
editorStack = $("#red-ui-editor-stack");
$(window).on("resize", handleWindowResize);
RED.events.on("sidebar:resize",handleWindowResize);
$("#red-ui-editor-shade").on("click", function () {
if (openingTray) { return; }
const clickOutsideEditTray = RED.settings.get("editor.view.click-outside-edit-tray", "save");
if (clickOutsideEditTray !== "nothing") {
const tray = stack[stack.length - 1];
if (tray && clickOutsideEditTray === "discard") {
RED.actions.invoke("core:cancel-edit-tray");
} else if (tray && clickOutsideEditTray === "save") {
if (tray.primaryButton) {
tray.primaryButton.click();
}
}
}
});
},
show: function show(options) {
lowerTrayZ();

View File

@ -141,7 +141,8 @@ RED.userSettings = (function() {
options: [
{setting:"view-node-status",oldSetting:"menu-menu-item-status",label:"menu.label.displayStatus",default: true, toggle:true,onchange:"core:toggle-status"},
{setting:"view-node-info-icon", label:"menu.label.displayInfoIcon", default: true, toggle:true,onchange:"core:toggle-node-info-icon"},
{setting:"view-node-show-label",label:"menu.label.showNodeLabelDefault",default: true, toggle:true}
{setting:"view-node-show-label",label:"menu.label.showNodeLabelDefault",default: true, toggle:true},
{ setting: "click-outside-edit-tray", label: "menu.label.clickOutsideEditTray", default: "nothing", options: (done) => done(["nothing", "discard", "save"].map((option) => ({ val: option, text: RED._("menu.label.clickOptions." + option) }))) }
]
},
{