mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-24 14:42:11 -03:00
Allow negative strength loras
This commit is contained in:
@@ -1,13 +1,15 @@
|
|||||||
import { app } from "../../scripts/app.js";
|
import { app } from "../../scripts/app.js";
|
||||||
import { addLorasWidget } from "./loras_widget.js";
|
import { addLorasWidget } from "./loras_widget.js";
|
||||||
|
|
||||||
|
// Extract pattern into a constant for consistent use
|
||||||
|
const LORA_PATTERN = /<lora:([^:]+):([-\d\.]+)>/g;
|
||||||
|
|
||||||
function mergeLoras(lorasText, lorasJson) {
|
function mergeLoras(lorasText, lorasJson) {
|
||||||
const result = [];
|
const result = [];
|
||||||
const pattern = /<lora:([^:]+):([\d\.]+)>/g;
|
|
||||||
let match;
|
let match;
|
||||||
|
|
||||||
// Parse text input and create initial entries
|
// Parse text input and create initial entries
|
||||||
while ((match = pattern.exec(lorasText)) !== null) {
|
while ((match = LORA_PATTERN.exec(lorasText)) !== null) {
|
||||||
const name = match[1];
|
const name = match[1];
|
||||||
const inputStrength = Number(match[2]);
|
const inputStrength = Number(match[2]);
|
||||||
|
|
||||||
@@ -69,10 +71,10 @@ app.registerExtension({
|
|||||||
try {
|
try {
|
||||||
// Remove loras that are not in the value array
|
// Remove loras that are not in the value array
|
||||||
const inputWidget = node.widgets[0];
|
const inputWidget = node.widgets[0];
|
||||||
const pattern = /<lora:([^:]+):([\d\.]+)>/g;
|
|
||||||
const currentLoras = value.map(l => l.name);
|
const currentLoras = value.map(l => l.name);
|
||||||
|
|
||||||
let newText = inputWidget.value.replace(pattern, (match, name, strength) => {
|
// Use the constant pattern here as well
|
||||||
|
let newText = inputWidget.value.replace(LORA_PATTERN, (match, name, strength) => {
|
||||||
return currentLoras.includes(name) ? match : '';
|
return currentLoras.includes(name) ? match : '';
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user