forked from Zuellni/ComfyUI-ExLlama-Nodes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtext.js
33 lines (26 loc) · 936 Bytes
/
text.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { app } from "../../../scripts/app.js";
import { ComfyWidgets } from "../../../scripts/widgets.js";
app.registerExtension({
name: "ZuellniText",
async beforeRegisterNodeDef(nodeType, nodeData, app) {
if (nodeData.name === "ZuellniTextPreview") {
const onExecuted = nodeType.prototype.onExecuted;
nodeType.prototype.onExecuted = function(message) {
onExecuted?.apply(this, arguments);
if (this.widgets) {
const index = this.widgets.findIndex((w) => w.name === "output");
if (index !== -1) {
for (let i = index; i < this.widgets.length; i++)
this.widgets[i].onRemove?.();
this.widgets.length = index;
}
const options = ["STRING", {multiline: true }]
const widget = ComfyWidgets["STRING"](this, "output", options, app).widget;
widget.inputEl.readOnly = true;
widget.inputEl.style.opacity = 0.7;
widget.value = message.text;
}
};
}
},
});