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.

Editor: keep the project name readable in narrow windows

Bowen Xue3b9f52e4d9ad
diff --git a/web/editor.css b/web/editor.css
index 89de825..694a5ff 100644
--- a/web/editor.css
+++ b/web/editor.css
@@ -189,6 +189,13 @@
}
.fv-ed-name-menu{max-height:calc(100dvh - 72px);overflow-y:auto}
+/* editor_header_fit.js: when the project name would not stay readable beside a centred view switch, the logo takes its phone size, then leaves, then the switch takes a second row. */
+.fv-studio.fv-editor .fv-header[data-fit~=compact] .fv-wordmark{width:90px}
+.fv-studio.fv-editor .fv-header[data-fit~=bare] .fv-wordmark{display:none}
+.fv-studio.fv-editor .fv-header[data-fit~=wrap]{height:auto;min-height:98px;grid-template-columns:minmax(0,1fr) auto;padding-block:10px}
+.fv-studio.fv-editor .fv-header[data-fit~=wrap]>.fv-view-switch{grid-column:1/-1;grid-row:2;justify-self:center}
+.fv-studio.fv-editor .fv-header[data-fit~=wrap]>.fv-header-actions{grid-column:2;grid-row:1}
+.fv-studio.fv-editor .fv-header[data-fit~=wrap] .fv-ed-name{max-width:320px}
.fv-ed-volume-popover{position:absolute;top:calc(100% + 8px);left:0;display:flex;align-items:center;gap:8px;padding:10px 12px;border:1px solid var(--fv-border);border-radius:8px;background:var(--fv-card);white-space:nowrap;z-index:8}
.fv-ed-volume{width:90px}.fv-ed-volume-value{font-variant-numeric:tabular-nums;font-size:12px;min-width:34px}
diff --git a/web/editor.js b/web/editor.js
index 084e7aa..385f35f 100644
--- a/web/editor.js
+++ b/web/editor.js
@@ -25,6 +25,7 @@ import {isolateDialogKeys, topDialog} from './dialog_keys.js';
import {createBlockNotes, describedTrack} from './editor_notes.js';
import {createFirstRunGuide} from './first_run_guide.js';
import {createEditorFailures} from './editor_failure.js';
+import {fitEditorHeader} from './editor_header_fit.js';
const editorStyles = Promise.all(['result_actions.css', 'editor.css', 'editor_tracks.css', 'editor_frame.css', 'editor_adjust.css', 'editor_adjust_picture.css', 'editor_preview_picture.css', 'editor_select.css', 'editor_menu.css', 'editor_text.css', 'editor_notes.css', 'editor_transport.css'].map(name => {
const style = document.createElement('link'); style.rel = 'stylesheet'; style.href = new URL(name, import.meta.url).href;
const ready = 'sheet' in style ? new Promise(resolve => { style.onload = style.onerror = resolve; }) : Promise.resolve();
@@ -177,6 +178,7 @@ export function openEditor({api, app, from = null, panel = {}, components: given
exportBox.append(exportHint, exportButton, exportCancel); brand.append(wordmark(), title);
headerActions.append(exportBox, button(t('Settings', '设置'), openSetup, 'fv-quiet'));
top.append(brand, navigation, headerActions);
+ const headerFit = fitEditorHeader(top, brand, title, navigation, headerActions);
const menu = el('div', 'fv-ed-name-menu'); menu.hidden = true; menu.setAttribute('role', 'menu');
// Up and Down move through the name box and the items; Home and End go to either end.
menu.onkeydown = event => {
@@ -448,7 +450,9 @@ export function openEditor({api, app, from = null, panel = {}, components: given
return !!state.record.id;
}
function updateTop() {
- title.replaceChildren(el('span', '', state.record.name || new Date().toLocaleDateString()), icon('m4 6 4 4 4-4')); title.title = state.record.name;
+ const name = state.record.name || new Date().toLocaleDateString();
+ if (title.firstElementChild?.textContent !== name) { title.replaceChildren(el('span', '', name), icon('m4 6 4 4 4-4')); headerFit.check(); }
+ title.title = state.record.name;
exportButton.classList.toggle('fv-primary', !!model.exportFrames(state.record) && !state.selection && !jobActive() && !exportStatus);
const running = exportPreparing || ['running', 'queued'].includes(exportStatus?.state);
if (['running', 'queued'].includes(exportStatus?.state)) exportButton.textContent = t(`Export ${Math.round((exportStatus.fraction || 0) * 100)}%`, `导出 ${Math.round((exportStatus.fraction || 0) * 100)}%`);
@@ -1183,7 +1187,7 @@ export function openEditor({api, app, from = null, panel = {}, components: given
}
rememberView(); disposed = true; guide?.dispose(); transportControls.dispose(); toolbarMore.dispose(); player.dispose();
textTools.dispose(); adjust.dispose(); notes.dispose(); pictureEdit.dispose();
- audio.dispose();
+ audio.dispose(); headerFit.dispose();
listeners.splice(0).forEach(remove => remove());
for (const node of [element, ...element.querySelectorAll('*')]) for (const name of ['onclick', 'ondblclick', 'oninput', 'onchange', 'onkeydown', 'ondragstart']) node[name] = null;
unsubscribe(); stopSources(); library?.dispose(); genbar.dispose(); tracks?.dispose(); stopExport?.();
diff --git a/web/editor_header_fit.js b/web/editor_header_fit.js
new file mode 100644
index 0000000..fe58c0a
--- /dev/null
+++ b/web/editor_header_fit.js
@@ -0,0 +1,31 @@
+// The view switch stays centred in the editor's header while the project name next to the logo stays readable.
+// When it would not, the logo first takes its phone size, then gives its place to the name; if that is still too tight, the switch moves to a second row.
+// About six Chinese characters or ten Latin letters of the name itself, without the menu arrow.
+const READABLE = 120, COMPACT_MARK = 90;
+
+export function fitEditorHeader(header, brand, title, navigation, actions) {
+ if (typeof ResizeObserver !== 'function' || typeof getComputedStyle !== 'function' || typeof matchMedia !== 'function') return {check() {}, dispose() {}};
+ const px = value => parseFloat(value) || 0;
+ function check() {
+ const span = title.firstElementChild, mark = brand.firstElementChild;
+ if (!header.isConnected || !span || !header.clientWidth) return;
+ // Measure the plain layout, so the result never depends on the one applied before.
+ delete header.dataset.fit;
+ const box = getComputedStyle(header), gap = px(box.columnGap), inner = header.clientWidth - px(box.paddingLeft) - px(box.paddingRight);
+ const side = (inner - navigation.offsetWidth - 2 * gap) / 2, spacing = px(getComputedStyle(brand).columnGap);
+ const own = getComputedStyle(title), chevron = span.nextElementSibling, text = document.createRange(); text.selectNodeContents(span);
+ const frame = px(own.paddingLeft) + px(own.paddingRight) + px(own.borderLeftWidth) + px(own.borderRightWidth) + (chevron ? chevron.getBoundingClientRect().width + px(own.columnGap) : 0);
+ const wanted = Math.min(READABLE, text.getBoundingClientRect().width) + frame;
+ const fits = markWidth => side >= actions.offsetWidth && side - markWidth - spacing >= wanted;
+ const compact = Math.min(COMPACT_MARK, mark.offsetWidth);
+ // On two rows the name shares the first row with the actions only; the logo shrinks too when that is still tight.
+ const rowFits = inner - actions.offsetWidth - gap - mark.offsetWidth - spacing >= wanted;
+ // From 681 px up the switch has one place in every view, so the logo leaves before the switch moves down.
+ const bare = !matchMedia('(max-width:680px)').matches && side >= actions.offsetWidth && side >= wanted;
+ const fit = fits(mark.offsetWidth) ? '' : fits(compact) ? 'compact' : bare ? 'bare' : rowFits ? 'wrap' : 'wrap compact';
+ if (fit) header.dataset.fit = fit;
+ }
+ const observer = new ResizeObserver(check);
+ observer.observe(header); observer.observe(navigation); observer.observe(actions);
+ return {check, dispose: () => observer.disconnect()};
+}
diff --git a/web/health.js b/web/health.js
index cb0910f..538e8ed 100644
--- a/web/health.js
+++ b/web/health.js
@@ -14,7 +14,7 @@ const t = (en, zh) => cn ? zh : en;
const launchVisit = query.get('freevideo') === 'launch';
// Every script this folder ships; a test keeps the list in step with web/*.js.
export const MODULES = ['agent_activity.js', 'agent_connect.js', 'agent_session.js', 'autopilot.js', 'autopilot_chat.js', 'autopilot_conversations.js', 'browser_extension.js', 'caret_rect.js', 'chain_support.js', 'capability_view.js', 'compatibility.js', 'error_panel.js', 'first_run_guide.js', 'fonts.js', 'freevideo.js', 'generation_progress.js',
- 'editor.js', 'editor_actions.js', 'editor_adjust.js', 'editor_adjust_picture.js', 'editor_picture_fields.js', 'editor_picture_session.js', 'editor_preview_picture.js', 'editor_entry.js', 'editor_export_dialog.js', 'editor_first_frame.js', 'editor_media_references.js', 'editor_references.js', 'editor_genbar.js', 'editor_geometry.js', 'editor_library.js', 'editor_menu.js', 'editor_model.js', 'editor_frame.js', 'editor_player.js', 'editor_room.js', 'editor_select.js', 'editor_state.js', 'editor_store.js', 'editor_tracks.js', 'editor_generation.js', 'editor_transport.js', 'editor_transport_model.js', 'editor_audio.js', 'editor_audio_model.js', 'editor_audio_notes.js', 'editor_audio_replace.js', 'editor_audio_rules.js', 'editor_speed.js', 'editor_speed_model.js', 'editor_failure.js',
+ 'editor.js', 'editor_actions.js', 'editor_adjust.js', 'editor_adjust_picture.js', 'editor_picture_fields.js', 'editor_picture_session.js', 'editor_preview_picture.js', 'editor_entry.js', 'editor_export_dialog.js', 'editor_first_frame.js', 'editor_media_references.js', 'editor_references.js', 'editor_genbar.js', 'editor_geometry.js', 'editor_library.js', 'editor_menu.js', 'editor_model.js', 'editor_frame.js', 'editor_player.js', 'editor_room.js', 'editor_select.js', 'editor_state.js', 'editor_store.js', 'editor_tracks.js', 'editor_generation.js', 'editor_transport.js', 'editor_transport_model.js', 'editor_audio.js', 'editor_audio_model.js', 'editor_audio_notes.js', 'editor_audio_replace.js', 'editor_audio_rules.js', 'editor_speed.js', 'editor_speed_model.js', 'editor_failure.js', 'editor_header_fit.js',
'editor_loader.js', 'editor_text_coverage.js', 'editor_text.js', 'editor_toolbar_more.js', 'editor_text_model.js', 'editor_text_layout.js', 'editor_notes.js', 'editor_icons.js', 'dialog_keys.js', 'done_notify.js', 'frame_sizes.js', 'health.js', 'image_commands.js', 'image_editor.js', 'image_editor_engine.js', 'image_generation.js', 'launcher.js', 'length_plan.js', 'lora_triggers.js', 'library.js', 'motion.js', 'output_download.js', 'port_notice.js', 'preview_scene.js',
'progress_connection.js', 'prompt_draft.js', 'prompt_enhance.js', 'prompt_references.js', 'prompt_terms.js', 'report_issue.js', 'studio_recent.js',
'result_actions.js', 'sampling_effort.js', 'setup.js', 'share.js', 'share_layout.js', 'studio.js', 'studio_chain.js', 'studio_extend.js', 'studio_length.js', 'first_frame_row.js', 'optional_inputs.js', 'studio_queue.js', 'studio_size.js',