This commit is contained in:
@@ -258,8 +258,6 @@ app.registerExtension({
|
||||
}
|
||||
return this._widgetNameMap[nm]
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
|
||||
init() {
|
||||
@@ -318,22 +316,6 @@ app.registerExtension({
|
||||
|
||||
if (false) add_debug();
|
||||
|
||||
const export_api_label = Array.from(document.getElementsByClassName('p-menubar-item-label')).find((e)=>e.innerText=='Export (API)')
|
||||
if (export_api_label) {
|
||||
export_api_label.addEventListener('click', (e)=>{
|
||||
const ue_links = app.graph.extra['ue_links'];
|
||||
if (ue_links.length>0) {
|
||||
if (!confirm("This model contains links added by Use Everywhere which won't work with the API. " +
|
||||
"You probably want to use 'Convert all UEs to real links' on the canvas right click menu before saving.\n\n" +
|
||||
"Save anyway?"))
|
||||
{
|
||||
e.stopImmediatePropagation()
|
||||
e.stopPropagation()
|
||||
e.preventDefault()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const original_subgraph = app.graph.convertToSubgraph
|
||||
app.graph.convertToSubgraph = function () {
|
||||
|
||||
@@ -124,6 +124,9 @@ function remove_this(node, keep_seed_everywhere) {
|
||||
return (is_UEnode(node) && !(keep_seed_everywhere && node.comfyClass=="Seed Everywhere") )
|
||||
}
|
||||
|
||||
export function remove_all_ues(keep_seed_everywhere, graph) {
|
||||
graph._nodes.filter((node)=>remove_this(node, keep_seed_everywhere)).forEach((node)=>{app.graph.remove(node)})
|
||||
export function remove_all_ues(keep_seed_everywhere, graph, recurse) {
|
||||
graph._nodes.filter((node)=>remove_this(node, keep_seed_everywhere)).forEach((node)=>{graph.remove(node)})
|
||||
if (recurse) {
|
||||
graph._nodes.filter((node)=>(node.subgraph)).forEach((node)=>{remove_all_ues(keep_seed_everywhere, node.subgraph, recurse)})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ class GraphAnalyser extends Pausable {
|
||||
|
||||
modify_graphs_recursively(graph, mods) {
|
||||
const modifications = convert_to_links( this.analyse_graph(graph), null, graph )
|
||||
mods.push( modifications );
|
||||
if (mods) mods.push( modifications );
|
||||
if (!graph.extra) graph.extra = {}
|
||||
graph.extra['links_added_by_ue'] = modifications.added_links.map(x=>x.id)
|
||||
graph.nodes.filter((node)=>(node.subgraph)).forEach((node) => {this.modify_graphs_recursively(node.subgraph, mods);});
|
||||
|
||||
@@ -4,7 +4,7 @@ import { LinkRenderController } from "./use_everywhere_ui.js";
|
||||
import { convert_to_links, remove_all_ues } from "./use_everywhere_apply.js";
|
||||
import { Logger } from "./use_everywhere_utilities.js";
|
||||
import { settingsCache } from "./use_everywhere_cache.js";
|
||||
import { visible_graph } from "./use_everywhere_subgraph_utils.js";
|
||||
import { visible_graph, master_graph } from "./use_everywhere_subgraph_utils.js";
|
||||
import { edit_restrictions } from "./ue_properties_editor.js";
|
||||
import { is_UEnode } from "./use_everywhere_utilities.js";
|
||||
import { i18ify_settings } from "./i18n.js";
|
||||
@@ -258,6 +258,22 @@ export function canvas_menu_settings(options) {
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
content: "Convert all UEs to real links",
|
||||
callback: async () => {
|
||||
if (window.confirm("This will convert all links created by Use Everywhere to real links, and delete all the Use Everywhere nodes. Is that what you want?")) {
|
||||
LinkRenderController.instance().pause("convert");
|
||||
try {
|
||||
GraphAnalyser.instance().modify_graphs_recursively(master_graph())
|
||||
remove_all_ues(true, master_graph(), true);
|
||||
} finally {
|
||||
app.graph.change();
|
||||
LinkRenderController.instance().unpause()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
if (GraphAnalyser.instance().ambiguity_messages.length) {
|
||||
options.push({
|
||||
|
||||
Reference in New Issue
Block a user