mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-21 21:22:11 -03:00
Fix serialize issue caused by comfy by a workaround of adding dummy items
This commit is contained in:
@@ -53,8 +53,6 @@ class LoraManagerLoader:
|
||||
"""Loads multiple LoRAs based on the kwargs input."""
|
||||
loaded_loras = []
|
||||
all_trigger_words = []
|
||||
|
||||
print(f"kwargs: {kwargs}")
|
||||
|
||||
if 'loras' in kwargs:
|
||||
for lora in kwargs['loras']:
|
||||
|
||||
@@ -29,8 +29,6 @@ class TriggerWordToggle:
|
||||
"id": id,
|
||||
"message": trigger_words
|
||||
})
|
||||
|
||||
print(f"kwargs: {kwargs}")
|
||||
|
||||
filtered_triggers = trigger_words
|
||||
|
||||
|
||||
@@ -73,15 +73,7 @@ app.registerExtension({
|
||||
node.lorasWidget.value = mergedLoras;
|
||||
// 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
|
||||
const defaultValue = opts?.defaultVal || "";
|
||||
const defaultValue = opts?.defaultVal || [];
|
||||
|
||||
// Parse LoRA entries from value
|
||||
const parseLoraValue = (value) => {
|
||||
@@ -247,7 +247,11 @@ export function addLorasWidget(node, name, opts, callback) {
|
||||
textAlign: "center",
|
||||
padding: "20px 0",
|
||||
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);
|
||||
return;
|
||||
@@ -283,6 +287,10 @@ export function addLorasWidget(node, name, opts, callback) {
|
||||
color: "rgba(226, 232, 240, 0.8)",
|
||||
fontSize: "13px",
|
||||
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");
|
||||
@@ -299,7 +307,11 @@ export function addLorasWidget(node, name, opts, callback) {
|
||||
Object.assign(strengthLabel.style, {
|
||||
color: "rgba(226, 232, 240, 0.8)",
|
||||
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);
|
||||
@@ -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)",
|
||||
fontSize: "13px",
|
||||
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
|
||||
@@ -530,18 +546,17 @@ export function addLorasWidget(node, name, opts, callback) {
|
||||
},
|
||||
});
|
||||
|
||||
// Initialize widget value using options methods
|
||||
widget.options.setValue(defaultValue);
|
||||
widget.value = defaultValue;
|
||||
|
||||
widget.callback = callback;
|
||||
|
||||
// widget.computeSize = (width) => {
|
||||
// // console.log("loras_widget computeSize called: ", width, height);
|
||||
// return [400, 200];
|
||||
// };
|
||||
|
||||
// Render initial state
|
||||
renderLoras(widgetValue, widget);
|
||||
widget.serializeValue = () => {
|
||||
// Add dummy items to avoid the 2-element serialization issue, a bug in comfyui
|
||||
return [...widgetValue,
|
||||
{ name: "__dummy_item1__", strength: 0, active: false, _isDummy: true },
|
||||
{ name: "__dummy_item2__", strength: 0, active: false, _isDummy: true }
|
||||
];
|
||||
}
|
||||
|
||||
widget.onRemove = () => {
|
||||
container.remove();
|
||||
|
||||
@@ -126,5 +126,13 @@ export function addTagsWidget(node, name, opts, 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 };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user