Update 1.2.1

Fixed some minor bugs and changed the environment direction from side to right + left for more control
This commit is contained in:
drago87
2026-03-24 23:37:12 +01:00
parent ce2de1666b
commit c6ee01db1e
3 changed files with 116 additions and 104 deletions
+34 -30
View File
@@ -578,36 +578,40 @@ app.registerExtension({
syncPreviewHeight = function()
{
if (!previewWidget?.inputEl) return;
if (!node.size) return;
const HEADER = LiteGraph.NODE_TITLE_HEIGHT || 30;
const SLOT = LiteGraph.NODE_SLOT_HEIGHT || 20;
const PADDING = 10;
let widgetY = HEADER;
for (const w of node.widgets)
{
if (w === previewWidget) break;
const size = w.computeSize?.(node.size[0]);
widgetY += (size?.[1] || SLOT) + 4;
}
const inputsHeight =
(node.inputs?.length || 0) * SLOT;
const available =
node.size[1]
- widgetY
- inputsHeight
- PADDING;
previewWidget.inputEl.style.height =
Math.max(available, 50) + "px";
};
{
if (!previewWidget?.inputEl) return;
if (!node.size) return;
const HEADER = LiteGraph.NODE_TITLE_HEIGHT || 30;
const SLOT = LiteGraph.NODE_SLOT_HEIGHT || 20;
const WIDGET_SPACING = 4;
const BOTTOM_PADDING = 5; // Creates the consistent buffer at the bottom
let widgetY = HEADER;
// Calculate the Y position where the preview widget starts
for (const w of node.widgets)
{
if (w === previewWidget) break;
const size = w.computeSize?.(node.size[0]);
widgetY += (size?.[1] || 20) + WIDGET_SPACING;
}
// Calculate height occupied by inputs on the left
// We subtract this to create the "buffer" so the text box doesn't overlap the inputs area
const inputCount = node.inputs?.length || 0;
const inputsHeight = inputCount * SLOT;
// Calculate available height
// Node Height - (Widgets Above) - (Inputs Height) - (Bottom Padding)
const available = node.size[1] - widgetY - inputsHeight - BOTTOM_PADDING;
// Set height.
// We use Math.max(20) instead of 50.
// This allows the box to be small enough to FIT in small nodes (fixing Image_1)
// while the calculation above ensures it stops before the inputs (fixing Image_3).
previewWidget.inputEl.style.height = Math.max(available, 20) + "px";
};
const origOnResize = node.onResize;
+80 -73
View File
@@ -43,77 +43,84 @@ function parsePrompt(content) {
app.registerExtension({
name: "Dragos.PromptLoader",
nodeCreated(node)
{
// Only affect DragosPromptLoaderNode
if (node.comfyClass !== "DragosPromptLoader")
return;
setTimeout(async () =>
{
const promptDropdown =
node.widgets?.find(w => w.name === "prompt");
if (!promptDropdown)
return;
let infoWidget =
node.widgets.find(w => w.name === "info_text");
if (!infoWidget)
{
infoWidget =
node.addWidget("text", "info_text", "", () => {});
infoWidget.hidden = false;
}
let promptWidget =
node.widgets.find(w => w.name === "prompt_text");
if (!promptWidget)
{
promptWidget =
node.addWidget("text", "prompt_text", "", () => {});
promptWidget.hidden = false;
}
async function updateInputs(promptName)
{
if (!promptName) return;
const { info, prompt } =
await loadPromptFile(promptName);
infoWidget.value = info;
promptWidget.value = prompt;
const infoInput =
node.inputs?.find(i => i.name === "info_text");
const promptInput =
node.inputs?.find(i => i.name === "prompt_text");
if (infoInput) infoInput.value = info;
if (promptInput) promptInput.value = prompt;
node.graph?.setDirtyCanvas(true, true);
}
const oldCallback = promptDropdown.callback;
promptDropdown.callback = async function(value)
{
if (oldCallback)
oldCallback.call(this, value);
await updateInputs(value);
};
if (promptDropdown.value)
await updateInputs(promptDropdown.value);
}, 10);
}
nodeCreated(node) {
// Strict check: Only run for DragosPromptLoader
if (node.comfyClass !== "DragosPromptLoader") return;
// Increased timeout to 50ms to ensure Python widgets are instantiated
setTimeout(async () => {
// 1. Find the dropdown created by Python
const promptDropdown = node.widgets?.find(w => w.name === "prompt");
if (!promptDropdown) {
console.warn("DragosPromptLoader: Prompt dropdown missing on init.");
return;
}
// 2. Find the text widgets created by Python
// We DO NOT use addWidget here. We assume Python created them.
let infoWidget = node.widgets.find(w => w.name === "info_text");
let promptWidget = node.widgets.find(w => w.name === "prompt_text");
if (!infoWidget || !promptWidget) {
console.warn("DragosPromptLoader: info_text or prompt_text widgets missing. Check Python definition.");
return;
}
// Helper to handle visibility of info_widget
const updateVisibility = () => {
const hasInfo = infoWidget.value && infoWidget.value.trim().length > 0;
if (hasInfo) {
// Show widget
infoWidget.hidden = false;
if (infoWidget._originalComputeSize) {
infoWidget.computeSize = infoWidget._originalComputeSize;
}
} else {
// Hide widget
infoWidget.hidden = true;
if (!infoWidget._originalComputeSize) {
infoWidget._originalComputeSize = infoWidget.computeSize;
}
infoWidget.computeSize = () => [0, -4];
}
};
async function updateInputs(promptName) {
if (!promptName) return;
const { info, prompt } = await loadPromptFile(promptName);
infoWidget.value = info;
promptWidget.value = prompt;
updateVisibility();
// Sync inputs
const infoInput = node.inputs?.find(i => i.name === "info_text");
const promptInput = node.inputs?.find(i => i.name === "prompt_text");
if (infoInput) infoInput.value = info;
if (promptInput) promptInput.value = prompt;
node.setSize(node.computeSize());
node.graph?.setDirtyCanvas(true, true);
}
// Hook the dropdown callback
const oldCallback = promptDropdown.callback;
promptDropdown.callback = async function(value) {
if (oldCallback) oldCallback.call(this, value);
await updateInputs(value);
};
// Initial load
if (promptDropdown.value) {
await updateInputs(promptDropdown.value);
} else {
updateVisibility();
node.setSize(node.computeSize());
}
}, 50); // Increased timeout
}
});
+2 -1
View File
@@ -50,7 +50,8 @@
"direction": [
"front",
"side",
"right",
"left",
"back",
"top",
"bottom"