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 a description for each planned part

Bowen Xue5ee953d245ea
diff --git a/web/editor.js b/web/editor.js
index 1c55f65..eb1fdd1 100644
--- a/web/editor.js
+++ b/web/editor.js
@@ -392,6 +392,22 @@ export function openEditor({api, app, from = null, panel = {}, components: given
const generating = clip => ['queued', 'running'].includes(clip?.pending);
const isHeld = id => held.some(entry => entry.ids.includes(id));
const partBefore = start => state.record.tracks[0].clips.find(clip => clip.frames > 0 && clip.start + clip.frames === start);
+ // A planned part whose description is still the user's to write: not started, not being sent.
+ const editablePart = clip => !!clip && !clip.source && clip.pending === 'draft' && !clip.job && !sending.has(clip.id);
+ const attached = (clip, before) => !!before && before.start + before.frames === clip.start && model.continuesBefore(state.record, clip.id);
+ // The planned parts Generate makes from a choice of planned parts: with the parts before them that they
+ // continue and that are not started yet, as one video; a part whose earlier part is not started would
+ // otherwise start a new one.
+ function partRun(selection) {
+ const free = clip => editablePart(clip) && !isHeld(clip.id);
+ const clips = selectionClips(selection).sort((a, b) => a.start - b.start);
+ if (!clips.length || !clips.every(free)) return null;
+ if (!clips.every((clip, i) => !i || attached(clip, clips[i - 1]))) return clips;
+ const run = [...clips];
+ for (let before; attached(run[0], before = partBefore(run[0].start)) && free(before);) run.unshift(before);
+ return run;
+ }
+ const clipChoice = clips => ({kind: 'clip', ids: clips.flatMap(clip => clip.link ? [clip.id, clip.link] : [clip.id])});
function busySelection(selection) {
const range = selectionRange(selection); if (!range) return false;
if ([...sendingRanges].some(other => overlaps(other, range))) return true;
@@ -438,13 +454,13 @@ export function openEditor({api, app, from = null, panel = {}, components: given
progress.set(id, value); tracks?.setProgress(id, value);
} };
const queuedReady = () => t('Queued. It starts once generation is ready.', '已排队,准备好后自动开始。');
- function hold(selection, text, job = null) {
- const range = selectionRange(selection), selectedIds = selectionClips(selection).map(clip => clip.id), shown = selection === state.selection;
+ function hold(selection, text, job = null, {texts = null, shown = selection === state.selection} = {}) {
+ const range = selectionRange(selection), selectedIds = selectionClips(selection).map(clip => clip.id);
let ids = [];
if (job) ids = selectedIds;
else state.apply(t('Generate', '生成'), record => {
const selected = selectedIds.map(id => model.find(record, id)).filter(Boolean), planned = selected.length && selected.every(clip => !clip.source && clip.pending && !generating(clip));
- const next = planned ? model.startAttempt(record, selected.map(clip => clip.id), text) : model.planRange(record, {...range, target: 'both', text, maxSeconds: capability.maxSeconds, maxFollowSeconds: capability.maxFollowSeconds});
+ const next = planned ? model.startAttempt(record, selected.map(clip => clip.id), texts ?? text) : model.planRange(record, {...range, target: 'both', text, maxSeconds: capability.maxSeconds, maxFollowSeconds: capability.maxFollowSeconds});
ids = next.tracks[0].clips.filter(clip => clip.start >= range.start && clip.start < range.start + range.frames && clip.pending && !generating(clip)).map(clip => clip.id);
return next;
}, {checkpoint: true});
@@ -471,7 +487,9 @@ export function openEditor({api, app, from = null, panel = {}, components: given
const selection = {kind: 'clip', ids: clips.map(clip => clip.id)}, before = partBefore(Math.min(...clips.map(clip => clip.start)));
held.shift(); markHeld(entry.ids, false); rememberView();
if (before && !before.source && before.pending && !before.job) { genbar?.say(t('The part before did not finish, so this one did not start.', '上一段没有完成,这一段没有开始。')); continue; }
- try { await actions.generate({text: entry.text, selection}); }
+ // Each part goes with its own description, as written while it waited.
+ const texts = Object.fromEntries(clips.map(clip => [clip.id, clip.text.trim() || entry.text]));
+ try { await actions.generate({text: texts[clips[0].id], texts, selection}); }
catch (value) { const reason = error(value, 'generate'); if (reason && !['chain_too_long', 'chain_part_too_short'].includes(reason.reason)) genbar?.say(reason.say); }
}
} finally { startingHeld = false; }
@@ -774,6 +792,8 @@ export function openEditor({api, app, from = null, panel = {}, components: given
generationWaiting: () => generationAsked && !store.generationAvailable,
importFiles: (files, options) => library?.importFiles(files, options),
gestureStart({selectionGesture = false} = {}) {
+ // A description being typed is written to its part before the gesture, which a later edit would stop.
+ genbar?.commit();
pointerEditing = true;
if (selectionGesture && !menu.hidden) { menu.hidden = true; updateTransport(); }
},
@@ -834,13 +854,25 @@ export function openEditor({api, app, from = null, panel = {}, components: given
canGenerate(text, selection = state.selection) {
return store.generationAvailable && actions.supportedSelection(selection) && (!!text.trim() || !actions.needsText(selection));
},
+ // The description the box shows for a choice of planned parts, and the parts it is written to; null for
+ // any other choice.
+ partText(selection = state.selection) {
+ const clips = selectionClips(selection).sort((a, b) => a.start - b.start);
+ return clips.length && clips.every(editablePart) ? {ids: clips.map(clip => clip.id), text: clips[0].text} : null;
+ },
+ describeParts(ids, text) {
+ if (!ids.every(id => editablePart(model.find(state.record, id)))) return false;
+ try { state.apply(t('Edit description', '修改说明'), record => model.describePlanned(record, ids, text)); return true; }
+ catch (value) { if (value instanceof model.EditError) return false; throw value; }
+ },
needsText(selection = state.selection) {
const range = selectionRange(selection); if (!range) return true;
- // Only a part pulled out of a finished one needs no description: it continues that one with the
- // description it took over. A finished video without one (an exported edit) still needs it.
+ // Only a part pulled out of a finished one needs no description: it continues that one, with that one's
+ // description when it has none of its own. A finished video without one (an exported edit) still needs it.
const head = state.record.tracks[0].clips.find(clip => clip.start === range.start);
- const before = !!head && !!head.text?.trim() && model.continuesBefore(state.record, head.id) && state.record.tracks[0].clips.some(clip =>
- clip.start + clip.frames === range.start && clip.source && clip.extend && clip.in + clip.frames === clip.length);
+ const before = !!head && model.continuesBefore(state.record, head.id) && state.record.tracks[0].clips.some(clip =>
+ clip.start + clip.frames === range.start && clip.source && clip.extend && clip.in + clip.frames === clip.length
+ && !!(head.text?.trim() || clip.text?.trim()));
return !before;
},
// Only where earlier footage is continued: a part right after an extendable clip, or a range split into several parts.
@@ -864,16 +896,17 @@ export function openEditor({api, app, from = null, panel = {}, components: given
}},
previewRange: selection => genbar?.preview(selection),
async estimate(selection) {
- const range = selectionRange(selection); if (!range) return null;
+ const run = partRun(selection), range = selectionRange(run ? clipChoice(run) : selection); if (!range) return null;
let seconds = 0;
for (const count of model.rangeParts(state.record, {...range, ...capability})) { const value = capability.estimate(count); if (value == null) return null; seconds += value; }
return seconds;
},
- async generate({target = 'both', text = '', label = t('Generate', '生成'), selection = state.selection} = {}) {
+ // texts: a description for each planned part, by the part's picture; otherwise text is every part's.
+ async generate({target = 'both', text = '', texts = null, label = t('Generate', '生成'), selection = state.selection, shown = selection === state.selection} = {}) {
if (target !== 'both' || !actions.supportedSelection(selection)) throw new model.EditError('unsupported');
if (!actions.canGenerate(text, selection)) throw new model.EditError('text');
submissionFailure = null; genbar?.update(null);
- const shown = selection === state.selection;
+ const chosen = state.selection;
generationBusy = true; updateTop(); updateTransport();
generationDone = new Promise(resolve => { finishGeneration = resolve; });
let ids = [], prepared = null, beforeAttempt = null, priorSelection = null, priorText = null, submittedSelection = null, frozen = null;
@@ -884,7 +917,7 @@ export function openEditor({api, app, from = null, panel = {}, components: given
beforeAttempt = state.record; priorSelection = state.selection; priorText = state.rangeText;
state.apply(label, record => {
const selected = selectedIds.map(id => model.find(record, id)).filter(Boolean), alreadyPlanned = selected.length && selected.every(clip => !clip.source && clip.pending && !['queued', 'running'].includes(clip.pending));
- let next = alreadyPlanned ? model.startAttempt(record, selected.map(clip => clip.id), text) : model.planRange(record, {...range, target: 'both', text, maxSeconds: capability.maxSeconds, maxFollowSeconds: capability.maxFollowSeconds});
+ let next = alreadyPlanned ? model.startAttempt(record, selected.map(clip => clip.id), texts ?? text) : model.planRange(record, {...range, target: 'both', text, maxSeconds: capability.maxSeconds, maxFollowSeconds: capability.maxFollowSeconds});
if (!record.tracks[0].clips.length && text.trim()) next = model.rename(next, model.truncateText(text.trim(), 40));
ids = next.tracks[0].clips.filter(clip => clip.start >= range.start && clip.start < range.start + range.frames && clip.pending && !['queued', 'running'].includes(clip.pending)).map(clip => clip.id);
return model.prepare(next, ids);
@@ -893,9 +926,9 @@ export function openEditor({api, app, from = null, panel = {}, components: given
prepared = state.record;
// Only a press on what is still chosen moves the choice; a part started in the background
// leaves whatever the user has moved on to, and what they typed there.
- submittedSelection = shown && state.selection === selection ? state.select({kind: 'clip', ids}) : state.selection; await completeSources();
+ submittedSelection = shown && state.selection === chosen ? state.select({kind: 'clip', ids}) : state.selection; await completeSources();
const paths = Object.fromEntries([...store.sources].map(([key, value]) => [key, value.path]));
- const request = model.generationRequest(prepared, ids, {text, paths, queue: true});
+ const request = model.generationRequest(prepared, ids, {text: texts ? undefined : text, paths, queue: true});
const beforeKeys = model.generationBefore(prepared, ids), sizes = new Map(store.sources);
for (const key of beforeKeys.filter(key => key?.startsWith('chain:'))) {
const job = await store.chain(key.split(':')[1]);
@@ -973,12 +1006,31 @@ export function openEditor({api, app, from = null, panel = {}, components: given
if (!moved) return {say: t('Choose an empty spot on the timeline.', '请在时间线上选一段空白。')};
selection = state.select(moved); said = t('Moved to the next empty spot.', '已挪到后面的空位。'); genbar?.say(said);
}
- let used = null;
- if (!text.trim() && actions.needsText(selection)) {
+ let used = null, texts = null, shown = selection === state.selection;
+ const before = t('Used the description of the part before.', '沿用了上一段的描述。'), latest = t('Used the latest description.', '沿用了最近一次的描述。');
+ let run = partRun(selection);
+ if (run) {
+ // What is in the box is the chosen parts' description; each part goes with its own, and one with
+ // none uses the one before it.
+ const chosen = selectionClips(selection).sort((a, b) => a.start - b.start);
+ if (text.trim() && text.trim() !== chosen[0].text && actions.describeParts(chosen.map(clip => clip.id), text)) run = partRun(selection);
+ texts = {};
+ for (const [i, clip] of run.entries()) {
+ let value = clip.text.trim();
+ if (!value && i && attached(clip, run[i - 1])) { value = texts[run[i - 1].id]; used ??= before; }
+ else if (!value) {
+ const found = nearbyText(clip.start);
+ if (!found) return {say: [said, t('Write a description first.', '先写一句描述。')].filter(Boolean).join(' '), focus: true};
+ value = found.text; used ??= found.before ? before : latest;
+ }
+ texts[clip.id] = value;
+ }
+ text = texts[chosen[0].id];
+ selection = clipChoice(run);
+ } else if (!text.trim() && actions.needsText(selection)) {
const found = nearbyText(selectionRange(selection).start);
if (!found) return {say: [said, t('Write a description first.', '先写一句描述。')].filter(Boolean).join(' '), focus: true};
- text = found.text; used = found.before ? t('Used the description of the part before.', '沿用了上一段的描述。')
- : t('Used the latest description.', '沿用了最近一次的描述。');
+ text = found.text; used = found.before ? before : latest;
state.setRangeText(text); genbar?.setText(text);
} else if (!text.trim()) {
// The box was emptied; the part keeps the description it took over, as an empty one cannot be generated.
@@ -987,12 +1039,12 @@ export function openEditor({api, app, from = null, panel = {}, components: given
}
const waiting = waitingFor(selection);
if (waiting) {
- hold(selection, text);
+ hold(selection, texts ? texts[run[0].id] : text, null, {texts, shown});
return {text, say: [said, used, waiting === 'ready' ? queuedReady()
: t('Queued. It starts after the previous part finishes.', '已排队,上一段完成后自动开始。')].filter(Boolean).join(' '), queued: true};
}
const busyBefore = jobActive();
- await actions.generate({text, selection});
+ await actions.generate({text: texts ? texts[run[0].id] : text, texts, selection, shown});
return {text, say: [said, used, busyBefore ? t('Queued. It starts after the part now generating.', '已排队,正在生成的那段完成后自动开始。') : null].filter(Boolean).join(' ') || null, queued: busyBefore};
},
selectionRunning: () => busySelection(state.selection),
diff --git a/web/editor_genbar.js b/web/editor_genbar.js
index b6152eb..823e22b 100644
--- a/web/editor_genbar.js
+++ b/web/editor_genbar.js
@@ -202,7 +202,29 @@ export function createEditorGenbar(host, {state, t, actions, text = ''}) {
width = next; resizeDescription();
}) : null;
resize?.observe(description);
- input.oninput = () => { state.setRangeText(input.value); render(); };
+ // The box shows the description of the planned parts chosen and is written to them when the choice moves
+ // on, the box is left or Generate is pressed. What is typed with no part or range chosen goes to the next
+ // part chosen that has no description yet.
+ // written: what is to be written, which the enlarged box has before the small one.
+ let bound = null, dirty = false, loose = false, committing = false, written = '';
+ const typed = (value = input.value) => {
+ state.setRangeText(value); written = value;
+ if (bound) dirty = true; else loose = state.selection?.kind !== 'range';
+ };
+ function commit() {
+ if (!bound || !dirty) return;
+ const {ids} = bound; dirty = false; committing = true;
+ try { actions.describeParts?.(ids, written); } finally { committing = false; }
+ }
+ function bind() {
+ const part = actions.partText?.(state.selection) ?? null;
+ if (part && !part.text && loose && input.value.trim()) { bound = part; dirty = true; written = input.value; }
+ else if (part) { bound = part; dirty = false; input.value = part.text; }
+ else bound = null;
+ if (part || state.selection?.kind === 'range') loose = false;
+ }
+ input.oninput = () => { typed(); render(); };
+ input.onblur = () => { if (dirty) { commit(); bind(); } };
input.onkeydown = event => {
// The former text input did not submit or insert a line on Enter.
if (event.key === 'Enter' && !event.shiftKey && !event.isComposing && event.keyCode !== 229) event.preventDefault();
@@ -211,14 +233,15 @@ export function createEditorGenbar(host, {state, t, actions, text = ''}) {
const key = JSON.stringify(state.selection ?? null);
if (pressing.has(key)) return;
pressing.add(key); say(''); render();
- const typed = input.value;
+ commit();
+ const shown = input.value;
let reason = '';
try {
// The press shows before any planning, however long that takes.
await painted();
const result = actions.press ? await actions.press(input.value) : await actions.generate({target: 'both', text: input.value});
// Never over what the user typed meanwhile, for another part.
- if (result?.text != null && result.text !== input.value && input.value === typed) input.value = result.text;
+ if (result?.text != null && result.text !== input.value && input.value === shown) input.value = result.text;
if (result?.say) { say(result.say, !!result.queued); reason = result.say; }
if (result?.focus) { pressing.delete(key); render(); input.disabled = false; input.focus(); }
}
@@ -229,7 +252,7 @@ export function createEditorGenbar(host, {state, t, actions, text = ''}) {
finally { pressing.delete(key); render(); }
return reason;
};
- const expand = createExpandButton({t, textarea: input, onGenerate: () => generate.onclick(), canGenerate: () => !generate.disabled, onDraft: text => state.setRangeText(text)});
+ const expand = createExpandButton({t, textarea: input, onGenerate: () => generate.onclick(), canGenerate: () => !generate.disabled, onDraft: text => typed(text)});
description.append(expand.element);
cancel.onclick = () => (!previewSelection && actions.selectionHeld?.() ? Promise.resolve(actions.unhold()).then(render) : actions.cancel()).catch(actions.error);
resume.onclick = () => actions.resume().catch(value => actions.error(value, 'generate'));
@@ -238,20 +261,23 @@ export function createEditorGenbar(host, {state, t, actions, text = ''}) {
if (state.rangeText === null) state.setRangeText(input.value);
else if (input.value !== state.rangeText) input.value = state.rangeText;
}
- if (event.type === 'selection' && state.selection?.kind === 'clip') {
- const selected = state.record.tracks.flatMap(track => track.clips).find(clip => state.selection.ids.includes(clip.id) && clip.pending);
- // A part with no description of its own keeps what is typed, as a new range does.
+ if (event.type === 'selection') {
+ commit(); bind();
+ // A part being made shows the description it is made with.
+ const selected = !bound && state.selection?.kind === 'clip' && state.record.tracks.flatMap(track => track.clips).find(clip => state.selection.ids.includes(clip.id) && clip.pending);
if (selected?.text) input.value = selected.text;
}
+ // An undo, or a description written elsewhere, shows unless something not yet written is in the box.
+ if (event.type === 'record' && !committing && !dirty && (bound || actions.partText?.(state.selection))) bind();
if (event.type === 'selection' || event.type === 'record') render();
});
render();
- return {element: host, say, downloadFailure,
+ return {element: host, say, downloadFailure, commit,
service(value) {
service = value;
if (!value && note.contains(retryService)) { retryService.remove(); note.hidden = true; }
showService();
- }, getText() { expand.commit(); return input.value; }, update(value) { status = value; render(); }, preview(selection) { previewSelection = selection; render(); }, setText(value) { input.value = value || ''; state.setRangeText(input.value); render(); },
+ }, getText() { expand.commit(); return input.value; }, update(value) { status = value; render(); }, preview(selection) { previewSelection = selection; render(); }, setText(value) { input.value = value || ''; state.setRangeText(input.value); if (bound && input.value !== bound.text) { dirty = true; written = input.value; } render(); },
dispose() { disposed = true; ++serial; clearTimeout(noteTimer); clearTimeout(refNoticeTimer); unsubscribe(); resize?.disconnect(); expand.dispose(); references?.dispose(); assets?.dispose(); }};
}
diff --git a/web/editor_model.js b/web/editor_model.js
index 0e7d5a8..dbd6223 100644
--- a/web/editor_model.js
+++ b/web/editor_model.js
@@ -362,6 +362,18 @@ function written(clip, text, by) {
if (by === 'user' && text !== clip.text) delete clip.note;
clip.text = text; if (text && by === 'agent') clip.text_by = by; else delete clip.text_by;
}
+// A planned part's own description. The parts after it that still had the same one take the new one too;
+// a part with none of its own is left so, and goes on using the one before it when generated.
+export function describePlanned(record, ids, text, {by = 'user'} = {}) {
+ const selected = linkedIds(record, ids), video = trackBy(record, 'v1').clips;
+ const chosen = video.filter(clip => selected.has(clip.id)).sort((a, b) => a.start - b.start);
+ const following = [], old = chosen.at(-1)?.text ?? '';
+ for (let last = chosen.at(-1), next; old && (next = video.find(clip => continuing(clip, last))); last = next) {
+ if (selected.has(next.id) || next.source || next.pending !== 'draft' || next.job || (next.text && next.text !== old)) break;
+ if (next.text) following.push(next.id);
+ }
+ return describe(record, [...ids, ...following], text, {by});
+}
function onBlocks(record, ids, change, refuseBusy, {picture = false, kept = false} = {}) {
check(Array.isArray(ids) && ids.length > 0 && ids.every(id => typeof id === 'string'), 'id');
for (const id of ids) check(find(record, id), 'missing');
@@ -923,8 +935,9 @@ export function extendClip(record, id, frames, {maxSeconds = RULES.maxSeconds, m
const next = copy(restored), sound = sourceAudioTrack(next, start, count);
const parts = rangeParts(restored, {start, frames: count, continues: true, maxSeconds, maxFollowSeconds});
const planned = planRange({...emptyProject(restored), serial: next.serial},
- {start, frames: count, parts, target: 'both', text: clip.text, maxSeconds: maxFollowSeconds, maxFollowSeconds});
- // Pulled out of this part's end: the new parts continue it.
+ {start, frames: count, parts, target: 'both', maxSeconds: maxFollowSeconds, maxFollowSeconds});
+ // Pulled out of this part's end: the new parts continue it. They have no description of their own until one
+ // is written, and are generated with the one of the part before them.
trackBy(next, 'v1').clips.push(...planned.tracks[0].clips.map(added => added.start === start ? {...added, follows: clip.id} : added));
sound.clips.push(...planned.tracks[1].clips);
next.serial = planned.serial;
@@ -1033,9 +1046,11 @@ function update(record, ids, change) {
for (const clip of all(next)) if (selected.has(clip.id)) change(clip);
return finish(next);
}
+// text is one description for every part, or one per part keyed by the part's picture.
export function startAttempt(record, ids, text, {by = 'user'} = {}) {
- check(validText(text) && TEXT_BY.includes(by), 'text');
+ const textOf = clip => typeof text === 'string' ? text : text?.[clip.id] ?? text?.[clip.link];
const next = copy(record), selected = linkedIds(next, ids), parts = new Map();
+ check(TEXT_BY.includes(by) && all(next).every(clip => !selected.has(clip.id) || validText(textOf(clip))), 'text');
busy(all(next).filter(clip => selected.has(clip.id)));
// Parts that continue one another stay one video; ranges drawn apart stay apart, however many are started together.
let part = null, last = null;
@@ -1044,7 +1059,7 @@ export function startAttempt(record, ids, text, {by = 'user'} = {}) {
parts.set(clip.id, part); if (clip.link) parts.set(clip.link, part); last = clip;
}
const other = () => part ??= freshId(next);
- for (const clip of all(next)) if (selected.has(clip.id)) { written(clip, text, by); clip.part = parts.get(clip.id) ?? other(); clip.pending = 'draft'; clip.reason = clip.job = null; }
+ for (const clip of all(next)) if (selected.has(clip.id)) { written(clip, textOf(clip), by); clip.part = parts.get(clip.id) ?? other(); clip.pending = 'draft'; clip.reason = clip.job = null; }
return finish(next);
}
export function assignJob(record, ids, job, {prepared = record} = {}) {
diff --git a/web/editor_tracks.js b/web/editor_tracks.js
index 937073c..6f80e2e 100644
--- a/web/editor_tracks.js
+++ b/web/editor_tracks.js
@@ -625,8 +625,24 @@ export function createTracks(host, {state, sources = {}, t = en => en, actions =
const room = next.length ? Math.min(...next) : bounds.height;
popover.style.top = `${Math.max(8, below + height <= room || above < 8 ? Math.min(below, bounds.height - height - 8) : above)}px`;
}
+ // A click inside a range drawn over empty space that makes several parts plans those parts and chooses the one
+ // clicked, so each can be described on its own. What was typed for the range is the first part's description.
+ function choosePart(event) {
+ const range = state.selection;
+ if (event.kind !== 'rangeMove' || range?.kind !== 'range' || rangeParts(range).length < 2
+ || state.record.tracks.some(track => track.clips.some(clip => clip.start < range.start + range.frames && clip.start + clip.frames > range.start))) return;
+ const frame = frameAt(event), text = state.rangeText?.trim() || '';
+ let next, clicked;
+ try {
+ next = model.planRange(state.record, {start: range.start, frames: range.frames, ...(range.parts ? {parts: range.parts} : {}), target: 'both', ...actions.generationLimits?.()});
+ const drawn = next.tracks[0].clips.filter(clip => !model.find(state.record, clip.id)).sort((a, b) => a.start - b.start);
+ clicked = drawn.find(clip => frame >= clip.start && frame < clip.start + clip.frames) ?? (frame < range.start ? drawn[0] : drawn.at(-1));
+ if (text) next = model.describe(next, [drawn[0].id], text);
+ } catch (error) { if (error instanceof model.EditError) return; throw error; }
+ attempt(t('Edit description', '修改说明'), () => next, {selectionAfter: {kind: 'clip', ids: model.pair(next, clicked.id).map(clip => clip.id)}});
+ }
function clickSelection(event) {
- if (event.range) return;
+ if (event.range) { choosePart(event); return; }
const id = event.clipId || event.target.closest?.('.fv-ed-clip')?.dataset.clip;
if (id) {
selectGestures.choose(id, event);
@@ -928,7 +944,7 @@ export function createTracks(host, {state, sources = {}, t = en => en, actions =
if (cancel) { state.select(finished.previousSelection); if (finished.type === 'seek') state.seek(finished.previousPlayhead); return; }
if (finished.type === 'seek') return;
if (!finished.moved || finished.type === 'click') {
- clickSelection({target: finished.target, clientX: event.clientX, range: finished.range, clipId: finished.id}); return;
+ clickSelection({target: finished.target, clientX: event.clientX, range: finished.range, kind: finished.type, clipId: finished.id}); return;
}
if (finished.type === 'rangeMove' && finished.rangeBlocked) return;
if (['range', 'rangeMove', 'rangeEdge', 'rangeBoundary'].includes(finished.type)) { state.select(finished.selection, {history: true}); return; }
@@ -1186,7 +1202,7 @@ export function createTracks(host, {state, sources = {}, t = en => en, actions =
const unsubscribe = state.subscribe(event => {
if (event.type === 'record') {
// Status updates elsewhere must not cancel an unchanged moving pair.
- if (gesture && !(gesture.type === 'move' && gesture.members.every(clip =>
+ if (gesture && !(gesture.type === 'move' && (gesture.members ?? []).every(clip =>
JSON.stringify(model.find(state.record, clip.id)) === JSON.stringify(clip)))) stopPointer(null, true);
if (gesture) cachedPoints = allPoints(gesture.ids);
renderRecord();