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.

Add @ reference picker for image, video and audio prompts (#10)

Bowen Xue763b7d2c2b5c
diff --git a/scripts/test_freevideo_entry.mjs b/scripts/test_freevideo_entry.mjs
index e924d87..4bbd4b8 100644
--- a/scripts/test_freevideo_entry.mjs
+++ b/scripts/test_freevideo_entry.mjs
@@ -37,6 +37,7 @@ test('main browser entry registers both views and preserves node hooks', async (
notifyCompatibility: async () => { compatibilityChecks++; },
installNavigation: callback => installed.push(callback),
refreshNavigation: () => refreshed++, preferredView: () => null,
+ attachReferencePicker() {}, referenceItems: () => [], syncReferencePrompt() {},
};
const previous = new Map();
for (const [name, value] of Object.entries({
@@ -57,6 +58,7 @@ test('main browser entry registers both views and preserves node hooks', async (
.replace("import { createGenerationProgress } from './generation_progress.js';", 'const {createGenerationProgress} = globalThis.__freevideoEntryTest;')
.replace("import { createProgressConnection } from './progress_connection.js';", 'const {createProgressConnection} = globalThis.__freevideoEntryTest;')
.replace("import { notifyCompatibility } from './compatibility.js';", 'const {notifyCompatibility} = globalThis.__freevideoEntryTest;')
+ .replace("import { attachReferencePicker, referenceItems, syncReferencePrompt } from './prompt_references.js';", 'const {attachReferencePicker,referenceItems,syncReferencePrompt} = globalThis.__freevideoEntryTest;')
.replace("import { installNavigation, refreshNavigation, preferredView } from './view_navigation.js';", 'const {installNavigation,refreshNavigation,preferredView} = globalThis.__freevideoEntryTest;');
await import('data:text/javascript;base64,' + Buffer.from(source).toString('base64'));
const extension = extensions.find(row => row.name === 'FreeVideo.UnifiedMedia');
diff --git a/web/freevideo.js b/web/freevideo.js
index af5e22b..b2eea90 100644
--- a/web/freevideo.js
+++ b/web/freevideo.js
@@ -6,6 +6,7 @@ import { createGenerationProgress } from './generation_progress.js';
import { createProgressConnection } from './progress_connection.js';
import { notifyCompatibility } from './compatibility.js';
import { installNavigation, refreshNavigation, preferredView } from './view_navigation.js';
+import { attachReferencePicker, referenceItems, syncReferencePrompt } from './prompt_references.js';
const languageOverride = typeof location !== 'undefined'
? new URLSearchParams(location.search).get('freevideo_lang') : null;
@@ -183,6 +184,19 @@ function mediaPanel(node, mount = null) {
}
function resultPanel(node) {
+ const input = node.widgets?.find(w => w.name === 'text')?.inputEl;
+ if (input?.tagName === 'TEXTAREA') {
+ const picker = attachReferencePicker(input, {items: () => referenceItems(node), t: text, view: viewURL});
+ const changed = e => {
+ if (String(e.detail) !== String(node.id)) return;
+ const value = node.widgets.find(w => w.name === 'text').value;
+ if (input.value !== value) input.value = value;
+ picker.refresh();
+ };
+ window.addEventListener('freevideo-reference-prompt', changed);
+ const removed = node.onRemoved;
+ node.onRemoved = function (...args) { picker.dispose(); window.removeEventListener('freevideo-reference-prompt', changed); return removed?.apply(this, args); };
+ }
node.addDOMWidget('freevideo_prompt_guide', 'freevideo_prompt_guide', promptGuide(),
{serialize: false, getMinHeight: () => 58, getMaxHeight: () => 76});
const panel = el("div", undefined, "fv-panel"); panel.dataset.freevideo = "result";
@@ -215,7 +229,7 @@ function resultPanel(node) {
const panelHeight = () => (hasLoRA() ? 240 : 140) + (node.freevideoFailure ? 280 : 0) + (node.freevideoProgress ? 190 : 0);
node.addDOMWidget("freevideo_result", "freevideo_result", panel, {serialize: false, getMinHeight: panelHeight, getMaxHeight: panelHeight});
const connected = node.onConnectionsChange, configured = node.onConfigure;
- node.onConnectionsChange = function (...args) { const result = connected?.apply(this, args); warn(); return result; };
+ node.onConnectionsChange = function (...args) { const result = connected?.apply(this, args); warn(); queueMicrotask(syncPrompts); return result; };
node.onConfigure = function (...args) { const result = configured?.apply(this, args); warn(); return result; };
warn();
node.freevideoShowPrewarm = function (value) {
@@ -259,6 +273,13 @@ function resultPanel(node) {
};
}
+let configuringGraph = false;
+function syncPrompts(reset = false) {
+ if (configuringGraph && reset !== true) return;
+ for (const node of app.graph?._nodes || []) if (node.type === 'FreeVideoGenerate') syncReferencePrompt(node, text, reset === true);
+}
+window.addEventListener('freevideo-media', () => syncPrompts());
+
const progressConnection = createProgressConnection(api, message => {
const node = app.graph?.getNodeById(message.node);
if (!node?.freevideoShowProgress) return false;
@@ -270,8 +291,14 @@ const progressConnection = createProgressConnection(api, message => {
app.registerExtension({
name: "FreeVideo.UnifiedMedia",
+ beforeConfigureGraph() { configuringGraph = true; },
async setup() { progressConnection.start(); installNavigation(openStudio); await notifyCompatibility(); },
async beforeRegisterNodeDef(nodeType, nodeData) {
+ if (nodeData.name === 'FreeVideoReference') {
+ const connected = nodeType.prototype.onConnectionsChange;
+ nodeType.prototype.onConnectionsChange = function (...args) { const result = connected?.apply(this, args); queueMicrotask(syncPrompts); return result; };
+ return;
+ }
if (!["FreeVideoMedia", "FreeVideoGenerate", "FreeVideoLoRAStack"].includes(nodeData.name)) return;
const created = nodeType.prototype.onNodeCreated;
nodeType.prototype.onNodeCreated = function () {
@@ -304,6 +331,8 @@ app.registerExtension({
};
},
afterConfigureGraph() {
+ syncPrompts(true);
+ configuringGraph = false;
progressConnection.reset();
progressConnection.refresh();
refreshNavigation();
diff --git a/web/prompt_references.css b/web/prompt_references.css
new file mode 100644
index 0000000..4720859
--- /dev/null
+++ b/web/prompt_references.css
@@ -0,0 +1,12 @@
+.fv-prompt-editor{position:relative}.fv-studio .fv-prompt-editor textarea{padding-bottom:40px}
+.fv-studio .fv-reference-trigger{position:absolute;right:9px;bottom:9px;min-height:27px;width:30px;padding:0;font-size:17px;border:0;background:var(--fv-raised);color:var(--fv-muted)}
+.fv-reference-picker{box-sizing:border-box;position:fixed;inset:auto;margin:0;padding:6px;border:1px solid var(--fv-border,#3a414c);border-radius:14px;background:var(--fv-card,#1a202a);color:var(--fv-ink,#eee);box-shadow:0 14px 42px #0006;font:13px/1.4 var(--fv-font,system-ui);z-index:10000;max-height:280px;overflow:hidden;animation:fv-reference-appear .12s ease-out}
+.fv-reference-picker[hidden]{display:none!important}.fv-reference-options{max-height:266px;overflow-y:auto;overscroll-behavior:contain;scrollbar-width:thin}
+.fv-reference-option{display:flex;align-items:center;gap:10px;min-height:59px;padding:7px;border-radius:9px;cursor:pointer}
+.fv-reference-option[aria-selected=true]{background:var(--fv-selected,#2d3949)}
+.fv-reference-thumb{display:grid;place-items:center;width:40px;height:40px;flex:none;object-fit:cover;border-radius:7px;background:var(--fv-raised,#252e39);font-size:21px;color:var(--fv-muted,#a9b3c4)}
+.fv-reference-option>span:not(.fv-reference-thumb){flex:1;min-width:0}.fv-reference-option strong,.fv-reference-option small{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
+.fv-reference-option strong{font-size:13px;font-weight:550}.fv-reference-option small{font-size:11px;color:var(--fv-muted,#a9b3c4);margin-top:3px}.fv-reference-option code{font:11px var(--fv-font,system-ui);color:var(--fv-muted,#a9b3c4);white-space:nowrap}
+.fv-reference-empty{padding:18px 12px;color:var(--fv-muted,#a9b3c4)}.fv-reference-picker button{margin:0 12px 10px;padding:5px 10px;border:1px solid var(--fv-border,#3a414c);border-radius:8px;background:var(--fv-raised,#252e39);color:inherit;cursor:pointer;font:inherit}
+@keyframes fv-reference-appear{from{opacity:0;transform:translateY(4px)}to{opacity:1;transform:translateY(0)}}
+@media(prefers-reduced-motion:reduce){.fv-reference-picker{animation:none}}
diff --git a/web/prompt_references.js b/web/prompt_references.js
new file mode 100644
index 0000000..9865929
--- /dev/null
+++ b/web/prompt_references.js
@@ -0,0 +1,219 @@
+// H3 numbers each reference kind separately, in the order of comfy_media.export.
+const titles = {image: 'Picture', video: 'Video', audio: 'Audio'};
+const widget = (node, name) => node?.widgets?.find(w => w.name === name);
+const linkFor = (node, name) => node?.graph?.links?.[node.inputs?.find(i => i.name === name)?.link];
+const sourceFor = (node, name) => node?.graph?.getNodeById(linkFor(node, name)?.origin_id);
+export function referenceKind(file) {
+ const ext = String(file).split('.').pop().toLowerCase();
+ return ['png','jpg','jpeg','webp','bmp','tif','tiff'].includes(ext) ? 'image'
+ : ['mp4','mov','webm','mkv','m4v'].includes(ext) ? 'video'
+ : ['wav','mp3','flac','ogg','m4a','aac','opus'].includes(ext) ? 'audio' : null;
+}
+
+export function referenceItems(node) {
+ if (linkFor(node, 'conditioning')) return [];
+ const refs = [], anchors = {}, seen = new Set();
+ const connected = (owner, name, kind) => {
+ const link = linkFor(owner, name), source = sourceFor(owner, name);
+ return link ? {key: `node:${owner.id}:${name}:${link.origin_id}:${link.origin_slot}`,
+ kind, name: source?.title || source?.type || name} : null;
+ };
+ const media = sourceFor(node, 'media');
+ if (media) {
+ if (['first','last','references'].some(name => linkFor(node, name))) throw new Error('invalid_media');
+ const serialized = widget(media, 'assets');
+ if (!serialized) throw new Error('unknown_references');
+ const rows = JSON.parse(serialized.value || '[]'), counts = new Map();
+ if (!Array.isArray(rows)) throw new Error('invalid_media');
+ for (const row of rows) {
+ const occurrence = counts.get(row.file) || 0; counts.set(row.file, occurrence + 1);
+ if (row.enabled === false) continue;
+ const kind = referenceKind(row.file);
+ if (!kind) throw new Error('invalid_media');
+ const item = {key: `file:${media.id}:${row.file}:${occurrence}`, kind, file: row.file,
+ name: row.file.split('/').pop(), assetIndex: rows.indexOf(row)};
+ if (row.role === 'reference') refs.push(item);
+ else if (kind === 'image' && ['first','last'].includes(row.role) && !anchors[row.role]) anchors[row.role] = item;
+ else throw new Error('invalid_media');
+ }
+ for (const name of ['first','last']) {
+ const item = connected(media, name, 'image');
+ if (item && anchors[name]) throw new Error('invalid_media');
+ if (item) anchors[name] = item;
+ }
+ for (const [name, kind] of [['reference','image'],['reference_audio','audio']]) {
+ const item = connected(media, name, kind); if (item) refs.push(item);
+ }
+ } else {
+ for (const name of ['first','last']) {
+ const item = connected(node, name, 'image'); if (item) anchors[name] = item;
+ }
+ function stack(current) {
+ if (!current) return;
+ if (seen.has(current.id) || current.type !== 'FreeVideoReference') throw new Error('unknown_references');
+ seen.add(current.id); stack(sourceFor(current, 'previous'));
+ const items = ['image','video','audio'].map(kind => connected(current, kind, kind)).filter(Boolean);
+ if (items.length !== 1) throw new Error('invalid_media');
+ refs.push(items[0]);
+ }
+ stack(sourceFor(node, 'references'));
+ }
+ if (refs.length && Object.keys(anchors).length) throw new Error('invalid_media');
+ const ordered = refs.length ? refs : ['first','last'].filter(k => anchors[k]).map(k => ({...anchors[k], role: k}));
+ const counters = {image: 0, video: 0, audio: 0};
+ return ordered.map(item => ({...item, number: ++counters[item.kind],
+ token: `<${titles[item.kind]} ${counters[item.kind]}>`}));
+}
+
+export function remapReferences(text, previous, current, removed = '[Removed reference]') {
+ const byKey = new Map(current.map(item => [item.key, item.token]));
+ const replacement = new Map(previous.map(item => [item.token, byKey.get(item.key) || removed]));
+ return text.replace(/<(?:Picture|Video|Audio) \d+>/g, token => replacement.get(token) || token);
+}
+
+const bindings = new WeakMap();
+export function syncReferencePrompt(node, t = en => en, reset = false) {
+ const text = widget(node, 'text');
+ if (!text || linkFor(node, 'text') || linkFor(node, 'conditioning')) { bindings.delete(node); return; }
+ let items; try { items = referenceItems(node); } catch { return; }
+ const previous = reset ? null : bindings.get(node);
+ const current = items.map(({key, token}) => ({key, token}));
+ if (Array.isArray(previous) && JSON.stringify(previous) !== JSON.stringify(current)) {
+ const updated = remapReferences(String(text.value || ''), previous, current, t('[Removed reference]', '[素材已移除]'));
+ if (updated !== text.value) { text.value = updated; text.callback?.(updated); node.graph?.change(); }
+ }
+ bindings.set(node, current);
+ window.dispatchEvent(new CustomEvent('freevideo-reference-prompt', {detail: node.id}));
+}
+
+export function mentionAt(text, start, end = start) {
+ if (start < 1 || start !== end) return null;
+ const at = text.lastIndexOf('@', start - 1);
+ if (at < 0 || (at > 0 && /[\w.%+\-]/.test(text[at - 1]))) return null;
+ const query = text.slice(at + 1, start);
+ return /^[\p{L}\p{N}_. \-]{0,64}$/u.test(query) ? {start: at, end: start, query: query.trim().toLowerCase()} : null;
+}
+
+let serial = 0;
+export function attachReferencePicker(input, {items, t = en => en, view, host, addMedia} = {}) {
+ if (!document.querySelector('link[data-freevideo-references]')) {
+ const css = document.createElement('link'); css.rel = 'stylesheet';
+ css.dataset.freevideoReferences = ''; css.href = new URL('./prompt_references.css', import.meta.url).href;
+ document.head.append(css);
+ }
+ const popup = document.createElement('div'); popup.className = 'fv-reference-picker';
+ popup.setAttribute('popover', 'manual'); popup.hidden = true;
+ const list = document.createElement('div'); list.className = 'fv-reference-options';
+ list.id = `fv-reference-options-${++serial}`; list.setAttribute('role', 'listbox');
+ list.setAttribute('aria-label', t('Reference media', '参考素材'));
+ popup.append(list); (host || input.closest('dialog') || document.body).append(popup);
+ const saved = new Map(['role','aria-autocomplete','aria-controls','aria-expanded','aria-activedescendant']
+ .map(name => [name, input.getAttribute(name)]));
+ input.setAttribute('role', 'combobox'); input.setAttribute('aria-autocomplete', 'list');
+ input.setAttribute('aria-controls', list.id); input.setAttribute('aria-expanded', 'false');
+ let matches = [], active = 0, range = null, composing = false, disposed = false;
+ const listeners = [];
+ const listen = (target, name, fn, options) => { target.addEventListener(name, fn, options); listeners.push(() => target.removeEventListener(name, fn, options)); };
+ function close() {
+ if (popup.hidePopover && popup.matches(':popover-open')) popup.hidePopover();
+ popup.hidden = true; input.setAttribute('aria-expanded', 'false'); input.removeAttribute('aria-activedescendant');
+ }
+ function place() {
+ if (popup.hidden) return;
+ const rect = input.getBoundingClientRect();
+ popup.style.width = `${Math.min(Math.max(rect.width, 260), innerWidth - 24)}px`;
+ const height = Math.min(popup.scrollHeight, 280);
+ popup.style.left = `${Math.max(12, Math.min(rect.left, innerWidth - popup.offsetWidth - 12))}px`;
+ popup.style.top = `${Math.max(12, rect.bottom + height + 8 < innerHeight ? rect.bottom + 6 : rect.top - height - 6)}px`;
+ }
+ function select(index) {
+ active = index;
+ for (const [i, option] of [...list.children].entries()) option.setAttribute('aria-selected', String(i === active));
+ const selected = list.children[active];
+ if (selected && matches.length) {
+ input.setAttribute('aria-activedescendant', selected.id);
+ if (selected.offsetTop < list.scrollTop) list.scrollTop = selected.offsetTop;
+ else if (selected.offsetTop + selected.offsetHeight > list.scrollTop + list.clientHeight)
+ list.scrollTop = selected.offsetTop + selected.offsetHeight - list.clientHeight;
+ }
+ else input.removeAttribute('aria-activedescendant');
+ }
+ function insert(value, start, end) {
+ input.focus(); input.setSelectionRange(start, end);
+ // Preserve the browser's native undo history for prompt edits.
+ if (!document.execCommand('insertText', false, value)) {
+ input.setRangeText(value, start, end, 'end'); input.dispatchEvent(new Event('input', {bubbles: true}));
+ }
+ }
+ function choose(index) {
+ if (!range || !matches[index]) return;
+ const item = matches[index], selection = range;
+ close(); insert(item.token + (/^\s/.test(input.value.slice(selection.end)) ? '' : ' '), selection.start, selection.end); close();
+ }
+ function refresh() {
+ if (disposed || composing || input.disabled || input.readOnly || document.activeElement !== input) { close(); return; }
+ range = mentionAt(input.value, input.selectionStart, input.selectionEnd);
+ if (!range) { close(); return; }
+ let available = [], invalid = false;
+ try { available = items(); } catch { invalid = true; }
+ matches = available.filter(item => `${item.name} ${item.token} ${t(item.kind, {image:'图片',video:'视频',audio:'音频'}[item.kind])} ${item.number}`.toLowerCase().includes(range.query));
+ list.replaceChildren();
+ if (!matches.length) {
+ const empty = document.createElement('div'); empty.className = 'fv-reference-empty';
+ empty.textContent = invalid ? t('Check your media selection.', '请检查素材用途是否冲突。')
+ : available.length ? t('No matching references', '没有匹配的素材') : t('Add reference media to use @', '添加参考素材后即可使用 @');
+ list.append(empty);
+ if (!available.length && !invalid && addMedia) {
+ const add = document.createElement('button'); add.type = 'button'; add.textContent = t('Add media', '添加素材');
+ add.onpointerdown = e => e.preventDefault();
+ add.onclick = () => { close(); addMedia(); }; list.append(add);
+ }
+ }
+ for (const [index, item] of matches.entries()) {
+ const option = document.createElement('div'); option.id = `${list.id}-${index}`;
+ option.className = 'fv-reference-option'; option.setAttribute('role', 'option');
+ const thumb = document.createElement(item.file && item.kind === 'image' ? 'img' : 'span');
+ thumb.className = 'fv-reference-thumb';
+ if (thumb.tagName === 'IMG') { thumb.src = view(item.file); thumb.alt = ''; }
+ else thumb.textContent = item.kind === 'audio' ? '♫' : item.kind === 'video' ? '▸' : '▧';
+ const label = document.createElement('span'), name = document.createElement('strong'), detail = document.createElement('small');
+ name.textContent = t({image:'Image',video:'Video',audio:'Audio'}[item.kind], {image:'图片',video:'视频',audio:'音频'}[item.kind]) + ` ${item.number}`;
+ detail.textContent = item.name; label.append(name, detail);
+ const token = document.createElement('code'); token.textContent = item.token;
+ option.append(thumb, label, token); option.title = item.name;
+ option.onpointerdown = e => e.preventDefault(); option.onclick = () => choose(index);
+ option.onpointermove = () => select(index); list.append(option);
+ }
+ const wasHidden = popup.hidden; popup.hidden = false;
+ if (wasHidden && popup.showPopover) popup.showPopover();
+ input.setAttribute('aria-expanded', 'true'); active = 0; select(active); place();
+ }
+ listen(input, 'input', refresh); listen(input, 'click', refresh);
+ listen(input, 'compositionstart', () => { composing = true; close(); });
+ listen(input, 'compositionend', () => { composing = false; refresh(); });
+ listen(input, 'keydown', e => {
+ if (composing || e.isComposing || e.keyCode === 229 || popup.hidden || e.ctrlKey || e.metaKey || e.altKey) return;
+ if (['ArrowDown','ArrowUp'].includes(e.key) && matches.length) {
+ e.preventDefault(); e.stopPropagation(); select((active + (e.key === 'ArrowDown' ? 1 : -1) + matches.length) % matches.length);
+ } else if ((e.key === 'Enter' || e.key === 'Tab') && !e.shiftKey && matches.length) {
+ e.preventDefault(); e.stopPropagation(); choose(active);
+ } else if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); close(); }
+ });
+ listen(input, 'keyup', e => { if (['ArrowLeft','ArrowRight','Home','End'].includes(e.key)) refresh(); });
+ listen(input, 'blur', () => { if (!popup.contains(document.activeElement)) close(); });
+ listen(document, 'pointerdown', e => { if (e.target !== input && !popup.contains(e.target)) close(); });
+ listen(window, 'resize', place);
+ listen(window, 'scroll', e => { if (!popup.contains(e.target)) place(); }, true);
+ return {
+ refresh,
+ open() {
+ if (input.disabled || input.readOnly) return;
+ if (!mentionAt(input.value, input.selectionStart, input.selectionEnd)) {
+ const prefix = input.value[input.selectionStart - 1] || '';
+ insert((/[\w.%+\-]/.test(prefix) ? ' ' : '') + '@', input.selectionStart, input.selectionEnd);
+ }
+ input.focus(); refresh();
+ },
+ dispose() { disposed = true; close(); listeners.forEach(stop => stop()); popup.remove(); for (const [name, value] of saved) { if (value === null) input.removeAttribute(name); else input.setAttribute(name, value); } },
+ };
+}
diff --git a/web/studio.js b/web/studio.js
index 6f370a7..a55966c 100644
--- a/web/studio.js
+++ b/web/studio.js
@@ -9,6 +9,7 @@ import { createPreviewScene } from './preview_scene.js?v=20260929-swell';
import { animateDetails, closeDialog } from './motion.js';
import { openLibrary, latestVideo } from './library.js';
import { createStudioQueue, randomSeed } from './studio_queue.js';
+import { attachReferencePicker, referenceItems, syncReferencePrompt } from './prompt_references.js';
const languageOverride = typeof location !== 'undefined'
? new URLSearchParams(location.search).get('freevideo_lang') : null;
@@ -139,9 +140,20 @@ export function openStudio(node) {
const section = (label, parent = controls) => { const wrap = el('section', null, 'fv-section'); wrap.append(el('div', label, 'fv-label')); parent.append(wrap); return wrap; };
const field = (name, input) => { const label = el('label', null, 'fv-field'); label.append(el('span', name), input); return label; };
const expand = label => { const d = el('details', null, 'fv-section'); d.append(el('summary', label, 'fv-section-title')); const content = el('div', null, 'fv-expand'); d.append(content); controls.append(d); cleanup.push(animateDetails(d)); return [d, content]; };
- const prompt = el('textarea'); prompt.value = value(node, 'text') || ''; prompt.placeholder = t('Describe the scene, movement, dialogue and sound…', '描述画面、动作、对白和声音…'); prompt.setAttribute('aria-label', t('Prompt', '提示词'));
+ syncReferencePrompt(node, t);
+ const prompt = el('textarea'); prompt.value = value(node, 'text') || ''; prompt.placeholder = t('Describe the scene… Type @ to reference media', '描述画面… 输入 @ 引用素材'); prompt.setAttribute('aria-label', t('Prompt', '提示词'));
prompt.disabled = linked(node, 'text'); prompt.oninput = () => set(node, 'text', prompt.value);
- section(t('Describe your scene', '描述画面')).append(prompt, promptGuide());
+ const promptEditor = el('div', null, 'fv-prompt-editor'); promptEditor.append(prompt);
+ const references = attachReferencePicker(prompt, {items: () => referenceItems(node), t, view, host: dialog,
+ addMedia: () => { mediaDetails.open = true; mediaDetails.scrollIntoView({block: 'nearest', behavior: 'smooth'}); mediaMount.querySelector('button')?.focus(); }});
+ const mention = button('@', () => references.open(), 'fv-reference-trigger');
+ mention.title = t('Reference media (@)', '引用素材(@)'); mention.setAttribute('aria-label', mention.title);
+ mention.disabled = prompt.disabled; mention.onpointerdown = e => e.preventDefault(); promptEditor.append(mention);
+ cleanup.push(() => references.dispose());
+ const promptChanged = e => { if (String(e.detail) === String(node.id)) { if (prompt.value !== value(node, 'text')) prompt.value = value(node, 'text') || ''; references.refresh(); } };
+ window.addEventListener('freevideo-reference-prompt', promptChanged);
+ cleanup.push(() => window.removeEventListener('freevideo-reference-prompt', promptChanged));
+ section(t('Describe your scene', '描述画面')).append(promptEditor, promptGuide());
const canvas = section(t('Frame & duration', '画幅与时长'));
const shapes = el('div', null, 'fv-shapes'); canvas.append(shapes);
const dimensionsLinked = linked(node, 'width') || linked(node, 'height');
diff --git a/web/theme.css b/web/theme.css
index cd68ee9..4fca3d9 100644
--- a/web/theme.css
+++ b/web/theme.css
@@ -1,7 +1,7 @@
/* One token table for the web views, mirroring freevideo_engine/branding.py so
a control looks the same in the launcher and in ComfyUI. Scope the tokens to
our own views; never change ComfyUI's theme. */
-:where(.fv-studio,.fv-setup,.fv-panel,.fv-generation-progress,.fv-view-navigation,.fv-prompt-guide,.fv-failure-dialog){
+:where(.fv-studio,.fv-setup,.fv-panel,.fv-generation-progress,.fv-view-navigation,.fv-prompt-guide,.fv-failure-dialog,.fv-reference-picker){
/* Surfaces, from the backdrop up to a hovered control; mirrors branding.py. */
--fv-bg:#111720;--fv-canvas:#161e29;--fv-card:#1a222e;--fv-raised:#212a37;--fv-hover:#2a3341;
--fv-border:#2a3443;--fv-sheen:#35404e;