Skip to content

Make videos on the computer you already own. FreeVideo runs MiniMax H3 in as little as 8 GB of VRAM and 16 GB of RAM, and adapts its acceleration path to your hardware.

Editing view references: limit counts pictures in use; full row keeps plus and description

Bowen Xuef9022167285f
diff --git a/web/editor.css b/web/editor.css
index 1599393..79cb4b0 100644
--- a/web/editor.css
+++ b/web/editor.css
@@ -80,14 +80,15 @@
.fv-ed-genbar{position:relative}
.fv-ed-refs{display:flex;align-items:center;gap:6px;flex:none}
.fv-ed-refs[hidden],.fv-ed-ref-menu[hidden]{display:none}
-.fv-ed-ref-chips{display:flex;align-items:center;gap:6px}
+.fv-ed-ref-chips{display:flex;align-items:center;gap:6px;max-width:min(240px,32vw);overflow-x:auto;scrollbar-width:thin;scrollbar-color:var(--fv-border) transparent;padding:1px}
+.fv-ed-ref-chips:empty{display:none}
.fv-ed-ref-add,.fv-ed-ref-chip{flex:none;width:30px;height:30px;padding:0;border:1px solid var(--fv-border);border-radius:8px;background:transparent;color:var(--fv-muted);font:16px/1 var(--fv-font);cursor:pointer;overflow:hidden;position:relative}
.fv-ed-ref-chip{border-color:transparent;background:var(--fv-bg)}
.fv-ed-ref-add:not(:disabled):not([aria-disabled=true]):hover,.fv-ed-ref-add[aria-expanded=true],.fv-ed-ref-chip:not(:disabled):not([aria-disabled=true]):hover{border-color:var(--fv-accent);color:var(--fv-ink)}
.fv-ed-ref-add:disabled,.fv-ed-ref-chip:disabled,.fv-ed-ref-add[aria-disabled=true],.fv-ed-ref-chip[aria-disabled=true]{opacity:.4;cursor:default}
.fv-ed-ref-thumb{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;font-size:11px;color:var(--fv-muted)}
.fv-ed-ref-thumb img{display:block;width:100%;height:100%;object-fit:cover}
-.fv-ed-ref-menu{position:absolute;bottom:calc(100% - 4px);min-width:180px;max-width:260px;padding:6px;background:var(--fv-card);border:1px solid var(--fv-border);border-radius:8px;z-index:8;display:flex;flex-direction:column;font:13px var(--fv-font)}
+.fv-ed-ref-menu{position:absolute;bottom:calc(100% - 4px);min-width:180px;max-width:260px;padding:6px;background:var(--fv-card);border:1px solid var(--fv-border);border-radius:8px;z-index:12;display:flex;flex-direction:column;font:13px var(--fv-font)}
.fv-ed-ref-menu>button{display:block;width:100%;height:32px;padding:0 10px;border:0;border-radius:4px;background:transparent;color:var(--fv-ink);font:inherit;text-align:left;cursor:pointer}
.fv-ed-ref-menu>button:hover,.fv-ed-ref-menu button:focus-visible{background:color-mix(in srgb,var(--fv-accent) 12%,transparent);outline:1px solid var(--fv-accent);outline-offset:-1px}
.fv-ed-ref-menu>button[aria-checked=true]::after{content:'✓';float:right;color:var(--fv-accent)}
@@ -146,7 +147,8 @@
.fv-ed-genbar{grid-column:1;grid-row:4;min-height:56px;gap:8px;padding:10px 12px;flex-wrap:wrap}
.fv-ed-description{width:100%;flex:1 1 100%}
.fv-ed-genbar .fv-ed-description{order:-1}
- .fv-ed-refs{margin-right:auto}
+ .fv-ed-refs{margin-right:auto;max-width:100%}
+ .fv-ed-ref-chips{max-width:calc(100vw - 96px)}
.fv-ed-gen-hint{flex:1 0 auto;white-space:nowrap}
.fv-ed-gen-note{order:-1;flex:1 1 100%;white-space:normal}
.fv-editor .fv-ed-genbar>button{margin-left:auto;max-width:100%;font-size:12px}
diff --git a/web/editor_media_references.js b/web/editor_media_references.js
index b3f5dda..3080bf5 100644
--- a/web/editor_media_references.js
+++ b/web/editor_media_references.js
@@ -5,6 +5,7 @@ import {imageGenerationSupported} from './image_generation.js';
export const MAX_REFERENCES = 32;
const IMAGE = /\.(png|jpe?g|webp|bmp|tiff?)$/i;
export const isImageFile = file => IMAGE.test(file || '');
+const inUse = rows => rows.filter(row => row.enabled !== false).length;
export const ROLES = ['reference', 'first', 'last'];
const upstream = (node, name) => {
const input = node?.inputs?.find(i => i.name === name);
@@ -24,6 +25,9 @@ export function mediaReferences(node) {
rows: read,
write(rows) {
const field = widget(), owner = media();
+ // The limit counts pictures in use; when the list would grow past it, the oldest spare ones go first.
+ for (let at = rows.findIndex(row => row.enabled === false); rows.length > MAX_REFERENCES && at >= 0;
+ at = rows.findIndex(row => row.enabled === false)) rows.splice(at, 1);
if (!field || rows.length > MAX_REFERENCES) throw new Error('references');
field.value = JSON.stringify(rows);
owner.graph?.change?.();
@@ -53,13 +57,13 @@ export function mediaReferences(node) {
// The image editor opens on a blank picture the shape of the video, ready to generate one; a saved one is added as a reference.
async newImage({target, t}) {
const rows = read();
- if (rows.length >= MAX_REFERENCES) return null;
+ if (inUse(rows) >= MAX_REFERENCES) return null;
const library = rows.filter(row => isImageFile(row.file)).map(row => ({file: row.file, label: (row.source || row.file).split('/').pop()}));
const outcome = await openImageEditor({target, role: 'reference', t, resolve: file => this.url(file), upload: file => this.upload(file), library});
if (!outcome?.blob) return null;
const result = await this.upload(new File([outcome.blob], outcome.name, {type: outcome.blob.type}));
const latest = read();
- if (latest.length >= MAX_REFERENCES) return null;
+ if (inUse(latest) >= MAX_REFERENCES) return null;
latest.push({file: result.file, role: 'reference', enabled: true, edit: outcome.edit}); this.write(latest);
return result.file;
},
diff --git a/web/editor_references.js b/web/editor_references.js
index c33c246..e085128 100644
--- a/web/editor_references.js
+++ b/web/editor_references.js
@@ -11,7 +11,7 @@ export function createEditorReferences({t, source, size = () => null, error = ()
add.textContent = '+';
const menu = el('div', 'fv-ed-ref-menu'); menu.hidden = true; menu.setAttribute('role', 'menu');
const picker = el('input'); picker.type = 'file'; picker.accept = 'image/*'; picker.multiple = true; picker.hidden = true;
- root.append(chips, add, menu, picker);
+ root.append(add, chips, menu, picker);
let shown = false, busy = false, working = false, opener = null, disposed = false, entries = [];
const active = () => source.rows().map((row, index) => ({row, index})).filter(({row}) => row.enabled !== false);
const isImage = file => IMAGE.test(file || '');
@@ -35,7 +35,10 @@ export function createEditorReferences({t, source, size = () => null, error = ()
function open(anchor, items) {
menu.replaceChildren(...items); menu.hidden = false; opener = anchor;
add.setAttribute('aria-expanded', String(anchor === add));
- menu.style.left = Math.max(0, anchor.offsetLeft || 0) + 'px';
+ // Under the clicked thumbnail, pulled back inside the bar when that is near its right edge.
+ const bar = (root.offsetParent || root.parentNode)?.getBoundingClientRect?.(), at = anchor.getBoundingClientRect?.();
+ if (bar && at) menu.style.left = Math.min(Math.max(0, at.left - bar.left), Math.max(0, bar.width - Math.min(menu.offsetWidth || 260, 260) - 4)) + 'px';
+ else menu.style.left = Math.max(0, anchor.offsetLeft || 0) + 'px';
entries[0]?.focus();
}
// Every button of the open menu, in order, for the arrow keys.
@@ -55,7 +58,7 @@ export function createEditorReferences({t, source, size = () => null, error = ()
working = true; update();
try {
for (const file of files) {
- if (source.rows().length >= MAX) break;
+ if (active().length >= MAX) break;
const result = await source.upload(file);
write([...source.rows(), {file: result.file, role: 'reference', enabled: true}]);
}
@@ -111,7 +114,7 @@ export function createEditorReferences({t, source, size = () => null, error = ()
root.hidden = !shown || !source.available();
if ((root.hidden || busy) && !menu.hidden) close(false);
// The panel holds at most MAX pictures: a full list greys the plus out rather than ignoring a click.
- const full = source.rows().length >= MAX;
+ const full = active().length >= MAX;
// While a part is being made the controls stay clickable and say why they do nothing.
add.disabled = working;
add.setAttribute('aria-disabled', String(busy || full));
@@ -128,7 +131,7 @@ export function createEditorReferences({t, source, size = () => null, error = ()
}
add.onclick = () => {
if (busy) { notify(sentence(waitText())); return; }
- if (source.rows().length >= MAX) { notify(sentence(fullText())); return; }
+ if (active().length >= MAX) { notify(sentence(fullText())); return; }
if (!menu.hidden && opener === add) close(); else open(add, addMenu()); };
picker.onchange = () => addFiles(Array.from(picker.files));
// Keys stay in the menu: Escape closes it only, and the arrows move through it.