diff --git a/web/sequence_prompt_builder.js b/web/sequence_prompt_builder.js index c04efc0..049eeb6 100644 --- a/web/sequence_prompt_builder.js +++ b/web/sequence_prompt_builder.js @@ -14,6 +14,18 @@ const DURATION_OPTIONS = [ ].map(([requested, actual, latent, labelSeconds]) => ({ requested, actual, latent, labelSeconds, seconds: actual / 24, })); +const CAMERA_HELPERS = [ + ["Push / Pull", ["The camera pushes in", "The camera pulls out"]], + ["Zoom", ["The camera zooms in", "The camera zooms out"]], + ["Pan", ["The camera pans left", "The camera pans right"]], + ["Truck", ["The camera trucks left", "The camera trucks right"]], + ["Tilt", ["The camera tilts up", "The camera tilts down"]], + ["Pedestal", ["The camera pedestals up", "The camera pedestals down"]], + ["Movement", ["The camera holds a static shot", "The camera arcs around the subject", "The camera tracks the subject"]], + ["POV", ["The camera holds the subject's point of view"]], + ["Roll", ["The camera rolls clockwise", "The camera rolls counterclockwise"]], + ["Shake", ["The camera shakes slightly", "The camera shakes strongly"]], +]; const get = (node, name) => node.widgets?.find((widget) => widget.name === name); const el = (tag, text = "") => { const item = document.createElement(tag); item.textContent = text; return item; }; @@ -448,6 +460,39 @@ function configure(node) { promptFrame.append(prompt); panel.append(suggestionLayer); panel.append(promptFrame); + promptSelectionStart = prompt.value.length; + promptSelectionEnd = prompt.value.length; + const insertPromptText = (text) => { + if (!prompt) return; + const start = Math.min(promptSelectionStart, prompt.value.length); + const end = Math.min(Math.max(start, promptSelectionEnd), prompt.value.length); + const before = prompt.value.slice(0, start); + const after = prompt.value.slice(end); + const prefix = before && !/\s$/.test(before) ? " " : ""; + const token = `${prefix}${text} `; + prompt.value = before + token + after; + const caret = before.length + token.length; + prompt.focus(); prompt.setSelectionRange(caret, caret); + promptSelectionStart = caret; promptSelectionEnd = caret; + promptText = prompt.value; clip.prompt = prompt.value; + syncPrompt(clip, clip.prompt); persistState(); + }; + const helperPanel = el("div"); + helperPanel.style.cssText = "display:flex;flex-wrap:wrap;gap:4px;align-items:center;margin:5px 0 7px;padding:5px 6px;background:#202020;border:1px solid #414141;border-radius:4px"; + const helperTitle = el("span", "CAMERA HELPERS"); + helperTitle.style.cssText = "width:100%;color:#8fa898;font-size:10px;letter-spacing:.08em;margin-bottom:1px"; + helperPanel.append(helperTitle); + CAMERA_HELPERS.forEach(([category, phrases]) => phrases.forEach((phrase) => { + const button = el("button", phrase.replace(/^The camera /, "")); + button.type = "button"; + button.title = `${category}: insert \"${phrase}\"`; + button.style.cssText = "padding:3px 7px;border:1px solid #596b60;border-radius:4px;background:#2b3b31;color:#b9e6c4;font:11px Arial;cursor:pointer;white-space:nowrap"; + button.onpointerdown = (event) => { event.preventDefault(); event.stopPropagation(); }; + button.onmousedown = (event) => { event.preventDefault(); event.stopPropagation(); }; + button.onclick = (event) => { event.preventDefault(); event.stopPropagation(); insertPromptText(phrase); }; + helperPanel.append(button); + })); + panel.insertBefore(helperPanel, promptFrame); const checkLabel = el("div", "PROMPT CHECK"); checkLabel.style.cssText = "color:#8fa898;font-size:10px;letter-spacing:.08em;margin:7px 0 3px"; panel.append(checkLabel); const check = el("div", `${clip.slots.length} shot${clip.slots.length === 1 ? "" : "s"} · ${duration.toFixed(1)}s chunk · @ references preserved`); check.style.cssText = "padding:6px 8px;background:#171717;border:1px solid #444;border-radius:4px;color:#9bd0a8;font:11px monospace"; panel.append(check); const encoderLabel = el("div", "SENT TO ENCODER AS"); encoderLabel.style.cssText = "color:#8fa898;font-size:10px;letter-spacing:.08em;margin:7px 0 3px"; panel.append(encoderLabel);