Support inserting workflows

Move buttosn to top of lists
This commit is contained in:
pythongosssss 2024-02-22 20:38:59 +00:00
parent ec3822b1f7
commit e3e1b47aa6
4 changed files with 32 additions and 17 deletions

View File

@ -1793,7 +1793,7 @@ export class ComfyApp {
}
try {
this.graph.configure(graphData, keepOld);
this.graph.configure(graphData);
} catch (error) {
let errorHint = [];
// Try extracting filename to see if it was caused by an extension script

View File

@ -484,15 +484,15 @@
text-align: center;
padding: 0 2px;
}
.comfyui-view-list-popup footer {
margin-top: 10px;
.comfyui-view-list-popup header {
margin-bottom: 10px;
display: flex;
gap: 5px;
}
.comfyui-view-list-popup footer .comfyui-button {
.comfyui-view-list-popup header .comfyui-button {
border: 1px solid transparent;
}
.comfyui-view-list-popup footer .comfyui-button:not(:disabled):hover {
.comfyui-view-list-popup header .comfyui-button:not(:disabled):hover {
border: 1px solid var(--comfy-menu-bg);
}
/* Queue button */

View File

@ -71,8 +71,8 @@ export class ComfyViewList {
this.element = $el(`div.comfyui-${this.type}-popup.comfyui-view-list-popup`, [
$el("h3", mode),
$el("header", [this.clear.element, this.refresh.element]),
this.items,
$el("footer", [this.clear.element, this.refresh.element]),
]);
api.addEventListener("status", () => {

View File

@ -343,35 +343,50 @@ class FileNode {
deleteButton.element.style.removeProperty("background");
});
const loadWorkflow = async (e) => {
const getWorkflow = async (e) => {
e.stopImmediatePropagation();
const resp = await api.getUserData(fileName);
if (resp.status !== 200) {
alert(`Error storing user data file '${fileName}': ${resp.status} ${resp.statusText}`);
alert(`Error loading user data file '${fileName}': ${resp.status} ${resp.statusText}`);
return;
}
const data = await resp.json();
return await resp.json();
};
const loadWorkflow = async (e) => {
const data = await getWorkflow(e);
await this.parent.app.loadGraphData(data, true, this.path);
this.parent.popup.open = false;
};
const insertWorkflow = async (e) => {
const data = await getWorkflow(e);
const old = localStorage.getItem("litegrapheditor_clipboard");
const graph = new LGraph(data);
const canvas = new LGraphCanvas(null, graph, { skip_events: true, skip_render: true });
canvas.selectNodes();
canvas.copyToClipboard();
this.parent.app.canvas.pasteFromClipboard();
localStorage.setItem("litegrapheditor_clipboard", old);
};
const name = trimJsonExt(this.part);
this.element = $el(
tagName + ".comfyui-workflows-tree-file",
{
onclick: (e) => loadWorkflow(e),
onclick: loadWorkflow,
title: this.path,
},
[
this.nodeIcon,
$el("span", name),
// new ComfyButton({
// icon: "file-move-outline",
// tooltip: "Insert this workflow into the current view",
// classList: "comfyui-button comfyui-workflows-file-action",
// iconSize: 18,
// action: (e) => loadWorkflow(e, true),
// }).element,
new ComfyButton({
icon: "file-move-outline",
tooltip: "Insert this workflow into the current view",
classList: "comfyui-button comfyui-workflows-file-action",
iconSize: 18,
action: insertWorkflow,
}).element,
new ComfyButton({
icon: "pencil",
tooltip: "Rename this workflow",