mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-11-22 01:57:04 +08:00
Support inserting workflows
Move buttosn to top of lists
This commit is contained in:
parent
ec3822b1f7
commit
e3e1b47aa6
@ -1793,7 +1793,7 @@ export class ComfyApp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.graph.configure(graphData, keepOld);
|
this.graph.configure(graphData);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
let errorHint = [];
|
let errorHint = [];
|
||||||
// Try extracting filename to see if it was caused by an extension script
|
// Try extracting filename to see if it was caused by an extension script
|
||||||
|
|||||||
@ -484,15 +484,15 @@
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
padding: 0 2px;
|
padding: 0 2px;
|
||||||
}
|
}
|
||||||
.comfyui-view-list-popup footer {
|
.comfyui-view-list-popup header {
|
||||||
margin-top: 10px;
|
margin-bottom: 10px;
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 5px;
|
gap: 5px;
|
||||||
}
|
}
|
||||||
.comfyui-view-list-popup footer .comfyui-button {
|
.comfyui-view-list-popup header .comfyui-button {
|
||||||
border: 1px solid transparent;
|
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);
|
border: 1px solid var(--comfy-menu-bg);
|
||||||
}
|
}
|
||||||
/* Queue button */
|
/* Queue button */
|
||||||
|
|||||||
@ -71,8 +71,8 @@ export class ComfyViewList {
|
|||||||
|
|
||||||
this.element = $el(`div.comfyui-${this.type}-popup.comfyui-view-list-popup`, [
|
this.element = $el(`div.comfyui-${this.type}-popup.comfyui-view-list-popup`, [
|
||||||
$el("h3", mode),
|
$el("h3", mode),
|
||||||
|
$el("header", [this.clear.element, this.refresh.element]),
|
||||||
this.items,
|
this.items,
|
||||||
$el("footer", [this.clear.element, this.refresh.element]),
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
api.addEventListener("status", () => {
|
api.addEventListener("status", () => {
|
||||||
|
|||||||
@ -343,35 +343,50 @@ class FileNode {
|
|||||||
deleteButton.element.style.removeProperty("background");
|
deleteButton.element.style.removeProperty("background");
|
||||||
});
|
});
|
||||||
|
|
||||||
const loadWorkflow = async (e) => {
|
const getWorkflow = async (e) => {
|
||||||
e.stopImmediatePropagation();
|
e.stopImmediatePropagation();
|
||||||
const resp = await api.getUserData(fileName);
|
const resp = await api.getUserData(fileName);
|
||||||
if (resp.status !== 200) {
|
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;
|
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);
|
await this.parent.app.loadGraphData(data, true, this.path);
|
||||||
this.parent.popup.open = false;
|
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);
|
const name = trimJsonExt(this.part);
|
||||||
this.element = $el(
|
this.element = $el(
|
||||||
tagName + ".comfyui-workflows-tree-file",
|
tagName + ".comfyui-workflows-tree-file",
|
||||||
{
|
{
|
||||||
onclick: (e) => loadWorkflow(e),
|
onclick: loadWorkflow,
|
||||||
title: this.path,
|
title: this.path,
|
||||||
},
|
},
|
||||||
[
|
[
|
||||||
this.nodeIcon,
|
this.nodeIcon,
|
||||||
$el("span", name),
|
$el("span", name),
|
||||||
// new ComfyButton({
|
new ComfyButton({
|
||||||
// icon: "file-move-outline",
|
icon: "file-move-outline",
|
||||||
// tooltip: "Insert this workflow into the current view",
|
tooltip: "Insert this workflow into the current view",
|
||||||
// classList: "comfyui-button comfyui-workflows-file-action",
|
classList: "comfyui-button comfyui-workflows-file-action",
|
||||||
// iconSize: 18,
|
iconSize: 18,
|
||||||
// action: (e) => loadWorkflow(e, true),
|
action: insertWorkflow,
|
||||||
// }).element,
|
}).element,
|
||||||
new ComfyButton({
|
new ComfyButton({
|
||||||
icon: "pencil",
|
icon: "pencil",
|
||||||
tooltip: "Rename this workflow",
|
tooltip: "Rename this workflow",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user