🎥 Make videos programmatically with React
`@remotion/studio`: Make keyframe frame editable in Inspector (#8662)
Jonny Burgerfd28a00e2104
diff --git a/packages/studio/src/components/InspectorPanel/EasingInspector.tsx b/packages/studio/src/components/InspectorPanel/EasingInspector.tsxindex c527233f8a..ab0a4388f0 100644--- a/packages/studio/src/components/InspectorPanel/EasingInspector.tsx+++ b/packages/studio/src/components/InspectorPanel/EasingInspector.tsx@@ -1,34 +1,80 @@import React, {useCallback, useContext, useMemo} from 'react';-import {Internals} from 'remotion';+import type {DragOverrideValue} from 'remotion';+import {Internals, useVideoConfig} from 'remotion';+import {StudioServerConnectionCtx} from '../../helpers/client-id';+import {+ getEffectFieldsToShow,+ getFieldsToShow,+} from '../../helpers/timeline-layout';+import {Plus} from '../../icons/plus';+import {renderFrame} from '../../state/render-frame';import {VERTICAL_SCROLLBAR_CLASSNAME} from '../Menu/is-menu-item';-import type {SegmentedControlItem} from '../SegmentedControl';-import {SegmentedControl} from '../SegmentedControl';+import {+ callAddEffectKeyframe,+ callAddSequenceKeyframe,+} from '../Timeline/call-add-keyframe';import {EasingEditor} from '../Timeline/EasingEditorModal';-import {getTimelineSelectionKey} from '../Timeline/TimelineSelection';import {- getTimelineEasingValueForSelection,+ getTimelineSelectionFromNodePathInfo,+ getTimelineSelectionKey,+ useTimelineSelection,+} from '../Timeline/TimelineSelection';+import {+ getSelectedEasingUpdate,type EasingSelection,} from '../Timeline/update-selected-easing';-import {InspectorMessage, InspectorSectionHeader} from './common';import {- sectionHeaderRow,- sectionHeaderStart,+ InspectorBackHeaderWithDivider,+ InspectorInlineAction,+ InspectorMessage,+} from './common';+import {getEasingSelectionFromCurrentKeyframes} from './easing-inspector-selection';+import {KeyframeEasingNavigator} from './KeyframeEasingNavigator';+import {SequenceInspectorHeaderWithDivider} from './SequenceInspectorHeader';+import {+ detailsContainer,sectionHeaderTitle,selectedContainer,} from './styles';+import {useTrackForSelection} from './use-track-for-selection';++type EasingInspectorDetails = {+ readonly defaultValue: unknown;+ readonly dragOverrideValue: DragOverrideValue | undefined;+ readonly fieldLabel: string;+};++const addKeyframeIcon: React.CSSProperties = {+ display: 'block',+ height: 13,+ width: 12,+};export const EasingInspector: React.FC<{readonly selection: EasingSelection;}> = ({selection}) => {+ const track = useTrackForSelection(selection);+ const videoConfig = useVideoConfig();+ const timelinePosition = Internals.Timeline.useTimelinePosition();const {sequences} = useContext(Internals.SequenceManager);const {overrideIdToNodePathMappings} = useContext(Internals.OverrideIdsToNodePathsGettersContext,);const {propStatuses} = useContext(Internals.VisualModePropStatusesContext);+ const {getDragOverrides, getEffectDragOverrides} = useContext(+ Internals.VisualModeDragOverridesContext,+ );+ const {setPropStatuses} = useContext(Internals.VisualModeSettersContext);+ const {previewServerState} = useContext(StudioServerConnectionCtx);+ const {selectItems} = useTimelineSelection();+ const parentSelection = useMemo(+ () => getTimelineSelectionFromNodePathInfo(selection.nodePathInfo),+ [selection.nodePathInfo],+ );- const initialEasing = useMemo(+ const easingUpdate = useMemo(() =>- getTimelineEasingValueForSelection({+ getSelectedEasingUpdate({selection,sequences,overrideIdsToNodePaths: overrideIdToNodePathMappings,@@ -36,47 +82,259 @@ export const EasingInspector: React.FC<{}),[overrideIdToNodePathMappings, propStatuses, selection, sequences],);+ const initialEasing = easingUpdate?.currentEasing ?? null;+ const easingDetails = useMemo<EasingInspectorDetails | null>(() => {+ if (easingUpdate === null || track === null) {+ return null;+ }++ if (easingUpdate.type === 'sequence') {+ const sequenceDragOverrideValue = (getDragOverrides(+ easingUpdate.nodePath,+ ) ?? {})[easingUpdate.fieldKey];+ if (!track.sequence.controls) {+ return {+ defaultValue: undefined,+ dragOverrideValue: sequenceDragOverrideValue,+ fieldLabel: easingUpdate.fieldKey,+ };+ }++ const sequenceFields = getFieldsToShow({+ schema: track.sequence.controls.schema,+ currentRuntimeValueDotNotation:+ track.sequence.controls.currentRuntimeValueDotNotation,+ getDragOverrides,+ propStatuses,+ nodePath: easingUpdate.nodePath,+ });+ const sequenceField =+ sequenceFields?.find(+ (candidate) => candidate.key === easingUpdate.fieldKey,+ ) ?? null;++ return {+ defaultValue: sequenceField?.fieldSchema.default,+ dragOverrideValue: sequenceDragOverrideValue,+ fieldLabel:+ sequenceField?.description ??+ sequenceField?.key ??+ easingUpdate.fieldKey,+ };+ }++ const effectDragOverrideValue = getEffectDragOverrides(+ easingUpdate.nodePath,+ easingUpdate.effectIndex,+ )[easingUpdate.fieldKey];+ const effect = track.sequence.effects[easingUpdate.effectIndex];+ if (!effect) {+ return {+ defaultValue: undefined,+ dragOverrideValue: effectDragOverrideValue,+ fieldLabel: easingUpdate.fieldKey,+ };+ }++ const effectFields = getEffectFieldsToShow({+ effect,+ effectIndex: easingUpdate.effectIndex,+ nodePath: easingUpdate.nodePath,+ propStatuses,+ getEffectDragOverrides,+ });+ const effectField =+ effectFields.find(+ (candidate) => candidate.key === easingUpdate.fieldKey,+ ) ?? null;++ return {+ defaultValue: effectField?.fieldSchema.default,+ dragOverrideValue: effectDragOverrideValue,+ fieldLabel:+ effectField?.description ?? effectField?.key ?? easingUpdate.fieldKey,+ };+ }, [+ easingUpdate,+ getDragOverrides,+ getEffectDragOverrides,+ propStatuses,+ track,+ ]);+ const fieldLabel = easingDetails?.fieldLabel ?? null;++ const currentEasingSelection = useMemo(() => {+ if (easingUpdate === null || track === null) {+ return null;+ }++ return getEasingSelectionFromCurrentKeyframes({+ keyframeDisplayOffset: track.keyframeDisplayOffset,+ nodePathInfo: selection.nodePathInfo,+ propStatus: easingUpdate.propStatus,+ segmentIndex: easingUpdate.segmentIndex,+ });+ }, [easingUpdate, selection.nodePathInfo, track]);const state = useMemo(() => {- if (initialEasing === null) {+ if (initialEasing === null || currentEasingSelection === null) {return null;}return {initialEasing,- selections: [selection],+ selections: [currentEasingSelection],};- }, [initialEasing, selection]);+ }, [currentEasingSelection, initialEasing]);++ const onSelectParent = useCallback<+ React.MouseEventHandler<HTMLButtonElement>+ >(+ (event) => {+ event.stopPropagation();+ if (parentSelection === null) {+ return;+ }++ selectItems([parentSelection], {reveal: true});+ },+ [parentSelection, selectItems],+ );++ const canAddKeyframeAtPlayhead =+ currentEasingSelection !== null &&+ timelinePosition > currentEasingSelection.fromFrame &&+ timelinePosition < currentEasingSelection.toFrame;+ const addKeyframeTime = renderFrame(timelinePosition, videoConfig.fps);+ const addKeyframeDisabled = previewServerState.type !== 'connected';+ const onAddKeyframeAtPlayhead = useCallback<+ React.MouseEventHandler<HTMLButtonElement>+ >(+ (event) => {+ event.stopPropagation();+ if (+ !canAddKeyframeAtPlayhead ||+ easingUpdate === null ||+ easingDetails === null ||+ track === null ||+ previewServerState.type !== 'connected'+ ) {+ return;+ }++ const sourceFrame = timelinePosition - track.keyframeDisplayOffset;+ const value = Internals.getEffectiveVisualModeValue({+ propStatus: easingUpdate.propStatus,+ dragOverrideValue: easingDetails.dragOverrideValue,+ defaultValue: easingDetails.defaultValue,+ frame: sourceFrame,+ shouldResortToDefaultValueIfUndefined: true,+ });+ const keyframeSelection = {+ type: 'keyframe' as const,+ nodePathInfo: selection.nodePathInfo,+ frame: timelinePosition,+ };++ if (easingUpdate.type === 'sequence') {+ callAddSequenceKeyframe({+ fileName: easingUpdate.fileName,+ nodePath: easingUpdate.nodePath,+ fieldKey: easingUpdate.fieldKey,+ sourceFrame,+ value,+ schema: easingUpdate.schema,+ setPropStatuses,+ clientId: previewServerState.clientId,+ }).catch(() => undefined);+ } else {+ callAddEffectKeyframe({+ fileName: easingUpdate.fileName,+ nodePath: easingUpdate.nodePath,+ effectIndex: easingUpdate.effectIndex,+ fieldKey: easingUpdate.fieldKey,+ sourceFrame,+ value,+ schema: easingUpdate.schema,+ setPropStatuses,+ clientId: previewServerState.clientId,+ }).catch(() => undefined);+ }++ selectItems([keyframeSelection], {reveal: true});+ },+ [+ canAddKeyframeAtPlayhead,+ easingDetails,+ easingUpdate,+ previewServerState,+ selectItems,+ selection.nodePathInfo,+ setPropStatuses,+ timelinePosition,+ track,+ ],+ );const renderHeader = useCallback(- (modeItems: SegmentedControlItem[]) => (- <InspectorSectionHeader>- <div style={sectionHeaderRow}>- <div style={sectionHeaderStart}>- <span style={sectionHeaderTitle}>Easing</span>- <SegmentedControl- items={modeItems}- needsWrapping={false}- size="compact"- />- </div>- </div>- </InspectorSectionHeader>+ () => (+ <>+ <InspectorBackHeaderWithDivider+ disabled={parentSelection === null}+ onClick={onSelectParent}+ title="Back to property"+ >+ <div style={sectionHeaderTitle}>{fieldLabel}</div>+ </InspectorBackHeaderWithDivider>+ {easingUpdate === null || track === null ? null : (+ <KeyframeEasingNavigator+ currentSelection={currentEasingSelection ?? selection}+ includeEasings+ keyframes={easingUpdate.propStatus.keyframes.map((keyframe) => ({+ ...keyframe,+ frame: keyframe.frame + track.keyframeDisplayOffset,+ }))}+ nodePathInfo={selection.nodePathInfo}+ />+ )}+ </>),- [],+ [+ currentEasingSelection,+ easingUpdate,+ fieldLabel,+ onSelectParent,+ parentSelection,+ selection,+ track,+ ],);- if (state === null) {+ if (state === null || track === null || currentEasingSelection === null) {return <InspectorMessage>Easing unavailable</InspectorMessage>;}return (<div style={selectedContainer} className={VERTICAL_SCROLLBAR_CLASSNAME}>+ <SequenceInspectorHeaderWithDivider track={track} /><EasingEditor- key={getTimelineSelectionKey(selection)}+ key={getTimelineSelectionKey(currentEasingSelection)}state={state}renderHeader={renderHeader}/>+ {canAddKeyframeAtPlayhead ? (+ <div style={detailsContainer}>+ <InspectorInlineAction+ disabled={addKeyframeDisabled}+ onClick={onAddKeyframeAtPlayhead}+ renderIcon={(color) => (+ <Plus color={color} style={addKeyframeIcon} />+ )}+ >+ {`Add keyframe at ${addKeyframeTime}`}+ </InspectorInlineAction>+ </div>+ ) : null}</div>);};diff --git a/packages/studio/src/components/InspectorPanel/KeyframeEasingNavigator.tsx b/packages/studio/src/components/InspectorPanel/KeyframeEasingNavigator.tsxnew file mode 100644index 0000000000..e905282a47--- /dev/null+++ b/packages/studio/src/components/InspectorPanel/KeyframeEasingNavigator.tsx@@ -0,0 +1,294 @@+import React, {useCallback, useMemo} from 'react';+import {Internals, useVideoConfig} from 'remotion';+import {LIGHT_TEXT} from '../../helpers/colors';+import type {SequenceNodePathInfo} from '../../helpers/get-timeline-sequence-sort-key';+import {InlineAction} from '../InlineAction';+import {INSPECTOR_PANEL_HORIZONTAL_PADDING} from '../InspectorPanelLayout';+import {TimelineKeyframeDiamondIcon} from '../Timeline/TimelineKeyframeDiamondIcon';+import {TimelineKeyframeEasingLineVisual} from '../Timeline/TimelineKeyframeEasingLine';+import {+ getTimelineSelectionKey,+ useTimelineSelection,+ type TimelineSelection,+} from '../Timeline/TimelineSelection';+import {+ getKeyframeEasingNavigatorItems,+ getNavigatorItemPlayheadFrame,+ type NavigatorItem,+ type NavigatorKeyframe,+} from './keyframe-easing-navigator-items';++const navigatorContainer: React.CSSProperties = {+ alignItems: 'center',+ boxSizing: 'border-box',+ display: 'flex',+ gap: 8,+ justifyContent: 'space-between',+ padding: `8px ${INSPECTOR_PANEL_HORIZONTAL_PADDING}px 6px`,+ width: '100%',+};++const itemStrip: React.CSSProperties = {+ alignItems: 'center',+ display: 'flex',+ flex: 1,+ gap: 0,+ height: 24,+ justifyContent: 'center',+ minWidth: 0,+};++const itemButton: React.CSSProperties = {+ alignItems: 'center',+ background: 'none',+ border: 'none',+ display: 'flex',+ height: 24,+ justifyContent: 'center',+ padding: 0,+};++const diamondSize = 12;+const easingLineDiamondOverlap = diamondSize / 2;++const emptyItem: React.CSSProperties = {+ height: 24,+ width: diamondSize,+};++const easingItem: React.CSSProperties = {+ height: 12,+ position: 'relative',+ width: 38,+};++const getEasingLineUnderlay = ({+ extendLeft,+ extendRight,+}: {+ readonly extendLeft: boolean;+ readonly extendRight: boolean;+}): React.CSSProperties => {+ return {+ bottom: 0,+ left: extendLeft ? -easingLineDiamondOverlap : 0,+ pointerEvents: 'none',+ position: 'absolute',+ right: extendRight ? -easingLineDiamondOverlap : 0,+ top: 0,+ };+};++const chevronIcon: React.CSSProperties = {+ display: 'block',+ height: 12,+ width: 8,+};++const disabledChevronColor = 'rgba(255, 255, 255, 0.25)';++const NavigationChevron: React.FC<{+ readonly color: string;+ readonly direction: 'left' | 'right';+}> = ({color, direction}) => {+ const path = direction === 'left' ? 'M6 1L2 6L6 11' : 'M2 1L6 6L2 11';++ return (+ <svg viewBox="0 0 8 12" style={chevronIcon}>+ <path+ d={path}+ fill="none"+ stroke={color}+ strokeLinecap="round"+ strokeLinejoin="round"+ strokeWidth="1.5"+ />+ </svg>+ );+};++const TimelineNavigatorItem: React.FC<{+ readonly extendLineLeft: boolean;+ readonly extendLineRight: boolean;+ readonly item: NavigatorItem | null;+ readonly onSelect: (item: NavigatorItem) => void;+ readonly selected: boolean;+}> = ({extendLineLeft, extendLineRight, item, onSelect, selected}) => {+ const onClick = useCallback(() => {+ if (item === null) {+ return;+ }++ onSelect(item);+ }, [item, onSelect]);++ if (item === null) {+ return <div style={emptyItem} />;+ }++ const buttonStyle: React.CSSProperties = {+ ...itemButton,+ position: 'relative',+ width: item.type === 'easing' ? 38 : diamondSize,+ zIndex: item.type === 'keyframe' ? 1 : 0,+ };+ const lineUnderlayStyle = getEasingLineUnderlay({+ extendLeft: extendLineLeft,+ extendRight: extendLineRight,+ });++ return (+ <button+ type="button"+ style={buttonStyle}+ onClick={onClick}+ title={+ item.type === 'keyframe'+ ? `Keyframe at frame ${item.selection.frame}`+ : `Easing from frame ${item.selection.fromFrame} to ${item.selection.toFrame}`+ }+ aria-label={+ item.type === 'keyframe'+ ? `Select keyframe at frame ${item.selection.frame}`+ : `Select easing from frame ${item.selection.fromFrame} to ${item.selection.toFrame}`+ }+ >+ {item.type === 'keyframe' ? (+ <TimelineKeyframeDiamondIcon+ color={LIGHT_TEXT}+ selected={selected}+ size={12}+ />+ ) : (+ <div style={easingItem}>+ <div style={lineUnderlayStyle}>+ <TimelineKeyframeEasingLineVisual selected={selected} />+ </div>+ </div>+ )}+ </button>+ );+};++export const KeyframeEasingNavigator: React.FC<{+ readonly currentSelection: Extract<+ TimelineSelection,+ {type: 'keyframe'} | {type: 'easing'}+ >;+ readonly includeEasings: boolean;+ readonly keyframes: readonly NavigatorKeyframe[];+ readonly nodePathInfo: SequenceNodePathInfo;+}> = ({currentSelection, includeEasings, keyframes, nodePathInfo}) => {+ const {isSelected, selectItems} = useTimelineSelection();+ const setFrame = Internals.useTimelineSetFrame();+ const videoConfig = useVideoConfig();+ const items = useMemo(+ () =>+ getKeyframeEasingNavigatorItems({+ includeEasings,+ keyframes,+ nodePathInfo,+ }),+ [includeEasings, keyframes, nodePathInfo],+ );+ const currentKey = getTimelineSelectionKey(currentSelection);+ const currentIndex = items.findIndex(+ (item) => getTimelineSelectionKey(item.selection) === currentKey,+ );+ const previousItem = currentIndex > 0 ? items[currentIndex - 1] : null;+ const currentItem = currentIndex === -1 ? null : items[currentIndex];+ const nextItem =+ currentIndex === -1 || currentIndex >= items.length - 1+ ? null+ : items[currentIndex + 1];++ const selectItem = useCallback(+ (item: NavigatorItem) => {+ selectItems([item.selection], {reveal: true});+ },+ [selectItems],+ );+ const seekToItem = useCallback(+ (item: NavigatorItem) => {+ const frame = getNavigatorItemPlayheadFrame(item);+ setFrame((current) => {+ const next = {...current, [videoConfig.id]: frame};+ Internals.persistCurrentFrame(next);+ return next;+ });+ },+ [setFrame, videoConfig.id],+ );+ const selectPrevious = useCallback(() => {+ if (previousItem === null) {+ return;+ }++ seekToItem(previousItem);+ selectItem(previousItem);+ }, [previousItem, seekToItem, selectItem]);+ const selectNext = useCallback(() => {+ if (nextItem === null) {+ return;+ }++ seekToItem(nextItem);+ selectItem(nextItem);+ }, [nextItem, seekToItem, selectItem]);++ if (currentItem === null) {+ return null;+ }++ return (+ <div style={navigatorContainer}>+ <InlineAction+ disabled={previousItem === null}+ onClick={selectPrevious}+ title="Previous animation item"+ renderAction={(color) => (+ <NavigationChevron+ color={previousItem === null ? disabledChevronColor : color}+ direction="left"+ />+ )}+ />+ <div style={itemStrip}>+ <TimelineNavigatorItem+ extendLineLeft={false}+ extendLineRight={currentItem.type === 'keyframe'}+ item={previousItem}+ onSelect={selectItem}+ selected={+ previousItem === null ? false : isSelected(previousItem.selection)+ }+ />+ <TimelineNavigatorItem+ extendLineLeft={previousItem?.type === 'keyframe'}+ extendLineRight={nextItem?.type === 'keyframe'}+ item={currentItem}+ onSelect={selectItem}+ selected={isSelected(currentItem.selection)}+ />+ <TimelineNavigatorItem+ extendLineLeft={currentItem.type === 'keyframe'}+ extendLineRight={false}+ item={nextItem}+ onSelect={selectItem}+ selected={nextItem === null ? false : isSelected(nextItem.selection)}+ />+ </div>+ <InlineAction+ disabled={nextItem === null}+ onClick={selectNext}+ title="Next animation item"+ renderAction={(color) => (+ <NavigationChevron+ color={nextItem === null ? disabledChevronColor : color}+ direction="right"+ />+ )}+ />+ </div>+ );+};diff --git a/packages/studio/src/components/InspectorPanel/KeyframeInspector.tsx b/packages/studio/src/components/InspectorPanel/KeyframeInspector.tsxindex 4d5094379a..faf36feffc 100644--- a/packages/studio/src/components/InspectorPanel/KeyframeInspector.tsx+++ b/packages/studio/src/components/InspectorPanel/KeyframeInspector.tsx@@ -1,11 +1,23 @@-import React, {useContext, useMemo} from 'react';+import {+ canMoveKeyframesWithoutCollisions,+ moveKeyframesInPropStatus,+} from '@remotion/studio-shared';+import React, {+ useCallback,+ useContext,+ useEffect,+ useMemo,+ useState,+} from 'react';import type {CanUpdateSequencePropStatusKeyframed,+ DragOverrideValue,SequencePropsSubscriptionKey,InteractivitySchema,} from 'remotion';-import {Internals} from 'remotion';+import {Internals, useVideoConfig} from 'remotion';import type {CodePosition} from '../../error-overlay/react-overlay/utils/get-source-map';+import {StudioServerConnectionCtx} from '../../helpers/client-id';import {getEffectFieldsToShow,getFieldsToShow,@@ -13,20 +25,40 @@ import {type SchemaFieldInfo,} from '../../helpers/timeline-layout';import {VERTICAL_SCROLLBAR_CLASSNAME} from '../Menu/is-menu-item';+import {InputDragger} from '../NewComposition/InputDragger';+import {+ callDeleteEffectKeyframe,+ callDeleteSequenceKeyframe,+} from '../Timeline/call-delete-keyframe';+import {callMoveKeyframes} from '../Timeline/call-move-keyframe';+import {getEasingSelectionAfterKeyframeDelete} from '../Timeline/get-easing-selection-after-keyframe-delete';import {parseKeyframeFieldFromNodePath} from '../Timeline/parse-keyframe-field-from-node-path';import {TimelineEffectPropValue} from '../Timeline/TimelineEffectPropItem';-import type {TimelineSelection} from '../Timeline/TimelineSelection';+import {+ getTimelineSelectionFromNodePathInfo,+ useTimelineSelection,+ type TimelineSelection,+} from '../Timeline/TimelineSelection';import {TimelineSequenceKeyframedValue} from '../Timeline/TimelineSequencePropItem';+import {canEditEasingForInterpolationFunction} from '../Timeline/update-selected-easing';import {+ InspectorBackHeaderWithDivider,InspectorDetailRow,+ InspectorInlineAction,InspectorMessage,- InspectorSectionHeader,} from './common';+import {+ clampInspectorKeyframeDisplayFrame,+ getInspectorKeyframeSourceFrame,+} from './keyframe-inspector-frame';+import {KeyframeEasingNavigator} from './KeyframeEasingNavigator';+import {SequenceInspectorHeaderWithDivider} from './SequenceInspectorHeader';import {detailsContainer,keyframeEditorLabel,keyframeEditorRow,keyframeEditorValue,+ sectionHeaderTitle,selectedContainer,} from './styles';import {useTrackForSelection} from './use-track-for-selection';@@ -40,25 +72,100 @@ type KeyframeEditorDetails =readonly nodePath: SequencePropsSubscriptionKey;readonly propStatus: CanUpdateSequencePropStatusKeyframed;readonly schema: InteractivitySchema;+ readonly keyframeDisplayOffset: number;readonly sourceFrame: number;}| {readonly type: 'effect';+ readonly effectIndex: number;readonly field: EffectSchemaFieldInfo;readonly fieldLabel: string;+ readonly fileName: string;readonly nodePath: SequencePropsSubscriptionKey;+ readonly propStatus: CanUpdateSequencePropStatusKeyframed;+ readonly schema: InteractivitySchema;+ readonly keyframeDisplayOffset: number;readonly sourceFrame: number;readonly validatedLocation: CodePosition;};+const makeMovedKeyframedDragOverride = ({+ details,+ toFrame,+}: {+ readonly details: KeyframeEditorDetails;+ readonly toFrame: number;+}): DragOverrideValue | null => {+ if (+ !canMoveKeyframesWithoutCollisions({+ status: details.propStatus,+ moves: [{fromFrame: details.sourceFrame, toFrame}],+ })+ ) {+ return null;+ }++ const movedStatus = moveKeyframesInPropStatus({+ status: details.propStatus,+ moves: [{fromFrame: details.sourceFrame, toFrame}],+ });++ if (movedStatus.status !== 'keyframed') {+ return null;+ }++ return {+ type: 'keyframed',+ status: movedStatus,+ };+};++const removeKeyframeIcon: React.CSSProperties = {+ display: 'block',+ flexShrink: 0,+ height: 13,+ width: 12,+};++const TrashIcon: React.FC<{readonly color: string}> = ({color}) => {+ return (+ <svg viewBox="0 0 448 512" style={removeKeyframeIcon}>+ <path+ fill={color}+ d="M136.7 5.9C141.1-7.2 153.3-16 167.1-16l113.9 0c13.8 0 26 8.8 30.4 21.9L320 32 416 32c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 96C14.3 96 0 81.7 0 64S14.3 32 32 32l96 0 8.7-26.1zM32 144l384 0 0 304c0 35.3-28.7 64-64 64L96 512c-35.3 0-64-28.7-64-64l0-304zm88 64c-13.3 0-24 10.7-24 24l0 192c0 13.3 10.7 24 24 24s24-10.7 24-24l0-192c0-13.3-10.7-24-24-24zm104 0c-13.3 0-24 10.7-24 24l0 192c0 13.3 10.7 24 24 24s24-10.7 24-24l0-192c0-13.3-10.7-24-24-24zm104 0c-13.3 0-24 10.7-24 24l0 192c0 13.3 10.7 24 24 24s24-10.7 24-24l0-192c0-13.3-10.7-24-24-24z"+ />+ </svg>+ );+};+export const KeyframeInspector: React.FC<{readonly selection: Extract<TimelineSelection, {type: 'keyframe'}>;}> = ({selection}) => {const track = useTrackForSelection(selection);+ const videoConfig = useVideoConfig();+ const timelinePosition = Internals.Timeline.useTimelinePosition();const {propStatuses} = useContext(Internals.VisualModePropStatusesContext);+ const {+ clearDragOverrides,+ clearEffectDragOverrides,+ setDragOverrides,+ setEffectDragOverrides,+ setPropStatuses,+ } = useContext(Internals.VisualModeSettersContext);const {getDragOverrides, getEffectDragOverrides} = useContext(Internals.VisualModeDragOverridesContext,);+ const {previewServerState} = useContext(StudioServerConnectionCtx);+ const {selectItems} = useTimelineSelection();+ const [draftFrame, setDraftFrame] = useState(selection.frame);+ const parentSelection = useMemo(+ () => getTimelineSelectionFromNodePathInfo(selection.nodePathInfo),+ [selection.nodePathInfo],+ );++ useEffect(() => {+ setDraftFrame(selection.frame);+ }, [selection.frame]);const details = useMemo<KeyframeEditorDetails | null>(() => {if (!track || !track.sequence.controls) {@@ -103,6 +210,7 @@ export const KeyframeInspector: React.FC<{field: sequenceField,fieldLabel: sequenceField.description ?? sequenceField.key,fileName: nodePath.absolutePath,+ keyframeDisplayOffset,nodePath,propStatus: sequencePropStatus,schema: track.sequence.controls.schema,@@ -142,9 +250,14 @@ export const KeyframeInspector: React.FC<{return {type: 'effect',+ effectIndex: keyframeField.effectIndex,field: effectField,fieldLabel: effectField.description ?? effectField.key,+ fileName: nodePath.absolutePath,+ keyframeDisplayOffset,nodePath,+ propStatus: effectPropStatus,+ schema: effect.schema,sourceFrame,validatedLocation: {source: nodePath.absolutePath,@@ -160,15 +273,276 @@ export const KeyframeInspector: React.FC<{track,]);- if (details === null) {+ const clearFrameDragOverride = useCallback(+ (detailsToClear: KeyframeEditorDetails | null) => {+ if (detailsToClear === null) {+ return;+ }++ if (detailsToClear.type === 'sequence') {+ clearDragOverrides(detailsToClear.nodePath);+ return;+ }++ clearEffectDragOverrides(+ detailsToClear.nodePath,+ detailsToClear.effectIndex,+ );+ },+ [clearDragOverrides, clearEffectDragOverrides],+ );++ const onFrameChange = useCallback(+ (value: number) => {+ const displayFrame = clampInspectorKeyframeDisplayFrame({+ durationInFrames: videoConfig.durationInFrames,+ frame: value,+ });++ setDraftFrame(displayFrame);++ if (details === null) {+ return;+ }++ const toFrame = getInspectorKeyframeSourceFrame({+ displayFrame,+ keyframeDisplayOffset: details.keyframeDisplayOffset,+ });++ if (displayFrame === selection.frame || toFrame === details.sourceFrame) {+ clearFrameDragOverride(details);+ return;+ }++ const dragOverrideValue = makeMovedKeyframedDragOverride({+ details,+ toFrame,+ });++ if (dragOverrideValue === null) {+ clearFrameDragOverride(details);+ return;+ }++ if (details.type === 'sequence') {+ setDragOverrides(+ details.nodePath,+ details.field.key,+ dragOverrideValue,+ );+ return;+ }++ setEffectDragOverrides(+ details.nodePath,+ details.effectIndex,+ details.field.key,+ dragOverrideValue,+ );+ },+ [+ clearFrameDragOverride,+ details,+ selection.frame,+ setDragOverrides,+ setEffectDragOverrides,+ videoConfig.durationInFrames,+ ],+ );++ const onFrameChangeEnd = useCallback(+ (value: number) => {+ if (details === null || previewServerState.type !== 'connected') {+ clearFrameDragOverride(details);+ setDraftFrame(selection.frame);+ return;+ }++ const displayFrame = clampInspectorKeyframeDisplayFrame({+ durationInFrames: videoConfig.durationInFrames,+ frame: value,+ });+ const toFrame = getInspectorKeyframeSourceFrame({+ displayFrame,+ keyframeDisplayOffset: details.keyframeDisplayOffset,+ });++ setDraftFrame(displayFrame);+ clearFrameDragOverride(details);++ if (displayFrame === selection.frame || toFrame === details.sourceFrame) {+ return;+ }++ if (makeMovedKeyframedDragOverride({details, toFrame}) === null) {+ setDraftFrame(selection.frame);+ return;+ }++ selectItems(+ [+ {+ ...selection,+ frame: displayFrame,+ },+ ],+ {reveal: true},+ );++ const move = {+ fileName: details.fileName,+ nodePath: details.nodePath,+ fieldKey: details.field.key,+ fromFrame: details.sourceFrame,+ toFrame,+ schema: details.schema,+ };++ callMoveKeyframes({+ sequenceKeyframes: details.type === 'sequence' ? [move] : [],+ effectKeyframes:+ details.type === 'effect'+ ? [+ {+ ...move,+ effectIndex: details.effectIndex,+ },+ ]+ : [],+ setPropStatuses,+ clientId: previewServerState.clientId,+ }).catch(() => undefined);+ },+ [+ clearFrameDragOverride,+ details,+ previewServerState,+ selection,+ selectItems,+ setPropStatuses,+ videoConfig.durationInFrames,+ ],+ );++ const onSelectParent = useCallback<+ React.MouseEventHandler<HTMLButtonElement>+ >(+ (event) => {+ event.stopPropagation();+ if (parentSelection === null) {+ return;+ }++ selectItems([parentSelection], {reveal: true});+ },+ [parentSelection, selectItems],+ );++ const removeDisabled = previewServerState.type !== 'connected';+ const onRemoveKeyframe = useCallback<+ React.MouseEventHandler<HTMLButtonElement>+ >(+ (event) => {+ event.stopPropagation();+ if (details === null || previewServerState.type !== 'connected') {+ return;+ }++ const easingSelection = canEditEasingForInterpolationFunction(+ details.propStatus.interpolationFunction,+ )+ ? getEasingSelectionAfterKeyframeDelete({+ deletedSourceFrames: [details.sourceFrame],+ keyframeDisplayOffset: details.keyframeDisplayOffset,+ nodePathInfo: selection.nodePathInfo,+ propStatus: details.propStatus,+ timelinePosition,+ })+ : null;+ if (easingSelection !== null) {+ selectItems([easingSelection], {reveal: true});+ } else if (parentSelection !== null) {+ selectItems([parentSelection], {reveal: true});+ }++ if (details.type === 'sequence') {+ callDeleteSequenceKeyframe({+ fileName: details.fileName,+ nodePath: details.nodePath,+ fieldKey: details.field.key,+ sourceFrame: details.sourceFrame,+ schema: details.schema,+ setPropStatuses,+ clientId: previewServerState.clientId,+ }).catch(() => undefined);+ return;+ }++ callDeleteEffectKeyframe({+ fileName: details.fileName,+ nodePath: details.nodePath,+ effectIndex: details.effectIndex,+ fieldKey: details.field.key,+ sourceFrame: details.sourceFrame,+ schema: details.schema,+ setPropStatuses,+ clientId: previewServerState.clientId,+ }).catch(() => undefined);+ },+ [+ details,+ parentSelection,+ previewServerState,+ selectItems,+ selection.nodePathInfo,+ setPropStatuses,+ timelinePosition,+ ],+ );++ if (details === null || track === null) {return <InspectorMessage>Keyframe unavailable</InspectorMessage>;}return (<div style={selectedContainer} className={VERTICAL_SCROLLBAR_CLASSNAME}>- <InspectorSectionHeader>Keyframe</InspectorSectionHeader>+ <SequenceInspectorHeaderWithDivider track={track} />+ <InspectorBackHeaderWithDivider+ disabled={parentSelection === null}+ onClick={onSelectParent}+ title="Back to property"+ >+ <div style={sectionHeaderTitle}>{details.fieldLabel}</div>+ </InspectorBackHeaderWithDivider>+ <KeyframeEasingNavigator+ currentSelection={selection}+ includeEasings={canEditEasingForInterpolationFunction(+ details.propStatus.interpolationFunction,+ )}+ keyframes={details.propStatus.keyframes.map((keyframe) => ({+ ...keyframe,+ frame: keyframe.frame + details.keyframeDisplayOffset,+ }))}+ nodePathInfo={selection.nodePathInfo}+ /><div style={detailsContainer}>- <InspectorDetailRow label="Frame">{selection.frame}</InspectorDetailRow>+ <InspectorDetailRow label="Frame">+ <InputDragger+ type="number"+ value={draftFrame}+ status="ok"+ onValueChange={onFrameChange}+ onValueChangeEnd={onFrameChangeEnd}+ onTextChange={() => undefined}+ min={0}+ max={Math.max(0, videoConfig.durationInFrames - 1)}+ step={1}+ formatter={(value) => String(Math.round(Number(value)))}+ rightAlign+ small+ />+ </InspectorDetailRow><div style={keyframeEditorRow}><div style={keyframeEditorLabel}>{details.fieldLabel}</div><div style={keyframeEditorValue}>@@ -191,6 +565,13 @@ export const KeyframeInspector: React.FC<{)}</div></div>+ <InspectorInlineAction+ disabled={removeDisabled}+ onClick={onRemoveKeyframe}+ renderIcon={(color) => <TrashIcon color={color} />}+ >+ Remove keyframe+ </InspectorInlineAction></div></div>);diff --git a/packages/studio/src/components/InspectorPanel/SequenceInspectorHeader.tsx b/packages/studio/src/components/InspectorPanel/SequenceInspectorHeader.tsxnew file mode 100644index 0000000000..98398b1622--- /dev/null+++ b/packages/studio/src/components/InspectorPanel/SequenceInspectorHeader.tsx@@ -0,0 +1,148 @@+import React, {useCallback, useContext, useMemo} from 'react';+import {Internals} from 'remotion';+import type {CodePosition} from '../../error-overlay/react-overlay/utils/get-source-map';+import type {TrackWithHash} from '../../helpers/get-timeline-sequence-sort-key';+import {InspectorSourceLocation} from '../InspectorSourceLocation';+import {useOpenSequenceInEditor} from '../Timeline/use-open-sequence-in-editor';+import {+ sequenceHeader,+ sequenceHeaderDivider,+ sequenceHeaderSubtitle,+ sequenceHeaderTitle,+} from './styles';++type SequenceInspectorSourceLocation = {+ readonly canOpenInEditor: boolean;+ readonly openFileLocation: () => void;+ readonly validatedLocation: CodePosition | null;+};++export const useSequenceInspectorSourceLocation = (+ sequence: TrackWithHash['sequence'],+): SequenceInspectorSourceLocation => {+ const {canOpenInEditor, openInEditor, originalLocation} =+ useOpenSequenceInEditor(sequence);++ const validatedLocation = useMemo(() => {+ if (+ !originalLocation ||+ !originalLocation.source ||+ !originalLocation.line+ ) {+ return null;+ }++ return {+ source: originalLocation.source,+ line: originalLocation.line,+ column: originalLocation.column ?? 0,+ };+ }, [originalLocation]);++ const openFileLocation = useCallback(() => {+ if (!canOpenInEditor) {+ return;+ }++ openInEditor();+ }, [canOpenInEditor, openInEditor]);++ return {+ canOpenInEditor,+ openFileLocation,+ validatedLocation,+ };+};++const useSequenceDisplayName = (track: TrackWithHash) => {+ const {propStatuses} = useContext(Internals.VisualModePropStatusesContext);+ const nodePath = track.nodePathInfo?.sequenceSubscriptionKey ?? null;++ return useMemo(() => {+ const propStatusesForOverride = nodePath+ ? Internals.getPropStatusesCtx(propStatuses, nodePath)+ : undefined;+ const codeNameStatus = propStatusesForOverride?.name;+ const fallbackDisplayName =+ track.sequence.controls?.componentName || '<Sequence>';++ if (+ codeNameStatus?.status === 'static' &&+ typeof codeNameStatus.codeValue === 'string'+ ) {+ return codeNameStatus.codeValue;+ }++ if (codeNameStatus?.status === 'static') {+ return fallbackDisplayName;+ }++ return track.sequence.displayName || fallbackDisplayName;+ }, [+ nodePath,+ propStatuses,+ track.sequence.controls?.componentName,+ track.sequence.displayName,+ ]);+};++export const SequenceInspectorHeader: React.FC<{+ readonly sourceLocation: SequenceInspectorSourceLocation;+ readonly track: TrackWithHash;+}> = ({sourceLocation, track}) => {+ const sequenceDisplayName = useSequenceDisplayName(track);+ const {documentationLink} = track.sequence;++ const openDocumentationLink = useCallback(() => {+ if (!documentationLink) {+ return;+ }++ window.open(documentationLink, '_blank', 'noopener,noreferrer');+ }, [documentationLink]);++ const subtitleStyle = useMemo((): React.CSSProperties => {+ return {+ ...sequenceHeaderSubtitle,+ cursor: documentationLink ? 'pointer' : 'default',+ };+ }, [documentationLink]);++ const componentName = track.sequence.controls?.componentName;++ return (+ <div style={sequenceHeader}>+ <div style={sequenceHeaderTitle}>{sequenceDisplayName}</div>+ {documentationLink ? (+ <button+ type="button"+ style={subtitleStyle}+ title="Open component docs"+ onClick={openDocumentationLink}+ >+ {componentName}+ </button>+ ) : (+ <div style={subtitleStyle}>{componentName}</div>+ )}+ <InspectorSourceLocation+ location={sourceLocation.validatedLocation}+ canOpen={sourceLocation.canOpenInEditor}+ onOpen={sourceLocation.openFileLocation}+ />+ </div>+ );+};++export const SequenceInspectorHeaderWithDivider: React.FC<{+ readonly track: TrackWithHash;+}> = ({track}) => {+ const sourceLocation = useSequenceInspectorSourceLocation(track.sequence);++ return (+ <>+ <SequenceInspectorHeader sourceLocation={sourceLocation} track={track} />+ <div style={sequenceHeaderDivider} />+ </>+ );+};diff --git a/packages/studio/src/components/InspectorPanel/SequenceSelectionInspector.tsx b/packages/studio/src/components/InspectorPanel/SequenceSelectionInspector.tsxindex 4b24ade816..11b9b74dbd 100644--- a/packages/studio/src/components/InspectorPanel/SequenceSelectionInspector.tsx+++ b/packages/studio/src/components/InspectorPanel/SequenceSelectionInspector.tsx@@ -1,106 +1,32 @@import React, {useCallback, useContext, useMemo} from 'react';-import {Internals} from 'remotion';import {StudioServerConnectionCtx} from '../../helpers/client-id';import type {TrackWithHash} from '../../helpers/get-timeline-sequence-sort-key';import {hasSequenceControls,InspectorSequenceSection,} from '../InspectorSequenceSection';-import {InspectorSourceLocation} from '../InspectorSourceLocation';import {VERTICAL_SCROLLBAR_CLASSNAME} from '../Menu/is-menu-item';import {getTimelineSelectionKey,type TimelineSelection,useTimelineSelection,} from '../Timeline/TimelineSelection';-import {useOpenSequenceInEditor} from '../Timeline/use-open-sequence-in-editor';import {InspectorMessage, InspectorSectionHeader} from './common';import type {SequenceSectionSelection} from './inspector-selection';import {- selectedContainer,- sequenceHeader,- sequenceHeaderSubtitle,- sequenceHeaderTitle,-} from './styles';+ SequenceInspectorHeader,+ useSequenceInspectorSourceLocation,+} from './SequenceInspectorHeader';+import {selectedContainer} from './styles';import {useTrackForSelection} from './use-track-for-selection';-const useSequenceDisplayName = (track: TrackWithHash) => {- const {propStatuses} = useContext(Internals.VisualModePropStatusesContext);- const nodePath = track.nodePathInfo?.sequenceSubscriptionKey ?? null;-- return useMemo(() => {- const propStatusesForOverride = nodePath- ? Internals.getPropStatusesCtx(propStatuses, nodePath)- : undefined;- const fallbackDisplayName =- track.sequence.controls?.componentName || '<Sequence>';- const codeNameStatus = propStatusesForOverride?.name;-- if (- codeNameStatus?.status === 'static' &&- typeof codeNameStatus.codeValue === 'string'- ) {- return codeNameStatus.codeValue;- }-- if (codeNameStatus?.status === 'static') {- return fallbackDisplayName;- }-- return track.sequence.displayName || fallbackDisplayName;- }, [- nodePath,- propStatuses,- track.sequence.controls?.componentName,- track.sequence.displayName,- ]);-};-const SequenceExpandedInspector: React.FC<{readonly track: TrackWithHash;}> = ({track}) => {const {previewServerState} = useContext(StudioServerConnectionCtx);const {selectedItems, selectItems} = useTimelineSelection();- const {canOpenInEditor, openInEditor, originalLocation} =- useOpenSequenceInEditor(track.sequence);- const sequenceDisplayName = useSequenceDisplayName(track);- const {documentationLink} = track.sequence;-- const validatedLocation = useMemo(() => {- if (- !originalLocation ||- !originalLocation.source ||- !originalLocation.line- ) {- return null;- }-- return {- source: originalLocation.source,- line: originalLocation.line,- column: originalLocation.column ?? 0,- };- }, [originalLocation]);- const openFileLocation = useCallback(() => {- if (!canOpenInEditor) {- return;- }-- openInEditor();- }, [canOpenInEditor, openInEditor]);- const openDocumentationLink = useCallback(() => {- if (!documentationLink) {- return;- }-- window.open(documentationLink, '_blank', 'noopener,noreferrer');- }, [documentationLink]);- const subtitleStyle = useMemo((): React.CSSProperties => {- return {- ...sequenceHeaderSubtitle,- cursor: documentationLink ? 'pointer' : 'default',- };- }, [documentationLink]);+ const sourceLocation = useSequenceInspectorSourceLocation(track.sequence);+ const {validatedLocation} = sourceLocation;const sequenceSelection = useMemo((): TimelineSelection | null => {if (!track.nodePathInfo) {return null;@@ -155,28 +81,7 @@ const SequenceExpandedInspector: React.FC<{className={VERTICAL_SCROLLBAR_CLASSNAME}onPointerDown={selectSequenceOnInspectorPointerDown}>- <div style={sequenceHeader}>- <div style={sequenceHeaderTitle}>{sequenceDisplayName}</div>- {documentationLink ? (- <button- type="button"- style={subtitleStyle}- title="Open component docs"- onClick={openDocumentationLink}- >- {track.sequence.controls.componentName}- </button>- ) : (- <div style={subtitleStyle}>- {track.sequence.controls.componentName}- </div>- )}- <InspectorSourceLocation- location={validatedLocation}- canOpen={canOpenInEditor}- onOpen={openFileLocation}- />- </div>+ <SequenceInspectorHeader sourceLocation={sourceLocation} track={track} /><InspectorSequenceSectionsequence={track.sequence}validatedLocation={validatedLocation}diff --git a/packages/studio/src/components/InspectorPanel/common.tsx b/packages/studio/src/components/InspectorPanel/common.tsxindex 6487eb30e8..588f4035f3 100644--- a/packages/studio/src/components/InspectorPanel/common.tsx+++ b/packages/studio/src/components/InspectorPanel/common.tsx@@ -1,4 +1,6 @@import React from 'react';+import {LIGHT_TEXT} from '../../helpers/colors';+import {InlineAction} from '../InlineAction';import {ValidationMessage} from '../NewComposition/ValidationMessage';import type {RenderModalWarning} from '../RenderModal/DataEditor';import {@@ -7,14 +9,68 @@ import {detailLabel,detailRow,detailValue,+ inspectorSectionDivider,resolveLinkStyle,sectionHeader,+ sectionHeaderRow,+ sectionHeaderStart,} from './styles';export const InspectorSectionHeader: React.FC<{readonly children: React.ReactNode;}> = ({children}) => <div style={sectionHeader}>{children}</div>;+const backIcon: React.CSSProperties = {+ alignItems: 'center',+ display: 'flex',+ height: 12,+ justifyContent: 'center',+ width: 12,+};++const BackChevron: React.FC<{+ readonly color: string;+}> = ({color}) => {+ return (+ <svg viewBox="0 0 8 12" style={backIcon}>+ <path+ d="M6 1L2 6L6 11"+ fill="none"+ stroke={color}+ strokeLinecap="round"+ strokeLinejoin="round"+ strokeWidth="1.5"+ />+ </svg>+ );+};++export const InspectorBackHeaderWithDivider: React.FC<{+ readonly children: React.ReactNode;+ readonly disabled: boolean;+ readonly onClick: React.MouseEventHandler<HTMLButtonElement>;+ readonly title: string;+}> = ({children, disabled, onClick, title}) => {+ return (+ <>+ <InspectorSectionHeader>+ <div style={sectionHeaderRow}>+ <div style={sectionHeaderStart}>+ <InlineAction+ disabled={disabled}+ onClick={onClick}+ title={title}+ renderAction={(color) => <BackChevron color={color} />}+ />+ {children}+ </div>+ </div>+ </InspectorSectionHeader>+ <div style={inspectorSectionDivider} />+ </>+ );+};+export const InspectorMessage: React.FC<{readonly children: React.ReactNode;}> = ({children}) => <div style={centeredMessage}>{children}</div>;@@ -29,6 +85,88 @@ export const InspectorDetailRow: React.FC<{</div>);+const inlineLabelButton: React.CSSProperties = {+ alignItems: 'center',+ appearance: 'none',+ backgroundColor: 'transparent',+ border: 'none',+ color: LIGHT_TEXT,+ cursor: 'default',+ display: 'flex',+ fontFamily: 'sans-serif',+ fontSize: 13,+ gap: 8,+ lineHeight: '18px',+ margin: 0,+ padding: '10px 0 0',+};++const inlineLabelButtonDisabled: React.CSSProperties = {+ ...inlineLabelButton,+ opacity: 0.35,+};++const inlineLabelText: React.CSSProperties = {+ color: LIGHT_TEXT,+ fontFamily: 'sans-serif',+ fontSize: 13,+ lineHeight: '18px',+};++const inlineLabelIcon: React.CSSProperties = {+ alignItems: 'center',+ display: 'flex',+ flexShrink: 0,+ height: 13,+ justifyContent: 'center',+ width: 13,+};++export const InspectorInlineAction: React.FC<{+ readonly children: React.ReactNode;+ readonly disabled: boolean;+ readonly onClick: React.MouseEventHandler<HTMLButtonElement>;+ readonly renderIcon: (color: string) => React.ReactNode;+}> = ({children, disabled, onClick, renderIcon}) => {+ const [hovered, setHovered] = React.useState(false);+ const color = hovered && !disabled ? 'white' : LIGHT_TEXT;+ const buttonStyle = React.useMemo(+ (): React.CSSProperties => ({+ ...(disabled ? inlineLabelButtonDisabled : inlineLabelButton),+ color,+ }),+ [color, disabled],+ );+ const textStyle = React.useMemo(+ (): React.CSSProperties => ({+ ...inlineLabelText,+ color,+ }),+ [color],+ );++ const onPointerEnter = React.useCallback(() => {+ setHovered(true);+ }, []);+ const onPointerLeave = React.useCallback(() => {+ setHovered(false);+ }, []);++ return (+ <button+ type="button"+ disabled={disabled}+ style={buttonStyle}+ onClick={onClick}+ onPointerEnter={disabled ? undefined : onPointerEnter}+ onPointerLeave={onPointerLeave}+ >+ <span style={inlineLabelIcon}>{renderIcon(color)}</span>+ <span style={textStyle}>{children}</span>+ </button>+ );+};+export const InspectorDefaultPropsWarnings: React.FC<{readonly warnings: RenderModalWarning[];}> = ({warnings}) => {diff --git a/packages/studio/src/components/InspectorPanel/easing-inspector-selection.ts b/packages/studio/src/components/InspectorPanel/easing-inspector-selection.tsnew file mode 100644index 0000000000..5ffa86ebc1--- /dev/null+++ b/packages/studio/src/components/InspectorPanel/easing-inspector-selection.ts@@ -0,0 +1,29 @@+import type {CanUpdateSequencePropStatusKeyframed} from 'remotion';+import type {SequenceNodePathInfo} from '../../helpers/get-timeline-sequence-sort-key';+import type {TimelineEasingSelection} from '../Timeline/TimelineSelection';++export const getEasingSelectionFromCurrentKeyframes = ({+ keyframeDisplayOffset,+ nodePathInfo,+ propStatus,+ segmentIndex,+}: {+ readonly keyframeDisplayOffset: number;+ readonly nodePathInfo: SequenceNodePathInfo;+ readonly propStatus: CanUpdateSequencePropStatusKeyframed;+ readonly segmentIndex: number;+}): TimelineEasingSelection | null => {+ const fromKeyframe = propStatus.keyframes[segmentIndex];+ const toKeyframe = propStatus.keyframes[segmentIndex + 1];+ if (!fromKeyframe || !toKeyframe) {+ return null;+ }++ return {+ type: 'easing',+ nodePathInfo,+ fromFrame: fromKeyframe.frame + keyframeDisplayOffset,+ toFrame: toKeyframe.frame + keyframeDisplayOffset,+ segmentIndex,+ };+};diff --git a/packages/studio/src/components/InspectorPanel/keyframe-easing-navigator-items.ts b/packages/studio/src/components/InspectorPanel/keyframe-easing-navigator-items.tsnew file mode 100644index 0000000000..018686ba4a--- /dev/null+++ b/packages/studio/src/components/InspectorPanel/keyframe-easing-navigator-items.ts@@ -0,0 +1,65 @@+import type {SequenceNodePathInfo} from '../../helpers/get-timeline-sequence-sort-key';+import type {TimelineSelection} from '../Timeline/TimelineSelection';++export type KeyframeNavigatorItem = {+ readonly selection: Extract<TimelineSelection, {type: 'keyframe'}>;+ readonly type: 'keyframe';+};++export type EasingNavigatorItem = {+ readonly selection: Extract<TimelineSelection, {type: 'easing'}>;+ readonly type: 'easing';+};++export type NavigatorItem = KeyframeNavigatorItem | EasingNavigatorItem;++export type NavigatorKeyframe = {+ readonly frame: number;+};++export const getKeyframeEasingNavigatorItems = ({+ includeEasings,+ keyframes,+ nodePathInfo,+}: {+ readonly includeEasings: boolean;+ readonly keyframes: readonly NavigatorKeyframe[];+ readonly nodePathInfo: SequenceNodePathInfo;+}): NavigatorItem[] => {+ return keyframes.flatMap((keyframe, index): NavigatorItem[] => {+ const keyframeItem: NavigatorItem = {+ type: 'keyframe',+ selection: {+ type: 'keyframe',+ nodePathInfo,+ frame: keyframe.frame,+ },+ };+ const nextKeyframe = keyframes[index + 1];+ if (!includeEasings || !nextKeyframe) {+ return [keyframeItem];+ }++ return [+ keyframeItem,+ {+ type: 'easing',+ selection: {+ type: 'easing',+ nodePathInfo,+ fromFrame: keyframe.frame,+ toFrame: nextKeyframe.frame,+ segmentIndex: index,+ },+ },+ ];+ });+};++export const getNavigatorItemPlayheadFrame = (item: NavigatorItem): number => {+ if (item.type === 'keyframe') {+ return item.selection.frame;+ }++ return Math.round((item.selection.fromFrame + item.selection.toFrame) / 2);+};diff --git a/packages/studio/src/components/InspectorPanel/keyframe-inspector-frame.ts b/packages/studio/src/components/InspectorPanel/keyframe-inspector-frame.tsnew file mode 100644index 0000000000..1b17e985aa--- /dev/null+++ b/packages/studio/src/components/InspectorPanel/keyframe-inspector-frame.ts@@ -0,0 +1,23 @@+export const clampInspectorKeyframeDisplayFrame = ({+ durationInFrames,+ frame,+}: {+ readonly durationInFrames: number;+ readonly frame: number;+}) => {+ if (durationInFrames <= 0) {+ return 0;+ }++ return Math.min(Math.max(Math.round(frame), 0), durationInFrames - 1);+};++export const getInspectorKeyframeSourceFrame = ({+ displayFrame,+ keyframeDisplayOffset,+}: {+ readonly displayFrame: number;+ readonly keyframeDisplayOffset: number;+}) => {+ return displayFrame - keyframeDisplayOffset;+};diff --git a/packages/studio/src/components/InspectorPanel/styles.ts b/packages/studio/src/components/InspectorPanel/styles.tsindex 1df2f736f7..40314c0738 100644--- a/packages/studio/src/components/InspectorPanel/styles.ts+++ b/packages/studio/src/components/InspectorPanel/styles.ts@@ -36,6 +36,13 @@ export const inspectorSectionDivider: React.CSSProperties = {borderBottom: `1px solid ${LINE_COLOR}`,};+export const sequenceHeaderDivider: React.CSSProperties = {+ backgroundColor: LINE_COLOR,+ flexShrink: 0,+ height: 1,+ margin: '4px 0',+};+export const sectionHeader: React.CSSProperties = {color: LIGHT_TEXT,fontSize: 12,diff --git a/packages/studio/src/components/InspectorSequenceSection.tsx b/packages/studio/src/components/InspectorSequenceSection.tsxindex 9736d71277..2c670e569c 100644--- a/packages/studio/src/components/InspectorSequenceSection.tsx+++ b/packages/studio/src/components/InspectorSequenceSection.tsx@@ -2,7 +2,7 @@ import React, {useCallback, useContext, useMemo, useState} from 'react';import type {TSequence} from 'remotion';import type {CodePosition} from '../error-overlay/react-overlay/utils/get-source-map';import {StudioServerConnectionCtx} from '../helpers/client-id';-import {LIGHT_TEXT, LINE_COLOR} from '../helpers/colors';+import {LIGHT_TEXT} from '../helpers/colors';import type {SequenceNodePathInfo} from '../helpers/get-timeline-sequence-sort-key';import {SCHEMA_FIELD_GROUPS,@@ -14,7 +14,11 @@ import {import {Plus} from '../icons/plus';import {ModalsContext} from '../state/modals';import {InlineAction} from './InlineAction';-import {sectionHeaderRow, sectionHeaderTitle} from './InspectorPanel/styles';+import {+ sectionHeaderRow,+ sectionHeaderTitle,+ sequenceHeaderDivider,+} from './InspectorPanel/styles';import {TimelineExpandedRow} from './Timeline/TimelineExpandedRow';import {getTimelineSelectionFromNodePathInfo,@@ -39,15 +43,8 @@ const emptyState: React.CSSProperties = {padding: '0 12px 8px',};-const divider: React.CSSProperties = {- backgroundColor: LINE_COLOR,- flexShrink: 0,- height: 1,- margin: '4px 0',-};-const controlsEffectsDivider: React.CSSProperties = {- ...divider,+ ...sequenceHeaderDivider,margin: '8px 0 4px',};@@ -259,7 +256,7 @@ export const InspectorSequenceSection: React.FC<{if (controlRows.length === 0 && !showEffectsSection) {return (<div style={container}>- <div style={divider} />+ <div style={sequenceHeaderDivider} /><div style={emptyState}>No schema</div></div>);@@ -267,7 +264,7 @@ export const InspectorSequenceSection: React.FC<{return (<div style={container}>- <div style={divider} />+ <div style={sequenceHeaderDivider} />{controlRows.length > 0 ? (<TimelineSelectionOrderProvider items={controlSelectableItems}>{controlGroups.map((group, i) => (diff --git a/packages/studio/src/components/Timeline/EasingEditorModal.tsx b/packages/studio/src/components/Timeline/EasingEditorModal.tsxindex 7ed0ee5ebe..90af095b04 100644--- a/packages/studio/src/components/Timeline/EasingEditorModal.tsx+++ b/packages/studio/src/components/Timeline/EasingEditorModal.tsx@@ -137,8 +137,8 @@ const inlineContainer: React.CSSProperties = {const segmentedControlWrapper: React.CSSProperties = {display: 'flex',justifyContent: 'flex-start',+ marginTop: 8,padding: `0 ${INSPECTOR_PANEL_HORIZONTAL_PADDING}px`,- marginBottom: 10,};const presetButtonsWrapper: React.CSSProperties = {@@ -150,6 +150,11 @@ const presetButtonsWrapper: React.CSSProperties = {padding: `0 ${INSPECTOR_PANEL_HORIZONTAL_PADDING}px`,};+const inspectorPresetButtonsWrapper: React.CSSProperties = {+ ...presetButtonsWrapper,+ padding: `8px ${INSPECTOR_PANEL_HORIZONTAL_PADDING}px 0`,+};+const presetButtonBase: React.CSSProperties = {alignItems: 'center',backgroundColor: INPUT_BACKGROUND,@@ -1136,21 +1141,20 @@ export const EasingEditor: React.FC<{}),[],);+ const modeSwitcher = (+ <div style={segmentedControlWrapper}>+ <SegmentedControl items={modeItems} needsWrapping={false} />+ </div>+ );return (<div style={inlineContainer}>- {renderHeader ? (- renderHeader(modeItems)- ) : (- <div style={segmentedControlWrapper}>- <SegmentedControl- items={modeItems}- needsWrapping={false}- size="compact"- />- </div>- )}- <div style={presetButtonsWrapper}>+ {renderHeader ? renderHeader(modeItems) : null}+ <div+ style={+ renderHeader ? inspectorPresetButtonsWrapper : presetButtonsWrapper+ }+ >{EDITOR_EASING_PRESETS.map((preset) => (<EasingPresetButtonkey={preset.id}@@ -1216,6 +1220,7 @@ export const EasingEditor: React.FC<{onPointerDown={(event) => onHandlePointerDown(1, event)}/></svg>+ {modeSwitcher}<div style={coordinatesGrid}><div style={coordinateRow}><div style={coordinateLabel}>X1</div>@@ -1325,6 +1330,7 @@ export const EasingEditor: React.FC<{<circle cx={xToSvg(0)} cy={yToSvg(0)} r={4} fill="white" /><circle cx={xToSvg(1)} cy={yToSvg(1)} r={4} fill="white" /></svg>+ {modeSwitcher}<div style={coordinatesGrid}><div style={coordinateRow}><div style={coordinateLabel}>Damping</div>diff --git a/packages/studio/src/components/Timeline/TimelineDeleteKeybindings.tsx b/packages/studio/src/components/Timeline/TimelineDeleteKeybindings.tsxindex 5b7e9b2ea7..3024972496 100644--- a/packages/studio/src/components/Timeline/TimelineDeleteKeybindings.tsx+++ b/packages/studio/src/components/Timeline/TimelineDeleteKeybindings.tsx@@ -1,6 +1,6 @@import {LINEAR_KEYFRAME_EASING} from '@remotion/studio-shared';import type React from 'react';-import {useContext, useEffect} from 'react';+import {useContext, useEffect, useRef} from 'react';import {Internals} from 'remotion';import {StudioServerConnectionCtx} from '../../helpers/client-id';import {useKeybinding} from '../../helpers/use-keybinding';@@ -39,6 +39,9 @@ export const TimelineDeleteKeybindings: React.FC = () => {const {canSelect} = useTimelineSelection();const currentSelection = useCurrentTimelineSelectionStateAsRef();const confirm = useConfirmationDialog();+ const timelinePosition = Internals.Timeline.useTimelinePosition();+ const timelinePositionRef = useRef(timelinePosition);+ timelinePositionRef.current = timelinePosition;useEffect(() => {if (!canSelect || previewServerState.type !== 'connected') {@@ -81,8 +84,13 @@ export const TimelineDeleteKeybindings: React.FC = () => {deletePromise.then((deleted) => {if (deleted) {- const nextSelection =- getTimelineSelectionAfterDeletingItems(selectedItems);+ const nextSelection = getTimelineSelectionAfterDeletingItems({+ selections: selectedItems,+ sequences,+ overrideIdsToNodePaths: overrideIdToNodePathMappings,+ propStatuses,+ timelinePosition: timelinePositionRef.current,+ });if (nextSelection.length === 0) {clearSelection();} else {@@ -186,6 +194,7 @@ export const TimelineDeleteKeybindings: React.FC = () => {sequencesRef,setGuidesList,setPropStatuses,+ timelinePositionRef,]);return null;diff --git a/packages/studio/src/components/Timeline/TimelineEffectPropItem.tsx b/packages/studio/src/components/Timeline/TimelineEffectPropItem.tsxindex 3138554277..01f2a18e2b 100644--- a/packages/studio/src/components/Timeline/TimelineEffectPropItem.tsx+++ b/packages/studio/src/components/Timeline/TimelineEffectPropItem.tsx@@ -8,7 +8,7 @@ import type {CanUpdateSequencePropStatusKeyframed,SequencePropsSubscriptionKey,} from 'remotion';-import {Internals} from 'remotion';+import {Internals, useVideoConfig} from 'remotion';import type {CodePosition} from '../../error-overlay/react-overlay/utils/get-source-map';import {StudioServerConnectionCtx} from '../../helpers/client-id';import type {SequenceNodePathInfo} from '../../helpers/get-timeline-sequence-sort-key';@@ -18,6 +18,7 @@ import {callApi} from '../call-api';import {ContextMenu} from '../ContextMenu';import type {ComboboxValue} from '../NewComposition/ComboBox';import {callAddEffectKeyframe} from './call-add-keyframe';+import {getAnimationItemSelectionForSourceFrame} from './get-animation-item-selection-for-frame';import {getComputedStatusLabel} from './get-timeline-keyframes';import {saveEffectProp} from './save-effect-prop';import {enqueueSavePropChange} from './save-prop-queue';@@ -33,7 +34,11 @@ import {TimelineKeyframedValue} from './TimelineKeyframedValue';import {TimelineLayerEyeSpacer} from './TimelineLayerEye';import {TimelineRowChrome} from './TimelineRowChrome';import {TimelineFieldValue, UnsupportedStatus} from './TimelineSchemaField';-import {useTimelineRowSelection} from './TimelineSelection';+import {+ useTimelineRowSelection,+ useTimelineSelection,+} from './TimelineSelection';+import {canEditEasingForInterpolationFunction} from './update-selected-easing';const fieldRowBase: React.CSSProperties = {};@@ -350,6 +355,9 @@ export const TimelineEffectPropItem: React.FC<{Internals.VisualModeDragOverridesContext,);const selection = useTimelineRowSelection(nodePathInfo);+ const {selectItems} = useTimelineSelection();+ const setFrame = Internals.useTimelineSetFrame();+ const videoConfig = useVideoConfig();const timelinePosition = Internals.Timeline.useTimelinePosition();const sourceFrame = timelinePosition - keyframeDisplayOffset;const style = useMemo(() => {@@ -530,6 +538,101 @@ export const TimelineEffectPropItem: React.FC<{propStatus,]);+ const seekToDisplayFrame = useCallback(+ (frame: number) => {+ setFrame((current) => {+ const next = {...current, [videoConfig.id]: frame};+ Internals.persistCurrentFrame(next);+ return next;+ });+ },+ [setFrame, videoConfig.id],+ );++ const onPropertyDoubleClick = useCallback<+ React.MouseEventHandler<HTMLDivElement>+ >(+ (event) => {+ if (propStatus === null || propStatus.status === 'computed') {+ return;+ }++ const keyframeSelection = {+ type: 'keyframe' as const,+ nodePathInfo,+ frame: sourceFrame + keyframeDisplayOffset,+ };++ if (propStatus.status === 'static') {+ if (!keyframable || previewServerState.type !== 'connected') {+ return;+ }++ const value = Internals.getEffectiveVisualModeValue({+ propStatus,+ dragOverrideValue,+ frame: sourceFrame,+ defaultValue: field.fieldSchema.default,+ shouldResortToDefaultValueIfUndefined: true,+ });++ event.stopPropagation();+ callAddEffectKeyframe({+ fileName: validatedLocation.source,+ nodePath,+ effectIndex: field.effectIndex,+ fieldKey: field.key,+ sourceFrame,+ value,+ schema: field.effectSchema,+ setPropStatuses,+ clientId: previewServerState.clientId,+ }).catch(() => undefined);+ selectItems([keyframeSelection], {reveal: true});+ seekToDisplayFrame(keyframeSelection.frame);+ return;+ }++ const targetSelection = getAnimationItemSelectionForSourceFrame({+ includeEasings: canEditEasingForInterpolationFunction(+ propStatus.interpolationFunction,+ ),+ keyframeDisplayOffset,+ keyframes: propStatus.keyframes,+ nodePathInfo,+ sourceFrame,+ });++ if (targetSelection === null) {+ return;+ }++ event.stopPropagation();+ selectItems([targetSelection], {reveal: true});+ if (targetSelection.type === 'keyframe') {+ seekToDisplayFrame(targetSelection.frame);+ }+ },+ [+ dragOverrideValue,+ field.effectIndex,+ field.effectSchema,+ field.fieldSchema.default,+ field.key,+ keyframeDisplayOffset,+ keyframable,+ nodePath,+ nodePathInfo,+ previewServerState,+ propStatus,+ seekToDisplayFrame,+ selectItems,+ setPropStatuses,+ sourceFrame,+ validatedLocation.source,+ ],+ );+const row = (<TimelineRowChromedepth={rowDepth}@@ -541,6 +644,7 @@ export const TimelineEffectPropItem: React.FC<{selectable={selection.selectable}selectionItem={selection.selectionItem}onSelect={selection.onSelect}+ onDoubleClick={onPropertyDoubleClick}showSelectedBackgroundcontainsSelection={false}outerHeight={null}diff --git a/packages/studio/src/components/Timeline/TimelineKeyframeControls.tsx b/packages/studio/src/components/Timeline/TimelineKeyframeControls.tsxindex dae1f4270d..36f238695f 100644--- a/packages/studio/src/components/Timeline/TimelineKeyframeControls.tsx+++ b/packages/studio/src/components/Timeline/TimelineKeyframeControls.tsx@@ -32,6 +32,7 @@ import {type DeleteEffectKeyframeChange,type DeleteSequenceKeyframeChange,} from './call-delete-keyframe';+import {getEasingSelectionAfterKeyframeDelete} from './get-easing-selection-after-keyframe-delete';import {getNextKeyframeDisplayFrame,getPreviousKeyframeDisplayFrame,@@ -46,6 +47,7 @@ import {useTimelineSelection,type TimelineSelection,} from './TimelineSelection';+import {canEditEasingForInterpolationFunction} from './update-selected-easing';const controlsContainerStyle: React.CSSProperties = {alignItems: 'center',@@ -466,6 +468,7 @@ export const TimelineKeyframeControls: React.FC<{schema,effectIndex,nodePathInfo,+ mode = 'timeline',}) => {const videoConfig = useVideoConfig();const timelinePosition = Internals.Timeline.useTimelinePosition();@@ -476,7 +479,7 @@ export const TimelineKeyframeControls: React.FC<{Internals.VisualModeDragOverridesContext,);const {previewServerState} = useContext(StudioServerConnectionCtx);- const {selectedItems} = useTimelineSelection();+ const {selectedItems, selectItems} = useTimelineSelection();const tracks = useTimelineKeyframeTracks();const clientId =@@ -655,10 +658,28 @@ export const TimelineKeyframeControls: React.FC<{}if (hasKeyframeAtCurrentFrame) {- const deleteChanges = keyframeToggleTargets.flatMap((target) => {+ const deleteTargets = keyframeToggleTargets.flatMap((target) => {const change = getDeleteChange(target);- return change === null ? [] : [change];+ return change === null ? [] : [{target, change}];});+ const singleDeleteTarget = deleteTargets[0];+ const easingSelection =+ deleteTargets.length === 1 &&+ singleDeleteTarget &&+ isKeyframedStatus(singleDeleteTarget.target.propStatus) &&+ canEditEasingForInterpolationFunction(+ singleDeleteTarget.target.propStatus.interpolationFunction,+ )+ ? getEasingSelectionAfterKeyframeDelete({+ deletedSourceFrames: [singleDeleteTarget.target.sourceFrame],+ keyframeDisplayOffset:+ singleDeleteTarget.target.keyframeDisplayOffset,+ nodePathInfo: singleDeleteTarget.target.nodePathInfo,+ propStatus: singleDeleteTarget.target.propStatus,+ timelinePosition,+ })+ : null;+ const deleteChanges = deleteTargets.map(({change}) => change);await callDeleteKeyframes({sequenceKeyframes: deleteChanges.filter((change): change is DeleteSequenceKeyframeChange =>@@ -671,35 +692,53 @@ export const TimelineKeyframeControls: React.FC<{setPropStatuses,clientId,});+ if (mode === 'timeline' && easingSelection !== null) {+ selectItems([easingSelection], {reveal: true});+ }+return;}const addChanges = keyframeToggleTargets.flatMap((target) => {const change = getAddChange(target);- return change === null ? [] : [change];+ return change === null ? [] : [{target, change}];});if (addChanges.length === 0) {return;}+ const addChangeValues = addChanges.map(({change}) => change);await callAddKeyframes({- sequenceKeyframes: addChanges.filter(+ sequenceKeyframes: addChangeValues.filter((change): change is AddSequenceKeyframeChange =>!hasEffectIndex(change),),- effectKeyframes: addChanges.filter(+ effectKeyframes: addChangeValues.filter((change): change is AddEffectKeyframeChange => hasEffectIndex(change),),setPropStatuses,clientId,});+ if (mode === 'timeline') {+ selectItems(+ addChanges.map(({target}) => ({+ type: 'keyframe' as const,+ nodePathInfo: target.nodePathInfo,+ frame: target.sourceFrame + target.keyframeDisplayOffset,+ })),+ {reveal: true},+ );+ }},[canToggleKeyframe,clientId,hasKeyframeAtCurrentFrame,keyframeToggleTargets,+ mode,+ selectItems,setPropStatuses,+ timelinePosition,],);diff --git a/packages/studio/src/components/Timeline/TimelineKeyframeEasingLine.tsx b/packages/studio/src/components/Timeline/TimelineKeyframeEasingLine.tsxindex e88a74a66d..6bfb42f684 100644--- a/packages/studio/src/components/Timeline/TimelineKeyframeEasingLine.tsx+++ b/packages/studio/src/components/Timeline/TimelineKeyframeEasingLine.tsx@@ -48,6 +48,24 @@ const easingLine: React.CSSProperties = {transform: 'translateY(-50%)',};+export const getTimelineKeyframeEasingLineStyle = (+ selected: boolean,+): React.CSSProperties => ({+ ...easingLine,+ outline: selected ? `1px solid ${BLUE}` : undefined,+});++export const TimelineKeyframeEasingLineVisual: React.FC<{+ readonly selected: boolean;+}> = ({selected}) => {+ const lineStyle = useMemo(+ () => getTimelineKeyframeEasingLineStyle(selected),+ [selected],+ );++ return <div style={lineStyle} />;+};+const TimelineKeyframeEasingLineUnmemoized: React.FC<{readonly fromFrame: number;readonly toFrame: number;@@ -197,14 +215,6 @@ const TimelineKeyframeEasingLineUnmemoized: React.FC<{videoConfig.durationInFrames,]);- const lineStyle = useMemo(- (): React.CSSProperties => ({- ...easingLine,- outline: selected ? `1px solid ${BLUE}` : undefined,- }),- [selected],- );-const onPointerDown = useTimelineEasingKeyframeDrag({onSelect,selectable,@@ -227,7 +237,7 @@ const TimelineKeyframeEasingLineUnmemoized: React.FC<{aria-label={`Select easing from frame ${fromFrame} to ${toFrame}`}onPointerDown={selectable ? onPointerDown : undefined}>- <div style={lineStyle} />+ <TimelineKeyframeEasingLineVisual selected={selected} /></button><ContextMenuForTargettriggerRef={buttonRef}diff --git a/packages/studio/src/components/Timeline/TimelineSequencePropItem.tsx b/packages/studio/src/components/Timeline/TimelineSequencePropItem.tsxindex d64de86219..ca90b4094e 100644--- a/packages/studio/src/components/Timeline/TimelineSequencePropItem.tsx+++ b/packages/studio/src/components/Timeline/TimelineSequencePropItem.tsx@@ -4,10 +4,10 @@ import type {CanUpdateSequencePropStatus,CanUpdateSequencePropStatusKeyframed,CanUpdateSequencePropStatusStatic,- SequencePropsSubscriptionKey,InteractivitySchema,+ SequencePropsSubscriptionKey,} from 'remotion';-import {Internals} from 'remotion';+import {Internals, useVideoConfig} from 'remotion';import type {CodePosition} from '../../error-overlay/react-overlay/utils/get-source-map';import {StudioServerConnectionCtx} from '../../helpers/client-id';import type {SequenceNodePathInfo} from '../../helpers/get-timeline-sequence-sort-key';@@ -20,6 +20,7 @@ import {ModalsContext} from '../../state/modals';import {ContextMenu} from '../ContextMenu';import type {ComboboxValue} from '../NewComposition/ComboBox';import {callAddSequenceKeyframe} from './call-add-keyframe';+import {getAnimationItemSelectionForSourceFrame} from './get-animation-item-selection-for-frame';import {saveSequenceProps} from './save-sequence-prop';import {timelineFieldValueColumnStyle} from './timeline-field-row-layout';import {TimelineExpandArrowSpacer} from './TimelineExpandArrowButton';@@ -36,7 +37,11 @@ import {TimelineFieldValue,TimelineNonEditableStatus,} from './TimelineSchemaField';-import {useTimelineRowSelection} from './TimelineSelection';+import {+ useTimelineRowSelection,+ useTimelineSelection,+} from './TimelineSelection';+import {canEditEasingForInterpolationFunction} from './update-selected-easing';const fieldRowBase: React.CSSProperties = {};@@ -300,6 +305,9 @@ export const TimelineSequencePropItem: React.FC<{const {previewServerState} = useContext(StudioServerConnectionCtx);const {setSelectedModal} = useContext(ModalsContext);const selection = useTimelineRowSelection(nodePathInfo);+ const {selectItems} = useTimelineSelection();+ const setFrame = Internals.useTimelineSetFrame();+ const videoConfig = useVideoConfig();const timelinePosition = Internals.Timeline.useTimelinePosition();const sourceFrame = timelinePosition - keyframeDisplayOffset;@@ -477,6 +485,99 @@ export const TimelineSequencePropItem: React.FC<{previewServerState,]);+ const seekToDisplayFrame = useCallback(+ (frame: number) => {+ setFrame((current) => {+ const next = {...current, [videoConfig.id]: frame};+ Internals.persistCurrentFrame(next);+ return next;+ });+ },+ [setFrame, videoConfig.id],+ );++ const onPropertyDoubleClick = useCallback<+ React.MouseEventHandler<HTMLDivElement>+ >(+ (event) => {+ if (propStatus === null || propStatus.status === 'computed') {+ return;+ }++ const keyframeSelection = {+ type: 'keyframe' as const,+ nodePathInfo,+ frame: sourceFrame + keyframeDisplayOffset,+ };++ if (propStatus.status === 'static') {+ if (!keyframable || previewServerState.type !== 'connected') {+ return;+ }++ const value = Internals.getEffectiveVisualModeValue({+ propStatus,+ dragOverrideValue,+ frame: sourceFrame,+ defaultValue: field.fieldSchema.default,+ shouldResortToDefaultValueIfUndefined: true,+ });++ event.stopPropagation();+ callAddSequenceKeyframe({+ fileName: validatedLocation.source,+ nodePath,+ fieldKey: field.key,+ sourceFrame,+ value,+ schema,+ setPropStatuses,+ clientId: previewServerState.clientId,+ }).catch(() => undefined);+ selectItems([keyframeSelection], {reveal: true});+ seekToDisplayFrame(keyframeSelection.frame);+ return;+ }++ const targetSelection = getAnimationItemSelectionForSourceFrame({+ includeEasings: canEditEasingForInterpolationFunction(+ propStatus.interpolationFunction,+ ),+ keyframeDisplayOffset,+ keyframes: propStatus.keyframes,+ nodePathInfo,+ sourceFrame,+ });++ if (targetSelection === null) {+ return;+ }++ event.stopPropagation();+ selectItems([targetSelection], {reveal: true});+ if (targetSelection.type === 'keyframe') {+ seekToDisplayFrame(targetSelection.frame);+ }+ },+ [+ dragOverrideValue,+ field.fieldSchema.default,+ field.key,+ keyframeDisplayOffset,+ keyframable,+ nodePath,+ nodePathInfo,+ previewServerState,+ propStatus,+ schema,+ seekToDisplayFrame,+ selectItems,+ setPropStatuses,+ sourceFrame,+ validatedLocation.source,+ ],+ );+if (propStatus === null) {return null;}@@ -492,6 +593,7 @@ export const TimelineSequencePropItem: React.FC<{selectable={selection.selectable}selectionItem={selection.selectionItem}onSelect={selection.onSelect}+ onDoubleClick={onPropertyDoubleClick}showSelectedBackgroundcontainsSelection={false}outerHeight={null}diff --git a/packages/studio/src/components/Timeline/delete-selected-timeline-item.ts b/packages/studio/src/components/Timeline/delete-selected-timeline-item.tsindex c67915f42c..2c776a8df2 100644--- a/packages/studio/src/components/Timeline/delete-selected-timeline-item.ts+++ b/packages/studio/src/components/Timeline/delete-selected-timeline-item.ts@@ -1,4 +1,5 @@-import type {OverrideIdToNodePaths, TSequence} from 'remotion';+import type {OverrideIdToNodePaths, PropStatuses, TSequence} from 'remotion';+import {Internals} from 'remotion';import type {SequenceNodePathInfo} from '../../helpers/get-timeline-sequence-sort-key';import {callApi} from '../call-api';import type {ConfirmationDialogFunction} from '../ConfirmationDialog-types';@@ -7,11 +8,15 @@ import {deleteSelectedKeyframe,deleteSelectedKeyframes,} from './delete-selected-keyframe';+import {findTrackForNodePathInfo} from './find-track-for-node-path-info';+import {getEasingSelectionAfterKeyframeDelete} from './get-easing-selection-after-keyframe-delete';+import {parseKeyframeFieldFromNodePath} from './parse-keyframe-field-from-node-path';import type {SetPropStatuses} from './save-sequence-prop';import {getTimelineSelectionKey,type TimelineSelection,} from './TimelineSelection';+import {canEditEasingForInterpolationFunction} from './update-selected-easing';const confirmDeletingDuplicatedSequences = (nodePathInfos: SequenceNodePathInfo[],@@ -239,9 +244,131 @@ const getSequenceSelectionAfterDeletingEffect = (};};-export const getTimelineSelectionAfterDeletingItems = (- selections: readonly TimelineSelection[],-): readonly TimelineSelection[] => {+const getEasingSelectionAfterDeletingKeyframes = ({+ selections,+ sequences,+ overrideIdsToNodePaths,+ propStatuses,+ timelinePosition,+}: {+ readonly selections: readonly TimelineSelection[];+ readonly sequences: TSequence[] | undefined;+ readonly overrideIdsToNodePaths: OverrideIdToNodePaths | undefined;+ readonly propStatuses: PropStatuses | undefined;+ readonly timelinePosition: number | undefined;+}): TimelineSelection | null => {+ if (+ sequences === undefined ||+ overrideIdsToNodePaths === undefined ||+ propStatuses === undefined ||+ timelinePosition === undefined+ ) {+ return null;+ }++ const keyframeSelections = selections.filter(isKeyframeSelection);+ if (keyframeSelections.length !== 1) {+ return null;+ }++ const [selection] = keyframeSelections;+ if (!selection) {+ return null;+ }++ const field = parseKeyframeFieldFromNodePath(+ selection.nodePathInfo.auxiliaryKeys,+ );+ if (field === null) {+ return null;+ }++ const track = findTrackForNodePathInfo({+ sequences,+ overrideIdsToNodePaths,+ nodePathInfo: selection.nodePathInfo,+ });+ if (!track || !track.sequence.controls) {+ return null;+ }++ const nodePath = selection.nodePathInfo.sequenceSubscriptionKey;+ const sourceFrame = selection.frame - track.keyframeDisplayOffset;++ if (field.type === 'sequence') {+ const sequencePropStatus = Internals.getPropStatusesCtx(+ propStatuses,+ nodePath,+ )?.[field.fieldKey];+ if (+ sequencePropStatus?.status !== 'keyframed' ||+ !canEditEasingForInterpolationFunction(+ sequencePropStatus.interpolationFunction,+ )+ ) {+ return null;+ }++ return getEasingSelectionAfterKeyframeDelete({+ deletedSourceFrames: [sourceFrame],+ keyframeDisplayOffset: track.keyframeDisplayOffset,+ nodePathInfo: selection.nodePathInfo,+ propStatus: sequencePropStatus,+ timelinePosition,+ });+ }++ const effectStatus = Internals.getEffectPropStatusesCtx({+ propStatuses,+ nodePath,+ effectIndex: field.effectIndex,+ });+ const effectPropStatus =+ effectStatus.type === 'can-update-effect'+ ? effectStatus.props[field.fieldKey]+ : null;+ if (+ effectPropStatus?.status !== 'keyframed' ||+ !canEditEasingForInterpolationFunction(+ effectPropStatus.interpolationFunction,+ )+ ) {+ return null;+ }++ return getEasingSelectionAfterKeyframeDelete({+ deletedSourceFrames: [sourceFrame],+ keyframeDisplayOffset: track.keyframeDisplayOffset,+ nodePathInfo: selection.nodePathInfo,+ propStatus: effectPropStatus,+ timelinePosition,+ });+};++export const getTimelineSelectionAfterDeletingItems = ({+ selections,+ sequences,+ overrideIdsToNodePaths,+ propStatuses,+ timelinePosition,+}: {+ readonly selections: readonly TimelineSelection[];+ readonly sequences?: TSequence[];+ readonly overrideIdsToNodePaths?: OverrideIdToNodePaths;+ readonly propStatuses?: PropStatuses;+ readonly timelinePosition?: number;+}): readonly TimelineSelection[] => {+ const easingSelection = getEasingSelectionAfterDeletingKeyframes({+ selections,+ sequences,+ overrideIdsToNodePaths,+ propStatuses,+ timelinePosition,+ });+ if (easingSelection !== null) {+ return [easingSelection];+ }+const nextSelections = new Map<string, TimelineSelection>();for (const selection of selections) {diff --git a/packages/studio/src/components/Timeline/get-animation-item-selection-for-frame.ts b/packages/studio/src/components/Timeline/get-animation-item-selection-for-frame.tsnew file mode 100644index 0000000000..886626d559--- /dev/null+++ b/packages/studio/src/components/Timeline/get-animation-item-selection-for-frame.ts@@ -0,0 +1,83 @@+import type {SequenceNodePathInfo} from '../../helpers/get-timeline-sequence-sort-key';+import type {TimelineSelection} from './TimelineSelection';++type AnimationItemSelection = Extract<+ TimelineSelection,+ {type: 'keyframe'} | {type: 'easing'}+>;++type AnimationKeyframe = {+ readonly frame: number;+};++const getKeyframeSelection = ({+ keyframe,+ keyframeDisplayOffset,+ nodePathInfo,+}: {+ readonly keyframe: AnimationKeyframe;+ readonly keyframeDisplayOffset: number;+ readonly nodePathInfo: SequenceNodePathInfo;+}): AnimationItemSelection => {+ return {+ type: 'keyframe',+ nodePathInfo,+ frame: keyframe.frame + keyframeDisplayOffset,+ };+};++export const getAnimationItemSelectionForSourceFrame = ({+ includeEasings,+ keyframeDisplayOffset,+ keyframes,+ nodePathInfo,+ sourceFrame,+}: {+ readonly includeEasings: boolean;+ readonly keyframeDisplayOffset: number;+ readonly keyframes: readonly AnimationKeyframe[];+ readonly nodePathInfo: SequenceNodePathInfo;+ readonly sourceFrame: number;+}): AnimationItemSelection | null => {+ const firstKeyframe = keyframes[0];+ if (!firstKeyframe) {+ return null;+ }++ for (let i = 0; i < keyframes.length; i++) {+ const keyframe = keyframes[i];+ if (keyframe.frame === sourceFrame) {+ return getKeyframeSelection({+ keyframe,+ keyframeDisplayOffset,+ nodePathInfo,+ });+ }++ const nextKeyframe = keyframes[i + 1];+ if (!nextKeyframe) {+ continue;+ }++ if (sourceFrame > keyframe.frame && sourceFrame < nextKeyframe.frame) {+ if (!includeEasings) {+ return null;+ }++ return {+ type: 'easing',+ nodePathInfo,+ fromFrame: keyframe.frame + keyframeDisplayOffset,+ toFrame: nextKeyframe.frame + keyframeDisplayOffset,+ segmentIndex: i,+ };+ }+ }++ const lastKeyframe = keyframes[keyframes.length - 1];+ return getKeyframeSelection({+ keyframe: sourceFrame < firstKeyframe.frame ? firstKeyframe : lastKeyframe,+ keyframeDisplayOffset,+ nodePathInfo,+ });+};diff --git a/packages/studio/src/components/Timeline/get-easing-selection-after-keyframe-delete.ts b/packages/studio/src/components/Timeline/get-easing-selection-after-keyframe-delete.tsnew file mode 100644index 0000000000..664ba9b536--- /dev/null+++ b/packages/studio/src/components/Timeline/get-easing-selection-after-keyframe-delete.ts@@ -0,0 +1,43 @@+import type {CanUpdateSequencePropStatusKeyframed} from 'remotion';+import type {SequenceNodePathInfo} from '../../helpers/get-timeline-sequence-sort-key';+import type {TimelineEasingSelection} from './TimelineSelection';++export const getEasingSelectionAfterKeyframeDelete = ({+ deletedSourceFrames,+ keyframeDisplayOffset,+ nodePathInfo,+ propStatus,+ timelinePosition,+}: {+ readonly deletedSourceFrames: readonly number[];+ readonly keyframeDisplayOffset: number;+ readonly nodePathInfo: SequenceNodePathInfo;+ readonly propStatus: CanUpdateSequencePropStatusKeyframed;+ readonly timelinePosition: number;+}): TimelineEasingSelection | null => {+ const deletedSourceFrameSet = new Set(deletedSourceFrames);+ const remainingKeyframes = propStatus.keyframes.filter(+ (keyframe) => !deletedSourceFrameSet.has(keyframe.frame),+ );+ const sourceFrame = timelinePosition - keyframeDisplayOffset;++ for (let i = 0; i < remainingKeyframes.length - 1; i++) {+ const keyframe = remainingKeyframes[i];+ const nextKeyframe = remainingKeyframes[i + 1];+ if (!keyframe || !nextKeyframe) {+ continue;+ }++ if (sourceFrame > keyframe.frame && sourceFrame < nextKeyframe.frame) {+ return {+ type: 'easing',+ nodePathInfo,+ fromFrame: keyframe.frame + keyframeDisplayOffset,+ toFrame: nextKeyframe.frame + keyframeDisplayOffset,+ segmentIndex: i,+ };+ }+ }++ return null;+};diff --git a/packages/studio/src/components/Timeline/update-selected-easing.ts b/packages/studio/src/components/Timeline/update-selected-easing.tsindex e98b7ea8d7..07fb0ed6d0 100644--- a/packages/studio/src/components/Timeline/update-selected-easing.ts+++ b/packages/studio/src/components/Timeline/update-selected-easing.ts@@ -47,7 +47,7 @@ export type SelectedEasingUpdate =readonly propStatus: CanUpdateSequencePropStatusKeyframed;};-const canEditEasingForInterpolationFunction = (+export const canEditEasingForInterpolationFunction = (interpolationFunction: string,): boolean =>interpolationFunction === 'interpolate' ||diff --git a/packages/studio/src/test/animation-item-selection-for-frame.test.ts b/packages/studio/src/test/animation-item-selection-for-frame.test.tsnew file mode 100644index 0000000000..1720c653cd--- /dev/null+++ b/packages/studio/src/test/animation-item-selection-for-frame.test.ts@@ -0,0 +1,91 @@+import {expect, test} from 'bun:test';+import {getAnimationItemSelectionForSourceFrame} from '../components/Timeline/get-animation-item-selection-for-frame';+import type {SequenceNodePathInfo} from '../helpers/get-timeline-sequence-sort-key';++const nodePathInfo = {+ sequenceSubscriptionKey: {+ absolutePath: '/tmp/test.tsx',+ },+ auxiliaryKeys: ['controls', 'radius'],+ index: 0,+ numberOfSequencesWithThisNodePath: 1,+ supportsEffects: true,+} as SequenceNodePathInfo;++test('selects the keyframe when the playhead is on a keyframe', () => {+ expect(+ getAnimationItemSelectionForSourceFrame({+ includeEasings: true,+ keyframeDisplayOffset: 100,+ keyframes: [{frame: 10}, {frame: 30}],+ nodePathInfo,+ sourceFrame: 10,+ }),+ ).toEqual({+ type: 'keyframe',+ nodePathInfo,+ frame: 110,+ });+});++test('selects the easing when the playhead is between two keyframes', () => {+ expect(+ getAnimationItemSelectionForSourceFrame({+ includeEasings: true,+ keyframeDisplayOffset: 100,+ keyframes: [{frame: 10}, {frame: 30}, {frame: 50}],+ nodePathInfo,+ sourceFrame: 35,+ }),+ ).toEqual({+ type: 'easing',+ nodePathInfo,+ fromFrame: 130,+ toFrame: 150,+ segmentIndex: 1,+ });+});++test('does not select an easing when easing editing is unavailable', () => {+ expect(+ getAnimationItemSelectionForSourceFrame({+ includeEasings: false,+ keyframeDisplayOffset: 100,+ keyframes: [{frame: 10}, {frame: 30}],+ nodePathInfo,+ sourceFrame: 20,+ }),+ ).toBe(null);+});++test('selects the first keyframe before the keyframe chain', () => {+ expect(+ getAnimationItemSelectionForSourceFrame({+ includeEasings: true,+ keyframeDisplayOffset: 100,+ keyframes: [{frame: 10}, {frame: 30}],+ nodePathInfo,+ sourceFrame: 0,+ }),+ ).toEqual({+ type: 'keyframe',+ nodePathInfo,+ frame: 110,+ });+});++test('selects the last keyframe after the keyframe chain', () => {+ expect(+ getAnimationItemSelectionForSourceFrame({+ includeEasings: true,+ keyframeDisplayOffset: 100,+ keyframes: [{frame: 10}, {frame: 30}],+ nodePathInfo,+ sourceFrame: 40,+ }),+ ).toEqual({+ type: 'keyframe',+ nodePathInfo,+ frame: 130,+ });+});diff --git a/packages/studio/src/test/easing-inspector-selection.test.ts b/packages/studio/src/test/easing-inspector-selection.test.tsnew file mode 100644index 0000000000..bc32d4f596--- /dev/null+++ b/packages/studio/src/test/easing-inspector-selection.test.ts@@ -0,0 +1,71 @@+import {expect, test} from 'bun:test';+import type {+ CanUpdateSequencePropStatusKeyframed,+ SequenceNodePath,+ SequencePropsSubscriptionKey,+} from 'remotion';+import {getEasingSelectionFromCurrentKeyframes} from '../components/InspectorPanel/easing-inspector-selection';+import type {SequenceNodePathInfo} from '../helpers/get-timeline-sequence-sort-key';++const makeNodePathInfo = (+ nodePath: SequenceNodePath,+ auxiliaryKeys: string[],+): SequenceNodePathInfo => ({+ sequenceSubscriptionKey: {+ absolutePath: '/project/src/Comp.tsx',+ nodePath,+ sequenceKeys: ['from', 'durationInFrames'],+ effectKeys: [],+ } satisfies SequencePropsSubscriptionKey,+ auxiliaryKeys,+ index: 0,+ numberOfSequencesWithThisNodePath: 1,+ supportsEffects: true,+});++const makeKeyframedStatus = (+ keyframes: {readonly frame: number; readonly value: number}[],+): CanUpdateSequencePropStatusKeyframed => ({+ status: 'keyframed',+ interpolationFunction: 'interpolate',+ keyframes,+ easing: [{type: 'linear'}, {type: 'linear'}],+ clamping: {left: 'extend', right: 'extend'},+ posterize: undefined,+});++test('derives easing selection endpoints from current keyframes', () => {+ const nodePathInfo = makeNodePathInfo(['body', 0], ['controls', 'opacity']);++ expect(+ getEasingSelectionFromCurrentKeyframes({+ keyframeDisplayOffset: 3,+ nodePathInfo,+ propStatus: makeKeyframedStatus([+ {frame: 0, value: 0},+ {frame: 14, value: 0.5},+ {frame: 30, value: 1},+ ]),+ segmentIndex: 1,+ }),+ ).toEqual({+ type: 'easing',+ nodePathInfo,+ fromFrame: 17,+ toFrame: 33,+ segmentIndex: 1,+ });+});++test('returns null when selected easing segment no longer exists', () => {+ const nodePathInfo = makeNodePathInfo(['body', 0], ['controls', 'opacity']);++ expect(+ getEasingSelectionFromCurrentKeyframes({+ keyframeDisplayOffset: 0,+ nodePathInfo,+ propStatus: makeKeyframedStatus([{frame: 0, value: 0}]),+ segmentIndex: 0,+ }),+ ).toBe(null);+});diff --git a/packages/studio/src/test/easing-selection-after-keyframe-delete.test.ts b/packages/studio/src/test/easing-selection-after-keyframe-delete.test.tsnew file mode 100644index 0000000000..90b7e5c8e0--- /dev/null+++ b/packages/studio/src/test/easing-selection-after-keyframe-delete.test.ts@@ -0,0 +1,71 @@+import {expect, test} from 'bun:test';+import type {+ CanUpdateSequencePropStatusKeyframed,+ SequenceNodePath,+ SequencePropsSubscriptionKey,+} from 'remotion';+import {getEasingSelectionAfterKeyframeDelete} from '../components/Timeline/get-easing-selection-after-keyframe-delete';+import type {SequenceNodePathInfo} from '../helpers/get-timeline-sequence-sort-key';++const makeNodePathInfo = (+ nodePath: SequenceNodePath,+ auxiliaryKeys: string[],+): SequenceNodePathInfo => ({+ sequenceSubscriptionKey: {+ absolutePath: '/project/src/Comp.tsx',+ nodePath,+ sequenceKeys: ['from', 'durationInFrames'],+ effectKeys: [],+ } satisfies SequencePropsSubscriptionKey,+ auxiliaryKeys,+ index: 0,+ numberOfSequencesWithThisNodePath: 1,+ supportsEffects: true,+});++const keyframedStatus = {+ status: 'keyframed',+ interpolationFunction: 'interpolate',+ keyframes: [+ {frame: 0, value: 0},+ {frame: 10, value: 0.5},+ {frame: 20, value: 1},+ ],+ easing: [{type: 'linear'}, {type: 'linear'}],+ clamping: {left: 'extend', right: 'extend'},+ posterize: undefined,+} satisfies CanUpdateSequencePropStatusKeyframed;++test('gets easing selection after deleting an in-between keyframe', () => {+ const nodePathInfo = makeNodePathInfo(['body', 0], ['controls', 'opacity']);++ expect(+ getEasingSelectionAfterKeyframeDelete({+ deletedSourceFrames: [10],+ keyframeDisplayOffset: 5,+ nodePathInfo,+ propStatus: keyframedStatus,+ timelinePosition: 15,+ }),+ ).toEqual({+ type: 'easing',+ nodePathInfo,+ fromFrame: 5,+ toFrame: 25,+ segmentIndex: 0,+ });+});++test('does not select an easing after deleting an edge keyframe', () => {+ const nodePathInfo = makeNodePathInfo(['body', 0], ['controls', 'opacity']);++ expect(+ getEasingSelectionAfterKeyframeDelete({+ deletedSourceFrames: [0],+ keyframeDisplayOffset: 5,+ nodePathInfo,+ propStatus: keyframedStatus,+ timelinePosition: 5,+ }),+ ).toBe(null);+});diff --git a/packages/studio/src/test/keyframe-easing-navigator.test.ts b/packages/studio/src/test/keyframe-easing-navigator.test.tsnew file mode 100644index 0000000000..2652e44fa9--- /dev/null+++ b/packages/studio/src/test/keyframe-easing-navigator.test.ts@@ -0,0 +1,100 @@+import {expect, test} from 'bun:test';+import {+ getKeyframeEasingNavigatorItems,+ getNavigatorItemPlayheadFrame,+} from '../components/InspectorPanel/keyframe-easing-navigator-items';+import type {SequenceNodePathInfo} from '../helpers/get-timeline-sequence-sort-key';++const nodePathInfo = {+ sequenceSubscriptionKey: {+ absolutePath: '/tmp/test.tsx',+ },+ auxiliaryKeys: ['controls', 'radius'],+ index: 0,+ numberOfSequencesWithThisNodePath: 1,+ supportsEffects: true,+} as SequenceNodePathInfo;++test('builds alternating keyframe and easing navigator items', () => {+ const items = getKeyframeEasingNavigatorItems({+ includeEasings: true,+ keyframes: [{frame: 10}, {frame: 30}, {frame: 50}],+ nodePathInfo,+ });++ expect(items.map((item) => item.type)).toEqual([+ 'keyframe',+ 'easing',+ 'keyframe',+ 'easing',+ 'keyframe',+ ]);+ expect(items[1]?.selection).toEqual({+ type: 'easing',+ nodePathInfo,+ fromFrame: 10,+ toFrame: 30,+ segmentIndex: 0,+ });+ expect(items[3]?.selection).toEqual({+ type: 'easing',+ nodePathInfo,+ fromFrame: 30,+ toFrame: 50,+ segmentIndex: 1,+ });+});++test('omits easing navigator items when easing cannot be selected', () => {+ const items = getKeyframeEasingNavigatorItems({+ includeEasings: false,+ keyframes: [{frame: 10}, {frame: 30}, {frame: 50}],+ nodePathInfo,+ });++ expect(items.map((item) => item.selection)).toEqual([+ {+ type: 'keyframe',+ nodePathInfo,+ frame: 10,+ },+ {+ type: 'keyframe',+ nodePathInfo,+ frame: 30,+ },+ {+ type: 'keyframe',+ nodePathInfo,+ frame: 50,+ },+ ]);+});++test('returns the keyframe frame as playhead target', () => {+ expect(+ getNavigatorItemPlayheadFrame({+ type: 'keyframe',+ selection: {+ type: 'keyframe',+ nodePathInfo,+ frame: 42,+ },+ }),+ ).toBe(42);+});++test('returns the easing midpoint as playhead target', () => {+ expect(+ getNavigatorItemPlayheadFrame({+ type: 'easing',+ selection: {+ type: 'easing',+ nodePathInfo,+ fromFrame: 10,+ toFrame: 31,+ segmentIndex: 0,+ },+ }),+ ).toBe(21);+});diff --git a/packages/studio/src/test/keyframe-inspector-frame.test.ts b/packages/studio/src/test/keyframe-inspector-frame.test.tsnew file mode 100644index 0000000000..d5c1813166--- /dev/null+++ b/packages/studio/src/test/keyframe-inspector-frame.test.ts@@ -0,0 +1,50 @@+import {expect, test} from 'bun:test';+import {+ clampInspectorKeyframeDisplayFrame,+ getInspectorKeyframeSourceFrame,+} from '../components/InspectorPanel/keyframe-inspector-frame';++test('clamps the inspector keyframe frame to the composition timeline', () => {+ expect(+ clampInspectorKeyframeDisplayFrame({+ durationInFrames: 50,+ frame: -12,+ }),+ ).toBe(0);+ expect(+ clampInspectorKeyframeDisplayFrame({+ durationInFrames: 50,+ frame: 12.4,+ }),+ ).toBe(12);+ expect(+ clampInspectorKeyframeDisplayFrame({+ durationInFrames: 50,+ frame: 12.5,+ }),+ ).toBe(13);+ expect(+ clampInspectorKeyframeDisplayFrame({+ durationInFrames: 50,+ frame: 80,+ }),+ ).toBe(49);+});++test('falls back to frame 0 if the composition has no duration', () => {+ expect(+ clampInspectorKeyframeDisplayFrame({+ durationInFrames: 0,+ frame: 12,+ }),+ ).toBe(0);+});++test('converts an inspector display frame to the source keyframe frame', () => {+ expect(+ getInspectorKeyframeSourceFrame({+ displayFrame: 40,+ keyframeDisplayOffset: 12,+ }),+ ).toBe(28);+});diff --git a/packages/studio/src/test/timeline-selection.test.ts b/packages/studio/src/test/timeline-selection.test.tsindex fba634fdcb..152b39db9b 100644--- a/packages/studio/src/test/timeline-selection.test.ts+++ b/packages/studio/src/test/timeline-selection.test.ts@@ -4509,13 +4509,15 @@ test('Deleting unsupported mixed timeline selection types returns null', () => {test('Deleting selected effects keeps their parent sequence selected', () => {const effectNodePathInfo = makeNodePathInfo(['body', 0], ['effects', '1']);- const result = getTimelineSelectionAfterDeletingItems([- {- type: 'sequence-effect',- nodePathInfo: effectNodePathInfo,- i: 1,- },- ]);+ const result = getTimelineSelectionAfterDeletingItems({+ selections: [+ {+ type: 'sequence-effect',+ nodePathInfo: effectNodePathInfo,+ i: 1,+ },+ ],+ });expect(result).toEqual([{@@ -4530,12 +4532,14 @@ test('Deleting selected effects keeps their parent sequence selected', () => {test('Deleting selected all-effects rows keeps their parent sequence selected', () => {const effectsNodePathInfo = makeNodePathInfo(['body', 0], ['effects']);- const result = getTimelineSelectionAfterDeletingItems([- {- type: 'sequence-all-effects',- nodePathInfo: effectsNodePathInfo,- },- ]);+ const result = getTimelineSelectionAfterDeletingItems({+ selections: [+ {+ type: 'sequence-all-effects',+ nodePathInfo: effectsNodePathInfo,+ },+ ],+ });expect(result).toEqual([{@@ -4552,9 +4556,111 @@ test('Deleting selected sequences still clears selection', () => {const sequenceNodePathInfo = makeNodePathInfo(['body', 0], []);expect(- getTimelineSelectionAfterDeletingItems([- {type: 'sequence', nodePathInfo: sequenceNodePathInfo},- ]),+ getTimelineSelectionAfterDeletingItems({+ selections: [{type: 'sequence', nodePathInfo: sequenceNodePathInfo}],+ }),+ ).toEqual([]);+});++test('Deleting selected keyframe selects remaining easing under playhead', () => {+ const schema = {+ opacity: {type: 'number', default: 1, hiddenFromList: false},+ } satisfies InteractivitySchema;+ const opacityNodePathInfo = makeNodePathInfo(+ ['body', 0],+ ['controls', 'opacity'],+ );+ const nodePath = opacityNodePathInfo.sequenceSubscriptionKey;+ const propStatuses = {+ [Internals.makeSequencePropsSubscriptionKey(nodePath)]: {+ canUpdate: true,+ props: {+ opacity: {+ status: 'keyframed',+ interpolationFunction: 'interpolate',+ keyframes: [+ {frame: 0, value: 0},+ {frame: 10, value: 0.5},+ {frame: 20, value: 1},+ ],+ easing: [{type: 'linear'}, {type: 'linear'}],+ clamping: {left: 'extend', right: 'extend'},+ posterize: undefined,+ },+ },+ effects: [],+ },+ } satisfies PropStatuses;++ expect(+ getTimelineSelectionAfterDeletingItems({+ selections: [+ {+ type: 'keyframe',+ nodePathInfo: opacityNodePathInfo,+ frame: 10,+ },+ ],+ sequences: [makeTimelineSequence({schema})],+ overrideIdsToNodePaths: {override: nodePath},+ propStatuses,+ timelinePosition: 10,+ }),+ ).toEqual([+ {+ type: 'easing',+ nodePathInfo: opacityNodePathInfo,+ fromFrame: 0,+ toFrame: 20,+ segmentIndex: 0,+ },+ ]);+});++test('Deleting selected keyframe clears selection when playhead is not between remaining keyframes', () => {+ const schema = {+ opacity: {type: 'number', default: 1, hiddenFromList: false},+ } satisfies InteractivitySchema;+ const opacityNodePathInfo = makeNodePathInfo(+ ['body', 0],+ ['controls', 'opacity'],+ );+ const nodePath = opacityNodePathInfo.sequenceSubscriptionKey;+ const propStatuses = {+ [Internals.makeSequencePropsSubscriptionKey(nodePath)]: {+ canUpdate: true,+ props: {+ opacity: {+ status: 'keyframed',+ interpolationFunction: 'interpolate',+ keyframes: [+ {frame: 0, value: 0},+ {frame: 10, value: 0.5},+ {frame: 20, value: 1},+ ],+ easing: [{type: 'linear'}, {type: 'linear'}],+ clamping: {left: 'extend', right: 'extend'},+ posterize: undefined,+ },+ },+ effects: [],+ },+ } satisfies PropStatuses;++ expect(+ getTimelineSelectionAfterDeletingItems({+ selections: [+ {+ type: 'keyframe',+ nodePathInfo: opacityNodePathInfo,+ frame: 0,+ },+ ],+ sequences: [makeTimelineSequence({schema})],+ overrideIdsToNodePaths: {override: nodePath},+ propStatuses,+ timelinePosition: 0,+ }),).toEqual([]);});