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.

Prompt pop-ups (media mentions and camera words) open under the line being typed

Bowen Xueedd14a500083
diff --git a/web/caret_rect.js b/web/caret_rect.js
new file mode 100644
index 0000000..c3b3b90
--- /dev/null
+++ b/web/caret_rect.js
@@ -0,0 +1,21 @@
+// Where the caret of a textarea is on screen, for popups that should sit under the line being typed.
+const COPIED = ['boxSizing', 'borderTopWidth', 'borderRightWidth', 'borderBottomWidth', 'borderLeftWidth',
+ 'paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft', 'fontFamily', 'fontSize', 'fontStyle', 'fontWeight',
+ 'fontVariant', 'letterSpacing', 'lineHeight', 'textTransform', 'textIndent', 'tabSize', 'wordSpacing', 'direction'];
+export function caretRect(input, index = input.selectionStart) {
+ const box = input.getBoundingClientRect(), style = getComputedStyle(input);
+ const mirror = document.createElement('div');
+ for (const name of COPIED) mirror.style[name] = style[name];
+ Object.assign(mirror.style, {position: 'fixed', left: '-9999px', top: '0', visibility: 'hidden',
+ whiteSpace: 'pre-wrap', overflowWrap: 'break-word', width: `${input.clientWidth + parseFloat(style.borderLeftWidth) + parseFloat(style.borderRightWidth)}px`,
+ height: 'auto', overflow: 'hidden'});
+ mirror.textContent = String(input.value).slice(0, index);
+ const marker = document.createElement('span'); marker.textContent = '​';
+ mirror.append(marker); document.body.append(mirror);
+ const top = marker.offsetTop, left = marker.offsetLeft, height = marker.offsetHeight || parseFloat(style.fontSize) * 1.3;
+ mirror.remove();
+ const border = parseFloat(style.borderTopWidth) || 0;
+ // The line the caret is on, clipped to the visible part of the box when the text is scrolled.
+ const lineTop = Math.min(Math.max(box.top + border + top - input.scrollTop, box.top), box.bottom - height);
+ return {left: box.left + (parseFloat(style.borderLeftWidth) || 0) + left, top: lineTop, bottom: lineTop + height};
+}
diff --git a/web/health.js b/web/health.js
index caaa5ce..cb0910f 100644
--- a/web/health.js
+++ b/web/health.js
@@ -13,7 +13,7 @@ const t = (en, zh) => cn ? zh : en;
// launcher.js removes this flag during setup; read it before that.
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', 'chain_support.js', 'capability_view.js', 'compatibility.js', 'error_panel.js', 'first_run_guide.js', 'fonts.js', 'freevideo.js', 'generation_progress.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_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',
diff --git a/web/prompt_references.js b/web/prompt_references.js
index 160ec1c..3dfb0ac 100644
--- a/web/prompt_references.js
+++ b/web/prompt_references.js
@@ -1,4 +1,5 @@
// H3 numbers each reference kind separately, in the order of comfy_media.export.
+import {caretRect} from './caret_rect.js';
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];
@@ -125,7 +126,8 @@ export function attachReferencePicker(input, {items, t = en => en, view, host, a
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`;
+ const line = caretRect(input);
+ popup.style.top = `${Math.max(12, line.bottom + height + 8 < innerHeight ? line.bottom + 4 : line.top - height - 4)}px`;
}
function select(index) {
active = index;
diff --git a/web/prompt_terms.js b/web/prompt_terms.js
index d00db45..d3f9589 100644
--- a/web/prompt_terms.js
+++ b/web/prompt_terms.js
@@ -1,5 +1,6 @@
// Camera and motion words offered while a prompt is typed. The list is local; nothing is sent anywhere,
// a word is written only when it is chosen, and the typed language decides which form is inserted.
+import {caretRect} from './caret_rect.js';
export const TERMS = [
['dolly in', '推镜头'], ['dolly out', '拉镜头'], ['pan left', '左摇镜头'], ['pan right', '右摇镜头'],
['tilt up', '上摇镜头'], ['tilt down', '下摇镜头'], ['tracking shot', '跟拍镜头'], ['orbit shot', '环绕镜头'],
@@ -70,7 +71,8 @@ export function attachTermSuggest(input, {t = en => en, host, suppressed = () =>
popup.style.width = `${Math.min(Math.max(rect.width * .6, 240), innerWidth - 24)}px`;
const height = Math.min(popup.scrollHeight, 220);
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`;
+ const line = caretRect(input);
+ popup.style.top = `${Math.max(12, line.bottom + height + 8 < innerHeight ? line.bottom + 4 : line.top - height - 4)}px`;
}
function select(index) {
active = index;