Add new conditional append node Issue #5 recoommendation. Minor fixes and changes Issues #4 and #6.

This commit is contained in:
BRADSEC
2025-12-02 20:59:02 +10:00
parent a482111411
commit ba182e390e
17 changed files with 398 additions and 50 deletions
+45
View File
@@ -1,12 +1,16 @@
import { app } from "../../../scripts/app.js";
import { ComfyWidgets } from "../../../scripts/widgets.js";
// Consistent sizing for all String Essentials nodes
const DEFAULT_NODE_SIZE = [400, 200];
app.registerExtension({
name: "string.strip",
async beforeRegisterNodeDef(nodeType) {
if (nodeType.comfyClass === "StringStrip") {
nodeType.prototype.onNodeCreated = function() {
this.addInput("input_string", "STRING");
this.setSize(DEFAULT_NODE_SIZE);
};
}
}
@@ -18,6 +22,7 @@ app.registerExtension({
if (nodeType.comfyClass === "StringMultiReplace") {
nodeType.prototype.onNodeCreated = function() {
this.addInput("input_string", "STRING");
this.setSize(DEFAULT_NODE_SIZE);
};
}
}
@@ -32,6 +37,7 @@ app.registerExtension({
this.showValueWidget = ComfyWidgets["STRING"](this, "preview", ["STRING", { multiline: true }], app).widget;
this.showValueWidget.inputEl.readOnly = true;
this.showValueWidget.inputEl.style.opacity = 0.6;
this.setSize(DEFAULT_NODE_SIZE);
};
const onExecuted = nodeType.prototype.onExecuted;
@@ -39,8 +45,47 @@ app.registerExtension({
onExecuted?.apply(this, arguments);
if (message?.text?.[0] !== undefined) {
this.showValueWidget.value = message.text[0];
} else {
// Clear preview if no text received
this.showValueWidget.value = "";
}
};
// Clear preview when input is disconnected
const onConnectionsChange = nodeType.prototype.onConnectionsChange;
nodeType.prototype.onConnectionsChange = function(type, index, connected, link_info) {
if (onConnectionsChange) {
onConnectionsChange.apply(this, arguments);
}
// If input was disconnected, clear the preview
if (type === 1 && !connected) { // type 1 = input
this.showValueWidget.value = "";
}
};
}
}
});
app.registerExtension({
name: "string.conditionalappend",
async beforeRegisterNodeDef(nodeType) {
if (nodeType.comfyClass === "StringConditionalAppend") {
nodeType.prototype.onNodeCreated = function() {
this.addInput("input_string", "STRING");
this.setSize(DEFAULT_NODE_SIZE);
};
}
}
});
app.registerExtension({
name: "string.textbox",
async beforeRegisterNodeDef(nodeType) {
if (nodeType.comfyClass === "StringTextbox") {
nodeType.prototype.onNodeCreated = function() {
this.setSize(DEFAULT_NODE_SIZE);
};
}
}
});