mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-09 01:20:09 +00:00
added support to load from file
This commit is contained in:
@@ -2117,8 +2117,25 @@
|
||||
return error;
|
||||
};
|
||||
|
||||
LGraph.prototype.load = function(url) {
|
||||
LGraph.prototype.load = function(url, callback) {
|
||||
var that = this;
|
||||
|
||||
//from file
|
||||
if(url.constructor === File || url.constructor === Blob)
|
||||
{
|
||||
var reader = new FileReader();
|
||||
reader.addEventListener('load', function(event) {
|
||||
var data = JSON.parse(event.target.result);
|
||||
that.configure(data);
|
||||
if(callback)
|
||||
callback();
|
||||
});
|
||||
|
||||
reader.readAsText(url);
|
||||
return;
|
||||
}
|
||||
|
||||
//is a string, then an URL
|
||||
var req = new XMLHttpRequest();
|
||||
req.open("GET", url, true);
|
||||
req.send(null);
|
||||
@@ -2127,8 +2144,10 @@
|
||||
console.error("Error loading graph:", req.status, req.response);
|
||||
return;
|
||||
}
|
||||
var data = JSON.parse(req.response);
|
||||
var data = JSON.parse( req.response );
|
||||
that.configure(data);
|
||||
if(callback)
|
||||
callback();
|
||||
};
|
||||
req.onerror = function(err) {
|
||||
console.error("Error loading graph:", err);
|
||||
@@ -10773,9 +10792,9 @@ LGraphNode.prototype.executeAction = function(action)
|
||||
callback: LGraphCanvas.onMenuNodeMode
|
||||
},
|
||||
{
|
||||
content: "Resize", callback: () => {
|
||||
content: "Resize", callback: function() {
|
||||
if(node.resizable)
|
||||
LGraphCanvas.onResizeNode
|
||||
return LGraphCanvas.onResizeNode;
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user