Fix reference chip insertion caret
This commit is contained in:
@@ -31,10 +31,10 @@ widget, making saved workflows portable even when the optional browser panel
|
||||
is unavailable.
|
||||
|
||||
The node can also accept up to nine optional reference-image inputs. Each
|
||||
input has a fixed identity (`Reference Image 1` is always `@image1`, through
|
||||
`@image9`; the backend also accepts the equivalent `@R1`–`@R9` tags). When an
|
||||
image is connected, the editor shows a CSGlide-style pill with a thumbnail and
|
||||
inserts that tag at the current caret position. The fourth output is the same typed
|
||||
input has a fixed identity (`Reference Image 1` is always `@R1`, through
|
||||
`@R9`; the editor displays these as CSGlide-style `@image1`–`@image9` pills).
|
||||
When an image is connected, the pill includes a thumbnail and inserts the
|
||||
canonical `@R#` tag at the current caret position. The fourth output is the same typed
|
||||
`H3_CONTINUUM_REFERENCE_IMAGES_V39` bundle used by the V3.9 sampler. It is
|
||||
automatically set to `Per chunk`, and only references explicitly mentioned in
|
||||
each chunk's prompt are assigned to that chunk. References that are connected
|
||||
|
||||
@@ -161,6 +161,8 @@ function configure(node) {
|
||||
const timeline = el("div"); timeline.style.cssText = "position:relative;height:38px;margin:8px 0 4px;background:#171717;border-radius:4px;overflow:hidden;border:1px solid #555";
|
||||
const palette = ["#4b9b67", "#4d7fb1", "#a87945", "#8c5aa8", "#a44f5d", "#3f8e8a"];
|
||||
let prompt = null;
|
||||
let promptSelectionStart = 0;
|
||||
let promptSelectionEnd = 0;
|
||||
const segments = [];
|
||||
const handles = [];
|
||||
const updateTimeline = () => {
|
||||
@@ -268,15 +270,30 @@ function configure(node) {
|
||||
}
|
||||
thumbnail.onerror = () => { thumbnail.style.opacity = "0.35"; };
|
||||
button.append(thumbnail, el("span", `@image${index}`));
|
||||
const rememberPromptSelection = () => {
|
||||
if (!prompt) return;
|
||||
promptSelectionStart = prompt.selectionStart ?? prompt.value.length;
|
||||
promptSelectionEnd = prompt.selectionEnd ?? promptSelectionStart;
|
||||
};
|
||||
button.onpointerdown = (event) => {
|
||||
rememberPromptSelection();
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
};
|
||||
button.onmousedown = (event) => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
};
|
||||
button.onclick = (event) => {
|
||||
event.preventDefault(); event.stopPropagation();
|
||||
if (!prompt) return;
|
||||
const start = prompt.selectionStart ?? prompt.value.length;
|
||||
const end = prompt.selectionEnd ?? start;
|
||||
const token = `@image${index} `;
|
||||
const start = Math.min(promptSelectionStart, prompt.value.length);
|
||||
const end = Math.min(Math.max(start, promptSelectionEnd), prompt.value.length);
|
||||
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);
|
||||
promptSelectionStart = caret; promptSelectionEnd = caret;
|
||||
promptText = prompt.value; clip.prompt = prompt.value;
|
||||
syncPrompt(clip, clip.prompt); persistState();
|
||||
};
|
||||
@@ -286,8 +303,15 @@ function configure(node) {
|
||||
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; };
|
||||
prompt.onblur = () => { if (prompt) { clip.prompt = prompt.value; syncPrompt(clip, clip.prompt); persistState(); } };
|
||||
const rememberPromptSelection = () => {
|
||||
promptSelectionStart = prompt.selectionStart ?? prompt.value.length;
|
||||
promptSelectionEnd = prompt.selectionEnd ?? promptSelectionStart;
|
||||
};
|
||||
prompt.oninput = () => { rememberPromptSelection(); promptText = prompt.value; clip.prompt = prompt.value; };
|
||||
prompt.onselect = rememberPromptSelection;
|
||||
prompt.onkeyup = rememberPromptSelection;
|
||||
prompt.onmouseup = rememberPromptSelection;
|
||||
prompt.onblur = () => { rememberPromptSelection(); clip.prompt = prompt.value; syncPrompt(clip, clip.prompt); persistState(); };
|
||||
prompt.onchange = () => { commitPrompt(clip, prompt.value); };
|
||||
prompt.onpointerdown = (event) => event.stopPropagation();
|
||||
prompt.onkeydown = (event) => {
|
||||
|
||||
Reference in New Issue
Block a user