Improve responsive editor workflows

This commit is contained in:
haixin.yang committed 2026-07-20 19:29:21 +08:00
1 parent 9e1b155662
commit 2ebcf6a673
15 files changed
+438 -78

No files matched your search

@@ -39,6 +39,9 @@ The first visual may open a shortcuts coach guide. Do not click an action that p
- Separating audio creates derived source-audio clips and mutes embedded playback to prevent doubling.
- Deleting a separated piece does not imply that the original visual has lost its embedded audio.
- Verify audible playback, clip mute state, separation state, and exported audio instead of treating lane visibility as proof.
- When separating audio from a trimmed video clip, verify immediately that the project duration is unchanged and the visible source-audio piece matches the clip's timeline duration. The piece must resolve the visual clip's source start and source duration, not expose the full original media range.
- Generate captions from the selected mapped source-audio piece so transcription uses its source start, duration, and timeline start. Stop if separation expands the project or the caption source falls outside the visual clip.
- If export with a separated source track remains at the first frame for several progress checks without errors, preserve the `.timeline` archive and classify it as a product defect. After captions are safely stored, removing the derived source track is a valid recovery only when the video is configured to resume its embedded audio; verify the final file is audible.
## Handoff
@@ -30,6 +30,8 @@ Observed browser-path constraints:
- Locator-scoped Escape can fail on the coach dialog when browser focus moves; a verified page-level Escape works as a session-only dismissal.
- After splitting a very short visual, toolbar selection can be misread; a right-click clip menu provides a safer clip-scoped delete path.
- Browser-control download events can time out even when `.timeline` or video files are successfully written; confirm with filesystem timestamps and media decoding before retrying.
- The local repository now resolves a timeline video clip's `assetId` when separating source audio, so trimmed clips retain their source start/duration and do not expand the project. Keep a regression for both timeline-clip and asset-library extraction entry points.
- A reloaded project with a separated source track was observed to stall offline export at frame 1/479 without a console error. Preserve the project artifact and treat this as an export product defect; an embedded-audio export completed after removing the derived track.
## Missing for reliable Agent editing
@@ -27,9 +27,9 @@ Run these across empty and pre-populated projects where applicable:
5. Verify the first-visual coach guide: persistent completion only through the user's explicit action; temporary dismissal through close or Escape.
6. Trim, split, reorder, delete, undo, redo, save, reopen, and compare media identity and source-time mapping. Include a sub-second split where mute controls and handles consume most of the clip width; verify clip-scoped context-menu deletion and immediate recovery from a deliberately detected wrong-target action.
7. Add and move captions, stickers, voiceover, music, source audio, and picture-in-picture; verify lane visibility and overlap packing.
8. Verify embedded video audio, mute, Separate audio, derived-piece deletion, link modes, preview playback, and export without doubled or missing sound.
8. Verify embedded video audio, mute, Separate audio, derived-piece deletion, link modes, preview playback, and export without doubled or missing sound. Separate audio from a clip trimmed at both ends and assert the project duration, source-audio piece duration, source start, source duration, and waveform range remain mapped to that clip rather than the full original asset.
9. Change transforms, masks, keyframes, speed, effects, animations, and aspect ratio; compare preview with deterministic export.
10. Export MP4/WebM and decode the entire result to verify dimensions, duration, frame count, visible captions/overlays, and a real non-silent audio track when expected. Test both a captured browser download event and the fallback where the event times out but a new artifact exists on disk.
10. Export MP4/WebM and decode the entire result to verify dimensions, duration, frame count, visible captions/overlays, and a real non-silent audio track when expected. Extract frames inside every caption range and visually verify the burned-in text. Test both a captured browser download event and the fallback where the event times out but a new artifact exists on disk.
11. Compare same-tab autosave, a newly opened same-origin tab, and explicit `.timeline` save/reopen. Verify duration, ordering, assets, track state, selections that should persist, and generated media links; never treat an “Autosaved” label as proof that local blobs will reopen.
12. Repeat critical flows in every supported interface language, narrow desktop panels, reduced motion, and at least the supported Chromium path; include Firefox/Windows regressions when available.
13. Exercise AI paths with cold and warm caches, unavailable models, download failure, cancellation, WASM/WebGPU fallback, and truthful backend reporting.
+21 -1
View File
@@ -811,7 +811,7 @@ export function App() {
toggleCaptionSegmentHidden, toggleVisionOption, trOption, updateCaptionSegmentText,
updateScript, userAssets, visionJob,
selectedVisualSegment, visualLocalTime, updateSelectedVisualEffects,
mobilePanel, setMobilePanel: changeMobilePanel,
mobilePanel, setMobilePanel: changeMobilePanel, applyAssetToTrack,
}} />
<PreviewStage
@@ -856,6 +856,11 @@ export function App() {
fileInputRef={fileInputRef}
selectedFilter={activePreviewFilter}
fitMode={fitMode}
ratioId={ratioId}
setRatioId={(nextRatioId) => {
setRatioId(nextRatioId);
setFitModeFromUser("contain");
}}
visualObjectFit={previewVisualObjectFit}
visualObjectPosition={previewVisualObjectPosition}
visionOverlayBoxes={previewVisionOverlayBoxes}
@@ -1039,6 +1044,11 @@ export function App() {
selectedTrack={selectedTrack}
setSelectedTrack={setSelectedTrack}
setActiveTool={setActiveTool}
openMobileMediaPicker={() => {
setActiveTool("media");
setMediaTab("upload");
changeMobilePanel("tools");
}}
requestCaptionVoiceFocus={() => setCaptionVoiceFocusRequest((request) => request + 1)}
trackVisibility={trackVisibility}
toggleTrackVisibility={toggleTrackVisibility}
@@ -1123,6 +1133,16 @@ export function App() {
startMusicMove={startMusicMove}
/>
{mobilePanel ? (
<header className="mobile-sheet-nav">
<strong>{t(activeTool)}</strong>
<div role="tablist" aria-label={t("mobilePanelView")}>
<button className={mobilePanel === "tools" ? "is-active" : ""} type="button" role="tab" aria-selected={mobilePanel === "tools"} onClick={() => changeMobilePanel("tools")}>{t("mobileDrawerTools")}</button>
<button className={mobilePanel === "inspector" ? "is-active" : ""} type="button" role="tab" aria-selected={mobilePanel === "inspector"} onClick={() => changeMobilePanel("inspector")}>{t("properties")}</button>
<button className="mobile-sheet-close" type="button" aria-label={t("close", "关闭")} onClick={() => changeMobilePanel("")}>×</button>
</div>
</header>
) : null}
{mobilePanel ? <button className="mobile-sheet-backdrop" type="button" aria-label={t("close", "关闭")} onClick={() => changeMobilePanel("")} /> : null}
<AssetDragPreview preview={assetDragPreview} t={t} />
+4 -15
View File
@@ -1,5 +1,4 @@
import { TOOL_RAIL } from "../config/editor.js";
import { SlidersHorizontal } from "@phosphor-icons/react";
import { MediaPanel, ToolPanel } from "./panels.jsx";
export function EditorSidebar({ model: d }) {
@@ -22,22 +21,9 @@ export function EditorSidebar({ model: d }) {
<span>{d.t(id, label)}</span>
</button>
))}
<button
className={`rail-tool mobile-inspector-tool ${d.mobilePanel === "inspector" ? "is-active" : ""}`}
type="button"
aria-expanded={d.mobilePanel === "inspector"}
onClick={() => {
if (window.matchMedia?.("(max-width: 760px)").matches) {
d.setMobilePanel?.(d.mobilePanel === "inspector" ? "" : "inspector");
}
}}
>
<SlidersHorizontal size={23} />
<span>{d.t("properties", "属性")}</span>
</button>
</aside>
<aside className="media-panel">
<aside className={`media-panel ${d.mobilePanel === "tools" && d.selectedLibraryAssetId ? "has-mobile-asset-actions" : ""}`}>
{d.activeTool === "media" ? (
<MediaPanel
t={d.t}
@@ -64,6 +50,9 @@ export function EditorSidebar({ model: d }) {
draggedAssetId={d.draggedAssetId}
handleAssetPointerDown={d.handleAssetPointerDown}
handleAssetClick={d.handleAssetClick}
applyAssetToTrack={d.applyAssetToTrack}
closeMobilePanel={() => d.setMobilePanel?.("")}
mobilePanelOpen={d.mobilePanel === "tools"}
/>
) : (
<ToolPanel
+34 -23
View File
@@ -23,6 +23,7 @@ import { IconButton } from "./ui.jsx";
import { getVisualOverlayPixelBox, snapVisualOverlayTransform } from "../lib/visualOverlayTimeline.js";
import { getAnchoredResize } from "../lib/anchoredResize.js";
import { getVisualFitRect } from "../lib/visualGeometry.js";
import { RATIO_OPTIONS } from "../config/editor.js";
export function PreviewStage({
t,
@@ -43,6 +44,8 @@ export function PreviewStage({
fileInputRef,
selectedFilter,
fitMode,
ratioId,
setRatioId,
visualObjectFit,
visualObjectPosition,
visionOverlayBoxes = [],
@@ -93,6 +96,9 @@ export function PreviewStage({
const lastReportedVideoTimeRef = useRef(-Infinity);
const [isFocusPreviewOpen, setIsFocusPreviewOpen] = useState(false);
const [focusPreviewFrameSize, setFocusPreviewFrameSize] = useState({ width: 0, height: 0 });
const [previewRatioWidth, previewRatioHeight] = String(previewRatio).split("/").map((value) => Number(value.trim()));
const previewRatioValue = previewRatioWidth > 0 && previewRatioHeight > 0 ? previewRatioWidth / previewRatioHeight : 16 / 9;
const focusPreviewOrientation = previewRatioValue > 1.1 ? "landscape" : previewRatioValue < 0.9 ? "portrait" : "square";
const visibleStickers = stickers;
const hasStickerOverlay = visibleStickers.some((sticker) => sticker?.src || sticker?.text);
const hasPreviewContent = Boolean(previewVisualSrc || hasStickerOverlay);
@@ -361,31 +367,30 @@ export function PreviewStage({
return () => window.removeEventListener("keydown", handleKeyDown);
}, [isFocusPreviewOpen]);
useEffect(() => {
if (!isFocusPreviewOpen) return undefined;
const shell = previewShellRef.current;
if (!shell) return undefined;
const [ratioWidth, ratioHeight] = String(previewRatio).split("/").map(Number);
const ratio = ratioWidth > 0 && ratioHeight > 0 ? ratioWidth / ratioHeight : 16 / 9;
const update = () => {
const style = getComputedStyle(shell);
const availableWidth = Math.max(1, shell.clientWidth - parseFloat(style.paddingLeft || 0) - parseFloat(style.paddingRight || 0));
const availableHeight = Math.max(1, shell.clientHeight - parseFloat(style.paddingTop || 0) - parseFloat(style.paddingBottom || 0));
const width = Math.max(1, Math.floor(Math.min(availableWidth, availableHeight * ratio)));
const height = Math.max(1, Math.floor(width / ratio));
setFocusPreviewFrameSize((old) => old.width === width && old.height === height ? old : { width, height });
};
update();
const observer = new ResizeObserver(update);
observer.observe(shell);
return () => observer.disconnect();
}, [isFocusPreviewOpen, previewRatio, previewShellRef]);
const previewStage = (
<section className={`preview-stage ${isFocusPreviewOpen ? "is-focus-preview" : ""}`} role={isFocusPreviewOpen ? "dialog" : undefined} aria-modal={isFocusPreviewOpen ? "true" : undefined} aria-label={isFocusPreviewOpen ? t("focusPreviewTitle", "大画布编辑") : undefined}>
<section
className={`preview-stage ${isFocusPreviewOpen ? `is-focus-preview is-focus-${focusPreviewOrientation}` : ""}`}
style={isFocusPreviewOpen ? { "--focus-preview-ratio": previewRatioValue } : undefined}
role={isFocusPreviewOpen ? "dialog" : undefined}
aria-modal={isFocusPreviewOpen ? "true" : undefined}
aria-label={isFocusPreviewOpen ? t("focusPreviewTitle", "大画布编辑") : undefined}
>
{isFocusPreviewOpen ? <header className="focus-preview-header">
<div><strong>{t("focusPreviewTitle", "大画布编辑")}</strong><span>{t("focusPreviewHint", "点击画面元素进行移动、缩放和旋转")}</span></div>
<IconButton label={t("closeFocusPreview", "关闭大画布预览")} onClick={() => setIsFocusPreviewOpen(false)}><X size={20} /></IconButton>
<button
className="focus-preview-close"
type="button"
aria-label={t("closeFocusPreview", "关闭大画布预览")}
title={t("closeFocusPreview", "关闭大画布预览")}
onPointerDown={(event) => {
event.preventDefault();
event.stopPropagation();
setIsFocusPreviewOpen(false);
}}
onClick={(event) => event.stopPropagation()}
>
<X size={22} />
</button>
</header> : null}
<div
ref={previewShellRef}
@@ -622,7 +627,7 @@ export function PreviewStage({
</IconButton>
</div>
<button
className="fit-button"
className="fit-button desktop-fit-button"
type="button"
onClick={() => {
setFitMode((mode) => (mode === "contain" ? "cover" : "contain"));
@@ -631,6 +636,12 @@ export function PreviewStage({
>
{fitMode === "contain" ? t("fit") : t("cover")} <CaretDown size={14} />
</button>
<label className="mobile-ratio-select" aria-label={t("canvasRatio", "画布比例")}>
<select value={ratioId} onChange={(event) => setRatioId?.(event.target.value)}>
{RATIO_OPTIONS.map((option) => <option value={option.id} key={option.id}>{option.label}</option>)}
</select>
<CaretDown size={14} />
</label>
<IconButton label={isFocusPreviewOpen ? t("closeFocusPreview", "关闭大画布预览") : t("fullscreenPreview")} onClick={() => setIsFocusPreviewOpen((open) => !open)}>
<FrameCorners size={19} />
</IconButton>
+15
View File
@@ -129,6 +129,7 @@ export function Timeline({
selectedTrack,
setSelectedTrack,
setActiveTool,
openMobileMediaPicker,
requestCaptionVoiceFocus,
trackVisibility,
toggleTrackVisibility,
@@ -1036,6 +1037,20 @@ export function Timeline({
{assetDropTargetTrack === "image" || assetDropTargetTrack === "overlay" ? (
<div className="track-drop-hint">{assetDropTargetTrack === "overlay" ? t("dropAsOverlay", "作为画中画") : t("appendAfter", "添加到后面")}</div>
) : null}
{!imageSrc ? (
<button
className="mobile-empty-visual-entry"
type="button"
aria-label={t("mobileAddMedia", "添加素材")}
onClick={(event) => {
event.stopPropagation();
openMobileMediaPicker?.();
}}
>
<PlusCircle size={20} weight="bold" />
<span>{t("mobileAddMedia", "添加素材")}</span>
</button>
) : null}
{imageSrc
? displayedVisualSegments.map((segment, index) => {
const segmentSrc = segment.src || imageSrc;
+27 -3
View File
@@ -97,8 +97,12 @@ export function MediaPanel({
draggedAssetId,
handleAssetPointerDown,
handleAssetClick,
applyAssetToTrack,
closeMobilePanel,
mobilePanelOpen,
}) {
const assets = mediaTab === "library" ? builtInAssets : userAssets;
const selectedAsset = [...userAssets, ...builtInAssets].find((asset) => asset.id === selectedLibraryAssetId) ?? null;
const assetIntentTimerRef = useRef(null);
const [previewAsset, setPreviewAsset] = useState(null);
@@ -113,8 +117,14 @@ export function MediaPanel({
const openAssetPreview = (event, asset) => {
handleAssetClick(event, asset);
if (window.matchMedia?.("(max-width: 760px)").matches) return;
if (!event.defaultPrevented) setPreviewAsset(asset);
};
const addSelectedAsset = async (track) => {
if (!selectedAsset) return;
await applyAssetToTrack?.(selectedAsset, track);
closeMobilePanel?.();
};
const renderAssetList = (items, { deletable = false } = {}) => (
<div className={`asset-list ${mediaTab === "upload" ? "upload-assets" : ""}`}>
{libraryStatus === "loading" && mediaTab === "library" ? (
@@ -229,6 +239,23 @@ export function MediaPanel({
renderAssetList(assets, { deletable: mediaTab === "mine" })
)}
{selectedAsset && mobilePanelOpen ? createPortal((
<div className="mobile-asset-actions" aria-label={t("mobileAssetActions")}>
<span><strong>{selectedAsset.name}</strong><small>{t("mobileAssetSelected")}</small></span>
{selectedAsset.type === "audio" ? (
<div>
<button type="button" className="is-secondary" onClick={() => void addSelectedAsset("music")}>{t("mobileAddToMusic")}</button>
<button type="button" onClick={() => void addSelectedAsset("audio")}>{t("mobileAddToVoice")}</button>
</div>
) : (
<div>
<button type="button" className="is-secondary" onClick={() => void addSelectedAsset("overlay")}>{t("dropAsOverlay")}</button>
<button type="button" onClick={() => void addSelectedAsset("image")}>{t("mobileAddToMainTrack")}</button>
</div>
)}
</div>
), document.body) : null}
{previewAsset ? createPortal(
<AssetPreviewDialog asset={previewAsset} t={t} onClose={() => setPreviewAsset(null)} />,
document.body,
@@ -562,9 +589,6 @@ export function ToolPanel(props) {
if (activeTool === "smart") {
return (
<div className="tool-panel smart-hub-panel">
<header className="smart-mobile-header">
<strong>{t("smartTools")}</strong>
</header>
<div className="smart-hub-grid" role="tablist" aria-label={t("smartTools")}>
{[
["auto-edit", Scissors, t("smartAutoEdit"), t("smartAutoEditHint")],
+4 -4
View File
@@ -1,5 +1,6 @@
import { useCallback } from "react";
import { concatenateAudioBlobs, decodeWaveform, extractAudioFromVideo } from "../lib/media.js";
import { attachSourceAudioOffset, getSourceAudioAssetId } from "../lib/sourceAudioSync.js";
export function useSourceAudioExtraction(d) {
return useCallback(async (asset, timelineStart = 0, options = {}) => {
@@ -10,13 +11,12 @@ export function useSourceAudioExtraction(d) {
const extracted = await decodeWaveform(extractedBlob, 96); if (!extracted.duration) throw new Error("视频没有可识别的音频轨");
const shouldAppend = options.append === true && d.sourceAudioBlob instanceof Blob;
const sourceAudioOffset = shouldAppend ? Math.max(0, Number(d.sourceAudioDuration) || 0) : 0;
const sourceAudioAssetId = getSourceAudioAssetId(asset);
const blob = shouldAppend ? await concatenateAudioBlobs([d.sourceAudioBlob, extractedBlob]) : extractedBlob;
const decoded = shouldAppend ? await decodeWaveform(blob, 192) : extracted;
d.setVisualSegments((segments) => segments.map((segment) => segment.assetId === asset.id && segment.type === "video"
? { ...segment, sourceAudioOffset }
: segment));
d.setVisualSegments((segments) => attachSourceAudioOffset(segments, asset, sourceAudioOffset));
const sourceName = shouldAppend ? "视频原声合集.wav" : `${asset.name.replace(/\.[^.]+$/, "")} 原声.wav`;
d.replaceSourceAudio(blob, decoded.duration, decoded.peaks, sourceName, shouldAppend ? "视频原声已追加到时间线" : "视频原声已分离到时间线", timelineStart, shouldAppend ? "" : asset.id, { focusAudio: false });
d.replaceSourceAudio(blob, decoded.duration, decoded.peaks, sourceName, shouldAppend ? "视频原声已追加到时间线" : "视频原声已分离到时间线", timelineStart, shouldAppend ? "" : sourceAudioAssetId, { focusAudio: false });
return true;
} catch (error) {
console.warn(error); d.setStatus("ready"); d.setStatusText("视频未检测到可分离原声");
+16 -1
View File
@@ -27,6 +27,20 @@ const EXPORT_RENDER_COPY = {
vi: { exportPreparing: "Đang chuẩn bị xuất", exportRecordingStream: "Đang ghi luồng video {format}", exportEmbeddedAudio: "Đang chuẩn bị âm thanh nhúng {current}/{total}", exportOfflinePreparing: "Đang chuẩn bị kết xuất ngoại tuyến", exportOfflineRendering: "Kết xuất ngoại tuyến {current}/{total}", exportVerifyFile: "Đang xác minh tệp xuất", exportPrepareVisuals: "Đang chuẩn bị hình ảnh", exportPrepareTracks: "Đang chuẩn bị khung vẽ và rãnh", exportMixAudio: "Đang giải mã và trộn âm thanh", exportStartRecording: "Đang bắt đầu ghi video", exportRecording: "Đang ghi luồng video", exportPackageFile: "Đang đóng gói tệp xuất", exportCompatibility: "Đang chuyển sang xuất tương thích", exportSaveFile: "Đang lưu tệp {format}", exportComplete: "Xuất hoàn tất", exportFailed: "Xuất thất bại" },
};
const MOBILE_DRAWER_COPY = {
zh: { mobilePanelView: "抽屉视图", mobileDrawerTools: "工具", properties: "属性", mobileAddMedia: "添加素材", mobileAssetActions: "素材添加操作", mobileAssetSelected: "已选择素材", mobileAssetChooseDestination: "素材已选中,请选择添加位置", mobileAddToMainTrack: "添加到主轨道", mobileAddToVoice: "添加到配音轨", mobileAddToMusic: "添加到音乐轨" },
en: { mobilePanelView: "Drawer view", mobileDrawerTools: "Tools", properties: "Properties", mobileAddMedia: "Add media", mobileAssetActions: "Add media", mobileAssetSelected: "Selected media", mobileAssetChooseDestination: "Media selected. Choose where to add it.", mobileAddToMainTrack: "Add to main track", mobileAddToVoice: "Add to voiceover", mobileAddToMusic: "Add to music" },
ja: { mobilePanelView: "ドロワービュー", mobileDrawerTools: "ツール", properties: "プロパティ", mobileAddMedia: "素材を追加", mobileAssetActions: "素材を追加", mobileAssetSelected: "選択中の素材", mobileAssetChooseDestination: "追加先を選択してください", mobileAddToMainTrack: "メイントラックに追加", mobileAddToVoice: "ナレーションに追加", mobileAddToMusic: "音楽に追加" },
ko: { mobilePanelView: "패널 보기", mobileDrawerTools: "도구", properties: "속성", mobileAddMedia: "미디어 추가", mobileAssetActions: "미디어 추가", mobileAssetSelected: "선택한 미디어", mobileAssetChooseDestination: "추가할 위치를 선택하세요", mobileAddToMainTrack: "메인 트랙에 추가", mobileAddToVoice: "보이스오버에 추가", mobileAddToMusic: "음악에 추가" },
es: { mobilePanelView: "Vista del panel", mobileDrawerTools: "Herramientas", properties: "Propiedades", mobileAddMedia: "Añadir contenido", mobileAssetActions: "Añadir contenido", mobileAssetSelected: "Contenido seleccionado", mobileAssetChooseDestination: "Elige dónde añadirlo", mobileAddToMainTrack: "Añadir a pista principal", mobileAddToVoice: "Añadir a voz", mobileAddToMusic: "Añadir a música" },
fr: { mobilePanelView: "Vue du panneau", mobileDrawerTools: "Outils", properties: "Propriétés", mobileAddMedia: "Ajouter un média", mobileAssetActions: "Ajouter le média", mobileAssetSelected: "Média sélectionné", mobileAssetChooseDestination: "Choisissez où l’ajouter", mobileAddToMainTrack: "Ajouter à la piste principale", mobileAddToVoice: "Ajouter à la voix", mobileAddToMusic: "Ajouter à la musique" },
de: { mobilePanelView: "Panelansicht", mobileDrawerTools: "Werkzeuge", properties: "Eigenschaften", mobileAddMedia: "Medium hinzufügen", mobileAssetActions: "Medium hinzufügen", mobileAssetSelected: "Ausgewähltes Medium", mobileAssetChooseDestination: "Wähle aus, wo es hinzugefügt wird", mobileAddToMainTrack: "Zur Hauptspur hinzufügen", mobileAddToVoice: "Zur Sprachspur hinzufügen", mobileAddToMusic: "Zur Musik hinzufügen" },
pt: { mobilePanelView: "Vista do painel", mobileDrawerTools: "Ferramentas", properties: "Propriedades", mobileAddMedia: "Adicionar mídia", mobileAssetActions: "Adicionar mídia", mobileAssetSelected: "Mídia selecionada", mobileAssetChooseDestination: "Escolha onde adicionar", mobileAddToMainTrack: "Adicionar à faixa principal", mobileAddToVoice: "Adicionar à narração", mobileAddToMusic: "Adicionar à música" },
th: { mobilePanelView: "มุมมองแผง", mobileDrawerTools: "เครื่องมือ", properties: "คุณสมบัติ", mobileAddMedia: "เพิ่มสื่อ", mobileAssetActions: "เพิ่มสื่อ", mobileAssetSelected: "สื่อที่เลือก", mobileAssetChooseDestination: "เลือกตำแหน่งที่จะเพิ่ม", mobileAddToMainTrack: "เพิ่มไปยังแทร็กหลัก", mobileAddToVoice: "เพิ่มไปยังเสียงพากย์", mobileAddToMusic: "เพิ่มไปยังเพลง" },
vi: { mobilePanelView: "Chế độ xem bảng", mobileDrawerTools: "Công cụ", properties: "Thuộc tính", mobileAddMedia: "Thêm nội dung", mobileAssetActions: "Thêm nội dung", mobileAssetSelected: "Nội dung đã chọn", mobileAssetChooseDestination: "Chọn vị trí để thêm", mobileAddToMainTrack: "Thêm vào rãnh chính", mobileAddToVoice: "Thêm vào lồng tiếng", mobileAddToMusic: "Thêm vào nhạc" },
ru: { mobilePanelView: "Вид панели", mobileDrawerTools: "Инструменты", properties: "Свойства", mobileAddMedia: "Добавить медиа", mobileAssetActions: "Добавить медиа", mobileAssetSelected: "Выбранный материал", mobileAssetChooseDestination: "Выберите, куда его добавить", mobileAddToMainTrack: "На основную дорожку", mobileAddToVoice: "В озвучку", mobileAddToMusic: "В музыку" },
};
const VISUAL_EDITOR_COPY = {
zh: { visualSelectClip: "请先选择 Visuals 轨上的片段", visualKeyframes: "关键帧", visualFrames: "帧", visualScale: "缩放", visualPositionX: "水平位置", visualPositionY: "垂直位置", visualRotation: "旋转", visualOpacity: "不透明度", visualDeleteKeyframe: "删除当前位置关键帧", visualMask: "蒙版", visualMaskResize: "调整蒙版大小", visualClipScoped: "片段级", visualMaskNone: "无", visualMaskRectangle: "矩形", visualMaskRounded: "圆角", visualMaskCircle: "圆形", visualFeather: "羽化", visualHorizontal: "水平", visualVertical: "垂直", visualWidth: "宽度", visualHeight: "高度", visualDiameter: "直径", visualCornerRadius: "圆角半径", visualMaskNoneHint: "选择一种蒙版后显示对应参数", visualInvertMask: "反向蒙版", visualEffects: "画面效果" },
en: { visualSelectClip: "Select a clip on the Visuals track", visualKeyframes: "Keyframes", visualFrames: "frames", visualScale: "Scale", visualPositionX: "Horizontal position", visualPositionY: "Vertical position", visualRotation: "Rotation", visualOpacity: "Opacity", visualDeleteKeyframe: "Delete keyframe at playhead", visualMask: "Mask", visualMaskResize: "Resize mask", visualClipScoped: "Clip", visualMaskNone: "None", visualMaskRectangle: "Rectangle", visualMaskRounded: "Rounded", visualMaskCircle: "Circle", visualFeather: "Feather", visualHorizontal: "Horizontal", visualVertical: "Vertical", visualWidth: "Width", visualHeight: "Height", visualDiameter: "Diameter", visualCornerRadius: "Corner radius", visualMaskNoneHint: "Choose a mask to show its parameters", visualInvertMask: "Invert mask", visualEffects: "Visual effects" },
@@ -1833,7 +1847,8 @@ export function createTranslator(languageId) {
const assetPreviewCopy = ASSET_PREVIEW_COPY[copyLanguage] ?? ASSET_PREVIEW_COPY.en;
const assetDropCopy = ASSET_DROP_COPY[copyLanguage] ?? ASSET_DROP_COPY.en;
const autoCaptionStatusCopy = AUTO_CAPTION_STATUS_COPY[copyLanguage] ?? AUTO_CAPTION_STATUS_COPY.en;
return (key, fallbackText) => srtImportCopy[key] ?? exportCopy[key] ?? EXPORT_RENDER_COPY.en[key] ?? assetPreviewCopy[key] ?? ASSET_PREVIEW_COPY.en[key] ?? assetDropCopy[key] ?? ASSET_DROP_COPY.en[key] ?? autoCaptionStatusCopy[key] ?? AUTO_CAPTION_STATUS_COPY.en[key] ?? copy[key] ?? fallback[key] ?? UI_COPY.zh[key] ?? fallbackText ?? key;
const mobileDrawerCopy = MOBILE_DRAWER_COPY[languageId] ?? MOBILE_DRAWER_COPY.en;
return (key, fallbackText) => mobileDrawerCopy[key] ?? MOBILE_DRAWER_COPY.en[key] ?? srtImportCopy[key] ?? exportCopy[key] ?? EXPORT_RENDER_COPY.en[key] ?? assetPreviewCopy[key] ?? ASSET_PREVIEW_COPY.en[key] ?? assetDropCopy[key] ?? ASSET_DROP_COPY.en[key] ?? autoCaptionStatusCopy[key] ?? AUTO_CAPTION_STATUS_COPY.en[key] ?? copy[key] ?? fallback[key] ?? UI_COPY.zh[key] ?? fallbackText ?? key;
}
export function translateOptionName(languageId, name) {
+28
View File
@@ -0,0 +1,28 @@
import { describe, expect, it } from "vitest";
import { APP_LANGUAGES, createTranslator } from "./i18n.js";
describe("mobile drawer translations", () => {
it("provides every drawer header label in every supported language", () => {
APP_LANGUAGES.forEach(({ id }) => {
const t = createTranslator(id);
expect(t("mobilePanelView")).not.toBe("mobilePanelView");
expect(t("mobileDrawerTools")).not.toBe("mobileDrawerTools");
expect(t("properties")).not.toBe("properties");
expect(t("mobileAddMedia")).not.toBe("mobileAddMedia");
expect(t("mobileAddMedia")).not.toBe("mobileAddMedia");
expect(t("mobileAddToMainTrack")).not.toBe("mobileAddToMainTrack");
expect(t("mobileAddToVoice")).not.toBe("mobileAddToVoice");
expect(t("mobileAddToMusic")).not.toBe("mobileAddToMusic");
});
});
it("uses English labels in the English interface", () => {
const t = createTranslator("en");
expect(t("mobilePanelView")).toBe("Drawer view");
expect(t("mobileDrawerTools")).toBe("Tools");
expect(t("properties")).toBe("Properties");
expect(t("mobileAddMedia")).toBe("Add media");
expect(t("mobileAddMedia")).toBe("Add media");
expect(t("mobileAddToMainTrack")).toBe("Add to main track");
});
});
+3 -1
View File
@@ -85,7 +85,9 @@ export function createAssetDragControls(deps) {
const handleAssetClick = (event, asset) => {
if (deps.suppressAssetClickRef.current === asset.id) { deps.suppressAssetClickRef.current = ""; event.preventDefault(); event.stopPropagation(); return; }
deps.setSelectedLibraryAssetId(asset.id);
deps.notify("素材已选中,请拖到对应轨道使用");
deps.notify(window.matchMedia?.("(max-width: 760px)").matches
? deps.t?.("mobileAssetChooseDestination", "素材已选中,请选择添加位置")
: deps.t?.("assetSelectedDragHint", "素材已选中,请拖到对应轨道使用"));
};
const handleStickerClick = (event, sticker) => {
if (deps.suppressAssetClickRef.current === sticker.id) { deps.suppressAssetClickRef.current = ""; event.preventDefault(); event.stopPropagation(); return; }
+17
View File
@@ -11,6 +11,23 @@ function resolveLinkedAssetId(visualSegments, sourceAudioAssetId) {
return assetIds.length === 1 ? assetIds[0] : "";
}
export function getSourceAudioAssetId(source = {}) {
return source.assetId || source.id || "";
}
export function attachSourceAudioOffset(visualSegments = [], source = {}, sourceAudioOffset = 0) {
const assetId = getSourceAudioAssetId(source);
const clipId = source.id || "";
const offset = Math.max(0, Number(sourceAudioOffset) || 0);
if (!assetId && !clipId) return visualSegments;
return visualSegments.map((segment) => {
if (segment.type !== "video") return segment;
const matchesAsset = Boolean(assetId && segment.assetId === assetId);
const matchesUnboundClip = Boolean(clipId && !segment.assetId && segment.id === clipId);
return matchesAsset || matchesUnboundClip ? { ...segment, sourceAudioOffset: offset } : segment;
});
}
export function getLinkedSourceAudioSegments(visualSegments = [], sourceAudioAssetId = "", sourceAudioDuration = 0) {
const hasMappedOffsets = visualSegments.some((segment) => segment.type === "video" && Number.isFinite(segment.sourceAudioOffset));
const linkedAssetId = resolveLinkedAssetId(visualSegments, sourceAudioAssetId);
+30 -1
View File
@@ -1,5 +1,12 @@
import { describe, expect, it } from "vitest";
import { getLinkedSourceAudioEnd, getLinkedSourceAudioSegments, getLinkedSourceAudioState, shouldMuteEmbeddedVideoAudio } from "./sourceAudioSync.js";
import {
attachSourceAudioOffset,
getLinkedSourceAudioEnd,
getLinkedSourceAudioSegments,
getLinkedSourceAudioState,
getSourceAudioAssetId,
shouldMuteEmbeddedVideoAudio,
} from "./sourceAudioSync.js";
describe("linked source audio", () => {
const visualSegments = [
@@ -54,4 +61,26 @@ describe("linked source audio", () => {
expect(shouldMuteEmbeddedVideoAudio(clip, { sourceAudioBlob: new Blob(), sourceAudioAssetId: "video-1" })).toBe(true);
expect(shouldMuteEmbeddedVideoAudio(clip, { sourceAudioBlob: new Blob(), sourceAudioAssetId: "another-video" })).toBe(false);
});
it("uses the underlying asset id when audio is separated from a trimmed timeline clip", () => {
const clip = {
id: "clip-1", assetId: "asset-video", type: "video",
duration: 15.94, sourceStart: 0.83, sourceDuration: 15.94,
};
expect(getSourceAudioAssetId(clip)).toBe("asset-video");
const linkedVisuals = attachSourceAudioOffset([clip], clip, 0);
expect(linkedVisuals[0]).toMatchObject({ assetId: "asset-video", sourceAudioOffset: 0 });
expect(getLinkedSourceAudioSegments(linkedVisuals, "asset-video", 17.94)).toEqual([{
id: "clip-1", assetId: "asset-video", start: 0,
duration: 15.94, sourceStart: 0.83, sourceDuration: 15.94, playbackRate: 1,
}]);
expect(getLinkedSourceAudioEnd(getLinkedSourceAudioSegments(linkedVisuals, "asset-video", 17.94))).toBe(15.94);
});
it("still links extraction started from a library asset", () => {
const asset = { id: "asset-video", type: "video" };
const clips = [{ id: "clip-1", assetId: "asset-video", type: "video", duration: 4, sourceStart: 0, sourceDuration: 4 }];
expect(getSourceAudioAssetId(asset)).toBe("asset-video");
expect(attachSourceAudioOffset(clips, asset, 6)[0]).toMatchObject({ sourceAudioOffset: 6 });
});
});
+232 -27
View File
@@ -422,6 +422,8 @@ button:disabled {
background: #1b2028;
}
.mobile-ratio-select { display: none; }
.export-settings-popover { width: 360px; padding: 0; overflow: hidden; }
.export-settings-card { display: grid; gap: 14px; padding: 18px; }
.export-settings-heading { display: flex; align-items: flex-start; justify-content: space-between; padding-right: 24px; }
@@ -887,11 +889,11 @@ button:disabled {
cursor: pointer;
}
.mobile-inspector-tool {
.mobile-sheet-backdrop {
display: none;
}
.mobile-sheet-backdrop {
.mobile-sheet-nav {
display: none;
}
@@ -957,6 +959,26 @@ button:disabled {
.focus-preview-header > div { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.focus-preview-header strong { color: #edf5f7; font-size: 14px; }
.focus-preview-header span { overflow: hidden; color: #84919b; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.focus-preview-close {
position: relative;
z-index: 2;
flex: 0 0 44px;
display: inline-flex;
align-items: center;
justify-content: center;
width: 44px;
height: 44px;
border: 0;
border-radius: 10px;
padding: 0;
color: #b9c5cd;
background: transparent;
cursor: pointer;
touch-action: manipulation;
}
.focus-preview-close:hover,
.focus-preview-close:active { color: #f3ffff; background: rgba(255, 255, 255, .08); }
.focus-preview-close:focus-visible { outline: 2px solid #35ead9; outline-offset: -2px; }
.preview-stage.is-focus-preview .preview-canvas { padding: 12px; }
.preview-stage.is-focus-preview .preview-empty { width: auto; min-width: min(420px, 78%); }
.preview-stage.is-focus-preview .preview-empty strong,
@@ -1329,6 +1351,8 @@ button:disabled {
cursor: pointer;
}
.mobile-asset-actions { display: none; }
.asset-list > .empty-state {
grid-column: 1 / -1;
}
@@ -1519,7 +1543,6 @@ button:disabled {
}
.smart-hub-panel { gap: 16px; }
.smart-mobile-header { display: none; }
.smart-hub-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.smart-hub-grid > button { display: grid; align-content: start; min-width: 0; min-height: 104px; border: 1px solid rgba(255,255,255,.08); border-radius: 11px; padding: 13px; color: #8e9ca8; text-align: left; background: linear-gradient(145deg, rgba(255,255,255,.045), rgba(255,255,255,.018)); cursor: pointer; }
.smart-hub-grid > button:first-child { grid-column: span 2; min-height: 92px; }
@@ -3109,6 +3132,7 @@ button:disabled {
.visual-overlay-track { position: relative; min-width: 0; border-bottom: 1px solid rgba(255,255,255,.045); background: rgba(88,166,255,.025); }
.visual-overlay-track.is-selected { background: rgba(88,166,255,.07); }
.mobile-empty-visual-entry { display: none; }
.visual-overlay-clip { position: absolute; top: 5px; left: var(--overlay-left); width: var(--overlay-width); height: 38px; overflow: hidden; border: 1px solid rgba(88,166,255,.5); border-radius: 5px; padding: 0; background: #162231; color: #eaf4ff; text-align: left; cursor: pointer; }
.visual-overlay-drop-preview { position: absolute; top: 5px; left: var(--overlay-left); width: var(--overlay-width); height: 38px; min-width: 18px; display: grid; place-items: center; overflow: hidden; border: 1px dashed rgba(83,166,255,.96); border-radius: 5px; color: #dcecff; font-size: 10px; font-weight: 700; background: repeating-linear-gradient(-45deg,rgba(83,166,255,.24) 0 8px,rgba(83,166,255,.08) 8px 16px); box-shadow: inset 0 0 0 1px rgba(83,166,255,.16),0 0 18px rgba(50,132,255,.2); pointer-events: none; }
.visual-overlay-drop-preview span { overflow: hidden; padding: 0 6px; text-overflow: ellipsis; white-space: nowrap; }
@@ -5825,7 +5849,31 @@ button:disabled {
.playback-controls { min-width: 0; gap: 1px; }
.playback-controls .icon-button { width: 36px; height: 36px; }
.transport-time { min-width: 74px; font-size: 11px; }
.fit-button { min-width: 58px; padding: 0 7px; font-size: 11px; }
.desktop-fit-button { display: none; }
.mobile-ratio-select {
position: relative;
display: inline-flex;
align-items: center;
min-width: 58px;
height: 36px;
border: 1px solid rgba(255, 255, 255, .08);
border-radius: 8px;
color: #cbd6dc;
background: #222831;
}
.mobile-ratio-select select {
width: 100%;
height: 100%;
border: 0;
outline: 0;
padding: 0 23px 0 10px;
color: inherit;
font: inherit;
font-size: 11px;
appearance: none;
background: transparent;
}
.mobile-ratio-select svg { position: absolute; right: 7px; pointer-events: none; }
.tool-rail,
.tool-rail.is-compact {
@@ -5854,8 +5902,6 @@ button:disabled {
min-height: 52px;
padding: 4px 3px;
}
.tool-rail .mobile-inspector-tool,
.tool-rail.is-compact .mobile-inspector-tool { display: grid; }
.tool-rail.is-compact .rail-tool span { display: block; }
.rail-tool span { font-size: 10px; }
@@ -5874,6 +5920,15 @@ button:disabled {
background: #121820;
box-shadow: 0 -18px 52px rgba(0, 0, 0, .58);
}
.media-panel {
padding-top: 62px;
padding-bottom: 0;
overflow-x: hidden;
overflow-y: auto;
overscroll-behavior: contain;
-webkit-overflow-scrolling: touch;
}
.voice-panel { padding-top: 62px; }
.mobile-panel-tools .media-panel,
.mobile-panel-inspector .voice-panel {
display: block;
@@ -5887,22 +5942,94 @@ button:disabled {
}
.media-panel > *,
.voice-panel > * { min-width: 0; }
.media-panel.has-mobile-asset-actions { padding-bottom: 96px; }
.mobile-asset-actions {
position: fixed;
right: 7px;
bottom: calc(68px + env(safe-area-inset-bottom));
left: 7px;
z-index: 105;
display: grid;
grid-template-columns: minmax(0, 1fr) auto;
align-items: center;
gap: 10px;
min-height: 78px;
padding: 10px 12px;
border-top: 1px solid rgba(255, 255, 255, .09);
border-radius: 0 0 13px 13px;
background: rgba(14, 20, 27, .98);
box-shadow: 0 -10px 24px rgba(0, 0, 0, .28);
}
.mobile-asset-actions > span { min-width: 0; }
.mobile-asset-actions > span strong,
.mobile-asset-actions > span small {
display: block;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.mobile-asset-actions > span strong { color: #e8f2f4; font-size: 12px; }
.mobile-asset-actions > span small { margin-top: 4px; color: #81909a; font-size: 10px; }
.mobile-asset-actions > div { display: flex; gap: 7px; }
.mobile-asset-actions button {
min-height: 40px;
border: 1px solid #35ead9;
border-radius: 9px;
padding: 0 12px;
color: #061312;
font-size: 11px;
font-weight: 700;
white-space: nowrap;
background: #35ead9;
}
.mobile-asset-actions button.is-secondary {
color: #c5d1d6;
border-color: rgba(255, 255, 255, .13);
background: rgba(255, 255, 255, .045);
}
.tool-panel { padding-bottom: 18px; }
.asset-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.smart-hub-panel { gap: 12px; }
.smart-mobile-header {
position: sticky;
top: 0;
z-index: 3;
display: grid;
padding: 16px 0 12px;
.mobile-sheet-nav {
position: fixed;
right: 7px;
bottom: calc(68px + env(safe-area-inset-bottom) + min(68dvh, 620px) - 55px);
left: 7px;
z-index: 106;
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
height: 54px;
padding: 0 10px 0 16px;
border-bottom: 1px solid rgba(255, 255, 255, .08);
background: #121820;
border-radius: 13px 13px 0 0;
background: rgba(18, 24, 32, .98);
animation: mobile-sheet-enter 240ms cubic-bezier(.2, .82, .24, 1) both;
}
.smart-mobile-header strong {
color: #f1f8fa;
font-size: 16px;
font-weight: 750;
.mobile-sheet-nav > strong {
min-width: 0;
overflow: hidden;
color: #f0f7f8;
font-size: 15px;
text-overflow: ellipsis;
white-space: nowrap;
}
.mobile-sheet-nav > div { display: flex; align-items: center; gap: 4px; }
.mobile-sheet-nav button {
min-height: 34px;
border: 0;
border-radius: 8px;
padding: 0 10px;
color: #94a2ac;
background: transparent;
}
.mobile-sheet-nav button.is-active { color: #36ead9; background: rgba(54, 234, 217, .1); }
.mobile-sheet-nav .mobile-sheet-close { width: 34px; padding: 0; color: #c9d4da; font-size: 23px; line-height: 1; }
.is-mobile-panel-closing .mobile-sheet-nav {
pointer-events: none;
animation: mobile-sheet-exit 170ms ease-in both;
}
.mobile-sheet-backdrop {
@@ -5981,27 +6108,95 @@ button:disabled {
.sticker-segment,
.audio-clip { min-height: 28px; }
.mobile-empty-visual-entry {
position: absolute;
z-index: 3;
top: 4px;
left: 10px;
display: inline-flex;
align-items: center;
justify-content: center;
gap: 6px;
min-width: 116px;
min-height: 32px;
border: 1px dashed rgba(53, 234, 217, .62);
border-radius: 8px;
padding: 0 12px;
color: #35ead9;
font: inherit;
font-size: 11px;
font-weight: 720;
background: rgba(53, 234, 217, .08);
box-shadow: 0 0 0 1px rgba(53, 234, 217, .025) inset;
}
.mobile-empty-visual-entry:active { background: rgba(53, 234, 217, .16); }
.mobile-empty-visual-entry:focus-visible {
outline: 2px solid #b9fff8;
outline-offset: 2px;
}
.timeline-context-menu {
position: fixed;
right: 8px !important;
bottom: max(8px, env(safe-area-inset-bottom));
left: 8px !important;
right: 10px !important;
bottom: calc(72px + env(safe-area-inset-bottom));
left: auto !important;
top: auto !important;
width: auto;
max-height: 58dvh;
width: min(270px, calc(100vw - 20px));
max-height: min(36dvh, 300px);
overflow-y: auto;
border-radius: 12px;
padding: 8px;
border-radius: 10px;
padding: 5px;
overscroll-behavior: contain;
-webkit-overflow-scrolling: touch;
animation: mobile-context-menu-enter 180ms cubic-bezier(.2, .8, .25, 1) both;
}
.timeline-context-heading {
position: sticky;
top: -5px;
z-index: 2;
padding: 7px 6px;
background: #171b22;
}
.timeline-context-menu button {
min-height: 34px;
padding: 4px 6px;
font-size: 11.5px;
}
.timeline-context-menu button svg { width: 15px; height: 15px; }
@keyframes mobile-context-menu-enter {
from { opacity: 0; transform: translateY(16px) scale(.985); }
to { opacity: 1; transform: translateY(0) scale(1); }
}
.timeline-context-menu button { min-height: 44px; font-size: 13px; }
.preview-stage.is-focus-preview {
inset: max(6px, env(safe-area-inset-top)) 6px max(6px, env(safe-area-inset-bottom));
grid-template-rows: 52px minmax(0, 1fr) 62px;
border-radius: 12px;
}
.focus-preview-header { padding: 0 8px; }
.preview-stage.is-focus-preview.is-focus-landscape,
.preview-stage.is-focus-preview.is-focus-square {
top: 50%;
bottom: auto;
height: auto;
max-height: calc(100dvh - max(12px, env(safe-area-inset-top)) - max(12px, env(safe-area-inset-bottom)));
transform: translateY(-50%);
}
.preview-stage.is-focus-preview.is-focus-landscape {
grid-template-rows: 52px auto 62px;
}
.preview-stage.is-focus-preview.is-focus-square {
grid-template-rows: 52px minmax(280px, 58dvh) 62px;
}
.preview-stage.is-focus-preview.is-focus-landscape .preview-canvas {
width: 100%;
aspect-ratio: var(--focus-preview-ratio, 16 / 9);
min-height: 220px;
max-height: calc(100dvh - 126px);
}
.focus-preview-header { padding: 0 max(4px, env(safe-area-inset-right)) 0 12px; }
.focus-preview-header span { display: none; }
.focus-preview-close { flex-basis: 48px; width: 48px; height: 48px; }
.toast {
right: 10px;
@@ -6019,7 +6214,9 @@ button:disabled {
@media (max-width: 760px) and (prefers-reduced-motion: reduce) {
.mobile-panel-tools .media-panel,
.mobile-panel-inspector .voice-panel,
.mobile-sheet-backdrop { animation-duration: 1ms !important; }
.mobile-sheet-nav,
.mobile-sheet-backdrop,
.timeline-context-menu { animation-duration: 1ms !important; }
}
@media (max-width: 390px) {
@@ -6042,3 +6239,11 @@ button:disabled {
width: 0;
height: 0;
}
@media (max-width: 760px) {
.media-panel .tool-panel {
height: auto;
min-height: 100%;
overflow-y: visible;
}
}