Improve sequence prompt editor presentation
This commit is contained in:
@@ -34,8 +34,8 @@ function configure(node) {
|
||||
if (!countWidget || !secondsWidget || !stateWidget) return;
|
||||
hide(stateWidget);
|
||||
const panel = el("div");
|
||||
panel.style.cssText = "box-sizing:border-box;min-width:360px;padding:7px;color:#e7f4e9;background:#203827;font:12px Arial;pointer-events:auto";
|
||||
const host = el("div"); host.style.cssText = "pointer-events:auto"; host.append(panel);
|
||||
panel.style.cssText = "box-sizing:border-box;min-width:420px;padding:9px;color:#d9e3dc;background:#292929;border:1px solid #454545;border-radius:4px;font:12px Arial;pointer-events:auto";
|
||||
const host = el("div"); host.style.cssText = "pointer-events:auto;background:#292929"; host.append(panel);
|
||||
["pointerdown", "mousedown", "mouseup", "dblclick"].forEach((name) => host.addEventListener(name, (event) => event.stopPropagation()));
|
||||
const display = node.addDOMWidget("clip_tabs", "dumas_h3_clip_tabs", host, { serialize: false });
|
||||
display.options ||= {}; display.options.serialize = false;
|
||||
@@ -133,8 +133,12 @@ function configure(node) {
|
||||
while (state.clips.length < count) state.clips.push({ duration: chunkDuration, slots: [] });
|
||||
state.clips = state.clips.slice(0, count); active = Math.min(active, count - 1);
|
||||
panel.replaceChildren();
|
||||
const tabs = el("div"); tabs.style.cssText = "display:flex;flex-wrap:wrap;gap:3px;margin-bottom:6px";
|
||||
state.clips.forEach((clip, index) => { const button = el("button", `Clip ${index + 1}`); button.type = "button"; button.disabled = index === active; button.onclick = () => { active = index; render(); }; tabs.append(button); });
|
||||
const tabs = el("div"); tabs.style.cssText = "display:flex;flex-wrap:wrap;gap:4px;margin-bottom:8px;border-bottom:1px solid #444;padding-bottom:6px";
|
||||
state.clips.forEach((clip, index) => {
|
||||
const button = el("button", `Clip ${index + 1}`); button.type = "button"; button.disabled = index === active;
|
||||
button.style.cssText = `padding:3px 10px;border:1px solid ${index === active ? "#8bc99b" : "#555"};border-radius:3px;background:${index === active ? "#4b6f55" : "#333"};color:${index === active ? "#fff" : "#bbb"};cursor:pointer`;
|
||||
button.onclick = () => { active = index; render(); }; tabs.append(button);
|
||||
});
|
||||
panel.append(tabs);
|
||||
const clip = state.clips[active];
|
||||
// All clips share the one authoritative project duration widget.
|
||||
@@ -142,9 +146,9 @@ function configure(node) {
|
||||
clip.duration = duration;
|
||||
if (clip.slots.length) clip.slots[clip.slots.length - 1].end = duration;
|
||||
promptText = promptFor(clip);
|
||||
const durationRow = el("div"); durationRow.style.cssText = "display:flex;align-items:center;gap:8px;margin:4px 0;color:#b7d6bf";
|
||||
const durationRow = el("div"); durationRow.style.cssText = "display:flex;align-items:center;gap:8px;margin:4px 0 6px;color:#b7d6bf";
|
||||
durationRow.append(el("strong", `Clip ${active + 1}`), el("span", `· ${duration.toFixed(1)}s shared chunk duration`)); panel.append(durationRow);
|
||||
const timeline = el("div"); timeline.style.cssText = "position:relative;height:44px;margin:8px 0 3px;background:#15251a;border-radius:3px;overflow:hidden;border:1px solid #41634a";
|
||||
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;
|
||||
const segments = [];
|
||||
@@ -161,7 +165,7 @@ function configure(node) {
|
||||
};
|
||||
clip.slots.forEach((slot, index) => {
|
||||
const segment = el("button", `Shot ${index + 1}\n${(slot.text || "unscripted").slice(0, 18)}`); segment.type = "button";
|
||||
segment.style.cssText = `position:absolute;top:0;height:100%;border:0;border-right:2px solid #203827;color:white;background:${palette[index % palette.length]};white-space:pre-wrap;font-size:10px;overflow:hidden;padding:2px`;
|
||||
segment.style.cssText = `position:absolute;top:0;height:100%;border:0;border-right:2px solid #292929;color:white;background:${palette[index % palette.length]};white-space:pre-wrap;font-size:10px;overflow:hidden;padding:2px;cursor:pointer`;
|
||||
segment.onclick = () => { prompt.focus(); }; segments.push(segment); timeline.append(segment);
|
||||
});
|
||||
clip.slots.slice(0, -1).forEach((slot, index) => {
|
||||
@@ -209,8 +213,26 @@ function configure(node) {
|
||||
});
|
||||
updateTimeline();
|
||||
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 = 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:#111;font:12px monospace;margin-top:6px";
|
||||
const sliderHint = el("div", "Drag the white handles to resize shots. The bar represents the complete chunk duration."); sliderHint.style.cssText = "color:#aab6ad;margin-bottom:6px;font-size:11px"; panel.append(sliderHint);
|
||||
|
||||
const shotChips = el("div"); shotChips.style.cssText = "display:flex;gap:4px;overflow:hidden;margin:3px 0 5px";
|
||||
clip.slots.forEach((slot, index) => {
|
||||
const chipText = (slot.text || `Shot ${index + 1}`).replace(/\s+/g, " ").trim().slice(0, 31);
|
||||
const chip = el("button", chipText || `Shot ${index + 1}`); chip.type = "button";
|
||||
chip.title = `Jump to Shot ${index + 1}`;
|
||||
chip.style.cssText = `max-width:180px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding:3px 8px;border:1px solid ${palette[index % palette.length]};border-radius:4px;background:#1e1e1e;color:#e6e6e6;font:11px Arial;cursor:pointer`;
|
||||
chip.onclick = () => {
|
||||
if (!prompt) return;
|
||||
const marker = `[Shot ${index + 1}]`;
|
||||
const position = prompt.value.indexOf(marker);
|
||||
prompt.focus();
|
||||
if (position >= 0) prompt.setSelectionRange(position, position + marker.length);
|
||||
};
|
||||
shotChips.append(chip);
|
||||
});
|
||||
panel.append(shotChips);
|
||||
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(); } };
|
||||
prompt.onchange = () => { commitPrompt(clip, prompt.value); };
|
||||
@@ -227,6 +249,10 @@ function configure(node) {
|
||||
setState(); render();
|
||||
};
|
||||
panel.append(prompt);
|
||||
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);
|
||||
const encoder = el("div", clip.slots.map((slot, index) => `Shot ${index + 1} ${formatTime(slot.start)}`).join(" ")); encoder.style.cssText = "padding:6px 8px;background:#171717;border:1px solid #444;border-radius:4px;color:#7cc4d5;font:11px monospace;white-space:nowrap;overflow:hidden;text-overflow:ellipsis"; panel.append(encoder);
|
||||
const actions = el("div"); actions.style.cssText = "display:flex;gap:5px;margin-top:5px";
|
||||
const add = el("button", "@ Add shot"); add.type = "button"; add.onclick = () => { clip.prompt = prompt.value; syncPrompt(clip, clip.prompt); addSlot(clip); rebuildPromptAfterStructureChange(clip); setState(); render(); }; actions.append(add);
|
||||
if (clip.slots.length > 1) { const remove = el("button", "Remove last shot"); remove.type = "button"; remove.onclick = () => { clip.prompt = prompt.value; syncPrompt(clip, clip.prompt); clip.slots.pop(); clip.slots.at(-1).end = clip.duration; rebuildPromptAfterStructureChange(clip); setState(); render(); }; actions.append(remove); }
|
||||
|
||||
Reference in New Issue
Block a user