Sync prompt text on every edit
This commit is contained in:
@@ -142,6 +142,15 @@ function configure(node) {
|
||||
panel.append(timeline);
|
||||
const sliderHint = el("div", "Drag the white handles on the bar to resize shots. The bar always represents the complete chunk duration."); sliderHint.style.cssText = "color:#b7d6bf;margin-bottom:4px"; panel.append(sliderHint);
|
||||
prompt = el("textarea"); prompt.rows = 9; prompt.value = promptFor(clip); 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:#111;font:12px monospace;margin-top:6px";
|
||||
// Keep the serializable state current while typing, but do not render
|
||||
// on every keypress: rendering would replace the textarea and lose the
|
||||
// caret/selection. This also means a track interaction cannot see a
|
||||
// stale copy of the script.
|
||||
prompt.oninput = () => {
|
||||
syncPrompt(clip, prompt.value);
|
||||
stateWidget.value = JSON.stringify(state);
|
||||
node.setDirtyCanvas?.(true, true);
|
||||
};
|
||||
prompt.onchange = () => { syncPrompt(clip, prompt.value); setState(); render(); };
|
||||
prompt.onkeydown = (event) => { if (event.key !== "@") return; const cursor = prompt.selectionStart || 0; if (cursor !== 0 && prompt.value[cursor - 1] !== "\n") return; event.preventDefault(); addSlot(clip); setState(); render(); };
|
||||
panel.append(prompt);
|
||||
|
||||
Reference in New Issue
Block a user