Add commands to toggle visibility of manager and custom nodes manager menus (#1505)

* Add commands for manager keybindings

* use more consistent isVisible condition check

* remove hide method in favor of super class's close method

* fix formatting

* fix tabs formatting
This commit is contained in:
bymyself 2025-02-01 22:37:04 -07:00 committed by GitHub
parent cf0d038978
commit 2e55bc470c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 51 additions and 0 deletions

View File

@ -1275,10 +1275,22 @@ class ManagerMenuDialog extends ComfyDialog {
this.element = $el("div.comfy-modal", { id:'cm-manager-dialog', parent: document.body }, [ content ]);
}
get isVisible() {
return this.element?.style?.display !== "none";
}
show() {
this.element.style.display = "block";
}
toggleVisibility() {
if (this.isVisible) {
this.close();
} else {
this.show();
}
}
handleWorkflowGalleryButtonClick(e) {
e.preventDefault();
e.stopPropagation();
@ -1396,6 +1408,41 @@ app.registerExtension({
}
],
commands: [
{
id: "Comfy.Manager.Menu.ToggleVisibility",
label: "Toggle Manager Menu Visibility",
icon: "mdi mdi-puzzle",
function: () => {
if (!manager_instance) {
setManagerInstance(new ManagerMenuDialog());
manager_instance.show();
} else {
manager_instance.toggleVisibility();
}
},
},
{
id: "Comfy.Manager.CustomNodesManager.ToggleVisibility",
label: "Toggle Custom Nodes Manager Visibility",
icon: "pi pi-server",
function: () => {
if (CustomNodesManager.instance?.isVisible) {
CustomNodesManager.instance.close();
return;
}
if (!manager_instance) {
setManagerInstance(new ManagerMenuDialog());
}
if (!CustomNodesManager.instance) {
CustomNodesManager.instance = new CustomNodesManager(app, self);
}
CustomNodesManager.instance.show(CustomNodesManager.ShowMode.NORMAL);
},
},
],
init() {
$el("style", {
textContent: style,

View File

@ -1916,4 +1916,8 @@ export class CustomNodesManager {
close() {
this.element.style.display = "none";
}
get isVisible() {
return this.element?.style?.display !== "none";
}
}