mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-26 07:35:44 -03:00
Fix serialize issue caused by comfy by a workaround of adding dummy items
This commit is contained in:
@@ -54,8 +54,6 @@ class LoraManagerLoader:
|
|||||||
loaded_loras = []
|
loaded_loras = []
|
||||||
all_trigger_words = []
|
all_trigger_words = []
|
||||||
|
|
||||||
print(f"kwargs: {kwargs}")
|
|
||||||
|
|
||||||
if 'loras' in kwargs:
|
if 'loras' in kwargs:
|
||||||
for lora in kwargs['loras']:
|
for lora in kwargs['loras']:
|
||||||
if not lora.get('active', False):
|
if not lora.get('active', False):
|
||||||
|
|||||||
@@ -30,8 +30,6 @@ class TriggerWordToggle:
|
|||||||
"message": trigger_words
|
"message": trigger_words
|
||||||
})
|
})
|
||||||
|
|
||||||
print(f"kwargs: {kwargs}")
|
|
||||||
|
|
||||||
filtered_triggers = trigger_words
|
filtered_triggers = trigger_words
|
||||||
|
|
||||||
if 'toggle_trigger_words' in kwargs:
|
if 'toggle_trigger_words' in kwargs:
|
||||||
|
|||||||
@@ -73,15 +73,7 @@ app.registerExtension({
|
|||||||
node.lorasWidget.value = mergedLoras;
|
node.lorasWidget.value = mergedLoras;
|
||||||
// node.graph.setDirtyCanvas(true, true);
|
// node.graph.setDirtyCanvas(true, true);
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log("node: ", node);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async nodeRemoved(node) {
|
|
||||||
if (node.comfyClass === "Lora Loader (LoraManager)") {
|
|
||||||
// TODO: Remove widget from node
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
@@ -15,7 +15,7 @@ export function addLorasWidget(node, name, opts, callback) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Initialize default value
|
// Initialize default value
|
||||||
const defaultValue = opts?.defaultVal || "";
|
const defaultValue = opts?.defaultVal || [];
|
||||||
|
|
||||||
// Parse LoRA entries from value
|
// Parse LoRA entries from value
|
||||||
const parseLoraValue = (value) => {
|
const parseLoraValue = (value) => {
|
||||||
@@ -247,7 +247,11 @@ export function addLorasWidget(node, name, opts, callback) {
|
|||||||
textAlign: "center",
|
textAlign: "center",
|
||||||
padding: "20px 0",
|
padding: "20px 0",
|
||||||
color: "rgba(226, 232, 240, 0.8)",
|
color: "rgba(226, 232, 240, 0.8)",
|
||||||
fontStyle: "italic"
|
fontStyle: "italic",
|
||||||
|
userSelect: "none", // Add this line to prevent text selection
|
||||||
|
WebkitUserSelect: "none", // For Safari support
|
||||||
|
MozUserSelect: "none", // For Firefox support
|
||||||
|
msUserSelect: "none", // For IE/Edge support
|
||||||
});
|
});
|
||||||
container.appendChild(emptyMessage);
|
container.appendChild(emptyMessage);
|
||||||
return;
|
return;
|
||||||
@@ -283,6 +287,10 @@ export function addLorasWidget(node, name, opts, callback) {
|
|||||||
color: "rgba(226, 232, 240, 0.8)",
|
color: "rgba(226, 232, 240, 0.8)",
|
||||||
fontSize: "13px",
|
fontSize: "13px",
|
||||||
marginLeft: "8px",
|
marginLeft: "8px",
|
||||||
|
userSelect: "none", // Add this line to prevent text selection
|
||||||
|
WebkitUserSelect: "none", // For Safari support
|
||||||
|
MozUserSelect: "none", // For Firefox support
|
||||||
|
msUserSelect: "none", // For IE/Edge support
|
||||||
});
|
});
|
||||||
|
|
||||||
const toggleContainer = document.createElement("div");
|
const toggleContainer = document.createElement("div");
|
||||||
@@ -299,7 +307,11 @@ export function addLorasWidget(node, name, opts, callback) {
|
|||||||
Object.assign(strengthLabel.style, {
|
Object.assign(strengthLabel.style, {
|
||||||
color: "rgba(226, 232, 240, 0.8)",
|
color: "rgba(226, 232, 240, 0.8)",
|
||||||
fontSize: "13px",
|
fontSize: "13px",
|
||||||
marginRight: "8px"
|
marginRight: "8px",
|
||||||
|
userSelect: "none", // Add this line to prevent text selection
|
||||||
|
WebkitUserSelect: "none", // For Safari support
|
||||||
|
MozUserSelect: "none", // For Firefox support
|
||||||
|
msUserSelect: "none", // For IE/Edge support
|
||||||
});
|
});
|
||||||
|
|
||||||
header.appendChild(toggleContainer);
|
header.appendChild(toggleContainer);
|
||||||
@@ -350,6 +362,10 @@ export function addLorasWidget(node, name, opts, callback) {
|
|||||||
color: active ? "rgba(226, 232, 240, 0.9)" : "rgba(226, 232, 240, 0.6)",
|
color: active ? "rgba(226, 232, 240, 0.9)" : "rgba(226, 232, 240, 0.6)",
|
||||||
fontSize: "13px",
|
fontSize: "13px",
|
||||||
cursor: "pointer", // Add pointer cursor to indicate hoverable area
|
cursor: "pointer", // Add pointer cursor to indicate hoverable area
|
||||||
|
userSelect: "none", // Add this line to prevent text selection
|
||||||
|
WebkitUserSelect: "none", // For Safari support
|
||||||
|
MozUserSelect: "none", // For Firefox support
|
||||||
|
msUserSelect: "none", // For IE/Edge support
|
||||||
});
|
});
|
||||||
|
|
||||||
// Move preview tooltip events to nameEl instead of loraEl
|
// Move preview tooltip events to nameEl instead of loraEl
|
||||||
@@ -530,18 +546,17 @@ export function addLorasWidget(node, name, opts, callback) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// Initialize widget value using options methods
|
widget.value = defaultValue;
|
||||||
widget.options.setValue(defaultValue);
|
|
||||||
|
|
||||||
widget.callback = callback;
|
widget.callback = callback;
|
||||||
|
|
||||||
// widget.computeSize = (width) => {
|
widget.serializeValue = () => {
|
||||||
// // console.log("loras_widget computeSize called: ", width, height);
|
// Add dummy items to avoid the 2-element serialization issue, a bug in comfyui
|
||||||
// return [400, 200];
|
return [...widgetValue,
|
||||||
// };
|
{ name: "__dummy_item1__", strength: 0, active: false, _isDummy: true },
|
||||||
|
{ name: "__dummy_item2__", strength: 0, active: false, _isDummy: true }
|
||||||
// Render initial state
|
];
|
||||||
renderLoras(widgetValue, widget);
|
}
|
||||||
|
|
||||||
widget.onRemove = () => {
|
widget.onRemove = () => {
|
||||||
container.remove();
|
container.remove();
|
||||||
|
|||||||
@@ -126,5 +126,13 @@ export function addTagsWidget(node, name, opts, callback) {
|
|||||||
|
|
||||||
widget.callback = callback;
|
widget.callback = callback;
|
||||||
|
|
||||||
|
widget.serializeValue = () => {
|
||||||
|
// Add dummy items to avoid the 2-element serialization issue, a bug in comfyui
|
||||||
|
return [...widgetValue,
|
||||||
|
{ text: "__dummy_item__", active: false, _isDummy: true },
|
||||||
|
{ text: "__dummy_item__", active: false, _isDummy: true }
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
return { minWidth: 300, minHeight: 150, widget };
|
return { minWidth: 300, minHeight: 150, widget };
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user