import { app } from "/scripts/app.js"; import { ComfyWidgets } from "/scripts/widgets.js"; // Displays input text on a node app.registerExtension({ name: "pysssss.ShowText", async beforeRegisterNodeDef(nodeType, nodeData, app) { if (nodeData.name === "ShowText|pysssss") { // When the node is executed we will be sent the input text, display this in the widget const onExecuted = nodeType.prototype.onExecuted; nodeType.prototype.onExecuted = function (message) { onExecuted?.apply(this, arguments); if (this.widgets) { const pos = this.widgets.findIndex((w) => w.name === "text"); if (pos !== -1) { for (let i = pos; i < this.widgets.length; i++) { this.widgets[i].onRemove?.(); } this.widgets.length = pos; } } for (const list of message.text) { const w = ComfyWidgets["STRING"](this, "text", ["STRING", { multiline: true }], app).widget; w.inputEl.readOnly = true; w.inputEl.style.opacity = 0.6; w.value = list; } this.onResize?.(this.size); }; } }, });