mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-24 22:52:12 -03:00
Add context menu for Lora items and improve Lora cleanup logic
This commit is contained in:
@@ -58,7 +58,19 @@ app.registerExtension({
|
||||
const result = addLorasWidget(node, "loras", {
|
||||
defaultVal: mergedLoras // Pass object directly
|
||||
}, (value) => {
|
||||
console.log("Loras data updated:", value);
|
||||
// Remove loras that are not in the value array
|
||||
const inputWidget = node.widgets[0];
|
||||
const pattern = /<lora:([^:]+):([\d\.]+)>/g;
|
||||
const currentLoras = value.map(l => l.name);
|
||||
|
||||
let newText = inputWidget.value.replace(pattern, (match, name, strength) => {
|
||||
return currentLoras.includes(name) ? match : '';
|
||||
});
|
||||
|
||||
// Clean up multiple spaces and trim
|
||||
newText = newText.replace(/\s+/g, ' ').trim();
|
||||
|
||||
inputWidget.value = newText;
|
||||
});
|
||||
|
||||
node.lorasWidget = result.widget;
|
||||
|
||||
Reference in New Issue
Block a user