Add filename prompt

This commit is contained in:
missionfloyd 2023-04-14 14:28:43 -06:00
parent 334aab05e5
commit af079193a7

View File

@ -519,12 +519,16 @@ export class ComfyUI {
$el("button", { $el("button", {
textContent: "Save", textContent: "Save",
onclick: () => { onclick: () => {
const filename = prompt("Save as...", "workflow");
if (!filename) {
return;
}
const json = JSON.stringify(app.graph.serialize(), null, 2); // convert the data to a JSON string const json = JSON.stringify(app.graph.serialize(), null, 2); // convert the data to a JSON string
const blob = new Blob([json], { type: "application/json" }); const blob = new Blob([json], { type: "application/json" });
const url = URL.createObjectURL(blob); const url = URL.createObjectURL(blob);
const a = $el("a", { const a = $el("a", {
href: url, href: url,
download: "workflow.json", download: `${filename}.json`,
style: { display: "none" }, style: { display: "none" },
parent: document.body, parent: document.body,
}); });