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 text: dropping onto a locked text track says the track is locked

Bowen Xue4c329a809851
diff --git a/web/editor_select.js b/web/editor_select.js
index 7a0339b..684ebbb 100644
--- a/web/editor_select.js
+++ b/web/editor_select.js
@@ -5,6 +5,7 @@ import {copyContent, pasteContent, copyRange, pasteRange, playheadTargets, remov
export {copyContent, pasteContent} from './editor_room.js';
import {transportSnapPoints} from './editor_transport_model.js';
import {unlockedIds} from './editor_audio_model.js';
+import {isTextTrack, textDropLocked} from './editor_text_model.js';
const end = clip => clip.start + clip.frames;
const busy = clip => ['queued', 'running'].includes(clip.pending);
@@ -143,11 +144,13 @@ export function createSelectionActions({state, t = en => en, actions = {}, clipb
// project, dispatching selection events, or rebuilding clip DOM.
export function prepareMove(record, ids) {
const selected = model.linkedIds(record, ids), members = all(record).filter(clip => selected.has(clip.id));
- const rows = record.tracks.map(track => ({moving: track.clips.filter(clip => selected.has(clip.id)), others: track.clips.filter(clip => !selected.has(clip.id))}));
+ const rows = record.tracks.map(track => ({locked: isTextTrack(track) && track.locked,
+ moving: track.clips.filter(clip => selected.has(clip.id)), others: track.clips.filter(clip => !selected.has(clip.id))}));
const start = Math.min(...members.map(clip => clip.start)), stop = Math.max(...members.map(end));
- return {ids: [...selected], start, end: stop, members, preview(delta) {
+ return {ids: [...selected], start, end: stop, members, preview(delta, trackId = null) {
delta = Math.max(-start, delta);
- let code = members.some(busy) ? 'busy' : null;
+ let code = rows.some(row => row.locked && row.moving.length) || textDropLocked(record, members, trackId) ? 'locked'
+ : members.some(busy) ? 'busy' : null;
for (const {moving, others} of rows) {
let i = 0;
for (const clip of moving) {
@@ -241,7 +244,8 @@ export function createSelectionGestures({state, element, content, scroll, clips,
const clip = clips.get(g.id).clip, desired = clip.start + Math.round((p.x - g.start.x) * model.FPS / state.zoom);
const points = [...g.points, ...[desired, desired + clip.frames].map(frame => Math.round(frame / (5 * model.FPS)) * 5 * model.FPS)];
const aligned = snap(Math.max(0, desired), transportSnapPoints(state, points, event), state.zoom, {offsets: [0, clip.frames]});
- const result = g.plan.preview(aligned.frame - clip.start); g.result = result;
+ const track = [...rows].find(([, row]) => p.y >= row.top && p.y <= row.top + row.height)?.[0];
+ const result = g.plan.preview(aligned.frame - clip.start, track); g.result = result;
if (result.code === 'busy') {
if (!g.warned) { g.warned = true; commands.report(new model.EditError('busy')); }
return;
@@ -283,6 +287,7 @@ export function createSelectionGestures({state, element, content, scroll, clips,
if (cancel) state.select(g.previous);
else if (g.type === 'box') { const ids = g.selected || (adding(g) ? selectedIds(g.record, g.previous) : []); state.select(selection(ids), {history: true}); anchor = ids.at(-1) ?? null; }
else if (g.type === 'move' && !g.moved) choose(g.id);
+ else if (g.type === 'move' && g.result?.code === 'locked') commands.report(new model.EditError('locked'));
else if (g.type === 'move' && g.result && !g.result.code) state.apply(t('Move', '移动'), record => actionsModel.moveParts(record, g.plan.ids, {frames: g.result.delta, track: null}));
} catch (error) { commands.report(error); }
finally { paint(selectedIds(state.record, state.selection)); renderSelection(); actions.gestureEnd?.(); }
diff --git a/web/editor_text_model.js b/web/editor_text_model.js
index 8055646..b7d3271 100644
--- a/web/editor_text_model.js
+++ b/web/editor_text_model.js
@@ -65,6 +65,9 @@ export function readTextProject(raw, parseMedia) {
export function assertUnlocked(record, ids) {
check(!record.tracks.some(t => t.locked && t.clips.some(c => ids.includes(c.id))), 'locked');
}
+// Timeline moves keep their original lanes, but text cannot land over a locked overlay lane.
+export const textDropLocked = (record, clips, trackId) => clips.some(isText)
+ && record.tracks.some(track => track.id === trackId && isTextTrack(track) && track.locked);
export function addText(record, {kind = 'text', at = 0, text = '', style, frames = kind === 'subtitle' ? 48 : 72} = {}) {
check(['text', 'subtitle'].includes(kind));
const next = model.serialize(record); let row = next.tracks.find(t => t.kind === kind);
diff --git a/web/editor_tracks.js b/web/editor_tracks.js
index 31941d1..d4d9212 100644
--- a/web/editor_tracks.js
+++ b/web/editor_tracks.js
@@ -1,5 +1,5 @@
import {editorIcon} from './editor_icons.js';
-import {displayTracks, isText, isTextTrack} from './editor_text_model.js';
+import {displayTracks, isText, isTextTrack, textDropLocked} from './editor_text_model.js';
// Pointer gestures translate coordinates into model calls; the model owns edits.
// These exports deliberately have no DOM dependencies, so input arithmetic can
// be checked in Node with the same code that runs in the browser.
@@ -774,6 +774,7 @@ export function createTracks(host, {state, sources = {}, t = en => en, actions =
plannedLines.hidden = true;
const desired = gesture.clip.start + frame - gesture.anchor;
const result = moveParameters(gesture.clip, gesture.anchor, frame, dragPoints(desired, gesture.clip.frames), state.zoom);
+ result.track = isText(gesture.clip) ? pointerHit(event).track : null;
gesture.result = result;
const track = state.record.tracks.find(row => row.id === gesture.track);
const drop = isText(gesture.clip) ? {hit: false} : insertionPoint(track.clips, result.frame, gesture.ids);
@@ -783,7 +784,10 @@ export function createTracks(host, {state, sources = {}, t = en => en, actions =
}
gesture.rightPreviewIds = [];
let preview, error, shifted = 0;
- try { preview = model.move(state.record, gesture.id, result.frame); }
+ try {
+ if (textDropLocked(state.record, gesture.members, result.track)) throw new model.EditError('locked');
+ preview = model.move(state.record, gesture.id, result.frame);
+ }
catch (caught) { if (!(caught instanceof model.EditError)) throw caught; error = caught; }
if (preview) for (const row of preview.tracks) for (const clip of row.clips) {
const item = locate(clip.id);
@@ -913,7 +917,10 @@ export function createTracks(host, {state, sources = {}, t = en => en, actions =
if (['range', 'rangeMove', 'rangeEdge', 'rangeBoundary'].includes(finished.type)) { state.select(finished.selection, {history: true}); return; }
const result = finished.result;
if (!result) return;
- if (finished.type === 'move') attempt(t('Move', '移动'), record => model.move(record, finished.id, result.frame));
+ if (finished.type === 'move') attempt(t('Move', '移动'), record => {
+ if (textDropLocked(record, finished.members, result.track)) throw new model.EditError('locked');
+ return model.move(record, finished.id, result.frame);
+ });
else if (finished.type === 'plannedBoundary') attempt(t('Resize parts', '调整段长'), record => model.resizePlannedBoundary(record, finished.id, finished.neighbor.clip.id, result.frame, actions.generationLimits?.()));
else if (result.kind === 'planned') attempt(t('Resize', '改长短'), record => model.resizePlanned(record, finished.id, finished.edge, result.frame, actions.generationLimits?.()));
else if (result.kind === 'extend') {