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.
|
is unavailable.
|
||||||
|
|
||||||
The node can also accept up to nine optional reference-image inputs. Each
|
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
|
input has a fixed identity (`Reference Image 1` is always `@R1`, through
|
||||||
`@image9`; the backend also accepts the equivalent `@R1`–`@R9` tags). When an
|
`@R9`; the editor displays these as CSGlide-style `@image1`–`@image9` pills).
|
||||||
image is connected, the editor shows a CSGlide-style pill with a thumbnail and
|
When an image is connected, the pill includes a thumbnail and inserts the
|
||||||
inserts that tag at the current caret position. The fourth output is the same typed
|
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
|
`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
|
automatically set to `Per chunk`, and only references explicitly mentioned in
|
||||||
each chunk's prompt are assigned to that chunk. References that are connected
|
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 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"];
|
const palette = ["#4b9b67", "#4d7fb1", "#a87945", "#8c5aa8", "#a44f5d", "#3f8e8a"];
|
||||||
let prompt = null;
|
let prompt = null;
|
||||||
|
let promptSelectionStart = 0;
|
||||||
|
let promptSelectionEnd = 0;
|
||||||
const segments = [];
|
const segments = [];
|
||||||
const handles = [];
|
const handles = [];
|
||||||
const updateTimeline = () => {
|
const updateTimeline = () => {
|
||||||
@@ -268,15 +270,30 @@ function configure(node) {
|
|||||||
}
|
}
|
||||||
thumbnail.onerror = () => { thumbnail.style.opacity = "0.35"; };
|
thumbnail.onerror = () => { thumbnail.style.opacity = "0.35"; };
|
||||||
button.append(thumbnail, el("span", `@image${index}`));
|
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) => {
|
button.onclick = (event) => {
|
||||||
event.preventDefault(); event.stopPropagation();
|
event.preventDefault(); event.stopPropagation();
|
||||||
if (!prompt) return;
|
if (!prompt) return;
|
||||||
const start = prompt.selectionStart ?? prompt.value.length;
|
const start = Math.min(promptSelectionStart, prompt.value.length);
|
||||||
const end = prompt.selectionEnd ?? start;
|
const end = Math.min(Math.max(start, promptSelectionEnd), prompt.value.length);
|
||||||
const token = `@image${index} `;
|
const token = `@R${index} `;
|
||||||
prompt.value = prompt.value.slice(0, start) + token + prompt.value.slice(end);
|
prompt.value = prompt.value.slice(0, start) + token + prompt.value.slice(end);
|
||||||
const caret = start + token.length;
|
const caret = start + token.length;
|
||||||
prompt.focus(); prompt.setSelectionRange(caret, caret);
|
prompt.focus(); prompt.setSelectionRange(caret, caret);
|
||||||
|
promptSelectionStart = caret; promptSelectionEnd = caret;
|
||||||
promptText = prompt.value; clip.prompt = prompt.value;
|
promptText = prompt.value; clip.prompt = prompt.value;
|
||||||
syncPrompt(clip, clip.prompt); persistState();
|
syncPrompt(clip, clip.prompt); persistState();
|
||||||
};
|
};
|
||||||
@@ -286,8 +303,15 @@ function configure(node) {
|
|||||||
panel.append(referenceRow);
|
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);
|
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 = 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; };
|
const rememberPromptSelection = () => {
|
||||||
prompt.onblur = () => { if (prompt) { clip.prompt = prompt.value; syncPrompt(clip, clip.prompt); persistState(); } };
|
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.onchange = () => { commitPrompt(clip, prompt.value); };
|
||||||
prompt.onpointerdown = (event) => event.stopPropagation();
|
prompt.onpointerdown = (event) => event.stopPropagation();
|
||||||
prompt.onkeydown = (event) => {
|
prompt.onkeydown = (event) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user