Add prompt-driven reference image routing
This commit is contained in:
@@ -241,6 +241,31 @@ function configure(node) {
|
||||
shotChips.append(chip);
|
||||
});
|
||||
panel.append(shotChips);
|
||||
const referenceRow = el("div"); referenceRow.style.cssText = "display:flex;gap:4px;overflow:hidden;margin:4px 0 7px;align-items:center";
|
||||
const connectedReferences = Array.from({ length: 9 }, (_, offset) => offset + 1)
|
||||
.filter((index) => node.inputs?.some((input) => input.name === `reference_image_${index}` && input.link != null));
|
||||
if (connectedReferences.length) {
|
||||
const referenceLabel = el("span", "Refs:"); referenceLabel.style.cssText = "color:#8fa898;font:10px monospace;margin-right:2px"; referenceRow.append(referenceLabel);
|
||||
connectedReferences.forEach((index) => {
|
||||
const button = el("button", `@R${index}`); button.type = "button";
|
||||
button.title = `Insert reference image ${index} as @R${index}`;
|
||||
button.style.cssText = "padding:3px 8px;border:1px solid #4f9bb0;border-radius:4px;background:#172d33;color:#8bd5e7;font:11px monospace;cursor:pointer";
|
||||
button.onclick = (event) => {
|
||||
event.preventDefault(); event.stopPropagation();
|
||||
if (!prompt) return;
|
||||
const start = prompt.selectionStart ?? prompt.value.length;
|
||||
const end = prompt.selectionEnd ?? start;
|
||||
const token = `@R${index} `;
|
||||
prompt.value = prompt.value.slice(0, start) + token + prompt.value.slice(end);
|
||||
const caret = start + token.length;
|
||||
prompt.focus(); prompt.setSelectionRange(caret, caret);
|
||||
promptText = prompt.value; clip.prompt = prompt.value;
|
||||
syncPrompt(clip, clip.prompt); persistState();
|
||||
};
|
||||
referenceRow.append(button);
|
||||
});
|
||||
}
|
||||
panel.append(referenceRow);
|
||||
const promptLabel = el("div", "PROMPT SCRIPT"); promptLabel.style.cssText = "color:#8fa898;font-size:10px;letter-spacing:.08em;margin:4px 0 3px"; panel.append(promptLabel);
|
||||
prompt = el("textarea"); prompt.rows = 10; prompt.value = promptText; prompt.placeholder = "[Shot 1] At 00:00.000, describe the opening action...\n\nType @ at the start of a new line to add the next shot."; prompt.style.cssText = "width:100%;box-sizing:border-box;color:#e8e8e8;background:#171717;border:1px solid #4e4e4e;border-radius:4px;padding:8px;font:12px/1.45 monospace;margin-top:2px;resize:vertical;outline:none";
|
||||
prompt.oninput = () => { promptText = prompt.value; clip.prompt = prompt.value; };
|
||||
@@ -303,6 +328,12 @@ function configure(node) {
|
||||
setState(); render(); return result;
|
||||
})(secondsWidget.callback);
|
||||
stateWidget.callback = ((previous) => function(...args) { const result = previous?.apply(this, args); render(); return result; })(stateWidget.callback);
|
||||
const previousConnections = node.onConnectionsChange;
|
||||
node.onConnectionsChange = function(...args) {
|
||||
const result = previousConnections?.apply(this, args);
|
||||
render();
|
||||
return result;
|
||||
};
|
||||
node.__dumasSequencePromptBuilder = refresh;
|
||||
refresh();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user